]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/iD/iD.js
b2d625139b956a972c1049303bb2844795aeae65
[rails.git] / vendor / assets / iD / iD.js
1 (() => {
2   var __create = Object.create;
3   var __defProp = Object.defineProperty;
4   var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5   var __getOwnPropNames = Object.getOwnPropertyNames;
6   var __getProtoOf = Object.getPrototypeOf;
7   var __hasOwnProp = Object.prototype.hasOwnProperty;
8   var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9   var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
10     get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
11   }) : x2)(function(x2) {
12     if (typeof require !== "undefined")
13       return require.apply(this, arguments);
14     throw Error('Dynamic require of "' + x2 + '" is not supported');
15   });
16   var __commonJS = (cb, mod) => function __require2() {
17     return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18   };
19   var __export = (target, all) => {
20     for (var name in all)
21       __defProp(target, name, { get: all[name], enumerable: true });
22   };
23   var __copyProps = (to, from, except, desc) => {
24     if (from && typeof from === "object" || typeof from === "function") {
25       for (let key of __getOwnPropNames(from))
26         if (!__hasOwnProp.call(to, key) && key !== except)
27           __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28     }
29     return to;
30   };
31   var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32     // If the importer is in node compatibility mode or this is not an ESM
33     // file that has been converted to a CommonJS file using a Babel-
34     // compatible transform (i.e. "__esModule" has not been set), then set
35     // "default" to the CommonJS "module.exports" for node compatibility.
36     isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37     mod
38   ));
39   var __publicField = (obj, key, value) => {
40     __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41     return value;
42   };
43   var __accessCheck = (obj, member, msg) => {
44     if (!member.has(obj))
45       throw TypeError("Cannot " + msg);
46   };
47   var __privateAdd = (obj, member, value) => {
48     if (member.has(obj))
49       throw TypeError("Cannot add the same private member more than once");
50     member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
51   };
52   var __privateMethod = (obj, member, method) => {
53     __accessCheck(obj, member, "access private method");
54     return method;
55   };
56
57   // node_modules/diacritics/index.js
58   var require_diacritics = __commonJS({
59     "node_modules/diacritics/index.js"(exports2) {
60       exports2.remove = removeDiacritics2;
61       var replacementList = [
62         {
63           base: " ",
64           chars: "\xA0"
65         },
66         {
67           base: "0",
68           chars: "\u07C0"
69         },
70         {
71           base: "A",
72           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"
73         },
74         {
75           base: "AA",
76           chars: "\uA732"
77         },
78         {
79           base: "AE",
80           chars: "\xC6\u01FC\u01E2"
81         },
82         {
83           base: "AO",
84           chars: "\uA734"
85         },
86         {
87           base: "AU",
88           chars: "\uA736"
89         },
90         {
91           base: "AV",
92           chars: "\uA738\uA73A"
93         },
94         {
95           base: "AY",
96           chars: "\uA73C"
97         },
98         {
99           base: "B",
100           chars: "\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0181"
101         },
102         {
103           base: "C",
104           chars: "\u24B8\uFF23\uA73E\u1E08\u0106C\u0108\u010A\u010C\xC7\u0187\u023B"
105         },
106         {
107           base: "D",
108           chars: "\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018A\u0189\u1D05\uA779"
109         },
110         {
111           base: "Dh",
112           chars: "\xD0"
113         },
114         {
115           base: "DZ",
116           chars: "\u01F1\u01C4"
117         },
118         {
119           base: "Dz",
120           chars: "\u01F2\u01C5"
121         },
122         {
123           base: "E",
124           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"
125         },
126         {
127           base: "F",
128           chars: "\uA77C\u24BB\uFF26\u1E1E\u0191\uA77B"
129         },
130         {
131           base: "G",
132           chars: "\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E\u0262"
133         },
134         {
135           base: "H",
136           chars: "\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
137         },
138         {
139           base: "I",
140           chars: "\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
141         },
142         {
143           base: "J",
144           chars: "\u24BF\uFF2A\u0134\u0248\u0237"
145         },
146         {
147           base: "K",
148           chars: "\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
149         },
150         {
151           base: "L",
152           chars: "\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
153         },
154         {
155           base: "LJ",
156           chars: "\u01C7"
157         },
158         {
159           base: "Lj",
160           chars: "\u01C8"
161         },
162         {
163           base: "M",
164           chars: "\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C\u03FB"
165         },
166         {
167           base: "N",
168           chars: "\uA7A4\u0220\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u019D\uA790\u1D0E"
169         },
170         {
171           base: "NJ",
172           chars: "\u01CA"
173         },
174         {
175           base: "Nj",
176           chars: "\u01CB"
177         },
178         {
179           base: "O",
180           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"
181         },
182         {
183           base: "OE",
184           chars: "\u0152"
185         },
186         {
187           base: "OI",
188           chars: "\u01A2"
189         },
190         {
191           base: "OO",
192           chars: "\uA74E"
193         },
194         {
195           base: "OU",
196           chars: "\u0222"
197         },
198         {
199           base: "P",
200           chars: "\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
201         },
202         {
203           base: "Q",
204           chars: "\u24C6\uFF31\uA756\uA758\u024A"
205         },
206         {
207           base: "R",
208           chars: "\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
209         },
210         {
211           base: "S",
212           chars: "\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
213         },
214         {
215           base: "T",
216           chars: "\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
217         },
218         {
219           base: "Th",
220           chars: "\xDE"
221         },
222         {
223           base: "TZ",
224           chars: "\uA728"
225         },
226         {
227           base: "U",
228           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"
229         },
230         {
231           base: "V",
232           chars: "\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
233         },
234         {
235           base: "VY",
236           chars: "\uA760"
237         },
238         {
239           base: "W",
240           chars: "\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
241         },
242         {
243           base: "X",
244           chars: "\u24CD\uFF38\u1E8A\u1E8C"
245         },
246         {
247           base: "Y",
248           chars: "\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
249         },
250         {
251           base: "Z",
252           chars: "\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
253         },
254         {
255           base: "a",
256           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"
257         },
258         {
259           base: "aa",
260           chars: "\uA733"
261         },
262         {
263           base: "ae",
264           chars: "\xE6\u01FD\u01E3"
265         },
266         {
267           base: "ao",
268           chars: "\uA735"
269         },
270         {
271           base: "au",
272           chars: "\uA737"
273         },
274         {
275           base: "av",
276           chars: "\uA739\uA73B"
277         },
278         {
279           base: "ay",
280           chars: "\uA73D"
281         },
282         {
283           base: "b",
284           chars: "\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253\u0182"
285         },
286         {
287           base: "c",
288           chars: "\uFF43\u24D2\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
289         },
290         {
291           base: "d",
292           chars: "\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\u018B\u13E7\u0501\uA7AA"
293         },
294         {
295           base: "dh",
296           chars: "\xF0"
297         },
298         {
299           base: "dz",
300           chars: "\u01F3\u01C6"
301         },
302         {
303           base: "e",
304           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"
305         },
306         {
307           base: "f",
308           chars: "\u24D5\uFF46\u1E1F\u0192"
309         },
310         {
311           base: "ff",
312           chars: "\uFB00"
313         },
314         {
315           base: "fi",
316           chars: "\uFB01"
317         },
318         {
319           base: "fl",
320           chars: "\uFB02"
321         },
322         {
323           base: "ffi",
324           chars: "\uFB03"
325         },
326         {
327           base: "ffl",
328           chars: "\uFB04"
329         },
330         {
331           base: "g",
332           chars: "\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\uA77F\u1D79"
333         },
334         {
335           base: "h",
336           chars: "\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
337         },
338         {
339           base: "hv",
340           chars: "\u0195"
341         },
342         {
343           base: "i",
344           chars: "\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
345         },
346         {
347           base: "j",
348           chars: "\u24D9\uFF4A\u0135\u01F0\u0249"
349         },
350         {
351           base: "k",
352           chars: "\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
353         },
354         {
355           base: "l",
356           chars: "\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747\u026D"
357         },
358         {
359           base: "lj",
360           chars: "\u01C9"
361         },
362         {
363           base: "m",
364           chars: "\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
365         },
366         {
367           base: "n",
368           chars: "\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5\u043B\u0509"
369         },
370         {
371           base: "nj",
372           chars: "\u01CC"
373         },
374         {
375           base: "o",
376           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"
377         },
378         {
379           base: "oe",
380           chars: "\u0153"
381         },
382         {
383           base: "oi",
384           chars: "\u01A3"
385         },
386         {
387           base: "oo",
388           chars: "\uA74F"
389         },
390         {
391           base: "ou",
392           chars: "\u0223"
393         },
394         {
395           base: "p",
396           chars: "\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755\u03C1"
397         },
398         {
399           base: "q",
400           chars: "\u24E0\uFF51\u024B\uA757\uA759"
401         },
402         {
403           base: "r",
404           chars: "\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
405         },
406         {
407           base: "s",
408           chars: "\u24E2\uFF53\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B\u0282"
409         },
410         {
411           base: "ss",
412           chars: "\xDF"
413         },
414         {
415           base: "t",
416           chars: "\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
417         },
418         {
419           base: "th",
420           chars: "\xFE"
421         },
422         {
423           base: "tz",
424           chars: "\uA729"
425         },
426         {
427           base: "u",
428           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"
429         },
430         {
431           base: "v",
432           chars: "\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
433         },
434         {
435           base: "vy",
436           chars: "\uA761"
437         },
438         {
439           base: "w",
440           chars: "\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
441         },
442         {
443           base: "x",
444           chars: "\u24E7\uFF58\u1E8B\u1E8D"
445         },
446         {
447           base: "y",
448           chars: "\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
449         },
450         {
451           base: "z",
452           chars: "\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
453         }
454       ];
455       var diacriticsMap = {};
456       for (i3 = 0; i3 < replacementList.length; i3 += 1) {
457         chars = replacementList[i3].chars;
458         for (j2 = 0; j2 < chars.length; j2 += 1) {
459           diacriticsMap[chars[j2]] = replacementList[i3].base;
460         }
461       }
462       var chars;
463       var j2;
464       var i3;
465       function removeDiacritics2(str) {
466         return str.replace(/[^\u0000-\u007e]/g, function(c2) {
467           return diacriticsMap[c2] || c2;
468         });
469       }
470       exports2.replacementList = replacementList;
471       exports2.diacriticsMap = diacriticsMap;
472     }
473   });
474
475   // node_modules/alif-toolkit/lib/isArabic.js
476   var require_isArabic = __commonJS({
477     "node_modules/alif-toolkit/lib/isArabic.js"(exports2) {
478       "use strict";
479       Object.defineProperty(exports2, "__esModule", { value: true });
480       var arabicBlocks = [
481         [1536, 1791],
482         [1872, 1919],
483         [2208, 2303],
484         [64336, 65023],
485         [65136, 65279],
486         [69216, 69247],
487         [126064, 126143],
488         [126464, 126719]
489         // Mathematical Alphabetic symbols https://www.unicode.org/charts/PDF/U1EE00.pdf
490       ];
491       function isArabic(char) {
492         if (char.length > 1) {
493           throw new Error("isArabic works on only one-character strings");
494         }
495         let code = char.charCodeAt(0);
496         for (let i3 = 0; i3 < arabicBlocks.length; i3++) {
497           let block2 = arabicBlocks[i3];
498           if (code >= block2[0] && code <= block2[1]) {
499             return true;
500           }
501         }
502         return false;
503       }
504       exports2.isArabic = isArabic;
505       function isMath(char) {
506         if (char.length > 2) {
507           throw new Error("isMath works on only one-character strings");
508         }
509         let code = char.charCodeAt(0);
510         return code >= 1632 && code <= 1644 || code >= 1776 && code <= 1785;
511       }
512       exports2.isMath = isMath;
513     }
514   });
515
516   // node_modules/alif-toolkit/lib/unicode-arabic.js
517   var require_unicode_arabic = __commonJS({
518     "node_modules/alif-toolkit/lib/unicode-arabic.js"(exports2) {
519       "use strict";
520       Object.defineProperty(exports2, "__esModule", { value: true });
521       var arabicReference = {
522         "alef": {
523           "normal": [
524             "\u0627"
525           ],
526           "madda_above": {
527             "normal": [
528               "\u0627\u0653",
529               "\u0622"
530             ],
531             "isolated": "\uFE81",
532             "final": "\uFE82"
533           },
534           "hamza_above": {
535             "normal": [
536               "\u0627\u0654",
537               "\u0623"
538             ],
539             "isolated": "\uFE83",
540             "final": "\uFE84"
541           },
542           "hamza_below": {
543             "normal": [
544               "\u0627\u0655",
545               "\u0625"
546             ],
547             "isolated": "\uFE87",
548             "final": "\uFE88"
549           },
550           "wasla": {
551             "normal": "\u0671",
552             "isolated": "\uFB50",
553             "final": "\uFB51"
554           },
555           "wavy_hamza_above": [
556             "\u0672"
557           ],
558           "wavy_hamza_below": [
559             "\u0627\u065F",
560             "\u0673"
561           ],
562           "high_hamza": [
563             "\u0675",
564             "\u0627\u0674"
565           ],
566           "indic_two_above": [
567             "\u0773"
568           ],
569           "indic_three_above": [
570             "\u0774"
571           ],
572           "fathatan": {
573             "normal": [
574               "\u0627\u064B"
575             ],
576             "final": "\uFD3C",
577             "isolated": "\uFD3D"
578           },
579           "isolated": "\uFE8D",
580           "final": "\uFE8E"
581         },
582         "beh": {
583           "normal": [
584             "\u0628"
585           ],
586           "dotless": [
587             "\u066E"
588           ],
589           "three_dots_horizontally_below": [
590             "\u0750"
591           ],
592           "dot_below_three_dots_above": [
593             "\u0751"
594           ],
595           "three_dots_pointing_upwards_below": [
596             "\u0752"
597           ],
598           "three_dots_pointing_upwards_below_two_dots_above": [
599             "\u0753"
600           ],
601           "two_dots_below_dot_above": [
602             "\u0754"
603           ],
604           "inverted_small_v_below": [
605             "\u0755"
606           ],
607           "small_v": [
608             "\u0756"
609           ],
610           "small_v_below": [
611             "\u08A0"
612           ],
613           "hamza_above": [
614             "\u08A1"
615           ],
616           "small_meem_above": [
617             "\u08B6"
618           ],
619           "isolated": "\uFE8F",
620           "final": "\uFE90",
621           "initial": "\uFE91",
622           "medial": "\uFE92"
623         },
624         "teh marbuta": {
625           "normal": [
626             "\u0629"
627           ],
628           "isolated": "\uFE93",
629           "final": "\uFE94"
630         },
631         "teh": {
632           "normal": [
633             "\u062A"
634           ],
635           "ring": [
636             "\u067C"
637           ],
638           "three_dots_above_downwards": [
639             "\u067D"
640           ],
641           "small_teh_above": [
642             "\u08B8"
643           ],
644           "isolated": "\uFE95",
645           "final": "\uFE96",
646           "initial": "\uFE97",
647           "medial": "\uFE98"
648         },
649         "theh": {
650           "normal": [
651             "\u062B"
652           ],
653           "isolated": "\uFE99",
654           "final": "\uFE9A",
655           "initial": "\uFE9B",
656           "medial": "\uFE9C"
657         },
658         "jeem": {
659           "normal": [
660             "\u062C"
661           ],
662           "two_dots_above": [
663             "\u08A2"
664           ],
665           "isolated": "\uFE9D",
666           "final": "\uFE9E",
667           "initial": "\uFE9F",
668           "medial": "\uFEA0"
669         },
670         "hah": {
671           "normal": [
672             "\u062D"
673           ],
674           "hamza_above": [
675             "\u0681"
676           ],
677           "two_dots_vertical_above": [
678             "\u0682"
679           ],
680           "three_dots_above": [
681             "\u0685"
682           ],
683           "two_dots_above": [
684             "\u0757"
685           ],
686           "three_dots_pointing_upwards_below": [
687             "\u0758"
688           ],
689           "small_tah_below": [
690             "\u076E"
691           ],
692           "small_tah_two_dots": [
693             "\u076F"
694           ],
695           "small_tah_above": [
696             "\u0772"
697           ],
698           "indic_four_below": [
699             "\u077C"
700           ],
701           "isolated": "\uFEA1",
702           "final": "\uFEA2",
703           "initial": "\uFEA3",
704           "medial": "\uFEA4"
705         },
706         "khah": {
707           "normal": [
708             "\u062E"
709           ],
710           "isolated": "\uFEA5",
711           "final": "\uFEA6",
712           "initial": "\uFEA7",
713           "medial": "\uFEA8"
714         },
715         "dal": {
716           "normal": [
717             "\u062F"
718           ],
719           "ring": [
720             "\u0689"
721           ],
722           "dot_below": [
723             "\u068A"
724           ],
725           "dot_below_small_tah": [
726             "\u068B"
727           ],
728           "three_dots_above_downwards": [
729             "\u068F"
730           ],
731           "four_dots_above": [
732             "\u0690"
733           ],
734           "inverted_v": [
735             "\u06EE"
736           ],
737           "two_dots_vertically_below_small_tah": [
738             "\u0759"
739           ],
740           "inverted_small_v_below": [
741             "\u075A"
742           ],
743           "three_dots_below": [
744             "\u08AE"
745           ],
746           "isolated": "\uFEA9",
747           "final": "\uFEAA"
748         },
749         "thal": {
750           "normal": [
751             "\u0630"
752           ],
753           "isolated": "\uFEAB",
754           "final": "\uFEAC"
755         },
756         "reh": {
757           "normal": [
758             "\u0631"
759           ],
760           "small_v": [
761             "\u0692"
762           ],
763           "ring": [
764             "\u0693"
765           ],
766           "dot_below": [
767             "\u0694"
768           ],
769           "small_v_below": [
770             "\u0695"
771           ],
772           "dot_below_dot_above": [
773             "\u0696"
774           ],
775           "two_dots_above": [
776             "\u0697"
777           ],
778           "four_dots_above": [
779             "\u0699"
780           ],
781           "inverted_v": [
782             "\u06EF"
783           ],
784           "stroke": [
785             "\u075B"
786           ],
787           "two_dots_vertically_above": [
788             "\u076B"
789           ],
790           "hamza_above": [
791             "\u076C"
792           ],
793           "small_tah_two_dots": [
794             "\u0771"
795           ],
796           "loop": [
797             "\u08AA"
798           ],
799           "small_noon_above": [
800             "\u08B9"
801           ],
802           "isolated": "\uFEAD",
803           "final": "\uFEAE"
804         },
805         "zain": {
806           "normal": [
807             "\u0632"
808           ],
809           "inverted_v_above": [
810             "\u08B2"
811           ],
812           "isolated": "\uFEAF",
813           "final": "\uFEB0"
814         },
815         "seen": {
816           "normal": [
817             "\u0633"
818           ],
819           "dot_below_dot_above": [
820             "\u069A"
821           ],
822           "three_dots_below": [
823             "\u069B"
824           ],
825           "three_dots_below_three_dots_above": [
826             "\u069C"
827           ],
828           "four_dots_above": [
829             "\u075C"
830           ],
831           "two_dots_vertically_above": [
832             "\u076D"
833           ],
834           "small_tah_two_dots": [
835             "\u0770"
836           ],
837           "indic_four_above": [
838             "\u077D"
839           ],
840           "inverted_v": [
841             "\u077E"
842           ],
843           "isolated": "\uFEB1",
844           "final": "\uFEB2",
845           "initial": "\uFEB3",
846           "medial": "\uFEB4"
847         },
848         "sheen": {
849           "normal": [
850             "\u0634"
851           ],
852           "dot_below": [
853             "\u06FA"
854           ],
855           "isolated": "\uFEB5",
856           "final": "\uFEB6",
857           "initial": "\uFEB7",
858           "medial": "\uFEB8"
859         },
860         "sad": {
861           "normal": [
862             "\u0635"
863           ],
864           "two_dots_below": [
865             "\u069D"
866           ],
867           "three_dots_above": [
868             "\u069E"
869           ],
870           "three_dots_below": [
871             "\u08AF"
872           ],
873           "isolated": "\uFEB9",
874           "final": "\uFEBA",
875           "initial": "\uFEBB",
876           "medial": "\uFEBC"
877         },
878         "dad": {
879           "normal": [
880             "\u0636"
881           ],
882           "dot_below": [
883             "\u06FB"
884           ],
885           "isolated": "\uFEBD",
886           "final": "\uFEBE",
887           "initial": "\uFEBF",
888           "medial": "\uFEC0"
889         },
890         "tah": {
891           "normal": [
892             "\u0637"
893           ],
894           "three_dots_above": [
895             "\u069F"
896           ],
897           "two_dots_above": [
898             "\u08A3"
899           ],
900           "isolated": "\uFEC1",
901           "final": "\uFEC2",
902           "initial": "\uFEC3",
903           "medial": "\uFEC4"
904         },
905         "zah": {
906           "normal": [
907             "\u0638"
908           ],
909           "isolated": "\uFEC5",
910           "final": "\uFEC6",
911           "initial": "\uFEC7",
912           "medial": "\uFEC8"
913         },
914         "ain": {
915           "normal": [
916             "\u0639"
917           ],
918           "three_dots_above": [
919             "\u06A0"
920           ],
921           "two_dots_above": [
922             "\u075D"
923           ],
924           "three_dots_pointing_downwards_above": [
925             "\u075E"
926           ],
927           "two_dots_vertically_above": [
928             "\u075F"
929           ],
930           "three_dots_below": [
931             "\u08B3"
932           ],
933           "isolated": "\uFEC9",
934           "final": "\uFECA",
935           "initial": "\uFECB",
936           "medial": "\uFECC"
937         },
938         "ghain": {
939           "normal": [
940             "\u063A"
941           ],
942           "dot_below": [
943             "\u06FC"
944           ],
945           "isolated": "\uFECD",
946           "final": "\uFECE",
947           "initial": "\uFECF",
948           "medial": "\uFED0"
949         },
950         "feh": {
951           "normal": [
952             "\u0641"
953           ],
954           "dotless": [
955             "\u06A1"
956           ],
957           "dot_moved_below": [
958             "\u06A2"
959           ],
960           "dot_below": [
961             "\u06A3"
962           ],
963           "three_dots_below": [
964             "\u06A5"
965           ],
966           "two_dots_below": [
967             "\u0760"
968           ],
969           "three_dots_pointing_upwards_below": [
970             "\u0761"
971           ],
972           "dot_below_three_dots_above": [
973             "\u08A4"
974           ],
975           "isolated": "\uFED1",
976           "final": "\uFED2",
977           "initial": "\uFED3",
978           "medial": "\uFED4"
979         },
980         "qaf": {
981           "normal": [
982             "\u0642"
983           ],
984           "dotless": [
985             "\u066F"
986           ],
987           "dot_above": [
988             "\u06A7"
989           ],
990           "three_dots_above": [
991             "\u06A8"
992           ],
993           "dot_below": [
994             "\u08A5"
995           ],
996           "isolated": "\uFED5",
997           "final": "\uFED6",
998           "initial": "\uFED7",
999           "medial": "\uFED8"
1000         },
1001         "kaf": {
1002           "normal": [
1003             "\u0643"
1004           ],
1005           "swash": [
1006             "\u06AA"
1007           ],
1008           "ring": [
1009             "\u06AB"
1010           ],
1011           "dot_above": [
1012             "\u06AC"
1013           ],
1014           "three_dots_below": [
1015             "\u06AE"
1016           ],
1017           "two_dots_above": [
1018             "\u077F"
1019           ],
1020           "dot_below": [
1021             "\u08B4"
1022           ],
1023           "isolated": "\uFED9",
1024           "final": "\uFEDA",
1025           "initial": "\uFEDB",
1026           "medial": "\uFEDC"
1027         },
1028         "lam": {
1029           "normal": [
1030             "\u0644"
1031           ],
1032           "small_v": [
1033             "\u06B5"
1034           ],
1035           "dot_above": [
1036             "\u06B6"
1037           ],
1038           "three_dots_above": [
1039             "\u06B7"
1040           ],
1041           "three_dots_below": [
1042             "\u06B8"
1043           ],
1044           "bar": [
1045             "\u076A"
1046           ],
1047           "double_bar": [
1048             "\u08A6"
1049           ],
1050           "isolated": "\uFEDD",
1051           "final": "\uFEDE",
1052           "initial": "\uFEDF",
1053           "medial": "\uFEE0"
1054         },
1055         "meem": {
1056           "normal": [
1057             "\u0645"
1058           ],
1059           "dot_above": [
1060             "\u0765"
1061           ],
1062           "dot_below": [
1063             "\u0766"
1064           ],
1065           "three_dots_above": [
1066             "\u08A7"
1067           ],
1068           "isolated": "\uFEE1",
1069           "final": "\uFEE2",
1070           "initial": "\uFEE3",
1071           "medial": "\uFEE4"
1072         },
1073         "noon": {
1074           "normal": [
1075             "\u0646"
1076           ],
1077           "dot_below": [
1078             "\u06B9"
1079           ],
1080           "ring": [
1081             "\u06BC"
1082           ],
1083           "three_dots_above": [
1084             "\u06BD"
1085           ],
1086           "two_dots_below": [
1087             "\u0767"
1088           ],
1089           "small_tah": [
1090             "\u0768"
1091           ],
1092           "small_v": [
1093             "\u0769"
1094           ],
1095           "isolated": "\uFEE5",
1096           "final": "\uFEE6",
1097           "initial": "\uFEE7",
1098           "medial": "\uFEE8"
1099         },
1100         "heh": {
1101           "normal": [
1102             "\u0647"
1103           ],
1104           "isolated": "\uFEE9",
1105           "final": "\uFEEA",
1106           "initial": "\uFEEB",
1107           "medial": "\uFEEC"
1108         },
1109         "waw": {
1110           "normal": [
1111             "\u0648"
1112           ],
1113           "hamza_above": {
1114             "normal": [
1115               "\u0624",
1116               "\u0648\u0654"
1117             ],
1118             "isolated": "\uFE85",
1119             "final": "\uFE86"
1120           },
1121           "high_hamza": [
1122             "\u0676",
1123             "\u0648\u0674"
1124           ],
1125           "ring": [
1126             "\u06C4"
1127           ],
1128           "two_dots_above": [
1129             "\u06CA"
1130           ],
1131           "dot_above": [
1132             "\u06CF"
1133           ],
1134           "indic_two_above": [
1135             "\u0778"
1136           ],
1137           "indic_three_above": [
1138             "\u0779"
1139           ],
1140           "dot_within": [
1141             "\u08AB"
1142           ],
1143           "isolated": "\uFEED",
1144           "final": "\uFEEE"
1145         },
1146         "alef_maksura": {
1147           "normal": [
1148             "\u0649"
1149           ],
1150           "hamza_above": [
1151             "\u0626",
1152             "\u064A\u0654"
1153           ],
1154           "initial": "\uFBE8",
1155           "medial": "\uFBE9",
1156           "isolated": "\uFEEF",
1157           "final": "\uFEF0"
1158         },
1159         "yeh": {
1160           "normal": [
1161             "\u064A"
1162           ],
1163           "hamza_above": {
1164             "normal": [
1165               "\u0626",
1166               "\u0649\u0654"
1167             ],
1168             "isolated": "\uFE89",
1169             "final": "\uFE8A",
1170             "initial": "\uFE8B",
1171             "medial": "\uFE8C"
1172           },
1173           "two_dots_below_hamza_above": [
1174             "\u08A8"
1175           ],
1176           "high_hamza": [
1177             "\u0678",
1178             "\u064A\u0674"
1179           ],
1180           "tail": [
1181             "\u06CD"
1182           ],
1183           "small_v": [
1184             "\u06CE"
1185           ],
1186           "three_dots_below": [
1187             "\u06D1"
1188           ],
1189           "two_dots_below_dot_above": [
1190             "\u08A9"
1191           ],
1192           "two_dots_below_small_noon_above": [
1193             "\u08BA"
1194           ],
1195           "isolated": "\uFEF1",
1196           "final": "\uFEF2",
1197           "initial": "\uFEF3",
1198           "medial": "\uFEF4"
1199         },
1200         "tteh": {
1201           "normal": [
1202             "\u0679"
1203           ],
1204           "isolated": "\uFB66",
1205           "final": "\uFB67",
1206           "initial": "\uFB68",
1207           "medial": "\uFB69"
1208         },
1209         "tteheh": {
1210           "normal": [
1211             "\u067A"
1212           ],
1213           "isolated": "\uFB5E",
1214           "final": "\uFB5F",
1215           "initial": "\uFB60",
1216           "medial": "\uFB61"
1217         },
1218         "beeh": {
1219           "normal": [
1220             "\u067B"
1221           ],
1222           "isolated": "\uFB52",
1223           "final": "\uFB53",
1224           "initial": "\uFB54",
1225           "medial": "\uFB55"
1226         },
1227         "peh": {
1228           "normal": [
1229             "\u067E"
1230           ],
1231           "small_meem_above": [
1232             "\u08B7"
1233           ],
1234           "isolated": "\uFB56",
1235           "final": "\uFB57",
1236           "initial": "\uFB58",
1237           "medial": "\uFB59"
1238         },
1239         "teheh": {
1240           "normal": [
1241             "\u067F"
1242           ],
1243           "isolated": "\uFB62",
1244           "final": "\uFB63",
1245           "initial": "\uFB64",
1246           "medial": "\uFB65"
1247         },
1248         "beheh": {
1249           "normal": [
1250             "\u0680"
1251           ],
1252           "isolated": "\uFB5A",
1253           "final": "\uFB5B",
1254           "initial": "\uFB5C",
1255           "medial": "\uFB5D"
1256         },
1257         "nyeh": {
1258           "normal": [
1259             "\u0683"
1260           ],
1261           "isolated": "\uFB76",
1262           "final": "\uFB77",
1263           "initial": "\uFB78",
1264           "medial": "\uFB79"
1265         },
1266         "dyeh": {
1267           "normal": [
1268             "\u0684"
1269           ],
1270           "isolated": "\uFB72",
1271           "final": "\uFB73",
1272           "initial": "\uFB74",
1273           "medial": "\uFB75"
1274         },
1275         "tcheh": {
1276           "normal": [
1277             "\u0686"
1278           ],
1279           "dot_above": [
1280             "\u06BF"
1281           ],
1282           "isolated": "\uFB7A",
1283           "final": "\uFB7B",
1284           "initial": "\uFB7C",
1285           "medial": "\uFB7D"
1286         },
1287         "tcheheh": {
1288           "normal": [
1289             "\u0687"
1290           ],
1291           "isolated": "\uFB7E",
1292           "final": "\uFB7F",
1293           "initial": "\uFB80",
1294           "medial": "\uFB81"
1295         },
1296         "ddal": {
1297           "normal": [
1298             "\u0688"
1299           ],
1300           "isolated": "\uFB88",
1301           "final": "\uFB89"
1302         },
1303         "dahal": {
1304           "normal": [
1305             "\u068C"
1306           ],
1307           "isolated": "\uFB84",
1308           "final": "\uFB85"
1309         },
1310         "ddahal": {
1311           "normal": [
1312             "\u068D"
1313           ],
1314           "isolated": "\uFB82",
1315           "final": "\uFB83"
1316         },
1317         "dul": {
1318           "normal": [
1319             "\u068F",
1320             "\u068E"
1321           ],
1322           "isolated": "\uFB86",
1323           "final": "\uFB87"
1324         },
1325         "rreh": {
1326           "normal": [
1327             "\u0691"
1328           ],
1329           "isolated": "\uFB8C",
1330           "final": "\uFB8D"
1331         },
1332         "jeh": {
1333           "normal": [
1334             "\u0698"
1335           ],
1336           "isolated": "\uFB8A",
1337           "final": "\uFB8B"
1338         },
1339         "veh": {
1340           "normal": [
1341             "\u06A4"
1342           ],
1343           "isolated": "\uFB6A",
1344           "final": "\uFB6B",
1345           "initial": "\uFB6C",
1346           "medial": "\uFB6D"
1347         },
1348         "peheh": {
1349           "normal": [
1350             "\u06A6"
1351           ],
1352           "isolated": "\uFB6E",
1353           "final": "\uFB6F",
1354           "initial": "\uFB70",
1355           "medial": "\uFB71"
1356         },
1357         "keheh": {
1358           "normal": [
1359             "\u06A9"
1360           ],
1361           "dot_above": [
1362             "\u0762"
1363           ],
1364           "three_dots_above": [
1365             "\u0763"
1366           ],
1367           "three_dots_pointing_upwards_below": [
1368             "\u0764"
1369           ],
1370           "isolated": "\uFB8E",
1371           "final": "\uFB8F",
1372           "initial": "\uFB90",
1373           "medial": "\uFB91"
1374         },
1375         "ng": {
1376           "normal": [
1377             "\u06AD"
1378           ],
1379           "isolated": "\uFBD3",
1380           "final": "\uFBD4",
1381           "initial": "\uFBD5",
1382           "medial": "\uFBD6"
1383         },
1384         "gaf": {
1385           "normal": [
1386             "\u06AF"
1387           ],
1388           "ring": [
1389             "\u06B0"
1390           ],
1391           "two_dots_below": [
1392             "\u06B2"
1393           ],
1394           "three_dots_above": [
1395             "\u06B4"
1396           ],
1397           "inverted_stroke": [
1398             "\u08B0"
1399           ],
1400           "isolated": "\uFB92",
1401           "final": "\uFB93",
1402           "initial": "\uFB94",
1403           "medial": "\uFB95"
1404         },
1405         "ngoeh": {
1406           "normal": [
1407             "\u06B1"
1408           ],
1409           "isolated": "\uFB9A",
1410           "final": "\uFB9B",
1411           "initial": "\uFB9C",
1412           "medial": "\uFB9D"
1413         },
1414         "gueh": {
1415           "normal": [
1416             "\u06B3"
1417           ],
1418           "isolated": "\uFB96",
1419           "final": "\uFB97",
1420           "initial": "\uFB98",
1421           "medial": "\uFB99"
1422         },
1423         "noon ghunna": {
1424           "normal": [
1425             "\u06BA"
1426           ],
1427           "isolated": "\uFB9E",
1428           "final": "\uFB9F"
1429         },
1430         "rnoon": {
1431           "normal": [
1432             "\u06BB"
1433           ],
1434           "isolated": "\uFBA0",
1435           "final": "\uFBA1",
1436           "initial": "\uFBA2",
1437           "medial": "\uFBA3"
1438         },
1439         "heh doachashmee": {
1440           "normal": [
1441             "\u06BE"
1442           ],
1443           "isolated": "\uFBAA",
1444           "final": "\uFBAB",
1445           "initial": "\uFBAC",
1446           "medial": "\uFBAD"
1447         },
1448         "heh goal": {
1449           "normal": [
1450             "\u06C1"
1451           ],
1452           "hamza_above": [
1453             "\u06C1\u0654",
1454             "\u06C2"
1455           ],
1456           "isolated": "\uFBA6",
1457           "final": "\uFBA7",
1458           "initial": "\uFBA8",
1459           "medial": "\uFBA9"
1460         },
1461         "teh marbuta goal": {
1462           "normal": [
1463             "\u06C3"
1464           ]
1465         },
1466         "kirghiz oe": {
1467           "normal": [
1468             "\u06C5"
1469           ],
1470           "isolated": "\uFBE0",
1471           "final": "\uFBE1"
1472         },
1473         "oe": {
1474           "normal": [
1475             "\u06C6"
1476           ],
1477           "isolated": "\uFBD9",
1478           "final": "\uFBDA"
1479         },
1480         "u": {
1481           "normal": [
1482             "\u06C7"
1483           ],
1484           "hamza_above": {
1485             "normal": [
1486               "\u0677",
1487               "\u06C7\u0674"
1488             ],
1489             "isolated": "\uFBDD"
1490           },
1491           "isolated": "\uFBD7",
1492           "final": "\uFBD8"
1493         },
1494         "yu": {
1495           "normal": [
1496             "\u06C8"
1497           ],
1498           "isolated": "\uFBDB",
1499           "final": "\uFBDC"
1500         },
1501         "kirghiz yu": {
1502           "normal": [
1503             "\u06C9"
1504           ],
1505           "isolated": "\uFBE2",
1506           "final": "\uFBE3"
1507         },
1508         "ve": {
1509           "normal": [
1510             "\u06CB"
1511           ],
1512           "isolated": "\uFBDE",
1513           "final": "\uFBDF"
1514         },
1515         "farsi yeh": {
1516           "normal": [
1517             "\u06CC"
1518           ],
1519           "indic_two_above": [
1520             "\u0775"
1521           ],
1522           "indic_three_above": [
1523             "\u0776"
1524           ],
1525           "indic_four_above": [
1526             "\u0777"
1527           ],
1528           "isolated": "\uFBFC",
1529           "final": "\uFBFD",
1530           "initial": "\uFBFE",
1531           "medial": "\uFBFF"
1532         },
1533         "e": {
1534           "normal": [
1535             "\u06D0"
1536           ],
1537           "isolated": "\uFBE4",
1538           "final": "\uFBE5",
1539           "initial": "\uFBE6",
1540           "medial": "\uFBE7"
1541         },
1542         "yeh barree": {
1543           "normal": [
1544             "\u06D2"
1545           ],
1546           "hamza_above": {
1547             "normal": [
1548               "\u06D2\u0654",
1549               "\u06D3"
1550             ],
1551             "isolated": "\uFBB0",
1552             "final": "\uFBB1"
1553           },
1554           "indic_two_above": [
1555             "\u077A"
1556           ],
1557           "indic_three_above": [
1558             "\u077B"
1559           ],
1560           "isolated": "\uFBAE",
1561           "final": "\uFBAF"
1562         },
1563         "ae": {
1564           "normal": [
1565             "\u06D5"
1566           ],
1567           "isolated": "\u06D5",
1568           "final": "\uFEEA",
1569           "yeh_above": {
1570             "normal": [
1571               "\u06C0",
1572               "\u06D5\u0654"
1573             ],
1574             "isolated": "\uFBA4",
1575             "final": "\uFBA5"
1576           }
1577         },
1578         "rohingya yeh": {
1579           "normal": [
1580             "\u08AC"
1581           ]
1582         },
1583         "low alef": {
1584           "normal": [
1585             "\u08AD"
1586           ]
1587         },
1588         "straight waw": {
1589           "normal": [
1590             "\u08B1"
1591           ]
1592         },
1593         "african feh": {
1594           "normal": [
1595             "\u08BB"
1596           ]
1597         },
1598         "african qaf": {
1599           "normal": [
1600             "\u08BC"
1601           ]
1602         },
1603         "african noon": {
1604           "normal": [
1605             "\u08BD"
1606           ]
1607         }
1608       };
1609       exports2.default = arabicReference;
1610     }
1611   });
1612
1613   // node_modules/alif-toolkit/lib/unicode-ligatures.js
1614   var require_unicode_ligatures = __commonJS({
1615     "node_modules/alif-toolkit/lib/unicode-ligatures.js"(exports2) {
1616       "use strict";
1617       Object.defineProperty(exports2, "__esModule", { value: true });
1618       var ligatureReference = {
1619         "\u0626\u0627": {
1620           "isolated": "\uFBEA",
1621           "final": "\uFBEB"
1622         },
1623         "\u0626\u06D5": {
1624           "isolated": "\uFBEC",
1625           "final": "\uFBED"
1626         },
1627         "\u0626\u0648": {
1628           "isolated": "\uFBEE",
1629           "final": "\uFBEF"
1630         },
1631         "\u0626\u06C7": {
1632           "isolated": "\uFBF0",
1633           "final": "\uFBF1"
1634         },
1635         "\u0626\u06C6": {
1636           "isolated": "\uFBF2",
1637           "final": "\uFBF3"
1638         },
1639         "\u0626\u06C8": {
1640           "isolated": "\uFBF4",
1641           "final": "\uFBF5"
1642         },
1643         "\u0626\u06D0": {
1644           "isolated": "\uFBF6",
1645           "final": "\uFBF7",
1646           "initial": "\uFBF8"
1647         },
1648         "\u0626\u0649": {
1649           "uighur_kirghiz": {
1650             "isolated": "\uFBF9",
1651             "final": "\uFBFA",
1652             "initial": "\uFBFB"
1653           },
1654           "isolated": "\uFC03",
1655           "final": "\uFC68"
1656         },
1657         "\u0626\u062C": {
1658           "isolated": "\uFC00",
1659           "initial": "\uFC97"
1660         },
1661         "\u0626\u062D": {
1662           "isolated": "\uFC01",
1663           "initial": "\uFC98"
1664         },
1665         "\u0626\u0645": {
1666           "isolated": "\uFC02",
1667           "final": "\uFC66",
1668           "initial": "\uFC9A",
1669           "medial": "\uFCDF"
1670         },
1671         "\u0626\u064A": {
1672           "isolated": "\uFC04",
1673           "final": "\uFC69"
1674         },
1675         "\u0628\u062C": {
1676           "isolated": "\uFC05",
1677           "initial": "\uFC9C"
1678         },
1679         "\u0628\u062D": {
1680           "isolated": "\uFC06",
1681           "initial": "\uFC9D"
1682         },
1683         "\u0628\u062E": {
1684           "isolated": "\uFC07",
1685           "initial": "\uFC9E"
1686         },
1687         "\u0628\u0645": {
1688           "isolated": "\uFC08",
1689           "final": "\uFC6C",
1690           "initial": "\uFC9F",
1691           "medial": "\uFCE1"
1692         },
1693         "\u0628\u0649": {
1694           "isolated": "\uFC09",
1695           "final": "\uFC6E"
1696         },
1697         "\u0628\u064A": {
1698           "isolated": "\uFC0A",
1699           "final": "\uFC6F"
1700         },
1701         "\u062A\u062C": {
1702           "isolated": "\uFC0B",
1703           "initial": "\uFCA1"
1704         },
1705         "\u062A\u062D": {
1706           "isolated": "\uFC0C",
1707           "initial": "\uFCA2"
1708         },
1709         "\u062A\u062E": {
1710           "isolated": "\uFC0D",
1711           "initial": "\uFCA3"
1712         },
1713         "\u062A\u0645": {
1714           "isolated": "\uFC0E",
1715           "final": "\uFC72",
1716           "initial": "\uFCA4",
1717           "medial": "\uFCE3"
1718         },
1719         "\u062A\u0649": {
1720           "isolated": "\uFC0F",
1721           "final": "\uFC74"
1722         },
1723         "\u062A\u064A": {
1724           "isolated": "\uFC10",
1725           "final": "\uFC75"
1726         },
1727         "\u062B\u062C": {
1728           "isolated": "\uFC11"
1729         },
1730         "\u062B\u0645": {
1731           "isolated": "\uFC12",
1732           "final": "\uFC78",
1733           "initial": "\uFCA6",
1734           "medial": "\uFCE5"
1735         },
1736         "\u062B\u0649": {
1737           "isolated": "\uFC13",
1738           "final": "\uFC7A"
1739         },
1740         "\u062B\u0648": {
1741           "isolated": "\uFC14"
1742         },
1743         "\u062C\u062D": {
1744           "isolated": "\uFC15",
1745           "initial": "\uFCA7"
1746         },
1747         "\u062C\u0645": {
1748           "isolated": "\uFC16",
1749           "initial": "\uFCA8"
1750         },
1751         "\u062D\u062C": {
1752           "isolated": "\uFC17",
1753           "initial": "\uFCA9"
1754         },
1755         "\u062D\u0645": {
1756           "isolated": "\uFC18",
1757           "initial": "\uFCAA"
1758         },
1759         "\u062E\u062C": {
1760           "isolated": "\uFC19",
1761           "initial": "\uFCAB"
1762         },
1763         "\u062E\u062D": {
1764           "isolated": "\uFC1A"
1765         },
1766         "\u062E\u0645": {
1767           "isolated": "\uFC1B",
1768           "initial": "\uFCAC"
1769         },
1770         "\u0633\u062C": {
1771           "isolated": "\uFC1C",
1772           "initial": "\uFCAD",
1773           "medial": "\uFD34"
1774         },
1775         "\u0633\u062D": {
1776           "isolated": "\uFC1D",
1777           "initial": "\uFCAE",
1778           "medial": "\uFD35"
1779         },
1780         "\u0633\u062E": {
1781           "isolated": "\uFC1E",
1782           "initial": "\uFCAF",
1783           "medial": "\uFD36"
1784         },
1785         "\u0633\u0645": {
1786           "isolated": "\uFC1F",
1787           "initial": "\uFCB0",
1788           "medial": "\uFCE7"
1789         },
1790         "\u0635\u062D": {
1791           "isolated": "\uFC20",
1792           "initial": "\uFCB1"
1793         },
1794         "\u0635\u0645": {
1795           "isolated": "\uFC21",
1796           "initial": "\uFCB3"
1797         },
1798         "\u0636\u062C": {
1799           "isolated": "\uFC22",
1800           "initial": "\uFCB4"
1801         },
1802         "\u0636\u062D": {
1803           "isolated": "\uFC23",
1804           "initial": "\uFCB5"
1805         },
1806         "\u0636\u062E": {
1807           "isolated": "\uFC24",
1808           "initial": "\uFCB6"
1809         },
1810         "\u0636\u0645": {
1811           "isolated": "\uFC25",
1812           "initial": "\uFCB7"
1813         },
1814         "\u0637\u062D": {
1815           "isolated": "\uFC26",
1816           "initial": "\uFCB8"
1817         },
1818         "\u0637\u0645": {
1819           "isolated": "\uFC27",
1820           "initial": "\uFD33",
1821           "medial": "\uFD3A"
1822         },
1823         "\u0638\u0645": {
1824           "isolated": "\uFC28",
1825           "initial": "\uFCB9",
1826           "medial": "\uFD3B"
1827         },
1828         "\u0639\u062C": {
1829           "isolated": "\uFC29",
1830           "initial": "\uFCBA"
1831         },
1832         "\u0639\u0645": {
1833           "isolated": "\uFC2A",
1834           "initial": "\uFCBB"
1835         },
1836         "\u063A\u062C": {
1837           "isolated": "\uFC2B",
1838           "initial": "\uFCBC"
1839         },
1840         "\u063A\u0645": {
1841           "isolated": "\uFC2C",
1842           "initial": "\uFCBD"
1843         },
1844         "\u0641\u062C": {
1845           "isolated": "\uFC2D",
1846           "initial": "\uFCBE"
1847         },
1848         "\u0641\u062D": {
1849           "isolated": "\uFC2E",
1850           "initial": "\uFCBF"
1851         },
1852         "\u0641\u062E": {
1853           "isolated": "\uFC2F",
1854           "initial": "\uFCC0"
1855         },
1856         "\u0641\u0645": {
1857           "isolated": "\uFC30",
1858           "initial": "\uFCC1"
1859         },
1860         "\u0641\u0649": {
1861           "isolated": "\uFC31",
1862           "final": "\uFC7C"
1863         },
1864         "\u0641\u064A": {
1865           "isolated": "\uFC32",
1866           "final": "\uFC7D"
1867         },
1868         "\u0642\u062D": {
1869           "isolated": "\uFC33",
1870           "initial": "\uFCC2"
1871         },
1872         "\u0642\u0645": {
1873           "isolated": "\uFC34",
1874           "initial": "\uFCC3"
1875         },
1876         "\u0642\u0649": {
1877           "isolated": "\uFC35",
1878           "final": "\uFC7E"
1879         },
1880         "\u0642\u064A": {
1881           "isolated": "\uFC36",
1882           "final": "\uFC7F"
1883         },
1884         "\u0643\u0627": {
1885           "isolated": "\uFC37",
1886           "final": "\uFC80"
1887         },
1888         "\u0643\u062C": {
1889           "isolated": "\uFC38",
1890           "initial": "\uFCC4"
1891         },
1892         "\u0643\u062D": {
1893           "isolated": "\uFC39",
1894           "initial": "\uFCC5"
1895         },
1896         "\u0643\u062E": {
1897           "isolated": "\uFC3A",
1898           "initial": "\uFCC6"
1899         },
1900         "\u0643\u0644": {
1901           "isolated": "\uFC3B",
1902           "final": "\uFC81",
1903           "initial": "\uFCC7",
1904           "medial": "\uFCEB"
1905         },
1906         "\u0643\u0645": {
1907           "isolated": "\uFC3C",
1908           "final": "\uFC82",
1909           "initial": "\uFCC8",
1910           "medial": "\uFCEC"
1911         },
1912         "\u0643\u0649": {
1913           "isolated": "\uFC3D",
1914           "final": "\uFC83"
1915         },
1916         "\u0643\u064A": {
1917           "isolated": "\uFC3E",
1918           "final": "\uFC84"
1919         },
1920         "\u0644\u062C": {
1921           "isolated": "\uFC3F",
1922           "initial": "\uFCC9"
1923         },
1924         "\u0644\u062D": {
1925           "isolated": "\uFC40",
1926           "initial": "\uFCCA"
1927         },
1928         "\u0644\u062E": {
1929           "isolated": "\uFC41",
1930           "initial": "\uFCCB"
1931         },
1932         "\u0644\u0645": {
1933           "isolated": "\uFC42",
1934           "final": "\uFC85",
1935           "initial": "\uFCCC",
1936           "medial": "\uFCED"
1937         },
1938         "\u0644\u0649": {
1939           "isolated": "\uFC43",
1940           "final": "\uFC86"
1941         },
1942         "\u0644\u064A": {
1943           "isolated": "\uFC44",
1944           "final": "\uFC87"
1945         },
1946         "\u0645\u062C": {
1947           "isolated": "\uFC45",
1948           "initial": "\uFCCE"
1949         },
1950         "\u0645\u062D": {
1951           "isolated": "\uFC46",
1952           "initial": "\uFCCF"
1953         },
1954         "\u0645\u062E": {
1955           "isolated": "\uFC47",
1956           "initial": "\uFCD0"
1957         },
1958         "\u0645\u0645": {
1959           "isolated": "\uFC48",
1960           "final": "\uFC89",
1961           "initial": "\uFCD1"
1962         },
1963         "\u0645\u0649": {
1964           "isolated": "\uFC49"
1965         },
1966         "\u0645\u064A": {
1967           "isolated": "\uFC4A"
1968         },
1969         "\u0646\u062C": {
1970           "isolated": "\uFC4B",
1971           "initial": "\uFCD2"
1972         },
1973         "\u0646\u062D": {
1974           "isolated": "\uFC4C",
1975           "initial": "\uFCD3"
1976         },
1977         "\u0646\u062E": {
1978           "isolated": "\uFC4D",
1979           "initial": "\uFCD4"
1980         },
1981         "\u0646\u0645": {
1982           "isolated": "\uFC4E",
1983           "final": "\uFC8C",
1984           "initial": "\uFCD5",
1985           "medial": "\uFCEE"
1986         },
1987         "\u0646\u0649": {
1988           "isolated": "\uFC4F",
1989           "final": "\uFC8E"
1990         },
1991         "\u0646\u064A": {
1992           "isolated": "\uFC50",
1993           "final": "\uFC8F"
1994         },
1995         "\u0647\u062C": {
1996           "isolated": "\uFC51",
1997           "initial": "\uFCD7"
1998         },
1999         "\u0647\u0645": {
2000           "isolated": "\uFC52",
2001           "initial": "\uFCD8"
2002         },
2003         "\u0647\u0649": {
2004           "isolated": "\uFC53"
2005         },
2006         "\u0647\u064A": {
2007           "isolated": "\uFC54"
2008         },
2009         "\u064A\u062C": {
2010           "isolated": "\uFC55",
2011           "initial": "\uFCDA"
2012         },
2013         "\u064A\u062D": {
2014           "isolated": "\uFC56",
2015           "initial": "\uFCDB"
2016         },
2017         "\u064A\u062E": {
2018           "isolated": "\uFC57",
2019           "initial": "\uFCDC"
2020         },
2021         "\u064A\u0645": {
2022           "isolated": "\uFC58",
2023           "final": "\uFC93",
2024           "initial": "\uFCDD",
2025           "medial": "\uFCF0"
2026         },
2027         "\u064A\u0649": {
2028           "isolated": "\uFC59",
2029           "final": "\uFC95"
2030         },
2031         "\u064A\u064A": {
2032           "isolated": "\uFC5A",
2033           "final": "\uFC96"
2034         },
2035         "\u0630\u0670": {
2036           "isolated": "\uFC5B"
2037         },
2038         "\u0631\u0670": {
2039           "isolated": "\uFC5C"
2040         },
2041         "\u0649\u0670": {
2042           "isolated": "\uFC5D",
2043           "final": "\uFC90"
2044         },
2045         "\u064C\u0651": {
2046           "isolated": "\uFC5E"
2047         },
2048         "\u064D\u0651": {
2049           "isolated": "\uFC5F"
2050         },
2051         "\u064E\u0651": {
2052           "isolated": "\uFC60"
2053         },
2054         "\u064F\u0651": {
2055           "isolated": "\uFC61"
2056         },
2057         "\u0650\u0651": {
2058           "isolated": "\uFC62"
2059         },
2060         "\u0651\u0670": {
2061           "isolated": "\uFC63"
2062         },
2063         "\u0626\u0631": {
2064           "final": "\uFC64"
2065         },
2066         "\u0626\u0632": {
2067           "final": "\uFC65"
2068         },
2069         "\u0626\u0646": {
2070           "final": "\uFC67"
2071         },
2072         "\u0628\u0631": {
2073           "final": "\uFC6A"
2074         },
2075         "\u0628\u0632": {
2076           "final": "\uFC6B"
2077         },
2078         "\u0628\u0646": {
2079           "final": "\uFC6D"
2080         },
2081         "\u062A\u0631": {
2082           "final": "\uFC70"
2083         },
2084         "\u062A\u0632": {
2085           "final": "\uFC71"
2086         },
2087         "\u062A\u0646": {
2088           "final": "\uFC73"
2089         },
2090         "\u062B\u0631": {
2091           "final": "\uFC76"
2092         },
2093         "\u062B\u0632": {
2094           "final": "\uFC77"
2095         },
2096         "\u062B\u0646": {
2097           "final": "\uFC79"
2098         },
2099         "\u062B\u064A": {
2100           "final": "\uFC7B"
2101         },
2102         "\u0645\u0627": {
2103           "final": "\uFC88"
2104         },
2105         "\u0646\u0631": {
2106           "final": "\uFC8A"
2107         },
2108         "\u0646\u0632": {
2109           "final": "\uFC8B"
2110         },
2111         "\u0646\u0646": {
2112           "final": "\uFC8D"
2113         },
2114         "\u064A\u0631": {
2115           "final": "\uFC91"
2116         },
2117         "\u064A\u0632": {
2118           "final": "\uFC92"
2119         },
2120         "\u064A\u0646": {
2121           "final": "\uFC94"
2122         },
2123         "\u0626\u062E": {
2124           "initial": "\uFC99"
2125         },
2126         "\u0626\u0647": {
2127           "initial": "\uFC9B",
2128           "medial": "\uFCE0"
2129         },
2130         "\u0628\u0647": {
2131           "initial": "\uFCA0",
2132           "medial": "\uFCE2"
2133         },
2134         "\u062A\u0647": {
2135           "initial": "\uFCA5",
2136           "medial": "\uFCE4"
2137         },
2138         "\u0635\u062E": {
2139           "initial": "\uFCB2"
2140         },
2141         "\u0644\u0647": {
2142           "initial": "\uFCCD"
2143         },
2144         "\u0646\u0647": {
2145           "initial": "\uFCD6",
2146           "medial": "\uFCEF"
2147         },
2148         "\u0647\u0670": {
2149           "initial": "\uFCD9"
2150         },
2151         "\u064A\u0647": {
2152           "initial": "\uFCDE",
2153           "medial": "\uFCF1"
2154         },
2155         "\u062B\u0647": {
2156           "medial": "\uFCE6"
2157         },
2158         "\u0633\u0647": {
2159           "medial": "\uFCE8",
2160           "initial": "\uFD31"
2161         },
2162         "\u0634\u0645": {
2163           "medial": "\uFCE9",
2164           "isolated": "\uFD0C",
2165           "final": "\uFD28",
2166           "initial": "\uFD30"
2167         },
2168         "\u0634\u0647": {
2169           "medial": "\uFCEA",
2170           "initial": "\uFD32"
2171         },
2172         "\u0640\u064E\u0651": {
2173           "medial": "\uFCF2"
2174         },
2175         "\u0640\u064F\u0651": {
2176           "medial": "\uFCF3"
2177         },
2178         "\u0640\u0650\u0651": {
2179           "medial": "\uFCF4"
2180         },
2181         "\u0637\u0649": {
2182           "isolated": "\uFCF5",
2183           "final": "\uFD11"
2184         },
2185         "\u0637\u064A": {
2186           "isolated": "\uFCF6",
2187           "final": "\uFD12"
2188         },
2189         "\u0639\u0649": {
2190           "isolated": "\uFCF7",
2191           "final": "\uFD13"
2192         },
2193         "\u0639\u064A": {
2194           "isolated": "\uFCF8",
2195           "final": "\uFD14"
2196         },
2197         "\u063A\u0649": {
2198           "isolated": "\uFCF9",
2199           "final": "\uFD15"
2200         },
2201         "\u063A\u064A": {
2202           "isolated": "\uFCFA",
2203           "final": "\uFD16"
2204         },
2205         "\u0633\u0649": {
2206           "isolated": "\uFCFB"
2207         },
2208         "\u0633\u064A": {
2209           "isolated": "\uFCFC",
2210           "final": "\uFD18"
2211         },
2212         "\u0634\u0649": {
2213           "isolated": "\uFCFD",
2214           "final": "\uFD19"
2215         },
2216         "\u0634\u064A": {
2217           "isolated": "\uFCFE",
2218           "final": "\uFD1A"
2219         },
2220         "\u062D\u0649": {
2221           "isolated": "\uFCFF",
2222           "final": "\uFD1B"
2223         },
2224         "\u062D\u064A": {
2225           "isolated": "\uFD00",
2226           "final": "\uFD1C"
2227         },
2228         "\u062C\u0649": {
2229           "isolated": "\uFD01",
2230           "final": "\uFD1D"
2231         },
2232         "\u062C\u064A": {
2233           "isolated": "\uFD02",
2234           "final": "\uFD1E"
2235         },
2236         "\u062E\u0649": {
2237           "isolated": "\uFD03",
2238           "final": "\uFD1F"
2239         },
2240         "\u062E\u064A": {
2241           "isolated": "\uFD04",
2242           "final": "\uFD20"
2243         },
2244         "\u0635\u0649": {
2245           "isolated": "\uFD05",
2246           "final": "\uFD21"
2247         },
2248         "\u0635\u064A": {
2249           "isolated": "\uFD06",
2250           "final": "\uFD22"
2251         },
2252         "\u0636\u0649": {
2253           "isolated": "\uFD07",
2254           "final": "\uFD23"
2255         },
2256         "\u0636\u064A": {
2257           "isolated": "\uFD08",
2258           "final": "\uFD24"
2259         },
2260         "\u0634\u062C": {
2261           "isolated": "\uFD09",
2262           "final": "\uFD25",
2263           "initial": "\uFD2D",
2264           "medial": "\uFD37"
2265         },
2266         "\u0634\u062D": {
2267           "isolated": "\uFD0A",
2268           "final": "\uFD26",
2269           "initial": "\uFD2E",
2270           "medial": "\uFD38"
2271         },
2272         "\u0634\u062E": {
2273           "isolated": "\uFD0B",
2274           "final": "\uFD27",
2275           "initial": "\uFD2F",
2276           "medial": "\uFD39"
2277         },
2278         "\u0634\u0631": {
2279           "isolated": "\uFD0D",
2280           "final": "\uFD29"
2281         },
2282         "\u0633\u0631": {
2283           "isolated": "\uFD0E",
2284           "final": "\uFD2A"
2285         },
2286         "\u0635\u0631": {
2287           "isolated": "\uFD0F",
2288           "final": "\uFD2B"
2289         },
2290         "\u0636\u0631": {
2291           "isolated": "\uFD10",
2292           "final": "\uFD2C"
2293         },
2294         "\u0633\u0639": {
2295           "final": "\uFD17"
2296         },
2297         "\u062A\u062C\u0645": {
2298           "initial": "\uFD50"
2299         },
2300         "\u062A\u062D\u062C": {
2301           "final": "\uFD51",
2302           "initial": "\uFD52"
2303         },
2304         "\u062A\u062D\u0645": {
2305           "initial": "\uFD53"
2306         },
2307         "\u062A\u062E\u0645": {
2308           "initial": "\uFD54"
2309         },
2310         "\u062A\u0645\u062C": {
2311           "initial": "\uFD55"
2312         },
2313         "\u062A\u0645\u062D": {
2314           "initial": "\uFD56"
2315         },
2316         "\u062A\u0645\u062E": {
2317           "initial": "\uFD57"
2318         },
2319         "\u062C\u0645\u062D": {
2320           "final": "\uFD58",
2321           "initial": "\uFD59"
2322         },
2323         "\u062D\u0645\u064A": {
2324           "final": "\uFD5A"
2325         },
2326         "\u062D\u0645\u0649": {
2327           "final": "\uFD5B"
2328         },
2329         "\u0633\u062D\u062C": {
2330           "initial": "\uFD5C"
2331         },
2332         "\u0633\u062C\u062D": {
2333           "initial": "\uFD5D"
2334         },
2335         "\u0633\u062C\u0649": {
2336           "final": "\uFD5E"
2337         },
2338         "\u0633\u0645\u062D": {
2339           "final": "\uFD5F",
2340           "initial": "\uFD60"
2341         },
2342         "\u0633\u0645\u062C": {
2343           "initial": "\uFD61"
2344         },
2345         "\u0633\u0645\u0645": {
2346           "final": "\uFD62",
2347           "initial": "\uFD63"
2348         },
2349         "\u0635\u062D\u062D": {
2350           "final": "\uFD64",
2351           "initial": "\uFD65"
2352         },
2353         "\u0635\u0645\u0645": {
2354           "final": "\uFD66",
2355           "initial": "\uFDC5"
2356         },
2357         "\u0634\u062D\u0645": {
2358           "final": "\uFD67",
2359           "initial": "\uFD68"
2360         },
2361         "\u0634\u062C\u064A": {
2362           "final": "\uFD69"
2363         },
2364         "\u0634\u0645\u062E": {
2365           "final": "\uFD6A",
2366           "initial": "\uFD6B"
2367         },
2368         "\u0634\u0645\u0645": {
2369           "final": "\uFD6C",
2370           "initial": "\uFD6D"
2371         },
2372         "\u0636\u062D\u0649": {
2373           "final": "\uFD6E"
2374         },
2375         "\u0636\u062E\u0645": {
2376           "final": "\uFD6F",
2377           "initial": "\uFD70"
2378         },
2379         "\u0636\u0645\u062D": {
2380           "final": "\uFD71"
2381         },
2382         "\u0637\u0645\u062D": {
2383           "initial": "\uFD72"
2384         },
2385         "\u0637\u0645\u0645": {
2386           "initial": "\uFD73"
2387         },
2388         "\u0637\u0645\u064A": {
2389           "final": "\uFD74"
2390         },
2391         "\u0639\u062C\u0645": {
2392           "final": "\uFD75",
2393           "initial": "\uFDC4"
2394         },
2395         "\u0639\u0645\u0645": {
2396           "final": "\uFD76",
2397           "initial": "\uFD77"
2398         },
2399         "\u0639\u0645\u0649": {
2400           "final": "\uFD78"
2401         },
2402         "\u063A\u0645\u0645": {
2403           "final": "\uFD79"
2404         },
2405         "\u063A\u0645\u064A": {
2406           "final": "\uFD7A"
2407         },
2408         "\u063A\u0645\u0649": {
2409           "final": "\uFD7B"
2410         },
2411         "\u0641\u062E\u0645": {
2412           "final": "\uFD7C",
2413           "initial": "\uFD7D"
2414         },
2415         "\u0642\u0645\u062D": {
2416           "final": "\uFD7E",
2417           "initial": "\uFDB4"
2418         },
2419         "\u0642\u0645\u0645": {
2420           "final": "\uFD7F"
2421         },
2422         "\u0644\u062D\u0645": {
2423           "final": "\uFD80",
2424           "initial": "\uFDB5"
2425         },
2426         "\u0644\u062D\u064A": {
2427           "final": "\uFD81"
2428         },
2429         "\u0644\u062D\u0649": {
2430           "final": "\uFD82"
2431         },
2432         "\u0644\u062C\u062C": {
2433           "initial": "\uFD83",
2434           "final": "\uFD84"
2435         },
2436         "\u0644\u062E\u0645": {
2437           "final": "\uFD85",
2438           "initial": "\uFD86"
2439         },
2440         "\u0644\u0645\u062D": {
2441           "final": "\uFD87",
2442           "initial": "\uFD88"
2443         },
2444         "\u0645\u062D\u062C": {
2445           "initial": "\uFD89"
2446         },
2447         "\u0645\u062D\u0645": {
2448           "initial": "\uFD8A"
2449         },
2450         "\u0645\u062D\u064A": {
2451           "final": "\uFD8B"
2452         },
2453         "\u0645\u062C\u062D": {
2454           "initial": "\uFD8C"
2455         },
2456         "\u0645\u062C\u0645": {
2457           "initial": "\uFD8D"
2458         },
2459         "\u0645\u062E\u062C": {
2460           "initial": "\uFD8E"
2461         },
2462         "\u0645\u062E\u0645": {
2463           "initial": "\uFD8F"
2464         },
2465         "\u0645\u062C\u062E": {
2466           "initial": "\uFD92"
2467         },
2468         "\u0647\u0645\u062C": {
2469           "initial": "\uFD93"
2470         },
2471         "\u0647\u0645\u0645": {
2472           "initial": "\uFD94"
2473         },
2474         "\u0646\u062D\u0645": {
2475           "initial": "\uFD95"
2476         },
2477         "\u0646\u062D\u0649": {
2478           "final": "\uFD96"
2479         },
2480         "\u0646\u062C\u0645": {
2481           "final": "\uFD97",
2482           "initial": "\uFD98"
2483         },
2484         "\u0646\u062C\u0649": {
2485           "final": "\uFD99"
2486         },
2487         "\u0646\u0645\u064A": {
2488           "final": "\uFD9A"
2489         },
2490         "\u0646\u0645\u0649": {
2491           "final": "\uFD9B"
2492         },
2493         "\u064A\u0645\u0645": {
2494           "final": "\uFD9C",
2495           "initial": "\uFD9D"
2496         },
2497         "\u0628\u062E\u064A": {
2498           "final": "\uFD9E"
2499         },
2500         "\u062A\u062C\u064A": {
2501           "final": "\uFD9F"
2502         },
2503         "\u062A\u062C\u0649": {
2504           "final": "\uFDA0"
2505         },
2506         "\u062A\u062E\u064A": {
2507           "final": "\uFDA1"
2508         },
2509         "\u062A\u062E\u0649": {
2510           "final": "\uFDA2"
2511         },
2512         "\u062A\u0645\u064A": {
2513           "final": "\uFDA3"
2514         },
2515         "\u062A\u0645\u0649": {
2516           "final": "\uFDA4"
2517         },
2518         "\u062C\u0645\u064A": {
2519           "final": "\uFDA5"
2520         },
2521         "\u062C\u062D\u0649": {
2522           "final": "\uFDA6"
2523         },
2524         "\u062C\u0645\u0649": {
2525           "final": "\uFDA7"
2526         },
2527         "\u0633\u062E\u0649": {
2528           "final": "\uFDA8"
2529         },
2530         "\u0635\u062D\u064A": {
2531           "final": "\uFDA9"
2532         },
2533         "\u0634\u062D\u064A": {
2534           "final": "\uFDAA"
2535         },
2536         "\u0636\u062D\u064A": {
2537           "final": "\uFDAB"
2538         },
2539         "\u0644\u062C\u064A": {
2540           "final": "\uFDAC"
2541         },
2542         "\u0644\u0645\u064A": {
2543           "final": "\uFDAD"
2544         },
2545         "\u064A\u062D\u064A": {
2546           "final": "\uFDAE"
2547         },
2548         "\u064A\u062C\u064A": {
2549           "final": "\uFDAF"
2550         },
2551         "\u064A\u0645\u064A": {
2552           "final": "\uFDB0"
2553         },
2554         "\u0645\u0645\u064A": {
2555           "final": "\uFDB1"
2556         },
2557         "\u0642\u0645\u064A": {
2558           "final": "\uFDB2"
2559         },
2560         "\u0646\u062D\u064A": {
2561           "final": "\uFDB3"
2562         },
2563         "\u0639\u0645\u064A": {
2564           "final": "\uFDB6"
2565         },
2566         "\u0643\u0645\u064A": {
2567           "final": "\uFDB7"
2568         },
2569         "\u0646\u062C\u062D": {
2570           "initial": "\uFDB8",
2571           "final": "\uFDBD"
2572         },
2573         "\u0645\u062E\u064A": {
2574           "final": "\uFDB9"
2575         },
2576         "\u0644\u062C\u0645": {
2577           "initial": "\uFDBA",
2578           "final": "\uFDBC"
2579         },
2580         "\u0643\u0645\u0645": {
2581           "final": "\uFDBB",
2582           "initial": "\uFDC3"
2583         },
2584         "\u062C\u062D\u064A": {
2585           "final": "\uFDBE"
2586         },
2587         "\u062D\u062C\u064A": {
2588           "final": "\uFDBF"
2589         },
2590         "\u0645\u062C\u064A": {
2591           "final": "\uFDC0"
2592         },
2593         "\u0641\u0645\u064A": {
2594           "final": "\uFDC1"
2595         },
2596         "\u0628\u062D\u064A": {
2597           "final": "\uFDC2"
2598         },
2599         "\u0633\u062E\u064A": {
2600           "final": "\uFDC6"
2601         },
2602         "\u0646\u062C\u064A": {
2603           "final": "\uFDC7"
2604         },
2605         "\u0644\u0622": {
2606           "isolated": "\uFEF5",
2607           "final": "\uFEF6"
2608         },
2609         "\u0644\u0623": {
2610           "isolated": "\uFEF7",
2611           "final": "\uFEF8"
2612         },
2613         "\u0644\u0625": {
2614           "isolated": "\uFEF9",
2615           "final": "\uFEFA"
2616         },
2617         "\u0644\u0627": {
2618           "isolated": "\uFEFB",
2619           "final": "\uFEFC"
2620         },
2621         "words": {
2622           "\u0635\u0644\u06D2": "\uFDF0",
2623           "\u0642\u0644\u06D2": "\uFDF1",
2624           "\u0627\u0644\u0644\u0647": "\uFDF2",
2625           "\u0627\u0643\u0628\u0631": "\uFDF3",
2626           "\u0645\u062D\u0645\u062F": "\uFDF4",
2627           "\u0635\u0644\u0639\u0645": "\uFDF5",
2628           "\u0631\u0633\u0648\u0644": "\uFDF6",
2629           "\u0639\u0644\u064A\u0647": "\uFDF7",
2630           "\u0648\u0633\u0644\u0645": "\uFDF8",
2631           "\u0635\u0644\u0649": "\uFDF9",
2632           "\u0635\u0644\u0649\u0627\u0644\u0644\u0647\u0639\u0644\u064A\u0647\u0648\u0633\u0644\u0645": "\uFDFA",
2633           "\u062C\u0644\u062C\u0644\u0627\u0644\u0647": "\uFDFB",
2634           "\u0631\u06CC\u0627\u0644": "\uFDFC"
2635         }
2636       };
2637       exports2.default = ligatureReference;
2638     }
2639   });
2640
2641   // node_modules/alif-toolkit/lib/reference.js
2642   var require_reference = __commonJS({
2643     "node_modules/alif-toolkit/lib/reference.js"(exports2) {
2644       "use strict";
2645       Object.defineProperty(exports2, "__esModule", { value: true });
2646       var unicode_arabic_1 = require_unicode_arabic();
2647       var unicode_ligatures_1 = require_unicode_ligatures();
2648       var letterList = Object.keys(unicode_arabic_1.default);
2649       exports2.letterList = letterList;
2650       var ligatureList = Object.keys(unicode_ligatures_1.default);
2651       exports2.ligatureList = ligatureList;
2652       var ligatureWordList = Object.keys(unicode_ligatures_1.default.words);
2653       exports2.ligatureWordList = ligatureWordList;
2654       var lams = "\u0644\u06B5\u06B6\u06B7\u06B8";
2655       exports2.lams = lams;
2656       var alefs = "\u0627\u0622\u0623\u0625\u0671\u0672\u0673\u0675\u0773\u0774";
2657       exports2.alefs = alefs;
2658       var tashkeel = "\u0605\u0640\u0670\u0674\u06DF\u06E7\u06E8";
2659       exports2.tashkeel = tashkeel;
2660       function addToTashkeel(start2, finish) {
2661         for (var i3 = start2; i3 <= finish; i3++) {
2662           exports2.tashkeel = tashkeel += String.fromCharCode(i3);
2663         }
2664       }
2665       addToTashkeel(1552, 1562);
2666       addToTashkeel(1611, 1631);
2667       addToTashkeel(1750, 1756);
2668       addToTashkeel(1760, 1764);
2669       addToTashkeel(1770, 1773);
2670       addToTashkeel(2259, 2273);
2671       addToTashkeel(2275, 2303);
2672       addToTashkeel(65136, 65151);
2673       var lineBreakers = "\u0627\u0629\u0648\u06C0\u06CF\u06FD\u06FE\u076B\u076C\u0771\u0773\u0774\u0778\u0779\u08E2\u08B1\u08B2\u08B9";
2674       exports2.lineBreakers = lineBreakers;
2675       function addToLineBreakers(start2, finish) {
2676         for (var i3 = start2; i3 <= finish; i3++) {
2677           exports2.lineBreakers = lineBreakers += String.fromCharCode(i3);
2678         }
2679       }
2680       addToLineBreakers(1536, 1567);
2681       addToLineBreakers(1569, 1573);
2682       addToLineBreakers(1583, 1586);
2683       addToLineBreakers(1632, 1645);
2684       addToLineBreakers(1649, 1655);
2685       addToLineBreakers(1672, 1689);
2686       addToLineBreakers(1731, 1739);
2687       addToLineBreakers(1746, 1785);
2688       addToLineBreakers(1881, 1883);
2689       addToLineBreakers(2218, 2222);
2690       addToLineBreakers(64336, 65021);
2691       addToLineBreakers(65152, 65276);
2692       addToLineBreakers(69216, 69247);
2693       addToLineBreakers(126064, 126143);
2694       addToLineBreakers(126464, 126719);
2695     }
2696   });
2697
2698   // node_modules/alif-toolkit/lib/GlyphSplitter.js
2699   var require_GlyphSplitter = __commonJS({
2700     "node_modules/alif-toolkit/lib/GlyphSplitter.js"(exports2) {
2701       "use strict";
2702       Object.defineProperty(exports2, "__esModule", { value: true });
2703       var isArabic_1 = require_isArabic();
2704       var reference_1 = require_reference();
2705       function GlyphSplitter(word) {
2706         let letters = [];
2707         let lastLetter = "";
2708         word.split("").forEach((letter) => {
2709           if (isArabic_1.isArabic(letter)) {
2710             if (reference_1.tashkeel.indexOf(letter) > -1) {
2711               letters[letters.length - 1] += letter;
2712             } 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)) {
2713               letters[letters.length - 1] += letter;
2714             } else {
2715               letters.push(letter);
2716             }
2717           } else {
2718             letters.push(letter);
2719           }
2720           if (reference_1.tashkeel.indexOf(letter) === -1) {
2721             lastLetter = letter;
2722           }
2723         });
2724         return letters;
2725       }
2726       exports2.GlyphSplitter = GlyphSplitter;
2727     }
2728   });
2729
2730   // node_modules/alif-toolkit/lib/BaselineSplitter.js
2731   var require_BaselineSplitter = __commonJS({
2732     "node_modules/alif-toolkit/lib/BaselineSplitter.js"(exports2) {
2733       "use strict";
2734       Object.defineProperty(exports2, "__esModule", { value: true });
2735       var isArabic_1 = require_isArabic();
2736       var reference_1 = require_reference();
2737       function BaselineSplitter(word) {
2738         let letters = [];
2739         let lastLetter = "";
2740         word.split("").forEach((letter) => {
2741           if (isArabic_1.isArabic(letter) && isArabic_1.isArabic(lastLetter)) {
2742             if (lastLetter.length && reference_1.tashkeel.indexOf(letter) > -1) {
2743               letters[letters.length - 1] += letter;
2744             } else if (reference_1.lineBreakers.indexOf(lastLetter) > -1) {
2745               letters.push(letter);
2746             } else {
2747               letters[letters.length - 1] += letter;
2748             }
2749           } else {
2750             letters.push(letter);
2751           }
2752           if (reference_1.tashkeel.indexOf(letter) === -1) {
2753             lastLetter = letter;
2754           }
2755         });
2756         return letters;
2757       }
2758       exports2.BaselineSplitter = BaselineSplitter;
2759     }
2760   });
2761
2762   // node_modules/alif-toolkit/lib/Normalization.js
2763   var require_Normalization = __commonJS({
2764     "node_modules/alif-toolkit/lib/Normalization.js"(exports2) {
2765       "use strict";
2766       Object.defineProperty(exports2, "__esModule", { value: true });
2767       var unicode_arabic_1 = require_unicode_arabic();
2768       var unicode_ligatures_1 = require_unicode_ligatures();
2769       var isArabic_1 = require_isArabic();
2770       var reference_1 = require_reference();
2771       function Normal(word, breakPresentationForm) {
2772         if (typeof breakPresentationForm === "undefined") {
2773           breakPresentationForm = true;
2774         }
2775         let returnable = "";
2776         word.split("").forEach((letter) => {
2777           if (!isArabic_1.isArabic(letter)) {
2778             returnable += letter;
2779             return;
2780           }
2781           for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2782             let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2783             let versions = Object.keys(letterForms);
2784             for (let v2 = 0; v2 < versions.length; v2++) {
2785               let localVersion = letterForms[versions[v2]];
2786               if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2787                 let embeddedForms = Object.keys(localVersion);
2788                 for (let ef = 0; ef < embeddedForms.length; ef++) {
2789                   let form = localVersion[embeddedForms[ef]];
2790                   if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2791                     if (form === letter) {
2792                       if (breakPresentationForm && localVersion["normal"] && ["isolated", "initial", "medial", "final"].indexOf(embeddedForms[ef]) > -1) {
2793                         if (typeof localVersion["normal"] === "object") {
2794                           returnable += localVersion["normal"][0];
2795                         } else {
2796                           returnable += localVersion["normal"];
2797                         }
2798                         return;
2799                       }
2800                       returnable += letter;
2801                       return;
2802                     } else if (typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2803                       returnable += form[0];
2804                       return;
2805                     }
2806                   }
2807                 }
2808               } else if (localVersion === letter) {
2809                 if (breakPresentationForm && letterForms["normal"] && ["isolated", "initial", "medial", "final"].indexOf(versions[v2]) > -1) {
2810                   if (typeof letterForms["normal"] === "object") {
2811                     returnable += letterForms["normal"][0];
2812                   } else {
2813                     returnable += letterForms["normal"];
2814                   }
2815                   return;
2816                 }
2817                 returnable += letter;
2818                 return;
2819               } else if (typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2820                 returnable += localVersion[0];
2821                 return;
2822               }
2823             }
2824           }
2825           for (let v2 = 0; v2 < reference_1.ligatureList.length; v2++) {
2826             let normalForm = reference_1.ligatureList[v2];
2827             if (normalForm !== "words") {
2828               let ligForms = Object.keys(unicode_ligatures_1.default[normalForm]);
2829               for (let f2 = 0; f2 < ligForms.length; f2++) {
2830                 if (unicode_ligatures_1.default[normalForm][ligForms[f2]] === letter) {
2831                   returnable += normalForm;
2832                   return;
2833                 }
2834               }
2835             }
2836           }
2837           for (let v3 = 0; v3 < reference_1.ligatureWordList.length; v3++) {
2838             let normalForm = reference_1.ligatureWordList[v3];
2839             if (unicode_ligatures_1.default.words[normalForm] === letter) {
2840               returnable += normalForm;
2841               return;
2842             }
2843           }
2844           returnable += letter;
2845         });
2846         return returnable;
2847       }
2848       exports2.Normal = Normal;
2849     }
2850   });
2851
2852   // node_modules/alif-toolkit/lib/CharShaper.js
2853   var require_CharShaper = __commonJS({
2854     "node_modules/alif-toolkit/lib/CharShaper.js"(exports2) {
2855       "use strict";
2856       Object.defineProperty(exports2, "__esModule", { value: true });
2857       var unicode_arabic_1 = require_unicode_arabic();
2858       var isArabic_1 = require_isArabic();
2859       var reference_1 = require_reference();
2860       function CharShaper(letter, form) {
2861         if (!isArabic_1.isArabic(letter)) {
2862           throw new Error("Not Arabic");
2863         }
2864         if (letter === "\u0621") {
2865           return "\u0621";
2866         }
2867         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2868           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2869           let versions = Object.keys(letterForms);
2870           for (let v2 = 0; v2 < versions.length; v2++) {
2871             let localVersion = letterForms[versions[v2]];
2872             if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2873               if (versions.indexOf(form) > -1) {
2874                 return letterForms[form];
2875               }
2876             } else if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2877               let embeddedVersions = Object.keys(localVersion);
2878               for (let ev = 0; ev < embeddedVersions.length; ev++) {
2879                 if (localVersion[embeddedVersions[ev]] === letter || typeof localVersion[embeddedVersions[ev]] === "object" && localVersion[embeddedVersions[ev]].indexOf && localVersion[embeddedVersions[ev]].indexOf(letter) > -1) {
2880                   if (embeddedVersions.indexOf(form) > -1) {
2881                     return localVersion[form];
2882                   }
2883                 }
2884               }
2885             }
2886           }
2887         }
2888       }
2889       exports2.CharShaper = CharShaper;
2890     }
2891   });
2892
2893   // node_modules/alif-toolkit/lib/WordShaper.js
2894   var require_WordShaper = __commonJS({
2895     "node_modules/alif-toolkit/lib/WordShaper.js"(exports2) {
2896       "use strict";
2897       Object.defineProperty(exports2, "__esModule", { value: true });
2898       var isArabic_1 = require_isArabic();
2899       var reference_1 = require_reference();
2900       var CharShaper_1 = require_CharShaper();
2901       var unicode_ligatures_1 = require_unicode_ligatures();
2902       function WordShaper2(word) {
2903         let state = "initial";
2904         let output = "";
2905         for (let w2 = 0; w2 < word.length; w2++) {
2906           let nextLetter = " ";
2907           for (let nxw = w2 + 1; nxw < word.length; nxw++) {
2908             if (!isArabic_1.isArabic(word[nxw])) {
2909               break;
2910             }
2911             if (reference_1.tashkeel.indexOf(word[nxw]) === -1) {
2912               nextLetter = word[nxw];
2913               break;
2914             }
2915           }
2916           if (!isArabic_1.isArabic(word[w2]) || isArabic_1.isMath(word[w2])) {
2917             output += word[w2];
2918             state = "initial";
2919           } else if (reference_1.tashkeel.indexOf(word[w2]) > -1) {
2920             output += word[w2];
2921           } else if (nextLetter === " " || reference_1.lineBreakers.indexOf(word[w2]) > -1) {
2922             output += CharShaper_1.CharShaper(word[w2], state === "initial" ? "isolated" : "final");
2923             state = "initial";
2924           } else if (reference_1.lams.indexOf(word[w2]) > -1 && reference_1.alefs.indexOf(nextLetter) > -1) {
2925             output += unicode_ligatures_1.default[word[w2] + nextLetter][state === "initial" ? "isolated" : "final"];
2926             while (word[w2] !== nextLetter) {
2927               w2++;
2928             }
2929             state = "initial";
2930           } else {
2931             output += CharShaper_1.CharShaper(word[w2], state);
2932             state = "medial";
2933           }
2934         }
2935         return output;
2936       }
2937       exports2.WordShaper = WordShaper2;
2938     }
2939   });
2940
2941   // node_modules/alif-toolkit/lib/ParentLetter.js
2942   var require_ParentLetter = __commonJS({
2943     "node_modules/alif-toolkit/lib/ParentLetter.js"(exports2) {
2944       "use strict";
2945       Object.defineProperty(exports2, "__esModule", { value: true });
2946       var unicode_arabic_1 = require_unicode_arabic();
2947       var isArabic_1 = require_isArabic();
2948       var reference_1 = require_reference();
2949       function ParentLetter(letter) {
2950         if (!isArabic_1.isArabic(letter)) {
2951           throw new Error("Not an Arabic letter");
2952         }
2953         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2954           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2955           let versions = Object.keys(letterForms);
2956           for (let v2 = 0; v2 < versions.length; v2++) {
2957             let localVersion = letterForms[versions[v2]];
2958             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2959               let embeddedForms = Object.keys(localVersion);
2960               for (let ef = 0; ef < embeddedForms.length; ef++) {
2961                 let form = localVersion[embeddedForms[ef]];
2962                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2963                   return localVersion;
2964                 }
2965               }
2966             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2967               return letterForms;
2968             }
2969           }
2970           return null;
2971         }
2972       }
2973       exports2.ParentLetter = ParentLetter;
2974       function GrandparentLetter(letter) {
2975         if (!isArabic_1.isArabic(letter)) {
2976           throw new Error("Not an Arabic letter");
2977         }
2978         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2979           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2980           let versions = Object.keys(letterForms);
2981           for (let v2 = 0; v2 < versions.length; v2++) {
2982             let localVersion = letterForms[versions[v2]];
2983             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2984               let embeddedForms = Object.keys(localVersion);
2985               for (let ef = 0; ef < embeddedForms.length; ef++) {
2986                 let form = localVersion[embeddedForms[ef]];
2987                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2988                   return letterForms;
2989                 }
2990               }
2991             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2992               return letterForms;
2993             }
2994           }
2995           return null;
2996         }
2997       }
2998       exports2.GrandparentLetter = GrandparentLetter;
2999     }
3000   });
3001
3002   // node_modules/alif-toolkit/lib/index.js
3003   var require_lib = __commonJS({
3004     "node_modules/alif-toolkit/lib/index.js"(exports2) {
3005       "use strict";
3006       Object.defineProperty(exports2, "__esModule", { value: true });
3007       var isArabic_1 = require_isArabic();
3008       exports2.isArabic = isArabic_1.isArabic;
3009       var GlyphSplitter_1 = require_GlyphSplitter();
3010       exports2.GlyphSplitter = GlyphSplitter_1.GlyphSplitter;
3011       var BaselineSplitter_1 = require_BaselineSplitter();
3012       exports2.BaselineSplitter = BaselineSplitter_1.BaselineSplitter;
3013       var Normalization_1 = require_Normalization();
3014       exports2.Normal = Normalization_1.Normal;
3015       var CharShaper_1 = require_CharShaper();
3016       exports2.CharShaper = CharShaper_1.CharShaper;
3017       var WordShaper_1 = require_WordShaper();
3018       exports2.WordShaper = WordShaper_1.WordShaper;
3019       var ParentLetter_1 = require_ParentLetter();
3020       exports2.ParentLetter = ParentLetter_1.ParentLetter;
3021       exports2.GrandparentLetter = ParentLetter_1.GrandparentLetter;
3022     }
3023   });
3024
3025   // node_modules/vparse/index.js
3026   var require_vparse = __commonJS({
3027     "node_modules/vparse/index.js"(exports2, module2) {
3028       (function(window2) {
3029         "use strict";
3030         function parseVersion3(v2) {
3031           var m2 = v2.replace(/[^0-9.]/g, "").match(/[0-9]*\.|[0-9]+/g) || [];
3032           v2 = {
3033             major: +m2[0] || 0,
3034             minor: +m2[1] || 0,
3035             patch: +m2[2] || 0,
3036             build: +m2[3] || 0
3037           };
3038           v2.isEmpty = !v2.major && !v2.minor && !v2.patch && !v2.build;
3039           v2.parsed = [v2.major, v2.minor, v2.patch, v2.build];
3040           v2.text = v2.parsed.join(".");
3041           v2.compare = compare2;
3042           return v2;
3043         }
3044         function compare2(v2) {
3045           if (typeof v2 === "string") {
3046             v2 = parseVersion3(v2);
3047           }
3048           for (var i3 = 0; i3 < 4; i3++) {
3049             if (this.parsed[i3] !== v2.parsed[i3]) {
3050               return this.parsed[i3] > v2.parsed[i3] ? 1 : -1;
3051             }
3052           }
3053           return 0;
3054         }
3055         if (typeof module2 === "object" && module2 && typeof module2.exports === "object") {
3056           module2.exports = parseVersion3;
3057         } else {
3058           window2.parseVersion = parseVersion3;
3059         }
3060       })(exports2);
3061     }
3062   });
3063
3064   // node_modules/which-polygon/node_modules/quickselect/quickselect.js
3065   var require_quickselect = __commonJS({
3066     "node_modules/which-polygon/node_modules/quickselect/quickselect.js"(exports2, module2) {
3067       (function(global2, factory) {
3068         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.quickselect = factory();
3069       })(exports2, function() {
3070         "use strict";
3071         function quickselect2(arr, k2, left, right, compare2) {
3072           quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare2 || defaultCompare);
3073         }
3074         function quickselectStep(arr, k2, left, right, compare2) {
3075           while (right > left) {
3076             if (right - left > 600) {
3077               var n3 = right - left + 1;
3078               var m2 = k2 - left + 1;
3079               var z2 = Math.log(n3);
3080               var s2 = 0.5 * Math.exp(2 * z2 / 3);
3081               var sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
3082               var newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
3083               var newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
3084               quickselectStep(arr, k2, newLeft, newRight, compare2);
3085             }
3086             var t2 = arr[k2];
3087             var i3 = left;
3088             var j2 = right;
3089             swap2(arr, left, k2);
3090             if (compare2(arr[right], t2) > 0)
3091               swap2(arr, left, right);
3092             while (i3 < j2) {
3093               swap2(arr, i3, j2);
3094               i3++;
3095               j2--;
3096               while (compare2(arr[i3], t2) < 0)
3097                 i3++;
3098               while (compare2(arr[j2], t2) > 0)
3099                 j2--;
3100             }
3101             if (compare2(arr[left], t2) === 0)
3102               swap2(arr, left, j2);
3103             else {
3104               j2++;
3105               swap2(arr, j2, right);
3106             }
3107             if (j2 <= k2)
3108               left = j2 + 1;
3109             if (k2 <= j2)
3110               right = j2 - 1;
3111           }
3112         }
3113         function swap2(arr, i3, j2) {
3114           var tmp = arr[i3];
3115           arr[i3] = arr[j2];
3116           arr[j2] = tmp;
3117         }
3118         function defaultCompare(a2, b2) {
3119           return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
3120         }
3121         return quickselect2;
3122       });
3123     }
3124   });
3125
3126   // node_modules/which-polygon/node_modules/rbush/index.js
3127   var require_rbush = __commonJS({
3128     "node_modules/which-polygon/node_modules/rbush/index.js"(exports2, module2) {
3129       "use strict";
3130       module2.exports = rbush;
3131       module2.exports.default = rbush;
3132       var quickselect2 = require_quickselect();
3133       function rbush(maxEntries, format2) {
3134         if (!(this instanceof rbush))
3135           return new rbush(maxEntries, format2);
3136         this._maxEntries = Math.max(4, maxEntries || 9);
3137         this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
3138         if (format2) {
3139           this._initFormat(format2);
3140         }
3141         this.clear();
3142       }
3143       rbush.prototype = {
3144         all: function() {
3145           return this._all(this.data, []);
3146         },
3147         search: function(bbox2) {
3148           var node = this.data, result = [], toBBox = this.toBBox;
3149           if (!intersects(bbox2, node))
3150             return result;
3151           var nodesToSearch = [], i3, len, child, childBBox;
3152           while (node) {
3153             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3154               child = node.children[i3];
3155               childBBox = node.leaf ? toBBox(child) : child;
3156               if (intersects(bbox2, childBBox)) {
3157                 if (node.leaf)
3158                   result.push(child);
3159                 else if (contains(bbox2, childBBox))
3160                   this._all(child, result);
3161                 else
3162                   nodesToSearch.push(child);
3163               }
3164             }
3165             node = nodesToSearch.pop();
3166           }
3167           return result;
3168         },
3169         collides: function(bbox2) {
3170           var node = this.data, toBBox = this.toBBox;
3171           if (!intersects(bbox2, node))
3172             return false;
3173           var nodesToSearch = [], i3, len, child, childBBox;
3174           while (node) {
3175             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3176               child = node.children[i3];
3177               childBBox = node.leaf ? toBBox(child) : child;
3178               if (intersects(bbox2, childBBox)) {
3179                 if (node.leaf || contains(bbox2, childBBox))
3180                   return true;
3181                 nodesToSearch.push(child);
3182               }
3183             }
3184             node = nodesToSearch.pop();
3185           }
3186           return false;
3187         },
3188         load: function(data) {
3189           if (!(data && data.length))
3190             return this;
3191           if (data.length < this._minEntries) {
3192             for (var i3 = 0, len = data.length; i3 < len; i3++) {
3193               this.insert(data[i3]);
3194             }
3195             return this;
3196           }
3197           var node = this._build(data.slice(), 0, data.length - 1, 0);
3198           if (!this.data.children.length) {
3199             this.data = node;
3200           } else if (this.data.height === node.height) {
3201             this._splitRoot(this.data, node);
3202           } else {
3203             if (this.data.height < node.height) {
3204               var tmpNode = this.data;
3205               this.data = node;
3206               node = tmpNode;
3207             }
3208             this._insert(node, this.data.height - node.height - 1, true);
3209           }
3210           return this;
3211         },
3212         insert: function(item) {
3213           if (item)
3214             this._insert(item, this.data.height - 1);
3215           return this;
3216         },
3217         clear: function() {
3218           this.data = createNode([]);
3219           return this;
3220         },
3221         remove: function(item, equalsFn) {
3222           if (!item)
3223             return this;
3224           var node = this.data, bbox2 = this.toBBox(item), path = [], indexes = [], i3, parent, index, goingUp;
3225           while (node || path.length) {
3226             if (!node) {
3227               node = path.pop();
3228               parent = path[path.length - 1];
3229               i3 = indexes.pop();
3230               goingUp = true;
3231             }
3232             if (node.leaf) {
3233               index = findItem(item, node.children, equalsFn);
3234               if (index !== -1) {
3235                 node.children.splice(index, 1);
3236                 path.push(node);
3237                 this._condense(path);
3238                 return this;
3239               }
3240             }
3241             if (!goingUp && !node.leaf && contains(node, bbox2)) {
3242               path.push(node);
3243               indexes.push(i3);
3244               i3 = 0;
3245               parent = node;
3246               node = node.children[0];
3247             } else if (parent) {
3248               i3++;
3249               node = parent.children[i3];
3250               goingUp = false;
3251             } else
3252               node = null;
3253           }
3254           return this;
3255         },
3256         toBBox: function(item) {
3257           return item;
3258         },
3259         compareMinX: compareNodeMinX,
3260         compareMinY: compareNodeMinY,
3261         toJSON: function() {
3262           return this.data;
3263         },
3264         fromJSON: function(data) {
3265           this.data = data;
3266           return this;
3267         },
3268         _all: function(node, result) {
3269           var nodesToSearch = [];
3270           while (node) {
3271             if (node.leaf)
3272               result.push.apply(result, node.children);
3273             else
3274               nodesToSearch.push.apply(nodesToSearch, node.children);
3275             node = nodesToSearch.pop();
3276           }
3277           return result;
3278         },
3279         _build: function(items, left, right, height) {
3280           var N2 = right - left + 1, M2 = this._maxEntries, node;
3281           if (N2 <= M2) {
3282             node = createNode(items.slice(left, right + 1));
3283             calcBBox(node, this.toBBox);
3284             return node;
3285           }
3286           if (!height) {
3287             height = Math.ceil(Math.log(N2) / Math.log(M2));
3288             M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
3289           }
3290           node = createNode([]);
3291           node.leaf = false;
3292           node.height = height;
3293           var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j2, right2, right3;
3294           multiSelect(items, left, right, N1, this.compareMinX);
3295           for (i3 = left; i3 <= right; i3 += N1) {
3296             right2 = Math.min(i3 + N1 - 1, right);
3297             multiSelect(items, i3, right2, N22, this.compareMinY);
3298             for (j2 = i3; j2 <= right2; j2 += N22) {
3299               right3 = Math.min(j2 + N22 - 1, right2);
3300               node.children.push(this._build(items, j2, right3, height - 1));
3301             }
3302           }
3303           calcBBox(node, this.toBBox);
3304           return node;
3305         },
3306         _chooseSubtree: function(bbox2, node, level, path) {
3307           var i3, len, child, targetNode, area, enlargement, minArea, minEnlargement;
3308           while (true) {
3309             path.push(node);
3310             if (node.leaf || path.length - 1 === level)
3311               break;
3312             minArea = minEnlargement = Infinity;
3313             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3314               child = node.children[i3];
3315               area = bboxArea(child);
3316               enlargement = enlargedArea(bbox2, child) - area;
3317               if (enlargement < minEnlargement) {
3318                 minEnlargement = enlargement;
3319                 minArea = area < minArea ? area : minArea;
3320                 targetNode = child;
3321               } else if (enlargement === minEnlargement) {
3322                 if (area < minArea) {
3323                   minArea = area;
3324                   targetNode = child;
3325                 }
3326               }
3327             }
3328             node = targetNode || node.children[0];
3329           }
3330           return node;
3331         },
3332         _insert: function(item, level, isNode) {
3333           var toBBox = this.toBBox, bbox2 = isNode ? item : toBBox(item), insertPath = [];
3334           var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
3335           node.children.push(item);
3336           extend2(node, bbox2);
3337           while (level >= 0) {
3338             if (insertPath[level].children.length > this._maxEntries) {
3339               this._split(insertPath, level);
3340               level--;
3341             } else
3342               break;
3343           }
3344           this._adjustParentBBoxes(bbox2, insertPath, level);
3345         },
3346         // split overflowed node into two
3347         _split: function(insertPath, level) {
3348           var node = insertPath[level], M2 = node.children.length, m2 = this._minEntries;
3349           this._chooseSplitAxis(node, m2, M2);
3350           var splitIndex = this._chooseSplitIndex(node, m2, M2);
3351           var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
3352           newNode.height = node.height;
3353           newNode.leaf = node.leaf;
3354           calcBBox(node, this.toBBox);
3355           calcBBox(newNode, this.toBBox);
3356           if (level)
3357             insertPath[level - 1].children.push(newNode);
3358           else
3359             this._splitRoot(node, newNode);
3360         },
3361         _splitRoot: function(node, newNode) {
3362           this.data = createNode([node, newNode]);
3363           this.data.height = node.height + 1;
3364           this.data.leaf = false;
3365           calcBBox(this.data, this.toBBox);
3366         },
3367         _chooseSplitIndex: function(node, m2, M2) {
3368           var i3, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
3369           minOverlap = minArea = Infinity;
3370           for (i3 = m2; i3 <= M2 - m2; i3++) {
3371             bbox1 = distBBox(node, 0, i3, this.toBBox);
3372             bbox2 = distBBox(node, i3, M2, this.toBBox);
3373             overlap = intersectionArea(bbox1, bbox2);
3374             area = bboxArea(bbox1) + bboxArea(bbox2);
3375             if (overlap < minOverlap) {
3376               minOverlap = overlap;
3377               index = i3;
3378               minArea = area < minArea ? area : minArea;
3379             } else if (overlap === minOverlap) {
3380               if (area < minArea) {
3381                 minArea = area;
3382                 index = i3;
3383               }
3384             }
3385           }
3386           return index;
3387         },
3388         // sorts node children by the best axis for split
3389         _chooseSplitAxis: function(node, m2, M2) {
3390           var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, xMargin = this._allDistMargin(node, m2, M2, compareMinX), yMargin = this._allDistMargin(node, m2, M2, compareMinY);
3391           if (xMargin < yMargin)
3392             node.children.sort(compareMinX);
3393         },
3394         // total margin of all possible split distributions where each node is at least m full
3395         _allDistMargin: function(node, m2, M2, compare2) {
3396           node.children.sort(compare2);
3397           var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m2, toBBox), rightBBox = distBBox(node, M2 - m2, M2, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i3, child;
3398           for (i3 = m2; i3 < M2 - m2; i3++) {
3399             child = node.children[i3];
3400             extend2(leftBBox, node.leaf ? toBBox(child) : child);
3401             margin += bboxMargin(leftBBox);
3402           }
3403           for (i3 = M2 - m2 - 1; i3 >= m2; i3--) {
3404             child = node.children[i3];
3405             extend2(rightBBox, node.leaf ? toBBox(child) : child);
3406             margin += bboxMargin(rightBBox);
3407           }
3408           return margin;
3409         },
3410         _adjustParentBBoxes: function(bbox2, path, level) {
3411           for (var i3 = level; i3 >= 0; i3--) {
3412             extend2(path[i3], bbox2);
3413           }
3414         },
3415         _condense: function(path) {
3416           for (var i3 = path.length - 1, siblings; i3 >= 0; i3--) {
3417             if (path[i3].children.length === 0) {
3418               if (i3 > 0) {
3419                 siblings = path[i3 - 1].children;
3420                 siblings.splice(siblings.indexOf(path[i3]), 1);
3421               } else
3422                 this.clear();
3423             } else
3424               calcBBox(path[i3], this.toBBox);
3425           }
3426         },
3427         _initFormat: function(format2) {
3428           var compareArr = ["return a", " - b", ";"];
3429           this.compareMinX = new Function("a", "b", compareArr.join(format2[0]));
3430           this.compareMinY = new Function("a", "b", compareArr.join(format2[1]));
3431           this.toBBox = new Function(
3432             "a",
3433             "return {minX: a" + format2[0] + ", minY: a" + format2[1] + ", maxX: a" + format2[2] + ", maxY: a" + format2[3] + "};"
3434           );
3435         }
3436       };
3437       function findItem(item, items, equalsFn) {
3438         if (!equalsFn)
3439           return items.indexOf(item);
3440         for (var i3 = 0; i3 < items.length; i3++) {
3441           if (equalsFn(item, items[i3]))
3442             return i3;
3443         }
3444         return -1;
3445       }
3446       function calcBBox(node, toBBox) {
3447         distBBox(node, 0, node.children.length, toBBox, node);
3448       }
3449       function distBBox(node, k2, p2, toBBox, destNode) {
3450         if (!destNode)
3451           destNode = createNode(null);
3452         destNode.minX = Infinity;
3453         destNode.minY = Infinity;
3454         destNode.maxX = -Infinity;
3455         destNode.maxY = -Infinity;
3456         for (var i3 = k2, child; i3 < p2; i3++) {
3457           child = node.children[i3];
3458           extend2(destNode, node.leaf ? toBBox(child) : child);
3459         }
3460         return destNode;
3461       }
3462       function extend2(a2, b2) {
3463         a2.minX = Math.min(a2.minX, b2.minX);
3464         a2.minY = Math.min(a2.minY, b2.minY);
3465         a2.maxX = Math.max(a2.maxX, b2.maxX);
3466         a2.maxY = Math.max(a2.maxY, b2.maxY);
3467         return a2;
3468       }
3469       function compareNodeMinX(a2, b2) {
3470         return a2.minX - b2.minX;
3471       }
3472       function compareNodeMinY(a2, b2) {
3473         return a2.minY - b2.minY;
3474       }
3475       function bboxArea(a2) {
3476         return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
3477       }
3478       function bboxMargin(a2) {
3479         return a2.maxX - a2.minX + (a2.maxY - a2.minY);
3480       }
3481       function enlargedArea(a2, b2) {
3482         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));
3483       }
3484       function intersectionArea(a2, b2) {
3485         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);
3486         return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
3487       }
3488       function contains(a2, b2) {
3489         return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
3490       }
3491       function intersects(a2, b2) {
3492         return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
3493       }
3494       function createNode(children2) {
3495         return {
3496           children: children2,
3497           height: 1,
3498           leaf: true,
3499           minX: Infinity,
3500           minY: Infinity,
3501           maxX: -Infinity,
3502           maxY: -Infinity
3503         };
3504       }
3505       function multiSelect(arr, left, right, n3, compare2) {
3506         var stack = [left, right], mid;
3507         while (stack.length) {
3508           right = stack.pop();
3509           left = stack.pop();
3510           if (right - left <= n3)
3511             continue;
3512           mid = left + Math.ceil((right - left) / n3 / 2) * n3;
3513           quickselect2(arr, mid, left, right, compare2);
3514           stack.push(left, mid, mid, right);
3515         }
3516       }
3517     }
3518   });
3519
3520   // node_modules/lineclip/index.js
3521   var require_lineclip = __commonJS({
3522     "node_modules/lineclip/index.js"(exports2, module2) {
3523       "use strict";
3524       module2.exports = lineclip2;
3525       lineclip2.polyline = lineclip2;
3526       lineclip2.polygon = polygonclip2;
3527       function lineclip2(points, bbox2, result) {
3528         var len = points.length, codeA = bitCode2(points[0], bbox2), part = [], i3, a2, b2, codeB, lastCode;
3529         if (!result)
3530           result = [];
3531         for (i3 = 1; i3 < len; i3++) {
3532           a2 = points[i3 - 1];
3533           b2 = points[i3];
3534           codeB = lastCode = bitCode2(b2, bbox2);
3535           while (true) {
3536             if (!(codeA | codeB)) {
3537               part.push(a2);
3538               if (codeB !== lastCode) {
3539                 part.push(b2);
3540                 if (i3 < len - 1) {
3541                   result.push(part);
3542                   part = [];
3543                 }
3544               } else if (i3 === len - 1) {
3545                 part.push(b2);
3546               }
3547               break;
3548             } else if (codeA & codeB) {
3549               break;
3550             } else if (codeA) {
3551               a2 = intersect2(a2, b2, codeA, bbox2);
3552               codeA = bitCode2(a2, bbox2);
3553             } else {
3554               b2 = intersect2(a2, b2, codeB, bbox2);
3555               codeB = bitCode2(b2, bbox2);
3556             }
3557           }
3558           codeA = lastCode;
3559         }
3560         if (part.length)
3561           result.push(part);
3562         return result;
3563       }
3564       function polygonclip2(points, bbox2) {
3565         var result, edge, prev, prevInside, i3, p2, inside;
3566         for (edge = 1; edge <= 8; edge *= 2) {
3567           result = [];
3568           prev = points[points.length - 1];
3569           prevInside = !(bitCode2(prev, bbox2) & edge);
3570           for (i3 = 0; i3 < points.length; i3++) {
3571             p2 = points[i3];
3572             inside = !(bitCode2(p2, bbox2) & edge);
3573             if (inside !== prevInside)
3574               result.push(intersect2(prev, p2, edge, bbox2));
3575             if (inside)
3576               result.push(p2);
3577             prev = p2;
3578             prevInside = inside;
3579           }
3580           points = result;
3581           if (!points.length)
3582             break;
3583         }
3584         return result;
3585       }
3586       function intersect2(a2, b2, edge, bbox2) {
3587         return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : (
3588           // top
3589           edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : (
3590             // bottom
3591             edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : (
3592               // right
3593               edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : (
3594                 // left
3595                 null
3596               )
3597             )
3598           )
3599         );
3600       }
3601       function bitCode2(p2, bbox2) {
3602         var code = 0;
3603         if (p2[0] < bbox2[0])
3604           code |= 1;
3605         else if (p2[0] > bbox2[2])
3606           code |= 2;
3607         if (p2[1] < bbox2[1])
3608           code |= 4;
3609         else if (p2[1] > bbox2[3])
3610           code |= 8;
3611         return code;
3612       }
3613     }
3614   });
3615
3616   // node_modules/which-polygon/index.js
3617   var require_which_polygon = __commonJS({
3618     "node_modules/which-polygon/index.js"(exports2, module2) {
3619       "use strict";
3620       var rbush = require_rbush();
3621       var lineclip2 = require_lineclip();
3622       module2.exports = whichPolygon5;
3623       function whichPolygon5(data) {
3624         var bboxes = [];
3625         for (var i3 = 0; i3 < data.features.length; i3++) {
3626           var feature3 = data.features[i3];
3627           if (!feature3.geometry)
3628             continue;
3629           var coords = feature3.geometry.coordinates;
3630           if (feature3.geometry.type === "Polygon") {
3631             bboxes.push(treeItem(coords, feature3.properties));
3632           } else if (feature3.geometry.type === "MultiPolygon") {
3633             for (var j2 = 0; j2 < coords.length; j2++) {
3634               bboxes.push(treeItem(coords[j2], feature3.properties));
3635             }
3636           }
3637         }
3638         var tree = rbush().load(bboxes);
3639         function query(p2, multi) {
3640           var output = [], result = tree.search({
3641             minX: p2[0],
3642             minY: p2[1],
3643             maxX: p2[0],
3644             maxY: p2[1]
3645           });
3646           for (var i4 = 0; i4 < result.length; i4++) {
3647             if (insidePolygon(result[i4].coords, p2)) {
3648               if (multi)
3649                 output.push(result[i4].props);
3650               else
3651                 return result[i4].props;
3652             }
3653           }
3654           return multi && output.length ? output : null;
3655         }
3656         query.tree = tree;
3657         query.bbox = function queryBBox(bbox2) {
3658           var output = [];
3659           var result = tree.search({
3660             minX: bbox2[0],
3661             minY: bbox2[1],
3662             maxX: bbox2[2],
3663             maxY: bbox2[3]
3664           });
3665           for (var i4 = 0; i4 < result.length; i4++) {
3666             if (polygonIntersectsBBox(result[i4].coords, bbox2)) {
3667               output.push(result[i4].props);
3668             }
3669           }
3670           return output;
3671         };
3672         return query;
3673       }
3674       function polygonIntersectsBBox(polygon2, bbox2) {
3675         var bboxCenter = [
3676           (bbox2[0] + bbox2[2]) / 2,
3677           (bbox2[1] + bbox2[3]) / 2
3678         ];
3679         if (insidePolygon(polygon2, bboxCenter))
3680           return true;
3681         for (var i3 = 0; i3 < polygon2.length; i3++) {
3682           if (lineclip2(polygon2[i3], bbox2).length > 0)
3683             return true;
3684         }
3685         return false;
3686       }
3687       function insidePolygon(rings, p2) {
3688         var inside = false;
3689         for (var i3 = 0, len = rings.length; i3 < len; i3++) {
3690           var ring = rings[i3];
3691           for (var j2 = 0, len2 = ring.length, k2 = len2 - 1; j2 < len2; k2 = j2++) {
3692             if (rayIntersect(p2, ring[j2], ring[k2]))
3693               inside = !inside;
3694           }
3695         }
3696         return inside;
3697       }
3698       function rayIntersect(p2, p1, p22) {
3699         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];
3700       }
3701       function treeItem(coords, props) {
3702         var item = {
3703           minX: Infinity,
3704           minY: Infinity,
3705           maxX: -Infinity,
3706           maxY: -Infinity,
3707           coords,
3708           props
3709         };
3710         for (var i3 = 0; i3 < coords[0].length; i3++) {
3711           var p2 = coords[0][i3];
3712           item.minX = Math.min(item.minX, p2[0]);
3713           item.minY = Math.min(item.minY, p2[1]);
3714           item.maxX = Math.max(item.maxX, p2[0]);
3715           item.maxY = Math.max(item.maxY, p2[1]);
3716         }
3717         return item;
3718       }
3719     }
3720   });
3721
3722   // node_modules/wgs84/index.js
3723   var require_wgs84 = __commonJS({
3724     "node_modules/wgs84/index.js"(exports2, module2) {
3725       module2.exports.RADIUS = 6378137;
3726       module2.exports.FLATTENING = 1 / 298.257223563;
3727       module2.exports.POLAR_RADIUS = 63567523142e-4;
3728     }
3729   });
3730
3731   // node_modules/@mapbox/geojson-area/index.js
3732   var require_geojson_area = __commonJS({
3733     "node_modules/@mapbox/geojson-area/index.js"(exports2, module2) {
3734       var wgs84 = require_wgs84();
3735       module2.exports.geometry = geometry;
3736       module2.exports.ring = ringArea;
3737       function geometry(_2) {
3738         var area = 0, i3;
3739         switch (_2.type) {
3740           case "Polygon":
3741             return polygonArea(_2.coordinates);
3742           case "MultiPolygon":
3743             for (i3 = 0; i3 < _2.coordinates.length; i3++) {
3744               area += polygonArea(_2.coordinates[i3]);
3745             }
3746             return area;
3747           case "Point":
3748           case "MultiPoint":
3749           case "LineString":
3750           case "MultiLineString":
3751             return 0;
3752           case "GeometryCollection":
3753             for (i3 = 0; i3 < _2.geometries.length; i3++) {
3754               area += geometry(_2.geometries[i3]);
3755             }
3756             return area;
3757         }
3758       }
3759       function polygonArea(coords) {
3760         var area = 0;
3761         if (coords && coords.length > 0) {
3762           area += Math.abs(ringArea(coords[0]));
3763           for (var i3 = 1; i3 < coords.length; i3++) {
3764             area -= Math.abs(ringArea(coords[i3]));
3765           }
3766         }
3767         return area;
3768       }
3769       function ringArea(coords) {
3770         var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i3, area = 0, coordsLength = coords.length;
3771         if (coordsLength > 2) {
3772           for (i3 = 0; i3 < coordsLength; i3++) {
3773             if (i3 === coordsLength - 2) {
3774               lowerIndex = coordsLength - 2;
3775               middleIndex = coordsLength - 1;
3776               upperIndex = 0;
3777             } else if (i3 === coordsLength - 1) {
3778               lowerIndex = coordsLength - 1;
3779               middleIndex = 0;
3780               upperIndex = 1;
3781             } else {
3782               lowerIndex = i3;
3783               middleIndex = i3 + 1;
3784               upperIndex = i3 + 2;
3785             }
3786             p1 = coords[lowerIndex];
3787             p2 = coords[middleIndex];
3788             p3 = coords[upperIndex];
3789             area += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
3790           }
3791           area = area * wgs84.RADIUS * wgs84.RADIUS / 2;
3792         }
3793         return area;
3794       }
3795       function rad(_2) {
3796         return _2 * Math.PI / 180;
3797       }
3798     }
3799   });
3800
3801   // node_modules/circle-to-polygon/input-validation/validateCenter.js
3802   var require_validateCenter = __commonJS({
3803     "node_modules/circle-to-polygon/input-validation/validateCenter.js"(exports2) {
3804       exports2.validateCenter = function validateCenter(center) {
3805         var validCenterLengths = [2, 3];
3806         if (!Array.isArray(center) || !validCenterLengths.includes(center.length)) {
3807           throw new Error("ERROR! Center has to be an array of length two or three");
3808         }
3809         var [lng, lat] = center;
3810         if (typeof lng !== "number" || typeof lat !== "number") {
3811           throw new Error(
3812             "ERROR! Longitude and Latitude has to be numbers but where ".concat(typeof lng, " and ").concat(typeof lat)
3813           );
3814         }
3815         if (lng > 180 || lng < -180) {
3816           throw new Error("ERROR! Longitude has to be between -180 and 180 but was ".concat(lng));
3817         }
3818         if (lat > 90 || lat < -90) {
3819           throw new Error("ERROR! Latitude has to be between -90 and 90 but was ".concat(lat));
3820         }
3821       };
3822     }
3823   });
3824
3825   // node_modules/circle-to-polygon/input-validation/validateRadius.js
3826   var require_validateRadius = __commonJS({
3827     "node_modules/circle-to-polygon/input-validation/validateRadius.js"(exports2) {
3828       exports2.validateRadius = function validateRadius(radius) {
3829         if (typeof radius !== "number") {
3830           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(typeof radius));
3831         }
3832         if (radius <= 0) {
3833           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(radius));
3834         }
3835       };
3836     }
3837   });
3838
3839   // node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js
3840   var require_validateNumberOfEdges = __commonJS({
3841     "node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js"(exports2) {
3842       exports2.validateNumberOfEdges = function validateNumberOfEdges(numberOfEdges) {
3843         if (typeof numberOfEdges !== "number") {
3844           const ARGUMENT_TYPE = Array.isArray(numberOfEdges) ? "array" : typeof numberOfEdges;
3845           throw new Error("ERROR! Number of edges has to be a number but was: ".concat(ARGUMENT_TYPE));
3846         }
3847         if (numberOfEdges < 3) {
3848           throw new Error("ERROR! Number of edges has to be at least 3 but was: ".concat(numberOfEdges));
3849         }
3850       };
3851     }
3852   });
3853
3854   // node_modules/circle-to-polygon/input-validation/validateEarthRadius.js
3855   var require_validateEarthRadius = __commonJS({
3856     "node_modules/circle-to-polygon/input-validation/validateEarthRadius.js"(exports2) {
3857       exports2.validateEarthRadius = function validateEarthRadius(earthRadius2) {
3858         if (typeof earthRadius2 !== "number") {
3859           const ARGUMENT_TYPE = Array.isArray(earthRadius2) ? "array" : typeof earthRadius2;
3860           throw new Error("ERROR! Earth radius has to be a number but was: ".concat(ARGUMENT_TYPE));
3861         }
3862         if (earthRadius2 <= 0) {
3863           throw new Error("ERROR! Earth radius has to be a positive number but was: ".concat(earthRadius2));
3864         }
3865       };
3866     }
3867   });
3868
3869   // node_modules/circle-to-polygon/input-validation/validateBearing.js
3870   var require_validateBearing = __commonJS({
3871     "node_modules/circle-to-polygon/input-validation/validateBearing.js"(exports2) {
3872       exports2.validateBearing = function validateBearing(bearing) {
3873         if (typeof bearing !== "number") {
3874           const ARGUMENT_TYPE = Array.isArray(bearing) ? "array" : typeof bearing;
3875           throw new Error("ERROR! Bearing has to be a number but was: ".concat(ARGUMENT_TYPE));
3876         }
3877       };
3878     }
3879   });
3880
3881   // node_modules/circle-to-polygon/input-validation/index.js
3882   var require_input_validation = __commonJS({
3883     "node_modules/circle-to-polygon/input-validation/index.js"(exports2) {
3884       var validateCenter = require_validateCenter().validateCenter;
3885       var validateRadius = require_validateRadius().validateRadius;
3886       var validateNumberOfEdges = require_validateNumberOfEdges().validateNumberOfEdges;
3887       var validateEarthRadius = require_validateEarthRadius().validateEarthRadius;
3888       var validateBearing = require_validateBearing().validateBearing;
3889       function validateInput({ center, radius, numberOfEdges, earthRadius: earthRadius2, bearing }) {
3890         validateCenter(center);
3891         validateRadius(radius);
3892         validateNumberOfEdges(numberOfEdges);
3893         validateEarthRadius(earthRadius2);
3894         validateBearing(bearing);
3895       }
3896       exports2.validateCenter = validateCenter;
3897       exports2.validateRadius = validateRadius;
3898       exports2.validateNumberOfEdges = validateNumberOfEdges;
3899       exports2.validateEarthRadius = validateEarthRadius;
3900       exports2.validateBearing = validateBearing;
3901       exports2.validateInput = validateInput;
3902     }
3903   });
3904
3905   // node_modules/circle-to-polygon/index.js
3906   var require_circle_to_polygon = __commonJS({
3907     "node_modules/circle-to-polygon/index.js"(exports2, module2) {
3908       "use strict";
3909       var { validateInput } = require_input_validation();
3910       var defaultEarthRadius = 6378137;
3911       function toRadians(angleInDegrees) {
3912         return angleInDegrees * Math.PI / 180;
3913       }
3914       function toDegrees(angleInRadians) {
3915         return angleInRadians * 180 / Math.PI;
3916       }
3917       function offset(c1, distance, earthRadius2, bearing) {
3918         var lat1 = toRadians(c1[1]);
3919         var lon1 = toRadians(c1[0]);
3920         var dByR = distance / earthRadius2;
3921         var lat = Math.asin(
3922           Math.sin(lat1) * Math.cos(dByR) + Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)
3923         );
3924         var lon = lon1 + Math.atan2(
3925           Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
3926           Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)
3927         );
3928         return [toDegrees(lon), toDegrees(lat)];
3929       }
3930       module2.exports = function circleToPolygon2(center, radius, options2) {
3931         var n3 = getNumberOfEdges(options2);
3932         var earthRadius2 = getEarthRadius(options2);
3933         var bearing = getBearing(options2);
3934         var direction = getDirection(options2);
3935         validateInput({ center, radius, numberOfEdges: n3, earthRadius: earthRadius2, bearing });
3936         var start2 = toRadians(bearing);
3937         var coordinates = [];
3938         for (var i3 = 0; i3 < n3; ++i3) {
3939           coordinates.push(
3940             offset(
3941               center,
3942               radius,
3943               earthRadius2,
3944               start2 + direction * 2 * Math.PI * -i3 / n3
3945             )
3946           );
3947         }
3948         coordinates.push(coordinates[0]);
3949         return {
3950           type: "Polygon",
3951           coordinates: [coordinates]
3952         };
3953       };
3954       function getNumberOfEdges(options2) {
3955         if (isUndefinedOrNull(options2)) {
3956           return 32;
3957         } else if (isObjectNotArray(options2)) {
3958           var numberOfEdges = options2.numberOfEdges;
3959           return numberOfEdges === void 0 ? 32 : numberOfEdges;
3960         }
3961         return options2;
3962       }
3963       function getEarthRadius(options2) {
3964         if (isUndefinedOrNull(options2)) {
3965           return defaultEarthRadius;
3966         } else if (isObjectNotArray(options2)) {
3967           var earthRadius2 = options2.earthRadius;
3968           return earthRadius2 === void 0 ? defaultEarthRadius : earthRadius2;
3969         }
3970         return defaultEarthRadius;
3971       }
3972       function getDirection(options2) {
3973         if (isObjectNotArray(options2) && options2.rightHandRule) {
3974           return -1;
3975         }
3976         return 1;
3977       }
3978       function getBearing(options2) {
3979         if (isUndefinedOrNull(options2)) {
3980           return 0;
3981         } else if (isObjectNotArray(options2)) {
3982           var bearing = options2.bearing;
3983           return bearing === void 0 ? 0 : bearing;
3984         }
3985         return 0;
3986       }
3987       function isObjectNotArray(argument) {
3988         return argument !== null && typeof argument === "object" && !Array.isArray(argument);
3989       }
3990       function isUndefinedOrNull(argument) {
3991         return argument === null || argument === void 0;
3992       }
3993     }
3994   });
3995
3996   // node_modules/geojson-precision/index.js
3997   var require_geojson_precision = __commonJS({
3998     "node_modules/geojson-precision/index.js"(exports2, module2) {
3999       (function() {
4000         function parse(t2, coordinatePrecision, extrasPrecision) {
4001           function point2(p2) {
4002             return p2.map(function(e3, index) {
4003               if (index < 2) {
4004                 return 1 * e3.toFixed(coordinatePrecision);
4005               } else {
4006                 return 1 * e3.toFixed(extrasPrecision);
4007               }
4008             });
4009           }
4010           function multi(l2) {
4011             return l2.map(point2);
4012           }
4013           function poly(p2) {
4014             return p2.map(multi);
4015           }
4016           function multiPoly(m2) {
4017             return m2.map(poly);
4018           }
4019           function geometry(obj) {
4020             if (!obj) {
4021               return {};
4022             }
4023             switch (obj.type) {
4024               case "Point":
4025                 obj.coordinates = point2(obj.coordinates);
4026                 return obj;
4027               case "LineString":
4028               case "MultiPoint":
4029                 obj.coordinates = multi(obj.coordinates);
4030                 return obj;
4031               case "Polygon":
4032               case "MultiLineString":
4033                 obj.coordinates = poly(obj.coordinates);
4034                 return obj;
4035               case "MultiPolygon":
4036                 obj.coordinates = multiPoly(obj.coordinates);
4037                 return obj;
4038               case "GeometryCollection":
4039                 obj.geometries = obj.geometries.map(geometry);
4040                 return obj;
4041               default:
4042                 return {};
4043             }
4044           }
4045           function feature3(obj) {
4046             obj.geometry = geometry(obj.geometry);
4047             return obj;
4048           }
4049           function featureCollection(f2) {
4050             f2.features = f2.features.map(feature3);
4051             return f2;
4052           }
4053           function geometryCollection(g3) {
4054             g3.geometries = g3.geometries.map(geometry);
4055             return g3;
4056           }
4057           if (!t2) {
4058             return t2;
4059           }
4060           switch (t2.type) {
4061             case "Feature":
4062               return feature3(t2);
4063             case "GeometryCollection":
4064               return geometryCollection(t2);
4065             case "FeatureCollection":
4066               return featureCollection(t2);
4067             case "Point":
4068             case "LineString":
4069             case "Polygon":
4070             case "MultiPoint":
4071             case "MultiPolygon":
4072             case "MultiLineString":
4073               return geometry(t2);
4074             default:
4075               return t2;
4076           }
4077         }
4078         module2.exports = parse;
4079         module2.exports.parse = parse;
4080       })();
4081     }
4082   });
4083
4084   // node_modules/@aitodotai/json-stringify-pretty-compact/index.js
4085   var require_json_stringify_pretty_compact = __commonJS({
4086     "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) {
4087       function isObject3(obj) {
4088         return typeof obj === "object" && obj !== null;
4089       }
4090       function forEach(obj, cb) {
4091         if (Array.isArray(obj)) {
4092           obj.forEach(cb);
4093         } else if (isObject3(obj)) {
4094           Object.keys(obj).forEach(function(key) {
4095             var val = obj[key];
4096             cb(val, key);
4097           });
4098         }
4099       }
4100       function getTreeDepth(obj) {
4101         var depth = 0;
4102         if (Array.isArray(obj) || isObject3(obj)) {
4103           forEach(obj, function(val) {
4104             if (Array.isArray(val) || isObject3(val)) {
4105               var tmpDepth = getTreeDepth(val);
4106               if (tmpDepth > depth) {
4107                 depth = tmpDepth;
4108               }
4109             }
4110           });
4111           return depth + 1;
4112         }
4113         return depth;
4114       }
4115       function stringify3(obj, options2) {
4116         options2 = options2 || {};
4117         var indent = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3);
4118         var addMargin = get4(options2, "margins", false);
4119         var addArrayMargin = get4(options2, "arrayMargins", false);
4120         var addObjectMargin = get4(options2, "objectMargins", false);
4121         var maxLength = indent === "" ? Infinity : get4(options2, "maxLength", 80);
4122         var maxNesting = get4(options2, "maxNesting", Infinity);
4123         return function _stringify(obj2, currentIndent, reserved) {
4124           if (obj2 && typeof obj2.toJSON === "function") {
4125             obj2 = obj2.toJSON();
4126           }
4127           var string = JSON.stringify(obj2);
4128           if (string === void 0) {
4129             return string;
4130           }
4131           var length2 = maxLength - currentIndent.length - reserved;
4132           var treeDepth = getTreeDepth(obj2);
4133           if (treeDepth <= maxNesting && string.length <= length2) {
4134             var prettified = prettify(string, {
4135               addMargin,
4136               addArrayMargin,
4137               addObjectMargin
4138             });
4139             if (prettified.length <= length2) {
4140               return prettified;
4141             }
4142           }
4143           if (isObject3(obj2)) {
4144             var nextIndent = currentIndent + indent;
4145             var items = [];
4146             var delimiters;
4147             var comma = function(array2, index2) {
4148               return index2 === array2.length - 1 ? 0 : 1;
4149             };
4150             if (Array.isArray(obj2)) {
4151               for (var index = 0; index < obj2.length; index++) {
4152                 items.push(
4153                   _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null"
4154                 );
4155               }
4156               delimiters = "[]";
4157             } else {
4158               Object.keys(obj2).forEach(function(key, index2, array2) {
4159                 var keyPart = JSON.stringify(key) + ": ";
4160                 var value = _stringify(
4161                   obj2[key],
4162                   nextIndent,
4163                   keyPart.length + comma(array2, index2)
4164                 );
4165                 if (value !== void 0) {
4166                   items.push(keyPart + value);
4167                 }
4168               });
4169               delimiters = "{}";
4170             }
4171             if (items.length > 0) {
4172               return [
4173                 delimiters[0],
4174                 indent + items.join(",\n" + nextIndent),
4175                 delimiters[1]
4176               ].join("\n" + currentIndent);
4177             }
4178           }
4179           return string;
4180         }(obj, "", 0);
4181       }
4182       var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g;
4183       function prettify(string, options2) {
4184         options2 = options2 || {};
4185         var tokens = {
4186           "{": "{",
4187           "}": "}",
4188           "[": "[",
4189           "]": "]",
4190           ",": ", ",
4191           ":": ": "
4192         };
4193         if (options2.addMargin || options2.addObjectMargin) {
4194           tokens["{"] = "{ ";
4195           tokens["}"] = " }";
4196         }
4197         if (options2.addMargin || options2.addArrayMargin) {
4198           tokens["["] = "[ ";
4199           tokens["]"] = " ]";
4200         }
4201         return string.replace(stringOrChar, function(match, string2) {
4202           return string2 ? match : tokens[match];
4203         });
4204       }
4205       function get4(options2, name, defaultValue) {
4206         return name in options2 ? options2[name] : defaultValue;
4207       }
4208       module2.exports = stringify3;
4209     }
4210   });
4211
4212   // node_modules/aes-js/index.js
4213   var require_aes_js = __commonJS({
4214     "node_modules/aes-js/index.js"(exports2, module2) {
4215       (function(root3) {
4216         "use strict";
4217         function checkInt(value) {
4218           return parseInt(value) === value;
4219         }
4220         function checkInts(arrayish) {
4221           if (!checkInt(arrayish.length)) {
4222             return false;
4223           }
4224           for (var i3 = 0; i3 < arrayish.length; i3++) {
4225             if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) {
4226               return false;
4227             }
4228           }
4229           return true;
4230         }
4231         function coerceArray(arg, copy2) {
4232           if (arg.buffer && arg.name === "Uint8Array") {
4233             if (copy2) {
4234               if (arg.slice) {
4235                 arg = arg.slice();
4236               } else {
4237                 arg = Array.prototype.slice.call(arg);
4238               }
4239             }
4240             return arg;
4241           }
4242           if (Array.isArray(arg)) {
4243             if (!checkInts(arg)) {
4244               throw new Error("Array contains invalid value: " + arg);
4245             }
4246             return new Uint8Array(arg);
4247           }
4248           if (checkInt(arg.length) && checkInts(arg)) {
4249             return new Uint8Array(arg);
4250           }
4251           throw new Error("unsupported array-like object");
4252         }
4253         function createArray(length2) {
4254           return new Uint8Array(length2);
4255         }
4256         function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
4257           if (sourceStart != null || sourceEnd != null) {
4258             if (sourceArray.slice) {
4259               sourceArray = sourceArray.slice(sourceStart, sourceEnd);
4260             } else {
4261               sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
4262             }
4263           }
4264           targetArray.set(sourceArray, targetStart);
4265         }
4266         var convertUtf8 = /* @__PURE__ */ function() {
4267           function toBytes(text) {
4268             var result = [], i3 = 0;
4269             text = encodeURI(text);
4270             while (i3 < text.length) {
4271               var c2 = text.charCodeAt(i3++);
4272               if (c2 === 37) {
4273                 result.push(parseInt(text.substr(i3, 2), 16));
4274                 i3 += 2;
4275               } else {
4276                 result.push(c2);
4277               }
4278             }
4279             return coerceArray(result);
4280           }
4281           function fromBytes(bytes) {
4282             var result = [], i3 = 0;
4283             while (i3 < bytes.length) {
4284               var c2 = bytes[i3];
4285               if (c2 < 128) {
4286                 result.push(String.fromCharCode(c2));
4287                 i3++;
4288               } else if (c2 > 191 && c2 < 224) {
4289                 result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63));
4290                 i3 += 2;
4291               } else {
4292                 result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63));
4293                 i3 += 3;
4294               }
4295             }
4296             return result.join("");
4297           }
4298           return {
4299             toBytes,
4300             fromBytes
4301           };
4302         }();
4303         var convertHex = /* @__PURE__ */ function() {
4304           function toBytes(text) {
4305             var result = [];
4306             for (var i3 = 0; i3 < text.length; i3 += 2) {
4307               result.push(parseInt(text.substr(i3, 2), 16));
4308             }
4309             return result;
4310           }
4311           var Hex = "0123456789abcdef";
4312           function fromBytes(bytes) {
4313             var result = [];
4314             for (var i3 = 0; i3 < bytes.length; i3++) {
4315               var v2 = bytes[i3];
4316               result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]);
4317             }
4318             return result.join("");
4319           }
4320           return {
4321             toBytes,
4322             fromBytes
4323           };
4324         }();
4325         var numberOfRounds = { 16: 10, 24: 12, 32: 14 };
4326         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];
4327         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];
4328         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];
4329         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];
4330         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];
4331         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];
4332         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];
4333         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];
4334         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];
4335         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];
4336         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];
4337         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];
4338         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];
4339         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];
4340         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];
4341         function convertToInt32(bytes) {
4342           var result = [];
4343           for (var i3 = 0; i3 < bytes.length; i3 += 4) {
4344             result.push(
4345               bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3]
4346             );
4347           }
4348           return result;
4349         }
4350         var AES = function(key) {
4351           if (!(this instanceof AES)) {
4352             throw Error("AES must be instanitated with `new`");
4353           }
4354           Object.defineProperty(this, "key", {
4355             value: coerceArray(key, true)
4356           });
4357           this._prepare();
4358         };
4359         AES.prototype._prepare = function() {
4360           var rounds = numberOfRounds[this.key.length];
4361           if (rounds == null) {
4362             throw new Error("invalid key size (must be 16, 24 or 32 bytes)");
4363           }
4364           this._Ke = [];
4365           this._Kd = [];
4366           for (var i3 = 0; i3 <= rounds; i3++) {
4367             this._Ke.push([0, 0, 0, 0]);
4368             this._Kd.push([0, 0, 0, 0]);
4369           }
4370           var roundKeyCount = (rounds + 1) * 4;
4371           var KC = this.key.length / 4;
4372           var tk = convertToInt32(this.key);
4373           var index;
4374           for (var i3 = 0; i3 < KC; i3++) {
4375             index = i3 >> 2;
4376             this._Ke[index][i3 % 4] = tk[i3];
4377             this._Kd[rounds - index][i3 % 4] = tk[i3];
4378           }
4379           var rconpointer = 0;
4380           var t2 = KC, tt2;
4381           while (t2 < roundKeyCount) {
4382             tt2 = tk[KC - 1];
4383             tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24;
4384             rconpointer += 1;
4385             if (KC != 8) {
4386               for (var i3 = 1; i3 < KC; i3++) {
4387                 tk[i3] ^= tk[i3 - 1];
4388               }
4389             } else {
4390               for (var i3 = 1; i3 < KC / 2; i3++) {
4391                 tk[i3] ^= tk[i3 - 1];
4392               }
4393               tt2 = tk[KC / 2 - 1];
4394               tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24;
4395               for (var i3 = KC / 2 + 1; i3 < KC; i3++) {
4396                 tk[i3] ^= tk[i3 - 1];
4397               }
4398             }
4399             var i3 = 0, r2, c2;
4400             while (i3 < KC && t2 < roundKeyCount) {
4401               r2 = t2 >> 2;
4402               c2 = t2 % 4;
4403               this._Ke[r2][c2] = tk[i3];
4404               this._Kd[rounds - r2][c2] = tk[i3++];
4405               t2++;
4406             }
4407           }
4408           for (var r2 = 1; r2 < rounds; r2++) {
4409             for (var c2 = 0; c2 < 4; c2++) {
4410               tt2 = this._Kd[r2][c2];
4411               this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255];
4412             }
4413           }
4414         };
4415         AES.prototype.encrypt = function(plaintext) {
4416           if (plaintext.length != 16) {
4417             throw new Error("invalid plaintext size (must be 16 bytes)");
4418           }
4419           var rounds = this._Ke.length - 1;
4420           var a2 = [0, 0, 0, 0];
4421           var t2 = convertToInt32(plaintext);
4422           for (var i3 = 0; i3 < 4; i3++) {
4423             t2[i3] ^= this._Ke[0][i3];
4424           }
4425           for (var r2 = 1; r2 < rounds; r2++) {
4426             for (var i3 = 0; i3 < 4; i3++) {
4427               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];
4428             }
4429             t2 = a2.slice();
4430           }
4431           var result = createArray(16), tt2;
4432           for (var i3 = 0; i3 < 4; i3++) {
4433             tt2 = this._Ke[rounds][i3];
4434             result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
4435             result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
4436             result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
4437             result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255;
4438           }
4439           return result;
4440         };
4441         AES.prototype.decrypt = function(ciphertext) {
4442           if (ciphertext.length != 16) {
4443             throw new Error("invalid ciphertext size (must be 16 bytes)");
4444           }
4445           var rounds = this._Kd.length - 1;
4446           var a2 = [0, 0, 0, 0];
4447           var t2 = convertToInt32(ciphertext);
4448           for (var i3 = 0; i3 < 4; i3++) {
4449             t2[i3] ^= this._Kd[0][i3];
4450           }
4451           for (var r2 = 1; r2 < rounds; r2++) {
4452             for (var i3 = 0; i3 < 4; i3++) {
4453               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];
4454             }
4455             t2 = a2.slice();
4456           }
4457           var result = createArray(16), tt2;
4458           for (var i3 = 0; i3 < 4; i3++) {
4459             tt2 = this._Kd[rounds][i3];
4460             result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
4461             result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
4462             result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
4463             result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255;
4464           }
4465           return result;
4466         };
4467         var ModeOfOperationECB = function(key) {
4468           if (!(this instanceof ModeOfOperationECB)) {
4469             throw Error("AES must be instanitated with `new`");
4470           }
4471           this.description = "Electronic Code Block";
4472           this.name = "ecb";
4473           this._aes = new AES(key);
4474         };
4475         ModeOfOperationECB.prototype.encrypt = function(plaintext) {
4476           plaintext = coerceArray(plaintext);
4477           if (plaintext.length % 16 !== 0) {
4478             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
4479           }
4480           var ciphertext = createArray(plaintext.length);
4481           var block2 = createArray(16);
4482           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
4483             copyArray(plaintext, block2, 0, i3, i3 + 16);
4484             block2 = this._aes.encrypt(block2);
4485             copyArray(block2, ciphertext, i3);
4486           }
4487           return ciphertext;
4488         };
4489         ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
4490           ciphertext = coerceArray(ciphertext);
4491           if (ciphertext.length % 16 !== 0) {
4492             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
4493           }
4494           var plaintext = createArray(ciphertext.length);
4495           var block2 = createArray(16);
4496           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
4497             copyArray(ciphertext, block2, 0, i3, i3 + 16);
4498             block2 = this._aes.decrypt(block2);
4499             copyArray(block2, plaintext, i3);
4500           }
4501           return plaintext;
4502         };
4503         var ModeOfOperationCBC = function(key, iv) {
4504           if (!(this instanceof ModeOfOperationCBC)) {
4505             throw Error("AES must be instanitated with `new`");
4506           }
4507           this.description = "Cipher Block Chaining";
4508           this.name = "cbc";
4509           if (!iv) {
4510             iv = createArray(16);
4511           } else if (iv.length != 16) {
4512             throw new Error("invalid initialation vector size (must be 16 bytes)");
4513           }
4514           this._lastCipherblock = coerceArray(iv, true);
4515           this._aes = new AES(key);
4516         };
4517         ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
4518           plaintext = coerceArray(plaintext);
4519           if (plaintext.length % 16 !== 0) {
4520             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
4521           }
4522           var ciphertext = createArray(plaintext.length);
4523           var block2 = createArray(16);
4524           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
4525             copyArray(plaintext, block2, 0, i3, i3 + 16);
4526             for (var j2 = 0; j2 < 16; j2++) {
4527               block2[j2] ^= this._lastCipherblock[j2];
4528             }
4529             this._lastCipherblock = this._aes.encrypt(block2);
4530             copyArray(this._lastCipherblock, ciphertext, i3);
4531           }
4532           return ciphertext;
4533         };
4534         ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
4535           ciphertext = coerceArray(ciphertext);
4536           if (ciphertext.length % 16 !== 0) {
4537             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
4538           }
4539           var plaintext = createArray(ciphertext.length);
4540           var block2 = createArray(16);
4541           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
4542             copyArray(ciphertext, block2, 0, i3, i3 + 16);
4543             block2 = this._aes.decrypt(block2);
4544             for (var j2 = 0; j2 < 16; j2++) {
4545               plaintext[i3 + j2] = block2[j2] ^ this._lastCipherblock[j2];
4546             }
4547             copyArray(ciphertext, this._lastCipherblock, 0, i3, i3 + 16);
4548           }
4549           return plaintext;
4550         };
4551         var ModeOfOperationCFB = function(key, iv, segmentSize) {
4552           if (!(this instanceof ModeOfOperationCFB)) {
4553             throw Error("AES must be instanitated with `new`");
4554           }
4555           this.description = "Cipher Feedback";
4556           this.name = "cfb";
4557           if (!iv) {
4558             iv = createArray(16);
4559           } else if (iv.length != 16) {
4560             throw new Error("invalid initialation vector size (must be 16 size)");
4561           }
4562           if (!segmentSize) {
4563             segmentSize = 1;
4564           }
4565           this.segmentSize = segmentSize;
4566           this._shiftRegister = coerceArray(iv, true);
4567           this._aes = new AES(key);
4568         };
4569         ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
4570           if (plaintext.length % this.segmentSize != 0) {
4571             throw new Error("invalid plaintext size (must be segmentSize bytes)");
4572           }
4573           var encrypted = coerceArray(plaintext, true);
4574           var xorSegment;
4575           for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) {
4576             xorSegment = this._aes.encrypt(this._shiftRegister);
4577             for (var j2 = 0; j2 < this.segmentSize; j2++) {
4578               encrypted[i3 + j2] ^= xorSegment[j2];
4579             }
4580             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
4581             copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
4582           }
4583           return encrypted;
4584         };
4585         ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
4586           if (ciphertext.length % this.segmentSize != 0) {
4587             throw new Error("invalid ciphertext size (must be segmentSize bytes)");
4588           }
4589           var plaintext = coerceArray(ciphertext, true);
4590           var xorSegment;
4591           for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) {
4592             xorSegment = this._aes.encrypt(this._shiftRegister);
4593             for (var j2 = 0; j2 < this.segmentSize; j2++) {
4594               plaintext[i3 + j2] ^= xorSegment[j2];
4595             }
4596             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
4597             copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
4598           }
4599           return plaintext;
4600         };
4601         var ModeOfOperationOFB = function(key, iv) {
4602           if (!(this instanceof ModeOfOperationOFB)) {
4603             throw Error("AES must be instanitated with `new`");
4604           }
4605           this.description = "Output Feedback";
4606           this.name = "ofb";
4607           if (!iv) {
4608             iv = createArray(16);
4609           } else if (iv.length != 16) {
4610             throw new Error("invalid initialation vector size (must be 16 bytes)");
4611           }
4612           this._lastPrecipher = coerceArray(iv, true);
4613           this._lastPrecipherIndex = 16;
4614           this._aes = new AES(key);
4615         };
4616         ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
4617           var encrypted = coerceArray(plaintext, true);
4618           for (var i3 = 0; i3 < encrypted.length; i3++) {
4619             if (this._lastPrecipherIndex === 16) {
4620               this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
4621               this._lastPrecipherIndex = 0;
4622             }
4623             encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++];
4624           }
4625           return encrypted;
4626         };
4627         ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
4628         var Counter = function(initialValue) {
4629           if (!(this instanceof Counter)) {
4630             throw Error("Counter must be instanitated with `new`");
4631           }
4632           if (initialValue !== 0 && !initialValue) {
4633             initialValue = 1;
4634           }
4635           if (typeof initialValue === "number") {
4636             this._counter = createArray(16);
4637             this.setValue(initialValue);
4638           } else {
4639             this.setBytes(initialValue);
4640           }
4641         };
4642         Counter.prototype.setValue = function(value) {
4643           if (typeof value !== "number" || parseInt(value) != value) {
4644             throw new Error("invalid counter value (must be an integer)");
4645           }
4646           if (value > Number.MAX_SAFE_INTEGER) {
4647             throw new Error("integer value out of safe range");
4648           }
4649           for (var index = 15; index >= 0; --index) {
4650             this._counter[index] = value % 256;
4651             value = parseInt(value / 256);
4652           }
4653         };
4654         Counter.prototype.setBytes = function(bytes) {
4655           bytes = coerceArray(bytes, true);
4656           if (bytes.length != 16) {
4657             throw new Error("invalid counter bytes size (must be 16 bytes)");
4658           }
4659           this._counter = bytes;
4660         };
4661         Counter.prototype.increment = function() {
4662           for (var i3 = 15; i3 >= 0; i3--) {
4663             if (this._counter[i3] === 255) {
4664               this._counter[i3] = 0;
4665             } else {
4666               this._counter[i3]++;
4667               break;
4668             }
4669           }
4670         };
4671         var ModeOfOperationCTR = function(key, counter) {
4672           if (!(this instanceof ModeOfOperationCTR)) {
4673             throw Error("AES must be instanitated with `new`");
4674           }
4675           this.description = "Counter";
4676           this.name = "ctr";
4677           if (!(counter instanceof Counter)) {
4678             counter = new Counter(counter);
4679           }
4680           this._counter = counter;
4681           this._remainingCounter = null;
4682           this._remainingCounterIndex = 16;
4683           this._aes = new AES(key);
4684         };
4685         ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
4686           var encrypted = coerceArray(plaintext, true);
4687           for (var i3 = 0; i3 < encrypted.length; i3++) {
4688             if (this._remainingCounterIndex === 16) {
4689               this._remainingCounter = this._aes.encrypt(this._counter._counter);
4690               this._remainingCounterIndex = 0;
4691               this._counter.increment();
4692             }
4693             encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++];
4694           }
4695           return encrypted;
4696         };
4697         ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
4698         function pkcs7pad(data) {
4699           data = coerceArray(data, true);
4700           var padder = 16 - data.length % 16;
4701           var result = createArray(data.length + padder);
4702           copyArray(data, result);
4703           for (var i3 = data.length; i3 < result.length; i3++) {
4704             result[i3] = padder;
4705           }
4706           return result;
4707         }
4708         function pkcs7strip(data) {
4709           data = coerceArray(data, true);
4710           if (data.length < 16) {
4711             throw new Error("PKCS#7 invalid length");
4712           }
4713           var padder = data[data.length - 1];
4714           if (padder > 16) {
4715             throw new Error("PKCS#7 padding byte out of range");
4716           }
4717           var length2 = data.length - padder;
4718           for (var i3 = 0; i3 < padder; i3++) {
4719             if (data[length2 + i3] !== padder) {
4720               throw new Error("PKCS#7 invalid padding byte");
4721             }
4722           }
4723           var result = createArray(length2);
4724           copyArray(data, result, 0, 0, length2);
4725           return result;
4726         }
4727         var aesjs2 = {
4728           AES,
4729           Counter,
4730           ModeOfOperation: {
4731             ecb: ModeOfOperationECB,
4732             cbc: ModeOfOperationCBC,
4733             cfb: ModeOfOperationCFB,
4734             ofb: ModeOfOperationOFB,
4735             ctr: ModeOfOperationCTR
4736           },
4737           utils: {
4738             hex: convertHex,
4739             utf8: convertUtf8
4740           },
4741           padding: {
4742             pkcs7: {
4743               pad: pkcs7pad,
4744               strip: pkcs7strip
4745             }
4746           },
4747           _arrayTest: {
4748             coerceArray,
4749             createArray,
4750             copyArray
4751           }
4752         };
4753         if (typeof exports2 !== "undefined") {
4754           module2.exports = aesjs2;
4755         } else if (typeof define === "function" && define.amd) {
4756           define([], function() {
4757             return aesjs2;
4758           });
4759         } else {
4760           if (root3.aesjs) {
4761             aesjs2._aesjs = root3.aesjs;
4762           }
4763           root3.aesjs = aesjs2;
4764         }
4765       })(exports2);
4766     }
4767   });
4768
4769   // node_modules/lodash/lodash.js
4770   var require_lodash = __commonJS({
4771     "node_modules/lodash/lodash.js"(exports2, module2) {
4772       (function() {
4773         var undefined2;
4774         var VERSION = "4.17.21";
4775         var LARGE_ARRAY_SIZE2 = 200;
4776         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`";
4777         var HASH_UNDEFINED4 = "__lodash_hash_undefined__";
4778         var MAX_MEMOIZE_SIZE = 500;
4779         var PLACEHOLDER = "__lodash_placeholder__";
4780         var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
4781         var COMPARE_PARTIAL_FLAG5 = 1, COMPARE_UNORDERED_FLAG3 = 2;
4782         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;
4783         var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "...";
4784         var HOT_COUNT = 800, HOT_SPAN = 16;
4785         var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2, LAZY_WHILE_FLAG = 3;
4786         var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER4 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0;
4787         var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
4788         var wrapFlags = [
4789           ["ary", WRAP_ARY_FLAG],
4790           ["bind", WRAP_BIND_FLAG],
4791           ["bindKey", WRAP_BIND_KEY_FLAG],
4792           ["curry", WRAP_CURRY_FLAG],
4793           ["curryRight", WRAP_CURRY_RIGHT_FLAG],
4794           ["flip", WRAP_FLIP_FLAG],
4795           ["partial", WRAP_PARTIAL_FLAG],
4796           ["partialRight", WRAP_PARTIAL_RIGHT_FLAG],
4797           ["rearg", WRAP_REARG_FLAG]
4798         ];
4799         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]";
4800         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]";
4801         var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
4802         var reEscapedHtml2 = /&(?:amp|lt|gt|quot|#39);/g, reUnescapedHtml2 = /[&<>"']/g, reHasEscapedHtml2 = RegExp(reEscapedHtml2.source), reHasUnescapedHtml2 = RegExp(reUnescapedHtml2.source);
4803         var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g;
4804         var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
4805         var reRegExpChar2 = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar2.source);
4806         var reTrimStart2 = /^\s+/;
4807         var reWhitespace2 = /\s/;
4808         var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, reSplitDetails = /,? & /;
4809         var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
4810         var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
4811         var reEscapeChar = /\\(\\)?/g;
4812         var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
4813         var reFlags = /\w*$/;
4814         var reIsBadHex2 = /^[-+]0x[0-9a-f]+$/i;
4815         var reIsBinary2 = /^0b[01]+$/i;
4816         var reIsHostCtor2 = /^\[object .+?Constructor\]$/;
4817         var reIsOctal2 = /^0o[0-7]+$/i;
4818         var reIsUint2 = /^(?:0|[1-9]\d*)$/;
4819         var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
4820         var reNoMatch = /($^)/;
4821         var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
4822         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;
4823         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";
4824         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("|") + ")";
4825         var reApos = RegExp(rsApos, "g");
4826         var reComboMark = RegExp(rsCombo, "g");
4827         var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
4828         var reUnicodeWord = RegExp([
4829           rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
4830           rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
4831           rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
4832           rsUpper + "+" + rsOptContrUpper,
4833           rsOrdUpper,
4834           rsOrdLower,
4835           rsDigits,
4836           rsEmoji
4837         ].join("|"), "g");
4838         var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
4839         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 ]/;
4840         var contextProps = [
4841           "Array",
4842           "Buffer",
4843           "DataView",
4844           "Date",
4845           "Error",
4846           "Float32Array",
4847           "Float64Array",
4848           "Function",
4849           "Int8Array",
4850           "Int16Array",
4851           "Int32Array",
4852           "Map",
4853           "Math",
4854           "Object",
4855           "Promise",
4856           "RegExp",
4857           "Set",
4858           "String",
4859           "Symbol",
4860           "TypeError",
4861           "Uint8Array",
4862           "Uint8ClampedArray",
4863           "Uint16Array",
4864           "Uint32Array",
4865           "WeakMap",
4866           "_",
4867           "clearTimeout",
4868           "isFinite",
4869           "parseInt",
4870           "setTimeout"
4871         ];
4872         var templateCounter = -1;
4873         var typedArrayTags2 = {};
4874         typedArrayTags2[float32Tag2] = typedArrayTags2[float64Tag2] = typedArrayTags2[int8Tag2] = typedArrayTags2[int16Tag2] = typedArrayTags2[int32Tag2] = typedArrayTags2[uint8Tag2] = typedArrayTags2[uint8ClampedTag2] = typedArrayTags2[uint16Tag2] = typedArrayTags2[uint32Tag2] = true;
4875         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;
4876         var cloneableTags = {};
4877         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;
4878         cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
4879         var deburredLetters = {
4880           // Latin-1 Supplement block.
4881           "\xC0": "A",
4882           "\xC1": "A",
4883           "\xC2": "A",
4884           "\xC3": "A",
4885           "\xC4": "A",
4886           "\xC5": "A",
4887           "\xE0": "a",
4888           "\xE1": "a",
4889           "\xE2": "a",
4890           "\xE3": "a",
4891           "\xE4": "a",
4892           "\xE5": "a",
4893           "\xC7": "C",
4894           "\xE7": "c",
4895           "\xD0": "D",
4896           "\xF0": "d",
4897           "\xC8": "E",
4898           "\xC9": "E",
4899           "\xCA": "E",
4900           "\xCB": "E",
4901           "\xE8": "e",
4902           "\xE9": "e",
4903           "\xEA": "e",
4904           "\xEB": "e",
4905           "\xCC": "I",
4906           "\xCD": "I",
4907           "\xCE": "I",
4908           "\xCF": "I",
4909           "\xEC": "i",
4910           "\xED": "i",
4911           "\xEE": "i",
4912           "\xEF": "i",
4913           "\xD1": "N",
4914           "\xF1": "n",
4915           "\xD2": "O",
4916           "\xD3": "O",
4917           "\xD4": "O",
4918           "\xD5": "O",
4919           "\xD6": "O",
4920           "\xD8": "O",
4921           "\xF2": "o",
4922           "\xF3": "o",
4923           "\xF4": "o",
4924           "\xF5": "o",
4925           "\xF6": "o",
4926           "\xF8": "o",
4927           "\xD9": "U",
4928           "\xDA": "U",
4929           "\xDB": "U",
4930           "\xDC": "U",
4931           "\xF9": "u",
4932           "\xFA": "u",
4933           "\xFB": "u",
4934           "\xFC": "u",
4935           "\xDD": "Y",
4936           "\xFD": "y",
4937           "\xFF": "y",
4938           "\xC6": "Ae",
4939           "\xE6": "ae",
4940           "\xDE": "Th",
4941           "\xFE": "th",
4942           "\xDF": "ss",
4943           // Latin Extended-A block.
4944           "\u0100": "A",
4945           "\u0102": "A",
4946           "\u0104": "A",
4947           "\u0101": "a",
4948           "\u0103": "a",
4949           "\u0105": "a",
4950           "\u0106": "C",
4951           "\u0108": "C",
4952           "\u010A": "C",
4953           "\u010C": "C",
4954           "\u0107": "c",
4955           "\u0109": "c",
4956           "\u010B": "c",
4957           "\u010D": "c",
4958           "\u010E": "D",
4959           "\u0110": "D",
4960           "\u010F": "d",
4961           "\u0111": "d",
4962           "\u0112": "E",
4963           "\u0114": "E",
4964           "\u0116": "E",
4965           "\u0118": "E",
4966           "\u011A": "E",
4967           "\u0113": "e",
4968           "\u0115": "e",
4969           "\u0117": "e",
4970           "\u0119": "e",
4971           "\u011B": "e",
4972           "\u011C": "G",
4973           "\u011E": "G",
4974           "\u0120": "G",
4975           "\u0122": "G",
4976           "\u011D": "g",
4977           "\u011F": "g",
4978           "\u0121": "g",
4979           "\u0123": "g",
4980           "\u0124": "H",
4981           "\u0126": "H",
4982           "\u0125": "h",
4983           "\u0127": "h",
4984           "\u0128": "I",
4985           "\u012A": "I",
4986           "\u012C": "I",
4987           "\u012E": "I",
4988           "\u0130": "I",
4989           "\u0129": "i",
4990           "\u012B": "i",
4991           "\u012D": "i",
4992           "\u012F": "i",
4993           "\u0131": "i",
4994           "\u0134": "J",
4995           "\u0135": "j",
4996           "\u0136": "K",
4997           "\u0137": "k",
4998           "\u0138": "k",
4999           "\u0139": "L",
5000           "\u013B": "L",
5001           "\u013D": "L",
5002           "\u013F": "L",
5003           "\u0141": "L",
5004           "\u013A": "l",
5005           "\u013C": "l",
5006           "\u013E": "l",
5007           "\u0140": "l",
5008           "\u0142": "l",
5009           "\u0143": "N",
5010           "\u0145": "N",
5011           "\u0147": "N",
5012           "\u014A": "N",
5013           "\u0144": "n",
5014           "\u0146": "n",
5015           "\u0148": "n",
5016           "\u014B": "n",
5017           "\u014C": "O",
5018           "\u014E": "O",
5019           "\u0150": "O",
5020           "\u014D": "o",
5021           "\u014F": "o",
5022           "\u0151": "o",
5023           "\u0154": "R",
5024           "\u0156": "R",
5025           "\u0158": "R",
5026           "\u0155": "r",
5027           "\u0157": "r",
5028           "\u0159": "r",
5029           "\u015A": "S",
5030           "\u015C": "S",
5031           "\u015E": "S",
5032           "\u0160": "S",
5033           "\u015B": "s",
5034           "\u015D": "s",
5035           "\u015F": "s",
5036           "\u0161": "s",
5037           "\u0162": "T",
5038           "\u0164": "T",
5039           "\u0166": "T",
5040           "\u0163": "t",
5041           "\u0165": "t",
5042           "\u0167": "t",
5043           "\u0168": "U",
5044           "\u016A": "U",
5045           "\u016C": "U",
5046           "\u016E": "U",
5047           "\u0170": "U",
5048           "\u0172": "U",
5049           "\u0169": "u",
5050           "\u016B": "u",
5051           "\u016D": "u",
5052           "\u016F": "u",
5053           "\u0171": "u",
5054           "\u0173": "u",
5055           "\u0174": "W",
5056           "\u0175": "w",
5057           "\u0176": "Y",
5058           "\u0177": "y",
5059           "\u0178": "Y",
5060           "\u0179": "Z",
5061           "\u017B": "Z",
5062           "\u017D": "Z",
5063           "\u017A": "z",
5064           "\u017C": "z",
5065           "\u017E": "z",
5066           "\u0132": "IJ",
5067           "\u0133": "ij",
5068           "\u0152": "Oe",
5069           "\u0153": "oe",
5070           "\u0149": "'n",
5071           "\u017F": "s"
5072         };
5073         var htmlEscapes2 = {
5074           "&": "&amp;",
5075           "<": "&lt;",
5076           ">": "&gt;",
5077           '"': "&quot;",
5078           "'": "&#39;"
5079         };
5080         var htmlUnescapes2 = {
5081           "&amp;": "&",
5082           "&lt;": "<",
5083           "&gt;": ">",
5084           "&quot;": '"',
5085           "&#39;": "'"
5086         };
5087         var stringEscapes = {
5088           "\\": "\\",
5089           "'": "'",
5090           "\n": "n",
5091           "\r": "r",
5092           "\u2028": "u2028",
5093           "\u2029": "u2029"
5094         };
5095         var freeParseFloat = parseFloat, freeParseInt2 = parseInt;
5096         var freeGlobal2 = typeof global == "object" && global && global.Object === Object && global;
5097         var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
5098         var root3 = freeGlobal2 || freeSelf2 || Function("return this")();
5099         var freeExports3 = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
5100         var freeModule3 = freeExports3 && typeof module2 == "object" && module2 && !module2.nodeType && module2;
5101         var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
5102         var freeProcess2 = moduleExports3 && freeGlobal2.process;
5103         var nodeUtil2 = function() {
5104           try {
5105             var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
5106             if (types) {
5107               return types;
5108             }
5109             return freeProcess2 && freeProcess2.binding && freeProcess2.binding("util");
5110           } catch (e3) {
5111           }
5112         }();
5113         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;
5114         function apply(func, thisArg, args) {
5115           switch (args.length) {
5116             case 0:
5117               return func.call(thisArg);
5118             case 1:
5119               return func.call(thisArg, args[0]);
5120             case 2:
5121               return func.call(thisArg, args[0], args[1]);
5122             case 3:
5123               return func.call(thisArg, args[0], args[1], args[2]);
5124           }
5125           return func.apply(thisArg, args);
5126         }
5127         function arrayAggregator(array2, setter, iteratee, accumulator) {
5128           var index = -1, length2 = array2 == null ? 0 : array2.length;
5129           while (++index < length2) {
5130             var value = array2[index];
5131             setter(accumulator, value, iteratee(value), array2);
5132           }
5133           return accumulator;
5134         }
5135         function arrayEach(array2, iteratee) {
5136           var index = -1, length2 = array2 == null ? 0 : array2.length;
5137           while (++index < length2) {
5138             if (iteratee(array2[index], index, array2) === false) {
5139               break;
5140             }
5141           }
5142           return array2;
5143         }
5144         function arrayEachRight(array2, iteratee) {
5145           var length2 = array2 == null ? 0 : array2.length;
5146           while (length2--) {
5147             if (iteratee(array2[length2], length2, array2) === false) {
5148               break;
5149             }
5150           }
5151           return array2;
5152         }
5153         function arrayEvery(array2, predicate) {
5154           var index = -1, length2 = array2 == null ? 0 : array2.length;
5155           while (++index < length2) {
5156             if (!predicate(array2[index], index, array2)) {
5157               return false;
5158             }
5159           }
5160           return true;
5161         }
5162         function arrayFilter2(array2, predicate) {
5163           var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
5164           while (++index < length2) {
5165             var value = array2[index];
5166             if (predicate(value, index, array2)) {
5167               result[resIndex++] = value;
5168             }
5169           }
5170           return result;
5171         }
5172         function arrayIncludes(array2, value) {
5173           var length2 = array2 == null ? 0 : array2.length;
5174           return !!length2 && baseIndexOf(array2, value, 0) > -1;
5175         }
5176         function arrayIncludesWith(array2, value, comparator) {
5177           var index = -1, length2 = array2 == null ? 0 : array2.length;
5178           while (++index < length2) {
5179             if (comparator(value, array2[index])) {
5180               return true;
5181             }
5182           }
5183           return false;
5184         }
5185         function arrayMap2(array2, iteratee) {
5186           var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
5187           while (++index < length2) {
5188             result[index] = iteratee(array2[index], index, array2);
5189           }
5190           return result;
5191         }
5192         function arrayPush2(array2, values) {
5193           var index = -1, length2 = values.length, offset = array2.length;
5194           while (++index < length2) {
5195             array2[offset + index] = values[index];
5196           }
5197           return array2;
5198         }
5199         function arrayReduce(array2, iteratee, accumulator, initAccum) {
5200           var index = -1, length2 = array2 == null ? 0 : array2.length;
5201           if (initAccum && length2) {
5202             accumulator = array2[++index];
5203           }
5204           while (++index < length2) {
5205             accumulator = iteratee(accumulator, array2[index], index, array2);
5206           }
5207           return accumulator;
5208         }
5209         function arrayReduceRight(array2, iteratee, accumulator, initAccum) {
5210           var length2 = array2 == null ? 0 : array2.length;
5211           if (initAccum && length2) {
5212             accumulator = array2[--length2];
5213           }
5214           while (length2--) {
5215             accumulator = iteratee(accumulator, array2[length2], length2, array2);
5216           }
5217           return accumulator;
5218         }
5219         function arraySome2(array2, predicate) {
5220           var index = -1, length2 = array2 == null ? 0 : array2.length;
5221           while (++index < length2) {
5222             if (predicate(array2[index], index, array2)) {
5223               return true;
5224             }
5225           }
5226           return false;
5227         }
5228         var asciiSize = baseProperty("length");
5229         function asciiToArray(string) {
5230           return string.split("");
5231         }
5232         function asciiWords(string) {
5233           return string.match(reAsciiWord) || [];
5234         }
5235         function baseFindKey(collection, predicate, eachFunc) {
5236           var result;
5237           eachFunc(collection, function(value, key, collection2) {
5238             if (predicate(value, key, collection2)) {
5239               result = key;
5240               return false;
5241             }
5242           });
5243           return result;
5244         }
5245         function baseFindIndex(array2, predicate, fromIndex, fromRight) {
5246           var length2 = array2.length, index = fromIndex + (fromRight ? 1 : -1);
5247           while (fromRight ? index-- : ++index < length2) {
5248             if (predicate(array2[index], index, array2)) {
5249               return index;
5250             }
5251           }
5252           return -1;
5253         }
5254         function baseIndexOf(array2, value, fromIndex) {
5255           return value === value ? strictIndexOf(array2, value, fromIndex) : baseFindIndex(array2, baseIsNaN, fromIndex);
5256         }
5257         function baseIndexOfWith(array2, value, fromIndex, comparator) {
5258           var index = fromIndex - 1, length2 = array2.length;
5259           while (++index < length2) {
5260             if (comparator(array2[index], value)) {
5261               return index;
5262             }
5263           }
5264           return -1;
5265         }
5266         function baseIsNaN(value) {
5267           return value !== value;
5268         }
5269         function baseMean(array2, iteratee) {
5270           var length2 = array2 == null ? 0 : array2.length;
5271           return length2 ? baseSum(array2, iteratee) / length2 : NAN2;
5272         }
5273         function baseProperty(key) {
5274           return function(object) {
5275             return object == null ? undefined2 : object[key];
5276           };
5277         }
5278         function basePropertyOf2(object) {
5279           return function(key) {
5280             return object == null ? undefined2 : object[key];
5281           };
5282         }
5283         function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
5284           eachFunc(collection, function(value, index, collection2) {
5285             accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection2);
5286           });
5287           return accumulator;
5288         }
5289         function baseSortBy(array2, comparer) {
5290           var length2 = array2.length;
5291           array2.sort(comparer);
5292           while (length2--) {
5293             array2[length2] = array2[length2].value;
5294           }
5295           return array2;
5296         }
5297         function baseSum(array2, iteratee) {
5298           var result, index = -1, length2 = array2.length;
5299           while (++index < length2) {
5300             var current = iteratee(array2[index]);
5301             if (current !== undefined2) {
5302               result = result === undefined2 ? current : result + current;
5303             }
5304           }
5305           return result;
5306         }
5307         function baseTimes2(n3, iteratee) {
5308           var index = -1, result = Array(n3);
5309           while (++index < n3) {
5310             result[index] = iteratee(index);
5311           }
5312           return result;
5313         }
5314         function baseToPairs(object, props) {
5315           return arrayMap2(props, function(key) {
5316             return [key, object[key]];
5317           });
5318         }
5319         function baseTrim2(string) {
5320           return string ? string.slice(0, trimmedEndIndex2(string) + 1).replace(reTrimStart2, "") : string;
5321         }
5322         function baseUnary2(func) {
5323           return function(value) {
5324             return func(value);
5325           };
5326         }
5327         function baseValues(object, props) {
5328           return arrayMap2(props, function(key) {
5329             return object[key];
5330           });
5331         }
5332         function cacheHas2(cache, key) {
5333           return cache.has(key);
5334         }
5335         function charsStartIndex(strSymbols, chrSymbols) {
5336           var index = -1, length2 = strSymbols.length;
5337           while (++index < length2 && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
5338           }
5339           return index;
5340         }
5341         function charsEndIndex(strSymbols, chrSymbols) {
5342           var index = strSymbols.length;
5343           while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
5344           }
5345           return index;
5346         }
5347         function countHolders(array2, placeholder) {
5348           var length2 = array2.length, result = 0;
5349           while (length2--) {
5350             if (array2[length2] === placeholder) {
5351               ++result;
5352             }
5353           }
5354           return result;
5355         }
5356         var deburrLetter = basePropertyOf2(deburredLetters);
5357         var escapeHtmlChar2 = basePropertyOf2(htmlEscapes2);
5358         function escapeStringChar(chr) {
5359           return "\\" + stringEscapes[chr];
5360         }
5361         function getValue2(object, key) {
5362           return object == null ? undefined2 : object[key];
5363         }
5364         function hasUnicode(string) {
5365           return reHasUnicode.test(string);
5366         }
5367         function hasUnicodeWord(string) {
5368           return reHasUnicodeWord.test(string);
5369         }
5370         function iteratorToArray(iterator) {
5371           var data, result = [];
5372           while (!(data = iterator.next()).done) {
5373             result.push(data.value);
5374           }
5375           return result;
5376         }
5377         function mapToArray2(map2) {
5378           var index = -1, result = Array(map2.size);
5379           map2.forEach(function(value, key) {
5380             result[++index] = [key, value];
5381           });
5382           return result;
5383         }
5384         function overArg2(func, transform2) {
5385           return function(arg) {
5386             return func(transform2(arg));
5387           };
5388         }
5389         function replaceHolders(array2, placeholder) {
5390           var index = -1, length2 = array2.length, resIndex = 0, result = [];
5391           while (++index < length2) {
5392             var value = array2[index];
5393             if (value === placeholder || value === PLACEHOLDER) {
5394               array2[index] = PLACEHOLDER;
5395               result[resIndex++] = index;
5396             }
5397           }
5398           return result;
5399         }
5400         function setToArray2(set4) {
5401           var index = -1, result = Array(set4.size);
5402           set4.forEach(function(value) {
5403             result[++index] = value;
5404           });
5405           return result;
5406         }
5407         function setToPairs(set4) {
5408           var index = -1, result = Array(set4.size);
5409           set4.forEach(function(value) {
5410             result[++index] = [value, value];
5411           });
5412           return result;
5413         }
5414         function strictIndexOf(array2, value, fromIndex) {
5415           var index = fromIndex - 1, length2 = array2.length;
5416           while (++index < length2) {
5417             if (array2[index] === value) {
5418               return index;
5419             }
5420           }
5421           return -1;
5422         }
5423         function strictLastIndexOf(array2, value, fromIndex) {
5424           var index = fromIndex + 1;
5425           while (index--) {
5426             if (array2[index] === value) {
5427               return index;
5428             }
5429           }
5430           return index;
5431         }
5432         function stringSize(string) {
5433           return hasUnicode(string) ? unicodeSize(string) : asciiSize(string);
5434         }
5435         function stringToArray(string) {
5436           return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
5437         }
5438         function trimmedEndIndex2(string) {
5439           var index = string.length;
5440           while (index-- && reWhitespace2.test(string.charAt(index))) {
5441           }
5442           return index;
5443         }
5444         var unescapeHtmlChar2 = basePropertyOf2(htmlUnescapes2);
5445         function unicodeSize(string) {
5446           var result = reUnicode.lastIndex = 0;
5447           while (reUnicode.test(string)) {
5448             ++result;
5449           }
5450           return result;
5451         }
5452         function unicodeToArray(string) {
5453           return string.match(reUnicode) || [];
5454         }
5455         function unicodeWords(string) {
5456           return string.match(reUnicodeWord) || [];
5457         }
5458         var runInContext = function runInContext2(context) {
5459           context = context == null ? root3 : _2.defaults(root3.Object(), context, _2.pick(root3, contextProps));
5460           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;
5461           var arrayProto2 = Array2.prototype, funcProto3 = Function2.prototype, objectProto13 = Object2.prototype;
5462           var coreJsData2 = context["__core-js_shared__"];
5463           var funcToString3 = funcProto3.toString;
5464           var hasOwnProperty10 = objectProto13.hasOwnProperty;
5465           var idCounter = 0;
5466           var maskSrcKey2 = function() {
5467             var uid = /[^.]+$/.exec(coreJsData2 && coreJsData2.keys && coreJsData2.keys.IE_PROTO || "");
5468             return uid ? "Symbol(src)_1." + uid : "";
5469           }();
5470           var nativeObjectToString3 = objectProto13.toString;
5471           var objectCtorString = funcToString3.call(Object2);
5472           var oldDash = root3._;
5473           var reIsNative2 = RegExp2(
5474             "^" + funcToString3.call(hasOwnProperty10).replace(reRegExpChar2, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
5475           );
5476           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;
5477           var defineProperty = function() {
5478             try {
5479               var func = getNative2(Object2, "defineProperty");
5480               func({}, "", {});
5481               return func;
5482             } catch (e3) {
5483             }
5484           }();
5485           var ctxClearTimeout = context.clearTimeout !== root3.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root3.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root3.setTimeout && context.setTimeout;
5486           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;
5487           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");
5488           var metaMap = WeakMap2 && new WeakMap2();
5489           var realNames = {};
5490           var dataViewCtorString2 = toSource2(DataView3), mapCtorString2 = toSource2(Map3), promiseCtorString2 = toSource2(Promise3), setCtorString2 = toSource2(Set3), weakMapCtorString2 = toSource2(WeakMap2);
5491           var symbolProto3 = Symbol3 ? Symbol3.prototype : undefined2, symbolValueOf2 = symbolProto3 ? symbolProto3.valueOf : undefined2, symbolToString2 = symbolProto3 ? symbolProto3.toString : undefined2;
5492           function lodash(value) {
5493             if (isObjectLike2(value) && !isArray2(value) && !(value instanceof LazyWrapper)) {
5494               if (value instanceof LodashWrapper) {
5495                 return value;
5496               }
5497               if (hasOwnProperty10.call(value, "__wrapped__")) {
5498                 return wrapperClone(value);
5499               }
5500             }
5501             return new LodashWrapper(value);
5502           }
5503           var baseCreate = /* @__PURE__ */ function() {
5504             function object() {
5505             }
5506             return function(proto) {
5507               if (!isObject3(proto)) {
5508                 return {};
5509               }
5510               if (objectCreate) {
5511                 return objectCreate(proto);
5512               }
5513               object.prototype = proto;
5514               var result2 = new object();
5515               object.prototype = undefined2;
5516               return result2;
5517             };
5518           }();
5519           function baseLodash() {
5520           }
5521           function LodashWrapper(value, chainAll) {
5522             this.__wrapped__ = value;
5523             this.__actions__ = [];
5524             this.__chain__ = !!chainAll;
5525             this.__index__ = 0;
5526             this.__values__ = undefined2;
5527           }
5528           lodash.templateSettings = {
5529             /**
5530              * Used to detect `data` property values to be HTML-escaped.
5531              *
5532              * @memberOf _.templateSettings
5533              * @type {RegExp}
5534              */
5535             "escape": reEscape,
5536             /**
5537              * Used to detect code to be evaluated.
5538              *
5539              * @memberOf _.templateSettings
5540              * @type {RegExp}
5541              */
5542             "evaluate": reEvaluate,
5543             /**
5544              * Used to detect `data` property values to inject.
5545              *
5546              * @memberOf _.templateSettings
5547              * @type {RegExp}
5548              */
5549             "interpolate": reInterpolate,
5550             /**
5551              * Used to reference the data object in the template text.
5552              *
5553              * @memberOf _.templateSettings
5554              * @type {string}
5555              */
5556             "variable": "",
5557             /**
5558              * Used to import variables into the compiled template.
5559              *
5560              * @memberOf _.templateSettings
5561              * @type {Object}
5562              */
5563             "imports": {
5564               /**
5565                * A reference to the `lodash` function.
5566                *
5567                * @memberOf _.templateSettings.imports
5568                * @type {Function}
5569                */
5570               "_": lodash
5571             }
5572           };
5573           lodash.prototype = baseLodash.prototype;
5574           lodash.prototype.constructor = lodash;
5575           LodashWrapper.prototype = baseCreate(baseLodash.prototype);
5576           LodashWrapper.prototype.constructor = LodashWrapper;
5577           function LazyWrapper(value) {
5578             this.__wrapped__ = value;
5579             this.__actions__ = [];
5580             this.__dir__ = 1;
5581             this.__filtered__ = false;
5582             this.__iteratees__ = [];
5583             this.__takeCount__ = MAX_ARRAY_LENGTH;
5584             this.__views__ = [];
5585           }
5586           function lazyClone() {
5587             var result2 = new LazyWrapper(this.__wrapped__);
5588             result2.__actions__ = copyArray(this.__actions__);
5589             result2.__dir__ = this.__dir__;
5590             result2.__filtered__ = this.__filtered__;
5591             result2.__iteratees__ = copyArray(this.__iteratees__);
5592             result2.__takeCount__ = this.__takeCount__;
5593             result2.__views__ = copyArray(this.__views__);
5594             return result2;
5595           }
5596           function lazyReverse() {
5597             if (this.__filtered__) {
5598               var result2 = new LazyWrapper(this);
5599               result2.__dir__ = -1;
5600               result2.__filtered__ = true;
5601             } else {
5602               result2 = this.clone();
5603               result2.__dir__ *= -1;
5604             }
5605             return result2;
5606           }
5607           function lazyValue() {
5608             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__);
5609             if (!isArr || !isRight && arrLength == length2 && takeCount == length2) {
5610               return baseWrapperValue(array2, this.__actions__);
5611             }
5612             var result2 = [];
5613             outer:
5614               while (length2-- && resIndex < takeCount) {
5615                 index += dir;
5616                 var iterIndex = -1, value = array2[index];
5617                 while (++iterIndex < iterLength) {
5618                   var data = iteratees[iterIndex], iteratee2 = data.iteratee, type2 = data.type, computed = iteratee2(value);
5619                   if (type2 == LAZY_MAP_FLAG) {
5620                     value = computed;
5621                   } else if (!computed) {
5622                     if (type2 == LAZY_FILTER_FLAG) {
5623                       continue outer;
5624                     } else {
5625                       break outer;
5626                     }
5627                   }
5628                 }
5629                 result2[resIndex++] = value;
5630               }
5631             return result2;
5632           }
5633           LazyWrapper.prototype = baseCreate(baseLodash.prototype);
5634           LazyWrapper.prototype.constructor = LazyWrapper;
5635           function Hash2(entries) {
5636             var index = -1, length2 = entries == null ? 0 : entries.length;
5637             this.clear();
5638             while (++index < length2) {
5639               var entry = entries[index];
5640               this.set(entry[0], entry[1]);
5641             }
5642           }
5643           function hashClear2() {
5644             this.__data__ = nativeCreate2 ? nativeCreate2(null) : {};
5645             this.size = 0;
5646           }
5647           function hashDelete2(key) {
5648             var result2 = this.has(key) && delete this.__data__[key];
5649             this.size -= result2 ? 1 : 0;
5650             return result2;
5651           }
5652           function hashGet2(key) {
5653             var data = this.__data__;
5654             if (nativeCreate2) {
5655               var result2 = data[key];
5656               return result2 === HASH_UNDEFINED4 ? undefined2 : result2;
5657             }
5658             return hasOwnProperty10.call(data, key) ? data[key] : undefined2;
5659           }
5660           function hashHas2(key) {
5661             var data = this.__data__;
5662             return nativeCreate2 ? data[key] !== undefined2 : hasOwnProperty10.call(data, key);
5663           }
5664           function hashSet2(key, value) {
5665             var data = this.__data__;
5666             this.size += this.has(key) ? 0 : 1;
5667             data[key] = nativeCreate2 && value === undefined2 ? HASH_UNDEFINED4 : value;
5668             return this;
5669           }
5670           Hash2.prototype.clear = hashClear2;
5671           Hash2.prototype["delete"] = hashDelete2;
5672           Hash2.prototype.get = hashGet2;
5673           Hash2.prototype.has = hashHas2;
5674           Hash2.prototype.set = hashSet2;
5675           function ListCache2(entries) {
5676             var index = -1, length2 = entries == null ? 0 : entries.length;
5677             this.clear();
5678             while (++index < length2) {
5679               var entry = entries[index];
5680               this.set(entry[0], entry[1]);
5681             }
5682           }
5683           function listCacheClear2() {
5684             this.__data__ = [];
5685             this.size = 0;
5686           }
5687           function listCacheDelete2(key) {
5688             var data = this.__data__, index = assocIndexOf2(data, key);
5689             if (index < 0) {
5690               return false;
5691             }
5692             var lastIndex = data.length - 1;
5693             if (index == lastIndex) {
5694               data.pop();
5695             } else {
5696               splice2.call(data, index, 1);
5697             }
5698             --this.size;
5699             return true;
5700           }
5701           function listCacheGet2(key) {
5702             var data = this.__data__, index = assocIndexOf2(data, key);
5703             return index < 0 ? undefined2 : data[index][1];
5704           }
5705           function listCacheHas2(key) {
5706             return assocIndexOf2(this.__data__, key) > -1;
5707           }
5708           function listCacheSet2(key, value) {
5709             var data = this.__data__, index = assocIndexOf2(data, key);
5710             if (index < 0) {
5711               ++this.size;
5712               data.push([key, value]);
5713             } else {
5714               data[index][1] = value;
5715             }
5716             return this;
5717           }
5718           ListCache2.prototype.clear = listCacheClear2;
5719           ListCache2.prototype["delete"] = listCacheDelete2;
5720           ListCache2.prototype.get = listCacheGet2;
5721           ListCache2.prototype.has = listCacheHas2;
5722           ListCache2.prototype.set = listCacheSet2;
5723           function MapCache2(entries) {
5724             var index = -1, length2 = entries == null ? 0 : entries.length;
5725             this.clear();
5726             while (++index < length2) {
5727               var entry = entries[index];
5728               this.set(entry[0], entry[1]);
5729             }
5730           }
5731           function mapCacheClear2() {
5732             this.size = 0;
5733             this.__data__ = {
5734               "hash": new Hash2(),
5735               "map": new (Map3 || ListCache2)(),
5736               "string": new Hash2()
5737             };
5738           }
5739           function mapCacheDelete2(key) {
5740             var result2 = getMapData2(this, key)["delete"](key);
5741             this.size -= result2 ? 1 : 0;
5742             return result2;
5743           }
5744           function mapCacheGet2(key) {
5745             return getMapData2(this, key).get(key);
5746           }
5747           function mapCacheHas2(key) {
5748             return getMapData2(this, key).has(key);
5749           }
5750           function mapCacheSet2(key, value) {
5751             var data = getMapData2(this, key), size2 = data.size;
5752             data.set(key, value);
5753             this.size += data.size == size2 ? 0 : 1;
5754             return this;
5755           }
5756           MapCache2.prototype.clear = mapCacheClear2;
5757           MapCache2.prototype["delete"] = mapCacheDelete2;
5758           MapCache2.prototype.get = mapCacheGet2;
5759           MapCache2.prototype.has = mapCacheHas2;
5760           MapCache2.prototype.set = mapCacheSet2;
5761           function SetCache2(values2) {
5762             var index = -1, length2 = values2 == null ? 0 : values2.length;
5763             this.__data__ = new MapCache2();
5764             while (++index < length2) {
5765               this.add(values2[index]);
5766             }
5767           }
5768           function setCacheAdd2(value) {
5769             this.__data__.set(value, HASH_UNDEFINED4);
5770             return this;
5771           }
5772           function setCacheHas2(value) {
5773             return this.__data__.has(value);
5774           }
5775           SetCache2.prototype.add = SetCache2.prototype.push = setCacheAdd2;
5776           SetCache2.prototype.has = setCacheHas2;
5777           function Stack2(entries) {
5778             var data = this.__data__ = new ListCache2(entries);
5779             this.size = data.size;
5780           }
5781           function stackClear2() {
5782             this.__data__ = new ListCache2();
5783             this.size = 0;
5784           }
5785           function stackDelete2(key) {
5786             var data = this.__data__, result2 = data["delete"](key);
5787             this.size = data.size;
5788             return result2;
5789           }
5790           function stackGet2(key) {
5791             return this.__data__.get(key);
5792           }
5793           function stackHas2(key) {
5794             return this.__data__.has(key);
5795           }
5796           function stackSet2(key, value) {
5797             var data = this.__data__;
5798             if (data instanceof ListCache2) {
5799               var pairs2 = data.__data__;
5800               if (!Map3 || pairs2.length < LARGE_ARRAY_SIZE2 - 1) {
5801                 pairs2.push([key, value]);
5802                 this.size = ++data.size;
5803                 return this;
5804               }
5805               data = this.__data__ = new MapCache2(pairs2);
5806             }
5807             data.set(key, value);
5808             this.size = data.size;
5809             return this;
5810           }
5811           Stack2.prototype.clear = stackClear2;
5812           Stack2.prototype["delete"] = stackDelete2;
5813           Stack2.prototype.get = stackGet2;
5814           Stack2.prototype.has = stackHas2;
5815           Stack2.prototype.set = stackSet2;
5816           function arrayLikeKeys2(value, inherited) {
5817             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;
5818             for (var key in value) {
5819               if ((inherited || hasOwnProperty10.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
5820               (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
5821               isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
5822               isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
5823               isIndex2(key, length2)))) {
5824                 result2.push(key);
5825               }
5826             }
5827             return result2;
5828           }
5829           function arraySample(array2) {
5830             var length2 = array2.length;
5831             return length2 ? array2[baseRandom(0, length2 - 1)] : undefined2;
5832           }
5833           function arraySampleSize(array2, n3) {
5834             return shuffleSelf(copyArray(array2), baseClamp(n3, 0, array2.length));
5835           }
5836           function arrayShuffle(array2) {
5837             return shuffleSelf(copyArray(array2));
5838           }
5839           function assignMergeValue(object, key, value) {
5840             if (value !== undefined2 && !eq2(object[key], value) || value === undefined2 && !(key in object)) {
5841               baseAssignValue(object, key, value);
5842             }
5843           }
5844           function assignValue(object, key, value) {
5845             var objValue = object[key];
5846             if (!(hasOwnProperty10.call(object, key) && eq2(objValue, value)) || value === undefined2 && !(key in object)) {
5847               baseAssignValue(object, key, value);
5848             }
5849           }
5850           function assocIndexOf2(array2, key) {
5851             var length2 = array2.length;
5852             while (length2--) {
5853               if (eq2(array2[length2][0], key)) {
5854                 return length2;
5855               }
5856             }
5857             return -1;
5858           }
5859           function baseAggregator(collection, setter, iteratee2, accumulator) {
5860             baseEach(collection, function(value, key, collection2) {
5861               setter(accumulator, value, iteratee2(value), collection2);
5862             });
5863             return accumulator;
5864           }
5865           function baseAssign(object, source) {
5866             return object && copyObject(source, keys2(source), object);
5867           }
5868           function baseAssignIn(object, source) {
5869             return object && copyObject(source, keysIn(source), object);
5870           }
5871           function baseAssignValue(object, key, value) {
5872             if (key == "__proto__" && defineProperty) {
5873               defineProperty(object, key, {
5874                 "configurable": true,
5875                 "enumerable": true,
5876                 "value": value,
5877                 "writable": true
5878               });
5879             } else {
5880               object[key] = value;
5881             }
5882           }
5883           function baseAt(object, paths) {
5884             var index = -1, length2 = paths.length, result2 = Array2(length2), skip = object == null;
5885             while (++index < length2) {
5886               result2[index] = skip ? undefined2 : get4(object, paths[index]);
5887             }
5888             return result2;
5889           }
5890           function baseClamp(number3, lower2, upper) {
5891             if (number3 === number3) {
5892               if (upper !== undefined2) {
5893                 number3 = number3 <= upper ? number3 : upper;
5894               }
5895               if (lower2 !== undefined2) {
5896                 number3 = number3 >= lower2 ? number3 : lower2;
5897               }
5898             }
5899             return number3;
5900           }
5901           function baseClone(value, bitmask, customizer, key, object, stack) {
5902             var result2, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
5903             if (customizer) {
5904               result2 = object ? customizer(value, key, object, stack) : customizer(value);
5905             }
5906             if (result2 !== undefined2) {
5907               return result2;
5908             }
5909             if (!isObject3(value)) {
5910               return value;
5911             }
5912             var isArr = isArray2(value);
5913             if (isArr) {
5914               result2 = initCloneArray(value);
5915               if (!isDeep) {
5916                 return copyArray(value, result2);
5917               }
5918             } else {
5919               var tag2 = getTag2(value), isFunc = tag2 == funcTag3 || tag2 == genTag2;
5920               if (isBuffer2(value)) {
5921                 return cloneBuffer(value, isDeep);
5922               }
5923               if (tag2 == objectTag4 || tag2 == argsTag4 || isFunc && !object) {
5924                 result2 = isFlat || isFunc ? {} : initCloneObject(value);
5925                 if (!isDeep) {
5926                   return isFlat ? copySymbolsIn(value, baseAssignIn(result2, value)) : copySymbols(value, baseAssign(result2, value));
5927                 }
5928               } else {
5929                 if (!cloneableTags[tag2]) {
5930                   return object ? value : {};
5931                 }
5932                 result2 = initCloneByTag(value, tag2, isDeep);
5933               }
5934             }
5935             stack || (stack = new Stack2());
5936             var stacked = stack.get(value);
5937             if (stacked) {
5938               return stacked;
5939             }
5940             stack.set(value, result2);
5941             if (isSet(value)) {
5942               value.forEach(function(subValue) {
5943                 result2.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
5944               });
5945             } else if (isMap(value)) {
5946               value.forEach(function(subValue, key2) {
5947                 result2.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
5948               });
5949             }
5950             var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys2 : isFlat ? keysIn : keys2;
5951             var props = isArr ? undefined2 : keysFunc(value);
5952             arrayEach(props || value, function(subValue, key2) {
5953               if (props) {
5954                 key2 = subValue;
5955                 subValue = value[key2];
5956               }
5957               assignValue(result2, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
5958             });
5959             return result2;
5960           }
5961           function baseConforms(source) {
5962             var props = keys2(source);
5963             return function(object) {
5964               return baseConformsTo(object, source, props);
5965             };
5966           }
5967           function baseConformsTo(object, source, props) {
5968             var length2 = props.length;
5969             if (object == null) {
5970               return !length2;
5971             }
5972             object = Object2(object);
5973             while (length2--) {
5974               var key = props[length2], predicate = source[key], value = object[key];
5975               if (value === undefined2 && !(key in object) || !predicate(value)) {
5976                 return false;
5977               }
5978             }
5979             return true;
5980           }
5981           function baseDelay(func, wait, args) {
5982             if (typeof func != "function") {
5983               throw new TypeError2(FUNC_ERROR_TEXT3);
5984             }
5985             return setTimeout2(function() {
5986               func.apply(undefined2, args);
5987             }, wait);
5988           }
5989           function baseDifference(array2, values2, iteratee2, comparator) {
5990             var index = -1, includes2 = arrayIncludes, isCommon = true, length2 = array2.length, result2 = [], valuesLength = values2.length;
5991             if (!length2) {
5992               return result2;
5993             }
5994             if (iteratee2) {
5995               values2 = arrayMap2(values2, baseUnary2(iteratee2));
5996             }
5997             if (comparator) {
5998               includes2 = arrayIncludesWith;
5999               isCommon = false;
6000             } else if (values2.length >= LARGE_ARRAY_SIZE2) {
6001               includes2 = cacheHas2;
6002               isCommon = false;
6003               values2 = new SetCache2(values2);
6004             }
6005             outer:
6006               while (++index < length2) {
6007                 var value = array2[index], computed = iteratee2 == null ? value : iteratee2(value);
6008                 value = comparator || value !== 0 ? value : 0;
6009                 if (isCommon && computed === computed) {
6010                   var valuesIndex = valuesLength;
6011                   while (valuesIndex--) {
6012                     if (values2[valuesIndex] === computed) {
6013                       continue outer;
6014                     }
6015                   }
6016                   result2.push(value);
6017                 } else if (!includes2(values2, computed, comparator)) {
6018                   result2.push(value);
6019                 }
6020               }
6021             return result2;
6022           }
6023           var baseEach = createBaseEach(baseForOwn);
6024           var baseEachRight = createBaseEach(baseForOwnRight, true);
6025           function baseEvery(collection, predicate) {
6026             var result2 = true;
6027             baseEach(collection, function(value, index, collection2) {
6028               result2 = !!predicate(value, index, collection2);
6029               return result2;
6030             });
6031             return result2;
6032           }
6033           function baseExtremum(array2, iteratee2, comparator) {
6034             var index = -1, length2 = array2.length;
6035             while (++index < length2) {
6036               var value = array2[index], current = iteratee2(value);
6037               if (current != null && (computed === undefined2 ? current === current && !isSymbol2(current) : comparator(current, computed))) {
6038                 var computed = current, result2 = value;
6039               }
6040             }
6041             return result2;
6042           }
6043           function baseFill(array2, value, start2, end) {
6044             var length2 = array2.length;
6045             start2 = toInteger(start2);
6046             if (start2 < 0) {
6047               start2 = -start2 > length2 ? 0 : length2 + start2;
6048             }
6049             end = end === undefined2 || end > length2 ? length2 : toInteger(end);
6050             if (end < 0) {
6051               end += length2;
6052             }
6053             end = start2 > end ? 0 : toLength(end);
6054             while (start2 < end) {
6055               array2[start2++] = value;
6056             }
6057             return array2;
6058           }
6059           function baseFilter(collection, predicate) {
6060             var result2 = [];
6061             baseEach(collection, function(value, index, collection2) {
6062               if (predicate(value, index, collection2)) {
6063                 result2.push(value);
6064               }
6065             });
6066             return result2;
6067           }
6068           function baseFlatten(array2, depth, predicate, isStrict, result2) {
6069             var index = -1, length2 = array2.length;
6070             predicate || (predicate = isFlattenable);
6071             result2 || (result2 = []);
6072             while (++index < length2) {
6073               var value = array2[index];
6074               if (depth > 0 && predicate(value)) {
6075                 if (depth > 1) {
6076                   baseFlatten(value, depth - 1, predicate, isStrict, result2);
6077                 } else {
6078                   arrayPush2(result2, value);
6079                 }
6080               } else if (!isStrict) {
6081                 result2[result2.length] = value;
6082               }
6083             }
6084             return result2;
6085           }
6086           var baseFor = createBaseFor();
6087           var baseForRight = createBaseFor(true);
6088           function baseForOwn(object, iteratee2) {
6089             return object && baseFor(object, iteratee2, keys2);
6090           }
6091           function baseForOwnRight(object, iteratee2) {
6092             return object && baseForRight(object, iteratee2, keys2);
6093           }
6094           function baseFunctions(object, props) {
6095             return arrayFilter2(props, function(key) {
6096               return isFunction2(object[key]);
6097             });
6098           }
6099           function baseGet(object, path) {
6100             path = castPath(path, object);
6101             var index = 0, length2 = path.length;
6102             while (object != null && index < length2) {
6103               object = object[toKey(path[index++])];
6104             }
6105             return index && index == length2 ? object : undefined2;
6106           }
6107           function baseGetAllKeys2(object, keysFunc, symbolsFunc) {
6108             var result2 = keysFunc(object);
6109             return isArray2(object) ? result2 : arrayPush2(result2, symbolsFunc(object));
6110           }
6111           function baseGetTag2(value) {
6112             if (value == null) {
6113               return value === undefined2 ? undefinedTag2 : nullTag2;
6114             }
6115             return symToStringTag3 && symToStringTag3 in Object2(value) ? getRawTag2(value) : objectToString2(value);
6116           }
6117           function baseGt(value, other) {
6118             return value > other;
6119           }
6120           function baseHas(object, key) {
6121             return object != null && hasOwnProperty10.call(object, key);
6122           }
6123           function baseHasIn(object, key) {
6124             return object != null && key in Object2(object);
6125           }
6126           function baseInRange(number3, start2, end) {
6127             return number3 >= nativeMin2(start2, end) && number3 < nativeMax2(start2, end);
6128           }
6129           function baseIntersection(arrays, iteratee2, comparator) {
6130             var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length2 = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = [];
6131             while (othIndex--) {
6132               var array2 = arrays[othIndex];
6133               if (othIndex && iteratee2) {
6134                 array2 = arrayMap2(array2, baseUnary2(iteratee2));
6135               }
6136               maxLength = nativeMin2(array2.length, maxLength);
6137               caches[othIndex] = !comparator && (iteratee2 || length2 >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2;
6138             }
6139             array2 = arrays[0];
6140             var index = -1, seen = caches[0];
6141             outer:
6142               while (++index < length2 && result2.length < maxLength) {
6143                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6144                 value = comparator || value !== 0 ? value : 0;
6145                 if (!(seen ? cacheHas2(seen, computed) : includes2(result2, computed, comparator))) {
6146                   othIndex = othLength;
6147                   while (--othIndex) {
6148                     var cache = caches[othIndex];
6149                     if (!(cache ? cacheHas2(cache, computed) : includes2(arrays[othIndex], computed, comparator))) {
6150                       continue outer;
6151                     }
6152                   }
6153                   if (seen) {
6154                     seen.push(computed);
6155                   }
6156                   result2.push(value);
6157                 }
6158               }
6159             return result2;
6160           }
6161           function baseInverter(object, setter, iteratee2, accumulator) {
6162             baseForOwn(object, function(value, key, object2) {
6163               setter(accumulator, iteratee2(value), key, object2);
6164             });
6165             return accumulator;
6166           }
6167           function baseInvoke(object, path, args) {
6168             path = castPath(path, object);
6169             object = parent(object, path);
6170             var func = object == null ? object : object[toKey(last(path))];
6171             return func == null ? undefined2 : apply(func, object, args);
6172           }
6173           function baseIsArguments2(value) {
6174             return isObjectLike2(value) && baseGetTag2(value) == argsTag4;
6175           }
6176           function baseIsArrayBuffer(value) {
6177             return isObjectLike2(value) && baseGetTag2(value) == arrayBufferTag3;
6178           }
6179           function baseIsDate(value) {
6180             return isObjectLike2(value) && baseGetTag2(value) == dateTag3;
6181           }
6182           function baseIsEqual2(value, other, bitmask, customizer, stack) {
6183             if (value === other) {
6184               return true;
6185             }
6186             if (value == null || other == null || !isObjectLike2(value) && !isObjectLike2(other)) {
6187               return value !== value && other !== other;
6188             }
6189             return baseIsEqualDeep2(value, other, bitmask, customizer, baseIsEqual2, stack);
6190           }
6191           function baseIsEqualDeep2(object, other, bitmask, customizer, equalFunc, stack) {
6192             var objIsArr = isArray2(object), othIsArr = isArray2(other), objTag = objIsArr ? arrayTag3 : getTag2(object), othTag = othIsArr ? arrayTag3 : getTag2(other);
6193             objTag = objTag == argsTag4 ? objectTag4 : objTag;
6194             othTag = othTag == argsTag4 ? objectTag4 : othTag;
6195             var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
6196             if (isSameTag && isBuffer2(object)) {
6197               if (!isBuffer2(other)) {
6198                 return false;
6199               }
6200               objIsArr = true;
6201               objIsObj = false;
6202             }
6203             if (isSameTag && !objIsObj) {
6204               stack || (stack = new Stack2());
6205               return objIsArr || isTypedArray2(object) ? equalArrays2(object, other, bitmask, customizer, equalFunc, stack) : equalByTag2(object, other, objTag, bitmask, customizer, equalFunc, stack);
6206             }
6207             if (!(bitmask & COMPARE_PARTIAL_FLAG5)) {
6208               var objIsWrapped = objIsObj && hasOwnProperty10.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty10.call(other, "__wrapped__");
6209               if (objIsWrapped || othIsWrapped) {
6210                 var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
6211                 stack || (stack = new Stack2());
6212                 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
6213               }
6214             }
6215             if (!isSameTag) {
6216               return false;
6217             }
6218             stack || (stack = new Stack2());
6219             return equalObjects2(object, other, bitmask, customizer, equalFunc, stack);
6220           }
6221           function baseIsMap(value) {
6222             return isObjectLike2(value) && getTag2(value) == mapTag4;
6223           }
6224           function baseIsMatch(object, source, matchData, customizer) {
6225             var index = matchData.length, length2 = index, noCustomizer = !customizer;
6226             if (object == null) {
6227               return !length2;
6228             }
6229             object = Object2(object);
6230             while (index--) {
6231               var data = matchData[index];
6232               if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
6233                 return false;
6234               }
6235             }
6236             while (++index < length2) {
6237               data = matchData[index];
6238               var key = data[0], objValue = object[key], srcValue = data[1];
6239               if (noCustomizer && data[2]) {
6240                 if (objValue === undefined2 && !(key in object)) {
6241                   return false;
6242                 }
6243               } else {
6244                 var stack = new Stack2();
6245                 if (customizer) {
6246                   var result2 = customizer(objValue, srcValue, key, object, source, stack);
6247                 }
6248                 if (!(result2 === undefined2 ? baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3, customizer, stack) : result2)) {
6249                   return false;
6250                 }
6251               }
6252             }
6253             return true;
6254           }
6255           function baseIsNative2(value) {
6256             if (!isObject3(value) || isMasked2(value)) {
6257               return false;
6258             }
6259             var pattern = isFunction2(value) ? reIsNative2 : reIsHostCtor2;
6260             return pattern.test(toSource2(value));
6261           }
6262           function baseIsRegExp(value) {
6263             return isObjectLike2(value) && baseGetTag2(value) == regexpTag3;
6264           }
6265           function baseIsSet(value) {
6266             return isObjectLike2(value) && getTag2(value) == setTag4;
6267           }
6268           function baseIsTypedArray2(value) {
6269             return isObjectLike2(value) && isLength2(value.length) && !!typedArrayTags2[baseGetTag2(value)];
6270           }
6271           function baseIteratee(value) {
6272             if (typeof value == "function") {
6273               return value;
6274             }
6275             if (value == null) {
6276               return identity4;
6277             }
6278             if (typeof value == "object") {
6279               return isArray2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
6280             }
6281             return property(value);
6282           }
6283           function baseKeys2(object) {
6284             if (!isPrototype2(object)) {
6285               return nativeKeys2(object);
6286             }
6287             var result2 = [];
6288             for (var key in Object2(object)) {
6289               if (hasOwnProperty10.call(object, key) && key != "constructor") {
6290                 result2.push(key);
6291               }
6292             }
6293             return result2;
6294           }
6295           function baseKeysIn(object) {
6296             if (!isObject3(object)) {
6297               return nativeKeysIn(object);
6298             }
6299             var isProto = isPrototype2(object), result2 = [];
6300             for (var key in object) {
6301               if (!(key == "constructor" && (isProto || !hasOwnProperty10.call(object, key)))) {
6302                 result2.push(key);
6303               }
6304             }
6305             return result2;
6306           }
6307           function baseLt(value, other) {
6308             return value < other;
6309           }
6310           function baseMap(collection, iteratee2) {
6311             var index = -1, result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
6312             baseEach(collection, function(value, key, collection2) {
6313               result2[++index] = iteratee2(value, key, collection2);
6314             });
6315             return result2;
6316           }
6317           function baseMatches(source) {
6318             var matchData = getMatchData(source);
6319             if (matchData.length == 1 && matchData[0][2]) {
6320               return matchesStrictComparable(matchData[0][0], matchData[0][1]);
6321             }
6322             return function(object) {
6323               return object === source || baseIsMatch(object, source, matchData);
6324             };
6325           }
6326           function baseMatchesProperty(path, srcValue) {
6327             if (isKey(path) && isStrictComparable(srcValue)) {
6328               return matchesStrictComparable(toKey(path), srcValue);
6329             }
6330             return function(object) {
6331               var objValue = get4(object, path);
6332               return objValue === undefined2 && objValue === srcValue ? hasIn(object, path) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3);
6333             };
6334           }
6335           function baseMerge(object, source, srcIndex, customizer, stack) {
6336             if (object === source) {
6337               return;
6338             }
6339             baseFor(source, function(srcValue, key) {
6340               stack || (stack = new Stack2());
6341               if (isObject3(srcValue)) {
6342                 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
6343               } else {
6344                 var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : undefined2;
6345                 if (newValue === undefined2) {
6346                   newValue = srcValue;
6347                 }
6348                 assignMergeValue(object, key, newValue);
6349               }
6350             }, keysIn);
6351           }
6352           function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
6353             var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
6354             if (stacked) {
6355               assignMergeValue(object, key, stacked);
6356               return;
6357             }
6358             var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : undefined2;
6359             var isCommon = newValue === undefined2;
6360             if (isCommon) {
6361               var isArr = isArray2(srcValue), isBuff = !isArr && isBuffer2(srcValue), isTyped = !isArr && !isBuff && isTypedArray2(srcValue);
6362               newValue = srcValue;
6363               if (isArr || isBuff || isTyped) {
6364                 if (isArray2(objValue)) {
6365                   newValue = objValue;
6366                 } else if (isArrayLikeObject(objValue)) {
6367                   newValue = copyArray(objValue);
6368                 } else if (isBuff) {
6369                   isCommon = false;
6370                   newValue = cloneBuffer(srcValue, true);
6371                 } else if (isTyped) {
6372                   isCommon = false;
6373                   newValue = cloneTypedArray(srcValue, true);
6374                 } else {
6375                   newValue = [];
6376                 }
6377               } else if (isPlainObject(srcValue) || isArguments2(srcValue)) {
6378                 newValue = objValue;
6379                 if (isArguments2(objValue)) {
6380                   newValue = toPlainObject(objValue);
6381                 } else if (!isObject3(objValue) || isFunction2(objValue)) {
6382                   newValue = initCloneObject(srcValue);
6383                 }
6384               } else {
6385                 isCommon = false;
6386               }
6387             }
6388             if (isCommon) {
6389               stack.set(srcValue, newValue);
6390               mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
6391               stack["delete"](srcValue);
6392             }
6393             assignMergeValue(object, key, newValue);
6394           }
6395           function baseNth(array2, n3) {
6396             var length2 = array2.length;
6397             if (!length2) {
6398               return;
6399             }
6400             n3 += n3 < 0 ? length2 : 0;
6401             return isIndex2(n3, length2) ? array2[n3] : undefined2;
6402           }
6403           function baseOrderBy(collection, iteratees, orders) {
6404             if (iteratees.length) {
6405               iteratees = arrayMap2(iteratees, function(iteratee2) {
6406                 if (isArray2(iteratee2)) {
6407                   return function(value) {
6408                     return baseGet(value, iteratee2.length === 1 ? iteratee2[0] : iteratee2);
6409                   };
6410                 }
6411                 return iteratee2;
6412               });
6413             } else {
6414               iteratees = [identity4];
6415             }
6416             var index = -1;
6417             iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
6418             var result2 = baseMap(collection, function(value, key, collection2) {
6419               var criteria = arrayMap2(iteratees, function(iteratee2) {
6420                 return iteratee2(value);
6421               });
6422               return { "criteria": criteria, "index": ++index, "value": value };
6423             });
6424             return baseSortBy(result2, function(object, other) {
6425               return compareMultiple(object, other, orders);
6426             });
6427           }
6428           function basePick(object, paths) {
6429             return basePickBy(object, paths, function(value, path) {
6430               return hasIn(object, path);
6431             });
6432           }
6433           function basePickBy(object, paths, predicate) {
6434             var index = -1, length2 = paths.length, result2 = {};
6435             while (++index < length2) {
6436               var path = paths[index], value = baseGet(object, path);
6437               if (predicate(value, path)) {
6438                 baseSet(result2, castPath(path, object), value);
6439               }
6440             }
6441             return result2;
6442           }
6443           function basePropertyDeep(path) {
6444             return function(object) {
6445               return baseGet(object, path);
6446             };
6447           }
6448           function basePullAll(array2, values2, iteratee2, comparator) {
6449             var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length2 = values2.length, seen = array2;
6450             if (array2 === values2) {
6451               values2 = copyArray(values2);
6452             }
6453             if (iteratee2) {
6454               seen = arrayMap2(array2, baseUnary2(iteratee2));
6455             }
6456             while (++index < length2) {
6457               var fromIndex = 0, value = values2[index], computed = iteratee2 ? iteratee2(value) : value;
6458               while ((fromIndex = indexOf2(seen, computed, fromIndex, comparator)) > -1) {
6459                 if (seen !== array2) {
6460                   splice2.call(seen, fromIndex, 1);
6461                 }
6462                 splice2.call(array2, fromIndex, 1);
6463               }
6464             }
6465             return array2;
6466           }
6467           function basePullAt(array2, indexes) {
6468             var length2 = array2 ? indexes.length : 0, lastIndex = length2 - 1;
6469             while (length2--) {
6470               var index = indexes[length2];
6471               if (length2 == lastIndex || index !== previous) {
6472                 var previous = index;
6473                 if (isIndex2(index)) {
6474                   splice2.call(array2, index, 1);
6475                 } else {
6476                   baseUnset(array2, index);
6477                 }
6478               }
6479             }
6480             return array2;
6481           }
6482           function baseRandom(lower2, upper) {
6483             return lower2 + nativeFloor(nativeRandom() * (upper - lower2 + 1));
6484           }
6485           function baseRange(start2, end, step, fromRight) {
6486             var index = -1, length2 = nativeMax2(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length2);
6487             while (length2--) {
6488               result2[fromRight ? length2 : ++index] = start2;
6489               start2 += step;
6490             }
6491             return result2;
6492           }
6493           function baseRepeat(string, n3) {
6494             var result2 = "";
6495             if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
6496               return result2;
6497             }
6498             do {
6499               if (n3 % 2) {
6500                 result2 += string;
6501               }
6502               n3 = nativeFloor(n3 / 2);
6503               if (n3) {
6504                 string += string;
6505               }
6506             } while (n3);
6507             return result2;
6508           }
6509           function baseRest(func, start2) {
6510             return setToString(overRest(func, start2, identity4), func + "");
6511           }
6512           function baseSample(collection) {
6513             return arraySample(values(collection));
6514           }
6515           function baseSampleSize(collection, n3) {
6516             var array2 = values(collection);
6517             return shuffleSelf(array2, baseClamp(n3, 0, array2.length));
6518           }
6519           function baseSet(object, path, value, customizer) {
6520             if (!isObject3(object)) {
6521               return object;
6522             }
6523             path = castPath(path, object);
6524             var index = -1, length2 = path.length, lastIndex = length2 - 1, nested = object;
6525             while (nested != null && ++index < length2) {
6526               var key = toKey(path[index]), newValue = value;
6527               if (key === "__proto__" || key === "constructor" || key === "prototype") {
6528                 return object;
6529               }
6530               if (index != lastIndex) {
6531                 var objValue = nested[key];
6532                 newValue = customizer ? customizer(objValue, key, nested) : undefined2;
6533                 if (newValue === undefined2) {
6534                   newValue = isObject3(objValue) ? objValue : isIndex2(path[index + 1]) ? [] : {};
6535                 }
6536               }
6537               assignValue(nested, key, newValue);
6538               nested = nested[key];
6539             }
6540             return object;
6541           }
6542           var baseSetData = !metaMap ? identity4 : function(func, data) {
6543             metaMap.set(func, data);
6544             return func;
6545           };
6546           var baseSetToString = !defineProperty ? identity4 : function(func, string) {
6547             return defineProperty(func, "toString", {
6548               "configurable": true,
6549               "enumerable": false,
6550               "value": constant(string),
6551               "writable": true
6552             });
6553           };
6554           function baseShuffle(collection) {
6555             return shuffleSelf(values(collection));
6556           }
6557           function baseSlice(array2, start2, end) {
6558             var index = -1, length2 = array2.length;
6559             if (start2 < 0) {
6560               start2 = -start2 > length2 ? 0 : length2 + start2;
6561             }
6562             end = end > length2 ? length2 : end;
6563             if (end < 0) {
6564               end += length2;
6565             }
6566             length2 = start2 > end ? 0 : end - start2 >>> 0;
6567             start2 >>>= 0;
6568             var result2 = Array2(length2);
6569             while (++index < length2) {
6570               result2[index] = array2[index + start2];
6571             }
6572             return result2;
6573           }
6574           function baseSome(collection, predicate) {
6575             var result2;
6576             baseEach(collection, function(value, index, collection2) {
6577               result2 = predicate(value, index, collection2);
6578               return !result2;
6579             });
6580             return !!result2;
6581           }
6582           function baseSortedIndex(array2, value, retHighest) {
6583             var low = 0, high = array2 == null ? low : array2.length;
6584             if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
6585               while (low < high) {
6586                 var mid = low + high >>> 1, computed = array2[mid];
6587                 if (computed !== null && !isSymbol2(computed) && (retHighest ? computed <= value : computed < value)) {
6588                   low = mid + 1;
6589                 } else {
6590                   high = mid;
6591                 }
6592               }
6593               return high;
6594             }
6595             return baseSortedIndexBy(array2, value, identity4, retHighest);
6596           }
6597           function baseSortedIndexBy(array2, value, iteratee2, retHighest) {
6598             var low = 0, high = array2 == null ? 0 : array2.length;
6599             if (high === 0) {
6600               return 0;
6601             }
6602             value = iteratee2(value);
6603             var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol2(value), valIsUndefined = value === undefined2;
6604             while (low < high) {
6605               var mid = nativeFloor((low + high) / 2), computed = iteratee2(array2[mid]), othIsDefined = computed !== undefined2, othIsNull = computed === null, othIsReflexive = computed === computed, othIsSymbol = isSymbol2(computed);
6606               if (valIsNaN) {
6607                 var setLow = retHighest || othIsReflexive;
6608               } else if (valIsUndefined) {
6609                 setLow = othIsReflexive && (retHighest || othIsDefined);
6610               } else if (valIsNull) {
6611                 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
6612               } else if (valIsSymbol) {
6613                 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
6614               } else if (othIsNull || othIsSymbol) {
6615                 setLow = false;
6616               } else {
6617                 setLow = retHighest ? computed <= value : computed < value;
6618               }
6619               if (setLow) {
6620                 low = mid + 1;
6621               } else {
6622                 high = mid;
6623               }
6624             }
6625             return nativeMin2(high, MAX_ARRAY_INDEX);
6626           }
6627           function baseSortedUniq(array2, iteratee2) {
6628             var index = -1, length2 = array2.length, resIndex = 0, result2 = [];
6629             while (++index < length2) {
6630               var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6631               if (!index || !eq2(computed, seen)) {
6632                 var seen = computed;
6633                 result2[resIndex++] = value === 0 ? 0 : value;
6634               }
6635             }
6636             return result2;
6637           }
6638           function baseToNumber(value) {
6639             if (typeof value == "number") {
6640               return value;
6641             }
6642             if (isSymbol2(value)) {
6643               return NAN2;
6644             }
6645             return +value;
6646           }
6647           function baseToString2(value) {
6648             if (typeof value == "string") {
6649               return value;
6650             }
6651             if (isArray2(value)) {
6652               return arrayMap2(value, baseToString2) + "";
6653             }
6654             if (isSymbol2(value)) {
6655               return symbolToString2 ? symbolToString2.call(value) : "";
6656             }
6657             var result2 = value + "";
6658             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
6659           }
6660           function baseUniq(array2, iteratee2, comparator) {
6661             var index = -1, includes2 = arrayIncludes, length2 = array2.length, isCommon = true, result2 = [], seen = result2;
6662             if (comparator) {
6663               isCommon = false;
6664               includes2 = arrayIncludesWith;
6665             } else if (length2 >= LARGE_ARRAY_SIZE2) {
6666               var set5 = iteratee2 ? null : createSet(array2);
6667               if (set5) {
6668                 return setToArray2(set5);
6669               }
6670               isCommon = false;
6671               includes2 = cacheHas2;
6672               seen = new SetCache2();
6673             } else {
6674               seen = iteratee2 ? [] : result2;
6675             }
6676             outer:
6677               while (++index < length2) {
6678                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6679                 value = comparator || value !== 0 ? value : 0;
6680                 if (isCommon && computed === computed) {
6681                   var seenIndex = seen.length;
6682                   while (seenIndex--) {
6683                     if (seen[seenIndex] === computed) {
6684                       continue outer;
6685                     }
6686                   }
6687                   if (iteratee2) {
6688                     seen.push(computed);
6689                   }
6690                   result2.push(value);
6691                 } else if (!includes2(seen, computed, comparator)) {
6692                   if (seen !== result2) {
6693                     seen.push(computed);
6694                   }
6695                   result2.push(value);
6696                 }
6697               }
6698             return result2;
6699           }
6700           function baseUnset(object, path) {
6701             path = castPath(path, object);
6702             object = parent(object, path);
6703             return object == null || delete object[toKey(last(path))];
6704           }
6705           function baseUpdate(object, path, updater, customizer) {
6706             return baseSet(object, path, updater(baseGet(object, path)), customizer);
6707           }
6708           function baseWhile(array2, predicate, isDrop, fromRight) {
6709             var length2 = array2.length, index = fromRight ? length2 : -1;
6710             while ((fromRight ? index-- : ++index < length2) && predicate(array2[index], index, array2)) {
6711             }
6712             return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length2) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length2 : index);
6713           }
6714           function baseWrapperValue(value, actions) {
6715             var result2 = value;
6716             if (result2 instanceof LazyWrapper) {
6717               result2 = result2.value();
6718             }
6719             return arrayReduce(actions, function(result3, action) {
6720               return action.func.apply(action.thisArg, arrayPush2([result3], action.args));
6721             }, result2);
6722           }
6723           function baseXor(arrays, iteratee2, comparator) {
6724             var length2 = arrays.length;
6725             if (length2 < 2) {
6726               return length2 ? baseUniq(arrays[0]) : [];
6727             }
6728             var index = -1, result2 = Array2(length2);
6729             while (++index < length2) {
6730               var array2 = arrays[index], othIndex = -1;
6731               while (++othIndex < length2) {
6732                 if (othIndex != index) {
6733                   result2[index] = baseDifference(result2[index] || array2, arrays[othIndex], iteratee2, comparator);
6734                 }
6735               }
6736             }
6737             return baseUniq(baseFlatten(result2, 1), iteratee2, comparator);
6738           }
6739           function baseZipObject(props, values2, assignFunc) {
6740             var index = -1, length2 = props.length, valsLength = values2.length, result2 = {};
6741             while (++index < length2) {
6742               var value = index < valsLength ? values2[index] : undefined2;
6743               assignFunc(result2, props[index], value);
6744             }
6745             return result2;
6746           }
6747           function castArrayLikeObject(value) {
6748             return isArrayLikeObject(value) ? value : [];
6749           }
6750           function castFunction(value) {
6751             return typeof value == "function" ? value : identity4;
6752           }
6753           function castPath(value, object) {
6754             if (isArray2(value)) {
6755               return value;
6756             }
6757             return isKey(value, object) ? [value] : stringToPath(toString2(value));
6758           }
6759           var castRest = baseRest;
6760           function castSlice(array2, start2, end) {
6761             var length2 = array2.length;
6762             end = end === undefined2 ? length2 : end;
6763             return !start2 && end >= length2 ? array2 : baseSlice(array2, start2, end);
6764           }
6765           var clearTimeout2 = ctxClearTimeout || function(id2) {
6766             return root3.clearTimeout(id2);
6767           };
6768           function cloneBuffer(buffer, isDeep) {
6769             if (isDeep) {
6770               return buffer.slice();
6771             }
6772             var length2 = buffer.length, result2 = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
6773             buffer.copy(result2);
6774             return result2;
6775           }
6776           function cloneArrayBuffer(arrayBuffer) {
6777             var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
6778             new Uint8Array3(result2).set(new Uint8Array3(arrayBuffer));
6779             return result2;
6780           }
6781           function cloneDataView(dataView, isDeep) {
6782             var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
6783             return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
6784           }
6785           function cloneRegExp(regexp) {
6786             var result2 = new regexp.constructor(regexp.source, reFlags.exec(regexp));
6787             result2.lastIndex = regexp.lastIndex;
6788             return result2;
6789           }
6790           function cloneSymbol(symbol) {
6791             return symbolValueOf2 ? Object2(symbolValueOf2.call(symbol)) : {};
6792           }
6793           function cloneTypedArray(typedArray, isDeep) {
6794             var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
6795             return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
6796           }
6797           function compareAscending(value, other) {
6798             if (value !== other) {
6799               var valIsDefined = value !== undefined2, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol2(value);
6800               var othIsDefined = other !== undefined2, othIsNull = other === null, othIsReflexive = other === other, othIsSymbol = isSymbol2(other);
6801               if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
6802                 return 1;
6803               }
6804               if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
6805                 return -1;
6806               }
6807             }
6808             return 0;
6809           }
6810           function compareMultiple(object, other, orders) {
6811             var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length2 = objCriteria.length, ordersLength = orders.length;
6812             while (++index < length2) {
6813               var result2 = compareAscending(objCriteria[index], othCriteria[index]);
6814               if (result2) {
6815                 if (index >= ordersLength) {
6816                   return result2;
6817                 }
6818                 var order = orders[index];
6819                 return result2 * (order == "desc" ? -1 : 1);
6820               }
6821             }
6822             return object.index - other.index;
6823           }
6824           function composeArgs(args, partials, holders, isCurried) {
6825             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;
6826             while (++leftIndex < leftLength) {
6827               result2[leftIndex] = partials[leftIndex];
6828             }
6829             while (++argsIndex < holdersLength) {
6830               if (isUncurried || argsIndex < argsLength) {
6831                 result2[holders[argsIndex]] = args[argsIndex];
6832               }
6833             }
6834             while (rangeLength--) {
6835               result2[leftIndex++] = args[argsIndex++];
6836             }
6837             return result2;
6838           }
6839           function composeArgsRight(args, partials, holders, isCurried) {
6840             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;
6841             while (++argsIndex < rangeLength) {
6842               result2[argsIndex] = args[argsIndex];
6843             }
6844             var offset = argsIndex;
6845             while (++rightIndex < rightLength) {
6846               result2[offset + rightIndex] = partials[rightIndex];
6847             }
6848             while (++holdersIndex < holdersLength) {
6849               if (isUncurried || argsIndex < argsLength) {
6850                 result2[offset + holders[holdersIndex]] = args[argsIndex++];
6851               }
6852             }
6853             return result2;
6854           }
6855           function copyArray(source, array2) {
6856             var index = -1, length2 = source.length;
6857             array2 || (array2 = Array2(length2));
6858             while (++index < length2) {
6859               array2[index] = source[index];
6860             }
6861             return array2;
6862           }
6863           function copyObject(source, props, object, customizer) {
6864             var isNew = !object;
6865             object || (object = {});
6866             var index = -1, length2 = props.length;
6867             while (++index < length2) {
6868               var key = props[index];
6869               var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined2;
6870               if (newValue === undefined2) {
6871                 newValue = source[key];
6872               }
6873               if (isNew) {
6874                 baseAssignValue(object, key, newValue);
6875               } else {
6876                 assignValue(object, key, newValue);
6877               }
6878             }
6879             return object;
6880           }
6881           function copySymbols(source, object) {
6882             return copyObject(source, getSymbols2(source), object);
6883           }
6884           function copySymbolsIn(source, object) {
6885             return copyObject(source, getSymbolsIn(source), object);
6886           }
6887           function createAggregator(setter, initializer) {
6888             return function(collection, iteratee2) {
6889               var func = isArray2(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {};
6890               return func(collection, setter, getIteratee(iteratee2, 2), accumulator);
6891             };
6892           }
6893           function createAssigner(assigner) {
6894             return baseRest(function(object, sources) {
6895               var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : undefined2, guard = length2 > 2 ? sources[2] : undefined2;
6896               customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : undefined2;
6897               if (guard && isIterateeCall(sources[0], sources[1], guard)) {
6898                 customizer = length2 < 3 ? undefined2 : customizer;
6899                 length2 = 1;
6900               }
6901               object = Object2(object);
6902               while (++index < length2) {
6903                 var source = sources[index];
6904                 if (source) {
6905                   assigner(object, source, index, customizer);
6906                 }
6907               }
6908               return object;
6909             });
6910           }
6911           function createBaseEach(eachFunc, fromRight) {
6912             return function(collection, iteratee2) {
6913               if (collection == null) {
6914                 return collection;
6915               }
6916               if (!isArrayLike2(collection)) {
6917                 return eachFunc(collection, iteratee2);
6918               }
6919               var length2 = collection.length, index = fromRight ? length2 : -1, iterable = Object2(collection);
6920               while (fromRight ? index-- : ++index < length2) {
6921                 if (iteratee2(iterable[index], index, iterable) === false) {
6922                   break;
6923                 }
6924               }
6925               return collection;
6926             };
6927           }
6928           function createBaseFor(fromRight) {
6929             return function(object, iteratee2, keysFunc) {
6930               var index = -1, iterable = Object2(object), props = keysFunc(object), length2 = props.length;
6931               while (length2--) {
6932                 var key = props[fromRight ? length2 : ++index];
6933                 if (iteratee2(iterable[key], key, iterable) === false) {
6934                   break;
6935                 }
6936               }
6937               return object;
6938             };
6939           }
6940           function createBind(func, bitmask, thisArg) {
6941             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
6942             function wrapper() {
6943               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
6944               return fn.apply(isBind ? thisArg : this, arguments);
6945             }
6946             return wrapper;
6947           }
6948           function createCaseFirst(methodName) {
6949             return function(string) {
6950               string = toString2(string);
6951               var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined2;
6952               var chr = strSymbols ? strSymbols[0] : string.charAt(0);
6953               var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
6954               return chr[methodName]() + trailing;
6955             };
6956           }
6957           function createCompounder(callback) {
6958             return function(string) {
6959               return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
6960             };
6961           }
6962           function createCtor(Ctor) {
6963             return function() {
6964               var args = arguments;
6965               switch (args.length) {
6966                 case 0:
6967                   return new Ctor();
6968                 case 1:
6969                   return new Ctor(args[0]);
6970                 case 2:
6971                   return new Ctor(args[0], args[1]);
6972                 case 3:
6973                   return new Ctor(args[0], args[1], args[2]);
6974                 case 4:
6975                   return new Ctor(args[0], args[1], args[2], args[3]);
6976                 case 5:
6977                   return new Ctor(args[0], args[1], args[2], args[3], args[4]);
6978                 case 6:
6979                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
6980                 case 7:
6981                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6982               }
6983               var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
6984               return isObject3(result2) ? result2 : thisBinding;
6985             };
6986           }
6987           function createCurry(func, bitmask, arity) {
6988             var Ctor = createCtor(func);
6989             function wrapper() {
6990               var length2 = arguments.length, args = Array2(length2), index = length2, placeholder = getHolder(wrapper);
6991               while (index--) {
6992                 args[index] = arguments[index];
6993               }
6994               var holders = length2 < 3 && args[0] !== placeholder && args[length2 - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
6995               length2 -= holders.length;
6996               if (length2 < arity) {
6997                 return createRecurry(
6998                   func,
6999                   bitmask,
7000                   createHybrid,
7001                   wrapper.placeholder,
7002                   undefined2,
7003                   args,
7004                   holders,
7005                   undefined2,
7006                   undefined2,
7007                   arity - length2
7008                 );
7009               }
7010               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
7011               return apply(fn, this, args);
7012             }
7013             return wrapper;
7014           }
7015           function createFind(findIndexFunc) {
7016             return function(collection, predicate, fromIndex) {
7017               var iterable = Object2(collection);
7018               if (!isArrayLike2(collection)) {
7019                 var iteratee2 = getIteratee(predicate, 3);
7020                 collection = keys2(collection);
7021                 predicate = function(key) {
7022                   return iteratee2(iterable[key], key, iterable);
7023                 };
7024               }
7025               var index = findIndexFunc(collection, predicate, fromIndex);
7026               return index > -1 ? iterable[iteratee2 ? collection[index] : index] : undefined2;
7027             };
7028           }
7029           function createFlow(fromRight) {
7030             return flatRest(function(funcs) {
7031               var length2 = funcs.length, index = length2, prereq = LodashWrapper.prototype.thru;
7032               if (fromRight) {
7033                 funcs.reverse();
7034               }
7035               while (index--) {
7036                 var func = funcs[index];
7037                 if (typeof func != "function") {
7038                   throw new TypeError2(FUNC_ERROR_TEXT3);
7039                 }
7040                 if (prereq && !wrapper && getFuncName(func) == "wrapper") {
7041                   var wrapper = new LodashWrapper([], true);
7042                 }
7043               }
7044               index = wrapper ? index : length2;
7045               while (++index < length2) {
7046                 func = funcs[index];
7047                 var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined2;
7048                 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) {
7049                   wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
7050                 } else {
7051                   wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func);
7052                 }
7053               }
7054               return function() {
7055                 var args = arguments, value = args[0];
7056                 if (wrapper && args.length == 1 && isArray2(value)) {
7057                   return wrapper.plant(value).value();
7058                 }
7059                 var index2 = 0, result2 = length2 ? funcs[index2].apply(this, args) : value;
7060                 while (++index2 < length2) {
7061                   result2 = funcs[index2].call(this, result2);
7062                 }
7063                 return result2;
7064               };
7065             });
7066           }
7067           function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
7068             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);
7069             function wrapper() {
7070               var length2 = arguments.length, args = Array2(length2), index = length2;
7071               while (index--) {
7072                 args[index] = arguments[index];
7073               }
7074               if (isCurried) {
7075                 var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
7076               }
7077               if (partials) {
7078                 args = composeArgs(args, partials, holders, isCurried);
7079               }
7080               if (partialsRight) {
7081                 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
7082               }
7083               length2 -= holdersCount;
7084               if (isCurried && length2 < arity) {
7085                 var newHolders = replaceHolders(args, placeholder);
7086                 return createRecurry(
7087                   func,
7088                   bitmask,
7089                   createHybrid,
7090                   wrapper.placeholder,
7091                   thisArg,
7092                   args,
7093                   newHolders,
7094                   argPos,
7095                   ary2,
7096                   arity - length2
7097                 );
7098               }
7099               var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func;
7100               length2 = args.length;
7101               if (argPos) {
7102                 args = reorder(args, argPos);
7103               } else if (isFlip && length2 > 1) {
7104                 args.reverse();
7105               }
7106               if (isAry && ary2 < length2) {
7107                 args.length = ary2;
7108               }
7109               if (this && this !== root3 && this instanceof wrapper) {
7110                 fn = Ctor || createCtor(fn);
7111               }
7112               return fn.apply(thisBinding, args);
7113             }
7114             return wrapper;
7115           }
7116           function createInverter(setter, toIteratee) {
7117             return function(object, iteratee2) {
7118               return baseInverter(object, setter, toIteratee(iteratee2), {});
7119             };
7120           }
7121           function createMathOperation(operator, defaultValue) {
7122             return function(value, other) {
7123               var result2;
7124               if (value === undefined2 && other === undefined2) {
7125                 return defaultValue;
7126               }
7127               if (value !== undefined2) {
7128                 result2 = value;
7129               }
7130               if (other !== undefined2) {
7131                 if (result2 === undefined2) {
7132                   return other;
7133                 }
7134                 if (typeof value == "string" || typeof other == "string") {
7135                   value = baseToString2(value);
7136                   other = baseToString2(other);
7137                 } else {
7138                   value = baseToNumber(value);
7139                   other = baseToNumber(other);
7140                 }
7141                 result2 = operator(value, other);
7142               }
7143               return result2;
7144             };
7145           }
7146           function createOver(arrayFunc) {
7147             return flatRest(function(iteratees) {
7148               iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
7149               return baseRest(function(args) {
7150                 var thisArg = this;
7151                 return arrayFunc(iteratees, function(iteratee2) {
7152                   return apply(iteratee2, thisArg, args);
7153                 });
7154               });
7155             });
7156           }
7157           function createPadding(length2, chars) {
7158             chars = chars === undefined2 ? " " : baseToString2(chars);
7159             var charsLength = chars.length;
7160             if (charsLength < 2) {
7161               return charsLength ? baseRepeat(chars, length2) : chars;
7162             }
7163             var result2 = baseRepeat(chars, nativeCeil(length2 / stringSize(chars)));
7164             return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length2).join("") : result2.slice(0, length2);
7165           }
7166           function createPartial(func, bitmask, thisArg, partials) {
7167             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
7168             function wrapper() {
7169               var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
7170               while (++leftIndex < leftLength) {
7171                 args[leftIndex] = partials[leftIndex];
7172               }
7173               while (argsLength--) {
7174                 args[leftIndex++] = arguments[++argsIndex];
7175               }
7176               return apply(fn, isBind ? thisArg : this, args);
7177             }
7178             return wrapper;
7179           }
7180           function createRange(fromRight) {
7181             return function(start2, end, step) {
7182               if (step && typeof step != "number" && isIterateeCall(start2, end, step)) {
7183                 end = step = undefined2;
7184               }
7185               start2 = toFinite(start2);
7186               if (end === undefined2) {
7187                 end = start2;
7188                 start2 = 0;
7189               } else {
7190                 end = toFinite(end);
7191               }
7192               step = step === undefined2 ? start2 < end ? 1 : -1 : toFinite(step);
7193               return baseRange(start2, end, step, fromRight);
7194             };
7195           }
7196           function createRelationalOperation(operator) {
7197             return function(value, other) {
7198               if (!(typeof value == "string" && typeof other == "string")) {
7199                 value = toNumber3(value);
7200                 other = toNumber3(other);
7201               }
7202               return operator(value, other);
7203             };
7204           }
7205           function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
7206             var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined2, newHoldersRight = isCurry ? undefined2 : holders, newPartials = isCurry ? partials : undefined2, newPartialsRight = isCurry ? undefined2 : partials;
7207             bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
7208             bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
7209             if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
7210               bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
7211             }
7212             var newData = [
7213               func,
7214               bitmask,
7215               thisArg,
7216               newPartials,
7217               newHolders,
7218               newPartialsRight,
7219               newHoldersRight,
7220               argPos,
7221               ary2,
7222               arity
7223             ];
7224             var result2 = wrapFunc.apply(undefined2, newData);
7225             if (isLaziable(func)) {
7226               setData(result2, newData);
7227             }
7228             result2.placeholder = placeholder;
7229             return setWrapToString(result2, func, bitmask);
7230           }
7231           function createRound(methodName) {
7232             var func = Math2[methodName];
7233             return function(number3, precision3) {
7234               number3 = toNumber3(number3);
7235               precision3 = precision3 == null ? 0 : nativeMin2(toInteger(precision3), 292);
7236               if (precision3 && nativeIsFinite(number3)) {
7237                 var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision3));
7238                 pair3 = (toString2(value) + "e").split("e");
7239                 return +(pair3[0] + "e" + (+pair3[1] - precision3));
7240               }
7241               return func(number3);
7242             };
7243           }
7244           var createSet = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY2) ? noop3 : function(values2) {
7245             return new Set3(values2);
7246           };
7247           function createToPairs(keysFunc) {
7248             return function(object) {
7249               var tag2 = getTag2(object);
7250               if (tag2 == mapTag4) {
7251                 return mapToArray2(object);
7252               }
7253               if (tag2 == setTag4) {
7254                 return setToPairs(object);
7255               }
7256               return baseToPairs(object, keysFunc(object));
7257             };
7258           }
7259           function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
7260             var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
7261             if (!isBindKey && typeof func != "function") {
7262               throw new TypeError2(FUNC_ERROR_TEXT3);
7263             }
7264             var length2 = partials ? partials.length : 0;
7265             if (!length2) {
7266               bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
7267               partials = holders = undefined2;
7268             }
7269             ary2 = ary2 === undefined2 ? ary2 : nativeMax2(toInteger(ary2), 0);
7270             arity = arity === undefined2 ? arity : toInteger(arity);
7271             length2 -= holders ? holders.length : 0;
7272             if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
7273               var partialsRight = partials, holdersRight = holders;
7274               partials = holders = undefined2;
7275             }
7276             var data = isBindKey ? undefined2 : getData(func);
7277             var newData = [
7278               func,
7279               bitmask,
7280               thisArg,
7281               partials,
7282               holders,
7283               partialsRight,
7284               holdersRight,
7285               argPos,
7286               ary2,
7287               arity
7288             ];
7289             if (data) {
7290               mergeData(newData, data);
7291             }
7292             func = newData[0];
7293             bitmask = newData[1];
7294             thisArg = newData[2];
7295             partials = newData[3];
7296             holders = newData[4];
7297             arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax2(newData[9] - length2, 0);
7298             if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
7299               bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
7300             }
7301             if (!bitmask || bitmask == WRAP_BIND_FLAG) {
7302               var result2 = createBind(func, bitmask, thisArg);
7303             } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
7304               result2 = createCurry(func, bitmask, arity);
7305             } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
7306               result2 = createPartial(func, bitmask, thisArg, partials);
7307             } else {
7308               result2 = createHybrid.apply(undefined2, newData);
7309             }
7310             var setter = data ? baseSetData : setData;
7311             return setWrapToString(setter(result2, newData), func, bitmask);
7312           }
7313           function customDefaultsAssignIn(objValue, srcValue, key, object) {
7314             if (objValue === undefined2 || eq2(objValue, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
7315               return srcValue;
7316             }
7317             return objValue;
7318           }
7319           function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
7320             if (isObject3(objValue) && isObject3(srcValue)) {
7321               stack.set(srcValue, objValue);
7322               baseMerge(objValue, srcValue, undefined2, customDefaultsMerge, stack);
7323               stack["delete"](srcValue);
7324             }
7325             return objValue;
7326           }
7327           function customOmitClone(value) {
7328             return isPlainObject(value) ? undefined2 : value;
7329           }
7330           function equalArrays2(array2, other, bitmask, customizer, equalFunc, stack) {
7331             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, arrLength = array2.length, othLength = other.length;
7332             if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
7333               return false;
7334             }
7335             var arrStacked = stack.get(array2);
7336             var othStacked = stack.get(other);
7337             if (arrStacked && othStacked) {
7338               return arrStacked == other && othStacked == array2;
7339             }
7340             var index = -1, result2 = true, seen = bitmask & COMPARE_UNORDERED_FLAG3 ? new SetCache2() : undefined2;
7341             stack.set(array2, other);
7342             stack.set(other, array2);
7343             while (++index < arrLength) {
7344               var arrValue = array2[index], othValue = other[index];
7345               if (customizer) {
7346                 var compared = isPartial ? customizer(othValue, arrValue, index, other, array2, stack) : customizer(arrValue, othValue, index, array2, other, stack);
7347               }
7348               if (compared !== undefined2) {
7349                 if (compared) {
7350                   continue;
7351                 }
7352                 result2 = false;
7353                 break;
7354               }
7355               if (seen) {
7356                 if (!arraySome2(other, function(othValue2, othIndex) {
7357                   if (!cacheHas2(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
7358                     return seen.push(othIndex);
7359                   }
7360                 })) {
7361                   result2 = false;
7362                   break;
7363                 }
7364               } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
7365                 result2 = false;
7366                 break;
7367               }
7368             }
7369             stack["delete"](array2);
7370             stack["delete"](other);
7371             return result2;
7372           }
7373           function equalByTag2(object, other, tag2, bitmask, customizer, equalFunc, stack) {
7374             switch (tag2) {
7375               case dataViewTag4:
7376                 if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
7377                   return false;
7378                 }
7379                 object = object.buffer;
7380                 other = other.buffer;
7381               case arrayBufferTag3:
7382                 if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array3(object), new Uint8Array3(other))) {
7383                   return false;
7384                 }
7385                 return true;
7386               case boolTag3:
7387               case dateTag3:
7388               case numberTag4:
7389                 return eq2(+object, +other);
7390               case errorTag3:
7391                 return object.name == other.name && object.message == other.message;
7392               case regexpTag3:
7393               case stringTag3:
7394                 return object == other + "";
7395               case mapTag4:
7396                 var convert = mapToArray2;
7397               case setTag4:
7398                 var isPartial = bitmask & COMPARE_PARTIAL_FLAG5;
7399                 convert || (convert = setToArray2);
7400                 if (object.size != other.size && !isPartial) {
7401                   return false;
7402                 }
7403                 var stacked = stack.get(object);
7404                 if (stacked) {
7405                   return stacked == other;
7406                 }
7407                 bitmask |= COMPARE_UNORDERED_FLAG3;
7408                 stack.set(object, other);
7409                 var result2 = equalArrays2(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
7410                 stack["delete"](object);
7411                 return result2;
7412               case symbolTag3:
7413                 if (symbolValueOf2) {
7414                   return symbolValueOf2.call(object) == symbolValueOf2.call(other);
7415                 }
7416             }
7417             return false;
7418           }
7419           function equalObjects2(object, other, bitmask, customizer, equalFunc, stack) {
7420             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, objProps = getAllKeys2(object), objLength = objProps.length, othProps = getAllKeys2(other), othLength = othProps.length;
7421             if (objLength != othLength && !isPartial) {
7422               return false;
7423             }
7424             var index = objLength;
7425             while (index--) {
7426               var key = objProps[index];
7427               if (!(isPartial ? key in other : hasOwnProperty10.call(other, key))) {
7428                 return false;
7429               }
7430             }
7431             var objStacked = stack.get(object);
7432             var othStacked = stack.get(other);
7433             if (objStacked && othStacked) {
7434               return objStacked == other && othStacked == object;
7435             }
7436             var result2 = true;
7437             stack.set(object, other);
7438             stack.set(other, object);
7439             var skipCtor = isPartial;
7440             while (++index < objLength) {
7441               key = objProps[index];
7442               var objValue = object[key], othValue = other[key];
7443               if (customizer) {
7444                 var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
7445               }
7446               if (!(compared === undefined2 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
7447                 result2 = false;
7448                 break;
7449               }
7450               skipCtor || (skipCtor = key == "constructor");
7451             }
7452             if (result2 && !skipCtor) {
7453               var objCtor = object.constructor, othCtor = other.constructor;
7454               if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
7455                 result2 = false;
7456               }
7457             }
7458             stack["delete"](object);
7459             stack["delete"](other);
7460             return result2;
7461           }
7462           function flatRest(func) {
7463             return setToString(overRest(func, undefined2, flatten2), func + "");
7464           }
7465           function getAllKeys2(object) {
7466             return baseGetAllKeys2(object, keys2, getSymbols2);
7467           }
7468           function getAllKeysIn(object) {
7469             return baseGetAllKeys2(object, keysIn, getSymbolsIn);
7470           }
7471           var getData = !metaMap ? noop3 : function(func) {
7472             return metaMap.get(func);
7473           };
7474           function getFuncName(func) {
7475             var result2 = func.name + "", array2 = realNames[result2], length2 = hasOwnProperty10.call(realNames, result2) ? array2.length : 0;
7476             while (length2--) {
7477               var data = array2[length2], otherFunc = data.func;
7478               if (otherFunc == null || otherFunc == func) {
7479                 return data.name;
7480               }
7481             }
7482             return result2;
7483           }
7484           function getHolder(func) {
7485             var object = hasOwnProperty10.call(lodash, "placeholder") ? lodash : func;
7486             return object.placeholder;
7487           }
7488           function getIteratee() {
7489             var result2 = lodash.iteratee || iteratee;
7490             result2 = result2 === iteratee ? baseIteratee : result2;
7491             return arguments.length ? result2(arguments[0], arguments[1]) : result2;
7492           }
7493           function getMapData2(map3, key) {
7494             var data = map3.__data__;
7495             return isKeyable2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
7496           }
7497           function getMatchData(object) {
7498             var result2 = keys2(object), length2 = result2.length;
7499             while (length2--) {
7500               var key = result2[length2], value = object[key];
7501               result2[length2] = [key, value, isStrictComparable(value)];
7502             }
7503             return result2;
7504           }
7505           function getNative2(object, key) {
7506             var value = getValue2(object, key);
7507             return baseIsNative2(value) ? value : undefined2;
7508           }
7509           function getRawTag2(value) {
7510             var isOwn = hasOwnProperty10.call(value, symToStringTag3), tag2 = value[symToStringTag3];
7511             try {
7512               value[symToStringTag3] = undefined2;
7513               var unmasked = true;
7514             } catch (e3) {
7515             }
7516             var result2 = nativeObjectToString3.call(value);
7517             if (unmasked) {
7518               if (isOwn) {
7519                 value[symToStringTag3] = tag2;
7520               } else {
7521                 delete value[symToStringTag3];
7522               }
7523             }
7524             return result2;
7525           }
7526           var getSymbols2 = !nativeGetSymbols2 ? stubArray2 : function(object) {
7527             if (object == null) {
7528               return [];
7529             }
7530             object = Object2(object);
7531             return arrayFilter2(nativeGetSymbols2(object), function(symbol) {
7532               return propertyIsEnumerable3.call(object, symbol);
7533             });
7534           };
7535           var getSymbolsIn = !nativeGetSymbols2 ? stubArray2 : function(object) {
7536             var result2 = [];
7537             while (object) {
7538               arrayPush2(result2, getSymbols2(object));
7539               object = getPrototype(object);
7540             }
7541             return result2;
7542           };
7543           var getTag2 = baseGetTag2;
7544           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) {
7545             getTag2 = function(value) {
7546               var result2 = baseGetTag2(value), Ctor = result2 == objectTag4 ? value.constructor : undefined2, ctorString = Ctor ? toSource2(Ctor) : "";
7547               if (ctorString) {
7548                 switch (ctorString) {
7549                   case dataViewCtorString2:
7550                     return dataViewTag4;
7551                   case mapCtorString2:
7552                     return mapTag4;
7553                   case promiseCtorString2:
7554                     return promiseTag2;
7555                   case setCtorString2:
7556                     return setTag4;
7557                   case weakMapCtorString2:
7558                     return weakMapTag3;
7559                 }
7560               }
7561               return result2;
7562             };
7563           }
7564           function getView(start2, end, transforms) {
7565             var index = -1, length2 = transforms.length;
7566             while (++index < length2) {
7567               var data = transforms[index], size2 = data.size;
7568               switch (data.type) {
7569                 case "drop":
7570                   start2 += size2;
7571                   break;
7572                 case "dropRight":
7573                   end -= size2;
7574                   break;
7575                 case "take":
7576                   end = nativeMin2(end, start2 + size2);
7577                   break;
7578                 case "takeRight":
7579                   start2 = nativeMax2(start2, end - size2);
7580                   break;
7581               }
7582             }
7583             return { "start": start2, "end": end };
7584           }
7585           function getWrapDetails(source) {
7586             var match = source.match(reWrapDetails);
7587             return match ? match[1].split(reSplitDetails) : [];
7588           }
7589           function hasPath(object, path, hasFunc) {
7590             path = castPath(path, object);
7591             var index = -1, length2 = path.length, result2 = false;
7592             while (++index < length2) {
7593               var key = toKey(path[index]);
7594               if (!(result2 = object != null && hasFunc(object, key))) {
7595                 break;
7596               }
7597               object = object[key];
7598             }
7599             if (result2 || ++index != length2) {
7600               return result2;
7601             }
7602             length2 = object == null ? 0 : object.length;
7603             return !!length2 && isLength2(length2) && isIndex2(key, length2) && (isArray2(object) || isArguments2(object));
7604           }
7605           function initCloneArray(array2) {
7606             var length2 = array2.length, result2 = new array2.constructor(length2);
7607             if (length2 && typeof array2[0] == "string" && hasOwnProperty10.call(array2, "index")) {
7608               result2.index = array2.index;
7609               result2.input = array2.input;
7610             }
7611             return result2;
7612           }
7613           function initCloneObject(object) {
7614             return typeof object.constructor == "function" && !isPrototype2(object) ? baseCreate(getPrototype(object)) : {};
7615           }
7616           function initCloneByTag(object, tag2, isDeep) {
7617             var Ctor = object.constructor;
7618             switch (tag2) {
7619               case arrayBufferTag3:
7620                 return cloneArrayBuffer(object);
7621               case boolTag3:
7622               case dateTag3:
7623                 return new Ctor(+object);
7624               case dataViewTag4:
7625                 return cloneDataView(object, isDeep);
7626               case float32Tag2:
7627               case float64Tag2:
7628               case int8Tag2:
7629               case int16Tag2:
7630               case int32Tag2:
7631               case uint8Tag2:
7632               case uint8ClampedTag2:
7633               case uint16Tag2:
7634               case uint32Tag2:
7635                 return cloneTypedArray(object, isDeep);
7636               case mapTag4:
7637                 return new Ctor();
7638               case numberTag4:
7639               case stringTag3:
7640                 return new Ctor(object);
7641               case regexpTag3:
7642                 return cloneRegExp(object);
7643               case setTag4:
7644                 return new Ctor();
7645               case symbolTag3:
7646                 return cloneSymbol(object);
7647             }
7648           }
7649           function insertWrapDetails(source, details) {
7650             var length2 = details.length;
7651             if (!length2) {
7652               return source;
7653             }
7654             var lastIndex = length2 - 1;
7655             details[lastIndex] = (length2 > 1 ? "& " : "") + details[lastIndex];
7656             details = details.join(length2 > 2 ? ", " : " ");
7657             return source.replace(reWrapComment, "{\n/* [wrapped with " + details + "] */\n");
7658           }
7659           function isFlattenable(value) {
7660             return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
7661           }
7662           function isIndex2(value, length2) {
7663             var type2 = typeof value;
7664             length2 = length2 == null ? MAX_SAFE_INTEGER4 : length2;
7665             return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
7666           }
7667           function isIterateeCall(value, index, object) {
7668             if (!isObject3(object)) {
7669               return false;
7670             }
7671             var type2 = typeof index;
7672             if (type2 == "number" ? isArrayLike2(object) && isIndex2(index, object.length) : type2 == "string" && index in object) {
7673               return eq2(object[index], value);
7674             }
7675             return false;
7676           }
7677           function isKey(value, object) {
7678             if (isArray2(value)) {
7679               return false;
7680             }
7681             var type2 = typeof value;
7682             if (type2 == "number" || type2 == "symbol" || type2 == "boolean" || value == null || isSymbol2(value)) {
7683               return true;
7684             }
7685             return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object2(object);
7686           }
7687           function isKeyable2(value) {
7688             var type2 = typeof value;
7689             return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
7690           }
7691           function isLaziable(func) {
7692             var funcName = getFuncName(func), other = lodash[funcName];
7693             if (typeof other != "function" || !(funcName in LazyWrapper.prototype)) {
7694               return false;
7695             }
7696             if (func === other) {
7697               return true;
7698             }
7699             var data = getData(other);
7700             return !!data && func === data[0];
7701           }
7702           function isMasked2(func) {
7703             return !!maskSrcKey2 && maskSrcKey2 in func;
7704           }
7705           var isMaskable = coreJsData2 ? isFunction2 : stubFalse2;
7706           function isPrototype2(value) {
7707             var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto13;
7708             return value === proto;
7709           }
7710           function isStrictComparable(value) {
7711             return value === value && !isObject3(value);
7712           }
7713           function matchesStrictComparable(key, srcValue) {
7714             return function(object) {
7715               if (object == null) {
7716                 return false;
7717               }
7718               return object[key] === srcValue && (srcValue !== undefined2 || key in Object2(object));
7719             };
7720           }
7721           function memoizeCapped(func) {
7722             var result2 = memoize(func, function(key) {
7723               if (cache.size === MAX_MEMOIZE_SIZE) {
7724                 cache.clear();
7725               }
7726               return key;
7727             });
7728             var cache = result2.cache;
7729             return result2;
7730           }
7731           function mergeData(data, source) {
7732             var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
7733             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;
7734             if (!(isCommon || isCombo)) {
7735               return data;
7736             }
7737             if (srcBitmask & WRAP_BIND_FLAG) {
7738               data[2] = source[2];
7739               newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
7740             }
7741             var value = source[3];
7742             if (value) {
7743               var partials = data[3];
7744               data[3] = partials ? composeArgs(partials, value, source[4]) : value;
7745               data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
7746             }
7747             value = source[5];
7748             if (value) {
7749               partials = data[5];
7750               data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
7751               data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
7752             }
7753             value = source[7];
7754             if (value) {
7755               data[7] = value;
7756             }
7757             if (srcBitmask & WRAP_ARY_FLAG) {
7758               data[8] = data[8] == null ? source[8] : nativeMin2(data[8], source[8]);
7759             }
7760             if (data[9] == null) {
7761               data[9] = source[9];
7762             }
7763             data[0] = source[0];
7764             data[1] = newBitmask;
7765             return data;
7766           }
7767           function nativeKeysIn(object) {
7768             var result2 = [];
7769             if (object != null) {
7770               for (var key in Object2(object)) {
7771                 result2.push(key);
7772               }
7773             }
7774             return result2;
7775           }
7776           function objectToString2(value) {
7777             return nativeObjectToString3.call(value);
7778           }
7779           function overRest(func, start2, transform3) {
7780             start2 = nativeMax2(start2 === undefined2 ? func.length - 1 : start2, 0);
7781             return function() {
7782               var args = arguments, index = -1, length2 = nativeMax2(args.length - start2, 0), array2 = Array2(length2);
7783               while (++index < length2) {
7784                 array2[index] = args[start2 + index];
7785               }
7786               index = -1;
7787               var otherArgs = Array2(start2 + 1);
7788               while (++index < start2) {
7789                 otherArgs[index] = args[index];
7790               }
7791               otherArgs[start2] = transform3(array2);
7792               return apply(func, this, otherArgs);
7793             };
7794           }
7795           function parent(object, path) {
7796             return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
7797           }
7798           function reorder(array2, indexes) {
7799             var arrLength = array2.length, length2 = nativeMin2(indexes.length, arrLength), oldArray = copyArray(array2);
7800             while (length2--) {
7801               var index = indexes[length2];
7802               array2[length2] = isIndex2(index, arrLength) ? oldArray[index] : undefined2;
7803             }
7804             return array2;
7805           }
7806           function safeGet(object, key) {
7807             if (key === "constructor" && typeof object[key] === "function") {
7808               return;
7809             }
7810             if (key == "__proto__") {
7811               return;
7812             }
7813             return object[key];
7814           }
7815           var setData = shortOut(baseSetData);
7816           var setTimeout2 = ctxSetTimeout || function(func, wait) {
7817             return root3.setTimeout(func, wait);
7818           };
7819           var setToString = shortOut(baseSetToString);
7820           function setWrapToString(wrapper, reference, bitmask) {
7821             var source = reference + "";
7822             return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
7823           }
7824           function shortOut(func) {
7825             var count = 0, lastCalled = 0;
7826             return function() {
7827               var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
7828               lastCalled = stamp;
7829               if (remaining > 0) {
7830                 if (++count >= HOT_COUNT) {
7831                   return arguments[0];
7832                 }
7833               } else {
7834                 count = 0;
7835               }
7836               return func.apply(undefined2, arguments);
7837             };
7838           }
7839           function shuffleSelf(array2, size2) {
7840             var index = -1, length2 = array2.length, lastIndex = length2 - 1;
7841             size2 = size2 === undefined2 ? length2 : size2;
7842             while (++index < size2) {
7843               var rand = baseRandom(index, lastIndex), value = array2[rand];
7844               array2[rand] = array2[index];
7845               array2[index] = value;
7846             }
7847             array2.length = size2;
7848             return array2;
7849           }
7850           var stringToPath = memoizeCapped(function(string) {
7851             var result2 = [];
7852             if (string.charCodeAt(0) === 46) {
7853               result2.push("");
7854             }
7855             string.replace(rePropName, function(match, number3, quote, subString) {
7856               result2.push(quote ? subString.replace(reEscapeChar, "$1") : number3 || match);
7857             });
7858             return result2;
7859           });
7860           function toKey(value) {
7861             if (typeof value == "string" || isSymbol2(value)) {
7862               return value;
7863             }
7864             var result2 = value + "";
7865             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
7866           }
7867           function toSource2(func) {
7868             if (func != null) {
7869               try {
7870                 return funcToString3.call(func);
7871               } catch (e3) {
7872               }
7873               try {
7874                 return func + "";
7875               } catch (e3) {
7876               }
7877             }
7878             return "";
7879           }
7880           function updateWrapDetails(details, bitmask) {
7881             arrayEach(wrapFlags, function(pair3) {
7882               var value = "_." + pair3[0];
7883               if (bitmask & pair3[1] && !arrayIncludes(details, value)) {
7884                 details.push(value);
7885               }
7886             });
7887             return details.sort();
7888           }
7889           function wrapperClone(wrapper) {
7890             if (wrapper instanceof LazyWrapper) {
7891               return wrapper.clone();
7892             }
7893             var result2 = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
7894             result2.__actions__ = copyArray(wrapper.__actions__);
7895             result2.__index__ = wrapper.__index__;
7896             result2.__values__ = wrapper.__values__;
7897             return result2;
7898           }
7899           function chunk(array2, size2, guard) {
7900             if (guard ? isIterateeCall(array2, size2, guard) : size2 === undefined2) {
7901               size2 = 1;
7902             } else {
7903               size2 = nativeMax2(toInteger(size2), 0);
7904             }
7905             var length2 = array2 == null ? 0 : array2.length;
7906             if (!length2 || size2 < 1) {
7907               return [];
7908             }
7909             var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length2 / size2));
7910             while (index < length2) {
7911               result2[resIndex++] = baseSlice(array2, index, index += size2);
7912             }
7913             return result2;
7914           }
7915           function compact(array2) {
7916             var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result2 = [];
7917             while (++index < length2) {
7918               var value = array2[index];
7919               if (value) {
7920                 result2[resIndex++] = value;
7921               }
7922             }
7923             return result2;
7924           }
7925           function concat() {
7926             var length2 = arguments.length;
7927             if (!length2) {
7928               return [];
7929             }
7930             var args = Array2(length2 - 1), array2 = arguments[0], index = length2;
7931             while (index--) {
7932               args[index - 1] = arguments[index];
7933             }
7934             return arrayPush2(isArray2(array2) ? copyArray(array2) : [array2], baseFlatten(args, 1));
7935           }
7936           var difference2 = baseRest(function(array2, values2) {
7937             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true)) : [];
7938           });
7939           var differenceBy = baseRest(function(array2, values2) {
7940             var iteratee2 = last(values2);
7941             if (isArrayLikeObject(iteratee2)) {
7942               iteratee2 = undefined2;
7943             }
7944             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2)) : [];
7945           });
7946           var differenceWith = baseRest(function(array2, values2) {
7947             var comparator = last(values2);
7948             if (isArrayLikeObject(comparator)) {
7949               comparator = undefined2;
7950             }
7951             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), undefined2, comparator) : [];
7952           });
7953           function drop(array2, n3, guard) {
7954             var length2 = array2 == null ? 0 : array2.length;
7955             if (!length2) {
7956               return [];
7957             }
7958             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7959             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
7960           }
7961           function dropRight(array2, n3, guard) {
7962             var length2 = array2 == null ? 0 : array2.length;
7963             if (!length2) {
7964               return [];
7965             }
7966             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7967             n3 = length2 - n3;
7968             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
7969           }
7970           function dropRightWhile(array2, predicate) {
7971             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true, true) : [];
7972           }
7973           function dropWhile(array2, predicate) {
7974             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true) : [];
7975           }
7976           function fill(array2, value, start2, end) {
7977             var length2 = array2 == null ? 0 : array2.length;
7978             if (!length2) {
7979               return [];
7980             }
7981             if (start2 && typeof start2 != "number" && isIterateeCall(array2, value, start2)) {
7982               start2 = 0;
7983               end = length2;
7984             }
7985             return baseFill(array2, value, start2, end);
7986           }
7987           function findIndex(array2, predicate, fromIndex) {
7988             var length2 = array2 == null ? 0 : array2.length;
7989             if (!length2) {
7990               return -1;
7991             }
7992             var index = fromIndex == null ? 0 : toInteger(fromIndex);
7993             if (index < 0) {
7994               index = nativeMax2(length2 + index, 0);
7995             }
7996             return baseFindIndex(array2, getIteratee(predicate, 3), index);
7997           }
7998           function findLastIndex(array2, predicate, fromIndex) {
7999             var length2 = array2 == null ? 0 : array2.length;
8000             if (!length2) {
8001               return -1;
8002             }
8003             var index = length2 - 1;
8004             if (fromIndex !== undefined2) {
8005               index = toInteger(fromIndex);
8006               index = fromIndex < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
8007             }
8008             return baseFindIndex(array2, getIteratee(predicate, 3), index, true);
8009           }
8010           function flatten2(array2) {
8011             var length2 = array2 == null ? 0 : array2.length;
8012             return length2 ? baseFlatten(array2, 1) : [];
8013           }
8014           function flattenDeep(array2) {
8015             var length2 = array2 == null ? 0 : array2.length;
8016             return length2 ? baseFlatten(array2, INFINITY2) : [];
8017           }
8018           function flattenDepth(array2, depth) {
8019             var length2 = array2 == null ? 0 : array2.length;
8020             if (!length2) {
8021               return [];
8022             }
8023             depth = depth === undefined2 ? 1 : toInteger(depth);
8024             return baseFlatten(array2, depth);
8025           }
8026           function fromPairs(pairs2) {
8027             var index = -1, length2 = pairs2 == null ? 0 : pairs2.length, result2 = {};
8028             while (++index < length2) {
8029               var pair3 = pairs2[index];
8030               result2[pair3[0]] = pair3[1];
8031             }
8032             return result2;
8033           }
8034           function head(array2) {
8035             return array2 && array2.length ? array2[0] : undefined2;
8036           }
8037           function indexOf(array2, value, fromIndex) {
8038             var length2 = array2 == null ? 0 : array2.length;
8039             if (!length2) {
8040               return -1;
8041             }
8042             var index = fromIndex == null ? 0 : toInteger(fromIndex);
8043             if (index < 0) {
8044               index = nativeMax2(length2 + index, 0);
8045             }
8046             return baseIndexOf(array2, value, index);
8047           }
8048           function initial(array2) {
8049             var length2 = array2 == null ? 0 : array2.length;
8050             return length2 ? baseSlice(array2, 0, -1) : [];
8051           }
8052           var intersection2 = baseRest(function(arrays) {
8053             var mapped = arrayMap2(arrays, castArrayLikeObject);
8054             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
8055           });
8056           var intersectionBy = baseRest(function(arrays) {
8057             var iteratee2 = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
8058             if (iteratee2 === last(mapped)) {
8059               iteratee2 = undefined2;
8060             } else {
8061               mapped.pop();
8062             }
8063             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, getIteratee(iteratee2, 2)) : [];
8064           });
8065           var intersectionWith = baseRest(function(arrays) {
8066             var comparator = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
8067             comparator = typeof comparator == "function" ? comparator : undefined2;
8068             if (comparator) {
8069               mapped.pop();
8070             }
8071             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
8072           });
8073           function join(array2, separator) {
8074             return array2 == null ? "" : nativeJoin.call(array2, separator);
8075           }
8076           function last(array2) {
8077             var length2 = array2 == null ? 0 : array2.length;
8078             return length2 ? array2[length2 - 1] : undefined2;
8079           }
8080           function lastIndexOf(array2, value, fromIndex) {
8081             var length2 = array2 == null ? 0 : array2.length;
8082             if (!length2) {
8083               return -1;
8084             }
8085             var index = length2;
8086             if (fromIndex !== undefined2) {
8087               index = toInteger(fromIndex);
8088               index = index < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
8089             }
8090             return value === value ? strictLastIndexOf(array2, value, index) : baseFindIndex(array2, baseIsNaN, index, true);
8091           }
8092           function nth(array2, n3) {
8093             return array2 && array2.length ? baseNth(array2, toInteger(n3)) : undefined2;
8094           }
8095           var pull = baseRest(pullAll);
8096           function pullAll(array2, values2) {
8097             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
8098           }
8099           function pullAllBy(array2, values2, iteratee2) {
8100             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, getIteratee(iteratee2, 2)) : array2;
8101           }
8102           function pullAllWith(array2, values2, comparator) {
8103             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, undefined2, comparator) : array2;
8104           }
8105           var pullAt = flatRest(function(array2, indexes) {
8106             var length2 = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes);
8107             basePullAt(array2, arrayMap2(indexes, function(index) {
8108               return isIndex2(index, length2) ? +index : index;
8109             }).sort(compareAscending));
8110             return result2;
8111           });
8112           function remove2(array2, predicate) {
8113             var result2 = [];
8114             if (!(array2 && array2.length)) {
8115               return result2;
8116             }
8117             var index = -1, indexes = [], length2 = array2.length;
8118             predicate = getIteratee(predicate, 3);
8119             while (++index < length2) {
8120               var value = array2[index];
8121               if (predicate(value, index, array2)) {
8122                 result2.push(value);
8123                 indexes.push(index);
8124               }
8125             }
8126             basePullAt(array2, indexes);
8127             return result2;
8128           }
8129           function reverse(array2) {
8130             return array2 == null ? array2 : nativeReverse.call(array2);
8131           }
8132           function slice(array2, start2, end) {
8133             var length2 = array2 == null ? 0 : array2.length;
8134             if (!length2) {
8135               return [];
8136             }
8137             if (end && typeof end != "number" && isIterateeCall(array2, start2, end)) {
8138               start2 = 0;
8139               end = length2;
8140             } else {
8141               start2 = start2 == null ? 0 : toInteger(start2);
8142               end = end === undefined2 ? length2 : toInteger(end);
8143             }
8144             return baseSlice(array2, start2, end);
8145           }
8146           function sortedIndex(array2, value) {
8147             return baseSortedIndex(array2, value);
8148           }
8149           function sortedIndexBy(array2, value, iteratee2) {
8150             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2));
8151           }
8152           function sortedIndexOf(array2, value) {
8153             var length2 = array2 == null ? 0 : array2.length;
8154             if (length2) {
8155               var index = baseSortedIndex(array2, value);
8156               if (index < length2 && eq2(array2[index], value)) {
8157                 return index;
8158               }
8159             }
8160             return -1;
8161           }
8162           function sortedLastIndex(array2, value) {
8163             return baseSortedIndex(array2, value, true);
8164           }
8165           function sortedLastIndexBy(array2, value, iteratee2) {
8166             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2), true);
8167           }
8168           function sortedLastIndexOf(array2, value) {
8169             var length2 = array2 == null ? 0 : array2.length;
8170             if (length2) {
8171               var index = baseSortedIndex(array2, value, true) - 1;
8172               if (eq2(array2[index], value)) {
8173                 return index;
8174               }
8175             }
8176             return -1;
8177           }
8178           function sortedUniq(array2) {
8179             return array2 && array2.length ? baseSortedUniq(array2) : [];
8180           }
8181           function sortedUniqBy(array2, iteratee2) {
8182             return array2 && array2.length ? baseSortedUniq(array2, getIteratee(iteratee2, 2)) : [];
8183           }
8184           function tail(array2) {
8185             var length2 = array2 == null ? 0 : array2.length;
8186             return length2 ? baseSlice(array2, 1, length2) : [];
8187           }
8188           function take(array2, n3, guard) {
8189             if (!(array2 && array2.length)) {
8190               return [];
8191             }
8192             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
8193             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
8194           }
8195           function takeRight(array2, n3, guard) {
8196             var length2 = array2 == null ? 0 : array2.length;
8197             if (!length2) {
8198               return [];
8199             }
8200             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
8201             n3 = length2 - n3;
8202             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
8203           }
8204           function takeRightWhile(array2, predicate) {
8205             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), false, true) : [];
8206           }
8207           function takeWhile(array2, predicate) {
8208             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3)) : [];
8209           }
8210           var union2 = baseRest(function(arrays) {
8211             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8212           });
8213           var unionBy = baseRest(function(arrays) {
8214             var iteratee2 = last(arrays);
8215             if (isArrayLikeObject(iteratee2)) {
8216               iteratee2 = undefined2;
8217             }
8218             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2));
8219           });
8220           var unionWith = baseRest(function(arrays) {
8221             var comparator = last(arrays);
8222             comparator = typeof comparator == "function" ? comparator : undefined2;
8223             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined2, comparator);
8224           });
8225           function uniq(array2) {
8226             return array2 && array2.length ? baseUniq(array2) : [];
8227           }
8228           function uniqBy(array2, iteratee2) {
8229             return array2 && array2.length ? baseUniq(array2, getIteratee(iteratee2, 2)) : [];
8230           }
8231           function uniqWith(array2, comparator) {
8232             comparator = typeof comparator == "function" ? comparator : undefined2;
8233             return array2 && array2.length ? baseUniq(array2, undefined2, comparator) : [];
8234           }
8235           function unzip(array2) {
8236             if (!(array2 && array2.length)) {
8237               return [];
8238             }
8239             var length2 = 0;
8240             array2 = arrayFilter2(array2, function(group) {
8241               if (isArrayLikeObject(group)) {
8242                 length2 = nativeMax2(group.length, length2);
8243                 return true;
8244               }
8245             });
8246             return baseTimes2(length2, function(index) {
8247               return arrayMap2(array2, baseProperty(index));
8248             });
8249           }
8250           function unzipWith(array2, iteratee2) {
8251             if (!(array2 && array2.length)) {
8252               return [];
8253             }
8254             var result2 = unzip(array2);
8255             if (iteratee2 == null) {
8256               return result2;
8257             }
8258             return arrayMap2(result2, function(group) {
8259               return apply(iteratee2, undefined2, group);
8260             });
8261           }
8262           var without = baseRest(function(array2, values2) {
8263             return isArrayLikeObject(array2) ? baseDifference(array2, values2) : [];
8264           });
8265           var xor = baseRest(function(arrays) {
8266             return baseXor(arrayFilter2(arrays, isArrayLikeObject));
8267           });
8268           var xorBy = baseRest(function(arrays) {
8269             var iteratee2 = last(arrays);
8270             if (isArrayLikeObject(iteratee2)) {
8271               iteratee2 = undefined2;
8272             }
8273             return baseXor(arrayFilter2(arrays, isArrayLikeObject), getIteratee(iteratee2, 2));
8274           });
8275           var xorWith = baseRest(function(arrays) {
8276             var comparator = last(arrays);
8277             comparator = typeof comparator == "function" ? comparator : undefined2;
8278             return baseXor(arrayFilter2(arrays, isArrayLikeObject), undefined2, comparator);
8279           });
8280           var zip = baseRest(unzip);
8281           function zipObject(props, values2) {
8282             return baseZipObject(props || [], values2 || [], assignValue);
8283           }
8284           function zipObjectDeep(props, values2) {
8285             return baseZipObject(props || [], values2 || [], baseSet);
8286           }
8287           var zipWith = baseRest(function(arrays) {
8288             var length2 = arrays.length, iteratee2 = length2 > 1 ? arrays[length2 - 1] : undefined2;
8289             iteratee2 = typeof iteratee2 == "function" ? (arrays.pop(), iteratee2) : undefined2;
8290             return unzipWith(arrays, iteratee2);
8291           });
8292           function chain(value) {
8293             var result2 = lodash(value);
8294             result2.__chain__ = true;
8295             return result2;
8296           }
8297           function tap(value, interceptor) {
8298             interceptor(value);
8299             return value;
8300           }
8301           function thru(value, interceptor) {
8302             return interceptor(value);
8303           }
8304           var wrapperAt = flatRest(function(paths) {
8305             var length2 = paths.length, start2 = length2 ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) {
8306               return baseAt(object, paths);
8307             };
8308             if (length2 > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) {
8309               return this.thru(interceptor);
8310             }
8311             value = value.slice(start2, +start2 + (length2 ? 1 : 0));
8312             value.__actions__.push({
8313               "func": thru,
8314               "args": [interceptor],
8315               "thisArg": undefined2
8316             });
8317             return new LodashWrapper(value, this.__chain__).thru(function(array2) {
8318               if (length2 && !array2.length) {
8319                 array2.push(undefined2);
8320               }
8321               return array2;
8322             });
8323           });
8324           function wrapperChain() {
8325             return chain(this);
8326           }
8327           function wrapperCommit() {
8328             return new LodashWrapper(this.value(), this.__chain__);
8329           }
8330           function wrapperNext() {
8331             if (this.__values__ === undefined2) {
8332               this.__values__ = toArray(this.value());
8333             }
8334             var done = this.__index__ >= this.__values__.length, value = done ? undefined2 : this.__values__[this.__index__++];
8335             return { "done": done, "value": value };
8336           }
8337           function wrapperToIterator() {
8338             return this;
8339           }
8340           function wrapperPlant(value) {
8341             var result2, parent2 = this;
8342             while (parent2 instanceof baseLodash) {
8343               var clone3 = wrapperClone(parent2);
8344               clone3.__index__ = 0;
8345               clone3.__values__ = undefined2;
8346               if (result2) {
8347                 previous.__wrapped__ = clone3;
8348               } else {
8349                 result2 = clone3;
8350               }
8351               var previous = clone3;
8352               parent2 = parent2.__wrapped__;
8353             }
8354             previous.__wrapped__ = value;
8355             return result2;
8356           }
8357           function wrapperReverse() {
8358             var value = this.__wrapped__;
8359             if (value instanceof LazyWrapper) {
8360               var wrapped = value;
8361               if (this.__actions__.length) {
8362                 wrapped = new LazyWrapper(this);
8363               }
8364               wrapped = wrapped.reverse();
8365               wrapped.__actions__.push({
8366                 "func": thru,
8367                 "args": [reverse],
8368                 "thisArg": undefined2
8369               });
8370               return new LodashWrapper(wrapped, this.__chain__);
8371             }
8372             return this.thru(reverse);
8373           }
8374           function wrapperValue() {
8375             return baseWrapperValue(this.__wrapped__, this.__actions__);
8376           }
8377           var countBy = createAggregator(function(result2, value, key) {
8378             if (hasOwnProperty10.call(result2, key)) {
8379               ++result2[key];
8380             } else {
8381               baseAssignValue(result2, key, 1);
8382             }
8383           });
8384           function every(collection, predicate, guard) {
8385             var func = isArray2(collection) ? arrayEvery : baseEvery;
8386             if (guard && isIterateeCall(collection, predicate, guard)) {
8387               predicate = undefined2;
8388             }
8389             return func(collection, getIteratee(predicate, 3));
8390           }
8391           function filter2(collection, predicate) {
8392             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
8393             return func(collection, getIteratee(predicate, 3));
8394           }
8395           var find2 = createFind(findIndex);
8396           var findLast = createFind(findLastIndex);
8397           function flatMap(collection, iteratee2) {
8398             return baseFlatten(map2(collection, iteratee2), 1);
8399           }
8400           function flatMapDeep(collection, iteratee2) {
8401             return baseFlatten(map2(collection, iteratee2), INFINITY2);
8402           }
8403           function flatMapDepth(collection, iteratee2, depth) {
8404             depth = depth === undefined2 ? 1 : toInteger(depth);
8405             return baseFlatten(map2(collection, iteratee2), depth);
8406           }
8407           function forEach(collection, iteratee2) {
8408             var func = isArray2(collection) ? arrayEach : baseEach;
8409             return func(collection, getIteratee(iteratee2, 3));
8410           }
8411           function forEachRight(collection, iteratee2) {
8412             var func = isArray2(collection) ? arrayEachRight : baseEachRight;
8413             return func(collection, getIteratee(iteratee2, 3));
8414           }
8415           var groupBy = createAggregator(function(result2, value, key) {
8416             if (hasOwnProperty10.call(result2, key)) {
8417               result2[key].push(value);
8418             } else {
8419               baseAssignValue(result2, key, [value]);
8420             }
8421           });
8422           function includes(collection, value, fromIndex, guard) {
8423             collection = isArrayLike2(collection) ? collection : values(collection);
8424             fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
8425             var length2 = collection.length;
8426             if (fromIndex < 0) {
8427               fromIndex = nativeMax2(length2 + fromIndex, 0);
8428             }
8429             return isString(collection) ? fromIndex <= length2 && collection.indexOf(value, fromIndex) > -1 : !!length2 && baseIndexOf(collection, value, fromIndex) > -1;
8430           }
8431           var invokeMap = baseRest(function(collection, path, args) {
8432             var index = -1, isFunc = typeof path == "function", result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
8433             baseEach(collection, function(value) {
8434               result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
8435             });
8436             return result2;
8437           });
8438           var keyBy = createAggregator(function(result2, value, key) {
8439             baseAssignValue(result2, key, value);
8440           });
8441           function map2(collection, iteratee2) {
8442             var func = isArray2(collection) ? arrayMap2 : baseMap;
8443             return func(collection, getIteratee(iteratee2, 3));
8444           }
8445           function orderBy(collection, iteratees, orders, guard) {
8446             if (collection == null) {
8447               return [];
8448             }
8449             if (!isArray2(iteratees)) {
8450               iteratees = iteratees == null ? [] : [iteratees];
8451             }
8452             orders = guard ? undefined2 : orders;
8453             if (!isArray2(orders)) {
8454               orders = orders == null ? [] : [orders];
8455             }
8456             return baseOrderBy(collection, iteratees, orders);
8457           }
8458           var partition = createAggregator(function(result2, value, key) {
8459             result2[key ? 0 : 1].push(value);
8460           }, function() {
8461             return [[], []];
8462           });
8463           function reduce(collection, iteratee2, accumulator) {
8464             var func = isArray2(collection) ? arrayReduce : baseReduce, initAccum = arguments.length < 3;
8465             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEach);
8466           }
8467           function reduceRight(collection, iteratee2, accumulator) {
8468             var func = isArray2(collection) ? arrayReduceRight : baseReduce, initAccum = arguments.length < 3;
8469             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEachRight);
8470           }
8471           function reject(collection, predicate) {
8472             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
8473             return func(collection, negate(getIteratee(predicate, 3)));
8474           }
8475           function sample(collection) {
8476             var func = isArray2(collection) ? arraySample : baseSample;
8477             return func(collection);
8478           }
8479           function sampleSize(collection, n3, guard) {
8480             if (guard ? isIterateeCall(collection, n3, guard) : n3 === undefined2) {
8481               n3 = 1;
8482             } else {
8483               n3 = toInteger(n3);
8484             }
8485             var func = isArray2(collection) ? arraySampleSize : baseSampleSize;
8486             return func(collection, n3);
8487           }
8488           function shuffle(collection) {
8489             var func = isArray2(collection) ? arrayShuffle : baseShuffle;
8490             return func(collection);
8491           }
8492           function size(collection) {
8493             if (collection == null) {
8494               return 0;
8495             }
8496             if (isArrayLike2(collection)) {
8497               return isString(collection) ? stringSize(collection) : collection.length;
8498             }
8499             var tag2 = getTag2(collection);
8500             if (tag2 == mapTag4 || tag2 == setTag4) {
8501               return collection.size;
8502             }
8503             return baseKeys2(collection).length;
8504           }
8505           function some(collection, predicate, guard) {
8506             var func = isArray2(collection) ? arraySome2 : baseSome;
8507             if (guard && isIterateeCall(collection, predicate, guard)) {
8508               predicate = undefined2;
8509             }
8510             return func(collection, getIteratee(predicate, 3));
8511           }
8512           var sortBy = baseRest(function(collection, iteratees) {
8513             if (collection == null) {
8514               return [];
8515             }
8516             var length2 = iteratees.length;
8517             if (length2 > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
8518               iteratees = [];
8519             } else if (length2 > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
8520               iteratees = [iteratees[0]];
8521             }
8522             return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
8523           });
8524           var now3 = ctxNow || function() {
8525             return root3.Date.now();
8526           };
8527           function after(n3, func) {
8528             if (typeof func != "function") {
8529               throw new TypeError2(FUNC_ERROR_TEXT3);
8530             }
8531             n3 = toInteger(n3);
8532             return function() {
8533               if (--n3 < 1) {
8534                 return func.apply(this, arguments);
8535               }
8536             };
8537           }
8538           function ary(func, n3, guard) {
8539             n3 = guard ? undefined2 : n3;
8540             n3 = func && n3 == null ? func.length : n3;
8541             return createWrap(func, WRAP_ARY_FLAG, undefined2, undefined2, undefined2, undefined2, n3);
8542           }
8543           function before(n3, func) {
8544             var result2;
8545             if (typeof func != "function") {
8546               throw new TypeError2(FUNC_ERROR_TEXT3);
8547             }
8548             n3 = toInteger(n3);
8549             return function() {
8550               if (--n3 > 0) {
8551                 result2 = func.apply(this, arguments);
8552               }
8553               if (n3 <= 1) {
8554                 func = undefined2;
8555               }
8556               return result2;
8557             };
8558           }
8559           var bind = baseRest(function(func, thisArg, partials) {
8560             var bitmask = WRAP_BIND_FLAG;
8561             if (partials.length) {
8562               var holders = replaceHolders(partials, getHolder(bind));
8563               bitmask |= WRAP_PARTIAL_FLAG;
8564             }
8565             return createWrap(func, bitmask, thisArg, partials, holders);
8566           });
8567           var bindKey2 = baseRest(function(object, key, partials) {
8568             var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
8569             if (partials.length) {
8570               var holders = replaceHolders(partials, getHolder(bindKey2));
8571               bitmask |= WRAP_PARTIAL_FLAG;
8572             }
8573             return createWrap(key, bitmask, object, partials, holders);
8574           });
8575           function curry(func, arity, guard) {
8576             arity = guard ? undefined2 : arity;
8577             var result2 = createWrap(func, WRAP_CURRY_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
8578             result2.placeholder = curry.placeholder;
8579             return result2;
8580           }
8581           function curryRight(func, arity, guard) {
8582             arity = guard ? undefined2 : arity;
8583             var result2 = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
8584             result2.placeholder = curryRight.placeholder;
8585             return result2;
8586           }
8587           function debounce2(func, wait, options2) {
8588             var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
8589             if (typeof func != "function") {
8590               throw new TypeError2(FUNC_ERROR_TEXT3);
8591             }
8592             wait = toNumber3(wait) || 0;
8593             if (isObject3(options2)) {
8594               leading = !!options2.leading;
8595               maxing = "maxWait" in options2;
8596               maxWait = maxing ? nativeMax2(toNumber3(options2.maxWait) || 0, wait) : maxWait;
8597               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
8598             }
8599             function invokeFunc(time) {
8600               var args = lastArgs, thisArg = lastThis;
8601               lastArgs = lastThis = undefined2;
8602               lastInvokeTime = time;
8603               result2 = func.apply(thisArg, args);
8604               return result2;
8605             }
8606             function leadingEdge(time) {
8607               lastInvokeTime = time;
8608               timerId = setTimeout2(timerExpired, wait);
8609               return leading ? invokeFunc(time) : result2;
8610             }
8611             function remainingWait(time) {
8612               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
8613               return maxing ? nativeMin2(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
8614             }
8615             function shouldInvoke(time) {
8616               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
8617               return lastCallTime === undefined2 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
8618             }
8619             function timerExpired() {
8620               var time = now3();
8621               if (shouldInvoke(time)) {
8622                 return trailingEdge(time);
8623               }
8624               timerId = setTimeout2(timerExpired, remainingWait(time));
8625             }
8626             function trailingEdge(time) {
8627               timerId = undefined2;
8628               if (trailing && lastArgs) {
8629                 return invokeFunc(time);
8630               }
8631               lastArgs = lastThis = undefined2;
8632               return result2;
8633             }
8634             function cancel() {
8635               if (timerId !== undefined2) {
8636                 clearTimeout2(timerId);
8637               }
8638               lastInvokeTime = 0;
8639               lastArgs = lastCallTime = lastThis = timerId = undefined2;
8640             }
8641             function flush() {
8642               return timerId === undefined2 ? result2 : trailingEdge(now3());
8643             }
8644             function debounced() {
8645               var time = now3(), isInvoking = shouldInvoke(time);
8646               lastArgs = arguments;
8647               lastThis = this;
8648               lastCallTime = time;
8649               if (isInvoking) {
8650                 if (timerId === undefined2) {
8651                   return leadingEdge(lastCallTime);
8652                 }
8653                 if (maxing) {
8654                   clearTimeout2(timerId);
8655                   timerId = setTimeout2(timerExpired, wait);
8656                   return invokeFunc(lastCallTime);
8657                 }
8658               }
8659               if (timerId === undefined2) {
8660                 timerId = setTimeout2(timerExpired, wait);
8661               }
8662               return result2;
8663             }
8664             debounced.cancel = cancel;
8665             debounced.flush = flush;
8666             return debounced;
8667           }
8668           var defer = baseRest(function(func, args) {
8669             return baseDelay(func, 1, args);
8670           });
8671           var delay = baseRest(function(func, wait, args) {
8672             return baseDelay(func, toNumber3(wait) || 0, args);
8673           });
8674           function flip(func) {
8675             return createWrap(func, WRAP_FLIP_FLAG);
8676           }
8677           function memoize(func, resolver) {
8678             if (typeof func != "function" || resolver != null && typeof resolver != "function") {
8679               throw new TypeError2(FUNC_ERROR_TEXT3);
8680             }
8681             var memoized = function() {
8682               var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
8683               if (cache.has(key)) {
8684                 return cache.get(key);
8685               }
8686               var result2 = func.apply(this, args);
8687               memoized.cache = cache.set(key, result2) || cache;
8688               return result2;
8689             };
8690             memoized.cache = new (memoize.Cache || MapCache2)();
8691             return memoized;
8692           }
8693           memoize.Cache = MapCache2;
8694           function negate(predicate) {
8695             if (typeof predicate != "function") {
8696               throw new TypeError2(FUNC_ERROR_TEXT3);
8697             }
8698             return function() {
8699               var args = arguments;
8700               switch (args.length) {
8701                 case 0:
8702                   return !predicate.call(this);
8703                 case 1:
8704                   return !predicate.call(this, args[0]);
8705                 case 2:
8706                   return !predicate.call(this, args[0], args[1]);
8707                 case 3:
8708                   return !predicate.call(this, args[0], args[1], args[2]);
8709               }
8710               return !predicate.apply(this, args);
8711             };
8712           }
8713           function once(func) {
8714             return before(2, func);
8715           }
8716           var overArgs = castRest(function(func, transforms) {
8717             transforms = transforms.length == 1 && isArray2(transforms[0]) ? arrayMap2(transforms[0], baseUnary2(getIteratee())) : arrayMap2(baseFlatten(transforms, 1), baseUnary2(getIteratee()));
8718             var funcsLength = transforms.length;
8719             return baseRest(function(args) {
8720               var index = -1, length2 = nativeMin2(args.length, funcsLength);
8721               while (++index < length2) {
8722                 args[index] = transforms[index].call(this, args[index]);
8723               }
8724               return apply(func, this, args);
8725             });
8726           });
8727           var partial = baseRest(function(func, partials) {
8728             var holders = replaceHolders(partials, getHolder(partial));
8729             return createWrap(func, WRAP_PARTIAL_FLAG, undefined2, partials, holders);
8730           });
8731           var partialRight = baseRest(function(func, partials) {
8732             var holders = replaceHolders(partials, getHolder(partialRight));
8733             return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined2, partials, holders);
8734           });
8735           var rearg = flatRest(function(func, indexes) {
8736             return createWrap(func, WRAP_REARG_FLAG, undefined2, undefined2, undefined2, indexes);
8737           });
8738           function rest(func, start2) {
8739             if (typeof func != "function") {
8740               throw new TypeError2(FUNC_ERROR_TEXT3);
8741             }
8742             start2 = start2 === undefined2 ? start2 : toInteger(start2);
8743             return baseRest(func, start2);
8744           }
8745           function spread(func, start2) {
8746             if (typeof func != "function") {
8747               throw new TypeError2(FUNC_ERROR_TEXT3);
8748             }
8749             start2 = start2 == null ? 0 : nativeMax2(toInteger(start2), 0);
8750             return baseRest(function(args) {
8751               var array2 = args[start2], otherArgs = castSlice(args, 0, start2);
8752               if (array2) {
8753                 arrayPush2(otherArgs, array2);
8754               }
8755               return apply(func, this, otherArgs);
8756             });
8757           }
8758           function throttle2(func, wait, options2) {
8759             var leading = true, trailing = true;
8760             if (typeof func != "function") {
8761               throw new TypeError2(FUNC_ERROR_TEXT3);
8762             }
8763             if (isObject3(options2)) {
8764               leading = "leading" in options2 ? !!options2.leading : leading;
8765               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
8766             }
8767             return debounce2(func, wait, {
8768               "leading": leading,
8769               "maxWait": wait,
8770               "trailing": trailing
8771             });
8772           }
8773           function unary(func) {
8774             return ary(func, 1);
8775           }
8776           function wrap2(value, wrapper) {
8777             return partial(castFunction(wrapper), value);
8778           }
8779           function castArray() {
8780             if (!arguments.length) {
8781               return [];
8782             }
8783             var value = arguments[0];
8784             return isArray2(value) ? value : [value];
8785           }
8786           function clone2(value) {
8787             return baseClone(value, CLONE_SYMBOLS_FLAG);
8788           }
8789           function cloneWith(value, customizer) {
8790             customizer = typeof customizer == "function" ? customizer : undefined2;
8791             return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
8792           }
8793           function cloneDeep(value) {
8794             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
8795           }
8796           function cloneDeepWith(value, customizer) {
8797             customizer = typeof customizer == "function" ? customizer : undefined2;
8798             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
8799           }
8800           function conformsTo(object, source) {
8801             return source == null || baseConformsTo(object, source, keys2(source));
8802           }
8803           function eq2(value, other) {
8804             return value === other || value !== value && other !== other;
8805           }
8806           var gt2 = createRelationalOperation(baseGt);
8807           var gte = createRelationalOperation(function(value, other) {
8808             return value >= other;
8809           });
8810           var isArguments2 = baseIsArguments2(/* @__PURE__ */ function() {
8811             return arguments;
8812           }()) ? baseIsArguments2 : function(value) {
8813             return isObjectLike2(value) && hasOwnProperty10.call(value, "callee") && !propertyIsEnumerable3.call(value, "callee");
8814           };
8815           var isArray2 = Array2.isArray;
8816           var isArrayBuffer = nodeIsArrayBuffer ? baseUnary2(nodeIsArrayBuffer) : baseIsArrayBuffer;
8817           function isArrayLike2(value) {
8818             return value != null && isLength2(value.length) && !isFunction2(value);
8819           }
8820           function isArrayLikeObject(value) {
8821             return isObjectLike2(value) && isArrayLike2(value);
8822           }
8823           function isBoolean(value) {
8824             return value === true || value === false || isObjectLike2(value) && baseGetTag2(value) == boolTag3;
8825           }
8826           var isBuffer2 = nativeIsBuffer2 || stubFalse2;
8827           var isDate = nodeIsDate ? baseUnary2(nodeIsDate) : baseIsDate;
8828           function isElement2(value) {
8829             return isObjectLike2(value) && value.nodeType === 1 && !isPlainObject(value);
8830           }
8831           function isEmpty(value) {
8832             if (value == null) {
8833               return true;
8834             }
8835             if (isArrayLike2(value) && (isArray2(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer2(value) || isTypedArray2(value) || isArguments2(value))) {
8836               return !value.length;
8837             }
8838             var tag2 = getTag2(value);
8839             if (tag2 == mapTag4 || tag2 == setTag4) {
8840               return !value.size;
8841             }
8842             if (isPrototype2(value)) {
8843               return !baseKeys2(value).length;
8844             }
8845             for (var key in value) {
8846               if (hasOwnProperty10.call(value, key)) {
8847                 return false;
8848               }
8849             }
8850             return true;
8851           }
8852           function isEqual4(value, other) {
8853             return baseIsEqual2(value, other);
8854           }
8855           function isEqualWith(value, other, customizer) {
8856             customizer = typeof customizer == "function" ? customizer : undefined2;
8857             var result2 = customizer ? customizer(value, other) : undefined2;
8858             return result2 === undefined2 ? baseIsEqual2(value, other, undefined2, customizer) : !!result2;
8859           }
8860           function isError(value) {
8861             if (!isObjectLike2(value)) {
8862               return false;
8863             }
8864             var tag2 = baseGetTag2(value);
8865             return tag2 == errorTag3 || tag2 == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value);
8866           }
8867           function isFinite2(value) {
8868             return typeof value == "number" && nativeIsFinite(value);
8869           }
8870           function isFunction2(value) {
8871             if (!isObject3(value)) {
8872               return false;
8873             }
8874             var tag2 = baseGetTag2(value);
8875             return tag2 == funcTag3 || tag2 == genTag2 || tag2 == asyncTag2 || tag2 == proxyTag2;
8876           }
8877           function isInteger(value) {
8878             return typeof value == "number" && value == toInteger(value);
8879           }
8880           function isLength2(value) {
8881             return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER4;
8882           }
8883           function isObject3(value) {
8884             var type2 = typeof value;
8885             return value != null && (type2 == "object" || type2 == "function");
8886           }
8887           function isObjectLike2(value) {
8888             return value != null && typeof value == "object";
8889           }
8890           var isMap = nodeIsMap ? baseUnary2(nodeIsMap) : baseIsMap;
8891           function isMatch(object, source) {
8892             return object === source || baseIsMatch(object, source, getMatchData(source));
8893           }
8894           function isMatchWith(object, source, customizer) {
8895             customizer = typeof customizer == "function" ? customizer : undefined2;
8896             return baseIsMatch(object, source, getMatchData(source), customizer);
8897           }
8898           function isNaN2(value) {
8899             return isNumber3(value) && value != +value;
8900           }
8901           function isNative(value) {
8902             if (isMaskable(value)) {
8903               throw new Error2(CORE_ERROR_TEXT);
8904             }
8905             return baseIsNative2(value);
8906           }
8907           function isNull(value) {
8908             return value === null;
8909           }
8910           function isNil(value) {
8911             return value == null;
8912           }
8913           function isNumber3(value) {
8914             return typeof value == "number" || isObjectLike2(value) && baseGetTag2(value) == numberTag4;
8915           }
8916           function isPlainObject(value) {
8917             if (!isObjectLike2(value) || baseGetTag2(value) != objectTag4) {
8918               return false;
8919             }
8920             var proto = getPrototype(value);
8921             if (proto === null) {
8922               return true;
8923             }
8924             var Ctor = hasOwnProperty10.call(proto, "constructor") && proto.constructor;
8925             return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
8926           }
8927           var isRegExp = nodeIsRegExp ? baseUnary2(nodeIsRegExp) : baseIsRegExp;
8928           function isSafeInteger(value) {
8929             return isInteger(value) && value >= -MAX_SAFE_INTEGER4 && value <= MAX_SAFE_INTEGER4;
8930           }
8931           var isSet = nodeIsSet ? baseUnary2(nodeIsSet) : baseIsSet;
8932           function isString(value) {
8933             return typeof value == "string" || !isArray2(value) && isObjectLike2(value) && baseGetTag2(value) == stringTag3;
8934           }
8935           function isSymbol2(value) {
8936             return typeof value == "symbol" || isObjectLike2(value) && baseGetTag2(value) == symbolTag3;
8937           }
8938           var isTypedArray2 = nodeIsTypedArray2 ? baseUnary2(nodeIsTypedArray2) : baseIsTypedArray2;
8939           function isUndefined(value) {
8940             return value === undefined2;
8941           }
8942           function isWeakMap(value) {
8943             return isObjectLike2(value) && getTag2(value) == weakMapTag3;
8944           }
8945           function isWeakSet(value) {
8946             return isObjectLike2(value) && baseGetTag2(value) == weakSetTag;
8947           }
8948           var lt2 = createRelationalOperation(baseLt);
8949           var lte = createRelationalOperation(function(value, other) {
8950             return value <= other;
8951           });
8952           function toArray(value) {
8953             if (!value) {
8954               return [];
8955             }
8956             if (isArrayLike2(value)) {
8957               return isString(value) ? stringToArray(value) : copyArray(value);
8958             }
8959             if (symIterator && value[symIterator]) {
8960               return iteratorToArray(value[symIterator]());
8961             }
8962             var tag2 = getTag2(value), func = tag2 == mapTag4 ? mapToArray2 : tag2 == setTag4 ? setToArray2 : values;
8963             return func(value);
8964           }
8965           function toFinite(value) {
8966             if (!value) {
8967               return value === 0 ? value : 0;
8968             }
8969             value = toNumber3(value);
8970             if (value === INFINITY2 || value === -INFINITY2) {
8971               var sign2 = value < 0 ? -1 : 1;
8972               return sign2 * MAX_INTEGER;
8973             }
8974             return value === value ? value : 0;
8975           }
8976           function toInteger(value) {
8977             var result2 = toFinite(value), remainder = result2 % 1;
8978             return result2 === result2 ? remainder ? result2 - remainder : result2 : 0;
8979           }
8980           function toLength(value) {
8981             return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
8982           }
8983           function toNumber3(value) {
8984             if (typeof value == "number") {
8985               return value;
8986             }
8987             if (isSymbol2(value)) {
8988               return NAN2;
8989             }
8990             if (isObject3(value)) {
8991               var other = typeof value.valueOf == "function" ? value.valueOf() : value;
8992               value = isObject3(other) ? other + "" : other;
8993             }
8994             if (typeof value != "string") {
8995               return value === 0 ? value : +value;
8996             }
8997             value = baseTrim2(value);
8998             var isBinary = reIsBinary2.test(value);
8999             return isBinary || reIsOctal2.test(value) ? freeParseInt2(value.slice(2), isBinary ? 2 : 8) : reIsBadHex2.test(value) ? NAN2 : +value;
9000           }
9001           function toPlainObject(value) {
9002             return copyObject(value, keysIn(value));
9003           }
9004           function toSafeInteger(value) {
9005             return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER4, MAX_SAFE_INTEGER4) : value === 0 ? value : 0;
9006           }
9007           function toString2(value) {
9008             return value == null ? "" : baseToString2(value);
9009           }
9010           var assign = createAssigner(function(object, source) {
9011             if (isPrototype2(source) || isArrayLike2(source)) {
9012               copyObject(source, keys2(source), object);
9013               return;
9014             }
9015             for (var key in source) {
9016               if (hasOwnProperty10.call(source, key)) {
9017                 assignValue(object, key, source[key]);
9018               }
9019             }
9020           });
9021           var assignIn = createAssigner(function(object, source) {
9022             copyObject(source, keysIn(source), object);
9023           });
9024           var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
9025             copyObject(source, keysIn(source), object, customizer);
9026           });
9027           var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
9028             copyObject(source, keys2(source), object, customizer);
9029           });
9030           var at2 = flatRest(baseAt);
9031           function create2(prototype, properties) {
9032             var result2 = baseCreate(prototype);
9033             return properties == null ? result2 : baseAssign(result2, properties);
9034           }
9035           var defaults = baseRest(function(object, sources) {
9036             object = Object2(object);
9037             var index = -1;
9038             var length2 = sources.length;
9039             var guard = length2 > 2 ? sources[2] : undefined2;
9040             if (guard && isIterateeCall(sources[0], sources[1], guard)) {
9041               length2 = 1;
9042             }
9043             while (++index < length2) {
9044               var source = sources[index];
9045               var props = keysIn(source);
9046               var propsIndex = -1;
9047               var propsLength = props.length;
9048               while (++propsIndex < propsLength) {
9049                 var key = props[propsIndex];
9050                 var value = object[key];
9051                 if (value === undefined2 || eq2(value, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
9052                   object[key] = source[key];
9053                 }
9054               }
9055             }
9056             return object;
9057           });
9058           var defaultsDeep = baseRest(function(args) {
9059             args.push(undefined2, customDefaultsMerge);
9060             return apply(mergeWith, undefined2, args);
9061           });
9062           function findKey(object, predicate) {
9063             return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
9064           }
9065           function findLastKey(object, predicate) {
9066             return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
9067           }
9068           function forIn(object, iteratee2) {
9069             return object == null ? object : baseFor(object, getIteratee(iteratee2, 3), keysIn);
9070           }
9071           function forInRight(object, iteratee2) {
9072             return object == null ? object : baseForRight(object, getIteratee(iteratee2, 3), keysIn);
9073           }
9074           function forOwn(object, iteratee2) {
9075             return object && baseForOwn(object, getIteratee(iteratee2, 3));
9076           }
9077           function forOwnRight(object, iteratee2) {
9078             return object && baseForOwnRight(object, getIteratee(iteratee2, 3));
9079           }
9080           function functions(object) {
9081             return object == null ? [] : baseFunctions(object, keys2(object));
9082           }
9083           function functionsIn(object) {
9084             return object == null ? [] : baseFunctions(object, keysIn(object));
9085           }
9086           function get4(object, path, defaultValue) {
9087             var result2 = object == null ? undefined2 : baseGet(object, path);
9088             return result2 === undefined2 ? defaultValue : result2;
9089           }
9090           function has(object, path) {
9091             return object != null && hasPath(object, path, baseHas);
9092           }
9093           function hasIn(object, path) {
9094             return object != null && hasPath(object, path, baseHasIn);
9095           }
9096           var invert = createInverter(function(result2, value, key) {
9097             if (value != null && typeof value.toString != "function") {
9098               value = nativeObjectToString3.call(value);
9099             }
9100             result2[value] = key;
9101           }, constant(identity4));
9102           var invertBy = createInverter(function(result2, value, key) {
9103             if (value != null && typeof value.toString != "function") {
9104               value = nativeObjectToString3.call(value);
9105             }
9106             if (hasOwnProperty10.call(result2, value)) {
9107               result2[value].push(key);
9108             } else {
9109               result2[value] = [key];
9110             }
9111           }, getIteratee);
9112           var invoke = baseRest(baseInvoke);
9113           function keys2(object) {
9114             return isArrayLike2(object) ? arrayLikeKeys2(object) : baseKeys2(object);
9115           }
9116           function keysIn(object) {
9117             return isArrayLike2(object) ? arrayLikeKeys2(object, true) : baseKeysIn(object);
9118           }
9119           function mapKeys(object, iteratee2) {
9120             var result2 = {};
9121             iteratee2 = getIteratee(iteratee2, 3);
9122             baseForOwn(object, function(value, key, object2) {
9123               baseAssignValue(result2, iteratee2(value, key, object2), value);
9124             });
9125             return result2;
9126           }
9127           function mapValues(object, iteratee2) {
9128             var result2 = {};
9129             iteratee2 = getIteratee(iteratee2, 3);
9130             baseForOwn(object, function(value, key, object2) {
9131               baseAssignValue(result2, key, iteratee2(value, key, object2));
9132             });
9133             return result2;
9134           }
9135           var merge2 = createAssigner(function(object, source, srcIndex) {
9136             baseMerge(object, source, srcIndex);
9137           });
9138           var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
9139             baseMerge(object, source, srcIndex, customizer);
9140           });
9141           var omit = flatRest(function(object, paths) {
9142             var result2 = {};
9143             if (object == null) {
9144               return result2;
9145             }
9146             var isDeep = false;
9147             paths = arrayMap2(paths, function(path) {
9148               path = castPath(path, object);
9149               isDeep || (isDeep = path.length > 1);
9150               return path;
9151             });
9152             copyObject(object, getAllKeysIn(object), result2);
9153             if (isDeep) {
9154               result2 = baseClone(result2, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
9155             }
9156             var length2 = paths.length;
9157             while (length2--) {
9158               baseUnset(result2, paths[length2]);
9159             }
9160             return result2;
9161           });
9162           function omitBy(object, predicate) {
9163             return pickBy(object, negate(getIteratee(predicate)));
9164           }
9165           var pick = flatRest(function(object, paths) {
9166             return object == null ? {} : basePick(object, paths);
9167           });
9168           function pickBy(object, predicate) {
9169             if (object == null) {
9170               return {};
9171             }
9172             var props = arrayMap2(getAllKeysIn(object), function(prop) {
9173               return [prop];
9174             });
9175             predicate = getIteratee(predicate);
9176             return basePickBy(object, props, function(value, path) {
9177               return predicate(value, path[0]);
9178             });
9179           }
9180           function result(object, path, defaultValue) {
9181             path = castPath(path, object);
9182             var index = -1, length2 = path.length;
9183             if (!length2) {
9184               length2 = 1;
9185               object = undefined2;
9186             }
9187             while (++index < length2) {
9188               var value = object == null ? undefined2 : object[toKey(path[index])];
9189               if (value === undefined2) {
9190                 index = length2;
9191                 value = defaultValue;
9192               }
9193               object = isFunction2(value) ? value.call(object) : value;
9194             }
9195             return object;
9196           }
9197           function set4(object, path, value) {
9198             return object == null ? object : baseSet(object, path, value);
9199           }
9200           function setWith(object, path, value, customizer) {
9201             customizer = typeof customizer == "function" ? customizer : undefined2;
9202             return object == null ? object : baseSet(object, path, value, customizer);
9203           }
9204           var toPairs = createToPairs(keys2);
9205           var toPairsIn = createToPairs(keysIn);
9206           function transform2(object, iteratee2, accumulator) {
9207             var isArr = isArray2(object), isArrLike = isArr || isBuffer2(object) || isTypedArray2(object);
9208             iteratee2 = getIteratee(iteratee2, 4);
9209             if (accumulator == null) {
9210               var Ctor = object && object.constructor;
9211               if (isArrLike) {
9212                 accumulator = isArr ? new Ctor() : [];
9213               } else if (isObject3(object)) {
9214                 accumulator = isFunction2(Ctor) ? baseCreate(getPrototype(object)) : {};
9215               } else {
9216                 accumulator = {};
9217               }
9218             }
9219             (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object2) {
9220               return iteratee2(accumulator, value, index, object2);
9221             });
9222             return accumulator;
9223           }
9224           function unset(object, path) {
9225             return object == null ? true : baseUnset(object, path);
9226           }
9227           function update(object, path, updater) {
9228             return object == null ? object : baseUpdate(object, path, castFunction(updater));
9229           }
9230           function updateWith(object, path, updater, customizer) {
9231             customizer = typeof customizer == "function" ? customizer : undefined2;
9232             return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
9233           }
9234           function values(object) {
9235             return object == null ? [] : baseValues(object, keys2(object));
9236           }
9237           function valuesIn(object) {
9238             return object == null ? [] : baseValues(object, keysIn(object));
9239           }
9240           function clamp3(number3, lower2, upper) {
9241             if (upper === undefined2) {
9242               upper = lower2;
9243               lower2 = undefined2;
9244             }
9245             if (upper !== undefined2) {
9246               upper = toNumber3(upper);
9247               upper = upper === upper ? upper : 0;
9248             }
9249             if (lower2 !== undefined2) {
9250               lower2 = toNumber3(lower2);
9251               lower2 = lower2 === lower2 ? lower2 : 0;
9252             }
9253             return baseClamp(toNumber3(number3), lower2, upper);
9254           }
9255           function inRange(number3, start2, end) {
9256             start2 = toFinite(start2);
9257             if (end === undefined2) {
9258               end = start2;
9259               start2 = 0;
9260             } else {
9261               end = toFinite(end);
9262             }
9263             number3 = toNumber3(number3);
9264             return baseInRange(number3, start2, end);
9265           }
9266           function random(lower2, upper, floating) {
9267             if (floating && typeof floating != "boolean" && isIterateeCall(lower2, upper, floating)) {
9268               upper = floating = undefined2;
9269             }
9270             if (floating === undefined2) {
9271               if (typeof upper == "boolean") {
9272                 floating = upper;
9273                 upper = undefined2;
9274               } else if (typeof lower2 == "boolean") {
9275                 floating = lower2;
9276                 lower2 = undefined2;
9277               }
9278             }
9279             if (lower2 === undefined2 && upper === undefined2) {
9280               lower2 = 0;
9281               upper = 1;
9282             } else {
9283               lower2 = toFinite(lower2);
9284               if (upper === undefined2) {
9285                 upper = lower2;
9286                 lower2 = 0;
9287               } else {
9288                 upper = toFinite(upper);
9289               }
9290             }
9291             if (lower2 > upper) {
9292               var temp = lower2;
9293               lower2 = upper;
9294               upper = temp;
9295             }
9296             if (floating || lower2 % 1 || upper % 1) {
9297               var rand = nativeRandom();
9298               return nativeMin2(lower2 + rand * (upper - lower2 + freeParseFloat("1e-" + ((rand + "").length - 1))), upper);
9299             }
9300             return baseRandom(lower2, upper);
9301           }
9302           var camelCase = createCompounder(function(result2, word, index) {
9303             word = word.toLowerCase();
9304             return result2 + (index ? capitalize(word) : word);
9305           });
9306           function capitalize(string) {
9307             return upperFirst(toString2(string).toLowerCase());
9308           }
9309           function deburr(string) {
9310             string = toString2(string);
9311             return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
9312           }
9313           function endsWith(string, target, position) {
9314             string = toString2(string);
9315             target = baseToString2(target);
9316             var length2 = string.length;
9317             position = position === undefined2 ? length2 : baseClamp(toInteger(position), 0, length2);
9318             var end = position;
9319             position -= target.length;
9320             return position >= 0 && string.slice(position, end) == target;
9321           }
9322           function escape6(string) {
9323             string = toString2(string);
9324             return string && reHasUnescapedHtml2.test(string) ? string.replace(reUnescapedHtml2, escapeHtmlChar2) : string;
9325           }
9326           function escapeRegExp(string) {
9327             string = toString2(string);
9328             return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar2, "\\$&") : string;
9329           }
9330           var kebabCase = createCompounder(function(result2, word, index) {
9331             return result2 + (index ? "-" : "") + word.toLowerCase();
9332           });
9333           var lowerCase = createCompounder(function(result2, word, index) {
9334             return result2 + (index ? " " : "") + word.toLowerCase();
9335           });
9336           var lowerFirst = createCaseFirst("toLowerCase");
9337           function pad2(string, length2, chars) {
9338             string = toString2(string);
9339             length2 = toInteger(length2);
9340             var strLength = length2 ? stringSize(string) : 0;
9341             if (!length2 || strLength >= length2) {
9342               return string;
9343             }
9344             var mid = (length2 - strLength) / 2;
9345             return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil(mid), chars);
9346           }
9347           function padEnd(string, length2, chars) {
9348             string = toString2(string);
9349             length2 = toInteger(length2);
9350             var strLength = length2 ? stringSize(string) : 0;
9351             return length2 && strLength < length2 ? string + createPadding(length2 - strLength, chars) : string;
9352           }
9353           function padStart(string, length2, chars) {
9354             string = toString2(string);
9355             length2 = toInteger(length2);
9356             var strLength = length2 ? stringSize(string) : 0;
9357             return length2 && strLength < length2 ? createPadding(length2 - strLength, chars) + string : string;
9358           }
9359           function parseInt2(string, radix, guard) {
9360             if (guard || radix == null) {
9361               radix = 0;
9362             } else if (radix) {
9363               radix = +radix;
9364             }
9365             return nativeParseInt(toString2(string).replace(reTrimStart2, ""), radix || 0);
9366           }
9367           function repeat(string, n3, guard) {
9368             if (guard ? isIterateeCall(string, n3, guard) : n3 === undefined2) {
9369               n3 = 1;
9370             } else {
9371               n3 = toInteger(n3);
9372             }
9373             return baseRepeat(toString2(string), n3);
9374           }
9375           function replace() {
9376             var args = arguments, string = toString2(args[0]);
9377             return args.length < 3 ? string : string.replace(args[1], args[2]);
9378           }
9379           var snakeCase = createCompounder(function(result2, word, index) {
9380             return result2 + (index ? "_" : "") + word.toLowerCase();
9381           });
9382           function split(string, separator, limit) {
9383             if (limit && typeof limit != "number" && isIterateeCall(string, separator, limit)) {
9384               separator = limit = undefined2;
9385             }
9386             limit = limit === undefined2 ? MAX_ARRAY_LENGTH : limit >>> 0;
9387             if (!limit) {
9388               return [];
9389             }
9390             string = toString2(string);
9391             if (string && (typeof separator == "string" || separator != null && !isRegExp(separator))) {
9392               separator = baseToString2(separator);
9393               if (!separator && hasUnicode(string)) {
9394                 return castSlice(stringToArray(string), 0, limit);
9395               }
9396             }
9397             return string.split(separator, limit);
9398           }
9399           var startCase = createCompounder(function(result2, word, index) {
9400             return result2 + (index ? " " : "") + upperFirst(word);
9401           });
9402           function startsWith(string, target, position) {
9403             string = toString2(string);
9404             position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length);
9405             target = baseToString2(target);
9406             return string.slice(position, position + target.length) == target;
9407           }
9408           function template(string, options2, guard) {
9409             var settings = lodash.templateSettings;
9410             if (guard && isIterateeCall(string, options2, guard)) {
9411               options2 = undefined2;
9412             }
9413             string = toString2(string);
9414             options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
9415             var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys2(imports), importsValues = baseValues(imports, importsKeys);
9416             var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
9417             var reDelimiters = RegExp2(
9418               (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
9419               "g"
9420             );
9421             var sourceURL = "//# sourceURL=" + (hasOwnProperty10.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
9422             string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
9423               interpolateValue || (interpolateValue = esTemplateValue);
9424               source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
9425               if (escapeValue) {
9426                 isEscaping = true;
9427                 source += "' +\n__e(" + escapeValue + ") +\n'";
9428               }
9429               if (evaluateValue) {
9430                 isEvaluating = true;
9431                 source += "';\n" + evaluateValue + ";\n__p += '";
9432               }
9433               if (interpolateValue) {
9434                 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
9435               }
9436               index = offset + match.length;
9437               return match;
9438             });
9439             source += "';\n";
9440             var variable = hasOwnProperty10.call(options2, "variable") && options2.variable;
9441             if (!variable) {
9442               source = "with (obj) {\n" + source + "\n}\n";
9443             } else if (reForbiddenIdentifierChars.test(variable)) {
9444               throw new Error2(INVALID_TEMPL_VAR_ERROR_TEXT);
9445             }
9446             source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;");
9447             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}";
9448             var result2 = attempt(function() {
9449               return Function2(importsKeys, sourceURL + "return " + source).apply(undefined2, importsValues);
9450             });
9451             result2.source = source;
9452             if (isError(result2)) {
9453               throw result2;
9454             }
9455             return result2;
9456           }
9457           function toLower(value) {
9458             return toString2(value).toLowerCase();
9459           }
9460           function toUpper(value) {
9461             return toString2(value).toUpperCase();
9462           }
9463           function trim(string, chars, guard) {
9464             string = toString2(string);
9465             if (string && (guard || chars === undefined2)) {
9466               return baseTrim2(string);
9467             }
9468             if (!string || !(chars = baseToString2(chars))) {
9469               return string;
9470             }
9471             var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars), start2 = charsStartIndex(strSymbols, chrSymbols), end = charsEndIndex(strSymbols, chrSymbols) + 1;
9472             return castSlice(strSymbols, start2, end).join("");
9473           }
9474           function trimEnd(string, chars, guard) {
9475             string = toString2(string);
9476             if (string && (guard || chars === undefined2)) {
9477               return string.slice(0, trimmedEndIndex2(string) + 1);
9478             }
9479             if (!string || !(chars = baseToString2(chars))) {
9480               return string;
9481             }
9482             var strSymbols = stringToArray(string), end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
9483             return castSlice(strSymbols, 0, end).join("");
9484           }
9485           function trimStart(string, chars, guard) {
9486             string = toString2(string);
9487             if (string && (guard || chars === undefined2)) {
9488               return string.replace(reTrimStart2, "");
9489             }
9490             if (!string || !(chars = baseToString2(chars))) {
9491               return string;
9492             }
9493             var strSymbols = stringToArray(string), start2 = charsStartIndex(strSymbols, stringToArray(chars));
9494             return castSlice(strSymbols, start2).join("");
9495           }
9496           function truncate(string, options2) {
9497             var length2 = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
9498             if (isObject3(options2)) {
9499               var separator = "separator" in options2 ? options2.separator : separator;
9500               length2 = "length" in options2 ? toInteger(options2.length) : length2;
9501               omission = "omission" in options2 ? baseToString2(options2.omission) : omission;
9502             }
9503             string = toString2(string);
9504             var strLength = string.length;
9505             if (hasUnicode(string)) {
9506               var strSymbols = stringToArray(string);
9507               strLength = strSymbols.length;
9508             }
9509             if (length2 >= strLength) {
9510               return string;
9511             }
9512             var end = length2 - stringSize(omission);
9513             if (end < 1) {
9514               return omission;
9515             }
9516             var result2 = strSymbols ? castSlice(strSymbols, 0, end).join("") : string.slice(0, end);
9517             if (separator === undefined2) {
9518               return result2 + omission;
9519             }
9520             if (strSymbols) {
9521               end += result2.length - end;
9522             }
9523             if (isRegExp(separator)) {
9524               if (string.slice(end).search(separator)) {
9525                 var match, substring = result2;
9526                 if (!separator.global) {
9527                   separator = RegExp2(separator.source, toString2(reFlags.exec(separator)) + "g");
9528                 }
9529                 separator.lastIndex = 0;
9530                 while (match = separator.exec(substring)) {
9531                   var newEnd = match.index;
9532                 }
9533                 result2 = result2.slice(0, newEnd === undefined2 ? end : newEnd);
9534               }
9535             } else if (string.indexOf(baseToString2(separator), end) != end) {
9536               var index = result2.lastIndexOf(separator);
9537               if (index > -1) {
9538                 result2 = result2.slice(0, index);
9539               }
9540             }
9541             return result2 + omission;
9542           }
9543           function unescape3(string) {
9544             string = toString2(string);
9545             return string && reHasEscapedHtml2.test(string) ? string.replace(reEscapedHtml2, unescapeHtmlChar2) : string;
9546           }
9547           var upperCase = createCompounder(function(result2, word, index) {
9548             return result2 + (index ? " " : "") + word.toUpperCase();
9549           });
9550           var upperFirst = createCaseFirst("toUpperCase");
9551           function words(string, pattern, guard) {
9552             string = toString2(string);
9553             pattern = guard ? undefined2 : pattern;
9554             if (pattern === undefined2) {
9555               return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
9556             }
9557             return string.match(pattern) || [];
9558           }
9559           var attempt = baseRest(function(func, args) {
9560             try {
9561               return apply(func, undefined2, args);
9562             } catch (e3) {
9563               return isError(e3) ? e3 : new Error2(e3);
9564             }
9565           });
9566           var bindAll = flatRest(function(object, methodNames) {
9567             arrayEach(methodNames, function(key) {
9568               key = toKey(key);
9569               baseAssignValue(object, key, bind(object[key], object));
9570             });
9571             return object;
9572           });
9573           function cond(pairs2) {
9574             var length2 = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee();
9575             pairs2 = !length2 ? [] : arrayMap2(pairs2, function(pair3) {
9576               if (typeof pair3[1] != "function") {
9577                 throw new TypeError2(FUNC_ERROR_TEXT3);
9578               }
9579               return [toIteratee(pair3[0]), pair3[1]];
9580             });
9581             return baseRest(function(args) {
9582               var index = -1;
9583               while (++index < length2) {
9584                 var pair3 = pairs2[index];
9585                 if (apply(pair3[0], this, args)) {
9586                   return apply(pair3[1], this, args);
9587                 }
9588               }
9589             });
9590           }
9591           function conforms(source) {
9592             return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
9593           }
9594           function constant(value) {
9595             return function() {
9596               return value;
9597             };
9598           }
9599           function defaultTo(value, defaultValue) {
9600             return value == null || value !== value ? defaultValue : value;
9601           }
9602           var flow = createFlow();
9603           var flowRight = createFlow(true);
9604           function identity4(value) {
9605             return value;
9606           }
9607           function iteratee(func) {
9608             return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
9609           }
9610           function matches(source) {
9611             return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
9612           }
9613           function matchesProperty(path, srcValue) {
9614             return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
9615           }
9616           var method = baseRest(function(path, args) {
9617             return function(object) {
9618               return baseInvoke(object, path, args);
9619             };
9620           });
9621           var methodOf = baseRest(function(object, args) {
9622             return function(path) {
9623               return baseInvoke(object, path, args);
9624             };
9625           });
9626           function mixin(object, source, options2) {
9627             var props = keys2(source), methodNames = baseFunctions(source, props);
9628             if (options2 == null && !(isObject3(source) && (methodNames.length || !props.length))) {
9629               options2 = source;
9630               source = object;
9631               object = this;
9632               methodNames = baseFunctions(source, keys2(source));
9633             }
9634             var chain2 = !(isObject3(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction2(object);
9635             arrayEach(methodNames, function(methodName) {
9636               var func = source[methodName];
9637               object[methodName] = func;
9638               if (isFunc) {
9639                 object.prototype[methodName] = function() {
9640                   var chainAll = this.__chain__;
9641                   if (chain2 || chainAll) {
9642                     var result2 = object(this.__wrapped__), actions = result2.__actions__ = copyArray(this.__actions__);
9643                     actions.push({ "func": func, "args": arguments, "thisArg": object });
9644                     result2.__chain__ = chainAll;
9645                     return result2;
9646                   }
9647                   return func.apply(object, arrayPush2([this.value()], arguments));
9648                 };
9649               }
9650             });
9651             return object;
9652           }
9653           function noConflict() {
9654             if (root3._ === this) {
9655               root3._ = oldDash;
9656             }
9657             return this;
9658           }
9659           function noop3() {
9660           }
9661           function nthArg(n3) {
9662             n3 = toInteger(n3);
9663             return baseRest(function(args) {
9664               return baseNth(args, n3);
9665             });
9666           }
9667           var over = createOver(arrayMap2);
9668           var overEvery = createOver(arrayEvery);
9669           var overSome = createOver(arraySome2);
9670           function property(path) {
9671             return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
9672           }
9673           function propertyOf(object) {
9674             return function(path) {
9675               return object == null ? undefined2 : baseGet(object, path);
9676             };
9677           }
9678           var range3 = createRange();
9679           var rangeRight = createRange(true);
9680           function stubArray2() {
9681             return [];
9682           }
9683           function stubFalse2() {
9684             return false;
9685           }
9686           function stubObject() {
9687             return {};
9688           }
9689           function stubString() {
9690             return "";
9691           }
9692           function stubTrue() {
9693             return true;
9694           }
9695           function times(n3, iteratee2) {
9696             n3 = toInteger(n3);
9697             if (n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
9698               return [];
9699             }
9700             var index = MAX_ARRAY_LENGTH, length2 = nativeMin2(n3, MAX_ARRAY_LENGTH);
9701             iteratee2 = getIteratee(iteratee2);
9702             n3 -= MAX_ARRAY_LENGTH;
9703             var result2 = baseTimes2(length2, iteratee2);
9704             while (++index < n3) {
9705               iteratee2(index);
9706             }
9707             return result2;
9708           }
9709           function toPath(value) {
9710             if (isArray2(value)) {
9711               return arrayMap2(value, toKey);
9712             }
9713             return isSymbol2(value) ? [value] : copyArray(stringToPath(toString2(value)));
9714           }
9715           function uniqueId(prefix) {
9716             var id2 = ++idCounter;
9717             return toString2(prefix) + id2;
9718           }
9719           var add = createMathOperation(function(augend, addend) {
9720             return augend + addend;
9721           }, 0);
9722           var ceil = createRound("ceil");
9723           var divide = createMathOperation(function(dividend, divisor) {
9724             return dividend / divisor;
9725           }, 1);
9726           var floor = createRound("floor");
9727           function max3(array2) {
9728             return array2 && array2.length ? baseExtremum(array2, identity4, baseGt) : undefined2;
9729           }
9730           function maxBy(array2, iteratee2) {
9731             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseGt) : undefined2;
9732           }
9733           function mean(array2) {
9734             return baseMean(array2, identity4);
9735           }
9736           function meanBy(array2, iteratee2) {
9737             return baseMean(array2, getIteratee(iteratee2, 2));
9738           }
9739           function min3(array2) {
9740             return array2 && array2.length ? baseExtremum(array2, identity4, baseLt) : undefined2;
9741           }
9742           function minBy(array2, iteratee2) {
9743             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseLt) : undefined2;
9744           }
9745           var multiply = createMathOperation(function(multiplier, multiplicand) {
9746             return multiplier * multiplicand;
9747           }, 1);
9748           var round = createRound("round");
9749           var subtract = createMathOperation(function(minuend, subtrahend) {
9750             return minuend - subtrahend;
9751           }, 0);
9752           function sum(array2) {
9753             return array2 && array2.length ? baseSum(array2, identity4) : 0;
9754           }
9755           function sumBy(array2, iteratee2) {
9756             return array2 && array2.length ? baseSum(array2, getIteratee(iteratee2, 2)) : 0;
9757           }
9758           lodash.after = after;
9759           lodash.ary = ary;
9760           lodash.assign = assign;
9761           lodash.assignIn = assignIn;
9762           lodash.assignInWith = assignInWith;
9763           lodash.assignWith = assignWith;
9764           lodash.at = at2;
9765           lodash.before = before;
9766           lodash.bind = bind;
9767           lodash.bindAll = bindAll;
9768           lodash.bindKey = bindKey2;
9769           lodash.castArray = castArray;
9770           lodash.chain = chain;
9771           lodash.chunk = chunk;
9772           lodash.compact = compact;
9773           lodash.concat = concat;
9774           lodash.cond = cond;
9775           lodash.conforms = conforms;
9776           lodash.constant = constant;
9777           lodash.countBy = countBy;
9778           lodash.create = create2;
9779           lodash.curry = curry;
9780           lodash.curryRight = curryRight;
9781           lodash.debounce = debounce2;
9782           lodash.defaults = defaults;
9783           lodash.defaultsDeep = defaultsDeep;
9784           lodash.defer = defer;
9785           lodash.delay = delay;
9786           lodash.difference = difference2;
9787           lodash.differenceBy = differenceBy;
9788           lodash.differenceWith = differenceWith;
9789           lodash.drop = drop;
9790           lodash.dropRight = dropRight;
9791           lodash.dropRightWhile = dropRightWhile;
9792           lodash.dropWhile = dropWhile;
9793           lodash.fill = fill;
9794           lodash.filter = filter2;
9795           lodash.flatMap = flatMap;
9796           lodash.flatMapDeep = flatMapDeep;
9797           lodash.flatMapDepth = flatMapDepth;
9798           lodash.flatten = flatten2;
9799           lodash.flattenDeep = flattenDeep;
9800           lodash.flattenDepth = flattenDepth;
9801           lodash.flip = flip;
9802           lodash.flow = flow;
9803           lodash.flowRight = flowRight;
9804           lodash.fromPairs = fromPairs;
9805           lodash.functions = functions;
9806           lodash.functionsIn = functionsIn;
9807           lodash.groupBy = groupBy;
9808           lodash.initial = initial;
9809           lodash.intersection = intersection2;
9810           lodash.intersectionBy = intersectionBy;
9811           lodash.intersectionWith = intersectionWith;
9812           lodash.invert = invert;
9813           lodash.invertBy = invertBy;
9814           lodash.invokeMap = invokeMap;
9815           lodash.iteratee = iteratee;
9816           lodash.keyBy = keyBy;
9817           lodash.keys = keys2;
9818           lodash.keysIn = keysIn;
9819           lodash.map = map2;
9820           lodash.mapKeys = mapKeys;
9821           lodash.mapValues = mapValues;
9822           lodash.matches = matches;
9823           lodash.matchesProperty = matchesProperty;
9824           lodash.memoize = memoize;
9825           lodash.merge = merge2;
9826           lodash.mergeWith = mergeWith;
9827           lodash.method = method;
9828           lodash.methodOf = methodOf;
9829           lodash.mixin = mixin;
9830           lodash.negate = negate;
9831           lodash.nthArg = nthArg;
9832           lodash.omit = omit;
9833           lodash.omitBy = omitBy;
9834           lodash.once = once;
9835           lodash.orderBy = orderBy;
9836           lodash.over = over;
9837           lodash.overArgs = overArgs;
9838           lodash.overEvery = overEvery;
9839           lodash.overSome = overSome;
9840           lodash.partial = partial;
9841           lodash.partialRight = partialRight;
9842           lodash.partition = partition;
9843           lodash.pick = pick;
9844           lodash.pickBy = pickBy;
9845           lodash.property = property;
9846           lodash.propertyOf = propertyOf;
9847           lodash.pull = pull;
9848           lodash.pullAll = pullAll;
9849           lodash.pullAllBy = pullAllBy;
9850           lodash.pullAllWith = pullAllWith;
9851           lodash.pullAt = pullAt;
9852           lodash.range = range3;
9853           lodash.rangeRight = rangeRight;
9854           lodash.rearg = rearg;
9855           lodash.reject = reject;
9856           lodash.remove = remove2;
9857           lodash.rest = rest;
9858           lodash.reverse = reverse;
9859           lodash.sampleSize = sampleSize;
9860           lodash.set = set4;
9861           lodash.setWith = setWith;
9862           lodash.shuffle = shuffle;
9863           lodash.slice = slice;
9864           lodash.sortBy = sortBy;
9865           lodash.sortedUniq = sortedUniq;
9866           lodash.sortedUniqBy = sortedUniqBy;
9867           lodash.split = split;
9868           lodash.spread = spread;
9869           lodash.tail = tail;
9870           lodash.take = take;
9871           lodash.takeRight = takeRight;
9872           lodash.takeRightWhile = takeRightWhile;
9873           lodash.takeWhile = takeWhile;
9874           lodash.tap = tap;
9875           lodash.throttle = throttle2;
9876           lodash.thru = thru;
9877           lodash.toArray = toArray;
9878           lodash.toPairs = toPairs;
9879           lodash.toPairsIn = toPairsIn;
9880           lodash.toPath = toPath;
9881           lodash.toPlainObject = toPlainObject;
9882           lodash.transform = transform2;
9883           lodash.unary = unary;
9884           lodash.union = union2;
9885           lodash.unionBy = unionBy;
9886           lodash.unionWith = unionWith;
9887           lodash.uniq = uniq;
9888           lodash.uniqBy = uniqBy;
9889           lodash.uniqWith = uniqWith;
9890           lodash.unset = unset;
9891           lodash.unzip = unzip;
9892           lodash.unzipWith = unzipWith;
9893           lodash.update = update;
9894           lodash.updateWith = updateWith;
9895           lodash.values = values;
9896           lodash.valuesIn = valuesIn;
9897           lodash.without = without;
9898           lodash.words = words;
9899           lodash.wrap = wrap2;
9900           lodash.xor = xor;
9901           lodash.xorBy = xorBy;
9902           lodash.xorWith = xorWith;
9903           lodash.zip = zip;
9904           lodash.zipObject = zipObject;
9905           lodash.zipObjectDeep = zipObjectDeep;
9906           lodash.zipWith = zipWith;
9907           lodash.entries = toPairs;
9908           lodash.entriesIn = toPairsIn;
9909           lodash.extend = assignIn;
9910           lodash.extendWith = assignInWith;
9911           mixin(lodash, lodash);
9912           lodash.add = add;
9913           lodash.attempt = attempt;
9914           lodash.camelCase = camelCase;
9915           lodash.capitalize = capitalize;
9916           lodash.ceil = ceil;
9917           lodash.clamp = clamp3;
9918           lodash.clone = clone2;
9919           lodash.cloneDeep = cloneDeep;
9920           lodash.cloneDeepWith = cloneDeepWith;
9921           lodash.cloneWith = cloneWith;
9922           lodash.conformsTo = conformsTo;
9923           lodash.deburr = deburr;
9924           lodash.defaultTo = defaultTo;
9925           lodash.divide = divide;
9926           lodash.endsWith = endsWith;
9927           lodash.eq = eq2;
9928           lodash.escape = escape6;
9929           lodash.escapeRegExp = escapeRegExp;
9930           lodash.every = every;
9931           lodash.find = find2;
9932           lodash.findIndex = findIndex;
9933           lodash.findKey = findKey;
9934           lodash.findLast = findLast;
9935           lodash.findLastIndex = findLastIndex;
9936           lodash.findLastKey = findLastKey;
9937           lodash.floor = floor;
9938           lodash.forEach = forEach;
9939           lodash.forEachRight = forEachRight;
9940           lodash.forIn = forIn;
9941           lodash.forInRight = forInRight;
9942           lodash.forOwn = forOwn;
9943           lodash.forOwnRight = forOwnRight;
9944           lodash.get = get4;
9945           lodash.gt = gt2;
9946           lodash.gte = gte;
9947           lodash.has = has;
9948           lodash.hasIn = hasIn;
9949           lodash.head = head;
9950           lodash.identity = identity4;
9951           lodash.includes = includes;
9952           lodash.indexOf = indexOf;
9953           lodash.inRange = inRange;
9954           lodash.invoke = invoke;
9955           lodash.isArguments = isArguments2;
9956           lodash.isArray = isArray2;
9957           lodash.isArrayBuffer = isArrayBuffer;
9958           lodash.isArrayLike = isArrayLike2;
9959           lodash.isArrayLikeObject = isArrayLikeObject;
9960           lodash.isBoolean = isBoolean;
9961           lodash.isBuffer = isBuffer2;
9962           lodash.isDate = isDate;
9963           lodash.isElement = isElement2;
9964           lodash.isEmpty = isEmpty;
9965           lodash.isEqual = isEqual4;
9966           lodash.isEqualWith = isEqualWith;
9967           lodash.isError = isError;
9968           lodash.isFinite = isFinite2;
9969           lodash.isFunction = isFunction2;
9970           lodash.isInteger = isInteger;
9971           lodash.isLength = isLength2;
9972           lodash.isMap = isMap;
9973           lodash.isMatch = isMatch;
9974           lodash.isMatchWith = isMatchWith;
9975           lodash.isNaN = isNaN2;
9976           lodash.isNative = isNative;
9977           lodash.isNil = isNil;
9978           lodash.isNull = isNull;
9979           lodash.isNumber = isNumber3;
9980           lodash.isObject = isObject3;
9981           lodash.isObjectLike = isObjectLike2;
9982           lodash.isPlainObject = isPlainObject;
9983           lodash.isRegExp = isRegExp;
9984           lodash.isSafeInteger = isSafeInteger;
9985           lodash.isSet = isSet;
9986           lodash.isString = isString;
9987           lodash.isSymbol = isSymbol2;
9988           lodash.isTypedArray = isTypedArray2;
9989           lodash.isUndefined = isUndefined;
9990           lodash.isWeakMap = isWeakMap;
9991           lodash.isWeakSet = isWeakSet;
9992           lodash.join = join;
9993           lodash.kebabCase = kebabCase;
9994           lodash.last = last;
9995           lodash.lastIndexOf = lastIndexOf;
9996           lodash.lowerCase = lowerCase;
9997           lodash.lowerFirst = lowerFirst;
9998           lodash.lt = lt2;
9999           lodash.lte = lte;
10000           lodash.max = max3;
10001           lodash.maxBy = maxBy;
10002           lodash.mean = mean;
10003           lodash.meanBy = meanBy;
10004           lodash.min = min3;
10005           lodash.minBy = minBy;
10006           lodash.stubArray = stubArray2;
10007           lodash.stubFalse = stubFalse2;
10008           lodash.stubObject = stubObject;
10009           lodash.stubString = stubString;
10010           lodash.stubTrue = stubTrue;
10011           lodash.multiply = multiply;
10012           lodash.nth = nth;
10013           lodash.noConflict = noConflict;
10014           lodash.noop = noop3;
10015           lodash.now = now3;
10016           lodash.pad = pad2;
10017           lodash.padEnd = padEnd;
10018           lodash.padStart = padStart;
10019           lodash.parseInt = parseInt2;
10020           lodash.random = random;
10021           lodash.reduce = reduce;
10022           lodash.reduceRight = reduceRight;
10023           lodash.repeat = repeat;
10024           lodash.replace = replace;
10025           lodash.result = result;
10026           lodash.round = round;
10027           lodash.runInContext = runInContext2;
10028           lodash.sample = sample;
10029           lodash.size = size;
10030           lodash.snakeCase = snakeCase;
10031           lodash.some = some;
10032           lodash.sortedIndex = sortedIndex;
10033           lodash.sortedIndexBy = sortedIndexBy;
10034           lodash.sortedIndexOf = sortedIndexOf;
10035           lodash.sortedLastIndex = sortedLastIndex;
10036           lodash.sortedLastIndexBy = sortedLastIndexBy;
10037           lodash.sortedLastIndexOf = sortedLastIndexOf;
10038           lodash.startCase = startCase;
10039           lodash.startsWith = startsWith;
10040           lodash.subtract = subtract;
10041           lodash.sum = sum;
10042           lodash.sumBy = sumBy;
10043           lodash.template = template;
10044           lodash.times = times;
10045           lodash.toFinite = toFinite;
10046           lodash.toInteger = toInteger;
10047           lodash.toLength = toLength;
10048           lodash.toLower = toLower;
10049           lodash.toNumber = toNumber3;
10050           lodash.toSafeInteger = toSafeInteger;
10051           lodash.toString = toString2;
10052           lodash.toUpper = toUpper;
10053           lodash.trim = trim;
10054           lodash.trimEnd = trimEnd;
10055           lodash.trimStart = trimStart;
10056           lodash.truncate = truncate;
10057           lodash.unescape = unescape3;
10058           lodash.uniqueId = uniqueId;
10059           lodash.upperCase = upperCase;
10060           lodash.upperFirst = upperFirst;
10061           lodash.each = forEach;
10062           lodash.eachRight = forEachRight;
10063           lodash.first = head;
10064           mixin(lodash, function() {
10065             var source = {};
10066             baseForOwn(lodash, function(func, methodName) {
10067               if (!hasOwnProperty10.call(lodash.prototype, methodName)) {
10068                 source[methodName] = func;
10069               }
10070             });
10071             return source;
10072           }(), { "chain": false });
10073           lodash.VERSION = VERSION;
10074           arrayEach(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(methodName) {
10075             lodash[methodName].placeholder = lodash;
10076           });
10077           arrayEach(["drop", "take"], function(methodName, index) {
10078             LazyWrapper.prototype[methodName] = function(n3) {
10079               n3 = n3 === undefined2 ? 1 : nativeMax2(toInteger(n3), 0);
10080               var result2 = this.__filtered__ && !index ? new LazyWrapper(this) : this.clone();
10081               if (result2.__filtered__) {
10082                 result2.__takeCount__ = nativeMin2(n3, result2.__takeCount__);
10083               } else {
10084                 result2.__views__.push({
10085                   "size": nativeMin2(n3, MAX_ARRAY_LENGTH),
10086                   "type": methodName + (result2.__dir__ < 0 ? "Right" : "")
10087                 });
10088               }
10089               return result2;
10090             };
10091             LazyWrapper.prototype[methodName + "Right"] = function(n3) {
10092               return this.reverse()[methodName](n3).reverse();
10093             };
10094           });
10095           arrayEach(["filter", "map", "takeWhile"], function(methodName, index) {
10096             var type2 = index + 1, isFilter = type2 == LAZY_FILTER_FLAG || type2 == LAZY_WHILE_FLAG;
10097             LazyWrapper.prototype[methodName] = function(iteratee2) {
10098               var result2 = this.clone();
10099               result2.__iteratees__.push({
10100                 "iteratee": getIteratee(iteratee2, 3),
10101                 "type": type2
10102               });
10103               result2.__filtered__ = result2.__filtered__ || isFilter;
10104               return result2;
10105             };
10106           });
10107           arrayEach(["head", "last"], function(methodName, index) {
10108             var takeName = "take" + (index ? "Right" : "");
10109             LazyWrapper.prototype[methodName] = function() {
10110               return this[takeName](1).value()[0];
10111             };
10112           });
10113           arrayEach(["initial", "tail"], function(methodName, index) {
10114             var dropName = "drop" + (index ? "" : "Right");
10115             LazyWrapper.prototype[methodName] = function() {
10116               return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
10117             };
10118           });
10119           LazyWrapper.prototype.compact = function() {
10120             return this.filter(identity4);
10121           };
10122           LazyWrapper.prototype.find = function(predicate) {
10123             return this.filter(predicate).head();
10124           };
10125           LazyWrapper.prototype.findLast = function(predicate) {
10126             return this.reverse().find(predicate);
10127           };
10128           LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
10129             if (typeof path == "function") {
10130               return new LazyWrapper(this);
10131             }
10132             return this.map(function(value) {
10133               return baseInvoke(value, path, args);
10134             });
10135           });
10136           LazyWrapper.prototype.reject = function(predicate) {
10137             return this.filter(negate(getIteratee(predicate)));
10138           };
10139           LazyWrapper.prototype.slice = function(start2, end) {
10140             start2 = toInteger(start2);
10141             var result2 = this;
10142             if (result2.__filtered__ && (start2 > 0 || end < 0)) {
10143               return new LazyWrapper(result2);
10144             }
10145             if (start2 < 0) {
10146               result2 = result2.takeRight(-start2);
10147             } else if (start2) {
10148               result2 = result2.drop(start2);
10149             }
10150             if (end !== undefined2) {
10151               end = toInteger(end);
10152               result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start2);
10153             }
10154             return result2;
10155           };
10156           LazyWrapper.prototype.takeRightWhile = function(predicate) {
10157             return this.reverse().takeWhile(predicate).reverse();
10158           };
10159           LazyWrapper.prototype.toArray = function() {
10160             return this.take(MAX_ARRAY_LENGTH);
10161           };
10162           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
10163             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);
10164             if (!lodashFunc) {
10165               return;
10166             }
10167             lodash.prototype[methodName] = function() {
10168               var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
10169               var interceptor = function(value2) {
10170                 var result3 = lodashFunc.apply(lodash, arrayPush2([value2], args));
10171                 return isTaker && chainAll ? result3[0] : result3;
10172               };
10173               if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
10174                 isLazy = useLazy = false;
10175               }
10176               var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
10177               if (!retUnwrapped && useLazy) {
10178                 value = onlyLazy ? value : new LazyWrapper(this);
10179                 var result2 = func.apply(value, args);
10180                 result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined2 });
10181                 return new LodashWrapper(result2, chainAll);
10182               }
10183               if (isUnwrapped && onlyLazy) {
10184                 return func.apply(this, args);
10185               }
10186               result2 = this.thru(interceptor);
10187               return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
10188             };
10189           });
10190           arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
10191             var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
10192             lodash.prototype[methodName] = function() {
10193               var args = arguments;
10194               if (retUnwrapped && !this.__chain__) {
10195                 var value = this.value();
10196                 return func.apply(isArray2(value) ? value : [], args);
10197               }
10198               return this[chainName](function(value2) {
10199                 return func.apply(isArray2(value2) ? value2 : [], args);
10200               });
10201             };
10202           });
10203           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
10204             var lodashFunc = lodash[methodName];
10205             if (lodashFunc) {
10206               var key = lodashFunc.name + "";
10207               if (!hasOwnProperty10.call(realNames, key)) {
10208                 realNames[key] = [];
10209               }
10210               realNames[key].push({ "name": methodName, "func": lodashFunc });
10211             }
10212           });
10213           realNames[createHybrid(undefined2, WRAP_BIND_KEY_FLAG).name] = [{
10214             "name": "wrapper",
10215             "func": undefined2
10216           }];
10217           LazyWrapper.prototype.clone = lazyClone;
10218           LazyWrapper.prototype.reverse = lazyReverse;
10219           LazyWrapper.prototype.value = lazyValue;
10220           lodash.prototype.at = wrapperAt;
10221           lodash.prototype.chain = wrapperChain;
10222           lodash.prototype.commit = wrapperCommit;
10223           lodash.prototype.next = wrapperNext;
10224           lodash.prototype.plant = wrapperPlant;
10225           lodash.prototype.reverse = wrapperReverse;
10226           lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
10227           lodash.prototype.first = lodash.prototype.head;
10228           if (symIterator) {
10229             lodash.prototype[symIterator] = wrapperToIterator;
10230           }
10231           return lodash;
10232         };
10233         var _2 = runInContext();
10234         if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
10235           root3._ = _2;
10236           define(function() {
10237             return _2;
10238           });
10239         } else if (freeModule3) {
10240           (freeModule3.exports = _2)._ = _2;
10241           freeExports3._ = _2;
10242         } else {
10243           root3._ = _2;
10244         }
10245       }).call(exports2);
10246     }
10247   });
10248
10249   // node_modules/fast-deep-equal/index.js
10250   var require_fast_deep_equal = __commonJS({
10251     "node_modules/fast-deep-equal/index.js"(exports2, module2) {
10252       "use strict";
10253       module2.exports = function equal(a2, b2) {
10254         if (a2 === b2)
10255           return true;
10256         if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
10257           if (a2.constructor !== b2.constructor)
10258             return false;
10259           var length2, i3, keys2;
10260           if (Array.isArray(a2)) {
10261             length2 = a2.length;
10262             if (length2 != b2.length)
10263               return false;
10264             for (i3 = length2; i3-- !== 0; )
10265               if (!equal(a2[i3], b2[i3]))
10266                 return false;
10267             return true;
10268           }
10269           if (a2.constructor === RegExp)
10270             return a2.source === b2.source && a2.flags === b2.flags;
10271           if (a2.valueOf !== Object.prototype.valueOf)
10272             return a2.valueOf() === b2.valueOf();
10273           if (a2.toString !== Object.prototype.toString)
10274             return a2.toString() === b2.toString();
10275           keys2 = Object.keys(a2);
10276           length2 = keys2.length;
10277           if (length2 !== Object.keys(b2).length)
10278             return false;
10279           for (i3 = length2; i3-- !== 0; )
10280             if (!Object.prototype.hasOwnProperty.call(b2, keys2[i3]))
10281               return false;
10282           for (i3 = length2; i3-- !== 0; ) {
10283             var key = keys2[i3];
10284             if (!equal(a2[key], b2[key]))
10285               return false;
10286           }
10287           return true;
10288         }
10289         return a2 !== a2 && b2 !== b2;
10290       };
10291     }
10292   });
10293
10294   // node_modules/rbush/rbush.min.js
10295   var require_rbush_min = __commonJS({
10296     "node_modules/rbush/rbush.min.js"(exports2, module2) {
10297       !function(t2, i3) {
10298         "object" == typeof exports2 && "undefined" != typeof module2 ? module2.exports = i3() : "function" == typeof define && define.amd ? define(i3) : (t2 = t2 || self).RBush = i3();
10299       }(exports2, function() {
10300         "use strict";
10301         function t2(t3, r3, e4, a3, h3) {
10302           !function t4(n4, r4, e6, a4, h4) {
10303             for (; a4 > e6; ) {
10304               if (a4 - e6 > 600) {
10305                 var o3 = a4 - e6 + 1, s3 = r4 - e6 + 1, l3 = Math.log(o3), f3 = 0.5 * Math.exp(2 * l3 / 3), u3 = 0.5 * Math.sqrt(l3 * f3 * (o3 - f3) / o3) * (s3 - o3 / 2 < 0 ? -1 : 1), m3 = Math.max(e6, Math.floor(r4 - s3 * f3 / o3 + u3)), c3 = Math.min(a4, Math.floor(r4 + (o3 - s3) * f3 / o3 + u3));
10306                 t4(n4, r4, m3, c3, h4);
10307               }
10308               var p3 = n4[r4], d4 = e6, x2 = a4;
10309               for (i3(n4, e6, r4), h4(n4[a4], p3) > 0 && i3(n4, e6, a4); d4 < x2; ) {
10310                 for (i3(n4, d4, x2), d4++, x2--; h4(n4[d4], p3) < 0; )
10311                   d4++;
10312                 for (; h4(n4[x2], p3) > 0; )
10313                   x2--;
10314               }
10315               0 === h4(n4[e6], p3) ? i3(n4, e6, x2) : i3(n4, ++x2, a4), x2 <= r4 && (e6 = x2 + 1), r4 <= x2 && (a4 = x2 - 1);
10316             }
10317           }(t3, r3, e4 || 0, a3 || t3.length - 1, h3 || n3);
10318         }
10319         function i3(t3, i4, n4) {
10320           var r3 = t3[i4];
10321           t3[i4] = t3[n4], t3[n4] = r3;
10322         }
10323         function n3(t3, i4) {
10324           return t3 < i4 ? -1 : t3 > i4 ? 1 : 0;
10325         }
10326         var r2 = function(t3) {
10327           void 0 === t3 && (t3 = 9), this._maxEntries = Math.max(4, t3), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
10328         };
10329         function e3(t3, i4, n4) {
10330           if (!n4)
10331             return i4.indexOf(t3);
10332           for (var r3 = 0; r3 < i4.length; r3++)
10333             if (n4(t3, i4[r3]))
10334               return r3;
10335           return -1;
10336         }
10337         function a2(t3, i4) {
10338           h2(t3, 0, t3.children.length, i4, t3);
10339         }
10340         function h2(t3, i4, n4, r3, e4) {
10341           e4 || (e4 = p2(null)), e4.minX = 1 / 0, e4.minY = 1 / 0, e4.maxX = -1 / 0, e4.maxY = -1 / 0;
10342           for (var a3 = i4; a3 < n4; a3++) {
10343             var h3 = t3.children[a3];
10344             o2(e4, t3.leaf ? r3(h3) : h3);
10345           }
10346           return e4;
10347         }
10348         function o2(t3, i4) {
10349           return t3.minX = Math.min(t3.minX, i4.minX), t3.minY = Math.min(t3.minY, i4.minY), t3.maxX = Math.max(t3.maxX, i4.maxX), t3.maxY = Math.max(t3.maxY, i4.maxY), t3;
10350         }
10351         function s2(t3, i4) {
10352           return t3.minX - i4.minX;
10353         }
10354         function l2(t3, i4) {
10355           return t3.minY - i4.minY;
10356         }
10357         function f2(t3) {
10358           return (t3.maxX - t3.minX) * (t3.maxY - t3.minY);
10359         }
10360         function u2(t3) {
10361           return t3.maxX - t3.minX + (t3.maxY - t3.minY);
10362         }
10363         function m2(t3, i4) {
10364           return t3.minX <= i4.minX && t3.minY <= i4.minY && i4.maxX <= t3.maxX && i4.maxY <= t3.maxY;
10365         }
10366         function c2(t3, i4) {
10367           return i4.minX <= t3.maxX && i4.minY <= t3.maxY && i4.maxX >= t3.minX && i4.maxY >= t3.minY;
10368         }
10369         function p2(t3) {
10370           return { children: t3, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
10371         }
10372         function d2(i4, n4, r3, e4, a3) {
10373           for (var h3 = [n4, r3]; h3.length; )
10374             if (!((r3 = h3.pop()) - (n4 = h3.pop()) <= e4)) {
10375               var o3 = n4 + Math.ceil((r3 - n4) / e4 / 2) * e4;
10376               t2(i4, o3, n4, r3, a3), h3.push(n4, o3, o3, r3);
10377             }
10378         }
10379         return r2.prototype.all = function() {
10380           return this._all(this.data, []);
10381         }, r2.prototype.search = function(t3) {
10382           var i4 = this.data, n4 = [];
10383           if (!c2(t3, i4))
10384             return n4;
10385           for (var r3 = this.toBBox, e4 = []; i4; ) {
10386             for (var a3 = 0; a3 < i4.children.length; a3++) {
10387               var h3 = i4.children[a3], o3 = i4.leaf ? r3(h3) : h3;
10388               c2(t3, o3) && (i4.leaf ? n4.push(h3) : m2(t3, o3) ? this._all(h3, n4) : e4.push(h3));
10389             }
10390             i4 = e4.pop();
10391           }
10392           return n4;
10393         }, r2.prototype.collides = function(t3) {
10394           var i4 = this.data;
10395           if (!c2(t3, i4))
10396             return false;
10397           for (var n4 = []; i4; ) {
10398             for (var r3 = 0; r3 < i4.children.length; r3++) {
10399               var e4 = i4.children[r3], a3 = i4.leaf ? this.toBBox(e4) : e4;
10400               if (c2(t3, a3)) {
10401                 if (i4.leaf || m2(t3, a3))
10402                   return true;
10403                 n4.push(e4);
10404               }
10405             }
10406             i4 = n4.pop();
10407           }
10408           return false;
10409         }, r2.prototype.load = function(t3) {
10410           if (!t3 || !t3.length)
10411             return this;
10412           if (t3.length < this._minEntries) {
10413             for (var i4 = 0; i4 < t3.length; i4++)
10414               this.insert(t3[i4]);
10415             return this;
10416           }
10417           var n4 = this._build(t3.slice(), 0, t3.length - 1, 0);
10418           if (this.data.children.length)
10419             if (this.data.height === n4.height)
10420               this._splitRoot(this.data, n4);
10421             else {
10422               if (this.data.height < n4.height) {
10423                 var r3 = this.data;
10424                 this.data = n4, n4 = r3;
10425               }
10426               this._insert(n4, this.data.height - n4.height - 1, true);
10427             }
10428           else
10429             this.data = n4;
10430           return this;
10431         }, r2.prototype.insert = function(t3) {
10432           return t3 && this._insert(t3, this.data.height - 1), this;
10433         }, r2.prototype.clear = function() {
10434           return this.data = p2([]), this;
10435         }, r2.prototype.remove = function(t3, i4) {
10436           if (!t3)
10437             return this;
10438           for (var n4, r3, a3, h3 = this.data, o3 = this.toBBox(t3), s3 = [], l3 = []; h3 || s3.length; ) {
10439             if (h3 || (h3 = s3.pop(), r3 = s3[s3.length - 1], n4 = l3.pop(), a3 = true), h3.leaf) {
10440               var f3 = e3(t3, h3.children, i4);
10441               if (-1 !== f3)
10442                 return h3.children.splice(f3, 1), s3.push(h3), this._condense(s3), this;
10443             }
10444             a3 || h3.leaf || !m2(h3, o3) ? r3 ? (n4++, h3 = r3.children[n4], a3 = false) : h3 = null : (s3.push(h3), l3.push(n4), n4 = 0, r3 = h3, h3 = h3.children[0]);
10445           }
10446           return this;
10447         }, r2.prototype.toBBox = function(t3) {
10448           return t3;
10449         }, r2.prototype.compareMinX = function(t3, i4) {
10450           return t3.minX - i4.minX;
10451         }, r2.prototype.compareMinY = function(t3, i4) {
10452           return t3.minY - i4.minY;
10453         }, r2.prototype.toJSON = function() {
10454           return this.data;
10455         }, r2.prototype.fromJSON = function(t3) {
10456           return this.data = t3, this;
10457         }, r2.prototype._all = function(t3, i4) {
10458           for (var n4 = []; t3; )
10459             t3.leaf ? i4.push.apply(i4, t3.children) : n4.push.apply(n4, t3.children), t3 = n4.pop();
10460           return i4;
10461         }, r2.prototype._build = function(t3, i4, n4, r3) {
10462           var e4, h3 = n4 - i4 + 1, o3 = this._maxEntries;
10463           if (h3 <= o3)
10464             return a2(e4 = p2(t3.slice(i4, n4 + 1)), this.toBBox), e4;
10465           r3 || (r3 = Math.ceil(Math.log(h3) / Math.log(o3)), o3 = Math.ceil(h3 / Math.pow(o3, r3 - 1))), (e4 = p2([])).leaf = false, e4.height = r3;
10466           var s3 = Math.ceil(h3 / o3), l3 = s3 * Math.ceil(Math.sqrt(o3));
10467           d2(t3, i4, n4, l3, this.compareMinX);
10468           for (var f3 = i4; f3 <= n4; f3 += l3) {
10469             var u3 = Math.min(f3 + l3 - 1, n4);
10470             d2(t3, f3, u3, s3, this.compareMinY);
10471             for (var m3 = f3; m3 <= u3; m3 += s3) {
10472               var c3 = Math.min(m3 + s3 - 1, u3);
10473               e4.children.push(this._build(t3, m3, c3, r3 - 1));
10474             }
10475           }
10476           return a2(e4, this.toBBox), e4;
10477         }, r2.prototype._chooseSubtree = function(t3, i4, n4, r3) {
10478           for (; r3.push(i4), !i4.leaf && r3.length - 1 !== n4; ) {
10479             for (var e4 = 1 / 0, a3 = 1 / 0, h3 = void 0, o3 = 0; o3 < i4.children.length; o3++) {
10480               var s3 = i4.children[o3], l3 = f2(s3), u3 = (m3 = t3, c3 = s3, (Math.max(c3.maxX, m3.maxX) - Math.min(c3.minX, m3.minX)) * (Math.max(c3.maxY, m3.maxY) - Math.min(c3.minY, m3.minY)) - l3);
10481               u3 < a3 ? (a3 = u3, e4 = l3 < e4 ? l3 : e4, h3 = s3) : u3 === a3 && l3 < e4 && (e4 = l3, h3 = s3);
10482             }
10483             i4 = h3 || i4.children[0];
10484           }
10485           var m3, c3;
10486           return i4;
10487         }, r2.prototype._insert = function(t3, i4, n4) {
10488           var r3 = n4 ? t3 : this.toBBox(t3), e4 = [], a3 = this._chooseSubtree(r3, this.data, i4, e4);
10489           for (a3.children.push(t3), o2(a3, r3); i4 >= 0 && e4[i4].children.length > this._maxEntries; )
10490             this._split(e4, i4), i4--;
10491           this._adjustParentBBoxes(r3, e4, i4);
10492         }, r2.prototype._split = function(t3, i4) {
10493           var n4 = t3[i4], r3 = n4.children.length, e4 = this._minEntries;
10494           this._chooseSplitAxis(n4, e4, r3);
10495           var h3 = this._chooseSplitIndex(n4, e4, r3), o3 = p2(n4.children.splice(h3, n4.children.length - h3));
10496           o3.height = n4.height, o3.leaf = n4.leaf, a2(n4, this.toBBox), a2(o3, this.toBBox), i4 ? t3[i4 - 1].children.push(o3) : this._splitRoot(n4, o3);
10497         }, r2.prototype._splitRoot = function(t3, i4) {
10498           this.data = p2([t3, i4]), this.data.height = t3.height + 1, this.data.leaf = false, a2(this.data, this.toBBox);
10499         }, r2.prototype._chooseSplitIndex = function(t3, i4, n4) {
10500           for (var r3, e4, a3, o3, s3, l3, u3, m3 = 1 / 0, c3 = 1 / 0, p3 = i4; p3 <= n4 - i4; p3++) {
10501             var d4 = h2(t3, 0, p3, this.toBBox), x2 = h2(t3, p3, n4, this.toBBox), v2 = (e4 = d4, a3 = x2, o3 = void 0, s3 = void 0, l3 = void 0, u3 = void 0, o3 = Math.max(e4.minX, a3.minX), s3 = Math.max(e4.minY, a3.minY), l3 = Math.min(e4.maxX, a3.maxX), u3 = Math.min(e4.maxY, a3.maxY), Math.max(0, l3 - o3) * Math.max(0, u3 - s3)), M2 = f2(d4) + f2(x2);
10502             v2 < m3 ? (m3 = v2, r3 = p3, c3 = M2 < c3 ? M2 : c3) : v2 === m3 && M2 < c3 && (c3 = M2, r3 = p3);
10503           }
10504           return r3 || n4 - i4;
10505         }, r2.prototype._chooseSplitAxis = function(t3, i4, n4) {
10506           var r3 = t3.leaf ? this.compareMinX : s2, e4 = t3.leaf ? this.compareMinY : l2;
10507           this._allDistMargin(t3, i4, n4, r3) < this._allDistMargin(t3, i4, n4, e4) && t3.children.sort(r3);
10508         }, r2.prototype._allDistMargin = function(t3, i4, n4, r3) {
10509           t3.children.sort(r3);
10510           for (var e4 = this.toBBox, a3 = h2(t3, 0, i4, e4), s3 = h2(t3, n4 - i4, n4, e4), l3 = u2(a3) + u2(s3), f3 = i4; f3 < n4 - i4; f3++) {
10511             var m3 = t3.children[f3];
10512             o2(a3, t3.leaf ? e4(m3) : m3), l3 += u2(a3);
10513           }
10514           for (var c3 = n4 - i4 - 1; c3 >= i4; c3--) {
10515             var p3 = t3.children[c3];
10516             o2(s3, t3.leaf ? e4(p3) : p3), l3 += u2(s3);
10517           }
10518           return l3;
10519         }, r2.prototype._adjustParentBBoxes = function(t3, i4, n4) {
10520           for (var r3 = n4; r3 >= 0; r3--)
10521             o2(i4[r3], t3);
10522         }, r2.prototype._condense = function(t3) {
10523           for (var i4 = t3.length - 1, n4 = void 0; i4 >= 0; i4--)
10524             0 === t3[i4].children.length ? i4 > 0 ? (n4 = t3[i4 - 1].children).splice(n4.indexOf(t3[i4]), 1) : this.clear() : a2(t3[i4], this.toBBox);
10525         }, r2;
10526       });
10527     }
10528   });
10529
10530   // node_modules/ieee754/index.js
10531   var require_ieee754 = __commonJS({
10532     "node_modules/ieee754/index.js"(exports2) {
10533       exports2.read = function(buffer, offset, isLE, mLen, nBytes) {
10534         var e3, m2;
10535         var eLen = nBytes * 8 - mLen - 1;
10536         var eMax = (1 << eLen) - 1;
10537         var eBias = eMax >> 1;
10538         var nBits = -7;
10539         var i3 = isLE ? nBytes - 1 : 0;
10540         var d2 = isLE ? -1 : 1;
10541         var s2 = buffer[offset + i3];
10542         i3 += d2;
10543         e3 = s2 & (1 << -nBits) - 1;
10544         s2 >>= -nBits;
10545         nBits += eLen;
10546         for (; nBits > 0; e3 = e3 * 256 + buffer[offset + i3], i3 += d2, nBits -= 8) {
10547         }
10548         m2 = e3 & (1 << -nBits) - 1;
10549         e3 >>= -nBits;
10550         nBits += mLen;
10551         for (; nBits > 0; m2 = m2 * 256 + buffer[offset + i3], i3 += d2, nBits -= 8) {
10552         }
10553         if (e3 === 0) {
10554           e3 = 1 - eBias;
10555         } else if (e3 === eMax) {
10556           return m2 ? NaN : (s2 ? -1 : 1) * Infinity;
10557         } else {
10558           m2 = m2 + Math.pow(2, mLen);
10559           e3 = e3 - eBias;
10560         }
10561         return (s2 ? -1 : 1) * m2 * Math.pow(2, e3 - mLen);
10562       };
10563       exports2.write = function(buffer, value, offset, isLE, mLen, nBytes) {
10564         var e3, m2, c2;
10565         var eLen = nBytes * 8 - mLen - 1;
10566         var eMax = (1 << eLen) - 1;
10567         var eBias = eMax >> 1;
10568         var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
10569         var i3 = isLE ? 0 : nBytes - 1;
10570         var d2 = isLE ? 1 : -1;
10571         var s2 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
10572         value = Math.abs(value);
10573         if (isNaN(value) || value === Infinity) {
10574           m2 = isNaN(value) ? 1 : 0;
10575           e3 = eMax;
10576         } else {
10577           e3 = Math.floor(Math.log(value) / Math.LN2);
10578           if (value * (c2 = Math.pow(2, -e3)) < 1) {
10579             e3--;
10580             c2 *= 2;
10581           }
10582           if (e3 + eBias >= 1) {
10583             value += rt / c2;
10584           } else {
10585             value += rt * Math.pow(2, 1 - eBias);
10586           }
10587           if (value * c2 >= 2) {
10588             e3++;
10589             c2 /= 2;
10590           }
10591           if (e3 + eBias >= eMax) {
10592             m2 = 0;
10593             e3 = eMax;
10594           } else if (e3 + eBias >= 1) {
10595             m2 = (value * c2 - 1) * Math.pow(2, mLen);
10596             e3 = e3 + eBias;
10597           } else {
10598             m2 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
10599             e3 = 0;
10600           }
10601         }
10602         for (; mLen >= 8; buffer[offset + i3] = m2 & 255, i3 += d2, m2 /= 256, mLen -= 8) {
10603         }
10604         e3 = e3 << mLen | m2;
10605         eLen += mLen;
10606         for (; eLen > 0; buffer[offset + i3] = e3 & 255, i3 += d2, e3 /= 256, eLen -= 8) {
10607         }
10608         buffer[offset + i3 - d2] |= s2 * 128;
10609       };
10610     }
10611   });
10612
10613   // node_modules/pbf/index.js
10614   var require_pbf = __commonJS({
10615     "node_modules/pbf/index.js"(exports2, module2) {
10616       "use strict";
10617       module2.exports = Pbf;
10618       var ieee754 = require_ieee754();
10619       function Pbf(buf) {
10620         this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
10621         this.pos = 0;
10622         this.type = 0;
10623         this.length = this.buf.length;
10624       }
10625       Pbf.Varint = 0;
10626       Pbf.Fixed64 = 1;
10627       Pbf.Bytes = 2;
10628       Pbf.Fixed32 = 5;
10629       var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
10630       var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
10631       var TEXT_DECODER_MIN_LENGTH = 12;
10632       var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
10633       Pbf.prototype = {
10634         destroy: function() {
10635           this.buf = null;
10636         },
10637         // === READING =================================================================
10638         readFields: function(readField, result, end) {
10639           end = end || this.length;
10640           while (this.pos < end) {
10641             var val = this.readVarint(), tag2 = val >> 3, startPos = this.pos;
10642             this.type = val & 7;
10643             readField(tag2, result, this);
10644             if (this.pos === startPos)
10645               this.skip(val);
10646           }
10647           return result;
10648         },
10649         readMessage: function(readField, result) {
10650           return this.readFields(readField, result, this.readVarint() + this.pos);
10651         },
10652         readFixed32: function() {
10653           var val = readUInt32(this.buf, this.pos);
10654           this.pos += 4;
10655           return val;
10656         },
10657         readSFixed32: function() {
10658           var val = readInt32(this.buf, this.pos);
10659           this.pos += 4;
10660           return val;
10661         },
10662         // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
10663         readFixed64: function() {
10664           var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
10665           this.pos += 8;
10666           return val;
10667         },
10668         readSFixed64: function() {
10669           var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
10670           this.pos += 8;
10671           return val;
10672         },
10673         readFloat: function() {
10674           var val = ieee754.read(this.buf, this.pos, true, 23, 4);
10675           this.pos += 4;
10676           return val;
10677         },
10678         readDouble: function() {
10679           var val = ieee754.read(this.buf, this.pos, true, 52, 8);
10680           this.pos += 8;
10681           return val;
10682         },
10683         readVarint: function(isSigned) {
10684           var buf = this.buf, val, b2;
10685           b2 = buf[this.pos++];
10686           val = b2 & 127;
10687           if (b2 < 128)
10688             return val;
10689           b2 = buf[this.pos++];
10690           val |= (b2 & 127) << 7;
10691           if (b2 < 128)
10692             return val;
10693           b2 = buf[this.pos++];
10694           val |= (b2 & 127) << 14;
10695           if (b2 < 128)
10696             return val;
10697           b2 = buf[this.pos++];
10698           val |= (b2 & 127) << 21;
10699           if (b2 < 128)
10700             return val;
10701           b2 = buf[this.pos];
10702           val |= (b2 & 15) << 28;
10703           return readVarintRemainder(val, isSigned, this);
10704         },
10705         readVarint64: function() {
10706           return this.readVarint(true);
10707         },
10708         readSVarint: function() {
10709           var num = this.readVarint();
10710           return num % 2 === 1 ? (num + 1) / -2 : num / 2;
10711         },
10712         readBoolean: function() {
10713           return Boolean(this.readVarint());
10714         },
10715         readString: function() {
10716           var end = this.readVarint() + this.pos;
10717           var pos = this.pos;
10718           this.pos = end;
10719           if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
10720             return readUtf8TextDecoder(this.buf, pos, end);
10721           }
10722           return readUtf8(this.buf, pos, end);
10723         },
10724         readBytes: function() {
10725           var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
10726           this.pos = end;
10727           return buffer;
10728         },
10729         // verbose for performance reasons; doesn't affect gzipped size
10730         readPackedVarint: function(arr, isSigned) {
10731           if (this.type !== Pbf.Bytes)
10732             return arr.push(this.readVarint(isSigned));
10733           var end = readPackedEnd(this);
10734           arr = arr || [];
10735           while (this.pos < end)
10736             arr.push(this.readVarint(isSigned));
10737           return arr;
10738         },
10739         readPackedSVarint: function(arr) {
10740           if (this.type !== Pbf.Bytes)
10741             return arr.push(this.readSVarint());
10742           var end = readPackedEnd(this);
10743           arr = arr || [];
10744           while (this.pos < end)
10745             arr.push(this.readSVarint());
10746           return arr;
10747         },
10748         readPackedBoolean: function(arr) {
10749           if (this.type !== Pbf.Bytes)
10750             return arr.push(this.readBoolean());
10751           var end = readPackedEnd(this);
10752           arr = arr || [];
10753           while (this.pos < end)
10754             arr.push(this.readBoolean());
10755           return arr;
10756         },
10757         readPackedFloat: function(arr) {
10758           if (this.type !== Pbf.Bytes)
10759             return arr.push(this.readFloat());
10760           var end = readPackedEnd(this);
10761           arr = arr || [];
10762           while (this.pos < end)
10763             arr.push(this.readFloat());
10764           return arr;
10765         },
10766         readPackedDouble: function(arr) {
10767           if (this.type !== Pbf.Bytes)
10768             return arr.push(this.readDouble());
10769           var end = readPackedEnd(this);
10770           arr = arr || [];
10771           while (this.pos < end)
10772             arr.push(this.readDouble());
10773           return arr;
10774         },
10775         readPackedFixed32: function(arr) {
10776           if (this.type !== Pbf.Bytes)
10777             return arr.push(this.readFixed32());
10778           var end = readPackedEnd(this);
10779           arr = arr || [];
10780           while (this.pos < end)
10781             arr.push(this.readFixed32());
10782           return arr;
10783         },
10784         readPackedSFixed32: function(arr) {
10785           if (this.type !== Pbf.Bytes)
10786             return arr.push(this.readSFixed32());
10787           var end = readPackedEnd(this);
10788           arr = arr || [];
10789           while (this.pos < end)
10790             arr.push(this.readSFixed32());
10791           return arr;
10792         },
10793         readPackedFixed64: function(arr) {
10794           if (this.type !== Pbf.Bytes)
10795             return arr.push(this.readFixed64());
10796           var end = readPackedEnd(this);
10797           arr = arr || [];
10798           while (this.pos < end)
10799             arr.push(this.readFixed64());
10800           return arr;
10801         },
10802         readPackedSFixed64: function(arr) {
10803           if (this.type !== Pbf.Bytes)
10804             return arr.push(this.readSFixed64());
10805           var end = readPackedEnd(this);
10806           arr = arr || [];
10807           while (this.pos < end)
10808             arr.push(this.readSFixed64());
10809           return arr;
10810         },
10811         skip: function(val) {
10812           var type2 = val & 7;
10813           if (type2 === Pbf.Varint)
10814             while (this.buf[this.pos++] > 127) {
10815             }
10816           else if (type2 === Pbf.Bytes)
10817             this.pos = this.readVarint() + this.pos;
10818           else if (type2 === Pbf.Fixed32)
10819             this.pos += 4;
10820           else if (type2 === Pbf.Fixed64)
10821             this.pos += 8;
10822           else
10823             throw new Error("Unimplemented type: " + type2);
10824         },
10825         // === WRITING =================================================================
10826         writeTag: function(tag2, type2) {
10827           this.writeVarint(tag2 << 3 | type2);
10828         },
10829         realloc: function(min3) {
10830           var length2 = this.length || 16;
10831           while (length2 < this.pos + min3)
10832             length2 *= 2;
10833           if (length2 !== this.length) {
10834             var buf = new Uint8Array(length2);
10835             buf.set(this.buf);
10836             this.buf = buf;
10837             this.length = length2;
10838           }
10839         },
10840         finish: function() {
10841           this.length = this.pos;
10842           this.pos = 0;
10843           return this.buf.subarray(0, this.length);
10844         },
10845         writeFixed32: function(val) {
10846           this.realloc(4);
10847           writeInt32(this.buf, val, this.pos);
10848           this.pos += 4;
10849         },
10850         writeSFixed32: function(val) {
10851           this.realloc(4);
10852           writeInt32(this.buf, val, this.pos);
10853           this.pos += 4;
10854         },
10855         writeFixed64: function(val) {
10856           this.realloc(8);
10857           writeInt32(this.buf, val & -1, this.pos);
10858           writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
10859           this.pos += 8;
10860         },
10861         writeSFixed64: function(val) {
10862           this.realloc(8);
10863           writeInt32(this.buf, val & -1, this.pos);
10864           writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
10865           this.pos += 8;
10866         },
10867         writeVarint: function(val) {
10868           val = +val || 0;
10869           if (val > 268435455 || val < 0) {
10870             writeBigVarint(val, this);
10871             return;
10872           }
10873           this.realloc(4);
10874           this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
10875           if (val <= 127)
10876             return;
10877           this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
10878           if (val <= 127)
10879             return;
10880           this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
10881           if (val <= 127)
10882             return;
10883           this.buf[this.pos++] = val >>> 7 & 127;
10884         },
10885         writeSVarint: function(val) {
10886           this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
10887         },
10888         writeBoolean: function(val) {
10889           this.writeVarint(Boolean(val));
10890         },
10891         writeString: function(str) {
10892           str = String(str);
10893           this.realloc(str.length * 4);
10894           this.pos++;
10895           var startPos = this.pos;
10896           this.pos = writeUtf8(this.buf, str, this.pos);
10897           var len = this.pos - startPos;
10898           if (len >= 128)
10899             makeRoomForExtraLength(startPos, len, this);
10900           this.pos = startPos - 1;
10901           this.writeVarint(len);
10902           this.pos += len;
10903         },
10904         writeFloat: function(val) {
10905           this.realloc(4);
10906           ieee754.write(this.buf, val, this.pos, true, 23, 4);
10907           this.pos += 4;
10908         },
10909         writeDouble: function(val) {
10910           this.realloc(8);
10911           ieee754.write(this.buf, val, this.pos, true, 52, 8);
10912           this.pos += 8;
10913         },
10914         writeBytes: function(buffer) {
10915           var len = buffer.length;
10916           this.writeVarint(len);
10917           this.realloc(len);
10918           for (var i3 = 0; i3 < len; i3++)
10919             this.buf[this.pos++] = buffer[i3];
10920         },
10921         writeRawMessage: function(fn, obj) {
10922           this.pos++;
10923           var startPos = this.pos;
10924           fn(obj, this);
10925           var len = this.pos - startPos;
10926           if (len >= 128)
10927             makeRoomForExtraLength(startPos, len, this);
10928           this.pos = startPos - 1;
10929           this.writeVarint(len);
10930           this.pos += len;
10931         },
10932         writeMessage: function(tag2, fn, obj) {
10933           this.writeTag(tag2, Pbf.Bytes);
10934           this.writeRawMessage(fn, obj);
10935         },
10936         writePackedVarint: function(tag2, arr) {
10937           if (arr.length)
10938             this.writeMessage(tag2, writePackedVarint, arr);
10939         },
10940         writePackedSVarint: function(tag2, arr) {
10941           if (arr.length)
10942             this.writeMessage(tag2, writePackedSVarint, arr);
10943         },
10944         writePackedBoolean: function(tag2, arr) {
10945           if (arr.length)
10946             this.writeMessage(tag2, writePackedBoolean, arr);
10947         },
10948         writePackedFloat: function(tag2, arr) {
10949           if (arr.length)
10950             this.writeMessage(tag2, writePackedFloat, arr);
10951         },
10952         writePackedDouble: function(tag2, arr) {
10953           if (arr.length)
10954             this.writeMessage(tag2, writePackedDouble, arr);
10955         },
10956         writePackedFixed32: function(tag2, arr) {
10957           if (arr.length)
10958             this.writeMessage(tag2, writePackedFixed32, arr);
10959         },
10960         writePackedSFixed32: function(tag2, arr) {
10961           if (arr.length)
10962             this.writeMessage(tag2, writePackedSFixed32, arr);
10963         },
10964         writePackedFixed64: function(tag2, arr) {
10965           if (arr.length)
10966             this.writeMessage(tag2, writePackedFixed64, arr);
10967         },
10968         writePackedSFixed64: function(tag2, arr) {
10969           if (arr.length)
10970             this.writeMessage(tag2, writePackedSFixed64, arr);
10971         },
10972         writeBytesField: function(tag2, buffer) {
10973           this.writeTag(tag2, Pbf.Bytes);
10974           this.writeBytes(buffer);
10975         },
10976         writeFixed32Field: function(tag2, val) {
10977           this.writeTag(tag2, Pbf.Fixed32);
10978           this.writeFixed32(val);
10979         },
10980         writeSFixed32Field: function(tag2, val) {
10981           this.writeTag(tag2, Pbf.Fixed32);
10982           this.writeSFixed32(val);
10983         },
10984         writeFixed64Field: function(tag2, val) {
10985           this.writeTag(tag2, Pbf.Fixed64);
10986           this.writeFixed64(val);
10987         },
10988         writeSFixed64Field: function(tag2, val) {
10989           this.writeTag(tag2, Pbf.Fixed64);
10990           this.writeSFixed64(val);
10991         },
10992         writeVarintField: function(tag2, val) {
10993           this.writeTag(tag2, Pbf.Varint);
10994           this.writeVarint(val);
10995         },
10996         writeSVarintField: function(tag2, val) {
10997           this.writeTag(tag2, Pbf.Varint);
10998           this.writeSVarint(val);
10999         },
11000         writeStringField: function(tag2, str) {
11001           this.writeTag(tag2, Pbf.Bytes);
11002           this.writeString(str);
11003         },
11004         writeFloatField: function(tag2, val) {
11005           this.writeTag(tag2, Pbf.Fixed32);
11006           this.writeFloat(val);
11007         },
11008         writeDoubleField: function(tag2, val) {
11009           this.writeTag(tag2, Pbf.Fixed64);
11010           this.writeDouble(val);
11011         },
11012         writeBooleanField: function(tag2, val) {
11013           this.writeVarintField(tag2, Boolean(val));
11014         }
11015       };
11016       function readVarintRemainder(l2, s2, p2) {
11017         var buf = p2.buf, h2, b2;
11018         b2 = buf[p2.pos++];
11019         h2 = (b2 & 112) >> 4;
11020         if (b2 < 128)
11021           return toNum(l2, h2, s2);
11022         b2 = buf[p2.pos++];
11023         h2 |= (b2 & 127) << 3;
11024         if (b2 < 128)
11025           return toNum(l2, h2, s2);
11026         b2 = buf[p2.pos++];
11027         h2 |= (b2 & 127) << 10;
11028         if (b2 < 128)
11029           return toNum(l2, h2, s2);
11030         b2 = buf[p2.pos++];
11031         h2 |= (b2 & 127) << 17;
11032         if (b2 < 128)
11033           return toNum(l2, h2, s2);
11034         b2 = buf[p2.pos++];
11035         h2 |= (b2 & 127) << 24;
11036         if (b2 < 128)
11037           return toNum(l2, h2, s2);
11038         b2 = buf[p2.pos++];
11039         h2 |= (b2 & 1) << 31;
11040         if (b2 < 128)
11041           return toNum(l2, h2, s2);
11042         throw new Error("Expected varint not more than 10 bytes");
11043       }
11044       function readPackedEnd(pbf) {
11045         return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
11046       }
11047       function toNum(low, high, isSigned) {
11048         if (isSigned) {
11049           return high * 4294967296 + (low >>> 0);
11050         }
11051         return (high >>> 0) * 4294967296 + (low >>> 0);
11052       }
11053       function writeBigVarint(val, pbf) {
11054         var low, high;
11055         if (val >= 0) {
11056           low = val % 4294967296 | 0;
11057           high = val / 4294967296 | 0;
11058         } else {
11059           low = ~(-val % 4294967296);
11060           high = ~(-val / 4294967296);
11061           if (low ^ 4294967295) {
11062             low = low + 1 | 0;
11063           } else {
11064             low = 0;
11065             high = high + 1 | 0;
11066           }
11067         }
11068         if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
11069           throw new Error("Given varint doesn't fit into 10 bytes");
11070         }
11071         pbf.realloc(10);
11072         writeBigVarintLow(low, high, pbf);
11073         writeBigVarintHigh(high, pbf);
11074       }
11075       function writeBigVarintLow(low, high, pbf) {
11076         pbf.buf[pbf.pos++] = low & 127 | 128;
11077         low >>>= 7;
11078         pbf.buf[pbf.pos++] = low & 127 | 128;
11079         low >>>= 7;
11080         pbf.buf[pbf.pos++] = low & 127 | 128;
11081         low >>>= 7;
11082         pbf.buf[pbf.pos++] = low & 127 | 128;
11083         low >>>= 7;
11084         pbf.buf[pbf.pos] = low & 127;
11085       }
11086       function writeBigVarintHigh(high, pbf) {
11087         var lsb = (high & 7) << 4;
11088         pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
11089         if (!high)
11090           return;
11091         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11092         if (!high)
11093           return;
11094         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11095         if (!high)
11096           return;
11097         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11098         if (!high)
11099           return;
11100         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11101         if (!high)
11102           return;
11103         pbf.buf[pbf.pos++] = high & 127;
11104       }
11105       function makeRoomForExtraLength(startPos, len, pbf) {
11106         var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
11107         pbf.realloc(extraLen);
11108         for (var i3 = pbf.pos - 1; i3 >= startPos; i3--)
11109           pbf.buf[i3 + extraLen] = pbf.buf[i3];
11110       }
11111       function writePackedVarint(arr, pbf) {
11112         for (var i3 = 0; i3 < arr.length; i3++)
11113           pbf.writeVarint(arr[i3]);
11114       }
11115       function writePackedSVarint(arr, pbf) {
11116         for (var i3 = 0; i3 < arr.length; i3++)
11117           pbf.writeSVarint(arr[i3]);
11118       }
11119       function writePackedFloat(arr, pbf) {
11120         for (var i3 = 0; i3 < arr.length; i3++)
11121           pbf.writeFloat(arr[i3]);
11122       }
11123       function writePackedDouble(arr, pbf) {
11124         for (var i3 = 0; i3 < arr.length; i3++)
11125           pbf.writeDouble(arr[i3]);
11126       }
11127       function writePackedBoolean(arr, pbf) {
11128         for (var i3 = 0; i3 < arr.length; i3++)
11129           pbf.writeBoolean(arr[i3]);
11130       }
11131       function writePackedFixed32(arr, pbf) {
11132         for (var i3 = 0; i3 < arr.length; i3++)
11133           pbf.writeFixed32(arr[i3]);
11134       }
11135       function writePackedSFixed32(arr, pbf) {
11136         for (var i3 = 0; i3 < arr.length; i3++)
11137           pbf.writeSFixed32(arr[i3]);
11138       }
11139       function writePackedFixed64(arr, pbf) {
11140         for (var i3 = 0; i3 < arr.length; i3++)
11141           pbf.writeFixed64(arr[i3]);
11142       }
11143       function writePackedSFixed64(arr, pbf) {
11144         for (var i3 = 0; i3 < arr.length; i3++)
11145           pbf.writeSFixed64(arr[i3]);
11146       }
11147       function readUInt32(buf, pos) {
11148         return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
11149       }
11150       function writeInt32(buf, val, pos) {
11151         buf[pos] = val;
11152         buf[pos + 1] = val >>> 8;
11153         buf[pos + 2] = val >>> 16;
11154         buf[pos + 3] = val >>> 24;
11155       }
11156       function readInt32(buf, pos) {
11157         return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24);
11158       }
11159       function readUtf8(buf, pos, end) {
11160         var str = "";
11161         var i3 = pos;
11162         while (i3 < end) {
11163           var b0 = buf[i3];
11164           var c2 = null;
11165           var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
11166           if (i3 + bytesPerSequence > end)
11167             break;
11168           var b1, b2, b3;
11169           if (bytesPerSequence === 1) {
11170             if (b0 < 128) {
11171               c2 = b0;
11172             }
11173           } else if (bytesPerSequence === 2) {
11174             b1 = buf[i3 + 1];
11175             if ((b1 & 192) === 128) {
11176               c2 = (b0 & 31) << 6 | b1 & 63;
11177               if (c2 <= 127) {
11178                 c2 = null;
11179               }
11180             }
11181           } else if (bytesPerSequence === 3) {
11182             b1 = buf[i3 + 1];
11183             b2 = buf[i3 + 2];
11184             if ((b1 & 192) === 128 && (b2 & 192) === 128) {
11185               c2 = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
11186               if (c2 <= 2047 || c2 >= 55296 && c2 <= 57343) {
11187                 c2 = null;
11188               }
11189             }
11190           } else if (bytesPerSequence === 4) {
11191             b1 = buf[i3 + 1];
11192             b2 = buf[i3 + 2];
11193             b3 = buf[i3 + 3];
11194             if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
11195               c2 = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
11196               if (c2 <= 65535 || c2 >= 1114112) {
11197                 c2 = null;
11198               }
11199             }
11200           }
11201           if (c2 === null) {
11202             c2 = 65533;
11203             bytesPerSequence = 1;
11204           } else if (c2 > 65535) {
11205             c2 -= 65536;
11206             str += String.fromCharCode(c2 >>> 10 & 1023 | 55296);
11207             c2 = 56320 | c2 & 1023;
11208           }
11209           str += String.fromCharCode(c2);
11210           i3 += bytesPerSequence;
11211         }
11212         return str;
11213       }
11214       function readUtf8TextDecoder(buf, pos, end) {
11215         return utf8TextDecoder.decode(buf.subarray(pos, end));
11216       }
11217       function writeUtf8(buf, str, pos) {
11218         for (var i3 = 0, c2, lead; i3 < str.length; i3++) {
11219           c2 = str.charCodeAt(i3);
11220           if (c2 > 55295 && c2 < 57344) {
11221             if (lead) {
11222               if (c2 < 56320) {
11223                 buf[pos++] = 239;
11224                 buf[pos++] = 191;
11225                 buf[pos++] = 189;
11226                 lead = c2;
11227                 continue;
11228               } else {
11229                 c2 = lead - 55296 << 10 | c2 - 56320 | 65536;
11230                 lead = null;
11231               }
11232             } else {
11233               if (c2 > 56319 || i3 + 1 === str.length) {
11234                 buf[pos++] = 239;
11235                 buf[pos++] = 191;
11236                 buf[pos++] = 189;
11237               } else {
11238                 lead = c2;
11239               }
11240               continue;
11241             }
11242           } else if (lead) {
11243             buf[pos++] = 239;
11244             buf[pos++] = 191;
11245             buf[pos++] = 189;
11246             lead = null;
11247           }
11248           if (c2 < 128) {
11249             buf[pos++] = c2;
11250           } else {
11251             if (c2 < 2048) {
11252               buf[pos++] = c2 >> 6 | 192;
11253             } else {
11254               if (c2 < 65536) {
11255                 buf[pos++] = c2 >> 12 | 224;
11256               } else {
11257                 buf[pos++] = c2 >> 18 | 240;
11258                 buf[pos++] = c2 >> 12 & 63 | 128;
11259               }
11260               buf[pos++] = c2 >> 6 & 63 | 128;
11261             }
11262             buf[pos++] = c2 & 63 | 128;
11263           }
11264         }
11265         return pos;
11266       }
11267     }
11268   });
11269
11270   // node_modules/@mapbox/point-geometry/index.js
11271   var require_point_geometry = __commonJS({
11272     "node_modules/@mapbox/point-geometry/index.js"(exports2, module2) {
11273       "use strict";
11274       module2.exports = Point;
11275       function Point(x2, y2) {
11276         this.x = x2;
11277         this.y = y2;
11278       }
11279       Point.prototype = {
11280         /**
11281          * Clone this point, returning a new point that can be modified
11282          * without affecting the old one.
11283          * @return {Point} the clone
11284          */
11285         clone: function() {
11286           return new Point(this.x, this.y);
11287         },
11288         /**
11289          * Add this point's x & y coordinates to another point,
11290          * yielding a new point.
11291          * @param {Point} p the other point
11292          * @return {Point} output point
11293          */
11294         add: function(p2) {
11295           return this.clone()._add(p2);
11296         },
11297         /**
11298          * Subtract this point's x & y coordinates to from point,
11299          * yielding a new point.
11300          * @param {Point} p the other point
11301          * @return {Point} output point
11302          */
11303         sub: function(p2) {
11304           return this.clone()._sub(p2);
11305         },
11306         /**
11307          * Multiply this point's x & y coordinates by point,
11308          * yielding a new point.
11309          * @param {Point} p the other point
11310          * @return {Point} output point
11311          */
11312         multByPoint: function(p2) {
11313           return this.clone()._multByPoint(p2);
11314         },
11315         /**
11316          * Divide this point's x & y coordinates by point,
11317          * yielding a new point.
11318          * @param {Point} p the other point
11319          * @return {Point} output point
11320          */
11321         divByPoint: function(p2) {
11322           return this.clone()._divByPoint(p2);
11323         },
11324         /**
11325          * Multiply this point's x & y coordinates by a factor,
11326          * yielding a new point.
11327          * @param {Point} k factor
11328          * @return {Point} output point
11329          */
11330         mult: function(k2) {
11331           return this.clone()._mult(k2);
11332         },
11333         /**
11334          * Divide this point's x & y coordinates by a factor,
11335          * yielding a new point.
11336          * @param {Point} k factor
11337          * @return {Point} output point
11338          */
11339         div: function(k2) {
11340           return this.clone()._div(k2);
11341         },
11342         /**
11343          * Rotate this point around the 0, 0 origin by an angle a,
11344          * given in radians
11345          * @param {Number} a angle to rotate around, in radians
11346          * @return {Point} output point
11347          */
11348         rotate: function(a2) {
11349           return this.clone()._rotate(a2);
11350         },
11351         /**
11352          * Rotate this point around p point by an angle a,
11353          * given in radians
11354          * @param {Number} a angle to rotate around, in radians
11355          * @param {Point} p Point to rotate around
11356          * @return {Point} output point
11357          */
11358         rotateAround: function(a2, p2) {
11359           return this.clone()._rotateAround(a2, p2);
11360         },
11361         /**
11362          * Multiply this point by a 4x1 transformation matrix
11363          * @param {Array<Number>} m transformation matrix
11364          * @return {Point} output point
11365          */
11366         matMult: function(m2) {
11367           return this.clone()._matMult(m2);
11368         },
11369         /**
11370          * Calculate this point but as a unit vector from 0, 0, meaning
11371          * that the distance from the resulting point to the 0, 0
11372          * coordinate will be equal to 1 and the angle from the resulting
11373          * point to the 0, 0 coordinate will be the same as before.
11374          * @return {Point} unit vector point
11375          */
11376         unit: function() {
11377           return this.clone()._unit();
11378         },
11379         /**
11380          * Compute a perpendicular point, where the new y coordinate
11381          * is the old x coordinate and the new x coordinate is the old y
11382          * coordinate multiplied by -1
11383          * @return {Point} perpendicular point
11384          */
11385         perp: function() {
11386           return this.clone()._perp();
11387         },
11388         /**
11389          * Return a version of this point with the x & y coordinates
11390          * rounded to integers.
11391          * @return {Point} rounded point
11392          */
11393         round: function() {
11394           return this.clone()._round();
11395         },
11396         /**
11397          * Return the magitude of this point: this is the Euclidean
11398          * distance from the 0, 0 coordinate to this point's x and y
11399          * coordinates.
11400          * @return {Number} magnitude
11401          */
11402         mag: function() {
11403           return Math.sqrt(this.x * this.x + this.y * this.y);
11404         },
11405         /**
11406          * Judge whether this point is equal to another point, returning
11407          * true or false.
11408          * @param {Point} other the other point
11409          * @return {boolean} whether the points are equal
11410          */
11411         equals: function(other) {
11412           return this.x === other.x && this.y === other.y;
11413         },
11414         /**
11415          * Calculate the distance from this point to another point
11416          * @param {Point} p the other point
11417          * @return {Number} distance
11418          */
11419         dist: function(p2) {
11420           return Math.sqrt(this.distSqr(p2));
11421         },
11422         /**
11423          * Calculate the distance from this point to another point,
11424          * without the square root step. Useful if you're comparing
11425          * relative distances.
11426          * @param {Point} p the other point
11427          * @return {Number} distance
11428          */
11429         distSqr: function(p2) {
11430           var dx = p2.x - this.x, dy = p2.y - this.y;
11431           return dx * dx + dy * dy;
11432         },
11433         /**
11434          * Get the angle from the 0, 0 coordinate to this point, in radians
11435          * coordinates.
11436          * @return {Number} angle
11437          */
11438         angle: function() {
11439           return Math.atan2(this.y, this.x);
11440         },
11441         /**
11442          * Get the angle from this point to another point, in radians
11443          * @param {Point} b the other point
11444          * @return {Number} angle
11445          */
11446         angleTo: function(b2) {
11447           return Math.atan2(this.y - b2.y, this.x - b2.x);
11448         },
11449         /**
11450          * Get the angle between this point and another point, in radians
11451          * @param {Point} b the other point
11452          * @return {Number} angle
11453          */
11454         angleWith: function(b2) {
11455           return this.angleWithSep(b2.x, b2.y);
11456         },
11457         /*
11458          * Find the angle of the two vectors, solving the formula for
11459          * the cross product a x b = |a||b|sin(θ) for θ.
11460          * @param {Number} x the x-coordinate
11461          * @param {Number} y the y-coordinate
11462          * @return {Number} the angle in radians
11463          */
11464         angleWithSep: function(x2, y2) {
11465           return Math.atan2(
11466             this.x * y2 - this.y * x2,
11467             this.x * x2 + this.y * y2
11468           );
11469         },
11470         _matMult: function(m2) {
11471           var x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y;
11472           this.x = x2;
11473           this.y = y2;
11474           return this;
11475         },
11476         _add: function(p2) {
11477           this.x += p2.x;
11478           this.y += p2.y;
11479           return this;
11480         },
11481         _sub: function(p2) {
11482           this.x -= p2.x;
11483           this.y -= p2.y;
11484           return this;
11485         },
11486         _mult: function(k2) {
11487           this.x *= k2;
11488           this.y *= k2;
11489           return this;
11490         },
11491         _div: function(k2) {
11492           this.x /= k2;
11493           this.y /= k2;
11494           return this;
11495         },
11496         _multByPoint: function(p2) {
11497           this.x *= p2.x;
11498           this.y *= p2.y;
11499           return this;
11500         },
11501         _divByPoint: function(p2) {
11502           this.x /= p2.x;
11503           this.y /= p2.y;
11504           return this;
11505         },
11506         _unit: function() {
11507           this._div(this.mag());
11508           return this;
11509         },
11510         _perp: function() {
11511           var y2 = this.y;
11512           this.y = this.x;
11513           this.x = -y2;
11514           return this;
11515         },
11516         _rotate: function(angle2) {
11517           var cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y;
11518           this.x = x2;
11519           this.y = y2;
11520           return this;
11521         },
11522         _rotateAround: function(angle2, p2) {
11523           var 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);
11524           this.x = x2;
11525           this.y = y2;
11526           return this;
11527         },
11528         _round: function() {
11529           this.x = Math.round(this.x);
11530           this.y = Math.round(this.y);
11531           return this;
11532         }
11533       };
11534       Point.convert = function(a2) {
11535         if (a2 instanceof Point) {
11536           return a2;
11537         }
11538         if (Array.isArray(a2)) {
11539           return new Point(a2[0], a2[1]);
11540         }
11541         return a2;
11542       };
11543     }
11544   });
11545
11546   // node_modules/@mapbox/vector-tile/lib/vectortilefeature.js
11547   var require_vectortilefeature = __commonJS({
11548     "node_modules/@mapbox/vector-tile/lib/vectortilefeature.js"(exports2, module2) {
11549       "use strict";
11550       var Point = require_point_geometry();
11551       module2.exports = VectorTileFeature;
11552       function VectorTileFeature(pbf, end, extent, keys2, values) {
11553         this.properties = {};
11554         this.extent = extent;
11555         this.type = 0;
11556         this._pbf = pbf;
11557         this._geometry = -1;
11558         this._keys = keys2;
11559         this._values = values;
11560         pbf.readFields(readFeature, this, end);
11561       }
11562       function readFeature(tag2, feature3, pbf) {
11563         if (tag2 == 1)
11564           feature3.id = pbf.readVarint();
11565         else if (tag2 == 2)
11566           readTag(pbf, feature3);
11567         else if (tag2 == 3)
11568           feature3.type = pbf.readVarint();
11569         else if (tag2 == 4)
11570           feature3._geometry = pbf.pos;
11571       }
11572       function readTag(pbf, feature3) {
11573         var end = pbf.readVarint() + pbf.pos;
11574         while (pbf.pos < end) {
11575           var key = feature3._keys[pbf.readVarint()], value = feature3._values[pbf.readVarint()];
11576           feature3.properties[key] = value;
11577         }
11578       }
11579       VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"];
11580       VectorTileFeature.prototype.loadGeometry = function() {
11581         var pbf = this._pbf;
11582         pbf.pos = this._geometry;
11583         var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, lines = [], line;
11584         while (pbf.pos < end) {
11585           if (length2 <= 0) {
11586             var cmdLen = pbf.readVarint();
11587             cmd = cmdLen & 7;
11588             length2 = cmdLen >> 3;
11589           }
11590           length2--;
11591           if (cmd === 1 || cmd === 2) {
11592             x2 += pbf.readSVarint();
11593             y2 += pbf.readSVarint();
11594             if (cmd === 1) {
11595               if (line)
11596                 lines.push(line);
11597               line = [];
11598             }
11599             line.push(new Point(x2, y2));
11600           } else if (cmd === 7) {
11601             if (line) {
11602               line.push(line[0].clone());
11603             }
11604           } else {
11605             throw new Error("unknown command " + cmd);
11606           }
11607         }
11608         if (line)
11609           lines.push(line);
11610         return lines;
11611       };
11612       VectorTileFeature.prototype.bbox = function() {
11613         var pbf = this._pbf;
11614         pbf.pos = this._geometry;
11615         var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity;
11616         while (pbf.pos < end) {
11617           if (length2 <= 0) {
11618             var cmdLen = pbf.readVarint();
11619             cmd = cmdLen & 7;
11620             length2 = cmdLen >> 3;
11621           }
11622           length2--;
11623           if (cmd === 1 || cmd === 2) {
11624             x2 += pbf.readSVarint();
11625             y2 += pbf.readSVarint();
11626             if (x2 < x12)
11627               x12 = x2;
11628             if (x2 > x22)
11629               x22 = x2;
11630             if (y2 < y12)
11631               y12 = y2;
11632             if (y2 > y22)
11633               y22 = y2;
11634           } else if (cmd !== 7) {
11635             throw new Error("unknown command " + cmd);
11636           }
11637         }
11638         return [x12, y12, x22, y22];
11639       };
11640       VectorTileFeature.prototype.toGeoJSON = function(x2, y2, z2) {
11641         var size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, coords = this.loadGeometry(), type2 = VectorTileFeature.types[this.type], i3, j2;
11642         function project(line) {
11643           for (var j3 = 0; j3 < line.length; j3++) {
11644             var p2 = line[j3], y22 = 180 - (p2.y + y05) * 360 / size;
11645             line[j3] = [
11646               (p2.x + x05) * 360 / size - 180,
11647               360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90
11648             ];
11649           }
11650         }
11651         switch (this.type) {
11652           case 1:
11653             var points = [];
11654             for (i3 = 0; i3 < coords.length; i3++) {
11655               points[i3] = coords[i3][0];
11656             }
11657             coords = points;
11658             project(coords);
11659             break;
11660           case 2:
11661             for (i3 = 0; i3 < coords.length; i3++) {
11662               project(coords[i3]);
11663             }
11664             break;
11665           case 3:
11666             coords = classifyRings(coords);
11667             for (i3 = 0; i3 < coords.length; i3++) {
11668               for (j2 = 0; j2 < coords[i3].length; j2++) {
11669                 project(coords[i3][j2]);
11670               }
11671             }
11672             break;
11673         }
11674         if (coords.length === 1) {
11675           coords = coords[0];
11676         } else {
11677           type2 = "Multi" + type2;
11678         }
11679         var result = {
11680           type: "Feature",
11681           geometry: {
11682             type: type2,
11683             coordinates: coords
11684           },
11685           properties: this.properties
11686         };
11687         if ("id" in this) {
11688           result.id = this.id;
11689         }
11690         return result;
11691       };
11692       function classifyRings(rings) {
11693         var len = rings.length;
11694         if (len <= 1)
11695           return [rings];
11696         var polygons = [], polygon2, ccw;
11697         for (var i3 = 0; i3 < len; i3++) {
11698           var area = signedArea(rings[i3]);
11699           if (area === 0)
11700             continue;
11701           if (ccw === void 0)
11702             ccw = area < 0;
11703           if (ccw === area < 0) {
11704             if (polygon2)
11705               polygons.push(polygon2);
11706             polygon2 = [rings[i3]];
11707           } else {
11708             polygon2.push(rings[i3]);
11709           }
11710         }
11711         if (polygon2)
11712           polygons.push(polygon2);
11713         return polygons;
11714       }
11715       function signedArea(ring) {
11716         var sum = 0;
11717         for (var i3 = 0, len = ring.length, j2 = len - 1, p1, p2; i3 < len; j2 = i3++) {
11718           p1 = ring[i3];
11719           p2 = ring[j2];
11720           sum += (p2.x - p1.x) * (p1.y + p2.y);
11721         }
11722         return sum;
11723       }
11724     }
11725   });
11726
11727   // node_modules/@mapbox/vector-tile/lib/vectortilelayer.js
11728   var require_vectortilelayer = __commonJS({
11729     "node_modules/@mapbox/vector-tile/lib/vectortilelayer.js"(exports2, module2) {
11730       "use strict";
11731       var VectorTileFeature = require_vectortilefeature();
11732       module2.exports = VectorTileLayer;
11733       function VectorTileLayer(pbf, end) {
11734         this.version = 1;
11735         this.name = null;
11736         this.extent = 4096;
11737         this.length = 0;
11738         this._pbf = pbf;
11739         this._keys = [];
11740         this._values = [];
11741         this._features = [];
11742         pbf.readFields(readLayer, this, end);
11743         this.length = this._features.length;
11744       }
11745       function readLayer(tag2, layer, pbf) {
11746         if (tag2 === 15)
11747           layer.version = pbf.readVarint();
11748         else if (tag2 === 1)
11749           layer.name = pbf.readString();
11750         else if (tag2 === 5)
11751           layer.extent = pbf.readVarint();
11752         else if (tag2 === 2)
11753           layer._features.push(pbf.pos);
11754         else if (tag2 === 3)
11755           layer._keys.push(pbf.readString());
11756         else if (tag2 === 4)
11757           layer._values.push(readValueMessage(pbf));
11758       }
11759       function readValueMessage(pbf) {
11760         var value = null, end = pbf.readVarint() + pbf.pos;
11761         while (pbf.pos < end) {
11762           var tag2 = pbf.readVarint() >> 3;
11763           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;
11764         }
11765         return value;
11766       }
11767       VectorTileLayer.prototype.feature = function(i3) {
11768         if (i3 < 0 || i3 >= this._features.length)
11769           throw new Error("feature index out of bounds");
11770         this._pbf.pos = this._features[i3];
11771         var end = this._pbf.readVarint() + this._pbf.pos;
11772         return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
11773       };
11774     }
11775   });
11776
11777   // node_modules/@mapbox/vector-tile/lib/vectortile.js
11778   var require_vectortile = __commonJS({
11779     "node_modules/@mapbox/vector-tile/lib/vectortile.js"(exports2, module2) {
11780       "use strict";
11781       var VectorTileLayer = require_vectortilelayer();
11782       module2.exports = VectorTile3;
11783       function VectorTile3(pbf, end) {
11784         this.layers = pbf.readFields(readTile, {}, end);
11785       }
11786       function readTile(tag2, layers, pbf) {
11787         if (tag2 === 3) {
11788           var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
11789           if (layer.length)
11790             layers[layer.name] = layer;
11791         }
11792       }
11793     }
11794   });
11795
11796   // node_modules/@mapbox/vector-tile/index.js
11797   var require_vector_tile = __commonJS({
11798     "node_modules/@mapbox/vector-tile/index.js"(exports2, module2) {
11799       module2.exports.VectorTile = require_vectortile();
11800       module2.exports.VectorTileFeature = require_vectortilefeature();
11801       module2.exports.VectorTileLayer = require_vectortilelayer();
11802     }
11803   });
11804
11805   // node_modules/fast-json-stable-stringify/index.js
11806   var require_fast_json_stable_stringify = __commonJS({
11807     "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) {
11808       "use strict";
11809       module2.exports = function(data, opts) {
11810         if (!opts)
11811           opts = {};
11812         if (typeof opts === "function")
11813           opts = { cmp: opts };
11814         var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
11815         var cmp = opts.cmp && /* @__PURE__ */ function(f2) {
11816           return function(node) {
11817             return function(a2, b2) {
11818               var aobj = { key: a2, value: node[a2] };
11819               var bobj = { key: b2, value: node[b2] };
11820               return f2(aobj, bobj);
11821             };
11822           };
11823         }(opts.cmp);
11824         var seen = [];
11825         return function stringify3(node) {
11826           if (node && node.toJSON && typeof node.toJSON === "function") {
11827             node = node.toJSON();
11828           }
11829           if (node === void 0)
11830             return;
11831           if (typeof node == "number")
11832             return isFinite(node) ? "" + node : "null";
11833           if (typeof node !== "object")
11834             return JSON.stringify(node);
11835           var i3, out;
11836           if (Array.isArray(node)) {
11837             out = "[";
11838             for (i3 = 0; i3 < node.length; i3++) {
11839               if (i3)
11840                 out += ",";
11841               out += stringify3(node[i3]) || "null";
11842             }
11843             return out + "]";
11844           }
11845           if (node === null)
11846             return "null";
11847           if (seen.indexOf(node) !== -1) {
11848             if (cycles)
11849               return JSON.stringify("__cycle__");
11850             throw new TypeError("Converting circular structure to JSON");
11851           }
11852           var seenIndex = seen.push(node) - 1;
11853           var keys2 = Object.keys(node).sort(cmp && cmp(node));
11854           out = "";
11855           for (i3 = 0; i3 < keys2.length; i3++) {
11856             var key = keys2[i3];
11857             var value = stringify3(node[key]);
11858             if (!value)
11859               continue;
11860             if (out)
11861               out += ",";
11862             out += JSON.stringify(key) + ":" + value;
11863           }
11864           seen.splice(seenIndex, 1);
11865           return "{" + out + "}";
11866         }(data);
11867       };
11868     }
11869   });
11870
11871   // node_modules/@mapbox/sexagesimal/index.js
11872   var require_sexagesimal = __commonJS({
11873     "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) {
11874       module2.exports = element;
11875       module2.exports.pair = pair3;
11876       module2.exports.format = format2;
11877       module2.exports.formatPair = formatPair;
11878       module2.exports.coordToDMS = coordToDMS;
11879       function element(input, dims) {
11880         var result = search(input, dims);
11881         return result === null ? null : result.val;
11882       }
11883       function formatPair(input) {
11884         return format2(input.lat, "lat") + " " + format2(input.lon, "lon");
11885       }
11886       function format2(input, dim) {
11887         var dms = coordToDMS(input, dim);
11888         return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir;
11889       }
11890       function coordToDMS(input, dim) {
11891         var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || "";
11892         var dir = dirs[input >= 0 ? 0 : 1];
11893         var abs3 = Math.abs(input);
11894         var whole = Math.floor(abs3);
11895         var fraction = abs3 - whole;
11896         var fractionMinutes = fraction * 60;
11897         var minutes = Math.floor(fractionMinutes);
11898         var seconds = Math.floor((fractionMinutes - minutes) * 60);
11899         return {
11900           whole,
11901           minutes,
11902           seconds,
11903           dir
11904         };
11905       }
11906       function search(input, dims) {
11907         if (!dims)
11908           dims = "NSEW";
11909         if (typeof input !== "string")
11910           return null;
11911         input = input.toUpperCase();
11912         var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/;
11913         var m2 = input.match(regex);
11914         if (!m2)
11915           return null;
11916         var matched = m2[0];
11917         var dim;
11918         if (m2[1] && m2[5]) {
11919           dim = m2[1];
11920           matched = matched.slice(0, -1);
11921         } else {
11922           dim = m2[1] || m2[5];
11923         }
11924         if (dim && dims.indexOf(dim) === -1)
11925           return null;
11926         var deg = m2[2] ? parseFloat(m2[2]) : 0;
11927         var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0;
11928         var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0;
11929         var sign2 = deg < 0 ? -1 : 1;
11930         if (dim === "S" || dim === "W")
11931           sign2 *= -1;
11932         return {
11933           val: (Math.abs(deg) + min3 + sec) * sign2,
11934           dim,
11935           matched,
11936           remain: input.slice(matched.length)
11937         };
11938       }
11939       function pair3(input, dims) {
11940         input = input.trim();
11941         var one2 = search(input, dims);
11942         if (!one2)
11943           return null;
11944         input = one2.remain.trim();
11945         var two = search(input, dims);
11946         if (!two || two.remain)
11947           return null;
11948         if (one2.dim) {
11949           return swapdim(one2.val, two.val, one2.dim);
11950         } else {
11951           return [one2.val, two.val];
11952         }
11953       }
11954       function swapdim(a2, b2, dim) {
11955         if (dim === "N" || dim === "S")
11956           return [a2, b2];
11957         if (dim === "W" || dim === "E")
11958           return [b2, a2];
11959       }
11960     }
11961   });
11962
11963   // node_modules/polygon-clipping/dist/polygon-clipping.umd.js
11964   var require_polygon_clipping_umd = __commonJS({
11965     "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) {
11966       (function(global2, factory) {
11967         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());
11968       })(exports2, function() {
11969         "use strict";
11970         function __generator(thisArg, body) {
11971           var _2 = {
11972             label: 0,
11973             sent: function() {
11974               if (t2[0] & 1)
11975                 throw t2[1];
11976               return t2[1];
11977             },
11978             trys: [],
11979             ops: []
11980           }, f2, y2, t2, g3;
11981           return g3 = {
11982             next: verb(0),
11983             "throw": verb(1),
11984             "return": verb(2)
11985           }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() {
11986             return this;
11987           }), g3;
11988           function verb(n3) {
11989             return function(v2) {
11990               return step([n3, v2]);
11991             };
11992           }
11993           function step(op) {
11994             if (f2)
11995               throw new TypeError("Generator is already executing.");
11996             while (_2)
11997               try {
11998                 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)
11999                   return t2;
12000                 if (y2 = 0, t2)
12001                   op = [op[0] & 2, t2.value];
12002                 switch (op[0]) {
12003                   case 0:
12004                   case 1:
12005                     t2 = op;
12006                     break;
12007                   case 4:
12008                     _2.label++;
12009                     return {
12010                       value: op[1],
12011                       done: false
12012                     };
12013                   case 5:
12014                     _2.label++;
12015                     y2 = op[1];
12016                     op = [0];
12017                     continue;
12018                   case 7:
12019                     op = _2.ops.pop();
12020                     _2.trys.pop();
12021                     continue;
12022                   default:
12023                     if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
12024                       _2 = 0;
12025                       continue;
12026                     }
12027                     if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
12028                       _2.label = op[1];
12029                       break;
12030                     }
12031                     if (op[0] === 6 && _2.label < t2[1]) {
12032                       _2.label = t2[1];
12033                       t2 = op;
12034                       break;
12035                     }
12036                     if (t2 && _2.label < t2[2]) {
12037                       _2.label = t2[2];
12038                       _2.ops.push(op);
12039                       break;
12040                     }
12041                     if (t2[2])
12042                       _2.ops.pop();
12043                     _2.trys.pop();
12044                     continue;
12045                 }
12046                 op = body.call(thisArg, _2);
12047               } catch (e3) {
12048                 op = [6, e3];
12049                 y2 = 0;
12050               } finally {
12051                 f2 = t2 = 0;
12052               }
12053             if (op[0] & 5)
12054               throw op[1];
12055             return {
12056               value: op[0] ? op[1] : void 0,
12057               done: true
12058             };
12059           }
12060         }
12061         var Node = (
12062           /** @class */
12063           /* @__PURE__ */ function() {
12064             function Node2(key, data) {
12065               this.next = null;
12066               this.key = key;
12067               this.data = data;
12068               this.left = null;
12069               this.right = null;
12070             }
12071             return Node2;
12072           }()
12073         );
12074         function DEFAULT_COMPARE(a2, b2) {
12075           return a2 > b2 ? 1 : a2 < b2 ? -1 : 0;
12076         }
12077         function splay(i3, t2, comparator) {
12078           var N2 = new Node(null, null);
12079           var l2 = N2;
12080           var r2 = N2;
12081           while (true) {
12082             var cmp2 = comparator(i3, t2.key);
12083             if (cmp2 < 0) {
12084               if (t2.left === null)
12085                 break;
12086               if (comparator(i3, t2.left.key) < 0) {
12087                 var y2 = t2.left;
12088                 t2.left = y2.right;
12089                 y2.right = t2;
12090                 t2 = y2;
12091                 if (t2.left === null)
12092                   break;
12093               }
12094               r2.left = t2;
12095               r2 = t2;
12096               t2 = t2.left;
12097             } else if (cmp2 > 0) {
12098               if (t2.right === null)
12099                 break;
12100               if (comparator(i3, t2.right.key) > 0) {
12101                 var y2 = t2.right;
12102                 t2.right = y2.left;
12103                 y2.left = t2;
12104                 t2 = y2;
12105                 if (t2.right === null)
12106                   break;
12107               }
12108               l2.right = t2;
12109               l2 = t2;
12110               t2 = t2.right;
12111             } else
12112               break;
12113           }
12114           l2.right = t2.left;
12115           r2.left = t2.right;
12116           t2.left = N2.right;
12117           t2.right = N2.left;
12118           return t2;
12119         }
12120         function insert(i3, data, t2, comparator) {
12121           var node = new Node(i3, data);
12122           if (t2 === null) {
12123             node.left = node.right = null;
12124             return node;
12125           }
12126           t2 = splay(i3, t2, comparator);
12127           var cmp2 = comparator(i3, t2.key);
12128           if (cmp2 < 0) {
12129             node.left = t2.left;
12130             node.right = t2;
12131             t2.left = null;
12132           } else if (cmp2 >= 0) {
12133             node.right = t2.right;
12134             node.left = t2;
12135             t2.right = null;
12136           }
12137           return node;
12138         }
12139         function split(key, v2, comparator) {
12140           var left = null;
12141           var right = null;
12142           if (v2) {
12143             v2 = splay(key, v2, comparator);
12144             var cmp2 = comparator(v2.key, key);
12145             if (cmp2 === 0) {
12146               left = v2.left;
12147               right = v2.right;
12148             } else if (cmp2 < 0) {
12149               right = v2.right;
12150               v2.right = null;
12151               left = v2;
12152             } else {
12153               left = v2.left;
12154               v2.left = null;
12155               right = v2;
12156             }
12157           }
12158           return {
12159             left,
12160             right
12161           };
12162         }
12163         function merge2(left, right, comparator) {
12164           if (right === null)
12165             return left;
12166           if (left === null)
12167             return right;
12168           right = splay(left.key, right, comparator);
12169           right.left = left;
12170           return right;
12171         }
12172         function printRow(root3, prefix, isTail, out, printNode) {
12173           if (root3) {
12174             out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n");
12175             var indent = prefix + (isTail ? "    " : "\u2502   ");
12176             if (root3.left)
12177               printRow(root3.left, indent, false, out, printNode);
12178             if (root3.right)
12179               printRow(root3.right, indent, true, out, printNode);
12180           }
12181         }
12182         var Tree = (
12183           /** @class */
12184           function() {
12185             function Tree2(comparator) {
12186               if (comparator === void 0) {
12187                 comparator = DEFAULT_COMPARE;
12188               }
12189               this._root = null;
12190               this._size = 0;
12191               this._comparator = comparator;
12192             }
12193             Tree2.prototype.insert = function(key, data) {
12194               this._size++;
12195               return this._root = insert(key, data, this._root, this._comparator);
12196             };
12197             Tree2.prototype.add = function(key, data) {
12198               var node = new Node(key, data);
12199               if (this._root === null) {
12200                 node.left = node.right = null;
12201                 this._size++;
12202                 this._root = node;
12203               }
12204               var comparator = this._comparator;
12205               var t2 = splay(key, this._root, comparator);
12206               var cmp2 = comparator(key, t2.key);
12207               if (cmp2 === 0)
12208                 this._root = t2;
12209               else {
12210                 if (cmp2 < 0) {
12211                   node.left = t2.left;
12212                   node.right = t2;
12213                   t2.left = null;
12214                 } else if (cmp2 > 0) {
12215                   node.right = t2.right;
12216                   node.left = t2;
12217                   t2.right = null;
12218                 }
12219                 this._size++;
12220                 this._root = node;
12221               }
12222               return this._root;
12223             };
12224             Tree2.prototype.remove = function(key) {
12225               this._root = this._remove(key, this._root, this._comparator);
12226             };
12227             Tree2.prototype._remove = function(i3, t2, comparator) {
12228               var x2;
12229               if (t2 === null)
12230                 return null;
12231               t2 = splay(i3, t2, comparator);
12232               var cmp2 = comparator(i3, t2.key);
12233               if (cmp2 === 0) {
12234                 if (t2.left === null) {
12235                   x2 = t2.right;
12236                 } else {
12237                   x2 = splay(i3, t2.left, comparator);
12238                   x2.right = t2.right;
12239                 }
12240                 this._size--;
12241                 return x2;
12242               }
12243               return t2;
12244             };
12245             Tree2.prototype.pop = function() {
12246               var node = this._root;
12247               if (node) {
12248                 while (node.left)
12249                   node = node.left;
12250                 this._root = splay(node.key, this._root, this._comparator);
12251                 this._root = this._remove(node.key, this._root, this._comparator);
12252                 return {
12253                   key: node.key,
12254                   data: node.data
12255                 };
12256               }
12257               return null;
12258             };
12259             Tree2.prototype.findStatic = function(key) {
12260               var current = this._root;
12261               var compare2 = this._comparator;
12262               while (current) {
12263                 var cmp2 = compare2(key, current.key);
12264                 if (cmp2 === 0)
12265                   return current;
12266                 else if (cmp2 < 0)
12267                   current = current.left;
12268                 else
12269                   current = current.right;
12270               }
12271               return null;
12272             };
12273             Tree2.prototype.find = function(key) {
12274               if (this._root) {
12275                 this._root = splay(key, this._root, this._comparator);
12276                 if (this._comparator(key, this._root.key) !== 0)
12277                   return null;
12278               }
12279               return this._root;
12280             };
12281             Tree2.prototype.contains = function(key) {
12282               var current = this._root;
12283               var compare2 = this._comparator;
12284               while (current) {
12285                 var cmp2 = compare2(key, current.key);
12286                 if (cmp2 === 0)
12287                   return true;
12288                 else if (cmp2 < 0)
12289                   current = current.left;
12290                 else
12291                   current = current.right;
12292               }
12293               return false;
12294             };
12295             Tree2.prototype.forEach = function(visitor, ctx) {
12296               var current = this._root;
12297               var Q2 = [];
12298               var done = false;
12299               while (!done) {
12300                 if (current !== null) {
12301                   Q2.push(current);
12302                   current = current.left;
12303                 } else {
12304                   if (Q2.length !== 0) {
12305                     current = Q2.pop();
12306                     visitor.call(ctx, current);
12307                     current = current.right;
12308                   } else
12309                     done = true;
12310                 }
12311               }
12312               return this;
12313             };
12314             Tree2.prototype.range = function(low, high, fn, ctx) {
12315               var Q2 = [];
12316               var compare2 = this._comparator;
12317               var node = this._root;
12318               var cmp2;
12319               while (Q2.length !== 0 || node) {
12320                 if (node) {
12321                   Q2.push(node);
12322                   node = node.left;
12323                 } else {
12324                   node = Q2.pop();
12325                   cmp2 = compare2(node.key, high);
12326                   if (cmp2 > 0) {
12327                     break;
12328                   } else if (compare2(node.key, low) >= 0) {
12329                     if (fn.call(ctx, node))
12330                       return this;
12331                   }
12332                   node = node.right;
12333                 }
12334               }
12335               return this;
12336             };
12337             Tree2.prototype.keys = function() {
12338               var keys2 = [];
12339               this.forEach(function(_a2) {
12340                 var key = _a2.key;
12341                 return keys2.push(key);
12342               });
12343               return keys2;
12344             };
12345             Tree2.prototype.values = function() {
12346               var values = [];
12347               this.forEach(function(_a2) {
12348                 var data = _a2.data;
12349                 return values.push(data);
12350               });
12351               return values;
12352             };
12353             Tree2.prototype.min = function() {
12354               if (this._root)
12355                 return this.minNode(this._root).key;
12356               return null;
12357             };
12358             Tree2.prototype.max = function() {
12359               if (this._root)
12360                 return this.maxNode(this._root).key;
12361               return null;
12362             };
12363             Tree2.prototype.minNode = function(t2) {
12364               if (t2 === void 0) {
12365                 t2 = this._root;
12366               }
12367               if (t2)
12368                 while (t2.left)
12369                   t2 = t2.left;
12370               return t2;
12371             };
12372             Tree2.prototype.maxNode = function(t2) {
12373               if (t2 === void 0) {
12374                 t2 = this._root;
12375               }
12376               if (t2)
12377                 while (t2.right)
12378                   t2 = t2.right;
12379               return t2;
12380             };
12381             Tree2.prototype.at = function(index2) {
12382               var current = this._root;
12383               var done = false;
12384               var i3 = 0;
12385               var Q2 = [];
12386               while (!done) {
12387                 if (current) {
12388                   Q2.push(current);
12389                   current = current.left;
12390                 } else {
12391                   if (Q2.length > 0) {
12392                     current = Q2.pop();
12393                     if (i3 === index2)
12394                       return current;
12395                     i3++;
12396                     current = current.right;
12397                   } else
12398                     done = true;
12399                 }
12400               }
12401               return null;
12402             };
12403             Tree2.prototype.next = function(d2) {
12404               var root3 = this._root;
12405               var successor = null;
12406               if (d2.right) {
12407                 successor = d2.right;
12408                 while (successor.left)
12409                   successor = successor.left;
12410                 return successor;
12411               }
12412               var comparator = this._comparator;
12413               while (root3) {
12414                 var cmp2 = comparator(d2.key, root3.key);
12415                 if (cmp2 === 0)
12416                   break;
12417                 else if (cmp2 < 0) {
12418                   successor = root3;
12419                   root3 = root3.left;
12420                 } else
12421                   root3 = root3.right;
12422               }
12423               return successor;
12424             };
12425             Tree2.prototype.prev = function(d2) {
12426               var root3 = this._root;
12427               var predecessor = null;
12428               if (d2.left !== null) {
12429                 predecessor = d2.left;
12430                 while (predecessor.right)
12431                   predecessor = predecessor.right;
12432                 return predecessor;
12433               }
12434               var comparator = this._comparator;
12435               while (root3) {
12436                 var cmp2 = comparator(d2.key, root3.key);
12437                 if (cmp2 === 0)
12438                   break;
12439                 else if (cmp2 < 0)
12440                   root3 = root3.left;
12441                 else {
12442                   predecessor = root3;
12443                   root3 = root3.right;
12444                 }
12445               }
12446               return predecessor;
12447             };
12448             Tree2.prototype.clear = function() {
12449               this._root = null;
12450               this._size = 0;
12451               return this;
12452             };
12453             Tree2.prototype.toList = function() {
12454               return toList(this._root);
12455             };
12456             Tree2.prototype.load = function(keys2, values, presort) {
12457               if (values === void 0) {
12458                 values = [];
12459               }
12460               if (presort === void 0) {
12461                 presort = false;
12462               }
12463               var size = keys2.length;
12464               var comparator = this._comparator;
12465               if (presort)
12466                 sort(keys2, values, 0, size - 1, comparator);
12467               if (this._root === null) {
12468                 this._root = loadRecursive(keys2, values, 0, size);
12469                 this._size = size;
12470               } else {
12471                 var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator);
12472                 size = this._size + size;
12473                 this._root = sortedListToBST({
12474                   head: mergedList
12475                 }, 0, size);
12476               }
12477               return this;
12478             };
12479             Tree2.prototype.isEmpty = function() {
12480               return this._root === null;
12481             };
12482             Object.defineProperty(Tree2.prototype, "size", {
12483               get: function() {
12484                 return this._size;
12485               },
12486               enumerable: true,
12487               configurable: true
12488             });
12489             Object.defineProperty(Tree2.prototype, "root", {
12490               get: function() {
12491                 return this._root;
12492               },
12493               enumerable: true,
12494               configurable: true
12495             });
12496             Tree2.prototype.toString = function(printNode) {
12497               if (printNode === void 0) {
12498                 printNode = function(n3) {
12499                   return String(n3.key);
12500                 };
12501               }
12502               var out = [];
12503               printRow(this._root, "", true, function(v2) {
12504                 return out.push(v2);
12505               }, printNode);
12506               return out.join("");
12507             };
12508             Tree2.prototype.update = function(key, newKey, newData) {
12509               var comparator = this._comparator;
12510               var _a2 = split(key, this._root, comparator), left = _a2.left, right = _a2.right;
12511               if (comparator(key, newKey) < 0) {
12512                 right = insert(newKey, newData, right, comparator);
12513               } else {
12514                 left = insert(newKey, newData, left, comparator);
12515               }
12516               this._root = merge2(left, right, comparator);
12517             };
12518             Tree2.prototype.split = function(key) {
12519               return split(key, this._root, this._comparator);
12520             };
12521             Tree2.prototype[Symbol.iterator] = function() {
12522               var current, Q2, done;
12523               return __generator(this, function(_a2) {
12524                 switch (_a2.label) {
12525                   case 0:
12526                     current = this._root;
12527                     Q2 = [];
12528                     done = false;
12529                     _a2.label = 1;
12530                   case 1:
12531                     if (!!done)
12532                       return [3, 6];
12533                     if (!(current !== null))
12534                       return [3, 2];
12535                     Q2.push(current);
12536                     current = current.left;
12537                     return [3, 5];
12538                   case 2:
12539                     if (!(Q2.length !== 0))
12540                       return [3, 4];
12541                     current = Q2.pop();
12542                     return [4, current];
12543                   case 3:
12544                     _a2.sent();
12545                     current = current.right;
12546                     return [3, 5];
12547                   case 4:
12548                     done = true;
12549                     _a2.label = 5;
12550                   case 5:
12551                     return [3, 1];
12552                   case 6:
12553                     return [
12554                       2
12555                       /*return*/
12556                     ];
12557                 }
12558               });
12559             };
12560             return Tree2;
12561           }()
12562         );
12563         function loadRecursive(keys2, values, start2, end) {
12564           var size = end - start2;
12565           if (size > 0) {
12566             var middle = start2 + Math.floor(size / 2);
12567             var key = keys2[middle];
12568             var data = values[middle];
12569             var node = new Node(key, data);
12570             node.left = loadRecursive(keys2, values, start2, middle);
12571             node.right = loadRecursive(keys2, values, middle + 1, end);
12572             return node;
12573           }
12574           return null;
12575         }
12576         function createList(keys2, values) {
12577           var head = new Node(null, null);
12578           var p2 = head;
12579           for (var i3 = 0; i3 < keys2.length; i3++) {
12580             p2 = p2.next = new Node(keys2[i3], values[i3]);
12581           }
12582           p2.next = null;
12583           return head.next;
12584         }
12585         function toList(root3) {
12586           var current = root3;
12587           var Q2 = [];
12588           var done = false;
12589           var head = new Node(null, null);
12590           var p2 = head;
12591           while (!done) {
12592             if (current) {
12593               Q2.push(current);
12594               current = current.left;
12595             } else {
12596               if (Q2.length > 0) {
12597                 current = p2 = p2.next = Q2.pop();
12598                 current = current.right;
12599               } else
12600                 done = true;
12601             }
12602           }
12603           p2.next = null;
12604           return head.next;
12605         }
12606         function sortedListToBST(list2, start2, end) {
12607           var size = end - start2;
12608           if (size > 0) {
12609             var middle = start2 + Math.floor(size / 2);
12610             var left = sortedListToBST(list2, start2, middle);
12611             var root3 = list2.head;
12612             root3.left = left;
12613             list2.head = list2.head.next;
12614             root3.right = sortedListToBST(list2, middle + 1, end);
12615             return root3;
12616           }
12617           return null;
12618         }
12619         function mergeLists(l1, l2, compare2) {
12620           var head = new Node(null, null);
12621           var p2 = head;
12622           var p1 = l1;
12623           var p22 = l2;
12624           while (p1 !== null && p22 !== null) {
12625             if (compare2(p1.key, p22.key) < 0) {
12626               p2.next = p1;
12627               p1 = p1.next;
12628             } else {
12629               p2.next = p22;
12630               p22 = p22.next;
12631             }
12632             p2 = p2.next;
12633           }
12634           if (p1 !== null) {
12635             p2.next = p1;
12636           } else if (p22 !== null) {
12637             p2.next = p22;
12638           }
12639           return head.next;
12640         }
12641         function sort(keys2, values, left, right, compare2) {
12642           if (left >= right)
12643             return;
12644           var pivot = keys2[left + right >> 1];
12645           var i3 = left - 1;
12646           var j2 = right + 1;
12647           while (true) {
12648             do
12649               i3++;
12650             while (compare2(keys2[i3], pivot) < 0);
12651             do
12652               j2--;
12653             while (compare2(keys2[j2], pivot) > 0);
12654             if (i3 >= j2)
12655               break;
12656             var tmp = keys2[i3];
12657             keys2[i3] = keys2[j2];
12658             keys2[j2] = tmp;
12659             tmp = values[i3];
12660             values[i3] = values[j2];
12661             values[j2] = tmp;
12662           }
12663           sort(keys2, values, left, j2, compare2);
12664           sort(keys2, values, j2 + 1, right, compare2);
12665         }
12666         const isInBbox2 = (bbox2, point2) => {
12667           return bbox2.ll.x <= point2.x && point2.x <= bbox2.ur.x && bbox2.ll.y <= point2.y && point2.y <= bbox2.ur.y;
12668         };
12669         const getBboxOverlap2 = (b1, b2) => {
12670           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)
12671             return null;
12672           const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
12673           const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
12674           const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
12675           const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
12676           return {
12677             ll: {
12678               x: lowerX,
12679               y: lowerY
12680             },
12681             ur: {
12682               x: upperX,
12683               y: upperY
12684             }
12685           };
12686         };
12687         let epsilon$1 = Number.EPSILON;
12688         if (epsilon$1 === void 0)
12689           epsilon$1 = Math.pow(2, -52);
12690         const EPSILON_SQ = epsilon$1 * epsilon$1;
12691         const cmp = (a2, b2) => {
12692           if (-epsilon$1 < a2 && a2 < epsilon$1) {
12693             if (-epsilon$1 < b2 && b2 < epsilon$1) {
12694               return 0;
12695             }
12696           }
12697           const ab = a2 - b2;
12698           if (ab * ab < EPSILON_SQ * a2 * b2) {
12699             return 0;
12700           }
12701           return a2 < b2 ? -1 : 1;
12702         };
12703         class PtRounder {
12704           constructor() {
12705             this.reset();
12706           }
12707           reset() {
12708             this.xRounder = new CoordRounder();
12709             this.yRounder = new CoordRounder();
12710           }
12711           round(x2, y2) {
12712             return {
12713               x: this.xRounder.round(x2),
12714               y: this.yRounder.round(y2)
12715             };
12716           }
12717         }
12718         class CoordRounder {
12719           constructor() {
12720             this.tree = new Tree();
12721             this.round(0);
12722           }
12723           // Note: this can rounds input values backwards or forwards.
12724           //       You might ask, why not restrict this to just rounding
12725           //       forwards? Wouldn't that allow left endpoints to always
12726           //       remain left endpoints during splitting (never change to
12727           //       right). No - it wouldn't, because we snap intersections
12728           //       to endpoints (to establish independence from the segment
12729           //       angle for t-intersections).
12730           round(coord2) {
12731             const node = this.tree.add(coord2);
12732             const prevNode = this.tree.prev(node);
12733             if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
12734               this.tree.remove(coord2);
12735               return prevNode.key;
12736             }
12737             const nextNode = this.tree.next(node);
12738             if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
12739               this.tree.remove(coord2);
12740               return nextNode.key;
12741             }
12742             return coord2;
12743           }
12744         }
12745         const rounder = new PtRounder();
12746         const epsilon3 = 11102230246251565e-32;
12747         const splitter = 134217729;
12748         const resulterrbound = (3 + 8 * epsilon3) * epsilon3;
12749         function sum(elen, e3, flen, f2, h2) {
12750           let Q2, Qnew, hh, bvirt;
12751           let enow = e3[0];
12752           let fnow = f2[0];
12753           let eindex = 0;
12754           let findex = 0;
12755           if (fnow > enow === fnow > -enow) {
12756             Q2 = enow;
12757             enow = e3[++eindex];
12758           } else {
12759             Q2 = fnow;
12760             fnow = f2[++findex];
12761           }
12762           let hindex = 0;
12763           if (eindex < elen && findex < flen) {
12764             if (fnow > enow === fnow > -enow) {
12765               Qnew = enow + Q2;
12766               hh = Q2 - (Qnew - enow);
12767               enow = e3[++eindex];
12768             } else {
12769               Qnew = fnow + Q2;
12770               hh = Q2 - (Qnew - fnow);
12771               fnow = f2[++findex];
12772             }
12773             Q2 = Qnew;
12774             if (hh !== 0) {
12775               h2[hindex++] = hh;
12776             }
12777             while (eindex < elen && findex < flen) {
12778               if (fnow > enow === fnow > -enow) {
12779                 Qnew = Q2 + enow;
12780                 bvirt = Qnew - Q2;
12781                 hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
12782                 enow = e3[++eindex];
12783               } else {
12784                 Qnew = Q2 + fnow;
12785                 bvirt = Qnew - Q2;
12786                 hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
12787                 fnow = f2[++findex];
12788               }
12789               Q2 = Qnew;
12790               if (hh !== 0) {
12791                 h2[hindex++] = hh;
12792               }
12793             }
12794           }
12795           while (eindex < elen) {
12796             Qnew = Q2 + enow;
12797             bvirt = Qnew - Q2;
12798             hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
12799             enow = e3[++eindex];
12800             Q2 = Qnew;
12801             if (hh !== 0) {
12802               h2[hindex++] = hh;
12803             }
12804           }
12805           while (findex < flen) {
12806             Qnew = Q2 + fnow;
12807             bvirt = Qnew - Q2;
12808             hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
12809             fnow = f2[++findex];
12810             Q2 = Qnew;
12811             if (hh !== 0) {
12812               h2[hindex++] = hh;
12813             }
12814           }
12815           if (Q2 !== 0 || hindex === 0) {
12816             h2[hindex++] = Q2;
12817           }
12818           return hindex;
12819         }
12820         function estimate(elen, e3) {
12821           let Q2 = e3[0];
12822           for (let i3 = 1; i3 < elen; i3++)
12823             Q2 += e3[i3];
12824           return Q2;
12825         }
12826         function vec(n3) {
12827           return new Float64Array(n3);
12828         }
12829         const ccwerrboundA = (3 + 16 * epsilon3) * epsilon3;
12830         const ccwerrboundB = (2 + 12 * epsilon3) * epsilon3;
12831         const ccwerrboundC = (9 + 64 * epsilon3) * epsilon3 * epsilon3;
12832         const B2 = vec(4);
12833         const C1 = vec(8);
12834         const C2 = vec(12);
12835         const D2 = vec(16);
12836         const u2 = vec(4);
12837         function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
12838           let acxtail, acytail, bcxtail, bcytail;
12839           let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
12840           const acx = ax - cx;
12841           const bcx = bx - cx;
12842           const acy = ay - cy;
12843           const bcy = by - cy;
12844           s1 = acx * bcy;
12845           c2 = splitter * acx;
12846           ahi = c2 - (c2 - acx);
12847           alo = acx - ahi;
12848           c2 = splitter * bcy;
12849           bhi = c2 - (c2 - bcy);
12850           blo = bcy - bhi;
12851           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12852           t1 = acy * bcx;
12853           c2 = splitter * acy;
12854           ahi = c2 - (c2 - acy);
12855           alo = acy - ahi;
12856           c2 = splitter * bcx;
12857           bhi = c2 - (c2 - bcx);
12858           blo = bcx - bhi;
12859           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12860           _i = s0 - t0;
12861           bvirt = s0 - _i;
12862           B2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12863           _j = s1 + _i;
12864           bvirt = _j - s1;
12865           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12866           _i = _0 - t1;
12867           bvirt = _0 - _i;
12868           B2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12869           u3 = _j + _i;
12870           bvirt = u3 - _j;
12871           B2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12872           B2[3] = u3;
12873           let det = estimate(4, B2);
12874           let errbound = ccwerrboundB * detsum;
12875           if (det >= errbound || -det >= errbound) {
12876             return det;
12877           }
12878           bvirt = ax - acx;
12879           acxtail = ax - (acx + bvirt) + (bvirt - cx);
12880           bvirt = bx - bcx;
12881           bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
12882           bvirt = ay - acy;
12883           acytail = ay - (acy + bvirt) + (bvirt - cy);
12884           bvirt = by - bcy;
12885           bcytail = by - (bcy + bvirt) + (bvirt - cy);
12886           if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
12887             return det;
12888           }
12889           errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
12890           det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
12891           if (det >= errbound || -det >= errbound)
12892             return det;
12893           s1 = acxtail * bcy;
12894           c2 = splitter * acxtail;
12895           ahi = c2 - (c2 - acxtail);
12896           alo = acxtail - ahi;
12897           c2 = splitter * bcy;
12898           bhi = c2 - (c2 - bcy);
12899           blo = bcy - bhi;
12900           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12901           t1 = acytail * bcx;
12902           c2 = splitter * acytail;
12903           ahi = c2 - (c2 - acytail);
12904           alo = acytail - ahi;
12905           c2 = splitter * bcx;
12906           bhi = c2 - (c2 - bcx);
12907           blo = bcx - bhi;
12908           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12909           _i = s0 - t0;
12910           bvirt = s0 - _i;
12911           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12912           _j = s1 + _i;
12913           bvirt = _j - s1;
12914           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12915           _i = _0 - t1;
12916           bvirt = _0 - _i;
12917           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12918           u3 = _j + _i;
12919           bvirt = u3 - _j;
12920           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12921           u2[3] = u3;
12922           const C1len = sum(4, B2, 4, u2, C1);
12923           s1 = acx * bcytail;
12924           c2 = splitter * acx;
12925           ahi = c2 - (c2 - acx);
12926           alo = acx - ahi;
12927           c2 = splitter * bcytail;
12928           bhi = c2 - (c2 - bcytail);
12929           blo = bcytail - bhi;
12930           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12931           t1 = acy * bcxtail;
12932           c2 = splitter * acy;
12933           ahi = c2 - (c2 - acy);
12934           alo = acy - ahi;
12935           c2 = splitter * bcxtail;
12936           bhi = c2 - (c2 - bcxtail);
12937           blo = bcxtail - bhi;
12938           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12939           _i = s0 - t0;
12940           bvirt = s0 - _i;
12941           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12942           _j = s1 + _i;
12943           bvirt = _j - s1;
12944           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12945           _i = _0 - t1;
12946           bvirt = _0 - _i;
12947           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12948           u3 = _j + _i;
12949           bvirt = u3 - _j;
12950           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12951           u2[3] = u3;
12952           const C2len = sum(C1len, C1, 4, u2, C2);
12953           s1 = acxtail * bcytail;
12954           c2 = splitter * acxtail;
12955           ahi = c2 - (c2 - acxtail);
12956           alo = acxtail - ahi;
12957           c2 = splitter * bcytail;
12958           bhi = c2 - (c2 - bcytail);
12959           blo = bcytail - bhi;
12960           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12961           t1 = acytail * bcxtail;
12962           c2 = splitter * acytail;
12963           ahi = c2 - (c2 - acytail);
12964           alo = acytail - ahi;
12965           c2 = splitter * bcxtail;
12966           bhi = c2 - (c2 - bcxtail);
12967           blo = bcxtail - bhi;
12968           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12969           _i = s0 - t0;
12970           bvirt = s0 - _i;
12971           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12972           _j = s1 + _i;
12973           bvirt = _j - s1;
12974           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12975           _i = _0 - t1;
12976           bvirt = _0 - _i;
12977           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12978           u3 = _j + _i;
12979           bvirt = u3 - _j;
12980           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12981           u2[3] = u3;
12982           const Dlen = sum(C2len, C2, 4, u2, D2);
12983           return D2[Dlen - 1];
12984         }
12985         function orient2d(ax, ay, bx, by, cx, cy) {
12986           const detleft = (ay - cy) * (bx - cx);
12987           const detright = (ax - cx) * (by - cy);
12988           const det = detleft - detright;
12989           const detsum = Math.abs(detleft + detright);
12990           if (Math.abs(det) >= ccwerrboundA * detsum)
12991             return det;
12992           return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
12993         }
12994         const crossProduct2 = (a2, b2) => a2.x * b2.y - a2.y * b2.x;
12995         const dotProduct2 = (a2, b2) => a2.x * b2.x + a2.y * b2.y;
12996         const compareVectorAngles = (basePt, endPt1, endPt2) => {
12997           const res = orient2d(basePt.x, basePt.y, endPt1.x, endPt1.y, endPt2.x, endPt2.y);
12998           if (res > 0)
12999             return -1;
13000           if (res < 0)
13001             return 1;
13002           return 0;
13003         };
13004         const length2 = (v2) => Math.sqrt(dotProduct2(v2, v2));
13005         const sineOfAngle2 = (pShared, pBase, pAngle) => {
13006           const vBase = {
13007             x: pBase.x - pShared.x,
13008             y: pBase.y - pShared.y
13009           };
13010           const vAngle = {
13011             x: pAngle.x - pShared.x,
13012             y: pAngle.y - pShared.y
13013           };
13014           return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
13015         };
13016         const cosineOfAngle2 = (pShared, pBase, pAngle) => {
13017           const vBase = {
13018             x: pBase.x - pShared.x,
13019             y: pBase.y - pShared.y
13020           };
13021           const vAngle = {
13022             x: pAngle.x - pShared.x,
13023             y: pAngle.y - pShared.y
13024           };
13025           return dotProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
13026         };
13027         const horizontalIntersection2 = (pt2, v2, y2) => {
13028           if (v2.y === 0)
13029             return null;
13030           return {
13031             x: pt2.x + v2.x / v2.y * (y2 - pt2.y),
13032             y: y2
13033           };
13034         };
13035         const verticalIntersection2 = (pt2, v2, x2) => {
13036           if (v2.x === 0)
13037             return null;
13038           return {
13039             x: x2,
13040             y: pt2.y + v2.y / v2.x * (x2 - pt2.x)
13041           };
13042         };
13043         const intersection$1 = (pt1, v1, pt2, v2) => {
13044           if (v1.x === 0)
13045             return verticalIntersection2(pt2, v2, pt1.x);
13046           if (v2.x === 0)
13047             return verticalIntersection2(pt1, v1, pt2.x);
13048           if (v1.y === 0)
13049             return horizontalIntersection2(pt2, v2, pt1.y);
13050           if (v2.y === 0)
13051             return horizontalIntersection2(pt1, v1, pt2.y);
13052           const kross = crossProduct2(v1, v2);
13053           if (kross == 0)
13054             return null;
13055           const ve2 = {
13056             x: pt2.x - pt1.x,
13057             y: pt2.y - pt1.y
13058           };
13059           const d1 = crossProduct2(ve2, v1) / kross;
13060           const d2 = crossProduct2(ve2, v2) / kross;
13061           const x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
13062           const y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
13063           const x3 = (x12 + x2) / 2;
13064           const y3 = (y12 + y2) / 2;
13065           return {
13066             x: x3,
13067             y: y3
13068           };
13069         };
13070         class SweepEvent2 {
13071           // for ordering sweep events in the sweep event queue
13072           static compare(a2, b2) {
13073             const ptCmp = SweepEvent2.comparePoints(a2.point, b2.point);
13074             if (ptCmp !== 0)
13075               return ptCmp;
13076             if (a2.point !== b2.point)
13077               a2.link(b2);
13078             if (a2.isLeft !== b2.isLeft)
13079               return a2.isLeft ? 1 : -1;
13080             return Segment2.compare(a2.segment, b2.segment);
13081           }
13082           // for ordering points in sweep line order
13083           static comparePoints(aPt, bPt) {
13084             if (aPt.x < bPt.x)
13085               return -1;
13086             if (aPt.x > bPt.x)
13087               return 1;
13088             if (aPt.y < bPt.y)
13089               return -1;
13090             if (aPt.y > bPt.y)
13091               return 1;
13092             return 0;
13093           }
13094           // Warning: 'point' input will be modified and re-used (for performance)
13095           constructor(point2, isLeft) {
13096             if (point2.events === void 0)
13097               point2.events = [this];
13098             else
13099               point2.events.push(this);
13100             this.point = point2;
13101             this.isLeft = isLeft;
13102           }
13103           link(other) {
13104             if (other.point === this.point) {
13105               throw new Error("Tried to link already linked events");
13106             }
13107             const otherEvents = other.point.events;
13108             for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
13109               const evt = otherEvents[i3];
13110               this.point.events.push(evt);
13111               evt.point = this.point;
13112             }
13113             this.checkForConsuming();
13114           }
13115           /* Do a pass over our linked events and check to see if any pair
13116            * of segments match, and should be consumed. */
13117           checkForConsuming() {
13118             const numEvents = this.point.events.length;
13119             for (let i3 = 0; i3 < numEvents; i3++) {
13120               const evt1 = this.point.events[i3];
13121               if (evt1.segment.consumedBy !== void 0)
13122                 continue;
13123               for (let j2 = i3 + 1; j2 < numEvents; j2++) {
13124                 const evt2 = this.point.events[j2];
13125                 if (evt2.consumedBy !== void 0)
13126                   continue;
13127                 if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
13128                   continue;
13129                 evt1.segment.consume(evt2.segment);
13130               }
13131             }
13132           }
13133           getAvailableLinkedEvents() {
13134             const events = [];
13135             for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
13136               const evt = this.point.events[i3];
13137               if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
13138                 events.push(evt);
13139               }
13140             }
13141             return events;
13142           }
13143           /**
13144            * Returns a comparator function for sorting linked events that will
13145            * favor the event that will give us the smallest left-side angle.
13146            * All ring construction starts as low as possible heading to the right,
13147            * so by always turning left as sharp as possible we'll get polygons
13148            * without uncessary loops & holes.
13149            *
13150            * The comparator function has a compute cache such that it avoids
13151            * re-computing already-computed values.
13152            */
13153           getLeftmostComparator(baseEvent) {
13154             const cache = /* @__PURE__ */ new Map();
13155             const fillCache = (linkedEvent) => {
13156               const nextEvent = linkedEvent.otherSE;
13157               cache.set(linkedEvent, {
13158                 sine: sineOfAngle2(this.point, baseEvent.point, nextEvent.point),
13159                 cosine: cosineOfAngle2(this.point, baseEvent.point, nextEvent.point)
13160               });
13161             };
13162             return (a2, b2) => {
13163               if (!cache.has(a2))
13164                 fillCache(a2);
13165               if (!cache.has(b2))
13166                 fillCache(b2);
13167               const {
13168                 sine: asine,
13169                 cosine: acosine
13170               } = cache.get(a2);
13171               const {
13172                 sine: bsine,
13173                 cosine: bcosine
13174               } = cache.get(b2);
13175               if (asine >= 0 && bsine >= 0) {
13176                 if (acosine < bcosine)
13177                   return 1;
13178                 if (acosine > bcosine)
13179                   return -1;
13180                 return 0;
13181               }
13182               if (asine < 0 && bsine < 0) {
13183                 if (acosine < bcosine)
13184                   return -1;
13185                 if (acosine > bcosine)
13186                   return 1;
13187                 return 0;
13188               }
13189               if (bsine < asine)
13190                 return -1;
13191               if (bsine > asine)
13192                 return 1;
13193               return 0;
13194             };
13195           }
13196         }
13197         let segmentId2 = 0;
13198         class Segment2 {
13199           /* This compare() function is for ordering segments in the sweep
13200            * line tree, and does so according to the following criteria:
13201            *
13202            * Consider the vertical line that lies an infinestimal step to the
13203            * right of the right-more of the two left endpoints of the input
13204            * segments. Imagine slowly moving a point up from negative infinity
13205            * in the increasing y direction. Which of the two segments will that
13206            * point intersect first? That segment comes 'before' the other one.
13207            *
13208            * If neither segment would be intersected by such a line, (if one
13209            * or more of the segments are vertical) then the line to be considered
13210            * is directly on the right-more of the two left inputs.
13211            */
13212           static compare(a2, b2) {
13213             const alx = a2.leftSE.point.x;
13214             const blx = b2.leftSE.point.x;
13215             const arx = a2.rightSE.point.x;
13216             const brx = b2.rightSE.point.x;
13217             if (brx < alx)
13218               return 1;
13219             if (arx < blx)
13220               return -1;
13221             const aly = a2.leftSE.point.y;
13222             const bly = b2.leftSE.point.y;
13223             const ary = a2.rightSE.point.y;
13224             const bry = b2.rightSE.point.y;
13225             if (alx < blx) {
13226               if (bly < aly && bly < ary)
13227                 return 1;
13228               if (bly > aly && bly > ary)
13229                 return -1;
13230               const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
13231               if (aCmpBLeft < 0)
13232                 return 1;
13233               if (aCmpBLeft > 0)
13234                 return -1;
13235               const bCmpARight = b2.comparePoint(a2.rightSE.point);
13236               if (bCmpARight !== 0)
13237                 return bCmpARight;
13238               return -1;
13239             }
13240             if (alx > blx) {
13241               if (aly < bly && aly < bry)
13242                 return -1;
13243               if (aly > bly && aly > bry)
13244                 return 1;
13245               const bCmpALeft = b2.comparePoint(a2.leftSE.point);
13246               if (bCmpALeft !== 0)
13247                 return bCmpALeft;
13248               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
13249               if (aCmpBRight < 0)
13250                 return 1;
13251               if (aCmpBRight > 0)
13252                 return -1;
13253               return 1;
13254             }
13255             if (aly < bly)
13256               return -1;
13257             if (aly > bly)
13258               return 1;
13259             if (arx < brx) {
13260               const bCmpARight = b2.comparePoint(a2.rightSE.point);
13261               if (bCmpARight !== 0)
13262                 return bCmpARight;
13263             }
13264             if (arx > brx) {
13265               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
13266               if (aCmpBRight < 0)
13267                 return 1;
13268               if (aCmpBRight > 0)
13269                 return -1;
13270             }
13271             if (arx !== brx) {
13272               const ay = ary - aly;
13273               const ax = arx - alx;
13274               const by = bry - bly;
13275               const bx = brx - blx;
13276               if (ay > ax && by < bx)
13277                 return 1;
13278               if (ay < ax && by > bx)
13279                 return -1;
13280             }
13281             if (arx > brx)
13282               return 1;
13283             if (arx < brx)
13284               return -1;
13285             if (ary < bry)
13286               return -1;
13287             if (ary > bry)
13288               return 1;
13289             if (a2.id < b2.id)
13290               return -1;
13291             if (a2.id > b2.id)
13292               return 1;
13293             return 0;
13294           }
13295           /* Warning: a reference to ringWindings input will be stored,
13296            *  and possibly will be later modified */
13297           constructor(leftSE, rightSE, rings, windings) {
13298             this.id = ++segmentId2;
13299             this.leftSE = leftSE;
13300             leftSE.segment = this;
13301             leftSE.otherSE = rightSE;
13302             this.rightSE = rightSE;
13303             rightSE.segment = this;
13304             rightSE.otherSE = leftSE;
13305             this.rings = rings;
13306             this.windings = windings;
13307           }
13308           static fromRing(pt1, pt2, ring) {
13309             let leftPt, rightPt, winding;
13310             const cmpPts = SweepEvent2.comparePoints(pt1, pt2);
13311             if (cmpPts < 0) {
13312               leftPt = pt1;
13313               rightPt = pt2;
13314               winding = 1;
13315             } else if (cmpPts > 0) {
13316               leftPt = pt2;
13317               rightPt = pt1;
13318               winding = -1;
13319             } else
13320               throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
13321             const leftSE = new SweepEvent2(leftPt, true);
13322             const rightSE = new SweepEvent2(rightPt, false);
13323             return new Segment2(leftSE, rightSE, [ring], [winding]);
13324           }
13325           /* When a segment is split, the rightSE is replaced with a new sweep event */
13326           replaceRightSE(newRightSE) {
13327             this.rightSE = newRightSE;
13328             this.rightSE.segment = this;
13329             this.rightSE.otherSE = this.leftSE;
13330             this.leftSE.otherSE = this.rightSE;
13331           }
13332           bbox() {
13333             const y12 = this.leftSE.point.y;
13334             const y2 = this.rightSE.point.y;
13335             return {
13336               ll: {
13337                 x: this.leftSE.point.x,
13338                 y: y12 < y2 ? y12 : y2
13339               },
13340               ur: {
13341                 x: this.rightSE.point.x,
13342                 y: y12 > y2 ? y12 : y2
13343               }
13344             };
13345           }
13346           /* A vector from the left point to the right */
13347           vector() {
13348             return {
13349               x: this.rightSE.point.x - this.leftSE.point.x,
13350               y: this.rightSE.point.y - this.leftSE.point.y
13351             };
13352           }
13353           isAnEndpoint(pt2) {
13354             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;
13355           }
13356           /* Compare this segment with a point.
13357            *
13358            * A point P is considered to be colinear to a segment if there
13359            * exists a distance D such that if we travel along the segment
13360            * from one * endpoint towards the other a distance D, we find
13361            * ourselves at point P.
13362            *
13363            * Return value indicates:
13364            *
13365            *   1: point lies above the segment (to the left of vertical)
13366            *   0: point is colinear to segment
13367            *  -1: point lies below the segment (to the right of vertical)
13368            */
13369           comparePoint(point2) {
13370             if (this.isAnEndpoint(point2))
13371               return 0;
13372             const lPt = this.leftSE.point;
13373             const rPt = this.rightSE.point;
13374             const v2 = this.vector();
13375             if (lPt.x === rPt.x) {
13376               if (point2.x === lPt.x)
13377                 return 0;
13378               return point2.x < lPt.x ? 1 : -1;
13379             }
13380             const yDist = (point2.y - lPt.y) / v2.y;
13381             const xFromYDist = lPt.x + yDist * v2.x;
13382             if (point2.x === xFromYDist)
13383               return 0;
13384             const xDist = (point2.x - lPt.x) / v2.x;
13385             const yFromXDist = lPt.y + xDist * v2.y;
13386             if (point2.y === yFromXDist)
13387               return 0;
13388             return point2.y < yFromXDist ? -1 : 1;
13389           }
13390           /**
13391            * Given another segment, returns the first non-trivial intersection
13392            * between the two segments (in terms of sweep line ordering), if it exists.
13393            *
13394            * A 'non-trivial' intersection is one that will cause one or both of the
13395            * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
13396            *
13397            *   * endpoint of segA with endpoint of segB --> trivial
13398            *   * endpoint of segA with point along segB --> non-trivial
13399            *   * endpoint of segB with point along segA --> non-trivial
13400            *   * point along segA with point along segB --> non-trivial
13401            *
13402            * If no non-trivial intersection exists, return null
13403            * Else, return null.
13404            */
13405           getIntersection(other) {
13406             const tBbox = this.bbox();
13407             const oBbox = other.bbox();
13408             const bboxOverlap = getBboxOverlap2(tBbox, oBbox);
13409             if (bboxOverlap === null)
13410               return null;
13411             const tlp = this.leftSE.point;
13412             const trp = this.rightSE.point;
13413             const olp = other.leftSE.point;
13414             const orp = other.rightSE.point;
13415             const touchesOtherLSE = isInBbox2(tBbox, olp) && this.comparePoint(olp) === 0;
13416             const touchesThisLSE = isInBbox2(oBbox, tlp) && other.comparePoint(tlp) === 0;
13417             const touchesOtherRSE = isInBbox2(tBbox, orp) && this.comparePoint(orp) === 0;
13418             const touchesThisRSE = isInBbox2(oBbox, trp) && other.comparePoint(trp) === 0;
13419             if (touchesThisLSE && touchesOtherLSE) {
13420               if (touchesThisRSE && !touchesOtherRSE)
13421                 return trp;
13422               if (!touchesThisRSE && touchesOtherRSE)
13423                 return orp;
13424               return null;
13425             }
13426             if (touchesThisLSE) {
13427               if (touchesOtherRSE) {
13428                 if (tlp.x === orp.x && tlp.y === orp.y)
13429                   return null;
13430               }
13431               return tlp;
13432             }
13433             if (touchesOtherLSE) {
13434               if (touchesThisRSE) {
13435                 if (trp.x === olp.x && trp.y === olp.y)
13436                   return null;
13437               }
13438               return olp;
13439             }
13440             if (touchesThisRSE && touchesOtherRSE)
13441               return null;
13442             if (touchesThisRSE)
13443               return trp;
13444             if (touchesOtherRSE)
13445               return orp;
13446             const pt2 = intersection$1(tlp, this.vector(), olp, other.vector());
13447             if (pt2 === null)
13448               return null;
13449             if (!isInBbox2(bboxOverlap, pt2))
13450               return null;
13451             return rounder.round(pt2.x, pt2.y);
13452           }
13453           /**
13454            * Split the given segment into multiple segments on the given points.
13455            *  * Each existing segment will retain its leftSE and a new rightSE will be
13456            *    generated for it.
13457            *  * A new segment will be generated which will adopt the original segment's
13458            *    rightSE, and a new leftSE will be generated for it.
13459            *  * If there are more than two points given to split on, new segments
13460            *    in the middle will be generated with new leftSE and rightSE's.
13461            *  * An array of the newly generated SweepEvents will be returned.
13462            *
13463            * Warning: input array of points is modified
13464            */
13465           split(point2) {
13466             const newEvents = [];
13467             const alreadyLinked = point2.events !== void 0;
13468             const newLeftSE = new SweepEvent2(point2, true);
13469             const newRightSE = new SweepEvent2(point2, false);
13470             const oldRightSE = this.rightSE;
13471             this.replaceRightSE(newRightSE);
13472             newEvents.push(newRightSE);
13473             newEvents.push(newLeftSE);
13474             const newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
13475             if (SweepEvent2.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
13476               newSeg.swapEvents();
13477             }
13478             if (SweepEvent2.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
13479               this.swapEvents();
13480             }
13481             if (alreadyLinked) {
13482               newLeftSE.checkForConsuming();
13483               newRightSE.checkForConsuming();
13484             }
13485             return newEvents;
13486           }
13487           /* Swap which event is left and right */
13488           swapEvents() {
13489             const tmpEvt = this.rightSE;
13490             this.rightSE = this.leftSE;
13491             this.leftSE = tmpEvt;
13492             this.leftSE.isLeft = true;
13493             this.rightSE.isLeft = false;
13494             for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
13495               this.windings[i3] *= -1;
13496             }
13497           }
13498           /* Consume another segment. We take their rings under our wing
13499            * and mark them as consumed. Use for perfectly overlapping segments */
13500           consume(other) {
13501             let consumer = this;
13502             let consumee = other;
13503             while (consumer.consumedBy)
13504               consumer = consumer.consumedBy;
13505             while (consumee.consumedBy)
13506               consumee = consumee.consumedBy;
13507             const cmp2 = Segment2.compare(consumer, consumee);
13508             if (cmp2 === 0)
13509               return;
13510             if (cmp2 > 0) {
13511               const tmp = consumer;
13512               consumer = consumee;
13513               consumee = tmp;
13514             }
13515             if (consumer.prev === consumee) {
13516               const tmp = consumer;
13517               consumer = consumee;
13518               consumee = tmp;
13519             }
13520             for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
13521               const ring = consumee.rings[i3];
13522               const winding = consumee.windings[i3];
13523               const index2 = consumer.rings.indexOf(ring);
13524               if (index2 === -1) {
13525                 consumer.rings.push(ring);
13526                 consumer.windings.push(winding);
13527               } else
13528                 consumer.windings[index2] += winding;
13529             }
13530             consumee.rings = null;
13531             consumee.windings = null;
13532             consumee.consumedBy = consumer;
13533             consumee.leftSE.consumedBy = consumer.leftSE;
13534             consumee.rightSE.consumedBy = consumer.rightSE;
13535           }
13536           /* The first segment previous segment chain that is in the result */
13537           prevInResult() {
13538             if (this._prevInResult !== void 0)
13539               return this._prevInResult;
13540             if (!this.prev)
13541               this._prevInResult = null;
13542             else if (this.prev.isInResult())
13543               this._prevInResult = this.prev;
13544             else
13545               this._prevInResult = this.prev.prevInResult();
13546             return this._prevInResult;
13547           }
13548           beforeState() {
13549             if (this._beforeState !== void 0)
13550               return this._beforeState;
13551             if (!this.prev)
13552               this._beforeState = {
13553                 rings: [],
13554                 windings: [],
13555                 multiPolys: []
13556               };
13557             else {
13558               const seg = this.prev.consumedBy || this.prev;
13559               this._beforeState = seg.afterState();
13560             }
13561             return this._beforeState;
13562           }
13563           afterState() {
13564             if (this._afterState !== void 0)
13565               return this._afterState;
13566             const beforeState = this.beforeState();
13567             this._afterState = {
13568               rings: beforeState.rings.slice(0),
13569               windings: beforeState.windings.slice(0),
13570               multiPolys: []
13571             };
13572             const ringsAfter = this._afterState.rings;
13573             const windingsAfter = this._afterState.windings;
13574             const mpsAfter = this._afterState.multiPolys;
13575             for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
13576               const ring = this.rings[i3];
13577               const winding = this.windings[i3];
13578               const index2 = ringsAfter.indexOf(ring);
13579               if (index2 === -1) {
13580                 ringsAfter.push(ring);
13581                 windingsAfter.push(winding);
13582               } else
13583                 windingsAfter[index2] += winding;
13584             }
13585             const polysAfter = [];
13586             const polysExclude = [];
13587             for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
13588               if (windingsAfter[i3] === 0)
13589                 continue;
13590               const ring = ringsAfter[i3];
13591               const poly = ring.poly;
13592               if (polysExclude.indexOf(poly) !== -1)
13593                 continue;
13594               if (ring.isExterior)
13595                 polysAfter.push(poly);
13596               else {
13597                 if (polysExclude.indexOf(poly) === -1)
13598                   polysExclude.push(poly);
13599                 const index2 = polysAfter.indexOf(ring.poly);
13600                 if (index2 !== -1)
13601                   polysAfter.splice(index2, 1);
13602               }
13603             }
13604             for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
13605               const mp = polysAfter[i3].multiPoly;
13606               if (mpsAfter.indexOf(mp) === -1)
13607                 mpsAfter.push(mp);
13608             }
13609             return this._afterState;
13610           }
13611           /* Is this segment part of the final result? */
13612           isInResult() {
13613             if (this.consumedBy)
13614               return false;
13615             if (this._isInResult !== void 0)
13616               return this._isInResult;
13617             const mpsBefore = this.beforeState().multiPolys;
13618             const mpsAfter = this.afterState().multiPolys;
13619             switch (operation2.type) {
13620               case "union": {
13621                 const noBefores = mpsBefore.length === 0;
13622                 const noAfters = mpsAfter.length === 0;
13623                 this._isInResult = noBefores !== noAfters;
13624                 break;
13625               }
13626               case "intersection": {
13627                 let least;
13628                 let most;
13629                 if (mpsBefore.length < mpsAfter.length) {
13630                   least = mpsBefore.length;
13631                   most = mpsAfter.length;
13632                 } else {
13633                   least = mpsAfter.length;
13634                   most = mpsBefore.length;
13635                 }
13636                 this._isInResult = most === operation2.numMultiPolys && least < most;
13637                 break;
13638               }
13639               case "xor": {
13640                 const diff = Math.abs(mpsBefore.length - mpsAfter.length);
13641                 this._isInResult = diff % 2 === 1;
13642                 break;
13643               }
13644               case "difference": {
13645                 const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
13646                 this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
13647                 break;
13648               }
13649               default:
13650                 throw new Error("Unrecognized operation type found ".concat(operation2.type));
13651             }
13652             return this._isInResult;
13653           }
13654         }
13655         class RingIn2 {
13656           constructor(geomRing, poly, isExterior) {
13657             if (!Array.isArray(geomRing) || geomRing.length === 0) {
13658               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13659             }
13660             this.poly = poly;
13661             this.isExterior = isExterior;
13662             this.segments = [];
13663             if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
13664               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13665             }
13666             const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
13667             this.bbox = {
13668               ll: {
13669                 x: firstPoint.x,
13670                 y: firstPoint.y
13671               },
13672               ur: {
13673                 x: firstPoint.x,
13674                 y: firstPoint.y
13675               }
13676             };
13677             let prevPoint = firstPoint;
13678             for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
13679               if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
13680                 throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13681               }
13682               let point2 = rounder.round(geomRing[i3][0], geomRing[i3][1]);
13683               if (point2.x === prevPoint.x && point2.y === prevPoint.y)
13684                 continue;
13685               this.segments.push(Segment2.fromRing(prevPoint, point2, this));
13686               if (point2.x < this.bbox.ll.x)
13687                 this.bbox.ll.x = point2.x;
13688               if (point2.y < this.bbox.ll.y)
13689                 this.bbox.ll.y = point2.y;
13690               if (point2.x > this.bbox.ur.x)
13691                 this.bbox.ur.x = point2.x;
13692               if (point2.y > this.bbox.ur.y)
13693                 this.bbox.ur.y = point2.y;
13694               prevPoint = point2;
13695             }
13696             if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
13697               this.segments.push(Segment2.fromRing(prevPoint, firstPoint, this));
13698             }
13699           }
13700           getSweepEvents() {
13701             const sweepEvents = [];
13702             for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
13703               const segment = this.segments[i3];
13704               sweepEvents.push(segment.leftSE);
13705               sweepEvents.push(segment.rightSE);
13706             }
13707             return sweepEvents;
13708           }
13709         }
13710         class PolyIn2 {
13711           constructor(geomPoly, multiPoly) {
13712             if (!Array.isArray(geomPoly)) {
13713               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13714             }
13715             this.exteriorRing = new RingIn2(geomPoly[0], this, true);
13716             this.bbox = {
13717               ll: {
13718                 x: this.exteriorRing.bbox.ll.x,
13719                 y: this.exteriorRing.bbox.ll.y
13720               },
13721               ur: {
13722                 x: this.exteriorRing.bbox.ur.x,
13723                 y: this.exteriorRing.bbox.ur.y
13724               }
13725             };
13726             this.interiorRings = [];
13727             for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
13728               const ring = new RingIn2(geomPoly[i3], this, false);
13729               if (ring.bbox.ll.x < this.bbox.ll.x)
13730                 this.bbox.ll.x = ring.bbox.ll.x;
13731               if (ring.bbox.ll.y < this.bbox.ll.y)
13732                 this.bbox.ll.y = ring.bbox.ll.y;
13733               if (ring.bbox.ur.x > this.bbox.ur.x)
13734                 this.bbox.ur.x = ring.bbox.ur.x;
13735               if (ring.bbox.ur.y > this.bbox.ur.y)
13736                 this.bbox.ur.y = ring.bbox.ur.y;
13737               this.interiorRings.push(ring);
13738             }
13739             this.multiPoly = multiPoly;
13740           }
13741           getSweepEvents() {
13742             const sweepEvents = this.exteriorRing.getSweepEvents();
13743             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
13744               const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
13745               for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
13746                 sweepEvents.push(ringSweepEvents[j2]);
13747               }
13748             }
13749             return sweepEvents;
13750           }
13751         }
13752         class MultiPolyIn2 {
13753           constructor(geom, isSubject) {
13754             if (!Array.isArray(geom)) {
13755               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13756             }
13757             try {
13758               if (typeof geom[0][0][0] === "number")
13759                 geom = [geom];
13760             } catch (ex) {
13761             }
13762             this.polys = [];
13763             this.bbox = {
13764               ll: {
13765                 x: Number.POSITIVE_INFINITY,
13766                 y: Number.POSITIVE_INFINITY
13767               },
13768               ur: {
13769                 x: Number.NEGATIVE_INFINITY,
13770                 y: Number.NEGATIVE_INFINITY
13771               }
13772             };
13773             for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
13774               const poly = new PolyIn2(geom[i3], this);
13775               if (poly.bbox.ll.x < this.bbox.ll.x)
13776                 this.bbox.ll.x = poly.bbox.ll.x;
13777               if (poly.bbox.ll.y < this.bbox.ll.y)
13778                 this.bbox.ll.y = poly.bbox.ll.y;
13779               if (poly.bbox.ur.x > this.bbox.ur.x)
13780                 this.bbox.ur.x = poly.bbox.ur.x;
13781               if (poly.bbox.ur.y > this.bbox.ur.y)
13782                 this.bbox.ur.y = poly.bbox.ur.y;
13783               this.polys.push(poly);
13784             }
13785             this.isSubject = isSubject;
13786           }
13787           getSweepEvents() {
13788             const sweepEvents = [];
13789             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
13790               const polySweepEvents = this.polys[i3].getSweepEvents();
13791               for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
13792                 sweepEvents.push(polySweepEvents[j2]);
13793               }
13794             }
13795             return sweepEvents;
13796           }
13797         }
13798         class RingOut2 {
13799           /* Given the segments from the sweep line pass, compute & return a series
13800            * of closed rings from all the segments marked to be part of the result */
13801           static factory(allSegments) {
13802             const ringsOut = [];
13803             for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
13804               const segment = allSegments[i3];
13805               if (!segment.isInResult() || segment.ringOut)
13806                 continue;
13807               let prevEvent = null;
13808               let event = segment.leftSE;
13809               let nextEvent = segment.rightSE;
13810               const events = [event];
13811               const startingPoint = event.point;
13812               const intersectionLEs = [];
13813               while (true) {
13814                 prevEvent = event;
13815                 event = nextEvent;
13816                 events.push(event);
13817                 if (event.point === startingPoint)
13818                   break;
13819                 while (true) {
13820                   const availableLEs = event.getAvailableLinkedEvents();
13821                   if (availableLEs.length === 0) {
13822                     const firstPt = events[0].point;
13823                     const lastPt = events[events.length - 1].point;
13824                     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, "]."));
13825                   }
13826                   if (availableLEs.length === 1) {
13827                     nextEvent = availableLEs[0].otherSE;
13828                     break;
13829                   }
13830                   let indexLE = null;
13831                   for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
13832                     if (intersectionLEs[j2].point === event.point) {
13833                       indexLE = j2;
13834                       break;
13835                     }
13836                   }
13837                   if (indexLE !== null) {
13838                     const intersectionLE = intersectionLEs.splice(indexLE)[0];
13839                     const ringEvents = events.splice(intersectionLE.index);
13840                     ringEvents.unshift(ringEvents[0].otherSE);
13841                     ringsOut.push(new RingOut2(ringEvents.reverse()));
13842                     continue;
13843                   }
13844                   intersectionLEs.push({
13845                     index: events.length,
13846                     point: event.point
13847                   });
13848                   const comparator = event.getLeftmostComparator(prevEvent);
13849                   nextEvent = availableLEs.sort(comparator)[0].otherSE;
13850                   break;
13851                 }
13852               }
13853               ringsOut.push(new RingOut2(events));
13854             }
13855             return ringsOut;
13856           }
13857           constructor(events) {
13858             this.events = events;
13859             for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
13860               events[i3].segment.ringOut = this;
13861             }
13862             this.poly = null;
13863           }
13864           getGeom() {
13865             let prevPt = this.events[0].point;
13866             const points = [prevPt];
13867             for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
13868               const pt3 = this.events[i3].point;
13869               const nextPt2 = this.events[i3 + 1].point;
13870               if (compareVectorAngles(pt3, prevPt, nextPt2) === 0)
13871                 continue;
13872               points.push(pt3);
13873               prevPt = pt3;
13874             }
13875             if (points.length === 1)
13876               return null;
13877             const pt2 = points[0];
13878             const nextPt = points[1];
13879             if (compareVectorAngles(pt2, prevPt, nextPt) === 0)
13880               points.shift();
13881             points.push(points[0]);
13882             const step = this.isExteriorRing() ? 1 : -1;
13883             const iStart = this.isExteriorRing() ? 0 : points.length - 1;
13884             const iEnd = this.isExteriorRing() ? points.length : -1;
13885             const orderedPoints = [];
13886             for (let i3 = iStart; i3 != iEnd; i3 += step)
13887               orderedPoints.push([points[i3].x, points[i3].y]);
13888             return orderedPoints;
13889           }
13890           isExteriorRing() {
13891             if (this._isExteriorRing === void 0) {
13892               const enclosing = this.enclosingRing();
13893               this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
13894             }
13895             return this._isExteriorRing;
13896           }
13897           enclosingRing() {
13898             if (this._enclosingRing === void 0) {
13899               this._enclosingRing = this._calcEnclosingRing();
13900             }
13901             return this._enclosingRing;
13902           }
13903           /* Returns the ring that encloses this one, if any */
13904           _calcEnclosingRing() {
13905             let leftMostEvt = this.events[0];
13906             for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
13907               const evt = this.events[i3];
13908               if (SweepEvent2.compare(leftMostEvt, evt) > 0)
13909                 leftMostEvt = evt;
13910             }
13911             let prevSeg = leftMostEvt.segment.prevInResult();
13912             let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
13913             while (true) {
13914               if (!prevSeg)
13915                 return null;
13916               if (!prevPrevSeg)
13917                 return prevSeg.ringOut;
13918               if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
13919                 if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
13920                   return prevSeg.ringOut;
13921                 } else
13922                   return prevSeg.ringOut.enclosingRing();
13923               }
13924               prevSeg = prevPrevSeg.prevInResult();
13925               prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
13926             }
13927           }
13928         }
13929         class PolyOut2 {
13930           constructor(exteriorRing) {
13931             this.exteriorRing = exteriorRing;
13932             exteriorRing.poly = this;
13933             this.interiorRings = [];
13934           }
13935           addInterior(ring) {
13936             this.interiorRings.push(ring);
13937             ring.poly = this;
13938           }
13939           getGeom() {
13940             const geom = [this.exteriorRing.getGeom()];
13941             if (geom[0] === null)
13942               return null;
13943             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
13944               const ringGeom = this.interiorRings[i3].getGeom();
13945               if (ringGeom === null)
13946                 continue;
13947               geom.push(ringGeom);
13948             }
13949             return geom;
13950           }
13951         }
13952         class MultiPolyOut2 {
13953           constructor(rings) {
13954             this.rings = rings;
13955             this.polys = this._composePolys(rings);
13956           }
13957           getGeom() {
13958             const geom = [];
13959             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
13960               const polyGeom = this.polys[i3].getGeom();
13961               if (polyGeom === null)
13962                 continue;
13963               geom.push(polyGeom);
13964             }
13965             return geom;
13966           }
13967           _composePolys(rings) {
13968             const polys = [];
13969             for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
13970               const ring = rings[i3];
13971               if (ring.poly)
13972                 continue;
13973               if (ring.isExteriorRing())
13974                 polys.push(new PolyOut2(ring));
13975               else {
13976                 const enclosingRing = ring.enclosingRing();
13977                 if (!enclosingRing.poly)
13978                   polys.push(new PolyOut2(enclosingRing));
13979                 enclosingRing.poly.addInterior(ring);
13980               }
13981             }
13982             return polys;
13983           }
13984         }
13985         class SweepLine2 {
13986           constructor(queue) {
13987             let comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment2.compare;
13988             this.queue = queue;
13989             this.tree = new Tree(comparator);
13990             this.segments = [];
13991           }
13992           process(event) {
13993             const segment = event.segment;
13994             const newEvents = [];
13995             if (event.consumedBy) {
13996               if (event.isLeft)
13997                 this.queue.remove(event.otherSE);
13998               else
13999                 this.tree.remove(segment);
14000               return newEvents;
14001             }
14002             const node = event.isLeft ? this.tree.add(segment) : this.tree.find(segment);
14003             if (!node)
14004               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.");
14005             let prevNode = node;
14006             let nextNode = node;
14007             let prevSeg = void 0;
14008             let nextSeg = void 0;
14009             while (prevSeg === void 0) {
14010               prevNode = this.tree.prev(prevNode);
14011               if (prevNode === null)
14012                 prevSeg = null;
14013               else if (prevNode.key.consumedBy === void 0)
14014                 prevSeg = prevNode.key;
14015             }
14016             while (nextSeg === void 0) {
14017               nextNode = this.tree.next(nextNode);
14018               if (nextNode === null)
14019                 nextSeg = null;
14020               else if (nextNode.key.consumedBy === void 0)
14021                 nextSeg = nextNode.key;
14022             }
14023             if (event.isLeft) {
14024               let prevMySplitter = null;
14025               if (prevSeg) {
14026                 const prevInter = prevSeg.getIntersection(segment);
14027                 if (prevInter !== null) {
14028                   if (!segment.isAnEndpoint(prevInter))
14029                     prevMySplitter = prevInter;
14030                   if (!prevSeg.isAnEndpoint(prevInter)) {
14031                     const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
14032                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14033                       newEvents.push(newEventsFromSplit[i3]);
14034                     }
14035                   }
14036                 }
14037               }
14038               let nextMySplitter = null;
14039               if (nextSeg) {
14040                 const nextInter = nextSeg.getIntersection(segment);
14041                 if (nextInter !== null) {
14042                   if (!segment.isAnEndpoint(nextInter))
14043                     nextMySplitter = nextInter;
14044                   if (!nextSeg.isAnEndpoint(nextInter)) {
14045                     const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
14046                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14047                       newEvents.push(newEventsFromSplit[i3]);
14048                     }
14049                   }
14050                 }
14051               }
14052               if (prevMySplitter !== null || nextMySplitter !== null) {
14053                 let mySplitter = null;
14054                 if (prevMySplitter === null)
14055                   mySplitter = nextMySplitter;
14056                 else if (nextMySplitter === null)
14057                   mySplitter = prevMySplitter;
14058                 else {
14059                   const cmpSplitters = SweepEvent2.comparePoints(prevMySplitter, nextMySplitter);
14060                   mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
14061                 }
14062                 this.queue.remove(segment.rightSE);
14063                 newEvents.push(segment.rightSE);
14064                 const newEventsFromSplit = segment.split(mySplitter);
14065                 for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14066                   newEvents.push(newEventsFromSplit[i3]);
14067                 }
14068               }
14069               if (newEvents.length > 0) {
14070                 this.tree.remove(segment);
14071                 newEvents.push(event);
14072               } else {
14073                 this.segments.push(segment);
14074                 segment.prev = prevSeg;
14075               }
14076             } else {
14077               if (prevSeg && nextSeg) {
14078                 const inter = prevSeg.getIntersection(nextSeg);
14079                 if (inter !== null) {
14080                   if (!prevSeg.isAnEndpoint(inter)) {
14081                     const newEventsFromSplit = this._splitSafely(prevSeg, inter);
14082                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14083                       newEvents.push(newEventsFromSplit[i3]);
14084                     }
14085                   }
14086                   if (!nextSeg.isAnEndpoint(inter)) {
14087                     const newEventsFromSplit = this._splitSafely(nextSeg, inter);
14088                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14089                       newEvents.push(newEventsFromSplit[i3]);
14090                     }
14091                   }
14092                 }
14093               }
14094               this.tree.remove(segment);
14095             }
14096             return newEvents;
14097           }
14098           /* Safely split a segment that is currently in the datastructures
14099            * IE - a segment other than the one that is currently being processed. */
14100           _splitSafely(seg, pt2) {
14101             this.tree.remove(seg);
14102             const rightSE = seg.rightSE;
14103             this.queue.remove(rightSE);
14104             const newEvents = seg.split(pt2);
14105             newEvents.push(rightSE);
14106             if (seg.consumedBy === void 0)
14107               this.tree.add(seg);
14108             return newEvents;
14109           }
14110         }
14111         const POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
14112         const POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
14113         class Operation2 {
14114           run(type2, geom, moreGeoms) {
14115             operation2.type = type2;
14116             rounder.reset();
14117             const multipolys = [new MultiPolyIn2(geom, true)];
14118             for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
14119               multipolys.push(new MultiPolyIn2(moreGeoms[i3], false));
14120             }
14121             operation2.numMultiPolys = multipolys.length;
14122             if (operation2.type === "difference") {
14123               const subject = multipolys[0];
14124               let i3 = 1;
14125               while (i3 < multipolys.length) {
14126                 if (getBboxOverlap2(multipolys[i3].bbox, subject.bbox) !== null)
14127                   i3++;
14128                 else
14129                   multipolys.splice(i3, 1);
14130               }
14131             }
14132             if (operation2.type === "intersection") {
14133               for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
14134                 const mpA = multipolys[i3];
14135                 for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
14136                   if (getBboxOverlap2(mpA.bbox, multipolys[j2].bbox) === null)
14137                     return [];
14138                 }
14139               }
14140             }
14141             const queue = new Tree(SweepEvent2.compare);
14142             for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
14143               const sweepEvents = multipolys[i3].getSweepEvents();
14144               for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
14145                 queue.insert(sweepEvents[j2]);
14146                 if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
14147                   throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
14148                 }
14149               }
14150             }
14151             const sweepLine = new SweepLine2(queue);
14152             let prevQueueSize = queue.size;
14153             let node = queue.pop();
14154             while (node) {
14155               const evt = node.key;
14156               if (queue.size === prevQueueSize) {
14157                 const seg = evt.segment;
14158                 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."));
14159               }
14160               if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
14161                 throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
14162               }
14163               if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
14164                 throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
14165               }
14166               const newEvents = sweepLine.process(evt);
14167               for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
14168                 const evt2 = newEvents[i3];
14169                 if (evt2.consumedBy === void 0)
14170                   queue.insert(evt2);
14171               }
14172               prevQueueSize = queue.size;
14173               node = queue.pop();
14174             }
14175             rounder.reset();
14176             const ringsOut = RingOut2.factory(sweepLine.segments);
14177             const result = new MultiPolyOut2(ringsOut);
14178             return result.getGeom();
14179           }
14180         }
14181         const operation2 = new Operation2();
14182         const union2 = function(geom) {
14183           for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
14184             moreGeoms[_key - 1] = arguments[_key];
14185           }
14186           return operation2.run("union", geom, moreGeoms);
14187         };
14188         const intersection2 = function(geom) {
14189           for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
14190             moreGeoms[_key2 - 1] = arguments[_key2];
14191           }
14192           return operation2.run("intersection", geom, moreGeoms);
14193         };
14194         const xor = function(geom) {
14195           for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
14196             moreGeoms[_key3 - 1] = arguments[_key3];
14197           }
14198           return operation2.run("xor", geom, moreGeoms);
14199         };
14200         const difference2 = function(subjectGeom) {
14201           for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
14202             clippingGeoms[_key4 - 1] = arguments[_key4];
14203           }
14204           return operation2.run("difference", subjectGeom, clippingGeoms);
14205         };
14206         var index = {
14207           union: union2,
14208           intersection: intersection2,
14209           xor,
14210           difference: difference2
14211         };
14212         return index;
14213       });
14214     }
14215   });
14216
14217   // node_modules/whatwg-fetch/fetch.js
14218   var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
14219   typeof global !== "undefined" && global || {};
14220   var support = {
14221     searchParams: "URLSearchParams" in g,
14222     iterable: "Symbol" in g && "iterator" in Symbol,
14223     blob: "FileReader" in g && "Blob" in g && function() {
14224       try {
14225         new Blob();
14226         return true;
14227       } catch (e3) {
14228         return false;
14229       }
14230     }(),
14231     formData: "FormData" in g,
14232     arrayBuffer: "ArrayBuffer" in g
14233   };
14234   function isDataView(obj) {
14235     return obj && DataView.prototype.isPrototypeOf(obj);
14236   }
14237   if (support.arrayBuffer) {
14238     viewClasses = [
14239       "[object Int8Array]",
14240       "[object Uint8Array]",
14241       "[object Uint8ClampedArray]",
14242       "[object Int16Array]",
14243       "[object Uint16Array]",
14244       "[object Int32Array]",
14245       "[object Uint32Array]",
14246       "[object Float32Array]",
14247       "[object Float64Array]"
14248     ];
14249     isArrayBufferView = ArrayBuffer.isView || function(obj) {
14250       return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
14251     };
14252   }
14253   var viewClasses;
14254   var isArrayBufferView;
14255   function normalizeName(name) {
14256     if (typeof name !== "string") {
14257       name = String(name);
14258     }
14259     if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
14260       throw new TypeError('Invalid character in header field name: "' + name + '"');
14261     }
14262     return name.toLowerCase();
14263   }
14264   function normalizeValue(value) {
14265     if (typeof value !== "string") {
14266       value = String(value);
14267     }
14268     return value;
14269   }
14270   function iteratorFor(items) {
14271     var iterator = {
14272       next: function() {
14273         var value = items.shift();
14274         return { done: value === void 0, value };
14275       }
14276     };
14277     if (support.iterable) {
14278       iterator[Symbol.iterator] = function() {
14279         return iterator;
14280       };
14281     }
14282     return iterator;
14283   }
14284   function Headers(headers) {
14285     this.map = {};
14286     if (headers instanceof Headers) {
14287       headers.forEach(function(value, name) {
14288         this.append(name, value);
14289       }, this);
14290     } else if (Array.isArray(headers)) {
14291       headers.forEach(function(header) {
14292         if (header.length != 2) {
14293           throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
14294         }
14295         this.append(header[0], header[1]);
14296       }, this);
14297     } else if (headers) {
14298       Object.getOwnPropertyNames(headers).forEach(function(name) {
14299         this.append(name, headers[name]);
14300       }, this);
14301     }
14302   }
14303   Headers.prototype.append = function(name, value) {
14304     name = normalizeName(name);
14305     value = normalizeValue(value);
14306     var oldValue = this.map[name];
14307     this.map[name] = oldValue ? oldValue + ", " + value : value;
14308   };
14309   Headers.prototype["delete"] = function(name) {
14310     delete this.map[normalizeName(name)];
14311   };
14312   Headers.prototype.get = function(name) {
14313     name = normalizeName(name);
14314     return this.has(name) ? this.map[name] : null;
14315   };
14316   Headers.prototype.has = function(name) {
14317     return this.map.hasOwnProperty(normalizeName(name));
14318   };
14319   Headers.prototype.set = function(name, value) {
14320     this.map[normalizeName(name)] = normalizeValue(value);
14321   };
14322   Headers.prototype.forEach = function(callback, thisArg) {
14323     for (var name in this.map) {
14324       if (this.map.hasOwnProperty(name)) {
14325         callback.call(thisArg, this.map[name], name, this);
14326       }
14327     }
14328   };
14329   Headers.prototype.keys = function() {
14330     var items = [];
14331     this.forEach(function(value, name) {
14332       items.push(name);
14333     });
14334     return iteratorFor(items);
14335   };
14336   Headers.prototype.values = function() {
14337     var items = [];
14338     this.forEach(function(value) {
14339       items.push(value);
14340     });
14341     return iteratorFor(items);
14342   };
14343   Headers.prototype.entries = function() {
14344     var items = [];
14345     this.forEach(function(value, name) {
14346       items.push([name, value]);
14347     });
14348     return iteratorFor(items);
14349   };
14350   if (support.iterable) {
14351     Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
14352   }
14353   function consumed(body) {
14354     if (body._noBody)
14355       return;
14356     if (body.bodyUsed) {
14357       return Promise.reject(new TypeError("Already read"));
14358     }
14359     body.bodyUsed = true;
14360   }
14361   function fileReaderReady(reader) {
14362     return new Promise(function(resolve, reject) {
14363       reader.onload = function() {
14364         resolve(reader.result);
14365       };
14366       reader.onerror = function() {
14367         reject(reader.error);
14368       };
14369     });
14370   }
14371   function readBlobAsArrayBuffer(blob) {
14372     var reader = new FileReader();
14373     var promise = fileReaderReady(reader);
14374     reader.readAsArrayBuffer(blob);
14375     return promise;
14376   }
14377   function readBlobAsText(blob) {
14378     var reader = new FileReader();
14379     var promise = fileReaderReady(reader);
14380     var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
14381     var encoding = match ? match[1] : "utf-8";
14382     reader.readAsText(blob, encoding);
14383     return promise;
14384   }
14385   function readArrayBufferAsText(buf) {
14386     var view = new Uint8Array(buf);
14387     var chars = new Array(view.length);
14388     for (var i3 = 0; i3 < view.length; i3++) {
14389       chars[i3] = String.fromCharCode(view[i3]);
14390     }
14391     return chars.join("");
14392   }
14393   function bufferClone(buf) {
14394     if (buf.slice) {
14395       return buf.slice(0);
14396     } else {
14397       var view = new Uint8Array(buf.byteLength);
14398       view.set(new Uint8Array(buf));
14399       return view.buffer;
14400     }
14401   }
14402   function Body() {
14403     this.bodyUsed = false;
14404     this._initBody = function(body) {
14405       this.bodyUsed = this.bodyUsed;
14406       this._bodyInit = body;
14407       if (!body) {
14408         this._noBody = true;
14409         this._bodyText = "";
14410       } else if (typeof body === "string") {
14411         this._bodyText = body;
14412       } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
14413         this._bodyBlob = body;
14414       } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
14415         this._bodyFormData = body;
14416       } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
14417         this._bodyText = body.toString();
14418       } else if (support.arrayBuffer && support.blob && isDataView(body)) {
14419         this._bodyArrayBuffer = bufferClone(body.buffer);
14420         this._bodyInit = new Blob([this._bodyArrayBuffer]);
14421       } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
14422         this._bodyArrayBuffer = bufferClone(body);
14423       } else {
14424         this._bodyText = body = Object.prototype.toString.call(body);
14425       }
14426       if (!this.headers.get("content-type")) {
14427         if (typeof body === "string") {
14428           this.headers.set("content-type", "text/plain;charset=UTF-8");
14429         } else if (this._bodyBlob && this._bodyBlob.type) {
14430           this.headers.set("content-type", this._bodyBlob.type);
14431         } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
14432           this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
14433         }
14434       }
14435     };
14436     if (support.blob) {
14437       this.blob = function() {
14438         var rejected = consumed(this);
14439         if (rejected) {
14440           return rejected;
14441         }
14442         if (this._bodyBlob) {
14443           return Promise.resolve(this._bodyBlob);
14444         } else if (this._bodyArrayBuffer) {
14445           return Promise.resolve(new Blob([this._bodyArrayBuffer]));
14446         } else if (this._bodyFormData) {
14447           throw new Error("could not read FormData body as blob");
14448         } else {
14449           return Promise.resolve(new Blob([this._bodyText]));
14450         }
14451       };
14452     }
14453     this.arrayBuffer = function() {
14454       if (this._bodyArrayBuffer) {
14455         var isConsumed = consumed(this);
14456         if (isConsumed) {
14457           return isConsumed;
14458         } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
14459           return Promise.resolve(
14460             this._bodyArrayBuffer.buffer.slice(
14461               this._bodyArrayBuffer.byteOffset,
14462               this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
14463             )
14464           );
14465         } else {
14466           return Promise.resolve(this._bodyArrayBuffer);
14467         }
14468       } else if (support.blob) {
14469         return this.blob().then(readBlobAsArrayBuffer);
14470       } else {
14471         throw new Error("could not read as ArrayBuffer");
14472       }
14473     };
14474     this.text = function() {
14475       var rejected = consumed(this);
14476       if (rejected) {
14477         return rejected;
14478       }
14479       if (this._bodyBlob) {
14480         return readBlobAsText(this._bodyBlob);
14481       } else if (this._bodyArrayBuffer) {
14482         return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
14483       } else if (this._bodyFormData) {
14484         throw new Error("could not read FormData body as text");
14485       } else {
14486         return Promise.resolve(this._bodyText);
14487       }
14488     };
14489     if (support.formData) {
14490       this.formData = function() {
14491         return this.text().then(decode);
14492       };
14493     }
14494     this.json = function() {
14495       return this.text().then(JSON.parse);
14496     };
14497     return this;
14498   }
14499   var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
14500   function normalizeMethod(method) {
14501     var upcased = method.toUpperCase();
14502     return methods.indexOf(upcased) > -1 ? upcased : method;
14503   }
14504   function Request(input, options2) {
14505     if (!(this instanceof Request)) {
14506       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
14507     }
14508     options2 = options2 || {};
14509     var body = options2.body;
14510     if (input instanceof Request) {
14511       if (input.bodyUsed) {
14512         throw new TypeError("Already read");
14513       }
14514       this.url = input.url;
14515       this.credentials = input.credentials;
14516       if (!options2.headers) {
14517         this.headers = new Headers(input.headers);
14518       }
14519       this.method = input.method;
14520       this.mode = input.mode;
14521       this.signal = input.signal;
14522       if (!body && input._bodyInit != null) {
14523         body = input._bodyInit;
14524         input.bodyUsed = true;
14525       }
14526     } else {
14527       this.url = String(input);
14528     }
14529     this.credentials = options2.credentials || this.credentials || "same-origin";
14530     if (options2.headers || !this.headers) {
14531       this.headers = new Headers(options2.headers);
14532     }
14533     this.method = normalizeMethod(options2.method || this.method || "GET");
14534     this.mode = options2.mode || this.mode || null;
14535     this.signal = options2.signal || this.signal || function() {
14536       if ("AbortController" in g) {
14537         var ctrl = new AbortController();
14538         return ctrl.signal;
14539       }
14540     }();
14541     this.referrer = null;
14542     if ((this.method === "GET" || this.method === "HEAD") && body) {
14543       throw new TypeError("Body not allowed for GET or HEAD requests");
14544     }
14545     this._initBody(body);
14546     if (this.method === "GET" || this.method === "HEAD") {
14547       if (options2.cache === "no-store" || options2.cache === "no-cache") {
14548         var reParamSearch = /([?&])_=[^&]*/;
14549         if (reParamSearch.test(this.url)) {
14550           this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
14551         } else {
14552           var reQueryString = /\?/;
14553           this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
14554         }
14555       }
14556     }
14557   }
14558   Request.prototype.clone = function() {
14559     return new Request(this, { body: this._bodyInit });
14560   };
14561   function decode(body) {
14562     var form = new FormData();
14563     body.trim().split("&").forEach(function(bytes) {
14564       if (bytes) {
14565         var split = bytes.split("=");
14566         var name = split.shift().replace(/\+/g, " ");
14567         var value = split.join("=").replace(/\+/g, " ");
14568         form.append(decodeURIComponent(name), decodeURIComponent(value));
14569       }
14570     });
14571     return form;
14572   }
14573   function parseHeaders(rawHeaders) {
14574     var headers = new Headers();
14575     var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
14576     preProcessedHeaders.split("\r").map(function(header) {
14577       return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
14578     }).forEach(function(line) {
14579       var parts = line.split(":");
14580       var key = parts.shift().trim();
14581       if (key) {
14582         var value = parts.join(":").trim();
14583         try {
14584           headers.append(key, value);
14585         } catch (error) {
14586           console.warn("Response " + error.message);
14587         }
14588       }
14589     });
14590     return headers;
14591   }
14592   Body.call(Request.prototype);
14593   function Response(bodyInit, options2) {
14594     if (!(this instanceof Response)) {
14595       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
14596     }
14597     if (!options2) {
14598       options2 = {};
14599     }
14600     this.type = "default";
14601     this.status = options2.status === void 0 ? 200 : options2.status;
14602     if (this.status < 200 || this.status > 599) {
14603       throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
14604     }
14605     this.ok = this.status >= 200 && this.status < 300;
14606     this.statusText = options2.statusText === void 0 ? "" : "" + options2.statusText;
14607     this.headers = new Headers(options2.headers);
14608     this.url = options2.url || "";
14609     this._initBody(bodyInit);
14610   }
14611   Body.call(Response.prototype);
14612   Response.prototype.clone = function() {
14613     return new Response(this._bodyInit, {
14614       status: this.status,
14615       statusText: this.statusText,
14616       headers: new Headers(this.headers),
14617       url: this.url
14618     });
14619   };
14620   Response.error = function() {
14621     var response = new Response(null, { status: 200, statusText: "" });
14622     response.ok = false;
14623     response.status = 0;
14624     response.type = "error";
14625     return response;
14626   };
14627   var redirectStatuses = [301, 302, 303, 307, 308];
14628   Response.redirect = function(url, status) {
14629     if (redirectStatuses.indexOf(status) === -1) {
14630       throw new RangeError("Invalid status code");
14631     }
14632     return new Response(null, { status, headers: { location: url } });
14633   };
14634   var DOMException2 = g.DOMException;
14635   try {
14636     new DOMException2();
14637   } catch (err) {
14638     DOMException2 = function(message, name) {
14639       this.message = message;
14640       this.name = name;
14641       var error = Error(message);
14642       this.stack = error.stack;
14643     };
14644     DOMException2.prototype = Object.create(Error.prototype);
14645     DOMException2.prototype.constructor = DOMException2;
14646   }
14647   function fetch2(input, init2) {
14648     return new Promise(function(resolve, reject) {
14649       var request3 = new Request(input, init2);
14650       if (request3.signal && request3.signal.aborted) {
14651         return reject(new DOMException2("Aborted", "AbortError"));
14652       }
14653       var xhr = new XMLHttpRequest();
14654       function abortXhr() {
14655         xhr.abort();
14656       }
14657       xhr.onload = function() {
14658         var options2 = {
14659           statusText: xhr.statusText,
14660           headers: parseHeaders(xhr.getAllResponseHeaders() || "")
14661         };
14662         if (request3.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
14663           options2.status = 200;
14664         } else {
14665           options2.status = xhr.status;
14666         }
14667         options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL");
14668         var body = "response" in xhr ? xhr.response : xhr.responseText;
14669         setTimeout(function() {
14670           resolve(new Response(body, options2));
14671         }, 0);
14672       };
14673       xhr.onerror = function() {
14674         setTimeout(function() {
14675           reject(new TypeError("Network request failed"));
14676         }, 0);
14677       };
14678       xhr.ontimeout = function() {
14679         setTimeout(function() {
14680           reject(new TypeError("Network request timed out"));
14681         }, 0);
14682       };
14683       xhr.onabort = function() {
14684         setTimeout(function() {
14685           reject(new DOMException2("Aborted", "AbortError"));
14686         }, 0);
14687       };
14688       function fixUrl(url) {
14689         try {
14690           return url === "" && g.location.href ? g.location.href : url;
14691         } catch (e3) {
14692           return url;
14693         }
14694       }
14695       xhr.open(request3.method, fixUrl(request3.url), true);
14696       if (request3.credentials === "include") {
14697         xhr.withCredentials = true;
14698       } else if (request3.credentials === "omit") {
14699         xhr.withCredentials = false;
14700       }
14701       if ("responseType" in xhr) {
14702         if (support.blob) {
14703           xhr.responseType = "blob";
14704         } else if (support.arrayBuffer) {
14705           xhr.responseType = "arraybuffer";
14706         }
14707       }
14708       if (init2 && typeof init2.headers === "object" && !(init2.headers instanceof Headers || g.Headers && init2.headers instanceof g.Headers)) {
14709         var names = [];
14710         Object.getOwnPropertyNames(init2.headers).forEach(function(name) {
14711           names.push(normalizeName(name));
14712           xhr.setRequestHeader(name, normalizeValue(init2.headers[name]));
14713         });
14714         request3.headers.forEach(function(value, name) {
14715           if (names.indexOf(name) === -1) {
14716             xhr.setRequestHeader(name, value);
14717           }
14718         });
14719       } else {
14720         request3.headers.forEach(function(value, name) {
14721           xhr.setRequestHeader(name, value);
14722         });
14723       }
14724       if (request3.signal) {
14725         request3.signal.addEventListener("abort", abortXhr);
14726         xhr.onreadystatechange = function() {
14727           if (xhr.readyState === 4) {
14728             request3.signal.removeEventListener("abort", abortXhr);
14729           }
14730         };
14731       }
14732       xhr.send(typeof request3._bodyInit === "undefined" ? null : request3._bodyInit);
14733     });
14734   }
14735   fetch2.polyfill = true;
14736   if (!g.fetch) {
14737     g.fetch = fetch2;
14738     g.Headers = Headers;
14739     g.Request = Request;
14740     g.Response = Response;
14741   }
14742
14743   // node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js
14744   (function(factory) {
14745     typeof define === "function" && define.amd ? define(factory) : factory();
14746   })(function() {
14747     "use strict";
14748     function _classCallCheck(instance, Constructor) {
14749       if (!(instance instanceof Constructor)) {
14750         throw new TypeError("Cannot call a class as a function");
14751       }
14752     }
14753     function _defineProperties(target, props) {
14754       for (var i3 = 0; i3 < props.length; i3++) {
14755         var descriptor = props[i3];
14756         descriptor.enumerable = descriptor.enumerable || false;
14757         descriptor.configurable = true;
14758         if ("value" in descriptor)
14759           descriptor.writable = true;
14760         Object.defineProperty(target, descriptor.key, descriptor);
14761       }
14762     }
14763     function _createClass(Constructor, protoProps, staticProps) {
14764       if (protoProps)
14765         _defineProperties(Constructor.prototype, protoProps);
14766       if (staticProps)
14767         _defineProperties(Constructor, staticProps);
14768       Object.defineProperty(Constructor, "prototype", {
14769         writable: false
14770       });
14771       return Constructor;
14772     }
14773     function _inherits(subClass, superClass) {
14774       if (typeof superClass !== "function" && superClass !== null) {
14775         throw new TypeError("Super expression must either be null or a function");
14776       }
14777       subClass.prototype = Object.create(superClass && superClass.prototype, {
14778         constructor: {
14779           value: subClass,
14780           writable: true,
14781           configurable: true
14782         }
14783       });
14784       Object.defineProperty(subClass, "prototype", {
14785         writable: false
14786       });
14787       if (superClass)
14788         _setPrototypeOf(subClass, superClass);
14789     }
14790     function _getPrototypeOf(o2) {
14791       _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o3) {
14792         return o3.__proto__ || Object.getPrototypeOf(o3);
14793       };
14794       return _getPrototypeOf(o2);
14795     }
14796     function _setPrototypeOf(o2, p2) {
14797       _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o3, p3) {
14798         o3.__proto__ = p3;
14799         return o3;
14800       };
14801       return _setPrototypeOf(o2, p2);
14802     }
14803     function _isNativeReflectConstruct() {
14804       if (typeof Reflect === "undefined" || !Reflect.construct)
14805         return false;
14806       if (Reflect.construct.sham)
14807         return false;
14808       if (typeof Proxy === "function")
14809         return true;
14810       try {
14811         Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
14812         }));
14813         return true;
14814       } catch (e3) {
14815         return false;
14816       }
14817     }
14818     function _assertThisInitialized(self2) {
14819       if (self2 === void 0) {
14820         throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
14821       }
14822       return self2;
14823     }
14824     function _possibleConstructorReturn(self2, call) {
14825       if (call && (typeof call === "object" || typeof call === "function")) {
14826         return call;
14827       } else if (call !== void 0) {
14828         throw new TypeError("Derived constructors may only return object or undefined");
14829       }
14830       return _assertThisInitialized(self2);
14831     }
14832     function _createSuper(Derived) {
14833       var hasNativeReflectConstruct = _isNativeReflectConstruct();
14834       return function _createSuperInternal() {
14835         var Super = _getPrototypeOf(Derived), result;
14836         if (hasNativeReflectConstruct) {
14837           var NewTarget = _getPrototypeOf(this).constructor;
14838           result = Reflect.construct(Super, arguments, NewTarget);
14839         } else {
14840           result = Super.apply(this, arguments);
14841         }
14842         return _possibleConstructorReturn(this, result);
14843       };
14844     }
14845     function _superPropBase(object, property) {
14846       while (!Object.prototype.hasOwnProperty.call(object, property)) {
14847         object = _getPrototypeOf(object);
14848         if (object === null)
14849           break;
14850       }
14851       return object;
14852     }
14853     function _get() {
14854       if (typeof Reflect !== "undefined" && Reflect.get) {
14855         _get = Reflect.get.bind();
14856       } else {
14857         _get = function _get2(target, property, receiver) {
14858           var base = _superPropBase(target, property);
14859           if (!base)
14860             return;
14861           var desc = Object.getOwnPropertyDescriptor(base, property);
14862           if (desc.get) {
14863             return desc.get.call(arguments.length < 3 ? target : receiver);
14864           }
14865           return desc.value;
14866         };
14867       }
14868       return _get.apply(this, arguments);
14869     }
14870     var Emitter = /* @__PURE__ */ function() {
14871       function Emitter2() {
14872         _classCallCheck(this, Emitter2);
14873         Object.defineProperty(this, "listeners", {
14874           value: {},
14875           writable: true,
14876           configurable: true
14877         });
14878       }
14879       _createClass(Emitter2, [{
14880         key: "addEventListener",
14881         value: function addEventListener(type2, callback, options2) {
14882           if (!(type2 in this.listeners)) {
14883             this.listeners[type2] = [];
14884           }
14885           this.listeners[type2].push({
14886             callback,
14887             options: options2
14888           });
14889         }
14890       }, {
14891         key: "removeEventListener",
14892         value: function removeEventListener(type2, callback) {
14893           if (!(type2 in this.listeners)) {
14894             return;
14895           }
14896           var stack = this.listeners[type2];
14897           for (var i3 = 0, l2 = stack.length; i3 < l2; i3++) {
14898             if (stack[i3].callback === callback) {
14899               stack.splice(i3, 1);
14900               return;
14901             }
14902           }
14903         }
14904       }, {
14905         key: "dispatchEvent",
14906         value: function dispatchEvent2(event) {
14907           if (!(event.type in this.listeners)) {
14908             return;
14909           }
14910           var stack = this.listeners[event.type];
14911           var stackToCall = stack.slice();
14912           for (var i3 = 0, l2 = stackToCall.length; i3 < l2; i3++) {
14913             var listener = stackToCall[i3];
14914             try {
14915               listener.callback.call(this, event);
14916             } catch (e3) {
14917               Promise.resolve().then(function() {
14918                 throw e3;
14919               });
14920             }
14921             if (listener.options && listener.options.once) {
14922               this.removeEventListener(event.type, listener.callback);
14923             }
14924           }
14925           return !event.defaultPrevented;
14926         }
14927       }]);
14928       return Emitter2;
14929     }();
14930     var AbortSignal = /* @__PURE__ */ function(_Emitter) {
14931       _inherits(AbortSignal2, _Emitter);
14932       var _super = _createSuper(AbortSignal2);
14933       function AbortSignal2() {
14934         var _this;
14935         _classCallCheck(this, AbortSignal2);
14936         _this = _super.call(this);
14937         if (!_this.listeners) {
14938           Emitter.call(_assertThisInitialized(_this));
14939         }
14940         Object.defineProperty(_assertThisInitialized(_this), "aborted", {
14941           value: false,
14942           writable: true,
14943           configurable: true
14944         });
14945         Object.defineProperty(_assertThisInitialized(_this), "onabort", {
14946           value: null,
14947           writable: true,
14948           configurable: true
14949         });
14950         Object.defineProperty(_assertThisInitialized(_this), "reason", {
14951           value: void 0,
14952           writable: true,
14953           configurable: true
14954         });
14955         return _this;
14956       }
14957       _createClass(AbortSignal2, [{
14958         key: "toString",
14959         value: function toString2() {
14960           return "[object AbortSignal]";
14961         }
14962       }, {
14963         key: "dispatchEvent",
14964         value: function dispatchEvent2(event) {
14965           if (event.type === "abort") {
14966             this.aborted = true;
14967             if (typeof this.onabort === "function") {
14968               this.onabort.call(this, event);
14969             }
14970           }
14971           _get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
14972         }
14973       }]);
14974       return AbortSignal2;
14975     }(Emitter);
14976     var AbortController2 = /* @__PURE__ */ function() {
14977       function AbortController3() {
14978         _classCallCheck(this, AbortController3);
14979         Object.defineProperty(this, "signal", {
14980           value: new AbortSignal(),
14981           writable: true,
14982           configurable: true
14983         });
14984       }
14985       _createClass(AbortController3, [{
14986         key: "abort",
14987         value: function abort(reason) {
14988           var event;
14989           try {
14990             event = new Event("abort");
14991           } catch (e3) {
14992             if (typeof document !== "undefined") {
14993               if (!document.createEvent) {
14994                 event = document.createEventObject();
14995                 event.type = "abort";
14996               } else {
14997                 event = document.createEvent("Event");
14998                 event.initEvent("abort", false, false);
14999               }
15000             } else {
15001               event = {
15002                 type: "abort",
15003                 bubbles: false,
15004                 cancelable: false
15005               };
15006             }
15007           }
15008           var signalReason = reason;
15009           if (signalReason === void 0) {
15010             if (typeof document === "undefined") {
15011               signalReason = new Error("This operation was aborted");
15012               signalReason.name = "AbortError";
15013             } else {
15014               try {
15015                 signalReason = new DOMException("signal is aborted without reason");
15016               } catch (err) {
15017                 signalReason = new Error("This operation was aborted");
15018                 signalReason.name = "AbortError";
15019               }
15020             }
15021           }
15022           this.signal.reason = signalReason;
15023           this.signal.dispatchEvent(event);
15024         }
15025       }, {
15026         key: "toString",
15027         value: function toString2() {
15028           return "[object AbortController]";
15029         }
15030       }]);
15031       return AbortController3;
15032     }();
15033     if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
15034       AbortController2.prototype[Symbol.toStringTag] = "AbortController";
15035       AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
15036     }
15037     function polyfillNeeded(self2) {
15038       if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
15039         console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
15040         return true;
15041       }
15042       return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
15043     }
15044     function abortableFetchDecorator(patchTargets) {
15045       if ("function" === typeof patchTargets) {
15046         patchTargets = {
15047           fetch: patchTargets
15048         };
15049       }
15050       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;
15051       if (!polyfillNeeded({
15052         fetch: fetch3,
15053         Request: NativeRequest,
15054         AbortController: NativeAbortController,
15055         __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
15056       })) {
15057         return {
15058           fetch: fetch3,
15059           Request: Request2
15060         };
15061       }
15062       var Request2 = NativeRequest;
15063       if (Request2 && !Request2.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
15064         Request2 = function Request3(input, init2) {
15065           var signal;
15066           if (init2 && init2.signal) {
15067             signal = init2.signal;
15068             delete init2.signal;
15069           }
15070           var request3 = new NativeRequest(input, init2);
15071           if (signal) {
15072             Object.defineProperty(request3, "signal", {
15073               writable: false,
15074               enumerable: false,
15075               configurable: true,
15076               value: signal
15077             });
15078           }
15079           return request3;
15080         };
15081         Request2.prototype = NativeRequest.prototype;
15082       }
15083       var realFetch = fetch3;
15084       var abortableFetch = function abortableFetch2(input, init2) {
15085         var signal = Request2 && Request2.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
15086         if (signal) {
15087           var abortError;
15088           try {
15089             abortError = new DOMException("Aborted", "AbortError");
15090           } catch (err) {
15091             abortError = new Error("Aborted");
15092             abortError.name = "AbortError";
15093           }
15094           if (signal.aborted) {
15095             return Promise.reject(abortError);
15096           }
15097           var cancellation = new Promise(function(_2, reject) {
15098             signal.addEventListener("abort", function() {
15099               return reject(abortError);
15100             }, {
15101               once: true
15102             });
15103           });
15104           if (init2 && init2.signal) {
15105             delete init2.signal;
15106           }
15107           return Promise.race([cancellation, realFetch(input, init2)]);
15108         }
15109         return realFetch(input, init2);
15110       };
15111       return {
15112         fetch: abortableFetch,
15113         Request: Request2
15114       };
15115     }
15116     (function(self2) {
15117       if (!polyfillNeeded(self2)) {
15118         return;
15119       }
15120       if (!self2.fetch) {
15121         console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
15122         return;
15123       }
15124       var _abortableFetch = abortableFetchDecorator(self2), fetch3 = _abortableFetch.fetch, Request2 = _abortableFetch.Request;
15125       self2.fetch = fetch3;
15126       self2.Request = Request2;
15127       Object.defineProperty(self2, "AbortController", {
15128         writable: true,
15129         enumerable: false,
15130         configurable: true,
15131         value: AbortController2
15132       });
15133       Object.defineProperty(self2, "AbortSignal", {
15134         writable: true,
15135         enumerable: false,
15136         configurable: true,
15137         value: AbortSignal
15138       });
15139     })(typeof self !== "undefined" ? self : global);
15140   });
15141
15142   // modules/index.js
15143   var modules_exports = {};
15144   __export(modules_exports, {
15145     LocationManager: () => LocationManager,
15146     QAItem: () => QAItem,
15147     actionAddEntity: () => actionAddEntity,
15148     actionAddMember: () => actionAddMember,
15149     actionAddMidpoint: () => actionAddMidpoint,
15150     actionAddVertex: () => actionAddVertex,
15151     actionChangeMember: () => actionChangeMember,
15152     actionChangePreset: () => actionChangePreset,
15153     actionChangeTags: () => actionChangeTags,
15154     actionCircularize: () => actionCircularize,
15155     actionConnect: () => actionConnect,
15156     actionCopyEntities: () => actionCopyEntities,
15157     actionDeleteMember: () => actionDeleteMember,
15158     actionDeleteMultiple: () => actionDeleteMultiple,
15159     actionDeleteNode: () => actionDeleteNode,
15160     actionDeleteRelation: () => actionDeleteRelation,
15161     actionDeleteWay: () => actionDeleteWay,
15162     actionDiscardTags: () => actionDiscardTags,
15163     actionDisconnect: () => actionDisconnect,
15164     actionExtract: () => actionExtract,
15165     actionJoin: () => actionJoin,
15166     actionMerge: () => actionMerge,
15167     actionMergeNodes: () => actionMergeNodes,
15168     actionMergePolygon: () => actionMergePolygon,
15169     actionMergeRemoteChanges: () => actionMergeRemoteChanges,
15170     actionMove: () => actionMove,
15171     actionMoveMember: () => actionMoveMember,
15172     actionMoveNode: () => actionMoveNode,
15173     actionNoop: () => actionNoop,
15174     actionOrthogonalize: () => actionOrthogonalize,
15175     actionReflect: () => actionReflect,
15176     actionRestrictTurn: () => actionRestrictTurn,
15177     actionReverse: () => actionReverse,
15178     actionRevert: () => actionRevert,
15179     actionRotate: () => actionRotate,
15180     actionScale: () => actionScale,
15181     actionSplit: () => actionSplit,
15182     actionStraightenNodes: () => actionStraightenNodes,
15183     actionStraightenWay: () => actionStraightenWay,
15184     actionUnrestrictTurn: () => actionUnrestrictTurn,
15185     actionUpgradeTags: () => actionUpgradeTags,
15186     behaviorAddWay: () => behaviorAddWay,
15187     behaviorBreathe: () => behaviorBreathe,
15188     behaviorDrag: () => behaviorDrag,
15189     behaviorDraw: () => behaviorDraw,
15190     behaviorDrawWay: () => behaviorDrawWay,
15191     behaviorEdit: () => behaviorEdit,
15192     behaviorHash: () => behaviorHash,
15193     behaviorHover: () => behaviorHover,
15194     behaviorLasso: () => behaviorLasso,
15195     behaviorOperation: () => behaviorOperation,
15196     behaviorPaste: () => behaviorPaste,
15197     behaviorSelect: () => behaviorSelect,
15198     coreContext: () => coreContext,
15199     coreDifference: () => coreDifference,
15200     coreFileFetcher: () => coreFileFetcher,
15201     coreGraph: () => coreGraph,
15202     coreHistory: () => coreHistory,
15203     coreLocalizer: () => coreLocalizer,
15204     coreTree: () => coreTree,
15205     coreUploader: () => coreUploader,
15206     coreValidator: () => coreValidator,
15207     d3: () => d3,
15208     debug: () => debug,
15209     dmsCoordinatePair: () => dmsCoordinatePair,
15210     dmsMatcher: () => dmsMatcher,
15211     fileFetcher: () => _mainFileFetcher,
15212     geoAngle: () => geoAngle,
15213     geoChooseEdge: () => geoChooseEdge,
15214     geoEdgeEqual: () => geoEdgeEqual,
15215     geoExtent: () => geoExtent,
15216     geoGetSmallestSurroundingRectangle: () => geoGetSmallestSurroundingRectangle,
15217     geoHasLineIntersections: () => geoHasLineIntersections,
15218     geoHasSelfIntersections: () => geoHasSelfIntersections,
15219     geoLatToMeters: () => geoLatToMeters,
15220     geoLineIntersection: () => geoLineIntersection,
15221     geoLonToMeters: () => geoLonToMeters,
15222     geoMetersToLat: () => geoMetersToLat,
15223     geoMetersToLon: () => geoMetersToLon,
15224     geoMetersToOffset: () => geoMetersToOffset,
15225     geoOffsetToMeters: () => geoOffsetToMeters,
15226     geoOrthoCalcScore: () => geoOrthoCalcScore,
15227     geoOrthoCanOrthogonalize: () => geoOrthoCanOrthogonalize,
15228     geoOrthoMaxOffsetAngle: () => geoOrthoMaxOffsetAngle,
15229     geoOrthoNormalizedDotProduct: () => geoOrthoNormalizedDotProduct,
15230     geoPathHasIntersections: () => geoPathHasIntersections,
15231     geoPathIntersections: () => geoPathIntersections,
15232     geoPathLength: () => geoPathLength,
15233     geoPointInPolygon: () => geoPointInPolygon,
15234     geoPolygonContainsPolygon: () => geoPolygonContainsPolygon,
15235     geoPolygonIntersectsPolygon: () => geoPolygonIntersectsPolygon,
15236     geoRawMercator: () => geoRawMercator,
15237     geoRotate: () => geoRotate,
15238     geoScaleToZoom: () => geoScaleToZoom,
15239     geoSphericalClosestNode: () => geoSphericalClosestNode,
15240     geoSphericalDistance: () => geoSphericalDistance,
15241     geoVecAdd: () => geoVecAdd,
15242     geoVecAngle: () => geoVecAngle,
15243     geoVecCross: () => geoVecCross,
15244     geoVecDot: () => geoVecDot,
15245     geoVecEqual: () => geoVecEqual,
15246     geoVecFloor: () => geoVecFloor,
15247     geoVecInterp: () => geoVecInterp,
15248     geoVecLength: () => geoVecLength,
15249     geoVecLengthSquare: () => geoVecLengthSquare,
15250     geoVecNormalize: () => geoVecNormalize,
15251     geoVecNormalizedDot: () => geoVecNormalizedDot,
15252     geoVecProject: () => geoVecProject,
15253     geoVecScale: () => geoVecScale,
15254     geoVecSubtract: () => geoVecSubtract,
15255     geoViewportEdge: () => geoViewportEdge,
15256     geoZoomToScale: () => geoZoomToScale,
15257     likelyRawNumberFormat: () => likelyRawNumberFormat,
15258     localizer: () => _mainLocalizer,
15259     locationManager: () => _sharedLocationManager,
15260     modeAddArea: () => modeAddArea,
15261     modeAddLine: () => modeAddLine,
15262     modeAddNote: () => modeAddNote,
15263     modeAddPoint: () => modeAddPoint,
15264     modeBrowse: () => modeBrowse,
15265     modeDragNode: () => modeDragNode,
15266     modeDragNote: () => modeDragNote,
15267     modeDrawArea: () => modeDrawArea,
15268     modeDrawLine: () => modeDrawLine,
15269     modeMove: () => modeMove,
15270     modeRotate: () => modeRotate,
15271     modeSave: () => modeSave,
15272     modeSelect: () => modeSelect,
15273     modeSelectData: () => modeSelectData,
15274     modeSelectError: () => modeSelectError,
15275     modeSelectNote: () => modeSelectNote,
15276     operationCircularize: () => operationCircularize,
15277     operationContinue: () => operationContinue,
15278     operationCopy: () => operationCopy,
15279     operationDelete: () => operationDelete,
15280     operationDisconnect: () => operationDisconnect,
15281     operationDowngrade: () => operationDowngrade,
15282     operationExtract: () => operationExtract,
15283     operationMerge: () => operationMerge,
15284     operationMove: () => operationMove,
15285     operationOrthogonalize: () => operationOrthogonalize,
15286     operationPaste: () => operationPaste,
15287     operationReflectLong: () => operationReflectLong,
15288     operationReflectShort: () => operationReflectShort,
15289     operationReverse: () => operationReverse,
15290     operationRotate: () => operationRotate,
15291     operationSplit: () => operationSplit,
15292     operationStraighten: () => operationStraighten,
15293     osmAreaKeys: () => osmAreaKeys,
15294     osmChangeset: () => osmChangeset,
15295     osmEntity: () => osmEntity,
15296     osmFlowingWaterwayTagValues: () => osmFlowingWaterwayTagValues,
15297     osmInferRestriction: () => osmInferRestriction,
15298     osmIntersection: () => osmIntersection,
15299     osmIsInterestingTag: () => osmIsInterestingTag,
15300     osmIsOldMultipolygonOuterMember: () => osmIsOldMultipolygonOuterMember,
15301     osmJoinWays: () => osmJoinWays,
15302     osmLanes: () => osmLanes,
15303     osmLifecyclePrefixes: () => osmLifecyclePrefixes,
15304     osmNode: () => osmNode,
15305     osmNodeGeometriesForTags: () => osmNodeGeometriesForTags,
15306     osmNote: () => osmNote,
15307     osmOldMultipolygonOuterMember: () => osmOldMultipolygonOuterMember,
15308     osmOldMultipolygonOuterMemberOfRelation: () => osmOldMultipolygonOuterMemberOfRelation,
15309     osmOneWayTags: () => osmOneWayTags,
15310     osmPavedTags: () => osmPavedTags,
15311     osmPointTags: () => osmPointTags,
15312     osmRailwayTrackTagValues: () => osmRailwayTrackTagValues,
15313     osmRelation: () => osmRelation,
15314     osmRemoveLifecyclePrefix: () => osmRemoveLifecyclePrefix,
15315     osmRoutableHighwayTagValues: () => osmRoutableHighwayTagValues,
15316     osmSetAreaKeys: () => osmSetAreaKeys,
15317     osmSetPointTags: () => osmSetPointTags,
15318     osmSetVertexTags: () => osmSetVertexTags,
15319     osmTagSuggestingArea: () => osmTagSuggestingArea,
15320     osmTurn: () => osmTurn,
15321     osmVertexTags: () => osmVertexTags,
15322     osmWay: () => osmWay,
15323     prefs: () => corePreferences,
15324     presetCategory: () => presetCategory,
15325     presetCollection: () => presetCollection,
15326     presetField: () => presetField,
15327     presetIndex: () => presetIndex,
15328     presetManager: () => _mainPresetIndex,
15329     presetPreset: () => presetPreset,
15330     rendererBackground: () => rendererBackground,
15331     rendererBackgroundSource: () => rendererBackgroundSource,
15332     rendererFeatures: () => rendererFeatures,
15333     rendererMap: () => rendererMap,
15334     rendererPhotos: () => rendererPhotos,
15335     rendererTileLayer: () => rendererTileLayer,
15336     serviceImproveOSM: () => improveOSM_default,
15337     serviceKartaview: () => kartaview_default,
15338     serviceKeepRight: () => keepRight_default,
15339     serviceMapRules: () => maprules_default,
15340     serviceMapilio: () => mapilio_default,
15341     serviceMapillary: () => mapillary_default,
15342     serviceNominatim: () => nominatim_default,
15343     serviceNsi: () => nsi_default,
15344     serviceOsm: () => osm_default,
15345     serviceOsmWikibase: () => osm_wikibase_default,
15346     serviceOsmose: () => osmose_default,
15347     serviceStreetside: () => streetside_default,
15348     serviceTaginfo: () => taginfo_default,
15349     serviceVectorTile: () => vector_tile_default,
15350     serviceVegbilder: () => vegbilder_default,
15351     serviceWikidata: () => wikidata_default,
15352     serviceWikipedia: () => wikipedia_default,
15353     services: () => services,
15354     svgAreas: () => svgAreas,
15355     svgData: () => svgData,
15356     svgDebug: () => svgDebug,
15357     svgDefs: () => svgDefs,
15358     svgGeolocate: () => svgGeolocate,
15359     svgIcon: () => svgIcon,
15360     svgKartaviewImages: () => svgKartaviewImages,
15361     svgKeepRight: () => svgKeepRight,
15362     svgLabels: () => svgLabels,
15363     svgLayers: () => svgLayers,
15364     svgLines: () => svgLines,
15365     svgMapilioImages: () => svgMapilioImages,
15366     svgMapillaryImages: () => svgMapillaryImages,
15367     svgMapillarySigns: () => svgMapillarySigns,
15368     svgMarkerSegments: () => svgMarkerSegments,
15369     svgMidpoints: () => svgMidpoints,
15370     svgNotes: () => svgNotes,
15371     svgOsm: () => svgOsm,
15372     svgPassiveVertex: () => svgPassiveVertex,
15373     svgPath: () => svgPath,
15374     svgPointTransform: () => svgPointTransform,
15375     svgPoints: () => svgPoints,
15376     svgRelationMemberTags: () => svgRelationMemberTags,
15377     svgSegmentWay: () => svgSegmentWay,
15378     svgStreetside: () => svgStreetside,
15379     svgTagClasses: () => svgTagClasses,
15380     svgTagPattern: () => svgTagPattern,
15381     svgTouch: () => svgTouch,
15382     svgTurns: () => svgTurns,
15383     svgVegbilder: () => svgVegbilder,
15384     svgVertices: () => svgVertices,
15385     t: () => _t,
15386     uiAccount: () => uiAccount,
15387     uiAttribution: () => uiAttribution,
15388     uiChangesetEditor: () => uiChangesetEditor,
15389     uiCmd: () => uiCmd,
15390     uiCombobox: () => uiCombobox,
15391     uiCommit: () => uiCommit,
15392     uiCommitWarnings: () => uiCommitWarnings,
15393     uiConfirm: () => uiConfirm,
15394     uiConflicts: () => uiConflicts,
15395     uiContributors: () => uiContributors,
15396     uiCurtain: () => uiCurtain,
15397     uiDataEditor: () => uiDataEditor,
15398     uiDataHeader: () => uiDataHeader,
15399     uiDisclosure: () => uiDisclosure,
15400     uiEditMenu: () => uiEditMenu,
15401     uiEntityEditor: () => uiEntityEditor,
15402     uiFeatureInfo: () => uiFeatureInfo,
15403     uiFeatureList: () => uiFeatureList,
15404     uiField: () => uiField,
15405     uiFieldAccess: () => uiFieldAccess,
15406     uiFieldAddress: () => uiFieldAddress,
15407     uiFieldCheck: () => uiFieldCheck,
15408     uiFieldColour: () => uiFieldText,
15409     uiFieldCombo: () => uiFieldCombo,
15410     uiFieldDefaultCheck: () => uiFieldCheck,
15411     uiFieldDirectionalCombo: () => uiFieldDirectionalCombo,
15412     uiFieldEmail: () => uiFieldText,
15413     uiFieldHelp: () => uiFieldHelp,
15414     uiFieldIdentifier: () => uiFieldText,
15415     uiFieldLanes: () => uiFieldLanes,
15416     uiFieldLocalized: () => uiFieldLocalized,
15417     uiFieldManyCombo: () => uiFieldCombo,
15418     uiFieldMultiCombo: () => uiFieldCombo,
15419     uiFieldNetworkCombo: () => uiFieldCombo,
15420     uiFieldNumber: () => uiFieldText,
15421     uiFieldOnewayCheck: () => uiFieldCheck,
15422     uiFieldRadio: () => uiFieldRadio,
15423     uiFieldRestrictions: () => uiFieldRestrictions,
15424     uiFieldRoadheight: () => uiFieldRoadheight,
15425     uiFieldRoadspeed: () => uiFieldRoadspeed,
15426     uiFieldSemiCombo: () => uiFieldCombo,
15427     uiFieldStructureRadio: () => uiFieldRadio,
15428     uiFieldTel: () => uiFieldText,
15429     uiFieldText: () => uiFieldText,
15430     uiFieldTextarea: () => uiFieldTextarea,
15431     uiFieldTypeCombo: () => uiFieldCombo,
15432     uiFieldUrl: () => uiFieldText,
15433     uiFieldWikidata: () => uiFieldWikidata,
15434     uiFieldWikipedia: () => uiFieldWikipedia,
15435     uiFields: () => uiFields,
15436     uiFlash: () => uiFlash,
15437     uiFormFields: () => uiFormFields,
15438     uiFullScreen: () => uiFullScreen,
15439     uiGeolocate: () => uiGeolocate,
15440     uiImproveOsmComments: () => uiImproveOsmComments,
15441     uiImproveOsmDetails: () => uiImproveOsmDetails,
15442     uiImproveOsmEditor: () => uiImproveOsmEditor,
15443     uiImproveOsmHeader: () => uiImproveOsmHeader,
15444     uiInfo: () => uiInfo,
15445     uiInfoPanels: () => uiInfoPanels,
15446     uiInit: () => uiInit,
15447     uiInspector: () => uiInspector,
15448     uiIntro: () => uiIntro,
15449     uiIssuesInfo: () => uiIssuesInfo,
15450     uiKeepRightDetails: () => uiKeepRightDetails,
15451     uiKeepRightEditor: () => uiKeepRightEditor,
15452     uiKeepRightHeader: () => uiKeepRightHeader,
15453     uiLasso: () => uiLasso,
15454     uiLengthIndicator: () => uiLengthIndicator,
15455     uiLoading: () => uiLoading,
15456     uiMapInMap: () => uiMapInMap,
15457     uiModal: () => uiModal,
15458     uiNoteComments: () => uiNoteComments,
15459     uiNoteEditor: () => uiNoteEditor,
15460     uiNoteHeader: () => uiNoteHeader,
15461     uiNoteReport: () => uiNoteReport,
15462     uiNotice: () => uiNotice,
15463     uiPaneBackground: () => uiPaneBackground,
15464     uiPaneHelp: () => uiPaneHelp,
15465     uiPaneIssues: () => uiPaneIssues,
15466     uiPaneMapData: () => uiPaneMapData,
15467     uiPanePreferences: () => uiPanePreferences,
15468     uiPanelBackground: () => uiPanelBackground,
15469     uiPanelHistory: () => uiPanelHistory,
15470     uiPanelLocation: () => uiPanelLocation,
15471     uiPanelMeasurement: () => uiPanelMeasurement,
15472     uiPopover: () => uiPopover,
15473     uiPresetIcon: () => uiPresetIcon,
15474     uiPresetList: () => uiPresetList,
15475     uiRestore: () => uiRestore,
15476     uiScale: () => uiScale,
15477     uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions,
15478     uiSectionBackgroundList: () => uiSectionBackgroundList,
15479     uiSectionBackgroundOffset: () => uiSectionBackgroundOffset,
15480     uiSectionChanges: () => uiSectionChanges,
15481     uiSectionDataLayers: () => uiSectionDataLayers,
15482     uiSectionEntityIssues: () => uiSectionEntityIssues,
15483     uiSectionFeatureType: () => uiSectionFeatureType,
15484     uiSectionMapFeatures: () => uiSectionMapFeatures,
15485     uiSectionMapStyleOptions: () => uiSectionMapStyleOptions,
15486     uiSectionOverlayList: () => uiSectionOverlayList,
15487     uiSectionPhotoOverlays: () => uiSectionPhotoOverlays,
15488     uiSectionPresetFields: () => uiSectionPresetFields,
15489     uiSectionPrivacy: () => uiSectionPrivacy,
15490     uiSectionRawMemberEditor: () => uiSectionRawMemberEditor,
15491     uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor,
15492     uiSectionRawTagEditor: () => uiSectionRawTagEditor,
15493     uiSectionSelectionList: () => uiSectionSelectionList,
15494     uiSectionValidationIssues: () => uiSectionValidationIssues,
15495     uiSectionValidationOptions: () => uiSectionValidationOptions,
15496     uiSectionValidationRules: () => uiSectionValidationRules,
15497     uiSectionValidationStatus: () => uiSectionValidationStatus,
15498     uiSettingsCustomBackground: () => uiSettingsCustomBackground,
15499     uiSettingsCustomData: () => uiSettingsCustomData,
15500     uiSidebar: () => uiSidebar,
15501     uiSourceSwitch: () => uiSourceSwitch,
15502     uiSpinner: () => uiSpinner,
15503     uiSplash: () => uiSplash,
15504     uiStatus: () => uiStatus,
15505     uiSuccess: () => uiSuccess,
15506     uiTagReference: () => uiTagReference,
15507     uiToggle: () => uiToggle,
15508     uiTooltip: () => uiTooltip,
15509     uiVersion: () => uiVersion,
15510     uiViewOnKeepRight: () => uiViewOnKeepRight,
15511     uiViewOnOSM: () => uiViewOnOSM,
15512     uiZoom: () => uiZoom,
15513     utilAesDecrypt: () => utilAesDecrypt,
15514     utilAesEncrypt: () => utilAesEncrypt,
15515     utilArrayChunk: () => utilArrayChunk,
15516     utilArrayDifference: () => utilArrayDifference,
15517     utilArrayFlatten: () => utilArrayFlatten,
15518     utilArrayGroupBy: () => utilArrayGroupBy,
15519     utilArrayIdentical: () => utilArrayIdentical,
15520     utilArrayIntersection: () => utilArrayIntersection,
15521     utilArrayUnion: () => utilArrayUnion,
15522     utilArrayUniq: () => utilArrayUniq,
15523     utilArrayUniqBy: () => utilArrayUniqBy,
15524     utilAsyncMap: () => utilAsyncMap,
15525     utilCleanOsmString: () => utilCleanOsmString,
15526     utilCleanTags: () => utilCleanTags,
15527     utilCombinedTags: () => utilCombinedTags,
15528     utilCompareIDs: () => utilCompareIDs,
15529     utilDeepMemberSelector: () => utilDeepMemberSelector,
15530     utilDetect: () => utilDetect,
15531     utilDisplayLabel: () => utilDisplayLabel,
15532     utilDisplayName: () => utilDisplayName,
15533     utilDisplayNameForPath: () => utilDisplayNameForPath,
15534     utilDisplayType: () => utilDisplayType,
15535     utilEditDistance: () => utilEditDistance,
15536     utilEntityAndDeepMemberIDs: () => utilEntityAndDeepMemberIDs,
15537     utilEntityOrDeepMemberSelector: () => utilEntityOrDeepMemberSelector,
15538     utilEntityOrMemberSelector: () => utilEntityOrMemberSelector,
15539     utilEntityRoot: () => utilEntityRoot,
15540     utilEntitySelector: () => utilEntitySelector,
15541     utilFastMouse: () => utilFastMouse,
15542     utilFunctor: () => utilFunctor,
15543     utilGetAllNodes: () => utilGetAllNodes,
15544     utilGetSetValue: () => utilGetSetValue,
15545     utilHashcode: () => utilHashcode,
15546     utilHighlightEntities: () => utilHighlightEntities,
15547     utilKeybinding: () => utilKeybinding,
15548     utilNoAuto: () => utilNoAuto,
15549     utilObjectOmit: () => utilObjectOmit,
15550     utilOldestID: () => utilOldestID,
15551     utilPrefixCSSProperty: () => utilPrefixCSSProperty,
15552     utilPrefixDOMProperty: () => utilPrefixDOMProperty,
15553     utilQsString: () => utilQsString,
15554     utilRebind: () => utilRebind,
15555     utilSafeClassName: () => utilSafeClassName,
15556     utilSessionMutex: () => utilSessionMutex,
15557     utilSetTransform: () => utilSetTransform,
15558     utilStringQs: () => utilStringQs,
15559     utilTagDiff: () => utilTagDiff,
15560     utilTagText: () => utilTagText,
15561     utilTiler: () => utilTiler,
15562     utilTotalExtent: () => utilTotalExtent,
15563     utilTriggerEvent: () => utilTriggerEvent,
15564     utilUnicodeCharsCount: () => utilUnicodeCharsCount,
15565     utilUnicodeCharsTruncated: () => utilUnicodeCharsTruncated,
15566     utilUniqueDomId: () => utilUniqueDomId,
15567     utilWrap: () => utilWrap,
15568     validationAlmostJunction: () => validationAlmostJunction,
15569     validationCloseNodes: () => validationCloseNodes,
15570     validationCrossingWays: () => validationCrossingWays,
15571     validationDisconnectedWay: () => validationDisconnectedWay,
15572     validationFormatting: () => validationFormatting,
15573     validationHelpRequest: () => validationHelpRequest,
15574     validationImpossibleOneway: () => validationImpossibleOneway,
15575     validationIncompatibleSource: () => validationIncompatibleSource,
15576     validationMaprules: () => validationMaprules,
15577     validationMismatchedGeometry: () => validationMismatchedGeometry,
15578     validationMissingRole: () => validationMissingRole,
15579     validationMissingTag: () => validationMissingTag,
15580     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
15581     validationOutdatedTags: () => validationOutdatedTags,
15582     validationPrivateData: () => validationPrivateData,
15583     validationSuspiciousName: () => validationSuspiciousName,
15584     validationUnsquareWay: () => validationUnsquareWay
15585   });
15586
15587   // modules/actions/add_entity.js
15588   function actionAddEntity(way) {
15589     return function(graph) {
15590       return graph.replace(way);
15591     };
15592   }
15593
15594   // modules/actions/reverse.js
15595   function actionReverse(entityID, options2) {
15596     var ignoreKey = /^.*(_|:)?(description|name|note|website|ref|source|comment|watch|attribution)(_|:)?/;
15597     var numeric = /^([+\-]?)(?=[\d.])/;
15598     var directionKey = /direction$/;
15599     var turn_lanes = /^turn:lanes:?/;
15600     var keyReplacements = [
15601       [/:right$/, ":left"],
15602       [/:left$/, ":right"],
15603       [/:forward$/, ":backward"],
15604       [/:backward$/, ":forward"],
15605       [/:right:/, ":left:"],
15606       [/:left:/, ":right:"],
15607       [/:forward:/, ":backward:"],
15608       [/:backward:/, ":forward:"]
15609     ];
15610     var valueReplacements = {
15611       left: "right",
15612       right: "left",
15613       up: "down",
15614       down: "up",
15615       forward: "backward",
15616       backward: "forward",
15617       forwards: "backward",
15618       backwards: "forward"
15619     };
15620     const valueReplacementsExceptions = {
15621       "side": [
15622         { highway: "cyclist_waiting_aid" }
15623       ]
15624     };
15625     var roleReplacements = {
15626       forward: "backward",
15627       backward: "forward",
15628       forwards: "backward",
15629       backwards: "forward"
15630     };
15631     var onewayReplacements = {
15632       yes: "-1",
15633       "1": "-1",
15634       "-1": "yes"
15635     };
15636     var compassReplacements = {
15637       N: "S",
15638       NNE: "SSW",
15639       NE: "SW",
15640       ENE: "WSW",
15641       E: "W",
15642       ESE: "WNW",
15643       SE: "NW",
15644       SSE: "NNW",
15645       S: "N",
15646       SSW: "NNE",
15647       SW: "NE",
15648       WSW: "ENE",
15649       W: "E",
15650       WNW: "ESE",
15651       NW: "SE",
15652       NNW: "SSE"
15653     };
15654     function reverseKey(key) {
15655       for (var i3 = 0; i3 < keyReplacements.length; ++i3) {
15656         var replacement = keyReplacements[i3];
15657         if (replacement[0].test(key)) {
15658           return key.replace(replacement[0], replacement[1]);
15659         }
15660       }
15661       return key;
15662     }
15663     function reverseValue(key, value, includeAbsolute, allTags) {
15664       if (ignoreKey.test(key))
15665         return value;
15666       if (turn_lanes.test(key)) {
15667         return value;
15668       } else if (key === "incline" && numeric.test(value)) {
15669         return value.replace(numeric, function(_2, sign2) {
15670           return sign2 === "-" ? "" : "-";
15671         });
15672       } else if (options2 && options2.reverseOneway && key === "oneway") {
15673         return onewayReplacements[value] || value;
15674       } else if (includeAbsolute && directionKey.test(key)) {
15675         return value.split(";").map((value2) => {
15676           if (compassReplacements[value2])
15677             return compassReplacements[value2];
15678           var degrees3 = Number(value2);
15679           if (isFinite(degrees3)) {
15680             if (degrees3 < 180) {
15681               degrees3 += 180;
15682             } else {
15683               degrees3 -= 180;
15684             }
15685             return degrees3.toString();
15686           } else {
15687             return valueReplacements[value2] || value2;
15688           }
15689         }).join(";");
15690       }
15691       if (valueReplacementsExceptions[key] && valueReplacementsExceptions[key].some(
15692         (exceptionTags) => Object.keys(exceptionTags).every((k2) => {
15693           const v2 = exceptionTags[k2];
15694           return allTags[k2] && (v2 === "*" || allTags[k2] === v2);
15695         })
15696       )) {
15697         return value;
15698       }
15699       return valueReplacements[value] || value;
15700     }
15701     function reverseNodeTags(graph, nodeIDs) {
15702       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
15703         var node = graph.hasEntity(nodeIDs[i3]);
15704         if (!node || !Object.keys(node.tags).length)
15705           continue;
15706         var tags = {};
15707         for (var key in node.tags) {
15708           tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags);
15709         }
15710         graph = graph.replace(node.update({ tags }));
15711       }
15712       return graph;
15713     }
15714     function reverseWay(graph, way) {
15715       var nodes = way.nodes.slice().reverse();
15716       var tags = {};
15717       var role;
15718       for (var key in way.tags) {
15719         tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags);
15720       }
15721       graph.parentRelations(way).forEach(function(relation) {
15722         relation.members.forEach(function(member, index) {
15723           if (member.id === way.id && (role = roleReplacements[member.role])) {
15724             relation = relation.updateMember({ role }, index);
15725             graph = graph.replace(relation);
15726           }
15727         });
15728       });
15729       return reverseNodeTags(graph, nodes).replace(way.update({ nodes, tags }));
15730     }
15731     var action = function(graph) {
15732       var entity = graph.entity(entityID);
15733       if (entity.type === "way") {
15734         return reverseWay(graph, entity);
15735       }
15736       return reverseNodeTags(graph, [entityID]);
15737     };
15738     action.disabled = function(graph) {
15739       var entity = graph.hasEntity(entityID);
15740       if (!entity || entity.type === "way")
15741         return false;
15742       for (var key in entity.tags) {
15743         var value = entity.tags[key];
15744         if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) {
15745           return false;
15746         }
15747       }
15748       return "nondirectional_node";
15749     };
15750     action.entityID = function() {
15751       return entityID;
15752     };
15753     return action;
15754   }
15755
15756   // modules/osm/tags.js
15757   function osmIsInterestingTag(key) {
15758     return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
15759     key.indexOf("tiger:") !== 0;
15760   }
15761   var osmLifecyclePrefixes = {
15762     // nonexistent, might be built
15763     proposed: true,
15764     planned: true,
15765     // under maintentance or between groundbreaking and opening
15766     construction: true,
15767     // existent but not functional
15768     disused: true,
15769     // dilapidated to nonexistent
15770     abandoned: true,
15771     was: true,
15772     // nonexistent, still may appear in imagery
15773     dismantled: true,
15774     razed: true,
15775     demolished: true,
15776     destroyed: true,
15777     removed: true,
15778     obliterated: true,
15779     // existent occasionally, e.g. stormwater drainage basin
15780     intermittent: true
15781   };
15782   function osmRemoveLifecyclePrefix(key) {
15783     const keySegments = key.split(":");
15784     if (keySegments.length === 1)
15785       return key;
15786     if (keySegments[0] in osmLifecyclePrefixes) {
15787       return key.slice(keySegments[0].length + 1);
15788     }
15789     return key;
15790   }
15791   var osmAreaKeys = {};
15792   function osmSetAreaKeys(value) {
15793     osmAreaKeys = value;
15794   }
15795   var osmAreaKeysExceptions = {
15796     highway: {
15797       elevator: true,
15798       rest_area: true,
15799       services: true
15800     },
15801     public_transport: {
15802       platform: true
15803     },
15804     railway: {
15805       platform: true,
15806       roundhouse: true,
15807       station: true,
15808       traverser: true,
15809       turntable: true,
15810       wash: true
15811     },
15812     waterway: {
15813       dam: true
15814     }
15815   };
15816   function osmTagSuggestingArea(tags) {
15817     if (tags.area === "yes")
15818       return { area: "yes" };
15819     if (tags.area === "no")
15820       return null;
15821     var returnTags = {};
15822     for (var realKey in tags) {
15823       const key = osmRemoveLifecyclePrefix(realKey);
15824       if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
15825         returnTags[realKey] = tags[realKey];
15826         return returnTags;
15827       }
15828       if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
15829         returnTags[realKey] = tags[realKey];
15830         return returnTags;
15831       }
15832     }
15833     return null;
15834   }
15835   var osmLineTags = {};
15836   function osmSetLineTags(value) {
15837     osmLineTags = value;
15838   }
15839   var osmPointTags = {};
15840   function osmSetPointTags(value) {
15841     osmPointTags = value;
15842   }
15843   var osmVertexTags = {};
15844   function osmSetVertexTags(value) {
15845     osmVertexTags = value;
15846   }
15847   function osmNodeGeometriesForTags(nodeTags) {
15848     var geometries = {};
15849     for (var key in nodeTags) {
15850       if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
15851         geometries.point = true;
15852       }
15853       if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
15854         geometries.vertex = true;
15855       }
15856       if (geometries.point && geometries.vertex)
15857         break;
15858     }
15859     return geometries;
15860   }
15861   var osmOneWayTags = {
15862     "aerialway": {
15863       "chair_lift": true,
15864       "drag_lift": true,
15865       "j-bar": true,
15866       "magic_carpet": true,
15867       "mixed_lift": true,
15868       "platter": true,
15869       "rope_tow": true,
15870       "t-bar": true,
15871       "zip_line": true
15872     },
15873     "highway": {
15874       "motorway": true
15875     },
15876     "junction": {
15877       "circular": true,
15878       "roundabout": true
15879     },
15880     "man_made": {
15881       "goods_conveyor": true,
15882       "piste:halfpipe": true
15883     },
15884     "piste:type": {
15885       "downhill": true,
15886       "sled": true,
15887       "yes": true
15888     },
15889     "seamark:type": {
15890       "two-way_route": true,
15891       "recommended_traffic_lane": true,
15892       "separation_lane": true,
15893       "separation_roundabout": true
15894     },
15895     "waterway": {
15896       "canal": true,
15897       "ditch": true,
15898       "drain": true,
15899       "fish_pass": true,
15900       "pressurised": true,
15901       "river": true,
15902       "spillway": true,
15903       "stream": true,
15904       "tidal_channel": true
15905     }
15906   };
15907   var osmPavedTags = {
15908     "surface": {
15909       "paved": true,
15910       "asphalt": true,
15911       "concrete": true,
15912       "chipseal": true,
15913       "concrete:lanes": true,
15914       "concrete:plates": true
15915     },
15916     "tracktype": {
15917       "grade1": true
15918     }
15919   };
15920   var osmSemipavedTags = {
15921     "surface": {
15922       "cobblestone": true,
15923       "cobblestone:flattened": true,
15924       "unhewn_cobblestone": true,
15925       "sett": true,
15926       "paving_stones": true,
15927       "metal": true,
15928       "wood": true
15929     }
15930   };
15931   var osmRightSideIsInsideTags = {
15932     "natural": {
15933       "cliff": true,
15934       "coastline": "coastline"
15935     },
15936     "barrier": {
15937       "retaining_wall": true,
15938       "kerb": true,
15939       "guard_rail": true,
15940       "city_wall": true
15941     },
15942     "man_made": {
15943       "embankment": true,
15944       "quay": true
15945     },
15946     "waterway": {
15947       "weir": true
15948     }
15949   };
15950   var osmRoutableHighwayTagValues = {
15951     motorway: true,
15952     trunk: true,
15953     primary: true,
15954     secondary: true,
15955     tertiary: true,
15956     residential: true,
15957     motorway_link: true,
15958     trunk_link: true,
15959     primary_link: true,
15960     secondary_link: true,
15961     tertiary_link: true,
15962     unclassified: true,
15963     road: true,
15964     service: true,
15965     track: true,
15966     living_street: true,
15967     bus_guideway: true,
15968     busway: true,
15969     path: true,
15970     footway: true,
15971     cycleway: true,
15972     bridleway: true,
15973     pedestrian: true,
15974     corridor: true,
15975     steps: true
15976   };
15977   var osmPathHighwayTagValues = {
15978     path: true,
15979     footway: true,
15980     cycleway: true,
15981     bridleway: true,
15982     pedestrian: true,
15983     corridor: true,
15984     steps: true
15985   };
15986   var osmRailwayTrackTagValues = {
15987     rail: true,
15988     light_rail: true,
15989     tram: true,
15990     subway: true,
15991     monorail: true,
15992     funicular: true,
15993     miniature: true,
15994     narrow_gauge: true,
15995     disused: true,
15996     preserved: true
15997   };
15998   var osmFlowingWaterwayTagValues = {
15999     canal: true,
16000     ditch: true,
16001     drain: true,
16002     fish_pass: true,
16003     river: true,
16004     stream: true,
16005     tidal_channel: true
16006   };
16007   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/;
16008   function isColourValid(value) {
16009     if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
16010       return false;
16011     }
16012     if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
16013       return false;
16014     }
16015     return true;
16016   }
16017   var osmMutuallyExclusiveTagPairs = [
16018     ["noname", "name"],
16019     ["noref", "ref"],
16020     ["nohousenumber", "addr:housenumber"],
16021     ["noaddress", "addr:housenumber"],
16022     ["noaddress", "addr:housename"],
16023     ["noaddress", "addr:unit"],
16024     ["addr:nostreet", "addr:street"]
16025   ];
16026
16027   // node_modules/d3-array/src/ascending.js
16028   function ascending(a2, b2) {
16029     return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
16030   }
16031
16032   // node_modules/d3-array/src/descending.js
16033   function descending(a2, b2) {
16034     return a2 == null || b2 == null ? NaN : b2 < a2 ? -1 : b2 > a2 ? 1 : b2 >= a2 ? 0 : NaN;
16035   }
16036
16037   // node_modules/d3-array/src/bisector.js
16038   function bisector(f2) {
16039     let compare1, compare2, delta;
16040     if (f2.length !== 2) {
16041       compare1 = ascending;
16042       compare2 = (d2, x2) => ascending(f2(d2), x2);
16043       delta = (d2, x2) => f2(d2) - x2;
16044     } else {
16045       compare1 = f2 === ascending || f2 === descending ? f2 : zero;
16046       compare2 = f2;
16047       delta = f2;
16048     }
16049     function left(a2, x2, lo = 0, hi = a2.length) {
16050       if (lo < hi) {
16051         if (compare1(x2, x2) !== 0)
16052           return hi;
16053         do {
16054           const mid = lo + hi >>> 1;
16055           if (compare2(a2[mid], x2) < 0)
16056             lo = mid + 1;
16057           else
16058             hi = mid;
16059         } while (lo < hi);
16060       }
16061       return lo;
16062     }
16063     function right(a2, x2, lo = 0, hi = a2.length) {
16064       if (lo < hi) {
16065         if (compare1(x2, x2) !== 0)
16066           return hi;
16067         do {
16068           const mid = lo + hi >>> 1;
16069           if (compare2(a2[mid], x2) <= 0)
16070             lo = mid + 1;
16071           else
16072             hi = mid;
16073         } while (lo < hi);
16074       }
16075       return lo;
16076     }
16077     function center(a2, x2, lo = 0, hi = a2.length) {
16078       const i3 = left(a2, x2, lo, hi - 1);
16079       return i3 > lo && delta(a2[i3 - 1], x2) > -delta(a2[i3], x2) ? i3 - 1 : i3;
16080     }
16081     return { left, center, right };
16082   }
16083   function zero() {
16084     return 0;
16085   }
16086
16087   // node_modules/d3-array/src/number.js
16088   function number(x2) {
16089     return x2 === null ? NaN : +x2;
16090   }
16091   function* numbers(values, valueof) {
16092     if (valueof === void 0) {
16093       for (let value of values) {
16094         if (value != null && (value = +value) >= value) {
16095           yield value;
16096         }
16097       }
16098     } else {
16099       let index = -1;
16100       for (let value of values) {
16101         if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
16102           yield value;
16103         }
16104       }
16105     }
16106   }
16107
16108   // node_modules/d3-array/src/bisect.js
16109   var ascendingBisect = bisector(ascending);
16110   var bisectRight = ascendingBisect.right;
16111   var bisectLeft = ascendingBisect.left;
16112   var bisectCenter = bisector(number).center;
16113   var bisect_default = bisectRight;
16114
16115   // node_modules/d3-array/src/fsum.js
16116   var Adder = class {
16117     constructor() {
16118       this._partials = new Float64Array(32);
16119       this._n = 0;
16120     }
16121     add(x2) {
16122       const p2 = this._partials;
16123       let i3 = 0;
16124       for (let j2 = 0; j2 < this._n && j2 < 32; j2++) {
16125         const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2);
16126         if (lo)
16127           p2[i3++] = lo;
16128         x2 = hi;
16129       }
16130       p2[i3] = x2;
16131       this._n = i3 + 1;
16132       return this;
16133     }
16134     valueOf() {
16135       const p2 = this._partials;
16136       let n3 = this._n, x2, y2, lo, hi = 0;
16137       if (n3 > 0) {
16138         hi = p2[--n3];
16139         while (n3 > 0) {
16140           x2 = hi;
16141           y2 = p2[--n3];
16142           hi = x2 + y2;
16143           lo = y2 - (hi - x2);
16144           if (lo)
16145             break;
16146         }
16147         if (n3 > 0 && (lo < 0 && p2[n3 - 1] < 0 || lo > 0 && p2[n3 - 1] > 0)) {
16148           y2 = lo * 2;
16149           x2 = hi + y2;
16150           if (y2 == x2 - hi)
16151             hi = x2;
16152         }
16153       }
16154       return hi;
16155     }
16156   };
16157
16158   // node_modules/d3-array/src/sort.js
16159   function compareDefined(compare2 = ascending) {
16160     if (compare2 === ascending)
16161       return ascendingDefined;
16162     if (typeof compare2 !== "function")
16163       throw new TypeError("compare is not a function");
16164     return (a2, b2) => {
16165       const x2 = compare2(a2, b2);
16166       if (x2 || x2 === 0)
16167         return x2;
16168       return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0);
16169     };
16170   }
16171   function ascendingDefined(a2, b2) {
16172     return (a2 == null || !(a2 >= a2)) - (b2 == null || !(b2 >= b2)) || (a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
16173   }
16174
16175   // node_modules/d3-array/src/ticks.js
16176   var e10 = Math.sqrt(50);
16177   var e5 = Math.sqrt(10);
16178   var e2 = Math.sqrt(2);
16179   function ticks(start2, stop, count) {
16180     var reverse, i3 = -1, n3, ticks2, step;
16181     stop = +stop, start2 = +start2, count = +count;
16182     if (start2 === stop && count > 0)
16183       return [start2];
16184     if (reverse = stop < start2)
16185       n3 = start2, start2 = stop, stop = n3;
16186     if ((step = tickIncrement(start2, stop, count)) === 0 || !isFinite(step))
16187       return [];
16188     if (step > 0) {
16189       let r0 = Math.round(start2 / step), r1 = Math.round(stop / step);
16190       if (r0 * step < start2)
16191         ++r0;
16192       if (r1 * step > stop)
16193         --r1;
16194       ticks2 = new Array(n3 = r1 - r0 + 1);
16195       while (++i3 < n3)
16196         ticks2[i3] = (r0 + i3) * step;
16197     } else {
16198       step = -step;
16199       let r0 = Math.round(start2 * step), r1 = Math.round(stop * step);
16200       if (r0 / step < start2)
16201         ++r0;
16202       if (r1 / step > stop)
16203         --r1;
16204       ticks2 = new Array(n3 = r1 - r0 + 1);
16205       while (++i3 < n3)
16206         ticks2[i3] = (r0 + i3) / step;
16207     }
16208     if (reverse)
16209       ticks2.reverse();
16210     return ticks2;
16211   }
16212   function tickIncrement(start2, stop, count) {
16213     var step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power);
16214     return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
16215   }
16216   function tickStep(start2, stop, count) {
16217     var step0 = Math.abs(stop - start2) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1;
16218     if (error >= e10)
16219       step1 *= 10;
16220     else if (error >= e5)
16221       step1 *= 5;
16222     else if (error >= e2)
16223       step1 *= 2;
16224     return stop < start2 ? -step1 : step1;
16225   }
16226
16227   // node_modules/d3-array/src/max.js
16228   function max(values, valueof) {
16229     let max3;
16230     if (valueof === void 0) {
16231       for (const value of values) {
16232         if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
16233           max3 = value;
16234         }
16235       }
16236     } else {
16237       let index = -1;
16238       for (let value of values) {
16239         if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
16240           max3 = value;
16241         }
16242       }
16243     }
16244     return max3;
16245   }
16246
16247   // node_modules/d3-array/src/min.js
16248   function min(values, valueof) {
16249     let min3;
16250     if (valueof === void 0) {
16251       for (const value of values) {
16252         if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
16253           min3 = value;
16254         }
16255       }
16256     } else {
16257       let index = -1;
16258       for (let value of values) {
16259         if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
16260           min3 = value;
16261         }
16262       }
16263     }
16264     return min3;
16265   }
16266
16267   // node_modules/d3-array/src/quickselect.js
16268   function quickselect(array2, k2, left = 0, right = array2.length - 1, compare2) {
16269     compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
16270     while (right > left) {
16271       if (right - left > 600) {
16272         const n3 = right - left + 1;
16273         const m2 = k2 - left + 1;
16274         const z2 = Math.log(n3);
16275         const s2 = 0.5 * Math.exp(2 * z2 / 3);
16276         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
16277         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
16278         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
16279         quickselect(array2, k2, newLeft, newRight, compare2);
16280       }
16281       const t2 = array2[k2];
16282       let i3 = left;
16283       let j2 = right;
16284       swap(array2, left, k2);
16285       if (compare2(array2[right], t2) > 0)
16286         swap(array2, left, right);
16287       while (i3 < j2) {
16288         swap(array2, i3, j2), ++i3, --j2;
16289         while (compare2(array2[i3], t2) < 0)
16290           ++i3;
16291         while (compare2(array2[j2], t2) > 0)
16292           --j2;
16293       }
16294       if (compare2(array2[left], t2) === 0)
16295         swap(array2, left, j2);
16296       else
16297         ++j2, swap(array2, j2, right);
16298       if (j2 <= k2)
16299         left = j2 + 1;
16300       if (k2 <= j2)
16301         right = j2 - 1;
16302     }
16303     return array2;
16304   }
16305   function swap(array2, i3, j2) {
16306     const t2 = array2[i3];
16307     array2[i3] = array2[j2];
16308     array2[j2] = t2;
16309   }
16310
16311   // node_modules/d3-array/src/quantile.js
16312   function quantile(values, p2, valueof) {
16313     values = Float64Array.from(numbers(values, valueof));
16314     if (!(n3 = values.length))
16315       return;
16316     if ((p2 = +p2) <= 0 || n3 < 2)
16317       return min(values);
16318     if (p2 >= 1)
16319       return max(values);
16320     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));
16321     return value0 + (value1 - value0) * (i3 - i0);
16322   }
16323
16324   // node_modules/d3-array/src/median.js
16325   function median(values, valueof) {
16326     return quantile(values, 0.5, valueof);
16327   }
16328
16329   // node_modules/d3-array/src/merge.js
16330   function* flatten(arrays) {
16331     for (const array2 of arrays) {
16332       yield* array2;
16333     }
16334   }
16335   function merge(arrays) {
16336     return Array.from(flatten(arrays));
16337   }
16338
16339   // node_modules/d3-array/src/pairs.js
16340   function pairs(values, pairof = pair) {
16341     const pairs2 = [];
16342     let previous;
16343     let first = false;
16344     for (const value of values) {
16345       if (first)
16346         pairs2.push(pairof(previous, value));
16347       previous = value;
16348       first = true;
16349     }
16350     return pairs2;
16351   }
16352   function pair(a2, b2) {
16353     return [a2, b2];
16354   }
16355
16356   // node_modules/d3-array/src/range.js
16357   function range(start2, stop, step) {
16358     start2 = +start2, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n3 < 3 ? 1 : +step;
16359     var i3 = -1, n3 = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range3 = new Array(n3);
16360     while (++i3 < n3) {
16361       range3[i3] = start2 + i3 * step;
16362     }
16363     return range3;
16364   }
16365
16366   // node_modules/d3-geo/src/math.js
16367   var epsilon = 1e-6;
16368   var epsilon2 = 1e-12;
16369   var pi = Math.PI;
16370   var halfPi = pi / 2;
16371   var quarterPi = pi / 4;
16372   var tau = pi * 2;
16373   var degrees = 180 / pi;
16374   var radians = pi / 180;
16375   var abs = Math.abs;
16376   var atan = Math.atan;
16377   var atan2 = Math.atan2;
16378   var cos = Math.cos;
16379   var exp = Math.exp;
16380   var log = Math.log;
16381   var sin = Math.sin;
16382   var sign = Math.sign || function(x2) {
16383     return x2 > 0 ? 1 : x2 < 0 ? -1 : 0;
16384   };
16385   var sqrt = Math.sqrt;
16386   var tan = Math.tan;
16387   function acos(x2) {
16388     return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
16389   }
16390   function asin(x2) {
16391     return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
16392   }
16393
16394   // node_modules/d3-geo/src/noop.js
16395   function noop() {
16396   }
16397
16398   // node_modules/d3-geo/src/stream.js
16399   function streamGeometry(geometry, stream) {
16400     if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
16401       streamGeometryType[geometry.type](geometry, stream);
16402     }
16403   }
16404   var streamObjectType = {
16405     Feature: function(object, stream) {
16406       streamGeometry(object.geometry, stream);
16407     },
16408     FeatureCollection: function(object, stream) {
16409       var features = object.features, i3 = -1, n3 = features.length;
16410       while (++i3 < n3)
16411         streamGeometry(features[i3].geometry, stream);
16412     }
16413   };
16414   var streamGeometryType = {
16415     Sphere: function(object, stream) {
16416       stream.sphere();
16417     },
16418     Point: function(object, stream) {
16419       object = object.coordinates;
16420       stream.point(object[0], object[1], object[2]);
16421     },
16422     MultiPoint: function(object, stream) {
16423       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16424       while (++i3 < n3)
16425         object = coordinates[i3], stream.point(object[0], object[1], object[2]);
16426     },
16427     LineString: function(object, stream) {
16428       streamLine(object.coordinates, stream, 0);
16429     },
16430     MultiLineString: function(object, stream) {
16431       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16432       while (++i3 < n3)
16433         streamLine(coordinates[i3], stream, 0);
16434     },
16435     Polygon: function(object, stream) {
16436       streamPolygon(object.coordinates, stream);
16437     },
16438     MultiPolygon: function(object, stream) {
16439       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16440       while (++i3 < n3)
16441         streamPolygon(coordinates[i3], stream);
16442     },
16443     GeometryCollection: function(object, stream) {
16444       var geometries = object.geometries, i3 = -1, n3 = geometries.length;
16445       while (++i3 < n3)
16446         streamGeometry(geometries[i3], stream);
16447     }
16448   };
16449   function streamLine(coordinates, stream, closed) {
16450     var i3 = -1, n3 = coordinates.length - closed, coordinate;
16451     stream.lineStart();
16452     while (++i3 < n3)
16453       coordinate = coordinates[i3], stream.point(coordinate[0], coordinate[1], coordinate[2]);
16454     stream.lineEnd();
16455   }
16456   function streamPolygon(coordinates, stream) {
16457     var i3 = -1, n3 = coordinates.length;
16458     stream.polygonStart();
16459     while (++i3 < n3)
16460       streamLine(coordinates[i3], stream, 1);
16461     stream.polygonEnd();
16462   }
16463   function stream_default(object, stream) {
16464     if (object && streamObjectType.hasOwnProperty(object.type)) {
16465       streamObjectType[object.type](object, stream);
16466     } else {
16467       streamGeometry(object, stream);
16468     }
16469   }
16470
16471   // node_modules/d3-geo/src/area.js
16472   var areaRingSum = new Adder();
16473   var areaSum = new Adder();
16474   var lambda00;
16475   var phi00;
16476   var lambda0;
16477   var cosPhi0;
16478   var sinPhi0;
16479   var areaStream = {
16480     point: noop,
16481     lineStart: noop,
16482     lineEnd: noop,
16483     polygonStart: function() {
16484       areaRingSum = new Adder();
16485       areaStream.lineStart = areaRingStart;
16486       areaStream.lineEnd = areaRingEnd;
16487     },
16488     polygonEnd: function() {
16489       var areaRing = +areaRingSum;
16490       areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
16491       this.lineStart = this.lineEnd = this.point = noop;
16492     },
16493     sphere: function() {
16494       areaSum.add(tau);
16495     }
16496   };
16497   function areaRingStart() {
16498     areaStream.point = areaPointFirst;
16499   }
16500   function areaRingEnd() {
16501     areaPoint(lambda00, phi00);
16502   }
16503   function areaPointFirst(lambda, phi) {
16504     areaStream.point = areaPoint;
16505     lambda00 = lambda, phi00 = phi;
16506     lambda *= radians, phi *= radians;
16507     lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
16508   }
16509   function areaPoint(lambda, phi) {
16510     lambda *= radians, phi *= radians;
16511     phi = phi / 2 + quarterPi;
16512     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);
16513     areaRingSum.add(atan2(v2, u2));
16514     lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
16515   }
16516   function area_default(object) {
16517     areaSum = new Adder();
16518     stream_default(object, areaStream);
16519     return areaSum * 2;
16520   }
16521
16522   // node_modules/d3-geo/src/cartesian.js
16523   function spherical(cartesian2) {
16524     return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
16525   }
16526   function cartesian(spherical2) {
16527     var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
16528     return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
16529   }
16530   function cartesianDot(a2, b2) {
16531     return a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
16532   }
16533   function cartesianCross(a2, b2) {
16534     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]];
16535   }
16536   function cartesianAddInPlace(a2, b2) {
16537     a2[0] += b2[0], a2[1] += b2[1], a2[2] += b2[2];
16538   }
16539   function cartesianScale(vector, k2) {
16540     return [vector[0] * k2, vector[1] * k2, vector[2] * k2];
16541   }
16542   function cartesianNormalizeInPlace(d2) {
16543     var l2 = sqrt(d2[0] * d2[0] + d2[1] * d2[1] + d2[2] * d2[2]);
16544     d2[0] /= l2, d2[1] /= l2, d2[2] /= l2;
16545   }
16546
16547   // node_modules/d3-geo/src/bounds.js
16548   var lambda02;
16549   var phi0;
16550   var lambda1;
16551   var phi1;
16552   var lambda2;
16553   var lambda002;
16554   var phi002;
16555   var p0;
16556   var deltaSum;
16557   var ranges;
16558   var range2;
16559   var boundsStream = {
16560     point: boundsPoint,
16561     lineStart: boundsLineStart,
16562     lineEnd: boundsLineEnd,
16563     polygonStart: function() {
16564       boundsStream.point = boundsRingPoint;
16565       boundsStream.lineStart = boundsRingStart;
16566       boundsStream.lineEnd = boundsRingEnd;
16567       deltaSum = new Adder();
16568       areaStream.polygonStart();
16569     },
16570     polygonEnd: function() {
16571       areaStream.polygonEnd();
16572       boundsStream.point = boundsPoint;
16573       boundsStream.lineStart = boundsLineStart;
16574       boundsStream.lineEnd = boundsLineEnd;
16575       if (areaRingSum < 0)
16576         lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16577       else if (deltaSum > epsilon)
16578         phi1 = 90;
16579       else if (deltaSum < -epsilon)
16580         phi0 = -90;
16581       range2[0] = lambda02, range2[1] = lambda1;
16582     },
16583     sphere: function() {
16584       lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16585     }
16586   };
16587   function boundsPoint(lambda, phi) {
16588     ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16589     if (phi < phi0)
16590       phi0 = phi;
16591     if (phi > phi1)
16592       phi1 = phi;
16593   }
16594   function linePoint(lambda, phi) {
16595     var p2 = cartesian([lambda * radians, phi * radians]);
16596     if (p0) {
16597       var normal = cartesianCross(p0, p2), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
16598       cartesianNormalizeInPlace(inflection);
16599       inflection = spherical(inflection);
16600       var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs(delta) > 180;
16601       if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16602         phii = inflection[1] * degrees;
16603         if (phii > phi1)
16604           phi1 = phii;
16605       } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16606         phii = -inflection[1] * degrees;
16607         if (phii < phi0)
16608           phi0 = phii;
16609       } else {
16610         if (phi < phi0)
16611           phi0 = phi;
16612         if (phi > phi1)
16613           phi1 = phi;
16614       }
16615       if (antimeridian) {
16616         if (lambda < lambda2) {
16617           if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16618             lambda1 = lambda;
16619         } else {
16620           if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16621             lambda02 = lambda;
16622         }
16623       } else {
16624         if (lambda1 >= lambda02) {
16625           if (lambda < lambda02)
16626             lambda02 = lambda;
16627           if (lambda > lambda1)
16628             lambda1 = lambda;
16629         } else {
16630           if (lambda > lambda2) {
16631             if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16632               lambda1 = lambda;
16633           } else {
16634             if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16635               lambda02 = lambda;
16636           }
16637         }
16638       }
16639     } else {
16640       ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16641     }
16642     if (phi < phi0)
16643       phi0 = phi;
16644     if (phi > phi1)
16645       phi1 = phi;
16646     p0 = p2, lambda2 = lambda;
16647   }
16648   function boundsLineStart() {
16649     boundsStream.point = linePoint;
16650   }
16651   function boundsLineEnd() {
16652     range2[0] = lambda02, range2[1] = lambda1;
16653     boundsStream.point = boundsPoint;
16654     p0 = null;
16655   }
16656   function boundsRingPoint(lambda, phi) {
16657     if (p0) {
16658       var delta = lambda - lambda2;
16659       deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
16660     } else {
16661       lambda002 = lambda, phi002 = phi;
16662     }
16663     areaStream.point(lambda, phi);
16664     linePoint(lambda, phi);
16665   }
16666   function boundsRingStart() {
16667     areaStream.lineStart();
16668   }
16669   function boundsRingEnd() {
16670     boundsRingPoint(lambda002, phi002);
16671     areaStream.lineEnd();
16672     if (abs(deltaSum) > epsilon)
16673       lambda02 = -(lambda1 = 180);
16674     range2[0] = lambda02, range2[1] = lambda1;
16675     p0 = null;
16676   }
16677   function angle(lambda04, lambda12) {
16678     return (lambda12 -= lambda04) < 0 ? lambda12 + 360 : lambda12;
16679   }
16680   function rangeCompare(a2, b2) {
16681     return a2[0] - b2[0];
16682   }
16683   function rangeContains(range3, x2) {
16684     return range3[0] <= range3[1] ? range3[0] <= x2 && x2 <= range3[1] : x2 < range3[0] || range3[1] < x2;
16685   }
16686   function bounds_default(feature3) {
16687     var i3, n3, a2, b2, merged, deltaMax, delta;
16688     phi1 = lambda1 = -(lambda02 = phi0 = Infinity);
16689     ranges = [];
16690     stream_default(feature3, boundsStream);
16691     if (n3 = ranges.length) {
16692       ranges.sort(rangeCompare);
16693       for (i3 = 1, a2 = ranges[0], merged = [a2]; i3 < n3; ++i3) {
16694         b2 = ranges[i3];
16695         if (rangeContains(a2, b2[0]) || rangeContains(a2, b2[1])) {
16696           if (angle(a2[0], b2[1]) > angle(a2[0], a2[1]))
16697             a2[1] = b2[1];
16698           if (angle(b2[0], a2[1]) > angle(a2[0], a2[1]))
16699             a2[0] = b2[0];
16700         } else {
16701           merged.push(a2 = b2);
16702         }
16703       }
16704       for (deltaMax = -Infinity, n3 = merged.length - 1, i3 = 0, a2 = merged[n3]; i3 <= n3; a2 = b2, ++i3) {
16705         b2 = merged[i3];
16706         if ((delta = angle(a2[1], b2[0])) > deltaMax)
16707           deltaMax = delta, lambda02 = b2[0], lambda1 = a2[1];
16708       }
16709     }
16710     ranges = range2 = null;
16711     return lambda02 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda02, phi0], [lambda1, phi1]];
16712   }
16713
16714   // node_modules/d3-geo/src/compose.js
16715   function compose_default(a2, b2) {
16716     function compose(x2, y2) {
16717       return x2 = a2(x2, y2), b2(x2[0], x2[1]);
16718     }
16719     if (a2.invert && b2.invert)
16720       compose.invert = function(x2, y2) {
16721         return x2 = b2.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]);
16722       };
16723     return compose;
16724   }
16725
16726   // node_modules/d3-geo/src/rotation.js
16727   function rotationIdentity(lambda, phi) {
16728     return [abs(lambda) > pi ? lambda + Math.round(-lambda / tau) * tau : lambda, phi];
16729   }
16730   rotationIdentity.invert = rotationIdentity;
16731   function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
16732     return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
16733   }
16734   function forwardRotationLambda(deltaLambda) {
16735     return function(lambda, phi) {
16736       return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
16737     };
16738   }
16739   function rotationLambda(deltaLambda) {
16740     var rotation = forwardRotationLambda(deltaLambda);
16741     rotation.invert = forwardRotationLambda(-deltaLambda);
16742     return rotation;
16743   }
16744   function rotationPhiGamma(deltaPhi, deltaGamma) {
16745     var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
16746     function rotation(lambda, phi) {
16747       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaPhi + x2 * sinDeltaPhi;
16748       return [
16749         atan2(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z2 * sinDeltaPhi),
16750         asin(k2 * cosDeltaGamma + y2 * sinDeltaGamma)
16751       ];
16752     }
16753     rotation.invert = function(lambda, phi) {
16754       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaGamma - y2 * sinDeltaGamma;
16755       return [
16756         atan2(y2 * cosDeltaGamma + z2 * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi),
16757         asin(k2 * cosDeltaPhi - x2 * sinDeltaPhi)
16758       ];
16759     };
16760     return rotation;
16761   }
16762   function rotation_default(rotate) {
16763     rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
16764     function forward(coordinates) {
16765       coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
16766       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16767     }
16768     forward.invert = function(coordinates) {
16769       coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
16770       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16771     };
16772     return forward;
16773   }
16774
16775   // node_modules/d3-geo/src/circle.js
16776   function circleStream(stream, radius, delta, direction, t0, t1) {
16777     if (!delta)
16778       return;
16779     var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
16780     if (t0 == null) {
16781       t0 = radius + direction * tau;
16782       t1 = radius - step / 2;
16783     } else {
16784       t0 = circleRadius(cosRadius, t0);
16785       t1 = circleRadius(cosRadius, t1);
16786       if (direction > 0 ? t0 < t1 : t0 > t1)
16787         t0 += direction * tau;
16788     }
16789     for (var point2, t2 = t0; direction > 0 ? t2 > t1 : t2 < t1; t2 -= step) {
16790       point2 = spherical([cosRadius, -sinRadius * cos(t2), -sinRadius * sin(t2)]);
16791       stream.point(point2[0], point2[1]);
16792     }
16793   }
16794   function circleRadius(cosRadius, point2) {
16795     point2 = cartesian(point2), point2[0] -= cosRadius;
16796     cartesianNormalizeInPlace(point2);
16797     var radius = acos(-point2[1]);
16798     return ((-point2[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
16799   }
16800
16801   // node_modules/d3-geo/src/clip/buffer.js
16802   function buffer_default() {
16803     var lines = [], line;
16804     return {
16805       point: function(x2, y2, m2) {
16806         line.push([x2, y2, m2]);
16807       },
16808       lineStart: function() {
16809         lines.push(line = []);
16810       },
16811       lineEnd: noop,
16812       rejoin: function() {
16813         if (lines.length > 1)
16814           lines.push(lines.pop().concat(lines.shift()));
16815       },
16816       result: function() {
16817         var result = lines;
16818         lines = [];
16819         line = null;
16820         return result;
16821       }
16822     };
16823   }
16824
16825   // node_modules/d3-geo/src/pointEqual.js
16826   function pointEqual_default(a2, b2) {
16827     return abs(a2[0] - b2[0]) < epsilon && abs(a2[1] - b2[1]) < epsilon;
16828   }
16829
16830   // node_modules/d3-geo/src/clip/rejoin.js
16831   function Intersection(point2, points, other, entry) {
16832     this.x = point2;
16833     this.z = points;
16834     this.o = other;
16835     this.e = entry;
16836     this.v = false;
16837     this.n = this.p = null;
16838   }
16839   function rejoin_default(segments, compareIntersection2, startInside, interpolate, stream) {
16840     var subject = [], clip = [], i3, n3;
16841     segments.forEach(function(segment) {
16842       if ((n4 = segment.length - 1) <= 0)
16843         return;
16844       var n4, p02 = segment[0], p1 = segment[n4], x2;
16845       if (pointEqual_default(p02, p1)) {
16846         if (!p02[2] && !p1[2]) {
16847           stream.lineStart();
16848           for (i3 = 0; i3 < n4; ++i3)
16849             stream.point((p02 = segment[i3])[0], p02[1]);
16850           stream.lineEnd();
16851           return;
16852         }
16853         p1[0] += 2 * epsilon;
16854       }
16855       subject.push(x2 = new Intersection(p02, segment, null, true));
16856       clip.push(x2.o = new Intersection(p02, null, x2, false));
16857       subject.push(x2 = new Intersection(p1, segment, null, false));
16858       clip.push(x2.o = new Intersection(p1, null, x2, true));
16859     });
16860     if (!subject.length)
16861       return;
16862     clip.sort(compareIntersection2);
16863     link(subject);
16864     link(clip);
16865     for (i3 = 0, n3 = clip.length; i3 < n3; ++i3) {
16866       clip[i3].e = startInside = !startInside;
16867     }
16868     var start2 = subject[0], points, point2;
16869     while (1) {
16870       var current = start2, isSubject = true;
16871       while (current.v)
16872         if ((current = current.n) === start2)
16873           return;
16874       points = current.z;
16875       stream.lineStart();
16876       do {
16877         current.v = current.o.v = true;
16878         if (current.e) {
16879           if (isSubject) {
16880             for (i3 = 0, n3 = points.length; i3 < n3; ++i3)
16881               stream.point((point2 = points[i3])[0], point2[1]);
16882           } else {
16883             interpolate(current.x, current.n.x, 1, stream);
16884           }
16885           current = current.n;
16886         } else {
16887           if (isSubject) {
16888             points = current.p.z;
16889             for (i3 = points.length - 1; i3 >= 0; --i3)
16890               stream.point((point2 = points[i3])[0], point2[1]);
16891           } else {
16892             interpolate(current.x, current.p.x, -1, stream);
16893           }
16894           current = current.p;
16895         }
16896         current = current.o;
16897         points = current.z;
16898         isSubject = !isSubject;
16899       } while (!current.v);
16900       stream.lineEnd();
16901     }
16902   }
16903   function link(array2) {
16904     if (!(n3 = array2.length))
16905       return;
16906     var n3, i3 = 0, a2 = array2[0], b2;
16907     while (++i3 < n3) {
16908       a2.n = b2 = array2[i3];
16909       b2.p = a2;
16910       a2 = b2;
16911     }
16912     a2.n = b2 = array2[0];
16913     b2.p = a2;
16914   }
16915
16916   // node_modules/d3-geo/src/polygonContains.js
16917   function longitude(point2) {
16918     return abs(point2[0]) <= pi ? point2[0] : sign(point2[0]) * ((abs(point2[0]) + pi) % tau - pi);
16919   }
16920   function polygonContains_default(polygon2, point2) {
16921     var lambda = longitude(point2), phi = point2[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
16922     var sum = new Adder();
16923     if (sinPhi === 1)
16924       phi = halfPi + epsilon;
16925     else if (sinPhi === -1)
16926       phi = -halfPi - epsilon;
16927     for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
16928       if (!(m2 = (ring = polygon2[i3]).length))
16929         continue;
16930       var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02);
16931       for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) {
16932         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;
16933         sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta)));
16934         angle2 += antimeridian ? delta + sign2 * tau : delta;
16935         if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) {
16936           var arc = cartesianCross(cartesian(point0), cartesian(point1));
16937           cartesianNormalizeInPlace(arc);
16938           var intersection2 = cartesianCross(normal, arc);
16939           cartesianNormalizeInPlace(intersection2);
16940           var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]);
16941           if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
16942             winding += antimeridian ^ delta >= 0 ? 1 : -1;
16943           }
16944         }
16945       }
16946     }
16947     return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon2) ^ winding & 1;
16948   }
16949
16950   // node_modules/d3-geo/src/clip/index.js
16951   function clip_default(pointVisible, clipLine, interpolate, start2) {
16952     return function(sink) {
16953       var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon2, segments, ring;
16954       var clip = {
16955         point: point2,
16956         lineStart,
16957         lineEnd,
16958         polygonStart: function() {
16959           clip.point = pointRing;
16960           clip.lineStart = ringStart;
16961           clip.lineEnd = ringEnd;
16962           segments = [];
16963           polygon2 = [];
16964         },
16965         polygonEnd: function() {
16966           clip.point = point2;
16967           clip.lineStart = lineStart;
16968           clip.lineEnd = lineEnd;
16969           segments = merge(segments);
16970           var startInside = polygonContains_default(polygon2, start2);
16971           if (segments.length) {
16972             if (!polygonStarted)
16973               sink.polygonStart(), polygonStarted = true;
16974             rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
16975           } else if (startInside) {
16976             if (!polygonStarted)
16977               sink.polygonStart(), polygonStarted = true;
16978             sink.lineStart();
16979             interpolate(null, null, 1, sink);
16980             sink.lineEnd();
16981           }
16982           if (polygonStarted)
16983             sink.polygonEnd(), polygonStarted = false;
16984           segments = polygon2 = null;
16985         },
16986         sphere: function() {
16987           sink.polygonStart();
16988           sink.lineStart();
16989           interpolate(null, null, 1, sink);
16990           sink.lineEnd();
16991           sink.polygonEnd();
16992         }
16993       };
16994       function point2(lambda, phi) {
16995         if (pointVisible(lambda, phi))
16996           sink.point(lambda, phi);
16997       }
16998       function pointLine(lambda, phi) {
16999         line.point(lambda, phi);
17000       }
17001       function lineStart() {
17002         clip.point = pointLine;
17003         line.lineStart();
17004       }
17005       function lineEnd() {
17006         clip.point = point2;
17007         line.lineEnd();
17008       }
17009       function pointRing(lambda, phi) {
17010         ring.push([lambda, phi]);
17011         ringSink.point(lambda, phi);
17012       }
17013       function ringStart() {
17014         ringSink.lineStart();
17015         ring = [];
17016       }
17017       function ringEnd() {
17018         pointRing(ring[0][0], ring[0][1]);
17019         ringSink.lineEnd();
17020         var clean2 = ringSink.clean(), ringSegments = ringBuffer.result(), i3, n3 = ringSegments.length, m2, segment, point3;
17021         ring.pop();
17022         polygon2.push(ring);
17023         ring = null;
17024         if (!n3)
17025           return;
17026         if (clean2 & 1) {
17027           segment = ringSegments[0];
17028           if ((m2 = segment.length - 1) > 0) {
17029             if (!polygonStarted)
17030               sink.polygonStart(), polygonStarted = true;
17031             sink.lineStart();
17032             for (i3 = 0; i3 < m2; ++i3)
17033               sink.point((point3 = segment[i3])[0], point3[1]);
17034             sink.lineEnd();
17035           }
17036           return;
17037         }
17038         if (n3 > 1 && clean2 & 2)
17039           ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
17040         segments.push(ringSegments.filter(validSegment));
17041       }
17042       return clip;
17043     };
17044   }
17045   function validSegment(segment) {
17046     return segment.length > 1;
17047   }
17048   function compareIntersection(a2, b2) {
17049     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]);
17050   }
17051
17052   // node_modules/d3-geo/src/clip/antimeridian.js
17053   var antimeridian_default = clip_default(
17054     function() {
17055       return true;
17056     },
17057     clipAntimeridianLine,
17058     clipAntimeridianInterpolate,
17059     [-pi, -halfPi]
17060   );
17061   function clipAntimeridianLine(stream) {
17062     var lambda04 = NaN, phi02 = NaN, sign0 = NaN, clean2;
17063     return {
17064       lineStart: function() {
17065         stream.lineStart();
17066         clean2 = 1;
17067       },
17068       point: function(lambda12, phi12) {
17069         var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda04);
17070         if (abs(delta - pi) < epsilon) {
17071           stream.point(lambda04, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
17072           stream.point(sign0, phi02);
17073           stream.lineEnd();
17074           stream.lineStart();
17075           stream.point(sign1, phi02);
17076           stream.point(lambda12, phi02);
17077           clean2 = 0;
17078         } else if (sign0 !== sign1 && delta >= pi) {
17079           if (abs(lambda04 - sign0) < epsilon)
17080             lambda04 -= sign0 * epsilon;
17081           if (abs(lambda12 - sign1) < epsilon)
17082             lambda12 -= sign1 * epsilon;
17083           phi02 = clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12);
17084           stream.point(sign0, phi02);
17085           stream.lineEnd();
17086           stream.lineStart();
17087           stream.point(sign1, phi02);
17088           clean2 = 0;
17089         }
17090         stream.point(lambda04 = lambda12, phi02 = phi12);
17091         sign0 = sign1;
17092       },
17093       lineEnd: function() {
17094         stream.lineEnd();
17095         lambda04 = phi02 = NaN;
17096       },
17097       clean: function() {
17098         return 2 - clean2;
17099       }
17100     };
17101   }
17102   function clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12) {
17103     var cosPhi03, cosPhi1, sinLambda0Lambda1 = sin(lambda04 - lambda12);
17104     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;
17105   }
17106   function clipAntimeridianInterpolate(from, to, direction, stream) {
17107     var phi;
17108     if (from == null) {
17109       phi = direction * halfPi;
17110       stream.point(-pi, phi);
17111       stream.point(0, phi);
17112       stream.point(pi, phi);
17113       stream.point(pi, 0);
17114       stream.point(pi, -phi);
17115       stream.point(0, -phi);
17116       stream.point(-pi, -phi);
17117       stream.point(-pi, 0);
17118       stream.point(-pi, phi);
17119     } else if (abs(from[0] - to[0]) > epsilon) {
17120       var lambda = from[0] < to[0] ? pi : -pi;
17121       phi = direction * lambda / 2;
17122       stream.point(-lambda, phi);
17123       stream.point(0, phi);
17124       stream.point(lambda, phi);
17125     } else {
17126       stream.point(to[0], to[1]);
17127     }
17128   }
17129
17130   // node_modules/d3-geo/src/clip/circle.js
17131   function circle_default(radius) {
17132     var cr = cos(radius), delta = 6 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
17133     function interpolate(from, to, direction, stream) {
17134       circleStream(stream, radius, delta, direction, from, to);
17135     }
17136     function visible(lambda, phi) {
17137       return cos(lambda) * cos(phi) > cr;
17138     }
17139     function clipLine(stream) {
17140       var point0, c0, v0, v00, clean2;
17141       return {
17142         lineStart: function() {
17143           v00 = v0 = false;
17144           clean2 = 1;
17145         },
17146         point: function(lambda, phi) {
17147           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;
17148           if (!point0 && (v00 = v0 = v2))
17149             stream.lineStart();
17150           if (v2 !== v0) {
17151             point2 = intersect2(point0, point1);
17152             if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2))
17153               point1[2] = 1;
17154           }
17155           if (v2 !== v0) {
17156             clean2 = 0;
17157             if (v2) {
17158               stream.lineStart();
17159               point2 = intersect2(point1, point0);
17160               stream.point(point2[0], point2[1]);
17161             } else {
17162               point2 = intersect2(point0, point1);
17163               stream.point(point2[0], point2[1], 2);
17164               stream.lineEnd();
17165             }
17166             point0 = point2;
17167           } else if (notHemisphere && point0 && smallRadius ^ v2) {
17168             var t2;
17169             if (!(c2 & c0) && (t2 = intersect2(point1, point0, true))) {
17170               clean2 = 0;
17171               if (smallRadius) {
17172                 stream.lineStart();
17173                 stream.point(t2[0][0], t2[0][1]);
17174                 stream.point(t2[1][0], t2[1][1]);
17175                 stream.lineEnd();
17176               } else {
17177                 stream.point(t2[1][0], t2[1][1]);
17178                 stream.lineEnd();
17179                 stream.lineStart();
17180                 stream.point(t2[0][0], t2[0][1], 3);
17181               }
17182             }
17183           }
17184           if (v2 && (!point0 || !pointEqual_default(point0, point1))) {
17185             stream.point(point1[0], point1[1]);
17186           }
17187           point0 = point1, v0 = v2, c0 = c2;
17188         },
17189         lineEnd: function() {
17190           if (v0)
17191             stream.lineEnd();
17192           point0 = null;
17193         },
17194         // Rejoin first and last segments if there were intersections and the first
17195         // and last points were visible.
17196         clean: function() {
17197           return clean2 | (v00 && v0) << 1;
17198         }
17199       };
17200     }
17201     function intersect2(a2, b2, two) {
17202       var pa = cartesian(a2), pb = cartesian(b2);
17203       var n1 = [1, 0, 0], n22 = cartesianCross(pa, pb), n2n2 = cartesianDot(n22, n22), n1n2 = n22[0], determinant = n2n2 - n1n2 * n1n2;
17204       if (!determinant)
17205         return !two && a2;
17206       var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n22), A2 = cartesianScale(n1, c1), B2 = cartesianScale(n22, c2);
17207       cartesianAddInPlace(A2, B2);
17208       var u2 = n1xn2, w2 = cartesianDot(A2, u2), uu = cartesianDot(u2, u2), t2 = w2 * w2 - uu * (cartesianDot(A2, A2) - 1);
17209       if (t2 < 0)
17210         return;
17211       var t3 = sqrt(t2), q2 = cartesianScale(u2, (-w2 - t3) / uu);
17212       cartesianAddInPlace(q2, A2);
17213       q2 = spherical(q2);
17214       if (!two)
17215         return q2;
17216       var lambda04 = a2[0], lambda12 = b2[0], phi02 = a2[1], phi12 = b2[1], z2;
17217       if (lambda12 < lambda04)
17218         z2 = lambda04, lambda04 = lambda12, lambda12 = z2;
17219       var delta2 = lambda12 - lambda04, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
17220       if (!polar && phi12 < phi02)
17221         z2 = phi02, phi02 = phi12, phi12 = z2;
17222       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)) {
17223         var q1 = cartesianScale(u2, (-w2 + t3) / uu);
17224         cartesianAddInPlace(q1, A2);
17225         return [q2, spherical(q1)];
17226       }
17227     }
17228     function code(lambda, phi) {
17229       var r2 = smallRadius ? radius : pi - radius, code2 = 0;
17230       if (lambda < -r2)
17231         code2 |= 1;
17232       else if (lambda > r2)
17233         code2 |= 2;
17234       if (phi < -r2)
17235         code2 |= 4;
17236       else if (phi > r2)
17237         code2 |= 8;
17238       return code2;
17239     }
17240     return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
17241   }
17242
17243   // node_modules/d3-geo/src/clip/line.js
17244   function line_default(a2, b2, x05, y05, x12, y12) {
17245     var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r2;
17246     r2 = x05 - ax;
17247     if (!dx && r2 > 0)
17248       return;
17249     r2 /= dx;
17250     if (dx < 0) {
17251       if (r2 < t0)
17252         return;
17253       if (r2 < t1)
17254         t1 = r2;
17255     } else if (dx > 0) {
17256       if (r2 > t1)
17257         return;
17258       if (r2 > t0)
17259         t0 = r2;
17260     }
17261     r2 = x12 - ax;
17262     if (!dx && r2 < 0)
17263       return;
17264     r2 /= dx;
17265     if (dx < 0) {
17266       if (r2 > t1)
17267         return;
17268       if (r2 > t0)
17269         t0 = r2;
17270     } else if (dx > 0) {
17271       if (r2 < t0)
17272         return;
17273       if (r2 < t1)
17274         t1 = r2;
17275     }
17276     r2 = y05 - ay;
17277     if (!dy && r2 > 0)
17278       return;
17279     r2 /= dy;
17280     if (dy < 0) {
17281       if (r2 < t0)
17282         return;
17283       if (r2 < t1)
17284         t1 = r2;
17285     } else if (dy > 0) {
17286       if (r2 > t1)
17287         return;
17288       if (r2 > t0)
17289         t0 = r2;
17290     }
17291     r2 = y12 - ay;
17292     if (!dy && r2 < 0)
17293       return;
17294     r2 /= dy;
17295     if (dy < 0) {
17296       if (r2 > t1)
17297         return;
17298       if (r2 > t0)
17299         t0 = r2;
17300     } else if (dy > 0) {
17301       if (r2 < t0)
17302         return;
17303       if (r2 < t1)
17304         t1 = r2;
17305     }
17306     if (t0 > 0)
17307       a2[0] = ax + t0 * dx, a2[1] = ay + t0 * dy;
17308     if (t1 < 1)
17309       b2[0] = ax + t1 * dx, b2[1] = ay + t1 * dy;
17310     return true;
17311   }
17312
17313   // node_modules/d3-geo/src/clip/rectangle.js
17314   var clipMax = 1e9;
17315   var clipMin = -clipMax;
17316   function clipRectangle(x05, y05, x12, y12) {
17317     function visible(x2, y2) {
17318       return x05 <= x2 && x2 <= x12 && y05 <= y2 && y2 <= y12;
17319     }
17320     function interpolate(from, to, direction, stream) {
17321       var a2 = 0, a1 = 0;
17322       if (from == null || (a2 = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
17323         do
17324           stream.point(a2 === 0 || a2 === 3 ? x05 : x12, a2 > 1 ? y12 : y05);
17325         while ((a2 = (a2 + direction + 4) % 4) !== a1);
17326       } else {
17327         stream.point(to[0], to[1]);
17328       }
17329     }
17330     function corner(p2, direction) {
17331       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;
17332     }
17333     function compareIntersection2(a2, b2) {
17334       return comparePoint(a2.x, b2.x);
17335     }
17336     function comparePoint(a2, b2) {
17337       var ca = corner(a2, 1), cb = corner(b2, 1);
17338       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];
17339     }
17340     return function(stream) {
17341       var activeStream = stream, bufferStream = buffer_default(), segments, polygon2, ring, x__, y__, v__, x_, y_, v_, first, clean2;
17342       var clipStream = {
17343         point: point2,
17344         lineStart,
17345         lineEnd,
17346         polygonStart,
17347         polygonEnd
17348       };
17349       function point2(x2, y2) {
17350         if (visible(x2, y2))
17351           activeStream.point(x2, y2);
17352       }
17353       function polygonInside() {
17354         var winding = 0;
17355         for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
17356           for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b0 = point3[0], b1 = point3[1]; j2 < m2; ++j2) {
17357             a0 = b0, a1 = b1, point3 = ring2[j2], b0 = point3[0], b1 = point3[1];
17358             if (a1 <= y12) {
17359               if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0))
17360                 ++winding;
17361             } else {
17362               if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x05 - a0))
17363                 --winding;
17364             }
17365           }
17366         }
17367         return winding;
17368       }
17369       function polygonStart() {
17370         activeStream = bufferStream, segments = [], polygon2 = [], clean2 = true;
17371       }
17372       function polygonEnd() {
17373         var startInside = polygonInside(), cleanInside = clean2 && startInside, visible2 = (segments = merge(segments)).length;
17374         if (cleanInside || visible2) {
17375           stream.polygonStart();
17376           if (cleanInside) {
17377             stream.lineStart();
17378             interpolate(null, null, 1, stream);
17379             stream.lineEnd();
17380           }
17381           if (visible2) {
17382             rejoin_default(segments, compareIntersection2, startInside, interpolate, stream);
17383           }
17384           stream.polygonEnd();
17385         }
17386         activeStream = stream, segments = polygon2 = ring = null;
17387       }
17388       function lineStart() {
17389         clipStream.point = linePoint2;
17390         if (polygon2)
17391           polygon2.push(ring = []);
17392         first = true;
17393         v_ = false;
17394         x_ = y_ = NaN;
17395       }
17396       function lineEnd() {
17397         if (segments) {
17398           linePoint2(x__, y__);
17399           if (v__ && v_)
17400             bufferStream.rejoin();
17401           segments.push(bufferStream.result());
17402         }
17403         clipStream.point = point2;
17404         if (v_)
17405           activeStream.lineEnd();
17406       }
17407       function linePoint2(x2, y2) {
17408         var v2 = visible(x2, y2);
17409         if (polygon2)
17410           ring.push([x2, y2]);
17411         if (first) {
17412           x__ = x2, y__ = y2, v__ = v2;
17413           first = false;
17414           if (v2) {
17415             activeStream.lineStart();
17416             activeStream.point(x2, y2);
17417           }
17418         } else {
17419           if (v2 && v_)
17420             activeStream.point(x2, y2);
17421           else {
17422             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))];
17423             if (line_default(a2, b2, x05, y05, x12, y12)) {
17424               if (!v_) {
17425                 activeStream.lineStart();
17426                 activeStream.point(a2[0], a2[1]);
17427               }
17428               activeStream.point(b2[0], b2[1]);
17429               if (!v2)
17430                 activeStream.lineEnd();
17431               clean2 = false;
17432             } else if (v2) {
17433               activeStream.lineStart();
17434               activeStream.point(x2, y2);
17435               clean2 = false;
17436             }
17437           }
17438         }
17439         x_ = x2, y_ = y2, v_ = v2;
17440       }
17441       return clipStream;
17442     };
17443   }
17444
17445   // node_modules/d3-geo/src/length.js
17446   var lengthSum;
17447   var lambda03;
17448   var sinPhi02;
17449   var cosPhi02;
17450   var lengthStream = {
17451     sphere: noop,
17452     point: noop,
17453     lineStart: lengthLineStart,
17454     lineEnd: noop,
17455     polygonStart: noop,
17456     polygonEnd: noop
17457   };
17458   function lengthLineStart() {
17459     lengthStream.point = lengthPointFirst;
17460     lengthStream.lineEnd = lengthLineEnd;
17461   }
17462   function lengthLineEnd() {
17463     lengthStream.point = lengthStream.lineEnd = noop;
17464   }
17465   function lengthPointFirst(lambda, phi) {
17466     lambda *= radians, phi *= radians;
17467     lambda03 = lambda, sinPhi02 = sin(phi), cosPhi02 = cos(phi);
17468     lengthStream.point = lengthPoint;
17469   }
17470   function lengthPoint(lambda, phi) {
17471     lambda *= radians, phi *= radians;
17472     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;
17473     lengthSum.add(atan2(sqrt(x2 * x2 + y2 * y2), z2));
17474     lambda03 = lambda, sinPhi02 = sinPhi, cosPhi02 = cosPhi;
17475   }
17476   function length_default(object) {
17477     lengthSum = new Adder();
17478     stream_default(object, lengthStream);
17479     return +lengthSum;
17480   }
17481
17482   // node_modules/d3-geo/src/identity.js
17483   var identity_default = (x2) => x2;
17484
17485   // node_modules/d3-geo/src/path/area.js
17486   var areaSum2 = new Adder();
17487   var areaRingSum2 = new Adder();
17488   var x00;
17489   var y00;
17490   var x0;
17491   var y0;
17492   var areaStream2 = {
17493     point: noop,
17494     lineStart: noop,
17495     lineEnd: noop,
17496     polygonStart: function() {
17497       areaStream2.lineStart = areaRingStart2;
17498       areaStream2.lineEnd = areaRingEnd2;
17499     },
17500     polygonEnd: function() {
17501       areaStream2.lineStart = areaStream2.lineEnd = areaStream2.point = noop;
17502       areaSum2.add(abs(areaRingSum2));
17503       areaRingSum2 = new Adder();
17504     },
17505     result: function() {
17506       var area = areaSum2 / 2;
17507       areaSum2 = new Adder();
17508       return area;
17509     }
17510   };
17511   function areaRingStart2() {
17512     areaStream2.point = areaPointFirst2;
17513   }
17514   function areaPointFirst2(x2, y2) {
17515     areaStream2.point = areaPoint2;
17516     x00 = x0 = x2, y00 = y0 = y2;
17517   }
17518   function areaPoint2(x2, y2) {
17519     areaRingSum2.add(y0 * x2 - x0 * y2);
17520     x0 = x2, y0 = y2;
17521   }
17522   function areaRingEnd2() {
17523     areaPoint2(x00, y00);
17524   }
17525   var area_default2 = areaStream2;
17526
17527   // node_modules/d3-geo/src/path/bounds.js
17528   var x02 = Infinity;
17529   var y02 = x02;
17530   var x1 = -x02;
17531   var y1 = x1;
17532   var boundsStream2 = {
17533     point: boundsPoint2,
17534     lineStart: noop,
17535     lineEnd: noop,
17536     polygonStart: noop,
17537     polygonEnd: noop,
17538     result: function() {
17539       var bounds = [[x02, y02], [x1, y1]];
17540       x1 = y1 = -(y02 = x02 = Infinity);
17541       return bounds;
17542     }
17543   };
17544   function boundsPoint2(x2, y2) {
17545     if (x2 < x02)
17546       x02 = x2;
17547     if (x2 > x1)
17548       x1 = x2;
17549     if (y2 < y02)
17550       y02 = y2;
17551     if (y2 > y1)
17552       y1 = y2;
17553   }
17554   var bounds_default2 = boundsStream2;
17555
17556   // node_modules/d3-geo/src/path/centroid.js
17557   var X0 = 0;
17558   var Y0 = 0;
17559   var Z0 = 0;
17560   var X1 = 0;
17561   var Y1 = 0;
17562   var Z1 = 0;
17563   var X2 = 0;
17564   var Y2 = 0;
17565   var Z2 = 0;
17566   var x002;
17567   var y002;
17568   var x03;
17569   var y03;
17570   var centroidStream = {
17571     point: centroidPoint,
17572     lineStart: centroidLineStart,
17573     lineEnd: centroidLineEnd,
17574     polygonStart: function() {
17575       centroidStream.lineStart = centroidRingStart;
17576       centroidStream.lineEnd = centroidRingEnd;
17577     },
17578     polygonEnd: function() {
17579       centroidStream.point = centroidPoint;
17580       centroidStream.lineStart = centroidLineStart;
17581       centroidStream.lineEnd = centroidLineEnd;
17582     },
17583     result: function() {
17584       var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
17585       X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
17586       return centroid;
17587     }
17588   };
17589   function centroidPoint(x2, y2) {
17590     X0 += x2;
17591     Y0 += y2;
17592     ++Z0;
17593   }
17594   function centroidLineStart() {
17595     centroidStream.point = centroidPointFirstLine;
17596   }
17597   function centroidPointFirstLine(x2, y2) {
17598     centroidStream.point = centroidPointLine;
17599     centroidPoint(x03 = x2, y03 = y2);
17600   }
17601   function centroidPointLine(x2, y2) {
17602     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17603     X1 += z2 * (x03 + x2) / 2;
17604     Y1 += z2 * (y03 + y2) / 2;
17605     Z1 += z2;
17606     centroidPoint(x03 = x2, y03 = y2);
17607   }
17608   function centroidLineEnd() {
17609     centroidStream.point = centroidPoint;
17610   }
17611   function centroidRingStart() {
17612     centroidStream.point = centroidPointFirstRing;
17613   }
17614   function centroidRingEnd() {
17615     centroidPointRing(x002, y002);
17616   }
17617   function centroidPointFirstRing(x2, y2) {
17618     centroidStream.point = centroidPointRing;
17619     centroidPoint(x002 = x03 = x2, y002 = y03 = y2);
17620   }
17621   function centroidPointRing(x2, y2) {
17622     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17623     X1 += z2 * (x03 + x2) / 2;
17624     Y1 += z2 * (y03 + y2) / 2;
17625     Z1 += z2;
17626     z2 = y03 * x2 - x03 * y2;
17627     X2 += z2 * (x03 + x2);
17628     Y2 += z2 * (y03 + y2);
17629     Z2 += z2 * 3;
17630     centroidPoint(x03 = x2, y03 = y2);
17631   }
17632   var centroid_default = centroidStream;
17633
17634   // node_modules/d3-geo/src/path/context.js
17635   function PathContext(context) {
17636     this._context = context;
17637   }
17638   PathContext.prototype = {
17639     _radius: 4.5,
17640     pointRadius: function(_2) {
17641       return this._radius = _2, this;
17642     },
17643     polygonStart: function() {
17644       this._line = 0;
17645     },
17646     polygonEnd: function() {
17647       this._line = NaN;
17648     },
17649     lineStart: function() {
17650       this._point = 0;
17651     },
17652     lineEnd: function() {
17653       if (this._line === 0)
17654         this._context.closePath();
17655       this._point = NaN;
17656     },
17657     point: function(x2, y2) {
17658       switch (this._point) {
17659         case 0: {
17660           this._context.moveTo(x2, y2);
17661           this._point = 1;
17662           break;
17663         }
17664         case 1: {
17665           this._context.lineTo(x2, y2);
17666           break;
17667         }
17668         default: {
17669           this._context.moveTo(x2 + this._radius, y2);
17670           this._context.arc(x2, y2, this._radius, 0, tau);
17671           break;
17672         }
17673       }
17674     },
17675     result: noop
17676   };
17677
17678   // node_modules/d3-geo/src/path/measure.js
17679   var lengthSum2 = new Adder();
17680   var lengthRing;
17681   var x003;
17682   var y003;
17683   var x04;
17684   var y04;
17685   var lengthStream2 = {
17686     point: noop,
17687     lineStart: function() {
17688       lengthStream2.point = lengthPointFirst2;
17689     },
17690     lineEnd: function() {
17691       if (lengthRing)
17692         lengthPoint2(x003, y003);
17693       lengthStream2.point = noop;
17694     },
17695     polygonStart: function() {
17696       lengthRing = true;
17697     },
17698     polygonEnd: function() {
17699       lengthRing = null;
17700     },
17701     result: function() {
17702       var length2 = +lengthSum2;
17703       lengthSum2 = new Adder();
17704       return length2;
17705     }
17706   };
17707   function lengthPointFirst2(x2, y2) {
17708     lengthStream2.point = lengthPoint2;
17709     x003 = x04 = x2, y003 = y04 = y2;
17710   }
17711   function lengthPoint2(x2, y2) {
17712     x04 -= x2, y04 -= y2;
17713     lengthSum2.add(sqrt(x04 * x04 + y04 * y04));
17714     x04 = x2, y04 = y2;
17715   }
17716   var measure_default = lengthStream2;
17717
17718   // node_modules/d3-geo/src/path/string.js
17719   function PathString() {
17720     this._string = [];
17721   }
17722   PathString.prototype = {
17723     _radius: 4.5,
17724     _circle: circle(4.5),
17725     pointRadius: function(_2) {
17726       if ((_2 = +_2) !== this._radius)
17727         this._radius = _2, this._circle = null;
17728       return this;
17729     },
17730     polygonStart: function() {
17731       this._line = 0;
17732     },
17733     polygonEnd: function() {
17734       this._line = NaN;
17735     },
17736     lineStart: function() {
17737       this._point = 0;
17738     },
17739     lineEnd: function() {
17740       if (this._line === 0)
17741         this._string.push("Z");
17742       this._point = NaN;
17743     },
17744     point: function(x2, y2) {
17745       switch (this._point) {
17746         case 0: {
17747           this._string.push("M", x2, ",", y2);
17748           this._point = 1;
17749           break;
17750         }
17751         case 1: {
17752           this._string.push("L", x2, ",", y2);
17753           break;
17754         }
17755         default: {
17756           if (this._circle == null)
17757             this._circle = circle(this._radius);
17758           this._string.push("M", x2, ",", y2, this._circle);
17759           break;
17760         }
17761       }
17762     },
17763     result: function() {
17764       if (this._string.length) {
17765         var result = this._string.join("");
17766         this._string = [];
17767         return result;
17768       } else {
17769         return null;
17770       }
17771     }
17772   };
17773   function circle(radius) {
17774     return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
17775   }
17776
17777   // node_modules/d3-geo/src/path/index.js
17778   function path_default(projection2, context) {
17779     var pointRadius = 4.5, projectionStream, contextStream;
17780     function path(object) {
17781       if (object) {
17782         if (typeof pointRadius === "function")
17783           contextStream.pointRadius(+pointRadius.apply(this, arguments));
17784         stream_default(object, projectionStream(contextStream));
17785       }
17786       return contextStream.result();
17787     }
17788     path.area = function(object) {
17789       stream_default(object, projectionStream(area_default2));
17790       return area_default2.result();
17791     };
17792     path.measure = function(object) {
17793       stream_default(object, projectionStream(measure_default));
17794       return measure_default.result();
17795     };
17796     path.bounds = function(object) {
17797       stream_default(object, projectionStream(bounds_default2));
17798       return bounds_default2.result();
17799     };
17800     path.centroid = function(object) {
17801       stream_default(object, projectionStream(centroid_default));
17802       return centroid_default.result();
17803     };
17804     path.projection = function(_2) {
17805       return arguments.length ? (projectionStream = _2 == null ? (projection2 = null, identity_default) : (projection2 = _2).stream, path) : projection2;
17806     };
17807     path.context = function(_2) {
17808       if (!arguments.length)
17809         return context;
17810       contextStream = _2 == null ? (context = null, new PathString()) : new PathContext(context = _2);
17811       if (typeof pointRadius !== "function")
17812         contextStream.pointRadius(pointRadius);
17813       return path;
17814     };
17815     path.pointRadius = function(_2) {
17816       if (!arguments.length)
17817         return pointRadius;
17818       pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2);
17819       return path;
17820     };
17821     return path.projection(projection2).context(context);
17822   }
17823
17824   // node_modules/d3-geo/src/transform.js
17825   function transform_default(methods2) {
17826     return {
17827       stream: transformer(methods2)
17828     };
17829   }
17830   function transformer(methods2) {
17831     return function(stream) {
17832       var s2 = new TransformStream();
17833       for (var key in methods2)
17834         s2[key] = methods2[key];
17835       s2.stream = stream;
17836       return s2;
17837     };
17838   }
17839   function TransformStream() {
17840   }
17841   TransformStream.prototype = {
17842     constructor: TransformStream,
17843     point: function(x2, y2) {
17844       this.stream.point(x2, y2);
17845     },
17846     sphere: function() {
17847       this.stream.sphere();
17848     },
17849     lineStart: function() {
17850       this.stream.lineStart();
17851     },
17852     lineEnd: function() {
17853       this.stream.lineEnd();
17854     },
17855     polygonStart: function() {
17856       this.stream.polygonStart();
17857     },
17858     polygonEnd: function() {
17859       this.stream.polygonEnd();
17860     }
17861   };
17862
17863   // node_modules/d3-geo/src/projection/fit.js
17864   function fit(projection2, fitBounds, object) {
17865     var clip = projection2.clipExtent && projection2.clipExtent();
17866     projection2.scale(150).translate([0, 0]);
17867     if (clip != null)
17868       projection2.clipExtent(null);
17869     stream_default(object, projection2.stream(bounds_default2));
17870     fitBounds(bounds_default2.result());
17871     if (clip != null)
17872       projection2.clipExtent(clip);
17873     return projection2;
17874   }
17875   function fitExtent(projection2, extent, object) {
17876     return fit(projection2, function(b2) {
17877       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;
17878       projection2.scale(150 * k2).translate([x2, y2]);
17879     }, object);
17880   }
17881   function fitSize(projection2, size, object) {
17882     return fitExtent(projection2, [[0, 0], size], object);
17883   }
17884   function fitWidth(projection2, width, object) {
17885     return fit(projection2, function(b2) {
17886       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];
17887       projection2.scale(150 * k2).translate([x2, y2]);
17888     }, object);
17889   }
17890   function fitHeight(projection2, height, object) {
17891     return fit(projection2, function(b2) {
17892       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;
17893       projection2.scale(150 * k2).translate([x2, y2]);
17894     }, object);
17895   }
17896
17897   // node_modules/d3-geo/src/projection/resample.js
17898   var maxDepth = 16;
17899   var cosMinDistance = cos(30 * radians);
17900   function resample_default(project, delta2) {
17901     return +delta2 ? resample(project, delta2) : resampleNone(project);
17902   }
17903   function resampleNone(project) {
17904     return transformer({
17905       point: function(x2, y2) {
17906         x2 = project(x2, y2);
17907         this.stream.point(x2[0], x2[1]);
17908       }
17909     });
17910   }
17911   function resample(project, delta2) {
17912     function resampleLineTo(x05, y05, lambda04, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
17913       var dx = x12 - x05, dy = y12 - y05, d2 = dx * dx + dy * dy;
17914       if (d2 > 4 * delta2 && depth--) {
17915         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;
17916         if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
17917           resampleLineTo(x05, y05, lambda04, a0, b0, c0, x2, y2, lambda22, a2 /= m2, b2 /= m2, c2, depth, stream);
17918           stream.point(x2, y2);
17919           resampleLineTo(x2, y2, lambda22, a2, b2, c2, x12, y12, lambda12, a1, b1, c1, depth, stream);
17920         }
17921       }
17922     }
17923     return function(stream) {
17924       var lambda003, x004, y004, a00, b00, c00, lambda04, x05, y05, a0, b0, c0;
17925       var resampleStream = {
17926         point: point2,
17927         lineStart,
17928         lineEnd,
17929         polygonStart: function() {
17930           stream.polygonStart();
17931           resampleStream.lineStart = ringStart;
17932         },
17933         polygonEnd: function() {
17934           stream.polygonEnd();
17935           resampleStream.lineStart = lineStart;
17936         }
17937       };
17938       function point2(x2, y2) {
17939         x2 = project(x2, y2);
17940         stream.point(x2[0], x2[1]);
17941       }
17942       function lineStart() {
17943         x05 = NaN;
17944         resampleStream.point = linePoint2;
17945         stream.lineStart();
17946       }
17947       function linePoint2(lambda, phi) {
17948         var c2 = cartesian([lambda, phi]), p2 = project(lambda, phi);
17949         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);
17950         stream.point(x05, y05);
17951       }
17952       function lineEnd() {
17953         resampleStream.point = point2;
17954         stream.lineEnd();
17955       }
17956       function ringStart() {
17957         lineStart();
17958         resampleStream.point = ringPoint;
17959         resampleStream.lineEnd = ringEnd;
17960       }
17961       function ringPoint(lambda, phi) {
17962         linePoint2(lambda003 = lambda, phi), x004 = x05, y004 = y05, a00 = a0, b00 = b0, c00 = c0;
17963         resampleStream.point = linePoint2;
17964       }
17965       function ringEnd() {
17966         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x004, y004, lambda003, a00, b00, c00, maxDepth, stream);
17967         resampleStream.lineEnd = lineEnd;
17968         lineEnd();
17969       }
17970       return resampleStream;
17971     };
17972   }
17973
17974   // node_modules/d3-geo/src/projection/index.js
17975   var transformRadians = transformer({
17976     point: function(x2, y2) {
17977       this.stream.point(x2 * radians, y2 * radians);
17978     }
17979   });
17980   function transformRotate(rotate) {
17981     return transformer({
17982       point: function(x2, y2) {
17983         var r2 = rotate(x2, y2);
17984         return this.stream.point(r2[0], r2[1]);
17985       }
17986     });
17987   }
17988   function scaleTranslate(k2, dx, dy, sx, sy) {
17989     function transform2(x2, y2) {
17990       x2 *= sx;
17991       y2 *= sy;
17992       return [dx + k2 * x2, dy - k2 * y2];
17993     }
17994     transform2.invert = function(x2, y2) {
17995       return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy];
17996     };
17997     return transform2;
17998   }
17999   function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) {
18000     if (!alpha)
18001       return scaleTranslate(k2, dx, dy, sx, sy);
18002     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;
18003     function transform2(x2, y2) {
18004       x2 *= sx;
18005       y2 *= sy;
18006       return [a2 * x2 - b2 * y2 + dx, dy - b2 * x2 - a2 * y2];
18007     }
18008     transform2.invert = function(x2, y2) {
18009       return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)];
18010     };
18011     return transform2;
18012   }
18013   function projection(project) {
18014     return projectionMutator(function() {
18015       return project;
18016     })();
18017   }
18018   function projectionMutator(projectAt) {
18019     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;
18020     function projection2(point2) {
18021       return projectRotateTransform(point2[0] * radians, point2[1] * radians);
18022     }
18023     function invert(point2) {
18024       point2 = projectRotateTransform.invert(point2[0], point2[1]);
18025       return point2 && [point2[0] * degrees, point2[1] * degrees];
18026     }
18027     projection2.stream = function(stream) {
18028       return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
18029     };
18030     projection2.preclip = function(_2) {
18031       return arguments.length ? (preclip = _2, theta = void 0, reset()) : preclip;
18032     };
18033     projection2.postclip = function(_2) {
18034       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
18035     };
18036     projection2.clipAngle = function(_2) {
18037       return arguments.length ? (preclip = +_2 ? circle_default(theta = _2 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
18038     };
18039     projection2.clipExtent = function(_2) {
18040       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]];
18041     };
18042     projection2.scale = function(_2) {
18043       return arguments.length ? (k2 = +_2, recenter()) : k2;
18044     };
18045     projection2.translate = function(_2) {
18046       return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2];
18047     };
18048     projection2.center = function(_2) {
18049       return arguments.length ? (lambda = _2[0] % 360 * radians, phi = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
18050     };
18051     projection2.rotate = function(_2) {
18052       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];
18053     };
18054     projection2.angle = function(_2) {
18055       return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees;
18056     };
18057     projection2.reflectX = function(_2) {
18058       return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0;
18059     };
18060     projection2.reflectY = function(_2) {
18061       return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0;
18062     };
18063     projection2.precision = function(_2) {
18064       return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _2 * _2), reset()) : sqrt(delta2);
18065     };
18066     projection2.fitExtent = function(extent, object) {
18067       return fitExtent(projection2, extent, object);
18068     };
18069     projection2.fitSize = function(size, object) {
18070       return fitSize(projection2, size, object);
18071     };
18072     projection2.fitWidth = function(width, object) {
18073       return fitWidth(projection2, width, object);
18074     };
18075     projection2.fitHeight = function(height, object) {
18076       return fitHeight(projection2, height, object);
18077     };
18078     function recenter() {
18079       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);
18080       rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
18081       projectTransform = compose_default(project, transform2);
18082       projectRotateTransform = compose_default(rotate, projectTransform);
18083       projectResample = resample_default(projectTransform, delta2);
18084       return reset();
18085     }
18086     function reset() {
18087       cache = cacheStream = null;
18088       return projection2;
18089     }
18090     return function() {
18091       project = projectAt.apply(this, arguments);
18092       projection2.invert = project.invert && invert;
18093       return recenter();
18094     };
18095   }
18096
18097   // node_modules/d3-geo/src/projection/mercator.js
18098   function mercatorRaw(lambda, phi) {
18099     return [lambda, log(tan((halfPi + phi) / 2))];
18100   }
18101   mercatorRaw.invert = function(x2, y2) {
18102     return [x2, 2 * atan(exp(y2)) - halfPi];
18103   };
18104   function mercator_default() {
18105     return mercatorProjection(mercatorRaw).scale(961 / tau);
18106   }
18107   function mercatorProjection(project) {
18108     var m2 = projection(project), center = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x05 = null, y05, x12, y12;
18109     m2.scale = function(_2) {
18110       return arguments.length ? (scale(_2), reclip()) : scale();
18111     };
18112     m2.translate = function(_2) {
18113       return arguments.length ? (translate(_2), reclip()) : translate();
18114     };
18115     m2.center = function(_2) {
18116       return arguments.length ? (center(_2), reclip()) : center();
18117     };
18118     m2.clipExtent = function(_2) {
18119       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]];
18120     };
18121     function reclip() {
18122       var k2 = pi * scale(), t2 = m2(rotation_default(m2.rotate()).invert([0, 0]));
18123       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)]]);
18124     }
18125     return reclip();
18126   }
18127
18128   // node_modules/d3-geo/src/projection/identity.js
18129   function identity_default2() {
18130     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({
18131       point: function(x2, y2) {
18132         var p2 = projection2([x2, y2]);
18133         this.stream.point(p2[0], p2[1]);
18134       }
18135     }), postclip = identity_default, cache, cacheStream;
18136     function reset() {
18137       kx = k2 * sx;
18138       ky = k2 * sy;
18139       cache = cacheStream = null;
18140       return projection2;
18141     }
18142     function projection2(p2) {
18143       var x2 = p2[0] * kx, y2 = p2[1] * ky;
18144       if (alpha) {
18145         var t2 = y2 * ca - x2 * sa;
18146         x2 = x2 * ca + y2 * sa;
18147         y2 = t2;
18148       }
18149       return [x2 + tx, y2 + ty];
18150     }
18151     projection2.invert = function(p2) {
18152       var x2 = p2[0] - tx, y2 = p2[1] - ty;
18153       if (alpha) {
18154         var t2 = y2 * ca + x2 * sa;
18155         x2 = x2 * ca - y2 * sa;
18156         y2 = t2;
18157       }
18158       return [x2 / kx, y2 / ky];
18159     };
18160     projection2.stream = function(stream) {
18161       return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
18162     };
18163     projection2.postclip = function(_2) {
18164       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
18165     };
18166     projection2.clipExtent = function(_2) {
18167       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]];
18168     };
18169     projection2.scale = function(_2) {
18170       return arguments.length ? (k2 = +_2, reset()) : k2;
18171     };
18172     projection2.translate = function(_2) {
18173       return arguments.length ? (tx = +_2[0], ty = +_2[1], reset()) : [tx, ty];
18174     };
18175     projection2.angle = function(_2) {
18176       return arguments.length ? (alpha = _2 % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
18177     };
18178     projection2.reflectX = function(_2) {
18179       return arguments.length ? (sx = _2 ? -1 : 1, reset()) : sx < 0;
18180     };
18181     projection2.reflectY = function(_2) {
18182       return arguments.length ? (sy = _2 ? -1 : 1, reset()) : sy < 0;
18183     };
18184     projection2.fitExtent = function(extent, object) {
18185       return fitExtent(projection2, extent, object);
18186     };
18187     projection2.fitSize = function(size, object) {
18188       return fitSize(projection2, size, object);
18189     };
18190     projection2.fitWidth = function(width, object) {
18191       return fitWidth(projection2, width, object);
18192     };
18193     projection2.fitHeight = function(height, object) {
18194       return fitHeight(projection2, height, object);
18195     };
18196     return projection2;
18197   }
18198
18199   // modules/geo/geo.js
18200   var TAU = 2 * Math.PI;
18201   var EQUATORIAL_RADIUS = 6378137;
18202   var POLAR_RADIUS = 63567523e-1;
18203   function geoLatToMeters(dLat) {
18204     return dLat * (TAU * POLAR_RADIUS / 360);
18205   }
18206   function geoLonToMeters(dLon, atLat) {
18207     return Math.abs(atLat) >= 90 ? 0 : dLon * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(atLat * (Math.PI / 180)));
18208   }
18209   function geoMetersToLat(m2) {
18210     return m2 / (TAU * POLAR_RADIUS / 360);
18211   }
18212   function geoMetersToLon(m2, atLat) {
18213     return Math.abs(atLat) >= 90 ? 0 : m2 / (TAU * EQUATORIAL_RADIUS / 360) / Math.abs(Math.cos(atLat * (Math.PI / 180)));
18214   }
18215   function geoMetersToOffset(meters, tileSize) {
18216     tileSize = tileSize || 256;
18217     return [
18218       meters[0] * tileSize / (TAU * EQUATORIAL_RADIUS),
18219       -meters[1] * tileSize / (TAU * POLAR_RADIUS)
18220     ];
18221   }
18222   function geoOffsetToMeters(offset, tileSize) {
18223     tileSize = tileSize || 256;
18224     return [
18225       offset[0] * TAU * EQUATORIAL_RADIUS / tileSize,
18226       -offset[1] * TAU * POLAR_RADIUS / tileSize
18227     ];
18228   }
18229   function geoSphericalDistance(a2, b2) {
18230     var x2 = geoLonToMeters(a2[0] - b2[0], (a2[1] + b2[1]) / 2);
18231     var y2 = geoLatToMeters(a2[1] - b2[1]);
18232     return Math.sqrt(x2 * x2 + y2 * y2);
18233   }
18234   function geoScaleToZoom(k2, tileSize) {
18235     tileSize = tileSize || 256;
18236     var log2ts = Math.log(tileSize) * Math.LOG2E;
18237     return Math.log(k2 * TAU) / Math.LN2 - log2ts;
18238   }
18239   function geoZoomToScale(z2, tileSize) {
18240     tileSize = tileSize || 256;
18241     return tileSize * Math.pow(2, z2) / TAU;
18242   }
18243   function geoSphericalClosestNode(nodes, point2) {
18244     var minDistance = Infinity, distance;
18245     var indexOfMin;
18246     for (var i3 in nodes) {
18247       distance = geoSphericalDistance(nodes[i3].loc, point2);
18248       if (distance < minDistance) {
18249         minDistance = distance;
18250         indexOfMin = i3;
18251       }
18252     }
18253     if (indexOfMin !== void 0) {
18254       return { index: indexOfMin, distance: minDistance, node: nodes[indexOfMin] };
18255     } else {
18256       return null;
18257     }
18258   }
18259
18260   // modules/geo/extent.js
18261   function geoExtent(min3, max3) {
18262     if (!(this instanceof geoExtent)) {
18263       return new geoExtent(min3, max3);
18264     } else if (min3 instanceof geoExtent) {
18265       return min3;
18266     } else if (min3 && min3.length === 2 && min3[0].length === 2 && min3[1].length === 2) {
18267       this[0] = min3[0];
18268       this[1] = min3[1];
18269     } else {
18270       this[0] = min3 || [Infinity, Infinity];
18271       this[1] = max3 || min3 || [-Infinity, -Infinity];
18272     }
18273   }
18274   geoExtent.prototype = new Array(2);
18275   Object.assign(geoExtent.prototype, {
18276     equals: function(obj) {
18277       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];
18278     },
18279     extend: function(obj) {
18280       if (!(obj instanceof geoExtent))
18281         obj = new geoExtent(obj);
18282       return geoExtent(
18283         [Math.min(obj[0][0], this[0][0]), Math.min(obj[0][1], this[0][1])],
18284         [Math.max(obj[1][0], this[1][0]), Math.max(obj[1][1], this[1][1])]
18285       );
18286     },
18287     _extend: function(extent) {
18288       this[0][0] = Math.min(extent[0][0], this[0][0]);
18289       this[0][1] = Math.min(extent[0][1], this[0][1]);
18290       this[1][0] = Math.max(extent[1][0], this[1][0]);
18291       this[1][1] = Math.max(extent[1][1], this[1][1]);
18292     },
18293     area: function() {
18294       return Math.abs((this[1][0] - this[0][0]) * (this[1][1] - this[0][1]));
18295     },
18296     center: function() {
18297       return [(this[0][0] + this[1][0]) / 2, (this[0][1] + this[1][1]) / 2];
18298     },
18299     rectangle: function() {
18300       return [this[0][0], this[0][1], this[1][0], this[1][1]];
18301     },
18302     bbox: function() {
18303       return { minX: this[0][0], minY: this[0][1], maxX: this[1][0], maxY: this[1][1] };
18304     },
18305     polygon: function() {
18306       return [
18307         [this[0][0], this[0][1]],
18308         [this[0][0], this[1][1]],
18309         [this[1][0], this[1][1]],
18310         [this[1][0], this[0][1]],
18311         [this[0][0], this[0][1]]
18312       ];
18313     },
18314     contains: function(obj) {
18315       if (!(obj instanceof geoExtent))
18316         obj = new geoExtent(obj);
18317       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];
18318     },
18319     intersects: function(obj) {
18320       if (!(obj instanceof geoExtent))
18321         obj = new geoExtent(obj);
18322       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];
18323     },
18324     intersection: function(obj) {
18325       if (!this.intersects(obj))
18326         return new geoExtent();
18327       return new geoExtent(
18328         [Math.max(obj[0][0], this[0][0]), Math.max(obj[0][1], this[0][1])],
18329         [Math.min(obj[1][0], this[1][0]), Math.min(obj[1][1], this[1][1])]
18330       );
18331     },
18332     percentContainedIn: function(obj) {
18333       if (!(obj instanceof geoExtent))
18334         obj = new geoExtent(obj);
18335       var a1 = this.intersection(obj).area();
18336       var a2 = this.area();
18337       if (a1 === Infinity || a2 === Infinity) {
18338         return 0;
18339       } else if (a1 === 0 || a2 === 0) {
18340         if (obj.contains(this)) {
18341           return 1;
18342         }
18343         return 0;
18344       } else {
18345         return a1 / a2;
18346       }
18347     },
18348     padByMeters: function(meters) {
18349       var dLat = geoMetersToLat(meters);
18350       var dLon = geoMetersToLon(meters, this.center()[1]);
18351       return geoExtent(
18352         [this[0][0] - dLon, this[0][1] - dLat],
18353         [this[1][0] + dLon, this[1][1] + dLat]
18354       );
18355     },
18356     toParam: function() {
18357       return this.rectangle().join(",");
18358     },
18359     split: function() {
18360       const center = this.center();
18361       return [
18362         geoExtent(this[0], center),
18363         geoExtent([center[0], this[0][1]], [this[1][0], center[1]]),
18364         geoExtent(center, this[1]),
18365         geoExtent([this[0][0], center[1]], [center[0], this[1][1]])
18366       ];
18367     }
18368   });
18369
18370   // node_modules/d3-polygon/src/area.js
18371   function area_default3(polygon2) {
18372     var i3 = -1, n3 = polygon2.length, a2, b2 = polygon2[n3 - 1], area = 0;
18373     while (++i3 < n3) {
18374       a2 = b2;
18375       b2 = polygon2[i3];
18376       area += a2[1] * b2[0] - a2[0] * b2[1];
18377     }
18378     return area / 2;
18379   }
18380
18381   // node_modules/d3-polygon/src/centroid.js
18382   function centroid_default2(polygon2) {
18383     var i3 = -1, n3 = polygon2.length, x2 = 0, y2 = 0, a2, b2 = polygon2[n3 - 1], c2, k2 = 0;
18384     while (++i3 < n3) {
18385       a2 = b2;
18386       b2 = polygon2[i3];
18387       k2 += c2 = a2[0] * b2[1] - b2[0] * a2[1];
18388       x2 += (a2[0] + b2[0]) * c2;
18389       y2 += (a2[1] + b2[1]) * c2;
18390     }
18391     return k2 *= 3, [x2 / k2, y2 / k2];
18392   }
18393
18394   // node_modules/d3-polygon/src/cross.js
18395   function cross_default(a2, b2, c2) {
18396     return (b2[0] - a2[0]) * (c2[1] - a2[1]) - (b2[1] - a2[1]) * (c2[0] - a2[0]);
18397   }
18398
18399   // node_modules/d3-polygon/src/hull.js
18400   function lexicographicOrder(a2, b2) {
18401     return a2[0] - b2[0] || a2[1] - b2[1];
18402   }
18403   function computeUpperHullIndexes(points) {
18404     const n3 = points.length, indexes = [0, 1];
18405     let size = 2, i3;
18406     for (i3 = 2; i3 < n3; ++i3) {
18407       while (size > 1 && cross_default(points[indexes[size - 2]], points[indexes[size - 1]], points[i3]) <= 0)
18408         --size;
18409       indexes[size++] = i3;
18410     }
18411     return indexes.slice(0, size);
18412   }
18413   function hull_default(points) {
18414     if ((n3 = points.length) < 3)
18415       return null;
18416     var i3, n3, sortedPoints = new Array(n3), flippedPoints = new Array(n3);
18417     for (i3 = 0; i3 < n3; ++i3)
18418       sortedPoints[i3] = [+points[i3][0], +points[i3][1], i3];
18419     sortedPoints.sort(lexicographicOrder);
18420     for (i3 = 0; i3 < n3; ++i3)
18421       flippedPoints[i3] = [sortedPoints[i3][0], -sortedPoints[i3][1]];
18422     var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints);
18423     var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull = [];
18424     for (i3 = upperIndexes.length - 1; i3 >= 0; --i3)
18425       hull.push(points[sortedPoints[upperIndexes[i3]][2]]);
18426     for (i3 = +skipLeft; i3 < lowerIndexes.length - skipRight; ++i3)
18427       hull.push(points[sortedPoints[lowerIndexes[i3]][2]]);
18428     return hull;
18429   }
18430
18431   // modules/geo/vector.js
18432   function geoVecEqual(a2, b2, epsilon3) {
18433     if (epsilon3) {
18434       return Math.abs(a2[0] - b2[0]) <= epsilon3 && Math.abs(a2[1] - b2[1]) <= epsilon3;
18435     } else {
18436       return a2[0] === b2[0] && a2[1] === b2[1];
18437     }
18438   }
18439   function geoVecAdd(a2, b2) {
18440     return [a2[0] + b2[0], a2[1] + b2[1]];
18441   }
18442   function geoVecSubtract(a2, b2) {
18443     return [a2[0] - b2[0], a2[1] - b2[1]];
18444   }
18445   function geoVecScale(a2, mag) {
18446     return [a2[0] * mag, a2[1] * mag];
18447   }
18448   function geoVecFloor(a2) {
18449     return [Math.floor(a2[0]), Math.floor(a2[1])];
18450   }
18451   function geoVecInterp(a2, b2, t2) {
18452     return [
18453       a2[0] + (b2[0] - a2[0]) * t2,
18454       a2[1] + (b2[1] - a2[1]) * t2
18455     ];
18456   }
18457   function geoVecLength(a2, b2) {
18458     return Math.sqrt(geoVecLengthSquare(a2, b2));
18459   }
18460   function geoVecLengthSquare(a2, b2) {
18461     b2 = b2 || [0, 0];
18462     var x2 = a2[0] - b2[0];
18463     var y2 = a2[1] - b2[1];
18464     return x2 * x2 + y2 * y2;
18465   }
18466   function geoVecNormalize(a2) {
18467     var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
18468     if (length2 !== 0) {
18469       return geoVecScale(a2, 1 / length2);
18470     }
18471     return [0, 0];
18472   }
18473   function geoVecAngle(a2, b2) {
18474     return Math.atan2(b2[1] - a2[1], b2[0] - a2[0]);
18475   }
18476   function geoVecDot(a2, b2, origin) {
18477     origin = origin || [0, 0];
18478     var p2 = geoVecSubtract(a2, origin);
18479     var q2 = geoVecSubtract(b2, origin);
18480     return p2[0] * q2[0] + p2[1] * q2[1];
18481   }
18482   function geoVecNormalizedDot(a2, b2, origin) {
18483     origin = origin || [0, 0];
18484     var p2 = geoVecNormalize(geoVecSubtract(a2, origin));
18485     var q2 = geoVecNormalize(geoVecSubtract(b2, origin));
18486     return geoVecDot(p2, q2);
18487   }
18488   function geoVecCross(a2, b2, origin) {
18489     origin = origin || [0, 0];
18490     var p2 = geoVecSubtract(a2, origin);
18491     var q2 = geoVecSubtract(b2, origin);
18492     return p2[0] * q2[1] - p2[1] * q2[0];
18493   }
18494   function geoVecProject(a2, points) {
18495     var min3 = Infinity;
18496     var idx;
18497     var target;
18498     for (var i3 = 0; i3 < points.length - 1; i3++) {
18499       var o2 = points[i3];
18500       var s2 = geoVecSubtract(points[i3 + 1], o2);
18501       var v2 = geoVecSubtract(a2, o2);
18502       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18503       var p2;
18504       if (proj < 0) {
18505         p2 = o2;
18506       } else if (proj > 1) {
18507         p2 = points[i3 + 1];
18508       } else {
18509         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18510       }
18511       var dist = geoVecLength(p2, a2);
18512       if (dist < min3) {
18513         min3 = dist;
18514         idx = i3 + 1;
18515         target = p2;
18516       }
18517     }
18518     if (idx !== void 0) {
18519       return { index: idx, distance: min3, target };
18520     } else {
18521       return null;
18522     }
18523   }
18524
18525   // modules/geo/geom.js
18526   function geoAngle(a2, b2, projection2) {
18527     return geoVecAngle(projection2(a2.loc), projection2(b2.loc));
18528   }
18529   function geoEdgeEqual(a2, b2) {
18530     return a2[0] === b2[0] && a2[1] === b2[1] || a2[0] === b2[1] && a2[1] === b2[0];
18531   }
18532   function geoRotate(points, angle2, around) {
18533     return points.map(function(point2) {
18534       var radial = geoVecSubtract(point2, around);
18535       return [
18536         radial[0] * Math.cos(angle2) - radial[1] * Math.sin(angle2) + around[0],
18537         radial[0] * Math.sin(angle2) + radial[1] * Math.cos(angle2) + around[1]
18538       ];
18539     });
18540   }
18541   function geoChooseEdge(nodes, point2, projection2, activeID) {
18542     var dist = geoVecLength;
18543     var points = nodes.map(function(n3) {
18544       return projection2(n3.loc);
18545     });
18546     var ids = nodes.map(function(n3) {
18547       return n3.id;
18548     });
18549     var min3 = Infinity;
18550     var idx;
18551     var loc;
18552     for (var i3 = 0; i3 < points.length - 1; i3++) {
18553       if (ids[i3] === activeID || ids[i3 + 1] === activeID)
18554         continue;
18555       var o2 = points[i3];
18556       var s2 = geoVecSubtract(points[i3 + 1], o2);
18557       var v2 = geoVecSubtract(point2, o2);
18558       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18559       var p2;
18560       if (proj < 0) {
18561         p2 = o2;
18562       } else if (proj > 1) {
18563         p2 = points[i3 + 1];
18564       } else {
18565         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18566       }
18567       var d2 = dist(p2, point2);
18568       if (d2 < min3) {
18569         min3 = d2;
18570         idx = i3 + 1;
18571         loc = projection2.invert(p2);
18572       }
18573     }
18574     if (idx !== void 0) {
18575       return { index: idx, distance: min3, loc };
18576     } else {
18577       return null;
18578     }
18579   }
18580   function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) {
18581     var actives = [];
18582     var inactives = [];
18583     var j2, k2, n1, n22, segment;
18584     for (j2 = 0; j2 < activeNodes.length - 1; j2++) {
18585       n1 = activeNodes[j2];
18586       n22 = activeNodes[j2 + 1];
18587       segment = [n1.loc, n22.loc];
18588       if (n1.id === activeID || n22.id === activeID) {
18589         actives.push(segment);
18590       }
18591     }
18592     for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) {
18593       n1 = inactiveNodes[j2];
18594       n22 = inactiveNodes[j2 + 1];
18595       segment = [n1.loc, n22.loc];
18596       inactives.push(segment);
18597     }
18598     for (j2 = 0; j2 < actives.length; j2++) {
18599       for (k2 = 0; k2 < inactives.length; k2++) {
18600         var p2 = actives[j2];
18601         var q2 = inactives[k2];
18602         var hit = geoLineIntersection(p2, q2);
18603         if (hit) {
18604           return true;
18605         }
18606       }
18607     }
18608     return false;
18609   }
18610   function geoHasSelfIntersections(nodes, activeID) {
18611     var actives = [];
18612     var inactives = [];
18613     var j2, k2;
18614     for (j2 = 0; j2 < nodes.length - 1; j2++) {
18615       var n1 = nodes[j2];
18616       var n22 = nodes[j2 + 1];
18617       var segment = [n1.loc, n22.loc];
18618       if (n1.id === activeID || n22.id === activeID) {
18619         actives.push(segment);
18620       } else {
18621         inactives.push(segment);
18622       }
18623     }
18624     for (j2 = 0; j2 < actives.length; j2++) {
18625       for (k2 = 0; k2 < inactives.length; k2++) {
18626         var p2 = actives[j2];
18627         var q2 = inactives[k2];
18628         if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) {
18629           continue;
18630         }
18631         var hit = geoLineIntersection(p2, q2);
18632         if (hit) {
18633           var epsilon3 = 1e-8;
18634           if (geoVecEqual(p2[1], hit, epsilon3) || geoVecEqual(p2[0], hit, epsilon3) || geoVecEqual(q2[1], hit, epsilon3) || geoVecEqual(q2[0], hit, epsilon3)) {
18635             continue;
18636           } else {
18637             return true;
18638           }
18639         }
18640       }
18641     }
18642     return false;
18643   }
18644   function geoLineIntersection(a2, b2) {
18645     var p2 = [a2[0][0], a2[0][1]];
18646     var p22 = [a2[1][0], a2[1][1]];
18647     var q2 = [b2[0][0], b2[0][1]];
18648     var q22 = [b2[1][0], b2[1][1]];
18649     var r2 = geoVecSubtract(p22, p2);
18650     var s2 = geoVecSubtract(q22, q2);
18651     var uNumerator = geoVecCross(geoVecSubtract(q2, p2), r2);
18652     var denominator = geoVecCross(r2, s2);
18653     if (uNumerator && denominator) {
18654       var u2 = uNumerator / denominator;
18655       var t2 = geoVecCross(geoVecSubtract(q2, p2), s2) / denominator;
18656       if (t2 >= 0 && t2 <= 1 && u2 >= 0 && u2 <= 1) {
18657         return geoVecInterp(p2, p22, t2);
18658       }
18659     }
18660     return null;
18661   }
18662   function geoPathIntersections(path1, path2) {
18663     var intersections = [];
18664     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18665       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18666         var a2 = [path1[i3], path1[i3 + 1]];
18667         var b2 = [path2[j2], path2[j2 + 1]];
18668         var hit = geoLineIntersection(a2, b2);
18669         if (hit) {
18670           intersections.push(hit);
18671         }
18672       }
18673     }
18674     return intersections;
18675   }
18676   function geoPathHasIntersections(path1, path2) {
18677     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18678       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18679         var a2 = [path1[i3], path1[i3 + 1]];
18680         var b2 = [path2[j2], path2[j2 + 1]];
18681         var hit = geoLineIntersection(a2, b2);
18682         if (hit) {
18683           return true;
18684         }
18685       }
18686     }
18687     return false;
18688   }
18689   function geoPointInPolygon(point2, polygon2) {
18690     var x2 = point2[0];
18691     var y2 = point2[1];
18692     var inside = false;
18693     for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) {
18694       var xi = polygon2[i3][0];
18695       var yi = polygon2[i3][1];
18696       var xj = polygon2[j2][0];
18697       var yj = polygon2[j2][1];
18698       var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
18699       if (intersect2)
18700         inside = !inside;
18701     }
18702     return inside;
18703   }
18704   function geoPolygonContainsPolygon(outer, inner) {
18705     return inner.every(function(point2) {
18706       return geoPointInPolygon(point2, outer);
18707     });
18708   }
18709   function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
18710     function testPoints(outer2, inner2) {
18711       return inner2.some(function(point2) {
18712         return geoPointInPolygon(point2, outer2);
18713       });
18714     }
18715     return testPoints(outer, inner) || !!checkSegments && geoPathHasIntersections(outer, inner);
18716   }
18717   function geoGetSmallestSurroundingRectangle(points) {
18718     var hull = hull_default(points);
18719     var centroid = centroid_default2(hull);
18720     var minArea = Infinity;
18721     var ssrExtent = [];
18722     var ssrAngle = 0;
18723     var c1 = hull[0];
18724     for (var i3 = 0; i3 <= hull.length - 1; i3++) {
18725       var c2 = i3 === hull.length - 1 ? hull[0] : hull[i3 + 1];
18726       var angle2 = Math.atan2(c2[1] - c1[1], c2[0] - c1[0]);
18727       var poly = geoRotate(hull, -angle2, centroid);
18728       var extent = poly.reduce(function(extent2, point2) {
18729         return extent2.extend(geoExtent(point2));
18730       }, geoExtent());
18731       var area = extent.area();
18732       if (area < minArea) {
18733         minArea = area;
18734         ssrExtent = extent;
18735         ssrAngle = angle2;
18736       }
18737       c1 = c2;
18738     }
18739     return {
18740       poly: geoRotate(ssrExtent.polygon(), ssrAngle, centroid),
18741       angle: ssrAngle
18742     };
18743   }
18744   function geoPathLength(path) {
18745     var length2 = 0;
18746     for (var i3 = 0; i3 < path.length - 1; i3++) {
18747       length2 += geoVecLength(path[i3], path[i3 + 1]);
18748     }
18749     return length2;
18750   }
18751   function geoViewportEdge(point2, dimensions) {
18752     var pad2 = [80, 20, 50, 20];
18753     var x2 = 0;
18754     var y2 = 0;
18755     if (point2[0] > dimensions[0] - pad2[1]) {
18756       x2 = -10;
18757     }
18758     if (point2[0] < pad2[3]) {
18759       x2 = 10;
18760     }
18761     if (point2[1] > dimensions[1] - pad2[2]) {
18762       y2 = -10;
18763     }
18764     if (point2[1] < pad2[0]) {
18765       y2 = 10;
18766     }
18767     if (x2 || y2) {
18768       return [x2, y2];
18769     } else {
18770       return null;
18771     }
18772   }
18773
18774   // node_modules/d3-dispatch/src/dispatch.js
18775   var noop2 = { value: () => {
18776   } };
18777   function dispatch() {
18778     for (var i3 = 0, n3 = arguments.length, _2 = {}, t2; i3 < n3; ++i3) {
18779       if (!(t2 = arguments[i3] + "") || t2 in _2 || /[\s.]/.test(t2))
18780         throw new Error("illegal type: " + t2);
18781       _2[t2] = [];
18782     }
18783     return new Dispatch(_2);
18784   }
18785   function Dispatch(_2) {
18786     this._ = _2;
18787   }
18788   function parseTypenames(typenames, types) {
18789     return typenames.trim().split(/^|\s+/).map(function(t2) {
18790       var name = "", i3 = t2.indexOf(".");
18791       if (i3 >= 0)
18792         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
18793       if (t2 && !types.hasOwnProperty(t2))
18794         throw new Error("unknown type: " + t2);
18795       return { type: t2, name };
18796     });
18797   }
18798   Dispatch.prototype = dispatch.prototype = {
18799     constructor: Dispatch,
18800     on: function(typename, callback) {
18801       var _2 = this._, T2 = parseTypenames(typename + "", _2), t2, i3 = -1, n3 = T2.length;
18802       if (arguments.length < 2) {
18803         while (++i3 < n3)
18804           if ((t2 = (typename = T2[i3]).type) && (t2 = get(_2[t2], typename.name)))
18805             return t2;
18806         return;
18807       }
18808       if (callback != null && typeof callback !== "function")
18809         throw new Error("invalid callback: " + callback);
18810       while (++i3 < n3) {
18811         if (t2 = (typename = T2[i3]).type)
18812           _2[t2] = set(_2[t2], typename.name, callback);
18813         else if (callback == null)
18814           for (t2 in _2)
18815             _2[t2] = set(_2[t2], typename.name, null);
18816       }
18817       return this;
18818     },
18819     copy: function() {
18820       var copy2 = {}, _2 = this._;
18821       for (var t2 in _2)
18822         copy2[t2] = _2[t2].slice();
18823       return new Dispatch(copy2);
18824     },
18825     call: function(type2, that) {
18826       if ((n3 = arguments.length - 2) > 0)
18827         for (var args = new Array(n3), i3 = 0, n3, t2; i3 < n3; ++i3)
18828           args[i3] = arguments[i3 + 2];
18829       if (!this._.hasOwnProperty(type2))
18830         throw new Error("unknown type: " + type2);
18831       for (t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18832         t2[i3].value.apply(that, args);
18833     },
18834     apply: function(type2, that, args) {
18835       if (!this._.hasOwnProperty(type2))
18836         throw new Error("unknown type: " + type2);
18837       for (var t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18838         t2[i3].value.apply(that, args);
18839     }
18840   };
18841   function get(type2, name) {
18842     for (var i3 = 0, n3 = type2.length, c2; i3 < n3; ++i3) {
18843       if ((c2 = type2[i3]).name === name) {
18844         return c2.value;
18845       }
18846     }
18847   }
18848   function set(type2, name, callback) {
18849     for (var i3 = 0, n3 = type2.length; i3 < n3; ++i3) {
18850       if (type2[i3].name === name) {
18851         type2[i3] = noop2, type2 = type2.slice(0, i3).concat(type2.slice(i3 + 1));
18852         break;
18853       }
18854     }
18855     if (callback != null)
18856       type2.push({ name, value: callback });
18857     return type2;
18858   }
18859   var dispatch_default = dispatch;
18860
18861   // node_modules/d3-selection/src/namespaces.js
18862   var xhtml = "http://www.w3.org/1999/xhtml";
18863   var namespaces_default = {
18864     svg: "http://www.w3.org/2000/svg",
18865     xhtml,
18866     xlink: "http://www.w3.org/1999/xlink",
18867     xml: "http://www.w3.org/XML/1998/namespace",
18868     xmlns: "http://www.w3.org/2000/xmlns/"
18869   };
18870
18871   // node_modules/d3-selection/src/namespace.js
18872   function namespace_default(name) {
18873     var prefix = name += "", i3 = prefix.indexOf(":");
18874     if (i3 >= 0 && (prefix = name.slice(0, i3)) !== "xmlns")
18875       name = name.slice(i3 + 1);
18876     return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name;
18877   }
18878
18879   // node_modules/d3-selection/src/creator.js
18880   function creatorInherit(name) {
18881     return function() {
18882       var document2 = this.ownerDocument, uri = this.namespaceURI;
18883       return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
18884     };
18885   }
18886   function creatorFixed(fullname) {
18887     return function() {
18888       return this.ownerDocument.createElementNS(fullname.space, fullname.local);
18889     };
18890   }
18891   function creator_default(name) {
18892     var fullname = namespace_default(name);
18893     return (fullname.local ? creatorFixed : creatorInherit)(fullname);
18894   }
18895
18896   // node_modules/d3-selection/src/selector.js
18897   function none() {
18898   }
18899   function selector_default(selector) {
18900     return selector == null ? none : function() {
18901       return this.querySelector(selector);
18902     };
18903   }
18904
18905   // node_modules/d3-selection/src/selection/select.js
18906   function select_default(select) {
18907     if (typeof select !== "function")
18908       select = selector_default(select);
18909     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18910       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
18911         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
18912           if ("__data__" in node)
18913             subnode.__data__ = node.__data__;
18914           subgroup[i3] = subnode;
18915         }
18916       }
18917     }
18918     return new Selection(subgroups, this._parents);
18919   }
18920
18921   // node_modules/d3-selection/src/array.js
18922   function array(x2) {
18923     return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2);
18924   }
18925
18926   // node_modules/d3-selection/src/selectorAll.js
18927   function empty() {
18928     return [];
18929   }
18930   function selectorAll_default(selector) {
18931     return selector == null ? empty : function() {
18932       return this.querySelectorAll(selector);
18933     };
18934   }
18935
18936   // node_modules/d3-selection/src/selection/selectAll.js
18937   function arrayAll(select) {
18938     return function() {
18939       return array(select.apply(this, arguments));
18940     };
18941   }
18942   function selectAll_default(select) {
18943     if (typeof select === "function")
18944       select = arrayAll(select);
18945     else
18946       select = selectorAll_default(select);
18947     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
18948       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
18949         if (node = group[i3]) {
18950           subgroups.push(select.call(node, node.__data__, i3, group));
18951           parents.push(node);
18952         }
18953       }
18954     }
18955     return new Selection(subgroups, parents);
18956   }
18957
18958   // node_modules/d3-selection/src/matcher.js
18959   function matcher_default(selector) {
18960     return function() {
18961       return this.matches(selector);
18962     };
18963   }
18964   function childMatcher(selector) {
18965     return function(node) {
18966       return node.matches(selector);
18967     };
18968   }
18969
18970   // node_modules/d3-selection/src/selection/selectChild.js
18971   var find = Array.prototype.find;
18972   function childFind(match) {
18973     return function() {
18974       return find.call(this.children, match);
18975     };
18976   }
18977   function childFirst() {
18978     return this.firstElementChild;
18979   }
18980   function selectChild_default(match) {
18981     return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
18982   }
18983
18984   // node_modules/d3-selection/src/selection/selectChildren.js
18985   var filter = Array.prototype.filter;
18986   function children() {
18987     return Array.from(this.children);
18988   }
18989   function childrenFilter(match) {
18990     return function() {
18991       return filter.call(this.children, match);
18992     };
18993   }
18994   function selectChildren_default(match) {
18995     return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
18996   }
18997
18998   // node_modules/d3-selection/src/selection/filter.js
18999   function filter_default(match) {
19000     if (typeof match !== "function")
19001       match = matcher_default(match);
19002     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19003       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
19004         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
19005           subgroup.push(node);
19006         }
19007       }
19008     }
19009     return new Selection(subgroups, this._parents);
19010   }
19011
19012   // node_modules/d3-selection/src/selection/sparse.js
19013   function sparse_default(update) {
19014     return new Array(update.length);
19015   }
19016
19017   // node_modules/d3-selection/src/selection/enter.js
19018   function enter_default() {
19019     return new Selection(this._enter || this._groups.map(sparse_default), this._parents);
19020   }
19021   function EnterNode(parent, datum2) {
19022     this.ownerDocument = parent.ownerDocument;
19023     this.namespaceURI = parent.namespaceURI;
19024     this._next = null;
19025     this._parent = parent;
19026     this.__data__ = datum2;
19027   }
19028   EnterNode.prototype = {
19029     constructor: EnterNode,
19030     appendChild: function(child) {
19031       return this._parent.insertBefore(child, this._next);
19032     },
19033     insertBefore: function(child, next) {
19034       return this._parent.insertBefore(child, next);
19035     },
19036     querySelector: function(selector) {
19037       return this._parent.querySelector(selector);
19038     },
19039     querySelectorAll: function(selector) {
19040       return this._parent.querySelectorAll(selector);
19041     }
19042   };
19043
19044   // node_modules/d3-selection/src/constant.js
19045   function constant_default(x2) {
19046     return function() {
19047       return x2;
19048     };
19049   }
19050
19051   // node_modules/d3-selection/src/selection/data.js
19052   function bindIndex(parent, group, enter, update, exit, data) {
19053     var i3 = 0, node, groupLength = group.length, dataLength = data.length;
19054     for (; i3 < dataLength; ++i3) {
19055       if (node = group[i3]) {
19056         node.__data__ = data[i3];
19057         update[i3] = node;
19058       } else {
19059         enter[i3] = new EnterNode(parent, data[i3]);
19060       }
19061     }
19062     for (; i3 < groupLength; ++i3) {
19063       if (node = group[i3]) {
19064         exit[i3] = node;
19065       }
19066     }
19067   }
19068   function bindKey(parent, group, enter, update, exit, data, key) {
19069     var i3, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
19070     for (i3 = 0; i3 < groupLength; ++i3) {
19071       if (node = group[i3]) {
19072         keyValues[i3] = keyValue = key.call(node, node.__data__, i3, group) + "";
19073         if (nodeByKeyValue.has(keyValue)) {
19074           exit[i3] = node;
19075         } else {
19076           nodeByKeyValue.set(keyValue, node);
19077         }
19078       }
19079     }
19080     for (i3 = 0; i3 < dataLength; ++i3) {
19081       keyValue = key.call(parent, data[i3], i3, data) + "";
19082       if (node = nodeByKeyValue.get(keyValue)) {
19083         update[i3] = node;
19084         node.__data__ = data[i3];
19085         nodeByKeyValue.delete(keyValue);
19086       } else {
19087         enter[i3] = new EnterNode(parent, data[i3]);
19088       }
19089     }
19090     for (i3 = 0; i3 < groupLength; ++i3) {
19091       if ((node = group[i3]) && nodeByKeyValue.get(keyValues[i3]) === node) {
19092         exit[i3] = node;
19093       }
19094     }
19095   }
19096   function datum(node) {
19097     return node.__data__;
19098   }
19099   function data_default(value, key) {
19100     if (!arguments.length)
19101       return Array.from(this, datum);
19102     var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
19103     if (typeof value !== "function")
19104       value = constant_default(value);
19105     for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19106       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);
19107       bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
19108       for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
19109         if (previous = enterGroup[i0]) {
19110           if (i0 >= i1)
19111             i1 = i0 + 1;
19112           while (!(next = updateGroup[i1]) && ++i1 < dataLength)
19113             ;
19114           previous._next = next || null;
19115         }
19116       }
19117     }
19118     update = new Selection(update, parents);
19119     update._enter = enter;
19120     update._exit = exit;
19121     return update;
19122   }
19123   function arraylike(data) {
19124     return typeof data === "object" && "length" in data ? data : Array.from(data);
19125   }
19126
19127   // node_modules/d3-selection/src/selection/exit.js
19128   function exit_default() {
19129     return new Selection(this._exit || this._groups.map(sparse_default), this._parents);
19130   }
19131
19132   // node_modules/d3-selection/src/selection/join.js
19133   function join_default(onenter, onupdate, onexit) {
19134     var enter = this.enter(), update = this, exit = this.exit();
19135     if (typeof onenter === "function") {
19136       enter = onenter(enter);
19137       if (enter)
19138         enter = enter.selection();
19139     } else {
19140       enter = enter.append(onenter + "");
19141     }
19142     if (onupdate != null) {
19143       update = onupdate(update);
19144       if (update)
19145         update = update.selection();
19146     }
19147     if (onexit == null)
19148       exit.remove();
19149     else
19150       onexit(exit);
19151     return enter && update ? enter.merge(update).order() : update;
19152   }
19153
19154   // node_modules/d3-selection/src/selection/merge.js
19155   function merge_default(context) {
19156     var selection2 = context.selection ? context.selection() : context;
19157     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) {
19158       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19159         if (node = group0[i3] || group1[i3]) {
19160           merge2[i3] = node;
19161         }
19162       }
19163     }
19164     for (; j2 < m0; ++j2) {
19165       merges[j2] = groups0[j2];
19166     }
19167     return new Selection(merges, this._parents);
19168   }
19169
19170   // node_modules/d3-selection/src/selection/order.js
19171   function order_default() {
19172     for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) {
19173       for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) {
19174         if (node = group[i3]) {
19175           if (next && node.compareDocumentPosition(next) ^ 4)
19176             next.parentNode.insertBefore(node, next);
19177           next = node;
19178         }
19179       }
19180     }
19181     return this;
19182   }
19183
19184   // node_modules/d3-selection/src/selection/sort.js
19185   function sort_default(compare2) {
19186     if (!compare2)
19187       compare2 = ascending2;
19188     function compareNode(a2, b2) {
19189       return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2;
19190     }
19191     for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19192       for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19193         if (node = group[i3]) {
19194           sortgroup[i3] = node;
19195         }
19196       }
19197       sortgroup.sort(compareNode);
19198     }
19199     return new Selection(sortgroups, this._parents).order();
19200   }
19201   function ascending2(a2, b2) {
19202     return a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
19203   }
19204
19205   // node_modules/d3-selection/src/selection/call.js
19206   function call_default() {
19207     var callback = arguments[0];
19208     arguments[0] = this;
19209     callback.apply(null, arguments);
19210     return this;
19211   }
19212
19213   // node_modules/d3-selection/src/selection/nodes.js
19214   function nodes_default() {
19215     return Array.from(this);
19216   }
19217
19218   // node_modules/d3-selection/src/selection/node.js
19219   function node_default() {
19220     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19221       for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) {
19222         var node = group[i3];
19223         if (node)
19224           return node;
19225       }
19226     }
19227     return null;
19228   }
19229
19230   // node_modules/d3-selection/src/selection/size.js
19231   function size_default() {
19232     let size = 0;
19233     for (const node of this)
19234       ++size;
19235     return size;
19236   }
19237
19238   // node_modules/d3-selection/src/selection/empty.js
19239   function empty_default() {
19240     return !this.node();
19241   }
19242
19243   // node_modules/d3-selection/src/selection/each.js
19244   function each_default(callback) {
19245     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19246       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
19247         if (node = group[i3])
19248           callback.call(node, node.__data__, i3, group);
19249       }
19250     }
19251     return this;
19252   }
19253
19254   // node_modules/d3-selection/src/selection/attr.js
19255   function attrRemove(name) {
19256     return function() {
19257       this.removeAttribute(name);
19258     };
19259   }
19260   function attrRemoveNS(fullname) {
19261     return function() {
19262       this.removeAttributeNS(fullname.space, fullname.local);
19263     };
19264   }
19265   function attrConstant(name, value) {
19266     return function() {
19267       this.setAttribute(name, value);
19268     };
19269   }
19270   function attrConstantNS(fullname, value) {
19271     return function() {
19272       this.setAttributeNS(fullname.space, fullname.local, value);
19273     };
19274   }
19275   function attrFunction(name, value) {
19276     return function() {
19277       var v2 = value.apply(this, arguments);
19278       if (v2 == null)
19279         this.removeAttribute(name);
19280       else
19281         this.setAttribute(name, v2);
19282     };
19283   }
19284   function attrFunctionNS(fullname, value) {
19285     return function() {
19286       var v2 = value.apply(this, arguments);
19287       if (v2 == null)
19288         this.removeAttributeNS(fullname.space, fullname.local);
19289       else
19290         this.setAttributeNS(fullname.space, fullname.local, v2);
19291     };
19292   }
19293   function attr_default(name, value) {
19294     var fullname = namespace_default(name);
19295     if (arguments.length < 2) {
19296       var node = this.node();
19297       return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
19298     }
19299     return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value));
19300   }
19301
19302   // node_modules/d3-selection/src/window.js
19303   function window_default(node) {
19304     return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
19305   }
19306
19307   // node_modules/d3-selection/src/selection/style.js
19308   function styleRemove(name) {
19309     return function() {
19310       this.style.removeProperty(name);
19311     };
19312   }
19313   function styleConstant(name, value, priority) {
19314     return function() {
19315       this.style.setProperty(name, value, priority);
19316     };
19317   }
19318   function styleFunction(name, value, priority) {
19319     return function() {
19320       var v2 = value.apply(this, arguments);
19321       if (v2 == null)
19322         this.style.removeProperty(name);
19323       else
19324         this.style.setProperty(name, v2, priority);
19325     };
19326   }
19327   function style_default(name, value, priority) {
19328     return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
19329   }
19330   function styleValue(node, name) {
19331     return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name);
19332   }
19333
19334   // node_modules/d3-selection/src/selection/property.js
19335   function propertyRemove(name) {
19336     return function() {
19337       delete this[name];
19338     };
19339   }
19340   function propertyConstant(name, value) {
19341     return function() {
19342       this[name] = value;
19343     };
19344   }
19345   function propertyFunction(name, value) {
19346     return function() {
19347       var v2 = value.apply(this, arguments);
19348       if (v2 == null)
19349         delete this[name];
19350       else
19351         this[name] = v2;
19352     };
19353   }
19354   function property_default(name, value) {
19355     return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
19356   }
19357
19358   // node_modules/d3-selection/src/selection/classed.js
19359   function classArray(string) {
19360     return string.trim().split(/^|\s+/);
19361   }
19362   function classList(node) {
19363     return node.classList || new ClassList(node);
19364   }
19365   function ClassList(node) {
19366     this._node = node;
19367     this._names = classArray(node.getAttribute("class") || "");
19368   }
19369   ClassList.prototype = {
19370     add: function(name) {
19371       var i3 = this._names.indexOf(name);
19372       if (i3 < 0) {
19373         this._names.push(name);
19374         this._node.setAttribute("class", this._names.join(" "));
19375       }
19376     },
19377     remove: function(name) {
19378       var i3 = this._names.indexOf(name);
19379       if (i3 >= 0) {
19380         this._names.splice(i3, 1);
19381         this._node.setAttribute("class", this._names.join(" "));
19382       }
19383     },
19384     contains: function(name) {
19385       return this._names.indexOf(name) >= 0;
19386     }
19387   };
19388   function classedAdd(node, names) {
19389     var list2 = classList(node), i3 = -1, n3 = names.length;
19390     while (++i3 < n3)
19391       list2.add(names[i3]);
19392   }
19393   function classedRemove(node, names) {
19394     var list2 = classList(node), i3 = -1, n3 = names.length;
19395     while (++i3 < n3)
19396       list2.remove(names[i3]);
19397   }
19398   function classedTrue(names) {
19399     return function() {
19400       classedAdd(this, names);
19401     };
19402   }
19403   function classedFalse(names) {
19404     return function() {
19405       classedRemove(this, names);
19406     };
19407   }
19408   function classedFunction(names, value) {
19409     return function() {
19410       (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
19411     };
19412   }
19413   function classed_default(name, value) {
19414     var names = classArray(name + "");
19415     if (arguments.length < 2) {
19416       var list2 = classList(this.node()), i3 = -1, n3 = names.length;
19417       while (++i3 < n3)
19418         if (!list2.contains(names[i3]))
19419           return false;
19420       return true;
19421     }
19422     return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
19423   }
19424
19425   // node_modules/d3-selection/src/selection/text.js
19426   function textRemove() {
19427     this.textContent = "";
19428   }
19429   function textConstant(value) {
19430     return function() {
19431       this.textContent = value;
19432     };
19433   }
19434   function textFunction(value) {
19435     return function() {
19436       var v2 = value.apply(this, arguments);
19437       this.textContent = v2 == null ? "" : v2;
19438     };
19439   }
19440   function text_default(value) {
19441     return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent;
19442   }
19443
19444   // node_modules/d3-selection/src/selection/html.js
19445   function htmlRemove() {
19446     this.innerHTML = "";
19447   }
19448   function htmlConstant(value) {
19449     return function() {
19450       this.innerHTML = value;
19451     };
19452   }
19453   function htmlFunction(value) {
19454     return function() {
19455       var v2 = value.apply(this, arguments);
19456       this.innerHTML = v2 == null ? "" : v2;
19457     };
19458   }
19459   function html_default(value) {
19460     return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
19461   }
19462
19463   // node_modules/d3-selection/src/selection/raise.js
19464   function raise() {
19465     if (this.nextSibling)
19466       this.parentNode.appendChild(this);
19467   }
19468   function raise_default() {
19469     return this.each(raise);
19470   }
19471
19472   // node_modules/d3-selection/src/selection/lower.js
19473   function lower() {
19474     if (this.previousSibling)
19475       this.parentNode.insertBefore(this, this.parentNode.firstChild);
19476   }
19477   function lower_default() {
19478     return this.each(lower);
19479   }
19480
19481   // node_modules/d3-selection/src/selection/append.js
19482   function append_default(name) {
19483     var create2 = typeof name === "function" ? name : creator_default(name);
19484     return this.select(function() {
19485       return this.appendChild(create2.apply(this, arguments));
19486     });
19487   }
19488
19489   // node_modules/d3-selection/src/selection/insert.js
19490   function constantNull() {
19491     return null;
19492   }
19493   function insert_default(name, before) {
19494     var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before);
19495     return this.select(function() {
19496       return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
19497     });
19498   }
19499
19500   // node_modules/d3-selection/src/selection/remove.js
19501   function remove() {
19502     var parent = this.parentNode;
19503     if (parent)
19504       parent.removeChild(this);
19505   }
19506   function remove_default() {
19507     return this.each(remove);
19508   }
19509
19510   // node_modules/d3-selection/src/selection/clone.js
19511   function selection_cloneShallow() {
19512     var clone2 = this.cloneNode(false), parent = this.parentNode;
19513     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19514   }
19515   function selection_cloneDeep() {
19516     var clone2 = this.cloneNode(true), parent = this.parentNode;
19517     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19518   }
19519   function clone_default(deep) {
19520     return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
19521   }
19522
19523   // node_modules/d3-selection/src/selection/datum.js
19524   function datum_default(value) {
19525     return arguments.length ? this.property("__data__", value) : this.node().__data__;
19526   }
19527
19528   // node_modules/d3-selection/src/selection/on.js
19529   function contextListener(listener) {
19530     return function(event) {
19531       listener.call(this, event, this.__data__);
19532     };
19533   }
19534   function parseTypenames2(typenames) {
19535     return typenames.trim().split(/^|\s+/).map(function(t2) {
19536       var name = "", i3 = t2.indexOf(".");
19537       if (i3 >= 0)
19538         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
19539       return { type: t2, name };
19540     });
19541   }
19542   function onRemove(typename) {
19543     return function() {
19544       var on = this.__on;
19545       if (!on)
19546         return;
19547       for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) {
19548         if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) {
19549           this.removeEventListener(o2.type, o2.listener, o2.options);
19550         } else {
19551           on[++i3] = o2;
19552         }
19553       }
19554       if (++i3)
19555         on.length = i3;
19556       else
19557         delete this.__on;
19558     };
19559   }
19560   function onAdd(typename, value, options2) {
19561     return function() {
19562       var on = this.__on, o2, listener = contextListener(value);
19563       if (on)
19564         for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) {
19565           if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) {
19566             this.removeEventListener(o2.type, o2.listener, o2.options);
19567             this.addEventListener(o2.type, o2.listener = listener, o2.options = options2);
19568             o2.value = value;
19569             return;
19570           }
19571         }
19572       this.addEventListener(typename.type, listener, options2);
19573       o2 = { type: typename.type, name: typename.name, value, listener, options: options2 };
19574       if (!on)
19575         this.__on = [o2];
19576       else
19577         on.push(o2);
19578     };
19579   }
19580   function on_default(typename, value, options2) {
19581     var typenames = parseTypenames2(typename + ""), i3, n3 = typenames.length, t2;
19582     if (arguments.length < 2) {
19583       var on = this.node().__on;
19584       if (on)
19585         for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) {
19586           for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) {
19587             if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) {
19588               return o2.value;
19589             }
19590           }
19591         }
19592       return;
19593     }
19594     on = value ? onAdd : onRemove;
19595     for (i3 = 0; i3 < n3; ++i3)
19596       this.each(on(typenames[i3], value, options2));
19597     return this;
19598   }
19599
19600   // node_modules/d3-selection/src/selection/dispatch.js
19601   function dispatchEvent(node, type2, params) {
19602     var window2 = window_default(node), event = window2.CustomEvent;
19603     if (typeof event === "function") {
19604       event = new event(type2, params);
19605     } else {
19606       event = window2.document.createEvent("Event");
19607       if (params)
19608         event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail;
19609       else
19610         event.initEvent(type2, false, false);
19611     }
19612     node.dispatchEvent(event);
19613   }
19614   function dispatchConstant(type2, params) {
19615     return function() {
19616       return dispatchEvent(this, type2, params);
19617     };
19618   }
19619   function dispatchFunction(type2, params) {
19620     return function() {
19621       return dispatchEvent(this, type2, params.apply(this, arguments));
19622     };
19623   }
19624   function dispatch_default2(type2, params) {
19625     return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params));
19626   }
19627
19628   // node_modules/d3-selection/src/selection/iterator.js
19629   function* iterator_default() {
19630     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19631       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
19632         if (node = group[i3])
19633           yield node;
19634       }
19635     }
19636   }
19637
19638   // node_modules/d3-selection/src/selection/index.js
19639   var root = [null];
19640   function Selection(groups, parents) {
19641     this._groups = groups;
19642     this._parents = parents;
19643   }
19644   function selection() {
19645     return new Selection([[document.documentElement]], root);
19646   }
19647   function selection_selection() {
19648     return this;
19649   }
19650   Selection.prototype = selection.prototype = {
19651     constructor: Selection,
19652     select: select_default,
19653     selectAll: selectAll_default,
19654     selectChild: selectChild_default,
19655     selectChildren: selectChildren_default,
19656     filter: filter_default,
19657     data: data_default,
19658     enter: enter_default,
19659     exit: exit_default,
19660     join: join_default,
19661     merge: merge_default,
19662     selection: selection_selection,
19663     order: order_default,
19664     sort: sort_default,
19665     call: call_default,
19666     nodes: nodes_default,
19667     node: node_default,
19668     size: size_default,
19669     empty: empty_default,
19670     each: each_default,
19671     attr: attr_default,
19672     style: style_default,
19673     property: property_default,
19674     classed: classed_default,
19675     text: text_default,
19676     html: html_default,
19677     raise: raise_default,
19678     lower: lower_default,
19679     append: append_default,
19680     insert: insert_default,
19681     remove: remove_default,
19682     clone: clone_default,
19683     datum: datum_default,
19684     on: on_default,
19685     dispatch: dispatch_default2,
19686     [Symbol.iterator]: iterator_default
19687   };
19688   var selection_default = selection;
19689
19690   // node_modules/d3-selection/src/select.js
19691   function select_default2(selector) {
19692     return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
19693   }
19694
19695   // node_modules/d3-selection/src/sourceEvent.js
19696   function sourceEvent_default(event) {
19697     let sourceEvent;
19698     while (sourceEvent = event.sourceEvent)
19699       event = sourceEvent;
19700     return event;
19701   }
19702
19703   // node_modules/d3-selection/src/pointer.js
19704   function pointer_default(event, node) {
19705     event = sourceEvent_default(event);
19706     if (node === void 0)
19707       node = event.currentTarget;
19708     if (node) {
19709       var svg2 = node.ownerSVGElement || node;
19710       if (svg2.createSVGPoint) {
19711         var point2 = svg2.createSVGPoint();
19712         point2.x = event.clientX, point2.y = event.clientY;
19713         point2 = point2.matrixTransform(node.getScreenCTM().inverse());
19714         return [point2.x, point2.y];
19715       }
19716       if (node.getBoundingClientRect) {
19717         var rect = node.getBoundingClientRect();
19718         return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
19719       }
19720     }
19721     return [event.pageX, event.pageY];
19722   }
19723
19724   // node_modules/d3-selection/src/selectAll.js
19725   function selectAll_default2(selector) {
19726     return typeof selector === "string" ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) : new Selection([array(selector)], root);
19727   }
19728
19729   // node_modules/d3-drag/src/noevent.js
19730   var nonpassive = { passive: false };
19731   var nonpassivecapture = { capture: true, passive: false };
19732   function nopropagation(event) {
19733     event.stopImmediatePropagation();
19734   }
19735   function noevent_default(event) {
19736     event.preventDefault();
19737     event.stopImmediatePropagation();
19738   }
19739
19740   // node_modules/d3-drag/src/nodrag.js
19741   function nodrag_default(view) {
19742     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture);
19743     if ("onselectstart" in root3) {
19744       selection2.on("selectstart.drag", noevent_default, nonpassivecapture);
19745     } else {
19746       root3.__noselect = root3.style.MozUserSelect;
19747       root3.style.MozUserSelect = "none";
19748     }
19749   }
19750   function yesdrag(view, noclick) {
19751     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null);
19752     if (noclick) {
19753       selection2.on("click.drag", noevent_default, nonpassivecapture);
19754       setTimeout(function() {
19755         selection2.on("click.drag", null);
19756       }, 0);
19757     }
19758     if ("onselectstart" in root3) {
19759       selection2.on("selectstart.drag", null);
19760     } else {
19761       root3.style.MozUserSelect = root3.__noselect;
19762       delete root3.__noselect;
19763     }
19764   }
19765
19766   // node_modules/d3-drag/src/constant.js
19767   var constant_default2 = (x2) => () => x2;
19768
19769   // node_modules/d3-drag/src/event.js
19770   function DragEvent(type2, {
19771     sourceEvent,
19772     subject,
19773     target,
19774     identifier,
19775     active,
19776     x: x2,
19777     y: y2,
19778     dx,
19779     dy,
19780     dispatch: dispatch14
19781   }) {
19782     Object.defineProperties(this, {
19783       type: { value: type2, enumerable: true, configurable: true },
19784       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
19785       subject: { value: subject, enumerable: true, configurable: true },
19786       target: { value: target, enumerable: true, configurable: true },
19787       identifier: { value: identifier, enumerable: true, configurable: true },
19788       active: { value: active, enumerable: true, configurable: true },
19789       x: { value: x2, enumerable: true, configurable: true },
19790       y: { value: y2, enumerable: true, configurable: true },
19791       dx: { value: dx, enumerable: true, configurable: true },
19792       dy: { value: dy, enumerable: true, configurable: true },
19793       _: { value: dispatch14 }
19794     });
19795   }
19796   DragEvent.prototype.on = function() {
19797     var value = this._.on.apply(this._, arguments);
19798     return value === this._ ? this : value;
19799   };
19800
19801   // node_modules/d3-drag/src/drag.js
19802   function defaultFilter(event) {
19803     return !event.ctrlKey && !event.button;
19804   }
19805   function defaultContainer() {
19806     return this.parentNode;
19807   }
19808   function defaultSubject(event, d2) {
19809     return d2 == null ? { x: event.x, y: event.y } : d2;
19810   }
19811   function defaultTouchable() {
19812     return navigator.maxTouchPoints || "ontouchstart" in this;
19813   }
19814   function drag_default() {
19815     var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
19816     function drag(selection2) {
19817       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)");
19818     }
19819     function mousedowned(event, d2) {
19820       if (touchending || !filter2.call(this, event, d2))
19821         return;
19822       var gesture = beforestart(this, container.call(this, event, d2), event, d2, "mouse");
19823       if (!gesture)
19824         return;
19825       select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture);
19826       nodrag_default(event.view);
19827       nopropagation(event);
19828       mousemoving = false;
19829       mousedownx = event.clientX;
19830       mousedowny = event.clientY;
19831       gesture("start", event);
19832     }
19833     function mousemoved(event) {
19834       noevent_default(event);
19835       if (!mousemoving) {
19836         var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
19837         mousemoving = dx * dx + dy * dy > clickDistance2;
19838       }
19839       gestures.mouse("drag", event);
19840     }
19841     function mouseupped(event) {
19842       select_default2(event.view).on("mousemove.drag mouseup.drag", null);
19843       yesdrag(event.view, mousemoving);
19844       noevent_default(event);
19845       gestures.mouse("end", event);
19846     }
19847     function touchstarted(event, d2) {
19848       if (!filter2.call(this, event, d2))
19849         return;
19850       var touches = event.changedTouches, c2 = container.call(this, event, d2), n3 = touches.length, i3, gesture;
19851       for (i3 = 0; i3 < n3; ++i3) {
19852         if (gesture = beforestart(this, c2, event, d2, touches[i3].identifier, touches[i3])) {
19853           nopropagation(event);
19854           gesture("start", event, touches[i3]);
19855         }
19856       }
19857     }
19858     function touchmoved(event) {
19859       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19860       for (i3 = 0; i3 < n3; ++i3) {
19861         if (gesture = gestures[touches[i3].identifier]) {
19862           noevent_default(event);
19863           gesture("drag", event, touches[i3]);
19864         }
19865       }
19866     }
19867     function touchended(event) {
19868       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19869       if (touchending)
19870         clearTimeout(touchending);
19871       touchending = setTimeout(function() {
19872         touchending = null;
19873       }, 500);
19874       for (i3 = 0; i3 < n3; ++i3) {
19875         if (gesture = gestures[touches[i3].identifier]) {
19876           nopropagation(event);
19877           gesture("end", event, touches[i3]);
19878         }
19879       }
19880     }
19881     function beforestart(that, container2, event, d2, identifier, touch) {
19882       var dispatch14 = listeners.copy(), p2 = pointer_default(touch || event, container2), dx, dy, s2;
19883       if ((s2 = subject.call(that, new DragEvent("beforestart", {
19884         sourceEvent: event,
19885         target: drag,
19886         identifier,
19887         active,
19888         x: p2[0],
19889         y: p2[1],
19890         dx: 0,
19891         dy: 0,
19892         dispatch: dispatch14
19893       }), d2)) == null)
19894         return;
19895       dx = s2.x - p2[0] || 0;
19896       dy = s2.y - p2[1] || 0;
19897       return function gesture(type2, event2, touch2) {
19898         var p02 = p2, n3;
19899         switch (type2) {
19900           case "start":
19901             gestures[identifier] = gesture, n3 = active++;
19902             break;
19903           case "end":
19904             delete gestures[identifier], --active;
19905           case "drag":
19906             p2 = pointer_default(touch2 || event2, container2), n3 = active;
19907             break;
19908         }
19909         dispatch14.call(
19910           type2,
19911           that,
19912           new DragEvent(type2, {
19913             sourceEvent: event2,
19914             subject: s2,
19915             target: drag,
19916             identifier,
19917             active: n3,
19918             x: p2[0] + dx,
19919             y: p2[1] + dy,
19920             dx: p2[0] - p02[0],
19921             dy: p2[1] - p02[1],
19922             dispatch: dispatch14
19923           }),
19924           d2
19925         );
19926       };
19927     }
19928     drag.filter = function(_2) {
19929       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : filter2;
19930     };
19931     drag.container = function(_2) {
19932       return arguments.length ? (container = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : container;
19933     };
19934     drag.subject = function(_2) {
19935       return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : subject;
19936     };
19937     drag.touchable = function(_2) {
19938       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : touchable;
19939     };
19940     drag.on = function() {
19941       var value = listeners.on.apply(listeners, arguments);
19942       return value === listeners ? drag : value;
19943     };
19944     drag.clickDistance = function(_2) {
19945       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag) : Math.sqrt(clickDistance2);
19946     };
19947     return drag;
19948   }
19949
19950   // node_modules/d3-color/src/define.js
19951   function define_default(constructor, factory, prototype) {
19952     constructor.prototype = factory.prototype = prototype;
19953     prototype.constructor = constructor;
19954   }
19955   function extend(parent, definition) {
19956     var prototype = Object.create(parent.prototype);
19957     for (var key in definition)
19958       prototype[key] = definition[key];
19959     return prototype;
19960   }
19961
19962   // node_modules/d3-color/src/color.js
19963   function Color() {
19964   }
19965   var darker = 0.7;
19966   var brighter = 1 / darker;
19967   var reI = "\\s*([+-]?\\d+)\\s*";
19968   var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
19969   var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
19970   var reHex = /^#([0-9a-f]{3,8})$/;
19971   var reRgbInteger = new RegExp("^rgb\\(".concat(reI, ",").concat(reI, ",").concat(reI, "\\)$"));
19972   var reRgbPercent = new RegExp("^rgb\\(".concat(reP, ",").concat(reP, ",").concat(reP, "\\)$"));
19973   var reRgbaInteger = new RegExp("^rgba\\(".concat(reI, ",").concat(reI, ",").concat(reI, ",").concat(reN, "\\)$"));
19974   var reRgbaPercent = new RegExp("^rgba\\(".concat(reP, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19975   var reHslPercent = new RegExp("^hsl\\(".concat(reN, ",").concat(reP, ",").concat(reP, "\\)$"));
19976   var reHslaPercent = new RegExp("^hsla\\(".concat(reN, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19977   var named = {
19978     aliceblue: 15792383,
19979     antiquewhite: 16444375,
19980     aqua: 65535,
19981     aquamarine: 8388564,
19982     azure: 15794175,
19983     beige: 16119260,
19984     bisque: 16770244,
19985     black: 0,
19986     blanchedalmond: 16772045,
19987     blue: 255,
19988     blueviolet: 9055202,
19989     brown: 10824234,
19990     burlywood: 14596231,
19991     cadetblue: 6266528,
19992     chartreuse: 8388352,
19993     chocolate: 13789470,
19994     coral: 16744272,
19995     cornflowerblue: 6591981,
19996     cornsilk: 16775388,
19997     crimson: 14423100,
19998     cyan: 65535,
19999     darkblue: 139,
20000     darkcyan: 35723,
20001     darkgoldenrod: 12092939,
20002     darkgray: 11119017,
20003     darkgreen: 25600,
20004     darkgrey: 11119017,
20005     darkkhaki: 12433259,
20006     darkmagenta: 9109643,
20007     darkolivegreen: 5597999,
20008     darkorange: 16747520,
20009     darkorchid: 10040012,
20010     darkred: 9109504,
20011     darksalmon: 15308410,
20012     darkseagreen: 9419919,
20013     darkslateblue: 4734347,
20014     darkslategray: 3100495,
20015     darkslategrey: 3100495,
20016     darkturquoise: 52945,
20017     darkviolet: 9699539,
20018     deeppink: 16716947,
20019     deepskyblue: 49151,
20020     dimgray: 6908265,
20021     dimgrey: 6908265,
20022     dodgerblue: 2003199,
20023     firebrick: 11674146,
20024     floralwhite: 16775920,
20025     forestgreen: 2263842,
20026     fuchsia: 16711935,
20027     gainsboro: 14474460,
20028     ghostwhite: 16316671,
20029     gold: 16766720,
20030     goldenrod: 14329120,
20031     gray: 8421504,
20032     green: 32768,
20033     greenyellow: 11403055,
20034     grey: 8421504,
20035     honeydew: 15794160,
20036     hotpink: 16738740,
20037     indianred: 13458524,
20038     indigo: 4915330,
20039     ivory: 16777200,
20040     khaki: 15787660,
20041     lavender: 15132410,
20042     lavenderblush: 16773365,
20043     lawngreen: 8190976,
20044     lemonchiffon: 16775885,
20045     lightblue: 11393254,
20046     lightcoral: 15761536,
20047     lightcyan: 14745599,
20048     lightgoldenrodyellow: 16448210,
20049     lightgray: 13882323,
20050     lightgreen: 9498256,
20051     lightgrey: 13882323,
20052     lightpink: 16758465,
20053     lightsalmon: 16752762,
20054     lightseagreen: 2142890,
20055     lightskyblue: 8900346,
20056     lightslategray: 7833753,
20057     lightslategrey: 7833753,
20058     lightsteelblue: 11584734,
20059     lightyellow: 16777184,
20060     lime: 65280,
20061     limegreen: 3329330,
20062     linen: 16445670,
20063     magenta: 16711935,
20064     maroon: 8388608,
20065     mediumaquamarine: 6737322,
20066     mediumblue: 205,
20067     mediumorchid: 12211667,
20068     mediumpurple: 9662683,
20069     mediumseagreen: 3978097,
20070     mediumslateblue: 8087790,
20071     mediumspringgreen: 64154,
20072     mediumturquoise: 4772300,
20073     mediumvioletred: 13047173,
20074     midnightblue: 1644912,
20075     mintcream: 16121850,
20076     mistyrose: 16770273,
20077     moccasin: 16770229,
20078     navajowhite: 16768685,
20079     navy: 128,
20080     oldlace: 16643558,
20081     olive: 8421376,
20082     olivedrab: 7048739,
20083     orange: 16753920,
20084     orangered: 16729344,
20085     orchid: 14315734,
20086     palegoldenrod: 15657130,
20087     palegreen: 10025880,
20088     paleturquoise: 11529966,
20089     palevioletred: 14381203,
20090     papayawhip: 16773077,
20091     peachpuff: 16767673,
20092     peru: 13468991,
20093     pink: 16761035,
20094     plum: 14524637,
20095     powderblue: 11591910,
20096     purple: 8388736,
20097     rebeccapurple: 6697881,
20098     red: 16711680,
20099     rosybrown: 12357519,
20100     royalblue: 4286945,
20101     saddlebrown: 9127187,
20102     salmon: 16416882,
20103     sandybrown: 16032864,
20104     seagreen: 3050327,
20105     seashell: 16774638,
20106     sienna: 10506797,
20107     silver: 12632256,
20108     skyblue: 8900331,
20109     slateblue: 6970061,
20110     slategray: 7372944,
20111     slategrey: 7372944,
20112     snow: 16775930,
20113     springgreen: 65407,
20114     steelblue: 4620980,
20115     tan: 13808780,
20116     teal: 32896,
20117     thistle: 14204888,
20118     tomato: 16737095,
20119     turquoise: 4251856,
20120     violet: 15631086,
20121     wheat: 16113331,
20122     white: 16777215,
20123     whitesmoke: 16119285,
20124     yellow: 16776960,
20125     yellowgreen: 10145074
20126   };
20127   define_default(Color, color, {
20128     copy(channels) {
20129       return Object.assign(new this.constructor(), this, channels);
20130     },
20131     displayable() {
20132       return this.rgb().displayable();
20133     },
20134     hex: color_formatHex,
20135     // Deprecated! Use color.formatHex.
20136     formatHex: color_formatHex,
20137     formatHex8: color_formatHex8,
20138     formatHsl: color_formatHsl,
20139     formatRgb: color_formatRgb,
20140     toString: color_formatRgb
20141   });
20142   function color_formatHex() {
20143     return this.rgb().formatHex();
20144   }
20145   function color_formatHex8() {
20146     return this.rgb().formatHex8();
20147   }
20148   function color_formatHsl() {
20149     return hslConvert(this).formatHsl();
20150   }
20151   function color_formatRgb() {
20152     return this.rgb().formatRgb();
20153   }
20154   function color(format2) {
20155     var m2, l2;
20156     format2 = (format2 + "").trim().toLowerCase();
20157     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;
20158   }
20159   function rgbn(n3) {
20160     return new Rgb(n3 >> 16 & 255, n3 >> 8 & 255, n3 & 255, 1);
20161   }
20162   function rgba(r2, g3, b2, a2) {
20163     if (a2 <= 0)
20164       r2 = g3 = b2 = NaN;
20165     return new Rgb(r2, g3, b2, a2);
20166   }
20167   function rgbConvert(o2) {
20168     if (!(o2 instanceof Color))
20169       o2 = color(o2);
20170     if (!o2)
20171       return new Rgb();
20172     o2 = o2.rgb();
20173     return new Rgb(o2.r, o2.g, o2.b, o2.opacity);
20174   }
20175   function rgb(r2, g3, b2, opacity) {
20176     return arguments.length === 1 ? rgbConvert(r2) : new Rgb(r2, g3, b2, opacity == null ? 1 : opacity);
20177   }
20178   function Rgb(r2, g3, b2, opacity) {
20179     this.r = +r2;
20180     this.g = +g3;
20181     this.b = +b2;
20182     this.opacity = +opacity;
20183   }
20184   define_default(Rgb, rgb, extend(Color, {
20185     brighter(k2) {
20186       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
20187       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
20188     },
20189     darker(k2) {
20190       k2 = k2 == null ? darker : Math.pow(darker, k2);
20191       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
20192     },
20193     rgb() {
20194       return this;
20195     },
20196     clamp() {
20197       return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
20198     },
20199     displayable() {
20200       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);
20201     },
20202     hex: rgb_formatHex,
20203     // Deprecated! Use color.formatHex.
20204     formatHex: rgb_formatHex,
20205     formatHex8: rgb_formatHex8,
20206     formatRgb: rgb_formatRgb,
20207     toString: rgb_formatRgb
20208   }));
20209   function rgb_formatHex() {
20210     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b));
20211   }
20212   function rgb_formatHex8() {
20213     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b)).concat(hex((isNaN(this.opacity) ? 1 : this.opacity) * 255));
20214   }
20215   function rgb_formatRgb() {
20216     const a2 = clampa(this.opacity);
20217     return "".concat(a2 === 1 ? "rgb(" : "rgba(").concat(clampi(this.r), ", ").concat(clampi(this.g), ", ").concat(clampi(this.b)).concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
20218   }
20219   function clampa(opacity) {
20220     return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
20221   }
20222   function clampi(value) {
20223     return Math.max(0, Math.min(255, Math.round(value) || 0));
20224   }
20225   function hex(value) {
20226     value = clampi(value);
20227     return (value < 16 ? "0" : "") + value.toString(16);
20228   }
20229   function hsla(h2, s2, l2, a2) {
20230     if (a2 <= 0)
20231       h2 = s2 = l2 = NaN;
20232     else if (l2 <= 0 || l2 >= 1)
20233       h2 = s2 = NaN;
20234     else if (s2 <= 0)
20235       h2 = NaN;
20236     return new Hsl(h2, s2, l2, a2);
20237   }
20238   function hslConvert(o2) {
20239     if (o2 instanceof Hsl)
20240       return new Hsl(o2.h, o2.s, o2.l, o2.opacity);
20241     if (!(o2 instanceof Color))
20242       o2 = color(o2);
20243     if (!o2)
20244       return new Hsl();
20245     if (o2 instanceof Hsl)
20246       return o2;
20247     o2 = o2.rgb();
20248     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;
20249     if (s2) {
20250       if (r2 === max3)
20251         h2 = (g3 - b2) / s2 + (g3 < b2) * 6;
20252       else if (g3 === max3)
20253         h2 = (b2 - r2) / s2 + 2;
20254       else
20255         h2 = (r2 - g3) / s2 + 4;
20256       s2 /= l2 < 0.5 ? max3 + min3 : 2 - max3 - min3;
20257       h2 *= 60;
20258     } else {
20259       s2 = l2 > 0 && l2 < 1 ? 0 : h2;
20260     }
20261     return new Hsl(h2, s2, l2, o2.opacity);
20262   }
20263   function hsl(h2, s2, l2, opacity) {
20264     return arguments.length === 1 ? hslConvert(h2) : new Hsl(h2, s2, l2, opacity == null ? 1 : opacity);
20265   }
20266   function Hsl(h2, s2, l2, opacity) {
20267     this.h = +h2;
20268     this.s = +s2;
20269     this.l = +l2;
20270     this.opacity = +opacity;
20271   }
20272   define_default(Hsl, hsl, extend(Color, {
20273     brighter(k2) {
20274       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
20275       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20276     },
20277     darker(k2) {
20278       k2 = k2 == null ? darker : Math.pow(darker, k2);
20279       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20280     },
20281     rgb() {
20282       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;
20283       return new Rgb(
20284         hsl2rgb(h2 >= 240 ? h2 - 240 : h2 + 120, m1, m2),
20285         hsl2rgb(h2, m1, m2),
20286         hsl2rgb(h2 < 120 ? h2 + 240 : h2 - 120, m1, m2),
20287         this.opacity
20288       );
20289     },
20290     clamp() {
20291       return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
20292     },
20293     displayable() {
20294       return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
20295     },
20296     formatHsl() {
20297       const a2 = clampa(this.opacity);
20298       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, ")"));
20299     }
20300   }));
20301   function clamph(value) {
20302     value = (value || 0) % 360;
20303     return value < 0 ? value + 360 : value;
20304   }
20305   function clampt(value) {
20306     return Math.max(0, Math.min(1, value || 0));
20307   }
20308   function hsl2rgb(h2, m1, m2) {
20309     return (h2 < 60 ? m1 + (m2 - m1) * h2 / 60 : h2 < 180 ? m2 : h2 < 240 ? m1 + (m2 - m1) * (240 - h2) / 60 : m1) * 255;
20310   }
20311
20312   // node_modules/d3-interpolate/src/basis.js
20313   function basis(t1, v0, v1, v2, v3) {
20314     var t2 = t1 * t1, t3 = t2 * t1;
20315     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;
20316   }
20317   function basis_default(values) {
20318     var n3 = values.length - 1;
20319     return function(t2) {
20320       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;
20321       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20322     };
20323   }
20324
20325   // node_modules/d3-interpolate/src/basisClosed.js
20326   function basisClosed_default(values) {
20327     var n3 = values.length;
20328     return function(t2) {
20329       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];
20330       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20331     };
20332   }
20333
20334   // node_modules/d3-interpolate/src/constant.js
20335   var constant_default3 = (x2) => () => x2;
20336
20337   // node_modules/d3-interpolate/src/color.js
20338   function linear(a2, d2) {
20339     return function(t2) {
20340       return a2 + t2 * d2;
20341     };
20342   }
20343   function exponential(a2, b2, y2) {
20344     return a2 = Math.pow(a2, y2), b2 = Math.pow(b2, y2) - a2, y2 = 1 / y2, function(t2) {
20345       return Math.pow(a2 + t2 * b2, y2);
20346     };
20347   }
20348   function gamma(y2) {
20349     return (y2 = +y2) === 1 ? nogamma : function(a2, b2) {
20350       return b2 - a2 ? exponential(a2, b2, y2) : constant_default3(isNaN(a2) ? b2 : a2);
20351     };
20352   }
20353   function nogamma(a2, b2) {
20354     var d2 = b2 - a2;
20355     return d2 ? linear(a2, d2) : constant_default3(isNaN(a2) ? b2 : a2);
20356   }
20357
20358   // node_modules/d3-interpolate/src/rgb.js
20359   var rgb_default = function rgbGamma(y2) {
20360     var color2 = gamma(y2);
20361     function rgb2(start2, end) {
20362       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);
20363       return function(t2) {
20364         start2.r = r2(t2);
20365         start2.g = g3(t2);
20366         start2.b = b2(t2);
20367         start2.opacity = opacity(t2);
20368         return start2 + "";
20369       };
20370     }
20371     rgb2.gamma = rgbGamma;
20372     return rgb2;
20373   }(1);
20374   function rgbSpline(spline) {
20375     return function(colors) {
20376       var n3 = colors.length, r2 = new Array(n3), g3 = new Array(n3), b2 = new Array(n3), i3, color2;
20377       for (i3 = 0; i3 < n3; ++i3) {
20378         color2 = rgb(colors[i3]);
20379         r2[i3] = color2.r || 0;
20380         g3[i3] = color2.g || 0;
20381         b2[i3] = color2.b || 0;
20382       }
20383       r2 = spline(r2);
20384       g3 = spline(g3);
20385       b2 = spline(b2);
20386       color2.opacity = 1;
20387       return function(t2) {
20388         color2.r = r2(t2);
20389         color2.g = g3(t2);
20390         color2.b = b2(t2);
20391         return color2 + "";
20392       };
20393     };
20394   }
20395   var rgbBasis = rgbSpline(basis_default);
20396   var rgbBasisClosed = rgbSpline(basisClosed_default);
20397
20398   // node_modules/d3-interpolate/src/numberArray.js
20399   function numberArray_default(a2, b2) {
20400     if (!b2)
20401       b2 = [];
20402     var n3 = a2 ? Math.min(b2.length, a2.length) : 0, c2 = b2.slice(), i3;
20403     return function(t2) {
20404       for (i3 = 0; i3 < n3; ++i3)
20405         c2[i3] = a2[i3] * (1 - t2) + b2[i3] * t2;
20406       return c2;
20407     };
20408   }
20409   function isNumberArray(x2) {
20410     return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
20411   }
20412
20413   // node_modules/d3-interpolate/src/array.js
20414   function genericArray(a2, b2) {
20415     var nb = b2 ? b2.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i3;
20416     for (i3 = 0; i3 < na; ++i3)
20417       x2[i3] = value_default(a2[i3], b2[i3]);
20418     for (; i3 < nb; ++i3)
20419       c2[i3] = b2[i3];
20420     return function(t2) {
20421       for (i3 = 0; i3 < na; ++i3)
20422         c2[i3] = x2[i3](t2);
20423       return c2;
20424     };
20425   }
20426
20427   // node_modules/d3-interpolate/src/date.js
20428   function date_default(a2, b2) {
20429     var d2 = /* @__PURE__ */ new Date();
20430     return a2 = +a2, b2 = +b2, function(t2) {
20431       return d2.setTime(a2 * (1 - t2) + b2 * t2), d2;
20432     };
20433   }
20434
20435   // node_modules/d3-interpolate/src/number.js
20436   function number_default(a2, b2) {
20437     return a2 = +a2, b2 = +b2, function(t2) {
20438       return a2 * (1 - t2) + b2 * t2;
20439     };
20440   }
20441
20442   // node_modules/d3-interpolate/src/object.js
20443   function object_default(a2, b2) {
20444     var i3 = {}, c2 = {}, k2;
20445     if (a2 === null || typeof a2 !== "object")
20446       a2 = {};
20447     if (b2 === null || typeof b2 !== "object")
20448       b2 = {};
20449     for (k2 in b2) {
20450       if (k2 in a2) {
20451         i3[k2] = value_default(a2[k2], b2[k2]);
20452       } else {
20453         c2[k2] = b2[k2];
20454       }
20455     }
20456     return function(t2) {
20457       for (k2 in i3)
20458         c2[k2] = i3[k2](t2);
20459       return c2;
20460     };
20461   }
20462
20463   // node_modules/d3-interpolate/src/string.js
20464   var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
20465   var reB = new RegExp(reA.source, "g");
20466   function zero2(b2) {
20467     return function() {
20468       return b2;
20469     };
20470   }
20471   function one(b2) {
20472     return function(t2) {
20473       return b2(t2) + "";
20474     };
20475   }
20476   function string_default(a2, b2) {
20477     var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i3 = -1, s2 = [], q2 = [];
20478     a2 = a2 + "", b2 = b2 + "";
20479     while ((am = reA.exec(a2)) && (bm = reB.exec(b2))) {
20480       if ((bs = bm.index) > bi) {
20481         bs = b2.slice(bi, bs);
20482         if (s2[i3])
20483           s2[i3] += bs;
20484         else
20485           s2[++i3] = bs;
20486       }
20487       if ((am = am[0]) === (bm = bm[0])) {
20488         if (s2[i3])
20489           s2[i3] += bm;
20490         else
20491           s2[++i3] = bm;
20492       } else {
20493         s2[++i3] = null;
20494         q2.push({ i: i3, x: number_default(am, bm) });
20495       }
20496       bi = reB.lastIndex;
20497     }
20498     if (bi < b2.length) {
20499       bs = b2.slice(bi);
20500       if (s2[i3])
20501         s2[i3] += bs;
20502       else
20503         s2[++i3] = bs;
20504     }
20505     return s2.length < 2 ? q2[0] ? one(q2[0].x) : zero2(b2) : (b2 = q2.length, function(t2) {
20506       for (var i4 = 0, o2; i4 < b2; ++i4)
20507         s2[(o2 = q2[i4]).i] = o2.x(t2);
20508       return s2.join("");
20509     });
20510   }
20511
20512   // node_modules/d3-interpolate/src/value.js
20513   function value_default(a2, b2) {
20514     var t2 = typeof b2, c2;
20515     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);
20516   }
20517
20518   // node_modules/d3-interpolate/src/round.js
20519   function round_default(a2, b2) {
20520     return a2 = +a2, b2 = +b2, function(t2) {
20521       return Math.round(a2 * (1 - t2) + b2 * t2);
20522     };
20523   }
20524
20525   // node_modules/d3-interpolate/src/transform/decompose.js
20526   var degrees2 = 180 / Math.PI;
20527   var identity = {
20528     translateX: 0,
20529     translateY: 0,
20530     rotate: 0,
20531     skewX: 0,
20532     scaleX: 1,
20533     scaleY: 1
20534   };
20535   function decompose_default(a2, b2, c2, d2, e3, f2) {
20536     var scaleX, scaleY, skewX;
20537     if (scaleX = Math.sqrt(a2 * a2 + b2 * b2))
20538       a2 /= scaleX, b2 /= scaleX;
20539     if (skewX = a2 * c2 + b2 * d2)
20540       c2 -= a2 * skewX, d2 -= b2 * skewX;
20541     if (scaleY = Math.sqrt(c2 * c2 + d2 * d2))
20542       c2 /= scaleY, d2 /= scaleY, skewX /= scaleY;
20543     if (a2 * d2 < b2 * c2)
20544       a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX;
20545     return {
20546       translateX: e3,
20547       translateY: f2,
20548       rotate: Math.atan2(b2, a2) * degrees2,
20549       skewX: Math.atan(skewX) * degrees2,
20550       scaleX,
20551       scaleY
20552     };
20553   }
20554
20555   // node_modules/d3-interpolate/src/transform/parse.js
20556   var svgNode;
20557   function parseCss(value) {
20558     const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
20559     return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f);
20560   }
20561   function parseSvg(value) {
20562     if (value == null)
20563       return identity;
20564     if (!svgNode)
20565       svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
20566     svgNode.setAttribute("transform", value);
20567     if (!(value = svgNode.transform.baseVal.consolidate()))
20568       return identity;
20569     value = value.matrix;
20570     return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f);
20571   }
20572
20573   // node_modules/d3-interpolate/src/transform/index.js
20574   function interpolateTransform(parse, pxComma, pxParen, degParen) {
20575     function pop(s2) {
20576       return s2.length ? s2.pop() + " " : "";
20577     }
20578     function translate(xa, ya, xb, yb, s2, q2) {
20579       if (xa !== xb || ya !== yb) {
20580         var i3 = s2.push("translate(", null, pxComma, null, pxParen);
20581         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20582       } else if (xb || yb) {
20583         s2.push("translate(" + xb + pxComma + yb + pxParen);
20584       }
20585     }
20586     function rotate(a2, b2, s2, q2) {
20587       if (a2 !== b2) {
20588         if (a2 - b2 > 180)
20589           b2 += 360;
20590         else if (b2 - a2 > 180)
20591           a2 += 360;
20592         q2.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: number_default(a2, b2) });
20593       } else if (b2) {
20594         s2.push(pop(s2) + "rotate(" + b2 + degParen);
20595       }
20596     }
20597     function skewX(a2, b2, s2, q2) {
20598       if (a2 !== b2) {
20599         q2.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: number_default(a2, b2) });
20600       } else if (b2) {
20601         s2.push(pop(s2) + "skewX(" + b2 + degParen);
20602       }
20603     }
20604     function scale(xa, ya, xb, yb, s2, q2) {
20605       if (xa !== xb || ya !== yb) {
20606         var i3 = s2.push(pop(s2) + "scale(", null, ",", null, ")");
20607         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20608       } else if (xb !== 1 || yb !== 1) {
20609         s2.push(pop(s2) + "scale(" + xb + "," + yb + ")");
20610       }
20611     }
20612     return function(a2, b2) {
20613       var s2 = [], q2 = [];
20614       a2 = parse(a2), b2 = parse(b2);
20615       translate(a2.translateX, a2.translateY, b2.translateX, b2.translateY, s2, q2);
20616       rotate(a2.rotate, b2.rotate, s2, q2);
20617       skewX(a2.skewX, b2.skewX, s2, q2);
20618       scale(a2.scaleX, a2.scaleY, b2.scaleX, b2.scaleY, s2, q2);
20619       a2 = b2 = null;
20620       return function(t2) {
20621         var i3 = -1, n3 = q2.length, o2;
20622         while (++i3 < n3)
20623           s2[(o2 = q2[i3]).i] = o2.x(t2);
20624         return s2.join("");
20625       };
20626     };
20627   }
20628   var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
20629   var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
20630
20631   // node_modules/d3-interpolate/src/zoom.js
20632   var epsilon22 = 1e-12;
20633   function cosh(x2) {
20634     return ((x2 = Math.exp(x2)) + 1 / x2) / 2;
20635   }
20636   function sinh(x2) {
20637     return ((x2 = Math.exp(x2)) - 1 / x2) / 2;
20638   }
20639   function tanh(x2) {
20640     return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1);
20641   }
20642   var zoom_default = function zoomRho(rho, rho2, rho4) {
20643     function zoom(p02, p1) {
20644       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;
20645       if (d2 < epsilon22) {
20646         S2 = Math.log(w1 / w0) / rho;
20647         i3 = function(t2) {
20648           return [
20649             ux0 + t2 * dx,
20650             uy0 + t2 * dy,
20651             w0 * Math.exp(rho * t2 * S2)
20652           ];
20653         };
20654       } else {
20655         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);
20656         S2 = (r1 - r0) / rho;
20657         i3 = function(t2) {
20658           var s2 = t2 * S2, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0));
20659           return [
20660             ux0 + u2 * dx,
20661             uy0 + u2 * dy,
20662             w0 * coshr0 / cosh(rho * s2 + r0)
20663           ];
20664         };
20665       }
20666       i3.duration = S2 * 1e3 * rho / Math.SQRT2;
20667       return i3;
20668     }
20669     zoom.rho = function(_2) {
20670       var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22;
20671       return zoomRho(_1, _22, _4);
20672     };
20673     return zoom;
20674   }(Math.SQRT2, 2, 4);
20675
20676   // node_modules/d3-interpolate/src/quantize.js
20677   function quantize_default(interpolator, n3) {
20678     var samples = new Array(n3);
20679     for (var i3 = 0; i3 < n3; ++i3)
20680       samples[i3] = interpolator(i3 / (n3 - 1));
20681     return samples;
20682   }
20683
20684   // node_modules/d3-timer/src/timer.js
20685   var frame = 0;
20686   var timeout = 0;
20687   var interval = 0;
20688   var pokeDelay = 1e3;
20689   var taskHead;
20690   var taskTail;
20691   var clockLast = 0;
20692   var clockNow = 0;
20693   var clockSkew = 0;
20694   var clock = typeof performance === "object" && performance.now ? performance : Date;
20695   var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) {
20696     setTimeout(f2, 17);
20697   };
20698   function now() {
20699     return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
20700   }
20701   function clearNow() {
20702     clockNow = 0;
20703   }
20704   function Timer() {
20705     this._call = this._time = this._next = null;
20706   }
20707   Timer.prototype = timer.prototype = {
20708     constructor: Timer,
20709     restart: function(callback, delay, time) {
20710       if (typeof callback !== "function")
20711         throw new TypeError("callback is not a function");
20712       time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
20713       if (!this._next && taskTail !== this) {
20714         if (taskTail)
20715           taskTail._next = this;
20716         else
20717           taskHead = this;
20718         taskTail = this;
20719       }
20720       this._call = callback;
20721       this._time = time;
20722       sleep();
20723     },
20724     stop: function() {
20725       if (this._call) {
20726         this._call = null;
20727         this._time = Infinity;
20728         sleep();
20729       }
20730     }
20731   };
20732   function timer(callback, delay, time) {
20733     var t2 = new Timer();
20734     t2.restart(callback, delay, time);
20735     return t2;
20736   }
20737   function timerFlush() {
20738     now();
20739     ++frame;
20740     var t2 = taskHead, e3;
20741     while (t2) {
20742       if ((e3 = clockNow - t2._time) >= 0)
20743         t2._call.call(void 0, e3);
20744       t2 = t2._next;
20745     }
20746     --frame;
20747   }
20748   function wake() {
20749     clockNow = (clockLast = clock.now()) + clockSkew;
20750     frame = timeout = 0;
20751     try {
20752       timerFlush();
20753     } finally {
20754       frame = 0;
20755       nap();
20756       clockNow = 0;
20757     }
20758   }
20759   function poke() {
20760     var now3 = clock.now(), delay = now3 - clockLast;
20761     if (delay > pokeDelay)
20762       clockSkew -= delay, clockLast = now3;
20763   }
20764   function nap() {
20765     var t0, t1 = taskHead, t2, time = Infinity;
20766     while (t1) {
20767       if (t1._call) {
20768         if (time > t1._time)
20769           time = t1._time;
20770         t0 = t1, t1 = t1._next;
20771       } else {
20772         t2 = t1._next, t1._next = null;
20773         t1 = t0 ? t0._next = t2 : taskHead = t2;
20774       }
20775     }
20776     taskTail = t0;
20777     sleep(time);
20778   }
20779   function sleep(time) {
20780     if (frame)
20781       return;
20782     if (timeout)
20783       timeout = clearTimeout(timeout);
20784     var delay = time - clockNow;
20785     if (delay > 24) {
20786       if (time < Infinity)
20787         timeout = setTimeout(wake, time - clock.now() - clockSkew);
20788       if (interval)
20789         interval = clearInterval(interval);
20790     } else {
20791       if (!interval)
20792         clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
20793       frame = 1, setFrame(wake);
20794     }
20795   }
20796
20797   // node_modules/d3-timer/src/timeout.js
20798   function timeout_default(callback, delay, time) {
20799     var t2 = new Timer();
20800     delay = delay == null ? 0 : +delay;
20801     t2.restart((elapsed) => {
20802       t2.stop();
20803       callback(elapsed + delay);
20804     }, delay, time);
20805     return t2;
20806   }
20807
20808   // node_modules/d3-transition/src/transition/schedule.js
20809   var emptyOn = dispatch_default("start", "end", "cancel", "interrupt");
20810   var emptyTween = [];
20811   var CREATED = 0;
20812   var SCHEDULED = 1;
20813   var STARTING = 2;
20814   var STARTED = 3;
20815   var RUNNING = 4;
20816   var ENDING = 5;
20817   var ENDED = 6;
20818   function schedule_default(node, name, id2, index, group, timing) {
20819     var schedules = node.__transition;
20820     if (!schedules)
20821       node.__transition = {};
20822     else if (id2 in schedules)
20823       return;
20824     create(node, id2, {
20825       name,
20826       index,
20827       // For context during callback.
20828       group,
20829       // For context during callback.
20830       on: emptyOn,
20831       tween: emptyTween,
20832       time: timing.time,
20833       delay: timing.delay,
20834       duration: timing.duration,
20835       ease: timing.ease,
20836       timer: null,
20837       state: CREATED
20838     });
20839   }
20840   function init(node, id2) {
20841     var schedule = get2(node, id2);
20842     if (schedule.state > CREATED)
20843       throw new Error("too late; already scheduled");
20844     return schedule;
20845   }
20846   function set2(node, id2) {
20847     var schedule = get2(node, id2);
20848     if (schedule.state > STARTED)
20849       throw new Error("too late; already running");
20850     return schedule;
20851   }
20852   function get2(node, id2) {
20853     var schedule = node.__transition;
20854     if (!schedule || !(schedule = schedule[id2]))
20855       throw new Error("transition not found");
20856     return schedule;
20857   }
20858   function create(node, id2, self2) {
20859     var schedules = node.__transition, tween;
20860     schedules[id2] = self2;
20861     self2.timer = timer(schedule, 0, self2.time);
20862     function schedule(elapsed) {
20863       self2.state = SCHEDULED;
20864       self2.timer.restart(start2, self2.delay, self2.time);
20865       if (self2.delay <= elapsed)
20866         start2(elapsed - self2.delay);
20867     }
20868     function start2(elapsed) {
20869       var i3, j2, n3, o2;
20870       if (self2.state !== SCHEDULED)
20871         return stop();
20872       for (i3 in schedules) {
20873         o2 = schedules[i3];
20874         if (o2.name !== self2.name)
20875           continue;
20876         if (o2.state === STARTED)
20877           return timeout_default(start2);
20878         if (o2.state === RUNNING) {
20879           o2.state = ENDED;
20880           o2.timer.stop();
20881           o2.on.call("interrupt", node, node.__data__, o2.index, o2.group);
20882           delete schedules[i3];
20883         } else if (+i3 < id2) {
20884           o2.state = ENDED;
20885           o2.timer.stop();
20886           o2.on.call("cancel", node, node.__data__, o2.index, o2.group);
20887           delete schedules[i3];
20888         }
20889       }
20890       timeout_default(function() {
20891         if (self2.state === STARTED) {
20892           self2.state = RUNNING;
20893           self2.timer.restart(tick, self2.delay, self2.time);
20894           tick(elapsed);
20895         }
20896       });
20897       self2.state = STARTING;
20898       self2.on.call("start", node, node.__data__, self2.index, self2.group);
20899       if (self2.state !== STARTING)
20900         return;
20901       self2.state = STARTED;
20902       tween = new Array(n3 = self2.tween.length);
20903       for (i3 = 0, j2 = -1; i3 < n3; ++i3) {
20904         if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) {
20905           tween[++j2] = o2;
20906         }
20907       }
20908       tween.length = j2 + 1;
20909     }
20910     function tick(elapsed) {
20911       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;
20912       while (++i3 < n3) {
20913         tween[i3].call(node, t2);
20914       }
20915       if (self2.state === ENDING) {
20916         self2.on.call("end", node, node.__data__, self2.index, self2.group);
20917         stop();
20918       }
20919     }
20920     function stop() {
20921       self2.state = ENDED;
20922       self2.timer.stop();
20923       delete schedules[id2];
20924       for (var i3 in schedules)
20925         return;
20926       delete node.__transition;
20927     }
20928   }
20929
20930   // node_modules/d3-transition/src/interrupt.js
20931   function interrupt_default(node, name) {
20932     var schedules = node.__transition, schedule, active, empty2 = true, i3;
20933     if (!schedules)
20934       return;
20935     name = name == null ? null : name + "";
20936     for (i3 in schedules) {
20937       if ((schedule = schedules[i3]).name !== name) {
20938         empty2 = false;
20939         continue;
20940       }
20941       active = schedule.state > STARTING && schedule.state < ENDING;
20942       schedule.state = ENDED;
20943       schedule.timer.stop();
20944       schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
20945       delete schedules[i3];
20946     }
20947     if (empty2)
20948       delete node.__transition;
20949   }
20950
20951   // node_modules/d3-transition/src/selection/interrupt.js
20952   function interrupt_default2(name) {
20953     return this.each(function() {
20954       interrupt_default(this, name);
20955     });
20956   }
20957
20958   // node_modules/d3-transition/src/transition/tween.js
20959   function tweenRemove(id2, name) {
20960     var tween0, tween1;
20961     return function() {
20962       var schedule = set2(this, id2), tween = schedule.tween;
20963       if (tween !== tween0) {
20964         tween1 = tween0 = tween;
20965         for (var i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20966           if (tween1[i3].name === name) {
20967             tween1 = tween1.slice();
20968             tween1.splice(i3, 1);
20969             break;
20970           }
20971         }
20972       }
20973       schedule.tween = tween1;
20974     };
20975   }
20976   function tweenFunction(id2, name, value) {
20977     var tween0, tween1;
20978     if (typeof value !== "function")
20979       throw new Error();
20980     return function() {
20981       var schedule = set2(this, id2), tween = schedule.tween;
20982       if (tween !== tween0) {
20983         tween1 = (tween0 = tween).slice();
20984         for (var t2 = { name, value }, i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20985           if (tween1[i3].name === name) {
20986             tween1[i3] = t2;
20987             break;
20988           }
20989         }
20990         if (i3 === n3)
20991           tween1.push(t2);
20992       }
20993       schedule.tween = tween1;
20994     };
20995   }
20996   function tween_default(name, value) {
20997     var id2 = this._id;
20998     name += "";
20999     if (arguments.length < 2) {
21000       var tween = get2(this.node(), id2).tween;
21001       for (var i3 = 0, n3 = tween.length, t2; i3 < n3; ++i3) {
21002         if ((t2 = tween[i3]).name === name) {
21003           return t2.value;
21004         }
21005       }
21006       return null;
21007     }
21008     return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
21009   }
21010   function tweenValue(transition2, name, value) {
21011     var id2 = transition2._id;
21012     transition2.each(function() {
21013       var schedule = set2(this, id2);
21014       (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
21015     });
21016     return function(node) {
21017       return get2(node, id2).value[name];
21018     };
21019   }
21020
21021   // node_modules/d3-transition/src/transition/interpolate.js
21022   function interpolate_default(a2, b2) {
21023     var c2;
21024     return (typeof b2 === "number" ? number_default : b2 instanceof color ? rgb_default : (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default)(a2, b2);
21025   }
21026
21027   // node_modules/d3-transition/src/transition/attr.js
21028   function attrRemove2(name) {
21029     return function() {
21030       this.removeAttribute(name);
21031     };
21032   }
21033   function attrRemoveNS2(fullname) {
21034     return function() {
21035       this.removeAttributeNS(fullname.space, fullname.local);
21036     };
21037   }
21038   function attrConstant2(name, interpolate, value1) {
21039     var string00, string1 = value1 + "", interpolate0;
21040     return function() {
21041       var string0 = this.getAttribute(name);
21042       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21043     };
21044   }
21045   function attrConstantNS2(fullname, interpolate, value1) {
21046     var string00, string1 = value1 + "", interpolate0;
21047     return function() {
21048       var string0 = this.getAttributeNS(fullname.space, fullname.local);
21049       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21050     };
21051   }
21052   function attrFunction2(name, interpolate, value) {
21053     var string00, string10, interpolate0;
21054     return function() {
21055       var string0, value1 = value(this), string1;
21056       if (value1 == null)
21057         return void this.removeAttribute(name);
21058       string0 = this.getAttribute(name);
21059       string1 = value1 + "";
21060       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21061     };
21062   }
21063   function attrFunctionNS2(fullname, interpolate, value) {
21064     var string00, string10, interpolate0;
21065     return function() {
21066       var string0, value1 = value(this), string1;
21067       if (value1 == null)
21068         return void this.removeAttributeNS(fullname.space, fullname.local);
21069       string0 = this.getAttributeNS(fullname.space, fullname.local);
21070       string1 = value1 + "";
21071       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21072     };
21073   }
21074   function attr_default2(name, value) {
21075     var fullname = namespace_default(name), i3 = fullname === "transform" ? interpolateTransformSvg : interpolate_default;
21076     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));
21077   }
21078
21079   // node_modules/d3-transition/src/transition/attrTween.js
21080   function attrInterpolate(name, i3) {
21081     return function(t2) {
21082       this.setAttribute(name, i3.call(this, t2));
21083     };
21084   }
21085   function attrInterpolateNS(fullname, i3) {
21086     return function(t2) {
21087       this.setAttributeNS(fullname.space, fullname.local, i3.call(this, t2));
21088     };
21089   }
21090   function attrTweenNS(fullname, value) {
21091     var t0, i0;
21092     function tween() {
21093       var i3 = value.apply(this, arguments);
21094       if (i3 !== i0)
21095         t0 = (i0 = i3) && attrInterpolateNS(fullname, i3);
21096       return t0;
21097     }
21098     tween._value = value;
21099     return tween;
21100   }
21101   function attrTween(name, value) {
21102     var t0, i0;
21103     function tween() {
21104       var i3 = value.apply(this, arguments);
21105       if (i3 !== i0)
21106         t0 = (i0 = i3) && attrInterpolate(name, i3);
21107       return t0;
21108     }
21109     tween._value = value;
21110     return tween;
21111   }
21112   function attrTween_default(name, value) {
21113     var key = "attr." + name;
21114     if (arguments.length < 2)
21115       return (key = this.tween(key)) && key._value;
21116     if (value == null)
21117       return this.tween(key, null);
21118     if (typeof value !== "function")
21119       throw new Error();
21120     var fullname = namespace_default(name);
21121     return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
21122   }
21123
21124   // node_modules/d3-transition/src/transition/delay.js
21125   function delayFunction(id2, value) {
21126     return function() {
21127       init(this, id2).delay = +value.apply(this, arguments);
21128     };
21129   }
21130   function delayConstant(id2, value) {
21131     return value = +value, function() {
21132       init(this, id2).delay = value;
21133     };
21134   }
21135   function delay_default(value) {
21136     var id2 = this._id;
21137     return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay;
21138   }
21139
21140   // node_modules/d3-transition/src/transition/duration.js
21141   function durationFunction(id2, value) {
21142     return function() {
21143       set2(this, id2).duration = +value.apply(this, arguments);
21144     };
21145   }
21146   function durationConstant(id2, value) {
21147     return value = +value, function() {
21148       set2(this, id2).duration = value;
21149     };
21150   }
21151   function duration_default(value) {
21152     var id2 = this._id;
21153     return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration;
21154   }
21155
21156   // node_modules/d3-transition/src/transition/ease.js
21157   function easeConstant(id2, value) {
21158     if (typeof value !== "function")
21159       throw new Error();
21160     return function() {
21161       set2(this, id2).ease = value;
21162     };
21163   }
21164   function ease_default(value) {
21165     var id2 = this._id;
21166     return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease;
21167   }
21168
21169   // node_modules/d3-transition/src/transition/easeVarying.js
21170   function easeVarying(id2, value) {
21171     return function() {
21172       var v2 = value.apply(this, arguments);
21173       if (typeof v2 !== "function")
21174         throw new Error();
21175       set2(this, id2).ease = v2;
21176     };
21177   }
21178   function easeVarying_default(value) {
21179     if (typeof value !== "function")
21180       throw new Error();
21181     return this.each(easeVarying(this._id, value));
21182   }
21183
21184   // node_modules/d3-transition/src/transition/filter.js
21185   function filter_default2(match) {
21186     if (typeof match !== "function")
21187       match = matcher_default(match);
21188     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
21189       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
21190         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
21191           subgroup.push(node);
21192         }
21193       }
21194     }
21195     return new Transition(subgroups, this._parents, this._name, this._id);
21196   }
21197
21198   // node_modules/d3-transition/src/transition/merge.js
21199   function merge_default2(transition2) {
21200     if (transition2._id !== this._id)
21201       throw new Error();
21202     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) {
21203       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
21204         if (node = group0[i3] || group1[i3]) {
21205           merge2[i3] = node;
21206         }
21207       }
21208     }
21209     for (; j2 < m0; ++j2) {
21210       merges[j2] = groups0[j2];
21211     }
21212     return new Transition(merges, this._parents, this._name, this._id);
21213   }
21214
21215   // node_modules/d3-transition/src/transition/on.js
21216   function start(name) {
21217     return (name + "").trim().split(/^|\s+/).every(function(t2) {
21218       var i3 = t2.indexOf(".");
21219       if (i3 >= 0)
21220         t2 = t2.slice(0, i3);
21221       return !t2 || t2 === "start";
21222     });
21223   }
21224   function onFunction(id2, name, listener) {
21225     var on0, on1, sit = start(name) ? init : set2;
21226     return function() {
21227       var schedule = sit(this, id2), on = schedule.on;
21228       if (on !== on0)
21229         (on1 = (on0 = on).copy()).on(name, listener);
21230       schedule.on = on1;
21231     };
21232   }
21233   function on_default2(name, listener) {
21234     var id2 = this._id;
21235     return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
21236   }
21237
21238   // node_modules/d3-transition/src/transition/remove.js
21239   function removeFunction(id2) {
21240     return function() {
21241       var parent = this.parentNode;
21242       for (var i3 in this.__transition)
21243         if (+i3 !== id2)
21244           return;
21245       if (parent)
21246         parent.removeChild(this);
21247     };
21248   }
21249   function remove_default2() {
21250     return this.on("end.remove", removeFunction(this._id));
21251   }
21252
21253   // node_modules/d3-transition/src/transition/select.js
21254   function select_default3(select) {
21255     var name = this._name, id2 = this._id;
21256     if (typeof select !== "function")
21257       select = selector_default(select);
21258     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
21259       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
21260         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
21261           if ("__data__" in node)
21262             subnode.__data__ = node.__data__;
21263           subgroup[i3] = subnode;
21264           schedule_default(subgroup[i3], name, id2, i3, subgroup, get2(node, id2));
21265         }
21266       }
21267     }
21268     return new Transition(subgroups, this._parents, name, id2);
21269   }
21270
21271   // node_modules/d3-transition/src/transition/selectAll.js
21272   function selectAll_default3(select) {
21273     var name = this._name, id2 = this._id;
21274     if (typeof select !== "function")
21275       select = selectorAll_default(select);
21276     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
21277       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21278         if (node = group[i3]) {
21279           for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) {
21280             if (child = children2[k2]) {
21281               schedule_default(child, name, id2, k2, children2, inherit2);
21282             }
21283           }
21284           subgroups.push(children2);
21285           parents.push(node);
21286         }
21287       }
21288     }
21289     return new Transition(subgroups, parents, name, id2);
21290   }
21291
21292   // node_modules/d3-transition/src/transition/selection.js
21293   var Selection2 = selection_default.prototype.constructor;
21294   function selection_default2() {
21295     return new Selection2(this._groups, this._parents);
21296   }
21297
21298   // node_modules/d3-transition/src/transition/style.js
21299   function styleNull(name, interpolate) {
21300     var string00, string10, interpolate0;
21301     return function() {
21302       var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
21303       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1);
21304     };
21305   }
21306   function styleRemove2(name) {
21307     return function() {
21308       this.style.removeProperty(name);
21309     };
21310   }
21311   function styleConstant2(name, interpolate, value1) {
21312     var string00, string1 = value1 + "", interpolate0;
21313     return function() {
21314       var string0 = styleValue(this, name);
21315       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21316     };
21317   }
21318   function styleFunction2(name, interpolate, value) {
21319     var string00, string10, interpolate0;
21320     return function() {
21321       var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
21322       if (value1 == null)
21323         string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
21324       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21325     };
21326   }
21327   function styleMaybeRemove(id2, name) {
21328     var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
21329     return function() {
21330       var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0;
21331       if (on !== on0 || listener0 !== listener)
21332         (on1 = (on0 = on).copy()).on(event, listener0 = listener);
21333       schedule.on = on1;
21334     };
21335   }
21336   function style_default2(name, value, priority) {
21337     var i3 = (name += "") === "transform" ? interpolateTransformCss : interpolate_default;
21338     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);
21339   }
21340
21341   // node_modules/d3-transition/src/transition/styleTween.js
21342   function styleInterpolate(name, i3, priority) {
21343     return function(t2) {
21344       this.style.setProperty(name, i3.call(this, t2), priority);
21345     };
21346   }
21347   function styleTween(name, value, priority) {
21348     var t2, i0;
21349     function tween() {
21350       var i3 = value.apply(this, arguments);
21351       if (i3 !== i0)
21352         t2 = (i0 = i3) && styleInterpolate(name, i3, priority);
21353       return t2;
21354     }
21355     tween._value = value;
21356     return tween;
21357   }
21358   function styleTween_default(name, value, priority) {
21359     var key = "style." + (name += "");
21360     if (arguments.length < 2)
21361       return (key = this.tween(key)) && key._value;
21362     if (value == null)
21363       return this.tween(key, null);
21364     if (typeof value !== "function")
21365       throw new Error();
21366     return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
21367   }
21368
21369   // node_modules/d3-transition/src/transition/text.js
21370   function textConstant2(value) {
21371     return function() {
21372       this.textContent = value;
21373     };
21374   }
21375   function textFunction2(value) {
21376     return function() {
21377       var value1 = value(this);
21378       this.textContent = value1 == null ? "" : value1;
21379     };
21380   }
21381   function text_default2(value) {
21382     return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + ""));
21383   }
21384
21385   // node_modules/d3-transition/src/transition/textTween.js
21386   function textInterpolate(i3) {
21387     return function(t2) {
21388       this.textContent = i3.call(this, t2);
21389     };
21390   }
21391   function textTween(value) {
21392     var t0, i0;
21393     function tween() {
21394       var i3 = value.apply(this, arguments);
21395       if (i3 !== i0)
21396         t0 = (i0 = i3) && textInterpolate(i3);
21397       return t0;
21398     }
21399     tween._value = value;
21400     return tween;
21401   }
21402   function textTween_default(value) {
21403     var key = "text";
21404     if (arguments.length < 1)
21405       return (key = this.tween(key)) && key._value;
21406     if (value == null)
21407       return this.tween(key, null);
21408     if (typeof value !== "function")
21409       throw new Error();
21410     return this.tween(key, textTween(value));
21411   }
21412
21413   // node_modules/d3-transition/src/transition/transition.js
21414   function transition_default() {
21415     var name = this._name, id0 = this._id, id1 = newId();
21416     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21417       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21418         if (node = group[i3]) {
21419           var inherit2 = get2(node, id0);
21420           schedule_default(node, name, id1, i3, group, {
21421             time: inherit2.time + inherit2.delay + inherit2.duration,
21422             delay: 0,
21423             duration: inherit2.duration,
21424             ease: inherit2.ease
21425           });
21426         }
21427       }
21428     }
21429     return new Transition(groups, this._parents, name, id1);
21430   }
21431
21432   // node_modules/d3-transition/src/transition/end.js
21433   function end_default() {
21434     var on0, on1, that = this, id2 = that._id, size = that.size();
21435     return new Promise(function(resolve, reject) {
21436       var cancel = { value: reject }, end = { value: function() {
21437         if (--size === 0)
21438           resolve();
21439       } };
21440       that.each(function() {
21441         var schedule = set2(this, id2), on = schedule.on;
21442         if (on !== on0) {
21443           on1 = (on0 = on).copy();
21444           on1._.cancel.push(cancel);
21445           on1._.interrupt.push(cancel);
21446           on1._.end.push(end);
21447         }
21448         schedule.on = on1;
21449       });
21450       if (size === 0)
21451         resolve();
21452     });
21453   }
21454
21455   // node_modules/d3-transition/src/transition/index.js
21456   var id = 0;
21457   function Transition(groups, parents, name, id2) {
21458     this._groups = groups;
21459     this._parents = parents;
21460     this._name = name;
21461     this._id = id2;
21462   }
21463   function transition(name) {
21464     return selection_default().transition(name);
21465   }
21466   function newId() {
21467     return ++id;
21468   }
21469   var selection_prototype = selection_default.prototype;
21470   Transition.prototype = transition.prototype = {
21471     constructor: Transition,
21472     select: select_default3,
21473     selectAll: selectAll_default3,
21474     selectChild: selection_prototype.selectChild,
21475     selectChildren: selection_prototype.selectChildren,
21476     filter: filter_default2,
21477     merge: merge_default2,
21478     selection: selection_default2,
21479     transition: transition_default,
21480     call: selection_prototype.call,
21481     nodes: selection_prototype.nodes,
21482     node: selection_prototype.node,
21483     size: selection_prototype.size,
21484     empty: selection_prototype.empty,
21485     each: selection_prototype.each,
21486     on: on_default2,
21487     attr: attr_default2,
21488     attrTween: attrTween_default,
21489     style: style_default2,
21490     styleTween: styleTween_default,
21491     text: text_default2,
21492     textTween: textTween_default,
21493     remove: remove_default2,
21494     tween: tween_default,
21495     delay: delay_default,
21496     duration: duration_default,
21497     ease: ease_default,
21498     easeVarying: easeVarying_default,
21499     end: end_default,
21500     [Symbol.iterator]: selection_prototype[Symbol.iterator]
21501   };
21502
21503   // node_modules/d3-ease/src/linear.js
21504   var linear2 = (t2) => +t2;
21505
21506   // node_modules/d3-ease/src/cubic.js
21507   function cubicInOut(t2) {
21508     return ((t2 *= 2) <= 1 ? t2 * t2 * t2 : (t2 -= 2) * t2 * t2 + 2) / 2;
21509   }
21510
21511   // node_modules/d3-transition/src/selection/transition.js
21512   var defaultTiming = {
21513     time: null,
21514     // Set on use.
21515     delay: 0,
21516     duration: 250,
21517     ease: cubicInOut
21518   };
21519   function inherit(node, id2) {
21520     var timing;
21521     while (!(timing = node.__transition) || !(timing = timing[id2])) {
21522       if (!(node = node.parentNode)) {
21523         throw new Error("transition ".concat(id2, " not found"));
21524       }
21525     }
21526     return timing;
21527   }
21528   function transition_default2(name) {
21529     var id2, timing;
21530     if (name instanceof Transition) {
21531       id2 = name._id, name = name._name;
21532     } else {
21533       id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
21534     }
21535     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21536       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21537         if (node = group[i3]) {
21538           schedule_default(node, name, id2, i3, group, timing || inherit(node, id2));
21539         }
21540       }
21541     }
21542     return new Transition(groups, this._parents, name, id2);
21543   }
21544
21545   // node_modules/d3-transition/src/selection/index.js
21546   selection_default.prototype.interrupt = interrupt_default2;
21547   selection_default.prototype.transition = transition_default2;
21548
21549   // node_modules/d3-zoom/src/constant.js
21550   var constant_default4 = (x2) => () => x2;
21551
21552   // node_modules/d3-zoom/src/event.js
21553   function ZoomEvent(type2, {
21554     sourceEvent,
21555     target,
21556     transform: transform2,
21557     dispatch: dispatch14
21558   }) {
21559     Object.defineProperties(this, {
21560       type: { value: type2, enumerable: true, configurable: true },
21561       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
21562       target: { value: target, enumerable: true, configurable: true },
21563       transform: { value: transform2, enumerable: true, configurable: true },
21564       _: { value: dispatch14 }
21565     });
21566   }
21567
21568   // node_modules/d3-zoom/src/transform.js
21569   function Transform(k2, x2, y2) {
21570     this.k = k2;
21571     this.x = x2;
21572     this.y = y2;
21573   }
21574   Transform.prototype = {
21575     constructor: Transform,
21576     scale: function(k2) {
21577       return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y);
21578     },
21579     translate: function(x2, y2) {
21580       return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2);
21581     },
21582     apply: function(point2) {
21583       return [point2[0] * this.k + this.x, point2[1] * this.k + this.y];
21584     },
21585     applyX: function(x2) {
21586       return x2 * this.k + this.x;
21587     },
21588     applyY: function(y2) {
21589       return y2 * this.k + this.y;
21590     },
21591     invert: function(location) {
21592       return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
21593     },
21594     invertX: function(x2) {
21595       return (x2 - this.x) / this.k;
21596     },
21597     invertY: function(y2) {
21598       return (y2 - this.y) / this.k;
21599     },
21600     rescaleX: function(x2) {
21601       return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2));
21602     },
21603     rescaleY: function(y2) {
21604       return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2));
21605     },
21606     toString: function() {
21607       return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
21608     }
21609   };
21610   var identity2 = new Transform(1, 0, 0);
21611   transform.prototype = Transform.prototype;
21612   function transform(node) {
21613     while (!node.__zoom)
21614       if (!(node = node.parentNode))
21615         return identity2;
21616     return node.__zoom;
21617   }
21618
21619   // node_modules/d3-zoom/src/noevent.js
21620   function nopropagation2(event) {
21621     event.stopImmediatePropagation();
21622   }
21623   function noevent_default2(event) {
21624     event.preventDefault();
21625     event.stopImmediatePropagation();
21626   }
21627
21628   // node_modules/d3-zoom/src/zoom.js
21629   function defaultFilter2(event) {
21630     return (!event.ctrlKey || event.type === "wheel") && !event.button;
21631   }
21632   function defaultExtent() {
21633     var e3 = this;
21634     if (e3 instanceof SVGElement) {
21635       e3 = e3.ownerSVGElement || e3;
21636       if (e3.hasAttribute("viewBox")) {
21637         e3 = e3.viewBox.baseVal;
21638         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
21639       }
21640       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
21641     }
21642     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
21643   }
21644   function defaultTransform() {
21645     return this.__zoom || identity2;
21646   }
21647   function defaultWheelDelta(event) {
21648     return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1);
21649   }
21650   function defaultTouchable2() {
21651     return navigator.maxTouchPoints || "ontouchstart" in this;
21652   }
21653   function defaultConstrain(transform2, extent, translateExtent) {
21654     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];
21655     return transform2.translate(
21656       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
21657       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
21658     );
21659   }
21660   function zoom_default2() {
21661     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;
21662     function zoom(selection2) {
21663       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)");
21664     }
21665     zoom.transform = function(collection, transform2, point2, event) {
21666       var selection2 = collection.selection ? collection.selection() : collection;
21667       selection2.property("__zoom", defaultTransform);
21668       if (collection !== selection2) {
21669         schedule(collection, transform2, point2, event);
21670       } else {
21671         selection2.interrupt().each(function() {
21672           gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end();
21673         });
21674       }
21675     };
21676     zoom.scaleBy = function(selection2, k2, p2, event) {
21677       zoom.scaleTo(selection2, function() {
21678         var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
21679         return k0 * k1;
21680       }, p2, event);
21681     };
21682     zoom.scaleTo = function(selection2, k2, p2, event) {
21683       zoom.transform(selection2, function() {
21684         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;
21685         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
21686       }, p2, event);
21687     };
21688     zoom.translateBy = function(selection2, x2, y2, event) {
21689       zoom.transform(selection2, function() {
21690         return constrain(this.__zoom.translate(
21691           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
21692           typeof y2 === "function" ? y2.apply(this, arguments) : y2
21693         ), extent.apply(this, arguments), translateExtent);
21694       }, null, event);
21695     };
21696     zoom.translateTo = function(selection2, x2, y2, p2, event) {
21697       zoom.transform(selection2, function() {
21698         var e3 = extent.apply(this, arguments), t2 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
21699         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
21700           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
21701           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
21702         ), e3, translateExtent);
21703       }, p2, event);
21704     };
21705     function scale(transform2, k2) {
21706       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
21707       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
21708     }
21709     function translate(transform2, p02, p1) {
21710       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
21711       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
21712     }
21713     function centroid(extent2) {
21714       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
21715     }
21716     function schedule(transition2, transform2, point2, event) {
21717       transition2.on("start.zoom", function() {
21718         gesture(this, arguments).event(event).start();
21719       }).on("interrupt.zoom end.zoom", function() {
21720         gesture(this, arguments).event(event).end();
21721       }).tween("zoom", function() {
21722         var that = this, args = arguments, g3 = gesture(that, args).event(event), e3 = extent.apply(that, args), p2 = point2 == null ? centroid(e3) : typeof point2 === "function" ? point2.apply(that, args) : point2, 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));
21723         return function(t2) {
21724           if (t2 === 1)
21725             t2 = b2;
21726           else {
21727             var l2 = i3(t2), k2 = w2 / l2[2];
21728             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
21729           }
21730           g3.zoom(null, t2);
21731         };
21732       });
21733     }
21734     function gesture(that, args, clean2) {
21735       return !clean2 && that.__zooming || new Gesture(that, args);
21736     }
21737     function Gesture(that, args) {
21738       this.that = that;
21739       this.args = args;
21740       this.active = 0;
21741       this.sourceEvent = null;
21742       this.extent = extent.apply(that, args);
21743       this.taps = 0;
21744     }
21745     Gesture.prototype = {
21746       event: function(event) {
21747         if (event)
21748           this.sourceEvent = event;
21749         return this;
21750       },
21751       start: function() {
21752         if (++this.active === 1) {
21753           this.that.__zooming = this;
21754           this.emit("start");
21755         }
21756         return this;
21757       },
21758       zoom: function(key, transform2) {
21759         if (this.mouse && key !== "mouse")
21760           this.mouse[1] = transform2.invert(this.mouse[0]);
21761         if (this.touch0 && key !== "touch")
21762           this.touch0[1] = transform2.invert(this.touch0[0]);
21763         if (this.touch1 && key !== "touch")
21764           this.touch1[1] = transform2.invert(this.touch1[0]);
21765         this.that.__zoom = transform2;
21766         this.emit("zoom");
21767         return this;
21768       },
21769       end: function() {
21770         if (--this.active === 0) {
21771           delete this.that.__zooming;
21772           this.emit("end");
21773         }
21774         return this;
21775       },
21776       emit: function(type2) {
21777         var d2 = select_default2(this.that).datum();
21778         listeners.call(
21779           type2,
21780           this.that,
21781           new ZoomEvent(type2, {
21782             sourceEvent: this.sourceEvent,
21783             target: zoom,
21784             type: type2,
21785             transform: this.that.__zoom,
21786             dispatch: listeners
21787           }),
21788           d2
21789         );
21790       }
21791     };
21792     function wheeled(event, ...args) {
21793       if (!filter2.apply(this, arguments))
21794         return;
21795       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);
21796       if (g3.wheel) {
21797         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
21798           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
21799         }
21800         clearTimeout(g3.wheel);
21801       } else if (t2.k === k2)
21802         return;
21803       else {
21804         g3.mouse = [p2, t2.invert(p2)];
21805         interrupt_default(this);
21806         g3.start();
21807       }
21808       noevent_default2(event);
21809       g3.wheel = setTimeout(wheelidled, wheelDelay);
21810       g3.zoom("mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
21811       function wheelidled() {
21812         g3.wheel = null;
21813         g3.end();
21814       }
21815     }
21816     function mousedowned(event, ...args) {
21817       if (touchending || !filter2.apply(this, arguments))
21818         return;
21819       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;
21820       nodrag_default(event.view);
21821       nopropagation2(event);
21822       g3.mouse = [p2, this.__zoom.invert(p2)];
21823       interrupt_default(this);
21824       g3.start();
21825       function mousemoved(event2) {
21826         noevent_default2(event2);
21827         if (!g3.moved) {
21828           var dx = event2.clientX - x05, dy = event2.clientY - y05;
21829           g3.moved = dx * dx + dy * dy > clickDistance2;
21830         }
21831         g3.event(event2).zoom("mouse", constrain(translate(g3.that.__zoom, g3.mouse[0] = pointer_default(event2, currentTarget), g3.mouse[1]), g3.extent, translateExtent));
21832       }
21833       function mouseupped(event2) {
21834         v2.on("mousemove.zoom mouseup.zoom", null);
21835         yesdrag(event2.view, g3.moved);
21836         noevent_default2(event2);
21837         g3.event(event2).end();
21838       }
21839     }
21840     function dblclicked(event, ...args) {
21841       if (!filter2.apply(this, arguments))
21842         return;
21843       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);
21844       noevent_default2(event);
21845       if (duration > 0)
21846         select_default2(this).transition().duration(duration).call(schedule, t1, p02, event);
21847       else
21848         select_default2(this).call(zoom.transform, t1, p02, event);
21849     }
21850     function touchstarted(event, ...args) {
21851       if (!filter2.apply(this, arguments))
21852         return;
21853       var touches = event.touches, n3 = touches.length, g3 = gesture(this, args, event.changedTouches.length === n3).event(event), started, i3, t2, p2;
21854       nopropagation2(event);
21855       for (i3 = 0; i3 < n3; ++i3) {
21856         t2 = touches[i3], p2 = pointer_default(t2, this);
21857         p2 = [p2, this.__zoom.invert(p2), t2.identifier];
21858         if (!g3.touch0)
21859           g3.touch0 = p2, started = true, g3.taps = 1 + !!touchstarting;
21860         else if (!g3.touch1 && g3.touch0[2] !== p2[2])
21861           g3.touch1 = p2, g3.taps = 0;
21862       }
21863       if (touchstarting)
21864         touchstarting = clearTimeout(touchstarting);
21865       if (started) {
21866         if (g3.taps < 2)
21867           touchfirst = p2[0], touchstarting = setTimeout(function() {
21868             touchstarting = null;
21869           }, touchDelay);
21870         interrupt_default(this);
21871         g3.start();
21872       }
21873     }
21874     function touchmoved(event, ...args) {
21875       if (!this.__zooming)
21876         return;
21877       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2, p2, l2;
21878       noevent_default2(event);
21879       for (i3 = 0; i3 < n3; ++i3) {
21880         t2 = touches[i3], p2 = pointer_default(t2, this);
21881         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21882           g3.touch0[0] = p2;
21883         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21884           g3.touch1[0] = p2;
21885       }
21886       t2 = g3.that.__zoom;
21887       if (g3.touch1) {
21888         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;
21889         t2 = scale(t2, Math.sqrt(dp / dl));
21890         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
21891         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
21892       } else if (g3.touch0)
21893         p2 = g3.touch0[0], l2 = g3.touch0[1];
21894       else
21895         return;
21896       g3.zoom("touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
21897     }
21898     function touchended(event, ...args) {
21899       if (!this.__zooming)
21900         return;
21901       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2;
21902       nopropagation2(event);
21903       if (touchending)
21904         clearTimeout(touchending);
21905       touchending = setTimeout(function() {
21906         touchending = null;
21907       }, touchDelay);
21908       for (i3 = 0; i3 < n3; ++i3) {
21909         t2 = touches[i3];
21910         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21911           delete g3.touch0;
21912         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21913           delete g3.touch1;
21914       }
21915       if (g3.touch1 && !g3.touch0)
21916         g3.touch0 = g3.touch1, delete g3.touch1;
21917       if (g3.touch0)
21918         g3.touch0[1] = this.__zoom.invert(g3.touch0[0]);
21919       else {
21920         g3.end();
21921         if (g3.taps === 2) {
21922           t2 = pointer_default(t2, this);
21923           if (Math.hypot(touchfirst[0] - t2[0], touchfirst[1] - t2[1]) < tapDistance) {
21924             var p2 = select_default2(this).on("dblclick.zoom");
21925             if (p2)
21926               p2.apply(this, arguments);
21927           }
21928         }
21929       }
21930     }
21931     zoom.wheelDelta = function(_2) {
21932       return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant_default4(+_2), zoom) : wheelDelta;
21933     };
21934     zoom.filter = function(_2) {
21935       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : filter2;
21936     };
21937     zoom.touchable = function(_2) {
21938       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : touchable;
21939     };
21940     zoom.extent = function(_2) {
21941       return arguments.length ? (extent = typeof _2 === "function" ? _2 : constant_default4([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
21942     };
21943     zoom.scaleExtent = function(_2) {
21944       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
21945     };
21946     zoom.translateExtent = function(_2) {
21947       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]]];
21948     };
21949     zoom.constrain = function(_2) {
21950       return arguments.length ? (constrain = _2, zoom) : constrain;
21951     };
21952     zoom.duration = function(_2) {
21953       return arguments.length ? (duration = +_2, zoom) : duration;
21954     };
21955     zoom.interpolate = function(_2) {
21956       return arguments.length ? (interpolate = _2, zoom) : interpolate;
21957     };
21958     zoom.on = function() {
21959       var value = listeners.on.apply(listeners, arguments);
21960       return value === listeners ? zoom : value;
21961     };
21962     zoom.clickDistance = function(_2) {
21963       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom) : Math.sqrt(clickDistance2);
21964     };
21965     zoom.tapDistance = function(_2) {
21966       return arguments.length ? (tapDistance = +_2, zoom) : tapDistance;
21967     };
21968     return zoom;
21969   }
21970
21971   // modules/geo/raw_mercator.js
21972   function geoRawMercator() {
21973     var project = mercatorRaw;
21974     var k2 = 512 / Math.PI;
21975     var x2 = 0;
21976     var y2 = 0;
21977     var clipExtent = [[0, 0], [0, 0]];
21978     function projection2(point2) {
21979       point2 = project(point2[0] * Math.PI / 180, point2[1] * Math.PI / 180);
21980       return [point2[0] * k2 + x2, y2 - point2[1] * k2];
21981     }
21982     projection2.invert = function(point2) {
21983       point2 = project.invert((point2[0] - x2) / k2, (y2 - point2[1]) / k2);
21984       return point2 && [point2[0] * 180 / Math.PI, point2[1] * 180 / Math.PI];
21985     };
21986     projection2.scale = function(_2) {
21987       if (!arguments.length)
21988         return k2;
21989       k2 = +_2;
21990       return projection2;
21991     };
21992     projection2.translate = function(_2) {
21993       if (!arguments.length)
21994         return [x2, y2];
21995       x2 = +_2[0];
21996       y2 = +_2[1];
21997       return projection2;
21998     };
21999     projection2.clipExtent = function(_2) {
22000       if (!arguments.length)
22001         return clipExtent;
22002       clipExtent = _2;
22003       return projection2;
22004     };
22005     projection2.transform = function(obj) {
22006       if (!arguments.length)
22007         return identity2.translate(x2, y2).scale(k2);
22008       x2 = +obj.x;
22009       y2 = +obj.y;
22010       k2 = +obj.k;
22011       return projection2;
22012     };
22013     projection2.stream = transform_default({
22014       point: function(x3, y3) {
22015         var vec = projection2([x3, y3]);
22016         this.stream.point(vec[0], vec[1]);
22017       }
22018     }).stream;
22019     return projection2;
22020   }
22021
22022   // modules/geo/ortho.js
22023   function geoOrthoNormalizedDotProduct(a2, b2, origin) {
22024     if (geoVecEqual(origin, a2) || geoVecEqual(origin, b2)) {
22025       return 1;
22026     }
22027     return geoVecNormalizedDot(a2, b2, origin);
22028   }
22029   function geoOrthoFilterDotProduct(dotp, epsilon3, lowerThreshold, upperThreshold, allowStraightAngles) {
22030     var val = Math.abs(dotp);
22031     if (val < epsilon3) {
22032       return 0;
22033     } else if (allowStraightAngles && Math.abs(val - 1) < epsilon3) {
22034       return 0;
22035     } else if (val < lowerThreshold || val > upperThreshold) {
22036       return dotp;
22037     } else {
22038       return null;
22039     }
22040   }
22041   function geoOrthoCalcScore(points, isClosed, epsilon3, threshold) {
22042     var score = 0;
22043     var first = isClosed ? 0 : 1;
22044     var last = isClosed ? points.length : points.length - 1;
22045     var coords = points.map(function(p2) {
22046       return p2.coord;
22047     });
22048     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
22049     var upperThreshold = Math.cos(threshold * Math.PI / 180);
22050     for (var i3 = first; i3 < last; i3++) {
22051       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22052       var origin = coords[i3];
22053       var b2 = coords[(i3 + 1) % coords.length];
22054       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold);
22055       if (dotp === null)
22056         continue;
22057       score = score + 2 * Math.min(Math.abs(dotp - 1), Math.min(Math.abs(dotp), Math.abs(dotp + 1)));
22058     }
22059     return score;
22060   }
22061   function geoOrthoMaxOffsetAngle(coords, isClosed, lessThan) {
22062     var max3 = -Infinity;
22063     var first = isClosed ? 0 : 1;
22064     var last = isClosed ? coords.length : coords.length - 1;
22065     for (var i3 = first; i3 < last; i3++) {
22066       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22067       var origin = coords[i3];
22068       var b2 = coords[(i3 + 1) % coords.length];
22069       var normalizedDotP = geoOrthoNormalizedDotProduct(a2, b2, origin);
22070       var angle2 = Math.acos(Math.abs(normalizedDotP)) * 180 / Math.PI;
22071       if (angle2 > 45)
22072         angle2 = 90 - angle2;
22073       if (angle2 >= lessThan)
22074         continue;
22075       if (angle2 > max3)
22076         max3 = angle2;
22077     }
22078     if (max3 === -Infinity)
22079       return null;
22080     return max3;
22081   }
22082   function geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles) {
22083     var score = null;
22084     var first = isClosed ? 0 : 1;
22085     var last = isClosed ? coords.length : coords.length - 1;
22086     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
22087     var upperThreshold = Math.cos(threshold * Math.PI / 180);
22088     for (var i3 = first; i3 < last; i3++) {
22089       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22090       var origin = coords[i3];
22091       var b2 = coords[(i3 + 1) % coords.length];
22092       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold, allowStraightAngles);
22093       if (dotp === null)
22094         continue;
22095       if (Math.abs(dotp) > 0)
22096         return 1;
22097       score = 0;
22098     }
22099     return score;
22100   }
22101
22102   // modules/util/array.js
22103   function utilArrayIdentical(a2, b2) {
22104     if (a2 === b2)
22105       return true;
22106     var i3 = a2.length;
22107     if (i3 !== b2.length)
22108       return false;
22109     while (i3--) {
22110       if (a2[i3] !== b2[i3])
22111         return false;
22112     }
22113     return true;
22114   }
22115   function utilArrayDifference(a2, b2) {
22116     var other = new Set(b2);
22117     return Array.from(new Set(a2)).filter(function(v2) {
22118       return !other.has(v2);
22119     });
22120   }
22121   function utilArrayIntersection(a2, b2) {
22122     var other = new Set(b2);
22123     return Array.from(new Set(a2)).filter(function(v2) {
22124       return other.has(v2);
22125     });
22126   }
22127   function utilArrayUnion(a2, b2) {
22128     var result = new Set(a2);
22129     b2.forEach(function(v2) {
22130       result.add(v2);
22131     });
22132     return Array.from(result);
22133   }
22134   function utilArrayUniq(a2) {
22135     return Array.from(new Set(a2));
22136   }
22137   function utilArrayChunk(a2, chunkSize) {
22138     if (!chunkSize || chunkSize < 0)
22139       return [a2.slice()];
22140     var result = new Array(Math.ceil(a2.length / chunkSize));
22141     return Array.from(result, function(item, i3) {
22142       return a2.slice(i3 * chunkSize, i3 * chunkSize + chunkSize);
22143     });
22144   }
22145   function utilArrayFlatten(a2) {
22146     return a2.reduce(function(acc, val) {
22147       return acc.concat(val);
22148     }, []);
22149   }
22150   function utilArrayGroupBy(a2, key) {
22151     return a2.reduce(function(acc, item) {
22152       var group = typeof key === "function" ? key(item) : item[key];
22153       (acc[group] = acc[group] || []).push(item);
22154       return acc;
22155     }, {});
22156   }
22157   function utilArrayUniqBy(a2, key) {
22158     var seen = /* @__PURE__ */ new Set();
22159     return a2.reduce(function(acc, item) {
22160       var val = typeof key === "function" ? key(item) : item[key];
22161       if (val && !seen.has(val)) {
22162         seen.add(val);
22163         acc.push(item);
22164       }
22165       return acc;
22166     }, []);
22167   }
22168
22169   // modules/util/util.js
22170   var import_diacritics = __toESM(require_diacritics());
22171
22172   // modules/util/svg_paths_rtl_fix.js
22173   var import_alif_toolkit = __toESM(require_lib());
22174   var rtlRegex = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u07BF\u08A0–\u08BF]/;
22175   function fixRTLTextForSvg(inputText) {
22176     var ret = "", rtlBuffer = [];
22177     var arabicRegex = /[\u0600-\u06FF]/g;
22178     var arabicDiacritics = /[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g;
22179     var arabicMath = /[\u0660-\u066C\u06F0-\u06F9]+/g;
22180     var thaanaVowel = /[\u07A6-\u07B0]/;
22181     var hebrewSign = /[\u0591-\u05bd\u05bf\u05c1-\u05c5\u05c7]/;
22182     if (arabicRegex.test(inputText)) {
22183       inputText = (0, import_alif_toolkit.WordShaper)(inputText);
22184     }
22185     for (var n3 = 0; n3 < inputText.length; n3++) {
22186       var c2 = inputText[n3];
22187       if (arabicMath.test(c2)) {
22188         ret += rtlBuffer.reverse().join("");
22189         rtlBuffer = [c2];
22190       } else {
22191         if (rtlBuffer.length && arabicMath.test(rtlBuffer[rtlBuffer.length - 1])) {
22192           ret += rtlBuffer.reverse().join("");
22193           rtlBuffer = [];
22194         }
22195         if ((thaanaVowel.test(c2) || hebrewSign.test(c2) || arabicDiacritics.test(c2)) && rtlBuffer.length) {
22196           rtlBuffer[rtlBuffer.length - 1] += c2;
22197         } else if (rtlRegex.test(c2) || c2.charCodeAt(0) >= 64336 && c2.charCodeAt(0) <= 65023 || c2.charCodeAt(0) >= 65136 && c2.charCodeAt(0) <= 65279) {
22198           rtlBuffer.push(c2);
22199         } else if (c2 === " " && rtlBuffer.length) {
22200           rtlBuffer = [rtlBuffer.reverse().join("") + " "];
22201         } else {
22202           ret += rtlBuffer.reverse().join("") + c2;
22203           rtlBuffer = [];
22204         }
22205       }
22206     }
22207     ret += rtlBuffer.reverse().join("");
22208     return ret;
22209   }
22210
22211   // modules/core/preferences.js
22212   var _storage;
22213   try {
22214     _storage = localStorage;
22215   } catch (e3) {
22216   }
22217   _storage = _storage || /* @__PURE__ */ (() => {
22218     let s2 = {};
22219     return {
22220       getItem: (k2) => s2[k2],
22221       setItem: (k2, v2) => s2[k2] = v2,
22222       removeItem: (k2) => delete s2[k2]
22223     };
22224   })();
22225   var _listeners = {};
22226   function corePreferences(k2, v2) {
22227     try {
22228       if (v2 === void 0)
22229         return _storage.getItem(k2);
22230       else if (v2 === null)
22231         _storage.removeItem(k2);
22232       else
22233         _storage.setItem(k2, v2);
22234       if (_listeners[k2]) {
22235         _listeners[k2].forEach((handler) => handler(v2));
22236       }
22237       return true;
22238     } catch (e3) {
22239       if (typeof console !== "undefined") {
22240         console.error("localStorage quota exceeded");
22241       }
22242       return false;
22243     }
22244   }
22245   corePreferences.onChange = function(k2, handler) {
22246     _listeners[k2] = _listeners[k2] || [];
22247     _listeners[k2].push(handler);
22248   };
22249
22250   // modules/core/file_fetcher.js
22251   var import_vparse = __toESM(require_vparse());
22252
22253   // config/id.js
22254   var presetsCdnUrl = "https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/";
22255   var ociCdnUrl = "https://cdn.jsdelivr.net/npm/osm-community-index@{version}/";
22256   var wmfSitematrixCdnUrl = "https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/";
22257   var nsiCdnUrl = "https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/";
22258   var defaultOsmApiConnections = {
22259     live: {
22260       url: "https://www.openstreetmap.org",
22261       apiUrl: "https://api.openstreetmap.org",
22262       client_id: "0tmNTmd0Jo1dQp4AUmMBLtGiD9YpMuXzHefitcuVStc",
22263       client_secret: "BTlNrNxIPitHdL4sP2clHw5KLoee9aKkA7dQbc0Bj7Q"
22264     },
22265     dev: {
22266       url: "https://api06.dev.openstreetmap.org",
22267       client_id: "Ee1wWJ6UlpERbF6BfTNOpwn0R8k_06mvMXdDUkeHMgw",
22268       client_secret: "OnfWFC-JkZNHyYdr_viNn_h_RTZXRslKcUxllOXqf5g"
22269     }
22270   };
22271   var osmApiConnections = [];
22272   if (false) {
22273     osmApiConnections.push({
22274       url: null,
22275       apiUrl: ENV__ID_API_CONNECTION_API_URL,
22276       client_id: null,
22277       client_secret: null
22278     });
22279   } else if (false) {
22280     osmApiConnections.push(defaultOsmApiConnections[null]);
22281   } else {
22282     osmApiConnections.push(defaultOsmApiConnections.live);
22283     osmApiConnections.push(defaultOsmApiConnections.dev);
22284   }
22285   var taginfoApiUrl = "https://taginfo.openstreetmap.org/api/4/";
22286   var nominatimApiUrl = "https://nominatim.openstreetmap.org/";
22287   var showDonationMessage = true;
22288
22289   // package.json
22290   var package_default = {
22291     name: "iD",
22292     version: "2.28.0",
22293     description: "A friendly editor for OpenStreetMap",
22294     main: "dist/iD.min.js",
22295     repository: "github:openstreetmap/iD",
22296     homepage: "https://github.com/openstreetmap/iD",
22297     bugs: "https://github.com/openstreetmap/iD/issues",
22298     keywords: [
22299       "editor",
22300       "openstreetmap"
22301     ],
22302     license: "ISC",
22303     scripts: {
22304       all: "run-s clean build dist",
22305       build: "run-s build:css build:data build:js",
22306       "build:css": "node scripts/build_css.js",
22307       "build:data": "shx mkdir -p dist/data && node scripts/build_data.js",
22308       "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",
22309       "build:js": "node config/esbuild.config.mjs",
22310       "build:js:watch": "node config/esbuild.config.mjs --watch",
22311       clean: "shx rm -f dist/esbuild.json dist/*.js dist/*.map dist/*.css dist/img/*.svg",
22312       dist: "run-p dist:**",
22313       "dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/",
22314       "dist:pannellum": "shx mkdir -p dist/pannellum && shx cp -R node_modules/pannellum/build/* dist/pannellum/",
22315       "dist:min": "node config/esbuild.config.min.mjs",
22316       "dist:svg:iD": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "iD-%s" --symbol-sprite dist/img/iD-sprite.svg "svg/iD-sprite/**/*.svg"',
22317       "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',
22318       "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
22319       "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',
22320       "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",
22321       "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",
22322       "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',
22323       "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',
22324       imagery: "node scripts/update_imagery.js",
22325       lint: "eslint config scripts test/spec modules --ext js,mjs",
22326       "lint:fix": "eslint scripts test/spec modules --fix",
22327       start: "run-s start:watch",
22328       "start:single-build": "run-p build:js start:server",
22329       "start:watch": "run-p build:js:watch start:server",
22330       "start:server": "node scripts/server.js",
22331       test: "npm-run-all -s lint build test:spec",
22332       "test:spec": "karma start config/karma.conf.js",
22333       translations: "node scripts/update_locales.js"
22334     },
22335     dependencies: {
22336       "@mapbox/geojson-area": "^0.2.2",
22337       "@mapbox/sexagesimal": "1.2.0",
22338       "@mapbox/vector-tile": "^1.3.1",
22339       "@rapideditor/country-coder": "~5.2.2",
22340       "@rapideditor/location-conflation": "~1.3.0",
22341       "@tmcw/togeojson": "^5.8.1",
22342       "@turf/bbox": "^6.0.0",
22343       "@turf/bbox-clip": "^6.0.0",
22344       "abortcontroller-polyfill": "^1.7.5",
22345       "aes-js": "^3.1.2",
22346       "alif-toolkit": "^1.2.9",
22347       "core-js-bundle": "^3.36.0",
22348       diacritics: "1.3.0",
22349       exifr: "^7.1.3",
22350       "fast-deep-equal": "~3.1.1",
22351       "fast-json-stable-stringify": "2.1.0",
22352       "lodash-es": "~4.17.15",
22353       marked: "~12.0.0",
22354       "node-diff3": "~3.1.0",
22355       "osm-auth": "~2.4.0",
22356       pannellum: "2.5.6",
22357       pbf: "^3.2.1",
22358       "polygon-clipping": "~0.15.7",
22359       rbush: "3.0.1",
22360       "whatwg-fetch": "^3.6.20",
22361       "which-polygon": "2.2.1"
22362     },
22363     devDependencies: {
22364       "@fortawesome/fontawesome-svg-core": "~6.5.1",
22365       "@fortawesome/free-brands-svg-icons": "~6.5.1",
22366       "@fortawesome/free-regular-svg-icons": "~6.5.1",
22367       "@fortawesome/free-solid-svg-icons": "~6.5.1",
22368       "@mapbox/maki": "^8.0.1",
22369       "@openstreetmap/id-tagging-schema": "^6.6.0",
22370       "@rapideditor/mapillary_sprite_source": "^1.8.0",
22371       "@rapideditor/temaki": "^5.7.0",
22372       "@transifex/api": "^7.1.0",
22373       autoprefixer: "^10.4.17",
22374       browserslist: "^4.23.0",
22375       "browserslist-to-esbuild": "^2.1.1",
22376       chai: "^4.4.1",
22377       chalk: "^4.1.2",
22378       "cldr-core": "^44.0.1",
22379       "cldr-localenames-full": "^44.1.0",
22380       "concat-files": "^0.1.1",
22381       d3: "~7.8.5",
22382       dotenv: "^16.4.5",
22383       "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
22384       esbuild: "^0.20.1",
22385       "esbuild-visualizer": "^0.6.0",
22386       eslint: "^8.57.0",
22387       "fetch-mock": "^9.11.0",
22388       gaze: "^1.1.3",
22389       glob: "^10.3.10",
22390       happen: "^0.3.2",
22391       "js-yaml": "^4.0.0",
22392       "json-stringify-pretty-compact": "^3.0.0",
22393       karma: "^6.4.3",
22394       "karma-chrome-launcher": "^3.2.0",
22395       "karma-coverage": "2.1.1",
22396       "karma-mocha": "^2.0.1",
22397       "karma-remap-istanbul": "^0.6.0",
22398       "mapillary-js": "4.1.2",
22399       minimist: "^1.2.8",
22400       mocha: "^10.3.0",
22401       "name-suggestion-index": "~6.0",
22402       "node-fetch": "^2.7.0",
22403       "npm-run-all": "^4.0.0",
22404       "osm-community-index": "~5.6.2",
22405       postcss: "^8.4.35",
22406       "postcss-selector-prepend": "^0.5.0",
22407       shelljs: "^0.8.0",
22408       shx: "^0.3.0",
22409       sinon: "^11.1.2",
22410       "sinon-chai": "^3.7.0",
22411       smash: "0.0",
22412       "static-server": "^2.2.1",
22413       "svg-sprite": "2.0.2",
22414       vparse: "~1.1.0"
22415     },
22416     engines: {
22417       node: ">=18"
22418     },
22419     browserslist: [
22420       "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions"
22421     ]
22422   };
22423
22424   // modules/core/file_fetcher.js
22425   var _mainFileFetcher = coreFileFetcher();
22426   function coreFileFetcher() {
22427     const ociVersion = package_default.dependencies["osm-community-index"] || package_default.devDependencies["osm-community-index"];
22428     const v2 = (0, import_vparse.default)(ociVersion);
22429     const ociVersionMinor = "".concat(v2.major, ".").concat(v2.minor);
22430     const presetsVersion = package_default.devDependencies["@openstreetmap/id-tagging-schema"];
22431     let _this = {};
22432     let _inflight4 = {};
22433     let _fileMap = {
22434       "address_formats": "data/address_formats.min.json",
22435       "imagery": "data/imagery.min.json",
22436       "intro_graph": "data/intro_graph.min.json",
22437       "keepRight": "data/keepRight.min.json",
22438       "languages": "data/languages.min.json",
22439       "locales": "locales/index.min.json",
22440       "phone_formats": "data/phone_formats.min.json",
22441       "qa_data": "data/qa_data.min.json",
22442       "shortcuts": "data/shortcuts.min.json",
22443       "territory_languages": "data/territory_languages.min.json",
22444       "oci_defaults": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/defaults.min.json",
22445       "oci_features": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/featureCollection.min.json",
22446       "oci_resources": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/resources.min.json",
22447       "presets_package": presetsCdnUrl.replace("{presets_version}", presetsVersion) + "package.json",
22448       "deprecated": presetsCdnUrl + "dist/deprecated.min.json",
22449       "discarded": presetsCdnUrl + "dist/discarded.min.json",
22450       "preset_categories": presetsCdnUrl + "dist/preset_categories.min.json",
22451       "preset_defaults": presetsCdnUrl + "dist/preset_defaults.min.json",
22452       "preset_fields": presetsCdnUrl + "dist/fields.min.json",
22453       "preset_presets": presetsCdnUrl + "dist/presets.min.json",
22454       "wmf_sitematrix": wmfSitematrixCdnUrl.replace("{version}", "0.1") + "wikipedia.min.json"
22455     };
22456     let _cachedData = {};
22457     _this.cache = () => _cachedData;
22458     _this.get = (which) => {
22459       if (_cachedData[which]) {
22460         return Promise.resolve(_cachedData[which]);
22461       }
22462       const file = _fileMap[which];
22463       const url = file && _this.asset(file);
22464       if (!url) {
22465         return Promise.reject('Unknown data file for "'.concat(which, '"'));
22466       }
22467       if (url.includes("{presets_version}")) {
22468         return _this.get("presets_package").then((result) => {
22469           const presetsVersion2 = result.version;
22470           return getUrl(url.replace("{presets_version}", presetsVersion2), which);
22471         });
22472       } else {
22473         return getUrl(url);
22474       }
22475     };
22476     function getUrl(url, which) {
22477       let prom = _inflight4[url];
22478       if (!prom) {
22479         _inflight4[url] = prom = fetch(url).then((response) => {
22480           if (!response.ok || !response.json) {
22481             throw new Error(response.status + " " + response.statusText);
22482           }
22483           if (response.status === 204 || response.status === 205)
22484             return;
22485           return response.json();
22486         }).then((result) => {
22487           delete _inflight4[url];
22488           if (!result) {
22489             throw new Error('No data loaded for "'.concat(which, '"'));
22490           }
22491           _cachedData[which] = result;
22492           return result;
22493         }).catch((err) => {
22494           delete _inflight4[url];
22495           throw err;
22496         });
22497       }
22498       return prom;
22499     }
22500     _this.fileMap = function(val) {
22501       if (!arguments.length)
22502         return _fileMap;
22503       _fileMap = val;
22504       return _this;
22505     };
22506     let _assetPath = "";
22507     _this.assetPath = function(val) {
22508       if (!arguments.length)
22509         return _assetPath;
22510       _assetPath = val;
22511       return _this;
22512     };
22513     let _assetMap = {};
22514     _this.assetMap = function(val) {
22515       if (!arguments.length)
22516         return _assetMap;
22517       _assetMap = val;
22518       return _this;
22519     };
22520     _this.asset = (val) => {
22521       if (/^http(s)?:\/\//i.test(val))
22522         return val;
22523       const filename = _assetPath + val;
22524       return _assetMap[filename] || filename;
22525     };
22526     return _this;
22527   }
22528
22529   // node_modules/@rapideditor/country-coder/dist/country-coder.mjs
22530   var import_which_polygon = __toESM(require_which_polygon(), 1);
22531   var borders_default = { type: "FeatureCollection", features: [
22532     { 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]]]] } },
22533     { 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]]]] } },
22534     { 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]]]] } },
22535     { 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]]]] } },
22536     { 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]]]] } },
22537     { 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]]]] } },
22538     { 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]]]] } },
22539     { 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]]]] } },
22540     { 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]]]] } },
22541     { 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]]]] } },
22542     { 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]]]] } },
22543     { 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]]]] } },
22544     { 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]]]] } },
22545     { 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]]]] } },
22546     { 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]]]] } },
22547     { 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]]]] } },
22548     { 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]]]] } },
22549     { 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]]]] } },
22550     { 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]]]] } },
22551     { type: "Feature", properties: { wikidata: "Q12837", nameEn: "Iberia", level: "sharedLandform" }, geometry: null },
22552     { 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]]]] } },
22553     { 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]]]] } },
22554     { type: "Feature", properties: { wikidata: "Q22890", nameEn: "Ireland", level: "sharedLandform" }, geometry: null },
22555     { type: "Feature", properties: { wikidata: "Q23666", nameEn: "Great Britain", country: "GB", level: "sharedLandform" }, geometry: null },
22556     { 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.91299, 35.07579], [33.90247, 35.07686], [33.89485, 35.06873], [33.88367, 35.07877], [33.85261, 35.0574], [33.8355, 35.05777], [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.85621, 34.98956], [33.83505, 34.98108], [33.84811, 34.97075], [33.86432, 34.97592], [33.90075, 34.96623], [33.98684, 34.76642], [35.48515, 34.70851], [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]]]] } },
22557     { 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]]]] } },
22558     { 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]]]] } },
22559     { 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]]]] } },
22560     { 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]]]] } },
22561     { 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]]]] } },
22562     { 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]]]] } },
22563     { 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]]]] } },
22564     { 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]]]] } },
22565     { 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]]]] } },
22566     { 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]]]] } },
22567     { 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]]]] } },
22568     { type: "Feature", properties: { wikidata: "Q35657", nameEn: "US States", country: "US", level: "subcountryGroup" }, geometry: null },
22569     { type: "Feature", properties: { wikidata: "Q36117", nameEn: "Borneo", level: "sharedLandform" }, geometry: null },
22570     { 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]]]] } },
22571     { type: "Feature", properties: { wikidata: "Q37362", nameEn: "Akrotiri and Dhekelia", aliases: ["SBA"], country: "GB" }, geometry: null },
22572     { 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]]]] } },
22573     { 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]]]] } },
22574     { 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]]]] } },
22575     { 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]]]] } },
22576     { 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]]]] } },
22577     { 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]]]] } },
22578     { type: "Feature", properties: { wikidata: "Q46395", nameEn: "British Overseas Territories", aliases: ["BOTS", "UKOTS"], country: "GB", level: "subcountryGroup" }, geometry: null },
22579     { 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]]]] } },
22580     { 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]]]] } },
22581     { 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]]]] } },
22582     { 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]]]] } },
22583     { type: "Feature", properties: { wikidata: "Q105472", nameEn: "Macaronesia", level: "sharedLandform" }, geometry: null },
22584     { 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]]]] } },
22585     { 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]]]] } },
22586     { 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]]]] } },
22587     { 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]]]] } },
22588     { 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]]]] } },
22589     { 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]]]] } },
22590     { 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]]]] } },
22591     { 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]]]] } },
22592     { 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]]]] } },
22593     { 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]]]] } },
22594     { type: "Feature", properties: { wikidata: "Q153732", nameEn: "Mariana Islands", level: "sharedLandform" }, geometry: null },
22595     { 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]]]] } },
22596     { 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]]]] } },
22597     { type: "Feature", properties: { wikidata: "Q185086", nameEn: "Crown Dependencies", country: "GB", level: "subcountryGroup" }, geometry: null },
22598     { 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]]]] } },
22599     { type: "Feature", properties: { wikidata: "Q191011", nameEn: "Plazas de soberan\xEDa", country: "ES" }, geometry: null },
22600     { 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]]]] } },
22601     { 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]]]] } },
22602     { 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]]]] } },
22603     { 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]]]] } },
22604     { 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]]]] } },
22605     { type: "Feature", properties: { wikidata: "Q644636", nameEn: "Cyprus", level: "sharedLandform" }, geometry: null },
22606     { type: "Feature", properties: { wikidata: "Q851132", nameEn: "New Zealand Outlying Islands", country: "NZ", level: "subcountryGroup" }, geometry: null },
22607     { 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]]]] } },
22608     { 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]]]] } },
22609     { 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]]]] } },
22610     { 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]]]] } },
22611     { type: "Feature", properties: { wikidata: "Q1352230", nameEn: "US Territories", country: "US", level: "subcountryGroup" }, geometry: null },
22612     { type: "Feature", properties: { wikidata: "Q1451600", nameEn: "Overseas Countries and Territories of the EU", aliases: ["OCT"], level: "subunion" }, geometry: null },
22613     { 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]]]] } },
22614     { 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]]]] } },
22615     { 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]]]] } },
22616     { 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]]]] } },
22617     { 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]]]] } },
22618     { 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]]]] } },
22619     { 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]]]] } },
22620     { 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]]]] } },
22621     { type: "Feature", properties: { wikidata: "Q2914565", nameEn: "Autonomous Regions of Portugal", country: "PT", level: "subcountryGroup" }, geometry: null },
22622     { 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]]]] } },
22623     { 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]]]] } },
22624     { type: "Feature", properties: { wikidata: "Q3320166", nameEn: "Outermost Regions of the EU", aliases: ["OMR"], level: "subunion" }, geometry: null },
22625     { type: "Feature", properties: { wikidata: "Q3336843", nameEn: "Countries of the United Kingdom", aliases: ["GB-UKM"], country: "GB", level: "subcountryGroup" }, geometry: null },
22626     { 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]]]] } },
22627     { 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.95891, 34.62919], [32.95323, 34.64075], [32.95471, 34.64528], [32.94976, 34.65204], [32.94796, 34.6587], [32.95325, 34.66462], [32.97079, 34.66112], [32.97736, 34.65277], [32.99014, 34.65518], [32.98668, 34.67268], [32.99135, 34.68061], [32.95539, 34.68471], [32.94683, 34.67907], [32.94379, 34.67111], [32.93693, 34.67027], [32.93449, 34.66241], [32.92807, 34.66736], [32.93043, 34.67091], [32.91398, 34.67343], [32.9068, 34.66102], [32.86167, 34.68734], [32.86014, 34.70585]]]] } },
22628     { 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.90075, 34.96623], [33.86432, 34.97592], [33.84811, 34.97075], [33.83505, 34.98108], [33.85621, 34.98956], [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.88367, 35.07877], [33.89485, 35.06873], [33.90247, 35.07686], [33.91299, 35.07579], [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]]]] } },
22629     { 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]]]] } },
22630     { 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]]]] } },
22631     { 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]]]] } },
22632     { type: "Feature", properties: { m49: "001", wikidata: "Q2", nameEn: "World", aliases: ["Earth", "Planet"], level: "world" }, geometry: null },
22633     { type: "Feature", properties: { m49: "002", wikidata: "Q15", nameEn: "Africa", level: "region" }, geometry: null },
22634     { type: "Feature", properties: { m49: "003", wikidata: "Q49", nameEn: "North America", level: "subregion" }, geometry: null },
22635     { type: "Feature", properties: { m49: "005", wikidata: "Q18", nameEn: "South America", level: "intermediateRegion" }, geometry: null },
22636     { type: "Feature", properties: { m49: "009", wikidata: "Q538", nameEn: "Oceania", level: "region" }, geometry: null },
22637     { type: "Feature", properties: { m49: "011", wikidata: "Q4412", nameEn: "Western Africa", level: "intermediateRegion" }, geometry: null },
22638     { type: "Feature", properties: { m49: "013", wikidata: "Q27611", nameEn: "Central America", level: "intermediateRegion" }, geometry: null },
22639     { type: "Feature", properties: { m49: "014", wikidata: "Q27407", nameEn: "Eastern Africa", level: "intermediateRegion" }, geometry: null },
22640     { type: "Feature", properties: { m49: "015", wikidata: "Q27381", nameEn: "Northern Africa", level: "subregion" }, geometry: null },
22641     { type: "Feature", properties: { m49: "017", wikidata: "Q27433", nameEn: "Middle Africa", level: "intermediateRegion" }, geometry: null },
22642     { type: "Feature", properties: { m49: "018", wikidata: "Q27394", nameEn: "Southern Africa", level: "intermediateRegion" }, geometry: null },
22643     { type: "Feature", properties: { m49: "019", wikidata: "Q828", nameEn: "Americas", level: "region" }, geometry: null },
22644     { type: "Feature", properties: { m49: "021", wikidata: "Q2017699", nameEn: "Northern America", level: "subregion" }, geometry: null },
22645     { type: "Feature", properties: { m49: "029", wikidata: "Q664609", nameEn: "Caribbean", level: "intermediateRegion" }, geometry: null },
22646     { type: "Feature", properties: { m49: "030", wikidata: "Q27231", nameEn: "Eastern Asia", level: "subregion" }, geometry: null },
22647     { type: "Feature", properties: { m49: "034", wikidata: "Q771405", nameEn: "Southern Asia", level: "subregion" }, geometry: null },
22648     { type: "Feature", properties: { m49: "035", wikidata: "Q11708", nameEn: "South-eastern Asia", level: "subregion" }, geometry: null },
22649     { type: "Feature", properties: { m49: "039", wikidata: "Q27449", nameEn: "Southern Europe", level: "subregion" }, geometry: null },
22650     { type: "Feature", properties: { m49: "053", wikidata: "Q45256", nameEn: "Australia and New Zealand", aliases: ["Australasia"], level: "subregion" }, geometry: null },
22651     { type: "Feature", properties: { m49: "054", wikidata: "Q37394", nameEn: "Melanesia", level: "subregion" }, geometry: null },
22652     { type: "Feature", properties: { m49: "057", wikidata: "Q3359409", nameEn: "Micronesia", level: "subregion" }, geometry: null },
22653     { type: "Feature", properties: { m49: "061", wikidata: "Q35942", nameEn: "Polynesia", level: "subregion" }, geometry: null },
22654     { type: "Feature", properties: { m49: "142", wikidata: "Q48", nameEn: "Asia", level: "region" }, geometry: null },
22655     { type: "Feature", properties: { m49: "143", wikidata: "Q27275", nameEn: "Central Asia", level: "subregion" }, geometry: null },
22656     { type: "Feature", properties: { m49: "145", wikidata: "Q27293", nameEn: "Western Asia", level: "subregion" }, geometry: null },
22657     { type: "Feature", properties: { m49: "150", wikidata: "Q46", nameEn: "Europe", level: "region" }, geometry: null },
22658     { type: "Feature", properties: { m49: "151", wikidata: "Q27468", nameEn: "Eastern Europe", level: "subregion" }, geometry: null },
22659     { type: "Feature", properties: { m49: "154", wikidata: "Q27479", nameEn: "Northern Europe", level: "subregion" }, geometry: null },
22660     { type: "Feature", properties: { m49: "155", wikidata: "Q27496", nameEn: "Western Europe", level: "subregion" }, geometry: null },
22661     { type: "Feature", properties: { m49: "202", wikidata: "Q132959", nameEn: "Sub-Saharan Africa", level: "subregion" }, geometry: null },
22662     { type: "Feature", properties: { m49: "419", wikidata: "Q72829598", nameEn: "Latin America and the Caribbean", level: "subregion" }, geometry: null },
22663     { type: "Feature", properties: { m49: "680", wikidata: "Q3405693", nameEn: "Sark", 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.65349, 49.15373], [-2.09454, 49.46288], [-2.36485, 49.48223]]]] } },
22664     { type: "Feature", properties: { m49: "830", wikidata: "Q42314", nameEn: "Channel Islands", level: "intermediateRegion" }, geometry: null },
22665     { 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]]]] } },
22666     { 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]]]] } },
22667     { 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]]]] } },
22668     { 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]]]] } },
22669     { 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]]]] } },
22670     { 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]]]] } },
22671     { 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]]]] } },
22672     { 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]]]] } },
22673     { 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]]]] } },
22674     { 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]]]] } },
22675     { 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]]]] } },
22676     { 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]]]] } },
22677     { 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]]]] } },
22678     { type: "Feature", properties: { iso1A2: "AU", iso1A3: "AUS", iso1N3: "036", wikidata: "Q408", nameEn: "Australia" }, geometry: null },
22679     { 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]]]] } },
22680     { 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]]]] } },
22681     { 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]]]] } },
22682     { 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]]]] } },
22683     { 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]]]] } },
22684     { 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]]]] } },
22685     { 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]]]] } },
22686     { 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]]]] } },
22687     { 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]]]] } },
22688     { 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]]]] } },
22689     { 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]]]] } },
22690     { 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]]]] } },
22691     { 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]]]] } },
22692     { 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]]]] } },
22693     { 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]]]] } },
22694     { 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]]]] } },
22695     { type: "Feature", properties: { iso1A2: "BQ", iso1A3: "BES", iso1N3: "535", wikidata: "Q27561", nameEn: "Caribbean Netherlands", country: "NL" }, geometry: null },
22696     { 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]]]] } },
22697     { 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]]]] } },
22698     { 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]]]] } },
22699     { 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]]]] } },
22700     { 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]]]] } },
22701     { 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]]]] } },
22702     { 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]]]] } },
22703     { 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]]]] } },
22704     { 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]]]] } },
22705     { 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]]]] } },
22706     { 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]]]] } },
22707     { 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]]]] } },
22708     { type: "Feature", 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]]]] }, properties: { iso1A2: "CH", iso1A3: "CHE", iso1N3: "756", wikidata: "Q39", nameEn: "Switzerland", groups: ["155", "150", "UN"], callingCodes: ["41"] } },
22709     { 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]]]] } },
22710     { 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]]]] } },
22711     { 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]]]] } },
22712     { 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]]]] } },
22713     { type: "Feature", properties: { iso1A2: "CN", iso1A3: "CHN", iso1N3: "156", wikidata: "Q148", nameEn: "People's Republic of China" }, geometry: null },
22714     { 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]]]] } },
22715     { 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]]]] } },
22716     { 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]]]] } },
22717     { 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]]]] } },
22718     { 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]]]] } },
22719     { 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]]]] } },
22720     { 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]]]] } },
22721     { 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.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.92807, 34.66736], [32.93449, 34.66241], [32.93693, 34.67027], [32.94379, 34.67111], [32.94683, 34.67907], [32.95539, 34.68471], [32.99135, 34.68061], [32.98668, 34.67268], [32.99014, 34.65518], [32.97736, 34.65277], [32.97079, 34.66112], [32.95325, 34.66462], [32.94796, 34.6587], [32.94976, 34.65204], [32.95471, 34.64528], [32.95323, 34.64075], [32.95891, 34.62919], [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], [32.46489, 35.48584]]], [[[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.74144, 35.01053]]], [[[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.77312, 34.9976]]]] } },
22722     { 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]]]] } },
22723     { 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]]]] } },
22724     { 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]]]] } },
22725     { 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]]]] } },
22726     { type: "Feature", properties: { iso1A2: "DK", iso1A3: "DNK", iso1N3: "208", wikidata: "Q756617", nameEn: "Kingdom of Denmark" }, geometry: null },
22727     { 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]]]] } },
22728     { 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]]]] } },
22729     { 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]]]] } },
22730     { type: "Feature", properties: { iso1A2: "EA", wikidata: "Q28868874", nameEn: "Ceuta, Melilla", country: "ES", level: "territory", isoStatus: "excRes" }, geometry: null },
22731     { type: "Feature", properties: { iso1A2: "EC", iso1A3: "ECU", iso1N3: "218", wikidata: "Q736", nameEn: "Ecuador" }, geometry: null },
22732     { 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]]]] } },
22733     { 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]]]] } },
22734     { 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]]]] } },
22735     { 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]]]] } },
22736     { type: "Feature", properties: { iso1A2: "ES", iso1A3: "ESP", iso1N3: "724", wikidata: "Q29", nameEn: "Spain" }, geometry: null },
22737     { 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]]]] } },
22738     { type: "Feature", properties: { iso1A2: "EU", iso1A3: "EUE", wikidata: "Q458", nameEn: "European Union", level: "union", isoStatus: "excRes" }, geometry: null },
22739     { type: "Feature", properties: { iso1A2: "FI", iso1A3: "FIN", iso1N3: "246", wikidata: "Q33", nameEn: "Finland", aliases: ["SF"] }, geometry: null },
22740     { 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]]]] } },
22741     { 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]]]] } },
22742     { 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]]]] } },
22743     { 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]]]] } },
22744     { type: "Feature", properties: { iso1A2: "FR", iso1A3: "FRA", iso1N3: "250", wikidata: "Q142", nameEn: "France" }, geometry: null },
22745     { 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]]]] } },
22746     { 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]]]] } },
22747     { type: "Feature", properties: { iso1A2: "GB", iso1A3: "GBR", iso1N3: "826", wikidata: "Q145", ccTLD: ".uk", nameEn: "United Kingdom", aliases: ["UK"] }, geometry: null },
22748     { 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]]]] } },
22749     { 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]]]] } },
22750     { 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]]]] } },
22751     { type: "Feature", properties: { iso1A2: "GG", iso1A3: "GGY", iso1N3: "831", wikidata: "Q25230", nameEn: "Bailiwick of Guernsey", country: "GB" }, geometry: null },
22752     { 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]]]] } },
22753     { 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]]]] } },
22754     { 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]]]] } },
22755     { 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]]]] } },
22756     { 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]]]] } },
22757     { 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]]]] } },
22758     { 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]]]] } },
22759     { 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]]]] } },
22760     { 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]]]] } },
22761     { 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]]]] } },
22762     { 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]]]] } },
22763     { 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]]]] } },
22764     { 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]]]] } },
22765     { 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]]]] } },
22766     { 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]]]] } },
22767     { 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]]]] } },
22768     { 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]]]] } },
22769     { 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]]]] } },
22770     { 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]]]] } },
22771     { 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]]]] } },
22772     { type: "Feature", properties: { iso1A2: "ID", iso1A3: "IDN", iso1N3: "360", wikidata: "Q252", nameEn: "Indonesia", aliases: ["RI"] }, geometry: null },
22773     { type: "Feature", 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]]]] }, properties: { iso1A2: "IE", iso1A3: "IRL", iso1N3: "372", wikidata: "Q27", nameEn: "Republic of Ireland", groups: ["EU", "Q22890", "154", "150", "UN"], driveSide: "left", callingCodes: ["353"] } },
22774     { 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]]]] } },
22775     { 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]]]] } },
22776     { type: "Feature", properties: { iso1A2: "IN", iso1A3: "IND", iso1N3: "356", wikidata: "Q668", nameEn: "India" }, geometry: null },
22777     { type: "Feature", properties: { iso1A2: "IO", iso1A3: "IOT", iso1N3: "086", wikidata: "Q43448", nameEn: "British Indian Ocean Territory", country: "GB" }, geometry: null },
22778     { 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]]]] } },
22779     { 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]]]] } },
22780     { 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]]]] } },
22781     { 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]]]] } },
22782     { 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]]]] } },
22783     { 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]]]] } },
22784     { 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]]]] } },
22785     { 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]]]] } },
22786     { 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]]]] } },
22787     { 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]]]] } },
22788     { 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]]]] } },
22789     { 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]]]] } },
22790     { 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]]]] } },
22791     { 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]]]] } },
22792     { 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]]]] } },
22793     { 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]]]] } },
22794     { 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]]]] } },
22795     { 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]]]] } },
22796     { 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]]]] } },
22797     { 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]]]] } },
22798     { 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]]]] } },
22799     { 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]]]] } },
22800     { 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]]]] } },
22801     { 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]]]] } },
22802     { 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]]]] } },
22803     { 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]]]] } },
22804     { 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]]]] } },
22805     { 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]]]] } },
22806     { 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]]]] } },
22807     { 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]]]] } },
22808     { 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]]]] } },
22809     { 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]]]] } },
22810     { 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]]]] } },
22811     { 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]]]] } },
22812     { 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]]]] } },
22813     { 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]]]] } },
22814     { 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]]]] } },
22815     { 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]]]] } },
22816     { 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]]]] } },
22817     { 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]]]] } },
22818     { 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]]]] } },
22819     { 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]]]] } },
22820     { 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]]]] } },
22821     { 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]]]] } },
22822     { 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]]]] } },
22823     { 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]]]] } },
22824     { 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]]]] } },
22825     { 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]]]] } },
22826     { 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]]]] } },
22827     { 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]]]] } },
22828     { 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]]]] } },
22829     { type: "Feature", properties: { iso1A2: "MY", iso1A3: "MYS", iso1N3: "458", wikidata: "Q833", nameEn: "Malaysia" }, geometry: null },
22830     { 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]]]] } },
22831     { 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]]]] } },
22832     { 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]]]] } },
22833     { 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]]]] } },
22834     { 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]]]] } },
22835     { 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]]]] } },
22836     { 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]]]] } },
22837     { type: "Feature", properties: { iso1A2: "NL", iso1A3: "NLD", iso1N3: "528", wikidata: "Q29999", nameEn: "Kingdom of the Netherlands" }, geometry: null },
22838     { type: "Feature", properties: { iso1A2: "NO", iso1A3: "NOR", iso1N3: "578", wikidata: "Q20", nameEn: "Norway" }, geometry: null },
22839     { 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]]]] } },
22840     { 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]]]] } },
22841     { 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]]]] } },
22842     { type: "Feature", properties: { iso1A2: "NZ", iso1A3: "NZL", iso1N3: "554", wikidata: "Q664", nameEn: "New Zealand" }, geometry: null },
22843     { 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]]]] } },
22844     { 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]]]] } },
22845     { 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]]]] } },
22846     { 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]]]] } },
22847     { 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]]]] } },
22848     { 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]]]] } },
22849     { 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]]]] } },
22850     { 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]]]] } },
22851     { 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]]]] } },
22852     { 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]]]] } },
22853     { 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]]]] } },
22854     { type: "Feature", properties: { iso1A2: "PS", iso1A3: "PSE", iso1N3: "275", wikidata: "Q219060", nameEn: "Palestine" }, geometry: null },
22855     { type: "Feature", properties: { iso1A2: "PT", iso1A3: "PRT", iso1N3: "620", wikidata: "Q45", nameEn: "Portugal" }, geometry: null },
22856     { 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]]]] } },
22857     { 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]]]] } },
22858     { 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]]]] } },
22859     { 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]]]] } },
22860     { 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]]]] } },
22861     { 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]]]] } },
22862     { type: "Feature", properties: { iso1A2: "RU", iso1A3: "RUS", iso1N3: "643", wikidata: "Q159", nameEn: "Russia" }, geometry: null },
22863     { 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]]]] } },
22864     { 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]]]] } },
22865     { 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]]]] } },
22866     { 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]]]] } },
22867     { 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]]]] } },
22868     { 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]]]] } },
22869     { 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]]]] } },
22870     { type: "Feature", properties: { iso1A2: "SH", iso1A3: "SHN", iso1N3: "654", wikidata: "Q192184", nameEn: "Saint Helena, Ascension and Tristan da Cunha", country: "GB" }, geometry: null },
22871     { 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]]]] } },
22872     { type: "Feature", properties: { iso1A2: "SJ", iso1A3: "SJM", iso1N3: "744", wikidata: "Q842829", nameEn: "Svalbard and Jan Mayen", country: "NO" }, geometry: null },
22873     { 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]]]] } },
22874     { 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]]]] } },
22875     { 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]]]] } },
22876     { 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]]]] } },
22877     { 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]]]] } },
22878     { 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]]]] } },
22879     { 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]]]] } },
22880     { 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]]]] } },
22881     { 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]]]] } },
22882     { 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]]]] } },
22883     { 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]]]] } },
22884     { 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]]]] } },
22885     { 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]]]] } },
22886     { 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]]]] } },
22887     { 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]]]] } },
22888     { type: "Feature", properties: { iso1A2: "TF", iso1A3: "ATF", iso1N3: "260", wikidata: "Q129003", nameEn: "French Southern Territories", country: "FR", groups: ["EU", "UN"] }, geometry: null },
22889     { 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]]]] } },
22890     { 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]]]] } },
22891     { 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]]]] } },
22892     { 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]]]] } },
22893     { 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]]]] } },
22894     { 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]]]] } },
22895     { 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]]]] } },
22896     { 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]]]] } },
22897     { 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]]]] } },
22898     { 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]]]] } },
22899     { 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]]]] } },
22900     { 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]]]] } },
22901     { 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]]]] } },
22902     { 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]]]] } },
22903     { 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]]]] } },
22904     { type: "Feature", properties: { iso1A2: "UM", iso1A3: "UMI", iso1N3: "581", wikidata: "Q16645", nameEn: "United States Minor Outlying Islands", country: "US" }, geometry: null },
22905     { type: "Feature", properties: { iso1A2: "UN", wikidata: "Q1065", nameEn: "United Nations", level: "unitedNations", isoStatus: "excRes" }, geometry: null },
22906     { type: "Feature", properties: { iso1A2: "US", iso1A3: "USA", iso1N3: "840", wikidata: "Q30", nameEn: "United States of America" }, geometry: null },
22907     { 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]]]] } },
22908     { 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]]]] } },
22909     { 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]]]] } },
22910     { 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]]]] } },
22911     { 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]]]] } },
22912     { 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]]]] } },
22913     { 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]]]] } },
22914     { 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]]]] } },
22915     { 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]]]] } },
22916     { 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]]]] } },
22917     { 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]]]] } },
22918     { 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]]]] } },
22919     { 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]]]] } },
22920     { 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]]]] } },
22921     { 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]]]] } },
22922     { 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]]]] } },
22923     { 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]]]] } }
22924   ] };
22925   var borders = borders_default;
22926   var _whichPolygon = {};
22927   var _featuresByCode = {};
22928   var idFilterRegex = /(?=(?!^(and|the|of|el|la|de)$))(\b(and|the|of|el|la|de)\b)|[-_ .,'()&[\]/]/gi;
22929   function canonicalID(id2) {
22930     const s2 = id2 || "";
22931     if (s2.charAt(0) === ".") {
22932       return s2.toUpperCase();
22933     } else {
22934       return s2.replace(idFilterRegex, "").toUpperCase();
22935     }
22936   }
22937   var levels = [
22938     "subterritory",
22939     "territory",
22940     "subcountryGroup",
22941     "country",
22942     "sharedLandform",
22943     "intermediateRegion",
22944     "subregion",
22945     "region",
22946     "subunion",
22947     "union",
22948     "unitedNations",
22949     "world"
22950   ];
22951   loadDerivedDataAndCaches(borders);
22952   function loadDerivedDataAndCaches(borders2) {
22953     const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"];
22954     let geometryFeatures = [];
22955     for (const feature22 of borders2.features) {
22956       const props = feature22.properties;
22957       props.id = props.iso1A2 || props.m49 || props.wikidata;
22958       loadM49(feature22);
22959       loadTLD(feature22);
22960       loadIsoStatus(feature22);
22961       loadLevel(feature22);
22962       loadGroups(feature22);
22963       loadFlag(feature22);
22964       cacheFeatureByIDs(feature22);
22965       if (feature22.geometry) {
22966         geometryFeatures.push(feature22);
22967       }
22968     }
22969     for (const feature22 of borders2.features) {
22970       feature22.properties.groups = feature22.properties.groups.map((groupID) => {
22971         return _featuresByCode[groupID].properties.id;
22972       });
22973       loadMembersForGroupsOf(feature22);
22974     }
22975     for (const feature22 of borders2.features) {
22976       loadRoadSpeedUnit(feature22);
22977       loadRoadHeightUnit(feature22);
22978       loadDriveSide(feature22);
22979       loadCallingCodes(feature22);
22980       loadGroupGroups(feature22);
22981     }
22982     for (const feature22 of borders2.features) {
22983       feature22.properties.groups.sort((groupID1, groupID2) => {
22984         return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level);
22985       });
22986       if (feature22.properties.members) {
22987         feature22.properties.members.sort((id1, id2) => {
22988           const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level);
22989           if (diff === 0) {
22990             return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]);
22991           }
22992           return diff;
22993         });
22994       }
22995     }
22996     const geometryOnlyCollection = {
22997       type: "FeatureCollection",
22998       features: geometryFeatures
22999     };
23000     _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection);
23001     function loadGroups(feature22) {
23002       const props = feature22.properties;
23003       if (!props.groups) {
23004         props.groups = [];
23005       }
23006       if (feature22.geometry && props.country) {
23007         props.groups.push(props.country);
23008       }
23009       if (props.m49 !== "001") {
23010         props.groups.push("001");
23011       }
23012     }
23013     function loadM49(feature22) {
23014       const props = feature22.properties;
23015       if (!props.m49 && props.iso1N3) {
23016         props.m49 = props.iso1N3;
23017       }
23018     }
23019     function loadTLD(feature22) {
23020       const props = feature22.properties;
23021       if (props.level === "unitedNations")
23022         return;
23023       if (!props.ccTLD && props.iso1A2) {
23024         props.ccTLD = "." + props.iso1A2.toLowerCase();
23025       }
23026     }
23027     function loadIsoStatus(feature22) {
23028       const props = feature22.properties;
23029       if (!props.isoStatus && props.iso1A2) {
23030         props.isoStatus = "official";
23031       }
23032     }
23033     function loadLevel(feature22) {
23034       const props = feature22.properties;
23035       if (props.level)
23036         return;
23037       if (!props.country) {
23038         props.level = "country";
23039       } else if (!props.iso1A2 || props.isoStatus === "official") {
23040         props.level = "territory";
23041       } else {
23042         props.level = "subterritory";
23043       }
23044     }
23045     function loadGroupGroups(feature22) {
23046       const props = feature22.properties;
23047       if (feature22.geometry || !props.members)
23048         return;
23049       const featureLevelIndex = levels.indexOf(props.level);
23050       let sharedGroups = [];
23051       props.members.forEach((memberID, index) => {
23052         const member = _featuresByCode[memberID];
23053         const memberGroups = member.properties.groups.filter((groupID) => {
23054           return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level);
23055         });
23056         if (index === 0) {
23057           sharedGroups = memberGroups;
23058         } else {
23059           sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1);
23060         }
23061       });
23062       props.groups = props.groups.concat(
23063         sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1)
23064       );
23065       for (const groupID of sharedGroups) {
23066         const groupFeature = _featuresByCode[groupID];
23067         if (groupFeature.properties.members.indexOf(props.id) === -1) {
23068           groupFeature.properties.members.push(props.id);
23069         }
23070       }
23071     }
23072     function loadRoadSpeedUnit(feature22) {
23073       const props = feature22.properties;
23074       if (feature22.geometry) {
23075         if (!props.roadSpeedUnit)
23076           props.roadSpeedUnit = "km/h";
23077       } else if (props.members) {
23078         const vals = Array.from(
23079           new Set(
23080             props.members.map((id2) => {
23081               const member = _featuresByCode[id2];
23082               if (member.geometry)
23083                 return member.properties.roadSpeedUnit || "km/h";
23084             }).filter(Boolean)
23085           )
23086         );
23087         if (vals.length === 1)
23088           props.roadSpeedUnit = vals[0];
23089       }
23090     }
23091     function loadRoadHeightUnit(feature22) {
23092       const props = feature22.properties;
23093       if (feature22.geometry) {
23094         if (!props.roadHeightUnit)
23095           props.roadHeightUnit = "m";
23096       } else if (props.members) {
23097         const vals = Array.from(
23098           new Set(
23099             props.members.map((id2) => {
23100               const member = _featuresByCode[id2];
23101               if (member.geometry)
23102                 return member.properties.roadHeightUnit || "m";
23103             }).filter(Boolean)
23104           )
23105         );
23106         if (vals.length === 1)
23107           props.roadHeightUnit = vals[0];
23108       }
23109     }
23110     function loadDriveSide(feature22) {
23111       const props = feature22.properties;
23112       if (feature22.geometry) {
23113         if (!props.driveSide)
23114           props.driveSide = "right";
23115       } else if (props.members) {
23116         const vals = Array.from(
23117           new Set(
23118             props.members.map((id2) => {
23119               const member = _featuresByCode[id2];
23120               if (member.geometry)
23121                 return member.properties.driveSide || "right";
23122             }).filter(Boolean)
23123           )
23124         );
23125         if (vals.length === 1)
23126           props.driveSide = vals[0];
23127       }
23128     }
23129     function loadCallingCodes(feature22) {
23130       const props = feature22.properties;
23131       if (!feature22.geometry && props.members) {
23132         props.callingCodes = Array.from(
23133           new Set(
23134             props.members.reduce((array2, id2) => {
23135               const member = _featuresByCode[id2];
23136               if (member.geometry && member.properties.callingCodes) {
23137                 return array2.concat(member.properties.callingCodes);
23138               }
23139               return array2;
23140             }, [])
23141           )
23142         );
23143       }
23144     }
23145     function loadFlag(feature22) {
23146       if (!feature22.properties.iso1A2)
23147         return;
23148       const flag = feature22.properties.iso1A2.replace(/./g, function(char) {
23149         return String.fromCodePoint(char.charCodeAt(0) + 127397);
23150       });
23151       feature22.properties.emojiFlag = flag;
23152     }
23153     function loadMembersForGroupsOf(feature22) {
23154       for (const groupID of feature22.properties.groups) {
23155         const groupFeature = _featuresByCode[groupID];
23156         if (!groupFeature.properties.members) {
23157           groupFeature.properties.members = [];
23158         }
23159         groupFeature.properties.members.push(feature22.properties.id);
23160       }
23161     }
23162     function cacheFeatureByIDs(feature22) {
23163       let ids = [];
23164       for (const prop of identifierProps) {
23165         const id2 = feature22.properties[prop];
23166         if (id2) {
23167           ids.push(id2);
23168         }
23169       }
23170       for (const alias of feature22.properties.aliases || []) {
23171         ids.push(alias);
23172       }
23173       for (const id2 of ids) {
23174         const cid = canonicalID(id2);
23175         _featuresByCode[cid] = feature22;
23176       }
23177     }
23178   }
23179   function locArray(loc) {
23180     if (Array.isArray(loc)) {
23181       return loc;
23182     } else if (loc.coordinates) {
23183       return loc.coordinates;
23184     }
23185     return loc.geometry.coordinates;
23186   }
23187   function smallestFeature(loc) {
23188     const query = locArray(loc);
23189     const featureProperties = _whichPolygon(query);
23190     if (!featureProperties)
23191       return null;
23192     return _featuresByCode[featureProperties.id];
23193   }
23194   function countryFeature(loc) {
23195     const feature22 = smallestFeature(loc);
23196     if (!feature22)
23197       return null;
23198     const countryCode = feature22.properties.country || feature22.properties.iso1A2;
23199     return _featuresByCode[countryCode] || null;
23200   }
23201   var defaultOpts = {
23202     level: void 0,
23203     maxLevel: void 0,
23204     withProp: void 0
23205   };
23206   function featureForLoc(loc, opts) {
23207     const targetLevel = opts.level || "country";
23208     const maxLevel = opts.maxLevel || "world";
23209     const withProp = opts.withProp;
23210     const targetLevelIndex = levels.indexOf(targetLevel);
23211     if (targetLevelIndex === -1)
23212       return null;
23213     const maxLevelIndex = levels.indexOf(maxLevel);
23214     if (maxLevelIndex === -1)
23215       return null;
23216     if (maxLevelIndex < targetLevelIndex)
23217       return null;
23218     if (targetLevel === "country") {
23219       const fastFeature = countryFeature(loc);
23220       if (fastFeature) {
23221         if (!withProp || fastFeature.properties[withProp]) {
23222           return fastFeature;
23223         }
23224       }
23225     }
23226     const features = featuresContaining(loc);
23227     const match = features.find((feature22) => {
23228       let levelIndex = levels.indexOf(feature22.properties.level);
23229       if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up
23230       levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) {
23231         if (!withProp || feature22.properties[withProp]) {
23232           return feature22;
23233         }
23234       }
23235       return false;
23236     });
23237     return match || null;
23238   }
23239   function featureForID(id2) {
23240     let stringID;
23241     if (typeof id2 === "number") {
23242       stringID = id2.toString();
23243       if (stringID.length === 1) {
23244         stringID = "00" + stringID;
23245       } else if (stringID.length === 2) {
23246         stringID = "0" + stringID;
23247       }
23248     } else {
23249       stringID = canonicalID(id2);
23250     }
23251     return _featuresByCode[stringID] || null;
23252   }
23253   function smallestFeaturesForBbox(bbox2) {
23254     return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]);
23255   }
23256   function smallestOrMatchingFeature(query) {
23257     if (typeof query === "object") {
23258       return smallestFeature(query);
23259     }
23260     return featureForID(query);
23261   }
23262   function feature(query, opts = defaultOpts) {
23263     if (typeof query === "object") {
23264       return featureForLoc(query, opts);
23265     }
23266     return featureForID(query);
23267   }
23268   function iso1A2Code(query, opts = defaultOpts) {
23269     opts.withProp = "iso1A2";
23270     const match = feature(query, opts);
23271     if (!match)
23272       return null;
23273     return match.properties.iso1A2 || null;
23274   }
23275   function propertiesForQuery(query, property) {
23276     const features = featuresContaining(query, false);
23277     return features.map((feature22) => feature22.properties[property]).filter(Boolean);
23278   }
23279   function iso1A2Codes(query) {
23280     return propertiesForQuery(query, "iso1A2");
23281   }
23282   function featuresContaining(query, strict) {
23283     let matchingFeatures;
23284     if (Array.isArray(query) && query.length === 4) {
23285       matchingFeatures = smallestFeaturesForBbox(query);
23286     } else {
23287       const smallestOrMatching = smallestOrMatchingFeature(query);
23288       matchingFeatures = smallestOrMatching ? [smallestOrMatching] : [];
23289     }
23290     if (!matchingFeatures.length)
23291       return [];
23292     let returnFeatures;
23293     if (!strict || typeof query === "object") {
23294       returnFeatures = matchingFeatures.slice();
23295     } else {
23296       returnFeatures = [];
23297     }
23298     for (const feature22 of matchingFeatures) {
23299       const properties = feature22.properties;
23300       for (const groupID of properties.groups) {
23301         const groupFeature = _featuresByCode[groupID];
23302         if (returnFeatures.indexOf(groupFeature) === -1) {
23303           returnFeatures.push(groupFeature);
23304         }
23305       }
23306     }
23307     return returnFeatures;
23308   }
23309   function featuresIn(id2, strict) {
23310     const feature22 = featureForID(id2);
23311     if (!feature22)
23312       return [];
23313     let features = [];
23314     if (!strict) {
23315       features.push(feature22);
23316     }
23317     const properties = feature22.properties;
23318     for (const memberID of properties.members || []) {
23319       features.push(_featuresByCode[memberID]);
23320     }
23321     return features;
23322   }
23323   function aggregateFeature(id2) {
23324     var _a2;
23325     const features = featuresIn(id2, false);
23326     if (features.length === 0)
23327       return null;
23328     let aggregateCoordinates = [];
23329     for (const feature22 of features) {
23330       if (((_a2 = feature22.geometry) == null ? void 0 : _a2.type) === "MultiPolygon" && feature22.geometry.coordinates) {
23331         aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates);
23332       }
23333     }
23334     return {
23335       type: "Feature",
23336       properties: features[0].properties,
23337       geometry: {
23338         type: "MultiPolygon",
23339         coordinates: aggregateCoordinates
23340       }
23341     };
23342   }
23343   function roadSpeedUnit(query) {
23344     const feature22 = smallestOrMatchingFeature(query);
23345     return feature22 && feature22.properties.roadSpeedUnit || null;
23346   }
23347   function roadHeightUnit(query) {
23348     const feature22 = smallestOrMatchingFeature(query);
23349     return feature22 && feature22.properties.roadHeightUnit || null;
23350   }
23351
23352   // node_modules/polyclip-ts/dist/constant.js
23353   var constant_default5 = (x2) => {
23354     return () => {
23355       return x2;
23356     };
23357   };
23358
23359   // node_modules/polyclip-ts/dist/compare.js
23360   var compare_default = (eps) => {
23361     const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default5(false);
23362     return (a2, b2) => {
23363       if (almostEqual(a2, b2))
23364         return 0;
23365       return a2.comparedTo(b2);
23366     };
23367   };
23368
23369   // node_modules/polyclip-ts/dist/orient.js
23370   function orient_default(eps) {
23371     const almostCollinear = eps ? (area2, ax, ay, cx, cy) => area2.exponentiatedBy(2).isLessThanOrEqualTo(cx.minus(ax).exponentiatedBy(2).plus(cy.minus(ay).exponentiatedBy(2)).times(eps)) : constant_default5(false);
23372     return (a2, b2, c2) => {
23373       const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y;
23374       const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy)));
23375       if (almostCollinear(area2, ax, ay, cx, cy))
23376         return 0;
23377       return area2.comparedTo(0);
23378     };
23379   }
23380
23381   // node_modules/bignumber.js/bignumber.mjs
23382   var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
23383   var mathceil = Math.ceil;
23384   var mathfloor = Math.floor;
23385   var bignumberError = "[BigNumber Error] ";
23386   var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
23387   var BASE = 1e14;
23388   var LOG_BASE = 14;
23389   var MAX_SAFE_INTEGER = 9007199254740991;
23390   var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
23391   var SQRT_BASE = 1e7;
23392   var MAX = 1e9;
23393   function clone(configObject) {
23394     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 = {
23395       prefix: "",
23396       groupSize: 3,
23397       secondaryGroupSize: 0,
23398       groupSeparator: ",",
23399       decimalSeparator: ".",
23400       fractionGroupSize: 0,
23401       fractionGroupSeparator: "\xA0",
23402       // non-breaking space
23403       suffix: ""
23404     }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
23405     function BigNumber2(v2, b2) {
23406       var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this;
23407       if (!(x2 instanceof BigNumber2))
23408         return new BigNumber2(v2, b2);
23409       if (b2 == null) {
23410         if (v2 && v2._isBigNumber === true) {
23411           x2.s = v2.s;
23412           if (!v2.c || v2.e > MAX_EXP) {
23413             x2.c = x2.e = null;
23414           } else if (v2.e < MIN_EXP) {
23415             x2.c = [x2.e = 0];
23416           } else {
23417             x2.e = v2.e;
23418             x2.c = v2.c.slice();
23419           }
23420           return;
23421         }
23422         if ((isNum = typeof v2 == "number") && v2 * 0 == 0) {
23423           x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1;
23424           if (v2 === ~~v2) {
23425             for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++)
23426               ;
23427             if (e3 > MAX_EXP) {
23428               x2.c = x2.e = null;
23429             } else {
23430               x2.e = e3;
23431               x2.c = [v2];
23432             }
23433             return;
23434           }
23435           str = String(v2);
23436         } else {
23437           if (!isNumeric.test(str = String(v2)))
23438             return parseNumeric2(x2, str, isNum);
23439           x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
23440         }
23441         if ((e3 = str.indexOf(".")) > -1)
23442           str = str.replace(".", "");
23443         if ((i3 = str.search(/e/i)) > 0) {
23444           if (e3 < 0)
23445             e3 = i3;
23446           e3 += +str.slice(i3 + 1);
23447           str = str.substring(0, i3);
23448         } else if (e3 < 0) {
23449           e3 = str.length;
23450         }
23451       } else {
23452         intCheck(b2, 2, ALPHABET.length, "Base");
23453         if (b2 == 10 && alphabetHasNormalDecimalDigits) {
23454           x2 = new BigNumber2(v2);
23455           return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE);
23456         }
23457         str = String(v2);
23458         if (isNum = typeof v2 == "number") {
23459           if (v2 * 0 != 0)
23460             return parseNumeric2(x2, str, isNum, b2);
23461           x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1;
23462           if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
23463             throw Error(tooManyDigits + v2);
23464           }
23465         } else {
23466           x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
23467         }
23468         alphabet = ALPHABET.slice(0, b2);
23469         e3 = i3 = 0;
23470         for (len = str.length; i3 < len; i3++) {
23471           if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) {
23472             if (c2 == ".") {
23473               if (i3 > e3) {
23474                 e3 = len;
23475                 continue;
23476               }
23477             } else if (!caseChanged) {
23478               if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
23479                 caseChanged = true;
23480                 i3 = -1;
23481                 e3 = 0;
23482                 continue;
23483               }
23484             }
23485             return parseNumeric2(x2, String(v2), isNum, b2);
23486           }
23487         }
23488         isNum = false;
23489         str = convertBase(str, b2, 10, x2.s);
23490         if ((e3 = str.indexOf(".")) > -1)
23491           str = str.replace(".", "");
23492         else
23493           e3 = str.length;
23494       }
23495       for (i3 = 0; str.charCodeAt(i3) === 48; i3++)
23496         ;
23497       for (len = str.length; str.charCodeAt(--len) === 48; )
23498         ;
23499       if (str = str.slice(i3, ++len)) {
23500         len -= i3;
23501         if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER || v2 !== mathfloor(v2))) {
23502           throw Error(tooManyDigits + x2.s * v2);
23503         }
23504         if ((e3 = e3 - i3 - 1) > MAX_EXP) {
23505           x2.c = x2.e = null;
23506         } else if (e3 < MIN_EXP) {
23507           x2.c = [x2.e = 0];
23508         } else {
23509           x2.e = e3;
23510           x2.c = [];
23511           i3 = (e3 + 1) % LOG_BASE;
23512           if (e3 < 0)
23513             i3 += LOG_BASE;
23514           if (i3 < len) {
23515             if (i3)
23516               x2.c.push(+str.slice(0, i3));
23517             for (len -= LOG_BASE; i3 < len; ) {
23518               x2.c.push(+str.slice(i3, i3 += LOG_BASE));
23519             }
23520             i3 = LOG_BASE - (str = str.slice(i3)).length;
23521           } else {
23522             i3 -= len;
23523           }
23524           for (; i3--; str += "0")
23525             ;
23526           x2.c.push(+str);
23527         }
23528       } else {
23529         x2.c = [x2.e = 0];
23530       }
23531     }
23532     BigNumber2.clone = clone;
23533     BigNumber2.ROUND_UP = 0;
23534     BigNumber2.ROUND_DOWN = 1;
23535     BigNumber2.ROUND_CEIL = 2;
23536     BigNumber2.ROUND_FLOOR = 3;
23537     BigNumber2.ROUND_HALF_UP = 4;
23538     BigNumber2.ROUND_HALF_DOWN = 5;
23539     BigNumber2.ROUND_HALF_EVEN = 6;
23540     BigNumber2.ROUND_HALF_CEIL = 7;
23541     BigNumber2.ROUND_HALF_FLOOR = 8;
23542     BigNumber2.EUCLID = 9;
23543     BigNumber2.config = BigNumber2.set = function(obj) {
23544       var p2, v2;
23545       if (obj != null) {
23546         if (typeof obj == "object") {
23547           if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) {
23548             v2 = obj[p2];
23549             intCheck(v2, 0, MAX, p2);
23550             DECIMAL_PLACES = v2;
23551           }
23552           if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) {
23553             v2 = obj[p2];
23554             intCheck(v2, 0, 8, p2);
23555             ROUNDING_MODE = v2;
23556           }
23557           if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) {
23558             v2 = obj[p2];
23559             if (v2 && v2.pop) {
23560               intCheck(v2[0], -MAX, 0, p2);
23561               intCheck(v2[1], 0, MAX, p2);
23562               TO_EXP_NEG = v2[0];
23563               TO_EXP_POS = v2[1];
23564             } else {
23565               intCheck(v2, -MAX, MAX, p2);
23566               TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2);
23567             }
23568           }
23569           if (obj.hasOwnProperty(p2 = "RANGE")) {
23570             v2 = obj[p2];
23571             if (v2 && v2.pop) {
23572               intCheck(v2[0], -MAX, -1, p2);
23573               intCheck(v2[1], 1, MAX, p2);
23574               MIN_EXP = v2[0];
23575               MAX_EXP = v2[1];
23576             } else {
23577               intCheck(v2, -MAX, MAX, p2);
23578               if (v2) {
23579                 MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2);
23580               } else {
23581                 throw Error(bignumberError + p2 + " cannot be zero: " + v2);
23582               }
23583             }
23584           }
23585           if (obj.hasOwnProperty(p2 = "CRYPTO")) {
23586             v2 = obj[p2];
23587             if (v2 === !!v2) {
23588               if (v2) {
23589                 if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
23590                   CRYPTO = v2;
23591                 } else {
23592                   CRYPTO = !v2;
23593                   throw Error(bignumberError + "crypto unavailable");
23594                 }
23595               } else {
23596                 CRYPTO = v2;
23597               }
23598             } else {
23599               throw Error(bignumberError + p2 + " not true or false: " + v2);
23600             }
23601           }
23602           if (obj.hasOwnProperty(p2 = "MODULO_MODE")) {
23603             v2 = obj[p2];
23604             intCheck(v2, 0, 9, p2);
23605             MODULO_MODE = v2;
23606           }
23607           if (obj.hasOwnProperty(p2 = "POW_PRECISION")) {
23608             v2 = obj[p2];
23609             intCheck(v2, 0, MAX, p2);
23610             POW_PRECISION = v2;
23611           }
23612           if (obj.hasOwnProperty(p2 = "FORMAT")) {
23613             v2 = obj[p2];
23614             if (typeof v2 == "object")
23615               FORMAT = v2;
23616             else
23617               throw Error(bignumberError + p2 + " not an object: " + v2);
23618           }
23619           if (obj.hasOwnProperty(p2 = "ALPHABET")) {
23620             v2 = obj[p2];
23621             if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) {
23622               alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789";
23623               ALPHABET = v2;
23624             } else {
23625               throw Error(bignumberError + p2 + " invalid: " + v2);
23626             }
23627           }
23628         } else {
23629           throw Error(bignumberError + "Object expected: " + obj);
23630         }
23631       }
23632       return {
23633         DECIMAL_PLACES,
23634         ROUNDING_MODE,
23635         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
23636         RANGE: [MIN_EXP, MAX_EXP],
23637         CRYPTO,
23638         MODULO_MODE,
23639         POW_PRECISION,
23640         FORMAT,
23641         ALPHABET
23642       };
23643     };
23644     BigNumber2.isBigNumber = function(v2) {
23645       if (!v2 || v2._isBigNumber !== true)
23646         return false;
23647       if (!BigNumber2.DEBUG)
23648         return true;
23649       var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s;
23650       out:
23651         if ({}.toString.call(c2) == "[object Array]") {
23652           if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) {
23653             if (c2[0] === 0) {
23654               if (e3 === 0 && c2.length === 1)
23655                 return true;
23656               break out;
23657             }
23658             i3 = (e3 + 1) % LOG_BASE;
23659             if (i3 < 1)
23660               i3 += LOG_BASE;
23661             if (String(c2[0]).length == i3) {
23662               for (i3 = 0; i3 < c2.length; i3++) {
23663                 n3 = c2[i3];
23664                 if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3))
23665                   break out;
23666               }
23667               if (n3 !== 0)
23668                 return true;
23669             }
23670           }
23671         } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) {
23672           return true;
23673         }
23674       throw Error(bignumberError + "Invalid BigNumber: " + v2);
23675     };
23676     BigNumber2.maximum = BigNumber2.max = function() {
23677       return maxOrMin(arguments, -1);
23678     };
23679     BigNumber2.minimum = BigNumber2.min = function() {
23680       return maxOrMin(arguments, 1);
23681     };
23682     BigNumber2.random = function() {
23683       var pow2_53 = 9007199254740992;
23684       var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
23685         return mathfloor(Math.random() * pow2_53);
23686       } : function() {
23687         return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
23688       };
23689       return function(dp) {
23690         var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE);
23691         if (dp == null)
23692           dp = DECIMAL_PLACES;
23693         else
23694           intCheck(dp, 0, MAX);
23695         k2 = mathceil(dp / LOG_BASE);
23696         if (CRYPTO) {
23697           if (crypto.getRandomValues) {
23698             a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2));
23699             for (; i3 < k2; ) {
23700               v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11);
23701               if (v2 >= 9e15) {
23702                 b2 = crypto.getRandomValues(new Uint32Array(2));
23703                 a2[i3] = b2[0];
23704                 a2[i3 + 1] = b2[1];
23705               } else {
23706                 c2.push(v2 % 1e14);
23707                 i3 += 2;
23708               }
23709             }
23710             i3 = k2 / 2;
23711           } else if (crypto.randomBytes) {
23712             a2 = crypto.randomBytes(k2 *= 7);
23713             for (; i3 < k2; ) {
23714               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];
23715               if (v2 >= 9e15) {
23716                 crypto.randomBytes(7).copy(a2, i3);
23717               } else {
23718                 c2.push(v2 % 1e14);
23719                 i3 += 7;
23720               }
23721             }
23722             i3 = k2 / 7;
23723           } else {
23724             CRYPTO = false;
23725             throw Error(bignumberError + "crypto unavailable");
23726           }
23727         }
23728         if (!CRYPTO) {
23729           for (; i3 < k2; ) {
23730             v2 = random53bitInt();
23731             if (v2 < 9e15)
23732               c2[i3++] = v2 % 1e14;
23733           }
23734         }
23735         k2 = c2[--i3];
23736         dp %= LOG_BASE;
23737         if (k2 && dp) {
23738           v2 = POWS_TEN[LOG_BASE - dp];
23739           c2[i3] = mathfloor(k2 / v2) * v2;
23740         }
23741         for (; c2[i3] === 0; c2.pop(), i3--)
23742           ;
23743         if (i3 < 0) {
23744           c2 = [e3 = 0];
23745         } else {
23746           for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE)
23747             ;
23748           for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++)
23749             ;
23750           if (i3 < LOG_BASE)
23751             e3 -= LOG_BASE - i3;
23752         }
23753         rand.e = e3;
23754         rand.c = c2;
23755         return rand;
23756       };
23757     }();
23758     BigNumber2.sum = function() {
23759       var i3 = 1, args = arguments, sum = new BigNumber2(args[0]);
23760       for (; i3 < args.length; )
23761         sum = sum.plus(args[i3++]);
23762       return sum;
23763     };
23764     convertBase = /* @__PURE__ */ function() {
23765       var decimal = "0123456789";
23766       function toBaseOut(str, baseIn, baseOut, alphabet) {
23767         var j2, arr = [0], arrL, i3 = 0, len = str.length;
23768         for (; i3 < len; ) {
23769           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn)
23770             ;
23771           arr[0] += alphabet.indexOf(str.charAt(i3++));
23772           for (j2 = 0; j2 < arr.length; j2++) {
23773             if (arr[j2] > baseOut - 1) {
23774               if (arr[j2 + 1] == null)
23775                 arr[j2 + 1] = 0;
23776               arr[j2 + 1] += arr[j2] / baseOut | 0;
23777               arr[j2] %= baseOut;
23778             }
23779           }
23780         }
23781         return arr.reverse();
23782       }
23783       return function(str, baseIn, baseOut, sign2, callerIsToString) {
23784         var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
23785         if (i3 >= 0) {
23786           k2 = POW_PRECISION;
23787           POW_PRECISION = 0;
23788           str = str.replace(".", "");
23789           y2 = new BigNumber2(baseIn);
23790           x2 = y2.pow(str.length - i3);
23791           POW_PRECISION = k2;
23792           y2.c = toBaseOut(
23793             toFixedPoint(coeffToString(x2.c), x2.e, "0"),
23794             10,
23795             baseOut,
23796             decimal
23797           );
23798           y2.e = y2.c.length;
23799         }
23800         xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
23801         e3 = k2 = xc.length;
23802         for (; xc[--k2] == 0; xc.pop())
23803           ;
23804         if (!xc[0])
23805           return alphabet.charAt(0);
23806         if (i3 < 0) {
23807           --e3;
23808         } else {
23809           x2.c = xc;
23810           x2.e = e3;
23811           x2.s = sign2;
23812           x2 = div(x2, y2, dp, rm, baseOut);
23813           xc = x2.c;
23814           r2 = x2.r;
23815           e3 = x2.e;
23816         }
23817         d2 = e3 + dp + 1;
23818         i3 = xc[d2];
23819         k2 = baseOut / 2;
23820         r2 = r2 || d2 < 0 || xc[d2 + 1] != null;
23821         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));
23822         if (d2 < 1 || !xc[0]) {
23823           str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
23824         } else {
23825           xc.length = d2;
23826           if (r2) {
23827             for (--baseOut; ++xc[--d2] > baseOut; ) {
23828               xc[d2] = 0;
23829               if (!d2) {
23830                 ++e3;
23831                 xc = [1].concat(xc);
23832               }
23833             }
23834           }
23835           for (k2 = xc.length; !xc[--k2]; )
23836             ;
23837           for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++]))
23838             ;
23839           str = toFixedPoint(str, e3, alphabet.charAt(0));
23840         }
23841         return str;
23842       };
23843     }();
23844     div = /* @__PURE__ */ function() {
23845       function multiply(x2, k2, base) {
23846         var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0;
23847         for (x2 = x2.slice(); i3--; ) {
23848           xlo = x2[i3] % SQRT_BASE;
23849           xhi = x2[i3] / SQRT_BASE | 0;
23850           m2 = khi * xlo + xhi * klo;
23851           temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry;
23852           carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi;
23853           x2[i3] = temp % base;
23854         }
23855         if (carry)
23856           x2 = [carry].concat(x2);
23857         return x2;
23858       }
23859       function compare2(a2, b2, aL, bL) {
23860         var i3, cmp;
23861         if (aL != bL) {
23862           cmp = aL > bL ? 1 : -1;
23863         } else {
23864           for (i3 = cmp = 0; i3 < aL; i3++) {
23865             if (a2[i3] != b2[i3]) {
23866               cmp = a2[i3] > b2[i3] ? 1 : -1;
23867               break;
23868             }
23869           }
23870         }
23871         return cmp;
23872       }
23873       function subtract(a2, b2, aL, base) {
23874         var i3 = 0;
23875         for (; aL--; ) {
23876           a2[aL] -= i3;
23877           i3 = a2[aL] < b2[aL] ? 1 : 0;
23878           a2[aL] = i3 * base + a2[aL] - b2[aL];
23879         }
23880         for (; !a2[0] && a2.length > 1; a2.splice(0, 1))
23881           ;
23882       }
23883       return function(x2, y2, dp, rm, base) {
23884         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;
23885         if (!xc || !xc[0] || !yc || !yc[0]) {
23886           return new BigNumber2(
23887             // Return NaN if either NaN, or both Infinity or 0.
23888             !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
23889               // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
23890               xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0
23891             )
23892           );
23893         }
23894         q2 = new BigNumber2(s2);
23895         qc = q2.c = [];
23896         e3 = x2.e - y2.e;
23897         s2 = dp + e3 + 1;
23898         if (!base) {
23899           base = BASE;
23900           e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE);
23901           s2 = s2 / LOG_BASE | 0;
23902         }
23903         for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++)
23904           ;
23905         if (yc[i3] > (xc[i3] || 0))
23906           e3--;
23907         if (s2 < 0) {
23908           qc.push(1);
23909           more = true;
23910         } else {
23911           xL = xc.length;
23912           yL = yc.length;
23913           i3 = 0;
23914           s2 += 2;
23915           n3 = mathfloor(base / (yc[0] + 1));
23916           if (n3 > 1) {
23917             yc = multiply(yc, n3, base);
23918             xc = multiply(xc, n3, base);
23919             yL = yc.length;
23920             xL = xc.length;
23921           }
23922           xi = yL;
23923           rem = xc.slice(0, yL);
23924           remL = rem.length;
23925           for (; remL < yL; rem[remL++] = 0)
23926             ;
23927           yz = yc.slice();
23928           yz = [0].concat(yz);
23929           yc0 = yc[0];
23930           if (yc[1] >= base / 2)
23931             yc0++;
23932           do {
23933             n3 = 0;
23934             cmp = compare2(yc, rem, yL, remL);
23935             if (cmp < 0) {
23936               rem0 = rem[0];
23937               if (yL != remL)
23938                 rem0 = rem0 * base + (rem[1] || 0);
23939               n3 = mathfloor(rem0 / yc0);
23940               if (n3 > 1) {
23941                 if (n3 >= base)
23942                   n3 = base - 1;
23943                 prod = multiply(yc, n3, base);
23944                 prodL = prod.length;
23945                 remL = rem.length;
23946                 while (compare2(prod, rem, prodL, remL) == 1) {
23947                   n3--;
23948                   subtract(prod, yL < prodL ? yz : yc, prodL, base);
23949                   prodL = prod.length;
23950                   cmp = 1;
23951                 }
23952               } else {
23953                 if (n3 == 0) {
23954                   cmp = n3 = 1;
23955                 }
23956                 prod = yc.slice();
23957                 prodL = prod.length;
23958               }
23959               if (prodL < remL)
23960                 prod = [0].concat(prod);
23961               subtract(rem, prod, remL, base);
23962               remL = rem.length;
23963               if (cmp == -1) {
23964                 while (compare2(yc, rem, yL, remL) < 1) {
23965                   n3++;
23966                   subtract(rem, yL < remL ? yz : yc, remL, base);
23967                   remL = rem.length;
23968                 }
23969               }
23970             } else if (cmp === 0) {
23971               n3++;
23972               rem = [0];
23973             }
23974             qc[i3++] = n3;
23975             if (rem[0]) {
23976               rem[remL++] = xc[xi] || 0;
23977             } else {
23978               rem = [xc[xi]];
23979               remL = 1;
23980             }
23981           } while ((xi++ < xL || rem[0] != null) && s2--);
23982           more = rem[0] != null;
23983           if (!qc[0])
23984             qc.splice(0, 1);
23985         }
23986         if (base == BASE) {
23987           for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++)
23988             ;
23989           round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more);
23990         } else {
23991           q2.e = e3;
23992           q2.r = +more;
23993         }
23994         return q2;
23995       };
23996     }();
23997     function format2(n3, i3, rm, id2) {
23998       var c0, e3, ne2, len, str;
23999       if (rm == null)
24000         rm = ROUNDING_MODE;
24001       else
24002         intCheck(rm, 0, 8);
24003       if (!n3.c)
24004         return n3.toString();
24005       c0 = n3.c[0];
24006       ne2 = n3.e;
24007       if (i3 == null) {
24008         str = coeffToString(n3.c);
24009         str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0");
24010       } else {
24011         n3 = round(new BigNumber2(n3), i3, rm);
24012         e3 = n3.e;
24013         str = coeffToString(n3.c);
24014         len = str.length;
24015         if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) {
24016           for (; len < i3; str += "0", len++)
24017             ;
24018           str = toExponential(str, e3);
24019         } else {
24020           i3 -= ne2;
24021           str = toFixedPoint(str, e3, "0");
24022           if (e3 + 1 > len) {
24023             if (--i3 > 0)
24024               for (str += "."; i3--; str += "0")
24025                 ;
24026           } else {
24027             i3 += e3 - len;
24028             if (i3 > 0) {
24029               if (e3 + 1 == len)
24030                 str += ".";
24031               for (; i3--; str += "0")
24032                 ;
24033             }
24034           }
24035         }
24036       }
24037       return n3.s < 0 && c0 ? "-" + str : str;
24038     }
24039     function maxOrMin(args, n3) {
24040       var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]);
24041       for (; i3 < args.length; i3++) {
24042         y2 = new BigNumber2(args[i3]);
24043         if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) {
24044           x2 = y2;
24045         }
24046       }
24047       return x2;
24048     }
24049     function normalise(n3, c2, e3) {
24050       var i3 = 1, j2 = c2.length;
24051       for (; !c2[--j2]; c2.pop())
24052         ;
24053       for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++)
24054         ;
24055       if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) {
24056         n3.c = n3.e = null;
24057       } else if (e3 < MIN_EXP) {
24058         n3.c = [n3.e = 0];
24059       } else {
24060         n3.e = e3;
24061         n3.c = c2;
24062       }
24063       return n3;
24064     }
24065     parseNumeric2 = /* @__PURE__ */ function() {
24066       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
24067       return function(x2, str, isNum, b2) {
24068         var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, "");
24069         if (isInfinityOrNaN.test(s2)) {
24070           x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1;
24071         } else {
24072           if (!isNum) {
24073             s2 = s2.replace(basePrefix, function(m2, p1, p2) {
24074               base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
24075               return !b2 || b2 == base ? p1 : m2;
24076             });
24077             if (b2) {
24078               base = b2;
24079               s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
24080             }
24081             if (str != s2)
24082               return new BigNumber2(s2, base);
24083           }
24084           if (BigNumber2.DEBUG) {
24085             throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str);
24086           }
24087           x2.s = null;
24088         }
24089         x2.c = x2.e = null;
24090       };
24091     }();
24092     function round(x2, sd, rm, r2) {
24093       var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN;
24094       if (xc) {
24095         out: {
24096           for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++)
24097             ;
24098           i3 = sd - d2;
24099           if (i3 < 0) {
24100             i3 += LOG_BASE;
24101             j2 = sd;
24102             n3 = xc[ni = 0];
24103             rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24104           } else {
24105             ni = mathceil((i3 + 1) / LOG_BASE);
24106             if (ni >= xc.length) {
24107               if (r2) {
24108                 for (; xc.length <= ni; xc.push(0))
24109                   ;
24110                 n3 = rd = 0;
24111                 d2 = 1;
24112                 i3 %= LOG_BASE;
24113                 j2 = i3 - LOG_BASE + 1;
24114               } else {
24115                 break out;
24116               }
24117             } else {
24118               n3 = k2 = xc[ni];
24119               for (d2 = 1; k2 >= 10; k2 /= 10, d2++)
24120                 ;
24121               i3 %= LOG_BASE;
24122               j2 = i3 - LOG_BASE + d2;
24123               rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24124             }
24125           }
24126           r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit?
24127           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right
24128           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
24129           xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]);
24130           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.
24131           (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7));
24132           if (sd < 1 || !xc[0]) {
24133             xc.length = 0;
24134             if (r2) {
24135               sd -= x2.e + 1;
24136               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
24137               x2.e = -sd || 0;
24138             } else {
24139               xc[0] = x2.e = 0;
24140             }
24141             return x2;
24142           }
24143           if (i3 == 0) {
24144             xc.length = ni;
24145             k2 = 1;
24146             ni--;
24147           } else {
24148             xc.length = ni + 1;
24149             k2 = pows10[LOG_BASE - i3];
24150             xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0;
24151           }
24152           if (r2) {
24153             for (; ; ) {
24154               if (ni == 0) {
24155                 for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++)
24156                   ;
24157                 j2 = xc[0] += k2;
24158                 for (k2 = 1; j2 >= 10; j2 /= 10, k2++)
24159                   ;
24160                 if (i3 != k2) {
24161                   x2.e++;
24162                   if (xc[0] == BASE)
24163                     xc[0] = 1;
24164                 }
24165                 break;
24166               } else {
24167                 xc[ni] += k2;
24168                 if (xc[ni] != BASE)
24169                   break;
24170                 xc[ni--] = 0;
24171                 k2 = 1;
24172               }
24173             }
24174           }
24175           for (i3 = xc.length; xc[--i3] === 0; xc.pop())
24176             ;
24177         }
24178         if (x2.e > MAX_EXP) {
24179           x2.c = x2.e = null;
24180         } else if (x2.e < MIN_EXP) {
24181           x2.c = [x2.e = 0];
24182         }
24183       }
24184       return x2;
24185     }
24186     function valueOf(n3) {
24187       var str, e3 = n3.e;
24188       if (e3 === null)
24189         return n3.toString();
24190       str = coeffToString(n3.c);
24191       str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0");
24192       return n3.s < 0 ? "-" + str : str;
24193     }
24194     P2.absoluteValue = P2.abs = function() {
24195       var x2 = new BigNumber2(this);
24196       if (x2.s < 0)
24197         x2.s = 1;
24198       return x2;
24199     };
24200     P2.comparedTo = function(y2, b2) {
24201       return compare(this, new BigNumber2(y2, b2));
24202     };
24203     P2.decimalPlaces = P2.dp = function(dp, rm) {
24204       var c2, n3, v2, x2 = this;
24205       if (dp != null) {
24206         intCheck(dp, 0, MAX);
24207         if (rm == null)
24208           rm = ROUNDING_MODE;
24209         else
24210           intCheck(rm, 0, 8);
24211         return round(new BigNumber2(x2), dp + x2.e + 1, rm);
24212       }
24213       if (!(c2 = x2.c))
24214         return null;
24215       n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
24216       if (v2 = c2[v2])
24217         for (; v2 % 10 == 0; v2 /= 10, n3--)
24218           ;
24219       if (n3 < 0)
24220         n3 = 0;
24221       return n3;
24222     };
24223     P2.dividedBy = P2.div = function(y2, b2) {
24224       return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE);
24225     };
24226     P2.dividedToIntegerBy = P2.idiv = function(y2, b2) {
24227       return div(this, new BigNumber2(y2, b2), 0, 1);
24228     };
24229     P2.exponentiatedBy = P2.pow = function(n3, m2) {
24230       var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this;
24231       n3 = new BigNumber2(n3);
24232       if (n3.c && !n3.isInteger()) {
24233         throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3));
24234       }
24235       if (m2 != null)
24236         m2 = new BigNumber2(m2);
24237       nIsBig = n3.e > 14;
24238       if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) {
24239         y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3)));
24240         return m2 ? y2.mod(m2) : y2;
24241       }
24242       nIsNeg = n3.s < 0;
24243       if (m2) {
24244         if (m2.c ? !m2.c[0] : !m2.s)
24245           return new BigNumber2(NaN);
24246         isModExp = !nIsNeg && x2.isInteger() && m2.isInteger();
24247         if (isModExp)
24248           x2 = x2.mod(m2);
24249       } 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))) {
24250         k2 = x2.s < 0 && isOdd(n3) ? -0 : 0;
24251         if (x2.e > -1)
24252           k2 = 1 / k2;
24253         return new BigNumber2(nIsNeg ? 1 / k2 : k2);
24254       } else if (POW_PRECISION) {
24255         k2 = mathceil(POW_PRECISION / LOG_BASE + 2);
24256       }
24257       if (nIsBig) {
24258         half = new BigNumber2(0.5);
24259         if (nIsNeg)
24260           n3.s = 1;
24261         nIsOdd = isOdd(n3);
24262       } else {
24263         i3 = Math.abs(+valueOf(n3));
24264         nIsOdd = i3 % 2;
24265       }
24266       y2 = new BigNumber2(ONE);
24267       for (; ; ) {
24268         if (nIsOdd) {
24269           y2 = y2.times(x2);
24270           if (!y2.c)
24271             break;
24272           if (k2) {
24273             if (y2.c.length > k2)
24274               y2.c.length = k2;
24275           } else if (isModExp) {
24276             y2 = y2.mod(m2);
24277           }
24278         }
24279         if (i3) {
24280           i3 = mathfloor(i3 / 2);
24281           if (i3 === 0)
24282             break;
24283           nIsOdd = i3 % 2;
24284         } else {
24285           n3 = n3.times(half);
24286           round(n3, n3.e + 1, 1);
24287           if (n3.e > 14) {
24288             nIsOdd = isOdd(n3);
24289           } else {
24290             i3 = +valueOf(n3);
24291             if (i3 === 0)
24292               break;
24293             nIsOdd = i3 % 2;
24294           }
24295         }
24296         x2 = x2.times(x2);
24297         if (k2) {
24298           if (x2.c && x2.c.length > k2)
24299             x2.c.length = k2;
24300         } else if (isModExp) {
24301           x2 = x2.mod(m2);
24302         }
24303       }
24304       if (isModExp)
24305         return y2;
24306       if (nIsNeg)
24307         y2 = ONE.div(y2);
24308       return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2;
24309     };
24310     P2.integerValue = function(rm) {
24311       var n3 = new BigNumber2(this);
24312       if (rm == null)
24313         rm = ROUNDING_MODE;
24314       else
24315         intCheck(rm, 0, 8);
24316       return round(n3, n3.e + 1, rm);
24317     };
24318     P2.isEqualTo = P2.eq = function(y2, b2) {
24319       return compare(this, new BigNumber2(y2, b2)) === 0;
24320     };
24321     P2.isFinite = function() {
24322       return !!this.c;
24323     };
24324     P2.isGreaterThan = P2.gt = function(y2, b2) {
24325       return compare(this, new BigNumber2(y2, b2)) > 0;
24326     };
24327     P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) {
24328       return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0;
24329     };
24330     P2.isInteger = function() {
24331       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
24332     };
24333     P2.isLessThan = P2.lt = function(y2, b2) {
24334       return compare(this, new BigNumber2(y2, b2)) < 0;
24335     };
24336     P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) {
24337       return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0;
24338     };
24339     P2.isNaN = function() {
24340       return !this.s;
24341     };
24342     P2.isNegative = function() {
24343       return this.s < 0;
24344     };
24345     P2.isPositive = function() {
24346       return this.s > 0;
24347     };
24348     P2.isZero = function() {
24349       return !!this.c && this.c[0] == 0;
24350     };
24351     P2.minus = function(y2, b2) {
24352       var i3, j2, t2, xLTy, x2 = this, a2 = x2.s;
24353       y2 = new BigNumber2(y2, b2);
24354       b2 = y2.s;
24355       if (!a2 || !b2)
24356         return new BigNumber2(NaN);
24357       if (a2 != b2) {
24358         y2.s = -b2;
24359         return x2.plus(y2);
24360       }
24361       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24362       if (!xe2 || !ye2) {
24363         if (!xc || !yc)
24364           return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN);
24365         if (!xc[0] || !yc[0]) {
24366           return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : (
24367             // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
24368             ROUNDING_MODE == 3 ? -0 : 0
24369           ));
24370         }
24371       }
24372       xe2 = bitFloor(xe2);
24373       ye2 = bitFloor(ye2);
24374       xc = xc.slice();
24375       if (a2 = xe2 - ye2) {
24376         if (xLTy = a2 < 0) {
24377           a2 = -a2;
24378           t2 = xc;
24379         } else {
24380           ye2 = xe2;
24381           t2 = yc;
24382         }
24383         t2.reverse();
24384         for (b2 = a2; b2--; t2.push(0))
24385           ;
24386         t2.reverse();
24387       } else {
24388         j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2;
24389         for (a2 = b2 = 0; b2 < j2; b2++) {
24390           if (xc[b2] != yc[b2]) {
24391             xLTy = xc[b2] < yc[b2];
24392             break;
24393           }
24394         }
24395       }
24396       if (xLTy) {
24397         t2 = xc;
24398         xc = yc;
24399         yc = t2;
24400         y2.s = -y2.s;
24401       }
24402       b2 = (j2 = yc.length) - (i3 = xc.length);
24403       if (b2 > 0)
24404         for (; b2--; xc[i3++] = 0)
24405           ;
24406       b2 = BASE - 1;
24407       for (; j2 > a2; ) {
24408         if (xc[--j2] < yc[j2]) {
24409           for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2)
24410             ;
24411           --xc[i3];
24412           xc[j2] += BASE;
24413         }
24414         xc[j2] -= yc[j2];
24415       }
24416       for (; xc[0] == 0; xc.splice(0, 1), --ye2)
24417         ;
24418       if (!xc[0]) {
24419         y2.s = ROUNDING_MODE == 3 ? -1 : 1;
24420         y2.c = [y2.e = 0];
24421         return y2;
24422       }
24423       return normalise(y2, xc, ye2);
24424     };
24425     P2.modulo = P2.mod = function(y2, b2) {
24426       var q2, s2, x2 = this;
24427       y2 = new BigNumber2(y2, b2);
24428       if (!x2.c || !y2.s || y2.c && !y2.c[0]) {
24429         return new BigNumber2(NaN);
24430       } else if (!y2.c || x2.c && !x2.c[0]) {
24431         return new BigNumber2(x2);
24432       }
24433       if (MODULO_MODE == 9) {
24434         s2 = y2.s;
24435         y2.s = 1;
24436         q2 = div(x2, y2, 0, 3);
24437         y2.s = s2;
24438         q2.s *= s2;
24439       } else {
24440         q2 = div(x2, y2, 0, MODULO_MODE);
24441       }
24442       y2 = x2.minus(q2.times(y2));
24443       if (!y2.c[0] && MODULO_MODE == 1)
24444         y2.s = x2.s;
24445       return y2;
24446     };
24447     P2.multipliedBy = P2.times = function(y2, b2) {
24448       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;
24449       if (!xc || !yc || !xc[0] || !yc[0]) {
24450         if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
24451           y2.c = y2.e = y2.s = null;
24452         } else {
24453           y2.s *= x2.s;
24454           if (!xc || !yc) {
24455             y2.c = y2.e = null;
24456           } else {
24457             y2.c = [0];
24458             y2.e = 0;
24459           }
24460         }
24461         return y2;
24462       }
24463       e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE);
24464       y2.s *= x2.s;
24465       xcL = xc.length;
24466       ycL = yc.length;
24467       if (xcL < ycL) {
24468         zc = xc;
24469         xc = yc;
24470         yc = zc;
24471         i3 = xcL;
24472         xcL = ycL;
24473         ycL = i3;
24474       }
24475       for (i3 = xcL + ycL, zc = []; i3--; zc.push(0))
24476         ;
24477       base = BASE;
24478       sqrtBase = SQRT_BASE;
24479       for (i3 = ycL; --i3 >= 0; ) {
24480         c2 = 0;
24481         ylo = yc[i3] % sqrtBase;
24482         yhi = yc[i3] / sqrtBase | 0;
24483         for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) {
24484           xlo = xc[--k2] % sqrtBase;
24485           xhi = xc[k2] / sqrtBase | 0;
24486           m2 = yhi * xlo + xhi * ylo;
24487           xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2;
24488           c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi;
24489           zc[j2--] = xlo % base;
24490         }
24491         zc[j2] = c2;
24492       }
24493       if (c2) {
24494         ++e3;
24495       } else {
24496         zc.splice(0, 1);
24497       }
24498       return normalise(y2, zc, e3);
24499     };
24500     P2.negated = function() {
24501       var x2 = new BigNumber2(this);
24502       x2.s = -x2.s || null;
24503       return x2;
24504     };
24505     P2.plus = function(y2, b2) {
24506       var t2, x2 = this, a2 = x2.s;
24507       y2 = new BigNumber2(y2, b2);
24508       b2 = y2.s;
24509       if (!a2 || !b2)
24510         return new BigNumber2(NaN);
24511       if (a2 != b2) {
24512         y2.s = -b2;
24513         return x2.minus(y2);
24514       }
24515       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24516       if (!xe2 || !ye2) {
24517         if (!xc || !yc)
24518           return new BigNumber2(a2 / 0);
24519         if (!xc[0] || !yc[0])
24520           return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0);
24521       }
24522       xe2 = bitFloor(xe2);
24523       ye2 = bitFloor(ye2);
24524       xc = xc.slice();
24525       if (a2 = xe2 - ye2) {
24526         if (a2 > 0) {
24527           ye2 = xe2;
24528           t2 = yc;
24529         } else {
24530           a2 = -a2;
24531           t2 = xc;
24532         }
24533         t2.reverse();
24534         for (; a2--; t2.push(0))
24535           ;
24536         t2.reverse();
24537       }
24538       a2 = xc.length;
24539       b2 = yc.length;
24540       if (a2 - b2 < 0) {
24541         t2 = yc;
24542         yc = xc;
24543         xc = t2;
24544         b2 = a2;
24545       }
24546       for (a2 = 0; b2; ) {
24547         a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0;
24548         xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE;
24549       }
24550       if (a2) {
24551         xc = [a2].concat(xc);
24552         ++ye2;
24553       }
24554       return normalise(y2, xc, ye2);
24555     };
24556     P2.precision = P2.sd = function(sd, rm) {
24557       var c2, n3, v2, x2 = this;
24558       if (sd != null && sd !== !!sd) {
24559         intCheck(sd, 1, MAX);
24560         if (rm == null)
24561           rm = ROUNDING_MODE;
24562         else
24563           intCheck(rm, 0, 8);
24564         return round(new BigNumber2(x2), sd, rm);
24565       }
24566       if (!(c2 = x2.c))
24567         return null;
24568       v2 = c2.length - 1;
24569       n3 = v2 * LOG_BASE + 1;
24570       if (v2 = c2[v2]) {
24571         for (; v2 % 10 == 0; v2 /= 10, n3--)
24572           ;
24573         for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++)
24574           ;
24575       }
24576       if (sd && x2.e + 1 > n3)
24577         n3 = x2.e + 1;
24578       return n3;
24579     };
24580     P2.shiftedBy = function(k2) {
24581       intCheck(k2, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
24582       return this.times("1e" + k2);
24583     };
24584     P2.squareRoot = P2.sqrt = function() {
24585       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");
24586       if (s2 !== 1 || !c2 || !c2[0]) {
24587         return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0);
24588       }
24589       s2 = Math.sqrt(+valueOf(x2));
24590       if (s2 == 0 || s2 == 1 / 0) {
24591         n3 = coeffToString(c2);
24592         if ((n3.length + e3) % 2 == 0)
24593           n3 += "0";
24594         s2 = Math.sqrt(+n3);
24595         e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
24596         if (s2 == 1 / 0) {
24597           n3 = "5e" + e3;
24598         } else {
24599           n3 = s2.toExponential();
24600           n3 = n3.slice(0, n3.indexOf("e") + 1) + e3;
24601         }
24602         r2 = new BigNumber2(n3);
24603       } else {
24604         r2 = new BigNumber2(s2 + "");
24605       }
24606       if (r2.c[0]) {
24607         e3 = r2.e;
24608         s2 = e3 + dp;
24609         if (s2 < 3)
24610           s2 = 0;
24611         for (; ; ) {
24612           t2 = r2;
24613           r2 = half.times(t2.plus(div(x2, t2, dp, 1)));
24614           if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) {
24615             if (r2.e < e3)
24616               --s2;
24617             n3 = n3.slice(s2 - 3, s2 + 1);
24618             if (n3 == "9999" || !rep && n3 == "4999") {
24619               if (!rep) {
24620                 round(t2, t2.e + DECIMAL_PLACES + 2, 0);
24621                 if (t2.times(t2).eq(x2)) {
24622                   r2 = t2;
24623                   break;
24624                 }
24625               }
24626               dp += 4;
24627               s2 += 4;
24628               rep = 1;
24629             } else {
24630               if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") {
24631                 round(r2, r2.e + DECIMAL_PLACES + 2, 1);
24632                 m2 = !r2.times(r2).eq(x2);
24633               }
24634               break;
24635             }
24636           }
24637         }
24638       }
24639       return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2);
24640     };
24641     P2.toExponential = function(dp, rm) {
24642       if (dp != null) {
24643         intCheck(dp, 0, MAX);
24644         dp++;
24645       }
24646       return format2(this, dp, rm, 1);
24647     };
24648     P2.toFixed = function(dp, rm) {
24649       if (dp != null) {
24650         intCheck(dp, 0, MAX);
24651         dp = dp + this.e + 1;
24652       }
24653       return format2(this, dp, rm);
24654     };
24655     P2.toFormat = function(dp, rm, format3) {
24656       var str, x2 = this;
24657       if (format3 == null) {
24658         if (dp != null && rm && typeof rm == "object") {
24659           format3 = rm;
24660           rm = null;
24661         } else if (dp && typeof dp == "object") {
24662           format3 = dp;
24663           dp = rm = null;
24664         } else {
24665           format3 = FORMAT;
24666         }
24667       } else if (typeof format3 != "object") {
24668         throw Error(bignumberError + "Argument not an object: " + format3);
24669       }
24670       str = x2.toFixed(dp, rm);
24671       if (x2.c) {
24672         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;
24673         if (g22) {
24674           i3 = g1;
24675           g1 = g22;
24676           g22 = i3;
24677           len -= i3;
24678         }
24679         if (g1 > 0 && len > 0) {
24680           i3 = len % g1 || g1;
24681           intPart = intDigits.substr(0, i3);
24682           for (; i3 < len; i3 += g1)
24683             intPart += groupSeparator + intDigits.substr(i3, g1);
24684           if (g22 > 0)
24685             intPart += groupSeparator + intDigits.slice(i3);
24686           if (isNeg)
24687             intPart = "-" + intPart;
24688         }
24689         str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace(
24690           new RegExp("\\d{" + g22 + "}\\B", "g"),
24691           "$&" + (format3.fractionGroupSeparator || "")
24692         ) : fractionPart) : intPart;
24693       }
24694       return (format3.prefix || "") + str + (format3.suffix || "");
24695     };
24696     P2.toFraction = function(md) {
24697       var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c;
24698       if (md != null) {
24699         n3 = new BigNumber2(md);
24700         if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) {
24701           throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3));
24702         }
24703       }
24704       if (!xc)
24705         return new BigNumber2(x2);
24706       d2 = new BigNumber2(ONE);
24707       n1 = d0 = new BigNumber2(ONE);
24708       d1 = n0 = new BigNumber2(ONE);
24709       s2 = coeffToString(xc);
24710       e3 = d2.e = s2.length - x2.e - 1;
24711       d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2];
24712       md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3;
24713       exp2 = MAX_EXP;
24714       MAX_EXP = 1 / 0;
24715       n3 = new BigNumber2(s2);
24716       n0.c[0] = 0;
24717       for (; ; ) {
24718         q2 = div(n3, d2, 0, 1);
24719         d22 = d0.plus(q2.times(d1));
24720         if (d22.comparedTo(md) == 1)
24721           break;
24722         d0 = d1;
24723         d1 = d22;
24724         n1 = n0.plus(q2.times(d22 = n1));
24725         n0 = d22;
24726         d2 = n3.minus(q2.times(d22 = d2));
24727         n3 = d22;
24728       }
24729       d22 = div(md.minus(d0), d1, 0, 1);
24730       n0 = n0.plus(d22.times(n1));
24731       d0 = d0.plus(d22.times(d1));
24732       n0.s = n1.s = x2.s;
24733       e3 = e3 * 2;
24734       r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo(
24735         div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs()
24736       ) < 1 ? [n1, d1] : [n0, d0];
24737       MAX_EXP = exp2;
24738       return r2;
24739     };
24740     P2.toNumber = function() {
24741       return +valueOf(this);
24742     };
24743     P2.toPrecision = function(sd, rm) {
24744       if (sd != null)
24745         intCheck(sd, 1, MAX);
24746       return format2(this, sd, rm, 2);
24747     };
24748     P2.toString = function(b2) {
24749       var str, n3 = this, s2 = n3.s, e3 = n3.e;
24750       if (e3 === null) {
24751         if (s2) {
24752           str = "Infinity";
24753           if (s2 < 0)
24754             str = "-" + str;
24755         } else {
24756           str = "NaN";
24757         }
24758       } else {
24759         if (b2 == null) {
24760           str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0");
24761         } else if (b2 === 10 && alphabetHasNormalDecimalDigits) {
24762           n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE);
24763           str = toFixedPoint(coeffToString(n3.c), n3.e, "0");
24764         } else {
24765           intCheck(b2, 2, ALPHABET.length, "Base");
24766           str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true);
24767         }
24768         if (s2 < 0 && n3.c[0])
24769           str = "-" + str;
24770       }
24771       return str;
24772     };
24773     P2.valueOf = P2.toJSON = function() {
24774       return valueOf(this);
24775     };
24776     P2._isBigNumber = true;
24777     P2[Symbol.toStringTag] = "BigNumber";
24778     P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf;
24779     if (configObject != null)
24780       BigNumber2.set(configObject);
24781     return BigNumber2;
24782   }
24783   function bitFloor(n3) {
24784     var i3 = n3 | 0;
24785     return n3 > 0 || n3 === i3 ? i3 : i3 - 1;
24786   }
24787   function coeffToString(a2) {
24788     var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + "";
24789     for (; i3 < j2; ) {
24790       s2 = a2[i3++] + "";
24791       z2 = LOG_BASE - s2.length;
24792       for (; z2--; s2 = "0" + s2)
24793         ;
24794       r2 += s2;
24795     }
24796     for (j2 = r2.length; r2.charCodeAt(--j2) === 48; )
24797       ;
24798     return r2.slice(0, j2 + 1 || 1);
24799   }
24800   function compare(x2, y2) {
24801     var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e;
24802     if (!i3 || !j2)
24803       return null;
24804     a2 = xc && !xc[0];
24805     b2 = yc && !yc[0];
24806     if (a2 || b2)
24807       return a2 ? b2 ? 0 : -j2 : i3;
24808     if (i3 != j2)
24809       return i3;
24810     a2 = i3 < 0;
24811     b2 = k2 == l2;
24812     if (!xc || !yc)
24813       return b2 ? 0 : !xc ^ a2 ? 1 : -1;
24814     if (!b2)
24815       return k2 > l2 ^ a2 ? 1 : -1;
24816     j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2;
24817     for (i3 = 0; i3 < j2; i3++)
24818       if (xc[i3] != yc[i3])
24819         return xc[i3] > yc[i3] ^ a2 ? 1 : -1;
24820     return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1;
24821   }
24822   function intCheck(n3, min3, max3, name) {
24823     if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) {
24824       throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3));
24825     }
24826   }
24827   function isOdd(n3) {
24828     var k2 = n3.c.length - 1;
24829     return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0;
24830   }
24831   function toExponential(str, e3) {
24832     return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3;
24833   }
24834   function toFixedPoint(str, e3, z2) {
24835     var len, zs;
24836     if (e3 < 0) {
24837       for (zs = z2 + "."; ++e3; zs += z2)
24838         ;
24839       str = zs + str;
24840     } else {
24841       len = str.length;
24842       if (++e3 > len) {
24843         for (zs = z2, e3 -= len; --e3; zs += z2)
24844           ;
24845         str += zs;
24846       } else if (e3 < len) {
24847         str = str.slice(0, e3) + "." + str.slice(e3);
24848       }
24849     }
24850     return str;
24851   }
24852   var BigNumber = clone();
24853   var bignumber_default = BigNumber;
24854
24855   // node_modules/splaytree-ts/dist/index.js
24856   var SplayTreeNode = class {
24857     constructor(key) {
24858       __publicField(this, "key");
24859       __publicField(this, "left", null);
24860       __publicField(this, "right", null);
24861       this.key = key;
24862     }
24863   };
24864   var SplayTreeSetNode = class extends SplayTreeNode {
24865     constructor(key) {
24866       super(key);
24867     }
24868   };
24869   var SplayTree = class {
24870     constructor() {
24871       __publicField(this, "size", 0);
24872       __publicField(this, "modificationCount", 0);
24873       __publicField(this, "splayCount", 0);
24874     }
24875     splay(key) {
24876       const root3 = this.root;
24877       if (root3 == null) {
24878         this.compare(key, key);
24879         return -1;
24880       }
24881       let right = null;
24882       let newTreeRight = null;
24883       let left = null;
24884       let newTreeLeft = null;
24885       let current = root3;
24886       const compare2 = this.compare;
24887       let comp;
24888       while (true) {
24889         comp = compare2(current.key, key);
24890         if (comp > 0) {
24891           let currentLeft = current.left;
24892           if (currentLeft == null)
24893             break;
24894           comp = compare2(currentLeft.key, key);
24895           if (comp > 0) {
24896             current.left = currentLeft.right;
24897             currentLeft.right = current;
24898             current = currentLeft;
24899             currentLeft = current.left;
24900             if (currentLeft == null)
24901               break;
24902           }
24903           if (right == null) {
24904             newTreeRight = current;
24905           } else {
24906             right.left = current;
24907           }
24908           right = current;
24909           current = currentLeft;
24910         } else if (comp < 0) {
24911           let currentRight = current.right;
24912           if (currentRight == null)
24913             break;
24914           comp = compare2(currentRight.key, key);
24915           if (comp < 0) {
24916             current.right = currentRight.left;
24917             currentRight.left = current;
24918             current = currentRight;
24919             currentRight = current.right;
24920             if (currentRight == null)
24921               break;
24922           }
24923           if (left == null) {
24924             newTreeLeft = current;
24925           } else {
24926             left.right = current;
24927           }
24928           left = current;
24929           current = currentRight;
24930         } else {
24931           break;
24932         }
24933       }
24934       if (left != null) {
24935         left.right = current.left;
24936         current.left = newTreeLeft;
24937       }
24938       if (right != null) {
24939         right.left = current.right;
24940         current.right = newTreeRight;
24941       }
24942       if (this.root !== current) {
24943         this.root = current;
24944         this.splayCount++;
24945       }
24946       return comp;
24947     }
24948     splayMin(node) {
24949       let current = node;
24950       let nextLeft = current.left;
24951       while (nextLeft != null) {
24952         const left = nextLeft;
24953         current.left = left.right;
24954         left.right = current;
24955         current = left;
24956         nextLeft = current.left;
24957       }
24958       return current;
24959     }
24960     splayMax(node) {
24961       let current = node;
24962       let nextRight = current.right;
24963       while (nextRight != null) {
24964         const right = nextRight;
24965         current.right = right.left;
24966         right.left = current;
24967         current = right;
24968         nextRight = current.right;
24969       }
24970       return current;
24971     }
24972     _delete(key) {
24973       if (this.root == null)
24974         return null;
24975       const comp = this.splay(key);
24976       if (comp != 0)
24977         return null;
24978       let root3 = this.root;
24979       const result = root3;
24980       const left = root3.left;
24981       this.size--;
24982       if (left == null) {
24983         this.root = root3.right;
24984       } else {
24985         const right = root3.right;
24986         root3 = this.splayMax(left);
24987         root3.right = right;
24988         this.root = root3;
24989       }
24990       this.modificationCount++;
24991       return result;
24992     }
24993     addNewRoot(node, comp) {
24994       this.size++;
24995       this.modificationCount++;
24996       const root3 = this.root;
24997       if (root3 == null) {
24998         this.root = node;
24999         return;
25000       }
25001       if (comp < 0) {
25002         node.left = root3;
25003         node.right = root3.right;
25004         root3.right = null;
25005       } else {
25006         node.right = root3;
25007         node.left = root3.left;
25008         root3.left = null;
25009       }
25010       this.root = node;
25011     }
25012     _first() {
25013       const root3 = this.root;
25014       if (root3 == null)
25015         return null;
25016       this.root = this.splayMin(root3);
25017       return this.root;
25018     }
25019     _last() {
25020       const root3 = this.root;
25021       if (root3 == null)
25022         return null;
25023       this.root = this.splayMax(root3);
25024       return this.root;
25025     }
25026     clear() {
25027       this.root = null;
25028       this.size = 0;
25029       this.modificationCount++;
25030     }
25031     has(key) {
25032       return this.validKey(key) && this.splay(key) == 0;
25033     }
25034     defaultCompare() {
25035       return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
25036     }
25037     wrap() {
25038       return {
25039         getRoot: () => {
25040           return this.root;
25041         },
25042         setRoot: (root3) => {
25043           this.root = root3;
25044         },
25045         getSize: () => {
25046           return this.size;
25047         },
25048         getModificationCount: () => {
25049           return this.modificationCount;
25050         },
25051         getSplayCount: () => {
25052           return this.splayCount;
25053         },
25054         setSplayCount: (count) => {
25055           this.splayCount = count;
25056         },
25057         splay: (key) => {
25058           return this.splay(key);
25059         },
25060         has: (key) => {
25061           return this.has(key);
25062         }
25063       };
25064     }
25065   };
25066   var _a;
25067   var _SplayTreeSet = class _SplayTreeSet extends SplayTree {
25068     constructor(compare2, isValidKey) {
25069       super();
25070       __publicField(this, "root", null);
25071       __publicField(this, "compare");
25072       __publicField(this, "validKey");
25073       __publicField(this, _a, "[object Set]");
25074       this.compare = compare2 != null ? compare2 : this.defaultCompare();
25075       this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0;
25076     }
25077     delete(element) {
25078       if (!this.validKey(element))
25079         return false;
25080       return this._delete(element) != null;
25081     }
25082     deleteAll(elements) {
25083       for (const element of elements) {
25084         this.delete(element);
25085       }
25086     }
25087     forEach(f2) {
25088       const nodes = this[Symbol.iterator]();
25089       let result;
25090       while (result = nodes.next(), !result.done) {
25091         f2(result.value, result.value, this);
25092       }
25093     }
25094     add(element) {
25095       const compare2 = this.splay(element);
25096       if (compare2 != 0)
25097         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25098       return this;
25099     }
25100     addAndReturn(element) {
25101       const compare2 = this.splay(element);
25102       if (compare2 != 0)
25103         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25104       return this.root.key;
25105     }
25106     addAll(elements) {
25107       for (const element of elements) {
25108         this.add(element);
25109       }
25110     }
25111     isEmpty() {
25112       return this.root == null;
25113     }
25114     isNotEmpty() {
25115       return this.root != null;
25116     }
25117     single() {
25118       if (this.size == 0)
25119         throw "Bad state: No element";
25120       if (this.size > 1)
25121         throw "Bad state: Too many element";
25122       return this.root.key;
25123     }
25124     first() {
25125       if (this.size == 0)
25126         throw "Bad state: No element";
25127       return this._first().key;
25128     }
25129     last() {
25130       if (this.size == 0)
25131         throw "Bad state: No element";
25132       return this._last().key;
25133     }
25134     lastBefore(element) {
25135       if (element == null)
25136         throw "Invalid arguments(s)";
25137       if (this.root == null)
25138         return null;
25139       const comp = this.splay(element);
25140       if (comp < 0)
25141         return this.root.key;
25142       let node = this.root.left;
25143       if (node == null)
25144         return null;
25145       let nodeRight = node.right;
25146       while (nodeRight != null) {
25147         node = nodeRight;
25148         nodeRight = node.right;
25149       }
25150       return node.key;
25151     }
25152     firstAfter(element) {
25153       if (element == null)
25154         throw "Invalid arguments(s)";
25155       if (this.root == null)
25156         return null;
25157       const comp = this.splay(element);
25158       if (comp > 0)
25159         return this.root.key;
25160       let node = this.root.right;
25161       if (node == null)
25162         return null;
25163       let nodeLeft = node.left;
25164       while (nodeLeft != null) {
25165         node = nodeLeft;
25166         nodeLeft = node.left;
25167       }
25168       return node.key;
25169     }
25170     retainAll(elements) {
25171       const retainSet = new _SplayTreeSet(this.compare, this.validKey);
25172       const modificationCount = this.modificationCount;
25173       for (const object of elements) {
25174         if (modificationCount != this.modificationCount) {
25175           throw "Concurrent modification during iteration.";
25176         }
25177         if (this.validKey(object) && this.splay(object) == 0) {
25178           retainSet.add(this.root.key);
25179         }
25180       }
25181       if (retainSet.size != this.size) {
25182         this.root = retainSet.root;
25183         this.size = retainSet.size;
25184         this.modificationCount++;
25185       }
25186     }
25187     lookup(object) {
25188       if (!this.validKey(object))
25189         return null;
25190       const comp = this.splay(object);
25191       if (comp != 0)
25192         return null;
25193       return this.root.key;
25194     }
25195     intersection(other) {
25196       const result = new _SplayTreeSet(this.compare, this.validKey);
25197       for (const element of this) {
25198         if (other.has(element))
25199           result.add(element);
25200       }
25201       return result;
25202     }
25203     difference(other) {
25204       const result = new _SplayTreeSet(this.compare, this.validKey);
25205       for (const element of this) {
25206         if (!other.has(element))
25207           result.add(element);
25208       }
25209       return result;
25210     }
25211     union(other) {
25212       const u2 = this.clone();
25213       u2.addAll(other);
25214       return u2;
25215     }
25216     clone() {
25217       const set4 = new _SplayTreeSet(this.compare, this.validKey);
25218       set4.size = this.size;
25219       set4.root = this.copyNode(this.root);
25220       return set4;
25221     }
25222     copyNode(node) {
25223       if (node == null)
25224         return null;
25225       function copyChildren(node2, dest) {
25226         let left;
25227         let right;
25228         do {
25229           left = node2.left;
25230           right = node2.right;
25231           if (left != null) {
25232             const newLeft = new SplayTreeSetNode(left.key);
25233             dest.left = newLeft;
25234             copyChildren(left, newLeft);
25235           }
25236           if (right != null) {
25237             const newRight = new SplayTreeSetNode(right.key);
25238             dest.right = newRight;
25239             node2 = right;
25240             dest = newRight;
25241           }
25242         } while (right != null);
25243       }
25244       const result = new SplayTreeSetNode(node.key);
25245       copyChildren(node, result);
25246       return result;
25247     }
25248     toSet() {
25249       return this.clone();
25250     }
25251     entries() {
25252       return new SplayTreeSetEntryIterableIterator(this.wrap());
25253     }
25254     keys() {
25255       return this[Symbol.iterator]();
25256     }
25257     values() {
25258       return this[Symbol.iterator]();
25259     }
25260     [Symbol.iterator]() {
25261       return new SplayTreeKeyIterableIterator(this.wrap());
25262     }
25263   };
25264   _a = Symbol.toStringTag;
25265   var SplayTreeSet = _SplayTreeSet;
25266   var SplayTreeIterableIterator = class {
25267     constructor(tree) {
25268       __publicField(this, "tree");
25269       __publicField(this, "path", new Array());
25270       __publicField(this, "modificationCount", null);
25271       __publicField(this, "splayCount");
25272       this.tree = tree;
25273       this.splayCount = tree.getSplayCount();
25274     }
25275     [Symbol.iterator]() {
25276       return this;
25277     }
25278     next() {
25279       if (this.moveNext())
25280         return { done: false, value: this.current() };
25281       return { done: true, value: null };
25282     }
25283     current() {
25284       if (!this.path.length)
25285         return null;
25286       const node = this.path[this.path.length - 1];
25287       return this.getValue(node);
25288     }
25289     rebuildPath(key) {
25290       this.path.splice(0, this.path.length);
25291       this.tree.splay(key);
25292       this.path.push(this.tree.getRoot());
25293       this.splayCount = this.tree.getSplayCount();
25294     }
25295     findLeftMostDescendent(node) {
25296       while (node != null) {
25297         this.path.push(node);
25298         node = node.left;
25299       }
25300     }
25301     moveNext() {
25302       if (this.modificationCount != this.tree.getModificationCount()) {
25303         if (this.modificationCount == null) {
25304           this.modificationCount = this.tree.getModificationCount();
25305           let node2 = this.tree.getRoot();
25306           while (node2 != null) {
25307             this.path.push(node2);
25308             node2 = node2.left;
25309           }
25310           return this.path.length > 0;
25311         }
25312         throw "Concurrent modification during iteration.";
25313       }
25314       if (!this.path.length)
25315         return false;
25316       if (this.splayCount != this.tree.getSplayCount()) {
25317         this.rebuildPath(this.path[this.path.length - 1].key);
25318       }
25319       let node = this.path[this.path.length - 1];
25320       let next = node.right;
25321       if (next != null) {
25322         while (next != null) {
25323           this.path.push(next);
25324           next = next.left;
25325         }
25326         return true;
25327       }
25328       this.path.pop();
25329       while (this.path.length && this.path[this.path.length - 1].right === node) {
25330         node = this.path.pop();
25331       }
25332       return this.path.length > 0;
25333     }
25334   };
25335   var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator {
25336     getValue(node) {
25337       return node.key;
25338     }
25339   };
25340   var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator {
25341     getValue(node) {
25342       return [node.key, node.key];
25343     }
25344   };
25345
25346   // node_modules/polyclip-ts/dist/identity.js
25347   var identity_default3 = (x2) => {
25348     return x2;
25349   };
25350
25351   // node_modules/polyclip-ts/dist/snap.js
25352   var snap_default = (eps) => {
25353     if (eps) {
25354       const xTree = new SplayTreeSet(compare_default(eps));
25355       const yTree = new SplayTreeSet(compare_default(eps));
25356       const snapCoord = (coord2, tree) => {
25357         return tree.addAndReturn(coord2);
25358       };
25359       const snap = (v2) => {
25360         return {
25361           x: snapCoord(v2.x, xTree),
25362           y: snapCoord(v2.y, yTree)
25363         };
25364       };
25365       snap({ x: new bignumber_default(0), y: new bignumber_default(0) });
25366       return snap;
25367     }
25368     return identity_default3;
25369   };
25370
25371   // node_modules/polyclip-ts/dist/precision.js
25372   var set3 = (eps) => {
25373     return {
25374       set: (eps2) => {
25375         precision = set3(eps2);
25376       },
25377       reset: () => set3(eps),
25378       compare: compare_default(eps),
25379       snap: snap_default(eps),
25380       orient: orient_default(eps)
25381     };
25382   };
25383   var precision = set3();
25384
25385   // node_modules/polyclip-ts/dist/bbox.js
25386   var isInBbox = (bbox2, point2) => {
25387     return bbox2.ll.x.isLessThanOrEqualTo(point2.x) && point2.x.isLessThanOrEqualTo(bbox2.ur.x) && bbox2.ll.y.isLessThanOrEqualTo(point2.y) && point2.y.isLessThanOrEqualTo(bbox2.ur.y);
25388   };
25389   var getBboxOverlap = (b1, b2) => {
25390     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))
25391       return null;
25392     const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x;
25393     const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x;
25394     const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y;
25395     const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y;
25396     return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } };
25397   };
25398
25399   // node_modules/polyclip-ts/dist/vector.js
25400   var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x));
25401   var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y));
25402   var length = (v2) => dotProduct(v2, v2).sqrt();
25403   var sineOfAngle = (pShared, pBase, pAngle) => {
25404     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25405     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25406     return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25407   };
25408   var cosineOfAngle = (pShared, pBase, pAngle) => {
25409     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25410     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25411     return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25412   };
25413   var horizontalIntersection = (pt2, v2, y2) => {
25414     if (v2.y.isZero())
25415       return null;
25416     return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 };
25417   };
25418   var verticalIntersection = (pt2, v2, x2) => {
25419     if (v2.x.isZero())
25420       return null;
25421     return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) };
25422   };
25423   var intersection = (pt1, v1, pt2, v2) => {
25424     if (v1.x.isZero())
25425       return verticalIntersection(pt2, v2, pt1.x);
25426     if (v2.x.isZero())
25427       return verticalIntersection(pt1, v1, pt2.x);
25428     if (v1.y.isZero())
25429       return horizontalIntersection(pt2, v2, pt1.y);
25430     if (v2.y.isZero())
25431       return horizontalIntersection(pt1, v1, pt2.y);
25432     const kross = crossProduct(v1, v2);
25433     if (kross.isZero())
25434       return null;
25435     const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) };
25436     const d1 = crossProduct(ve2, v1).div(kross);
25437     const d2 = crossProduct(ve2, v2).div(kross);
25438     const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x));
25439     const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y));
25440     const x3 = x12.plus(x2).div(2);
25441     const y3 = y12.plus(y2).div(2);
25442     return { x: x3, y: y3 };
25443   };
25444
25445   // node_modules/polyclip-ts/dist/sweep-event.js
25446   var SweepEvent = class _SweepEvent {
25447     // Warning: 'point' input will be modified and re-used (for performance)
25448     constructor(point2, isLeft) {
25449       __publicField(this, "point");
25450       __publicField(this, "isLeft");
25451       __publicField(this, "segment");
25452       __publicField(this, "otherSE");
25453       __publicField(this, "consumedBy");
25454       if (point2.events === void 0)
25455         point2.events = [this];
25456       else
25457         point2.events.push(this);
25458       this.point = point2;
25459       this.isLeft = isLeft;
25460     }
25461     // for ordering sweep events in the sweep event queue
25462     static compare(a2, b2) {
25463       const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point);
25464       if (ptCmp !== 0)
25465         return ptCmp;
25466       if (a2.point !== b2.point)
25467         a2.link(b2);
25468       if (a2.isLeft !== b2.isLeft)
25469         return a2.isLeft ? 1 : -1;
25470       return Segment.compare(a2.segment, b2.segment);
25471     }
25472     // for ordering points in sweep line order
25473     static comparePoints(aPt, bPt) {
25474       if (aPt.x.isLessThan(bPt.x))
25475         return -1;
25476       if (aPt.x.isGreaterThan(bPt.x))
25477         return 1;
25478       if (aPt.y.isLessThan(bPt.y))
25479         return -1;
25480       if (aPt.y.isGreaterThan(bPt.y))
25481         return 1;
25482       return 0;
25483     }
25484     link(other) {
25485       if (other.point === this.point) {
25486         throw new Error("Tried to link already linked events");
25487       }
25488       const otherEvents = other.point.events;
25489       for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
25490         const evt = otherEvents[i3];
25491         this.point.events.push(evt);
25492         evt.point = this.point;
25493       }
25494       this.checkForConsuming();
25495     }
25496     /* Do a pass over our linked events and check to see if any pair
25497      * of segments match, and should be consumed. */
25498     checkForConsuming() {
25499       const numEvents = this.point.events.length;
25500       for (let i3 = 0; i3 < numEvents; i3++) {
25501         const evt1 = this.point.events[i3];
25502         if (evt1.segment.consumedBy !== void 0)
25503           continue;
25504         for (let j2 = i3 + 1; j2 < numEvents; j2++) {
25505           const evt2 = this.point.events[j2];
25506           if (evt2.consumedBy !== void 0)
25507             continue;
25508           if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
25509             continue;
25510           evt1.segment.consume(evt2.segment);
25511         }
25512       }
25513     }
25514     getAvailableLinkedEvents() {
25515       const events = [];
25516       for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
25517         const evt = this.point.events[i3];
25518         if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
25519           events.push(evt);
25520         }
25521       }
25522       return events;
25523     }
25524     /**
25525      * Returns a comparator function for sorting linked events that will
25526      * favor the event that will give us the smallest left-side angle.
25527      * All ring construction starts as low as possible heading to the right,
25528      * so by always turning left as sharp as possible we'll get polygons
25529      * without uncessary loops & holes.
25530      *
25531      * The comparator function has a compute cache such that it avoids
25532      * re-computing already-computed values.
25533      */
25534     getLeftmostComparator(baseEvent) {
25535       const cache = /* @__PURE__ */ new Map();
25536       const fillCache = (linkedEvent) => {
25537         const nextEvent = linkedEvent.otherSE;
25538         cache.set(linkedEvent, {
25539           sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
25540           cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
25541         });
25542       };
25543       return (a2, b2) => {
25544         if (!cache.has(a2))
25545           fillCache(a2);
25546         if (!cache.has(b2))
25547           fillCache(b2);
25548         const { sine: asine, cosine: acosine } = cache.get(a2);
25549         const { sine: bsine, cosine: bcosine } = cache.get(b2);
25550         if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) {
25551           if (acosine.isLessThan(bcosine))
25552             return 1;
25553           if (acosine.isGreaterThan(bcosine))
25554             return -1;
25555           return 0;
25556         }
25557         if (asine.isLessThan(0) && bsine.isLessThan(0)) {
25558           if (acosine.isLessThan(bcosine))
25559             return -1;
25560           if (acosine.isGreaterThan(bcosine))
25561             return 1;
25562           return 0;
25563         }
25564         if (bsine.isLessThan(asine))
25565           return -1;
25566         if (bsine.isGreaterThan(asine))
25567           return 1;
25568         return 0;
25569       };
25570     }
25571   };
25572
25573   // node_modules/polyclip-ts/dist/segment.js
25574   var segmentId = 0;
25575   var Segment = class _Segment {
25576     /* Warning: a reference to ringWindings input will be stored,
25577      *  and possibly will be later modified */
25578     constructor(leftSE, rightSE, rings, windings) {
25579       __publicField(this, "id");
25580       __publicField(this, "leftSE");
25581       __publicField(this, "rightSE");
25582       __publicField(this, "rings");
25583       __publicField(this, "windings");
25584       __publicField(this, "ringOut");
25585       __publicField(this, "consumedBy");
25586       __publicField(this, "prev");
25587       __publicField(this, "_prevInResult");
25588       __publicField(this, "_beforeState");
25589       __publicField(this, "_afterState");
25590       __publicField(this, "_isInResult");
25591       this.id = ++segmentId;
25592       this.leftSE = leftSE;
25593       leftSE.segment = this;
25594       leftSE.otherSE = rightSE;
25595       this.rightSE = rightSE;
25596       rightSE.segment = this;
25597       rightSE.otherSE = leftSE;
25598       this.rings = rings;
25599       this.windings = windings;
25600     }
25601     /* This compare() function is for ordering segments in the sweep
25602      * line tree, and does so according to the following criteria:
25603      *
25604      * Consider the vertical line that lies an infinestimal step to the
25605      * right of the right-more of the two left endpoints of the input
25606      * segments. Imagine slowly moving a point up from negative infinity
25607      * in the increasing y direction. Which of the two segments will that
25608      * point intersect first? That segment comes 'before' the other one.
25609      *
25610      * If neither segment would be intersected by such a line, (if one
25611      * or more of the segments are vertical) then the line to be considered
25612      * is directly on the right-more of the two left inputs.
25613      */
25614     static compare(a2, b2) {
25615       const alx = a2.leftSE.point.x;
25616       const blx = b2.leftSE.point.x;
25617       const arx = a2.rightSE.point.x;
25618       const brx = b2.rightSE.point.x;
25619       if (brx.isLessThan(alx))
25620         return 1;
25621       if (arx.isLessThan(blx))
25622         return -1;
25623       const aly = a2.leftSE.point.y;
25624       const bly = b2.leftSE.point.y;
25625       const ary = a2.rightSE.point.y;
25626       const bry = b2.rightSE.point.y;
25627       if (alx.isLessThan(blx)) {
25628         if (bly.isLessThan(aly) && bly.isLessThan(ary))
25629           return 1;
25630         if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary))
25631           return -1;
25632         const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
25633         if (aCmpBLeft < 0)
25634           return 1;
25635         if (aCmpBLeft > 0)
25636           return -1;
25637         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25638         if (bCmpARight !== 0)
25639           return bCmpARight;
25640         return -1;
25641       }
25642       if (alx.isGreaterThan(blx)) {
25643         if (aly.isLessThan(bly) && aly.isLessThan(bry))
25644           return -1;
25645         if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry))
25646           return 1;
25647         const bCmpALeft = b2.comparePoint(a2.leftSE.point);
25648         if (bCmpALeft !== 0)
25649           return bCmpALeft;
25650         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25651         if (aCmpBRight < 0)
25652           return 1;
25653         if (aCmpBRight > 0)
25654           return -1;
25655         return 1;
25656       }
25657       if (aly.isLessThan(bly))
25658         return -1;
25659       if (aly.isGreaterThan(bly))
25660         return 1;
25661       if (arx.isLessThan(brx)) {
25662         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25663         if (bCmpARight !== 0)
25664           return bCmpARight;
25665       }
25666       if (arx.isGreaterThan(brx)) {
25667         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25668         if (aCmpBRight < 0)
25669           return 1;
25670         if (aCmpBRight > 0)
25671           return -1;
25672       }
25673       if (!arx.eq(brx)) {
25674         const ay = ary.minus(aly);
25675         const ax = arx.minus(alx);
25676         const by = bry.minus(bly);
25677         const bx = brx.minus(blx);
25678         if (ay.isGreaterThan(ax) && by.isLessThan(bx))
25679           return 1;
25680         if (ay.isLessThan(ax) && by.isGreaterThan(bx))
25681           return -1;
25682       }
25683       if (arx.isGreaterThan(brx))
25684         return 1;
25685       if (arx.isLessThan(brx))
25686         return -1;
25687       if (ary.isLessThan(bry))
25688         return -1;
25689       if (ary.isGreaterThan(bry))
25690         return 1;
25691       if (a2.id < b2.id)
25692         return -1;
25693       if (a2.id > b2.id)
25694         return 1;
25695       return 0;
25696     }
25697     static fromRing(pt1, pt2, ring) {
25698       let leftPt, rightPt, winding;
25699       const cmpPts = SweepEvent.comparePoints(pt1, pt2);
25700       if (cmpPts < 0) {
25701         leftPt = pt1;
25702         rightPt = pt2;
25703         winding = 1;
25704       } else if (cmpPts > 0) {
25705         leftPt = pt2;
25706         rightPt = pt1;
25707         winding = -1;
25708       } else
25709         throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
25710       const leftSE = new SweepEvent(leftPt, true);
25711       const rightSE = new SweepEvent(rightPt, false);
25712       return new _Segment(leftSE, rightSE, [ring], [winding]);
25713     }
25714     /* When a segment is split, the rightSE is replaced with a new sweep event */
25715     replaceRightSE(newRightSE) {
25716       this.rightSE = newRightSE;
25717       this.rightSE.segment = this;
25718       this.rightSE.otherSE = this.leftSE;
25719       this.leftSE.otherSE = this.rightSE;
25720     }
25721     bbox() {
25722       const y12 = this.leftSE.point.y;
25723       const y2 = this.rightSE.point.y;
25724       return {
25725         ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 },
25726         ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 }
25727       };
25728     }
25729     /* A vector from the left point to the right */
25730     vector() {
25731       return {
25732         x: this.rightSE.point.x.minus(this.leftSE.point.x),
25733         y: this.rightSE.point.y.minus(this.leftSE.point.y)
25734       };
25735     }
25736     isAnEndpoint(pt2) {
25737       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);
25738     }
25739     /* Compare this segment with a point.
25740      *
25741      * A point P is considered to be colinear to a segment if there
25742      * exists a distance D such that if we travel along the segment
25743      * from one * endpoint towards the other a distance D, we find
25744      * ourselves at point P.
25745      *
25746      * Return value indicates:
25747      *
25748      *   1: point lies above the segment (to the left of vertical)
25749      *   0: point is colinear to segment
25750      *  -1: point lies below the segment (to the right of vertical)
25751      */
25752     comparePoint(point2) {
25753       return precision.orient(this.leftSE.point, point2, this.rightSE.point);
25754     }
25755     /**
25756      * Given another segment, returns the first non-trivial intersection
25757      * between the two segments (in terms of sweep line ordering), if it exists.
25758      *
25759      * A 'non-trivial' intersection is one that will cause one or both of the
25760      * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
25761      *
25762      *   * endpoint of segA with endpoint of segB --> trivial
25763      *   * endpoint of segA with point along segB --> non-trivial
25764      *   * endpoint of segB with point along segA --> non-trivial
25765      *   * point along segA with point along segB --> non-trivial
25766      *
25767      * If no non-trivial intersection exists, return null
25768      * Else, return null.
25769      */
25770     getIntersection(other) {
25771       const tBbox = this.bbox();
25772       const oBbox = other.bbox();
25773       const bboxOverlap = getBboxOverlap(tBbox, oBbox);
25774       if (bboxOverlap === null)
25775         return null;
25776       const tlp = this.leftSE.point;
25777       const trp = this.rightSE.point;
25778       const olp = other.leftSE.point;
25779       const orp = other.rightSE.point;
25780       const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
25781       const touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0;
25782       const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
25783       const touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0;
25784       if (touchesThisLSE && touchesOtherLSE) {
25785         if (touchesThisRSE && !touchesOtherRSE)
25786           return trp;
25787         if (!touchesThisRSE && touchesOtherRSE)
25788           return orp;
25789         return null;
25790       }
25791       if (touchesThisLSE) {
25792         if (touchesOtherRSE) {
25793           if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y))
25794             return null;
25795         }
25796         return tlp;
25797       }
25798       if (touchesOtherLSE) {
25799         if (touchesThisRSE) {
25800           if (trp.x.eq(olp.x) && trp.y.eq(olp.y))
25801             return null;
25802         }
25803         return olp;
25804       }
25805       if (touchesThisRSE && touchesOtherRSE)
25806         return null;
25807       if (touchesThisRSE)
25808         return trp;
25809       if (touchesOtherRSE)
25810         return orp;
25811       const pt2 = intersection(tlp, this.vector(), olp, other.vector());
25812       if (pt2 === null)
25813         return null;
25814       if (!isInBbox(bboxOverlap, pt2))
25815         return null;
25816       return precision.snap(pt2);
25817     }
25818     /**
25819      * Split the given segment into multiple segments on the given points.
25820      *  * Each existing segment will retain its leftSE and a new rightSE will be
25821      *    generated for it.
25822      *  * A new segment will be generated which will adopt the original segment's
25823      *    rightSE, and a new leftSE will be generated for it.
25824      *  * If there are more than two points given to split on, new segments
25825      *    in the middle will be generated with new leftSE and rightSE's.
25826      *  * An array of the newly generated SweepEvents will be returned.
25827      *
25828      * Warning: input array of points is modified
25829      */
25830     split(point2) {
25831       const newEvents = [];
25832       const alreadyLinked = point2.events !== void 0;
25833       const newLeftSE = new SweepEvent(point2, true);
25834       const newRightSE = new SweepEvent(point2, false);
25835       const oldRightSE = this.rightSE;
25836       this.replaceRightSE(newRightSE);
25837       newEvents.push(newRightSE);
25838       newEvents.push(newLeftSE);
25839       const newSeg = new _Segment(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
25840       if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
25841         newSeg.swapEvents();
25842       }
25843       if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
25844         this.swapEvents();
25845       }
25846       if (alreadyLinked) {
25847         newLeftSE.checkForConsuming();
25848         newRightSE.checkForConsuming();
25849       }
25850       return newEvents;
25851     }
25852     /* Swap which event is left and right */
25853     swapEvents() {
25854       const tmpEvt = this.rightSE;
25855       this.rightSE = this.leftSE;
25856       this.leftSE = tmpEvt;
25857       this.leftSE.isLeft = true;
25858       this.rightSE.isLeft = false;
25859       for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
25860         this.windings[i3] *= -1;
25861       }
25862     }
25863     /* Consume another segment. We take their rings under our wing
25864      * and mark them as consumed. Use for perfectly overlapping segments */
25865     consume(other) {
25866       let consumer = this;
25867       let consumee = other;
25868       while (consumer.consumedBy)
25869         consumer = consumer.consumedBy;
25870       while (consumee.consumedBy)
25871         consumee = consumee.consumedBy;
25872       const cmp = _Segment.compare(consumer, consumee);
25873       if (cmp === 0)
25874         return;
25875       if (cmp > 0) {
25876         const tmp = consumer;
25877         consumer = consumee;
25878         consumee = tmp;
25879       }
25880       if (consumer.prev === consumee) {
25881         const tmp = consumer;
25882         consumer = consumee;
25883         consumee = tmp;
25884       }
25885       for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
25886         const ring = consumee.rings[i3];
25887         const winding = consumee.windings[i3];
25888         const index = consumer.rings.indexOf(ring);
25889         if (index === -1) {
25890           consumer.rings.push(ring);
25891           consumer.windings.push(winding);
25892         } else
25893           consumer.windings[index] += winding;
25894       }
25895       consumee.rings = null;
25896       consumee.windings = null;
25897       consumee.consumedBy = consumer;
25898       consumee.leftSE.consumedBy = consumer.leftSE;
25899       consumee.rightSE.consumedBy = consumer.rightSE;
25900     }
25901     /* The first segment previous segment chain that is in the result */
25902     prevInResult() {
25903       if (this._prevInResult !== void 0)
25904         return this._prevInResult;
25905       if (!this.prev)
25906         this._prevInResult = null;
25907       else if (this.prev.isInResult())
25908         this._prevInResult = this.prev;
25909       else
25910         this._prevInResult = this.prev.prevInResult();
25911       return this._prevInResult;
25912     }
25913     beforeState() {
25914       if (this._beforeState !== void 0)
25915         return this._beforeState;
25916       if (!this.prev)
25917         this._beforeState = {
25918           rings: [],
25919           windings: [],
25920           multiPolys: []
25921         };
25922       else {
25923         const seg = this.prev.consumedBy || this.prev;
25924         this._beforeState = seg.afterState();
25925       }
25926       return this._beforeState;
25927     }
25928     afterState() {
25929       if (this._afterState !== void 0)
25930         return this._afterState;
25931       const beforeState = this.beforeState();
25932       this._afterState = {
25933         rings: beforeState.rings.slice(0),
25934         windings: beforeState.windings.slice(0),
25935         multiPolys: []
25936       };
25937       const ringsAfter = this._afterState.rings;
25938       const windingsAfter = this._afterState.windings;
25939       const mpsAfter = this._afterState.multiPolys;
25940       for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
25941         const ring = this.rings[i3];
25942         const winding = this.windings[i3];
25943         const index = ringsAfter.indexOf(ring);
25944         if (index === -1) {
25945           ringsAfter.push(ring);
25946           windingsAfter.push(winding);
25947         } else
25948           windingsAfter[index] += winding;
25949       }
25950       const polysAfter = [];
25951       const polysExclude = [];
25952       for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
25953         if (windingsAfter[i3] === 0)
25954           continue;
25955         const ring = ringsAfter[i3];
25956         const poly = ring.poly;
25957         if (polysExclude.indexOf(poly) !== -1)
25958           continue;
25959         if (ring.isExterior)
25960           polysAfter.push(poly);
25961         else {
25962           if (polysExclude.indexOf(poly) === -1)
25963             polysExclude.push(poly);
25964           const index = polysAfter.indexOf(ring.poly);
25965           if (index !== -1)
25966             polysAfter.splice(index, 1);
25967         }
25968       }
25969       for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
25970         const mp = polysAfter[i3].multiPoly;
25971         if (mpsAfter.indexOf(mp) === -1)
25972           mpsAfter.push(mp);
25973       }
25974       return this._afterState;
25975     }
25976     /* Is this segment part of the final result? */
25977     isInResult() {
25978       if (this.consumedBy)
25979         return false;
25980       if (this._isInResult !== void 0)
25981         return this._isInResult;
25982       const mpsBefore = this.beforeState().multiPolys;
25983       const mpsAfter = this.afterState().multiPolys;
25984       switch (operation_default.type) {
25985         case "union": {
25986           const noBefores = mpsBefore.length === 0;
25987           const noAfters = mpsAfter.length === 0;
25988           this._isInResult = noBefores !== noAfters;
25989           break;
25990         }
25991         case "intersection": {
25992           let least;
25993           let most;
25994           if (mpsBefore.length < mpsAfter.length) {
25995             least = mpsBefore.length;
25996             most = mpsAfter.length;
25997           } else {
25998             least = mpsAfter.length;
25999             most = mpsBefore.length;
26000           }
26001           this._isInResult = most === operation_default.numMultiPolys && least < most;
26002           break;
26003         }
26004         case "xor": {
26005           const diff = Math.abs(mpsBefore.length - mpsAfter.length);
26006           this._isInResult = diff % 2 === 1;
26007           break;
26008         }
26009         case "difference": {
26010           const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
26011           this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
26012           break;
26013         }
26014       }
26015       return this._isInResult;
26016     }
26017   };
26018
26019   // node_modules/polyclip-ts/dist/geom-in.js
26020   var RingIn = class {
26021     constructor(geomRing, poly, isExterior) {
26022       __publicField(this, "poly");
26023       __publicField(this, "isExterior");
26024       __publicField(this, "segments");
26025       __publicField(this, "bbox");
26026       if (!Array.isArray(geomRing) || geomRing.length === 0) {
26027         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26028       }
26029       this.poly = poly;
26030       this.isExterior = isExterior;
26031       this.segments = [];
26032       if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
26033         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26034       }
26035       const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) });
26036       this.bbox = {
26037         ll: { x: firstPoint.x, y: firstPoint.y },
26038         ur: { x: firstPoint.x, y: firstPoint.y }
26039       };
26040       let prevPoint = firstPoint;
26041       for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
26042         if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
26043           throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26044         }
26045         const point2 = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) });
26046         if (point2.x.eq(prevPoint.x) && point2.y.eq(prevPoint.y))
26047           continue;
26048         this.segments.push(Segment.fromRing(prevPoint, point2, this));
26049         if (point2.x.isLessThan(this.bbox.ll.x))
26050           this.bbox.ll.x = point2.x;
26051         if (point2.y.isLessThan(this.bbox.ll.y))
26052           this.bbox.ll.y = point2.y;
26053         if (point2.x.isGreaterThan(this.bbox.ur.x))
26054           this.bbox.ur.x = point2.x;
26055         if (point2.y.isGreaterThan(this.bbox.ur.y))
26056           this.bbox.ur.y = point2.y;
26057         prevPoint = point2;
26058       }
26059       if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) {
26060         this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
26061       }
26062     }
26063     getSweepEvents() {
26064       const sweepEvents = [];
26065       for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
26066         const segment = this.segments[i3];
26067         sweepEvents.push(segment.leftSE);
26068         sweepEvents.push(segment.rightSE);
26069       }
26070       return sweepEvents;
26071     }
26072   };
26073   var PolyIn = class {
26074     constructor(geomPoly, multiPoly) {
26075       __publicField(this, "multiPoly");
26076       __publicField(this, "exteriorRing");
26077       __publicField(this, "interiorRings");
26078       __publicField(this, "bbox");
26079       if (!Array.isArray(geomPoly)) {
26080         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26081       }
26082       this.exteriorRing = new RingIn(geomPoly[0], this, true);
26083       this.bbox = {
26084         ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
26085         ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
26086       };
26087       this.interiorRings = [];
26088       for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
26089         const ring = new RingIn(geomPoly[i3], this, false);
26090         if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x))
26091           this.bbox.ll.x = ring.bbox.ll.x;
26092         if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y))
26093           this.bbox.ll.y = ring.bbox.ll.y;
26094         if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26095           this.bbox.ur.x = ring.bbox.ur.x;
26096         if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26097           this.bbox.ur.y = ring.bbox.ur.y;
26098         this.interiorRings.push(ring);
26099       }
26100       this.multiPoly = multiPoly;
26101     }
26102     getSweepEvents() {
26103       const sweepEvents = this.exteriorRing.getSweepEvents();
26104       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26105         const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
26106         for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
26107           sweepEvents.push(ringSweepEvents[j2]);
26108         }
26109       }
26110       return sweepEvents;
26111     }
26112   };
26113   var MultiPolyIn = class {
26114     constructor(geom, isSubject) {
26115       __publicField(this, "isSubject");
26116       __publicField(this, "polys");
26117       __publicField(this, "bbox");
26118       if (!Array.isArray(geom)) {
26119         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26120       }
26121       try {
26122         if (typeof geom[0][0][0] === "number")
26123           geom = [geom];
26124       } catch (ex) {
26125       }
26126       this.polys = [];
26127       this.bbox = {
26128         ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) },
26129         ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) }
26130       };
26131       for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
26132         const poly = new PolyIn(geom[i3], this);
26133         if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x))
26134           this.bbox.ll.x = poly.bbox.ll.x;
26135         if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y))
26136           this.bbox.ll.y = poly.bbox.ll.y;
26137         if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26138           this.bbox.ur.x = poly.bbox.ur.x;
26139         if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26140           this.bbox.ur.y = poly.bbox.ur.y;
26141         this.polys.push(poly);
26142       }
26143       this.isSubject = isSubject;
26144     }
26145     getSweepEvents() {
26146       const sweepEvents = [];
26147       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26148         const polySweepEvents = this.polys[i3].getSweepEvents();
26149         for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
26150           sweepEvents.push(polySweepEvents[j2]);
26151         }
26152       }
26153       return sweepEvents;
26154     }
26155   };
26156
26157   // node_modules/polyclip-ts/dist/geom-out.js
26158   var RingOut = class _RingOut {
26159     constructor(events) {
26160       __publicField(this, "events");
26161       __publicField(this, "poly");
26162       __publicField(this, "_isExteriorRing");
26163       __publicField(this, "_enclosingRing");
26164       this.events = events;
26165       for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
26166         events[i3].segment.ringOut = this;
26167       }
26168       this.poly = null;
26169     }
26170     /* Given the segments from the sweep line pass, compute & return a series
26171      * of closed rings from all the segments marked to be part of the result */
26172     static factory(allSegments) {
26173       const ringsOut = [];
26174       for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
26175         const segment = allSegments[i3];
26176         if (!segment.isInResult() || segment.ringOut)
26177           continue;
26178         let prevEvent = null;
26179         let event = segment.leftSE;
26180         let nextEvent = segment.rightSE;
26181         const events = [event];
26182         const startingPoint = event.point;
26183         const intersectionLEs = [];
26184         while (true) {
26185           prevEvent = event;
26186           event = nextEvent;
26187           events.push(event);
26188           if (event.point === startingPoint)
26189             break;
26190           while (true) {
26191             const availableLEs = event.getAvailableLinkedEvents();
26192             if (availableLEs.length === 0) {
26193               const firstPt = events[0].point;
26194               const lastPt = events[events.length - 1].point;
26195               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, "]."));
26196             }
26197             if (availableLEs.length === 1) {
26198               nextEvent = availableLEs[0].otherSE;
26199               break;
26200             }
26201             let indexLE = null;
26202             for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
26203               if (intersectionLEs[j2].point === event.point) {
26204                 indexLE = j2;
26205                 break;
26206               }
26207             }
26208             if (indexLE !== null) {
26209               const intersectionLE = intersectionLEs.splice(indexLE)[0];
26210               const ringEvents = events.splice(intersectionLE.index);
26211               ringEvents.unshift(ringEvents[0].otherSE);
26212               ringsOut.push(new _RingOut(ringEvents.reverse()));
26213               continue;
26214             }
26215             intersectionLEs.push({
26216               index: events.length,
26217               point: event.point
26218             });
26219             const comparator = event.getLeftmostComparator(prevEvent);
26220             nextEvent = availableLEs.sort(comparator)[0].otherSE;
26221             break;
26222           }
26223         }
26224         ringsOut.push(new _RingOut(events));
26225       }
26226       return ringsOut;
26227     }
26228     getGeom() {
26229       let prevPt = this.events[0].point;
26230       const points = [prevPt];
26231       for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
26232         const pt3 = this.events[i3].point;
26233         const nextPt2 = this.events[i3 + 1].point;
26234         if (precision.orient(pt3, prevPt, nextPt2) === 0)
26235           continue;
26236         points.push(pt3);
26237         prevPt = pt3;
26238       }
26239       if (points.length === 1)
26240         return null;
26241       const pt2 = points[0];
26242       const nextPt = points[1];
26243       if (precision.orient(pt2, prevPt, nextPt) === 0)
26244         points.shift();
26245       points.push(points[0]);
26246       const step = this.isExteriorRing() ? 1 : -1;
26247       const iStart = this.isExteriorRing() ? 0 : points.length - 1;
26248       const iEnd = this.isExteriorRing() ? points.length : -1;
26249       const orderedPoints = [];
26250       for (let i3 = iStart; i3 != iEnd; i3 += step)
26251         orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]);
26252       return orderedPoints;
26253     }
26254     isExteriorRing() {
26255       if (this._isExteriorRing === void 0) {
26256         const enclosing = this.enclosingRing();
26257         this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
26258       }
26259       return this._isExteriorRing;
26260     }
26261     enclosingRing() {
26262       if (this._enclosingRing === void 0) {
26263         this._enclosingRing = this._calcEnclosingRing();
26264       }
26265       return this._enclosingRing;
26266     }
26267     /* Returns the ring that encloses this one, if any */
26268     _calcEnclosingRing() {
26269       var _a2, _b;
26270       let leftMostEvt = this.events[0];
26271       for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
26272         const evt = this.events[i3];
26273         if (SweepEvent.compare(leftMostEvt, evt) > 0)
26274           leftMostEvt = evt;
26275       }
26276       let prevSeg = leftMostEvt.segment.prevInResult();
26277       let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26278       while (true) {
26279         if (!prevSeg)
26280           return null;
26281         if (!prevPrevSeg)
26282           return prevSeg.ringOut;
26283         if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
26284           if (((_a2 = prevPrevSeg.ringOut) == null ? void 0 : _a2.enclosingRing()) !== prevSeg.ringOut) {
26285             return prevSeg.ringOut;
26286           } else
26287             return (_b = prevSeg.ringOut) == null ? void 0 : _b.enclosingRing();
26288         }
26289         prevSeg = prevPrevSeg.prevInResult();
26290         prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26291       }
26292     }
26293   };
26294   var PolyOut = class {
26295     constructor(exteriorRing) {
26296       __publicField(this, "exteriorRing");
26297       __publicField(this, "interiorRings");
26298       this.exteriorRing = exteriorRing;
26299       exteriorRing.poly = this;
26300       this.interiorRings = [];
26301     }
26302     addInterior(ring) {
26303       this.interiorRings.push(ring);
26304       ring.poly = this;
26305     }
26306     getGeom() {
26307       const geom = [this.exteriorRing.getGeom()];
26308       if (geom[0] === null)
26309         return null;
26310       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26311         const ringGeom = this.interiorRings[i3].getGeom();
26312         if (ringGeom === null)
26313           continue;
26314         geom.push(ringGeom);
26315       }
26316       return geom;
26317     }
26318   };
26319   var MultiPolyOut = class {
26320     constructor(rings) {
26321       __publicField(this, "rings");
26322       __publicField(this, "polys");
26323       this.rings = rings;
26324       this.polys = this._composePolys(rings);
26325     }
26326     getGeom() {
26327       const geom = [];
26328       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26329         const polyGeom = this.polys[i3].getGeom();
26330         if (polyGeom === null)
26331           continue;
26332         geom.push(polyGeom);
26333       }
26334       return geom;
26335     }
26336     _composePolys(rings) {
26337       var _a2;
26338       const polys = [];
26339       for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
26340         const ring = rings[i3];
26341         if (ring.poly)
26342           continue;
26343         if (ring.isExteriorRing())
26344           polys.push(new PolyOut(ring));
26345         else {
26346           const enclosingRing = ring.enclosingRing();
26347           if (!(enclosingRing == null ? void 0 : enclosingRing.poly))
26348             polys.push(new PolyOut(enclosingRing));
26349           (_a2 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a2.addInterior(ring);
26350         }
26351       }
26352       return polys;
26353     }
26354   };
26355
26356   // node_modules/polyclip-ts/dist/sweep-line.js
26357   var SweepLine = class {
26358     constructor(queue, comparator = Segment.compare) {
26359       __publicField(this, "queue");
26360       __publicField(this, "tree");
26361       __publicField(this, "segments");
26362       this.queue = queue;
26363       this.tree = new SplayTreeSet(comparator);
26364       this.segments = [];
26365     }
26366     process(event) {
26367       const segment = event.segment;
26368       const newEvents = [];
26369       if (event.consumedBy) {
26370         if (event.isLeft)
26371           this.queue.delete(event.otherSE);
26372         else
26373           this.tree.delete(segment);
26374         return newEvents;
26375       }
26376       if (event.isLeft)
26377         this.tree.add(segment);
26378       let prevSeg = segment;
26379       let nextSeg = segment;
26380       do {
26381         prevSeg = this.tree.lastBefore(prevSeg);
26382       } while (prevSeg != null && prevSeg.consumedBy != void 0);
26383       do {
26384         nextSeg = this.tree.firstAfter(nextSeg);
26385       } while (nextSeg != null && nextSeg.consumedBy != void 0);
26386       if (event.isLeft) {
26387         let prevMySplitter = null;
26388         if (prevSeg) {
26389           const prevInter = prevSeg.getIntersection(segment);
26390           if (prevInter !== null) {
26391             if (!segment.isAnEndpoint(prevInter))
26392               prevMySplitter = prevInter;
26393             if (!prevSeg.isAnEndpoint(prevInter)) {
26394               const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
26395               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26396                 newEvents.push(newEventsFromSplit[i3]);
26397               }
26398             }
26399           }
26400         }
26401         let nextMySplitter = null;
26402         if (nextSeg) {
26403           const nextInter = nextSeg.getIntersection(segment);
26404           if (nextInter !== null) {
26405             if (!segment.isAnEndpoint(nextInter))
26406               nextMySplitter = nextInter;
26407             if (!nextSeg.isAnEndpoint(nextInter)) {
26408               const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
26409               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26410                 newEvents.push(newEventsFromSplit[i3]);
26411               }
26412             }
26413           }
26414         }
26415         if (prevMySplitter !== null || nextMySplitter !== null) {
26416           let mySplitter = null;
26417           if (prevMySplitter === null)
26418             mySplitter = nextMySplitter;
26419           else if (nextMySplitter === null)
26420             mySplitter = prevMySplitter;
26421           else {
26422             const cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter);
26423             mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
26424           }
26425           this.queue.delete(segment.rightSE);
26426           newEvents.push(segment.rightSE);
26427           const newEventsFromSplit = segment.split(mySplitter);
26428           for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26429             newEvents.push(newEventsFromSplit[i3]);
26430           }
26431         }
26432         if (newEvents.length > 0) {
26433           this.tree.delete(segment);
26434           newEvents.push(event);
26435         } else {
26436           this.segments.push(segment);
26437           segment.prev = prevSeg;
26438         }
26439       } else {
26440         if (prevSeg && nextSeg) {
26441           const inter = prevSeg.getIntersection(nextSeg);
26442           if (inter !== null) {
26443             if (!prevSeg.isAnEndpoint(inter)) {
26444               const newEventsFromSplit = this._splitSafely(prevSeg, inter);
26445               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26446                 newEvents.push(newEventsFromSplit[i3]);
26447               }
26448             }
26449             if (!nextSeg.isAnEndpoint(inter)) {
26450               const newEventsFromSplit = this._splitSafely(nextSeg, inter);
26451               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26452                 newEvents.push(newEventsFromSplit[i3]);
26453               }
26454             }
26455           }
26456         }
26457         this.tree.delete(segment);
26458       }
26459       return newEvents;
26460     }
26461     /* Safely split a segment that is currently in the datastructures
26462      * IE - a segment other than the one that is currently being processed. */
26463     _splitSafely(seg, pt2) {
26464       this.tree.delete(seg);
26465       const rightSE = seg.rightSE;
26466       this.queue.delete(rightSE);
26467       const newEvents = seg.split(pt2);
26468       newEvents.push(rightSE);
26469       if (seg.consumedBy === void 0)
26470         this.tree.add(seg);
26471       return newEvents;
26472     }
26473   };
26474
26475   // node_modules/polyclip-ts/dist/operation.js
26476   var Operation = class {
26477     constructor() {
26478       __publicField(this, "type");
26479       __publicField(this, "numMultiPolys");
26480     }
26481     run(type2, geom, moreGeoms) {
26482       operation.type = type2;
26483       const multipolys = [new MultiPolyIn(geom, true)];
26484       for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
26485         multipolys.push(new MultiPolyIn(moreGeoms[i3], false));
26486       }
26487       operation.numMultiPolys = multipolys.length;
26488       if (operation.type === "difference") {
26489         const subject = multipolys[0];
26490         let i3 = 1;
26491         while (i3 < multipolys.length) {
26492           if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null)
26493             i3++;
26494           else
26495             multipolys.splice(i3, 1);
26496         }
26497       }
26498       if (operation.type === "intersection") {
26499         for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26500           const mpA = multipolys[i3];
26501           for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
26502             if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null)
26503               return [];
26504           }
26505         }
26506       }
26507       const queue = new SplayTreeSet(SweepEvent.compare);
26508       for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26509         const sweepEvents = multipolys[i3].getSweepEvents();
26510         for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
26511           queue.add(sweepEvents[j2]);
26512         }
26513       }
26514       const sweepLine = new SweepLine(queue);
26515       let evt = null;
26516       if (queue.size != 0) {
26517         evt = queue.first();
26518         queue.delete(evt);
26519       }
26520       while (evt) {
26521         const newEvents = sweepLine.process(evt);
26522         for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
26523           const evt2 = newEvents[i3];
26524           if (evt2.consumedBy === void 0)
26525             queue.add(evt2);
26526         }
26527         if (queue.size != 0) {
26528           evt = queue.first();
26529           queue.delete(evt);
26530         } else {
26531           evt = null;
26532         }
26533       }
26534       precision.reset();
26535       const ringsOut = RingOut.factory(sweepLine.segments);
26536       const result = new MultiPolyOut(ringsOut);
26537       return result.getGeom();
26538     }
26539   };
26540   var operation = new Operation();
26541   var operation_default = operation;
26542
26543   // node_modules/polyclip-ts/dist/index.js
26544   var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms);
26545   var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms);
26546   var setPrecision = precision.set;
26547
26548   // node_modules/@rapideditor/location-conflation/index.mjs
26549   var import_geojson_area = __toESM(require_geojson_area(), 1);
26550   var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1);
26551   var import_geojson_precision = __toESM(require_geojson_precision(), 1);
26552   var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1);
26553   var LocationConflation = class {
26554     // constructor
26555     //
26556     // `fc`  Optional FeatureCollection of known features
26557     //
26558     // Optionally pass a GeoJSON FeatureCollection of known features which we can refer to later.
26559     // Each feature must have a filename-like `id`, for example: `something.geojson`
26560     //
26561     // {
26562     //   "type": "FeatureCollection"
26563     //   "features": [
26564     //     {
26565     //       "type": "Feature",
26566     //       "id": "philly_metro.geojson",
26567     //       "properties": { … },
26568     //       "geometry": { … }
26569     //     }
26570     //   ]
26571     // }
26572     constructor(fc) {
26573       this._cache = {};
26574       this.strict = true;
26575       if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) {
26576         fc.features.forEach((feature3) => {
26577           feature3.properties = feature3.properties || {};
26578           let props = feature3.properties;
26579           let id2 = feature3.id || props.id;
26580           if (!id2 || !/^\S+\.geojson$/i.test(id2))
26581             return;
26582           id2 = id2.toLowerCase();
26583           feature3.id = id2;
26584           props.id = id2;
26585           if (!props.area) {
26586             const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26587             props.area = Number(area.toFixed(2));
26588           }
26589           this._cache[id2] = feature3;
26590         });
26591       }
26592       let world = _cloneDeep(feature("Q2"));
26593       world.geometry = {
26594         type: "Polygon",
26595         coordinates: [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
26596       };
26597       world.id = "Q2";
26598       world.properties.id = "Q2";
26599       world.properties.area = import_geojson_area.default.geometry(world.geometry) / 1e6;
26600       this._cache.Q2 = world;
26601     }
26602     // validateLocation
26603     // `location`  The location to validate
26604     //
26605     // Pass a `location` value to validate
26606     //
26607     // Returns a result like:
26608     //   {
26609     //     type:     'point', 'geojson', or 'countrycoder'
26610     //     location:  the queried location
26611     //     id:        the stable identifier for the feature
26612     //   }
26613     // or `null` if the location is invalid
26614     //
26615     validateLocation(location) {
26616       if (Array.isArray(location) && (location.length === 2 || location.length === 3)) {
26617         const lon = location[0];
26618         const lat = location[1];
26619         const radius = location[2];
26620         if (Number.isFinite(lon) && lon >= -180 && lon <= 180 && Number.isFinite(lat) && lat >= -90 && lat <= 90 && (location.length === 2 || Number.isFinite(radius) && radius > 0)) {
26621           const id2 = "[" + location.toString() + "]";
26622           return { type: "point", location, id: id2 };
26623         }
26624       } else if (typeof location === "string" && /^\S+\.geojson$/i.test(location)) {
26625         const id2 = location.toLowerCase();
26626         if (this._cache[id2]) {
26627           return { type: "geojson", location, id: id2 };
26628         }
26629       } else if (typeof location === "string" || typeof location === "number") {
26630         const feature3 = feature(location);
26631         if (feature3) {
26632           const id2 = feature3.properties.wikidata;
26633           return { type: "countrycoder", location, id: id2 };
26634         }
26635       }
26636       if (this.strict) {
26637         throw new Error('validateLocation:  Invalid location: "'.concat(location, '".'));
26638       } else {
26639         return null;
26640       }
26641     }
26642     // resolveLocation
26643     // `location`  The location to resolve
26644     //
26645     // Pass a `location` value to resolve
26646     //
26647     // Returns a result like:
26648     //   {
26649     //     type:      'point', 'geojson', or 'countrycoder'
26650     //     location:  the queried location
26651     //     id:        a stable identifier for the feature
26652     //     feature:   the resolved GeoJSON feature
26653     //   }
26654     //  or `null` if the location is invalid
26655     //
26656     resolveLocation(location) {
26657       const valid = this.validateLocation(location);
26658       if (!valid)
26659         return null;
26660       const id2 = valid.id;
26661       if (this._cache[id2]) {
26662         return Object.assign(valid, { feature: this._cache[id2] });
26663       }
26664       if (valid.type === "point") {
26665         const lon = location[0];
26666         const lat = location[1];
26667         const radius = location[2] || 25;
26668         const EDGES = 10;
26669         const PRECISION = 3;
26670         const area = Math.PI * radius * radius;
26671         const feature3 = this._cache[id2] = (0, import_geojson_precision.default)({
26672           type: "Feature",
26673           id: id2,
26674           properties: { id: id2, area: Number(area.toFixed(2)) },
26675           geometry: (0, import_circle_to_polygon.default)([lon, lat], radius * 1e3, EDGES)
26676           // km to m
26677         }, PRECISION);
26678         return Object.assign(valid, { feature: feature3 });
26679       } else if (valid.type === "geojson") {
26680       } else if (valid.type === "countrycoder") {
26681         let feature3 = _cloneDeep(feature(id2));
26682         let props = feature3.properties;
26683         if (Array.isArray(props.members)) {
26684           let aggregate = aggregateFeature(id2);
26685           aggregate.geometry.coordinates = _clip([aggregate], "UNION").geometry.coordinates;
26686           feature3.geometry = aggregate.geometry;
26687         }
26688         if (!props.area) {
26689           const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26690           props.area = Number(area.toFixed(2));
26691         }
26692         feature3.id = id2;
26693         props.id = id2;
26694         this._cache[id2] = feature3;
26695         return Object.assign(valid, { feature: feature3 });
26696       }
26697       if (this.strict) {
26698         throw new Error("resolveLocation:  Couldn't resolve location \"".concat(location, '".'));
26699       } else {
26700         return null;
26701       }
26702     }
26703     // validateLocationSet
26704     // `locationSet`  the locationSet to validate
26705     //
26706     // Pass a locationSet Object to validate like:
26707     //   {
26708     //     include: [ Array of locations ],
26709     //     exclude: [ Array of locations ]
26710     //   }
26711     //
26712     // Returns a result like:
26713     //   {
26714     //     type:         'locationset'
26715     //     locationSet:  the queried locationSet
26716     //     id:           the stable identifier for the feature
26717     //   }
26718     // or `null` if the locationSet is invalid
26719     //
26720     validateLocationSet(locationSet) {
26721       locationSet = locationSet || {};
26722       const validator = this.validateLocation.bind(this);
26723       let include = (locationSet.include || []).map(validator).filter(Boolean);
26724       let exclude = (locationSet.exclude || []).map(validator).filter(Boolean);
26725       if (!include.length) {
26726         if (this.strict) {
26727           throw new Error("validateLocationSet:  LocationSet includes nothing.");
26728         } else {
26729           locationSet.include = ["Q2"];
26730           include = [{ type: "countrycoder", location: "Q2", id: "Q2" }];
26731         }
26732       }
26733       include.sort(_sortLocations);
26734       let id2 = "+[" + include.map((d2) => d2.id).join(",") + "]";
26735       if (exclude.length) {
26736         exclude.sort(_sortLocations);
26737         id2 += "-[" + exclude.map((d2) => d2.id).join(",") + "]";
26738       }
26739       return { type: "locationset", locationSet, id: id2 };
26740     }
26741     // resolveLocationSet
26742     // `locationSet`  the locationSet to resolve
26743     //
26744     // Pass a locationSet Object to validate like:
26745     //   {
26746     //     include: [ Array of locations ],
26747     //     exclude: [ Array of locations ]
26748     //   }
26749     //
26750     // Returns a result like:
26751     //   {
26752     //     type:         'locationset'
26753     //     locationSet:  the queried locationSet
26754     //     id:           the stable identifier for the feature
26755     //     feature:      the resolved GeoJSON feature
26756     //   }
26757     // or `null` if the locationSet is invalid
26758     //
26759     resolveLocationSet(locationSet) {
26760       locationSet = locationSet || {};
26761       const valid = this.validateLocationSet(locationSet);
26762       if (!valid)
26763         return null;
26764       const id2 = valid.id;
26765       if (this._cache[id2]) {
26766         return Object.assign(valid, { feature: this._cache[id2] });
26767       }
26768       const resolver = this.resolveLocation.bind(this);
26769       const includes = (locationSet.include || []).map(resolver).filter(Boolean);
26770       const excludes = (locationSet.exclude || []).map(resolver).filter(Boolean);
26771       if (includes.length === 1 && excludes.length === 0) {
26772         return Object.assign(valid, { feature: includes[0].feature });
26773       }
26774       const includeGeoJSON = _clip(includes.map((d2) => d2.feature), "UNION");
26775       const excludeGeoJSON = _clip(excludes.map((d2) => d2.feature), "UNION");
26776       let resultGeoJSON = excludeGeoJSON ? _clip([includeGeoJSON, excludeGeoJSON], "DIFFERENCE") : includeGeoJSON;
26777       const area = import_geojson_area.default.geometry(resultGeoJSON.geometry) / 1e6;
26778       resultGeoJSON.id = id2;
26779       resultGeoJSON.properties = { id: id2, area: Number(area.toFixed(2)) };
26780       this._cache[id2] = resultGeoJSON;
26781       return Object.assign(valid, { feature: resultGeoJSON });
26782     }
26783     // stringify
26784     // convenience method to prettyStringify the given object
26785     stringify(obj, options2) {
26786       return (0, import_json_stringify_pretty_compact.default)(obj, options2);
26787     }
26788   };
26789   function _clip(features, which) {
26790     if (!Array.isArray(features) || !features.length)
26791       return null;
26792     const fn = { UNION: union, DIFFERENCE: difference }[which];
26793     const args = features.map((feature3) => feature3.geometry.coordinates);
26794     const coords = fn.apply(null, args);
26795     return {
26796       type: "Feature",
26797       properties: {},
26798       geometry: {
26799         type: whichType(coords),
26800         coordinates: coords
26801       }
26802     };
26803     function whichType(coords2) {
26804       const a2 = Array.isArray(coords2);
26805       const b2 = a2 && Array.isArray(coords2[0]);
26806       const c2 = b2 && Array.isArray(coords2[0][0]);
26807       const d2 = c2 && Array.isArray(coords2[0][0][0]);
26808       return d2 ? "MultiPolygon" : "Polygon";
26809     }
26810   }
26811   function _cloneDeep(obj) {
26812     return JSON.parse(JSON.stringify(obj));
26813   }
26814   function _sortLocations(a2, b2) {
26815     const rank = { countrycoder: 1, geojson: 2, point: 3 };
26816     const aRank = rank[a2.type];
26817     const bRank = rank[b2.type];
26818     return aRank > bRank ? 1 : aRank < bRank ? -1 : a2.id.localeCompare(b2.id);
26819   }
26820
26821   // modules/core/LocationManager.js
26822   var import_which_polygon2 = __toESM(require_which_polygon());
26823   var import_geojson_area2 = __toESM(require_geojson_area());
26824   var _loco = new LocationConflation();
26825   var LocationManager = class {
26826     /**
26827      * @constructor
26828      */
26829     constructor() {
26830       this._wp = null;
26831       this._resolved = /* @__PURE__ */ new Map();
26832       this._knownLocationSets = /* @__PURE__ */ new Map();
26833       this._locationIncludedIn = /* @__PURE__ */ new Map();
26834       this._locationExcludedIn = /* @__PURE__ */ new Map();
26835       const world = { locationSet: { include: ["Q2"] } };
26836       this._resolveLocationSet(world);
26837       this._rebuildIndex();
26838     }
26839     /**
26840      * _validateLocationSet
26841      * Pass an Object with a `locationSet` property.
26842      * Validates the `locationSet` and sets a `locationSetID` property on the object.
26843      * To avoid so much computation we only resolve the include and exclude regions, but not the locationSet itself.
26844      *
26845      * Use `_resolveLocationSet()` instead if you need to resolve geojson of locationSet, for example to render it.
26846      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26847      *
26848      * @param  `obj`  Object to check, it should have `locationSet` property
26849      */
26850     _validateLocationSet(obj) {
26851       if (obj.locationSetID)
26852         return;
26853       try {
26854         let locationSet = obj.locationSet;
26855         if (!locationSet) {
26856           throw new Error("object missing locationSet property");
26857         }
26858         if (!locationSet.include) {
26859           locationSet.include = ["Q2"];
26860         }
26861         const locationSetID = _loco.validateLocationSet(locationSet).id;
26862         obj.locationSetID = locationSetID;
26863         if (this._knownLocationSets.has(locationSetID))
26864           return;
26865         let area = 0;
26866         (locationSet.include || []).forEach((location) => {
26867           const locationID = _loco.validateLocation(location).id;
26868           let geojson = this._resolved.get(locationID);
26869           if (!geojson) {
26870             geojson = _loco.resolveLocation(location).feature;
26871             this._resolved.set(locationID, geojson);
26872           }
26873           area += geojson.properties.area;
26874           let s2 = this._locationIncludedIn.get(locationID);
26875           if (!s2) {
26876             s2 = /* @__PURE__ */ new Set();
26877             this._locationIncludedIn.set(locationID, s2);
26878           }
26879           s2.add(locationSetID);
26880         });
26881         (locationSet.exclude || []).forEach((location) => {
26882           const locationID = _loco.validateLocation(location).id;
26883           let geojson = this._resolved.get(locationID);
26884           if (!geojson) {
26885             geojson = _loco.resolveLocation(location).feature;
26886             this._resolved.set(locationID, geojson);
26887           }
26888           area -= geojson.properties.area;
26889           let s2 = this._locationExcludedIn.get(locationID);
26890           if (!s2) {
26891             s2 = /* @__PURE__ */ new Set();
26892             this._locationExcludedIn.set(locationID, s2);
26893           }
26894           s2.add(locationSetID);
26895         });
26896         this._knownLocationSets.set(locationSetID, area);
26897       } catch (err) {
26898         obj.locationSet = { include: ["Q2"] };
26899         obj.locationSetID = "+[Q2]";
26900       }
26901     }
26902     /**
26903      * _resolveLocationSet
26904      * Does everything that `_validateLocationSet()` does, but then "resolves" the locationSet into GeoJSON.
26905      * This step is a bit more computationally expensive, so really only needed if you intend to render the shape.
26906      *
26907      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26908      *
26909      * @param  `obj`  Object to check, it should have `locationSet` property
26910      */
26911     _resolveLocationSet(obj) {
26912       this._validateLocationSet(obj);
26913       if (this._resolved.has(obj.locationSetID))
26914         return;
26915       try {
26916         const result = _loco.resolveLocationSet(obj.locationSet);
26917         const locationSetID = result.id;
26918         obj.locationSetID = locationSetID;
26919         if (!result.feature.geometry.coordinates.length || !result.feature.properties.area) {
26920           throw new Error("locationSet ".concat(locationSetID, " resolves to an empty feature."));
26921         }
26922         let geojson = JSON.parse(JSON.stringify(result.feature));
26923         geojson.id = locationSetID;
26924         geojson.properties.id = locationSetID;
26925         this._resolved.set(locationSetID, geojson);
26926       } catch (err) {
26927         obj.locationSet = { include: ["Q2"] };
26928         obj.locationSetID = "+[Q2]";
26929       }
26930     }
26931     /**
26932      * _rebuildIndex
26933      * Rebuilds the whichPolygon index with whatever features have been resolved into GeoJSON.
26934      */
26935     _rebuildIndex() {
26936       this._wp = (0, import_which_polygon2.default)({ features: [...this._resolved.values()] });
26937     }
26938     /**
26939      * mergeCustomGeoJSON
26940      * Accepts a FeatureCollection-like object containing custom locations
26941      * Each feature must have a filename-like `id`, for example: `something.geojson`
26942      * {
26943      *   "type": "FeatureCollection"
26944      *   "features": [
26945      *     {
26946      *       "type": "Feature",
26947      *       "id": "philly_metro.geojson",
26948      *       "properties": { … },
26949      *       "geometry": { … }
26950      *     }
26951      *   ]
26952      * }
26953      *
26954      * @param  `fc`  FeatureCollection-like Object containing custom locations
26955      */
26956     mergeCustomGeoJSON(fc) {
26957       if (!fc || fc.type !== "FeatureCollection" || !Array.isArray(fc.features))
26958         return;
26959       fc.features.forEach((feature3) => {
26960         feature3.properties = feature3.properties || {};
26961         let props = feature3.properties;
26962         let id2 = feature3.id || props.id;
26963         if (!id2 || !/^\S+\.geojson$/i.test(id2))
26964           return;
26965         id2 = id2.toLowerCase();
26966         feature3.id = id2;
26967         props.id = id2;
26968         if (!props.area) {
26969           const area = import_geojson_area2.default.geometry(feature3.geometry) / 1e6;
26970           props.area = Number(area.toFixed(2));
26971         }
26972         _loco._cache[id2] = feature3;
26973       });
26974     }
26975     /**
26976      * mergeLocationSets
26977      * Accepts an Array of Objects containing `locationSet` properties:
26978      * [
26979      *  { id: 'preset1', locationSet: {…} },
26980      *  { id: 'preset2', locationSet: {…} },
26981      *  …
26982      * ]
26983      * After validating, the Objects will be decorated with a `locationSetID` property:
26984      * [
26985      *  { id: 'preset1', locationSet: {…}, locationSetID: '+[Q2]' },
26986      *  { id: 'preset2', locationSet: {…}, locationSetID: '+[Q30]' },
26987      *  …
26988      * ]
26989      *
26990      * @param  `objects`  Objects to check - they should have `locationSet` property
26991      * @return  Promise resolved true (this function used to be slow/async, now it's faster and sync)
26992      */
26993     mergeLocationSets(objects) {
26994       if (!Array.isArray(objects))
26995         return Promise.reject("nothing to do");
26996       objects.forEach((obj) => this._validateLocationSet(obj));
26997       this._rebuildIndex();
26998       return Promise.resolve(objects);
26999     }
27000     /**
27001      * locationSetID
27002      * Returns a locationSetID for a given locationSet (fallback to `+[Q2]`, world)
27003      * (The locationSet doesn't necessarily need to be resolved to compute its `id`)
27004      *
27005      * @param  `locationSet`  A locationSet Object, e.g. `{ include: ['us'] }`
27006      * @return  String locationSetID, e.g. `+[Q30]`
27007      */
27008     locationSetID(locationSet) {
27009       let locationSetID;
27010       try {
27011         locationSetID = _loco.validateLocationSet(locationSet).id;
27012       } catch (err) {
27013         locationSetID = "+[Q2]";
27014       }
27015       return locationSetID;
27016     }
27017     /**
27018      * feature
27019      * Returns the resolved GeoJSON feature for a given locationSetID (fallback to 'world')
27020      * A GeoJSON feature:
27021      * {
27022      *   type: 'Feature',
27023      *   id: '+[Q30]',
27024      *   properties: { id: '+[Q30]', area: 21817019.17, … },
27025      *   geometry: { … }
27026      * }
27027      *
27028      * @param  `locationSetID`  String identifier, e.g. `+[Q30]`
27029      * @return  GeoJSON object (fallback to world)
27030      */
27031     feature(locationSetID = "+[Q2]") {
27032       const feature3 = this._resolved.get(locationSetID);
27033       return feature3 || this._resolved.get("+[Q2]");
27034     }
27035     /**
27036      * locationSetsAt
27037      * Find all the locationSets valid at the given location.
27038      * Results include the area (in km²) to facilitate sorting.
27039      *
27040      * Object of locationSetIDs to areas (in km²)
27041      * {
27042      *   "+[Q2]": 511207893.3958111,
27043      *   "+[Q30]": 21817019.17,
27044      *   "+[new_jersey.geojson]": 22390.77,
27045      *   …
27046      * }
27047      *
27048      * @param  `loc`  `[lon,lat]` location to query, e.g. `[-74.4813, 40.7967]`
27049      * @return  Object of locationSetIDs valid at given location
27050      */
27051     locationSetsAt(loc) {
27052       let result = {};
27053       const hits = this._wp(loc, true) || [];
27054       const thiz = this;
27055       hits.forEach((prop) => {
27056         if (prop.id[0] !== "+")
27057           return;
27058         const locationSetID = prop.id;
27059         const area = thiz._knownLocationSets.get(locationSetID);
27060         if (area) {
27061           result[locationSetID] = area;
27062         }
27063       });
27064       hits.forEach((prop) => {
27065         if (prop.id[0] === "+")
27066           return;
27067         const locationID = prop.id;
27068         const included = thiz._locationIncludedIn.get(locationID);
27069         (included || []).forEach((locationSetID) => {
27070           const area = thiz._knownLocationSets.get(locationSetID);
27071           if (area) {
27072             result[locationSetID] = area;
27073           }
27074         });
27075       });
27076       hits.forEach((prop) => {
27077         if (prop.id[0] === "+")
27078           return;
27079         const locationID = prop.id;
27080         const excluded = thiz._locationExcludedIn.get(locationID);
27081         (excluded || []).forEach((locationSetID) => {
27082           delete result[locationSetID];
27083         });
27084       });
27085       return result;
27086     }
27087     // Direct access to the location-conflation resolver
27088     loco() {
27089       return _loco;
27090     }
27091   };
27092   var _sharedLocationManager = new LocationManager();
27093
27094   // node_modules/lodash-es/_freeGlobal.js
27095   var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
27096   var freeGlobal_default = freeGlobal;
27097
27098   // node_modules/lodash-es/_root.js
27099   var freeSelf = typeof self == "object" && self && self.Object === Object && self;
27100   var root2 = freeGlobal_default || freeSelf || Function("return this")();
27101   var root_default = root2;
27102
27103   // node_modules/lodash-es/_Symbol.js
27104   var Symbol2 = root_default.Symbol;
27105   var Symbol_default = Symbol2;
27106
27107   // node_modules/lodash-es/_getRawTag.js
27108   var objectProto = Object.prototype;
27109   var hasOwnProperty = objectProto.hasOwnProperty;
27110   var nativeObjectToString = objectProto.toString;
27111   var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
27112   function getRawTag(value) {
27113     var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag];
27114     try {
27115       value[symToStringTag] = void 0;
27116       var unmasked = true;
27117     } catch (e3) {
27118     }
27119     var result = nativeObjectToString.call(value);
27120     if (unmasked) {
27121       if (isOwn) {
27122         value[symToStringTag] = tag2;
27123       } else {
27124         delete value[symToStringTag];
27125       }
27126     }
27127     return result;
27128   }
27129   var getRawTag_default = getRawTag;
27130
27131   // node_modules/lodash-es/_objectToString.js
27132   var objectProto2 = Object.prototype;
27133   var nativeObjectToString2 = objectProto2.toString;
27134   function objectToString(value) {
27135     return nativeObjectToString2.call(value);
27136   }
27137   var objectToString_default = objectToString;
27138
27139   // node_modules/lodash-es/_baseGetTag.js
27140   var nullTag = "[object Null]";
27141   var undefinedTag = "[object Undefined]";
27142   var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
27143   function baseGetTag(value) {
27144     if (value == null) {
27145       return value === void 0 ? undefinedTag : nullTag;
27146     }
27147     return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
27148   }
27149   var baseGetTag_default = baseGetTag;
27150
27151   // node_modules/lodash-es/isObjectLike.js
27152   function isObjectLike(value) {
27153     return value != null && typeof value == "object";
27154   }
27155   var isObjectLike_default = isObjectLike;
27156
27157   // node_modules/lodash-es/isSymbol.js
27158   var symbolTag = "[object Symbol]";
27159   function isSymbol(value) {
27160     return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
27161   }
27162   var isSymbol_default = isSymbol;
27163
27164   // node_modules/lodash-es/_arrayMap.js
27165   function arrayMap(array2, iteratee) {
27166     var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
27167     while (++index < length2) {
27168       result[index] = iteratee(array2[index], index, array2);
27169     }
27170     return result;
27171   }
27172   var arrayMap_default = arrayMap;
27173
27174   // node_modules/lodash-es/isArray.js
27175   var isArray = Array.isArray;
27176   var isArray_default = isArray;
27177
27178   // node_modules/lodash-es/_baseToString.js
27179   var INFINITY = 1 / 0;
27180   var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
27181   var symbolToString = symbolProto ? symbolProto.toString : void 0;
27182   function baseToString(value) {
27183     if (typeof value == "string") {
27184       return value;
27185     }
27186     if (isArray_default(value)) {
27187       return arrayMap_default(value, baseToString) + "";
27188     }
27189     if (isSymbol_default(value)) {
27190       return symbolToString ? symbolToString.call(value) : "";
27191     }
27192     var result = value + "";
27193     return result == "0" && 1 / value == -INFINITY ? "-0" : result;
27194   }
27195   var baseToString_default = baseToString;
27196
27197   // node_modules/lodash-es/_trimmedEndIndex.js
27198   var reWhitespace = /\s/;
27199   function trimmedEndIndex(string) {
27200     var index = string.length;
27201     while (index-- && reWhitespace.test(string.charAt(index))) {
27202     }
27203     return index;
27204   }
27205   var trimmedEndIndex_default = trimmedEndIndex;
27206
27207   // node_modules/lodash-es/_baseTrim.js
27208   var reTrimStart = /^\s+/;
27209   function baseTrim(string) {
27210     return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
27211   }
27212   var baseTrim_default = baseTrim;
27213
27214   // node_modules/lodash-es/isObject.js
27215   function isObject(value) {
27216     var type2 = typeof value;
27217     return value != null && (type2 == "object" || type2 == "function");
27218   }
27219   var isObject_default = isObject;
27220
27221   // node_modules/lodash-es/toNumber.js
27222   var NAN = 0 / 0;
27223   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
27224   var reIsBinary = /^0b[01]+$/i;
27225   var reIsOctal = /^0o[0-7]+$/i;
27226   var freeParseInt = parseInt;
27227   function toNumber(value) {
27228     if (typeof value == "number") {
27229       return value;
27230     }
27231     if (isSymbol_default(value)) {
27232       return NAN;
27233     }
27234     if (isObject_default(value)) {
27235       var other = typeof value.valueOf == "function" ? value.valueOf() : value;
27236       value = isObject_default(other) ? other + "" : other;
27237     }
27238     if (typeof value != "string") {
27239       return value === 0 ? value : +value;
27240     }
27241     value = baseTrim_default(value);
27242     var isBinary = reIsBinary.test(value);
27243     return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
27244   }
27245   var toNumber_default = toNumber;
27246
27247   // node_modules/lodash-es/isFunction.js
27248   var asyncTag = "[object AsyncFunction]";
27249   var funcTag = "[object Function]";
27250   var genTag = "[object GeneratorFunction]";
27251   var proxyTag = "[object Proxy]";
27252   function isFunction(value) {
27253     if (!isObject_default(value)) {
27254       return false;
27255     }
27256     var tag2 = baseGetTag_default(value);
27257     return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag;
27258   }
27259   var isFunction_default = isFunction;
27260
27261   // node_modules/lodash-es/_coreJsData.js
27262   var coreJsData = root_default["__core-js_shared__"];
27263   var coreJsData_default = coreJsData;
27264
27265   // node_modules/lodash-es/_isMasked.js
27266   var maskSrcKey = function() {
27267     var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
27268     return uid ? "Symbol(src)_1." + uid : "";
27269   }();
27270   function isMasked(func) {
27271     return !!maskSrcKey && maskSrcKey in func;
27272   }
27273   var isMasked_default = isMasked;
27274
27275   // node_modules/lodash-es/_toSource.js
27276   var funcProto = Function.prototype;
27277   var funcToString = funcProto.toString;
27278   function toSource(func) {
27279     if (func != null) {
27280       try {
27281         return funcToString.call(func);
27282       } catch (e3) {
27283       }
27284       try {
27285         return func + "";
27286       } catch (e3) {
27287       }
27288     }
27289     return "";
27290   }
27291   var toSource_default = toSource;
27292
27293   // node_modules/lodash-es/_baseIsNative.js
27294   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
27295   var reIsHostCtor = /^\[object .+?Constructor\]$/;
27296   var funcProto2 = Function.prototype;
27297   var objectProto3 = Object.prototype;
27298   var funcToString2 = funcProto2.toString;
27299   var hasOwnProperty2 = objectProto3.hasOwnProperty;
27300   var reIsNative = RegExp(
27301     "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
27302   );
27303   function baseIsNative(value) {
27304     if (!isObject_default(value) || isMasked_default(value)) {
27305       return false;
27306     }
27307     var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
27308     return pattern.test(toSource_default(value));
27309   }
27310   var baseIsNative_default = baseIsNative;
27311
27312   // node_modules/lodash-es/_getValue.js
27313   function getValue(object, key) {
27314     return object == null ? void 0 : object[key];
27315   }
27316   var getValue_default = getValue;
27317
27318   // node_modules/lodash-es/_getNative.js
27319   function getNative(object, key) {
27320     var value = getValue_default(object, key);
27321     return baseIsNative_default(value) ? value : void 0;
27322   }
27323   var getNative_default = getNative;
27324
27325   // node_modules/lodash-es/_WeakMap.js
27326   var WeakMap = getNative_default(root_default, "WeakMap");
27327   var WeakMap_default = WeakMap;
27328
27329   // node_modules/lodash-es/_isIndex.js
27330   var MAX_SAFE_INTEGER2 = 9007199254740991;
27331   var reIsUint = /^(?:0|[1-9]\d*)$/;
27332   function isIndex(value, length2) {
27333     var type2 = typeof value;
27334     length2 = length2 == null ? MAX_SAFE_INTEGER2 : length2;
27335     return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
27336   }
27337   var isIndex_default = isIndex;
27338
27339   // node_modules/lodash-es/eq.js
27340   function eq(value, other) {
27341     return value === other || value !== value && other !== other;
27342   }
27343   var eq_default = eq;
27344
27345   // node_modules/lodash-es/isLength.js
27346   var MAX_SAFE_INTEGER3 = 9007199254740991;
27347   function isLength(value) {
27348     return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER3;
27349   }
27350   var isLength_default = isLength;
27351
27352   // node_modules/lodash-es/isArrayLike.js
27353   function isArrayLike(value) {
27354     return value != null && isLength_default(value.length) && !isFunction_default(value);
27355   }
27356   var isArrayLike_default = isArrayLike;
27357
27358   // node_modules/lodash-es/_isPrototype.js
27359   var objectProto4 = Object.prototype;
27360   function isPrototype(value) {
27361     var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto4;
27362     return value === proto;
27363   }
27364   var isPrototype_default = isPrototype;
27365
27366   // node_modules/lodash-es/_baseTimes.js
27367   function baseTimes(n3, iteratee) {
27368     var index = -1, result = Array(n3);
27369     while (++index < n3) {
27370       result[index] = iteratee(index);
27371     }
27372     return result;
27373   }
27374   var baseTimes_default = baseTimes;
27375
27376   // node_modules/lodash-es/_baseIsArguments.js
27377   var argsTag = "[object Arguments]";
27378   function baseIsArguments(value) {
27379     return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
27380   }
27381   var baseIsArguments_default = baseIsArguments;
27382
27383   // node_modules/lodash-es/isArguments.js
27384   var objectProto5 = Object.prototype;
27385   var hasOwnProperty3 = objectProto5.hasOwnProperty;
27386   var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
27387   var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
27388     return arguments;
27389   }()) ? baseIsArguments_default : function(value) {
27390     return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
27391   };
27392   var isArguments_default = isArguments;
27393
27394   // node_modules/lodash-es/stubFalse.js
27395   function stubFalse() {
27396     return false;
27397   }
27398   var stubFalse_default = stubFalse;
27399
27400   // node_modules/lodash-es/isBuffer.js
27401   var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
27402   var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
27403   var moduleExports = freeModule && freeModule.exports === freeExports;
27404   var Buffer2 = moduleExports ? root_default.Buffer : void 0;
27405   var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
27406   var isBuffer = nativeIsBuffer || stubFalse_default;
27407   var isBuffer_default = isBuffer;
27408
27409   // node_modules/lodash-es/_baseIsTypedArray.js
27410   var argsTag2 = "[object Arguments]";
27411   var arrayTag = "[object Array]";
27412   var boolTag = "[object Boolean]";
27413   var dateTag = "[object Date]";
27414   var errorTag = "[object Error]";
27415   var funcTag2 = "[object Function]";
27416   var mapTag = "[object Map]";
27417   var numberTag = "[object Number]";
27418   var objectTag = "[object Object]";
27419   var regexpTag = "[object RegExp]";
27420   var setTag = "[object Set]";
27421   var stringTag = "[object String]";
27422   var weakMapTag = "[object WeakMap]";
27423   var arrayBufferTag = "[object ArrayBuffer]";
27424   var dataViewTag = "[object DataView]";
27425   var float32Tag = "[object Float32Array]";
27426   var float64Tag = "[object Float64Array]";
27427   var int8Tag = "[object Int8Array]";
27428   var int16Tag = "[object Int16Array]";
27429   var int32Tag = "[object Int32Array]";
27430   var uint8Tag = "[object Uint8Array]";
27431   var uint8ClampedTag = "[object Uint8ClampedArray]";
27432   var uint16Tag = "[object Uint16Array]";
27433   var uint32Tag = "[object Uint32Array]";
27434   var typedArrayTags = {};
27435   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
27436   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;
27437   function baseIsTypedArray(value) {
27438     return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
27439   }
27440   var baseIsTypedArray_default = baseIsTypedArray;
27441
27442   // node_modules/lodash-es/_baseUnary.js
27443   function baseUnary(func) {
27444     return function(value) {
27445       return func(value);
27446     };
27447   }
27448   var baseUnary_default = baseUnary;
27449
27450   // node_modules/lodash-es/_nodeUtil.js
27451   var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
27452   var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
27453   var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
27454   var freeProcess = moduleExports2 && freeGlobal_default.process;
27455   var nodeUtil = function() {
27456     try {
27457       var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
27458       if (types) {
27459         return types;
27460       }
27461       return freeProcess && freeProcess.binding && freeProcess.binding("util");
27462     } catch (e3) {
27463     }
27464   }();
27465   var nodeUtil_default = nodeUtil;
27466
27467   // node_modules/lodash-es/isTypedArray.js
27468   var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
27469   var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
27470   var isTypedArray_default = isTypedArray;
27471
27472   // node_modules/lodash-es/_arrayLikeKeys.js
27473   var objectProto6 = Object.prototype;
27474   var hasOwnProperty4 = objectProto6.hasOwnProperty;
27475   function arrayLikeKeys(value, inherited) {
27476     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;
27477     for (var key in value) {
27478       if ((inherited || hasOwnProperty4.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
27479       (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
27480       isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
27481       isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
27482       isIndex_default(key, length2)))) {
27483         result.push(key);
27484       }
27485     }
27486     return result;
27487   }
27488   var arrayLikeKeys_default = arrayLikeKeys;
27489
27490   // node_modules/lodash-es/_overArg.js
27491   function overArg(func, transform2) {
27492     return function(arg) {
27493       return func(transform2(arg));
27494     };
27495   }
27496   var overArg_default = overArg;
27497
27498   // node_modules/lodash-es/_nativeKeys.js
27499   var nativeKeys = overArg_default(Object.keys, Object);
27500   var nativeKeys_default = nativeKeys;
27501
27502   // node_modules/lodash-es/_baseKeys.js
27503   var objectProto7 = Object.prototype;
27504   var hasOwnProperty5 = objectProto7.hasOwnProperty;
27505   function baseKeys(object) {
27506     if (!isPrototype_default(object)) {
27507       return nativeKeys_default(object);
27508     }
27509     var result = [];
27510     for (var key in Object(object)) {
27511       if (hasOwnProperty5.call(object, key) && key != "constructor") {
27512         result.push(key);
27513       }
27514     }
27515     return result;
27516   }
27517   var baseKeys_default = baseKeys;
27518
27519   // node_modules/lodash-es/keys.js
27520   function keys(object) {
27521     return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
27522   }
27523   var keys_default = keys;
27524
27525   // node_modules/lodash-es/_nativeCreate.js
27526   var nativeCreate = getNative_default(Object, "create");
27527   var nativeCreate_default = nativeCreate;
27528
27529   // node_modules/lodash-es/_hashClear.js
27530   function hashClear() {
27531     this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
27532     this.size = 0;
27533   }
27534   var hashClear_default = hashClear;
27535
27536   // node_modules/lodash-es/_hashDelete.js
27537   function hashDelete(key) {
27538     var result = this.has(key) && delete this.__data__[key];
27539     this.size -= result ? 1 : 0;
27540     return result;
27541   }
27542   var hashDelete_default = hashDelete;
27543
27544   // node_modules/lodash-es/_hashGet.js
27545   var HASH_UNDEFINED = "__lodash_hash_undefined__";
27546   var objectProto8 = Object.prototype;
27547   var hasOwnProperty6 = objectProto8.hasOwnProperty;
27548   function hashGet(key) {
27549     var data = this.__data__;
27550     if (nativeCreate_default) {
27551       var result = data[key];
27552       return result === HASH_UNDEFINED ? void 0 : result;
27553     }
27554     return hasOwnProperty6.call(data, key) ? data[key] : void 0;
27555   }
27556   var hashGet_default = hashGet;
27557
27558   // node_modules/lodash-es/_hashHas.js
27559   var objectProto9 = Object.prototype;
27560   var hasOwnProperty7 = objectProto9.hasOwnProperty;
27561   function hashHas(key) {
27562     var data = this.__data__;
27563     return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty7.call(data, key);
27564   }
27565   var hashHas_default = hashHas;
27566
27567   // node_modules/lodash-es/_hashSet.js
27568   var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
27569   function hashSet(key, value) {
27570     var data = this.__data__;
27571     this.size += this.has(key) ? 0 : 1;
27572     data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
27573     return this;
27574   }
27575   var hashSet_default = hashSet;
27576
27577   // node_modules/lodash-es/_Hash.js
27578   function Hash(entries) {
27579     var index = -1, length2 = entries == null ? 0 : entries.length;
27580     this.clear();
27581     while (++index < length2) {
27582       var entry = entries[index];
27583       this.set(entry[0], entry[1]);
27584     }
27585   }
27586   Hash.prototype.clear = hashClear_default;
27587   Hash.prototype["delete"] = hashDelete_default;
27588   Hash.prototype.get = hashGet_default;
27589   Hash.prototype.has = hashHas_default;
27590   Hash.prototype.set = hashSet_default;
27591   var Hash_default = Hash;
27592
27593   // node_modules/lodash-es/_listCacheClear.js
27594   function listCacheClear() {
27595     this.__data__ = [];
27596     this.size = 0;
27597   }
27598   var listCacheClear_default = listCacheClear;
27599
27600   // node_modules/lodash-es/_assocIndexOf.js
27601   function assocIndexOf(array2, key) {
27602     var length2 = array2.length;
27603     while (length2--) {
27604       if (eq_default(array2[length2][0], key)) {
27605         return length2;
27606       }
27607     }
27608     return -1;
27609   }
27610   var assocIndexOf_default = assocIndexOf;
27611
27612   // node_modules/lodash-es/_listCacheDelete.js
27613   var arrayProto = Array.prototype;
27614   var splice = arrayProto.splice;
27615   function listCacheDelete(key) {
27616     var data = this.__data__, index = assocIndexOf_default(data, key);
27617     if (index < 0) {
27618       return false;
27619     }
27620     var lastIndex = data.length - 1;
27621     if (index == lastIndex) {
27622       data.pop();
27623     } else {
27624       splice.call(data, index, 1);
27625     }
27626     --this.size;
27627     return true;
27628   }
27629   var listCacheDelete_default = listCacheDelete;
27630
27631   // node_modules/lodash-es/_listCacheGet.js
27632   function listCacheGet(key) {
27633     var data = this.__data__, index = assocIndexOf_default(data, key);
27634     return index < 0 ? void 0 : data[index][1];
27635   }
27636   var listCacheGet_default = listCacheGet;
27637
27638   // node_modules/lodash-es/_listCacheHas.js
27639   function listCacheHas(key) {
27640     return assocIndexOf_default(this.__data__, key) > -1;
27641   }
27642   var listCacheHas_default = listCacheHas;
27643
27644   // node_modules/lodash-es/_listCacheSet.js
27645   function listCacheSet(key, value) {
27646     var data = this.__data__, index = assocIndexOf_default(data, key);
27647     if (index < 0) {
27648       ++this.size;
27649       data.push([key, value]);
27650     } else {
27651       data[index][1] = value;
27652     }
27653     return this;
27654   }
27655   var listCacheSet_default = listCacheSet;
27656
27657   // node_modules/lodash-es/_ListCache.js
27658   function ListCache(entries) {
27659     var index = -1, length2 = entries == null ? 0 : entries.length;
27660     this.clear();
27661     while (++index < length2) {
27662       var entry = entries[index];
27663       this.set(entry[0], entry[1]);
27664     }
27665   }
27666   ListCache.prototype.clear = listCacheClear_default;
27667   ListCache.prototype["delete"] = listCacheDelete_default;
27668   ListCache.prototype.get = listCacheGet_default;
27669   ListCache.prototype.has = listCacheHas_default;
27670   ListCache.prototype.set = listCacheSet_default;
27671   var ListCache_default = ListCache;
27672
27673   // node_modules/lodash-es/_Map.js
27674   var Map2 = getNative_default(root_default, "Map");
27675   var Map_default = Map2;
27676
27677   // node_modules/lodash-es/_mapCacheClear.js
27678   function mapCacheClear() {
27679     this.size = 0;
27680     this.__data__ = {
27681       "hash": new Hash_default(),
27682       "map": new (Map_default || ListCache_default)(),
27683       "string": new Hash_default()
27684     };
27685   }
27686   var mapCacheClear_default = mapCacheClear;
27687
27688   // node_modules/lodash-es/_isKeyable.js
27689   function isKeyable(value) {
27690     var type2 = typeof value;
27691     return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
27692   }
27693   var isKeyable_default = isKeyable;
27694
27695   // node_modules/lodash-es/_getMapData.js
27696   function getMapData(map2, key) {
27697     var data = map2.__data__;
27698     return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
27699   }
27700   var getMapData_default = getMapData;
27701
27702   // node_modules/lodash-es/_mapCacheDelete.js
27703   function mapCacheDelete(key) {
27704     var result = getMapData_default(this, key)["delete"](key);
27705     this.size -= result ? 1 : 0;
27706     return result;
27707   }
27708   var mapCacheDelete_default = mapCacheDelete;
27709
27710   // node_modules/lodash-es/_mapCacheGet.js
27711   function mapCacheGet(key) {
27712     return getMapData_default(this, key).get(key);
27713   }
27714   var mapCacheGet_default = mapCacheGet;
27715
27716   // node_modules/lodash-es/_mapCacheHas.js
27717   function mapCacheHas(key) {
27718     return getMapData_default(this, key).has(key);
27719   }
27720   var mapCacheHas_default = mapCacheHas;
27721
27722   // node_modules/lodash-es/_mapCacheSet.js
27723   function mapCacheSet(key, value) {
27724     var data = getMapData_default(this, key), size = data.size;
27725     data.set(key, value);
27726     this.size += data.size == size ? 0 : 1;
27727     return this;
27728   }
27729   var mapCacheSet_default = mapCacheSet;
27730
27731   // node_modules/lodash-es/_MapCache.js
27732   function MapCache(entries) {
27733     var index = -1, length2 = entries == null ? 0 : entries.length;
27734     this.clear();
27735     while (++index < length2) {
27736       var entry = entries[index];
27737       this.set(entry[0], entry[1]);
27738     }
27739   }
27740   MapCache.prototype.clear = mapCacheClear_default;
27741   MapCache.prototype["delete"] = mapCacheDelete_default;
27742   MapCache.prototype.get = mapCacheGet_default;
27743   MapCache.prototype.has = mapCacheHas_default;
27744   MapCache.prototype.set = mapCacheSet_default;
27745   var MapCache_default = MapCache;
27746
27747   // node_modules/lodash-es/toString.js
27748   function toString(value) {
27749     return value == null ? "" : baseToString_default(value);
27750   }
27751   var toString_default = toString;
27752
27753   // node_modules/lodash-es/_arrayPush.js
27754   function arrayPush(array2, values) {
27755     var index = -1, length2 = values.length, offset = array2.length;
27756     while (++index < length2) {
27757       array2[offset + index] = values[index];
27758     }
27759     return array2;
27760   }
27761   var arrayPush_default = arrayPush;
27762
27763   // node_modules/lodash-es/_basePropertyOf.js
27764   function basePropertyOf(object) {
27765     return function(key) {
27766       return object == null ? void 0 : object[key];
27767     };
27768   }
27769   var basePropertyOf_default = basePropertyOf;
27770
27771   // node_modules/lodash-es/_stackClear.js
27772   function stackClear() {
27773     this.__data__ = new ListCache_default();
27774     this.size = 0;
27775   }
27776   var stackClear_default = stackClear;
27777
27778   // node_modules/lodash-es/_stackDelete.js
27779   function stackDelete(key) {
27780     var data = this.__data__, result = data["delete"](key);
27781     this.size = data.size;
27782     return result;
27783   }
27784   var stackDelete_default = stackDelete;
27785
27786   // node_modules/lodash-es/_stackGet.js
27787   function stackGet(key) {
27788     return this.__data__.get(key);
27789   }
27790   var stackGet_default = stackGet;
27791
27792   // node_modules/lodash-es/_stackHas.js
27793   function stackHas(key) {
27794     return this.__data__.has(key);
27795   }
27796   var stackHas_default = stackHas;
27797
27798   // node_modules/lodash-es/_stackSet.js
27799   var LARGE_ARRAY_SIZE = 200;
27800   function stackSet(key, value) {
27801     var data = this.__data__;
27802     if (data instanceof ListCache_default) {
27803       var pairs2 = data.__data__;
27804       if (!Map_default || pairs2.length < LARGE_ARRAY_SIZE - 1) {
27805         pairs2.push([key, value]);
27806         this.size = ++data.size;
27807         return this;
27808       }
27809       data = this.__data__ = new MapCache_default(pairs2);
27810     }
27811     data.set(key, value);
27812     this.size = data.size;
27813     return this;
27814   }
27815   var stackSet_default = stackSet;
27816
27817   // node_modules/lodash-es/_Stack.js
27818   function Stack(entries) {
27819     var data = this.__data__ = new ListCache_default(entries);
27820     this.size = data.size;
27821   }
27822   Stack.prototype.clear = stackClear_default;
27823   Stack.prototype["delete"] = stackDelete_default;
27824   Stack.prototype.get = stackGet_default;
27825   Stack.prototype.has = stackHas_default;
27826   Stack.prototype.set = stackSet_default;
27827   var Stack_default = Stack;
27828
27829   // node_modules/lodash-es/_arrayFilter.js
27830   function arrayFilter(array2, predicate) {
27831     var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
27832     while (++index < length2) {
27833       var value = array2[index];
27834       if (predicate(value, index, array2)) {
27835         result[resIndex++] = value;
27836       }
27837     }
27838     return result;
27839   }
27840   var arrayFilter_default = arrayFilter;
27841
27842   // node_modules/lodash-es/stubArray.js
27843   function stubArray() {
27844     return [];
27845   }
27846   var stubArray_default = stubArray;
27847
27848   // node_modules/lodash-es/_getSymbols.js
27849   var objectProto10 = Object.prototype;
27850   var propertyIsEnumerable2 = objectProto10.propertyIsEnumerable;
27851   var nativeGetSymbols = Object.getOwnPropertySymbols;
27852   var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
27853     if (object == null) {
27854       return [];
27855     }
27856     object = Object(object);
27857     return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
27858       return propertyIsEnumerable2.call(object, symbol);
27859     });
27860   };
27861   var getSymbols_default = getSymbols;
27862
27863   // node_modules/lodash-es/_baseGetAllKeys.js
27864   function baseGetAllKeys(object, keysFunc, symbolsFunc) {
27865     var result = keysFunc(object);
27866     return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
27867   }
27868   var baseGetAllKeys_default = baseGetAllKeys;
27869
27870   // node_modules/lodash-es/_getAllKeys.js
27871   function getAllKeys(object) {
27872     return baseGetAllKeys_default(object, keys_default, getSymbols_default);
27873   }
27874   var getAllKeys_default = getAllKeys;
27875
27876   // node_modules/lodash-es/_DataView.js
27877   var DataView2 = getNative_default(root_default, "DataView");
27878   var DataView_default = DataView2;
27879
27880   // node_modules/lodash-es/_Promise.js
27881   var Promise2 = getNative_default(root_default, "Promise");
27882   var Promise_default = Promise2;
27883
27884   // node_modules/lodash-es/_Set.js
27885   var Set2 = getNative_default(root_default, "Set");
27886   var Set_default = Set2;
27887
27888   // node_modules/lodash-es/_getTag.js
27889   var mapTag2 = "[object Map]";
27890   var objectTag2 = "[object Object]";
27891   var promiseTag = "[object Promise]";
27892   var setTag2 = "[object Set]";
27893   var weakMapTag2 = "[object WeakMap]";
27894   var dataViewTag2 = "[object DataView]";
27895   var dataViewCtorString = toSource_default(DataView_default);
27896   var mapCtorString = toSource_default(Map_default);
27897   var promiseCtorString = toSource_default(Promise_default);
27898   var setCtorString = toSource_default(Set_default);
27899   var weakMapCtorString = toSource_default(WeakMap_default);
27900   var getTag = baseGetTag_default;
27901   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) {
27902     getTag = function(value) {
27903       var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
27904       if (ctorString) {
27905         switch (ctorString) {
27906           case dataViewCtorString:
27907             return dataViewTag2;
27908           case mapCtorString:
27909             return mapTag2;
27910           case promiseCtorString:
27911             return promiseTag;
27912           case setCtorString:
27913             return setTag2;
27914           case weakMapCtorString:
27915             return weakMapTag2;
27916         }
27917       }
27918       return result;
27919     };
27920   }
27921   var getTag_default = getTag;
27922
27923   // node_modules/lodash-es/_Uint8Array.js
27924   var Uint8Array2 = root_default.Uint8Array;
27925   var Uint8Array_default = Uint8Array2;
27926
27927   // node_modules/lodash-es/_setCacheAdd.js
27928   var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
27929   function setCacheAdd(value) {
27930     this.__data__.set(value, HASH_UNDEFINED3);
27931     return this;
27932   }
27933   var setCacheAdd_default = setCacheAdd;
27934
27935   // node_modules/lodash-es/_setCacheHas.js
27936   function setCacheHas(value) {
27937     return this.__data__.has(value);
27938   }
27939   var setCacheHas_default = setCacheHas;
27940
27941   // node_modules/lodash-es/_SetCache.js
27942   function SetCache(values) {
27943     var index = -1, length2 = values == null ? 0 : values.length;
27944     this.__data__ = new MapCache_default();
27945     while (++index < length2) {
27946       this.add(values[index]);
27947     }
27948   }
27949   SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
27950   SetCache.prototype.has = setCacheHas_default;
27951   var SetCache_default = SetCache;
27952
27953   // node_modules/lodash-es/_arraySome.js
27954   function arraySome(array2, predicate) {
27955     var index = -1, length2 = array2 == null ? 0 : array2.length;
27956     while (++index < length2) {
27957       if (predicate(array2[index], index, array2)) {
27958         return true;
27959       }
27960     }
27961     return false;
27962   }
27963   var arraySome_default = arraySome;
27964
27965   // node_modules/lodash-es/_cacheHas.js
27966   function cacheHas(cache, key) {
27967     return cache.has(key);
27968   }
27969   var cacheHas_default = cacheHas;
27970
27971   // node_modules/lodash-es/_equalArrays.js
27972   var COMPARE_PARTIAL_FLAG = 1;
27973   var COMPARE_UNORDERED_FLAG = 2;
27974   function equalArrays(array2, other, bitmask, customizer, equalFunc, stack) {
27975     var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other.length;
27976     if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
27977       return false;
27978     }
27979     var arrStacked = stack.get(array2);
27980     var othStacked = stack.get(other);
27981     if (arrStacked && othStacked) {
27982       return arrStacked == other && othStacked == array2;
27983     }
27984     var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
27985     stack.set(array2, other);
27986     stack.set(other, array2);
27987     while (++index < arrLength) {
27988       var arrValue = array2[index], othValue = other[index];
27989       if (customizer) {
27990         var compared = isPartial ? customizer(othValue, arrValue, index, other, array2, stack) : customizer(arrValue, othValue, index, array2, other, stack);
27991       }
27992       if (compared !== void 0) {
27993         if (compared) {
27994           continue;
27995         }
27996         result = false;
27997         break;
27998       }
27999       if (seen) {
28000         if (!arraySome_default(other, function(othValue2, othIndex) {
28001           if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
28002             return seen.push(othIndex);
28003           }
28004         })) {
28005           result = false;
28006           break;
28007         }
28008       } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
28009         result = false;
28010         break;
28011       }
28012     }
28013     stack["delete"](array2);
28014     stack["delete"](other);
28015     return result;
28016   }
28017   var equalArrays_default = equalArrays;
28018
28019   // node_modules/lodash-es/_mapToArray.js
28020   function mapToArray(map2) {
28021     var index = -1, result = Array(map2.size);
28022     map2.forEach(function(value, key) {
28023       result[++index] = [key, value];
28024     });
28025     return result;
28026   }
28027   var mapToArray_default = mapToArray;
28028
28029   // node_modules/lodash-es/_setToArray.js
28030   function setToArray(set4) {
28031     var index = -1, result = Array(set4.size);
28032     set4.forEach(function(value) {
28033       result[++index] = value;
28034     });
28035     return result;
28036   }
28037   var setToArray_default = setToArray;
28038
28039   // node_modules/lodash-es/_equalByTag.js
28040   var COMPARE_PARTIAL_FLAG2 = 1;
28041   var COMPARE_UNORDERED_FLAG2 = 2;
28042   var boolTag2 = "[object Boolean]";
28043   var dateTag2 = "[object Date]";
28044   var errorTag2 = "[object Error]";
28045   var mapTag3 = "[object Map]";
28046   var numberTag2 = "[object Number]";
28047   var regexpTag2 = "[object RegExp]";
28048   var setTag3 = "[object Set]";
28049   var stringTag2 = "[object String]";
28050   var symbolTag2 = "[object Symbol]";
28051   var arrayBufferTag2 = "[object ArrayBuffer]";
28052   var dataViewTag3 = "[object DataView]";
28053   var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
28054   var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
28055   function equalByTag(object, other, tag2, bitmask, customizer, equalFunc, stack) {
28056     switch (tag2) {
28057       case dataViewTag3:
28058         if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
28059           return false;
28060         }
28061         object = object.buffer;
28062         other = other.buffer;
28063       case arrayBufferTag2:
28064         if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
28065           return false;
28066         }
28067         return true;
28068       case boolTag2:
28069       case dateTag2:
28070       case numberTag2:
28071         return eq_default(+object, +other);
28072       case errorTag2:
28073         return object.name == other.name && object.message == other.message;
28074       case regexpTag2:
28075       case stringTag2:
28076         return object == other + "";
28077       case mapTag3:
28078         var convert = mapToArray_default;
28079       case setTag3:
28080         var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
28081         convert || (convert = setToArray_default);
28082         if (object.size != other.size && !isPartial) {
28083           return false;
28084         }
28085         var stacked = stack.get(object);
28086         if (stacked) {
28087           return stacked == other;
28088         }
28089         bitmask |= COMPARE_UNORDERED_FLAG2;
28090         stack.set(object, other);
28091         var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
28092         stack["delete"](object);
28093         return result;
28094       case symbolTag2:
28095         if (symbolValueOf) {
28096           return symbolValueOf.call(object) == symbolValueOf.call(other);
28097         }
28098     }
28099     return false;
28100   }
28101   var equalByTag_default = equalByTag;
28102
28103   // node_modules/lodash-es/_equalObjects.js
28104   var COMPARE_PARTIAL_FLAG3 = 1;
28105   var objectProto11 = Object.prototype;
28106   var hasOwnProperty8 = objectProto11.hasOwnProperty;
28107   function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
28108     var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
28109     if (objLength != othLength && !isPartial) {
28110       return false;
28111     }
28112     var index = objLength;
28113     while (index--) {
28114       var key = objProps[index];
28115       if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
28116         return false;
28117       }
28118     }
28119     var objStacked = stack.get(object);
28120     var othStacked = stack.get(other);
28121     if (objStacked && othStacked) {
28122       return objStacked == other && othStacked == object;
28123     }
28124     var result = true;
28125     stack.set(object, other);
28126     stack.set(other, object);
28127     var skipCtor = isPartial;
28128     while (++index < objLength) {
28129       key = objProps[index];
28130       var objValue = object[key], othValue = other[key];
28131       if (customizer) {
28132         var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
28133       }
28134       if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
28135         result = false;
28136         break;
28137       }
28138       skipCtor || (skipCtor = key == "constructor");
28139     }
28140     if (result && !skipCtor) {
28141       var objCtor = object.constructor, othCtor = other.constructor;
28142       if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
28143         result = false;
28144       }
28145     }
28146     stack["delete"](object);
28147     stack["delete"](other);
28148     return result;
28149   }
28150   var equalObjects_default = equalObjects;
28151
28152   // node_modules/lodash-es/_baseIsEqualDeep.js
28153   var COMPARE_PARTIAL_FLAG4 = 1;
28154   var argsTag3 = "[object Arguments]";
28155   var arrayTag2 = "[object Array]";
28156   var objectTag3 = "[object Object]";
28157   var objectProto12 = Object.prototype;
28158   var hasOwnProperty9 = objectProto12.hasOwnProperty;
28159   function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
28160     var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
28161     objTag = objTag == argsTag3 ? objectTag3 : objTag;
28162     othTag = othTag == argsTag3 ? objectTag3 : othTag;
28163     var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
28164     if (isSameTag && isBuffer_default(object)) {
28165       if (!isBuffer_default(other)) {
28166         return false;
28167       }
28168       objIsArr = true;
28169       objIsObj = false;
28170     }
28171     if (isSameTag && !objIsObj) {
28172       stack || (stack = new Stack_default());
28173       return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
28174     }
28175     if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
28176       var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
28177       if (objIsWrapped || othIsWrapped) {
28178         var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
28179         stack || (stack = new Stack_default());
28180         return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
28181       }
28182     }
28183     if (!isSameTag) {
28184       return false;
28185     }
28186     stack || (stack = new Stack_default());
28187     return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
28188   }
28189   var baseIsEqualDeep_default = baseIsEqualDeep;
28190
28191   // node_modules/lodash-es/_baseIsEqual.js
28192   function baseIsEqual(value, other, bitmask, customizer, stack) {
28193     if (value === other) {
28194       return true;
28195     }
28196     if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
28197       return value !== value && other !== other;
28198     }
28199     return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
28200   }
28201   var baseIsEqual_default = baseIsEqual;
28202
28203   // node_modules/lodash-es/now.js
28204   var now2 = function() {
28205     return root_default.Date.now();
28206   };
28207   var now_default = now2;
28208
28209   // node_modules/lodash-es/debounce.js
28210   var FUNC_ERROR_TEXT = "Expected a function";
28211   var nativeMax = Math.max;
28212   var nativeMin = Math.min;
28213   function debounce(func, wait, options2) {
28214     var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
28215     if (typeof func != "function") {
28216       throw new TypeError(FUNC_ERROR_TEXT);
28217     }
28218     wait = toNumber_default(wait) || 0;
28219     if (isObject_default(options2)) {
28220       leading = !!options2.leading;
28221       maxing = "maxWait" in options2;
28222       maxWait = maxing ? nativeMax(toNumber_default(options2.maxWait) || 0, wait) : maxWait;
28223       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28224     }
28225     function invokeFunc(time) {
28226       var args = lastArgs, thisArg = lastThis;
28227       lastArgs = lastThis = void 0;
28228       lastInvokeTime = time;
28229       result = func.apply(thisArg, args);
28230       return result;
28231     }
28232     function leadingEdge(time) {
28233       lastInvokeTime = time;
28234       timerId = setTimeout(timerExpired, wait);
28235       return leading ? invokeFunc(time) : result;
28236     }
28237     function remainingWait(time) {
28238       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
28239       return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
28240     }
28241     function shouldInvoke(time) {
28242       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
28243       return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
28244     }
28245     function timerExpired() {
28246       var time = now_default();
28247       if (shouldInvoke(time)) {
28248         return trailingEdge(time);
28249       }
28250       timerId = setTimeout(timerExpired, remainingWait(time));
28251     }
28252     function trailingEdge(time) {
28253       timerId = void 0;
28254       if (trailing && lastArgs) {
28255         return invokeFunc(time);
28256       }
28257       lastArgs = lastThis = void 0;
28258       return result;
28259     }
28260     function cancel() {
28261       if (timerId !== void 0) {
28262         clearTimeout(timerId);
28263       }
28264       lastInvokeTime = 0;
28265       lastArgs = lastCallTime = lastThis = timerId = void 0;
28266     }
28267     function flush() {
28268       return timerId === void 0 ? result : trailingEdge(now_default());
28269     }
28270     function debounced() {
28271       var time = now_default(), isInvoking = shouldInvoke(time);
28272       lastArgs = arguments;
28273       lastThis = this;
28274       lastCallTime = time;
28275       if (isInvoking) {
28276         if (timerId === void 0) {
28277           return leadingEdge(lastCallTime);
28278         }
28279         if (maxing) {
28280           clearTimeout(timerId);
28281           timerId = setTimeout(timerExpired, wait);
28282           return invokeFunc(lastCallTime);
28283         }
28284       }
28285       if (timerId === void 0) {
28286         timerId = setTimeout(timerExpired, wait);
28287       }
28288       return result;
28289     }
28290     debounced.cancel = cancel;
28291     debounced.flush = flush;
28292     return debounced;
28293   }
28294   var debounce_default = debounce;
28295
28296   // node_modules/lodash-es/_escapeHtmlChar.js
28297   var htmlEscapes = {
28298     "&": "&amp;",
28299     "<": "&lt;",
28300     ">": "&gt;",
28301     '"': "&quot;",
28302     "'": "&#39;"
28303   };
28304   var escapeHtmlChar = basePropertyOf_default(htmlEscapes);
28305   var escapeHtmlChar_default = escapeHtmlChar;
28306
28307   // node_modules/lodash-es/escape.js
28308   var reUnescapedHtml = /[&<>"']/g;
28309   var reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
28310   function escape2(string) {
28311     string = toString_default(string);
28312     return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar_default) : string;
28313   }
28314   var escape_default = escape2;
28315
28316   // node_modules/lodash-es/isEqual.js
28317   function isEqual(value, other) {
28318     return baseIsEqual_default(value, other);
28319   }
28320   var isEqual_default = isEqual;
28321
28322   // node_modules/lodash-es/isNumber.js
28323   var numberTag3 = "[object Number]";
28324   function isNumber(value) {
28325     return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag3;
28326   }
28327   var isNumber_default = isNumber;
28328
28329   // node_modules/lodash-es/throttle.js
28330   var FUNC_ERROR_TEXT2 = "Expected a function";
28331   function throttle(func, wait, options2) {
28332     var leading = true, trailing = true;
28333     if (typeof func != "function") {
28334       throw new TypeError(FUNC_ERROR_TEXT2);
28335     }
28336     if (isObject_default(options2)) {
28337       leading = "leading" in options2 ? !!options2.leading : leading;
28338       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28339     }
28340     return debounce_default(func, wait, {
28341       "leading": leading,
28342       "maxWait": wait,
28343       "trailing": trailing
28344     });
28345   }
28346   var throttle_default = throttle;
28347
28348   // node_modules/lodash-es/_unescapeHtmlChar.js
28349   var htmlUnescapes = {
28350     "&amp;": "&",
28351     "&lt;": "<",
28352     "&gt;": ">",
28353     "&quot;": '"',
28354     "&#39;": "'"
28355   };
28356   var unescapeHtmlChar = basePropertyOf_default(htmlUnescapes);
28357   var unescapeHtmlChar_default = unescapeHtmlChar;
28358
28359   // node_modules/lodash-es/unescape.js
28360   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
28361   var reHasEscapedHtml = RegExp(reEscapedHtml.source);
28362   function unescape(string) {
28363     string = toString_default(string);
28364     return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string;
28365   }
28366   var unescape_default = unescape;
28367
28368   // modules/util/detect.js
28369   var _detected;
28370   function utilDetect(refresh2) {
28371     if (_detected && !refresh2)
28372       return _detected;
28373     _detected = {};
28374     const ua = navigator.userAgent;
28375     let m2 = null;
28376     m2 = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i);
28377     if (m2 !== null) {
28378       _detected.browser = m2[1];
28379       _detected.version = m2[2];
28380     }
28381     if (!_detected.browser) {
28382       m2 = ua.match(/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i);
28383       if (m2 !== null) {
28384         _detected.browser = "msie";
28385         _detected.version = m2[1];
28386       }
28387     }
28388     if (!_detected.browser) {
28389       m2 = ua.match(/(opr)\/?\s*(\.?\d+(\.\d+)*)/i);
28390       if (m2 !== null) {
28391         _detected.browser = "Opera";
28392         _detected.version = m2[2];
28393       }
28394     }
28395     if (!_detected.browser) {
28396       m2 = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
28397       if (m2 !== null) {
28398         _detected.browser = m2[1];
28399         _detected.version = m2[2];
28400         m2 = ua.match(/version\/([\.\d]+)/i);
28401         if (m2 !== null)
28402           _detected.version = m2[1];
28403       }
28404     }
28405     if (!_detected.browser) {
28406       _detected.browser = navigator.appName;
28407       _detected.version = navigator.appVersion;
28408     }
28409     _detected.version = _detected.version.split(/\W/).slice(0, 2).join(".");
28410     _detected.opera = _detected.browser.toLowerCase() === "opera" && Number(_detected.version) < 15;
28411     if (_detected.browser.toLowerCase() === "msie") {
28412       _detected.ie = true;
28413       _detected.browser = "Internet Explorer";
28414       _detected.support = false;
28415     } else {
28416       _detected.ie = false;
28417       _detected.support = true;
28418     }
28419     _detected.filedrop = window.FileReader && "ondrop" in window;
28420     if (/Win/.test(ua)) {
28421       _detected.os = "win";
28422       _detected.platform = "Windows";
28423     } else if (/Mac/.test(ua)) {
28424       _detected.os = "mac";
28425       _detected.platform = "Macintosh";
28426     } else if (/X11/.test(ua) || /Linux/.test(ua)) {
28427       _detected.os = "linux";
28428       _detected.platform = "Linux";
28429     } else {
28430       _detected.os = "win";
28431       _detected.platform = "Unknown";
28432     }
28433     _detected.isMobileWebKit = (/\b(iPad|iPhone|iPod)\b/.test(ua) || // HACK: iPadOS 13+ requests desktop sites by default by using a Mac user agent,
28434     // so assume any "mac" with multitouch is actually iOS
28435     navigator.platform === "MacIntel" && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 1) && /WebKit/.test(ua) && !/Edge/.test(ua) && !window.MSStream;
28436     _detected.browserLocales = Array.from(new Set(
28437       // remove duplicates
28438       [navigator.language].concat(navigator.languages || []).concat([
28439         // old property for backwards compatibility
28440         navigator.userLanguage
28441       ]).filter(Boolean)
28442     ));
28443     const loc = window.top.location;
28444     let origin = loc.origin;
28445     if (!origin) {
28446       origin = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "");
28447     }
28448     _detected.host = origin + loc.pathname;
28449     return _detected;
28450   }
28451
28452   // modules/util/aes.js
28453   var import_aes_js = __toESM(require_aes_js());
28454   var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208];
28455   function utilAesEncrypt(text, key) {
28456     key = key || DEFAULT_128;
28457     const textBytes = import_aes_js.default.utils.utf8.toBytes(text);
28458     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28459     const encryptedBytes = aesCtr.encrypt(textBytes);
28460     const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes);
28461     return encryptedHex;
28462   }
28463   function utilAesDecrypt(encryptedHex, key) {
28464     key = key || DEFAULT_128;
28465     const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex);
28466     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28467     const decryptedBytes = aesCtr.decrypt(encryptedBytes);
28468     const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes);
28469     return text;
28470   }
28471
28472   // modules/util/clean_tags.js
28473   function utilCleanTags(tags) {
28474     var out = {};
28475     for (var k2 in tags) {
28476       if (!k2)
28477         continue;
28478       var v2 = tags[k2];
28479       if (v2 !== void 0) {
28480         out[k2] = cleanValue(k2, v2);
28481       }
28482     }
28483     return out;
28484     function cleanValue(k3, v3) {
28485       function keepSpaces(k4) {
28486         return /_hours|_times|:conditional$/.test(k4);
28487       }
28488       function skip(k4) {
28489         return /^(description|note|fixme)$/.test(k4);
28490       }
28491       if (skip(k3))
28492         return v3;
28493       var cleaned = v3.split(";").map(function(s2) {
28494         return s2.trim();
28495       }).join(keepSpaces(k3) ? "; " : ";");
28496       if (k3.indexOf("website") !== -1 || k3.indexOf("email") !== -1 || cleaned.indexOf("http") === 0) {
28497         cleaned = cleaned.replace(/[\u200B-\u200F\uFEFF]/g, "");
28498       }
28499       return cleaned;
28500     }
28501   }
28502
28503   // modules/util/get_set_value.js
28504   function utilGetSetValue(selection2, value, shouldUpdate) {
28505     function setValue(value2, shouldUpdate2) {
28506       function valueNull() {
28507         delete this.value;
28508       }
28509       function valueConstant() {
28510         if (shouldUpdate2(this.value, value2)) {
28511           this.value = value2;
28512         }
28513       }
28514       function valueFunction() {
28515         var x2 = value2.apply(this, arguments);
28516         if (x2 === null || x2 === void 0) {
28517           delete this.value;
28518         } else if (shouldUpdate2(this.value, x2)) {
28519           this.value = x2;
28520         }
28521       }
28522       return value2 === null || value2 === void 0 ? valueNull : typeof value2 === "function" ? valueFunction : valueConstant;
28523     }
28524     if (arguments.length === 1) {
28525       return selection2.property("value");
28526     }
28527     if (shouldUpdate === void 0) {
28528       shouldUpdate = (a2, b2) => a2 !== b2;
28529     }
28530     return selection2.each(setValue(value, shouldUpdate));
28531   }
28532
28533   // modules/util/keybinding.js
28534   function utilKeybinding(namespace) {
28535     var _keybindings = {};
28536     function testBindings(d3_event, isCapturing) {
28537       var didMatch = false;
28538       var bindings = Object.keys(_keybindings).map(function(id2) {
28539         return _keybindings[id2];
28540       });
28541       var i3, binding;
28542       for (i3 = 0; i3 < bindings.length; i3++) {
28543         binding = bindings[i3];
28544         if (!binding.event.modifiers.shiftKey)
28545           continue;
28546         if (!!binding.capture !== isCapturing)
28547           continue;
28548         if (matches(d3_event, binding, true)) {
28549           binding.callback(d3_event);
28550           didMatch = true;
28551           break;
28552         }
28553       }
28554       if (didMatch)
28555         return;
28556       for (i3 = 0; i3 < bindings.length; i3++) {
28557         binding = bindings[i3];
28558         if (binding.event.modifiers.shiftKey)
28559           continue;
28560         if (!!binding.capture !== isCapturing)
28561           continue;
28562         if (matches(d3_event, binding, false)) {
28563           binding.callback(d3_event);
28564           break;
28565         }
28566       }
28567       function matches(d3_event2, binding2, testShift) {
28568         var event = d3_event2;
28569         var isMatch = false;
28570         var tryKeyCode = true;
28571         if (event.key !== void 0) {
28572           tryKeyCode = event.key.charCodeAt(0) > 127;
28573           isMatch = true;
28574           if (binding2.event.key === void 0) {
28575             isMatch = false;
28576           } else if (Array.isArray(binding2.event.key)) {
28577             if (binding2.event.key.map(function(s2) {
28578               return s2.toLowerCase();
28579             }).indexOf(event.key.toLowerCase()) === -1) {
28580               isMatch = false;
28581             }
28582           } else {
28583             if (event.key.toLowerCase() !== binding2.event.key.toLowerCase()) {
28584               isMatch = false;
28585             }
28586           }
28587         }
28588         if (!isMatch && (tryKeyCode || binding2.event.modifiers.altKey)) {
28589           isMatch = event.keyCode === binding2.event.keyCode;
28590         }
28591         if (!isMatch)
28592           return false;
28593         if (!(event.ctrlKey && event.altKey)) {
28594           if (event.ctrlKey !== binding2.event.modifiers.ctrlKey)
28595             return false;
28596           if (event.altKey !== binding2.event.modifiers.altKey)
28597             return false;
28598         }
28599         if (event.metaKey !== binding2.event.modifiers.metaKey)
28600           return false;
28601         if (testShift && event.shiftKey !== binding2.event.modifiers.shiftKey)
28602           return false;
28603         return true;
28604       }
28605     }
28606     function capture(d3_event) {
28607       testBindings(d3_event, true);
28608     }
28609     function bubble(d3_event) {
28610       var tagName = select_default2(d3_event.target).node().tagName;
28611       if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
28612         return;
28613       }
28614       testBindings(d3_event, false);
28615     }
28616     function keybinding(selection2) {
28617       selection2 = selection2 || select_default2(document);
28618       selection2.on("keydown.capture." + namespace, capture, true);
28619       selection2.on("keydown.bubble." + namespace, bubble, false);
28620       return keybinding;
28621     }
28622     keybinding.unbind = function(selection2) {
28623       _keybindings = [];
28624       selection2 = selection2 || select_default2(document);
28625       selection2.on("keydown.capture." + namespace, null);
28626       selection2.on("keydown.bubble." + namespace, null);
28627       return keybinding;
28628     };
28629     keybinding.clear = function() {
28630       _keybindings = {};
28631       return keybinding;
28632     };
28633     keybinding.off = function(codes, capture2) {
28634       var arr = utilArrayUniq([].concat(codes));
28635       for (var i3 = 0; i3 < arr.length; i3++) {
28636         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28637         delete _keybindings[id2];
28638       }
28639       return keybinding;
28640     };
28641     keybinding.on = function(codes, callback, capture2) {
28642       if (typeof callback !== "function") {
28643         return keybinding.off(codes, capture2);
28644       }
28645       var arr = utilArrayUniq([].concat(codes));
28646       for (var i3 = 0; i3 < arr.length; i3++) {
28647         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28648         var binding = {
28649           id: id2,
28650           capture: capture2,
28651           callback,
28652           event: {
28653             key: void 0,
28654             // preferred
28655             keyCode: 0,
28656             // fallback
28657             modifiers: {
28658               shiftKey: false,
28659               ctrlKey: false,
28660               altKey: false,
28661               metaKey: false
28662             }
28663           }
28664         };
28665         if (_keybindings[id2]) {
28666           console.warn('warning: duplicate keybinding for "' + id2 + '"');
28667         }
28668         _keybindings[id2] = binding;
28669         var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g);
28670         for (var j2 = 0; j2 < matches.length; j2++) {
28671           if (matches[j2] === "++")
28672             matches[j2] = "+";
28673           if (matches[j2] in utilKeybinding.modifierCodes) {
28674             var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]];
28675             binding.event.modifiers[prop] = true;
28676           } else {
28677             binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2];
28678             if (matches[j2] in utilKeybinding.keyCodes) {
28679               binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]];
28680             }
28681           }
28682         }
28683       }
28684       return keybinding;
28685     };
28686     return keybinding;
28687   }
28688   utilKeybinding.modifierCodes = {
28689     // Shift key, ⇧
28690     "\u21E7": 16,
28691     shift: 16,
28692     // CTRL key, on Mac: ⌃
28693     "\u2303": 17,
28694     ctrl: 17,
28695     // ALT key, on Mac: ⌥ (Alt)
28696     "\u2325": 18,
28697     alt: 18,
28698     option: 18,
28699     // META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
28700     "\u2318": 91,
28701     meta: 91,
28702     cmd: 91,
28703     "super": 91,
28704     win: 91
28705   };
28706   utilKeybinding.modifierProperties = {
28707     16: "shiftKey",
28708     17: "ctrlKey",
28709     18: "altKey",
28710     91: "metaKey"
28711   };
28712   utilKeybinding.plusKeys = ["plus", "ffplus", "=", "ffequals", "\u2260", "\xB1"];
28713   utilKeybinding.minusKeys = ["_", "-", "ffminus", "dash", "\u2013", "\u2014"];
28714   utilKeybinding.keys = {
28715     // Backspace key, on Mac: ⌫ (Backspace)
28716     "\u232B": "Backspace",
28717     backspace: "Backspace",
28718     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28719     "\u21E5": "Tab",
28720     "\u21C6": "Tab",
28721     tab: "Tab",
28722     // Return key, ↩
28723     "\u21A9": "Enter",
28724     "\u21B5": "Enter",
28725     "\u23CE": "Enter",
28726     "return": "Enter",
28727     enter: "Enter",
28728     "\u2305": "Enter",
28729     // Pause/Break key
28730     "pause": "Pause",
28731     "pause-break": "Pause",
28732     // Caps Lock key, ⇪
28733     "\u21EA": "CapsLock",
28734     caps: "CapsLock",
28735     "caps-lock": "CapsLock",
28736     // Escape key, on Mac: ⎋, on Windows: Esc
28737     "\u238B": ["Escape", "Esc"],
28738     escape: ["Escape", "Esc"],
28739     esc: ["Escape", "Esc"],
28740     // Space key
28741     space: [" ", "Spacebar"],
28742     // Page-Up key, or pgup, on Mac: ↖
28743     "\u2196": "PageUp",
28744     pgup: "PageUp",
28745     "page-up": "PageUp",
28746     // Page-Down key, or pgdown, on Mac: ↘
28747     "\u2198": "PageDown",
28748     pgdown: "PageDown",
28749     "page-down": "PageDown",
28750     // END key, on Mac: ⇟
28751     "\u21DF": "End",
28752     end: "End",
28753     // HOME key, on Mac: ⇞
28754     "\u21DE": "Home",
28755     home: "Home",
28756     // Insert key, or ins
28757     ins: "Insert",
28758     insert: "Insert",
28759     // Delete key, on Mac: ⌦ (Delete)
28760     "\u2326": ["Delete", "Del"],
28761     del: ["Delete", "Del"],
28762     "delete": ["Delete", "Del"],
28763     // Left Arrow Key, or ←
28764     "\u2190": ["ArrowLeft", "Left"],
28765     left: ["ArrowLeft", "Left"],
28766     "arrow-left": ["ArrowLeft", "Left"],
28767     // Up Arrow Key, or ↑
28768     "\u2191": ["ArrowUp", "Up"],
28769     up: ["ArrowUp", "Up"],
28770     "arrow-up": ["ArrowUp", "Up"],
28771     // Right Arrow Key, or →
28772     "\u2192": ["ArrowRight", "Right"],
28773     right: ["ArrowRight", "Right"],
28774     "arrow-right": ["ArrowRight", "Right"],
28775     // Up Arrow Key, or ↓
28776     "\u2193": ["ArrowDown", "Down"],
28777     down: ["ArrowDown", "Down"],
28778     "arrow-down": ["ArrowDown", "Down"],
28779     // odities, stuff for backward compatibility (browsers and code):
28780     // Num-Multiply, or *
28781     "*": ["*", "Multiply"],
28782     star: ["*", "Multiply"],
28783     asterisk: ["*", "Multiply"],
28784     multiply: ["*", "Multiply"],
28785     // Num-Plus or +
28786     "+": ["+", "Add"],
28787     "plus": ["+", "Add"],
28788     // Num-Subtract, or -
28789     "-": ["-", "Subtract"],
28790     subtract: ["-", "Subtract"],
28791     "dash": ["-", "Subtract"],
28792     // Semicolon
28793     semicolon: ";",
28794     // = or equals
28795     equals: "=",
28796     // Comma, or ,
28797     comma: ",",
28798     // Period, or ., or full-stop
28799     period: ".",
28800     "full-stop": ".",
28801     // Slash, or /, or forward-slash
28802     slash: "/",
28803     "forward-slash": "/",
28804     // Tick, or `, or back-quote
28805     tick: "`",
28806     "back-quote": "`",
28807     // Open bracket, or [
28808     "open-bracket": "[",
28809     // Back slash, or \
28810     "back-slash": "\\",
28811     // Close bracket, or ]
28812     "close-bracket": "]",
28813     // Apostrophe, or Quote, or '
28814     quote: "'",
28815     apostrophe: "'",
28816     // NUMPAD 0-9
28817     "num-0": "0",
28818     "num-1": "1",
28819     "num-2": "2",
28820     "num-3": "3",
28821     "num-4": "4",
28822     "num-5": "5",
28823     "num-6": "6",
28824     "num-7": "7",
28825     "num-8": "8",
28826     "num-9": "9",
28827     // F1-F25
28828     f1: "F1",
28829     f2: "F2",
28830     f3: "F3",
28831     f4: "F4",
28832     f5: "F5",
28833     f6: "F6",
28834     f7: "F7",
28835     f8: "F8",
28836     f9: "F9",
28837     f10: "F10",
28838     f11: "F11",
28839     f12: "F12",
28840     f13: "F13",
28841     f14: "F14",
28842     f15: "F15",
28843     f16: "F16",
28844     f17: "F17",
28845     f18: "F18",
28846     f19: "F19",
28847     f20: "F20",
28848     f21: "F21",
28849     f22: "F22",
28850     f23: "F23",
28851     f24: "F24",
28852     f25: "F25"
28853   };
28854   utilKeybinding.keyCodes = {
28855     // Backspace key, on Mac: ⌫ (Backspace)
28856     "\u232B": 8,
28857     backspace: 8,
28858     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28859     "\u21E5": 9,
28860     "\u21C6": 9,
28861     tab: 9,
28862     // Return key, ↩
28863     "\u21A9": 13,
28864     "\u21B5": 13,
28865     "\u23CE": 13,
28866     "return": 13,
28867     enter: 13,
28868     "\u2305": 13,
28869     // Pause/Break key
28870     "pause": 19,
28871     "pause-break": 19,
28872     // Caps Lock key, ⇪
28873     "\u21EA": 20,
28874     caps: 20,
28875     "caps-lock": 20,
28876     // Escape key, on Mac: ⎋, on Windows: Esc
28877     "\u238B": 27,
28878     escape: 27,
28879     esc: 27,
28880     // Space key
28881     space: 32,
28882     // Page-Up key, or pgup, on Mac: ↖
28883     "\u2196": 33,
28884     pgup: 33,
28885     "page-up": 33,
28886     // Page-Down key, or pgdown, on Mac: ↘
28887     "\u2198": 34,
28888     pgdown: 34,
28889     "page-down": 34,
28890     // END key, on Mac: ⇟
28891     "\u21DF": 35,
28892     end: 35,
28893     // HOME key, on Mac: ⇞
28894     "\u21DE": 36,
28895     home: 36,
28896     // Insert key, or ins
28897     ins: 45,
28898     insert: 45,
28899     // Delete key, on Mac: ⌦ (Delete)
28900     "\u2326": 46,
28901     del: 46,
28902     "delete": 46,
28903     // Left Arrow Key, or ←
28904     "\u2190": 37,
28905     left: 37,
28906     "arrow-left": 37,
28907     // Up Arrow Key, or ↑
28908     "\u2191": 38,
28909     up: 38,
28910     "arrow-up": 38,
28911     // Right Arrow Key, or →
28912     "\u2192": 39,
28913     right: 39,
28914     "arrow-right": 39,
28915     // Up Arrow Key, or ↓
28916     "\u2193": 40,
28917     down: 40,
28918     "arrow-down": 40,
28919     // odities, printing characters that come out wrong:
28920     // Firefox Equals
28921     "ffequals": 61,
28922     // Num-Multiply, or *
28923     "*": 106,
28924     star: 106,
28925     asterisk: 106,
28926     multiply: 106,
28927     // Num-Plus or +
28928     "+": 107,
28929     "plus": 107,
28930     // Num-Subtract, or -
28931     "-": 109,
28932     subtract: 109,
28933     // Vertical Bar / Pipe
28934     "|": 124,
28935     // Firefox Plus
28936     "ffplus": 171,
28937     // Firefox Minus
28938     "ffminus": 173,
28939     // Semicolon
28940     ";": 186,
28941     semicolon: 186,
28942     // = or equals
28943     "=": 187,
28944     "equals": 187,
28945     // Comma, or ,
28946     ",": 188,
28947     comma: 188,
28948     // Dash / Underscore key
28949     "dash": 189,
28950     // Period, or ., or full-stop
28951     ".": 190,
28952     period: 190,
28953     "full-stop": 190,
28954     // Slash, or /, or forward-slash
28955     "/": 191,
28956     slash: 191,
28957     "forward-slash": 191,
28958     // Tick, or `, or back-quote
28959     "`": 192,
28960     tick: 192,
28961     "back-quote": 192,
28962     // Open bracket, or [
28963     "[": 219,
28964     "open-bracket": 219,
28965     // Back slash, or \
28966     "\\": 220,
28967     "back-slash": 220,
28968     // Close bracket, or ]
28969     "]": 221,
28970     "close-bracket": 221,
28971     // Apostrophe, or Quote, or '
28972     "'": 222,
28973     quote: 222,
28974     apostrophe: 222
28975   };
28976   var i = 95;
28977   var n = 0;
28978   while (++i < 106) {
28979     utilKeybinding.keyCodes["num-" + n] = i;
28980     ++n;
28981   }
28982   i = 47;
28983   n = 0;
28984   while (++i < 58) {
28985     utilKeybinding.keyCodes[n] = i;
28986     ++n;
28987   }
28988   i = 111;
28989   n = 1;
28990   while (++i < 136) {
28991     utilKeybinding.keyCodes["f" + n] = i;
28992     ++n;
28993   }
28994   i = 64;
28995   while (++i < 91) {
28996     utilKeybinding.keyCodes[String.fromCharCode(i).toLowerCase()] = i;
28997   }
28998
28999   // modules/util/object.js
29000   function utilObjectOmit(obj, omitKeys) {
29001     return Object.keys(obj).reduce(function(result, key) {
29002       if (omitKeys.indexOf(key) === -1) {
29003         result[key] = obj[key];
29004       }
29005       return result;
29006     }, {});
29007   }
29008
29009   // modules/util/rebind.js
29010   function utilRebind(target, source) {
29011     var i3 = 1, n3 = arguments.length, method;
29012     while (++i3 < n3) {
29013       target[method = arguments[i3]] = d3_rebind(target, source, source[method]);
29014     }
29015     return target;
29016   }
29017   function d3_rebind(target, source, method) {
29018     return function() {
29019       var value = method.apply(source, arguments);
29020       return value === source ? target : value;
29021     };
29022   }
29023
29024   // modules/util/session_mutex.js
29025   function utilSessionMutex(name) {
29026     var mutex = {};
29027     var intervalID;
29028     function renew() {
29029       var expires = /* @__PURE__ */ new Date();
29030       expires.setSeconds(expires.getSeconds() + 5);
29031       document.cookie = name + "=1; expires=" + expires.toUTCString() + "; sameSite=strict";
29032     }
29033     mutex.lock = function() {
29034       if (intervalID)
29035         return true;
29036       var cookie = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1");
29037       if (cookie)
29038         return false;
29039       renew();
29040       intervalID = window.setInterval(renew, 4e3);
29041       return true;
29042     };
29043     mutex.unlock = function() {
29044       if (!intervalID)
29045         return;
29046       document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; sameSite=strict";
29047       clearInterval(intervalID);
29048       intervalID = null;
29049     };
29050     mutex.locked = function() {
29051       return !!intervalID;
29052     };
29053     return mutex;
29054   }
29055
29056   // modules/util/tiler.js
29057   function utilTiler() {
29058     var _size = [256, 256];
29059     var _scale = 256;
29060     var _tileSize = 256;
29061     var _zoomExtent = [0, 20];
29062     var _translate = [_size[0] / 2, _size[1] / 2];
29063     var _margin = 0;
29064     var _skipNullIsland = false;
29065     function clamp3(num, min3, max3) {
29066       return Math.max(min3, Math.min(num, max3));
29067     }
29068     function nearNullIsland(tile) {
29069       var x2 = tile[0];
29070       var y2 = tile[1];
29071       var z2 = tile[2];
29072       if (z2 >= 7) {
29073         var center = Math.pow(2, z2 - 1);
29074         var width = Math.pow(2, z2 - 6);
29075         var min3 = center - width / 2;
29076         var max3 = center + width / 2 - 1;
29077         return x2 >= min3 && x2 <= max3 && y2 >= min3 && y2 <= max3;
29078       }
29079       return false;
29080     }
29081     function tiler9() {
29082       var z2 = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
29083       var z0 = clamp3(Math.round(z2), _zoomExtent[0], _zoomExtent[1]);
29084       var tileMin = 0;
29085       var tileMax = Math.pow(2, z0) - 1;
29086       var log2ts = Math.log(_tileSize) * Math.LOG2E;
29087       var k2 = Math.pow(2, z2 - z0 + log2ts);
29088       var origin = [
29089         (_translate[0] - _scale / 2) / k2,
29090         (_translate[1] - _scale / 2) / k2
29091       ];
29092       var cols = range(
29093         clamp3(Math.floor(-origin[0]) - _margin, tileMin, tileMax + 1),
29094         clamp3(Math.ceil(_size[0] / k2 - origin[0]) + _margin, tileMin, tileMax + 1)
29095       );
29096       var rows = range(
29097         clamp3(Math.floor(-origin[1]) - _margin, tileMin, tileMax + 1),
29098         clamp3(Math.ceil(_size[1] / k2 - origin[1]) + _margin, tileMin, tileMax + 1)
29099       );
29100       var tiles = [];
29101       for (var i3 = 0; i3 < rows.length; i3++) {
29102         var y2 = rows[i3];
29103         for (var j2 = 0; j2 < cols.length; j2++) {
29104           var x2 = cols[j2];
29105           if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) {
29106             tiles.unshift([x2, y2, z0]);
29107           } else {
29108             tiles.push([x2, y2, z0]);
29109           }
29110         }
29111       }
29112       tiles.translate = origin;
29113       tiles.scale = k2;
29114       return tiles;
29115     }
29116     tiler9.getTiles = function(projection2) {
29117       var origin = [
29118         projection2.scale() * Math.PI - projection2.translate()[0],
29119         projection2.scale() * Math.PI - projection2.translate()[1]
29120       ];
29121       this.size(projection2.clipExtent()[1]).scale(projection2.scale() * 2 * Math.PI).translate(projection2.translate());
29122       var tiles = tiler9();
29123       var ts = tiles.scale;
29124       return tiles.map(function(tile) {
29125         if (_skipNullIsland && nearNullIsland(tile)) {
29126           return false;
29127         }
29128         var x2 = tile[0] * ts - origin[0];
29129         var y2 = tile[1] * ts - origin[1];
29130         return {
29131           id: tile.toString(),
29132           xyz: tile,
29133           extent: geoExtent(
29134             projection2.invert([x2, y2 + ts]),
29135             projection2.invert([x2 + ts, y2])
29136           )
29137         };
29138       }).filter(Boolean);
29139     };
29140     tiler9.getGeoJSON = function(projection2) {
29141       var features = tiler9.getTiles(projection2).map(function(tile) {
29142         return {
29143           type: "Feature",
29144           properties: {
29145             id: tile.id,
29146             name: tile.id
29147           },
29148           geometry: {
29149             type: "Polygon",
29150             coordinates: [tile.extent.polygon()]
29151           }
29152         };
29153       });
29154       return {
29155         type: "FeatureCollection",
29156         features
29157       };
29158     };
29159     tiler9.tileSize = function(val) {
29160       if (!arguments.length)
29161         return _tileSize;
29162       _tileSize = val;
29163       return tiler9;
29164     };
29165     tiler9.zoomExtent = function(val) {
29166       if (!arguments.length)
29167         return _zoomExtent;
29168       _zoomExtent = val;
29169       return tiler9;
29170     };
29171     tiler9.size = function(val) {
29172       if (!arguments.length)
29173         return _size;
29174       _size = val;
29175       return tiler9;
29176     };
29177     tiler9.scale = function(val) {
29178       if (!arguments.length)
29179         return _scale;
29180       _scale = val;
29181       return tiler9;
29182     };
29183     tiler9.translate = function(val) {
29184       if (!arguments.length)
29185         return _translate;
29186       _translate = val;
29187       return tiler9;
29188     };
29189     tiler9.margin = function(val) {
29190       if (!arguments.length)
29191         return _margin;
29192       _margin = +val;
29193       return tiler9;
29194     };
29195     tiler9.skipNullIsland = function(val) {
29196       if (!arguments.length)
29197         return _skipNullIsland;
29198       _skipNullIsland = val;
29199       return tiler9;
29200     };
29201     return tiler9;
29202   }
29203
29204   // modules/util/trigger_event.js
29205   function utilTriggerEvent(target, type2, eventProperties) {
29206     target.each(function() {
29207       var evt = document.createEvent("HTMLEvents");
29208       evt.initEvent(type2, true, true);
29209       for (var prop in eventProperties) {
29210         evt[prop] = eventProperties[prop];
29211       }
29212       this.dispatchEvent(evt);
29213     });
29214   }
29215
29216   // modules/util/units.js
29217   var OSM_PRECISION = 7;
29218   function displayLength(m2, isImperial) {
29219     var d2 = m2 * (isImperial ? 3.28084 : 1);
29220     var unit2;
29221     if (isImperial) {
29222       if (d2 >= 5280) {
29223         d2 /= 5280;
29224         unit2 = "miles";
29225       } else {
29226         unit2 = "feet";
29227       }
29228     } else {
29229       if (d2 >= 1e3) {
29230         d2 /= 1e3;
29231         unit2 = "kilometers";
29232       } else {
29233         unit2 = "meters";
29234       }
29235     }
29236     return _t("units." + unit2, {
29237       quantity: d2.toLocaleString(_mainLocalizer.localeCode(), {
29238         maximumSignificantDigits: 4
29239       })
29240     });
29241   }
29242   function displayArea(m2, isImperial) {
29243     var locale2 = _mainLocalizer.localeCode();
29244     var d2 = m2 * (isImperial ? 10.7639111056 : 1);
29245     var d1, d22, area;
29246     var unit1 = "";
29247     var unit2 = "";
29248     if (isImperial) {
29249       if (d2 >= 6969600) {
29250         d1 = d2 / 27878400;
29251         unit1 = "square_miles";
29252       } else {
29253         d1 = d2;
29254         unit1 = "square_feet";
29255       }
29256       if (d2 > 4356 && d2 < 4356e4) {
29257         d22 = d2 / 43560;
29258         unit2 = "acres";
29259       }
29260     } else {
29261       if (d2 >= 25e4) {
29262         d1 = d2 / 1e6;
29263         unit1 = "square_kilometers";
29264       } else {
29265         d1 = d2;
29266         unit1 = "square_meters";
29267       }
29268       if (d2 > 1e3 && d2 < 1e7) {
29269         d22 = d2 / 1e4;
29270         unit2 = "hectares";
29271       }
29272     }
29273     area = _t("units." + unit1, {
29274       quantity: d1.toLocaleString(locale2, {
29275         maximumSignificantDigits: 4
29276       })
29277     });
29278     if (d22) {
29279       return _t("units.area_pair", {
29280         area1: area,
29281         area2: _t("units." + unit2, {
29282           quantity: d22.toLocaleString(locale2, {
29283             maximumSignificantDigits: 2
29284           })
29285         })
29286       });
29287     } else {
29288       return area;
29289     }
29290   }
29291   function wrap(x2, min3, max3) {
29292     var d2 = max3 - min3;
29293     return ((x2 - min3) % d2 + d2) % d2 + min3;
29294   }
29295   function clamp(x2, min3, max3) {
29296     return Math.max(min3, Math.min(x2, max3));
29297   }
29298   function roundToDecimal(target, decimalPlace) {
29299     target = Number(target);
29300     decimalPlace = Number(decimalPlace);
29301     const factor = Math.pow(10, decimalPlace);
29302     return Math.round(target * factor) / factor;
29303   }
29304   function displayCoordinate(deg, pos, neg) {
29305     var displayCoordinate2;
29306     var locale2 = _mainLocalizer.localeCode();
29307     var degreesFloor = Math.floor(Math.abs(deg));
29308     var min3 = (Math.abs(deg) - degreesFloor) * 60;
29309     var minFloor = Math.floor(min3);
29310     var sec = (min3 - minFloor) * 60;
29311     var fix = roundToDecimal(sec, 8);
29312     var secRounded = roundToDecimal(fix, 0);
29313     if (secRounded === 60) {
29314       secRounded = 0;
29315       minFloor += 1;
29316       if (minFloor === 60) {
29317         minFloor = 0;
29318         degreesFloor += 1;
29319       }
29320     }
29321     displayCoordinate2 = _t("units.arcdegrees", {
29322       quantity: degreesFloor.toLocaleString(locale2)
29323     }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", {
29324       quantity: minFloor.toLocaleString(locale2)
29325     }) : "") + (secRounded !== 0 ? _t("units.arcseconds", {
29326       quantity: secRounded.toLocaleString(locale2)
29327     }) : "");
29328     if (deg === 0) {
29329       return displayCoordinate2;
29330     } else {
29331       return _t("units.coordinate", {
29332         coordinate: displayCoordinate2,
29333         direction: _t("units." + (deg > 0 ? pos : neg))
29334       });
29335     }
29336   }
29337   function dmsCoordinatePair(coord2) {
29338     return _t("units.coordinate_pair", {
29339       latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"),
29340       longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west")
29341     });
29342   }
29343   function decimalCoordinatePair(coord2) {
29344     return _t("units.coordinate_pair", {
29345       latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION),
29346       longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION)
29347     });
29348   }
29349   function dmsMatcher(q2) {
29350     const matchers = [
29351       // D M SS , D M SS  ex: 35 11 10.1 , 136 49 53.8
29352       {
29353         condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/,
29354         parser: function(q3) {
29355           const match = this.condition.exec(q3);
29356           const lat = +match[2] + +match[3] / 60 + +match[4] / 3600;
29357           const lng = +match[6] + +match[7] / 60 + +match[8] / 3600;
29358           const isNegLat = match[1] === "-" ? -lat : lat;
29359           const isNegLng = match[5] === "-" ? -lng : lng;
29360           const d2 = [isNegLat, isNegLng];
29361           return d2;
29362         }
29363       },
29364       // D MM , D MM ex: 35 11.1683 , 136 49.8966
29365       {
29366         condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/,
29367         parser: function(q3) {
29368           const match = this.condition.exec(q3);
29369           const lat = +match[2] + +match[3] / 60;
29370           const lng = +match[5] + +match[6] / 60;
29371           const isNegLat = match[1] === "-" ? -lat : lat;
29372           const isNegLng = match[4] === "-" ? -lng : lng;
29373           const d2 = [isNegLat, isNegLng];
29374           return d2;
29375         }
29376       }
29377     ];
29378     for (const matcher of matchers) {
29379       if (matcher.condition.test(q2)) {
29380         return matcher.parser(q2);
29381       }
29382     }
29383     return null;
29384   }
29385
29386   // modules/core/localizer.js
29387   var _mainLocalizer = coreLocalizer();
29388   var _t = _mainLocalizer.t;
29389   function coreLocalizer() {
29390     let localizer = {};
29391     let _dataLanguages = {};
29392     let _dataLocales = {};
29393     let _localeStrings = {};
29394     let _localeCode = "en-US";
29395     let _localeCodes = ["en-US", "en"];
29396     let _languageCode = "en";
29397     let _textDirection = "ltr";
29398     let _usesMetric = false;
29399     let _languageNames = {};
29400     let _scriptNames = {};
29401     localizer.localeCode = () => _localeCode;
29402     localizer.localeCodes = () => _localeCodes;
29403     localizer.languageCode = () => _languageCode;
29404     localizer.textDirection = () => _textDirection;
29405     localizer.usesMetric = () => _usesMetric;
29406     localizer.languageNames = () => _languageNames;
29407     localizer.scriptNames = () => _scriptNames;
29408     let _preferredLocaleCodes = [];
29409     localizer.preferredLocaleCodes = function(codes) {
29410       if (!arguments.length)
29411         return _preferredLocaleCodes;
29412       if (typeof codes === "string") {
29413         _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean);
29414       } else {
29415         _preferredLocaleCodes = codes;
29416       }
29417       return localizer;
29418     };
29419     var _loadPromise;
29420     localizer.ensureLoaded = () => {
29421       if (_loadPromise)
29422         return _loadPromise;
29423       let filesToFetch = [
29424         "languages",
29425         // load the list of languages
29426         "locales"
29427         // load the list of supported locales
29428       ];
29429       const localeDirs = {
29430         general: "locales",
29431         tagging: presetsCdnUrl + "dist/translations"
29432       };
29433       let fileMap = _mainFileFetcher.fileMap();
29434       for (let scopeId in localeDirs) {
29435         const key = "locales_index_".concat(scopeId);
29436         if (!fileMap[key]) {
29437           fileMap[key] = localeDirs[scopeId] + "/index.min.json";
29438         }
29439         filesToFetch.push(key);
29440       }
29441       return _loadPromise = Promise.all(filesToFetch.map((key) => _mainFileFetcher.get(key))).then((results) => {
29442         _dataLanguages = results[0];
29443         _dataLocales = results[1];
29444         let indexes = results.slice(2);
29445         let requestedLocales = (_preferredLocaleCodes || []).concat(utilDetect().browserLocales).concat(["en"]);
29446         _localeCodes = localesToUseFrom(requestedLocales);
29447         _localeCode = _localeCodes[0];
29448         let loadStringsPromises = [];
29449         indexes.forEach((index, i3) => {
29450           const fullCoverageIndex = _localeCodes.findIndex(function(locale2) {
29451             return index[locale2] && index[locale2].pct === 1;
29452           });
29453           _localeCodes.slice(0, fullCoverageIndex + 1).forEach(function(code) {
29454             let scopeId = Object.keys(localeDirs)[i3];
29455             let directory = Object.values(localeDirs)[i3];
29456             if (index[code])
29457               loadStringsPromises.push(localizer.loadLocale(code, scopeId, directory));
29458           });
29459         });
29460         return Promise.all(loadStringsPromises);
29461       }).then(() => {
29462         updateForCurrentLocale();
29463       }).catch((err) => console.error(err));
29464     };
29465     function localesToUseFrom(requestedLocales) {
29466       let supportedLocales = _dataLocales;
29467       let toUse = [];
29468       for (let i3 in requestedLocales) {
29469         let locale2 = requestedLocales[i3];
29470         if (supportedLocales[locale2])
29471           toUse.push(locale2);
29472         if (locale2.includes("-")) {
29473           let langPart = locale2.split("-")[0];
29474           if (supportedLocales[langPart])
29475             toUse.push(langPart);
29476         }
29477       }
29478       return utilArrayUniq(toUse);
29479     }
29480     function updateForCurrentLocale() {
29481       if (!_localeCode)
29482         return;
29483       _languageCode = _localeCode.split("-")[0];
29484       const currentData = _dataLocales[_localeCode] || _dataLocales[_languageCode];
29485       const hash = utilStringQs(window.location.hash);
29486       if (hash.rtl === "true") {
29487         _textDirection = "rtl";
29488       } else if (hash.rtl === "false") {
29489         _textDirection = "ltr";
29490       } else {
29491         _textDirection = currentData && currentData.rtl ? "rtl" : "ltr";
29492       }
29493       let locale2 = _localeCode;
29494       if (locale2.toLowerCase() === "en-us")
29495         locale2 = "en";
29496       _languageNames = _localeStrings.general[locale2].languageNames || _localeStrings.general[_languageCode].languageNames;
29497       _scriptNames = _localeStrings.general[locale2].scriptNames || _localeStrings.general[_languageCode].scriptNames;
29498       _usesMetric = _localeCode.slice(-3).toLowerCase() !== "-us";
29499     }
29500     localizer.loadLocale = (locale2, scopeId, directory) => {
29501       if (locale2.toLowerCase() === "en-us")
29502         locale2 = "en";
29503       if (_localeStrings[scopeId] && _localeStrings[scopeId][locale2]) {
29504         return Promise.resolve(locale2);
29505       }
29506       let fileMap = _mainFileFetcher.fileMap();
29507       const key = "locale_".concat(scopeId, "_").concat(locale2);
29508       if (!fileMap[key]) {
29509         fileMap[key] = "".concat(directory, "/").concat(locale2, ".min.json");
29510       }
29511       return _mainFileFetcher.get(key).then((d2) => {
29512         if (!_localeStrings[scopeId])
29513           _localeStrings[scopeId] = {};
29514         _localeStrings[scopeId][locale2] = d2[locale2];
29515         return locale2;
29516       });
29517     };
29518     localizer.pluralRule = function(number3) {
29519       return pluralRule(number3, _localeCode);
29520     };
29521     function pluralRule(number3, localeCode) {
29522       const rules = "Intl" in window && Intl.PluralRules && new Intl.PluralRules(localeCode);
29523       if (rules) {
29524         return rules.select(number3);
29525       }
29526       if (number3 === 1)
29527         return "one";
29528       return "other";
29529     }
29530     localizer.tInfo = function(origStringId, replacements, locale2) {
29531       let stringId = origStringId.trim();
29532       let scopeId = "general";
29533       if (stringId[0] === "_") {
29534         let split = stringId.split(".");
29535         scopeId = split[0].slice(1);
29536         stringId = split.slice(1).join(".");
29537       }
29538       locale2 = locale2 || _localeCode;
29539       let path = stringId.split(".").map((s2) => s2.replace(/<TX_DOT>/g, ".")).reverse();
29540       let stringsKey = locale2;
29541       if (stringsKey.toLowerCase() === "en-us")
29542         stringsKey = "en";
29543       let result = _localeStrings && _localeStrings[scopeId] && _localeStrings[scopeId][stringsKey];
29544       while (result !== void 0 && path.length) {
29545         result = result[path.pop()];
29546       }
29547       if (result !== void 0) {
29548         if (replacements) {
29549           if (typeof result === "object" && Object.keys(result).length) {
29550             const number3 = Object.values(replacements).find(function(value) {
29551               return typeof value === "number";
29552             });
29553             if (number3 !== void 0) {
29554               const rule = pluralRule(number3, locale2);
29555               if (result[rule]) {
29556                 result = result[rule];
29557               } else {
29558                 result = Object.values(result)[0];
29559               }
29560             }
29561           }
29562           if (typeof result === "string") {
29563             for (let key in replacements) {
29564               let value = replacements[key];
29565               if (typeof value === "number") {
29566                 if (value.toLocaleString) {
29567                   value = value.toLocaleString(locale2, {
29568                     style: "decimal",
29569                     useGrouping: true,
29570                     minimumFractionDigits: 0
29571                   });
29572                 } else {
29573                   value = value.toString();
29574                 }
29575               }
29576               const token = "{".concat(key, "}");
29577               const regex = new RegExp(token, "g");
29578               result = result.replace(regex, value);
29579             }
29580           }
29581         }
29582         if (typeof result === "string") {
29583           return {
29584             text: result,
29585             locale: locale2
29586           };
29587         }
29588       }
29589       let index = _localeCodes.indexOf(locale2);
29590       if (index >= 0 && index < _localeCodes.length - 1) {
29591         let fallback = _localeCodes[index + 1];
29592         return localizer.tInfo(origStringId, replacements, fallback);
29593       }
29594       if (replacements && "default" in replacements) {
29595         return {
29596           text: replacements.default,
29597           locale: null
29598         };
29599       }
29600       const missing = "Missing ".concat(locale2, " translation: ").concat(origStringId);
29601       if (typeof console !== "undefined")
29602         console.error(missing);
29603       return {
29604         text: missing,
29605         locale: "en"
29606       };
29607     };
29608     localizer.hasTextForStringId = function(stringId) {
29609       return !!localizer.tInfo(stringId, { default: "nothing found" }).locale;
29610     };
29611     localizer.t = function(stringId, replacements, locale2) {
29612       return localizer.tInfo(stringId, replacements, locale2).text;
29613     };
29614     localizer.t.html = function(stringId, replacements, locale2) {
29615       replacements = Object.assign({}, replacements);
29616       for (var k2 in replacements) {
29617         if (typeof replacements[k2] === "string") {
29618           replacements[k2] = escape_default(replacements[k2]);
29619         }
29620         if (typeof replacements[k2] === "object" && typeof replacements[k2].html === "string") {
29621           replacements[k2] = replacements[k2].html;
29622         }
29623       }
29624       const info = localizer.tInfo(stringId, replacements, locale2);
29625       if (info.text) {
29626         return '<span class="localized-text" lang="'.concat(info.locale || "und", '">').concat(info.text, "</span>");
29627       } else {
29628         return "";
29629       }
29630     };
29631     localizer.t.append = function(stringId, replacements, locale2) {
29632       const ret = function(selection2) {
29633         const info = localizer.tInfo(stringId, replacements, locale2);
29634         return selection2.append("span").attr("class", "localized-text").attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
29635       };
29636       ret.stringId = stringId;
29637       return ret;
29638     };
29639     localizer.languageName = (code, options2) => {
29640       if (_languageNames && _languageNames[code]) {
29641         return _languageNames[code];
29642       }
29643       if (options2 && options2.localOnly)
29644         return null;
29645       const langInfo = _dataLanguages[code];
29646       if (langInfo) {
29647         if (langInfo.nativeName) {
29648           return localizer.t("translate.language_and_code", { language: langInfo.nativeName, code });
29649         } else if (langInfo.base && langInfo.script) {
29650           const base = langInfo.base;
29651           if (_languageNames && _languageNames[base]) {
29652             const scriptCode = langInfo.script;
29653             const script = _scriptNames && _scriptNames[scriptCode] || scriptCode;
29654             return localizer.t("translate.language_and_code", { language: _languageNames[base], code: script });
29655           } else if (_dataLanguages[base] && _dataLanguages[base].nativeName) {
29656             return localizer.t("translate.language_and_code", { language: _dataLanguages[base].nativeName, code });
29657           }
29658         }
29659       }
29660       return code;
29661     };
29662     localizer.floatFormatter = (locale2) => {
29663       if (!("Intl" in window && "NumberFormat" in Intl && "formatToParts" in Intl.NumberFormat.prototype)) {
29664         return (number3, fractionDigits) => {
29665           return fractionDigits === void 0 ? number3.toString() : number3.toFixed(fractionDigits);
29666         };
29667       } else {
29668         return (number3, fractionDigits) => number3.toLocaleString(locale2, {
29669           minimumFractionDigits: fractionDigits,
29670           maximumFractionDigits: fractionDigits === void 0 ? 20 : fractionDigits
29671         });
29672       }
29673     };
29674     localizer.floatParser = (locale2) => {
29675       const polyfill = (string) => +string.trim();
29676       if (!("Intl" in window && "NumberFormat" in Intl))
29677         return polyfill;
29678       const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29679       if (!("formatToParts" in format2))
29680         return polyfill;
29681       const parts = format2.formatToParts(-12345.6);
29682       const numerals = Array.from({ length: 10 }).map((_2, i3) => format2.format(i3));
29683       const index = new Map(numerals.map((d2, i3) => [d2, i3]));
29684       const literalPart = parts.find((d2) => d2.type === "literal");
29685       const literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29686       const groupPart = parts.find((d2) => d2.type === "group");
29687       const group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29688       const decimalPart = parts.find((d2) => d2.type === "decimal");
29689       const decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29690       const numeral = new RegExp("[".concat(numerals.join(""), "]"), "g");
29691       const getIndex = (d2) => index.get(d2);
29692       return (string) => {
29693         string = string.trim();
29694         if (literal)
29695           string = string.replace(literal, "");
29696         if (group)
29697           string = string.replace(group, "");
29698         if (decimal)
29699           string = string.replace(decimal, ".");
29700         string = string.replace(numeral, getIndex);
29701         return string ? +string : NaN;
29702       };
29703     };
29704     localizer.decimalPlaceCounter = (locale2) => {
29705       var literal, group, decimal;
29706       if ("Intl" in window && "NumberFormat" in Intl) {
29707         const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29708         if ("formatToParts" in format2) {
29709           const parts = format2.formatToParts(-12345.6);
29710           const literalPart = parts.find((d2) => d2.type === "literal");
29711           literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29712           const groupPart = parts.find((d2) => d2.type === "group");
29713           group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29714           const decimalPart = parts.find((d2) => d2.type === "decimal");
29715           decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29716         }
29717       }
29718       return (string) => {
29719         string = string.trim();
29720         if (literal)
29721           string = string.replace(literal, "");
29722         if (group)
29723           string = string.replace(group, "");
29724         const parts = string.split(decimal || ".");
29725         return parts && parts[1] && parts[1].length || 0;
29726       };
29727     };
29728     return localizer;
29729   }
29730
29731   // modules/presets/collection.js
29732   function presetCollection(collection) {
29733     const MAXRESULTS = 50;
29734     let _this = {};
29735     let _memo = {};
29736     _this.collection = collection;
29737     _this.item = (id2) => {
29738       if (_memo[id2])
29739         return _memo[id2];
29740       const found = _this.collection.find((d2) => d2.id === id2);
29741       if (found)
29742         _memo[id2] = found;
29743       return found;
29744     };
29745     _this.index = (id2) => _this.collection.findIndex((d2) => d2.id === id2);
29746     _this.matchGeometry = (geometry) => {
29747       return presetCollection(
29748         _this.collection.filter((d2) => d2.matchGeometry(geometry))
29749       );
29750     };
29751     _this.matchAllGeometry = (geometries) => {
29752       return presetCollection(
29753         _this.collection.filter((d2) => d2 && d2.matchAllGeometry(geometries))
29754       );
29755     };
29756     _this.matchAnyGeometry = (geometries) => {
29757       return presetCollection(
29758         _this.collection.filter((d2) => geometries.some((geom) => d2.matchGeometry(geom)))
29759       );
29760     };
29761     _this.fallback = (geometry) => {
29762       let id2 = geometry;
29763       if (id2 === "vertex")
29764         id2 = "point";
29765       return _this.item(id2);
29766     };
29767     _this.search = (value, geometry, loc) => {
29768       if (!value)
29769         return _this;
29770       value = value.toLowerCase().trim();
29771       function leading(a2) {
29772         const index = a2.indexOf(value);
29773         return index === 0 || a2[index - 1] === " ";
29774       }
29775       function leadingStrict(a2) {
29776         const index = a2.indexOf(value);
29777         return index === 0;
29778       }
29779       function sortPresets(nameProp, aliasesProp) {
29780         return function sortNames(a2, b2) {
29781           let aCompare = a2[nameProp]();
29782           let bCompare = b2[nameProp]();
29783           if (aliasesProp) {
29784             const findMatchingAlias = (strings) => {
29785               if (strings.some((s2) => s2 === value)) {
29786                 return strings.find((s2) => s2 === value);
29787               } else {
29788                 return strings.filter((s2) => s2.includes(value)).sort((a3, b3) => a3.length - b3.length)[0];
29789               }
29790             };
29791             aCompare = findMatchingAlias([aCompare].concat(a2[aliasesProp]()));
29792             bCompare = findMatchingAlias([bCompare].concat(b2[aliasesProp]()));
29793           }
29794           if (value === aCompare)
29795             return -1;
29796           if (value === bCompare)
29797             return 1;
29798           let i3 = b2.originalScore - a2.originalScore;
29799           if (i3 !== 0)
29800             return i3;
29801           i3 = aCompare.indexOf(value) - bCompare.indexOf(value);
29802           if (i3 !== 0)
29803             return i3;
29804           return aCompare.length - bCompare.length;
29805         };
29806       }
29807       let pool = _this.collection;
29808       if (Array.isArray(loc)) {
29809         const validHere = _sharedLocationManager.locationSetsAt(loc);
29810         pool = pool.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
29811       }
29812       const searchable = pool.filter((a2) => a2.searchable !== false && a2.suggestion !== true);
29813       const suggestions = pool.filter((a2) => a2.suggestion === true);
29814       const leadingNames = searchable.filter((a2) => leading(a2.searchName()) || a2.searchAliases().some(leading)).sort(sortPresets("searchName", "searchAliases"));
29815       const leadingSuggestions = suggestions.filter((a2) => leadingStrict(a2.searchName())).sort(sortPresets("searchName"));
29816       const leadingNamesStripped = searchable.filter((a2) => leading(a2.searchNameStripped()) || a2.searchAliasesStripped().some(leading)).sort(sortPresets("searchNameStripped", "searchAliasesStripped"));
29817       const leadingSuggestionsStripped = suggestions.filter((a2) => leadingStrict(a2.searchNameStripped())).sort(sortPresets("searchNameStripped"));
29818       const leadingTerms = searchable.filter((a2) => (a2.terms() || []).some(leading));
29819       const leadingSuggestionTerms = suggestions.filter((a2) => (a2.terms() || []).some(leading));
29820       const leadingTagValues = searchable.filter((a2) => Object.values(a2.tags || {}).filter((val) => val !== "*").some(leading));
29821       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);
29822       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);
29823       const similarTerms = searchable.filter((a2) => {
29824         return (a2.terms() || []).some((b2) => {
29825           return utilEditDistance(value, b2) + Math.min(value.length - b2.length, 0) < 3;
29826         });
29827       });
29828       let leadingTagKeyValues = [];
29829       if (value.includes("=")) {
29830         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]))));
29831       }
29832       let results = leadingNames.concat(
29833         leadingSuggestions,
29834         leadingNamesStripped,
29835         leadingSuggestionsStripped,
29836         leadingTerms,
29837         leadingSuggestionTerms,
29838         leadingTagValues,
29839         similarName,
29840         similarSuggestions,
29841         similarTerms,
29842         leadingTagKeyValues
29843       ).slice(0, MAXRESULTS - 1);
29844       if (geometry) {
29845         if (typeof geometry === "string") {
29846           results.push(_this.fallback(geometry));
29847         } else {
29848           geometry.forEach((geom) => results.push(_this.fallback(geom)));
29849         }
29850       }
29851       return presetCollection(utilArrayUniq(results));
29852     };
29853     return _this;
29854   }
29855
29856   // modules/presets/category.js
29857   function presetCategory(categoryID, category, allPresets) {
29858     let _this = Object.assign({}, category);
29859     let _searchName;
29860     let _searchNameStripped;
29861     _this.id = categoryID;
29862     _this.members = presetCollection(
29863       (category.members || []).map((presetID) => allPresets[presetID]).filter(Boolean)
29864     );
29865     _this.geometry = _this.members.collection.reduce((acc, preset) => {
29866       for (let i3 in preset.geometry) {
29867         const geometry = preset.geometry[i3];
29868         if (acc.indexOf(geometry) === -1) {
29869           acc.push(geometry);
29870         }
29871       }
29872       return acc;
29873     }, []);
29874     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29875     _this.matchAllGeometry = (geometries) => _this.members.collection.some((preset) => preset.matchAllGeometry(geometries));
29876     _this.matchScore = () => -1;
29877     _this.name = () => _t("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29878     _this.nameLabel = () => _t.append("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29879     _this.terms = () => [];
29880     _this.searchName = () => {
29881       if (!_searchName) {
29882         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
29883       }
29884       return _searchName;
29885     };
29886     _this.searchNameStripped = () => {
29887       if (!_searchNameStripped) {
29888         _searchNameStripped = _this.searchName();
29889         if (_searchNameStripped.normalize)
29890           _searchNameStripped = _searchNameStripped.normalize("NFD");
29891         _searchNameStripped = _searchNameStripped.replace(/[\u0300-\u036f]/g, "");
29892       }
29893       return _searchNameStripped;
29894     };
29895     _this.searchAliases = () => [];
29896     _this.searchAliasesStripped = () => [];
29897     return _this;
29898   }
29899
29900   // modules/presets/field.js
29901   function presetField(fieldID, field, allFields) {
29902     allFields = allFields || {};
29903     let _this = Object.assign({}, field);
29904     _this.id = fieldID;
29905     _this.safeid = utilSafeClassName(fieldID);
29906     _this.matchGeometry = (geom) => !_this.geometry || _this.geometry.indexOf(geom) !== -1;
29907     _this.matchAllGeometry = (geometries) => {
29908       return !_this.geometry || geometries.every((geom) => _this.geometry.indexOf(geom) !== -1);
29909     };
29910     _this.t = (scope, options2) => _t("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29911     _this.t.html = (scope, options2) => _t.html("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29912     _this.t.append = (scope, options2) => _t.append("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29913     _this.hasTextForStringId = (scope) => _mainLocalizer.hasTextForStringId("_tagging.presets.fields.".concat(fieldID, ".").concat(scope));
29914     _this.resolveReference = (which) => {
29915       const referenceRegex = /^\{(.*)\}$/;
29916       const match = (field[which] || "").match(referenceRegex);
29917       if (match) {
29918         const field2 = allFields[match[1]];
29919         if (field2) {
29920           return field2;
29921         }
29922         console.error("Unable to resolve referenced field: ".concat(match[1]));
29923       }
29924       return _this;
29925     };
29926     _this.title = () => _this.overrideLabel || _this.resolveReference("label").t("label", { "default": fieldID });
29927     _this.label = () => _this.overrideLabel ? (selection2) => selection2.text(_this.overrideLabel) : _this.resolveReference("label").t.append("label", { "default": fieldID });
29928     _this.placeholder = () => _this.resolveReference("placeholder").t("placeholder", { "default": "" });
29929     _this.originalTerms = (_this.terms || []).join();
29930     _this.terms = () => _this.resolveReference("label").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
29931     _this.increment = _this.type === "number" ? _this.increment || 1 : void 0;
29932     return _this;
29933   }
29934
29935   // modules/presets/preset.js
29936   var import_lodash = __toESM(require_lodash());
29937   function presetPreset(presetID, preset, addable, allFields, allPresets) {
29938     allFields = allFields || {};
29939     allPresets = allPresets || {};
29940     let _this = Object.assign({}, preset);
29941     let _addable = addable || false;
29942     let _searchName;
29943     let _searchNameStripped;
29944     let _searchAliases;
29945     let _searchAliasesStripped;
29946     const referenceRegex = /^\{(.*)\}$/;
29947     _this.id = presetID;
29948     _this.safeid = utilSafeClassName(presetID);
29949     _this.originalTerms = (_this.terms || []).join();
29950     _this.originalName = _this.name || "";
29951     _this.originalAliases = (_this.aliases || []).join("\n");
29952     _this.originalScore = _this.matchScore || 1;
29953     _this.originalReference = _this.reference || {};
29954     _this.originalFields = _this.fields || [];
29955     _this.originalMoreFields = _this.moreFields || [];
29956     _this.fields = (loc) => resolveFields("fields", loc);
29957     _this.moreFields = (loc) => resolveFields("moreFields", loc);
29958     _this.tags = _this.tags || {};
29959     _this.addTags = _this.addTags || _this.tags;
29960     _this.removeTags = _this.removeTags || _this.addTags;
29961     _this.geometry = _this.geometry || [];
29962     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29963     _this.matchAllGeometry = (geoms) => geoms.every(_this.matchGeometry);
29964     _this.matchScore = (entityTags) => {
29965       const tags = _this.tags;
29966       let seen = {};
29967       let score = 0;
29968       for (let k2 in tags) {
29969         seen[k2] = true;
29970         if (entityTags[k2] === tags[k2]) {
29971           score += _this.originalScore;
29972         } else if (tags[k2] === "*" && k2 in entityTags) {
29973           score += _this.originalScore / 2;
29974         } else {
29975           return -1;
29976         }
29977       }
29978       const addTags = _this.addTags;
29979       for (let k2 in addTags) {
29980         if (!seen[k2] && entityTags[k2] === addTags[k2]) {
29981           score += _this.originalScore;
29982         }
29983       }
29984       if (_this.searchable === false) {
29985         score *= 0.999;
29986       }
29987       return score;
29988     };
29989     _this.t = (scope, options2) => {
29990       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29991       return _t(textID, options2);
29992     };
29993     _this.t.append = (scope, options2) => {
29994       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29995       return _t.append(textID, options2);
29996     };
29997     function resolveReference(which) {
29998       const match = (_this[which] || "").match(referenceRegex);
29999       if (match) {
30000         const preset2 = allPresets[match[1]];
30001         if (preset2) {
30002           return preset2;
30003         }
30004         console.error("Unable to resolve referenced preset: ".concat(match[1]));
30005       }
30006       return _this;
30007     }
30008     _this.name = () => {
30009       return resolveReference("originalName").t("name", { "default": _this.originalName || presetID });
30010     };
30011     _this.nameLabel = () => {
30012       return resolveReference("originalName").t.append("name", { "default": _this.originalName || presetID });
30013     };
30014     _this.subtitle = () => {
30015       if (_this.suggestion) {
30016         let path = presetID.split("/");
30017         path.pop();
30018         return _t("_tagging.presets.presets." + path.join("/") + ".name");
30019       }
30020       return null;
30021     };
30022     _this.subtitleLabel = () => {
30023       if (_this.suggestion) {
30024         let path = presetID.split("/");
30025         path.pop();
30026         return _t.append("_tagging.presets.presets." + path.join("/") + ".name");
30027       }
30028       return null;
30029     };
30030     _this.aliases = () => {
30031       return resolveReference("originalName").t("aliases", { "default": _this.originalAliases }).trim().split(/\s*[\r\n]+\s*/);
30032     };
30033     _this.terms = () => {
30034       return resolveReference("originalName").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
30035     };
30036     _this.searchName = () => {
30037       if (!_searchName) {
30038         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
30039       }
30040       return _searchName;
30041     };
30042     _this.searchNameStripped = () => {
30043       if (!_searchNameStripped) {
30044         _searchNameStripped = stripDiacritics(_this.searchName());
30045       }
30046       return _searchNameStripped;
30047     };
30048     _this.searchAliases = () => {
30049       if (!_searchAliases) {
30050         _searchAliases = _this.aliases().map((alias) => alias.toLowerCase());
30051       }
30052       return _searchAliases;
30053     };
30054     _this.searchAliasesStripped = () => {
30055       if (!_searchAliasesStripped) {
30056         _searchAliasesStripped = _this.searchAliases();
30057         _searchAliasesStripped = _searchAliasesStripped.map(stripDiacritics);
30058       }
30059       return _searchAliasesStripped;
30060     };
30061     _this.isFallback = () => {
30062       const tagCount = Object.keys(_this.tags).length;
30063       return tagCount === 0 || tagCount === 1 && _this.tags.hasOwnProperty("area");
30064     };
30065     _this.addable = function(val) {
30066       if (!arguments.length)
30067         return _addable;
30068       _addable = val;
30069       return _this;
30070     };
30071     _this.reference = () => {
30072       const qid = _this.tags.wikidata || _this.tags["flag:wikidata"] || _this.tags["brand:wikidata"] || _this.tags["network:wikidata"] || _this.tags["operator:wikidata"];
30073       if (qid) {
30074         return { qid };
30075       }
30076       let key = _this.originalReference.key || Object.keys(utilObjectOmit(_this.tags, "name"))[0];
30077       let value = _this.originalReference.value || _this.tags[key];
30078       if (value === "*") {
30079         return { key };
30080       } else {
30081         return { key, value };
30082       }
30083     };
30084     _this.unsetTags = (tags, geometry, ignoringKeys, skipFieldDefaults, loc) => {
30085       let removeTags = ignoringKeys ? utilObjectOmit(_this.removeTags, ignoringKeys) : _this.removeTags;
30086       tags = utilObjectOmit(tags, Object.keys(removeTags));
30087       if (geometry && !skipFieldDefaults) {
30088         _this.fields(loc).forEach((field) => {
30089           if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key] && (!ignoringKeys || ignoringKeys.indexOf(field.key) === -1)) {
30090             delete tags[field.key];
30091           }
30092         });
30093       }
30094       delete tags.area;
30095       return tags;
30096     };
30097     _this.setTags = (tags, geometry, skipFieldDefaults, loc) => {
30098       const addTags = _this.addTags;
30099       tags = Object.assign({}, tags);
30100       for (let k2 in addTags) {
30101         if (addTags[k2] === "*") {
30102           if (_this.tags[k2] || !tags[k2]) {
30103             tags[k2] = "yes";
30104           }
30105         } else if (addTags[k2] === "") {
30106           delete tags[k2];
30107         } else {
30108           tags[k2] = addTags[k2];
30109         }
30110       }
30111       if (!addTags.hasOwnProperty("area")) {
30112         delete tags.area;
30113         if (geometry === "area") {
30114           let needsAreaTag = true;
30115           for (let k2 in addTags) {
30116             if (_this.geometry.indexOf("line") === -1 && k2 in osmAreaKeys || k2 in osmAreaKeysExceptions && addTags[k2] in osmAreaKeysExceptions[k2]) {
30117               needsAreaTag = false;
30118               break;
30119             }
30120           }
30121           if (needsAreaTag) {
30122             tags.area = "yes";
30123           }
30124         }
30125       }
30126       if (geometry && !skipFieldDefaults) {
30127         _this.fields(loc).forEach((field) => {
30128           if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field.default) {
30129             tags[field.key] = field.default;
30130           }
30131         });
30132       }
30133       return tags;
30134     };
30135     function resolveFields(which, loc) {
30136       const fieldIDs = which === "fields" ? _this.originalFields : _this.originalMoreFields;
30137       let resolved = [];
30138       fieldIDs.forEach((fieldID) => {
30139         const match = fieldID.match(referenceRegex);
30140         if (match !== null) {
30141           resolved = resolved.concat(inheritFields(allPresets[match[1]], which));
30142         } else if (allFields[fieldID]) {
30143           resolved.push(allFields[fieldID]);
30144         } else {
30145           console.log('Cannot resolve "'.concat(fieldID, '" found in ').concat(_this.id, ".").concat(which));
30146         }
30147       });
30148       if (!resolved.length) {
30149         const endIndex = _this.id.lastIndexOf("/");
30150         const parentID = endIndex && _this.id.substring(0, endIndex);
30151         if (parentID) {
30152           let parent = allPresets[parentID];
30153           if (loc) {
30154             const validHere = _sharedLocationManager.locationSetsAt(loc);
30155             if ((parent == null ? void 0 : parent.locationSetID) && !validHere[parent.locationSetID]) {
30156               const candidateIDs = Object.keys(allPresets).filter((k2) => k2.startsWith(parentID));
30157               parent = allPresets[candidateIDs.find((candidateID) => {
30158                 const candidate = allPresets[candidateID];
30159                 return validHere[candidate.locationSetID] && (0, import_lodash.isEqual)(candidate.tags, parent.tags);
30160               })];
30161             }
30162           }
30163           resolved = inheritFields(parent, which);
30164         }
30165       }
30166       return utilArrayUniq(resolved);
30167       function inheritFields(parent, which2) {
30168         if (!parent)
30169           return [];
30170         if (which2 === "fields") {
30171           return parent.fields().filter(shouldInherit);
30172         } else if (which2 === "moreFields") {
30173           return parent.moreFields();
30174         } else {
30175           return [];
30176         }
30177       }
30178       function shouldInherit(f2) {
30179         if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox
30180         f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check")
30181           return false;
30182         return true;
30183       }
30184     }
30185     function stripDiacritics(s2) {
30186       if (s2.normalize)
30187         s2 = s2.normalize("NFD");
30188       s2 = s2.replace(/[\u0300-\u036f]/g, "");
30189       return s2;
30190     }
30191     return _this;
30192   }
30193
30194   // modules/presets/index.js
30195   var _mainPresetIndex = presetIndex();
30196   function presetIndex() {
30197     const dispatch14 = dispatch_default("favoritePreset", "recentsChange");
30198     const MAXRECENTS = 30;
30199     const POINT = presetPreset("point", { name: "Point", tags: {}, geometry: ["point", "vertex"], matchScore: 0.1 });
30200     const LINE = presetPreset("line", { name: "Line", tags: {}, geometry: ["line"], matchScore: 0.1 });
30201     const AREA = presetPreset("area", { name: "Area", tags: { area: "yes" }, geometry: ["area"], matchScore: 0.1 });
30202     const RELATION = presetPreset("relation", { name: "Relation", tags: {}, geometry: ["relation"], matchScore: 0.1 });
30203     let _this = presetCollection([POINT, LINE, AREA, RELATION]);
30204     let _presets = { point: POINT, line: LINE, area: AREA, relation: RELATION };
30205     let _defaults2 = {
30206       point: presetCollection([POINT]),
30207       vertex: presetCollection([POINT]),
30208       line: presetCollection([LINE]),
30209       area: presetCollection([AREA]),
30210       relation: presetCollection([RELATION])
30211     };
30212     let _fields = {};
30213     let _categories = {};
30214     let _universal = [];
30215     let _addablePresetIDs = null;
30216     let _recents;
30217     let _favorites;
30218     let _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30219     let _loadPromise;
30220     _this.ensureLoaded = () => {
30221       if (_loadPromise)
30222         return _loadPromise;
30223       return _loadPromise = Promise.all([
30224         _mainFileFetcher.get("preset_categories"),
30225         _mainFileFetcher.get("preset_defaults"),
30226         _mainFileFetcher.get("preset_presets"),
30227         _mainFileFetcher.get("preset_fields")
30228       ]).then((vals) => {
30229         _this.merge({
30230           categories: vals[0],
30231           defaults: vals[1],
30232           presets: vals[2],
30233           fields: vals[3]
30234         });
30235         osmSetAreaKeys(_this.areaKeys());
30236         osmSetLineTags(_this.lineTags());
30237         osmSetPointTags(_this.pointTags());
30238         osmSetVertexTags(_this.vertexTags());
30239       });
30240     };
30241     _this.merge = (d2) => {
30242       let newLocationSets = [];
30243       if (d2.fields) {
30244         Object.keys(d2.fields).forEach((fieldID) => {
30245           let f2 = d2.fields[fieldID];
30246           if (f2) {
30247             f2 = presetField(fieldID, f2, _fields);
30248             if (f2.locationSet)
30249               newLocationSets.push(f2);
30250             _fields[fieldID] = f2;
30251           } else {
30252             delete _fields[fieldID];
30253           }
30254         });
30255       }
30256       if (d2.presets) {
30257         Object.keys(d2.presets).forEach((presetID) => {
30258           let p2 = d2.presets[presetID];
30259           if (p2) {
30260             const isAddable = !_addablePresetIDs || _addablePresetIDs.has(presetID);
30261             p2 = presetPreset(presetID, p2, isAddable, _fields, _presets);
30262             if (p2.locationSet)
30263               newLocationSets.push(p2);
30264             _presets[presetID] = p2;
30265           } else {
30266             const existing = _presets[presetID];
30267             if (existing && !existing.isFallback()) {
30268               delete _presets[presetID];
30269             }
30270           }
30271         });
30272       }
30273       if (d2.categories) {
30274         Object.keys(d2.categories).forEach((categoryID) => {
30275           let c2 = d2.categories[categoryID];
30276           if (c2) {
30277             c2 = presetCategory(categoryID, c2, _presets);
30278             if (c2.locationSet)
30279               newLocationSets.push(c2);
30280             _categories[categoryID] = c2;
30281           } else {
30282             delete _categories[categoryID];
30283           }
30284         });
30285       }
30286       _this.collection = Object.values(_presets).concat(Object.values(_categories));
30287       if (d2.defaults) {
30288         Object.keys(d2.defaults).forEach((geometry) => {
30289           const def2 = d2.defaults[geometry];
30290           if (Array.isArray(def2)) {
30291             _defaults2[geometry] = presetCollection(
30292               def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean)
30293             );
30294           } else {
30295             delete _defaults2[geometry];
30296           }
30297         });
30298       }
30299       _universal = Object.values(_fields).filter((field) => field.universal);
30300       _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30301       _this.collection.forEach((preset) => {
30302         (preset.geometry || []).forEach((geometry) => {
30303           let g3 = _geometryIndex[geometry];
30304           for (let key in preset.tags) {
30305             g3[key] = g3[key] || {};
30306             let value = preset.tags[key];
30307             (g3[key][value] = g3[key][value] || []).push(preset);
30308           }
30309         });
30310       });
30311       if (d2.featureCollection && Array.isArray(d2.featureCollection.features)) {
30312         _sharedLocationManager.mergeCustomGeoJSON(d2.featureCollection);
30313       }
30314       if (newLocationSets.length) {
30315         _sharedLocationManager.mergeLocationSets(newLocationSets);
30316       }
30317       return _this;
30318     };
30319     _this.match = (entity, resolver) => {
30320       return resolver.transient(entity, "presetMatch", () => {
30321         let geometry = entity.geometry(resolver);
30322         if (geometry === "vertex" && entity.isOnAddressLine(resolver)) {
30323           geometry = "point";
30324         }
30325         const entityExtent = entity.extent(resolver);
30326         return _this.matchTags(entity.tags, geometry, entityExtent.center());
30327       });
30328     };
30329     _this.matchTags = (tags, geometry, loc) => {
30330       const keyIndex = _geometryIndex[geometry];
30331       let bestScore = -1;
30332       let bestMatch;
30333       let matchCandidates = [];
30334       for (let k2 in tags) {
30335         let indexMatches = [];
30336         let valueIndex = keyIndex[k2];
30337         if (!valueIndex)
30338           continue;
30339         let keyValueMatches = valueIndex[tags[k2]];
30340         if (keyValueMatches)
30341           indexMatches.push(...keyValueMatches);
30342         let keyStarMatches = valueIndex["*"];
30343         if (keyStarMatches)
30344           indexMatches.push(...keyStarMatches);
30345         if (indexMatches.length === 0)
30346           continue;
30347         for (let i3 = 0; i3 < indexMatches.length; i3++) {
30348           const candidate = indexMatches[i3];
30349           const score = candidate.matchScore(tags);
30350           if (score === -1) {
30351             continue;
30352           }
30353           matchCandidates.push({ score, candidate });
30354           if (score > bestScore) {
30355             bestScore = score;
30356             bestMatch = candidate;
30357           }
30358         }
30359       }
30360       if (bestMatch && bestMatch.locationSetID && bestMatch.locationSetID !== "+[Q2]" && Array.isArray(loc)) {
30361         const validHere = _sharedLocationManager.locationSetsAt(loc);
30362         if (!validHere[bestMatch.locationSetID]) {
30363           matchCandidates.sort((a2, b2) => a2.score < b2.score ? 1 : -1);
30364           for (let i3 = 0; i3 < matchCandidates.length; i3++) {
30365             const candidateScore = matchCandidates[i3];
30366             if (!candidateScore.candidate.locationSetID || validHere[candidateScore.candidate.locationSetID]) {
30367               bestMatch = candidateScore.candidate;
30368               bestScore = candidateScore.score;
30369               break;
30370             }
30371           }
30372         }
30373       }
30374       if (!bestMatch || bestMatch.isFallback()) {
30375         for (let k2 in tags) {
30376           if (/^addr:/.test(k2) && keyIndex["addr:*"] && keyIndex["addr:*"]["*"]) {
30377             bestMatch = keyIndex["addr:*"]["*"][0];
30378             break;
30379           }
30380         }
30381       }
30382       return bestMatch || _this.fallback(geometry);
30383     };
30384     _this.allowsVertex = (entity, resolver) => {
30385       if (entity.type !== "node")
30386         return false;
30387       if (Object.keys(entity.tags).length === 0)
30388         return true;
30389       return resolver.transient(entity, "vertexMatch", () => {
30390         if (entity.isOnAddressLine(resolver))
30391           return true;
30392         const geometries = osmNodeGeometriesForTags(entity.tags);
30393         if (geometries.vertex)
30394           return true;
30395         if (geometries.point)
30396           return false;
30397         return true;
30398       });
30399     };
30400     _this.areaKeys = () => {
30401       const ignore = {
30402         barrier: true,
30403         highway: true,
30404         footway: true,
30405         railway: true,
30406         junction: true,
30407         type: true
30408       };
30409       let areaKeys = {};
30410       const presets = _this.collection.filter((p2) => !p2.suggestion && !p2.replacement);
30411       presets.forEach((p2) => {
30412         const keys2 = p2.tags && Object.keys(p2.tags);
30413         const key = keys2 && keys2.length && keys2[0];
30414         if (!key)
30415           return;
30416         if (ignore[key])
30417           return;
30418         if (p2.geometry.indexOf("area") !== -1) {
30419           areaKeys[key] = areaKeys[key] || {};
30420         }
30421       });
30422       presets.forEach((p2) => {
30423         let key;
30424         for (key in p2.addTags) {
30425           const value = p2.addTags[key];
30426           if (key in areaKeys && // probably an area...
30427           p2.geometry.indexOf("line") !== -1 && // but sometimes a line
30428           value !== "*") {
30429             areaKeys[key][value] = true;
30430           }
30431         }
30432       });
30433       return areaKeys;
30434     };
30435     _this.lineTags = () => {
30436       return _this.collection.filter((lineTags, d2) => {
30437         if (d2.suggestion || d2.replacement || d2.searchable === false)
30438           return lineTags;
30439         const keys2 = d2.tags && Object.keys(d2.tags);
30440         const key = keys2 && keys2.length && keys2[0];
30441         if (!key)
30442           return lineTags;
30443         if (d2.geometry.indexOf("line") !== -1) {
30444           lineTags[key] = lineTags[key] || [];
30445           lineTags[key].push(d2.tags);
30446         }
30447         return lineTags;
30448       }, {});
30449     };
30450     _this.pointTags = () => {
30451       return _this.collection.reduce((pointTags, d2) => {
30452         if (d2.suggestion || d2.replacement || d2.searchable === false)
30453           return pointTags;
30454         const keys2 = d2.tags && Object.keys(d2.tags);
30455         const key = keys2 && keys2.length && keys2[0];
30456         if (!key)
30457           return pointTags;
30458         if (d2.geometry.indexOf("point") !== -1) {
30459           pointTags[key] = pointTags[key] || {};
30460           pointTags[key][d2.tags[key]] = true;
30461         }
30462         return pointTags;
30463       }, {});
30464     };
30465     _this.vertexTags = () => {
30466       return _this.collection.reduce((vertexTags, d2) => {
30467         if (d2.suggestion || d2.replacement || d2.searchable === false)
30468           return vertexTags;
30469         const keys2 = d2.tags && Object.keys(d2.tags);
30470         const key = keys2 && keys2.length && keys2[0];
30471         if (!key)
30472           return vertexTags;
30473         if (d2.geometry.indexOf("vertex") !== -1) {
30474           vertexTags[key] = vertexTags[key] || {};
30475           vertexTags[key][d2.tags[key]] = true;
30476         }
30477         return vertexTags;
30478       }, {});
30479     };
30480     _this.field = (id2) => _fields[id2];
30481     _this.universal = () => _universal;
30482     _this.defaults = (geometry, n3, startWithRecents, loc, extraPresets) => {
30483       let recents = [];
30484       if (startWithRecents) {
30485         recents = _this.recent().matchGeometry(geometry).collection.slice(0, 4);
30486       }
30487       let defaults;
30488       if (_addablePresetIDs) {
30489         defaults = Array.from(_addablePresetIDs).map(function(id2) {
30490           var preset = _this.item(id2);
30491           if (preset && preset.matchGeometry(geometry))
30492             return preset;
30493           return null;
30494         }).filter(Boolean);
30495       } else {
30496         defaults = _defaults2[geometry].collection.concat(_this.fallback(geometry));
30497       }
30498       let result = presetCollection(
30499         utilArrayUniq(recents.concat(defaults).concat(extraPresets || [])).slice(0, n3 - 1)
30500       );
30501       if (Array.isArray(loc)) {
30502         const validHere = _sharedLocationManager.locationSetsAt(loc);
30503         result.collection = result.collection.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
30504       }
30505       return result;
30506     };
30507     _this.addablePresetIDs = function(val) {
30508       if (!arguments.length)
30509         return _addablePresetIDs;
30510       if (Array.isArray(val))
30511         val = new Set(val);
30512       _addablePresetIDs = val;
30513       if (_addablePresetIDs) {
30514         _this.collection.forEach((p2) => {
30515           if (p2.addable)
30516             p2.addable(_addablePresetIDs.has(p2.id));
30517         });
30518       } else {
30519         _this.collection.forEach((p2) => {
30520           if (p2.addable)
30521             p2.addable(true);
30522         });
30523       }
30524       return _this;
30525     };
30526     _this.recent = () => {
30527       return presetCollection(
30528         utilArrayUniq(_this.getRecents().map((d2) => d2.preset).filter((d2) => d2.searchable !== false))
30529       );
30530     };
30531     function RibbonItem(preset, source) {
30532       let item = {};
30533       item.preset = preset;
30534       item.source = source;
30535       item.isFavorite = () => item.source === "favorite";
30536       item.isRecent = () => item.source === "recent";
30537       item.matches = (preset2) => item.preset.id === preset2.id;
30538       item.minified = () => ({ pID: item.preset.id });
30539       return item;
30540     }
30541     function ribbonItemForMinified(d2, source) {
30542       if (d2 && d2.pID) {
30543         const preset = _this.item(d2.pID);
30544         if (!preset)
30545           return null;
30546         return RibbonItem(preset, source);
30547       }
30548       return null;
30549     }
30550     _this.getGenericRibbonItems = () => {
30551       return ["point", "line", "area"].map((id2) => RibbonItem(_this.item(id2), "generic"));
30552     };
30553     _this.getAddable = () => {
30554       if (!_addablePresetIDs)
30555         return [];
30556       return _addablePresetIDs.map((id2) => {
30557         const preset = _this.item(id2);
30558         if (preset)
30559           return RibbonItem(preset, "addable");
30560         return null;
30561       }).filter(Boolean);
30562     };
30563     function setRecents(items) {
30564       _recents = items;
30565       const minifiedItems = items.map((d2) => d2.minified());
30566       corePreferences("preset_recents", JSON.stringify(minifiedItems));
30567       dispatch14.call("recentsChange");
30568     }
30569     _this.getRecents = () => {
30570       if (!_recents) {
30571         _recents = (JSON.parse(corePreferences("preset_recents")) || []).reduce((acc, d2) => {
30572           let item = ribbonItemForMinified(d2, "recent");
30573           if (item && item.preset.addable())
30574             acc.push(item);
30575           return acc;
30576         }, []);
30577       }
30578       return _recents;
30579     };
30580     _this.addRecent = (preset, besidePreset, after) => {
30581       const recents = _this.getRecents();
30582       const beforeItem = _this.recentMatching(besidePreset);
30583       let toIndex = recents.indexOf(beforeItem);
30584       if (after)
30585         toIndex += 1;
30586       const newItem = RibbonItem(preset, "recent");
30587       recents.splice(toIndex, 0, newItem);
30588       setRecents(recents);
30589     };
30590     _this.removeRecent = (preset) => {
30591       const item = _this.recentMatching(preset);
30592       if (item) {
30593         let items = _this.getRecents();
30594         items.splice(items.indexOf(item), 1);
30595         setRecents(items);
30596       }
30597     };
30598     _this.recentMatching = (preset) => {
30599       const items = _this.getRecents();
30600       for (let i3 in items) {
30601         if (items[i3].matches(preset)) {
30602           return items[i3];
30603         }
30604       }
30605       return null;
30606     };
30607     _this.moveItem = (items, fromIndex, toIndex) => {
30608       if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length)
30609         return null;
30610       items.splice(toIndex, 0, items.splice(fromIndex, 1)[0]);
30611       return items;
30612     };
30613     _this.moveRecent = (item, beforeItem) => {
30614       const recents = _this.getRecents();
30615       const fromIndex = recents.indexOf(item);
30616       const toIndex = recents.indexOf(beforeItem);
30617       const items = _this.moveItem(recents, fromIndex, toIndex);
30618       if (items)
30619         setRecents(items);
30620     };
30621     _this.setMostRecent = (preset) => {
30622       if (preset.searchable === false)
30623         return;
30624       let items = _this.getRecents();
30625       let item = _this.recentMatching(preset);
30626       if (item) {
30627         items.splice(items.indexOf(item), 1);
30628       } else {
30629         item = RibbonItem(preset, "recent");
30630       }
30631       while (items.length >= MAXRECENTS) {
30632         items.pop();
30633       }
30634       items.unshift(item);
30635       setRecents(items);
30636     };
30637     function setFavorites(items) {
30638       _favorites = items;
30639       const minifiedItems = items.map((d2) => d2.minified());
30640       corePreferences("preset_favorites", JSON.stringify(minifiedItems));
30641       dispatch14.call("favoritePreset");
30642     }
30643     _this.addFavorite = (preset, besidePreset, after) => {
30644       const favorites = _this.getFavorites();
30645       const beforeItem = _this.favoriteMatching(besidePreset);
30646       let toIndex = favorites.indexOf(beforeItem);
30647       if (after)
30648         toIndex += 1;
30649       const newItem = RibbonItem(preset, "favorite");
30650       favorites.splice(toIndex, 0, newItem);
30651       setFavorites(favorites);
30652     };
30653     _this.toggleFavorite = (preset) => {
30654       const favs = _this.getFavorites();
30655       const favorite = _this.favoriteMatching(preset);
30656       if (favorite) {
30657         favs.splice(favs.indexOf(favorite), 1);
30658       } else {
30659         if (favs.length === 10) {
30660           favs.pop();
30661         }
30662         favs.push(RibbonItem(preset, "favorite"));
30663       }
30664       setFavorites(favs);
30665     };
30666     _this.removeFavorite = (preset) => {
30667       const item = _this.favoriteMatching(preset);
30668       if (item) {
30669         const items = _this.getFavorites();
30670         items.splice(items.indexOf(item), 1);
30671         setFavorites(items);
30672       }
30673     };
30674     _this.getFavorites = () => {
30675       if (!_favorites) {
30676         let rawFavorites = JSON.parse(corePreferences("preset_favorites"));
30677         if (!rawFavorites) {
30678           rawFavorites = [];
30679           corePreferences("preset_favorites", JSON.stringify(rawFavorites));
30680         }
30681         _favorites = rawFavorites.reduce((output, d2) => {
30682           const item = ribbonItemForMinified(d2, "favorite");
30683           if (item && item.preset.addable())
30684             output.push(item);
30685           return output;
30686         }, []);
30687       }
30688       return _favorites;
30689     };
30690     _this.favoriteMatching = (preset) => {
30691       const favs = _this.getFavorites();
30692       for (let index in favs) {
30693         if (favs[index].matches(preset)) {
30694           return favs[index];
30695         }
30696       }
30697       return null;
30698     };
30699     return utilRebind(_this, dispatch14, "on");
30700   }
30701
30702   // modules/util/util.js
30703   function utilTagText(entity) {
30704     var obj = entity && entity.tags || {};
30705     return Object.keys(obj).map(function(k2) {
30706       return k2 + "=" + obj[k2];
30707     }).join(", ");
30708   }
30709   function utilTotalExtent(array2, graph) {
30710     var extent = geoExtent();
30711     var val, entity;
30712     for (var i3 = 0; i3 < array2.length; i3++) {
30713       val = array2[i3];
30714       entity = typeof val === "string" ? graph.hasEntity(val) : val;
30715       if (entity) {
30716         extent._extend(entity.extent(graph));
30717       }
30718     }
30719     return extent;
30720   }
30721   function utilTagDiff(oldTags, newTags) {
30722     var tagDiff = [];
30723     var keys2 = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
30724     keys2.forEach(function(k2) {
30725       var oldVal = oldTags[k2];
30726       var newVal = newTags[k2];
30727       if ((oldVal || oldVal === "") && (newVal === void 0 || newVal !== oldVal)) {
30728         tagDiff.push({
30729           type: "-",
30730           key: k2,
30731           oldVal,
30732           newVal,
30733           display: "- " + k2 + "=" + oldVal
30734         });
30735       }
30736       if ((newVal || newVal === "") && (oldVal === void 0 || newVal !== oldVal)) {
30737         tagDiff.push({
30738           type: "+",
30739           key: k2,
30740           oldVal,
30741           newVal,
30742           display: "+ " + k2 + "=" + newVal
30743         });
30744       }
30745     });
30746     return tagDiff;
30747   }
30748   function utilEntitySelector(ids) {
30749     return ids.length ? "." + ids.join(",.") : "nothing";
30750   }
30751   function utilEntityOrMemberSelector(ids, graph) {
30752     var seen = new Set(ids);
30753     ids.forEach(collectShallowDescendants);
30754     return utilEntitySelector(Array.from(seen));
30755     function collectShallowDescendants(id2) {
30756       var entity = graph.hasEntity(id2);
30757       if (!entity || entity.type !== "relation")
30758         return;
30759       entity.members.map(function(member) {
30760         return member.id;
30761       }).forEach(function(id3) {
30762         seen.add(id3);
30763       });
30764     }
30765   }
30766   function utilEntityOrDeepMemberSelector(ids, graph) {
30767     return utilEntitySelector(utilEntityAndDeepMemberIDs(ids, graph));
30768   }
30769   function utilEntityAndDeepMemberIDs(ids, graph) {
30770     var seen = /* @__PURE__ */ new Set();
30771     ids.forEach(collectDeepDescendants);
30772     return Array.from(seen);
30773     function collectDeepDescendants(id2) {
30774       if (seen.has(id2))
30775         return;
30776       seen.add(id2);
30777       var entity = graph.hasEntity(id2);
30778       if (!entity || entity.type !== "relation")
30779         return;
30780       entity.members.map(function(member) {
30781         return member.id;
30782       }).forEach(collectDeepDescendants);
30783     }
30784   }
30785   function utilDeepMemberSelector(ids, graph, skipMultipolgonMembers) {
30786     var idsSet = new Set(ids);
30787     var seen = /* @__PURE__ */ new Set();
30788     var returners = /* @__PURE__ */ new Set();
30789     ids.forEach(collectDeepDescendants);
30790     return utilEntitySelector(Array.from(returners));
30791     function collectDeepDescendants(id2) {
30792       if (seen.has(id2))
30793         return;
30794       seen.add(id2);
30795       if (!idsSet.has(id2)) {
30796         returners.add(id2);
30797       }
30798       var entity = graph.hasEntity(id2);
30799       if (!entity || entity.type !== "relation")
30800         return;
30801       if (skipMultipolgonMembers && entity.isMultipolygon())
30802         return;
30803       entity.members.map(function(member) {
30804         return member.id;
30805       }).forEach(collectDeepDescendants);
30806     }
30807   }
30808   function utilHighlightEntities(ids, highlighted, context) {
30809     context.surface().selectAll(utilEntityOrDeepMemberSelector(ids, context.graph())).classed("highlighted", highlighted);
30810   }
30811   function utilGetAllNodes(ids, graph) {
30812     var seen = /* @__PURE__ */ new Set();
30813     var nodes = /* @__PURE__ */ new Set();
30814     ids.forEach(collectNodes);
30815     return Array.from(nodes);
30816     function collectNodes(id2) {
30817       if (seen.has(id2))
30818         return;
30819       seen.add(id2);
30820       var entity = graph.hasEntity(id2);
30821       if (!entity)
30822         return;
30823       if (entity.type === "node") {
30824         nodes.add(entity);
30825       } else if (entity.type === "way") {
30826         entity.nodes.forEach(collectNodes);
30827       } else {
30828         entity.members.map(function(member) {
30829           return member.id;
30830         }).forEach(collectNodes);
30831       }
30832     }
30833   }
30834   function utilDisplayName(entity) {
30835     var localizedNameKey = "name:" + _mainLocalizer.languageCode().toLowerCase();
30836     var name = entity.tags[localizedNameKey] || entity.tags.name || "";
30837     if (name)
30838       return name;
30839     var tags = {
30840       direction: entity.tags.direction,
30841       from: entity.tags.from,
30842       network: entity.tags.cycle_network || entity.tags.network,
30843       ref: entity.tags.ref,
30844       to: entity.tags.to,
30845       via: entity.tags.via
30846     };
30847     var keyComponents = [];
30848     if (tags.network) {
30849       keyComponents.push("network");
30850     }
30851     if (tags.ref) {
30852       keyComponents.push("ref");
30853     }
30854     if (entity.tags.route) {
30855       if (tags.direction) {
30856         keyComponents.push("direction");
30857       } else if (tags.from && tags.to) {
30858         keyComponents.push("from");
30859         keyComponents.push("to");
30860         if (tags.via) {
30861           keyComponents.push("via");
30862         }
30863       }
30864     }
30865     if (keyComponents.length) {
30866       name = _t("inspector.display_name." + keyComponents.join("_"), tags);
30867     }
30868     return name;
30869   }
30870   function utilDisplayNameForPath(entity) {
30871     var name = utilDisplayName(entity);
30872     var isFirefox = utilDetect().browser.toLowerCase().indexOf("firefox") > -1;
30873     var isNewChromium = Number(utilDetect().version.split(".")[0]) >= 96;
30874     if (!isFirefox && !isNewChromium && name && rtlRegex.test(name)) {
30875       name = fixRTLTextForSvg(name);
30876     }
30877     return name;
30878   }
30879   function utilDisplayType(id2) {
30880     return {
30881       n: _t("inspector.node"),
30882       w: _t("inspector.way"),
30883       r: _t("inspector.relation")
30884     }[id2.charAt(0)];
30885   }
30886   function utilDisplayLabel(entity, graphOrGeometry, verbose) {
30887     var result;
30888     var displayName = utilDisplayName(entity);
30889     var preset = typeof graphOrGeometry === "string" ? _mainPresetIndex.matchTags(entity.tags, graphOrGeometry) : _mainPresetIndex.match(entity, graphOrGeometry);
30890     var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
30891     if (verbose) {
30892       result = [presetName, displayName].filter(Boolean).join(" ");
30893     } else {
30894       result = displayName || presetName;
30895     }
30896     return result || utilDisplayType(entity.id);
30897   }
30898   function utilEntityRoot(entityType) {
30899     return {
30900       node: "n",
30901       way: "w",
30902       relation: "r"
30903     }[entityType];
30904   }
30905   function utilCombinedTags(entityIDs, graph) {
30906     var tags = {};
30907     var tagCounts = {};
30908     var allKeys = /* @__PURE__ */ new Set();
30909     var entities = entityIDs.map(function(entityID) {
30910       return graph.hasEntity(entityID);
30911     }).filter(Boolean);
30912     entities.forEach(function(entity) {
30913       var keys2 = Object.keys(entity.tags).filter(Boolean);
30914       keys2.forEach(function(key2) {
30915         allKeys.add(key2);
30916       });
30917     });
30918     entities.forEach(function(entity) {
30919       allKeys.forEach(function(key2) {
30920         var value = entity.tags[key2];
30921         if (!tags.hasOwnProperty(key2)) {
30922           tags[key2] = value;
30923         } else {
30924           if (!Array.isArray(tags[key2])) {
30925             if (tags[key2] !== value) {
30926               tags[key2] = [tags[key2], value];
30927             }
30928           } else {
30929             if (tags[key2].indexOf(value) === -1) {
30930               tags[key2].push(value);
30931             }
30932           }
30933         }
30934         var tagHash = key2 + "=" + value;
30935         if (!tagCounts[tagHash])
30936           tagCounts[tagHash] = 0;
30937         tagCounts[tagHash] += 1;
30938       });
30939     });
30940     for (var key in tags) {
30941       if (!Array.isArray(tags[key]))
30942         continue;
30943       tags[key] = tags[key].sort(function(val12, val2) {
30944         var key2 = key2;
30945         var count2 = tagCounts[key2 + "=" + val2];
30946         var count1 = tagCounts[key2 + "=" + val12];
30947         if (count2 !== count1) {
30948           return count2 - count1;
30949         }
30950         if (val2 && val12) {
30951           return val12.localeCompare(val2);
30952         }
30953         return val12 ? 1 : -1;
30954       });
30955     }
30956     return tags;
30957   }
30958   function utilStringQs(str) {
30959     var i3 = 0;
30960     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
30961       i3++;
30962     str = str.slice(i3);
30963     return str.split("&").reduce(function(obj, pair3) {
30964       var parts = pair3.split("=");
30965       if (parts.length === 2) {
30966         obj[parts[0]] = null === parts[1] ? "" : decodeURIComponent(parts[1]);
30967       }
30968       return obj;
30969     }, {});
30970   }
30971   function utilQsString(obj, noencode) {
30972     function softEncode(s2) {
30973       return encodeURIComponent(s2).replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent);
30974     }
30975     return Object.keys(obj).sort().map(function(key) {
30976       return encodeURIComponent(key) + "=" + (noencode ? softEncode(obj[key]) : encodeURIComponent(obj[key]));
30977     }).join("&");
30978   }
30979   function utilPrefixDOMProperty(property) {
30980     var prefixes2 = ["webkit", "ms", "moz", "o"];
30981     var i3 = -1;
30982     var n3 = prefixes2.length;
30983     var s2 = document.body;
30984     if (property in s2)
30985       return property;
30986     property = property.slice(0, 1).toUpperCase() + property.slice(1);
30987     while (++i3 < n3) {
30988       if (prefixes2[i3] + property in s2) {
30989         return prefixes2[i3] + property;
30990       }
30991     }
30992     return false;
30993   }
30994   function utilPrefixCSSProperty(property) {
30995     var prefixes2 = ["webkit", "ms", "Moz", "O"];
30996     var i3 = -1;
30997     var n3 = prefixes2.length;
30998     var s2 = document.body.style;
30999     if (property.toLowerCase() in s2) {
31000       return property.toLowerCase();
31001     }
31002     while (++i3 < n3) {
31003       if (prefixes2[i3] + property in s2) {
31004         return "-" + prefixes2[i3].toLowerCase() + property.replace(/([A-Z])/g, "-$1").toLowerCase();
31005       }
31006     }
31007     return false;
31008   }
31009   var transformProperty;
31010   function utilSetTransform(el, x2, y2, scale) {
31011     var prop = transformProperty = transformProperty || utilPrefixCSSProperty("Transform");
31012     var translate = utilDetect().opera ? "translate(" + x2 + "px," + y2 + "px)" : "translate3d(" + x2 + "px," + y2 + "px,0)";
31013     return el.style(prop, translate + (scale ? " scale(" + scale + ")" : ""));
31014   }
31015   function utilEditDistance(a2, b2) {
31016     a2 = (0, import_diacritics.remove)(a2.toLowerCase());
31017     b2 = (0, import_diacritics.remove)(b2.toLowerCase());
31018     if (a2.length === 0)
31019       return b2.length;
31020     if (b2.length === 0)
31021       return a2.length;
31022     var matrix = [];
31023     var i3, j2;
31024     for (i3 = 0; i3 <= b2.length; i3++) {
31025       matrix[i3] = [i3];
31026     }
31027     for (j2 = 0; j2 <= a2.length; j2++) {
31028       matrix[0][j2] = j2;
31029     }
31030     for (i3 = 1; i3 <= b2.length; i3++) {
31031       for (j2 = 1; j2 <= a2.length; j2++) {
31032         if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) {
31033           matrix[i3][j2] = matrix[i3 - 1][j2 - 1];
31034         } else {
31035           matrix[i3][j2] = Math.min(
31036             matrix[i3 - 1][j2 - 1] + 1,
31037             // substitution
31038             Math.min(
31039               matrix[i3][j2 - 1] + 1,
31040               // insertion
31041               matrix[i3 - 1][j2] + 1
31042             )
31043           );
31044         }
31045       }
31046     }
31047     return matrix[b2.length][a2.length];
31048   }
31049   function utilFastMouse(container) {
31050     var rect = container.getBoundingClientRect();
31051     var rectLeft = rect.left;
31052     var rectTop = rect.top;
31053     var clientLeft = +container.clientLeft;
31054     var clientTop = +container.clientTop;
31055     return function(e3) {
31056       return [
31057         e3.clientX - rectLeft - clientLeft,
31058         e3.clientY - rectTop - clientTop
31059       ];
31060     };
31061   }
31062   function utilAsyncMap(inputs, func, callback) {
31063     var remaining = inputs.length;
31064     var results = [];
31065     var errors = [];
31066     inputs.forEach(function(d2, i3) {
31067       func(d2, function done(err, data) {
31068         errors[i3] = err;
31069         results[i3] = data;
31070         remaining--;
31071         if (!remaining)
31072           callback(errors, results);
31073       });
31074     });
31075   }
31076   function utilWrap(index, length2) {
31077     if (index < 0) {
31078       index += Math.ceil(-index / length2) * length2;
31079     }
31080     return index % length2;
31081   }
31082   function utilFunctor(value) {
31083     if (typeof value === "function")
31084       return value;
31085     return function() {
31086       return value;
31087     };
31088   }
31089   function utilNoAuto(selection2) {
31090     var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea";
31091     return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("spellcheck", isText ? "true" : "false");
31092   }
31093   function utilHashcode(str) {
31094     var hash = 0;
31095     if (str.length === 0) {
31096       return hash;
31097     }
31098     for (var i3 = 0; i3 < str.length; i3++) {
31099       var char = str.charCodeAt(i3);
31100       hash = (hash << 5) - hash + char;
31101       hash = hash & hash;
31102     }
31103     return hash;
31104   }
31105   function utilSafeClassName(str) {
31106     return str.toLowerCase().replace(/[^a-z0-9]+/g, "_");
31107   }
31108   function utilUniqueDomId(val) {
31109     return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString();
31110   }
31111   function utilUnicodeCharsCount(str) {
31112     return Array.from(str).length;
31113   }
31114   function utilUnicodeCharsTruncated(str, limit) {
31115     return Array.from(str).slice(0, limit).join("");
31116   }
31117   function toNumericID(id2) {
31118     var match = id2.match(/^[cnwr](-?\d+)$/);
31119     if (match) {
31120       return parseInt(match[1], 10);
31121     }
31122     return NaN;
31123   }
31124   function compareNumericIDs(left, right) {
31125     if (isNaN(left) && isNaN(right))
31126       return -1;
31127     if (isNaN(left))
31128       return 1;
31129     if (isNaN(right))
31130       return -1;
31131     if (Math.sign(left) !== Math.sign(right))
31132       return -Math.sign(left);
31133     if (Math.sign(left) < 0)
31134       return Math.sign(right - left);
31135     return Math.sign(left - right);
31136   }
31137   function utilCompareIDs(left, right) {
31138     return compareNumericIDs(toNumericID(left), toNumericID(right));
31139   }
31140   function utilOldestID(ids) {
31141     if (ids.length === 0) {
31142       return void 0;
31143     }
31144     var oldestIDIndex = 0;
31145     var oldestID = toNumericID(ids[0]);
31146     for (var i3 = 1; i3 < ids.length; i3++) {
31147       var num = toNumericID(ids[i3]);
31148       if (compareNumericIDs(oldestID, num) === 1) {
31149         oldestIDIndex = i3;
31150         oldestID = num;
31151       }
31152     }
31153     return ids[oldestIDIndex];
31154   }
31155   function utilCleanOsmString(val, maxChars) {
31156     if (val === void 0 || val === null) {
31157       val = "";
31158     } else {
31159       val = val.toString();
31160     }
31161     val = val.trim();
31162     if (val.normalize)
31163       val = val.normalize("NFC");
31164     return utilUnicodeCharsTruncated(val, maxChars);
31165   }
31166
31167   // modules/osm/entity.js
31168   function osmEntity(attrs) {
31169     if (this instanceof osmEntity)
31170       return;
31171     if (attrs && attrs.type) {
31172       return osmEntity[attrs.type].apply(this, arguments);
31173     } else if (attrs && attrs.id) {
31174       return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
31175     }
31176     return new osmEntity().initialize(arguments);
31177   }
31178   osmEntity.id = function(type2) {
31179     return osmEntity.id.fromOSM(type2, osmEntity.id.next[type2]--);
31180   };
31181   osmEntity.id.next = {
31182     changeset: -1,
31183     node: -1,
31184     way: -1,
31185     relation: -1
31186   };
31187   osmEntity.id.fromOSM = function(type2, id2) {
31188     return type2[0] + id2;
31189   };
31190   osmEntity.id.toOSM = function(id2) {
31191     var match = id2.match(/^[cnwr](-?\d+)$/);
31192     if (match) {
31193       return match[1];
31194     }
31195     return "";
31196   };
31197   osmEntity.id.type = function(id2) {
31198     return { "c": "changeset", "n": "node", "w": "way", "r": "relation" }[id2[0]];
31199   };
31200   osmEntity.key = function(entity) {
31201     return entity.id + "v" + (entity.v || 0);
31202   };
31203   var _deprecatedTagValuesByKey;
31204   osmEntity.deprecatedTagValuesByKey = function(dataDeprecated) {
31205     if (!_deprecatedTagValuesByKey) {
31206       _deprecatedTagValuesByKey = {};
31207       dataDeprecated.forEach(function(d2) {
31208         var oldKeys = Object.keys(d2.old);
31209         if (oldKeys.length === 1) {
31210           var oldKey = oldKeys[0];
31211           var oldValue = d2.old[oldKey];
31212           if (oldValue !== "*") {
31213             if (!_deprecatedTagValuesByKey[oldKey]) {
31214               _deprecatedTagValuesByKey[oldKey] = [oldValue];
31215             } else {
31216               _deprecatedTagValuesByKey[oldKey].push(oldValue);
31217             }
31218           }
31219         }
31220       });
31221     }
31222     return _deprecatedTagValuesByKey;
31223   };
31224   osmEntity.prototype = {
31225     tags: {},
31226     initialize: function(sources) {
31227       for (var i3 = 0; i3 < sources.length; ++i3) {
31228         var source = sources[i3];
31229         for (var prop in source) {
31230           if (Object.prototype.hasOwnProperty.call(source, prop)) {
31231             if (source[prop] === void 0) {
31232               delete this[prop];
31233             } else {
31234               this[prop] = source[prop];
31235             }
31236           }
31237         }
31238       }
31239       if (!this.id && this.type) {
31240         this.id = osmEntity.id(this.type);
31241       }
31242       if (!this.hasOwnProperty("visible")) {
31243         this.visible = true;
31244       }
31245       if (debug) {
31246         Object.freeze(this);
31247         Object.freeze(this.tags);
31248         if (this.loc)
31249           Object.freeze(this.loc);
31250         if (this.nodes)
31251           Object.freeze(this.nodes);
31252         if (this.members)
31253           Object.freeze(this.members);
31254       }
31255       return this;
31256     },
31257     copy: function(resolver, copies) {
31258       if (copies[this.id])
31259         return copies[this.id];
31260       var copy2 = osmEntity(this, { id: void 0, user: void 0, version: void 0 });
31261       copies[this.id] = copy2;
31262       return copy2;
31263     },
31264     osmId: function() {
31265       return osmEntity.id.toOSM(this.id);
31266     },
31267     isNew: function() {
31268       var osmId = osmEntity.id.toOSM(this.id);
31269       return osmId.length === 0 || osmId[0] === "-";
31270     },
31271     update: function(attrs) {
31272       return osmEntity(this, attrs, { v: 1 + (this.v || 0) });
31273     },
31274     mergeTags: function(tags) {
31275       var merged = Object.assign({}, this.tags);
31276       var changed = false;
31277       for (var k2 in tags) {
31278         var t1 = merged[k2];
31279         var t2 = tags[k2];
31280         if (!t1) {
31281           changed = true;
31282           merged[k2] = t2;
31283         } else if (t1 !== t2) {
31284           changed = true;
31285           merged[k2] = utilUnicodeCharsTruncated(
31286             utilArrayUnion(t1.split(/;\s*/), t2.split(/;\s*/)).join(";"),
31287             255
31288             // avoid exceeding character limit; see also context.maxCharsForTagValue()
31289           );
31290         }
31291       }
31292       return changed ? this.update({ tags: merged }) : this;
31293     },
31294     intersects: function(extent, resolver) {
31295       return this.extent(resolver).intersects(extent);
31296     },
31297     hasNonGeometryTags: function() {
31298       return Object.keys(this.tags).some(function(k2) {
31299         return k2 !== "area";
31300       });
31301     },
31302     hasParentRelations: function(resolver) {
31303       return resolver.parentRelations(this).length > 0;
31304     },
31305     hasInterestingTags: function() {
31306       return Object.keys(this.tags).some(osmIsInterestingTag);
31307     },
31308     isHighwayIntersection: function() {
31309       return false;
31310     },
31311     isDegenerate: function() {
31312       return true;
31313     },
31314     deprecatedTags: function(dataDeprecated) {
31315       var tags = this.tags;
31316       if (Object.keys(tags).length === 0)
31317         return [];
31318       var deprecated = [];
31319       dataDeprecated.forEach(function(d2) {
31320         var oldKeys = Object.keys(d2.old);
31321         if (d2.replace) {
31322           var hasExistingValues = Object.keys(d2.replace).some(function(replaceKey) {
31323             if (!tags[replaceKey] || d2.old[replaceKey])
31324               return false;
31325             var replaceValue = d2.replace[replaceKey];
31326             if (replaceValue === "*")
31327               return false;
31328             if (replaceValue === tags[replaceKey])
31329               return false;
31330             return true;
31331           });
31332           if (hasExistingValues)
31333             return;
31334         }
31335         var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
31336           if (!tags[oldKey])
31337             return false;
31338           if (d2.old[oldKey] === "*")
31339             return true;
31340           if (d2.old[oldKey] === tags[oldKey])
31341             return true;
31342           var vals = tags[oldKey].split(";").filter(Boolean);
31343           if (vals.length === 0) {
31344             return false;
31345           } else if (vals.length > 1) {
31346             return vals.indexOf(d2.old[oldKey]) !== -1;
31347           } else {
31348             if (tags[oldKey] === d2.old[oldKey]) {
31349               if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) {
31350                 var replaceKeys = Object.keys(d2.replace);
31351                 return !replaceKeys.every(function(replaceKey) {
31352                   return tags[replaceKey] === d2.replace[replaceKey];
31353                 });
31354               } else {
31355                 return true;
31356               }
31357             }
31358           }
31359           return false;
31360         });
31361         if (matchesDeprecatedTags) {
31362           deprecated.push(d2);
31363         }
31364       });
31365       return deprecated;
31366     }
31367   };
31368
31369   // modules/osm/lanes.js
31370   function osmLanes(entity) {
31371     if (entity.type !== "way")
31372       return null;
31373     if (!entity.tags.highway)
31374       return null;
31375     var tags = entity.tags;
31376     var isOneWay = entity.isOneWay();
31377     var laneCount = getLaneCount(tags, isOneWay);
31378     var maxspeed = parseMaxspeed(tags);
31379     var laneDirections = parseLaneDirections(tags, isOneWay, laneCount);
31380     var forward = laneDirections.forward;
31381     var backward = laneDirections.backward;
31382     var bothways = laneDirections.bothways;
31383     var turnLanes = {};
31384     turnLanes.unspecified = parseTurnLanes(tags["turn:lanes"]);
31385     turnLanes.forward = parseTurnLanes(tags["turn:lanes:forward"]);
31386     turnLanes.backward = parseTurnLanes(tags["turn:lanes:backward"]);
31387     var maxspeedLanes = {};
31388     maxspeedLanes.unspecified = parseMaxspeedLanes(tags["maxspeed:lanes"], maxspeed);
31389     maxspeedLanes.forward = parseMaxspeedLanes(tags["maxspeed:lanes:forward"], maxspeed);
31390     maxspeedLanes.backward = parseMaxspeedLanes(tags["maxspeed:lanes:backward"], maxspeed);
31391     var psvLanes = {};
31392     psvLanes.unspecified = parseMiscLanes(tags["psv:lanes"]);
31393     psvLanes.forward = parseMiscLanes(tags["psv:lanes:forward"]);
31394     psvLanes.backward = parseMiscLanes(tags["psv:lanes:backward"]);
31395     var busLanes = {};
31396     busLanes.unspecified = parseMiscLanes(tags["bus:lanes"]);
31397     busLanes.forward = parseMiscLanes(tags["bus:lanes:forward"]);
31398     busLanes.backward = parseMiscLanes(tags["bus:lanes:backward"]);
31399     var taxiLanes = {};
31400     taxiLanes.unspecified = parseMiscLanes(tags["taxi:lanes"]);
31401     taxiLanes.forward = parseMiscLanes(tags["taxi:lanes:forward"]);
31402     taxiLanes.backward = parseMiscLanes(tags["taxi:lanes:backward"]);
31403     var hovLanes = {};
31404     hovLanes.unspecified = parseMiscLanes(tags["hov:lanes"]);
31405     hovLanes.forward = parseMiscLanes(tags["hov:lanes:forward"]);
31406     hovLanes.backward = parseMiscLanes(tags["hov:lanes:backward"]);
31407     var hgvLanes = {};
31408     hgvLanes.unspecified = parseMiscLanes(tags["hgv:lanes"]);
31409     hgvLanes.forward = parseMiscLanes(tags["hgv:lanes:forward"]);
31410     hgvLanes.backward = parseMiscLanes(tags["hgv:lanes:backward"]);
31411     var bicyclewayLanes = {};
31412     bicyclewayLanes.unspecified = parseBicycleWay(tags["bicycleway:lanes"]);
31413     bicyclewayLanes.forward = parseBicycleWay(tags["bicycleway:lanes:forward"]);
31414     bicyclewayLanes.backward = parseBicycleWay(tags["bicycleway:lanes:backward"]);
31415     var lanesObj = {
31416       forward: [],
31417       backward: [],
31418       unspecified: []
31419     };
31420     mapToLanesObj(lanesObj, turnLanes, "turnLane");
31421     mapToLanesObj(lanesObj, maxspeedLanes, "maxspeed");
31422     mapToLanesObj(lanesObj, psvLanes, "psv");
31423     mapToLanesObj(lanesObj, busLanes, "bus");
31424     mapToLanesObj(lanesObj, taxiLanes, "taxi");
31425     mapToLanesObj(lanesObj, hovLanes, "hov");
31426     mapToLanesObj(lanesObj, hgvLanes, "hgv");
31427     mapToLanesObj(lanesObj, bicyclewayLanes, "bicycleway");
31428     return {
31429       metadata: {
31430         count: laneCount,
31431         oneway: isOneWay,
31432         forward,
31433         backward,
31434         bothways,
31435         turnLanes,
31436         maxspeed,
31437         maxspeedLanes,
31438         psvLanes,
31439         busLanes,
31440         taxiLanes,
31441         hovLanes,
31442         hgvLanes,
31443         bicyclewayLanes
31444       },
31445       lanes: lanesObj
31446     };
31447   }
31448   function getLaneCount(tags, isOneWay) {
31449     var count;
31450     if (tags.lanes) {
31451       count = parseInt(tags.lanes, 10);
31452       if (count > 0) {
31453         return count;
31454       }
31455     }
31456     switch (tags.highway) {
31457       case "trunk":
31458       case "motorway":
31459         count = isOneWay ? 2 : 4;
31460         break;
31461       default:
31462         count = isOneWay ? 1 : 2;
31463         break;
31464     }
31465     return count;
31466   }
31467   function parseMaxspeed(tags) {
31468     var maxspeed = tags.maxspeed;
31469     if (!maxspeed)
31470       return;
31471     var maxspeedRegex = /^([0-9][\.0-9]+?)(?:[ ]?(?:km\/h|kmh|kph|mph|knots))?$/;
31472     if (!maxspeedRegex.test(maxspeed))
31473       return;
31474     return parseInt(maxspeed, 10);
31475   }
31476   function parseLaneDirections(tags, isOneWay, laneCount) {
31477     var forward = parseInt(tags["lanes:forward"], 10);
31478     var backward = parseInt(tags["lanes:backward"], 10);
31479     var bothways = parseInt(tags["lanes:both_ways"], 10) > 0 ? 1 : 0;
31480     if (parseInt(tags.oneway, 10) === -1) {
31481       forward = 0;
31482       bothways = 0;
31483       backward = laneCount;
31484     } else if (isOneWay) {
31485       forward = laneCount;
31486       bothways = 0;
31487       backward = 0;
31488     } else if (isNaN(forward) && isNaN(backward)) {
31489       backward = Math.floor((laneCount - bothways) / 2);
31490       forward = laneCount - bothways - backward;
31491     } else if (isNaN(forward)) {
31492       if (backward > laneCount - bothways) {
31493         backward = laneCount - bothways;
31494       }
31495       forward = laneCount - bothways - backward;
31496     } else if (isNaN(backward)) {
31497       if (forward > laneCount - bothways) {
31498         forward = laneCount - bothways;
31499       }
31500       backward = laneCount - bothways - forward;
31501     }
31502     return {
31503       forward,
31504       backward,
31505       bothways
31506     };
31507   }
31508   function parseTurnLanes(tag2) {
31509     if (!tag2)
31510       return;
31511     var validValues = [
31512       "left",
31513       "slight_left",
31514       "sharp_left",
31515       "through",
31516       "right",
31517       "slight_right",
31518       "sharp_right",
31519       "reverse",
31520       "merge_to_left",
31521       "merge_to_right",
31522       "none"
31523     ];
31524     return tag2.split("|").map(function(s2) {
31525       if (s2 === "")
31526         s2 = "none";
31527       return s2.split(";").map(function(d2) {
31528         return validValues.indexOf(d2) === -1 ? "unknown" : d2;
31529       });
31530     });
31531   }
31532   function parseMaxspeedLanes(tag2, maxspeed) {
31533     if (!tag2)
31534       return;
31535     return tag2.split("|").map(function(s2) {
31536       if (s2 === "none")
31537         return s2;
31538       var m2 = parseInt(s2, 10);
31539       if (s2 === "" || m2 === maxspeed)
31540         return null;
31541       return isNaN(m2) ? "unknown" : m2;
31542     });
31543   }
31544   function parseMiscLanes(tag2) {
31545     if (!tag2)
31546       return;
31547     var validValues = [
31548       "yes",
31549       "no",
31550       "designated"
31551     ];
31552     return tag2.split("|").map(function(s2) {
31553       if (s2 === "")
31554         s2 = "no";
31555       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31556     });
31557   }
31558   function parseBicycleWay(tag2) {
31559     if (!tag2)
31560       return;
31561     var validValues = [
31562       "yes",
31563       "no",
31564       "designated",
31565       "lane"
31566     ];
31567     return tag2.split("|").map(function(s2) {
31568       if (s2 === "")
31569         s2 = "no";
31570       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31571     });
31572   }
31573   function mapToLanesObj(lanesObj, data, key) {
31574     if (data.forward) {
31575       data.forward.forEach(function(l2, i3) {
31576         if (!lanesObj.forward[i3])
31577           lanesObj.forward[i3] = {};
31578         lanesObj.forward[i3][key] = l2;
31579       });
31580     }
31581     if (data.backward) {
31582       data.backward.forEach(function(l2, i3) {
31583         if (!lanesObj.backward[i3])
31584           lanesObj.backward[i3] = {};
31585         lanesObj.backward[i3][key] = l2;
31586       });
31587     }
31588     if (data.unspecified) {
31589       data.unspecified.forEach(function(l2, i3) {
31590         if (!lanesObj.unspecified[i3])
31591           lanesObj.unspecified[i3] = {};
31592         lanesObj.unspecified[i3][key] = l2;
31593       });
31594     }
31595   }
31596
31597   // modules/osm/way.js
31598   function osmWay() {
31599     if (!(this instanceof osmWay)) {
31600       return new osmWay().initialize(arguments);
31601     } else if (arguments.length) {
31602       this.initialize(arguments);
31603     }
31604   }
31605   osmEntity.way = osmWay;
31606   osmWay.prototype = Object.create(osmEntity.prototype);
31607   Object.assign(osmWay.prototype, {
31608     type: "way",
31609     nodes: [],
31610     copy: function(resolver, copies) {
31611       if (copies[this.id])
31612         return copies[this.id];
31613       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
31614       var nodes = this.nodes.map(function(id2) {
31615         return resolver.entity(id2).copy(resolver, copies).id;
31616       });
31617       copy2 = copy2.update({ nodes });
31618       copies[this.id] = copy2;
31619       return copy2;
31620     },
31621     extent: function(resolver) {
31622       return resolver.transient(this, "extent", function() {
31623         var extent = geoExtent();
31624         for (var i3 = 0; i3 < this.nodes.length; i3++) {
31625           var node = resolver.hasEntity(this.nodes[i3]);
31626           if (node) {
31627             extent._extend(node.extent());
31628           }
31629         }
31630         return extent;
31631       });
31632     },
31633     first: function() {
31634       return this.nodes[0];
31635     },
31636     last: function() {
31637       return this.nodes[this.nodes.length - 1];
31638     },
31639     contains: function(node) {
31640       return this.nodes.indexOf(node) >= 0;
31641     },
31642     affix: function(node) {
31643       if (this.nodes[0] === node)
31644         return "prefix";
31645       if (this.nodes[this.nodes.length - 1] === node)
31646         return "suffix";
31647     },
31648     layer: function() {
31649       if (isFinite(this.tags.layer)) {
31650         return Math.max(-10, Math.min(+this.tags.layer, 10));
31651       }
31652       if (this.tags.covered === "yes")
31653         return -1;
31654       if (this.tags.location === "overground")
31655         return 1;
31656       if (this.tags.location === "underground")
31657         return -1;
31658       if (this.tags.location === "underwater")
31659         return -10;
31660       if (this.tags.power === "line")
31661         return 10;
31662       if (this.tags.power === "minor_line")
31663         return 10;
31664       if (this.tags.aerialway)
31665         return 10;
31666       if (this.tags.bridge)
31667         return 1;
31668       if (this.tags.cutting)
31669         return -1;
31670       if (this.tags.tunnel)
31671         return -1;
31672       if (this.tags.waterway)
31673         return -1;
31674       if (this.tags.man_made === "pipeline")
31675         return -10;
31676       if (this.tags.boundary)
31677         return -10;
31678       return 0;
31679     },
31680     // the approximate width of the line based on its tags except its `width` tag
31681     impliedLineWidthMeters: function() {
31682       var averageWidths = {
31683         highway: {
31684           // width is for single lane
31685           motorway: 5,
31686           motorway_link: 5,
31687           trunk: 4.5,
31688           trunk_link: 4.5,
31689           primary: 4,
31690           secondary: 4,
31691           tertiary: 4,
31692           primary_link: 4,
31693           secondary_link: 4,
31694           tertiary_link: 4,
31695           unclassified: 4,
31696           road: 4,
31697           living_street: 4,
31698           bus_guideway: 4,
31699           busway: 4,
31700           pedestrian: 4,
31701           residential: 3.5,
31702           service: 3.5,
31703           track: 3,
31704           cycleway: 2.5,
31705           bridleway: 2,
31706           corridor: 2,
31707           steps: 2,
31708           path: 1.5,
31709           footway: 1.5
31710         },
31711         railway: {
31712           // width includes ties and rail bed, not just track gauge
31713           rail: 2.5,
31714           light_rail: 2.5,
31715           tram: 2.5,
31716           subway: 2.5,
31717           monorail: 2.5,
31718           funicular: 2.5,
31719           disused: 2.5,
31720           preserved: 2.5,
31721           miniature: 1.5,
31722           narrow_gauge: 1.5
31723         },
31724         waterway: {
31725           river: 50,
31726           canal: 25,
31727           stream: 5,
31728           tidal_channel: 5,
31729           fish_pass: 2.5,
31730           drain: 2.5,
31731           ditch: 1.5
31732         }
31733       };
31734       for (var key in averageWidths) {
31735         if (this.tags[key] && averageWidths[key][this.tags[key]]) {
31736           var width = averageWidths[key][this.tags[key]];
31737           if (key === "highway") {
31738             var laneCount = this.tags.lanes && parseInt(this.tags.lanes, 10);
31739             if (!laneCount)
31740               laneCount = this.isOneWay() ? 1 : 2;
31741             return width * laneCount;
31742           }
31743           return width;
31744         }
31745       }
31746       return null;
31747     },
31748     isOneWay: function() {
31749       var values = {
31750         "yes": true,
31751         "1": true,
31752         "-1": true,
31753         "reversible": true,
31754         "alternating": true,
31755         "no": false,
31756         "0": false
31757       };
31758       if (values[this.tags.oneway] !== void 0) {
31759         return values[this.tags.oneway];
31760       }
31761       for (var key in this.tags) {
31762         if (key in osmOneWayTags && this.tags[key] in osmOneWayTags[key]) {
31763           return true;
31764         }
31765       }
31766       return false;
31767     },
31768     // Some identifier for tag that implies that this way is "sided",
31769     // i.e. the right side is the 'inside' (e.g. the right side of a
31770     // natural=cliff is lower).
31771     sidednessIdentifier: function() {
31772       for (const realKey in this.tags) {
31773         const value = this.tags[realKey];
31774         const key = osmRemoveLifecyclePrefix(realKey);
31775         if (key in osmRightSideIsInsideTags && value in osmRightSideIsInsideTags[key]) {
31776           if (osmRightSideIsInsideTags[key][value] === true) {
31777             return key;
31778           } else {
31779             return osmRightSideIsInsideTags[key][value];
31780           }
31781         }
31782       }
31783       return null;
31784     },
31785     isSided: function() {
31786       if (this.tags.two_sided === "yes") {
31787         return false;
31788       }
31789       return this.sidednessIdentifier() !== null;
31790     },
31791     lanes: function() {
31792       return osmLanes(this);
31793     },
31794     isClosed: function() {
31795       return this.nodes.length > 1 && this.first() === this.last();
31796     },
31797     isConvex: function(resolver) {
31798       if (!this.isClosed() || this.isDegenerate())
31799         return null;
31800       var nodes = utilArrayUniq(resolver.childNodes(this));
31801       var coords = nodes.map(function(n3) {
31802         return n3.loc;
31803       });
31804       var curr = 0;
31805       var prev = 0;
31806       for (var i3 = 0; i3 < coords.length; i3++) {
31807         var o2 = coords[(i3 + 1) % coords.length];
31808         var a2 = coords[i3];
31809         var b2 = coords[(i3 + 2) % coords.length];
31810         var res = geoVecCross(a2, b2, o2);
31811         curr = res > 0 ? 1 : res < 0 ? -1 : 0;
31812         if (curr === 0) {
31813           continue;
31814         } else if (prev && curr !== prev) {
31815           return false;
31816         }
31817         prev = curr;
31818       }
31819       return true;
31820     },
31821     // returns an object with the tag that implies this is an area, if any
31822     tagSuggestingArea: function() {
31823       return osmTagSuggestingArea(this.tags);
31824     },
31825     isArea: function() {
31826       if (this.tags.area === "yes")
31827         return true;
31828       if (!this.isClosed() || this.tags.area === "no")
31829         return false;
31830       return this.tagSuggestingArea() !== null;
31831     },
31832     isDegenerate: function() {
31833       return new Set(this.nodes).size < (this.isArea() ? 3 : 2);
31834     },
31835     areAdjacent: function(n1, n22) {
31836       for (var i3 = 0; i3 < this.nodes.length; i3++) {
31837         if (this.nodes[i3] === n1) {
31838           if (this.nodes[i3 - 1] === n22)
31839             return true;
31840           if (this.nodes[i3 + 1] === n22)
31841             return true;
31842         }
31843       }
31844       return false;
31845     },
31846     geometry: function(graph) {
31847       return graph.transient(this, "geometry", function() {
31848         return this.isArea() ? "area" : "line";
31849       });
31850     },
31851     // returns an array of objects representing the segments between the nodes in this way
31852     segments: function(graph) {
31853       function segmentExtent(graph2) {
31854         var n1 = graph2.hasEntity(this.nodes[0]);
31855         var n22 = graph2.hasEntity(this.nodes[1]);
31856         return n1 && n22 && geoExtent([
31857           [
31858             Math.min(n1.loc[0], n22.loc[0]),
31859             Math.min(n1.loc[1], n22.loc[1])
31860           ],
31861           [
31862             Math.max(n1.loc[0], n22.loc[0]),
31863             Math.max(n1.loc[1], n22.loc[1])
31864           ]
31865         ]);
31866       }
31867       return graph.transient(this, "segments", function() {
31868         var segments = [];
31869         for (var i3 = 0; i3 < this.nodes.length - 1; i3++) {
31870           segments.push({
31871             id: this.id + "-" + i3,
31872             wayId: this.id,
31873             index: i3,
31874             nodes: [this.nodes[i3], this.nodes[i3 + 1]],
31875             extent: segmentExtent
31876           });
31877         }
31878         return segments;
31879       });
31880     },
31881     // If this way is not closed, append the beginning node to the end of the nodelist to close it.
31882     close: function() {
31883       if (this.isClosed() || !this.nodes.length)
31884         return this;
31885       var nodes = this.nodes.slice();
31886       nodes = nodes.filter(noRepeatNodes);
31887       nodes.push(nodes[0]);
31888       return this.update({ nodes });
31889     },
31890     // If this way is closed, remove any connector nodes from the end of the nodelist to unclose it.
31891     unclose: function() {
31892       if (!this.isClosed())
31893         return this;
31894       var nodes = this.nodes.slice();
31895       var connector = this.first();
31896       var i3 = nodes.length - 1;
31897       while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31898         nodes.splice(i3, 1);
31899         i3 = nodes.length - 1;
31900       }
31901       nodes = nodes.filter(noRepeatNodes);
31902       return this.update({ nodes });
31903     },
31904     // Adds a node (id) in front of the node which is currently at position index.
31905     // If index is undefined, the node will be added to the end of the way for linear ways,
31906     //   or just before the final connecting node for circular ways.
31907     // Consecutive duplicates are eliminated including existing ones.
31908     // Circularity is always preserved when adding a node.
31909     addNode: function(id2, index) {
31910       var nodes = this.nodes.slice();
31911       var isClosed = this.isClosed();
31912       var max3 = isClosed ? nodes.length - 1 : nodes.length;
31913       if (index === void 0) {
31914         index = max3;
31915       }
31916       if (index < 0 || index > max3) {
31917         throw new RangeError("index " + index + " out of range 0.." + max3);
31918       }
31919       if (isClosed) {
31920         var connector = this.first();
31921         var i3 = 1;
31922         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31923           nodes.splice(i3, 1);
31924           if (index > i3)
31925             index--;
31926         }
31927         i3 = nodes.length - 1;
31928         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31929           nodes.splice(i3, 1);
31930           if (index > i3)
31931             index--;
31932           i3 = nodes.length - 1;
31933         }
31934       }
31935       nodes.splice(index, 0, id2);
31936       nodes = nodes.filter(noRepeatNodes);
31937       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31938         nodes.push(nodes[0]);
31939       }
31940       return this.update({ nodes });
31941     },
31942     // Replaces the node which is currently at position index with the given node (id).
31943     // Consecutive duplicates are eliminated including existing ones.
31944     // Circularity is preserved when updating a node.
31945     updateNode: function(id2, index) {
31946       var nodes = this.nodes.slice();
31947       var isClosed = this.isClosed();
31948       var max3 = nodes.length - 1;
31949       if (index === void 0 || index < 0 || index > max3) {
31950         throw new RangeError("index " + index + " out of range 0.." + max3);
31951       }
31952       if (isClosed) {
31953         var connector = this.first();
31954         var i3 = 1;
31955         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31956           nodes.splice(i3, 1);
31957           if (index > i3)
31958             index--;
31959         }
31960         i3 = nodes.length - 1;
31961         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31962           nodes.splice(i3, 1);
31963           if (index === i3)
31964             index = 0;
31965           i3 = nodes.length - 1;
31966         }
31967       }
31968       nodes.splice(index, 1, id2);
31969       nodes = nodes.filter(noRepeatNodes);
31970       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31971         nodes.push(nodes[0]);
31972       }
31973       return this.update({ nodes });
31974     },
31975     // Replaces each occurrence of node id needle with replacement.
31976     // Consecutive duplicates are eliminated including existing ones.
31977     // Circularity is preserved.
31978     replaceNode: function(needleID, replacementID) {
31979       var nodes = this.nodes.slice();
31980       var isClosed = this.isClosed();
31981       for (var i3 = 0; i3 < nodes.length; i3++) {
31982         if (nodes[i3] === needleID) {
31983           nodes[i3] = replacementID;
31984         }
31985       }
31986       nodes = nodes.filter(noRepeatNodes);
31987       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31988         nodes.push(nodes[0]);
31989       }
31990       return this.update({ nodes });
31991     },
31992     // Removes each occurrence of node id.
31993     // Consecutive duplicates are eliminated including existing ones.
31994     // Circularity is preserved.
31995     removeNode: function(id2) {
31996       var nodes = this.nodes.slice();
31997       var isClosed = this.isClosed();
31998       nodes = nodes.filter(function(node) {
31999         return node !== id2;
32000       }).filter(noRepeatNodes);
32001       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
32002         nodes.push(nodes[0]);
32003       }
32004       return this.update({ nodes });
32005     },
32006     asJXON: function(changeset_id) {
32007       var r2 = {
32008         way: {
32009           "@id": this.osmId(),
32010           "@version": this.version || 0,
32011           nd: this.nodes.map(function(id2) {
32012             return { keyAttributes: { ref: osmEntity.id.toOSM(id2) } };
32013           }, this),
32014           tag: Object.keys(this.tags).map(function(k2) {
32015             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32016           }, this)
32017         }
32018       };
32019       if (changeset_id) {
32020         r2.way["@changeset"] = changeset_id;
32021       }
32022       return r2;
32023     },
32024     asGeoJSON: function(resolver) {
32025       return resolver.transient(this, "GeoJSON", function() {
32026         var coordinates = resolver.childNodes(this).map(function(n3) {
32027           return n3.loc;
32028         });
32029         if (this.isArea() && this.isClosed()) {
32030           return {
32031             type: "Polygon",
32032             coordinates: [coordinates]
32033           };
32034         } else {
32035           return {
32036             type: "LineString",
32037             coordinates
32038           };
32039         }
32040       });
32041     },
32042     area: function(resolver) {
32043       return resolver.transient(this, "area", function() {
32044         var nodes = resolver.childNodes(this);
32045         var json = {
32046           type: "Polygon",
32047           coordinates: [nodes.map(function(n3) {
32048             return n3.loc;
32049           })]
32050         };
32051         if (!this.isClosed() && nodes.length) {
32052           json.coordinates[0].push(nodes[0].loc);
32053         }
32054         var area = area_default(json);
32055         if (area > 2 * Math.PI) {
32056           json.coordinates[0] = json.coordinates[0].reverse();
32057           area = area_default(json);
32058         }
32059         return isNaN(area) ? 0 : area;
32060       });
32061     }
32062   });
32063   function noRepeatNodes(node, i3, arr) {
32064     return i3 === 0 || node !== arr[i3 - 1];
32065   }
32066
32067   // modules/osm/multipolygon.js
32068   function osmOldMultipolygonOuterMemberOfRelation(entity, graph) {
32069     if (entity.type !== "relation" || !entity.isMultipolygon() || Object.keys(entity.tags).filter(osmIsInterestingTag).length > 1) {
32070       return false;
32071     }
32072     var outerMember;
32073     for (var memberIndex in entity.members) {
32074       var member = entity.members[memberIndex];
32075       if (!member.role || member.role === "outer") {
32076         if (outerMember)
32077           return false;
32078         if (member.type !== "way")
32079           return false;
32080         if (!graph.hasEntity(member.id))
32081           return false;
32082         outerMember = graph.entity(member.id);
32083         if (Object.keys(outerMember.tags).filter(osmIsInterestingTag).length === 0) {
32084           return false;
32085         }
32086       }
32087     }
32088     return outerMember;
32089   }
32090   function osmIsOldMultipolygonOuterMember(entity, graph) {
32091     if (entity.type !== "way" || Object.keys(entity.tags).filter(osmIsInterestingTag).length === 0) {
32092       return false;
32093     }
32094     var parents = graph.parentRelations(entity);
32095     if (parents.length !== 1)
32096       return false;
32097     var parent = parents[0];
32098     if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
32099       return false;
32100     }
32101     var members = parent.members, member;
32102     for (var i3 = 0; i3 < members.length; i3++) {
32103       member = members[i3];
32104       if (member.id === entity.id && member.role && member.role !== "outer") {
32105         return false;
32106       }
32107       if (member.id !== entity.id && (!member.role || member.role === "outer")) {
32108         return false;
32109       }
32110     }
32111     return parent;
32112   }
32113   function osmOldMultipolygonOuterMember(entity, graph) {
32114     if (entity.type !== "way")
32115       return false;
32116     var parents = graph.parentRelations(entity);
32117     if (parents.length !== 1)
32118       return false;
32119     var parent = parents[0];
32120     if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
32121       return false;
32122     }
32123     var members = parent.members, member, outerMember;
32124     for (var i3 = 0; i3 < members.length; i3++) {
32125       member = members[i3];
32126       if (!member.role || member.role === "outer") {
32127         if (outerMember)
32128           return false;
32129         outerMember = member;
32130       }
32131     }
32132     if (!outerMember)
32133       return false;
32134     var outerEntity = graph.hasEntity(outerMember.id);
32135     if (!outerEntity || !Object.keys(outerEntity.tags).filter(osmIsInterestingTag).length) {
32136       return false;
32137     }
32138     return outerEntity;
32139   }
32140   function osmJoinWays(toJoin, graph) {
32141     function resolve(member) {
32142       return graph.childNodes(graph.entity(member.id));
32143     }
32144     function reverse(item2) {
32145       var action = actionReverse(item2.id, { reverseOneway: true });
32146       sequences.actions.push(action);
32147       return item2 instanceof osmWay ? action(graph).entity(item2.id) : item2;
32148     }
32149     toJoin = toJoin.filter(function(member) {
32150       return member.type === "way" && graph.hasEntity(member.id);
32151     });
32152     var i3;
32153     var joinAsMembers = true;
32154     for (i3 = 0; i3 < toJoin.length; i3++) {
32155       if (toJoin[i3] instanceof osmWay) {
32156         joinAsMembers = false;
32157         break;
32158       }
32159     }
32160     var sequences = [];
32161     sequences.actions = [];
32162     while (toJoin.length) {
32163       var item = toJoin.shift();
32164       var currWays = [item];
32165       var currNodes = resolve(item).slice();
32166       while (toJoin.length) {
32167         var start2 = currNodes[0];
32168         var end = currNodes[currNodes.length - 1];
32169         var fn = null;
32170         var nodes = null;
32171         for (i3 = 0; i3 < toJoin.length; i3++) {
32172           item = toJoin[i3];
32173           nodes = resolve(item);
32174           if (joinAsMembers && currWays.length === 1 && nodes[0] !== end && nodes[nodes.length - 1] !== end && (nodes[nodes.length - 1] === start2 || nodes[0] === start2)) {
32175             currWays[0] = reverse(currWays[0]);
32176             currNodes.reverse();
32177             start2 = currNodes[0];
32178             end = currNodes[currNodes.length - 1];
32179           }
32180           if (nodes[0] === end) {
32181             fn = currNodes.push;
32182             nodes = nodes.slice(1);
32183             break;
32184           } else if (nodes[nodes.length - 1] === end) {
32185             fn = currNodes.push;
32186             nodes = nodes.slice(0, -1).reverse();
32187             item = reverse(item);
32188             break;
32189           } else if (nodes[nodes.length - 1] === start2) {
32190             fn = currNodes.unshift;
32191             nodes = nodes.slice(0, -1);
32192             break;
32193           } else if (nodes[0] === start2) {
32194             fn = currNodes.unshift;
32195             nodes = nodes.slice(1).reverse();
32196             item = reverse(item);
32197             break;
32198           } else {
32199             fn = nodes = null;
32200           }
32201         }
32202         if (!nodes) {
32203           break;
32204         }
32205         fn.apply(currWays, [item]);
32206         fn.apply(currNodes, nodes);
32207         toJoin.splice(i3, 1);
32208       }
32209       currWays.nodes = currNodes;
32210       sequences.push(currWays);
32211     }
32212     return sequences;
32213   }
32214
32215   // modules/actions/add_member.js
32216   function actionAddMember(relationId, member, memberIndex, insertPair) {
32217     return function action(graph) {
32218       var relation = graph.entity(relationId);
32219       var isPTv2 = /stop|platform/.test(member.role);
32220       if ((isNaN(memberIndex) || insertPair) && member.type === "way" && !isPTv2) {
32221         graph = addWayMember(relation, graph);
32222       } else {
32223         if (isPTv2 && isNaN(memberIndex)) {
32224           memberIndex = 0;
32225         }
32226         graph = graph.replace(relation.addMember(member, memberIndex));
32227       }
32228       return graph;
32229     };
32230     function addWayMember(relation, graph) {
32231       var groups, tempWay, insertPairIsReversed, item, i3, j2, k2;
32232       var PTv2members = [];
32233       var members = [];
32234       for (i3 = 0; i3 < relation.members.length; i3++) {
32235         var m2 = relation.members[i3];
32236         if (/stop|platform/.test(m2.role)) {
32237           PTv2members.push(m2);
32238         } else {
32239           members.push(m2);
32240         }
32241       }
32242       relation = relation.update({ members });
32243       if (insertPair) {
32244         tempWay = osmWay({ id: "wTemp", nodes: insertPair.nodes });
32245         graph = graph.replace(tempWay);
32246         var tempMember = { id: tempWay.id, type: "way", role: member.role };
32247         var tempRelation = relation.replaceMember({ id: insertPair.originalID }, tempMember, true);
32248         groups = utilArrayGroupBy(tempRelation.members, "type");
32249         groups.way = groups.way || [];
32250         var originalWay = graph.entity(insertPair.originalID);
32251         var insertedWay = graph.entity(insertPair.insertedID);
32252         insertPairIsReversed = originalWay.nodes.length > 0 && insertedWay.nodes.length > 0 && insertedWay.nodes[insertedWay.nodes.length - 1] === originalWay.nodes[0] && originalWay.nodes[originalWay.nodes.length - 1] !== insertedWay.nodes[0];
32253       } else {
32254         groups = utilArrayGroupBy(relation.members, "type");
32255         groups.way = groups.way || [];
32256         groups.way.push(member);
32257       }
32258       members = withIndex(groups.way);
32259       var joined = osmJoinWays(members, graph);
32260       for (i3 = 0; i3 < joined.length; i3++) {
32261         var segment = joined[i3];
32262         var nodes = segment.nodes.slice();
32263         var startIndex = segment[0].index;
32264         for (j2 = 0; j2 < members.length; j2++) {
32265           if (members[j2].index === startIndex) {
32266             break;
32267           }
32268         }
32269         for (k2 = 0; k2 < segment.length; k2++) {
32270           item = segment[k2];
32271           var way = graph.entity(item.id);
32272           if (tempWay && item.id === tempWay.id) {
32273             var reverse = nodes[0].id !== insertPair.nodes[0] ^ insertPairIsReversed;
32274             if (reverse) {
32275               item.pair = [
32276                 { id: insertPair.insertedID, type: "way", role: item.role },
32277                 { id: insertPair.originalID, type: "way", role: item.role }
32278               ];
32279             } else {
32280               item.pair = [
32281                 { id: insertPair.originalID, type: "way", role: item.role },
32282                 { id: insertPair.insertedID, type: "way", role: item.role }
32283               ];
32284             }
32285           }
32286           if (k2 > 0) {
32287             if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) {
32288               moveMember(members, item.index, j2 + k2);
32289             }
32290           }
32291           nodes.splice(0, way.nodes.length - 1);
32292         }
32293       }
32294       if (tempWay) {
32295         graph = graph.remove(tempWay);
32296       }
32297       var wayMembers = [];
32298       for (i3 = 0; i3 < members.length; i3++) {
32299         item = members[i3];
32300         if (item.index === -1)
32301           continue;
32302         if (item.pair) {
32303           wayMembers.push(item.pair[0]);
32304           wayMembers.push(item.pair[1]);
32305         } else {
32306           wayMembers.push(utilObjectOmit(item, ["index"]));
32307         }
32308       }
32309       var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []);
32310       return graph.replace(relation.update({ members: newMembers }));
32311       function moveMember(arr, findIndex, toIndex) {
32312         var i4;
32313         for (i4 = 0; i4 < arr.length; i4++) {
32314           if (arr[i4].index === findIndex) {
32315             break;
32316           }
32317         }
32318         var item2 = Object.assign({}, arr[i4]);
32319         arr[i4].index = -1;
32320         item2.index = toIndex;
32321         arr.splice(toIndex, 0, item2);
32322       }
32323       function withIndex(arr) {
32324         var result = new Array(arr.length);
32325         for (var i4 = 0; i4 < arr.length; i4++) {
32326           result[i4] = Object.assign({}, arr[i4]);
32327           result[i4].index = i4;
32328         }
32329         return result;
32330       }
32331     }
32332   }
32333
32334   // modules/actions/add_midpoint.js
32335   function actionAddMidpoint(midpoint, node) {
32336     return function(graph) {
32337       graph = graph.replace(node.move(midpoint.loc));
32338       var parents = utilArrayIntersection(
32339         graph.parentWays(graph.entity(midpoint.edge[0])),
32340         graph.parentWays(graph.entity(midpoint.edge[1]))
32341       );
32342       parents.forEach(function(way) {
32343         for (var i3 = 0; i3 < way.nodes.length - 1; i3++) {
32344           if (geoEdgeEqual([way.nodes[i3], way.nodes[i3 + 1]], midpoint.edge)) {
32345             graph = graph.replace(graph.entity(way.id).addNode(node.id, i3 + 1));
32346             return;
32347           }
32348         }
32349       });
32350       return graph;
32351     };
32352   }
32353
32354   // modules/actions/add_vertex.js
32355   function actionAddVertex(wayId, nodeId, index) {
32356     return function(graph) {
32357       return graph.replace(graph.entity(wayId).addNode(nodeId, index));
32358     };
32359   }
32360
32361   // modules/actions/change_member.js
32362   function actionChangeMember(relationId, member, memberIndex) {
32363     return function(graph) {
32364       return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
32365     };
32366   }
32367
32368   // modules/actions/change_preset.js
32369   function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
32370     return function action(graph) {
32371       var entity = graph.entity(entityID);
32372       var geometry = entity.geometry(graph);
32373       var tags = entity.tags;
32374       const loc = entity.extent(graph).center();
32375       var preserveKeys;
32376       if (newPreset) {
32377         preserveKeys = [];
32378         if (newPreset.addTags) {
32379           preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
32380         }
32381         if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) {
32382           newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key));
32383         }
32384       }
32385       if (oldPreset)
32386         tags = oldPreset.unsetTags(tags, geometry, preserveKeys, false, loc);
32387       if (newPreset)
32388         tags = newPreset.setTags(tags, geometry, skipFieldDefaults, loc);
32389       return graph.replace(entity.update({ tags }));
32390     };
32391   }
32392
32393   // modules/actions/change_tags.js
32394   function actionChangeTags(entityId, tags) {
32395     return function(graph) {
32396       var entity = graph.entity(entityId);
32397       return graph.replace(entity.update({ tags }));
32398     };
32399   }
32400
32401   // modules/osm/node.js
32402   var cardinal = {
32403     north: 0,
32404     n: 0,
32405     northnortheast: 22,
32406     nne: 22,
32407     northeast: 45,
32408     ne: 45,
32409     eastnortheast: 67,
32410     ene: 67,
32411     east: 90,
32412     e: 90,
32413     eastsoutheast: 112,
32414     ese: 112,
32415     southeast: 135,
32416     se: 135,
32417     southsoutheast: 157,
32418     sse: 157,
32419     south: 180,
32420     s: 180,
32421     southsouthwest: 202,
32422     ssw: 202,
32423     southwest: 225,
32424     sw: 225,
32425     westsouthwest: 247,
32426     wsw: 247,
32427     west: 270,
32428     w: 270,
32429     westnorthwest: 292,
32430     wnw: 292,
32431     northwest: 315,
32432     nw: 315,
32433     northnorthwest: 337,
32434     nnw: 337
32435   };
32436   function osmNode() {
32437     if (!(this instanceof osmNode)) {
32438       return new osmNode().initialize(arguments);
32439     } else if (arguments.length) {
32440       this.initialize(arguments);
32441     }
32442   }
32443   osmEntity.node = osmNode;
32444   osmNode.prototype = Object.create(osmEntity.prototype);
32445   Object.assign(osmNode.prototype, {
32446     type: "node",
32447     loc: [9999, 9999],
32448     extent: function() {
32449       return new geoExtent(this.loc);
32450     },
32451     geometry: function(graph) {
32452       return graph.transient(this, "geometry", function() {
32453         return graph.isPoi(this) ? "point" : "vertex";
32454       });
32455     },
32456     move: function(loc) {
32457       return this.update({ loc });
32458     },
32459     isDegenerate: function() {
32460       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);
32461     },
32462     // Inspect tags and geometry to determine which direction(s) this node/vertex points
32463     directions: function(resolver, projection2) {
32464       var val;
32465       var i3;
32466       if (this.isHighwayIntersection(resolver) && (this.tags.stop || "").toLowerCase() === "all") {
32467         val = "all";
32468       } else {
32469         val = (this.tags.direction || "").toLowerCase();
32470         var re3 = /:direction$/i;
32471         var keys2 = Object.keys(this.tags);
32472         for (i3 = 0; i3 < keys2.length; i3++) {
32473           if (re3.test(keys2[i3])) {
32474             val = this.tags[keys2[i3]].toLowerCase();
32475             break;
32476           }
32477         }
32478       }
32479       if (val === "")
32480         return [];
32481       var values = val.split(";");
32482       var results = [];
32483       values.forEach(function(v2) {
32484         if (cardinal[v2] !== void 0) {
32485           v2 = cardinal[v2];
32486         }
32487         if (v2 !== "" && !isNaN(+v2)) {
32488           results.push(+v2);
32489           return;
32490         }
32491         var lookBackward = this.tags["traffic_sign:backward"] || v2 === "backward" || v2 === "both" || v2 === "all";
32492         var lookForward = this.tags["traffic_sign:forward"] || v2 === "forward" || v2 === "both" || v2 === "all";
32493         if (!lookForward && !lookBackward)
32494           return;
32495         var nodeIds = {};
32496         resolver.parentWays(this).forEach(function(parent) {
32497           var nodes = parent.nodes;
32498           for (i3 = 0; i3 < nodes.length; i3++) {
32499             if (nodes[i3] === this.id) {
32500               if (lookForward && i3 > 0) {
32501                 nodeIds[nodes[i3 - 1]] = true;
32502               }
32503               if (lookBackward && i3 < nodes.length - 1) {
32504                 nodeIds[nodes[i3 + 1]] = true;
32505               }
32506             }
32507           }
32508         }, this);
32509         Object.keys(nodeIds).forEach(function(nodeId) {
32510           results.push(
32511             geoAngle(this, resolver.entity(nodeId), projection2) * (180 / Math.PI) + 90
32512           );
32513         }, this);
32514       }, this);
32515       return utilArrayUniq(results);
32516     },
32517     isCrossing: function() {
32518       return this.tags.highway === "crossing" || this.tags.railway && this.tags.railway.indexOf("crossing") !== -1;
32519     },
32520     isEndpoint: function(resolver) {
32521       return resolver.transient(this, "isEndpoint", function() {
32522         var id2 = this.id;
32523         return resolver.parentWays(this).filter(function(parent) {
32524           return !parent.isClosed() && !!parent.affix(id2);
32525         }).length > 0;
32526       });
32527     },
32528     isConnected: function(resolver) {
32529       return resolver.transient(this, "isConnected", function() {
32530         var parents = resolver.parentWays(this);
32531         if (parents.length > 1) {
32532           for (var i3 in parents) {
32533             if (parents[i3].geometry(resolver) === "line" && parents[i3].hasInterestingTags())
32534               return true;
32535           }
32536         } else if (parents.length === 1) {
32537           var way = parents[0];
32538           var nodes = way.nodes.slice();
32539           if (way.isClosed()) {
32540             nodes.pop();
32541           }
32542           return nodes.indexOf(this.id) !== nodes.lastIndexOf(this.id);
32543         }
32544         return false;
32545       });
32546     },
32547     parentIntersectionWays: function(resolver) {
32548       return resolver.transient(this, "parentIntersectionWays", function() {
32549         return resolver.parentWays(this).filter(function(parent) {
32550           return (parent.tags.highway || parent.tags.waterway || parent.tags.railway || parent.tags.aeroway) && parent.geometry(resolver) === "line";
32551         });
32552       });
32553     },
32554     isIntersection: function(resolver) {
32555       return this.parentIntersectionWays(resolver).length > 1;
32556     },
32557     isHighwayIntersection: function(resolver) {
32558       return resolver.transient(this, "isHighwayIntersection", function() {
32559         return resolver.parentWays(this).filter(function(parent) {
32560           return parent.tags.highway && parent.geometry(resolver) === "line";
32561         }).length > 1;
32562       });
32563     },
32564     isOnAddressLine: function(resolver) {
32565       return resolver.transient(this, "isOnAddressLine", function() {
32566         return resolver.parentWays(this).filter(function(parent) {
32567           return parent.tags.hasOwnProperty("addr:interpolation") && parent.geometry(resolver) === "line";
32568         }).length > 0;
32569       });
32570     },
32571     asJXON: function(changeset_id) {
32572       var r2 = {
32573         node: {
32574           "@id": this.osmId(),
32575           "@lon": this.loc[0],
32576           "@lat": this.loc[1],
32577           "@version": this.version || 0,
32578           tag: Object.keys(this.tags).map(function(k2) {
32579             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32580           }, this)
32581         }
32582       };
32583       if (changeset_id)
32584         r2.node["@changeset"] = changeset_id;
32585       return r2;
32586     },
32587     asGeoJSON: function() {
32588       return {
32589         type: "Point",
32590         coordinates: this.loc
32591       };
32592     }
32593   });
32594
32595   // modules/actions/circularize.js
32596   function actionCircularize(wayId, projection2, maxAngle) {
32597     maxAngle = (maxAngle || 20) * Math.PI / 180;
32598     var action = function(graph, t2) {
32599       if (t2 === null || !isFinite(t2))
32600         t2 = 1;
32601       t2 = Math.min(Math.max(+t2, 0), 1);
32602       var way = graph.entity(wayId);
32603       var origNodes = {};
32604       graph.childNodes(way).forEach(function(node2) {
32605         if (!origNodes[node2.id])
32606           origNodes[node2.id] = node2;
32607       });
32608       if (!way.isConvex(graph)) {
32609         graph = action.makeConvex(graph);
32610       }
32611       var nodes = utilArrayUniq(graph.childNodes(way));
32612       var keyNodes = nodes.filter(function(n3) {
32613         return graph.parentWays(n3).length !== 1;
32614       });
32615       var points = nodes.map(function(n3) {
32616         return projection2(n3.loc);
32617       });
32618       var keyPoints = keyNodes.map(function(n3) {
32619         return projection2(n3.loc);
32620       });
32621       var centroid = points.length === 2 ? geoVecInterp(points[0], points[1], 0.5) : centroid_default2(points);
32622       var radius = median(points, function(p2) {
32623         return geoVecLength(centroid, p2);
32624       });
32625       var sign2 = area_default3(points) > 0 ? 1 : -1;
32626       var ids, i3, j2, k2;
32627       if (!keyNodes.length) {
32628         keyNodes = [nodes[0]];
32629         keyPoints = [points[0]];
32630       }
32631       if (keyNodes.length === 1) {
32632         var index = nodes.indexOf(keyNodes[0]);
32633         var oppositeIndex = Math.floor((index + nodes.length / 2) % nodes.length);
32634         keyNodes.push(nodes[oppositeIndex]);
32635         keyPoints.push(points[oppositeIndex]);
32636       }
32637       for (i3 = 0; i3 < keyPoints.length; i3++) {
32638         var nextKeyNodeIndex = (i3 + 1) % keyNodes.length;
32639         var startNode = keyNodes[i3];
32640         var endNode = keyNodes[nextKeyNodeIndex];
32641         var startNodeIndex = nodes.indexOf(startNode);
32642         var endNodeIndex = nodes.indexOf(endNode);
32643         var numberNewPoints = -1;
32644         var indexRange = endNodeIndex - startNodeIndex;
32645         var nearNodes = {};
32646         var inBetweenNodes = [];
32647         var startAngle, endAngle, totalAngle, eachAngle;
32648         var angle2, loc, node, origNode;
32649         if (indexRange < 0) {
32650           indexRange += nodes.length;
32651         }
32652         var distance = geoVecLength(centroid, keyPoints[i3]) || 1e-4;
32653         keyPoints[i3] = [
32654           centroid[0] + (keyPoints[i3][0] - centroid[0]) / distance * radius,
32655           centroid[1] + (keyPoints[i3][1] - centroid[1]) / distance * radius
32656         ];
32657         loc = projection2.invert(keyPoints[i3]);
32658         node = keyNodes[i3];
32659         origNode = origNodes[node.id];
32660         node = node.move(geoVecInterp(origNode.loc, loc, t2));
32661         graph = graph.replace(node);
32662         startAngle = Math.atan2(keyPoints[i3][1] - centroid[1], keyPoints[i3][0] - centroid[0]);
32663         endAngle = Math.atan2(keyPoints[nextKeyNodeIndex][1] - centroid[1], keyPoints[nextKeyNodeIndex][0] - centroid[0]);
32664         totalAngle = endAngle - startAngle;
32665         if (totalAngle * sign2 > 0) {
32666           totalAngle = -sign2 * (2 * Math.PI - Math.abs(totalAngle));
32667         }
32668         do {
32669           numberNewPoints++;
32670           eachAngle = totalAngle / (indexRange + numberNewPoints);
32671         } while (Math.abs(eachAngle) > maxAngle);
32672         for (j2 = 1; j2 < indexRange; j2++) {
32673           angle2 = startAngle + j2 * eachAngle;
32674           loc = projection2.invert([
32675             centroid[0] + Math.cos(angle2) * radius,
32676             centroid[1] + Math.sin(angle2) * radius
32677           ]);
32678           node = nodes[(j2 + startNodeIndex) % nodes.length];
32679           origNode = origNodes[node.id];
32680           nearNodes[node.id] = angle2;
32681           node = node.move(geoVecInterp(origNode.loc, loc, t2));
32682           graph = graph.replace(node);
32683         }
32684         for (j2 = 0; j2 < numberNewPoints; j2++) {
32685           angle2 = startAngle + (indexRange + j2) * eachAngle;
32686           loc = projection2.invert([
32687             centroid[0] + Math.cos(angle2) * radius,
32688             centroid[1] + Math.sin(angle2) * radius
32689           ]);
32690           var min3 = Infinity;
32691           for (var nodeId in nearNodes) {
32692             var nearAngle = nearNodes[nodeId];
32693             var dist = Math.abs(nearAngle - angle2);
32694             if (dist < min3) {
32695               min3 = dist;
32696               origNode = origNodes[nodeId];
32697             }
32698           }
32699           node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) });
32700           graph = graph.replace(node);
32701           nodes.splice(endNodeIndex + j2, 0, node);
32702           inBetweenNodes.push(node.id);
32703         }
32704         if (indexRange === 1 && inBetweenNodes.length) {
32705           var startIndex1 = way.nodes.lastIndexOf(startNode.id);
32706           var endIndex1 = way.nodes.lastIndexOf(endNode.id);
32707           var wayDirection1 = endIndex1 - startIndex1;
32708           if (wayDirection1 < -1) {
32709             wayDirection1 = 1;
32710           }
32711           var parentWays = graph.parentWays(keyNodes[i3]);
32712           for (j2 = 0; j2 < parentWays.length; j2++) {
32713             var sharedWay = parentWays[j2];
32714             if (sharedWay === way)
32715               continue;
32716             if (sharedWay.areAdjacent(startNode.id, endNode.id)) {
32717               var startIndex2 = sharedWay.nodes.lastIndexOf(startNode.id);
32718               var endIndex2 = sharedWay.nodes.lastIndexOf(endNode.id);
32719               var wayDirection2 = endIndex2 - startIndex2;
32720               var insertAt = endIndex2;
32721               if (wayDirection2 < -1) {
32722                 wayDirection2 = 1;
32723               }
32724               if (wayDirection1 !== wayDirection2) {
32725                 inBetweenNodes.reverse();
32726                 insertAt = startIndex2;
32727               }
32728               for (k2 = 0; k2 < inBetweenNodes.length; k2++) {
32729                 sharedWay = sharedWay.addNode(inBetweenNodes[k2], insertAt + k2);
32730               }
32731               graph = graph.replace(sharedWay);
32732             }
32733           }
32734         }
32735       }
32736       ids = nodes.map(function(n3) {
32737         return n3.id;
32738       });
32739       ids.push(ids[0]);
32740       way = way.update({ nodes: ids });
32741       graph = graph.replace(way);
32742       return graph;
32743     };
32744     action.makeConvex = function(graph) {
32745       var way = graph.entity(wayId);
32746       var nodes = utilArrayUniq(graph.childNodes(way));
32747       var points = nodes.map(function(n3) {
32748         return projection2(n3.loc);
32749       });
32750       var sign2 = area_default3(points) > 0 ? 1 : -1;
32751       var hull = hull_default(points);
32752       var i3, j2;
32753       if (sign2 === -1) {
32754         nodes.reverse();
32755         points.reverse();
32756       }
32757       for (i3 = 0; i3 < hull.length - 1; i3++) {
32758         var startIndex = points.indexOf(hull[i3]);
32759         var endIndex = points.indexOf(hull[i3 + 1]);
32760         var indexRange = endIndex - startIndex;
32761         if (indexRange < 0) {
32762           indexRange += nodes.length;
32763         }
32764         for (j2 = 1; j2 < indexRange; j2++) {
32765           var point2 = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange);
32766           var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point2));
32767           graph = graph.replace(node);
32768         }
32769       }
32770       return graph;
32771     };
32772     action.disabled = function(graph) {
32773       if (!graph.entity(wayId).isClosed()) {
32774         return "not_closed";
32775       }
32776       var way = graph.entity(wayId);
32777       var nodes = utilArrayUniq(graph.childNodes(way));
32778       var points = nodes.map(function(n3) {
32779         return projection2(n3.loc);
32780       });
32781       var hull = hull_default(points);
32782       var epsilonAngle = Math.PI / 180;
32783       if (hull.length !== points.length || hull.length < 3) {
32784         return false;
32785       }
32786       var centroid = centroid_default2(points);
32787       var radius = geoVecLengthSquare(centroid, points[0]);
32788       var i3, actualPoint;
32789       for (i3 = 0; i3 < hull.length; i3++) {
32790         actualPoint = hull[i3];
32791         var actualDist = geoVecLengthSquare(actualPoint, centroid);
32792         var diff = Math.abs(actualDist - radius);
32793         if (diff > 0.05 * radius) {
32794           return false;
32795         }
32796       }
32797       for (i3 = 0; i3 < hull.length; i3++) {
32798         actualPoint = hull[i3];
32799         var nextPoint = hull[(i3 + 1) % hull.length];
32800         var startAngle = Math.atan2(actualPoint[1] - centroid[1], actualPoint[0] - centroid[0]);
32801         var endAngle = Math.atan2(nextPoint[1] - centroid[1], nextPoint[0] - centroid[0]);
32802         var angle2 = endAngle - startAngle;
32803         if (angle2 < 0) {
32804           angle2 = -angle2;
32805         }
32806         if (angle2 > Math.PI) {
32807           angle2 = 2 * Math.PI - angle2;
32808         }
32809         if (angle2 > maxAngle + epsilonAngle) {
32810           return false;
32811         }
32812       }
32813       return "already_circular";
32814     };
32815     action.transitionable = true;
32816     return action;
32817   }
32818
32819   // modules/actions/delete_way.js
32820   function actionDeleteWay(wayID) {
32821     function canDeleteNode(node, graph) {
32822       if (graph.parentWays(node).length || graph.parentRelations(node).length)
32823         return false;
32824       var geometries = osmNodeGeometriesForTags(node.tags);
32825       if (geometries.point)
32826         return false;
32827       if (geometries.vertex)
32828         return true;
32829       return !node.hasInterestingTags();
32830     }
32831     var action = function(graph) {
32832       var way = graph.entity(wayID);
32833       graph.parentRelations(way).forEach(function(parent) {
32834         parent = parent.removeMembersWithID(wayID);
32835         graph = graph.replace(parent);
32836         if (parent.isDegenerate()) {
32837           graph = actionDeleteRelation(parent.id)(graph);
32838         }
32839       });
32840       new Set(way.nodes).forEach(function(nodeID) {
32841         graph = graph.replace(way.removeNode(nodeID));
32842         var node = graph.entity(nodeID);
32843         if (canDeleteNode(node, graph)) {
32844           graph = graph.remove(node);
32845         }
32846       });
32847       return graph.remove(way);
32848     };
32849     return action;
32850   }
32851
32852   // modules/actions/delete_multiple.js
32853   function actionDeleteMultiple(ids) {
32854     var actions = {
32855       way: actionDeleteWay,
32856       node: actionDeleteNode,
32857       relation: actionDeleteRelation
32858     };
32859     var action = function(graph) {
32860       ids.forEach(function(id2) {
32861         if (graph.hasEntity(id2)) {
32862           graph = actions[graph.entity(id2).type](id2)(graph);
32863         }
32864       });
32865       return graph;
32866     };
32867     return action;
32868   }
32869
32870   // modules/actions/delete_relation.js
32871   function actionDeleteRelation(relationID, allowUntaggedMembers) {
32872     function canDeleteEntity(entity, graph) {
32873       return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && (!entity.hasInterestingTags() && !allowUntaggedMembers);
32874     }
32875     var action = function(graph) {
32876       var relation = graph.entity(relationID);
32877       graph.parentRelations(relation).forEach(function(parent) {
32878         parent = parent.removeMembersWithID(relationID);
32879         graph = graph.replace(parent);
32880         if (parent.isDegenerate()) {
32881           graph = actionDeleteRelation(parent.id)(graph);
32882         }
32883       });
32884       var memberIDs = utilArrayUniq(relation.members.map(function(m2) {
32885         return m2.id;
32886       }));
32887       memberIDs.forEach(function(memberID) {
32888         graph = graph.replace(relation.removeMembersWithID(memberID));
32889         var entity = graph.entity(memberID);
32890         if (canDeleteEntity(entity, graph)) {
32891           graph = actionDeleteMultiple([memberID])(graph);
32892         }
32893       });
32894       return graph.remove(relation);
32895     };
32896     return action;
32897   }
32898
32899   // modules/actions/delete_node.js
32900   function actionDeleteNode(nodeId) {
32901     var action = function(graph) {
32902       var node = graph.entity(nodeId);
32903       graph.parentWays(node).forEach(function(parent) {
32904         parent = parent.removeNode(nodeId);
32905         graph = graph.replace(parent);
32906         if (parent.isDegenerate()) {
32907           graph = actionDeleteWay(parent.id)(graph);
32908         }
32909       });
32910       graph.parentRelations(node).forEach(function(parent) {
32911         parent = parent.removeMembersWithID(nodeId);
32912         graph = graph.replace(parent);
32913         if (parent.isDegenerate()) {
32914           graph = actionDeleteRelation(parent.id)(graph);
32915         }
32916       });
32917       return graph.remove(node);
32918     };
32919     return action;
32920   }
32921
32922   // modules/actions/connect.js
32923   function actionConnect(nodeIDs) {
32924     var action = function(graph) {
32925       var survivor;
32926       var node;
32927       var parents;
32928       var i3, j2;
32929       nodeIDs.reverse();
32930       var interestingIDs = [];
32931       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32932         node = graph.entity(nodeIDs[i3]);
32933         if (node.hasInterestingTags()) {
32934           if (!node.isNew()) {
32935             interestingIDs.push(node.id);
32936           }
32937         }
32938       }
32939       survivor = graph.entity(utilOldestID(interestingIDs.length > 0 ? interestingIDs : nodeIDs));
32940       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32941         node = graph.entity(nodeIDs[i3]);
32942         if (node.id === survivor.id)
32943           continue;
32944         parents = graph.parentWays(node);
32945         for (j2 = 0; j2 < parents.length; j2++) {
32946           graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id));
32947         }
32948         parents = graph.parentRelations(node);
32949         for (j2 = 0; j2 < parents.length; j2++) {
32950           graph = graph.replace(parents[j2].replaceMember(node, survivor));
32951         }
32952         survivor = survivor.mergeTags(node.tags);
32953         graph = actionDeleteNode(node.id)(graph);
32954       }
32955       graph = graph.replace(survivor);
32956       parents = graph.parentWays(survivor);
32957       for (i3 = 0; i3 < parents.length; i3++) {
32958         if (parents[i3].isDegenerate()) {
32959           graph = actionDeleteWay(parents[i3].id)(graph);
32960         }
32961       }
32962       return graph;
32963     };
32964     action.disabled = function(graph) {
32965       var seen = {};
32966       var restrictionIDs = [];
32967       var survivor;
32968       var node, way;
32969       var relations, relation, role;
32970       var i3, j2, k2;
32971       survivor = graph.entity(utilOldestID(nodeIDs));
32972       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32973         node = graph.entity(nodeIDs[i3]);
32974         relations = graph.parentRelations(node);
32975         for (j2 = 0; j2 < relations.length; j2++) {
32976           relation = relations[j2];
32977           role = relation.memberById(node.id).role || "";
32978           if (relation.hasFromViaTo()) {
32979             restrictionIDs.push(relation.id);
32980           }
32981           if (seen[relation.id] !== void 0 && seen[relation.id] !== role) {
32982             return "relation";
32983           } else {
32984             seen[relation.id] = role;
32985           }
32986         }
32987       }
32988       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32989         node = graph.entity(nodeIDs[i3]);
32990         var parents = graph.parentWays(node);
32991         for (j2 = 0; j2 < parents.length; j2++) {
32992           var parent = parents[j2];
32993           relations = graph.parentRelations(parent);
32994           for (k2 = 0; k2 < relations.length; k2++) {
32995             relation = relations[k2];
32996             if (relation.hasFromViaTo()) {
32997               restrictionIDs.push(relation.id);
32998             }
32999           }
33000         }
33001       }
33002       restrictionIDs = utilArrayUniq(restrictionIDs);
33003       for (i3 = 0; i3 < restrictionIDs.length; i3++) {
33004         relation = graph.entity(restrictionIDs[i3]);
33005         if (!relation.isComplete(graph))
33006           continue;
33007         var memberWays = relation.members.filter(function(m2) {
33008           return m2.type === "way";
33009         }).map(function(m2) {
33010           return graph.entity(m2.id);
33011         });
33012         memberWays = utilArrayUniq(memberWays);
33013         var f2 = relation.memberByRole("from");
33014         var t2 = relation.memberByRole("to");
33015         var isUturn = f2.id === t2.id;
33016         var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] };
33017         for (j2 = 0; j2 < relation.members.length; j2++) {
33018           collectNodes(relation.members[j2], nodes);
33019         }
33020         nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates));
33021         nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates));
33022         var filter2 = keyNodeFilter(nodes.keyfrom, nodes.keyto);
33023         nodes.from = nodes.from.filter(filter2);
33024         nodes.via = nodes.via.filter(filter2);
33025         nodes.to = nodes.to.filter(filter2);
33026         var connectFrom = false;
33027         var connectVia = false;
33028         var connectTo = false;
33029         var connectKeyFrom = false;
33030         var connectKeyTo = false;
33031         for (j2 = 0; j2 < nodeIDs.length; j2++) {
33032           var n3 = nodeIDs[j2];
33033           if (nodes.from.indexOf(n3) !== -1) {
33034             connectFrom = true;
33035           }
33036           if (nodes.via.indexOf(n3) !== -1) {
33037             connectVia = true;
33038           }
33039           if (nodes.to.indexOf(n3) !== -1) {
33040             connectTo = true;
33041           }
33042           if (nodes.keyfrom.indexOf(n3) !== -1) {
33043             connectKeyFrom = true;
33044           }
33045           if (nodes.keyto.indexOf(n3) !== -1) {
33046             connectKeyTo = true;
33047           }
33048         }
33049         if (connectFrom && connectTo && !isUturn) {
33050           return "restriction";
33051         }
33052         if (connectFrom && connectVia) {
33053           return "restriction";
33054         }
33055         if (connectTo && connectVia) {
33056           return "restriction";
33057         }
33058         if (connectKeyFrom || connectKeyTo) {
33059           if (nodeIDs.length !== 2) {
33060             return "restriction";
33061           }
33062           var n0 = null;
33063           var n1 = null;
33064           for (j2 = 0; j2 < memberWays.length; j2++) {
33065             way = memberWays[j2];
33066             if (way.contains(nodeIDs[0])) {
33067               n0 = nodeIDs[0];
33068             }
33069             if (way.contains(nodeIDs[1])) {
33070               n1 = nodeIDs[1];
33071             }
33072           }
33073           if (n0 && n1) {
33074             var ok = false;
33075             for (j2 = 0; j2 < memberWays.length; j2++) {
33076               way = memberWays[j2];
33077               if (way.areAdjacent(n0, n1)) {
33078                 ok = true;
33079                 break;
33080               }
33081             }
33082             if (!ok) {
33083               return "restriction";
33084             }
33085           }
33086         }
33087         for (j2 = 0; j2 < memberWays.length; j2++) {
33088           way = memberWays[j2].update({});
33089           for (k2 = 0; k2 < nodeIDs.length; k2++) {
33090             if (nodeIDs[k2] === survivor.id)
33091               continue;
33092             if (way.areAdjacent(nodeIDs[k2], survivor.id)) {
33093               way = way.removeNode(nodeIDs[k2]);
33094             } else {
33095               way = way.replaceNode(nodeIDs[k2], survivor.id);
33096             }
33097           }
33098           if (way.isDegenerate()) {
33099             return "restriction";
33100           }
33101         }
33102       }
33103       return false;
33104       function hasDuplicates(n4, i4, arr) {
33105         return arr.indexOf(n4) !== arr.lastIndexOf(n4);
33106       }
33107       function keyNodeFilter(froms, tos) {
33108         return function(n4) {
33109           return froms.indexOf(n4) === -1 && tos.indexOf(n4) === -1;
33110         };
33111       }
33112       function collectNodes(member, collection) {
33113         var entity = graph.hasEntity(member.id);
33114         if (!entity)
33115           return;
33116         var role2 = member.role || "";
33117         if (!collection[role2]) {
33118           collection[role2] = [];
33119         }
33120         if (member.type === "node") {
33121           collection[role2].push(member.id);
33122           if (role2 === "via") {
33123             collection.keyfrom.push(member.id);
33124             collection.keyto.push(member.id);
33125           }
33126         } else if (member.type === "way") {
33127           collection[role2].push.apply(collection[role2], entity.nodes);
33128           if (role2 === "from" || role2 === "via") {
33129             collection.keyfrom.push(entity.first());
33130             collection.keyfrom.push(entity.last());
33131           }
33132           if (role2 === "to" || role2 === "via") {
33133             collection.keyto.push(entity.first());
33134             collection.keyto.push(entity.last());
33135           }
33136         }
33137       }
33138     };
33139     return action;
33140   }
33141
33142   // modules/actions/copy_entities.js
33143   function actionCopyEntities(ids, fromGraph) {
33144     var _copies = {};
33145     var action = function(graph) {
33146       ids.forEach(function(id3) {
33147         fromGraph.entity(id3).copy(fromGraph, _copies);
33148       });
33149       for (var id2 in _copies) {
33150         graph = graph.replace(_copies[id2]);
33151       }
33152       return graph;
33153     };
33154     action.copies = function() {
33155       return _copies;
33156     };
33157     return action;
33158   }
33159
33160   // modules/actions/delete_member.js
33161   function actionDeleteMember(relationId, memberIndex) {
33162     return function(graph) {
33163       var relation = graph.entity(relationId).removeMember(memberIndex);
33164       graph = graph.replace(relation);
33165       if (relation.isDegenerate()) {
33166         graph = actionDeleteRelation(relation.id)(graph);
33167       }
33168       return graph;
33169     };
33170   }
33171
33172   // modules/actions/discard_tags.js
33173   function actionDiscardTags(difference2, discardTags) {
33174     discardTags = discardTags || {};
33175     return (graph) => {
33176       difference2.modified().forEach(checkTags);
33177       difference2.created().forEach(checkTags);
33178       return graph;
33179       function checkTags(entity) {
33180         const keys2 = Object.keys(entity.tags);
33181         let didDiscard = false;
33182         let tags = {};
33183         for (let i3 = 0; i3 < keys2.length; i3++) {
33184           const k2 = keys2[i3];
33185           if (discardTags[k2] || !entity.tags[k2]) {
33186             didDiscard = true;
33187           } else {
33188             tags[k2] = entity.tags[k2];
33189           }
33190         }
33191         if (didDiscard) {
33192           graph = graph.replace(entity.update({ tags }));
33193         }
33194       }
33195     };
33196   }
33197
33198   // modules/actions/disconnect.js
33199   function actionDisconnect(nodeId, newNodeId) {
33200     var wayIds;
33201     var disconnectableRelationTypes = {
33202       "associatedStreet": true,
33203       "enforcement": true,
33204       "site": true
33205     };
33206     var action = function(graph) {
33207       var node = graph.entity(nodeId);
33208       var connections = action.connections(graph);
33209       connections.forEach(function(connection) {
33210         var way = graph.entity(connection.wayID);
33211         var newNode = osmNode({ id: newNodeId, loc: node.loc, tags: node.tags });
33212         graph = graph.replace(newNode);
33213         if (connection.index === 0 && way.isArea()) {
33214           graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
33215         } else if (way.isClosed() && connection.index === way.nodes.length - 1) {
33216           graph = graph.replace(way.unclose().addNode(newNode.id));
33217         } else {
33218           graph = graph.replace(way.updateNode(newNode.id, connection.index));
33219         }
33220       });
33221       return graph;
33222     };
33223     action.connections = function(graph) {
33224       var candidates = [];
33225       var keeping = false;
33226       var parentWays = graph.parentWays(graph.entity(nodeId));
33227       var way, waynode;
33228       for (var i3 = 0; i3 < parentWays.length; i3++) {
33229         way = parentWays[i3];
33230         if (wayIds && wayIds.indexOf(way.id) === -1) {
33231           keeping = true;
33232           continue;
33233         }
33234         if (way.isArea() && way.nodes[0] === nodeId) {
33235           candidates.push({ wayID: way.id, index: 0 });
33236         } else {
33237           for (var j2 = 0; j2 < way.nodes.length; j2++) {
33238             waynode = way.nodes[j2];
33239             if (waynode === nodeId) {
33240               if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) {
33241                 continue;
33242               }
33243               candidates.push({ wayID: way.id, index: j2 });
33244             }
33245           }
33246         }
33247       }
33248       return keeping ? candidates : candidates.slice(1);
33249     };
33250     action.disabled = function(graph) {
33251       var connections = action.connections(graph);
33252       if (connections.length === 0)
33253         return "not_connected";
33254       var parentWays = graph.parentWays(graph.entity(nodeId));
33255       var seenRelationIds = {};
33256       var sharedRelation;
33257       parentWays.forEach(function(way) {
33258         var relations = graph.parentRelations(way);
33259         relations.filter((relation) => !disconnectableRelationTypes[relation.tags.type]).forEach(function(relation) {
33260           if (relation.id in seenRelationIds) {
33261             if (wayIds) {
33262               if (wayIds.indexOf(way.id) !== -1 || wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
33263                 sharedRelation = relation;
33264               }
33265             } else {
33266               sharedRelation = relation;
33267             }
33268           } else {
33269             seenRelationIds[relation.id] = way.id;
33270           }
33271         });
33272       });
33273       if (sharedRelation)
33274         return "relation";
33275     };
33276     action.limitWays = function(val) {
33277       if (!arguments.length)
33278         return wayIds;
33279       wayIds = val;
33280       return action;
33281     };
33282     return action;
33283   }
33284
33285   // modules/actions/extract.js
33286   function actionExtract(entityID, projection2) {
33287     var extractedNodeID;
33288     var action = function(graph) {
33289       var entity = graph.entity(entityID);
33290       if (entity.type === "node") {
33291         return extractFromNode(entity, graph);
33292       }
33293       return extractFromWayOrRelation(entity, graph);
33294     };
33295     function extractFromNode(node, graph) {
33296       extractedNodeID = node.id;
33297       var replacement = osmNode({ loc: node.loc });
33298       graph = graph.replace(replacement);
33299       graph = graph.parentWays(node).reduce(function(accGraph, parentWay) {
33300         return accGraph.replace(parentWay.replaceNode(entityID, replacement.id));
33301       }, graph);
33302       return graph.parentRelations(node).reduce(function(accGraph, parentRel) {
33303         return accGraph.replace(parentRel.replaceMember(node, replacement));
33304       }, graph);
33305     }
33306     function extractFromWayOrRelation(entity, graph) {
33307       var fromGeometry = entity.geometry(graph);
33308       var keysToCopyAndRetain = ["source", "wheelchair"];
33309       var keysToRetain = ["area"];
33310       var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"];
33311       var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph));
33312       extractedLoc = extractedLoc && projection2.invert(extractedLoc);
33313       if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
33314         extractedLoc = entity.extent(graph).center();
33315       }
33316       var indoorAreaValues = {
33317         area: true,
33318         corridor: true,
33319         elevator: true,
33320         level: true,
33321         room: true
33322       };
33323       var isBuilding = entity.tags.building && entity.tags.building !== "no" || entity.tags["building:part"] && entity.tags["building:part"] !== "no";
33324       var isIndoorArea = fromGeometry === "area" && entity.tags.indoor && indoorAreaValues[entity.tags.indoor];
33325       var entityTags = Object.assign({}, entity.tags);
33326       var pointTags = {};
33327       for (var key in entityTags) {
33328         if (entity.type === "relation" && key === "type") {
33329           continue;
33330         }
33331         if (keysToRetain.indexOf(key) !== -1) {
33332           continue;
33333         }
33334         if (isBuilding) {
33335           if (buildingKeysToRetain.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
33336             continue;
33337         }
33338         if (isIndoorArea && key === "indoor") {
33339           continue;
33340         }
33341         pointTags[key] = entityTags[key];
33342         if (keysToCopyAndRetain.indexOf(key) !== -1 || key.match(/^addr:.{1,}/)) {
33343           continue;
33344         } else if (isIndoorArea && key === "level") {
33345           continue;
33346         }
33347         delete entityTags[key];
33348       }
33349       if (!isBuilding && !isIndoorArea && fromGeometry === "area") {
33350         entityTags.area = "yes";
33351       }
33352       var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
33353       graph = graph.replace(replacement);
33354       extractedNodeID = replacement.id;
33355       return graph.replace(entity.update({ tags: entityTags }));
33356     }
33357     action.getExtractedNodeID = function() {
33358       return extractedNodeID;
33359     };
33360     return action;
33361   }
33362
33363   // modules/actions/join.js
33364   function actionJoin(ids) {
33365     function groupEntitiesByGeometry(graph) {
33366       var entities = ids.map(function(id2) {
33367         return graph.entity(id2);
33368       });
33369       return Object.assign(
33370         { line: [] },
33371         utilArrayGroupBy(entities, function(entity) {
33372           return entity.geometry(graph);
33373         })
33374       );
33375     }
33376     var action = function(graph) {
33377       var ways = ids.map(graph.entity, graph);
33378       var survivorID = utilOldestID(ways.map((way) => way.id));
33379       ways.sort(function(a2, b2) {
33380         var aSided = a2.isSided();
33381         var bSided = b2.isSided();
33382         return aSided && !bSided ? -1 : bSided && !aSided ? 1 : 0;
33383       });
33384       var sequences = osmJoinWays(ways, graph);
33385       var joined = sequences[0];
33386       graph = sequences.actions.reduce(function(g3, action2) {
33387         return action2(g3);
33388       }, graph);
33389       var survivor = graph.entity(survivorID);
33390       survivor = survivor.update({ nodes: joined.nodes.map(function(n3) {
33391         return n3.id;
33392       }) });
33393       graph = graph.replace(survivor);
33394       joined.forEach(function(way) {
33395         if (way.id === survivorID)
33396           return;
33397         graph.parentRelations(way).forEach(function(parent) {
33398           graph = graph.replace(parent.replaceMember(way, survivor));
33399         });
33400         survivor = survivor.mergeTags(way.tags);
33401         graph = graph.replace(survivor);
33402         graph = actionDeleteWay(way.id)(graph);
33403       });
33404       function checkForSimpleMultipolygon() {
33405         if (!survivor.isClosed())
33406           return;
33407         var multipolygons = graph.parentMultipolygons(survivor).filter(function(multipolygon2) {
33408           return multipolygon2.members.length === 1;
33409         });
33410         if (multipolygons.length !== 1)
33411           return;
33412         var multipolygon = multipolygons[0];
33413         for (var key in survivor.tags) {
33414           if (multipolygon.tags[key] && // don't collapse if tags cannot be cleanly merged
33415           multipolygon.tags[key] !== survivor.tags[key])
33416             return;
33417         }
33418         survivor = survivor.mergeTags(multipolygon.tags);
33419         graph = graph.replace(survivor);
33420         graph = actionDeleteRelation(
33421           multipolygon.id,
33422           true
33423           /* allow untagged members */
33424         )(graph);
33425         var tags = Object.assign({}, survivor.tags);
33426         if (survivor.geometry(graph) !== "area") {
33427           tags.area = "yes";
33428         }
33429         delete tags.type;
33430         survivor = survivor.update({ tags });
33431         graph = graph.replace(survivor);
33432       }
33433       checkForSimpleMultipolygon();
33434       return graph;
33435     };
33436     action.resultingWayNodesLength = function(graph) {
33437       return ids.reduce(function(count, id2) {
33438         return count + graph.entity(id2).nodes.length;
33439       }, 0) - ids.length - 1;
33440     };
33441     action.disabled = function(graph) {
33442       var geometries = groupEntitiesByGeometry(graph);
33443       if (ids.length < 2 || ids.length !== geometries.line.length) {
33444         return "not_eligible";
33445       }
33446       var joined = osmJoinWays(ids.map(graph.entity, graph), graph);
33447       if (joined.length > 1) {
33448         return "not_adjacent";
33449       }
33450       var i3;
33451       var sortedParentRelations = function(id2) {
33452         return graph.parentRelations(graph.entity(id2)).filter((rel) => !rel.isRestriction() && !rel.isConnectivity()).sort((a2, b2) => a2.id - b2.id);
33453       };
33454       var relsA = sortedParentRelations(ids[0]);
33455       for (i3 = 1; i3 < ids.length; i3++) {
33456         var relsB = sortedParentRelations(ids[i3]);
33457         if (!utilArrayIdentical(relsA, relsB)) {
33458           return "conflicting_relations";
33459         }
33460       }
33461       for (i3 = 0; i3 < ids.length - 1; i3++) {
33462         for (var j2 = i3 + 1; j2 < ids.length; j2++) {
33463           var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) {
33464             return e3.loc;
33465           });
33466           var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) {
33467             return e3.loc;
33468           });
33469           var intersections = geoPathIntersections(path1, path2);
33470           var common = utilArrayIntersection(
33471             joined[0].nodes.map(function(n3) {
33472               return n3.loc.toString();
33473             }),
33474             intersections.map(function(n3) {
33475               return n3.toString();
33476             })
33477           );
33478           if (common.length !== intersections.length) {
33479             return "paths_intersect";
33480           }
33481         }
33482       }
33483       var nodeIds = joined[0].nodes.map(function(n3) {
33484         return n3.id;
33485       }).slice(1, -1);
33486       var relation;
33487       var tags = {};
33488       var conflicting = false;
33489       joined[0].forEach(function(way) {
33490         var parents = graph.parentRelations(way);
33491         parents.forEach(function(parent) {
33492           if ((parent.isRestriction() || parent.isConnectivity()) && parent.members.some(function(m2) {
33493             return nodeIds.indexOf(m2.id) >= 0;
33494           })) {
33495             relation = parent;
33496           }
33497         });
33498         for (var k2 in way.tags) {
33499           if (!(k2 in tags)) {
33500             tags[k2] = way.tags[k2];
33501           } else if (tags[k2] && osmIsInterestingTag(k2) && tags[k2] !== way.tags[k2]) {
33502             conflicting = true;
33503           }
33504         }
33505       });
33506       if (relation) {
33507         return relation.isRestriction() ? "restriction" : "connectivity";
33508       }
33509       if (conflicting) {
33510         return "conflicting_tags";
33511       }
33512     };
33513     return action;
33514   }
33515
33516   // modules/actions/merge.js
33517   function actionMerge(ids) {
33518     function groupEntitiesByGeometry(graph) {
33519       var entities = ids.map(function(id2) {
33520         return graph.entity(id2);
33521       });
33522       return Object.assign(
33523         { point: [], area: [], line: [], relation: [] },
33524         utilArrayGroupBy(entities, function(entity) {
33525           return entity.geometry(graph);
33526         })
33527       );
33528     }
33529     var action = function(graph) {
33530       var geometries = groupEntitiesByGeometry(graph);
33531       var target = geometries.area[0] || geometries.line[0];
33532       var points = geometries.point;
33533       points.forEach(function(point2) {
33534         target = target.mergeTags(point2.tags);
33535         graph = graph.replace(target);
33536         graph.parentRelations(point2).forEach(function(parent) {
33537           graph = graph.replace(parent.replaceMember(point2, target));
33538         });
33539         var nodes = utilArrayUniq(graph.childNodes(target));
33540         var removeNode = point2;
33541         if (!point2.isNew()) {
33542           var inserted = false;
33543           var canBeReplaced = function(node2) {
33544             return !(graph.parentWays(node2).length > 1 || graph.parentRelations(node2).length);
33545           };
33546           var replaceNode = function(node2) {
33547             graph = graph.replace(point2.update({ tags: node2.tags, loc: node2.loc }));
33548             target = target.replaceNode(node2.id, point2.id);
33549             graph = graph.replace(target);
33550             removeNode = node2;
33551             inserted = true;
33552           };
33553           var i3;
33554           var node;
33555           for (i3 = 0; i3 < nodes.length; i3++) {
33556             node = nodes[i3];
33557             if (canBeReplaced(node) && node.isNew()) {
33558               replaceNode(node);
33559               break;
33560             }
33561           }
33562           if (!inserted && point2.hasInterestingTags()) {
33563             for (i3 = 0; i3 < nodes.length; i3++) {
33564               node = nodes[i3];
33565               if (canBeReplaced(node) && !node.hasInterestingTags()) {
33566                 replaceNode(node);
33567                 break;
33568               }
33569             }
33570             if (!inserted) {
33571               for (i3 = 0; i3 < nodes.length; i3++) {
33572                 node = nodes[i3];
33573                 if (canBeReplaced(node) && utilCompareIDs(point2.id, node.id) < 0) {
33574                   replaceNode(node);
33575                   break;
33576                 }
33577               }
33578             }
33579           }
33580         }
33581         graph = graph.remove(removeNode);
33582       });
33583       if (target.tags.area === "yes") {
33584         var tags = Object.assign({}, target.tags);
33585         delete tags.area;
33586         if (osmTagSuggestingArea(tags)) {
33587           target = target.update({ tags });
33588           graph = graph.replace(target);
33589         }
33590       }
33591       return graph;
33592     };
33593     action.disabled = function(graph) {
33594       var geometries = groupEntitiesByGeometry(graph);
33595       if (geometries.point.length === 0 || geometries.area.length + geometries.line.length !== 1 || geometries.relation.length !== 0) {
33596         return "not_eligible";
33597       }
33598     };
33599     return action;
33600   }
33601
33602   // modules/actions/merge_nodes.js
33603   function actionMergeNodes(nodeIDs, loc) {
33604     function chooseLoc(graph) {
33605       if (!nodeIDs.length)
33606         return null;
33607       var sum = [0, 0];
33608       var interestingCount = 0;
33609       var interestingLoc;
33610       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33611         var node = graph.entity(nodeIDs[i3]);
33612         if (node.hasInterestingTags()) {
33613           interestingLoc = ++interestingCount === 1 ? node.loc : null;
33614         }
33615         sum = geoVecAdd(sum, node.loc);
33616       }
33617       return interestingLoc || geoVecScale(sum, 1 / nodeIDs.length);
33618     }
33619     var action = function(graph) {
33620       if (nodeIDs.length < 2)
33621         return graph;
33622       var toLoc = loc;
33623       if (!toLoc) {
33624         toLoc = chooseLoc(graph);
33625       }
33626       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33627         var node = graph.entity(nodeIDs[i3]);
33628         if (node.loc !== toLoc) {
33629           graph = graph.replace(node.move(toLoc));
33630         }
33631       }
33632       return actionConnect(nodeIDs)(graph);
33633     };
33634     action.disabled = function(graph) {
33635       if (nodeIDs.length < 2)
33636         return "not_eligible";
33637       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33638         var entity = graph.entity(nodeIDs[i3]);
33639         if (entity.type !== "node")
33640           return "not_eligible";
33641       }
33642       return actionConnect(nodeIDs).disabled(graph);
33643     };
33644     return action;
33645   }
33646
33647   // modules/osm/changeset.js
33648   function osmChangeset() {
33649     if (!(this instanceof osmChangeset)) {
33650       return new osmChangeset().initialize(arguments);
33651     } else if (arguments.length) {
33652       this.initialize(arguments);
33653     }
33654   }
33655   osmEntity.changeset = osmChangeset;
33656   osmChangeset.prototype = Object.create(osmEntity.prototype);
33657   Object.assign(osmChangeset.prototype, {
33658     type: "changeset",
33659     extent: function() {
33660       return new geoExtent();
33661     },
33662     geometry: function() {
33663       return "changeset";
33664     },
33665     asJXON: function() {
33666       return {
33667         osm: {
33668           changeset: {
33669             tag: Object.keys(this.tags).map(function(k2) {
33670               return { "@k": k2, "@v": this.tags[k2] };
33671             }, this),
33672             "@version": 0.6,
33673             "@generator": "iD"
33674           }
33675         }
33676       };
33677     },
33678     // Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
33679     // XML. Returns a string.
33680     osmChangeJXON: function(changes) {
33681       var changeset_id = this.id;
33682       function nest(x2, order) {
33683         var groups = {};
33684         for (var i3 = 0; i3 < x2.length; i3++) {
33685           var tagName = Object.keys(x2[i3])[0];
33686           if (!groups[tagName])
33687             groups[tagName] = [];
33688           groups[tagName].push(x2[i3][tagName]);
33689         }
33690         var ordered = {};
33691         order.forEach(function(o2) {
33692           if (groups[o2])
33693             ordered[o2] = groups[o2];
33694         });
33695         return ordered;
33696       }
33697       function sort(changes2) {
33698         function resolve(item) {
33699           return relations.find(function(relation2) {
33700             return item.keyAttributes.type === "relation" && item.keyAttributes.ref === relation2["@id"];
33701           });
33702         }
33703         function isNew(item) {
33704           return !sorted[item["@id"]] && !processing.find(function(proc) {
33705             return proc["@id"] === item["@id"];
33706           });
33707         }
33708         var processing = [];
33709         var sorted = {};
33710         var relations = changes2.relation;
33711         if (!relations)
33712           return changes2;
33713         for (var i3 = 0; i3 < relations.length; i3++) {
33714           var relation = relations[i3];
33715           if (!sorted[relation["@id"]]) {
33716             processing.push(relation);
33717           }
33718           while (processing.length > 0) {
33719             var next = processing[0], deps = next.member.map(resolve).filter(Boolean).filter(isNew);
33720             if (deps.length === 0) {
33721               sorted[next["@id"]] = next;
33722               processing.shift();
33723             } else {
33724               processing = deps.concat(processing);
33725             }
33726           }
33727         }
33728         changes2.relation = Object.values(sorted);
33729         return changes2;
33730       }
33731       function rep(entity) {
33732         return entity.asJXON(changeset_id);
33733       }
33734       return {
33735         osmChange: {
33736           "@version": 0.6,
33737           "@generator": "iD",
33738           "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])),
33739           "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]),
33740           "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true })
33741         }
33742       };
33743     },
33744     asGeoJSON: function() {
33745       return {};
33746     }
33747   });
33748
33749   // modules/osm/note.js
33750   function osmNote() {
33751     if (!(this instanceof osmNote)) {
33752       return new osmNote().initialize(arguments);
33753     } else if (arguments.length) {
33754       this.initialize(arguments);
33755     }
33756   }
33757   osmNote.id = function() {
33758     return osmNote.id.next--;
33759   };
33760   osmNote.id.next = -1;
33761   Object.assign(osmNote.prototype, {
33762     type: "note",
33763     initialize: function(sources) {
33764       for (var i3 = 0; i3 < sources.length; ++i3) {
33765         var source = sources[i3];
33766         for (var prop in source) {
33767           if (Object.prototype.hasOwnProperty.call(source, prop)) {
33768             if (source[prop] === void 0) {
33769               delete this[prop];
33770             } else {
33771               this[prop] = source[prop];
33772             }
33773           }
33774         }
33775       }
33776       if (!this.id) {
33777         this.id = osmNote.id().toString();
33778       }
33779       return this;
33780     },
33781     extent: function() {
33782       return new geoExtent(this.loc);
33783     },
33784     update: function(attrs) {
33785       return osmNote(this, attrs);
33786     },
33787     isNew: function() {
33788       return this.id < 0;
33789     },
33790     move: function(loc) {
33791       return this.update({ loc });
33792     }
33793   });
33794
33795   // modules/osm/relation.js
33796   function osmRelation() {
33797     if (!(this instanceof osmRelation)) {
33798       return new osmRelation().initialize(arguments);
33799     } else if (arguments.length) {
33800       this.initialize(arguments);
33801     }
33802   }
33803   osmEntity.relation = osmRelation;
33804   osmRelation.prototype = Object.create(osmEntity.prototype);
33805   osmRelation.creationOrder = function(a2, b2) {
33806     var aId = parseInt(osmEntity.id.toOSM(a2.id), 10);
33807     var bId = parseInt(osmEntity.id.toOSM(b2.id), 10);
33808     if (aId < 0 || bId < 0)
33809       return aId - bId;
33810     return bId - aId;
33811   };
33812   Object.assign(osmRelation.prototype, {
33813     type: "relation",
33814     members: [],
33815     copy: function(resolver, copies) {
33816       if (copies[this.id])
33817         return copies[this.id];
33818       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
33819       var members = this.members.map(function(member) {
33820         return Object.assign({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
33821       });
33822       copy2 = copy2.update({ members });
33823       copies[this.id] = copy2;
33824       return copy2;
33825     },
33826     extent: function(resolver, memo) {
33827       return resolver.transient(this, "extent", function() {
33828         if (memo && memo[this.id])
33829           return geoExtent();
33830         memo = memo || {};
33831         memo[this.id] = true;
33832         var extent = geoExtent();
33833         for (var i3 = 0; i3 < this.members.length; i3++) {
33834           var member = resolver.hasEntity(this.members[i3].id);
33835           if (member) {
33836             extent._extend(member.extent(resolver, memo));
33837           }
33838         }
33839         return extent;
33840       });
33841     },
33842     geometry: function(graph) {
33843       return graph.transient(this, "geometry", function() {
33844         return this.isMultipolygon() ? "area" : "relation";
33845       });
33846     },
33847     isDegenerate: function() {
33848       return this.members.length === 0;
33849     },
33850     // Return an array of members, each extended with an 'index' property whose value
33851     // is the member index.
33852     indexedMembers: function() {
33853       var result = new Array(this.members.length);
33854       for (var i3 = 0; i3 < this.members.length; i3++) {
33855         result[i3] = Object.assign({}, this.members[i3], { index: i3 });
33856       }
33857       return result;
33858     },
33859     // Return the first member with the given role. A copy of the member object
33860     // is returned, extended with an 'index' property whose value is the member index.
33861     memberByRole: function(role) {
33862       for (var i3 = 0; i3 < this.members.length; i3++) {
33863         if (this.members[i3].role === role) {
33864           return Object.assign({}, this.members[i3], { index: i3 });
33865         }
33866       }
33867     },
33868     // Same as memberByRole, but returns all members with the given role
33869     membersByRole: function(role) {
33870       var result = [];
33871       for (var i3 = 0; i3 < this.members.length; i3++) {
33872         if (this.members[i3].role === role) {
33873           result.push(Object.assign({}, this.members[i3], { index: i3 }));
33874         }
33875       }
33876       return result;
33877     },
33878     // Return the first member with the given id. A copy of the member object
33879     // is returned, extended with an 'index' property whose value is the member index.
33880     memberById: function(id2) {
33881       for (var i3 = 0; i3 < this.members.length; i3++) {
33882         if (this.members[i3].id === id2) {
33883           return Object.assign({}, this.members[i3], { index: i3 });
33884         }
33885       }
33886     },
33887     // Return the first member with the given id and role. A copy of the member object
33888     // is returned, extended with an 'index' property whose value is the member index.
33889     memberByIdAndRole: function(id2, role) {
33890       for (var i3 = 0; i3 < this.members.length; i3++) {
33891         if (this.members[i3].id === id2 && this.members[i3].role === role) {
33892           return Object.assign({}, this.members[i3], { index: i3 });
33893         }
33894       }
33895     },
33896     addMember: function(member, index) {
33897       var members = this.members.slice();
33898       members.splice(index === void 0 ? members.length : index, 0, member);
33899       return this.update({ members });
33900     },
33901     updateMember: function(member, index) {
33902       var members = this.members.slice();
33903       members.splice(index, 1, Object.assign({}, members[index], member));
33904       return this.update({ members });
33905     },
33906     removeMember: function(index) {
33907       var members = this.members.slice();
33908       members.splice(index, 1);
33909       return this.update({ members });
33910     },
33911     removeMembersWithID: function(id2) {
33912       var members = this.members.filter(function(m2) {
33913         return m2.id !== id2;
33914       });
33915       return this.update({ members });
33916     },
33917     moveMember: function(fromIndex, toIndex) {
33918       var members = this.members.slice();
33919       members.splice(toIndex, 0, members.splice(fromIndex, 1)[0]);
33920       return this.update({ members });
33921     },
33922     // Wherever a member appears with id `needle.id`, replace it with a member
33923     // with id `replacement.id`, type `replacement.type`, and the original role,
33924     // By default, adding a duplicate member (by id and role) is prevented.
33925     // Return an updated relation.
33926     replaceMember: function(needle, replacement, keepDuplicates) {
33927       if (!this.memberById(needle.id))
33928         return this;
33929       var members = [];
33930       for (var i3 = 0; i3 < this.members.length; i3++) {
33931         var member = this.members[i3];
33932         if (member.id !== needle.id) {
33933           members.push(member);
33934         } else if (keepDuplicates || !this.memberByIdAndRole(replacement.id, member.role)) {
33935           members.push({ id: replacement.id, type: replacement.type, role: member.role });
33936         }
33937       }
33938       return this.update({ members });
33939     },
33940     asJXON: function(changeset_id) {
33941       var r2 = {
33942         relation: {
33943           "@id": this.osmId(),
33944           "@version": this.version || 0,
33945           member: this.members.map(function(member) {
33946             return {
33947               keyAttributes: {
33948                 type: member.type,
33949                 role: member.role,
33950                 ref: osmEntity.id.toOSM(member.id)
33951               }
33952             };
33953           }, this),
33954           tag: Object.keys(this.tags).map(function(k2) {
33955             return { keyAttributes: { k: k2, v: this.tags[k2] } };
33956           }, this)
33957         }
33958       };
33959       if (changeset_id) {
33960         r2.relation["@changeset"] = changeset_id;
33961       }
33962       return r2;
33963     },
33964     asGeoJSON: function(resolver) {
33965       return resolver.transient(this, "GeoJSON", function() {
33966         if (this.isMultipolygon()) {
33967           return {
33968             type: "MultiPolygon",
33969             coordinates: this.multipolygon(resolver)
33970           };
33971         } else {
33972           return {
33973             type: "FeatureCollection",
33974             properties: this.tags,
33975             features: this.members.map(function(member) {
33976               return Object.assign({ role: member.role }, resolver.entity(member.id).asGeoJSON(resolver));
33977             })
33978           };
33979         }
33980       });
33981     },
33982     area: function(resolver) {
33983       return resolver.transient(this, "area", function() {
33984         return area_default(this.asGeoJSON(resolver));
33985       });
33986     },
33987     isMultipolygon: function() {
33988       return this.tags.type === "multipolygon";
33989     },
33990     isComplete: function(resolver) {
33991       for (var i3 = 0; i3 < this.members.length; i3++) {
33992         if (!resolver.hasEntity(this.members[i3].id)) {
33993           return false;
33994         }
33995       }
33996       return true;
33997     },
33998     hasFromViaTo: function() {
33999       return this.members.some(function(m2) {
34000         return m2.role === "from";
34001       }) && this.members.some(function(m2) {
34002         return m2.role === "via";
34003       }) && this.members.some(function(m2) {
34004         return m2.role === "to";
34005       });
34006     },
34007     isRestriction: function() {
34008       return !!(this.tags.type && this.tags.type.match(/^restriction:?/));
34009     },
34010     isValidRestriction: function() {
34011       if (!this.isRestriction())
34012         return false;
34013       var froms = this.members.filter(function(m2) {
34014         return m2.role === "from";
34015       });
34016       var vias = this.members.filter(function(m2) {
34017         return m2.role === "via";
34018       });
34019       var tos = this.members.filter(function(m2) {
34020         return m2.role === "to";
34021       });
34022       if (froms.length !== 1 && this.tags.restriction !== "no_entry")
34023         return false;
34024       if (froms.some(function(m2) {
34025         return m2.type !== "way";
34026       }))
34027         return false;
34028       if (tos.length !== 1 && this.tags.restriction !== "no_exit")
34029         return false;
34030       if (tos.some(function(m2) {
34031         return m2.type !== "way";
34032       }))
34033         return false;
34034       if (vias.length === 0)
34035         return false;
34036       if (vias.length > 1 && vias.some(function(m2) {
34037         return m2.type !== "way";
34038       }))
34039         return false;
34040       return true;
34041     },
34042     isConnectivity: function() {
34043       return !!(this.tags.type && this.tags.type.match(/^connectivity:?/));
34044     },
34045     // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm],
34046     // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings.
34047     //
34048     // This corresponds to the structure needed for rendering a multipolygon path using a
34049     // `evenodd` fill rule, as well as the structure of a GeoJSON MultiPolygon geometry.
34050     //
34051     // In the case of invalid geometries, this function will still return a result which
34052     // includes the nodes of all way members, but some Nds may be unclosed and some inner
34053     // rings not matched with the intended outer ring.
34054     //
34055     multipolygon: function(resolver) {
34056       var outers = this.members.filter(function(m2) {
34057         return "outer" === (m2.role || "outer");
34058       });
34059       var inners = this.members.filter(function(m2) {
34060         return "inner" === m2.role;
34061       });
34062       outers = osmJoinWays(outers, resolver);
34063       inners = osmJoinWays(inners, resolver);
34064       var sequenceToLineString = function(sequence) {
34065         if (sequence.nodes.length > 2 && sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
34066           sequence.nodes.push(sequence.nodes[0]);
34067         }
34068         return sequence.nodes.map(function(node) {
34069           return node.loc;
34070         });
34071       };
34072       outers = outers.map(sequenceToLineString);
34073       inners = inners.map(sequenceToLineString);
34074       var result = outers.map(function(o3) {
34075         return [area_default({ type: "Polygon", coordinates: [o3] }) > 2 * Math.PI ? o3.reverse() : o3];
34076       });
34077       function findOuter(inner2) {
34078         var o3, outer;
34079         for (o3 = 0; o3 < outers.length; o3++) {
34080           outer = outers[o3];
34081           if (geoPolygonContainsPolygon(outer, inner2)) {
34082             return o3;
34083           }
34084         }
34085         for (o3 = 0; o3 < outers.length; o3++) {
34086           outer = outers[o3];
34087           if (geoPolygonIntersectsPolygon(outer, inner2, false)) {
34088             return o3;
34089           }
34090         }
34091       }
34092       for (var i3 = 0; i3 < inners.length; i3++) {
34093         var inner = inners[i3];
34094         if (area_default({ type: "Polygon", coordinates: [inner] }) < 2 * Math.PI) {
34095           inner = inner.reverse();
34096         }
34097         var o2 = findOuter(inners[i3]);
34098         if (o2 !== void 0) {
34099           result[o2].push(inners[i3]);
34100         } else {
34101           result.push([inners[i3]]);
34102         }
34103       }
34104       return result;
34105     }
34106   });
34107
34108   // modules/osm/qa_item.js
34109   var QAItem = class _QAItem {
34110     constructor(loc, service, itemType, id2, props) {
34111       this.loc = loc;
34112       this.service = service.title;
34113       this.itemType = itemType;
34114       this.id = id2 ? id2 : "".concat(_QAItem.id());
34115       this.update(props);
34116       if (service && typeof service.getIcon === "function") {
34117         this.icon = service.getIcon(itemType);
34118       }
34119     }
34120     update(props) {
34121       const { loc, service, itemType, id: id2 } = this;
34122       Object.keys(props).forEach((prop) => this[prop] = props[prop]);
34123       this.loc = loc;
34124       this.service = service;
34125       this.itemType = itemType;
34126       this.id = id2;
34127       return this;
34128     }
34129     // Generic handling for newly created QAItems
34130     static id() {
34131       return this.nextId--;
34132     }
34133   };
34134   QAItem.nextId = -1;
34135
34136   // modules/actions/split.js
34137   function actionSplit(nodeIds, newWayIds) {
34138     if (typeof nodeIds === "string")
34139       nodeIds = [nodeIds];
34140     var _wayIDs;
34141     var _keepHistoryOn = "longest";
34142     var _createdWayIDs = [];
34143     function dist(graph, nA, nB) {
34144       var locA = graph.entity(nA).loc;
34145       var locB = graph.entity(nB).loc;
34146       var epsilon3 = 1e-6;
34147       return locA && locB ? geoSphericalDistance(locA, locB) : epsilon3;
34148     }
34149     function splitArea(nodes, idxA, graph) {
34150       var lengths = new Array(nodes.length);
34151       var length2;
34152       var i3;
34153       var best = 0;
34154       var idxB;
34155       function wrap2(index) {
34156         return utilWrap(index, nodes.length);
34157       }
34158       length2 = 0;
34159       for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) {
34160         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]);
34161         lengths[i3] = length2;
34162       }
34163       length2 = 0;
34164       for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) {
34165         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]);
34166         if (length2 < lengths[i3]) {
34167           lengths[i3] = length2;
34168         }
34169       }
34170       for (i3 = 0; i3 < nodes.length; i3++) {
34171         var cost = lengths[i3] / dist(graph, nodes[idxA], nodes[i3]);
34172         if (cost > best) {
34173           idxB = i3;
34174           best = cost;
34175         }
34176       }
34177       return idxB;
34178     }
34179     function totalLengthBetweenNodes(graph, nodes) {
34180       var totalLength = 0;
34181       for (var i3 = 0; i3 < nodes.length - 1; i3++) {
34182         totalLength += dist(graph, nodes[i3], nodes[i3 + 1]);
34183       }
34184       return totalLength;
34185     }
34186     function split(graph, nodeId, wayA, newWayId) {
34187       var wayB = osmWay({ id: newWayId, tags: wayA.tags });
34188       var origNodes = wayA.nodes.slice();
34189       var nodesA;
34190       var nodesB;
34191       var isArea = wayA.isArea();
34192       var isOuter = osmIsOldMultipolygonOuterMember(wayA, graph);
34193       if (wayA.isClosed()) {
34194         var nodes = wayA.nodes.slice(0, -1);
34195         var idxA = nodes.indexOf(nodeId);
34196         var idxB = splitArea(nodes, idxA, graph);
34197         if (idxB < idxA) {
34198           nodesA = nodes.slice(idxA).concat(nodes.slice(0, idxB + 1));
34199           nodesB = nodes.slice(idxB, idxA + 1);
34200         } else {
34201           nodesA = nodes.slice(idxA, idxB + 1);
34202           nodesB = nodes.slice(idxB).concat(nodes.slice(0, idxA + 1));
34203         }
34204       } else {
34205         var idx = wayA.nodes.indexOf(nodeId, 1);
34206         nodesA = wayA.nodes.slice(0, idx + 1);
34207         nodesB = wayA.nodes.slice(idx);
34208       }
34209       var lengthA = totalLengthBetweenNodes(graph, nodesA);
34210       var lengthB = totalLengthBetweenNodes(graph, nodesB);
34211       if (_keepHistoryOn === "longest" && lengthB > lengthA) {
34212         wayA = wayA.update({ nodes: nodesB });
34213         wayB = wayB.update({ nodes: nodesA });
34214         var temp = lengthA;
34215         lengthA = lengthB;
34216         lengthB = temp;
34217       } else {
34218         wayA = wayA.update({ nodes: nodesA });
34219         wayB = wayB.update({ nodes: nodesB });
34220       }
34221       if (wayA.tags.step_count) {
34222         var stepCount = Number(wayA.tags.step_count);
34223         if (stepCount && // ensure a number
34224         isFinite(stepCount) && // ensure positive
34225         stepCount > 0 && // ensure integer
34226         Math.round(stepCount) === stepCount) {
34227           var tagsA = Object.assign({}, wayA.tags);
34228           var tagsB = Object.assign({}, wayB.tags);
34229           var ratioA = lengthA / (lengthA + lengthB);
34230           var countA = Math.round(stepCount * ratioA);
34231           tagsA.step_count = countA.toString();
34232           tagsB.step_count = (stepCount - countA).toString();
34233           wayA = wayA.update({ tags: tagsA });
34234           wayB = wayB.update({ tags: tagsB });
34235         }
34236       }
34237       graph = graph.replace(wayA);
34238       graph = graph.replace(wayB);
34239       graph.parentRelations(wayA).forEach(function(relation) {
34240         var member;
34241         if (relation.hasFromViaTo()) {
34242           var f2 = relation.memberByRole("from");
34243           var v2 = relation.membersByRole("via");
34244           var t2 = relation.memberByRole("to");
34245           var i3;
34246           if (f2.id === wayA.id || t2.id === wayA.id) {
34247             var keepB = false;
34248             if (v2.length === 1 && v2[0].type === "node") {
34249               keepB = wayB.contains(v2[0].id);
34250             } else {
34251               for (i3 = 0; i3 < v2.length; i3++) {
34252                 if (v2[i3].type === "way") {
34253                   var wayVia = graph.hasEntity(v2[i3].id);
34254                   if (wayVia && utilArrayIntersection(wayB.nodes, wayVia.nodes).length) {
34255                     keepB = true;
34256                     break;
34257                   }
34258                 }
34259               }
34260             }
34261             if (keepB) {
34262               relation = relation.replaceMember(wayA, wayB);
34263               graph = graph.replace(relation);
34264             }
34265           } else {
34266             for (i3 = 0; i3 < v2.length; i3++) {
34267               if (v2[i3].type === "way" && v2[i3].id === wayA.id) {
34268                 member = {
34269                   id: wayB.id,
34270                   type: "way",
34271                   role: "via"
34272                 };
34273                 graph = actionAddMember(relation.id, member, v2[i3].index + 1)(graph);
34274                 break;
34275               }
34276             }
34277           }
34278         } else {
34279           if (relation === isOuter) {
34280             graph = graph.replace(relation.mergeTags(wayA.tags));
34281             graph = graph.replace(wayA.update({ tags: {} }));
34282             graph = graph.replace(wayB.update({ tags: {} }));
34283           }
34284           member = {
34285             id: wayB.id,
34286             type: "way",
34287             role: relation.memberById(wayA.id).role
34288           };
34289           var insertPair = {
34290             originalID: wayA.id,
34291             insertedID: wayB.id,
34292             nodes: origNodes
34293           };
34294           graph = actionAddMember(relation.id, member, void 0, insertPair)(graph);
34295         }
34296       });
34297       if (!isOuter && isArea) {
34298         var multipolygon = osmRelation({
34299           tags: Object.assign({}, wayA.tags, { type: "multipolygon" }),
34300           members: [
34301             { id: wayA.id, role: "outer", type: "way" },
34302             { id: wayB.id, role: "outer", type: "way" }
34303           ]
34304         });
34305         graph = graph.replace(multipolygon);
34306         graph = graph.replace(wayA.update({ tags: {} }));
34307         graph = graph.replace(wayB.update({ tags: {} }));
34308       }
34309       _createdWayIDs.push(wayB.id);
34310       return graph;
34311     }
34312     var action = function(graph) {
34313       _createdWayIDs = [];
34314       var newWayIndex = 0;
34315       for (var i3 = 0; i3 < nodeIds.length; i3++) {
34316         var nodeId = nodeIds[i3];
34317         var candidates = action.waysForNode(nodeId, graph);
34318         for (var j2 = 0; j2 < candidates.length; j2++) {
34319           graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex]);
34320           newWayIndex += 1;
34321         }
34322       }
34323       return graph;
34324     };
34325     action.getCreatedWayIDs = function() {
34326       return _createdWayIDs;
34327     };
34328     action.waysForNode = function(nodeId, graph) {
34329       var node = graph.entity(nodeId);
34330       var splittableParents = graph.parentWays(node).filter(isSplittable);
34331       if (!_wayIDs) {
34332         var hasLine = splittableParents.some(function(parent) {
34333           return parent.geometry(graph) === "line";
34334         });
34335         if (hasLine) {
34336           return splittableParents.filter(function(parent) {
34337             return parent.geometry(graph) === "line";
34338           });
34339         }
34340       }
34341       return splittableParents;
34342       function isSplittable(parent) {
34343         if (_wayIDs && _wayIDs.indexOf(parent.id) === -1)
34344           return false;
34345         if (parent.isClosed())
34346           return true;
34347         for (var i3 = 1; i3 < parent.nodes.length - 1; i3++) {
34348           if (parent.nodes[i3] === nodeId)
34349             return true;
34350         }
34351         return false;
34352       }
34353     };
34354     action.ways = function(graph) {
34355       return utilArrayUniq([].concat.apply([], nodeIds.map(function(nodeId) {
34356         return action.waysForNode(nodeId, graph);
34357       })));
34358     };
34359     action.disabled = function(graph) {
34360       for (var i3 = 0; i3 < nodeIds.length; i3++) {
34361         var nodeId = nodeIds[i3];
34362         var candidates = action.waysForNode(nodeId, graph);
34363         if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) {
34364           return "not_eligible";
34365         }
34366       }
34367     };
34368     action.limitWays = function(val) {
34369       if (!arguments.length)
34370         return _wayIDs;
34371       _wayIDs = val;
34372       return action;
34373     };
34374     action.keepHistoryOn = function(val) {
34375       if (!arguments.length)
34376         return _keepHistoryOn;
34377       _keepHistoryOn = val;
34378       return action;
34379     };
34380     return action;
34381   }
34382
34383   // modules/core/graph.js
34384   function coreGraph(other, mutable) {
34385     if (!(this instanceof coreGraph))
34386       return new coreGraph(other, mutable);
34387     if (other instanceof coreGraph) {
34388       var base = other.base();
34389       this.entities = Object.assign(Object.create(base.entities), other.entities);
34390       this._parentWays = Object.assign(Object.create(base.parentWays), other._parentWays);
34391       this._parentRels = Object.assign(Object.create(base.parentRels), other._parentRels);
34392     } else {
34393       this.entities = /* @__PURE__ */ Object.create({});
34394       this._parentWays = /* @__PURE__ */ Object.create({});
34395       this._parentRels = /* @__PURE__ */ Object.create({});
34396       this.rebase(other || [], [this]);
34397     }
34398     this.transients = {};
34399     this._childNodes = {};
34400     this.frozen = !mutable;
34401   }
34402   coreGraph.prototype = {
34403     hasEntity: function(id2) {
34404       return this.entities[id2];
34405     },
34406     entity: function(id2) {
34407       var entity = this.entities[id2];
34408       if (!entity) {
34409         entity = this.entities.__proto__[id2];
34410       }
34411       if (!entity) {
34412         throw new Error("entity " + id2 + " not found");
34413       }
34414       return entity;
34415     },
34416     geometry: function(id2) {
34417       return this.entity(id2).geometry(this);
34418     },
34419     transient: function(entity, key, fn) {
34420       var id2 = entity.id;
34421       var transients = this.transients[id2] || (this.transients[id2] = {});
34422       if (transients[key] !== void 0) {
34423         return transients[key];
34424       }
34425       transients[key] = fn.call(entity);
34426       return transients[key];
34427     },
34428     parentWays: function(entity) {
34429       var parents = this._parentWays[entity.id];
34430       var result = [];
34431       if (parents) {
34432         parents.forEach(function(id2) {
34433           result.push(this.entity(id2));
34434         }, this);
34435       }
34436       return result;
34437     },
34438     isPoi: function(entity) {
34439       var parents = this._parentWays[entity.id];
34440       return !parents || parents.size === 0;
34441     },
34442     isShared: function(entity) {
34443       var parents = this._parentWays[entity.id];
34444       return parents && parents.size > 1;
34445     },
34446     parentRelations: function(entity) {
34447       var parents = this._parentRels[entity.id];
34448       var result = [];
34449       if (parents) {
34450         parents.forEach(function(id2) {
34451           result.push(this.entity(id2));
34452         }, this);
34453       }
34454       return result;
34455     },
34456     parentMultipolygons: function(entity) {
34457       return this.parentRelations(entity).filter(function(relation) {
34458         return relation.isMultipolygon();
34459       });
34460     },
34461     childNodes: function(entity) {
34462       if (this._childNodes[entity.id])
34463         return this._childNodes[entity.id];
34464       if (!entity.nodes)
34465         return [];
34466       var nodes = [];
34467       for (var i3 = 0; i3 < entity.nodes.length; i3++) {
34468         nodes[i3] = this.entity(entity.nodes[i3]);
34469       }
34470       if (debug)
34471         Object.freeze(nodes);
34472       this._childNodes[entity.id] = nodes;
34473       return this._childNodes[entity.id];
34474     },
34475     base: function() {
34476       return {
34477         "entities": Object.getPrototypeOf(this.entities),
34478         "parentWays": Object.getPrototypeOf(this._parentWays),
34479         "parentRels": Object.getPrototypeOf(this._parentRels)
34480       };
34481     },
34482     // Unlike other graph methods, rebase mutates in place. This is because it
34483     // is used only during the history operation that merges newly downloaded
34484     // data into each state. To external consumers, it should appear as if the
34485     // graph always contained the newly downloaded data.
34486     rebase: function(entities, stack, force) {
34487       var base = this.base();
34488       var i3, j2, k2, id2;
34489       for (i3 = 0; i3 < entities.length; i3++) {
34490         var entity = entities[i3];
34491         if (!entity.visible || !force && base.entities[entity.id])
34492           continue;
34493         base.entities[entity.id] = entity;
34494         this._updateCalculated(void 0, entity, base.parentWays, base.parentRels);
34495         if (entity.type === "way") {
34496           for (j2 = 0; j2 < entity.nodes.length; j2++) {
34497             id2 = entity.nodes[j2];
34498             for (k2 = 1; k2 < stack.length; k2++) {
34499               var ents = stack[k2].entities;
34500               if (ents.hasOwnProperty(id2) && ents[id2] === void 0) {
34501                 delete ents[id2];
34502               }
34503             }
34504           }
34505         }
34506       }
34507       for (i3 = 0; i3 < stack.length; i3++) {
34508         stack[i3]._updateRebased();
34509       }
34510     },
34511     _updateRebased: function() {
34512       var base = this.base();
34513       Object.keys(this._parentWays).forEach(function(child) {
34514         if (base.parentWays[child]) {
34515           base.parentWays[child].forEach(function(id2) {
34516             if (!this.entities.hasOwnProperty(id2)) {
34517               this._parentWays[child].add(id2);
34518             }
34519           }, this);
34520         }
34521       }, this);
34522       Object.keys(this._parentRels).forEach(function(child) {
34523         if (base.parentRels[child]) {
34524           base.parentRels[child].forEach(function(id2) {
34525             if (!this.entities.hasOwnProperty(id2)) {
34526               this._parentRels[child].add(id2);
34527             }
34528           }, this);
34529         }
34530       }, this);
34531       this.transients = {};
34532     },
34533     // Updates calculated properties (parentWays, parentRels) for the specified change
34534     _updateCalculated: function(oldentity, entity, parentWays, parentRels) {
34535       parentWays = parentWays || this._parentWays;
34536       parentRels = parentRels || this._parentRels;
34537       var type2 = entity && entity.type || oldentity && oldentity.type;
34538       var removed, added, i3;
34539       if (type2 === "way") {
34540         if (oldentity && entity) {
34541           removed = utilArrayDifference(oldentity.nodes, entity.nodes);
34542           added = utilArrayDifference(entity.nodes, oldentity.nodes);
34543         } else if (oldentity) {
34544           removed = oldentity.nodes;
34545           added = [];
34546         } else if (entity) {
34547           removed = [];
34548           added = entity.nodes;
34549         }
34550         for (i3 = 0; i3 < removed.length; i3++) {
34551           parentWays[removed[i3]] = new Set(parentWays[removed[i3]]);
34552           parentWays[removed[i3]].delete(oldentity.id);
34553         }
34554         for (i3 = 0; i3 < added.length; i3++) {
34555           parentWays[added[i3]] = new Set(parentWays[added[i3]]);
34556           parentWays[added[i3]].add(entity.id);
34557         }
34558       } else if (type2 === "relation") {
34559         var oldentityMemberIDs = oldentity ? oldentity.members.map(function(m2) {
34560           return m2.id;
34561         }) : [];
34562         var entityMemberIDs = entity ? entity.members.map(function(m2) {
34563           return m2.id;
34564         }) : [];
34565         if (oldentity && entity) {
34566           removed = utilArrayDifference(oldentityMemberIDs, entityMemberIDs);
34567           added = utilArrayDifference(entityMemberIDs, oldentityMemberIDs);
34568         } else if (oldentity) {
34569           removed = oldentityMemberIDs;
34570           added = [];
34571         } else if (entity) {
34572           removed = [];
34573           added = entityMemberIDs;
34574         }
34575         for (i3 = 0; i3 < removed.length; i3++) {
34576           parentRels[removed[i3]] = new Set(parentRels[removed[i3]]);
34577           parentRels[removed[i3]].delete(oldentity.id);
34578         }
34579         for (i3 = 0; i3 < added.length; i3++) {
34580           parentRels[added[i3]] = new Set(parentRels[added[i3]]);
34581           parentRels[added[i3]].add(entity.id);
34582         }
34583       }
34584     },
34585     replace: function(entity) {
34586       if (this.entities[entity.id] === entity)
34587         return this;
34588       return this.update(function() {
34589         this._updateCalculated(this.entities[entity.id], entity);
34590         this.entities[entity.id] = entity;
34591       });
34592     },
34593     remove: function(entity) {
34594       return this.update(function() {
34595         this._updateCalculated(entity, void 0);
34596         this.entities[entity.id] = void 0;
34597       });
34598     },
34599     revert: function(id2) {
34600       var baseEntity = this.base().entities[id2];
34601       var headEntity = this.entities[id2];
34602       if (headEntity === baseEntity)
34603         return this;
34604       return this.update(function() {
34605         this._updateCalculated(headEntity, baseEntity);
34606         delete this.entities[id2];
34607       });
34608     },
34609     update: function() {
34610       var graph = this.frozen ? coreGraph(this, true) : this;
34611       for (var i3 = 0; i3 < arguments.length; i3++) {
34612         arguments[i3].call(graph, graph);
34613       }
34614       if (this.frozen)
34615         graph.frozen = true;
34616       return graph;
34617     },
34618     // Obliterates any existing entities
34619     load: function(entities) {
34620       var base = this.base();
34621       this.entities = Object.create(base.entities);
34622       for (var i3 in entities) {
34623         this.entities[i3] = entities[i3];
34624         this._updateCalculated(base.entities[i3], this.entities[i3]);
34625       }
34626       return this;
34627     }
34628   };
34629
34630   // modules/osm/intersection.js
34631   function osmTurn(turn) {
34632     if (!(this instanceof osmTurn)) {
34633       return new osmTurn(turn);
34634     }
34635     Object.assign(this, turn);
34636   }
34637   function osmIntersection(graph, startVertexId, maxDistance) {
34638     maxDistance = maxDistance || 30;
34639     var vgraph = coreGraph();
34640     var i3, j2, k2;
34641     function memberOfRestriction(entity) {
34642       return graph.parentRelations(entity).some(function(r2) {
34643         return r2.isRestriction();
34644       });
34645     }
34646     function isRoad(way2) {
34647       if (way2.isArea() || way2.isDegenerate())
34648         return false;
34649       var roads = {
34650         "motorway": true,
34651         "motorway_link": true,
34652         "trunk": true,
34653         "trunk_link": true,
34654         "primary": true,
34655         "primary_link": true,
34656         "secondary": true,
34657         "secondary_link": true,
34658         "tertiary": true,
34659         "tertiary_link": true,
34660         "residential": true,
34661         "unclassified": true,
34662         "living_street": true,
34663         "service": true,
34664         "busway": true,
34665         "road": true,
34666         "track": true
34667       };
34668       return roads[way2.tags.highway];
34669     }
34670     var startNode = graph.entity(startVertexId);
34671     var checkVertices = [startNode];
34672     var checkWays;
34673     var vertices = [];
34674     var vertexIds = [];
34675     var vertex;
34676     var ways = [];
34677     var wayIds = [];
34678     var way;
34679     var nodes = [];
34680     var node;
34681     var parents = [];
34682     var parent;
34683     var actions = [];
34684     while (checkVertices.length) {
34685       vertex = checkVertices.pop();
34686       checkWays = graph.parentWays(vertex);
34687       var hasWays = false;
34688       for (i3 = 0; i3 < checkWays.length; i3++) {
34689         way = checkWays[i3];
34690         if (!isRoad(way) && !memberOfRestriction(way))
34691           continue;
34692         ways.push(way);
34693         hasWays = true;
34694         nodes = utilArrayUniq(graph.childNodes(way));
34695         for (j2 = 0; j2 < nodes.length; j2++) {
34696           node = nodes[j2];
34697           if (node === vertex)
34698             continue;
34699           if (vertices.indexOf(node) !== -1)
34700             continue;
34701           if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance)
34702             continue;
34703           var hasParents = false;
34704           parents = graph.parentWays(node);
34705           for (k2 = 0; k2 < parents.length; k2++) {
34706             parent = parents[k2];
34707             if (parent === way)
34708               continue;
34709             if (ways.indexOf(parent) !== -1)
34710               continue;
34711             if (!isRoad(parent))
34712               continue;
34713             hasParents = true;
34714             break;
34715           }
34716           if (hasParents) {
34717             checkVertices.push(node);
34718           }
34719         }
34720       }
34721       if (hasWays) {
34722         vertices.push(vertex);
34723       }
34724     }
34725     vertices = utilArrayUniq(vertices);
34726     ways = utilArrayUniq(ways);
34727     ways.forEach(function(way2) {
34728       graph.childNodes(way2).forEach(function(node2) {
34729         vgraph = vgraph.replace(node2);
34730       });
34731       vgraph = vgraph.replace(way2);
34732       graph.parentRelations(way2).forEach(function(relation) {
34733         if (relation.isRestriction()) {
34734           if (relation.isValidRestriction(graph)) {
34735             vgraph = vgraph.replace(relation);
34736           } else if (relation.isComplete(graph)) {
34737             actions.push(actionDeleteRelation(relation.id));
34738           }
34739         }
34740       });
34741     });
34742     ways.forEach(function(w2) {
34743       var way2 = vgraph.entity(w2.id);
34744       if (way2.tags.oneway === "-1") {
34745         var action = actionReverse(way2.id, { reverseOneway: true });
34746         actions.push(action);
34747         vgraph = action(vgraph);
34748       }
34749     });
34750     var origCount = osmEntity.id.next.way;
34751     vertices.forEach(function(v2) {
34752       var splitAll = actionSplit([v2.id]).keepHistoryOn("first");
34753       if (!splitAll.disabled(vgraph)) {
34754         splitAll.ways(vgraph).forEach(function(way2) {
34755           var splitOne = actionSplit([v2.id]).limitWays([way2.id]).keepHistoryOn("first");
34756           actions.push(splitOne);
34757           vgraph = splitOne(vgraph);
34758         });
34759       }
34760     });
34761     osmEntity.id.next.way = origCount;
34762     vertexIds = vertices.map(function(v2) {
34763       return v2.id;
34764     });
34765     vertices = [];
34766     ways = [];
34767     vertexIds.forEach(function(id2) {
34768       var vertex2 = vgraph.entity(id2);
34769       var parents2 = vgraph.parentWays(vertex2);
34770       vertices.push(vertex2);
34771       ways = ways.concat(parents2);
34772     });
34773     vertices = utilArrayUniq(vertices);
34774     ways = utilArrayUniq(ways);
34775     vertexIds = vertices.map(function(v2) {
34776       return v2.id;
34777     });
34778     wayIds = ways.map(function(w2) {
34779       return w2.id;
34780     });
34781     function withMetadata(way2, vertexIds2) {
34782       var __oneWay = way2.isOneWay();
34783       var __first = vertexIds2.indexOf(way2.first()) !== -1;
34784       var __last = vertexIds2.indexOf(way2.last()) !== -1;
34785       var __via = __first && __last;
34786       var __from = __first && !__oneWay || __last;
34787       var __to = __first || __last && !__oneWay;
34788       return way2.update({
34789         __first,
34790         __last,
34791         __from,
34792         __via,
34793         __to,
34794         __oneWay
34795       });
34796     }
34797     ways = [];
34798     wayIds.forEach(function(id2) {
34799       var way2 = withMetadata(vgraph.entity(id2), vertexIds);
34800       vgraph = vgraph.replace(way2);
34801       ways.push(way2);
34802     });
34803     var keepGoing;
34804     var removeWayIds = [];
34805     var removeVertexIds = [];
34806     do {
34807       keepGoing = false;
34808       checkVertices = vertexIds.slice();
34809       for (i3 = 0; i3 < checkVertices.length; i3++) {
34810         var vertexId = checkVertices[i3];
34811         vertex = vgraph.hasEntity(vertexId);
34812         if (!vertex) {
34813           if (vertexIds.indexOf(vertexId) !== -1) {
34814             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34815           }
34816           removeVertexIds.push(vertexId);
34817           continue;
34818         }
34819         parents = vgraph.parentWays(vertex);
34820         if (parents.length < 3) {
34821           if (vertexIds.indexOf(vertexId) !== -1) {
34822             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34823           }
34824         }
34825         if (parents.length === 2) {
34826           var a2 = parents[0];
34827           var b2 = parents[1];
34828           var aIsLeaf = a2 && !a2.__via;
34829           var bIsLeaf = b2 && !b2.__via;
34830           var leaf, survivor;
34831           if (aIsLeaf && !bIsLeaf) {
34832             leaf = a2;
34833             survivor = b2;
34834           } else if (!aIsLeaf && bIsLeaf) {
34835             leaf = b2;
34836             survivor = a2;
34837           }
34838           if (leaf && survivor) {
34839             survivor = withMetadata(survivor, vertexIds);
34840             vgraph = vgraph.replace(survivor).remove(leaf);
34841             removeWayIds.push(leaf.id);
34842             keepGoing = true;
34843           }
34844         }
34845         parents = vgraph.parentWays(vertex);
34846         if (parents.length < 2) {
34847           if (vertexIds.indexOf(vertexId) !== -1) {
34848             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34849           }
34850           removeVertexIds.push(vertexId);
34851           keepGoing = true;
34852         }
34853         if (parents.length < 1) {
34854           vgraph = vgraph.remove(vertex);
34855         }
34856       }
34857     } while (keepGoing);
34858     vertices = vertices.filter(function(vertex2) {
34859       return removeVertexIds.indexOf(vertex2.id) === -1;
34860     }).map(function(vertex2) {
34861       return vgraph.entity(vertex2.id);
34862     });
34863     ways = ways.filter(function(way2) {
34864       return removeWayIds.indexOf(way2.id) === -1;
34865     }).map(function(way2) {
34866       return vgraph.entity(way2.id);
34867     });
34868     var intersection2 = {
34869       graph: vgraph,
34870       actions,
34871       vertices,
34872       ways
34873     };
34874     intersection2.turns = function(fromWayId, maxViaWay) {
34875       if (!fromWayId)
34876         return [];
34877       if (!maxViaWay)
34878         maxViaWay = 0;
34879       var vgraph2 = intersection2.graph;
34880       var keyVertexIds = intersection2.vertices.map(function(v2) {
34881         return v2.id;
34882       });
34883       var start2 = vgraph2.entity(fromWayId);
34884       if (!start2 || !(start2.__from || start2.__via))
34885         return [];
34886       var maxPathLength = maxViaWay * 2 + 3;
34887       var turns = [];
34888       step(start2);
34889       return turns;
34890       function step(entity, currPath, currRestrictions, matchedRestriction) {
34891         currPath = (currPath || []).slice();
34892         if (currPath.length >= maxPathLength)
34893           return;
34894         currPath.push(entity.id);
34895         currRestrictions = (currRestrictions || []).slice();
34896         if (entity.type === "node") {
34897           stepNode(entity, currPath, currRestrictions);
34898         } else {
34899           stepWay(entity, currPath, currRestrictions, matchedRestriction);
34900         }
34901       }
34902       function stepNode(entity, currPath, currRestrictions) {
34903         var i4, j3;
34904         var parents2 = vgraph2.parentWays(entity);
34905         var nextWays = [];
34906         for (i4 = 0; i4 < parents2.length; i4++) {
34907           var way2 = parents2[i4];
34908           if (way2.__oneWay && way2.nodes[0] !== entity.id)
34909             continue;
34910           if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3)
34911             continue;
34912           var restrict = null;
34913           for (j3 = 0; j3 < currRestrictions.length; j3++) {
34914             var restriction = currRestrictions[j3];
34915             var f2 = restriction.memberByRole("from");
34916             var v2 = restriction.membersByRole("via");
34917             var t2 = restriction.memberByRole("to");
34918             var isNo = /^no_/.test(restriction.tags.restriction);
34919             var isOnly = /^only_/.test(restriction.tags.restriction);
34920             if (!(isNo || isOnly)) {
34921               continue;
34922             }
34923             var matchesFrom = f2.id === fromWayId;
34924             var matchesViaTo = false;
34925             var isAlongOnlyPath = false;
34926             if (t2.id === way2.id) {
34927               if (v2.length === 1 && v2[0].type === "node") {
34928                 matchesViaTo = v2[0].id === entity.id && (matchesFrom && currPath.length === 2 || !matchesFrom && currPath.length > 2);
34929               } else {
34930                 var pathVias = [];
34931                 for (k2 = 2; k2 < currPath.length; k2 += 2) {
34932                   pathVias.push(currPath[k2]);
34933                 }
34934                 var restrictionVias = [];
34935                 for (k2 = 0; k2 < v2.length; k2++) {
34936                   if (v2[k2].type === "way") {
34937                     restrictionVias.push(v2[k2].id);
34938                   }
34939                 }
34940                 var diff = utilArrayDifference(pathVias, restrictionVias);
34941                 matchesViaTo = !diff.length;
34942               }
34943             } else if (isOnly) {
34944               for (k2 = 0; k2 < v2.length; k2++) {
34945                 if (v2[k2].type === "way" && v2[k2].id === way2.id) {
34946                   isAlongOnlyPath = true;
34947                   break;
34948                 }
34949               }
34950             }
34951             if (matchesViaTo) {
34952               if (isOnly) {
34953                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true };
34954               } else {
34955                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true };
34956               }
34957             } else {
34958               if (isAlongOnlyPath) {
34959                 restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false };
34960               } else if (isOnly) {
34961                 restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true };
34962               }
34963             }
34964             if (restrict && restrict.direct)
34965               break;
34966           }
34967           nextWays.push({ way: way2, restrict });
34968         }
34969         nextWays.forEach(function(nextWay) {
34970           step(nextWay.way, currPath, currRestrictions, nextWay.restrict);
34971         });
34972       }
34973       function stepWay(entity, currPath, currRestrictions, matchedRestriction) {
34974         var i4;
34975         if (currPath.length >= 3) {
34976           var turnPath = currPath.slice();
34977           if (matchedRestriction && matchedRestriction.direct === false) {
34978             for (i4 = 0; i4 < turnPath.length; i4++) {
34979               if (turnPath[i4] === matchedRestriction.from) {
34980                 turnPath = turnPath.slice(i4);
34981                 break;
34982               }
34983             }
34984           }
34985           var turn = pathToTurn(turnPath);
34986           if (turn) {
34987             if (matchedRestriction) {
34988               turn.restrictionID = matchedRestriction.id;
34989               turn.no = matchedRestriction.no;
34990               turn.only = matchedRestriction.only;
34991               turn.direct = matchedRestriction.direct;
34992             }
34993             turns.push(osmTurn(turn));
34994           }
34995           if (currPath[0] === currPath[2])
34996             return;
34997         }
34998         if (matchedRestriction && matchedRestriction.end)
34999           return;
35000         var n1 = vgraph2.entity(entity.first());
35001         var n22 = vgraph2.entity(entity.last());
35002         var dist = geoSphericalDistance(n1.loc, n22.loc);
35003         var nextNodes = [];
35004         if (currPath.length > 1) {
35005           if (dist > maxDistance)
35006             return;
35007           if (!entity.__via)
35008             return;
35009         }
35010         if (!entity.__oneWay && // bidirectional..
35011         keyVertexIds.indexOf(n1.id) !== -1 && // key vertex..
35012         currPath.indexOf(n1.id) === -1) {
35013           nextNodes.push(n1);
35014         }
35015         if (keyVertexIds.indexOf(n22.id) !== -1 && // key vertex..
35016         currPath.indexOf(n22.id) === -1) {
35017           nextNodes.push(n22);
35018         }
35019         nextNodes.forEach(function(nextNode) {
35020           var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) {
35021             if (!r2.isRestriction())
35022               return false;
35023             var f2 = r2.memberByRole("from");
35024             if (!f2 || f2.id !== entity.id)
35025               return false;
35026             var isOnly = /^only_/.test(r2.tags.restriction);
35027             if (!isOnly)
35028               return true;
35029             var isOnlyVia = false;
35030             var v2 = r2.membersByRole("via");
35031             if (v2.length === 1 && v2[0].type === "node") {
35032               isOnlyVia = v2[0].id === nextNode.id;
35033             } else {
35034               for (var i5 = 0; i5 < v2.length; i5++) {
35035                 if (v2[i5].type !== "way")
35036                   continue;
35037                 var viaWay = vgraph2.entity(v2[i5].id);
35038                 if (viaWay.first() === nextNode.id || viaWay.last() === nextNode.id) {
35039                   isOnlyVia = true;
35040                   break;
35041                 }
35042               }
35043             }
35044             return isOnlyVia;
35045           });
35046           step(nextNode, currPath, currRestrictions.concat(fromRestrictions), false);
35047         });
35048       }
35049       function pathToTurn(path) {
35050         if (path.length < 3)
35051           return;
35052         var fromWayId2, fromNodeId, fromVertexId;
35053         var toWayId, toNodeId, toVertexId;
35054         var viaWayIds, viaNodeId, isUturn;
35055         fromWayId2 = path[0];
35056         toWayId = path[path.length - 1];
35057         if (path.length === 3 && fromWayId2 === toWayId) {
35058           var way2 = vgraph2.entity(fromWayId2);
35059           if (way2.__oneWay)
35060             return null;
35061           isUturn = true;
35062           viaNodeId = fromVertexId = toVertexId = path[1];
35063           fromNodeId = toNodeId = adjacentNode(fromWayId2, viaNodeId);
35064         } else {
35065           isUturn = false;
35066           fromVertexId = path[1];
35067           fromNodeId = adjacentNode(fromWayId2, fromVertexId);
35068           toVertexId = path[path.length - 2];
35069           toNodeId = adjacentNode(toWayId, toVertexId);
35070           if (path.length === 3) {
35071             viaNodeId = path[1];
35072           } else {
35073             viaWayIds = path.filter(function(entityId) {
35074               return entityId[0] === "w";
35075             });
35076             viaWayIds = viaWayIds.slice(1, viaWayIds.length - 1);
35077           }
35078         }
35079         return {
35080           key: path.join("_"),
35081           path,
35082           from: { node: fromNodeId, way: fromWayId2, vertex: fromVertexId },
35083           via: { node: viaNodeId, ways: viaWayIds },
35084           to: { node: toNodeId, way: toWayId, vertex: toVertexId },
35085           u: isUturn
35086         };
35087         function adjacentNode(wayId, affixId) {
35088           var nodes2 = vgraph2.entity(wayId).nodes;
35089           return affixId === nodes2[0] ? nodes2[1] : nodes2[nodes2.length - 2];
35090         }
35091       }
35092     };
35093     return intersection2;
35094   }
35095   function osmInferRestriction(graph, turn, projection2) {
35096     var fromWay = graph.entity(turn.from.way);
35097     var fromNode = graph.entity(turn.from.node);
35098     var fromVertex = graph.entity(turn.from.vertex);
35099     var toWay = graph.entity(turn.to.way);
35100     var toNode = graph.entity(turn.to.node);
35101     var toVertex = graph.entity(turn.to.vertex);
35102     var fromOneWay = fromWay.tags.oneway === "yes";
35103     var toOneWay = toWay.tags.oneway === "yes";
35104     var angle2 = (geoAngle(fromVertex, fromNode, projection2) - geoAngle(toVertex, toNode, projection2)) * 180 / Math.PI;
35105     while (angle2 < 0) {
35106       angle2 += 360;
35107     }
35108     if (fromNode === toNode) {
35109       return "no_u_turn";
35110     }
35111     if ((angle2 < 23 || angle2 > 336) && fromOneWay && toOneWay) {
35112       return "no_u_turn";
35113     }
35114     if ((angle2 < 40 || angle2 > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
35115       return "no_u_turn";
35116     }
35117     if (angle2 < 158) {
35118       return "no_right_turn";
35119     }
35120     if (angle2 > 202) {
35121       return "no_left_turn";
35122     }
35123     return "no_straight_on";
35124   }
35125
35126   // modules/actions/merge_polygon.js
35127   function actionMergePolygon(ids, newRelationId) {
35128     function groupEntities(graph) {
35129       var entities = ids.map(function(id2) {
35130         return graph.entity(id2);
35131       });
35132       var geometryGroups = utilArrayGroupBy(entities, function(entity) {
35133         if (entity.type === "way" && entity.isClosed()) {
35134           return "closedWay";
35135         } else if (entity.type === "relation" && entity.isMultipolygon()) {
35136           return "multipolygon";
35137         } else {
35138           return "other";
35139         }
35140       });
35141       return Object.assign(
35142         { closedWay: [], multipolygon: [], other: [] },
35143         geometryGroups
35144       );
35145     }
35146     var action = function(graph) {
35147       var entities = groupEntities(graph);
35148       var polygons = entities.multipolygon.reduce(function(polygons2, m2) {
35149         return polygons2.concat(osmJoinWays(m2.members, graph));
35150       }, []).concat(entities.closedWay.map(function(d2) {
35151         var member = [{ id: d2.id }];
35152         member.nodes = graph.childNodes(d2);
35153         return member;
35154       }));
35155       var contained = polygons.map(function(w2, i3) {
35156         return polygons.map(function(d2, n3) {
35157           if (i3 === n3)
35158             return null;
35159           return geoPolygonContainsPolygon(
35160             d2.nodes.map(function(n4) {
35161               return n4.loc;
35162             }),
35163             w2.nodes.map(function(n4) {
35164               return n4.loc;
35165             })
35166           );
35167         });
35168       });
35169       var members = [];
35170       var outer = true;
35171       while (polygons.length) {
35172         extractUncontained(polygons);
35173         polygons = polygons.filter(isContained);
35174         contained = contained.filter(isContained).map(filterContained);
35175       }
35176       function isContained(d2, i3) {
35177         return contained[i3].some(function(val) {
35178           return val;
35179         });
35180       }
35181       function filterContained(d2) {
35182         return d2.filter(isContained);
35183       }
35184       function extractUncontained(polygons2) {
35185         polygons2.forEach(function(d2, i3) {
35186           if (!isContained(d2, i3)) {
35187             d2.forEach(function(member) {
35188               members.push({
35189                 type: "way",
35190                 id: member.id,
35191                 role: outer ? "outer" : "inner"
35192               });
35193             });
35194           }
35195         });
35196         outer = !outer;
35197       }
35198       var relation;
35199       if (entities.multipolygon.length > 0) {
35200         var oldestID = utilOldestID(entities.multipolygon.map((entity) => entity.id));
35201         relation = entities.multipolygon.find((entity) => entity.id === oldestID);
35202       } else {
35203         relation = osmRelation({ id: newRelationId, tags: { type: "multipolygon" } });
35204       }
35205       entities.multipolygon.forEach(function(m2) {
35206         if (m2.id !== relation.id) {
35207           relation = relation.mergeTags(m2.tags);
35208           graph = graph.remove(m2);
35209         }
35210       });
35211       entities.closedWay.forEach(function(way) {
35212         function isThisOuter(m2) {
35213           return m2.id === way.id && m2.role !== "inner";
35214         }
35215         if (members.some(isThisOuter)) {
35216           relation = relation.mergeTags(way.tags);
35217           graph = graph.replace(way.update({ tags: {} }));
35218         }
35219       });
35220       return graph.replace(relation.update({
35221         members,
35222         tags: utilObjectOmit(relation.tags, ["area"])
35223       }));
35224     };
35225     action.disabled = function(graph) {
35226       var entities = groupEntities(graph);
35227       if (entities.other.length > 0 || entities.closedWay.length + entities.multipolygon.length < 2) {
35228         return "not_eligible";
35229       }
35230       if (!entities.multipolygon.every(function(r2) {
35231         return r2.isComplete(graph);
35232       })) {
35233         return "incomplete_relation";
35234       }
35235       if (!entities.multipolygon.length) {
35236         var sharedMultipolygons = [];
35237         entities.closedWay.forEach(function(way, i3) {
35238           if (i3 === 0) {
35239             sharedMultipolygons = graph.parentMultipolygons(way);
35240           } else {
35241             sharedMultipolygons = utilArrayIntersection(sharedMultipolygons, graph.parentMultipolygons(way));
35242           }
35243         });
35244         sharedMultipolygons = sharedMultipolygons.filter(function(relation) {
35245           return relation.members.length === entities.closedWay.length;
35246         });
35247         if (sharedMultipolygons.length) {
35248           return "not_eligible";
35249         }
35250       } else if (entities.closedWay.some(function(way) {
35251         return utilArrayIntersection(graph.parentMultipolygons(way), entities.multipolygon).length;
35252       })) {
35253         return "not_eligible";
35254       }
35255     };
35256     return action;
35257   }
35258
35259   // modules/actions/merge_remote_changes.js
35260   var import_fast_deep_equal = __toESM(require_fast_deep_equal());
35261
35262   // node_modules/node-diff3/index.mjs
35263   function LCS(buffer1, buffer2) {
35264     let equivalenceClasses = {};
35265     for (let j2 = 0; j2 < buffer2.length; j2++) {
35266       const item = buffer2[j2];
35267       if (equivalenceClasses[item]) {
35268         equivalenceClasses[item].push(j2);
35269       } else {
35270         equivalenceClasses[item] = [j2];
35271       }
35272     }
35273     const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null };
35274     let candidates = [NULLRESULT];
35275     for (let i3 = 0; i3 < buffer1.length; i3++) {
35276       const item = buffer1[i3];
35277       const buffer2indices = equivalenceClasses[item] || [];
35278       let r2 = 0;
35279       let c2 = candidates[0];
35280       for (let jx = 0; jx < buffer2indices.length; jx++) {
35281         const j2 = buffer2indices[jx];
35282         let s2;
35283         for (s2 = r2; s2 < candidates.length; s2++) {
35284           if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) {
35285             break;
35286           }
35287         }
35288         if (s2 < candidates.length) {
35289           const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] };
35290           if (r2 === candidates.length) {
35291             candidates.push(c2);
35292           } else {
35293             candidates[r2] = c2;
35294           }
35295           r2 = s2 + 1;
35296           c2 = newCandidate;
35297           if (r2 === candidates.length) {
35298             break;
35299           }
35300         }
35301       }
35302       candidates[r2] = c2;
35303     }
35304     return candidates[candidates.length - 1];
35305   }
35306   function diffIndices(buffer1, buffer2) {
35307     const lcs = LCS(buffer1, buffer2);
35308     let result = [];
35309     let tail1 = buffer1.length;
35310     let tail2 = buffer2.length;
35311     for (let candidate = lcs; candidate !== null; candidate = candidate.chain) {
35312       const mismatchLength1 = tail1 - candidate.buffer1index - 1;
35313       const mismatchLength2 = tail2 - candidate.buffer2index - 1;
35314       tail1 = candidate.buffer1index;
35315       tail2 = candidate.buffer2index;
35316       if (mismatchLength1 || mismatchLength2) {
35317         result.push({
35318           buffer1: [tail1 + 1, mismatchLength1],
35319           buffer1Content: buffer1.slice(tail1 + 1, tail1 + 1 + mismatchLength1),
35320           buffer2: [tail2 + 1, mismatchLength2],
35321           buffer2Content: buffer2.slice(tail2 + 1, tail2 + 1 + mismatchLength2)
35322         });
35323       }
35324     }
35325     result.reverse();
35326     return result;
35327   }
35328   function diff3MergeRegions(a2, o2, b2) {
35329     let hunks = [];
35330     function addHunk(h2, ab) {
35331       hunks.push({
35332         ab,
35333         oStart: h2.buffer1[0],
35334         oLength: h2.buffer1[1],
35335         // length of o to remove
35336         abStart: h2.buffer2[0],
35337         abLength: h2.buffer2[1]
35338         // length of a/b to insert
35339         // abContent: (ab === 'a' ? a : b).slice(h.buffer2[0], h.buffer2[0] + h.buffer2[1])
35340       });
35341     }
35342     diffIndices(o2, a2).forEach((item) => addHunk(item, "a"));
35343     diffIndices(o2, b2).forEach((item) => addHunk(item, "b"));
35344     hunks.sort((x2, y2) => x2.oStart - y2.oStart);
35345     let results = [];
35346     let currOffset = 0;
35347     function advanceTo(endOffset) {
35348       if (endOffset > currOffset) {
35349         results.push({
35350           stable: true,
35351           buffer: "o",
35352           bufferStart: currOffset,
35353           bufferLength: endOffset - currOffset,
35354           bufferContent: o2.slice(currOffset, endOffset)
35355         });
35356         currOffset = endOffset;
35357       }
35358     }
35359     while (hunks.length) {
35360       let hunk = hunks.shift();
35361       let regionStart = hunk.oStart;
35362       let regionEnd = hunk.oStart + hunk.oLength;
35363       let regionHunks = [hunk];
35364       advanceTo(regionStart);
35365       while (hunks.length) {
35366         const nextHunk = hunks[0];
35367         const nextHunkStart = nextHunk.oStart;
35368         if (nextHunkStart > regionEnd)
35369           break;
35370         regionEnd = Math.max(regionEnd, nextHunkStart + nextHunk.oLength);
35371         regionHunks.push(hunks.shift());
35372       }
35373       if (regionHunks.length === 1) {
35374         if (hunk.abLength > 0) {
35375           const buffer = hunk.ab === "a" ? a2 : b2;
35376           results.push({
35377             stable: true,
35378             buffer: hunk.ab,
35379             bufferStart: hunk.abStart,
35380             bufferLength: hunk.abLength,
35381             bufferContent: buffer.slice(hunk.abStart, hunk.abStart + hunk.abLength)
35382           });
35383         }
35384       } else {
35385         let bounds = {
35386           a: [a2.length, -1, o2.length, -1],
35387           b: [b2.length, -1, o2.length, -1]
35388         };
35389         while (regionHunks.length) {
35390           hunk = regionHunks.shift();
35391           const oStart = hunk.oStart;
35392           const oEnd = oStart + hunk.oLength;
35393           const abStart = hunk.abStart;
35394           const abEnd = abStart + hunk.abLength;
35395           let b3 = bounds[hunk.ab];
35396           b3[0] = Math.min(abStart, b3[0]);
35397           b3[1] = Math.max(abEnd, b3[1]);
35398           b3[2] = Math.min(oStart, b3[2]);
35399           b3[3] = Math.max(oEnd, b3[3]);
35400         }
35401         const aStart = bounds.a[0] + (regionStart - bounds.a[2]);
35402         const aEnd = bounds.a[1] + (regionEnd - bounds.a[3]);
35403         const bStart = bounds.b[0] + (regionStart - bounds.b[2]);
35404         const bEnd = bounds.b[1] + (regionEnd - bounds.b[3]);
35405         let result = {
35406           stable: false,
35407           aStart,
35408           aLength: aEnd - aStart,
35409           aContent: a2.slice(aStart, aEnd),
35410           oStart: regionStart,
35411           oLength: regionEnd - regionStart,
35412           oContent: o2.slice(regionStart, regionEnd),
35413           bStart,
35414           bLength: bEnd - bStart,
35415           bContent: b2.slice(bStart, bEnd)
35416         };
35417         results.push(result);
35418       }
35419       currOffset = regionEnd;
35420     }
35421     advanceTo(o2.length);
35422     return results;
35423   }
35424   function diff3Merge(a2, o2, b2, options2) {
35425     let defaults = {
35426       excludeFalseConflicts: true,
35427       stringSeparator: /\s+/
35428     };
35429     options2 = Object.assign(defaults, options2);
35430     if (typeof a2 === "string")
35431       a2 = a2.split(options2.stringSeparator);
35432     if (typeof o2 === "string")
35433       o2 = o2.split(options2.stringSeparator);
35434     if (typeof b2 === "string")
35435       b2 = b2.split(options2.stringSeparator);
35436     let results = [];
35437     const regions = diff3MergeRegions(a2, o2, b2);
35438     let okBuffer = [];
35439     function flushOk() {
35440       if (okBuffer.length) {
35441         results.push({ ok: okBuffer });
35442       }
35443       okBuffer = [];
35444     }
35445     function isFalseConflict(a3, b3) {
35446       if (a3.length !== b3.length)
35447         return false;
35448       for (let i3 = 0; i3 < a3.length; i3++) {
35449         if (a3[i3] !== b3[i3])
35450           return false;
35451       }
35452       return true;
35453     }
35454     regions.forEach((region) => {
35455       if (region.stable) {
35456         okBuffer.push(...region.bufferContent);
35457       } else {
35458         if (options2.excludeFalseConflicts && isFalseConflict(region.aContent, region.bContent)) {
35459           okBuffer.push(...region.aContent);
35460         } else {
35461           flushOk();
35462           results.push({
35463             conflict: {
35464               a: region.aContent,
35465               aIndex: region.aStart,
35466               o: region.oContent,
35467               oIndex: region.oStart,
35468               b: region.bContent,
35469               bIndex: region.bStart
35470             }
35471           });
35472         }
35473       }
35474     });
35475     flushOk();
35476     return results;
35477   }
35478
35479   // modules/actions/merge_remote_changes.js
35480   var import_lodash2 = __toESM(require_lodash());
35481   function actionMergeRemoteChanges(id2, localGraph, remoteGraph, discardTags, formatUser) {
35482     discardTags = discardTags || {};
35483     var _option = "safe";
35484     var _conflicts = [];
35485     function user(d2) {
35486       return typeof formatUser === "function" ? formatUser(d2) : (0, import_lodash2.escape)(d2);
35487     }
35488     function mergeLocation(remote, target) {
35489       function pointEqual(a2, b2) {
35490         var epsilon3 = 1e-6;
35491         return Math.abs(a2[0] - b2[0]) < epsilon3 && Math.abs(a2[1] - b2[1]) < epsilon3;
35492       }
35493       if (_option === "force_local" || pointEqual(target.loc, remote.loc)) {
35494         return target;
35495       }
35496       if (_option === "force_remote") {
35497         return target.update({ loc: remote.loc });
35498       }
35499       _conflicts.push(_t.html("merge_remote_changes.conflict.location", { user: { html: user(remote.user) } }));
35500       return target;
35501     }
35502     function mergeNodes(base, remote, target) {
35503       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.nodes, remote.nodes)) {
35504         return target;
35505       }
35506       if (_option === "force_remote") {
35507         return target.update({ nodes: remote.nodes });
35508       }
35509       var ccount = _conflicts.length;
35510       var o2 = base.nodes || [];
35511       var a2 = target.nodes || [];
35512       var b2 = remote.nodes || [];
35513       var nodes = [];
35514       var hunks = diff3Merge(a2, o2, b2, { excludeFalseConflicts: true });
35515       for (var i3 = 0; i3 < hunks.length; i3++) {
35516         var hunk = hunks[i3];
35517         if (hunk.ok) {
35518           nodes.push.apply(nodes, hunk.ok);
35519         } else {
35520           var c2 = hunk.conflict;
35521           if ((0, import_fast_deep_equal.default)(c2.o, c2.a)) {
35522             nodes.push.apply(nodes, c2.b);
35523           } else if ((0, import_fast_deep_equal.default)(c2.o, c2.b)) {
35524             nodes.push.apply(nodes, c2.a);
35525           } else {
35526             _conflicts.push(_t.html("merge_remote_changes.conflict.nodelist", { user: { html: user(remote.user) } }));
35527             break;
35528           }
35529         }
35530       }
35531       return _conflicts.length === ccount ? target.update({ nodes }) : target;
35532     }
35533     function mergeChildren(targetWay, children2, updates, graph) {
35534       function isUsed(node2, targetWay2) {
35535         var hasInterestingParent = graph.parentWays(node2).some(function(way) {
35536           return way.id !== targetWay2.id;
35537         });
35538         return node2.hasInterestingTags() || hasInterestingParent || graph.parentRelations(node2).length > 0;
35539       }
35540       var ccount = _conflicts.length;
35541       for (var i3 = 0; i3 < children2.length; i3++) {
35542         var id3 = children2[i3];
35543         var node = graph.hasEntity(id3);
35544         if (targetWay.nodes.indexOf(id3) === -1) {
35545           if (node && !isUsed(node, targetWay)) {
35546             updates.removeIds.push(id3);
35547           }
35548           continue;
35549         }
35550         var local = localGraph.hasEntity(id3);
35551         var remote = remoteGraph.hasEntity(id3);
35552         var target;
35553         if (_option === "force_remote" && remote && remote.visible) {
35554           updates.replacements.push(remote);
35555         } else if (_option === "force_local" && local) {
35556           target = osmEntity(local);
35557           if (remote) {
35558             target = target.update({ version: remote.version });
35559           }
35560           updates.replacements.push(target);
35561         } else if (_option === "safe" && local && remote && local.version !== remote.version) {
35562           target = osmEntity(local, { version: remote.version });
35563           if (remote.visible) {
35564             target = mergeLocation(remote, target);
35565           } else {
35566             _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35567           }
35568           if (_conflicts.length !== ccount)
35569             break;
35570           updates.replacements.push(target);
35571         }
35572       }
35573       return targetWay;
35574     }
35575     function updateChildren(updates, graph) {
35576       for (var i3 = 0; i3 < updates.replacements.length; i3++) {
35577         graph = graph.replace(updates.replacements[i3]);
35578       }
35579       if (updates.removeIds.length) {
35580         graph = actionDeleteMultiple(updates.removeIds)(graph);
35581       }
35582       return graph;
35583     }
35584     function mergeMembers(remote, target) {
35585       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.members, remote.members)) {
35586         return target;
35587       }
35588       if (_option === "force_remote") {
35589         return target.update({ members: remote.members });
35590       }
35591       _conflicts.push(_t.html("merge_remote_changes.conflict.memberlist", { user: { html: user(remote.user) } }));
35592       return target;
35593     }
35594     function mergeTags(base, remote, target) {
35595       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.tags, remote.tags)) {
35596         return target;
35597       }
35598       if (_option === "force_remote") {
35599         return target.update({ tags: remote.tags });
35600       }
35601       var ccount = _conflicts.length;
35602       var o2 = base.tags || {};
35603       var a2 = target.tags || {};
35604       var b2 = remote.tags || {};
35605       var keys2 = utilArrayUnion(utilArrayUnion(Object.keys(o2), Object.keys(a2)), Object.keys(b2)).filter(function(k3) {
35606         return !discardTags[k3];
35607       });
35608       var tags = Object.assign({}, a2);
35609       var changed = false;
35610       for (var i3 = 0; i3 < keys2.length; i3++) {
35611         var k2 = keys2[i3];
35612         if (o2[k2] !== b2[k2] && a2[k2] !== b2[k2]) {
35613           if (o2[k2] !== a2[k2]) {
35614             _conflicts.push(_t.html(
35615               "merge_remote_changes.conflict.tags",
35616               { tag: k2, local: a2[k2], remote: b2[k2], user: { html: user(remote.user) } }
35617             ));
35618           } else {
35619             if (b2.hasOwnProperty(k2)) {
35620               tags[k2] = b2[k2];
35621             } else {
35622               delete tags[k2];
35623             }
35624             changed = true;
35625           }
35626         }
35627       }
35628       return changed && _conflicts.length === ccount ? target.update({ tags }) : target;
35629     }
35630     var action = function(graph) {
35631       var updates = { replacements: [], removeIds: [] };
35632       var base = graph.base().entities[id2];
35633       var local = localGraph.entity(id2);
35634       var remote = remoteGraph.entity(id2);
35635       var target = osmEntity(local, { version: remote.version });
35636       if (!remote.visible) {
35637         if (_option === "force_remote") {
35638           return actionDeleteMultiple([id2])(graph);
35639         } else if (_option === "force_local") {
35640           if (target.type === "way") {
35641             target = mergeChildren(target, utilArrayUniq(local.nodes), updates, graph);
35642             graph = updateChildren(updates, graph);
35643           }
35644           return graph.replace(target);
35645         } else {
35646           _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35647           return graph;
35648         }
35649       }
35650       if (target.type === "node") {
35651         target = mergeLocation(remote, target);
35652       } else if (target.type === "way") {
35653         graph.rebase(remoteGraph.childNodes(remote), [graph], false);
35654         target = mergeNodes(base, remote, target);
35655         target = mergeChildren(target, utilArrayUnion(local.nodes, remote.nodes), updates, graph);
35656       } else if (target.type === "relation") {
35657         target = mergeMembers(remote, target);
35658       }
35659       target = mergeTags(base, remote, target);
35660       if (!_conflicts.length) {
35661         graph = updateChildren(updates, graph).replace(target);
35662       }
35663       return graph;
35664     };
35665     action.withOption = function(opt) {
35666       _option = opt;
35667       return action;
35668     };
35669     action.conflicts = function() {
35670       return _conflicts;
35671     };
35672     return action;
35673   }
35674
35675   // modules/actions/move.js
35676   function actionMove(moveIDs, tryDelta, projection2, cache) {
35677     var _delta = tryDelta;
35678     function setupCache(graph) {
35679       function canMove(nodeID) {
35680         if (moveIDs.indexOf(nodeID) !== -1)
35681           return true;
35682         var parents = graph.parentWays(graph.entity(nodeID));
35683         if (parents.length < 3)
35684           return true;
35685         var parentsMoving = parents.every(function(way) {
35686           return cache.moving[way.id];
35687         });
35688         if (!parentsMoving)
35689           delete cache.moving[nodeID];
35690         return parentsMoving;
35691       }
35692       function cacheEntities(ids) {
35693         for (var i3 = 0; i3 < ids.length; i3++) {
35694           var id2 = ids[i3];
35695           if (cache.moving[id2])
35696             continue;
35697           cache.moving[id2] = true;
35698           var entity = graph.hasEntity(id2);
35699           if (!entity)
35700             continue;
35701           if (entity.type === "node") {
35702             cache.nodes.push(id2);
35703             cache.startLoc[id2] = entity.loc;
35704           } else if (entity.type === "way") {
35705             cache.ways.push(id2);
35706             cacheEntities(entity.nodes);
35707           } else {
35708             cacheEntities(entity.members.map(function(member) {
35709               return member.id;
35710             }));
35711           }
35712         }
35713       }
35714       function cacheIntersections(ids) {
35715         function isEndpoint(way2, id3) {
35716           return !way2.isClosed() && !!way2.affix(id3);
35717         }
35718         for (var i3 = 0; i3 < ids.length; i3++) {
35719           var id2 = ids[i3];
35720           var childNodes = graph.childNodes(graph.entity(id2));
35721           for (var j2 = 0; j2 < childNodes.length; j2++) {
35722             var node = childNodes[j2];
35723             var parents = graph.parentWays(node);
35724             if (parents.length !== 2)
35725               continue;
35726             var moved = graph.entity(id2);
35727             var unmoved = null;
35728             for (var k2 = 0; k2 < parents.length; k2++) {
35729               var way = parents[k2];
35730               if (!cache.moving[way.id]) {
35731                 unmoved = way;
35732                 break;
35733               }
35734             }
35735             if (!unmoved)
35736               continue;
35737             if (utilArrayIntersection(moved.nodes, unmoved.nodes).length > 2)
35738               continue;
35739             if (moved.isArea() || unmoved.isArea())
35740               continue;
35741             cache.intersections.push({
35742               nodeId: node.id,
35743               movedId: moved.id,
35744               unmovedId: unmoved.id,
35745               movedIsEP: isEndpoint(moved, node.id),
35746               unmovedIsEP: isEndpoint(unmoved, node.id)
35747             });
35748           }
35749         }
35750       }
35751       if (!cache) {
35752         cache = {};
35753       }
35754       if (!cache.ok) {
35755         cache.moving = {};
35756         cache.intersections = [];
35757         cache.replacedVertex = {};
35758         cache.startLoc = {};
35759         cache.nodes = [];
35760         cache.ways = [];
35761         cacheEntities(moveIDs);
35762         cacheIntersections(cache.ways);
35763         cache.nodes = cache.nodes.filter(canMove);
35764         cache.ok = true;
35765       }
35766     }
35767     function replaceMovedVertex(nodeId, wayId, graph, delta) {
35768       var way = graph.entity(wayId);
35769       var moved = graph.entity(nodeId);
35770       var movedIndex = way.nodes.indexOf(nodeId);
35771       var len, prevIndex, nextIndex;
35772       if (way.isClosed()) {
35773         len = way.nodes.length - 1;
35774         prevIndex = (movedIndex + len - 1) % len;
35775         nextIndex = (movedIndex + len + 1) % len;
35776       } else {
35777         len = way.nodes.length;
35778         prevIndex = movedIndex - 1;
35779         nextIndex = movedIndex + 1;
35780       }
35781       var prev = graph.hasEntity(way.nodes[prevIndex]);
35782       var next = graph.hasEntity(way.nodes[nextIndex]);
35783       if (!prev || !next)
35784         return graph;
35785       var key = wayId + "_" + nodeId;
35786       var orig = cache.replacedVertex[key];
35787       if (!orig) {
35788         orig = osmNode();
35789         cache.replacedVertex[key] = orig;
35790         cache.startLoc[orig.id] = cache.startLoc[nodeId];
35791       }
35792       var start2, end;
35793       if (delta) {
35794         start2 = projection2(cache.startLoc[nodeId]);
35795         end = projection2.invert(geoVecAdd(start2, delta));
35796       } else {
35797         end = cache.startLoc[nodeId];
35798       }
35799       orig = orig.move(end);
35800       var angle2 = Math.abs(geoAngle(orig, prev, projection2) - geoAngle(orig, next, projection2)) * 180 / Math.PI;
35801       if (angle2 > 175 && angle2 < 185)
35802         return graph;
35803       var p1 = [prev.loc, orig.loc, moved.loc, next.loc].map(projection2);
35804       var p2 = [prev.loc, moved.loc, orig.loc, next.loc].map(projection2);
35805       var d1 = geoPathLength(p1);
35806       var d2 = geoPathLength(p2);
35807       var insertAt = d1 <= d2 ? movedIndex : nextIndex;
35808       if (way.isClosed() && insertAt === 0)
35809         insertAt = len;
35810       way = way.addNode(orig.id, insertAt);
35811       return graph.replace(orig).replace(way);
35812     }
35813     function removeDuplicateVertices(wayId, graph) {
35814       var way = graph.entity(wayId);
35815       var epsilon3 = 1e-6;
35816       var prev, curr;
35817       function isInteresting(node, graph2) {
35818         return graph2.parentWays(node).length > 1 || graph2.parentRelations(node).length || node.hasInterestingTags();
35819       }
35820       for (var i3 = 0; i3 < way.nodes.length; i3++) {
35821         curr = graph.entity(way.nodes[i3]);
35822         if (prev && curr && geoVecEqual(prev.loc, curr.loc, epsilon3)) {
35823           if (!isInteresting(prev, graph)) {
35824             way = way.removeNode(prev.id);
35825             graph = graph.replace(way).remove(prev);
35826           } else if (!isInteresting(curr, graph)) {
35827             way = way.removeNode(curr.id);
35828             graph = graph.replace(way).remove(curr);
35829           }
35830         }
35831         prev = curr;
35832       }
35833       return graph;
35834     }
35835     function unZorroIntersection(intersection2, graph) {
35836       var vertex = graph.entity(intersection2.nodeId);
35837       var way1 = graph.entity(intersection2.movedId);
35838       var way2 = graph.entity(intersection2.unmovedId);
35839       var isEP1 = intersection2.movedIsEP;
35840       var isEP2 = intersection2.unmovedIsEP;
35841       if (isEP1 && isEP2)
35842         return graph;
35843       var nodes1 = graph.childNodes(way1).filter(function(n3) {
35844         return n3 !== vertex;
35845       });
35846       var nodes2 = graph.childNodes(way2).filter(function(n3) {
35847         return n3 !== vertex;
35848       });
35849       if (way1.isClosed() && way1.first() === vertex.id)
35850         nodes1.push(nodes1[0]);
35851       if (way2.isClosed() && way2.first() === vertex.id)
35852         nodes2.push(nodes2[0]);
35853       var edge1 = !isEP1 && geoChooseEdge(nodes1, projection2(vertex.loc), projection2);
35854       var edge2 = !isEP2 && geoChooseEdge(nodes2, projection2(vertex.loc), projection2);
35855       var loc;
35856       if (!isEP1 && !isEP2) {
35857         var epsilon3 = 1e-6, maxIter = 10;
35858         for (var i3 = 0; i3 < maxIter; i3++) {
35859           loc = geoVecInterp(edge1.loc, edge2.loc, 0.5);
35860           edge1 = geoChooseEdge(nodes1, projection2(loc), projection2);
35861           edge2 = geoChooseEdge(nodes2, projection2(loc), projection2);
35862           if (Math.abs(edge1.distance - edge2.distance) < epsilon3)
35863             break;
35864         }
35865       } else if (!isEP1) {
35866         loc = edge1.loc;
35867       } else {
35868         loc = edge2.loc;
35869       }
35870       graph = graph.replace(vertex.move(loc));
35871       if (!isEP1 && edge1.index !== way1.nodes.indexOf(vertex.id)) {
35872         way1 = way1.removeNode(vertex.id).addNode(vertex.id, edge1.index);
35873         graph = graph.replace(way1);
35874       }
35875       if (!isEP2 && edge2.index !== way2.nodes.indexOf(vertex.id)) {
35876         way2 = way2.removeNode(vertex.id).addNode(vertex.id, edge2.index);
35877         graph = graph.replace(way2);
35878       }
35879       return graph;
35880     }
35881     function cleanupIntersections(graph) {
35882       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35883         var obj = cache.intersections[i3];
35884         graph = replaceMovedVertex(obj.nodeId, obj.movedId, graph, _delta);
35885         graph = replaceMovedVertex(obj.nodeId, obj.unmovedId, graph, null);
35886         graph = unZorroIntersection(obj, graph);
35887         graph = removeDuplicateVertices(obj.movedId, graph);
35888         graph = removeDuplicateVertices(obj.unmovedId, graph);
35889       }
35890       return graph;
35891     }
35892     function limitDelta(graph) {
35893       function moveNode(loc) {
35894         return geoVecAdd(projection2(loc), _delta);
35895       }
35896       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35897         var obj = cache.intersections[i3];
35898         if (obj.movedIsEP && obj.unmovedIsEP)
35899           continue;
35900         if (!obj.movedIsEP)
35901           continue;
35902         var node = graph.entity(obj.nodeId);
35903         var start2 = projection2(node.loc);
35904         var end = geoVecAdd(start2, _delta);
35905         var movedNodes = graph.childNodes(graph.entity(obj.movedId));
35906         var movedPath = movedNodes.map(function(n3) {
35907           return moveNode(n3.loc);
35908         });
35909         var unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId));
35910         var unmovedPath = unmovedNodes.map(function(n3) {
35911           return projection2(n3.loc);
35912         });
35913         var hits = geoPathIntersections(movedPath, unmovedPath);
35914         for (var j2 = 0; i3 < hits.length; i3++) {
35915           if (geoVecEqual(hits[j2], end))
35916             continue;
35917           var edge = geoChooseEdge(unmovedNodes, end, projection2);
35918           _delta = geoVecSubtract(projection2(edge.loc), start2);
35919         }
35920       }
35921     }
35922     var action = function(graph) {
35923       if (_delta[0] === 0 && _delta[1] === 0)
35924         return graph;
35925       setupCache(graph);
35926       if (cache.intersections.length) {
35927         limitDelta(graph);
35928       }
35929       for (var i3 = 0; i3 < cache.nodes.length; i3++) {
35930         var node = graph.entity(cache.nodes[i3]);
35931         var start2 = projection2(node.loc);
35932         var end = geoVecAdd(start2, _delta);
35933         graph = graph.replace(node.move(projection2.invert(end)));
35934       }
35935       if (cache.intersections.length) {
35936         graph = cleanupIntersections(graph);
35937       }
35938       return graph;
35939     };
35940     action.delta = function() {
35941       return _delta;
35942     };
35943     return action;
35944   }
35945
35946   // modules/actions/move_member.js
35947   function actionMoveMember(relationId, fromIndex, toIndex) {
35948     return function(graph) {
35949       return graph.replace(graph.entity(relationId).moveMember(fromIndex, toIndex));
35950     };
35951   }
35952
35953   // modules/actions/move_node.js
35954   function actionMoveNode(nodeID, toLoc) {
35955     var action = function(graph, t2) {
35956       if (t2 === null || !isFinite(t2))
35957         t2 = 1;
35958       t2 = Math.min(Math.max(+t2, 0), 1);
35959       var node = graph.entity(nodeID);
35960       return graph.replace(
35961         node.move(geoVecInterp(node.loc, toLoc, t2))
35962       );
35963     };
35964     action.transitionable = true;
35965     return action;
35966   }
35967
35968   // modules/actions/noop.js
35969   function actionNoop() {
35970     return function(graph) {
35971       return graph;
35972     };
35973   }
35974
35975   // modules/actions/orthogonalize.js
35976   function actionOrthogonalize(wayID, projection2, vertexID, degThresh, ep) {
35977     var epsilon3 = ep || 1e-4;
35978     var threshold = degThresh || 13;
35979     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
35980     var upperThreshold = Math.cos(threshold * Math.PI / 180);
35981     var action = function(graph, t2) {
35982       if (t2 === null || !isFinite(t2))
35983         t2 = 1;
35984       t2 = Math.min(Math.max(+t2, 0), 1);
35985       var way = graph.entity(wayID);
35986       way = way.removeNode("");
35987       if (way.tags.nonsquare) {
35988         var tags = Object.assign({}, way.tags);
35989         delete tags.nonsquare;
35990         way = way.update({ tags });
35991       }
35992       graph = graph.replace(way);
35993       var isClosed = way.isClosed();
35994       var nodes = graph.childNodes(way).slice();
35995       if (isClosed)
35996         nodes.pop();
35997       if (vertexID !== void 0) {
35998         nodes = nodeSubset(nodes, vertexID, isClosed);
35999         if (nodes.length !== 3)
36000           return graph;
36001       }
36002       var nodeCount = {};
36003       var points = [];
36004       var corner = { i: 0, dotp: 1 };
36005       var node, point2, loc, score, motions, i3, j2;
36006       for (i3 = 0; i3 < nodes.length; i3++) {
36007         node = nodes[i3];
36008         nodeCount[node.id] = (nodeCount[node.id] || 0) + 1;
36009         points.push({ id: node.id, coord: projection2(node.loc) });
36010       }
36011       if (points.length === 3) {
36012         for (i3 = 0; i3 < 1e3; i3++) {
36013           motions = points.map(calcMotion);
36014           points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]);
36015           score = corner.dotp;
36016           if (score < epsilon3) {
36017             break;
36018           }
36019         }
36020         node = graph.entity(nodes[corner.i].id);
36021         loc = projection2.invert(points[corner.i].coord);
36022         graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36023       } else {
36024         var straights = [];
36025         var simplified = [];
36026         for (i3 = 0; i3 < points.length; i3++) {
36027           point2 = points[i3];
36028           var dotp = 0;
36029           if (isClosed || i3 > 0 && i3 < points.length - 1) {
36030             var a2 = points[(i3 - 1 + points.length) % points.length];
36031             var b2 = points[(i3 + 1) % points.length];
36032             dotp = Math.abs(geoOrthoNormalizedDotProduct(a2.coord, b2.coord, point2.coord));
36033           }
36034           if (dotp > upperThreshold) {
36035             straights.push(point2);
36036           } else {
36037             simplified.push(point2);
36038           }
36039         }
36040         var bestPoints = clonePoints(simplified);
36041         var originalPoints = clonePoints(simplified);
36042         score = Infinity;
36043         for (i3 = 0; i3 < 1e3; i3++) {
36044           motions = simplified.map(calcMotion);
36045           for (j2 = 0; j2 < motions.length; j2++) {
36046             simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]);
36047           }
36048           var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold);
36049           if (newScore < score) {
36050             bestPoints = clonePoints(simplified);
36051             score = newScore;
36052           }
36053           if (score < epsilon3) {
36054             break;
36055           }
36056         }
36057         var bestCoords = bestPoints.map(function(p2) {
36058           return p2.coord;
36059         });
36060         if (isClosed)
36061           bestCoords.push(bestCoords[0]);
36062         for (i3 = 0; i3 < bestPoints.length; i3++) {
36063           point2 = bestPoints[i3];
36064           if (!geoVecEqual(originalPoints[i3].coord, point2.coord)) {
36065             node = graph.entity(point2.id);
36066             loc = projection2.invert(point2.coord);
36067             graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36068           }
36069         }
36070         for (i3 = 0; i3 < straights.length; i3++) {
36071           point2 = straights[i3];
36072           if (nodeCount[point2.id] > 1)
36073             continue;
36074           node = graph.entity(point2.id);
36075           if (t2 === 1 && graph.parentWays(node).length === 1 && graph.parentRelations(node).length === 0 && !node.hasInterestingTags()) {
36076             graph = actionDeleteNode(node.id)(graph);
36077           } else {
36078             var choice = geoVecProject(point2.coord, bestCoords);
36079             if (choice) {
36080               loc = projection2.invert(choice.target);
36081               graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36082             }
36083           }
36084         }
36085       }
36086       return graph;
36087       function clonePoints(array2) {
36088         return array2.map(function(p2) {
36089           return { id: p2.id, coord: [p2.coord[0], p2.coord[1]] };
36090         });
36091       }
36092       function calcMotion(point3, i4, array2) {
36093         if (!isClosed && (i4 === 0 || i4 === array2.length - 1))
36094           return [0, 0];
36095         if (nodeCount[array2[i4].id] > 1)
36096           return [0, 0];
36097         var a3 = array2[(i4 - 1 + array2.length) % array2.length].coord;
36098         var origin = point3.coord;
36099         var b3 = array2[(i4 + 1) % array2.length].coord;
36100         var p2 = geoVecSubtract(a3, origin);
36101         var q2 = geoVecSubtract(b3, origin);
36102         var scale = 2 * Math.min(geoVecLength(p2), geoVecLength(q2));
36103         p2 = geoVecNormalize(p2);
36104         q2 = geoVecNormalize(q2);
36105         var dotp2 = p2[0] * q2[0] + p2[1] * q2[1];
36106         var val = Math.abs(dotp2);
36107         if (val < lowerThreshold) {
36108           corner.i = i4;
36109           corner.dotp = val;
36110           var vec = geoVecNormalize(geoVecAdd(p2, q2));
36111           return geoVecScale(vec, 0.1 * dotp2 * scale);
36112         }
36113         return [0, 0];
36114       }
36115     };
36116     function nodeSubset(nodes, vertexID2, isClosed) {
36117       var first = isClosed ? 0 : 1;
36118       var last = isClosed ? nodes.length : nodes.length - 1;
36119       for (var i3 = first; i3 < last; i3++) {
36120         if (nodes[i3].id === vertexID2) {
36121           return [
36122             nodes[(i3 - 1 + nodes.length) % nodes.length],
36123             nodes[i3],
36124             nodes[(i3 + 1) % nodes.length]
36125           ];
36126         }
36127       }
36128       return [];
36129     }
36130     action.disabled = function(graph) {
36131       var way = graph.entity(wayID);
36132       way = way.removeNode("");
36133       graph = graph.replace(way);
36134       var isClosed = way.isClosed();
36135       var nodes = graph.childNodes(way).slice();
36136       if (isClosed)
36137         nodes.pop();
36138       var allowStraightAngles = false;
36139       if (vertexID !== void 0) {
36140         allowStraightAngles = true;
36141         nodes = nodeSubset(nodes, vertexID, isClosed);
36142         if (nodes.length !== 3)
36143           return "end_vertex";
36144       }
36145       var coords = nodes.map(function(n3) {
36146         return projection2(n3.loc);
36147       });
36148       var score = geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles);
36149       if (score === null) {
36150         return "not_squarish";
36151       } else if (score === 0) {
36152         return "square_enough";
36153       } else {
36154         return false;
36155       }
36156     };
36157     action.transitionable = true;
36158     return action;
36159   }
36160
36161   // modules/actions/restrict_turn.js
36162   function actionRestrictTurn(turn, restrictionType, restrictionID) {
36163     return function(graph) {
36164       var fromWay = graph.entity(turn.from.way);
36165       var toWay = graph.entity(turn.to.way);
36166       var viaNode = turn.via.node && graph.entity(turn.via.node);
36167       var viaWays = turn.via.ways && turn.via.ways.map(function(id2) {
36168         return graph.entity(id2);
36169       });
36170       var members = [];
36171       members.push({ id: fromWay.id, type: "way", role: "from" });
36172       if (viaNode) {
36173         members.push({ id: viaNode.id, type: "node", role: "via" });
36174       } else if (viaWays) {
36175         viaWays.forEach(function(viaWay) {
36176           members.push({ id: viaWay.id, type: "way", role: "via" });
36177         });
36178       }
36179       members.push({ id: toWay.id, type: "way", role: "to" });
36180       return graph.replace(osmRelation({
36181         id: restrictionID,
36182         tags: {
36183           type: "restriction",
36184           restriction: restrictionType
36185         },
36186         members
36187       }));
36188     };
36189   }
36190
36191   // modules/actions/revert.js
36192   function actionRevert(id2) {
36193     var action = function(graph) {
36194       var entity = graph.hasEntity(id2), base = graph.base().entities[id2];
36195       if (entity && !base) {
36196         if (entity.type === "node") {
36197           graph.parentWays(entity).forEach(function(parent) {
36198             parent = parent.removeNode(id2);
36199             graph = graph.replace(parent);
36200             if (parent.isDegenerate()) {
36201               graph = actionDeleteWay(parent.id)(graph);
36202             }
36203           });
36204         }
36205         graph.parentRelations(entity).forEach(function(parent) {
36206           parent = parent.removeMembersWithID(id2);
36207           graph = graph.replace(parent);
36208           if (parent.isDegenerate()) {
36209             graph = actionDeleteRelation(parent.id)(graph);
36210           }
36211         });
36212       }
36213       return graph.revert(id2);
36214     };
36215     return action;
36216   }
36217
36218   // modules/actions/rotate.js
36219   function actionRotate(rotateIds, pivot, angle2, projection2) {
36220     var action = function(graph) {
36221       return graph.update(function(graph2) {
36222         utilGetAllNodes(rotateIds, graph2).forEach(function(node) {
36223           var point2 = geoRotate([projection2(node.loc)], angle2, pivot)[0];
36224           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36225         });
36226       });
36227     };
36228     return action;
36229   }
36230
36231   // modules/actions/scale.js
36232   function actionScale(ids, pivotLoc, scaleFactor, projection2) {
36233     return function(graph) {
36234       return graph.update(function(graph2) {
36235         let point2, radial;
36236         utilGetAllNodes(ids, graph2).forEach(function(node) {
36237           point2 = projection2(node.loc);
36238           radial = [
36239             point2[0] - pivotLoc[0],
36240             point2[1] - pivotLoc[1]
36241           ];
36242           point2 = [
36243             pivotLoc[0] + scaleFactor * radial[0],
36244             pivotLoc[1] + scaleFactor * radial[1]
36245           ];
36246           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36247         });
36248       });
36249     };
36250   }
36251
36252   // modules/actions/straighten_nodes.js
36253   function actionStraightenNodes(nodeIDs, projection2) {
36254     function positionAlongWay(a2, o2, b2) {
36255       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36256     }
36257     function getEndpoints(points) {
36258       var ssr = geoGetSmallestSurroundingRectangle(points);
36259       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36260       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36261       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36262       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36263       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36264       if (isLong) {
36265         return [p1, q1];
36266       }
36267       return [p2, q2];
36268     }
36269     var action = function(graph, t2) {
36270       if (t2 === null || !isFinite(t2))
36271         t2 = 1;
36272       t2 = Math.min(Math.max(+t2, 0), 1);
36273       var nodes = nodeIDs.map(function(id2) {
36274         return graph.entity(id2);
36275       });
36276       var points = nodes.map(function(n3) {
36277         return projection2(n3.loc);
36278       });
36279       var endpoints = getEndpoints(points);
36280       var startPoint = endpoints[0];
36281       var endPoint = endpoints[1];
36282       for (var i3 = 0; i3 < points.length; i3++) {
36283         var node = nodes[i3];
36284         var point2 = points[i3];
36285         var u2 = positionAlongWay(point2, startPoint, endPoint);
36286         var point22 = geoVecInterp(startPoint, endPoint, u2);
36287         var loc2 = projection2.invert(point22);
36288         graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36289       }
36290       return graph;
36291     };
36292     action.disabled = function(graph) {
36293       var nodes = nodeIDs.map(function(id2) {
36294         return graph.entity(id2);
36295       });
36296       var points = nodes.map(function(n3) {
36297         return projection2(n3.loc);
36298       });
36299       var endpoints = getEndpoints(points);
36300       var startPoint = endpoints[0];
36301       var endPoint = endpoints[1];
36302       var maxDistance = 0;
36303       for (var i3 = 0; i3 < points.length; i3++) {
36304         var point2 = points[i3];
36305         var u2 = positionAlongWay(point2, startPoint, endPoint);
36306         var p2 = geoVecInterp(startPoint, endPoint, u2);
36307         var dist = geoVecLength(p2, point2);
36308         if (!isNaN(dist) && dist > maxDistance) {
36309           maxDistance = dist;
36310         }
36311       }
36312       if (maxDistance < 1e-4) {
36313         return "straight_enough";
36314       }
36315     };
36316     action.transitionable = true;
36317     return action;
36318   }
36319
36320   // modules/actions/straighten_way.js
36321   function actionStraightenWay(selectedIDs, projection2) {
36322     function positionAlongWay(a2, o2, b2) {
36323       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36324     }
36325     function allNodes(graph) {
36326       var nodes = [];
36327       var startNodes = [];
36328       var endNodes = [];
36329       var remainingWays = [];
36330       var selectedWays = selectedIDs.filter(function(w2) {
36331         return graph.entity(w2).type === "way";
36332       });
36333       var selectedNodes = selectedIDs.filter(function(n3) {
36334         return graph.entity(n3).type === "node";
36335       });
36336       for (var i3 = 0; i3 < selectedWays.length; i3++) {
36337         var way = graph.entity(selectedWays[i3]);
36338         nodes = way.nodes.slice(0);
36339         remainingWays.push(nodes);
36340         startNodes.push(nodes[0]);
36341         endNodes.push(nodes[nodes.length - 1]);
36342       }
36343       startNodes = startNodes.filter(function(n3) {
36344         return startNodes.indexOf(n3) === startNodes.lastIndexOf(n3);
36345       });
36346       endNodes = endNodes.filter(function(n3) {
36347         return endNodes.indexOf(n3) === endNodes.lastIndexOf(n3);
36348       });
36349       var currNode = utilArrayDifference(startNodes, endNodes).concat(utilArrayDifference(endNodes, startNodes))[0];
36350       var nextWay = [];
36351       nodes = [];
36352       var getNextWay = function(currNode2, remainingWays2) {
36353         return remainingWays2.filter(function(way2) {
36354           return way2[0] === currNode2 || way2[way2.length - 1] === currNode2;
36355         })[0];
36356       };
36357       while (remainingWays.length) {
36358         nextWay = getNextWay(currNode, remainingWays);
36359         remainingWays = utilArrayDifference(remainingWays, [nextWay]);
36360         if (nextWay[0] !== currNode) {
36361           nextWay.reverse();
36362         }
36363         nodes = nodes.concat(nextWay);
36364         currNode = nodes[nodes.length - 1];
36365       }
36366       if (selectedNodes.length === 2) {
36367         var startNodeIdx = nodes.indexOf(selectedNodes[0]);
36368         var endNodeIdx = nodes.indexOf(selectedNodes[1]);
36369         var sortedStartEnd = [startNodeIdx, endNodeIdx];
36370         sortedStartEnd.sort(function(a2, b2) {
36371           return a2 - b2;
36372         });
36373         nodes = nodes.slice(sortedStartEnd[0], sortedStartEnd[1] + 1);
36374       }
36375       return nodes.map(function(n3) {
36376         return graph.entity(n3);
36377       });
36378     }
36379     function shouldKeepNode(node, graph) {
36380       return graph.parentWays(node).length > 1 || graph.parentRelations(node).length || node.hasInterestingTags();
36381     }
36382     var action = function(graph, t2) {
36383       if (t2 === null || !isFinite(t2))
36384         t2 = 1;
36385       t2 = Math.min(Math.max(+t2, 0), 1);
36386       var nodes = allNodes(graph);
36387       var points = nodes.map(function(n3) {
36388         return projection2(n3.loc);
36389       });
36390       var startPoint = points[0];
36391       var endPoint = points[points.length - 1];
36392       var toDelete = [];
36393       var i3;
36394       for (i3 = 1; i3 < points.length - 1; i3++) {
36395         var node = nodes[i3];
36396         var point2 = points[i3];
36397         if (t2 < 1 || shouldKeepNode(node, graph)) {
36398           var u2 = positionAlongWay(point2, startPoint, endPoint);
36399           var p2 = geoVecInterp(startPoint, endPoint, u2);
36400           var loc2 = projection2.invert(p2);
36401           graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36402         } else {
36403           if (toDelete.indexOf(node) === -1) {
36404             toDelete.push(node);
36405           }
36406         }
36407       }
36408       for (i3 = 0; i3 < toDelete.length; i3++) {
36409         graph = actionDeleteNode(toDelete[i3].id)(graph);
36410       }
36411       return graph;
36412     };
36413     action.disabled = function(graph) {
36414       var nodes = allNodes(graph);
36415       var points = nodes.map(function(n3) {
36416         return projection2(n3.loc);
36417       });
36418       var startPoint = points[0];
36419       var endPoint = points[points.length - 1];
36420       var threshold = 0.2 * geoVecLength(startPoint, endPoint);
36421       var i3;
36422       if (threshold === 0) {
36423         return "too_bendy";
36424       }
36425       var maxDistance = 0;
36426       for (i3 = 1; i3 < points.length - 1; i3++) {
36427         var point2 = points[i3];
36428         var u2 = positionAlongWay(point2, startPoint, endPoint);
36429         var p2 = geoVecInterp(startPoint, endPoint, u2);
36430         var dist = geoVecLength(p2, point2);
36431         if (isNaN(dist) || dist > threshold) {
36432           return "too_bendy";
36433         } else if (dist > maxDistance) {
36434           maxDistance = dist;
36435         }
36436       }
36437       var keepingAllNodes = nodes.every(function(node, i4) {
36438         return i4 === 0 || i4 === nodes.length - 1 || shouldKeepNode(node, graph);
36439       });
36440       if (maxDistance < 1e-4 && // Allow straightening even if already straight in order to remove extraneous nodes
36441       keepingAllNodes) {
36442         return "straight_enough";
36443       }
36444     };
36445     action.transitionable = true;
36446     return action;
36447   }
36448
36449   // modules/actions/unrestrict_turn.js
36450   function actionUnrestrictTurn(turn) {
36451     return function(graph) {
36452       return actionDeleteRelation(turn.restrictionID)(graph);
36453     };
36454   }
36455
36456   // modules/actions/reflect.js
36457   function actionReflect(reflectIds, projection2) {
36458     var _useLongAxis = true;
36459     var action = function(graph, t2) {
36460       if (t2 === null || !isFinite(t2))
36461         t2 = 1;
36462       t2 = Math.min(Math.max(+t2, 0), 1);
36463       var nodes = utilGetAllNodes(reflectIds, graph);
36464       var points = nodes.map(function(n3) {
36465         return projection2(n3.loc);
36466       });
36467       var ssr = geoGetSmallestSurroundingRectangle(points);
36468       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36469       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36470       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36471       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36472       var p3, q3;
36473       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36474       if (_useLongAxis && isLong || !_useLongAxis && !isLong) {
36475         p3 = p1;
36476         q3 = q1;
36477       } else {
36478         p3 = p2;
36479         q3 = q2;
36480       }
36481       var dx = q3[0] - p3[0];
36482       var dy = q3[1] - p3[1];
36483       var a2 = (dx * dx - dy * dy) / (dx * dx + dy * dy);
36484       var b2 = 2 * dx * dy / (dx * dx + dy * dy);
36485       for (var i3 = 0; i3 < nodes.length; i3++) {
36486         var node = nodes[i3];
36487         var c2 = projection2(node.loc);
36488         var c22 = [
36489           a2 * (c2[0] - p3[0]) + b2 * (c2[1] - p3[1]) + p3[0],
36490           b2 * (c2[0] - p3[0]) - a2 * (c2[1] - p3[1]) + p3[1]
36491         ];
36492         var loc2 = projection2.invert(c22);
36493         node = node.move(geoVecInterp(node.loc, loc2, t2));
36494         graph = graph.replace(node);
36495       }
36496       return graph;
36497     };
36498     action.useLongAxis = function(val) {
36499       if (!arguments.length)
36500         return _useLongAxis;
36501       _useLongAxis = val;
36502       return action;
36503     };
36504     action.transitionable = true;
36505     return action;
36506   }
36507
36508   // modules/actions/upgrade_tags.js
36509   function actionUpgradeTags(entityId, oldTags, replaceTags) {
36510     return function(graph) {
36511       var entity = graph.entity(entityId);
36512       var tags = Object.assign({}, entity.tags);
36513       var transferValue;
36514       var semiIndex;
36515       for (var oldTagKey in oldTags) {
36516         if (!(oldTagKey in tags))
36517           continue;
36518         if (oldTags[oldTagKey] === "*") {
36519           transferValue = tags[oldTagKey];
36520           delete tags[oldTagKey];
36521         } else if (oldTags[oldTagKey] === tags[oldTagKey]) {
36522           delete tags[oldTagKey];
36523         } else {
36524           var vals = tags[oldTagKey].split(";").filter(Boolean);
36525           var oldIndex = vals.indexOf(oldTags[oldTagKey]);
36526           if (vals.length === 1 || oldIndex === -1) {
36527             delete tags[oldTagKey];
36528           } else {
36529             if (replaceTags && replaceTags[oldTagKey]) {
36530               semiIndex = oldIndex;
36531             }
36532             vals.splice(oldIndex, 1);
36533             tags[oldTagKey] = vals.join(";");
36534           }
36535         }
36536       }
36537       if (replaceTags) {
36538         for (var replaceKey in replaceTags) {
36539           var replaceValue = replaceTags[replaceKey];
36540           if (replaceValue === "*") {
36541             if (tags[replaceKey] && tags[replaceKey] !== "no") {
36542               continue;
36543             } else {
36544               tags[replaceKey] = "yes";
36545             }
36546           } else if (replaceValue === "$1") {
36547             tags[replaceKey] = transferValue;
36548           } else {
36549             if (tags[replaceKey] && oldTags[replaceKey] && semiIndex !== void 0) {
36550               var existingVals = tags[replaceKey].split(";").filter(Boolean);
36551               if (existingVals.indexOf(replaceValue) === -1) {
36552                 existingVals.splice(semiIndex, 0, replaceValue);
36553                 tags[replaceKey] = existingVals.join(";");
36554               }
36555             } else {
36556               tags[replaceKey] = replaceValue;
36557             }
36558           }
36559         }
36560       }
36561       return graph.replace(entity.update({ tags }));
36562     };
36563   }
36564
36565   // modules/behavior/edit.js
36566   function behaviorEdit(context) {
36567     function behavior() {
36568       context.map().minzoom(context.minEditableZoom());
36569     }
36570     behavior.off = function() {
36571       context.map().minzoom(0);
36572     };
36573     return behavior;
36574   }
36575
36576   // modules/behavior/hover.js
36577   function behaviorHover(context) {
36578     var dispatch14 = dispatch_default("hover");
36579     var _selection = select_default2(null);
36580     var _newNodeId = null;
36581     var _initialNodeID = null;
36582     var _altDisables;
36583     var _ignoreVertex;
36584     var _targets = [];
36585     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36586     function keydown(d3_event) {
36587       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36588         _selection.selectAll(".hover").classed("hover-suppressed", true).classed("hover", false);
36589         _selection.classed("hover-disabled", true);
36590         dispatch14.call("hover", this, null);
36591       }
36592     }
36593     function keyup(d3_event) {
36594       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36595         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false).classed("hover", true);
36596         _selection.classed("hover-disabled", false);
36597         dispatch14.call("hover", this, _targets);
36598       }
36599     }
36600     function behavior(selection2) {
36601       _selection = selection2;
36602       _targets = [];
36603       if (_initialNodeID) {
36604         _newNodeId = _initialNodeID;
36605         _initialNodeID = null;
36606       } else {
36607         _newNodeId = null;
36608       }
36609       _selection.on(_pointerPrefix + "over.hover", pointerover).on(_pointerPrefix + "out.hover", pointerout).on(_pointerPrefix + "down.hover", pointerover);
36610       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", pointerout, true).on("keydown.hover", keydown).on("keyup.hover", keyup);
36611       function eventTarget(d3_event) {
36612         var datum2 = d3_event.target && d3_event.target.__data__;
36613         if (typeof datum2 !== "object")
36614           return null;
36615         if (!(datum2 instanceof osmEntity) && datum2.properties && datum2.properties.entity instanceof osmEntity) {
36616           return datum2.properties.entity;
36617         }
36618         return datum2;
36619       }
36620       function pointerover(d3_event) {
36621         if (context.mode().id.indexOf("drag") === -1 && (!d3_event.pointerType || d3_event.pointerType === "mouse") && d3_event.buttons)
36622           return;
36623         var target = eventTarget(d3_event);
36624         if (target && _targets.indexOf(target) === -1) {
36625           _targets.push(target);
36626           updateHover(d3_event, _targets);
36627         }
36628       }
36629       function pointerout(d3_event) {
36630         var target = eventTarget(d3_event);
36631         var index = _targets.indexOf(target);
36632         if (index !== -1) {
36633           _targets.splice(index);
36634           updateHover(d3_event, _targets);
36635         }
36636       }
36637       function allowsVertex(d2) {
36638         return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36639       }
36640       function modeAllowsHover(target) {
36641         var mode = context.mode();
36642         if (mode.id === "add-point") {
36643           return mode.preset.matchGeometry("vertex") || target.type !== "way" && target.geometry(context.graph()) !== "vertex";
36644         }
36645         return true;
36646       }
36647       function updateHover(d3_event, targets) {
36648         _selection.selectAll(".hover").classed("hover", false);
36649         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36650         var mode = context.mode();
36651         if (!_newNodeId && (mode.id === "draw-line" || mode.id === "draw-area")) {
36652           var node = targets.find(function(target) {
36653             return target instanceof osmEntity && target.type === "node";
36654           });
36655           _newNodeId = node && node.id;
36656         }
36657         targets = targets.filter(function(datum3) {
36658           if (datum3 instanceof osmEntity) {
36659             return datum3.id !== _newNodeId && (datum3.type !== "node" || !_ignoreVertex || allowsVertex(datum3)) && modeAllowsHover(datum3);
36660           }
36661           return true;
36662         });
36663         var selector = "";
36664         for (var i3 in targets) {
36665           var datum2 = targets[i3];
36666           if (datum2.__featurehash__) {
36667             selector += ", .data" + datum2.__featurehash__;
36668           } else if (datum2 instanceof QAItem) {
36669             selector += ", ." + datum2.service + ".itemId-" + datum2.id;
36670           } else if (datum2 instanceof osmNote) {
36671             selector += ", .note-" + datum2.id;
36672           } else if (datum2 instanceof osmEntity) {
36673             selector += ", ." + datum2.id;
36674             if (datum2.type === "relation") {
36675               for (var j2 in datum2.members) {
36676                 selector += ", ." + datum2.members[j2].id;
36677               }
36678             }
36679           }
36680         }
36681         var suppressed = _altDisables && d3_event && d3_event.altKey;
36682         if (selector.trim().length) {
36683           selector = selector.slice(1);
36684           _selection.selectAll(selector).classed(suppressed ? "hover-suppressed" : "hover", true);
36685         }
36686         dispatch14.call("hover", this, !suppressed && targets);
36687       }
36688     }
36689     behavior.off = function(selection2) {
36690       selection2.selectAll(".hover").classed("hover", false);
36691       selection2.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36692       selection2.classed("hover-disabled", false);
36693       selection2.on(_pointerPrefix + "over.hover", null).on(_pointerPrefix + "out.hover", null).on(_pointerPrefix + "down.hover", null);
36694       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", null, true).on("keydown.hover", null).on("keyup.hover", null);
36695     };
36696     behavior.altDisables = function(val) {
36697       if (!arguments.length)
36698         return _altDisables;
36699       _altDisables = val;
36700       return behavior;
36701     };
36702     behavior.ignoreVertex = function(val) {
36703       if (!arguments.length)
36704         return _ignoreVertex;
36705       _ignoreVertex = val;
36706       return behavior;
36707     };
36708     behavior.initialNodeID = function(nodeId) {
36709       _initialNodeID = nodeId;
36710       return behavior;
36711     };
36712     return utilRebind(behavior, dispatch14, "on");
36713   }
36714
36715   // modules/behavior/draw.js
36716   var _disableSpace = false;
36717   var _lastSpace = null;
36718   function behaviorDraw(context) {
36719     var dispatch14 = dispatch_default(
36720       "move",
36721       "down",
36722       "downcancel",
36723       "click",
36724       "clickWay",
36725       "clickNode",
36726       "undo",
36727       "cancel",
36728       "finish"
36729     );
36730     var keybinding = utilKeybinding("draw");
36731     var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true).on("hover", context.ui().sidebar.hover);
36732     var _edit = behaviorEdit(context);
36733     var _closeTolerance = 4;
36734     var _tolerance = 12;
36735     var _mouseLeave = false;
36736     var _lastMouse = null;
36737     var _lastPointerUpEvent;
36738     var _downPointer;
36739     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36740     function datum2(d3_event) {
36741       var mode = context.mode();
36742       var isNote = mode && mode.id.indexOf("note") !== -1;
36743       if (d3_event.altKey || isNote)
36744         return {};
36745       var element;
36746       if (d3_event.type === "keydown") {
36747         element = _lastMouse && _lastMouse.target;
36748       } else {
36749         element = d3_event.target;
36750       }
36751       var d2 = element.__data__;
36752       return d2 && d2.properties && d2.properties.target ? d2 : {};
36753     }
36754     function pointerdown(d3_event) {
36755       if (_downPointer)
36756         return;
36757       var pointerLocGetter = utilFastMouse(this);
36758       _downPointer = {
36759         id: d3_event.pointerId || "mouse",
36760         pointerLocGetter,
36761         downTime: +/* @__PURE__ */ new Date(),
36762         downLoc: pointerLocGetter(d3_event)
36763       };
36764       dispatch14.call("down", this, d3_event, datum2(d3_event));
36765     }
36766     function pointerup(d3_event) {
36767       if (!_downPointer || _downPointer.id !== (d3_event.pointerId || "mouse"))
36768         return;
36769       var downPointer = _downPointer;
36770       _downPointer = null;
36771       _lastPointerUpEvent = d3_event;
36772       if (downPointer.isCancelled)
36773         return;
36774       var t2 = +/* @__PURE__ */ new Date();
36775       var p2 = downPointer.pointerLocGetter(d3_event);
36776       var dist = geoVecLength(downPointer.downLoc, p2);
36777       if (dist < _closeTolerance || dist < _tolerance && t2 - downPointer.downTime < 500) {
36778         select_default2(window).on("click.draw-block", function() {
36779           d3_event.stopPropagation();
36780         }, true);
36781         context.map().dblclickZoomEnable(false);
36782         window.setTimeout(function() {
36783           context.map().dblclickZoomEnable(true);
36784           select_default2(window).on("click.draw-block", null);
36785         }, 500);
36786         click(d3_event, p2);
36787       }
36788     }
36789     function pointermove(d3_event) {
36790       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse") && !_downPointer.isCancelled) {
36791         var p2 = _downPointer.pointerLocGetter(d3_event);
36792         var dist = geoVecLength(_downPointer.downLoc, p2);
36793         if (dist >= _closeTolerance) {
36794           _downPointer.isCancelled = true;
36795           dispatch14.call("downcancel", this);
36796         }
36797       }
36798       if (d3_event.pointerType && d3_event.pointerType !== "mouse" || d3_event.buttons || _downPointer)
36799         return;
36800       if (_lastPointerUpEvent && _lastPointerUpEvent.pointerType !== "mouse" && d3_event.timeStamp - _lastPointerUpEvent.timeStamp < 100)
36801         return;
36802       _lastMouse = d3_event;
36803       dispatch14.call("move", this, d3_event, datum2(d3_event));
36804     }
36805     function pointercancel(d3_event) {
36806       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse")) {
36807         if (!_downPointer.isCancelled) {
36808           dispatch14.call("downcancel", this);
36809         }
36810         _downPointer = null;
36811       }
36812     }
36813     function mouseenter() {
36814       _mouseLeave = false;
36815     }
36816     function mouseleave() {
36817       _mouseLeave = true;
36818     }
36819     function allowsVertex(d2) {
36820       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36821     }
36822     function click(d3_event, loc) {
36823       var d2 = datum2(d3_event);
36824       var target = d2 && d2.properties && d2.properties.entity;
36825       var mode = context.mode();
36826       if (target && target.type === "node" && allowsVertex(target)) {
36827         dispatch14.call("clickNode", this, target, d2);
36828         return;
36829       } else if (target && target.type === "way" && (mode.id !== "add-point" || mode.preset.matchGeometry("vertex"))) {
36830         var choice = geoChooseEdge(
36831           context.graph().childNodes(target),
36832           loc,
36833           context.projection,
36834           context.activeID()
36835         );
36836         if (choice) {
36837           var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
36838           dispatch14.call("clickWay", this, choice.loc, edge, d2);
36839           return;
36840         }
36841       } else if (mode.id !== "add-point" || mode.preset.matchGeometry("point")) {
36842         var locLatLng = context.projection.invert(loc);
36843         dispatch14.call("click", this, locLatLng, d2);
36844       }
36845     }
36846     function space(d3_event) {
36847       d3_event.preventDefault();
36848       d3_event.stopPropagation();
36849       var currSpace = context.map().mouse();
36850       if (_disableSpace && _lastSpace) {
36851         var dist = geoVecLength(_lastSpace, currSpace);
36852         if (dist > _tolerance) {
36853           _disableSpace = false;
36854         }
36855       }
36856       if (_disableSpace || _mouseLeave || !_lastMouse)
36857         return;
36858       _lastSpace = currSpace;
36859       _disableSpace = true;
36860       select_default2(window).on("keyup.space-block", function() {
36861         d3_event.preventDefault();
36862         d3_event.stopPropagation();
36863         _disableSpace = false;
36864         select_default2(window).on("keyup.space-block", null);
36865       });
36866       var loc = context.map().mouse() || // or the map center if the mouse has never entered the map
36867       context.projection(context.map().center());
36868       click(d3_event, loc);
36869     }
36870     function backspace(d3_event) {
36871       d3_event.preventDefault();
36872       dispatch14.call("undo");
36873     }
36874     function del(d3_event) {
36875       d3_event.preventDefault();
36876       dispatch14.call("cancel");
36877     }
36878     function ret(d3_event) {
36879       d3_event.preventDefault();
36880       dispatch14.call("finish");
36881     }
36882     function behavior(selection2) {
36883       context.install(_hover);
36884       context.install(_edit);
36885       _downPointer = null;
36886       keybinding.on("\u232B", backspace).on("\u2326", del).on("\u238B", ret).on("\u21A9", ret).on("space", space).on("\u2325space", space);
36887       selection2.on("mouseenter.draw", mouseenter).on("mouseleave.draw", mouseleave).on(_pointerPrefix + "down.draw", pointerdown).on(_pointerPrefix + "move.draw", pointermove);
36888       select_default2(window).on(_pointerPrefix + "up.draw", pointerup, true).on("pointercancel.draw", pointercancel, true);
36889       select_default2(document).call(keybinding);
36890       return behavior;
36891     }
36892     behavior.off = function(selection2) {
36893       context.ui().sidebar.hover.cancel();
36894       context.uninstall(_hover);
36895       context.uninstall(_edit);
36896       selection2.on("mouseenter.draw", null).on("mouseleave.draw", null).on(_pointerPrefix + "down.draw", null).on(_pointerPrefix + "move.draw", null);
36897       select_default2(window).on(_pointerPrefix + "up.draw", null).on("pointercancel.draw", null);
36898       select_default2(document).call(keybinding.unbind);
36899     };
36900     behavior.hover = function() {
36901       return _hover;
36902     };
36903     return utilRebind(behavior, dispatch14, "on");
36904   }
36905
36906   // modules/behavior/breathe.js
36907   var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
36908
36909   // node_modules/d3-scale/src/init.js
36910   function initRange(domain, range3) {
36911     switch (arguments.length) {
36912       case 0:
36913         break;
36914       case 1:
36915         this.range(domain);
36916         break;
36917       default:
36918         this.range(range3).domain(domain);
36919         break;
36920     }
36921     return this;
36922   }
36923
36924   // node_modules/d3-scale/src/constant.js
36925   function constants(x2) {
36926     return function() {
36927       return x2;
36928     };
36929   }
36930
36931   // node_modules/d3-scale/src/number.js
36932   function number2(x2) {
36933     return +x2;
36934   }
36935
36936   // node_modules/d3-scale/src/continuous.js
36937   var unit = [0, 1];
36938   function identity3(x2) {
36939     return x2;
36940   }
36941   function normalize(a2, b2) {
36942     return (b2 -= a2 = +a2) ? function(x2) {
36943       return (x2 - a2) / b2;
36944     } : constants(isNaN(b2) ? NaN : 0.5);
36945   }
36946   function clamper(a2, b2) {
36947     var t2;
36948     if (a2 > b2)
36949       t2 = a2, a2 = b2, b2 = t2;
36950     return function(x2) {
36951       return Math.max(a2, Math.min(b2, x2));
36952     };
36953   }
36954   function bimap(domain, range3, interpolate) {
36955     var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1];
36956     if (d1 < d0)
36957       d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
36958     else
36959       d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
36960     return function(x2) {
36961       return r0(d0(x2));
36962     };
36963   }
36964   function polymap(domain, range3, interpolate) {
36965     var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1;
36966     if (domain[j2] < domain[0]) {
36967       domain = domain.slice().reverse();
36968       range3 = range3.slice().reverse();
36969     }
36970     while (++i3 < j2) {
36971       d2[i3] = normalize(domain[i3], domain[i3 + 1]);
36972       r2[i3] = interpolate(range3[i3], range3[i3 + 1]);
36973     }
36974     return function(x2) {
36975       var i4 = bisect_default(domain, x2, 1, j2) - 1;
36976       return r2[i4](d2[i4](x2));
36977     };
36978   }
36979   function copy(source, target) {
36980     return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
36981   }
36982   function transformer2() {
36983     var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input;
36984     function rescale() {
36985       var n3 = Math.min(domain.length, range3.length);
36986       if (clamp3 !== identity3)
36987         clamp3 = clamper(domain[0], domain[n3 - 1]);
36988       piecewise = n3 > 2 ? polymap : bimap;
36989       output = input = null;
36990       return scale;
36991     }
36992     function scale(x2) {
36993       return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2)));
36994     }
36995     scale.invert = function(y2) {
36996       return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2)));
36997     };
36998     scale.domain = function(_2) {
36999       return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice();
37000     };
37001     scale.range = function(_2) {
37002       return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice();
37003     };
37004     scale.rangeRound = function(_2) {
37005       return range3 = Array.from(_2), interpolate = round_default, rescale();
37006     };
37007     scale.clamp = function(_2) {
37008       return arguments.length ? (clamp3 = _2 ? true : identity3, rescale()) : clamp3 !== identity3;
37009     };
37010     scale.interpolate = function(_2) {
37011       return arguments.length ? (interpolate = _2, rescale()) : interpolate;
37012     };
37013     scale.unknown = function(_2) {
37014       return arguments.length ? (unknown = _2, scale) : unknown;
37015     };
37016     return function(t2, u2) {
37017       transform2 = t2, untransform = u2;
37018       return rescale();
37019     };
37020   }
37021   function continuous() {
37022     return transformer2()(identity3, identity3);
37023   }
37024
37025   // node_modules/d3-format/src/formatDecimal.js
37026   function formatDecimal_default(x2) {
37027     return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
37028   }
37029   function formatDecimalParts(x2, p2) {
37030     if ((i3 = (x2 = p2 ? x2.toExponential(p2 - 1) : x2.toExponential()).indexOf("e")) < 0)
37031       return null;
37032     var i3, coefficient = x2.slice(0, i3);
37033     return [
37034       coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
37035       +x2.slice(i3 + 1)
37036     ];
37037   }
37038
37039   // node_modules/d3-format/src/exponent.js
37040   function exponent_default(x2) {
37041     return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
37042   }
37043
37044   // node_modules/d3-format/src/formatGroup.js
37045   function formatGroup_default(grouping, thousands) {
37046     return function(value, width) {
37047       var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0;
37048       while (i3 > 0 && g3 > 0) {
37049         if (length2 + g3 + 1 > width)
37050           g3 = Math.max(1, width - length2);
37051         t2.push(value.substring(i3 -= g3, i3 + g3));
37052         if ((length2 += g3 + 1) > width)
37053           break;
37054         g3 = grouping[j2 = (j2 + 1) % grouping.length];
37055       }
37056       return t2.reverse().join(thousands);
37057     };
37058   }
37059
37060   // node_modules/d3-format/src/formatNumerals.js
37061   function formatNumerals_default(numerals) {
37062     return function(value) {
37063       return value.replace(/[0-9]/g, function(i3) {
37064         return numerals[+i3];
37065       });
37066     };
37067   }
37068
37069   // node_modules/d3-format/src/formatSpecifier.js
37070   var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
37071   function formatSpecifier(specifier) {
37072     if (!(match = re.exec(specifier)))
37073       throw new Error("invalid format: " + specifier);
37074     var match;
37075     return new FormatSpecifier({
37076       fill: match[1],
37077       align: match[2],
37078       sign: match[3],
37079       symbol: match[4],
37080       zero: match[5],
37081       width: match[6],
37082       comma: match[7],
37083       precision: match[8] && match[8].slice(1),
37084       trim: match[9],
37085       type: match[10]
37086     });
37087   }
37088   formatSpecifier.prototype = FormatSpecifier.prototype;
37089   function FormatSpecifier(specifier) {
37090     this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
37091     this.align = specifier.align === void 0 ? ">" : specifier.align + "";
37092     this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
37093     this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
37094     this.zero = !!specifier.zero;
37095     this.width = specifier.width === void 0 ? void 0 : +specifier.width;
37096     this.comma = !!specifier.comma;
37097     this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
37098     this.trim = !!specifier.trim;
37099     this.type = specifier.type === void 0 ? "" : specifier.type + "";
37100   }
37101   FormatSpecifier.prototype.toString = function() {
37102     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;
37103   };
37104
37105   // node_modules/d3-format/src/formatTrim.js
37106   function formatTrim_default(s2) {
37107     out:
37108       for (var n3 = s2.length, i3 = 1, i0 = -1, i1; i3 < n3; ++i3) {
37109         switch (s2[i3]) {
37110           case ".":
37111             i0 = i1 = i3;
37112             break;
37113           case "0":
37114             if (i0 === 0)
37115               i0 = i3;
37116             i1 = i3;
37117             break;
37118           default:
37119             if (!+s2[i3])
37120               break out;
37121             if (i0 > 0)
37122               i0 = 0;
37123             break;
37124         }
37125       }
37126     return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2;
37127   }
37128
37129   // node_modules/d3-format/src/formatPrefixAuto.js
37130   var prefixExponent;
37131   function formatPrefixAuto_default(x2, p2) {
37132     var d2 = formatDecimalParts(x2, p2);
37133     if (!d2)
37134       return x2 + "";
37135     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;
37136     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];
37137   }
37138
37139   // node_modules/d3-format/src/formatRounded.js
37140   function formatRounded_default(x2, p2) {
37141     var d2 = formatDecimalParts(x2, p2);
37142     if (!d2)
37143       return x2 + "";
37144     var coefficient = d2[0], exponent = d2[1];
37145     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");
37146   }
37147
37148   // node_modules/d3-format/src/formatTypes.js
37149   var formatTypes_default = {
37150     "%": (x2, p2) => (x2 * 100).toFixed(p2),
37151     "b": (x2) => Math.round(x2).toString(2),
37152     "c": (x2) => x2 + "",
37153     "d": formatDecimal_default,
37154     "e": (x2, p2) => x2.toExponential(p2),
37155     "f": (x2, p2) => x2.toFixed(p2),
37156     "g": (x2, p2) => x2.toPrecision(p2),
37157     "o": (x2) => Math.round(x2).toString(8),
37158     "p": (x2, p2) => formatRounded_default(x2 * 100, p2),
37159     "r": formatRounded_default,
37160     "s": formatPrefixAuto_default,
37161     "X": (x2) => Math.round(x2).toString(16).toUpperCase(),
37162     "x": (x2) => Math.round(x2).toString(16)
37163   };
37164
37165   // node_modules/d3-format/src/identity.js
37166   function identity_default4(x2) {
37167     return x2;
37168   }
37169
37170   // node_modules/d3-format/src/locale.js
37171   var map = Array.prototype.map;
37172   var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
37173   function locale_default(locale2) {
37174     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 + "";
37175     function newFormat(specifier) {
37176       specifier = formatSpecifier(specifier);
37177       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;
37178       if (type2 === "n")
37179         comma = true, type2 = "g";
37180       else if (!formatTypes_default[type2])
37181         precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g";
37182       if (zero3 || fill === "0" && align === "=")
37183         zero3 = true, fill = "0", align = "=";
37184       var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : "";
37185       var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2);
37186       precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3));
37187       function format2(value) {
37188         var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2;
37189         if (type2 === "c") {
37190           valueSuffix = formatType(value) + valueSuffix;
37191           value = "";
37192         } else {
37193           value = +value;
37194           var valueNegative = value < 0 || 1 / value < 0;
37195           value = isNaN(value) ? nan : formatType(Math.abs(value), precision3);
37196           if (trim)
37197             value = formatTrim_default(value);
37198           if (valueNegative && +value === 0 && sign2 !== "+")
37199             valueNegative = false;
37200           valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
37201           valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
37202           if (maybeSuffix) {
37203             i3 = -1, n3 = value.length;
37204             while (++i3 < n3) {
37205               if (c2 = value.charCodeAt(i3), 48 > c2 || c2 > 57) {
37206                 valueSuffix = (c2 === 46 ? decimal + value.slice(i3 + 1) : value.slice(i3)) + valueSuffix;
37207                 value = value.slice(0, i3);
37208                 break;
37209               }
37210             }
37211           }
37212         }
37213         if (comma && !zero3)
37214           value = group(value, Infinity);
37215         var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : "";
37216         if (comma && zero3)
37217           value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
37218         switch (align) {
37219           case "<":
37220             value = valuePrefix + value + valueSuffix + padding;
37221             break;
37222           case "=":
37223             value = valuePrefix + padding + value + valueSuffix;
37224             break;
37225           case "^":
37226             value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2);
37227             break;
37228           default:
37229             value = padding + valuePrefix + value + valueSuffix;
37230             break;
37231         }
37232         return numerals(value);
37233       }
37234       format2.toString = function() {
37235         return specifier + "";
37236       };
37237       return format2;
37238     }
37239     function formatPrefix2(specifier, value) {
37240       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];
37241       return function(value2) {
37242         return f2(k2 * value2) + prefix;
37243       };
37244     }
37245     return {
37246       format: newFormat,
37247       formatPrefix: formatPrefix2
37248     };
37249   }
37250
37251   // node_modules/d3-format/src/defaultLocale.js
37252   var locale;
37253   var format;
37254   var formatPrefix;
37255   defaultLocale({
37256     thousands: ",",
37257     grouping: [3],
37258     currency: ["$", ""]
37259   });
37260   function defaultLocale(definition) {
37261     locale = locale_default(definition);
37262     format = locale.format;
37263     formatPrefix = locale.formatPrefix;
37264     return locale;
37265   }
37266
37267   // node_modules/d3-format/src/precisionFixed.js
37268   function precisionFixed_default(step) {
37269     return Math.max(0, -exponent_default(Math.abs(step)));
37270   }
37271
37272   // node_modules/d3-format/src/precisionPrefix.js
37273   function precisionPrefix_default(step, value) {
37274     return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
37275   }
37276
37277   // node_modules/d3-format/src/precisionRound.js
37278   function precisionRound_default(step, max3) {
37279     step = Math.abs(step), max3 = Math.abs(max3) - step;
37280     return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
37281   }
37282
37283   // node_modules/d3-scale/src/tickFormat.js
37284   function tickFormat(start2, stop, count, specifier) {
37285     var step = tickStep(start2, stop, count), precision3;
37286     specifier = formatSpecifier(specifier == null ? ",f" : specifier);
37287     switch (specifier.type) {
37288       case "s": {
37289         var value = Math.max(Math.abs(start2), Math.abs(stop));
37290         if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value)))
37291           specifier.precision = precision3;
37292         return formatPrefix(specifier, value);
37293       }
37294       case "":
37295       case "e":
37296       case "g":
37297       case "p":
37298       case "r": {
37299         if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop)))))
37300           specifier.precision = precision3 - (specifier.type === "e");
37301         break;
37302       }
37303       case "f":
37304       case "%": {
37305         if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step)))
37306           specifier.precision = precision3 - (specifier.type === "%") * 2;
37307         break;
37308       }
37309     }
37310     return format(specifier);
37311   }
37312
37313   // node_modules/d3-scale/src/linear.js
37314   function linearish(scale) {
37315     var domain = scale.domain;
37316     scale.ticks = function(count) {
37317       var d2 = domain();
37318       return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count);
37319     };
37320     scale.tickFormat = function(count, specifier) {
37321       var d2 = domain();
37322       return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier);
37323     };
37324     scale.nice = function(count) {
37325       if (count == null)
37326         count = 10;
37327       var d2 = domain();
37328       var i0 = 0;
37329       var i1 = d2.length - 1;
37330       var start2 = d2[i0];
37331       var stop = d2[i1];
37332       var prestep;
37333       var step;
37334       var maxIter = 10;
37335       if (stop < start2) {
37336         step = start2, start2 = stop, stop = step;
37337         step = i0, i0 = i1, i1 = step;
37338       }
37339       while (maxIter-- > 0) {
37340         step = tickIncrement(start2, stop, count);
37341         if (step === prestep) {
37342           d2[i0] = start2;
37343           d2[i1] = stop;
37344           return domain(d2);
37345         } else if (step > 0) {
37346           start2 = Math.floor(start2 / step) * step;
37347           stop = Math.ceil(stop / step) * step;
37348         } else if (step < 0) {
37349           start2 = Math.ceil(start2 * step) / step;
37350           stop = Math.floor(stop * step) / step;
37351         } else {
37352           break;
37353         }
37354         prestep = step;
37355       }
37356       return scale;
37357     };
37358     return scale;
37359   }
37360   function linear3() {
37361     var scale = continuous();
37362     scale.copy = function() {
37363       return copy(scale, linear3());
37364     };
37365     initRange.apply(scale, arguments);
37366     return linearish(scale);
37367   }
37368
37369   // node_modules/d3-scale/src/quantize.js
37370   function quantize() {
37371     var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown;
37372     function scale(x2) {
37373       return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown;
37374     }
37375     function rescale() {
37376       var i3 = -1;
37377       domain = new Array(n3);
37378       while (++i3 < n3)
37379         domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1);
37380       return scale;
37381     }
37382     scale.domain = function(_2) {
37383       return arguments.length ? ([x05, x12] = _2, x05 = +x05, x12 = +x12, rescale()) : [x05, x12];
37384     };
37385     scale.range = function(_2) {
37386       return arguments.length ? (n3 = (range3 = Array.from(_2)).length - 1, rescale()) : range3.slice();
37387     };
37388     scale.invertExtent = function(y2) {
37389       var i3 = range3.indexOf(y2);
37390       return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]];
37391     };
37392     scale.unknown = function(_2) {
37393       return arguments.length ? (unknown = _2, scale) : scale;
37394     };
37395     scale.thresholds = function() {
37396       return domain.slice();
37397     };
37398     scale.copy = function() {
37399       return quantize().domain([x05, x12]).range(range3).unknown(unknown);
37400     };
37401     return initRange.apply(linearish(scale), arguments);
37402   }
37403
37404   // modules/behavior/breathe.js
37405   function behaviorBreathe() {
37406     var duration = 800;
37407     var steps = 4;
37408     var selector = ".selected.shadow, .selected .shadow";
37409     var _selected = select_default2(null);
37410     var _classed = "";
37411     var _params = {};
37412     var _done = false;
37413     var _timer;
37414     function ratchetyInterpolator(a2, b2, steps2, units) {
37415       a2 = Number(a2);
37416       b2 = Number(b2);
37417       var sample = quantize().domain([0, 1]).range(quantize_default(number_default(a2, b2), steps2));
37418       return function(t2) {
37419         return String(sample(t2)) + (units || "");
37420       };
37421     }
37422     function reset(selection2) {
37423       selection2.style("stroke-opacity", null).style("stroke-width", null).style("fill-opacity", null).style("r", null);
37424     }
37425     function setAnimationParams(transition2, fromTo) {
37426       var toFrom = fromTo === "from" ? "to" : "from";
37427       transition2.styleTween("stroke-opacity", function(d2) {
37428         return ratchetyInterpolator(
37429           _params[d2.id][toFrom].opacity,
37430           _params[d2.id][fromTo].opacity,
37431           steps
37432         );
37433       }).styleTween("stroke-width", function(d2) {
37434         return ratchetyInterpolator(
37435           _params[d2.id][toFrom].width,
37436           _params[d2.id][fromTo].width,
37437           steps,
37438           "px"
37439         );
37440       }).styleTween("fill-opacity", function(d2) {
37441         return ratchetyInterpolator(
37442           _params[d2.id][toFrom].opacity,
37443           _params[d2.id][fromTo].opacity,
37444           steps
37445         );
37446       }).styleTween("r", function(d2) {
37447         return ratchetyInterpolator(
37448           _params[d2.id][toFrom].width,
37449           _params[d2.id][fromTo].width,
37450           steps,
37451           "px"
37452         );
37453       });
37454     }
37455     function calcAnimationParams(selection2) {
37456       selection2.call(reset).each(function(d2) {
37457         var s2 = select_default2(this);
37458         var tag2 = s2.node().tagName;
37459         var p2 = { "from": {}, "to": {} };
37460         var opacity;
37461         var width;
37462         if (tag2 === "circle") {
37463           opacity = Number(s2.style("fill-opacity") || 0.5);
37464           width = Number(s2.style("r") || 15.5);
37465         } else {
37466           opacity = Number(s2.style("stroke-opacity") || 0.7);
37467           width = Number(s2.style("stroke-width") || 10);
37468         }
37469         p2.tag = tag2;
37470         p2.from.opacity = opacity * 0.6;
37471         p2.to.opacity = opacity * 1.25;
37472         p2.from.width = width * 0.7;
37473         p2.to.width = width * (tag2 === "circle" ? 1.5 : 1);
37474         _params[d2.id] = p2;
37475       });
37476     }
37477     function run(surface, fromTo) {
37478       var toFrom = fromTo === "from" ? "to" : "from";
37479       var currSelected = surface.selectAll(selector);
37480       var currClassed = surface.attr("class");
37481       if (_done || currSelected.empty()) {
37482         _selected.call(reset);
37483         _selected = select_default2(null);
37484         return;
37485       }
37486       if (!(0, import_fast_deep_equal2.default)(currSelected.data(), _selected.data()) || currClassed !== _classed) {
37487         _selected.call(reset);
37488         _classed = currClassed;
37489         _selected = currSelected.call(calcAnimationParams);
37490       }
37491       var didCallNextRun = false;
37492       _selected.transition().duration(duration).call(setAnimationParams, fromTo).on("end", function() {
37493         if (!didCallNextRun) {
37494           surface.call(run, toFrom);
37495           didCallNextRun = true;
37496         }
37497         if (!select_default2(this).classed("selected")) {
37498           reset(select_default2(this));
37499         }
37500       });
37501     }
37502     function behavior(surface) {
37503       _done = false;
37504       _timer = timer(function() {
37505         if (surface.selectAll(selector).empty()) {
37506           return false;
37507         }
37508         surface.call(run, "from");
37509         _timer.stop();
37510         return true;
37511       }, 20);
37512     }
37513     behavior.restartIfNeeded = function(surface) {
37514       if (_selected.empty()) {
37515         surface.call(run, "from");
37516         if (_timer) {
37517           _timer.stop();
37518         }
37519       }
37520     };
37521     behavior.off = function() {
37522       _done = true;
37523       if (_timer) {
37524         _timer.stop();
37525       }
37526       _selected.interrupt().call(reset);
37527     };
37528     return behavior;
37529   }
37530
37531   // modules/behavior/operation.js
37532   function behaviorOperation(context) {
37533     var _operation;
37534     function keypress(d3_event) {
37535       if (!context.map().withinEditableZoom())
37536         return;
37537       if (_operation.availableForKeypress && !_operation.availableForKeypress())
37538         return;
37539       d3_event.preventDefault();
37540       var disabled = _operation.disabled();
37541       if (disabled) {
37542         context.ui().flash.duration(4e3).iconName("#iD-operation-" + _operation.id).iconClass("operation disabled").label(_operation.tooltip())();
37543       } else {
37544         context.ui().flash.duration(2e3).iconName("#iD-operation-" + _operation.id).iconClass("operation").label(_operation.annotation() || _operation.title)();
37545         if (_operation.point)
37546           _operation.point(null);
37547         _operation();
37548       }
37549     }
37550     function behavior() {
37551       if (_operation && _operation.available()) {
37552         context.keybinding().on(_operation.keys, keypress);
37553       }
37554       return behavior;
37555     }
37556     behavior.off = function() {
37557       context.keybinding().off(_operation.keys);
37558     };
37559     behavior.which = function(_2) {
37560       if (!arguments.length)
37561         return _operation;
37562       _operation = _2;
37563       return behavior;
37564     };
37565     return behavior;
37566   }
37567
37568   // modules/operations/circularize.js
37569   function operationCircularize(context, selectedIDs) {
37570     var _extent;
37571     var _actions = selectedIDs.map(getAction).filter(Boolean);
37572     var _amount = _actions.length === 1 ? "single" : "multiple";
37573     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37574       return n3.loc;
37575     });
37576     function getAction(entityID) {
37577       var entity = context.entity(entityID);
37578       if (entity.type !== "way" || new Set(entity.nodes).size <= 1)
37579         return null;
37580       if (!_extent) {
37581         _extent = entity.extent(context.graph());
37582       } else {
37583         _extent = _extent.extend(entity.extent(context.graph()));
37584       }
37585       return actionCircularize(entityID, context.projection);
37586     }
37587     var operation2 = function() {
37588       if (!_actions.length)
37589         return;
37590       var combinedAction = function(graph, t2) {
37591         _actions.forEach(function(action) {
37592           if (!action.disabled(graph)) {
37593             graph = action(graph, t2);
37594           }
37595         });
37596         return graph;
37597       };
37598       combinedAction.transitionable = true;
37599       context.perform(combinedAction, operation2.annotation());
37600       window.setTimeout(function() {
37601         context.validator().validate();
37602       }, 300);
37603     };
37604     operation2.available = function() {
37605       return _actions.length && selectedIDs.length === _actions.length;
37606     };
37607     operation2.disabled = function() {
37608       if (!_actions.length)
37609         return "";
37610       var actionDisableds = _actions.map(function(action) {
37611         return action.disabled(context.graph());
37612       }).filter(Boolean);
37613       if (actionDisableds.length === _actions.length) {
37614         if (new Set(actionDisableds).size > 1) {
37615           return "multiple_blockers";
37616         }
37617         return actionDisableds[0];
37618       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
37619         return "too_large";
37620       } else if (someMissing()) {
37621         return "not_downloaded";
37622       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37623         return "connected_to_hidden";
37624       }
37625       return false;
37626       function someMissing() {
37627         if (context.inIntro())
37628           return false;
37629         var osm = context.connection();
37630         if (osm) {
37631           var missing = _coords.filter(function(loc) {
37632             return !osm.isDataLoaded(loc);
37633           });
37634           if (missing.length) {
37635             missing.forEach(function(loc) {
37636               context.loadTileAtLoc(loc);
37637             });
37638             return true;
37639           }
37640         }
37641         return false;
37642       }
37643     };
37644     operation2.tooltip = function() {
37645       var disable = operation2.disabled();
37646       return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount);
37647     };
37648     operation2.annotation = function() {
37649       return _t("operations.circularize.annotation.feature", { n: _actions.length });
37650     };
37651     operation2.id = "circularize";
37652     operation2.keys = [_t("operations.circularize.key")];
37653     operation2.title = _t.append("operations.circularize.title");
37654     operation2.behavior = behaviorOperation(context).which(operation2);
37655     return operation2;
37656   }
37657
37658   // modules/ui/cmd.js
37659   var uiCmd = function(code) {
37660     var detected = utilDetect();
37661     if (detected.os === "mac") {
37662       return code;
37663     }
37664     if (detected.os === "win") {
37665       if (code === "\u2318\u21E7Z")
37666         return "Ctrl+Y";
37667     }
37668     var result = "", replacements = {
37669       "\u2318": "Ctrl",
37670       "\u21E7": "Shift",
37671       "\u2325": "Alt",
37672       "\u232B": "Backspace",
37673       "\u2326": "Delete"
37674     };
37675     for (var i3 = 0; i3 < code.length; i3++) {
37676       if (code[i3] in replacements) {
37677         result += replacements[code[i3]] + (i3 < code.length - 1 ? "+" : "");
37678       } else {
37679         result += code[i3];
37680       }
37681     }
37682     return result;
37683   };
37684   uiCmd.display = function(code) {
37685     if (code.length !== 1)
37686       return code;
37687     var detected = utilDetect();
37688     var mac = detected.os === "mac";
37689     var replacements = {
37690       "\u2318": mac ? "\u2318 " + _t("shortcuts.key.cmd") : _t("shortcuts.key.ctrl"),
37691       "\u21E7": mac ? "\u21E7 " + _t("shortcuts.key.shift") : _t("shortcuts.key.shift"),
37692       "\u2325": mac ? "\u2325 " + _t("shortcuts.key.option") : _t("shortcuts.key.alt"),
37693       "\u2303": mac ? "\u2303 " + _t("shortcuts.key.ctrl") : _t("shortcuts.key.ctrl"),
37694       "\u232B": mac ? "\u232B " + _t("shortcuts.key.delete") : _t("shortcuts.key.backspace"),
37695       "\u2326": mac ? "\u2326 " + _t("shortcuts.key.del") : _t("shortcuts.key.del"),
37696       "\u2196": mac ? "\u2196 " + _t("shortcuts.key.pgup") : _t("shortcuts.key.pgup"),
37697       "\u2198": mac ? "\u2198 " + _t("shortcuts.key.pgdn") : _t("shortcuts.key.pgdn"),
37698       "\u21DE": mac ? "\u21DE " + _t("shortcuts.key.home") : _t("shortcuts.key.home"),
37699       "\u21DF": mac ? "\u21DF " + _t("shortcuts.key.end") : _t("shortcuts.key.end"),
37700       "\u21B5": mac ? "\u23CE " + _t("shortcuts.key.return") : _t("shortcuts.key.enter"),
37701       "\u238B": mac ? "\u238B " + _t("shortcuts.key.esc") : _t("shortcuts.key.esc"),
37702       "\u2630": mac ? "\u2630 " + _t("shortcuts.key.menu") : _t("shortcuts.key.menu")
37703     };
37704     return replacements[code] || code;
37705   };
37706
37707   // modules/operations/delete.js
37708   function operationDelete(context, selectedIDs) {
37709     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37710     var action = actionDeleteMultiple(selectedIDs);
37711     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37712     var coords = nodes.map(function(n3) {
37713       return n3.loc;
37714     });
37715     var extent = utilTotalExtent(selectedIDs, context.graph());
37716     var operation2 = function() {
37717       var nextSelectedID;
37718       var nextSelectedLoc;
37719       if (selectedIDs.length === 1) {
37720         var id2 = selectedIDs[0];
37721         var entity = context.entity(id2);
37722         var geometry = entity.geometry(context.graph());
37723         var parents = context.graph().parentWays(entity);
37724         var parent = parents[0];
37725         if (geometry === "vertex") {
37726           var nodes2 = parent.nodes;
37727           var i3 = nodes2.indexOf(id2);
37728           if (i3 === 0) {
37729             i3++;
37730           } else if (i3 === nodes2.length - 1) {
37731             i3--;
37732           } else {
37733             var a2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 - 1]).loc);
37734             var b2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 + 1]).loc);
37735             i3 = a2 < b2 ? i3 - 1 : i3 + 1;
37736           }
37737           nextSelectedID = nodes2[i3];
37738           nextSelectedLoc = context.entity(nextSelectedID).loc;
37739         }
37740       }
37741       context.perform(action, operation2.annotation());
37742       context.validator().validate();
37743       if (nextSelectedID && nextSelectedLoc) {
37744         if (context.hasEntity(nextSelectedID)) {
37745           context.enter(modeSelect(context, [nextSelectedID]).follow(true));
37746         } else {
37747           context.map().centerEase(nextSelectedLoc);
37748           context.enter(modeBrowse(context));
37749         }
37750       } else {
37751         context.enter(modeBrowse(context));
37752       }
37753     };
37754     operation2.available = function() {
37755       return true;
37756     };
37757     operation2.disabled = function() {
37758       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37759         return "too_large";
37760       } else if (someMissing()) {
37761         return "not_downloaded";
37762       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37763         return "connected_to_hidden";
37764       } else if (selectedIDs.some(protectedMember)) {
37765         return "part_of_relation";
37766       } else if (selectedIDs.some(incompleteRelation)) {
37767         return "incomplete_relation";
37768       } else if (selectedIDs.some(hasWikidataTag)) {
37769         return "has_wikidata_tag";
37770       }
37771       return false;
37772       function someMissing() {
37773         if (context.inIntro())
37774           return false;
37775         var osm = context.connection();
37776         if (osm) {
37777           var missing = coords.filter(function(loc) {
37778             return !osm.isDataLoaded(loc);
37779           });
37780           if (missing.length) {
37781             missing.forEach(function(loc) {
37782               context.loadTileAtLoc(loc);
37783             });
37784             return true;
37785           }
37786         }
37787         return false;
37788       }
37789       function hasWikidataTag(id2) {
37790         var entity = context.entity(id2);
37791         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
37792       }
37793       function incompleteRelation(id2) {
37794         var entity = context.entity(id2);
37795         return entity.type === "relation" && !entity.isComplete(context.graph());
37796       }
37797       function protectedMember(id2) {
37798         var entity = context.entity(id2);
37799         if (entity.type !== "way")
37800           return false;
37801         var parents = context.graph().parentRelations(entity);
37802         for (var i3 = 0; i3 < parents.length; i3++) {
37803           var parent = parents[i3];
37804           var type2 = parent.tags.type;
37805           var role = parent.memberById(id2).role || "outer";
37806           if (type2 === "route" || type2 === "boundary" || type2 === "multipolygon" && role === "outer") {
37807             return true;
37808           }
37809         }
37810         return false;
37811       }
37812     };
37813     operation2.tooltip = function() {
37814       var disable = operation2.disabled();
37815       return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi);
37816     };
37817     operation2.annotation = function() {
37818       return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length });
37819     };
37820     operation2.id = "delete";
37821     operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")];
37822     operation2.title = _t.append("operations.delete.title");
37823     operation2.behavior = behaviorOperation(context).which(operation2);
37824     return operation2;
37825   }
37826
37827   // modules/operations/orthogonalize.js
37828   function operationOrthogonalize(context, selectedIDs) {
37829     var _extent;
37830     var _type;
37831     var _actions = selectedIDs.map(chooseAction).filter(Boolean);
37832     var _amount = _actions.length === 1 ? "single" : "multiple";
37833     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37834       return n3.loc;
37835     });
37836     function chooseAction(entityID) {
37837       var entity = context.entity(entityID);
37838       var geometry = entity.geometry(context.graph());
37839       if (!_extent) {
37840         _extent = entity.extent(context.graph());
37841       } else {
37842         _extent = _extent.extend(entity.extent(context.graph()));
37843       }
37844       if (entity.type === "way" && new Set(entity.nodes).size > 2) {
37845         if (_type && _type !== "feature")
37846           return null;
37847         _type = "feature";
37848         return actionOrthogonalize(entityID, context.projection);
37849       } else if (geometry === "vertex") {
37850         if (_type && _type !== "corner")
37851           return null;
37852         _type = "corner";
37853         var graph = context.graph();
37854         var parents = graph.parentWays(entity);
37855         if (parents.length === 1) {
37856           var way = parents[0];
37857           if (way.nodes.indexOf(entityID) !== -1) {
37858             return actionOrthogonalize(way.id, context.projection, entityID);
37859           }
37860         }
37861       }
37862       return null;
37863     }
37864     var operation2 = function() {
37865       if (!_actions.length)
37866         return;
37867       var combinedAction = function(graph, t2) {
37868         _actions.forEach(function(action) {
37869           if (!action.disabled(graph)) {
37870             graph = action(graph, t2);
37871           }
37872         });
37873         return graph;
37874       };
37875       combinedAction.transitionable = true;
37876       context.perform(combinedAction, operation2.annotation());
37877       window.setTimeout(function() {
37878         context.validator().validate();
37879       }, 300);
37880     };
37881     operation2.available = function() {
37882       return _actions.length && selectedIDs.length === _actions.length;
37883     };
37884     operation2.disabled = function() {
37885       if (!_actions.length)
37886         return "";
37887       var actionDisableds = _actions.map(function(action) {
37888         return action.disabled(context.graph());
37889       }).filter(Boolean);
37890       if (actionDisableds.length === _actions.length) {
37891         if (new Set(actionDisableds).size > 1) {
37892           return "multiple_blockers";
37893         }
37894         return actionDisableds[0];
37895       } else if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
37896         return "too_large";
37897       } else if (someMissing()) {
37898         return "not_downloaded";
37899       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37900         return "connected_to_hidden";
37901       }
37902       return false;
37903       function someMissing() {
37904         if (context.inIntro())
37905           return false;
37906         var osm = context.connection();
37907         if (osm) {
37908           var missing = _coords.filter(function(loc) {
37909             return !osm.isDataLoaded(loc);
37910           });
37911           if (missing.length) {
37912             missing.forEach(function(loc) {
37913               context.loadTileAtLoc(loc);
37914             });
37915             return true;
37916           }
37917         }
37918         return false;
37919       }
37920     };
37921     operation2.tooltip = function() {
37922       var disable = operation2.disabled();
37923       return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount);
37924     };
37925     operation2.annotation = function() {
37926       return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length });
37927     };
37928     operation2.id = "orthogonalize";
37929     operation2.keys = [_t("operations.orthogonalize.key")];
37930     operation2.title = _t.append("operations.orthogonalize.title");
37931     operation2.behavior = behaviorOperation(context).which(operation2);
37932     return operation2;
37933   }
37934
37935   // modules/operations/reflect.js
37936   function operationReflectShort(context, selectedIDs) {
37937     return operationReflect(context, selectedIDs, "short");
37938   }
37939   function operationReflectLong(context, selectedIDs) {
37940     return operationReflect(context, selectedIDs, "long");
37941   }
37942   function operationReflect(context, selectedIDs, axis) {
37943     axis = axis || "long";
37944     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37945     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37946     var coords = nodes.map(function(n3) {
37947       return n3.loc;
37948     });
37949     var extent = utilTotalExtent(selectedIDs, context.graph());
37950     var operation2 = function() {
37951       var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long"));
37952       context.perform(action, operation2.annotation());
37953       window.setTimeout(function() {
37954         context.validator().validate();
37955       }, 300);
37956     };
37957     operation2.available = function() {
37958       return nodes.length >= 3;
37959     };
37960     operation2.disabled = function() {
37961       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37962         return "too_large";
37963       } else if (someMissing()) {
37964         return "not_downloaded";
37965       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37966         return "connected_to_hidden";
37967       } else if (selectedIDs.some(incompleteRelation)) {
37968         return "incomplete_relation";
37969       }
37970       return false;
37971       function someMissing() {
37972         if (context.inIntro())
37973           return false;
37974         var osm = context.connection();
37975         if (osm) {
37976           var missing = coords.filter(function(loc) {
37977             return !osm.isDataLoaded(loc);
37978           });
37979           if (missing.length) {
37980             missing.forEach(function(loc) {
37981               context.loadTileAtLoc(loc);
37982             });
37983             return true;
37984           }
37985         }
37986         return false;
37987       }
37988       function incompleteRelation(id2) {
37989         var entity = context.entity(id2);
37990         return entity.type === "relation" && !entity.isComplete(context.graph());
37991       }
37992     };
37993     operation2.tooltip = function() {
37994       var disable = operation2.disabled();
37995       return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi);
37996     };
37997     operation2.annotation = function() {
37998       return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length });
37999     };
38000     operation2.id = "reflect-" + axis;
38001     operation2.keys = [_t("operations.reflect.key." + axis)];
38002     operation2.title = _t.append("operations.reflect.title." + axis);
38003     operation2.behavior = behaviorOperation(context).which(operation2);
38004     return operation2;
38005   }
38006
38007   // modules/operations/move.js
38008   function operationMove(context, selectedIDs) {
38009     var multi = selectedIDs.length === 1 ? "single" : "multiple";
38010     var nodes = utilGetAllNodes(selectedIDs, context.graph());
38011     var coords = nodes.map(function(n3) {
38012       return n3.loc;
38013     });
38014     var extent = utilTotalExtent(selectedIDs, context.graph());
38015     var operation2 = function() {
38016       context.enter(modeMove(context, selectedIDs));
38017     };
38018     operation2.available = function() {
38019       return selectedIDs.length > 0;
38020     };
38021     operation2.disabled = function() {
38022       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38023         return "too_large";
38024       } else if (someMissing()) {
38025         return "not_downloaded";
38026       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38027         return "connected_to_hidden";
38028       } else if (selectedIDs.some(incompleteRelation)) {
38029         return "incomplete_relation";
38030       }
38031       return false;
38032       function someMissing() {
38033         if (context.inIntro())
38034           return false;
38035         var osm = context.connection();
38036         if (osm) {
38037           var missing = coords.filter(function(loc) {
38038             return !osm.isDataLoaded(loc);
38039           });
38040           if (missing.length) {
38041             missing.forEach(function(loc) {
38042               context.loadTileAtLoc(loc);
38043             });
38044             return true;
38045           }
38046         }
38047         return false;
38048       }
38049       function incompleteRelation(id2) {
38050         var entity = context.entity(id2);
38051         return entity.type === "relation" && !entity.isComplete(context.graph());
38052       }
38053     };
38054     operation2.tooltip = function() {
38055       var disable = operation2.disabled();
38056       return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi);
38057     };
38058     operation2.annotation = function() {
38059       return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length });
38060     };
38061     operation2.id = "move";
38062     operation2.keys = [_t("operations.move.key")];
38063     operation2.title = _t.append("operations.move.title");
38064     operation2.behavior = behaviorOperation(context).which(operation2);
38065     operation2.mouseOnly = true;
38066     return operation2;
38067   }
38068
38069   // modules/modes/rotate.js
38070   function modeRotate(context, entityIDs) {
38071     var _tolerancePx = 4;
38072     var mode = {
38073       id: "rotate",
38074       button: "browse"
38075     };
38076     var keybinding = utilKeybinding("rotate");
38077     var behaviors = [
38078       behaviorEdit(context),
38079       operationCircularize(context, entityIDs).behavior,
38080       operationDelete(context, entityIDs).behavior,
38081       operationMove(context, entityIDs).behavior,
38082       operationOrthogonalize(context, entityIDs).behavior,
38083       operationReflectLong(context, entityIDs).behavior,
38084       operationReflectShort(context, entityIDs).behavior
38085     ];
38086     var annotation = entityIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.rotate.annotation.feature", { n: entityIDs.length });
38087     var _prevGraph;
38088     var _prevAngle;
38089     var _prevTransform;
38090     var _pivot;
38091     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38092     function doRotate(d3_event) {
38093       var fn;
38094       if (context.graph() !== _prevGraph) {
38095         fn = context.perform;
38096       } else {
38097         fn = context.replace;
38098       }
38099       var projection2 = context.projection;
38100       var currTransform = projection2.transform();
38101       if (!_prevTransform || currTransform.k !== _prevTransform.k || currTransform.x !== _prevTransform.x || currTransform.y !== _prevTransform.y) {
38102         var nodes = utilGetAllNodes(entityIDs, context.graph());
38103         var points = nodes.map(function(n3) {
38104           return projection2(n3.loc);
38105         });
38106         _pivot = getPivot(points);
38107         _prevAngle = void 0;
38108       }
38109       var currMouse = context.map().mouse(d3_event);
38110       var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
38111       if (typeof _prevAngle === "undefined")
38112         _prevAngle = currAngle;
38113       var delta = currAngle - _prevAngle;
38114       fn(actionRotate(entityIDs, _pivot, delta, projection2));
38115       _prevTransform = currTransform;
38116       _prevAngle = currAngle;
38117       _prevGraph = context.graph();
38118     }
38119     function getPivot(points) {
38120       var _pivot2;
38121       if (points.length === 1) {
38122         _pivot2 = points[0];
38123       } else if (points.length === 2) {
38124         _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38125       } else {
38126         var polygonHull = hull_default(points);
38127         if (polygonHull.length === 2) {
38128           _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38129         } else {
38130           _pivot2 = centroid_default2(hull_default(points));
38131         }
38132       }
38133       return _pivot2;
38134     }
38135     function finish(d3_event) {
38136       d3_event.stopPropagation();
38137       context.replace(actionNoop(), annotation);
38138       context.enter(modeSelect(context, entityIDs));
38139     }
38140     function cancel() {
38141       if (_prevGraph)
38142         context.pop();
38143       context.enter(modeSelect(context, entityIDs));
38144     }
38145     function undone() {
38146       context.enter(modeBrowse(context));
38147     }
38148     mode.enter = function() {
38149       _prevGraph = null;
38150       context.features().forceVisible(entityIDs);
38151       behaviors.forEach(context.install);
38152       var downEvent;
38153       context.surface().on(_pointerPrefix + "down.modeRotate", function(d3_event) {
38154         downEvent = d3_event;
38155       });
38156       select_default2(window).on(_pointerPrefix + "move.modeRotate", doRotate, true).on(_pointerPrefix + "up.modeRotate", function(d3_event) {
38157         if (!downEvent)
38158           return;
38159         var mapNode = context.container().select(".main-map").node();
38160         var pointGetter = utilFastMouse(mapNode);
38161         var p1 = pointGetter(downEvent);
38162         var p2 = pointGetter(d3_event);
38163         var dist = geoVecLength(p1, p2);
38164         if (dist <= _tolerancePx)
38165           finish(d3_event);
38166         downEvent = null;
38167       }, true);
38168       context.history().on("undone.modeRotate", undone);
38169       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38170       select_default2(document).call(keybinding);
38171     };
38172     mode.exit = function() {
38173       behaviors.forEach(context.uninstall);
38174       context.surface().on(_pointerPrefix + "down.modeRotate", null);
38175       select_default2(window).on(_pointerPrefix + "move.modeRotate", null, true).on(_pointerPrefix + "up.modeRotate", null, true);
38176       context.history().on("undone.modeRotate", null);
38177       select_default2(document).call(keybinding.unbind);
38178       context.features().forceVisible([]);
38179     };
38180     mode.selectedIDs = function() {
38181       if (!arguments.length)
38182         return entityIDs;
38183       return mode;
38184     };
38185     return mode;
38186   }
38187
38188   // modules/operations/rotate.js
38189   function operationRotate(context, selectedIDs) {
38190     var multi = selectedIDs.length === 1 ? "single" : "multiple";
38191     var nodes = utilGetAllNodes(selectedIDs, context.graph());
38192     var coords = nodes.map(function(n3) {
38193       return n3.loc;
38194     });
38195     var extent = utilTotalExtent(selectedIDs, context.graph());
38196     var operation2 = function() {
38197       context.enter(modeRotate(context, selectedIDs));
38198     };
38199     operation2.available = function() {
38200       return nodes.length >= 2;
38201     };
38202     operation2.disabled = function() {
38203       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38204         return "too_large";
38205       } else if (someMissing()) {
38206         return "not_downloaded";
38207       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38208         return "connected_to_hidden";
38209       } else if (selectedIDs.some(incompleteRelation)) {
38210         return "incomplete_relation";
38211       }
38212       return false;
38213       function someMissing() {
38214         if (context.inIntro())
38215           return false;
38216         var osm = context.connection();
38217         if (osm) {
38218           var missing = coords.filter(function(loc) {
38219             return !osm.isDataLoaded(loc);
38220           });
38221           if (missing.length) {
38222             missing.forEach(function(loc) {
38223               context.loadTileAtLoc(loc);
38224             });
38225             return true;
38226           }
38227         }
38228         return false;
38229       }
38230       function incompleteRelation(id2) {
38231         var entity = context.entity(id2);
38232         return entity.type === "relation" && !entity.isComplete(context.graph());
38233       }
38234     };
38235     operation2.tooltip = function() {
38236       var disable = operation2.disabled();
38237       return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi);
38238     };
38239     operation2.annotation = function() {
38240       return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length });
38241     };
38242     operation2.id = "rotate";
38243     operation2.keys = [_t("operations.rotate.key")];
38244     operation2.title = _t.append("operations.rotate.title");
38245     operation2.behavior = behaviorOperation(context).which(operation2);
38246     operation2.mouseOnly = true;
38247     return operation2;
38248   }
38249
38250   // modules/modes/move.js
38251   function modeMove(context, entityIDs, baseGraph) {
38252     var _tolerancePx = 4;
38253     var mode = {
38254       id: "move",
38255       button: "browse"
38256     };
38257     var keybinding = utilKeybinding("move");
38258     var behaviors = [
38259       behaviorEdit(context),
38260       operationCircularize(context, entityIDs).behavior,
38261       operationDelete(context, entityIDs).behavior,
38262       operationOrthogonalize(context, entityIDs).behavior,
38263       operationReflectLong(context, entityIDs).behavior,
38264       operationReflectShort(context, entityIDs).behavior,
38265       operationRotate(context, entityIDs).behavior
38266     ];
38267     var annotation = entityIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.move.annotation.feature", { n: entityIDs.length });
38268     var _prevGraph;
38269     var _cache5;
38270     var _origin;
38271     var _nudgeInterval;
38272     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38273     function doMove(nudge) {
38274       nudge = nudge || [0, 0];
38275       var fn;
38276       if (_prevGraph !== context.graph()) {
38277         _cache5 = {};
38278         _origin = context.map().mouseCoordinates();
38279         fn = context.perform;
38280       } else {
38281         fn = context.overwrite;
38282       }
38283       var currMouse = context.map().mouse();
38284       var origMouse = context.projection(_origin);
38285       var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
38286       fn(actionMove(entityIDs, delta, context.projection, _cache5));
38287       _prevGraph = context.graph();
38288     }
38289     function startNudge(nudge) {
38290       if (_nudgeInterval)
38291         window.clearInterval(_nudgeInterval);
38292       _nudgeInterval = window.setInterval(function() {
38293         context.map().pan(nudge);
38294         doMove(nudge);
38295       }, 50);
38296     }
38297     function stopNudge() {
38298       if (_nudgeInterval) {
38299         window.clearInterval(_nudgeInterval);
38300         _nudgeInterval = null;
38301       }
38302     }
38303     function move() {
38304       doMove();
38305       var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
38306       if (nudge) {
38307         startNudge(nudge);
38308       } else {
38309         stopNudge();
38310       }
38311     }
38312     function finish(d3_event) {
38313       d3_event.stopPropagation();
38314       context.replace(actionNoop(), annotation);
38315       context.enter(modeSelect(context, entityIDs));
38316       stopNudge();
38317     }
38318     function cancel() {
38319       if (baseGraph) {
38320         while (context.graph() !== baseGraph)
38321           context.pop();
38322         context.enter(modeBrowse(context));
38323       } else {
38324         if (_prevGraph)
38325           context.pop();
38326         context.enter(modeSelect(context, entityIDs));
38327       }
38328       stopNudge();
38329     }
38330     function undone() {
38331       context.enter(modeBrowse(context));
38332     }
38333     mode.enter = function() {
38334       _origin = context.map().mouseCoordinates();
38335       _prevGraph = null;
38336       _cache5 = {};
38337       context.features().forceVisible(entityIDs);
38338       behaviors.forEach(context.install);
38339       var downEvent;
38340       context.surface().on(_pointerPrefix + "down.modeMove", function(d3_event) {
38341         downEvent = d3_event;
38342       });
38343       select_default2(window).on(_pointerPrefix + "move.modeMove", move, true).on(_pointerPrefix + "up.modeMove", function(d3_event) {
38344         if (!downEvent)
38345           return;
38346         var mapNode = context.container().select(".main-map").node();
38347         var pointGetter = utilFastMouse(mapNode);
38348         var p1 = pointGetter(downEvent);
38349         var p2 = pointGetter(d3_event);
38350         var dist = geoVecLength(p1, p2);
38351         if (dist <= _tolerancePx)
38352           finish(d3_event);
38353         downEvent = null;
38354       }, true);
38355       context.history().on("undone.modeMove", undone);
38356       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38357       select_default2(document).call(keybinding);
38358     };
38359     mode.exit = function() {
38360       stopNudge();
38361       behaviors.forEach(function(behavior) {
38362         context.uninstall(behavior);
38363       });
38364       context.surface().on(_pointerPrefix + "down.modeMove", null);
38365       select_default2(window).on(_pointerPrefix + "move.modeMove", null, true).on(_pointerPrefix + "up.modeMove", null, true);
38366       context.history().on("undone.modeMove", null);
38367       select_default2(document).call(keybinding.unbind);
38368       context.features().forceVisible([]);
38369     };
38370     mode.selectedIDs = function() {
38371       if (!arguments.length)
38372         return entityIDs;
38373       return mode;
38374     };
38375     return mode;
38376   }
38377
38378   // modules/behavior/paste.js
38379   function behaviorPaste(context) {
38380     function doPaste(d3_event) {
38381       if (!context.map().withinEditableZoom())
38382         return;
38383       d3_event.preventDefault();
38384       var baseGraph = context.graph();
38385       var mouse = context.map().mouse();
38386       var projection2 = context.projection;
38387       var viewport = geoExtent(projection2.clipExtent()).polygon();
38388       if (!geoPointInPolygon(mouse, viewport))
38389         return;
38390       var oldIDs = context.copyIDs();
38391       if (!oldIDs.length)
38392         return;
38393       var extent = geoExtent();
38394       var oldGraph = context.copyGraph();
38395       var newIDs = [];
38396       var action = actionCopyEntities(oldIDs, oldGraph);
38397       context.perform(action);
38398       var copies = action.copies();
38399       var originals = /* @__PURE__ */ new Set();
38400       Object.values(copies).forEach(function(entity) {
38401         originals.add(entity.id);
38402       });
38403       for (var id2 in copies) {
38404         var oldEntity = oldGraph.entity(id2);
38405         var newEntity = copies[id2];
38406         extent._extend(oldEntity.extent(oldGraph));
38407         var parents = context.graph().parentWays(newEntity);
38408         var parentCopied = parents.some(function(parent) {
38409           return originals.has(parent.id);
38410         });
38411         if (!parentCopied) {
38412           newIDs.push(newEntity.id);
38413         }
38414       }
38415       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
38416       var delta = geoVecSubtract(mouse, copyPoint);
38417       context.perform(actionMove(newIDs, delta, projection2));
38418       context.enter(modeMove(context, newIDs, baseGraph));
38419     }
38420     function behavior() {
38421       context.keybinding().on(uiCmd("\u2318V"), doPaste);
38422       return behavior;
38423     }
38424     behavior.off = function() {
38425       context.keybinding().off(uiCmd("\u2318V"));
38426     };
38427     return behavior;
38428   }
38429
38430   // modules/behavior/drag.js
38431   function behaviorDrag() {
38432     var dispatch14 = dispatch_default("start", "move", "end");
38433     var _tolerancePx = 1;
38434     var _penTolerancePx = 4;
38435     var _origin = null;
38436     var _selector = "";
38437     var _targetNode;
38438     var _targetEntity;
38439     var _surface;
38440     var _pointerId;
38441     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38442     var d3_event_userSelectProperty = utilPrefixCSSProperty("UserSelect");
38443     var d3_event_userSelectSuppress = function() {
38444       var selection2 = selection_default();
38445       var select = selection2.style(d3_event_userSelectProperty);
38446       selection2.style(d3_event_userSelectProperty, "none");
38447       return function() {
38448         selection2.style(d3_event_userSelectProperty, select);
38449       };
38450     };
38451     function pointerdown(d3_event) {
38452       if (_pointerId)
38453         return;
38454       _pointerId = d3_event.pointerId || "mouse";
38455       _targetNode = this;
38456       var pointerLocGetter = utilFastMouse(_surface || _targetNode.parentNode);
38457       var offset;
38458       var startOrigin = pointerLocGetter(d3_event);
38459       var started = false;
38460       var selectEnable = d3_event_userSelectSuppress();
38461       select_default2(window).on(_pointerPrefix + "move.drag", pointermove).on(_pointerPrefix + "up.drag pointercancel.drag", pointerup, true);
38462       if (_origin) {
38463         offset = _origin.call(_targetNode, _targetEntity);
38464         offset = [offset[0] - startOrigin[0], offset[1] - startOrigin[1]];
38465       } else {
38466         offset = [0, 0];
38467       }
38468       d3_event.stopPropagation();
38469       function pointermove(d3_event2) {
38470         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38471           return;
38472         var p2 = pointerLocGetter(d3_event2);
38473         if (!started) {
38474           var dist = geoVecLength(startOrigin, p2);
38475           var tolerance = d3_event2.pointerType === "pen" ? _penTolerancePx : _tolerancePx;
38476           if (dist < tolerance)
38477             return;
38478           started = true;
38479           dispatch14.call("start", this, d3_event2, _targetEntity);
38480         } else {
38481           startOrigin = p2;
38482           d3_event2.stopPropagation();
38483           d3_event2.preventDefault();
38484           var dx = p2[0] - startOrigin[0];
38485           var dy = p2[1] - startOrigin[1];
38486           dispatch14.call("move", this, d3_event2, _targetEntity, [p2[0] + offset[0], p2[1] + offset[1]], [dx, dy]);
38487         }
38488       }
38489       function pointerup(d3_event2) {
38490         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38491           return;
38492         _pointerId = null;
38493         if (started) {
38494           dispatch14.call("end", this, d3_event2, _targetEntity);
38495           d3_event2.preventDefault();
38496         }
38497         select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38498         selectEnable();
38499       }
38500     }
38501     function behavior(selection2) {
38502       var matchesSelector = utilPrefixDOMProperty("matchesSelector");
38503       var delegate = pointerdown;
38504       if (_selector) {
38505         delegate = function(d3_event) {
38506           var root3 = this;
38507           var target = d3_event.target;
38508           for (; target && target !== root3; target = target.parentNode) {
38509             var datum2 = target.__data__;
38510             _targetEntity = datum2 instanceof osmNote ? datum2 : datum2 && datum2.properties && datum2.properties.entity;
38511             if (_targetEntity && target[matchesSelector](_selector)) {
38512               return pointerdown.call(target, d3_event);
38513             }
38514           }
38515         };
38516       }
38517       selection2.on(_pointerPrefix + "down.drag" + _selector, delegate);
38518     }
38519     behavior.off = function(selection2) {
38520       selection2.on(_pointerPrefix + "down.drag" + _selector, null);
38521     };
38522     behavior.selector = function(_2) {
38523       if (!arguments.length)
38524         return _selector;
38525       _selector = _2;
38526       return behavior;
38527     };
38528     behavior.origin = function(_2) {
38529       if (!arguments.length)
38530         return _origin;
38531       _origin = _2;
38532       return behavior;
38533     };
38534     behavior.cancel = function() {
38535       select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38536       return behavior;
38537     };
38538     behavior.targetNode = function(_2) {
38539       if (!arguments.length)
38540         return _targetNode;
38541       _targetNode = _2;
38542       return behavior;
38543     };
38544     behavior.targetEntity = function(_2) {
38545       if (!arguments.length)
38546         return _targetEntity;
38547       _targetEntity = _2;
38548       return behavior;
38549     };
38550     behavior.surface = function(_2) {
38551       if (!arguments.length)
38552         return _surface;
38553       _surface = _2;
38554       return behavior;
38555     };
38556     return utilRebind(behavior, dispatch14, "on");
38557   }
38558
38559   // modules/modes/drag_node.js
38560   function modeDragNode(context) {
38561     var mode = {
38562       id: "drag-node",
38563       button: "browse"
38564     };
38565     var hover = behaviorHover(context).altDisables(true).on("hover", context.ui().sidebar.hover);
38566     var edit2 = behaviorEdit(context);
38567     var _nudgeInterval;
38568     var _restoreSelectedIDs = [];
38569     var _wasMidpoint = false;
38570     var _isCancelled = false;
38571     var _activeEntity;
38572     var _startLoc;
38573     var _lastLoc;
38574     function startNudge(d3_event, entity, nudge) {
38575       if (_nudgeInterval)
38576         window.clearInterval(_nudgeInterval);
38577       _nudgeInterval = window.setInterval(function() {
38578         context.map().pan(nudge);
38579         doMove(d3_event, entity, nudge);
38580       }, 50);
38581     }
38582     function stopNudge() {
38583       if (_nudgeInterval) {
38584         window.clearInterval(_nudgeInterval);
38585         _nudgeInterval = null;
38586       }
38587     }
38588     function moveAnnotation(entity) {
38589       return _t("operations.move.annotation." + entity.geometry(context.graph()));
38590     }
38591     function connectAnnotation(nodeEntity, targetEntity) {
38592       var nodeGeometry = nodeEntity.geometry(context.graph());
38593       var targetGeometry = targetEntity.geometry(context.graph());
38594       if (nodeGeometry === "vertex" && targetGeometry === "vertex") {
38595         var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
38596         var targetParentWayIDs = context.graph().parentWays(targetEntity);
38597         var sharedParentWays = utilArrayIntersection(nodeParentWayIDs, targetParentWayIDs);
38598         if (sharedParentWays.length !== 0) {
38599           if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
38600             return _t("operations.connect.annotation.from_vertex.to_adjacent_vertex");
38601           }
38602           return _t("operations.connect.annotation.from_vertex.to_sibling_vertex");
38603         }
38604       }
38605       return _t("operations.connect.annotation.from_" + nodeGeometry + ".to_" + targetGeometry);
38606     }
38607     function shouldSnapToNode(target) {
38608       if (!_activeEntity)
38609         return false;
38610       return _activeEntity.geometry(context.graph()) !== "vertex" || (target.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(target, context.graph()));
38611     }
38612     function origin(entity) {
38613       return context.projection(entity.loc);
38614     }
38615     function keydown(d3_event) {
38616       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38617         if (context.surface().classed("nope")) {
38618           context.surface().classed("nope-suppressed", true);
38619         }
38620         context.surface().classed("nope", false).classed("nope-disabled", true);
38621       }
38622     }
38623     function keyup(d3_event) {
38624       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38625         if (context.surface().classed("nope-suppressed")) {
38626           context.surface().classed("nope", true);
38627         }
38628         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
38629       }
38630     }
38631     function start2(d3_event, entity) {
38632       _wasMidpoint = entity.type === "midpoint";
38633       var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
38634       _isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
38635       if (_isCancelled) {
38636         if (hasHidden) {
38637           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("modes.drag_node.connected_to_hidden"))();
38638         }
38639         return drag.cancel();
38640       }
38641       if (_wasMidpoint) {
38642         var midpoint = entity;
38643         entity = osmNode();
38644         context.perform(actionAddMidpoint(midpoint, entity));
38645         entity = context.entity(entity.id);
38646         var vertex = context.surface().selectAll("." + entity.id);
38647         drag.targetNode(vertex.node()).targetEntity(entity);
38648       } else {
38649         context.perform(actionNoop());
38650       }
38651       _activeEntity = entity;
38652       _startLoc = entity.loc;
38653       hover.ignoreVertex(entity.geometry(context.graph()) === "vertex");
38654       context.surface().selectAll("." + _activeEntity.id).classed("active", true);
38655       context.enter(mode);
38656     }
38657     function datum2(d3_event) {
38658       if (!d3_event || d3_event.altKey) {
38659         return {};
38660       } else {
38661         var d2 = d3_event.target.__data__;
38662         return d2 && d2.properties && d2.properties.target ? d2 : {};
38663       }
38664     }
38665     function doMove(d3_event, entity, nudge) {
38666       nudge = nudge || [0, 0];
38667       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
38668       var currMouse = geoVecSubtract(currPoint, nudge);
38669       var loc = context.projection.invert(currMouse);
38670       var target, edge;
38671       if (!_nudgeInterval) {
38672         var d2 = datum2(d3_event);
38673         target = d2 && d2.properties && d2.properties.entity;
38674         var targetLoc = target && target.loc;
38675         var targetNodes = d2 && d2.properties && d2.properties.nodes;
38676         if (targetLoc) {
38677           if (shouldSnapToNode(target)) {
38678             loc = targetLoc;
38679           }
38680         } else if (targetNodes) {
38681           edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
38682           if (edge) {
38683             loc = edge.loc;
38684           }
38685         }
38686       }
38687       context.replace(
38688         actionMoveNode(entity.id, loc)
38689       );
38690       var isInvalid = false;
38691       if (target) {
38692         isInvalid = hasRelationConflict(entity, target, edge, context.graph());
38693       }
38694       if (!isInvalid) {
38695         isInvalid = hasInvalidGeometry(entity, context.graph());
38696       }
38697       var nope = context.surface().classed("nope");
38698       if (isInvalid === "relation" || isInvalid === "restriction") {
38699         if (!nope) {
38700           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(
38701             "operations.connect." + isInvalid,
38702             { relation: _mainPresetIndex.item("type/restriction").name() }
38703           ))();
38704         }
38705       } else if (isInvalid) {
38706         var errorID = isInvalid === "line" ? "lines" : "areas";
38707         context.ui().flash.duration(3e3).iconName("#iD-icon-no").label(_t.append("self_intersection.error." + errorID))();
38708       } else {
38709         if (nope) {
38710           context.ui().flash.duration(1).label("")();
38711         }
38712       }
38713       var nopeDisabled = context.surface().classed("nope-disabled");
38714       if (nopeDisabled) {
38715         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
38716       } else {
38717         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
38718       }
38719       _lastLoc = loc;
38720     }
38721     function hasRelationConflict(entity, target, edge, graph) {
38722       var testGraph = graph.update();
38723       if (edge) {
38724         var midpoint = osmNode();
38725         var action = actionAddMidpoint({
38726           loc: edge.loc,
38727           edge: [target.nodes[edge.index - 1], target.nodes[edge.index]]
38728         }, midpoint);
38729         testGraph = action(testGraph);
38730         target = midpoint;
38731       }
38732       var ids = [entity.id, target.id];
38733       return actionConnect(ids).disabled(testGraph);
38734     }
38735     function hasInvalidGeometry(entity, graph) {
38736       var parents = graph.parentWays(entity);
38737       var i3, j2, k2;
38738       for (i3 = 0; i3 < parents.length; i3++) {
38739         var parent = parents[i3];
38740         var nodes = [];
38741         var activeIndex = null;
38742         var relations = graph.parentRelations(parent);
38743         for (j2 = 0; j2 < relations.length; j2++) {
38744           if (!relations[j2].isMultipolygon())
38745             continue;
38746           var rings = osmJoinWays(relations[j2].members, graph);
38747           for (k2 = 0; k2 < rings.length; k2++) {
38748             nodes = rings[k2].nodes;
38749             if (nodes.find(function(n3) {
38750               return n3.id === entity.id;
38751             })) {
38752               activeIndex = k2;
38753               if (geoHasSelfIntersections(nodes, entity.id)) {
38754                 return "multipolygonMember";
38755               }
38756             }
38757             rings[k2].coords = nodes.map(function(n3) {
38758               return n3.loc;
38759             });
38760           }
38761           for (k2 = 0; k2 < rings.length; k2++) {
38762             if (k2 === activeIndex)
38763               continue;
38764             if (geoHasLineIntersections(rings[activeIndex].nodes, rings[k2].nodes, entity.id)) {
38765               return "multipolygonRing";
38766             }
38767           }
38768         }
38769         if (activeIndex === null) {
38770           nodes = parent.nodes.map(function(nodeID) {
38771             return graph.entity(nodeID);
38772           });
38773           if (nodes.length && geoHasSelfIntersections(nodes, entity.id)) {
38774             return parent.geometry(graph);
38775           }
38776         }
38777       }
38778       return false;
38779     }
38780     function move(d3_event, entity, point2) {
38781       if (_isCancelled)
38782         return;
38783       d3_event.stopPropagation();
38784       context.surface().classed("nope-disabled", d3_event.altKey);
38785       _lastLoc = context.projection.invert(point2);
38786       doMove(d3_event, entity);
38787       var nudge = geoViewportEdge(point2, context.map().dimensions());
38788       if (nudge) {
38789         startNudge(d3_event, entity, nudge);
38790       } else {
38791         stopNudge();
38792       }
38793     }
38794     function end(d3_event, entity) {
38795       if (_isCancelled)
38796         return;
38797       var wasPoint = entity.geometry(context.graph()) === "point";
38798       var d2 = datum2(d3_event);
38799       var nope = d2 && d2.properties && d2.properties.nope || context.surface().classed("nope");
38800       var target = d2 && d2.properties && d2.properties.entity;
38801       if (nope) {
38802         context.perform(
38803           _actionBounceBack(entity.id, _startLoc)
38804         );
38805       } else if (target && target.type === "way") {
38806         var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
38807         context.replace(
38808           actionAddMidpoint({
38809             loc: choice.loc,
38810             edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
38811           }, entity),
38812           connectAnnotation(entity, target)
38813         );
38814       } else if (target && target.type === "node" && shouldSnapToNode(target)) {
38815         context.replace(
38816           actionConnect([target.id, entity.id]),
38817           connectAnnotation(entity, target)
38818         );
38819       } else if (_wasMidpoint) {
38820         context.replace(
38821           actionNoop(),
38822           _t("operations.add.annotation.vertex")
38823         );
38824       } else {
38825         context.replace(
38826           actionNoop(),
38827           moveAnnotation(entity)
38828         );
38829       }
38830       if (wasPoint) {
38831         context.enter(modeSelect(context, [entity.id]));
38832       } else {
38833         var reselection = _restoreSelectedIDs.filter(function(id2) {
38834           return context.graph().hasEntity(id2);
38835         });
38836         if (reselection.length) {
38837           context.enter(modeSelect(context, reselection));
38838         } else {
38839           context.enter(modeBrowse(context));
38840         }
38841       }
38842     }
38843     function _actionBounceBack(nodeID, toLoc) {
38844       var moveNode = actionMoveNode(nodeID, toLoc);
38845       var action = function(graph, t2) {
38846         if (t2 === 1)
38847           context.pop();
38848         return moveNode(graph, t2);
38849       };
38850       action.transitionable = true;
38851       return action;
38852     }
38853     function cancel() {
38854       drag.cancel();
38855       context.enter(modeBrowse(context));
38856     }
38857     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);
38858     mode.enter = function() {
38859       context.install(hover);
38860       context.install(edit2);
38861       select_default2(window).on("keydown.dragNode", keydown).on("keyup.dragNode", keyup);
38862       context.history().on("undone.drag-node", cancel);
38863     };
38864     mode.exit = function() {
38865       context.ui().sidebar.hover.cancel();
38866       context.uninstall(hover);
38867       context.uninstall(edit2);
38868       select_default2(window).on("keydown.dragNode", null).on("keyup.dragNode", null);
38869       context.history().on("undone.drag-node", null);
38870       _activeEntity = null;
38871       context.surface().classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false).selectAll(".active").classed("active", false);
38872       stopNudge();
38873     };
38874     mode.selectedIDs = function() {
38875       if (!arguments.length)
38876         return _activeEntity ? [_activeEntity.id] : [];
38877       return mode;
38878     };
38879     mode.activeID = function() {
38880       if (!arguments.length)
38881         return _activeEntity && _activeEntity.id;
38882       return mode;
38883     };
38884     mode.restoreSelectedIDs = function(_2) {
38885       if (!arguments.length)
38886         return _restoreSelectedIDs;
38887       _restoreSelectedIDs = _2;
38888       return mode;
38889     };
38890     mode.behavior = drag;
38891     return mode;
38892   }
38893
38894   // modules/services/keepRight.js
38895   var import_rbush = __toESM(require_rbush_min());
38896
38897   // node_modules/d3-fetch/src/text.js
38898   function responseText(response) {
38899     if (!response.ok)
38900       throw new Error(response.status + " " + response.statusText);
38901     return response.text();
38902   }
38903   function text_default3(input, init2) {
38904     return fetch(input, init2).then(responseText);
38905   }
38906
38907   // node_modules/d3-fetch/src/json.js
38908   function responseJson(response) {
38909     if (!response.ok)
38910       throw new Error(response.status + " " + response.statusText);
38911     if (response.status === 204 || response.status === 205)
38912       return;
38913     return response.json();
38914   }
38915   function json_default(input, init2) {
38916     return fetch(input, init2).then(responseJson);
38917   }
38918
38919   // node_modules/d3-fetch/src/xml.js
38920   function parser(type2) {
38921     return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2));
38922   }
38923   var xml_default = parser("application/xml");
38924   var html = parser("text/html");
38925   var svg = parser("image/svg+xml");
38926
38927   // modules/services/keepRight.js
38928   var tiler = utilTiler();
38929   var dispatch2 = dispatch_default("loaded");
38930   var _tileZoom = 14;
38931   var _krUrlRoot = "https://www.keepright.at";
38932   var _krData = { errorTypes: {}, localizeStrings: {} };
38933   var _cache;
38934   var _krRuleset = [
38935     // no 20 - multiple node on same spot - these are mostly boundaries overlapping roads
38936     30,
38937     40,
38938     50,
38939     60,
38940     70,
38941     90,
38942     100,
38943     110,
38944     120,
38945     130,
38946     150,
38947     160,
38948     170,
38949     180,
38950     190,
38951     191,
38952     192,
38953     193,
38954     194,
38955     195,
38956     196,
38957     197,
38958     198,
38959     200,
38960     201,
38961     202,
38962     203,
38963     204,
38964     205,
38965     206,
38966     207,
38967     208,
38968     210,
38969     220,
38970     230,
38971     231,
38972     232,
38973     270,
38974     280,
38975     281,
38976     282,
38977     283,
38978     284,
38979     285,
38980     290,
38981     291,
38982     292,
38983     293,
38984     294,
38985     295,
38986     296,
38987     297,
38988     298,
38989     300,
38990     310,
38991     311,
38992     312,
38993     313,
38994     320,
38995     350,
38996     360,
38997     370,
38998     380,
38999     390,
39000     400,
39001     401,
39002     402,
39003     410,
39004     411,
39005     412,
39006     413
39007   ];
39008   function abortRequest(controller) {
39009     if (controller) {
39010       controller.abort();
39011     }
39012   }
39013   function abortUnwantedRequests(cache, tiles) {
39014     Object.keys(cache.inflightTile).forEach((k2) => {
39015       const wanted = tiles.find((tile) => k2 === tile.id);
39016       if (!wanted) {
39017         abortRequest(cache.inflightTile[k2]);
39018         delete cache.inflightTile[k2];
39019       }
39020     });
39021   }
39022   function encodeIssueRtree(d2) {
39023     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39024   }
39025   function updateRtree(item, replace) {
39026     _cache.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39027     if (replace) {
39028       _cache.rtree.insert(item);
39029     }
39030   }
39031   function tokenReplacements(d2) {
39032     if (!(d2 instanceof QAItem))
39033       return;
39034     const replacements = {};
39035     const issueTemplate = _krData.errorTypes[d2.whichType];
39036     if (!issueTemplate) {
39037       console.log("No Template: ", d2.whichType);
39038       console.log("  ", d2.description);
39039       return;
39040     }
39041     if (!issueTemplate.regex)
39042       return;
39043     const errorRegex = new RegExp(issueTemplate.regex, "i");
39044     const errorMatch = errorRegex.exec(d2.description);
39045     if (!errorMatch) {
39046       console.log("Unmatched: ", d2.whichType);
39047       console.log("  ", d2.description);
39048       console.log("  ", errorRegex);
39049       return;
39050     }
39051     for (let i3 = 1; i3 < errorMatch.length; i3++) {
39052       let capture = errorMatch[i3];
39053       let idType;
39054       idType = "IDs" in issueTemplate ? issueTemplate.IDs[i3 - 1] : "";
39055       if (idType && capture) {
39056         capture = parseError(capture, idType);
39057       } else {
39058         const compare2 = capture.toLowerCase();
39059         if (_krData.localizeStrings[compare2]) {
39060           capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39061         } else {
39062           capture = unescape_default(capture);
39063         }
39064       }
39065       replacements["var" + i3] = capture;
39066     }
39067     return replacements;
39068   }
39069   function parseError(capture, idType) {
39070     const compare2 = capture.toLowerCase();
39071     if (_krData.localizeStrings[compare2]) {
39072       capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39073     }
39074     switch (idType) {
39075       case "this":
39076         capture = linkErrorObject2(capture);
39077         break;
39078       case "url":
39079         capture = linkURL(capture);
39080         break;
39081       case "n":
39082       case "w":
39083       case "r":
39084         capture = linkEntity2(idType + capture);
39085         break;
39086       case "20":
39087         capture = parse20(capture);
39088         break;
39089       case "211":
39090         capture = parse211(capture);
39091         break;
39092       case "231":
39093         capture = parse231(capture);
39094         break;
39095       case "294":
39096         capture = parse294(capture);
39097         break;
39098       case "370":
39099         capture = parse370(capture);
39100         break;
39101     }
39102     return capture;
39103     function linkErrorObject2(d2) {
39104       return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39105     }
39106     function linkEntity2(d2) {
39107       return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39108     }
39109     function linkURL(d2) {
39110       return { html: '<a class="kr_external_link" target="_blank" href="'.concat(d2, '">').concat(d2, "</a>") };
39111     }
39112     function parse211(capture2) {
39113       let newList = [];
39114       const items = capture2.split(", ");
39115       items.forEach((item) => {
39116         let id2 = linkEntity2("n" + item.slice(1));
39117         newList.push(id2);
39118       });
39119       return newList.join(", ");
39120     }
39121     function parse231(capture2) {
39122       let newList = [];
39123       const items = capture2.split("),");
39124       items.forEach((item) => {
39125         const match = item.match(/\#(\d+)\((.+)\)?/);
39126         if (match !== null && match.length > 2) {
39127           newList.push(
39128             linkEntity2("w" + match[1]) + " " + _t("QA.keepRight.errorTypes.231.layer", { layer: match[2] })
39129           );
39130         }
39131       });
39132       return newList.join(", ");
39133     }
39134     function parse294(capture2) {
39135       let newList = [];
39136       const items = capture2.split(",");
39137       items.forEach((item) => {
39138         item = item.split(" ");
39139         const role = '"'.concat(item[0], '"');
39140         const idType2 = item[1].slice(0, 1);
39141         let id2 = item[2].slice(1);
39142         id2 = linkEntity2(idType2 + id2);
39143         newList.push("".concat(role, " ").concat(item[1], " ").concat(id2));
39144       });
39145       return newList.join(", ");
39146     }
39147     function parse370(capture2) {
39148       if (!capture2)
39149         return "";
39150       const match = capture2.match(/\(including the name (\'.+\')\)/);
39151       if (match && match.length) {
39152         return _t("QA.keepRight.errorTypes.370.including_the_name", { name: match[1] });
39153       }
39154       return "";
39155     }
39156     function parse20(capture2) {
39157       let newList = [];
39158       const items = capture2.split(",");
39159       items.forEach((item) => {
39160         const id2 = linkEntity2("n" + item.slice(1));
39161         newList.push(id2);
39162       });
39163       return newList.join(", ");
39164     }
39165   }
39166   var keepRight_default = {
39167     title: "keepRight",
39168     init() {
39169       _mainFileFetcher.get("keepRight").then((d2) => _krData = d2);
39170       if (!_cache) {
39171         this.reset();
39172       }
39173       this.event = utilRebind(this, dispatch2, "on");
39174     },
39175     reset() {
39176       if (_cache) {
39177         Object.values(_cache.inflightTile).forEach(abortRequest);
39178       }
39179       _cache = {
39180         data: {},
39181         loadedTile: {},
39182         inflightTile: {},
39183         inflightPost: {},
39184         closed: {},
39185         rtree: new import_rbush.default()
39186       };
39187     },
39188     // KeepRight API:  http://osm.mueschelsoft.de/keepright/interfacing.php
39189     loadIssues(projection2) {
39190       const options2 = {
39191         format: "geojson",
39192         ch: _krRuleset
39193       };
39194       const tiles = tiler.zoomExtent([_tileZoom, _tileZoom]).getTiles(projection2);
39195       abortUnwantedRequests(_cache, tiles);
39196       tiles.forEach((tile) => {
39197         if (_cache.loadedTile[tile.id] || _cache.inflightTile[tile.id])
39198           return;
39199         const [left, top, right, bottom] = tile.extent.rectangle();
39200         const params = Object.assign({}, options2, { left, bottom, right, top });
39201         const url = "".concat(_krUrlRoot, "/export.php?") + utilQsString(params);
39202         const controller = new AbortController();
39203         _cache.inflightTile[tile.id] = controller;
39204         json_default(url, { signal: controller.signal }).then((data) => {
39205           delete _cache.inflightTile[tile.id];
39206           _cache.loadedTile[tile.id] = true;
39207           if (!data || !data.features || !data.features.length) {
39208             throw new Error("No Data");
39209           }
39210           data.features.forEach((feature3) => {
39211             const {
39212               properties: {
39213                 error_type: itemType,
39214                 error_id: id2,
39215                 comment = null,
39216                 object_id: objectId,
39217                 object_type: objectType,
39218                 schema,
39219                 title
39220               }
39221             } = feature3;
39222             let {
39223               geometry: { coordinates: loc },
39224               properties: { description = "" }
39225             } = feature3;
39226             const issueTemplate = _krData.errorTypes[itemType];
39227             const parentIssueType = (Math.floor(itemType / 10) * 10).toString();
39228             const whichType = issueTemplate ? itemType : parentIssueType;
39229             const whichTemplate = _krData.errorTypes[whichType];
39230             switch (whichType) {
39231               case "170":
39232                 description = "This feature has a FIXME tag: ".concat(description);
39233                 break;
39234               case "292":
39235               case "293":
39236                 description = description.replace("A turn-", "This turn-");
39237                 break;
39238               case "294":
39239               case "295":
39240               case "296":
39241               case "297":
39242               case "298":
39243                 description = "This turn-restriction~".concat(description);
39244                 break;
39245               case "300":
39246                 description = "This highway is missing a maxspeed tag";
39247                 break;
39248               case "411":
39249               case "412":
39250               case "413":
39251                 description = "This feature~".concat(description);
39252                 break;
39253             }
39254             let coincident = false;
39255             do {
39256               let delta = coincident ? [1e-5, 0] : [0, 1e-5];
39257               loc = geoVecAdd(loc, delta);
39258               let bbox2 = geoExtent(loc).bbox();
39259               coincident = _cache.rtree.search(bbox2).length;
39260             } while (coincident);
39261             let d2 = new QAItem(loc, this, itemType, id2, {
39262               comment,
39263               description,
39264               whichType,
39265               parentIssueType,
39266               severity: whichTemplate.severity || "error",
39267               objectId,
39268               objectType,
39269               schema,
39270               title
39271             });
39272             d2.replacements = tokenReplacements(d2);
39273             _cache.data[id2] = d2;
39274             _cache.rtree.insert(encodeIssueRtree(d2));
39275           });
39276           dispatch2.call("loaded");
39277         }).catch(() => {
39278           delete _cache.inflightTile[tile.id];
39279           _cache.loadedTile[tile.id] = true;
39280         });
39281       });
39282     },
39283     postUpdate(d2, callback) {
39284       if (_cache.inflightPost[d2.id]) {
39285         return callback({ message: "Error update already inflight", status: -2 }, d2);
39286       }
39287       const params = { schema: d2.schema, id: d2.id };
39288       if (d2.newStatus) {
39289         params.st = d2.newStatus;
39290       }
39291       if (d2.newComment !== void 0) {
39292         params.co = d2.newComment;
39293       }
39294       const url = "".concat(_krUrlRoot, "/comment.php?") + utilQsString(params);
39295       const controller = new AbortController();
39296       _cache.inflightPost[d2.id] = controller;
39297       json_default(url, { signal: controller.signal }).finally(() => {
39298         delete _cache.inflightPost[d2.id];
39299         if (d2.newStatus === "ignore") {
39300           this.removeItem(d2);
39301         } else if (d2.newStatus === "ignore_t") {
39302           this.removeItem(d2);
39303           _cache.closed["".concat(d2.schema, ":").concat(d2.id)] = true;
39304         } else {
39305           d2 = this.replaceItem(d2.update({
39306             comment: d2.newComment,
39307             newComment: void 0,
39308             newState: void 0
39309           }));
39310         }
39311         if (callback)
39312           callback(null, d2);
39313       });
39314     },
39315     // Get all cached QAItems covering the viewport
39316     getItems(projection2) {
39317       const viewport = projection2.clipExtent();
39318       const min3 = [viewport[0][0], viewport[1][1]];
39319       const max3 = [viewport[1][0], viewport[0][1]];
39320       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39321       return _cache.rtree.search(bbox2).map((d2) => d2.data);
39322     },
39323     // Get a QAItem from cache
39324     // NOTE: Don't change method name until UI v3 is merged
39325     getError(id2) {
39326       return _cache.data[id2];
39327     },
39328     // Replace a single QAItem in the cache
39329     replaceItem(item) {
39330       if (!(item instanceof QAItem) || !item.id)
39331         return;
39332       _cache.data[item.id] = item;
39333       updateRtree(encodeIssueRtree(item), true);
39334       return item;
39335     },
39336     // Remove a single QAItem from the cache
39337     removeItem(item) {
39338       if (!(item instanceof QAItem) || !item.id)
39339         return;
39340       delete _cache.data[item.id];
39341       updateRtree(encodeIssueRtree(item), false);
39342     },
39343     issueURL(item) {
39344       return "".concat(_krUrlRoot, "/report_map.php?schema=").concat(item.schema, "&error=").concat(item.id);
39345     },
39346     // Get an array of issues closed during this session.
39347     // Used to populate `closed:keepright` changeset tag
39348     getClosedIDs() {
39349       return Object.keys(_cache.closed).sort();
39350     }
39351   };
39352
39353   // modules/services/improveOSM.js
39354   var import_rbush2 = __toESM(require_rbush_min());
39355   var tiler2 = utilTiler();
39356   var dispatch3 = dispatch_default("loaded");
39357   var _tileZoom2 = 14;
39358   var _impOsmUrls = {
39359     ow: "https://grab.community.improve-osm.org/directionOfFlowService",
39360     mr: "https://grab.community.improve-osm.org/missingGeoService",
39361     tr: "https://grab.community.improve-osm.org/turnRestrictionService"
39362   };
39363   var _impOsmData = { icons: {} };
39364   var _cache2;
39365   function abortRequest2(i3) {
39366     Object.values(i3).forEach((controller) => {
39367       if (controller) {
39368         controller.abort();
39369       }
39370     });
39371   }
39372   function abortUnwantedRequests2(cache, tiles) {
39373     Object.keys(cache.inflightTile).forEach((k2) => {
39374       const wanted = tiles.find((tile) => k2 === tile.id);
39375       if (!wanted) {
39376         abortRequest2(cache.inflightTile[k2]);
39377         delete cache.inflightTile[k2];
39378       }
39379     });
39380   }
39381   function encodeIssueRtree2(d2) {
39382     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39383   }
39384   function updateRtree2(item, replace) {
39385     _cache2.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39386     if (replace) {
39387       _cache2.rtree.insert(item);
39388     }
39389   }
39390   function linkErrorObject(d2) {
39391     return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39392   }
39393   function linkEntity(d2) {
39394     return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39395   }
39396   function pointAverage(points) {
39397     if (points.length) {
39398       const sum = points.reduce(
39399         (acc, point2) => geoVecAdd(acc, [point2.lon, point2.lat]),
39400         [0, 0]
39401       );
39402       return geoVecScale(sum, 1 / points.length);
39403     } else {
39404       return [0, 0];
39405     }
39406   }
39407   function relativeBearing(p1, p2) {
39408     let angle2 = Math.atan2(p2.lon - p1.lon, p2.lat - p1.lat);
39409     if (angle2 < 0) {
39410       angle2 += 2 * Math.PI;
39411     }
39412     return angle2 * 180 / Math.PI;
39413   }
39414   function cardinalDirection(bearing) {
39415     const dir = 45 * Math.round(bearing / 45);
39416     const compass = {
39417       0: "north",
39418       45: "northeast",
39419       90: "east",
39420       135: "southeast",
39421       180: "south",
39422       225: "southwest",
39423       270: "west",
39424       315: "northwest",
39425       360: "north"
39426     };
39427     return _t("QA.improveOSM.directions.".concat(compass[dir]));
39428   }
39429   function preventCoincident(loc, bumpUp) {
39430     let coincident = false;
39431     do {
39432       let delta = coincident ? [1e-5, 0] : bumpUp ? [0, 1e-5] : [0, 0];
39433       loc = geoVecAdd(loc, delta);
39434       let bbox2 = geoExtent(loc).bbox();
39435       coincident = _cache2.rtree.search(bbox2).length;
39436     } while (coincident);
39437     return loc;
39438   }
39439   var improveOSM_default = {
39440     title: "improveOSM",
39441     init() {
39442       _mainFileFetcher.get("qa_data").then((d2) => _impOsmData = d2.improveOSM);
39443       if (!_cache2) {
39444         this.reset();
39445       }
39446       this.event = utilRebind(this, dispatch3, "on");
39447     },
39448     reset() {
39449       if (_cache2) {
39450         Object.values(_cache2.inflightTile).forEach(abortRequest2);
39451       }
39452       _cache2 = {
39453         data: {},
39454         loadedTile: {},
39455         inflightTile: {},
39456         inflightPost: {},
39457         closed: {},
39458         rtree: new import_rbush2.default()
39459       };
39460     },
39461     loadIssues(projection2) {
39462       const options2 = {
39463         client: "iD",
39464         status: "OPEN",
39465         zoom: "19"
39466         // Use a high zoom so that clusters aren't returned
39467       };
39468       const tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2);
39469       abortUnwantedRequests2(_cache2, tiles);
39470       tiles.forEach((tile) => {
39471         if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id])
39472           return;
39473         const [east, north, west, south] = tile.extent.rectangle();
39474         const params = Object.assign({}, options2, { east, south, west, north });
39475         const requests = {};
39476         Object.keys(_impOsmUrls).forEach((k2) => {
39477           const kParams = Object.assign(
39478             {},
39479             params,
39480             k2 === "mr" ? { type: "PARKING,ROAD,BOTH,PATH" } : { confidenceLevel: "C1" }
39481           );
39482           const url = "".concat(_impOsmUrls[k2], "/search?") + utilQsString(kParams);
39483           const controller = new AbortController();
39484           requests[k2] = controller;
39485           json_default(url, { signal: controller.signal }).then((data) => {
39486             delete _cache2.inflightTile[tile.id][k2];
39487             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39488               delete _cache2.inflightTile[tile.id];
39489               _cache2.loadedTile[tile.id] = true;
39490             }
39491             if (data.roadSegments) {
39492               data.roadSegments.forEach((feature3) => {
39493                 const { points, wayId, fromNodeId, toNodeId } = feature3;
39494                 const itemId = "".concat(wayId).concat(fromNodeId).concat(toNodeId);
39495                 let mid = points.length / 2;
39496                 let loc;
39497                 if (mid % 1 === 0) {
39498                   loc = pointAverage([points[mid - 1], points[mid]]);
39499                 } else {
39500                   mid = points[Math.floor(mid)];
39501                   loc = [mid.lon, mid.lat];
39502                 }
39503                 loc = preventCoincident(loc, false);
39504                 let d2 = new QAItem(loc, this, k2, itemId, {
39505                   issueKey: k2,
39506                   // used as a category
39507                   identifier: {
39508                     // used to post changes
39509                     wayId,
39510                     fromNodeId,
39511                     toNodeId
39512                   },
39513                   objectId: wayId,
39514                   objectType: "way"
39515                 });
39516                 d2.replacements = {
39517                   percentage: feature3.percentOfTrips,
39518                   num_trips: feature3.numberOfTrips,
39519                   highway: linkErrorObject(_t("QA.keepRight.error_parts.highway")),
39520                   from_node: linkEntity("n" + feature3.fromNodeId),
39521                   to_node: linkEntity("n" + feature3.toNodeId)
39522                 };
39523                 _cache2.data[d2.id] = d2;
39524                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39525               });
39526             }
39527             if (data.tiles) {
39528               data.tiles.forEach((feature3) => {
39529                 const { type: type2, x: x2, y: y2, numberOfTrips } = feature3;
39530                 const geoType = type2.toLowerCase();
39531                 const itemId = "".concat(geoType).concat(x2).concat(y2).concat(numberOfTrips);
39532                 let loc = pointAverage(feature3.points);
39533                 loc = preventCoincident(loc, false);
39534                 let d2 = new QAItem(loc, this, "".concat(k2, "-").concat(geoType), itemId, {
39535                   issueKey: k2,
39536                   identifier: { x: x2, y: y2 }
39537                 });
39538                 d2.replacements = {
39539                   num_trips: numberOfTrips,
39540                   geometry_type: _t("QA.improveOSM.geometry_types.".concat(geoType))
39541                 };
39542                 if (numberOfTrips === -1) {
39543                   d2.desc = _t("QA.improveOSM.error_types.mr.description_alt", d2.replacements);
39544                 }
39545                 _cache2.data[d2.id] = d2;
39546                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39547               });
39548             }
39549             if (data.entities) {
39550               data.entities.forEach((feature3) => {
39551                 const { point: point2, id: id2, segments, numberOfPasses, turnType } = feature3;
39552                 const itemId = "".concat(id2.replace(/[,:+#]/g, "_"));
39553                 const loc = preventCoincident([point2.lon, point2.lat], true);
39554                 const ids = id2.split(",");
39555                 const from_way = ids[0];
39556                 const via_node = ids[3];
39557                 const to_way = ids[2].split(":")[1];
39558                 let d2 = new QAItem(loc, this, k2, itemId, {
39559                   issueKey: k2,
39560                   identifier: id2,
39561                   objectId: via_node,
39562                   objectType: "node"
39563                 });
39564                 const [p1, p2] = segments[0].points;
39565                 const dir_of_travel = cardinalDirection(relativeBearing(p1, p2));
39566                 d2.replacements = {
39567                   num_passed: numberOfPasses,
39568                   num_trips: segments[0].numberOfTrips,
39569                   turn_restriction: turnType.toLowerCase(),
39570                   from_way: linkEntity("w" + from_way),
39571                   to_way: linkEntity("w" + to_way),
39572                   travel_direction: dir_of_travel,
39573                   junction: linkErrorObject(_t("QA.keepRight.error_parts.this_node"))
39574                 };
39575                 _cache2.data[d2.id] = d2;
39576                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39577                 dispatch3.call("loaded");
39578               });
39579             }
39580           }).catch(() => {
39581             delete _cache2.inflightTile[tile.id][k2];
39582             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39583               delete _cache2.inflightTile[tile.id];
39584               _cache2.loadedTile[tile.id] = true;
39585             }
39586           });
39587         });
39588         _cache2.inflightTile[tile.id] = requests;
39589       });
39590     },
39591     getComments(item) {
39592       if (item.comments) {
39593         return Promise.resolve(item);
39594       }
39595       const key = item.issueKey;
39596       let qParams = {};
39597       if (key === "ow") {
39598         qParams = item.identifier;
39599       } else if (key === "mr") {
39600         qParams.tileX = item.identifier.x;
39601         qParams.tileY = item.identifier.y;
39602       } else if (key === "tr") {
39603         qParams.targetId = item.identifier;
39604       }
39605       const url = "".concat(_impOsmUrls[key], "/retrieveComments?") + utilQsString(qParams);
39606       const cacheComments = (data) => {
39607         item.comments = data.comments ? data.comments.reverse() : [];
39608         this.replaceItem(item);
39609       };
39610       return json_default(url).then(cacheComments).then(() => item);
39611     },
39612     postUpdate(d2, callback) {
39613       if (!osm_default.authenticated()) {
39614         return callback({ message: "Not Authenticated", status: -3 }, d2);
39615       }
39616       if (_cache2.inflightPost[d2.id]) {
39617         return callback({ message: "Error update already inflight", status: -2 }, d2);
39618       }
39619       osm_default.userDetails(sendPayload.bind(this));
39620       function sendPayload(err, user) {
39621         if (err) {
39622           return callback(err, d2);
39623         }
39624         const key = d2.issueKey;
39625         const url = "".concat(_impOsmUrls[key], "/comment");
39626         const payload = {
39627           username: user.display_name,
39628           targetIds: [d2.identifier]
39629         };
39630         if (d2.newStatus) {
39631           payload.status = d2.newStatus;
39632           payload.text = "status changed";
39633         }
39634         if (d2.newComment) {
39635           payload.text = d2.newComment;
39636         }
39637         const controller = new AbortController();
39638         _cache2.inflightPost[d2.id] = controller;
39639         const options2 = {
39640           method: "POST",
39641           signal: controller.signal,
39642           body: JSON.stringify(payload)
39643         };
39644         json_default(url, options2).then(() => {
39645           delete _cache2.inflightPost[d2.id];
39646           if (!d2.newStatus) {
39647             const now3 = /* @__PURE__ */ new Date();
39648             let comments = d2.comments ? d2.comments : [];
39649             comments.push({
39650               username: payload.username,
39651               text: payload.text,
39652               timestamp: now3.getTime() / 1e3
39653             });
39654             this.replaceItem(d2.update({
39655               comments,
39656               newComment: void 0
39657             }));
39658           } else {
39659             this.removeItem(d2);
39660             if (d2.newStatus === "SOLVED") {
39661               if (!(d2.issueKey in _cache2.closed)) {
39662                 _cache2.closed[d2.issueKey] = 0;
39663               }
39664               _cache2.closed[d2.issueKey] += 1;
39665             }
39666           }
39667           if (callback)
39668             callback(null, d2);
39669         }).catch((err2) => {
39670           delete _cache2.inflightPost[d2.id];
39671           if (callback)
39672             callback(err2.message);
39673         });
39674       }
39675     },
39676     // Get all cached QAItems covering the viewport
39677     getItems(projection2) {
39678       const viewport = projection2.clipExtent();
39679       const min3 = [viewport[0][0], viewport[1][1]];
39680       const max3 = [viewport[1][0], viewport[0][1]];
39681       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39682       return _cache2.rtree.search(bbox2).map((d2) => d2.data);
39683     },
39684     // Get a QAItem from cache
39685     // NOTE: Don't change method name until UI v3 is merged
39686     getError(id2) {
39687       return _cache2.data[id2];
39688     },
39689     // get the name of the icon to display for this item
39690     getIcon(itemType) {
39691       return _impOsmData.icons[itemType];
39692     },
39693     // Replace a single QAItem in the cache
39694     replaceItem(issue) {
39695       if (!(issue instanceof QAItem) || !issue.id)
39696         return;
39697       _cache2.data[issue.id] = issue;
39698       updateRtree2(encodeIssueRtree2(issue), true);
39699       return issue;
39700     },
39701     // Remove a single QAItem from the cache
39702     removeItem(issue) {
39703       if (!(issue instanceof QAItem) || !issue.id)
39704         return;
39705       delete _cache2.data[issue.id];
39706       updateRtree2(encodeIssueRtree2(issue), false);
39707     },
39708     // Used to populate `closed:improveosm:*` changeset tags
39709     getClosedCounts() {
39710       return _cache2.closed;
39711     }
39712   };
39713
39714   // modules/services/osmose.js
39715   var import_rbush3 = __toESM(require_rbush_min());
39716
39717   // node_modules/marked/lib/marked.esm.js
39718   function _getDefaults() {
39719     return {
39720       async: false,
39721       breaks: false,
39722       extensions: null,
39723       gfm: true,
39724       hooks: null,
39725       pedantic: false,
39726       renderer: null,
39727       silent: false,
39728       tokenizer: null,
39729       walkTokens: null
39730     };
39731   }
39732   var _defaults = _getDefaults();
39733   function changeDefaults(newDefaults) {
39734     _defaults = newDefaults;
39735   }
39736   var escapeTest = /[&<>"']/;
39737   var escapeReplace = new RegExp(escapeTest.source, "g");
39738   var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
39739   var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
39740   var escapeReplacements = {
39741     "&": "&amp;",
39742     "<": "&lt;",
39743     ">": "&gt;",
39744     '"': "&quot;",
39745     "'": "&#39;"
39746   };
39747   var getEscapeReplacement = (ch) => escapeReplacements[ch];
39748   function escape$1(html3, encode) {
39749     if (encode) {
39750       if (escapeTest.test(html3)) {
39751         return html3.replace(escapeReplace, getEscapeReplacement);
39752       }
39753     } else {
39754       if (escapeTestNoEncode.test(html3)) {
39755         return html3.replace(escapeReplaceNoEncode, getEscapeReplacement);
39756       }
39757     }
39758     return html3;
39759   }
39760   var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
39761   function unescape2(html3) {
39762     return html3.replace(unescapeTest, (_2, n3) => {
39763       n3 = n3.toLowerCase();
39764       if (n3 === "colon")
39765         return ":";
39766       if (n3.charAt(0) === "#") {
39767         return n3.charAt(1) === "x" ? String.fromCharCode(parseInt(n3.substring(2), 16)) : String.fromCharCode(+n3.substring(1));
39768       }
39769       return "";
39770     });
39771   }
39772   var caret = /(^|[^\[])\^/g;
39773   function edit(regex, opt) {
39774     let source = typeof regex === "string" ? regex : regex.source;
39775     opt = opt || "";
39776     const obj = {
39777       replace: (name, val) => {
39778         let valSource = typeof val === "string" ? val : val.source;
39779         valSource = valSource.replace(caret, "$1");
39780         source = source.replace(name, valSource);
39781         return obj;
39782       },
39783       getRegex: () => {
39784         return new RegExp(source, opt);
39785       }
39786     };
39787     return obj;
39788   }
39789   function cleanUrl(href) {
39790     try {
39791       href = encodeURI(href).replace(/%25/g, "%");
39792     } catch (e3) {
39793       return null;
39794     }
39795     return href;
39796   }
39797   var noopTest = { exec: () => null };
39798   function splitCells(tableRow, count) {
39799     const row = tableRow.replace(/\|/g, (match, offset, str) => {
39800       let escaped = false;
39801       let curr = offset;
39802       while (--curr >= 0 && str[curr] === "\\")
39803         escaped = !escaped;
39804       if (escaped) {
39805         return "|";
39806       } else {
39807         return " |";
39808       }
39809     }), cells = row.split(/ \|/);
39810     let i3 = 0;
39811     if (!cells[0].trim()) {
39812       cells.shift();
39813     }
39814     if (cells.length > 0 && !cells[cells.length - 1].trim()) {
39815       cells.pop();
39816     }
39817     if (count) {
39818       if (cells.length > count) {
39819         cells.splice(count);
39820       } else {
39821         while (cells.length < count)
39822           cells.push("");
39823       }
39824     }
39825     for (; i3 < cells.length; i3++) {
39826       cells[i3] = cells[i3].trim().replace(/\\\|/g, "|");
39827     }
39828     return cells;
39829   }
39830   function rtrim(str, c2, invert) {
39831     const l2 = str.length;
39832     if (l2 === 0) {
39833       return "";
39834     }
39835     let suffLen = 0;
39836     while (suffLen < l2) {
39837       const currChar = str.charAt(l2 - suffLen - 1);
39838       if (currChar === c2 && !invert) {
39839         suffLen++;
39840       } else if (currChar !== c2 && invert) {
39841         suffLen++;
39842       } else {
39843         break;
39844       }
39845     }
39846     return str.slice(0, l2 - suffLen);
39847   }
39848   function findClosingBracket(str, b2) {
39849     if (str.indexOf(b2[1]) === -1) {
39850       return -1;
39851     }
39852     let level = 0;
39853     for (let i3 = 0; i3 < str.length; i3++) {
39854       if (str[i3] === "\\") {
39855         i3++;
39856       } else if (str[i3] === b2[0]) {
39857         level++;
39858       } else if (str[i3] === b2[1]) {
39859         level--;
39860         if (level < 0) {
39861           return i3;
39862         }
39863       }
39864     }
39865     return -1;
39866   }
39867   function outputLink(cap, link3, raw, lexer2) {
39868     const href = link3.href;
39869     const title = link3.title ? escape$1(link3.title) : null;
39870     const text = cap[1].replace(/\\([\[\]])/g, "$1");
39871     if (cap[0].charAt(0) !== "!") {
39872       lexer2.state.inLink = true;
39873       const token = {
39874         type: "link",
39875         raw,
39876         href,
39877         title,
39878         text,
39879         tokens: lexer2.inlineTokens(text)
39880       };
39881       lexer2.state.inLink = false;
39882       return token;
39883     }
39884     return {
39885       type: "image",
39886       raw,
39887       href,
39888       title,
39889       text: escape$1(text)
39890     };
39891   }
39892   function indentCodeCompensation(raw, text) {
39893     const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
39894     if (matchIndentToCode === null) {
39895       return text;
39896     }
39897     const indentToCode = matchIndentToCode[1];
39898     return text.split("\n").map((node) => {
39899       const matchIndentInNode = node.match(/^\s+/);
39900       if (matchIndentInNode === null) {
39901         return node;
39902       }
39903       const [indentInNode] = matchIndentInNode;
39904       if (indentInNode.length >= indentToCode.length) {
39905         return node.slice(indentToCode.length);
39906       }
39907       return node;
39908     }).join("\n");
39909   }
39910   var _Tokenizer = class {
39911     // set by the lexer
39912     constructor(options2) {
39913       __publicField(this, "options");
39914       __publicField(this, "rules");
39915       // set by the lexer
39916       __publicField(this, "lexer");
39917       this.options = options2 || _defaults;
39918     }
39919     space(src) {
39920       const cap = this.rules.block.newline.exec(src);
39921       if (cap && cap[0].length > 0) {
39922         return {
39923           type: "space",
39924           raw: cap[0]
39925         };
39926       }
39927     }
39928     code(src) {
39929       const cap = this.rules.block.code.exec(src);
39930       if (cap) {
39931         const text = cap[0].replace(/^ {1,4}/gm, "");
39932         return {
39933           type: "code",
39934           raw: cap[0],
39935           codeBlockStyle: "indented",
39936           text: !this.options.pedantic ? rtrim(text, "\n") : text
39937         };
39938       }
39939     }
39940     fences(src) {
39941       const cap = this.rules.block.fences.exec(src);
39942       if (cap) {
39943         const raw = cap[0];
39944         const text = indentCodeCompensation(raw, cap[3] || "");
39945         return {
39946           type: "code",
39947           raw,
39948           lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
39949           text
39950         };
39951       }
39952     }
39953     heading(src) {
39954       const cap = this.rules.block.heading.exec(src);
39955       if (cap) {
39956         let text = cap[2].trim();
39957         if (/#$/.test(text)) {
39958           const trimmed = rtrim(text, "#");
39959           if (this.options.pedantic) {
39960             text = trimmed.trim();
39961           } else if (!trimmed || / $/.test(trimmed)) {
39962             text = trimmed.trim();
39963           }
39964         }
39965         return {
39966           type: "heading",
39967           raw: cap[0],
39968           depth: cap[1].length,
39969           text,
39970           tokens: this.lexer.inline(text)
39971         };
39972       }
39973     }
39974     hr(src) {
39975       const cap = this.rules.block.hr.exec(src);
39976       if (cap) {
39977         return {
39978           type: "hr",
39979           raw: cap[0]
39980         };
39981       }
39982     }
39983     blockquote(src) {
39984       const cap = this.rules.block.blockquote.exec(src);
39985       if (cap) {
39986         const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ""), "\n");
39987         const top = this.lexer.state.top;
39988         this.lexer.state.top = true;
39989         const tokens = this.lexer.blockTokens(text);
39990         this.lexer.state.top = top;
39991         return {
39992           type: "blockquote",
39993           raw: cap[0],
39994           tokens,
39995           text
39996         };
39997       }
39998     }
39999     list(src) {
40000       let cap = this.rules.block.list.exec(src);
40001       if (cap) {
40002         let bull = cap[1].trim();
40003         const isordered = bull.length > 1;
40004         const list2 = {
40005           type: "list",
40006           raw: "",
40007           ordered: isordered,
40008           start: isordered ? +bull.slice(0, -1) : "",
40009           loose: false,
40010           items: []
40011         };
40012         bull = isordered ? "\\d{1,9}\\".concat(bull.slice(-1)) : "\\".concat(bull);
40013         if (this.options.pedantic) {
40014           bull = isordered ? bull : "[*+-]";
40015         }
40016         const itemRegex = new RegExp("^( {0,3}".concat(bull, ")((?:[     ][^\\n]*)?(?:\\n|$))"));
40017         let raw = "";
40018         let itemContents = "";
40019         let endsWithBlankLine = false;
40020         while (src) {
40021           let endEarly = false;
40022           if (!(cap = itemRegex.exec(src))) {
40023             break;
40024           }
40025           if (this.rules.block.hr.test(src)) {
40026             break;
40027           }
40028           raw = cap[0];
40029           src = src.substring(raw.length);
40030           let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
40031           let nextLine = src.split("\n", 1)[0];
40032           let indent = 0;
40033           if (this.options.pedantic) {
40034             indent = 2;
40035             itemContents = line.trimStart();
40036           } else {
40037             indent = cap[2].search(/[^ ]/);
40038             indent = indent > 4 ? 1 : indent;
40039             itemContents = line.slice(indent);
40040             indent += cap[1].length;
40041           }
40042           let blankLine = false;
40043           if (!line && /^ *$/.test(nextLine)) {
40044             raw += nextLine + "\n";
40045             src = src.substring(nextLine.length + 1);
40046             endEarly = true;
40047           }
40048           if (!endEarly) {
40049             const nextBulletRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[    ][^\\n]*)?(?:\\n|$))"));
40050             const hrRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)"));
40051             const fencesBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)"));
40052             const headingBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#"));
40053             while (src) {
40054               const rawLine = src.split("\n", 1)[0];
40055               nextLine = rawLine;
40056               if (this.options.pedantic) {
40057                 nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ");
40058               }
40059               if (fencesBeginRegex.test(nextLine)) {
40060                 break;
40061               }
40062               if (headingBeginRegex.test(nextLine)) {
40063                 break;
40064               }
40065               if (nextBulletRegex.test(nextLine)) {
40066                 break;
40067               }
40068               if (hrRegex.test(src)) {
40069                 break;
40070               }
40071               if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
40072                 itemContents += "\n" + nextLine.slice(indent);
40073               } else {
40074                 if (blankLine) {
40075                   break;
40076                 }
40077                 if (line.search(/[^ ]/) >= 4) {
40078                   break;
40079                 }
40080                 if (fencesBeginRegex.test(line)) {
40081                   break;
40082                 }
40083                 if (headingBeginRegex.test(line)) {
40084                   break;
40085                 }
40086                 if (hrRegex.test(line)) {
40087                   break;
40088                 }
40089                 itemContents += "\n" + nextLine;
40090               }
40091               if (!blankLine && !nextLine.trim()) {
40092                 blankLine = true;
40093               }
40094               raw += rawLine + "\n";
40095               src = src.substring(rawLine.length + 1);
40096               line = nextLine.slice(indent);
40097             }
40098           }
40099           if (!list2.loose) {
40100             if (endsWithBlankLine) {
40101               list2.loose = true;
40102             } else if (/\n *\n *$/.test(raw)) {
40103               endsWithBlankLine = true;
40104             }
40105           }
40106           let istask = null;
40107           let ischecked;
40108           if (this.options.gfm) {
40109             istask = /^\[[ xX]\] /.exec(itemContents);
40110             if (istask) {
40111               ischecked = istask[0] !== "[ ] ";
40112               itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
40113             }
40114           }
40115           list2.items.push({
40116             type: "list_item",
40117             raw,
40118             task: !!istask,
40119             checked: ischecked,
40120             loose: false,
40121             text: itemContents,
40122             tokens: []
40123           });
40124           list2.raw += raw;
40125         }
40126         list2.items[list2.items.length - 1].raw = raw.trimEnd();
40127         list2.items[list2.items.length - 1].text = itemContents.trimEnd();
40128         list2.raw = list2.raw.trimEnd();
40129         for (let i3 = 0; i3 < list2.items.length; i3++) {
40130           this.lexer.state.top = false;
40131           list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
40132           if (!list2.loose) {
40133             const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space");
40134             const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => /\n.*\n/.test(t2.raw));
40135             list2.loose = hasMultipleLineBreaks;
40136           }
40137         }
40138         if (list2.loose) {
40139           for (let i3 = 0; i3 < list2.items.length; i3++) {
40140             list2.items[i3].loose = true;
40141           }
40142         }
40143         return list2;
40144       }
40145     }
40146     html(src) {
40147       const cap = this.rules.block.html.exec(src);
40148       if (cap) {
40149         const token = {
40150           type: "html",
40151           block: true,
40152           raw: cap[0],
40153           pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
40154           text: cap[0]
40155         };
40156         return token;
40157       }
40158     }
40159     def(src) {
40160       const cap = this.rules.block.def.exec(src);
40161       if (cap) {
40162         const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
40163         const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
40164         const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
40165         return {
40166           type: "def",
40167           tag: tag2,
40168           raw: cap[0],
40169           href,
40170           title
40171         };
40172       }
40173     }
40174     table(src) {
40175       const cap = this.rules.block.table.exec(src);
40176       if (!cap) {
40177         return;
40178       }
40179       if (!/[:|]/.test(cap[2])) {
40180         return;
40181       }
40182       const headers = splitCells(cap[1]);
40183       const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
40184       const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
40185       const item = {
40186         type: "table",
40187         raw: cap[0],
40188         header: [],
40189         align: [],
40190         rows: []
40191       };
40192       if (headers.length !== aligns.length) {
40193         return;
40194       }
40195       for (const align of aligns) {
40196         if (/^ *-+: *$/.test(align)) {
40197           item.align.push("right");
40198         } else if (/^ *:-+: *$/.test(align)) {
40199           item.align.push("center");
40200         } else if (/^ *:-+ *$/.test(align)) {
40201           item.align.push("left");
40202         } else {
40203           item.align.push(null);
40204         }
40205       }
40206       for (const header of headers) {
40207         item.header.push({
40208           text: header,
40209           tokens: this.lexer.inline(header)
40210         });
40211       }
40212       for (const row of rows) {
40213         item.rows.push(splitCells(row, item.header.length).map((cell) => {
40214           return {
40215             text: cell,
40216             tokens: this.lexer.inline(cell)
40217           };
40218         }));
40219       }
40220       return item;
40221     }
40222     lheading(src) {
40223       const cap = this.rules.block.lheading.exec(src);
40224       if (cap) {
40225         return {
40226           type: "heading",
40227           raw: cap[0],
40228           depth: cap[2].charAt(0) === "=" ? 1 : 2,
40229           text: cap[1],
40230           tokens: this.lexer.inline(cap[1])
40231         };
40232       }
40233     }
40234     paragraph(src) {
40235       const cap = this.rules.block.paragraph.exec(src);
40236       if (cap) {
40237         const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
40238         return {
40239           type: "paragraph",
40240           raw: cap[0],
40241           text,
40242           tokens: this.lexer.inline(text)
40243         };
40244       }
40245     }
40246     text(src) {
40247       const cap = this.rules.block.text.exec(src);
40248       if (cap) {
40249         return {
40250           type: "text",
40251           raw: cap[0],
40252           text: cap[0],
40253           tokens: this.lexer.inline(cap[0])
40254         };
40255       }
40256     }
40257     escape(src) {
40258       const cap = this.rules.inline.escape.exec(src);
40259       if (cap) {
40260         return {
40261           type: "escape",
40262           raw: cap[0],
40263           text: escape$1(cap[1])
40264         };
40265       }
40266     }
40267     tag(src) {
40268       const cap = this.rules.inline.tag.exec(src);
40269       if (cap) {
40270         if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
40271           this.lexer.state.inLink = true;
40272         } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
40273           this.lexer.state.inLink = false;
40274         }
40275         if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40276           this.lexer.state.inRawBlock = true;
40277         } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40278           this.lexer.state.inRawBlock = false;
40279         }
40280         return {
40281           type: "html",
40282           raw: cap[0],
40283           inLink: this.lexer.state.inLink,
40284           inRawBlock: this.lexer.state.inRawBlock,
40285           block: false,
40286           text: cap[0]
40287         };
40288       }
40289     }
40290     link(src) {
40291       const cap = this.rules.inline.link.exec(src);
40292       if (cap) {
40293         const trimmedUrl = cap[2].trim();
40294         if (!this.options.pedantic && /^</.test(trimmedUrl)) {
40295           if (!/>$/.test(trimmedUrl)) {
40296             return;
40297           }
40298           const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
40299           if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
40300             return;
40301           }
40302         } else {
40303           const lastParenIndex = findClosingBracket(cap[2], "()");
40304           if (lastParenIndex > -1) {
40305             const start2 = cap[0].indexOf("!") === 0 ? 5 : 4;
40306             const linkLen = start2 + cap[1].length + lastParenIndex;
40307             cap[2] = cap[2].substring(0, lastParenIndex);
40308             cap[0] = cap[0].substring(0, linkLen).trim();
40309             cap[3] = "";
40310           }
40311         }
40312         let href = cap[2];
40313         let title = "";
40314         if (this.options.pedantic) {
40315           const link3 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
40316           if (link3) {
40317             href = link3[1];
40318             title = link3[3];
40319           }
40320         } else {
40321           title = cap[3] ? cap[3].slice(1, -1) : "";
40322         }
40323         href = href.trim();
40324         if (/^</.test(href)) {
40325           if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
40326             href = href.slice(1);
40327           } else {
40328             href = href.slice(1, -1);
40329           }
40330         }
40331         return outputLink(cap, {
40332           href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
40333           title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
40334         }, cap[0], this.lexer);
40335       }
40336     }
40337     reflink(src, links) {
40338       let cap;
40339       if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
40340         const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
40341         const link3 = links[linkString.toLowerCase()];
40342         if (!link3) {
40343           const text = cap[0].charAt(0);
40344           return {
40345             type: "text",
40346             raw: text,
40347             text
40348           };
40349         }
40350         return outputLink(cap, link3, cap[0], this.lexer);
40351       }
40352     }
40353     emStrong(src, maskedSrc, prevChar = "") {
40354       let match = this.rules.inline.emStrongLDelim.exec(src);
40355       if (!match)
40356         return;
40357       if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
40358         return;
40359       const nextChar = match[1] || match[2] || "";
40360       if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
40361         const lLength = [...match[0]].length - 1;
40362         let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
40363         const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
40364         endReg.lastIndex = 0;
40365         maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
40366         while ((match = endReg.exec(maskedSrc)) != null) {
40367           rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
40368           if (!rDelim)
40369             continue;
40370           rLength = [...rDelim].length;
40371           if (match[3] || match[4]) {
40372             delimTotal += rLength;
40373             continue;
40374           } else if (match[5] || match[6]) {
40375             if (lLength % 3 && !((lLength + rLength) % 3)) {
40376               midDelimTotal += rLength;
40377               continue;
40378             }
40379           }
40380           delimTotal -= rLength;
40381           if (delimTotal > 0)
40382             continue;
40383           rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
40384           const lastCharLength = [...match[0]][0].length;
40385           const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
40386           if (Math.min(lLength, rLength) % 2) {
40387             const text2 = raw.slice(1, -1);
40388             return {
40389               type: "em",
40390               raw,
40391               text: text2,
40392               tokens: this.lexer.inlineTokens(text2)
40393             };
40394           }
40395           const text = raw.slice(2, -2);
40396           return {
40397             type: "strong",
40398             raw,
40399             text,
40400             tokens: this.lexer.inlineTokens(text)
40401           };
40402         }
40403       }
40404     }
40405     codespan(src) {
40406       const cap = this.rules.inline.code.exec(src);
40407       if (cap) {
40408         let text = cap[2].replace(/\n/g, " ");
40409         const hasNonSpaceChars = /[^ ]/.test(text);
40410         const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
40411         if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
40412           text = text.substring(1, text.length - 1);
40413         }
40414         text = escape$1(text, true);
40415         return {
40416           type: "codespan",
40417           raw: cap[0],
40418           text
40419         };
40420       }
40421     }
40422     br(src) {
40423       const cap = this.rules.inline.br.exec(src);
40424       if (cap) {
40425         return {
40426           type: "br",
40427           raw: cap[0]
40428         };
40429       }
40430     }
40431     del(src) {
40432       const cap = this.rules.inline.del.exec(src);
40433       if (cap) {
40434         return {
40435           type: "del",
40436           raw: cap[0],
40437           text: cap[2],
40438           tokens: this.lexer.inlineTokens(cap[2])
40439         };
40440       }
40441     }
40442     autolink(src) {
40443       const cap = this.rules.inline.autolink.exec(src);
40444       if (cap) {
40445         let text, href;
40446         if (cap[2] === "@") {
40447           text = escape$1(cap[1]);
40448           href = "mailto:" + text;
40449         } else {
40450           text = escape$1(cap[1]);
40451           href = text;
40452         }
40453         return {
40454           type: "link",
40455           raw: cap[0],
40456           text,
40457           href,
40458           tokens: [
40459             {
40460               type: "text",
40461               raw: text,
40462               text
40463             }
40464           ]
40465         };
40466       }
40467     }
40468     url(src) {
40469       var _a2, _b;
40470       let cap;
40471       if (cap = this.rules.inline.url.exec(src)) {
40472         let text, href;
40473         if (cap[2] === "@") {
40474           text = escape$1(cap[0]);
40475           href = "mailto:" + text;
40476         } else {
40477           let prevCapZero;
40478           do {
40479             prevCapZero = cap[0];
40480             cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
40481           } while (prevCapZero !== cap[0]);
40482           text = escape$1(cap[0]);
40483           if (cap[1] === "www.") {
40484             href = "http://" + cap[0];
40485           } else {
40486             href = cap[0];
40487           }
40488         }
40489         return {
40490           type: "link",
40491           raw: cap[0],
40492           text,
40493           href,
40494           tokens: [
40495             {
40496               type: "text",
40497               raw: text,
40498               text
40499             }
40500           ]
40501         };
40502       }
40503     }
40504     inlineText(src) {
40505       const cap = this.rules.inline.text.exec(src);
40506       if (cap) {
40507         let text;
40508         if (this.lexer.state.inRawBlock) {
40509           text = cap[0];
40510         } else {
40511           text = escape$1(cap[0]);
40512         }
40513         return {
40514           type: "text",
40515           raw: cap[0],
40516           text
40517         };
40518       }
40519     }
40520   };
40521   var newline = /^(?: *(?:\n|$))+/;
40522   var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
40523   var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
40524   var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
40525   var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
40526   var bullet = /(?:[*+-]|\d{1,9}[.)])/;
40527   var lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).getRegex();
40528   var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
40529   var blockText = /^[^\n]+/;
40530   var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
40531   var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
40532   var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
40533   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";
40534   var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
40535   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();
40536   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();
40537   var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
40538   var blockNormal = {
40539     blockquote,
40540     code: blockCode,
40541     def,
40542     fences,
40543     heading,
40544     hr,
40545     html: html2,
40546     lheading,
40547     list,
40548     newline,
40549     paragraph,
40550     table: noopTest,
40551     text: blockText
40552   };
40553   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}[^\\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();
40554   var blockGfm = {
40555     ...blockNormal,
40556     table: gfmTable,
40557     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()
40558   };
40559   var blockPedantic = {
40560     ...blockNormal,
40561     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(),
40562     def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
40563     heading: /^(#{1,6})(.*)(?:\n+|$)/,
40564     fences: noopTest,
40565     // fences not supported
40566     lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
40567     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()
40568   };
40569   var escape4 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
40570   var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
40571   var br = /^( {2,}|\\)\n(?!\s*$)/;
40572   var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
40573   var _punctuation = "\\p{P}\\p{S}";
40574   var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
40575   var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
40576   var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
40577   var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
40578   var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
40579   var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
40580   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();
40581   var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
40582   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();
40583   var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
40584   var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
40585   var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
40586   var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
40587   var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
40588   var inlineNormal = {
40589     _backpedal: noopTest,
40590     // only used for GFM url
40591     anyPunctuation,
40592     autolink,
40593     blockSkip,
40594     br,
40595     code: inlineCode,
40596     del: noopTest,
40597     emStrongLDelim,
40598     emStrongRDelimAst,
40599     emStrongRDelimUnd,
40600     escape: escape4,
40601     link: link2,
40602     nolink,
40603     punctuation,
40604     reflink,
40605     reflinkSearch,
40606     tag,
40607     text: inlineText,
40608     url: noopTest
40609   };
40610   var inlinePedantic = {
40611     ...inlineNormal,
40612     link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
40613     reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
40614   };
40615   var inlineGfm = {
40616     ...inlineNormal,
40617     escape: edit(escape4).replace("])", "~|])").getRegex(),
40618     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(),
40619     _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
40620     del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
40621     text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
40622   };
40623   var inlineBreaks = {
40624     ...inlineGfm,
40625     br: edit(br).replace("{2,}", "*").getRegex(),
40626     text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
40627   };
40628   var block = {
40629     normal: blockNormal,
40630     gfm: blockGfm,
40631     pedantic: blockPedantic
40632   };
40633   var inline = {
40634     normal: inlineNormal,
40635     gfm: inlineGfm,
40636     breaks: inlineBreaks,
40637     pedantic: inlinePedantic
40638   };
40639   var _Lexer = class __Lexer {
40640     constructor(options2) {
40641       __publicField(this, "tokens");
40642       __publicField(this, "options");
40643       __publicField(this, "state");
40644       __publicField(this, "tokenizer");
40645       __publicField(this, "inlineQueue");
40646       this.tokens = [];
40647       this.tokens.links = /* @__PURE__ */ Object.create(null);
40648       this.options = options2 || _defaults;
40649       this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
40650       this.tokenizer = this.options.tokenizer;
40651       this.tokenizer.options = this.options;
40652       this.tokenizer.lexer = this;
40653       this.inlineQueue = [];
40654       this.state = {
40655         inLink: false,
40656         inRawBlock: false,
40657         top: true
40658       };
40659       const rules = {
40660         block: block.normal,
40661         inline: inline.normal
40662       };
40663       if (this.options.pedantic) {
40664         rules.block = block.pedantic;
40665         rules.inline = inline.pedantic;
40666       } else if (this.options.gfm) {
40667         rules.block = block.gfm;
40668         if (this.options.breaks) {
40669           rules.inline = inline.breaks;
40670         } else {
40671           rules.inline = inline.gfm;
40672         }
40673       }
40674       this.tokenizer.rules = rules;
40675     }
40676     /**
40677      * Expose Rules
40678      */
40679     static get rules() {
40680       return {
40681         block,
40682         inline
40683       };
40684     }
40685     /**
40686      * Static Lex Method
40687      */
40688     static lex(src, options2) {
40689       const lexer2 = new __Lexer(options2);
40690       return lexer2.lex(src);
40691     }
40692     /**
40693      * Static Lex Inline Method
40694      */
40695     static lexInline(src, options2) {
40696       const lexer2 = new __Lexer(options2);
40697       return lexer2.inlineTokens(src);
40698     }
40699     /**
40700      * Preprocessing
40701      */
40702     lex(src) {
40703       src = src.replace(/\r\n|\r/g, "\n");
40704       this.blockTokens(src, this.tokens);
40705       for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
40706         const next = this.inlineQueue[i3];
40707         this.inlineTokens(next.src, next.tokens);
40708       }
40709       this.inlineQueue = [];
40710       return this.tokens;
40711     }
40712     blockTokens(src, tokens = []) {
40713       if (this.options.pedantic) {
40714         src = src.replace(/\t/g, "    ").replace(/^ +$/gm, "");
40715       } else {
40716         src = src.replace(/^( *)(\t+)/gm, (_2, leading, tabs) => {
40717           return leading + "    ".repeat(tabs.length);
40718         });
40719       }
40720       let token;
40721       let lastToken;
40722       let cutSrc;
40723       let lastParagraphClipped;
40724       while (src) {
40725         if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
40726           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40727             src = src.substring(token.raw.length);
40728             tokens.push(token);
40729             return true;
40730           }
40731           return false;
40732         })) {
40733           continue;
40734         }
40735         if (token = this.tokenizer.space(src)) {
40736           src = src.substring(token.raw.length);
40737           if (token.raw.length === 1 && tokens.length > 0) {
40738             tokens[tokens.length - 1].raw += "\n";
40739           } else {
40740             tokens.push(token);
40741           }
40742           continue;
40743         }
40744         if (token = this.tokenizer.code(src)) {
40745           src = src.substring(token.raw.length);
40746           lastToken = tokens[tokens.length - 1];
40747           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40748             lastToken.raw += "\n" + token.raw;
40749             lastToken.text += "\n" + token.text;
40750             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40751           } else {
40752             tokens.push(token);
40753           }
40754           continue;
40755         }
40756         if (token = this.tokenizer.fences(src)) {
40757           src = src.substring(token.raw.length);
40758           tokens.push(token);
40759           continue;
40760         }
40761         if (token = this.tokenizer.heading(src)) {
40762           src = src.substring(token.raw.length);
40763           tokens.push(token);
40764           continue;
40765         }
40766         if (token = this.tokenizer.hr(src)) {
40767           src = src.substring(token.raw.length);
40768           tokens.push(token);
40769           continue;
40770         }
40771         if (token = this.tokenizer.blockquote(src)) {
40772           src = src.substring(token.raw.length);
40773           tokens.push(token);
40774           continue;
40775         }
40776         if (token = this.tokenizer.list(src)) {
40777           src = src.substring(token.raw.length);
40778           tokens.push(token);
40779           continue;
40780         }
40781         if (token = this.tokenizer.html(src)) {
40782           src = src.substring(token.raw.length);
40783           tokens.push(token);
40784           continue;
40785         }
40786         if (token = this.tokenizer.def(src)) {
40787           src = src.substring(token.raw.length);
40788           lastToken = tokens[tokens.length - 1];
40789           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40790             lastToken.raw += "\n" + token.raw;
40791             lastToken.text += "\n" + token.raw;
40792             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40793           } else if (!this.tokens.links[token.tag]) {
40794             this.tokens.links[token.tag] = {
40795               href: token.href,
40796               title: token.title
40797             };
40798           }
40799           continue;
40800         }
40801         if (token = this.tokenizer.table(src)) {
40802           src = src.substring(token.raw.length);
40803           tokens.push(token);
40804           continue;
40805         }
40806         if (token = this.tokenizer.lheading(src)) {
40807           src = src.substring(token.raw.length);
40808           tokens.push(token);
40809           continue;
40810         }
40811         cutSrc = src;
40812         if (this.options.extensions && this.options.extensions.startBlock) {
40813           let startIndex = Infinity;
40814           const tempSrc = src.slice(1);
40815           let tempStart;
40816           this.options.extensions.startBlock.forEach((getStartIndex) => {
40817             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40818             if (typeof tempStart === "number" && tempStart >= 0) {
40819               startIndex = Math.min(startIndex, tempStart);
40820             }
40821           });
40822           if (startIndex < Infinity && startIndex >= 0) {
40823             cutSrc = src.substring(0, startIndex + 1);
40824           }
40825         }
40826         if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
40827           lastToken = tokens[tokens.length - 1];
40828           if (lastParagraphClipped && lastToken.type === "paragraph") {
40829             lastToken.raw += "\n" + token.raw;
40830             lastToken.text += "\n" + token.text;
40831             this.inlineQueue.pop();
40832             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40833           } else {
40834             tokens.push(token);
40835           }
40836           lastParagraphClipped = cutSrc.length !== src.length;
40837           src = src.substring(token.raw.length);
40838           continue;
40839         }
40840         if (token = this.tokenizer.text(src)) {
40841           src = src.substring(token.raw.length);
40842           lastToken = tokens[tokens.length - 1];
40843           if (lastToken && lastToken.type === "text") {
40844             lastToken.raw += "\n" + token.raw;
40845             lastToken.text += "\n" + token.text;
40846             this.inlineQueue.pop();
40847             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40848           } else {
40849             tokens.push(token);
40850           }
40851           continue;
40852         }
40853         if (src) {
40854           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
40855           if (this.options.silent) {
40856             console.error(errMsg);
40857             break;
40858           } else {
40859             throw new Error(errMsg);
40860           }
40861         }
40862       }
40863       this.state.top = true;
40864       return tokens;
40865     }
40866     inline(src, tokens = []) {
40867       this.inlineQueue.push({ src, tokens });
40868       return tokens;
40869     }
40870     /**
40871      * Lexing/Compiling
40872      */
40873     inlineTokens(src, tokens = []) {
40874       let token, lastToken, cutSrc;
40875       let maskedSrc = src;
40876       let match;
40877       let keepPrevChar, prevChar;
40878       if (this.tokens.links) {
40879         const links = Object.keys(this.tokens.links);
40880         if (links.length > 0) {
40881           while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
40882             if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
40883               maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
40884             }
40885           }
40886         }
40887       }
40888       while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
40889         maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
40890       }
40891       while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
40892         maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
40893       }
40894       while (src) {
40895         if (!keepPrevChar) {
40896           prevChar = "";
40897         }
40898         keepPrevChar = false;
40899         if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
40900           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40901             src = src.substring(token.raw.length);
40902             tokens.push(token);
40903             return true;
40904           }
40905           return false;
40906         })) {
40907           continue;
40908         }
40909         if (token = this.tokenizer.escape(src)) {
40910           src = src.substring(token.raw.length);
40911           tokens.push(token);
40912           continue;
40913         }
40914         if (token = this.tokenizer.tag(src)) {
40915           src = src.substring(token.raw.length);
40916           lastToken = tokens[tokens.length - 1];
40917           if (lastToken && token.type === "text" && lastToken.type === "text") {
40918             lastToken.raw += token.raw;
40919             lastToken.text += token.text;
40920           } else {
40921             tokens.push(token);
40922           }
40923           continue;
40924         }
40925         if (token = this.tokenizer.link(src)) {
40926           src = src.substring(token.raw.length);
40927           tokens.push(token);
40928           continue;
40929         }
40930         if (token = this.tokenizer.reflink(src, this.tokens.links)) {
40931           src = src.substring(token.raw.length);
40932           lastToken = tokens[tokens.length - 1];
40933           if (lastToken && token.type === "text" && lastToken.type === "text") {
40934             lastToken.raw += token.raw;
40935             lastToken.text += token.text;
40936           } else {
40937             tokens.push(token);
40938           }
40939           continue;
40940         }
40941         if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
40942           src = src.substring(token.raw.length);
40943           tokens.push(token);
40944           continue;
40945         }
40946         if (token = this.tokenizer.codespan(src)) {
40947           src = src.substring(token.raw.length);
40948           tokens.push(token);
40949           continue;
40950         }
40951         if (token = this.tokenizer.br(src)) {
40952           src = src.substring(token.raw.length);
40953           tokens.push(token);
40954           continue;
40955         }
40956         if (token = this.tokenizer.del(src)) {
40957           src = src.substring(token.raw.length);
40958           tokens.push(token);
40959           continue;
40960         }
40961         if (token = this.tokenizer.autolink(src)) {
40962           src = src.substring(token.raw.length);
40963           tokens.push(token);
40964           continue;
40965         }
40966         if (!this.state.inLink && (token = this.tokenizer.url(src))) {
40967           src = src.substring(token.raw.length);
40968           tokens.push(token);
40969           continue;
40970         }
40971         cutSrc = src;
40972         if (this.options.extensions && this.options.extensions.startInline) {
40973           let startIndex = Infinity;
40974           const tempSrc = src.slice(1);
40975           let tempStart;
40976           this.options.extensions.startInline.forEach((getStartIndex) => {
40977             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40978             if (typeof tempStart === "number" && tempStart >= 0) {
40979               startIndex = Math.min(startIndex, tempStart);
40980             }
40981           });
40982           if (startIndex < Infinity && startIndex >= 0) {
40983             cutSrc = src.substring(0, startIndex + 1);
40984           }
40985         }
40986         if (token = this.tokenizer.inlineText(cutSrc)) {
40987           src = src.substring(token.raw.length);
40988           if (token.raw.slice(-1) !== "_") {
40989             prevChar = token.raw.slice(-1);
40990           }
40991           keepPrevChar = true;
40992           lastToken = tokens[tokens.length - 1];
40993           if (lastToken && lastToken.type === "text") {
40994             lastToken.raw += token.raw;
40995             lastToken.text += token.text;
40996           } else {
40997             tokens.push(token);
40998           }
40999           continue;
41000         }
41001         if (src) {
41002           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
41003           if (this.options.silent) {
41004             console.error(errMsg);
41005             break;
41006           } else {
41007             throw new Error(errMsg);
41008           }
41009         }
41010       }
41011       return tokens;
41012     }
41013   };
41014   var _Renderer = class {
41015     constructor(options2) {
41016       __publicField(this, "options");
41017       this.options = options2 || _defaults;
41018     }
41019     code(code, infostring, escaped) {
41020       var _a2;
41021       const lang = (_a2 = (infostring || "").match(/^\S*/)) == null ? void 0 : _a2[0];
41022       code = code.replace(/\n$/, "") + "\n";
41023       if (!lang) {
41024         return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41025       }
41026       return '<pre><code class="language-' + escape$1(lang) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41027     }
41028     blockquote(quote) {
41029       return "<blockquote>\n".concat(quote, "</blockquote>\n");
41030     }
41031     html(html3, block2) {
41032       return html3;
41033     }
41034     heading(text, level, raw) {
41035       return "<h".concat(level, ">").concat(text, "</h").concat(level, ">\n");
41036     }
41037     hr() {
41038       return "<hr>\n";
41039     }
41040     list(body, ordered, start2) {
41041       const type2 = ordered ? "ol" : "ul";
41042       const startatt = ordered && start2 !== 1 ? ' start="' + start2 + '"' : "";
41043       return "<" + type2 + startatt + ">\n" + body + "</" + type2 + ">\n";
41044     }
41045     listitem(text, task, checked) {
41046       return "<li>".concat(text, "</li>\n");
41047     }
41048     checkbox(checked) {
41049       return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
41050     }
41051     paragraph(text) {
41052       return "<p>".concat(text, "</p>\n");
41053     }
41054     table(header, body) {
41055       if (body)
41056         body = "<tbody>".concat(body, "</tbody>");
41057       return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
41058     }
41059     tablerow(content) {
41060       return "<tr>\n".concat(content, "</tr>\n");
41061     }
41062     tablecell(content, flags) {
41063       const type2 = flags.header ? "th" : "td";
41064       const tag2 = flags.align ? "<".concat(type2, ' align="').concat(flags.align, '">') : "<".concat(type2, ">");
41065       return tag2 + content + "</".concat(type2, ">\n");
41066     }
41067     /**
41068      * span level renderer
41069      */
41070     strong(text) {
41071       return "<strong>".concat(text, "</strong>");
41072     }
41073     em(text) {
41074       return "<em>".concat(text, "</em>");
41075     }
41076     codespan(text) {
41077       return "<code>".concat(text, "</code>");
41078     }
41079     br() {
41080       return "<br>";
41081     }
41082     del(text) {
41083       return "<del>".concat(text, "</del>");
41084     }
41085     link(href, title, text) {
41086       const cleanHref = cleanUrl(href);
41087       if (cleanHref === null) {
41088         return text;
41089       }
41090       href = cleanHref;
41091       let out = '<a href="' + href + '"';
41092       if (title) {
41093         out += ' title="' + title + '"';
41094       }
41095       out += ">" + text + "</a>";
41096       return out;
41097     }
41098     image(href, title, text) {
41099       const cleanHref = cleanUrl(href);
41100       if (cleanHref === null) {
41101         return text;
41102       }
41103       href = cleanHref;
41104       let out = '<img src="'.concat(href, '" alt="').concat(text, '"');
41105       if (title) {
41106         out += ' title="'.concat(title, '"');
41107       }
41108       out += ">";
41109       return out;
41110     }
41111     text(text) {
41112       return text;
41113     }
41114   };
41115   var _TextRenderer = class {
41116     // no need for block level renderers
41117     strong(text) {
41118       return text;
41119     }
41120     em(text) {
41121       return text;
41122     }
41123     codespan(text) {
41124       return text;
41125     }
41126     del(text) {
41127       return text;
41128     }
41129     html(text) {
41130       return text;
41131     }
41132     text(text) {
41133       return text;
41134     }
41135     link(href, title, text) {
41136       return "" + text;
41137     }
41138     image(href, title, text) {
41139       return "" + text;
41140     }
41141     br() {
41142       return "";
41143     }
41144   };
41145   var _Parser = class __Parser {
41146     constructor(options2) {
41147       __publicField(this, "options");
41148       __publicField(this, "renderer");
41149       __publicField(this, "textRenderer");
41150       this.options = options2 || _defaults;
41151       this.options.renderer = this.options.renderer || new _Renderer();
41152       this.renderer = this.options.renderer;
41153       this.renderer.options = this.options;
41154       this.textRenderer = new _TextRenderer();
41155     }
41156     /**
41157      * Static Parse Method
41158      */
41159     static parse(tokens, options2) {
41160       const parser3 = new __Parser(options2);
41161       return parser3.parse(tokens);
41162     }
41163     /**
41164      * Static Parse Inline Method
41165      */
41166     static parseInline(tokens, options2) {
41167       const parser3 = new __Parser(options2);
41168       return parser3.parseInline(tokens);
41169     }
41170     /**
41171      * Parse Loop
41172      */
41173     parse(tokens, top = true) {
41174       let out = "";
41175       for (let i3 = 0; i3 < tokens.length; i3++) {
41176         const token = tokens[i3];
41177         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41178           const genericToken = token;
41179           const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
41180           if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
41181             out += ret || "";
41182             continue;
41183           }
41184         }
41185         switch (token.type) {
41186           case "space": {
41187             continue;
41188           }
41189           case "hr": {
41190             out += this.renderer.hr();
41191             continue;
41192           }
41193           case "heading": {
41194             const headingToken = token;
41195             out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape2(this.parseInline(headingToken.tokens, this.textRenderer)));
41196             continue;
41197           }
41198           case "code": {
41199             const codeToken = token;
41200             out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
41201             continue;
41202           }
41203           case "table": {
41204             const tableToken = token;
41205             let header = "";
41206             let cell = "";
41207             for (let j2 = 0; j2 < tableToken.header.length; j2++) {
41208               cell += this.renderer.tablecell(this.parseInline(tableToken.header[j2].tokens), { header: true, align: tableToken.align[j2] });
41209             }
41210             header += this.renderer.tablerow(cell);
41211             let body = "";
41212             for (let j2 = 0; j2 < tableToken.rows.length; j2++) {
41213               const row = tableToken.rows[j2];
41214               cell = "";
41215               for (let k2 = 0; k2 < row.length; k2++) {
41216                 cell += this.renderer.tablecell(this.parseInline(row[k2].tokens), { header: false, align: tableToken.align[k2] });
41217               }
41218               body += this.renderer.tablerow(cell);
41219             }
41220             out += this.renderer.table(header, body);
41221             continue;
41222           }
41223           case "blockquote": {
41224             const blockquoteToken = token;
41225             const body = this.parse(blockquoteToken.tokens);
41226             out += this.renderer.blockquote(body);
41227             continue;
41228           }
41229           case "list": {
41230             const listToken = token;
41231             const ordered = listToken.ordered;
41232             const start2 = listToken.start;
41233             const loose = listToken.loose;
41234             let body = "";
41235             for (let j2 = 0; j2 < listToken.items.length; j2++) {
41236               const item = listToken.items[j2];
41237               const checked = item.checked;
41238               const task = item.task;
41239               let itemBody = "";
41240               if (item.task) {
41241                 const checkbox = this.renderer.checkbox(!!checked);
41242                 if (loose) {
41243                   if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
41244                     item.tokens[0].text = checkbox + " " + item.tokens[0].text;
41245                     if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
41246                       item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
41247                     }
41248                   } else {
41249                     item.tokens.unshift({
41250                       type: "text",
41251                       text: checkbox + " "
41252                     });
41253                   }
41254                 } else {
41255                   itemBody += checkbox + " ";
41256                 }
41257               }
41258               itemBody += this.parse(item.tokens, loose);
41259               body += this.renderer.listitem(itemBody, task, !!checked);
41260             }
41261             out += this.renderer.list(body, ordered, start2);
41262             continue;
41263           }
41264           case "html": {
41265             const htmlToken = token;
41266             out += this.renderer.html(htmlToken.text, htmlToken.block);
41267             continue;
41268           }
41269           case "paragraph": {
41270             const paragraphToken = token;
41271             out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
41272             continue;
41273           }
41274           case "text": {
41275             let textToken = token;
41276             let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
41277             while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
41278               textToken = tokens[++i3];
41279               body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
41280             }
41281             out += top ? this.renderer.paragraph(body) : body;
41282             continue;
41283           }
41284           default: {
41285             const errMsg = 'Token with "' + token.type + '" type was not found.';
41286             if (this.options.silent) {
41287               console.error(errMsg);
41288               return "";
41289             } else {
41290               throw new Error(errMsg);
41291             }
41292           }
41293         }
41294       }
41295       return out;
41296     }
41297     /**
41298      * Parse Inline Tokens
41299      */
41300     parseInline(tokens, renderer) {
41301       renderer = renderer || this.renderer;
41302       let out = "";
41303       for (let i3 = 0; i3 < tokens.length; i3++) {
41304         const token = tokens[i3];
41305         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41306           const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
41307           if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
41308             out += ret || "";
41309             continue;
41310           }
41311         }
41312         switch (token.type) {
41313           case "escape": {
41314             const escapeToken = token;
41315             out += renderer.text(escapeToken.text);
41316             break;
41317           }
41318           case "html": {
41319             const tagToken = token;
41320             out += renderer.html(tagToken.text);
41321             break;
41322           }
41323           case "link": {
41324             const linkToken = token;
41325             out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
41326             break;
41327           }
41328           case "image": {
41329             const imageToken = token;
41330             out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
41331             break;
41332           }
41333           case "strong": {
41334             const strongToken = token;
41335             out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
41336             break;
41337           }
41338           case "em": {
41339             const emToken = token;
41340             out += renderer.em(this.parseInline(emToken.tokens, renderer));
41341             break;
41342           }
41343           case "codespan": {
41344             const codespanToken = token;
41345             out += renderer.codespan(codespanToken.text);
41346             break;
41347           }
41348           case "br": {
41349             out += renderer.br();
41350             break;
41351           }
41352           case "del": {
41353             const delToken = token;
41354             out += renderer.del(this.parseInline(delToken.tokens, renderer));
41355             break;
41356           }
41357           case "text": {
41358             const textToken = token;
41359             out += renderer.text(textToken.text);
41360             break;
41361           }
41362           default: {
41363             const errMsg = 'Token with "' + token.type + '" type was not found.';
41364             if (this.options.silent) {
41365               console.error(errMsg);
41366               return "";
41367             } else {
41368               throw new Error(errMsg);
41369             }
41370           }
41371         }
41372       }
41373       return out;
41374     }
41375   };
41376   var _Hooks = class {
41377     constructor(options2) {
41378       __publicField(this, "options");
41379       this.options = options2 || _defaults;
41380     }
41381     /**
41382      * Process markdown before marked
41383      */
41384     preprocess(markdown) {
41385       return markdown;
41386     }
41387     /**
41388      * Process HTML after marked is finished
41389      */
41390     postprocess(html3) {
41391       return html3;
41392     }
41393     /**
41394      * Process all tokens before walk tokens
41395      */
41396     processAllTokens(tokens) {
41397       return tokens;
41398     }
41399   };
41400   __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
41401     "preprocess",
41402     "postprocess",
41403     "processAllTokens"
41404   ]));
41405   var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
41406   var Marked = class {
41407     constructor(...args) {
41408       __privateAdd(this, _parseMarkdown);
41409       __privateAdd(this, _onError);
41410       __publicField(this, "defaults", _getDefaults());
41411       __publicField(this, "options", this.setOptions);
41412       __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
41413       __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
41414       __publicField(this, "Parser", _Parser);
41415       __publicField(this, "Renderer", _Renderer);
41416       __publicField(this, "TextRenderer", _TextRenderer);
41417       __publicField(this, "Lexer", _Lexer);
41418       __publicField(this, "Tokenizer", _Tokenizer);
41419       __publicField(this, "Hooks", _Hooks);
41420       this.use(...args);
41421     }
41422     /**
41423      * Run callback for every token
41424      */
41425     walkTokens(tokens, callback) {
41426       var _a2, _b;
41427       let values = [];
41428       for (const token of tokens) {
41429         values = values.concat(callback.call(this, token));
41430         switch (token.type) {
41431           case "table": {
41432             const tableToken = token;
41433             for (const cell of tableToken.header) {
41434               values = values.concat(this.walkTokens(cell.tokens, callback));
41435             }
41436             for (const row of tableToken.rows) {
41437               for (const cell of row) {
41438                 values = values.concat(this.walkTokens(cell.tokens, callback));
41439               }
41440             }
41441             break;
41442           }
41443           case "list": {
41444             const listToken = token;
41445             values = values.concat(this.walkTokens(listToken.items, callback));
41446             break;
41447           }
41448           default: {
41449             const genericToken = token;
41450             if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) {
41451               this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
41452                 const tokens2 = genericToken[childTokens].flat(Infinity);
41453                 values = values.concat(this.walkTokens(tokens2, callback));
41454               });
41455             } else if (genericToken.tokens) {
41456               values = values.concat(this.walkTokens(genericToken.tokens, callback));
41457             }
41458           }
41459         }
41460       }
41461       return values;
41462     }
41463     use(...args) {
41464       const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
41465       args.forEach((pack) => {
41466         const opts = { ...pack };
41467         opts.async = this.defaults.async || opts.async || false;
41468         if (pack.extensions) {
41469           pack.extensions.forEach((ext) => {
41470             if (!ext.name) {
41471               throw new Error("extension name required");
41472             }
41473             if ("renderer" in ext) {
41474               const prevRenderer = extensions.renderers[ext.name];
41475               if (prevRenderer) {
41476                 extensions.renderers[ext.name] = function(...args2) {
41477                   let ret = ext.renderer.apply(this, args2);
41478                   if (ret === false) {
41479                     ret = prevRenderer.apply(this, args2);
41480                   }
41481                   return ret;
41482                 };
41483               } else {
41484                 extensions.renderers[ext.name] = ext.renderer;
41485               }
41486             }
41487             if ("tokenizer" in ext) {
41488               if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
41489                 throw new Error("extension level must be 'block' or 'inline'");
41490               }
41491               const extLevel = extensions[ext.level];
41492               if (extLevel) {
41493                 extLevel.unshift(ext.tokenizer);
41494               } else {
41495                 extensions[ext.level] = [ext.tokenizer];
41496               }
41497               if (ext.start) {
41498                 if (ext.level === "block") {
41499                   if (extensions.startBlock) {
41500                     extensions.startBlock.push(ext.start);
41501                   } else {
41502                     extensions.startBlock = [ext.start];
41503                   }
41504                 } else if (ext.level === "inline") {
41505                   if (extensions.startInline) {
41506                     extensions.startInline.push(ext.start);
41507                   } else {
41508                     extensions.startInline = [ext.start];
41509                   }
41510                 }
41511               }
41512             }
41513             if ("childTokens" in ext && ext.childTokens) {
41514               extensions.childTokens[ext.name] = ext.childTokens;
41515             }
41516           });
41517           opts.extensions = extensions;
41518         }
41519         if (pack.renderer) {
41520           const renderer = this.defaults.renderer || new _Renderer(this.defaults);
41521           for (const prop in pack.renderer) {
41522             if (!(prop in renderer)) {
41523               throw new Error("renderer '".concat(prop, "' does not exist"));
41524             }
41525             if (prop === "options") {
41526               continue;
41527             }
41528             const rendererProp = prop;
41529             const rendererFunc = pack.renderer[rendererProp];
41530             const prevRenderer = renderer[rendererProp];
41531             renderer[rendererProp] = (...args2) => {
41532               let ret = rendererFunc.apply(renderer, args2);
41533               if (ret === false) {
41534                 ret = prevRenderer.apply(renderer, args2);
41535               }
41536               return ret || "";
41537             };
41538           }
41539           opts.renderer = renderer;
41540         }
41541         if (pack.tokenizer) {
41542           const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
41543           for (const prop in pack.tokenizer) {
41544             if (!(prop in tokenizer)) {
41545               throw new Error("tokenizer '".concat(prop, "' does not exist"));
41546             }
41547             if (["options", "rules", "lexer"].includes(prop)) {
41548               continue;
41549             }
41550             const tokenizerProp = prop;
41551             const tokenizerFunc = pack.tokenizer[tokenizerProp];
41552             const prevTokenizer = tokenizer[tokenizerProp];
41553             tokenizer[tokenizerProp] = (...args2) => {
41554               let ret = tokenizerFunc.apply(tokenizer, args2);
41555               if (ret === false) {
41556                 ret = prevTokenizer.apply(tokenizer, args2);
41557               }
41558               return ret;
41559             };
41560           }
41561           opts.tokenizer = tokenizer;
41562         }
41563         if (pack.hooks) {
41564           const hooks = this.defaults.hooks || new _Hooks();
41565           for (const prop in pack.hooks) {
41566             if (!(prop in hooks)) {
41567               throw new Error("hook '".concat(prop, "' does not exist"));
41568             }
41569             if (prop === "options") {
41570               continue;
41571             }
41572             const hooksProp = prop;
41573             const hooksFunc = pack.hooks[hooksProp];
41574             const prevHook = hooks[hooksProp];
41575             if (_Hooks.passThroughHooks.has(prop)) {
41576               hooks[hooksProp] = (arg) => {
41577                 if (this.defaults.async) {
41578                   return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
41579                     return prevHook.call(hooks, ret2);
41580                   });
41581                 }
41582                 const ret = hooksFunc.call(hooks, arg);
41583                 return prevHook.call(hooks, ret);
41584               };
41585             } else {
41586               hooks[hooksProp] = (...args2) => {
41587                 let ret = hooksFunc.apply(hooks, args2);
41588                 if (ret === false) {
41589                   ret = prevHook.apply(hooks, args2);
41590                 }
41591                 return ret;
41592               };
41593             }
41594           }
41595           opts.hooks = hooks;
41596         }
41597         if (pack.walkTokens) {
41598           const walkTokens2 = this.defaults.walkTokens;
41599           const packWalktokens = pack.walkTokens;
41600           opts.walkTokens = function(token) {
41601             let values = [];
41602             values.push(packWalktokens.call(this, token));
41603             if (walkTokens2) {
41604               values = values.concat(walkTokens2.call(this, token));
41605             }
41606             return values;
41607           };
41608         }
41609         this.defaults = { ...this.defaults, ...opts };
41610       });
41611       return this;
41612     }
41613     setOptions(opt) {
41614       this.defaults = { ...this.defaults, ...opt };
41615       return this;
41616     }
41617     lexer(src, options2) {
41618       return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
41619     }
41620     parser(tokens, options2) {
41621       return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
41622     }
41623   };
41624   _parseMarkdown = new WeakSet();
41625   parseMarkdown_fn = function(lexer2, parser3) {
41626     return (src, options2) => {
41627       const origOpt = { ...options2 };
41628       const opt = { ...this.defaults, ...origOpt };
41629       if (this.defaults.async === true && origOpt.async === false) {
41630         if (!opt.silent) {
41631           console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
41632         }
41633         opt.async = true;
41634       }
41635       const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async);
41636       if (typeof src === "undefined" || src === null) {
41637         return throwError(new Error("marked(): input parameter is undefined or null"));
41638       }
41639       if (typeof src !== "string") {
41640         return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
41641       }
41642       if (opt.hooks) {
41643         opt.hooks.options = opt;
41644       }
41645       if (opt.async) {
41646         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);
41647       }
41648       try {
41649         if (opt.hooks) {
41650           src = opt.hooks.preprocess(src);
41651         }
41652         let tokens = lexer2(src, opt);
41653         if (opt.hooks) {
41654           tokens = opt.hooks.processAllTokens(tokens);
41655         }
41656         if (opt.walkTokens) {
41657           this.walkTokens(tokens, opt.walkTokens);
41658         }
41659         let html3 = parser3(tokens, opt);
41660         if (opt.hooks) {
41661           html3 = opt.hooks.postprocess(html3);
41662         }
41663         return html3;
41664       } catch (e3) {
41665         return throwError(e3);
41666       }
41667     };
41668   };
41669   _onError = new WeakSet();
41670   onError_fn = function(silent, async) {
41671     return (e3) => {
41672       e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
41673       if (silent) {
41674         const msg = "<p>An error occurred:</p><pre>" + escape$1(e3.message + "", true) + "</pre>";
41675         if (async) {
41676           return Promise.resolve(msg);
41677         }
41678         return msg;
41679       }
41680       if (async) {
41681         return Promise.reject(e3);
41682       }
41683       throw e3;
41684     };
41685   };
41686   var markedInstance = new Marked();
41687   function marked(src, opt) {
41688     return markedInstance.parse(src, opt);
41689   }
41690   marked.options = marked.setOptions = function(options2) {
41691     markedInstance.setOptions(options2);
41692     marked.defaults = markedInstance.defaults;
41693     changeDefaults(marked.defaults);
41694     return marked;
41695   };
41696   marked.getDefaults = _getDefaults;
41697   marked.defaults = _defaults;
41698   marked.use = function(...args) {
41699     markedInstance.use(...args);
41700     marked.defaults = markedInstance.defaults;
41701     changeDefaults(marked.defaults);
41702     return marked;
41703   };
41704   marked.walkTokens = function(tokens, callback) {
41705     return markedInstance.walkTokens(tokens, callback);
41706   };
41707   marked.parseInline = markedInstance.parseInline;
41708   marked.Parser = _Parser;
41709   marked.parser = _Parser.parse;
41710   marked.Renderer = _Renderer;
41711   marked.TextRenderer = _TextRenderer;
41712   marked.Lexer = _Lexer;
41713   marked.lexer = _Lexer.lex;
41714   marked.Tokenizer = _Tokenizer;
41715   marked.Hooks = _Hooks;
41716   marked.parse = marked;
41717   var options = marked.options;
41718   var setOptions = marked.setOptions;
41719   var use = marked.use;
41720   var walkTokens = marked.walkTokens;
41721   var parseInline = marked.parseInline;
41722   var parser2 = _Parser.parse;
41723   var lexer = _Lexer.lex;
41724
41725   // modules/services/osmose.js
41726   var tiler3 = utilTiler();
41727   var dispatch4 = dispatch_default("loaded");
41728   var _tileZoom3 = 14;
41729   var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3";
41730   var _osmoseData = { icons: {}, items: [] };
41731   var _cache3;
41732   function abortRequest3(controller) {
41733     if (controller) {
41734       controller.abort();
41735     }
41736   }
41737   function abortUnwantedRequests3(cache, tiles) {
41738     Object.keys(cache.inflightTile).forEach((k2) => {
41739       let wanted = tiles.find((tile) => k2 === tile.id);
41740       if (!wanted) {
41741         abortRequest3(cache.inflightTile[k2]);
41742         delete cache.inflightTile[k2];
41743       }
41744     });
41745   }
41746   function encodeIssueRtree3(d2) {
41747     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
41748   }
41749   function updateRtree3(item, replace) {
41750     _cache3.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
41751     if (replace) {
41752       _cache3.rtree.insert(item);
41753     }
41754   }
41755   function preventCoincident2(loc) {
41756     let coincident = false;
41757     do {
41758       let delta = coincident ? [1e-5, 0] : [0, 1e-5];
41759       loc = geoVecAdd(loc, delta);
41760       let bbox2 = geoExtent(loc).bbox();
41761       coincident = _cache3.rtree.search(bbox2).length;
41762     } while (coincident);
41763     return loc;
41764   }
41765   var osmose_default = {
41766     title: "osmose",
41767     init() {
41768       _mainFileFetcher.get("qa_data").then((d2) => {
41769         _osmoseData = d2.osmose;
41770         _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []);
41771       });
41772       if (!_cache3) {
41773         this.reset();
41774       }
41775       this.event = utilRebind(this, dispatch4, "on");
41776     },
41777     reset() {
41778       let _strings = {};
41779       let _colors = {};
41780       if (_cache3) {
41781         Object.values(_cache3.inflightTile).forEach(abortRequest3);
41782         _strings = _cache3.strings;
41783         _colors = _cache3.colors;
41784       }
41785       _cache3 = {
41786         data: {},
41787         loadedTile: {},
41788         inflightTile: {},
41789         inflightPost: {},
41790         closed: {},
41791         rtree: new import_rbush3.default(),
41792         strings: _strings,
41793         colors: _colors
41794       };
41795     },
41796     loadIssues(projection2) {
41797       let params = {
41798         // Tiles return a maximum # of issues
41799         // So we want to filter our request for only types iD supports
41800         item: _osmoseData.items
41801       };
41802       let tiles = tiler3.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
41803       abortUnwantedRequests3(_cache3, tiles);
41804       tiles.forEach((tile) => {
41805         if (_cache3.loadedTile[tile.id] || _cache3.inflightTile[tile.id])
41806           return;
41807         let [x2, y2, z2] = tile.xyz;
41808         let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params);
41809         let controller = new AbortController();
41810         _cache3.inflightTile[tile.id] = controller;
41811         json_default(url, { signal: controller.signal }).then((data) => {
41812           delete _cache3.inflightTile[tile.id];
41813           _cache3.loadedTile[tile.id] = true;
41814           if (data.features) {
41815             data.features.forEach((issue) => {
41816               const { item, class: cl, uuid: id2 } = issue.properties;
41817               const itemType = "".concat(item, "-").concat(cl);
41818               if (itemType in _osmoseData.icons) {
41819                 let loc = issue.geometry.coordinates;
41820                 loc = preventCoincident2(loc);
41821                 let d2 = new QAItem(loc, this, itemType, id2, { item });
41822                 if (item === 8300 || item === 8360) {
41823                   d2.elems = [];
41824                 }
41825                 _cache3.data[d2.id] = d2;
41826                 _cache3.rtree.insert(encodeIssueRtree3(d2));
41827               }
41828             });
41829           }
41830           dispatch4.call("loaded");
41831         }).catch(() => {
41832           delete _cache3.inflightTile[tile.id];
41833           _cache3.loadedTile[tile.id] = true;
41834         });
41835       });
41836     },
41837     loadIssueDetail(issue) {
41838       if (issue.elems !== void 0) {
41839         return Promise.resolve(issue);
41840       }
41841       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode());
41842       const cacheDetails = (data) => {
41843         issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id);
41844         issue.detail = data.subtitle ? marked(data.subtitle.auto) : "";
41845         this.replaceItem(issue);
41846       };
41847       return json_default(url).then(cacheDetails).then(() => issue);
41848     },
41849     loadStrings(locale2 = _mainLocalizer.localeCode()) {
41850       const items = Object.keys(_osmoseData.icons);
41851       if (locale2 in _cache3.strings && Object.keys(_cache3.strings[locale2]).length === items.length) {
41852         return Promise.resolve(_cache3.strings[locale2]);
41853       }
41854       if (!(locale2 in _cache3.strings)) {
41855         _cache3.strings[locale2] = {};
41856       }
41857       const allRequests = items.map((itemType) => {
41858         if (itemType in _cache3.strings[locale2])
41859           return null;
41860         const cacheData = (data) => {
41861           const [cat = { items: [] }] = data.categories;
41862           const [item2 = { class: [] }] = cat.items;
41863           const [cl2 = null] = item2.class;
41864           if (!cl2) {
41865             console.log("Osmose strings request (".concat(itemType, ") had unexpected data"));
41866             return;
41867           }
41868           const { item: itemInt, color: color2 } = item2;
41869           if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) {
41870             _cache3.colors[itemInt] = color2;
41871           }
41872           const { title, detail, fix, trap } = cl2;
41873           let issueStrings = {};
41874           if (title)
41875             issueStrings.title = title.auto;
41876           if (detail)
41877             issueStrings.detail = marked(detail.auto);
41878           if (trap)
41879             issueStrings.trap = marked(trap.auto);
41880           if (fix)
41881             issueStrings.fix = marked(fix.auto);
41882           _cache3.strings[locale2][itemType] = issueStrings;
41883         };
41884         const [item, cl] = itemType.split("-");
41885         const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2);
41886         return json_default(url).then(cacheData);
41887       }).filter(Boolean);
41888       return Promise.all(allRequests).then(() => _cache3.strings[locale2]);
41889     },
41890     getStrings(itemType, locale2 = _mainLocalizer.localeCode()) {
41891       return locale2 in _cache3.strings ? _cache3.strings[locale2][itemType] : {};
41892     },
41893     getColor(itemType) {
41894       return itemType in _cache3.colors ? _cache3.colors[itemType] : "#FFFFFF";
41895     },
41896     postUpdate(issue, callback) {
41897       if (_cache3.inflightPost[issue.id]) {
41898         return callback({ message: "Issue update already inflight", status: -2 }, issue);
41899       }
41900       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus);
41901       const controller = new AbortController();
41902       const after = () => {
41903         delete _cache3.inflightPost[issue.id];
41904         this.removeItem(issue);
41905         if (issue.newStatus === "done") {
41906           if (!(issue.item in _cache3.closed)) {
41907             _cache3.closed[issue.item] = 0;
41908           }
41909           _cache3.closed[issue.item] += 1;
41910         }
41911         if (callback)
41912           callback(null, issue);
41913       };
41914       _cache3.inflightPost[issue.id] = controller;
41915       fetch(url, { signal: controller.signal }).then(after).catch((err) => {
41916         delete _cache3.inflightPost[issue.id];
41917         if (callback)
41918           callback(err.message);
41919       });
41920     },
41921     // Get all cached QAItems covering the viewport
41922     getItems(projection2) {
41923       const viewport = projection2.clipExtent();
41924       const min3 = [viewport[0][0], viewport[1][1]];
41925       const max3 = [viewport[1][0], viewport[0][1]];
41926       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
41927       return _cache3.rtree.search(bbox2).map((d2) => d2.data);
41928     },
41929     // Get a QAItem from cache
41930     // NOTE: Don't change method name until UI v3 is merged
41931     getError(id2) {
41932       return _cache3.data[id2];
41933     },
41934     // get the name of the icon to display for this item
41935     getIcon(itemType) {
41936       return _osmoseData.icons[itemType];
41937     },
41938     // Replace a single QAItem in the cache
41939     replaceItem(item) {
41940       if (!(item instanceof QAItem) || !item.id)
41941         return;
41942       _cache3.data[item.id] = item;
41943       updateRtree3(encodeIssueRtree3(item), true);
41944       return item;
41945     },
41946     // Remove a single QAItem from the cache
41947     removeItem(item) {
41948       if (!(item instanceof QAItem) || !item.id)
41949         return;
41950       delete _cache3.data[item.id];
41951       updateRtree3(encodeIssueRtree3(item), false);
41952     },
41953     // Used to populate `closed:osmose:*` changeset tags
41954     getClosedCounts() {
41955       return _cache3.closed;
41956     },
41957     itemURL(item) {
41958       return "https://osmose.openstreetmap.fr/en/error/".concat(item.id);
41959     }
41960   };
41961
41962   // modules/services/mapillary.js
41963   var import_pbf = __toESM(require_pbf());
41964   var import_rbush4 = __toESM(require_rbush_min());
41965   var import_vector_tile = __toESM(require_vector_tile());
41966   var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf";
41967   var apiUrl = "https://graph.mapillary.com/";
41968   var baseTileUrl = "https://tiles.mapillary.com/maps/vtp";
41969   var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41970   var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41971   var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41972   var viewercss = "mapillary-js/mapillary.css";
41973   var viewerjs = "mapillary-js/mapillary.js";
41974   var minZoom = 14;
41975   var dispatch5 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged");
41976   var _loadViewerPromise;
41977   var _mlyActiveImage;
41978   var _mlyCache;
41979   var _mlyFallback = false;
41980   var _mlyHighlightedDetection;
41981   var _mlyShowFeatureDetections = false;
41982   var _mlyShowSignDetections = false;
41983   var _mlyViewer;
41984   var _mlyViewerFilter = ["all"];
41985   function loadTiles(which, url, maxZoom2, projection2) {
41986     const tiler9 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true);
41987     const tiles = tiler9.getTiles(projection2);
41988     tiles.forEach(function(tile) {
41989       loadTile(which, url, tile);
41990     });
41991   }
41992   function loadTile(which, url, tile) {
41993     const cache = _mlyCache.requests;
41994     const tileId = "".concat(tile.id, "-").concat(which);
41995     if (cache.loaded[tileId] || cache.inflight[tileId])
41996       return;
41997     const controller = new AbortController();
41998     cache.inflight[tileId] = controller;
41999     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
42000     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
42001       if (!response.ok) {
42002         throw new Error(response.status + " " + response.statusText);
42003       }
42004       cache.loaded[tileId] = true;
42005       delete cache.inflight[tileId];
42006       return response.arrayBuffer();
42007     }).then(function(data) {
42008       if (!data) {
42009         throw new Error("No Data");
42010       }
42011       loadTileDataToCache(data, tile, which);
42012       if (which === "images") {
42013         dispatch5.call("loadedImages");
42014       } else if (which === "signs") {
42015         dispatch5.call("loadedSigns");
42016       } else if (which === "points") {
42017         dispatch5.call("loadedMapFeatures");
42018       }
42019     }).catch(function() {
42020       cache.loaded[tileId] = true;
42021       delete cache.inflight[tileId];
42022     });
42023   }
42024   function loadTileDataToCache(data, tile, which) {
42025     const vectorTile = new import_vector_tile.VectorTile(new import_pbf.default(data));
42026     let features, cache, layer, i3, feature3, loc, d2;
42027     if (vectorTile.layers.hasOwnProperty("image")) {
42028       features = [];
42029       cache = _mlyCache.images;
42030       layer = vectorTile.layers.image;
42031       for (i3 = 0; i3 < layer.length; i3++) {
42032         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42033         loc = feature3.geometry.coordinates;
42034         d2 = {
42035           loc,
42036           captured_at: feature3.properties.captured_at,
42037           ca: feature3.properties.compass_angle,
42038           id: feature3.properties.id,
42039           is_pano: feature3.properties.is_pano,
42040           sequence_id: feature3.properties.sequence_id
42041         };
42042         cache.forImageId[d2.id] = d2;
42043         features.push({
42044           minX: loc[0],
42045           minY: loc[1],
42046           maxX: loc[0],
42047           maxY: loc[1],
42048           data: d2
42049         });
42050       }
42051       if (cache.rtree) {
42052         cache.rtree.load(features);
42053       }
42054     }
42055     if (vectorTile.layers.hasOwnProperty("sequence")) {
42056       features = [];
42057       cache = _mlyCache.sequences;
42058       layer = vectorTile.layers.sequence;
42059       for (i3 = 0; i3 < layer.length; i3++) {
42060         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42061         if (cache.lineString[feature3.properties.id]) {
42062           cache.lineString[feature3.properties.id].push(feature3);
42063         } else {
42064           cache.lineString[feature3.properties.id] = [feature3];
42065         }
42066       }
42067     }
42068     if (vectorTile.layers.hasOwnProperty("point")) {
42069       features = [];
42070       cache = _mlyCache[which];
42071       layer = vectorTile.layers.point;
42072       for (i3 = 0; i3 < layer.length; i3++) {
42073         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42074         loc = feature3.geometry.coordinates;
42075         d2 = {
42076           loc,
42077           id: feature3.properties.id,
42078           first_seen_at: feature3.properties.first_seen_at,
42079           last_seen_at: feature3.properties.last_seen_at,
42080           value: feature3.properties.value
42081         };
42082         features.push({
42083           minX: loc[0],
42084           minY: loc[1],
42085           maxX: loc[0],
42086           maxY: loc[1],
42087           data: d2
42088         });
42089       }
42090       if (cache.rtree) {
42091         cache.rtree.load(features);
42092       }
42093     }
42094     if (vectorTile.layers.hasOwnProperty("traffic_sign")) {
42095       features = [];
42096       cache = _mlyCache[which];
42097       layer = vectorTile.layers.traffic_sign;
42098       for (i3 = 0; i3 < layer.length; i3++) {
42099         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42100         loc = feature3.geometry.coordinates;
42101         d2 = {
42102           loc,
42103           id: feature3.properties.id,
42104           first_seen_at: feature3.properties.first_seen_at,
42105           last_seen_at: feature3.properties.last_seen_at,
42106           value: feature3.properties.value
42107         };
42108         features.push({
42109           minX: loc[0],
42110           minY: loc[1],
42111           maxX: loc[0],
42112           maxY: loc[1],
42113           data: d2
42114         });
42115       }
42116       if (cache.rtree) {
42117         cache.rtree.load(features);
42118       }
42119     }
42120   }
42121   function loadData(url) {
42122     return fetch(url).then(function(response) {
42123       if (!response.ok) {
42124         throw new Error(response.status + " " + response.statusText);
42125       }
42126       return response.json();
42127     }).then(function(result) {
42128       if (!result) {
42129         return [];
42130       }
42131       return result.data || [];
42132     });
42133   }
42134   function partitionViewport(projection2) {
42135     const z2 = geoScaleToZoom(projection2.scale());
42136     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
42137     const tiler9 = utilTiler().zoomExtent([z22, z22]);
42138     return tiler9.getTiles(projection2).map(function(tile) {
42139       return tile.extent;
42140     });
42141   }
42142   function searchLimited(limit, projection2, rtree) {
42143     limit = limit || 5;
42144     return partitionViewport(projection2).reduce(function(result, extent) {
42145       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
42146         return d2.data;
42147       });
42148       return found.length ? result.concat(found) : result;
42149     }, []);
42150   }
42151   var mapillary_default = {
42152     // Initialize Mapillary
42153     init: function() {
42154       if (!_mlyCache) {
42155         this.reset();
42156       }
42157       this.event = utilRebind(this, dispatch5, "on");
42158     },
42159     // Reset cache and state
42160     reset: function() {
42161       if (_mlyCache) {
42162         Object.values(_mlyCache.requests.inflight).forEach(function(request3) {
42163           request3.abort();
42164         });
42165       }
42166       _mlyCache = {
42167         images: { rtree: new import_rbush4.default(), forImageId: {} },
42168         image_detections: { forImageId: {} },
42169         signs: { rtree: new import_rbush4.default() },
42170         points: { rtree: new import_rbush4.default() },
42171         sequences: { rtree: new import_rbush4.default(), lineString: {} },
42172         requests: { loaded: {}, inflight: {} }
42173       };
42174       _mlyActiveImage = null;
42175     },
42176     // Get visible images
42177     images: function(projection2) {
42178       const limit = 5;
42179       return searchLimited(limit, projection2, _mlyCache.images.rtree);
42180     },
42181     // Get visible traffic signs
42182     signs: function(projection2) {
42183       const limit = 5;
42184       return searchLimited(limit, projection2, _mlyCache.signs.rtree);
42185     },
42186     // Get visible map (point) features
42187     mapFeatures: function(projection2) {
42188       const limit = 5;
42189       return searchLimited(limit, projection2, _mlyCache.points.rtree);
42190     },
42191     // Get cached image by id
42192     cachedImage: function(imageId) {
42193       return _mlyCache.images.forImageId[imageId];
42194     },
42195     // Get visible sequences
42196     sequences: function(projection2) {
42197       const viewport = projection2.clipExtent();
42198       const min3 = [viewport[0][0], viewport[1][1]];
42199       const max3 = [viewport[1][0], viewport[0][1]];
42200       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
42201       const sequenceIds = {};
42202       let lineStrings = [];
42203       _mlyCache.images.rtree.search(bbox2).forEach(function(d2) {
42204         if (d2.data.sequence_id) {
42205           sequenceIds[d2.data.sequence_id] = true;
42206         }
42207       });
42208       Object.keys(sequenceIds).forEach(function(sequenceId) {
42209         if (_mlyCache.sequences.lineString[sequenceId]) {
42210           lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]);
42211         }
42212       });
42213       return lineStrings;
42214     },
42215     // Load images in the visible area
42216     loadImages: function(projection2) {
42217       loadTiles("images", tileUrl, 14, projection2);
42218     },
42219     // Load traffic signs in the visible area
42220     loadSigns: function(projection2) {
42221       loadTiles("signs", trafficSignTileUrl, 14, projection2);
42222     },
42223     // Load map (point) features in the visible area
42224     loadMapFeatures: function(projection2) {
42225       loadTiles("points", mapFeatureTileUrl, 14, projection2);
42226     },
42227     // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading
42228     ensureViewerLoaded: function(context) {
42229       if (_loadViewerPromise)
42230         return _loadViewerPromise;
42231       const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]);
42232       wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true);
42233       const that = this;
42234       _loadViewerPromise = new Promise((resolve, reject) => {
42235         let loadedCount = 0;
42236         function loaded() {
42237           loadedCount += 1;
42238           if (loadedCount === 2)
42239             resolve();
42240         }
42241         const head = select_default2("head");
42242         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() {
42243           reject();
42244         });
42245         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() {
42246           reject();
42247         });
42248       }).catch(function() {
42249         _loadViewerPromise = null;
42250       }).then(function() {
42251         that.initViewer(context);
42252       });
42253       return _loadViewerPromise;
42254     },
42255     // Load traffic sign image sprites
42256     loadSignResources: function(context) {
42257       context.ui().svgDefs.addSprites(
42258         ["mapillary-sprite"],
42259         false
42260         /* don't override colors */
42261       );
42262       return this;
42263     },
42264     // Load map (point) feature image sprites
42265     loadObjectResources: function(context) {
42266       context.ui().svgDefs.addSprites(
42267         ["mapillary-object-sprite"],
42268         false
42269         /* don't override colors */
42270       );
42271       return this;
42272     },
42273     // Remove previous detections in image viewer
42274     resetTags: function() {
42275       if (_mlyViewer && !_mlyFallback) {
42276         _mlyViewer.getComponent("tag").removeAll();
42277       }
42278     },
42279     // Show map feature detections in image viewer
42280     showFeatureDetections: function(value) {
42281       _mlyShowFeatureDetections = value;
42282       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42283         this.resetTags();
42284       }
42285     },
42286     // Show traffic sign detections in image viewer
42287     showSignDetections: function(value) {
42288       _mlyShowSignDetections = value;
42289       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42290         this.resetTags();
42291       }
42292     },
42293     // Apply filter to image viewer
42294     filterViewer: function(context) {
42295       const showsPano = context.photos().showsPanoramic();
42296       const showsFlat = context.photos().showsFlat();
42297       const fromDate = context.photos().fromDate();
42298       const toDate = context.photos().toDate();
42299       const filter2 = ["all"];
42300       if (!showsPano)
42301         filter2.push(["!=", "cameraType", "spherical"]);
42302       if (!showsFlat && showsPano)
42303         filter2.push(["==", "pano", true]);
42304       if (fromDate) {
42305         filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]);
42306       }
42307       if (toDate) {
42308         filter2.push([">=", "capturedAt", new Date(toDate).getTime()]);
42309       }
42310       if (_mlyViewer) {
42311         _mlyViewer.setFilter(filter2);
42312       }
42313       _mlyViewerFilter = filter2;
42314       return filter2;
42315     },
42316     // Make the image viewer visible
42317     showViewer: function(context) {
42318       const wrap2 = context.container().select(".photoviewer").classed("hide", false);
42319       const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size();
42320       if (isHidden && _mlyViewer) {
42321         wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true);
42322         wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false);
42323         _mlyViewer.resize();
42324       }
42325       return this;
42326     },
42327     // Hide the image viewer and resets map markers
42328     hideViewer: function(context) {
42329       _mlyActiveImage = null;
42330       if (!_mlyFallback && _mlyViewer) {
42331         _mlyViewer.getComponent("sequence").stop();
42332       }
42333       const viewer = context.container().select(".photoviewer");
42334       if (!viewer.empty())
42335         viewer.datum(null);
42336       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
42337       this.updateUrlImage(null);
42338       dispatch5.call("imageChanged");
42339       dispatch5.call("loadedMapFeatures");
42340       dispatch5.call("loadedSigns");
42341       return this.setStyles(context, null);
42342     },
42343     // Update the URL with current image id
42344     updateUrlImage: function(imageId) {
42345       if (!window.mocha) {
42346         const hash = utilStringQs(window.location.hash);
42347         if (imageId) {
42348           hash.photo = "mapillary/" + imageId;
42349         } else {
42350           delete hash.photo;
42351         }
42352         window.location.replace("#" + utilQsString(hash, true));
42353       }
42354     },
42355     // Highlight the detection in the viewer that is related to the clicked map feature
42356     highlightDetection: function(detection) {
42357       if (detection) {
42358         _mlyHighlightedDetection = detection.id;
42359       }
42360       return this;
42361     },
42362     // Initialize image viewer (Mapillar JS)
42363     initViewer: function(context) {
42364       const that = this;
42365       if (!window.mapillary)
42366         return;
42367       const opts = {
42368         accessToken,
42369         component: {
42370           cover: false,
42371           keyboard: false,
42372           tag: true
42373         },
42374         container: "ideditor-mly"
42375       };
42376       if (!mapillary.isSupported() && mapillary.isFallbackSupported()) {
42377         _mlyFallback = true;
42378         opts.component = {
42379           cover: false,
42380           direction: false,
42381           imagePlane: false,
42382           keyboard: false,
42383           mouse: false,
42384           sequence: false,
42385           tag: false,
42386           image: true,
42387           // fallback
42388           navigation: true
42389           // fallback
42390         };
42391       }
42392       _mlyViewer = new mapillary.Viewer(opts);
42393       _mlyViewer.on("image", imageChanged);
42394       _mlyViewer.on("bearing", bearingChanged);
42395       if (_mlyViewerFilter) {
42396         _mlyViewer.setFilter(_mlyViewerFilter);
42397       }
42398       context.ui().photoviewer.on("resize.mapillary", function() {
42399         if (_mlyViewer)
42400           _mlyViewer.resize();
42401       });
42402       function imageChanged(node) {
42403         that.resetTags();
42404         const image = node.image;
42405         that.setActiveImage(image);
42406         that.setStyles(context, null);
42407         const loc = [image.originalLngLat.lng, image.originalLngLat.lat];
42408         context.map().centerEase(loc);
42409         that.updateUrlImage(image.id);
42410         if (_mlyShowFeatureDetections || _mlyShowSignDetections) {
42411           that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value"));
42412         }
42413         dispatch5.call("imageChanged");
42414       }
42415       function bearingChanged(e3) {
42416         dispatch5.call("bearingChanged", void 0, e3);
42417       }
42418     },
42419     // Move to an image
42420     selectImage: function(context, imageId) {
42421       if (_mlyViewer && imageId) {
42422         _mlyViewer.moveTo(imageId).catch(function(e3) {
42423           console.error("mly3", e3);
42424         });
42425       }
42426       return this;
42427     },
42428     // Return the currently displayed image
42429     getActiveImage: function() {
42430       return _mlyActiveImage;
42431     },
42432     // Return a list of detection objects for the given id
42433     getDetections: function(id2) {
42434       return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image"));
42435     },
42436     // Set the currently visible image
42437     setActiveImage: function(image) {
42438       if (image) {
42439         _mlyActiveImage = {
42440           ca: image.originalCompassAngle,
42441           id: image.id,
42442           loc: [image.originalLngLat.lng, image.originalLngLat.lat],
42443           is_pano: image.cameraType === "spherical",
42444           sequence_id: image.sequenceId
42445         };
42446       } else {
42447         _mlyActiveImage = null;
42448       }
42449     },
42450     // Update the currently highlighted sequence and selected bubble.
42451     setStyles: function(context, hovered) {
42452       const hoveredImageId = hovered && hovered.id;
42453       const hoveredSequenceId = hovered && hovered.sequence_id;
42454       const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id;
42455       context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) {
42456         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
42457       }).classed("hovered", function(d2) {
42458         return d2.id === hoveredImageId;
42459       });
42460       context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) {
42461         return d2.properties.id === hoveredSequenceId;
42462       }).classed("currentView", function(d2) {
42463         return d2.properties.id === selectedSequenceId;
42464       });
42465       return this;
42466     },
42467     // Get detections for the current image and shows them in the image viewer
42468     updateDetections: function(imageId, url) {
42469       if (!_mlyViewer || _mlyFallback)
42470         return;
42471       if (!imageId)
42472         return;
42473       const cache = _mlyCache.image_detections;
42474       if (cache.forImageId[imageId]) {
42475         showDetections(_mlyCache.image_detections.forImageId[imageId]);
42476       } else {
42477         loadData(url).then((detections) => {
42478           detections.forEach(function(detection) {
42479             if (!cache.forImageId[imageId]) {
42480               cache.forImageId[imageId] = [];
42481             }
42482             cache.forImageId[imageId].push({
42483               geometry: detection.geometry,
42484               id: detection.id,
42485               image_id: imageId,
42486               value: detection.value
42487             });
42488           });
42489           showDetections(_mlyCache.image_detections.forImageId[imageId] || []);
42490         });
42491       }
42492       function showDetections(detections) {
42493         const tagComponent = _mlyViewer.getComponent("tag");
42494         detections.forEach(function(data) {
42495           const tag2 = makeTag(data);
42496           if (tag2) {
42497             tagComponent.add([tag2]);
42498           }
42499         });
42500       }
42501       function makeTag(data) {
42502         const valueParts = data.value.split("--");
42503         if (!valueParts.length)
42504           return;
42505         let tag2;
42506         let text;
42507         let color2 = 16777215;
42508         if (_mlyHighlightedDetection === data.id) {
42509           color2 = 16776960;
42510           text = valueParts[1];
42511           if (text === "flat" || text === "discrete" || text === "sign") {
42512             text = valueParts[2];
42513           }
42514           text = text.replace(/-/g, " ");
42515           text = text.charAt(0).toUpperCase() + text.slice(1);
42516           _mlyHighlightedDetection = null;
42517         }
42518         var decodedGeometry = window.atob(data.geometry);
42519         var uintArray = new Uint8Array(decodedGeometry.length);
42520         for (var i3 = 0; i3 < decodedGeometry.length; i3++) {
42521           uintArray[i3] = decodedGeometry.charCodeAt(i3);
42522         }
42523         const tile = new import_vector_tile.VectorTile(new import_pbf.default(uintArray.buffer));
42524         const layer = tile.layers["mpy-or"];
42525         const geometries = layer.feature(0).loadGeometry();
42526         const polygon2 = geometries.map((ring) => ring.map((point2) => [point2.x / layer.extent, point2.y / layer.extent]));
42527         tag2 = new mapillary.OutlineTag(
42528           data.id,
42529           new mapillary.PolygonGeometry(polygon2[0]),
42530           {
42531             text,
42532             textColor: color2,
42533             lineColor: color2,
42534             lineWidth: 2,
42535             fillColor: color2,
42536             fillOpacity: 0.3
42537           }
42538         );
42539         return tag2;
42540       }
42541     },
42542     // Return the current cache
42543     cache: function() {
42544       return _mlyCache;
42545     }
42546   };
42547
42548   // modules/core/validation/models.js
42549   function validationIssue(attrs) {
42550     this.type = attrs.type;
42551     this.subtype = attrs.subtype;
42552     this.severity = attrs.severity;
42553     this.message = attrs.message;
42554     this.reference = attrs.reference;
42555     this.entityIds = attrs.entityIds;
42556     this.loc = attrs.loc;
42557     this.data = attrs.data;
42558     this.dynamicFixes = attrs.dynamicFixes;
42559     this.hash = attrs.hash;
42560     this.id = generateID.apply(this);
42561     this.key = generateKey.apply(this);
42562     this.autoFix = null;
42563     function generateID() {
42564       var parts = [this.type];
42565       if (this.hash) {
42566         parts.push(this.hash);
42567       }
42568       if (this.subtype) {
42569         parts.push(this.subtype);
42570       }
42571       if (this.entityIds) {
42572         var entityKeys = this.entityIds.slice().sort();
42573         parts.push.apply(parts, entityKeys);
42574       }
42575       return parts.join(":");
42576     }
42577     function generateKey() {
42578       return this.id + ":" + Date.now().toString();
42579     }
42580     this.extent = function(resolver) {
42581       if (this.loc) {
42582         return geoExtent(this.loc);
42583       }
42584       if (this.entityIds && this.entityIds.length) {
42585         return this.entityIds.reduce(function(extent, entityId) {
42586           return extent.extend(resolver.entity(entityId).extent(resolver));
42587         }, geoExtent());
42588       }
42589       return null;
42590     };
42591     this.fixes = function(context) {
42592       var fixes = this.dynamicFixes ? this.dynamicFixes(context) : [];
42593       var issue = this;
42594       if (issue.severity === "warning") {
42595         fixes.push(new validationIssueFix({
42596           title: _t.append("issues.fix.ignore_issue.title"),
42597           icon: "iD-icon-close",
42598           onClick: function() {
42599             context.validator().ignoreIssue(this.issue.id);
42600           }
42601         }));
42602       }
42603       fixes.forEach(function(fix) {
42604         fix.id = fix.title.stringId;
42605         fix.issue = issue;
42606         if (fix.autoArgs) {
42607           issue.autoFix = fix;
42608         }
42609       });
42610       return fixes;
42611     };
42612   }
42613   function validationIssueFix(attrs) {
42614     this.title = attrs.title;
42615     this.onClick = attrs.onClick;
42616     this.disabledReason = attrs.disabledReason;
42617     this.icon = attrs.icon;
42618     this.entityIds = attrs.entityIds || [];
42619     this.autoArgs = attrs.autoArgs;
42620     this.issue = null;
42621   }
42622
42623   // modules/services/maprules.js
42624   var buildRuleChecks = function() {
42625     return {
42626       equals: function(equals) {
42627         return function(tags) {
42628           return Object.keys(equals).every(function(k2) {
42629             return equals[k2] === tags[k2];
42630           });
42631         };
42632       },
42633       notEquals: function(notEquals) {
42634         return function(tags) {
42635           return Object.keys(notEquals).some(function(k2) {
42636             return notEquals[k2] !== tags[k2];
42637           });
42638         };
42639       },
42640       absence: function(absence) {
42641         return function(tags) {
42642           return Object.keys(tags).indexOf(absence) === -1;
42643         };
42644       },
42645       presence: function(presence) {
42646         return function(tags) {
42647           return Object.keys(tags).indexOf(presence) > -1;
42648         };
42649       },
42650       greaterThan: function(greaterThan) {
42651         var key = Object.keys(greaterThan)[0];
42652         var value = greaterThan[key];
42653         return function(tags) {
42654           return tags[key] > value;
42655         };
42656       },
42657       greaterThanEqual: function(greaterThanEqual) {
42658         var key = Object.keys(greaterThanEqual)[0];
42659         var value = greaterThanEqual[key];
42660         return function(tags) {
42661           return tags[key] >= value;
42662         };
42663       },
42664       lessThan: function(lessThan) {
42665         var key = Object.keys(lessThan)[0];
42666         var value = lessThan[key];
42667         return function(tags) {
42668           return tags[key] < value;
42669         };
42670       },
42671       lessThanEqual: function(lessThanEqual) {
42672         var key = Object.keys(lessThanEqual)[0];
42673         var value = lessThanEqual[key];
42674         return function(tags) {
42675           return tags[key] <= value;
42676         };
42677       },
42678       positiveRegex: function(positiveRegex) {
42679         var tagKey = Object.keys(positiveRegex)[0];
42680         var expression = positiveRegex[tagKey].join("|");
42681         var regex = new RegExp(expression);
42682         return function(tags) {
42683           return regex.test(tags[tagKey]);
42684         };
42685       },
42686       negativeRegex: function(negativeRegex) {
42687         var tagKey = Object.keys(negativeRegex)[0];
42688         var expression = negativeRegex[tagKey].join("|");
42689         var regex = new RegExp(expression);
42690         return function(tags) {
42691           return !regex.test(tags[tagKey]);
42692         };
42693       }
42694     };
42695   };
42696   var buildLineKeys = function() {
42697     return {
42698       highway: {
42699         rest_area: true,
42700         services: true
42701       },
42702       railway: {
42703         roundhouse: true,
42704         station: true,
42705         traverser: true,
42706         turntable: true,
42707         wash: true
42708       }
42709     };
42710   };
42711   var maprules_default = {
42712     init: function() {
42713       this._ruleChecks = buildRuleChecks();
42714       this._validationRules = [];
42715       this._areaKeys = osmAreaKeys;
42716       this._lineKeys = buildLineKeys();
42717     },
42718     // list of rules only relevant to tag checks...
42719     filterRuleChecks: function(selector) {
42720       var _ruleChecks = this._ruleChecks;
42721       return Object.keys(selector).reduce(function(rules, key) {
42722         if (["geometry", "error", "warning"].indexOf(key) === -1) {
42723           rules.push(_ruleChecks[key](selector[key]));
42724         }
42725         return rules;
42726       }, []);
42727     },
42728     // builds tagMap from mapcss-parse selector object...
42729     buildTagMap: function(selector) {
42730       var getRegexValues = function(regexes) {
42731         return regexes.map(function(regex) {
42732           return regex.replace(/\$|\^/g, "");
42733         });
42734       };
42735       var tagMap = Object.keys(selector).reduce(function(expectedTags, key) {
42736         var values;
42737         var isRegex = /regex/gi.test(key);
42738         var isEqual4 = /equals/gi.test(key);
42739         if (isRegex || isEqual4) {
42740           Object.keys(selector[key]).forEach(function(selectorKey) {
42741             values = isEqual4 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]);
42742             if (expectedTags.hasOwnProperty(selectorKey)) {
42743               values = values.concat(expectedTags[selectorKey]);
42744             }
42745             expectedTags[selectorKey] = values;
42746           });
42747         } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) {
42748           var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0];
42749           values = [selector[key][tagKey]];
42750           if (expectedTags.hasOwnProperty(tagKey)) {
42751             values = values.concat(expectedTags[tagKey]);
42752           }
42753           expectedTags[tagKey] = values;
42754         }
42755         return expectedTags;
42756       }, {});
42757       return tagMap;
42758     },
42759     // inspired by osmWay#isArea()
42760     inferGeometry: function(tagMap) {
42761       var _lineKeys = this._lineKeys;
42762       var _areaKeys = this._areaKeys;
42763       var keyValueDoesNotImplyArea = function(key2) {
42764         return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0;
42765       };
42766       var keyValueImpliesLine = function(key2) {
42767         return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0;
42768       };
42769       if (tagMap.hasOwnProperty("area")) {
42770         if (tagMap.area.indexOf("yes") > -1) {
42771           return "area";
42772         }
42773         if (tagMap.area.indexOf("no") > -1) {
42774           return "line";
42775         }
42776       }
42777       for (var key in tagMap) {
42778         if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) {
42779           return "area";
42780         }
42781         if (key in _lineKeys && keyValueImpliesLine(key)) {
42782           return "area";
42783         }
42784       }
42785       return "line";
42786     },
42787     // adds from mapcss-parse selector check...
42788     addRule: function(selector) {
42789       var rule = {
42790         // checks relevant to mapcss-selector
42791         checks: this.filterRuleChecks(selector),
42792         // true if all conditions for a tag error are true..
42793         matches: function(entity) {
42794           return this.checks.every(function(check) {
42795             return check(entity.tags);
42796           });
42797         },
42798         // borrowed from Way#isArea()
42799         inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys),
42800         geometryMatches: function(entity, graph) {
42801           if (entity.type === "node" || entity.type === "relation") {
42802             return selector.geometry === entity.type;
42803           } else if (entity.type === "way") {
42804             return this.inferredGeometry === entity.geometry(graph);
42805           }
42806         },
42807         // when geometries match and tag matches are present, return a warning...
42808         findIssues: function(entity, graph, issues) {
42809           if (this.geometryMatches(entity, graph) && this.matches(entity)) {
42810             var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning";
42811             var message = selector[severity];
42812             issues.push(new validationIssue({
42813               type: "maprules",
42814               severity,
42815               message: function() {
42816                 return message;
42817               },
42818               entityIds: [entity.id]
42819             }));
42820           }
42821         }
42822       };
42823       this._validationRules.push(rule);
42824     },
42825     clearRules: function() {
42826       this._validationRules = [];
42827     },
42828     // returns validationRules...
42829     validationRules: function() {
42830       return this._validationRules;
42831     },
42832     // returns ruleChecks
42833     ruleChecks: function() {
42834       return this._ruleChecks;
42835     }
42836   };
42837
42838   // modules/services/nominatim.js
42839   var import_rbush7 = __toESM(require_rbush_min());
42840
42841   // modules/core/difference.js
42842   var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
42843   function coreDifference(base, head) {
42844     var _changes = {};
42845     var _didChange = {};
42846     var _diff = {};
42847     function checkEntityID(id2) {
42848       var h2 = head.entities[id2];
42849       var b2 = base.entities[id2];
42850       if (h2 === b2)
42851         return;
42852       if (_changes[id2])
42853         return;
42854       if (!h2 && b2) {
42855         _changes[id2] = { base: b2, head: h2 };
42856         _didChange.deletion = true;
42857         return;
42858       }
42859       if (h2 && !b2) {
42860         _changes[id2] = { base: b2, head: h2 };
42861         _didChange.addition = true;
42862         return;
42863       }
42864       if (h2 && b2) {
42865         if (h2.members && b2.members && !(0, import_fast_deep_equal3.default)(h2.members, b2.members)) {
42866           _changes[id2] = { base: b2, head: h2 };
42867           _didChange.geometry = true;
42868           _didChange.properties = true;
42869           return;
42870         }
42871         if (h2.loc && b2.loc && !geoVecEqual(h2.loc, b2.loc)) {
42872           _changes[id2] = { base: b2, head: h2 };
42873           _didChange.geometry = true;
42874         }
42875         if (h2.nodes && b2.nodes && !(0, import_fast_deep_equal3.default)(h2.nodes, b2.nodes)) {
42876           _changes[id2] = { base: b2, head: h2 };
42877           _didChange.geometry = true;
42878         }
42879         if (h2.tags && b2.tags && !(0, import_fast_deep_equal3.default)(h2.tags, b2.tags)) {
42880           _changes[id2] = { base: b2, head: h2 };
42881           _didChange.properties = true;
42882         }
42883       }
42884     }
42885     function load() {
42886       var ids = utilArrayUniq(Object.keys(head.entities).concat(Object.keys(base.entities)));
42887       for (var i3 = 0; i3 < ids.length; i3++) {
42888         checkEntityID(ids[i3]);
42889       }
42890     }
42891     load();
42892     _diff.length = function length2() {
42893       return Object.keys(_changes).length;
42894     };
42895     _diff.changes = function changes() {
42896       return _changes;
42897     };
42898     _diff.didChange = _didChange;
42899     _diff.extantIDs = function extantIDs(includeRelMembers) {
42900       var result = /* @__PURE__ */ new Set();
42901       Object.keys(_changes).forEach(function(id2) {
42902         if (_changes[id2].head) {
42903           result.add(id2);
42904         }
42905         var h2 = _changes[id2].head;
42906         var b2 = _changes[id2].base;
42907         var entity = h2 || b2;
42908         if (includeRelMembers && entity.type === "relation") {
42909           var mh = h2 ? h2.members.map(function(m2) {
42910             return m2.id;
42911           }) : [];
42912           var mb = b2 ? b2.members.map(function(m2) {
42913             return m2.id;
42914           }) : [];
42915           utilArrayUnion(mh, mb).forEach(function(memberID) {
42916             if (head.hasEntity(memberID)) {
42917               result.add(memberID);
42918             }
42919           });
42920         }
42921       });
42922       return Array.from(result);
42923     };
42924     _diff.modified = function modified() {
42925       var result = [];
42926       Object.values(_changes).forEach(function(change) {
42927         if (change.base && change.head) {
42928           result.push(change.head);
42929         }
42930       });
42931       return result;
42932     };
42933     _diff.created = function created() {
42934       var result = [];
42935       Object.values(_changes).forEach(function(change) {
42936         if (!change.base && change.head) {
42937           result.push(change.head);
42938         }
42939       });
42940       return result;
42941     };
42942     _diff.deleted = function deleted() {
42943       var result = [];
42944       Object.values(_changes).forEach(function(change) {
42945         if (change.base && !change.head) {
42946           result.push(change.base);
42947         }
42948       });
42949       return result;
42950     };
42951     _diff.summary = function summary() {
42952       var relevant = {};
42953       var keys2 = Object.keys(_changes);
42954       for (var i3 = 0; i3 < keys2.length; i3++) {
42955         var change = _changes[keys2[i3]];
42956         if (change.head && change.head.geometry(head) !== "vertex") {
42957           addEntity(change.head, head, change.base ? "modified" : "created");
42958         } else if (change.base && change.base.geometry(base) !== "vertex") {
42959           addEntity(change.base, base, "deleted");
42960         } else if (change.base && change.head) {
42961           var moved = !(0, import_fast_deep_equal3.default)(change.base.loc, change.head.loc);
42962           var retagged = !(0, import_fast_deep_equal3.default)(change.base.tags, change.head.tags);
42963           if (moved) {
42964             addParents(change.head);
42965           }
42966           if (retagged || moved && change.head.hasInterestingTags()) {
42967             addEntity(change.head, head, "modified");
42968           }
42969         } else if (change.head && change.head.hasInterestingTags()) {
42970           addEntity(change.head, head, "created");
42971         } else if (change.base && change.base.hasInterestingTags()) {
42972           addEntity(change.base, base, "deleted");
42973         }
42974       }
42975       return Object.values(relevant);
42976       function addEntity(entity, graph, changeType) {
42977         relevant[entity.id] = {
42978           entity,
42979           graph,
42980           changeType
42981         };
42982       }
42983       function addParents(entity) {
42984         var parents = head.parentWays(entity);
42985         for (var j2 = parents.length - 1; j2 >= 0; j2--) {
42986           var parent = parents[j2];
42987           if (!(parent.id in relevant)) {
42988             addEntity(parent, head, "modified");
42989           }
42990         }
42991       }
42992     };
42993     _diff.complete = function complete(extent) {
42994       var result = {};
42995       var id2, change;
42996       for (id2 in _changes) {
42997         change = _changes[id2];
42998         var h2 = change.head;
42999         var b2 = change.base;
43000         var entity = h2 || b2;
43001         var i3;
43002         if (extent && (!h2 || !h2.intersects(extent, head)) && (!b2 || !b2.intersects(extent, base))) {
43003           continue;
43004         }
43005         result[id2] = h2;
43006         if (entity.type === "way") {
43007           var nh = h2 ? h2.nodes : [];
43008           var nb = b2 ? b2.nodes : [];
43009           var diff;
43010           diff = utilArrayDifference(nh, nb);
43011           for (i3 = 0; i3 < diff.length; i3++) {
43012             result[diff[i3]] = head.hasEntity(diff[i3]);
43013           }
43014           diff = utilArrayDifference(nb, nh);
43015           for (i3 = 0; i3 < diff.length; i3++) {
43016             result[diff[i3]] = head.hasEntity(diff[i3]);
43017           }
43018         }
43019         if (entity.type === "relation" && entity.isMultipolygon()) {
43020           var mh = h2 ? h2.members.map(function(m2) {
43021             return m2.id;
43022           }) : [];
43023           var mb = b2 ? b2.members.map(function(m2) {
43024             return m2.id;
43025           }) : [];
43026           var ids = utilArrayUnion(mh, mb);
43027           for (i3 = 0; i3 < ids.length; i3++) {
43028             var member = head.hasEntity(ids[i3]);
43029             if (!member)
43030               continue;
43031             if (extent && !member.intersects(extent, head))
43032               continue;
43033             result[ids[i3]] = member;
43034           }
43035         }
43036         addParents(head.parentWays(entity), result);
43037         addParents(head.parentRelations(entity), result);
43038       }
43039       return result;
43040       function addParents(parents, result2) {
43041         for (var i4 = 0; i4 < parents.length; i4++) {
43042           var parent = parents[i4];
43043           if (parent.id in result2)
43044             continue;
43045           result2[parent.id] = parent;
43046           addParents(head.parentRelations(parent), result2);
43047         }
43048       }
43049     };
43050     return _diff;
43051   }
43052
43053   // modules/core/tree.js
43054   var import_rbush5 = __toESM(require_rbush_min());
43055   function coreTree(head) {
43056     var _rtree = new import_rbush5.default();
43057     var _bboxes = {};
43058     var _segmentsRTree = new import_rbush5.default();
43059     var _segmentsBBoxes = {};
43060     var _segmentsByWayId = {};
43061     var tree = {};
43062     function entityBBox(entity) {
43063       var bbox2 = entity.extent(head).bbox();
43064       bbox2.id = entity.id;
43065       _bboxes[entity.id] = bbox2;
43066       return bbox2;
43067     }
43068     function segmentBBox(segment) {
43069       var extent = segment.extent(head);
43070       if (!extent)
43071         return null;
43072       var bbox2 = extent.bbox();
43073       bbox2.segment = segment;
43074       _segmentsBBoxes[segment.id] = bbox2;
43075       return bbox2;
43076     }
43077     function removeEntity(entity) {
43078       _rtree.remove(_bboxes[entity.id]);
43079       delete _bboxes[entity.id];
43080       if (_segmentsByWayId[entity.id]) {
43081         _segmentsByWayId[entity.id].forEach(function(segment) {
43082           _segmentsRTree.remove(_segmentsBBoxes[segment.id]);
43083           delete _segmentsBBoxes[segment.id];
43084         });
43085         delete _segmentsByWayId[entity.id];
43086       }
43087     }
43088     function loadEntities(entities) {
43089       _rtree.load(entities.map(entityBBox));
43090       var segments = [];
43091       entities.forEach(function(entity) {
43092         if (entity.segments) {
43093           var entitySegments = entity.segments(head);
43094           _segmentsByWayId[entity.id] = entitySegments;
43095           segments = segments.concat(entitySegments);
43096         }
43097       });
43098       if (segments.length)
43099         _segmentsRTree.load(segments.map(segmentBBox).filter(Boolean));
43100     }
43101     function updateParents(entity, insertions, memo) {
43102       head.parentWays(entity).forEach(function(way) {
43103         if (_bboxes[way.id]) {
43104           removeEntity(way);
43105           insertions[way.id] = way;
43106         }
43107         updateParents(way, insertions, memo);
43108       });
43109       head.parentRelations(entity).forEach(function(relation) {
43110         if (memo[entity.id])
43111           return;
43112         memo[entity.id] = true;
43113         if (_bboxes[relation.id]) {
43114           removeEntity(relation);
43115           insertions[relation.id] = relation;
43116         }
43117         updateParents(relation, insertions, memo);
43118       });
43119     }
43120     tree.rebase = function(entities, force) {
43121       var insertions = {};
43122       for (var i3 = 0; i3 < entities.length; i3++) {
43123         var entity = entities[i3];
43124         if (!entity.visible)
43125           continue;
43126         if (head.entities.hasOwnProperty(entity.id) || _bboxes[entity.id]) {
43127           if (!force) {
43128             continue;
43129           } else if (_bboxes[entity.id]) {
43130             removeEntity(entity);
43131           }
43132         }
43133         insertions[entity.id] = entity;
43134         updateParents(entity, insertions, {});
43135       }
43136       loadEntities(Object.values(insertions));
43137       return tree;
43138     };
43139     function updateToGraph(graph) {
43140       if (graph === head)
43141         return;
43142       var diff = coreDifference(head, graph);
43143       head = graph;
43144       var changed = diff.didChange;
43145       if (!changed.addition && !changed.deletion && !changed.geometry)
43146         return;
43147       var insertions = {};
43148       if (changed.deletion) {
43149         diff.deleted().forEach(function(entity) {
43150           removeEntity(entity);
43151         });
43152       }
43153       if (changed.geometry) {
43154         diff.modified().forEach(function(entity) {
43155           removeEntity(entity);
43156           insertions[entity.id] = entity;
43157           updateParents(entity, insertions, {});
43158         });
43159       }
43160       if (changed.addition) {
43161         diff.created().forEach(function(entity) {
43162           insertions[entity.id] = entity;
43163         });
43164       }
43165       loadEntities(Object.values(insertions));
43166     }
43167     tree.intersects = function(extent, graph) {
43168       updateToGraph(graph);
43169       return _rtree.search(extent.bbox()).map(function(bbox2) {
43170         return graph.entity(bbox2.id);
43171       });
43172     };
43173     tree.waySegments = function(extent, graph) {
43174       updateToGraph(graph);
43175       return _segmentsRTree.search(extent.bbox()).map(function(bbox2) {
43176         return bbox2.segment;
43177       });
43178     };
43179     return tree;
43180   }
43181
43182   // modules/svg/icon.js
43183   function svgIcon(name, svgklass, useklass) {
43184     return function drawIcon(selection2) {
43185       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);
43186     };
43187   }
43188
43189   // modules/ui/modal.js
43190   function uiModal(selection2, blocking) {
43191     let keybinding = utilKeybinding("modal");
43192     let previous = selection2.select("div.modal");
43193     let animate = previous.empty();
43194     previous.transition().duration(200).style("opacity", 0).remove();
43195     let shaded = selection2.append("div").attr("class", "shaded").style("opacity", 0);
43196     shaded.close = () => {
43197       shaded.transition().duration(200).style("opacity", 0).remove();
43198       modal.transition().duration(200).style("top", "0px");
43199       select_default2(document).call(keybinding.unbind);
43200     };
43201     let modal = shaded.append("div").attr("class", "modal fillL");
43202     modal.append("input").attr("class", "keytrap keytrap-first").on("focus.keytrap", moveFocusToLast);
43203     if (!blocking) {
43204       shaded.on("click.remove-modal", (d3_event) => {
43205         if (d3_event.target === this) {
43206           shaded.close();
43207         }
43208       });
43209       modal.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", shaded.close).call(svgIcon("#iD-icon-close"));
43210       keybinding.on("\u232B", shaded.close).on("\u238B", shaded.close);
43211       select_default2(document).call(keybinding);
43212     }
43213     modal.append("div").attr("class", "content");
43214     modal.append("input").attr("class", "keytrap keytrap-last").on("focus.keytrap", moveFocusToFirst);
43215     if (animate) {
43216       shaded.transition().style("opacity", 1);
43217     } else {
43218       shaded.style("opacity", 1);
43219     }
43220     return shaded;
43221     function moveFocusToFirst() {
43222       let node = modal.select("a, button, input:not(.keytrap), select, textarea").node();
43223       if (node) {
43224         node.focus();
43225       } else {
43226         select_default2(this).node().blur();
43227       }
43228     }
43229     function moveFocusToLast() {
43230       let nodes = modal.selectAll("a, button, input:not(.keytrap), select, textarea").nodes();
43231       if (nodes.length) {
43232         nodes[nodes.length - 1].focus();
43233       } else {
43234         select_default2(this).node().blur();
43235       }
43236     }
43237   }
43238
43239   // modules/ui/loading.js
43240   function uiLoading(context) {
43241     let _modalSelection = select_default2(null);
43242     let _message = "";
43243     let _blocking = false;
43244     let loading = (selection2) => {
43245       _modalSelection = uiModal(selection2, _blocking);
43246       let loadertext = _modalSelection.select(".content").classed("loading-modal", true).append("div").attr("class", "modal-section fillL");
43247       loadertext.append("img").attr("class", "loader").attr("src", context.imagePath("loader-white.gif"));
43248       loadertext.append("h3").html(_message);
43249       _modalSelection.select("button.close").attr("class", "hide");
43250       return loading;
43251     };
43252     loading.message = function(val) {
43253       if (!arguments.length)
43254         return _message;
43255       _message = val;
43256       return loading;
43257     };
43258     loading.blocking = function(val) {
43259       if (!arguments.length)
43260         return _blocking;
43261       _blocking = val;
43262       return loading;
43263     };
43264     loading.close = () => {
43265       _modalSelection.remove();
43266     };
43267     loading.isShown = () => {
43268       return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode;
43269     };
43270     return loading;
43271   }
43272
43273   // modules/core/history.js
43274   function coreHistory(context) {
43275     var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error");
43276     var lock = utilSessionMutex("lock");
43277     var _hasUnresolvedRestorableChanges = lock.lock() && !!corePreferences(getKey("saved_history"));
43278     var duration = 150;
43279     var _imageryUsed = [];
43280     var _photoOverlaysUsed = [];
43281     var _checkpoints = {};
43282     var _pausedGraph;
43283     var _stack;
43284     var _index;
43285     var _tree;
43286     function _act(actions, t2) {
43287       actions = Array.prototype.slice.call(actions);
43288       var annotation;
43289       if (typeof actions[actions.length - 1] !== "function") {
43290         annotation = actions.pop();
43291       }
43292       var graph = _stack[_index].graph;
43293       for (var i3 = 0; i3 < actions.length; i3++) {
43294         graph = actions[i3](graph, t2);
43295       }
43296       return {
43297         graph,
43298         annotation,
43299         imageryUsed: _imageryUsed,
43300         photoOverlaysUsed: _photoOverlaysUsed,
43301         transform: context.projection.transform(),
43302         selectedIDs: context.selectedIDs()
43303       };
43304     }
43305     function _perform(args, t2) {
43306       var previous = _stack[_index].graph;
43307       _stack = _stack.slice(0, _index + 1);
43308       var actionResult = _act(args, t2);
43309       _stack.push(actionResult);
43310       _index++;
43311       return change(previous);
43312     }
43313     function _replace(args, t2) {
43314       var previous = _stack[_index].graph;
43315       var actionResult = _act(args, t2);
43316       _stack[_index] = actionResult;
43317       return change(previous);
43318     }
43319     function _overwrite(args, t2) {
43320       var previous = _stack[_index].graph;
43321       if (_index > 0) {
43322         _index--;
43323         _stack.pop();
43324       }
43325       _stack = _stack.slice(0, _index + 1);
43326       var actionResult = _act(args, t2);
43327       _stack.push(actionResult);
43328       _index++;
43329       return change(previous);
43330     }
43331     function change(previous) {
43332       var difference2 = coreDifference(previous, history.graph());
43333       if (!_pausedGraph) {
43334         dispatch14.call("change", this, difference2);
43335       }
43336       return difference2;
43337     }
43338     function getKey(n3) {
43339       return "iD_" + window.location.origin + "_" + n3;
43340     }
43341     var history = {
43342       graph: function() {
43343         return _stack[_index].graph;
43344       },
43345       tree: function() {
43346         return _tree;
43347       },
43348       base: function() {
43349         return _stack[0].graph;
43350       },
43351       merge: function(entities) {
43352         var stack = _stack.map(function(state) {
43353           return state.graph;
43354         });
43355         _stack[0].graph.rebase(entities, stack, false);
43356         _tree.rebase(entities, false);
43357         dispatch14.call("merge", this, entities);
43358       },
43359       perform: function() {
43360         select_default2(document).interrupt("history.perform");
43361         var transitionable = false;
43362         var action0 = arguments[0];
43363         if (arguments.length === 1 || arguments.length === 2 && typeof arguments[1] !== "function") {
43364           transitionable = !!action0.transitionable;
43365         }
43366         if (transitionable) {
43367           var origArguments = arguments;
43368           select_default2(document).transition("history.perform").duration(duration).ease(linear2).tween("history.tween", function() {
43369             return function(t2) {
43370               if (t2 < 1)
43371                 _overwrite([action0], t2);
43372             };
43373           }).on("start", function() {
43374             _perform([action0], 0);
43375           }).on("end interrupt", function() {
43376             _overwrite(origArguments, 1);
43377           });
43378         } else {
43379           return _perform(arguments);
43380         }
43381       },
43382       replace: function() {
43383         select_default2(document).interrupt("history.perform");
43384         return _replace(arguments, 1);
43385       },
43386       // Same as calling pop and then perform
43387       overwrite: function() {
43388         select_default2(document).interrupt("history.perform");
43389         return _overwrite(arguments, 1);
43390       },
43391       pop: function(n3) {
43392         select_default2(document).interrupt("history.perform");
43393         var previous = _stack[_index].graph;
43394         if (isNaN(+n3) || +n3 < 0) {
43395           n3 = 1;
43396         }
43397         while (n3-- > 0 && _index > 0) {
43398           _index--;
43399           _stack.pop();
43400         }
43401         return change(previous);
43402       },
43403       // Back to the previous annotated state or _index = 0.
43404       undo: function() {
43405         select_default2(document).interrupt("history.perform");
43406         var previousStack = _stack[_index];
43407         var previous = previousStack.graph;
43408         while (_index > 0) {
43409           _index--;
43410           if (_stack[_index].annotation)
43411             break;
43412         }
43413         dispatch14.call("undone", this, _stack[_index], previousStack);
43414         return change(previous);
43415       },
43416       // Forward to the next annotated state.
43417       redo: function() {
43418         select_default2(document).interrupt("history.perform");
43419         var previousStack = _stack[_index];
43420         var previous = previousStack.graph;
43421         var tryIndex = _index;
43422         while (tryIndex < _stack.length - 1) {
43423           tryIndex++;
43424           if (_stack[tryIndex].annotation) {
43425             _index = tryIndex;
43426             dispatch14.call("redone", this, _stack[_index], previousStack);
43427             break;
43428           }
43429         }
43430         return change(previous);
43431       },
43432       pauseChangeDispatch: function() {
43433         if (!_pausedGraph) {
43434           _pausedGraph = _stack[_index].graph;
43435         }
43436       },
43437       resumeChangeDispatch: function() {
43438         if (_pausedGraph) {
43439           var previous = _pausedGraph;
43440           _pausedGraph = null;
43441           return change(previous);
43442         }
43443       },
43444       undoAnnotation: function() {
43445         var i3 = _index;
43446         while (i3 >= 0) {
43447           if (_stack[i3].annotation)
43448             return _stack[i3].annotation;
43449           i3--;
43450         }
43451       },
43452       redoAnnotation: function() {
43453         var i3 = _index + 1;
43454         while (i3 <= _stack.length - 1) {
43455           if (_stack[i3].annotation)
43456             return _stack[i3].annotation;
43457           i3++;
43458         }
43459       },
43460       // Returns the entities from the active graph with bounding boxes
43461       // overlapping the given `extent`.
43462       intersects: function(extent) {
43463         return _tree.intersects(extent, _stack[_index].graph);
43464       },
43465       difference: function() {
43466         var base = _stack[0].graph;
43467         var head = _stack[_index].graph;
43468         return coreDifference(base, head);
43469       },
43470       changes: function(action) {
43471         var base = _stack[0].graph;
43472         var head = _stack[_index].graph;
43473         if (action) {
43474           head = action(head);
43475         }
43476         var difference2 = coreDifference(base, head);
43477         return {
43478           modified: difference2.modified(),
43479           created: difference2.created(),
43480           deleted: difference2.deleted()
43481         };
43482       },
43483       hasChanges: function() {
43484         return this.difference().length() > 0;
43485       },
43486       imageryUsed: function(sources) {
43487         if (sources) {
43488           _imageryUsed = sources;
43489           return history;
43490         } else {
43491           var s2 = /* @__PURE__ */ new Set();
43492           _stack.slice(1, _index + 1).forEach(function(state) {
43493             state.imageryUsed.forEach(function(source) {
43494               if (source !== "Custom") {
43495                 s2.add(source);
43496               }
43497             });
43498           });
43499           return Array.from(s2);
43500         }
43501       },
43502       photoOverlaysUsed: function(sources) {
43503         if (sources) {
43504           _photoOverlaysUsed = sources;
43505           return history;
43506         } else {
43507           var s2 = /* @__PURE__ */ new Set();
43508           _stack.slice(1, _index + 1).forEach(function(state) {
43509             if (state.photoOverlaysUsed && Array.isArray(state.photoOverlaysUsed)) {
43510               state.photoOverlaysUsed.forEach(function(photoOverlay) {
43511                 s2.add(photoOverlay);
43512               });
43513             }
43514           });
43515           return Array.from(s2);
43516         }
43517       },
43518       // save the current history state
43519       checkpoint: function(key) {
43520         _checkpoints[key] = {
43521           stack: _stack,
43522           index: _index
43523         };
43524         return history;
43525       },
43526       // restore history state to a given checkpoint or reset completely
43527       reset: function(key) {
43528         if (key !== void 0 && _checkpoints.hasOwnProperty(key)) {
43529           _stack = _checkpoints[key].stack;
43530           _index = _checkpoints[key].index;
43531         } else {
43532           _stack = [{ graph: coreGraph() }];
43533           _index = 0;
43534           _tree = coreTree(_stack[0].graph);
43535           _checkpoints = {};
43536         }
43537         dispatch14.call("reset");
43538         dispatch14.call("change");
43539         return history;
43540       },
43541       // `toIntroGraph()` is used to export the intro graph used by the walkthrough.
43542       //
43543       // To use it:
43544       //  1. Start the walkthrough.
43545       //  2. Get to a "free editing" tutorial step
43546       //  3. Make your edits to the walkthrough map
43547       //  4. In your browser dev console run:
43548       //        `id.history().toIntroGraph()`
43549       //  5. This outputs stringified JSON to the browser console
43550       //  6. Copy it to `data/intro_graph.json` and prettify it in your code editor
43551       toIntroGraph: function() {
43552         var nextID = { n: 0, r: 0, w: 0 };
43553         var permIDs = {};
43554         var graph = this.graph();
43555         var baseEntities = {};
43556         Object.values(graph.base().entities).forEach(function(entity) {
43557           var copy2 = copyIntroEntity(entity);
43558           baseEntities[copy2.id] = copy2;
43559         });
43560         Object.keys(graph.entities).forEach(function(id2) {
43561           var entity = graph.entities[id2];
43562           if (entity) {
43563             var copy2 = copyIntroEntity(entity);
43564             baseEntities[copy2.id] = copy2;
43565           } else {
43566             delete baseEntities[id2];
43567           }
43568         });
43569         Object.values(baseEntities).forEach(function(entity) {
43570           if (Array.isArray(entity.nodes)) {
43571             entity.nodes = entity.nodes.map(function(node) {
43572               return permIDs[node] || node;
43573             });
43574           }
43575           if (Array.isArray(entity.members)) {
43576             entity.members = entity.members.map(function(member) {
43577               member.id = permIDs[member.id] || member.id;
43578               return member;
43579             });
43580           }
43581         });
43582         return JSON.stringify({ dataIntroGraph: baseEntities });
43583         function copyIntroEntity(source) {
43584           var copy2 = utilObjectOmit(source, ["type", "user", "v", "version", "visible"]);
43585           if (copy2.tags && !Object.keys(copy2.tags)) {
43586             delete copy2.tags;
43587           }
43588           if (Array.isArray(copy2.loc)) {
43589             copy2.loc[0] = +copy2.loc[0].toFixed(6);
43590             copy2.loc[1] = +copy2.loc[1].toFixed(6);
43591           }
43592           var match = source.id.match(/([nrw])-\d*/);
43593           if (match !== null) {
43594             var nrw = match[1];
43595             var permID;
43596             do {
43597               permID = nrw + ++nextID[nrw];
43598             } while (baseEntities.hasOwnProperty(permID));
43599             copy2.id = permIDs[source.id] = permID;
43600           }
43601           return copy2;
43602         }
43603       },
43604       toJSON: function() {
43605         if (!this.hasChanges())
43606           return;
43607         var allEntities = {};
43608         var baseEntities = {};
43609         var base = _stack[0];
43610         var s2 = _stack.map(function(i3) {
43611           var modified = [];
43612           var deleted = [];
43613           Object.keys(i3.graph.entities).forEach(function(id2) {
43614             var entity = i3.graph.entities[id2];
43615             if (entity) {
43616               var key = osmEntity.key(entity);
43617               allEntities[key] = entity;
43618               modified.push(key);
43619             } else {
43620               deleted.push(id2);
43621             }
43622             if (id2 in base.graph.entities) {
43623               baseEntities[id2] = base.graph.entities[id2];
43624             }
43625             if (entity && entity.nodes) {
43626               entity.nodes.forEach(function(nodeID) {
43627                 if (nodeID in base.graph.entities) {
43628                   baseEntities[nodeID] = base.graph.entities[nodeID];
43629                 }
43630               });
43631             }
43632             var baseParents = base.graph._parentWays[id2];
43633             if (baseParents) {
43634               baseParents.forEach(function(parentID) {
43635                 if (parentID in base.graph.entities) {
43636                   baseEntities[parentID] = base.graph.entities[parentID];
43637                 }
43638               });
43639             }
43640           });
43641           var x2 = {};
43642           if (modified.length)
43643             x2.modified = modified;
43644           if (deleted.length)
43645             x2.deleted = deleted;
43646           if (i3.imageryUsed)
43647             x2.imageryUsed = i3.imageryUsed;
43648           if (i3.photoOverlaysUsed)
43649             x2.photoOverlaysUsed = i3.photoOverlaysUsed;
43650           if (i3.annotation)
43651             x2.annotation = i3.annotation;
43652           if (i3.transform)
43653             x2.transform = i3.transform;
43654           if (i3.selectedIDs)
43655             x2.selectedIDs = i3.selectedIDs;
43656           return x2;
43657         });
43658         return JSON.stringify({
43659           version: 3,
43660           entities: Object.values(allEntities),
43661           baseEntities: Object.values(baseEntities),
43662           stack: s2,
43663           nextIDs: osmEntity.id.next,
43664           index: _index,
43665           // note the time the changes were saved
43666           timestamp: (/* @__PURE__ */ new Date()).getTime()
43667         });
43668       },
43669       fromJSON: function(json, loadChildNodes) {
43670         var h2 = JSON.parse(json);
43671         var loadComplete = true;
43672         osmEntity.id.next = h2.nextIDs;
43673         _index = h2.index;
43674         if (h2.version === 2 || h2.version === 3) {
43675           var allEntities = {};
43676           h2.entities.forEach(function(entity) {
43677             allEntities[osmEntity.key(entity)] = osmEntity(entity);
43678           });
43679           if (h2.version === 3) {
43680             var baseEntities = h2.baseEntities.map(function(d2) {
43681               return osmEntity(d2);
43682             });
43683             var stack = _stack.map(function(state) {
43684               return state.graph;
43685             });
43686             _stack[0].graph.rebase(baseEntities, stack, true);
43687             _tree.rebase(baseEntities, true);
43688             if (loadChildNodes) {
43689               var osm = context.connection();
43690               var baseWays = baseEntities.filter(function(e3) {
43691                 return e3.type === "way";
43692               });
43693               var nodeIDs = baseWays.reduce(function(acc, way) {
43694                 return utilArrayUnion(acc, way.nodes);
43695               }, []);
43696               var missing = nodeIDs.filter(function(n3) {
43697                 return !_stack[0].graph.hasEntity(n3);
43698               });
43699               if (missing.length && osm) {
43700                 loadComplete = false;
43701                 context.map().redrawEnable(false);
43702                 var loading = uiLoading(context).blocking(true);
43703                 context.container().call(loading);
43704                 var childNodesLoaded = function(err, result) {
43705                   if (!err) {
43706                     var visibleGroups = utilArrayGroupBy(result.data, "visible");
43707                     var visibles = visibleGroups.true || [];
43708                     var invisibles = visibleGroups.false || [];
43709                     if (visibles.length) {
43710                       var visibleIDs = visibles.map(function(entity) {
43711                         return entity.id;
43712                       });
43713                       var stack2 = _stack.map(function(state) {
43714                         return state.graph;
43715                       });
43716                       missing = utilArrayDifference(missing, visibleIDs);
43717                       _stack[0].graph.rebase(visibles, stack2, true);
43718                       _tree.rebase(visibles, true);
43719                     }
43720                     invisibles.forEach(function(entity) {
43721                       osm.loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded);
43722                     });
43723                   }
43724                   if (err || !missing.length) {
43725                     loading.close();
43726                     context.map().redrawEnable(true);
43727                     dispatch14.call("change");
43728                     dispatch14.call("restore", this);
43729                   }
43730                 };
43731                 osm.loadMultiple(missing, childNodesLoaded);
43732               }
43733             }
43734           }
43735           _stack = h2.stack.map(function(d2) {
43736             var entities = {}, entity;
43737             if (d2.modified) {
43738               d2.modified.forEach(function(key) {
43739                 entity = allEntities[key];
43740                 entities[entity.id] = entity;
43741               });
43742             }
43743             if (d2.deleted) {
43744               d2.deleted.forEach(function(id2) {
43745                 entities[id2] = void 0;
43746               });
43747             }
43748             return {
43749               graph: coreGraph(_stack[0].graph).load(entities),
43750               annotation: d2.annotation,
43751               imageryUsed: d2.imageryUsed,
43752               photoOverlaysUsed: d2.photoOverlaysUsed,
43753               transform: d2.transform,
43754               selectedIDs: d2.selectedIDs
43755             };
43756           });
43757         } else {
43758           _stack = h2.stack.map(function(d2) {
43759             var entities = {};
43760             for (var i3 in d2.entities) {
43761               var entity = d2.entities[i3];
43762               entities[i3] = entity === "undefined" ? void 0 : osmEntity(entity);
43763             }
43764             d2.graph = coreGraph(_stack[0].graph).load(entities);
43765             return d2;
43766           });
43767         }
43768         var transform2 = _stack[_index].transform;
43769         if (transform2) {
43770           context.map().transformEase(transform2, 0);
43771         }
43772         if (loadComplete) {
43773           dispatch14.call("change");
43774           dispatch14.call("restore", this);
43775         }
43776         return history;
43777       },
43778       lock: function() {
43779         return lock.lock();
43780       },
43781       unlock: function() {
43782         lock.unlock();
43783       },
43784       save: function() {
43785         if (lock.locked() && // don't overwrite existing, unresolved changes
43786         !_hasUnresolvedRestorableChanges) {
43787           const success = corePreferences(getKey("saved_history"), history.toJSON() || null);
43788           if (!success)
43789             dispatch14.call("storage_error");
43790         }
43791         return history;
43792       },
43793       // delete the history version saved in localStorage
43794       clearSaved: function() {
43795         context.debouncedSave.cancel();
43796         if (lock.locked()) {
43797           _hasUnresolvedRestorableChanges = false;
43798           corePreferences(getKey("saved_history"), null);
43799           corePreferences("comment", null);
43800           corePreferences("hashtags", null);
43801           corePreferences("source", null);
43802         }
43803         return history;
43804       },
43805       savedHistoryJSON: function() {
43806         return corePreferences(getKey("saved_history"));
43807       },
43808       hasRestorableChanges: function() {
43809         return _hasUnresolvedRestorableChanges;
43810       },
43811       // load history from a version stored in localStorage
43812       restore: function() {
43813         if (lock.locked()) {
43814           _hasUnresolvedRestorableChanges = false;
43815           var json = this.savedHistoryJSON();
43816           if (json)
43817             history.fromJSON(json, true);
43818         }
43819       },
43820       _getKey: getKey
43821     };
43822     history.reset();
43823     return utilRebind(history, dispatch14, "on");
43824   }
43825
43826   // modules/validations/index.js
43827   var validations_exports = {};
43828   __export(validations_exports, {
43829     validationAlmostJunction: () => validationAlmostJunction,
43830     validationCloseNodes: () => validationCloseNodes,
43831     validationCrossingWays: () => validationCrossingWays,
43832     validationDisconnectedWay: () => validationDisconnectedWay,
43833     validationFormatting: () => validationFormatting,
43834     validationHelpRequest: () => validationHelpRequest,
43835     validationImpossibleOneway: () => validationImpossibleOneway,
43836     validationIncompatibleSource: () => validationIncompatibleSource,
43837     validationMaprules: () => validationMaprules,
43838     validationMismatchedGeometry: () => validationMismatchedGeometry,
43839     validationMissingRole: () => validationMissingRole,
43840     validationMissingTag: () => validationMissingTag,
43841     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
43842     validationOutdatedTags: () => validationOutdatedTags,
43843     validationPrivateData: () => validationPrivateData,
43844     validationSuspiciousName: () => validationSuspiciousName,
43845     validationUnsquareWay: () => validationUnsquareWay
43846   });
43847
43848   // modules/validations/almost_junction.js
43849   function validationAlmostJunction(context) {
43850     const type2 = "almost_junction";
43851     const EXTEND_TH_METERS = 5;
43852     const WELD_TH_METERS = 0.75;
43853     const CLOSE_NODE_TH = EXTEND_TH_METERS - WELD_TH_METERS;
43854     const SIG_ANGLE_TH = Math.atan(WELD_TH_METERS / EXTEND_TH_METERS);
43855     function isHighway(entity) {
43856       return entity.type === "way" && osmRoutableHighwayTagValues[entity.tags.highway];
43857     }
43858     function isTaggedAsNotContinuing(node) {
43859       return node.tags.noexit === "yes" || node.tags.amenity === "parking_entrance" || node.tags.entrance && node.tags.entrance !== "no";
43860     }
43861     const validation = function checkAlmostJunction(entity, graph) {
43862       if (!isHighway(entity))
43863         return [];
43864       if (entity.isDegenerate())
43865         return [];
43866       const tree = context.history().tree();
43867       const extendableNodeInfos = findConnectableEndNodesByExtension(entity);
43868       let issues = [];
43869       extendableNodeInfos.forEach((extendableNodeInfo) => {
43870         issues.push(new validationIssue({
43871           type: type2,
43872           subtype: "highway-highway",
43873           severity: "warning",
43874           message: function(context2) {
43875             const entity1 = context2.hasEntity(this.entityIds[0]);
43876             if (this.entityIds[0] === this.entityIds[2]) {
43877               return entity1 ? _t.append("issues.almost_junction.self.message", {
43878                 feature: utilDisplayLabel(entity1, context2.graph())
43879               }) : "";
43880             } else {
43881               const entity2 = context2.hasEntity(this.entityIds[2]);
43882               return entity1 && entity2 ? _t.append("issues.almost_junction.message", {
43883                 feature: utilDisplayLabel(entity1, context2.graph()),
43884                 feature2: utilDisplayLabel(entity2, context2.graph())
43885               }) : "";
43886             }
43887           },
43888           reference: showReference,
43889           entityIds: [
43890             entity.id,
43891             extendableNodeInfo.node.id,
43892             extendableNodeInfo.wid
43893           ],
43894           loc: extendableNodeInfo.node.loc,
43895           hash: JSON.stringify(extendableNodeInfo.node.loc),
43896           data: {
43897             midId: extendableNodeInfo.mid.id,
43898             edge: extendableNodeInfo.edge,
43899             cross_loc: extendableNodeInfo.cross_loc
43900           },
43901           dynamicFixes: makeFixes
43902         }));
43903       });
43904       return issues;
43905       function makeFixes(context2) {
43906         let fixes = [new validationIssueFix({
43907           icon: "iD-icon-abutment",
43908           title: _t.append("issues.fix.connect_features.title"),
43909           onClick: function(context3) {
43910             const annotation = _t("issues.fix.connect_almost_junction.annotation");
43911             const [, endNodeId, crossWayId] = this.issue.entityIds;
43912             const midNode = context3.entity(this.issue.data.midId);
43913             const endNode = context3.entity(endNodeId);
43914             const crossWay = context3.entity(crossWayId);
43915             const nearEndNodes = findNearbyEndNodes(endNode, crossWay);
43916             if (nearEndNodes.length > 0) {
43917               const collinear = findSmallJoinAngle(midNode, endNode, nearEndNodes);
43918               if (collinear) {
43919                 context3.perform(
43920                   actionMergeNodes([collinear.id, endNode.id], collinear.loc),
43921                   annotation
43922                 );
43923                 return;
43924               }
43925             }
43926             const targetEdge = this.issue.data.edge;
43927             const crossLoc = this.issue.data.cross_loc;
43928             const edgeNodes = [context3.entity(targetEdge[0]), context3.entity(targetEdge[1])];
43929             const closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
43930             if (closestNodeInfo.distance < WELD_TH_METERS) {
43931               context3.perform(
43932                 actionMergeNodes([closestNodeInfo.node.id, endNode.id], closestNodeInfo.node.loc),
43933                 annotation
43934               );
43935             } else {
43936               context3.perform(
43937                 actionAddMidpoint({ loc: crossLoc, edge: targetEdge }, endNode),
43938                 annotation
43939               );
43940             }
43941           }
43942         })];
43943         const node = context2.hasEntity(this.entityIds[1]);
43944         if (node && !node.hasInterestingTags()) {
43945           fixes.push(new validationIssueFix({
43946             icon: "maki-barrier",
43947             title: _t.append("issues.fix.tag_as_disconnected.title"),
43948             onClick: function(context3) {
43949               const nodeID = this.issue.entityIds[1];
43950               const tags = Object.assign({}, context3.entity(nodeID).tags);
43951               tags.noexit = "yes";
43952               context3.perform(
43953                 actionChangeTags(nodeID, tags),
43954                 _t("issues.fix.tag_as_disconnected.annotation")
43955               );
43956             }
43957           }));
43958         }
43959         return fixes;
43960       }
43961       function showReference(selection2) {
43962         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.almost_junction.highway-highway.reference"));
43963       }
43964       function isExtendableCandidate(node, way) {
43965         const osm = services.osm;
43966         if (osm && !osm.isDataLoaded(node.loc)) {
43967           return false;
43968         }
43969         if (isTaggedAsNotContinuing(node) || graph.parentWays(node).length !== 1) {
43970           return false;
43971         }
43972         let occurrences = 0;
43973         for (const index in way.nodes) {
43974           if (way.nodes[index] === node.id) {
43975             occurrences += 1;
43976             if (occurrences > 1) {
43977               return false;
43978             }
43979           }
43980         }
43981         return true;
43982       }
43983       function findConnectableEndNodesByExtension(way) {
43984         let results = [];
43985         if (way.isClosed())
43986           return results;
43987         let testNodes;
43988         const indices = [0, way.nodes.length - 1];
43989         indices.forEach((nodeIndex) => {
43990           const nodeID = way.nodes[nodeIndex];
43991           const node = graph.entity(nodeID);
43992           if (!isExtendableCandidate(node, way))
43993             return;
43994           const connectionInfo = canConnectByExtend(way, nodeIndex);
43995           if (!connectionInfo)
43996             return;
43997           testNodes = graph.childNodes(way).slice();
43998           testNodes[nodeIndex] = testNodes[nodeIndex].move(connectionInfo.cross_loc);
43999           if (geoHasSelfIntersections(testNodes, nodeID))
44000             return;
44001           results.push(connectionInfo);
44002         });
44003         return results;
44004       }
44005       function findNearbyEndNodes(node, way) {
44006         return [
44007           way.nodes[0],
44008           way.nodes[way.nodes.length - 1]
44009         ].map((d2) => graph.entity(d2)).filter((d2) => {
44010           return d2.id !== node.id && geoSphericalDistance(node.loc, d2.loc) <= CLOSE_NODE_TH;
44011         });
44012       }
44013       function findSmallJoinAngle(midNode, tipNode, endNodes) {
44014         let joinTo;
44015         let minAngle = Infinity;
44016         endNodes.forEach((endNode) => {
44017           const a1 = geoAngle(midNode, tipNode, context.projection) + Math.PI;
44018           const a2 = geoAngle(midNode, endNode, context.projection) + Math.PI;
44019           const diff = Math.max(a1, a2) - Math.min(a1, a2);
44020           if (diff < minAngle) {
44021             joinTo = endNode;
44022             minAngle = diff;
44023           }
44024         });
44025         if (minAngle <= SIG_ANGLE_TH)
44026           return joinTo;
44027         return null;
44028       }
44029       function hasTag(tags, key) {
44030         return tags[key] !== void 0 && tags[key] !== "no";
44031       }
44032       function canConnectWays(way, way2) {
44033         if (way.id === way2.id)
44034           return true;
44035         if ((hasTag(way.tags, "bridge") || hasTag(way2.tags, "bridge")) && !(hasTag(way.tags, "bridge") && hasTag(way2.tags, "bridge")))
44036           return false;
44037         if ((hasTag(way.tags, "tunnel") || hasTag(way2.tags, "tunnel")) && !(hasTag(way.tags, "tunnel") && hasTag(way2.tags, "tunnel")))
44038           return false;
44039         const layer1 = way.tags.layer || "0", layer2 = way2.tags.layer || "0";
44040         if (layer1 !== layer2)
44041           return false;
44042         const level1 = way.tags.level || "0", level2 = way2.tags.level || "0";
44043         if (level1 !== level2)
44044           return false;
44045         return true;
44046       }
44047       function canConnectByExtend(way, endNodeIdx) {
44048         const tipNid = way.nodes[endNodeIdx];
44049         const midNid = endNodeIdx === 0 ? way.nodes[1] : way.nodes[way.nodes.length - 2];
44050         const tipNode = graph.entity(tipNid);
44051         const midNode = graph.entity(midNid);
44052         const lon = tipNode.loc[0];
44053         const lat = tipNode.loc[1];
44054         const lon_range = geoMetersToLon(EXTEND_TH_METERS, lat) / 2;
44055         const lat_range = geoMetersToLat(EXTEND_TH_METERS) / 2;
44056         const queryExtent = geoExtent([
44057           [lon - lon_range, lat - lat_range],
44058           [lon + lon_range, lat + lat_range]
44059         ]);
44060         const edgeLen = geoSphericalDistance(midNode.loc, tipNode.loc);
44061         const t2 = EXTEND_TH_METERS / edgeLen + 1;
44062         const extTipLoc = geoVecInterp(midNode.loc, tipNode.loc, t2);
44063         const segmentInfos = tree.waySegments(queryExtent, graph);
44064         for (let i3 = 0; i3 < segmentInfos.length; i3++) {
44065           let segmentInfo = segmentInfos[i3];
44066           let way2 = graph.entity(segmentInfo.wayId);
44067           if (!isHighway(way2))
44068             continue;
44069           if (!canConnectWays(way, way2))
44070             continue;
44071           let nAid = segmentInfo.nodes[0], nBid = segmentInfo.nodes[1];
44072           if (nAid === tipNid || nBid === tipNid)
44073             continue;
44074           let nA = graph.entity(nAid), nB = graph.entity(nBid);
44075           let crossLoc = geoLineIntersection([tipNode.loc, extTipLoc], [nA.loc, nB.loc]);
44076           if (crossLoc) {
44077             return {
44078               mid: midNode,
44079               node: tipNode,
44080               wid: way2.id,
44081               edge: [nA.id, nB.id],
44082               cross_loc: crossLoc
44083             };
44084           }
44085         }
44086         return null;
44087       }
44088     };
44089     validation.type = type2;
44090     return validation;
44091   }
44092
44093   // modules/validations/close_nodes.js
44094   function validationCloseNodes(context) {
44095     var type2 = "close_nodes";
44096     var pointThresholdMeters = 0.2;
44097     var validation = function(entity, graph) {
44098       if (entity.type === "node") {
44099         return getIssuesForNode(entity);
44100       } else if (entity.type === "way") {
44101         return getIssuesForWay(entity);
44102       }
44103       return [];
44104       function getIssuesForNode(node) {
44105         var parentWays = graph.parentWays(node);
44106         if (parentWays.length) {
44107           return getIssuesForVertex(node, parentWays);
44108         } else {
44109           return getIssuesForDetachedPoint(node);
44110         }
44111       }
44112       function wayTypeFor(way) {
44113         if (way.tags.boundary && way.tags.boundary !== "no")
44114           return "boundary";
44115         if (way.tags.indoor && way.tags.indoor !== "no")
44116           return "indoor";
44117         if (way.tags.building && way.tags.building !== "no" || way.tags["building:part"] && way.tags["building:part"] !== "no")
44118           return "building";
44119         if (osmPathHighwayTagValues[way.tags.highway])
44120           return "path";
44121         var parentRelations = graph.parentRelations(way);
44122         for (var i3 in parentRelations) {
44123           var relation = parentRelations[i3];
44124           if (relation.tags.type === "boundary")
44125             return "boundary";
44126           if (relation.isMultipolygon()) {
44127             if (relation.tags.indoor && relation.tags.indoor !== "no")
44128               return "indoor";
44129             if (relation.tags.building && relation.tags.building !== "no" || relation.tags["building:part"] && relation.tags["building:part"] !== "no")
44130               return "building";
44131           }
44132         }
44133         return "other";
44134       }
44135       function shouldCheckWay(way) {
44136         if (way.nodes.length <= 2 || way.isClosed() && way.nodes.length <= 4)
44137           return false;
44138         var bbox2 = way.extent(graph).bbox();
44139         var hypotenuseMeters = geoSphericalDistance([bbox2.minX, bbox2.minY], [bbox2.maxX, bbox2.maxY]);
44140         if (hypotenuseMeters < 1.5)
44141           return false;
44142         return true;
44143       }
44144       function getIssuesForWay(way) {
44145         if (!shouldCheckWay(way))
44146           return [];
44147         var issues = [], nodes = graph.childNodes(way);
44148         for (var i3 = 0; i3 < nodes.length - 1; i3++) {
44149           var node1 = nodes[i3];
44150           var node2 = nodes[i3 + 1];
44151           var issue = getWayIssueIfAny(node1, node2, way);
44152           if (issue)
44153             issues.push(issue);
44154         }
44155         return issues;
44156       }
44157       function getIssuesForVertex(node, parentWays) {
44158         var issues = [];
44159         function checkForCloseness(node1, node2, way) {
44160           var issue = getWayIssueIfAny(node1, node2, way);
44161           if (issue)
44162             issues.push(issue);
44163         }
44164         for (var i3 = 0; i3 < parentWays.length; i3++) {
44165           var parentWay = parentWays[i3];
44166           if (!shouldCheckWay(parentWay))
44167             continue;
44168           var lastIndex = parentWay.nodes.length - 1;
44169           for (var j2 = 0; j2 < parentWay.nodes.length; j2++) {
44170             if (j2 !== 0) {
44171               if (parentWay.nodes[j2 - 1] === node.id) {
44172                 checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay);
44173               }
44174             }
44175             if (j2 !== lastIndex) {
44176               if (parentWay.nodes[j2 + 1] === node.id) {
44177                 checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay);
44178               }
44179             }
44180           }
44181         }
44182         return issues;
44183       }
44184       function thresholdMetersForWay(way) {
44185         if (!shouldCheckWay(way))
44186           return 0;
44187         var wayType = wayTypeFor(way);
44188         if (wayType === "boundary")
44189           return 0;
44190         if (wayType === "indoor")
44191           return 0.01;
44192         if (wayType === "building")
44193           return 0.05;
44194         if (wayType === "path")
44195           return 0.1;
44196         return 0.2;
44197       }
44198       function getIssuesForDetachedPoint(node) {
44199         var issues = [];
44200         var lon = node.loc[0];
44201         var lat = node.loc[1];
44202         var lon_range = geoMetersToLon(pointThresholdMeters, lat) / 2;
44203         var lat_range = geoMetersToLat(pointThresholdMeters) / 2;
44204         var queryExtent = geoExtent([
44205           [lon - lon_range, lat - lat_range],
44206           [lon + lon_range, lat + lat_range]
44207         ]);
44208         var intersected = context.history().tree().intersects(queryExtent, graph);
44209         for (var j2 = 0; j2 < intersected.length; j2++) {
44210           var nearby = intersected[j2];
44211           if (nearby.id === node.id)
44212             continue;
44213           if (nearby.type !== "node" || nearby.geometry(graph) !== "point")
44214             continue;
44215           if (nearby.loc === node.loc || geoSphericalDistance(node.loc, nearby.loc) < pointThresholdMeters) {
44216             if ("memorial:type" in node.tags && "memorial:type" in nearby.tags && node.tags["memorial:type"] === "stolperstein" && nearby.tags["memorial:type"] === "stolperstein")
44217               continue;
44218             if ("memorial" in node.tags && "memorial" in nearby.tags && node.tags.memorial === "stolperstein" && nearby.tags.memorial === "stolperstein")
44219               continue;
44220             var zAxisKeys = { layer: true, level: true, "addr:housenumber": true, "addr:unit": true };
44221             var zAxisDifferentiates = false;
44222             for (var key in zAxisKeys) {
44223               var nodeValue = node.tags[key] || "0";
44224               var nearbyValue = nearby.tags[key] || "0";
44225               if (nodeValue !== nearbyValue) {
44226                 zAxisDifferentiates = true;
44227                 break;
44228               }
44229             }
44230             if (zAxisDifferentiates)
44231               continue;
44232             issues.push(new validationIssue({
44233               type: type2,
44234               subtype: "detached",
44235               severity: "warning",
44236               message: function(context2) {
44237                 var entity2 = context2.hasEntity(this.entityIds[0]), entity22 = context2.hasEntity(this.entityIds[1]);
44238                 return entity2 && entity22 ? _t.append("issues.close_nodes.detached.message", {
44239                   feature: utilDisplayLabel(entity2, context2.graph()),
44240                   feature2: utilDisplayLabel(entity22, context2.graph())
44241                 }) : "";
44242               },
44243               reference: showReference,
44244               entityIds: [node.id, nearby.id],
44245               dynamicFixes: function() {
44246                 return [
44247                   new validationIssueFix({
44248                     icon: "iD-operation-disconnect",
44249                     title: _t.append("issues.fix.move_points_apart.title")
44250                   }),
44251                   new validationIssueFix({
44252                     icon: "iD-icon-layers",
44253                     title: _t.append("issues.fix.use_different_layers_or_levels.title")
44254                   })
44255                 ];
44256               }
44257             }));
44258           }
44259         }
44260         return issues;
44261         function showReference(selection2) {
44262           var referenceText = _t("issues.close_nodes.detached.reference");
44263           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44264         }
44265       }
44266       function getWayIssueIfAny(node1, node2, way) {
44267         if (node1.id === node2.id || node1.hasInterestingTags() && node2.hasInterestingTags()) {
44268           return null;
44269         }
44270         if (node1.loc !== node2.loc) {
44271           var parentWays1 = graph.parentWays(node1);
44272           var parentWays2 = new Set(graph.parentWays(node2));
44273           var sharedWays = parentWays1.filter(function(parentWay) {
44274             return parentWays2.has(parentWay);
44275           });
44276           var thresholds = sharedWays.map(function(parentWay) {
44277             return thresholdMetersForWay(parentWay);
44278           });
44279           var threshold = Math.min(...thresholds);
44280           var distance = geoSphericalDistance(node1.loc, node2.loc);
44281           if (distance > threshold)
44282             return null;
44283         }
44284         return new validationIssue({
44285           type: type2,
44286           subtype: "vertices",
44287           severity: "warning",
44288           message: function(context2) {
44289             var entity2 = context2.hasEntity(this.entityIds[0]);
44290             return entity2 ? _t.append("issues.close_nodes.message", { way: utilDisplayLabel(entity2, context2.graph()) }) : "";
44291           },
44292           reference: showReference,
44293           entityIds: [way.id, node1.id, node2.id],
44294           loc: node1.loc,
44295           dynamicFixes: function() {
44296             return [
44297               new validationIssueFix({
44298                 icon: "iD-icon-plus",
44299                 title: _t.append("issues.fix.merge_points.title"),
44300                 onClick: function(context2) {
44301                   var entityIds = this.issue.entityIds;
44302                   var action = actionMergeNodes([entityIds[1], entityIds[2]]);
44303                   context2.perform(action, _t("issues.fix.merge_close_vertices.annotation"));
44304                 }
44305               }),
44306               new validationIssueFix({
44307                 icon: "iD-operation-disconnect",
44308                 title: _t.append("issues.fix.move_points_apart.title")
44309               })
44310             ];
44311           }
44312         });
44313         function showReference(selection2) {
44314           var referenceText = _t("issues.close_nodes.reference");
44315           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44316         }
44317       }
44318     };
44319     validation.type = type2;
44320     return validation;
44321   }
44322
44323   // modules/validations/crossing_ways.js
44324   var import_lodash3 = __toESM(require_lodash());
44325   function validationCrossingWays(context) {
44326     var type2 = "crossing_ways";
44327     function getFeatureWithFeatureTypeTagsForWay(way, graph) {
44328       if (getFeatureType(way, graph) === null) {
44329         var parentRels = graph.parentRelations(way);
44330         for (var i3 = 0; i3 < parentRels.length; i3++) {
44331           var rel = parentRels[i3];
44332           if (getFeatureType(rel, graph) !== null) {
44333             return rel;
44334           }
44335         }
44336       }
44337       return way;
44338     }
44339     function hasTag(tags, key) {
44340       return tags[key] !== void 0 && tags[key] !== "no";
44341     }
44342     function taggedAsIndoor(tags) {
44343       return hasTag(tags, "indoor") || hasTag(tags, "level") || tags.highway === "corridor";
44344     }
44345     function allowsBridge(featureType) {
44346       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44347     }
44348     function allowsTunnel(featureType) {
44349       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44350     }
44351     var ignoredBuildings = {
44352       demolished: true,
44353       dismantled: true,
44354       proposed: true,
44355       razed: true
44356     };
44357     function getFeatureType(entity, graph) {
44358       var geometry = entity.geometry(graph);
44359       if (geometry !== "line" && geometry !== "area")
44360         return null;
44361       var tags = entity.tags;
44362       if (hasTag(tags, "building") && !ignoredBuildings[tags.building])
44363         return "building";
44364       if (hasTag(tags, "highway") && osmRoutableHighwayTagValues[tags.highway])
44365         return "highway";
44366       if (geometry !== "line")
44367         return null;
44368       if (hasTag(tags, "railway") && osmRailwayTrackTagValues[tags.railway])
44369         return "railway";
44370       if (hasTag(tags, "waterway") && osmFlowingWaterwayTagValues[tags.waterway])
44371         return "waterway";
44372       return null;
44373     }
44374     function isLegitCrossing(tags1, featureType1, tags2, featureType2) {
44375       var level1 = tags1.level || "0";
44376       var level2 = tags2.level || "0";
44377       if (taggedAsIndoor(tags1) && taggedAsIndoor(tags2) && level1 !== level2) {
44378         return true;
44379       }
44380       var layer1 = tags1.layer || "0";
44381       var layer2 = tags2.layer || "0";
44382       if (allowsBridge(featureType1) && allowsBridge(featureType2)) {
44383         if (hasTag(tags1, "bridge") && !hasTag(tags2, "bridge"))
44384           return true;
44385         if (!hasTag(tags1, "bridge") && hasTag(tags2, "bridge"))
44386           return true;
44387         if (hasTag(tags1, "bridge") && hasTag(tags2, "bridge") && layer1 !== layer2)
44388           return true;
44389       } else if (allowsBridge(featureType1) && hasTag(tags1, "bridge"))
44390         return true;
44391       else if (allowsBridge(featureType2) && hasTag(tags2, "bridge"))
44392         return true;
44393       if (allowsTunnel(featureType1) && allowsTunnel(featureType2)) {
44394         if (hasTag(tags1, "tunnel") && !hasTag(tags2, "tunnel"))
44395           return true;
44396         if (!hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel"))
44397           return true;
44398         if (hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel") && layer1 !== layer2)
44399           return true;
44400       } else if (allowsTunnel(featureType1) && hasTag(tags1, "tunnel"))
44401         return true;
44402       else if (allowsTunnel(featureType2) && hasTag(tags2, "tunnel"))
44403         return true;
44404       if (featureType1 === "waterway" && featureType2 === "highway" && tags2.man_made === "pier")
44405         return true;
44406       if (featureType2 === "waterway" && featureType1 === "highway" && tags1.man_made === "pier")
44407         return true;
44408       if (featureType1 === "building" || featureType2 === "building" || taggedAsIndoor(tags1) || taggedAsIndoor(tags2)) {
44409         if (layer1 !== layer2)
44410           return true;
44411       }
44412       return false;
44413     }
44414     var highwaysDisallowingFords = {
44415       motorway: true,
44416       motorway_link: true,
44417       trunk: true,
44418       trunk_link: true,
44419       primary: true,
44420       primary_link: true,
44421       secondary: true,
44422       secondary_link: true
44423     };
44424     function tagsForConnectionNodeIfAllowed(entity1, entity2, graph, lessLikelyTags) {
44425       var featureType1 = getFeatureType(entity1, graph);
44426       var featureType2 = getFeatureType(entity2, graph);
44427       var geometry1 = entity1.geometry(graph);
44428       var geometry2 = entity2.geometry(graph);
44429       var bothLines = geometry1 === "line" && geometry2 === "line";
44430       if (featureType1 === featureType2) {
44431         if (featureType1 === "highway") {
44432           var entity1IsPath = osmPathHighwayTagValues[entity1.tags.highway];
44433           var entity2IsPath = osmPathHighwayTagValues[entity2.tags.highway];
44434           if ((entity1IsPath || entity2IsPath) && entity1IsPath !== entity2IsPath) {
44435             var roadFeature = entity1IsPath ? entity2 : entity1;
44436             var pathFeature = entity1IsPath ? entity1 : entity2;
44437             if (roadFeature.tags.highway === "track") {
44438               return {};
44439             }
44440             if (!lessLikelyTags && roadFeature.tags.highway === "service" && pathFeature.tags.highway === "footway" && pathFeature.tags.footway === "sidewalk") {
44441               return {};
44442             }
44443             if (["marked", "unmarked", "traffic_signals", "uncontrolled"].indexOf(pathFeature.tags.crossing) !== -1) {
44444               return bothLines ? { highway: "crossing", crossing: pathFeature.tags.crossing } : {};
44445             }
44446             return bothLines ? { highway: "crossing" } : {};
44447           }
44448           return {};
44449         }
44450         if (featureType1 === "waterway")
44451           return {};
44452         if (featureType1 === "railway")
44453           return {};
44454       } else {
44455         var featureTypes = [featureType1, featureType2];
44456         if (featureTypes.indexOf("highway") !== -1) {
44457           if (featureTypes.indexOf("railway") !== -1) {
44458             if (!bothLines)
44459               return {};
44460             var isTram = entity1.tags.railway === "tram" || entity2.tags.railway === "tram";
44461             if (osmPathHighwayTagValues[entity1.tags.highway] || osmPathHighwayTagValues[entity2.tags.highway]) {
44462               if (isTram)
44463                 return { railway: "tram_crossing" };
44464               return { railway: "crossing" };
44465             } else {
44466               if (isTram)
44467                 return { railway: "tram_level_crossing" };
44468               return { railway: "level_crossing" };
44469             }
44470           }
44471           if (featureTypes.indexOf("waterway") !== -1) {
44472             if (hasTag(entity1.tags, "tunnel") && hasTag(entity2.tags, "tunnel"))
44473               return null;
44474             if (hasTag(entity1.tags, "bridge") && hasTag(entity2.tags, "bridge"))
44475               return null;
44476             if (highwaysDisallowingFords[entity1.tags.highway] || highwaysDisallowingFords[entity2.tags.highway]) {
44477               return null;
44478             }
44479             return bothLines ? { ford: "yes" } : {};
44480           }
44481         }
44482       }
44483       return null;
44484     }
44485     function findCrossingsByWay(way1, graph, tree) {
44486       var edgeCrossInfos = [];
44487       if (way1.type !== "way")
44488         return edgeCrossInfos;
44489       var taggedFeature1 = getFeatureWithFeatureTypeTagsForWay(way1, graph);
44490       var way1FeatureType = getFeatureType(taggedFeature1, graph);
44491       if (way1FeatureType === null)
44492         return edgeCrossInfos;
44493       var checkedSingleCrossingWays = {};
44494       var i3, j2;
44495       var extent;
44496       var n1, n22, nA, nB, nAId, nBId;
44497       var segment1, segment2;
44498       var oneOnly;
44499       var segmentInfos, segment2Info, way2, taggedFeature2, way2FeatureType;
44500       var way1Nodes = graph.childNodes(way1);
44501       var comparedWays = {};
44502       for (i3 = 0; i3 < way1Nodes.length - 1; i3++) {
44503         n1 = way1Nodes[i3];
44504         n22 = way1Nodes[i3 + 1];
44505         extent = geoExtent([
44506           [
44507             Math.min(n1.loc[0], n22.loc[0]),
44508             Math.min(n1.loc[1], n22.loc[1])
44509           ],
44510           [
44511             Math.max(n1.loc[0], n22.loc[0]),
44512             Math.max(n1.loc[1], n22.loc[1])
44513           ]
44514         ]);
44515         segmentInfos = tree.waySegments(extent, graph);
44516         for (j2 = 0; j2 < segmentInfos.length; j2++) {
44517           segment2Info = segmentInfos[j2];
44518           if (segment2Info.wayId === way1.id)
44519             continue;
44520           if (checkedSingleCrossingWays[segment2Info.wayId])
44521             continue;
44522           comparedWays[segment2Info.wayId] = true;
44523           way2 = graph.hasEntity(segment2Info.wayId);
44524           if (!way2)
44525             continue;
44526           taggedFeature2 = getFeatureWithFeatureTypeTagsForWay(way2, graph);
44527           way2FeatureType = getFeatureType(taggedFeature2, graph);
44528           if (way2FeatureType === null || isLegitCrossing(taggedFeature1.tags, way1FeatureType, taggedFeature2.tags, way2FeatureType)) {
44529             continue;
44530           }
44531           oneOnly = way1FeatureType === "building" || way2FeatureType === "building";
44532           nAId = segment2Info.nodes[0];
44533           nBId = segment2Info.nodes[1];
44534           if (nAId === n1.id || nAId === n22.id || nBId === n1.id || nBId === n22.id) {
44535             continue;
44536           }
44537           nA = graph.hasEntity(nAId);
44538           if (!nA)
44539             continue;
44540           nB = graph.hasEntity(nBId);
44541           if (!nB)
44542             continue;
44543           segment1 = [n1.loc, n22.loc];
44544           segment2 = [nA.loc, nB.loc];
44545           var point2 = geoLineIntersection(segment1, segment2);
44546           if (point2) {
44547             edgeCrossInfos.push({
44548               wayInfos: [
44549                 {
44550                   way: way1,
44551                   featureType: way1FeatureType,
44552                   edge: [n1.id, n22.id]
44553                 },
44554                 {
44555                   way: way2,
44556                   featureType: way2FeatureType,
44557                   edge: [nA.id, nB.id]
44558                 }
44559               ],
44560               crossPoint: point2
44561             });
44562             if (oneOnly) {
44563               checkedSingleCrossingWays[way2.id] = true;
44564               break;
44565             }
44566           }
44567         }
44568       }
44569       return edgeCrossInfos;
44570     }
44571     function waysToCheck(entity, graph) {
44572       var featureType = getFeatureType(entity, graph);
44573       if (!featureType)
44574         return [];
44575       if (entity.type === "way") {
44576         return [entity];
44577       } else if (entity.type === "relation") {
44578         return entity.members.reduce(function(array2, member) {
44579           if (member.type === "way" && // only look at geometry ways
44580           (!member.role || member.role === "outer" || member.role === "inner")) {
44581             var entity2 = graph.hasEntity(member.id);
44582             if (entity2 && array2.indexOf(entity2) === -1) {
44583               array2.push(entity2);
44584             }
44585           }
44586           return array2;
44587         }, []);
44588       }
44589       return [];
44590     }
44591     var validation = function checkCrossingWays(entity, graph) {
44592       var tree = context.history().tree();
44593       var ways = waysToCheck(entity, graph);
44594       var issues = [];
44595       var wayIndex, crossingIndex, crossings;
44596       for (wayIndex in ways) {
44597         crossings = findCrossingsByWay(ways[wayIndex], graph, tree);
44598         for (crossingIndex in crossings) {
44599           issues.push(createIssue(crossings[crossingIndex], graph));
44600         }
44601       }
44602       return issues;
44603     };
44604     function createIssue(crossing, graph) {
44605       crossing.wayInfos.sort(function(way1Info, way2Info) {
44606         var type1 = way1Info.featureType;
44607         var type22 = way2Info.featureType;
44608         if (type1 === type22) {
44609           return utilDisplayLabel(way1Info.way, graph) > utilDisplayLabel(way2Info.way, graph);
44610         } else if (type1 === "waterway") {
44611           return true;
44612         } else if (type22 === "waterway") {
44613           return false;
44614         }
44615         return type1 < type22;
44616       });
44617       var entities = crossing.wayInfos.map(function(wayInfo) {
44618         return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
44619       });
44620       var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
44621       var featureTypes = [crossing.wayInfos[0].featureType, crossing.wayInfos[1].featureType];
44622       var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph);
44623       var featureType1 = crossing.wayInfos[0].featureType;
44624       var featureType2 = crossing.wayInfos[1].featureType;
44625       var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
44626       var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, "tunnel") && allowsTunnel(featureType2) && hasTag(entities[1].tags, "tunnel");
44627       var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, "bridge") && allowsBridge(featureType2) && hasTag(entities[1].tags, "bridge");
44628       var subtype = [featureType1, featureType2].sort().join("-");
44629       var crossingTypeID = subtype;
44630       if (isCrossingIndoors) {
44631         crossingTypeID = "indoor-indoor";
44632       } else if (isCrossingTunnels) {
44633         crossingTypeID = "tunnel-tunnel";
44634       } else if (isCrossingBridges) {
44635         crossingTypeID = "bridge-bridge";
44636       }
44637       if (connectionTags && (isCrossingIndoors || isCrossingTunnels || isCrossingBridges)) {
44638         crossingTypeID += "_connectable";
44639       }
44640       var uniqueID = crossing.crossPoint[0].toFixed(4) + "," + crossing.crossPoint[1].toFixed(4);
44641       return new validationIssue({
44642         type: type2,
44643         subtype,
44644         severity: "warning",
44645         message: function(context2) {
44646           var graph2 = context2.graph();
44647           var entity1 = graph2.hasEntity(this.entityIds[0]), entity2 = graph2.hasEntity(this.entityIds[1]);
44648           return entity1 && entity2 ? _t.append("issues.crossing_ways.message", {
44649             feature: utilDisplayLabel(entity1, graph2),
44650             feature2: utilDisplayLabel(entity2, graph2)
44651           }) : "";
44652         },
44653         reference: showReference,
44654         entityIds: entities.map(function(entity) {
44655           return entity.id;
44656         }),
44657         data: {
44658           edges,
44659           featureTypes,
44660           connectionTags
44661         },
44662         hash: uniqueID,
44663         loc: crossing.crossPoint,
44664         dynamicFixes: function(context2) {
44665           var mode = context2.mode();
44666           if (!mode || mode.id !== "select" || mode.selectedIDs().length !== 1)
44667             return [];
44668           var selectedIndex = this.entityIds[0] === mode.selectedIDs()[0] ? 0 : 1;
44669           var selectedFeatureType = this.data.featureTypes[selectedIndex];
44670           var otherFeatureType = this.data.featureTypes[selectedIndex === 0 ? 1 : 0];
44671           var fixes = [];
44672           if (connectionTags) {
44673             fixes.push(makeConnectWaysFix(this.data.connectionTags));
44674             let lessLikelyConnectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph, true);
44675             if (lessLikelyConnectionTags && !(0, import_lodash3.isEqual)(connectionTags, lessLikelyConnectionTags)) {
44676               fixes.push(makeConnectWaysFix(lessLikelyConnectionTags));
44677             }
44678           }
44679           if (isCrossingIndoors) {
44680             fixes.push(new validationIssueFix({
44681               icon: "iD-icon-layers",
44682               title: _t.append("issues.fix.use_different_levels.title")
44683             }));
44684           } else if (isCrossingTunnels || isCrossingBridges || featureType1 === "building" || featureType2 === "building") {
44685             fixes.push(makeChangeLayerFix("higher"));
44686             fixes.push(makeChangeLayerFix("lower"));
44687           } else if (context2.graph().geometry(this.entityIds[0]) === "line" && context2.graph().geometry(this.entityIds[1]) === "line") {
44688             if (allowsBridge(selectedFeatureType) && selectedFeatureType !== "waterway") {
44689               fixes.push(makeAddBridgeOrTunnelFix("add_a_bridge", "temaki-bridge", "bridge"));
44690             }
44691             var skipTunnelFix = otherFeatureType === "waterway" && selectedFeatureType !== "waterway";
44692             if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) {
44693               fixes.push(makeAddBridgeOrTunnelFix("add_a_tunnel", "temaki-tunnel", "tunnel"));
44694             }
44695           }
44696           fixes.push(new validationIssueFix({
44697             icon: "iD-operation-move",
44698             title: _t.append("issues.fix.reposition_features.title")
44699           }));
44700           return fixes;
44701         }
44702       });
44703       function showReference(selection2) {
44704         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.crossing_ways." + crossingTypeID + ".reference"));
44705       }
44706     }
44707     function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
44708       return new validationIssueFix({
44709         icon: iconName,
44710         title: _t.append("issues.fix." + fixTitleID + ".title"),
44711         onClick: function(context2) {
44712           var mode = context2.mode();
44713           if (!mode || mode.id !== "select")
44714             return;
44715           var selectedIDs = mode.selectedIDs();
44716           if (selectedIDs.length !== 1)
44717             return;
44718           var selectedWayID = selectedIDs[0];
44719           if (!context2.hasEntity(selectedWayID))
44720             return;
44721           var resultWayIDs = [selectedWayID];
44722           var edge, crossedEdge, crossedWayID;
44723           if (this.issue.entityIds[0] === selectedWayID) {
44724             edge = this.issue.data.edges[0];
44725             crossedEdge = this.issue.data.edges[1];
44726             crossedWayID = this.issue.entityIds[1];
44727           } else {
44728             edge = this.issue.data.edges[1];
44729             crossedEdge = this.issue.data.edges[0];
44730             crossedWayID = this.issue.entityIds[0];
44731           }
44732           var crossingLoc = this.issue.loc;
44733           var projection2 = context2.projection;
44734           var action = function actionAddStructure(graph) {
44735             var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44736             var crossedWay = graph.hasEntity(crossedWayID);
44737             var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width);
44738             if (!structLengthMeters) {
44739               structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters();
44740             }
44741             if (structLengthMeters) {
44742               if (getFeatureType(crossedWay, graph) === "railway") {
44743                 structLengthMeters *= 2;
44744               }
44745             } else {
44746               structLengthMeters = 8;
44747             }
44748             var a1 = geoAngle(edgeNodes[0], edgeNodes[1], projection2) + Math.PI;
44749             var a2 = geoAngle(graph.entity(crossedEdge[0]), graph.entity(crossedEdge[1]), projection2) + Math.PI;
44750             var crossingAngle = Math.max(a1, a2) - Math.min(a1, a2);
44751             if (crossingAngle > Math.PI)
44752               crossingAngle -= Math.PI;
44753             structLengthMeters = structLengthMeters / 2 / Math.sin(crossingAngle) * 2;
44754             structLengthMeters += 4;
44755             structLengthMeters = Math.min(Math.max(structLengthMeters, 4), 50);
44756             function geomToProj(geoPoint) {
44757               return [
44758                 geoLonToMeters(geoPoint[0], geoPoint[1]),
44759                 geoLatToMeters(geoPoint[1])
44760               ];
44761             }
44762             function projToGeom(projPoint) {
44763               var lat = geoMetersToLat(projPoint[1]);
44764               return [
44765                 geoMetersToLon(projPoint[0], lat),
44766                 lat
44767               ];
44768             }
44769             var projEdgeNode1 = geomToProj(edgeNodes[0].loc);
44770             var projEdgeNode2 = geomToProj(edgeNodes[1].loc);
44771             var projectedAngle = geoVecAngle(projEdgeNode1, projEdgeNode2);
44772             var projectedCrossingLoc = geomToProj(crossingLoc);
44773             var linearToSphericalMetersRatio = geoVecLength(projEdgeNode1, projEdgeNode2) / geoSphericalDistance(edgeNodes[0].loc, edgeNodes[1].loc);
44774             function locSphericalDistanceFromCrossingLoc(angle2, distanceMeters) {
44775               var lengthSphericalMeters = distanceMeters * linearToSphericalMetersRatio;
44776               return projToGeom([
44777                 projectedCrossingLoc[0] + Math.cos(angle2) * lengthSphericalMeters,
44778                 projectedCrossingLoc[1] + Math.sin(angle2) * lengthSphericalMeters
44779               ]);
44780             }
44781             var endpointLocGetter1 = function(lengthMeters) {
44782               return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
44783             };
44784             var endpointLocGetter2 = function(lengthMeters) {
44785               return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
44786             };
44787             var minEdgeLengthMeters = 0.55;
44788             function determineEndpoint(edge2, endNode, locGetter) {
44789               var newNode;
44790               var idealLengthMeters = structLengthMeters / 2;
44791               var crossingToEdgeEndDistance = geoSphericalDistance(crossingLoc, endNode.loc);
44792               if (crossingToEdgeEndDistance - idealLengthMeters > minEdgeLengthMeters) {
44793                 var idealNodeLoc = locGetter(idealLengthMeters);
44794                 newNode = osmNode();
44795                 graph = actionAddMidpoint({ loc: idealNodeLoc, edge: edge2 }, newNode)(graph);
44796               } else {
44797                 var edgeCount = 0;
44798                 endNode.parentIntersectionWays(graph).forEach(function(way) {
44799                   way.nodes.forEach(function(nodeID) {
44800                     if (nodeID === endNode.id) {
44801                       if (endNode.id === way.first() && endNode.id !== way.last() || endNode.id === way.last() && endNode.id !== way.first()) {
44802                         edgeCount += 1;
44803                       } else {
44804                         edgeCount += 2;
44805                       }
44806                     }
44807                   });
44808                 });
44809                 if (edgeCount >= 3) {
44810                   var insetLength = crossingToEdgeEndDistance - minEdgeLengthMeters;
44811                   if (insetLength > minEdgeLengthMeters) {
44812                     var insetNodeLoc = locGetter(insetLength);
44813                     newNode = osmNode();
44814                     graph = actionAddMidpoint({ loc: insetNodeLoc, edge: edge2 }, newNode)(graph);
44815                   }
44816                 }
44817               }
44818               if (!newNode)
44819                 newNode = endNode;
44820               var splitAction = actionSplit([newNode.id]).limitWays(resultWayIDs);
44821               graph = splitAction(graph);
44822               if (splitAction.getCreatedWayIDs().length) {
44823                 resultWayIDs.push(splitAction.getCreatedWayIDs()[0]);
44824               }
44825               return newNode;
44826             }
44827             var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
44828             var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
44829             var structureWay = resultWayIDs.map(function(id2) {
44830               return graph.entity(id2);
44831             }).find(function(way) {
44832               return way.nodes.indexOf(structEndNode1.id) !== -1 && way.nodes.indexOf(structEndNode2.id) !== -1;
44833             });
44834             var tags = Object.assign({}, structureWay.tags);
44835             if (bridgeOrTunnel === "bridge") {
44836               tags.bridge = "yes";
44837               tags.layer = "1";
44838             } else {
44839               var tunnelValue = "yes";
44840               if (getFeatureType(structureWay, graph) === "waterway") {
44841                 tunnelValue = "culvert";
44842               }
44843               tags.tunnel = tunnelValue;
44844               tags.layer = "-1";
44845             }
44846             graph = actionChangeTags(structureWay.id, tags)(graph);
44847             return graph;
44848           };
44849           context2.perform(action, _t("issues.fix." + fixTitleID + ".annotation"));
44850           context2.enter(modeSelect(context2, resultWayIDs));
44851         }
44852       });
44853     }
44854     function makeConnectWaysFix(connectionTags) {
44855       var fixTitleID = "connect_features";
44856       var fixIcon = "iD-icon-crossing";
44857       if (connectionTags.highway === "crossing") {
44858         fixTitleID = "connect_using_crossing";
44859         fixIcon = "temaki-pedestrian";
44860       }
44861       if (connectionTags.ford) {
44862         fixTitleID = "connect_using_ford";
44863         fixIcon = "roentgen-ford";
44864       }
44865       const fix = new validationIssueFix({
44866         icon: fixIcon,
44867         title: _t.append("issues.fix." + fixTitleID + ".title"),
44868         onClick: function(context2) {
44869           var loc = this.issue.loc;
44870           var edges = this.issue.data.edges;
44871           context2.perform(
44872             function actionConnectCrossingWays(graph) {
44873               var node = osmNode({ loc, tags: connectionTags });
44874               graph = graph.replace(node);
44875               var nodesToMerge = [node.id];
44876               var mergeThresholdInMeters = 0.75;
44877               edges.forEach(function(edge) {
44878                 var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44879                 var nearby = geoSphericalClosestNode(edgeNodes, loc);
44880                 if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
44881                   nodesToMerge.push(nearby.node.id);
44882                 } else {
44883                   graph = actionAddMidpoint({ loc, edge }, node)(graph);
44884                 }
44885               });
44886               if (nodesToMerge.length > 1) {
44887                 graph = actionMergeNodes(nodesToMerge, loc)(graph);
44888               }
44889               return graph;
44890             },
44891             _t("issues.fix.connect_crossing_features.annotation")
44892           );
44893         }
44894       });
44895       fix._connectionTags = connectionTags;
44896       return fix;
44897     }
44898     function makeChangeLayerFix(higherOrLower) {
44899       return new validationIssueFix({
44900         icon: "iD-icon-" + (higherOrLower === "higher" ? "up" : "down"),
44901         title: _t.append("issues.fix.tag_this_as_" + higherOrLower + ".title"),
44902         onClick: function(context2) {
44903           var mode = context2.mode();
44904           if (!mode || mode.id !== "select")
44905             return;
44906           var selectedIDs = mode.selectedIDs();
44907           if (selectedIDs.length !== 1)
44908             return;
44909           var selectedID = selectedIDs[0];
44910           if (!this.issue.entityIds.some(function(entityId) {
44911             return entityId === selectedID;
44912           }))
44913             return;
44914           var entity = context2.hasEntity(selectedID);
44915           if (!entity)
44916             return;
44917           var tags = Object.assign({}, entity.tags);
44918           var layer = tags.layer && Number(tags.layer);
44919           if (layer && !isNaN(layer)) {
44920             if (higherOrLower === "higher") {
44921               layer += 1;
44922             } else {
44923               layer -= 1;
44924             }
44925           } else {
44926             if (higherOrLower === "higher") {
44927               layer = 1;
44928             } else {
44929               layer = -1;
44930             }
44931           }
44932           tags.layer = layer.toString();
44933           context2.perform(
44934             actionChangeTags(entity.id, tags),
44935             _t("operations.change_tags.annotation")
44936           );
44937         }
44938       });
44939     }
44940     validation.type = type2;
44941     return validation;
44942   }
44943
44944   // modules/behavior/draw_way.js
44945   function behaviorDrawWay(context, wayID, mode, startGraph) {
44946     const keybinding = utilKeybinding("drawWay");
44947     var dispatch14 = dispatch_default("rejectedSelfIntersection");
44948     var behavior = behaviorDraw(context);
44949     var _nodeIndex;
44950     var _origWay;
44951     var _wayGeometry;
44952     var _headNodeID;
44953     var _annotation;
44954     var _pointerHasMoved = false;
44955     var _drawNode;
44956     var _didResolveTempEdit = false;
44957     function createDrawNode(loc) {
44958       _drawNode = osmNode({ loc });
44959       context.pauseChangeDispatch();
44960       context.replace(function actionAddDrawNode(graph) {
44961         var way = graph.entity(wayID);
44962         return graph.replace(_drawNode).replace(way.addNode(_drawNode.id, _nodeIndex));
44963       }, _annotation);
44964       context.resumeChangeDispatch();
44965       setActiveElements();
44966     }
44967     function removeDrawNode() {
44968       context.pauseChangeDispatch();
44969       context.replace(
44970         function actionDeleteDrawNode(graph) {
44971           var way = graph.entity(wayID);
44972           return graph.replace(way.removeNode(_drawNode.id)).remove(_drawNode);
44973         },
44974         _annotation
44975       );
44976       _drawNode = void 0;
44977       context.resumeChangeDispatch();
44978     }
44979     function keydown(d3_event) {
44980       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44981         if (context.surface().classed("nope")) {
44982           context.surface().classed("nope-suppressed", true);
44983         }
44984         context.surface().classed("nope", false).classed("nope-disabled", true);
44985       }
44986     }
44987     function keyup(d3_event) {
44988       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44989         if (context.surface().classed("nope-suppressed")) {
44990           context.surface().classed("nope", true);
44991         }
44992         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
44993       }
44994     }
44995     function allowsVertex(d2) {
44996       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
44997     }
44998     function move(d3_event, datum2) {
44999       var loc = context.map().mouseCoordinates();
45000       if (!_drawNode)
45001         createDrawNode(loc);
45002       context.surface().classed("nope-disabled", d3_event.altKey);
45003       var targetLoc = datum2 && datum2.properties && datum2.properties.entity && allowsVertex(datum2.properties.entity) && datum2.properties.entity.loc;
45004       var targetNodes = datum2 && datum2.properties && datum2.properties.nodes;
45005       if (targetLoc) {
45006         loc = targetLoc;
45007       } else if (targetNodes) {
45008         var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
45009         if (choice) {
45010           loc = choice.loc;
45011         }
45012       }
45013       context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
45014       _drawNode = context.entity(_drawNode.id);
45015       checkGeometry(
45016         true
45017         /* includeDrawNode */
45018       );
45019     }
45020     function checkGeometry(includeDrawNode) {
45021       var nopeDisabled = context.surface().classed("nope-disabled");
45022       var isInvalid = isInvalidGeometry(includeDrawNode);
45023       if (nopeDisabled) {
45024         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
45025       } else {
45026         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
45027       }
45028     }
45029     function isInvalidGeometry(includeDrawNode) {
45030       var testNode = _drawNode;
45031       var parentWay = context.graph().entity(wayID);
45032       var nodes = context.graph().childNodes(parentWay).slice();
45033       if (includeDrawNode) {
45034         if (parentWay.isClosed()) {
45035           nodes.pop();
45036         }
45037       } else {
45038         if (parentWay.isClosed()) {
45039           if (nodes.length < 3)
45040             return false;
45041           if (_drawNode)
45042             nodes.splice(-2, 1);
45043           testNode = nodes[nodes.length - 2];
45044         } else {
45045           return false;
45046         }
45047       }
45048       return testNode && geoHasSelfIntersections(nodes, testNode.id);
45049     }
45050     function undone() {
45051       _didResolveTempEdit = true;
45052       context.pauseChangeDispatch();
45053       var nextMode;
45054       if (context.graph() === startGraph) {
45055         nextMode = modeSelect(context, [wayID]);
45056       } else {
45057         context.pop(1);
45058         nextMode = mode;
45059       }
45060       context.perform(actionNoop());
45061       context.pop(1);
45062       context.resumeChangeDispatch();
45063       context.enter(nextMode);
45064     }
45065     function setActiveElements() {
45066       if (!_drawNode)
45067         return;
45068       context.surface().selectAll("." + _drawNode.id).classed("active", true);
45069     }
45070     function resetToStartGraph() {
45071       while (context.graph() !== startGraph) {
45072         context.pop();
45073       }
45074     }
45075     var drawWay = function(surface) {
45076       _drawNode = void 0;
45077       _didResolveTempEdit = false;
45078       _origWay = context.entity(wayID);
45079       if (typeof _nodeIndex === "number") {
45080         _headNodeID = _origWay.nodes[_nodeIndex];
45081       } else if (_origWay.isClosed()) {
45082         _headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
45083       } else {
45084         _headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
45085       }
45086       _wayGeometry = _origWay.geometry(context.graph());
45087       _annotation = _t(
45088         (_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ? "operations.start.annotation." : "operations.continue.annotation.") + _wayGeometry
45089       );
45090       _pointerHasMoved = false;
45091       context.pauseChangeDispatch();
45092       context.perform(actionNoop(), _annotation);
45093       context.resumeChangeDispatch();
45094       behavior.hover().initialNodeID(_headNodeID);
45095       behavior.on("move", function() {
45096         _pointerHasMoved = true;
45097         move.apply(this, arguments);
45098       }).on("down", function() {
45099         move.apply(this, arguments);
45100       }).on("downcancel", function() {
45101         if (_drawNode)
45102           removeDrawNode();
45103       }).on("click", drawWay.add).on("clickWay", drawWay.addWay).on("clickNode", drawWay.addNode).on("undo", context.undo).on("cancel", drawWay.cancel).on("finish", drawWay.finish);
45104       select_default2(window).on("keydown.drawWay", keydown).on("keyup.drawWay", keyup);
45105       context.map().dblclickZoomEnable(false).on("drawn.draw", setActiveElements);
45106       setActiveElements();
45107       surface.call(behavior);
45108       context.history().on("undone.draw", undone);
45109     };
45110     drawWay.off = function(surface) {
45111       if (!_didResolveTempEdit) {
45112         context.pauseChangeDispatch();
45113         resetToStartGraph();
45114         context.resumeChangeDispatch();
45115       }
45116       _drawNode = void 0;
45117       _nodeIndex = void 0;
45118       context.map().on("drawn.draw", null);
45119       surface.call(behavior.off).selectAll(".active").classed("active", false);
45120       surface.classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false);
45121       select_default2(window).on("keydown.drawWay", null).on("keyup.drawWay", null);
45122       context.history().on("undone.draw", null);
45123     };
45124     function attemptAdd(d2, loc, doAdd) {
45125       if (_drawNode) {
45126         context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
45127         _drawNode = context.entity(_drawNode.id);
45128       } else {
45129         createDrawNode(loc);
45130       }
45131       checkGeometry(
45132         true
45133         /* includeDrawNode */
45134       );
45135       if (d2 && d2.properties && d2.properties.nope || context.surface().classed("nope")) {
45136         if (!_pointerHasMoved) {
45137           removeDrawNode();
45138         }
45139         dispatch14.call("rejectedSelfIntersection", this);
45140         return;
45141       }
45142       context.pauseChangeDispatch();
45143       doAdd();
45144       _didResolveTempEdit = true;
45145       context.resumeChangeDispatch();
45146       context.enter(mode);
45147     }
45148     drawWay.add = function(loc, d2) {
45149       attemptAdd(d2, loc, function() {
45150       });
45151     };
45152     drawWay.addWay = function(loc, edge, d2) {
45153       attemptAdd(d2, loc, function() {
45154         context.replace(
45155           actionAddMidpoint({ loc, edge }, _drawNode),
45156           _annotation
45157         );
45158       });
45159     };
45160     drawWay.addNode = function(node, d2) {
45161       if (node.id === _headNodeID || // or the first node when drawing an area
45162       _origWay.isClosed() && node.id === _origWay.first()) {
45163         drawWay.finish();
45164         return;
45165       }
45166       attemptAdd(d2, node.loc, function() {
45167         context.replace(
45168           function actionReplaceDrawNode(graph) {
45169             graph = graph.replace(graph.entity(wayID).removeNode(_drawNode.id)).remove(_drawNode);
45170             return graph.replace(graph.entity(wayID).addNode(node.id, _nodeIndex));
45171           },
45172           _annotation
45173         );
45174       });
45175     };
45176     function getFeatureType(ways) {
45177       if (ways.every((way) => way.isClosed()))
45178         return "area";
45179       if (ways.every((way) => !way.isClosed()))
45180         return "line";
45181       return "generic";
45182     }
45183     function followMode() {
45184       if (_didResolveTempEdit)
45185         return;
45186       try {
45187         const isDrawingArea = _origWay.nodes[0] === _origWay.nodes.slice(-1)[0];
45188         const [secondLastNodeId, lastNodeId] = _origWay.nodes.slice(isDrawingArea ? -3 : -2);
45189         const historyGraph = context.history().graph();
45190         if (!lastNodeId || !secondLastNodeId || !historyGraph.hasEntity(lastNodeId) || !historyGraph.hasEntity(secondLastNodeId)) {
45191           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.needs_more_initial_nodes"))();
45192           return;
45193         }
45194         const lastNodesParents = historyGraph.parentWays(historyGraph.entity(lastNodeId)).filter((w2) => w2.id !== wayID);
45195         const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID);
45196         const featureType = getFeatureType(lastNodesParents);
45197         if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) {
45198           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))();
45199           return;
45200         }
45201         if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) {
45202           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))();
45203           return;
45204         }
45205         const way = lastNodesParents[0];
45206         const indexOfLast = way.nodes.indexOf(lastNodeId);
45207         const indexOfSecondLast = way.nodes.indexOf(secondLastNodeId);
45208         const isDescendingPastZero = indexOfLast === way.nodes.length - 2 && indexOfSecondLast === 0;
45209         let nextNodeIndex = indexOfLast + (indexOfLast > indexOfSecondLast && !isDescendingPastZero ? 1 : -1);
45210         if (nextNodeIndex === -1)
45211           nextNodeIndex = indexOfSecondLast === 1 ? way.nodes.length - 2 : 1;
45212         const nextNode = historyGraph.entity(way.nodes[nextNodeIndex]);
45213         drawWay.addNode(nextNode, {
45214           geometry: { type: "Point", coordinates: nextNode.loc },
45215           id: nextNode.id,
45216           properties: { target: true, entity: nextNode }
45217         });
45218       } catch (ex) {
45219         context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))();
45220       }
45221     }
45222     keybinding.on(_t("operations.follow.key"), followMode);
45223     select_default2(document).call(keybinding);
45224     drawWay.finish = function() {
45225       checkGeometry(
45226         false
45227         /* includeDrawNode */
45228       );
45229       if (context.surface().classed("nope")) {
45230         dispatch14.call("rejectedSelfIntersection", this);
45231         return;
45232       }
45233       context.pauseChangeDispatch();
45234       context.pop(1);
45235       _didResolveTempEdit = true;
45236       context.resumeChangeDispatch();
45237       var way = context.hasEntity(wayID);
45238       if (!way || way.isDegenerate()) {
45239         drawWay.cancel();
45240         return;
45241       }
45242       window.setTimeout(function() {
45243         context.map().dblclickZoomEnable(true);
45244       }, 1e3);
45245       var isNewFeature = !mode.isContinuing;
45246       context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature));
45247     };
45248     drawWay.cancel = function() {
45249       context.pauseChangeDispatch();
45250       resetToStartGraph();
45251       context.resumeChangeDispatch();
45252       window.setTimeout(function() {
45253         context.map().dblclickZoomEnable(true);
45254       }, 1e3);
45255       context.surface().classed("nope", false).classed("nope-disabled", false).classed("nope-suppressed", false);
45256       context.enter(modeBrowse(context));
45257     };
45258     drawWay.nodeIndex = function(val) {
45259       if (!arguments.length)
45260         return _nodeIndex;
45261       _nodeIndex = val;
45262       return drawWay;
45263     };
45264     drawWay.activeID = function() {
45265       if (!arguments.length)
45266         return _drawNode && _drawNode.id;
45267       return drawWay;
45268     };
45269     return utilRebind(drawWay, dispatch14, "on");
45270   }
45271
45272   // modules/modes/draw_line.js
45273   function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
45274     var mode = {
45275       button,
45276       id: "draw-line"
45277     };
45278     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawLine", function() {
45279       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.lines"))();
45280     });
45281     mode.wayID = wayID;
45282     mode.isContinuing = continuing;
45283     mode.enter = function() {
45284       behavior.nodeIndex(affix === "prefix" ? 0 : void 0);
45285       context.install(behavior);
45286     };
45287     mode.exit = function() {
45288       context.uninstall(behavior);
45289     };
45290     mode.selectedIDs = function() {
45291       return [wayID];
45292     };
45293     mode.activeID = function() {
45294       return behavior && behavior.activeID() || [];
45295     };
45296     return mode;
45297   }
45298
45299   // modules/validations/disconnected_way.js
45300   function validationDisconnectedWay() {
45301     var type2 = "disconnected_way";
45302     function isTaggedAsHighway(entity) {
45303       return osmRoutableHighwayTagValues[entity.tags.highway];
45304     }
45305     var validation = function checkDisconnectedWay(entity, graph) {
45306       var routingIslandWays = routingIslandForEntity(entity);
45307       if (!routingIslandWays)
45308         return [];
45309       return [new validationIssue({
45310         type: type2,
45311         subtype: "highway",
45312         severity: "warning",
45313         message: function(context) {
45314           var entity2 = this.entityIds.length && context.hasEntity(this.entityIds[0]);
45315           var label = entity2 && utilDisplayLabel(entity2, context.graph());
45316           return _t.append("issues.disconnected_way.routable.message", { count: this.entityIds.length, highway: label });
45317         },
45318         reference: showReference,
45319         entityIds: Array.from(routingIslandWays).map(function(way) {
45320           return way.id;
45321         }),
45322         dynamicFixes: makeFixes
45323       })];
45324       function makeFixes(context) {
45325         var fixes = [];
45326         var singleEntity = this.entityIds.length === 1 && context.hasEntity(this.entityIds[0]);
45327         if (singleEntity) {
45328           if (singleEntity.type === "way" && !singleEntity.isClosed()) {
45329             var textDirection = _mainLocalizer.textDirection();
45330             var startFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.first(), "start");
45331             if (startFix)
45332               fixes.push(startFix);
45333             var endFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.last(), "end");
45334             if (endFix)
45335               fixes.push(endFix);
45336           }
45337           if (!fixes.length) {
45338             fixes.push(new validationIssueFix({
45339               title: _t.append("issues.fix.connect_feature.title")
45340             }));
45341           }
45342           fixes.push(new validationIssueFix({
45343             icon: "iD-operation-delete",
45344             title: _t.append("issues.fix.delete_feature.title"),
45345             entityIds: [singleEntity.id],
45346             onClick: function(context2) {
45347               var id2 = this.issue.entityIds[0];
45348               var operation2 = operationDelete(context2, [id2]);
45349               if (!operation2.disabled()) {
45350                 operation2();
45351               }
45352             }
45353           }));
45354         } else {
45355           fixes.push(new validationIssueFix({
45356             title: _t.append("issues.fix.connect_features.title")
45357           }));
45358         }
45359         return fixes;
45360       }
45361       function showReference(selection2) {
45362         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.disconnected_way.routable.reference"));
45363       }
45364       function routingIslandForEntity(entity2) {
45365         var routingIsland = /* @__PURE__ */ new Set();
45366         var waysToCheck = [];
45367         function queueParentWays(node) {
45368           graph.parentWays(node).forEach(function(parentWay) {
45369             if (!routingIsland.has(parentWay) && // only check each feature once
45370             isRoutableWay(parentWay, false)) {
45371               routingIsland.add(parentWay);
45372               waysToCheck.push(parentWay);
45373             }
45374           });
45375         }
45376         if (entity2.type === "way" && isRoutableWay(entity2, true)) {
45377           routingIsland.add(entity2);
45378           waysToCheck.push(entity2);
45379         } else if (entity2.type === "node" && isRoutableNode(entity2)) {
45380           routingIsland.add(entity2);
45381           queueParentWays(entity2);
45382         } else {
45383           return null;
45384         }
45385         while (waysToCheck.length) {
45386           var wayToCheck = waysToCheck.pop();
45387           var childNodes = graph.childNodes(wayToCheck);
45388           for (var i3 in childNodes) {
45389             var vertex = childNodes[i3];
45390             if (isConnectedVertex(vertex)) {
45391               return null;
45392             }
45393             if (isRoutableNode(vertex)) {
45394               routingIsland.add(vertex);
45395             }
45396             queueParentWays(vertex);
45397           }
45398         }
45399         return routingIsland;
45400       }
45401       function isConnectedVertex(vertex) {
45402         var osm = services.osm;
45403         if (osm && !osm.isDataLoaded(vertex.loc))
45404           return true;
45405         if (vertex.tags.entrance && vertex.tags.entrance !== "no")
45406           return true;
45407         if (vertex.tags.amenity === "parking_entrance")
45408           return true;
45409         return false;
45410       }
45411       function isRoutableNode(node) {
45412         if (node.tags.highway === "elevator")
45413           return true;
45414         return false;
45415       }
45416       function isRoutableWay(way, ignoreInnerWays) {
45417         if (isTaggedAsHighway(way) || way.tags.route === "ferry")
45418           return true;
45419         return graph.parentRelations(way).some(function(parentRelation) {
45420           if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45421             return true;
45422           if (parentRelation.isMultipolygon() && isTaggedAsHighway(parentRelation) && (!ignoreInnerWays || parentRelation.memberById(way.id).role !== "inner"))
45423             return true;
45424           return false;
45425         });
45426       }
45427       function makeContinueDrawingFixIfAllowed(textDirection, vertexID, whichEnd) {
45428         var vertex = graph.hasEntity(vertexID);
45429         if (!vertex || vertex.tags.noexit === "yes")
45430           return null;
45431         var useLeftContinue = whichEnd === "start" && textDirection === "ltr" || whichEnd === "end" && textDirection === "rtl";
45432         return new validationIssueFix({
45433           icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45434           title: _t.append("issues.fix.continue_from_" + whichEnd + ".title"),
45435           entityIds: [vertexID],
45436           onClick: function(context) {
45437             var wayId = this.issue.entityIds[0];
45438             var way = context.hasEntity(wayId);
45439             var vertexId = this.entityIds[0];
45440             var vertex2 = context.hasEntity(vertexId);
45441             if (!way || !vertex2)
45442               return;
45443             var map2 = context.map();
45444             if (!context.editable() || !map2.trimmedExtent().contains(vertex2.loc)) {
45445               map2.zoomToEase(vertex2);
45446             }
45447             context.enter(
45448               modeDrawLine(context, wayId, context.graph(), "line", way.affix(vertexId), true)
45449             );
45450           }
45451         });
45452       }
45453     };
45454     validation.type = type2;
45455     return validation;
45456   }
45457
45458   // modules/validations/invalid_format.js
45459   function validationFormatting() {
45460     var type2 = "invalid_format";
45461     var validation = function(entity) {
45462       var issues = [];
45463       function isValidEmail(email) {
45464         var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
45465         return !email || valid_email.test(email);
45466       }
45467       function showReferenceEmail(selection2) {
45468         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.invalid_format.email.reference"));
45469       }
45470       if (entity.tags.email) {
45471         var emails = entity.tags.email.split(";").map(function(s2) {
45472           return s2.trim();
45473         }).filter(function(x2) {
45474           return !isValidEmail(x2);
45475         });
45476         if (emails.length) {
45477           issues.push(new validationIssue({
45478             type: type2,
45479             subtype: "email",
45480             severity: "warning",
45481             message: function(context) {
45482               var entity2 = context.hasEntity(this.entityIds[0]);
45483               return entity2 ? _t.append(
45484                 "issues.invalid_format.email.message" + this.data,
45485                 { feature: utilDisplayLabel(entity2, context.graph()), email: emails.join(", ") }
45486               ) : "";
45487             },
45488             reference: showReferenceEmail,
45489             entityIds: [entity.id],
45490             hash: emails.join(),
45491             data: emails.length > 1 ? "_multi" : ""
45492           }));
45493         }
45494       }
45495       return issues;
45496     };
45497     validation.type = type2;
45498     return validation;
45499   }
45500
45501   // modules/validations/help_request.js
45502   function validationHelpRequest(context) {
45503     var type2 = "help_request";
45504     var validation = function checkFixmeTag(entity) {
45505       if (!entity.tags.fixme)
45506         return [];
45507       if (entity.version === void 0)
45508         return [];
45509       if (entity.v !== void 0) {
45510         var baseEntity = context.history().base().hasEntity(entity.id);
45511         if (!baseEntity || !baseEntity.tags.fixme)
45512           return [];
45513       }
45514       return [new validationIssue({
45515         type: type2,
45516         subtype: "fixme_tag",
45517         severity: "warning",
45518         message: function(context2) {
45519           var entity2 = context2.hasEntity(this.entityIds[0]);
45520           return entity2 ? _t.append("issues.fixme_tag.message", {
45521             feature: utilDisplayLabel(
45522               entity2,
45523               context2.graph(),
45524               true
45525               /* verbose */
45526             )
45527           }) : "";
45528         },
45529         dynamicFixes: function() {
45530           return [
45531             new validationIssueFix({
45532               title: _t.append("issues.fix.address_the_concern.title")
45533             })
45534           ];
45535         },
45536         reference: showReference,
45537         entityIds: [entity.id]
45538       })];
45539       function showReference(selection2) {
45540         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.fixme_tag.reference"));
45541       }
45542     };
45543     validation.type = type2;
45544     return validation;
45545   }
45546
45547   // modules/validations/impossible_oneway.js
45548   function validationImpossibleOneway() {
45549     var type2 = "impossible_oneway";
45550     var validation = function checkImpossibleOneway(entity, graph) {
45551       if (entity.type !== "way" || entity.geometry(graph) !== "line")
45552         return [];
45553       if (entity.isClosed())
45554         return [];
45555       if (!typeForWay(entity))
45556         return [];
45557       if (!isOneway(entity))
45558         return [];
45559       var firstIssues = issuesForNode(entity, entity.first());
45560       var lastIssues = issuesForNode(entity, entity.last());
45561       return firstIssues.concat(lastIssues);
45562       function typeForWay(way) {
45563         if (way.geometry(graph) !== "line")
45564           return null;
45565         if (osmRoutableHighwayTagValues[way.tags.highway])
45566           return "highway";
45567         if (osmFlowingWaterwayTagValues[way.tags.waterway])
45568           return "waterway";
45569         return null;
45570       }
45571       function isOneway(way) {
45572         if (way.tags.oneway === "yes")
45573           return true;
45574         if (way.tags.oneway)
45575           return false;
45576         for (var key in way.tags) {
45577           if (osmOneWayTags[key] && osmOneWayTags[key][way.tags[key]]) {
45578             return true;
45579           }
45580         }
45581         return false;
45582       }
45583       function nodeOccursMoreThanOnce(way, nodeID) {
45584         var occurrences = 0;
45585         for (var index in way.nodes) {
45586           if (way.nodes[index] === nodeID) {
45587             occurrences += 1;
45588             if (occurrences > 1)
45589               return true;
45590           }
45591         }
45592         return false;
45593       }
45594       function isConnectedViaOtherTypes(way, node) {
45595         var wayType = typeForWay(way);
45596         if (wayType === "highway") {
45597           if (node.tags.entrance && node.tags.entrance !== "no")
45598             return true;
45599           if (node.tags.amenity === "parking_entrance")
45600             return true;
45601         } else if (wayType === "waterway") {
45602           if (node.id === way.first()) {
45603             if (node.tags.natural === "spring")
45604               return true;
45605           } else {
45606             if (node.tags.manhole === "drain")
45607               return true;
45608           }
45609         }
45610         return graph.parentWays(node).some(function(parentWay) {
45611           if (parentWay.id === way.id)
45612             return false;
45613           if (wayType === "highway") {
45614             if (parentWay.geometry(graph) === "area" && osmRoutableHighwayTagValues[parentWay.tags.highway])
45615               return true;
45616             if (parentWay.tags.route === "ferry")
45617               return true;
45618             return graph.parentRelations(parentWay).some(function(parentRelation) {
45619               if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45620                 return true;
45621               return parentRelation.isMultipolygon() && osmRoutableHighwayTagValues[parentRelation.tags.highway];
45622             });
45623           } else if (wayType === "waterway") {
45624             if (parentWay.tags.natural === "water" || parentWay.tags.natural === "coastline")
45625               return true;
45626           }
45627           return false;
45628         });
45629       }
45630       function issuesForNode(way, nodeID) {
45631         var isFirst = nodeID === way.first();
45632         var wayType = typeForWay(way);
45633         if (nodeOccursMoreThanOnce(way, nodeID))
45634           return [];
45635         var osm = services.osm;
45636         if (!osm)
45637           return [];
45638         var node = graph.hasEntity(nodeID);
45639         if (!node || !osm.isDataLoaded(node.loc))
45640           return [];
45641         if (isConnectedViaOtherTypes(way, node))
45642           return [];
45643         var attachedWaysOfSameType = graph.parentWays(node).filter(function(parentWay) {
45644           if (parentWay.id === way.id)
45645             return false;
45646           return typeForWay(parentWay) === wayType;
45647         });
45648         if (wayType === "waterway" && attachedWaysOfSameType.length === 0)
45649           return [];
45650         var attachedOneways = attachedWaysOfSameType.filter(function(attachedWay) {
45651           return isOneway(attachedWay);
45652         });
45653         if (attachedOneways.length < attachedWaysOfSameType.length)
45654           return [];
45655         if (attachedOneways.length) {
45656           var connectedEndpointsOkay = attachedOneways.some(function(attachedOneway) {
45657             if ((isFirst ? attachedOneway.first() : attachedOneway.last()) !== nodeID)
45658               return true;
45659             if (nodeOccursMoreThanOnce(attachedOneway, nodeID))
45660               return true;
45661             return false;
45662           });
45663           if (connectedEndpointsOkay)
45664             return [];
45665         }
45666         var placement = isFirst ? "start" : "end", messageID = wayType + ".", referenceID = wayType + ".";
45667         if (wayType === "waterway") {
45668           messageID += "connected." + placement;
45669           referenceID += "connected";
45670         } else {
45671           messageID += placement;
45672           referenceID += placement;
45673         }
45674         return [new validationIssue({
45675           type: type2,
45676           subtype: wayType,
45677           severity: "warning",
45678           message: function(context) {
45679             var entity2 = context.hasEntity(this.entityIds[0]);
45680             return entity2 ? _t.append("issues.impossible_oneway." + messageID + ".message", {
45681               feature: utilDisplayLabel(entity2, context.graph())
45682             }) : "";
45683           },
45684           reference: getReference(referenceID),
45685           entityIds: [way.id, node.id],
45686           dynamicFixes: function() {
45687             var fixes = [];
45688             if (attachedOneways.length) {
45689               fixes.push(new validationIssueFix({
45690                 icon: "iD-operation-reverse",
45691                 title: _t.append("issues.fix.reverse_feature.title"),
45692                 entityIds: [way.id],
45693                 onClick: function(context) {
45694                   var id2 = this.issue.entityIds[0];
45695                   context.perform(actionReverse(id2), _t("operations.reverse.annotation.line", { n: 1 }));
45696                 }
45697               }));
45698             }
45699             if (node.tags.noexit !== "yes") {
45700               var textDirection = _mainLocalizer.textDirection();
45701               var useLeftContinue = isFirst && textDirection === "ltr" || !isFirst && textDirection === "rtl";
45702               fixes.push(new validationIssueFix({
45703                 icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45704                 title: _t.append("issues.fix.continue_from_" + (isFirst ? "start" : "end") + ".title"),
45705                 onClick: function(context) {
45706                   var entityID = this.issue.entityIds[0];
45707                   var vertexID = this.issue.entityIds[1];
45708                   var way2 = context.entity(entityID);
45709                   var vertex = context.entity(vertexID);
45710                   continueDrawing(way2, vertex, context);
45711                 }
45712               }));
45713             }
45714             return fixes;
45715           },
45716           loc: node.loc
45717         })];
45718         function getReference(referenceID2) {
45719           return function showReference(selection2) {
45720             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.impossible_oneway." + referenceID2 + ".reference"));
45721           };
45722         }
45723       }
45724     };
45725     function continueDrawing(way, vertex, context) {
45726       var map2 = context.map();
45727       if (!context.editable() || !map2.trimmedExtent().contains(vertex.loc)) {
45728         map2.zoomToEase(vertex);
45729       }
45730       context.enter(
45731         modeDrawLine(context, way.id, context.graph(), "line", way.affix(vertex.id), true)
45732       );
45733     }
45734     validation.type = type2;
45735     return validation;
45736   }
45737
45738   // modules/validations/incompatible_source.js
45739   function validationIncompatibleSource() {
45740     const type2 = "incompatible_source";
45741     const incompatibleRules = [
45742       {
45743         id: "amap",
45744         regex: /(^amap$|^amap\.com|autonavi|mapabc|高德)/i
45745       },
45746       {
45747         id: "baidu",
45748         regex: /(baidu|mapbar|百度)/i
45749       },
45750       {
45751         id: "google",
45752         regex: /google/i,
45753         exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))|(esri\/Google_Africa_Buildings)/i
45754       }
45755     ];
45756     const validation = function checkIncompatibleSource(entity) {
45757       const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(";");
45758       if (!entitySources)
45759         return [];
45760       const entityID = entity.id;
45761       return entitySources.map((source) => {
45762         const matchRule = incompatibleRules.find((rule) => {
45763           if (!rule.regex.test(source))
45764             return false;
45765           if (rule.exceptRegex && rule.exceptRegex.test(source))
45766             return false;
45767           return true;
45768         });
45769         if (!matchRule)
45770           return null;
45771         return new validationIssue({
45772           type: type2,
45773           severity: "warning",
45774           message: (context) => {
45775             const entity2 = context.hasEntity(entityID);
45776             return entity2 ? _t.append("issues.incompatible_source.feature.message", {
45777               feature: utilDisplayLabel(
45778                 entity2,
45779                 context.graph(),
45780                 true
45781                 /* verbose */
45782               ),
45783               value: source
45784             }) : "";
45785           },
45786           reference: getReference(matchRule.id),
45787           entityIds: [entityID],
45788           hash: source,
45789           dynamicFixes: () => {
45790             return [
45791               new validationIssueFix({ title: _t.append("issues.fix.remove_proprietary_data.title") })
45792             ];
45793           }
45794         });
45795       }).filter(Boolean);
45796       function getReference(id2) {
45797         return function showReference(selection2) {
45798           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2)));
45799         };
45800       }
45801     };
45802     validation.type = type2;
45803     return validation;
45804   }
45805
45806   // modules/validations/maprules.js
45807   function validationMaprules() {
45808     var type2 = "maprules";
45809     var validation = function checkMaprules(entity, graph) {
45810       if (!services.maprules)
45811         return [];
45812       var rules = services.maprules.validationRules();
45813       var issues = [];
45814       for (var i3 = 0; i3 < rules.length; i3++) {
45815         var rule = rules[i3];
45816         rule.findIssues(entity, graph, issues);
45817       }
45818       return issues;
45819     };
45820     validation.type = type2;
45821     return validation;
45822   }
45823
45824   // modules/validations/mismatched_geometry.js
45825   var import_fast_deep_equal4 = __toESM(require_fast_deep_equal());
45826   function validationMismatchedGeometry() {
45827     var type2 = "mismatched_geometry";
45828     function tagSuggestingLineIsArea(entity) {
45829       if (entity.type !== "way" || entity.isClosed())
45830         return null;
45831       var tagSuggestingArea = entity.tagSuggestingArea();
45832       if (!tagSuggestingArea) {
45833         return null;
45834       }
45835       var asLine = _mainPresetIndex.matchTags(tagSuggestingArea, "line");
45836       var asArea = _mainPresetIndex.matchTags(tagSuggestingArea, "area");
45837       if (asLine && asArea && (0, import_fast_deep_equal4.default)(asLine.tags, asArea.tags)) {
45838         return null;
45839       }
45840       return tagSuggestingArea;
45841     }
45842     function makeConnectEndpointsFixOnClick(way, graph) {
45843       if (way.nodes.length < 3)
45844         return null;
45845       var nodes = graph.childNodes(way), testNodes;
45846       var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length - 1].loc);
45847       if (firstToLastDistanceMeters < 0.75) {
45848         testNodes = nodes.slice();
45849         testNodes.pop();
45850         testNodes.push(testNodes[0]);
45851         if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45852           return function(context) {
45853             var way2 = context.entity(this.issue.entityIds[0]);
45854             context.perform(
45855               actionMergeNodes([way2.nodes[0], way2.nodes[way2.nodes.length - 1]], nodes[0].loc),
45856               _t("issues.fix.connect_endpoints.annotation")
45857             );
45858           };
45859         }
45860       }
45861       testNodes = nodes.slice();
45862       testNodes.push(testNodes[0]);
45863       if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45864         return function(context) {
45865           var wayId = this.issue.entityIds[0];
45866           var way2 = context.entity(wayId);
45867           var nodeId = way2.nodes[0];
45868           var index = way2.nodes.length;
45869           context.perform(
45870             actionAddVertex(wayId, nodeId, index),
45871             _t("issues.fix.connect_endpoints.annotation")
45872           );
45873         };
45874       }
45875     }
45876     function lineTaggedAsAreaIssue(entity) {
45877       var tagSuggestingArea = tagSuggestingLineIsArea(entity);
45878       if (!tagSuggestingArea)
45879         return null;
45880       var validAsLine = false;
45881       var presetAsLine = _mainPresetIndex.matchTags(entity.tags, "line");
45882       if (presetAsLine) {
45883         validAsLine = true;
45884         var key = Object.keys(tagSuggestingArea)[0];
45885         if (presetAsLine.tags[key] && presetAsLine.tags[key] === "*") {
45886           validAsLine = false;
45887         }
45888         if (Object.keys(presetAsLine.tags).length === 0) {
45889           validAsLine = false;
45890         }
45891       }
45892       return new validationIssue({
45893         type: type2,
45894         subtype: "area_as_line",
45895         severity: "warning",
45896         message: function(context) {
45897           var entity2 = context.hasEntity(this.entityIds[0]);
45898           return entity2 ? _t.append("issues.tag_suggests_area.message", {
45899             feature: utilDisplayLabel(
45900               entity2,
45901               "area",
45902               true
45903               /* verbose */
45904             ),
45905             tag: utilTagText({ tags: tagSuggestingArea })
45906           }) : "";
45907         },
45908         reference: showReference,
45909         entityIds: [entity.id],
45910         hash: JSON.stringify(tagSuggestingArea),
45911         dynamicFixes: function(context) {
45912           var fixes = [];
45913           var entity2 = context.entity(this.entityIds[0]);
45914           var connectEndsOnClick = makeConnectEndpointsFixOnClick(entity2, context.graph());
45915           if (!validAsLine) {
45916             fixes.push(new validationIssueFix({
45917               title: _t.append("issues.fix.connect_endpoints.title"),
45918               onClick: connectEndsOnClick
45919             }));
45920           }
45921           fixes.push(new validationIssueFix({
45922             icon: "iD-operation-delete",
45923             title: _t.append("issues.fix.remove_tag.title"),
45924             onClick: function(context2) {
45925               var entityId = this.issue.entityIds[0];
45926               var entity3 = context2.entity(entityId);
45927               var tags = Object.assign({}, entity3.tags);
45928               for (var key2 in tagSuggestingArea) {
45929                 delete tags[key2];
45930               }
45931               context2.perform(
45932                 actionChangeTags(entityId, tags),
45933                 _t("issues.fix.remove_tag.annotation")
45934               );
45935             }
45936           }));
45937           return fixes;
45938         }
45939       });
45940       function showReference(selection2) {
45941         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.tag_suggests_area.reference"));
45942       }
45943     }
45944     function vertexPointIssue(entity, graph) {
45945       if (entity.type !== "node")
45946         return null;
45947       if (Object.keys(entity.tags).length === 0)
45948         return null;
45949       if (entity.isOnAddressLine(graph))
45950         return null;
45951       var geometry = entity.geometry(graph);
45952       var allowedGeometries = osmNodeGeometriesForTags(entity.tags);
45953       if (geometry === "point" && !allowedGeometries.point && allowedGeometries.vertex) {
45954         return new validationIssue({
45955           type: type2,
45956           subtype: "vertex_as_point",
45957           severity: "warning",
45958           message: function(context) {
45959             var entity2 = context.hasEntity(this.entityIds[0]);
45960             return entity2 ? _t.append("issues.vertex_as_point.message", {
45961               feature: utilDisplayLabel(
45962                 entity2,
45963                 "vertex",
45964                 true
45965                 /* verbose */
45966               )
45967             }) : "";
45968           },
45969           reference: function showReference(selection2) {
45970             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.vertex_as_point.reference"));
45971           },
45972           entityIds: [entity.id]
45973         });
45974       } else if (geometry === "vertex" && !allowedGeometries.vertex && allowedGeometries.point) {
45975         return new validationIssue({
45976           type: type2,
45977           subtype: "point_as_vertex",
45978           severity: "warning",
45979           message: function(context) {
45980             var entity2 = context.hasEntity(this.entityIds[0]);
45981             return entity2 ? _t.append("issues.point_as_vertex.message", {
45982               feature: utilDisplayLabel(
45983                 entity2,
45984                 "point",
45985                 true
45986                 /* verbose */
45987               )
45988             }) : "";
45989           },
45990           reference: function showReference(selection2) {
45991             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.point_as_vertex.reference"));
45992           },
45993           entityIds: [entity.id],
45994           dynamicFixes: extractPointDynamicFixes
45995         });
45996       }
45997       return null;
45998     }
45999     function otherMismatchIssue(entity, graph) {
46000       if (!entity.hasInterestingTags())
46001         return null;
46002       if (entity.type !== "node" && entity.type !== "way")
46003         return null;
46004       if (entity.type === "node" && entity.isOnAddressLine(graph))
46005         return null;
46006       var sourceGeom = entity.geometry(graph);
46007       var targetGeoms = entity.type === "way" ? ["point", "vertex"] : ["line", "area"];
46008       if (sourceGeom === "area")
46009         targetGeoms.unshift("line");
46010       var asSource = _mainPresetIndex.match(entity, graph);
46011       var targetGeom = targetGeoms.find((nodeGeom) => {
46012         var asTarget = _mainPresetIndex.matchTags(entity.tags, nodeGeom);
46013         if (!asSource || !asTarget || asSource === asTarget || // sometimes there are two presets with the same tags for different geometries
46014         (0, import_fast_deep_equal4.default)(asSource.tags, asTarget.tags))
46015           return false;
46016         if (asTarget.isFallback())
46017           return false;
46018         var primaryKey = Object.keys(asTarget.tags)[0];
46019         if (primaryKey === "building")
46020           return false;
46021         if (asTarget.tags[primaryKey] === "*")
46022           return false;
46023         return asSource.isFallback() || asSource.tags[primaryKey] === "*";
46024       });
46025       if (!targetGeom)
46026         return null;
46027       var subtype = targetGeom + "_as_" + sourceGeom;
46028       if (targetGeom === "vertex")
46029         targetGeom = "point";
46030       if (sourceGeom === "vertex")
46031         sourceGeom = "point";
46032       var referenceId = targetGeom + "_as_" + sourceGeom;
46033       var dynamicFixes;
46034       if (targetGeom === "point") {
46035         dynamicFixes = extractPointDynamicFixes;
46036       } else if (sourceGeom === "area" && targetGeom === "line") {
46037         dynamicFixes = lineToAreaDynamicFixes;
46038       }
46039       return new validationIssue({
46040         type: type2,
46041         subtype,
46042         severity: "warning",
46043         message: function(context) {
46044           var entity2 = context.hasEntity(this.entityIds[0]);
46045           return entity2 ? _t.append("issues." + referenceId + ".message", {
46046             feature: utilDisplayLabel(
46047               entity2,
46048               targetGeom,
46049               true
46050               /* verbose */
46051             )
46052           }) : "";
46053         },
46054         reference: function showReference(selection2) {
46055           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.mismatched_geometry.reference"));
46056         },
46057         entityIds: [entity.id],
46058         dynamicFixes
46059       });
46060     }
46061     function lineToAreaDynamicFixes(context) {
46062       var convertOnClick;
46063       var entityId = this.entityIds[0];
46064       var entity = context.entity(entityId);
46065       var tags = Object.assign({}, entity.tags);
46066       delete tags.area;
46067       if (!osmTagSuggestingArea(tags)) {
46068         convertOnClick = function(context2) {
46069           var entityId2 = this.issue.entityIds[0];
46070           var entity2 = context2.entity(entityId2);
46071           var tags2 = Object.assign({}, entity2.tags);
46072           if (tags2.area) {
46073             delete tags2.area;
46074           }
46075           context2.perform(
46076             actionChangeTags(entityId2, tags2),
46077             _t("issues.fix.convert_to_line.annotation")
46078           );
46079         };
46080       }
46081       return [
46082         new validationIssueFix({
46083           icon: "iD-icon-line",
46084           title: _t.append("issues.fix.convert_to_line.title"),
46085           onClick: convertOnClick
46086         })
46087       ];
46088     }
46089     function extractPointDynamicFixes(context) {
46090       var entityId = this.entityIds[0];
46091       var extractOnClick = null;
46092       if (!context.hasHiddenConnections(entityId)) {
46093         extractOnClick = function(context2) {
46094           var entityId2 = this.issue.entityIds[0];
46095           var action = actionExtract(entityId2, context2.projection);
46096           context2.perform(
46097             action,
46098             _t("operations.extract.annotation", { n: 1 })
46099           );
46100           context2.enter(modeSelect(context2, [action.getExtractedNodeID()]));
46101         };
46102       }
46103       return [
46104         new validationIssueFix({
46105           icon: "iD-operation-extract",
46106           title: _t.append("issues.fix.extract_point.title"),
46107           onClick: extractOnClick
46108         })
46109       ];
46110     }
46111     function unclosedMultipolygonPartIssues(entity, graph) {
46112       if (entity.type !== "relation" || !entity.isMultipolygon() || entity.isDegenerate() || // cannot determine issues for incompletely-downloaded relations
46113       !entity.isComplete(graph))
46114         return [];
46115       var sequences = osmJoinWays(entity.members, graph);
46116       var issues = [];
46117       for (var i3 in sequences) {
46118         var sequence = sequences[i3];
46119         if (!sequence.nodes)
46120           continue;
46121         var firstNode = sequence.nodes[0];
46122         var lastNode = sequence.nodes[sequence.nodes.length - 1];
46123         if (firstNode === lastNode)
46124           continue;
46125         var issue = new validationIssue({
46126           type: type2,
46127           subtype: "unclosed_multipolygon_part",
46128           severity: "warning",
46129           message: function(context) {
46130             var entity2 = context.hasEntity(this.entityIds[0]);
46131             return entity2 ? _t.append("issues.unclosed_multipolygon_part.message", {
46132               feature: utilDisplayLabel(
46133                 entity2,
46134                 context.graph(),
46135                 true
46136                 /* verbose */
46137               )
46138             }) : "";
46139           },
46140           reference: showReference,
46141           loc: sequence.nodes[0].loc,
46142           entityIds: [entity.id],
46143           hash: sequence.map(function(way) {
46144             return way.id;
46145           }).join()
46146         });
46147         issues.push(issue);
46148       }
46149       return issues;
46150       function showReference(selection2) {
46151         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unclosed_multipolygon_part.reference"));
46152       }
46153     }
46154     var validation = function checkMismatchedGeometry(entity, graph) {
46155       var vertexPoint = vertexPointIssue(entity, graph);
46156       if (vertexPoint)
46157         return [vertexPoint];
46158       var lineAsArea = lineTaggedAsAreaIssue(entity);
46159       if (lineAsArea)
46160         return [lineAsArea];
46161       var mismatch = otherMismatchIssue(entity, graph);
46162       if (mismatch)
46163         return [mismatch];
46164       return unclosedMultipolygonPartIssues(entity, graph);
46165     };
46166     validation.type = type2;
46167     return validation;
46168   }
46169
46170   // modules/validations/missing_role.js
46171   function validationMissingRole() {
46172     var type2 = "missing_role";
46173     var validation = function checkMissingRole(entity, graph) {
46174       var issues = [];
46175       if (entity.type === "way") {
46176         graph.parentRelations(entity).forEach(function(relation) {
46177           if (!relation.isMultipolygon())
46178             return;
46179           var member = relation.memberById(entity.id);
46180           if (member && isMissingRole(member)) {
46181             issues.push(makeIssue(entity, relation, member));
46182           }
46183         });
46184       } else if (entity.type === "relation" && entity.isMultipolygon()) {
46185         entity.indexedMembers().forEach(function(member) {
46186           var way = graph.hasEntity(member.id);
46187           if (way && isMissingRole(member)) {
46188             issues.push(makeIssue(way, entity, member));
46189           }
46190         });
46191       }
46192       return issues;
46193     };
46194     function isMissingRole(member) {
46195       return !member.role || !member.role.trim().length;
46196     }
46197     function makeIssue(way, relation, member) {
46198       return new validationIssue({
46199         type: type2,
46200         severity: "warning",
46201         message: function(context) {
46202           var member2 = context.hasEntity(this.entityIds[1]), relation2 = context.hasEntity(this.entityIds[0]);
46203           return member2 && relation2 ? _t.append("issues.missing_role.message", {
46204             member: utilDisplayLabel(member2, context.graph()),
46205             relation: utilDisplayLabel(relation2, context.graph())
46206           }) : "";
46207         },
46208         reference: showReference,
46209         entityIds: [relation.id, way.id],
46210         data: {
46211           member
46212         },
46213         hash: member.index.toString(),
46214         dynamicFixes: function() {
46215           return [
46216             makeAddRoleFix("inner"),
46217             makeAddRoleFix("outer"),
46218             new validationIssueFix({
46219               icon: "iD-operation-delete",
46220               title: _t.append("issues.fix.remove_from_relation.title"),
46221               onClick: function(context) {
46222                 context.perform(
46223                   actionDeleteMember(this.issue.entityIds[0], this.issue.data.member.index),
46224                   _t("operations.delete_member.annotation", {
46225                     n: 1
46226                   })
46227                 );
46228               }
46229             })
46230           ];
46231         }
46232       });
46233       function showReference(selection2) {
46234         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.missing_role.multipolygon.reference"));
46235       }
46236     }
46237     function makeAddRoleFix(role) {
46238       return new validationIssueFix({
46239         title: _t.append("issues.fix.set_as_" + role + ".title"),
46240         onClick: function(context) {
46241           var oldMember = this.issue.data.member;
46242           var member = { id: this.issue.entityIds[1], type: oldMember.type, role };
46243           context.perform(
46244             actionChangeMember(this.issue.entityIds[0], member, oldMember.index),
46245             _t("operations.change_role.annotation", {
46246               n: 1
46247             })
46248           );
46249         }
46250       });
46251     }
46252     validation.type = type2;
46253     return validation;
46254   }
46255
46256   // modules/validations/missing_tag.js
46257   function validationMissingTag(context) {
46258     var type2 = "missing_tag";
46259     function hasDescriptiveTags(entity, graph) {
46260       var onlyAttributeKeys = ["description", "name", "note", "start_date"];
46261       var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) {
46262         if (k2 === "area" || !osmIsInterestingTag(k2))
46263           return false;
46264         return !onlyAttributeKeys.some(function(attributeKey) {
46265           return k2 === attributeKey || k2.indexOf(attributeKey + ":") === 0;
46266         });
46267       });
46268       if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") {
46269         return osmOldMultipolygonOuterMemberOfRelation(entity, graph);
46270       }
46271       return entityDescriptiveKeys.length > 0;
46272     }
46273     function isUnknownRoad(entity) {
46274       return entity.type === "way" && entity.tags.highway === "road";
46275     }
46276     function isUntypedRelation(entity) {
46277       return entity.type === "relation" && !entity.tags.type;
46278     }
46279     var validation = function checkMissingTag(entity, graph) {
46280       var subtype;
46281       var osm = context.connection();
46282       var isUnloadedNode = entity.type === "node" && osm && !osm.isDataLoaded(entity.loc);
46283       if (!isUnloadedNode && // allow untagged nodes that are part of ways
46284       entity.geometry(graph) !== "vertex" && // allow untagged entities that are part of relations
46285       !entity.hasParentRelations(graph)) {
46286         if (Object.keys(entity.tags).length === 0) {
46287           subtype = "any";
46288         } else if (!hasDescriptiveTags(entity, graph)) {
46289           subtype = "descriptive";
46290         } else if (isUntypedRelation(entity)) {
46291           subtype = "relation_type";
46292         }
46293       }
46294       if (!subtype && isUnknownRoad(entity)) {
46295         subtype = "highway_classification";
46296       }
46297       if (!subtype)
46298         return [];
46299       var messageID = subtype === "highway_classification" ? "unknown_road" : "missing_tag." + subtype;
46300       var referenceID = subtype === "highway_classification" ? "unknown_road" : "missing_tag";
46301       var canDelete = entity.version === void 0 || entity.v !== void 0;
46302       var severity = canDelete && subtype !== "highway_classification" ? "error" : "warning";
46303       return [new validationIssue({
46304         type: type2,
46305         subtype,
46306         severity,
46307         message: function(context2) {
46308           var entity2 = context2.hasEntity(this.entityIds[0]);
46309           return entity2 ? _t.append("issues." + messageID + ".message", {
46310             feature: utilDisplayLabel(entity2, context2.graph())
46311           }) : "";
46312         },
46313         reference: showReference,
46314         entityIds: [entity.id],
46315         dynamicFixes: function(context2) {
46316           var fixes = [];
46317           var selectFixType = subtype === "highway_classification" ? "select_road_type" : "select_preset";
46318           fixes.push(new validationIssueFix({
46319             icon: "iD-icon-search",
46320             title: _t.append("issues.fix." + selectFixType + ".title"),
46321             onClick: function(context3) {
46322               context3.ui().sidebar.showPresetList();
46323             }
46324           }));
46325           var deleteOnClick;
46326           var id2 = this.entityIds[0];
46327           var operation2 = operationDelete(context2, [id2]);
46328           var disabledReasonID = operation2.disabled();
46329           if (!disabledReasonID) {
46330             deleteOnClick = function(context3) {
46331               var id3 = this.issue.entityIds[0];
46332               var operation3 = operationDelete(context3, [id3]);
46333               if (!operation3.disabled()) {
46334                 operation3();
46335               }
46336             };
46337           }
46338           fixes.push(
46339             new validationIssueFix({
46340               icon: "iD-operation-delete",
46341               title: _t.append("issues.fix.delete_feature.title"),
46342               disabledReason: disabledReasonID ? _t("operations.delete." + disabledReasonID + ".single") : void 0,
46343               onClick: deleteOnClick
46344             })
46345           );
46346           return fixes;
46347         }
46348       })];
46349       function showReference(selection2) {
46350         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues." + referenceID + ".reference"));
46351       }
46352     };
46353     validation.type = type2;
46354     return validation;
46355   }
46356
46357   // modules/validations/mutually_exclusive_tags.js
46358   function validationMutuallyExclusiveTags() {
46359     const type2 = "mutually_exclusive_tags";
46360     const tagKeyPairs = osmMutuallyExclusiveTagPairs;
46361     const validation = function checkMutuallyExclusiveTags(entity) {
46362       let pairsFounds = tagKeyPairs.filter((pair3) => {
46363         return pair3[0] in entity.tags && pair3[1] in entity.tags;
46364       }).filter((pair3) => {
46365         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");
46366       });
46367       Object.keys(entity.tags).forEach((key) => {
46368         let negative_key = "not:" + key;
46369         if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46370           pairsFounds.push([negative_key, key, "same_value"]);
46371         }
46372         if (key.match(/^name:[a-z]+/)) {
46373           negative_key = "not:name";
46374           if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46375             pairsFounds.push([negative_key, key, "same_value"]);
46376           }
46377         }
46378       });
46379       let issues = pairsFounds.map((pair3) => {
46380         const subtype = pair3[2] || "default";
46381         return new validationIssue({
46382           type: type2,
46383           subtype,
46384           severity: "warning",
46385           message: function(context) {
46386             let entity2 = context.hasEntity(this.entityIds[0]);
46387             return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), {
46388               feature: utilDisplayLabel(entity2, context.graph()),
46389               tag1: pair3[0],
46390               tag2: pair3[1]
46391             }) : "";
46392           },
46393           reference: (selection2) => showReference(selection2, pair3, subtype),
46394           entityIds: [entity.id],
46395           dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove))
46396         });
46397       });
46398       function createIssueFix(tagToRemove) {
46399         return new validationIssueFix({
46400           icon: "iD-operation-delete",
46401           title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }),
46402           onClick: function(context) {
46403             const entityId = this.issue.entityIds[0];
46404             const entity2 = context.entity(entityId);
46405             let tags = Object.assign({}, entity2.tags);
46406             delete tags[tagToRemove];
46407             context.perform(
46408               actionChangeTags(entityId, tags),
46409               _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove })
46410             );
46411           }
46412         });
46413       }
46414       function showReference(selection2, pair3, subtype) {
46415         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] }));
46416       }
46417       return issues;
46418     };
46419     validation.type = type2;
46420     return validation;
46421   }
46422
46423   // modules/validations/outdated_tags.js
46424   function validationOutdatedTags() {
46425     const type2 = "outdated_tags";
46426     let _waitingForDeprecated = true;
46427     let _dataDeprecated;
46428     _mainFileFetcher.get("deprecated").then((d2) => _dataDeprecated = d2).catch(() => {
46429     }).finally(() => _waitingForDeprecated = false);
46430     function oldTagIssues(entity, graph) {
46431       if (!entity.hasInterestingTags())
46432         return [];
46433       let preset = _mainPresetIndex.match(entity, graph);
46434       if (!preset)
46435         return [];
46436       const oldTags = Object.assign({}, entity.tags);
46437       let subtype = "deprecated_tags";
46438       if (preset.replacement) {
46439         const newPreset = _mainPresetIndex.item(preset.replacement);
46440         graph = actionChangePreset(
46441           entity.id,
46442           preset,
46443           newPreset,
46444           true
46445           /* skip field defaults */
46446         )(graph);
46447         entity = graph.entity(entity.id);
46448         preset = newPreset;
46449       }
46450       if (_dataDeprecated) {
46451         const deprecatedTags = entity.deprecatedTags(_dataDeprecated);
46452         if (deprecatedTags.length) {
46453           deprecatedTags.forEach((tag2) => {
46454             graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph);
46455           });
46456           entity = graph.entity(entity.id);
46457         }
46458       }
46459       let newTags = Object.assign({}, entity.tags);
46460       if (preset.tags !== preset.addTags) {
46461         Object.keys(preset.addTags).forEach((k2) => {
46462           if (!newTags[k2]) {
46463             if (preset.addTags[k2] === "*") {
46464               newTags[k2] = "yes";
46465             } else {
46466               newTags[k2] = preset.addTags[k2];
46467             }
46468           }
46469         });
46470       }
46471       const nsi = services.nsi;
46472       let waitingForNsi = false;
46473       let nsiResult;
46474       if (nsi) {
46475         waitingForNsi = nsi.status() === "loading";
46476         if (!waitingForNsi) {
46477           const loc = entity.extent(graph).center();
46478           nsiResult = nsi.upgradeTags(newTags, loc);
46479           if (nsiResult) {
46480             newTags = nsiResult.newTags;
46481             subtype = "noncanonical_brand";
46482           }
46483         }
46484       }
46485       let issues = [];
46486       issues.provisional = _waitingForDeprecated || waitingForNsi;
46487       const tagDiff = utilTagDiff(oldTags, newTags);
46488       if (!tagDiff.length)
46489         return issues;
46490       const isOnlyAddingTags = tagDiff.every((d2) => d2.type === "+");
46491       let prefix = "";
46492       if (nsiResult) {
46493         prefix = "noncanonical_brand.";
46494       } else if (subtype === "deprecated_tags" && isOnlyAddingTags) {
46495         subtype = "incomplete_tags";
46496         prefix = "incomplete.";
46497       }
46498       let autoArgs = subtype !== "noncanonical_brand" ? [doUpgrade, _t("issues.fix.upgrade_tags.annotation")] : null;
46499       issues.push(new validationIssue({
46500         type: type2,
46501         subtype,
46502         severity: "warning",
46503         message: showMessage,
46504         reference: showReference,
46505         entityIds: [entity.id],
46506         hash: utilHashcode(JSON.stringify(tagDiff)),
46507         dynamicFixes: () => {
46508           let fixes = [
46509             new validationIssueFix({
46510               autoArgs,
46511               title: _t.append("issues.fix.upgrade_tags.title"),
46512               onClick: (context) => {
46513                 context.perform(doUpgrade, _t("issues.fix.upgrade_tags.annotation"));
46514               }
46515             })
46516           ];
46517           const item = nsiResult && nsiResult.matched;
46518           if (item) {
46519             fixes.push(
46520               new validationIssueFix({
46521                 title: _t.append("issues.fix.tag_as_not.title", { name: item.displayName }),
46522                 onClick: (context) => {
46523                   context.perform(addNotTag, _t("issues.fix.tag_as_not.annotation"));
46524                 }
46525               })
46526             );
46527           }
46528           return fixes;
46529         }
46530       }));
46531       return issues;
46532       function doUpgrade(graph2) {
46533         const currEntity = graph2.hasEntity(entity.id);
46534         if (!currEntity)
46535           return graph2;
46536         let newTags2 = Object.assign({}, currEntity.tags);
46537         tagDiff.forEach((diff) => {
46538           if (diff.type === "-") {
46539             delete newTags2[diff.key];
46540           } else if (diff.type === "+") {
46541             newTags2[diff.key] = diff.newVal;
46542           }
46543         });
46544         return actionChangeTags(currEntity.id, newTags2)(graph2);
46545       }
46546       function addNotTag(graph2) {
46547         const currEntity = graph2.hasEntity(entity.id);
46548         if (!currEntity)
46549           return graph2;
46550         const item = nsiResult && nsiResult.matched;
46551         if (!item)
46552           return graph2;
46553         let newTags2 = Object.assign({}, currEntity.tags);
46554         const wd = item.mainTag;
46555         const notwd = "not:".concat(wd);
46556         const qid = item.tags[wd];
46557         newTags2[notwd] = qid;
46558         if (newTags2[wd] === qid) {
46559           const wp = item.mainTag.replace("wikidata", "wikipedia");
46560           delete newTags2[wd];
46561           delete newTags2[wp];
46562         }
46563         return actionChangeTags(currEntity.id, newTags2)(graph2);
46564       }
46565       function showMessage(context) {
46566         const currEntity = context.hasEntity(entity.id);
46567         if (!currEntity)
46568           return "";
46569         let messageID = "issues.outdated_tags.".concat(prefix, "message");
46570         if (subtype === "noncanonical_brand" && isOnlyAddingTags) {
46571           messageID += "_incomplete";
46572         }
46573         return _t.append(messageID, {
46574           feature: utilDisplayLabel(
46575             currEntity,
46576             context.graph(),
46577             true
46578             /* verbose */
46579           )
46580         });
46581       }
46582       function showReference(selection2) {
46583         let enter = selection2.selectAll(".issue-reference").data([0]).enter();
46584         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.outdated_tags.".concat(prefix, "reference")));
46585         enter.append("strong").call(_t.append("issues.suggested"));
46586         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => {
46587           let klass = d2.type === "+" ? "add" : "remove";
46588           return "tagDiff-cell tagDiff-cell-".concat(klass);
46589         }).html((d2) => d2.display);
46590       }
46591     }
46592     function oldMultipolygonIssues(entity, graph) {
46593       let multipolygon, outerWay;
46594       if (entity.type === "relation") {
46595         outerWay = osmOldMultipolygonOuterMemberOfRelation(entity, graph);
46596         multipolygon = entity;
46597       } else if (entity.type === "way") {
46598         multipolygon = osmIsOldMultipolygonOuterMember(entity, graph);
46599         outerWay = entity;
46600       } else {
46601         return [];
46602       }
46603       if (!multipolygon || !outerWay)
46604         return [];
46605       return [new validationIssue({
46606         type: type2,
46607         subtype: "old_multipolygon",
46608         severity: "warning",
46609         message: showMessage,
46610         reference: showReference,
46611         entityIds: [outerWay.id, multipolygon.id],
46612         dynamicFixes: () => {
46613           return [
46614             new validationIssueFix({
46615               autoArgs: [doUpgrade, _t("issues.fix.move_tags.annotation")],
46616               title: _t.append("issues.fix.move_tags.title"),
46617               onClick: (context) => {
46618                 context.perform(doUpgrade, _t("issues.fix.move_tags.annotation"));
46619               }
46620             })
46621           ];
46622         }
46623       })];
46624       function doUpgrade(graph2) {
46625         let currMultipolygon = graph2.hasEntity(multipolygon.id);
46626         let currOuterWay = graph2.hasEntity(outerWay.id);
46627         if (!currMultipolygon || !currOuterWay)
46628           return graph2;
46629         currMultipolygon = currMultipolygon.mergeTags(currOuterWay.tags);
46630         graph2 = graph2.replace(currMultipolygon);
46631         return actionChangeTags(currOuterWay.id, {})(graph2);
46632       }
46633       function showMessage(context) {
46634         let currMultipolygon = context.hasEntity(multipolygon.id);
46635         if (!currMultipolygon)
46636           return "";
46637         return _t.append(
46638           "issues.old_multipolygon.message",
46639           { multipolygon: utilDisplayLabel(
46640             currMultipolygon,
46641             context.graph(),
46642             true
46643             /* verbose */
46644           ) }
46645         );
46646       }
46647       function showReference(selection2) {
46648         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.old_multipolygon.reference"));
46649       }
46650     }
46651     let validation = function checkOutdatedTags(entity, graph) {
46652       let issues = oldMultipolygonIssues(entity, graph);
46653       if (!issues.length)
46654         issues = oldTagIssues(entity, graph);
46655       return issues;
46656     };
46657     validation.type = type2;
46658     return validation;
46659   }
46660
46661   // modules/validations/private_data.js
46662   function validationPrivateData() {
46663     var type2 = "private_data";
46664     var privateBuildingValues = {
46665       detached: true,
46666       farm: true,
46667       house: true,
46668       houseboat: true,
46669       residential: true,
46670       semidetached_house: true,
46671       static_caravan: true
46672     };
46673     var publicKeys = {
46674       amenity: true,
46675       craft: true,
46676       historic: true,
46677       leisure: true,
46678       office: true,
46679       shop: true,
46680       tourism: true
46681     };
46682     var personalTags = {
46683       "contact:email": true,
46684       "contact:fax": true,
46685       "contact:phone": true,
46686       email: true,
46687       fax: true,
46688       phone: true
46689     };
46690     var validation = function checkPrivateData(entity) {
46691       var tags = entity.tags;
46692       if (!tags.building || !privateBuildingValues[tags.building])
46693         return [];
46694       var keepTags = {};
46695       for (var k2 in tags) {
46696         if (publicKeys[k2])
46697           return [];
46698         if (!personalTags[k2]) {
46699           keepTags[k2] = tags[k2];
46700         }
46701       }
46702       var tagDiff = utilTagDiff(tags, keepTags);
46703       if (!tagDiff.length)
46704         return [];
46705       var fixID = tagDiff.length === 1 ? "remove_tag" : "remove_tags";
46706       return [new validationIssue({
46707         type: type2,
46708         severity: "warning",
46709         message: showMessage,
46710         reference: showReference,
46711         entityIds: [entity.id],
46712         dynamicFixes: function() {
46713           return [
46714             new validationIssueFix({
46715               icon: "iD-operation-delete",
46716               title: _t.append("issues.fix." + fixID + ".title"),
46717               onClick: function(context) {
46718                 context.perform(doUpgrade, _t("issues.fix.remove_tag.annotation"));
46719               }
46720             })
46721           ];
46722         }
46723       })];
46724       function doUpgrade(graph) {
46725         var currEntity = graph.hasEntity(entity.id);
46726         if (!currEntity)
46727           return graph;
46728         var newTags = Object.assign({}, currEntity.tags);
46729         tagDiff.forEach(function(diff) {
46730           if (diff.type === "-") {
46731             delete newTags[diff.key];
46732           } else if (diff.type === "+") {
46733             newTags[diff.key] = diff.newVal;
46734           }
46735         });
46736         return actionChangeTags(currEntity.id, newTags)(graph);
46737       }
46738       function showMessage(context) {
46739         var currEntity = context.hasEntity(this.entityIds[0]);
46740         if (!currEntity)
46741           return "";
46742         return _t.append(
46743           "issues.private_data.contact.message",
46744           { feature: utilDisplayLabel(currEntity, context.graph()) }
46745         );
46746       }
46747       function showReference(selection2) {
46748         var enter = selection2.selectAll(".issue-reference").data([0]).enter();
46749         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.private_data.reference"));
46750         enter.append("strong").call(_t.append("issues.suggested"));
46751         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) {
46752           var klass = d2.type === "+" ? "add" : "remove";
46753           return "tagDiff-cell tagDiff-cell-" + klass;
46754         }).html(function(d2) {
46755           return d2.display;
46756         });
46757       }
46758     };
46759     validation.type = type2;
46760     return validation;
46761   }
46762
46763   // modules/validations/suspicious_name.js
46764   function validationSuspiciousName() {
46765     const type2 = "suspicious_name";
46766     const keysToTestForGenericValues = [
46767       "aerialway",
46768       "aeroway",
46769       "amenity",
46770       "building",
46771       "craft",
46772       "highway",
46773       "leisure",
46774       "railway",
46775       "man_made",
46776       "office",
46777       "shop",
46778       "tourism",
46779       "waterway"
46780     ];
46781     let _waitingForNsi = false;
46782     function isGenericMatchInNsi(tags) {
46783       const nsi = services.nsi;
46784       if (nsi) {
46785         _waitingForNsi = nsi.status() === "loading";
46786         if (!_waitingForNsi) {
46787           return nsi.isGenericName(tags);
46788         }
46789       }
46790       return false;
46791     }
46792     function nameMatchesRawTag(lowercaseName, tags) {
46793       for (let i3 = 0; i3 < keysToTestForGenericValues.length; i3++) {
46794         let key = keysToTestForGenericValues[i3];
46795         let val = tags[key];
46796         if (val) {
46797           val = val.toLowerCase();
46798           if (key === lowercaseName || val === lowercaseName || key.replace(/\_/g, " ") === lowercaseName || val.replace(/\_/g, " ") === lowercaseName) {
46799             return true;
46800           }
46801         }
46802       }
46803       return false;
46804     }
46805     function isGenericName(name, tags) {
46806       name = name.toLowerCase();
46807       return nameMatchesRawTag(name, tags) || isGenericMatchInNsi(tags);
46808     }
46809     function makeGenericNameIssue(entityId, nameKey, genericName, langCode) {
46810       return new validationIssue({
46811         type: type2,
46812         subtype: "generic_name",
46813         severity: "warning",
46814         message: function(context) {
46815           let entity = context.hasEntity(this.entityIds[0]);
46816           if (!entity)
46817             return "";
46818           let preset = _mainPresetIndex.match(entity, context.graph());
46819           let langName = langCode && _mainLocalizer.languageName(langCode);
46820           return _t.append(
46821             "issues.generic_name.message" + (langName ? "_language" : ""),
46822             { feature: preset.name(), name: genericName, language: langName }
46823           );
46824         },
46825         reference: showReference,
46826         entityIds: [entityId],
46827         hash: "".concat(nameKey, "=").concat(genericName),
46828         dynamicFixes: function() {
46829           return [
46830             new validationIssueFix({
46831               icon: "iD-operation-delete",
46832               title: _t.append("issues.fix.remove_the_name.title"),
46833               onClick: function(context) {
46834                 let entityId2 = this.issue.entityIds[0];
46835                 let entity = context.entity(entityId2);
46836                 let tags = Object.assign({}, entity.tags);
46837                 delete tags[nameKey];
46838                 context.perform(
46839                   actionChangeTags(entityId2, tags),
46840                   _t("issues.fix.remove_generic_name.annotation")
46841                 );
46842               }
46843             })
46844           ];
46845         }
46846       });
46847       function showReference(selection2) {
46848         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference"));
46849       }
46850     }
46851     let validation = function checkGenericName(entity) {
46852       const tags = entity.tags;
46853       const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"];
46854       if (hasWikidata)
46855         return [];
46856       let issues = [];
46857       for (let key in tags) {
46858         const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/);
46859         if (!m2)
46860           continue;
46861         const langCode = m2.length >= 2 ? m2[1] : null;
46862         const value = tags[key];
46863         if (isGenericName(value, tags)) {
46864           issues.provisional = _waitingForNsi;
46865           issues.push(makeGenericNameIssue(entity.id, key, value, langCode));
46866         }
46867       }
46868       return issues;
46869     };
46870     validation.type = type2;
46871     return validation;
46872   }
46873
46874   // modules/validations/unsquare_way.js
46875   function validationUnsquareWay(context) {
46876     var type2 = "unsquare_way";
46877     var DEFAULT_DEG_THRESHOLD = 5;
46878     var epsilon3 = 0.05;
46879     var nodeThreshold = 10;
46880     function isBuilding(entity, graph) {
46881       if (entity.type !== "way" || entity.geometry(graph) !== "area")
46882         return false;
46883       return entity.tags.building && entity.tags.building !== "no";
46884     }
46885     var validation = function checkUnsquareWay(entity, graph) {
46886       if (!isBuilding(entity, graph))
46887         return [];
46888       if (entity.tags.nonsquare === "yes")
46889         return [];
46890       var isClosed = entity.isClosed();
46891       if (!isClosed)
46892         return [];
46893       var nodes = graph.childNodes(entity).slice();
46894       if (nodes.length > nodeThreshold + 1)
46895         return [];
46896       var osm = services.osm;
46897       if (!osm || nodes.some(function(node) {
46898         return !osm.isDataLoaded(node.loc);
46899       }))
46900         return [];
46901       var hasConnectedSquarableWays = nodes.some(function(node) {
46902         return graph.parentWays(node).some(function(way) {
46903           if (way.id === entity.id)
46904             return false;
46905           if (isBuilding(way, graph))
46906             return true;
46907           return graph.parentRelations(way).some(function(parentRelation) {
46908             return parentRelation.isMultipolygon() && parentRelation.tags.building && parentRelation.tags.building !== "no";
46909           });
46910         });
46911       });
46912       if (hasConnectedSquarableWays)
46913         return [];
46914       var storedDegreeThreshold = corePreferences("validate-square-degrees");
46915       var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD;
46916       var points = nodes.map(function(node) {
46917         return context.projection(node.loc);
46918       });
46919       if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon3, degreeThreshold, true))
46920         return [];
46921       var autoArgs;
46922       if (!entity.tags.wikidata) {
46923         var autoAction = actionOrthogonalize(entity.id, context.projection, void 0, degreeThreshold);
46924         autoAction.transitionable = false;
46925         autoArgs = [autoAction, _t("operations.orthogonalize.annotation.feature", { n: 1 })];
46926       }
46927       return [new validationIssue({
46928         type: type2,
46929         subtype: "building",
46930         severity: "warning",
46931         message: function(context2) {
46932           var entity2 = context2.hasEntity(this.entityIds[0]);
46933           return entity2 ? _t.append("issues.unsquare_way.message", {
46934             feature: utilDisplayLabel(entity2, context2.graph())
46935           }) : "";
46936         },
46937         reference: showReference,
46938         entityIds: [entity.id],
46939         hash: degreeThreshold,
46940         dynamicFixes: function() {
46941           return [
46942             new validationIssueFix({
46943               icon: "iD-operation-orthogonalize",
46944               title: _t.append("issues.fix.square_feature.title"),
46945               autoArgs,
46946               onClick: function(context2, completionHandler) {
46947                 var entityId = this.issue.entityIds[0];
46948                 context2.perform(
46949                   actionOrthogonalize(entityId, context2.projection, void 0, degreeThreshold),
46950                   _t("operations.orthogonalize.annotation.feature", { n: 1 })
46951                 );
46952                 window.setTimeout(function() {
46953                   completionHandler();
46954                 }, 175);
46955               }
46956             })
46957             /*
46958             new validationIssueFix({
46959                 title: t.append('issues.fix.tag_as_unsquare.title'),
46960                 onClick: function(context) {
46961                     var entityId = this.issue.entityIds[0];
46962                     var entity = context.entity(entityId);
46963                     var tags = Object.assign({}, entity.tags);  // shallow copy
46964                     tags.nonsquare = 'yes';
46965                     context.perform(
46966                         actionChangeTags(entityId, tags),
46967                         t('issues.fix.tag_as_unsquare.annotation')
46968                     );
46969                 }
46970             })
46971             */
46972           ];
46973         }
46974       })];
46975       function showReference(selection2) {
46976         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unsquare_way.buildings.reference"));
46977       }
46978     };
46979     validation.type = type2;
46980     return validation;
46981   }
46982
46983   // modules/core/validator.js
46984   function coreValidator(context) {
46985     let dispatch14 = dispatch_default("validated", "focusedIssue");
46986     let validator = utilRebind({}, dispatch14, "on");
46987     let _rules = {};
46988     let _disabledRules = {};
46989     let _ignoredIssueIDs = /* @__PURE__ */ new Set();
46990     let _resolvedIssueIDs = /* @__PURE__ */ new Set();
46991     let _baseCache = validationCache("base");
46992     let _headCache = validationCache("head");
46993     let _completeDiff = {};
46994     let _headIsCurrent = false;
46995     let _deferredRIC = {};
46996     let _deferredST = /* @__PURE__ */ new Set();
46997     let _headPromise;
46998     const RETRY = 5e3;
46999     const _errorOverrides = parseHashParam(context.initialHashParams.validationError);
47000     const _warningOverrides = parseHashParam(context.initialHashParams.validationWarning);
47001     const _disableOverrides = parseHashParam(context.initialHashParams.validationDisable);
47002     function parseHashParam(param) {
47003       let result = [];
47004       let rules = (param || "").split(",");
47005       rules.forEach((rule) => {
47006         rule = rule.trim();
47007         const parts = rule.split("/", 2);
47008         const type2 = parts[0];
47009         const subtype = parts[1] || "*";
47010         if (!type2 || !subtype)
47011           return;
47012         result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) });
47013       });
47014       return result;
47015       function makeRegExp(str) {
47016         const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
47017         return new RegExp("^" + escaped + "$");
47018       }
47019     }
47020     validator.init = () => {
47021       Object.values(validations_exports).forEach((validation) => {
47022         if (typeof validation !== "function")
47023           return;
47024         const fn = validation(context);
47025         const key = fn.type;
47026         _rules[key] = fn;
47027       });
47028       let disabledRules = corePreferences("validate-disabledRules");
47029       if (disabledRules) {
47030         disabledRules.split(",").forEach((k2) => _disabledRules[k2] = true);
47031       }
47032     };
47033     function reset(resetIgnored) {
47034       _baseCache.queue = [];
47035       _headCache.queue = [];
47036       Object.keys(_deferredRIC).forEach((key) => {
47037         window.cancelIdleCallback(key);
47038         _deferredRIC[key]();
47039       });
47040       _deferredRIC = {};
47041       _deferredST.forEach(window.clearTimeout);
47042       _deferredST.clear();
47043       if (resetIgnored)
47044         _ignoredIssueIDs.clear();
47045       _resolvedIssueIDs.clear();
47046       _baseCache = validationCache("base");
47047       _headCache = validationCache("head");
47048       _completeDiff = {};
47049       _headIsCurrent = false;
47050     }
47051     validator.reset = () => {
47052       reset(true);
47053     };
47054     validator.resetIgnoredIssues = () => {
47055       _ignoredIssueIDs.clear();
47056       dispatch14.call("validated");
47057     };
47058     validator.revalidateUnsquare = () => {
47059       revalidateUnsquare(_headCache);
47060       revalidateUnsquare(_baseCache);
47061       dispatch14.call("validated");
47062     };
47063     function revalidateUnsquare(cache) {
47064       const checkUnsquareWay = _rules.unsquare_way;
47065       if (!cache.graph || typeof checkUnsquareWay !== "function")
47066         return;
47067       cache.uncacheIssuesOfType("unsquare_way");
47068       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");
47069       buildings.forEach((entity) => {
47070         const detected = checkUnsquareWay(entity, cache.graph);
47071         if (!detected.length)
47072           return;
47073         cache.cacheIssues(detected);
47074       });
47075     }
47076     validator.getIssues = (options2) => {
47077       const opts = Object.assign({ what: "all", where: "all", includeIgnored: false, includeDisabledRules: false }, options2);
47078       const view = context.map().extent();
47079       let seen = /* @__PURE__ */ new Set();
47080       let results = [];
47081       if (_headCache.graph && _headCache.graph !== _baseCache.graph) {
47082         Object.values(_headCache.issuesByIssueID).forEach((issue) => {
47083           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47084           if (opts.what === "edited" && !userModified)
47085             return;
47086           if (!filter2(issue))
47087             return;
47088           seen.add(issue.id);
47089           results.push(issue);
47090         });
47091       }
47092       if (opts.what === "all") {
47093         Object.values(_baseCache.issuesByIssueID).forEach((issue) => {
47094           if (!filter2(issue))
47095             return;
47096           seen.add(issue.id);
47097           results.push(issue);
47098         });
47099       }
47100       return results;
47101       function filter2(issue) {
47102         if (!issue)
47103           return false;
47104         if (seen.has(issue.id))
47105           return false;
47106         if (_resolvedIssueIDs.has(issue.id))
47107           return false;
47108         if (opts.includeDisabledRules === "only" && !_disabledRules[issue.type])
47109           return false;
47110         if (!opts.includeDisabledRules && _disabledRules[issue.type])
47111           return false;
47112         if (opts.includeIgnored === "only" && !_ignoredIssueIDs.has(issue.id))
47113           return false;
47114         if (!opts.includeIgnored && _ignoredIssueIDs.has(issue.id))
47115           return false;
47116         if ((issue.entityIds || []).some((id2) => !context.hasEntity(id2)))
47117           return false;
47118         if (opts.where === "visible") {
47119           const extent = issue.extent(context.graph());
47120           if (!view.intersects(extent))
47121             return false;
47122         }
47123         return true;
47124       }
47125     };
47126     validator.getResolvedIssues = () => {
47127       return Array.from(_resolvedIssueIDs).map((issueID) => _baseCache.issuesByIssueID[issueID]).filter(Boolean);
47128     };
47129     validator.focusIssue = (issue) => {
47130       const graph = context.graph();
47131       let selectID;
47132       let focusCenter;
47133       const issueExtent = issue.extent(graph);
47134       if (issueExtent) {
47135         focusCenter = issueExtent.center();
47136       }
47137       if (issue.entityIds && issue.entityIds.length) {
47138         selectID = issue.entityIds[0];
47139         if (selectID && selectID.charAt(0) === "r") {
47140           const ids = utilEntityAndDeepMemberIDs([selectID], graph);
47141           let nodeID = ids.find((id2) => id2.charAt(0) === "n" && graph.hasEntity(id2));
47142           if (!nodeID) {
47143             const wayID = ids.find((id2) => id2.charAt(0) === "w" && graph.hasEntity(id2));
47144             if (wayID) {
47145               nodeID = graph.entity(wayID).first();
47146             }
47147           }
47148           if (nodeID) {
47149             focusCenter = graph.entity(nodeID).loc;
47150           }
47151         }
47152       }
47153       if (focusCenter) {
47154         const setZoom = Math.max(context.map().zoom(), 19);
47155         context.map().unobscuredCenterZoomEase(focusCenter, setZoom);
47156       }
47157       if (selectID) {
47158         window.setTimeout(() => {
47159           context.enter(modeSelect(context, [selectID]));
47160           dispatch14.call("focusedIssue", this, issue);
47161         }, 250);
47162       }
47163     };
47164     validator.getIssuesBySeverity = (options2) => {
47165       let groups = utilArrayGroupBy(validator.getIssues(options2), "severity");
47166       groups.error = groups.error || [];
47167       groups.warning = groups.warning || [];
47168       return groups;
47169     };
47170     validator.getSharedEntityIssues = (entityIDs, options2) => {
47171       const orderedIssueTypes = [
47172         // Show some issue types in a particular order:
47173         "missing_tag",
47174         "missing_role",
47175         // - missing data first
47176         "outdated_tags",
47177         "mismatched_geometry",
47178         // - identity issues
47179         "crossing_ways",
47180         "almost_junction",
47181         // - geometry issues where fixing them might solve connectivity issues
47182         "disconnected_way",
47183         "impossible_oneway"
47184         // - finally connectivity issues
47185       ];
47186       const allIssues = validator.getIssues(options2);
47187       const forEntityIDs = new Set(entityIDs);
47188       return allIssues.filter((issue) => (issue.entityIds || []).some((entityID) => forEntityIDs.has(entityID))).sort((issue1, issue2) => {
47189         if (issue1.type === issue2.type) {
47190           return issue1.id < issue2.id ? -1 : 1;
47191         }
47192         const index1 = orderedIssueTypes.indexOf(issue1.type);
47193         const index2 = orderedIssueTypes.indexOf(issue2.type);
47194         if (index1 !== -1 && index2 !== -1) {
47195           return index1 - index2;
47196         } else if (index1 === -1 && index2 === -1) {
47197           return issue1.type < issue2.type ? -1 : 1;
47198         } else {
47199           return index1 !== -1 ? -1 : 1;
47200         }
47201       });
47202     };
47203     validator.getEntityIssues = (entityID, options2) => {
47204       return validator.getSharedEntityIssues([entityID], options2);
47205     };
47206     validator.getRuleKeys = () => {
47207       return Object.keys(_rules);
47208     };
47209     validator.isRuleEnabled = (key) => {
47210       return !_disabledRules[key];
47211     };
47212     validator.toggleRule = (key) => {
47213       if (_disabledRules[key]) {
47214         delete _disabledRules[key];
47215       } else {
47216         _disabledRules[key] = true;
47217       }
47218       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47219       validator.validate();
47220     };
47221     validator.disableRules = (keys2) => {
47222       _disabledRules = {};
47223       keys2.forEach((k2) => _disabledRules[k2] = true);
47224       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47225       validator.validate();
47226     };
47227     validator.ignoreIssue = (issueID) => {
47228       _ignoredIssueIDs.add(issueID);
47229     };
47230     validator.validate = () => {
47231       const baseGraph = context.history().base();
47232       if (!_headCache.graph)
47233         _headCache.graph = baseGraph;
47234       if (!_baseCache.graph)
47235         _baseCache.graph = baseGraph;
47236       const prevGraph = _headCache.graph;
47237       const currGraph = context.graph();
47238       if (currGraph === prevGraph) {
47239         _headIsCurrent = true;
47240         dispatch14.call("validated");
47241         return Promise.resolve();
47242       }
47243       if (_headPromise) {
47244         _headIsCurrent = false;
47245         return _headPromise;
47246       }
47247       _headCache.graph = currGraph;
47248       _completeDiff = context.history().difference().complete();
47249       const incrementalDiff = coreDifference(prevGraph, currGraph);
47250       let entityIDs = Object.keys(incrementalDiff.complete());
47251       entityIDs = _headCache.withAllRelatedEntities(entityIDs);
47252       if (!entityIDs.size) {
47253         dispatch14.call("validated");
47254         return Promise.resolve();
47255       }
47256       _headPromise = validateEntitiesAsync(entityIDs, _headCache).then(() => updateResolvedIssues(entityIDs)).then(() => dispatch14.call("validated")).catch(() => {
47257       }).then(() => {
47258         _headPromise = null;
47259         if (!_headIsCurrent) {
47260           validator.validate();
47261         }
47262       });
47263       return _headPromise;
47264     };
47265     context.history().on("restore.validator", validator.validate).on("undone.validator", validator.validate).on("redone.validator", validator.validate).on("reset.validator", () => {
47266       reset(false);
47267       validator.validate();
47268     });
47269     context.on("exit.validator", validator.validate);
47270     context.history().on("merge.validator", (entities) => {
47271       if (!entities)
47272         return;
47273       const baseGraph = context.history().base();
47274       if (!_headCache.graph)
47275         _headCache.graph = baseGraph;
47276       if (!_baseCache.graph)
47277         _baseCache.graph = baseGraph;
47278       let entityIDs = entities.map((entity) => entity.id);
47279       entityIDs = _baseCache.withAllRelatedEntities(entityIDs);
47280       validateEntitiesAsync(entityIDs, _baseCache);
47281     });
47282     function validateEntity(entity, graph) {
47283       let result = { issues: [], provisional: false };
47284       Object.keys(_rules).forEach(runValidation);
47285       return result;
47286       function runValidation(key) {
47287         const fn = _rules[key];
47288         if (typeof fn !== "function") {
47289           console.error("no such validation rule = " + key);
47290           return;
47291         }
47292         let detected = fn(entity, graph);
47293         if (detected.provisional) {
47294           result.provisional = true;
47295         }
47296         detected = detected.filter(applySeverityOverrides);
47297         result.issues = result.issues.concat(detected);
47298         function applySeverityOverrides(issue) {
47299           const type2 = issue.type;
47300           const subtype = issue.subtype || "";
47301           let i3;
47302           for (i3 = 0; i3 < _errorOverrides.length; i3++) {
47303             if (_errorOverrides[i3].type.test(type2) && _errorOverrides[i3].subtype.test(subtype)) {
47304               issue.severity = "error";
47305               return true;
47306             }
47307           }
47308           for (i3 = 0; i3 < _warningOverrides.length; i3++) {
47309             if (_warningOverrides[i3].type.test(type2) && _warningOverrides[i3].subtype.test(subtype)) {
47310               issue.severity = "warning";
47311               return true;
47312             }
47313           }
47314           for (i3 = 0; i3 < _disableOverrides.length; i3++) {
47315             if (_disableOverrides[i3].type.test(type2) && _disableOverrides[i3].subtype.test(subtype)) {
47316               return false;
47317             }
47318           }
47319           return true;
47320         }
47321       }
47322     }
47323     function updateResolvedIssues(entityIDs) {
47324       entityIDs.forEach((entityID) => {
47325         const baseIssues = _baseCache.issuesByEntityID[entityID];
47326         if (!baseIssues)
47327           return;
47328         baseIssues.forEach((issueID) => {
47329           const issue = _baseCache.issuesByIssueID[issueID];
47330           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47331           if (userModified && !_headCache.issuesByIssueID[issueID]) {
47332             _resolvedIssueIDs.add(issueID);
47333           } else {
47334             _resolvedIssueIDs.delete(issueID);
47335           }
47336         });
47337       });
47338     }
47339     function validateEntitiesAsync(entityIDs, cache) {
47340       const jobs = Array.from(entityIDs).map((entityID) => {
47341         if (cache.queuedEntityIDs.has(entityID))
47342           return null;
47343         cache.queuedEntityIDs.add(entityID);
47344         cache.uncacheEntityID(entityID);
47345         return () => {
47346           cache.queuedEntityIDs.delete(entityID);
47347           const graph = cache.graph;
47348           if (!graph)
47349             return;
47350           const entity = graph.hasEntity(entityID);
47351           if (!entity)
47352             return;
47353           const result = validateEntity(entity, graph);
47354           if (result.provisional) {
47355             cache.provisionalEntityIDs.add(entityID);
47356           }
47357           cache.cacheIssues(result.issues);
47358         };
47359       }).filter(Boolean);
47360       cache.queue = cache.queue.concat(utilArrayChunk(jobs, 100));
47361       if (cache.queuePromise)
47362         return cache.queuePromise;
47363       cache.queuePromise = processQueue(cache).then(() => revalidateProvisionalEntities(cache)).catch(() => {
47364       }).finally(() => cache.queuePromise = null);
47365       return cache.queuePromise;
47366     }
47367     function revalidateProvisionalEntities(cache) {
47368       if (!cache.provisionalEntityIDs.size)
47369         return;
47370       const handle = window.setTimeout(() => {
47371         _deferredST.delete(handle);
47372         if (!cache.provisionalEntityIDs.size)
47373           return;
47374         validateEntitiesAsync(Array.from(cache.provisionalEntityIDs), cache);
47375       }, RETRY);
47376       _deferredST.add(handle);
47377     }
47378     function processQueue(cache) {
47379       if (!cache.queue.length)
47380         return Promise.resolve();
47381       const chunk = cache.queue.pop();
47382       return new Promise((resolvePromise, rejectPromise) => {
47383         const handle = window.requestIdleCallback(() => {
47384           delete _deferredRIC[handle];
47385           chunk.forEach((job) => job());
47386           resolvePromise();
47387         });
47388         _deferredRIC[handle] = rejectPromise;
47389       }).then(() => {
47390         if (cache.queue.length % 25 === 0)
47391           dispatch14.call("validated");
47392       }).then(() => processQueue(cache));
47393     }
47394     return validator;
47395   }
47396   function validationCache(which) {
47397     let cache = {
47398       which,
47399       graph: null,
47400       queue: [],
47401       queuePromise: null,
47402       queuedEntityIDs: /* @__PURE__ */ new Set(),
47403       provisionalEntityIDs: /* @__PURE__ */ new Set(),
47404       issuesByIssueID: {},
47405       // issue.id -> issue
47406       issuesByEntityID: {}
47407       // entity.id -> Set(issue.id)
47408     };
47409     cache.cacheIssue = (issue) => {
47410       (issue.entityIds || []).forEach((entityID) => {
47411         if (!cache.issuesByEntityID[entityID]) {
47412           cache.issuesByEntityID[entityID] = /* @__PURE__ */ new Set();
47413         }
47414         cache.issuesByEntityID[entityID].add(issue.id);
47415       });
47416       cache.issuesByIssueID[issue.id] = issue;
47417     };
47418     cache.uncacheIssue = (issue) => {
47419       (issue.entityIds || []).forEach((entityID) => {
47420         if (cache.issuesByEntityID[entityID]) {
47421           cache.issuesByEntityID[entityID].delete(issue.id);
47422         }
47423       });
47424       delete cache.issuesByIssueID[issue.id];
47425     };
47426     cache.cacheIssues = (issues) => {
47427       issues.forEach(cache.cacheIssue);
47428     };
47429     cache.uncacheIssues = (issues) => {
47430       issues.forEach(cache.uncacheIssue);
47431     };
47432     cache.uncacheIssuesOfType = (type2) => {
47433       const issuesOfType = Object.values(cache.issuesByIssueID).filter((issue) => issue.type === type2);
47434       cache.uncacheIssues(issuesOfType);
47435     };
47436     cache.uncacheEntityID = (entityID) => {
47437       const entityIssueIDs = cache.issuesByEntityID[entityID];
47438       if (entityIssueIDs) {
47439         entityIssueIDs.forEach((issueID) => {
47440           const issue = cache.issuesByIssueID[issueID];
47441           if (issue) {
47442             cache.uncacheIssue(issue);
47443           } else {
47444             delete cache.issuesByIssueID[issueID];
47445           }
47446         });
47447       }
47448       delete cache.issuesByEntityID[entityID];
47449       cache.provisionalEntityIDs.delete(entityID);
47450     };
47451     cache.withAllRelatedEntities = (entityIDs) => {
47452       let result = /* @__PURE__ */ new Set();
47453       (entityIDs || []).forEach((entityID) => {
47454         result.add(entityID);
47455         const entityIssueIDs = cache.issuesByEntityID[entityID];
47456         if (entityIssueIDs) {
47457           entityIssueIDs.forEach((issueID) => {
47458             const issue = cache.issuesByIssueID[issueID];
47459             if (issue) {
47460               (issue.entityIds || []).forEach((relatedID) => result.add(relatedID));
47461             } else {
47462               delete cache.issuesByIssueID[issueID];
47463             }
47464           });
47465         }
47466       });
47467       return result;
47468     };
47469     return cache;
47470   }
47471
47472   // modules/core/uploader.js
47473   function coreUploader(context) {
47474     var dispatch14 = dispatch_default(
47475       // Start and end events are dispatched exactly once each per legitimate outside call to `save`
47476       "saveStarted",
47477       // dispatched as soon as a call to `save` has been deemed legitimate
47478       "saveEnded",
47479       // dispatched after the result event has been dispatched
47480       "willAttemptUpload",
47481       // dispatched before the actual upload call occurs, if it will
47482       "progressChanged",
47483       // Each save results in one of these outcomes:
47484       "resultNoChanges",
47485       // upload wasn't attempted since there were no edits
47486       "resultErrors",
47487       // upload failed due to errors
47488       "resultConflicts",
47489       // upload failed due to data conflicts
47490       "resultSuccess"
47491       // upload completed without errors
47492     );
47493     var _isSaving = false;
47494     var _conflicts = [];
47495     var _errors = [];
47496     var _origChanges;
47497     var _discardTags = {};
47498     _mainFileFetcher.get("discarded").then(function(d2) {
47499       _discardTags = d2;
47500     }).catch(function() {
47501     });
47502     var uploader = utilRebind({}, dispatch14, "on");
47503     uploader.isSaving = function() {
47504       return _isSaving;
47505     };
47506     uploader.save = function(changeset, tryAgain, checkConflicts) {
47507       if (_isSaving && !tryAgain) {
47508         return;
47509       }
47510       var osm = context.connection();
47511       if (!osm)
47512         return;
47513       if (!osm.authenticated()) {
47514         osm.authenticate(function(err) {
47515           if (!err) {
47516             uploader.save(changeset, tryAgain, checkConflicts);
47517           }
47518         });
47519         return;
47520       }
47521       if (!_isSaving) {
47522         _isSaving = true;
47523         dispatch14.call("saveStarted", this);
47524       }
47525       var history = context.history();
47526       _conflicts = [];
47527       _errors = [];
47528       _origChanges = history.changes(actionDiscardTags(history.difference(), _discardTags));
47529       if (!tryAgain) {
47530         history.perform(actionNoop());
47531       }
47532       if (!checkConflicts) {
47533         upload(changeset);
47534       } else {
47535         performFullConflictCheck(changeset);
47536       }
47537     };
47538     function performFullConflictCheck(changeset) {
47539       var osm = context.connection();
47540       if (!osm)
47541         return;
47542       var history = context.history();
47543       var localGraph = context.graph();
47544       var remoteGraph = coreGraph(history.base(), true);
47545       var summary = history.difference().summary();
47546       var _toCheck = [];
47547       for (var i3 = 0; i3 < summary.length; i3++) {
47548         var item = summary[i3];
47549         if (item.changeType === "modified") {
47550           _toCheck.push(item.entity.id);
47551         }
47552       }
47553       var _toLoad = withChildNodes(_toCheck, localGraph);
47554       var _loaded = {};
47555       var _toLoadCount = 0;
47556       var _toLoadTotal = _toLoad.length;
47557       if (_toCheck.length) {
47558         dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47559         _toLoad.forEach(function(id2) {
47560           _loaded[id2] = false;
47561         });
47562         osm.loadMultiple(_toLoad, loaded);
47563       } else {
47564         upload(changeset);
47565       }
47566       return;
47567       function withChildNodes(ids, graph) {
47568         var s2 = new Set(ids);
47569         ids.forEach(function(id2) {
47570           var entity = graph.entity(id2);
47571           if (entity.type !== "way")
47572             return;
47573           graph.childNodes(entity).forEach(function(child) {
47574             if (child.version !== void 0) {
47575               s2.add(child.id);
47576             }
47577           });
47578         });
47579         return Array.from(s2);
47580       }
47581       function loaded(err, result) {
47582         if (_errors.length)
47583           return;
47584         if (err) {
47585           _errors.push({
47586             msg: err.message || err.responseText,
47587             details: [_t("save.status_code", { code: err.status })]
47588           });
47589           didResultInErrors();
47590         } else {
47591           var loadMore = [];
47592           result.data.forEach(function(entity) {
47593             remoteGraph.replace(entity);
47594             _loaded[entity.id] = true;
47595             _toLoad = _toLoad.filter(function(val) {
47596               return val !== entity.id;
47597             });
47598             if (!entity.visible)
47599               return;
47600             var i4, id2;
47601             if (entity.type === "way") {
47602               for (i4 = 0; i4 < entity.nodes.length; i4++) {
47603                 id2 = entity.nodes[i4];
47604                 if (_loaded[id2] === void 0) {
47605                   _loaded[id2] = false;
47606                   loadMore.push(id2);
47607                 }
47608               }
47609             } else if (entity.type === "relation" && entity.isMultipolygon()) {
47610               for (i4 = 0; i4 < entity.members.length; i4++) {
47611                 id2 = entity.members[i4].id;
47612                 if (_loaded[id2] === void 0) {
47613                   _loaded[id2] = false;
47614                   loadMore.push(id2);
47615                 }
47616               }
47617             }
47618           });
47619           _toLoadCount += result.data.length;
47620           _toLoadTotal += loadMore.length;
47621           dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47622           if (loadMore.length) {
47623             _toLoad.push.apply(_toLoad, loadMore);
47624             osm.loadMultiple(loadMore, loaded);
47625           }
47626           if (!_toLoad.length) {
47627             detectConflicts();
47628             upload(changeset);
47629           }
47630         }
47631       }
47632       function detectConflicts() {
47633         function choice(id2, text, action) {
47634           return {
47635             id: id2,
47636             text,
47637             action: function() {
47638               history.replace(action);
47639             }
47640           };
47641         }
47642         function formatUser(d2) {
47643           return '<a href="' + osm.userURL(d2) + '" target="_blank">' + escape_default(d2) + "</a>";
47644         }
47645         function entityName(entity) {
47646           return utilDisplayName(entity) || utilDisplayType(entity.id) + " " + entity.id;
47647         }
47648         function sameVersions(local, remote) {
47649           if (local.version !== remote.version)
47650             return false;
47651           if (local.type === "way") {
47652             var children2 = utilArrayUnion(local.nodes, remote.nodes);
47653             for (var i4 = 0; i4 < children2.length; i4++) {
47654               var a2 = localGraph.hasEntity(children2[i4]);
47655               var b2 = remoteGraph.hasEntity(children2[i4]);
47656               if (a2 && b2 && a2.version !== b2.version)
47657                 return false;
47658             }
47659           }
47660           return true;
47661         }
47662         _toCheck.forEach(function(id2) {
47663           var local = localGraph.entity(id2);
47664           var remote = remoteGraph.entity(id2);
47665           if (sameVersions(local, remote))
47666             return;
47667           var merge2 = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags, formatUser);
47668           history.replace(merge2);
47669           var mergeConflicts = merge2.conflicts();
47670           if (!mergeConflicts.length)
47671             return;
47672           var forceLocal = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_local");
47673           var forceRemote = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_remote");
47674           var keepMine = _t("save.conflict." + (remote.visible ? "keep_local" : "restore"));
47675           var keepTheirs = _t("save.conflict." + (remote.visible ? "keep_remote" : "delete"));
47676           _conflicts.push({
47677             id: id2,
47678             name: entityName(local),
47679             details: mergeConflicts,
47680             chosen: 1,
47681             choices: [
47682               choice(id2, keepMine, forceLocal),
47683               choice(id2, keepTheirs, forceRemote)
47684             ]
47685           });
47686         });
47687       }
47688     }
47689     function upload(changeset) {
47690       var osm = context.connection();
47691       if (!osm) {
47692         _errors.push({ msg: "No OSM Service" });
47693       }
47694       if (_conflicts.length) {
47695         didResultInConflicts(changeset);
47696       } else if (_errors.length) {
47697         didResultInErrors();
47698       } else {
47699         var history = context.history();
47700         var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
47701         if (changes.modified.length || changes.created.length || changes.deleted.length) {
47702           dispatch14.call("willAttemptUpload", this);
47703           osm.putChangeset(changeset, changes, uploadCallback);
47704         } else {
47705           didResultInNoChanges();
47706         }
47707       }
47708     }
47709     function uploadCallback(err, changeset) {
47710       if (err) {
47711         if (err.status === 409) {
47712           uploader.save(changeset, true, true);
47713         } else {
47714           _errors.push({
47715             msg: err.message || err.responseText,
47716             details: [_t("save.status_code", { code: err.status })]
47717           });
47718           didResultInErrors();
47719         }
47720       } else {
47721         didResultInSuccess(changeset);
47722       }
47723     }
47724     function didResultInNoChanges() {
47725       dispatch14.call("resultNoChanges", this);
47726       endSave();
47727       context.flush();
47728     }
47729     function didResultInErrors() {
47730       context.history().pop();
47731       dispatch14.call("resultErrors", this, _errors);
47732       endSave();
47733     }
47734     function didResultInConflicts(changeset) {
47735       _conflicts.sort(function(a2, b2) {
47736         return b2.id.localeCompare(a2.id);
47737       });
47738       dispatch14.call("resultConflicts", this, changeset, _conflicts, _origChanges);
47739       endSave();
47740     }
47741     function didResultInSuccess(changeset) {
47742       context.history().clearSaved();
47743       dispatch14.call("resultSuccess", this, changeset);
47744       window.setTimeout(function() {
47745         endSave();
47746         context.flush();
47747       }, 2500);
47748     }
47749     function endSave() {
47750       _isSaving = false;
47751       dispatch14.call("saveEnded", this);
47752     }
47753     uploader.cancelConflictResolution = function() {
47754       context.history().pop();
47755     };
47756     uploader.processResolvedConflicts = function(changeset) {
47757       var history = context.history();
47758       for (var i3 = 0; i3 < _conflicts.length; i3++) {
47759         if (_conflicts[i3].chosen === 1) {
47760           var entity = context.hasEntity(_conflicts[i3].id);
47761           if (entity && entity.type === "way") {
47762             var children2 = utilArrayUniq(entity.nodes);
47763             for (var j2 = 0; j2 < children2.length; j2++) {
47764               history.replace(actionRevert(children2[j2]));
47765             }
47766           }
47767           history.replace(actionRevert(_conflicts[i3].id));
47768         }
47769       }
47770       uploader.save(changeset, true, false);
47771     };
47772     uploader.reset = function() {
47773     };
47774     return uploader;
47775   }
47776
47777   // modules/renderer/background_source.js
47778   var import_lodash4 = __toESM(require_lodash());
47779
47780   // modules/util/IntervalTasksQueue.js
47781   var IntervalTasksQueue = class {
47782     /**
47783      * Interval in milliseconds inside which only 1 task can execute.
47784      * e.g. if interval is 200ms, and 5 async tasks are unqueued,
47785      * they will complete in ~1s if not cleared
47786      * @param {number} intervalInMs
47787      */
47788     constructor(intervalInMs) {
47789       this.intervalInMs = intervalInMs;
47790       this.pendingHandles = [];
47791       this.time = 0;
47792     }
47793     enqueue(task) {
47794       let taskTimeout = this.time;
47795       this.time += this.intervalInMs;
47796       this.pendingHandles.push(setTimeout(() => {
47797         this.time -= this.intervalInMs;
47798         task();
47799       }, taskTimeout));
47800     }
47801     clear() {
47802       this.pendingHandles.forEach((timeoutHandle) => {
47803         clearTimeout(timeoutHandle);
47804       });
47805       this.pendingHandles = [];
47806       this.time = 0;
47807     }
47808   };
47809
47810   // modules/renderer/background_source.js
47811   var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47812   window.matchMedia("\n        (-webkit-min-device-pixel-ratio: 2), /* Safari */\n        (min-resolution: 2dppx),             /* standard */\n        (min-resolution: 192dpi)             /* fallback */\n    ").addListener(function() {
47813     isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47814   });
47815   function localeDateString(s2) {
47816     if (!s2)
47817       return null;
47818     var options2 = { day: "numeric", month: "short", year: "numeric" };
47819     var d2 = new Date(s2);
47820     if (isNaN(d2.getTime()))
47821       return null;
47822     return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
47823   }
47824   function vintageRange(vintage) {
47825     var s2;
47826     if (vintage.start || vintage.end) {
47827       s2 = vintage.start || "?";
47828       if (vintage.start !== vintage.end) {
47829         s2 += " - " + (vintage.end || "?");
47830       }
47831     }
47832     return s2;
47833   }
47834   function rendererBackgroundSource(data) {
47835     var source = Object.assign({}, data);
47836     var _offset = [0, 0];
47837     var _name = source.name;
47838     var _description = source.description;
47839     var _best = !!source.best;
47840     var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template;
47841     source.tileSize = data.tileSize || 256;
47842     source.zoomExtent = data.zoomExtent || [0, 22];
47843     source.overzoom = data.overzoom !== false;
47844     source.offset = function(val) {
47845       if (!arguments.length)
47846         return _offset;
47847       _offset = val;
47848       return source;
47849     };
47850     source.nudge = function(val, zoomlevel) {
47851       _offset[0] += val[0] / Math.pow(2, zoomlevel);
47852       _offset[1] += val[1] / Math.pow(2, zoomlevel);
47853       return source;
47854     };
47855     source.name = function() {
47856       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47857       return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47858     };
47859     source.label = function() {
47860       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47861       return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47862     };
47863     source.hasDescription = function() {
47864       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47865       var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text;
47866       return descriptionText !== "";
47867     };
47868     source.description = function() {
47869       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47870       return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) });
47871     };
47872     source.best = function() {
47873       return _best;
47874     };
47875     source.area = function() {
47876       if (!data.polygon)
47877         return Number.MAX_VALUE;
47878       var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] });
47879       return isNaN(area) ? 0 : area;
47880     };
47881     source.imageryUsed = function() {
47882       return _name || source.id;
47883     };
47884     source.template = function(val) {
47885       if (!arguments.length)
47886         return _template;
47887       if (source.id === "custom" || source.id === "Bing") {
47888         _template = val;
47889       }
47890       return source;
47891     };
47892     source.url = function(coord2) {
47893       var result = _template.replace(/#[\s\S]*/u, "");
47894       if (result === "")
47895         return result;
47896       if (!source.type || source.id === "custom") {
47897         if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
47898           source.type = "wms";
47899           source.projection = "EPSG:3857";
47900         } else if (/\{(x|y)\}/.test(result)) {
47901           source.type = "tms";
47902         } else if (/\{u\}/.test(result)) {
47903           source.type = "bing";
47904         }
47905       }
47906       if (source.type === "wms") {
47907         var tileToProjectedCoords = function(x2, y2, z2) {
47908           var zoomSize = Math.pow(2, z2);
47909           var lon = x2 / zoomSize * Math.PI * 2 - Math.PI;
47910           var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize)));
47911           switch (source.projection) {
47912             case "EPSG:4326":
47913               return {
47914                 x: lon * 180 / Math.PI,
47915                 y: lat * 180 / Math.PI
47916               };
47917             default:
47918               var mercCoords = mercatorRaw(lon, lat);
47919               return {
47920                 x: 2003750834e-2 / Math.PI * mercCoords[0],
47921                 y: 2003750834e-2 / Math.PI * mercCoords[1]
47922               };
47923           }
47924         };
47925         var tileSize = source.tileSize;
47926         var projection2 = source.projection;
47927         var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]);
47928         var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]);
47929         result = result.replace(/\{(\w+)\}/g, function(token, key) {
47930           switch (key) {
47931             case "width":
47932             case "height":
47933               return tileSize;
47934             case "proj":
47935               return projection2;
47936             case "wkid":
47937               return projection2.replace(/^EPSG:/, "");
47938             case "bbox":
47939               if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS)
47940               /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) {
47941                 return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x;
47942               } else {
47943                 return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y;
47944               }
47945             case "w":
47946               return minXmaxY.x;
47947             case "s":
47948               return maxXminY.y;
47949             case "n":
47950               return maxXminY.x;
47951             case "e":
47952               return minXmaxY.y;
47953             default:
47954               return token;
47955           }
47956         });
47957       } else if (source.type === "tms") {
47958         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" : "");
47959       } else if (source.type === "bing") {
47960         result = result.replace("{u}", function() {
47961           var u2 = "";
47962           for (var zoom = coord2[2]; zoom > 0; zoom--) {
47963             var b2 = 0;
47964             var mask = 1 << zoom - 1;
47965             if ((coord2[0] & mask) !== 0)
47966               b2++;
47967             if ((coord2[1] & mask) !== 0)
47968               b2 += 2;
47969             u2 += b2.toString();
47970           }
47971           return u2;
47972         });
47973       }
47974       result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) {
47975         var subdomains = r2.split(",");
47976         return subdomains[(coord2[0] + coord2[1]) % subdomains.length];
47977       });
47978       return result;
47979     };
47980     source.validZoom = function(z2) {
47981       return source.zoomExtent[0] <= z2 && (source.overzoom || source.zoomExtent[1] > z2);
47982     };
47983     source.isLocatorOverlay = function() {
47984       return source.id === "mapbox_locator_overlay";
47985     };
47986     source.isHidden = function() {
47987       return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage";
47988     };
47989     source.copyrightNotices = function() {
47990     };
47991     source.getMetadata = function(center, tileCoord, callback) {
47992       var vintage = {
47993         start: localeDateString(source.startDate),
47994         end: localeDateString(source.endDate)
47995       };
47996       vintage.range = vintageRange(vintage);
47997       var metadata = { vintage };
47998       callback(null, metadata);
47999     };
48000     return source;
48001   }
48002   rendererBackgroundSource.Bing = function(data, dispatch14) {
48003     data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z";
48004     var bing = rendererBackgroundSource(data);
48005     var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
48006     const strictParam = "n";
48007     var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key;
48008     var cache = {};
48009     var inflight = {};
48010     var providers = [];
48011     var taskQueue = new IntervalTasksQueue(250);
48012     var metadataLastZoom = -1;
48013     json_default(url).then(function(json) {
48014       let imageryResource = json.resourceSets[0].resources[0];
48015       let template = imageryResource.imageUrl;
48016       let subDomains = imageryResource.imageUrlSubdomains;
48017       let subDomainNumbers = subDomains.map((subDomain) => {
48018         return subDomain.substring(1);
48019       }).join(",");
48020       template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}");
48021       if (!new URLSearchParams(template).has(strictParam)) {
48022         template += "&".concat(strictParam, "=z");
48023       }
48024       bing.template(template);
48025       providers = imageryResource.imageryProviders.map(function(provider) {
48026         return {
48027           attribution: provider.attribution,
48028           areas: provider.coverageAreas.map(function(area) {
48029             return {
48030               zoom: [area.zoomMin, area.zoomMax],
48031               extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
48032             };
48033           })
48034         };
48035       });
48036       dispatch14.call("change");
48037     }).catch(function() {
48038     });
48039     bing.copyrightNotices = function(zoom, extent) {
48040       zoom = Math.min(zoom, 21);
48041       return providers.filter(function(provider) {
48042         return provider.areas.some(function(area) {
48043           return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom;
48044         });
48045       }).map(function(provider) {
48046         return provider.attribution;
48047       }).join(", ");
48048     };
48049     bing.getMetadata = function(center, tileCoord, callback) {
48050       var tileID = tileCoord.slice(0, 3).join("/");
48051       var zoom = Math.min(tileCoord[2], 21);
48052       var centerPoint = center[1] + "," + center[0];
48053       var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key;
48054       if (inflight[tileID])
48055         return;
48056       if (!cache[tileID]) {
48057         cache[tileID] = {};
48058       }
48059       if (cache[tileID] && cache[tileID].metadata) {
48060         return callback(null, cache[tileID].metadata);
48061       }
48062       inflight[tileID] = true;
48063       if (metadataLastZoom !== tileCoord[2]) {
48064         metadataLastZoom = tileCoord[2];
48065         taskQueue.clear();
48066       }
48067       taskQueue.enqueue(() => {
48068         json_default(url2).then(function(result) {
48069           delete inflight[tileID];
48070           if (!result) {
48071             throw new Error("Unknown Error");
48072           }
48073           var vintage = {
48074             start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
48075             end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
48076           };
48077           vintage.range = vintageRange(vintage);
48078           var metadata = { vintage };
48079           cache[tileID].metadata = metadata;
48080           if (callback)
48081             callback(null, metadata);
48082         }).catch(function(err) {
48083           delete inflight[tileID];
48084           if (callback)
48085             callback(err.message);
48086         });
48087       });
48088     };
48089     bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details";
48090     return bing;
48091   };
48092   rendererBackgroundSource.Esri = function(data) {
48093     if (data.template.match(/blankTile/) === null) {
48094       data.template = data.template + "?blankTile=false";
48095     }
48096     var esri = rendererBackgroundSource(data);
48097     var cache = {};
48098     var inflight = {};
48099     var _prevCenter;
48100     esri.fetchTilemap = function(center) {
48101       if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3)
48102         return;
48103       _prevCenter = center;
48104       var z2 = 20;
48105       var dummyUrl = esri.url([1, 2, 3]);
48106       var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2));
48107       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));
48108       var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8";
48109       json_default(tilemapUrl).then(function(tilemap) {
48110         if (!tilemap) {
48111           throw new Error("Unknown Error");
48112         }
48113         var hasTiles = true;
48114         for (var i3 = 0; i3 < tilemap.data.length; i3++) {
48115           if (!tilemap.data[i3]) {
48116             hasTiles = false;
48117             break;
48118           }
48119         }
48120         esri.zoomExtent[1] = hasTiles ? 22 : 19;
48121       }).catch(function() {
48122       });
48123     };
48124     esri.getMetadata = function(center, tileCoord, callback) {
48125       if (esri.id !== "EsriWorldImagery") {
48126         return callback(null, {});
48127       }
48128       var tileID = tileCoord.slice(0, 3).join("/");
48129       var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]);
48130       var centerPoint = center[0] + "," + center[1];
48131       var unknown = _t("info_panels.background.unknown");
48132       var vintage = {};
48133       var metadata = {};
48134       if (inflight[tileID])
48135         return;
48136       var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query";
48137       url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json";
48138       if (!cache[tileID]) {
48139         cache[tileID] = {};
48140       }
48141       if (cache[tileID] && cache[tileID].metadata) {
48142         return callback(null, cache[tileID].metadata);
48143       }
48144       inflight[tileID] = true;
48145       json_default(url).then(function(result) {
48146         delete inflight[tileID];
48147         result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0];
48148         if (!result) {
48149           throw new Error("Unknown Error");
48150         } else if (result.features && result.features.length < 1) {
48151           throw new Error("No Results");
48152         } else if (result.error && result.error.message) {
48153           throw new Error(result.error.message);
48154         }
48155         var captureDate = localeDateString(result.SRC_DATE2);
48156         vintage = {
48157           start: captureDate,
48158           end: captureDate,
48159           range: captureDate
48160         };
48161         metadata = {
48162           vintage,
48163           source: clean2(result.NICE_NAME),
48164           description: clean2(result.NICE_DESC),
48165           resolution: clean2(+Number(result.SRC_RES).toFixed(4)),
48166           accuracy: clean2(+Number(result.SRC_ACC).toFixed(4))
48167         };
48168         if (isFinite(metadata.resolution)) {
48169           metadata.resolution += " m";
48170         }
48171         if (isFinite(metadata.accuracy)) {
48172           metadata.accuracy += " m";
48173         }
48174         cache[tileID].metadata = metadata;
48175         if (callback)
48176           callback(null, metadata);
48177       }).catch(function(err) {
48178         delete inflight[tileID];
48179         if (callback)
48180           callback(err.message);
48181       });
48182       function clean2(val) {
48183         return String(val).trim() || unknown;
48184       }
48185     };
48186     return esri;
48187   };
48188   rendererBackgroundSource.None = function() {
48189     var source = rendererBackgroundSource({ id: "none", template: "" });
48190     source.name = function() {
48191       return _t("background.none");
48192     };
48193     source.label = function() {
48194       return _t.append("background.none");
48195     };
48196     source.imageryUsed = function() {
48197       return null;
48198     };
48199     source.area = function() {
48200       return -1;
48201     };
48202     return source;
48203   };
48204   rendererBackgroundSource.Custom = function(template) {
48205     var source = rendererBackgroundSource({ id: "custom", template });
48206     source.name = function() {
48207       return _t("background.custom");
48208     };
48209     source.label = function() {
48210       return _t.append("background.custom");
48211     };
48212     source.imageryUsed = function() {
48213       var cleaned = source.template();
48214       if (cleaned.indexOf("?") !== -1) {
48215         var parts = cleaned.split("?", 2);
48216         var qs = utilStringQs(parts[1]);
48217         ["access_token", "connectId", "token", "Signature"].forEach(function(param) {
48218           if (qs[param]) {
48219             qs[param] = "{apikey}";
48220           }
48221         });
48222         cleaned = parts[0] + "?" + utilQsString(qs, true);
48223       }
48224       cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}");
48225       return "Custom (" + cleaned + " )";
48226     };
48227     source.area = function() {
48228       return -2;
48229     };
48230     return source;
48231   };
48232
48233   // node_modules/@turf/helpers/dist/es/index.js
48234   var earthRadius = 63710088e-1;
48235   var factors = {
48236     centimeters: earthRadius * 100,
48237     centimetres: earthRadius * 100,
48238     degrees: earthRadius / 111325,
48239     feet: earthRadius * 3.28084,
48240     inches: earthRadius * 39.37,
48241     kilometers: earthRadius / 1e3,
48242     kilometres: earthRadius / 1e3,
48243     meters: earthRadius,
48244     metres: earthRadius,
48245     miles: earthRadius / 1609.344,
48246     millimeters: earthRadius * 1e3,
48247     millimetres: earthRadius * 1e3,
48248     nauticalmiles: earthRadius / 1852,
48249     radians: 1,
48250     yards: earthRadius * 1.0936
48251   };
48252   var unitsFactors = {
48253     centimeters: 100,
48254     centimetres: 100,
48255     degrees: 1 / 111325,
48256     feet: 3.28084,
48257     inches: 39.37,
48258     kilometers: 1 / 1e3,
48259     kilometres: 1 / 1e3,
48260     meters: 1,
48261     metres: 1,
48262     miles: 1 / 1609.344,
48263     millimeters: 1e3,
48264     millimetres: 1e3,
48265     nauticalmiles: 1 / 1852,
48266     radians: 1 / earthRadius,
48267     yards: 1.0936133
48268   };
48269   function feature2(geom, properties, options2) {
48270     if (options2 === void 0) {
48271       options2 = {};
48272     }
48273     var feat = { type: "Feature" };
48274     if (options2.id === 0 || options2.id) {
48275       feat.id = options2.id;
48276     }
48277     if (options2.bbox) {
48278       feat.bbox = options2.bbox;
48279     }
48280     feat.properties = properties || {};
48281     feat.geometry = geom;
48282     return feat;
48283   }
48284   function polygon(coordinates, properties, options2) {
48285     if (options2 === void 0) {
48286       options2 = {};
48287     }
48288     for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
48289       var ring = coordinates_1[_i];
48290       if (ring.length < 4) {
48291         throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
48292       }
48293       for (var j2 = 0; j2 < ring[ring.length - 1].length; j2++) {
48294         if (ring[ring.length - 1][j2] !== ring[0][j2]) {
48295           throw new Error("First and last Position are not equivalent.");
48296         }
48297       }
48298     }
48299     var geom = {
48300       type: "Polygon",
48301       coordinates
48302     };
48303     return feature2(geom, properties, options2);
48304   }
48305   function lineString(coordinates, properties, options2) {
48306     if (options2 === void 0) {
48307       options2 = {};
48308     }
48309     if (coordinates.length < 2) {
48310       throw new Error("coordinates must be an array of two or more positions");
48311     }
48312     var geom = {
48313       type: "LineString",
48314       coordinates
48315     };
48316     return feature2(geom, properties, options2);
48317   }
48318   function multiLineString(coordinates, properties, options2) {
48319     if (options2 === void 0) {
48320       options2 = {};
48321     }
48322     var geom = {
48323       type: "MultiLineString",
48324       coordinates
48325     };
48326     return feature2(geom, properties, options2);
48327   }
48328   function multiPolygon(coordinates, properties, options2) {
48329     if (options2 === void 0) {
48330       options2 = {};
48331     }
48332     var geom = {
48333       type: "MultiPolygon",
48334       coordinates
48335     };
48336     return feature2(geom, properties, options2);
48337   }
48338
48339   // node_modules/@turf/invariant/dist/es/index.js
48340   function getGeom(geojson) {
48341     if (geojson.type === "Feature") {
48342       return geojson.geometry;
48343     }
48344     return geojson;
48345   }
48346
48347   // node_modules/@turf/bbox-clip/dist/es/lib/lineclip.js
48348   function lineclip(points, bbox2, result) {
48349     var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode;
48350     var a2;
48351     var b2;
48352     if (!result)
48353       result = [];
48354     for (i3 = 1; i3 < len; i3++) {
48355       a2 = points[i3 - 1];
48356       b2 = points[i3];
48357       codeB = lastCode = bitCode(b2, bbox2);
48358       while (true) {
48359         if (!(codeA | codeB)) {
48360           part.push(a2);
48361           if (codeB !== lastCode) {
48362             part.push(b2);
48363             if (i3 < len - 1) {
48364               result.push(part);
48365               part = [];
48366             }
48367           } else if (i3 === len - 1) {
48368             part.push(b2);
48369           }
48370           break;
48371         } else if (codeA & codeB) {
48372           break;
48373         } else if (codeA) {
48374           a2 = intersect(a2, b2, codeA, bbox2);
48375           codeA = bitCode(a2, bbox2);
48376         } else {
48377           b2 = intersect(a2, b2, codeB, bbox2);
48378           codeB = bitCode(b2, bbox2);
48379         }
48380       }
48381       codeA = lastCode;
48382     }
48383     if (part.length)
48384       result.push(part);
48385     return result;
48386   }
48387   function polygonclip(points, bbox2) {
48388     var result, edge, prev, prevInside, i3, p2, inside;
48389     for (edge = 1; edge <= 8; edge *= 2) {
48390       result = [];
48391       prev = points[points.length - 1];
48392       prevInside = !(bitCode(prev, bbox2) & edge);
48393       for (i3 = 0; i3 < points.length; i3++) {
48394         p2 = points[i3];
48395         inside = !(bitCode(p2, bbox2) & edge);
48396         if (inside !== prevInside)
48397           result.push(intersect(prev, p2, edge, bbox2));
48398         if (inside)
48399           result.push(p2);
48400         prev = p2;
48401         prevInside = inside;
48402       }
48403       points = result;
48404       if (!points.length)
48405         break;
48406     }
48407     return result;
48408   }
48409   function intersect(a2, b2, edge, bbox2) {
48410     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;
48411   }
48412   function bitCode(p2, bbox2) {
48413     var code = 0;
48414     if (p2[0] < bbox2[0])
48415       code |= 1;
48416     else if (p2[0] > bbox2[2])
48417       code |= 2;
48418     if (p2[1] < bbox2[1])
48419       code |= 4;
48420     else if (p2[1] > bbox2[3])
48421       code |= 8;
48422     return code;
48423   }
48424
48425   // node_modules/@turf/bbox-clip/dist/es/index.js
48426   function bboxClip(feature3, bbox2) {
48427     var geom = getGeom(feature3);
48428     var type2 = geom.type;
48429     var properties = feature3.type === "Feature" ? feature3.properties : {};
48430     var coords = geom.coordinates;
48431     switch (type2) {
48432       case "LineString":
48433       case "MultiLineString": {
48434         var lines_1 = [];
48435         if (type2 === "LineString") {
48436           coords = [coords];
48437         }
48438         coords.forEach(function(line) {
48439           lineclip(line, bbox2, lines_1);
48440         });
48441         if (lines_1.length === 1) {
48442           return lineString(lines_1[0], properties);
48443         }
48444         return multiLineString(lines_1, properties);
48445       }
48446       case "Polygon":
48447         return polygon(clipPolygon(coords, bbox2), properties);
48448       case "MultiPolygon":
48449         return multiPolygon(coords.map(function(poly) {
48450           return clipPolygon(poly, bbox2);
48451         }), properties);
48452       default:
48453         throw new Error("geometry " + type2 + " not supported");
48454     }
48455   }
48456   function clipPolygon(rings, bbox2) {
48457     var outRings = [];
48458     for (var _i = 0, rings_1 = rings; _i < rings_1.length; _i++) {
48459       var ring = rings_1[_i];
48460       var clipped = polygonclip(ring, bbox2);
48461       if (clipped.length > 0) {
48462         if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
48463           clipped.push(clipped[0]);
48464         }
48465         if (clipped.length >= 4) {
48466           outRings.push(clipped);
48467         }
48468       }
48469     }
48470     return outRings;
48471   }
48472
48473   // node_modules/@turf/meta/dist/es/index.js
48474   function coordEach(geojson, callback, excludeWrapCoord) {
48475     if (geojson === null)
48476       return;
48477     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;
48478     for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
48479       geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
48480       isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
48481       stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
48482       for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
48483         var multiFeatureIndex = 0;
48484         var geometryIndex = 0;
48485         geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
48486         if (geometry === null)
48487           continue;
48488         coords = geometry.coordinates;
48489         var geomType = geometry.type;
48490         wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
48491         switch (geomType) {
48492           case null:
48493             break;
48494           case "Point":
48495             if (callback(
48496               coords,
48497               coordIndex,
48498               featureIndex,
48499               multiFeatureIndex,
48500               geometryIndex
48501             ) === false)
48502               return false;
48503             coordIndex++;
48504             multiFeatureIndex++;
48505             break;
48506           case "LineString":
48507           case "MultiPoint":
48508             for (j2 = 0; j2 < coords.length; j2++) {
48509               if (callback(
48510                 coords[j2],
48511                 coordIndex,
48512                 featureIndex,
48513                 multiFeatureIndex,
48514                 geometryIndex
48515               ) === false)
48516                 return false;
48517               coordIndex++;
48518               if (geomType === "MultiPoint")
48519                 multiFeatureIndex++;
48520             }
48521             if (geomType === "LineString")
48522               multiFeatureIndex++;
48523             break;
48524           case "Polygon":
48525           case "MultiLineString":
48526             for (j2 = 0; j2 < coords.length; j2++) {
48527               for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) {
48528                 if (callback(
48529                   coords[j2][k2],
48530                   coordIndex,
48531                   featureIndex,
48532                   multiFeatureIndex,
48533                   geometryIndex
48534                 ) === false)
48535                   return false;
48536                 coordIndex++;
48537               }
48538               if (geomType === "MultiLineString")
48539                 multiFeatureIndex++;
48540               if (geomType === "Polygon")
48541                 geometryIndex++;
48542             }
48543             if (geomType === "Polygon")
48544               multiFeatureIndex++;
48545             break;
48546           case "MultiPolygon":
48547             for (j2 = 0; j2 < coords.length; j2++) {
48548               geometryIndex = 0;
48549               for (k2 = 0; k2 < coords[j2].length; k2++) {
48550                 for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) {
48551                   if (callback(
48552                     coords[j2][k2][l2],
48553                     coordIndex,
48554                     featureIndex,
48555                     multiFeatureIndex,
48556                     geometryIndex
48557                   ) === false)
48558                     return false;
48559                   coordIndex++;
48560                 }
48561                 geometryIndex++;
48562               }
48563               multiFeatureIndex++;
48564             }
48565             break;
48566           case "GeometryCollection":
48567             for (j2 = 0; j2 < geometry.geometries.length; j2++)
48568               if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false)
48569                 return false;
48570             break;
48571           default:
48572             throw new Error("Unknown Geometry Type");
48573         }
48574       }
48575     }
48576   }
48577
48578   // node_modules/@turf/bbox/dist/es/index.js
48579   function bbox(geojson) {
48580     var result = [Infinity, Infinity, -Infinity, -Infinity];
48581     coordEach(geojson, function(coord2) {
48582       if (result[0] > coord2[0]) {
48583         result[0] = coord2[0];
48584       }
48585       if (result[1] > coord2[1]) {
48586         result[1] = coord2[1];
48587       }
48588       if (result[2] < coord2[0]) {
48589         result[2] = coord2[0];
48590       }
48591       if (result[3] < coord2[1]) {
48592         result[3] = coord2[1];
48593       }
48594     });
48595     return result;
48596   }
48597   bbox["default"] = bbox;
48598   var es_default = bbox;
48599
48600   // modules/renderer/background.js
48601   var import_which_polygon3 = __toESM(require_which_polygon());
48602
48603   // modules/renderer/tile_layer.js
48604   function rendererTileLayer(context) {
48605     var transformProp = utilPrefixCSSProperty("Transform");
48606     var tiler9 = utilTiler();
48607     var _tileSize = 256;
48608     var _projection;
48609     var _cache5 = {};
48610     var _tileOrigin;
48611     var _zoom;
48612     var _source;
48613     function tileSizeAtZoom(d2, z2) {
48614       var EPSILON = 2e-3;
48615       return _tileSize * Math.pow(2, z2 - d2[2]) / _tileSize + EPSILON;
48616     }
48617     function atZoom(t2, distance) {
48618       var power = Math.pow(2, distance);
48619       return [
48620         Math.floor(t2[0] * power),
48621         Math.floor(t2[1] * power),
48622         t2[2] + distance
48623       ];
48624     }
48625     function lookUp(d2) {
48626       for (var up = -1; up > -d2[2]; up--) {
48627         var tile = atZoom(d2, up);
48628         if (_cache5[_source.url(tile)] !== false) {
48629           return tile;
48630         }
48631       }
48632     }
48633     function uniqueBy(a2, n3) {
48634       var o2 = [];
48635       var seen = {};
48636       for (var i3 = 0; i3 < a2.length; i3++) {
48637         if (seen[a2[i3][n3]] === void 0) {
48638           o2.push(a2[i3]);
48639           seen[a2[i3][n3]] = true;
48640         }
48641       }
48642       return o2;
48643     }
48644     function addSource(d2) {
48645       d2.push(_source.url(d2));
48646       return d2;
48647     }
48648     function background(selection2) {
48649       _zoom = geoScaleToZoom(_projection.scale(), _tileSize);
48650       var pixelOffset;
48651       if (_source) {
48652         pixelOffset = [
48653           _source.offset()[0] * Math.pow(2, _zoom),
48654           _source.offset()[1] * Math.pow(2, _zoom)
48655         ];
48656       } else {
48657         pixelOffset = [0, 0];
48658       }
48659       var translate = [
48660         _projection.translate()[0] + pixelOffset[0],
48661         _projection.translate()[1] + pixelOffset[1]
48662       ];
48663       tiler9.scale(_projection.scale() * 2 * Math.PI).translate(translate);
48664       _tileOrigin = [
48665         _projection.scale() * Math.PI - translate[0],
48666         _projection.scale() * Math.PI - translate[1]
48667       ];
48668       render(selection2);
48669     }
48670     function render(selection2) {
48671       if (!_source)
48672         return;
48673       var requests = [];
48674       var showDebug = context.getDebug("tile") && !_source.overlay;
48675       if (_source.validZoom(_zoom)) {
48676         tiler9.skipNullIsland(!!_source.overlay);
48677         tiler9().forEach(function(d2) {
48678           addSource(d2);
48679           if (d2[3] === "")
48680             return;
48681           if (typeof d2[3] !== "string")
48682             return;
48683           requests.push(d2);
48684           if (_cache5[d2[3]] === false && lookUp(d2)) {
48685             requests.push(addSource(lookUp(d2)));
48686           }
48687         });
48688         requests = uniqueBy(requests, 3).filter(function(r2) {
48689           return _cache5[r2[3]] !== false;
48690         });
48691       }
48692       function load(d3_event, d2) {
48693         _cache5[d2[3]] = true;
48694         select_default2(this).on("error", null).on("load", null).classed("tile-loaded", true);
48695         render(selection2);
48696       }
48697       function error(d3_event, d2) {
48698         _cache5[d2[3]] = false;
48699         select_default2(this).on("error", null).on("load", null).remove();
48700         render(selection2);
48701       }
48702       function imageTransform(d2) {
48703         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48704         var scale = tileSizeAtZoom(d2, _zoom);
48705         return "translate(" + (d2[0] * ts - _tileOrigin[0]) + "px," + (d2[1] * ts - _tileOrigin[1]) + "px) scale(" + scale + "," + scale + ")";
48706       }
48707       function tileCenter(d2) {
48708         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48709         return [
48710           d2[0] * ts - _tileOrigin[0] + ts / 2,
48711           d2[1] * ts - _tileOrigin[1] + ts / 2
48712         ];
48713       }
48714       function debugTransform(d2) {
48715         var coord2 = tileCenter(d2);
48716         return "translate(" + coord2[0] + "px," + coord2[1] + "px)";
48717       }
48718       var dims = tiler9.size();
48719       var mapCenter = [dims[0] / 2, dims[1] / 2];
48720       var minDist = Math.max(dims[0], dims[1]);
48721       var nearCenter;
48722       requests.forEach(function(d2) {
48723         var c2 = tileCenter(d2);
48724         var dist = geoVecLength(c2, mapCenter);
48725         if (dist < minDist) {
48726           minDist = dist;
48727           nearCenter = d2;
48728         }
48729       });
48730       var image = selection2.selectAll("img").data(requests, function(d2) {
48731         return d2[3];
48732       });
48733       image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).each(function() {
48734         var tile = select_default2(this);
48735         window.setTimeout(function() {
48736           if (tile.classed("tile-removing")) {
48737             tile.remove();
48738           }
48739         }, 300);
48740       });
48741       image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) {
48742         return d2[3];
48743       }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) {
48744         return d2 === nearCenter;
48745       });
48746       var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) {
48747         return d2[3];
48748       });
48749       debug2.exit().remove();
48750       if (showDebug) {
48751         var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug");
48752         debugEnter.append("div").attr("class", "tile-label-debug-coord");
48753         debugEnter.append("div").attr("class", "tile-label-debug-vintage");
48754         debug2 = debug2.merge(debugEnter);
48755         debug2.style(transformProp, debugTransform);
48756         debug2.selectAll(".tile-label-debug-coord").text(function(d2) {
48757           return d2[2] + " / " + d2[0] + " / " + d2[1];
48758         });
48759         debug2.selectAll(".tile-label-debug-vintage").each(function(d2) {
48760           var span = select_default2(this);
48761           var center = context.projection.invert(tileCenter(d2));
48762           _source.getMetadata(center, d2, function(err, result) {
48763             if (result && result.vintage && result.vintage.range) {
48764               span.text(result.vintage.range);
48765             } else {
48766               span.text("");
48767               span.call(_t.append("info_panels.background.vintage"));
48768               span.append("span").text(": ");
48769               span.call(_t.append("info_panels.background.unknown"));
48770             }
48771           });
48772         });
48773       }
48774     }
48775     background.projection = function(val) {
48776       if (!arguments.length)
48777         return _projection;
48778       _projection = val;
48779       return background;
48780     };
48781     background.dimensions = function(val) {
48782       if (!arguments.length)
48783         return tiler9.size();
48784       tiler9.size(val);
48785       return background;
48786     };
48787     background.source = function(val) {
48788       if (!arguments.length)
48789         return _source;
48790       _source = val;
48791       _tileSize = _source.tileSize;
48792       _cache5 = {};
48793       tiler9.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
48794       return background;
48795     };
48796     return background;
48797   }
48798
48799   // modules/renderer/background.js
48800   var _imageryIndex = null;
48801   function rendererBackground(context) {
48802     const dispatch14 = dispatch_default("change");
48803     const baseLayer = rendererTileLayer(context).projection(context.projection);
48804     let _checkedBlocklists = [];
48805     let _isValid = true;
48806     let _overlayLayers = [];
48807     let _brightness = 1;
48808     let _contrast = 1;
48809     let _saturation = 1;
48810     let _sharpness = 1;
48811     function ensureImageryIndex() {
48812       return _mainFileFetcher.get("imagery").then((sources) => {
48813         if (_imageryIndex)
48814           return _imageryIndex;
48815         _imageryIndex = {
48816           imagery: sources,
48817           features: {}
48818         };
48819         const features = sources.map((source) => {
48820           if (!source.polygon)
48821             return null;
48822           const rings = source.polygon.map((ring) => [ring]);
48823           const feature3 = {
48824             type: "Feature",
48825             properties: { id: source.id },
48826             geometry: { type: "MultiPolygon", coordinates: rings }
48827           };
48828           _imageryIndex.features[source.id] = feature3;
48829           return feature3;
48830         }).filter(Boolean);
48831         _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features });
48832         _imageryIndex.backgrounds = sources.map((source) => {
48833           if (source.type === "bing") {
48834             return rendererBackgroundSource.Bing(source, dispatch14);
48835           } else if (/^EsriWorldImagery/.test(source.id)) {
48836             return rendererBackgroundSource.Esri(source);
48837           } else {
48838             return rendererBackgroundSource(source);
48839           }
48840         });
48841         _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None());
48842         let template = corePreferences("background-custom-template") || "";
48843         const custom = rendererBackgroundSource.Custom(template);
48844         _imageryIndex.backgrounds.unshift(custom);
48845         return _imageryIndex;
48846       });
48847     }
48848     function background(selection2) {
48849       const currSource = baseLayer.source();
48850       if (context.map().zoom() > 18) {
48851         if (currSource && /^EsriWorldImagery/.test(currSource.id)) {
48852           const center = context.map().center();
48853           currSource.fetchTilemap(center);
48854         }
48855       }
48856       const sources = background.sources(context.map().extent());
48857       const wasValid = _isValid;
48858       _isValid = !!sources.filter((d2) => d2 === currSource).length;
48859       if (wasValid !== _isValid) {
48860         background.updateImagery();
48861       }
48862       let baseFilter = "";
48863       if (_brightness !== 1) {
48864         baseFilter += " brightness(".concat(_brightness, ")");
48865       }
48866       if (_contrast !== 1) {
48867         baseFilter += " contrast(".concat(_contrast, ")");
48868       }
48869       if (_saturation !== 1) {
48870         baseFilter += " saturate(".concat(_saturation, ")");
48871       }
48872       if (_sharpness < 1) {
48873         const blur = number_default(0.5, 5)(1 - _sharpness);
48874         baseFilter += " blur(".concat(blur, "px)");
48875       }
48876       let base = selection2.selectAll(".layer-background").data([0]);
48877       base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base);
48878       base.style("filter", baseFilter || null);
48879       let imagery = base.selectAll(".layer-imagery").data([0]);
48880       imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer);
48881       let maskFilter = "";
48882       let mixBlendMode = "";
48883       if (_sharpness > 1) {
48884         mixBlendMode = "overlay";
48885         maskFilter = "saturate(0) blur(3px) invert(1)";
48886         let contrast = _sharpness - 1;
48887         maskFilter += " contrast(".concat(contrast, ")");
48888         let brightness = number_default(1, 0.85)(_sharpness - 1);
48889         maskFilter += " brightness(".concat(brightness, ")");
48890       }
48891       let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []);
48892       mask.exit().remove();
48893       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);
48894       let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name());
48895       overlays.exit().remove();
48896       overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer));
48897     }
48898     background.updateImagery = function() {
48899       let currSource = baseLayer.source();
48900       if (context.inIntro() || !currSource)
48901         return;
48902       let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(",");
48903       const meters = geoOffsetToMeters(currSource.offset());
48904       const EPSILON = 0.01;
48905       const x2 = +meters[0].toFixed(2);
48906       const y2 = +meters[1].toFixed(2);
48907       let hash = utilStringQs(window.location.hash);
48908       let id2 = currSource.id;
48909       if (id2 === "custom") {
48910         id2 = "custom:".concat(currSource.template());
48911       }
48912       if (id2) {
48913         hash.background = id2;
48914       } else {
48915         delete hash.background;
48916       }
48917       if (o2) {
48918         hash.overlays = o2;
48919       } else {
48920         delete hash.overlays;
48921       }
48922       if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) {
48923         hash.offset = "".concat(x2, ",").concat(y2);
48924       } else {
48925         delete hash.offset;
48926       }
48927       if (!window.mocha) {
48928         window.location.replace("#" + utilQsString(hash, true));
48929       }
48930       let imageryUsed = [];
48931       let photoOverlaysUsed = [];
48932       const currUsed = currSource.imageryUsed();
48933       if (currUsed && _isValid) {
48934         imageryUsed.push(currUsed);
48935       }
48936       _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed()));
48937       const dataLayer = context.layers().layer("data");
48938       if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) {
48939         imageryUsed.push(dataLayer.getSrc());
48940       }
48941       const photoOverlayLayers = {
48942         streetside: "Bing Streetside",
48943         mapillary: "Mapillary Images",
48944         "mapillary-map-features": "Mapillary Map Features",
48945         "mapillary-signs": "Mapillary Signs",
48946         kartaview: "KartaView Images",
48947         vegbilder: "Norwegian Road Administration Images",
48948         mapilio: "Mapilio Images"
48949       };
48950       for (let layerID in photoOverlayLayers) {
48951         const layer = context.layers().layer(layerID);
48952         if (layer && layer.enabled()) {
48953           photoOverlaysUsed.push(layerID);
48954           imageryUsed.push(photoOverlayLayers[layerID]);
48955         }
48956       }
48957       context.history().imageryUsed(imageryUsed);
48958       context.history().photoOverlaysUsed(photoOverlaysUsed);
48959     };
48960     background.sources = (extent, zoom, includeCurrent) => {
48961       if (!_imageryIndex)
48962         return [];
48963       let visible = {};
48964       (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true);
48965       const currSource = baseLayer.source();
48966       const osm = context.connection();
48967       const blocklists = osm && osm.imageryBlocklists() || [];
48968       const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]);
48969       if (blocklistChanged) {
48970         _imageryIndex.backgrounds.forEach((source) => {
48971           source.isBlocked = blocklists.some((regex) => regex.test(source.template()));
48972         });
48973         _checkedBlocklists = blocklists.map((regex) => String(regex));
48974       }
48975       return _imageryIndex.backgrounds.filter((source) => {
48976         if (includeCurrent && currSource === source)
48977           return true;
48978         if (source.isBlocked)
48979           return false;
48980         if (!source.polygon)
48981           return true;
48982         if (zoom && zoom < 6)
48983           return false;
48984         return visible[source.id];
48985       });
48986     };
48987     background.dimensions = (val) => {
48988       if (!val)
48989         return;
48990       baseLayer.dimensions(val);
48991       _overlayLayers.forEach((layer) => layer.dimensions(val));
48992     };
48993     background.baseLayerSource = function(d2) {
48994       if (!arguments.length)
48995         return baseLayer.source();
48996       const osm = context.connection();
48997       if (!osm)
48998         return background;
48999       const blocklists = osm.imageryBlocklists();
49000       const template = d2.template();
49001       let fail = false;
49002       let tested = 0;
49003       let regex;
49004       for (let i3 = 0; i3 < blocklists.length; i3++) {
49005         regex = blocklists[i3];
49006         fail = regex.test(template);
49007         tested++;
49008         if (fail)
49009           break;
49010       }
49011       if (!tested) {
49012         regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
49013         fail = regex.test(template);
49014       }
49015       baseLayer.source(!fail ? d2 : background.findSource("none"));
49016       dispatch14.call("change");
49017       background.updateImagery();
49018       return background;
49019     };
49020     background.findSource = (id2) => {
49021       if (!id2 || !_imageryIndex)
49022         return null;
49023       return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2);
49024     };
49025     background.bing = () => {
49026       background.baseLayerSource(background.findSource("Bing"));
49027     };
49028     background.showsLayer = (d2) => {
49029       const currSource = baseLayer.source();
49030       if (!d2 || !currSource)
49031         return false;
49032       return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id);
49033     };
49034     background.overlayLayerSources = () => {
49035       return _overlayLayers.map((layer) => layer.source());
49036     };
49037     background.toggleOverlayLayer = (d2) => {
49038       let layer;
49039       for (let i3 = 0; i3 < _overlayLayers.length; i3++) {
49040         layer = _overlayLayers[i3];
49041         if (layer.source() === d2) {
49042           _overlayLayers.splice(i3, 1);
49043           dispatch14.call("change");
49044           background.updateImagery();
49045           return;
49046         }
49047       }
49048       layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions(
49049         baseLayer.dimensions()
49050       );
49051       _overlayLayers.push(layer);
49052       dispatch14.call("change");
49053       background.updateImagery();
49054     };
49055     background.nudge = (d2, zoom) => {
49056       const currSource = baseLayer.source();
49057       if (currSource) {
49058         currSource.nudge(d2, zoom);
49059         dispatch14.call("change");
49060         background.updateImagery();
49061       }
49062       return background;
49063     };
49064     background.offset = function(d2) {
49065       const currSource = baseLayer.source();
49066       if (!arguments.length) {
49067         return currSource && currSource.offset() || [0, 0];
49068       }
49069       if (currSource) {
49070         currSource.offset(d2);
49071         dispatch14.call("change");
49072         background.updateImagery();
49073       }
49074       return background;
49075     };
49076     background.brightness = function(d2) {
49077       if (!arguments.length)
49078         return _brightness;
49079       _brightness = d2;
49080       if (context.mode())
49081         dispatch14.call("change");
49082       return background;
49083     };
49084     background.contrast = function(d2) {
49085       if (!arguments.length)
49086         return _contrast;
49087       _contrast = d2;
49088       if (context.mode())
49089         dispatch14.call("change");
49090       return background;
49091     };
49092     background.saturation = function(d2) {
49093       if (!arguments.length)
49094         return _saturation;
49095       _saturation = d2;
49096       if (context.mode())
49097         dispatch14.call("change");
49098       return background;
49099     };
49100     background.sharpness = function(d2) {
49101       if (!arguments.length)
49102         return _sharpness;
49103       _sharpness = d2;
49104       if (context.mode())
49105         dispatch14.call("change");
49106       return background;
49107     };
49108     let _loadPromise;
49109     background.ensureLoaded = () => {
49110       if (_loadPromise)
49111         return _loadPromise;
49112       return _loadPromise = ensureImageryIndex();
49113     };
49114     background.init = () => {
49115       const loadPromise = background.ensureLoaded();
49116       const hash = utilStringQs(window.location.hash);
49117       const requestedBackground = hash.background || hash.layer;
49118       const lastUsedBackground = corePreferences("background-last-used");
49119       return loadPromise.then((imageryIndex) => {
49120         const extent = context.map().extent();
49121         const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom");
49122         const first = validBackgrounds.length && validBackgrounds[0];
49123         const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground);
49124         let best;
49125         if (!requestedBackground && extent) {
49126           const viewArea = extent.area();
49127           best = validBackgrounds.find((s2) => {
49128             if (!s2.best() || s2.overlay)
49129               return false;
49130             let bbox2 = es_default(bboxClip(
49131               { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] },
49132               extent.rectangle()
49133             ));
49134             let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area();
49135             return area / viewArea > 0.5;
49136           });
49137         }
49138         if (requestedBackground && requestedBackground.indexOf("custom:") === 0) {
49139           const template = requestedBackground.replace(/^custom:/, "");
49140           const custom = background.findSource("custom");
49141           background.baseLayerSource(custom.template(template));
49142           corePreferences("background-custom-template", template);
49143         } else {
49144           background.baseLayerSource(
49145             background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none")
49146           );
49147         }
49148         const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default);
49149         if (locator) {
49150           background.toggleOverlayLayer(locator);
49151         }
49152         const overlays = (hash.overlays || "").split(",");
49153         overlays.forEach((overlay) => {
49154           overlay = background.findSource(overlay);
49155           if (overlay) {
49156             background.toggleOverlayLayer(overlay);
49157           }
49158         });
49159         if (hash.gpx) {
49160           const gpx2 = context.layers().layer("data");
49161           if (gpx2) {
49162             gpx2.url(hash.gpx, ".gpx");
49163           }
49164         }
49165         if (hash.offset) {
49166           const offset = hash.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3);
49167           if (offset.length === 2) {
49168             background.offset(geoMetersToOffset(offset));
49169           }
49170         }
49171       }).catch((err) => {
49172         console.error(err);
49173       });
49174     };
49175     return utilRebind(background, dispatch14, "on");
49176   }
49177
49178   // modules/renderer/features.js
49179   function rendererFeatures(context) {
49180     var dispatch14 = dispatch_default("change", "redraw");
49181     var features = utilRebind({}, dispatch14, "on");
49182     var _deferred2 = /* @__PURE__ */ new Set();
49183     var traffic_roads = {
49184       "motorway": true,
49185       "motorway_link": true,
49186       "trunk": true,
49187       "trunk_link": true,
49188       "primary": true,
49189       "primary_link": true,
49190       "secondary": true,
49191       "secondary_link": true,
49192       "tertiary": true,
49193       "tertiary_link": true,
49194       "residential": true,
49195       "unclassified": true,
49196       "living_street": true,
49197       "busway": true
49198     };
49199     var service_roads = {
49200       "service": true,
49201       "road": true,
49202       "track": true
49203     };
49204     var paths = {
49205       "path": true,
49206       "footway": true,
49207       "cycleway": true,
49208       "bridleway": true,
49209       "steps": true,
49210       "pedestrian": true
49211     };
49212     var _cullFactor = 1;
49213     var _cache5 = {};
49214     var _rules = {};
49215     var _stats = {};
49216     var _keys = [];
49217     var _hidden = [];
49218     var _forceVisible = {};
49219     function update() {
49220       if (!window.mocha) {
49221         var hash = utilStringQs(window.location.hash);
49222         var disabled = features.disabled();
49223         if (disabled.length) {
49224           hash.disable_features = disabled.join(",");
49225         } else {
49226           delete hash.disable_features;
49227         }
49228         window.location.replace("#" + utilQsString(hash, true));
49229         corePreferences("disabled-features", disabled.join(","));
49230       }
49231       _hidden = features.hidden();
49232       dispatch14.call("change");
49233       dispatch14.call("redraw");
49234     }
49235     function defineRule(k2, filter2, max3) {
49236       var isEnabled = true;
49237       _keys.push(k2);
49238       _rules[k2] = {
49239         filter: filter2,
49240         enabled: isEnabled,
49241         // whether the user wants it enabled..
49242         count: 0,
49243         currentMax: max3 || Infinity,
49244         defaultMax: max3 || Infinity,
49245         enable: function() {
49246           this.enabled = true;
49247           this.currentMax = this.defaultMax;
49248         },
49249         disable: function() {
49250           this.enabled = false;
49251           this.currentMax = 0;
49252         },
49253         hidden: function() {
49254           return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor;
49255         },
49256         autoHidden: function() {
49257           return this.hidden() && this.currentMax > 0;
49258         }
49259       };
49260     }
49261     defineRule("points", function isPoint(tags, geometry) {
49262       return geometry === "point";
49263     }, 200);
49264     defineRule("traffic_roads", function isTrafficRoad(tags) {
49265       return traffic_roads[tags.highway];
49266     });
49267     defineRule("service_roads", function isServiceRoad(tags) {
49268       return service_roads[tags.highway];
49269     });
49270     defineRule("paths", function isPath(tags) {
49271       return paths[tags.highway];
49272     });
49273     defineRule("buildings", function isBuilding(tags) {
49274       return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes";
49275     }, 250);
49276     defineRule("building_parts", function isBuildingPart(tags) {
49277       return tags["building:part"];
49278     });
49279     defineRule("indoor", function isIndoor(tags) {
49280       return tags.indoor;
49281     });
49282     defineRule("landuse", function isLanduse(tags, geometry) {
49283       return geometry === "area" && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags);
49284     });
49285     defineRule("boundaries", function isBoundary(tags, geometry) {
49286       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);
49287     });
49288     defineRule("water", function isWater(tags) {
49289       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";
49290     });
49291     defineRule("rail", function isRail(tags) {
49292       return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]);
49293     });
49294     defineRule("pistes", function isPiste(tags) {
49295       return tags["piste:type"];
49296     });
49297     defineRule("aerialways", function isPiste(tags) {
49298       return tags.aerialway && tags.aerialway !== "yes" && tags.aerialway !== "station";
49299     });
49300     defineRule("power", function isPower(tags) {
49301       return !!tags.power;
49302     });
49303     defineRule("past_future", function isPastFuture(tags) {
49304       if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) {
49305         return false;
49306       }
49307       var strings = Object.keys(tags);
49308       for (var i3 = 0; i3 < strings.length; i3++) {
49309         var s2 = strings[i3];
49310         if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[s2]])
49311           return true;
49312       }
49313       return false;
49314     });
49315     defineRule("others", function isOther(tags, geometry) {
49316       return geometry === "line" || geometry === "area";
49317     });
49318     features.features = function() {
49319       return _rules;
49320     };
49321     features.keys = function() {
49322       return _keys;
49323     };
49324     features.enabled = function(k2) {
49325       if (!arguments.length) {
49326         return _keys.filter(function(k3) {
49327           return _rules[k3].enabled;
49328         });
49329       }
49330       return _rules[k2] && _rules[k2].enabled;
49331     };
49332     features.disabled = function(k2) {
49333       if (!arguments.length) {
49334         return _keys.filter(function(k3) {
49335           return !_rules[k3].enabled;
49336         });
49337       }
49338       return _rules[k2] && !_rules[k2].enabled;
49339     };
49340     features.hidden = function(k2) {
49341       if (!arguments.length) {
49342         return _keys.filter(function(k3) {
49343           return _rules[k3].hidden();
49344         });
49345       }
49346       return _rules[k2] && _rules[k2].hidden();
49347     };
49348     features.autoHidden = function(k2) {
49349       if (!arguments.length) {
49350         return _keys.filter(function(k3) {
49351           return _rules[k3].autoHidden();
49352         });
49353       }
49354       return _rules[k2] && _rules[k2].autoHidden();
49355     };
49356     features.enable = function(k2) {
49357       if (_rules[k2] && !_rules[k2].enabled) {
49358         _rules[k2].enable();
49359         update();
49360       }
49361     };
49362     features.enableAll = function() {
49363       var didEnable = false;
49364       for (var k2 in _rules) {
49365         if (!_rules[k2].enabled) {
49366           didEnable = true;
49367           _rules[k2].enable();
49368         }
49369       }
49370       if (didEnable)
49371         update();
49372     };
49373     features.disable = function(k2) {
49374       if (_rules[k2] && _rules[k2].enabled) {
49375         _rules[k2].disable();
49376         update();
49377       }
49378     };
49379     features.disableAll = function() {
49380       var didDisable = false;
49381       for (var k2 in _rules) {
49382         if (_rules[k2].enabled) {
49383           didDisable = true;
49384           _rules[k2].disable();
49385         }
49386       }
49387       if (didDisable)
49388         update();
49389     };
49390     features.toggle = function(k2) {
49391       if (_rules[k2]) {
49392         (function(f2) {
49393           return f2.enabled ? f2.disable() : f2.enable();
49394         })(_rules[k2]);
49395         update();
49396       }
49397     };
49398     features.resetStats = function() {
49399       for (var i3 = 0; i3 < _keys.length; i3++) {
49400         _rules[_keys[i3]].count = 0;
49401       }
49402       dispatch14.call("change");
49403     };
49404     features.gatherStats = function(d2, resolver, dimensions) {
49405       var needsRedraw = false;
49406       var types = utilArrayGroupBy(d2, "type");
49407       var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49408       var currHidden, geometry, matches, i3, j2;
49409       for (i3 = 0; i3 < _keys.length; i3++) {
49410         _rules[_keys[i3]].count = 0;
49411       }
49412       _cullFactor = dimensions[0] * dimensions[1] / 1e6;
49413       for (i3 = 0; i3 < entities.length; i3++) {
49414         geometry = entities[i3].geometry(resolver);
49415         matches = Object.keys(features.getMatches(entities[i3], resolver, geometry));
49416         for (j2 = 0; j2 < matches.length; j2++) {
49417           _rules[matches[j2]].count++;
49418         }
49419       }
49420       currHidden = features.hidden();
49421       if (currHidden !== _hidden) {
49422         _hidden = currHidden;
49423         needsRedraw = true;
49424         dispatch14.call("change");
49425       }
49426       return needsRedraw;
49427     };
49428     features.stats = function() {
49429       for (var i3 = 0; i3 < _keys.length; i3++) {
49430         _stats[_keys[i3]] = _rules[_keys[i3]].count;
49431       }
49432       return _stats;
49433     };
49434     features.clear = function(d2) {
49435       for (var i3 = 0; i3 < d2.length; i3++) {
49436         features.clearEntity(d2[i3]);
49437       }
49438     };
49439     features.clearEntity = function(entity) {
49440       delete _cache5[osmEntity.key(entity)];
49441     };
49442     features.reset = function() {
49443       Array.from(_deferred2).forEach(function(handle) {
49444         window.cancelIdleCallback(handle);
49445         _deferred2.delete(handle);
49446       });
49447       _cache5 = {};
49448     };
49449     function relationShouldBeChecked(relation) {
49450       return relation.tags.type === "boundary";
49451     }
49452     features.getMatches = function(entity, resolver, geometry) {
49453       if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity))
49454         return {};
49455       var ent = osmEntity.key(entity);
49456       if (!_cache5[ent]) {
49457         _cache5[ent] = {};
49458       }
49459       if (!_cache5[ent].matches) {
49460         var matches = {};
49461         var hasMatch = false;
49462         for (var i3 = 0; i3 < _keys.length; i3++) {
49463           if (_keys[i3] === "others") {
49464             if (hasMatch)
49465               continue;
49466             if (entity.type === "way") {
49467               var parents = features.getParents(entity, resolver, geometry);
49468               if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations
49469               parents.length > 0 && parents.every(function(parent) {
49470                 return parent.tags.type === "boundary";
49471               })) {
49472                 var pkey = osmEntity.key(parents[0]);
49473                 if (_cache5[pkey] && _cache5[pkey].matches) {
49474                   matches = Object.assign({}, _cache5[pkey].matches);
49475                   continue;
49476                 }
49477               }
49478             }
49479           }
49480           if (_rules[_keys[i3]].filter(entity.tags, geometry)) {
49481             matches[_keys[i3]] = hasMatch = true;
49482           }
49483         }
49484         _cache5[ent].matches = matches;
49485       }
49486       return _cache5[ent].matches;
49487     };
49488     features.getParents = function(entity, resolver, geometry) {
49489       if (geometry === "point")
49490         return [];
49491       var ent = osmEntity.key(entity);
49492       if (!_cache5[ent]) {
49493         _cache5[ent] = {};
49494       }
49495       if (!_cache5[ent].parents) {
49496         var parents = [];
49497         if (geometry === "vertex") {
49498           parents = resolver.parentWays(entity);
49499         } else {
49500           parents = resolver.parentRelations(entity);
49501         }
49502         _cache5[ent].parents = parents;
49503       }
49504       return _cache5[ent].parents;
49505     };
49506     features.isHiddenPreset = function(preset, geometry) {
49507       if (!_hidden.length)
49508         return false;
49509       if (!preset.tags)
49510         return false;
49511       var test = preset.setTags({}, geometry);
49512       for (var key in _rules) {
49513         if (_rules[key].filter(test, geometry)) {
49514           if (_hidden.indexOf(key) !== -1) {
49515             return key;
49516           }
49517           return false;
49518         }
49519       }
49520       return false;
49521     };
49522     features.isHiddenFeature = function(entity, resolver, geometry) {
49523       if (!_hidden.length)
49524         return false;
49525       if (!entity.version)
49526         return false;
49527       if (_forceVisible[entity.id])
49528         return false;
49529       var matches = Object.keys(features.getMatches(entity, resolver, geometry));
49530       return matches.length && matches.every(function(k2) {
49531         return features.hidden(k2);
49532       });
49533     };
49534     features.isHiddenChild = function(entity, resolver, geometry) {
49535       if (!_hidden.length)
49536         return false;
49537       if (!entity.version || geometry === "point")
49538         return false;
49539       if (_forceVisible[entity.id])
49540         return false;
49541       var parents = features.getParents(entity, resolver, geometry);
49542       if (!parents.length)
49543         return false;
49544       for (var i3 = 0; i3 < parents.length; i3++) {
49545         if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) {
49546           return false;
49547         }
49548       }
49549       return true;
49550     };
49551     features.hasHiddenConnections = function(entity, resolver) {
49552       if (!_hidden.length)
49553         return false;
49554       var childNodes, connections;
49555       if (entity.type === "midpoint") {
49556         childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
49557         connections = [];
49558       } else {
49559         childNodes = entity.nodes ? resolver.childNodes(entity) : [];
49560         connections = features.getParents(entity, resolver, entity.geometry(resolver));
49561       }
49562       connections = childNodes.reduce(function(result, e3) {
49563         return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result;
49564       }, connections);
49565       return connections.some(function(e3) {
49566         return features.isHidden(e3, resolver, e3.geometry(resolver));
49567       });
49568     };
49569     features.isHidden = function(entity, resolver, geometry) {
49570       if (!_hidden.length)
49571         return false;
49572       if (!entity.version)
49573         return false;
49574       var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature;
49575       return fn(entity, resolver, geometry);
49576     };
49577     features.filter = function(d2, resolver) {
49578       if (!_hidden.length)
49579         return d2;
49580       var result = [];
49581       for (var i3 = 0; i3 < d2.length; i3++) {
49582         var entity = d2[i3];
49583         if (!features.isHidden(entity, resolver, entity.geometry(resolver))) {
49584           result.push(entity);
49585         }
49586       }
49587       return result;
49588     };
49589     features.forceVisible = function(entityIDs) {
49590       if (!arguments.length)
49591         return Object.keys(_forceVisible);
49592       _forceVisible = {};
49593       for (var i3 = 0; i3 < entityIDs.length; i3++) {
49594         _forceVisible[entityIDs[i3]] = true;
49595         var entity = context.hasEntity(entityIDs[i3]);
49596         if (entity && entity.type === "relation") {
49597           for (var j2 in entity.members) {
49598             _forceVisible[entity.members[j2].id] = true;
49599           }
49600         }
49601       }
49602       return features;
49603     };
49604     features.init = function() {
49605       var storage = corePreferences("disabled-features");
49606       if (storage) {
49607         var storageDisabled = storage.replace(/;/g, ",").split(",");
49608         storageDisabled.forEach(features.disable);
49609       }
49610       var hash = utilStringQs(window.location.hash);
49611       if (hash.disable_features) {
49612         var hashDisabled = hash.disable_features.replace(/;/g, ",").split(",");
49613         hashDisabled.forEach(features.disable);
49614       }
49615     };
49616     context.history().on("merge.features", function(newEntities) {
49617       if (!newEntities)
49618         return;
49619       var handle = window.requestIdleCallback(function() {
49620         var graph = context.graph();
49621         var types = utilArrayGroupBy(newEntities, "type");
49622         var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49623         for (var i3 = 0; i3 < entities.length; i3++) {
49624           var geometry = entities[i3].geometry(graph);
49625           features.getMatches(entities[i3], graph, geometry);
49626         }
49627       });
49628       _deferred2.add(handle);
49629     });
49630     return features;
49631   }
49632
49633   // modules/svg/areas.js
49634   var import_fast_deep_equal5 = __toESM(require_fast_deep_equal());
49635
49636   // modules/svg/helpers.js
49637   function svgPassiveVertex(node, graph, activeID) {
49638     if (!activeID)
49639       return 1;
49640     if (activeID === node.id)
49641       return 0;
49642     var parents = graph.parentWays(node);
49643     var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3;
49644     for (i3 = 0; i3 < parents.length; i3++) {
49645       nodes = parents[i3].nodes;
49646       isClosed = parents[i3].isClosed();
49647       for (j2 = 0; j2 < nodes.length; j2++) {
49648         if (nodes[j2] === node.id) {
49649           ix1 = j2 - 2;
49650           ix2 = j2 - 1;
49651           ix3 = j2 + 1;
49652           ix4 = j2 + 2;
49653           if (isClosed) {
49654             max3 = nodes.length - 1;
49655             if (ix1 < 0)
49656               ix1 = max3 + ix1;
49657             if (ix2 < 0)
49658               ix2 = max3 + ix2;
49659             if (ix3 > max3)
49660               ix3 = ix3 - max3;
49661             if (ix4 > max3)
49662               ix4 = ix4 - max3;
49663           }
49664           if (nodes[ix1] === activeID)
49665             return 0;
49666           else if (nodes[ix2] === activeID)
49667             return 2;
49668           else if (nodes[ix3] === activeID)
49669             return 2;
49670           else if (nodes[ix4] === activeID)
49671             return 0;
49672           else if (isClosed && nodes.indexOf(activeID) !== -1)
49673             return 0;
49674         }
49675       }
49676     }
49677     return 1;
49678   }
49679   function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) {
49680     return function(entity) {
49681       var i3 = 0;
49682       var offset = dt2;
49683       var segments = [];
49684       var clip = identity_default2().clipExtent(projection2.clipExtent()).stream;
49685       var coordinates = graph.childNodes(entity).map(function(n3) {
49686         return n3.loc;
49687       });
49688       var a2, b2;
49689       if (shouldReverse(entity)) {
49690         coordinates.reverse();
49691       }
49692       stream_default({
49693         type: "LineString",
49694         coordinates
49695       }, projection2.stream(clip({
49696         lineStart: function() {
49697         },
49698         lineEnd: function() {
49699           a2 = null;
49700         },
49701         point: function(x2, y2) {
49702           b2 = [x2, y2];
49703           if (a2) {
49704             var span = geoVecLength(a2, b2) - offset;
49705             if (span >= 0) {
49706               var heading2 = geoVecAngle(a2, b2);
49707               var dx = dt2 * Math.cos(heading2);
49708               var dy = dt2 * Math.sin(heading2);
49709               var p2 = [
49710                 a2[0] + offset * Math.cos(heading2),
49711                 a2[1] + offset * Math.sin(heading2)
49712               ];
49713               var coord2 = [a2, p2];
49714               for (span -= dt2; span >= 0; span -= dt2) {
49715                 p2 = geoVecAdd(p2, [dx, dy]);
49716                 coord2.push(p2);
49717               }
49718               coord2.push(b2);
49719               var segment = "";
49720               var j2;
49721               for (j2 = 0; j2 < coord2.length; j2++) {
49722                 segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49723               }
49724               segments.push({ id: entity.id, index: i3++, d: segment });
49725               if (bothDirections(entity)) {
49726                 segment = "";
49727                 for (j2 = coord2.length - 1; j2 >= 0; j2--) {
49728                   segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49729                 }
49730                 segments.push({ id: entity.id, index: i3++, d: segment });
49731               }
49732             }
49733             offset = -span;
49734           }
49735           a2 = b2;
49736         }
49737       })));
49738       return segments;
49739     };
49740   }
49741   function svgPath(projection2, graph, isArea) {
49742     var cache = {};
49743     var padding = isArea ? 65 : 5;
49744     var viewport = projection2.clipExtent();
49745     var paddedExtent = [
49746       [viewport[0][0] - padding, viewport[0][1] - padding],
49747       [viewport[1][0] + padding, viewport[1][1] + padding]
49748     ];
49749     var clip = identity_default2().clipExtent(paddedExtent).stream;
49750     var project = projection2.stream;
49751     var path = path_default().projection({ stream: function(output) {
49752       return project(clip(output));
49753     } });
49754     var svgpath = function(entity) {
49755       if (entity.id in cache) {
49756         return cache[entity.id];
49757       } else {
49758         return cache[entity.id] = path(entity.asGeoJSON(graph));
49759       }
49760     };
49761     svgpath.geojson = function(d2) {
49762       if (d2.__featurehash__ !== void 0) {
49763         if (d2.__featurehash__ in cache) {
49764           return cache[d2.__featurehash__];
49765         } else {
49766           return cache[d2.__featurehash__] = path(d2);
49767         }
49768       } else {
49769         return path(d2);
49770       }
49771     };
49772     return svgpath;
49773   }
49774   function svgPointTransform(projection2) {
49775     var svgpoint = function(entity) {
49776       var pt2 = projection2(entity.loc);
49777       return "translate(" + pt2[0] + "," + pt2[1] + ")";
49778     };
49779     svgpoint.geojson = function(d2) {
49780       return svgpoint(d2.properties.entity);
49781     };
49782     return svgpoint;
49783   }
49784   function svgRelationMemberTags(graph) {
49785     return function(entity) {
49786       var tags = entity.tags;
49787       var shouldCopyMultipolygonTags = !entity.hasInterestingTags();
49788       graph.parentRelations(entity).forEach(function(relation) {
49789         var type2 = relation.tags.type;
49790         if (type2 === "multipolygon" && shouldCopyMultipolygonTags || type2 === "boundary") {
49791           tags = Object.assign({}, relation.tags, tags);
49792         }
49793       });
49794       return tags;
49795     };
49796   }
49797   function svgSegmentWay(way, graph, activeID) {
49798     if (activeID === void 0) {
49799       return graph.transient(way, "waySegments", getWaySegments);
49800     } else {
49801       return getWaySegments();
49802     }
49803     function getWaySegments() {
49804       var isActiveWay = way.nodes.indexOf(activeID) !== -1;
49805       var features = { passive: [], active: [] };
49806       var start2 = {};
49807       var end = {};
49808       var node, type2;
49809       for (var i3 = 0; i3 < way.nodes.length; i3++) {
49810         node = graph.entity(way.nodes[i3]);
49811         type2 = svgPassiveVertex(node, graph, activeID);
49812         end = { node, type: type2 };
49813         if (start2.type !== void 0) {
49814           if (start2.node.id === activeID || end.node.id === activeID) {
49815           } else if (isActiveWay && (start2.type === 2 || end.type === 2)) {
49816             pushActive(start2, end, i3);
49817           } else if (start2.type === 0 && end.type === 0) {
49818             pushActive(start2, end, i3);
49819           } else {
49820             pushPassive(start2, end, i3);
49821           }
49822         }
49823         start2 = end;
49824       }
49825       return features;
49826       function pushActive(start3, end2, index) {
49827         features.active.push({
49828           type: "Feature",
49829           id: way.id + "-" + index + "-nope",
49830           properties: {
49831             nope: true,
49832             target: true,
49833             entity: way,
49834             nodes: [start3.node, end2.node],
49835             index
49836           },
49837           geometry: {
49838             type: "LineString",
49839             coordinates: [start3.node.loc, end2.node.loc]
49840           }
49841         });
49842       }
49843       function pushPassive(start3, end2, index) {
49844         features.passive.push({
49845           type: "Feature",
49846           id: way.id + "-" + index,
49847           properties: {
49848             target: true,
49849             entity: way,
49850             nodes: [start3.node, end2.node],
49851             index
49852           },
49853           geometry: {
49854             type: "LineString",
49855             coordinates: [start3.node.loc, end2.node.loc]
49856           }
49857         });
49858       }
49859     }
49860   }
49861
49862   // modules/svg/tag_classes.js
49863   function svgTagClasses() {
49864     var primaries = [
49865       "building",
49866       "highway",
49867       "railway",
49868       "waterway",
49869       "aeroway",
49870       "aerialway",
49871       "piste:type",
49872       "boundary",
49873       "power",
49874       "amenity",
49875       "natural",
49876       "landuse",
49877       "leisure",
49878       "military",
49879       "place",
49880       "man_made",
49881       "route",
49882       "attraction",
49883       "roller_coaster",
49884       "building:part",
49885       "indoor"
49886     ];
49887     var statuses = Object.keys(osmLifecyclePrefixes);
49888     var secondaries = [
49889       "oneway",
49890       "bridge",
49891       "tunnel",
49892       "embankment",
49893       "cutting",
49894       "barrier",
49895       "surface",
49896       "tracktype",
49897       "footway",
49898       "crossing",
49899       "service",
49900       "sport",
49901       "public_transport",
49902       "location",
49903       "parking",
49904       "golf",
49905       "type",
49906       "leisure",
49907       "man_made",
49908       "indoor",
49909       "construction",
49910       "proposed"
49911     ];
49912     var _tags = function(entity) {
49913       return entity.tags;
49914     };
49915     var tagClasses = function(selection2) {
49916       selection2.each(function tagClassesEach(entity) {
49917         var value = this.className;
49918         if (value.baseVal !== void 0) {
49919           value = value.baseVal;
49920         }
49921         var t2 = _tags(entity);
49922         var computed = tagClasses.getClassesString(t2, value);
49923         if (computed !== value) {
49924           select_default2(this).attr("class", computed);
49925         }
49926       });
49927     };
49928     tagClasses.getClassesString = function(t2, value) {
49929       var primary, status;
49930       var i3, j2, k2, v2;
49931       var overrideGeometry;
49932       if (/\bstroke\b/.test(value)) {
49933         if (!!t2.barrier && t2.barrier !== "no") {
49934           overrideGeometry = "line";
49935         }
49936       }
49937       var classes = value.trim().split(/\s+/).filter(function(klass) {
49938         return klass.length && !/^tag-/.test(klass);
49939       }).map(function(klass) {
49940         return klass === "line" || klass === "area" ? overrideGeometry || klass : klass;
49941       });
49942       for (i3 = 0; i3 < primaries.length; i3++) {
49943         k2 = primaries[i3];
49944         v2 = t2[k2];
49945         if (!v2 || v2 === "no")
49946           continue;
49947         if (k2 === "piste:type") {
49948           k2 = "piste";
49949         } else if (k2 === "building:part") {
49950           k2 = "building_part";
49951         }
49952         primary = k2;
49953         if (statuses.indexOf(v2) !== -1) {
49954           status = v2;
49955           classes.push("tag-" + k2);
49956         } else {
49957           classes.push("tag-" + k2);
49958           classes.push("tag-" + k2 + "-" + v2);
49959         }
49960         break;
49961       }
49962       if (!primary) {
49963         for (i3 = 0; i3 < statuses.length; i3++) {
49964           for (j2 = 0; j2 < primaries.length; j2++) {
49965             k2 = statuses[i3] + ":" + primaries[j2];
49966             v2 = t2[k2];
49967             if (!v2 || v2 === "no")
49968               continue;
49969             status = statuses[i3];
49970             break;
49971           }
49972         }
49973       }
49974       if (!status) {
49975         for (i3 = 0; i3 < statuses.length; i3++) {
49976           k2 = statuses[i3];
49977           v2 = t2[k2];
49978           if (!v2 || v2 === "no")
49979             continue;
49980           if (v2 === "yes") {
49981             status = k2;
49982           } else if (primary && primary === v2) {
49983             status = k2;
49984           } else if (!primary && primaries.indexOf(v2) !== -1) {
49985             status = k2;
49986             primary = v2;
49987             classes.push("tag-" + v2);
49988           }
49989           if (status)
49990             break;
49991         }
49992       }
49993       if (status) {
49994         classes.push("tag-status");
49995         classes.push("tag-status-" + status);
49996       }
49997       for (i3 = 0; i3 < secondaries.length; i3++) {
49998         k2 = secondaries[i3];
49999         v2 = t2[k2];
50000         if (!v2 || v2 === "no" || k2 === primary)
50001           continue;
50002         classes.push("tag-" + k2);
50003         classes.push("tag-" + k2 + "-" + v2);
50004       }
50005       if (primary === "highway" && !osmPathHighwayTagValues[t2.highway] || primary === "aeroway") {
50006         var surface = t2.highway === "track" ? "unpaved" : "paved";
50007         for (k2 in t2) {
50008           v2 = t2[k2];
50009           if (k2 in osmPavedTags) {
50010             surface = osmPavedTags[k2][v2] ? "paved" : "unpaved";
50011           }
50012           if (k2 in osmSemipavedTags && !!osmSemipavedTags[k2][v2]) {
50013             surface = "semipaved";
50014           }
50015         }
50016         classes.push("tag-" + surface);
50017       }
50018       var qid = t2.wikidata || t2["flag:wikidata"] || t2["brand:wikidata"] || t2["network:wikidata"] || t2["operator:wikidata"];
50019       if (qid) {
50020         classes.push("tag-wikidata");
50021       }
50022       return classes.filter((klass) => /^[-_a-z0-9]+$/.test(klass)).join(" ").trim();
50023     };
50024     tagClasses.tags = function(val) {
50025       if (!arguments.length)
50026         return _tags;
50027       _tags = val;
50028       return tagClasses;
50029     };
50030     return tagClasses;
50031   }
50032
50033   // modules/svg/tag_pattern.js
50034   var patterns = {
50035     // tag - pattern name
50036     // -or-
50037     // tag - value - pattern name
50038     // -or-
50039     // tag - value - rules (optional tag-values, pattern name)
50040     // (matches earlier rules first, so fallback should be last entry)
50041     amenity: {
50042       grave_yard: "cemetery",
50043       fountain: "water_standing"
50044     },
50045     landuse: {
50046       cemetery: [
50047         { religion: "christian", pattern: "cemetery_christian" },
50048         { religion: "buddhist", pattern: "cemetery_buddhist" },
50049         { religion: "muslim", pattern: "cemetery_muslim" },
50050         { religion: "jewish", pattern: "cemetery_jewish" },
50051         { pattern: "cemetery" }
50052       ],
50053       construction: "construction",
50054       farmland: "farmland",
50055       farmyard: "farmyard",
50056       forest: [
50057         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
50058         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
50059         { leaf_type: "leafless", pattern: "forest_leafless" },
50060         { pattern: "forest" }
50061         // same as 'leaf_type:mixed'
50062       ],
50063       grave_yard: "cemetery",
50064       grass: "grass",
50065       landfill: "landfill",
50066       meadow: "meadow",
50067       military: "construction",
50068       orchard: "orchard",
50069       quarry: "quarry",
50070       vineyard: "vineyard"
50071     },
50072     leisure: {
50073       horse_riding: "farmyard"
50074     },
50075     natural: {
50076       beach: "beach",
50077       grassland: "grass",
50078       sand: "beach",
50079       scrub: "scrub",
50080       water: [
50081         { water: "pond", pattern: "pond" },
50082         { water: "reservoir", pattern: "water_standing" },
50083         { pattern: "waves" }
50084       ],
50085       wetland: [
50086         { wetland: "marsh", pattern: "wetland_marsh" },
50087         { wetland: "swamp", pattern: "wetland_swamp" },
50088         { wetland: "bog", pattern: "wetland_bog" },
50089         { wetland: "reedbed", pattern: "wetland_reedbed" },
50090         { pattern: "wetland" }
50091       ],
50092       wood: [
50093         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
50094         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
50095         { leaf_type: "leafless", pattern: "forest_leafless" },
50096         { pattern: "forest" }
50097         // same as 'leaf_type:mixed'
50098       ]
50099     },
50100     golf: {
50101       green: "golf_green",
50102       tee: "grass",
50103       fairway: "grass",
50104       rough: "scrub"
50105     },
50106     surface: {
50107       grass: "grass",
50108       sand: "beach"
50109     }
50110   };
50111   function svgTagPattern(tags) {
50112     if (tags.building && tags.building !== "no") {
50113       return null;
50114     }
50115     for (var tag2 in patterns) {
50116       var entityValue = tags[tag2];
50117       if (!entityValue)
50118         continue;
50119       if (typeof patterns[tag2] === "string") {
50120         return "pattern-" + patterns[tag2];
50121       } else {
50122         var values = patterns[tag2];
50123         for (var value in values) {
50124           if (entityValue !== value)
50125             continue;
50126           var rules = values[value];
50127           if (typeof rules === "string") {
50128             return "pattern-" + rules;
50129           }
50130           for (var ruleKey in rules) {
50131             var rule = rules[ruleKey];
50132             var pass = true;
50133             for (var criterion in rule) {
50134               if (criterion !== "pattern") {
50135                 var v2 = tags[criterion];
50136                 if (!v2 || v2 !== rule[criterion]) {
50137                   pass = false;
50138                   break;
50139                 }
50140               }
50141             }
50142             if (pass) {
50143               return "pattern-" + rule.pattern;
50144             }
50145           }
50146         }
50147       }
50148     }
50149     return null;
50150   }
50151
50152   // modules/svg/areas.js
50153   function svgAreas(projection2, context) {
50154     function getPatternStyle(tags) {
50155       var imageID = svgTagPattern(tags);
50156       if (imageID) {
50157         return 'url("#ideditor-' + imageID + '")';
50158       }
50159       return "";
50160     }
50161     function drawTargets(selection2, graph, entities, filter2) {
50162       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
50163       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
50164       var getPath = svgPath(projection2).geojson;
50165       var activeID = context.activeID();
50166       var base = context.history().base();
50167       var data = { targets: [], nopes: [] };
50168       entities.forEach(function(way) {
50169         var features = svgSegmentWay(way, graph, activeID);
50170         data.targets.push.apply(data.targets, features.passive);
50171         data.nopes.push.apply(data.nopes, features.active);
50172       });
50173       var targetData = data.targets.filter(getPath);
50174       var targets = selection2.selectAll(".area.target-allowed").filter(function(d2) {
50175         return filter2(d2.properties.entity);
50176       }).data(targetData, function key(d2) {
50177         return d2.id;
50178       });
50179       targets.exit().remove();
50180       var segmentWasEdited = function(d2) {
50181         var wayID = d2.properties.entity.id;
50182         if (!base.entities[wayID] || !(0, import_fast_deep_equal5.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
50183           return false;
50184         }
50185         return d2.properties.nodes.some(function(n3) {
50186           return !base.entities[n3.id] || !(0, import_fast_deep_equal5.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
50187         });
50188       };
50189       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
50190         return "way area target target-allowed " + targetClass + d2.id;
50191       }).classed("segment-edited", segmentWasEdited);
50192       var nopeData = data.nopes.filter(getPath);
50193       var nopes = selection2.selectAll(".area.target-nope").filter(function(d2) {
50194         return filter2(d2.properties.entity);
50195       }).data(nopeData, function key(d2) {
50196         return d2.id;
50197       });
50198       nopes.exit().remove();
50199       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
50200         return "way area target target-nope " + nopeClass + d2.id;
50201       }).classed("segment-edited", segmentWasEdited);
50202     }
50203     function drawAreas(selection2, graph, entities, filter2) {
50204       var path = svgPath(projection2, graph, true);
50205       var areas = {};
50206       var multipolygon;
50207       var base = context.history().base();
50208       for (var i3 = 0; i3 < entities.length; i3++) {
50209         var entity = entities[i3];
50210         if (entity.geometry(graph) !== "area")
50211           continue;
50212         multipolygon = osmIsOldMultipolygonOuterMember(entity, graph);
50213         if (multipolygon) {
50214           areas[multipolygon.id] = {
50215             entity: multipolygon.mergeTags(entity.tags),
50216             area: Math.abs(entity.area(graph))
50217           };
50218         } else if (!areas[entity.id]) {
50219           areas[entity.id] = {
50220             entity,
50221             area: Math.abs(entity.area(graph))
50222           };
50223         }
50224       }
50225       var fills = Object.values(areas).filter(function hasPath(a2) {
50226         return path(a2.entity);
50227       });
50228       fills.sort(function areaSort(a2, b2) {
50229         return b2.area - a2.area;
50230       });
50231       fills = fills.map(function(a2) {
50232         return a2.entity;
50233       });
50234       var strokes = fills.filter(function(area) {
50235         return area.type === "way";
50236       });
50237       var data = {
50238         clip: fills,
50239         shadow: strokes,
50240         stroke: strokes,
50241         fill: fills
50242       };
50243       var clipPaths = context.surface().selectAll("defs").selectAll(".clipPath-osm").filter(filter2).data(data.clip, osmEntity.key);
50244       clipPaths.exit().remove();
50245       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-osm").attr("id", function(entity2) {
50246         return "ideditor-" + entity2.id + "-clippath";
50247       });
50248       clipPathsEnter.append("path");
50249       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", path);
50250       var drawLayer = selection2.selectAll(".layer-osm.areas");
50251       var touchLayer = selection2.selectAll(".layer-touch.areas");
50252       var areagroup = drawLayer.selectAll("g.areagroup").data(["fill", "shadow", "stroke"]);
50253       areagroup = areagroup.enter().append("g").attr("class", function(d2) {
50254         return "areagroup area-" + d2;
50255       }).merge(areagroup);
50256       var paths = areagroup.selectAll("path").filter(filter2).data(function(layer) {
50257         return data[layer];
50258       }, osmEntity.key);
50259       paths.exit().remove();
50260       var fillpaths = selection2.selectAll(".area-fill path.area").nodes();
50261       var bisect = bisector(function(node) {
50262         return -node.__data__.area(graph);
50263       }).left;
50264       function sortedByArea(entity2) {
50265         if (this._parent.__data__ === "fill") {
50266           return fillpaths[bisect(fillpaths, -entity2.area(graph))];
50267         }
50268       }
50269       paths = paths.enter().insert("path", sortedByArea).merge(paths).each(function(entity2) {
50270         var layer = this.parentNode.__data__;
50271         this.setAttribute("class", entity2.type + " area " + layer + " " + entity2.id);
50272         if (layer === "fill") {
50273           this.setAttribute("clip-path", "url(#ideditor-" + entity2.id + "-clippath)");
50274           this.style.fill = this.style.stroke = getPatternStyle(entity2.tags);
50275         }
50276       }).classed("added", function(d2) {
50277         return !base.entities[d2.id];
50278       }).classed("geometry-edited", function(d2) {
50279         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);
50280       }).classed("retagged", function(d2) {
50281         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);
50282       }).call(svgTagClasses()).attr("d", path);
50283       touchLayer.call(drawTargets, graph, data.stroke, filter2);
50284     }
50285     return drawAreas;
50286   }
50287
50288   // modules/svg/data.js
50289   var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify());
50290
50291   // node_modules/@tmcw/togeojson/dist/togeojson.es.mjs
50292   function $(element, tagName) {
50293     return Array.from(element.getElementsByTagName(tagName));
50294   }
50295   function normalizeId(id2) {
50296     return id2[0] === "#" ? id2 : "#".concat(id2);
50297   }
50298   function $ns(element, tagName, ns) {
50299     return Array.from(element.getElementsByTagNameNS(ns, tagName));
50300   }
50301   function nodeVal(node) {
50302     node == null ? void 0 : node.normalize();
50303     return node && node.textContent || "";
50304   }
50305   function get1(node, tagName, callback) {
50306     const n3 = node.getElementsByTagName(tagName);
50307     const result = n3.length ? n3[0] : null;
50308     if (result && callback)
50309       callback(result);
50310     return result;
50311   }
50312   function get3(node, tagName, callback) {
50313     const properties = {};
50314     if (!node)
50315       return properties;
50316     const n3 = node.getElementsByTagName(tagName);
50317     const result = n3.length ? n3[0] : null;
50318     if (result && callback) {
50319       return callback(result, properties);
50320     }
50321     return properties;
50322   }
50323   function val1(node, tagName, callback) {
50324     const val = nodeVal(get1(node, tagName));
50325     if (val && callback)
50326       return callback(val) || {};
50327     return {};
50328   }
50329   function $num(node, tagName, callback) {
50330     const val = parseFloat(nodeVal(get1(node, tagName)));
50331     if (isNaN(val))
50332       return void 0;
50333     if (val && callback)
50334       return callback(val) || {};
50335     return {};
50336   }
50337   function num1(node, tagName, callback) {
50338     const val = parseFloat(nodeVal(get1(node, tagName)));
50339     if (isNaN(val))
50340       return void 0;
50341     if (callback)
50342       callback(val);
50343     return val;
50344   }
50345   function getMulti(node, propertyNames) {
50346     const properties = {};
50347     for (const property of propertyNames) {
50348       val1(node, property, (val) => {
50349         properties[property] = val;
50350       });
50351     }
50352     return properties;
50353   }
50354   function isElement(node) {
50355     return (node == null ? void 0 : node.nodeType) === 1;
50356   }
50357   function getLineStyle(node) {
50358     return get3(node, "line", (lineStyle) => {
50359       const val = Object.assign({}, val1(lineStyle, "color", (color2) => {
50360         return { stroke: "#".concat(color2) };
50361       }), $num(lineStyle, "opacity", (opacity) => {
50362         return { "stroke-opacity": opacity };
50363       }), $num(lineStyle, "width", (width) => {
50364         return { "stroke-width": width * 96 / 25.4 };
50365       }));
50366       return val;
50367     });
50368   }
50369   function getExtensions(node) {
50370     let values = [];
50371     if (node === null)
50372       return values;
50373     for (const child of Array.from(node.childNodes)) {
50374       if (!isElement(child))
50375         continue;
50376       const name = abbreviateName(child.nodeName);
50377       if (name === "gpxtpx:TrackPointExtension") {
50378         values = values.concat(getExtensions(child));
50379       } else {
50380         const val = nodeVal(child);
50381         values.push([name, parseNumeric(val)]);
50382       }
50383     }
50384     return values;
50385   }
50386   function abbreviateName(name) {
50387     return ["heart", "gpxtpx:hr", "hr"].includes(name) ? "heart" : name;
50388   }
50389   function parseNumeric(val) {
50390     const num = parseFloat(val);
50391     return isNaN(num) ? val : num;
50392   }
50393   function coordPair$1(node) {
50394     const ll = [
50395       parseFloat(node.getAttribute("lon") || ""),
50396       parseFloat(node.getAttribute("lat") || "")
50397     ];
50398     if (isNaN(ll[0]) || isNaN(ll[1])) {
50399       return null;
50400     }
50401     num1(node, "ele", (val) => {
50402       ll.push(val);
50403     });
50404     const time = get1(node, "time");
50405     return {
50406       coordinates: ll,
50407       time: time ? nodeVal(time) : null,
50408       extendedValues: getExtensions(get1(node, "extensions"))
50409     };
50410   }
50411   function extractProperties(node) {
50412     var _a2;
50413     const properties = getMulti(node, [
50414       "name",
50415       "cmt",
50416       "desc",
50417       "type",
50418       "time",
50419       "keywords"
50420     ]);
50421     const extensions = Array.from(node.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*"));
50422     for (const child of extensions) {
50423       if (((_a2 = child.parentNode) == null ? void 0 : _a2.parentNode) === node) {
50424         properties[child.tagName.replace(":", "_")] = nodeVal(child);
50425       }
50426     }
50427     const links = $(node, "link");
50428     if (links.length) {
50429       properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"])));
50430     }
50431     return properties;
50432   }
50433   function getPoints$1(node, pointname) {
50434     const pts = $(node, pointname);
50435     const line = [];
50436     const times = [];
50437     const extendedValues = {};
50438     for (let i3 = 0; i3 < pts.length; i3++) {
50439       const c2 = coordPair$1(pts[i3]);
50440       if (!c2) {
50441         continue;
50442       }
50443       line.push(c2.coordinates);
50444       if (c2.time)
50445         times.push(c2.time);
50446       for (const [name, val] of c2.extendedValues) {
50447         const plural = name === "heart" ? name : name.replace("gpxtpx:", "") + "s";
50448         if (!extendedValues[plural]) {
50449           extendedValues[plural] = Array(pts.length).fill(null);
50450         }
50451         extendedValues[plural][i3] = val;
50452       }
50453     }
50454     if (line.length < 2)
50455       return;
50456     return {
50457       line,
50458       times,
50459       extendedValues
50460     };
50461   }
50462   function getRoute(node) {
50463     const line = getPoints$1(node, "rtept");
50464     if (!line)
50465       return;
50466     return {
50467       type: "Feature",
50468       properties: Object.assign({ _gpxType: "rte" }, extractProperties(node), getLineStyle(get1(node, "extensions"))),
50469       geometry: {
50470         type: "LineString",
50471         coordinates: line.line
50472       }
50473     };
50474   }
50475   function getTrack(node) {
50476     const segments = $(node, "trkseg");
50477     const track = [];
50478     const times = [];
50479     const extractedLines = [];
50480     for (const segment of segments) {
50481       const line = getPoints$1(segment, "trkpt");
50482       if (line) {
50483         extractedLines.push(line);
50484         if (line.times && line.times.length)
50485           times.push(line.times);
50486       }
50487     }
50488     if (extractedLines.length === 0)
50489       return null;
50490     const multi = extractedLines.length > 1;
50491     const properties = Object.assign({ _gpxType: "trk" }, extractProperties(node), getLineStyle(get1(node, "extensions")), times.length ? {
50492       coordinateProperties: {
50493         times: multi ? times : times[0]
50494       }
50495     } : {});
50496     for (const line of extractedLines) {
50497       track.push(line.line);
50498       if (!properties.coordinateProperties) {
50499         properties.coordinateProperties = {};
50500       }
50501       const props = properties.coordinateProperties;
50502       const entries = Object.entries(line.extendedValues);
50503       for (let i3 = 0; i3 < entries.length; i3++) {
50504         const [name, val] = entries[i3];
50505         if (multi) {
50506           if (!props[name]) {
50507             props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
50508           }
50509           props[name][i3] = val;
50510         } else {
50511           props[name] = val;
50512         }
50513       }
50514     }
50515     return {
50516       type: "Feature",
50517       properties,
50518       geometry: multi ? {
50519         type: "MultiLineString",
50520         coordinates: track
50521       } : {
50522         type: "LineString",
50523         coordinates: track[0]
50524       }
50525     };
50526   }
50527   function getPoint(node) {
50528     const properties = Object.assign(extractProperties(node), getMulti(node, ["sym"]));
50529     const pair3 = coordPair$1(node);
50530     if (!pair3)
50531       return null;
50532     return {
50533       type: "Feature",
50534       properties,
50535       geometry: {
50536         type: "Point",
50537         coordinates: pair3.coordinates
50538       }
50539     };
50540   }
50541   function* gpxGen(node) {
50542     for (const track of $(node, "trk")) {
50543       const feature3 = getTrack(track);
50544       if (feature3)
50545         yield feature3;
50546     }
50547     for (const route of $(node, "rte")) {
50548       const feature3 = getRoute(route);
50549       if (feature3)
50550         yield feature3;
50551     }
50552     for (const waypoint of $(node, "wpt")) {
50553       const point2 = getPoint(waypoint);
50554       if (point2)
50555         yield point2;
50556     }
50557   }
50558   function gpx(node) {
50559     return {
50560       type: "FeatureCollection",
50561       features: Array.from(gpxGen(node))
50562     };
50563   }
50564   function fixColor(v2, prefix) {
50565     const properties = {};
50566     const colorProp = prefix == "stroke" || prefix === "fill" ? prefix : prefix + "-color";
50567     if (v2[0] === "#") {
50568       v2 = v2.substring(1);
50569     }
50570     if (v2.length === 6 || v2.length === 3) {
50571       properties[colorProp] = "#" + v2;
50572     } else if (v2.length === 8) {
50573       properties[prefix + "-opacity"] = parseInt(v2.substring(0, 2), 16) / 255;
50574       properties[colorProp] = "#" + v2.substring(6, 8) + v2.substring(4, 6) + v2.substring(2, 4);
50575     }
50576     return properties;
50577   }
50578   function numericProperty(node, source, target) {
50579     const properties = {};
50580     num1(node, source, (val) => {
50581       properties[target] = val;
50582     });
50583     return properties;
50584   }
50585   function getColor(node, output) {
50586     return get3(node, "color", (elem) => fixColor(nodeVal(elem), output));
50587   }
50588   function extractIconHref(node) {
50589     return get3(node, "Icon", (icon2, properties) => {
50590       val1(icon2, "href", (href) => {
50591         properties.icon = href;
50592       });
50593       return properties;
50594     });
50595   }
50596   function extractIcon(node) {
50597     return get3(node, "IconStyle", (iconStyle) => {
50598       return Object.assign(getColor(iconStyle, "icon"), numericProperty(iconStyle, "scale", "icon-scale"), numericProperty(iconStyle, "heading", "icon-heading"), get3(iconStyle, "hotSpot", (hotspot) => {
50599         const left = parseFloat(hotspot.getAttribute("x") || "");
50600         const top = parseFloat(hotspot.getAttribute("y") || "");
50601         const xunits = hotspot.getAttribute("xunits") || "";
50602         const yunits = hotspot.getAttribute("yunits") || "";
50603         if (!isNaN(left) && !isNaN(top))
50604           return {
50605             "icon-offset": [left, top],
50606             "icon-offset-units": [xunits, yunits]
50607           };
50608         return {};
50609       }), extractIconHref(iconStyle));
50610     });
50611   }
50612   function extractLabel(node) {
50613     return get3(node, "LabelStyle", (labelStyle) => {
50614       return Object.assign(getColor(labelStyle, "label"), numericProperty(labelStyle, "scale", "label-scale"));
50615     });
50616   }
50617   function extractLine(node) {
50618     return get3(node, "LineStyle", (lineStyle) => {
50619       return Object.assign(getColor(lineStyle, "stroke"), numericProperty(lineStyle, "width", "stroke-width"));
50620     });
50621   }
50622   function extractPoly(node) {
50623     return get3(node, "PolyStyle", (polyStyle, properties) => {
50624       return Object.assign(properties, get3(polyStyle, "color", (elem) => fixColor(nodeVal(elem), "fill")), val1(polyStyle, "fill", (fill) => {
50625         if (fill === "0")
50626           return { "fill-opacity": 0 };
50627       }), val1(polyStyle, "outline", (outline) => {
50628         if (outline === "0")
50629           return { "stroke-opacity": 0 };
50630       }));
50631     });
50632   }
50633   function extractStyle(node) {
50634     return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node));
50635   }
50636   var toNumber2 = (x2) => Number(x2);
50637   var typeConverters = {
50638     string: (x2) => x2,
50639     int: toNumber2,
50640     uint: toNumber2,
50641     short: toNumber2,
50642     ushort: toNumber2,
50643     float: toNumber2,
50644     double: toNumber2,
50645     bool: (x2) => Boolean(x2)
50646   };
50647   function extractExtendedData(node, schema) {
50648     return get3(node, "ExtendedData", (extendedData, properties) => {
50649       for (const data of $(extendedData, "Data")) {
50650         properties[data.getAttribute("name") || ""] = nodeVal(get1(data, "value"));
50651       }
50652       for (const simpleData of $(extendedData, "SimpleData")) {
50653         const name = simpleData.getAttribute("name") || "";
50654         const typeConverter = schema[name] || typeConverters.string;
50655         properties[name] = typeConverter(nodeVal(simpleData));
50656       }
50657       return properties;
50658     });
50659   }
50660   function getMaybeHTMLDescription(node) {
50661     const descriptionNode = get1(node, "description");
50662     for (const c2 of Array.from((descriptionNode == null ? void 0 : descriptionNode.childNodes) || [])) {
50663       if (c2.nodeType === 4) {
50664         return {
50665           description: {
50666             "@type": "html",
50667             value: nodeVal(c2)
50668           }
50669         };
50670       }
50671     }
50672     return {};
50673   }
50674   function extractTimeSpan(node) {
50675     return get3(node, "TimeSpan", (timeSpan) => {
50676       return {
50677         timespan: {
50678           begin: nodeVal(get1(timeSpan, "begin")),
50679           end: nodeVal(get1(timeSpan, "end"))
50680         }
50681       };
50682     });
50683   }
50684   function extractTimeStamp(node) {
50685     return get3(node, "TimeStamp", (timeStamp) => {
50686       return { timestamp: nodeVal(get1(timeStamp, "when")) };
50687     });
50688   }
50689   function extractCascadedStyle(node, styleMap) {
50690     return val1(node, "styleUrl", (styleUrl) => {
50691       styleUrl = normalizeId(styleUrl);
50692       if (styleMap[styleUrl]) {
50693         return Object.assign({ styleUrl }, styleMap[styleUrl]);
50694       }
50695       return { styleUrl };
50696     });
50697   }
50698   var removeSpace = /\s*/g;
50699   var trimSpace = /^\s*|\s*$/g;
50700   var splitSpace = /\s+/;
50701   function coord1(value) {
50702     return value.replace(removeSpace, "").split(",").map(parseFloat).filter((num) => !isNaN(num)).slice(0, 3);
50703   }
50704   function coord(value) {
50705     return value.replace(trimSpace, "").split(splitSpace).map(coord1).filter((coord2) => {
50706       return coord2.length >= 2;
50707     });
50708   }
50709   function gxCoords(node) {
50710     let elems = $(node, "coord");
50711     if (elems.length === 0) {
50712       elems = $ns(node, "coord", "*");
50713     }
50714     const coordinates = elems.map((elem) => {
50715       return nodeVal(elem).split(" ").map(parseFloat);
50716     });
50717     if (coordinates.length === 0) {
50718       return null;
50719     }
50720     return {
50721       geometry: coordinates.length > 2 ? {
50722         type: "LineString",
50723         coordinates
50724       } : {
50725         type: "Point",
50726         coordinates: coordinates[0]
50727       },
50728       times: $(node, "when").map((elem) => nodeVal(elem))
50729     };
50730   }
50731   function fixRing(ring) {
50732     if (ring.length === 0)
50733       return ring;
50734     const first = ring[0];
50735     const last = ring[ring.length - 1];
50736     let equal = true;
50737     for (let i3 = 0; i3 < Math.max(first.length, last.length); i3++) {
50738       if (first[i3] !== last[i3]) {
50739         equal = false;
50740         break;
50741       }
50742     }
50743     if (!equal) {
50744       return ring.concat([ring[0]]);
50745     }
50746     return ring;
50747   }
50748   function getCoordinates(node) {
50749     return nodeVal(get1(node, "coordinates"));
50750   }
50751   function getGeometry(node) {
50752     let geometries = [];
50753     let coordTimes = [];
50754     for (let i3 = 0; i3 < node.childNodes.length; i3++) {
50755       const child = node.childNodes.item(i3);
50756       if (isElement(child)) {
50757         switch (child.tagName) {
50758           case "MultiGeometry":
50759           case "MultiTrack":
50760           case "gx:MultiTrack": {
50761             const childGeometries = getGeometry(child);
50762             geometries = geometries.concat(childGeometries.geometries);
50763             coordTimes = coordTimes.concat(childGeometries.coordTimes);
50764             break;
50765           }
50766           case "Point": {
50767             const coordinates = coord1(getCoordinates(child));
50768             if (coordinates.length >= 2) {
50769               geometries.push({
50770                 type: "Point",
50771                 coordinates
50772               });
50773             }
50774             break;
50775           }
50776           case "LinearRing":
50777           case "LineString": {
50778             const coordinates = coord(getCoordinates(child));
50779             if (coordinates.length >= 2) {
50780               geometries.push({
50781                 type: "LineString",
50782                 coordinates
50783               });
50784             }
50785             break;
50786           }
50787           case "Polygon": {
50788             const coords = [];
50789             for (const linearRing of $(child, "LinearRing")) {
50790               const ring = fixRing(coord(getCoordinates(linearRing)));
50791               if (ring.length >= 4) {
50792                 coords.push(ring);
50793               }
50794             }
50795             if (coords.length) {
50796               geometries.push({
50797                 type: "Polygon",
50798                 coordinates: coords
50799               });
50800             }
50801             break;
50802           }
50803           case "Track":
50804           case "gx:Track": {
50805             const gx = gxCoords(child);
50806             if (!gx)
50807               break;
50808             const { times, geometry } = gx;
50809             geometries.push(geometry);
50810             if (times.length)
50811               coordTimes.push(times);
50812             break;
50813           }
50814         }
50815       }
50816     }
50817     return {
50818       geometries,
50819       coordTimes
50820     };
50821   }
50822   function geometryListToGeometry(geometries) {
50823     return geometries.length === 0 ? null : geometries.length === 1 ? geometries[0] : {
50824       type: "GeometryCollection",
50825       geometries
50826     };
50827   }
50828   function getPlacemark(node, styleMap, schema, options2) {
50829     var _a2;
50830     const { coordTimes, geometries } = getGeometry(node);
50831     const geometry = geometryListToGeometry(geometries);
50832     if (!geometry && options2.skipNullGeometry) {
50833       return null;
50834     }
50835     const feature3 = {
50836       type: "Feature",
50837       geometry,
50838       properties: Object.assign(getMulti(node, [
50839         "name",
50840         "address",
50841         "visibility",
50842         "open",
50843         "phoneNumber",
50844         "description"
50845       ]), getMaybeHTMLDescription(node), extractCascadedStyle(node, styleMap), extractStyle(node), extractExtendedData(node, schema), extractTimeSpan(node), extractTimeStamp(node), coordTimes.length ? {
50846         coordinateProperties: {
50847           times: coordTimes.length === 1 ? coordTimes[0] : coordTimes
50848         }
50849       } : {})
50850     };
50851     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50852       feature3.properties.visibility = feature3.properties.visibility !== "0";
50853     }
50854     const id2 = node.getAttribute("id");
50855     if (id2 !== null && id2 !== "")
50856       feature3.id = id2;
50857     return feature3;
50858   }
50859   function getGroundOverlayBox(node) {
50860     const latLonQuad = get1(node, "gx:LatLonQuad");
50861     if (latLonQuad) {
50862       const ring = fixRing(coord(getCoordinates(node)));
50863       return {
50864         geometry: {
50865           type: "Polygon",
50866           coordinates: [ring]
50867         }
50868       };
50869     }
50870     return getLatLonBox(node);
50871   }
50872   var DEGREES_TO_RADIANS = Math.PI / 180;
50873   function rotateBox(bbox2, coordinates, rotation) {
50874     const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2];
50875     return [
50876       coordinates[0].map((coordinate) => {
50877         const dy = coordinate[1] - center[1];
50878         const dx = coordinate[0] - center[0];
50879         const distance = Math.sqrt(Math.pow(dy, 2) + Math.pow(dx, 2));
50880         const angle2 = Math.atan2(dy, dx) + rotation * DEGREES_TO_RADIANS;
50881         return [
50882           center[0] + Math.cos(angle2) * distance,
50883           center[1] + Math.sin(angle2) * distance
50884         ];
50885       })
50886     ];
50887   }
50888   function getLatLonBox(node) {
50889     const latLonBox = get1(node, "LatLonBox");
50890     if (latLonBox) {
50891       const north = num1(latLonBox, "north");
50892       const west = num1(latLonBox, "west");
50893       const east = num1(latLonBox, "east");
50894       const south = num1(latLonBox, "south");
50895       const rotation = num1(latLonBox, "rotation");
50896       if (typeof north === "number" && typeof south === "number" && typeof west === "number" && typeof east === "number") {
50897         const bbox2 = [west, south, east, north];
50898         let coordinates = [
50899           [
50900             [west, north],
50901             [east, north],
50902             [east, south],
50903             [west, south],
50904             [west, north]
50905             // top left (again)
50906           ]
50907         ];
50908         if (typeof rotation === "number") {
50909           coordinates = rotateBox(bbox2, coordinates, rotation);
50910         }
50911         return {
50912           bbox: bbox2,
50913           geometry: {
50914             type: "Polygon",
50915             coordinates
50916           }
50917         };
50918       }
50919     }
50920     return null;
50921   }
50922   function getGroundOverlay(node, styleMap, schema, options2) {
50923     var _a2;
50924     const box = getGroundOverlayBox(node);
50925     const geometry = (box == null ? void 0 : box.geometry) || null;
50926     if (!geometry && options2.skipNullGeometry) {
50927       return null;
50928     }
50929     const feature3 = {
50930       type: "Feature",
50931       geometry,
50932       properties: Object.assign(
50933         /**
50934          * Related to
50935          * https://gist.github.com/tmcw/037a1cb6660d74a392e9da7446540f46
50936          */
50937         { "@geometry-type": "groundoverlay" },
50938         getMulti(node, [
50939           "name",
50940           "address",
50941           "visibility",
50942           "open",
50943           "phoneNumber",
50944           "description"
50945         ]),
50946         getMaybeHTMLDescription(node),
50947         extractCascadedStyle(node, styleMap),
50948         extractStyle(node),
50949         extractIconHref(node),
50950         extractExtendedData(node, schema),
50951         extractTimeSpan(node),
50952         extractTimeStamp(node)
50953       )
50954     };
50955     if (box == null ? void 0 : box.bbox) {
50956       feature3.bbox = box.bbox;
50957     }
50958     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50959       feature3.properties.visibility = feature3.properties.visibility !== "0";
50960     }
50961     const id2 = node.getAttribute("id");
50962     if (id2 !== null && id2 !== "")
50963       feature3.id = id2;
50964     return feature3;
50965   }
50966   function getStyleId(style) {
50967     let id2 = style.getAttribute("id");
50968     const parentNode = style.parentNode;
50969     if (!id2 && isElement(parentNode) && parentNode.localName === "CascadingStyle") {
50970       id2 = parentNode.getAttribute("kml:id") || parentNode.getAttribute("id");
50971     }
50972     return normalizeId(id2 || "");
50973   }
50974   function buildStyleMap(node) {
50975     const styleMap = {};
50976     for (const style of $(node, "Style")) {
50977       styleMap[getStyleId(style)] = extractStyle(style);
50978     }
50979     for (const map2 of $(node, "StyleMap")) {
50980       const id2 = normalizeId(map2.getAttribute("id") || "");
50981       val1(map2, "styleUrl", (styleUrl) => {
50982         styleUrl = normalizeId(styleUrl);
50983         if (styleMap[styleUrl]) {
50984           styleMap[id2] = styleMap[styleUrl];
50985         }
50986       });
50987     }
50988     return styleMap;
50989   }
50990   function buildSchema(node) {
50991     const schema = {};
50992     for (const field of $(node, "SimpleField")) {
50993       schema[field.getAttribute("name") || ""] = typeConverters[field.getAttribute("type") || ""] || typeConverters["string"];
50994     }
50995     return schema;
50996   }
50997   function* kmlGen(node, options2 = {
50998     skipNullGeometry: false
50999   }) {
51000     const styleMap = buildStyleMap(node);
51001     const schema = buildSchema(node);
51002     for (const placemark of $(node, "Placemark")) {
51003       const feature3 = getPlacemark(placemark, styleMap, schema, options2);
51004       if (feature3)
51005         yield feature3;
51006     }
51007     for (const groundOverlay of $(node, "GroundOverlay")) {
51008       const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2);
51009       if (feature3)
51010         yield feature3;
51011     }
51012   }
51013   function kml(node, options2 = {
51014     skipNullGeometry: false
51015   }) {
51016     return {
51017       type: "FeatureCollection",
51018       features: Array.from(kmlGen(node, options2))
51019     };
51020   }
51021
51022   // modules/svg/data.js
51023   var _initialized = false;
51024   var _enabled = false;
51025   var _geojson;
51026   function svgData(projection2, context, dispatch14) {
51027     var throttledRedraw = throttle_default(function() {
51028       dispatch14.call("change");
51029     }, 1e3);
51030     var _showLabels = true;
51031     var detected = utilDetect();
51032     var layer = select_default2(null);
51033     var _vtService;
51034     var _fileList;
51035     var _template;
51036     var _src;
51037     const supportedFormats = [
51038       ".gpx",
51039       ".kml",
51040       ".geojson",
51041       ".json"
51042     ];
51043     function init2() {
51044       if (_initialized)
51045         return;
51046       _geojson = {};
51047       _enabled = true;
51048       function over(d3_event) {
51049         d3_event.stopPropagation();
51050         d3_event.preventDefault();
51051         d3_event.dataTransfer.dropEffect = "copy";
51052       }
51053       context.container().attr("dropzone", "copy").on("drop.svgData", function(d3_event) {
51054         d3_event.stopPropagation();
51055         d3_event.preventDefault();
51056         if (!detected.filedrop)
51057           return;
51058         var f2 = d3_event.dataTransfer.files[0];
51059         var extension = getExtension(f2.name);
51060         if (!supportedFormats.includes(extension))
51061           return;
51062         drawData.fileList(d3_event.dataTransfer.files);
51063       }).on("dragenter.svgData", over).on("dragexit.svgData", over).on("dragover.svgData", over);
51064       _initialized = true;
51065     }
51066     function getService() {
51067       if (services.vectorTile && !_vtService) {
51068         _vtService = services.vectorTile;
51069         _vtService.event.on("loadedData", throttledRedraw);
51070       } else if (!services.vectorTile && _vtService) {
51071         _vtService = null;
51072       }
51073       return _vtService;
51074     }
51075     function showLayer() {
51076       layerOn();
51077       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
51078         dispatch14.call("change");
51079       });
51080     }
51081     function hideLayer() {
51082       throttledRedraw.cancel();
51083       layer.transition().duration(250).style("opacity", 0).on("end", layerOff);
51084     }
51085     function layerOn() {
51086       layer.style("display", "block");
51087     }
51088     function layerOff() {
51089       layer.selectAll(".viewfield-group").remove();
51090       layer.style("display", "none");
51091     }
51092     function ensureIDs(gj) {
51093       if (!gj)
51094         return null;
51095       if (gj.type === "FeatureCollection") {
51096         for (var i3 = 0; i3 < gj.features.length; i3++) {
51097           ensureFeatureID(gj.features[i3]);
51098         }
51099       } else {
51100         ensureFeatureID(gj);
51101       }
51102       return gj;
51103     }
51104     function ensureFeatureID(feature3) {
51105       if (!feature3)
51106         return;
51107       feature3.__featurehash__ = utilHashcode((0, import_fast_json_stable_stringify.default)(feature3));
51108       return feature3;
51109     }
51110     function getFeatures(gj) {
51111       if (!gj)
51112         return [];
51113       if (gj.type === "FeatureCollection") {
51114         return gj.features;
51115       } else {
51116         return [gj];
51117       }
51118     }
51119     function featureKey(d2) {
51120       return d2.__featurehash__;
51121     }
51122     function isPolygon(d2) {
51123       return d2.geometry.type === "Polygon" || d2.geometry.type === "MultiPolygon";
51124     }
51125     function clipPathID(d2) {
51126       return "ideditor-data-" + d2.__featurehash__ + "-clippath";
51127     }
51128     function featureClasses(d2) {
51129       return [
51130         "data" + d2.__featurehash__,
51131         d2.geometry.type,
51132         isPolygon(d2) ? "area" : "",
51133         d2.__layerID__ || ""
51134       ].filter(Boolean).join(" ");
51135     }
51136     function drawData(selection2) {
51137       var vtService = getService();
51138       var getPath = svgPath(projection2).geojson;
51139       var getAreaPath = svgPath(projection2, null, true).geojson;
51140       var hasData = drawData.hasData();
51141       layer = selection2.selectAll(".layer-mapdata").data(_enabled && hasData ? [0] : []);
51142       layer.exit().remove();
51143       layer = layer.enter().append("g").attr("class", "layer-mapdata").merge(layer);
51144       var surface = context.surface();
51145       if (!surface || surface.empty())
51146         return;
51147       var geoData, polygonData;
51148       if (_template && vtService) {
51149         var sourceID = _template;
51150         vtService.loadTiles(sourceID, _template, projection2);
51151         geoData = vtService.data(sourceID, projection2);
51152       } else {
51153         geoData = getFeatures(_geojson);
51154       }
51155       geoData = geoData.filter(getPath);
51156       polygonData = geoData.filter(isPolygon);
51157       var clipPaths = surface.selectAll("defs").selectAll(".clipPath-data").data(polygonData, featureKey);
51158       clipPaths.exit().remove();
51159       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-data").attr("id", clipPathID);
51160       clipPathsEnter.append("path");
51161       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", getAreaPath);
51162       var datagroups = layer.selectAll("g.datagroup").data(["fill", "shadow", "stroke"]);
51163       datagroups = datagroups.enter().append("g").attr("class", function(d2) {
51164         return "datagroup datagroup-" + d2;
51165       }).merge(datagroups);
51166       var pathData = {
51167         fill: polygonData,
51168         shadow: geoData,
51169         stroke: geoData
51170       };
51171       var paths = datagroups.selectAll("path").data(function(layer2) {
51172         return pathData[layer2];
51173       }, featureKey);
51174       paths.exit().remove();
51175       paths = paths.enter().append("path").attr("class", function(d2) {
51176         var datagroup = this.parentNode.__data__;
51177         return "pathdata " + datagroup + " " + featureClasses(d2);
51178       }).attr("clip-path", function(d2) {
51179         var datagroup = this.parentNode.__data__;
51180         return datagroup === "fill" ? "url(#" + clipPathID(d2) + ")" : null;
51181       }).merge(paths).attr("d", function(d2) {
51182         var datagroup = this.parentNode.__data__;
51183         return datagroup === "fill" ? getAreaPath(d2) : getPath(d2);
51184       });
51185       layer.call(drawLabels, "label-halo", geoData).call(drawLabels, "label", geoData);
51186       function drawLabels(selection3, textClass, data) {
51187         var labelPath = path_default(projection2);
51188         var labelData = data.filter(function(d2) {
51189           return _showLabels && d2.properties && (d2.properties.desc || d2.properties.name);
51190         });
51191         var labels = selection3.selectAll("text." + textClass).data(labelData, featureKey);
51192         labels.exit().remove();
51193         labels = labels.enter().append("text").attr("class", function(d2) {
51194           return textClass + " " + featureClasses(d2);
51195         }).merge(labels).text(function(d2) {
51196           return d2.properties.desc || d2.properties.name;
51197         }).attr("x", function(d2) {
51198           var centroid = labelPath.centroid(d2);
51199           return centroid[0] + 11;
51200         }).attr("y", function(d2) {
51201           var centroid = labelPath.centroid(d2);
51202           return centroid[1];
51203         });
51204       }
51205     }
51206     function getExtension(fileName) {
51207       if (!fileName)
51208         return;
51209       var re3 = /\.(gpx|kml|(geo)?json|png)$/i;
51210       var match = fileName.toLowerCase().match(re3);
51211       return match && match.length && match[0];
51212     }
51213     function xmlToDom(textdata) {
51214       return new DOMParser().parseFromString(textdata, "text/xml");
51215     }
51216     function stringifyGeojsonProperties(feature3) {
51217       const properties = feature3.properties;
51218       for (const key in properties) {
51219         const property = properties[key];
51220         if (typeof property === "number" || typeof property === "boolean" || Array.isArray(property)) {
51221           properties[key] = property.toString();
51222         } else if (property === null) {
51223           properties[key] = "null";
51224         } else if (typeof property === "object") {
51225           properties[key] = JSON.stringify(property);
51226         }
51227       }
51228     }
51229     drawData.setFile = function(extension, data) {
51230       _template = null;
51231       _fileList = null;
51232       _geojson = null;
51233       _src = null;
51234       var gj;
51235       switch (extension) {
51236         case ".gpx":
51237           gj = gpx(xmlToDom(data));
51238           break;
51239         case ".kml":
51240           gj = kml(xmlToDom(data));
51241           break;
51242         case ".geojson":
51243         case ".json":
51244           gj = JSON.parse(data);
51245           if (gj.type === "FeatureCollection") {
51246             gj.features.forEach(stringifyGeojsonProperties);
51247           } else if (gj.type === "Feature") {
51248             stringifyGeojsonProperties(gj);
51249           }
51250           break;
51251       }
51252       gj = gj || {};
51253       if (Object.keys(gj).length) {
51254         _geojson = ensureIDs(gj);
51255         _src = extension + " data file";
51256         this.fitZoom();
51257       }
51258       dispatch14.call("change");
51259       return this;
51260     };
51261     drawData.showLabels = function(val) {
51262       if (!arguments.length)
51263         return _showLabels;
51264       _showLabels = val;
51265       return this;
51266     };
51267     drawData.enabled = function(val) {
51268       if (!arguments.length)
51269         return _enabled;
51270       _enabled = val;
51271       if (_enabled) {
51272         showLayer();
51273       } else {
51274         hideLayer();
51275       }
51276       dispatch14.call("change");
51277       return this;
51278     };
51279     drawData.hasData = function() {
51280       var gj = _geojson || {};
51281       return !!(_template || Object.keys(gj).length);
51282     };
51283     drawData.template = function(val, src) {
51284       if (!arguments.length)
51285         return _template;
51286       var osm = context.connection();
51287       if (osm) {
51288         var blocklists = osm.imageryBlocklists();
51289         var fail = false;
51290         var tested = 0;
51291         var regex;
51292         for (var i3 = 0; i3 < blocklists.length; i3++) {
51293           regex = blocklists[i3];
51294           fail = regex.test(val);
51295           tested++;
51296           if (fail)
51297             break;
51298         }
51299         if (!tested) {
51300           regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
51301           fail = regex.test(val);
51302         }
51303       }
51304       _template = val;
51305       _fileList = null;
51306       _geojson = null;
51307       _src = src || "vectortile:" + val.split(/[?#]/)[0];
51308       dispatch14.call("change");
51309       return this;
51310     };
51311     drawData.geojson = function(gj, src) {
51312       if (!arguments.length)
51313         return _geojson;
51314       _template = null;
51315       _fileList = null;
51316       _geojson = null;
51317       _src = null;
51318       gj = gj || {};
51319       if (Object.keys(gj).length) {
51320         _geojson = ensureIDs(gj);
51321         _src = src || "unknown.geojson";
51322       }
51323       dispatch14.call("change");
51324       return this;
51325     };
51326     drawData.fileList = function(fileList) {
51327       if (!arguments.length)
51328         return _fileList;
51329       _template = null;
51330       _geojson = null;
51331       _src = null;
51332       _fileList = fileList;
51333       if (!fileList || !fileList.length)
51334         return this;
51335       var f2 = fileList[0];
51336       var extension = getExtension(f2.name);
51337       var reader = new FileReader();
51338       reader.onload = /* @__PURE__ */ function() {
51339         return function(e3) {
51340           drawData.setFile(extension, e3.target.result);
51341         };
51342       }(f2);
51343       reader.readAsText(f2);
51344       return this;
51345     };
51346     drawData.url = function(url, defaultExtension) {
51347       _template = null;
51348       _fileList = null;
51349       _geojson = null;
51350       _src = null;
51351       var testUrl = url.split(/[?#]/)[0];
51352       var extension = getExtension(testUrl) || defaultExtension;
51353       if (extension) {
51354         _template = null;
51355         text_default3(url).then(function(data) {
51356           drawData.setFile(extension, data);
51357         }).catch(function() {
51358         });
51359       } else {
51360         drawData.template(url);
51361       }
51362       return this;
51363     };
51364     drawData.getSrc = function() {
51365       return _src || "";
51366     };
51367     drawData.fitZoom = function() {
51368       var features = getFeatures(_geojson);
51369       if (!features.length)
51370         return;
51371       var map2 = context.map();
51372       var viewport = map2.trimmedExtent().polygon();
51373       var coords = features.reduce(function(coords2, feature3) {
51374         var geom = feature3.geometry;
51375         if (!geom)
51376           return coords2;
51377         var c2 = geom.coordinates;
51378         switch (geom.type) {
51379           case "Point":
51380             c2 = [c2];
51381           case "MultiPoint":
51382           case "LineString":
51383             break;
51384           case "MultiPolygon":
51385             c2 = utilArrayFlatten(c2);
51386           case "Polygon":
51387           case "MultiLineString":
51388             c2 = utilArrayFlatten(c2);
51389             break;
51390         }
51391         return utilArrayUnion(coords2, c2);
51392       }, []);
51393       if (!geoPolygonIntersectsPolygon(viewport, coords, true)) {
51394         var extent = geoExtent(bounds_default({ type: "LineString", coordinates: coords }));
51395         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
51396       }
51397       return this;
51398     };
51399     init2();
51400     return drawData;
51401   }
51402
51403   // modules/svg/debug.js
51404   function svgDebug(projection2, context) {
51405     function drawDebug(selection2) {
51406       const showTile = context.getDebug("tile");
51407       const showCollision = context.getDebug("collision");
51408       const showImagery = context.getDebug("imagery");
51409       const showTouchTargets = context.getDebug("target");
51410       const showDownloaded = context.getDebug("downloaded");
51411       let debugData = [];
51412       if (showTile) {
51413         debugData.push({ class: "red", label: "tile" });
51414       }
51415       if (showCollision) {
51416         debugData.push({ class: "yellow", label: "collision" });
51417       }
51418       if (showImagery) {
51419         debugData.push({ class: "orange", label: "imagery" });
51420       }
51421       if (showTouchTargets) {
51422         debugData.push({ class: "pink", label: "touchTargets" });
51423       }
51424       if (showDownloaded) {
51425         debugData.push({ class: "purple", label: "downloaded" });
51426       }
51427       let legend = context.container().select(".main-content").selectAll(".debug-legend").data(debugData.length ? [0] : []);
51428       legend.exit().remove();
51429       legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend);
51430       let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label);
51431       legendItems.exit().remove();
51432       legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label);
51433       let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []);
51434       layer.exit().remove();
51435       layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer);
51436       const extent = context.map().extent();
51437       _mainFileFetcher.get("imagery").then((d2) => {
51438         const hits = showImagery && d2.query.bbox(extent.rectangle(), true) || [];
51439         const features = hits.map((d4) => d4.features[d4.id]);
51440         let imagery = layer.selectAll("path.debug-imagery").data(features);
51441         imagery.exit().remove();
51442         imagery.enter().append("path").attr("class", "debug-imagery debug orange");
51443       }).catch(() => {
51444       });
51445       const osm = context.connection();
51446       let dataDownloaded = [];
51447       if (osm && showDownloaded) {
51448         const rtree = osm.caches("get").tile.rtree;
51449         dataDownloaded = rtree.all().map((bbox2) => {
51450           return {
51451             type: "Feature",
51452             properties: { id: bbox2.id },
51453             geometry: {
51454               type: "Polygon",
51455               coordinates: [[
51456                 [bbox2.minX, bbox2.minY],
51457                 [bbox2.minX, bbox2.maxY],
51458                 [bbox2.maxX, bbox2.maxY],
51459                 [bbox2.maxX, bbox2.minY],
51460                 [bbox2.minX, bbox2.minY]
51461               ]]
51462             }
51463           };
51464         });
51465       }
51466       let downloaded = layer.selectAll("path.debug-downloaded").data(showDownloaded ? dataDownloaded : []);
51467       downloaded.exit().remove();
51468       downloaded.enter().append("path").attr("class", "debug-downloaded debug purple");
51469       layer.selectAll("path").attr("d", svgPath(projection2).geojson);
51470     }
51471     drawDebug.enabled = function() {
51472       if (!arguments.length) {
51473         return context.getDebug("tile") || context.getDebug("collision") || context.getDebug("imagery") || context.getDebug("target") || context.getDebug("downloaded");
51474       } else {
51475         return this;
51476       }
51477     };
51478     return drawDebug;
51479   }
51480
51481   // modules/svg/defs.js
51482   function svgDefs(context) {
51483     var _defsSelection = select_default2(null);
51484     var _spritesheetIds = [
51485       "iD-sprite",
51486       "maki-sprite",
51487       "temaki-sprite",
51488       "fa-sprite",
51489       "roentgen-sprite",
51490       "community-sprite"
51491     ];
51492     function drawDefs(selection2) {
51493       _defsSelection = selection2.append("defs");
51494       _defsSelection.append("marker").attr("id", "ideditor-oneway-marker").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", "#000").attr("opacity", "0.75");
51495       function addSidedMarker(name, color2, offset) {
51496         _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);
51497       }
51498       addSidedMarker("natural", "rgb(170, 170, 170)", 0);
51499       addSidedMarker("coastline", "#77dede", 1);
51500       addSidedMarker("waterway", "#77dede", 1);
51501       addSidedMarker("barrier", "#ddd", 1);
51502       addSidedMarker("man_made", "#fff", 0);
51503       _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");
51504       _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");
51505       var patterns2 = _defsSelection.selectAll("pattern").data([
51506         // pattern name, pattern image name
51507         ["beach", "dots"],
51508         ["construction", "construction"],
51509         ["cemetery", "cemetery"],
51510         ["cemetery_christian", "cemetery_christian"],
51511         ["cemetery_buddhist", "cemetery_buddhist"],
51512         ["cemetery_muslim", "cemetery_muslim"],
51513         ["cemetery_jewish", "cemetery_jewish"],
51514         ["farmland", "farmland"],
51515         ["farmyard", "farmyard"],
51516         ["forest", "forest"],
51517         ["forest_broadleaved", "forest_broadleaved"],
51518         ["forest_needleleaved", "forest_needleleaved"],
51519         ["forest_leafless", "forest_leafless"],
51520         ["golf_green", "grass"],
51521         ["grass", "grass"],
51522         ["landfill", "landfill"],
51523         ["meadow", "grass"],
51524         ["orchard", "orchard"],
51525         ["pond", "pond"],
51526         ["quarry", "quarry"],
51527         ["scrub", "bushes"],
51528         ["vineyard", "vineyard"],
51529         ["water_standing", "lines"],
51530         ["waves", "waves"],
51531         ["wetland", "wetland"],
51532         ["wetland_marsh", "wetland_marsh"],
51533         ["wetland_swamp", "wetland_swamp"],
51534         ["wetland_bog", "wetland_bog"],
51535         ["wetland_reedbed", "wetland_reedbed"]
51536       ]).enter().append("pattern").attr("id", function(d2) {
51537         return "ideditor-pattern-" + d2[0];
51538       }).attr("width", 32).attr("height", 32).attr("patternUnits", "userSpaceOnUse");
51539       patterns2.append("rect").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("class", function(d2) {
51540         return "pattern-color-" + d2[0];
51541       });
51542       patterns2.append("image").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("xlink:href", function(d2) {
51543         return context.imagePath("pattern/" + d2[1] + ".png");
51544       });
51545       _defsSelection.selectAll("clipPath").data([12, 18, 20, 32, 45]).enter().append("clipPath").attr("id", function(d2) {
51546         return "ideditor-clip-square-" + d2;
51547       }).append("rect").attr("x", 0).attr("y", 0).attr("width", function(d2) {
51548         return d2;
51549       }).attr("height", function(d2) {
51550         return d2;
51551       });
51552       addSprites(_spritesheetIds, true);
51553     }
51554     function addSprites(ids, overrideColors) {
51555       _spritesheetIds = utilArrayUniq(_spritesheetIds.concat(ids));
51556       var spritesheets = _defsSelection.selectAll(".spritesheet").data(_spritesheetIds);
51557       spritesheets.enter().append("g").attr("class", function(d2) {
51558         return "spritesheet spritesheet-" + d2;
51559       }).each(function(d2) {
51560         var url = context.imagePath(d2 + ".svg");
51561         var node = select_default2(this).node();
51562         svg(url).then(function(svg2) {
51563           node.appendChild(
51564             select_default2(svg2.documentElement).attr("id", "ideditor-" + d2).node()
51565           );
51566           if (overrideColors && d2 !== "iD-sprite") {
51567             select_default2(node).selectAll("path").attr("fill", "currentColor");
51568           }
51569         }).catch(function() {
51570         });
51571       });
51572       spritesheets.exit().remove();
51573     }
51574     drawDefs.addSprites = addSprites;
51575     return drawDefs;
51576   }
51577
51578   // modules/svg/keepRight.js
51579   var _layerEnabled = false;
51580   var _qaService;
51581   function svgKeepRight(projection2, context, dispatch14) {
51582     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
51583     const minZoom4 = 12;
51584     let touchLayer = select_default2(null);
51585     let drawLayer = select_default2(null);
51586     let layerVisible = false;
51587     function markerPath(selection2, klass) {
51588       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");
51589     }
51590     function getService() {
51591       if (services.keepRight && !_qaService) {
51592         _qaService = services.keepRight;
51593         _qaService.on("loaded", throttledRedraw);
51594       } else if (!services.keepRight && _qaService) {
51595         _qaService = null;
51596       }
51597       return _qaService;
51598     }
51599     function editOn() {
51600       if (!layerVisible) {
51601         layerVisible = true;
51602         drawLayer.style("display", "block");
51603       }
51604     }
51605     function editOff() {
51606       if (layerVisible) {
51607         layerVisible = false;
51608         drawLayer.style("display", "none");
51609         drawLayer.selectAll(".qaItem.keepRight").remove();
51610         touchLayer.selectAll(".qaItem.keepRight").remove();
51611       }
51612     }
51613     function layerOn() {
51614       editOn();
51615       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
51616     }
51617     function layerOff() {
51618       throttledRedraw.cancel();
51619       drawLayer.interrupt();
51620       touchLayer.selectAll(".qaItem.keepRight").remove();
51621       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
51622         editOff();
51623         dispatch14.call("change");
51624       });
51625     }
51626     function updateMarkers() {
51627       if (!layerVisible || !_layerEnabled)
51628         return;
51629       const service = getService();
51630       const selectedID = context.selectedErrorID();
51631       const data = service ? service.getItems(projection2) : [];
51632       const getTransform = svgPointTransform(projection2);
51633       const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51634       markers.exit().remove();
51635       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType));
51636       markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
51637       markersEnter.append("path").call(markerPath, "shadow");
51638       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");
51639       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
51640       if (touchLayer.empty())
51641         return;
51642       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
51643       const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51644       targets.exit().remove();
51645       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);
51646       function sortY(a2, b2) {
51647         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];
51648       }
51649     }
51650     function drawKeepRight(selection2) {
51651       const service = getService();
51652       const surface = context.surface();
51653       if (surface && !surface.empty()) {
51654         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
51655       }
51656       drawLayer = selection2.selectAll(".layer-keepRight").data(service ? [0] : []);
51657       drawLayer.exit().remove();
51658       drawLayer = drawLayer.enter().append("g").attr("class", "layer-keepRight").style("display", _layerEnabled ? "block" : "none").merge(drawLayer);
51659       if (_layerEnabled) {
51660         if (service && ~~context.map().zoom() >= minZoom4) {
51661           editOn();
51662           service.loadIssues(projection2);
51663           updateMarkers();
51664         } else {
51665           editOff();
51666         }
51667       }
51668     }
51669     drawKeepRight.enabled = function(val) {
51670       if (!arguments.length)
51671         return _layerEnabled;
51672       _layerEnabled = val;
51673       if (_layerEnabled) {
51674         layerOn();
51675       } else {
51676         layerOff();
51677         if (context.selectedErrorID()) {
51678           context.enter(modeBrowse(context));
51679         }
51680       }
51681       dispatch14.call("change");
51682       return this;
51683     };
51684     drawKeepRight.supported = () => !!getService();
51685     return drawKeepRight;
51686   }
51687
51688   // modules/svg/geolocate.js
51689   function svgGeolocate(projection2) {
51690     var layer = select_default2(null);
51691     var _position;
51692     function init2() {
51693       if (svgGeolocate.initialized)
51694         return;
51695       svgGeolocate.enabled = false;
51696       svgGeolocate.initialized = true;
51697     }
51698     function showLayer() {
51699       layer.style("display", "block");
51700     }
51701     function hideLayer() {
51702       layer.transition().duration(250).style("opacity", 0);
51703     }
51704     function layerOn() {
51705       layer.style("opacity", 0).transition().duration(250).style("opacity", 1);
51706     }
51707     function layerOff() {
51708       layer.style("display", "none");
51709     }
51710     function transform2(d2) {
51711       return svgPointTransform(projection2)(d2);
51712     }
51713     function accuracy(accuracy2, loc) {
51714       var degreesRadius = geoMetersToLat(accuracy2), tangentLoc = [loc[0], loc[1] + degreesRadius], projectedTangent = projection2(tangentLoc), projectedLoc = projection2([loc[0], loc[1]]);
51715       return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
51716     }
51717     function update() {
51718       var geolocation = { loc: [_position.coords.longitude, _position.coords.latitude] };
51719       var groups = layer.selectAll(".geolocations").selectAll(".geolocation").data([geolocation]);
51720       groups.exit().remove();
51721       var pointsEnter = groups.enter().append("g").attr("class", "geolocation");
51722       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");
51723       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");
51724       groups.merge(pointsEnter).attr("transform", transform2);
51725       layer.select(".geolocate-radius").attr("r", accuracy(_position.coords.accuracy, geolocation.loc));
51726     }
51727     function drawLocation(selection2) {
51728       var enabled = svgGeolocate.enabled;
51729       layer = selection2.selectAll(".layer-geolocate").data([0]);
51730       layer.exit().remove();
51731       var layerEnter = layer.enter().append("g").attr("class", "layer-geolocate").style("display", enabled ? "block" : "none");
51732       layerEnter.append("g").attr("class", "geolocations");
51733       layer = layerEnter.merge(layer);
51734       if (enabled) {
51735         update();
51736       } else {
51737         layerOff();
51738       }
51739     }
51740     drawLocation.enabled = function(position, enabled) {
51741       if (!arguments.length)
51742         return svgGeolocate.enabled;
51743       _position = position;
51744       svgGeolocate.enabled = enabled;
51745       if (svgGeolocate.enabled) {
51746         showLayer();
51747         layerOn();
51748       } else {
51749         hideLayer();
51750       }
51751       return this;
51752     };
51753     init2();
51754     return drawLocation;
51755   }
51756
51757   // modules/svg/labels.js
51758   var import_rbush6 = __toESM(require_rbush_min());
51759   function svgLabels(projection2, context) {
51760     var path = path_default(projection2);
51761     var detected = utilDetect();
51762     var baselineHack = detected.ie || detected.browser.toLowerCase() === "edge" || detected.browser.toLowerCase() === "firefox" && detected.version >= 70;
51763     var _rdrawn = new import_rbush6.default();
51764     var _rskipped = new import_rbush6.default();
51765     var _textWidthCache = {};
51766     var _entitybboxes = {};
51767     var labelStack = [
51768       ["line", "aeroway", "*", 12],
51769       ["line", "highway", "motorway", 12],
51770       ["line", "highway", "trunk", 12],
51771       ["line", "highway", "primary", 12],
51772       ["line", "highway", "secondary", 12],
51773       ["line", "highway", "tertiary", 12],
51774       ["line", "highway", "*", 12],
51775       ["line", "railway", "*", 12],
51776       ["line", "waterway", "*", 12],
51777       ["area", "aeroway", "*", 12],
51778       ["area", "amenity", "*", 12],
51779       ["area", "building", "*", 12],
51780       ["area", "historic", "*", 12],
51781       ["area", "leisure", "*", 12],
51782       ["area", "man_made", "*", 12],
51783       ["area", "natural", "*", 12],
51784       ["area", "shop", "*", 12],
51785       ["area", "tourism", "*", 12],
51786       ["area", "camp_site", "*", 12],
51787       ["point", "aeroway", "*", 10],
51788       ["point", "amenity", "*", 10],
51789       ["point", "building", "*", 10],
51790       ["point", "historic", "*", 10],
51791       ["point", "leisure", "*", 10],
51792       ["point", "man_made", "*", 10],
51793       ["point", "natural", "*", 10],
51794       ["point", "shop", "*", 10],
51795       ["point", "tourism", "*", 10],
51796       ["point", "camp_site", "*", 10],
51797       ["line", "ref", "*", 12],
51798       ["area", "ref", "*", 12],
51799       ["point", "ref", "*", 10],
51800       ["line", "name", "*", 12],
51801       ["area", "name", "*", 12],
51802       ["point", "name", "*", 10]
51803     ];
51804     function shouldSkipIcon(preset) {
51805       var noIcons = ["building", "landuse", "natural"];
51806       return noIcons.some(function(s2) {
51807         return preset.id.indexOf(s2) >= 0;
51808       });
51809     }
51810     function get4(array2, prop) {
51811       return function(d2, i3) {
51812         return array2[i3][prop];
51813       };
51814     }
51815     function textWidth(text, size, elem) {
51816       var c2 = _textWidthCache[size];
51817       if (!c2)
51818         c2 = _textWidthCache[size] = {};
51819       if (c2[text]) {
51820         return c2[text];
51821       } else if (elem) {
51822         c2[text] = elem.getComputedTextLength();
51823         return c2[text];
51824       } else {
51825         var str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
51826         if (str === null) {
51827           return size / 3 * 2 * text.length;
51828         } else {
51829           return size / 3 * (2 * text.length + str.length);
51830         }
51831       }
51832     }
51833     function drawLinePaths(selection2, entities, filter2, classes, labels) {
51834       var paths = selection2.selectAll("path").filter(filter2).data(entities, osmEntity.key);
51835       paths.exit().remove();
51836       paths.enter().append("path").style("stroke-width", get4(labels, "font-size")).attr("id", function(d2) {
51837         return "ideditor-labelpath-" + d2.id;
51838       }).attr("class", classes).merge(paths).attr("d", get4(labels, "lineString"));
51839     }
51840     function drawLineLabels(selection2, entities, filter2, classes, labels) {
51841       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51842       texts.exit().remove();
51843       texts.enter().append("text").attr("class", function(d2, i3) {
51844         return classes + " " + labels[i3].classes + " " + d2.id;
51845       }).attr("dy", baselineHack ? "0.35em" : null).append("textPath").attr("class", "textpath");
51846       selection2.selectAll("text." + classes).selectAll(".textpath").filter(filter2).data(entities, osmEntity.key).attr("startOffset", "50%").attr("xlink:href", function(d2) {
51847         return "#ideditor-labelpath-" + d2.id;
51848       }).text(utilDisplayNameForPath);
51849     }
51850     function drawPointLabels(selection2, entities, filter2, classes, labels) {
51851       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51852       texts.exit().remove();
51853       texts.enter().append("text").attr("class", function(d2, i3) {
51854         return classes + " " + labels[i3].classes + " " + d2.id;
51855       }).merge(texts).attr("x", get4(labels, "x")).attr("y", get4(labels, "y")).style("text-anchor", get4(labels, "textAnchor")).text(utilDisplayName).each(function(d2, i3) {
51856         textWidth(utilDisplayName(d2), labels[i3].height, this);
51857       });
51858     }
51859     function drawAreaLabels(selection2, entities, filter2, classes, labels) {
51860       entities = entities.filter(hasText);
51861       labels = labels.filter(hasText);
51862       drawPointLabels(selection2, entities, filter2, classes, labels);
51863       function hasText(d2, i3) {
51864         return labels[i3].hasOwnProperty("x") && labels[i3].hasOwnProperty("y");
51865       }
51866     }
51867     function drawAreaIcons(selection2, entities, filter2, classes, labels) {
51868       var icons = selection2.selectAll("use." + classes).filter(filter2).data(entities, osmEntity.key);
51869       icons.exit().remove();
51870       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) {
51871         var preset = _mainPresetIndex.match(d2, context.graph());
51872         var picon = preset && preset.icon;
51873         return picon ? "#" + picon : "";
51874       });
51875     }
51876     function drawCollisionBoxes(selection2, rtree, which) {
51877       var classes = "debug " + which + " " + (which === "debug-skipped" ? "orange" : "yellow");
51878       var gj = [];
51879       if (context.getDebug("collision")) {
51880         gj = rtree.all().map(function(d2) {
51881           return { type: "Polygon", coordinates: [[
51882             [d2.minX, d2.minY],
51883             [d2.maxX, d2.minY],
51884             [d2.maxX, d2.maxY],
51885             [d2.minX, d2.maxY],
51886             [d2.minX, d2.minY]
51887           ]] };
51888         });
51889       }
51890       var boxes = selection2.selectAll("." + which).data(gj);
51891       boxes.exit().remove();
51892       boxes.enter().append("path").attr("class", classes).merge(boxes).attr("d", path_default());
51893     }
51894     function drawLabels(selection2, graph, entities, filter2, dimensions, fullRedraw) {
51895       var wireframe = context.surface().classed("fill-wireframe");
51896       var zoom = geoScaleToZoom(projection2.scale());
51897       var labelable = [];
51898       var renderNodeAs = {};
51899       var i3, j2, k2, entity, geometry;
51900       for (i3 = 0; i3 < labelStack.length; i3++) {
51901         labelable.push([]);
51902       }
51903       if (fullRedraw) {
51904         _rdrawn.clear();
51905         _rskipped.clear();
51906         _entitybboxes = {};
51907       } else {
51908         for (i3 = 0; i3 < entities.length; i3++) {
51909           entity = entities[i3];
51910           var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []);
51911           for (j2 = 0; j2 < toRemove.length; j2++) {
51912             _rdrawn.remove(toRemove[j2]);
51913             _rskipped.remove(toRemove[j2]);
51914           }
51915         }
51916       }
51917       for (i3 = 0; i3 < entities.length; i3++) {
51918         entity = entities[i3];
51919         geometry = entity.geometry(graph);
51920         if (geometry === "point" || geometry === "vertex" && isInterestingVertex(entity)) {
51921           var hasDirections = entity.directions(graph, projection2).length;
51922           var markerPadding;
51923           if (!wireframe && geometry === "point" && !(zoom >= 18 && hasDirections)) {
51924             renderNodeAs[entity.id] = "point";
51925             markerPadding = 20;
51926           } else {
51927             renderNodeAs[entity.id] = "vertex";
51928             markerPadding = 0;
51929           }
51930           var coord2 = projection2(entity.loc);
51931           var nodePadding = 10;
51932           var bbox2 = {
51933             minX: coord2[0] - nodePadding,
51934             minY: coord2[1] - nodePadding - markerPadding,
51935             maxX: coord2[0] + nodePadding,
51936             maxY: coord2[1] + nodePadding
51937           };
51938           doInsert(bbox2, entity.id + "P");
51939         }
51940         if (geometry === "vertex") {
51941           geometry = "point";
51942         }
51943         var preset = geometry === "area" && _mainPresetIndex.match(entity, graph);
51944         var icon2 = preset && !shouldSkipIcon(preset) && preset.icon;
51945         if (!icon2 && !utilDisplayName(entity))
51946           continue;
51947         for (k2 = 0; k2 < labelStack.length; k2++) {
51948           var matchGeom = labelStack[k2][0];
51949           var matchKey = labelStack[k2][1];
51950           var matchVal = labelStack[k2][2];
51951           var hasVal = entity.tags[matchKey];
51952           if (geometry === matchGeom && hasVal && (matchVal === "*" || matchVal === hasVal)) {
51953             labelable[k2].push(entity);
51954             break;
51955           }
51956         }
51957       }
51958       var positions = {
51959         point: [],
51960         line: [],
51961         area: []
51962       };
51963       var labelled = {
51964         point: [],
51965         line: [],
51966         area: []
51967       };
51968       for (k2 = 0; k2 < labelable.length; k2++) {
51969         var fontSize = labelStack[k2][3];
51970         for (i3 = 0; i3 < labelable[k2].length; i3++) {
51971           entity = labelable[k2][i3];
51972           geometry = entity.geometry(graph);
51973           var getName = geometry === "line" ? utilDisplayNameForPath : utilDisplayName;
51974           var name = getName(entity);
51975           var width = name && textWidth(name, fontSize);
51976           var p2 = null;
51977           if (geometry === "point" || geometry === "vertex") {
51978             if (wireframe)
51979               continue;
51980             var renderAs = renderNodeAs[entity.id];
51981             if (renderAs === "vertex" && zoom < 17)
51982               continue;
51983             p2 = getPointLabel(entity, width, fontSize, renderAs);
51984           } else if (geometry === "line") {
51985             p2 = getLineLabel(entity, width, fontSize);
51986           } else if (geometry === "area") {
51987             p2 = getAreaLabel(entity, width, fontSize);
51988           }
51989           if (p2) {
51990             if (geometry === "vertex") {
51991               geometry = "point";
51992             }
51993             p2.classes = geometry + " tag-" + labelStack[k2][1];
51994             positions[geometry].push(p2);
51995             labelled[geometry].push(entity);
51996           }
51997         }
51998       }
51999       function isInterestingVertex(entity2) {
52000         var selectedIDs = context.selectedIDs();
52001         return entity2.hasInterestingTags() || entity2.isEndpoint(graph) || entity2.isConnected(graph) || selectedIDs.indexOf(entity2.id) !== -1 || graph.parentWays(entity2).some(function(parent) {
52002           return selectedIDs.indexOf(parent.id) !== -1;
52003         });
52004       }
52005       function getPointLabel(entity2, width2, height, geometry2) {
52006         var y2 = geometry2 === "point" ? -12 : 0;
52007         var pointOffsets = {
52008           ltr: [15, y2, "start"],
52009           rtl: [-15, y2, "end"]
52010         };
52011         var textDirection = _mainLocalizer.textDirection();
52012         var coord3 = projection2(entity2.loc);
52013         var textPadding = 2;
52014         var offset = pointOffsets[textDirection];
52015         var p3 = {
52016           height,
52017           width: width2,
52018           x: coord3[0] + offset[0],
52019           y: coord3[1] + offset[1],
52020           textAnchor: offset[2]
52021         };
52022         var bbox3;
52023         if (textDirection === "rtl") {
52024           bbox3 = {
52025             minX: p3.x - width2 - textPadding,
52026             minY: p3.y - height / 2 - textPadding,
52027             maxX: p3.x + textPadding,
52028             maxY: p3.y + height / 2 + textPadding
52029           };
52030         } else {
52031           bbox3 = {
52032             minX: p3.x - textPadding,
52033             minY: p3.y - height / 2 - textPadding,
52034             maxX: p3.x + width2 + textPadding,
52035             maxY: p3.y + height / 2 + textPadding
52036           };
52037         }
52038         if (tryInsert([bbox3], entity2.id, true)) {
52039           return p3;
52040         }
52041       }
52042       function getLineLabel(entity2, width2, height) {
52043         var viewport = geoExtent(context.projection.clipExtent()).polygon();
52044         var points = graph.childNodes(entity2).map(function(node) {
52045           return projection2(node.loc);
52046         });
52047         var length2 = geoPathLength(points);
52048         if (length2 < width2 + 20)
52049           return;
52050         var lineOffsets = [
52051           50,
52052           45,
52053           55,
52054           40,
52055           60,
52056           35,
52057           65,
52058           30,
52059           70,
52060           25,
52061           75,
52062           20,
52063           80,
52064           15,
52065           95,
52066           10,
52067           90,
52068           5,
52069           95
52070         ];
52071         var padding = 3;
52072         for (var i4 = 0; i4 < lineOffsets.length; i4++) {
52073           var offset = lineOffsets[i4];
52074           var middle = offset / 100 * length2;
52075           var start2 = middle - width2 / 2;
52076           if (start2 < 0 || start2 + width2 > length2)
52077             continue;
52078           var sub = subpath(points, start2, start2 + width2);
52079           if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) {
52080             continue;
52081           }
52082           var isReverse = reverse(sub);
52083           if (isReverse) {
52084             sub = sub.reverse();
52085           }
52086           var bboxes = [];
52087           var boxsize = (height + 2) / 2;
52088           for (var j3 = 0; j3 < sub.length - 1; j3++) {
52089             var a2 = sub[j3];
52090             var b2 = sub[j3 + 1];
52091             var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2));
52092             for (var box = 0; box < num; box++) {
52093               var p3 = geoVecInterp(a2, b2, box / num);
52094               var x05 = p3[0] - boxsize - padding;
52095               var y05 = p3[1] - boxsize - padding;
52096               var x12 = p3[0] + boxsize + padding;
52097               var y12 = p3[1] + boxsize + padding;
52098               bboxes.push({
52099                 minX: Math.min(x05, x12),
52100                 minY: Math.min(y05, y12),
52101                 maxX: Math.max(x05, x12),
52102                 maxY: Math.max(y05, y12)
52103               });
52104             }
52105           }
52106           if (tryInsert(bboxes, entity2.id, false)) {
52107             return {
52108               "font-size": height + 2,
52109               lineString: lineString2(sub),
52110               startOffset: offset + "%"
52111             };
52112           }
52113         }
52114         function reverse(p4) {
52115           var angle2 = Math.atan2(p4[1][1] - p4[0][1], p4[1][0] - p4[0][0]);
52116           return !(p4[0][0] < p4[p4.length - 1][0] && angle2 < Math.PI / 2 && angle2 > -Math.PI / 2);
52117         }
52118         function lineString2(points2) {
52119           return "M" + points2.join("L");
52120         }
52121         function subpath(points2, from, to) {
52122           var sofar = 0;
52123           var start3, end, i0, i1;
52124           for (var i5 = 0; i5 < points2.length - 1; i5++) {
52125             var a3 = points2[i5];
52126             var b3 = points2[i5 + 1];
52127             var current = geoVecLength(a3, b3);
52128             var portion;
52129             if (!start3 && sofar + current >= from) {
52130               portion = (from - sofar) / current;
52131               start3 = [
52132                 a3[0] + portion * (b3[0] - a3[0]),
52133                 a3[1] + portion * (b3[1] - a3[1])
52134               ];
52135               i0 = i5 + 1;
52136             }
52137             if (!end && sofar + current >= to) {
52138               portion = (to - sofar) / current;
52139               end = [
52140                 a3[0] + portion * (b3[0] - a3[0]),
52141                 a3[1] + portion * (b3[1] - a3[1])
52142               ];
52143               i1 = i5 + 1;
52144             }
52145             sofar += current;
52146           }
52147           var result = points2.slice(i0, i1);
52148           result.unshift(start3);
52149           result.push(end);
52150           return result;
52151         }
52152       }
52153       function getAreaLabel(entity2, width2, height) {
52154         var centroid = path.centroid(entity2.asGeoJSON(graph));
52155         var extent = entity2.extent(graph);
52156         var areaWidth = projection2(extent[1])[0] - projection2(extent[0])[0];
52157         if (isNaN(centroid[0]) || areaWidth < 20)
52158           return;
52159         var preset2 = _mainPresetIndex.match(entity2, context.graph());
52160         var picon = preset2 && preset2.icon;
52161         var iconSize = 17;
52162         var padding = 2;
52163         var p3 = {};
52164         if (picon) {
52165           if (addIcon()) {
52166             addLabel(iconSize + padding);
52167             return p3;
52168           }
52169         } else {
52170           if (addLabel(0)) {
52171             return p3;
52172           }
52173         }
52174         function addIcon() {
52175           var iconX = centroid[0] - iconSize / 2;
52176           var iconY = centroid[1] - iconSize / 2;
52177           var bbox3 = {
52178             minX: iconX,
52179             minY: iconY,
52180             maxX: iconX + iconSize,
52181             maxY: iconY + iconSize
52182           };
52183           if (tryInsert([bbox3], entity2.id + "I", true)) {
52184             p3.transform = "translate(" + iconX + "," + iconY + ")";
52185             return true;
52186           }
52187           return false;
52188         }
52189         function addLabel(yOffset) {
52190           if (width2 && areaWidth >= width2 + 20) {
52191             var labelX = centroid[0];
52192             var labelY = centroid[1] + yOffset;
52193             var bbox3 = {
52194               minX: labelX - width2 / 2 - padding,
52195               minY: labelY - height / 2 - padding,
52196               maxX: labelX + width2 / 2 + padding,
52197               maxY: labelY + height / 2 + padding
52198             };
52199             if (tryInsert([bbox3], entity2.id, true)) {
52200               p3.x = labelX;
52201               p3.y = labelY;
52202               p3.textAnchor = "middle";
52203               p3.height = height;
52204               return true;
52205             }
52206           }
52207           return false;
52208         }
52209       }
52210       function doInsert(bbox3, id2) {
52211         bbox3.id = id2;
52212         var oldbox = _entitybboxes[id2];
52213         if (oldbox) {
52214           _rdrawn.remove(oldbox);
52215         }
52216         _entitybboxes[id2] = bbox3;
52217         _rdrawn.insert(bbox3);
52218       }
52219       function tryInsert(bboxes, id2, saveSkipped) {
52220         var skipped = false;
52221         for (var i4 = 0; i4 < bboxes.length; i4++) {
52222           var bbox3 = bboxes[i4];
52223           bbox3.id = id2;
52224           if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) {
52225             skipped = true;
52226             break;
52227           }
52228           if (_rdrawn.collides(bbox3)) {
52229             skipped = true;
52230             break;
52231           }
52232         }
52233         _entitybboxes[id2] = bboxes;
52234         if (skipped) {
52235           if (saveSkipped) {
52236             _rskipped.load(bboxes);
52237           }
52238         } else {
52239           _rdrawn.load(bboxes);
52240         }
52241         return !skipped;
52242       }
52243       var layer = selection2.selectAll(".layer-osm.labels");
52244       layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) {
52245         return "labels-group " + d2;
52246       });
52247       var halo = layer.selectAll(".labels-group.halo");
52248       var label = layer.selectAll(".labels-group.label");
52249       var debug2 = layer.selectAll(".labels-group.debug");
52250       drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point);
52251       drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point);
52252       drawLinePaths(layer, labelled.line, filter2, "", positions.line);
52253       drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line);
52254       drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line);
52255       drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area);
52256       drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area);
52257       drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area);
52258       drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area);
52259       drawCollisionBoxes(debug2, _rskipped, "debug-skipped");
52260       drawCollisionBoxes(debug2, _rdrawn, "debug-drawn");
52261       layer.call(filterLabels);
52262     }
52263     function filterLabels(selection2) {
52264       var drawLayer = selection2.selectAll(".layer-osm.labels");
52265       var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label");
52266       layers.selectAll(".nolabel").classed("nolabel", false);
52267       var mouse = context.map().mouse();
52268       var graph = context.graph();
52269       var selectedIDs = context.selectedIDs();
52270       var ids = [];
52271       var pad2, bbox2;
52272       if (mouse) {
52273         pad2 = 20;
52274         bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 };
52275         var nearMouse = _rdrawn.search(bbox2).map(function(entity2) {
52276           return entity2.id;
52277         });
52278         ids.push.apply(ids, nearMouse);
52279       }
52280       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
52281         var entity = graph.hasEntity(selectedIDs[i3]);
52282         if (entity && entity.type === "node") {
52283           ids.push(selectedIDs[i3]);
52284         }
52285       }
52286       layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true);
52287       var debug2 = selection2.selectAll(".labels-group.debug");
52288       var gj = [];
52289       if (context.getDebug("collision")) {
52290         gj = bbox2 ? [{
52291           type: "Polygon",
52292           coordinates: [[
52293             [bbox2.minX, bbox2.minY],
52294             [bbox2.maxX, bbox2.minY],
52295             [bbox2.maxX, bbox2.maxY],
52296             [bbox2.minX, bbox2.maxY],
52297             [bbox2.minX, bbox2.minY]
52298           ]]
52299         }] : [];
52300       }
52301       var box = debug2.selectAll(".debug-mouse").data(gj);
52302       box.exit().remove();
52303       box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default());
52304     }
52305     var throttleFilterLabels = throttle_default(filterLabels, 100);
52306     drawLabels.observe = function(selection2) {
52307       var listener = function() {
52308         throttleFilterLabels(selection2);
52309       };
52310       selection2.on("mousemove.hidelabels", listener);
52311       context.on("enter.hidelabels", listener);
52312     };
52313     drawLabels.off = function(selection2) {
52314       throttleFilterLabels.cancel();
52315       selection2.on("mousemove.hidelabels", null);
52316       context.on("enter.hidelabels", null);
52317     };
52318     return drawLabels;
52319   }
52320
52321   // node_modules/exifr/dist/full.esm.mjs
52322   var e = "undefined" != typeof self ? self : global;
52323   var t = "undefined" != typeof navigator;
52324   var i2 = t && "undefined" == typeof HTMLImageElement;
52325   var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node);
52326   var s = e.Buffer;
52327   var r = e.BigInt;
52328   var a = !!s;
52329   var o = (e3) => e3;
52330   function l(e3, t2 = o) {
52331     if (n2)
52332       try {
52333         return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import(
52334           /* webpackIgnore: true */
52335           e3
52336         ).then(t2);
52337       } catch (t3) {
52338         console.warn("Couldn't load ".concat(e3));
52339       }
52340   }
52341   var h = e.fetch;
52342   var u = (e3) => h = e3;
52343   if (!e.fetch) {
52344     const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => {
52345       let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3);
52346       const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 };
52347       "" !== o2 && (f2.port = Number(o2));
52348       const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => {
52349         if (301 === e4.statusCode || 302 === e4.statusCode) {
52350           let t3 = new URL(e4.headers.location, n3).toString();
52351           return i3(t3, { headers: s2 }).then(r2).catch(a2);
52352         }
52353         r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => {
52354           let i4 = [];
52355           e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4)));
52356         }) });
52357       });
52358       d2.on("error", a2), d2.end();
52359     });
52360     u(i3);
52361   }
52362   function c(e3, t2, i3) {
52363     return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3;
52364   }
52365   var f = (e3) => p(e3) ? void 0 : e3;
52366   var d = (e3) => void 0 !== e3;
52367   function p(e3) {
52368     return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length);
52369   }
52370   function g2(e3) {
52371     let t2 = new Error(e3);
52372     throw delete t2.stack, t2;
52373   }
52374   function m(e3) {
52375     return "" === (e3 = function(e4) {
52376       for (; e4.endsWith("\0"); )
52377         e4 = e4.slice(0, -1);
52378       return e4;
52379     }(e3).trim()) ? void 0 : e3;
52380   }
52381   function S(e3) {
52382     let t2 = function(e4) {
52383       let t3 = 0;
52384       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;
52385     }(e3);
52386     return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2;
52387   }
52388   var C = (e3) => String.fromCharCode.apply(null, e3);
52389   var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0;
52390   function b(e3) {
52391     return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3)));
52392   }
52393   var I = class _I {
52394     static from(e3, t2) {
52395       return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2);
52396     }
52397     constructor(e3, t2 = 0, i3, n3) {
52398       if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3)
52399         this.byteOffset = 0, this.byteLength = 0;
52400       else if (e3 instanceof ArrayBuffer) {
52401         void 0 === i3 && (i3 = e3.byteLength - t2);
52402         let n4 = new DataView(e3, t2, i3);
52403         this._swapDataView(n4);
52404       } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) {
52405         void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer");
52406         let n4 = new DataView(e3.buffer, t2, i3);
52407         this._swapDataView(n4);
52408       } else if ("number" == typeof e3) {
52409         let t3 = new DataView(new ArrayBuffer(e3));
52410         this._swapDataView(t3);
52411       } else
52412         g2("Invalid input argument for BufferView: " + e3);
52413     }
52414     _swapArrayBuffer(e3) {
52415       this._swapDataView(new DataView(e3));
52416     }
52417     _swapBuffer(e3) {
52418       this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength));
52419     }
52420     _swapDataView(e3) {
52421       this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength;
52422     }
52423     _lengthToEnd(e3) {
52424       return this.byteLength - e3;
52425     }
52426     set(e3, t2, i3 = _I) {
52427       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);
52428     }
52429     subarray(e3, t2) {
52430       return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2);
52431     }
52432     toUint8() {
52433       return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
52434     }
52435     getUint8Array(e3, t2) {
52436       return new Uint8Array(this.buffer, this.byteOffset + e3, t2);
52437     }
52438     getString(e3 = 0, t2 = this.byteLength) {
52439       return b(this.getUint8Array(e3, t2));
52440     }
52441     getLatin1String(e3 = 0, t2 = this.byteLength) {
52442       let i3 = this.getUint8Array(e3, t2);
52443       return C(i3);
52444     }
52445     getUnicodeString(e3 = 0, t2 = this.byteLength) {
52446       const i3 = [];
52447       for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2)
52448         i3.push(this.getUint16(e3 + n3));
52449       return C(i3);
52450     }
52451     getInt8(e3) {
52452       return this.dataView.getInt8(e3);
52453     }
52454     getUint8(e3) {
52455       return this.dataView.getUint8(e3);
52456     }
52457     getInt16(e3, t2 = this.le) {
52458       return this.dataView.getInt16(e3, t2);
52459     }
52460     getInt32(e3, t2 = this.le) {
52461       return this.dataView.getInt32(e3, t2);
52462     }
52463     getUint16(e3, t2 = this.le) {
52464       return this.dataView.getUint16(e3, t2);
52465     }
52466     getUint32(e3, t2 = this.le) {
52467       return this.dataView.getUint32(e3, t2);
52468     }
52469     getFloat32(e3, t2 = this.le) {
52470       return this.dataView.getFloat32(e3, t2);
52471     }
52472     getFloat64(e3, t2 = this.le) {
52473       return this.dataView.getFloat64(e3, t2);
52474     }
52475     getFloat(e3, t2 = this.le) {
52476       return this.dataView.getFloat32(e3, t2);
52477     }
52478     getDouble(e3, t2 = this.le) {
52479       return this.dataView.getFloat64(e3, t2);
52480     }
52481     getUintBytes(e3, t2, i3) {
52482       switch (t2) {
52483         case 1:
52484           return this.getUint8(e3, i3);
52485         case 2:
52486           return this.getUint16(e3, i3);
52487         case 4:
52488           return this.getUint32(e3, i3);
52489         case 8:
52490           return this.getUint64 && this.getUint64(e3, i3);
52491       }
52492     }
52493     getUint(e3, t2, i3) {
52494       switch (t2) {
52495         case 8:
52496           return this.getUint8(e3, i3);
52497         case 16:
52498           return this.getUint16(e3, i3);
52499         case 32:
52500           return this.getUint32(e3, i3);
52501         case 64:
52502           return this.getUint64 && this.getUint64(e3, i3);
52503       }
52504     }
52505     toString(e3) {
52506       return this.dataView.toString(e3, this.constructor.name);
52507     }
52508     ensureChunk() {
52509     }
52510   };
52511   function P(e3, t2) {
52512     g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr."));
52513   }
52514   var k = class extends Map {
52515     constructor(e3) {
52516       super(), this.kind = e3;
52517     }
52518     get(e3, t2) {
52519       return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) {
52520         g2("Unknown ".concat(e4, " '").concat(t3, "'."));
52521       }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3);
52522     }
52523     keyList() {
52524       return Array.from(this.keys());
52525     }
52526   };
52527   var w = new k("file parser");
52528   var T = new k("segment parser");
52529   var A = new k("file reader");
52530   function D(e3, n3) {
52531     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");
52532   }
52533   function O(e3, i3) {
52534     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");
52535     var s2;
52536   }
52537   async function x(e3, t2, i3, n3) {
52538     return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) {
52539       let i4 = await t3(e4);
52540       return new I(i4);
52541     }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded"));
52542   }
52543   async function v(e3, t2, i3) {
52544     let n3 = new (A.get(i3))(e3, t2);
52545     return await n3.read(), n3;
52546   }
52547   var M = (e3) => h(e3).then((e4) => e4.arrayBuffer());
52548   var R = (e3) => new Promise((t2, i3) => {
52549     let n3 = new FileReader();
52550     n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3);
52551   });
52552   var L = class extends Map {
52553     get tagKeys() {
52554       return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys;
52555     }
52556     get tagValues() {
52557       return this.allValues || (this.allValues = Array.from(this.values())), this.allValues;
52558     }
52559   };
52560   function U(e3, t2, i3) {
52561     let n3 = new L();
52562     for (let [e4, t3] of i3)
52563       n3.set(e4, t3);
52564     if (Array.isArray(t2))
52565       for (let i4 of t2)
52566         e3.set(i4, n3);
52567     else
52568       e3.set(t2, n3);
52569     return n3;
52570   }
52571   function F(e3, t2, i3) {
52572     let n3, s2 = e3.get(t2);
52573     for (n3 of i3)
52574       s2.set(n3[0], n3[1]);
52575   }
52576   var E = /* @__PURE__ */ new Map();
52577   var B = /* @__PURE__ */ new Map();
52578   var N = /* @__PURE__ */ new Map();
52579   var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"];
52580   var V = ["jfif", "xmp", "icc", "iptc", "ihdr"];
52581   var z = ["tiff", ...V];
52582   var H = ["ifd0", "ifd1", "exif", "gps", "interop"];
52583   var j = [...z, ...H];
52584   var W = ["makerNote", "userComment"];
52585   var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"];
52586   var X = [...K, "sanitize", "mergeOutput", "silentErrors"];
52587   var _ = class {
52588     get translate() {
52589       return this.translateKeys || this.translateValues || this.reviveValues;
52590     }
52591   };
52592   var Y = class extends _ {
52593     get needed() {
52594       return this.enabled || this.deps.size > 0;
52595     }
52596     constructor(e3, t2, i3, n3) {
52597       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)
52598         if (Array.isArray(i3))
52599           this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick);
52600         else if ("object" == typeof i3) {
52601           if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) {
52602             let { pick: e4, skip: t3 } = i3;
52603             e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip);
52604           }
52605           this.applyInheritables(i3);
52606         } else
52607           true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3));
52608     }
52609     applyInheritables(e3) {
52610       let t2, i3;
52611       for (t2 of K)
52612         i3 = e3[t2], void 0 !== i3 && (this[t2] = i3);
52613     }
52614     translateTagSet(e3, t2) {
52615       if (this.dict) {
52616         let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict;
52617         for (i3 of e3)
52618           "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3);
52619       } else
52620         for (let i3 of e3)
52621           t2.add(i3);
52622     }
52623     finalizeFilters() {
52624       !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);
52625     }
52626   };
52627   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 };
52628   var J = /* @__PURE__ */ new Map();
52629   var q = class extends _ {
52630     static useCached(e3) {
52631       let t2 = J.get(e3);
52632       return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2;
52633     }
52634     constructor(e3) {
52635       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();
52636     }
52637     setupFromUndefined() {
52638       let e3;
52639       for (e3 of G)
52640         this[e3] = $2[e3];
52641       for (e3 of X)
52642         this[e3] = $2[e3];
52643       for (e3 of W)
52644         this[e3] = $2[e3];
52645       for (e3 of j)
52646         this[e3] = new Y(e3, $2[e3], void 0, this);
52647     }
52648     setupFromTrue() {
52649       let e3;
52650       for (e3 of G)
52651         this[e3] = $2[e3];
52652       for (e3 of X)
52653         this[e3] = $2[e3];
52654       for (e3 of W)
52655         this[e3] = true;
52656       for (e3 of j)
52657         this[e3] = new Y(e3, true, void 0, this);
52658     }
52659     setupFromArray(e3) {
52660       let t2;
52661       for (t2 of G)
52662         this[t2] = $2[t2];
52663       for (t2 of X)
52664         this[t2] = $2[t2];
52665       for (t2 of W)
52666         this[t2] = $2[t2];
52667       for (t2 of j)
52668         this[t2] = new Y(t2, false, void 0, this);
52669       this.setupGlobalFilters(e3, void 0, H);
52670     }
52671     setupFromObject(e3) {
52672       let t2;
52673       for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G))
52674         this[t2] = Z(e3[t2], $2[t2]);
52675       for (t2 of X)
52676         this[t2] = Z(e3[t2], $2[t2]);
52677       for (t2 of W)
52678         this[t2] = Z(e3[t2], $2[t2]);
52679       for (t2 of z)
52680         this[t2] = new Y(t2, $2[t2], e3[t2], this);
52681       for (t2 of H)
52682         this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff);
52683       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);
52684     }
52685     batchEnableWithBool(e3, t2) {
52686       for (let i3 of e3)
52687         this[i3].enabled = t2;
52688     }
52689     batchEnableWithUserValue(e3, t2) {
52690       for (let i3 of e3) {
52691         let e4 = t2[i3];
52692         this[i3].enabled = false !== e4 && void 0 !== e4;
52693       }
52694     }
52695     setupGlobalFilters(e3, t2, i3, n3 = i3) {
52696       if (e3 && e3.length) {
52697         for (let e4 of n3)
52698           this[e4].enabled = false;
52699         let t3 = Q(e3, i3);
52700         for (let [e4, i4] of t3)
52701           ee(this[e4].pick, i4), this[e4].enabled = true;
52702       } else if (t2 && t2.length) {
52703         let e4 = Q(t2, i3);
52704         for (let [t3, i4] of e4)
52705           ee(this[t3].skip, i4);
52706       }
52707     }
52708     filterNestedSegmentTags() {
52709       let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this;
52710       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);
52711     }
52712     traverseTiffDependencyTree() {
52713       let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this;
52714       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;
52715       for (let e4 of H)
52716         this[e4].finalizeFilters();
52717     }
52718     get onlyTiff() {
52719       return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled;
52720     }
52721     checkLoadedPlugins() {
52722       for (let e3 of z)
52723         this[e3].enabled && !T.has(e3) && P("segment parser", e3);
52724     }
52725   };
52726   function Q(e3, t2) {
52727     let i3, n3, s2, r2, a2 = [];
52728     for (s2 of t2) {
52729       for (r2 of (i3 = E.get(s2), n3 = [], i3))
52730         (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]);
52731       n3.length && a2.push([s2, n3]);
52732     }
52733     return a2;
52734   }
52735   function Z(e3, t2) {
52736     return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0;
52737   }
52738   function ee(e3, t2) {
52739     for (let i3 of t2)
52740       e3.add(i3);
52741   }
52742   c(q, "default", $2);
52743   var te = class {
52744     constructor(e3) {
52745       c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3);
52746     }
52747     async read(e3) {
52748       this.file = await D(e3, this.options);
52749     }
52750     setup() {
52751       if (this.fileParser)
52752         return;
52753       let { file: e3 } = this, t2 = e3.getUint16(0);
52754       for (let [i3, n3] of w)
52755         if (n3.canHandle(e3, t2))
52756           return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true;
52757       this.file.close && this.file.close(), g2("Unknown file format");
52758     }
52759     async parse() {
52760       let { output: e3, errors: t2 } = this;
52761       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);
52762     }
52763     async executeParsers() {
52764       let { output: e3 } = this;
52765       await this.fileParser.parse();
52766       let t2 = Object.values(this.parsers).map(async (t3) => {
52767         let i3 = await t3.parse();
52768         t3.assignToOutput(e3, i3);
52769       });
52770       this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2);
52771     }
52772     async extractThumbnail() {
52773       this.setup();
52774       let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3);
52775       var n3;
52776       if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3)
52777         return;
52778       let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail();
52779       return t2.close && t2.close(), a2;
52780     }
52781   };
52782   async function ie(e3, t2) {
52783     let i3 = new te(t2);
52784     return await i3.read(e3), i3.parse();
52785   }
52786   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 });
52787   var se = class {
52788     constructor(e3, t2, i3) {
52789       c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => {
52790         let t3 = e4.start, i4 = e4.size || 65536;
52791         if (this.file.chunked)
52792           if (this.file.available(t3, i4))
52793             e4.chunk = this.file.subarray(t3, i4);
52794           else
52795             try {
52796               e4.chunk = await this.file.readChunk(t3, i4);
52797             } catch (t4) {
52798               g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message));
52799             }
52800         else
52801           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));
52802         return e4.chunk;
52803       }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3;
52804     }
52805     injectSegment(e3, t2) {
52806       this.options[e3].enabled && this.createParser(e3, t2);
52807     }
52808     createParser(e3, t2) {
52809       let i3 = new (T.get(e3))(t2, this.options, this.file);
52810       return this.parsers[e3] = i3;
52811     }
52812     createParsers(e3) {
52813       for (let t2 of e3) {
52814         let { type: e4, chunk: i3 } = t2, n3 = this.options[e4];
52815         if (n3 && n3.enabled) {
52816           let t3 = this.parsers[e4];
52817           t3 && t3.append || t3 || this.createParser(e4, i3);
52818         }
52819       }
52820     }
52821     async readSegments(e3) {
52822       let t2 = e3.map(this.ensureSegmentChunk);
52823       await Promise.all(t2);
52824     }
52825   };
52826   var re2 = class {
52827     static findPosition(e3, t2) {
52828       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;
52829       return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 };
52830     }
52831     static parse(e3, t2 = {}) {
52832       return new this(e3, new q({ [this.type]: t2 }), e3).parse();
52833     }
52834     normalizeInput(e3) {
52835       return e3 instanceof I ? e3 : new I(e3);
52836     }
52837     constructor(e3, t2 = {}, i3) {
52838       c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => {
52839         if (!this.options.silentErrors)
52840           throw e4;
52841         this.errors.push(e4.message);
52842       }), 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;
52843     }
52844     translate() {
52845       this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type));
52846     }
52847     get output() {
52848       return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0;
52849     }
52850     translateBlock(e3, t2) {
52851       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 = {};
52852       for (let [t3, r3] of e3)
52853         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;
52854       return h2;
52855     }
52856     translateValue(e3, t2) {
52857       return t2[e3] || t2.DEFAULT || e3;
52858     }
52859     assignToOutput(e3, t2) {
52860       this.assignObjectToOutput(e3, this.constructor.type, t2);
52861     }
52862     assignObjectToOutput(e3, t2, i3) {
52863       if (this.globalOptions.mergeOutput)
52864         return Object.assign(e3, i3);
52865       e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3;
52866     }
52867   };
52868   c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false);
52869   function ae(e3) {
52870     return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3;
52871   }
52872   function oe(e3) {
52873     return e3 >= 224 && e3 <= 239;
52874   }
52875   function le(e3, t2, i3) {
52876     for (let [n3, s2] of T)
52877       if (s2.canHandle(e3, t2, i3))
52878         return n3;
52879   }
52880   var he = class extends se {
52881     constructor(...e3) {
52882       super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []);
52883     }
52884     static canHandle(e3, t2) {
52885       return 65496 === t2;
52886     }
52887     async parse() {
52888       await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments);
52889     }
52890     setupSegmentFinderArgs(e3) {
52891       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;
52892     }
52893     async findAppSegments(e3 = 0, t2) {
52894       this.setupSegmentFinderArgs(t2);
52895       let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this;
52896       if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => {
52897         let t3 = T.get(e4), i4 = this.options[e4];
52898         return t3.multiSegment && i4.multiSegment;
52899       }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) {
52900         let t3 = false;
52901         for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) {
52902           let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size));
52903           if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength)))
52904             return;
52905         }
52906       }
52907     }
52908     findAppSegmentsInRange(e3, t2) {
52909       t2 -= 2;
52910       let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this;
52911       for (; e3 < t2; e3++)
52912         if (255 === l2.getUint8(e3)) {
52913           if (i3 = l2.getUint8(e3 + 1), oe(i3)) {
52914             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)))
52915               break;
52916             f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1;
52917           } else if (ae(i3)) {
52918             if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos)
52919               return;
52920             f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1;
52921           }
52922         }
52923       return e3;
52924     }
52925     mergeMultiSegments() {
52926       if (!this.appSegments.some((e4) => e4.multiSegment))
52927         return;
52928       let e3 = function(e4, t2) {
52929         let i3, n3, s2, r2 = /* @__PURE__ */ new Map();
52930         for (let a2 = 0; a2 < e4.length; a2++)
52931           i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3);
52932         return Array.from(r2);
52933       }(this.appSegments, "type");
52934       this.mergedAppSegments = e3.map(([e4, t2]) => {
52935         let i3 = T.get(e4, this.options);
52936         if (i3.handleMultiSegments) {
52937           return { type: e4, chunk: i3.handleMultiSegments(t2) };
52938         }
52939         return t2[0];
52940       });
52941     }
52942     getSegment(e3) {
52943       return this.appSegments.find((t2) => t2.type === e3);
52944     }
52945     async getOrFindSegment(e3) {
52946       let t2 = this.getSegment(e3);
52947       return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2;
52948     }
52949   };
52950   c(he, "type", "jpeg"), w.set("jpeg", he);
52951   var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4];
52952   var ce = class extends re2 {
52953     parseHeader() {
52954       var e3 = this.chunk.getUint16();
52955       18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true;
52956     }
52957     parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) {
52958       let { pick: n3, skip: s2 } = this.options[t2];
52959       n3 = new Set(n3);
52960       let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3);
52961       e3 += 2;
52962       for (let l2 = 0; l2 < o2; l2++) {
52963         let o3 = this.chunk.getUint16(e3);
52964         if (r2) {
52965           if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size))
52966             break;
52967         } else
52968           !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2));
52969         e3 += 12;
52970       }
52971       return i3;
52972     }
52973     parseTag(e3, t2, i3) {
52974       let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2];
52975       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)
52976         return n3.getUint8Array(e3, r2);
52977       if (2 === s2)
52978         return m(n3.getString(e3, r2));
52979       if (7 === s2)
52980         return n3.getUint8Array(e3, r2);
52981       if (1 === r2)
52982         return this.parseTagValue(s2, e3);
52983       {
52984         let t3 = new (function(e4) {
52985           switch (e4) {
52986             case 1:
52987               return Uint8Array;
52988             case 3:
52989               return Uint16Array;
52990             case 4:
52991               return Uint32Array;
52992             case 5:
52993               return Array;
52994             case 6:
52995               return Int8Array;
52996             case 8:
52997               return Int16Array;
52998             case 9:
52999               return Int32Array;
53000             case 10:
53001               return Array;
53002             case 11:
53003               return Float32Array;
53004             case 12:
53005               return Float64Array;
53006             default:
53007               return Array;
53008           }
53009         }(s2))(r2), i4 = a2;
53010         for (let n4 = 0; n4 < r2; n4++)
53011           t3[n4] = this.parseTagValue(s2, e3), e3 += i4;
53012         return t3;
53013       }
53014     }
53015     parseTagValue(e3, t2) {
53016       let { chunk: i3 } = this;
53017       switch (e3) {
53018         case 1:
53019           return i3.getUint8(t2);
53020         case 3:
53021           return i3.getUint16(t2);
53022         case 4:
53023           return i3.getUint32(t2);
53024         case 5:
53025           return i3.getUint32(t2) / i3.getUint32(t2 + 4);
53026         case 6:
53027           return i3.getInt8(t2);
53028         case 8:
53029           return i3.getInt16(t2);
53030         case 9:
53031           return i3.getInt32(t2);
53032         case 10:
53033           return i3.getInt32(t2) / i3.getInt32(t2 + 4);
53034         case 11:
53035           return i3.getFloat(t2);
53036         case 12:
53037           return i3.getDouble(t2);
53038         case 13:
53039           return i3.getUint32(t2);
53040         default:
53041           g2("Invalid tiff type ".concat(e3));
53042       }
53043     }
53044   };
53045   var fe = class extends ce {
53046     static canHandle(e3, t2) {
53047       return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8);
53048     }
53049     async parse() {
53050       this.parseHeader();
53051       let { options: e3 } = this;
53052       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();
53053     }
53054     safeParse(e3) {
53055       let t2 = this[e3]();
53056       return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2;
53057     }
53058     findIfd0Offset() {
53059       void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4));
53060     }
53061     findIfd1Offset() {
53062       if (void 0 === this.ifd1Offset) {
53063         this.findIfd0Offset();
53064         let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3;
53065         this.ifd1Offset = this.chunk.getUint32(t2);
53066       }
53067     }
53068     parseBlock(e3, t2) {
53069       let i3 = /* @__PURE__ */ new Map();
53070       return this[t2] = i3, this.parseTags(e3, t2, i3), i3;
53071     }
53072     async parseIfd0Block() {
53073       if (this.ifd0)
53074         return;
53075       let { file: e3 } = this;
53076       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));
53077       let t2 = this.parseBlock(this.ifd0Offset, "ifd0");
53078       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;
53079     }
53080     async parseExifBlock() {
53081       if (this.exif)
53082         return;
53083       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset)
53084         return;
53085       this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options));
53086       let e3 = this.parseBlock(this.exifOffset, "exif");
53087       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;
53088     }
53089     unpack(e3, t2) {
53090       let i3 = e3.get(t2);
53091       i3 && 1 === i3.length && e3.set(t2, i3[0]);
53092     }
53093     async parseGpsBlock() {
53094       if (this.gps)
53095         return;
53096       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset)
53097         return;
53098       let e3 = this.parseBlock(this.gpsOffset, "gps");
53099       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;
53100     }
53101     async parseInteropBlock() {
53102       if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset))
53103         return this.parseBlock(this.interopOffset, "interop");
53104     }
53105     async parseThumbnailBlock(e3 = false) {
53106       if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3))
53107         return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1;
53108     }
53109     async extractThumbnail() {
53110       if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1)
53111         return;
53112       let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514);
53113       return this.chunk.getUint8Array(e3, t2);
53114     }
53115     get image() {
53116       return this.ifd0;
53117     }
53118     get thumbnail() {
53119       return this.ifd1;
53120     }
53121     createOutput() {
53122       let e3, t2, i3, n3 = {};
53123       for (t2 of H)
53124         if (e3 = this[t2], !p(e3))
53125           if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) {
53126             if ("ifd1" === t2)
53127               continue;
53128             Object.assign(n3, i3);
53129           } else
53130             n3[t2] = i3;
53131       return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3;
53132     }
53133     assignToOutput(e3, t2) {
53134       if (this.globalOptions.mergeOutput)
53135         Object.assign(e3, t2);
53136       else
53137         for (let [i3, n3] of Object.entries(t2))
53138           this.assignObjectToOutput(e3, i3, n3);
53139     }
53140   };
53141   function de(e3, t2, i3, n3) {
53142     var s2 = e3 + t2 / 60 + i3 / 3600;
53143     return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2;
53144   }
53145   c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe);
53146   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 });
53147   var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false };
53148   var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] });
53149   async function Se(e3) {
53150     let t2 = new te(me);
53151     await t2.read(e3);
53152     let i3 = await t2.parse();
53153     if (i3 && i3.gps) {
53154       let { latitude: e4, longitude: t3 } = i3.gps;
53155       return { latitude: e4, longitude: t3 };
53156     }
53157   }
53158   var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false });
53159   async function ye(e3) {
53160     let t2 = new te(Ce);
53161     await t2.read(e3);
53162     let i3 = await t2.extractThumbnail();
53163     return i3 && a ? s.from(i3) : i3;
53164   }
53165   async function be(e3) {
53166     let t2 = await this.thumbnail(e3);
53167     if (void 0 !== t2) {
53168       let e4 = new Blob([t2]);
53169       return URL.createObjectURL(e4);
53170     }
53171   }
53172   var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] });
53173   async function Pe(e3) {
53174     let t2 = new te(Ie);
53175     await t2.read(e3);
53176     let i3 = await t2.parse();
53177     if (i3 && i3.ifd0)
53178       return i3.ifd0[274];
53179   }
53180   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 } });
53181   var we = true;
53182   var Te = true;
53183   if ("object" == typeof navigator) {
53184     let e3 = navigator.userAgent;
53185     if (e3.includes("iPad") || e3.includes("iPhone")) {
53186       let t2 = e3.match(/OS (\d+)_(\d+)/);
53187       if (t2) {
53188         let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3);
53189         we = n3 < 13.4, Te = false;
53190       }
53191     } else if (e3.includes("OS X 10")) {
53192       let [, t2] = e3.match(/OS X 10[_.](\d+)/);
53193       we = Te = Number(t2) < 15;
53194     }
53195     if (e3.includes("Chrome/")) {
53196       let [, t2] = e3.match(/Chrome\/(\d+)/);
53197       we = Te = Number(t2) < 81;
53198     } else if (e3.includes("Firefox/")) {
53199       let [, t2] = e3.match(/Firefox\/(\d+)/);
53200       we = Te = Number(t2) < 77;
53201     }
53202   }
53203   async function Ae(e3) {
53204     let t2 = await Pe(e3);
53205     return Object.assign({ canvas: we, css: Te }, ke[t2]);
53206   }
53207   var De = class extends I {
53208     constructor(...e3) {
53209       super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength);
53210     }
53211     _tryExtend(e3, t2, i3) {
53212       if (0 === e3 && 0 === this.byteLength && i3) {
53213         let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength);
53214         this._swapDataView(e4);
53215       } else {
53216         let i4 = e3 + t2;
53217         if (i4 > this.byteLength) {
53218           let { dataView: e4 } = this._extend(i4);
53219           this._swapDataView(e4);
53220         }
53221       }
53222     }
53223     _extend(e3) {
53224       let t2;
53225       t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3);
53226       let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength);
53227       return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 };
53228     }
53229     subarray(e3, t2, i3 = false) {
53230       return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2);
53231     }
53232     set(e3, t2, i3 = false) {
53233       i3 && this._tryExtend(t2, e3.byteLength, e3);
53234       let n3 = super.set(e3, t2);
53235       return this.ranges.add(t2, n3.byteLength), n3;
53236     }
53237     async ensureChunk(e3, t2) {
53238       this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2));
53239     }
53240     available(e3, t2) {
53241       return this.ranges.available(e3, t2);
53242     }
53243   };
53244   var Oe = class {
53245     constructor() {
53246       c(this, "list", []);
53247     }
53248     get length() {
53249       return this.list.length;
53250     }
53251     add(e3, t2, i3 = 0) {
53252       let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3));
53253       if (s2.length > 0) {
53254         e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3;
53255         let i4 = s2.shift();
53256         i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4));
53257       } else
53258         this.list.push({ offset: e3, length: t2, end: n3 });
53259     }
53260     available(e3, t2) {
53261       let i3 = e3 + t2;
53262       return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end);
53263     }
53264   };
53265   function xe(e3, t2, i3) {
53266     return e3 <= t2 && t2 <= i3;
53267   }
53268   var ve = class extends De {
53269     constructor(e3, t2) {
53270       super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2;
53271     }
53272     async readWhole() {
53273       this.chunked = false, await this.readChunk(this.nextChunkOffset);
53274     }
53275     async readChunked() {
53276       this.chunked = true, await this.readChunk(0, this.options.firstChunkSize);
53277     }
53278     async readNextChunk(e3 = this.nextChunkOffset) {
53279       if (this.fullyRead)
53280         return this.chunksRead++, false;
53281       let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2);
53282       return !!i3 && i3.byteLength === t2;
53283     }
53284     async readChunk(e3, t2) {
53285       if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2)))
53286         return this._readChunk(e3, t2);
53287     }
53288     safeWrapAddress(e3, t2) {
53289       return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2;
53290     }
53291     get nextChunkOffset() {
53292       if (0 !== this.ranges.list.length)
53293         return this.ranges.list[0].length;
53294     }
53295     get canReadNextChunk() {
53296       return this.chunksRead < this.options.chunkLimit;
53297     }
53298     get fullyRead() {
53299       return void 0 !== this.size && this.nextChunkOffset === this.size;
53300     }
53301     read() {
53302       return this.options.chunked ? this.readChunked() : this.readWhole();
53303     }
53304     close() {
53305     }
53306   };
53307   A.set("blob", class extends ve {
53308     async readWhole() {
53309       this.chunked = false;
53310       let e3 = await R(this.input);
53311       this._swapArrayBuffer(e3);
53312     }
53313     readChunked() {
53314       return this.chunked = true, this.size = this.input.size, super.readChunked();
53315     }
53316     async _readChunk(e3, t2) {
53317       let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3);
53318       return this.set(s2, e3, true);
53319     }
53320   });
53321   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() {
53322     return we;
53323   }, get rotateCss() {
53324     return Te;
53325   }, rotation: Ae });
53326   A.set("url", class extends ve {
53327     async readWhole() {
53328       this.chunked = false;
53329       let e3 = await M(this.input);
53330       e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3);
53331     }
53332     async _readChunk(e3, t2) {
53333       let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {};
53334       (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-")));
53335       let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength;
53336       if (416 !== s2.status)
53337         return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true);
53338     }
53339   });
53340   I.prototype.getUint64 = function(e3) {
53341     let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4);
53342     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.");
53343   };
53344   var Re = class extends se {
53345     parseBoxes(e3 = 0) {
53346       let t2 = [];
53347       for (; e3 < this.file.byteLength - 4; ) {
53348         let i3 = this.parseBoxHead(e3);
53349         if (t2.push(i3), 0 === i3.length)
53350           break;
53351         e3 += i3.length;
53352       }
53353       return t2;
53354     }
53355     parseSubBoxes(e3) {
53356       e3.boxes = this.parseBoxes(e3.start);
53357     }
53358     findBox(e3, t2) {
53359       return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2);
53360     }
53361     parseBoxHead(e3) {
53362       let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8;
53363       return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 };
53364     }
53365     parseBoxFullHead(e3) {
53366       if (void 0 !== e3.version)
53367         return;
53368       let t2 = this.file.getUint32(e3.start);
53369       e3.version = t2 >> 24, e3.start += 4;
53370     }
53371   };
53372   var Le = class extends Re {
53373     static canHandle(e3, t2) {
53374       if (0 !== t2)
53375         return false;
53376       let i3 = e3.getUint16(2);
53377       if (i3 > 50)
53378         return false;
53379       let n3 = 16, s2 = [];
53380       for (; n3 < i3; )
53381         s2.push(e3.getString(n3, 4)), n3 += 4;
53382       return s2.includes(this.type);
53383     }
53384     async parse() {
53385       let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3);
53386       for (; "meta" !== t2.kind; )
53387         e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3);
53388       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);
53389     }
53390     async registerSegment(e3, t2, i3) {
53391       await this.file.ensureChunk(t2, i3);
53392       let n3 = this.file.subarray(t2, i3);
53393       this.createParser(e3, n3);
53394     }
53395     async findIcc(e3) {
53396       let t2 = this.findBox(e3, "iprp");
53397       if (void 0 === t2)
53398         return;
53399       let i3 = this.findBox(t2, "ipco");
53400       if (void 0 === i3)
53401         return;
53402       let n3 = this.findBox(i3, "colr");
53403       void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length);
53404     }
53405     async findExif(e3) {
53406       let t2 = this.findBox(e3, "iinf");
53407       if (void 0 === t2)
53408         return;
53409       let i3 = this.findBox(e3, "iloc");
53410       if (void 0 === i3)
53411         return;
53412       let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3);
53413       if (void 0 === s2)
53414         return;
53415       let [r2, a2] = s2;
53416       await this.file.ensureChunk(r2, a2);
53417       let o2 = 4 + this.file.getUint32(r2);
53418       r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2);
53419     }
53420     findExifLocIdInIinf(e3) {
53421       this.parseBoxFullHead(e3);
53422       let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2);
53423       for (r2 += 2; a2--; ) {
53424         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))
53425           return this.file.getUintBytes(i3, n3);
53426         r2 += t2.length;
53427       }
53428     }
53429     get8bits(e3) {
53430       let t2 = this.file.getUint8(e3);
53431       return [t2 >> 4, 15 & t2];
53432     }
53433     findExtentInIloc(e3, t2) {
53434       this.parseBoxFullHead(e3);
53435       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);
53436       for (i3 += u2; c2--; ) {
53437         let e4 = this.file.getUintBytes(i3, o2);
53438         i3 += o2 + l2 + 2 + r2;
53439         let u3 = this.file.getUint16(i3);
53440         if (i3 += 2, e4 === t2)
53441           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)];
53442         i3 += u3 * h2;
53443       }
53444     }
53445   };
53446   var Ue = class extends Le {
53447   };
53448   c(Ue, "type", "heic");
53449   var Fe = class extends Le {
53450   };
53451   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" }]]);
53452   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" }]]);
53453   var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" };
53454   Ee.set(37392, Be), Ee.set(41488, Be);
53455   var Ne = { 0: "Normal", 1: "Low", 2: "High" };
53456   function Ge(e3) {
53457     return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3;
53458   }
53459   function Ve(e3) {
53460     let t2 = Array.from(e3).slice(1);
53461     return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join(".");
53462   }
53463   function ze(e3) {
53464     if ("string" == typeof e3) {
53465       var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3);
53466       return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2;
53467     }
53468   }
53469   function He(e3) {
53470     if ("string" == typeof e3)
53471       return e3;
53472     let t2 = [];
53473     if (0 === e3[1] && 0 === e3[e3.length - 1])
53474       for (let i3 = 0; i3 < e3.length; i3 += 2)
53475         t2.push(je(e3[i3 + 1], e3[i3]));
53476     else
53477       for (let i3 = 0; i3 < e3.length; i3 += 2)
53478         t2.push(je(e3[i3], e3[i3 + 1]));
53479     return m(String.fromCodePoint(...t2));
53480   }
53481   function je(e3, t2) {
53482     return e3 << 8 | t2;
53483   }
53484   Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) {
53485     return "string" != typeof e3 ? b(e3) : e3;
53486   }], [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(":")]]);
53487   var We = class extends re2 {
53488     static canHandle(e3, t2) {
53489       return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length);
53490     }
53491     static headerLength(e3, t2) {
53492       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;
53493     }
53494     static findPosition(e3, t2) {
53495       let i3 = super.findPosition(e3, t2);
53496       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;
53497     }
53498     static handleMultiSegments(e3) {
53499       return e3.map((e4) => e4.chunk.getString()).join("");
53500     }
53501     normalizeInput(e3) {
53502       return "string" == typeof e3 ? e3 : I.from(e3).getString();
53503     }
53504     parse(e3 = this.chunk) {
53505       if (!this.localOptions.parse)
53506         return e3;
53507       e3 = function(e4) {
53508         let t3 = {}, i4 = {};
53509         for (let e6 of Ze)
53510           t3[e6] = [], i4[e6] = 0;
53511         return e4.replace(et, (e6, n4, s2) => {
53512           if ("<" === n4) {
53513             let n5 = ++i4[s2];
53514             return t3[s2].push(n5), "".concat(e6, "#").concat(n5);
53515           }
53516           return "".concat(e6, "#").concat(t3[s2].pop());
53517         });
53518       }(e3);
53519       let t2 = Xe.findAll(e3, "rdf", "Description");
53520       0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3));
53521       let i3, n3 = {};
53522       for (let e4 of t2)
53523         for (let t3 of e4.properties)
53524           i3 = Je(t3.ns, n3), _e(t3, i3);
53525       return function(e4) {
53526         let t3;
53527         for (let i4 in e4)
53528           t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4];
53529         return f(e4);
53530       }(n3);
53531     }
53532     assignToOutput(e3, t2) {
53533       if (this.localOptions.parse)
53534         for (let [i3, n3] of Object.entries(t2))
53535           switch (i3) {
53536             case "tiff":
53537               this.assignObjectToOutput(e3, "ifd0", n3);
53538               break;
53539             case "exif":
53540               this.assignObjectToOutput(e3, "exif", n3);
53541               break;
53542             case "xmlns":
53543               break;
53544             default:
53545               this.assignObjectToOutput(e3, i3, n3);
53546           }
53547       else
53548         e3.xmp = t2;
53549     }
53550   };
53551   c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We);
53552   var Ke = class _Ke {
53553     static findAll(e3) {
53554       return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch);
53555     }
53556     static unpackMatch(e3) {
53557       let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1);
53558       return n3 = Qe(n3), new _Ke(t2, i3, n3);
53559     }
53560     constructor(e3, t2, i3) {
53561       this.ns = e3, this.name = t2, this.value = i3;
53562     }
53563     serialize() {
53564       return this.value;
53565     }
53566   };
53567   var Xe = class _Xe {
53568     static findAll(e3, t2, i3) {
53569       if (void 0 !== t2 || void 0 !== i3) {
53570         t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+";
53571         var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm");
53572       } else
53573         n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;
53574       return qe(e3, n3).map(_Xe.unpackMatch);
53575     }
53576     static unpackMatch(e3) {
53577       let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8];
53578       return new _Xe(t2, i3, n3, s2);
53579     }
53580     constructor(e3, t2, i3, n3) {
53581       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];
53582     }
53583     get isPrimitive() {
53584       return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length;
53585     }
53586     get isListContainer() {
53587       return 1 === this.children.length && this.children[0].isList;
53588     }
53589     get isList() {
53590       let { ns: e3, name: t2 } = this;
53591       return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2);
53592     }
53593     get isListItem() {
53594       return "rdf" === this.ns && "li" === this.name;
53595     }
53596     serialize() {
53597       if (0 === this.properties.length && void 0 === this.value)
53598         return;
53599       if (this.isPrimitive)
53600         return this.value;
53601       if (this.isListContainer)
53602         return this.children[0].serialize();
53603       if (this.isList)
53604         return $e(this.children.map(Ye));
53605       if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length)
53606         return this.children[0].serialize();
53607       let e3 = {};
53608       for (let t2 of this.properties)
53609         _e(t2, e3);
53610       return void 0 !== this.value && (e3.value = this.value), f(e3);
53611     }
53612   };
53613   function _e(e3, t2) {
53614     let i3 = e3.serialize();
53615     void 0 !== i3 && (t2[e3.name] = i3);
53616   }
53617   var Ye = (e3) => e3.serialize();
53618   var $e = (e3) => 1 === e3.length ? e3[0] : e3;
53619   var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {};
53620   function qe(e3, t2) {
53621     let i3, n3 = [];
53622     if (!e3)
53623       return n3;
53624     for (; null !== (i3 = t2.exec(e3)); )
53625       n3.push(i3);
53626     return n3;
53627   }
53628   function Qe(e3) {
53629     if (function(e4) {
53630       return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim();
53631     }(e3))
53632       return;
53633     let t2 = Number(e3);
53634     if (!Number.isNaN(t2))
53635       return t2;
53636     let i3 = e3.toLowerCase();
53637     return "true" === i3 || "false" !== i3 && e3.trim();
53638   }
53639   var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"];
53640   var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g");
53641   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() {
53642     return we;
53643   }, get rotateCss() {
53644     return Te;
53645   }, rotation: Ae });
53646   var at = l("fs", (e3) => e3.promises);
53647   A.set("fs", class extends ve {
53648     async readWhole() {
53649       this.chunked = false, this.fs = await at;
53650       let e3 = await this.fs.readFile(this.input);
53651       this._swapBuffer(e3);
53652     }
53653     async readChunked() {
53654       this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize);
53655     }
53656     async open() {
53657       void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size);
53658     }
53659     async _readChunk(e3, t2) {
53660       void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3);
53661       var i3 = this.subarray(e3, t2, true);
53662       return await this.fh.read(i3.dataView, 0, t2, e3), i3;
53663     }
53664     async close() {
53665       if (this.fh) {
53666         let e3 = this.fh;
53667         this.fh = void 0, await e3.close();
53668       }
53669     }
53670   });
53671   A.set("base64", class extends ve {
53672     constructor(...e3) {
53673       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);
53674     }
53675     async _readChunk(e3, t2) {
53676       let i3, n3, r2 = this.input;
53677       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);
53678       let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3);
53679       r2 = r2.slice(i3, l2);
53680       let h2 = Math.min(t2, this.size - e3);
53681       if (a) {
53682         let t3 = s.from(r2, "base64").slice(n3, n3 + h2);
53683         return this.set(t3, e3, true);
53684       }
53685       {
53686         let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8();
53687         for (let e4 = 0; e4 < h2; e4++)
53688           s2[e4] = i4.charCodeAt(n3 + e4);
53689         return t3;
53690       }
53691     }
53692   });
53693   var ot = class extends se {
53694     static canHandle(e3, t2) {
53695       return 18761 === t2 || 19789 === t2;
53696     }
53697     extendOptions(e3) {
53698       let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3;
53699       i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters();
53700     }
53701     async parse() {
53702       let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options;
53703       if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) {
53704         let e4 = Math.max(S(this.options), this.options.chunkSize);
53705         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");
53706       }
53707     }
53708     adaptTiffPropAsSegment(e3) {
53709       if (this.parsers.tiff[e3]) {
53710         let t2 = this.parsers.tiff[e3];
53711         this.injectSegment(e3, t2);
53712       }
53713     }
53714   };
53715   c(ot, "type", "tiff"), w.set("tiff", ot);
53716   var lt = l("zlib");
53717   var ht = ["ihdr", "iccp", "text", "itxt", "exif"];
53718   var ut = class extends se {
53719     constructor(...e3) {
53720       super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []);
53721     }
53722     static canHandle(e3, t2) {
53723       return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4);
53724     }
53725     async parse() {
53726       let { file: e3 } = this;
53727       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);
53728     }
53729     async findPngChunksInRange(e3, t2) {
53730       let { file: i3 } = this;
53731       for (; e3 < t2; ) {
53732         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 };
53733         ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2;
53734       }
53735     }
53736     parseTextChunks() {
53737       let e3 = this.metaChunks.filter((e4) => "text" === e4.type);
53738       for (let t2 of e3) {
53739         let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0");
53740         this.injectKeyValToIhdr(e4, i3);
53741       }
53742     }
53743     injectKeyValToIhdr(e3, t2) {
53744       let i3 = this.parsers.ihdr;
53745       i3 && i3.raw.set(e3, t2);
53746     }
53747     findIhdr() {
53748       let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type);
53749       e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk);
53750     }
53751     async findExif() {
53752       let e3 = this.metaChunks.find((e4) => "exif" === e4.type);
53753       e3 && this.injectSegment("tiff", e3.chunk);
53754     }
53755     async findXmp() {
53756       let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type);
53757       for (let t2 of e3) {
53758         "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk);
53759       }
53760     }
53761     async findIcc() {
53762       let e3 = this.metaChunks.find((e4) => "iccp" === e4.type);
53763       if (!e3)
53764         return;
53765       let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0;
53766       for (; s2 < 80 && 0 !== i3[s2]; )
53767         s2++;
53768       let r2 = s2 + 2, a2 = t2.getString(0, s2);
53769       if (this.injectKeyValToIhdr("ProfileName", a2), n2) {
53770         let e4 = await lt, i4 = t2.getUint8Array(r2);
53771         i4 = e4.inflateSync(i4), this.injectSegment("icc", i4);
53772       }
53773     }
53774   };
53775   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"]]);
53776   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"]];
53777   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" }]]);
53778   var ft = class extends re2 {
53779     static canHandle(e3, t2) {
53780       return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8);
53781     }
53782     parse() {
53783       return this.parseTags(), this.translate(), this.output;
53784     }
53785     parseTags() {
53786       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)]]);
53787     }
53788   };
53789   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"]]);
53790   var dt = class extends re2 {
53791     parse() {
53792       return this.parseTags(), this.translate(), this.output;
53793     }
53794     parseTags() {
53795       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)]);
53796     }
53797   };
53798   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" }]]);
53799   var pt = class extends re2 {
53800     static canHandle(e3, t2) {
53801       return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4);
53802     }
53803     static findPosition(e3, t2) {
53804       let i3 = super.findPosition(e3, t2);
53805       return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3;
53806     }
53807     static handleMultiSegments(e3) {
53808       return function(e4) {
53809         let t2 = function(e6) {
53810           let t3 = e6[0].constructor, i3 = 0;
53811           for (let t4 of e6)
53812             i3 += t4.length;
53813           let n3 = new t3(i3), s2 = 0;
53814           for (let t4 of e6)
53815             n3.set(t4, s2), s2 += t4.length;
53816           return n3;
53817         }(e4.map((e6) => e6.chunk.toUint8()));
53818         return new I(t2);
53819       }(e3);
53820     }
53821     parse() {
53822       return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output;
53823     }
53824     parseHeader() {
53825       let { raw: e3 } = this;
53826       this.chunk.byteLength < 84 && g2("ICC header is too short");
53827       for (let [t2, i3] of Object.entries(gt)) {
53828         t2 = parseInt(t2, 10);
53829         let n3 = i3(this.chunk, t2);
53830         "\0\0\0\0" !== n3 && e3.set(t2, n3);
53831       }
53832     }
53833     parseTags() {
53834       let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength;
53835       for (; a2--; ) {
53836         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)
53837           return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments.");
53838         s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12;
53839       }
53840     }
53841     parseTag(e3, t2, i3) {
53842       switch (e3) {
53843         case "desc":
53844           return this.parseDesc(t2);
53845         case "mluc":
53846           return this.parseMluc(t2);
53847         case "text":
53848           return this.parseText(t2, i3);
53849         case "sig ":
53850           return this.parseSig(t2);
53851       }
53852       if (!(t2 + i3 > this.chunk.byteLength))
53853         return this.chunk.getUint8Array(t2, i3);
53854     }
53855     parseDesc(e3) {
53856       let t2 = this.chunk.getUint32(e3 + 8) - 1;
53857       return m(this.chunk.getString(e3 + 12, t2));
53858     }
53859     parseText(e3, t2) {
53860       return m(this.chunk.getString(e3 + 8, t2 - 8));
53861     }
53862     parseSig(e3) {
53863       return m(this.chunk.getString(e3 + 8, 4));
53864     }
53865     parseMluc(e3) {
53866       let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = [];
53867       for (let a2 = 0; a2 < i3; a2++) {
53868         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));
53869         r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3;
53870       }
53871       return 1 === i3 ? r2[0].text : r2;
53872     }
53873     translateValue(e3, t2) {
53874       return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3;
53875     }
53876   };
53877   c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18);
53878   var gt = { 4: mt, 8: function(e3, t2) {
53879     return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join(".");
53880   }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) {
53881     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);
53882     return new Date(Date.UTC(i3, n3, s2, r2, a2, o2));
53883   }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt };
53884   function mt(e3, t2) {
53885     return m(e3.getString(t2, 4));
53886   }
53887   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"]]);
53888   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" };
53889   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!)" };
53890   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" }]]);
53891   var yt = class extends re2 {
53892     static canHandle(e3, t2, i3) {
53893       return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3);
53894     }
53895     static headerLength(e3, t2, i3) {
53896       let n3, s2 = this.containsIptc8bim(e3, t2, i3);
53897       if (void 0 !== s2)
53898         return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3;
53899     }
53900     static containsIptc8bim(e3, t2, i3) {
53901       for (let n3 = 0; n3 < i3; n3++)
53902         if (this.isIptcSegmentHead(e3, t2 + n3))
53903           return n3;
53904     }
53905     static isIptcSegmentHead(e3, t2) {
53906       return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4);
53907     }
53908     parse() {
53909       let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false;
53910       for (let n3 = 0; n3 < t2; n3++)
53911         if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) {
53912           i3 = true;
53913           let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3);
53914           e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3;
53915         } else if (i3)
53916           break;
53917       return this.translate(), this.output;
53918     }
53919     pluralizeValue(e3, t2) {
53920       return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2;
53921     }
53922   };
53923   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" }]]);
53924   var full_esm_default = tt;
53925
53926   // modules/services/plane_photo.js
53927   var dispatch6 = dispatch_default("viewerChanged");
53928   var _photo;
53929   var _wrapper;
53930   var imgZoom;
53931   var _widthOverflow;
53932   function zoomPan(d3_event) {
53933     let t2 = d3_event.transform;
53934     _photo.call(utilSetTransform, t2.x, t2.y, t2.k);
53935   }
53936   function zoomBeahvior() {
53937     const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect();
53938     const { naturalHeight, naturalWidth } = _photo.node();
53939     const intrinsicRatio = naturalWidth / naturalHeight;
53940     _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth;
53941     return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan);
53942   }
53943   function loadImage(selection2, path) {
53944     return new Promise((resolve) => {
53945       selection2.attr("src", path);
53946       selection2.on("load", () => {
53947         resolve(selection2);
53948       });
53949     });
53950   }
53951   var plane_photo_default = {
53952     init: async function(context, selection2) {
53953       this.event = utilRebind(this, dispatch6, "on");
53954       _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true);
53955       _photo = _wrapper.append("img").attr("class", "plane-photo");
53956       context.ui().photoviewer.on("resize.plane", () => {
53957         imgZoom = zoomBeahvior();
53958         _wrapper.call(imgZoom);
53959       });
53960       await Promise.resolve();
53961       return this;
53962     },
53963     showPhotoFrame: function(context) {
53964       const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size();
53965       if (isHidden) {
53966         context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true);
53967         context.selectAll(".photo-frame.plane-frame").classed("hide", false);
53968       }
53969       return this;
53970     },
53971     hidePhotoFrame: function(context) {
53972       context.select("photo-frame.plane-frame").classed("hide", false);
53973       return this;
53974     },
53975     selectPhoto: function(data, keepOrientation) {
53976       dispatch6.call("viewerChanged");
53977       loadImage(_photo, "");
53978       loadImage(_photo, data.image_path).then(() => {
53979         if (!keepOrientation) {
53980           imgZoom = zoomBeahvior();
53981           _wrapper.call(imgZoom);
53982           _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0));
53983         }
53984       });
53985       return this;
53986     },
53987     getYaw: function() {
53988       return 0;
53989     }
53990   };
53991
53992   // modules/svg/local_photos.js
53993   var _initialized2 = false;
53994   var _enabled2 = false;
53995   var minViewfieldZoom = 16;
53996   function svgLocalPhotos(projection2, context, dispatch14) {
53997     const detected = utilDetect();
53998     let layer = select_default2(null);
53999     let _fileList;
54000     let _photos = [];
54001     let _idAutoinc = 0;
54002     let _photoFrame;
54003     function init2() {
54004       if (_initialized2)
54005         return;
54006       _enabled2 = true;
54007       function over(d3_event) {
54008         d3_event.stopPropagation();
54009         d3_event.preventDefault();
54010         d3_event.dataTransfer.dropEffect = "copy";
54011       }
54012       context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) {
54013         d3_event.stopPropagation();
54014         d3_event.preventDefault();
54015         if (!detected.filedrop)
54016           return;
54017         drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => {
54018           if (loaded.length > 0) {
54019             drawPhotos.fitZoom(false);
54020           }
54021         });
54022       }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over);
54023       _initialized2 = true;
54024     }
54025     function ensureViewerLoaded(context2) {
54026       if (_photoFrame) {
54027         return Promise.resolve(_photoFrame);
54028       }
54029       const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]);
54030       const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true);
54031       viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD");
54032       return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => {
54033         _photoFrame = planePhotoFrame;
54034       });
54035     }
54036     function click(d3_event, image, zoomTo) {
54037       ensureViewerLoaded(context).then(() => {
54038         const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false);
54039         const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false);
54040         const attribution = viewerWrap.selectAll(".photo-attribution").text("");
54041         if (image.date) {
54042           attribution.append("span").text(image.date.toLocaleString());
54043         }
54044         if (image.name) {
54045           attribution.append("span").classed("filename", true).text(image.name);
54046         }
54047         _photoFrame.selectPhoto({ image_path: "" });
54048         image.getSrc().then((src) => {
54049           _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap);
54050           setStyles();
54051         });
54052       });
54053       if (zoomTo) {
54054         context.map().centerEase(image.loc);
54055       }
54056     }
54057     function transform2(d2) {
54058       var svgpoint = projection2(d2.loc);
54059       return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")";
54060     }
54061     function setStyles(hovered) {
54062       const viewer = context.container().select(".photoviewer");
54063       const selected = viewer.empty() ? void 0 : viewer.datum();
54064       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));
54065     }
54066     function display_markers(imageList) {
54067       imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1]));
54068       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) {
54069         return d2.id;
54070       });
54071       groups.exit().remove();
54072       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click);
54073       groupsEnter.append("g").attr("class", "viewfield-scale");
54074       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
54075       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54076       const showViewfields = context.map().zoom() >= minViewfieldZoom;
54077       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54078       viewfields.exit().remove();
54079       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() {
54080         var _a2;
54081         const d2 = this.parentNode.__data__;
54082         return "rotate(".concat(Math.round((_a2 = d2.direction) != null ? _a2 : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)");
54083       }).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() {
54084         const d2 = this.parentNode.__data__;
54085         return isNumber_default(d2.direction) ? "visible" : "hidden";
54086       });
54087     }
54088     function drawPhotos(selection2) {
54089       layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []);
54090       layer.exit().remove();
54091       const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos");
54092       layerEnter.append("g").attr("class", "markers");
54093       layer = layerEnter.merge(layer);
54094       if (_photos) {
54095         display_markers(_photos);
54096       }
54097     }
54098     function readFileAsDataURL(file) {
54099       return new Promise((resolve, reject) => {
54100         const reader = new FileReader();
54101         reader.onload = () => resolve(reader.result);
54102         reader.onerror = (error) => reject(error);
54103         reader.readAsDataURL(file);
54104       });
54105     }
54106     async function readmultifiles(files, callback) {
54107       const loaded = [];
54108       for (const file of files) {
54109         try {
54110           const exifData = await full_esm_default.parse(file);
54111           const photo = {
54112             id: _idAutoinc++,
54113             name: file.name,
54114             getSrc: () => readFileAsDataURL(file),
54115             file,
54116             loc: [exifData.longitude, exifData.latitude],
54117             direction: exifData.GPSImgDirection,
54118             date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate
54119           };
54120           loaded.push(photo);
54121           const sameName = _photos.filter((i3) => i3.name === photo.name);
54122           if (sameName.length === 0) {
54123             _photos.push(photo);
54124           } else {
54125             const thisContent = await photo.getSrc();
54126             const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc()));
54127             if (!sameNameContent.some((i3) => i3.value === thisContent)) {
54128               _photos.push(photo);
54129             }
54130           }
54131         } catch (err) {
54132         }
54133       }
54134       if (typeof callback === "function")
54135         callback(loaded);
54136       dispatch14.call("change");
54137     }
54138     drawPhotos.setFiles = function(fileList, callback) {
54139       readmultifiles(Array.from(fileList), callback);
54140       return this;
54141     };
54142     drawPhotos.fileList = function(fileList, callback) {
54143       if (!arguments.length)
54144         return _fileList;
54145       _fileList = fileList;
54146       if (!fileList || !fileList.length)
54147         return this;
54148       drawPhotos.setFiles(_fileList, callback);
54149       return this;
54150     };
54151     drawPhotos.getPhotos = function() {
54152       return _photos;
54153     };
54154     drawPhotos.removePhoto = function(id2) {
54155       _photos = _photos.filter((i3) => i3.id !== id2);
54156       dispatch14.call("change");
54157       return _photos;
54158     };
54159     drawPhotos.openPhoto = click;
54160     drawPhotos.fitZoom = function(force) {
54161       const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1]));
54162       if (coords.length === 0)
54163         return;
54164       const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2));
54165       const map2 = context.map();
54166       var viewport = map2.trimmedExtent().polygon();
54167       if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) {
54168         map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent)));
54169       }
54170     };
54171     function showLayer() {
54172       layer.style("display", "block");
54173       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54174         dispatch14.call("change");
54175       });
54176     }
54177     function hideLayer() {
54178       layer.transition().duration(250).style("opacity", 0).on("end", () => {
54179         layer.selectAll(".viewfield-group").remove();
54180         layer.style("display", "none");
54181       });
54182     }
54183     drawPhotos.enabled = function(val) {
54184       if (!arguments.length)
54185         return _enabled2;
54186       _enabled2 = val;
54187       if (_enabled2) {
54188         showLayer();
54189       } else {
54190         hideLayer();
54191       }
54192       dispatch14.call("change");
54193       return this;
54194     };
54195     drawPhotos.hasData = function() {
54196       return isArray_default(_photos) && _photos.length > 0;
54197     };
54198     init2();
54199     return drawPhotos;
54200   }
54201
54202   // modules/svg/improveOSM.js
54203   var _layerEnabled2 = false;
54204   var _qaService2;
54205   function svgImproveOSM(projection2, context, dispatch14) {
54206     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54207     const minZoom4 = 12;
54208     let touchLayer = select_default2(null);
54209     let drawLayer = select_default2(null);
54210     let layerVisible = false;
54211     function markerPath(selection2, klass) {
54212       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");
54213     }
54214     function getService() {
54215       if (services.improveOSM && !_qaService2) {
54216         _qaService2 = services.improveOSM;
54217         _qaService2.on("loaded", throttledRedraw);
54218       } else if (!services.improveOSM && _qaService2) {
54219         _qaService2 = null;
54220       }
54221       return _qaService2;
54222     }
54223     function editOn() {
54224       if (!layerVisible) {
54225         layerVisible = true;
54226         drawLayer.style("display", "block");
54227       }
54228     }
54229     function editOff() {
54230       if (layerVisible) {
54231         layerVisible = false;
54232         drawLayer.style("display", "none");
54233         drawLayer.selectAll(".qaItem.improveOSM").remove();
54234         touchLayer.selectAll(".qaItem.improveOSM").remove();
54235       }
54236     }
54237     function layerOn() {
54238       editOn();
54239       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54240     }
54241     function layerOff() {
54242       throttledRedraw.cancel();
54243       drawLayer.interrupt();
54244       touchLayer.selectAll(".qaItem.improveOSM").remove();
54245       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54246         editOff();
54247         dispatch14.call("change");
54248       });
54249     }
54250     function updateMarkers() {
54251       if (!layerVisible || !_layerEnabled2)
54252         return;
54253       const service = getService();
54254       const selectedID = context.selectedErrorID();
54255       const data = service ? service.getItems(projection2) : [];
54256       const getTransform = svgPointTransform(projection2);
54257       const markers = drawLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54258       markers.exit().remove();
54259       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54260       markersEnter.append("polygon").call(markerPath, "shadow");
54261       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54262       markersEnter.append("polygon").attr("fill", "currentColor").call(markerPath, "qaItem-fill");
54263       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 : "");
54264       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54265       if (touchLayer.empty())
54266         return;
54267       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
54268       const targets = touchLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54269       targets.exit().remove();
54270       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);
54271       function sortY(a2, b2) {
54272         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54273       }
54274     }
54275     function drawImproveOSM(selection2) {
54276       const service = getService();
54277       const surface = context.surface();
54278       if (surface && !surface.empty()) {
54279         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54280       }
54281       drawLayer = selection2.selectAll(".layer-improveOSM").data(service ? [0] : []);
54282       drawLayer.exit().remove();
54283       drawLayer = drawLayer.enter().append("g").attr("class", "layer-improveOSM").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer);
54284       if (_layerEnabled2) {
54285         if (service && ~~context.map().zoom() >= minZoom4) {
54286           editOn();
54287           service.loadIssues(projection2);
54288           updateMarkers();
54289         } else {
54290           editOff();
54291         }
54292       }
54293     }
54294     drawImproveOSM.enabled = function(val) {
54295       if (!arguments.length)
54296         return _layerEnabled2;
54297       _layerEnabled2 = val;
54298       if (_layerEnabled2) {
54299         layerOn();
54300       } else {
54301         layerOff();
54302         if (context.selectedErrorID()) {
54303           context.enter(modeBrowse(context));
54304         }
54305       }
54306       dispatch14.call("change");
54307       return this;
54308     };
54309     drawImproveOSM.supported = () => !!getService();
54310     return drawImproveOSM;
54311   }
54312
54313   // modules/svg/osmose.js
54314   var _layerEnabled3 = false;
54315   var _qaService3;
54316   function svgOsmose(projection2, context, dispatch14) {
54317     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54318     const minZoom4 = 12;
54319     let touchLayer = select_default2(null);
54320     let drawLayer = select_default2(null);
54321     let layerVisible = false;
54322     function markerPath(selection2, klass) {
54323       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");
54324     }
54325     function getService() {
54326       if (services.osmose && !_qaService3) {
54327         _qaService3 = services.osmose;
54328         _qaService3.on("loaded", throttledRedraw);
54329       } else if (!services.osmose && _qaService3) {
54330         _qaService3 = null;
54331       }
54332       return _qaService3;
54333     }
54334     function editOn() {
54335       if (!layerVisible) {
54336         layerVisible = true;
54337         drawLayer.style("display", "block");
54338       }
54339     }
54340     function editOff() {
54341       if (layerVisible) {
54342         layerVisible = false;
54343         drawLayer.style("display", "none");
54344         drawLayer.selectAll(".qaItem.osmose").remove();
54345         touchLayer.selectAll(".qaItem.osmose").remove();
54346       }
54347     }
54348     function layerOn() {
54349       editOn();
54350       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54351     }
54352     function layerOff() {
54353       throttledRedraw.cancel();
54354       drawLayer.interrupt();
54355       touchLayer.selectAll(".qaItem.osmose").remove();
54356       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54357         editOff();
54358         dispatch14.call("change");
54359       });
54360     }
54361     function updateMarkers() {
54362       if (!layerVisible || !_layerEnabled3)
54363         return;
54364       const service = getService();
54365       const selectedID = context.selectedErrorID();
54366       const data = service ? service.getItems(projection2) : [];
54367       const getTransform = svgPointTransform(projection2);
54368       const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54369       markers.exit().remove();
54370       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54371       markersEnter.append("polygon").call(markerPath, "shadow");
54372       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54373       markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill");
54374       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 : "");
54375       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54376       if (touchLayer.empty())
54377         return;
54378       const fillClass = context.getDebug("target") ? "pink" : "nocolor";
54379       const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54380       targets.exit().remove();
54381       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);
54382       function sortY(a2, b2) {
54383         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54384       }
54385     }
54386     function drawOsmose(selection2) {
54387       const service = getService();
54388       const surface = context.surface();
54389       if (surface && !surface.empty()) {
54390         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54391       }
54392       drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []);
54393       drawLayer.exit().remove();
54394       drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled3 ? "block" : "none").merge(drawLayer);
54395       if (_layerEnabled3) {
54396         if (service && ~~context.map().zoom() >= minZoom4) {
54397           editOn();
54398           service.loadIssues(projection2);
54399           updateMarkers();
54400         } else {
54401           editOff();
54402         }
54403       }
54404     }
54405     drawOsmose.enabled = function(val) {
54406       if (!arguments.length)
54407         return _layerEnabled3;
54408       _layerEnabled3 = val;
54409       if (_layerEnabled3) {
54410         getService().loadStrings().then(layerOn).catch((err) => {
54411           console.log(err);
54412         });
54413       } else {
54414         layerOff();
54415         if (context.selectedErrorID()) {
54416           context.enter(modeBrowse(context));
54417         }
54418       }
54419       dispatch14.call("change");
54420       return this;
54421     };
54422     drawOsmose.supported = () => !!getService();
54423     return drawOsmose;
54424   }
54425
54426   // modules/svg/streetside.js
54427   function svgStreetside(projection2, context, dispatch14) {
54428     var throttledRedraw = throttle_default(function() {
54429       dispatch14.call("change");
54430     }, 1e3);
54431     var minZoom4 = 14;
54432     var minMarkerZoom = 16;
54433     var minViewfieldZoom2 = 18;
54434     var layer = select_default2(null);
54435     var _viewerYaw = 0;
54436     var _selectedSequence = null;
54437     var _streetside;
54438     function init2() {
54439       if (svgStreetside.initialized)
54440         return;
54441       svgStreetside.enabled = false;
54442       svgStreetside.initialized = true;
54443     }
54444     function getService() {
54445       if (services.streetside && !_streetside) {
54446         _streetside = services.streetside;
54447         _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw);
54448       } else if (!services.streetside && _streetside) {
54449         _streetside = null;
54450       }
54451       return _streetside;
54452     }
54453     function showLayer() {
54454       var service = getService();
54455       if (!service)
54456         return;
54457       editOn();
54458       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54459         dispatch14.call("change");
54460       });
54461     }
54462     function hideLayer() {
54463       throttledRedraw.cancel();
54464       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54465     }
54466     function editOn() {
54467       layer.style("display", "block");
54468     }
54469     function editOff() {
54470       layer.selectAll(".viewfield-group").remove();
54471       layer.style("display", "none");
54472     }
54473     function click(d3_event, d2) {
54474       var service = getService();
54475       if (!service)
54476         return;
54477       if (d2.sequenceKey !== _selectedSequence) {
54478         _viewerYaw = 0;
54479       }
54480       _selectedSequence = d2.sequenceKey;
54481       service.ensureViewerLoaded(context).then(function() {
54482         service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context);
54483       });
54484       context.map().centerEase(d2.loc);
54485     }
54486     function mouseover(d3_event, d2) {
54487       var service = getService();
54488       if (service)
54489         service.setStyles(context, d2);
54490     }
54491     function mouseout() {
54492       var service = getService();
54493       if (service)
54494         service.setStyles(context, null);
54495     }
54496     function transform2(d2) {
54497       var t2 = svgPointTransform(projection2)(d2);
54498       var rot = d2.ca + _viewerYaw;
54499       if (rot) {
54500         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54501       }
54502       return t2;
54503     }
54504     function viewerChanged() {
54505       var service = getService();
54506       if (!service)
54507         return;
54508       var viewer = service.viewer();
54509       if (!viewer)
54510         return;
54511       _viewerYaw = viewer.getYaw();
54512       if (context.map().isTransformed())
54513         return;
54514       layer.selectAll(".viewfield-group.currentView").attr("transform", transform2);
54515     }
54516     function filterBubbles(bubbles) {
54517       var fromDate = context.photos().fromDate();
54518       var toDate = context.photos().toDate();
54519       var usernames = context.photos().usernames();
54520       if (fromDate) {
54521         var fromTimestamp = new Date(fromDate).getTime();
54522         bubbles = bubbles.filter(function(bubble) {
54523           return new Date(bubble.captured_at).getTime() >= fromTimestamp;
54524         });
54525       }
54526       if (toDate) {
54527         var toTimestamp = new Date(toDate).getTime();
54528         bubbles = bubbles.filter(function(bubble) {
54529           return new Date(bubble.captured_at).getTime() <= toTimestamp;
54530         });
54531       }
54532       if (usernames) {
54533         bubbles = bubbles.filter(function(bubble) {
54534           return usernames.indexOf(bubble.captured_by) !== -1;
54535         });
54536       }
54537       return bubbles;
54538     }
54539     function filterSequences(sequences) {
54540       var fromDate = context.photos().fromDate();
54541       var toDate = context.photos().toDate();
54542       var usernames = context.photos().usernames();
54543       if (fromDate) {
54544         var fromTimestamp = new Date(fromDate).getTime();
54545         sequences = sequences.filter(function(sequences2) {
54546           return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp;
54547         });
54548       }
54549       if (toDate) {
54550         var toTimestamp = new Date(toDate).getTime();
54551         sequences = sequences.filter(function(sequences2) {
54552           return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp;
54553         });
54554       }
54555       if (usernames) {
54556         sequences = sequences.filter(function(sequences2) {
54557           return usernames.indexOf(sequences2.properties.captured_by) !== -1;
54558         });
54559       }
54560       return sequences;
54561     }
54562     function update() {
54563       var viewer = context.container().select(".photoviewer");
54564       var selected = viewer.empty() ? void 0 : viewer.datum();
54565       var z2 = ~~context.map().zoom();
54566       var showMarkers = z2 >= minMarkerZoom;
54567       var showViewfields = z2 >= minViewfieldZoom2;
54568       var service = getService();
54569       var sequences = [];
54570       var bubbles = [];
54571       if (context.photos().showsPanoramic()) {
54572         sequences = service ? service.sequences(projection2) : [];
54573         bubbles = service && showMarkers ? service.bubbles(projection2) : [];
54574         sequences = filterSequences(sequences);
54575         bubbles = filterBubbles(bubbles);
54576       }
54577       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54578         return d2.properties.key;
54579       });
54580       traces.exit().remove();
54581       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54582       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) {
54583         return d2.key + (d2.sequenceKey ? "v1" : "v0");
54584       });
54585       groups.exit().remove();
54586       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54587       groupsEnter.append("g").attr("class", "viewfield-scale");
54588       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54589         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54590       }).attr("transform", transform2).select(".viewfield-scale");
54591       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54592       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54593       viewfields.exit().remove();
54594       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54595       function viewfieldPath() {
54596         var d2 = this.parentNode.__data__;
54597         if (d2.pano) {
54598           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54599         } else {
54600           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54601         }
54602       }
54603     }
54604     function drawImages(selection2) {
54605       var enabled = svgStreetside.enabled;
54606       var service = getService();
54607       layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []);
54608       layer.exit().remove();
54609       var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none");
54610       layerEnter.append("g").attr("class", "sequences");
54611       layerEnter.append("g").attr("class", "markers");
54612       layer = layerEnter.merge(layer);
54613       if (enabled) {
54614         if (service && ~~context.map().zoom() >= minZoom4) {
54615           editOn();
54616           update();
54617           service.loadBubbles(projection2);
54618         } else {
54619           editOff();
54620         }
54621       }
54622     }
54623     drawImages.enabled = function(_2) {
54624       if (!arguments.length)
54625         return svgStreetside.enabled;
54626       svgStreetside.enabled = _2;
54627       if (svgStreetside.enabled) {
54628         showLayer();
54629         context.photos().on("change.streetside", update);
54630       } else {
54631         hideLayer();
54632         context.photos().on("change.streetside", null);
54633       }
54634       dispatch14.call("change");
54635       return this;
54636     };
54637     drawImages.supported = function() {
54638       return !!getService();
54639     };
54640     drawImages.rendered = function(zoom) {
54641       return zoom >= minZoom4;
54642     };
54643     init2();
54644     return drawImages;
54645   }
54646
54647   // modules/svg/vegbilder.js
54648   function svgVegbilder(projection2, context, dispatch14) {
54649     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54650     const minZoom4 = 14;
54651     const minMarkerZoom = 16;
54652     const minViewfieldZoom2 = 18;
54653     let layer = select_default2(null);
54654     let _viewerYaw = 0;
54655     let _vegbilder;
54656     function init2() {
54657       if (svgVegbilder.initialized)
54658         return;
54659       svgVegbilder.enabled = false;
54660       svgVegbilder.initialized = true;
54661     }
54662     function getService() {
54663       if (services.vegbilder && !_vegbilder) {
54664         _vegbilder = services.vegbilder;
54665         _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw);
54666       } else if (!services.vegbilder && _vegbilder) {
54667         _vegbilder = null;
54668       }
54669       return _vegbilder;
54670     }
54671     function showLayer() {
54672       const service = getService();
54673       if (!service)
54674         return;
54675       editOn();
54676       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change"));
54677     }
54678     function hideLayer() {
54679       throttledRedraw.cancel();
54680       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54681     }
54682     function editOn() {
54683       layer.style("display", "block");
54684     }
54685     function editOff() {
54686       layer.selectAll(".viewfield-group").remove();
54687       layer.style("display", "none");
54688     }
54689     function click(d3_event, d2) {
54690       const service = getService();
54691       if (!service)
54692         return;
54693       service.ensureViewerLoaded(context).then(() => {
54694         service.selectImage(context, d2.key).showViewer(context);
54695       });
54696       context.map().centerEase(d2.loc);
54697     }
54698     function mouseover(d3_event, d2) {
54699       const service = getService();
54700       if (service)
54701         service.setStyles(context, d2);
54702     }
54703     function mouseout() {
54704       const service = getService();
54705       if (service)
54706         service.setStyles(context, null);
54707     }
54708     function transform2(d2, selected) {
54709       let t2 = svgPointTransform(projection2)(d2);
54710       let rot = d2.ca;
54711       if (d2 === selected) {
54712         rot += _viewerYaw;
54713       }
54714       if (rot) {
54715         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54716       }
54717       return t2;
54718     }
54719     function viewerChanged() {
54720       const service = getService();
54721       if (!service)
54722         return;
54723       const frame2 = service.photoFrame();
54724       _viewerYaw = frame2.getYaw();
54725       if (context.map().isTransformed())
54726         return;
54727       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2));
54728     }
54729     function filterImages(images) {
54730       const photoContext = context.photos();
54731       const fromDateString = photoContext.fromDate();
54732       const toDateString = photoContext.toDate();
54733       const showsFlat = photoContext.showsFlat();
54734       const showsPano = photoContext.showsPanoramic();
54735       if (fromDateString) {
54736         const fromDate = new Date(fromDateString);
54737         images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime());
54738       }
54739       if (toDateString) {
54740         const toDate = new Date(toDateString);
54741         images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime());
54742       }
54743       if (!showsPano) {
54744         images = images.filter((image) => !image.is_sphere);
54745       }
54746       if (!showsFlat) {
54747         images = images.filter((image) => image.is_sphere);
54748       }
54749       return images;
54750     }
54751     function filterSequences(sequences) {
54752       const photoContext = context.photos();
54753       const fromDateString = photoContext.fromDate();
54754       const toDateString = photoContext.toDate();
54755       const showsFlat = photoContext.showsFlat();
54756       const showsPano = photoContext.showsPanoramic();
54757       if (fromDateString) {
54758         const fromDate = new Date(fromDateString);
54759         sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime());
54760       }
54761       if (toDateString) {
54762         const toDate = new Date(toDateString);
54763         sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime());
54764       }
54765       if (!showsPano) {
54766         sequences = sequences.filter(({ images }) => !images[0].is_sphere);
54767       }
54768       if (!showsFlat) {
54769         sequences = sequences.filter(({ images }) => images[0].is_sphere);
54770       }
54771       return sequences;
54772     }
54773     function update() {
54774       const viewer = context.container().select(".photoviewer");
54775       const selected = viewer.empty() ? void 0 : viewer.datum();
54776       const z2 = ~~context.map().zoom();
54777       const showMarkers = z2 >= minMarkerZoom;
54778       const showViewfields = z2 >= minViewfieldZoom2;
54779       const service = getService();
54780       let sequences = [];
54781       let images = [];
54782       if (service) {
54783         service.loadImages(context);
54784         sequences = service.sequences(projection2);
54785         images = showMarkers ? service.images(projection2) : [];
54786         images = filterImages(images);
54787         sequences = filterSequences(sequences);
54788       }
54789       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key);
54790       traces.exit().remove();
54791       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54792       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key);
54793       groups.exit().remove();
54794       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54795       groupsEnter.append("g").attr("class", "viewfield-scale");
54796       const markers = groups.merge(groupsEnter).sort((a2, b2) => {
54797         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54798       }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale");
54799       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54800       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54801       viewfields.exit().remove();
54802       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54803       function viewfieldPath() {
54804         const d2 = this.parentNode.__data__;
54805         if (d2.is_sphere) {
54806           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54807         } else {
54808           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54809         }
54810       }
54811     }
54812     function drawImages(selection2) {
54813       const enabled = svgVegbilder.enabled;
54814       const service = getService();
54815       layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []);
54816       layer.exit().remove();
54817       const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none");
54818       layerEnter.append("g").attr("class", "sequences");
54819       layerEnter.append("g").attr("class", "markers");
54820       layer = layerEnter.merge(layer);
54821       if (enabled) {
54822         if (service && ~~context.map().zoom() >= minZoom4) {
54823           editOn();
54824           update();
54825           service.loadImages(context);
54826         } else {
54827           editOff();
54828         }
54829       }
54830     }
54831     drawImages.enabled = function(_2) {
54832       if (!arguments.length)
54833         return svgVegbilder.enabled;
54834       svgVegbilder.enabled = _2;
54835       if (svgVegbilder.enabled) {
54836         showLayer();
54837         context.photos().on("change.vegbilder", update);
54838       } else {
54839         hideLayer();
54840         context.photos().on("change.vegbilder", null);
54841       }
54842       dispatch14.call("change");
54843       return this;
54844     };
54845     drawImages.supported = function() {
54846       return !!getService();
54847     };
54848     drawImages.rendered = function(zoom) {
54849       return zoom >= minZoom4;
54850     };
54851     drawImages.validHere = function(extent, zoom) {
54852       return zoom >= minZoom4 - 2 && getService().validHere(extent);
54853     };
54854     init2();
54855     return drawImages;
54856   }
54857
54858   // modules/svg/mapillary_images.js
54859   function svgMapillaryImages(projection2, context, dispatch14) {
54860     const throttledRedraw = throttle_default(function() {
54861       dispatch14.call("change");
54862     }, 1e3);
54863     const minZoom4 = 12;
54864     const minMarkerZoom = 16;
54865     const minViewfieldZoom2 = 18;
54866     let layer = select_default2(null);
54867     let _mapillary;
54868     function init2() {
54869       if (svgMapillaryImages.initialized)
54870         return;
54871       svgMapillaryImages.enabled = false;
54872       svgMapillaryImages.initialized = true;
54873     }
54874     function getService() {
54875       if (services.mapillary && !_mapillary) {
54876         _mapillary = services.mapillary;
54877         _mapillary.event.on("loadedImages", throttledRedraw);
54878       } else if (!services.mapillary && _mapillary) {
54879         _mapillary = null;
54880       }
54881       return _mapillary;
54882     }
54883     function showLayer() {
54884       const service = getService();
54885       if (!service)
54886         return;
54887       editOn();
54888       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54889         dispatch14.call("change");
54890       });
54891     }
54892     function hideLayer() {
54893       throttledRedraw.cancel();
54894       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54895     }
54896     function editOn() {
54897       layer.style("display", "block");
54898     }
54899     function editOff() {
54900       layer.selectAll(".viewfield-group").remove();
54901       layer.style("display", "none");
54902     }
54903     function click(d3_event, image) {
54904       const service = getService();
54905       if (!service)
54906         return;
54907       service.ensureViewerLoaded(context).then(function() {
54908         service.selectImage(context, image.id).showViewer(context);
54909       });
54910       context.map().centerEase(image.loc);
54911     }
54912     function mouseover(d3_event, image) {
54913       const service = getService();
54914       if (service)
54915         service.setStyles(context, image);
54916     }
54917     function mouseout() {
54918       const service = getService();
54919       if (service)
54920         service.setStyles(context, null);
54921     }
54922     function transform2(d2) {
54923       let t2 = svgPointTransform(projection2)(d2);
54924       if (d2.ca) {
54925         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
54926       }
54927       return t2;
54928     }
54929     function filterImages(images) {
54930       const showsPano = context.photos().showsPanoramic();
54931       const showsFlat = context.photos().showsFlat();
54932       const fromDate = context.photos().fromDate();
54933       const toDate = context.photos().toDate();
54934       if (!showsPano || !showsFlat) {
54935         images = images.filter(function(image) {
54936           if (image.is_pano)
54937             return showsPano;
54938           return showsFlat;
54939         });
54940       }
54941       if (fromDate) {
54942         images = images.filter(function(image) {
54943           return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime();
54944         });
54945       }
54946       if (toDate) {
54947         images = images.filter(function(image) {
54948           return new Date(image.captured_at).getTime() <= new Date(toDate).getTime();
54949         });
54950       }
54951       return images;
54952     }
54953     function filterSequences(sequences) {
54954       const showsPano = context.photos().showsPanoramic();
54955       const showsFlat = context.photos().showsFlat();
54956       const fromDate = context.photos().fromDate();
54957       const toDate = context.photos().toDate();
54958       if (!showsPano || !showsFlat) {
54959         sequences = sequences.filter(function(sequence) {
54960           if (sequence.properties.hasOwnProperty("is_pano")) {
54961             if (sequence.properties.is_pano)
54962               return showsPano;
54963             return showsFlat;
54964           }
54965           return false;
54966         });
54967       }
54968       if (fromDate) {
54969         sequences = sequences.filter(function(sequence) {
54970           return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString();
54971         });
54972       }
54973       if (toDate) {
54974         sequences = sequences.filter(function(sequence) {
54975           return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString();
54976         });
54977       }
54978       return sequences;
54979     }
54980     function update() {
54981       const z2 = ~~context.map().zoom();
54982       const showMarkers = z2 >= minMarkerZoom;
54983       const showViewfields = z2 >= minViewfieldZoom2;
54984       const service = getService();
54985       let sequences = service ? service.sequences(projection2) : [];
54986       let images = service && showMarkers ? service.images(projection2) : [];
54987       images = filterImages(images);
54988       sequences = filterSequences(sequences, service);
54989       service.filterViewer(context);
54990       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54991         return d2.properties.id;
54992       });
54993       traces.exit().remove();
54994       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54995       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54996         return d2.id;
54997       });
54998       groups.exit().remove();
54999       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55000       groupsEnter.append("g").attr("class", "viewfield-scale");
55001       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55002         return b2.loc[1] - a2.loc[1];
55003       }).attr("transform", transform2).select(".viewfield-scale");
55004       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55005       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55006       viewfields.exit().remove();
55007       viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() {
55008         return this.parentNode.__data__.is_pano;
55009       }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
55010       function viewfieldPath() {
55011         if (this.parentNode.__data__.is_pano) {
55012           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
55013         } else {
55014           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
55015         }
55016       }
55017     }
55018     function drawImages(selection2) {
55019       const enabled = svgMapillaryImages.enabled;
55020       const service = getService();
55021       layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []);
55022       layer.exit().remove();
55023       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none");
55024       layerEnter.append("g").attr("class", "sequences");
55025       layerEnter.append("g").attr("class", "markers");
55026       layer = layerEnter.merge(layer);
55027       if (enabled) {
55028         if (service && ~~context.map().zoom() >= minZoom4) {
55029           editOn();
55030           update();
55031           service.loadImages(projection2);
55032         } else {
55033           editOff();
55034         }
55035       }
55036     }
55037     drawImages.enabled = function(_2) {
55038       if (!arguments.length)
55039         return svgMapillaryImages.enabled;
55040       svgMapillaryImages.enabled = _2;
55041       if (svgMapillaryImages.enabled) {
55042         showLayer();
55043         context.photos().on("change.mapillary_images", update);
55044       } else {
55045         hideLayer();
55046         context.photos().on("change.mapillary_images", null);
55047       }
55048       dispatch14.call("change");
55049       return this;
55050     };
55051     drawImages.supported = function() {
55052       return !!getService();
55053     };
55054     drawImages.rendered = function(zoom) {
55055       return zoom >= minZoom4;
55056     };
55057     init2();
55058     return drawImages;
55059   }
55060
55061   // modules/svg/mapillary_position.js
55062   function svgMapillaryPosition(projection2, context) {
55063     const throttledRedraw = throttle_default(function() {
55064       update();
55065     }, 1e3);
55066     const minZoom4 = 12;
55067     const minViewfieldZoom2 = 18;
55068     let layer = select_default2(null);
55069     let _mapillary;
55070     let viewerCompassAngle;
55071     function init2() {
55072       if (svgMapillaryPosition.initialized)
55073         return;
55074       svgMapillaryPosition.initialized = true;
55075     }
55076     function getService() {
55077       if (services.mapillary && !_mapillary) {
55078         _mapillary = services.mapillary;
55079         _mapillary.event.on("imageChanged", throttledRedraw);
55080         _mapillary.event.on("bearingChanged", function(e3) {
55081           viewerCompassAngle = e3.bearing;
55082           if (context.map().isTransformed())
55083             return;
55084           layer.selectAll(".viewfield-group.currentView").filter(function(d2) {
55085             return d2.is_pano;
55086           }).attr("transform", transform2);
55087         });
55088       } else if (!services.mapillary && _mapillary) {
55089         _mapillary = null;
55090       }
55091       return _mapillary;
55092     }
55093     function editOn() {
55094       layer.style("display", "block");
55095     }
55096     function editOff() {
55097       layer.selectAll(".viewfield-group").remove();
55098       layer.style("display", "none");
55099     }
55100     function transform2(d2) {
55101       let t2 = svgPointTransform(projection2)(d2);
55102       if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) {
55103         t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)";
55104       } else if (d2.ca) {
55105         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55106       }
55107       return t2;
55108     }
55109     function update() {
55110       const z2 = ~~context.map().zoom();
55111       const showViewfields = z2 >= minViewfieldZoom2;
55112       const service = getService();
55113       const image = service && service.getActiveImage();
55114       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) {
55115         return d2.id;
55116       });
55117       groups.exit().remove();
55118       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted");
55119       groupsEnter.append("g").attr("class", "viewfield-scale");
55120       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
55121       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55122       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55123       viewfields.exit().remove();
55124       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");
55125     }
55126     function drawImages(selection2) {
55127       const service = getService();
55128       layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []);
55129       layer.exit().remove();
55130       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position");
55131       layerEnter.append("g").attr("class", "markers");
55132       layer = layerEnter.merge(layer);
55133       if (service && ~~context.map().zoom() >= minZoom4) {
55134         editOn();
55135         update();
55136       } else {
55137         editOff();
55138       }
55139     }
55140     drawImages.enabled = function() {
55141       update();
55142       return this;
55143     };
55144     drawImages.supported = function() {
55145       return !!getService();
55146     };
55147     drawImages.rendered = function(zoom) {
55148       return zoom >= minZoom4;
55149     };
55150     init2();
55151     return drawImages;
55152   }
55153
55154   // modules/svg/mapillary_signs.js
55155   function svgMapillarySigns(projection2, context, dispatch14) {
55156     const throttledRedraw = throttle_default(function() {
55157       dispatch14.call("change");
55158     }, 1e3);
55159     const minZoom4 = 12;
55160     let layer = select_default2(null);
55161     let _mapillary;
55162     function init2() {
55163       if (svgMapillarySigns.initialized)
55164         return;
55165       svgMapillarySigns.enabled = false;
55166       svgMapillarySigns.initialized = true;
55167     }
55168     function getService() {
55169       if (services.mapillary && !_mapillary) {
55170         _mapillary = services.mapillary;
55171         _mapillary.event.on("loadedSigns", throttledRedraw);
55172       } else if (!services.mapillary && _mapillary) {
55173         _mapillary = null;
55174       }
55175       return _mapillary;
55176     }
55177     function showLayer() {
55178       const service = getService();
55179       if (!service)
55180         return;
55181       service.loadSignResources(context);
55182       editOn();
55183     }
55184     function hideLayer() {
55185       throttledRedraw.cancel();
55186       editOff();
55187     }
55188     function editOn() {
55189       layer.style("display", "block");
55190     }
55191     function editOff() {
55192       layer.selectAll(".icon-sign").remove();
55193       layer.style("display", "none");
55194     }
55195     function click(d3_event, d2) {
55196       const service = getService();
55197       if (!service)
55198         return;
55199       context.map().centerEase(d2.loc);
55200       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55201       service.getDetections(d2.id).then((detections) => {
55202         if (detections.length) {
55203           const imageId = detections[0].image.id;
55204           if (imageId === selectedImageId) {
55205             service.highlightDetection(detections[0]).selectImage(context, imageId);
55206           } else {
55207             service.ensureViewerLoaded(context).then(function() {
55208               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55209             });
55210           }
55211         }
55212       });
55213     }
55214     function filterData(detectedFeatures) {
55215       var fromDate = context.photos().fromDate();
55216       var toDate = context.photos().toDate();
55217       if (fromDate) {
55218         var fromTimestamp = new Date(fromDate).getTime();
55219         detectedFeatures = detectedFeatures.filter(function(feature3) {
55220           return new Date(feature3.last_seen_at).getTime() >= fromTimestamp;
55221         });
55222       }
55223       if (toDate) {
55224         var toTimestamp = new Date(toDate).getTime();
55225         detectedFeatures = detectedFeatures.filter(function(feature3) {
55226           return new Date(feature3.first_seen_at).getTime() <= toTimestamp;
55227         });
55228       }
55229       return detectedFeatures;
55230     }
55231     function update() {
55232       const service = getService();
55233       let data = service ? service.signs(projection2) : [];
55234       data = filterData(data);
55235       const transform2 = svgPointTransform(projection2);
55236       const signs = layer.selectAll(".icon-sign").data(data, function(d2) {
55237         return d2.id;
55238       });
55239       signs.exit().remove();
55240       const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click);
55241       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55242         return "#" + d2.value;
55243       });
55244       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55245       signs.merge(enter).attr("transform", transform2);
55246     }
55247     function drawSigns(selection2) {
55248       const enabled = svgMapillarySigns.enabled;
55249       const service = getService();
55250       layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []);
55251       layer.exit().remove();
55252       layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55253       if (enabled) {
55254         if (service && ~~context.map().zoom() >= minZoom4) {
55255           editOn();
55256           update();
55257           service.loadSigns(projection2);
55258           service.showSignDetections(true);
55259         } else {
55260           editOff();
55261         }
55262       } else if (service) {
55263         service.showSignDetections(false);
55264       }
55265     }
55266     drawSigns.enabled = function(_2) {
55267       if (!arguments.length)
55268         return svgMapillarySigns.enabled;
55269       svgMapillarySigns.enabled = _2;
55270       if (svgMapillarySigns.enabled) {
55271         showLayer();
55272         context.photos().on("change.mapillary_signs", update);
55273       } else {
55274         hideLayer();
55275         context.photos().on("change.mapillary_signs", null);
55276       }
55277       dispatch14.call("change");
55278       return this;
55279     };
55280     drawSigns.supported = function() {
55281       return !!getService();
55282     };
55283     drawSigns.rendered = function(zoom) {
55284       return zoom >= minZoom4;
55285     };
55286     init2();
55287     return drawSigns;
55288   }
55289
55290   // modules/svg/mapillary_map_features.js
55291   function svgMapillaryMapFeatures(projection2, context, dispatch14) {
55292     const throttledRedraw = throttle_default(function() {
55293       dispatch14.call("change");
55294     }, 1e3);
55295     const minZoom4 = 12;
55296     let layer = select_default2(null);
55297     let _mapillary;
55298     function init2() {
55299       if (svgMapillaryMapFeatures.initialized)
55300         return;
55301       svgMapillaryMapFeatures.enabled = false;
55302       svgMapillaryMapFeatures.initialized = true;
55303     }
55304     function getService() {
55305       if (services.mapillary && !_mapillary) {
55306         _mapillary = services.mapillary;
55307         _mapillary.event.on("loadedMapFeatures", throttledRedraw);
55308       } else if (!services.mapillary && _mapillary) {
55309         _mapillary = null;
55310       }
55311       return _mapillary;
55312     }
55313     function showLayer() {
55314       const service = getService();
55315       if (!service)
55316         return;
55317       service.loadObjectResources(context);
55318       editOn();
55319     }
55320     function hideLayer() {
55321       throttledRedraw.cancel();
55322       editOff();
55323     }
55324     function editOn() {
55325       layer.style("display", "block");
55326     }
55327     function editOff() {
55328       layer.selectAll(".icon-map-feature").remove();
55329       layer.style("display", "none");
55330     }
55331     function click(d3_event, d2) {
55332       const service = getService();
55333       if (!service)
55334         return;
55335       context.map().centerEase(d2.loc);
55336       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55337       service.getDetections(d2.id).then((detections) => {
55338         if (detections.length) {
55339           const imageId = detections[0].image.id;
55340           if (imageId === selectedImageId) {
55341             service.highlightDetection(detections[0]).selectImage(context, imageId);
55342           } else {
55343             service.ensureViewerLoaded(context).then(function() {
55344               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55345             });
55346           }
55347         }
55348       });
55349     }
55350     function filterData(detectedFeatures) {
55351       const fromDate = context.photos().fromDate();
55352       const toDate = context.photos().toDate();
55353       if (fromDate) {
55354         detectedFeatures = detectedFeatures.filter(function(feature3) {
55355           return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime();
55356         });
55357       }
55358       if (toDate) {
55359         detectedFeatures = detectedFeatures.filter(function(feature3) {
55360           return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime();
55361         });
55362       }
55363       return detectedFeatures;
55364     }
55365     function update() {
55366       const service = getService();
55367       let data = service ? service.mapFeatures(projection2) : [];
55368       data = filterData(data);
55369       const transform2 = svgPointTransform(projection2);
55370       const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) {
55371         return d2.id;
55372       });
55373       mapFeatures.exit().remove();
55374       const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click);
55375       enter.append("title").text(function(d2) {
55376         var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_");
55377         return _t("mapillary_map_features." + id2);
55378       });
55379       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55380         if (d2.value === "object--billboard") {
55381           return "#object--sign--advertisement";
55382         }
55383         return "#" + d2.value;
55384       });
55385       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55386       mapFeatures.merge(enter).attr("transform", transform2);
55387     }
55388     function drawMapFeatures(selection2) {
55389       const enabled = svgMapillaryMapFeatures.enabled;
55390       const service = getService();
55391       layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []);
55392       layer.exit().remove();
55393       layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55394       if (enabled) {
55395         if (service && ~~context.map().zoom() >= minZoom4) {
55396           editOn();
55397           update();
55398           service.loadMapFeatures(projection2);
55399           service.showFeatureDetections(true);
55400         } else {
55401           editOff();
55402         }
55403       } else if (service) {
55404         service.showFeatureDetections(false);
55405       }
55406     }
55407     drawMapFeatures.enabled = function(_2) {
55408       if (!arguments.length)
55409         return svgMapillaryMapFeatures.enabled;
55410       svgMapillaryMapFeatures.enabled = _2;
55411       if (svgMapillaryMapFeatures.enabled) {
55412         showLayer();
55413         context.photos().on("change.mapillary_map_features", update);
55414       } else {
55415         hideLayer();
55416         context.photos().on("change.mapillary_map_features", null);
55417       }
55418       dispatch14.call("change");
55419       return this;
55420     };
55421     drawMapFeatures.supported = function() {
55422       return !!getService();
55423     };
55424     drawMapFeatures.rendered = function(zoom) {
55425       return zoom >= minZoom4;
55426     };
55427     init2();
55428     return drawMapFeatures;
55429   }
55430
55431   // modules/svg/kartaview_images.js
55432   function svgKartaviewImages(projection2, context, dispatch14) {
55433     var throttledRedraw = throttle_default(function() {
55434       dispatch14.call("change");
55435     }, 1e3);
55436     var minZoom4 = 12;
55437     var minMarkerZoom = 16;
55438     var minViewfieldZoom2 = 18;
55439     var layer = select_default2(null);
55440     var _kartaview;
55441     function init2() {
55442       if (svgKartaviewImages.initialized)
55443         return;
55444       svgKartaviewImages.enabled = false;
55445       svgKartaviewImages.initialized = true;
55446     }
55447     function getService() {
55448       if (services.kartaview && !_kartaview) {
55449         _kartaview = services.kartaview;
55450         _kartaview.event.on("loadedImages", throttledRedraw);
55451       } else if (!services.kartaview && _kartaview) {
55452         _kartaview = null;
55453       }
55454       return _kartaview;
55455     }
55456     function showLayer() {
55457       var service = getService();
55458       if (!service)
55459         return;
55460       editOn();
55461       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55462         dispatch14.call("change");
55463       });
55464     }
55465     function hideLayer() {
55466       throttledRedraw.cancel();
55467       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55468     }
55469     function editOn() {
55470       layer.style("display", "block");
55471     }
55472     function editOff() {
55473       layer.selectAll(".viewfield-group").remove();
55474       layer.style("display", "none");
55475     }
55476     function click(d3_event, d2) {
55477       var service = getService();
55478       if (!service)
55479         return;
55480       service.ensureViewerLoaded(context).then(function() {
55481         service.selectImage(context, d2.key).showViewer(context);
55482       });
55483       context.map().centerEase(d2.loc);
55484     }
55485     function mouseover(d3_event, d2) {
55486       var service = getService();
55487       if (service)
55488         service.setStyles(context, d2);
55489     }
55490     function mouseout() {
55491       var service = getService();
55492       if (service)
55493         service.setStyles(context, null);
55494     }
55495     function transform2(d2) {
55496       var t2 = svgPointTransform(projection2)(d2);
55497       if (d2.ca) {
55498         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55499       }
55500       return t2;
55501     }
55502     function filterImages(images) {
55503       var fromDate = context.photos().fromDate();
55504       var toDate = context.photos().toDate();
55505       var usernames = context.photos().usernames();
55506       if (fromDate) {
55507         var fromTimestamp = new Date(fromDate).getTime();
55508         images = images.filter(function(item) {
55509           return new Date(item.captured_at).getTime() >= fromTimestamp;
55510         });
55511       }
55512       if (toDate) {
55513         var toTimestamp = new Date(toDate).getTime();
55514         images = images.filter(function(item) {
55515           return new Date(item.captured_at).getTime() <= toTimestamp;
55516         });
55517       }
55518       if (usernames) {
55519         images = images.filter(function(item) {
55520           return usernames.indexOf(item.captured_by) !== -1;
55521         });
55522       }
55523       return images;
55524     }
55525     function filterSequences(sequences) {
55526       var fromDate = context.photos().fromDate();
55527       var toDate = context.photos().toDate();
55528       var usernames = context.photos().usernames();
55529       if (fromDate) {
55530         var fromTimestamp = new Date(fromDate).getTime();
55531         sequences = sequences.filter(function(image) {
55532           return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
55533         });
55534       }
55535       if (toDate) {
55536         var toTimestamp = new Date(toDate).getTime();
55537         sequences = sequences.filter(function(image) {
55538           return new Date(image.properties.captured_at).getTime() <= toTimestamp;
55539         });
55540       }
55541       if (usernames) {
55542         sequences = sequences.filter(function(image) {
55543           return usernames.indexOf(image.properties.captured_by) !== -1;
55544         });
55545       }
55546       return sequences;
55547     }
55548     function update() {
55549       var viewer = context.container().select(".photoviewer");
55550       var selected = viewer.empty() ? void 0 : viewer.datum();
55551       var z2 = ~~context.map().zoom();
55552       var showMarkers = z2 >= minMarkerZoom;
55553       var showViewfields = z2 >= minViewfieldZoom2;
55554       var service = getService();
55555       var sequences = [];
55556       var images = [];
55557       if (context.photos().showsFlat()) {
55558         sequences = service ? service.sequences(projection2) : [];
55559         images = service && showMarkers ? service.images(projection2) : [];
55560         sequences = filterSequences(sequences);
55561         images = filterImages(images);
55562       }
55563       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55564         return d2.properties.key;
55565       });
55566       traces.exit().remove();
55567       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55568       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55569         return d2.key;
55570       });
55571       groups.exit().remove();
55572       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55573       groupsEnter.append("g").attr("class", "viewfield-scale");
55574       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55575         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
55576       }).attr("transform", transform2).select(".viewfield-scale");
55577       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55578       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55579       viewfields.exit().remove();
55580       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");
55581     }
55582     function drawImages(selection2) {
55583       var enabled = svgKartaviewImages.enabled, service = getService();
55584       layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []);
55585       layer.exit().remove();
55586       var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none");
55587       layerEnter.append("g").attr("class", "sequences");
55588       layerEnter.append("g").attr("class", "markers");
55589       layer = layerEnter.merge(layer);
55590       if (enabled) {
55591         if (service && ~~context.map().zoom() >= minZoom4) {
55592           editOn();
55593           update();
55594           service.loadImages(projection2);
55595         } else {
55596           editOff();
55597         }
55598       }
55599     }
55600     drawImages.enabled = function(_2) {
55601       if (!arguments.length)
55602         return svgKartaviewImages.enabled;
55603       svgKartaviewImages.enabled = _2;
55604       if (svgKartaviewImages.enabled) {
55605         showLayer();
55606         context.photos().on("change.kartaview_images", update);
55607       } else {
55608         hideLayer();
55609         context.photos().on("change.kartaview_images", null);
55610       }
55611       dispatch14.call("change");
55612       return this;
55613     };
55614     drawImages.supported = function() {
55615       return !!getService();
55616     };
55617     drawImages.rendered = function(zoom) {
55618       return zoom >= minZoom4;
55619     };
55620     init2();
55621     return drawImages;
55622   }
55623
55624   // modules/svg/mapilio_images.js
55625   function svgMapilioImages(projection2, context, dispatch14) {
55626     const throttledRedraw = throttle_default(function() {
55627       dispatch14.call("change");
55628     }, 1e3);
55629     const minZoom4 = 12;
55630     let layer = select_default2(null);
55631     let _mapilio;
55632     const viewFieldZoomLevel = 18;
55633     function init2() {
55634       if (svgMapilioImages.initialized)
55635         return;
55636       svgMapilioImages.enabled = false;
55637       svgMapilioImages.initialized = true;
55638     }
55639     function getService() {
55640       if (services.mapilio && !_mapilio) {
55641         _mapilio = services.mapilio;
55642         _mapilio.event.on("loadedImages", throttledRedraw);
55643       } else if (!services.mapilio && _mapilio) {
55644         _mapilio = null;
55645       }
55646       return _mapilio;
55647     }
55648     function showLayer() {
55649       const service = getService();
55650       if (!service)
55651         return;
55652       editOn();
55653       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55654         dispatch14.call("change");
55655       });
55656     }
55657     function hideLayer() {
55658       throttledRedraw.cancel();
55659       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55660     }
55661     function transform2(d2) {
55662       let t2 = svgPointTransform(projection2)(d2);
55663       if (d2.heading) {
55664         t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)";
55665       }
55666       return t2;
55667     }
55668     function editOn() {
55669       layer.style("display", "block");
55670     }
55671     function editOff() {
55672       layer.selectAll(".viewfield-group").remove();
55673       layer.style("display", "none");
55674     }
55675     function click(d3_event, image) {
55676       const service = getService();
55677       if (!service)
55678         return;
55679       service.ensureViewerLoaded(context, image.id).then(function() {
55680         service.selectImage(context, image.id).showViewer(context);
55681       });
55682       context.map().centerEase(image.loc);
55683     }
55684     function mouseover(d3_event, image) {
55685       const service = getService();
55686       if (service)
55687         service.setStyles(context, image);
55688     }
55689     function mouseout() {
55690       const service = getService();
55691       if (service)
55692         service.setStyles(context, null);
55693     }
55694     function update() {
55695       const z2 = ~~context.map().zoom();
55696       const showViewfields = z2 >= viewFieldZoomLevel;
55697       const service = getService();
55698       let sequences = service ? service.sequences(projection2) : [];
55699       let images = service ? service.images(projection2) : [];
55700       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55701         return d2.properties.id;
55702       });
55703       traces.exit().remove();
55704       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55705       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55706         return d2.id;
55707       });
55708       groups.exit().remove();
55709       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55710       groupsEnter.append("g").attr("class", "viewfield-scale");
55711       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55712         return b2.loc[1] - a2.loc[1];
55713       }).attr("transform", transform2).select(".viewfield-scale");
55714       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55715       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55716       viewfields.exit().remove();
55717       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
55718       function viewfieldPath() {
55719         if (this.parentNode.__data__.isPano) {
55720           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
55721         } else {
55722           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
55723         }
55724       }
55725     }
55726     function drawImages(selection2) {
55727       const enabled = svgMapilioImages.enabled;
55728       const service = getService();
55729       layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []);
55730       layer.exit().remove();
55731       const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none");
55732       layerEnter.append("g").attr("class", "sequences");
55733       layerEnter.append("g").attr("class", "markers");
55734       layer = layerEnter.merge(layer);
55735       if (enabled) {
55736         if (service && ~~context.map().zoom() >= minZoom4) {
55737           editOn();
55738           update();
55739           service.loadImages(projection2);
55740           service.loadLines(projection2);
55741         } else {
55742           editOff();
55743         }
55744       }
55745     }
55746     drawImages.enabled = function(_2) {
55747       if (!arguments.length)
55748         return svgMapilioImages.enabled;
55749       svgMapilioImages.enabled = _2;
55750       if (svgMapilioImages.enabled) {
55751         showLayer();
55752         context.photos().on("change.mapilio_images", null);
55753       } else {
55754         hideLayer();
55755         context.photos().on("change.mapilio_images", null);
55756       }
55757       dispatch14.call("change");
55758       return this;
55759     };
55760     drawImages.supported = function() {
55761       return !!getService();
55762     };
55763     drawImages.rendered = function(zoom) {
55764       return zoom >= minZoom4;
55765     };
55766     init2();
55767     return drawImages;
55768   }
55769
55770   // modules/svg/osm.js
55771   function svgOsm(projection2, context, dispatch14) {
55772     var enabled = true;
55773     function drawOsm(selection2) {
55774       selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) {
55775         return "layer-osm " + d2;
55776       });
55777       selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) {
55778         return "points-group " + d2;
55779       });
55780     }
55781     function showLayer() {
55782       var layer = context.surface().selectAll(".data-layer.osm");
55783       layer.interrupt();
55784       layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55785         dispatch14.call("change");
55786       });
55787     }
55788     function hideLayer() {
55789       var layer = context.surface().selectAll(".data-layer.osm");
55790       layer.interrupt();
55791       layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55792         layer.classed("disabled", true);
55793         dispatch14.call("change");
55794       });
55795     }
55796     drawOsm.enabled = function(val) {
55797       if (!arguments.length)
55798         return enabled;
55799       enabled = val;
55800       if (enabled) {
55801         showLayer();
55802       } else {
55803         hideLayer();
55804       }
55805       dispatch14.call("change");
55806       return this;
55807     };
55808     return drawOsm;
55809   }
55810
55811   // modules/svg/notes.js
55812   var _notesEnabled = false;
55813   var _osmService;
55814   function svgNotes(projection2, context, dispatch14) {
55815     if (!dispatch14) {
55816       dispatch14 = dispatch_default("change");
55817     }
55818     var throttledRedraw = throttle_default(function() {
55819       dispatch14.call("change");
55820     }, 1e3);
55821     var minZoom4 = 12;
55822     var touchLayer = select_default2(null);
55823     var drawLayer = select_default2(null);
55824     var _notesVisible = false;
55825     function markerPath(selection2, klass) {
55826       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");
55827     }
55828     function getService() {
55829       if (services.osm && !_osmService) {
55830         _osmService = services.osm;
55831         _osmService.on("loadedNotes", throttledRedraw);
55832       } else if (!services.osm && _osmService) {
55833         _osmService = null;
55834       }
55835       return _osmService;
55836     }
55837     function editOn() {
55838       if (!_notesVisible) {
55839         _notesVisible = true;
55840         drawLayer.style("display", "block");
55841       }
55842     }
55843     function editOff() {
55844       if (_notesVisible) {
55845         _notesVisible = false;
55846         drawLayer.style("display", "none");
55847         drawLayer.selectAll(".note").remove();
55848         touchLayer.selectAll(".note").remove();
55849       }
55850     }
55851     function layerOn() {
55852       editOn();
55853       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55854         dispatch14.call("change");
55855       });
55856     }
55857     function layerOff() {
55858       throttledRedraw.cancel();
55859       drawLayer.interrupt();
55860       touchLayer.selectAll(".note").remove();
55861       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55862         editOff();
55863         dispatch14.call("change");
55864       });
55865     }
55866     function updateMarkers() {
55867       if (!_notesVisible || !_notesEnabled)
55868         return;
55869       var service = getService();
55870       var selectedID = context.selectedNoteID();
55871       var data = service ? service.notes(projection2) : [];
55872       var getTransform = svgPointTransform(projection2);
55873       var notes = drawLayer.selectAll(".note").data(data, function(d2) {
55874         return d2.status + d2.id;
55875       });
55876       notes.exit().remove();
55877       var notesEnter = notes.enter().append("g").attr("class", function(d2) {
55878         return "note note-" + d2.id + " " + d2.status;
55879       }).classed("new", function(d2) {
55880         return d2.id < 0;
55881       });
55882       notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55883       notesEnter.append("path").call(markerPath, "shadow");
55884       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");
55885       notesEnter.selectAll(".icon-annotation").data(function(d2) {
55886         return [d2];
55887       }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) {
55888         if (d2.id < 0)
55889           return "#iD-icon-plus";
55890         if (d2.status === "open")
55891           return "#iD-icon-close";
55892         return "#iD-icon-apply";
55893       });
55894       notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) {
55895         var mode = context.mode();
55896         var isMoving = mode && mode.id === "drag-note";
55897         return !isMoving && d2.id === selectedID;
55898       }).attr("transform", getTransform);
55899       if (touchLayer.empty())
55900         return;
55901       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55902       var targets = touchLayer.selectAll(".note").data(data, function(d2) {
55903         return d2.id;
55904       });
55905       targets.exit().remove();
55906       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) {
55907         var newClass = d2.id < 0 ? "new" : "";
55908         return "note target note-" + d2.id + " " + fillClass + newClass;
55909       }).attr("transform", getTransform);
55910       function sortY(a2, b2) {
55911         if (a2.id === selectedID)
55912           return 1;
55913         if (b2.id === selectedID)
55914           return -1;
55915         return b2.loc[1] - a2.loc[1];
55916       }
55917     }
55918     function drawNotes(selection2) {
55919       var service = getService();
55920       var surface = context.surface();
55921       if (surface && !surface.empty()) {
55922         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
55923       }
55924       drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []);
55925       drawLayer.exit().remove();
55926       drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer);
55927       if (_notesEnabled) {
55928         if (service && ~~context.map().zoom() >= minZoom4) {
55929           editOn();
55930           service.loadNotes(projection2);
55931           updateMarkers();
55932         } else {
55933           editOff();
55934         }
55935       }
55936     }
55937     drawNotes.enabled = function(val) {
55938       if (!arguments.length)
55939         return _notesEnabled;
55940       _notesEnabled = val;
55941       if (_notesEnabled) {
55942         layerOn();
55943       } else {
55944         layerOff();
55945         if (context.selectedNoteID()) {
55946           context.enter(modeBrowse(context));
55947         }
55948       }
55949       dispatch14.call("change");
55950       return this;
55951     };
55952     return drawNotes;
55953   }
55954
55955   // modules/svg/touch.js
55956   function svgTouch() {
55957     function drawTouch(selection2) {
55958       selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) {
55959         return "layer-touch " + d2;
55960       });
55961     }
55962     return drawTouch;
55963   }
55964
55965   // modules/util/dimensions.js
55966   function refresh(selection2, node) {
55967     var cr = node.getBoundingClientRect();
55968     var prop = [cr.width, cr.height];
55969     selection2.property("__dimensions__", prop);
55970     return prop;
55971   }
55972   function utilGetDimensions(selection2, force) {
55973     if (!selection2 || selection2.empty()) {
55974       return [0, 0];
55975     }
55976     var node = selection2.node(), cached = selection2.property("__dimensions__");
55977     return !cached || force ? refresh(selection2, node) : cached;
55978   }
55979   function utilSetDimensions(selection2, dimensions) {
55980     if (!selection2 || selection2.empty()) {
55981       return selection2;
55982     }
55983     var node = selection2.node();
55984     if (dimensions === null) {
55985       refresh(selection2, node);
55986       return selection2;
55987     }
55988     return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]);
55989   }
55990
55991   // modules/svg/layers.js
55992   function svgLayers(projection2, context) {
55993     var dispatch14 = dispatch_default("change");
55994     var svg2 = select_default2(null);
55995     var _layers = [
55996       { id: "osm", layer: svgOsm(projection2, context, dispatch14) },
55997       { id: "notes", layer: svgNotes(projection2, context, dispatch14) },
55998       { id: "data", layer: svgData(projection2, context, dispatch14) },
55999       { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) },
56000       { id: "improveOSM", layer: svgImproveOSM(projection2, context, dispatch14) },
56001       { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) },
56002       { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) },
56003       { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) },
56004       { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) },
56005       { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) },
56006       { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) },
56007       { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) },
56008       { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) },
56009       { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) },
56010       { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) },
56011       { id: "debug", layer: svgDebug(projection2, context, dispatch14) },
56012       { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) },
56013       { id: "touch", layer: svgTouch(projection2, context, dispatch14) }
56014     ];
56015     function drawLayers(selection2) {
56016       svg2 = selection2.selectAll(".surface").data([0]);
56017       svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2);
56018       var defs = svg2.selectAll(".surface-defs").data([0]);
56019       defs.enter().append("defs").attr("class", "surface-defs");
56020       var groups = svg2.selectAll(".data-layer").data(_layers);
56021       groups.exit().remove();
56022       groups.enter().append("g").attr("class", function(d2) {
56023         return "data-layer " + d2.id;
56024       }).merge(groups).each(function(d2) {
56025         select_default2(this).call(d2.layer);
56026       });
56027     }
56028     drawLayers.all = function() {
56029       return _layers;
56030     };
56031     drawLayers.layer = function(id2) {
56032       var obj = _layers.find(function(o2) {
56033         return o2.id === id2;
56034       });
56035       return obj && obj.layer;
56036     };
56037     drawLayers.only = function(what) {
56038       var arr = [].concat(what);
56039       var all = _layers.map(function(layer) {
56040         return layer.id;
56041       });
56042       return drawLayers.remove(utilArrayDifference(all, arr));
56043     };
56044     drawLayers.remove = function(what) {
56045       var arr = [].concat(what);
56046       arr.forEach(function(id2) {
56047         _layers = _layers.filter(function(o2) {
56048           return o2.id !== id2;
56049         });
56050       });
56051       dispatch14.call("change");
56052       return this;
56053     };
56054     drawLayers.add = function(what) {
56055       var arr = [].concat(what);
56056       arr.forEach(function(obj) {
56057         if ("id" in obj && "layer" in obj) {
56058           _layers.push(obj);
56059         }
56060       });
56061       dispatch14.call("change");
56062       return this;
56063     };
56064     drawLayers.dimensions = function(val) {
56065       if (!arguments.length)
56066         return utilGetDimensions(svg2);
56067       utilSetDimensions(svg2, val);
56068       return this;
56069     };
56070     return utilRebind(drawLayers, dispatch14, "on");
56071   }
56072
56073   // modules/svg/lines.js
56074   var import_fast_deep_equal6 = __toESM(require_fast_deep_equal());
56075   function svgLines(projection2, context) {
56076     var detected = utilDetect();
56077     var highway_stack = {
56078       motorway: 0,
56079       motorway_link: 1,
56080       trunk: 2,
56081       trunk_link: 3,
56082       primary: 4,
56083       primary_link: 5,
56084       secondary: 6,
56085       tertiary: 7,
56086       unclassified: 8,
56087       residential: 9,
56088       service: 10,
56089       busway: 11,
56090       footway: 12
56091     };
56092     function drawTargets(selection2, graph, entities, filter2) {
56093       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56094       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56095       var getPath = svgPath(projection2).geojson;
56096       var activeID = context.activeID();
56097       var base = context.history().base();
56098       var data = { targets: [], nopes: [] };
56099       entities.forEach(function(way) {
56100         var features = svgSegmentWay(way, graph, activeID);
56101         data.targets.push.apply(data.targets, features.passive);
56102         data.nopes.push.apply(data.nopes, features.active);
56103       });
56104       var targetData = data.targets.filter(getPath);
56105       var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) {
56106         return filter2(d2.properties.entity);
56107       }).data(targetData, function key(d2) {
56108         return d2.id;
56109       });
56110       targets.exit().remove();
56111       var segmentWasEdited = function(d2) {
56112         var wayID = d2.properties.entity.id;
56113         if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
56114           return false;
56115         }
56116         return d2.properties.nodes.some(function(n3) {
56117           return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
56118         });
56119       };
56120       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
56121         return "way line target target-allowed " + targetClass + d2.id;
56122       }).classed("segment-edited", segmentWasEdited);
56123       var nopeData = data.nopes.filter(getPath);
56124       var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) {
56125         return filter2(d2.properties.entity);
56126       }).data(nopeData, function key(d2) {
56127         return d2.id;
56128       });
56129       nopes.exit().remove();
56130       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
56131         return "way line target target-nope " + nopeClass + d2.id;
56132       }).classed("segment-edited", segmentWasEdited);
56133     }
56134     function drawLines(selection2, graph, entities, filter2) {
56135       var base = context.history().base();
56136       function waystack(a2, b2) {
56137         var selected = context.selectedIDs();
56138         var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0;
56139         var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0;
56140         if (a2.tags.highway) {
56141           scoreA -= highway_stack[a2.tags.highway];
56142         }
56143         if (b2.tags.highway) {
56144           scoreB -= highway_stack[b2.tags.highway];
56145         }
56146         return scoreA - scoreB;
56147       }
56148       function drawLineGroup(selection3, klass, isSelected) {
56149         var mode = context.mode();
56150         var isDrawing = mode && /^draw/.test(mode.id);
56151         var selectedClass = !isDrawing && isSelected ? "selected " : "";
56152         var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key);
56153         lines.exit().remove();
56154         lines.enter().append("path").attr("class", function(d2) {
56155           var prefix = "way line";
56156           if (!d2.hasInterestingTags()) {
56157             var parentRelations = graph.parentRelations(d2);
56158             var parentMultipolygons = parentRelations.filter(function(relation) {
56159               return relation.isMultipolygon();
56160             });
56161             if (parentMultipolygons.length > 0 && // and only multipolygon relations
56162             parentRelations.length === parentMultipolygons.length) {
56163               prefix = "relation area";
56164             }
56165           }
56166           var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : "";
56167           return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id;
56168         }).classed("added", function(d2) {
56169           return !base.entities[d2.id];
56170         }).classed("geometry-edited", function(d2) {
56171           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);
56172         }).classed("retagged", function(d2) {
56173           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);
56174         }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph)));
56175         return selection3;
56176       }
56177       function getPathData(isSelected) {
56178         return function() {
56179           var layer = this.parentNode.__data__;
56180           var data = pathdata[layer] || [];
56181           return data.filter(function(d2) {
56182             if (isSelected) {
56183               return context.selectedIDs().indexOf(d2.id) !== -1;
56184             } else {
56185               return context.selectedIDs().indexOf(d2.id) === -1;
56186             }
56187           });
56188         };
56189       }
56190       function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) {
56191         var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]);
56192         markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup);
56193         var markers = markergroup.selectAll("path").filter(filter2).data(
56194           function data() {
56195             return groupdata[this.parentNode.__data__] || [];
56196           },
56197           function key(d2) {
56198             return [d2.id, d2.index];
56199           }
56200         );
56201         markers.exit().remove();
56202         markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) {
56203           return d2.d;
56204         });
56205         if (detected.ie) {
56206           markers.each(function() {
56207             this.parentNode.insertBefore(this, this);
56208           });
56209         }
56210       }
56211       var getPath = svgPath(projection2, graph);
56212       var ways = [];
56213       var onewaydata = {};
56214       var sideddata = {};
56215       var oldMultiPolygonOuters = {};
56216       for (var i3 = 0; i3 < entities.length; i3++) {
56217         var entity = entities[i3];
56218         var outer = osmOldMultipolygonOuterMember(entity, graph);
56219         if (outer) {
56220           ways.push(entity.mergeTags(outer.tags));
56221           oldMultiPolygonOuters[outer.id] = true;
56222         } else if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") {
56223           ways.push(entity);
56224         }
56225       }
56226       ways = ways.filter(getPath);
56227       var pathdata = utilArrayGroupBy(ways, function(way) {
56228         return way.layer();
56229       });
56230       Object.keys(pathdata).forEach(function(k2) {
56231         var v2 = pathdata[k2];
56232         var onewayArr = v2.filter(function(d2) {
56233           return d2.isOneWay();
56234         });
56235         var onewaySegments = svgMarkerSegments(
56236           projection2,
56237           graph,
56238           35,
56239           function shouldReverse(entity2) {
56240             return entity2.tags.oneway === "-1";
56241           },
56242           function bothDirections(entity2) {
56243             return entity2.tags.oneway === "reversible" || entity2.tags.oneway === "alternating";
56244           }
56245         );
56246         onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments));
56247         var sidedArr = v2.filter(function(d2) {
56248           return d2.isSided();
56249         });
56250         var sidedSegments = svgMarkerSegments(
56251           projection2,
56252           graph,
56253           30,
56254           function shouldReverse() {
56255             return false;
56256           },
56257           function bothDirections() {
56258             return false;
56259           }
56260         );
56261         sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments));
56262       });
56263       var covered = selection2.selectAll(".layer-osm.covered");
56264       var uncovered = selection2.selectAll(".layer-osm.lines");
56265       var touchLayer = selection2.selectAll(".layer-touch.lines");
56266       [covered, uncovered].forEach(function(selection3) {
56267         var range3 = selection3 === covered ? range(-10, 0) : range(0, 11);
56268         var layergroup = selection3.selectAll("g.layergroup").data(range3);
56269         layergroup = layergroup.enter().append("g").attr("class", function(d2) {
56270           return "layergroup layer" + String(d2);
56271         }).merge(layergroup);
56272         layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) {
56273           return "linegroup line-" + d2;
56274         });
56275         layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false);
56276         layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false);
56277         layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false);
56278         layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true);
56279         layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true);
56280         layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true);
56281         addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, "url(#ideditor-oneway-marker)");
56282         addMarkers(
56283           layergroup,
56284           "sided",
56285           "sidedgroup",
56286           sideddata,
56287           function marker(d2) {
56288             var category = graph.entity(d2.id).sidednessIdentifier();
56289             return "url(#ideditor-sided-marker-" + category + ")";
56290           }
56291         );
56292       });
56293       touchLayer.call(drawTargets, graph, ways, filter2);
56294     }
56295     return drawLines;
56296   }
56297
56298   // modules/svg/midpoints.js
56299   function svgMidpoints(projection2, context) {
56300     var targetRadius = 8;
56301     function drawTargets(selection2, graph, entities, filter2) {
56302       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56303       var getTransform = svgPointTransform(projection2).geojson;
56304       var data = entities.map(function(midpoint) {
56305         return {
56306           type: "Feature",
56307           id: midpoint.id,
56308           properties: {
56309             target: true,
56310             entity: midpoint
56311           },
56312           geometry: {
56313             type: "Point",
56314             coordinates: midpoint.loc
56315           }
56316         };
56317       });
56318       var targets = selection2.selectAll(".midpoint.target").filter(function(d2) {
56319         return filter2(d2.properties.entity);
56320       }).data(data, function key(d2) {
56321         return d2.id;
56322       });
56323       targets.exit().remove();
56324       targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) {
56325         return "node midpoint target " + fillClass + d2.id;
56326       }).attr("transform", getTransform);
56327     }
56328     function drawMidpoints(selection2, graph, entities, filter2, extent) {
56329       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints");
56330       var touchLayer = selection2.selectAll(".layer-touch.points");
56331       var mode = context.mode();
56332       if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) {
56333         drawLayer.selectAll(".midpoint").remove();
56334         touchLayer.selectAll(".midpoint.target").remove();
56335         return;
56336       }
56337       var poly = extent.polygon();
56338       var midpoints = {};
56339       for (var i3 = 0; i3 < entities.length; i3++) {
56340         var entity = entities[i3];
56341         if (entity.type !== "way")
56342           continue;
56343         if (!filter2(entity))
56344           continue;
56345         if (context.selectedIDs().indexOf(entity.id) < 0)
56346           continue;
56347         var nodes = graph.childNodes(entity);
56348         for (var j2 = 0; j2 < nodes.length - 1; j2++) {
56349           var a2 = nodes[j2];
56350           var b2 = nodes[j2 + 1];
56351           var id2 = [a2.id, b2.id].sort().join("-");
56352           if (midpoints[id2]) {
56353             midpoints[id2].parents.push(entity);
56354           } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) {
56355             var point2 = geoVecInterp(a2.loc, b2.loc, 0.5);
56356             var loc = null;
56357             if (extent.intersects(point2)) {
56358               loc = point2;
56359             } else {
56360               for (var k2 = 0; k2 < 4; k2++) {
56361                 point2 = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]);
56362                 if (point2 && geoVecLength(projection2(a2.loc), projection2(point2)) > 20 && geoVecLength(projection2(b2.loc), projection2(point2)) > 20) {
56363                   loc = point2;
56364                   break;
56365                 }
56366               }
56367             }
56368             if (loc) {
56369               midpoints[id2] = {
56370                 type: "midpoint",
56371                 id: id2,
56372                 loc,
56373                 edge: [a2.id, b2.id],
56374                 parents: [entity]
56375               };
56376             }
56377           }
56378         }
56379       }
56380       function midpointFilter(d2) {
56381         if (midpoints[d2.id])
56382           return true;
56383         for (var i4 = 0; i4 < d2.parents.length; i4++) {
56384           if (filter2(d2.parents[i4])) {
56385             return true;
56386           }
56387         }
56388         return false;
56389       }
56390       var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) {
56391         return d2.id;
56392       });
56393       groups.exit().remove();
56394       var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint");
56395       enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow");
56396       enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill");
56397       groups = groups.merge(enter).attr("transform", function(d2) {
56398         var translate = svgPointTransform(projection2);
56399         var a3 = graph.entity(d2.edge[0]);
56400         var b3 = graph.entity(d2.edge[1]);
56401         var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI);
56402         return translate(d2) + " rotate(" + angle2 + ")";
56403       }).call(svgTagClasses().tags(
56404         function(d2) {
56405           return d2.parents[0].tags;
56406         }
56407       ));
56408       groups.select("polygon.shadow");
56409       groups.select("polygon.fill");
56410       touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter);
56411     }
56412     return drawMidpoints;
56413   }
56414
56415   // modules/svg/points.js
56416   var import_fast_deep_equal7 = __toESM(require_fast_deep_equal());
56417   function svgPoints(projection2, context) {
56418     function markerPath(selection2, klass) {
56419       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");
56420     }
56421     function sortY(a2, b2) {
56422       return b2.loc[1] - a2.loc[1];
56423     }
56424     function fastEntityKey(d2) {
56425       var mode = context.mode();
56426       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56427       return isMoving ? d2.id : osmEntity.key(d2);
56428     }
56429     function drawTargets(selection2, graph, entities, filter2) {
56430       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56431       var getTransform = svgPointTransform(projection2).geojson;
56432       var activeID = context.activeID();
56433       var data = [];
56434       entities.forEach(function(node) {
56435         if (activeID === node.id)
56436           return;
56437         data.push({
56438           type: "Feature",
56439           id: node.id,
56440           properties: {
56441             target: true,
56442             entity: node
56443           },
56444           geometry: node.asGeoJSON()
56445         });
56446       });
56447       var targets = selection2.selectAll(".point.target").filter(function(d2) {
56448         return filter2(d2.properties.entity);
56449       }).data(data, function key(d2) {
56450         return d2.id;
56451       });
56452       targets.exit().remove();
56453       targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) {
56454         return "node point target " + fillClass + d2.id;
56455       }).attr("transform", getTransform);
56456     }
56457     function drawPoints(selection2, graph, entities, filter2) {
56458       var wireframe = context.surface().classed("fill-wireframe");
56459       var zoom = geoScaleToZoom(projection2.scale());
56460       var base = context.history().base();
56461       function renderAsPoint(entity) {
56462         return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length);
56463       }
56464       var points = wireframe ? [] : entities.filter(renderAsPoint);
56465       points.sort(sortY);
56466       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points");
56467       var touchLayer = selection2.selectAll(".layer-touch.points");
56468       var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey);
56469       groups.exit().remove();
56470       var enter = groups.enter().append("g").attr("class", function(d2) {
56471         return "node point " + d2.id;
56472       }).order();
56473       enter.append("path").call(markerPath, "shadow");
56474       enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
56475       enter.append("path").call(markerPath, "stroke");
56476       enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px");
56477       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) {
56478         return !base.entities[d2.id];
56479       }).classed("moved", function(d2) {
56480         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56481       }).classed("retagged", function(d2) {
56482         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56483       }).call(svgTagClasses());
56484       groups.select(".shadow");
56485       groups.select(".stroke");
56486       groups.select(".icon").attr("xlink:href", function(entity) {
56487         var preset = _mainPresetIndex.match(entity, graph);
56488         var picon = preset && preset.icon;
56489         return picon ? "#" + picon : "";
56490       });
56491       touchLayer.call(drawTargets, graph, points, filter2);
56492     }
56493     return drawPoints;
56494   }
56495
56496   // modules/svg/turns.js
56497   function svgTurns(projection2, context) {
56498     function icon2(turn) {
56499       var u2 = turn.u ? "-u" : "";
56500       if (turn.no)
56501         return "#iD-turn-no" + u2;
56502       if (turn.only)
56503         return "#iD-turn-only" + u2;
56504       return "#iD-turn-yes" + u2;
56505     }
56506     function drawTurns(selection2, graph, turns) {
56507       function turnTransform(d2) {
56508         var pxRadius = 50;
56509         var toWay = graph.entity(d2.to.way);
56510         var toPoints = graph.childNodes(toWay).map(function(n3) {
56511           return n3.loc;
56512         }).map(projection2);
56513         var toLength = geoPathLength(toPoints);
56514         var mid = toLength / 2;
56515         var toNode = graph.entity(d2.to.node);
56516         var toVertex = graph.entity(d2.to.vertex);
56517         var a2 = geoAngle(toVertex, toNode, projection2);
56518         var o2 = projection2(toVertex.loc);
56519         var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius);
56520         return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")";
56521       }
56522       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns");
56523       var touchLayer = selection2.selectAll(".layer-touch.turns");
56524       var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) {
56525         return d2.key;
56526       });
56527       groups.exit().remove();
56528       var groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56529         return "turn " + d2.key;
56530       });
56531       var turnsEnter = groupsEnter.filter(function(d2) {
56532         return !d2.u;
56533       });
56534       turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56535       turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56536       var uEnter = groupsEnter.filter(function(d2) {
56537         return d2.u;
56538       });
56539       uEnter.append("circle").attr("r", "16");
56540       uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32");
56541       groups = groups.merge(groupsEnter).attr("opacity", function(d2) {
56542         return d2.direct === false ? "0.7" : null;
56543       }).attr("transform", turnTransform);
56544       groups.select("use").attr("xlink:href", icon2);
56545       groups.select("rect");
56546       groups.select("circle");
56547       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56548       groups = touchLayer.selectAll("g.turn").data(turns, function(d2) {
56549         return d2.key;
56550       });
56551       groups.exit().remove();
56552       groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56553         return "turn " + d2.key;
56554       });
56555       turnsEnter = groupsEnter.filter(function(d2) {
56556         return !d2.u;
56557       });
56558       turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56559       uEnter = groupsEnter.filter(function(d2) {
56560         return d2.u;
56561       });
56562       uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16");
56563       groups = groups.merge(groupsEnter).attr("transform", turnTransform);
56564       groups.select("rect");
56565       groups.select("circle");
56566       return this;
56567     }
56568     return drawTurns;
56569   }
56570
56571   // modules/svg/vertices.js
56572   var import_fast_deep_equal8 = __toESM(require_fast_deep_equal());
56573   function svgVertices(projection2, context) {
56574     var radiuses = {
56575       //       z16-, z17,   z18+,  w/icon
56576       shadow: [6, 7.5, 7.5, 12],
56577       stroke: [2.5, 3.5, 3.5, 8],
56578       fill: [1, 1.5, 1.5, 1.5]
56579     };
56580     var _currHoverTarget;
56581     var _currPersistent = {};
56582     var _currHover = {};
56583     var _prevHover = {};
56584     var _currSelected = {};
56585     var _prevSelected = {};
56586     var _radii = {};
56587     function sortY(a2, b2) {
56588       return b2.loc[1] - a2.loc[1];
56589     }
56590     function fastEntityKey(d2) {
56591       var mode = context.mode();
56592       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56593       return isMoving ? d2.id : osmEntity.key(d2);
56594     }
56595     function draw(selection2, graph, vertices, sets2, filter2) {
56596       sets2 = sets2 || { selected: {}, important: {}, hovered: {} };
56597       var icons = {};
56598       var directions = {};
56599       var wireframe = context.surface().classed("fill-wireframe");
56600       var zoom = geoScaleToZoom(projection2.scale());
56601       var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2;
56602       var activeID = context.activeID();
56603       var base = context.history().base();
56604       function getIcon(d2) {
56605         var entity = graph.entity(d2.id);
56606         if (entity.id in icons)
56607           return icons[entity.id];
56608         icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon;
56609         return icons[entity.id];
56610       }
56611       function getDirections(entity) {
56612         if (entity.id in directions)
56613           return directions[entity.id];
56614         var angles = entity.directions(graph, projection2);
56615         directions[entity.id] = angles.length ? angles : false;
56616         return angles;
56617       }
56618       function updateAttributes(selection3) {
56619         ["shadow", "stroke", "fill"].forEach(function(klass) {
56620           var rads = radiuses[klass];
56621           selection3.selectAll("." + klass).each(function(entity) {
56622             var i3 = z2 && getIcon(entity);
56623             var r2 = rads[i3 ? 3 : z2];
56624             if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) {
56625               r2 += 1.5;
56626             }
56627             if (klass === "shadow") {
56628               _radii[entity.id] = r2;
56629             }
56630             select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null);
56631           });
56632         });
56633       }
56634       vertices.sort(sortY);
56635       var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey);
56636       groups.exit().remove();
56637       var enter = groups.enter().append("g").attr("class", function(d2) {
56638         return "node vertex " + d2.id;
56639       }).order();
56640       enter.append("circle").attr("class", "shadow");
56641       enter.append("circle").attr("class", "stroke");
56642       enter.filter(function(d2) {
56643         return d2.hasInterestingTags();
56644       }).append("circle").attr("class", "fill");
56645       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) {
56646         return d2.id in sets2.selected;
56647       }).classed("shared", function(d2) {
56648         return graph.isShared(d2);
56649       }).classed("endpoint", function(d2) {
56650         return d2.isEndpoint(graph);
56651       }).classed("added", function(d2) {
56652         return !base.entities[d2.id];
56653       }).classed("moved", function(d2) {
56654         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56655       }).classed("retagged", function(d2) {
56656         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56657       }).call(updateAttributes);
56658       var iconUse = groups.selectAll(".icon").data(function data(d2) {
56659         return zoom >= 17 && getIcon(d2) ? [d2] : [];
56660       }, fastEntityKey);
56661       iconUse.exit().remove();
56662       iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) {
56663         var picon = getIcon(d2);
56664         return picon ? "#" + picon : "";
56665       });
56666       var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) {
56667         return zoom >= 18 && getDirections(d2) ? [d2] : [];
56668       }, fastEntityKey);
56669       dgroups.exit().remove();
56670       dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups);
56671       var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) {
56672         return osmEntity.key(d2);
56673       });
56674       viewfields.exit().remove();
56675       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) {
56676         return "rotate(" + d2 + ")";
56677       });
56678     }
56679     function drawTargets(selection2, graph, entities, filter2) {
56680       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56681       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56682       var getTransform = svgPointTransform(projection2).geojson;
56683       var activeID = context.activeID();
56684       var data = { targets: [], nopes: [] };
56685       entities.forEach(function(node) {
56686         if (activeID === node.id)
56687           return;
56688         var vertexType = svgPassiveVertex(node, graph, activeID);
56689         if (vertexType !== 0) {
56690           data.targets.push({
56691             type: "Feature",
56692             id: node.id,
56693             properties: {
56694               target: true,
56695               entity: node
56696             },
56697             geometry: node.asGeoJSON()
56698           });
56699         } else {
56700           data.nopes.push({
56701             type: "Feature",
56702             id: node.id + "-nope",
56703             properties: {
56704               nope: true,
56705               target: true,
56706               entity: node
56707             },
56708             geometry: node.asGeoJSON()
56709           });
56710         }
56711       });
56712       var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) {
56713         return filter2(d2.properties.entity);
56714       }).data(data.targets, function key(d2) {
56715         return d2.id;
56716       });
56717       targets.exit().remove();
56718       targets.enter().append("circle").attr("r", function(d2) {
56719         return _radii[d2.id] || radiuses.shadow[3];
56720       }).merge(targets).attr("class", function(d2) {
56721         return "node vertex target target-allowed " + targetClass + d2.id;
56722       }).attr("transform", getTransform);
56723       var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) {
56724         return filter2(d2.properties.entity);
56725       }).data(data.nopes, function key(d2) {
56726         return d2.id;
56727       });
56728       nopes.exit().remove();
56729       nopes.enter().append("circle").attr("r", function(d2) {
56730         return _radii[d2.properties.entity.id] || radiuses.shadow[3];
56731       }).merge(nopes).attr("class", function(d2) {
56732         return "node vertex target target-nope " + nopeClass + d2.id;
56733       }).attr("transform", getTransform);
56734     }
56735     function renderAsVertex(entity, graph, wireframe, zoom) {
56736       var geometry = entity.geometry(graph);
56737       return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length);
56738     }
56739     function isEditedNode(node, base, head) {
56740       var baseNode = base.entities[node.id];
56741       var headNode = head.entities[node.id];
56742       return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc);
56743     }
56744     function getSiblingAndChildVertices(ids, graph, wireframe, zoom) {
56745       var results = {};
56746       var seenIds = {};
56747       function addChildVertices(entity) {
56748         if (seenIds[entity.id])
56749           return;
56750         seenIds[entity.id] = true;
56751         var geometry = entity.geometry(graph);
56752         if (!context.features().isHiddenFeature(entity, graph, geometry)) {
56753           var i3;
56754           if (entity.type === "way") {
56755             for (i3 = 0; i3 < entity.nodes.length; i3++) {
56756               var child = graph.hasEntity(entity.nodes[i3]);
56757               if (child) {
56758                 addChildVertices(child);
56759               }
56760             }
56761           } else if (entity.type === "relation") {
56762             for (i3 = 0; i3 < entity.members.length; i3++) {
56763               var member = graph.hasEntity(entity.members[i3].id);
56764               if (member) {
56765                 addChildVertices(member);
56766               }
56767             }
56768           } else if (renderAsVertex(entity, graph, wireframe, zoom)) {
56769             results[entity.id] = entity;
56770           }
56771         }
56772       }
56773       ids.forEach(function(id2) {
56774         var entity = graph.hasEntity(id2);
56775         if (!entity)
56776           return;
56777         if (entity.type === "node") {
56778           if (renderAsVertex(entity, graph, wireframe, zoom)) {
56779             results[entity.id] = entity;
56780             graph.parentWays(entity).forEach(function(entity2) {
56781               addChildVertices(entity2);
56782             });
56783           }
56784         } else {
56785           addChildVertices(entity);
56786         }
56787       });
56788       return results;
56789     }
56790     function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) {
56791       var wireframe = context.surface().classed("fill-wireframe");
56792       var visualDiff = context.surface().classed("highlight-edited");
56793       var zoom = geoScaleToZoom(projection2.scale());
56794       var mode = context.mode();
56795       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56796       var base = context.history().base();
56797       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices");
56798       var touchLayer = selection2.selectAll(".layer-touch.points");
56799       if (fullRedraw) {
56800         _currPersistent = {};
56801         _radii = {};
56802       }
56803       for (var i3 = 0; i3 < entities.length; i3++) {
56804         var entity = entities[i3];
56805         var geometry = entity.geometry(graph);
56806         var keep = false;
56807         if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) {
56808           _currPersistent[entity.id] = entity;
56809           keep = true;
56810         } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) {
56811           _currPersistent[entity.id] = entity;
56812           keep = true;
56813         }
56814         if (!keep && !fullRedraw) {
56815           delete _currPersistent[entity.id];
56816         }
56817       }
56818       var sets2 = {
56819         persistent: _currPersistent,
56820         // persistent = important vertices (render always)
56821         selected: _currSelected,
56822         // selected + siblings of selected (render always)
56823         hovered: _currHover
56824         // hovered + siblings of hovered (render only in draw modes)
56825       };
56826       var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent);
56827       var filterRendered = function(d2) {
56828         return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2);
56829       };
56830       drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered);
56831       var filterTouch = function(d2) {
56832         return isMoving ? true : filterRendered(d2);
56833       };
56834       touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch);
56835       function currentVisible(which) {
56836         return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) {
56837           return entity2 && entity2.intersects(extent, graph);
56838         });
56839       }
56840     }
56841     drawVertices.drawSelected = function(selection2, graph, extent) {
56842       var wireframe = context.surface().classed("fill-wireframe");
56843       var zoom = geoScaleToZoom(projection2.scale());
56844       _prevSelected = _currSelected || {};
56845       if (context.map().isInWideSelection()) {
56846         _currSelected = {};
56847         context.selectedIDs().forEach(function(id2) {
56848           var entity = graph.hasEntity(id2);
56849           if (!entity)
56850             return;
56851           if (entity.type === "node") {
56852             if (renderAsVertex(entity, graph, wireframe, zoom)) {
56853               _currSelected[entity.id] = entity;
56854             }
56855           }
56856         });
56857       } else {
56858         _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom);
56859       }
56860       var filter2 = function(d2) {
56861         return d2.id in _prevSelected;
56862       };
56863       drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false);
56864     };
56865     drawVertices.drawHover = function(selection2, graph, target, extent) {
56866       if (target === _currHoverTarget)
56867         return;
56868       var wireframe = context.surface().classed("fill-wireframe");
56869       var zoom = geoScaleToZoom(projection2.scale());
56870       _prevHover = _currHover || {};
56871       _currHoverTarget = target;
56872       var entity = target && target.properties && target.properties.entity;
56873       if (entity) {
56874         _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom);
56875       } else {
56876         _currHover = {};
56877       }
56878       var filter2 = function(d2) {
56879         return d2.id in _prevHover;
56880       };
56881       drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false);
56882     };
56883     return drawVertices;
56884   }
56885
56886   // modules/util/bind_once.js
56887   function utilBindOnce(target, type2, listener, capture) {
56888     var typeOnce = type2 + ".once";
56889     function one2() {
56890       target.on(typeOnce, null);
56891       listener.apply(this, arguments);
56892     }
56893     target.on(typeOnce, one2, capture);
56894     return this;
56895   }
56896
56897   // modules/util/zoom_pan.js
56898   function defaultFilter3(d3_event) {
56899     return !d3_event.ctrlKey && !d3_event.button;
56900   }
56901   function defaultExtent2() {
56902     var e3 = this;
56903     if (e3 instanceof SVGElement) {
56904       e3 = e3.ownerSVGElement || e3;
56905       if (e3.hasAttribute("viewBox")) {
56906         e3 = e3.viewBox.baseVal;
56907         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
56908       }
56909       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
56910     }
56911     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
56912   }
56913   function defaultWheelDelta2(d3_event) {
56914     return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3);
56915   }
56916   function defaultConstrain2(transform2, extent, translateExtent) {
56917     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];
56918     return transform2.translate(
56919       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
56920       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
56921     );
56922   }
56923   function utilZoomPan() {
56924     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;
56925     function zoom(selection2) {
56926       selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
56927       select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup);
56928     }
56929     zoom.transform = function(collection, transform2, point2) {
56930       var selection2 = collection.selection ? collection.selection() : collection;
56931       if (collection !== selection2) {
56932         schedule(collection, transform2, point2);
56933       } else {
56934         selection2.interrupt().each(function() {
56935           gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null);
56936         });
56937       }
56938     };
56939     zoom.scaleBy = function(selection2, k2, p2) {
56940       zoom.scaleTo(selection2, function() {
56941         var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
56942         return k0 * k1;
56943       }, p2);
56944     };
56945     zoom.scaleTo = function(selection2, k2, p2) {
56946       zoom.transform(selection2, function() {
56947         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;
56948         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
56949       }, p2);
56950     };
56951     zoom.translateBy = function(selection2, x2, y2) {
56952       zoom.transform(selection2, function() {
56953         return constrain(_transform.translate(
56954           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
56955           typeof y2 === "function" ? y2.apply(this, arguments) : y2
56956         ), extent.apply(this, arguments), translateExtent);
56957       });
56958     };
56959     zoom.translateTo = function(selection2, x2, y2, p2) {
56960       zoom.transform(selection2, function() {
56961         var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
56962         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
56963           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
56964           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
56965         ), e3, translateExtent);
56966       }, p2);
56967     };
56968     function scale(transform2, k2) {
56969       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
56970       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
56971     }
56972     function translate(transform2, p02, p1) {
56973       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
56974       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
56975     }
56976     function centroid(extent2) {
56977       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
56978     }
56979     function schedule(transition2, transform2, point2) {
56980       transition2.on("start.zoom", function() {
56981         gesture(this, arguments).start(null);
56982       }).on("interrupt.zoom end.zoom", function() {
56983         gesture(this, arguments).end(null);
56984       }).tween("zoom", function() {
56985         var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point2 ? centroid(e3) : typeof point2 === "function" ? point2.apply(that, args) : point2, 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));
56986         return function(t2) {
56987           if (t2 === 1) {
56988             t2 = b2;
56989           } else {
56990             var l2 = i3(t2);
56991             var k2 = w2 / l2[2];
56992             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
56993           }
56994           g3.zoom(null, null, t2);
56995         };
56996       });
56997     }
56998     function gesture(that, args, clean2) {
56999       return !clean2 && _activeGesture || new Gesture(that, args);
57000     }
57001     function Gesture(that, args) {
57002       this.that = that;
57003       this.args = args;
57004       this.active = 0;
57005       this.extent = extent.apply(that, args);
57006     }
57007     Gesture.prototype = {
57008       start: function(d3_event) {
57009         if (++this.active === 1) {
57010           _activeGesture = this;
57011           dispatch14.call("start", this, d3_event);
57012         }
57013         return this;
57014       },
57015       zoom: function(d3_event, key, transform2) {
57016         if (this.mouse && key !== "mouse")
57017           this.mouse[1] = transform2.invert(this.mouse[0]);
57018         if (this.pointer0 && key !== "touch")
57019           this.pointer0[1] = transform2.invert(this.pointer0[0]);
57020         if (this.pointer1 && key !== "touch")
57021           this.pointer1[1] = transform2.invert(this.pointer1[0]);
57022         _transform = transform2;
57023         dispatch14.call("zoom", this, d3_event, key, transform2);
57024         return this;
57025       },
57026       end: function(d3_event) {
57027         if (--this.active === 0) {
57028           _activeGesture = null;
57029           dispatch14.call("end", this, d3_event);
57030         }
57031         return this;
57032       }
57033     };
57034     function wheeled(d3_event) {
57035       if (!filter2.apply(this, arguments))
57036         return;
57037       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);
57038       if (g3.wheel) {
57039         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
57040           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
57041         }
57042         clearTimeout(g3.wheel);
57043       } else {
57044         g3.mouse = [p2, t2.invert(p2)];
57045         interrupt_default(this);
57046         g3.start(d3_event);
57047       }
57048       d3_event.preventDefault();
57049       d3_event.stopImmediatePropagation();
57050       g3.wheel = setTimeout(wheelidled, _wheelDelay);
57051       g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
57052       function wheelidled() {
57053         g3.wheel = null;
57054         g3.end(d3_event);
57055       }
57056     }
57057     var _downPointerIDs = /* @__PURE__ */ new Set();
57058     var _pointerLocGetter;
57059     function pointerdown(d3_event) {
57060       _downPointerIDs.add(d3_event.pointerId);
57061       if (!filter2.apply(this, arguments))
57062         return;
57063       var g3 = gesture(this, arguments, _downPointerIDs.size === 1);
57064       var started;
57065       d3_event.stopImmediatePropagation();
57066       _pointerLocGetter = utilFastMouse(this);
57067       var loc = _pointerLocGetter(d3_event);
57068       var p2 = [loc, _transform.invert(loc), d3_event.pointerId];
57069       if (!g3.pointer0) {
57070         g3.pointer0 = p2;
57071         started = true;
57072       } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) {
57073         g3.pointer1 = p2;
57074       }
57075       if (started) {
57076         interrupt_default(this);
57077         g3.start(d3_event);
57078       }
57079     }
57080     function pointermove(d3_event) {
57081       if (!_downPointerIDs.has(d3_event.pointerId))
57082         return;
57083       if (!_activeGesture || !_pointerLocGetter)
57084         return;
57085       var g3 = gesture(this, arguments);
57086       var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId;
57087       var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId;
57088       if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) {
57089         if (g3.pointer0)
57090           _downPointerIDs.delete(g3.pointer0[2]);
57091         if (g3.pointer1)
57092           _downPointerIDs.delete(g3.pointer1[2]);
57093         g3.end(d3_event);
57094         return;
57095       }
57096       d3_event.preventDefault();
57097       d3_event.stopImmediatePropagation();
57098       var loc = _pointerLocGetter(d3_event);
57099       var t2, p2, l2;
57100       if (isPointer0)
57101         g3.pointer0[0] = loc;
57102       else if (isPointer1)
57103         g3.pointer1[0] = loc;
57104       t2 = _transform;
57105       if (g3.pointer1) {
57106         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;
57107         t2 = scale(t2, Math.sqrt(dp / dl));
57108         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
57109         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
57110       } else if (g3.pointer0) {
57111         p2 = g3.pointer0[0];
57112         l2 = g3.pointer0[1];
57113       } else {
57114         return;
57115       }
57116       g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
57117     }
57118     function pointerup(d3_event) {
57119       if (!_downPointerIDs.has(d3_event.pointerId))
57120         return;
57121       _downPointerIDs.delete(d3_event.pointerId);
57122       if (!_activeGesture)
57123         return;
57124       var g3 = gesture(this, arguments);
57125       d3_event.stopImmediatePropagation();
57126       if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId)
57127         delete g3.pointer0;
57128       else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId)
57129         delete g3.pointer1;
57130       if (g3.pointer1 && !g3.pointer0) {
57131         g3.pointer0 = g3.pointer1;
57132         delete g3.pointer1;
57133       }
57134       if (g3.pointer0) {
57135         g3.pointer0[1] = _transform.invert(g3.pointer0[0]);
57136       } else {
57137         g3.end(d3_event);
57138       }
57139     }
57140     zoom.wheelDelta = function(_2) {
57141       return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta;
57142     };
57143     zoom.filter = function(_2) {
57144       return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2;
57145     };
57146     zoom.extent = function(_2) {
57147       return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
57148     };
57149     zoom.scaleExtent = function(_2) {
57150       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
57151     };
57152     zoom.translateExtent = function(_2) {
57153       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]]];
57154     };
57155     zoom.constrain = function(_2) {
57156       return arguments.length ? (constrain = _2, zoom) : constrain;
57157     };
57158     zoom.interpolate = function(_2) {
57159       return arguments.length ? (interpolate = _2, zoom) : interpolate;
57160     };
57161     zoom._transform = function(_2) {
57162       return arguments.length ? (_transform = _2, zoom) : _transform;
57163     };
57164     return utilRebind(zoom, dispatch14, "on");
57165   }
57166
57167   // modules/util/double_up.js
57168   function utilDoubleUp() {
57169     var dispatch14 = dispatch_default("doubleUp");
57170     var _maxTimespan = 500;
57171     var _maxDistance = 20;
57172     var _pointer;
57173     function pointerIsValidFor(loc) {
57174       return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown
57175       geoVecLength(_pointer.startLoc, loc) <= _maxDistance;
57176     }
57177     function pointerdown(d3_event) {
57178       if (d3_event.ctrlKey || d3_event.button === 2)
57179         return;
57180       var loc = [d3_event.clientX, d3_event.clientY];
57181       if (_pointer && !pointerIsValidFor(loc)) {
57182         _pointer = void 0;
57183       }
57184       if (!_pointer) {
57185         _pointer = {
57186           startLoc: loc,
57187           startTime: (/* @__PURE__ */ new Date()).getTime(),
57188           upCount: 0,
57189           pointerId: d3_event.pointerId
57190         };
57191       } else {
57192         _pointer.pointerId = d3_event.pointerId;
57193       }
57194     }
57195     function pointerup(d3_event) {
57196       if (d3_event.ctrlKey || d3_event.button === 2)
57197         return;
57198       if (!_pointer || _pointer.pointerId !== d3_event.pointerId)
57199         return;
57200       _pointer.upCount += 1;
57201       if (_pointer.upCount === 2) {
57202         var loc = [d3_event.clientX, d3_event.clientY];
57203         if (pointerIsValidFor(loc)) {
57204           var locInThis = utilFastMouse(this)(d3_event);
57205           dispatch14.call("doubleUp", this, d3_event, locInThis);
57206         }
57207         _pointer = void 0;
57208       }
57209     }
57210     function doubleUp(selection2) {
57211       if ("PointerEvent" in window) {
57212         selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup);
57213       } else {
57214         selection2.on("dblclick.doubleUp", function(d3_event) {
57215           dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event));
57216         });
57217       }
57218     }
57219     doubleUp.off = function(selection2) {
57220       selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null);
57221     };
57222     return utilRebind(doubleUp, dispatch14, "on");
57223   }
57224
57225   // modules/renderer/map.js
57226   var TILESIZE = 256;
57227   var minZoom2 = 2;
57228   var maxZoom = 24;
57229   var kMin = geoZoomToScale(minZoom2, TILESIZE);
57230   var kMax = geoZoomToScale(maxZoom, TILESIZE);
57231   function clamp2(num, min3, max3) {
57232     return Math.max(min3, Math.min(num, max3));
57233   }
57234   function rendererMap(context) {
57235     var dispatch14 = dispatch_default(
57236       "move",
57237       "drawn",
57238       "crossEditableZoom",
57239       "hitMinZoom",
57240       "changeHighlighting",
57241       "changeAreaFill"
57242     );
57243     var projection2 = context.projection;
57244     var curtainProjection = context.curtainProjection;
57245     var drawLayers;
57246     var drawPoints;
57247     var drawVertices;
57248     var drawLines;
57249     var drawAreas;
57250     var drawMidpoints;
57251     var drawLabels;
57252     var _selection = select_default2(null);
57253     var supersurface = select_default2(null);
57254     var wrapper = select_default2(null);
57255     var surface = select_default2(null);
57256     var _dimensions = [1, 1];
57257     var _dblClickZoomEnabled = true;
57258     var _redrawEnabled = true;
57259     var _gestureTransformStart;
57260     var _transformStart = projection2.transform();
57261     var _transformLast;
57262     var _isTransformed = false;
57263     var _minzoom = 0;
57264     var _getMouseCoords;
57265     var _lastPointerEvent;
57266     var _lastWithinEditableZoom;
57267     var _pointerDown = false;
57268     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
57269     var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2;
57270     var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) {
57271       _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown");
57272     }).on("end.map", function() {
57273       _pointerDown = false;
57274     });
57275     var _doubleUpHandler = utilDoubleUp();
57276     var scheduleRedraw = throttle_default(redraw, 750);
57277     function cancelPendingRedraw() {
57278       scheduleRedraw.cancel();
57279     }
57280     function map2(selection2) {
57281       _selection = selection2;
57282       context.on("change.map", immediateRedraw);
57283       var osm = context.connection();
57284       if (osm) {
57285         osm.on("change.map", immediateRedraw);
57286       }
57287       function didUndoOrRedo(targetTransform) {
57288         var mode = context.mode().id;
57289         if (mode !== "browse" && mode !== "select")
57290           return;
57291         if (targetTransform) {
57292           map2.transformEase(targetTransform);
57293         }
57294       }
57295       context.history().on("merge.map", function() {
57296         scheduleRedraw();
57297       }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) {
57298         didUndoOrRedo(fromStack.transform);
57299       }).on("redone.map", function(stack) {
57300         didUndoOrRedo(stack.transform);
57301       });
57302       context.background().on("change.map", immediateRedraw);
57303       context.features().on("redraw.map", immediateRedraw);
57304       drawLayers.on("change.map", function() {
57305         context.background().updateImagery();
57306         immediateRedraw();
57307       });
57308       selection2.on("wheel.map mousewheel.map", function(d3_event) {
57309         d3_event.preventDefault();
57310       }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null);
57311       map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0);
57312       wrapper = supersurface.append("div").attr("class", "layer layer-data");
57313       map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface");
57314       surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) {
57315         _lastPointerEvent = d3_event;
57316         if (d3_event.button === 2) {
57317           d3_event.stopPropagation();
57318         }
57319       }, true).on(_pointerPrefix + "up.zoom", function(d3_event) {
57320         _lastPointerEvent = d3_event;
57321         if (resetTransform()) {
57322           immediateRedraw();
57323         }
57324       }).on(_pointerPrefix + "move.map", function(d3_event) {
57325         _lastPointerEvent = d3_event;
57326       }).on(_pointerPrefix + "over.vertices", function(d3_event) {
57327         if (map2.editableDataEnabled() && !_isTransformed) {
57328           var hover = d3_event.target.__data__;
57329           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57330           dispatch14.call("drawn", this, { full: false });
57331         }
57332       }).on(_pointerPrefix + "out.vertices", function(d3_event) {
57333         if (map2.editableDataEnabled() && !_isTransformed) {
57334           var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
57335           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57336           dispatch14.call("drawn", this, { full: false });
57337         }
57338       });
57339       var detected = utilDetect();
57340       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
57341       // but we only need to do this on desktop Safari anyway. – #7694
57342       !detected.isMobileWebKit) {
57343         surface.on("gesturestart.surface", function(d3_event) {
57344           d3_event.preventDefault();
57345           _gestureTransformStart = projection2.transform();
57346         }).on("gesturechange.surface", gestureChange);
57347       }
57348       updateAreaFill();
57349       _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) {
57350         if (!_dblClickZoomEnabled)
57351           return;
57352         if (typeof d3_event.target.__data__ === "object" && // or area fills
57353         !select_default2(d3_event.target).classed("fill"))
57354           return;
57355         var zoomOut2 = d3_event.shiftKey;
57356         var t2 = projection2.transform();
57357         var p1 = t2.invert(p02);
57358         t2 = t2.scale(zoomOut2 ? 0.5 : 2);
57359         t2.x = p02[0] - p1[0] * t2.k;
57360         t2.y = p02[1] - p1[1] * t2.k;
57361         map2.transformEase(t2);
57362       });
57363       context.on("enter.map", function() {
57364         if (!map2.editableDataEnabled(
57365           true
57366           /* skip zoom check */
57367         ))
57368           return;
57369         if (_isTransformed)
57370           return;
57371         var graph = context.graph();
57372         var selectedAndParents = {};
57373         context.selectedIDs().forEach(function(id2) {
57374           var entity = graph.hasEntity(id2);
57375           if (entity) {
57376             selectedAndParents[entity.id] = entity;
57377             if (entity.type === "node") {
57378               graph.parentWays(entity).forEach(function(parent) {
57379                 selectedAndParents[parent.id] = parent;
57380               });
57381             }
57382           }
57383         });
57384         var data = Object.values(selectedAndParents);
57385         var filter2 = function(d2) {
57386           return d2.id in selectedAndParents;
57387         };
57388         data = context.features().filter(data, graph);
57389         surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent());
57390         dispatch14.call("drawn", this, { full: false });
57391         scheduleRedraw();
57392       });
57393       map2.dimensions(utilGetDimensions(selection2));
57394     }
57395     function zoomEventFilter(d3_event) {
57396       if (d3_event.type === "mousedown") {
57397         var hasOrphan = false;
57398         var listeners = window.__on;
57399         for (var i3 = 0; i3 < listeners.length; i3++) {
57400           var listener = listeners[i3];
57401           if (listener.name === "zoom" && listener.type === "mouseup") {
57402             hasOrphan = true;
57403             break;
57404           }
57405         }
57406         if (hasOrphan) {
57407           var event = window.CustomEvent;
57408           if (event) {
57409             event = new event("mouseup");
57410           } else {
57411             event = window.document.createEvent("Event");
57412             event.initEvent("mouseup", false, false);
57413           }
57414           event.view = window;
57415           window.dispatchEvent(event);
57416         }
57417       }
57418       return d3_event.button !== 2;
57419     }
57420     function pxCenter() {
57421       return [_dimensions[0] / 2, _dimensions[1] / 2];
57422     }
57423     function drawEditable(difference2, extent) {
57424       var mode = context.mode();
57425       var graph = context.graph();
57426       var features = context.features();
57427       var all = context.history().intersects(map2.extent());
57428       var fullRedraw = false;
57429       var data;
57430       var set4;
57431       var filter2;
57432       var applyFeatureLayerFilters = true;
57433       if (map2.isInWideSelection()) {
57434         data = [];
57435         utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) {
57436           var entity = context.hasEntity(id2);
57437           if (entity)
57438             data.push(entity);
57439         });
57440         fullRedraw = true;
57441         filter2 = utilFunctor(true);
57442         applyFeatureLayerFilters = false;
57443       } else if (difference2) {
57444         var complete = difference2.complete(map2.extent());
57445         data = Object.values(complete).filter(Boolean);
57446         set4 = new Set(Object.keys(complete));
57447         filter2 = function(d2) {
57448           return set4.has(d2.id);
57449         };
57450         features.clear(data);
57451       } else {
57452         if (features.gatherStats(all, graph, _dimensions)) {
57453           extent = void 0;
57454         }
57455         if (extent) {
57456           data = context.history().intersects(map2.extent().intersection(extent));
57457           set4 = new Set(data.map(function(entity) {
57458             return entity.id;
57459           }));
57460           filter2 = function(d2) {
57461             return set4.has(d2.id);
57462           };
57463         } else {
57464           data = all;
57465           fullRedraw = true;
57466           filter2 = utilFunctor(true);
57467         }
57468       }
57469       if (applyFeatureLayerFilters) {
57470         data = features.filter(data, graph);
57471       } else {
57472         context.features().resetStats();
57473       }
57474       if (mode && mode.id === "select") {
57475         surface.call(drawVertices.drawSelected, graph, map2.extent());
57476       }
57477       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);
57478       dispatch14.call("drawn", this, { full: true });
57479     }
57480     map2.init = function() {
57481       drawLayers = svgLayers(projection2, context);
57482       drawPoints = svgPoints(projection2, context);
57483       drawVertices = svgVertices(projection2, context);
57484       drawLines = svgLines(projection2, context);
57485       drawAreas = svgAreas(projection2, context);
57486       drawMidpoints = svgMidpoints(projection2, context);
57487       drawLabels = svgLabels(projection2, context);
57488     };
57489     function editOff() {
57490       context.features().resetStats();
57491       surface.selectAll(".layer-osm *").remove();
57492       surface.selectAll(".layer-touch:not(.markers) *").remove();
57493       var allowed = {
57494         "browse": true,
57495         "save": true,
57496         "select-note": true,
57497         "select-data": true,
57498         "select-error": true
57499       };
57500       var mode = context.mode();
57501       if (mode && !allowed[mode.id]) {
57502         context.enter(modeBrowse(context));
57503       }
57504       dispatch14.call("drawn", this, { full: true });
57505     }
57506     function gestureChange(d3_event) {
57507       var e3 = d3_event;
57508       e3.preventDefault();
57509       var props = {
57510         deltaMode: 0,
57511         // dummy values to ignore in zoomPan
57512         deltaY: 1,
57513         // dummy values to ignore in zoomPan
57514         clientX: e3.clientX,
57515         clientY: e3.clientY,
57516         screenX: e3.screenX,
57517         screenY: e3.screenY,
57518         x: e3.x,
57519         y: e3.y
57520       };
57521       var e22 = new WheelEvent("wheel", props);
57522       e22._scale = e3.scale;
57523       e22._rotation = e3.rotation;
57524       _selection.node().dispatchEvent(e22);
57525     }
57526     function zoomPan2(event, key, transform2) {
57527       var source = event && event.sourceEvent || event;
57528       var eventTransform = transform2 || event && event.transform;
57529       var x2 = eventTransform.x;
57530       var y2 = eventTransform.y;
57531       var k2 = eventTransform.k;
57532       if (source && source.type === "wheel") {
57533         if (_pointerDown)
57534           return;
57535         var detected = utilDetect();
57536         var dX = source.deltaX;
57537         var dY = source.deltaY;
57538         var x22 = x2;
57539         var y22 = y2;
57540         var k22 = k2;
57541         var t0, p02, p1;
57542         if (source.deltaMode === 1) {
57543           var lines = Math.abs(source.deltaY);
57544           var sign2 = source.deltaY > 0 ? 1 : -1;
57545           dY = sign2 * clamp2(
57546             Math.exp((lines - 1) * 0.75) * 4.000244140625,
57547             4.000244140625,
57548             // min
57549             350.000244140625
57550             // max
57551           );
57552           if (detected.os !== "mac") {
57553             dY *= 5;
57554           }
57555           t0 = _isTransformed ? _transformLast : _transformStart;
57556           p02 = _getMouseCoords(source);
57557           p1 = t0.invert(p02);
57558           k22 = t0.k * Math.pow(2, -dY / 500);
57559           k22 = clamp2(k22, kMin, kMax);
57560           x22 = p02[0] - p1[0] * k22;
57561           y22 = p02[1] - p1[1] * k22;
57562         } else if (source._scale) {
57563           t0 = _gestureTransformStart;
57564           p02 = _getMouseCoords(source);
57565           p1 = t0.invert(p02);
57566           k22 = t0.k * source._scale;
57567           k22 = clamp2(k22, kMin, kMax);
57568           x22 = p02[0] - p1[0] * k22;
57569           y22 = p02[1] - p1[1] * k22;
57570         } else if (source.ctrlKey && !isInteger(dY)) {
57571           dY *= 6;
57572           t0 = _isTransformed ? _transformLast : _transformStart;
57573           p02 = _getMouseCoords(source);
57574           p1 = t0.invert(p02);
57575           k22 = t0.k * Math.pow(2, -dY / 500);
57576           k22 = clamp2(k22, kMin, kMax);
57577           x22 = p02[0] - p1[0] * k22;
57578           y22 = p02[1] - p1[1] * k22;
57579         } else if ((source.altKey || source.shiftKey) && isInteger(dY)) {
57580           t0 = _isTransformed ? _transformLast : _transformStart;
57581           p02 = _getMouseCoords(source);
57582           p1 = t0.invert(p02);
57583           k22 = t0.k * Math.pow(2, -dY / 500);
57584           k22 = clamp2(k22, kMin, kMax);
57585           x22 = p02[0] - p1[0] * k22;
57586           y22 = p02[1] - p1[1] * k22;
57587         } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) {
57588           p1 = projection2.translate();
57589           x22 = p1[0] - dX;
57590           y22 = p1[1] - dY;
57591           k22 = projection2.scale();
57592           k22 = clamp2(k22, kMin, kMax);
57593         }
57594         if (x22 !== x2 || y22 !== y2 || k22 !== k2) {
57595           x2 = x22;
57596           y2 = y22;
57597           k2 = k22;
57598           eventTransform = identity2.translate(x22, y22).scale(k22);
57599           if (_zoomerPanner._transform) {
57600             _zoomerPanner._transform(eventTransform);
57601           } else {
57602             _selection.node().__zoom = eventTransform;
57603           }
57604         }
57605       }
57606       if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) {
57607         return;
57608       }
57609       if (geoScaleToZoom(k2, TILESIZE) < _minzoom) {
57610         surface.interrupt();
57611         dispatch14.call("hitMinZoom", this, map2);
57612         setCenterZoom(map2.center(), context.minEditableZoom(), 0, true);
57613         scheduleRedraw();
57614         dispatch14.call("move", this, map2);
57615         return;
57616       }
57617       projection2.transform(eventTransform);
57618       var withinEditableZoom = map2.withinEditableZoom();
57619       if (_lastWithinEditableZoom !== withinEditableZoom) {
57620         if (_lastWithinEditableZoom !== void 0) {
57621           dispatch14.call("crossEditableZoom", this, withinEditableZoom);
57622         }
57623         _lastWithinEditableZoom = withinEditableZoom;
57624       }
57625       var scale = k2 / _transformStart.k;
57626       var tX = (x2 / scale - _transformStart.x) * scale;
57627       var tY = (y2 / scale - _transformStart.y) * scale;
57628       if (context.inIntro()) {
57629         curtainProjection.transform({
57630           x: x2 - tX,
57631           y: y2 - tY,
57632           k: k2
57633         });
57634       }
57635       if (source) {
57636         _lastPointerEvent = event;
57637       }
57638       _isTransformed = true;
57639       _transformLast = eventTransform;
57640       utilSetTransform(supersurface, tX, tY, scale);
57641       scheduleRedraw();
57642       dispatch14.call("move", this, map2);
57643       function isInteger(val) {
57644         return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
57645       }
57646     }
57647     function resetTransform() {
57648       if (!_isTransformed)
57649         return false;
57650       utilSetTransform(supersurface, 0, 0);
57651       _isTransformed = false;
57652       if (context.inIntro()) {
57653         curtainProjection.transform(projection2.transform());
57654       }
57655       return true;
57656     }
57657     function redraw(difference2, extent) {
57658       if (surface.empty() || !_redrawEnabled)
57659         return;
57660       if (resetTransform()) {
57661         difference2 = extent = void 0;
57662       }
57663       var zoom = map2.zoom();
57664       var z2 = String(~~zoom);
57665       if (surface.attr("data-zoom") !== z2) {
57666         surface.attr("data-zoom", z2);
57667       }
57668       var lat = map2.center()[1];
57669       var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true);
57670       surface.classed("low-zoom", zoom <= lowzoom(lat));
57671       if (!difference2) {
57672         supersurface.call(context.background());
57673         wrapper.call(drawLayers);
57674       }
57675       if (map2.editableDataEnabled() || map2.isInWideSelection()) {
57676         context.loadTiles(projection2);
57677         drawEditable(difference2, extent);
57678       } else {
57679         editOff();
57680       }
57681       _transformStart = projection2.transform();
57682       return map2;
57683     }
57684     var immediateRedraw = function(difference2, extent) {
57685       if (!difference2 && !extent)
57686         cancelPendingRedraw();
57687       redraw(difference2, extent);
57688     };
57689     map2.lastPointerEvent = function() {
57690       return _lastPointerEvent;
57691     };
57692     map2.mouse = function(d3_event) {
57693       var event = d3_event || _lastPointerEvent;
57694       if (event) {
57695         var s2;
57696         while (s2 = event.sourceEvent) {
57697           event = s2;
57698         }
57699         return _getMouseCoords(event);
57700       }
57701       return null;
57702     };
57703     map2.mouseCoordinates = function() {
57704       var coord2 = map2.mouse() || pxCenter();
57705       return projection2.invert(coord2);
57706     };
57707     map2.dblclickZoomEnable = function(val) {
57708       if (!arguments.length)
57709         return _dblClickZoomEnabled;
57710       _dblClickZoomEnabled = val;
57711       return map2;
57712     };
57713     map2.redrawEnable = function(val) {
57714       if (!arguments.length)
57715         return _redrawEnabled;
57716       _redrawEnabled = val;
57717       return map2;
57718     };
57719     map2.isTransformed = function() {
57720       return _isTransformed;
57721     };
57722     function setTransform(t2, duration, force) {
57723       var t3 = projection2.transform();
57724       if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y)
57725         return false;
57726       if (duration) {
57727         _selection.transition().duration(duration).on("start", function() {
57728           map2.startEase();
57729         }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k));
57730       } else {
57731         projection2.transform(t2);
57732         _transformStart = t2;
57733         _selection.call(_zoomerPanner.transform, _transformStart);
57734       }
57735       return true;
57736     }
57737     function setCenterZoom(loc2, z2, duration, force) {
57738       var c2 = map2.center();
57739       var z3 = map2.zoom();
57740       if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force)
57741         return false;
57742       var proj = geoRawMercator().transform(projection2.transform());
57743       var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax);
57744       proj.scale(k2);
57745       var t2 = proj.translate();
57746       var point2 = proj(loc2);
57747       var center = pxCenter();
57748       t2[0] += center[0] - point2[0];
57749       t2[1] += center[1] - point2[1];
57750       return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force);
57751     }
57752     map2.pan = function(delta, duration) {
57753       var t2 = projection2.translate();
57754       var k2 = projection2.scale();
57755       t2[0] += delta[0];
57756       t2[1] += delta[1];
57757       if (duration) {
57758         _selection.transition().duration(duration).on("start", function() {
57759           map2.startEase();
57760         }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2));
57761       } else {
57762         projection2.translate(t2);
57763         _transformStart = projection2.transform();
57764         _selection.call(_zoomerPanner.transform, _transformStart);
57765         dispatch14.call("move", this, map2);
57766         immediateRedraw();
57767       }
57768       return map2;
57769     };
57770     map2.dimensions = function(val) {
57771       if (!arguments.length)
57772         return _dimensions;
57773       _dimensions = val;
57774       drawLayers.dimensions(_dimensions);
57775       context.background().dimensions(_dimensions);
57776       projection2.clipExtent([[0, 0], _dimensions]);
57777       _getMouseCoords = utilFastMouse(supersurface.node());
57778       scheduleRedraw();
57779       return map2;
57780     };
57781     function zoomIn(delta) {
57782       setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true);
57783     }
57784     function zoomOut(delta) {
57785       setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true);
57786     }
57787     map2.zoomIn = function() {
57788       zoomIn(1);
57789     };
57790     map2.zoomInFurther = function() {
57791       zoomIn(4);
57792     };
57793     map2.canZoomIn = function() {
57794       return map2.zoom() < maxZoom;
57795     };
57796     map2.zoomOut = function() {
57797       zoomOut(1);
57798     };
57799     map2.zoomOutFurther = function() {
57800       zoomOut(4);
57801     };
57802     map2.canZoomOut = function() {
57803       return map2.zoom() > minZoom2;
57804     };
57805     map2.center = function(loc2) {
57806       if (!arguments.length) {
57807         return projection2.invert(pxCenter());
57808       }
57809       if (setCenterZoom(loc2, map2.zoom())) {
57810         dispatch14.call("move", this, map2);
57811       }
57812       scheduleRedraw();
57813       return map2;
57814     };
57815     map2.unobscuredCenterZoomEase = function(loc, zoom) {
57816       var offset = map2.unobscuredOffsetPx();
57817       var proj = geoRawMercator().transform(projection2.transform());
57818       proj.scale(geoZoomToScale(zoom, TILESIZE));
57819       var locPx = proj(loc);
57820       var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
57821       var offsetLoc = proj.invert(offsetLocPx);
57822       map2.centerZoomEase(offsetLoc, zoom);
57823     };
57824     map2.unobscuredOffsetPx = function() {
57825       var openPane = context.container().select(".map-panes .map-pane.shown");
57826       if (!openPane.empty()) {
57827         return [openPane.node().offsetWidth / 2, 0];
57828       }
57829       return [0, 0];
57830     };
57831     map2.zoom = function(z2) {
57832       if (!arguments.length) {
57833         return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0);
57834       }
57835       if (z2 < _minzoom) {
57836         surface.interrupt();
57837         dispatch14.call("hitMinZoom", this, map2);
57838         z2 = context.minEditableZoom();
57839       }
57840       if (setCenterZoom(map2.center(), z2)) {
57841         dispatch14.call("move", this, map2);
57842       }
57843       scheduleRedraw();
57844       return map2;
57845     };
57846     map2.centerZoom = function(loc2, z2) {
57847       if (setCenterZoom(loc2, z2)) {
57848         dispatch14.call("move", this, map2);
57849       }
57850       scheduleRedraw();
57851       return map2;
57852     };
57853     map2.zoomTo = function(entity) {
57854       var extent = entity.extent(context.graph());
57855       if (!isFinite(extent.area()))
57856         return map2;
57857       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57858       return map2.centerZoom(extent.center(), z2);
57859     };
57860     map2.centerEase = function(loc2, duration) {
57861       duration = duration || 250;
57862       setCenterZoom(loc2, map2.zoom(), duration);
57863       return map2;
57864     };
57865     map2.zoomEase = function(z2, duration) {
57866       duration = duration || 250;
57867       setCenterZoom(map2.center(), z2, duration, false);
57868       return map2;
57869     };
57870     map2.centerZoomEase = function(loc2, z2, duration) {
57871       duration = duration || 250;
57872       setCenterZoom(loc2, z2, duration, false);
57873       return map2;
57874     };
57875     map2.transformEase = function(t2, duration) {
57876       duration = duration || 250;
57877       setTransform(
57878         t2,
57879         duration,
57880         false
57881         /* don't force */
57882       );
57883       return map2;
57884     };
57885     map2.zoomToEase = function(obj, duration) {
57886       var extent;
57887       if (Array.isArray(obj)) {
57888         obj.forEach(function(entity) {
57889           var entityExtent = entity.extent(context.graph());
57890           if (!extent) {
57891             extent = entityExtent;
57892           } else {
57893             extent = extent.extend(entityExtent);
57894           }
57895         });
57896       } else {
57897         extent = obj.extent(context.graph());
57898       }
57899       if (!isFinite(extent.area()))
57900         return map2;
57901       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57902       return map2.centerZoomEase(extent.center(), z2, duration);
57903     };
57904     map2.startEase = function() {
57905       utilBindOnce(surface, _pointerPrefix + "down.ease", function() {
57906         map2.cancelEase();
57907       });
57908       return map2;
57909     };
57910     map2.cancelEase = function() {
57911       _selection.interrupt();
57912       return map2;
57913     };
57914     map2.extent = function(val) {
57915       if (!arguments.length) {
57916         return new geoExtent(
57917           projection2.invert([0, _dimensions[1]]),
57918           projection2.invert([_dimensions[0], 0])
57919         );
57920       } else {
57921         var extent = geoExtent(val);
57922         map2.centerZoom(extent.center(), map2.extentZoom(extent));
57923       }
57924     };
57925     map2.trimmedExtent = function(val) {
57926       if (!arguments.length) {
57927         var headerY = 71;
57928         var footerY = 30;
57929         var pad2 = 10;
57930         return new geoExtent(
57931           projection2.invert([pad2, _dimensions[1] - footerY - pad2]),
57932           projection2.invert([_dimensions[0] - pad2, headerY + pad2])
57933         );
57934       } else {
57935         var extent = geoExtent(val);
57936         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
57937       }
57938     };
57939     function calcExtentZoom(extent, dim) {
57940       var tl = projection2([extent[0][0], extent[1][1]]);
57941       var br2 = projection2([extent[1][0], extent[0][1]]);
57942       var hFactor = (br2[0] - tl[0]) / dim[0];
57943       var vFactor = (br2[1] - tl[1]) / dim[1];
57944       var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
57945       var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
57946       var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff);
57947       return newZoom;
57948     }
57949     map2.extentZoom = function(val) {
57950       return calcExtentZoom(geoExtent(val), _dimensions);
57951     };
57952     map2.trimmedExtentZoom = function(val) {
57953       var trimY = 120;
57954       var trimX = 40;
57955       var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY];
57956       return calcExtentZoom(geoExtent(val), trimmed);
57957     };
57958     map2.withinEditableZoom = function() {
57959       return map2.zoom() >= context.minEditableZoom();
57960     };
57961     map2.isInWideSelection = function() {
57962       return !map2.withinEditableZoom() && context.selectedIDs().length;
57963     };
57964     map2.editableDataEnabled = function(skipZoomCheck) {
57965       var layer = context.layers().layer("osm");
57966       if (!layer || !layer.enabled())
57967         return false;
57968       return skipZoomCheck || map2.withinEditableZoom();
57969     };
57970     map2.notesEditable = function() {
57971       var layer = context.layers().layer("notes");
57972       if (!layer || !layer.enabled())
57973         return false;
57974       return map2.withinEditableZoom();
57975     };
57976     map2.minzoom = function(val) {
57977       if (!arguments.length)
57978         return _minzoom;
57979       _minzoom = val;
57980       return map2;
57981     };
57982     map2.toggleHighlightEdited = function() {
57983       surface.classed("highlight-edited", !surface.classed("highlight-edited"));
57984       map2.pan([0, 0]);
57985       dispatch14.call("changeHighlighting", this);
57986     };
57987     map2.areaFillOptions = ["wireframe", "partial", "full"];
57988     map2.activeAreaFill = function(val) {
57989       if (!arguments.length)
57990         return corePreferences("area-fill") || "partial";
57991       corePreferences("area-fill", val);
57992       if (val !== "wireframe") {
57993         corePreferences("area-fill-toggle", val);
57994       }
57995       updateAreaFill();
57996       map2.pan([0, 0]);
57997       dispatch14.call("changeAreaFill", this);
57998       return map2;
57999     };
58000     map2.toggleWireframe = function() {
58001       var activeFill = map2.activeAreaFill();
58002       if (activeFill === "wireframe") {
58003         activeFill = corePreferences("area-fill-toggle") || "partial";
58004       } else {
58005         activeFill = "wireframe";
58006       }
58007       map2.activeAreaFill(activeFill);
58008     };
58009     function updateAreaFill() {
58010       var activeFill = map2.activeAreaFill();
58011       map2.areaFillOptions.forEach(function(opt) {
58012         surface.classed("fill-" + opt, Boolean(opt === activeFill));
58013       });
58014     }
58015     map2.layers = () => drawLayers;
58016     map2.doubleUpHandler = function() {
58017       return _doubleUpHandler;
58018     };
58019     return utilRebind(map2, dispatch14, "on");
58020   }
58021
58022   // modules/renderer/photos.js
58023   function rendererPhotos(context) {
58024     var dispatch14 = dispatch_default("change");
58025     var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder"];
58026     var _allPhotoTypes = ["flat", "panoramic"];
58027     var _shownPhotoTypes = _allPhotoTypes.slice();
58028     var _dateFilters = ["fromDate", "toDate"];
58029     var _fromDate;
58030     var _toDate;
58031     var _usernames;
58032     function photos() {
58033     }
58034     function updateStorage() {
58035       if (window.mocha)
58036         return;
58037       var hash = utilStringQs(window.location.hash);
58038       var enabled = context.layers().all().filter(function(d2) {
58039         return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled();
58040       }).map(function(d2) {
58041         return d2.id;
58042       });
58043       if (enabled.length) {
58044         hash.photo_overlay = enabled.join(",");
58045       } else {
58046         delete hash.photo_overlay;
58047       }
58048       window.location.replace("#" + utilQsString(hash, true));
58049     }
58050     photos.overlayLayerIDs = function() {
58051       return _layerIDs;
58052     };
58053     photos.allPhotoTypes = function() {
58054       return _allPhotoTypes;
58055     };
58056     photos.dateFilters = function() {
58057       return _dateFilters;
58058     };
58059     photos.dateFilterValue = function(val) {
58060       return val === _dateFilters[0] ? _fromDate : _toDate;
58061     };
58062     photos.setDateFilter = function(type2, val, updateUrl) {
58063       var date = val && new Date(val);
58064       if (date && !isNaN(date)) {
58065         val = date.toISOString().slice(0, 10);
58066       } else {
58067         val = null;
58068       }
58069       if (type2 === _dateFilters[0]) {
58070         _fromDate = val;
58071         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58072           _toDate = _fromDate;
58073         }
58074       }
58075       if (type2 === _dateFilters[1]) {
58076         _toDate = val;
58077         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58078           _fromDate = _toDate;
58079         }
58080       }
58081       dispatch14.call("change", this);
58082       if (updateUrl) {
58083         var rangeString;
58084         if (_fromDate || _toDate) {
58085           rangeString = (_fromDate || "") + "_" + (_toDate || "");
58086         }
58087         setUrlFilterValue("photo_dates", rangeString);
58088       }
58089     };
58090     photos.setUsernameFilter = function(val, updateUrl) {
58091       if (val && typeof val === "string")
58092         val = val.replace(/;/g, ",").split(",");
58093       if (val) {
58094         val = val.map((d2) => d2.trim()).filter(Boolean);
58095         if (!val.length) {
58096           val = null;
58097         }
58098       }
58099       _usernames = val;
58100       dispatch14.call("change", this);
58101       if (updateUrl) {
58102         var hashString;
58103         if (_usernames) {
58104           hashString = _usernames.join(",");
58105         }
58106         setUrlFilterValue("photo_username", hashString);
58107       }
58108     };
58109     function setUrlFilterValue(property, val) {
58110       if (!window.mocha) {
58111         var hash = utilStringQs(window.location.hash);
58112         if (val) {
58113           if (hash[property] === val)
58114             return;
58115           hash[property] = val;
58116         } else {
58117           if (!(property in hash))
58118             return;
58119           delete hash[property];
58120         }
58121         window.location.replace("#" + utilQsString(hash, true));
58122       }
58123     }
58124     function showsLayer(id2) {
58125       var layer = context.layers().layer(id2);
58126       return layer && layer.supported() && layer.enabled();
58127     }
58128     photos.shouldFilterByDate = function() {
58129       return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder");
58130     };
58131     photos.shouldFilterByPhotoType = function() {
58132       return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder");
58133     };
58134     photos.shouldFilterByUsername = function() {
58135       return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside");
58136     };
58137     photos.showsPhotoType = function(val) {
58138       if (!photos.shouldFilterByPhotoType())
58139         return true;
58140       return _shownPhotoTypes.indexOf(val) !== -1;
58141     };
58142     photos.showsFlat = function() {
58143       return photos.showsPhotoType("flat");
58144     };
58145     photos.showsPanoramic = function() {
58146       return photos.showsPhotoType("panoramic");
58147     };
58148     photos.fromDate = function() {
58149       return _fromDate;
58150     };
58151     photos.toDate = function() {
58152       return _toDate;
58153     };
58154     photos.togglePhotoType = function(val) {
58155       var index = _shownPhotoTypes.indexOf(val);
58156       if (index !== -1) {
58157         _shownPhotoTypes.splice(index, 1);
58158       } else {
58159         _shownPhotoTypes.push(val);
58160       }
58161       dispatch14.call("change", this);
58162       return photos;
58163     };
58164     photos.usernames = function() {
58165       return _usernames;
58166     };
58167     photos.init = function() {
58168       var hash = utilStringQs(window.location.hash);
58169       if (hash.photo_dates) {
58170         var parts = /^(.*)[–_](.*)$/g.exec(hash.photo_dates.trim());
58171         this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false);
58172         this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false);
58173       }
58174       if (hash.photo_username) {
58175         this.setUsernameFilter(hash.photo_username, false);
58176       }
58177       if (hash.photo_overlay) {
58178         var hashOverlayIDs = hash.photo_overlay.replace(/;/g, ",").split(",");
58179         hashOverlayIDs.forEach(function(id2) {
58180           if (id2 === "openstreetcam")
58181             id2 = "kartaview";
58182           var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2);
58183           if (layer2 && !layer2.enabled())
58184             layer2.enabled(true);
58185         });
58186       }
58187       if (hash.photo) {
58188         var photoIds = hash.photo.replace(/;/g, ",").split(",");
58189         var photoId = photoIds.length && photoIds[0].trim();
58190         var results = /(.*)\/(.*)/g.exec(photoId);
58191         if (results && results.length >= 3) {
58192           var serviceId = results[1];
58193           if (serviceId === "openstreetcam")
58194             serviceId = "kartaview";
58195           var photoKey = results[2];
58196           var service = services[serviceId];
58197           if (service && service.ensureViewerLoaded) {
58198             var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId);
58199             if (layer && !layer.enabled())
58200               layer.enabled(true);
58201             var baselineTime = Date.now();
58202             service.on("loadedImages.rendererPhotos", function() {
58203               if (Date.now() - baselineTime > 45e3) {
58204                 service.on("loadedImages.rendererPhotos", null);
58205                 return;
58206               }
58207               if (!service.cachedImage(photoKey))
58208                 return;
58209               service.on("loadedImages.rendererPhotos", null);
58210               service.ensureViewerLoaded(context).then(function() {
58211                 service.selectImage(context, photoKey).showViewer(context);
58212               });
58213             });
58214           }
58215         }
58216       }
58217       context.layers().on("change.rendererPhotos", updateStorage);
58218     };
58219     return utilRebind(photos, dispatch14, "on");
58220   }
58221
58222   // modules/ui/account.js
58223   function uiAccount(context) {
58224     const osm = context.connection();
58225     function updateUserDetails(selection2) {
58226       if (!osm)
58227         return;
58228       if (!osm.authenticated()) {
58229         render(selection2, null);
58230       } else {
58231         osm.userDetails((err, user) => render(selection2, user));
58232       }
58233     }
58234     function render(selection2, user) {
58235       let userInfo = selection2.select(".userInfo");
58236       let loginLogout = selection2.select(".loginLogout");
58237       if (user) {
58238         userInfo.html("").classed("hide", false);
58239         let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
58240         if (user.image_url) {
58241           userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url);
58242         } else {
58243           userLink.call(svgIcon("#iD-icon-avatar", "pre-text light"));
58244         }
58245         userLink.append("span").attr("class", "label").text(user.display_name);
58246         loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => {
58247           e3.preventDefault();
58248           osm.logout();
58249           tryLogout();
58250         });
58251       } else {
58252         userInfo.html("").classed("hide", true);
58253         loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => {
58254           e3.preventDefault();
58255           osm.authenticate();
58256         });
58257       }
58258     }
58259     function tryLogout() {
58260       if (!osm)
58261         return;
58262       const url = osm.getUrlRoot() + "/logout?referer=%2Flogin";
58263       const w2 = 600;
58264       const h2 = 550;
58265       const settings = [
58266         ["width", w2],
58267         ["height", h2],
58268         ["left", window.screen.width / 2 - w2 / 2],
58269         ["top", window.screen.height / 2 - h2 / 2]
58270       ].map((x2) => x2.join("=")).join(",");
58271       window.open(url, "_blank", settings);
58272     }
58273     return function(selection2) {
58274       if (!osm)
58275         return;
58276       selection2.append("li").attr("class", "userInfo").classed("hide", true);
58277       selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#");
58278       osm.on("change.account", () => updateUserDetails(selection2));
58279       updateUserDetails(selection2);
58280     };
58281   }
58282
58283   // modules/ui/attribution.js
58284   function uiAttribution(context) {
58285     let _selection = select_default2(null);
58286     function render(selection2, data, klass) {
58287       let div = selection2.selectAll(".".concat(klass)).data([0]);
58288       div = div.enter().append("div").attr("class", klass).merge(div);
58289       let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id);
58290       attributions.exit().remove();
58291       attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => {
58292         let attribution = select_default2(nodes[i3]);
58293         if (d2.terms_html) {
58294           attribution.html(d2.terms_html);
58295           return;
58296         }
58297         if (d2.terms_url) {
58298           attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank");
58299         }
58300         const sourceID = d2.id.replace(/\./g, "<TX_DOT>");
58301         const terms_text = _t(
58302           "imagery.".concat(sourceID, ".attribution.text"),
58303           { default: d2.terms_text || d2.id || d2.name() }
58304         );
58305         if (d2.icon && !d2.overlay) {
58306           attribution.append("img").attr("class", "source-image").attr("src", d2.icon);
58307         }
58308         attribution.append("span").attr("class", "attribution-text").text(terms_text);
58309       }).merge(attributions);
58310       let copyright = attributions.selectAll(".copyright-notice").data((d2) => {
58311         let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent());
58312         return notice ? [notice] : [];
58313       });
58314       copyright.exit().remove();
58315       copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright);
58316       copyright.text(String);
58317     }
58318     function update() {
58319       let baselayer = context.background().baseLayerSource();
58320       _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution");
58321       const z2 = context.map().zoom();
58322       let overlays = context.background().overlayLayerSources() || [];
58323       _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution");
58324     }
58325     return function(selection2) {
58326       _selection = selection2;
58327       context.background().on("change.attribution", update);
58328       context.map().on("move.attribution", throttle_default(update, 400, { leading: false }));
58329       update();
58330     };
58331   }
58332
58333   // modules/ui/contributors.js
58334   function uiContributors(context) {
58335     var osm = context.connection(), debouncedUpdate = debounce_default(function() {
58336       update();
58337     }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null);
58338     function update() {
58339       if (!osm)
58340         return;
58341       var users = {}, entities = context.history().intersects(context.map().extent());
58342       entities.forEach(function(entity) {
58343         if (entity && entity.user)
58344           users[entity.user] = true;
58345       });
58346       var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit);
58347       wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light"));
58348       var userList = select_default2(document.createElement("span"));
58349       userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) {
58350         return osm.userURL(d2);
58351       }).attr("target", "_blank").text(String);
58352       if (u2.length > limit) {
58353         var count = select_default2(document.createElement("span"));
58354         var othersNum = u2.length - limit + 1;
58355         count.append("a").attr("target", "_blank").attr("href", function() {
58356           return osm.changesetsURL(context.map().center(), context.map().zoom());
58357         }).text(othersNum);
58358         wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } }));
58359       } else {
58360         wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } }));
58361       }
58362       if (!u2.length) {
58363         hidden = true;
58364         wrap2.transition().style("opacity", 0);
58365       } else if (hidden) {
58366         wrap2.transition().style("opacity", 1);
58367       }
58368     }
58369     return function(selection2) {
58370       if (!osm)
58371         return;
58372       wrap2 = selection2;
58373       update();
58374       osm.on("loaded.contributors", debouncedUpdate);
58375       context.map().on("move.contributors", debouncedUpdate);
58376     };
58377   }
58378
58379   // modules/ui/popover.js
58380   var _popoverID = 0;
58381   function uiPopover(klass) {
58382     var _id = _popoverID++;
58383     var _anchorSelection = select_default2(null);
58384     var popover = function(selection2) {
58385       _anchorSelection = selection2;
58386       selection2.each(setup);
58387     };
58388     var _animation = utilFunctor(false);
58389     var _placement = utilFunctor("top");
58390     var _alignment = utilFunctor("center");
58391     var _scrollContainer = utilFunctor(select_default2(null));
58392     var _content;
58393     var _displayType = utilFunctor("");
58394     var _hasArrow = utilFunctor(true);
58395     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
58396     popover.displayType = function(val) {
58397       if (arguments.length) {
58398         _displayType = utilFunctor(val);
58399         return popover;
58400       } else {
58401         return _displayType;
58402       }
58403     };
58404     popover.hasArrow = function(val) {
58405       if (arguments.length) {
58406         _hasArrow = utilFunctor(val);
58407         return popover;
58408       } else {
58409         return _hasArrow;
58410       }
58411     };
58412     popover.placement = function(val) {
58413       if (arguments.length) {
58414         _placement = utilFunctor(val);
58415         return popover;
58416       } else {
58417         return _placement;
58418       }
58419     };
58420     popover.alignment = function(val) {
58421       if (arguments.length) {
58422         _alignment = utilFunctor(val);
58423         return popover;
58424       } else {
58425         return _alignment;
58426       }
58427     };
58428     popover.scrollContainer = function(val) {
58429       if (arguments.length) {
58430         _scrollContainer = utilFunctor(val);
58431         return popover;
58432       } else {
58433         return _scrollContainer;
58434       }
58435     };
58436     popover.content = function(val) {
58437       if (arguments.length) {
58438         _content = val;
58439         return popover;
58440       } else {
58441         return _content;
58442       }
58443     };
58444     popover.isShown = function() {
58445       var popoverSelection = _anchorSelection.select(".popover-" + _id);
58446       return !popoverSelection.empty() && popoverSelection.classed("in");
58447     };
58448     popover.show = function() {
58449       _anchorSelection.each(show);
58450     };
58451     popover.updateContent = function() {
58452       _anchorSelection.each(updateContent);
58453     };
58454     popover.hide = function() {
58455       _anchorSelection.each(hide);
58456     };
58457     popover.toggle = function() {
58458       _anchorSelection.each(toggle);
58459     };
58460     popover.destroy = function(selection2, selector) {
58461       selector = selector || ".popover-" + _id;
58462       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() {
58463         return this.getAttribute("data-original-title") || this.getAttribute("title");
58464       }).attr("data-original-title", null).selectAll(selector).remove();
58465     };
58466     popover.destroyAny = function(selection2) {
58467       selection2.call(popover.destroy, ".popover");
58468     };
58469     function setup() {
58470       var anchor = select_default2(this);
58471       var animate = _animation.apply(this, arguments);
58472       var popoverSelection = anchor.selectAll(".popover-" + _id).data([0]);
58473       var enter = popoverSelection.enter().append("div").attr("class", "popover popover-" + _id + " " + (klass ? klass : "")).classed("arrowed", _hasArrow.apply(this, arguments));
58474       enter.append("div").attr("class", "popover-arrow");
58475       enter.append("div").attr("class", "popover-inner");
58476       popoverSelection = enter.merge(popoverSelection);
58477       if (animate) {
58478         popoverSelection.classed("fade", true);
58479       }
58480       var display = _displayType.apply(this, arguments);
58481       if (display === "hover") {
58482         var _lastNonMouseEnterTime;
58483         anchor.on(_pointerPrefix + "enter.popover", function(d3_event) {
58484           if (d3_event.pointerType) {
58485             if (d3_event.pointerType !== "mouse") {
58486               _lastNonMouseEnterTime = d3_event.timeStamp;
58487               return;
58488             } else if (_lastNonMouseEnterTime && d3_event.timeStamp - _lastNonMouseEnterTime < 1500) {
58489               return;
58490             }
58491           }
58492           if (d3_event.buttons !== 0)
58493             return;
58494           show.apply(this, arguments);
58495         }).on(_pointerPrefix + "leave.popover", function() {
58496           hide.apply(this, arguments);
58497         }).on("focus.popover", function() {
58498           show.apply(this, arguments);
58499         }).on("blur.popover", function() {
58500           hide.apply(this, arguments);
58501         });
58502       } else if (display === "clickFocus") {
58503         anchor.on(_pointerPrefix + "down.popover", function(d3_event) {
58504           d3_event.preventDefault();
58505           d3_event.stopPropagation();
58506         }).on(_pointerPrefix + "up.popover", function(d3_event) {
58507           d3_event.preventDefault();
58508           d3_event.stopPropagation();
58509         }).on("click.popover", toggle);
58510         popoverSelection.attr("tabindex", 0).on("blur.popover", function() {
58511           anchor.each(function() {
58512             hide.apply(this, arguments);
58513           });
58514         });
58515       }
58516     }
58517     function show() {
58518       var anchor = select_default2(this);
58519       var popoverSelection = anchor.selectAll(".popover-" + _id);
58520       if (popoverSelection.empty()) {
58521         anchor.call(popover.destroy);
58522         anchor.each(setup);
58523         popoverSelection = anchor.selectAll(".popover-" + _id);
58524       }
58525       popoverSelection.classed("in", true);
58526       var displayType = _displayType.apply(this, arguments);
58527       if (displayType === "clickFocus") {
58528         anchor.classed("active", true);
58529         popoverSelection.node().focus();
58530       }
58531       anchor.each(updateContent);
58532     }
58533     function updateContent() {
58534       var anchor = select_default2(this);
58535       if (_content) {
58536         anchor.selectAll(".popover-" + _id + " > .popover-inner").call(_content.apply(this, arguments));
58537       }
58538       updatePosition.apply(this, arguments);
58539       updatePosition.apply(this, arguments);
58540       updatePosition.apply(this, arguments);
58541     }
58542     function updatePosition() {
58543       var anchor = select_default2(this);
58544       var popoverSelection = anchor.selectAll(".popover-" + _id);
58545       var scrollContainer = _scrollContainer && _scrollContainer.apply(this, arguments);
58546       var scrollNode = scrollContainer && !scrollContainer.empty() && scrollContainer.node();
58547       var scrollLeft = scrollNode ? scrollNode.scrollLeft : 0;
58548       var scrollTop = scrollNode ? scrollNode.scrollTop : 0;
58549       var placement = _placement.apply(this, arguments);
58550       popoverSelection.classed("left", false).classed("right", false).classed("top", false).classed("bottom", false).classed(placement, true);
58551       var alignment = _alignment.apply(this, arguments);
58552       var alignFactor = 0.5;
58553       if (alignment === "leading") {
58554         alignFactor = 0;
58555       } else if (alignment === "trailing") {
58556         alignFactor = 1;
58557       }
58558       var anchorFrame = getFrame(anchor.node());
58559       var popoverFrame = getFrame(popoverSelection.node());
58560       var position;
58561       switch (placement) {
58562         case "top":
58563           position = {
58564             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58565             y: anchorFrame.y - popoverFrame.h
58566           };
58567           break;
58568         case "bottom":
58569           position = {
58570             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58571             y: anchorFrame.y + anchorFrame.h
58572           };
58573           break;
58574         case "left":
58575           position = {
58576             x: anchorFrame.x - popoverFrame.w,
58577             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58578           };
58579           break;
58580         case "right":
58581           position = {
58582             x: anchorFrame.x + anchorFrame.w,
58583             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58584           };
58585           break;
58586       }
58587       if (position) {
58588         if (scrollNode && (placement === "top" || placement === "bottom")) {
58589           var initialPosX = position.x;
58590           if (position.x + popoverFrame.w > scrollNode.offsetWidth - 10) {
58591             position.x = scrollNode.offsetWidth - 10 - popoverFrame.w;
58592           } else if (position.x < 10) {
58593             position.x = 10;
58594           }
58595           var arrow = anchor.selectAll(".popover-" + _id + " > .popover-arrow");
58596           var arrowPosX = Math.min(Math.max(popoverFrame.w / 2 - (position.x - initialPosX), 10), popoverFrame.w - 10);
58597           arrow.style("left", ~~arrowPosX + "px");
58598         }
58599         popoverSelection.style("left", ~~position.x + "px").style("top", ~~position.y + "px");
58600       } else {
58601         popoverSelection.style("left", null).style("top", null);
58602       }
58603       function getFrame(node) {
58604         var positionStyle = select_default2(node).style("position");
58605         if (positionStyle === "absolute" || positionStyle === "static") {
58606           return {
58607             x: node.offsetLeft - scrollLeft,
58608             y: node.offsetTop - scrollTop,
58609             w: node.offsetWidth,
58610             h: node.offsetHeight
58611           };
58612         } else {
58613           return {
58614             x: 0,
58615             y: 0,
58616             w: node.offsetWidth,
58617             h: node.offsetHeight
58618           };
58619         }
58620       }
58621     }
58622     function hide() {
58623       var anchor = select_default2(this);
58624       if (_displayType.apply(this, arguments) === "clickFocus") {
58625         anchor.classed("active", false);
58626       }
58627       anchor.selectAll(".popover-" + _id).classed("in", false);
58628     }
58629     function toggle() {
58630       if (select_default2(this).select(".popover-" + _id).classed("in")) {
58631         hide.apply(this, arguments);
58632       } else {
58633         show.apply(this, arguments);
58634       }
58635     }
58636     return popover;
58637   }
58638
58639   // modules/ui/tooltip.js
58640   function uiTooltip(klass) {
58641     var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover");
58642     var _title = function() {
58643       var title = this.getAttribute("data-original-title");
58644       if (title) {
58645         return title;
58646       } else {
58647         title = this.getAttribute("title");
58648         this.removeAttribute("title");
58649         this.setAttribute("data-original-title", title);
58650       }
58651       return title;
58652     };
58653     var _heading = utilFunctor(null);
58654     var _keys = utilFunctor(null);
58655     tooltip.title = function(val) {
58656       if (!arguments.length)
58657         return _title;
58658       _title = utilFunctor(val);
58659       return tooltip;
58660     };
58661     tooltip.heading = function(val) {
58662       if (!arguments.length)
58663         return _heading;
58664       _heading = utilFunctor(val);
58665       return tooltip;
58666     };
58667     tooltip.keys = function(val) {
58668       if (!arguments.length)
58669         return _keys;
58670       _keys = utilFunctor(val);
58671       return tooltip;
58672     };
58673     tooltip.content(function() {
58674       var heading2 = _heading.apply(this, arguments);
58675       var text = _title.apply(this, arguments);
58676       var keys2 = _keys.apply(this, arguments);
58677       var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2);
58678       var textCallback = typeof text === "function" ? text : (s2) => s2.text(text);
58679       return function(selection2) {
58680         var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []);
58681         headingSelect.exit().remove();
58682         headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback);
58683         var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []);
58684         textSelect.exit().remove();
58685         textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback);
58686         var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []);
58687         keyhintWrap.exit().remove();
58688         var keyhintWrapEnter = keyhintWrap.enter().append("div").attr("class", "keyhint-wrap");
58689         keyhintWrapEnter.append("span").call(_t.append("tooltip_keyhint"));
58690         keyhintWrap = keyhintWrapEnter.merge(keyhintWrap);
58691         keyhintWrap.selectAll("kbd.shortcut").data(keys2 && keys2.length ? keys2 : []).enter().append("kbd").attr("class", "shortcut").text(function(d2) {
58692           return d2;
58693         });
58694       };
58695     });
58696     return tooltip;
58697   }
58698
58699   // modules/ui/edit_menu.js
58700   function uiEditMenu(context) {
58701     var dispatch14 = dispatch_default("toggled");
58702     var _menu = select_default2(null);
58703     var _operations = [];
58704     var _anchorLoc = [0, 0];
58705     var _anchorLocLonLat = [0, 0];
58706     var _triggerType = "";
58707     var _vpTopMargin = 85;
58708     var _vpBottomMargin = 45;
58709     var _vpSideMargin = 35;
58710     var _menuTop = false;
58711     var _menuHeight;
58712     var _menuWidth;
58713     var _verticalPadding = 4;
58714     var _tooltipWidth = 210;
58715     var _menuSideMargin = 10;
58716     var _tooltips = [];
58717     var editMenu = function(selection2) {
58718       var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen");
58719       var ops = _operations.filter(function(op) {
58720         return !isTouchMenu || !op.mouseOnly;
58721       });
58722       if (!ops.length)
58723         return;
58724       _tooltips = [];
58725       _menuTop = isTouchMenu;
58726       var showLabels = isTouchMenu;
58727       var buttonHeight = showLabels ? 32 : 34;
58728       if (showLabels) {
58729         _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) {
58730           return op.title.length;
58731         })));
58732       } else {
58733         _menuWidth = 44;
58734       }
58735       _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight;
58736       _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0");
58737       var buttons = _menu.selectAll(".edit-menu-item").data(ops);
58738       var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
58739         return "edit-menu-item edit-menu-item-" + d2.id;
58740       }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) {
58741         d3_event.stopPropagation();
58742       }).on("mouseenter.highlight", function(d3_event, d2) {
58743         if (!d2.relatedEntityIds || select_default2(this).classed("disabled"))
58744           return;
58745         utilHighlightEntities(d2.relatedEntityIds(), true, context);
58746       }).on("mouseleave.highlight", function(d3_event, d2) {
58747         if (!d2.relatedEntityIds)
58748           return;
58749         utilHighlightEntities(d2.relatedEntityIds(), false, context);
58750       });
58751       buttonsEnter.each(function(d2) {
58752         var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]);
58753         _tooltips.push(tooltip);
58754         select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation"));
58755       });
58756       if (showLabels) {
58757         buttonsEnter.append("span").attr("class", "label").each(function(d2) {
58758           select_default2(this).call(d2.title);
58759         });
58760       }
58761       buttonsEnter.merge(buttons).classed("disabled", function(d2) {
58762         return d2.disabled();
58763       });
58764       updatePosition();
58765       var initialScale = context.projection.scale();
58766       context.map().on("move.edit-menu", function() {
58767         if (initialScale !== context.projection.scale()) {
58768           editMenu.close();
58769         }
58770       }).on("drawn.edit-menu", function(info) {
58771         if (info.full)
58772           updatePosition();
58773       });
58774       var lastPointerUpType;
58775       function pointerup(d3_event) {
58776         lastPointerUpType = d3_event.pointerType;
58777       }
58778       function click(d3_event, operation2) {
58779         d3_event.stopPropagation();
58780         if (operation2.relatedEntityIds) {
58781           utilHighlightEntities(operation2.relatedEntityIds(), false, context);
58782         }
58783         if (operation2.disabled()) {
58784           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58785             context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())();
58786           }
58787         } else {
58788           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58789             context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)();
58790           }
58791           operation2();
58792           editMenu.close();
58793         }
58794         lastPointerUpType = null;
58795       }
58796       dispatch14.call("toggled", this, true);
58797     };
58798     function updatePosition() {
58799       if (!_menu || _menu.empty())
58800         return;
58801       var anchorLoc = context.projection(_anchorLocLonLat);
58802       var viewport = context.surfaceRect();
58803       if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) {
58804         editMenu.close();
58805         return;
58806       }
58807       var menuLeft = displayOnLeft(viewport);
58808       var offset = [0, 0];
58809       offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin;
58810       if (_menuTop) {
58811         if (anchorLoc[1] - _menuHeight < _vpTopMargin) {
58812           offset[1] = -anchorLoc[1] + _vpTopMargin;
58813         } else {
58814           offset[1] = -_menuHeight;
58815         }
58816       } else {
58817         if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) {
58818           offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin;
58819         } else {
58820           offset[1] = 0;
58821         }
58822       }
58823       var origin = geoVecAdd(anchorLoc, offset);
58824       _menu.style("left", origin[0] + "px").style("top", origin[1] + "px");
58825       var tooltipSide = tooltipPosition(viewport, menuLeft);
58826       _tooltips.forEach(function(tooltip) {
58827         tooltip.placement(tooltipSide);
58828       });
58829       function displayOnLeft(viewport2) {
58830         if (_mainLocalizer.textDirection() === "ltr") {
58831           if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) {
58832             return true;
58833           }
58834           return false;
58835         } else {
58836           if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) {
58837             return false;
58838           }
58839           return true;
58840         }
58841       }
58842       function tooltipPosition(viewport2, menuLeft2) {
58843         if (_mainLocalizer.textDirection() === "ltr") {
58844           if (menuLeft2) {
58845             return "left";
58846           }
58847           if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) {
58848             return "left";
58849           }
58850           return "right";
58851         } else {
58852           if (!menuLeft2) {
58853             return "right";
58854           }
58855           if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) {
58856             return "right";
58857           }
58858           return "left";
58859         }
58860       }
58861     }
58862     editMenu.close = function() {
58863       context.map().on("move.edit-menu", null).on("drawn.edit-menu", null);
58864       _menu.remove();
58865       _tooltips = [];
58866       dispatch14.call("toggled", this, false);
58867     };
58868     editMenu.anchorLoc = function(val) {
58869       if (!arguments.length)
58870         return _anchorLoc;
58871       _anchorLoc = val;
58872       _anchorLocLonLat = context.projection.invert(_anchorLoc);
58873       return editMenu;
58874     };
58875     editMenu.triggerType = function(val) {
58876       if (!arguments.length)
58877         return _triggerType;
58878       _triggerType = val;
58879       return editMenu;
58880     };
58881     editMenu.operations = function(val) {
58882       if (!arguments.length)
58883         return _operations;
58884       _operations = val;
58885       return editMenu;
58886     };
58887     return utilRebind(editMenu, dispatch14, "on");
58888   }
58889
58890   // modules/ui/feature_info.js
58891   function uiFeatureInfo(context) {
58892     function update(selection2) {
58893       var features = context.features();
58894       var stats = features.stats();
58895       var count = 0;
58896       var hiddenList = features.hidden().map(function(k2) {
58897         if (stats[k2]) {
58898           count += stats[k2];
58899           return _t.append("inspector.title_count", {
58900             title: _t("feature." + k2 + ".description"),
58901             count: stats[k2]
58902           });
58903         }
58904         return null;
58905       }).filter(Boolean);
58906       selection2.text("");
58907       if (hiddenList.length) {
58908         var tooltipBehavior = uiTooltip().placement("top").title(function() {
58909           return (selection3) => {
58910             hiddenList.forEach((hiddenFeature) => {
58911               selection3.append("div").call(hiddenFeature);
58912             });
58913           };
58914         });
58915         selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) {
58916           tooltipBehavior.hide();
58917           d3_event.preventDefault();
58918           context.ui().togglePanes(context.container().select(".map-panes .map-data-pane"));
58919         });
58920       }
58921       selection2.classed("hide", !hiddenList.length);
58922     }
58923     return function(selection2) {
58924       update(selection2);
58925       context.features().on("change.feature_info", function() {
58926         update(selection2);
58927       });
58928     };
58929   }
58930
58931   // modules/ui/flash.js
58932   function uiFlash(context) {
58933     var _flashTimer;
58934     var _duration = 2e3;
58935     var _iconName = "#iD-icon-no";
58936     var _iconClass = "disabled";
58937     var _label = (s2) => s2.text("");
58938     function flash() {
58939       if (_flashTimer) {
58940         _flashTimer.stop();
58941       }
58942       context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false);
58943       context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true);
58944       var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]);
58945       var contentEnter = content.enter().append("div").attr("class", "flash-content");
58946       var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)");
58947       iconEnter.append("circle").attr("r", 9);
58948       iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14");
58949       contentEnter.append("div").attr("class", "flash-text");
58950       content = content.merge(contentEnter);
58951       content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || ""));
58952       content.selectAll(".flash-icon use").attr("xlink:href", _iconName);
58953       content.selectAll(".flash-text").attr("class", "flash-text").call(_label);
58954       _flashTimer = timeout_default(function() {
58955         _flashTimer = null;
58956         context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true);
58957         context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false);
58958       }, _duration);
58959       return content;
58960     }
58961     flash.duration = function(_2) {
58962       if (!arguments.length)
58963         return _duration;
58964       _duration = _2;
58965       return flash;
58966     };
58967     flash.label = function(_2) {
58968       if (!arguments.length)
58969         return _label;
58970       if (typeof _2 !== "function") {
58971         _label = (selection2) => selection2.text(_2);
58972       } else {
58973         _label = (selection2) => selection2.text("").call(_2);
58974       }
58975       return flash;
58976     };
58977     flash.iconName = function(_2) {
58978       if (!arguments.length)
58979         return _iconName;
58980       _iconName = _2;
58981       return flash;
58982     };
58983     flash.iconClass = function(_2) {
58984       if (!arguments.length)
58985         return _iconClass;
58986       _iconClass = _2;
58987       return flash;
58988     };
58989     return flash;
58990   }
58991
58992   // modules/ui/full_screen.js
58993   function uiFullScreen(context) {
58994     var element = context.container().node();
58995     function getFullScreenFn() {
58996       if (element.requestFullscreen) {
58997         return element.requestFullscreen;
58998       } else if (element.msRequestFullscreen) {
58999         return element.msRequestFullscreen;
59000       } else if (element.mozRequestFullScreen) {
59001         return element.mozRequestFullScreen;
59002       } else if (element.webkitRequestFullscreen) {
59003         return element.webkitRequestFullscreen;
59004       }
59005     }
59006     function getExitFullScreenFn() {
59007       if (document.exitFullscreen) {
59008         return document.exitFullscreen;
59009       } else if (document.msExitFullscreen) {
59010         return document.msExitFullscreen;
59011       } else if (document.mozCancelFullScreen) {
59012         return document.mozCancelFullScreen;
59013       } else if (document.webkitExitFullscreen) {
59014         return document.webkitExitFullscreen;
59015       }
59016     }
59017     function isFullScreen() {
59018       return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
59019     }
59020     function isSupported() {
59021       return !!getFullScreenFn();
59022     }
59023     function fullScreen(d3_event) {
59024       d3_event.preventDefault();
59025       if (!isFullScreen()) {
59026         getFullScreenFn().apply(element);
59027       } else {
59028         getExitFullScreenFn().apply(document);
59029       }
59030     }
59031     return function() {
59032       if (!isSupported())
59033         return;
59034       var detected = utilDetect();
59035       var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"];
59036       context.keybinding().on(keys2, fullScreen);
59037     };
59038   }
59039
59040   // modules/ui/geolocate.js
59041   function uiGeolocate(context) {
59042     var _geolocationOptions = {
59043       // prioritize speed and power usage over precision
59044       enableHighAccuracy: false,
59045       // don't hang indefinitely getting the location
59046       timeout: 6e3
59047       // 6sec
59048     };
59049     var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true);
59050     var _layer = context.layers().layer("geolocate");
59051     var _position;
59052     var _extent;
59053     var _timeoutID;
59054     var _button = select_default2(null);
59055     function click() {
59056       if (context.inIntro())
59057         return;
59058       if (!_layer.enabled() && !_locating.isShown()) {
59059         _timeoutID = setTimeout(
59060           error,
59061           1e4
59062           /* 10sec */
59063         );
59064         context.container().call(_locating);
59065         navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions);
59066       } else {
59067         _locating.close();
59068         _layer.enabled(null, false);
59069         updateButtonState();
59070       }
59071     }
59072     function zoomTo() {
59073       context.enter(modeBrowse(context));
59074       var map2 = context.map();
59075       _layer.enabled(_position, true);
59076       updateButtonState();
59077       map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent)));
59078     }
59079     function success(geolocation) {
59080       _position = geolocation;
59081       var coords = _position.coords;
59082       _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy);
59083       zoomTo();
59084       finish();
59085     }
59086     function error() {
59087       if (_position) {
59088         zoomTo();
59089       } else {
59090         context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")();
59091       }
59092       finish();
59093     }
59094     function finish() {
59095       _locating.close();
59096       if (_timeoutID) {
59097         clearTimeout(_timeoutID);
59098       }
59099       _timeoutID = void 0;
59100     }
59101     function updateButtonState() {
59102       _button.classed("active", _layer.enabled());
59103       _button.attr("aria-pressed", _layer.enabled());
59104     }
59105     return function(selection2) {
59106       if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition)
59107         return;
59108       _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call(
59109         uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title")).keys([_t("geolocate.key")])
59110       );
59111       context.keybinding().on(_t("geolocate.key"), click);
59112     };
59113   }
59114
59115   // modules/ui/panels/background.js
59116   function uiPanelBackground(context) {
59117     var background = context.background();
59118     var _currSourceName = null;
59119     var _metadata = {};
59120     var _metadataKeys = [
59121       "zoom",
59122       "vintage",
59123       "source",
59124       "description",
59125       "resolution",
59126       "accuracy"
59127     ];
59128     var debouncedRedraw = debounce_default(redraw, 250);
59129     function redraw(selection2) {
59130       var source = background.baseLayerSource();
59131       if (!source)
59132         return;
59133       var isDG = source.id.match(/^DigitalGlobe/i) !== null;
59134       var sourceLabel = source.label();
59135       if (_currSourceName !== sourceLabel) {
59136         _currSourceName = sourceLabel;
59137         _metadata = {};
59138       }
59139       selection2.text("");
59140       var list2 = selection2.append("ul").attr("class", "background-info");
59141       list2.append("li").call(_currSourceName);
59142       _metadataKeys.forEach(function(k2) {
59143         if (isDG && k2 === "vintage")
59144           return;
59145         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]);
59146       });
59147       debouncedGetMetadata(selection2);
59148       var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles";
59149       selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) {
59150         d3_event.preventDefault();
59151         context.setDebug("tile", !context.getDebug("tile"));
59152         selection2.call(redraw);
59153       });
59154       if (isDG) {
59155         var key = source.id + "-vintage";
59156         var sourceVintage = context.background().findSource(key);
59157         var showsVintage = context.background().showsLayer(sourceVintage);
59158         var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage";
59159         selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) {
59160           d3_event.preventDefault();
59161           context.background().toggleOverlayLayer(sourceVintage);
59162           selection2.call(redraw);
59163         });
59164       }
59165       ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) {
59166         if (source.id !== layerId) {
59167           var key2 = layerId + "-vintage";
59168           var sourceVintage2 = context.background().findSource(key2);
59169           if (context.background().showsLayer(sourceVintage2)) {
59170             context.background().toggleOverlayLayer(sourceVintage2);
59171           }
59172         }
59173       });
59174     }
59175     var debouncedGetMetadata = debounce_default(getMetadata, 250);
59176     function getMetadata(selection2) {
59177       var tile = context.container().select(".layer-background img.tile-center");
59178       if (tile.empty())
59179         return;
59180       var sourceName = _currSourceName;
59181       var d2 = tile.datum();
59182       var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom());
59183       var center = context.map().center();
59184       _metadata.zoom = String(zoom);
59185       selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom);
59186       if (!d2 || !d2.length >= 3)
59187         return;
59188       background.baseLayerSource().getMetadata(center, d2, function(err, result) {
59189         if (err || _currSourceName !== sourceName)
59190           return;
59191         var vintage = result.vintage;
59192         _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown");
59193         selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage);
59194         _metadataKeys.forEach(function(k2) {
59195           if (k2 === "zoom" || k2 === "vintage")
59196             return;
59197           var val = result[k2];
59198           _metadata[k2] = val;
59199           selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val);
59200         });
59201       });
59202     }
59203     var panel = function(selection2) {
59204       selection2.call(redraw);
59205       context.map().on("drawn.info-background", function() {
59206         selection2.call(debouncedRedraw);
59207       }).on("move.info-background", function() {
59208         selection2.call(debouncedGetMetadata);
59209       });
59210     };
59211     panel.off = function() {
59212       context.map().on("drawn.info-background", null).on("move.info-background", null);
59213     };
59214     panel.id = "background";
59215     panel.label = _t.append("info_panels.background.title");
59216     panel.key = _t("info_panels.background.key");
59217     return panel;
59218   }
59219
59220   // modules/ui/panels/history.js
59221   function uiPanelHistory(context) {
59222     var osm;
59223     function displayTimestamp(timestamp) {
59224       if (!timestamp)
59225         return _t("info_panels.history.unknown");
59226       var options2 = {
59227         day: "numeric",
59228         month: "short",
59229         year: "numeric",
59230         hour: "numeric",
59231         minute: "numeric",
59232         second: "numeric"
59233       };
59234       var d2 = new Date(timestamp);
59235       if (isNaN(d2.getTime()))
59236         return _t("info_panels.history.unknown");
59237       return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
59238     }
59239     function displayUser(selection2, userName) {
59240       if (!userName) {
59241         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59242         return;
59243       }
59244       selection2.append("span").attr("class", "user-name").text(userName);
59245       var links = selection2.append("div").attr("class", "links");
59246       if (osm) {
59247         links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link"));
59248       }
59249       links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC");
59250     }
59251     function displayChangeset(selection2, changeset) {
59252       if (!changeset) {
59253         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59254         return;
59255       }
59256       selection2.append("span").attr("class", "changeset-id").text(changeset);
59257       var links = selection2.append("div").attr("class", "links");
59258       if (osm) {
59259         links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link"));
59260       }
59261       links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha");
59262       links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi");
59263     }
59264     function redraw(selection2) {
59265       var selectedNoteID = context.selectedNoteID();
59266       osm = context.connection();
59267       var selected, note, entity;
59268       if (selectedNoteID && osm) {
59269         selected = [_t.html("note.note") + " " + selectedNoteID];
59270         note = osm.getNote(selectedNoteID);
59271       } else {
59272         selected = context.selectedIDs().filter(function(e3) {
59273           return context.hasEntity(e3);
59274         });
59275         if (selected.length) {
59276           entity = context.entity(selected[0]);
59277         }
59278       }
59279       var singular = selected.length === 1 ? selected[0] : null;
59280       selection2.html("");
59281       if (singular) {
59282         selection2.append("h4").attr("class", "history-heading").html(singular);
59283       } else {
59284         selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length }));
59285       }
59286       if (!singular)
59287         return;
59288       if (entity) {
59289         selection2.call(redrawEntity, entity);
59290       } else if (note) {
59291         selection2.call(redrawNote, note);
59292       }
59293     }
59294     function redrawNote(selection2, note) {
59295       if (!note || note.isNew()) {
59296         selection2.append("div").call(_t.append("info_panels.history.note_no_history"));
59297         return;
59298       }
59299       var list2 = selection2.append("ul");
59300       list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length);
59301       if (note.comments.length) {
59302         list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date));
59303         list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user);
59304       }
59305       if (osm) {
59306         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"));
59307       }
59308     }
59309     function redrawEntity(selection2, entity) {
59310       if (!entity || entity.isNew()) {
59311         selection2.append("div").call(_t.append("info_panels.history.no_history"));
59312         return;
59313       }
59314       var links = selection2.append("div").attr("class", "links");
59315       if (osm) {
59316         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"));
59317       }
59318       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");
59319       var list2 = selection2.append("ul");
59320       list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version);
59321       list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp));
59322       list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user);
59323       list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset);
59324     }
59325     var panel = function(selection2) {
59326       selection2.call(redraw);
59327       context.map().on("drawn.info-history", function() {
59328         selection2.call(redraw);
59329       });
59330       context.on("enter.info-history", function() {
59331         selection2.call(redraw);
59332       });
59333     };
59334     panel.off = function() {
59335       context.map().on("drawn.info-history", null);
59336       context.on("enter.info-history", null);
59337     };
59338     panel.id = "history";
59339     panel.label = _t.append("info_panels.history.title");
59340     panel.key = _t("info_panels.history.key");
59341     return panel;
59342   }
59343
59344   // modules/ui/panels/location.js
59345   function uiPanelLocation(context) {
59346     var currLocation = "";
59347     function redraw(selection2) {
59348       selection2.html("");
59349       var list2 = selection2.append("ul");
59350       var coord2 = context.map().mouseCoordinates();
59351       if (coord2.some(isNaN)) {
59352         coord2 = context.map().center();
59353       }
59354       list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2));
59355       selection2.append("div").attr("class", "location-info").text(currLocation || " ");
59356       debouncedGetLocation(selection2, coord2);
59357     }
59358     var debouncedGetLocation = debounce_default(getLocation, 250);
59359     function getLocation(selection2, coord2) {
59360       if (!services.geocoder) {
59361         currLocation = _t("info_panels.location.unknown_location");
59362         selection2.selectAll(".location-info").text(currLocation);
59363       } else {
59364         services.geocoder.reverse(coord2, function(err, result) {
59365           currLocation = result ? result.display_name : _t("info_panels.location.unknown_location");
59366           selection2.selectAll(".location-info").text(currLocation);
59367         });
59368       }
59369     }
59370     var panel = function(selection2) {
59371       selection2.call(redraw);
59372       context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() {
59373         selection2.call(redraw);
59374       });
59375     };
59376     panel.off = function() {
59377       context.surface().on(".info-location", null);
59378     };
59379     panel.id = "location";
59380     panel.label = _t.append("info_panels.location.title");
59381     panel.key = _t("info_panels.location.key");
59382     return panel;
59383   }
59384
59385   // modules/ui/panels/measurement.js
59386   function uiPanelMeasurement(context) {
59387     function radiansToMeters(r2) {
59388       return r2 * 63710071809e-4;
59389     }
59390     function steradiansToSqmeters(r2) {
59391       return r2 / (4 * Math.PI) * 510065621724e3;
59392     }
59393     function toLineString(feature3) {
59394       if (feature3.type === "LineString")
59395         return feature3;
59396       var result = { type: "LineString", coordinates: [] };
59397       if (feature3.type === "Polygon") {
59398         result.coordinates = feature3.coordinates[0];
59399       } else if (feature3.type === "MultiPolygon") {
59400         result.coordinates = feature3.coordinates[0][0];
59401       }
59402       return result;
59403     }
59404     var _isImperial = !_mainLocalizer.usesMetric();
59405     function redraw(selection2) {
59406       var graph = context.graph();
59407       var selectedNoteID = context.selectedNoteID();
59408       var osm = services.osm;
59409       var localeCode = _mainLocalizer.localeCode();
59410       var heading2;
59411       var center, location, centroid;
59412       var closed, geometry;
59413       var totalNodeCount, length2 = 0, area = 0, distance;
59414       if (selectedNoteID && osm) {
59415         var note = osm.getNote(selectedNoteID);
59416         heading2 = _t.html("note.note") + " " + selectedNoteID;
59417         location = note.loc;
59418         geometry = "note";
59419       } else {
59420         var selectedIDs = context.selectedIDs().filter(function(id2) {
59421           return context.hasEntity(id2);
59422         });
59423         var selected = selectedIDs.map(function(id2) {
59424           return context.entity(id2);
59425         });
59426         heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length });
59427         if (selected.length) {
59428           var extent = geoExtent();
59429           for (var i3 in selected) {
59430             var entity = selected[i3];
59431             extent._extend(entity.extent(graph));
59432             geometry = entity.geometry(graph);
59433             if (geometry === "line" || geometry === "area") {
59434               closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate();
59435               var feature3 = entity.asGeoJSON(graph);
59436               length2 += radiansToMeters(length_default(toLineString(feature3)));
59437               centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph));
59438               centroid = centroid && context.projection.invert(centroid);
59439               if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) {
59440                 centroid = entity.extent(graph).center();
59441               }
59442               if (closed) {
59443                 area += steradiansToSqmeters(entity.area(graph));
59444               }
59445             }
59446           }
59447           if (selected.length > 1) {
59448             geometry = null;
59449             closed = null;
59450             centroid = null;
59451           }
59452           if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") {
59453             distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
59454           }
59455           if (selected.length === 1 && selected[0].type === "node") {
59456             location = selected[0].loc;
59457           } else {
59458             totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length;
59459           }
59460           if (!location && !centroid) {
59461             center = extent.center();
59462           }
59463         }
59464       }
59465       selection2.html("");
59466       if (heading2) {
59467         selection2.append("h4").attr("class", "measurement-heading").html(heading2);
59468       }
59469       var list2 = selection2.append("ul");
59470       var coordItem;
59471       if (geometry) {
59472         list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html(
59473           closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry)
59474         );
59475       }
59476       if (totalNodeCount) {
59477         list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode));
59478       }
59479       if (area) {
59480         list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial));
59481       }
59482       if (length2) {
59483         list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial));
59484       }
59485       if (typeof distance === "number") {
59486         list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial));
59487       }
59488       if (location) {
59489         coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" }));
59490         coordItem.append("span").text(dmsCoordinatePair(location));
59491         coordItem.append("span").text(decimalCoordinatePair(location));
59492       }
59493       if (centroid) {
59494         coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" }));
59495         coordItem.append("span").text(dmsCoordinatePair(centroid));
59496         coordItem.append("span").text(decimalCoordinatePair(centroid));
59497       }
59498       if (center) {
59499         coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" }));
59500         coordItem.append("span").text(dmsCoordinatePair(center));
59501         coordItem.append("span").text(decimalCoordinatePair(center));
59502       }
59503       if (length2 || area || typeof distance === "number") {
59504         var toggle = _isImperial ? "imperial" : "metric";
59505         selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) {
59506           d3_event.preventDefault();
59507           _isImperial = !_isImperial;
59508           selection2.call(redraw);
59509         });
59510       }
59511     }
59512     var panel = function(selection2) {
59513       selection2.call(redraw);
59514       context.map().on("drawn.info-measurement", function() {
59515         selection2.call(redraw);
59516       });
59517       context.on("enter.info-measurement", function() {
59518         selection2.call(redraw);
59519       });
59520     };
59521     panel.off = function() {
59522       context.map().on("drawn.info-measurement", null);
59523       context.on("enter.info-measurement", null);
59524     };
59525     panel.id = "measurement";
59526     panel.label = _t.append("info_panels.measurement.title");
59527     panel.key = _t("info_panels.measurement.key");
59528     return panel;
59529   }
59530
59531   // modules/ui/panels/index.js
59532   var uiInfoPanels = {
59533     background: uiPanelBackground,
59534     history: uiPanelHistory,
59535     location: uiPanelLocation,
59536     measurement: uiPanelMeasurement
59537   };
59538
59539   // modules/ui/info.js
59540   function uiInfo(context) {
59541     var ids = Object.keys(uiInfoPanels);
59542     var wasActive = ["measurement"];
59543     var panels = {};
59544     var active = {};
59545     ids.forEach(function(k2) {
59546       if (!panels[k2]) {
59547         panels[k2] = uiInfoPanels[k2](context);
59548         active[k2] = false;
59549       }
59550     });
59551     function info(selection2) {
59552       function redraw() {
59553         var activeids = ids.filter(function(k2) {
59554           return active[k2];
59555         }).sort();
59556         var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) {
59557           return k2;
59558         });
59559         containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) {
59560           select_default2(this).call(panels[d2].off).remove();
59561         });
59562         var enter = containers.enter().append("div").attr("class", function(d2) {
59563           return "fillD2 panel-container panel-container-" + d2;
59564         });
59565         enter.style("opacity", 0).transition().duration(200).style("opacity", 1);
59566         var title = enter.append("div").attr("class", "panel-title fillD2");
59567         title.append("h3").each(function(d2) {
59568           return panels[d2].label(select_default2(this));
59569         });
59570         title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) {
59571           d3_event.stopImmediatePropagation();
59572           d3_event.preventDefault();
59573           info.toggle(d2);
59574         }).call(svgIcon("#iD-icon-close"));
59575         enter.append("div").attr("class", function(d2) {
59576           return "panel-content panel-content-" + d2;
59577         });
59578         infoPanels.selectAll(".panel-content").each(function(d2) {
59579           select_default2(this).call(panels[d2]);
59580         });
59581       }
59582       info.toggle = function(which) {
59583         var activeids = ids.filter(function(k2) {
59584           return active[k2];
59585         });
59586         if (which) {
59587           active[which] = !active[which];
59588           if (activeids.length === 1 && activeids[0] === which) {
59589             wasActive = [which];
59590           }
59591           context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]);
59592         } else {
59593           if (activeids.length) {
59594             wasActive = activeids;
59595             activeids.forEach(function(k2) {
59596               active[k2] = false;
59597             });
59598           } else {
59599             wasActive.forEach(function(k2) {
59600               active[k2] = true;
59601             });
59602           }
59603         }
59604         redraw();
59605       };
59606       var infoPanels = selection2.selectAll(".info-panels").data([0]);
59607       infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels);
59608       redraw();
59609       context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) {
59610         d3_event.stopImmediatePropagation();
59611         d3_event.preventDefault();
59612         info.toggle();
59613       });
59614       ids.forEach(function(k2) {
59615         var key = _t("info_panels." + k2 + ".key", { default: null });
59616         if (!key)
59617           return;
59618         context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) {
59619           d3_event.stopImmediatePropagation();
59620           d3_event.preventDefault();
59621           info.toggle(k2);
59622         });
59623       });
59624     }
59625     return info;
59626   }
59627
59628   // modules/ui/intro/helper.js
59629   function pointBox(loc, context) {
59630     var rect = context.surfaceRect();
59631     var point2 = context.curtainProjection(loc);
59632     return {
59633       left: point2[0] + rect.left - 40,
59634       top: point2[1] + rect.top - 60,
59635       width: 80,
59636       height: 90
59637     };
59638   }
59639   function pad(locOrBox, padding, context) {
59640     var box;
59641     if (locOrBox instanceof Array) {
59642       var rect = context.surfaceRect();
59643       var point2 = context.curtainProjection(locOrBox);
59644       box = {
59645         left: point2[0] + rect.left,
59646         top: point2[1] + rect.top
59647       };
59648     } else {
59649       box = locOrBox;
59650     }
59651     return {
59652       left: box.left - padding,
59653       top: box.top - padding,
59654       width: (box.width || 0) + 2 * padding,
59655       height: (box.width || 0) + 2 * padding
59656     };
59657   }
59658   function icon(name, svgklass, useklass) {
59659     return '<svg class="icon ' + (svgklass || "") + '"><use xlink:href="' + name + '"' + (useklass ? ' class="' + useklass + '"' : "") + "></use></svg>";
59660   }
59661   var helpStringReplacements;
59662   function helpHtml(id2, replacements) {
59663     if (!helpStringReplacements) {
59664       helpStringReplacements = {
59665         // insert icons corresponding to various UI elements
59666         point_icon: icon("#iD-icon-point", "inline"),
59667         line_icon: icon("#iD-icon-line", "inline"),
59668         area_icon: icon("#iD-icon-area", "inline"),
59669         note_icon: icon("#iD-icon-note", "inline add-note"),
59670         plus: icon("#iD-icon-plus", "inline"),
59671         minus: icon("#iD-icon-minus", "inline"),
59672         layers_icon: icon("#iD-icon-layers", "inline"),
59673         data_icon: icon("#iD-icon-data", "inline"),
59674         inspect: icon("#iD-icon-inspect", "inline"),
59675         help_icon: icon("#iD-icon-help", "inline"),
59676         undo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo", "inline"),
59677         redo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-undo" : "#iD-icon-redo", "inline"),
59678         save_icon: icon("#iD-icon-save", "inline"),
59679         // operation icons
59680         circularize_icon: icon("#iD-operation-circularize", "inline operation"),
59681         continue_icon: icon("#iD-operation-continue", "inline operation"),
59682         copy_icon: icon("#iD-operation-copy", "inline operation"),
59683         delete_icon: icon("#iD-operation-delete", "inline operation"),
59684         disconnect_icon: icon("#iD-operation-disconnect", "inline operation"),
59685         downgrade_icon: icon("#iD-operation-downgrade", "inline operation"),
59686         extract_icon: icon("#iD-operation-extract", "inline operation"),
59687         merge_icon: icon("#iD-operation-merge", "inline operation"),
59688         move_icon: icon("#iD-operation-move", "inline operation"),
59689         orthogonalize_icon: icon("#iD-operation-orthogonalize", "inline operation"),
59690         paste_icon: icon("#iD-operation-paste", "inline operation"),
59691         reflect_long_icon: icon("#iD-operation-reflect-long", "inline operation"),
59692         reflect_short_icon: icon("#iD-operation-reflect-short", "inline operation"),
59693         reverse_icon: icon("#iD-operation-reverse", "inline operation"),
59694         rotate_icon: icon("#iD-operation-rotate", "inline operation"),
59695         split_icon: icon("#iD-operation-split", "inline operation"),
59696         straighten_icon: icon("#iD-operation-straighten", "inline operation"),
59697         // interaction icons
59698         leftclick: icon("#iD-walkthrough-mouse-left", "inline operation"),
59699         rightclick: icon("#iD-walkthrough-mouse-right", "inline operation"),
59700         mousewheel_icon: icon("#iD-walkthrough-mousewheel", "inline operation"),
59701         tap_icon: icon("#iD-walkthrough-tap", "inline operation"),
59702         doubletap_icon: icon("#iD-walkthrough-doubletap", "inline operation"),
59703         longpress_icon: icon("#iD-walkthrough-longpress", "inline operation"),
59704         touchdrag_icon: icon("#iD-walkthrough-touchdrag", "inline operation"),
59705         pinch_icon: icon("#iD-walkthrough-pinch-apart", "inline operation"),
59706         // insert keys; may be localized and platform-dependent
59707         shift: uiCmd.display("\u21E7"),
59708         alt: uiCmd.display("\u2325"),
59709         return: uiCmd.display("\u21B5"),
59710         esc: _t.html("shortcuts.key.esc"),
59711         space: _t.html("shortcuts.key.space"),
59712         add_note_key: _t.html("modes.add_note.key"),
59713         help_key: _t.html("help.key"),
59714         shortcuts_key: _t.html("shortcuts.toggle.key"),
59715         // reference localized UI labels directly so that they'll always match
59716         save: _t.html("save.title"),
59717         undo: _t.html("undo.title"),
59718         redo: _t.html("redo.title"),
59719         upload: _t.html("commit.save"),
59720         point: _t.html("modes.add_point.title"),
59721         line: _t.html("modes.add_line.title"),
59722         area: _t.html("modes.add_area.title"),
59723         note: _t.html("modes.add_note.label"),
59724         circularize: _t.html("operations.circularize.title"),
59725         continue: _t.html("operations.continue.title"),
59726         copy: _t.html("operations.copy.title"),
59727         delete: _t.html("operations.delete.title"),
59728         disconnect: _t.html("operations.disconnect.title"),
59729         downgrade: _t.html("operations.downgrade.title"),
59730         extract: _t.html("operations.extract.title"),
59731         merge: _t.html("operations.merge.title"),
59732         move: _t.html("operations.move.title"),
59733         orthogonalize: _t.html("operations.orthogonalize.title"),
59734         paste: _t.html("operations.paste.title"),
59735         reflect_long: _t.html("operations.reflect.title.long"),
59736         reflect_short: _t.html("operations.reflect.title.short"),
59737         reverse: _t.html("operations.reverse.title"),
59738         rotate: _t.html("operations.rotate.title"),
59739         split: _t.html("operations.split.title"),
59740         straighten: _t.html("operations.straighten.title"),
59741         map_data: _t.html("map_data.title"),
59742         osm_notes: _t.html("map_data.layers.notes.title"),
59743         fields: _t.html("inspector.fields"),
59744         tags: _t.html("inspector.tags"),
59745         relations: _t.html("inspector.relations"),
59746         new_relation: _t.html("inspector.new_relation"),
59747         turn_restrictions: _t.html("_tagging.presets.fields.restrictions.label"),
59748         background_settings: _t.html("background.description"),
59749         imagery_offset: _t.html("background.fix_misalignment"),
59750         start_the_walkthrough: _t.html("splash.walkthrough"),
59751         help: _t.html("help.title"),
59752         ok: _t.html("intro.ok")
59753       };
59754       for (var key in helpStringReplacements) {
59755         helpStringReplacements[key] = { html: helpStringReplacements[key] };
59756       }
59757     }
59758     var reps;
59759     if (replacements) {
59760       reps = Object.assign(replacements, helpStringReplacements);
59761     } else {
59762       reps = helpStringReplacements;
59763     }
59764     return _t.html(id2, reps).replace(/\`(.*?)\`/g, "<kbd>$1</kbd>");
59765   }
59766   function slugify(text) {
59767     return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
59768   }
59769   var missingStrings = {};
59770   function checkKey(key, text) {
59771     if (_t(key, { default: void 0 }) === void 0) {
59772       if (missingStrings.hasOwnProperty(key))
59773         return;
59774       missingStrings[key] = text;
59775       var missing = key + ": " + text;
59776       if (typeof console !== "undefined")
59777         console.log(missing);
59778     }
59779   }
59780   function localize(obj) {
59781     var key;
59782     var name = obj.tags && obj.tags.name;
59783     if (name) {
59784       key = "intro.graph.name." + slugify(name);
59785       obj.tags.name = _t(key, { default: name });
59786       checkKey(key, name);
59787     }
59788     var street = obj.tags && obj.tags["addr:street"];
59789     if (street) {
59790       key = "intro.graph.name." + slugify(street);
59791       obj.tags["addr:street"] = _t(key, { default: street });
59792       checkKey(key, street);
59793       var addrTags = [
59794         "block_number",
59795         "city",
59796         "county",
59797         "district",
59798         "hamlet",
59799         "neighbourhood",
59800         "postcode",
59801         "province",
59802         "quarter",
59803         "state",
59804         "subdistrict",
59805         "suburb"
59806       ];
59807       addrTags.forEach(function(k2) {
59808         var key2 = "intro.graph." + k2;
59809         var tag2 = "addr:" + k2;
59810         var val = obj.tags && obj.tags[tag2];
59811         var str = _t(key2, { default: val });
59812         if (str) {
59813           if (str.match(/^<.*>$/) !== null) {
59814             delete obj.tags[tag2];
59815           } else {
59816             obj.tags[tag2] = str;
59817           }
59818         }
59819       });
59820     }
59821     return obj;
59822   }
59823   function isMostlySquare(points) {
59824     var threshold = 15;
59825     var lowerBound = Math.cos((90 - threshold) * Math.PI / 180);
59826     var upperBound = Math.cos(threshold * Math.PI / 180);
59827     for (var i3 = 0; i3 < points.length; i3++) {
59828       var a2 = points[(i3 - 1 + points.length) % points.length];
59829       var origin = points[i3];
59830       var b2 = points[(i3 + 1) % points.length];
59831       var dotp = geoVecNormalizedDot(a2, b2, origin);
59832       var mag = Math.abs(dotp);
59833       if (mag > lowerBound && mag < upperBound) {
59834         return false;
59835       }
59836     }
59837     return true;
59838   }
59839   function selectMenuItem(context, operation2) {
59840     return context.container().select(".edit-menu .edit-menu-item-" + operation2);
59841   }
59842   function transitionTime(point1, point2) {
59843     var distance = geoSphericalDistance(point1, point2);
59844     if (distance === 0) {
59845       return 0;
59846     } else if (distance < 80) {
59847       return 500;
59848     } else {
59849       return 1e3;
59850     }
59851   }
59852
59853   // modules/ui/toggle.js
59854   function uiToggle(show, callback) {
59855     return function(selection2) {
59856       selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() {
59857         select_default2(this).classed("hide", !show).style("opacity", null);
59858         if (callback)
59859           callback.apply(this);
59860       });
59861     };
59862   }
59863
59864   // modules/ui/curtain.js
59865   function uiCurtain(containerNode) {
59866     var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null);
59867     function curtain(selection2) {
59868       surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0);
59869       darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness");
59870       select_default2(window).on("resize.curtain", resize);
59871       tooltip = selection2.append("div").attr("class", "tooltip");
59872       tooltip.append("div").attr("class", "popover-arrow");
59873       tooltip.append("div").attr("class", "popover-inner");
59874       resize();
59875       function resize() {
59876         surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight);
59877         curtain.cut(darkness.datum());
59878       }
59879     }
59880     curtain.reveal = function(box, html3, options2) {
59881       options2 = options2 || {};
59882       if (typeof box === "string") {
59883         box = select_default2(box).node();
59884       }
59885       if (box && box.getBoundingClientRect) {
59886         box = copyBox(box.getBoundingClientRect());
59887         var containerRect = containerNode.getBoundingClientRect();
59888         box.top -= containerRect.top;
59889         box.left -= containerRect.left;
59890       }
59891       if (box && options2.padding) {
59892         box.top -= options2.padding;
59893         box.left -= options2.padding;
59894         box.bottom += options2.padding;
59895         box.right += options2.padding;
59896         box.height += options2.padding * 2;
59897         box.width += options2.padding * 2;
59898       }
59899       var tooltipBox;
59900       if (options2.tooltipBox) {
59901         tooltipBox = options2.tooltipBox;
59902         if (typeof tooltipBox === "string") {
59903           tooltipBox = select_default2(tooltipBox).node();
59904         }
59905         if (tooltipBox && tooltipBox.getBoundingClientRect) {
59906           tooltipBox = copyBox(tooltipBox.getBoundingClientRect());
59907         }
59908       } else {
59909         tooltipBox = box;
59910       }
59911       if (tooltipBox && html3) {
59912         if (html3.indexOf("**") !== -1) {
59913           if (html3.indexOf("<span") === 0) {
59914             html3 = html3.replace(/^(<span.*?>)(.+?)(\*\*)/, "$1<span>$2</span>$3");
59915           } else {
59916             html3 = html3.replace(/^(.+?)(\*\*)/, "<span>$1</span>$2");
59917           }
59918           html3 = html3.replace(/\*\*(.*?)\*\*/g, '<span class="instruction">$1</span>');
59919         }
59920         html3 = html3.replace(/\*(.*?)\*/g, "<em>$1</em>");
59921         html3 = html3.replace(/\{br\}/g, "<br/><br/>");
59922         if (options2.buttonText && options2.buttonCallback) {
59923           html3 += '<div class="button-section"><button href="#" class="button action">' + options2.buttonText + "</button></div>";
59924         }
59925         var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || "");
59926         tooltip.classed(classes, true).selectAll(".popover-inner").html(html3);
59927         if (options2.buttonText && options2.buttonCallback) {
59928           var button = tooltip.selectAll(".button-section .button.action");
59929           button.on("click", function(d3_event) {
59930             d3_event.preventDefault();
59931             options2.buttonCallback();
59932           });
59933         }
59934         var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos;
59935         if (options2.tooltipClass === "intro-mouse") {
59936           tip.height += 80;
59937         }
59938         if (tooltipBox.top + tooltipBox.height > h2) {
59939           tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2;
59940         }
59941         if (tooltipBox.left + tooltipBox.width > w2) {
59942           tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2;
59943         }
59944         if (tooltipBox.top + tooltipBox.height < 100) {
59945           side = "bottom";
59946           pos = [
59947             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59948             tooltipBox.top + tooltipBox.height
59949           ];
59950         } else if (tooltipBox.top > h2 - 140) {
59951           side = "top";
59952           pos = [
59953             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59954             tooltipBox.top - tip.height
59955           ];
59956         } else {
59957           var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2;
59958           if (_mainLocalizer.textDirection() === "rtl") {
59959             if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) {
59960               side = "right";
59961               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59962             } else {
59963               side = "left";
59964               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59965             }
59966           } else {
59967             if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) {
59968               side = "left";
59969               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59970             } else {
59971               side = "right";
59972               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59973             }
59974           }
59975         }
59976         if (options2.duration !== 0 || !tooltip.classed(side)) {
59977           tooltip.call(uiToggle(true));
59978         }
59979         tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side);
59980         var shiftY = 0;
59981         if (side === "left" || side === "right") {
59982           if (pos[1] < 60) {
59983             shiftY = 60 - pos[1];
59984           } else if (pos[1] + tip.height > h2 - 100) {
59985             shiftY = h2 - pos[1] - tip.height - 100;
59986           }
59987         }
59988         tooltip.selectAll(".popover-inner").style("top", shiftY + "px");
59989       } else {
59990         tooltip.classed("in", false).call(uiToggle(false));
59991       }
59992       curtain.cut(box, options2.duration);
59993       return tooltip;
59994     };
59995     curtain.cut = function(datum2, duration) {
59996       darkness.datum(datum2).interrupt();
59997       var selection2;
59998       if (duration === 0) {
59999         selection2 = darkness;
60000       } else {
60001         selection2 = darkness.transition().duration(duration || 600).ease(linear2);
60002       }
60003       selection2.attr("d", function(d2) {
60004         var containerWidth = containerNode.clientWidth;
60005         var containerHeight = containerNode.clientHeight;
60006         var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z";
60007         if (!d2)
60008           return string;
60009         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";
60010       });
60011     };
60012     curtain.remove = function() {
60013       surface.remove();
60014       tooltip.remove();
60015       select_default2(window).on("resize.curtain", null);
60016     };
60017     function copyBox(src) {
60018       return {
60019         top: src.top,
60020         right: src.right,
60021         bottom: src.bottom,
60022         left: src.left,
60023         width: src.width,
60024         height: src.height
60025       };
60026     }
60027     return curtain;
60028   }
60029
60030   // modules/ui/intro/welcome.js
60031   function uiIntroWelcome(context, reveal) {
60032     var dispatch14 = dispatch_default("done");
60033     var chapter = {
60034       title: "intro.welcome.title"
60035     };
60036     function welcome() {
60037       context.map().centerZoom([-85.63591, 41.94285], 19);
60038       reveal(
60039         ".intro-nav-wrap .chapter-welcome",
60040         helpHtml("intro.welcome.welcome"),
60041         { buttonText: _t.html("intro.ok"), buttonCallback: practice }
60042       );
60043     }
60044     function practice() {
60045       reveal(
60046         ".intro-nav-wrap .chapter-welcome",
60047         helpHtml("intro.welcome.practice"),
60048         { buttonText: _t.html("intro.ok"), buttonCallback: words }
60049       );
60050     }
60051     function words() {
60052       reveal(
60053         ".intro-nav-wrap .chapter-welcome",
60054         helpHtml("intro.welcome.words"),
60055         { buttonText: _t.html("intro.ok"), buttonCallback: chapters }
60056       );
60057     }
60058     function chapters() {
60059       dispatch14.call("done");
60060       reveal(
60061         ".intro-nav-wrap .chapter-navigation",
60062         helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") })
60063       );
60064     }
60065     chapter.enter = function() {
60066       welcome();
60067     };
60068     chapter.exit = function() {
60069       context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove();
60070     };
60071     chapter.restart = function() {
60072       chapter.exit();
60073       chapter.enter();
60074     };
60075     return utilRebind(chapter, dispatch14, "on");
60076   }
60077
60078   // modules/ui/intro/navigation.js
60079   function uiIntroNavigation(context, reveal) {
60080     var dispatch14 = dispatch_default("done");
60081     var timeouts = [];
60082     var hallId = "n2061";
60083     var townHall = [-85.63591, 41.94285];
60084     var springStreetId = "w397";
60085     var springStreetEndId = "n1834";
60086     var springStreet = [-85.63582, 41.94255];
60087     var onewayField = _mainPresetIndex.field("oneway");
60088     var maxspeedField = _mainPresetIndex.field("maxspeed");
60089     var chapter = {
60090       title: "intro.navigation.title"
60091     };
60092     function timeout2(f2, t2) {
60093       timeouts.push(window.setTimeout(f2, t2));
60094     }
60095     function eventCancel(d3_event) {
60096       d3_event.stopPropagation();
60097       d3_event.preventDefault();
60098     }
60099     function isTownHallSelected() {
60100       var ids = context.selectedIDs();
60101       return ids.length === 1 && ids[0] === hallId;
60102     }
60103     function dragMap() {
60104       context.enter(modeBrowse(context));
60105       context.history().reset("initial");
60106       var msec = transitionTime(townHall, context.map().center());
60107       if (msec) {
60108         reveal(null, null, { duration: 0 });
60109       }
60110       context.map().centerZoomEase(townHall, 19, msec);
60111       timeout2(function() {
60112         var centerStart = context.map().center();
60113         var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch";
60114         var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId);
60115         reveal(".surface", dragString);
60116         context.map().on("drawn.intro", function() {
60117           reveal(".surface", dragString, { duration: 0 });
60118         });
60119         context.map().on("move.intro", function() {
60120           var centerNow = context.map().center();
60121           if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) {
60122             context.map().on("move.intro", null);
60123             timeout2(function() {
60124               continueTo(zoomMap);
60125             }, 3e3);
60126           }
60127         });
60128       }, msec + 100);
60129       function continueTo(nextStep) {
60130         context.map().on("move.intro drawn.intro", null);
60131         nextStep();
60132       }
60133     }
60134     function zoomMap() {
60135       var zoomStart = context.map().zoom();
60136       var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch";
60137       var zoomString = helpHtml("intro.navigation." + textId);
60138       reveal(".surface", zoomString);
60139       context.map().on("drawn.intro", function() {
60140         reveal(".surface", zoomString, { duration: 0 });
60141       });
60142       context.map().on("move.intro", function() {
60143         if (context.map().zoom() !== zoomStart) {
60144           context.map().on("move.intro", null);
60145           timeout2(function() {
60146             continueTo(features);
60147           }, 3e3);
60148         }
60149       });
60150       function continueTo(nextStep) {
60151         context.map().on("move.intro drawn.intro", null);
60152         nextStep();
60153       }
60154     }
60155     function features() {
60156       var onClick = function() {
60157         continueTo(pointsLinesAreas);
60158       };
60159       reveal(
60160         ".surface",
60161         helpHtml("intro.navigation.features"),
60162         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60163       );
60164       context.map().on("drawn.intro", function() {
60165         reveal(
60166           ".surface",
60167           helpHtml("intro.navigation.features"),
60168           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60169         );
60170       });
60171       function continueTo(nextStep) {
60172         context.map().on("drawn.intro", null);
60173         nextStep();
60174       }
60175     }
60176     function pointsLinesAreas() {
60177       var onClick = function() {
60178         continueTo(nodesWays);
60179       };
60180       reveal(
60181         ".surface",
60182         helpHtml("intro.navigation.points_lines_areas"),
60183         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60184       );
60185       context.map().on("drawn.intro", function() {
60186         reveal(
60187           ".surface",
60188           helpHtml("intro.navigation.points_lines_areas"),
60189           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60190         );
60191       });
60192       function continueTo(nextStep) {
60193         context.map().on("drawn.intro", null);
60194         nextStep();
60195       }
60196     }
60197     function nodesWays() {
60198       var onClick = function() {
60199         continueTo(clickTownHall);
60200       };
60201       reveal(
60202         ".surface",
60203         helpHtml("intro.navigation.nodes_ways"),
60204         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60205       );
60206       context.map().on("drawn.intro", function() {
60207         reveal(
60208           ".surface",
60209           helpHtml("intro.navigation.nodes_ways"),
60210           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60211         );
60212       });
60213       function continueTo(nextStep) {
60214         context.map().on("drawn.intro", null);
60215         nextStep();
60216       }
60217     }
60218     function clickTownHall() {
60219       context.enter(modeBrowse(context));
60220       context.history().reset("initial");
60221       var entity = context.hasEntity(hallId);
60222       if (!entity)
60223         return;
60224       reveal(null, null, { duration: 0 });
60225       context.map().centerZoomEase(entity.loc, 19, 500);
60226       timeout2(function() {
60227         var entity2 = context.hasEntity(hallId);
60228         if (!entity2)
60229           return;
60230         var box = pointBox(entity2.loc, context);
60231         var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall";
60232         reveal(box, helpHtml("intro.navigation." + textId));
60233         context.map().on("move.intro drawn.intro", function() {
60234           var entity3 = context.hasEntity(hallId);
60235           if (!entity3)
60236             return;
60237           var box2 = pointBox(entity3.loc, context);
60238           reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 });
60239         });
60240         context.on("enter.intro", function() {
60241           if (isTownHallSelected())
60242             continueTo(selectedTownHall);
60243         });
60244       }, 550);
60245       context.history().on("change.intro", function() {
60246         if (!context.hasEntity(hallId)) {
60247           continueTo(clickTownHall);
60248         }
60249       });
60250       function continueTo(nextStep) {
60251         context.on("enter.intro", null);
60252         context.map().on("move.intro drawn.intro", null);
60253         context.history().on("change.intro", null);
60254         nextStep();
60255       }
60256     }
60257     function selectedTownHall() {
60258       if (!isTownHallSelected())
60259         return clickTownHall();
60260       var entity = context.hasEntity(hallId);
60261       if (!entity)
60262         return clickTownHall();
60263       var box = pointBox(entity.loc, context);
60264       var onClick = function() {
60265         continueTo(editorTownHall);
60266       };
60267       reveal(
60268         box,
60269         helpHtml("intro.navigation.selected_townhall"),
60270         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60271       );
60272       context.map().on("move.intro drawn.intro", function() {
60273         var entity2 = context.hasEntity(hallId);
60274         if (!entity2)
60275           return;
60276         var box2 = pointBox(entity2.loc, context);
60277         reveal(
60278           box2,
60279           helpHtml("intro.navigation.selected_townhall"),
60280           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60281         );
60282       });
60283       context.history().on("change.intro", function() {
60284         if (!context.hasEntity(hallId)) {
60285           continueTo(clickTownHall);
60286         }
60287       });
60288       function continueTo(nextStep) {
60289         context.map().on("move.intro drawn.intro", null);
60290         context.history().on("change.intro", null);
60291         nextStep();
60292       }
60293     }
60294     function editorTownHall() {
60295       if (!isTownHallSelected())
60296         return clickTownHall();
60297       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60298       var onClick = function() {
60299         continueTo(presetTownHall);
60300       };
60301       reveal(
60302         ".entity-editor-pane",
60303         helpHtml("intro.navigation.editor_townhall"),
60304         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60305       );
60306       context.on("exit.intro", function() {
60307         continueTo(clickTownHall);
60308       });
60309       context.history().on("change.intro", function() {
60310         if (!context.hasEntity(hallId)) {
60311           continueTo(clickTownHall);
60312         }
60313       });
60314       function continueTo(nextStep) {
60315         context.on("exit.intro", null);
60316         context.history().on("change.intro", null);
60317         context.container().select(".inspector-wrap").on("wheel.intro", null);
60318         nextStep();
60319       }
60320     }
60321     function presetTownHall() {
60322       if (!isTownHallSelected())
60323         return clickTownHall();
60324       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60325       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60326       var entity = context.entity(context.selectedIDs()[0]);
60327       var preset = _mainPresetIndex.match(entity, context.graph());
60328       var onClick = function() {
60329         continueTo(fieldsTownHall);
60330       };
60331       reveal(
60332         ".entity-editor-pane .section-feature-type",
60333         helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }),
60334         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60335       );
60336       context.on("exit.intro", function() {
60337         continueTo(clickTownHall);
60338       });
60339       context.history().on("change.intro", function() {
60340         if (!context.hasEntity(hallId)) {
60341           continueTo(clickTownHall);
60342         }
60343       });
60344       function continueTo(nextStep) {
60345         context.on("exit.intro", null);
60346         context.history().on("change.intro", null);
60347         context.container().select(".inspector-wrap").on("wheel.intro", null);
60348         nextStep();
60349       }
60350     }
60351     function fieldsTownHall() {
60352       if (!isTownHallSelected())
60353         return clickTownHall();
60354       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60355       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60356       var onClick = function() {
60357         continueTo(closeTownHall);
60358       };
60359       reveal(
60360         ".entity-editor-pane .section-preset-fields",
60361         helpHtml("intro.navigation.fields_townhall"),
60362         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60363       );
60364       context.on("exit.intro", function() {
60365         continueTo(clickTownHall);
60366       });
60367       context.history().on("change.intro", function() {
60368         if (!context.hasEntity(hallId)) {
60369           continueTo(clickTownHall);
60370         }
60371       });
60372       function continueTo(nextStep) {
60373         context.on("exit.intro", null);
60374         context.history().on("change.intro", null);
60375         context.container().select(".inspector-wrap").on("wheel.intro", null);
60376         nextStep();
60377       }
60378     }
60379     function closeTownHall() {
60380       if (!isTownHallSelected())
60381         return clickTownHall();
60382       var selector = ".entity-editor-pane button.close svg use";
60383       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60384       reveal(
60385         ".entity-editor-pane",
60386         helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } })
60387       );
60388       context.on("exit.intro", function() {
60389         continueTo(searchStreet);
60390       });
60391       context.history().on("change.intro", function() {
60392         var selector2 = ".entity-editor-pane button.close svg use";
60393         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60394         reveal(
60395           ".entity-editor-pane",
60396           helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }),
60397           { duration: 0 }
60398         );
60399       });
60400       function continueTo(nextStep) {
60401         context.on("exit.intro", null);
60402         context.history().on("change.intro", null);
60403         nextStep();
60404       }
60405     }
60406     function searchStreet() {
60407       context.enter(modeBrowse(context));
60408       context.history().reset("initial");
60409       var msec = transitionTime(springStreet, context.map().center());
60410       if (msec) {
60411         reveal(null, null, { duration: 0 });
60412       }
60413       context.map().centerZoomEase(springStreet, 19, msec);
60414       timeout2(function() {
60415         reveal(
60416           ".search-header input",
60417           helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") })
60418         );
60419         context.container().select(".search-header input").on("keyup.intro", checkSearchResult);
60420       }, msec + 100);
60421     }
60422     function checkSearchResult() {
60423       var first = context.container().select(".feature-list-item:nth-child(0n+2)");
60424       var firstName = first.select(".entity-name");
60425       var name = _t("intro.graph.name.spring-street");
60426       if (!firstName.empty() && firstName.html() === name) {
60427         reveal(
60428           first.node(),
60429           helpHtml("intro.navigation.choose_street", { name }),
60430           { duration: 300 }
60431         );
60432         context.on("exit.intro", function() {
60433           continueTo(selectedStreet);
60434         });
60435         context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60436       }
60437       function continueTo(nextStep) {
60438         context.on("exit.intro", null);
60439         context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null);
60440         nextStep();
60441       }
60442     }
60443     function selectedStreet() {
60444       if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60445         return searchStreet();
60446       }
60447       var onClick = function() {
60448         continueTo(editorStreet);
60449       };
60450       var entity = context.entity(springStreetEndId);
60451       var box = pointBox(entity.loc, context);
60452       box.height = 500;
60453       reveal(
60454         box,
60455         helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60456         { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60457       );
60458       timeout2(function() {
60459         context.map().on("move.intro drawn.intro", function() {
60460           var entity2 = context.hasEntity(springStreetEndId);
60461           if (!entity2)
60462             return;
60463           var box2 = pointBox(entity2.loc, context);
60464           box2.height = 500;
60465           reveal(
60466             box2,
60467             helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60468             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60469           );
60470         });
60471       }, 600);
60472       context.on("enter.intro", function(mode) {
60473         if (!context.hasEntity(springStreetId)) {
60474           return continueTo(searchStreet);
60475         }
60476         var ids = context.selectedIDs();
60477         if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) {
60478           context.enter(modeSelect(context, [springStreetId]));
60479         }
60480       });
60481       context.history().on("change.intro", function() {
60482         if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60483           timeout2(function() {
60484             continueTo(searchStreet);
60485           }, 300);
60486         }
60487       });
60488       function continueTo(nextStep) {
60489         context.map().on("move.intro drawn.intro", null);
60490         context.on("enter.intro", null);
60491         context.history().on("change.intro", null);
60492         nextStep();
60493       }
60494     }
60495     function editorStreet() {
60496       var selector = ".entity-editor-pane button.close svg use";
60497       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60498       reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60499         button: { html: icon(href, "inline") },
60500         field1: onewayField.title(),
60501         field2: maxspeedField.title()
60502       }));
60503       context.on("exit.intro", function() {
60504         continueTo(play);
60505       });
60506       context.history().on("change.intro", function() {
60507         var selector2 = ".entity-editor-pane button.close svg use";
60508         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60509         reveal(
60510           ".entity-editor-pane",
60511           helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60512             button: { html: icon(href2, "inline") },
60513             field1: onewayField.title(),
60514             field2: maxspeedField.title()
60515           }),
60516           { duration: 0 }
60517         );
60518       });
60519       function continueTo(nextStep) {
60520         context.on("exit.intro", null);
60521         context.history().on("change.intro", null);
60522         nextStep();
60523       }
60524     }
60525     function play() {
60526       dispatch14.call("done");
60527       reveal(
60528         ".ideditor",
60529         helpHtml("intro.navigation.play", { next: _t("intro.points.title") }),
60530         {
60531           tooltipBox: ".intro-nav-wrap .chapter-point",
60532           buttonText: _t.html("intro.ok"),
60533           buttonCallback: function() {
60534             reveal(".ideditor");
60535           }
60536         }
60537       );
60538     }
60539     chapter.enter = function() {
60540       dragMap();
60541     };
60542     chapter.exit = function() {
60543       timeouts.forEach(window.clearTimeout);
60544       context.on("enter.intro exit.intro", null);
60545       context.map().on("move.intro drawn.intro", null);
60546       context.history().on("change.intro", null);
60547       context.container().select(".inspector-wrap").on("wheel.intro", null);
60548       context.container().select(".search-header input").on("keydown.intro keyup.intro", null);
60549     };
60550     chapter.restart = function() {
60551       chapter.exit();
60552       chapter.enter();
60553     };
60554     return utilRebind(chapter, dispatch14, "on");
60555   }
60556
60557   // modules/ui/intro/point.js
60558   function uiIntroPoint(context, reveal) {
60559     var dispatch14 = dispatch_default("done");
60560     var timeouts = [];
60561     var intersection2 = [-85.63279, 41.94394];
60562     var building = [-85.632422, 41.944045];
60563     var cafePreset = _mainPresetIndex.item("amenity/cafe");
60564     var _pointID = null;
60565     var chapter = {
60566       title: "intro.points.title"
60567     };
60568     function timeout2(f2, t2) {
60569       timeouts.push(window.setTimeout(f2, t2));
60570     }
60571     function eventCancel(d3_event) {
60572       d3_event.stopPropagation();
60573       d3_event.preventDefault();
60574     }
60575     function addPoint() {
60576       context.enter(modeBrowse(context));
60577       context.history().reset("initial");
60578       var msec = transitionTime(intersection2, context.map().center());
60579       if (msec) {
60580         reveal(null, null, { duration: 0 });
60581       }
60582       context.map().centerZoomEase(intersection2, 19, msec);
60583       timeout2(function() {
60584         var tooltip = reveal(
60585           "button.add-point",
60586           helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point")
60587         );
60588         _pointID = null;
60589         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points");
60590         context.on("enter.intro", function(mode) {
60591           if (mode.id !== "add-point")
60592             return;
60593           continueTo(placePoint);
60594         });
60595       }, msec + 100);
60596       function continueTo(nextStep) {
60597         context.on("enter.intro", null);
60598         nextStep();
60599       }
60600     }
60601     function placePoint() {
60602       if (context.mode().id !== "add-point") {
60603         return chapter.restart();
60604       }
60605       var pointBox2 = pad(building, 150, context);
60606       var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch";
60607       reveal(pointBox2, helpHtml("intro.points." + textId));
60608       context.map().on("move.intro drawn.intro", function() {
60609         pointBox2 = pad(building, 150, context);
60610         reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 });
60611       });
60612       context.on("enter.intro", function(mode) {
60613         if (mode.id !== "select")
60614           return chapter.restart();
60615         _pointID = context.mode().selectedIDs()[0];
60616         continueTo(searchPreset);
60617       });
60618       function continueTo(nextStep) {
60619         context.map().on("move.intro drawn.intro", null);
60620         context.on("enter.intro", null);
60621         nextStep();
60622       }
60623     }
60624     function searchPreset() {
60625       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60626         return addPoint();
60627       }
60628       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60629       context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60630       reveal(
60631         ".preset-search-input",
60632         helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60633       );
60634       context.on("enter.intro", function(mode) {
60635         if (!_pointID || !context.hasEntity(_pointID)) {
60636           return continueTo(addPoint);
60637         }
60638         var ids = context.selectedIDs();
60639         if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) {
60640           context.enter(modeSelect(context, [_pointID]));
60641           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60642           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60643           reveal(
60644             ".preset-search-input",
60645             helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60646           );
60647           context.history().on("change.intro", null);
60648         }
60649       });
60650       function checkPresetSearch() {
60651         var first = context.container().select(".preset-list-item:first-child");
60652         if (first.classed("preset-amenity-cafe")) {
60653           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60654           reveal(
60655             first.select(".preset-list-button").node(),
60656             helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }),
60657             { duration: 300 }
60658           );
60659           context.history().on("change.intro", function() {
60660             continueTo(aboutFeatureEditor);
60661           });
60662         }
60663       }
60664       function continueTo(nextStep) {
60665         context.on("enter.intro", null);
60666         context.history().on("change.intro", null);
60667         context.container().select(".inspector-wrap").on("wheel.intro", null);
60668         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60669         nextStep();
60670       }
60671     }
60672     function aboutFeatureEditor() {
60673       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60674         return addPoint();
60675       }
60676       timeout2(function() {
60677         reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), {
60678           tooltipClass: "intro-points-describe",
60679           buttonText: _t.html("intro.ok"),
60680           buttonCallback: function() {
60681             continueTo(addName);
60682           }
60683         });
60684       }, 400);
60685       context.on("exit.intro", function() {
60686         continueTo(reselectPoint);
60687       });
60688       function continueTo(nextStep) {
60689         context.on("exit.intro", null);
60690         nextStep();
60691       }
60692     }
60693     function addName() {
60694       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60695         return addPoint();
60696       }
60697       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60698       var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name");
60699       timeout2(function() {
60700         var entity = context.entity(_pointID);
60701         if (entity.tags.name) {
60702           var tooltip = reveal(".entity-editor-pane", addNameString, {
60703             tooltipClass: "intro-points-describe",
60704             buttonText: _t.html("intro.ok"),
60705             buttonCallback: function() {
60706               continueTo(addCloseEditor);
60707             }
60708           });
60709           tooltip.select(".instruction").style("display", "none");
60710         } else {
60711           reveal(
60712             ".entity-editor-pane",
60713             addNameString,
60714             { tooltipClass: "intro-points-describe" }
60715           );
60716         }
60717       }, 400);
60718       context.history().on("change.intro", function() {
60719         continueTo(addCloseEditor);
60720       });
60721       context.on("exit.intro", function() {
60722         continueTo(reselectPoint);
60723       });
60724       function continueTo(nextStep) {
60725         context.on("exit.intro", null);
60726         context.history().on("change.intro", null);
60727         nextStep();
60728       }
60729     }
60730     function addCloseEditor() {
60731       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60732       var selector = ".entity-editor-pane button.close svg use";
60733       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60734       context.on("exit.intro", function() {
60735         continueTo(reselectPoint);
60736       });
60737       reveal(
60738         ".entity-editor-pane",
60739         helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } })
60740       );
60741       function continueTo(nextStep) {
60742         context.on("exit.intro", null);
60743         nextStep();
60744       }
60745     }
60746     function reselectPoint() {
60747       if (!_pointID)
60748         return chapter.restart();
60749       var entity = context.hasEntity(_pointID);
60750       if (!entity)
60751         return chapter.restart();
60752       var oldPreset = _mainPresetIndex.match(entity, context.graph());
60753       context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
60754       context.enter(modeBrowse(context));
60755       var msec = transitionTime(entity.loc, context.map().center());
60756       if (msec) {
60757         reveal(null, null, { duration: 0 });
60758       }
60759       context.map().centerEase(entity.loc, msec);
60760       timeout2(function() {
60761         var box = pointBox(entity.loc, context);
60762         reveal(box, helpHtml("intro.points.reselect"), { duration: 600 });
60763         timeout2(function() {
60764           context.map().on("move.intro drawn.intro", function() {
60765             var entity2 = context.hasEntity(_pointID);
60766             if (!entity2)
60767               return chapter.restart();
60768             var box2 = pointBox(entity2.loc, context);
60769             reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 });
60770           });
60771         }, 600);
60772         context.on("enter.intro", function(mode) {
60773           if (mode.id !== "select")
60774             return;
60775           continueTo(updatePoint);
60776         });
60777       }, msec + 100);
60778       function continueTo(nextStep) {
60779         context.map().on("move.intro drawn.intro", null);
60780         context.on("enter.intro", null);
60781         nextStep();
60782       }
60783     }
60784     function updatePoint() {
60785       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60786         return continueTo(reselectPoint);
60787       }
60788       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60789       context.on("exit.intro", function() {
60790         continueTo(reselectPoint);
60791       });
60792       context.history().on("change.intro", function() {
60793         continueTo(updateCloseEditor);
60794       });
60795       timeout2(function() {
60796         reveal(
60797           ".entity-editor-pane",
60798           helpHtml("intro.points.update"),
60799           { tooltipClass: "intro-points-describe" }
60800         );
60801       }, 400);
60802       function continueTo(nextStep) {
60803         context.on("exit.intro", null);
60804         context.history().on("change.intro", null);
60805         nextStep();
60806       }
60807     }
60808     function updateCloseEditor() {
60809       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60810         return continueTo(reselectPoint);
60811       }
60812       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60813       context.on("exit.intro", function() {
60814         continueTo(rightClickPoint);
60815       });
60816       timeout2(function() {
60817         reveal(
60818           ".entity-editor-pane",
60819           helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } })
60820         );
60821       }, 500);
60822       function continueTo(nextStep) {
60823         context.on("exit.intro", null);
60824         nextStep();
60825       }
60826     }
60827     function rightClickPoint() {
60828       if (!_pointID)
60829         return chapter.restart();
60830       var entity = context.hasEntity(_pointID);
60831       if (!entity)
60832         return chapter.restart();
60833       context.enter(modeBrowse(context));
60834       var box = pointBox(entity.loc, context);
60835       var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch";
60836       reveal(box, helpHtml("intro.points." + textId), { duration: 600 });
60837       timeout2(function() {
60838         context.map().on("move.intro", function() {
60839           var entity2 = context.hasEntity(_pointID);
60840           if (!entity2)
60841             return chapter.restart();
60842           var box2 = pointBox(entity2.loc, context);
60843           reveal(box2, helpHtml("intro.points." + textId), { duration: 0 });
60844         });
60845       }, 600);
60846       context.on("enter.intro", function(mode) {
60847         if (mode.id !== "select")
60848           return;
60849         var ids = context.selectedIDs();
60850         if (ids.length !== 1 || ids[0] !== _pointID)
60851           return;
60852         timeout2(function() {
60853           var node = selectMenuItem(context, "delete").node();
60854           if (!node)
60855             return;
60856           continueTo(enterDelete);
60857         }, 50);
60858       });
60859       function continueTo(nextStep) {
60860         context.on("enter.intro", null);
60861         context.map().on("move.intro", null);
60862         nextStep();
60863       }
60864     }
60865     function enterDelete() {
60866       if (!_pointID)
60867         return chapter.restart();
60868       var entity = context.hasEntity(_pointID);
60869       if (!entity)
60870         return chapter.restart();
60871       var node = selectMenuItem(context, "delete").node();
60872       if (!node) {
60873         return continueTo(rightClickPoint);
60874       }
60875       reveal(
60876         ".edit-menu",
60877         helpHtml("intro.points.delete"),
60878         { padding: 50 }
60879       );
60880       timeout2(function() {
60881         context.map().on("move.intro", function() {
60882           reveal(
60883             ".edit-menu",
60884             helpHtml("intro.points.delete"),
60885             { duration: 0, padding: 50 }
60886           );
60887         });
60888       }, 300);
60889       context.on("exit.intro", function() {
60890         if (!_pointID)
60891           return chapter.restart();
60892         var entity2 = context.hasEntity(_pointID);
60893         if (entity2)
60894           return continueTo(rightClickPoint);
60895       });
60896       context.history().on("change.intro", function(changed) {
60897         if (changed.deleted().length) {
60898           continueTo(undo);
60899         }
60900       });
60901       function continueTo(nextStep) {
60902         context.map().on("move.intro", null);
60903         context.history().on("change.intro", null);
60904         context.on("exit.intro", null);
60905         nextStep();
60906       }
60907     }
60908     function undo() {
60909       context.history().on("change.intro", function() {
60910         continueTo(play);
60911       });
60912       reveal(
60913         ".top-toolbar button.undo-button",
60914         helpHtml("intro.points.undo")
60915       );
60916       function continueTo(nextStep) {
60917         context.history().on("change.intro", null);
60918         nextStep();
60919       }
60920     }
60921     function play() {
60922       dispatch14.call("done");
60923       reveal(
60924         ".ideditor",
60925         helpHtml("intro.points.play", { next: _t("intro.areas.title") }),
60926         {
60927           tooltipBox: ".intro-nav-wrap .chapter-area",
60928           buttonText: _t.html("intro.ok"),
60929           buttonCallback: function() {
60930             reveal(".ideditor");
60931           }
60932         }
60933       );
60934     }
60935     chapter.enter = function() {
60936       addPoint();
60937     };
60938     chapter.exit = function() {
60939       timeouts.forEach(window.clearTimeout);
60940       context.on("enter.intro exit.intro", null);
60941       context.map().on("move.intro drawn.intro", null);
60942       context.history().on("change.intro", null);
60943       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60944       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60945     };
60946     chapter.restart = function() {
60947       chapter.exit();
60948       chapter.enter();
60949     };
60950     return utilRebind(chapter, dispatch14, "on");
60951   }
60952
60953   // modules/ui/intro/area.js
60954   function uiIntroArea(context, reveal) {
60955     var dispatch14 = dispatch_default("done");
60956     var playground = [-85.63552, 41.94159];
60957     var playgroundPreset = _mainPresetIndex.item("leisure/playground");
60958     var nameField = _mainPresetIndex.field("name");
60959     var descriptionField = _mainPresetIndex.field("description");
60960     var timeouts = [];
60961     var _areaID;
60962     var chapter = {
60963       title: "intro.areas.title"
60964     };
60965     function timeout2(f2, t2) {
60966       timeouts.push(window.setTimeout(f2, t2));
60967     }
60968     function eventCancel(d3_event) {
60969       d3_event.stopPropagation();
60970       d3_event.preventDefault();
60971     }
60972     function revealPlayground(center, text, options2) {
60973       var padding = 180 * Math.pow(2, context.map().zoom() - 19.5);
60974       var box = pad(center, padding, context);
60975       reveal(box, text, options2);
60976     }
60977     function addArea() {
60978       context.enter(modeBrowse(context));
60979       context.history().reset("initial");
60980       _areaID = null;
60981       var msec = transitionTime(playground, context.map().center());
60982       if (msec) {
60983         reveal(null, null, { duration: 0 });
60984       }
60985       context.map().centerZoomEase(playground, 19, msec);
60986       timeout2(function() {
60987         var tooltip = reveal(
60988           "button.add-area",
60989           helpHtml("intro.areas.add_playground")
60990         );
60991         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas");
60992         context.on("enter.intro", function(mode) {
60993           if (mode.id !== "add-area")
60994             return;
60995           continueTo(startPlayground);
60996         });
60997       }, msec + 100);
60998       function continueTo(nextStep) {
60999         context.on("enter.intro", null);
61000         nextStep();
61001       }
61002     }
61003     function startPlayground() {
61004       if (context.mode().id !== "add-area") {
61005         return chapter.restart();
61006       }
61007       _areaID = null;
61008       context.map().zoomEase(19.5, 500);
61009       timeout2(function() {
61010         var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap";
61011         var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId);
61012         revealPlayground(
61013           playground,
61014           startDrawString,
61015           { duration: 250 }
61016         );
61017         timeout2(function() {
61018           context.map().on("move.intro drawn.intro", function() {
61019             revealPlayground(
61020               playground,
61021               startDrawString,
61022               { duration: 0 }
61023             );
61024           });
61025           context.on("enter.intro", function(mode) {
61026             if (mode.id !== "draw-area")
61027               return chapter.restart();
61028             continueTo(continuePlayground);
61029           });
61030         }, 250);
61031       }, 550);
61032       function continueTo(nextStep) {
61033         context.map().on("move.intro drawn.intro", null);
61034         context.on("enter.intro", null);
61035         nextStep();
61036       }
61037     }
61038     function continuePlayground() {
61039       if (context.mode().id !== "draw-area") {
61040         return chapter.restart();
61041       }
61042       _areaID = null;
61043       revealPlayground(
61044         playground,
61045         helpHtml("intro.areas.continue_playground"),
61046         { duration: 250 }
61047       );
61048       timeout2(function() {
61049         context.map().on("move.intro drawn.intro", function() {
61050           revealPlayground(
61051             playground,
61052             helpHtml("intro.areas.continue_playground"),
61053             { duration: 0 }
61054           );
61055         });
61056       }, 250);
61057       context.on("enter.intro", function(mode) {
61058         if (mode.id === "draw-area") {
61059           var entity = context.hasEntity(context.selectedIDs()[0]);
61060           if (entity && entity.nodes.length >= 6) {
61061             return continueTo(finishPlayground);
61062           } else {
61063             return;
61064           }
61065         } else if (mode.id === "select") {
61066           _areaID = context.selectedIDs()[0];
61067           return continueTo(searchPresets);
61068         } else {
61069           return chapter.restart();
61070         }
61071       });
61072       function continueTo(nextStep) {
61073         context.map().on("move.intro drawn.intro", null);
61074         context.on("enter.intro", null);
61075         nextStep();
61076       }
61077     }
61078     function finishPlayground() {
61079       if (context.mode().id !== "draw-area") {
61080         return chapter.restart();
61081       }
61082       _areaID = null;
61083       var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground");
61084       revealPlayground(
61085         playground,
61086         finishString,
61087         { duration: 250 }
61088       );
61089       timeout2(function() {
61090         context.map().on("move.intro drawn.intro", function() {
61091           revealPlayground(
61092             playground,
61093             finishString,
61094             { duration: 0 }
61095           );
61096         });
61097       }, 250);
61098       context.on("enter.intro", function(mode) {
61099         if (mode.id === "draw-area") {
61100           return;
61101         } else if (mode.id === "select") {
61102           _areaID = context.selectedIDs()[0];
61103           return continueTo(searchPresets);
61104         } else {
61105           return chapter.restart();
61106         }
61107       });
61108       function continueTo(nextStep) {
61109         context.map().on("move.intro drawn.intro", null);
61110         context.on("enter.intro", null);
61111         nextStep();
61112       }
61113     }
61114     function searchPresets() {
61115       if (!_areaID || !context.hasEntity(_areaID)) {
61116         return addArea();
61117       }
61118       var ids = context.selectedIDs();
61119       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61120         context.enter(modeSelect(context, [_areaID]));
61121       }
61122       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61123       timeout2(function() {
61124         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61125         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61126         reveal(
61127           ".preset-search-input",
61128           helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61129         );
61130       }, 400);
61131       context.on("enter.intro", function(mode) {
61132         if (!_areaID || !context.hasEntity(_areaID)) {
61133           return continueTo(addArea);
61134         }
61135         var ids2 = context.selectedIDs();
61136         if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) {
61137           context.enter(modeSelect(context, [_areaID]));
61138           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61139           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61140           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61141           reveal(
61142             ".preset-search-input",
61143             helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61144           );
61145           context.history().on("change.intro", null);
61146         }
61147       });
61148       function checkPresetSearch() {
61149         var first = context.container().select(".preset-list-item:first-child");
61150         if (first.classed("preset-leisure-playground")) {
61151           reveal(
61152             first.select(".preset-list-button").node(),
61153             helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }),
61154             { duration: 300 }
61155           );
61156           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
61157           context.history().on("change.intro", function() {
61158             continueTo(clickAddField);
61159           });
61160         }
61161       }
61162       function continueTo(nextStep) {
61163         context.container().select(".inspector-wrap").on("wheel.intro", null);
61164         context.on("enter.intro", null);
61165         context.history().on("change.intro", null);
61166         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61167         nextStep();
61168       }
61169     }
61170     function clickAddField() {
61171       if (!_areaID || !context.hasEntity(_areaID)) {
61172         return addArea();
61173       }
61174       var ids = context.selectedIDs();
61175       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61176         return searchPresets();
61177       }
61178       if (!context.container().select(".form-field-description").empty()) {
61179         return continueTo(describePlayground);
61180       }
61181       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61182       timeout2(function() {
61183         context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61184         var entity = context.entity(_areaID);
61185         if (entity.tags.description) {
61186           return continueTo(play);
61187         }
61188         var box = context.container().select(".more-fields").node().getBoundingClientRect();
61189         if (box.top > 300) {
61190           var pane = context.container().select(".entity-editor-pane .inspector-body");
61191           var start2 = pane.node().scrollTop;
61192           var end = start2 + (box.top - 300);
61193           pane.transition().duration(250).tween("scroll.inspector", function() {
61194             var node = this;
61195             var i3 = number_default(start2, end);
61196             return function(t2) {
61197               node.scrollTop = i3(t2);
61198             };
61199           });
61200         }
61201         timeout2(function() {
61202           reveal(
61203             ".more-fields .combobox-input",
61204             helpHtml("intro.areas.add_field", {
61205               name: nameField.title(),
61206               description: descriptionField.title()
61207             }),
61208             { duration: 300 }
61209           );
61210           context.container().select(".more-fields .combobox-input").on("click.intro", function() {
61211             var watcher;
61212             watcher = window.setInterval(function() {
61213               if (!context.container().select("div.combobox").empty()) {
61214                 window.clearInterval(watcher);
61215                 continueTo(chooseDescriptionField);
61216               }
61217             }, 300);
61218           });
61219         }, 300);
61220       }, 400);
61221       context.on("exit.intro", function() {
61222         return continueTo(searchPresets);
61223       });
61224       function continueTo(nextStep) {
61225         context.container().select(".inspector-wrap").on("wheel.intro", null);
61226         context.container().select(".more-fields .combobox-input").on("click.intro", null);
61227         context.on("exit.intro", null);
61228         nextStep();
61229       }
61230     }
61231     function chooseDescriptionField() {
61232       if (!_areaID || !context.hasEntity(_areaID)) {
61233         return addArea();
61234       }
61235       var ids = context.selectedIDs();
61236       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61237         return searchPresets();
61238       }
61239       if (!context.container().select(".form-field-description").empty()) {
61240         return continueTo(describePlayground);
61241       }
61242       if (context.container().select("div.combobox").empty()) {
61243         return continueTo(clickAddField);
61244       }
61245       var watcher;
61246       watcher = window.setInterval(function() {
61247         if (context.container().select("div.combobox").empty()) {
61248           window.clearInterval(watcher);
61249           timeout2(function() {
61250             if (context.container().select(".form-field-description").empty()) {
61251               continueTo(retryChooseDescription);
61252             } else {
61253               continueTo(describePlayground);
61254             }
61255           }, 300);
61256         }
61257       }, 300);
61258       reveal(
61259         "div.combobox",
61260         helpHtml("intro.areas.choose_field", { field: descriptionField.title() }),
61261         { duration: 300 }
61262       );
61263       context.on("exit.intro", function() {
61264         return continueTo(searchPresets);
61265       });
61266       function continueTo(nextStep) {
61267         if (watcher)
61268           window.clearInterval(watcher);
61269         context.on("exit.intro", null);
61270         nextStep();
61271       }
61272     }
61273     function describePlayground() {
61274       if (!_areaID || !context.hasEntity(_areaID)) {
61275         return addArea();
61276       }
61277       var ids = context.selectedIDs();
61278       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61279         return searchPresets();
61280       }
61281       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61282       if (context.container().select(".form-field-description").empty()) {
61283         return continueTo(retryChooseDescription);
61284       }
61285       context.on("exit.intro", function() {
61286         continueTo(play);
61287       });
61288       reveal(
61289         ".entity-editor-pane",
61290         helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }),
61291         { duration: 300 }
61292       );
61293       function continueTo(nextStep) {
61294         context.on("exit.intro", null);
61295         nextStep();
61296       }
61297     }
61298     function retryChooseDescription() {
61299       if (!_areaID || !context.hasEntity(_areaID)) {
61300         return addArea();
61301       }
61302       var ids = context.selectedIDs();
61303       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61304         return searchPresets();
61305       }
61306       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61307       reveal(
61308         ".entity-editor-pane",
61309         helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }),
61310         {
61311           buttonText: _t.html("intro.ok"),
61312           buttonCallback: function() {
61313             continueTo(clickAddField);
61314           }
61315         }
61316       );
61317       context.on("exit.intro", function() {
61318         return continueTo(searchPresets);
61319       });
61320       function continueTo(nextStep) {
61321         context.on("exit.intro", null);
61322         nextStep();
61323       }
61324     }
61325     function play() {
61326       dispatch14.call("done");
61327       reveal(
61328         ".ideditor",
61329         helpHtml("intro.areas.play", { next: _t("intro.lines.title") }),
61330         {
61331           tooltipBox: ".intro-nav-wrap .chapter-line",
61332           buttonText: _t.html("intro.ok"),
61333           buttonCallback: function() {
61334             reveal(".ideditor");
61335           }
61336         }
61337       );
61338     }
61339     chapter.enter = function() {
61340       addArea();
61341     };
61342     chapter.exit = function() {
61343       timeouts.forEach(window.clearTimeout);
61344       context.on("enter.intro exit.intro", null);
61345       context.map().on("move.intro drawn.intro", null);
61346       context.history().on("change.intro", null);
61347       context.container().select(".inspector-wrap").on("wheel.intro", null);
61348       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61349       context.container().select(".more-fields .combobox-input").on("click.intro", null);
61350     };
61351     chapter.restart = function() {
61352       chapter.exit();
61353       chapter.enter();
61354     };
61355     return utilRebind(chapter, dispatch14, "on");
61356   }
61357
61358   // modules/ui/intro/line.js
61359   function uiIntroLine(context, reveal) {
61360     var dispatch14 = dispatch_default("done");
61361     var timeouts = [];
61362     var _tulipRoadID = null;
61363     var flowerRoadID = "w646";
61364     var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
61365     var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
61366     var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
61367     var roadCategory = _mainPresetIndex.item("category-road_minor");
61368     var residentialPreset = _mainPresetIndex.item("highway/residential");
61369     var woodRoadID = "w525";
61370     var woodRoadEndID = "n2862";
61371     var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
61372     var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
61373     var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
61374     var washingtonStreetID = "w522";
61375     var twelfthAvenueID = "w1";
61376     var eleventhAvenueEndID = "n3550";
61377     var twelfthAvenueEndID = "n5";
61378     var _washingtonSegmentID = null;
61379     var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
61380     var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
61381     var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
61382     var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
61383     var chapter = {
61384       title: "intro.lines.title"
61385     };
61386     function timeout2(f2, t2) {
61387       timeouts.push(window.setTimeout(f2, t2));
61388     }
61389     function eventCancel(d3_event) {
61390       d3_event.stopPropagation();
61391       d3_event.preventDefault();
61392     }
61393     function addLine() {
61394       context.enter(modeBrowse(context));
61395       context.history().reset("initial");
61396       var msec = transitionTime(tulipRoadStart, context.map().center());
61397       if (msec) {
61398         reveal(null, null, { duration: 0 });
61399       }
61400       context.map().centerZoomEase(tulipRoadStart, 18.5, msec);
61401       timeout2(function() {
61402         var tooltip = reveal(
61403           "button.add-line",
61404           helpHtml("intro.lines.add_line")
61405         );
61406         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines");
61407         context.on("enter.intro", function(mode) {
61408           if (mode.id !== "add-line")
61409             return;
61410           continueTo(startLine);
61411         });
61412       }, msec + 100);
61413       function continueTo(nextStep) {
61414         context.on("enter.intro", null);
61415         nextStep();
61416       }
61417     }
61418     function startLine() {
61419       if (context.mode().id !== "add-line")
61420         return chapter.restart();
61421       _tulipRoadID = null;
61422       var padding = 70 * Math.pow(2, context.map().zoom() - 18);
61423       var box = pad(tulipRoadStart, padding, context);
61424       box.height = box.height + 100;
61425       var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap";
61426       var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId);
61427       reveal(box, startLineString);
61428       context.map().on("move.intro drawn.intro", function() {
61429         padding = 70 * Math.pow(2, context.map().zoom() - 18);
61430         box = pad(tulipRoadStart, padding, context);
61431         box.height = box.height + 100;
61432         reveal(box, startLineString, { duration: 0 });
61433       });
61434       context.on("enter.intro", function(mode) {
61435         if (mode.id !== "draw-line")
61436           return chapter.restart();
61437         continueTo(drawLine);
61438       });
61439       function continueTo(nextStep) {
61440         context.map().on("move.intro drawn.intro", null);
61441         context.on("enter.intro", null);
61442         nextStep();
61443       }
61444     }
61445     function drawLine() {
61446       if (context.mode().id !== "draw-line")
61447         return chapter.restart();
61448       _tulipRoadID = context.mode().selectedIDs()[0];
61449       context.map().centerEase(tulipRoadMidpoint, 500);
61450       timeout2(function() {
61451         var padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61452         var box = pad(tulipRoadMidpoint, padding, context);
61453         box.height = box.height * 2;
61454         reveal(
61455           box,
61456           helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") })
61457         );
61458         context.map().on("move.intro drawn.intro", function() {
61459           padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61460           box = pad(tulipRoadMidpoint, padding, context);
61461           box.height = box.height * 2;
61462           reveal(
61463             box,
61464             helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }),
61465             { duration: 0 }
61466           );
61467         });
61468       }, 550);
61469       context.history().on("change.intro", function() {
61470         if (isLineConnected()) {
61471           continueTo(continueLine);
61472         }
61473       });
61474       context.on("enter.intro", function(mode) {
61475         if (mode.id === "draw-line") {
61476           return;
61477         } else if (mode.id === "select") {
61478           continueTo(retryIntersect);
61479           return;
61480         } else {
61481           return chapter.restart();
61482         }
61483       });
61484       function continueTo(nextStep) {
61485         context.map().on("move.intro drawn.intro", null);
61486         context.history().on("change.intro", null);
61487         context.on("enter.intro", null);
61488         nextStep();
61489       }
61490     }
61491     function isLineConnected() {
61492       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61493       if (!entity)
61494         return false;
61495       var drawNodes = context.graph().childNodes(entity);
61496       return drawNodes.some(function(node) {
61497         return context.graph().parentWays(node).some(function(parent) {
61498           return parent.id === flowerRoadID;
61499         });
61500       });
61501     }
61502     function retryIntersect() {
61503       select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true);
61504       var box = pad(tulipRoadIntersection, 80, context);
61505       reveal(
61506         box,
61507         helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") })
61508       );
61509       timeout2(chapter.restart, 3e3);
61510     }
61511     function continueLine() {
61512       if (context.mode().id !== "draw-line")
61513         return chapter.restart();
61514       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61515       if (!entity)
61516         return chapter.restart();
61517       context.map().centerEase(tulipRoadIntersection, 500);
61518       var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road");
61519       reveal(".surface", continueLineText);
61520       context.on("enter.intro", function(mode) {
61521         if (mode.id === "draw-line") {
61522           return;
61523         } else if (mode.id === "select") {
61524           return continueTo(chooseCategoryRoad);
61525         } else {
61526           return chapter.restart();
61527         }
61528       });
61529       function continueTo(nextStep) {
61530         context.on("enter.intro", null);
61531         nextStep();
61532       }
61533     }
61534     function chooseCategoryRoad() {
61535       if (context.mode().id !== "select")
61536         return chapter.restart();
61537       context.on("exit.intro", function() {
61538         return chapter.restart();
61539       });
61540       var button = context.container().select(".preset-category-road_minor .preset-list-button");
61541       if (button.empty())
61542         return chapter.restart();
61543       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61544       timeout2(function() {
61545         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61546         reveal(
61547           button.node(),
61548           helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() })
61549         );
61550         button.on("click.intro", function() {
61551           continueTo(choosePresetResidential);
61552         });
61553       }, 400);
61554       function continueTo(nextStep) {
61555         context.container().select(".inspector-wrap").on("wheel.intro", null);
61556         context.container().select(".preset-list-button").on("click.intro", null);
61557         context.on("exit.intro", null);
61558         nextStep();
61559       }
61560     }
61561     function choosePresetResidential() {
61562       if (context.mode().id !== "select")
61563         return chapter.restart();
61564       context.on("exit.intro", function() {
61565         return chapter.restart();
61566       });
61567       var subgrid = context.container().select(".preset-category-road_minor .subgrid");
61568       if (subgrid.empty())
61569         return chapter.restart();
61570       subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() {
61571         continueTo(retryPresetResidential);
61572       });
61573       subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() {
61574         continueTo(nameRoad);
61575       });
61576       timeout2(function() {
61577         reveal(
61578           subgrid.node(),
61579           helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }),
61580           { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 }
61581         );
61582       }, 300);
61583       function continueTo(nextStep) {
61584         context.container().select(".preset-list-button").on("click.intro", null);
61585         context.on("exit.intro", null);
61586         nextStep();
61587       }
61588     }
61589     function retryPresetResidential() {
61590       if (context.mode().id !== "select")
61591         return chapter.restart();
61592       context.on("exit.intro", function() {
61593         return chapter.restart();
61594       });
61595       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61596       timeout2(function() {
61597         var button = context.container().select(".entity-editor-pane .preset-list-button");
61598         reveal(
61599           button.node(),
61600           helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() })
61601         );
61602         button.on("click.intro", function() {
61603           continueTo(chooseCategoryRoad);
61604         });
61605       }, 500);
61606       function continueTo(nextStep) {
61607         context.container().select(".inspector-wrap").on("wheel.intro", null);
61608         context.container().select(".preset-list-button").on("click.intro", null);
61609         context.on("exit.intro", null);
61610         nextStep();
61611       }
61612     }
61613     function nameRoad() {
61614       context.on("exit.intro", function() {
61615         continueTo(didNameRoad);
61616       });
61617       timeout2(function() {
61618         reveal(
61619           ".entity-editor-pane",
61620           helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }),
61621           { tooltipClass: "intro-lines-name_road" }
61622         );
61623       }, 500);
61624       function continueTo(nextStep) {
61625         context.on("exit.intro", null);
61626         nextStep();
61627       }
61628     }
61629     function didNameRoad() {
61630       context.history().checkpoint("doneAddLine");
61631       timeout2(function() {
61632         reveal(".surface", helpHtml("intro.lines.did_name_road"), {
61633           buttonText: _t.html("intro.ok"),
61634           buttonCallback: function() {
61635             continueTo(updateLine);
61636           }
61637         });
61638       }, 500);
61639       function continueTo(nextStep) {
61640         nextStep();
61641       }
61642     }
61643     function updateLine() {
61644       context.history().reset("doneAddLine");
61645       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61646         return chapter.restart();
61647       }
61648       var msec = transitionTime(woodRoadDragMidpoint, context.map().center());
61649       if (msec) {
61650         reveal(null, null, { duration: 0 });
61651       }
61652       context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec);
61653       timeout2(function() {
61654         var padding = 250 * Math.pow(2, context.map().zoom() - 19);
61655         var box = pad(woodRoadDragMidpoint, padding, context);
61656         var advance = function() {
61657           continueTo(addNode);
61658         };
61659         reveal(
61660           box,
61661           helpHtml("intro.lines.update_line"),
61662           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61663         );
61664         context.map().on("move.intro drawn.intro", function() {
61665           var padding2 = 250 * Math.pow(2, context.map().zoom() - 19);
61666           var box2 = pad(woodRoadDragMidpoint, padding2, context);
61667           reveal(
61668             box2,
61669             helpHtml("intro.lines.update_line"),
61670             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61671           );
61672         });
61673       }, msec + 100);
61674       function continueTo(nextStep) {
61675         context.map().on("move.intro drawn.intro", null);
61676         nextStep();
61677       }
61678     }
61679     function addNode() {
61680       context.history().reset("doneAddLine");
61681       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61682         return chapter.restart();
61683       }
61684       var padding = 40 * Math.pow(2, context.map().zoom() - 19);
61685       var box = pad(woodRoadAddNode, padding, context);
61686       var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61687       reveal(box, addNodeString);
61688       context.map().on("move.intro drawn.intro", function() {
61689         var padding2 = 40 * Math.pow(2, context.map().zoom() - 19);
61690         var box2 = pad(woodRoadAddNode, padding2, context);
61691         reveal(box2, addNodeString, { duration: 0 });
61692       });
61693       context.history().on("change.intro", function(changed) {
61694         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61695           return continueTo(updateLine);
61696         }
61697         if (changed.created().length === 1) {
61698           timeout2(function() {
61699             continueTo(startDragEndpoint);
61700           }, 500);
61701         }
61702       });
61703       context.on("enter.intro", function(mode) {
61704         if (mode.id !== "select") {
61705           continueTo(updateLine);
61706         }
61707       });
61708       function continueTo(nextStep) {
61709         context.map().on("move.intro drawn.intro", null);
61710         context.history().on("change.intro", null);
61711         context.on("enter.intro", null);
61712         nextStep();
61713       }
61714     }
61715     function startDragEndpoint() {
61716       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61717         return continueTo(updateLine);
61718       }
61719       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61720       var box = pad(woodRoadDragEndpoint, padding, context);
61721       var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection");
61722       reveal(box, startDragString);
61723       context.map().on("move.intro drawn.intro", function() {
61724         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61725           return continueTo(updateLine);
61726         }
61727         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61728         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61729         reveal(box2, startDragString, { duration: 0 });
61730         var entity = context.entity(woodRoadEndID);
61731         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
61732           continueTo(finishDragEndpoint);
61733         }
61734       });
61735       function continueTo(nextStep) {
61736         context.map().on("move.intro drawn.intro", null);
61737         nextStep();
61738       }
61739     }
61740     function finishDragEndpoint() {
61741       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61742         return continueTo(updateLine);
61743       }
61744       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61745       var box = pad(woodRoadDragEndpoint, padding, context);
61746       var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61747       reveal(box, finishDragString);
61748       context.map().on("move.intro drawn.intro", function() {
61749         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61750           return continueTo(updateLine);
61751         }
61752         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61753         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61754         reveal(box2, finishDragString, { duration: 0 });
61755         var entity = context.entity(woodRoadEndID);
61756         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
61757           continueTo(startDragEndpoint);
61758         }
61759       });
61760       context.on("enter.intro", function() {
61761         continueTo(startDragMidpoint);
61762       });
61763       function continueTo(nextStep) {
61764         context.map().on("move.intro drawn.intro", null);
61765         context.on("enter.intro", null);
61766         nextStep();
61767       }
61768     }
61769     function startDragMidpoint() {
61770       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61771         return continueTo(updateLine);
61772       }
61773       if (context.selectedIDs().indexOf(woodRoadID) === -1) {
61774         context.enter(modeSelect(context, [woodRoadID]));
61775       }
61776       var padding = 80 * Math.pow(2, context.map().zoom() - 19);
61777       var box = pad(woodRoadDragMidpoint, padding, context);
61778       reveal(box, helpHtml("intro.lines.start_drag_midpoint"));
61779       context.map().on("move.intro drawn.intro", function() {
61780         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61781           return continueTo(updateLine);
61782         }
61783         var padding2 = 80 * Math.pow(2, context.map().zoom() - 19);
61784         var box2 = pad(woodRoadDragMidpoint, padding2, context);
61785         reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 });
61786       });
61787       context.history().on("change.intro", function(changed) {
61788         if (changed.created().length === 1) {
61789           continueTo(continueDragMidpoint);
61790         }
61791       });
61792       context.on("enter.intro", function(mode) {
61793         if (mode.id !== "select") {
61794           context.enter(modeSelect(context, [woodRoadID]));
61795         }
61796       });
61797       function continueTo(nextStep) {
61798         context.map().on("move.intro drawn.intro", null);
61799         context.history().on("change.intro", null);
61800         context.on("enter.intro", null);
61801         nextStep();
61802       }
61803     }
61804     function continueDragMidpoint() {
61805       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61806         return continueTo(updateLine);
61807       }
61808       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61809       var box = pad(woodRoadDragEndpoint, padding, context);
61810       box.height += 400;
61811       var advance = function() {
61812         context.history().checkpoint("doneUpdateLine");
61813         continueTo(deleteLines);
61814       };
61815       reveal(
61816         box,
61817         helpHtml("intro.lines.continue_drag_midpoint"),
61818         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61819       );
61820       context.map().on("move.intro drawn.intro", function() {
61821         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61822           return continueTo(updateLine);
61823         }
61824         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61825         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61826         box2.height += 400;
61827         reveal(
61828           box2,
61829           helpHtml("intro.lines.continue_drag_midpoint"),
61830           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61831         );
61832       });
61833       function continueTo(nextStep) {
61834         context.map().on("move.intro drawn.intro", null);
61835         nextStep();
61836       }
61837     }
61838     function deleteLines() {
61839       context.history().reset("doneUpdateLine");
61840       context.enter(modeBrowse(context));
61841       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61842         return chapter.restart();
61843       }
61844       var msec = transitionTime(deleteLinesLoc, context.map().center());
61845       if (msec) {
61846         reveal(null, null, { duration: 0 });
61847       }
61848       context.map().centerZoomEase(deleteLinesLoc, 18, msec);
61849       timeout2(function() {
61850         var padding = 200 * Math.pow(2, context.map().zoom() - 18);
61851         var box = pad(deleteLinesLoc, padding, context);
61852         box.top -= 200;
61853         box.height += 400;
61854         var advance = function() {
61855           continueTo(rightClickIntersection);
61856         };
61857         reveal(
61858           box,
61859           helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61860           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61861         );
61862         context.map().on("move.intro drawn.intro", function() {
61863           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
61864           var box2 = pad(deleteLinesLoc, padding2, context);
61865           box2.top -= 200;
61866           box2.height += 400;
61867           reveal(
61868             box2,
61869             helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61870             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61871           );
61872         });
61873         context.history().on("change.intro", function() {
61874           timeout2(function() {
61875             continueTo(deleteLines);
61876           }, 500);
61877         });
61878       }, msec + 100);
61879       function continueTo(nextStep) {
61880         context.map().on("move.intro drawn.intro", null);
61881         context.history().on("change.intro", null);
61882         nextStep();
61883       }
61884     }
61885     function rightClickIntersection() {
61886       context.history().reset("doneUpdateLine");
61887       context.enter(modeBrowse(context));
61888       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61889       var rightClickString = helpHtml("intro.lines.split_street", {
61890         street1: _t("intro.graph.name.11th-avenue"),
61891         street2: _t("intro.graph.name.washington-street")
61892       }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch"));
61893       timeout2(function() {
61894         var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61895         var box = pad(eleventhAvenueEnd, padding, context);
61896         reveal(box, rightClickString);
61897         context.map().on("move.intro drawn.intro", function() {
61898           var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61899           var box2 = pad(eleventhAvenueEnd, padding2, context);
61900           reveal(
61901             box2,
61902             rightClickString,
61903             { duration: 0 }
61904           );
61905         });
61906         context.on("enter.intro", function(mode) {
61907           if (mode.id !== "select")
61908             return;
61909           var ids = context.selectedIDs();
61910           if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID)
61911             return;
61912           timeout2(function() {
61913             var node = selectMenuItem(context, "split").node();
61914             if (!node)
61915               return;
61916             continueTo(splitIntersection);
61917           }, 50);
61918         });
61919         context.history().on("change.intro", function() {
61920           timeout2(function() {
61921             continueTo(deleteLines);
61922           }, 300);
61923         });
61924       }, 600);
61925       function continueTo(nextStep) {
61926         context.map().on("move.intro drawn.intro", null);
61927         context.on("enter.intro", null);
61928         context.history().on("change.intro", null);
61929         nextStep();
61930       }
61931     }
61932     function splitIntersection() {
61933       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61934         return continueTo(deleteLines);
61935       }
61936       var node = selectMenuItem(context, "split").node();
61937       if (!node) {
61938         return continueTo(rightClickIntersection);
61939       }
61940       var wasChanged = false;
61941       _washingtonSegmentID = null;
61942       reveal(
61943         ".edit-menu",
61944         helpHtml(
61945           "intro.lines.split_intersection",
61946           { street: _t("intro.graph.name.washington-street") }
61947         ),
61948         { padding: 50 }
61949       );
61950       context.map().on("move.intro drawn.intro", function() {
61951         var node2 = selectMenuItem(context, "split").node();
61952         if (!wasChanged && !node2) {
61953           return continueTo(rightClickIntersection);
61954         }
61955         reveal(
61956           ".edit-menu",
61957           helpHtml(
61958             "intro.lines.split_intersection",
61959             { street: _t("intro.graph.name.washington-street") }
61960           ),
61961           { duration: 0, padding: 50 }
61962         );
61963       });
61964       context.history().on("change.intro", function(changed) {
61965         wasChanged = true;
61966         timeout2(function() {
61967           if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) {
61968             _washingtonSegmentID = changed.created()[0].id;
61969             continueTo(didSplit);
61970           } else {
61971             _washingtonSegmentID = null;
61972             continueTo(retrySplit);
61973           }
61974         }, 300);
61975       });
61976       function continueTo(nextStep) {
61977         context.map().on("move.intro drawn.intro", null);
61978         context.history().on("change.intro", null);
61979         nextStep();
61980       }
61981     }
61982     function retrySplit() {
61983       context.enter(modeBrowse(context));
61984       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61985       var advance = function() {
61986         continueTo(rightClickIntersection);
61987       };
61988       var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61989       var box = pad(eleventhAvenueEnd, padding, context);
61990       reveal(
61991         box,
61992         helpHtml("intro.lines.retry_split"),
61993         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61994       );
61995       context.map().on("move.intro drawn.intro", function() {
61996         var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61997         var box2 = pad(eleventhAvenueEnd, padding2, context);
61998         reveal(
61999           box2,
62000           helpHtml("intro.lines.retry_split"),
62001           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
62002         );
62003       });
62004       function continueTo(nextStep) {
62005         context.map().on("move.intro drawn.intro", null);
62006         nextStep();
62007       }
62008     }
62009     function didSplit() {
62010       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62011         return continueTo(rightClickIntersection);
62012       }
62013       var ids = context.selectedIDs();
62014       var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single");
62015       var street = _t("intro.graph.name.washington-street");
62016       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62017       var box = pad(twelfthAvenue, padding, context);
62018       box.width = box.width / 2;
62019       reveal(
62020         box,
62021         helpHtml(string, { street1: street, street2: street }),
62022         { duration: 500 }
62023       );
62024       timeout2(function() {
62025         context.map().centerZoomEase(twelfthAvenue, 18, 500);
62026         context.map().on("move.intro drawn.intro", function() {
62027           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
62028           var box2 = pad(twelfthAvenue, padding2, context);
62029           box2.width = box2.width / 2;
62030           reveal(
62031             box2,
62032             helpHtml(string, { street1: street, street2: street }),
62033             { duration: 0 }
62034           );
62035         });
62036       }, 600);
62037       context.on("enter.intro", function() {
62038         var ids2 = context.selectedIDs();
62039         if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) {
62040           continueTo(multiSelect);
62041         }
62042       });
62043       context.history().on("change.intro", function() {
62044         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62045           return continueTo(rightClickIntersection);
62046         }
62047       });
62048       function continueTo(nextStep) {
62049         context.map().on("move.intro drawn.intro", null);
62050         context.on("enter.intro", null);
62051         context.history().on("change.intro", null);
62052         nextStep();
62053       }
62054     }
62055     function multiSelect() {
62056       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62057         return continueTo(rightClickIntersection);
62058       }
62059       var ids = context.selectedIDs();
62060       var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
62061       var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
62062       if (hasWashington && hasTwelfth) {
62063         return continueTo(multiRightClick);
62064       } else if (!hasWashington && !hasTwelfth) {
62065         return continueTo(didSplit);
62066       }
62067       context.map().centerZoomEase(twelfthAvenue, 18, 500);
62068       timeout2(function() {
62069         var selected, other, padding, box;
62070         if (hasWashington) {
62071           selected = _t("intro.graph.name.washington-street");
62072           other = _t("intro.graph.name.12th-avenue");
62073           padding = 60 * Math.pow(2, context.map().zoom() - 18);
62074           box = pad(twelfthAvenueEnd, padding, context);
62075           box.width *= 3;
62076         } else {
62077           selected = _t("intro.graph.name.12th-avenue");
62078           other = _t("intro.graph.name.washington-street");
62079           padding = 200 * Math.pow(2, context.map().zoom() - 18);
62080           box = pad(twelfthAvenue, padding, context);
62081           box.width /= 2;
62082         }
62083         reveal(
62084           box,
62085           helpHtml(
62086             "intro.lines.multi_select",
62087             { selected, other1: other }
62088           ) + " " + helpHtml(
62089             "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62090             { selected, other2: other }
62091           )
62092         );
62093         context.map().on("move.intro drawn.intro", function() {
62094           if (hasWashington) {
62095             selected = _t("intro.graph.name.washington-street");
62096             other = _t("intro.graph.name.12th-avenue");
62097             padding = 60 * Math.pow(2, context.map().zoom() - 18);
62098             box = pad(twelfthAvenueEnd, padding, context);
62099             box.width *= 3;
62100           } else {
62101             selected = _t("intro.graph.name.12th-avenue");
62102             other = _t("intro.graph.name.washington-street");
62103             padding = 200 * Math.pow(2, context.map().zoom() - 18);
62104             box = pad(twelfthAvenue, padding, context);
62105             box.width /= 2;
62106           }
62107           reveal(
62108             box,
62109             helpHtml(
62110               "intro.lines.multi_select",
62111               { selected, other1: other }
62112             ) + " " + helpHtml(
62113               "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62114               { selected, other2: other }
62115             ),
62116             { duration: 0 }
62117           );
62118         });
62119         context.on("enter.intro", function() {
62120           continueTo(multiSelect);
62121         });
62122         context.history().on("change.intro", function() {
62123           if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62124             return continueTo(rightClickIntersection);
62125           }
62126         });
62127       }, 600);
62128       function continueTo(nextStep) {
62129         context.map().on("move.intro drawn.intro", null);
62130         context.on("enter.intro", null);
62131         context.history().on("change.intro", null);
62132         nextStep();
62133       }
62134     }
62135     function multiRightClick() {
62136       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62137         return continueTo(rightClickIntersection);
62138       }
62139       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62140       var box = pad(twelfthAvenue, padding, context);
62141       var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"));
62142       reveal(box, rightClickString);
62143       context.map().on("move.intro drawn.intro", function() {
62144         var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
62145         var box2 = pad(twelfthAvenue, padding2, context);
62146         reveal(box2, rightClickString, { duration: 0 });
62147       });
62148       context.ui().editMenu().on("toggled.intro", function(open) {
62149         if (!open)
62150           return;
62151         timeout2(function() {
62152           var ids = context.selectedIDs();
62153           if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62154             var node = selectMenuItem(context, "delete").node();
62155             if (!node)
62156               return;
62157             continueTo(multiDelete);
62158           } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62159             return continueTo(multiSelect);
62160           } else {
62161             return continueTo(didSplit);
62162           }
62163         }, 300);
62164       });
62165       context.history().on("change.intro", function() {
62166         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62167           return continueTo(rightClickIntersection);
62168         }
62169       });
62170       function continueTo(nextStep) {
62171         context.map().on("move.intro drawn.intro", null);
62172         context.ui().editMenu().on("toggled.intro", null);
62173         context.history().on("change.intro", null);
62174         nextStep();
62175       }
62176     }
62177     function multiDelete() {
62178       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62179         return continueTo(rightClickIntersection);
62180       }
62181       var node = selectMenuItem(context, "delete").node();
62182       if (!node)
62183         return continueTo(multiRightClick);
62184       reveal(
62185         ".edit-menu",
62186         helpHtml("intro.lines.multi_delete"),
62187         { padding: 50 }
62188       );
62189       context.map().on("move.intro drawn.intro", function() {
62190         reveal(
62191           ".edit-menu",
62192           helpHtml("intro.lines.multi_delete"),
62193           { duration: 0, padding: 50 }
62194         );
62195       });
62196       context.on("exit.intro", function() {
62197         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62198           return continueTo(multiSelect);
62199         }
62200       });
62201       context.history().on("change.intro", function() {
62202         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62203           continueTo(retryDelete);
62204         } else {
62205           continueTo(play);
62206         }
62207       });
62208       function continueTo(nextStep) {
62209         context.map().on("move.intro drawn.intro", null);
62210         context.on("exit.intro", null);
62211         context.history().on("change.intro", null);
62212         nextStep();
62213       }
62214     }
62215     function retryDelete() {
62216       context.enter(modeBrowse(context));
62217       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62218       var box = pad(twelfthAvenue, padding, context);
62219       reveal(box, helpHtml("intro.lines.retry_delete"), {
62220         buttonText: _t.html("intro.ok"),
62221         buttonCallback: function() {
62222           continueTo(multiSelect);
62223         }
62224       });
62225       function continueTo(nextStep) {
62226         nextStep();
62227       }
62228     }
62229     function play() {
62230       dispatch14.call("done");
62231       reveal(
62232         ".ideditor",
62233         helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }),
62234         {
62235           tooltipBox: ".intro-nav-wrap .chapter-building",
62236           buttonText: _t.html("intro.ok"),
62237           buttonCallback: function() {
62238             reveal(".ideditor");
62239           }
62240         }
62241       );
62242     }
62243     chapter.enter = function() {
62244       addLine();
62245     };
62246     chapter.exit = function() {
62247       timeouts.forEach(window.clearTimeout);
62248       select_default2(window).on("pointerdown.intro mousedown.intro", null, true);
62249       context.on("enter.intro exit.intro", null);
62250       context.map().on("move.intro drawn.intro", null);
62251       context.history().on("change.intro", null);
62252       context.container().select(".inspector-wrap").on("wheel.intro", null);
62253       context.container().select(".preset-list-button").on("click.intro", null);
62254     };
62255     chapter.restart = function() {
62256       chapter.exit();
62257       chapter.enter();
62258     };
62259     return utilRebind(chapter, dispatch14, "on");
62260   }
62261
62262   // modules/ui/intro/building.js
62263   function uiIntroBuilding(context, reveal) {
62264     var dispatch14 = dispatch_default("done");
62265     var house = [-85.62815, 41.95638];
62266     var tank = [-85.62732, 41.95347];
62267     var buildingCatetory = _mainPresetIndex.item("category-building");
62268     var housePreset = _mainPresetIndex.item("building/house");
62269     var tankPreset = _mainPresetIndex.item("man_made/storage_tank");
62270     var timeouts = [];
62271     var _houseID = null;
62272     var _tankID = null;
62273     var chapter = {
62274       title: "intro.buildings.title"
62275     };
62276     function timeout2(f2, t2) {
62277       timeouts.push(window.setTimeout(f2, t2));
62278     }
62279     function eventCancel(d3_event) {
62280       d3_event.stopPropagation();
62281       d3_event.preventDefault();
62282     }
62283     function revealHouse(center, text, options2) {
62284       var padding = 160 * Math.pow(2, context.map().zoom() - 20);
62285       var box = pad(center, padding, context);
62286       reveal(box, text, options2);
62287     }
62288     function revealTank(center, text, options2) {
62289       var padding = 190 * Math.pow(2, context.map().zoom() - 19.5);
62290       var box = pad(center, padding, context);
62291       reveal(box, text, options2);
62292     }
62293     function addHouse() {
62294       context.enter(modeBrowse(context));
62295       context.history().reset("initial");
62296       _houseID = null;
62297       var msec = transitionTime(house, context.map().center());
62298       if (msec) {
62299         reveal(null, null, { duration: 0 });
62300       }
62301       context.map().centerZoomEase(house, 19, msec);
62302       timeout2(function() {
62303         var tooltip = reveal(
62304           "button.add-area",
62305           helpHtml("intro.buildings.add_building")
62306         );
62307         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings");
62308         context.on("enter.intro", function(mode) {
62309           if (mode.id !== "add-area")
62310             return;
62311           continueTo(startHouse);
62312         });
62313       }, msec + 100);
62314       function continueTo(nextStep) {
62315         context.on("enter.intro", null);
62316         nextStep();
62317       }
62318     }
62319     function startHouse() {
62320       if (context.mode().id !== "add-area") {
62321         return continueTo(addHouse);
62322       }
62323       _houseID = null;
62324       context.map().zoomEase(20, 500);
62325       timeout2(function() {
62326         var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62327         revealHouse(house, startString);
62328         context.map().on("move.intro drawn.intro", function() {
62329           revealHouse(house, startString, { duration: 0 });
62330         });
62331         context.on("enter.intro", function(mode) {
62332           if (mode.id !== "draw-area")
62333             return chapter.restart();
62334           continueTo(continueHouse);
62335         });
62336       }, 550);
62337       function continueTo(nextStep) {
62338         context.map().on("move.intro drawn.intro", null);
62339         context.on("enter.intro", null);
62340         nextStep();
62341       }
62342     }
62343     function continueHouse() {
62344       if (context.mode().id !== "draw-area") {
62345         return continueTo(addHouse);
62346       }
62347       _houseID = null;
62348       var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building");
62349       revealHouse(house, continueString);
62350       context.map().on("move.intro drawn.intro", function() {
62351         revealHouse(house, continueString, { duration: 0 });
62352       });
62353       context.on("enter.intro", function(mode) {
62354         if (mode.id === "draw-area") {
62355           return;
62356         } else if (mode.id === "select") {
62357           var graph = context.graph();
62358           var way = context.entity(context.selectedIDs()[0]);
62359           var nodes = graph.childNodes(way);
62360           var points = utilArrayUniq(nodes).map(function(n3) {
62361             return context.projection(n3.loc);
62362           });
62363           if (isMostlySquare(points)) {
62364             _houseID = way.id;
62365             return continueTo(chooseCategoryBuilding);
62366           } else {
62367             return continueTo(retryHouse);
62368           }
62369         } else {
62370           return chapter.restart();
62371         }
62372       });
62373       function continueTo(nextStep) {
62374         context.map().on("move.intro drawn.intro", null);
62375         context.on("enter.intro", null);
62376         nextStep();
62377       }
62378     }
62379     function retryHouse() {
62380       var onClick = function() {
62381         continueTo(addHouse);
62382       };
62383       revealHouse(
62384         house,
62385         helpHtml("intro.buildings.retry_building"),
62386         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62387       );
62388       context.map().on("move.intro drawn.intro", function() {
62389         revealHouse(
62390           house,
62391           helpHtml("intro.buildings.retry_building"),
62392           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62393         );
62394       });
62395       function continueTo(nextStep) {
62396         context.map().on("move.intro drawn.intro", null);
62397         nextStep();
62398       }
62399     }
62400     function chooseCategoryBuilding() {
62401       if (!_houseID || !context.hasEntity(_houseID)) {
62402         return addHouse();
62403       }
62404       var ids = context.selectedIDs();
62405       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62406         context.enter(modeSelect(context, [_houseID]));
62407       }
62408       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62409       timeout2(function() {
62410         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62411         var button = context.container().select(".preset-category-building .preset-list-button");
62412         reveal(
62413           button.node(),
62414           helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() })
62415         );
62416         button.on("click.intro", function() {
62417           button.on("click.intro", null);
62418           continueTo(choosePresetHouse);
62419         });
62420       }, 400);
62421       context.on("enter.intro", function(mode) {
62422         if (!_houseID || !context.hasEntity(_houseID)) {
62423           return continueTo(addHouse);
62424         }
62425         var ids2 = context.selectedIDs();
62426         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62427           return continueTo(chooseCategoryBuilding);
62428         }
62429       });
62430       function continueTo(nextStep) {
62431         context.container().select(".inspector-wrap").on("wheel.intro", null);
62432         context.container().select(".preset-list-button").on("click.intro", null);
62433         context.on("enter.intro", null);
62434         nextStep();
62435       }
62436     }
62437     function choosePresetHouse() {
62438       if (!_houseID || !context.hasEntity(_houseID)) {
62439         return addHouse();
62440       }
62441       var ids = context.selectedIDs();
62442       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62443         context.enter(modeSelect(context, [_houseID]));
62444       }
62445       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62446       timeout2(function() {
62447         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62448         var button = context.container().select(".preset-building-house .preset-list-button");
62449         reveal(
62450           button.node(),
62451           helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }),
62452           { duration: 300 }
62453         );
62454         button.on("click.intro", function() {
62455           button.on("click.intro", null);
62456           continueTo(closeEditorHouse);
62457         });
62458       }, 400);
62459       context.on("enter.intro", function(mode) {
62460         if (!_houseID || !context.hasEntity(_houseID)) {
62461           return continueTo(addHouse);
62462         }
62463         var ids2 = context.selectedIDs();
62464         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62465           return continueTo(chooseCategoryBuilding);
62466         }
62467       });
62468       function continueTo(nextStep) {
62469         context.container().select(".inspector-wrap").on("wheel.intro", null);
62470         context.container().select(".preset-list-button").on("click.intro", null);
62471         context.on("enter.intro", null);
62472         nextStep();
62473       }
62474     }
62475     function closeEditorHouse() {
62476       if (!_houseID || !context.hasEntity(_houseID)) {
62477         return addHouse();
62478       }
62479       var ids = context.selectedIDs();
62480       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62481         context.enter(modeSelect(context, [_houseID]));
62482       }
62483       context.history().checkpoint("hasHouse");
62484       context.on("exit.intro", function() {
62485         continueTo(rightClickHouse);
62486       });
62487       timeout2(function() {
62488         reveal(
62489           ".entity-editor-pane",
62490           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62491         );
62492       }, 500);
62493       function continueTo(nextStep) {
62494         context.on("exit.intro", null);
62495         nextStep();
62496       }
62497     }
62498     function rightClickHouse() {
62499       if (!_houseID)
62500         return chapter.restart();
62501       context.enter(modeBrowse(context));
62502       context.history().reset("hasHouse");
62503       var zoom = context.map().zoom();
62504       if (zoom < 20) {
62505         zoom = 20;
62506       }
62507       context.map().centerZoomEase(house, zoom, 500);
62508       context.on("enter.intro", function(mode) {
62509         if (mode.id !== "select")
62510           return;
62511         var ids = context.selectedIDs();
62512         if (ids.length !== 1 || ids[0] !== _houseID)
62513           return;
62514         timeout2(function() {
62515           var node = selectMenuItem(context, "orthogonalize").node();
62516           if (!node)
62517             return;
62518           continueTo(clickSquare);
62519         }, 50);
62520       });
62521       context.map().on("move.intro drawn.intro", function() {
62522         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch"));
62523         revealHouse(house, rightclickString, { duration: 0 });
62524       });
62525       context.history().on("change.intro", function() {
62526         continueTo(rightClickHouse);
62527       });
62528       function continueTo(nextStep) {
62529         context.on("enter.intro", null);
62530         context.map().on("move.intro drawn.intro", null);
62531         context.history().on("change.intro", null);
62532         nextStep();
62533       }
62534     }
62535     function clickSquare() {
62536       if (!_houseID)
62537         return chapter.restart();
62538       var entity = context.hasEntity(_houseID);
62539       if (!entity)
62540         return continueTo(rightClickHouse);
62541       var node = selectMenuItem(context, "orthogonalize").node();
62542       if (!node) {
62543         return continueTo(rightClickHouse);
62544       }
62545       var wasChanged = false;
62546       reveal(
62547         ".edit-menu",
62548         helpHtml("intro.buildings.square_building"),
62549         { padding: 50 }
62550       );
62551       context.on("enter.intro", function(mode) {
62552         if (mode.id === "browse") {
62553           continueTo(rightClickHouse);
62554         } else if (mode.id === "move" || mode.id === "rotate") {
62555           continueTo(retryClickSquare);
62556         }
62557       });
62558       context.map().on("move.intro", function() {
62559         var node2 = selectMenuItem(context, "orthogonalize").node();
62560         if (!wasChanged && !node2) {
62561           return continueTo(rightClickHouse);
62562         }
62563         reveal(
62564           ".edit-menu",
62565           helpHtml("intro.buildings.square_building"),
62566           { duration: 0, padding: 50 }
62567         );
62568       });
62569       context.history().on("change.intro", function() {
62570         wasChanged = true;
62571         context.history().on("change.intro", null);
62572         timeout2(function() {
62573           if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) {
62574             continueTo(doneSquare);
62575           } else {
62576             continueTo(retryClickSquare);
62577           }
62578         }, 500);
62579       });
62580       function continueTo(nextStep) {
62581         context.on("enter.intro", null);
62582         context.map().on("move.intro", null);
62583         context.history().on("change.intro", null);
62584         nextStep();
62585       }
62586     }
62587     function retryClickSquare() {
62588       context.enter(modeBrowse(context));
62589       revealHouse(house, helpHtml("intro.buildings.retry_square"), {
62590         buttonText: _t.html("intro.ok"),
62591         buttonCallback: function() {
62592           continueTo(rightClickHouse);
62593         }
62594       });
62595       function continueTo(nextStep) {
62596         nextStep();
62597       }
62598     }
62599     function doneSquare() {
62600       context.history().checkpoint("doneSquare");
62601       revealHouse(house, helpHtml("intro.buildings.done_square"), {
62602         buttonText: _t.html("intro.ok"),
62603         buttonCallback: function() {
62604           continueTo(addTank);
62605         }
62606       });
62607       function continueTo(nextStep) {
62608         nextStep();
62609       }
62610     }
62611     function addTank() {
62612       context.enter(modeBrowse(context));
62613       context.history().reset("doneSquare");
62614       _tankID = null;
62615       var msec = transitionTime(tank, context.map().center());
62616       if (msec) {
62617         reveal(null, null, { duration: 0 });
62618       }
62619       context.map().centerZoomEase(tank, 19.5, msec);
62620       timeout2(function() {
62621         reveal(
62622           "button.add-area",
62623           helpHtml("intro.buildings.add_tank")
62624         );
62625         context.on("enter.intro", function(mode) {
62626           if (mode.id !== "add-area")
62627             return;
62628           continueTo(startTank);
62629         });
62630       }, msec + 100);
62631       function continueTo(nextStep) {
62632         context.on("enter.intro", null);
62633         nextStep();
62634       }
62635     }
62636     function startTank() {
62637       if (context.mode().id !== "add-area") {
62638         return continueTo(addTank);
62639       }
62640       _tankID = null;
62641       timeout2(function() {
62642         var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62643         revealTank(tank, startString);
62644         context.map().on("move.intro drawn.intro", function() {
62645           revealTank(tank, startString, { duration: 0 });
62646         });
62647         context.on("enter.intro", function(mode) {
62648           if (mode.id !== "draw-area")
62649             return chapter.restart();
62650           continueTo(continueTank);
62651         });
62652       }, 550);
62653       function continueTo(nextStep) {
62654         context.map().on("move.intro drawn.intro", null);
62655         context.on("enter.intro", null);
62656         nextStep();
62657       }
62658     }
62659     function continueTank() {
62660       if (context.mode().id !== "draw-area") {
62661         return continueTo(addTank);
62662       }
62663       _tankID = null;
62664       var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank");
62665       revealTank(tank, continueString);
62666       context.map().on("move.intro drawn.intro", function() {
62667         revealTank(tank, continueString, { duration: 0 });
62668       });
62669       context.on("enter.intro", function(mode) {
62670         if (mode.id === "draw-area") {
62671           return;
62672         } else if (mode.id === "select") {
62673           _tankID = context.selectedIDs()[0];
62674           return continueTo(searchPresetTank);
62675         } else {
62676           return continueTo(addTank);
62677         }
62678       });
62679       function continueTo(nextStep) {
62680         context.map().on("move.intro drawn.intro", null);
62681         context.on("enter.intro", null);
62682         nextStep();
62683       }
62684     }
62685     function searchPresetTank() {
62686       if (!_tankID || !context.hasEntity(_tankID)) {
62687         return addTank();
62688       }
62689       var ids = context.selectedIDs();
62690       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62691         context.enter(modeSelect(context, [_tankID]));
62692       }
62693       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62694       timeout2(function() {
62695         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62696         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62697         reveal(
62698           ".preset-search-input",
62699           helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62700         );
62701       }, 400);
62702       context.on("enter.intro", function(mode) {
62703         if (!_tankID || !context.hasEntity(_tankID)) {
62704           return continueTo(addTank);
62705         }
62706         var ids2 = context.selectedIDs();
62707         if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) {
62708           context.enter(modeSelect(context, [_tankID]));
62709           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62710           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62711           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62712           reveal(
62713             ".preset-search-input",
62714             helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62715           );
62716           context.history().on("change.intro", null);
62717         }
62718       });
62719       function checkPresetSearch() {
62720         var first = context.container().select(".preset-list-item:first-child");
62721         if (first.classed("preset-man_made-storage_tank")) {
62722           reveal(
62723             first.select(".preset-list-button").node(),
62724             helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }),
62725             { duration: 300 }
62726           );
62727           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
62728           context.history().on("change.intro", function() {
62729             continueTo(closeEditorTank);
62730           });
62731         }
62732       }
62733       function continueTo(nextStep) {
62734         context.container().select(".inspector-wrap").on("wheel.intro", null);
62735         context.on("enter.intro", null);
62736         context.history().on("change.intro", null);
62737         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62738         nextStep();
62739       }
62740     }
62741     function closeEditorTank() {
62742       if (!_tankID || !context.hasEntity(_tankID)) {
62743         return addTank();
62744       }
62745       var ids = context.selectedIDs();
62746       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62747         context.enter(modeSelect(context, [_tankID]));
62748       }
62749       context.history().checkpoint("hasTank");
62750       context.on("exit.intro", function() {
62751         continueTo(rightClickTank);
62752       });
62753       timeout2(function() {
62754         reveal(
62755           ".entity-editor-pane",
62756           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62757         );
62758       }, 500);
62759       function continueTo(nextStep) {
62760         context.on("exit.intro", null);
62761         nextStep();
62762       }
62763     }
62764     function rightClickTank() {
62765       if (!_tankID)
62766         return continueTo(addTank);
62767       context.enter(modeBrowse(context));
62768       context.history().reset("hasTank");
62769       context.map().centerEase(tank, 500);
62770       timeout2(function() {
62771         context.on("enter.intro", function(mode) {
62772           if (mode.id !== "select")
62773             return;
62774           var ids = context.selectedIDs();
62775           if (ids.length !== 1 || ids[0] !== _tankID)
62776             return;
62777           timeout2(function() {
62778             var node = selectMenuItem(context, "circularize").node();
62779             if (!node)
62780               return;
62781             continueTo(clickCircle);
62782           }, 50);
62783         });
62784         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch"));
62785         revealTank(tank, rightclickString);
62786         context.map().on("move.intro drawn.intro", function() {
62787           revealTank(tank, rightclickString, { duration: 0 });
62788         });
62789         context.history().on("change.intro", function() {
62790           continueTo(rightClickTank);
62791         });
62792       }, 600);
62793       function continueTo(nextStep) {
62794         context.on("enter.intro", null);
62795         context.map().on("move.intro drawn.intro", null);
62796         context.history().on("change.intro", null);
62797         nextStep();
62798       }
62799     }
62800     function clickCircle() {
62801       if (!_tankID)
62802         return chapter.restart();
62803       var entity = context.hasEntity(_tankID);
62804       if (!entity)
62805         return continueTo(rightClickTank);
62806       var node = selectMenuItem(context, "circularize").node();
62807       if (!node) {
62808         return continueTo(rightClickTank);
62809       }
62810       var wasChanged = false;
62811       reveal(
62812         ".edit-menu",
62813         helpHtml("intro.buildings.circle_tank"),
62814         { padding: 50 }
62815       );
62816       context.on("enter.intro", function(mode) {
62817         if (mode.id === "browse") {
62818           continueTo(rightClickTank);
62819         } else if (mode.id === "move" || mode.id === "rotate") {
62820           continueTo(retryClickCircle);
62821         }
62822       });
62823       context.map().on("move.intro", function() {
62824         var node2 = selectMenuItem(context, "circularize").node();
62825         if (!wasChanged && !node2) {
62826           return continueTo(rightClickTank);
62827         }
62828         reveal(
62829           ".edit-menu",
62830           helpHtml("intro.buildings.circle_tank"),
62831           { duration: 0, padding: 50 }
62832         );
62833       });
62834       context.history().on("change.intro", function() {
62835         wasChanged = true;
62836         context.history().on("change.intro", null);
62837         timeout2(function() {
62838           if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) {
62839             continueTo(play);
62840           } else {
62841             continueTo(retryClickCircle);
62842           }
62843         }, 500);
62844       });
62845       function continueTo(nextStep) {
62846         context.on("enter.intro", null);
62847         context.map().on("move.intro", null);
62848         context.history().on("change.intro", null);
62849         nextStep();
62850       }
62851     }
62852     function retryClickCircle() {
62853       context.enter(modeBrowse(context));
62854       revealTank(tank, helpHtml("intro.buildings.retry_circle"), {
62855         buttonText: _t.html("intro.ok"),
62856         buttonCallback: function() {
62857           continueTo(rightClickTank);
62858         }
62859       });
62860       function continueTo(nextStep) {
62861         nextStep();
62862       }
62863     }
62864     function play() {
62865       dispatch14.call("done");
62866       reveal(
62867         ".ideditor",
62868         helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }),
62869         {
62870           tooltipBox: ".intro-nav-wrap .chapter-startEditing",
62871           buttonText: _t.html("intro.ok"),
62872           buttonCallback: function() {
62873             reveal(".ideditor");
62874           }
62875         }
62876       );
62877     }
62878     chapter.enter = function() {
62879       addHouse();
62880     };
62881     chapter.exit = function() {
62882       timeouts.forEach(window.clearTimeout);
62883       context.on("enter.intro exit.intro", null);
62884       context.map().on("move.intro drawn.intro", null);
62885       context.history().on("change.intro", null);
62886       context.container().select(".inspector-wrap").on("wheel.intro", null);
62887       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62888       context.container().select(".more-fields .combobox-input").on("click.intro", null);
62889     };
62890     chapter.restart = function() {
62891       chapter.exit();
62892       chapter.enter();
62893     };
62894     return utilRebind(chapter, dispatch14, "on");
62895   }
62896
62897   // modules/ui/intro/start_editing.js
62898   function uiIntroStartEditing(context, reveal) {
62899     var dispatch14 = dispatch_default("done", "startEditing");
62900     var modalSelection = select_default2(null);
62901     var chapter = {
62902       title: "intro.startediting.title"
62903     };
62904     function showHelp() {
62905       reveal(
62906         ".map-control.help-control",
62907         helpHtml("intro.startediting.help"),
62908         {
62909           buttonText: _t.html("intro.ok"),
62910           buttonCallback: function() {
62911             shortcuts();
62912           }
62913         }
62914       );
62915     }
62916     function shortcuts() {
62917       reveal(
62918         ".map-control.help-control",
62919         helpHtml("intro.startediting.shortcuts"),
62920         {
62921           buttonText: _t.html("intro.ok"),
62922           buttonCallback: function() {
62923             showSave();
62924           }
62925         }
62926       );
62927     }
62928     function showSave() {
62929       context.container().selectAll(".shaded").remove();
62930       reveal(
62931         ".top-toolbar button.save",
62932         helpHtml("intro.startediting.save"),
62933         {
62934           buttonText: _t.html("intro.ok"),
62935           buttonCallback: function() {
62936             showStart();
62937           }
62938         }
62939       );
62940     }
62941     function showStart() {
62942       context.container().selectAll(".shaded").remove();
62943       modalSelection = uiModal(context.container());
62944       modalSelection.select(".modal").attr("class", "modal-splash modal");
62945       modalSelection.selectAll(".close").remove();
62946       var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() {
62947         modalSelection.remove();
62948       });
62949       startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough");
62950       startbutton.append("h2").call(_t.append("intro.startediting.start"));
62951       dispatch14.call("startEditing");
62952     }
62953     chapter.enter = function() {
62954       showHelp();
62955     };
62956     chapter.exit = function() {
62957       modalSelection.remove();
62958       context.container().selectAll(".shaded").remove();
62959     };
62960     return utilRebind(chapter, dispatch14, "on");
62961   }
62962
62963   // modules/ui/intro/intro.js
62964   var chapterUi = {
62965     welcome: uiIntroWelcome,
62966     navigation: uiIntroNavigation,
62967     point: uiIntroPoint,
62968     area: uiIntroArea,
62969     line: uiIntroLine,
62970     building: uiIntroBuilding,
62971     startEditing: uiIntroStartEditing
62972   };
62973   var chapterFlow = [
62974     "welcome",
62975     "navigation",
62976     "point",
62977     "area",
62978     "line",
62979     "building",
62980     "startEditing"
62981   ];
62982   function uiIntro(context) {
62983     const INTRO_IMAGERY = "EsriWorldImageryClarity";
62984     let _introGraph = {};
62985     let _currChapter;
62986     function intro(selection2) {
62987       _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => {
62988         for (let id2 in dataIntroGraph) {
62989           if (!_introGraph[id2]) {
62990             _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2]));
62991           }
62992         }
62993         selection2.call(startIntro);
62994       }).catch(function() {
62995       });
62996     }
62997     function startIntro(selection2) {
62998       context.enter(modeBrowse(context));
62999       let osm = context.connection();
63000       let history = context.history().toJSON();
63001       let hash = window.location.hash;
63002       let center = context.map().center();
63003       let zoom = context.map().zoom();
63004       let background = context.background().baseLayerSource();
63005       let overlays = context.background().overlayLayerSources();
63006       let opacity = context.container().selectAll(".main-map .layer-background").style("opacity");
63007       let caches = osm && osm.caches();
63008       let baseEntities = context.history().graph().base().entities;
63009       context.ui().sidebar.expand();
63010       context.container().selectAll("button.sidebar-toggle").classed("disabled", true);
63011       context.inIntro(true);
63012       if (osm) {
63013         osm.toggle(false).reset();
63014       }
63015       context.history().reset();
63016       context.history().merge(Object.values(coreGraph().load(_introGraph).entities));
63017       context.history().checkpoint("initial");
63018       let imagery = context.background().findSource(INTRO_IMAGERY);
63019       if (imagery) {
63020         context.background().baseLayerSource(imagery);
63021       } else {
63022         context.background().bing();
63023       }
63024       overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
63025       let layers = context.layers();
63026       layers.all().forEach((item) => {
63027         if (typeof item.layer.enabled === "function") {
63028           item.layer.enabled(item.id === "osm");
63029         }
63030       });
63031       context.container().selectAll(".main-map .layer-background").style("opacity", 1);
63032       let curtain = uiCurtain(context.container().node());
63033       selection2.call(curtain);
63034       corePreferences("walkthrough_started", "yes");
63035       let storedProgress = corePreferences("walkthrough_progress") || "";
63036       let progress = storedProgress.split(";").filter(Boolean);
63037       let chapters = chapterFlow.map((chapter, i3) => {
63038         let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => {
63039           buttons.filter((d2) => d2.title === s2.title).classed("finished", true);
63040           if (i3 < chapterFlow.length - 1) {
63041             const next = chapterFlow[i3 + 1];
63042             context.container().select("button.chapter-".concat(next)).classed("next", true);
63043           }
63044           progress.push(chapter);
63045           corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
63046         });
63047         return s2;
63048       });
63049       chapters[chapters.length - 1].on("startEditing", () => {
63050         progress.push("startEditing");
63051         corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
63052         let incomplete = utilArrayDifference(chapterFlow, progress);
63053         if (!incomplete.length) {
63054           corePreferences("walkthrough_completed", "yes");
63055         }
63056         curtain.remove();
63057         navwrap.remove();
63058         context.container().selectAll(".main-map .layer-background").style("opacity", opacity);
63059         context.container().selectAll("button.sidebar-toggle").classed("disabled", false);
63060         if (osm) {
63061           osm.toggle(true).reset().caches(caches);
63062         }
63063         context.history().reset().merge(Object.values(baseEntities));
63064         context.background().baseLayerSource(background);
63065         overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
63066         if (history) {
63067           context.history().fromJSON(history, false);
63068         }
63069         context.map().centerZoom(center, zoom);
63070         window.location.replace(hash);
63071         context.inIntro(false);
63072       });
63073       let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD");
63074       navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough");
63075       let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter");
63076       let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter);
63077       buttons.append("span").html((d2) => _t.html(d2.title));
63078       buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
63079       enterChapter(null, chapters[0]);
63080       function enterChapter(d3_event, newChapter) {
63081         if (_currChapter) {
63082           _currChapter.exit();
63083         }
63084         context.enter(modeBrowse(context));
63085         _currChapter = newChapter;
63086         _currChapter.enter();
63087         buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title);
63088       }
63089     }
63090     return intro;
63091   }
63092
63093   // modules/ui/issues_info.js
63094   function uiIssuesInfo(context) {
63095     var warningsItem = {
63096       id: "warnings",
63097       count: 0,
63098       iconID: "iD-icon-alert",
63099       descriptionID: "issues.warnings_and_errors"
63100     };
63101     var resolvedItem = {
63102       id: "resolved",
63103       count: 0,
63104       iconID: "iD-icon-apply",
63105       descriptionID: "issues.user_resolved_issues"
63106     };
63107     function update(selection2) {
63108       var shownItems = [];
63109       var liveIssues = context.validator().getIssues({
63110         what: corePreferences("validate-what") || "edited",
63111         where: corePreferences("validate-where") || "all"
63112       });
63113       if (liveIssues.length) {
63114         warningsItem.count = liveIssues.length;
63115         shownItems.push(warningsItem);
63116       }
63117       if (corePreferences("validate-what") === "all") {
63118         var resolvedIssues = context.validator().getResolvedIssues();
63119         if (resolvedIssues.length) {
63120           resolvedItem.count = resolvedIssues.length;
63121           shownItems.push(resolvedItem);
63122         }
63123       }
63124       var chips = selection2.selectAll(".chip").data(shownItems, function(d2) {
63125         return d2.id;
63126       });
63127       chips.exit().remove();
63128       var enter = chips.enter().append("a").attr("class", function(d2) {
63129         return "chip " + d2.id + "-count";
63130       }).attr("href", "#").each(function(d2) {
63131         var chipSelection = select_default2(this);
63132         var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID));
63133         chipSelection.call(tooltipBehavior).on("click", function(d3_event) {
63134           d3_event.preventDefault();
63135           tooltipBehavior.hide(select_default2(this));
63136           context.ui().togglePanes(context.container().select(".map-panes .issues-pane"));
63137         });
63138         chipSelection.call(svgIcon("#" + d2.iconID));
63139       });
63140       enter.append("span").attr("class", "count");
63141       enter.merge(chips).selectAll("span.count").text(function(d2) {
63142         return d2.count.toString();
63143       });
63144     }
63145     return function(selection2) {
63146       update(selection2);
63147       context.validator().on("validated.infobox", function() {
63148         update(selection2);
63149       });
63150     };
63151   }
63152
63153   // modules/ui/map_in_map.js
63154   function uiMapInMap(context) {
63155     function mapInMap(selection2) {
63156       var backgroundLayer = rendererTileLayer(context);
63157       var overlayLayers = {};
63158       var projection2 = geoRawMercator();
63159       var dataLayer = svgData(projection2, context).showLabels(false);
63160       var debugLayer = svgDebug(projection2, context);
63161       var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded);
63162       var wrap2 = select_default2(null);
63163       var tiles = select_default2(null);
63164       var viewport = select_default2(null);
63165       var _isTransformed = false;
63166       var _isHidden = true;
63167       var _skipEvents = false;
63168       var _gesture = null;
63169       var _zDiff = 6;
63170       var _dMini;
63171       var _cMini;
63172       var _tStart;
63173       var _tCurr;
63174       var _timeoutID;
63175       function zoomStarted() {
63176         if (_skipEvents)
63177           return;
63178         _tStart = _tCurr = projection2.transform();
63179         _gesture = null;
63180       }
63181       function zoomed(d3_event) {
63182         if (_skipEvents)
63183           return;
63184         var x2 = d3_event.transform.x;
63185         var y2 = d3_event.transform.y;
63186         var k2 = d3_event.transform.k;
63187         var isZooming = k2 !== _tStart.k;
63188         var isPanning = x2 !== _tStart.x || y2 !== _tStart.y;
63189         if (!isZooming && !isPanning) {
63190           return;
63191         }
63192         if (!_gesture) {
63193           _gesture = isZooming ? "zoom" : "pan";
63194         }
63195         var tMini = projection2.transform();
63196         var tX, tY, scale;
63197         if (_gesture === "zoom") {
63198           scale = k2 / tMini.k;
63199           tX = (_cMini[0] / scale - _cMini[0]) * scale;
63200           tY = (_cMini[1] / scale - _cMini[1]) * scale;
63201         } else {
63202           k2 = tMini.k;
63203           scale = 1;
63204           tX = x2 - tMini.x;
63205           tY = y2 - tMini.y;
63206         }
63207         utilSetTransform(tiles, tX, tY, scale);
63208         utilSetTransform(viewport, 0, 0, scale);
63209         _isTransformed = true;
63210         _tCurr = identity2.translate(x2, y2).scale(k2);
63211         var zMain = geoScaleToZoom(context.projection.scale());
63212         var zMini = geoScaleToZoom(k2);
63213         _zDiff = zMain - zMini;
63214         queueRedraw();
63215       }
63216       function zoomEnded() {
63217         if (_skipEvents)
63218           return;
63219         if (_gesture !== "pan")
63220           return;
63221         updateProjection();
63222         _gesture = null;
63223         context.map().center(projection2.invert(_cMini));
63224       }
63225       function updateProjection() {
63226         var loc = context.map().center();
63227         var tMain = context.projection.transform();
63228         var zMain = geoScaleToZoom(tMain.k);
63229         var zMini = Math.max(zMain - _zDiff, 0.5);
63230         var kMini = geoZoomToScale(zMini);
63231         projection2.translate([tMain.x, tMain.y]).scale(kMini);
63232         var point2 = projection2(loc);
63233         var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0];
63234         var xMini = _cMini[0] - point2[0] + tMain.x + mouse[0];
63235         var yMini = _cMini[1] - point2[1] + tMain.y + mouse[1];
63236         projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]);
63237         _tCurr = projection2.transform();
63238         if (_isTransformed) {
63239           utilSetTransform(tiles, 0, 0);
63240           utilSetTransform(viewport, 0, 0);
63241           _isTransformed = false;
63242         }
63243         zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]);
63244         _skipEvents = true;
63245         wrap2.call(zoom.transform, _tCurr);
63246         _skipEvents = false;
63247       }
63248       function redraw() {
63249         clearTimeout(_timeoutID);
63250         if (_isHidden)
63251           return;
63252         updateProjection();
63253         var zMini = geoScaleToZoom(projection2.scale());
63254         tiles = wrap2.selectAll(".map-in-map-tiles").data([0]);
63255         tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles);
63256         backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini);
63257         var background = tiles.selectAll(".map-in-map-background").data([0]);
63258         background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer);
63259         var overlaySources = context.background().overlayLayerSources();
63260         var activeOverlayLayers = [];
63261         for (var i3 = 0; i3 < overlaySources.length; i3++) {
63262           if (overlaySources[i3].validZoom(zMini)) {
63263             if (!overlayLayers[i3])
63264               overlayLayers[i3] = rendererTileLayer(context);
63265             activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini));
63266           }
63267         }
63268         var overlay = tiles.selectAll(".map-in-map-overlay").data([0]);
63269         overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay);
63270         var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) {
63271           return d2.source().name();
63272         });
63273         overlays.exit().remove();
63274         overlays = overlays.enter().append("div").merge(overlays).each(function(layer) {
63275           select_default2(this).call(layer);
63276         });
63277         var dataLayers = tiles.selectAll(".map-in-map-data").data([0]);
63278         dataLayers.exit().remove();
63279         dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer);
63280         if (_gesture !== "pan") {
63281           var getPath = path_default(projection2);
63282           var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] };
63283           viewport = wrap2.selectAll(".map-in-map-viewport").data([0]);
63284           viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport);
63285           var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]);
63286           path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) {
63287             return getPath.area(d2) < 30;
63288           });
63289         }
63290       }
63291       function queueRedraw() {
63292         clearTimeout(_timeoutID);
63293         _timeoutID = setTimeout(function() {
63294           redraw();
63295         }, 750);
63296       }
63297       function toggle(d3_event) {
63298         if (d3_event)
63299           d3_event.preventDefault();
63300         _isHidden = !_isHidden;
63301         context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden);
63302         if (_isHidden) {
63303           wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() {
63304             selection2.selectAll(".map-in-map").style("display", "none");
63305           });
63306         } else {
63307           wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() {
63308             redraw();
63309           });
63310         }
63311       }
63312       uiMapInMap.toggle = toggle;
63313       wrap2 = selection2.selectAll(".map-in-map").data([0]);
63314       wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2);
63315       _dMini = [200, 150];
63316       _cMini = geoVecScale(_dMini, 0.5);
63317       context.map().on("drawn.map-in-map", function(drawn) {
63318         if (drawn.full === true) {
63319           redraw();
63320         }
63321       });
63322       redraw();
63323       context.keybinding().on(_t("background.minimap.key"), toggle);
63324     }
63325     return mapInMap;
63326   }
63327
63328   // modules/ui/notice.js
63329   function uiNotice(context) {
63330     return function(selection2) {
63331       var div = selection2.append("div").attr("class", "notice");
63332       var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() {
63333         context.map().zoomEase(context.minEditableZoom());
63334       }).on("wheel", function(d3_event) {
63335         var e22 = new WheelEvent(d3_event.type, d3_event);
63336         context.surface().node().dispatchEvent(e22);
63337       });
63338       button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit"));
63339       function disableTooHigh() {
63340         var canEdit = context.map().zoom() >= context.minEditableZoom();
63341         div.style("display", canEdit ? "none" : "block");
63342       }
63343       context.map().on("move.notice", debounce_default(disableTooHigh, 500));
63344       disableTooHigh();
63345     };
63346   }
63347
63348   // modules/ui/photoviewer.js
63349   function uiPhotoviewer(context) {
63350     var dispatch14 = dispatch_default("resize");
63351     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
63352     function photoviewer(selection2) {
63353       selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() {
63354         if (services.streetside) {
63355           services.streetside.hideViewer(context);
63356         }
63357         if (services.mapillary) {
63358           services.mapillary.hideViewer(context);
63359         }
63360         if (services.kartaview) {
63361           services.kartaview.hideViewer(context);
63362         }
63363         if (services.mapilio) {
63364           services.mapilio.hideViewer(context);
63365         }
63366         if (services.vegbilder) {
63367           services.vegbilder.hideViewer(context);
63368         }
63369       }).append("div").call(svgIcon("#iD-icon-close"));
63370       function preventDefault(d3_event) {
63371         d3_event.preventDefault();
63372       }
63373       selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on(
63374         _pointerPrefix + "down",
63375         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true })
63376       );
63377       selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on(
63378         _pointerPrefix + "down",
63379         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true })
63380       );
63381       selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on(
63382         _pointerPrefix + "down",
63383         buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true })
63384       );
63385       function buildResizeListener(target, eventName, dispatch15, options2) {
63386         var resizeOnX = !!options2.resizeOnX;
63387         var resizeOnY = !!options2.resizeOnY;
63388         var minHeight = options2.minHeight || 240;
63389         var minWidth = options2.minWidth || 320;
63390         var pointerId;
63391         var startX;
63392         var startY;
63393         var startWidth;
63394         var startHeight;
63395         function startResize(d3_event) {
63396           if (pointerId !== (d3_event.pointerId || "mouse"))
63397             return;
63398           d3_event.preventDefault();
63399           d3_event.stopPropagation();
63400           var mapSize = context.map().dimensions();
63401           if (resizeOnX) {
63402             var maxWidth = mapSize[0];
63403             var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, maxWidth);
63404             target.style("width", newWidth + "px");
63405           }
63406           if (resizeOnY) {
63407             var maxHeight = mapSize[1] - 90;
63408             var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight);
63409             target.style("height", newHeight + "px");
63410           }
63411           dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target));
63412         }
63413         function clamp3(num, min3, max3) {
63414           return Math.max(min3, Math.min(num, max3));
63415         }
63416         function stopResize(d3_event) {
63417           if (pointerId !== (d3_event.pointerId || "mouse"))
63418             return;
63419           d3_event.preventDefault();
63420           d3_event.stopPropagation();
63421           select_default2(window).on("." + eventName, null);
63422         }
63423         return function initResize(d3_event) {
63424           d3_event.preventDefault();
63425           d3_event.stopPropagation();
63426           pointerId = d3_event.pointerId || "mouse";
63427           startX = d3_event.clientX;
63428           startY = d3_event.clientY;
63429           var targetRect = target.node().getBoundingClientRect();
63430           startWidth = targetRect.width;
63431           startHeight = targetRect.height;
63432           select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false);
63433           if (_pointerPrefix === "pointer") {
63434             select_default2(window).on("pointercancel." + eventName, stopResize, false);
63435           }
63436         };
63437       }
63438     }
63439     photoviewer.onMapResize = function() {
63440       var photoviewer2 = context.container().select(".photoviewer");
63441       var content = context.container().select(".main-content");
63442       var mapDimensions = utilGetDimensions(content, true);
63443       var photoDimensions = utilGetDimensions(photoviewer2, true);
63444       if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - 90) {
63445         var setPhotoDimensions = [
63446           Math.min(photoDimensions[0], mapDimensions[0]),
63447           Math.min(photoDimensions[1], mapDimensions[1] - 90)
63448         ];
63449         photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px");
63450         dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2));
63451       }
63452     };
63453     function subtractPadding(dimensions, selection2) {
63454       return [
63455         dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")),
63456         dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom"))
63457       ];
63458     }
63459     return utilRebind(photoviewer, dispatch14, "on");
63460   }
63461
63462   // modules/ui/restore.js
63463   function uiRestore(context) {
63464     return function(selection2) {
63465       if (!context.history().hasRestorableChanges())
63466         return;
63467       let modalSelection = uiModal(selection2, true);
63468       modalSelection.select(".modal").attr("class", "modal fillL");
63469       let introModal = modalSelection.select(".content");
63470       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading"));
63471       introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description"));
63472       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
63473       let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => {
63474         context.history().restore();
63475         modalSelection.remove();
63476       });
63477       restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore");
63478       restore.append("div").call(_t.append("restore.restore"));
63479       let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => {
63480         context.history().clearSaved();
63481         modalSelection.remove();
63482       });
63483       reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset");
63484       reset.append("div").call(_t.append("restore.reset"));
63485       restore.node().focus();
63486     };
63487   }
63488
63489   // modules/ui/scale.js
63490   function uiScale(context) {
63491     var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8;
63492     function scaleDefs(loc1, loc2) {
63493       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;
63494       if (isImperial) {
63495         buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1];
63496       } else {
63497         buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1];
63498       }
63499       for (i3 = 0; i3 < buckets.length; i3++) {
63500         val = buckets[i3];
63501         if (dist >= val) {
63502           scale.dist = Math.floor(dist / val) * val;
63503           break;
63504         } else {
63505           scale.dist = +dist.toFixed(2);
63506         }
63507       }
63508       dLon = geoMetersToLon(scale.dist / conversion, lat);
63509       scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]);
63510       scale.text = displayLength(scale.dist / conversion, isImperial);
63511       return scale;
63512     }
63513     function update(selection2) {
63514       var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2);
63515       selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight);
63516       selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text);
63517     }
63518     return function(selection2) {
63519       function switchUnits() {
63520         isImperial = !isImperial;
63521         selection2.call(update);
63522       }
63523       var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)");
63524       scalegroup.append("path").attr("class", "scale-path");
63525       selection2.append("div").attr("class", "scale-text");
63526       selection2.call(update);
63527       context.map().on("move.scale", function() {
63528         update(selection2);
63529       });
63530     };
63531   }
63532
63533   // modules/ui/shortcuts.js
63534   function uiShortcuts(context) {
63535     var detected = utilDetect();
63536     var _activeTab = 0;
63537     var _modalSelection;
63538     var _selection = select_default2(null);
63539     var _dataShortcuts;
63540     function shortcutsModal(_modalSelection2) {
63541       _modalSelection2.select(".modal").classed("modal-shortcuts", true);
63542       var content = _modalSelection2.select(".content");
63543       content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title"));
63544       _mainFileFetcher.get("shortcuts").then(function(data) {
63545         _dataShortcuts = data;
63546         content.call(render);
63547       }).catch(function() {
63548       });
63549     }
63550     function render(selection2) {
63551       if (!_dataShortcuts)
63552         return;
63553       var wrapper = selection2.selectAll(".wrapper").data([0]);
63554       var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section");
63555       var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar");
63556       var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list");
63557       wrapper = wrapper.merge(wrapperEnter);
63558       var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts);
63559       var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) {
63560         d3_event.preventDefault();
63561         var i3 = _dataShortcuts.indexOf(d2);
63562         _activeTab = i3;
63563         render(selection2);
63564       });
63565       tabsEnter.append("span").html(function(d2) {
63566         return _t.html(d2.text);
63567       });
63568       wrapper.selectAll(".tab").classed("active", function(d2, i3) {
63569         return i3 === _activeTab;
63570       });
63571       var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts);
63572       var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) {
63573         return "shortcut-tab shortcut-tab-" + d2.tab;
63574       });
63575       var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) {
63576         return d2.columns;
63577       }).enter().append("table").attr("class", "shortcut-column");
63578       var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) {
63579         return d2.rows;
63580       }).enter().append("tr").attr("class", "shortcut-row");
63581       var sectionRows = rowsEnter.filter(function(d2) {
63582         return !d2.shortcuts;
63583       });
63584       sectionRows.append("td");
63585       sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) {
63586         return _t.html(d2.text);
63587       });
63588       var shortcutRows = rowsEnter.filter(function(d2) {
63589         return d2.shortcuts;
63590       });
63591       var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys");
63592       var modifierKeys = shortcutKeys.filter(function(d2) {
63593         return d2.modifiers;
63594       });
63595       modifierKeys.selectAll("kbd.modifier").data(function(d2) {
63596         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63597           return ["\u2318"];
63598         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63599           return [];
63600         } else {
63601           return d2.modifiers;
63602         }
63603       }).enter().each(function() {
63604         var selection3 = select_default2(this);
63605         selection3.append("kbd").attr("class", "modifier").text(function(d2) {
63606           return uiCmd.display(d2);
63607         });
63608         selection3.append("span").text("+");
63609       });
63610       shortcutKeys.selectAll("kbd.shortcut").data(function(d2) {
63611         var arr = d2.shortcuts;
63612         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63613           arr = ["Y"];
63614         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63615           arr = ["F11"];
63616         }
63617         arr = arr.map(function(s2) {
63618           return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2);
63619         });
63620         return utilArrayUniq(arr).map(function(s2) {
63621           return {
63622             shortcut: s2,
63623             separator: d2.separator,
63624             suffix: d2.suffix
63625           };
63626         });
63627       }).enter().each(function(d2, i3, nodes) {
63628         var selection3 = select_default2(this);
63629         var click = d2.shortcut.toLowerCase().match(/(.*).click/);
63630         if (click && click[1]) {
63631           selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation"));
63632         } else if (d2.shortcut.toLowerCase() === "long-press") {
63633           selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation"));
63634         } else if (d2.shortcut.toLowerCase() === "tap") {
63635           selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation"));
63636         } else {
63637           selection3.append("kbd").attr("class", "shortcut").text(function(d4) {
63638             return d4.shortcut;
63639           });
63640         }
63641         if (i3 < nodes.length - 1) {
63642           selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0");
63643         } else if (i3 === nodes.length - 1 && d2.suffix) {
63644           selection3.append("span").text(d2.suffix);
63645         }
63646       });
63647       shortcutKeys.filter(function(d2) {
63648         return d2.gesture;
63649       }).each(function() {
63650         var selection3 = select_default2(this);
63651         selection3.append("span").text("+");
63652         selection3.append("span").attr("class", "gesture").html(function(d2) {
63653           return _t.html(d2.gesture);
63654         });
63655       });
63656       shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) {
63657         return d2.text ? _t.html(d2.text) : "\xA0";
63658       });
63659       wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) {
63660         return i3 === _activeTab ? "flex" : "none";
63661       });
63662     }
63663     return function(selection2, show) {
63664       _selection = selection2;
63665       if (show) {
63666         _modalSelection = uiModal(selection2);
63667         _modalSelection.call(shortcutsModal);
63668       } else {
63669         context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() {
63670           if (context.container().selectAll(".modal-shortcuts").size()) {
63671             if (_modalSelection) {
63672               _modalSelection.close();
63673               _modalSelection = null;
63674             }
63675           } else {
63676             _modalSelection = uiModal(_selection);
63677             _modalSelection.call(shortcutsModal);
63678           }
63679         });
63680       }
63681     };
63682   }
63683
63684   // modules/ui/data_header.js
63685   function uiDataHeader() {
63686     var _datum;
63687     function dataHeader(selection2) {
63688       var header = selection2.selectAll(".data-header").data(
63689         _datum ? [_datum] : [],
63690         function(d2) {
63691           return d2.__featurehash__;
63692         }
63693       );
63694       header.exit().remove();
63695       var headerEnter = header.enter().append("div").attr("class", "data-header");
63696       var iconEnter = headerEnter.append("div").attr("class", "data-header-icon");
63697       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill"));
63698       headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title"));
63699     }
63700     dataHeader.datum = function(val) {
63701       if (!arguments.length)
63702         return _datum;
63703       _datum = val;
63704       return this;
63705     };
63706     return dataHeader;
63707   }
63708
63709   // modules/ui/combobox.js
63710   var _comboHideTimerID;
63711   function uiCombobox(context, klass) {
63712     var dispatch14 = dispatch_default("accept", "cancel", "update");
63713     var container = context.container();
63714     var _suggestions = [];
63715     var _data = [];
63716     var _fetched = {};
63717     var _selected = null;
63718     var _canAutocomplete = true;
63719     var _caseSensitive = false;
63720     var _cancelFetch = false;
63721     var _minItems = 2;
63722     var _tDown = 0;
63723     var _mouseEnterHandler, _mouseLeaveHandler;
63724     var _fetcher = function(val, cb) {
63725       cb(_data.filter(function(d2) {
63726         var terms = d2.terms || [];
63727         terms.push(d2.value);
63728         if (d2.key) {
63729           terms.push(d2.key);
63730         }
63731         return terms.some(function(term) {
63732           return term.toString().toLowerCase().indexOf(val.toLowerCase()) !== -1;
63733         });
63734       }));
63735     };
63736     var combobox = function(input, attachTo) {
63737       if (!input || input.empty())
63738         return;
63739       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() {
63740         var parent = this.parentNode;
63741         var sibling = this.nextSibling;
63742         select_default2(parent).selectAll(".combobox-caret").filter(function(d2) {
63743           return d2 === input.node();
63744         }).data([input.node()]).enter().insert("div", function() {
63745           return sibling;
63746         }).attr("class", "combobox-caret").on("mousedown.combo-caret", function(d3_event) {
63747           d3_event.preventDefault();
63748           input.node().focus();
63749           mousedown(d3_event);
63750         }).on("mouseup.combo-caret", function(d3_event) {
63751           d3_event.preventDefault();
63752           mouseup(d3_event);
63753         });
63754       });
63755       function mousedown(d3_event) {
63756         if (d3_event.button !== 0)
63757           return;
63758         if (input.classed("disabled"))
63759           return;
63760         _tDown = +/* @__PURE__ */ new Date();
63761         var start2 = input.property("selectionStart");
63762         var end = input.property("selectionEnd");
63763         if (start2 !== end) {
63764           var val = utilGetSetValue(input);
63765           input.node().setSelectionRange(val.length, val.length);
63766           return;
63767         }
63768         input.on("mouseup.combo-input", mouseup);
63769       }
63770       function mouseup(d3_event) {
63771         input.on("mouseup.combo-input", null);
63772         if (d3_event.button !== 0)
63773           return;
63774         if (input.classed("disabled"))
63775           return;
63776         if (input.node() !== document.activeElement)
63777           return;
63778         var start2 = input.property("selectionStart");
63779         var end = input.property("selectionEnd");
63780         if (start2 !== end)
63781           return;
63782         var combo = container.selectAll(".combobox");
63783         if (combo.empty() || combo.datum() !== input.node()) {
63784           var tOrig = _tDown;
63785           window.setTimeout(function() {
63786             if (tOrig !== _tDown)
63787               return;
63788             fetchComboData("", function() {
63789               show();
63790               render();
63791             });
63792           }, 250);
63793         } else {
63794           hide();
63795         }
63796       }
63797       function focus() {
63798         fetchComboData("");
63799       }
63800       function blur() {
63801         _comboHideTimerID = window.setTimeout(hide, 75);
63802       }
63803       function show() {
63804         hide();
63805         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) {
63806           d3_event.preventDefault();
63807         });
63808         container.on("scroll.combo-scroll", render, true);
63809       }
63810       function hide() {
63811         if (_comboHideTimerID) {
63812           window.clearTimeout(_comboHideTimerID);
63813           _comboHideTimerID = void 0;
63814         }
63815         container.selectAll(".combobox").remove();
63816         container.on("scroll.combo-scroll", null);
63817       }
63818       function keydown(d3_event) {
63819         var shown = !container.selectAll(".combobox").empty();
63820         var tagName = input.node() ? input.node().tagName.toLowerCase() : "";
63821         switch (d3_event.keyCode) {
63822           case 8:
63823           case 46:
63824             d3_event.stopPropagation();
63825             _selected = null;
63826             render();
63827             input.on("input.combo-input", function() {
63828               var start2 = input.property("selectionStart");
63829               input.node().setSelectionRange(start2, start2);
63830               input.on("input.combo-input", change);
63831               change(false);
63832             });
63833             break;
63834           case 9:
63835             accept(d3_event);
63836             break;
63837           case 13:
63838             d3_event.preventDefault();
63839             d3_event.stopPropagation();
63840             accept(d3_event);
63841             break;
63842           case 38:
63843             if (tagName === "textarea" && !shown)
63844               return;
63845             d3_event.preventDefault();
63846             if (tagName === "input" && !shown) {
63847               show();
63848             }
63849             nav(-1);
63850             break;
63851           case 40:
63852             if (tagName === "textarea" && !shown)
63853               return;
63854             d3_event.preventDefault();
63855             if (tagName === "input" && !shown) {
63856               show();
63857             }
63858             nav(1);
63859             break;
63860         }
63861       }
63862       function keyup(d3_event) {
63863         switch (d3_event.keyCode) {
63864           case 27:
63865             cancel();
63866             break;
63867         }
63868       }
63869       function change(doAutoComplete) {
63870         if (doAutoComplete === void 0)
63871           doAutoComplete = true;
63872         fetchComboData(value(), function(skipAutosuggest) {
63873           _selected = null;
63874           var val = input.property("value");
63875           if (_suggestions.length) {
63876             if (doAutoComplete && !skipAutosuggest && input.property("selectionEnd") === val.length) {
63877               _selected = tryAutocomplete();
63878             }
63879             if (!_selected) {
63880               _selected = val;
63881             }
63882           }
63883           if (val.length) {
63884             var combo = container.selectAll(".combobox");
63885             if (combo.empty()) {
63886               show();
63887             }
63888           } else {
63889             hide();
63890           }
63891           render();
63892         });
63893       }
63894       function nav(dir) {
63895         if (_suggestions.length) {
63896           var index = -1;
63897           for (var i3 = 0; i3 < _suggestions.length; i3++) {
63898             if (_selected && _suggestions[i3].value === _selected) {
63899               index = i3;
63900               break;
63901             }
63902           }
63903           index = Math.max(Math.min(index + dir, _suggestions.length - 1), 0);
63904           _selected = _suggestions[index].value;
63905           utilGetSetValue(input, _selected);
63906           dispatch14.call("update");
63907         }
63908         render();
63909         ensureVisible();
63910       }
63911       function ensureVisible() {
63912         var combo = container.selectAll(".combobox");
63913         if (combo.empty())
63914           return;
63915         var containerRect = container.node().getBoundingClientRect();
63916         var comboRect = combo.node().getBoundingClientRect();
63917         if (comboRect.bottom > containerRect.bottom) {
63918           var node = attachTo ? attachTo.node() : input.node();
63919           node.scrollIntoView({ behavior: "instant", block: "center" });
63920           render();
63921         }
63922         var selected = combo.selectAll(".combobox-option.selected").node();
63923         if (selected) {
63924           selected.scrollIntoView({ behavior: "smooth", block: "nearest" });
63925         }
63926       }
63927       function value() {
63928         var value2 = input.property("value");
63929         var start2 = input.property("selectionStart");
63930         var end = input.property("selectionEnd");
63931         if (start2 && end) {
63932           value2 = value2.substring(0, start2);
63933         }
63934         return value2;
63935       }
63936       function fetchComboData(v2, cb) {
63937         _cancelFetch = false;
63938         _fetcher.call(input, v2, function(results, skipAutosuggest) {
63939           if (_cancelFetch)
63940             return;
63941           _suggestions = results;
63942           results.forEach(function(d2) {
63943             _fetched[d2.value] = d2;
63944           });
63945           if (cb) {
63946             cb(skipAutosuggest);
63947           }
63948         });
63949       }
63950       function tryAutocomplete() {
63951         if (!_canAutocomplete)
63952           return;
63953         var val = _caseSensitive ? value() : value().toLowerCase();
63954         if (!val)
63955           return;
63956         if (isFinite(val))
63957           return;
63958         const suggestionValues = [];
63959         _suggestions.forEach((s2) => {
63960           suggestionValues.push(s2.value);
63961           if (s2.key && s2.key !== s2.value) {
63962             suggestionValues.push(s2.key);
63963           }
63964         });
63965         var bestIndex = -1;
63966         for (var i3 = 0; i3 < suggestionValues.length; i3++) {
63967           var suggestion = suggestionValues[i3];
63968           var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase();
63969           if (compare2 === val) {
63970             bestIndex = i3;
63971             break;
63972           } else if (bestIndex === -1 && compare2.indexOf(val) === 0) {
63973             bestIndex = i3;
63974           }
63975         }
63976         if (bestIndex !== -1) {
63977           var bestVal = suggestionValues[bestIndex];
63978           input.property("value", bestVal);
63979           input.node().setSelectionRange(val.length, bestVal.length);
63980           dispatch14.call("update");
63981           return bestVal;
63982         }
63983       }
63984       function render() {
63985         if (_suggestions.length < _minItems || document.activeElement !== input.node()) {
63986           hide();
63987           return;
63988         }
63989         var shown = !container.selectAll(".combobox").empty();
63990         if (!shown)
63991           return;
63992         var combo = container.selectAll(".combobox");
63993         var options2 = combo.selectAll(".combobox-option").data(_suggestions, function(d2) {
63994           return d2.value;
63995         });
63996         options2.exit().remove();
63997         options2.enter().append("a").attr("class", function(d2) {
63998           return "combobox-option " + (d2.klass || "");
63999         }).attr("title", function(d2) {
64000           return d2.title;
64001         }).each(function(d2) {
64002           if (d2.display) {
64003             d2.display(select_default2(this));
64004           } else {
64005             select_default2(this).text(d2.value);
64006           }
64007         }).on("mouseenter", _mouseEnterHandler).on("mouseleave", _mouseLeaveHandler).merge(options2).classed("selected", function(d2) {
64008           return d2.value === _selected || d2.key === _selected;
64009         }).on("click.combo-option", accept).order();
64010         var node = attachTo ? attachTo.node() : input.node();
64011         var containerRect = container.node().getBoundingClientRect();
64012         var rect = node.getBoundingClientRect();
64013         combo.style("left", rect.left + 5 - containerRect.left + "px").style("width", rect.width - 10 + "px").style("top", rect.height + rect.top - containerRect.top + "px");
64014       }
64015       function accept(d3_event, d2) {
64016         _cancelFetch = true;
64017         var thiz = input.node();
64018         if (d2) {
64019           utilGetSetValue(input, d2.value);
64020           utilTriggerEvent(input, "change");
64021         }
64022         var val = utilGetSetValue(input);
64023         thiz.setSelectionRange(val.length, val.length);
64024         d2 = _fetched[val];
64025         dispatch14.call("accept", thiz, d2, val);
64026         hide();
64027       }
64028       function cancel() {
64029         _cancelFetch = true;
64030         var thiz = input.node();
64031         var val = utilGetSetValue(input);
64032         var start2 = input.property("selectionStart");
64033         var end = input.property("selectionEnd");
64034         val = val.slice(0, start2) + val.slice(end);
64035         utilGetSetValue(input, val);
64036         thiz.setSelectionRange(val.length, val.length);
64037         dispatch14.call("cancel", thiz);
64038         hide();
64039       }
64040     };
64041     combobox.canAutocomplete = function(val) {
64042       if (!arguments.length)
64043         return _canAutocomplete;
64044       _canAutocomplete = val;
64045       return combobox;
64046     };
64047     combobox.caseSensitive = function(val) {
64048       if (!arguments.length)
64049         return _caseSensitive;
64050       _caseSensitive = val;
64051       return combobox;
64052     };
64053     combobox.data = function(val) {
64054       if (!arguments.length)
64055         return _data;
64056       _data = val;
64057       return combobox;
64058     };
64059     combobox.fetcher = function(val) {
64060       if (!arguments.length)
64061         return _fetcher;
64062       _fetcher = val;
64063       return combobox;
64064     };
64065     combobox.minItems = function(val) {
64066       if (!arguments.length)
64067         return _minItems;
64068       _minItems = val;
64069       return combobox;
64070     };
64071     combobox.itemsMouseEnter = function(val) {
64072       if (!arguments.length)
64073         return _mouseEnterHandler;
64074       _mouseEnterHandler = val;
64075       return combobox;
64076     };
64077     combobox.itemsMouseLeave = function(val) {
64078       if (!arguments.length)
64079         return _mouseLeaveHandler;
64080       _mouseLeaveHandler = val;
64081       return combobox;
64082     };
64083     return utilRebind(combobox, dispatch14, "on");
64084   }
64085   uiCombobox.off = function(input, context) {
64086     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);
64087     context.container().on("scroll.combo-scroll", null);
64088   };
64089
64090   // modules/ui/disclosure.js
64091   function uiDisclosure(context, key, expandedDefault) {
64092     var dispatch14 = dispatch_default("toggled");
64093     var _expanded;
64094     var _label = utilFunctor("");
64095     var _updatePreference = true;
64096     var _content = function() {
64097     };
64098     var disclosure = function(selection2) {
64099       if (_expanded === void 0 || _expanded === null) {
64100         var preference = corePreferences("disclosure." + key + ".expanded");
64101         _expanded = preference === null ? !!expandedDefault : preference === "true";
64102       }
64103       var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]);
64104       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"));
64105       hideToggleEnter.append("span").attr("class", "hide-toggle-text");
64106       hideToggle = hideToggleEnter.merge(hideToggle);
64107       hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded);
64108       const label = _label();
64109       const labelSelection = hideToggle.selectAll(".hide-toggle-text");
64110       if (typeof label !== "function") {
64111         labelSelection.text(_label());
64112       } else {
64113         labelSelection.text("").call(label);
64114       }
64115       hideToggle.selectAll(".hide-toggle-icon").attr(
64116         "xlink:href",
64117         _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64118       );
64119       var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]);
64120       wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded);
64121       if (_expanded) {
64122         wrap2.call(_content);
64123       }
64124       function toggle(d3_event) {
64125         d3_event.preventDefault();
64126         _expanded = !_expanded;
64127         if (_updatePreference) {
64128           corePreferences("disclosure." + key + ".expanded", _expanded);
64129         }
64130         hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand")));
64131         hideToggle.selectAll(".hide-toggle-icon").attr(
64132           "xlink:href",
64133           _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64134         );
64135         wrap2.call(uiToggle(_expanded));
64136         if (_expanded) {
64137           wrap2.call(_content);
64138         }
64139         dispatch14.call("toggled", this, _expanded);
64140       }
64141     };
64142     disclosure.label = function(val) {
64143       if (!arguments.length)
64144         return _label;
64145       _label = utilFunctor(val);
64146       return disclosure;
64147     };
64148     disclosure.expanded = function(val) {
64149       if (!arguments.length)
64150         return _expanded;
64151       _expanded = val;
64152       return disclosure;
64153     };
64154     disclosure.updatePreference = function(val) {
64155       if (!arguments.length)
64156         return _updatePreference;
64157       _updatePreference = val;
64158       return disclosure;
64159     };
64160     disclosure.content = function(val) {
64161       if (!arguments.length)
64162         return _content;
64163       _content = val;
64164       return disclosure;
64165     };
64166     return utilRebind(disclosure, dispatch14, "on");
64167   }
64168
64169   // modules/ui/section.js
64170   function uiSection(id2, context) {
64171     var _classes = utilFunctor("");
64172     var _shouldDisplay;
64173     var _content;
64174     var _disclosure;
64175     var _label;
64176     var _expandedByDefault = utilFunctor(true);
64177     var _disclosureContent;
64178     var _disclosureExpanded;
64179     var _containerSelection = select_default2(null);
64180     var section = {
64181       id: id2
64182     };
64183     section.classes = function(val) {
64184       if (!arguments.length)
64185         return _classes;
64186       _classes = utilFunctor(val);
64187       return section;
64188     };
64189     section.label = function(val) {
64190       if (!arguments.length)
64191         return _label;
64192       _label = utilFunctor(val);
64193       return section;
64194     };
64195     section.expandedByDefault = function(val) {
64196       if (!arguments.length)
64197         return _expandedByDefault;
64198       _expandedByDefault = utilFunctor(val);
64199       return section;
64200     };
64201     section.shouldDisplay = function(val) {
64202       if (!arguments.length)
64203         return _shouldDisplay;
64204       _shouldDisplay = utilFunctor(val);
64205       return section;
64206     };
64207     section.content = function(val) {
64208       if (!arguments.length)
64209         return _content;
64210       _content = val;
64211       return section;
64212     };
64213     section.disclosureContent = function(val) {
64214       if (!arguments.length)
64215         return _disclosureContent;
64216       _disclosureContent = val;
64217       return section;
64218     };
64219     section.disclosureExpanded = function(val) {
64220       if (!arguments.length)
64221         return _disclosureExpanded;
64222       _disclosureExpanded = val;
64223       return section;
64224     };
64225     section.render = function(selection2) {
64226       _containerSelection = selection2.selectAll(".section-" + id2).data([0]);
64227       var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || ""));
64228       _containerSelection = sectionEnter.merge(_containerSelection);
64229       _containerSelection.call(renderContent);
64230     };
64231     section.reRender = function() {
64232       _containerSelection.call(renderContent);
64233     };
64234     section.selection = function() {
64235       return _containerSelection;
64236     };
64237     section.disclosure = function() {
64238       return _disclosure;
64239     };
64240     function renderContent(selection2) {
64241       if (_shouldDisplay) {
64242         var shouldDisplay = _shouldDisplay();
64243         selection2.classed("hide", !shouldDisplay);
64244         if (!shouldDisplay) {
64245           selection2.html("");
64246           return;
64247         }
64248       }
64249       if (_disclosureContent) {
64250         if (!_disclosure) {
64251           _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent);
64252         }
64253         if (_disclosureExpanded !== void 0) {
64254           _disclosure.expanded(_disclosureExpanded);
64255           _disclosureExpanded = void 0;
64256         }
64257         selection2.call(_disclosure);
64258         return;
64259       }
64260       if (_content) {
64261         selection2.call(_content);
64262       }
64263     }
64264     return section;
64265   }
64266
64267   // modules/ui/tag_reference.js
64268   function uiTagReference(what) {
64269     var wikibase = what.qid ? services.wikidata : services.osmWikibase;
64270     var tagReference = {};
64271     var _button = select_default2(null);
64272     var _body = select_default2(null);
64273     var _loaded;
64274     var _showing;
64275     function load() {
64276       if (!wikibase)
64277         return;
64278       _button.classed("tag-reference-loading", true);
64279       wikibase.getDocs(what, gotDocs);
64280     }
64281     function gotDocs(err, docs) {
64282       _body.html("");
64283       if (!docs || !docs.title) {
64284         _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key"));
64285         done();
64286         return;
64287       }
64288       if (docs.imageURL) {
64289         _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.description).attr("src", docs.imageURL).on("load", function() {
64290           done();
64291         }).on("error", function() {
64292           select_default2(this).remove();
64293           done();
64294         });
64295       } else {
64296         done();
64297       }
64298       var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span");
64299       if (docs.description) {
64300         tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").text(docs.description);
64301       } else {
64302         tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key"));
64303       }
64304       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"));
64305       if (docs.wiki) {
64306         _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));
64307       }
64308       if (what.key === "comment") {
64309         _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"));
64310       }
64311     }
64312     function done() {
64313       _loaded = true;
64314       _button.classed("tag-reference-loading", false);
64315       _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1");
64316       _showing = true;
64317       _button.selectAll("svg.icon use").each(function() {
64318         var iconUse = select_default2(this);
64319         if (iconUse.attr("href") === "#iD-icon-info") {
64320           iconUse.attr("href", "#iD-icon-info-filled");
64321         }
64322       });
64323     }
64324     function hide() {
64325       _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
64326         _body.classed("expanded", false);
64327       });
64328       _showing = false;
64329       _button.selectAll("svg.icon use").each(function() {
64330         var iconUse = select_default2(this);
64331         if (iconUse.attr("href") === "#iD-icon-info-filled") {
64332           iconUse.attr("href", "#iD-icon-info");
64333         }
64334       });
64335     }
64336     tagReference.button = function(selection2, klass, iconName) {
64337       _button = selection2.selectAll(".tag-reference-button").data([0]);
64338       _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button);
64339       _button.on("click", function(d3_event) {
64340         d3_event.stopPropagation();
64341         d3_event.preventDefault();
64342         this.blur();
64343         if (_showing) {
64344           hide();
64345         } else if (_loaded) {
64346           done();
64347         } else {
64348           load();
64349         }
64350       });
64351     };
64352     tagReference.body = function(selection2) {
64353       var itemID = what.qid || what.key + "-" + (what.value || "");
64354       _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) {
64355         return d2;
64356       });
64357       _body.exit().remove();
64358       _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body);
64359       if (_showing === false) {
64360         hide();
64361       }
64362     };
64363     tagReference.showing = function(val) {
64364       if (!arguments.length)
64365         return _showing;
64366       _showing = val;
64367       return tagReference;
64368     };
64369     return tagReference;
64370   }
64371
64372   // modules/ui/field_help.js
64373   function uiFieldHelp(context, fieldName) {
64374     var fieldHelp = {};
64375     var _inspector = select_default2(null);
64376     var _wrap = select_default2(null);
64377     var _body = select_default2(null);
64378     var fieldHelpKeys = {
64379       restrictions: [
64380         ["about", [
64381           "about",
64382           "from_via_to",
64383           "maxdist",
64384           "maxvia"
64385         ]],
64386         ["inspecting", [
64387           "about",
64388           "from_shadow",
64389           "allow_shadow",
64390           "restrict_shadow",
64391           "only_shadow",
64392           "restricted",
64393           "only"
64394         ]],
64395         ["modifying", [
64396           "about",
64397           "indicators",
64398           "allow_turn",
64399           "restrict_turn",
64400           "only_turn"
64401         ]],
64402         ["tips", [
64403           "simple",
64404           "simple_example",
64405           "indirect",
64406           "indirect_example",
64407           "indirect_noedit"
64408         ]]
64409       ]
64410     };
64411     var fieldHelpHeadings = {};
64412     var replacements = {
64413       distField: { html: _t.html("restriction.controls.distance") },
64414       viaField: { html: _t.html("restriction.controls.via") },
64415       fromShadow: { html: icon("#iD-turn-shadow", "inline shadow from") },
64416       allowShadow: { html: icon("#iD-turn-shadow", "inline shadow allow") },
64417       restrictShadow: { html: icon("#iD-turn-shadow", "inline shadow restrict") },
64418       onlyShadow: { html: icon("#iD-turn-shadow", "inline shadow only") },
64419       allowTurn: { html: icon("#iD-turn-yes", "inline turn") },
64420       restrictTurn: { html: icon("#iD-turn-no", "inline turn") },
64421       onlyTurn: { html: icon("#iD-turn-only", "inline turn") }
64422     };
64423     var docs = fieldHelpKeys[fieldName].map(function(key) {
64424       var helpkey = "help.field." + fieldName + "." + key[0];
64425       var text = key[1].reduce(function(all, part) {
64426         var subkey = helpkey + "." + part;
64427         var depth = fieldHelpHeadings[subkey];
64428         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
64429         return all + hhh + _t.html(subkey, replacements) + "\n\n";
64430       }, "");
64431       return {
64432         key: helpkey,
64433         title: _t.html(helpkey + ".title"),
64434         html: marked(text.trim())
64435       };
64436     });
64437     function show() {
64438       updatePosition();
64439       _body.classed("hide", false).style("opacity", "0").transition().duration(200).style("opacity", "1");
64440     }
64441     function hide() {
64442       _body.classed("hide", true).transition().duration(200).style("opacity", "0").on("end", function() {
64443         _body.classed("hide", true);
64444       });
64445     }
64446     function clickHelp(index) {
64447       var d2 = docs[index];
64448       var tkeys = fieldHelpKeys[fieldName][index][1];
64449       _body.selectAll(".field-help-nav-item").classed("active", function(d4, i3) {
64450         return i3 === index;
64451       });
64452       var content = _body.selectAll(".field-help-content").html(d2.html);
64453       content.selectAll("p").attr("class", function(d4, i3) {
64454         return tkeys[i3];
64455       });
64456       if (d2.key === "help.field.restrictions.inspecting") {
64457         content.insert("img", "p.from_shadow").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_inspect.gif"));
64458       } else if (d2.key === "help.field.restrictions.modifying") {
64459         content.insert("img", "p.allow_turn").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_modify.gif"));
64460       }
64461     }
64462     fieldHelp.button = function(selection2) {
64463       if (_body.empty())
64464         return;
64465       var button = selection2.selectAll(".field-help-button").data([0]);
64466       button.enter().append("button").attr("class", "field-help-button").call(svgIcon("#iD-icon-help")).merge(button).on("click", function(d3_event) {
64467         d3_event.stopPropagation();
64468         d3_event.preventDefault();
64469         if (_body.classed("hide")) {
64470           show();
64471         } else {
64472           hide();
64473         }
64474       });
64475     };
64476     function updatePosition() {
64477       var wrap2 = _wrap.node();
64478       var inspector = _inspector.node();
64479       var wRect = wrap2.getBoundingClientRect();
64480       var iRect = inspector.getBoundingClientRect();
64481       _body.style("top", wRect.top + inspector.scrollTop - iRect.top + "px");
64482     }
64483     fieldHelp.body = function(selection2) {
64484       _wrap = selection2.selectAll(".form-field-input-wrap");
64485       if (_wrap.empty())
64486         return;
64487       _inspector = context.container().select(".sidebar .entity-editor-pane .inspector-body");
64488       if (_inspector.empty())
64489         return;
64490       _body = _inspector.selectAll(".field-help-body").data([0]);
64491       var enter = _body.enter().append("div").attr("class", "field-help-body hide");
64492       var titleEnter = enter.append("div").attr("class", "field-help-title cf");
64493       titleEnter.append("h2").attr("class", _mainLocalizer.textDirection() === "rtl" ? "fr" : "fl").call(_t.append("help.field." + fieldName + ".title"));
64494       titleEnter.append("button").attr("class", "fr close").attr("title", _t("icons.close")).on("click", function(d3_event) {
64495         d3_event.stopPropagation();
64496         d3_event.preventDefault();
64497         hide();
64498       }).call(svgIcon("#iD-icon-close"));
64499       var navEnter = enter.append("div").attr("class", "field-help-nav cf");
64500       var titles = docs.map(function(d2) {
64501         return d2.title;
64502       });
64503       navEnter.selectAll(".field-help-nav-item").data(titles).enter().append("div").attr("class", "field-help-nav-item").html(function(d2) {
64504         return d2;
64505       }).on("click", function(d3_event, d2) {
64506         d3_event.stopPropagation();
64507         d3_event.preventDefault();
64508         clickHelp(titles.indexOf(d2));
64509       });
64510       enter.append("div").attr("class", "field-help-content");
64511       _body = _body.merge(enter);
64512       clickHelp(0);
64513     };
64514     return fieldHelp;
64515   }
64516
64517   // modules/ui/fields/check.js
64518   function uiFieldCheck(field, context) {
64519     var dispatch14 = dispatch_default("change");
64520     var options2 = field.options;
64521     var values = [];
64522     var texts = [];
64523     var _tags;
64524     var input = select_default2(null);
64525     var text = select_default2(null);
64526     var label = select_default2(null);
64527     var reverser = select_default2(null);
64528     var _impliedYes;
64529     var _entityIDs = [];
64530     var _value;
64531     var stringsField = field.resolveReference("stringsCrossReference");
64532     if (!options2 && stringsField.options) {
64533       options2 = stringsField.options;
64534     }
64535     if (options2) {
64536       for (var i3 in options2) {
64537         var v2 = options2[i3];
64538         values.push(v2 === "undefined" ? void 0 : v2);
64539         texts.push(stringsField.t.html("options." + v2, { "default": v2 }));
64540       }
64541     } else {
64542       values = [void 0, "yes"];
64543       texts = [_t.html("inspector.unknown"), _t.html("inspector.check.yes")];
64544       if (field.type !== "defaultCheck") {
64545         values.push("no");
64546         texts.push(_t.html("inspector.check.no"));
64547       }
64548     }
64549     function checkImpliedYes() {
64550       _impliedYes = field.id === "oneway_yes";
64551       if (field.id === "oneway") {
64552         var entity = context.entity(_entityIDs[0]);
64553         for (var key in entity.tags) {
64554           if (key in osmOneWayTags && entity.tags[key] in osmOneWayTags[key]) {
64555             _impliedYes = true;
64556             texts[0] = _t.html("_tagging.presets.fields.oneway_yes.options.undefined");
64557             break;
64558           }
64559         }
64560       }
64561     }
64562     function reverserHidden() {
64563       if (!context.container().select("div.inspector-hover").empty())
64564         return true;
64565       return !(_value === "yes" || _impliedYes && !_value);
64566     }
64567     function reverserSetText(selection2) {
64568       var entity = _entityIDs.length && context.hasEntity(_entityIDs[0]);
64569       if (reverserHidden() || !entity)
64570         return selection2;
64571       var first = entity.first();
64572       var last = entity.isClosed() ? entity.nodes[entity.nodes.length - 2] : entity.last();
64573       var pseudoDirection = first < last;
64574       var icon2 = pseudoDirection ? "#iD-icon-forward" : "#iD-icon-backward";
64575       selection2.selectAll(".reverser-span").html("").call(_t.append("inspector.check.reverser")).call(svgIcon(icon2, "inline"));
64576       return selection2;
64577     }
64578     var check = function(selection2) {
64579       checkImpliedYes();
64580       label = selection2.selectAll(".form-field-input-wrap").data([0]);
64581       var enter = label.enter().append("label").attr("class", "form-field-input-wrap form-field-input-check");
64582       enter.append("input").property("indeterminate", field.type !== "defaultCheck").attr("type", "checkbox").attr("id", field.domId);
64583       enter.append("span").html(texts[0]).attr("class", "value");
64584       if (field.type === "onewayCheck") {
64585         enter.append("button").attr("class", "reverser" + (reverserHidden() ? " hide" : "")).append("span").attr("class", "reverser-span");
64586       }
64587       label = label.merge(enter);
64588       input = label.selectAll("input");
64589       text = label.selectAll("span.value");
64590       input.on("click", function(d3_event) {
64591         d3_event.stopPropagation();
64592         var t2 = {};
64593         if (Array.isArray(_tags[field.key])) {
64594           if (values.indexOf("yes") !== -1) {
64595             t2[field.key] = "yes";
64596           } else {
64597             t2[field.key] = values[0];
64598           }
64599         } else {
64600           t2[field.key] = values[(values.indexOf(_value) + 1) % values.length];
64601         }
64602         if (t2[field.key] === "reversible" || t2[field.key] === "alternating") {
64603           t2[field.key] = values[0];
64604         }
64605         dispatch14.call("change", this, t2);
64606       });
64607       if (field.type === "onewayCheck") {
64608         reverser = label.selectAll(".reverser");
64609         reverser.call(reverserSetText).on("click", function(d3_event) {
64610           d3_event.preventDefault();
64611           d3_event.stopPropagation();
64612           context.perform(
64613             function(graph) {
64614               for (var i4 in _entityIDs) {
64615                 graph = actionReverse(_entityIDs[i4])(graph);
64616               }
64617               return graph;
64618             },
64619             _t("operations.reverse.annotation.line", { n: 1 })
64620           );
64621           context.validator().validate();
64622           select_default2(this).call(reverserSetText);
64623         });
64624       }
64625     };
64626     check.entityIDs = function(val) {
64627       if (!arguments.length)
64628         return _entityIDs;
64629       _entityIDs = val;
64630       return check;
64631     };
64632     check.tags = function(tags) {
64633       _tags = tags;
64634       function isChecked(val) {
64635         return val !== "no" && val !== "" && val !== void 0 && val !== null;
64636       }
64637       function textFor(val) {
64638         if (val === "")
64639           val = void 0;
64640         var index = values.indexOf(val);
64641         return index !== -1 ? texts[index] : '"' + val + '"';
64642       }
64643       checkImpliedYes();
64644       var isMixed = Array.isArray(tags[field.key]);
64645       _value = !isMixed && tags[field.key] && tags[field.key].toLowerCase();
64646       if (field.type === "onewayCheck" && (_value === "1" || _value === "-1")) {
64647         _value = "yes";
64648       }
64649       input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value));
64650       text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed);
64651       label.classed("set", !!_value);
64652       if (field.type === "onewayCheck") {
64653         reverser.classed("hide", reverserHidden()).call(reverserSetText);
64654       }
64655     };
64656     check.focus = function() {
64657       input.node().focus();
64658     };
64659     return utilRebind(check, dispatch14, "on");
64660   }
64661
64662   // modules/ui/length_indicator.js
64663   function uiLengthIndicator(maxChars) {
64664     var _wrap = select_default2(null);
64665     var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => {
64666       selection2.text("");
64667       selection2.call(svgIcon("#iD-icon-alert", "inline"));
64668       selection2.call(_t.append("inspector.max_length_reached", { maxChars }));
64669     });
64670     var _silent = false;
64671     var lengthIndicator = function(selection2) {
64672       _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]);
64673       _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true);
64674       selection2.call(_tooltip);
64675     };
64676     lengthIndicator.update = function(val) {
64677       const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY));
64678       let indicator = _wrap.selectAll("span.length-indicator").data([strLen]);
64679       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");
64680       if (_silent)
64681         return;
64682       if (strLen > maxChars) {
64683         _tooltip.show();
64684       } else {
64685         _tooltip.hide();
64686       }
64687     };
64688     lengthIndicator.silent = function(val) {
64689       if (!arguments.length)
64690         return _silent;
64691       _silent = val;
64692       return lengthIndicator;
64693     };
64694     return lengthIndicator;
64695   }
64696
64697   // modules/ui/fields/combo.js
64698   function uiFieldCombo(field, context) {
64699     var dispatch14 = dispatch_default("change");
64700     var _isMulti = field.type === "multiCombo" || field.type === "manyCombo";
64701     var _isNetwork = field.type === "networkCombo";
64702     var _isSemi = field.type === "semiCombo";
64703     var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false;
64704     var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false;
64705     var _snake_case = field.snake_case || field.snake_case === void 0;
64706     var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1);
64707     var _container = select_default2(null);
64708     var _inputWrap = select_default2(null);
64709     var _input = select_default2(null);
64710     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
64711     var _comboData = [];
64712     var _multiData = [];
64713     var _entityIDs = [];
64714     var _tags;
64715     var _countryCode;
64716     var _staticPlaceholder;
64717     var _dataDeprecated = [];
64718     _mainFileFetcher.get("deprecated").then(function(d2) {
64719       _dataDeprecated = d2;
64720     }).catch(function() {
64721     });
64722     if (_isMulti && field.key && /[^:]$/.test(field.key)) {
64723       field.key += ":";
64724     }
64725     function snake(s2) {
64726       return s2.replace(/\s+/g, "_");
64727     }
64728     function clean2(s2) {
64729       return s2.split(";").map(function(s3) {
64730         return s3.trim();
64731       }).join(";");
64732     }
64733     function tagValue(dval) {
64734       dval = clean2(dval || "");
64735       var found = getOptions(true).find(function(o2) {
64736         return o2.key && clean2(o2.value) === dval;
64737       });
64738       if (found)
64739         return found.key;
64740       if (field.type === "typeCombo" && !dval) {
64741         return "yes";
64742       }
64743       return restrictTagValueSpelling(dval) || void 0;
64744     }
64745     function restrictTagValueSpelling(dval) {
64746       if (_snake_case) {
64747         dval = snake(dval);
64748       }
64749       if (!field.caseSensitive) {
64750         dval = dval.toLowerCase();
64751       }
64752       return dval;
64753     }
64754     function getLabelId(field2, v2) {
64755       return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2);
64756     }
64757     function displayValue(tval) {
64758       tval = tval || "";
64759       var stringsField = field.resolveReference("stringsCrossReference");
64760       const labelId = getLabelId(stringsField, tval);
64761       if (stringsField.hasTextForStringId(labelId)) {
64762         return stringsField.t(labelId, { default: tval });
64763       }
64764       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64765         return "";
64766       }
64767       return tval;
64768     }
64769     function renderValue(tval) {
64770       tval = tval || "";
64771       var stringsField = field.resolveReference("stringsCrossReference");
64772       const labelId = getLabelId(stringsField, tval);
64773       if (stringsField.hasTextForStringId(labelId)) {
64774         return stringsField.t.append(labelId, { default: tval });
64775       }
64776       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64777         tval = "";
64778       }
64779       return (selection2) => selection2.text(tval);
64780     }
64781     function objectDifference(a2, b2) {
64782       return a2.filter(function(d1) {
64783         return !b2.some(function(d2) {
64784           return d1.value === d2.value;
64785         });
64786       });
64787     }
64788     function initCombo(selection2, attachTo) {
64789       if (!_allowCustomValues) {
64790         selection2.attr("readonly", "readonly");
64791       }
64792       if (_showTagInfoSuggestions && services.taginfo) {
64793         selection2.call(_combobox.fetcher(setTaginfoValues), attachTo);
64794         setTaginfoValues("", setPlaceholder);
64795       } else {
64796         selection2.call(_combobox, attachTo);
64797         setTimeout(() => setStaticValues(setPlaceholder), 0);
64798       }
64799     }
64800     function getOptions(allOptions) {
64801       var stringsField = field.resolveReference("stringsCrossReference");
64802       if (!(field.options || stringsField.options))
64803         return [];
64804       let options2;
64805       if (allOptions !== true) {
64806         options2 = field.options || stringsField.options;
64807       } else {
64808         options2 = [].concat(field.options, stringsField.options).filter(Boolean);
64809       }
64810       return options2.map(function(v2) {
64811         const labelId = getLabelId(stringsField, v2);
64812         return {
64813           key: v2,
64814           value: stringsField.t(labelId, { default: v2 }),
64815           title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }),
64816           display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64817           klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option"
64818         };
64819       });
64820     }
64821     function hasStaticValues() {
64822       return getOptions().length > 0;
64823     }
64824     function setStaticValues(callback, filter2) {
64825       _comboData = getOptions();
64826       if (filter2 !== void 0) {
64827         _comboData = _comboData.filter(filter2);
64828       }
64829       _comboData = objectDifference(_comboData, _multiData);
64830       _combobox.data(_comboData);
64831       if (callback)
64832         callback(_comboData);
64833     }
64834     function setTaginfoValues(q2, callback) {
64835       var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase());
64836       if (hasStaticValues()) {
64837         setStaticValues(callback, queryFilter);
64838       }
64839       var stringsField = field.resolveReference("stringsCrossReference");
64840       var fn = _isMulti ? "multikeys" : "values";
64841       var query = (_isMulti ? field.key : "") + q2;
64842       var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0;
64843       if (hasCountryPrefix) {
64844         query = _countryCode + ":";
64845       }
64846       var params = {
64847         debounce: q2 !== "",
64848         key: field.key,
64849         query
64850       };
64851       if (_entityIDs.length) {
64852         params.geometry = context.graph().geometry(_entityIDs[0]);
64853       }
64854       services.taginfo[fn](params, function(err, data) {
64855         if (err)
64856           return;
64857         data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes");
64858         data = data.filter((d2) => {
64859           var value = d2.value;
64860           if (_isMulti) {
64861             value = value.slice(field.key.length);
64862           }
64863           return value === restrictTagValueSpelling(value);
64864         });
64865         var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key];
64866         if (deprecatedValues) {
64867           data = data.filter((d2) => !deprecatedValues.includes(d2.value));
64868         }
64869         if (hasCountryPrefix) {
64870           data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0);
64871         }
64872         const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 }));
64873         _container.classed("empty-combobox", data.length === 0);
64874         _comboData = data.concat(additionalOptions).map(function(d2) {
64875           var v2 = d2.value;
64876           if (_isMulti)
64877             v2 = v2.replace(field.key, "");
64878           const labelId = getLabelId(stringsField, v2);
64879           var isLocalizable = stringsField.hasTextForStringId(labelId);
64880           var label = stringsField.t(labelId, { default: v2 });
64881           return {
64882             key: v2,
64883             value: label,
64884             title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }),
64885             display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64886             klass: isLocalizable ? "" : "raw-option"
64887           };
64888         });
64889         _comboData = _comboData.filter(queryFilter);
64890         _comboData = objectDifference(_comboData, _multiData);
64891         if (callback)
64892           callback(_comboData, hasStaticValues());
64893       });
64894     }
64895     function addComboboxIcons(disp, value) {
64896       const iconsField = field.resolveReference("iconsCrossReference");
64897       if (iconsField.icons) {
64898         return function(selection2) {
64899           var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon");
64900           if (iconsField.icons[value]) {
64901             span.call(svgIcon("#".concat(iconsField.icons[value])));
64902           }
64903           disp.call(this, selection2);
64904         };
64905       }
64906       return disp;
64907     }
64908     function setPlaceholder(values) {
64909       if (_isMulti || _isSemi) {
64910         _staticPlaceholder = field.placeholder() || _t("inspector.add");
64911       } else {
64912         var vals = values.map(function(d2) {
64913           return d2.value;
64914         }).filter(function(s2) {
64915           return s2.length < 20;
64916         });
64917         var placeholders = vals.length > 1 ? vals : values.map(function(d2) {
64918           return d2.key;
64919         });
64920         _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", ");
64921       }
64922       if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) {
64923         _staticPlaceholder += "\u2026";
64924       }
64925       var ph;
64926       if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
64927         ph = _t("inspector.multiple_values");
64928       } else {
64929         ph = _staticPlaceholder;
64930       }
64931       _container.selectAll("input").attr("placeholder", ph);
64932       var hideAdd = !_allowCustomValues && !values.length;
64933       _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
64934     }
64935     function change() {
64936       var t2 = {};
64937       var val;
64938       if (_isMulti || _isSemi) {
64939         var vals;
64940         if (_isMulti) {
64941           vals = [tagValue(utilGetSetValue(_input))];
64942         } else if (_isSemi) {
64943           val = tagValue(utilGetSetValue(_input)) || "";
64944           val = val.replace(/,/g, ";");
64945           vals = val.split(";");
64946         }
64947         vals = vals.filter(Boolean);
64948         if (!vals.length)
64949           return;
64950         _container.classed("active", false);
64951         utilGetSetValue(_input, "");
64952         if (_isMulti) {
64953           utilArrayUniq(vals).forEach(function(v2) {
64954             var key = (field.key || "") + v2;
64955             if (_tags) {
64956               var old = _tags[key];
64957               if (typeof old === "string" && old.toLowerCase() !== "no")
64958                 return;
64959             }
64960             key = context.cleanTagKey(key);
64961             field.keys.push(key);
64962             t2[key] = "yes";
64963           });
64964         } else if (_isSemi) {
64965           var arr = _multiData.map(function(d2) {
64966             return d2.key;
64967           });
64968           arr = arr.concat(vals);
64969           t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";"));
64970         }
64971         window.setTimeout(function() {
64972           _input.node().focus();
64973         }, 10);
64974       } else {
64975         var rawValue = utilGetSetValue(_input);
64976         if (!rawValue && Array.isArray(_tags[field.key]))
64977           return;
64978         val = context.cleanTagValue(tagValue(rawValue));
64979         t2[field.key] = val || void 0;
64980       }
64981       dispatch14.call("change", this, t2);
64982     }
64983     function removeMultikey(d3_event, d2) {
64984       d3_event.preventDefault();
64985       d3_event.stopPropagation();
64986       var t2 = {};
64987       if (_isMulti) {
64988         t2[d2.key] = void 0;
64989       } else if (_isSemi) {
64990         var arr = _multiData.map(function(md) {
64991           return md.key === d2.key ? null : md.key;
64992         }).filter(Boolean);
64993         arr = utilArrayUniq(arr);
64994         t2[field.key] = arr.length ? arr.join(";") : void 0;
64995         _lengthIndicator.update(t2[field.key]);
64996       }
64997       dispatch14.call("change", this, t2);
64998     }
64999     function invertMultikey(d3_event, d2) {
65000       d3_event.preventDefault();
65001       d3_event.stopPropagation();
65002       var t2 = {};
65003       if (_isMulti) {
65004         t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes";
65005       }
65006       dispatch14.call("change", this, t2);
65007     }
65008     function combo(selection2) {
65009       _container = selection2.selectAll(".form-field-input-wrap").data([0]);
65010       var type2 = _isMulti || _isSemi ? "multicombo" : "combo";
65011       _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container);
65012       if (_isMulti || _isSemi) {
65013         _container = _container.selectAll(".chiplist").data([0]);
65014         var listClass = "chiplist";
65015         if (field.key === "destination" || field.key === "via") {
65016           listClass += " full-line-chips";
65017         }
65018         _container = _container.enter().append("ul").attr("class", listClass).on("click", function() {
65019           window.setTimeout(function() {
65020             _input.node().focus();
65021           }, 10);
65022         }).merge(_container);
65023         _inputWrap = _container.selectAll(".input-wrap").data([0]);
65024         _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap);
65025         var hideAdd = !_allowCustomValues && !_comboData.length;
65026         _inputWrap.style("display", hideAdd ? "none" : null);
65027         _input = _inputWrap.selectAll("input").data([0]);
65028       } else {
65029         _input = _container.selectAll("input").data([0]);
65030       }
65031       _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input);
65032       if (_isSemi) {
65033         _inputWrap.call(_lengthIndicator);
65034       } else if (!_isMulti) {
65035         _container.call(_lengthIndicator);
65036       }
65037       if (_isNetwork) {
65038         var extent = combinedEntityExtent();
65039         var countryCode = extent && iso1A2Code(extent.center());
65040         _countryCode = countryCode && countryCode.toLowerCase();
65041       }
65042       _input.on("change", change).on("blur", change).on("input", function() {
65043         let val = utilGetSetValue(_input);
65044         updateIcon(val);
65045         if (_isSemi && _tags[field.key]) {
65046           val += ";" + _tags[field.key];
65047         }
65048         _lengthIndicator.update(val);
65049       });
65050       _input.on("keydown.field", function(d3_event) {
65051         switch (d3_event.keyCode) {
65052           case 13:
65053             _input.node().blur();
65054             d3_event.stopPropagation();
65055             break;
65056         }
65057       });
65058       if (_isMulti || _isSemi) {
65059         _combobox.on("accept", function() {
65060           _input.node().blur();
65061           _input.node().focus();
65062         });
65063         _input.on("focus", function() {
65064           _container.classed("active", true);
65065         });
65066       }
65067       _combobox.on("cancel", function() {
65068         _input.node().blur();
65069       }).on("update", function() {
65070         updateIcon(utilGetSetValue(_input));
65071       });
65072     }
65073     function updateIcon(value) {
65074       value = tagValue(value);
65075       let container = _container;
65076       if (field.type === "multiCombo" || field.type === "semiCombo") {
65077         container = _container.select(".input-wrap");
65078       }
65079       const iconsField = field.resolveReference("iconsCrossReference");
65080       if (iconsField.icons) {
65081         container.selectAll(".tag-value-icon").remove();
65082         if (iconsField.icons[value]) {
65083           container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value])));
65084         }
65085       }
65086     }
65087     combo.tags = function(tags) {
65088       _tags = tags;
65089       var stringsField = field.resolveReference("stringsCrossReference");
65090       var isMixed = Array.isArray(tags[field.key]);
65091       var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes");
65092       var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title"));
65093       var isKnownValue = (value) => showsValue(value) && !isRawValue(value);
65094       var isReadOnly = !_allowCustomValues;
65095       if (_isMulti || _isSemi) {
65096         _multiData = [];
65097         var maxLength;
65098         if (_isMulti) {
65099           for (var k2 in tags) {
65100             if (field.key && k2.indexOf(field.key) !== 0)
65101               continue;
65102             if (!field.key && field.keys.indexOf(k2) === -1)
65103               continue;
65104             var v2 = tags[k2];
65105             var suffix = field.key ? k2.slice(field.key.length) : k2;
65106             _multiData.push({
65107               key: k2,
65108               value: displayValue(suffix),
65109               display: addComboboxIcons(renderValue(suffix), suffix),
65110               state: typeof v2 === "string" ? v2.toLowerCase() : "",
65111               isMixed: Array.isArray(v2)
65112             });
65113           }
65114           if (field.key) {
65115             field.keys = _multiData.map(function(d2) {
65116               return d2.key;
65117             });
65118             maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
65119           } else {
65120             maxLength = context.maxCharsForTagKey();
65121           }
65122         } else if (_isSemi) {
65123           var allValues = [];
65124           var commonValues;
65125           if (Array.isArray(tags[field.key])) {
65126             tags[field.key].forEach(function(tagVal) {
65127               var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean);
65128               allValues = allValues.concat(thisVals);
65129               if (!commonValues) {
65130                 commonValues = thisVals;
65131               } else {
65132                 commonValues = commonValues.filter((value) => thisVals.includes(value));
65133               }
65134             });
65135             allValues = utilArrayUniq(allValues).filter(Boolean);
65136           } else {
65137             allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean);
65138             commonValues = allValues;
65139           }
65140           _multiData = allValues.map(function(v3) {
65141             return {
65142               key: v3,
65143               value: displayValue(v3),
65144               display: addComboboxIcons(renderValue(v3), v3),
65145               isMixed: !commonValues.includes(v3)
65146             };
65147           });
65148           var currLength = utilUnicodeCharsCount(commonValues.join(";"));
65149           maxLength = context.maxCharsForTagValue() - currLength;
65150           if (currLength > 0) {
65151             maxLength -= 1;
65152           }
65153         }
65154         maxLength = Math.max(0, maxLength);
65155         var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length;
65156         _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
65157         var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]);
65158         var chips = _container.selectAll(".chip").data(_multiData);
65159         chips.exit().remove();
65160         var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip");
65161         enter.append("span");
65162         const field_buttons = enter.append("div").attr("class", "field_buttons");
65163         field_buttons.append("a").attr("class", "remove");
65164         chips = chips.merge(enter).order().classed("raw-value", function(d2) {
65165           var k3 = d2.key;
65166           if (_isMulti)
65167             k3 = k3.replace(field.key, "");
65168           return !stringsField.hasTextForStringId("options." + k3);
65169         }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) {
65170           return d2.isMixed;
65171         }).attr("title", function(d2) {
65172           if (d2.isMixed) {
65173             return _t("inspector.unshared_value_tooltip");
65174           }
65175           if (!["yes", "no"].includes(d2.state)) {
65176             return d2.state;
65177           }
65178           return null;
65179         }).classed("negated", (d2) => d2.state === "no");
65180         if (!_isSemi) {
65181           chips.selectAll("input[type=checkbox]").remove();
65182           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);
65183         }
65184         if (allowDragAndDrop) {
65185           registerDragAndDrop(chips);
65186         }
65187         chips.each(function(d2) {
65188           const selection2 = select_default2(this);
65189           const text_span = selection2.select("span");
65190           const field_buttons2 = selection2.select(".field_buttons");
65191           const clean_value = d2.value.trim();
65192           text_span.text("");
65193           if (clean_value.startsWith("https://")) {
65194             text_span.text(clean_value);
65195             field_buttons2.select("button").remove();
65196             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) {
65197               d3_event.preventDefault();
65198               window.open(clean_value, "_blank");
65199             });
65200             return;
65201           }
65202           if (d2.display) {
65203             d2.display(text_span);
65204             return;
65205           }
65206           text_span.text(d2.value);
65207         });
65208         chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7");
65209         updateIcon("");
65210       } else {
65211         var mixedValues = isMixed && tags[field.key].map(function(val) {
65212           return displayValue(val);
65213         }).filter(Boolean);
65214         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) {
65215           if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
65216             d3_event.preventDefault();
65217             d3_event.stopPropagation();
65218             var t2 = {};
65219             t2[field.key] = void 0;
65220             dispatch14.call("change", this, t2);
65221           }
65222         });
65223         if (!Array.isArray(tags[field.key])) {
65224           updateIcon(tags[field.key]);
65225         }
65226         if (!isMixed) {
65227           _lengthIndicator.update(tags[field.key]);
65228         }
65229       }
65230       const refreshStyles = () => {
65231         _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue);
65232       };
65233       _input.on("input.refreshStyles", refreshStyles);
65234       _combobox.on("update.refreshStyles", refreshStyles);
65235       refreshStyles();
65236     };
65237     function registerDragAndDrop(selection2) {
65238       var dragOrigin, targetIndex;
65239       selection2.call(
65240         drag_default().on("start", function(d3_event) {
65241           dragOrigin = {
65242             x: d3_event.x,
65243             y: d3_event.y
65244           };
65245           targetIndex = null;
65246         }).on("drag", function(d3_event) {
65247           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
65248           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
65249           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
65250             return;
65251           var index = selection2.nodes().indexOf(this);
65252           select_default2(this).classed("dragging", true);
65253           targetIndex = null;
65254           var targetIndexOffsetTop = null;
65255           var draggedTagWidth = select_default2(this).node().offsetWidth;
65256           if (field.key === "destination" || field.key === "via") {
65257             _container.selectAll(".chip").style("transform", function(d2, index2) {
65258               var node = select_default2(this).node();
65259               if (index === index2) {
65260                 return "translate(" + x2 + "px, " + y2 + "px)";
65261               } else if (index2 > index && d3_event.y > node.offsetTop) {
65262                 if (targetIndex === null || index2 > targetIndex) {
65263                   targetIndex = index2;
65264                 }
65265                 return "translateY(-100%)";
65266               } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
65267                 if (targetIndex === null || index2 < targetIndex) {
65268                   targetIndex = index2;
65269                 }
65270                 return "translateY(100%)";
65271               }
65272               return null;
65273             });
65274           } else {
65275             _container.selectAll(".chip").each(function(d2, index2) {
65276               var node = select_default2(this).node();
65277               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) {
65278                 targetIndex = index2;
65279                 targetIndexOffsetTop = node.offsetTop;
65280               }
65281             }).style("transform", function(d2, index2) {
65282               var node = select_default2(this).node();
65283               if (index === index2) {
65284                 return "translate(" + x2 + "px, " + y2 + "px)";
65285               }
65286               if (node.offsetTop === targetIndexOffsetTop) {
65287                 if (index2 < index && index2 >= targetIndex) {
65288                   return "translateX(" + draggedTagWidth + "px)";
65289                 } else if (index2 > index && index2 <= targetIndex) {
65290                   return "translateX(-" + draggedTagWidth + "px)";
65291                 }
65292               }
65293               return null;
65294             });
65295           }
65296         }).on("end", function() {
65297           if (!select_default2(this).classed("dragging")) {
65298             return;
65299           }
65300           var index = selection2.nodes().indexOf(this);
65301           select_default2(this).classed("dragging", false);
65302           _container.selectAll(".chip").style("transform", null);
65303           if (typeof targetIndex === "number") {
65304             var element = _multiData[index];
65305             _multiData.splice(index, 1);
65306             _multiData.splice(targetIndex, 0, element);
65307             var t2 = {};
65308             if (_multiData.length) {
65309               t2[field.key] = _multiData.map(function(element2) {
65310                 return element2.key;
65311               }).join(";");
65312             } else {
65313               t2[field.key] = void 0;
65314             }
65315             dispatch14.call("change", this, t2);
65316           }
65317           dragOrigin = void 0;
65318           targetIndex = void 0;
65319         })
65320       );
65321     }
65322     combo.focus = function() {
65323       _input.node().focus();
65324     };
65325     combo.entityIDs = function(val) {
65326       if (!arguments.length)
65327         return _entityIDs;
65328       _entityIDs = val;
65329       return combo;
65330     };
65331     function combinedEntityExtent() {
65332       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65333     }
65334     return utilRebind(combo, dispatch14, "on");
65335   }
65336
65337   // modules/ui/fields/input.js
65338   var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
65339   function uiFieldText(field, context) {
65340     var dispatch14 = dispatch_default("change");
65341     var input = select_default2(null);
65342     var outlinkButton = select_default2(null);
65343     var wrap2 = select_default2(null);
65344     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
65345     var _entityIDs = [];
65346     var _tags;
65347     var _phoneFormats = {};
65348     const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
65349     const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
65350     const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
65351     const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
65352     if (field.type === "tel") {
65353       _mainFileFetcher.get("phone_formats").then(function(d2) {
65354         _phoneFormats = d2;
65355         updatePhonePlaceholder();
65356       }).catch(function() {
65357       });
65358     }
65359     function calcLocked() {
65360       var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
65361         var entity = context.graph().hasEntity(entityID);
65362         if (!entity)
65363           return false;
65364         if (entity.tags.wikidata)
65365           return true;
65366         var preset = _mainPresetIndex.match(entity, context.graph());
65367         var isSuggestion = preset && preset.suggestion;
65368         var which = field.id;
65369         return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
65370       });
65371       field.locked(isLocked);
65372     }
65373     function i3(selection2) {
65374       calcLocked();
65375       var isLocked = field.locked();
65376       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65377       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65378       input = wrap2.selectAll("input").data([0]);
65379       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);
65380       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
65381       wrap2.call(_lengthIndicator);
65382       if (field.type === "tel") {
65383         updatePhonePlaceholder();
65384       } else if (field.type === "number") {
65385         var rtl = _mainLocalizer.textDirection() === "rtl";
65386         input.attr("type", "text");
65387         var inc = field.increment;
65388         var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
65389         buttons.enter().append("button").attr("class", function(d2) {
65390           var which = d2 > 0 ? "increment" : "decrement";
65391           return "form-field-button " + which;
65392         }).attr("title", function(d2) {
65393           var which = d2 > 0 ? "increment" : "decrement";
65394           return _t("inspector.".concat(which));
65395         }).merge(buttons).on("click", function(d3_event, d2) {
65396           d3_event.preventDefault();
65397           var isMixed = Array.isArray(_tags[field.key]);
65398           if (isMixed)
65399             return;
65400           var raw_vals = input.node().value || "0";
65401           var vals = raw_vals.split(";");
65402           vals = vals.map(function(v2) {
65403             v2 = v2.trim();
65404             const isRawNumber = likelyRawNumberFormat.test(v2);
65405             var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
65406             if (isDirectionField) {
65407               const compassDir = cardinal[v2.toLowerCase()];
65408               if (compassDir !== void 0) {
65409                 num = compassDir;
65410               }
65411             }
65412             if (!isFinite(num))
65413               return v2;
65414             num = parseFloat(num);
65415             if (!isFinite(num))
65416               return v2;
65417             num += d2;
65418             if (isDirectionField) {
65419               num = (num % 360 + 360) % 360;
65420             }
65421             return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
65422           });
65423           input.node().value = vals.join(";");
65424           change()();
65425         });
65426       } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
65427         input.attr("type", "text");
65428         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65429         outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
65430           var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
65431           if (domainResults.length >= 2 && domainResults[1]) {
65432             var domain = domainResults[1];
65433             return _t("icons.view_on", { domain });
65434           }
65435           return "";
65436         }).merge(outlinkButton);
65437         outlinkButton.on("click", function(d3_event) {
65438           d3_event.preventDefault();
65439           var value = validIdentifierValueForLink();
65440           if (value) {
65441             var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
65442             window.open(url, "_blank");
65443           }
65444         }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
65445       } else if (field.type === "url") {
65446         input.attr("type", "text");
65447         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65448         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) {
65449           d3_event.preventDefault();
65450           const value = validIdentifierValueForLink();
65451           if (value)
65452             window.open(value, "_blank");
65453         }).merge(outlinkButton);
65454       } else if (field.type === "colour") {
65455         input.attr("type", "text");
65456         updateColourPreview();
65457       } else if (field.type === "date") {
65458         input.attr("type", "text");
65459         updateDateField();
65460       }
65461     }
65462     function updateColourPreview() {
65463       wrap2.selectAll(".colour-preview").remove();
65464       const colour = utilGetSetValue(input);
65465       if (!isColourValid(colour) && colour !== "") {
65466         wrap2.selectAll("input.colour-selector").remove();
65467         wrap2.selectAll(".form-field-button").remove();
65468         return;
65469       }
65470       var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
65471       colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
65472         d3_event.preventDefault();
65473         var colour2 = this.value;
65474         if (!isColourValid(colour2))
65475           return;
65476         utilGetSetValue(input, this.value);
65477         change()();
65478         updateColourPreview();
65479       }, 100));
65480       wrap2.selectAll("input.colour-selector").attr("value", colour);
65481       var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
65482       chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
65483       if (colour === "") {
65484         chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
65485       }
65486       chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
65487     }
65488     function updateDateField() {
65489       function isDateValid(date2) {
65490         return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
65491       }
65492       const date = utilGetSetValue(input);
65493       const now3 = /* @__PURE__ */ new Date();
65494       const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
65495       if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
65496         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", () => {
65497           utilGetSetValue(input, today);
65498           change()();
65499           updateDateField();
65500         });
65501       } else {
65502         wrap2.selectAll(".date-set-today").remove();
65503       }
65504       if (!isDateValid(date) && date !== "") {
65505         wrap2.selectAll("input.date-selector").remove();
65506         wrap2.selectAll(".date-calendar").remove();
65507         return;
65508       }
65509       if (utilDetect().browser !== "Safari") {
65510         var dateSelector = wrap2.selectAll(".date-selector").data([0]);
65511         dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
65512           d3_event.preventDefault();
65513           var date2 = this.value;
65514           if (!isDateValid(date2))
65515             return;
65516           utilGetSetValue(input, this.value);
65517           change()();
65518           updateDateField();
65519         }, 100));
65520         wrap2.selectAll("input.date-selector").attr("value", date);
65521         var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
65522         calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
65523         calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
65524       }
65525     }
65526     function updatePhonePlaceholder() {
65527       if (input.empty() || !Object.keys(_phoneFormats).length)
65528         return;
65529       var extent = combinedEntityExtent();
65530       var countryCode = extent && iso1A2Code(extent.center());
65531       var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
65532       if (format2)
65533         input.attr("placeholder", format2);
65534     }
65535     function validIdentifierValueForLink() {
65536       var _a2;
65537       const value = utilGetSetValue(input).trim();
65538       if (field.type === "url" && value) {
65539         try {
65540           return new URL(value).href;
65541         } catch (e3) {
65542           return null;
65543         }
65544       }
65545       if (field.type === "identifier" && field.pattern) {
65546         return value && ((_a2 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a2[0]);
65547       }
65548       return null;
65549     }
65550     function clamped(num) {
65551       if (field.minValue !== void 0) {
65552         num = Math.max(num, field.minValue);
65553       }
65554       if (field.maxValue !== void 0) {
65555         num = Math.min(num, field.maxValue);
65556       }
65557       return num;
65558     }
65559     function getVals(tags) {
65560       if (field.keys) {
65561         const multiSelection = context.selectedIDs();
65562         tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
65563         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]));
65564       } else {
65565         return new Set([].concat(tags[field.key]));
65566       }
65567     }
65568     function change(onInput) {
65569       return function() {
65570         var t2 = {};
65571         var val = utilGetSetValue(input);
65572         if (!onInput)
65573           val = context.cleanTagValue(val);
65574         if (!val && getVals(_tags).size > 1)
65575           return;
65576         var displayVal = val;
65577         if (field.type === "number" && val) {
65578           var numbers2 = val.split(";");
65579           numbers2 = numbers2.map(function(v2) {
65580             if (likelyRawNumberFormat.test(v2)) {
65581               return v2;
65582             }
65583             var num = parseLocaleFloat(v2);
65584             const fractionDigits = countDecimalPlaces(v2);
65585             return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
65586           });
65587           val = numbers2.join(";");
65588         }
65589         if (!onInput)
65590           utilGetSetValue(input, displayVal);
65591         t2[field.key] = val || void 0;
65592         if (field.keys) {
65593           dispatch14.call("change", this, (tags) => {
65594             if (field.keys.some((key) => tags[key])) {
65595               field.keys.filter((key) => tags[key]).forEach((key) => {
65596                 tags[key] = val || void 0;
65597               });
65598             } else {
65599               tags[field.key] = val || void 0;
65600             }
65601             return tags;
65602           }, onInput);
65603         } else {
65604           dispatch14.call("change", this, t2, onInput);
65605         }
65606       };
65607     }
65608     i3.entityIDs = function(val) {
65609       if (!arguments.length)
65610         return _entityIDs;
65611       _entityIDs = val;
65612       return i3;
65613     };
65614     i3.tags = function(tags) {
65615       var _a2;
65616       _tags = tags;
65617       const vals = getVals(tags);
65618       const isMixed = vals.size > 1;
65619       var val = vals.size === 1 ? (_a2 = [...vals][0]) != null ? _a2 : "" : "";
65620       var shouldUpdate;
65621       if (field.type === "number" && val) {
65622         var numbers2 = val.split(";");
65623         var oriNumbers = utilGetSetValue(input).split(";");
65624         if (numbers2.length !== oriNumbers.length)
65625           shouldUpdate = true;
65626         numbers2 = numbers2.map(function(v2) {
65627           v2 = v2.trim();
65628           var num = Number(v2);
65629           if (!isFinite(num) || v2 === "")
65630             return v2;
65631           const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
65632           return formatFloat(num, fractionDigits);
65633         });
65634         val = numbers2.join(";");
65635         shouldUpdate = (inputValue, setValue) => {
65636           const inputNums = inputValue.split(";").map(
65637             (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
65638           );
65639           const setNums = setValue.split(";").map(parseLocaleFloat);
65640           return !isEqual_default(inputNums, setNums);
65641         };
65642       }
65643       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);
65644       if (field.type === "number") {
65645         const buttons = wrap2.selectAll(".increment, .decrement");
65646         if (isMixed) {
65647           buttons.attr("disabled", "disabled").classed("disabled", true);
65648         } else {
65649           var raw_vals = tags[field.key] || "0";
65650           const canIncDec = raw_vals.split(";").some((val2) => isFinite(Number(val2)) || isDirectionField && cardinal[val2.trim().toLowerCase()]);
65651           buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
65652         }
65653       }
65654       if (field.type === "tel")
65655         updatePhonePlaceholder();
65656       if (field.type === "colour")
65657         updateColourPreview();
65658       if (field.type === "date")
65659         updateDateField();
65660       if (outlinkButton && !outlinkButton.empty()) {
65661         var disabled = !validIdentifierValueForLink();
65662         outlinkButton.classed("disabled", disabled);
65663       }
65664       if (!isMixed) {
65665         _lengthIndicator.update(tags[field.key]);
65666       }
65667     };
65668     i3.focus = function() {
65669       var node = input.node();
65670       if (node)
65671         node.focus();
65672     };
65673     function combinedEntityExtent() {
65674       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65675     }
65676     return utilRebind(i3, dispatch14, "on");
65677   }
65678
65679   // modules/ui/fields/access.js
65680   function uiFieldAccess(field, context) {
65681     var dispatch14 = dispatch_default("change");
65682     var items = select_default2(null);
65683     var _tags;
65684     function access(selection2) {
65685       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65686       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65687       var list2 = wrap2.selectAll("ul").data([0]);
65688       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
65689       items = list2.selectAll("li").data(field.keys);
65690       var enter = items.enter().append("li").attr("class", function(d2) {
65691         return "labeled-input preset-access-" + d2;
65692       });
65693       enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
65694         return "preset-input-access-" + d2;
65695       }).html(function(d2) {
65696         return field.t.html("types." + d2);
65697       });
65698       enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
65699         return "preset-input-access preset-input-access-" + d2;
65700       }).call(utilNoAuto).each(function(d2) {
65701         select_default2(this).call(
65702           uiCombobox(context, "access-" + d2).data(access.options(d2))
65703         );
65704       });
65705       items = items.merge(enter);
65706       wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
65707     }
65708     function change(d3_event, d2) {
65709       var tag2 = {};
65710       var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
65711       if (!value && typeof _tags[d2] !== "string")
65712         return;
65713       tag2[d2] = value || void 0;
65714       dispatch14.call("change", this, tag2);
65715     }
65716     access.options = function(type2) {
65717       var options2 = [
65718         "yes",
65719         "no",
65720         "designated",
65721         "permissive",
65722         "destination",
65723         "customers",
65724         "private",
65725         "permit",
65726         "unknown"
65727       ];
65728       if (type2 === "access") {
65729         options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
65730       }
65731       if (type2 === "bicycle") {
65732         options2.splice(options2.length - 4, 0, "dismount");
65733       }
65734       var stringsField = field.resolveReference("stringsCrossReference");
65735       return options2.map(function(option) {
65736         return {
65737           title: stringsField.t("options." + option + ".description"),
65738           value: option
65739         };
65740       });
65741     };
65742     const placeholdersByTag = {
65743       highway: {
65744         footway: {
65745           foot: "designated",
65746           motor_vehicle: "no"
65747         },
65748         steps: {
65749           foot: "yes",
65750           motor_vehicle: "no",
65751           bicycle: "no",
65752           horse: "no"
65753         },
65754         pedestrian: {
65755           foot: "yes",
65756           motor_vehicle: "no"
65757         },
65758         cycleway: {
65759           motor_vehicle: "no",
65760           bicycle: "designated"
65761         },
65762         bridleway: {
65763           motor_vehicle: "no",
65764           horse: "designated"
65765         },
65766         path: {
65767           foot: "yes",
65768           motor_vehicle: "no",
65769           bicycle: "yes",
65770           horse: "yes"
65771         },
65772         motorway: {
65773           foot: "no",
65774           motor_vehicle: "yes",
65775           bicycle: "no",
65776           horse: "no"
65777         },
65778         trunk: {
65779           motor_vehicle: "yes"
65780         },
65781         primary: {
65782           foot: "yes",
65783           motor_vehicle: "yes",
65784           bicycle: "yes",
65785           horse: "yes"
65786         },
65787         secondary: {
65788           foot: "yes",
65789           motor_vehicle: "yes",
65790           bicycle: "yes",
65791           horse: "yes"
65792         },
65793         tertiary: {
65794           foot: "yes",
65795           motor_vehicle: "yes",
65796           bicycle: "yes",
65797           horse: "yes"
65798         },
65799         residential: {
65800           foot: "yes",
65801           motor_vehicle: "yes",
65802           bicycle: "yes",
65803           horse: "yes"
65804         },
65805         unclassified: {
65806           foot: "yes",
65807           motor_vehicle: "yes",
65808           bicycle: "yes",
65809           horse: "yes"
65810         },
65811         service: {
65812           foot: "yes",
65813           motor_vehicle: "yes",
65814           bicycle: "yes",
65815           horse: "yes"
65816         },
65817         motorway_link: {
65818           foot: "no",
65819           motor_vehicle: "yes",
65820           bicycle: "no",
65821           horse: "no"
65822         },
65823         trunk_link: {
65824           motor_vehicle: "yes"
65825         },
65826         primary_link: {
65827           foot: "yes",
65828           motor_vehicle: "yes",
65829           bicycle: "yes",
65830           horse: "yes"
65831         },
65832         secondary_link: {
65833           foot: "yes",
65834           motor_vehicle: "yes",
65835           bicycle: "yes",
65836           horse: "yes"
65837         },
65838         tertiary_link: {
65839           foot: "yes",
65840           motor_vehicle: "yes",
65841           bicycle: "yes",
65842           horse: "yes"
65843         },
65844         construction: {
65845           access: "no"
65846         },
65847         busway: {
65848           access: "no",
65849           bus: "designated",
65850           emergency: "yes"
65851         }
65852       },
65853       barrier: {
65854         bollard: {
65855           access: "no",
65856           bicycle: "yes",
65857           foot: "yes"
65858         },
65859         bus_trap: {
65860           motor_vehicle: "no",
65861           psv: "yes",
65862           foot: "yes",
65863           bicycle: "yes"
65864         },
65865         city_wall: {
65866           access: "no"
65867         },
65868         coupure: {
65869           access: "yes"
65870         },
65871         cycle_barrier: {
65872           motor_vehicle: "no"
65873         },
65874         ditch: {
65875           access: "no"
65876         },
65877         entrance: {
65878           access: "yes"
65879         },
65880         fence: {
65881           access: "no"
65882         },
65883         hedge: {
65884           access: "no"
65885         },
65886         jersey_barrier: {
65887           access: "no"
65888         },
65889         motorcycle_barrier: {
65890           motor_vehicle: "no"
65891         },
65892         rail_guard: {
65893           access: "no"
65894         }
65895       }
65896     };
65897     access.tags = function(tags) {
65898       _tags = tags;
65899       utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
65900         return typeof tags[d2] === "string" ? tags[d2] : "";
65901       }).classed("mixed", function(d2) {
65902         return tags[d2] && Array.isArray(tags[d2]);
65903       }).attr("title", function(d2) {
65904         return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
65905       }).attr("placeholder", function(d2) {
65906         if (tags[d2] && Array.isArray(tags[d2])) {
65907           return _t("inspector.multiple_values");
65908         }
65909         if (d2 === "bicycle" || d2 === "motor_vehicle") {
65910           if (tags.vehicle && typeof tags.vehicle === "string") {
65911             return tags.vehicle;
65912           }
65913         }
65914         if (tags.access && typeof tags.access === "string") {
65915           return tags.access;
65916         }
65917         function getPlaceholdersByTag(key, placeholdersByKey) {
65918           if (typeof tags[key] === "string") {
65919             if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
65920               return placeholdersByKey[tags[key]][d2];
65921             }
65922           } else {
65923             var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
65924               return placeholdersByKey[val] && placeholdersByKey[val][d2];
65925             }).filter(Boolean);
65926             if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
65927               return impliedAccesses[0];
65928             }
65929           }
65930         }
65931         for (const key in placeholdersByTag) {
65932           if (tags[key]) {
65933             const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
65934             if (impliedAccess) {
65935               return impliedAccess;
65936             }
65937           }
65938         }
65939         if (d2 === "access" && !tags.barrier) {
65940           return "yes";
65941         }
65942         return field.placeholder();
65943       });
65944     };
65945     access.focus = function() {
65946       items.selectAll(".preset-input-access").node().focus();
65947     };
65948     return utilRebind(access, dispatch14, "on");
65949   }
65950
65951   // modules/ui/fields/address.js
65952   function uiFieldAddress(field, context) {
65953     var dispatch14 = dispatch_default("change");
65954     var _selection = select_default2(null);
65955     var _wrap = select_default2(null);
65956     var addrField = _mainPresetIndex.field("address");
65957     var _entityIDs = [];
65958     var _tags;
65959     var _countryCode;
65960     var _addressFormats = [{
65961       format: [
65962         ["housenumber", "street"],
65963         ["city", "postcode"]
65964       ]
65965     }];
65966     _mainFileFetcher.get("address_formats").then(function(d2) {
65967       _addressFormats = d2;
65968       if (!_selection.empty()) {
65969         _selection.call(address);
65970       }
65971     }).catch(function() {
65972     });
65973     function getNear(isAddressable, type2, searchRadius, resultProp) {
65974       var extent = combinedEntityExtent();
65975       var l2 = extent.center();
65976       var box = geoExtent(l2).padByMeters(searchRadius);
65977       var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
65978         let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
65979         if (d2.geometry(context.graph()) === "line") {
65980           var loc = context.projection([
65981             (extent[0][0] + extent[1][0]) / 2,
65982             (extent[0][1] + extent[1][1]) / 2
65983           ]);
65984           var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
65985           dist = geoSphericalDistance(choice.loc, l2);
65986         }
65987         const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
65988         let title = value;
65989         if (type2 === "street") {
65990           title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
65991         } else if (type2 === "place") {
65992           title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
65993         }
65994         return {
65995           title,
65996           value,
65997           dist,
65998           type: type2,
65999           klass: "address-".concat(type2)
66000         };
66001       }).sort(function(a2, b2) {
66002         return a2.dist - b2.dist;
66003       });
66004       return utilArrayUniqBy(features, "value");
66005     }
66006     function getNearStreets() {
66007       function isAddressable(d2) {
66008         return d2.tags.highway && d2.tags.name && d2.type === "way";
66009       }
66010       return getNear(isAddressable, "street", 200);
66011     }
66012     function getNearPlaces() {
66013       function isAddressable(d2) {
66014         if (d2.tags.name) {
66015           if (d2.tags.place)
66016             return true;
66017           if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8)
66018             return true;
66019         }
66020         return false;
66021       }
66022       return getNear(isAddressable, "place", 200);
66023     }
66024     function getNearCities() {
66025       function isAddressable(d2) {
66026         if (d2.tags.name) {
66027           if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8")
66028             return true;
66029           if (d2.tags.border_type === "city")
66030             return true;
66031           if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village")
66032             return true;
66033         }
66034         if (d2.tags["".concat(field.key, ":city")])
66035           return true;
66036         return false;
66037       }
66038       return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
66039     }
66040     function getNearPostcodes() {
66041       return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
66042     }
66043     function getNearValues(key) {
66044       const tagKey = "".concat(field.key, ":").concat(key);
66045       function hasTag(d2) {
66046         return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
66047       }
66048       return getNear(hasTag, key, 200, tagKey);
66049     }
66050     function updateForCountryCode() {
66051       if (!_countryCode)
66052         return;
66053       var addressFormat;
66054       for (var i3 = 0; i3 < _addressFormats.length; i3++) {
66055         var format2 = _addressFormats[i3];
66056         if (!format2.countryCodes) {
66057           addressFormat = format2;
66058         } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
66059           addressFormat = format2;
66060           break;
66061         }
66062       }
66063       var dropdowns = addressFormat.dropdowns || [
66064         "city",
66065         "county",
66066         "country",
66067         "district",
66068         "hamlet",
66069         "neighbourhood",
66070         "place",
66071         "postcode",
66072         "province",
66073         "quarter",
66074         "state",
66075         "street",
66076         "street+place",
66077         "subdistrict",
66078         "suburb"
66079       ];
66080       var widths = addressFormat.widths || {
66081         housenumber: 1 / 5,
66082         unit: 1 / 5,
66083         street: 1 / 2,
66084         place: 1 / 2,
66085         city: 2 / 3,
66086         state: 1 / 4,
66087         postcode: 1 / 3
66088       };
66089       function row(r2) {
66090         var total = r2.reduce(function(sum, key) {
66091           return sum + (widths[key] || 0.5);
66092         }, 0);
66093         return r2.map(function(key) {
66094           return {
66095             id: key,
66096             width: (widths[key] || 0.5) / total
66097           };
66098         });
66099       }
66100       var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
66101         return d2.toString();
66102       });
66103       rows.exit().remove();
66104       rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").call(updatePlaceholder).attr("class", function(d2) {
66105         return "addr-" + d2.id;
66106       }).call(utilNoAuto).each(addDropdown).style("width", function(d2) {
66107         return d2.width * 100 + "%";
66108       });
66109       function addDropdown(d2) {
66110         if (dropdowns.indexOf(d2.id) === -1)
66111           return;
66112         var nearValues;
66113         switch (d2.id) {
66114           case "street":
66115             nearValues = getNearStreets;
66116             break;
66117           case "place":
66118             nearValues = getNearPlaces;
66119             break;
66120           case "street+place":
66121             nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
66122             d2.isAutoStreetPlace = true;
66123             d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
66124             break;
66125           case "city":
66126             nearValues = getNearCities;
66127             break;
66128           case "postcode":
66129             nearValues = getNearPostcodes;
66130             break;
66131           default:
66132             nearValues = getNearValues;
66133         }
66134         select_default2(this).call(
66135           uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
66136             typedValue = typedValue.toLowerCase();
66137             callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
66138           }).on("accept", function(selected) {
66139             if (d2.isAutoStreetPlace) {
66140               d2.id = selected ? selected.type : "street";
66141             }
66142           })
66143         );
66144       }
66145       _wrap.selectAll("input").on("blur", change()).on("change", change());
66146       _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
66147       if (_tags)
66148         updateTags(_tags);
66149     }
66150     function address(selection2) {
66151       _selection = selection2;
66152       _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
66153       _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
66154       var extent = combinedEntityExtent();
66155       if (extent) {
66156         var countryCode;
66157         if (context.inIntro()) {
66158           countryCode = _t("intro.graph.countrycode");
66159         } else {
66160           var center = extent.center();
66161           countryCode = iso1A2Code(center);
66162         }
66163         if (countryCode) {
66164           _countryCode = countryCode.toLowerCase();
66165           updateForCountryCode();
66166         }
66167       }
66168     }
66169     function change(onInput) {
66170       return function() {
66171         setTimeout(() => {
66172           var tags = {};
66173           _wrap.selectAll("input").each(function(subfield) {
66174             var key = field.key + ":" + subfield.id;
66175             var value = this.value;
66176             if (!onInput)
66177               value = context.cleanTagValue(value);
66178             if (Array.isArray(_tags[key]) && !value)
66179               return;
66180             if (subfield.isAutoStreetPlace) {
66181               if (subfield.id === "street") {
66182                 tags["".concat(field.key, ":place")] = void 0;
66183               } else if (subfield.id === "place") {
66184                 tags["".concat(field.key, ":street")] = void 0;
66185               }
66186             }
66187             tags[key] = value || void 0;
66188           });
66189           Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
66190           dispatch14.call("change", this, tags, onInput);
66191         }, 0);
66192       };
66193     }
66194     function updatePlaceholder(inputSelection) {
66195       return inputSelection.attr("placeholder", function(subfield) {
66196         if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
66197           return _t("inspector.multiple_values");
66198         }
66199         if (subfield.isAutoStreetPlace) {
66200           return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
66201         }
66202         return getLocalPlaceholder(subfield.id);
66203       });
66204     }
66205     function getLocalPlaceholder(key) {
66206       if (_countryCode) {
66207         var localkey = key + "!" + _countryCode;
66208         var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
66209         return addrField.t("placeholders." + tkey);
66210       }
66211     }
66212     function updateTags(tags) {
66213       utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
66214         var val;
66215         if (subfield.isAutoStreetPlace) {
66216           const streetKey = "".concat(field.key, ":street");
66217           const placeKey = "".concat(field.key, ":place");
66218           if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
66219             val = tags[streetKey];
66220             subfield.id = "street";
66221           } else {
66222             val = tags[placeKey];
66223             subfield.id = "place";
66224           }
66225         } else {
66226           val = tags["".concat(field.key, ":").concat(subfield.id)];
66227         }
66228         return typeof val === "string" ? val : "";
66229       }).attr("title", function(subfield) {
66230         var val = tags[field.key + ":" + subfield.id];
66231         return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
66232       }).classed("mixed", function(subfield) {
66233         return Array.isArray(tags[field.key + ":" + subfield.id]);
66234       }).call(updatePlaceholder);
66235     }
66236     function combinedEntityExtent() {
66237       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66238     }
66239     address.entityIDs = function(val) {
66240       if (!arguments.length)
66241         return _entityIDs;
66242       _entityIDs = val;
66243       return address;
66244     };
66245     address.tags = function(tags) {
66246       _tags = tags;
66247       updateTags(tags);
66248     };
66249     address.focus = function() {
66250       var node = _wrap.selectAll("input").node();
66251       if (node)
66252         node.focus();
66253     };
66254     return utilRebind(address, dispatch14, "on");
66255   }
66256
66257   // modules/ui/fields/directional_combo.js
66258   function uiFieldDirectionalCombo(field, context) {
66259     var dispatch14 = dispatch_default("change");
66260     var items = select_default2(null);
66261     var wrap2 = select_default2(null);
66262     var _tags;
66263     var _combos = {};
66264     if (field.type === "cycleway") {
66265       field = {
66266         ...field,
66267         key: field.keys[0],
66268         keys: field.keys.slice(1)
66269       };
66270     }
66271     function directionalCombo(selection2) {
66272       function stripcolon(s2) {
66273         return s2.replace(":", "");
66274       }
66275       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66276       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66277       var div = wrap2.selectAll("ul").data([0]);
66278       div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
66279       items = div.selectAll("li").data(field.keys);
66280       var enter = items.enter().append("li").attr("class", function(d2) {
66281         return "labeled-input preset-directionalcombo-" + stripcolon(d2);
66282       });
66283       enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
66284         return "preset-input-directionalcombo-" + stripcolon(d2);
66285       }).html(function(d2) {
66286         return field.t.html("types." + d2);
66287       });
66288       enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
66289         const subField = {
66290           ...field,
66291           type: "combo",
66292           key
66293         };
66294         const combo = uiFieldCombo(subField, context);
66295         combo.on("change", (t2) => change(key, t2[key]));
66296         _combos[key] = combo;
66297         select_default2(this).call(combo);
66298       });
66299       items = items.merge(enter);
66300       wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
66301     }
66302     function change(key, newValue) {
66303       const commonKey = field.key;
66304       const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
66305       dispatch14.call("change", this, (tags) => {
66306         const otherValue = tags[otherKey] || tags[commonKey];
66307         if (newValue === otherValue) {
66308           tags[commonKey] = newValue;
66309           delete tags[key];
66310           delete tags[otherKey];
66311         } else {
66312           tags[key] = newValue;
66313           delete tags[commonKey];
66314           tags[otherKey] = otherValue;
66315         }
66316         return tags;
66317       });
66318     }
66319     directionalCombo.tags = function(tags) {
66320       _tags = tags;
66321       const commonKey = field.key;
66322       for (let key in _combos) {
66323         const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags[key]).filter(Boolean))];
66324         _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
66325       }
66326     };
66327     directionalCombo.focus = function() {
66328       var node = wrap2.selectAll("input").node();
66329       if (node)
66330         node.focus();
66331     };
66332     return utilRebind(directionalCombo, dispatch14, "on");
66333   }
66334
66335   // modules/ui/fields/lanes.js
66336   function uiFieldLanes(field, context) {
66337     var dispatch14 = dispatch_default("change");
66338     var LANE_WIDTH = 40;
66339     var LANE_HEIGHT = 200;
66340     var _entityIDs = [];
66341     function lanes(selection2) {
66342       var lanesData = context.entity(_entityIDs[0]).lanes();
66343       if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
66344         selection2.call(lanes.off);
66345         return;
66346       }
66347       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66348       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66349       var surface = wrap2.selectAll(".surface").data([0]);
66350       var d2 = utilGetDimensions(wrap2);
66351       var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
66352       surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
66353       var lanesSelection = surface.selectAll(".lanes").data([0]);
66354       lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
66355       lanesSelection.attr("transform", function() {
66356         return "translate(" + freeSpace / 2 + ", 0)";
66357       });
66358       var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
66359       lane.exit().remove();
66360       var enter = lane.enter().append("g").attr("class", "lane");
66361       enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
66362       enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
66363       enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
66364       enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
66365       lane = lane.merge(enter);
66366       lane.attr("transform", function(d4) {
66367         return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
66368       });
66369       lane.select(".forward").style("visibility", function(d4) {
66370         return d4.direction === "forward" ? "visible" : "hidden";
66371       });
66372       lane.select(".bothways").style("visibility", function(d4) {
66373         return d4.direction === "bothways" ? "visible" : "hidden";
66374       });
66375       lane.select(".backward").style("visibility", function(d4) {
66376         return d4.direction === "backward" ? "visible" : "hidden";
66377       });
66378     }
66379     lanes.entityIDs = function(val) {
66380       _entityIDs = val;
66381     };
66382     lanes.tags = function() {
66383     };
66384     lanes.focus = function() {
66385     };
66386     lanes.off = function() {
66387     };
66388     return utilRebind(lanes, dispatch14, "on");
66389   }
66390   uiFieldLanes.supportsMultiselection = false;
66391
66392   // modules/ui/fields/localized.js
66393   var _languagesArray = [];
66394   function uiFieldLocalized(field, context) {
66395     var dispatch14 = dispatch_default("change", "input");
66396     var wikipedia = services.wikipedia;
66397     var input = select_default2(null);
66398     var localizedInputs = select_default2(null);
66399     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
66400     var _countryCode;
66401     var _tags;
66402     _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
66403     });
66404     var _territoryLanguages = {};
66405     _mainFileFetcher.get("territory_languages").then(function(d2) {
66406       _territoryLanguages = d2;
66407     }).catch(function() {
66408     });
66409     var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
66410     var _selection = select_default2(null);
66411     var _multilingual = [];
66412     var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
66413     var _wikiTitles;
66414     var _entityIDs = [];
66415     function loadLanguagesArray(dataLanguages) {
66416       if (_languagesArray.length !== 0)
66417         return;
66418       var replacements = {
66419         sr: "sr-Cyrl",
66420         // in OSM, `sr` implies Cyrillic
66421         "sr-Cyrl": false
66422         // `sr-Cyrl` isn't used in OSM
66423       };
66424       for (var code in dataLanguages) {
66425         if (replacements[code] === false)
66426           continue;
66427         var metaCode = code;
66428         if (replacements[code])
66429           metaCode = replacements[code];
66430         _languagesArray.push({
66431           localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
66432           nativeName: dataLanguages[metaCode].nativeName,
66433           code,
66434           label: _mainLocalizer.languageName(metaCode)
66435         });
66436       }
66437     }
66438     function calcLocked() {
66439       var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
66440         var entity = context.graph().hasEntity(entityID);
66441         if (!entity)
66442           return false;
66443         if (entity.tags.wikidata)
66444           return true;
66445         if (entity.tags["name:etymology:wikidata"])
66446           return true;
66447         var preset = _mainPresetIndex.match(entity, context.graph());
66448         if (preset) {
66449           var isSuggestion = preset.suggestion;
66450           var fields = preset.fields(entity.extent(context.graph()).center());
66451           var showsBrandField = fields.some(function(d2) {
66452             return d2.id === "brand";
66453           });
66454           var showsOperatorField = fields.some(function(d2) {
66455             return d2.id === "operator";
66456           });
66457           var setsName = preset.addTags.name;
66458           var setsBrandWikidata = preset.addTags["brand:wikidata"];
66459           var setsOperatorWikidata = preset.addTags["operator:wikidata"];
66460           return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
66461         }
66462         return false;
66463       });
66464       field.locked(isLocked);
66465     }
66466     function calcMultilingual(tags) {
66467       var existingLangsOrdered = _multilingual.map(function(item2) {
66468         return item2.lang;
66469       });
66470       var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
66471       for (var k2 in tags) {
66472         var m2 = k2.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/);
66473         if (m2 && m2[1] === field.key && m2[2]) {
66474           var item = { lang: m2[2], value: tags[k2] };
66475           if (existingLangs.has(item.lang)) {
66476             _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
66477             existingLangs.delete(item.lang);
66478           } else {
66479             _multilingual.push(item);
66480           }
66481         }
66482       }
66483       _multilingual.forEach(function(item2) {
66484         if (item2.lang && existingLangs.has(item2.lang)) {
66485           item2.value = "";
66486         }
66487       });
66488     }
66489     function localized(selection2) {
66490       _selection = selection2;
66491       calcLocked();
66492       var isLocked = field.locked();
66493       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66494       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66495       input = wrap2.selectAll(".localized-main").data([0]);
66496       input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
66497       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
66498       wrap2.call(_lengthIndicator);
66499       var translateButton = wrap2.selectAll(".localized-add").data([0]);
66500       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);
66501       translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
66502       if (_tags && !_multilingual.length) {
66503         calcMultilingual(_tags);
66504       }
66505       localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
66506       localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
66507       localizedInputs.call(renderMultilingual);
66508       localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
66509       selection2.selectAll(".combobox-caret").classed("nope", true);
66510       function addNew(d3_event) {
66511         d3_event.preventDefault();
66512         if (field.locked())
66513           return;
66514         var defaultLang = _mainLocalizer.languageCode().toLowerCase();
66515         var langExists = _multilingual.find(function(datum2) {
66516           return datum2.lang === defaultLang;
66517         });
66518         var isLangEn = defaultLang.indexOf("en") > -1;
66519         if (isLangEn || langExists) {
66520           defaultLang = "";
66521           langExists = _multilingual.find(function(datum2) {
66522             return datum2.lang === defaultLang;
66523           });
66524         }
66525         if (!langExists) {
66526           _multilingual.unshift({ lang: defaultLang, value: "" });
66527           localizedInputs.call(renderMultilingual);
66528         }
66529       }
66530       function change(onInput) {
66531         return function(d3_event) {
66532           if (field.locked()) {
66533             d3_event.preventDefault();
66534             return;
66535           }
66536           var val = utilGetSetValue(select_default2(this));
66537           if (!onInput)
66538             val = context.cleanTagValue(val);
66539           if (!val && Array.isArray(_tags[field.key]))
66540             return;
66541           var t2 = {};
66542           t2[field.key] = val || void 0;
66543           dispatch14.call("change", this, t2, onInput);
66544         };
66545       }
66546     }
66547     function key(lang) {
66548       return field.key + ":" + lang;
66549     }
66550     function changeLang(d3_event, d2) {
66551       var tags = {};
66552       var lang = utilGetSetValue(select_default2(this)).toLowerCase();
66553       var language = _languagesArray.find(function(d4) {
66554         return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
66555       });
66556       if (language)
66557         lang = language.code;
66558       if (d2.lang && d2.lang !== lang) {
66559         tags[key(d2.lang)] = void 0;
66560       }
66561       var newKey = lang && context.cleanTagKey(key(lang));
66562       var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
66563       if (newKey && value) {
66564         tags[newKey] = value;
66565       } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
66566         tags[newKey] = _wikiTitles[d2.lang];
66567       }
66568       d2.lang = lang;
66569       dispatch14.call("change", this, tags);
66570     }
66571     function changeValue(d3_event, d2) {
66572       if (!d2.lang)
66573         return;
66574       var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
66575       if (!value && Array.isArray(d2.value))
66576         return;
66577       var t2 = {};
66578       t2[key(d2.lang)] = value;
66579       d2.value = value;
66580       dispatch14.call("change", this, t2);
66581     }
66582     function fetchLanguages(value, cb) {
66583       var v2 = value.toLowerCase();
66584       var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
66585       if (_countryCode && _territoryLanguages[_countryCode]) {
66586         langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
66587       }
66588       var langItems = [];
66589       langCodes.forEach(function(code) {
66590         var langItem = _languagesArray.find(function(item) {
66591           return item.code === code;
66592         });
66593         if (langItem)
66594           langItems.push(langItem);
66595       });
66596       langItems = utilArrayUniq(langItems.concat(_languagesArray));
66597       cb(langItems.filter(function(d2) {
66598         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;
66599       }).map(function(d2) {
66600         return { value: d2.label };
66601       }));
66602     }
66603     function renderMultilingual(selection2) {
66604       var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
66605         return d2.lang;
66606       });
66607       entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
66608       var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
66609         var wrap2 = select_default2(this);
66610         var domId = utilUniqueDomId(index);
66611         var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
66612         var text = label.append("span").attr("class", "label-text");
66613         text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
66614         text.append("span").attr("class", "label-textannotation");
66615         label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
66616           if (field.locked())
66617             return;
66618           d3_event.preventDefault();
66619           _multilingual.splice(_multilingual.indexOf(d2), 1);
66620           var langKey = d2.lang && key(d2.lang);
66621           if (langKey && langKey in _tags) {
66622             delete _tags[langKey];
66623             var t2 = {};
66624             t2[langKey] = void 0;
66625             dispatch14.call("change", this, t2);
66626             return;
66627           }
66628           renderMultilingual(selection2);
66629         }).call(svgIcon("#iD-operation-delete"));
66630         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);
66631         wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
66632       });
66633       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() {
66634         select_default2(this).style("max-height", "").style("overflow", "visible");
66635       });
66636       entries = entries.merge(entriesEnter);
66637       entries.order();
66638       entries.classed("present", true);
66639       utilGetSetValue(entries.select(".localized-lang"), function(d2) {
66640         var langItem = _languagesArray.find(function(item) {
66641           return item.code === d2.lang;
66642         });
66643         if (langItem)
66644           return langItem.label;
66645         return d2.lang;
66646       });
66647       utilGetSetValue(entries.select(".localized-value"), function(d2) {
66648         return typeof d2.value === "string" ? d2.value : "";
66649       }).attr("title", function(d2) {
66650         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
66651       }).attr("placeholder", function(d2) {
66652         return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
66653       }).classed("mixed", function(d2) {
66654         return Array.isArray(d2.value);
66655       });
66656     }
66657     localized.tags = function(tags) {
66658       _tags = tags;
66659       if (typeof tags.wikipedia === "string" && !_wikiTitles) {
66660         _wikiTitles = {};
66661         var wm = tags.wikipedia.match(/([^:]+):(.+)/);
66662         if (wm && wm[0] && wm[1]) {
66663           wikipedia.translations(wm[1], wm[2], function(err, d2) {
66664             if (err || !d2)
66665               return;
66666             _wikiTitles = d2;
66667           });
66668         }
66669       }
66670       var isMixed = Array.isArray(tags[field.key]);
66671       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);
66672       calcMultilingual(tags);
66673       _selection.call(localized);
66674       if (!isMixed) {
66675         _lengthIndicator.update(tags[field.key]);
66676       }
66677     };
66678     localized.focus = function() {
66679       input.node().focus();
66680     };
66681     localized.entityIDs = function(val) {
66682       if (!arguments.length)
66683         return _entityIDs;
66684       _entityIDs = val;
66685       _multilingual = [];
66686       loadCountryCode();
66687       return localized;
66688     };
66689     function loadCountryCode() {
66690       var extent = combinedEntityExtent();
66691       var countryCode = extent && iso1A2Code(extent.center());
66692       _countryCode = countryCode && countryCode.toLowerCase();
66693     }
66694     function combinedEntityExtent() {
66695       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66696     }
66697     return utilRebind(localized, dispatch14, "on");
66698   }
66699
66700   // modules/ui/fields/roadheight.js
66701   function uiFieldRoadheight(field, context) {
66702     var dispatch14 = dispatch_default("change");
66703     var primaryUnitInput = select_default2(null);
66704     var primaryInput = select_default2(null);
66705     var secondaryInput = select_default2(null);
66706     var secondaryUnitInput = select_default2(null);
66707     var _entityIDs = [];
66708     var _tags;
66709     var _isImperial;
66710     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66711     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66712     var primaryUnits = [
66713       {
66714         value: "m",
66715         title: _t("inspector.roadheight.meter")
66716       },
66717       {
66718         value: "ft",
66719         title: _t("inspector.roadheight.foot")
66720       }
66721     ];
66722     var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
66723     function roadheight(selection2) {
66724       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66725       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66726       primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
66727       primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
66728       primaryInput.on("change", change).on("blur", change);
66729       var loc = combinedEntityExtent().center();
66730       _isImperial = roadHeightUnit(loc) === "ft";
66731       primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
66732       primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
66733       primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
66734       secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
66735       secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
66736       secondaryInput.on("change", change).on("blur", change);
66737       secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
66738       secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
66739       function changeUnits() {
66740         var primaryUnit = utilGetSetValue(primaryUnitInput);
66741         if (primaryUnit === "m") {
66742           _isImperial = false;
66743         } else if (primaryUnit === "ft") {
66744           _isImperial = true;
66745         }
66746         utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66747         setUnitSuggestions();
66748         change();
66749       }
66750     }
66751     function setUnitSuggestions() {
66752       utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66753     }
66754     function change() {
66755       var tag2 = {};
66756       var primaryValue = utilGetSetValue(primaryInput).trim();
66757       var secondaryValue = utilGetSetValue(secondaryInput).trim();
66758       if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key]))
66759         return;
66760       if (!primaryValue && !secondaryValue) {
66761         tag2[field.key] = void 0;
66762       } else {
66763         var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
66764         if (isNaN(rawPrimaryValue))
66765           rawPrimaryValue = primaryValue;
66766         var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
66767         if (isNaN(rawSecondaryValue))
66768           rawSecondaryValue = secondaryValue;
66769         if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
66770           tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
66771         } else {
66772           if (rawPrimaryValue !== "") {
66773             rawPrimaryValue = rawPrimaryValue + "'";
66774           }
66775           if (rawSecondaryValue !== "") {
66776             rawSecondaryValue = rawSecondaryValue + '"';
66777           }
66778           tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
66779         }
66780       }
66781       dispatch14.call("change", this, tag2);
66782     }
66783     roadheight.tags = function(tags) {
66784       _tags = tags;
66785       var primaryValue = tags[field.key];
66786       var secondaryValue;
66787       var isMixed = Array.isArray(primaryValue);
66788       if (!isMixed) {
66789         if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
66790           secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
66791           if (secondaryValue !== null) {
66792             secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
66793           }
66794           primaryValue = primaryValue.match(/(-?[\d.]+)'/);
66795           if (primaryValue !== null) {
66796             primaryValue = formatFloat(parseFloat(primaryValue[1]));
66797           }
66798           _isImperial = true;
66799         } else if (primaryValue) {
66800           var rawValue = primaryValue;
66801           primaryValue = parseFloat(rawValue);
66802           if (isNaN(primaryValue)) {
66803             primaryValue = rawValue;
66804           } else {
66805             primaryValue = formatFloat(primaryValue);
66806           }
66807           _isImperial = false;
66808         }
66809       }
66810       setUnitSuggestions();
66811       var inchesPlaceholder = formatFloat(0);
66812       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);
66813       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");
66814       secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
66815     };
66816     roadheight.focus = function() {
66817       primaryInput.node().focus();
66818     };
66819     roadheight.entityIDs = function(val) {
66820       _entityIDs = val;
66821     };
66822     function combinedEntityExtent() {
66823       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66824     }
66825     return utilRebind(roadheight, dispatch14, "on");
66826   }
66827
66828   // modules/ui/fields/roadspeed.js
66829   function uiFieldRoadspeed(field, context) {
66830     var dispatch14 = dispatch_default("change");
66831     var unitInput = select_default2(null);
66832     var input = select_default2(null);
66833     var _entityIDs = [];
66834     var _tags;
66835     var _isImperial;
66836     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66837     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66838     var speedCombo = uiCombobox(context, "roadspeed");
66839     var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
66840     var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
66841     var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
66842     function roadspeed(selection2) {
66843       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66844       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66845       input = wrap2.selectAll("input.roadspeed-number").data([0]);
66846       input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
66847       input.on("change", change).on("blur", change);
66848       var loc = combinedEntityExtent().center();
66849       _isImperial = roadSpeedUnit(loc) === "mph";
66850       unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
66851       unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
66852       unitInput.on("blur", changeUnits).on("change", changeUnits);
66853       function changeUnits() {
66854         var unit2 = utilGetSetValue(unitInput);
66855         if (unit2 === "km/h") {
66856           _isImperial = false;
66857         } else if (unit2 === "mph") {
66858           _isImperial = true;
66859         }
66860         utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66861         setUnitSuggestions();
66862         change();
66863       }
66864     }
66865     function setUnitSuggestions() {
66866       speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
66867       utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66868     }
66869     function comboValues(d2) {
66870       return {
66871         value: formatFloat(d2),
66872         title: formatFloat(d2)
66873       };
66874     }
66875     function change() {
66876       var tag2 = {};
66877       var value = utilGetSetValue(input).trim();
66878       if (!value && Array.isArray(_tags[field.key]))
66879         return;
66880       if (!value) {
66881         tag2[field.key] = void 0;
66882       } else {
66883         var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
66884         if (isNaN(rawValue))
66885           rawValue = value;
66886         if (isNaN(rawValue) || !_isImperial) {
66887           tag2[field.key] = context.cleanTagValue(rawValue);
66888         } else {
66889           tag2[field.key] = context.cleanTagValue(rawValue + " mph");
66890         }
66891       }
66892       dispatch14.call("change", this, tag2);
66893     }
66894     roadspeed.tags = function(tags) {
66895       _tags = tags;
66896       var rawValue = tags[field.key];
66897       var value = rawValue;
66898       var isMixed = Array.isArray(value);
66899       if (!isMixed) {
66900         if (rawValue && rawValue.indexOf("mph") >= 0) {
66901           _isImperial = true;
66902         } else if (rawValue) {
66903           _isImperial = false;
66904         }
66905         value = parseInt(value, 10);
66906         if (isNaN(value)) {
66907           value = rawValue;
66908         } else {
66909           value = formatFloat(value);
66910         }
66911       }
66912       setUnitSuggestions();
66913       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);
66914     };
66915     roadspeed.focus = function() {
66916       input.node().focus();
66917     };
66918     roadspeed.entityIDs = function(val) {
66919       _entityIDs = val;
66920     };
66921     function combinedEntityExtent() {
66922       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66923     }
66924     return utilRebind(roadspeed, dispatch14, "on");
66925   }
66926
66927   // modules/ui/fields/radio.js
66928   function uiFieldRadio(field, context) {
66929     var dispatch14 = dispatch_default("change");
66930     var placeholder = select_default2(null);
66931     var wrap2 = select_default2(null);
66932     var labels = select_default2(null);
66933     var radios = select_default2(null);
66934     var radioData = (field.options || field.keys).slice();
66935     var typeField;
66936     var layerField;
66937     var _oldType = {};
66938     var _entityIDs = [];
66939     function selectedKey() {
66940       var node = wrap2.selectAll(".form-field-input-radio label.active input");
66941       return !node.empty() && node.datum();
66942     }
66943     function radio(selection2) {
66944       selection2.classed("preset-radio", true);
66945       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66946       var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
66947       enter.append("span").attr("class", "placeholder");
66948       wrap2 = wrap2.merge(enter);
66949       placeholder = wrap2.selectAll(".placeholder");
66950       labels = wrap2.selectAll("label").data(radioData);
66951       enter = labels.enter().append("label");
66952       var stringsField = field.resolveReference("stringsCrossReference");
66953       enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
66954         return stringsField.t("options." + d2, { "default": d2 });
66955       }).attr("checked", false);
66956       enter.append("span").each(function(d2) {
66957         stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
66958       });
66959       labels = labels.merge(enter);
66960       radios = labels.selectAll("input").on("change", changeRadio);
66961     }
66962     function structureExtras(selection2, tags) {
66963       var selected = selectedKey() || tags.layer !== void 0;
66964       var type2 = _mainPresetIndex.field(selected);
66965       var layer = _mainPresetIndex.field("layer");
66966       var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
66967       var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
66968       extrasWrap.exit().remove();
66969       extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
66970       var list2 = extrasWrap.selectAll("ul").data([0]);
66971       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
66972       if (type2) {
66973         if (!typeField || typeField.id !== selected) {
66974           typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
66975         }
66976         typeField.tags(tags);
66977       } else {
66978         typeField = null;
66979       }
66980       var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
66981         return d2.id;
66982       });
66983       typeItem.exit().remove();
66984       var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
66985       typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
66986       typeEnter.append("div").attr("class", "structure-input-type-wrap");
66987       typeItem = typeItem.merge(typeEnter);
66988       if (typeField) {
66989         typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
66990       }
66991       if (layer && showLayer) {
66992         if (!layerField) {
66993           layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
66994         }
66995         layerField.tags(tags);
66996         field.keys = utilArrayUnion(field.keys, ["layer"]);
66997       } else {
66998         layerField = null;
66999         field.keys = field.keys.filter(function(k2) {
67000           return k2 !== "layer";
67001         });
67002       }
67003       var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
67004       layerItem.exit().remove();
67005       var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
67006       layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
67007       layerEnter.append("div").attr("class", "structure-input-layer-wrap");
67008       layerItem = layerItem.merge(layerEnter);
67009       if (layerField) {
67010         layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
67011       }
67012     }
67013     function changeType(t2, onInput) {
67014       var key = selectedKey();
67015       if (!key)
67016         return;
67017       var val = t2[key];
67018       if (val !== "no") {
67019         _oldType[key] = val;
67020       }
67021       if (field.type === "structureRadio") {
67022         if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
67023           t2.layer = void 0;
67024         }
67025         if (t2.layer === void 0) {
67026           if (key === "bridge" && val !== "no") {
67027             t2.layer = "1";
67028           }
67029           if (key === "tunnel" && val !== "no" && val !== "building_passage") {
67030             t2.layer = "-1";
67031           }
67032         }
67033       }
67034       dispatch14.call("change", this, t2, onInput);
67035     }
67036     function changeLayer(t2, onInput) {
67037       if (t2.layer === "0") {
67038         t2.layer = void 0;
67039       }
67040       dispatch14.call("change", this, t2, onInput);
67041     }
67042     function changeRadio() {
67043       var t2 = {};
67044       var activeKey;
67045       if (field.key) {
67046         t2[field.key] = void 0;
67047       }
67048       radios.each(function(d2) {
67049         var active = select_default2(this).property("checked");
67050         if (active)
67051           activeKey = d2;
67052         if (field.key) {
67053           if (active)
67054             t2[field.key] = d2;
67055         } else {
67056           var val = _oldType[activeKey] || "yes";
67057           t2[d2] = active ? val : void 0;
67058         }
67059       });
67060       if (field.type === "structureRadio") {
67061         if (activeKey === "bridge") {
67062           t2.layer = "1";
67063         } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
67064           t2.layer = "-1";
67065         } else {
67066           t2.layer = void 0;
67067         }
67068       }
67069       dispatch14.call("change", this, t2);
67070     }
67071     radio.tags = function(tags) {
67072       function isOptionChecked(d2) {
67073         if (field.key) {
67074           return tags[field.key] === d2;
67075         }
67076         return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67077       }
67078       function isMixed(d2) {
67079         if (field.key) {
67080           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
67081         }
67082         return Array.isArray(tags[d2]);
67083       }
67084       radios.property("checked", function(d2) {
67085         return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
67086       });
67087       labels.classed("active", function(d2) {
67088         if (field.key) {
67089           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
67090         }
67091         return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67092       }).classed("mixed", isMixed).attr("title", function(d2) {
67093         return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
67094       });
67095       var selection2 = radios.filter(function() {
67096         return this.checked;
67097       });
67098       if (selection2.empty()) {
67099         placeholder.text("");
67100         placeholder.call(_t.append("inspector.none"));
67101       } else {
67102         placeholder.text(selection2.attr("value"));
67103         _oldType[selection2.datum()] = tags[selection2.datum()];
67104       }
67105       if (field.type === "structureRadio") {
67106         if (!!tags.waterway && !_oldType.tunnel) {
67107           _oldType.tunnel = "culvert";
67108         }
67109         wrap2.call(structureExtras, tags);
67110       }
67111     };
67112     radio.focus = function() {
67113       radios.node().focus();
67114     };
67115     radio.entityIDs = function(val) {
67116       if (!arguments.length)
67117         return _entityIDs;
67118       _entityIDs = val;
67119       _oldType = {};
67120       return radio;
67121     };
67122     radio.isAllowed = function() {
67123       return _entityIDs.length === 1;
67124     };
67125     return utilRebind(radio, dispatch14, "on");
67126   }
67127
67128   // modules/ui/fields/restrictions.js
67129   function uiFieldRestrictions(field, context) {
67130     var dispatch14 = dispatch_default("change");
67131     var breathe = behaviorBreathe(context);
67132     corePreferences("turn-restriction-via-way", null);
67133     var storedViaWay = corePreferences("turn-restriction-via-way0");
67134     var storedDistance = corePreferences("turn-restriction-distance");
67135     var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
67136     var _maxDistance = storedDistance ? +storedDistance : 30;
67137     var _initialized3 = false;
67138     var _parent = select_default2(null);
67139     var _container = select_default2(null);
67140     var _oldTurns;
67141     var _graph;
67142     var _vertexID;
67143     var _intersection;
67144     var _fromWayID;
67145     var _lastXPos;
67146     function restrictions(selection2) {
67147       _parent = selection2;
67148       if (_vertexID && (context.graph() !== _graph || !_intersection)) {
67149         _graph = context.graph();
67150         _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
67151       }
67152       var isOK = _intersection && _intersection.vertices.length && // has vertices
67153       _intersection.vertices.filter(function(vertex) {
67154         return vertex.id === _vertexID;
67155       }).length && _intersection.ways.length > 2;
67156       select_default2(selection2.node().parentNode).classed("hide", !isOK);
67157       if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
67158         selection2.call(restrictions.off);
67159         return;
67160       }
67161       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67162       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67163       var container = wrap2.selectAll(".restriction-container").data([0]);
67164       var containerEnter = container.enter().append("div").attr("class", "restriction-container");
67165       containerEnter.append("div").attr("class", "restriction-help");
67166       _container = containerEnter.merge(container).call(renderViewer);
67167       var controls = wrap2.selectAll(".restriction-controls").data([0]);
67168       controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
67169     }
67170     function renderControls(selection2) {
67171       var distControl = selection2.selectAll(".restriction-distance").data([0]);
67172       distControl.exit().remove();
67173       var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
67174       distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
67175       distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
67176       distControlEnter.append("span").attr("class", "restriction-distance-text");
67177       selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
67178         var val = select_default2(this).property("value");
67179         _maxDistance = +val;
67180         _intersection = null;
67181         _container.selectAll(".layer-osm .layer-turns *").remove();
67182         corePreferences("turn-restriction-distance", _maxDistance);
67183         _parent.call(restrictions);
67184       });
67185       selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
67186       var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
67187       viaControl.exit().remove();
67188       var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
67189       viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
67190       viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
67191       viaControlEnter.append("span").attr("class", "restriction-via-way-text");
67192       selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
67193         var val = select_default2(this).property("value");
67194         _maxViaWay = +val;
67195         _container.selectAll(".layer-osm .layer-turns *").remove();
67196         corePreferences("turn-restriction-via-way0", _maxViaWay);
67197         _parent.call(restrictions);
67198       });
67199       selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
67200     }
67201     function renderViewer(selection2) {
67202       if (!_intersection)
67203         return;
67204       var vgraph = _intersection.graph;
67205       var filter2 = utilFunctor(true);
67206       var projection2 = geoRawMercator();
67207       var sdims = utilGetDimensions(context.container().select(".sidebar"));
67208       var d2 = [sdims[0] - 50, 370];
67209       var c2 = geoVecScale(d2, 0.5);
67210       var z2 = 22;
67211       projection2.scale(geoZoomToScale(z2));
67212       var extent = geoExtent();
67213       for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
67214         extent._extend(_intersection.vertices[i3].extent());
67215       }
67216       var padTop = 35;
67217       if (_intersection.vertices.length > 1) {
67218         var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
67219         var vPadding = 160;
67220         var tl = projection2([extent[0][0], extent[1][1]]);
67221         var br2 = projection2([extent[1][0], extent[0][1]]);
67222         var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
67223         var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
67224         var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
67225         var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
67226         z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
67227         projection2.scale(geoZoomToScale(z2));
67228       }
67229       var extentCenter = projection2(extent.center());
67230       extentCenter[1] = extentCenter[1] - padTop / 2;
67231       projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
67232       var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
67233       var drawVertices = svgVertices(projection2, context);
67234       var drawLines = svgLines(projection2, context);
67235       var drawTurns = svgTurns(projection2, context);
67236       var firstTime = selection2.selectAll(".surface").empty();
67237       selection2.call(drawLayers);
67238       var surface = selection2.selectAll(".surface").classed("tr", true);
67239       if (firstTime) {
67240         _initialized3 = true;
67241         surface.call(breathe);
67242       }
67243       if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
67244         _fromWayID = null;
67245         _oldTurns = null;
67246       }
67247       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));
67248       surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
67249       surface.selectAll(".selected").classed("selected", false);
67250       surface.selectAll(".related").classed("related", false);
67251       var way;
67252       if (_fromWayID) {
67253         way = vgraph.entity(_fromWayID);
67254         surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67255       }
67256       document.addEventListener("resizeWindow", function() {
67257         utilSetDimensions(_container, null);
67258         redraw(1);
67259       }, false);
67260       updateHints(null);
67261       function click(d3_event) {
67262         surface.call(breathe.off).call(breathe);
67263         var datum2 = d3_event.target.__data__;
67264         var entity = datum2 && datum2.properties && datum2.properties.entity;
67265         if (entity) {
67266           datum2 = entity;
67267         }
67268         if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
67269           _fromWayID = datum2.id;
67270           _oldTurns = null;
67271           redraw();
67272         } else if (datum2 instanceof osmTurn) {
67273           var actions, extraActions, turns, i4;
67274           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67275           if (datum2.restrictionID && !datum2.direct) {
67276             return;
67277           } else if (datum2.restrictionID && !datum2.only) {
67278             var seen = {};
67279             var datumOnly = JSON.parse(JSON.stringify(datum2));
67280             datumOnly.only = true;
67281             restrictionType = restrictionType.replace(/^no/, "only");
67282             turns = _intersection.turns(_fromWayID, 2);
67283             extraActions = [];
67284             _oldTurns = [];
67285             for (i4 = 0; i4 < turns.length; i4++) {
67286               var turn = turns[i4];
67287               if (seen[turn.restrictionID])
67288                 continue;
67289               if (turn.direct && turn.path[1] === datum2.path[1]) {
67290                 seen[turns[i4].restrictionID] = true;
67291                 turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
67292                 _oldTurns.push(turn);
67293                 extraActions.push(actionUnrestrictTurn(turn));
67294               }
67295             }
67296             actions = _intersection.actions.concat(extraActions, [
67297               actionRestrictTurn(datumOnly, restrictionType),
67298               _t("operations.restriction.annotation.create")
67299             ]);
67300           } else if (datum2.restrictionID) {
67301             turns = _oldTurns || [];
67302             extraActions = [];
67303             for (i4 = 0; i4 < turns.length; i4++) {
67304               if (turns[i4].key !== datum2.key) {
67305                 extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
67306               }
67307             }
67308             _oldTurns = null;
67309             actions = _intersection.actions.concat(extraActions, [
67310               actionUnrestrictTurn(datum2),
67311               _t("operations.restriction.annotation.delete")
67312             ]);
67313           } else {
67314             actions = _intersection.actions.concat([
67315               actionRestrictTurn(datum2, restrictionType),
67316               _t("operations.restriction.annotation.create")
67317             ]);
67318           }
67319           context.perform.apply(context, actions);
67320           var s2 = surface.selectAll("." + datum2.key);
67321           datum2 = s2.empty() ? null : s2.datum();
67322           updateHints(datum2);
67323         } else {
67324           _fromWayID = null;
67325           _oldTurns = null;
67326           redraw();
67327         }
67328       }
67329       function mouseover(d3_event) {
67330         var datum2 = d3_event.target.__data__;
67331         updateHints(datum2);
67332       }
67333       _lastXPos = _lastXPos || sdims[0];
67334       function redraw(minChange) {
67335         var xPos = -1;
67336         if (minChange) {
67337           xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
67338         }
67339         if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
67340           if (context.hasEntity(_vertexID)) {
67341             _lastXPos = xPos;
67342             _container.call(renderViewer);
67343           }
67344         }
67345       }
67346       function highlightPathsFrom(wayID) {
67347         surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
67348         surface.selectAll("." + wayID).classed("related", true);
67349         if (wayID) {
67350           var turns = _intersection.turns(wayID, _maxViaWay);
67351           for (var i4 = 0; i4 < turns.length; i4++) {
67352             var turn = turns[i4];
67353             var ids = [turn.to.way];
67354             var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
67355             if (turn.only || turns.length === 1) {
67356               if (turn.via.ways) {
67357                 ids = ids.concat(turn.via.ways);
67358               }
67359             } else if (turn.to.way === wayID) {
67360               continue;
67361             }
67362             surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67363           }
67364         }
67365       }
67366       function updateHints(datum2) {
67367         var help = _container.selectAll(".restriction-help").html("");
67368         var placeholders = {};
67369         ["from", "via", "to"].forEach(function(k2) {
67370           placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
67371         });
67372         var entity = datum2 && datum2.properties && datum2.properties.entity;
67373         if (entity) {
67374           datum2 = entity;
67375         }
67376         if (_fromWayID) {
67377           way = vgraph.entity(_fromWayID);
67378           surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67379         }
67380         if (datum2 instanceof osmWay && datum2.__from) {
67381           way = datum2;
67382           highlightPathsFrom(_fromWayID ? null : way.id);
67383           surface.selectAll("." + way.id).classed("related", true);
67384           var clickSelect = !_fromWayID || _fromWayID !== way.id;
67385           help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
67386             from: placeholders.from,
67387             fromName: displayName(way.id, vgraph)
67388           }));
67389         } else if (datum2 instanceof osmTurn) {
67390           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67391           var turnType = restrictionType.replace(/^(only|no)\_/, "");
67392           var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
67393           var klass, turnText, nextText;
67394           if (datum2.no) {
67395             klass = "restrict";
67396             turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
67397             nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
67398           } else if (datum2.only) {
67399             klass = "only";
67400             turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
67401             nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
67402           } else {
67403             klass = "allow";
67404             turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
67405             nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
67406           }
67407           help.append("div").attr("class", "qualifier " + klass).html(turnText);
67408           help.append("div").html(_t.html("restriction.help.from_name_to_name", {
67409             from: placeholders.from,
67410             fromName: displayName(datum2.from.way, vgraph),
67411             to: placeholders.to,
67412             toName: displayName(datum2.to.way, vgraph)
67413           }));
67414           if (datum2.via.ways && datum2.via.ways.length) {
67415             var names = [];
67416             for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
67417               var prev = names[names.length - 1];
67418               var curr = displayName(datum2.via.ways[i4], vgraph);
67419               if (!prev || curr !== prev) {
67420                 names.push(curr);
67421               }
67422             }
67423             help.append("div").html(_t.html("restriction.help.via_names", {
67424               via: placeholders.via,
67425               viaNames: names.join(", ")
67426             }));
67427           }
67428           if (!indirect) {
67429             help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
67430           }
67431           highlightPathsFrom(null);
67432           var alongIDs = datum2.path.slice();
67433           surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67434         } else {
67435           highlightPathsFrom(null);
67436           if (_fromWayID) {
67437             help.append("div").html(_t.html("restriction.help.from_name", {
67438               from: placeholders.from,
67439               fromName: displayName(_fromWayID, vgraph)
67440             }));
67441           } else {
67442             help.append("div").html(_t.html("restriction.help.select_from", {
67443               from: placeholders.from
67444             }));
67445           }
67446         }
67447       }
67448     }
67449     function displayMaxDistance(maxDist) {
67450       return (selection2) => {
67451         var isImperial = !_mainLocalizer.usesMetric();
67452         var opts;
67453         if (isImperial) {
67454           var distToFeet = {
67455             // imprecise conversion for prettier display
67456             20: 70,
67457             25: 85,
67458             30: 100,
67459             35: 115,
67460             40: 130,
67461             45: 145,
67462             50: 160
67463           }[maxDist];
67464           opts = { distance: _t("units.feet", { quantity: distToFeet }) };
67465         } else {
67466           opts = { distance: _t("units.meters", { quantity: maxDist }) };
67467         }
67468         return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
67469       };
67470     }
67471     function displayMaxVia(maxVia) {
67472       return (selection2) => {
67473         selection2 = selection2.html("");
67474         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"));
67475       };
67476     }
67477     function displayName(entityID, graph) {
67478       var entity = graph.entity(entityID);
67479       var name = utilDisplayName(entity) || "";
67480       var matched = _mainPresetIndex.match(entity, graph);
67481       var type2 = matched && matched.name() || utilDisplayType(entity.id);
67482       return name || type2;
67483     }
67484     restrictions.entityIDs = function(val) {
67485       _intersection = null;
67486       _fromWayID = null;
67487       _oldTurns = null;
67488       _vertexID = val[0];
67489     };
67490     restrictions.tags = function() {
67491     };
67492     restrictions.focus = function() {
67493     };
67494     restrictions.off = function(selection2) {
67495       if (!_initialized3)
67496         return;
67497       selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
67498       select_default2(window).on("resize.restrictions", null);
67499     };
67500     return utilRebind(restrictions, dispatch14, "on");
67501   }
67502   uiFieldRestrictions.supportsMultiselection = false;
67503
67504   // modules/ui/fields/textarea.js
67505   function uiFieldTextarea(field, context) {
67506     var dispatch14 = dispatch_default("change");
67507     var input = select_default2(null);
67508     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
67509     var _tags;
67510     function textarea(selection2) {
67511       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67512       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
67513       input = wrap2.selectAll("textarea").data([0]);
67514       input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
67515       wrap2.call(_lengthIndicator);
67516       function change(onInput) {
67517         return function() {
67518           var val = utilGetSetValue(input);
67519           if (!onInput)
67520             val = context.cleanTagValue(val);
67521           if (!val && Array.isArray(_tags[field.key]))
67522             return;
67523           var t2 = {};
67524           t2[field.key] = val || void 0;
67525           dispatch14.call("change", this, t2, onInput);
67526         };
67527       }
67528     }
67529     textarea.tags = function(tags) {
67530       _tags = tags;
67531       var isMixed = Array.isArray(tags[field.key]);
67532       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);
67533       if (!isMixed) {
67534         _lengthIndicator.update(tags[field.key]);
67535       }
67536     };
67537     textarea.focus = function() {
67538       input.node().focus();
67539     };
67540     return utilRebind(textarea, dispatch14, "on");
67541   }
67542
67543   // modules/ui/fields/wikidata.js
67544   function uiFieldWikidata(field, context) {
67545     var wikidata = services.wikidata;
67546     var dispatch14 = dispatch_default("change");
67547     var _selection = select_default2(null);
67548     var _searchInput = select_default2(null);
67549     var _qid = null;
67550     var _wikidataEntity = null;
67551     var _wikiURL = "";
67552     var _entityIDs = [];
67553     var _wikipediaKey = field.keys && field.keys.find(function(key) {
67554       return key.includes("wikipedia");
67555     });
67556     var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
67557     var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
67558     function wiki(selection2) {
67559       _selection = selection2;
67560       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67561       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67562       var list2 = wrap2.selectAll("ul").data([0]);
67563       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
67564       var searchRow = list2.selectAll("li.wikidata-search").data([0]);
67565       var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
67566       searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
67567         var node = select_default2(this).node();
67568         node.setSelectionRange(0, node.value.length);
67569       }).on("blur", function() {
67570         setLabelForEntity();
67571       }).call(combobox.fetcher(fetchWikidataItems));
67572       combobox.on("accept", function(d2) {
67573         if (d2) {
67574           _qid = d2.id;
67575           change();
67576         }
67577       }).on("cancel", function() {
67578         setLabelForEntity();
67579       });
67580       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) {
67581         d3_event.preventDefault();
67582         if (_wikiURL)
67583           window.open(_wikiURL, "_blank");
67584       });
67585       searchRow = searchRow.merge(searchRowEnter);
67586       _searchInput = searchRow.select("input");
67587       var wikidataProperties = ["description", "identifier"];
67588       var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
67589       var enter = items.enter().append("li").attr("class", function(d2) {
67590         return "labeled-input preset-wikidata-" + d2;
67591       });
67592       enter.append("span").attr("class", "label").html(function(d2) {
67593         return _t.html("wikidata." + d2);
67594       });
67595       enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
67596       enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
67597         d3_event.preventDefault();
67598         select_default2(this.parentNode).select("input").node().select();
67599         document.execCommand("copy");
67600       });
67601     }
67602     function fetchWikidataItems(q2, callback) {
67603       if (!q2 && _hintKey) {
67604         for (var i3 in _entityIDs) {
67605           var entity = context.hasEntity(_entityIDs[i3]);
67606           if (entity.tags[_hintKey]) {
67607             q2 = entity.tags[_hintKey];
67608             break;
67609           }
67610         }
67611       }
67612       wikidata.itemsForSearchQuery(q2, function(err, data) {
67613         if (err) {
67614           if (err !== "No query")
67615             console.error(err);
67616           return;
67617         }
67618         var result = data.map(function(item) {
67619           return {
67620             id: item.id,
67621             value: item.display.label.value + " (" + item.id + ")",
67622             display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
67623             title: item.display.description && item.display.description.value,
67624             terms: item.aliases
67625           };
67626         });
67627         if (callback)
67628           callback(result);
67629       });
67630     }
67631     function change() {
67632       var syncTags = {};
67633       syncTags[field.key] = _qid;
67634       dispatch14.call("change", this, syncTags);
67635       var initGraph = context.graph();
67636       var initEntityIDs = _entityIDs;
67637       wikidata.entityByQID(_qid, function(err, entity) {
67638         if (err)
67639           return;
67640         if (context.graph() !== initGraph)
67641           return;
67642         if (!entity.sitelinks)
67643           return;
67644         var langs = wikidata.languagesToQuery();
67645         ["labels", "descriptions"].forEach(function(key) {
67646           if (!entity[key])
67647             return;
67648           var valueLangs = Object.keys(entity[key]);
67649           if (valueLangs.length === 0)
67650             return;
67651           var valueLang = valueLangs[0];
67652           if (langs.indexOf(valueLang) === -1) {
67653             langs.push(valueLang);
67654           }
67655         });
67656         var newWikipediaValue;
67657         if (_wikipediaKey) {
67658           var foundPreferred;
67659           for (var i3 in langs) {
67660             var lang = langs[i3];
67661             var siteID = lang.replace("-", "_") + "wiki";
67662             if (entity.sitelinks[siteID]) {
67663               foundPreferred = true;
67664               newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
67665               break;
67666             }
67667           }
67668           if (!foundPreferred) {
67669             var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
67670               return site.endsWith("wiki");
67671             });
67672             if (wikiSiteKeys.length === 0) {
67673               newWikipediaValue = null;
67674             } else {
67675               var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
67676               var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
67677               newWikipediaValue = wikiLang + ":" + wikiTitle;
67678             }
67679           }
67680         }
67681         if (newWikipediaValue) {
67682           newWikipediaValue = context.cleanTagValue(newWikipediaValue);
67683         }
67684         if (typeof newWikipediaValue === "undefined")
67685           return;
67686         var actions = initEntityIDs.map(function(entityID) {
67687           var entity2 = context.hasEntity(entityID);
67688           if (!entity2)
67689             return null;
67690           var currTags = Object.assign({}, entity2.tags);
67691           if (newWikipediaValue === null) {
67692             if (!currTags[_wikipediaKey])
67693               return null;
67694             delete currTags[_wikipediaKey];
67695           } else {
67696             currTags[_wikipediaKey] = newWikipediaValue;
67697           }
67698           return actionChangeTags(entityID, currTags);
67699         }).filter(Boolean);
67700         if (!actions.length)
67701           return;
67702         context.overwrite(
67703           function actionUpdateWikipediaTags(graph) {
67704             actions.forEach(function(action) {
67705               graph = action(graph);
67706             });
67707             return graph;
67708           },
67709           context.history().undoAnnotation()
67710         );
67711       });
67712     }
67713     function setLabelForEntity() {
67714       var label = "";
67715       if (_wikidataEntity) {
67716         label = entityPropertyForDisplay(_wikidataEntity, "labels");
67717         if (label.length === 0) {
67718           label = _wikidataEntity.id.toString();
67719         }
67720       }
67721       utilGetSetValue(_searchInput, label);
67722     }
67723     wiki.tags = function(tags) {
67724       var isMixed = Array.isArray(tags[field.key]);
67725       _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
67726       _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
67727       if (!/^Q[0-9]*$/.test(_qid)) {
67728         unrecognized();
67729         return;
67730       }
67731       _wikiURL = "https://wikidata.org/wiki/" + _qid;
67732       wikidata.entityByQID(_qid, function(err, entity) {
67733         if (err) {
67734           unrecognized();
67735           return;
67736         }
67737         _wikidataEntity = entity;
67738         setLabelForEntity();
67739         var description = entityPropertyForDisplay(entity, "descriptions");
67740         _selection.select("button.wiki-link").classed("disabled", false);
67741         _selection.select(".preset-wikidata-description").style("display", function() {
67742           return description.length > 0 ? "flex" : "none";
67743         }).select("input").attr("value", description);
67744         _selection.select(".preset-wikidata-identifier").style("display", function() {
67745           return entity.id ? "flex" : "none";
67746         }).select("input").attr("value", entity.id);
67747       });
67748       function unrecognized() {
67749         _wikidataEntity = null;
67750         setLabelForEntity();
67751         _selection.select(".preset-wikidata-description").style("display", "none");
67752         _selection.select(".preset-wikidata-identifier").style("display", "none");
67753         _selection.select("button.wiki-link").classed("disabled", true);
67754         if (_qid && _qid !== "") {
67755           _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
67756         } else {
67757           _wikiURL = "";
67758         }
67759       }
67760     };
67761     function entityPropertyForDisplay(wikidataEntity, propKey) {
67762       if (!wikidataEntity[propKey])
67763         return "";
67764       var propObj = wikidataEntity[propKey];
67765       var langKeys = Object.keys(propObj);
67766       if (langKeys.length === 0)
67767         return "";
67768       var langs = wikidata.languagesToQuery();
67769       for (var i3 in langs) {
67770         var lang = langs[i3];
67771         var valueObj = propObj[lang];
67772         if (valueObj && valueObj.value && valueObj.value.length > 0)
67773           return valueObj.value;
67774       }
67775       return propObj[langKeys[0]].value;
67776     }
67777     wiki.entityIDs = function(val) {
67778       if (!arguments.length)
67779         return _entityIDs;
67780       _entityIDs = val;
67781       return wiki;
67782     };
67783     wiki.focus = function() {
67784       _searchInput.node().focus();
67785     };
67786     return utilRebind(wiki, dispatch14, "on");
67787   }
67788
67789   // modules/ui/fields/wikipedia.js
67790   function uiFieldWikipedia(field, context) {
67791     const dispatch14 = dispatch_default("change");
67792     const wikipedia = services.wikipedia;
67793     const wikidata = services.wikidata;
67794     let _langInput = select_default2(null);
67795     let _titleInput = select_default2(null);
67796     let _wikiURL = "";
67797     let _entityIDs;
67798     let _tags;
67799     let _dataWikipedia = [];
67800     _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
67801       _dataWikipedia = d2;
67802       if (_tags)
67803         updateForTags(_tags);
67804     }).catch(() => {
67805     });
67806     const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
67807       const v2 = value.toLowerCase();
67808       callback(
67809         _dataWikipedia.filter((d2) => {
67810           return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
67811         }).map((d2) => ({ value: d2[1] }))
67812       );
67813     });
67814     const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
67815       if (!value) {
67816         value = "";
67817         for (let i3 in _entityIDs) {
67818           let entity = context.hasEntity(_entityIDs[i3]);
67819           if (entity.tags.name) {
67820             value = entity.tags.name;
67821             break;
67822           }
67823         }
67824       }
67825       const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
67826       searchfn(language()[2], value, (query, data) => {
67827         callback(data.map((d2) => ({ value: d2 })));
67828       });
67829     });
67830     function wiki(selection2) {
67831       let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67832       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
67833       let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
67834       langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
67835       _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
67836       _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);
67837       _langInput.on("blur", changeLang).on("change", changeLang);
67838       let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
67839       titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
67840       _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
67841       _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
67842       _titleInput.on("blur", function() {
67843         change(true);
67844       }).on("change", function() {
67845         change(false);
67846       });
67847       let link3 = titleContainer.selectAll(".wiki-link").data([0]);
67848       link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikipedia.org" })).call(svgIcon("#iD-icon-out-link")).merge(link3);
67849       link3.on("click", (d3_event) => {
67850         d3_event.preventDefault();
67851         if (_wikiURL)
67852           window.open(_wikiURL, "_blank");
67853       });
67854     }
67855     function defaultLanguageInfo(skipEnglishFallback) {
67856       const langCode = _mainLocalizer.languageCode().toLowerCase();
67857       for (let i3 in _dataWikipedia) {
67858         let d2 = _dataWikipedia[i3];
67859         if (d2[2] === langCode)
67860           return d2;
67861       }
67862       return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
67863     }
67864     function language(skipEnglishFallback) {
67865       const value = utilGetSetValue(_langInput).toLowerCase();
67866       for (let i3 in _dataWikipedia) {
67867         let d2 = _dataWikipedia[i3];
67868         if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value)
67869           return d2;
67870       }
67871       return defaultLanguageInfo(skipEnglishFallback);
67872     }
67873     function changeLang() {
67874       utilGetSetValue(_langInput, language()[1]);
67875       change(true);
67876     }
67877     function change(skipWikidata) {
67878       let value = utilGetSetValue(_titleInput);
67879       const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
67880       const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
67881       let syncTags = {};
67882       if (langInfo) {
67883         const nativeLangName = langInfo[1];
67884         value = decodeURIComponent(m2[2]).replace(/_/g, " ");
67885         if (m2[3]) {
67886           let anchor;
67887           anchor = decodeURIComponent(m2[3]);
67888           value += "#" + anchor.replace(/_/g, " ");
67889         }
67890         value = value.slice(0, 1).toUpperCase() + value.slice(1);
67891         utilGetSetValue(_langInput, nativeLangName);
67892         utilGetSetValue(_titleInput, value);
67893       }
67894       if (value) {
67895         syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
67896       } else {
67897         syncTags.wikipedia = void 0;
67898       }
67899       dispatch14.call("change", this, syncTags);
67900       if (skipWikidata || !value || !language()[2])
67901         return;
67902       const initGraph = context.graph();
67903       const initEntityIDs = _entityIDs;
67904       wikidata.itemsByTitle(language()[2], value, (err, data) => {
67905         if (err || !data || !Object.keys(data).length)
67906           return;
67907         if (context.graph() !== initGraph)
67908           return;
67909         const qids = Object.keys(data);
67910         const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
67911         let actions = initEntityIDs.map((entityID) => {
67912           let entity = context.entity(entityID).tags;
67913           let currTags = Object.assign({}, entity);
67914           if (currTags.wikidata !== value2) {
67915             currTags.wikidata = value2;
67916             return actionChangeTags(entityID, currTags);
67917           }
67918           return null;
67919         }).filter(Boolean);
67920         if (!actions.length)
67921           return;
67922         context.overwrite(
67923           function actionUpdateWikidataTags(graph) {
67924             actions.forEach(function(action) {
67925               graph = action(graph);
67926             });
67927             return graph;
67928           },
67929           context.history().undoAnnotation()
67930         );
67931       });
67932     }
67933     wiki.tags = (tags) => {
67934       _tags = tags;
67935       updateForTags(tags);
67936     };
67937     function updateForTags(tags) {
67938       const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
67939       const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
67940       const tagLang = m2 && m2[1];
67941       const tagArticleTitle = m2 && m2[2];
67942       let anchor = m2 && m2[3];
67943       const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
67944       if (tagLangInfo) {
67945         const nativeLangName = tagLangInfo[1];
67946         utilGetSetValue(_langInput, nativeLangName);
67947         utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
67948         if (anchor) {
67949           try {
67950             anchor = encodeURIComponent(anchor.replace(/ /g, "_")).replace(/%/g, ".");
67951           } catch (e3) {
67952             anchor = anchor.replace(/ /g, "_");
67953           }
67954         }
67955         _wikiURL = "https://" + tagLang + ".wikipedia.org/wiki/" + tagArticleTitle.replace(/ /g, "_") + (anchor ? "#" + anchor : "");
67956       } else {
67957         utilGetSetValue(_titleInput, value);
67958         if (value && value !== "") {
67959           utilGetSetValue(_langInput, "");
67960           const defaultLangInfo = defaultLanguageInfo();
67961           _wikiURL = "https://".concat(defaultLangInfo[2], ".wikipedia.org/w/index.php?fulltext=1&search=").concat(value);
67962         } else {
67963           const shownOrDefaultLangInfo = language(
67964             true
67965             /* skipEnglishFallback */
67966           );
67967           utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
67968           _wikiURL = "";
67969         }
67970       }
67971     }
67972     wiki.entityIDs = (val) => {
67973       if (!arguments.length)
67974         return _entityIDs;
67975       _entityIDs = val;
67976       return wiki;
67977     };
67978     wiki.focus = () => {
67979       _titleInput.node().focus();
67980     };
67981     return utilRebind(wiki, dispatch14, "on");
67982   }
67983   uiFieldWikipedia.supportsMultiselection = false;
67984
67985   // modules/ui/fields/index.js
67986   var uiFields = {
67987     access: uiFieldAccess,
67988     address: uiFieldAddress,
67989     check: uiFieldCheck,
67990     colour: uiFieldText,
67991     combo: uiFieldCombo,
67992     cycleway: uiFieldDirectionalCombo,
67993     date: uiFieldText,
67994     defaultCheck: uiFieldCheck,
67995     directionalCombo: uiFieldDirectionalCombo,
67996     email: uiFieldText,
67997     identifier: uiFieldText,
67998     lanes: uiFieldLanes,
67999     localized: uiFieldLocalized,
68000     roadheight: uiFieldRoadheight,
68001     roadspeed: uiFieldRoadspeed,
68002     manyCombo: uiFieldCombo,
68003     multiCombo: uiFieldCombo,
68004     networkCombo: uiFieldCombo,
68005     number: uiFieldText,
68006     onewayCheck: uiFieldCheck,
68007     radio: uiFieldRadio,
68008     restrictions: uiFieldRestrictions,
68009     semiCombo: uiFieldCombo,
68010     structureRadio: uiFieldRadio,
68011     tel: uiFieldText,
68012     text: uiFieldText,
68013     textarea: uiFieldTextarea,
68014     typeCombo: uiFieldCombo,
68015     url: uiFieldText,
68016     wikidata: uiFieldWikidata,
68017     wikipedia: uiFieldWikipedia
68018   };
68019
68020   // modules/ui/field.js
68021   function uiField(context, presetField2, entityIDs, options2) {
68022     options2 = Object.assign({
68023       show: true,
68024       wrap: true,
68025       remove: true,
68026       revert: true,
68027       info: true
68028     }, options2);
68029     var dispatch14 = dispatch_default("change", "revert");
68030     var field = Object.assign({}, presetField2);
68031     field.domId = utilUniqueDomId("form-field-" + field.safeid);
68032     var _show = options2.show;
68033     var _state = "";
68034     var _tags = {};
68035     var _entityExtent;
68036     if (entityIDs && entityIDs.length) {
68037       _entityExtent = entityIDs.reduce(function(extent, entityID) {
68038         var entity = context.graph().entity(entityID);
68039         return extent.extend(entity.extent(context.graph()));
68040       }, geoExtent());
68041     }
68042     var _locked = false;
68043     var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
68044     if (_show && !field.impl) {
68045       createField();
68046     }
68047     function createField() {
68048       field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
68049         dispatch14.call("change", field, t2, onInput);
68050       });
68051       if (entityIDs) {
68052         field.entityIDs = entityIDs;
68053         if (field.impl.entityIDs) {
68054           field.impl.entityIDs(entityIDs);
68055         }
68056       }
68057     }
68058     function allKeys() {
68059       let keys2 = field.keys || [field.key];
68060       if (field.type === "directionalCombo" && field.key) {
68061         keys2 = keys2.concat(field.key);
68062       }
68063       return keys2;
68064     }
68065     function isModified() {
68066       if (!entityIDs || !entityIDs.length)
68067         return false;
68068       return entityIDs.some(function(entityID) {
68069         var original = context.graph().base().entities[entityID];
68070         var latest = context.graph().entity(entityID);
68071         return allKeys().some(function(key) {
68072           return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
68073         });
68074       });
68075     }
68076     function tagsContainFieldKey() {
68077       return allKeys().some(function(key) {
68078         if (field.type === "multiCombo") {
68079           for (var tagKey in _tags) {
68080             if (tagKey.indexOf(key) === 0) {
68081               return true;
68082             }
68083           }
68084           return false;
68085         }
68086         return _tags[key] !== void 0;
68087       });
68088     }
68089     function revert(d3_event, d2) {
68090       d3_event.stopPropagation();
68091       d3_event.preventDefault();
68092       if (!entityIDs || _locked)
68093         return;
68094       dispatch14.call("revert", d2, allKeys());
68095     }
68096     function remove2(d3_event, d2) {
68097       d3_event.stopPropagation();
68098       d3_event.preventDefault();
68099       if (_locked)
68100         return;
68101       var t2 = {};
68102       allKeys().forEach(function(key) {
68103         t2[key] = void 0;
68104       });
68105       dispatch14.call("change", d2, t2);
68106     }
68107     field.render = function(selection2) {
68108       var container = selection2.selectAll(".form-field").data([field]);
68109       var enter = container.enter().append("div").attr("class", function(d2) {
68110         return "form-field form-field-" + d2.safeid;
68111       }).classed("nowrap", !options2.wrap);
68112       if (options2.wrap) {
68113         var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
68114           return d2.domId;
68115         });
68116         var textEnter = labelEnter.append("span").attr("class", "label-text");
68117         textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
68118           d2.label()(select_default2(this));
68119         });
68120         textEnter.append("span").attr("class", "label-textannotation");
68121         if (options2.remove) {
68122           labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
68123         }
68124         if (options2.revert) {
68125           labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
68126         }
68127       }
68128       container = container.merge(enter);
68129       container.select(".field-label > .remove-icon").on("click", remove2);
68130       container.select(".field-label > .modified-icon").on("click", revert);
68131       container.each(function(d2) {
68132         var selection3 = select_default2(this);
68133         if (!d2.impl) {
68134           createField();
68135         }
68136         var reference, help;
68137         if (options2.wrap && field.type === "restrictions") {
68138           help = uiFieldHelp(context, "restrictions");
68139         }
68140         if (options2.wrap && options2.info) {
68141           var referenceKey = d2.key || "";
68142           if (d2.type === "multiCombo") {
68143             referenceKey = referenceKey.replace(/:$/, "");
68144           }
68145           var referenceOptions = d2.reference || {
68146             key: referenceKey,
68147             value: _tags[referenceKey]
68148           };
68149           reference = uiTagReference(referenceOptions, context);
68150           if (_state === "hover") {
68151             reference.showing(false);
68152           }
68153         }
68154         selection3.call(d2.impl);
68155         if (help) {
68156           selection3.call(help.body).select(".field-label").call(help.button);
68157         }
68158         if (reference) {
68159           selection3.call(reference.body).select(".field-label").call(reference.button);
68160         }
68161         d2.impl.tags(_tags);
68162       });
68163       container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
68164       var annotation = container.selectAll(".field-label .label-textannotation");
68165       var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
68166       icon2.exit().remove();
68167       icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
68168       container.call(_locked ? _lockedTip : _lockedTip.destroy);
68169     };
68170     field.state = function(val) {
68171       if (!arguments.length)
68172         return _state;
68173       _state = val;
68174       return field;
68175     };
68176     field.tags = function(val) {
68177       if (!arguments.length)
68178         return _tags;
68179       _tags = val;
68180       if (tagsContainFieldKey() && !_show) {
68181         _show = true;
68182         if (!field.impl) {
68183           createField();
68184         }
68185       }
68186       return field;
68187     };
68188     field.locked = function(val) {
68189       if (!arguments.length)
68190         return _locked;
68191       _locked = val;
68192       return field;
68193     };
68194     field.show = function() {
68195       _show = true;
68196       if (!field.impl) {
68197         createField();
68198       }
68199       if (field.default && field.key && _tags[field.key] !== field.default) {
68200         var t2 = {};
68201         t2[field.key] = field.default;
68202         dispatch14.call("change", this, t2);
68203       }
68204     };
68205     field.isShown = function() {
68206       return _show;
68207     };
68208     field.isAllowed = function() {
68209       if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false)
68210         return false;
68211       if (field.geometry && !entityIDs.every(function(entityID) {
68212         return field.matchGeometry(context.graph().geometry(entityID));
68213       }))
68214         return false;
68215       if (entityIDs && _entityExtent && field.locationSetID) {
68216         var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
68217         if (!validHere[field.locationSetID])
68218           return false;
68219       }
68220       var prerequisiteTag = field.prerequisiteTag;
68221       if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
68222       prerequisiteTag) {
68223         if (!entityIDs.every(function(entityID) {
68224           var entity = context.graph().entity(entityID);
68225           if (prerequisiteTag.key) {
68226             var value = entity.tags[prerequisiteTag.key];
68227             if (!value)
68228               return false;
68229             if (prerequisiteTag.valueNot) {
68230               return prerequisiteTag.valueNot !== value;
68231             }
68232             if (prerequisiteTag.value) {
68233               return prerequisiteTag.value === value;
68234             }
68235           } else if (prerequisiteTag.keyNot) {
68236             if (entity.tags[prerequisiteTag.keyNot])
68237               return false;
68238           }
68239           return true;
68240         }))
68241           return false;
68242       }
68243       return true;
68244     };
68245     field.focus = function() {
68246       if (field.impl) {
68247         field.impl.focus();
68248       }
68249     };
68250     return utilRebind(field, dispatch14, "on");
68251   }
68252
68253   // modules/ui/form_fields.js
68254   function uiFormFields(context) {
68255     var moreCombo = uiCombobox(context, "more-fields").minItems(1);
68256     var _fieldsArr = [];
68257     var _lastPlaceholder = "";
68258     var _state = "";
68259     var _klass = "";
68260     function formFields(selection2) {
68261       var allowedFields = _fieldsArr.filter(function(field) {
68262         return field.isAllowed();
68263       });
68264       var shown = allowedFields.filter(function(field) {
68265         return field.isShown();
68266       });
68267       var notShown = allowedFields.filter(function(field) {
68268         return !field.isShown();
68269       });
68270       var container = selection2.selectAll(".form-fields-container").data([0]);
68271       container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container);
68272       var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) {
68273         return d2.id + (d2.entityIDs ? d2.entityIDs.join() : "");
68274       });
68275       fields.exit().remove();
68276       var enter = fields.enter().append("div").attr("class", function(d2) {
68277         return "wrap-form-field wrap-form-field-" + d2.safeid;
68278       });
68279       fields = fields.merge(enter);
68280       fields.order().each(function(d2) {
68281         select_default2(this).call(d2.render);
68282       });
68283       var titles = [];
68284       var moreFields = notShown.map(function(field) {
68285         var title = field.title();
68286         titles.push(title);
68287         var terms = field.terms();
68288         if (field.key)
68289           terms.push(field.key);
68290         if (field.keys)
68291           terms = terms.concat(field.keys);
68292         return {
68293           display: field.label(),
68294           value: title,
68295           title,
68296           field,
68297           terms
68298         };
68299       });
68300       var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : "");
68301       var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]);
68302       more.exit().remove();
68303       var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label");
68304       moreEnter.append("span").call(_t.append("inspector.add_fields"));
68305       more = moreEnter.merge(more);
68306       var input = more.selectAll(".value").data([0]);
68307       input.exit().remove();
68308       input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input);
68309       input.call(utilGetSetValue, "").call(
68310         moreCombo.data(moreFields).on("accept", function(d2) {
68311           if (!d2)
68312             return;
68313           var field = d2.field;
68314           field.show();
68315           selection2.call(formFields);
68316           field.focus();
68317         })
68318       );
68319       if (_lastPlaceholder !== placeholder) {
68320         input.attr("placeholder", placeholder);
68321         _lastPlaceholder = placeholder;
68322       }
68323     }
68324     formFields.fieldsArr = function(val) {
68325       if (!arguments.length)
68326         return _fieldsArr;
68327       _fieldsArr = val || [];
68328       return formFields;
68329     };
68330     formFields.state = function(val) {
68331       if (!arguments.length)
68332         return _state;
68333       _state = val;
68334       return formFields;
68335     };
68336     formFields.klass = function(val) {
68337       if (!arguments.length)
68338         return _klass;
68339       _klass = val;
68340       return formFields;
68341     };
68342     return formFields;
68343   }
68344
68345   // modules/ui/changeset_editor.js
68346   function uiChangesetEditor(context) {
68347     var dispatch14 = dispatch_default("change");
68348     var formFields = uiFormFields(context);
68349     var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
68350     var _fieldsArr;
68351     var _tags;
68352     var _changesetID;
68353     function changesetEditor(selection2) {
68354       render(selection2);
68355     }
68356     function render(selection2) {
68357       var initial = false;
68358       if (!_fieldsArr) {
68359         initial = true;
68360         var presets = _mainPresetIndex;
68361         _fieldsArr = [
68362           uiField(context, presets.field("comment"), null, { show: true, revert: false }),
68363           uiField(context, presets.field("source"), null, { show: true, revert: false }),
68364           uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
68365         ];
68366         _fieldsArr.forEach(function(field) {
68367           field.on("change", function(t2, onInput) {
68368             dispatch14.call("change", field, void 0, t2, onInput);
68369           });
68370         });
68371       }
68372       _fieldsArr.forEach(function(field) {
68373         field.tags(_tags);
68374       });
68375       selection2.call(formFields.fieldsArr(_fieldsArr));
68376       if (initial) {
68377         var commentField = selection2.select(".form-field-comment textarea");
68378         var commentNode = commentField.node();
68379         if (commentNode) {
68380           commentNode.focus();
68381           commentNode.select();
68382         }
68383         utilTriggerEvent(commentField, "blur");
68384         var osm = context.connection();
68385         if (osm) {
68386           osm.userChangesets(function(err, changesets) {
68387             if (err)
68388               return;
68389             var comments = changesets.map(function(changeset) {
68390               var comment = changeset.tags.comment;
68391               return comment ? { title: comment, value: comment } : null;
68392             }).filter(Boolean);
68393             commentField.call(
68394               commentCombo.data(utilArrayUniqBy(comments, "title"))
68395             );
68396           });
68397         }
68398       }
68399       const warnings = [];
68400       if (_tags.comment.match(/google/i)) {
68401         warnings.push({
68402           id: 'contains "google"',
68403           msg: _t.append("commit.google_warning"),
68404           link: _t("commit.google_warning_link")
68405         });
68406       }
68407       const maxChars = context.maxCharsForTagValue();
68408       const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
68409       if (strLen > maxChars || false) {
68410         warnings.push({
68411           id: "message too long",
68412           msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
68413         });
68414       }
68415       var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
68416       commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
68417       var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
68418       commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
68419       commentEnter.transition().duration(200).style("opacity", 1);
68420       commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
68421         let selection3 = select_default2(this);
68422         if (d2.link) {
68423           selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
68424         }
68425         selection3.call(d2.msg);
68426       });
68427     }
68428     changesetEditor.tags = function(_2) {
68429       if (!arguments.length)
68430         return _tags;
68431       _tags = _2;
68432       return changesetEditor;
68433     };
68434     changesetEditor.changesetID = function(_2) {
68435       if (!arguments.length)
68436         return _changesetID;
68437       if (_changesetID === _2)
68438         return changesetEditor;
68439       _changesetID = _2;
68440       _fieldsArr = null;
68441       return changesetEditor;
68442     };
68443     return utilRebind(changesetEditor, dispatch14, "on");
68444   }
68445
68446   // modules/ui/commit.js
68447   var import_fast_deep_equal9 = __toESM(require_fast_deep_equal());
68448
68449   // modules/util/jxon.js
68450   var JXON = new function() {
68451     var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i;
68452     function parseText(sValue) {
68453       if (rIsNull.test(sValue)) {
68454         return null;
68455       }
68456       if (rIsBool.test(sValue)) {
68457         return sValue.toLowerCase() === "true";
68458       }
68459       if (isFinite(sValue)) {
68460         return parseFloat(sValue);
68461       }
68462       if (isFinite(Date.parse(sValue))) {
68463         return new Date(sValue);
68464       }
68465       return sValue;
68466     }
68467     function EmptyTree() {
68468     }
68469     EmptyTree.prototype.toString = function() {
68470       return "null";
68471     };
68472     EmptyTree.prototype.valueOf = function() {
68473       return null;
68474     };
68475     function objectify(vValue) {
68476       return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
68477     }
68478     function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
68479       var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2);
68480       var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : (
68481         /* put here the default value for empty nodes: */
68482         true
68483       );
68484       if (bChildren) {
68485         for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
68486           oNode = oParentNode.childNodes.item(nItem);
68487           if (oNode.nodeType === 4) {
68488             sCollectedTxt += oNode.nodeValue;
68489           } else if (oNode.nodeType === 3) {
68490             sCollectedTxt += oNode.nodeValue.trim();
68491           } else if (oNode.nodeType === 1 && !oNode.prefix) {
68492             aCache.push(oNode);
68493           }
68494         }
68495       }
68496       var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt);
68497       if (!bHighVerb && (bChildren || bAttributes)) {
68498         vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
68499       }
68500       for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
68501         sProp = aCache[nElId].nodeName.toLowerCase();
68502         vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
68503         if (vResult.hasOwnProperty(sProp)) {
68504           if (vResult[sProp].constructor !== Array) {
68505             vResult[sProp] = [vResult[sProp]];
68506           }
68507           vResult[sProp].push(vContent);
68508         } else {
68509           vResult[sProp] = vContent;
68510           nLength++;
68511         }
68512       }
68513       if (bAttributes) {
68514         var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult;
68515         for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
68516           oAttrib = oParentNode.attributes.item(nAttrib);
68517           oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim());
68518         }
68519         if (bNesteAttr) {
68520           if (bFreeze) {
68521             Object.freeze(oAttrParent);
68522           }
68523           vResult[sAttributesProp] = oAttrParent;
68524           nLength -= nAttrLen - 1;
68525         }
68526       }
68527       if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
68528         vResult[sValueProp] = vBuiltVal;
68529       } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
68530         vResult = vBuiltVal;
68531       }
68532       if (bFreeze && (bHighVerb || nLength > 0)) {
68533         Object.freeze(vResult);
68534       }
68535       aCache.length = nLevelStart;
68536       return vResult;
68537     }
68538     function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
68539       var vValue, oChild;
68540       if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) {
68541         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString()));
68542       } else if (oParentObj.constructor === Date) {
68543         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString()));
68544       }
68545       for (var sName in oParentObj) {
68546         vValue = oParentObj[sName];
68547         if (isFinite(sName) || vValue instanceof Function) {
68548           continue;
68549         }
68550         if (sName === sValueProp) {
68551           if (vValue !== null && vValue !== true) {
68552             oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue)));
68553           }
68554         } else if (sName === sAttributesProp) {
68555           for (var sAttrib in vValue) {
68556             oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
68557           }
68558         } else if (sName.charAt(0) === sAttrPref) {
68559           oParentEl.setAttribute(sName.slice(1), vValue);
68560         } else if (vValue.constructor === Array) {
68561           for (var nItem = 0; nItem < vValue.length; nItem++) {
68562             oChild = oXMLDoc.createElement(sName);
68563             loadObjTree(oXMLDoc, oChild, vValue[nItem]);
68564             oParentEl.appendChild(oChild);
68565           }
68566         } else {
68567           oChild = oXMLDoc.createElement(sName);
68568           if (vValue instanceof Object) {
68569             loadObjTree(oXMLDoc, oChild, vValue);
68570           } else if (vValue !== null && vValue !== true) {
68571             oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
68572           }
68573           oParentEl.appendChild(oChild);
68574         }
68575       }
68576     }
68577     this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) {
68578       var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : (
68579         /* put here the default verbosity level: */
68580         1
68581       );
68582       return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
68583     };
68584     this.unbuild = function(oObjTree) {
68585       var oNewDoc = document.implementation.createDocument("", "", null);
68586       loadObjTree(oNewDoc, oNewDoc, oObjTree);
68587       return oNewDoc;
68588     };
68589     this.stringify = function(oObjTree) {
68590       return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree));
68591     };
68592   }();
68593
68594   // modules/ui/sections/changes.js
68595   function uiSectionChanges(context) {
68596     var _discardTags = {};
68597     _mainFileFetcher.get("discarded").then(function(d2) {
68598       _discardTags = d2;
68599     }).catch(function() {
68600     });
68601     var section = uiSection("changes-list", context).label(function() {
68602       var history = context.history();
68603       var summary = history.difference().summary();
68604       return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
68605     }).disclosureContent(renderDisclosureContent);
68606     function renderDisclosureContent(selection2) {
68607       var history = context.history();
68608       var summary = history.difference().summary();
68609       var container = selection2.selectAll(".commit-section").data([0]);
68610       var containerEnter = container.enter().append("div").attr("class", "commit-section");
68611       containerEnter.append("ul").attr("class", "changeset-list");
68612       container = containerEnter.merge(container);
68613       var items = container.select("ul").selectAll("li").data(summary);
68614       var itemsEnter = items.enter().append("li").attr("class", "change-item");
68615       var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
68616       buttons.each(function(d2) {
68617         select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
68618       });
68619       buttons.append("span").attr("class", "change-type").html(function(d2) {
68620         return _t.html("commit." + d2.changeType) + " ";
68621       });
68622       buttons.append("strong").attr("class", "entity-type").text(function(d2) {
68623         var matched = _mainPresetIndex.match(d2.entity, d2.graph);
68624         return matched && matched.name() || utilDisplayType(d2.entity.id);
68625       });
68626       buttons.append("span").attr("class", "entity-name").text(function(d2) {
68627         var name = utilDisplayName(d2.entity) || "", string = "";
68628         if (name !== "") {
68629           string += ":";
68630         }
68631         return string += " " + name;
68632       });
68633       items = itemsEnter.merge(items);
68634       var changeset = new osmChangeset().update({ id: void 0 });
68635       var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
68636       delete changeset.id;
68637       var data = JXON.stringify(changeset.osmChangeJXON(changes));
68638       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
68639       var fileName = "changes.osc";
68640       var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
68641       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
68642       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
68643       function mouseover(d2) {
68644         if (d2.entity) {
68645           context.surface().selectAll(
68646             utilEntityOrMemberSelector([d2.entity.id], context.graph())
68647           ).classed("hover", true);
68648         }
68649       }
68650       function mouseout() {
68651         context.surface().selectAll(".hover").classed("hover", false);
68652       }
68653       function click(d3_event, change) {
68654         if (change.changeType !== "deleted") {
68655           var entity = change.entity;
68656           context.map().zoomToEase(entity);
68657           context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
68658         }
68659       }
68660     }
68661     return section;
68662   }
68663
68664   // modules/ui/commit_warnings.js
68665   function uiCommitWarnings(context) {
68666     function commitWarnings(selection2) {
68667       var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
68668       for (var severity in issuesBySeverity) {
68669         var issues = issuesBySeverity[severity];
68670         if (severity !== "error") {
68671           issues = issues.filter(function(issue) {
68672             return issue.type !== "help_request";
68673           });
68674         }
68675         var section = severity + "-section";
68676         var issueItem = severity + "-item";
68677         var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
68678         container.exit().remove();
68679         var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
68680         containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
68681         containerEnter.append("ul").attr("class", "changeset-list");
68682         container = containerEnter.merge(container);
68683         var items = container.select("ul").selectAll("li").data(issues, function(d2) {
68684           return d2.key;
68685         });
68686         items.exit().remove();
68687         var itemsEnter = items.enter().append("li").attr("class", issueItem);
68688         var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
68689           if (d2.entityIds) {
68690             context.surface().selectAll(
68691               utilEntityOrMemberSelector(
68692                 d2.entityIds,
68693                 context.graph()
68694               )
68695             ).classed("hover", true);
68696           }
68697         }).on("mouseout", function() {
68698           context.surface().selectAll(".hover").classed("hover", false);
68699         }).on("click", function(d3_event, d2) {
68700           context.validator().focusIssue(d2);
68701         });
68702         buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
68703         buttons.append("strong").attr("class", "issue-message");
68704         buttons.filter(function(d2) {
68705           return d2.tooltip;
68706         }).call(
68707           uiTooltip().title(function(d2) {
68708             return d2.tooltip;
68709           }).placement("top")
68710         );
68711         items = itemsEnter.merge(items);
68712         items.selectAll(".issue-message").text("").each(function(d2) {
68713           return d2.message(context)(select_default2(this));
68714         });
68715       }
68716     }
68717     return commitWarnings;
68718   }
68719
68720   // modules/ui/commit.js
68721   var readOnlyTags = [
68722     /^changesets_count$/,
68723     /^created_by$/,
68724     /^ideditor:/,
68725     /^imagery_used$/,
68726     /^host$/,
68727     /^locale$/,
68728     /^warnings:/,
68729     /^resolved:/,
68730     /^closed:note$/,
68731     /^closed:keepright$/,
68732     /^closed:improveosm:/,
68733     /^closed:osmose:/
68734   ];
68735   var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
68736   function uiCommit(context) {
68737     var dispatch14 = dispatch_default("cancel");
68738     var _userDetails2;
68739     var _selection;
68740     var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
68741     var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
68742     var commitChanges = uiSectionChanges(context);
68743     var commitWarnings = uiCommitWarnings(context);
68744     function commit(selection2) {
68745       _selection = selection2;
68746       if (!context.changeset)
68747         initChangeset();
68748       loadDerivedChangesetTags();
68749       selection2.call(render);
68750     }
68751     function initChangeset() {
68752       var commentDate = +corePreferences("commentDate") || 0;
68753       var currDate = Date.now();
68754       var cutoff = 2 * 86400 * 1e3;
68755       if (commentDate > currDate || currDate - commentDate > cutoff) {
68756         corePreferences("comment", null);
68757         corePreferences("hashtags", null);
68758         corePreferences("source", null);
68759       }
68760       if (context.defaultChangesetComment()) {
68761         corePreferences("comment", context.defaultChangesetComment());
68762         corePreferences("commentDate", Date.now());
68763       }
68764       if (context.defaultChangesetSource()) {
68765         corePreferences("source", context.defaultChangesetSource());
68766         corePreferences("commentDate", Date.now());
68767       }
68768       if (context.defaultChangesetHashtags()) {
68769         corePreferences("hashtags", context.defaultChangesetHashtags());
68770         corePreferences("commentDate", Date.now());
68771       }
68772       var detected = utilDetect();
68773       var tags = {
68774         comment: corePreferences("comment") || "",
68775         created_by: context.cleanTagValue("iD " + context.version),
68776         host: context.cleanTagValue(detected.host),
68777         locale: context.cleanTagValue(_mainLocalizer.localeCode())
68778       };
68779       findHashtags(tags, true);
68780       var hashtags = corePreferences("hashtags");
68781       if (hashtags) {
68782         tags.hashtags = hashtags;
68783       }
68784       var source = corePreferences("source");
68785       if (source) {
68786         tags.source = source;
68787       }
68788       var photoOverlaysUsed = context.history().photoOverlaysUsed();
68789       if (photoOverlaysUsed.length) {
68790         var sources = (tags.source || "").split(";");
68791         if (sources.indexOf("streetlevel imagery") === -1) {
68792           sources.push("streetlevel imagery");
68793         }
68794         photoOverlaysUsed.forEach(function(photoOverlay) {
68795           if (sources.indexOf(photoOverlay) === -1) {
68796             sources.push(photoOverlay);
68797           }
68798         });
68799         tags.source = context.cleanTagValue(sources.join(";"));
68800       }
68801       context.changeset = new osmChangeset({ tags });
68802     }
68803     function loadDerivedChangesetTags() {
68804       var osm = context.connection();
68805       if (!osm)
68806         return;
68807       var tags = Object.assign({}, context.changeset.tags);
68808       var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
68809       tags.imagery_used = imageryUsed || "None";
68810       var osmClosed = osm.getClosedIDs();
68811       var itemType;
68812       if (osmClosed.length) {
68813         tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
68814       }
68815       if (services.keepRight) {
68816         var krClosed = services.keepRight.getClosedIDs();
68817         if (krClosed.length) {
68818           tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
68819         }
68820       }
68821       if (services.improveOSM) {
68822         var iOsmClosed = services.improveOSM.getClosedCounts();
68823         for (itemType in iOsmClosed) {
68824           tags["closed:improveosm:" + itemType] = context.cleanTagValue(iOsmClosed[itemType].toString());
68825         }
68826       }
68827       if (services.osmose) {
68828         var osmoseClosed = services.osmose.getClosedCounts();
68829         for (itemType in osmoseClosed) {
68830           tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
68831         }
68832       }
68833       for (var key in tags) {
68834         if (key.match(/(^warnings:)|(^resolved:)/)) {
68835           delete tags[key];
68836         }
68837       }
68838       function addIssueCounts(issues, prefix) {
68839         var issuesByType = utilArrayGroupBy(issues, "type");
68840         for (var issueType in issuesByType) {
68841           var issuesOfType = issuesByType[issueType];
68842           if (issuesOfType[0].subtype) {
68843             var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
68844             for (var issueSubtype in issuesBySubtype) {
68845               var issuesOfSubtype = issuesBySubtype[issueSubtype];
68846               tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
68847             }
68848           } else {
68849             tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
68850           }
68851         }
68852       }
68853       var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
68854         return issue.type !== "help_request";
68855       });
68856       addIssueCounts(warnings, "warnings");
68857       var resolvedIssues = context.validator().getResolvedIssues();
68858       addIssueCounts(resolvedIssues, "resolved");
68859       context.changeset = context.changeset.update({ tags });
68860     }
68861     function render(selection2) {
68862       var osm = context.connection();
68863       if (!osm)
68864         return;
68865       var header = selection2.selectAll(".header").data([0]);
68866       var headerTitle = header.enter().append("div").attr("class", "header fillL");
68867       headerTitle.append("div").append("h2").call(_t.append("commit.title"));
68868       headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
68869         dispatch14.call("cancel", this);
68870       }).call(svgIcon("#iD-icon-close"));
68871       var body = selection2.selectAll(".body").data([0]);
68872       body = body.enter().append("div").attr("class", "body").merge(body);
68873       var changesetSection = body.selectAll(".changeset-editor").data([0]);
68874       changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
68875       changesetSection.call(
68876         changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
68877       );
68878       body.call(commitWarnings);
68879       var saveSection = body.selectAll(".save-section").data([0]);
68880       saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
68881       var prose = saveSection.selectAll(".commit-info").data([0]);
68882       if (prose.enter().size()) {
68883         _userDetails2 = null;
68884       }
68885       prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
68886       osm.userDetails(function(err, user) {
68887         if (err)
68888           return;
68889         if (_userDetails2 === user)
68890           return;
68891         _userDetails2 = user;
68892         var userLink = select_default2(document.createElement("div"));
68893         if (user.image_url) {
68894           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
68895         }
68896         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
68897         prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
68898       });
68899       var requestReview = saveSection.selectAll(".request-review").data([0]);
68900       var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
68901       var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
68902       var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
68903       if (!labelEnter.empty()) {
68904         labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
68905       }
68906       labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
68907       labelEnter.append("span").call(_t.append("commit.request_review"));
68908       requestReview = requestReview.merge(requestReviewEnter);
68909       var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
68910       var buttonSection = saveSection.selectAll(".buttons").data([0]);
68911       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
68912       buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
68913       var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
68914       uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
68915       var uploadBlockerTooltipText = getUploadBlockerMessage();
68916       buttonSection = buttonSection.merge(buttonEnter);
68917       buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
68918         dispatch14.call("cancel", this);
68919       });
68920       buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
68921         if (!select_default2(this).classed("disabled")) {
68922           this.blur();
68923           for (var key in context.changeset.tags) {
68924             if (!key)
68925               delete context.changeset.tags[key];
68926           }
68927           context.uploader().save(context.changeset);
68928         }
68929       });
68930       uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
68931       if (uploadBlockerTooltipText) {
68932         buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
68933       }
68934       var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
68935       tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
68936       tagSection.call(
68937         rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68938       );
68939       var changesSection = body.selectAll(".commit-changes-section").data([0]);
68940       changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
68941       changesSection.call(commitChanges.render);
68942       function toggleRequestReview() {
68943         var rr = requestReviewInput.property("checked");
68944         updateChangeset({ review_requested: rr ? "yes" : void 0 });
68945         tagSection.call(
68946           rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68947         );
68948       }
68949     }
68950     function getUploadBlockerMessage() {
68951       var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
68952       if (errors.length) {
68953         return _t.append("commit.outstanding_errors_message", { count: errors.length });
68954       } else {
68955         var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
68956         if (!hasChangesetComment) {
68957           return _t.append("commit.comment_needed_message");
68958         }
68959       }
68960       return null;
68961     }
68962     function changeTags(_2, changed, onInput) {
68963       if (changed.hasOwnProperty("comment")) {
68964         if (changed.comment === void 0) {
68965           changed.comment = "";
68966         }
68967         if (!onInput) {
68968           corePreferences("comment", changed.comment);
68969           corePreferences("commentDate", Date.now());
68970         }
68971       }
68972       if (changed.hasOwnProperty("source")) {
68973         if (changed.source === void 0) {
68974           corePreferences("source", null);
68975         } else if (!onInput) {
68976           corePreferences("source", changed.source);
68977           corePreferences("commentDate", Date.now());
68978         }
68979       }
68980       updateChangeset(changed, onInput);
68981       if (_selection) {
68982         _selection.call(render);
68983       }
68984     }
68985     function findHashtags(tags, commentOnly) {
68986       var detectedHashtags = commentHashtags();
68987       if (detectedHashtags.length) {
68988         corePreferences("hashtags", null);
68989       }
68990       if (!detectedHashtags.length || !commentOnly) {
68991         detectedHashtags = detectedHashtags.concat(hashtagHashtags());
68992       }
68993       var allLowerCase = /* @__PURE__ */ new Set();
68994       return detectedHashtags.filter(function(hashtag) {
68995         var lowerCase = hashtag.toLowerCase();
68996         if (!allLowerCase.has(lowerCase)) {
68997           allLowerCase.add(lowerCase);
68998           return true;
68999         }
69000         return false;
69001       });
69002       function commentHashtags() {
69003         var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
69004         return matches || [];
69005       }
69006       function hashtagHashtags() {
69007         var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
69008           if (s2[0] !== "#") {
69009             s2 = "#" + s2;
69010           }
69011           var matched = s2.match(hashtagRegex);
69012           return matched && matched[0];
69013         }).filter(Boolean);
69014         return matches || [];
69015       }
69016     }
69017     function isReviewRequested(tags) {
69018       var rr = tags.review_requested;
69019       if (rr === void 0)
69020         return false;
69021       rr = rr.trim().toLowerCase();
69022       return !(rr === "" || rr === "no");
69023     }
69024     function updateChangeset(changed, onInput) {
69025       var tags = Object.assign({}, context.changeset.tags);
69026       Object.keys(changed).forEach(function(k2) {
69027         var v2 = changed[k2];
69028         k2 = context.cleanTagKey(k2);
69029         if (readOnlyTags.indexOf(k2) !== -1)
69030           return;
69031         if (v2 === void 0) {
69032           delete tags[k2];
69033         } else if (onInput) {
69034           tags[k2] = v2;
69035         } else {
69036           tags[k2] = context.cleanTagValue(v2);
69037         }
69038       });
69039       if (!onInput) {
69040         var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
69041         var arr = findHashtags(tags, commentOnly);
69042         if (arr.length) {
69043           tags.hashtags = context.cleanTagValue(arr.join(";"));
69044           corePreferences("hashtags", tags.hashtags);
69045         } else {
69046           delete tags.hashtags;
69047           corePreferences("hashtags", null);
69048         }
69049       }
69050       if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
69051         var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
69052         tags.changesets_count = String(changesetsCount);
69053         if (changesetsCount <= 100) {
69054           var s2;
69055           s2 = corePreferences("walkthrough_completed");
69056           if (s2) {
69057             tags["ideditor:walkthrough_completed"] = s2;
69058           }
69059           s2 = corePreferences("walkthrough_progress");
69060           if (s2) {
69061             tags["ideditor:walkthrough_progress"] = s2;
69062           }
69063           s2 = corePreferences("walkthrough_started");
69064           if (s2) {
69065             tags["ideditor:walkthrough_started"] = s2;
69066           }
69067         }
69068       } else {
69069         delete tags.changesets_count;
69070       }
69071       if (!(0, import_fast_deep_equal9.default)(context.changeset.tags, tags)) {
69072         context.changeset = context.changeset.update({ tags });
69073       }
69074     }
69075     commit.reset = function() {
69076       context.changeset = null;
69077     };
69078     return utilRebind(commit, dispatch14, "on");
69079   }
69080
69081   // modules/ui/confirm.js
69082   function uiConfirm(selection2) {
69083     var modalSelection = uiModal(selection2);
69084     modalSelection.select(".modal").classed("modal-alert", true);
69085     var section = modalSelection.select(".content");
69086     section.append("div").attr("class", "modal-section header");
69087     section.append("div").attr("class", "modal-section message-text");
69088     var buttons = section.append("div").attr("class", "modal-section buttons cf");
69089     modalSelection.okButton = function() {
69090       buttons.append("button").attr("class", "button ok-button action").on("click.confirm", function() {
69091         modalSelection.remove();
69092       }).call(_t.append("confirm.okay")).node().focus();
69093       return modalSelection;
69094     };
69095     return modalSelection;
69096   }
69097
69098   // modules/ui/conflicts.js
69099   function uiConflicts(context) {
69100     var dispatch14 = dispatch_default("cancel", "save");
69101     var keybinding = utilKeybinding("conflicts");
69102     var _origChanges;
69103     var _conflictList;
69104     var _shownConflictIndex;
69105     function keybindingOn() {
69106       select_default2(document).call(keybinding.on("\u238B", cancel, true));
69107     }
69108     function keybindingOff() {
69109       select_default2(document).call(keybinding.unbind);
69110     }
69111     function tryAgain() {
69112       keybindingOff();
69113       dispatch14.call("save");
69114     }
69115     function cancel() {
69116       keybindingOff();
69117       dispatch14.call("cancel");
69118     }
69119     function conflicts(selection2) {
69120       keybindingOn();
69121       var headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
69122       headerEnter.append("button").attr("class", "fr").attr("title", _t("icons.close")).on("click", cancel).call(svgIcon("#iD-icon-close"));
69123       headerEnter.append("h2").call(_t.append("save.conflict.header"));
69124       var bodyEnter = selection2.selectAll(".body").data([0]).enter().append("div").attr("class", "body fillL");
69125       var conflictsHelpEnter = bodyEnter.append("div").attr("class", "conflicts-help").call(_t.append("save.conflict.help"));
69126       var changeset = new osmChangeset();
69127       delete changeset.id;
69128       var data = JXON.stringify(changeset.osmChangeJXON(_origChanges));
69129       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
69130       var fileName = "changes.osc";
69131       var linkEnter = conflictsHelpEnter.selectAll(".download-changes").append("a").attr("class", "download-changes");
69132       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
69133       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("save.conflict.download_changes"));
69134       bodyEnter.append("div").attr("class", "conflict-container fillL3").call(showConflict, 0);
69135       bodyEnter.append("div").attr("class", "conflicts-done").attr("opacity", 0).style("display", "none").call(_t.append("save.conflict.done"));
69136       var buttonsEnter = bodyEnter.append("div").attr("class", "buttons col12 joined conflicts-buttons");
69137       buttonsEnter.append("button").attr("disabled", _conflictList.length > 1).attr("class", "action conflicts-button col6").call(_t.append("save.title")).on("click.try_again", tryAgain);
69138       buttonsEnter.append("button").attr("class", "secondary-action conflicts-button col6").call(_t.append("confirm.cancel")).on("click.cancel", cancel);
69139     }
69140     function showConflict(selection2, index) {
69141       index = utilWrap(index, _conflictList.length);
69142       _shownConflictIndex = index;
69143       var parent = select_default2(selection2.node().parentNode);
69144       if (index === _conflictList.length - 1) {
69145         window.setTimeout(function() {
69146           parent.select(".conflicts-button").attr("disabled", null);
69147           parent.select(".conflicts-done").transition().attr("opacity", 1).style("display", "block");
69148         }, 250);
69149       }
69150       var conflict = selection2.selectAll(".conflict").data([_conflictList[index]]);
69151       conflict.exit().remove();
69152       var conflictEnter = conflict.enter().append("div").attr("class", "conflict");
69153       conflictEnter.append("h4").attr("class", "conflict-count").call(_t.append("save.conflict.count", { num: index + 1, total: _conflictList.length }));
69154       conflictEnter.append("a").attr("class", "conflict-description").attr("href", "#").text(function(d2) {
69155         return d2.name;
69156       }).on("click", function(d3_event, d2) {
69157         d3_event.preventDefault();
69158         zoomToEntity(d2.id);
69159       });
69160       var details = conflictEnter.append("div").attr("class", "conflict-detail-container");
69161       details.append("ul").attr("class", "conflict-detail-list").selectAll("li").data(function(d2) {
69162         return d2.details || [];
69163       }).enter().append("li").attr("class", "conflict-detail-item").html(function(d2) {
69164         return d2;
69165       });
69166       details.append("div").attr("class", "conflict-choices").call(addChoices);
69167       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) {
69168         return i3 === 0 && index === 0 || i3 === 1 && index === _conflictList.length - 1 || null;
69169       }).on("click", function(d3_event, d2) {
69170         d3_event.preventDefault();
69171         var container = parent.selectAll(".conflict-container");
69172         var sign2 = d2 === "previous" ? -1 : 1;
69173         container.selectAll(".conflict").remove();
69174         container.call(showConflict, index + sign2);
69175       }).each(function(d2) {
69176         _t.append("save.conflict." + d2)(select_default2(this));
69177       });
69178     }
69179     function addChoices(selection2) {
69180       var choices = selection2.append("ul").attr("class", "layer-list").selectAll("li").data(function(d2) {
69181         return d2.choices || [];
69182       });
69183       var choicesEnter = choices.enter().append("li").attr("class", "layer");
69184       var labelEnter = choicesEnter.append("label");
69185       labelEnter.append("input").attr("type", "radio").attr("name", function(d2) {
69186         return d2.id;
69187       }).on("change", function(d3_event, d2) {
69188         var ul = this.parentNode.parentNode.parentNode;
69189         ul.__data__.chosen = d2.id;
69190         choose(d3_event, ul, d2);
69191       });
69192       labelEnter.append("span").text(function(d2) {
69193         return d2.text;
69194       });
69195       choicesEnter.merge(choices).each(function(d2) {
69196         var ul = this.parentNode;
69197         if (ul.__data__.chosen === d2.id) {
69198           choose(null, ul, d2);
69199         }
69200       });
69201     }
69202     function choose(d3_event, ul, datum2) {
69203       if (d3_event)
69204         d3_event.preventDefault();
69205       select_default2(ul).selectAll("li").classed("active", function(d2) {
69206         return d2 === datum2;
69207       }).selectAll("input").property("checked", function(d2) {
69208         return d2 === datum2;
69209       });
69210       var extent = geoExtent();
69211       var entity;
69212       entity = context.graph().hasEntity(datum2.id);
69213       if (entity)
69214         extent._extend(entity.extent(context.graph()));
69215       datum2.action();
69216       entity = context.graph().hasEntity(datum2.id);
69217       if (entity)
69218         extent._extend(entity.extent(context.graph()));
69219       zoomToEntity(datum2.id, extent);
69220     }
69221     function zoomToEntity(id2, extent) {
69222       context.surface().selectAll(".hover").classed("hover", false);
69223       var entity = context.graph().hasEntity(id2);
69224       if (entity) {
69225         if (extent) {
69226           context.map().trimmedExtent(extent);
69227         } else {
69228           context.map().zoomToEase(entity);
69229         }
69230         context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
69231       }
69232     }
69233     conflicts.conflictList = function(_2) {
69234       if (!arguments.length)
69235         return _conflictList;
69236       _conflictList = _2;
69237       return conflicts;
69238     };
69239     conflicts.origChanges = function(_2) {
69240       if (!arguments.length)
69241         return _origChanges;
69242       _origChanges = _2;
69243       return conflicts;
69244     };
69245     conflicts.shownEntityIds = function() {
69246       if (_conflictList && typeof _shownConflictIndex === "number") {
69247         return [_conflictList[_shownConflictIndex].id];
69248       }
69249       return [];
69250     };
69251     return utilRebind(conflicts, dispatch14, "on");
69252   }
69253
69254   // modules/ui/entity_editor.js
69255   var import_fast_deep_equal10 = __toESM(require_fast_deep_equal());
69256
69257   // modules/ui/sections/entity_issues.js
69258   function uiSectionEntityIssues(context) {
69259     var preference = corePreferences("entity-issues.reference.expanded");
69260     var _expanded = preference === null ? true : preference === "true";
69261     var _entityIDs = [];
69262     var _issues = [];
69263     var _activeIssueID;
69264     var section = uiSection("entity-issues", context).shouldDisplay(function() {
69265       return _issues.length > 0;
69266     }).label(function() {
69267       return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length });
69268     }).disclosureContent(renderDisclosureContent);
69269     context.validator().on("validated.entity_issues", function() {
69270       reloadIssues();
69271       section.reRender();
69272     }).on("focusedIssue.entity_issues", function(issue) {
69273       makeActiveIssue(issue.id);
69274     });
69275     function reloadIssues() {
69276       _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true });
69277     }
69278     function makeActiveIssue(issueID) {
69279       _activeIssueID = issueID;
69280       section.selection().selectAll(".issue-container").classed("active", function(d2) {
69281         return d2.id === _activeIssueID;
69282       });
69283     }
69284     function renderDisclosureContent(selection2) {
69285       selection2.classed("grouped-items-area", true);
69286       _activeIssueID = _issues.length > 0 ? _issues[0].id : null;
69287       var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) {
69288         return d2.key;
69289       });
69290       containers.exit().remove();
69291       var containersEnter = containers.enter().append("div").attr("class", "issue-container");
69292       var itemsEnter = containersEnter.append("div").attr("class", function(d2) {
69293         return "issue severity-" + d2.severity;
69294       }).on("mouseover.highlight", function(d3_event, d2) {
69295         var ids = d2.entityIds.filter(function(e3) {
69296           return _entityIDs.indexOf(e3) === -1;
69297         });
69298         utilHighlightEntities(ids, true, context);
69299       }).on("mouseout.highlight", function(d3_event, d2) {
69300         var ids = d2.entityIds.filter(function(e3) {
69301           return _entityIDs.indexOf(e3) === -1;
69302         });
69303         utilHighlightEntities(ids, false, context);
69304       });
69305       var labelsEnter = itemsEnter.append("div").attr("class", "issue-label");
69306       var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) {
69307         makeActiveIssue(d2.id);
69308         var extent = d2.extent(context.graph());
69309         if (extent) {
69310           var setZoom = Math.max(context.map().zoom(), 19);
69311           context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
69312         }
69313       });
69314       textEnter.each(function(d2) {
69315         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
69316         select_default2(this).call(svgIcon(iconName, "issue-icon"));
69317       });
69318       textEnter.append("span").attr("class", "issue-message");
69319       var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect"));
69320       infoButton.on("click", function(d3_event) {
69321         d3_event.stopPropagation();
69322         d3_event.preventDefault();
69323         this.blur();
69324         var container = select_default2(this.parentNode.parentNode.parentNode);
69325         var info = container.selectAll(".issue-info");
69326         var isExpanded = info.classed("expanded");
69327         _expanded = !isExpanded;
69328         corePreferences("entity-issues.reference.expanded", _expanded);
69329         if (isExpanded) {
69330           info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
69331             info.classed("expanded", false);
69332           });
69333         } else {
69334           info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() {
69335             info.style("max-height", null);
69336           });
69337         }
69338       });
69339       itemsEnter.append("ul").attr("class", "issue-fix-list");
69340       containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) {
69341         if (typeof d2.reference === "function") {
69342           select_default2(this).call(d2.reference);
69343         } else {
69344           select_default2(this).call(_t.append("inspector.no_documentation_key"));
69345         }
69346       });
69347       containers = containers.merge(containersEnter).classed("active", function(d2) {
69348         return d2.id === _activeIssueID;
69349       });
69350       containers.selectAll(".issue-message").text("").each(function(d2) {
69351         return d2.message(context)(select_default2(this));
69352       });
69353       var fixLists = containers.selectAll(".issue-fix-list");
69354       var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) {
69355         return d2.fixes ? d2.fixes(context) : [];
69356       }, function(fix) {
69357         return fix.id;
69358       });
69359       fixes.exit().remove();
69360       var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item");
69361       var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) {
69362         if (select_default2(this).attr("disabled") || !d2.onClick)
69363           return;
69364         if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3)
69365           return;
69366         d2.issue.dateLastRanFix = /* @__PURE__ */ new Date();
69367         utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context);
69368         new Promise(function(resolve, reject) {
69369           d2.onClick(context, resolve, reject);
69370           if (d2.onClick.length <= 1) {
69371             resolve();
69372           }
69373         }).then(function() {
69374           context.validator().validate();
69375         });
69376       }).on("mouseover.highlight", function(d3_event, d2) {
69377         utilHighlightEntities(d2.entityIds, true, context);
69378       }).on("mouseout.highlight", function(d3_event, d2) {
69379         utilHighlightEntities(d2.entityIds, false, context);
69380       });
69381       buttons.each(function(d2) {
69382         var iconName = d2.icon || "iD-icon-wrench";
69383         if (iconName.startsWith("maki")) {
69384           iconName += "-15";
69385         }
69386         select_default2(this).call(svgIcon("#" + iconName, "fix-icon"));
69387       });
69388       buttons.append("span").attr("class", "fix-message").each(function(d2) {
69389         return d2.title(select_default2(this));
69390       });
69391       fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) {
69392         return d2.onClick;
69393       }).attr("disabled", function(d2) {
69394         return d2.onClick ? null : "true";
69395       }).attr("title", function(d2) {
69396         if (d2.disabledReason) {
69397           return d2.disabledReason;
69398         }
69399         return null;
69400       });
69401     }
69402     section.entityIDs = function(val) {
69403       if (!arguments.length)
69404         return _entityIDs;
69405       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
69406         _entityIDs = val;
69407         _activeIssueID = null;
69408         reloadIssues();
69409       }
69410       return section;
69411     };
69412     return section;
69413   }
69414
69415   // modules/ui/preset_icon.js
69416   function uiPresetIcon() {
69417     let _preset;
69418     let _geometry;
69419     function presetIcon(selection2) {
69420       selection2.each(render);
69421     }
69422     function getIcon(p2, geom) {
69423       if (p2.isFallback && p2.isFallback())
69424         return geom === "vertex" ? "" : "iD-icon-" + p2.id;
69425       if (p2.icon)
69426         return p2.icon;
69427       if (geom === "line")
69428         return "iD-other-line";
69429       if (geom === "vertex")
69430         return "temaki-vertex";
69431       return "maki-marker-stroked";
69432     }
69433     function renderPointBorder(container, drawPoint) {
69434       let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []);
69435       pointBorder.exit().remove();
69436       let pointBorderEnter = pointBorder.enter();
69437       const w2 = 40;
69438       const h2 = 40;
69439       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");
69440       pointBorder = pointBorderEnter.merge(pointBorder);
69441     }
69442     function renderCategoryBorder(container, category) {
69443       let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []);
69444       categoryBorder.exit().remove();
69445       let categoryBorderEnter = categoryBorder.enter();
69446       const d2 = 60;
69447       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));
69448       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");
69449       categoryBorder = categoryBorderEnter.merge(categoryBorder);
69450       if (category) {
69451         categoryBorder.selectAll("path").attr("class", "area ".concat(category.id));
69452       }
69453     }
69454     function renderCircleFill(container, drawVertex) {
69455       let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []);
69456       vertexFill.exit().remove();
69457       let vertexFillEnter = vertexFill.enter();
69458       const w2 = 60;
69459       const h2 = 60;
69460       const d2 = 40;
69461       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);
69462       vertexFill = vertexFillEnter.merge(vertexFill);
69463     }
69464     function renderSquareFill(container, drawArea, tagClasses) {
69465       let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []);
69466       fill.exit().remove();
69467       let fillEnter = fill.enter();
69468       const d2 = 60;
69469       const w2 = d2;
69470       const h2 = d2;
69471       const l2 = d2 * 2 / 3;
69472       const c1 = (w2 - l2) / 2;
69473       const c2 = c1 + l2;
69474       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));
69475       ["fill", "stroke"].forEach((klass) => {
69476         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));
69477       });
69478       const rVertex = 2.5;
69479       [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point2) => {
69480         fillEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rVertex);
69481       });
69482       const rMidpoint = 1.25;
69483       [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point2) => {
69484         fillEnter.append("circle").attr("class", "midpoint").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rMidpoint);
69485       });
69486       fill = fillEnter.merge(fill);
69487       fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses));
69488       fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses));
69489     }
69490     function renderLine(container, drawLine, tagClasses) {
69491       let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []);
69492       line.exit().remove();
69493       let lineEnter = line.enter();
69494       const d2 = 60;
69495       const w2 = d2;
69496       const h2 = d2;
69497       const y2 = Math.round(d2 * 0.72);
69498       const l2 = Math.round(d2 * 0.6);
69499       const r2 = 2.5;
69500       const x12 = (w2 - l2) / 2;
69501       const x2 = x12 + l2;
69502       lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69503       ["casing", "stroke"].forEach((klass) => {
69504         lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass));
69505       });
69506       [[x12 - 1, y2], [x2 + 1, y2]].forEach((point2) => {
69507         lineEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69508       });
69509       line = lineEnter.merge(line);
69510       line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses));
69511       line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses));
69512     }
69513     function renderRoute(container, drawRoute, p2) {
69514       let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []);
69515       route.exit().remove();
69516       let routeEnter = route.enter();
69517       const d2 = 60;
69518       const w2 = d2;
69519       const h2 = d2;
69520       const y12 = Math.round(d2 * 0.8);
69521       const y2 = Math.round(d2 * 0.68);
69522       const l2 = Math.round(d2 * 0.6);
69523       const r2 = 2;
69524       const x12 = (w2 - l2) / 2;
69525       const x2 = x12 + l2 / 3;
69526       const x3 = x2 + l2 / 3;
69527       const x4 = x3 + l2 / 3;
69528       routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69529       ["casing", "stroke"].forEach((klass) => {
69530         routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass));
69531         routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass));
69532         routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass));
69533       });
69534       [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point2) => {
69535         routeEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69536       });
69537       route = routeEnter.merge(route);
69538       if (drawRoute) {
69539         let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route;
69540         const segmentPresetIDs = routeSegments[routeType];
69541         for (let i3 in segmentPresetIDs) {
69542           const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]);
69543           const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, "");
69544           route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses));
69545           route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses));
69546         }
69547       }
69548     }
69549     function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) {
69550       const isMaki = picon && /^maki-/.test(picon);
69551       const isTemaki = picon && /^temaki-/.test(picon);
69552       const isFa = picon && /^fa[srb]-/.test(picon);
69553       const isR\u00F6ntgen = picon && /^roentgen-/.test(picon);
69554       const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen);
69555       let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []);
69556       icon2.exit().remove();
69557       icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2);
69558       icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon);
69559       icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses));
69560       icon2.selectAll("use").attr("href", "#" + picon);
69561     }
69562     function renderImageIcon(container, imageURL) {
69563       let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []);
69564       imageIcon.exit().remove();
69565       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);
69566       imageIcon.attr("src", imageURL);
69567     }
69568     const routeSegments = {
69569       bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"],
69570       bus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69571       trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69572       detour: ["highway/tertiary", "highway/residential", "highway/unclassified"],
69573       ferry: ["route/ferry", "route/ferry", "route/ferry"],
69574       foot: ["highway/footway", "highway/footway", "highway/footway"],
69575       hiking: ["highway/path", "highway/path", "highway/path"],
69576       horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"],
69577       light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"],
69578       monorail: ["railway/monorail", "railway/monorail", "railway/monorail"],
69579       mtb: ["highway/path", "highway/track", "highway/bridleway"],
69580       pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"],
69581       piste: ["piste/downhill", "piste/hike", "piste/nordic"],
69582       power: ["power/line", "power/line", "power/line"],
69583       road: ["highway/secondary", "highway/primary", "highway/trunk"],
69584       subway: ["railway/subway", "railway/subway", "railway/subway"],
69585       train: ["railway/rail", "railway/rail", "railway/rail"],
69586       tram: ["railway/tram", "railway/tram", "railway/tram"],
69587       railway: ["railway/rail", "railway/rail", "railway/rail"],
69588       waterway: ["waterway/stream", "waterway/stream", "waterway/stream"]
69589     };
69590     function render() {
69591       let p2 = _preset.apply(this, arguments);
69592       let geom = _geometry ? _geometry.apply(this, arguments) : null;
69593       if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) {
69594         geom = "route";
69595       }
69596       const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
69597       const isFallback = p2.isFallback && p2.isFallback();
69598       const imageURL = showThirdPartyIcons === "true" && p2.imageURL;
69599       const picon = getIcon(p2, geom);
69600       const isCategory = !p2.setTags;
69601       const drawPoint = false;
69602       const drawVertex = picon !== null && geom === "vertex";
69603       const drawLine = picon && geom === "line" && !isFallback && !isCategory;
69604       const drawArea = picon && geom === "area" && !isFallback && !isCategory;
69605       const drawRoute = picon && geom === "route";
69606       const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory;
69607       let tags = !isCategory ? p2.setTags({}, geom) : {};
69608       for (let k2 in tags) {
69609         if (tags[k2] === "*") {
69610           tags[k2] = "yes";
69611         }
69612       }
69613       let tagClasses = svgTagClasses().getClassesString(tags, "");
69614       let selection2 = select_default2(this);
69615       let container = selection2.selectAll(".preset-icon-container").data([0]);
69616       container = container.enter().append("div").attr("class", "preset-icon-container").merge(container);
69617       container.classed("showing-img", !!imageURL).classed("fallback", isFallback);
69618       renderCategoryBorder(container, isCategory && p2);
69619       renderPointBorder(container, drawPoint);
69620       renderCircleFill(container, drawVertex);
69621       renderSquareFill(container, drawArea, tagClasses);
69622       renderLine(container, drawLine, tagClasses);
69623       renderRoute(container, drawRoute, p2);
69624       renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses);
69625       renderImageIcon(container, imageURL);
69626     }
69627     presetIcon.preset = function(val) {
69628       if (!arguments.length)
69629         return _preset;
69630       _preset = utilFunctor(val);
69631       return presetIcon;
69632     };
69633     presetIcon.geometry = function(val) {
69634       if (!arguments.length)
69635         return _geometry;
69636       _geometry = utilFunctor(val);
69637       return presetIcon;
69638     };
69639     return presetIcon;
69640   }
69641
69642   // modules/ui/sections/feature_type.js
69643   function uiSectionFeatureType(context) {
69644     var dispatch14 = dispatch_default("choose");
69645     var _entityIDs = [];
69646     var _presets = [];
69647     var _tagReference;
69648     var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent);
69649     function renderDisclosureContent(selection2) {
69650       selection2.classed("preset-list-item", true);
69651       selection2.classed("mixed-types", _presets.length > 1);
69652       var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap");
69653       var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call(
69654         uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom")
69655       );
69656       presetButton.append("div").attr("class", "preset-icon-container");
69657       presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner");
69658       presetButtonWrap.append("div").attr("class", "accessory-buttons");
69659       var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]);
69660       tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap);
69661       if (_tagReference) {
69662         selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button);
69663         tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body);
69664       }
69665       selection2.selectAll(".preset-reset").on("click", function() {
69666         dispatch14.call("choose", this, _presets);
69667       }).on("pointerdown pointerup mousedown mouseup", function(d3_event) {
69668         d3_event.preventDefault();
69669         d3_event.stopPropagation();
69670       });
69671       var geometries = entityGeometries();
69672       selection2.select(".preset-list-item button").call(
69673         uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point"))
69674       );
69675       var names = _presets.length === 1 ? [
69676         _presets[0].nameLabel(),
69677         _presets[0].subtitleLabel()
69678       ].filter(Boolean) : [_t.append("inspector.multiple_types")];
69679       var label = selection2.select(".label-inner");
69680       var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId);
69681       nameparts.exit().remove();
69682       nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) {
69683         d2(select_default2(this));
69684       });
69685     }
69686     section.entityIDs = function(val) {
69687       if (!arguments.length)
69688         return _entityIDs;
69689       _entityIDs = val;
69690       return section;
69691     };
69692     section.presets = function(val) {
69693       if (!arguments.length)
69694         return _presets;
69695       if (!utilArrayIdentical(val, _presets)) {
69696         _presets = val;
69697         if (_presets.length === 1) {
69698           _tagReference = uiTagReference(_presets[0].reference(), context).showing(false);
69699         }
69700       }
69701       return section;
69702     };
69703     function entityGeometries() {
69704       var counts = {};
69705       for (var i3 in _entityIDs) {
69706         var geometry = context.graph().geometry(_entityIDs[i3]);
69707         if (!counts[geometry])
69708           counts[geometry] = 0;
69709         counts[geometry] += 1;
69710       }
69711       return Object.keys(counts).sort(function(geom1, geom2) {
69712         return counts[geom2] - counts[geom1];
69713       });
69714     }
69715     return utilRebind(section, dispatch14, "on");
69716   }
69717
69718   // modules/ui/sections/preset_fields.js
69719   function uiSectionPresetFields(context) {
69720     var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
69721     var dispatch14 = dispatch_default("change", "revert");
69722     var formFields = uiFormFields(context);
69723     var _state;
69724     var _fieldsArr;
69725     var _presets = [];
69726     var _tags;
69727     var _entityIDs;
69728     function renderDisclosureContent(selection2) {
69729       if (!_fieldsArr) {
69730         var graph = context.graph();
69731         var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
69732           geoms[graph.entity(entityID).geometry(graph)] = true;
69733           return geoms;
69734         }, {}));
69735         const loc = _entityIDs.reduce(function(extent, entityID) {
69736           var entity = context.graph().entity(entityID);
69737           return extent.extend(entity.extent(context.graph()));
69738         }, geoExtent()).center();
69739         var presetsManager = _mainPresetIndex;
69740         var allFields = [];
69741         var allMoreFields = [];
69742         var sharedTotalFields;
69743         _presets.forEach(function(preset) {
69744           var fields = preset.fields(loc);
69745           var moreFields = preset.moreFields(loc);
69746           allFields = utilArrayUnion(allFields, fields);
69747           allMoreFields = utilArrayUnion(allMoreFields, moreFields);
69748           if (!sharedTotalFields) {
69749             sharedTotalFields = utilArrayUnion(fields, moreFields);
69750           } else {
69751             sharedTotalFields = sharedTotalFields.filter(function(field) {
69752               return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
69753             });
69754           }
69755         });
69756         var sharedFields = allFields.filter(function(field) {
69757           return sharedTotalFields.indexOf(field) !== -1;
69758         });
69759         var sharedMoreFields = allMoreFields.filter(function(field) {
69760           return sharedTotalFields.indexOf(field) !== -1;
69761         });
69762         _fieldsArr = [];
69763         sharedFields.forEach(function(field) {
69764           if (field.matchAllGeometry(geometries)) {
69765             _fieldsArr.push(
69766               uiField(context, field, _entityIDs)
69767             );
69768           }
69769         });
69770         var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
69771         if (singularEntity && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
69772           _fieldsArr.push(
69773             uiField(context, presetsManager.field("restrictions"), _entityIDs)
69774           );
69775         }
69776         var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
69777         additionalFields.sort(function(field1, field2) {
69778           return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
69779         });
69780         additionalFields.forEach(function(field) {
69781           if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
69782             _fieldsArr.push(
69783               uiField(context, field, _entityIDs, { show: false })
69784             );
69785           }
69786         });
69787         _fieldsArr.forEach(function(field) {
69788           field.on("change", function(t2, onInput) {
69789             dispatch14.call("change", field, _entityIDs, t2, onInput);
69790           }).on("revert", function(keys2) {
69791             dispatch14.call("revert", field, keys2);
69792           });
69793         });
69794       }
69795       _fieldsArr.forEach(function(field) {
69796         field.state(_state).tags(_tags);
69797       });
69798       selection2.call(
69799         formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
69800       );
69801     }
69802     section.presets = function(val) {
69803       if (!arguments.length)
69804         return _presets;
69805       if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
69806         _presets = val;
69807         _fieldsArr = null;
69808       }
69809       return section;
69810     };
69811     section.state = function(val) {
69812       if (!arguments.length)
69813         return _state;
69814       _state = val;
69815       return section;
69816     };
69817     section.tags = function(val) {
69818       if (!arguments.length)
69819         return _tags;
69820       _tags = val;
69821       return section;
69822     };
69823     section.entityIDs = function(val) {
69824       if (!arguments.length)
69825         return _entityIDs;
69826       if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
69827         _entityIDs = val;
69828         _fieldsArr = null;
69829       }
69830       return section;
69831     };
69832     return utilRebind(section, dispatch14, "on");
69833   }
69834
69835   // modules/ui/sections/raw_member_editor.js
69836   function uiSectionRawMemberEditor(context) {
69837     var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
69838       if (!_entityIDs || _entityIDs.length !== 1)
69839         return false;
69840       var entity = context.hasEntity(_entityIDs[0]);
69841       return entity && entity.type === "relation";
69842     }).label(function() {
69843       var entity = context.hasEntity(_entityIDs[0]);
69844       if (!entity)
69845         return "";
69846       var gt2 = entity.members.length > _maxMembers ? ">" : "";
69847       var count = gt2 + entity.members.slice(0, _maxMembers).length;
69848       return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
69849     }).disclosureContent(renderDisclosureContent);
69850     var taginfo = services.taginfo;
69851     var _entityIDs;
69852     var _maxMembers = 1e3;
69853     function downloadMember(d3_event, d2) {
69854       d3_event.preventDefault();
69855       select_default2(this.parentNode).classed("tag-reference-loading", true);
69856       context.loadEntity(d2.id, function() {
69857         section.reRender();
69858       });
69859     }
69860     function zoomToMember(d3_event, d2) {
69861       d3_event.preventDefault();
69862       var entity = context.entity(d2.id);
69863       context.map().zoomToEase(entity);
69864       utilHighlightEntities([d2.id], true, context);
69865     }
69866     function selectMember(d3_event, d2) {
69867       d3_event.preventDefault();
69868       utilHighlightEntities([d2.id], false, context);
69869       var entity = context.entity(d2.id);
69870       var mapExtent = context.map().extent();
69871       if (!entity.intersects(mapExtent, context.graph())) {
69872         context.map().zoomToEase(entity);
69873       }
69874       context.enter(modeSelect(context, [d2.id]));
69875     }
69876     function changeRole(d3_event, d2) {
69877       var oldRole = d2.role;
69878       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
69879       if (oldRole !== newRole) {
69880         var member = { id: d2.id, type: d2.type, role: newRole };
69881         context.perform(
69882           actionChangeMember(d2.relation.id, member, d2.index),
69883           _t("operations.change_role.annotation", {
69884             n: 1
69885           })
69886         );
69887         context.validator().validate();
69888       }
69889     }
69890     function deleteMember(d3_event, d2) {
69891       utilHighlightEntities([d2.id], false, context);
69892       context.perform(
69893         actionDeleteMember(d2.relation.id, d2.index),
69894         _t("operations.delete_member.annotation", {
69895           n: 1
69896         })
69897       );
69898       if (!context.hasEntity(d2.relation.id)) {
69899         context.enter(modeBrowse(context));
69900       } else {
69901         context.validator().validate();
69902       }
69903     }
69904     function renderDisclosureContent(selection2) {
69905       var entityID = _entityIDs[0];
69906       var memberships = [];
69907       var entity = context.entity(entityID);
69908       entity.members.slice(0, _maxMembers).forEach(function(member, index) {
69909         memberships.push({
69910           index,
69911           id: member.id,
69912           type: member.type,
69913           role: member.role,
69914           relation: entity,
69915           member: context.hasEntity(member.id),
69916           domId: utilUniqueDomId(entityID + "-member-" + index)
69917         });
69918       });
69919       var list2 = selection2.selectAll(".member-list").data([0]);
69920       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
69921       var items = list2.selectAll("li").data(memberships, function(d2) {
69922         return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
69923       });
69924       items.exit().each(unbind).remove();
69925       var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
69926         return !d2.member;
69927       });
69928       itemsEnter.each(function(d2) {
69929         var item = select_default2(this);
69930         var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
69931         if (d2.member) {
69932           item.on("mouseover", function() {
69933             utilHighlightEntities([d2.id], true, context);
69934           }).on("mouseout", function() {
69935             utilHighlightEntities([d2.id], false, context);
69936           });
69937           var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
69938           labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
69939             var matched = _mainPresetIndex.match(d4.member, context.graph());
69940             return matched && matched.name() || utilDisplayType(d4.member.id);
69941           });
69942           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) {
69943             return utilDisplayName(d4.member);
69944           });
69945           label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
69946           label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
69947         } else {
69948           var labelText = label.append("span").attr("class", "label-text");
69949           labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
69950           labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
69951           label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
69952         }
69953       });
69954       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
69955       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
69956         return d2.domId;
69957       }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
69958       if (taginfo) {
69959         wrapEnter.each(bindTypeahead);
69960       }
69961       items = items.merge(itemsEnter).order();
69962       items.select("input.member-role").property("value", function(d2) {
69963         return d2.role;
69964       }).on("blur", changeRole).on("change", changeRole);
69965       items.select("button.member-delete").on("click", deleteMember);
69966       var dragOrigin, targetIndex;
69967       items.call(
69968         drag_default().on("start", function(d3_event) {
69969           dragOrigin = {
69970             x: d3_event.x,
69971             y: d3_event.y
69972           };
69973           targetIndex = null;
69974         }).on("drag", function(d3_event) {
69975           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
69976           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
69977           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
69978             return;
69979           var index = items.nodes().indexOf(this);
69980           select_default2(this).classed("dragging", true);
69981           targetIndex = null;
69982           selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
69983             var node = select_default2(this).node();
69984             if (index === index2) {
69985               return "translate(" + x2 + "px, " + y2 + "px)";
69986             } else if (index2 > index && d3_event.y > node.offsetTop) {
69987               if (targetIndex === null || index2 > targetIndex) {
69988                 targetIndex = index2;
69989               }
69990               return "translateY(-100%)";
69991             } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
69992               if (targetIndex === null || index2 < targetIndex) {
69993                 targetIndex = index2;
69994               }
69995               return "translateY(100%)";
69996             }
69997             return null;
69998           });
69999         }).on("end", function(d3_event, d2) {
70000           if (!select_default2(this).classed("dragging"))
70001             return;
70002           var index = items.nodes().indexOf(this);
70003           select_default2(this).classed("dragging", false);
70004           selection2.selectAll("li.member-row").style("transform", null);
70005           if (targetIndex !== null) {
70006             context.perform(
70007               actionMoveMember(d2.relation.id, index, targetIndex),
70008               _t("operations.reorder_members.annotation")
70009             );
70010             context.validator().validate();
70011           }
70012         })
70013       );
70014       function bindTypeahead(d2) {
70015         var row = select_default2(this);
70016         var role = row.selectAll("input.member-role");
70017         var origValue = role.property("value");
70018         function sort(value, data) {
70019           var sameletter = [];
70020           var other = [];
70021           for (var i3 = 0; i3 < data.length; i3++) {
70022             if (data[i3].value.substring(0, value.length) === value) {
70023               sameletter.push(data[i3]);
70024             } else {
70025               other.push(data[i3]);
70026             }
70027           }
70028           return sameletter.concat(other);
70029         }
70030         role.call(
70031           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
70032             var geometry;
70033             if (d2.member) {
70034               geometry = context.graph().geometry(d2.member.id);
70035             } else if (d2.type === "relation") {
70036               geometry = "relation";
70037             } else if (d2.type === "way") {
70038               geometry = "line";
70039             } else {
70040               geometry = "point";
70041             }
70042             var rtype = entity.tags.type;
70043             taginfo.roles({
70044               debounce: true,
70045               rtype: rtype || "",
70046               geometry,
70047               query: role2
70048             }, function(err, data) {
70049               if (!err)
70050                 callback(sort(role2, data));
70051             });
70052           }).on("cancel", function() {
70053             role.property("value", origValue);
70054           })
70055         );
70056       }
70057       function unbind() {
70058         var row = select_default2(this);
70059         row.selectAll("input.member-role").call(uiCombobox.off, context);
70060       }
70061     }
70062     section.entityIDs = function(val) {
70063       if (!arguments.length)
70064         return _entityIDs;
70065       _entityIDs = val;
70066       return section;
70067     };
70068     return section;
70069   }
70070
70071   // modules/actions/delete_members.js
70072   function actionDeleteMembers(relationId, memberIndexes) {
70073     return function(graph) {
70074       memberIndexes.sort((a2, b2) => b2 - a2);
70075       for (var i3 in memberIndexes) {
70076         graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
70077       }
70078       return graph;
70079     };
70080   }
70081
70082   // modules/ui/sections/raw_membership_editor.js
70083   function uiSectionRawMembershipEditor(context) {
70084     var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
70085       return _entityIDs && _entityIDs.length;
70086     }).label(function() {
70087       var parents = getSharedParentRelations();
70088       var gt2 = parents.length > _maxMemberships ? ">" : "";
70089       var count = gt2 + parents.slice(0, _maxMemberships).length;
70090       return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
70091     }).disclosureContent(renderDisclosureContent);
70092     var taginfo = services.taginfo;
70093     var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
70094       if (d2.relation)
70095         utilHighlightEntities([d2.relation.id], true, context);
70096     }).itemsMouseLeave(function(d3_event, d2) {
70097       if (d2.relation)
70098         utilHighlightEntities([d2.relation.id], false, context);
70099     });
70100     var _inChange = false;
70101     var _entityIDs = [];
70102     var _showBlank;
70103     var _maxMemberships = 1e3;
70104     function getSharedParentRelations() {
70105       var parents = [];
70106       for (var i3 = 0; i3 < _entityIDs.length; i3++) {
70107         var entity = context.graph().hasEntity(_entityIDs[i3]);
70108         if (!entity)
70109           continue;
70110         if (i3 === 0) {
70111           parents = context.graph().parentRelations(entity);
70112         } else {
70113           parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
70114         }
70115         if (!parents.length)
70116           break;
70117       }
70118       return parents;
70119     }
70120     function getMemberships() {
70121       var memberships = [];
70122       var relations = getSharedParentRelations().slice(0, _maxMemberships);
70123       var isMultiselect = _entityIDs.length > 1;
70124       var i3, relation, membership, index, member, indexedMember;
70125       for (i3 = 0; i3 < relations.length; i3++) {
70126         relation = relations[i3];
70127         membership = {
70128           relation,
70129           members: [],
70130           hash: osmEntity.key(relation)
70131         };
70132         for (index = 0; index < relation.members.length; index++) {
70133           member = relation.members[index];
70134           if (_entityIDs.indexOf(member.id) !== -1) {
70135             indexedMember = Object.assign({}, member, { index });
70136             membership.members.push(indexedMember);
70137             membership.hash += "," + index.toString();
70138             if (!isMultiselect) {
70139               memberships.push(membership);
70140               membership = {
70141                 relation,
70142                 members: [],
70143                 hash: osmEntity.key(relation)
70144               };
70145             }
70146           }
70147         }
70148         if (membership.members.length)
70149           memberships.push(membership);
70150       }
70151       memberships.forEach(function(membership2) {
70152         membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
70153         var roles = [];
70154         membership2.members.forEach(function(member2) {
70155           if (roles.indexOf(member2.role) === -1)
70156             roles.push(member2.role);
70157         });
70158         membership2.role = roles.length === 1 ? roles[0] : roles;
70159       });
70160       return memberships;
70161     }
70162     function selectRelation(d3_event, d2) {
70163       d3_event.preventDefault();
70164       utilHighlightEntities([d2.relation.id], false, context);
70165       context.enter(modeSelect(context, [d2.relation.id]));
70166     }
70167     function zoomToRelation(d3_event, d2) {
70168       d3_event.preventDefault();
70169       var entity = context.entity(d2.relation.id);
70170       context.map().zoomToEase(entity);
70171       utilHighlightEntities([d2.relation.id], true, context);
70172     }
70173     function changeRole(d3_event, d2) {
70174       if (d2 === 0)
70175         return;
70176       if (_inChange)
70177         return;
70178       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
70179       if (!newRole.trim() && typeof d2.role !== "string")
70180         return;
70181       var membersToUpdate = d2.members.filter(function(member) {
70182         return member.role !== newRole;
70183       });
70184       if (membersToUpdate.length) {
70185         _inChange = true;
70186         context.perform(
70187           function actionChangeMemberRoles(graph) {
70188             membersToUpdate.forEach(function(member) {
70189               var newMember = Object.assign({}, member, { role: newRole });
70190               delete newMember.index;
70191               graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
70192             });
70193             return graph;
70194           },
70195           _t("operations.change_role.annotation", {
70196             n: membersToUpdate.length
70197           })
70198         );
70199         context.validator().validate();
70200       }
70201       _inChange = false;
70202     }
70203     function addMembership(d2, role) {
70204       this.blur();
70205       _showBlank = false;
70206       function actionAddMembers(relationId, ids, role2) {
70207         return function(graph) {
70208           for (var i3 in ids) {
70209             var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
70210             graph = actionAddMember(relationId, member)(graph);
70211           }
70212           return graph;
70213         };
70214       }
70215       if (d2.relation) {
70216         context.perform(
70217           actionAddMembers(d2.relation.id, _entityIDs, role),
70218           _t("operations.add_member.annotation", {
70219             n: _entityIDs.length
70220           })
70221         );
70222         context.validator().validate();
70223       } else {
70224         var relation = osmRelation();
70225         context.perform(
70226           actionAddEntity(relation),
70227           actionAddMembers(relation.id, _entityIDs, role),
70228           _t("operations.add.annotation.relation")
70229         );
70230         context.enter(modeSelect(context, [relation.id]).newFeature(true));
70231       }
70232     }
70233     function deleteMembership(d3_event, d2) {
70234       this.blur();
70235       if (d2 === 0)
70236         return;
70237       utilHighlightEntities([d2.relation.id], false, context);
70238       var indexes = d2.members.map(function(member) {
70239         return member.index;
70240       });
70241       context.perform(
70242         actionDeleteMembers(d2.relation.id, indexes),
70243         _t("operations.delete_member.annotation", {
70244           n: _entityIDs.length
70245         })
70246       );
70247       context.validator().validate();
70248     }
70249     function fetchNearbyRelations(q2, callback) {
70250       var newRelation = {
70251         relation: null,
70252         value: _t("inspector.new_relation"),
70253         display: _t.append("inspector.new_relation")
70254       };
70255       var entityID = _entityIDs[0];
70256       var result = [];
70257       var graph = context.graph();
70258       function baseDisplayValue(entity) {
70259         var matched = _mainPresetIndex.match(entity, graph);
70260         var presetName = matched && matched.name() || _t("inspector.relation");
70261         var entityName = utilDisplayName(entity) || "";
70262         return presetName + " " + entityName;
70263       }
70264       function baseDisplayLabel(entity) {
70265         var matched = _mainPresetIndex.match(entity, graph);
70266         var presetName = matched && matched.name() || _t("inspector.relation");
70267         var entityName = utilDisplayName(entity) || "";
70268         return (selection2) => {
70269           selection2.append("b").text(presetName + " ");
70270           selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
70271         };
70272       }
70273       var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
70274       if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
70275         result.push({
70276           relation: explicitRelation,
70277           value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
70278           display: baseDisplayLabel(explicitRelation)
70279         });
70280       } else {
70281         context.history().intersects(context.map().extent()).forEach(function(entity) {
70282           if (entity.type !== "relation" || entity.id === entityID)
70283             return;
70284           var value = baseDisplayValue(entity);
70285           if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1)
70286             return;
70287           result.push({
70288             relation: entity,
70289             value,
70290             display: baseDisplayLabel(entity)
70291           });
70292         });
70293         result.sort(function(a2, b2) {
70294           return osmRelation.creationOrder(a2.relation, b2.relation);
70295         });
70296         var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
70297           return v2.length > 1;
70298         });
70299         dupeGroups.forEach(function(group) {
70300           group.forEach(function(obj) {
70301             obj.value += " " + obj.relation.id;
70302           });
70303         });
70304       }
70305       result.forEach(function(obj) {
70306         obj.title = obj.value;
70307       });
70308       result.unshift(newRelation);
70309       callback(result);
70310     }
70311     function renderDisclosureContent(selection2) {
70312       var memberships = getMemberships();
70313       var list2 = selection2.selectAll(".member-list").data([0]);
70314       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
70315       var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
70316         return d2.hash;
70317       });
70318       items.exit().each(unbind).remove();
70319       var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
70320       itemsEnter.on("mouseover", function(d3_event, d2) {
70321         utilHighlightEntities([d2.relation.id], true, context);
70322       }).on("mouseout", function(d3_event, d2) {
70323         utilHighlightEntities([d2.relation.id], false, context);
70324       });
70325       var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
70326         return d2.domId;
70327       });
70328       var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
70329       labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
70330         var matched = _mainPresetIndex.match(d2.relation, context.graph());
70331         return matched && matched.name() || _t.html("inspector.relation");
70332       });
70333       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).text(function(d2) {
70334         return utilDisplayName(d2.relation);
70335       });
70336       labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
70337       labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
70338       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70339       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
70340         return d2.domId;
70341       }).property("type", "text").property("value", function(d2) {
70342         return typeof d2.role === "string" ? d2.role : "";
70343       }).attr("title", function(d2) {
70344         return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
70345       }).attr("placeholder", function(d2) {
70346         return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
70347       }).classed("mixed", function(d2) {
70348         return Array.isArray(d2.role);
70349       }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
70350       if (taginfo) {
70351         wrapEnter.each(bindTypeahead);
70352       }
70353       var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
70354       newMembership.exit().remove();
70355       var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
70356       var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
70357       newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
70358       newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
70359         list2.selectAll(".member-row-new").remove();
70360       });
70361       var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70362       newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
70363       newMembership = newMembership.merge(newMembershipEnter);
70364       newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
70365         nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity)
70366       );
70367       var addRow = selection2.selectAll(".add-row").data([0]);
70368       var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
70369       var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
70370       addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
70371       addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
70372       addRowEnter.append("div").attr("class", "space-value");
70373       addRowEnter.append("div").attr("class", "space-buttons");
70374       addRow = addRow.merge(addRowEnter);
70375       addRow.select(".add-relation").on("click", function() {
70376         _showBlank = true;
70377         section.reRender();
70378         list2.selectAll(".member-entity-input").node().focus();
70379       });
70380       function acceptEntity(d2) {
70381         if (!d2) {
70382           cancelEntity();
70383           return;
70384         }
70385         if (d2.relation)
70386           utilHighlightEntities([d2.relation.id], false, context);
70387         var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
70388         addMembership(d2, role);
70389       }
70390       function cancelEntity() {
70391         var input = newMembership.selectAll(".member-entity-input");
70392         input.property("value", "");
70393         context.surface().selectAll(".highlighted").classed("highlighted", false);
70394       }
70395       function bindTypeahead(d2) {
70396         var row = select_default2(this);
70397         var role = row.selectAll("input.member-role");
70398         var origValue = role.property("value");
70399         function sort(value, data) {
70400           var sameletter = [];
70401           var other = [];
70402           for (var i3 = 0; i3 < data.length; i3++) {
70403             if (data[i3].value.substring(0, value.length) === value) {
70404               sameletter.push(data[i3]);
70405             } else {
70406               other.push(data[i3]);
70407             }
70408           }
70409           return sameletter.concat(other);
70410         }
70411         role.call(
70412           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
70413             var rtype = d2.relation.tags.type;
70414             taginfo.roles({
70415               debounce: true,
70416               rtype: rtype || "",
70417               geometry: context.graph().geometry(_entityIDs[0]),
70418               query: role2
70419             }, function(err, data) {
70420               if (!err)
70421                 callback(sort(role2, data));
70422             });
70423           }).on("cancel", function() {
70424             role.property("value", origValue);
70425           })
70426         );
70427       }
70428       function unbind() {
70429         var row = select_default2(this);
70430         row.selectAll("input.member-role").call(uiCombobox.off, context);
70431       }
70432     }
70433     section.entityIDs = function(val) {
70434       if (!arguments.length)
70435         return _entityIDs;
70436       _entityIDs = val;
70437       _showBlank = false;
70438       return section;
70439     };
70440     return section;
70441   }
70442
70443   // modules/ui/sections/selection_list.js
70444   function uiSectionSelectionList(context) {
70445     var _selectedIDs = [];
70446     var section = uiSection("selected-features", context).shouldDisplay(function() {
70447       return _selectedIDs.length > 1;
70448     }).label(function() {
70449       return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
70450     }).disclosureContent(renderDisclosureContent);
70451     context.history().on("change.selectionList", function(difference2) {
70452       if (difference2) {
70453         section.reRender();
70454       }
70455     });
70456     section.entityIDs = function(val) {
70457       if (!arguments.length)
70458         return _selectedIDs;
70459       _selectedIDs = val;
70460       return section;
70461     };
70462     function selectEntity(d3_event, entity) {
70463       context.enter(modeSelect(context, [entity.id]));
70464     }
70465     function deselectEntity(d3_event, entity) {
70466       var selectedIDs = _selectedIDs.slice();
70467       var index = selectedIDs.indexOf(entity.id);
70468       if (index > -1) {
70469         selectedIDs.splice(index, 1);
70470         context.enter(modeSelect(context, selectedIDs));
70471       }
70472     }
70473     function renderDisclosureContent(selection2) {
70474       var list2 = selection2.selectAll(".feature-list").data([0]);
70475       list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
70476       var entities = _selectedIDs.map(function(id2) {
70477         return context.hasEntity(id2);
70478       }).filter(Boolean);
70479       var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
70480       items.exit().remove();
70481       var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
70482         select_default2(this).on("mouseover", function() {
70483           utilHighlightEntities([d2.id], true, context);
70484         }).on("mouseout", function() {
70485           utilHighlightEntities([d2.id], false, context);
70486         });
70487       });
70488       var label = enter.append("button").attr("class", "label").on("click", selectEntity);
70489       label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
70490       label.append("span").attr("class", "entity-type");
70491       label.append("span").attr("class", "entity-name");
70492       enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
70493       items = items.merge(enter);
70494       items.selectAll(".entity-geom-icon use").attr("href", function() {
70495         var entity = this.parentNode.parentNode.__data__;
70496         return "#iD-icon-" + entity.geometry(context.graph());
70497       });
70498       items.selectAll(".entity-type").text(function(entity) {
70499         return _mainPresetIndex.match(entity, context.graph()).name();
70500       });
70501       items.selectAll(".entity-name").text(function(d2) {
70502         var entity = context.entity(d2.id);
70503         return utilDisplayName(entity);
70504       });
70505     }
70506     return section;
70507   }
70508
70509   // modules/ui/entity_editor.js
70510   function uiEntityEditor(context) {
70511     var dispatch14 = dispatch_default("choose");
70512     var _state = "select";
70513     var _coalesceChanges = false;
70514     var _modified = false;
70515     var _base;
70516     var _entityIDs;
70517     var _activePresets = [];
70518     var _newFeature;
70519     var _sections;
70520     function entityEditor(selection2) {
70521       var combinedTags = utilCombinedTags(_entityIDs, context.graph());
70522       var header = selection2.selectAll(".header").data([0]);
70523       var headerEnter = header.enter().append("div").attr("class", "header fillL");
70524       var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
70525       headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
70526       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
70527         context.enter(modeBrowse(context));
70528       }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
70529       headerEnter.append("h2");
70530       header = header.merge(headerEnter);
70531       header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
70532       header.selectAll(".preset-reset").on("click", function() {
70533         dispatch14.call("choose", this, _activePresets);
70534       });
70535       var body = selection2.selectAll(".inspector-body").data([0]);
70536       var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
70537       body = body.merge(bodyEnter);
70538       if (!_sections) {
70539         _sections = [
70540           uiSectionSelectionList(context),
70541           uiSectionFeatureType(context).on("choose", function(presets) {
70542             dispatch14.call("choose", this, presets);
70543           }),
70544           uiSectionEntityIssues(context),
70545           uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
70546           uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
70547           uiSectionRawMemberEditor(context),
70548           uiSectionRawMembershipEditor(context)
70549         ];
70550       }
70551       _sections.forEach(function(section) {
70552         if (section.entityIDs) {
70553           section.entityIDs(_entityIDs);
70554         }
70555         if (section.presets) {
70556           section.presets(_activePresets);
70557         }
70558         if (section.tags) {
70559           section.tags(combinedTags);
70560         }
70561         if (section.state) {
70562           section.state(_state);
70563         }
70564         body.call(section.render);
70565       });
70566       context.history().on("change.entity-editor", historyChanged);
70567       function historyChanged(difference2) {
70568         if (selection2.selectAll(".entity-editor").empty())
70569           return;
70570         if (_state === "hide")
70571           return;
70572         var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
70573         if (!significant)
70574           return;
70575         _entityIDs = _entityIDs.filter(context.hasEntity);
70576         if (!_entityIDs.length)
70577           return;
70578         var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
70579         loadActivePresets();
70580         var graph = context.graph();
70581         entityEditor.modified(_base !== graph);
70582         entityEditor(selection2);
70583         if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
70584           context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
70585         }
70586       }
70587     }
70588     function changeTags(entityIDs, changed, onInput) {
70589       var actions = [];
70590       for (var i3 in entityIDs) {
70591         var entityID = entityIDs[i3];
70592         var entity = context.entity(entityID);
70593         var tags = Object.assign({}, entity.tags);
70594         if (typeof changed === "function") {
70595           tags = changed(tags);
70596         } else {
70597           for (var k2 in changed) {
70598             if (!k2)
70599               continue;
70600             var v2 = changed[k2];
70601             if (typeof v2 === "object") {
70602               tags[k2] = tags[v2.oldKey];
70603             } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70604               tags[k2] = v2;
70605             }
70606           }
70607         }
70608         if (!onInput) {
70609           tags = utilCleanTags(tags);
70610         }
70611         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70612           actions.push(actionChangeTags(entityID, tags));
70613         }
70614       }
70615       if (actions.length) {
70616         var combinedAction = function(graph) {
70617           actions.forEach(function(action) {
70618             graph = action(graph);
70619           });
70620           return graph;
70621         };
70622         var annotation = _t("operations.change_tags.annotation");
70623         if (_coalesceChanges) {
70624           context.overwrite(combinedAction, annotation);
70625         } else {
70626           context.perform(combinedAction, annotation);
70627           _coalesceChanges = !!onInput;
70628         }
70629       }
70630       if (!onInput) {
70631         context.validator().validate();
70632       }
70633     }
70634     function revertTags(keys2) {
70635       var actions = [];
70636       for (var i3 in _entityIDs) {
70637         var entityID = _entityIDs[i3];
70638         var original = context.graph().base().entities[entityID];
70639         var changed = {};
70640         for (var j2 in keys2) {
70641           var key = keys2[j2];
70642           changed[key] = original ? original.tags[key] : void 0;
70643         }
70644         var entity = context.entity(entityID);
70645         var tags = Object.assign({}, entity.tags);
70646         for (var k2 in changed) {
70647           if (!k2)
70648             continue;
70649           var v2 = changed[k2];
70650           if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70651             tags[k2] = v2;
70652           }
70653         }
70654         tags = utilCleanTags(tags);
70655         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70656           actions.push(actionChangeTags(entityID, tags));
70657         }
70658       }
70659       if (actions.length) {
70660         var combinedAction = function(graph) {
70661           actions.forEach(function(action) {
70662             graph = action(graph);
70663           });
70664           return graph;
70665         };
70666         var annotation = _t("operations.change_tags.annotation");
70667         if (_coalesceChanges) {
70668           context.overwrite(combinedAction, annotation);
70669         } else {
70670           context.perform(combinedAction, annotation);
70671           _coalesceChanges = false;
70672         }
70673       }
70674       context.validator().validate();
70675     }
70676     entityEditor.modified = function(val) {
70677       if (!arguments.length)
70678         return _modified;
70679       _modified = val;
70680       return entityEditor;
70681     };
70682     entityEditor.state = function(val) {
70683       if (!arguments.length)
70684         return _state;
70685       _state = val;
70686       return entityEditor;
70687     };
70688     entityEditor.entityIDs = function(val) {
70689       if (!arguments.length)
70690         return _entityIDs;
70691       _base = context.graph();
70692       _coalesceChanges = false;
70693       if (val && _entityIDs && utilArrayIdentical(_entityIDs, val))
70694         return entityEditor;
70695       _entityIDs = val;
70696       loadActivePresets(true);
70697       return entityEditor.modified(false);
70698     };
70699     entityEditor.newFeature = function(val) {
70700       if (!arguments.length)
70701         return _newFeature;
70702       _newFeature = val;
70703       return entityEditor;
70704     };
70705     function loadActivePresets(isForNewSelection) {
70706       var graph = context.graph();
70707       var counts = {};
70708       for (var i3 in _entityIDs) {
70709         var entity = graph.hasEntity(_entityIDs[i3]);
70710         if (!entity)
70711           return;
70712         var match = _mainPresetIndex.match(entity, graph);
70713         if (!counts[match.id])
70714           counts[match.id] = 0;
70715         counts[match.id] += 1;
70716       }
70717       var matches = Object.keys(counts).sort(function(p1, p2) {
70718         return counts[p2] - counts[p1];
70719       }).map(function(pID) {
70720         return _mainPresetIndex.item(pID);
70721       });
70722       if (!isForNewSelection) {
70723         var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
70724         if (weakPreset && matches.length === 1 && matches[0].isFallback())
70725           return;
70726       }
70727       entityEditor.presets(matches);
70728     }
70729     entityEditor.presets = function(val) {
70730       if (!arguments.length)
70731         return _activePresets;
70732       if (!utilArrayIdentical(val, _activePresets)) {
70733         _activePresets = val;
70734       }
70735       return entityEditor;
70736     };
70737     return utilRebind(entityEditor, dispatch14, "on");
70738   }
70739
70740   // modules/ui/feature_list.js
70741   var sexagesimal = __toESM(require_sexagesimal());
70742
70743   // modules/modes/draw_area.js
70744   function modeDrawArea(context, wayID, startGraph, button) {
70745     var mode = {
70746       button,
70747       id: "draw-area"
70748     };
70749     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
70750       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
70751     });
70752     mode.wayID = wayID;
70753     mode.enter = function() {
70754       context.install(behavior);
70755     };
70756     mode.exit = function() {
70757       context.uninstall(behavior);
70758     };
70759     mode.selectedIDs = function() {
70760       return [wayID];
70761     };
70762     mode.activeID = function() {
70763       return behavior && behavior.activeID() || [];
70764     };
70765     return mode;
70766   }
70767
70768   // modules/modes/add_area.js
70769   function modeAddArea(context, mode) {
70770     mode.id = "add-area";
70771     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70772     function defaultTags(loc) {
70773       var defaultTags2 = { area: "yes" };
70774       if (mode.preset)
70775         defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
70776       return defaultTags2;
70777     }
70778     function actionClose(wayId) {
70779       return function(graph) {
70780         return graph.replace(graph.entity(wayId).close());
70781       };
70782     }
70783     function start2(loc) {
70784       var startGraph = context.graph();
70785       var node = osmNode({ loc });
70786       var way = osmWay({ tags: defaultTags(loc) });
70787       context.perform(
70788         actionAddEntity(node),
70789         actionAddEntity(way),
70790         actionAddVertex(way.id, node.id),
70791         actionClose(way.id)
70792       );
70793       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70794     }
70795     function startFromWay(loc, edge) {
70796       var startGraph = context.graph();
70797       var node = osmNode({ loc });
70798       var way = osmWay({ tags: defaultTags(loc) });
70799       context.perform(
70800         actionAddEntity(node),
70801         actionAddEntity(way),
70802         actionAddVertex(way.id, node.id),
70803         actionClose(way.id),
70804         actionAddMidpoint({ loc, edge }, node)
70805       );
70806       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70807     }
70808     function startFromNode(node) {
70809       var startGraph = context.graph();
70810       var way = osmWay({ tags: defaultTags(node.loc) });
70811       context.perform(
70812         actionAddEntity(way),
70813         actionAddVertex(way.id, node.id),
70814         actionClose(way.id)
70815       );
70816       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70817     }
70818     mode.enter = function() {
70819       context.install(behavior);
70820     };
70821     mode.exit = function() {
70822       context.uninstall(behavior);
70823     };
70824     return mode;
70825   }
70826
70827   // modules/modes/add_line.js
70828   function modeAddLine(context, mode) {
70829     mode.id = "add-line";
70830     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70831     function defaultTags(loc) {
70832       var defaultTags2 = {};
70833       if (mode.preset)
70834         defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
70835       return defaultTags2;
70836     }
70837     function start2(loc) {
70838       var startGraph = context.graph();
70839       var node = osmNode({ loc });
70840       var way = osmWay({ tags: defaultTags(loc) });
70841       context.perform(
70842         actionAddEntity(node),
70843         actionAddEntity(way),
70844         actionAddVertex(way.id, node.id)
70845       );
70846       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70847     }
70848     function startFromWay(loc, edge) {
70849       var startGraph = context.graph();
70850       var node = osmNode({ loc });
70851       var way = osmWay({ tags: defaultTags(loc) });
70852       context.perform(
70853         actionAddEntity(node),
70854         actionAddEntity(way),
70855         actionAddVertex(way.id, node.id),
70856         actionAddMidpoint({ loc, edge }, node)
70857       );
70858       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70859     }
70860     function startFromNode(node) {
70861       var startGraph = context.graph();
70862       var way = osmWay({ tags: defaultTags(node.loc) });
70863       context.perform(
70864         actionAddEntity(way),
70865         actionAddVertex(way.id, node.id)
70866       );
70867       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70868     }
70869     mode.enter = function() {
70870       context.install(behavior);
70871     };
70872     mode.exit = function() {
70873       context.uninstall(behavior);
70874     };
70875     return mode;
70876   }
70877
70878   // modules/modes/add_point.js
70879   function modeAddPoint(context, mode) {
70880     mode.id = "add-point";
70881     var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
70882     function defaultTags(loc) {
70883       var defaultTags2 = {};
70884       if (mode.preset)
70885         defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
70886       return defaultTags2;
70887     }
70888     function add(loc) {
70889       var node = osmNode({ loc, tags: defaultTags(loc) });
70890       context.perform(
70891         actionAddEntity(node),
70892         _t("operations.add.annotation.point")
70893       );
70894       enterSelectMode(node);
70895     }
70896     function addWay(loc, edge) {
70897       var node = osmNode({ tags: defaultTags(loc) });
70898       context.perform(
70899         actionAddMidpoint({ loc, edge }, node),
70900         _t("operations.add.annotation.vertex")
70901       );
70902       enterSelectMode(node);
70903     }
70904     function enterSelectMode(node) {
70905       context.enter(
70906         modeSelect(context, [node.id]).newFeature(true)
70907       );
70908     }
70909     function addNode(node) {
70910       const _defaultTags = defaultTags(node.loc);
70911       if (Object.keys(_defaultTags).length === 0) {
70912         enterSelectMode(node);
70913         return;
70914       }
70915       var tags = Object.assign({}, node.tags);
70916       for (var key in _defaultTags) {
70917         tags[key] = _defaultTags[key];
70918       }
70919       context.perform(
70920         actionChangeTags(node.id, tags),
70921         _t("operations.add.annotation.point")
70922       );
70923       enterSelectMode(node);
70924     }
70925     function cancel() {
70926       context.enter(modeBrowse(context));
70927     }
70928     mode.enter = function() {
70929       context.install(behavior);
70930     };
70931     mode.exit = function() {
70932       context.uninstall(behavior);
70933     };
70934     return mode;
70935   }
70936
70937   // modules/ui/note_comments.js
70938   function uiNoteComments() {
70939     var _note;
70940     function noteComments(selection2) {
70941       if (_note.isNew())
70942         return;
70943       var comments = selection2.selectAll(".comments-container").data([0]);
70944       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
70945       var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
70946       commentEnter.append("div").attr("class", function(d2) {
70947         return "comment-avatar user-" + d2.uid;
70948       }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
70949       var mainEnter = commentEnter.append("div").attr("class", "comment-main");
70950       var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
70951       metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
70952         var selection3 = select_default2(this);
70953         var osm = services.osm;
70954         if (osm && d2.user) {
70955           selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
70956         }
70957         if (d2.user) {
70958           selection3.text(d2.user);
70959         } else {
70960           selection3.call(_t.append("note.anonymous"));
70961         }
70962       });
70963       metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
70964         return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
70965       });
70966       mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
70967         return d2.html;
70968       }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
70969       comments.call(replaceAvatars);
70970     }
70971     function replaceAvatars(selection2) {
70972       var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
70973       var osm = services.osm;
70974       if (showThirdPartyIcons !== "true" || !osm)
70975         return;
70976       var uids = {};
70977       _note.comments.forEach(function(d2) {
70978         if (d2.uid)
70979           uids[d2.uid] = true;
70980       });
70981       Object.keys(uids).forEach(function(uid) {
70982         osm.loadUser(uid, function(err, user) {
70983           if (!user || !user.image_url)
70984             return;
70985           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);
70986         });
70987       });
70988     }
70989     function localeDateString2(s2) {
70990       if (!s2)
70991         return null;
70992       var options2 = { day: "numeric", month: "short", year: "numeric" };
70993       s2 = s2.replace(/-/g, "/");
70994       var d2 = new Date(s2);
70995       if (isNaN(d2.getTime()))
70996         return null;
70997       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
70998     }
70999     noteComments.note = function(val) {
71000       if (!arguments.length)
71001         return _note;
71002       _note = val;
71003       return noteComments;
71004     };
71005     return noteComments;
71006   }
71007
71008   // modules/ui/note_header.js
71009   function uiNoteHeader() {
71010     var _note;
71011     function noteHeader(selection2) {
71012       var header = selection2.selectAll(".note-header").data(
71013         _note ? [_note] : [],
71014         function(d2) {
71015           return d2.status + d2.id;
71016         }
71017       );
71018       header.exit().remove();
71019       var headerEnter = header.enter().append("div").attr("class", "note-header");
71020       var iconEnter = headerEnter.append("div").attr("class", function(d2) {
71021         return "note-header-icon " + d2.status;
71022       }).classed("new", function(d2) {
71023         return d2.id < 0;
71024       });
71025       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
71026       iconEnter.each(function(d2) {
71027         var statusIcon;
71028         if (d2.id < 0) {
71029           statusIcon = "#iD-icon-plus";
71030         } else if (d2.status === "open") {
71031           statusIcon = "#iD-icon-close";
71032         } else {
71033           statusIcon = "#iD-icon-apply";
71034         }
71035         iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
71036       });
71037       headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
71038         if (_note.isNew()) {
71039           return _t.html("note.new");
71040         }
71041         return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
71042       });
71043     }
71044     noteHeader.note = function(val) {
71045       if (!arguments.length)
71046         return _note;
71047       _note = val;
71048       return noteHeader;
71049     };
71050     return noteHeader;
71051   }
71052
71053   // modules/ui/note_report.js
71054   function uiNoteReport() {
71055     var _note;
71056     function noteReport(selection2) {
71057       var url;
71058       if (services.osm && _note instanceof osmNote && !_note.isNew()) {
71059         url = services.osm.noteReportURL(_note);
71060       }
71061       var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
71062       link3.exit().remove();
71063       var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
71064         return d2;
71065       }).call(svgIcon("#iD-icon-out-link", "inline"));
71066       linkEnter.append("span").call(_t.append("note.report"));
71067     }
71068     noteReport.note = function(val) {
71069       if (!arguments.length)
71070         return _note;
71071       _note = val;
71072       return noteReport;
71073     };
71074     return noteReport;
71075   }
71076
71077   // modules/ui/view_on_osm.js
71078   function uiViewOnOSM(context) {
71079     var _what;
71080     function viewOnOSM(selection2) {
71081       var url;
71082       if (_what instanceof osmEntity) {
71083         url = context.connection().entityURL(_what);
71084       } else if (_what instanceof osmNote) {
71085         url = context.connection().noteURL(_what);
71086       }
71087       var data = !_what || _what.isNew() ? [] : [_what];
71088       var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
71089         return d2.id;
71090       });
71091       link3.exit().remove();
71092       var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
71093       linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
71094     }
71095     viewOnOSM.what = function(_2) {
71096       if (!arguments.length)
71097         return _what;
71098       _what = _2;
71099       return viewOnOSM;
71100     };
71101     return viewOnOSM;
71102   }
71103
71104   // modules/ui/note_editor.js
71105   function uiNoteEditor(context) {
71106     var dispatch14 = dispatch_default("change");
71107     var noteComments = uiNoteComments(context);
71108     var noteHeader = uiNoteHeader();
71109     var _note;
71110     var _newNote;
71111     function noteEditor(selection2) {
71112       var header = selection2.selectAll(".header").data([0]);
71113       var headerEnter = header.enter().append("div").attr("class", "header fillL");
71114       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
71115         context.enter(modeBrowse(context));
71116       }).call(svgIcon("#iD-icon-close"));
71117       headerEnter.append("h2").call(_t.append("note.title"));
71118       var body = selection2.selectAll(".body").data([0]);
71119       body = body.enter().append("div").attr("class", "body").merge(body);
71120       var editor = body.selectAll(".note-editor").data([0]);
71121       editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
71122       var footer = selection2.selectAll(".footer").data([0]);
71123       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
71124       var osm = services.osm;
71125       if (osm) {
71126         osm.on("change.note-save", function() {
71127           selection2.call(noteEditor);
71128         });
71129       }
71130     }
71131     function noteSaveSection(selection2) {
71132       var isSelected = _note && _note.id === context.selectedNoteID();
71133       var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
71134         return d2.status + d2.id;
71135       });
71136       noteSave.exit().remove();
71137       var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
71138       noteSaveEnter.append("h4").attr("class", ".note-save-header").html(function() {
71139         return _note.isNew() ? _t.html("note.newDescription") : _t.html("note.newComment");
71140       });
71141       var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
71142         return d2.newComment;
71143       }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
71144       if (!commentTextarea.empty() && _newNote) {
71145         commentTextarea.node().focus();
71146       }
71147       noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
71148       function keydown(d3_event) {
71149         if (!(d3_event.keyCode === 13 && // ↩ Return
71150         d3_event.metaKey))
71151           return;
71152         var osm = services.osm;
71153         if (!osm)
71154           return;
71155         var hasAuth = osm.authenticated();
71156         if (!hasAuth)
71157           return;
71158         if (!_note.newComment)
71159           return;
71160         d3_event.preventDefault();
71161         select_default2(this).on("keydown.note-input", null);
71162         window.setTimeout(function() {
71163           if (_note.isNew()) {
71164             noteSave.selectAll(".save-button").node().focus();
71165             clickSave(_note);
71166           } else {
71167             noteSave.selectAll(".comment-button").node().focus();
71168             clickComment(_note);
71169           }
71170         }, 10);
71171       }
71172       function changeInput() {
71173         var input = select_default2(this);
71174         var val = input.property("value").trim() || void 0;
71175         _note = _note.update({ newComment: val });
71176         var osm = services.osm;
71177         if (osm) {
71178           osm.replaceNote(_note);
71179         }
71180         noteSave.call(noteSaveButtons);
71181       }
71182     }
71183     function userDetails(selection2) {
71184       var detailSection = selection2.selectAll(".detail-section").data([0]);
71185       detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
71186       var osm = services.osm;
71187       if (!osm)
71188         return;
71189       var hasAuth = osm.authenticated();
71190       var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
71191       authWarning.exit().transition().duration(200).style("opacity", 0).remove();
71192       var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
71193       authEnter.call(svgIcon("#iD-icon-alert", "inline"));
71194       authEnter.append("span").call(_t.append("note.login"));
71195       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) {
71196         d3_event.preventDefault();
71197         osm.authenticate();
71198       });
71199       authEnter.transition().duration(200).style("opacity", 1);
71200       var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
71201       prose.exit().remove();
71202       prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
71203       osm.userDetails(function(err, user) {
71204         if (err)
71205           return;
71206         var userLink = select_default2(document.createElement("div"));
71207         if (user.image_url) {
71208           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
71209         }
71210         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
71211         prose.html(_t.html("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
71212       });
71213     }
71214     function noteSaveButtons(selection2) {
71215       var osm = services.osm;
71216       var hasAuth = osm && osm.authenticated();
71217       var isSelected = _note && _note.id === context.selectedNoteID();
71218       var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
71219         return d2.status + d2.id;
71220       });
71221       buttonSection.exit().remove();
71222       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
71223       if (_note.isNew()) {
71224         buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
71225         buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
71226       } else {
71227         buttonEnter.append("button").attr("class", "button status-button action");
71228         buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
71229       }
71230       buttonSection = buttonSection.merge(buttonEnter);
71231       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
71232       buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
71233       buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).html(function(d2) {
71234         var action = d2.status === "open" ? "close" : "open";
71235         var andComment = d2.newComment ? "_comment" : "";
71236         return _t.html("note." + action + andComment);
71237       }).on("click.status", clickStatus);
71238       buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
71239       function isSaveDisabled(d2) {
71240         return hasAuth && d2.status === "open" && d2.newComment ? null : true;
71241       }
71242     }
71243     function clickCancel(d3_event, d2) {
71244       this.blur();
71245       var osm = services.osm;
71246       if (osm) {
71247         osm.removeNote(d2);
71248       }
71249       context.enter(modeBrowse(context));
71250       dispatch14.call("change");
71251     }
71252     function clickSave(d3_event, d2) {
71253       this.blur();
71254       var osm = services.osm;
71255       if (osm) {
71256         osm.postNoteCreate(d2, function(err, note) {
71257           dispatch14.call("change", note);
71258         });
71259       }
71260     }
71261     function clickStatus(d3_event, d2) {
71262       this.blur();
71263       var osm = services.osm;
71264       if (osm) {
71265         var setStatus = d2.status === "open" ? "closed" : "open";
71266         osm.postNoteUpdate(d2, setStatus, function(err, note) {
71267           dispatch14.call("change", note);
71268         });
71269       }
71270     }
71271     function clickComment(d3_event, d2) {
71272       this.blur();
71273       var osm = services.osm;
71274       if (osm) {
71275         osm.postNoteUpdate(d2, d2.status, function(err, note) {
71276           dispatch14.call("change", note);
71277         });
71278       }
71279     }
71280     noteEditor.note = function(val) {
71281       if (!arguments.length)
71282         return _note;
71283       _note = val;
71284       return noteEditor;
71285     };
71286     noteEditor.newNote = function(val) {
71287       if (!arguments.length)
71288         return _newNote;
71289       _newNote = val;
71290       return noteEditor;
71291     };
71292     return utilRebind(noteEditor, dispatch14, "on");
71293   }
71294
71295   // modules/modes/select_note.js
71296   function modeSelectNote(context, selectedNoteID) {
71297     var mode = {
71298       id: "select-note",
71299       button: "browse"
71300     };
71301     var _keybinding = utilKeybinding("select-note");
71302     var _noteEditor = uiNoteEditor(context).on("change", function() {
71303       context.map().pan([0, 0]);
71304       var note = checkSelectedID();
71305       if (!note)
71306         return;
71307       context.ui().sidebar.show(_noteEditor.note(note));
71308     });
71309     var _behaviors = [
71310       behaviorBreathe(context),
71311       behaviorHover(context),
71312       behaviorSelect(context),
71313       behaviorLasso(context),
71314       modeDragNode(context).behavior,
71315       modeDragNote(context).behavior
71316     ];
71317     var _newFeature = false;
71318     function checkSelectedID() {
71319       if (!services.osm)
71320         return;
71321       var note = services.osm.getNote(selectedNoteID);
71322       if (!note) {
71323         context.enter(modeBrowse(context));
71324       }
71325       return note;
71326     }
71327     function selectNote(d3_event, drawn) {
71328       if (!checkSelectedID())
71329         return;
71330       var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
71331       if (selection2.empty()) {
71332         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
71333         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
71334           context.enter(modeBrowse(context));
71335         }
71336       } else {
71337         selection2.classed("selected", true);
71338         context.selectedNoteID(selectedNoteID);
71339       }
71340     }
71341     function esc() {
71342       if (context.container().select(".combobox").size())
71343         return;
71344       context.enter(modeBrowse(context));
71345     }
71346     mode.zoomToSelected = function() {
71347       if (!services.osm)
71348         return;
71349       var note = services.osm.getNote(selectedNoteID);
71350       if (note) {
71351         context.map().centerZoomEase(note.loc, 20);
71352       }
71353     };
71354     mode.newFeature = function(val) {
71355       if (!arguments.length)
71356         return _newFeature;
71357       _newFeature = val;
71358       return mode;
71359     };
71360     mode.enter = function() {
71361       var note = checkSelectedID();
71362       if (!note)
71363         return;
71364       _behaviors.forEach(context.install);
71365       _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
71366       select_default2(document).call(_keybinding);
71367       selectNote();
71368       var sidebar = context.ui().sidebar;
71369       sidebar.show(_noteEditor.note(note).newNote(_newFeature));
71370       sidebar.expand(sidebar.intersects(note.extent()));
71371       context.map().on("drawn.select", selectNote);
71372     };
71373     mode.exit = function() {
71374       _behaviors.forEach(context.uninstall);
71375       select_default2(document).call(_keybinding.unbind);
71376       context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
71377       context.map().on("drawn.select", null);
71378       context.ui().sidebar.hide();
71379       context.selectedNoteID(null);
71380     };
71381     return mode;
71382   }
71383
71384   // modules/modes/add_note.js
71385   function modeAddNote(context) {
71386     var mode = {
71387       id: "add-note",
71388       button: "note",
71389       description: _t.append("modes.add_note.description"),
71390       key: _t("modes.add_note.key")
71391     };
71392     var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
71393     function add(loc) {
71394       var osm = services.osm;
71395       if (!osm)
71396         return;
71397       var note = osmNote({ loc, status: "open", comments: [] });
71398       osm.replaceNote(note);
71399       context.map().pan([0, 0]);
71400       context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
71401     }
71402     function cancel() {
71403       context.enter(modeBrowse(context));
71404     }
71405     mode.enter = function() {
71406       context.install(behavior);
71407     };
71408     mode.exit = function() {
71409       context.uninstall(behavior);
71410     };
71411     return mode;
71412   }
71413
71414   // node_modules/osm-community-index/lib/simplify.js
71415   var import_diacritics2 = __toESM(require_diacritics(), 1);
71416   function simplify(str) {
71417     if (typeof str !== "string")
71418       return "";
71419     return import_diacritics2.default.remove(
71420       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()
71421     );
71422   }
71423
71424   // node_modules/osm-community-index/lib/resolve_strings.js
71425   function resolveStrings(item, defaults, localizerFn) {
71426     let itemStrings = Object.assign({}, item.strings);
71427     let defaultStrings = Object.assign({}, defaults[item.type]);
71428     const anyToken = new RegExp(/(\{\w+\})/, "gi");
71429     if (localizerFn) {
71430       if (itemStrings.community) {
71431         const communityID = simplify(itemStrings.community);
71432         itemStrings.community = localizerFn("_communities.".concat(communityID));
71433       }
71434       ["name", "description", "extendedDescription"].forEach((prop) => {
71435         if (defaultStrings[prop])
71436           defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
71437         if (itemStrings[prop])
71438           itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
71439       });
71440     }
71441     let replacements = {
71442       account: item.account,
71443       community: itemStrings.community,
71444       signupUrl: itemStrings.signupUrl,
71445       url: itemStrings.url
71446     };
71447     if (!replacements.signupUrl) {
71448       replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
71449     }
71450     if (!replacements.url) {
71451       replacements.url = resolve(itemStrings.url || defaultStrings.url);
71452     }
71453     let resolved = {
71454       name: resolve(itemStrings.name || defaultStrings.name),
71455       url: resolve(itemStrings.url || defaultStrings.url),
71456       signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
71457       description: resolve(itemStrings.description || defaultStrings.description),
71458       extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
71459     };
71460     resolved.nameHTML = linkify(resolved.url, resolved.name);
71461     resolved.urlHTML = linkify(resolved.url);
71462     resolved.signupUrlHTML = linkify(resolved.signupUrl);
71463     resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
71464     resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
71465     return resolved;
71466     function resolve(s2, addLinks) {
71467       if (!s2)
71468         return void 0;
71469       let result = s2;
71470       for (let key in replacements) {
71471         const token = "{".concat(key, "}");
71472         const regex = new RegExp(token, "g");
71473         if (regex.test(result)) {
71474           let replacement = replacements[key];
71475           if (!replacement) {
71476             throw new Error("Cannot resolve token: ".concat(token));
71477           } else {
71478             if (addLinks && (key === "signupUrl" || key === "url")) {
71479               replacement = linkify(replacement);
71480             }
71481             result = result.replace(regex, replacement);
71482           }
71483         }
71484       }
71485       const leftovers = result.match(anyToken);
71486       if (leftovers) {
71487         throw new Error("Cannot resolve tokens: ".concat(leftovers));
71488       }
71489       if (addLinks && item.type === "reddit") {
71490         result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
71491       }
71492       return result;
71493     }
71494     function linkify(url, text) {
71495       if (!url)
71496         return void 0;
71497       text = text || url;
71498       return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
71499     }
71500   }
71501
71502   // modules/ui/success.js
71503   var _oci = null;
71504   function uiSuccess(context) {
71505     const MAXEVENTS = 2;
71506     const dispatch14 = dispatch_default("cancel");
71507     let _changeset2;
71508     let _location;
71509     ensureOSMCommunityIndex();
71510     function ensureOSMCommunityIndex() {
71511       const data = _mainFileFetcher;
71512       return Promise.all([
71513         data.get("oci_features"),
71514         data.get("oci_resources"),
71515         data.get("oci_defaults")
71516       ]).then((vals) => {
71517         if (_oci)
71518           return _oci;
71519         if (vals[0] && Array.isArray(vals[0].features)) {
71520           _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
71521         }
71522         let ociResources = Object.values(vals[1].resources);
71523         if (ociResources.length) {
71524           return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
71525             _oci = {
71526               resources: ociResources,
71527               defaults: vals[2].defaults
71528             };
71529             return _oci;
71530           });
71531         } else {
71532           _oci = {
71533             resources: [],
71534             // no resources?
71535             defaults: vals[2].defaults
71536           };
71537           return _oci;
71538         }
71539       });
71540     }
71541     function parseEventDate(when) {
71542       if (!when)
71543         return;
71544       let raw = when.trim();
71545       if (!raw)
71546         return;
71547       if (!/Z$/.test(raw)) {
71548         raw += "Z";
71549       }
71550       const parsed = new Date(raw);
71551       return new Date(parsed.toUTCString().slice(0, 25));
71552     }
71553     function success(selection2) {
71554       let header = selection2.append("div").attr("class", "header fillL");
71555       header.append("h2").call(_t.append("success.just_edited"));
71556       header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
71557       let body = selection2.append("div").attr("class", "body save-success fillL");
71558       let summary = body.append("div").attr("class", "save-summary");
71559       summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
71560       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"));
71561       let osm = context.connection();
71562       if (!osm)
71563         return;
71564       let changesetURL = osm.changesetURL(_changeset2.id);
71565       let table = summary.append("table").attr("class", "summary-table");
71566       let row = table.append("tr").attr("class", "summary-row");
71567       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");
71568       let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
71569       summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
71570       summaryDetail.append("div").html(_t.html("success.changeset_id", {
71571         changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
71572       }));
71573       if (showDonationMessage !== false) {
71574         const donationUrl = "https://supporting.openstreetmap.org/";
71575         let supporting = body.append("div").attr("class", "save-supporting");
71576         supporting.append("h3").call(_t.append("success.supporting.title"));
71577         supporting.append("p").call(_t.append("success.supporting.details"));
71578         table = supporting.append("table").attr("class", "supporting-table");
71579         row = table.append("tr").attr("class", "supporting-row");
71580         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");
71581         let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
71582         supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
71583         supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
71584       }
71585       ensureOSMCommunityIndex().then((oci) => {
71586         const loc = context.map().center();
71587         const validHere = _sharedLocationManager.locationSetsAt(loc);
71588         let communities = [];
71589         oci.resources.forEach((resource) => {
71590           let area = validHere[resource.locationSetID];
71591           if (!area)
71592             return;
71593           const localizer = (stringID) => _t.html("community.".concat(stringID));
71594           resource.resolved = resolveStrings(resource, oci.defaults, localizer);
71595           communities.push({
71596             area,
71597             order: resource.order || 0,
71598             resource
71599           });
71600         });
71601         communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
71602         body.call(showCommunityLinks, communities.map((c2) => c2.resource));
71603       });
71604     }
71605     function showCommunityLinks(selection2, resources) {
71606       let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
71607       communityLinks.append("h3").call(_t.append("success.like_osm"));
71608       let table = communityLinks.append("table").attr("class", "community-table");
71609       let row = table.selectAll(".community-row").data(resources);
71610       let rowEnter = row.enter().append("tr").attr("class", "community-row");
71611       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));
71612       let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
71613       communityDetail.each(showCommunityDetails);
71614       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"));
71615     }
71616     function showCommunityDetails(d2) {
71617       let selection2 = select_default2(this);
71618       let communityID = d2.id;
71619       selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
71620       selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
71621       if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
71622         selection2.append("div").call(
71623           uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
71624         );
71625       }
71626       let nextEvents = (d2.events || []).map((event) => {
71627         event.date = parseEventDate(event.when);
71628         return event;
71629       }).filter((event) => {
71630         const t2 = event.date.getTime();
71631         const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
71632         return !isNaN(t2) && t2 >= now3;
71633       }).sort((a2, b2) => {
71634         return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
71635       }).slice(0, MAXEVENTS);
71636       if (nextEvents.length) {
71637         selection2.append("div").call(
71638           uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
71639         ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
71640       }
71641       function showMore(selection3) {
71642         let more = selection3.selectAll(".community-more").data([0]);
71643         let moreEnter = more.enter().append("div").attr("class", "community-more");
71644         if (d2.resolved.extendedDescriptionHTML) {
71645           moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
71646         }
71647         if (d2.languageCodes && d2.languageCodes.length) {
71648           const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
71649           moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
71650         }
71651       }
71652       function showNextEvents(selection3) {
71653         let events = selection3.append("div").attr("class", "community-events");
71654         let item = events.selectAll(".community-event").data(nextEvents);
71655         let itemEnter = item.enter().append("div").attr("class", "community-event");
71656         itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
71657           let name = d4.name;
71658           if (d4.i18n && d4.id) {
71659             name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
71660           }
71661           return name;
71662         });
71663         itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
71664           let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
71665           if (d4.date.getHours() || d4.date.getMinutes()) {
71666             options2.hour = "numeric";
71667             options2.minute = "numeric";
71668           }
71669           return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
71670         });
71671         itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
71672           let where = d4.where;
71673           if (d4.i18n && d4.id) {
71674             where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
71675           }
71676           return where;
71677         });
71678         itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
71679           let description = d4.description;
71680           if (d4.i18n && d4.id) {
71681             description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
71682           }
71683           return description;
71684         });
71685       }
71686     }
71687     success.changeset = function(val) {
71688       if (!arguments.length)
71689         return _changeset2;
71690       _changeset2 = val;
71691       return success;
71692     };
71693     success.location = function(val) {
71694       if (!arguments.length)
71695         return _location;
71696       _location = val;
71697       return success;
71698     };
71699     return utilRebind(success, dispatch14, "on");
71700   }
71701
71702   // modules/modes/save.js
71703   function modeSave(context) {
71704     var mode = { id: "save" };
71705     var keybinding = utilKeybinding("modeSave");
71706     var commit = uiCommit(context).on("cancel", cancel);
71707     var _conflictsUi;
71708     var _location;
71709     var _success;
71710     var uploader = context.uploader().on("saveStarted.modeSave", function() {
71711       keybindingOff();
71712     }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
71713       cancel();
71714     }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
71715     function cancel() {
71716       context.enter(modeBrowse(context));
71717     }
71718     function showProgress(num, total) {
71719       var modal = context.container().select(".loading-modal .modal-section");
71720       var progress = modal.selectAll(".progress").data([0]);
71721       progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
71722     }
71723     function showConflicts(changeset, conflicts, origChanges) {
71724       var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
71725       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71726       _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
71727         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71728         selection2.remove();
71729         keybindingOn();
71730         uploader.cancelConflictResolution();
71731       }).on("save", function() {
71732         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71733         selection2.remove();
71734         uploader.processResolvedConflicts(changeset);
71735       });
71736       selection2.call(_conflictsUi);
71737     }
71738     function showErrors(errors) {
71739       keybindingOn();
71740       var selection2 = uiConfirm(context.container());
71741       selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
71742       addErrors(selection2, errors);
71743       selection2.okButton();
71744     }
71745     function addErrors(selection2, data) {
71746       var message = selection2.select(".modal-section.message-text");
71747       var items = message.selectAll(".error-container").data(data);
71748       var enter = items.enter().append("div").attr("class", "error-container");
71749       enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
71750         return d2.msg || _t("save.unknown_error_details");
71751       }).on("click", function(d3_event) {
71752         d3_event.preventDefault();
71753         var error = select_default2(this);
71754         var detail = select_default2(this.nextElementSibling);
71755         var exp2 = error.classed("expanded");
71756         detail.style("display", exp2 ? "none" : "block");
71757         error.classed("expanded", !exp2);
71758       });
71759       var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
71760       details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
71761         return d2.details || [];
71762       }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
71763         return d2;
71764       });
71765       items.exit().remove();
71766     }
71767     function showSuccess(changeset) {
71768       commit.reset();
71769       var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
71770         context.ui().sidebar.hide();
71771       });
71772       context.enter(modeBrowse(context).sidebar(ui));
71773     }
71774     function keybindingOn() {
71775       select_default2(document).call(keybinding.on("\u238B", cancel, true));
71776     }
71777     function keybindingOff() {
71778       select_default2(document).call(keybinding.unbind);
71779     }
71780     function prepareForSuccess() {
71781       _success = uiSuccess(context);
71782       _location = null;
71783       if (!services.geocoder)
71784         return;
71785       services.geocoder.reverse(context.map().center(), function(err, result) {
71786         if (err || !result || !result.address)
71787           return;
71788         var addr = result.address;
71789         var place = addr && (addr.town || addr.city || addr.county) || "";
71790         var region = addr && (addr.state || addr.country) || "";
71791         var separator = place && region ? _t("success.thank_you_where.separator") : "";
71792         _location = _t(
71793           "success.thank_you_where.format",
71794           { place, separator, region }
71795         );
71796       });
71797     }
71798     mode.selectedIDs = function() {
71799       return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
71800     };
71801     mode.enter = function() {
71802       context.ui().sidebar.expand();
71803       function done() {
71804         context.ui().sidebar.show(commit);
71805       }
71806       keybindingOn();
71807       context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71808       var osm = context.connection();
71809       if (!osm) {
71810         cancel();
71811         return;
71812       }
71813       if (osm.authenticated()) {
71814         done();
71815       } else {
71816         osm.authenticate(function(err) {
71817           if (err) {
71818             cancel();
71819           } else {
71820             done();
71821           }
71822         });
71823       }
71824     };
71825     mode.exit = function() {
71826       keybindingOff();
71827       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71828       context.ui().sidebar.hide();
71829     };
71830     return mode;
71831   }
71832
71833   // modules/ui/improveOSM_comments.js
71834   function uiImproveOsmComments() {
71835     let _qaItem;
71836     function issueComments(selection2) {
71837       let comments = selection2.selectAll(".comments-container").data([0]);
71838       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
71839       services.improveOSM.getComments(_qaItem).then((d2) => {
71840         if (!d2.comments)
71841           return;
71842         const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment");
71843         commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
71844         const mainEnter = commentEnter.append("div").attr("class", "comment-main");
71845         const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
71846         metadataEnter.append("div").attr("class", "comment-author").each(function(d4) {
71847           const osm = services.osm;
71848           let selection3 = select_default2(this);
71849           if (osm && d4.username) {
71850             selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank");
71851           }
71852           selection3.text((d5) => d5.username);
71853         });
71854         metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) }));
71855         mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text);
71856       }).catch((err) => {
71857         console.log(err);
71858       });
71859     }
71860     function localeDateString2(s2) {
71861       if (!s2)
71862         return null;
71863       const options2 = { day: "numeric", month: "short", year: "numeric" };
71864       const d2 = new Date(s2 * 1e3);
71865       if (isNaN(d2.getTime()))
71866         return null;
71867       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
71868     }
71869     issueComments.issue = function(val) {
71870       if (!arguments.length)
71871         return _qaItem;
71872       _qaItem = val;
71873       return issueComments;
71874     };
71875     return issueComments;
71876   }
71877
71878   // modules/ui/improveOSM_details.js
71879   function uiImproveOsmDetails(context) {
71880     let _qaItem;
71881     function issueDetail(d2) {
71882       if (d2.desc)
71883         return d2.desc;
71884       const issueKey = d2.issueKey;
71885       d2.replacements = d2.replacements || {};
71886       d2.replacements.default = { html: _t.html("inspector.unknown") };
71887       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements);
71888     }
71889     function improveOsmDetails(selection2) {
71890       const details = selection2.selectAll(".error-details").data(
71891         _qaItem ? [_qaItem] : [],
71892         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71893       );
71894       details.exit().remove();
71895       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
71896       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
71897       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
71898       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
71899       let relatedEntities = [];
71900       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
71901         const link3 = select_default2(this);
71902         const isObjectLink = link3.classed("error_object_link");
71903         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
71904         const entity = context.hasEntity(entityID);
71905         relatedEntities.push(entityID);
71906         link3.on("mouseenter", () => {
71907           utilHighlightEntities([entityID], true, context);
71908         }).on("mouseleave", () => {
71909           utilHighlightEntities([entityID], false, context);
71910         }).on("click", (d3_event) => {
71911           d3_event.preventDefault();
71912           utilHighlightEntities([entityID], false, context);
71913           const osmlayer = context.layers().layer("osm");
71914           if (!osmlayer.enabled()) {
71915             osmlayer.enabled(true);
71916           }
71917           context.map().centerZoom(_qaItem.loc, 20);
71918           if (entity) {
71919             context.enter(modeSelect(context, [entityID]));
71920           } else {
71921             context.loadEntity(entityID, (err, result) => {
71922               if (err)
71923                 return;
71924               const entity2 = result.data.find((e3) => e3.id === entityID);
71925               if (entity2)
71926                 context.enter(modeSelect(context, [entityID]));
71927             });
71928           }
71929         });
71930         if (entity) {
71931           let name = utilDisplayName(entity);
71932           if (!name && !isObjectLink) {
71933             const preset = _mainPresetIndex.match(entity, context.graph());
71934             name = preset && !preset.isFallback() && preset.name();
71935           }
71936           if (name) {
71937             this.innerText = name;
71938           }
71939         }
71940       });
71941       context.features().forceVisible(relatedEntities);
71942       context.map().pan([0, 0]);
71943     }
71944     improveOsmDetails.issue = function(val) {
71945       if (!arguments.length)
71946         return _qaItem;
71947       _qaItem = val;
71948       return improveOsmDetails;
71949     };
71950     return improveOsmDetails;
71951   }
71952
71953   // modules/ui/improveOSM_header.js
71954   function uiImproveOsmHeader() {
71955     let _qaItem;
71956     function issueTitle(d2) {
71957       const issueKey = d2.issueKey;
71958       d2.replacements = d2.replacements || {};
71959       d2.replacements.default = { html: _t.html("inspector.unknown") };
71960       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements);
71961     }
71962     function improveOsmHeader(selection2) {
71963       const header = selection2.selectAll(".qa-header").data(
71964         _qaItem ? [_qaItem] : [],
71965         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71966       );
71967       header.exit().remove();
71968       const headerEnter = header.enter().append("div").attr("class", "qa-header");
71969       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));
71970       svgEnter.append("polygon").attr("fill", "currentColor").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");
71971       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 : "");
71972       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
71973     }
71974     improveOsmHeader.issue = function(val) {
71975       if (!arguments.length)
71976         return _qaItem;
71977       _qaItem = val;
71978       return improveOsmHeader;
71979     };
71980     return improveOsmHeader;
71981   }
71982
71983   // modules/ui/improveOSM_editor.js
71984   function uiImproveOsmEditor(context) {
71985     const dispatch14 = dispatch_default("change");
71986     const qaDetails = uiImproveOsmDetails(context);
71987     const qaComments = uiImproveOsmComments(context);
71988     const qaHeader = uiImproveOsmHeader(context);
71989     let _qaItem;
71990     function improveOsmEditor(selection2) {
71991       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
71992       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
71993       headerEnter.append("h2").call(_t.append("QA.improveOSM.title"));
71994       let body = selection2.selectAll(".body").data([0]);
71995       body = body.enter().append("div").attr("class", "body").merge(body);
71996       const editor = body.selectAll(".qa-editor").data([0]);
71997       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(qaComments.issue(_qaItem)).call(improveOsmSaveSection);
71998     }
71999     function improveOsmSaveSection(selection2) {
72000       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72001       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
72002       let saveSection = selection2.selectAll(".qa-save").data(
72003         isShown ? [_qaItem] : [],
72004         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72005       );
72006       saveSection.exit().remove();
72007       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72008       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment"));
72009       saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
72010       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72011       function changeInput() {
72012         const input = select_default2(this);
72013         let val = input.property("value").trim();
72014         if (val === "") {
72015           val = void 0;
72016         }
72017         _qaItem = _qaItem.update({ newComment: val });
72018         const qaService = services.improveOSM;
72019         if (qaService) {
72020           qaService.replaceItem(_qaItem);
72021         }
72022         saveSection.call(qaSaveButtons);
72023       }
72024     }
72025     function qaSaveButtons(selection2) {
72026       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72027       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72028       buttonSection.exit().remove();
72029       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72030       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
72031       buttonEnter.append("button").attr("class", "button close-button action");
72032       buttonEnter.append("button").attr("class", "button ignore-button action");
72033       buttonSection = buttonSection.merge(buttonEnter);
72034       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72035         this.blur();
72036         const qaService = services.improveOSM;
72037         if (qaService) {
72038           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72039         }
72040       });
72041       buttonSection.select(".close-button").html((d2) => {
72042         const andComment = d2.newComment ? "_comment" : "";
72043         return _t.html("QA.keepRight.close".concat(andComment));
72044       }).on("click.close", function(d3_event, d2) {
72045         this.blur();
72046         const qaService = services.improveOSM;
72047         if (qaService) {
72048           d2.newStatus = "SOLVED";
72049           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72050         }
72051       });
72052       buttonSection.select(".ignore-button").html((d2) => {
72053         const andComment = d2.newComment ? "_comment" : "";
72054         return _t.html("QA.keepRight.ignore".concat(andComment));
72055       }).on("click.ignore", function(d3_event, d2) {
72056         this.blur();
72057         const qaService = services.improveOSM;
72058         if (qaService) {
72059           d2.newStatus = "INVALID";
72060           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72061         }
72062       });
72063     }
72064     improveOsmEditor.error = function(val) {
72065       if (!arguments.length)
72066         return _qaItem;
72067       _qaItem = val;
72068       return improveOsmEditor;
72069     };
72070     return utilRebind(improveOsmEditor, dispatch14, "on");
72071   }
72072
72073   // modules/ui/keepRight_details.js
72074   function uiKeepRightDetails(context) {
72075     let _qaItem;
72076     function issueDetail(d2) {
72077       const { itemType, parentIssueType } = d2;
72078       const unknown = { html: _t.html("inspector.unknown") };
72079       let replacements = d2.replacements || {};
72080       replacements.default = unknown;
72081       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72082         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
72083       } else {
72084         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
72085       }
72086     }
72087     function keepRightDetails(selection2) {
72088       const details = selection2.selectAll(".error-details").data(
72089         _qaItem ? [_qaItem] : [],
72090         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72091       );
72092       details.exit().remove();
72093       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72094       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
72095       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
72096       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
72097       let relatedEntities = [];
72098       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
72099         const link3 = select_default2(this);
72100         const isObjectLink = link3.classed("error_object_link");
72101         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
72102         const entity = context.hasEntity(entityID);
72103         relatedEntities.push(entityID);
72104         link3.on("mouseenter", () => {
72105           utilHighlightEntities([entityID], true, context);
72106         }).on("mouseleave", () => {
72107           utilHighlightEntities([entityID], false, context);
72108         }).on("click", (d3_event) => {
72109           d3_event.preventDefault();
72110           utilHighlightEntities([entityID], false, context);
72111           const osmlayer = context.layers().layer("osm");
72112           if (!osmlayer.enabled()) {
72113             osmlayer.enabled(true);
72114           }
72115           context.map().centerZoomEase(_qaItem.loc, 20);
72116           if (entity) {
72117             context.enter(modeSelect(context, [entityID]));
72118           } else {
72119             context.loadEntity(entityID, (err, result) => {
72120               if (err)
72121                 return;
72122               const entity2 = result.data.find((e3) => e3.id === entityID);
72123               if (entity2)
72124                 context.enter(modeSelect(context, [entityID]));
72125             });
72126           }
72127         });
72128         if (entity) {
72129           let name = utilDisplayName(entity);
72130           if (!name && !isObjectLink) {
72131             const preset = _mainPresetIndex.match(entity, context.graph());
72132             name = preset && !preset.isFallback() && preset.name();
72133           }
72134           if (name) {
72135             this.innerText = name;
72136           }
72137         }
72138       });
72139       context.features().forceVisible(relatedEntities);
72140       context.map().pan([0, 0]);
72141     }
72142     keepRightDetails.issue = function(val) {
72143       if (!arguments.length)
72144         return _qaItem;
72145       _qaItem = val;
72146       return keepRightDetails;
72147     };
72148     return keepRightDetails;
72149   }
72150
72151   // modules/ui/keepRight_header.js
72152   function uiKeepRightHeader() {
72153     let _qaItem;
72154     function issueTitle(d2) {
72155       const { itemType, parentIssueType } = d2;
72156       const unknown = _t.html("inspector.unknown");
72157       let replacements = d2.replacements || {};
72158       replacements.default = { html: unknown };
72159       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72160         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
72161       } else {
72162         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
72163       }
72164     }
72165     function keepRightHeader(selection2) {
72166       const header = selection2.selectAll(".qa-header").data(
72167         _qaItem ? [_qaItem] : [],
72168         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72169       );
72170       header.exit().remove();
72171       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72172       const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
72173       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"));
72174       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
72175     }
72176     keepRightHeader.issue = function(val) {
72177       if (!arguments.length)
72178         return _qaItem;
72179       _qaItem = val;
72180       return keepRightHeader;
72181     };
72182     return keepRightHeader;
72183   }
72184
72185   // modules/ui/view_on_keepRight.js
72186   function uiViewOnKeepRight() {
72187     let _qaItem;
72188     function viewOnKeepRight(selection2) {
72189       let url;
72190       if (services.keepRight && _qaItem instanceof QAItem) {
72191         url = services.keepRight.issueURL(_qaItem);
72192       }
72193       const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
72194       link3.exit().remove();
72195       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"));
72196       linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
72197     }
72198     viewOnKeepRight.what = function(val) {
72199       if (!arguments.length)
72200         return _qaItem;
72201       _qaItem = val;
72202       return viewOnKeepRight;
72203     };
72204     return viewOnKeepRight;
72205   }
72206
72207   // modules/ui/keepRight_editor.js
72208   function uiKeepRightEditor(context) {
72209     const dispatch14 = dispatch_default("change");
72210     const qaDetails = uiKeepRightDetails(context);
72211     const qaHeader = uiKeepRightHeader(context);
72212     let _qaItem;
72213     function keepRightEditor(selection2) {
72214       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
72215       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72216       headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
72217       let body = selection2.selectAll(".body").data([0]);
72218       body = body.enter().append("div").attr("class", "body").merge(body);
72219       const editor = body.selectAll(".qa-editor").data([0]);
72220       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
72221       const footer = selection2.selectAll(".footer").data([0]);
72222       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
72223     }
72224     function keepRightSaveSection(selection2) {
72225       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72226       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
72227       let saveSection = selection2.selectAll(".qa-save").data(
72228         isShown ? [_qaItem] : [],
72229         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72230       );
72231       saveSection.exit().remove();
72232       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72233       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
72234       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);
72235       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72236       function changeInput() {
72237         const input = select_default2(this);
72238         let val = input.property("value").trim();
72239         if (val === _qaItem.comment) {
72240           val = void 0;
72241         }
72242         _qaItem = _qaItem.update({ newComment: val });
72243         const qaService = services.keepRight;
72244         if (qaService) {
72245           qaService.replaceItem(_qaItem);
72246         }
72247         saveSection.call(qaSaveButtons);
72248       }
72249     }
72250     function qaSaveButtons(selection2) {
72251       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72252       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72253       buttonSection.exit().remove();
72254       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72255       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
72256       buttonEnter.append("button").attr("class", "button close-button action");
72257       buttonEnter.append("button").attr("class", "button ignore-button action");
72258       buttonSection = buttonSection.merge(buttonEnter);
72259       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72260         this.blur();
72261         const qaService = services.keepRight;
72262         if (qaService) {
72263           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72264         }
72265       });
72266       buttonSection.select(".close-button").html((d2) => {
72267         const andComment = d2.newComment ? "_comment" : "";
72268         return _t.html("QA.keepRight.close".concat(andComment));
72269       }).on("click.close", function(d3_event, d2) {
72270         this.blur();
72271         const qaService = services.keepRight;
72272         if (qaService) {
72273           d2.newStatus = "ignore_t";
72274           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72275         }
72276       });
72277       buttonSection.select(".ignore-button").html((d2) => {
72278         const andComment = d2.newComment ? "_comment" : "";
72279         return _t.html("QA.keepRight.ignore".concat(andComment));
72280       }).on("click.ignore", function(d3_event, d2) {
72281         this.blur();
72282         const qaService = services.keepRight;
72283         if (qaService) {
72284           d2.newStatus = "ignore";
72285           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72286         }
72287       });
72288     }
72289     keepRightEditor.error = function(val) {
72290       if (!arguments.length)
72291         return _qaItem;
72292       _qaItem = val;
72293       return keepRightEditor;
72294     };
72295     return utilRebind(keepRightEditor, dispatch14, "on");
72296   }
72297
72298   // modules/ui/osmose_details.js
72299   function uiOsmoseDetails(context) {
72300     let _qaItem;
72301     function issueString(d2, type2) {
72302       if (!d2)
72303         return "";
72304       const s2 = services.osmose.getStrings(d2.itemType);
72305       return type2 in s2 ? s2[type2] : "";
72306     }
72307     function osmoseDetails(selection2) {
72308       const details = selection2.selectAll(".error-details").data(
72309         _qaItem ? [_qaItem] : [],
72310         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72311       );
72312       details.exit().remove();
72313       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72314       if (issueString(_qaItem, "detail")) {
72315         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72316         div.append("h4").call(_t.append("QA.keepRight.detail_description"));
72317         div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72318       }
72319       const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72320       const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72321       if (issueString(_qaItem, "fix")) {
72322         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72323         div.append("h4").call(_t.append("QA.osmose.fix_title"));
72324         div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72325       }
72326       if (issueString(_qaItem, "trap")) {
72327         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72328         div.append("h4").call(_t.append("QA.osmose.trap_title"));
72329         div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72330       }
72331       const thisItem = _qaItem;
72332       services.osmose.loadIssueDetail(_qaItem).then((d2) => {
72333         if (!d2.elems || d2.elems.length === 0)
72334           return;
72335         if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty())
72336           return;
72337         if (d2.detail) {
72338           detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
72339           detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72340         }
72341         elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
72342         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() {
72343           const link3 = select_default2(this);
72344           const entityID = this.textContent;
72345           const entity = context.hasEntity(entityID);
72346           link3.on("mouseenter", () => {
72347             utilHighlightEntities([entityID], true, context);
72348           }).on("mouseleave", () => {
72349             utilHighlightEntities([entityID], false, context);
72350           }).on("click", (d3_event) => {
72351             d3_event.preventDefault();
72352             utilHighlightEntities([entityID], false, context);
72353             const osmlayer = context.layers().layer("osm");
72354             if (!osmlayer.enabled()) {
72355               osmlayer.enabled(true);
72356             }
72357             context.map().centerZoom(d2.loc, 20);
72358             if (entity) {
72359               context.enter(modeSelect(context, [entityID]));
72360             } else {
72361               context.loadEntity(entityID, (err, result) => {
72362                 if (err)
72363                   return;
72364                 const entity2 = result.data.find((e3) => e3.id === entityID);
72365                 if (entity2)
72366                   context.enter(modeSelect(context, [entityID]));
72367               });
72368             }
72369           });
72370           if (entity) {
72371             let name = utilDisplayName(entity);
72372             if (!name) {
72373               const preset = _mainPresetIndex.match(entity, context.graph());
72374               name = preset && !preset.isFallback() && preset.name();
72375             }
72376             if (name) {
72377               this.innerText = name;
72378             }
72379           }
72380         });
72381         context.features().forceVisible(d2.elems);
72382         context.map().pan([0, 0]);
72383       }).catch((err) => {
72384         console.log(err);
72385       });
72386     }
72387     osmoseDetails.issue = function(val) {
72388       if (!arguments.length)
72389         return _qaItem;
72390       _qaItem = val;
72391       return osmoseDetails;
72392     };
72393     return osmoseDetails;
72394   }
72395
72396   // modules/ui/osmose_header.js
72397   function uiOsmoseHeader() {
72398     let _qaItem;
72399     function issueTitle(d2) {
72400       const unknown = _t("inspector.unknown");
72401       if (!d2)
72402         return unknown;
72403       const s2 = services.osmose.getStrings(d2.itemType);
72404       return "title" in s2 ? s2.title : unknown;
72405     }
72406     function osmoseHeader(selection2) {
72407       const header = selection2.selectAll(".qa-header").data(
72408         _qaItem ? [_qaItem] : [],
72409         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72410       );
72411       header.exit().remove();
72412       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72413       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));
72414       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");
72415       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 : "");
72416       headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
72417     }
72418     osmoseHeader.issue = function(val) {
72419       if (!arguments.length)
72420         return _qaItem;
72421       _qaItem = val;
72422       return osmoseHeader;
72423     };
72424     return osmoseHeader;
72425   }
72426
72427   // modules/ui/view_on_osmose.js
72428   function uiViewOnOsmose() {
72429     let _qaItem;
72430     function viewOnOsmose(selection2) {
72431       let url;
72432       if (services.osmose && _qaItem instanceof QAItem) {
72433         url = services.osmose.itemURL(_qaItem);
72434       }
72435       const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
72436       link3.exit().remove();
72437       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"));
72438       linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
72439     }
72440     viewOnOsmose.what = function(val) {
72441       if (!arguments.length)
72442         return _qaItem;
72443       _qaItem = val;
72444       return viewOnOsmose;
72445     };
72446     return viewOnOsmose;
72447   }
72448
72449   // modules/ui/osmose_editor.js
72450   function uiOsmoseEditor(context) {
72451     const dispatch14 = dispatch_default("change");
72452     const qaDetails = uiOsmoseDetails(context);
72453     const qaHeader = uiOsmoseHeader(context);
72454     let _qaItem;
72455     function osmoseEditor(selection2) {
72456       const header = selection2.selectAll(".header").data([0]);
72457       const headerEnter = header.enter().append("div").attr("class", "header fillL");
72458       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72459       headerEnter.append("h2").call(_t.append("QA.osmose.title"));
72460       let body = selection2.selectAll(".body").data([0]);
72461       body = body.enter().append("div").attr("class", "body").merge(body);
72462       let editor = body.selectAll(".qa-editor").data([0]);
72463       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
72464       const footer = selection2.selectAll(".footer").data([0]);
72465       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
72466     }
72467     function osmoseSaveSection(selection2) {
72468       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72469       const isShown = _qaItem && isSelected;
72470       let saveSection = selection2.selectAll(".qa-save").data(
72471         isShown ? [_qaItem] : [],
72472         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72473       );
72474       saveSection.exit().remove();
72475       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72476       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72477     }
72478     function qaSaveButtons(selection2) {
72479       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72480       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72481       buttonSection.exit().remove();
72482       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72483       buttonEnter.append("button").attr("class", "button close-button action");
72484       buttonEnter.append("button").attr("class", "button ignore-button action");
72485       buttonSection = buttonSection.merge(buttonEnter);
72486       buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
72487         this.blur();
72488         const qaService = services.osmose;
72489         if (qaService) {
72490           d2.newStatus = "done";
72491           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72492         }
72493       });
72494       buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
72495         this.blur();
72496         const qaService = services.osmose;
72497         if (qaService) {
72498           d2.newStatus = "false";
72499           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72500         }
72501       });
72502     }
72503     osmoseEditor.error = function(val) {
72504       if (!arguments.length)
72505         return _qaItem;
72506       _qaItem = val;
72507       return osmoseEditor;
72508     };
72509     return utilRebind(osmoseEditor, dispatch14, "on");
72510   }
72511
72512   // modules/modes/select_error.js
72513   function modeSelectError(context, selectedErrorID, selectedErrorService) {
72514     var mode = {
72515       id: "select-error",
72516       button: "browse"
72517     };
72518     var keybinding = utilKeybinding("select-error");
72519     var errorService = services[selectedErrorService];
72520     var errorEditor;
72521     switch (selectedErrorService) {
72522       case "improveOSM":
72523         errorEditor = uiImproveOsmEditor(context).on("change", function() {
72524           context.map().pan([0, 0]);
72525           var error = checkSelectedID();
72526           if (!error)
72527             return;
72528           context.ui().sidebar.show(errorEditor.error(error));
72529         });
72530         break;
72531       case "keepRight":
72532         errorEditor = uiKeepRightEditor(context).on("change", function() {
72533           context.map().pan([0, 0]);
72534           var error = checkSelectedID();
72535           if (!error)
72536             return;
72537           context.ui().sidebar.show(errorEditor.error(error));
72538         });
72539         break;
72540       case "osmose":
72541         errorEditor = uiOsmoseEditor(context).on("change", function() {
72542           context.map().pan([0, 0]);
72543           var error = checkSelectedID();
72544           if (!error)
72545             return;
72546           context.ui().sidebar.show(errorEditor.error(error));
72547         });
72548         break;
72549     }
72550     var behaviors = [
72551       behaviorBreathe(context),
72552       behaviorHover(context),
72553       behaviorSelect(context),
72554       behaviorLasso(context),
72555       modeDragNode(context).behavior,
72556       modeDragNote(context).behavior
72557     ];
72558     function checkSelectedID() {
72559       if (!errorService)
72560         return;
72561       var error = errorService.getError(selectedErrorID);
72562       if (!error) {
72563         context.enter(modeBrowse(context));
72564       }
72565       return error;
72566     }
72567     mode.zoomToSelected = function() {
72568       if (!errorService)
72569         return;
72570       var error = errorService.getError(selectedErrorID);
72571       if (error) {
72572         context.map().centerZoomEase(error.loc, 20);
72573       }
72574     };
72575     mode.enter = function() {
72576       var error = checkSelectedID();
72577       if (!error)
72578         return;
72579       behaviors.forEach(context.install);
72580       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
72581       select_default2(document).call(keybinding);
72582       selectError();
72583       var sidebar = context.ui().sidebar;
72584       sidebar.show(errorEditor.error(error));
72585       context.map().on("drawn.select-error", selectError);
72586       function selectError(d3_event, drawn) {
72587         if (!checkSelectedID())
72588           return;
72589         var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
72590         if (selection2.empty()) {
72591           var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
72592           if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
72593             context.enter(modeBrowse(context));
72594           }
72595         } else {
72596           selection2.classed("selected", true);
72597           context.selectedErrorID(selectedErrorID);
72598         }
72599       }
72600       function esc() {
72601         if (context.container().select(".combobox").size())
72602           return;
72603         context.enter(modeBrowse(context));
72604       }
72605     };
72606     mode.exit = function() {
72607       behaviors.forEach(context.uninstall);
72608       select_default2(document).call(keybinding.unbind);
72609       context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
72610       context.map().on("drawn.select-error", null);
72611       context.ui().sidebar.hide();
72612       context.selectedErrorID(null);
72613       context.features().forceVisible([]);
72614     };
72615     return mode;
72616   }
72617
72618   // modules/ui/feature_list.js
72619   function uiFeatureList(context) {
72620     var _geocodeResults;
72621     function featureList(selection2) {
72622       var header = selection2.append("div").attr("class", "header fillL");
72623       header.append("h2").call(_t.append("inspector.feature_list"));
72624       var searchWrap = selection2.append("div").attr("class", "search-header");
72625       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72626       var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
72627       var listWrap = selection2.append("div").attr("class", "inspector-body");
72628       var list2 = listWrap.append("div").attr("class", "feature-list");
72629       context.on("exit.feature-list", clearSearch);
72630       context.map().on("drawn.feature-list", mapDrawn);
72631       context.keybinding().on(uiCmd("\u2318F"), focusSearch);
72632       function focusSearch(d3_event) {
72633         var mode = context.mode() && context.mode().id;
72634         if (mode !== "browse")
72635           return;
72636         d3_event.preventDefault();
72637         search.node().focus();
72638       }
72639       function keydown(d3_event) {
72640         if (d3_event.keyCode === 27) {
72641           search.node().blur();
72642         }
72643       }
72644       function keypress(d3_event) {
72645         var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
72646         if (d3_event.keyCode === 13 && // ↩ Return
72647         q2.length && items.size()) {
72648           click(d3_event, items.datum());
72649         }
72650       }
72651       function inputevent() {
72652         _geocodeResults = void 0;
72653         drawList();
72654       }
72655       function clearSearch() {
72656         search.property("value", "");
72657         drawList();
72658       }
72659       function mapDrawn(e3) {
72660         if (e3.full) {
72661           drawList();
72662         }
72663       }
72664       function features() {
72665         var result = [];
72666         var graph = context.graph();
72667         var visibleCenter = context.map().extent().center();
72668         var q2 = search.property("value").toLowerCase();
72669         if (!q2)
72670           return result;
72671         var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
72672         if (locationMatch) {
72673           var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
72674           result.push({
72675             id: -1,
72676             geometry: "point",
72677             type: _t("inspector.location"),
72678             name: dmsCoordinatePair([loc[1], loc[0]]),
72679             location: loc
72680           });
72681         }
72682         var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
72683         if (idMatch) {
72684           var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
72685           var elemId = idMatch[2];
72686           result.push({
72687             id: elemType + elemId,
72688             geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
72689             type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
72690             name: elemId
72691           });
72692         }
72693         var allEntities = graph.entities;
72694         var localResults = [];
72695         for (var id2 in allEntities) {
72696           var entity = allEntities[id2];
72697           if (!entity)
72698             continue;
72699           var name = utilDisplayName(entity) || "";
72700           if (name.toLowerCase().indexOf(q2) < 0)
72701             continue;
72702           var matched = _mainPresetIndex.match(entity, graph);
72703           var type2 = matched && matched.name() || utilDisplayType(entity.id);
72704           var extent = entity.extent(graph);
72705           var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
72706           localResults.push({
72707             id: entity.id,
72708             entity,
72709             geometry: entity.geometry(graph),
72710             type: type2,
72711             name,
72712             distance
72713           });
72714           if (localResults.length > 100)
72715             break;
72716         }
72717         localResults = localResults.sort(function byDistance(a2, b2) {
72718           return a2.distance - b2.distance;
72719         });
72720         result = result.concat(localResults);
72721         (_geocodeResults || []).forEach(function(d2) {
72722           if (d2.osm_type && d2.osm_id) {
72723             var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
72724             var tags = {};
72725             tags[d2.class] = d2.type;
72726             var attrs = { id: id3, type: d2.osm_type, tags };
72727             if (d2.osm_type === "way") {
72728               attrs.nodes = ["a", "a"];
72729             }
72730             var tempEntity = osmEntity(attrs);
72731             var tempGraph = coreGraph([tempEntity]);
72732             var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
72733             var type3 = matched2 && matched2.name() || utilDisplayType(id3);
72734             result.push({
72735               id: tempEntity.id,
72736               geometry: tempEntity.geometry(tempGraph),
72737               type: type3,
72738               name: d2.display_name,
72739               extent: new geoExtent(
72740                 [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
72741                 [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
72742               )
72743             });
72744           }
72745         });
72746         if (q2.match(/^[0-9]+$/)) {
72747           result.push({
72748             id: "n" + q2,
72749             geometry: "point",
72750             type: _t("inspector.node"),
72751             name: q2
72752           });
72753           result.push({
72754             id: "w" + q2,
72755             geometry: "line",
72756             type: _t("inspector.way"),
72757             name: q2
72758           });
72759           result.push({
72760             id: "r" + q2,
72761             geometry: "relation",
72762             type: _t("inspector.relation"),
72763             name: q2
72764           });
72765           result.push({
72766             id: "note" + q2,
72767             geometry: "note",
72768             type: _t("note.note"),
72769             name: q2
72770           });
72771         }
72772         return result;
72773       }
72774       function drawList() {
72775         var value = search.property("value");
72776         var results = features();
72777         list2.classed("filtered", value.length);
72778         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"));
72779         resultsIndicator.append("span").attr("class", "entity-name");
72780         list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
72781         if (services.geocoder) {
72782           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"));
72783         }
72784         list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
72785         list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
72786         list2.selectAll(".feature-list-item").data([-1]).remove();
72787         var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
72788           return d2.id;
72789         });
72790         var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
72791         var label = enter.append("div").attr("class", "label");
72792         label.each(function(d2) {
72793           select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
72794         });
72795         label.append("span").attr("class", "entity-type").text(function(d2) {
72796           return d2.type;
72797         });
72798         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) {
72799           return d2.name;
72800         });
72801         enter.style("opacity", 0).transition().style("opacity", 1);
72802         items.order();
72803         items.exit().remove();
72804       }
72805       function mouseover(d3_event, d2) {
72806         if (d2.id === -1)
72807           return;
72808         utilHighlightEntities([d2.id], true, context);
72809       }
72810       function mouseout(d3_event, d2) {
72811         if (d2.id === -1)
72812           return;
72813         utilHighlightEntities([d2.id], false, context);
72814       }
72815       function click(d3_event, d2) {
72816         d3_event.preventDefault();
72817         if (d2.location) {
72818           context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
72819         } else if (d2.entity) {
72820           utilHighlightEntities([d2.id], false, context);
72821           context.enter(modeSelect(context, [d2.entity.id]));
72822           context.map().zoomToEase(d2.entity);
72823         } else if (d2.geometry === "note") {
72824           const noteId = d2.id.replace(/\D/g, "");
72825           context.loadNote(noteId, (err, result) => {
72826             if (err)
72827               return;
72828             const entity = result.data.find((e3) => e3.id === noteId);
72829             if (entity) {
72830               const note = services.osm.getNote(noteId);
72831               context.map().centerZoom(note.loc, 15);
72832               const noteLayer = context.layers().layer("notes");
72833               noteLayer.enabled(true);
72834               context.enter(modeSelectNote(context, noteId));
72835             }
72836           });
72837         } else {
72838           context.zoomToEntity(d2.id);
72839         }
72840       }
72841       function geocoderSearch() {
72842         services.geocoder.search(search.property("value"), function(err, resp) {
72843           _geocodeResults = resp || [];
72844           drawList();
72845         });
72846       }
72847     }
72848     return featureList;
72849   }
72850
72851   // modules/ui/preset_list.js
72852   function uiPresetList(context) {
72853     var dispatch14 = dispatch_default("cancel", "choose");
72854     var _entityIDs;
72855     var _currLoc;
72856     var _currentPresets;
72857     var _autofocus = false;
72858     function presetList(selection2) {
72859       if (!_entityIDs)
72860         return;
72861       var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
72862       selection2.html("");
72863       var messagewrap = selection2.append("div").attr("class", "header fillL");
72864       var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
72865       var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward";
72866       messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
72867         dispatch14.call("cancel", this);
72868       }).call(svgIcon("#iD-icon-".concat(direction)));
72869       function initialKeydown(d3_event) {
72870         if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
72871           d3_event.preventDefault();
72872           d3_event.stopPropagation();
72873           operationDelete(context, _entityIDs)();
72874         } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
72875           d3_event.preventDefault();
72876           d3_event.stopPropagation();
72877           context.undo();
72878         } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
72879           select_default2(this).on("keydown", keydown);
72880           keydown.call(this, d3_event);
72881         }
72882       }
72883       function keydown(d3_event) {
72884         if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
72885         search.node().selectionStart === search.property("value").length) {
72886           d3_event.preventDefault();
72887           d3_event.stopPropagation();
72888           var buttons = list2.selectAll(".preset-list-button");
72889           if (!buttons.empty())
72890             buttons.nodes()[0].focus();
72891         }
72892       }
72893       function keypress(d3_event) {
72894         var value = search.property("value");
72895         if (d3_event.keyCode === 13 && // ↩ Return
72896         value.length) {
72897           list2.selectAll(".preset-list-item:first-child").each(function(d2) {
72898             d2.choose.call(this);
72899           });
72900         }
72901       }
72902       function inputevent() {
72903         var value = search.property("value");
72904         list2.classed("filtered", value.length);
72905         var results, messageText;
72906         if (value.length) {
72907           results = presets.search(value, entityGeometries()[0], _currLoc);
72908           messageText = _t.html("inspector.results", {
72909             n: results.collection.length,
72910             search: value
72911           });
72912         } else {
72913           var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72914           results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
72915           messageText = _t.html("inspector.choose");
72916         }
72917         list2.call(drawList, results);
72918         message.html(messageText);
72919       }
72920       var searchWrap = selection2.append("div").attr("class", "search-header");
72921       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72922       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));
72923       if (_autofocus) {
72924         search.node().focus();
72925         setTimeout(function() {
72926           search.node().focus();
72927         }, 0);
72928       }
72929       var listWrap = selection2.append("div").attr("class", "inspector-body");
72930       var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72931       var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
72932       context.features().on("change.preset-list", updateForFeatureHiddenState);
72933     }
72934     function drawList(list2, presets) {
72935       presets = presets.matchAllGeometry(entityGeometries());
72936       var collection = presets.collection.reduce(function(collection2, preset) {
72937         if (!preset)
72938           return collection2;
72939         if (preset.members) {
72940           if (preset.members.collection.filter(function(preset2) {
72941             return preset2.addable();
72942           }).length > 1) {
72943             collection2.push(CategoryItem(preset));
72944           }
72945         } else if (preset.addable()) {
72946           collection2.push(PresetItem(preset));
72947         }
72948         return collection2;
72949       }, []);
72950       var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
72951         return d2.preset.id;
72952       });
72953       items.order();
72954       items.exit().remove();
72955       items.enter().append("div").attr("class", function(item) {
72956         return "preset-list-item preset-" + item.preset.id.replace("/", "-");
72957       }).classed("current", function(item) {
72958         return _currentPresets.indexOf(item.preset) !== -1;
72959       }).each(function(item) {
72960         select_default2(this).call(item);
72961       }).style("opacity", 0).transition().style("opacity", 1);
72962       updateForFeatureHiddenState();
72963     }
72964     function itemKeydown(d3_event) {
72965       var item = select_default2(this.closest(".preset-list-item"));
72966       var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
72967       if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
72968         d3_event.preventDefault();
72969         d3_event.stopPropagation();
72970         var nextItem = select_default2(item.node().nextElementSibling);
72971         if (nextItem.empty()) {
72972           if (!parentItem.empty()) {
72973             nextItem = select_default2(parentItem.node().nextElementSibling);
72974           }
72975         } else if (select_default2(this).classed("expanded")) {
72976           nextItem = item.select(".subgrid .preset-list-item:first-child");
72977         }
72978         if (!nextItem.empty()) {
72979           nextItem.select(".preset-list-button").node().focus();
72980         }
72981       } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
72982         d3_event.preventDefault();
72983         d3_event.stopPropagation();
72984         var previousItem = select_default2(item.node().previousElementSibling);
72985         if (previousItem.empty()) {
72986           if (!parentItem.empty()) {
72987             previousItem = parentItem;
72988           }
72989         } else if (previousItem.select(".preset-list-button").classed("expanded")) {
72990           previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
72991         }
72992         if (!previousItem.empty()) {
72993           previousItem.select(".preset-list-button").node().focus();
72994         } else {
72995           var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
72996           search.node().focus();
72997         }
72998       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
72999         d3_event.preventDefault();
73000         d3_event.stopPropagation();
73001         if (!parentItem.empty()) {
73002           parentItem.select(".preset-list-button").node().focus();
73003         }
73004       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
73005         d3_event.preventDefault();
73006         d3_event.stopPropagation();
73007         item.datum().choose.call(select_default2(this).node());
73008       }
73009     }
73010     function CategoryItem(preset) {
73011       var box, sublist, shown = false;
73012       function item(selection2) {
73013         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
73014         function click() {
73015           var isExpanded = select_default2(this).classed("expanded");
73016           var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
73017           select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
73018           select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
73019           item.choose();
73020         }
73021         var geometries = entityGeometries();
73022         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) {
73023           if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
73024             d3_event.preventDefault();
73025             d3_event.stopPropagation();
73026             if (!select_default2(this).classed("expanded")) {
73027               click.call(this, d3_event);
73028             }
73029           } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
73030             d3_event.preventDefault();
73031             d3_event.stopPropagation();
73032             if (select_default2(this).classed("expanded")) {
73033               click.call(this, d3_event);
73034             }
73035           } else {
73036             itemKeydown.call(this, d3_event);
73037           }
73038         });
73039         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73040         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");
73041         box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
73042         box.append("div").attr("class", "arrow");
73043         sublist = box.append("div").attr("class", "preset-list fillL3");
73044       }
73045       item.choose = function() {
73046         if (!box || !sublist)
73047           return;
73048         if (shown) {
73049           shown = false;
73050           box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
73051         } else {
73052           shown = true;
73053           var members = preset.members.matchAllGeometry(entityGeometries());
73054           sublist.call(drawList, members);
73055           box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
73056         }
73057       };
73058       item.preset = preset;
73059       return item;
73060     }
73061     function PresetItem(preset) {
73062       function item(selection2) {
73063         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
73064         var geometries = entityGeometries();
73065         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);
73066         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73067         var nameparts = [
73068           preset.nameLabel(),
73069           preset.subtitleLabel()
73070         ].filter(Boolean);
73071         label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
73072           d2(select_default2(this));
73073         });
73074         wrap2.call(item.reference.button);
73075         selection2.call(item.reference.body);
73076       }
73077       item.choose = function() {
73078         if (select_default2(this).classed("disabled"))
73079           return;
73080         if (!context.inIntro()) {
73081           _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
73082         }
73083         context.perform(
73084           function(graph) {
73085             for (var i3 in _entityIDs) {
73086               var entityID = _entityIDs[i3];
73087               var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
73088               graph = actionChangePreset(entityID, oldPreset, preset)(graph);
73089             }
73090             return graph;
73091           },
73092           _t("operations.change_tags.annotation")
73093         );
73094         context.validator().validate();
73095         dispatch14.call("choose", this, preset);
73096       };
73097       item.help = function(d3_event) {
73098         d3_event.stopPropagation();
73099         item.reference.toggle();
73100       };
73101       item.preset = preset;
73102       item.reference = uiTagReference(preset.reference(), context);
73103       return item;
73104     }
73105     function updateForFeatureHiddenState() {
73106       if (!_entityIDs.every(context.hasEntity))
73107         return;
73108       var geometries = entityGeometries();
73109       var button = context.container().selectAll(".preset-list .preset-list-button");
73110       button.call(uiTooltip().destroyAny);
73111       button.each(function(item, index) {
73112         var hiddenPresetFeaturesId;
73113         for (var i3 in geometries) {
73114           hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
73115           if (hiddenPresetFeaturesId)
73116             break;
73117         }
73118         var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
73119         select_default2(this).classed("disabled", isHiddenPreset);
73120         if (isHiddenPreset) {
73121           var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
73122           select_default2(this).call(
73123             uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
73124               features: _t("feature." + hiddenPresetFeaturesId + ".description")
73125             })).placement(index < 2 ? "bottom" : "top")
73126           );
73127         }
73128       });
73129     }
73130     presetList.autofocus = function(val) {
73131       if (!arguments.length)
73132         return _autofocus;
73133       _autofocus = val;
73134       return presetList;
73135     };
73136     presetList.entityIDs = function(val) {
73137       if (!arguments.length)
73138         return _entityIDs;
73139       _entityIDs = val;
73140       _currLoc = null;
73141       if (_entityIDs && _entityIDs.length) {
73142         const extent = _entityIDs.reduce(function(extent2, entityID) {
73143           var entity = context.graph().entity(entityID);
73144           return extent2.extend(entity.extent(context.graph()));
73145         }, geoExtent());
73146         _currLoc = extent.center();
73147         var presets = _entityIDs.map(function(entityID) {
73148           return _mainPresetIndex.match(context.entity(entityID), context.graph());
73149         });
73150         presetList.presets(presets);
73151       }
73152       return presetList;
73153     };
73154     presetList.presets = function(val) {
73155       if (!arguments.length)
73156         return _currentPresets;
73157       _currentPresets = val;
73158       return presetList;
73159     };
73160     function entityGeometries() {
73161       var counts = {};
73162       for (var i3 in _entityIDs) {
73163         var entityID = _entityIDs[i3];
73164         var entity = context.entity(entityID);
73165         var geometry = entity.geometry(context.graph());
73166         if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
73167           geometry = "point";
73168         }
73169         if (!counts[geometry])
73170           counts[geometry] = 0;
73171         counts[geometry] += 1;
73172       }
73173       return Object.keys(counts).sort(function(geom1, geom2) {
73174         return counts[geom2] - counts[geom1];
73175       });
73176     }
73177     return utilRebind(presetList, dispatch14, "on");
73178   }
73179
73180   // modules/ui/inspector.js
73181   function uiInspector(context) {
73182     var presetList = uiPresetList(context);
73183     var entityEditor = uiEntityEditor(context);
73184     var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
73185     var _state = "select";
73186     var _entityIDs;
73187     var _newFeature = false;
73188     function inspector(selection2) {
73189       presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
73190         inspector.setPreset();
73191       });
73192       entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
73193       wrap2 = selection2.selectAll(".panewrap").data([0]);
73194       var enter = wrap2.enter().append("div").attr("class", "panewrap");
73195       enter.append("div").attr("class", "preset-list-pane pane");
73196       enter.append("div").attr("class", "entity-editor-pane pane");
73197       wrap2 = wrap2.merge(enter);
73198       presetPane = wrap2.selectAll(".preset-list-pane");
73199       editorPane = wrap2.selectAll(".entity-editor-pane");
73200       function shouldDefaultToPresetList() {
73201         if (_state !== "select")
73202           return false;
73203         if (_entityIDs.length !== 1)
73204           return false;
73205         var entityID = _entityIDs[0];
73206         var entity = context.hasEntity(entityID);
73207         if (!entity)
73208           return false;
73209         if (entity.hasNonGeometryTags())
73210           return false;
73211         if (_newFeature)
73212           return true;
73213         if (entity.geometry(context.graph()) !== "vertex")
73214           return false;
73215         if (context.graph().parentRelations(entity).length)
73216           return false;
73217         if (context.validator().getEntityIssues(entityID).length)
73218           return false;
73219         if (entity.isHighwayIntersection(context.graph()))
73220           return false;
73221         return true;
73222       }
73223       if (shouldDefaultToPresetList()) {
73224         wrap2.style("right", "-100%");
73225         editorPane.classed("hide", true);
73226         presetPane.classed("hide", false).call(presetList);
73227       } else {
73228         wrap2.style("right", "0%");
73229         presetPane.classed("hide", true);
73230         editorPane.classed("hide", false).call(entityEditor);
73231       }
73232       var footer = selection2.selectAll(".footer").data([0]);
73233       footer = footer.enter().append("div").attr("class", "footer").merge(footer);
73234       footer.call(
73235         uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
73236       );
73237     }
73238     inspector.showList = function(presets) {
73239       presetPane.classed("hide", false);
73240       wrap2.transition().styleTween("right", function() {
73241         return value_default("0%", "-100%");
73242       }).on("end", function() {
73243         editorPane.classed("hide", true);
73244       });
73245       if (presets) {
73246         presetList.presets(presets);
73247       }
73248       presetPane.call(presetList.autofocus(true));
73249     };
73250     inspector.setPreset = function(preset) {
73251       if (preset && preset.id === "type/multipolygon") {
73252         presetPane.call(presetList.autofocus(true));
73253       } else {
73254         editorPane.classed("hide", false);
73255         wrap2.transition().styleTween("right", function() {
73256           return value_default("-100%", "0%");
73257         }).on("end", function() {
73258           presetPane.classed("hide", true);
73259         });
73260         if (preset) {
73261           entityEditor.presets([preset]);
73262         }
73263         editorPane.call(entityEditor);
73264       }
73265     };
73266     inspector.state = function(val) {
73267       if (!arguments.length)
73268         return _state;
73269       _state = val;
73270       entityEditor.state(_state);
73271       context.container().selectAll(".field-help-body").remove();
73272       return inspector;
73273     };
73274     inspector.entityIDs = function(val) {
73275       if (!arguments.length)
73276         return _entityIDs;
73277       _entityIDs = val;
73278       return inspector;
73279     };
73280     inspector.newFeature = function(val) {
73281       if (!arguments.length)
73282         return _newFeature;
73283       _newFeature = val;
73284       return inspector;
73285     };
73286     return inspector;
73287   }
73288
73289   // modules/ui/lasso.js
73290   function uiLasso(context) {
73291     var group, polygon2;
73292     lasso.coordinates = [];
73293     function lasso(selection2) {
73294       context.container().classed("lasso", true);
73295       group = selection2.append("g").attr("class", "lasso hide");
73296       polygon2 = group.append("path").attr("class", "lasso-path");
73297       group.call(uiToggle(true));
73298     }
73299     function draw() {
73300       if (polygon2) {
73301         polygon2.data([lasso.coordinates]).attr("d", function(d2) {
73302           return "M" + d2.join(" L") + " Z";
73303         });
73304       }
73305     }
73306     lasso.extent = function() {
73307       return lasso.coordinates.reduce(function(extent, point2) {
73308         return extent.extend(geoExtent(point2));
73309       }, geoExtent());
73310     };
73311     lasso.p = function(_2) {
73312       if (!arguments.length)
73313         return lasso;
73314       lasso.coordinates.push(_2);
73315       draw();
73316       return lasso;
73317     };
73318     lasso.close = function() {
73319       if (group) {
73320         group.call(uiToggle(false, function() {
73321           select_default2(this).remove();
73322         }));
73323       }
73324       context.container().classed("lasso", false);
73325     };
73326     return lasso;
73327   }
73328
73329   // modules/ui/source_switch.js
73330   function uiSourceSwitch(context) {
73331     var keys2;
73332     function click(d3_event) {
73333       d3_event.preventDefault();
73334       var osm = context.connection();
73335       if (!osm)
73336         return;
73337       if (context.inIntro())
73338         return;
73339       if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes")))
73340         return;
73341       var isLive = select_default2(this).classed("live");
73342       isLive = !isLive;
73343       context.enter(modeBrowse(context));
73344       context.history().clearSaved();
73345       context.flush();
73346       select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
73347       osm.switch(isLive ? keys2[0] : keys2[1]);
73348     }
73349     var sourceSwitch = function(selection2) {
73350       selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
73351     };
73352     sourceSwitch.keys = function(_2) {
73353       if (!arguments.length)
73354         return keys2;
73355       keys2 = _2;
73356       return sourceSwitch;
73357     };
73358     return sourceSwitch;
73359   }
73360
73361   // modules/ui/spinner.js
73362   function uiSpinner(context) {
73363     var osm = context.connection();
73364     return function(selection2) {
73365       var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
73366       if (osm) {
73367         osm.on("loading.spinner", function() {
73368           img.transition().style("opacity", 1);
73369         }).on("loaded.spinner", function() {
73370           img.transition().style("opacity", 0);
73371         });
73372       }
73373     };
73374   }
73375
73376   // modules/ui/sections/privacy.js
73377   function uiSectionPrivacy(context) {
73378     let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
73379     function renderDisclosureContent(selection2) {
73380       selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
73381       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(
73382         uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
73383       );
73384       thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
73385         d3_event.preventDefault();
73386         corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
73387       });
73388       thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
73389       selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
73390       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"));
73391     }
73392     corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
73393     return section;
73394   }
73395
73396   // modules/ui/splash.js
73397   function uiSplash(context) {
73398     return (selection2) => {
73399       if (context.history().hasRestorableChanges())
73400         return;
73401       let updateMessage = "";
73402       const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
73403       let showSplash = !corePreferences("sawSplash");
73404       if (sawPrivacyVersion !== context.privacyVersion) {
73405         updateMessage = _t("splash.privacy_update");
73406         showSplash = true;
73407       }
73408       if (!showSplash)
73409         return;
73410       corePreferences("sawSplash", true);
73411       corePreferences("sawPrivacyVersion", context.privacyVersion);
73412       _mainFileFetcher.get("intro_graph");
73413       let modalSelection = uiModal(selection2);
73414       modalSelection.select(".modal").attr("class", "modal-splash modal");
73415       let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
73416       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
73417       let modalSection = introModal.append("div").attr("class", "modal-section");
73418       modalSection.append("p").html(_t.html("splash.text", {
73419         version: context.version,
73420         website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
73421         github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
73422       }));
73423       modalSection.append("p").html(_t.html("splash.privacy", {
73424         updateMessage,
73425         privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
73426       }));
73427       uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
73428       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
73429       let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
73430         context.container().call(uiIntro(context));
73431         modalSelection.close();
73432       });
73433       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
73434       walkthrough.append("div").call(_t.append("splash.walkthrough"));
73435       let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
73436       startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
73437       startEditing.append("div").call(_t.append("splash.start"));
73438       modalSelection.select("button.close").attr("class", "hide");
73439     };
73440   }
73441
73442   // modules/ui/status.js
73443   function uiStatus(context) {
73444     var osm = context.connection();
73445     return function(selection2) {
73446       if (!osm)
73447         return;
73448       function update(err, apiStatus) {
73449         selection2.html("");
73450         if (err) {
73451           if (apiStatus === "connectionSwitched") {
73452             return;
73453           } else if (apiStatus === "rateLimited") {
73454             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) {
73455               d3_event.preventDefault();
73456               osm.authenticate();
73457             });
73458           } else {
73459             var throttledRetry = throttle_default(function() {
73460               context.loadTiles(context.projection);
73461               osm.reloadApiStatus();
73462             }, 2e3);
73463             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) {
73464               d3_event.preventDefault();
73465               throttledRetry();
73466             });
73467           }
73468         } else if (apiStatus === "readonly") {
73469           selection2.call(_t.append("osm_api_status.message.readonly"));
73470         } else if (apiStatus === "offline") {
73471           selection2.call(_t.append("osm_api_status.message.offline"));
73472         }
73473         selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
73474       }
73475       osm.on("apiStatusChange.uiStatus", update);
73476       context.history().on("storage_error", () => {
73477         selection2.selectAll("span.local-storage-full").remove();
73478         selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
73479         selection2.classed("error", true);
73480       });
73481       window.setInterval(function() {
73482         osm.reloadApiStatus();
73483       }, 9e4);
73484       osm.reloadApiStatus();
73485     };
73486   }
73487
73488   // modules/ui/version.js
73489   var sawVersion = null;
73490   var isNewVersion = false;
73491   var isNewUser = false;
73492   function uiVersion(context) {
73493     var currVersion = context.version;
73494     var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
73495     if (sawVersion === null && matchedVersion !== null) {
73496       if (corePreferences("sawVersion")) {
73497         isNewUser = false;
73498         isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
73499       } else {
73500         isNewUser = true;
73501         isNewVersion = true;
73502       }
73503       corePreferences("sawVersion", currVersion);
73504       sawVersion = currVersion;
73505     }
73506     return function(selection2) {
73507       selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
73508       if (isNewVersion && !isNewUser) {
73509         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(
73510           uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
73511         );
73512       }
73513     };
73514   }
73515
73516   // modules/ui/zoom.js
73517   function uiZoom(context) {
73518     var zooms = [{
73519       id: "zoom-in",
73520       icon: "iD-icon-plus",
73521       title: _t.append("zoom.in"),
73522       action: zoomIn,
73523       disabled: function() {
73524         return !context.map().canZoomIn();
73525       },
73526       disabledTitle: _t.append("zoom.disabled.in"),
73527       key: "+"
73528     }, {
73529       id: "zoom-out",
73530       icon: "iD-icon-minus",
73531       title: _t.append("zoom.out"),
73532       action: zoomOut,
73533       disabled: function() {
73534         return !context.map().canZoomOut();
73535       },
73536       disabledTitle: _t.append("zoom.disabled.out"),
73537       key: "-"
73538     }];
73539     function zoomIn(d3_event) {
73540       if (d3_event.shiftKey)
73541         return;
73542       d3_event.preventDefault();
73543       context.map().zoomIn();
73544     }
73545     function zoomOut(d3_event) {
73546       if (d3_event.shiftKey)
73547         return;
73548       d3_event.preventDefault();
73549       context.map().zoomOut();
73550     }
73551     function zoomInFurther(d3_event) {
73552       if (d3_event.shiftKey)
73553         return;
73554       d3_event.preventDefault();
73555       context.map().zoomInFurther();
73556     }
73557     function zoomOutFurther(d3_event) {
73558       if (d3_event.shiftKey)
73559         return;
73560       d3_event.preventDefault();
73561       context.map().zoomOutFurther();
73562     }
73563     return function(selection2) {
73564       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
73565         if (d2.disabled()) {
73566           return d2.disabledTitle;
73567         }
73568         return d2.title;
73569       }).keys(function(d2) {
73570         return [d2.key];
73571       });
73572       var lastPointerUpType;
73573       var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
73574         return d2.id;
73575       }).on("pointerup.editor", function(d3_event) {
73576         lastPointerUpType = d3_event.pointerType;
73577       }).on("click.editor", function(d3_event, d2) {
73578         if (!d2.disabled()) {
73579           d2.action(d3_event);
73580         } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
73581           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
73582         }
73583         lastPointerUpType = null;
73584       }).call(tooltipBehavior);
73585       buttons.each(function(d2) {
73586         select_default2(this).call(svgIcon("#" + d2.icon, "light"));
73587       });
73588       utilKeybinding.plusKeys.forEach(function(key) {
73589         context.keybinding().on([key], zoomIn);
73590         context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
73591       });
73592       utilKeybinding.minusKeys.forEach(function(key) {
73593         context.keybinding().on([key], zoomOut);
73594         context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
73595       });
73596       function updateButtonStates() {
73597         buttons.classed("disabled", function(d2) {
73598           return d2.disabled();
73599         }).each(function() {
73600           var selection3 = select_default2(this);
73601           if (!selection3.select(".tooltip.in").empty()) {
73602             selection3.call(tooltipBehavior.updateContent);
73603           }
73604         });
73605       }
73606       updateButtonStates();
73607       context.map().on("move.uiZoom", updateButtonStates);
73608     };
73609   }
73610
73611   // modules/ui/sections/raw_tag_editor.js
73612   function uiSectionRawTagEditor(id2, context) {
73613     var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
73614       var count = Object.keys(_tags).filter(function(d2) {
73615         return d2;
73616       }).length;
73617       return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
73618     }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
73619     var taginfo = services.taginfo;
73620     var dispatch14 = dispatch_default("change");
73621     var availableViews = [
73622       { id: "list", icon: "#fas-th-list" },
73623       { id: "text", icon: "#fas-i-cursor" }
73624     ];
73625     let _discardTags = {};
73626     _mainFileFetcher.get("discarded").then((d2) => {
73627       _discardTags = d2;
73628     }).catch(() => {
73629     });
73630     var _tagView = corePreferences("raw-tag-editor-view") || "list";
73631     var _readOnlyTags = [];
73632     var _orderedKeys = [];
73633     var _showBlank = false;
73634     var _pendingChange = null;
73635     var _state;
73636     var _presets;
73637     var _tags;
73638     var _entityIDs;
73639     var _didInteract = false;
73640     function interacted() {
73641       _didInteract = true;
73642     }
73643     function renderDisclosureContent(wrap2) {
73644       _orderedKeys = _orderedKeys.filter(function(key) {
73645         return _tags[key] !== void 0;
73646       });
73647       var all = Object.keys(_tags).sort();
73648       var missingKeys = utilArrayDifference(all, _orderedKeys);
73649       for (var i3 in missingKeys) {
73650         _orderedKeys.push(missingKeys[i3]);
73651       }
73652       var rowData = _orderedKeys.map(function(key, i4) {
73653         return { index: i4, key, value: _tags[key] };
73654       });
73655       if (!rowData.length || _showBlank) {
73656         _showBlank = false;
73657         rowData.push({ index: rowData.length, key: "", value: "" });
73658       }
73659       var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
73660       options2.exit().remove();
73661       var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
73662       var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
73663         return d2.id;
73664       }).enter();
73665       optionEnter.append("button").attr("class", function(d2) {
73666         return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
73667       }).attr("aria-selected", function(d2) {
73668         return _tagView === d2.id;
73669       }).attr("role", "tab").attr("title", function(d2) {
73670         return _t("icons." + d2.id);
73671       }).on("click", function(d3_event, d2) {
73672         _tagView = d2.id;
73673         corePreferences("raw-tag-editor-view", d2.id);
73674         wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
73675           return datum2 === d2;
73676         }).attr("aria-selected", function(datum2) {
73677           return datum2 === d2;
73678         });
73679         wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
73680         wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
73681       }).each(function(d2) {
73682         select_default2(this).call(svgIcon(d2.icon));
73683       });
73684       var textData = rowsToText(rowData);
73685       var textarea = wrap2.selectAll(".tag-text").data([0]);
73686       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);
73687       textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
73688       var list2 = wrap2.selectAll(".tag-list").data([0]);
73689       list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
73690       var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
73691       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);
73692       addRowEnter.append("div").attr("class", "space-value");
73693       addRowEnter.append("div").attr("class", "space-buttons");
73694       var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
73695         return d2.key;
73696       });
73697       items.exit().each(unbind).remove();
73698       var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
73699       var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
73700       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);
73701       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);
73702       innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
73703       items = items.merge(itemsEnter).sort(function(a2, b2) {
73704         return a2.index - b2.index;
73705       });
73706       items.each(function(d2) {
73707         var row = select_default2(this);
73708         var key = row.select("input.key");
73709         var value = row.select("input.value");
73710         if (_entityIDs && taginfo && _state !== "hover") {
73711           bindTypeahead(key, value);
73712         }
73713         var referenceOptions = { key: d2.key };
73714         if (typeof d2.value === "string") {
73715           referenceOptions.value = d2.value;
73716         }
73717         var reference = uiTagReference(referenceOptions, context);
73718         if (_state === "hover") {
73719           reference.showing(false);
73720         }
73721         row.select(".inner-wrap").call(reference.button);
73722         row.call(reference.body);
73723         row.select("button.remove");
73724       });
73725       items.selectAll("input.key").attr("title", function(d2) {
73726         return d2.key;
73727       }).call(utilGetSetValue, function(d2) {
73728         return d2.key;
73729       }).attr("readonly", function(d2) {
73730         return isReadOnly(d2) || null;
73731       });
73732       items.selectAll("input.value").attr("title", function(d2) {
73733         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
73734       }).classed("mixed", function(d2) {
73735         return Array.isArray(d2.value);
73736       }).attr("placeholder", function(d2) {
73737         return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
73738       }).call(utilGetSetValue, function(d2) {
73739         return typeof d2.value === "string" ? d2.value : "";
73740       }).attr("readonly", function(d2) {
73741         return isReadOnly(d2) || null;
73742       });
73743       items.selectAll("button.remove").on(
73744         ("PointerEvent" in window ? "pointer" : "mouse") + "down",
73745         // 'click' fires too late - #5878
73746         (d3_event, d2) => {
73747           if (d3_event.button !== 0)
73748             return;
73749           removeTag(d3_event, d2);
73750         }
73751       );
73752     }
73753     function isReadOnly(d2) {
73754       for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
73755         if (d2.key.match(_readOnlyTags[i3]) !== null) {
73756           return true;
73757         }
73758       }
73759       return false;
73760     }
73761     function setTextareaHeight() {
73762       if (_tagView !== "text")
73763         return;
73764       var selection2 = select_default2(this);
73765       var matches = selection2.node().value.match(/\n/g);
73766       var lineCount = 2 + Number(matches && matches.length);
73767       var lineHeight = 20;
73768       selection2.style("height", lineCount * lineHeight + "px");
73769     }
73770     function stringify3(s2) {
73771       return JSON.stringify(s2).slice(1, -1);
73772     }
73773     function unstringify(s2) {
73774       var leading = "";
73775       var trailing = "";
73776       if (s2.length < 1 || s2.charAt(0) !== '"') {
73777         leading = '"';
73778       }
73779       if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") {
73780         trailing = '"';
73781       }
73782       return JSON.parse(leading + s2 + trailing);
73783     }
73784     function rowsToText(rows) {
73785       var str = rows.filter(function(row) {
73786         return row.key && row.key.trim() !== "";
73787       }).map(function(row) {
73788         var rawVal = row.value;
73789         if (typeof rawVal !== "string")
73790           rawVal = "*";
73791         var val = rawVal ? stringify3(rawVal) : "";
73792         return stringify3(row.key) + "=" + val;
73793       }).join("\n");
73794       if (_state !== "hover" && str.length) {
73795         return str + "\n";
73796       }
73797       return str;
73798     }
73799     function textChanged() {
73800       var newText = this.value.trim();
73801       var newTags = {};
73802       newText.split("\n").forEach(function(row) {
73803         var m2 = row.match(/^\s*([^=]+)=(.*)$/);
73804         if (m2 !== null) {
73805           var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
73806           var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
73807           newTags[k2] = v2;
73808         }
73809       });
73810       var tagDiff = utilTagDiff(_tags, newTags);
73811       if (!tagDiff.length)
73812         return;
73813       _pendingChange = _pendingChange || {};
73814       tagDiff.forEach(function(change) {
73815         if (isReadOnly({ key: change.key }))
73816           return;
73817         if (change.newVal === "*" && typeof change.oldVal !== "string")
73818           return;
73819         if (change.type === "-") {
73820           _pendingChange[change.key] = void 0;
73821         } else if (change.type === "+") {
73822           _pendingChange[change.key] = change.newVal || "";
73823         }
73824       });
73825       if (Object.keys(_pendingChange).length === 0) {
73826         _pendingChange = null;
73827         return;
73828       }
73829       scheduleChange();
73830     }
73831     function pushMore(d3_event) {
73832       if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
73833         addTag();
73834       }
73835     }
73836     function bindTypeahead(key, value) {
73837       if (isReadOnly(key.datum()))
73838         return;
73839       if (Array.isArray(value.datum().value)) {
73840         value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
73841           var keyString = utilGetSetValue(key);
73842           if (!_tags[keyString])
73843             return;
73844           var data = _tags[keyString].map(function(tagValue) {
73845             if (!tagValue) {
73846               return {
73847                 value: " ",
73848                 title: _t("inspector.empty"),
73849                 display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
73850               };
73851             }
73852             return {
73853               value: tagValue,
73854               title: tagValue
73855             };
73856           });
73857           callback(data);
73858         }));
73859         return;
73860       }
73861       var geometry = context.graph().geometry(_entityIDs[0]);
73862       key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
73863         taginfo.keys({
73864           debounce: true,
73865           geometry,
73866           query: value2
73867         }, function(err, data) {
73868           if (!err) {
73869             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()));
73870             callback(sort(value2, filtered));
73871           }
73872         });
73873       }));
73874       value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
73875         taginfo.values({
73876           debounce: true,
73877           key: utilGetSetValue(key),
73878           geometry,
73879           query: value2
73880         }, function(err, data) {
73881           if (!err) {
73882             const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
73883             callback(sort(value2, filtered));
73884           }
73885         });
73886       }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
73887       function sort(value2, data) {
73888         var sameletter = [];
73889         var other = [];
73890         for (var i3 = 0; i3 < data.length; i3++) {
73891           if (data[i3].value.substring(0, value2.length) === value2) {
73892             sameletter.push(data[i3]);
73893           } else {
73894             other.push(data[i3]);
73895           }
73896         }
73897         return sameletter.concat(other);
73898       }
73899     }
73900     function unbind() {
73901       var row = select_default2(this);
73902       row.selectAll("input.key").call(uiCombobox.off, context);
73903       row.selectAll("input.value").call(uiCombobox.off, context);
73904     }
73905     function keyChange(d3_event, d2) {
73906       if (select_default2(this).attr("readonly"))
73907         return;
73908       var kOld = d2.key;
73909       if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0)
73910         return;
73911       var kNew = context.cleanTagKey(this.value.trim());
73912       if (isReadOnly({ key: kNew })) {
73913         this.value = kOld;
73914         return;
73915       }
73916       if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
73917         this.value = kOld;
73918         section.selection().selectAll(".tag-list input.value").each(function(d4) {
73919           if (d4.key === kNew) {
73920             var input = select_default2(this).node();
73921             input.focus();
73922             input.select();
73923           }
73924         });
73925         return;
73926       }
73927       _pendingChange = _pendingChange || {};
73928       if (kOld) {
73929         if (kOld === kNew)
73930           return;
73931         _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
73932         _pendingChange[kOld] = void 0;
73933       } else {
73934         let row = this.parentNode.parentNode;
73935         let inputVal = select_default2(row).selectAll("input.value");
73936         let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
73937         _pendingChange[kNew] = vNew;
73938         utilGetSetValue(inputVal, vNew);
73939       }
73940       var existingKeyIndex = _orderedKeys.indexOf(kOld);
73941       if (existingKeyIndex !== -1)
73942         _orderedKeys[existingKeyIndex] = kNew;
73943       d2.key = kNew;
73944       this.value = kNew;
73945       scheduleChange();
73946     }
73947     function valueChange(d3_event, d2) {
73948       if (isReadOnly(d2))
73949         return;
73950       if (typeof d2.value !== "string" && !this.value)
73951         return;
73952       if (!this.value.trim())
73953         return removeTag(d3_event, d2);
73954       if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0)
73955         return;
73956       _pendingChange = _pendingChange || {};
73957       _pendingChange[d2.key] = context.cleanTagValue(this.value);
73958       scheduleChange();
73959     }
73960     function removeTag(d3_event, d2) {
73961       if (isReadOnly(d2))
73962         return;
73963       if (d2.key === "") {
73964         _showBlank = false;
73965         section.reRender();
73966       } else {
73967         _orderedKeys = _orderedKeys.filter(function(key) {
73968           return key !== d2.key;
73969         });
73970         _pendingChange = _pendingChange || {};
73971         _pendingChange[d2.key] = void 0;
73972         scheduleChange();
73973       }
73974     }
73975     function addTag() {
73976       window.setTimeout(function() {
73977         _showBlank = true;
73978         section.reRender();
73979         section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
73980       }, 20);
73981     }
73982     function scheduleChange() {
73983       var entityIDs = _entityIDs;
73984       window.setTimeout(function() {
73985         if (!_pendingChange)
73986           return;
73987         dispatch14.call("change", this, entityIDs, _pendingChange);
73988         _pendingChange = null;
73989       }, 10);
73990     }
73991     section.state = function(val) {
73992       if (!arguments.length)
73993         return _state;
73994       if (_state !== val) {
73995         _orderedKeys = [];
73996         _state = val;
73997       }
73998       return section;
73999     };
74000     section.presets = function(val) {
74001       if (!arguments.length)
74002         return _presets;
74003       _presets = val;
74004       if (_presets && _presets.length && _presets[0].isFallback()) {
74005         section.disclosureExpanded(true);
74006       } else if (!_didInteract) {
74007         section.disclosureExpanded(null);
74008       }
74009       return section;
74010     };
74011     section.tags = function(val) {
74012       if (!arguments.length)
74013         return _tags;
74014       _tags = val;
74015       return section;
74016     };
74017     section.entityIDs = function(val) {
74018       if (!arguments.length)
74019         return _entityIDs;
74020       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
74021         _entityIDs = val;
74022         _orderedKeys = [];
74023       }
74024       return section;
74025     };
74026     section.readOnlyTags = function(val) {
74027       if (!arguments.length)
74028         return _readOnlyTags;
74029       _readOnlyTags = val;
74030       return section;
74031     };
74032     return utilRebind(section, dispatch14, "on");
74033   }
74034
74035   // modules/ui/data_editor.js
74036   function uiDataEditor(context) {
74037     var dataHeader = uiDataHeader();
74038     var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
74039     var _datum;
74040     function dataEditor(selection2) {
74041       var header = selection2.selectAll(".header").data([0]);
74042       var headerEnter = header.enter().append("div").attr("class", "header fillL");
74043       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
74044         context.enter(modeBrowse(context));
74045       }).call(svgIcon("#iD-icon-close"));
74046       headerEnter.append("h2").call(_t.append("map_data.title"));
74047       var body = selection2.selectAll(".body").data([0]);
74048       body = body.enter().append("div").attr("class", "body").merge(body);
74049       var editor = body.selectAll(".data-editor").data([0]);
74050       editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
74051       var rte = body.selectAll(".raw-tag-editor").data([0]);
74052       rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
74053         rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
74054       ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
74055     }
74056     dataEditor.datum = function(val) {
74057       if (!arguments.length)
74058         return _datum;
74059       _datum = val;
74060       return this;
74061     };
74062     return dataEditor;
74063   }
74064
74065   // modules/ui/sidebar.js
74066   function uiSidebar(context) {
74067     var inspector = uiInspector(context);
74068     var dataEditor = uiDataEditor(context);
74069     var noteEditor = uiNoteEditor(context);
74070     var improveOsmEditor = uiImproveOsmEditor(context);
74071     var keepRightEditor = uiKeepRightEditor(context);
74072     var osmoseEditor = uiOsmoseEditor(context);
74073     var _current;
74074     var _wasData = false;
74075     var _wasNote = false;
74076     var _wasQaItem = false;
74077     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
74078     function sidebar(selection2) {
74079       var container = context.container();
74080       var minWidth = 240;
74081       var sidebarWidth;
74082       var containerWidth;
74083       var dragOffset;
74084       selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
74085       var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
74086       var downPointerId, lastClientX, containerLocGetter;
74087       function pointerdown(d3_event) {
74088         if (downPointerId)
74089           return;
74090         if ("button" in d3_event && d3_event.button !== 0)
74091           return;
74092         downPointerId = d3_event.pointerId || "mouse";
74093         lastClientX = d3_event.clientX;
74094         containerLocGetter = utilFastMouse(container.node());
74095         dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
74096         sidebarWidth = selection2.node().getBoundingClientRect().width;
74097         containerWidth = container.node().getBoundingClientRect().width;
74098         var widthPct = sidebarWidth / containerWidth * 100;
74099         selection2.style("width", widthPct + "%").style("max-width", "85%");
74100         resizer.classed("dragging", true);
74101         select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
74102           d3_event2.preventDefault();
74103         }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
74104       }
74105       function pointermove(d3_event) {
74106         if (downPointerId !== (d3_event.pointerId || "mouse"))
74107           return;
74108         d3_event.preventDefault();
74109         var dx = d3_event.clientX - lastClientX;
74110         lastClientX = d3_event.clientX;
74111         var isRTL = _mainLocalizer.textDirection() === "rtl";
74112         var scaleX = isRTL ? 0 : 1;
74113         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74114         var x2 = containerLocGetter(d3_event)[0] - dragOffset;
74115         sidebarWidth = isRTL ? containerWidth - x2 : x2;
74116         var isCollapsed = selection2.classed("collapsed");
74117         var shouldCollapse = sidebarWidth < minWidth;
74118         selection2.classed("collapsed", shouldCollapse);
74119         if (shouldCollapse) {
74120           if (!isCollapsed) {
74121             selection2.style(xMarginProperty, "-400px").style("width", "400px");
74122             context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
74123           }
74124         } else {
74125           var widthPct = sidebarWidth / containerWidth * 100;
74126           selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74127           if (isCollapsed) {
74128             context.ui().onResize([-sidebarWidth * scaleX, 0]);
74129           } else {
74130             context.ui().onResize([-dx * scaleX, 0]);
74131           }
74132         }
74133       }
74134       function pointerup(d3_event) {
74135         if (downPointerId !== (d3_event.pointerId || "mouse"))
74136           return;
74137         downPointerId = null;
74138         resizer.classed("dragging", false);
74139         select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
74140       }
74141       var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
74142       var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
74143       var hoverModeSelect = function(targets) {
74144         context.container().selectAll(".feature-list-item button").classed("hover", false);
74145         if (context.selectedIDs().length > 1 && targets && targets.length) {
74146           var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
74147             return targets.indexOf(node) !== -1;
74148           });
74149           if (!elements.empty()) {
74150             elements.classed("hover", true);
74151           }
74152         }
74153       };
74154       sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
74155       function hover(targets) {
74156         var datum2 = targets && targets.length && targets[0];
74157         if (datum2 && datum2.__featurehash__) {
74158           _wasData = true;
74159           sidebar.show(dataEditor.datum(datum2));
74160           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74161         } else if (datum2 instanceof osmNote) {
74162           if (context.mode().id === "drag-note")
74163             return;
74164           _wasNote = true;
74165           var osm = services.osm;
74166           if (osm) {
74167             datum2 = osm.getNote(datum2.id);
74168           }
74169           sidebar.show(noteEditor.note(datum2));
74170           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74171         } else if (datum2 instanceof QAItem) {
74172           _wasQaItem = true;
74173           var errService = services[datum2.service];
74174           if (errService) {
74175             datum2 = errService.getError(datum2.id);
74176           }
74177           var errEditor;
74178           if (datum2.service === "keepRight") {
74179             errEditor = keepRightEditor;
74180           } else if (datum2.service === "osmose") {
74181             errEditor = osmoseEditor;
74182           } else {
74183             errEditor = improveOsmEditor;
74184           }
74185           context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
74186             return d2.id === datum2.id;
74187           });
74188           sidebar.show(errEditor.error(datum2));
74189           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74190         } else if (!_current && datum2 instanceof osmEntity) {
74191           featureListWrap.classed("inspector-hidden", true);
74192           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
74193           if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
74194             inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
74195             inspectorWrap.call(inspector);
74196           }
74197         } else if (!_current) {
74198           featureListWrap.classed("inspector-hidden", false);
74199           inspectorWrap.classed("inspector-hidden", true);
74200           inspector.state("hide");
74201         } else if (_wasData || _wasNote || _wasQaItem) {
74202           _wasNote = false;
74203           _wasData = false;
74204           _wasQaItem = false;
74205           context.container().selectAll(".note").classed("hover", false);
74206           context.container().selectAll(".qaItem").classed("hover", false);
74207           sidebar.hide();
74208         }
74209       }
74210       sidebar.hover = throttle_default(hover, 200);
74211       sidebar.intersects = function(extent) {
74212         var rect = selection2.node().getBoundingClientRect();
74213         return extent.intersects([
74214           context.projection.invert([0, rect.height]),
74215           context.projection.invert([rect.width, 0])
74216         ]);
74217       };
74218       sidebar.select = function(ids, newFeature) {
74219         sidebar.hide();
74220         if (ids && ids.length) {
74221           var entity = ids.length === 1 && context.entity(ids[0]);
74222           if (entity && newFeature && selection2.classed("collapsed")) {
74223             var extent = entity.extent(context.graph());
74224             sidebar.expand(sidebar.intersects(extent));
74225           }
74226           featureListWrap.classed("inspector-hidden", true);
74227           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
74228           inspector.state("select").entityIDs(ids).newFeature(newFeature);
74229           inspectorWrap.call(inspector);
74230         } else {
74231           inspector.state("hide");
74232         }
74233       };
74234       sidebar.showPresetList = function() {
74235         inspector.showList();
74236       };
74237       sidebar.show = function(component, element) {
74238         featureListWrap.classed("inspector-hidden", true);
74239         inspectorWrap.classed("inspector-hidden", true);
74240         if (_current)
74241           _current.remove();
74242         _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
74243       };
74244       sidebar.hide = function() {
74245         featureListWrap.classed("inspector-hidden", false);
74246         inspectorWrap.classed("inspector-hidden", true);
74247         if (_current)
74248           _current.remove();
74249         _current = null;
74250       };
74251       sidebar.expand = function(moveMap) {
74252         if (selection2.classed("collapsed")) {
74253           sidebar.toggle(moveMap);
74254         }
74255       };
74256       sidebar.collapse = function(moveMap) {
74257         if (!selection2.classed("collapsed")) {
74258           sidebar.toggle(moveMap);
74259         }
74260       };
74261       sidebar.toggle = function(moveMap) {
74262         if (context.inIntro())
74263           return;
74264         var isCollapsed = selection2.classed("collapsed");
74265         var isCollapsing = !isCollapsed;
74266         var isRTL = _mainLocalizer.textDirection() === "rtl";
74267         var scaleX = isRTL ? 0 : 1;
74268         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74269         sidebarWidth = selection2.node().getBoundingClientRect().width;
74270         selection2.style("width", sidebarWidth + "px");
74271         var startMargin, endMargin, lastMargin;
74272         if (isCollapsing) {
74273           startMargin = lastMargin = 0;
74274           endMargin = -sidebarWidth;
74275         } else {
74276           startMargin = lastMargin = -sidebarWidth;
74277           endMargin = 0;
74278         }
74279         if (!isCollapsing) {
74280           selection2.classed("collapsed", isCollapsing);
74281         }
74282         selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
74283           var i3 = number_default(startMargin, endMargin);
74284           return function(t2) {
74285             var dx = lastMargin - Math.round(i3(t2));
74286             lastMargin = lastMargin - dx;
74287             context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
74288           };
74289         }).on("end", function() {
74290           if (isCollapsing) {
74291             selection2.classed("collapsed", isCollapsing);
74292           }
74293           if (!isCollapsing) {
74294             var containerWidth2 = container.node().getBoundingClientRect().width;
74295             var widthPct = sidebarWidth / containerWidth2 * 100;
74296             selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74297           }
74298         });
74299       };
74300       resizer.on("dblclick", function(d3_event) {
74301         d3_event.preventDefault();
74302         if (d3_event.sourceEvent) {
74303           d3_event.sourceEvent.preventDefault();
74304         }
74305         sidebar.toggle();
74306       });
74307       context.map().on("crossEditableZoom.sidebar", function(within) {
74308         if (!within && !selection2.select(".inspector-hover").empty()) {
74309           hover([]);
74310         }
74311       });
74312     }
74313     sidebar.showPresetList = function() {
74314     };
74315     sidebar.hover = function() {
74316     };
74317     sidebar.hover.cancel = function() {
74318     };
74319     sidebar.intersects = function() {
74320     };
74321     sidebar.select = function() {
74322     };
74323     sidebar.show = function() {
74324     };
74325     sidebar.hide = function() {
74326     };
74327     sidebar.expand = function() {
74328     };
74329     sidebar.collapse = function() {
74330     };
74331     sidebar.toggle = function() {
74332     };
74333     return sidebar;
74334   }
74335
74336   // modules/ui/tools/modes.js
74337   function uiToolDrawModes(context) {
74338     var tool = {
74339       id: "old_modes",
74340       label: _t.append("toolbar.add_feature")
74341     };
74342     var modes = [
74343       modeAddPoint(context, {
74344         title: _t.append("modes.add_point.title"),
74345         button: "point",
74346         description: _t.append("modes.add_point.description"),
74347         preset: _mainPresetIndex.item("point"),
74348         key: "1"
74349       }),
74350       modeAddLine(context, {
74351         title: _t.append("modes.add_line.title"),
74352         button: "line",
74353         description: _t.append("modes.add_line.description"),
74354         preset: _mainPresetIndex.item("line"),
74355         key: "2"
74356       }),
74357       modeAddArea(context, {
74358         title: _t.append("modes.add_area.title"),
74359         button: "area",
74360         description: _t.append("modes.add_area.description"),
74361         preset: _mainPresetIndex.item("area"),
74362         key: "3"
74363       })
74364     ];
74365     function enabled(_mode) {
74366       return osmEditable();
74367     }
74368     function osmEditable() {
74369       return context.editable();
74370     }
74371     modes.forEach(function(mode) {
74372       context.keybinding().on(mode.key, function() {
74373         if (!enabled(mode))
74374           return;
74375         if (mode.id === context.mode().id) {
74376           context.enter(modeBrowse(context));
74377         } else {
74378           context.enter(mode);
74379         }
74380       });
74381     });
74382     tool.render = function(selection2) {
74383       var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
74384       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74385       context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
74386       context.on("enter.modes", update);
74387       update();
74388       function update() {
74389         var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
74390           return d2.id;
74391         });
74392         buttons.exit().remove();
74393         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74394           return d2.id + " add-button bar-button";
74395         }).on("click.mode-buttons", function(d3_event, d2) {
74396           if (!enabled(d2))
74397             return;
74398           var currMode = context.mode().id;
74399           if (/^draw/.test(currMode))
74400             return;
74401           if (d2.id === currMode) {
74402             context.enter(modeBrowse(context));
74403           } else {
74404             context.enter(d2);
74405           }
74406         }).call(
74407           uiTooltip().placement("bottom").title(function(d2) {
74408             return d2.description;
74409           }).keys(function(d2) {
74410             return [d2.key];
74411           }).scrollContainer(context.container().select(".top-toolbar"))
74412         );
74413         buttonsEnter.each(function(d2) {
74414           select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
74415         });
74416         buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
74417           mode.title(select_default2(this));
74418         });
74419         if (buttons.enter().size() || buttons.exit().size()) {
74420           context.ui().checkOverflow(".top-toolbar", true);
74421         }
74422         buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
74423           return !enabled(d2);
74424         }).classed("disabled", function(d2) {
74425           return !enabled(d2);
74426         }).attr("aria-pressed", function(d2) {
74427           return context.mode() && context.mode().button === d2.button;
74428         }).classed("active", function(d2) {
74429           return context.mode() && context.mode().button === d2.button;
74430         });
74431       }
74432     };
74433     return tool;
74434   }
74435
74436   // modules/ui/tools/notes.js
74437   function uiToolNotes(context) {
74438     var tool = {
74439       id: "notes",
74440       label: _t.append("modes.add_note.label")
74441     };
74442     var mode = modeAddNote(context);
74443     function enabled() {
74444       return notesEnabled() && notesEditable();
74445     }
74446     function notesEnabled() {
74447       var noteLayer = context.layers().layer("notes");
74448       return noteLayer && noteLayer.enabled();
74449     }
74450     function notesEditable() {
74451       var mode2 = context.mode();
74452       return context.map().notesEditable() && mode2 && mode2.id !== "save";
74453     }
74454     context.keybinding().on(mode.key, function() {
74455       if (!enabled())
74456         return;
74457       if (mode.id === context.mode().id) {
74458         context.enter(modeBrowse(context));
74459       } else {
74460         context.enter(mode);
74461       }
74462     });
74463     tool.render = function(selection2) {
74464       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74465       context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
74466       context.on("enter.notes", update);
74467       update();
74468       function update() {
74469         var showNotes = notesEnabled();
74470         var data = showNotes ? [mode] : [];
74471         var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
74472           return d2.id;
74473         });
74474         buttons.exit().remove();
74475         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74476           return d2.id + " add-button bar-button";
74477         }).on("click.notes", function(d3_event, d2) {
74478           if (!enabled())
74479             return;
74480           var currMode = context.mode().id;
74481           if (/^draw/.test(currMode))
74482             return;
74483           if (d2.id === currMode) {
74484             context.enter(modeBrowse(context));
74485           } else {
74486             context.enter(d2);
74487           }
74488         }).call(
74489           uiTooltip().placement("bottom").title(function(d2) {
74490             return d2.description;
74491           }).keys(function(d2) {
74492             return [d2.key];
74493           }).scrollContainer(context.container().select(".top-toolbar"))
74494         );
74495         buttonsEnter.each(function(d2) {
74496           select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
74497         });
74498         if (buttons.enter().size() || buttons.exit().size()) {
74499           context.ui().checkOverflow(".top-toolbar", true);
74500         }
74501         buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
74502           return !enabled();
74503         }).attr("aria-disabled", function() {
74504           return !enabled();
74505         }).classed("active", function(d2) {
74506           return context.mode() && context.mode().button === d2.button;
74507         }).attr("aria-pressed", function(d2) {
74508           return context.mode() && context.mode().button === d2.button;
74509         });
74510       }
74511     };
74512     tool.uninstall = function() {
74513       context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
74514       context.map().on("move.notes", null).on("drawn.notes", null);
74515     };
74516     return tool;
74517   }
74518
74519   // modules/ui/tools/save.js
74520   function uiToolSave(context) {
74521     var tool = {
74522       id: "save",
74523       label: _t.append("save.title")
74524     };
74525     var button = null;
74526     var tooltipBehavior = null;
74527     var history = context.history();
74528     var key = uiCmd("\u2318S");
74529     var _numChanges = 0;
74530     function isSaving() {
74531       var mode = context.mode();
74532       return mode && mode.id === "save";
74533     }
74534     function isDisabled() {
74535       return _numChanges === 0 || isSaving();
74536     }
74537     function save(d3_event) {
74538       d3_event.preventDefault();
74539       if (!context.inIntro() && !isSaving() && history.hasChanges()) {
74540         context.enter(modeSave(context));
74541       }
74542     }
74543     function bgColor(numChanges) {
74544       var step;
74545       if (numChanges === 0) {
74546         return null;
74547       } else if (numChanges <= 50) {
74548         step = numChanges / 50;
74549         return rgb_default("#fff", "#ff8")(step);
74550       } else {
74551         step = Math.min((numChanges - 50) / 50, 1);
74552         return rgb_default("#ff8", "#f88")(step);
74553       }
74554     }
74555     function updateCount() {
74556       var val = history.difference().summary().length;
74557       if (val === _numChanges)
74558         return;
74559       _numChanges = val;
74560       if (tooltipBehavior) {
74561         tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
74562       }
74563       if (button) {
74564         button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
74565         button.select("span.count").text(_numChanges);
74566       }
74567     }
74568     tool.render = function(selection2) {
74569       tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
74570       var lastPointerUpType;
74571       button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
74572         lastPointerUpType = d3_event.pointerType;
74573       }).on("click", function(d3_event) {
74574         save(d3_event);
74575         if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74576           context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
74577         }
74578         lastPointerUpType = null;
74579       }).call(tooltipBehavior);
74580       button.call(svgIcon("#iD-icon-save"));
74581       button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
74582       updateCount();
74583       context.keybinding().on(key, save, true);
74584       context.history().on("change.save", updateCount);
74585       context.on("enter.save", function() {
74586         if (button) {
74587           button.classed("disabled", isDisabled());
74588           if (isSaving()) {
74589             button.call(tooltipBehavior.hide);
74590           }
74591         }
74592       });
74593     };
74594     tool.uninstall = function() {
74595       context.keybinding().off(key, true);
74596       context.history().on("change.save", null);
74597       context.on("enter.save", null);
74598       button = null;
74599       tooltipBehavior = null;
74600     };
74601     return tool;
74602   }
74603
74604   // modules/ui/tools/sidebar_toggle.js
74605   function uiToolSidebarToggle(context) {
74606     var tool = {
74607       id: "sidebar_toggle",
74608       label: _t.append("toolbar.inspect")
74609     };
74610     tool.render = function(selection2) {
74611       selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
74612         context.ui().sidebar.toggle();
74613       }).call(
74614         uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
74615       ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
74616     };
74617     return tool;
74618   }
74619
74620   // modules/ui/tools/undo_redo.js
74621   function uiToolUndoRedo(context) {
74622     var tool = {
74623       id: "undo_redo",
74624       label: _t.append("toolbar.undo_redo")
74625     };
74626     var commands = [{
74627       id: "undo",
74628       cmd: uiCmd("\u2318Z"),
74629       action: function() {
74630         context.undo();
74631       },
74632       annotation: function() {
74633         return context.history().undoAnnotation();
74634       },
74635       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
74636     }, {
74637       id: "redo",
74638       cmd: uiCmd("\u2318\u21E7Z"),
74639       action: function() {
74640         context.redo();
74641       },
74642       annotation: function() {
74643         return context.history().redoAnnotation();
74644       },
74645       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
74646     }];
74647     function editable() {
74648       return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
74649         true
74650         /* ignore min zoom */
74651       );
74652     }
74653     tool.render = function(selection2) {
74654       var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
74655         return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
74656       }).keys(function(d2) {
74657         return [d2.cmd];
74658       }).scrollContainer(context.container().select(".top-toolbar"));
74659       var lastPointerUpType;
74660       var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
74661         return "disabled " + d2.id + "-button bar-button";
74662       }).on("pointerup", function(d3_event) {
74663         lastPointerUpType = d3_event.pointerType;
74664       }).on("click", function(d3_event, d2) {
74665         d3_event.preventDefault();
74666         var annotation = d2.annotation();
74667         if (editable() && annotation) {
74668           d2.action();
74669         }
74670         if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74671           var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
74672           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
74673         }
74674         lastPointerUpType = null;
74675       }).call(tooltipBehavior);
74676       buttons.each(function(d2) {
74677         select_default2(this).call(svgIcon("#" + d2.icon));
74678       });
74679       context.keybinding().on(commands[0].cmd, function(d3_event) {
74680         d3_event.preventDefault();
74681         if (editable())
74682           commands[0].action();
74683       }).on(commands[1].cmd, function(d3_event) {
74684         d3_event.preventDefault();
74685         if (editable())
74686           commands[1].action();
74687       });
74688       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74689       context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
74690       context.history().on("change.undo_redo", function(difference2) {
74691         if (difference2)
74692           update();
74693       });
74694       context.on("enter.undo_redo", update);
74695       function update() {
74696         buttons.classed("disabled", function(d2) {
74697           return !editable() || !d2.annotation();
74698         }).each(function() {
74699           var selection3 = select_default2(this);
74700           if (!selection3.select(".tooltip.in").empty()) {
74701             selection3.call(tooltipBehavior.updateContent);
74702           }
74703         });
74704       }
74705     };
74706     tool.uninstall = function() {
74707       context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
74708       context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
74709       context.history().on("change.undo_redo", null);
74710       context.on("enter.undo_redo", null);
74711     };
74712     return tool;
74713   }
74714
74715   // modules/ui/top_toolbar.js
74716   function uiTopToolbar(context) {
74717     var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
74718     function notesEnabled() {
74719       var noteLayer = context.layers().layer("notes");
74720       return noteLayer && noteLayer.enabled();
74721     }
74722     function topToolbar(bar) {
74723       bar.on("wheel.topToolbar", function(d3_event) {
74724         if (!d3_event.deltaX) {
74725           bar.node().scrollLeft += d3_event.deltaY;
74726         }
74727       });
74728       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74729       context.layers().on("change.topToolbar", debouncedUpdate);
74730       update();
74731       function update() {
74732         var tools = [
74733           sidebarToggle,
74734           "spacer",
74735           modes
74736         ];
74737         tools.push("spacer");
74738         if (notesEnabled()) {
74739           tools = tools.concat([notes, "spacer"]);
74740         }
74741         tools = tools.concat([undoRedo, save]);
74742         var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
74743           return d2.id || d2;
74744         });
74745         toolbarItems.exit().each(function(d2) {
74746           if (d2.uninstall) {
74747             d2.uninstall();
74748           }
74749         }).remove();
74750         var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
74751           var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
74752           if (d2.klass)
74753             classes += " " + d2.klass;
74754           return classes;
74755         });
74756         var actionableItems = itemsEnter.filter(function(d2) {
74757           return d2 !== "spacer";
74758         });
74759         actionableItems.append("div").attr("class", "item-content").each(function(d2) {
74760           select_default2(this).call(d2.render, bar);
74761         });
74762         actionableItems.append("div").attr("class", "item-label").each(function(d2) {
74763           d2.label(select_default2(this));
74764         });
74765       }
74766     }
74767     return topToolbar;
74768   }
74769
74770   // modules/ui/zoom_to_selection.js
74771   function uiZoomToSelection(context) {
74772     function isDisabled() {
74773       var mode = context.mode();
74774       return !mode || !mode.zoomToSelected;
74775     }
74776     var _lastPointerUpType;
74777     function pointerup(d3_event) {
74778       _lastPointerUpType = d3_event.pointerType;
74779     }
74780     function click(d3_event) {
74781       d3_event.preventDefault();
74782       if (isDisabled()) {
74783         if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
74784           context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
74785         }
74786       } else {
74787         var mode = context.mode();
74788         if (mode && mode.zoomToSelected) {
74789           mode.zoomToSelected();
74790         }
74791       }
74792       _lastPointerUpType = null;
74793     }
74794     return function(selection2) {
74795       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
74796         if (isDisabled()) {
74797           return _t.append("inspector.zoom_to.no_selection");
74798         }
74799         return _t.append("inspector.zoom_to.title");
74800       }).keys([_t("inspector.zoom_to.key")]);
74801       var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
74802       function setEnabledState() {
74803         button.classed("disabled", isDisabled());
74804         if (!button.select(".tooltip.in").empty()) {
74805           button.call(tooltipBehavior.updateContent);
74806         }
74807       }
74808       context.on("enter.uiZoomToSelection", setEnabledState);
74809       setEnabledState();
74810     };
74811   }
74812
74813   // modules/ui/pane.js
74814   function uiPane(id2, context) {
74815     var _key;
74816     var _label = "";
74817     var _description = "";
74818     var _iconName = "";
74819     var _sections;
74820     var _paneSelection = select_default2(null);
74821     var _paneTooltip;
74822     var pane = {
74823       id: id2
74824     };
74825     pane.label = function(val) {
74826       if (!arguments.length)
74827         return _label;
74828       _label = val;
74829       return pane;
74830     };
74831     pane.key = function(val) {
74832       if (!arguments.length)
74833         return _key;
74834       _key = val;
74835       return pane;
74836     };
74837     pane.description = function(val) {
74838       if (!arguments.length)
74839         return _description;
74840       _description = val;
74841       return pane;
74842     };
74843     pane.iconName = function(val) {
74844       if (!arguments.length)
74845         return _iconName;
74846       _iconName = val;
74847       return pane;
74848     };
74849     pane.sections = function(val) {
74850       if (!arguments.length)
74851         return _sections;
74852       _sections = val;
74853       return pane;
74854     };
74855     pane.selection = function() {
74856       return _paneSelection;
74857     };
74858     function hidePane() {
74859       context.ui().togglePanes();
74860     }
74861     pane.togglePane = function(d3_event) {
74862       if (d3_event)
74863         d3_event.preventDefault();
74864       _paneTooltip.hide();
74865       context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
74866     };
74867     pane.renderToggleButton = function(selection2) {
74868       if (!_paneTooltip) {
74869         _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
74870       }
74871       selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
74872     };
74873     pane.renderContent = function(selection2) {
74874       if (_sections) {
74875         _sections.forEach(function(section) {
74876           selection2.call(section.render);
74877         });
74878       }
74879     };
74880     pane.renderPane = function(selection2) {
74881       _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
74882       var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
74883       heading2.append("h2").text("").call(_label);
74884       heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
74885       _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
74886       if (_key) {
74887         context.keybinding().on(_key, pane.togglePane);
74888       }
74889     };
74890     return pane;
74891   }
74892
74893   // modules/ui/sections/background_display_options.js
74894   function uiSectionBackgroundDisplayOptions(context) {
74895     var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
74896     var _storedOpacity = corePreferences("background-opacity");
74897     var _minVal = 0;
74898     var _maxVal = 3;
74899     var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
74900     var _options = {
74901       brightness: _storedOpacity !== null ? +_storedOpacity : 1,
74902       contrast: 1,
74903       saturation: 1,
74904       sharpness: 1
74905     };
74906     function clamp3(x2, min3, max3) {
74907       return Math.max(min3, Math.min(x2, max3));
74908     }
74909     function updateValue(d2, val) {
74910       val = clamp3(val, _minVal, _maxVal);
74911       _options[d2] = val;
74912       context.background()[d2](val);
74913       if (d2 === "brightness") {
74914         corePreferences("background-opacity", val);
74915       }
74916       section.reRender();
74917     }
74918     function renderDisclosureContent(selection2) {
74919       var container = selection2.selectAll(".display-options-container").data([0]);
74920       var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
74921       var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
74922         return "display-control display-control-" + d2;
74923       });
74924       slidersEnter.html(function(d2) {
74925         return _t.html("background." + d2);
74926       }).append("span").attr("class", function(d2) {
74927         return "display-option-value display-option-value-" + d2;
74928       });
74929       var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
74930       sildersControlEnter.append("input").attr("class", function(d2) {
74931         return "display-option-input display-option-input-" + d2;
74932       }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
74933         var val = select_default2(this).property("value");
74934         if (!val && d3_event && d3_event.target) {
74935           val = d3_event.target.value;
74936         }
74937         updateValue(d2, val);
74938       });
74939       sildersControlEnter.append("button").attr("title", function(d2) {
74940         return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
74941       }).attr("class", function(d2) {
74942         return "display-option-reset display-option-reset-" + d2;
74943       }).on("click", function(d3_event, d2) {
74944         if (d3_event.button !== 0)
74945           return;
74946         updateValue(d2, 1);
74947       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
74948       containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
74949         d3_event.preventDefault();
74950         for (var i3 = 0; i3 < _sliders.length; i3++) {
74951           updateValue(_sliders[i3], 1);
74952         }
74953       });
74954       container = containerEnter.merge(container);
74955       container.selectAll(".display-option-input").property("value", function(d2) {
74956         return _options[d2];
74957       });
74958       container.selectAll(".display-option-value").text(function(d2) {
74959         return Math.floor(_options[d2] * 100) + "%";
74960       });
74961       container.selectAll(".display-option-reset").classed("disabled", function(d2) {
74962         return _options[d2] === 1;
74963       });
74964       if (containerEnter.size() && _options.brightness !== 1) {
74965         context.background().brightness(_options.brightness);
74966       }
74967     }
74968     return section;
74969   }
74970
74971   // modules/ui/settings/custom_background.js
74972   function uiSettingsCustomBackground() {
74973     var dispatch14 = dispatch_default("change");
74974     function render(selection2) {
74975       var _origSettings = {
74976         template: corePreferences("background-custom-template")
74977       };
74978       var _currSettings = {
74979         template: corePreferences("background-custom-template")
74980       };
74981       var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
74982       var modal = uiConfirm(selection2).okButton();
74983       modal.classed("settings-modal settings-custom-background", true);
74984       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
74985       var textSection = modal.select(".modal-section.message-text");
74986       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, "`");
74987       textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
74988       textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
74989       var buttonSection = modal.select(".modal-section.buttons");
74990       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
74991       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
74992       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
74993       function isSaveDisabled() {
74994         return null;
74995       }
74996       function clickCancel() {
74997         textSection.select(".field-template").property("value", _origSettings.template);
74998         corePreferences("background-custom-template", _origSettings.template);
74999         this.blur();
75000         modal.close();
75001       }
75002       function clickSave() {
75003         _currSettings.template = textSection.select(".field-template").property("value");
75004         corePreferences("background-custom-template", _currSettings.template);
75005         this.blur();
75006         modal.close();
75007         dispatch14.call("change", this, _currSettings);
75008       }
75009     }
75010     return utilRebind(render, dispatch14, "on");
75011   }
75012
75013   // modules/ui/sections/background_list.js
75014   function uiSectionBackgroundList(context) {
75015     var _backgroundList = select_default2(null);
75016     var _customSource = context.background().findSource("custom");
75017     var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
75018     var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
75019     function previousBackgroundID() {
75020       return corePreferences("background-last-used-toggle");
75021     }
75022     function renderDisclosureContent(selection2) {
75023       var container = selection2.selectAll(".layer-background-list").data([0]);
75024       _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
75025       var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
75026       var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
75027         uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
75028       );
75029       minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75030         d3_event.preventDefault();
75031         uiMapInMap.toggle();
75032       });
75033       minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
75034       var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
75035         uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
75036       );
75037       panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75038         d3_event.preventDefault();
75039         context.ui().info.toggle("background");
75040       });
75041       panelLabelEnter.append("span").call(_t.append("background.panel.description"));
75042       var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
75043         uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
75044       );
75045       locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75046         d3_event.preventDefault();
75047         context.ui().info.toggle("location");
75048       });
75049       locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
75050       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"));
75051       _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
75052         chooseBackground(d2);
75053       }, function(d2) {
75054         return !d2.isHidden() && !d2.overlay;
75055       });
75056     }
75057     function setTooltips(selection2) {
75058       selection2.each(function(d2, i3, nodes) {
75059         var item = select_default2(this).select("label");
75060         var span = item.select("span");
75061         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75062         var hasDescription = d2.hasDescription();
75063         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75064         item.call(uiTooltip().destroyAny);
75065         if (d2.id === previousBackgroundID()) {
75066           item.call(
75067             uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
75068           );
75069         } else if (hasDescription || isOverflowing) {
75070           item.call(
75071             uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
75072           );
75073         }
75074       });
75075     }
75076     function drawListItems(layerList, type2, change, filter2) {
75077       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
75078         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75079       });
75080       var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
75081         return d2.id + "---" + i3;
75082       });
75083       layerLinks.exit().remove();
75084       var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
75085         return d2.id === "custom";
75086       }).classed("best", function(d2) {
75087         return d2.best();
75088       });
75089       var label = enter.append("label");
75090       label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
75091         return d2.id;
75092       }).on("change", change);
75093       label.append("span").each(function(d2) {
75094         d2.label()(select_default2(this));
75095       });
75096       enter.filter(function(d2) {
75097         return d2.id === "custom";
75098       }).append("button").attr("class", "layer-browse").call(
75099         uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75100       ).on("click", function(d3_event) {
75101         d3_event.preventDefault();
75102         editCustom();
75103       }).call(svgIcon("#iD-icon-more"));
75104       enter.filter(function(d2) {
75105         return d2.best();
75106       }).append("div").attr("class", "best").call(
75107         uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75108       ).append("span").text("\u2605");
75109       layerList.call(updateLayerSelections);
75110     }
75111     function updateLayerSelections(selection2) {
75112       function active(d2) {
75113         return context.background().showsLayer(d2);
75114       }
75115       selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
75116         return d2.id === previousBackgroundID();
75117       }).call(setTooltips).selectAll("input").property("checked", active);
75118     }
75119     function chooseBackground(d2) {
75120       if (d2.id === "custom" && !d2.template()) {
75121         return editCustom();
75122       }
75123       var previousBackground = context.background().baseLayerSource();
75124       corePreferences("background-last-used-toggle", previousBackground.id);
75125       corePreferences("background-last-used", d2.id);
75126       context.background().baseLayerSource(d2);
75127     }
75128     function customChanged(d2) {
75129       if (d2 && d2.template) {
75130         _customSource.template(d2.template);
75131         chooseBackground(_customSource);
75132       } else {
75133         _customSource.template("");
75134         chooseBackground(context.background().findSource("none"));
75135       }
75136     }
75137     function editCustom() {
75138       context.container().call(_settingsCustomBackground);
75139     }
75140     context.background().on("change.background_list", function() {
75141       _backgroundList.call(updateLayerSelections);
75142     });
75143     context.map().on(
75144       "move.background_list",
75145       debounce_default(function() {
75146         window.requestIdleCallback(section.reRender);
75147       }, 1e3)
75148     );
75149     return section;
75150   }
75151
75152   // modules/ui/sections/background_offset.js
75153   function uiSectionBackgroundOffset(context) {
75154     var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
75155     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
75156     var _directions = [
75157       ["top", [0, -0.5]],
75158       ["left", [-0.5, 0]],
75159       ["right", [0.5, 0]],
75160       ["bottom", [0, 0.5]]
75161     ];
75162     function updateValue() {
75163       var meters = geoOffsetToMeters(context.background().offset());
75164       var x2 = +meters[0].toFixed(2);
75165       var y2 = +meters[1].toFixed(2);
75166       context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
75167       context.container().selectAll(".nudge-reset").classed("disabled", function() {
75168         return x2 === 0 && y2 === 0;
75169       });
75170     }
75171     function resetOffset() {
75172       context.background().offset([0, 0]);
75173       updateValue();
75174     }
75175     function nudge(d2) {
75176       context.background().nudge(d2, context.map().zoom());
75177       updateValue();
75178     }
75179     function inputOffset() {
75180       var input = select_default2(this);
75181       var d2 = input.node().value;
75182       if (d2 === "")
75183         return resetOffset();
75184       d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
75185         return !isNaN(n3) && n3;
75186       });
75187       if (d2.length !== 2 || !d2[0] || !d2[1]) {
75188         input.classed("error", true);
75189         return;
75190       }
75191       context.background().offset(geoMetersToOffset(d2));
75192       updateValue();
75193     }
75194     function dragOffset(d3_event) {
75195       if (d3_event.button !== 0)
75196         return;
75197       var origin = [d3_event.clientX, d3_event.clientY];
75198       var pointerId = d3_event.pointerId || "mouse";
75199       context.container().append("div").attr("class", "nudge-surface");
75200       select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
75201       if (_pointerPrefix === "pointer") {
75202         select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
75203       }
75204       function pointermove(d3_event2) {
75205         if (pointerId !== (d3_event2.pointerId || "mouse"))
75206           return;
75207         var latest = [d3_event2.clientX, d3_event2.clientY];
75208         var d2 = [
75209           -(origin[0] - latest[0]) / 4,
75210           -(origin[1] - latest[1]) / 4
75211         ];
75212         origin = latest;
75213         nudge(d2);
75214       }
75215       function pointerup(d3_event2) {
75216         if (pointerId !== (d3_event2.pointerId || "mouse"))
75217           return;
75218         if (d3_event2.button !== 0)
75219           return;
75220         context.container().selectAll(".nudge-surface").remove();
75221         select_default2(window).on(".drag-bg-offset", null);
75222       }
75223     }
75224     function renderDisclosureContent(selection2) {
75225       var container = selection2.selectAll(".nudge-container").data([0]);
75226       var containerEnter = container.enter().append("div").attr("class", "nudge-container");
75227       containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
75228       var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
75229       var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
75230       nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
75231       nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
75232         return _t("background.nudge.".concat(d2[0]));
75233       }).attr("class", function(d2) {
75234         return d2[0] + " nudge";
75235       }).on("click", function(d3_event, d2) {
75236         nudge(d2[1]);
75237       });
75238       nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
75239         d3_event.preventDefault();
75240         resetOffset();
75241       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
75242       updateValue();
75243     }
75244     context.background().on("change.backgroundOffset-update", updateValue);
75245     return section;
75246   }
75247
75248   // modules/ui/sections/overlay_list.js
75249   function uiSectionOverlayList(context) {
75250     var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
75251     var _overlayList = select_default2(null);
75252     function setTooltips(selection2) {
75253       selection2.each(function(d2, i3, nodes) {
75254         var item = select_default2(this).select("label");
75255         var span = item.select("span");
75256         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75257         var description = d2.description();
75258         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75259         item.call(uiTooltip().destroyAny);
75260         if (description || isOverflowing) {
75261           item.call(
75262             uiTooltip().placement(placement).title(() => description || d2.name())
75263           );
75264         }
75265       });
75266     }
75267     function updateLayerSelections(selection2) {
75268       function active(d2) {
75269         return context.background().showsLayer(d2);
75270       }
75271       selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
75272     }
75273     function chooseOverlay(d3_event, d2) {
75274       d3_event.preventDefault();
75275       context.background().toggleOverlayLayer(d2);
75276       _overlayList.call(updateLayerSelections);
75277       document.activeElement.blur();
75278     }
75279     function drawListItems(layerList, type2, change, filter2) {
75280       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
75281       var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
75282         return d2.name();
75283       });
75284       layerLinks.exit().remove();
75285       var enter = layerLinks.enter().append("li");
75286       var label = enter.append("label");
75287       label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
75288       label.append("span").each(function(d2) {
75289         d2.label()(select_default2(this));
75290       });
75291       layerList.selectAll("li").sort(sortSources);
75292       layerList.call(updateLayerSelections);
75293       function sortSources(a2, b2) {
75294         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75295       }
75296     }
75297     function renderDisclosureContent(selection2) {
75298       var container = selection2.selectAll(".layer-overlay-list").data([0]);
75299       _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
75300       _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
75301         return !d2.isHidden() && d2.overlay;
75302       });
75303     }
75304     context.map().on(
75305       "move.overlay_list",
75306       debounce_default(function() {
75307         window.requestIdleCallback(section.reRender);
75308       }, 1e3)
75309     );
75310     return section;
75311   }
75312
75313   // modules/ui/panes/background.js
75314   function uiPaneBackground(context) {
75315     var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([
75316       uiSectionBackgroundList(context),
75317       uiSectionOverlayList(context),
75318       uiSectionBackgroundDisplayOptions(context),
75319       uiSectionBackgroundOffset(context)
75320     ]);
75321     return backgroundPane;
75322   }
75323
75324   // modules/ui/panes/help.js
75325   function uiPaneHelp(context) {
75326     var docKeys = [
75327       ["help", [
75328         "welcome",
75329         "open_data_h",
75330         "open_data",
75331         "before_start_h",
75332         "before_start",
75333         "open_source_h",
75334         "open_source",
75335         "open_source_attribution",
75336         "open_source_help"
75337       ]],
75338       ["overview", [
75339         "navigation_h",
75340         "navigation_drag",
75341         "navigation_zoom",
75342         "features_h",
75343         "features",
75344         "nodes_ways"
75345       ]],
75346       ["editing", [
75347         "select_h",
75348         "select_left_click",
75349         "select_right_click",
75350         "select_space",
75351         "multiselect_h",
75352         "multiselect",
75353         "multiselect_shift_click",
75354         "multiselect_lasso",
75355         "undo_redo_h",
75356         "undo_redo",
75357         "save_h",
75358         "save",
75359         "save_validation",
75360         "upload_h",
75361         "upload",
75362         "backups_h",
75363         "backups",
75364         "keyboard_h",
75365         "keyboard"
75366       ]],
75367       ["feature_editor", [
75368         "intro",
75369         "definitions",
75370         "type_h",
75371         "type",
75372         "type_picker",
75373         "fields_h",
75374         "fields_all_fields",
75375         "fields_example",
75376         "fields_add_field",
75377         "tags_h",
75378         "tags_all_tags",
75379         "tags_resources"
75380       ]],
75381       ["points", [
75382         "intro",
75383         "add_point_h",
75384         "add_point",
75385         "add_point_finish",
75386         "move_point_h",
75387         "move_point",
75388         "delete_point_h",
75389         "delete_point",
75390         "delete_point_command"
75391       ]],
75392       ["lines", [
75393         "intro",
75394         "add_line_h",
75395         "add_line",
75396         "add_line_draw",
75397         "add_line_continue",
75398         "add_line_finish",
75399         "modify_line_h",
75400         "modify_line_dragnode",
75401         "modify_line_addnode",
75402         "connect_line_h",
75403         "connect_line",
75404         "connect_line_display",
75405         "connect_line_drag",
75406         "connect_line_tag",
75407         "disconnect_line_h",
75408         "disconnect_line_command",
75409         "move_line_h",
75410         "move_line_command",
75411         "move_line_connected",
75412         "delete_line_h",
75413         "delete_line",
75414         "delete_line_command"
75415       ]],
75416       ["areas", [
75417         "intro",
75418         "point_or_area_h",
75419         "point_or_area",
75420         "add_area_h",
75421         "add_area_command",
75422         "add_area_draw",
75423         "add_area_continue",
75424         "add_area_finish",
75425         "square_area_h",
75426         "square_area_command",
75427         "modify_area_h",
75428         "modify_area_dragnode",
75429         "modify_area_addnode",
75430         "delete_area_h",
75431         "delete_area",
75432         "delete_area_command"
75433       ]],
75434       ["relations", [
75435         "intro",
75436         "edit_relation_h",
75437         "edit_relation",
75438         "edit_relation_add",
75439         "edit_relation_delete",
75440         "maintain_relation_h",
75441         "maintain_relation",
75442         "relation_types_h",
75443         "multipolygon_h",
75444         "multipolygon",
75445         "multipolygon_create",
75446         "multipolygon_merge",
75447         "turn_restriction_h",
75448         "turn_restriction",
75449         "turn_restriction_field",
75450         "turn_restriction_editing",
75451         "route_h",
75452         "route",
75453         "route_add",
75454         "boundary_h",
75455         "boundary",
75456         "boundary_add"
75457       ]],
75458       ["operations", [
75459         "intro",
75460         "intro_2",
75461         "straighten",
75462         "orthogonalize",
75463         "circularize",
75464         "move",
75465         "rotate",
75466         "reflect",
75467         "continue",
75468         "reverse",
75469         "disconnect",
75470         "split",
75471         "extract",
75472         "merge",
75473         "delete",
75474         "downgrade",
75475         "copy_paste"
75476       ]],
75477       ["notes", [
75478         "intro",
75479         "add_note_h",
75480         "add_note",
75481         "place_note",
75482         "move_note",
75483         "update_note_h",
75484         "update_note",
75485         "save_note_h",
75486         "save_note"
75487       ]],
75488       ["imagery", [
75489         "intro",
75490         "sources_h",
75491         "choosing",
75492         "sources",
75493         "offsets_h",
75494         "offset",
75495         "offset_change"
75496       ]],
75497       ["streetlevel", [
75498         "intro",
75499         "using_h",
75500         "using",
75501         "photos",
75502         "viewer"
75503       ]],
75504       ["gps", [
75505         "intro",
75506         "survey",
75507         "using_h",
75508         "using",
75509         "tracing",
75510         "upload"
75511       ]],
75512       ["qa", [
75513         "intro",
75514         "tools_h",
75515         "tools",
75516         "issues_h",
75517         "issues"
75518       ]]
75519     ];
75520     var headings = {
75521       "help.help.open_data_h": 3,
75522       "help.help.before_start_h": 3,
75523       "help.help.open_source_h": 3,
75524       "help.overview.navigation_h": 3,
75525       "help.overview.features_h": 3,
75526       "help.editing.select_h": 3,
75527       "help.editing.multiselect_h": 3,
75528       "help.editing.undo_redo_h": 3,
75529       "help.editing.save_h": 3,
75530       "help.editing.upload_h": 3,
75531       "help.editing.backups_h": 3,
75532       "help.editing.keyboard_h": 3,
75533       "help.feature_editor.type_h": 3,
75534       "help.feature_editor.fields_h": 3,
75535       "help.feature_editor.tags_h": 3,
75536       "help.points.add_point_h": 3,
75537       "help.points.move_point_h": 3,
75538       "help.points.delete_point_h": 3,
75539       "help.lines.add_line_h": 3,
75540       "help.lines.modify_line_h": 3,
75541       "help.lines.connect_line_h": 3,
75542       "help.lines.disconnect_line_h": 3,
75543       "help.lines.move_line_h": 3,
75544       "help.lines.delete_line_h": 3,
75545       "help.areas.point_or_area_h": 3,
75546       "help.areas.add_area_h": 3,
75547       "help.areas.square_area_h": 3,
75548       "help.areas.modify_area_h": 3,
75549       "help.areas.delete_area_h": 3,
75550       "help.relations.edit_relation_h": 3,
75551       "help.relations.maintain_relation_h": 3,
75552       "help.relations.relation_types_h": 2,
75553       "help.relations.multipolygon_h": 3,
75554       "help.relations.turn_restriction_h": 3,
75555       "help.relations.route_h": 3,
75556       "help.relations.boundary_h": 3,
75557       "help.notes.add_note_h": 3,
75558       "help.notes.update_note_h": 3,
75559       "help.notes.save_note_h": 3,
75560       "help.imagery.sources_h": 3,
75561       "help.imagery.offsets_h": 3,
75562       "help.streetlevel.using_h": 3,
75563       "help.gps.using_h": 3,
75564       "help.qa.tools_h": 3,
75565       "help.qa.issues_h": 3
75566     };
75567     var docs = docKeys.map(function(key) {
75568       var helpkey = "help." + key[0];
75569       var helpPaneReplacements = { version: context.version };
75570       var text = key[1].reduce(function(all, part) {
75571         var subkey = helpkey + "." + part;
75572         var depth = headings[subkey];
75573         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
75574         return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n";
75575       }, "");
75576       return {
75577         title: _t.html(helpkey + ".title"),
75578         content: marked(text.trim()).replace(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
75579       };
75580     });
75581     var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help");
75582     helpPane.renderContent = function(content) {
75583       function clickHelp(d2, i3) {
75584         var rtl = _mainLocalizer.textDirection() === "rtl";
75585         content.property("scrollTop", 0);
75586         helpPane.selection().select(".pane-heading h2").html(d2.title);
75587         body.html(d2.content);
75588         body.selectAll("a").attr("target", "_blank");
75589         menuItems.classed("selected", function(m2) {
75590           return m2.title === d2.title;
75591         });
75592         nav.html("");
75593         if (rtl) {
75594           nav.call(drawNext).call(drawPrevious);
75595         } else {
75596           nav.call(drawPrevious).call(drawNext);
75597         }
75598         function drawNext(selection2) {
75599           if (i3 < docs.length - 1) {
75600             var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) {
75601               d3_event.preventDefault();
75602               clickHelp(docs[i3 + 1], i3 + 1);
75603             });
75604             nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
75605           }
75606         }
75607         function drawPrevious(selection2) {
75608           if (i3 > 0) {
75609             var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) {
75610               d3_event.preventDefault();
75611               clickHelp(docs[i3 - 1], i3 - 1);
75612             });
75613             prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title);
75614           }
75615         }
75616       }
75617       function clickWalkthrough(d3_event) {
75618         d3_event.preventDefault();
75619         if (context.inIntro())
75620           return;
75621         context.container().call(uiIntro(context));
75622         context.ui().togglePanes();
75623       }
75624       function clickShortcuts(d3_event) {
75625         d3_event.preventDefault();
75626         context.container().call(context.ui().shortcuts, true);
75627       }
75628       var toc = content.append("ul").attr("class", "toc");
75629       var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) {
75630         return d2.title;
75631       }).on("click", function(d3_event, d2) {
75632         d3_event.preventDefault();
75633         clickHelp(d2, docs.indexOf(d2));
75634       });
75635       var shortcuts = toc.append("li").attr("class", "shortcuts").call(
75636         uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top")
75637       ).append("a").attr("href", "#").on("click", clickShortcuts);
75638       shortcuts.append("div").call(_t.append("shortcuts.title"));
75639       var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough);
75640       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
75641       walkthrough.append("div").call(_t.append("splash.walkthrough"));
75642       var helpContent = content.append("div").attr("class", "left-content");
75643       var body = helpContent.append("div").attr("class", "body");
75644       var nav = helpContent.append("div").attr("class", "nav");
75645       clickHelp(docs[0], 0);
75646     };
75647     return helpPane;
75648   }
75649
75650   // modules/ui/sections/validation_issues.js
75651   function uiSectionValidationIssues(id2, severity, context) {
75652     var _issues = [];
75653     var section = uiSection(id2, context).label(function() {
75654       if (!_issues)
75655         return "";
75656       var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length);
75657       return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText });
75658     }).disclosureContent(renderDisclosureContent).shouldDisplay(function() {
75659       return _issues && _issues.length;
75660     });
75661     function getOptions() {
75662       return {
75663         what: corePreferences("validate-what") || "edited",
75664         where: corePreferences("validate-where") || "all"
75665       };
75666     }
75667     function reloadIssues() {
75668       _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
75669     }
75670     function renderDisclosureContent(selection2) {
75671       var center = context.map().center();
75672       var graph = context.graph();
75673       var issues = _issues.map(function withDistance(issue) {
75674         var extent = issue.extent(graph);
75675         var dist = extent ? geoSphericalDistance(center, extent.center()) : 0;
75676         return Object.assign(issue, { dist });
75677       }).sort(function byDistance(a2, b2) {
75678         return a2.dist - b2.dist;
75679       });
75680       issues = issues.slice(0, 1e3);
75681       selection2.call(drawIssuesList, issues);
75682     }
75683     function drawIssuesList(selection2, issues) {
75684       var list2 = selection2.selectAll(".issues-list").data([0]);
75685       list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2);
75686       var items = list2.selectAll("li").data(issues, function(d2) {
75687         return d2.key;
75688       });
75689       items.exit().remove();
75690       var itemsEnter = items.enter().append("li").attr("class", function(d2) {
75691         return "issue severity-" + d2.severity;
75692       });
75693       var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) {
75694         context.validator().focusIssue(d2);
75695       }).on("mouseover", function(d3_event, d2) {
75696         utilHighlightEntities(d2.entityIds, true, context);
75697       }).on("mouseout", function(d3_event, d2) {
75698         utilHighlightEntities(d2.entityIds, false, context);
75699       });
75700       var textEnter = labelsEnter.append("span").attr("class", "issue-text");
75701       textEnter.append("span").attr("class", "issue-icon").each(function(d2) {
75702         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
75703         select_default2(this).call(svgIcon(iconName));
75704       });
75705       textEnter.append("span").attr("class", "issue-message");
75706       items = items.merge(itemsEnter).order();
75707       items.selectAll(".issue-message").text("").each(function(d2) {
75708         return d2.message(context)(select_default2(this));
75709       });
75710     }
75711     context.validator().on("validated.uiSectionValidationIssues" + id2, function() {
75712       window.requestIdleCallback(function() {
75713         reloadIssues();
75714         section.reRender();
75715       });
75716     });
75717     context.map().on(
75718       "move.uiSectionValidationIssues" + id2,
75719       debounce_default(function() {
75720         window.requestIdleCallback(function() {
75721           if (getOptions().where === "visible") {
75722             reloadIssues();
75723           }
75724           section.reRender();
75725         });
75726       }, 1e3)
75727     );
75728     return section;
75729   }
75730
75731   // modules/ui/sections/validation_options.js
75732   function uiSectionValidationOptions(context) {
75733     var section = uiSection("issues-options", context).content(renderContent);
75734     function renderContent(selection2) {
75735       var container = selection2.selectAll(".issues-options-container").data([0]);
75736       container = container.enter().append("div").attr("class", "issues-options-container").merge(container);
75737       var data = [
75738         { key: "what", values: ["edited", "all"] },
75739         { key: "where", values: ["visible", "all"] }
75740       ];
75741       var options2 = container.selectAll(".issues-option").data(data, function(d2) {
75742         return d2.key;
75743       });
75744       var optionsEnter = options2.enter().append("div").attr("class", function(d2) {
75745         return "issues-option issues-option-" + d2.key;
75746       });
75747       optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) {
75748         return _t.html("issues.options." + d2.key + ".title");
75749       });
75750       var valuesEnter = optionsEnter.selectAll("label").data(function(d2) {
75751         return d2.values.map(function(val) {
75752           return { value: val, key: d2.key };
75753         });
75754       }).enter().append("label");
75755       valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) {
75756         return "issues-option-" + d2.key;
75757       }).attr("value", function(d2) {
75758         return d2.value;
75759       }).property("checked", function(d2) {
75760         return getOptions()[d2.key] === d2.value;
75761       }).on("change", function(d3_event, d2) {
75762         updateOptionValue(d3_event, d2.key, d2.value);
75763       });
75764       valuesEnter.append("span").html(function(d2) {
75765         return _t.html("issues.options." + d2.key + "." + d2.value);
75766       });
75767     }
75768     function getOptions() {
75769       return {
75770         what: corePreferences("validate-what") || "edited",
75771         // 'all', 'edited'
75772         where: corePreferences("validate-where") || "all"
75773         // 'all', 'visible'
75774       };
75775     }
75776     function updateOptionValue(d3_event, d2, val) {
75777       if (!val && d3_event && d3_event.target) {
75778         val = d3_event.target.value;
75779       }
75780       corePreferences("validate-" + d2, val);
75781       context.validator().validate();
75782     }
75783     return section;
75784   }
75785
75786   // modules/ui/sections/validation_rules.js
75787   function uiSectionValidationRules(context) {
75788     var MINSQUARE = 0;
75789     var MAXSQUARE = 20;
75790     var DEFAULTSQUARE = 5;
75791     var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title"));
75792     var _ruleKeys = context.validator().getRuleKeys().filter(function(key) {
75793       return key !== "maprules";
75794     }).sort(function(key1, key2) {
75795       return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1;
75796     });
75797     function renderDisclosureContent(selection2) {
75798       var container = selection2.selectAll(".issues-rulelist-container").data([0]);
75799       var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container");
75800       containerEnter.append("ul").attr("class", "layer-list issue-rules-list");
75801       var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer");
75802       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
75803         d3_event.preventDefault();
75804         context.validator().disableRules(_ruleKeys);
75805       });
75806       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
75807         d3_event.preventDefault();
75808         context.validator().disableRules([]);
75809       });
75810       container = container.merge(containerEnter);
75811       container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled);
75812     }
75813     function drawListItems(selection2, data, type2, name, change, active) {
75814       var items = selection2.selectAll("li").data(data);
75815       items.exit().remove();
75816       var enter = items.enter().append("li");
75817       if (name === "rule") {
75818         enter.call(
75819           uiTooltip().title(function(d2) {
75820             return _t.append("issues." + d2 + ".tip");
75821           }).placement("top")
75822         );
75823       }
75824       var label = enter.append("label");
75825       label.append("input").attr("type", type2).attr("name", name).on("change", change);
75826       label.append("span").html(function(d2) {
75827         var params = {};
75828         if (d2 === "unsquare_way") {
75829           params.val = { html: '<span class="square-degrees"></span>' };
75830         }
75831         return _t.html("issues." + d2 + ".title", params);
75832       });
75833       items = items.merge(enter);
75834       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
75835       var degStr = corePreferences("validate-square-degrees");
75836       if (degStr === null) {
75837         degStr = DEFAULTSQUARE.toString();
75838       }
75839       var span = items.selectAll(".square-degrees");
75840       var input = span.selectAll(".square-degrees-input").data([0]);
75841       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) {
75842         d3_event.preventDefault();
75843         d3_event.stopPropagation();
75844         this.select();
75845       }).on("keyup", function(d3_event) {
75846         if (d3_event.keyCode === 13) {
75847           this.blur();
75848           this.select();
75849         }
75850       }).on("blur", changeSquare).merge(input).property("value", degStr);
75851     }
75852     function changeSquare() {
75853       var input = select_default2(this);
75854       var degStr = utilGetSetValue(input).trim();
75855       var degNum = Number(degStr);
75856       if (!isFinite(degNum)) {
75857         degNum = DEFAULTSQUARE;
75858       } else if (degNum > MAXSQUARE) {
75859         degNum = MAXSQUARE;
75860       } else if (degNum < MINSQUARE) {
75861         degNum = MINSQUARE;
75862       }
75863       degNum = Math.round(degNum * 10) / 10;
75864       degStr = degNum.toString();
75865       input.property("value", degStr);
75866       corePreferences("validate-square-degrees", degStr);
75867       context.validator().revalidateUnsquare();
75868     }
75869     function isRuleEnabled(d2) {
75870       return context.validator().isRuleEnabled(d2);
75871     }
75872     function toggleRule(d3_event, d2) {
75873       context.validator().toggleRule(d2);
75874     }
75875     context.validator().on("validated.uiSectionValidationRules", function() {
75876       window.requestIdleCallback(section.reRender);
75877     });
75878     return section;
75879   }
75880
75881   // modules/ui/sections/validation_status.js
75882   function uiSectionValidationStatus(context) {
75883     var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() {
75884       var issues = context.validator().getIssues(getOptions());
75885       return issues.length === 0;
75886     });
75887     function getOptions() {
75888       return {
75889         what: corePreferences("validate-what") || "edited",
75890         where: corePreferences("validate-where") || "all"
75891       };
75892     }
75893     function renderContent(selection2) {
75894       var box = selection2.selectAll(".box").data([0]);
75895       var boxEnter = box.enter().append("div").attr("class", "box");
75896       boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text"));
75897       var noIssuesMessage = boxEnter.append("span");
75898       noIssuesMessage.append("strong").attr("class", "message");
75899       noIssuesMessage.append("br");
75900       noIssuesMessage.append("span").attr("class", "details");
75901       renderIgnoredIssuesReset(selection2);
75902       setNoIssuesText(selection2);
75903     }
75904     function renderIgnoredIssuesReset(selection2) {
75905       var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" });
75906       var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []);
75907       resetIgnored.exit().remove();
75908       var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer");
75909       resetIgnoredEnter.append("a").attr("href", "#");
75910       resetIgnored = resetIgnored.merge(resetIgnoredEnter);
75911       resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length }));
75912       resetIgnored.on("click", function(d3_event) {
75913         d3_event.preventDefault();
75914         context.validator().resetIgnoredIssues();
75915       });
75916     }
75917     function setNoIssuesText(selection2) {
75918       var opts = getOptions();
75919       function checkForHiddenIssues(cases) {
75920         for (var type2 in cases) {
75921           var hiddenOpts = cases[type2];
75922           var hiddenIssues = context.validator().getIssues(hiddenOpts);
75923           if (hiddenIssues.length) {
75924             selection2.select(".box .details").html("").call(_t.append(
75925               "issues.no_issues.hidden_issues." + type2,
75926               { count: hiddenIssues.length.toString() }
75927             ));
75928             return;
75929           }
75930         }
75931         selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none"));
75932       }
75933       var messageType;
75934       if (opts.what === "edited" && opts.where === "visible") {
75935         messageType = "edits_in_view";
75936         checkForHiddenIssues({
75937           elsewhere: { what: "edited", where: "all" },
75938           everything_else: { what: "all", where: "visible" },
75939           disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" },
75940           everything_else_elsewhere: { what: "all", where: "all" },
75941           disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" },
75942           ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" },
75943           ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" }
75944         });
75945       } else if (opts.what === "edited" && opts.where === "all") {
75946         messageType = "edits";
75947         checkForHiddenIssues({
75948           everything_else: { what: "all", where: "all" },
75949           disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" },
75950           ignored_issues: { what: "edited", where: "all", includeIgnored: "only" }
75951         });
75952       } else if (opts.what === "all" && opts.where === "visible") {
75953         messageType = "everything_in_view";
75954         checkForHiddenIssues({
75955           elsewhere: { what: "all", where: "all" },
75956           disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" },
75957           disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" },
75958           ignored_issues: { what: "all", where: "visible", includeIgnored: "only" },
75959           ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" }
75960         });
75961       } else if (opts.what === "all" && opts.where === "all") {
75962         messageType = "everything";
75963         checkForHiddenIssues({
75964           disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" },
75965           ignored_issues: { what: "all", where: "all", includeIgnored: "only" }
75966         });
75967       }
75968       if (opts.what === "edited" && context.history().difference().summary().length === 0) {
75969         messageType = "no_edits";
75970       }
75971       selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType));
75972     }
75973     context.validator().on("validated.uiSectionValidationStatus", function() {
75974       window.requestIdleCallback(section.reRender);
75975     });
75976     context.map().on(
75977       "move.uiSectionValidationStatus",
75978       debounce_default(function() {
75979         window.requestIdleCallback(section.reRender);
75980       }, 1e3)
75981     );
75982     return section;
75983   }
75984
75985   // modules/ui/panes/issues.js
75986   function uiPaneIssues(context) {
75987     var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([
75988       uiSectionValidationOptions(context),
75989       uiSectionValidationStatus(context),
75990       uiSectionValidationIssues("issues-errors", "error", context),
75991       uiSectionValidationIssues("issues-warnings", "warning", context),
75992       uiSectionValidationRules(context)
75993     ]);
75994     return issuesPane;
75995   }
75996
75997   // modules/ui/settings/custom_data.js
75998   function uiSettingsCustomData(context) {
75999     var dispatch14 = dispatch_default("change");
76000     function render(selection2) {
76001       var dataLayer = context.layers().layer("data");
76002       var _origSettings = {
76003         fileList: dataLayer && dataLayer.fileList() || null,
76004         url: corePreferences("settings-custom-data-url")
76005       };
76006       var _currSettings = {
76007         fileList: dataLayer && dataLayer.fileList() || null
76008         // url: prefs('settings-custom-data-url')
76009       };
76010       var modal = uiConfirm(selection2).okButton();
76011       modal.classed("settings-modal settings-custom-data", true);
76012       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header"));
76013       var textSection = modal.select(".modal-section.message-text");
76014       textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions"));
76015       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) {
76016         var files = d3_event.target.files;
76017         if (files && files.length) {
76018           _currSettings.url = "";
76019           textSection.select(".field-url").property("value", "");
76020           _currSettings.fileList = files;
76021         } else {
76022           _currSettings.fileList = null;
76023         }
76024       });
76025       textSection.append("h4").call(_t.append("settings.custom_data.or"));
76026       textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions"));
76027       textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url);
76028       var buttonSection = modal.select(".modal-section.buttons");
76029       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
76030       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
76031       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
76032       function isSaveDisabled() {
76033         return null;
76034       }
76035       function clickCancel() {
76036         textSection.select(".field-url").property("value", _origSettings.url);
76037         corePreferences("settings-custom-data-url", _origSettings.url);
76038         this.blur();
76039         modal.close();
76040       }
76041       function clickSave() {
76042         _currSettings.url = textSection.select(".field-url").property("value").trim();
76043         if (_currSettings.url) {
76044           _currSettings.fileList = null;
76045         }
76046         if (_currSettings.fileList) {
76047           _currSettings.url = "";
76048         }
76049         corePreferences("settings-custom-data-url", _currSettings.url);
76050         this.blur();
76051         modal.close();
76052         dispatch14.call("change", this, _currSettings);
76053       }
76054     }
76055     return utilRebind(render, dispatch14, "on");
76056   }
76057
76058   // modules/ui/sections/data_layers.js
76059   function uiSectionDataLayers(context) {
76060     var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged);
76061     var layers = context.layers();
76062     var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent);
76063     function renderDisclosureContent(selection2) {
76064       var container = selection2.selectAll(".data-layer-container").data([0]);
76065       container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems);
76066     }
76067     function showsLayer(which) {
76068       var layer = layers.layer(which);
76069       if (layer) {
76070         return layer.enabled();
76071       }
76072       return false;
76073     }
76074     function setLayer(which, enabled) {
76075       var mode = context.mode();
76076       if (mode && /^draw/.test(mode.id))
76077         return;
76078       var layer = layers.layer(which);
76079       if (layer) {
76080         layer.enabled(enabled);
76081         if (!enabled && (which === "osm" || which === "notes")) {
76082           context.enter(modeBrowse(context));
76083         }
76084       }
76085     }
76086     function toggleLayer(which) {
76087       setLayer(which, !showsLayer(which));
76088     }
76089     function drawOsmItems(selection2) {
76090       var osmKeys = ["osm", "notes"];
76091       var osmLayers = layers.all().filter(function(obj) {
76092         return osmKeys.indexOf(obj.id) !== -1;
76093       });
76094       var ul = selection2.selectAll(".layer-list-osm").data([0]);
76095       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul);
76096       var li = ul.selectAll(".list-item").data(osmLayers);
76097       li.exit().remove();
76098       var liEnter = li.enter().append("li").attr("class", function(d2) {
76099         return "list-item list-item-" + d2.id;
76100       });
76101       var labelEnter = liEnter.append("label").each(function(d2) {
76102         if (d2.id === "osm") {
76103           select_default2(this).call(
76104             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom")
76105           );
76106         } else {
76107           select_default2(this).call(
76108             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76109           );
76110         }
76111       });
76112       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76113         toggleLayer(d2.id);
76114       });
76115       labelEnter.append("span").html(function(d2) {
76116         return _t.html("map_data.layers." + d2.id + ".title");
76117       });
76118       li.merge(liEnter).classed("active", function(d2) {
76119         return d2.layer.enabled();
76120       }).selectAll("input").property("checked", function(d2) {
76121         return d2.layer.enabled();
76122       });
76123     }
76124     function drawQAItems(selection2) {
76125       var qaKeys = ["keepRight", "improveOSM", "osmose"];
76126       var qaLayers = layers.all().filter(function(obj) {
76127         return qaKeys.indexOf(obj.id) !== -1;
76128       });
76129       var ul = selection2.selectAll(".layer-list-qa").data([0]);
76130       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul);
76131       var li = ul.selectAll(".list-item").data(qaLayers);
76132       li.exit().remove();
76133       var liEnter = li.enter().append("li").attr("class", function(d2) {
76134         return "list-item list-item-" + d2.id;
76135       });
76136       var labelEnter = liEnter.append("label").each(function(d2) {
76137         select_default2(this).call(
76138           uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76139         );
76140       });
76141       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76142         toggleLayer(d2.id);
76143       });
76144       labelEnter.append("span").each(function(d2) {
76145         _t.append("map_data.layers." + d2.id + ".title")(select_default2(this));
76146       });
76147       li.merge(liEnter).classed("active", function(d2) {
76148         return d2.layer.enabled();
76149       }).selectAll("input").property("checked", function(d2) {
76150         return d2.layer.enabled();
76151       });
76152     }
76153     function drawVectorItems(selection2) {
76154       var dataLayer = layers.layer("data");
76155       var vtData = [
76156         {
76157           name: "Detroit Neighborhoods/Parks",
76158           src: "neighborhoods-parks",
76159           tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.",
76160           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"
76161         },
76162         {
76163           name: "Detroit Composite POIs",
76164           src: "composite-poi",
76165           tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.",
76166           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"
76167         },
76168         {
76169           name: "Detroit All-The-Places POIs",
76170           src: "alltheplaces-poi",
76171           tooltip: "Public domain business location data created by web scrapers.",
76172           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"
76173         }
76174       ];
76175       var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]);
76176       var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center());
76177       var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []);
76178       container.exit().remove();
76179       var containerEnter = container.enter().append("div").attr("class", "vectortile-container");
76180       containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)");
76181       containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile");
76182       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");
76183       container = container.merge(containerEnter);
76184       var ul = container.selectAll(".layer-list-vectortile");
76185       var li = ul.selectAll(".list-item").data(vtData);
76186       li.exit().remove();
76187       var liEnter = li.enter().append("li").attr("class", function(d2) {
76188         return "list-item list-item-" + d2.src;
76189       });
76190       var labelEnter = liEnter.append("label").each(function(d2) {
76191         select_default2(this).call(
76192           uiTooltip().title(d2.tooltip).placement("top")
76193         );
76194       });
76195       labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer);
76196       labelEnter.append("span").text(function(d2) {
76197         return d2.name;
76198       });
76199       li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected);
76200       function isVTLayerSelected(d2) {
76201         return dataLayer && dataLayer.template() === d2.template;
76202       }
76203       function selectVTLayer(d3_event, d2) {
76204         corePreferences("settings-custom-data-url", d2.template);
76205         if (dataLayer) {
76206           dataLayer.template(d2.template, d2.src);
76207           dataLayer.enabled(true);
76208         }
76209       }
76210     }
76211     function drawCustomDataItems(selection2) {
76212       var dataLayer = layers.layer("data");
76213       var hasData = dataLayer && dataLayer.hasData();
76214       var showsData = hasData && dataLayer.enabled();
76215       var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []);
76216       ul.exit().remove();
76217       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data");
76218       var liEnter = ulEnter.append("li").attr("class", "list-item-data");
76219       var labelEnter = liEnter.append("label").call(
76220         uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top")
76221       );
76222       labelEnter.append("input").attr("type", "checkbox").on("change", function() {
76223         toggleLayer("data");
76224       });
76225       labelEnter.append("span").call(_t.append("map_data.layers.custom.title"));
76226       liEnter.append("button").attr("class", "open-data-options").call(
76227         uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76228       ).on("click", function(d3_event) {
76229         d3_event.preventDefault();
76230         editCustom();
76231       }).call(svgIcon("#iD-icon-more"));
76232       liEnter.append("button").attr("class", "zoom-to-data").call(
76233         uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76234       ).on("click", function(d3_event) {
76235         if (select_default2(this).classed("disabled"))
76236           return;
76237         d3_event.preventDefault();
76238         d3_event.stopPropagation();
76239         dataLayer.fitZoom();
76240       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76241       ul = ul.merge(ulEnter);
76242       ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76243       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76244     }
76245     function editCustom() {
76246       context.container().call(settingsCustomData);
76247     }
76248     function customChanged(d2) {
76249       var dataLayer = layers.layer("data");
76250       if (d2 && d2.url) {
76251         dataLayer.url(d2.url);
76252       } else if (d2 && d2.fileList) {
76253         dataLayer.fileList(d2.fileList);
76254       }
76255     }
76256     function drawPanelItems(selection2) {
76257       var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list");
76258       var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call(
76259         uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top")
76260       );
76261       historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76262         d3_event.preventDefault();
76263         context.ui().info.toggle("history");
76264       });
76265       historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title"));
76266       var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call(
76267         uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top")
76268       );
76269       measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76270         d3_event.preventDefault();
76271         context.ui().info.toggle("measurement");
76272       });
76273       measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title"));
76274     }
76275     context.layers().on("change.uiSectionDataLayers", section.reRender);
76276     context.map().on(
76277       "move.uiSectionDataLayers",
76278       debounce_default(function() {
76279         window.requestIdleCallback(section.reRender);
76280       }, 1e3)
76281     );
76282     return section;
76283   }
76284
76285   // modules/ui/sections/map_features.js
76286   function uiSectionMapFeatures(context) {
76287     var _features = context.features().keys();
76288     var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76289     function renderDisclosureContent(selection2) {
76290       var container = selection2.selectAll(".layer-feature-list-container").data([0]);
76291       var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container");
76292       containerEnter.append("ul").attr("class", "layer-list layer-feature-list");
76293       var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer");
76294       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
76295         d3_event.preventDefault();
76296         context.features().disableAll();
76297       });
76298       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
76299         d3_event.preventDefault();
76300         context.features().enableAll();
76301       });
76302       container = container.merge(containerEnter);
76303       container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature);
76304     }
76305     function drawListItems(selection2, data, type2, name, change, active) {
76306       var items = selection2.selectAll("li").data(data);
76307       items.exit().remove();
76308       var enter = items.enter().append("li").call(
76309         uiTooltip().title(function(d2) {
76310           var tip = _t.append(name + "." + d2 + ".tooltip");
76311           if (autoHiddenFeature(d2)) {
76312             var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden");
76313             return (selection3) => {
76314               selection3.call(tip);
76315               selection3.append("div").call(msg);
76316             };
76317           }
76318           return tip;
76319         }).placement("top")
76320       );
76321       var label = enter.append("label");
76322       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76323       label.append("span").html(function(d2) {
76324         return _t.html(name + "." + d2 + ".description");
76325       });
76326       items = items.merge(enter);
76327       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature);
76328     }
76329     function autoHiddenFeature(d2) {
76330       return context.features().autoHidden(d2);
76331     }
76332     function showsFeature(d2) {
76333       return context.features().enabled(d2);
76334     }
76335     function clickFeature(d3_event, d2) {
76336       context.features().toggle(d2);
76337     }
76338     function showsLayer(id2) {
76339       var layer = context.layers().layer(id2);
76340       return layer && layer.enabled();
76341     }
76342     context.features().on("change.map_features", section.reRender);
76343     return section;
76344   }
76345
76346   // modules/ui/sections/map_style_options.js
76347   function uiSectionMapStyleOptions(context) {
76348     var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76349     function renderDisclosureContent(selection2) {
76350       var container = selection2.selectAll(".layer-fill-list").data([0]);
76351       container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill);
76352       var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]);
76353       container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() {
76354         return context.surface().classed("highlight-edited");
76355       });
76356     }
76357     function drawListItems(selection2, data, type2, name, change, active) {
76358       var items = selection2.selectAll("li").data(data);
76359       items.exit().remove();
76360       var enter = items.enter().append("li").call(
76361         uiTooltip().title(function(d2) {
76362           return _t.append(name + "." + d2 + ".tooltip");
76363         }).keys(function(d2) {
76364           var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null;
76365           if (d2 === "highlight_edits")
76366             key = _t("map_data.highlight_edits.key");
76367           return key ? [key] : null;
76368         }).placement("top")
76369       );
76370       var label = enter.append("label");
76371       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76372       label.append("span").html(function(d2) {
76373         return _t.html(name + "." + d2 + ".description");
76374       });
76375       items = items.merge(enter);
76376       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
76377     }
76378     function isActiveFill(d2) {
76379       return context.map().activeAreaFill() === d2;
76380     }
76381     function toggleHighlightEdited(d3_event) {
76382       d3_event.preventDefault();
76383       context.map().toggleHighlightEdited();
76384     }
76385     function setFill(d3_event, d2) {
76386       context.map().activeAreaFill(d2);
76387     }
76388     context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender);
76389     return section;
76390   }
76391
76392   // modules/ui/settings/local_photos.js
76393   function uiSettingsLocalPhotos(context) {
76394     var dispatch14 = dispatch_default("change");
76395     var photoLayer = context.layers().layer("local-photos");
76396     var modal;
76397     function render(selection2) {
76398       modal = uiConfirm(selection2).okButton();
76399       modal.classed("settings-modal settings-local-photos", true);
76400       modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header"));
76401       modal.select(".modal-section.message-text").append("div").classed("local-photos", true);
76402       var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true);
76403       instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions"));
76404       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) {
76405         var files = d3_event.target.files;
76406         if (files && files.length) {
76407           photoList.select("ul").append("li").classed("placeholder", true).append("div");
76408           dispatch14.call("change", this, files);
76409         }
76410         d3_event.target.value = null;
76411       });
76412       instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label"));
76413       const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true);
76414       photoList.append("ul");
76415       updatePhotoList(photoList.select("ul"));
76416       context.layers().on("change", () => updatePhotoList(photoList.select("ul")));
76417     }
76418     function updatePhotoList(container) {
76419       var _a2;
76420       function locationUnavailable(d2) {
76421         return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
76422       }
76423       container.selectAll("li.placeholder").remove();
76424       let selection2 = container.selectAll("li").data((_a2 = photoLayer.getPhotos()) != null ? _a2 : [], (d2) => d2.id);
76425       selection2.exit().remove();
76426       const selectionEnter = selection2.enter().append("li");
76427       selectionEnter.append("span").classed("filename", true);
76428       selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot"));
76429       selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call(
76430         uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left")
76431       );
76432       selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
76433       selection2 = selection2.merge(selectionEnter);
76434       selection2.classed("invalid", locationUnavailable);
76435       selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name);
76436       selection2.select("span.filename").on("click", (d3_event, d2) => {
76437         photoLayer.openPhoto(d3_event, d2, false);
76438       });
76439       selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => {
76440         photoLayer.openPhoto(d3_event, d2, true);
76441       });
76442       selection2.select("button.remove").on("click", (d3_event, d2) => {
76443         photoLayer.removePhoto(d2.id);
76444         updatePhotoList(container);
76445       });
76446     }
76447     return utilRebind(render, dispatch14, "on");
76448   }
76449
76450   // modules/ui/sections/photo_overlays.js
76451   function uiSectionPhotoOverlays(context) {
76452     var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged);
76453     var layers = context.layers();
76454     var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76455     function renderDisclosureContent(selection2) {
76456       var container = selection2.selectAll(".photo-overlay-container").data([0]);
76457       container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
76458     }
76459     function drawPhotoItems(selection2) {
76460       var photoKeys = context.photos().overlayLayerIDs();
76461       var photoLayers = layers.all().filter(function(obj) {
76462         return photoKeys.indexOf(obj.id) !== -1;
76463       });
76464       var data = photoLayers.filter(function(obj) {
76465         if (!obj.layer.supported())
76466           return false;
76467         if (layerEnabled(obj))
76468           return true;
76469         if (typeof obj.layer.validHere === "function") {
76470           return obj.layer.validHere(context.map().extent(), context.map().zoom());
76471         }
76472         return true;
76473       });
76474       function layerSupported(d2) {
76475         return d2.layer && d2.layer.supported();
76476       }
76477       function layerEnabled(d2) {
76478         return layerSupported(d2) && d2.layer.enabled();
76479       }
76480       function layerRendered(d2) {
76481         var _a2, _b, _c;
76482         return (_c = (_b = (_a2 = d2.layer).rendered) == null ? void 0 : _b.call(_a2, context.map().zoom())) != null ? _c : true;
76483       }
76484       var ul = selection2.selectAll(".layer-list-photos").data([0]);
76485       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
76486       var li = ul.selectAll(".list-item-photos").data(data);
76487       li.exit().remove();
76488       var liEnter = li.enter().append("li").attr("class", function(d2) {
76489         var classes = "list-item-photos list-item-" + d2.id;
76490         if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") {
76491           classes += " indented";
76492         }
76493         return classes;
76494       });
76495       var labelEnter = liEnter.append("label").each(function(d2) {
76496         var titleID;
76497         if (d2.id === "mapillary-signs")
76498           titleID = "mapillary.signs.tooltip";
76499         else if (d2.id === "mapillary")
76500           titleID = "mapillary_images.tooltip";
76501         else if (d2.id === "kartaview")
76502           titleID = "kartaview_images.tooltip";
76503         else
76504           titleID = d2.id.replace(/-/g, "_") + ".tooltip";
76505         select_default2(this).call(
76506           uiTooltip().title(() => {
76507             if (!layerRendered(d2)) {
76508               return _t.append("street_side.minzoom_tooltip");
76509             } else {
76510               return _t.append(titleID);
76511             }
76512           }).placement("top")
76513         );
76514       });
76515       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76516         toggleLayer(d2.id);
76517       });
76518       labelEnter.append("span").html(function(d2) {
76519         var id2 = d2.id;
76520         if (id2 === "mapillary-signs")
76521           id2 = "photo_overlays.traffic_signs";
76522         return _t.html(id2.replace(/-/g, "_") + ".title");
76523       });
76524       li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled);
76525     }
76526     function drawPhotoTypeItems(selection2) {
76527       var data = context.photos().allPhotoTypes();
76528       function typeEnabled(d2) {
76529         return context.photos().showsPhotoType(d2);
76530       }
76531       var ul = selection2.selectAll(".layer-list-photo-types").data([0]);
76532       ul.exit().remove();
76533       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul);
76534       var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []);
76535       li.exit().remove();
76536       var liEnter = li.enter().append("li").attr("class", function(d2) {
76537         return "list-item-photo-types list-item-" + d2;
76538       });
76539       var labelEnter = liEnter.append("label").each(function(d2) {
76540         select_default2(this).call(
76541           uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top")
76542         );
76543       });
76544       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76545         context.photos().togglePhotoType(d2);
76546       });
76547       labelEnter.append("span").html(function(d2) {
76548         return _t.html("photo_overlays.photo_type." + d2 + ".title");
76549       });
76550       li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled);
76551     }
76552     function drawDateFilter(selection2) {
76553       var data = context.photos().dateFilters();
76554       function filterEnabled(d2) {
76555         return context.photos().dateFilterValue(d2);
76556       }
76557       var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
76558       ul.exit().remove();
76559       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
76560       var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
76561       li.exit().remove();
76562       var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
76563       var labelEnter = liEnter.append("label").each(function(d2) {
76564         select_default2(this).call(
76565           uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
76566         );
76567       });
76568       labelEnter.append("span").each(function(d2) {
76569         _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
76570       });
76571       labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
76572         utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
76573       }).on("change", function(d3_event, d2) {
76574         var value = utilGetSetValue(select_default2(this)).trim();
76575         context.photos().setDateFilter(d2, value, true);
76576         li.selectAll("input").each(function(d4) {
76577           utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
76578         });
76579       });
76580       li = li.merge(liEnter).classed("active", filterEnabled);
76581     }
76582     function drawUsernameFilter(selection2) {
76583       function filterEnabled() {
76584         return context.photos().usernames();
76585       }
76586       var ul = selection2.selectAll(".layer-list-username-filter").data([0]);
76587       ul.exit().remove();
76588       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul);
76589       var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []);
76590       li.exit().remove();
76591       var liEnter = li.enter().append("li").attr("class", "list-item-username-filter");
76592       var labelEnter = liEnter.append("label").each(function() {
76593         select_default2(this).call(
76594           uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top")
76595         );
76596       });
76597       labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title"));
76598       labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() {
76599         var value = select_default2(this).property("value");
76600         context.photos().setUsernameFilter(value, true);
76601         select_default2(this).property("value", usernameValue);
76602       });
76603       li.merge(liEnter).classed("active", filterEnabled);
76604       function usernameValue() {
76605         var usernames = context.photos().usernames();
76606         if (usernames)
76607           return usernames.join("; ");
76608         return usernames;
76609       }
76610     }
76611     function toggleLayer(which) {
76612       setLayer(which, !showsLayer(which));
76613     }
76614     function showsLayer(which) {
76615       var layer = layers.layer(which);
76616       if (layer) {
76617         return layer.enabled();
76618       }
76619       return false;
76620     }
76621     function setLayer(which, enabled) {
76622       var layer = layers.layer(which);
76623       if (layer) {
76624         layer.enabled(enabled);
76625       }
76626     }
76627     function drawLocalPhotos(selection2) {
76628       var photoLayer = layers.layer("local-photos");
76629       var hasData = photoLayer && photoLayer.hasData();
76630       var showsData = hasData && photoLayer.enabled();
76631       var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []);
76632       ul.exit().remove();
76633       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos");
76634       var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos");
76635       var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip")));
76636       localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() {
76637         toggleLayer("local-photos");
76638       });
76639       localPhotosLabelEnter.call(_t.append("local_photos.header"));
76640       localPhotosEnter.append("button").attr("class", "open-data-options").call(
76641         uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76642       ).on("click", function(d3_event) {
76643         d3_event.preventDefault();
76644         editLocalPhotos();
76645       }).call(svgIcon("#iD-icon-more"));
76646       localPhotosEnter.append("button").attr("class", "zoom-to-data").call(
76647         uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76648       ).on("click", function(d3_event) {
76649         if (select_default2(this).classed("disabled"))
76650           return;
76651         d3_event.preventDefault();
76652         d3_event.stopPropagation();
76653         photoLayer.fitZoom();
76654       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76655       ul = ul.merge(ulEnter);
76656       ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76657       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76658     }
76659     function editLocalPhotos() {
76660       context.container().call(settingsLocalPhotos);
76661     }
76662     function localPhotosChanged(d2) {
76663       var localPhotosLayer = layers.layer("local-photos");
76664       localPhotosLayer.fileList(d2);
76665     }
76666     context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
76667     context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
76668     context.map().on(
76669       "move.photo_overlays",
76670       debounce_default(function() {
76671         window.requestIdleCallback(section.reRender);
76672       }, 1e3)
76673     );
76674     return section;
76675   }
76676
76677   // modules/ui/panes/map_data.js
76678   function uiPaneMapData(context) {
76679     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([
76680       uiSectionDataLayers(context),
76681       uiSectionPhotoOverlays(context),
76682       uiSectionMapStyleOptions(context),
76683       uiSectionMapFeatures(context)
76684     ]);
76685     return mapDataPane;
76686   }
76687
76688   // modules/ui/panes/preferences.js
76689   function uiPanePreferences(context) {
76690     let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([
76691       uiSectionPrivacy(context)
76692     ]);
76693     return preferencesPane;
76694   }
76695
76696   // modules/ui/init.js
76697   function uiInit(context) {
76698     var _initCounter = 0;
76699     var _needWidth = {};
76700     var _lastPointerType;
76701     function render(container) {
76702       container.on("click.ui", function(d3_event) {
76703         if (d3_event.button !== 0)
76704           return;
76705         if (!d3_event.composedPath)
76706           return;
76707         var isOkayTarget = d3_event.composedPath().some(function(node) {
76708           return node.nodeType === 1 && // clicking <input> focuses it and/or changes a value
76709           (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
76710           node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
76711           node.nodeName === "A");
76712         });
76713         if (isOkayTarget)
76714           return;
76715         d3_event.preventDefault();
76716       });
76717       var detected = utilDetect();
76718       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
76719       // but we only need to do this on desktop Safari anyway. – #7694
76720       !detected.isMobileWebKit) {
76721         container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
76722           d3_event.preventDefault();
76723         });
76724       }
76725       if ("PointerEvent" in window) {
76726         select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
76727           var pointerType = d3_event.pointerType || "mouse";
76728           if (_lastPointerType !== pointerType) {
76729             _lastPointerType = pointerType;
76730             container.attr("pointer", pointerType);
76731           }
76732         }, true);
76733       } else {
76734         _lastPointerType = "mouse";
76735         container.attr("pointer", "mouse");
76736       }
76737       container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
76738       container.call(uiFullScreen(context));
76739       var map2 = context.map();
76740       map2.redrawEnable(false);
76741       map2.on("hitMinZoom.ui", function() {
76742         ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
76743       });
76744       container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
76745       container.append("div").attr("class", "sidebar").call(ui.sidebar);
76746       var content = container.append("div").attr("class", "main-content active");
76747       content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
76748       content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
76749       var overMap = content.append("div").attr("class", "over-map");
76750       overMap.append("div").attr("class", "select-trap").text("t");
76751       overMap.call(uiMapInMap(context)).call(uiNotice(context));
76752       overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
76753       var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
76754       var controls = controlsWrap.append("div").attr("class", "map-controls");
76755       controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
76756       controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
76757       controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
76758       controlsWrap.on("wheel.mapControls", function(d3_event) {
76759         if (!d3_event.deltaX) {
76760           controlsWrap.node().scrollTop += d3_event.deltaY;
76761         }
76762       });
76763       var panes = overMap.append("div").attr("class", "map-panes");
76764       var uiPanes = [
76765         uiPaneBackground(context),
76766         uiPaneMapData(context),
76767         uiPaneIssues(context),
76768         uiPanePreferences(context),
76769         uiPaneHelp(context)
76770       ];
76771       uiPanes.forEach(function(pane) {
76772         controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
76773         panes.call(pane.renderPane);
76774       });
76775       ui.info = uiInfo(context);
76776       overMap.call(ui.info);
76777       overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
76778       overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
76779       var about = content.append("div").attr("class", "map-footer");
76780       about.append("div").attr("class", "api-status").call(uiStatus(context));
76781       var footer = about.append("div").attr("class", "map-footer-bar fillD");
76782       footer.append("div").attr("class", "flash-wrap footer-hide");
76783       var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
76784       footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
76785       var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
76786       aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
76787       var apiConnections = context.connection().apiConnections();
76788       if (apiConnections && apiConnections.length > 1) {
76789         aboutList.append("li").attr("class", "source-switch").call(
76790           uiSourceSwitch(context).keys(apiConnections)
76791         );
76792       }
76793       aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
76794       aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
76795       var issueLinks = aboutList.append("li");
76796       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"));
76797       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"));
76798       aboutList.append("li").attr("class", "version").call(uiVersion(context));
76799       if (!context.embed()) {
76800         aboutList.call(uiAccount(context));
76801       }
76802       ui.onResize();
76803       map2.redrawEnable(true);
76804       ui.hash = behaviorHash(context);
76805       ui.hash();
76806       if (!ui.hash.hadLocation) {
76807         map2.centerZoom([0, 0], 2);
76808       }
76809       window.onbeforeunload = function() {
76810         return context.save();
76811       };
76812       window.onunload = function() {
76813         context.history().unlock();
76814       };
76815       select_default2(window).on("resize.editor", function() {
76816         ui.onResize();
76817       });
76818       var panPixels = 80;
76819       context.keybinding().on("\u232B", function(d3_event) {
76820         d3_event.preventDefault();
76821       }).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) {
76822         if (d3_event) {
76823           d3_event.stopImmediatePropagation();
76824           d3_event.preventDefault();
76825         }
76826         var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
76827         if (previousBackground) {
76828           var currentBackground = context.background().baseLayerSource();
76829           corePreferences("background-last-used-toggle", currentBackground.id);
76830           corePreferences("background-last-used", previousBackground.id);
76831           context.background().baseLayerSource(previousBackground);
76832         }
76833       }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
76834         d3_event.preventDefault();
76835         d3_event.stopPropagation();
76836         context.map().toggleWireframe();
76837       }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
76838         d3_event.preventDefault();
76839         d3_event.stopPropagation();
76840         var mode = context.mode();
76841         if (mode && /^draw/.test(mode.id))
76842           return;
76843         var layer = context.layers().layer("osm");
76844         if (layer) {
76845           layer.enabled(!layer.enabled());
76846           if (!layer.enabled()) {
76847             context.enter(modeBrowse(context));
76848           }
76849         }
76850       }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
76851         d3_event.preventDefault();
76852         context.map().toggleHighlightEdited();
76853       });
76854       context.on("enter.editor", function(entered) {
76855         container.classed("mode-" + entered.id, true);
76856       }).on("exit.editor", function(exited) {
76857         container.classed("mode-" + exited.id, false);
76858       });
76859       context.enter(modeBrowse(context));
76860       if (!_initCounter++) {
76861         if (!ui.hash.startWalkthrough) {
76862           context.container().call(uiSplash(context)).call(uiRestore(context));
76863         }
76864         context.container().call(ui.shortcuts);
76865       }
76866       var osm = context.connection();
76867       var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
76868       if (osm && auth) {
76869         osm.on("authLoading.ui", function() {
76870           context.container().call(auth);
76871         }).on("authDone.ui", function() {
76872           auth.close();
76873         });
76874       }
76875       _initCounter++;
76876       if (ui.hash.startWalkthrough) {
76877         ui.hash.startWalkthrough = false;
76878         context.container().call(uiIntro(context));
76879       }
76880       function pan(d2) {
76881         return function(d3_event) {
76882           if (d3_event.shiftKey)
76883             return;
76884           if (context.container().select(".combobox").size())
76885             return;
76886           d3_event.preventDefault();
76887           context.map().pan(d2, 100);
76888         };
76889       }
76890     }
76891     let ui = {};
76892     let _loadPromise;
76893     ui.ensureLoaded = () => {
76894       if (_loadPromise)
76895         return _loadPromise;
76896       return _loadPromise = Promise.all([
76897         // must have strings and presets before loading the UI
76898         _mainLocalizer.ensureLoaded(),
76899         _mainPresetIndex.ensureLoaded()
76900       ]).then(() => {
76901         if (!context.container().empty())
76902           render(context.container());
76903       }).catch((err) => console.error(err));
76904     };
76905     ui.restart = function() {
76906       context.keybinding().clear();
76907       _loadPromise = null;
76908       context.container().selectAll("*").remove();
76909       ui.ensureLoaded();
76910     };
76911     ui.lastPointerType = function() {
76912       return _lastPointerType;
76913     };
76914     ui.svgDefs = svgDefs(context);
76915     ui.flash = uiFlash(context);
76916     ui.sidebar = uiSidebar(context);
76917     ui.photoviewer = uiPhotoviewer(context);
76918     ui.shortcuts = uiShortcuts(context);
76919     ui.onResize = function(withPan) {
76920       var map2 = context.map();
76921       var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
76922       utilGetDimensions(context.container().select(".sidebar"), true);
76923       if (withPan !== void 0) {
76924         map2.redrawEnable(false);
76925         map2.pan(withPan);
76926         map2.redrawEnable(true);
76927       }
76928       map2.dimensions(mapDimensions);
76929       ui.photoviewer.onMapResize();
76930       ui.checkOverflow(".top-toolbar");
76931       ui.checkOverflow(".map-footer-bar");
76932       var resizeWindowEvent = document.createEvent("Event");
76933       resizeWindowEvent.initEvent("resizeWindow", true, true);
76934       document.dispatchEvent(resizeWindowEvent);
76935     };
76936     ui.checkOverflow = function(selector, reset) {
76937       if (reset) {
76938         delete _needWidth[selector];
76939       }
76940       var selection2 = context.container().select(selector);
76941       if (selection2.empty())
76942         return;
76943       var scrollWidth = selection2.property("scrollWidth");
76944       var clientWidth = selection2.property("clientWidth");
76945       var needed = _needWidth[selector] || scrollWidth;
76946       if (scrollWidth > clientWidth) {
76947         selection2.classed("narrow", true);
76948         if (!_needWidth[selector]) {
76949           _needWidth[selector] = scrollWidth;
76950         }
76951       } else if (scrollWidth >= needed) {
76952         selection2.classed("narrow", false);
76953       }
76954     };
76955     ui.togglePanes = function(showPane) {
76956       var hidePanes = context.container().selectAll(".map-pane.shown");
76957       var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
76958       hidePanes.classed("shown", false).classed("hide", true);
76959       context.container().selectAll(".map-pane-control button").classed("active", false);
76960       if (showPane) {
76961         hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
76962         context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
76963         showPane.classed("shown", true).classed("hide", false);
76964         if (hidePanes.empty()) {
76965           showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
76966         } else {
76967           showPane.style(side, "0px");
76968         }
76969       } else {
76970         hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
76971           select_default2(this).classed("shown", false).classed("hide", true);
76972         });
76973       }
76974     };
76975     var _editMenu = uiEditMenu(context);
76976     ui.editMenu = function() {
76977       return _editMenu;
76978     };
76979     ui.showEditMenu = function(anchorPoint, triggerType, operations) {
76980       ui.closeEditMenu();
76981       if (!operations && context.mode().operations)
76982         operations = context.mode().operations();
76983       if (!operations || !operations.length)
76984         return;
76985       if (!context.map().editableDataEnabled())
76986         return;
76987       var surfaceNode = context.surface().node();
76988       if (surfaceNode.focus) {
76989         surfaceNode.focus();
76990       }
76991       operations.forEach(function(operation2) {
76992         if (operation2.point)
76993           operation2.point(anchorPoint);
76994       });
76995       _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
76996       context.map().supersurface.call(_editMenu);
76997     };
76998     ui.closeEditMenu = function() {
76999       context.map().supersurface.select(".edit-menu").remove();
77000     };
77001     var _saveLoading = select_default2(null);
77002     context.uploader().on("saveStarted.ui", function() {
77003       _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
77004       context.container().call(_saveLoading);
77005     }).on("saveEnded.ui", function() {
77006       _saveLoading.close();
77007       _saveLoading = select_default2(null);
77008     });
77009     marked.use({
77010       mangle: false,
77011       headerIds: false
77012     });
77013     return ui;
77014   }
77015
77016   // modules/core/context.js
77017   function coreContext() {
77018     const dispatch14 = dispatch_default("enter", "exit", "change");
77019     let context = utilRebind({}, dispatch14, "on");
77020     let _deferred2 = /* @__PURE__ */ new Set();
77021     context.version = package_default.version;
77022     context.privacyVersion = "20201202";
77023     context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
77024     context.changeset = null;
77025     let _defaultChangesetComment = context.initialHashParams.comment;
77026     let _defaultChangesetSource = context.initialHashParams.source;
77027     let _defaultChangesetHashtags = context.initialHashParams.hashtags;
77028     context.defaultChangesetComment = function(val) {
77029       if (!arguments.length)
77030         return _defaultChangesetComment;
77031       _defaultChangesetComment = val;
77032       return context;
77033     };
77034     context.defaultChangesetSource = function(val) {
77035       if (!arguments.length)
77036         return _defaultChangesetSource;
77037       _defaultChangesetSource = val;
77038       return context;
77039     };
77040     context.defaultChangesetHashtags = function(val) {
77041       if (!arguments.length)
77042         return _defaultChangesetHashtags;
77043       _defaultChangesetHashtags = val;
77044       return context;
77045     };
77046     let _setsDocumentTitle = true;
77047     context.setsDocumentTitle = function(val) {
77048       if (!arguments.length)
77049         return _setsDocumentTitle;
77050       _setsDocumentTitle = val;
77051       return context;
77052     };
77053     let _documentTitleBase = document.title;
77054     context.documentTitleBase = function(val) {
77055       if (!arguments.length)
77056         return _documentTitleBase;
77057       _documentTitleBase = val;
77058       return context;
77059     };
77060     let _ui;
77061     context.ui = () => _ui;
77062     context.lastPointerType = () => _ui.lastPointerType();
77063     let _keybinding = utilKeybinding("context");
77064     context.keybinding = () => _keybinding;
77065     select_default2(document).call(_keybinding);
77066     let _connection = services.osm;
77067     let _history;
77068     let _validator;
77069     let _uploader;
77070     context.connection = () => _connection;
77071     context.history = () => _history;
77072     context.validator = () => _validator;
77073     context.uploader = () => _uploader;
77074     context.preauth = (options2) => {
77075       if (_connection) {
77076         _connection.switch(options2);
77077       }
77078       return context;
77079     };
77080     context.locale = function(locale2) {
77081       if (!arguments.length)
77082         return _mainLocalizer.localeCode();
77083       _mainLocalizer.preferredLocaleCodes(locale2);
77084       return context;
77085     };
77086     function afterLoad(cid, callback) {
77087       return (err, result) => {
77088         if (err) {
77089           if (err.status === 400 || err.status === 401 || err.status === 403) {
77090             if (_connection) {
77091               _connection.logout();
77092             }
77093           }
77094           if (typeof callback === "function") {
77095             callback(err);
77096           }
77097           return;
77098         } else if (_connection && _connection.getConnectionId() !== cid) {
77099           if (typeof callback === "function") {
77100             callback({ message: "Connection Switched", status: -1 });
77101           }
77102           return;
77103         } else {
77104           _history.merge(result.data, result.extent);
77105           if (typeof callback === "function") {
77106             callback(err, result);
77107           }
77108           return;
77109         }
77110       };
77111     }
77112     context.loadTiles = (projection2, callback) => {
77113       const handle = window.requestIdleCallback(() => {
77114         _deferred2.delete(handle);
77115         if (_connection && context.editableDataEnabled()) {
77116           const cid = _connection.getConnectionId();
77117           _connection.loadTiles(projection2, afterLoad(cid, callback));
77118         }
77119       });
77120       _deferred2.add(handle);
77121     };
77122     context.loadTileAtLoc = (loc, callback) => {
77123       const handle = window.requestIdleCallback(() => {
77124         _deferred2.delete(handle);
77125         if (_connection && context.editableDataEnabled()) {
77126           const cid = _connection.getConnectionId();
77127           _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
77128         }
77129       });
77130       _deferred2.add(handle);
77131     };
77132     context.loadEntity = (entityID, callback) => {
77133       if (_connection) {
77134         const cid = _connection.getConnectionId();
77135         _connection.loadEntity(entityID, afterLoad(cid, callback));
77136         _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
77137       }
77138     };
77139     context.loadNote = (entityID, callback) => {
77140       if (_connection) {
77141         const cid = _connection.getConnectionId();
77142         _connection.loadEntityNote(entityID, afterLoad(cid, callback));
77143       }
77144     };
77145     context.zoomToEntity = (entityID, zoomTo) => {
77146       context.loadEntity(entityID, (err, result) => {
77147         if (err)
77148           return;
77149         if (zoomTo !== false) {
77150           const entity = result.data.find((e3) => e3.id === entityID);
77151           if (entity) {
77152             _map.zoomTo(entity);
77153           }
77154         }
77155       });
77156       _map.on("drawn.zoomToEntity", () => {
77157         if (!context.hasEntity(entityID))
77158           return;
77159         _map.on("drawn.zoomToEntity", null);
77160         context.on("enter.zoomToEntity", null);
77161         context.enter(modeSelect(context, [entityID]));
77162       });
77163       context.on("enter.zoomToEntity", () => {
77164         if (_mode.id !== "browse") {
77165           _map.on("drawn.zoomToEntity", null);
77166           context.on("enter.zoomToEntity", null);
77167         }
77168       });
77169     };
77170     let _minEditableZoom = 16;
77171     context.minEditableZoom = function(val) {
77172       if (!arguments.length)
77173         return _minEditableZoom;
77174       _minEditableZoom = val;
77175       if (_connection) {
77176         _connection.tileZoom(val);
77177       }
77178       return context;
77179     };
77180     context.maxCharsForTagKey = () => 255;
77181     context.maxCharsForTagValue = () => 255;
77182     context.maxCharsForRelationRole = () => 255;
77183     context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
77184     context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
77185     context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
77186     let _inIntro = false;
77187     context.inIntro = function(val) {
77188       if (!arguments.length)
77189         return _inIntro;
77190       _inIntro = val;
77191       return context;
77192     };
77193     context.save = () => {
77194       if (_inIntro || context.container().select(".modal").size())
77195         return;
77196       let canSave;
77197       if (_mode && _mode.id === "save") {
77198         canSave = false;
77199         if (services.osm && services.osm.isChangesetInflight()) {
77200           _history.clearSaved();
77201           return;
77202         }
77203       } else {
77204         canSave = context.selectedIDs().every((id2) => {
77205           const entity = context.hasEntity(id2);
77206           return entity && !entity.isDegenerate();
77207         });
77208       }
77209       if (canSave) {
77210         _history.save();
77211       }
77212       if (_history.hasChanges()) {
77213         return _t("save.unsaved_changes");
77214       }
77215     };
77216     context.debouncedSave = debounce_default(context.save, 350);
77217     function withDebouncedSave(fn) {
77218       return function() {
77219         const result = fn.apply(_history, arguments);
77220         context.debouncedSave();
77221         return result;
77222       };
77223     }
77224     context.hasEntity = (id2) => _history.graph().hasEntity(id2);
77225     context.entity = (id2) => _history.graph().entity(id2);
77226     let _mode;
77227     context.mode = () => _mode;
77228     context.enter = (newMode) => {
77229       if (_mode) {
77230         _mode.exit();
77231         dispatch14.call("exit", this, _mode);
77232       }
77233       _mode = newMode;
77234       _mode.enter();
77235       dispatch14.call("enter", this, _mode);
77236     };
77237     context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
77238     context.activeID = () => _mode && _mode.activeID && _mode.activeID();
77239     let _selectedNoteID;
77240     context.selectedNoteID = function(noteID) {
77241       if (!arguments.length)
77242         return _selectedNoteID;
77243       _selectedNoteID = noteID;
77244       return context;
77245     };
77246     let _selectedErrorID;
77247     context.selectedErrorID = function(errorID) {
77248       if (!arguments.length)
77249         return _selectedErrorID;
77250       _selectedErrorID = errorID;
77251       return context;
77252     };
77253     context.install = (behavior) => context.surface().call(behavior);
77254     context.uninstall = (behavior) => context.surface().call(behavior.off);
77255     let _copyGraph;
77256     context.copyGraph = () => _copyGraph;
77257     let _copyIDs = [];
77258     context.copyIDs = function(val) {
77259       if (!arguments.length)
77260         return _copyIDs;
77261       _copyIDs = val;
77262       _copyGraph = _history.graph();
77263       return context;
77264     };
77265     let _copyLonLat;
77266     context.copyLonLat = function(val) {
77267       if (!arguments.length)
77268         return _copyLonLat;
77269       _copyLonLat = val;
77270       return context;
77271     };
77272     let _background;
77273     context.background = () => _background;
77274     let _features;
77275     context.features = () => _features;
77276     context.hasHiddenConnections = (id2) => {
77277       const graph = _history.graph();
77278       const entity = graph.entity(id2);
77279       return _features.hasHiddenConnections(entity, graph);
77280     };
77281     let _photos;
77282     context.photos = () => _photos;
77283     let _map;
77284     context.map = () => _map;
77285     context.layers = () => _map.layers();
77286     context.surface = () => _map.surface;
77287     context.editableDataEnabled = () => _map.editableDataEnabled();
77288     context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
77289     context.editable = () => {
77290       const mode = context.mode();
77291       if (!mode || mode.id === "save")
77292         return false;
77293       return _map.editableDataEnabled();
77294     };
77295     let _debugFlags = {
77296       tile: false,
77297       // tile boundaries
77298       collision: false,
77299       // label collision bounding boxes
77300       imagery: false,
77301       // imagery bounding polygons
77302       target: false,
77303       // touch targets
77304       downloaded: false
77305       // downloaded data from osm
77306     };
77307     context.debugFlags = () => _debugFlags;
77308     context.getDebug = (flag) => flag && _debugFlags[flag];
77309     context.setDebug = function(flag, val) {
77310       if (arguments.length === 1)
77311         val = true;
77312       _debugFlags[flag] = val;
77313       dispatch14.call("change");
77314       return context;
77315     };
77316     let _container = select_default2(null);
77317     context.container = function(val) {
77318       if (!arguments.length)
77319         return _container;
77320       _container = val;
77321       _container.classed("ideditor", true);
77322       return context;
77323     };
77324     context.containerNode = function(val) {
77325       if (!arguments.length)
77326         return context.container().node();
77327       context.container(select_default2(val));
77328       return context;
77329     };
77330     let _embed;
77331     context.embed = function(val) {
77332       if (!arguments.length)
77333         return _embed;
77334       _embed = val;
77335       return context;
77336     };
77337     let _assetPath = "";
77338     context.assetPath = function(val) {
77339       if (!arguments.length)
77340         return _assetPath;
77341       _assetPath = val;
77342       _mainFileFetcher.assetPath(val);
77343       return context;
77344     };
77345     let _assetMap = {};
77346     context.assetMap = function(val) {
77347       if (!arguments.length)
77348         return _assetMap;
77349       _assetMap = val;
77350       _mainFileFetcher.assetMap(val);
77351       return context;
77352     };
77353     context.asset = (val) => {
77354       if (/^http(s)?:\/\//i.test(val))
77355         return val;
77356       const filename = _assetPath + val;
77357       return _assetMap[filename] || filename;
77358     };
77359     context.imagePath = (val) => context.asset("img/".concat(val));
77360     context.reset = context.flush = () => {
77361       context.debouncedSave.cancel();
77362       Array.from(_deferred2).forEach((handle) => {
77363         window.cancelIdleCallback(handle);
77364         _deferred2.delete(handle);
77365       });
77366       Object.values(services).forEach((service) => {
77367         if (service && typeof service.reset === "function") {
77368           service.reset(context);
77369         }
77370       });
77371       context.changeset = null;
77372       _validator.reset();
77373       _features.reset();
77374       _history.reset();
77375       _uploader.reset();
77376       context.container().select(".inspector-wrap *").remove();
77377       return context;
77378     };
77379     context.projection = geoRawMercator();
77380     context.curtainProjection = geoRawMercator();
77381     context.init = () => {
77382       instantiateInternal();
77383       initializeDependents();
77384       return context;
77385       function instantiateInternal() {
77386         _history = coreHistory(context);
77387         context.graph = _history.graph;
77388         context.pauseChangeDispatch = _history.pauseChangeDispatch;
77389         context.resumeChangeDispatch = _history.resumeChangeDispatch;
77390         context.perform = withDebouncedSave(_history.perform);
77391         context.replace = withDebouncedSave(_history.replace);
77392         context.pop = withDebouncedSave(_history.pop);
77393         context.overwrite = withDebouncedSave(_history.overwrite);
77394         context.undo = withDebouncedSave(_history.undo);
77395         context.redo = withDebouncedSave(_history.redo);
77396         _validator = coreValidator(context);
77397         _uploader = coreUploader(context);
77398         _background = rendererBackground(context);
77399         _features = rendererFeatures(context);
77400         _map = rendererMap(context);
77401         _photos = rendererPhotos(context);
77402         _ui = uiInit(context);
77403       }
77404       function initializeDependents() {
77405         if (context.initialHashParams.presets) {
77406           _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
77407         }
77408         if (context.initialHashParams.locale) {
77409           _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
77410         }
77411         _mainLocalizer.ensureLoaded();
77412         _mainPresetIndex.ensureLoaded();
77413         _background.ensureLoaded();
77414         Object.values(services).forEach((service) => {
77415           if (service && typeof service.init === "function") {
77416             service.init();
77417           }
77418         });
77419         _map.init();
77420         _validator.init();
77421         _features.init();
77422         if (services.maprules && context.initialHashParams.maprules) {
77423           json_default(context.initialHashParams.maprules).then((mapcss) => {
77424             services.maprules.init();
77425             mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
77426           }).catch(() => {
77427           });
77428         }
77429         if (!context.container().empty()) {
77430           _ui.ensureLoaded().then(() => {
77431             _background.init();
77432             _photos.init();
77433           });
77434         }
77435       }
77436     };
77437     return context;
77438   }
77439
77440   // modules/services/nominatim.js
77441   var apibase = nominatimApiUrl;
77442   var _inflight = {};
77443   var _nominatimCache;
77444   var nominatim_default = {
77445     init: function() {
77446       _inflight = {};
77447       _nominatimCache = new import_rbush7.default();
77448     },
77449     reset: function() {
77450       Object.values(_inflight).forEach(function(controller) {
77451         controller.abort();
77452       });
77453       _inflight = {};
77454       _nominatimCache = new import_rbush7.default();
77455     },
77456     countryCode: function(location, callback) {
77457       this.reverse(location, function(err, result) {
77458         if (err) {
77459           return callback(err);
77460         } else if (result.address) {
77461           return callback(null, result.address.country_code);
77462         } else {
77463           return callback("Unable to geocode", null);
77464         }
77465       });
77466     },
77467     reverse: function(loc, callback) {
77468       var cached = _nominatimCache.search(
77469         { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
77470       );
77471       if (cached.length > 0) {
77472         if (callback)
77473           callback(null, cached[0].data);
77474         return;
77475       }
77476       var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
77477       var url = apibase + "reverse?" + utilQsString(params);
77478       if (_inflight[url])
77479         return;
77480       var controller = new AbortController();
77481       _inflight[url] = controller;
77482       json_default(url, {
77483         signal: controller.signal,
77484         headers: {
77485           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77486         }
77487       }).then(function(result) {
77488         delete _inflight[url];
77489         if (result && result.error) {
77490           throw new Error(result.error);
77491         }
77492         var extent = geoExtent(loc).padByMeters(200);
77493         _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
77494         if (callback)
77495           callback(null, result);
77496       }).catch(function(err) {
77497         delete _inflight[url];
77498         if (err.name === "AbortError")
77499           return;
77500         if (callback)
77501           callback(err.message);
77502       });
77503     },
77504     search: function(val, callback) {
77505       const params = {
77506         q: val,
77507         limit: 10,
77508         format: "json"
77509       };
77510       var url = apibase + "search?" + utilQsString(params);
77511       if (_inflight[url])
77512         return;
77513       var controller = new AbortController();
77514       _inflight[url] = controller;
77515       json_default(url, {
77516         signal: controller.signal,
77517         headers: {
77518           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77519         }
77520       }).then(function(result) {
77521         delete _inflight[url];
77522         if (result && result.error) {
77523           throw new Error(result.error);
77524         }
77525         if (callback)
77526           callback(null, result);
77527       }).catch(function(err) {
77528         delete _inflight[url];
77529         if (err.name === "AbortError")
77530           return;
77531         if (callback)
77532           callback(err.message);
77533       });
77534     }
77535   };
77536
77537   // node_modules/name-suggestion-index/lib/matcher.js
77538   var import_which_polygon4 = __toESM(require_which_polygon(), 1);
77539
77540   // node_modules/name-suggestion-index/lib/simplify.js
77541   var import_diacritics3 = __toESM(require_diacritics(), 1);
77542   function simplify2(str) {
77543     if (typeof str !== "string")
77544       return "";
77545     return import_diacritics3.default.remove(
77546       str.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
77547     );
77548   }
77549
77550   // node_modules/name-suggestion-index/config/matchGroups.json
77551   var matchGroups_default = {
77552     matchGroups: {
77553       adult_gaming_centre: [
77554         "amenity/casino",
77555         "amenity/gambling",
77556         "leisure/adult_gaming_centre"
77557       ],
77558       beauty: [
77559         "shop/beauty",
77560         "shop/hairdresser_supply"
77561       ],
77562       bed: [
77563         "shop/bed",
77564         "shop/furniture"
77565       ],
77566       beverages: [
77567         "shop/alcohol",
77568         "shop/beer",
77569         "shop/beverages",
77570         "shop/kiosk",
77571         "shop/wine"
77572       ],
77573       camping: [
77574         "tourism/camp_site",
77575         "tourism/caravan_site"
77576       ],
77577       car_parts: [
77578         "shop/car_parts",
77579         "shop/car_repair",
77580         "shop/tires",
77581         "shop/tyres"
77582       ],
77583       clinic: [
77584         "amenity/clinic",
77585         "amenity/doctors",
77586         "healthcare/clinic",
77587         "healthcare/laboratory",
77588         "healthcare/physiotherapist",
77589         "healthcare/sample_collection",
77590         "healthcare/dialysis"
77591       ],
77592       convenience: [
77593         "shop/beauty",
77594         "shop/chemist",
77595         "shop/convenience",
77596         "shop/cosmetics",
77597         "shop/grocery",
77598         "shop/kiosk",
77599         "shop/newsagent",
77600         "shop/perfumery"
77601       ],
77602       coworking: [
77603         "amenity/coworking_space",
77604         "office/coworking",
77605         "office/coworking_space"
77606       ],
77607       dentist: [
77608         "amenity/dentist",
77609         "amenity/doctors",
77610         "healthcare/dentist"
77611       ],
77612       electronics: [
77613         "office/telecommunication",
77614         "shop/computer",
77615         "shop/electronics",
77616         "shop/hifi",
77617         "shop/kiosk",
77618         "shop/mobile",
77619         "shop/mobile_phone",
77620         "shop/telecommunication"
77621       ],
77622       fabric: [
77623         "shop/fabric",
77624         "shop/haberdashery",
77625         "shop/sewing"
77626       ],
77627       fashion: [
77628         "shop/accessories",
77629         "shop/bag",
77630         "shop/boutique",
77631         "shop/clothes",
77632         "shop/department_store",
77633         "shop/fashion",
77634         "shop/fashion_accessories",
77635         "shop/sports",
77636         "shop/shoes"
77637       ],
77638       financial: [
77639         "amenity/bank",
77640         "office/accountant",
77641         "office/financial",
77642         "office/financial_advisor",
77643         "office/tax_advisor",
77644         "shop/tax"
77645       ],
77646       fitness: [
77647         "leisure/fitness_centre",
77648         "leisure/fitness_center",
77649         "leisure/sports_centre",
77650         "leisure/sports_center"
77651       ],
77652       food: [
77653         "amenity/bar",
77654         "amenity/cafe",
77655         "amenity/fast_food",
77656         "amenity/ice_cream",
77657         "amenity/pub",
77658         "amenity/restaurant",
77659         "shop/bakery",
77660         "shop/candy",
77661         "shop/chocolate",
77662         "shop/coffee",
77663         "shop/confectionary",
77664         "shop/confectionery",
77665         "shop/food",
77666         "shop/kiosk",
77667         "shop/ice_cream",
77668         "shop/pastry",
77669         "shop/tea"
77670       ],
77671       fuel: [
77672         "amenity/fuel",
77673         "shop/gas",
77674         "shop/convenience;gas",
77675         "shop/gas;convenience"
77676       ],
77677       gift: [
77678         "shop/gift",
77679         "shop/card",
77680         "shop/cards",
77681         "shop/kiosk",
77682         "shop/stationery"
77683       ],
77684       hardware: [
77685         "shop/bathroom_furnishing",
77686         "shop/carpet",
77687         "shop/diy",
77688         "shop/doityourself",
77689         "shop/doors",
77690         "shop/electrical",
77691         "shop/flooring",
77692         "shop/hardware",
77693         "shop/hardware_store",
77694         "shop/power_tools",
77695         "shop/tool_hire",
77696         "shop/tools",
77697         "shop/trade"
77698       ],
77699       health_food: [
77700         "shop/health",
77701         "shop/health_food",
77702         "shop/herbalist",
77703         "shop/nutrition_supplements"
77704       ],
77705       hobby: [
77706         "shop/electronics",
77707         "shop/hobby",
77708         "shop/books",
77709         "shop/games",
77710         "shop/collector",
77711         "shop/toys",
77712         "shop/model",
77713         "shop/video_games",
77714         "shop/anime"
77715       ],
77716       hospital: [
77717         "amenity/doctors",
77718         "amenity/hospital",
77719         "healthcare/hospital"
77720       ],
77721       houseware: [
77722         "shop/houseware",
77723         "shop/interior_decoration"
77724       ],
77725       lifeboat_station: [
77726         "amenity/lifeboat_station",
77727         "emergency/lifeboat_station",
77728         "emergency/marine_rescue"
77729       ],
77730       lodging: [
77731         "tourism/hotel",
77732         "tourism/motel"
77733       ],
77734       money_transfer: [
77735         "amenity/money_transfer",
77736         "shop/money_transfer"
77737       ],
77738       office_supplies: [
77739         "shop/office_supplies",
77740         "shop/stationary",
77741         "shop/stationery"
77742       ],
77743       outdoor: [
77744         "shop/clothes",
77745         "shop/outdoor",
77746         "shop/sports"
77747       ],
77748       parcel_locker: [
77749         "amenity/parcel_locker",
77750         "amenity/vending_machine"
77751       ],
77752       pharmacy: [
77753         "amenity/doctors",
77754         "amenity/pharmacy",
77755         "healthcare/pharmacy"
77756       ],
77757       playground: [
77758         "amenity/theme_park",
77759         "leisure/amusement_arcade",
77760         "leisure/playground"
77761       ],
77762       rental: [
77763         "amenity/bicycle_rental",
77764         "amenity/boat_rental",
77765         "amenity/car_rental",
77766         "amenity/truck_rental",
77767         "amenity/vehicle_rental",
77768         "shop/kiosk",
77769         "shop/rental"
77770       ],
77771       school: [
77772         "amenity/childcare",
77773         "amenity/college",
77774         "amenity/kindergarten",
77775         "amenity/language_school",
77776         "amenity/prep_school",
77777         "amenity/school",
77778         "amenity/university"
77779       ],
77780       storage: [
77781         "shop/storage_units",
77782         "shop/storage_rental"
77783       ],
77784       substation: [
77785         "power/station",
77786         "power/substation",
77787         "power/sub_station"
77788       ],
77789       supermarket: [
77790         "shop/food",
77791         "shop/frozen_food",
77792         "shop/greengrocer",
77793         "shop/grocery",
77794         "shop/supermarket",
77795         "shop/wholesale"
77796       ],
77797       variety_store: [
77798         "shop/variety_store",
77799         "shop/discount",
77800         "shop/convenience"
77801       ],
77802       vending: [
77803         "amenity/vending_machine",
77804         "shop/kiosk",
77805         "shop/vending_machine"
77806       ],
77807       weight_loss: [
77808         "amenity/clinic",
77809         "amenity/doctors",
77810         "amenity/weight_clinic",
77811         "healthcare/counselling",
77812         "leisure/fitness_centre",
77813         "office/therapist",
77814         "shop/beauty",
77815         "shop/diet",
77816         "shop/food",
77817         "shop/health_food",
77818         "shop/herbalist",
77819         "shop/nutrition",
77820         "shop/nutrition_supplements",
77821         "shop/weight_loss"
77822       ],
77823       wholesale: [
77824         "shop/wholesale",
77825         "shop/supermarket",
77826         "shop/department_store"
77827       ]
77828     }
77829   };
77830
77831   // node_modules/name-suggestion-index/config/genericWords.json
77832   var genericWords_default = {
77833     genericWords: [
77834       "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
77835       "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
77836       "^(club|green|out|ware)\\s?house$",
77837       "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
77838       "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
77839       "^(hofladen|librairie|magazine?|maison)$",
77840       "^(mobile home|skate)?\\s?park$",
77841       "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
77842       "^\\?+$",
77843       "^private$",
77844       "^tattoo( studio)?$",
77845       "^windmill$",
77846       "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
77847     ]
77848   };
77849
77850   // node_modules/name-suggestion-index/config/trees.json
77851   var trees_default = {
77852     trees: {
77853       brands: {
77854         emoji: "\u{1F354}",
77855         mainTag: "brand:wikidata",
77856         sourceTags: ["brand", "name"],
77857         nameTags: {
77858           primary: "^(name|name:\\w+)$",
77859           alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
77860         }
77861       },
77862       flags: {
77863         emoji: "\u{1F6A9}",
77864         mainTag: "flag:wikidata",
77865         nameTags: {
77866           primary: "^(flag:name|flag:name:\\w+)$",
77867           alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
77868         }
77869       },
77870       operators: {
77871         emoji: "\u{1F4BC}",
77872         mainTag: "operator:wikidata",
77873         sourceTags: ["operator"],
77874         nameTags: {
77875           primary: "^(name|name:\\w+|operator|operator:\\w+)$",
77876           alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
77877         }
77878       },
77879       transit: {
77880         emoji: "\u{1F687}",
77881         mainTag: "network:wikidata",
77882         sourceTags: ["network"],
77883         nameTags: {
77884           primary: "^network$",
77885           alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
77886         }
77887       }
77888     }
77889   };
77890
77891   // node_modules/name-suggestion-index/lib/matcher.js
77892   var matchGroups = matchGroups_default.matchGroups;
77893   var trees = trees_default.trees;
77894   var Matcher = class {
77895     //
77896     // `constructor`
77897     // initialize the genericWords regexes
77898     constructor() {
77899       this.matchIndex = void 0;
77900       this.genericWords = /* @__PURE__ */ new Map();
77901       (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
77902       this.itemLocation = void 0;
77903       this.locationSets = void 0;
77904       this.locationIndex = void 0;
77905       this.warnings = [];
77906     }
77907     //
77908     // `buildMatchIndex()`
77909     // Call this to prepare the matcher for use
77910     //
77911     // `data` needs to be an Object indexed on a 'tree/key/value' path.
77912     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
77913     // {
77914     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
77915     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
77916     //    …
77917     // }
77918     //
77919     buildMatchIndex(data) {
77920       const that = this;
77921       if (that.matchIndex)
77922         return;
77923       that.matchIndex = /* @__PURE__ */ new Map();
77924       const seenTree = /* @__PURE__ */ new Map();
77925       Object.keys(data).forEach((tkv) => {
77926         const category = data[tkv];
77927         const parts = tkv.split("/", 3);
77928         const t2 = parts[0];
77929         const k2 = parts[1];
77930         const v2 = parts[2];
77931         const thiskv = "".concat(k2, "/").concat(v2);
77932         const tree = trees[t2];
77933         let branch = that.matchIndex.get(thiskv);
77934         if (!branch) {
77935           branch = {
77936             primary: /* @__PURE__ */ new Map(),
77937             alternate: /* @__PURE__ */ new Map(),
77938             excludeGeneric: /* @__PURE__ */ new Map(),
77939             excludeNamed: /* @__PURE__ */ new Map()
77940           };
77941           that.matchIndex.set(thiskv, branch);
77942         }
77943         const properties = category.properties || {};
77944         const exclude = properties.exclude || {};
77945         (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
77946         (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
77947         const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
77948         let items = category.items;
77949         if (!Array.isArray(items) || !items.length)
77950           return;
77951         const primaryName = new RegExp(tree.nameTags.primary, "i");
77952         const alternateName = new RegExp(tree.nameTags.alternate, "i");
77953         const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
77954         const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
77955         const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
77956         const matchGroupKV = /* @__PURE__ */ new Set();
77957         Object.values(matchGroups).forEach((matchGroup) => {
77958           const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
77959           if (!inGroup)
77960             return;
77961           matchGroup.forEach((otherkv) => {
77962             if (otherkv === thiskv)
77963               return;
77964             matchGroupKV.add(otherkv);
77965             const otherk = otherkv.split("/", 2)[0];
77966             genericKV.add("".concat(otherk, "/yes"));
77967           });
77968         });
77969         items.forEach((item) => {
77970           if (!item.id)
77971             return;
77972           if (Array.isArray(item.matchTags) && item.matchTags.length) {
77973             item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && !genericKV.has(matchTag));
77974             if (!item.matchTags.length)
77975               delete item.matchTags;
77976           }
77977           let kvTags = ["".concat(thiskv)].concat(item.matchTags || []);
77978           if (!skipGenericKV) {
77979             kvTags = kvTags.concat(Array.from(genericKV));
77980           }
77981           Object.keys(item.tags).forEach((osmkey) => {
77982             if (notName.test(osmkey))
77983               return;
77984             const osmvalue = item.tags[osmkey];
77985             if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue)))
77986               return;
77987             if (primaryName.test(osmkey)) {
77988               kvTags.forEach((kv) => insertName("primary", t2, kv, simplify2(osmvalue), item.id));
77989             } else if (alternateName.test(osmkey)) {
77990               kvTags.forEach((kv) => insertName("alternate", t2, kv, simplify2(osmvalue), item.id));
77991             }
77992           });
77993           let keepMatchNames = /* @__PURE__ */ new Set();
77994           (item.matchNames || []).forEach((matchName) => {
77995             const nsimple = simplify2(matchName);
77996             kvTags.forEach((kv) => {
77997               const branch2 = that.matchIndex.get(kv);
77998               const primaryLeaf = branch2 && branch2.primary.get(nsimple);
77999               const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
78000               const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
78001               const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
78002               if (!inPrimary && !inAlternate) {
78003                 insertName("alternate", t2, kv, nsimple, item.id);
78004                 keepMatchNames.add(matchName);
78005               }
78006             });
78007           });
78008           if (keepMatchNames.size) {
78009             item.matchNames = Array.from(keepMatchNames);
78010           } else {
78011             delete item.matchNames;
78012           }
78013         });
78014       });
78015       function insertName(which, t2, kv, nsimple, itemID) {
78016         if (!nsimple) {
78017           that.warnings.push("Warning: skipping empty ".concat(which, " name for item ").concat(t2, "/").concat(kv, ": ").concat(itemID));
78018           return;
78019         }
78020         let branch = that.matchIndex.get(kv);
78021         if (!branch) {
78022           branch = {
78023             primary: /* @__PURE__ */ new Map(),
78024             alternate: /* @__PURE__ */ new Map(),
78025             excludeGeneric: /* @__PURE__ */ new Map(),
78026             excludeNamed: /* @__PURE__ */ new Map()
78027           };
78028           that.matchIndex.set(kv, branch);
78029         }
78030         let leaf = branch[which].get(nsimple);
78031         if (!leaf) {
78032           leaf = /* @__PURE__ */ new Set();
78033           branch[which].set(nsimple, leaf);
78034         }
78035         leaf.add(itemID);
78036         if (!/yes$/.test(kv)) {
78037           const kvnsimple = "".concat(kv, "/").concat(nsimple);
78038           const existing = seenTree.get(kvnsimple);
78039           if (existing && existing !== t2) {
78040             const items = Array.from(leaf);
78041             that.warnings.push('Duplicate cache key "'.concat(kvnsimple, '" in trees "').concat(t2, '" and "').concat(existing, '", check items: ').concat(items));
78042             return;
78043           }
78044           seenTree.set(kvnsimple, t2);
78045         }
78046       }
78047       function skipGenericKVMatches(t2, k2, v2) {
78048         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";
78049       }
78050     }
78051     //
78052     // `buildLocationIndex()`
78053     // Call this to prepare a which-polygon location index.
78054     // This *resolves* all the locationSets into GeoJSON, which takes some time.
78055     // You can skip this step if you don't care about matching within a location.
78056     //
78057     // `data` needs to be an Object indexed on a 'tree/key/value' path.
78058     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
78059     // {
78060     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
78061     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
78062     //    …
78063     // }
78064     //
78065     buildLocationIndex(data, loco) {
78066       const that = this;
78067       if (that.locationIndex)
78068         return;
78069       that.itemLocation = /* @__PURE__ */ new Map();
78070       that.locationSets = /* @__PURE__ */ new Map();
78071       Object.keys(data).forEach((tkv) => {
78072         const items = data[tkv].items;
78073         if (!Array.isArray(items) || !items.length)
78074           return;
78075         items.forEach((item) => {
78076           if (that.itemLocation.has(item.id))
78077             return;
78078           let resolved;
78079           try {
78080             resolved = loco.resolveLocationSet(item.locationSet);
78081           } catch (err) {
78082             console.warn("buildLocationIndex: ".concat(err.message));
78083           }
78084           if (!resolved || !resolved.id)
78085             return;
78086           that.itemLocation.set(item.id, resolved.id);
78087           if (that.locationSets.has(resolved.id))
78088             return;
78089           let feature3 = _cloneDeep2(resolved.feature);
78090           feature3.id = resolved.id;
78091           feature3.properties.id = resolved.id;
78092           if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
78093             console.warn("buildLocationIndex: locationSet ".concat(resolved.id, " for ").concat(item.id, " resolves to an empty feature:"));
78094             console.warn(JSON.stringify(feature3));
78095             return;
78096           }
78097           that.locationSets.set(resolved.id, feature3);
78098         });
78099       });
78100       that.locationIndex = (0, import_which_polygon4.default)({ type: "FeatureCollection", features: [...that.locationSets.values()] });
78101       function _cloneDeep2(obj) {
78102         return JSON.parse(JSON.stringify(obj));
78103       }
78104     }
78105     //
78106     // `match()`
78107     // Pass parts and return an Array of matches.
78108     // `k` - key
78109     // `v` - value
78110     // `n` - namelike
78111     // `loc` - optional - [lon,lat] location to search
78112     //
78113     // 1. If the [k,v,n] tuple matches a canonical item…
78114     // Return an Array of match results.
78115     // Each result will include the area in km² that the item is valid.
78116     //
78117     // Order of results:
78118     // Primary ordering will be on the "match" column:
78119     //   "primary" - where the query matches the `name` tag, followed by
78120     //   "alternate" - where the query matches an alternate name tag (e.g. short_name, brand, operator, etc)
78121     // Secondary ordering will be on the "area" column:
78122     //   "area descending" if no location was provided, (worldwide before local)
78123     //   "area ascending" if location was provided (local before worldwide)
78124     //
78125     // [
78126     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78127     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78128     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78129     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78130     //   …
78131     // ]
78132     //
78133     // -or-
78134     //
78135     // 2. If the [k,v,n] tuple matches an exclude pattern…
78136     // Return an Array with a single exclude result, either
78137     //
78138     // [ { match: 'excludeGeneric', pattern: String,  kv: String } ]  // "generic" e.g. "Food Court"
78139     //   or
78140     // [ { match: 'excludeNamed', pattern: String,  kv: String } ]    // "named", e.g. "Kebabai"
78141     //
78142     // About results
78143     //   "generic" - a generic word that is probably not really a name.
78144     //     For these, iD should warn the user "Hey don't put 'food court' in the name tag".
78145     //   "named" - a real name like "Kebabai" that is just common, but not a brand.
78146     //     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.
78147     //
78148     // -or-
78149     //
78150     // 3. If the [k,v,n] tuple matches nothing of any kind, return `null`
78151     //
78152     //
78153     match(k2, v2, n3, loc) {
78154       const that = this;
78155       if (!that.matchIndex) {
78156         throw new Error("match:  matchIndex not built.");
78157       }
78158       let matchLocations;
78159       if (Array.isArray(loc) && that.locationIndex) {
78160         matchLocations = that.locationIndex([loc[0], loc[1], loc[0], loc[1]], true);
78161       }
78162       const nsimple = simplify2(n3);
78163       let seen = /* @__PURE__ */ new Set();
78164       let results = [];
78165       gatherResults("primary");
78166       gatherResults("alternate");
78167       if (results.length)
78168         return results;
78169       gatherResults("exclude");
78170       return results.length ? results : null;
78171       function gatherResults(which) {
78172         const kv = "".concat(k2, "/").concat(v2);
78173         let didMatch = tryMatch(which, kv);
78174         if (didMatch)
78175           return;
78176         for (let mg in matchGroups) {
78177           const matchGroup = matchGroups[mg];
78178           const inGroup = matchGroup.some((otherkv) => otherkv === kv);
78179           if (!inGroup)
78180             continue;
78181           for (let i3 = 0; i3 < matchGroup.length; i3++) {
78182             const otherkv = matchGroup[i3];
78183             if (otherkv === kv)
78184               continue;
78185             didMatch = tryMatch(which, otherkv);
78186             if (didMatch)
78187               return;
78188           }
78189         }
78190         if (which === "exclude") {
78191           const regex = [...that.genericWords.values()].find((regex2) => regex2.test(n3));
78192           if (regex) {
78193             results.push({ match: "excludeGeneric", pattern: String(regex) });
78194             return;
78195           }
78196         }
78197       }
78198       function tryMatch(which, kv) {
78199         const branch = that.matchIndex.get(kv);
78200         if (!branch)
78201           return;
78202         if (which === "exclude") {
78203           let regex = [...branch.excludeNamed.values()].find((regex2) => regex2.test(n3));
78204           if (regex) {
78205             results.push({ match: "excludeNamed", pattern: String(regex), kv });
78206             return;
78207           }
78208           regex = [...branch.excludeGeneric.values()].find((regex2) => regex2.test(n3));
78209           if (regex) {
78210             results.push({ match: "excludeGeneric", pattern: String(regex), kv });
78211             return;
78212           }
78213           return;
78214         }
78215         const leaf = branch[which].get(nsimple);
78216         if (!leaf || !leaf.size)
78217           return;
78218         let hits = Array.from(leaf).map((itemID) => {
78219           let area = Infinity;
78220           if (that.itemLocation && that.locationSets) {
78221             const location = that.locationSets.get(that.itemLocation.get(itemID));
78222             area = location && location.properties.area || Infinity;
78223           }
78224           return { match: which, itemID, area, kv, nsimple };
78225         });
78226         let sortFn = byAreaDescending;
78227         if (matchLocations) {
78228           hits = hits.filter(isValidLocation);
78229           sortFn = byAreaAscending;
78230         }
78231         if (!hits.length)
78232           return;
78233         hits.sort(sortFn).forEach((hit) => {
78234           if (seen.has(hit.itemID))
78235             return;
78236           seen.add(hit.itemID);
78237           results.push(hit);
78238         });
78239         return true;
78240         function isValidLocation(hit) {
78241           if (!that.itemLocation)
78242             return true;
78243           return matchLocations.find((props) => props.id === that.itemLocation.get(hit.itemID));
78244         }
78245         function byAreaAscending(hitA, hitB) {
78246           return hitA.area - hitB.area;
78247         }
78248         function byAreaDescending(hitA, hitB) {
78249           return hitB.area - hitA.area;
78250         }
78251       }
78252     }
78253     //
78254     // `getWarnings()`
78255     // Return any warnings discovered when buiding the index.
78256     // (currently this does nothing)
78257     //
78258     getWarnings() {
78259       return this.warnings;
78260     }
78261   };
78262
78263   // modules/services/nsi.js
78264   var import_vparse2 = __toESM(require_vparse());
78265   var _nsiStatus = "loading";
78266   var _nsi = {};
78267   var buildingPreset = {
78268     "building/commercial": true,
78269     "building/government": true,
78270     "building/hotel": true,
78271     "building/retail": true,
78272     "building/office": true,
78273     "building/supermarket": true,
78274     "building/yes": true
78275   };
78276   var notNames = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
78277   var notBranches = /(coop|express|wireless|factory|outlet)/i;
78278   function setNsiSources() {
78279     const nsiVersion = package_default.dependencies["name-suggestion-index"] || package_default.devDependencies["name-suggestion-index"];
78280     const v2 = (0, import_vparse2.default)(nsiVersion);
78281     const vMinor = "".concat(v2.major, ".").concat(v2.minor);
78282     const cdn = nsiCdnUrl.replace("{version}", vMinor);
78283     const sources = {
78284       "nsi_data": cdn + "dist/nsi.min.json",
78285       "nsi_dissolved": cdn + "dist/dissolved.min.json",
78286       "nsi_features": cdn + "dist/featureCollection.min.json",
78287       "nsi_generics": cdn + "dist/genericWords.min.json",
78288       "nsi_presets": cdn + "dist/presets/nsi-id-presets.min.json",
78289       "nsi_replacements": cdn + "dist/replacements.min.json",
78290       "nsi_trees": cdn + "dist/trees.min.json"
78291     };
78292     let fileMap = _mainFileFetcher.fileMap();
78293     for (const k2 in sources) {
78294       if (!fileMap[k2])
78295         fileMap[k2] = sources[k2];
78296     }
78297   }
78298   function loadNsiPresets() {
78299     return Promise.all([
78300       _mainFileFetcher.get("nsi_presets"),
78301       _mainFileFetcher.get("nsi_features")
78302     ]).then((vals) => {
78303       Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true);
78304       Object.values(vals[0].presets).forEach((preset) => {
78305         if (preset.tags["brand:wikidata"]) {
78306           preset.addTags["brand:wikipedia"] = "";
78307         }
78308         if (preset.tags["operator:wikidata"]) {
78309           preset.addTags["operator:wikipedia"] = "";
78310         }
78311         if (preset.tags["network:wikidata"]) {
78312           preset.addTags["network:wikipedia"] = "";
78313         }
78314       });
78315       _mainPresetIndex.merge({
78316         presets: vals[0].presets,
78317         featureCollection: vals[1]
78318       });
78319     });
78320   }
78321   function loadNsiData() {
78322     return Promise.all([
78323       _mainFileFetcher.get("nsi_data"),
78324       _mainFileFetcher.get("nsi_dissolved"),
78325       _mainFileFetcher.get("nsi_replacements"),
78326       _mainFileFetcher.get("nsi_trees")
78327     ]).then((vals) => {
78328       _nsi = {
78329         data: vals[0].nsi,
78330         // the raw name-suggestion-index data
78331         dissolved: vals[1].dissolved,
78332         // list of dissolved items
78333         replacements: vals[2].replacements,
78334         // trivial old->new qid replacements
78335         trees: vals[3].trees,
78336         // metadata about trees, main tags
78337         kvt: /* @__PURE__ */ new Map(),
78338         // Map (k -> Map (v -> t) )
78339         qids: /* @__PURE__ */ new Map(),
78340         // Map (wd/wp tag values -> qids)
78341         ids: /* @__PURE__ */ new Map()
78342         // Map (id -> NSI item)
78343       };
78344       const matcher = _nsi.matcher = new Matcher();
78345       matcher.buildMatchIndex(_nsi.data);
78346       matcher.itemLocation = /* @__PURE__ */ new Map();
78347       matcher.locationSets = /* @__PURE__ */ new Map();
78348       Object.keys(_nsi.data).forEach((tkv) => {
78349         const items = _nsi.data[tkv].items;
78350         if (!Array.isArray(items) || !items.length)
78351           return;
78352         items.forEach((item) => {
78353           if (matcher.itemLocation.has(item.id))
78354             return;
78355           const locationSetID = _sharedLocationManager.locationSetID(item.locationSet);
78356           matcher.itemLocation.set(item.id, locationSetID);
78357           if (matcher.locationSets.has(locationSetID))
78358             return;
78359           const fakeFeature = { id: locationSetID, properties: { id: locationSetID, area: 1 } };
78360           matcher.locationSets.set(locationSetID, fakeFeature);
78361         });
78362       });
78363       matcher.locationIndex = (bbox2) => {
78364         const validHere = _sharedLocationManager.locationSetsAt([bbox2[0], bbox2[1]]);
78365         const results = [];
78366         for (const [locationSetID, area] of Object.entries(validHere)) {
78367           const fakeFeature = matcher.locationSets.get(locationSetID);
78368           if (fakeFeature) {
78369             fakeFeature.properties.area = area;
78370             results.push(fakeFeature);
78371           }
78372         }
78373         return results;
78374       };
78375       Object.keys(_nsi.data).forEach((tkv) => {
78376         const category = _nsi.data[tkv];
78377         const parts = tkv.split("/", 3);
78378         const t2 = parts[0];
78379         const k2 = parts[1];
78380         const v2 = parts[2];
78381         let vmap = _nsi.kvt.get(k2);
78382         if (!vmap) {
78383           vmap = /* @__PURE__ */ new Map();
78384           _nsi.kvt.set(k2, vmap);
78385         }
78386         vmap.set(v2, t2);
78387         const tree = _nsi.trees[t2];
78388         const mainTag = tree.mainTag;
78389         const items = category.items || [];
78390         items.forEach((item) => {
78391           item.tkv = tkv;
78392           item.mainTag = mainTag;
78393           _nsi.ids.set(item.id, item);
78394           const wd = item.tags[mainTag];
78395           const wp = item.tags[mainTag.replace("wikidata", "wikipedia")];
78396           if (wd)
78397             _nsi.qids.set(wd, wd);
78398           if (wp && wd)
78399             _nsi.qids.set(wp, wd);
78400         });
78401       });
78402     });
78403   }
78404   function gatherKVs(tags) {
78405     let primary = /* @__PURE__ */ new Set();
78406     let alternate = /* @__PURE__ */ new Set();
78407     Object.keys(tags).forEach((osmkey) => {
78408       const osmvalue = tags[osmkey];
78409       if (!osmvalue)
78410         return;
78411       if (osmkey === "route_master")
78412         osmkey = "route";
78413       const vmap = _nsi.kvt.get(osmkey);
78414       if (!vmap)
78415         return;
78416       if (vmap.get(osmvalue)) {
78417         primary.add("".concat(osmkey, "/").concat(osmvalue));
78418       } else if (osmvalue === "yes") {
78419         alternate.add("".concat(osmkey, "/").concat(osmvalue));
78420       }
78421     });
78422     const preset = _mainPresetIndex.matchTags(tags, "area");
78423     if (buildingPreset[preset.id]) {
78424       alternate.add("building/yes");
78425     }
78426     return { primary, alternate };
78427   }
78428   function identifyTree(tags) {
78429     let unknown;
78430     let t2;
78431     Object.keys(tags).forEach((osmkey) => {
78432       if (t2)
78433         return;
78434       const osmvalue = tags[osmkey];
78435       if (!osmvalue)
78436         return;
78437       if (osmkey === "route_master")
78438         osmkey = "route";
78439       const vmap = _nsi.kvt.get(osmkey);
78440       if (!vmap)
78441         return;
78442       if (osmvalue === "yes") {
78443         unknown = "unknown";
78444       } else {
78445         t2 = vmap.get(osmvalue);
78446       }
78447     });
78448     return t2 || unknown || null;
78449   }
78450   function gatherNames(tags) {
78451     const empty2 = { primary: /* @__PURE__ */ new Set(), alternate: /* @__PURE__ */ new Set() };
78452     let primary = /* @__PURE__ */ new Set();
78453     let alternate = /* @__PURE__ */ new Set();
78454     let foundSemi = false;
78455     let testNameFragments = false;
78456     let patterns2;
78457     let t2 = identifyTree(tags);
78458     if (!t2)
78459       return empty2;
78460     if (t2 === "transit") {
78461       patterns2 = {
78462         primary: /^network$/i,
78463         alternate: /^(operator|operator:\w+|network:\w+|\w+_name|\w+_name:\w+)$/i
78464       };
78465     } else if (t2 === "flags") {
78466       patterns2 = {
78467         primary: /^(flag:name|flag:name:\w+)$/i,
78468         alternate: /^(flag|flag:\w+|subject|subject:\w+)$/i
78469         // note: no `country`, we special-case it below
78470       };
78471     } else if (t2 === "brands") {
78472       testNameFragments = true;
78473       patterns2 = {
78474         primary: /^(name|name:\w+)$/i,
78475         alternate: /^(brand|brand:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78476       };
78477     } else if (t2 === "operators") {
78478       testNameFragments = true;
78479       patterns2 = {
78480         primary: /^(name|name:\w+|operator|operator:\w+)$/i,
78481         alternate: /^(brand|brand:\w+|\w+_name|\w+_name:\w+)/i
78482       };
78483     } else {
78484       testNameFragments = true;
78485       patterns2 = {
78486         primary: /^(name|name:\w+)$/i,
78487         alternate: /^(brand|brand:\w+|network|network:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78488       };
78489     }
78490     if (tags.name && testNameFragments) {
78491       const nameParts = tags.name.split(/[\s\-\/,.]/);
78492       for (let split = nameParts.length; split > 0; split--) {
78493         const name = nameParts.slice(0, split).join(" ");
78494         primary.add(name);
78495       }
78496     }
78497     Object.keys(tags).forEach((osmkey) => {
78498       const osmvalue = tags[osmkey];
78499       if (!osmvalue)
78500         return;
78501       if (isNamelike(osmkey, "primary")) {
78502         if (/;/.test(osmvalue)) {
78503           foundSemi = true;
78504         } else {
78505           primary.add(osmvalue);
78506           alternate.delete(osmvalue);
78507         }
78508       } else if (!primary.has(osmvalue) && isNamelike(osmkey, "alternate")) {
78509         if (/;/.test(osmvalue)) {
78510           foundSemi = true;
78511         } else {
78512           alternate.add(osmvalue);
78513         }
78514       }
78515     });
78516     if (tags.man_made === "flagpole" && !primary.size && !alternate.size && !!tags.country) {
78517       const osmvalue = tags.country;
78518       if (/;/.test(osmvalue)) {
78519         foundSemi = true;
78520       } else {
78521         alternate.add(osmvalue);
78522       }
78523     }
78524     if (foundSemi) {
78525       return empty2;
78526     } else {
78527       return { primary, alternate };
78528     }
78529     function isNamelike(osmkey, which) {
78530       if (osmkey === "old_name")
78531         return false;
78532       return patterns2[which].test(osmkey) && !notNames.test(osmkey);
78533     }
78534   }
78535   function gatherTuples(tryKVs, tryNames) {
78536     let tuples = [];
78537     ["primary", "alternate"].forEach((whichName) => {
78538       const arr = Array.from(tryNames[whichName]).sort((a2, b2) => b2.length - a2.length);
78539       arr.forEach((n3) => {
78540         ["primary", "alternate"].forEach((whichKV) => {
78541           tryKVs[whichKV].forEach((kv) => {
78542             const parts = kv.split("/", 2);
78543             const k2 = parts[0];
78544             const v2 = parts[1];
78545             tuples.push({ k: k2, v: v2, n: n3 });
78546           });
78547         });
78548       });
78549     });
78550     return tuples;
78551   }
78552   function _upgradeTags(tags, loc) {
78553     let newTags = Object.assign({}, tags);
78554     let changed = false;
78555     Object.keys(newTags).forEach((osmkey) => {
78556       const matchTag = osmkey.match(/^(\w+:)?wikidata$/);
78557       if (matchTag) {
78558         const prefix = matchTag[1] || "";
78559         const wd = newTags[osmkey];
78560         const replace = _nsi.replacements[wd];
78561         if (replace && replace.wikidata !== void 0) {
78562           changed = true;
78563           if (replace.wikidata) {
78564             newTags[osmkey] = replace.wikidata;
78565           } else {
78566             delete newTags[osmkey];
78567           }
78568         }
78569         if (replace && replace.wikipedia !== void 0) {
78570           changed = true;
78571           const wpkey = "".concat(prefix, "wikipedia");
78572           if (replace.wikipedia) {
78573             newTags[wpkey] = replace.wikipedia;
78574           } else {
78575             delete newTags[wpkey];
78576           }
78577         }
78578       }
78579     });
78580     const isRouteMaster = tags.type === "route_master";
78581     const tryKVs = gatherKVs(tags);
78582     if (!tryKVs.primary.size && !tryKVs.alternate.size) {
78583       return changed ? { newTags, matched: null } : null;
78584     }
78585     const tryNames = gatherNames(tags);
78586     const foundQID = _nsi.qids.get(tags.wikidata) || _nsi.qids.get(tags.wikipedia);
78587     if (foundQID)
78588       tryNames.primary.add(foundQID);
78589     if (!tryNames.primary.size && !tryNames.alternate.size) {
78590       return changed ? { newTags, matched: null } : null;
78591     }
78592     const tuples = gatherTuples(tryKVs, tryNames);
78593     for (let i3 = 0; i3 < tuples.length; i3++) {
78594       const tuple = tuples[i3];
78595       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n, loc);
78596       if (!hits || !hits.length)
78597         continue;
78598       if (hits[0].match !== "primary" && hits[0].match !== "alternate")
78599         break;
78600       let itemID, item;
78601       for (let j2 = 0; j2 < hits.length; j2++) {
78602         const hit = hits[j2];
78603         itemID = hit.itemID;
78604         if (_nsi.dissolved[itemID])
78605           continue;
78606         item = _nsi.ids.get(itemID);
78607         if (!item)
78608           continue;
78609         const mainTag = item.mainTag;
78610         const itemQID = item.tags[mainTag];
78611         const notQID = newTags["not:".concat(mainTag)];
78612         if (
78613           // Exceptions, skip this hit
78614           !itemQID || itemQID === notQID || // No `*:wikidata` or matched a `not:*:wikidata`
78615           newTags.office && !item.tags.office
78616         ) {
78617           item = null;
78618           continue;
78619         } else {
78620           break;
78621         }
78622       }
78623       if (!item)
78624         continue;
78625       item = JSON.parse(JSON.stringify(item));
78626       const tkv = item.tkv;
78627       const parts = tkv.split("/", 3);
78628       const k2 = parts[1];
78629       const v2 = parts[2];
78630       const category = _nsi.data[tkv];
78631       const properties = category.properties || {};
78632       let preserveTags = item.preserveTags || properties.preserveTags || [];
78633       ["building", "emergency", "internet_access", "takeaway"].forEach((osmkey) => {
78634         if (k2 !== osmkey)
78635           preserveTags.push("^".concat(osmkey, "$"));
78636       });
78637       const regexes = preserveTags.map((s2) => new RegExp(s2, "i"));
78638       let keepTags = {};
78639       Object.keys(newTags).forEach((osmkey) => {
78640         if (regexes.some((regex) => regex.test(osmkey))) {
78641           keepTags[osmkey] = newTags[osmkey];
78642         }
78643       });
78644       _nsi.kvt.forEach((vmap, k3) => {
78645         if (newTags[k3] === "yes")
78646           delete newTags[k3];
78647       });
78648       if (foundQID) {
78649         delete newTags.wikipedia;
78650         delete newTags.wikidata;
78651       }
78652       Object.assign(newTags, item.tags, keepTags);
78653       if (isRouteMaster) {
78654         newTags.route_master = newTags.route;
78655         delete newTags.route;
78656       }
78657       const origName = tags.name;
78658       const newName = newTags.name;
78659       if (newName && origName && newName !== origName && !newTags.branch) {
78660         const newNames = gatherNames(newTags);
78661         const newSet = /* @__PURE__ */ new Set([...newNames.primary, ...newNames.alternate]);
78662         const isMoved = newSet.has(origName);
78663         if (!isMoved) {
78664           const nameParts = origName.split(/[\s\-\/,.]/);
78665           for (let split = nameParts.length; split > 0; split--) {
78666             const name = nameParts.slice(0, split).join(" ");
78667             const branch = nameParts.slice(split).join(" ");
78668             const nameHits = _nsi.matcher.match(k2, v2, name, loc);
78669             if (!nameHits || !nameHits.length)
78670               continue;
78671             if (nameHits.some((hit) => hit.itemID === itemID)) {
78672               if (branch) {
78673                 if (notBranches.test(branch)) {
78674                   newTags.name = origName;
78675                 } else {
78676                   const branchHits = _nsi.matcher.match(k2, v2, branch, loc);
78677                   if (branchHits && branchHits.length) {
78678                     if (branchHits[0].match === "primary" || branchHits[0].match === "alternate") {
78679                       return null;
78680                     }
78681                   } else {
78682                     newTags.branch = branch;
78683                   }
78684                 }
78685               }
78686               break;
78687             }
78688           }
78689         }
78690       }
78691       return { newTags, matched: item };
78692     }
78693     return changed ? { newTags, matched: null } : null;
78694   }
78695   function _isGenericName(tags) {
78696     const n3 = tags.name;
78697     if (!n3)
78698       return false;
78699     const tryNames = { primary: /* @__PURE__ */ new Set([n3]), alternate: /* @__PURE__ */ new Set() };
78700     const tryKVs = gatherKVs(tags);
78701     if (!tryKVs.primary.size && !tryKVs.alternate.size)
78702       return false;
78703     const tuples = gatherTuples(tryKVs, tryNames);
78704     for (let i3 = 0; i3 < tuples.length; i3++) {
78705       const tuple = tuples[i3];
78706       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n);
78707       if (hits && hits.length && hits[0].match === "excludeGeneric")
78708         return true;
78709     }
78710     return false;
78711   }
78712   var nsi_default = {
78713     // `init()`
78714     // On init, start preparing the name-suggestion-index
78715     //
78716     init: () => {
78717       setNsiSources();
78718       _mainPresetIndex.ensureLoaded().then(() => loadNsiPresets()).then(() => loadNsiData()).then(() => _nsiStatus = "ok").catch(() => _nsiStatus = "failed");
78719     },
78720     // `reset()`
78721     // Reset is called when user saves data to OSM (does nothing here)
78722     //
78723     reset: () => {
78724     },
78725     // `status()`
78726     // To let other code know how it's going...
78727     //
78728     // Returns
78729     //   `String`: 'loading', 'ok', 'failed'
78730     //
78731     status: () => _nsiStatus,
78732     // `isGenericName()`
78733     // Is the `name` tag generic?
78734     //
78735     // Arguments
78736     //   `tags`: `Object` containing the feature's OSM tags
78737     // Returns
78738     //   `true` if it is generic, `false` if not
78739     //
78740     isGenericName: (tags) => _isGenericName(tags),
78741     // `upgradeTags()`
78742     // Suggest tag upgrades.
78743     // This function will not modify the input tags, it makes a copy.
78744     //
78745     // Arguments
78746     //   `tags`: `Object` containing the feature's OSM tags
78747     //   `loc`: Location where this feature exists, as a [lon, lat]
78748     // Returns
78749     //   `Object` containing the result, or `null` if no changes needed:
78750     //   {
78751     //     'newTags': `Object` - The tags the the feature should have
78752     //     'matched': `Object` - The matched item
78753     //   }
78754     //
78755     upgradeTags: (tags, loc) => _upgradeTags(tags, loc),
78756     // `cache()`
78757     // Direct access to the NSI cache, useful for testing or breaking things
78758     //
78759     // Returns
78760     //   `Object`: the internal NSI cache
78761     //
78762     cache: () => _nsi
78763   };
78764
78765   // modules/services/kartaview.js
78766   var import_rbush8 = __toESM(require_rbush_min());
78767   var apibase2 = "https://kartaview.org";
78768   var maxResults = 1e3;
78769   var tileZoom = 14;
78770   var tiler4 = utilTiler().zoomExtent([tileZoom, tileZoom]).skipNullIsland(true);
78771   var dispatch7 = dispatch_default("loadedImages");
78772   var imgZoom2 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
78773   var _oscCache;
78774   var _oscSelectedImage;
78775   var _loadViewerPromise2;
78776   function abortRequest4(controller) {
78777     controller.abort();
78778   }
78779   function maxPageAtZoom(z2) {
78780     if (z2 < 15)
78781       return 2;
78782     if (z2 === 15)
78783       return 5;
78784     if (z2 === 16)
78785       return 10;
78786     if (z2 === 17)
78787       return 20;
78788     if (z2 === 18)
78789       return 40;
78790     if (z2 > 18)
78791       return 80;
78792   }
78793   function loadTiles2(which, url, projection2) {
78794     var currZoom = Math.floor(geoScaleToZoom(projection2.scale()));
78795     var tiles = tiler4.getTiles(projection2);
78796     var cache = _oscCache[which];
78797     Object.keys(cache.inflight).forEach(function(k2) {
78798       var wanted = tiles.find(function(tile) {
78799         return k2.indexOf(tile.id + ",") === 0;
78800       });
78801       if (!wanted) {
78802         abortRequest4(cache.inflight[k2]);
78803         delete cache.inflight[k2];
78804       }
78805     });
78806     tiles.forEach(function(tile) {
78807       loadNextTilePage(which, currZoom, url, tile);
78808     });
78809   }
78810   function loadNextTilePage(which, currZoom, url, tile) {
78811     var cache = _oscCache[which];
78812     var bbox2 = tile.extent.bbox();
78813     var maxPages = maxPageAtZoom(currZoom);
78814     var nextPage = cache.nextPage[tile.id] || 1;
78815     var params = utilQsString({
78816       ipp: maxResults,
78817       page: nextPage,
78818       // client_id: clientId,
78819       bbTopLeft: [bbox2.maxY, bbox2.minX].join(","),
78820       bbBottomRight: [bbox2.minY, bbox2.maxX].join(",")
78821     }, true);
78822     if (nextPage > maxPages)
78823       return;
78824     var id2 = tile.id + "," + String(nextPage);
78825     if (cache.loaded[id2] || cache.inflight[id2])
78826       return;
78827     var controller = new AbortController();
78828     cache.inflight[id2] = controller;
78829     var options2 = {
78830       method: "POST",
78831       signal: controller.signal,
78832       body: params,
78833       headers: { "Content-Type": "application/x-www-form-urlencoded" }
78834     };
78835     json_default(url, options2).then(function(data) {
78836       cache.loaded[id2] = true;
78837       delete cache.inflight[id2];
78838       if (!data || !data.currentPageItems || !data.currentPageItems.length) {
78839         throw new Error("No Data");
78840       }
78841       var features = data.currentPageItems.map(function(item) {
78842         var loc = [+item.lng, +item.lat];
78843         var d2;
78844         if (which === "images") {
78845           d2 = {
78846             loc,
78847             key: item.id,
78848             ca: +item.heading,
78849             captured_at: item.shot_date || item.date_added,
78850             captured_by: item.username,
78851             imagePath: item.lth_name,
78852             sequence_id: item.sequence_id,
78853             sequence_index: +item.sequence_index
78854           };
78855           var seq = _oscCache.sequences[d2.sequence_id];
78856           if (!seq) {
78857             seq = { rotation: 0, images: [] };
78858             _oscCache.sequences[d2.sequence_id] = seq;
78859           }
78860           seq.images[d2.sequence_index] = d2;
78861           _oscCache.images.forImageKey[d2.key] = d2;
78862         }
78863         return {
78864           minX: loc[0],
78865           minY: loc[1],
78866           maxX: loc[0],
78867           maxY: loc[1],
78868           data: d2
78869         };
78870       });
78871       cache.rtree.load(features);
78872       if (data.currentPageItems.length === maxResults) {
78873         cache.nextPage[tile.id] = nextPage + 1;
78874         loadNextTilePage(which, currZoom, url, tile);
78875       } else {
78876         cache.nextPage[tile.id] = Infinity;
78877       }
78878       if (which === "images") {
78879         dispatch7.call("loadedImages");
78880       }
78881     }).catch(function() {
78882       cache.loaded[id2] = true;
78883       delete cache.inflight[id2];
78884     });
78885   }
78886   function partitionViewport2(projection2) {
78887     var z2 = geoScaleToZoom(projection2.scale());
78888     var z22 = Math.ceil(z2 * 2) / 2 + 2.5;
78889     var tiler9 = utilTiler().zoomExtent([z22, z22]);
78890     return tiler9.getTiles(projection2).map(function(tile) {
78891       return tile.extent;
78892     });
78893   }
78894   function searchLimited2(limit, projection2, rtree) {
78895     limit = limit || 5;
78896     return partitionViewport2(projection2).reduce(function(result, extent) {
78897       var found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
78898         return d2.data;
78899       });
78900       return found.length ? result.concat(found) : result;
78901     }, []);
78902   }
78903   var kartaview_default = {
78904     init: function() {
78905       if (!_oscCache) {
78906         this.reset();
78907       }
78908       this.event = utilRebind(this, dispatch7, "on");
78909     },
78910     reset: function() {
78911       if (_oscCache) {
78912         Object.values(_oscCache.images.inflight).forEach(abortRequest4);
78913       }
78914       _oscCache = {
78915         images: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush8.default(), forImageKey: {} },
78916         sequences: {}
78917       };
78918       _oscSelectedImage = null;
78919     },
78920     images: function(projection2) {
78921       var limit = 5;
78922       return searchLimited2(limit, projection2, _oscCache.images.rtree);
78923     },
78924     sequences: function(projection2) {
78925       var viewport = projection2.clipExtent();
78926       var min3 = [viewport[0][0], viewport[1][1]];
78927       var max3 = [viewport[1][0], viewport[0][1]];
78928       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
78929       var sequenceKeys = {};
78930       _oscCache.images.rtree.search(bbox2).forEach(function(d2) {
78931         sequenceKeys[d2.data.sequence_id] = true;
78932       });
78933       var lineStrings = [];
78934       Object.keys(sequenceKeys).forEach(function(sequenceKey) {
78935         var seq = _oscCache.sequences[sequenceKey];
78936         var images = seq && seq.images;
78937         if (images) {
78938           lineStrings.push({
78939             type: "LineString",
78940             coordinates: images.map(function(d2) {
78941               return d2.loc;
78942             }).filter(Boolean),
78943             properties: {
78944               captured_at: images[0] ? images[0].captured_at : null,
78945               captured_by: images[0] ? images[0].captured_by : null,
78946               key: sequenceKey
78947             }
78948           });
78949         }
78950       });
78951       return lineStrings;
78952     },
78953     cachedImage: function(imageKey) {
78954       return _oscCache.images.forImageKey[imageKey];
78955     },
78956     loadImages: function(projection2) {
78957       var url = apibase2 + "/1.0/list/nearby-photos/";
78958       loadTiles2("images", url, projection2);
78959     },
78960     ensureViewerLoaded: function(context) {
78961       if (_loadViewerPromise2)
78962         return _loadViewerPromise2;
78963       var wrap2 = context.container().select(".photoviewer").selectAll(".kartaview-wrapper").data([0]);
78964       var that = this;
78965       var wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper kartaview-wrapper").classed("hide", true).call(imgZoom2.on("zoom", zoomPan2)).on("dblclick.zoom", null);
78966       wrapEnter.append("div").attr("class", "photo-attribution fillD");
78967       var controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
78968       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
78969       controlsEnter.append("button").on("click.rotate-ccw", rotate(-90)).text("\u293F");
78970       controlsEnter.append("button").on("click.rotate-cw", rotate(90)).text("\u293E");
78971       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
78972       wrapEnter.append("div").attr("class", "kartaview-image-wrap");
78973       context.ui().photoviewer.on("resize.kartaview", function(dimensions) {
78974         imgZoom2.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]);
78975       });
78976       function zoomPan2(d3_event) {
78977         var t2 = d3_event.transform;
78978         context.container().select(".photoviewer .kartaview-image-wrap").call(utilSetTransform, t2.x, t2.y, t2.k);
78979       }
78980       function rotate(deg) {
78981         return function() {
78982           if (!_oscSelectedImage)
78983             return;
78984           var sequenceKey = _oscSelectedImage.sequence_id;
78985           var sequence = _oscCache.sequences[sequenceKey];
78986           if (!sequence)
78987             return;
78988           var r2 = sequence.rotation || 0;
78989           r2 += deg;
78990           if (r2 > 180)
78991             r2 -= 360;
78992           if (r2 < -180)
78993             r2 += 360;
78994           sequence.rotation = r2;
78995           var wrap3 = context.container().select(".photoviewer .kartaview-wrapper");
78996           wrap3.transition().duration(100).call(imgZoom2.transform, identity2);
78997           wrap3.selectAll(".kartaview-image").transition().duration(100).style("transform", "rotate(" + r2 + "deg)");
78998         };
78999       }
79000       function step(stepBy) {
79001         return function() {
79002           if (!_oscSelectedImage)
79003             return;
79004           var sequenceKey = _oscSelectedImage.sequence_id;
79005           var sequence = _oscCache.sequences[sequenceKey];
79006           if (!sequence)
79007             return;
79008           var nextIndex = _oscSelectedImage.sequence_index + stepBy;
79009           var nextImage = sequence.images[nextIndex];
79010           if (!nextImage)
79011             return;
79012           context.map().centerEase(nextImage.loc);
79013           that.selectImage(context, nextImage.key);
79014         };
79015       }
79016       _loadViewerPromise2 = Promise.resolve();
79017       return _loadViewerPromise2;
79018     },
79019     showViewer: function(context) {
79020       var viewer = context.container().select(".photoviewer").classed("hide", false);
79021       var isHidden = viewer.selectAll(".photo-wrapper.kartaview-wrapper.hide").size();
79022       if (isHidden) {
79023         viewer.selectAll(".photo-wrapper:not(.kartaview-wrapper)").classed("hide", true);
79024         viewer.selectAll(".photo-wrapper.kartaview-wrapper").classed("hide", false);
79025       }
79026       return this;
79027     },
79028     hideViewer: function(context) {
79029       _oscSelectedImage = null;
79030       this.updateUrlImage(null);
79031       var viewer = context.container().select(".photoviewer");
79032       if (!viewer.empty())
79033         viewer.datum(null);
79034       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79035       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
79036       return this.setStyles(context, null, true);
79037     },
79038     selectImage: function(context, imageKey) {
79039       var d2 = this.cachedImage(imageKey);
79040       _oscSelectedImage = d2;
79041       this.updateUrlImage(imageKey);
79042       var viewer = context.container().select(".photoviewer");
79043       if (!viewer.empty())
79044         viewer.datum(d2);
79045       this.setStyles(context, null, true);
79046       context.container().selectAll(".icon-sign").classed("currentView", false);
79047       if (!d2)
79048         return this;
79049       var wrap2 = context.container().select(".photoviewer .kartaview-wrapper");
79050       var imageWrap = wrap2.selectAll(".kartaview-image-wrap");
79051       var attribution = wrap2.selectAll(".photo-attribution").text("");
79052       wrap2.transition().duration(100).call(imgZoom2.transform, identity2);
79053       imageWrap.selectAll(".kartaview-image").remove();
79054       if (d2) {
79055         var sequence = _oscCache.sequences[d2.sequence_id];
79056         var r2 = sequence && sequence.rotation || 0;
79057         imageWrap.append("img").attr("class", "kartaview-image").attr("src", apibase2 + "/" + d2.imagePath).style("transform", "rotate(" + r2 + "deg)");
79058         if (d2.captured_by) {
79059           attribution.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://kartaview.org/user/" + encodeURIComponent(d2.captured_by)).text("@" + d2.captured_by);
79060           attribution.append("span").text("|");
79061         }
79062         if (d2.captured_at) {
79063           attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.captured_at));
79064           attribution.append("span").text("|");
79065         }
79066         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");
79067       }
79068       return this;
79069       function localeDateString2(s2) {
79070         if (!s2)
79071           return null;
79072         var options2 = { day: "numeric", month: "short", year: "numeric" };
79073         var d4 = new Date(s2);
79074         if (isNaN(d4.getTime()))
79075           return null;
79076         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
79077       }
79078     },
79079     getSelectedImage: function() {
79080       return _oscSelectedImage;
79081     },
79082     getSequenceKeyForImage: function(d2) {
79083       return d2 && d2.sequence_id;
79084     },
79085     // Updates the currently highlighted sequence and selected bubble.
79086     // Reset is only necessary when interacting with the viewport because
79087     // this implicitly changes the currently selected bubble/sequence
79088     setStyles: function(context, hovered, reset) {
79089       if (reset) {
79090         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79091         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79092       }
79093       var hoveredImageKey = hovered && hovered.key;
79094       var hoveredSequenceKey = this.getSequenceKeyForImage(hovered);
79095       var hoveredSequence = hoveredSequenceKey && _oscCache.sequences[hoveredSequenceKey];
79096       var hoveredImageKeys = hoveredSequence && hoveredSequence.images.map(function(d2) {
79097         return d2.key;
79098       }) || [];
79099       var viewer = context.container().select(".photoviewer");
79100       var selected = viewer.empty() ? void 0 : viewer.datum();
79101       var selectedImageKey = selected && selected.key;
79102       var selectedSequenceKey = this.getSequenceKeyForImage(selected);
79103       var selectedSequence = selectedSequenceKey && _oscCache.sequences[selectedSequenceKey];
79104       var selectedImageKeys = selectedSequence && selectedSequence.images.map(function(d2) {
79105         return d2.key;
79106       }) || [];
79107       var highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79108       context.container().selectAll(".layer-kartaview .viewfield-group").classed("highlighted", function(d2) {
79109         return highlightedImageKeys.indexOf(d2.key) !== -1;
79110       }).classed("hovered", function(d2) {
79111         return d2.key === hoveredImageKey;
79112       }).classed("currentView", function(d2) {
79113         return d2.key === selectedImageKey;
79114       });
79115       context.container().selectAll(".layer-kartaview .sequence").classed("highlighted", function(d2) {
79116         return d2.properties.key === hoveredSequenceKey;
79117       }).classed("currentView", function(d2) {
79118         return d2.properties.key === selectedSequenceKey;
79119       });
79120       context.container().selectAll(".layer-kartaview .viewfield-group .viewfield").attr("d", viewfieldPath);
79121       function viewfieldPath() {
79122         var d2 = this.parentNode.__data__;
79123         if (d2.pano && d2.key !== selectedImageKey) {
79124           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79125         } else {
79126           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79127         }
79128       }
79129       return this;
79130     },
79131     updateUrlImage: function(imageKey) {
79132       if (!window.mocha) {
79133         var hash = utilStringQs(window.location.hash);
79134         if (imageKey) {
79135           hash.photo = "kartaview/" + imageKey;
79136         } else {
79137           delete hash.photo;
79138         }
79139         window.location.replace("#" + utilQsString(hash, true));
79140       }
79141     },
79142     cache: function() {
79143       return _oscCache;
79144     }
79145   };
79146
79147   // modules/services/vegbilder.js
79148   var import_rbush9 = __toESM(require_rbush_min());
79149
79150   // modules/services/pannellum_photo.js
79151   var pannellumViewerCSS = "pannellum/pannellum.css";
79152   var pannellumViewerJS = "pannellum/pannellum.js";
79153   var dispatch8 = dispatch_default("viewerChanged");
79154   var _currScenes = [];
79155   var _pannellumViewer;
79156   var pannellum_photo_default = {
79157     init: async function(context, selection2) {
79158       selection2.append("div").attr("class", "photo-frame pannellum-frame").attr("id", "ideditor-pannellum-viewer").classed("hide", true);
79159       if (!window.pannellum) {
79160         await this.loadPannellum(context);
79161       }
79162       const options2 = {
79163         "default": { firstScene: "" },
79164         scenes: {}
79165       };
79166       _pannellumViewer = window.pannellum.viewer("ideditor-pannellum-viewer", options2);
79167       _pannellumViewer.on("mousedown", () => {
79168         select_default2(window).on("pointermove.pannellum mousemove.pannellum", () => {
79169           dispatch8.call("viewerChanged");
79170         });
79171       }).on("mouseup", () => {
79172         select_default2(window).on("pointermove.pannellum mousemove.pannellum", null);
79173       }).on("animatefinished", () => {
79174         dispatch8.call("viewerChanged");
79175       });
79176       context.ui().photoviewer.on("resize.pannellum", () => {
79177         _pannellumViewer.resize();
79178       });
79179       this.event = utilRebind(this, dispatch8, "on");
79180       return this;
79181     },
79182     loadPannellum: function(context) {
79183       const head = select_default2("head");
79184       return Promise.all([
79185         new Promise((resolve, reject) => {
79186           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);
79187         }),
79188         new Promise((resolve, reject) => {
79189           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);
79190         })
79191       ]);
79192     },
79193     showPhotoFrame: function(context) {
79194       const isHidden = context.selectAll(".photo-frame.pannellum-frame.hide").size();
79195       if (isHidden) {
79196         context.selectAll(".photo-frame:not(.pannellum-frame)").classed("hide", true);
79197         context.selectAll(".photo-frame.pannellum-frame").classed("hide", false);
79198       }
79199       return this;
79200     },
79201     hidePhotoFrame: function(viewerContext) {
79202       viewerContext.select("photo-frame.pannellum-frame").classed("hide", false);
79203       return this;
79204     },
79205     selectPhoto: function(data, keepOrientation) {
79206       const { key } = data;
79207       if (!(key in _currScenes)) {
79208         let newSceneOptions = {
79209           showFullscreenCtrl: false,
79210           autoLoad: false,
79211           compass: true,
79212           yaw: 0,
79213           type: "equirectangular",
79214           preview: data.preview_path,
79215           panorama: data.image_path,
79216           northOffset: data.ca
79217         };
79218         _currScenes.push(key);
79219         _pannellumViewer.addScene(key, newSceneOptions);
79220       }
79221       let yaw = 0;
79222       let pitch = 0;
79223       if (keepOrientation) {
79224         yaw = this.getYaw();
79225         pitch = _pannellumViewer.getPitch();
79226       }
79227       _pannellumViewer.loadScene(key, pitch, yaw);
79228       dispatch8.call("viewerChanged");
79229       if (_currScenes.length > 3) {
79230         const old_key = _currScenes.shift();
79231         _pannellumViewer.removeScene(old_key);
79232       }
79233       return this;
79234     },
79235     getYaw: function() {
79236       return _pannellumViewer.getYaw();
79237     }
79238   };
79239
79240   // modules/services/vegbilder.js
79241   var owsEndpoint = "https://www.vegvesen.no/kart/ogc/vegbilder_1_0/ows?";
79242   var tileZoom2 = 14;
79243   var tiler5 = utilTiler().zoomExtent([tileZoom2, tileZoom2]).skipNullIsland(true);
79244   var dispatch9 = dispatch_default("loadedImages", "viewerChanged");
79245   var directionEnum = Object.freeze({
79246     forward: Symbol(0),
79247     backward: Symbol(1)
79248   });
79249   var _planeFrame;
79250   var _pannellumFrame;
79251   var _currentFrame;
79252   var _loadViewerPromise3;
79253   var _vegbilderCache;
79254   async function fetchAvailableLayers() {
79255     var _a2, _b, _c;
79256     const params = {
79257       service: "WFS",
79258       request: "GetCapabilities",
79259       version: "2.0.0"
79260     };
79261     const urlForRequest = owsEndpoint + utilQsString(params);
79262     const response = await xml_default(urlForRequest);
79263     const xPathSelector = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType/wfs:Name";
79264     const regexMatcher = /^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\d{4})$/;
79265     const NSResolver = response.createNSResolver(response);
79266     const l2 = response.evaluate(
79267       xPathSelector,
79268       response,
79269       NSResolver,
79270       XPathResult.ANY_TYPE
79271     );
79272     let node;
79273     const availableLayers = [];
79274     while ((node = l2.iterateNext()) !== null) {
79275       const match = (_a2 = node.textContent) == null ? void 0 : _a2.match(regexMatcher);
79276       if (match) {
79277         availableLayers.push({
79278           name: match[0],
79279           is_sphere: !!((_b = match.groups) == null ? void 0 : _b.image_type),
79280           year: parseInt((_c = match.groups) == null ? void 0 : _c.year, 10)
79281         });
79282       }
79283     }
79284     return availableLayers;
79285   }
79286   function filterAvailableLayers(photoContex) {
79287     const fromDateString = photoContex.fromDate();
79288     const toDateString = photoContex.toDate();
79289     const fromYear = fromDateString ? new Date(fromDateString).getFullYear() : 2016;
79290     const toYear = toDateString ? new Date(toDateString).getFullYear() : null;
79291     const showsFlat = photoContex.showsFlat();
79292     const showsPano = photoContex.showsPanoramic();
79293     return Array.from(_vegbilderCache.wfslayers.values()).filter(({ layerInfo }) => layerInfo.year >= fromYear && (!toYear || layerInfo.year <= toYear) && (!layerInfo.is_sphere && showsFlat || layerInfo.is_sphere && showsPano));
79294   }
79295   function loadWFSLayers(projection2, margin, wfslayers) {
79296     const tiles = tiler5.margin(margin).getTiles(projection2);
79297     for (const cache of wfslayers) {
79298       loadWFSLayer(projection2, cache, tiles);
79299     }
79300   }
79301   function loadWFSLayer(projection2, cache, tiles) {
79302     for (const [key, controller] of cache.inflight.entries()) {
79303       const wanted = tiles.some((tile) => key === tile.id);
79304       if (!wanted) {
79305         controller.abort();
79306         cache.inflight.delete(key);
79307       }
79308     }
79309     Promise.all(tiles.map(
79310       (tile) => loadTile2(cache, cache.layerInfo.name, tile)
79311     )).then(() => orderSequences(projection2, cache));
79312   }
79313   async function loadTile2(cache, typename, tile) {
79314     const bbox2 = tile.extent.bbox();
79315     const tileid = tile.id;
79316     if (cache.loaded.get(tileid) === true || cache.inflight.has(tileid))
79317       return;
79318     const params = {
79319       service: "WFS",
79320       request: "GetFeature",
79321       version: "2.0.0",
79322       typenames: typename,
79323       bbox: [bbox2.minY, bbox2.minX, bbox2.maxY, bbox2.maxX].join(","),
79324       outputFormat: "json"
79325     };
79326     const controller = new AbortController();
79327     cache.inflight.set(tileid, controller);
79328     const options2 = {
79329       method: "GET",
79330       signal: controller.signal
79331     };
79332     const urlForRequest = owsEndpoint + utilQsString(params);
79333     let featureCollection;
79334     try {
79335       featureCollection = await json_default(urlForRequest, options2);
79336     } catch {
79337       cache.loaded.set(tileid, false);
79338       return;
79339     } finally {
79340       cache.inflight.delete(tileid);
79341     }
79342     cache.loaded.set(tileid, true);
79343     if (featureCollection.features.length === 0) {
79344       return;
79345     }
79346     const features = featureCollection.features.map((feature3) => {
79347       const loc = feature3.geometry.coordinates;
79348       const key = feature3.id;
79349       const properties = feature3.properties;
79350       const {
79351         RETNING: ca,
79352         TIDSPUNKT: captured_at,
79353         URL: image_path,
79354         URLPREVIEW: preview_path,
79355         BILDETYPE: image_type,
79356         METER: metering,
79357         FELTKODE: lane_code
79358       } = properties;
79359       const lane_number = parseInt(lane_code.match(/^[0-9]+/)[0], 10);
79360       const direction = lane_number % 2 === 0 ? directionEnum.backward : directionEnum.forward;
79361       const data = {
79362         loc,
79363         key,
79364         ca,
79365         image_path,
79366         preview_path,
79367         road_reference: roadReference(properties),
79368         metering,
79369         lane_code,
79370         direction,
79371         captured_at: new Date(captured_at),
79372         is_sphere: image_type === "360"
79373       };
79374       cache.points.set(key, data);
79375       return {
79376         minX: loc[0],
79377         minY: loc[1],
79378         maxX: loc[0],
79379         maxY: loc[1],
79380         data
79381       };
79382     });
79383     _vegbilderCache.rtree.load(features);
79384     dispatch9.call("loadedImages");
79385   }
79386   function orderSequences(projection2, cache) {
79387     const { points } = cache;
79388     const grouped = Array.from(points.values()).reduce((grouped2, image) => {
79389       const key = image.road_reference;
79390       if (grouped2.has(key)) {
79391         grouped2.get(key).push(image);
79392       } else {
79393         grouped2.set(key, [image]);
79394       }
79395       return grouped2;
79396     }, /* @__PURE__ */ new Map());
79397     const imageSequences = Array.from(grouped.values()).reduce((imageSequences2, imageGroup) => {
79398       imageGroup.sort((a2, b2) => {
79399         if (a2.captured_at.valueOf() > b2.captured_at.valueOf()) {
79400           return 1;
79401         } else if (a2.captured_at.valueOf() < b2.captured_at.valueOf()) {
79402           return -1;
79403         } else {
79404           const { direction } = a2;
79405           if (direction === directionEnum.forward) {
79406             return a2.metering - b2.metering;
79407           } else {
79408             return b2.metering - a2.metering;
79409           }
79410         }
79411       });
79412       let imageSequence = [imageGroup[0]];
79413       let angle2 = null;
79414       for (const [lastImage, image] of pairs(imageGroup)) {
79415         if (lastImage.ca === null) {
79416           const b2 = projection2(lastImage.loc);
79417           const a2 = projection2(image.loc);
79418           if (!geoVecEqual(a2, b2)) {
79419             angle2 = geoVecAngle(a2, b2);
79420             angle2 *= 180 / Math.PI;
79421             angle2 -= 90;
79422             angle2 = angle2 >= 0 ? angle2 : angle2 + 360;
79423           }
79424           lastImage.ca = angle2;
79425         }
79426         if (image.direction === lastImage.direction && image.captured_at.valueOf() - lastImage.captured_at.valueOf() <= 2e4) {
79427           imageSequence.push(image);
79428         } else {
79429           imageSequences2.push(imageSequence);
79430           imageSequence = [image];
79431         }
79432       }
79433       imageSequences2.push(imageSequence);
79434       return imageSequences2;
79435     }, []);
79436     cache.sequences = imageSequences.map((images) => {
79437       const sequence = {
79438         images,
79439         key: images[0].key,
79440         geometry: {
79441           type: "LineString",
79442           coordinates: images.map((image) => image.loc)
79443         }
79444       };
79445       for (const image of images) {
79446         _vegbilderCache.image2sequence_map.set(image.key, sequence);
79447       }
79448       return sequence;
79449     });
79450   }
79451   function roadReference(properties) {
79452     const {
79453       FYLKENUMMER: county_number,
79454       VEGKATEGORI: road_class,
79455       VEGSTATUS: road_status,
79456       VEGNUMMER: road_number,
79457       STREKNING: section,
79458       DELSTREKNING: subsection,
79459       HP: parcel,
79460       KRYSSDEL: junction_part,
79461       SIDEANLEGGSDEL: services_part,
79462       ANKERPUNKT: anker_point,
79463       AAR: year
79464     } = properties;
79465     let reference;
79466     if (year >= 2020) {
79467       reference = "".concat(road_class).concat(road_status).concat(road_number, " S").concat(section, "D").concat(subsection);
79468       if (junction_part) {
79469         reference = "".concat(reference, " M").concat(anker_point, " KD").concat(junction_part);
79470       } else if (services_part) {
79471         reference = "".concat(reference, " M").concat(anker_point, " SD").concat(services_part);
79472       }
79473     } else {
79474       reference = "".concat(county_number).concat(road_class).concat(road_status).concat(road_number, " HP").concat(parcel);
79475     }
79476     return reference;
79477   }
79478   function localeTimestamp(date) {
79479     const options2 = {
79480       day: "2-digit",
79481       month: "2-digit",
79482       year: "numeric",
79483       hour: "numeric",
79484       minute: "numeric",
79485       second: "numeric"
79486     };
79487     return date.toLocaleString(_mainLocalizer.localeCode(), options2);
79488   }
79489   function partitionViewport3(projection2) {
79490     const zoom = geoScaleToZoom(projection2.scale());
79491     const roundZoom = Math.ceil(zoom * 2) / 2 + 2.5;
79492     const tiler9 = utilTiler().zoomExtent([roundZoom, roundZoom]);
79493     return tiler9.getTiles(projection2).map((tile) => tile.extent);
79494   }
79495   function searchLimited3(limit, projection2, rtree) {
79496     limit != null ? limit : limit = 5;
79497     return partitionViewport3(projection2).reduce((result, extent) => {
79498       const found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
79499       return result.concat(found);
79500     }, []);
79501   }
79502   var vegbilder_default = {
79503     init: function() {
79504       this.event = utilRebind(this, dispatch9, "on");
79505     },
79506     reset: async function() {
79507       if (_vegbilderCache) {
79508         for (const layer of _vegbilderCache.wfslayers.values()) {
79509           for (const controller of layer.inflight.values()) {
79510             controller.abort();
79511           }
79512         }
79513       }
79514       _vegbilderCache = {
79515         wfslayers: /* @__PURE__ */ new Map(),
79516         rtree: new import_rbush9.default(),
79517         image2sequence_map: /* @__PURE__ */ new Map()
79518       };
79519       const availableLayers = await fetchAvailableLayers();
79520       const { wfslayers } = _vegbilderCache;
79521       for (const layerInfo of availableLayers) {
79522         const cache = {
79523           layerInfo,
79524           loaded: /* @__PURE__ */ new Map(),
79525           inflight: /* @__PURE__ */ new Map(),
79526           points: /* @__PURE__ */ new Map(),
79527           sequences: []
79528         };
79529         wfslayers.set(layerInfo.name, cache);
79530       }
79531     },
79532     images: function(projection2) {
79533       const limit = 5;
79534       return searchLimited3(limit, projection2, _vegbilderCache.rtree);
79535     },
79536     sequences: function(projection2) {
79537       const viewport = projection2.clipExtent();
79538       const min3 = [viewport[0][0], viewport[1][1]];
79539       const max3 = [viewport[1][0], viewport[0][1]];
79540       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
79541       const seen = /* @__PURE__ */ new Set();
79542       const line_strings = [];
79543       for (const { data } of _vegbilderCache.rtree.search(bbox2)) {
79544         const sequence = _vegbilderCache.image2sequence_map.get(data.key);
79545         if (!sequence)
79546           continue;
79547         const { key, geometry, images } = sequence;
79548         if (seen.has(key))
79549           continue;
79550         seen.add(key);
79551         const line = {
79552           type: "LineString",
79553           coordinates: geometry.coordinates,
79554           key,
79555           images
79556         };
79557         line_strings.push(line);
79558       }
79559       return line_strings;
79560     },
79561     cachedImage: function(key) {
79562       for (const { points } of _vegbilderCache.wfslayers.values()) {
79563         if (points.has(key))
79564           return points.get(key);
79565       }
79566     },
79567     getSequenceForImage: function(image) {
79568       return _vegbilderCache == null ? void 0 : _vegbilderCache.image2sequence_map.get(image == null ? void 0 : image.key);
79569     },
79570     loadImages: async function(context, margin) {
79571       if (!_vegbilderCache) {
79572         await this.reset();
79573       }
79574       margin != null ? margin : margin = 1;
79575       const wfslayers = filterAvailableLayers(context.photos());
79576       loadWFSLayers(context.projection, margin, wfslayers);
79577     },
79578     photoFrame: function() {
79579       return _currentFrame;
79580     },
79581     ensureViewerLoaded: function(context) {
79582       if (_loadViewerPromise3)
79583         return _loadViewerPromise3;
79584       const step = (stepBy) => () => {
79585         const viewer = context.container().select(".photoviewer");
79586         const selected = viewer.empty() ? void 0 : viewer.datum();
79587         if (!selected)
79588           return;
79589         const sequence = this.getSequenceForImage(selected);
79590         const nextIndex = sequence.images.indexOf(selected) + stepBy;
79591         const nextImage = sequence.images[nextIndex];
79592         if (!nextImage)
79593           return;
79594         context.map().centerEase(nextImage.loc);
79595         this.selectImage(context, nextImage.key, true);
79596       };
79597       const wrap2 = context.container().select(".photoviewer").selectAll(".vegbilder-wrapper").data([0]);
79598       const wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper vegbilder-wrapper").classed("hide", true);
79599       wrapEnter.append("div").attr("class", "photo-attribution fillD");
79600       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
79601       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
79602       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
79603       _loadViewerPromise3 = Promise.all([
79604         pannellum_photo_default.init(context, wrapEnter),
79605         plane_photo_default.init(context, wrapEnter)
79606       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
79607         _pannellumFrame = pannellumPhotoFrame;
79608         _pannellumFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79609         _planeFrame = planePhotoFrame;
79610         _planeFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79611       });
79612       return _loadViewerPromise3;
79613     },
79614     selectImage: function(context, key, keepOrientation) {
79615       const d2 = this.cachedImage(key);
79616       this.updateUrlImage(key);
79617       const viewer = context.container().select(".photoviewer");
79618       if (!viewer.empty()) {
79619         viewer.datum(d2);
79620       }
79621       this.setStyles(context, null, true);
79622       if (!d2)
79623         return this;
79624       const wrap2 = context.container().select(".photoviewer .vegbilder-wrapper");
79625       const attribution = wrap2.selectAll(".photo-attribution").text("");
79626       if (d2.captured_at) {
79627         attribution.append("span").attr("class", "captured_at").text(localeTimestamp(d2.captured_at));
79628       }
79629       attribution.append("a").attr("target", "_blank").attr("href", "https://vegvesen.no").call(_t.append("vegbilder.publisher"));
79630       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"));
79631       _currentFrame = d2.is_sphere ? _pannellumFrame : _planeFrame;
79632       _currentFrame.selectPhoto(d2, keepOrientation).showPhotoFrame(wrap2);
79633       return this;
79634     },
79635     showViewer: function(context) {
79636       const viewer = context.container().select(".photoviewer").classed("hide", false);
79637       const isHidden = viewer.selectAll(".photo-wrapper.vegbilder-wrapper.hide").size();
79638       if (isHidden) {
79639         viewer.selectAll(".photo-wrapper:not(.vegbilder-wrapper)").classed("hide", true);
79640         viewer.selectAll(".photo-wrapper.vegbilder-wrapper").classed("hide", false);
79641       }
79642       return this;
79643     },
79644     hideViewer: function(context) {
79645       this.updateUrlImage(null);
79646       const viewer = context.container().select(".photoviewer");
79647       if (!viewer.empty())
79648         viewer.datum(null);
79649       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79650       context.container().selectAll(".viewfield-group, .sequence").classed("currentView", false);
79651       return this.setStyles(context, null, true);
79652     },
79653     // Updates the currently highlighted sequence and selected bubble.
79654     // Reset is only necessary when interacting with the viewport because
79655     // this implicitly changes the currently selected bubble/sequence
79656     setStyles: function(context, hovered, reset) {
79657       var _a2, _b;
79658       if (reset) {
79659         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79660         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79661       }
79662       const hoveredImageKey = hovered == null ? void 0 : hovered.key;
79663       const hoveredSequence = this.getSequenceForImage(hovered);
79664       const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key;
79665       const hoveredImageKeys = (_a2 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a2 : [];
79666       const viewer = context.container().select(".photoviewer");
79667       const selected = viewer.empty() ? void 0 : viewer.datum();
79668       const selectedImageKey = selected == null ? void 0 : selected.key;
79669       const selectedSequence = this.getSequenceForImage(selected);
79670       const selectedSequenceKey = selectedSequence == null ? void 0 : selectedSequence.key;
79671       const selectedImageKeys = (_b = selectedSequence == null ? void 0 : selectedSequence.images.map((d2) => d2.key)) != null ? _b : [];
79672       const highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79673       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);
79674       context.container().selectAll(".layer-vegbilder .sequence").classed("highlighted", (d2) => d2.key === hoveredSequenceKey).classed("currentView", (d2) => d2.key === selectedSequenceKey);
79675       context.container().selectAll(".layer-vegbilder .viewfield-group .viewfield").attr("d", viewfieldPath);
79676       function viewfieldPath() {
79677         const d2 = this.parentNode.__data__;
79678         if (d2.is_sphere && d2.key !== selectedImageKey) {
79679           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79680         } else {
79681           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79682         }
79683       }
79684       return this;
79685     },
79686     updateUrlImage: function(key) {
79687       if (!window.mocha) {
79688         const hash = utilStringQs(window.location.hash);
79689         if (key) {
79690           hash.photo = "vegbilder/" + key;
79691         } else {
79692           delete hash.photo;
79693         }
79694         window.location.replace("#" + utilQsString(hash, true));
79695       }
79696     },
79697     validHere: function(extent) {
79698       const bbox2 = Object.values(extent.bbox());
79699       return iso1A2Codes(bbox2).includes("NO");
79700     },
79701     cache: function() {
79702       return _vegbilderCache;
79703     }
79704   };
79705
79706   // node_modules/osm-auth/src/osm-auth.mjs
79707   function osmAuth(o2) {
79708     var oauth2 = {};
79709     var _store = null;
79710     try {
79711       _store = window.localStorage;
79712     } catch (e3) {
79713       var _mock = /* @__PURE__ */ new Map();
79714       _store = {
79715         isMocked: true,
79716         hasItem: (k2) => _mock.has(k2),
79717         getItem: (k2) => _mock.get(k2),
79718         setItem: (k2, v2) => _mock.set(k2, v2),
79719         removeItem: (k2) => _mock.delete(k2),
79720         clear: () => _mock.clear()
79721       };
79722     }
79723     function token(k2, v2) {
79724       if (arguments.length === 1)
79725         return _store.getItem(o2.url + k2);
79726       else if (arguments.length === 2)
79727         return _store.setItem(o2.url + k2, v2);
79728     }
79729     oauth2.authenticated = function() {
79730       return !!token("oauth2_access_token");
79731     };
79732     oauth2.logout = function() {
79733       token("oauth2_access_token", "");
79734       token("oauth_token", "");
79735       token("oauth_token_secret", "");
79736       token("oauth_request_token_secret", "");
79737       return oauth2;
79738     };
79739     oauth2.authenticate = function(callback) {
79740       if (oauth2.authenticated()) {
79741         callback(null, oauth2);
79742         return;
79743       }
79744       oauth2.logout();
79745       _preopenPopup(function(error, popup) {
79746         if (error) {
79747           callback(error);
79748         } else {
79749           _generatePkceChallenge(function(pkce) {
79750             _authenticate(pkce, popup, callback);
79751           });
79752         }
79753       });
79754     };
79755     oauth2.authenticateAsync = function() {
79756       if (oauth2.authenticated()) {
79757         return Promise.resolve(oauth2);
79758       }
79759       oauth2.logout();
79760       return new Promise((resolve, reject) => {
79761         var errback = (err, result) => {
79762           if (err) {
79763             reject(err);
79764           } else {
79765             resolve(result);
79766           }
79767         };
79768         _preopenPopup((error, popup) => {
79769           if (error) {
79770             errback(error);
79771           } else {
79772             _generatePkceChallenge((pkce) => _authenticate(pkce, popup, errback));
79773           }
79774         });
79775       });
79776     };
79777     function _preopenPopup(callback) {
79778       if (o2.singlepage) {
79779         callback(null, void 0);
79780         return;
79781       }
79782       var w2 = 550;
79783       var h2 = 610;
79784       var settings = [
79785         ["width", w2],
79786         ["height", h2],
79787         ["left", window.screen.width / 2 - w2 / 2],
79788         ["top", window.screen.height / 2 - h2 / 2]
79789       ].map(function(x2) {
79790         return x2.join("=");
79791       }).join(",");
79792       var popup = window.open("about:blank", "oauth_window", settings);
79793       if (popup) {
79794         callback(null, popup);
79795       } else {
79796         var error = new Error("Popup was blocked");
79797         error.status = "popup-blocked";
79798         callback(error);
79799       }
79800     }
79801     function _authenticate(pkce, popup, callback) {
79802       var state = generateState();
79803       var url = o2.url + "/oauth2/authorize?" + utilQsString2({
79804         client_id: o2.client_id,
79805         redirect_uri: o2.redirect_uri,
79806         response_type: "code",
79807         scope: o2.scope,
79808         state,
79809         code_challenge: pkce.code_challenge,
79810         code_challenge_method: pkce.code_challenge_method
79811       });
79812       if (o2.singlepage) {
79813         if (_store.isMocked) {
79814           var error = new Error("localStorage unavailable, but required in singlepage mode");
79815           error.status = "pkce-localstorage-unavailable";
79816           callback(error);
79817           return;
79818         }
79819         var params = utilStringQs2(window.location.search.slice(1));
79820         if (params.code) {
79821           oauth2.bootstrapToken(params.code, callback);
79822         } else {
79823           token("oauth2_state", state);
79824           token("oauth2_pkce_code_verifier", pkce.code_verifier);
79825           window.location = url;
79826         }
79827       } else {
79828         oauth2.popupWindow = popup;
79829         popup.location = url;
79830       }
79831       window.authComplete = function(url2) {
79832         var params2 = utilStringQs2(url2.split("?")[1]);
79833         if (params2.state !== state) {
79834           error = new Error("Invalid state");
79835           error.status = "invalid-state";
79836           callback(error);
79837           return;
79838         }
79839         _getAccessToken(params2.code, pkce.code_verifier, accessTokenDone);
79840         delete window.authComplete;
79841       };
79842       function accessTokenDone(err, xhr) {
79843         o2.done();
79844         if (err) {
79845           callback(err);
79846           return;
79847         }
79848         var access_token = JSON.parse(xhr.response);
79849         token("oauth2_access_token", access_token.access_token);
79850         callback(null, oauth2);
79851       }
79852     }
79853     function _getAccessToken(auth_code, code_verifier, accessTokenDone) {
79854       var url = o2.url + "/oauth2/token?" + utilQsString2({
79855         client_id: o2.client_id,
79856         redirect_uri: o2.redirect_uri,
79857         grant_type: "authorization_code",
79858         code: auth_code,
79859         code_verifier
79860       });
79861       oauth2.rawxhr("POST", url, null, null, null, accessTokenDone);
79862       o2.loading();
79863     }
79864     oauth2.bringPopupWindowToFront = function() {
79865       var broughtPopupToFront = false;
79866       try {
79867         if (oauth2.popupWindow && !oauth2.popupWindow.closed) {
79868           oauth2.popupWindow.focus();
79869           broughtPopupToFront = true;
79870         }
79871       } catch (err) {
79872       }
79873       return broughtPopupToFront;
79874     };
79875     oauth2.bootstrapToken = function(auth_code, callback) {
79876       var state = token("oauth2_state");
79877       token("oauth2_state", "");
79878       var params = utilStringQs2(window.location.search.slice(1));
79879       if (params.state !== state) {
79880         var error = new Error("Invalid state");
79881         error.status = "invalid-state";
79882         callback(error);
79883         return;
79884       }
79885       var code_verifier = token("oauth2_pkce_code_verifier");
79886       token("oauth2_pkce_code_verifier", "");
79887       _getAccessToken(auth_code, code_verifier, accessTokenDone);
79888       function accessTokenDone(err, xhr) {
79889         o2.done();
79890         if (err) {
79891           callback(err);
79892           return;
79893         }
79894         var access_token = JSON.parse(xhr.response);
79895         token("oauth2_access_token", access_token.access_token);
79896         callback(null, oauth2);
79897       }
79898     };
79899     oauth2.fetch = function(resource, options2) {
79900       if (oauth2.authenticated()) {
79901         return _doFetch();
79902       } else {
79903         if (o2.auto) {
79904           return oauth2.authenticateAsync().then(_doFetch);
79905         } else {
79906           return Promise.reject(new Error("not authenticated"));
79907         }
79908       }
79909       function _doFetch() {
79910         options2 = options2 || {};
79911         if (!options2.headers) {
79912           options2.headers = { "Content-Type": "application/x-www-form-urlencoded" };
79913         }
79914         options2.headers.Authorization = "Bearer " + token("oauth2_access_token");
79915         return fetch(resource, options2);
79916       }
79917     };
79918     oauth2.xhr = function(options2, callback) {
79919       if (oauth2.authenticated()) {
79920         return _doXHR();
79921       } else {
79922         if (o2.auto) {
79923           oauth2.authenticate(_doXHR);
79924           return;
79925         } else {
79926           callback("not authenticated", null);
79927           return;
79928         }
79929       }
79930       function _doXHR() {
79931         var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path;
79932         return oauth2.rawxhr(
79933           options2.method,
79934           url,
79935           token("oauth2_access_token"),
79936           options2.content,
79937           options2.headers,
79938           done
79939         );
79940       }
79941       function done(err, xhr) {
79942         if (err) {
79943           callback(err);
79944         } else if (xhr.responseXML) {
79945           callback(err, xhr.responseXML);
79946         } else {
79947           callback(err, xhr.response);
79948         }
79949       }
79950     };
79951     oauth2.rawxhr = function(method, url, access_token, data, headers, callback) {
79952       headers = headers || { "Content-Type": "application/x-www-form-urlencoded" };
79953       if (access_token) {
79954         headers.Authorization = "Bearer " + access_token;
79955       }
79956       var xhr = new XMLHttpRequest();
79957       xhr.onreadystatechange = function() {
79958         if (4 === xhr.readyState && 0 !== xhr.status) {
79959           if (/^20\d$/.test(xhr.status)) {
79960             callback(null, xhr);
79961           } else {
79962             callback(xhr, null);
79963           }
79964         }
79965       };
79966       xhr.onerror = function(e3) {
79967         callback(e3, null);
79968       };
79969       xhr.open(method, url, true);
79970       for (var h2 in headers)
79971         xhr.setRequestHeader(h2, headers[h2]);
79972       xhr.send(data);
79973       return xhr;
79974     };
79975     oauth2.preauth = function(val) {
79976       if (val && val.access_token) {
79977         token("oauth2_access_token", val.access_token);
79978       }
79979       return oauth2;
79980     };
79981     oauth2.options = function(val) {
79982       if (!arguments.length)
79983         return o2;
79984       o2 = val;
79985       o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org";
79986       o2.url = o2.url || "https://www.openstreetmap.org";
79987       o2.auto = o2.auto || false;
79988       o2.singlepage = o2.singlepage || false;
79989       o2.loading = o2.loading || function() {
79990       };
79991       o2.done = o2.done || function() {
79992       };
79993       return oauth2.preauth(o2);
79994     };
79995     oauth2.options(o2);
79996     return oauth2;
79997   }
79998   function utilQsString2(obj) {
79999     return Object.keys(obj).filter(function(key) {
80000       return obj[key] !== void 0;
80001     }).sort().map(function(key) {
80002       return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
80003     }).join("&");
80004   }
80005   function utilStringQs2(str) {
80006     var i3 = 0;
80007     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
80008       i3++;
80009     str = str.slice(i3);
80010     return str.split("&").reduce(function(obj, pair3) {
80011       var parts = pair3.split("=");
80012       if (parts.length === 2) {
80013         obj[parts[0]] = decodeURIComponent(parts[1]);
80014       }
80015       return obj;
80016     }, {});
80017   }
80018   function supportsWebCryptoAPI() {
80019     return window && window.crypto && window.crypto.getRandomValues && window.crypto.subtle && window.crypto.subtle.digest;
80020   }
80021   function _generatePkceChallenge(callback) {
80022     var code_verifier;
80023     if (supportsWebCryptoAPI()) {
80024       var random = window.crypto.getRandomValues(new Uint8Array(32));
80025       code_verifier = base64(random.buffer);
80026       var verifier = Uint8Array.from(Array.from(code_verifier).map(function(char) {
80027         return char.charCodeAt(0);
80028       }));
80029       window.crypto.subtle.digest("SHA-256", verifier).then(function(hash) {
80030         var code_challenge = base64(hash);
80031         callback({
80032           code_challenge,
80033           code_verifier,
80034           code_challenge_method: "S256"
80035         });
80036       });
80037     } else {
80038       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80039       code_verifier = "";
80040       for (var i3 = 0; i3 < 64; i3++) {
80041         code_verifier += chars[Math.floor(Math.random() * chars.length)];
80042       }
80043       callback({
80044         code_verifier,
80045         code_challenge: code_verifier,
80046         code_challenge_method: "plain"
80047       });
80048     }
80049   }
80050   function generateState() {
80051     var state;
80052     if (supportsWebCryptoAPI()) {
80053       var random = window.crypto.getRandomValues(new Uint8Array(32));
80054       state = base64(random.buffer);
80055     } else {
80056       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80057       state = "";
80058       for (var i3 = 0; i3 < 64; i3++) {
80059         state += chars[Math.floor(Math.random() * chars.length)];
80060       }
80061     }
80062     return state;
80063   }
80064   function base64(buffer) {
80065     return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]/g, "");
80066   }
80067
80068   // modules/services/osm.js
80069   var import_rbush10 = __toESM(require_rbush_min());
80070   var tiler6 = utilTiler();
80071   var dispatch10 = dispatch_default("apiStatusChange", "authLoading", "authDone", "change", "loading", "loaded", "loadedNotes");
80072   var urlroot = osmApiConnections[0].url;
80073   var apiUrlroot = osmApiConnections[0].apiUrl || urlroot;
80074   var redirectPath = window.location.origin + window.location.pathname;
80075   var oauth = osmAuth({
80076     url: urlroot,
80077     apiUrl: apiUrlroot,
80078     client_id: osmApiConnections[0].client_id,
80079     client_secret: osmApiConnections[0].client_secret,
80080     scope: "read_prefs write_prefs write_api read_gpx write_notes",
80081     redirect_uri: redirectPath + "land.html",
80082     loading: authLoading,
80083     done: authDone
80084   });
80085   var _apiConnections = osmApiConnections;
80086   var _imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
80087   var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80088   var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80089   var _userCache = { toLoad: {}, user: {} };
80090   var _cachedApiStatus;
80091   var _changeset = {};
80092   var _deferred = /* @__PURE__ */ new Set();
80093   var _connectionID = 1;
80094   var _tileZoom4 = 16;
80095   var _noteZoom = 12;
80096   var _rateLimitError;
80097   var _userChangesets;
80098   var _userDetails;
80099   var _off;
80100   var _maxWayNodes = 2e3;
80101   function authLoading() {
80102     dispatch10.call("authLoading");
80103   }
80104   function authDone() {
80105     dispatch10.call("authDone");
80106   }
80107   function abortRequest5(controllerOrXHR) {
80108     if (controllerOrXHR) {
80109       controllerOrXHR.abort();
80110     }
80111   }
80112   function hasInflightRequests(cache) {
80113     return Object.keys(cache.inflight).length;
80114   }
80115   function abortUnwantedRequests4(cache, visibleTiles) {
80116     Object.keys(cache.inflight).forEach(function(k2) {
80117       if (cache.toLoad[k2])
80118         return;
80119       if (visibleTiles.find(function(tile) {
80120         return k2 === tile.id;
80121       }))
80122         return;
80123       abortRequest5(cache.inflight[k2]);
80124       delete cache.inflight[k2];
80125     });
80126   }
80127   function getLoc(attrs) {
80128     var lon = attrs.lon && attrs.lon.value;
80129     var lat = attrs.lat && attrs.lat.value;
80130     return [Number(lon), Number(lat)];
80131   }
80132   function getNodes(obj) {
80133     var elems = obj.getElementsByTagName("nd");
80134     var nodes = new Array(elems.length);
80135     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80136       nodes[i3] = "n" + elems[i3].attributes.ref.value;
80137     }
80138     return nodes;
80139   }
80140   function getNodesJSON(obj) {
80141     var elems = obj.nodes;
80142     var nodes = new Array(elems.length);
80143     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80144       nodes[i3] = "n" + elems[i3];
80145     }
80146     return nodes;
80147   }
80148   function getTags(obj) {
80149     var elems = obj.getElementsByTagName("tag");
80150     var tags = {};
80151     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80152       var attrs = elems[i3].attributes;
80153       tags[attrs.k.value] = attrs.v.value;
80154     }
80155     return tags;
80156   }
80157   function getMembers(obj) {
80158     var elems = obj.getElementsByTagName("member");
80159     var members = new Array(elems.length);
80160     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80161       var attrs = elems[i3].attributes;
80162       members[i3] = {
80163         id: attrs.type.value[0] + attrs.ref.value,
80164         type: attrs.type.value,
80165         role: attrs.role.value
80166       };
80167     }
80168     return members;
80169   }
80170   function getMembersJSON(obj) {
80171     var elems = obj.members;
80172     var members = new Array(elems.length);
80173     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80174       var attrs = elems[i3];
80175       members[i3] = {
80176         id: attrs.type[0] + attrs.ref,
80177         type: attrs.type,
80178         role: attrs.role
80179       };
80180     }
80181     return members;
80182   }
80183   function getVisible(attrs) {
80184     return !attrs.visible || attrs.visible.value !== "false";
80185   }
80186   function parseComments(comments) {
80187     var parsedComments = [];
80188     for (var i3 = 0; i3 < comments.length; i3++) {
80189       var comment = comments[i3];
80190       if (comment.nodeName === "comment") {
80191         var childNodes = comment.childNodes;
80192         var parsedComment = {};
80193         for (var j2 = 0; j2 < childNodes.length; j2++) {
80194           var node = childNodes[j2];
80195           var nodeName = node.nodeName;
80196           if (nodeName === "#text")
80197             continue;
80198           parsedComment[nodeName] = node.textContent;
80199           if (nodeName === "uid") {
80200             var uid = node.textContent;
80201             if (uid && !_userCache.user[uid]) {
80202               _userCache.toLoad[uid] = true;
80203             }
80204           }
80205         }
80206         if (parsedComment) {
80207           parsedComments.push(parsedComment);
80208         }
80209       }
80210     }
80211     return parsedComments;
80212   }
80213   function encodeNoteRtree(note) {
80214     return {
80215       minX: note.loc[0],
80216       minY: note.loc[1],
80217       maxX: note.loc[0],
80218       maxY: note.loc[1],
80219       data: note
80220     };
80221   }
80222   var jsonparsers = {
80223     node: function nodeData(obj, uid) {
80224       return new osmNode({
80225         id: uid,
80226         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80227         version: obj.version && obj.version.toString(),
80228         changeset: obj.changeset && obj.changeset.toString(),
80229         timestamp: obj.timestamp,
80230         user: obj.user,
80231         uid: obj.uid && obj.uid.toString(),
80232         loc: [Number(obj.lon), Number(obj.lat)],
80233         tags: obj.tags
80234       });
80235     },
80236     way: function wayData(obj, uid) {
80237       return new osmWay({
80238         id: uid,
80239         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80240         version: obj.version && obj.version.toString(),
80241         changeset: obj.changeset && obj.changeset.toString(),
80242         timestamp: obj.timestamp,
80243         user: obj.user,
80244         uid: obj.uid && obj.uid.toString(),
80245         tags: obj.tags,
80246         nodes: getNodesJSON(obj)
80247       });
80248     },
80249     relation: function relationData(obj, uid) {
80250       return new osmRelation({
80251         id: uid,
80252         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80253         version: obj.version && obj.version.toString(),
80254         changeset: obj.changeset && obj.changeset.toString(),
80255         timestamp: obj.timestamp,
80256         user: obj.user,
80257         uid: obj.uid && obj.uid.toString(),
80258         tags: obj.tags,
80259         members: getMembersJSON(obj)
80260       });
80261     },
80262     user: function parseUser(obj, uid) {
80263       return {
80264         id: uid,
80265         display_name: obj.display_name,
80266         account_created: obj.account_created,
80267         image_url: obj.img && obj.img.href,
80268         changesets_count: obj.changesets && obj.changesets.count && obj.changesets.count.toString() || "0",
80269         active_blocks: obj.blocks && obj.blocks.received && obj.blocks.received.active && obj.blocks.received.active.toString() || "0"
80270       };
80271     }
80272   };
80273   function parseJSON(payload, callback, options2) {
80274     options2 = Object.assign({ skipSeen: true }, options2);
80275     if (!payload) {
80276       return callback({ message: "No JSON", status: -1 });
80277     }
80278     var json = payload;
80279     if (typeof json !== "object")
80280       json = JSON.parse(payload);
80281     if (!json.elements)
80282       return callback({ message: "No JSON", status: -1 });
80283     var children2 = json.elements;
80284     var handle = window.requestIdleCallback(function() {
80285       _deferred.delete(handle);
80286       var results = [];
80287       var result;
80288       for (var i3 = 0; i3 < children2.length; i3++) {
80289         result = parseChild(children2[i3]);
80290         if (result)
80291           results.push(result);
80292       }
80293       callback(null, results);
80294     });
80295     _deferred.add(handle);
80296     function parseChild(child) {
80297       var parser3 = jsonparsers[child.type];
80298       if (!parser3)
80299         return null;
80300       var uid;
80301       uid = osmEntity.id.fromOSM(child.type, child.id);
80302       if (options2.skipSeen) {
80303         if (_tileCache.seen[uid])
80304           return null;
80305         _tileCache.seen[uid] = true;
80306       }
80307       return parser3(child, uid);
80308     }
80309   }
80310   function parseUserJSON(payload, callback, options2) {
80311     options2 = Object.assign({ skipSeen: true }, options2);
80312     if (!payload) {
80313       return callback({ message: "No JSON", status: -1 });
80314     }
80315     var json = payload;
80316     if (typeof json !== "object")
80317       json = JSON.parse(payload);
80318     if (!json.users && !json.user)
80319       return callback({ message: "No JSON", status: -1 });
80320     var objs = json.users || [json];
80321     var handle = window.requestIdleCallback(function() {
80322       _deferred.delete(handle);
80323       var results = [];
80324       var result;
80325       for (var i3 = 0; i3 < objs.length; i3++) {
80326         result = parseObj(objs[i3]);
80327         if (result)
80328           results.push(result);
80329       }
80330       callback(null, results);
80331     });
80332     _deferred.add(handle);
80333     function parseObj(obj) {
80334       var uid = obj.user.id && obj.user.id.toString();
80335       if (options2.skipSeen && _userCache.user[uid]) {
80336         delete _userCache.toLoad[uid];
80337         return null;
80338       }
80339       var user = jsonparsers.user(obj.user, uid);
80340       _userCache.user[uid] = user;
80341       delete _userCache.toLoad[uid];
80342       return user;
80343     }
80344   }
80345   var parsers = {
80346     node: function nodeData2(obj, uid) {
80347       var attrs = obj.attributes;
80348       return new osmNode({
80349         id: uid,
80350         visible: getVisible(attrs),
80351         version: attrs.version.value,
80352         changeset: attrs.changeset && attrs.changeset.value,
80353         timestamp: attrs.timestamp && attrs.timestamp.value,
80354         user: attrs.user && attrs.user.value,
80355         uid: attrs.uid && attrs.uid.value,
80356         loc: getLoc(attrs),
80357         tags: getTags(obj)
80358       });
80359     },
80360     way: function wayData2(obj, uid) {
80361       var attrs = obj.attributes;
80362       return new osmWay({
80363         id: uid,
80364         visible: getVisible(attrs),
80365         version: attrs.version.value,
80366         changeset: attrs.changeset && attrs.changeset.value,
80367         timestamp: attrs.timestamp && attrs.timestamp.value,
80368         user: attrs.user && attrs.user.value,
80369         uid: attrs.uid && attrs.uid.value,
80370         tags: getTags(obj),
80371         nodes: getNodes(obj)
80372       });
80373     },
80374     relation: function relationData2(obj, uid) {
80375       var attrs = obj.attributes;
80376       return new osmRelation({
80377         id: uid,
80378         visible: getVisible(attrs),
80379         version: attrs.version.value,
80380         changeset: attrs.changeset && attrs.changeset.value,
80381         timestamp: attrs.timestamp && attrs.timestamp.value,
80382         user: attrs.user && attrs.user.value,
80383         uid: attrs.uid && attrs.uid.value,
80384         tags: getTags(obj),
80385         members: getMembers(obj)
80386       });
80387     },
80388     note: function parseNote(obj, uid) {
80389       var attrs = obj.attributes;
80390       var childNodes = obj.childNodes;
80391       var props = {};
80392       props.id = uid;
80393       props.loc = getLoc(attrs);
80394       if (!_noteCache.note[uid]) {
80395         let coincident = false;
80396         const epsilon3 = 1e-5;
80397         do {
80398           if (coincident) {
80399             props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]);
80400           }
80401           const bbox2 = geoExtent(props.loc).bbox();
80402           coincident = _noteCache.rtree.search(bbox2).length;
80403         } while (coincident);
80404       } else {
80405         props.loc = _noteCache.note[uid].loc;
80406       }
80407       for (var i3 = 0; i3 < childNodes.length; i3++) {
80408         var node = childNodes[i3];
80409         var nodeName = node.nodeName;
80410         if (nodeName === "#text")
80411           continue;
80412         if (nodeName === "comments") {
80413           props[nodeName] = parseComments(node.childNodes);
80414         } else {
80415           props[nodeName] = node.textContent;
80416         }
80417       }
80418       var note = new osmNote(props);
80419       var item = encodeNoteRtree(note);
80420       _noteCache.note[note.id] = note;
80421       updateRtree4(item, true);
80422       return note;
80423     },
80424     user: function parseUser2(obj, uid) {
80425       var attrs = obj.attributes;
80426       var user = {
80427         id: uid,
80428         display_name: attrs.display_name && attrs.display_name.value,
80429         account_created: attrs.account_created && attrs.account_created.value,
80430         changesets_count: "0",
80431         active_blocks: "0"
80432       };
80433       var img = obj.getElementsByTagName("img");
80434       if (img && img[0] && img[0].getAttribute("href")) {
80435         user.image_url = img[0].getAttribute("href");
80436       }
80437       var changesets = obj.getElementsByTagName("changesets");
80438       if (changesets && changesets[0] && changesets[0].getAttribute("count")) {
80439         user.changesets_count = changesets[0].getAttribute("count");
80440       }
80441       var blocks = obj.getElementsByTagName("blocks");
80442       if (blocks && blocks[0]) {
80443         var received = blocks[0].getElementsByTagName("received");
80444         if (received && received[0] && received[0].getAttribute("active")) {
80445           user.active_blocks = received[0].getAttribute("active");
80446         }
80447       }
80448       _userCache.user[uid] = user;
80449       delete _userCache.toLoad[uid];
80450       return user;
80451     }
80452   };
80453   function parseXML(xml, callback, options2) {
80454     options2 = Object.assign({ skipSeen: true }, options2);
80455     if (!xml || !xml.childNodes) {
80456       return callback({ message: "No XML", status: -1 });
80457     }
80458     var root3 = xml.childNodes[0];
80459     var children2 = root3.childNodes;
80460     var handle = window.requestIdleCallback(function() {
80461       _deferred.delete(handle);
80462       var results = [];
80463       var result;
80464       for (var i3 = 0; i3 < children2.length; i3++) {
80465         result = parseChild(children2[i3]);
80466         if (result)
80467           results.push(result);
80468       }
80469       callback(null, results);
80470     });
80471     _deferred.add(handle);
80472     function parseChild(child) {
80473       var parser3 = parsers[child.nodeName];
80474       if (!parser3)
80475         return null;
80476       var uid;
80477       if (child.nodeName === "user") {
80478         uid = child.attributes.id.value;
80479         if (options2.skipSeen && _userCache.user[uid]) {
80480           delete _userCache.toLoad[uid];
80481           return null;
80482         }
80483       } else if (child.nodeName === "note") {
80484         uid = child.getElementsByTagName("id")[0].textContent;
80485       } else {
80486         uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value);
80487         if (options2.skipSeen) {
80488           if (_tileCache.seen[uid])
80489             return null;
80490           _tileCache.seen[uid] = true;
80491         }
80492       }
80493       return parser3(child, uid);
80494     }
80495   }
80496   function updateRtree4(item, replace) {
80497     _noteCache.rtree.remove(item, function isEql(a2, b2) {
80498       return a2.data.id === b2.data.id;
80499     });
80500     if (replace) {
80501       _noteCache.rtree.insert(item);
80502     }
80503   }
80504   function wrapcb(thisArg, callback, cid) {
80505     return function(err, result) {
80506       if (err) {
80507         if (err.status === 400 || err.status === 401 || err.status === 403) {
80508           thisArg.logout();
80509         }
80510         return callback.call(thisArg, err);
80511       } else if (thisArg.getConnectionId() !== cid) {
80512         return callback.call(thisArg, { message: "Connection Switched", status: -1 });
80513       } else {
80514         return callback.call(thisArg, err, result);
80515       }
80516     };
80517   }
80518   var osm_default = {
80519     init: function() {
80520       utilRebind(this, dispatch10, "on");
80521     },
80522     reset: function() {
80523       Array.from(_deferred).forEach(function(handle) {
80524         window.cancelIdleCallback(handle);
80525         _deferred.delete(handle);
80526       });
80527       _connectionID++;
80528       _userChangesets = void 0;
80529       _userDetails = void 0;
80530       _rateLimitError = void 0;
80531       Object.values(_tileCache.inflight).forEach(abortRequest5);
80532       Object.values(_noteCache.inflight).forEach(abortRequest5);
80533       Object.values(_noteCache.inflightPost).forEach(abortRequest5);
80534       if (_changeset.inflight)
80535         abortRequest5(_changeset.inflight);
80536       _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80537       _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80538       _userCache = { toLoad: {}, user: {} };
80539       _cachedApiStatus = void 0;
80540       _changeset = {};
80541       return this;
80542     },
80543     getConnectionId: function() {
80544       return _connectionID;
80545     },
80546     getUrlRoot: function() {
80547       return urlroot;
80548     },
80549     getApiUrlRoot: function() {
80550       return apiUrlroot;
80551     },
80552     changesetURL: function(changesetID) {
80553       return urlroot + "/changeset/" + changesetID;
80554     },
80555     changesetsURL: function(center, zoom) {
80556       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
80557       return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
80558     },
80559     entityURL: function(entity) {
80560       return urlroot + "/" + entity.type + "/" + entity.osmId();
80561     },
80562     historyURL: function(entity) {
80563       return urlroot + "/" + entity.type + "/" + entity.osmId() + "/history";
80564     },
80565     userURL: function(username) {
80566       return urlroot + "/user/" + encodeURIComponent(username);
80567     },
80568     noteURL: function(note) {
80569       return urlroot + "/note/" + note.id;
80570     },
80571     noteReportURL: function(note) {
80572       return urlroot + "/reports/new?reportable_type=Note&reportable_id=" + note.id;
80573     },
80574     // Generic method to load data from the OSM API
80575     // Can handle either auth or unauth calls.
80576     loadFromAPI: function(path, callback, options2) {
80577       options2 = Object.assign({ skipSeen: true }, options2);
80578       var that = this;
80579       var cid = _connectionID;
80580       function done(err, payload) {
80581         if (that.getConnectionId() !== cid) {
80582           if (callback)
80583             callback({ message: "Connection Switched", status: -1 });
80584           return;
80585         }
80586         var isAuthenticated = that.authenticated();
80587         if (isAuthenticated && err && err.status && (err.status === 400 || err.status === 401 || err.status === 403)) {
80588           that.logout();
80589           that.loadFromAPI(path, callback, options2);
80590         } else {
80591           if (!isAuthenticated && !_rateLimitError && err && err.status && (err.status === 509 || err.status === 429)) {
80592             _rateLimitError = err;
80593             dispatch10.call("change");
80594             that.reloadApiStatus();
80595           } else if (err && _cachedApiStatus === "online" || !err && _cachedApiStatus !== "online") {
80596             that.reloadApiStatus();
80597           }
80598           if (callback) {
80599             if (err) {
80600               return callback(err);
80601             } else {
80602               if (path.indexOf(".json") !== -1) {
80603                 return parseJSON(payload, callback, options2);
80604               } else {
80605                 return parseXML(payload, callback, options2);
80606               }
80607             }
80608           }
80609         }
80610       }
80611       if (this.authenticated()) {
80612         return oauth.xhr({
80613           method: "GET",
80614           path
80615         }, done);
80616       } else {
80617         var url = apiUrlroot + path;
80618         var controller = new AbortController();
80619         var fn;
80620         if (path.indexOf(".json") !== -1) {
80621           fn = json_default;
80622         } else {
80623           fn = xml_default;
80624         }
80625         fn(url, { signal: controller.signal }).then(function(data) {
80626           done(null, data);
80627         }).catch(function(err) {
80628           if (err.name === "AbortError")
80629             return;
80630           var match = err.message.match(/^\d{3}/);
80631           if (match) {
80632             done({ status: +match[0], statusText: err.message });
80633           } else {
80634             done(err.message);
80635           }
80636         });
80637         return controller;
80638       }
80639     },
80640     // Load a single entity by id (ways and relations use the `/full` call to include
80641     // nodes and members). Parent relations are not included, see `loadEntityRelations`.
80642     // GET /api/0.6/node/#id
80643     // GET /api/0.6/[way|relation]/#id/full
80644     loadEntity: function(id2, callback) {
80645       var type2 = osmEntity.id.type(id2);
80646       var osmID = osmEntity.id.toOSM(id2);
80647       var options2 = { skipSeen: false };
80648       this.loadFromAPI(
80649         "/api/0.6/" + type2 + "/" + osmID + (type2 !== "node" ? "/full" : "") + ".json",
80650         function(err, entities) {
80651           if (callback)
80652             callback(err, { data: entities });
80653         },
80654         options2
80655       );
80656     },
80657     // Load a single note by id , XML format
80658     // GET /api/0.6/notes/#id
80659     loadEntityNote: function(id2, callback) {
80660       var options2 = { skipSeen: false };
80661       this.loadFromAPI(
80662         "/api/0.6/notes/" + id2,
80663         function(err, entities) {
80664           if (callback)
80665             callback(err, { data: entities });
80666         },
80667         options2
80668       );
80669     },
80670     // Load a single entity with a specific version
80671     // GET /api/0.6/[node|way|relation]/#id/#version
80672     loadEntityVersion: function(id2, version, callback) {
80673       var type2 = osmEntity.id.type(id2);
80674       var osmID = osmEntity.id.toOSM(id2);
80675       var options2 = { skipSeen: false };
80676       this.loadFromAPI(
80677         "/api/0.6/" + type2 + "/" + osmID + "/" + version + ".json",
80678         function(err, entities) {
80679           if (callback)
80680             callback(err, { data: entities });
80681         },
80682         options2
80683       );
80684     },
80685     // Load the relations of a single entity with the given.
80686     // GET /api/0.6/[node|way|relation]/#id/relations
80687     loadEntityRelations: function(id2, callback) {
80688       var type2 = osmEntity.id.type(id2);
80689       var osmID = osmEntity.id.toOSM(id2);
80690       var options2 = { skipSeen: false };
80691       this.loadFromAPI(
80692         "/api/0.6/" + type2 + "/" + osmID + "/relations.json",
80693         function(err, entities) {
80694           if (callback)
80695             callback(err, { data: entities });
80696         },
80697         options2
80698       );
80699     },
80700     // Load multiple entities in chunks
80701     // (note: callback may be called multiple times)
80702     // Unlike `loadEntity`, child nodes and members are not fetched
80703     // GET /api/0.6/[nodes|ways|relations]?#parameters
80704     loadMultiple: function(ids, callback) {
80705       var that = this;
80706       var groups = utilArrayGroupBy(utilArrayUniq(ids), osmEntity.id.type);
80707       Object.keys(groups).forEach(function(k2) {
80708         var type2 = k2 + "s";
80709         var osmIDs = groups[k2].map(function(id2) {
80710           return osmEntity.id.toOSM(id2);
80711         });
80712         var options2 = { skipSeen: false };
80713         utilArrayChunk(osmIDs, 150).forEach(function(arr) {
80714           that.loadFromAPI(
80715             "/api/0.6/" + type2 + ".json?" + type2 + "=" + arr.join(),
80716             function(err, entities) {
80717               if (callback)
80718                 callback(err, { data: entities });
80719             },
80720             options2
80721           );
80722         });
80723       });
80724     },
80725     // Create, upload, and close a changeset
80726     // PUT /api/0.6/changeset/create
80727     // POST /api/0.6/changeset/#id/upload
80728     // PUT /api/0.6/changeset/#id/close
80729     putChangeset: function(changeset, changes, callback) {
80730       var cid = _connectionID;
80731       if (_changeset.inflight) {
80732         return callback({ message: "Changeset already inflight", status: -2 }, changeset);
80733       } else if (_changeset.open) {
80734         return createdChangeset.call(this, null, _changeset.open);
80735       } else {
80736         var options2 = {
80737           method: "PUT",
80738           path: "/api/0.6/changeset/create",
80739           headers: { "Content-Type": "text/xml" },
80740           content: JXON.stringify(changeset.asJXON())
80741         };
80742         _changeset.inflight = oauth.xhr(
80743           options2,
80744           wrapcb(this, createdChangeset, cid)
80745         );
80746       }
80747       function createdChangeset(err, changesetID) {
80748         _changeset.inflight = null;
80749         if (err) {
80750           return callback(err, changeset);
80751         }
80752         _changeset.open = changesetID;
80753         changeset = changeset.update({ id: changesetID });
80754         var options3 = {
80755           method: "POST",
80756           path: "/api/0.6/changeset/" + changesetID + "/upload",
80757           headers: { "Content-Type": "text/xml" },
80758           content: JXON.stringify(changeset.osmChangeJXON(changes))
80759         };
80760         _changeset.inflight = oauth.xhr(
80761           options3,
80762           wrapcb(this, uploadedChangeset, cid)
80763         );
80764       }
80765       function uploadedChangeset(err) {
80766         _changeset.inflight = null;
80767         if (err)
80768           return callback(err, changeset);
80769         window.setTimeout(function() {
80770           callback(null, changeset);
80771         }, 2500);
80772         _changeset.open = null;
80773         if (this.getConnectionId() === cid) {
80774           oauth.xhr({
80775             method: "PUT",
80776             path: "/api/0.6/changeset/" + changeset.id + "/close",
80777             headers: { "Content-Type": "text/xml" }
80778           }, function() {
80779             return true;
80780           });
80781         }
80782       }
80783     },
80784     // Load multiple users in chunks
80785     // (note: callback may be called multiple times)
80786     // GET /api/0.6/users?users=#id1,#id2,...,#idn
80787     loadUsers: function(uids, callback) {
80788       var toLoad = [];
80789       var cached = [];
80790       utilArrayUniq(uids).forEach(function(uid) {
80791         if (_userCache.user[uid]) {
80792           delete _userCache.toLoad[uid];
80793           cached.push(_userCache.user[uid]);
80794         } else {
80795           toLoad.push(uid);
80796         }
80797       });
80798       if (cached.length || !this.authenticated()) {
80799         callback(void 0, cached);
80800         if (!this.authenticated())
80801           return;
80802       }
80803       utilArrayChunk(toLoad, 150).forEach((function(arr) {
80804         oauth.xhr({
80805           method: "GET",
80806           path: "/api/0.6/users.json?users=" + arr.join()
80807         }, wrapcb(this, done, _connectionID));
80808       }).bind(this));
80809       function done(err, payload) {
80810         if (err)
80811           return callback(err);
80812         var options2 = { skipSeen: true };
80813         return parseUserJSON(payload, function(err2, results) {
80814           if (err2)
80815             return callback(err2);
80816           return callback(void 0, results);
80817         }, options2);
80818       }
80819     },
80820     // Load a given user by id
80821     // GET /api/0.6/user/#id
80822     loadUser: function(uid, callback) {
80823       if (_userCache.user[uid] || !this.authenticated()) {
80824         delete _userCache.toLoad[uid];
80825         return callback(void 0, _userCache.user[uid]);
80826       }
80827       oauth.xhr({
80828         method: "GET",
80829         path: "/api/0.6/user/" + uid + ".json"
80830       }, wrapcb(this, done, _connectionID));
80831       function done(err, payload) {
80832         if (err)
80833           return callback(err);
80834         var options2 = { skipSeen: true };
80835         return parseUserJSON(payload, function(err2, results) {
80836           if (err2)
80837             return callback(err2);
80838           return callback(void 0, results[0]);
80839         }, options2);
80840       }
80841     },
80842     // Load the details of the logged-in user
80843     // GET /api/0.6/user/details
80844     userDetails: function(callback) {
80845       if (_userDetails) {
80846         return callback(void 0, _userDetails);
80847       }
80848       oauth.xhr({
80849         method: "GET",
80850         path: "/api/0.6/user/details.json"
80851       }, wrapcb(this, done, _connectionID));
80852       function done(err, payload) {
80853         if (err)
80854           return callback(err);
80855         var options2 = { skipSeen: false };
80856         return parseUserJSON(payload, function(err2, results) {
80857           if (err2)
80858             return callback(err2);
80859           _userDetails = results[0];
80860           return callback(void 0, _userDetails);
80861         }, options2);
80862       }
80863     },
80864     // Load previous changesets for the logged in user
80865     // GET /api/0.6/changesets?user=#id
80866     userChangesets: function(callback) {
80867       if (_userChangesets) {
80868         return callback(void 0, _userChangesets);
80869       }
80870       this.userDetails(
80871         wrapcb(this, gotDetails, _connectionID)
80872       );
80873       function gotDetails(err, user) {
80874         if (err) {
80875           return callback(err);
80876         }
80877         oauth.xhr({
80878           method: "GET",
80879           path: "/api/0.6/changesets?user=" + user.id
80880         }, wrapcb(this, done, _connectionID));
80881       }
80882       function done(err, xml) {
80883         if (err) {
80884           return callback(err);
80885         }
80886         _userChangesets = Array.prototype.map.call(
80887           xml.getElementsByTagName("changeset"),
80888           function(changeset) {
80889             return { tags: getTags(changeset) };
80890           }
80891         ).filter(function(changeset) {
80892           var comment = changeset.tags.comment;
80893           return comment && comment !== "";
80894         });
80895         return callback(void 0, _userChangesets);
80896       }
80897     },
80898     // Fetch the status of the OSM API
80899     // GET /api/capabilities
80900     status: function(callback) {
80901       var url = apiUrlroot + "/api/capabilities";
80902       var errback = wrapcb(this, done, _connectionID);
80903       xml_default(url).then(function(data) {
80904         errback(null, data);
80905       }).catch(function(err) {
80906         errback(err.message);
80907       });
80908       function done(err, xml) {
80909         if (err) {
80910           return callback(err, null);
80911         }
80912         var elements = xml.getElementsByTagName("blacklist");
80913         var regexes = [];
80914         for (var i3 = 0; i3 < elements.length; i3++) {
80915           var regexString = elements[i3].getAttribute("regex");
80916           if (regexString) {
80917             try {
80918               var regex = new RegExp(regexString);
80919               regexes.push(regex);
80920             } catch (e3) {
80921             }
80922           }
80923         }
80924         if (regexes.length) {
80925           _imageryBlocklists = regexes;
80926         }
80927         if (_rateLimitError) {
80928           return callback(_rateLimitError, "rateLimited");
80929         } else {
80930           var waynodes = xml.getElementsByTagName("waynodes");
80931           var maxWayNodes = waynodes.length && parseInt(waynodes[0].getAttribute("maximum"), 10);
80932           if (maxWayNodes && isFinite(maxWayNodes))
80933             _maxWayNodes = maxWayNodes;
80934           var apiStatus = xml.getElementsByTagName("status");
80935           var val = apiStatus[0].getAttribute("api");
80936           return callback(void 0, val);
80937         }
80938       }
80939     },
80940     // Calls `status` and dispatches an `apiStatusChange` event if the returned
80941     // status differs from the cached status.
80942     reloadApiStatus: function() {
80943       if (!this.throttledReloadApiStatus) {
80944         var that = this;
80945         this.throttledReloadApiStatus = throttle_default(function() {
80946           that.status(function(err, status) {
80947             if (status !== _cachedApiStatus) {
80948               _cachedApiStatus = status;
80949               dispatch10.call("apiStatusChange", that, err, status);
80950             }
80951           });
80952         }, 500);
80953       }
80954       this.throttledReloadApiStatus();
80955     },
80956     // Returns the maximum number of nodes a single way can have
80957     maxWayNodes: function() {
80958       return _maxWayNodes;
80959     },
80960     // Load data (entities) from the API in tiles
80961     // GET /api/0.6/map?bbox=
80962     loadTiles: function(projection2, callback) {
80963       if (_off)
80964         return;
80965       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
80966       var hadRequests = hasInflightRequests(_tileCache);
80967       abortUnwantedRequests4(_tileCache, tiles);
80968       if (hadRequests && !hasInflightRequests(_tileCache)) {
80969         dispatch10.call("loaded");
80970       }
80971       tiles.forEach(function(tile) {
80972         this.loadTile(tile, callback);
80973       }, this);
80974     },
80975     // Load a single data tile
80976     // GET /api/0.6/map?bbox=
80977     loadTile: function(tile, callback) {
80978       if (_off)
80979         return;
80980       if (_tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
80981         return;
80982       if (!hasInflightRequests(_tileCache)) {
80983         dispatch10.call("loading");
80984       }
80985       var path = "/api/0.6/map.json?bbox=";
80986       var options2 = { skipSeen: true };
80987       _tileCache.inflight[tile.id] = this.loadFromAPI(
80988         path + tile.extent.toParam(),
80989         tileCallback,
80990         options2
80991       );
80992       function tileCallback(err, parsed) {
80993         delete _tileCache.inflight[tile.id];
80994         if (!err) {
80995           delete _tileCache.toLoad[tile.id];
80996           _tileCache.loaded[tile.id] = true;
80997           var bbox2 = tile.extent.bbox();
80998           bbox2.id = tile.id;
80999           _tileCache.rtree.insert(bbox2);
81000         }
81001         if (callback) {
81002           callback(err, Object.assign({ data: parsed }, tile));
81003         }
81004         if (!hasInflightRequests(_tileCache)) {
81005           dispatch10.call("loaded");
81006         }
81007       }
81008     },
81009     isDataLoaded: function(loc) {
81010       var bbox2 = { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] };
81011       return _tileCache.rtree.collides(bbox2);
81012     },
81013     // load the tile that covers the given `loc`
81014     loadTileAtLoc: function(loc, callback) {
81015       if (Object.keys(_tileCache.toLoad).length > 50)
81016         return;
81017       var k2 = geoZoomToScale(_tileZoom4 + 1);
81018       var offset = geoRawMercator().scale(k2)(loc);
81019       var projection2 = geoRawMercator().transform({ k: k2, x: -offset[0], y: -offset[1] });
81020       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
81021       tiles.forEach(function(tile) {
81022         if (_tileCache.toLoad[tile.id] || _tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
81023           return;
81024         _tileCache.toLoad[tile.id] = true;
81025         this.loadTile(tile, callback);
81026       }, this);
81027     },
81028     // Load notes from the API in tiles
81029     // GET /api/0.6/notes?bbox=
81030     loadNotes: function(projection2, noteOptions) {
81031       noteOptions = Object.assign({ limit: 1e4, closed: 7 }, noteOptions);
81032       if (_off)
81033         return;
81034       var that = this;
81035       var path = "/api/0.6/notes?limit=" + noteOptions.limit + "&closed=" + noteOptions.closed + "&bbox=";
81036       var throttleLoadUsers = throttle_default(function() {
81037         var uids = Object.keys(_userCache.toLoad);
81038         if (!uids.length)
81039           return;
81040         that.loadUsers(uids, function() {
81041         });
81042       }, 750);
81043       var tiles = tiler6.zoomExtent([_noteZoom, _noteZoom]).getTiles(projection2);
81044       abortUnwantedRequests4(_noteCache, tiles);
81045       tiles.forEach(function(tile) {
81046         if (_noteCache.loaded[tile.id] || _noteCache.inflight[tile.id])
81047           return;
81048         var options2 = { skipSeen: false };
81049         _noteCache.inflight[tile.id] = that.loadFromAPI(
81050           path + tile.extent.toParam(),
81051           function(err) {
81052             delete _noteCache.inflight[tile.id];
81053             if (!err) {
81054               _noteCache.loaded[tile.id] = true;
81055             }
81056             throttleLoadUsers();
81057             dispatch10.call("loadedNotes");
81058           },
81059           options2
81060         );
81061       });
81062     },
81063     // Create a note
81064     // POST /api/0.6/notes?params
81065     postNoteCreate: function(note, callback) {
81066       if (!this.authenticated()) {
81067         return callback({ message: "Not Authenticated", status: -3 }, note);
81068       }
81069       if (_noteCache.inflightPost[note.id]) {
81070         return callback({ message: "Note update already inflight", status: -2 }, note);
81071       }
81072       if (!note.loc[0] || !note.loc[1] || !note.newComment)
81073         return;
81074       var comment = note.newComment;
81075       if (note.newCategory && note.newCategory !== "None") {
81076         comment += " #" + note.newCategory;
81077       }
81078       var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment });
81079       _noteCache.inflightPost[note.id] = oauth.xhr({
81080         method: "POST",
81081         path
81082       }, wrapcb(this, done, _connectionID));
81083       function done(err, xml) {
81084         delete _noteCache.inflightPost[note.id];
81085         if (err) {
81086           return callback(err);
81087         }
81088         this.removeNote(note);
81089         var options2 = { skipSeen: false };
81090         return parseXML(xml, function(err2, results) {
81091           if (err2) {
81092             return callback(err2);
81093           } else {
81094             return callback(void 0, results[0]);
81095           }
81096         }, options2);
81097       }
81098     },
81099     // Update a note
81100     // POST /api/0.6/notes/#id/comment?text=comment
81101     // POST /api/0.6/notes/#id/close?text=comment
81102     // POST /api/0.6/notes/#id/reopen?text=comment
81103     postNoteUpdate: function(note, newStatus, callback) {
81104       if (!this.authenticated()) {
81105         return callback({ message: "Not Authenticated", status: -3 }, note);
81106       }
81107       if (_noteCache.inflightPost[note.id]) {
81108         return callback({ message: "Note update already inflight", status: -2 }, note);
81109       }
81110       var action;
81111       if (note.status !== "closed" && newStatus === "closed") {
81112         action = "close";
81113       } else if (note.status !== "open" && newStatus === "open") {
81114         action = "reopen";
81115       } else {
81116         action = "comment";
81117         if (!note.newComment)
81118           return;
81119       }
81120       var path = "/api/0.6/notes/" + note.id + "/" + action;
81121       if (note.newComment) {
81122         path += "?" + utilQsString({ text: note.newComment });
81123       }
81124       _noteCache.inflightPost[note.id] = oauth.xhr({
81125         method: "POST",
81126         path
81127       }, wrapcb(this, done, _connectionID));
81128       function done(err, xml) {
81129         delete _noteCache.inflightPost[note.id];
81130         if (err) {
81131           return callback(err);
81132         }
81133         this.removeNote(note);
81134         if (action === "close") {
81135           _noteCache.closed[note.id] = true;
81136         } else if (action === "reopen") {
81137           delete _noteCache.closed[note.id];
81138         }
81139         var options2 = { skipSeen: false };
81140         return parseXML(xml, function(err2, results) {
81141           if (err2) {
81142             return callback(err2);
81143           } else {
81144             return callback(void 0, results[0]);
81145           }
81146         }, options2);
81147       }
81148     },
81149     /* connection options for source switcher (optional) */
81150     apiConnections: function(val) {
81151       if (!arguments.length)
81152         return _apiConnections;
81153       _apiConnections = val;
81154       return this;
81155     },
81156     switch: function(newOptions) {
81157       urlroot = newOptions.url;
81158       apiUrlroot = newOptions.apiUrl || urlroot;
81159       if (newOptions.url && !newOptions.apiUrl) {
81160         newOptions = {
81161           ...newOptions,
81162           apiUrl: newOptions.url
81163         };
81164       }
81165       const oldOptions = utilObjectOmit(oauth.options(), "access_token");
81166       oauth.options({ ...oldOptions, ...newOptions });
81167       this.reset();
81168       this.userChangesets(function() {
81169       });
81170       dispatch10.call("change");
81171       return this;
81172     },
81173     toggle: function(val) {
81174       _off = !val;
81175       return this;
81176     },
81177     isChangesetInflight: function() {
81178       return !!_changeset.inflight;
81179     },
81180     // get/set cached data
81181     // This is used to save/restore the state when entering/exiting the walkthrough
81182     // Also used for testing purposes.
81183     caches: function(obj) {
81184       function cloneCache(source) {
81185         var target = {};
81186         Object.keys(source).forEach(function(k2) {
81187           if (k2 === "rtree") {
81188             target.rtree = new import_rbush10.default().fromJSON(source.rtree.toJSON());
81189           } else if (k2 === "note") {
81190             target.note = {};
81191             Object.keys(source.note).forEach(function(id2) {
81192               target.note[id2] = osmNote(source.note[id2]);
81193             });
81194           } else {
81195             target[k2] = JSON.parse(JSON.stringify(source[k2]));
81196           }
81197         });
81198         return target;
81199       }
81200       if (!arguments.length) {
81201         return {
81202           tile: cloneCache(_tileCache),
81203           note: cloneCache(_noteCache),
81204           user: cloneCache(_userCache)
81205         };
81206       }
81207       if (obj === "get") {
81208         return {
81209           tile: _tileCache,
81210           note: _noteCache,
81211           user: _userCache
81212         };
81213       }
81214       if (obj.tile) {
81215         _tileCache = obj.tile;
81216         _tileCache.inflight = {};
81217       }
81218       if (obj.note) {
81219         _noteCache = obj.note;
81220         _noteCache.inflight = {};
81221         _noteCache.inflightPost = {};
81222       }
81223       if (obj.user) {
81224         _userCache = obj.user;
81225       }
81226       return this;
81227     },
81228     logout: function() {
81229       _userChangesets = void 0;
81230       _userDetails = void 0;
81231       oauth.logout();
81232       dispatch10.call("change");
81233       return this;
81234     },
81235     authenticated: function() {
81236       return oauth.authenticated();
81237     },
81238     authenticate: function(callback) {
81239       var that = this;
81240       var cid = _connectionID;
81241       _userChangesets = void 0;
81242       _userDetails = void 0;
81243       function done(err, res) {
81244         if (err) {
81245           if (callback)
81246             callback(err);
81247           return;
81248         }
81249         if (that.getConnectionId() !== cid) {
81250           if (callback)
81251             callback({ message: "Connection Switched", status: -1 });
81252           return;
81253         }
81254         _rateLimitError = void 0;
81255         dispatch10.call("change");
81256         if (callback)
81257           callback(err, res);
81258         that.userChangesets(function() {
81259         });
81260       }
81261       oauth.authenticate(done);
81262     },
81263     imageryBlocklists: function() {
81264       return _imageryBlocklists;
81265     },
81266     tileZoom: function(val) {
81267       if (!arguments.length)
81268         return _tileZoom4;
81269       _tileZoom4 = val;
81270       return this;
81271     },
81272     // get all cached notes covering the viewport
81273     notes: function(projection2) {
81274       var viewport = projection2.clipExtent();
81275       var min3 = [viewport[0][0], viewport[1][1]];
81276       var max3 = [viewport[1][0], viewport[0][1]];
81277       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81278       return _noteCache.rtree.search(bbox2).map(function(d2) {
81279         return d2.data;
81280       });
81281     },
81282     // get a single note from the cache
81283     getNote: function(id2) {
81284       return _noteCache.note[id2];
81285     },
81286     // remove a single note from the cache
81287     removeNote: function(note) {
81288       if (!(note instanceof osmNote) || !note.id)
81289         return;
81290       delete _noteCache.note[note.id];
81291       updateRtree4(encodeNoteRtree(note), false);
81292     },
81293     // replace a single note in the cache
81294     replaceNote: function(note) {
81295       if (!(note instanceof osmNote) || !note.id)
81296         return;
81297       _noteCache.note[note.id] = note;
81298       updateRtree4(encodeNoteRtree(note), true);
81299       return note;
81300     },
81301     // Get an array of note IDs closed during this session.
81302     // Used to populate `closed:note` changeset tag
81303     getClosedIDs: function() {
81304       return Object.keys(_noteCache.closed).sort();
81305     }
81306   };
81307
81308   // modules/services/osm_wikibase.js
81309   var apibase3 = "https://wiki.openstreetmap.org/w/api.php";
81310   var _inflight2 = {};
81311   var _wikibaseCache = {};
81312   var _localeIDs = { en: false };
81313   var debouncedRequest = debounce_default(request, 500, { leading: false });
81314   function request(url, callback) {
81315     if (_inflight2[url])
81316       return;
81317     var controller = new AbortController();
81318     _inflight2[url] = controller;
81319     json_default(url, { signal: controller.signal }).then(function(result) {
81320       delete _inflight2[url];
81321       if (callback)
81322         callback(null, result);
81323     }).catch(function(err) {
81324       delete _inflight2[url];
81325       if (err.name === "AbortError")
81326         return;
81327       if (callback)
81328         callback(err.message);
81329     });
81330   }
81331   var osm_wikibase_default = {
81332     init: function() {
81333       _inflight2 = {};
81334       _wikibaseCache = {};
81335       _localeIDs = {};
81336     },
81337     reset: function() {
81338       Object.values(_inflight2).forEach(function(controller) {
81339         controller.abort();
81340       });
81341       _inflight2 = {};
81342     },
81343     /**
81344      * Get the best value for the property, or undefined if not found
81345      * @param entity object from wikibase
81346      * @param property string e.g. 'P4' for image
81347      * @param langCode string e.g. 'fr' for French
81348      */
81349     claimToValue: function(entity, property, langCode) {
81350       if (!entity.claims[property])
81351         return void 0;
81352       var locale2 = _localeIDs[langCode];
81353       var preferredPick, localePick;
81354       entity.claims[property].forEach(function(stmt) {
81355         if (!preferredPick && stmt.rank === "preferred") {
81356           preferredPick = stmt;
81357         }
81358         if (locale2 && stmt.qualifiers && stmt.qualifiers.P26 && stmt.qualifiers.P26[0].datavalue.value.id === locale2) {
81359           localePick = stmt;
81360         }
81361       });
81362       var result = localePick || preferredPick;
81363       if (result) {
81364         var datavalue = result.mainsnak.datavalue;
81365         return datavalue.type === "wikibase-entityid" ? datavalue.value.id : datavalue.value;
81366       } else {
81367         return void 0;
81368       }
81369     },
81370     /**
81371      * Convert monolingual property into a key-value object (language -> value)
81372      * @param entity object from wikibase
81373      * @param property string e.g. 'P31' for monolingual wiki page title
81374      */
81375     monolingualClaimToValueObj: function(entity, property) {
81376       if (!entity || !entity.claims[property])
81377         return void 0;
81378       return entity.claims[property].reduce(function(acc, obj) {
81379         var value = obj.mainsnak.datavalue.value;
81380         acc[value.language] = value.text;
81381         return acc;
81382       }, {});
81383     },
81384     toSitelink: function(key, value) {
81385       var result = value ? "Tag:" + key + "=" + value : "Key:" + key;
81386       return result.replace(/_/g, " ").trim();
81387     },
81388     //
81389     // Pass params object of the form:
81390     // {
81391     //   key: 'string',
81392     //   value: 'string',
81393     //   langCode: 'string'
81394     // }
81395     //
81396     getEntity: function(params, callback) {
81397       var doRequest = params.debounce ? debouncedRequest : request;
81398       var that = this;
81399       var titles = [];
81400       var result = {};
81401       var rtypeSitelink = params.key === "type" && params.value ? ("Relation:" + params.value).replace(/_/g, " ").trim() : false;
81402       var keySitelink = params.key ? this.toSitelink(params.key) : false;
81403       var tagSitelink = params.key && params.value ? this.toSitelink(params.key, params.value) : false;
81404       var localeSitelink;
81405       if (params.langCodes) {
81406         params.langCodes.forEach(function(langCode) {
81407           if (_localeIDs[langCode] === void 0) {
81408             localeSitelink = ("Locale:" + langCode).replace(/_/g, " ").trim();
81409             titles.push(localeSitelink);
81410           }
81411         });
81412       }
81413       if (rtypeSitelink) {
81414         if (_wikibaseCache[rtypeSitelink]) {
81415           result.rtype = _wikibaseCache[rtypeSitelink];
81416         } else {
81417           titles.push(rtypeSitelink);
81418         }
81419       }
81420       if (keySitelink) {
81421         if (_wikibaseCache[keySitelink]) {
81422           result.key = _wikibaseCache[keySitelink];
81423         } else {
81424           titles.push(keySitelink);
81425         }
81426       }
81427       if (tagSitelink) {
81428         if (_wikibaseCache[tagSitelink]) {
81429           result.tag = _wikibaseCache[tagSitelink];
81430         } else {
81431           titles.push(tagSitelink);
81432         }
81433       }
81434       if (!titles.length) {
81435         return callback(null, result);
81436       }
81437       var obj = {
81438         action: "wbgetentities",
81439         sites: "wiki",
81440         titles: titles.join("|"),
81441         languages: params.langCodes.join("|"),
81442         languagefallback: 1,
81443         origin: "*",
81444         format: "json"
81445         // There is an MW Wikibase API bug https://phabricator.wikimedia.org/T212069
81446         // We shouldn't use v1 until it gets fixed, but should switch to it afterwards
81447         // formatversion: 2,
81448       };
81449       var url = apibase3 + "?" + utilQsString(obj);
81450       doRequest(url, function(err, d2) {
81451         if (err) {
81452           callback(err);
81453         } else if (!d2.success || d2.error) {
81454           callback(d2.error.messages.map(function(v2) {
81455             return v2.html["*"];
81456           }).join("<br>"));
81457         } else {
81458           var localeID = false;
81459           Object.values(d2.entities).forEach(function(res) {
81460             if (res.missing !== "") {
81461               var title = res.sitelinks.wiki.title;
81462               if (title === rtypeSitelink) {
81463                 _wikibaseCache[rtypeSitelink] = res;
81464                 result.rtype = res;
81465               } else if (title === keySitelink) {
81466                 _wikibaseCache[keySitelink] = res;
81467                 result.key = res;
81468               } else if (title === tagSitelink) {
81469                 _wikibaseCache[tagSitelink] = res;
81470                 result.tag = res;
81471               } else if (title === localeSitelink) {
81472                 localeID = res.id;
81473               } else {
81474                 console.log("Unexpected title " + title);
81475               }
81476             }
81477           });
81478           if (localeSitelink) {
81479             that.addLocale(params.langCodes[0], localeID);
81480           }
81481           callback(null, result);
81482         }
81483       });
81484     },
81485     //
81486     // Pass params object of the form:
81487     // {
81488     //   key: 'string',     // required
81489     //   value: 'string'    // optional
81490     // }
81491     //
81492     // Get an result object used to display tag documentation
81493     // {
81494     //   title:        'string',
81495     //   description:  'string',
81496     //   editURL:      'string',
81497     //   imageURL:     'string',
81498     //   wiki:         { title: 'string', text: 'string', url: 'string' }
81499     // }
81500     //
81501     getDocs: function(params, callback) {
81502       var that = this;
81503       var langCodes = _mainLocalizer.localeCodes().map(function(code) {
81504         return code.toLowerCase();
81505       });
81506       params.langCodes = langCodes;
81507       this.getEntity(params, function(err, data) {
81508         if (err) {
81509           callback(err);
81510           return;
81511         }
81512         var entity = data.rtype || data.tag || data.key;
81513         if (!entity) {
81514           callback("No entity");
81515           return;
81516         }
81517         var i3;
81518         var description;
81519         for (i3 in langCodes) {
81520           let code2 = langCodes[i3];
81521           if (entity.descriptions[code2] && entity.descriptions[code2].language === code2) {
81522             description = entity.descriptions[code2];
81523             break;
81524           }
81525         }
81526         if (!description && Object.values(entity.descriptions).length)
81527           description = Object.values(entity.descriptions)[0];
81528         var result = {
81529           title: entity.title,
81530           description: description ? description.value : "",
81531           descriptionLocaleCode: description ? description.language : "",
81532           editURL: "https://wiki.openstreetmap.org/wiki/" + entity.title
81533         };
81534         if (entity.claims) {
81535           var imageroot;
81536           var image = that.claimToValue(entity, "P4", langCodes[0]);
81537           if (image) {
81538             imageroot = "https://commons.wikimedia.org/w/index.php";
81539           } else {
81540             image = that.claimToValue(entity, "P28", langCodes[0]);
81541             if (image) {
81542               imageroot = "https://wiki.openstreetmap.org/w/index.php";
81543             }
81544           }
81545           if (imageroot && image) {
81546             result.imageURL = imageroot + "?" + utilQsString({
81547               title: "Special:Redirect/file/" + image,
81548               width: 400
81549             });
81550           }
81551         }
81552         var rtypeWiki = that.monolingualClaimToValueObj(data.rtype, "P31");
81553         var tagWiki = that.monolingualClaimToValueObj(data.tag, "P31");
81554         var keyWiki = that.monolingualClaimToValueObj(data.key, "P31");
81555         var wikis = [rtypeWiki, tagWiki, keyWiki];
81556         for (i3 in wikis) {
81557           var wiki = wikis[i3];
81558           for (var j2 in langCodes) {
81559             var code = langCodes[j2];
81560             var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference";
81561             var info = getWikiInfo(wiki, code, referenceId);
81562             if (info) {
81563               result.wiki = info;
81564               break;
81565             }
81566           }
81567           if (result.wiki)
81568             break;
81569         }
81570         callback(null, result);
81571         function getWikiInfo(wiki2, langCode, tKey) {
81572           if (wiki2 && wiki2[langCode]) {
81573             return {
81574               title: wiki2[langCode],
81575               text: tKey,
81576               url: "https://wiki.openstreetmap.org/wiki/" + wiki2[langCode]
81577             };
81578           }
81579         }
81580       });
81581     },
81582     addLocale: function(langCode, qid) {
81583       _localeIDs[langCode] = qid;
81584     },
81585     apibase: function(val) {
81586       if (!arguments.length)
81587         return apibase3;
81588       apibase3 = val;
81589       return this;
81590     }
81591   };
81592
81593   // modules/services/streetside.js
81594   var import_rbush11 = __toESM(require_rbush_min());
81595   var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}";
81596   var maxResults2 = 500;
81597   var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
81598   var pannellumViewerCSS2 = "pannellum/pannellum.css";
81599   var pannellumViewerJS2 = "pannellum/pannellum.js";
81600   var tileZoom3 = 16.5;
81601   var tiler7 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true);
81602   var dispatch11 = dispatch_default("loadedImages", "viewerChanged");
81603   var minHfov = 10;
81604   var maxHfov = 90;
81605   var defaultHfov = 45;
81606   var _hires = false;
81607   var _resolution = 512;
81608   var _currScene = 0;
81609   var _ssCache;
81610   var _pannellumViewer2;
81611   var _sceneOptions = {
81612     showFullscreenCtrl: false,
81613     autoLoad: true,
81614     compass: true,
81615     yaw: 0,
81616     minHfov,
81617     maxHfov,
81618     hfov: defaultHfov,
81619     type: "cubemap",
81620     cubeMap: []
81621   };
81622   var _loadViewerPromise4;
81623   function abortRequest6(i3) {
81624     i3.abort();
81625   }
81626   function localeTimestamp2(s2) {
81627     if (!s2)
81628       return null;
81629     const options2 = { day: "numeric", month: "short", year: "numeric" };
81630     const d2 = new Date(s2);
81631     if (isNaN(d2.getTime()))
81632       return null;
81633     return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
81634   }
81635   function loadTiles3(which, url, projection2, margin) {
81636     const tiles = tiler7.margin(margin).getTiles(projection2);
81637     const cache = _ssCache[which];
81638     Object.keys(cache.inflight).forEach((k2) => {
81639       const wanted = tiles.find((tile) => k2.indexOf(tile.id + ",") === 0);
81640       if (!wanted) {
81641         abortRequest6(cache.inflight[k2]);
81642         delete cache.inflight[k2];
81643       }
81644     });
81645     tiles.forEach((tile) => loadNextTilePage2(which, url, tile));
81646   }
81647   function loadNextTilePage2(which, url, tile) {
81648     const cache = _ssCache[which];
81649     const nextPage = cache.nextPage[tile.id] || 0;
81650     const id2 = tile.id + "," + String(nextPage);
81651     if (cache.loaded[id2] || cache.inflight[id2])
81652       return;
81653     cache.inflight[id2] = getBubbles(url, tile, (response) => {
81654       cache.loaded[id2] = true;
81655       delete cache.inflight[id2];
81656       if (!response)
81657         return;
81658       if (response.resourceSets[0].resources.length === maxResults2) {
81659         const split = tile.extent.split();
81660         loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] });
81661         loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] });
81662         loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] });
81663         loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] });
81664       }
81665       const features = response.resourceSets[0].resources.map((bubble) => {
81666         const bubbleId = bubble.imageUrl;
81667         if (cache.points[bubbleId])
81668           return null;
81669         const loc = [bubble.lon, bubble.lat];
81670         const d2 = {
81671           loc,
81672           key: bubbleId,
81673           imageUrl: bubble.imageUrl.replace(
81674             "{subdomain}",
81675             bubble.imageUrlSubdomains[0]
81676           ),
81677           ca: bubble.he,
81678           captured_at: bubble.vintageEnd,
81679           captured_by: "microsoft",
81680           pano: true,
81681           sequenceKey: null
81682         };
81683         cache.points[bubbleId] = d2;
81684         return {
81685           minX: loc[0],
81686           minY: loc[1],
81687           maxX: loc[0],
81688           maxY: loc[1],
81689           data: d2
81690         };
81691       }).filter(Boolean);
81692       cache.rtree.load(features);
81693       if (which === "bubbles") {
81694         dispatch11.call("loadedImages");
81695       }
81696     });
81697   }
81698   function getBubbles(url, tile, callback) {
81699     let rect = tile.extent.rectangle();
81700     let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2);
81701     const controller = new AbortController();
81702     fetch(urlForRequest, { signal: controller.signal }).then(function(response) {
81703       if (!response.ok) {
81704         throw new Error(response.status + " " + response.statusText);
81705       }
81706       return response.json();
81707     }).then(function(result) {
81708       if (!result) {
81709         callback(null);
81710       }
81711       return callback(result || []);
81712     }).catch(function(err) {
81713       if (err.name === "AbortError") {
81714       } else {
81715         throw new Error(err);
81716       }
81717     });
81718     return controller;
81719   }
81720   function partitionViewport4(projection2) {
81721     let z2 = geoScaleToZoom(projection2.scale());
81722     let z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81723     let tiler9 = utilTiler().zoomExtent([z22, z22]);
81724     return tiler9.getTiles(projection2).map((tile) => tile.extent);
81725   }
81726   function searchLimited4(limit, projection2, rtree) {
81727     limit = limit || 5;
81728     return partitionViewport4(projection2).reduce((result, extent) => {
81729       let found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
81730       return found.length ? result.concat(found) : result;
81731     }, []);
81732   }
81733   function loadImage2(imgInfo) {
81734     return new Promise((resolve) => {
81735       let img = new Image();
81736       img.onload = () => {
81737         let canvas = document.getElementById("ideditor-canvas" + imgInfo.face);
81738         let ctx = canvas.getContext("2d");
81739         ctx.drawImage(img, imgInfo.x, imgInfo.y);
81740         resolve({ imgInfo, status: "ok" });
81741       };
81742       img.onerror = () => {
81743         resolve({ data: imgInfo, status: "error" });
81744       };
81745       img.setAttribute("crossorigin", "");
81746       img.src = imgInfo.url;
81747     });
81748   }
81749   function loadCanvas(imageGroup) {
81750     return Promise.all(imageGroup.map(loadImage2)).then((data) => {
81751       let canvas = document.getElementById("ideditor-canvas" + data[0].imgInfo.face);
81752       const which = { "01": 0, "02": 1, "03": 2, "10": 3, "11": 4, "12": 5 };
81753       let face = data[0].imgInfo.face;
81754       _sceneOptions.cubeMap[which[face]] = canvas.toDataURL("image/jpeg", 1);
81755       return { status: "loadCanvas for face " + data[0].imgInfo.face + "ok" };
81756     });
81757   }
81758   function loadFaces(faceGroup) {
81759     return Promise.all(faceGroup.map(loadCanvas)).then(() => {
81760       return { status: "loadFaces done" };
81761     });
81762   }
81763   function setupCanvas(selection2, reset) {
81764     if (reset) {
81765       selection2.selectAll("#ideditor-stitcher-canvases").remove();
81766     }
81767     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);
81768   }
81769   function qkToXY(qk) {
81770     let x2 = 0;
81771     let y2 = 0;
81772     let scale = 256;
81773     for (let i3 = qk.length; i3 > 0; i3--) {
81774       const key = qk[i3 - 1];
81775       x2 += +(key === "1" || key === "3") * scale;
81776       y2 += +(key === "2" || key === "3") * scale;
81777       scale *= 2;
81778     }
81779     return [x2, y2];
81780   }
81781   function getQuadKeys() {
81782     let dim = _resolution / 256;
81783     let quadKeys;
81784     if (dim === 16) {
81785       quadKeys = [
81786         "0000",
81787         "0001",
81788         "0010",
81789         "0011",
81790         "0100",
81791         "0101",
81792         "0110",
81793         "0111",
81794         "1000",
81795         "1001",
81796         "1010",
81797         "1011",
81798         "1100",
81799         "1101",
81800         "1110",
81801         "1111",
81802         "0002",
81803         "0003",
81804         "0012",
81805         "0013",
81806         "0102",
81807         "0103",
81808         "0112",
81809         "0113",
81810         "1002",
81811         "1003",
81812         "1012",
81813         "1013",
81814         "1102",
81815         "1103",
81816         "1112",
81817         "1113",
81818         "0020",
81819         "0021",
81820         "0030",
81821         "0031",
81822         "0120",
81823         "0121",
81824         "0130",
81825         "0131",
81826         "1020",
81827         "1021",
81828         "1030",
81829         "1031",
81830         "1120",
81831         "1121",
81832         "1130",
81833         "1131",
81834         "0022",
81835         "0023",
81836         "0032",
81837         "0033",
81838         "0122",
81839         "0123",
81840         "0132",
81841         "0133",
81842         "1022",
81843         "1023",
81844         "1032",
81845         "1033",
81846         "1122",
81847         "1123",
81848         "1132",
81849         "1133",
81850         "0200",
81851         "0201",
81852         "0210",
81853         "0211",
81854         "0300",
81855         "0301",
81856         "0310",
81857         "0311",
81858         "1200",
81859         "1201",
81860         "1210",
81861         "1211",
81862         "1300",
81863         "1301",
81864         "1310",
81865         "1311",
81866         "0202",
81867         "0203",
81868         "0212",
81869         "0213",
81870         "0302",
81871         "0303",
81872         "0312",
81873         "0313",
81874         "1202",
81875         "1203",
81876         "1212",
81877         "1213",
81878         "1302",
81879         "1303",
81880         "1312",
81881         "1313",
81882         "0220",
81883         "0221",
81884         "0230",
81885         "0231",
81886         "0320",
81887         "0321",
81888         "0330",
81889         "0331",
81890         "1220",
81891         "1221",
81892         "1230",
81893         "1231",
81894         "1320",
81895         "1321",
81896         "1330",
81897         "1331",
81898         "0222",
81899         "0223",
81900         "0232",
81901         "0233",
81902         "0322",
81903         "0323",
81904         "0332",
81905         "0333",
81906         "1222",
81907         "1223",
81908         "1232",
81909         "1233",
81910         "1322",
81911         "1323",
81912         "1332",
81913         "1333",
81914         "2000",
81915         "2001",
81916         "2010",
81917         "2011",
81918         "2100",
81919         "2101",
81920         "2110",
81921         "2111",
81922         "3000",
81923         "3001",
81924         "3010",
81925         "3011",
81926         "3100",
81927         "3101",
81928         "3110",
81929         "3111",
81930         "2002",
81931         "2003",
81932         "2012",
81933         "2013",
81934         "2102",
81935         "2103",
81936         "2112",
81937         "2113",
81938         "3002",
81939         "3003",
81940         "3012",
81941         "3013",
81942         "3102",
81943         "3103",
81944         "3112",
81945         "3113",
81946         "2020",
81947         "2021",
81948         "2030",
81949         "2031",
81950         "2120",
81951         "2121",
81952         "2130",
81953         "2131",
81954         "3020",
81955         "3021",
81956         "3030",
81957         "3031",
81958         "3120",
81959         "3121",
81960         "3130",
81961         "3131",
81962         "2022",
81963         "2023",
81964         "2032",
81965         "2033",
81966         "2122",
81967         "2123",
81968         "2132",
81969         "2133",
81970         "3022",
81971         "3023",
81972         "3032",
81973         "3033",
81974         "3122",
81975         "3123",
81976         "3132",
81977         "3133",
81978         "2200",
81979         "2201",
81980         "2210",
81981         "2211",
81982         "2300",
81983         "2301",
81984         "2310",
81985         "2311",
81986         "3200",
81987         "3201",
81988         "3210",
81989         "3211",
81990         "3300",
81991         "3301",
81992         "3310",
81993         "3311",
81994         "2202",
81995         "2203",
81996         "2212",
81997         "2213",
81998         "2302",
81999         "2303",
82000         "2312",
82001         "2313",
82002         "3202",
82003         "3203",
82004         "3212",
82005         "3213",
82006         "3302",
82007         "3303",
82008         "3312",
82009         "3313",
82010         "2220",
82011         "2221",
82012         "2230",
82013         "2231",
82014         "2320",
82015         "2321",
82016         "2330",
82017         "2331",
82018         "3220",
82019         "3221",
82020         "3230",
82021         "3231",
82022         "3320",
82023         "3321",
82024         "3330",
82025         "3331",
82026         "2222",
82027         "2223",
82028         "2232",
82029         "2233",
82030         "2322",
82031         "2323",
82032         "2332",
82033         "2333",
82034         "3222",
82035         "3223",
82036         "3232",
82037         "3233",
82038         "3322",
82039         "3323",
82040         "3332",
82041         "3333"
82042       ];
82043     } else if (dim === 8) {
82044       quadKeys = [
82045         "000",
82046         "001",
82047         "010",
82048         "011",
82049         "100",
82050         "101",
82051         "110",
82052         "111",
82053         "002",
82054         "003",
82055         "012",
82056         "013",
82057         "102",
82058         "103",
82059         "112",
82060         "113",
82061         "020",
82062         "021",
82063         "030",
82064         "031",
82065         "120",
82066         "121",
82067         "130",
82068         "131",
82069         "022",
82070         "023",
82071         "032",
82072         "033",
82073         "122",
82074         "123",
82075         "132",
82076         "133",
82077         "200",
82078         "201",
82079         "210",
82080         "211",
82081         "300",
82082         "301",
82083         "310",
82084         "311",
82085         "202",
82086         "203",
82087         "212",
82088         "213",
82089         "302",
82090         "303",
82091         "312",
82092         "313",
82093         "220",
82094         "221",
82095         "230",
82096         "231",
82097         "320",
82098         "321",
82099         "330",
82100         "331",
82101         "222",
82102         "223",
82103         "232",
82104         "233",
82105         "322",
82106         "323",
82107         "332",
82108         "333"
82109       ];
82110     } else if (dim === 4) {
82111       quadKeys = [
82112         "00",
82113         "01",
82114         "10",
82115         "11",
82116         "02",
82117         "03",
82118         "12",
82119         "13",
82120         "20",
82121         "21",
82122         "30",
82123         "31",
82124         "22",
82125         "23",
82126         "32",
82127         "33"
82128       ];
82129     } else {
82130       quadKeys = [
82131         "0",
82132         "1",
82133         "2",
82134         "3"
82135       ];
82136     }
82137     return quadKeys;
82138   }
82139   var streetside_default = {
82140     /**
82141      * init() initialize streetside.
82142      */
82143     init: function() {
82144       if (!_ssCache) {
82145         this.reset();
82146       }
82147       this.event = utilRebind(this, dispatch11, "on");
82148     },
82149     /**
82150      * reset() reset the cache.
82151      */
82152     reset: function() {
82153       if (_ssCache) {
82154         Object.values(_ssCache.bubbles.inflight).forEach(abortRequest6);
82155       }
82156       _ssCache = {
82157         bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush11.default(), points: {} },
82158         sequences: {}
82159       };
82160     },
82161     /**
82162      * bubbles()
82163      */
82164     bubbles: function(projection2) {
82165       const limit = 5;
82166       return searchLimited4(limit, projection2, _ssCache.bubbles.rtree);
82167     },
82168     cachedImage: function(imageKey) {
82169       return _ssCache.bubbles.points[imageKey];
82170     },
82171     sequences: function(projection2) {
82172       const viewport = projection2.clipExtent();
82173       const min3 = [viewport[0][0], viewport[1][1]];
82174       const max3 = [viewport[1][0], viewport[0][1]];
82175       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
82176       let seen = {};
82177       let results = [];
82178       _ssCache.bubbles.rtree.search(bbox2).forEach((d2) => {
82179         const key = d2.data.sequenceKey;
82180         if (key && !seen[key]) {
82181           seen[key] = true;
82182           results.push(_ssCache.sequences[key].geojson);
82183         }
82184       });
82185       return results;
82186     },
82187     /**
82188      * loadBubbles()
82189      */
82190     loadBubbles: function(projection2, margin) {
82191       if (margin === void 0)
82192         margin = 2;
82193       loadTiles3("bubbles", streetsideApi, projection2, margin);
82194     },
82195     viewer: function() {
82196       return _pannellumViewer2;
82197     },
82198     initViewer: function() {
82199       if (!window.pannellum)
82200         return;
82201       if (_pannellumViewer2)
82202         return;
82203       _currScene += 1;
82204       const sceneID = _currScene.toString();
82205       const options2 = {
82206         "default": { firstScene: sceneID },
82207         scenes: {}
82208       };
82209       options2.scenes[sceneID] = _sceneOptions;
82210       _pannellumViewer2 = window.pannellum.viewer("ideditor-viewer-streetside", options2);
82211     },
82212     ensureViewerLoaded: function(context) {
82213       if (_loadViewerPromise4)
82214         return _loadViewerPromise4;
82215       let wrap2 = context.container().select(".photoviewer").selectAll(".ms-wrapper").data([0]);
82216       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper ms-wrapper").classed("hide", true);
82217       let that = this;
82218       let pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
82219       wrapEnter.append("div").attr("id", "ideditor-viewer-streetside").on(pointerPrefix + "down.streetside", () => {
82220         select_default2(window).on(pointerPrefix + "move.streetside", () => {
82221           dispatch11.call("viewerChanged");
82222         }, true);
82223       }).on(pointerPrefix + "up.streetside pointercancel.streetside", () => {
82224         select_default2(window).on(pointerPrefix + "move.streetside", null);
82225         let t2 = timer((elapsed) => {
82226           dispatch11.call("viewerChanged");
82227           if (elapsed > 2e3) {
82228             t2.stop();
82229           }
82230         });
82231       }).append("div").attr("class", "photo-attribution fillD");
82232       let controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
82233       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
82234       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
82235       wrap2 = wrap2.merge(wrapEnter).call(setupCanvas, true);
82236       context.ui().photoviewer.on("resize.streetside", () => {
82237         if (_pannellumViewer2) {
82238           _pannellumViewer2.resize();
82239         }
82240       });
82241       _loadViewerPromise4 = new Promise((resolve, reject) => {
82242         let loadedCount = 0;
82243         function loaded() {
82244           loadedCount += 1;
82245           if (loadedCount === 2)
82246             resolve();
82247         }
82248         const head = select_default2("head");
82249         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() {
82250           reject();
82251         });
82252         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() {
82253           reject();
82254         });
82255       }).catch(function() {
82256         _loadViewerPromise4 = null;
82257       });
82258       return _loadViewerPromise4;
82259       function step(stepBy) {
82260         return () => {
82261           let viewer = context.container().select(".photoviewer");
82262           let selected = viewer.empty() ? void 0 : viewer.datum();
82263           if (!selected)
82264             return;
82265           let nextID = stepBy === 1 ? selected.ne : selected.pr;
82266           let yaw = _pannellumViewer2.getYaw();
82267           let ca = selected.ca + yaw;
82268           let origin = selected.loc;
82269           const meters = 35;
82270           let p1 = [
82271             origin[0] + geoMetersToLon(meters / 5, origin[1]),
82272             origin[1]
82273           ];
82274           let p2 = [
82275             origin[0] + geoMetersToLon(meters / 2, origin[1]),
82276             origin[1] + geoMetersToLat(meters)
82277           ];
82278           let p3 = [
82279             origin[0] - geoMetersToLon(meters / 2, origin[1]),
82280             origin[1] + geoMetersToLat(meters)
82281           ];
82282           let p4 = [
82283             origin[0] - geoMetersToLon(meters / 5, origin[1]),
82284             origin[1]
82285           ];
82286           let poly = [p1, p2, p3, p4, p1];
82287           let angle2 = (stepBy === 1 ? ca : ca + 180) * (Math.PI / 180);
82288           poly = geoRotate(poly, -angle2, origin);
82289           let extent = poly.reduce((extent2, point2) => {
82290             return extent2.extend(geoExtent(point2));
82291           }, geoExtent());
82292           let minDist = Infinity;
82293           _ssCache.bubbles.rtree.search(extent.bbox()).forEach((d2) => {
82294             if (d2.data.key === selected.key)
82295               return;
82296             if (!geoPointInPolygon(d2.data.loc, poly))
82297               return;
82298             let dist = geoVecLength(d2.data.loc, selected.loc);
82299             let theta = selected.ca - d2.data.ca;
82300             let minTheta = Math.min(Math.abs(theta), 360 - Math.abs(theta));
82301             if (minTheta > 20) {
82302               dist += 5;
82303             }
82304             if (dist < minDist) {
82305               nextID = d2.data.key;
82306               minDist = dist;
82307             }
82308           });
82309           let nextBubble = nextID && that.cachedImage(nextID);
82310           if (!nextBubble)
82311             return;
82312           context.map().centerEase(nextBubble.loc);
82313           that.selectImage(context, nextBubble.key).yaw(yaw).showViewer(context);
82314         };
82315       }
82316     },
82317     yaw: function(yaw) {
82318       if (typeof yaw !== "number")
82319         return yaw;
82320       _sceneOptions.yaw = yaw;
82321       return this;
82322     },
82323     /**
82324      * showViewer()
82325      */
82326     showViewer: function(context) {
82327       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
82328       let isHidden = wrap2.selectAll(".photo-wrapper.ms-wrapper.hide").size();
82329       if (isHidden) {
82330         wrap2.selectAll(".photo-wrapper:not(.ms-wrapper)").classed("hide", true);
82331         wrap2.selectAll(".photo-wrapper.ms-wrapper").classed("hide", false);
82332       }
82333       return this;
82334     },
82335     /**
82336      * hideViewer()
82337      */
82338     hideViewer: function(context) {
82339       let viewer = context.container().select(".photoviewer");
82340       if (!viewer.empty())
82341         viewer.datum(null);
82342       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
82343       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
82344       this.updateUrlImage(null);
82345       return this.setStyles(context, null, true);
82346     },
82347     /**
82348      * selectImage().
82349      */
82350     selectImage: function(context, key) {
82351       let that = this;
82352       let d2 = this.cachedImage(key);
82353       let viewer = context.container().select(".photoviewer");
82354       if (!viewer.empty())
82355         viewer.datum(d2);
82356       this.setStyles(context, null, true);
82357       let wrap2 = context.container().select(".photoviewer .ms-wrapper");
82358       let attribution = wrap2.selectAll(".photo-attribution").html("");
82359       wrap2.selectAll(".pnlm-load-box").style("display", "block");
82360       if (!d2)
82361         return this;
82362       this.updateUrlImage(key);
82363       _sceneOptions.northOffset = d2.ca;
82364       let line1 = attribution.append("div").attr("class", "attribution-row");
82365       const hiresDomId = utilUniqueDomId("streetside-hires");
82366       let label = line1.append("label").attr("for", hiresDomId).attr("class", "streetside-hires");
82367       label.append("input").attr("type", "checkbox").attr("id", hiresDomId).property("checked", _hires).on("click", (d3_event) => {
82368         d3_event.stopPropagation();
82369         _hires = !_hires;
82370         _resolution = _hires ? 1024 : 512;
82371         wrap2.call(setupCanvas, true);
82372         let viewstate = {
82373           yaw: _pannellumViewer2.getYaw(),
82374           pitch: _pannellumViewer2.getPitch(),
82375           hfov: _pannellumViewer2.getHfov()
82376         };
82377         _sceneOptions = Object.assign(_sceneOptions, viewstate);
82378         that.selectImage(context, d2.key).showViewer(context);
82379       });
82380       label.append("span").call(_t.append("streetside.hires"));
82381       let captureInfo = line1.append("div").attr("class", "attribution-capture-info");
82382       if (d2.captured_by) {
82383         const yyyy = (/* @__PURE__ */ new Date()).getFullYear();
82384         captureInfo.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://www.microsoft.com/en-us/maps/streetside").text("\xA9" + yyyy + " Microsoft");
82385         captureInfo.append("span").text("|");
82386       }
82387       if (d2.captured_at) {
82388         captureInfo.append("span").attr("class", "captured_at").text(localeTimestamp2(d2.captured_at));
82389       }
82390       let line2 = attribution.append("div").attr("class", "attribution-row");
82391       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"));
82392       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"));
82393       const faceKeys = ["01", "02", "03", "10", "11", "12"];
82394       let quadKeys = getQuadKeys();
82395       let faces = faceKeys.map((faceKey) => {
82396         return quadKeys.map((quadKey) => {
82397           const xy = qkToXY(quadKey);
82398           return {
82399             face: faceKey,
82400             url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey),
82401             x: xy[0],
82402             y: xy[1]
82403           };
82404         });
82405       });
82406       loadFaces(faces).then(function() {
82407         if (!_pannellumViewer2) {
82408           that.initViewer();
82409         } else {
82410           _currScene += 1;
82411           let sceneID = _currScene.toString();
82412           _pannellumViewer2.addScene(sceneID, _sceneOptions).loadScene(sceneID);
82413           if (_currScene > 2) {
82414             sceneID = (_currScene - 1).toString();
82415             _pannellumViewer2.removeScene(sceneID);
82416           }
82417         }
82418       });
82419       return this;
82420     },
82421     getSequenceKeyForBubble: function(d2) {
82422       return d2 && d2.sequenceKey;
82423     },
82424     // Updates the currently highlighted sequence and selected bubble.
82425     // Reset is only necessary when interacting with the viewport because
82426     // this implicitly changes the currently selected bubble/sequence
82427     setStyles: function(context, hovered, reset) {
82428       if (reset) {
82429         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
82430         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
82431       }
82432       let hoveredBubbleKey = hovered && hovered.key;
82433       let hoveredSequenceKey = this.getSequenceKeyForBubble(hovered);
82434       let hoveredSequence = hoveredSequenceKey && _ssCache.sequences[hoveredSequenceKey];
82435       let hoveredBubbleKeys = hoveredSequence && hoveredSequence.bubbles.map((d2) => d2.key) || [];
82436       let viewer = context.container().select(".photoviewer");
82437       let selected = viewer.empty() ? void 0 : viewer.datum();
82438       let selectedBubbleKey = selected && selected.key;
82439       let selectedSequenceKey = this.getSequenceKeyForBubble(selected);
82440       let selectedSequence = selectedSequenceKey && _ssCache.sequences[selectedSequenceKey];
82441       let selectedBubbleKeys = selectedSequence && selectedSequence.bubbles.map((d2) => d2.key) || [];
82442       let highlightedBubbleKeys = utilArrayUnion(hoveredBubbleKeys, selectedBubbleKeys);
82443       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);
82444       context.container().selectAll(".layer-streetside-images .sequence").classed("highlighted", (d2) => d2.properties.key === hoveredSequenceKey).classed("currentView", (d2) => d2.properties.key === selectedSequenceKey);
82445       context.container().selectAll(".layer-streetside-images .viewfield-group .viewfield").attr("d", viewfieldPath);
82446       function viewfieldPath() {
82447         let d2 = this.parentNode.__data__;
82448         if (d2.pano && d2.key !== selectedBubbleKey) {
82449           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
82450         } else {
82451           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
82452         }
82453       }
82454       return this;
82455     },
82456     updateUrlImage: function(imageKey) {
82457       if (!window.mocha) {
82458         var hash = utilStringQs(window.location.hash);
82459         if (imageKey) {
82460           hash.photo = "streetside/" + imageKey;
82461         } else {
82462           delete hash.photo;
82463         }
82464         window.location.replace("#" + utilQsString(hash, true));
82465       }
82466     },
82467     /**
82468      * cache().
82469      */
82470     cache: function() {
82471       return _ssCache;
82472     }
82473   };
82474
82475   // modules/services/taginfo.js
82476   var apibase4 = taginfoApiUrl;
82477   var _inflight3 = {};
82478   var _popularKeys = {};
82479   var _taginfoCache = {};
82480   var tag_sorts = {
82481     point: "count_nodes",
82482     vertex: "count_nodes",
82483     area: "count_ways",
82484     line: "count_ways"
82485   };
82486   var tag_sort_members = {
82487     point: "count_node_members",
82488     vertex: "count_node_members",
82489     area: "count_way_members",
82490     line: "count_way_members",
82491     relation: "count_relation_members"
82492   };
82493   var tag_filters = {
82494     point: "nodes",
82495     vertex: "nodes",
82496     area: "ways",
82497     line: "ways"
82498   };
82499   var tag_members_fractions = {
82500     point: "count_node_members_fraction",
82501     vertex: "count_node_members_fraction",
82502     area: "count_way_members_fraction",
82503     line: "count_way_members_fraction",
82504     relation: "count_relation_members_fraction"
82505   };
82506   function sets(params, n3, o2) {
82507     if (params.geometry && o2[params.geometry]) {
82508       params[n3] = o2[params.geometry];
82509     }
82510     return params;
82511   }
82512   function setFilter(params) {
82513     return sets(params, "filter", tag_filters);
82514   }
82515   function setSort(params) {
82516     return sets(params, "sortname", tag_sorts);
82517   }
82518   function setSortMembers(params) {
82519     return sets(params, "sortname", tag_sort_members);
82520   }
82521   function clean(params) {
82522     return utilObjectOmit(params, ["geometry", "debounce"]);
82523   }
82524   function filterKeys(type2) {
82525     var count_type = type2 ? "count_" + type2 : "count_all";
82526     return function(d2) {
82527       return Number(d2[count_type]) > 2500 || d2.in_wiki;
82528     };
82529   }
82530   function filterMultikeys(prefix) {
82531     return function(d2) {
82532       var re3 = new RegExp("^" + prefix + "(.*)$", "i");
82533       var matches = d2.key.match(re3) || [];
82534       return matches.length === 2 && matches[1].indexOf(":") === -1;
82535     };
82536   }
82537   function filterValues(allowUpperCase) {
82538     return function(d2) {
82539       if (d2.value.match(/[;,]/) !== null)
82540         return false;
82541       if (!allowUpperCase && d2.value.match(/[A-Z*]/) !== null)
82542         return false;
82543       return d2.count > 100 || d2.in_wiki;
82544     };
82545   }
82546   function filterRoles(geometry) {
82547     return function(d2) {
82548       if (d2.role === "")
82549         return false;
82550       if (d2.role.match(/[A-Z*;,]/) !== null)
82551         return false;
82552       return Number(d2[tag_members_fractions[geometry]]) > 0;
82553     };
82554   }
82555   function valKey(d2) {
82556     return {
82557       value: d2.key,
82558       title: d2.key
82559     };
82560   }
82561   function valKeyDescription(d2) {
82562     var obj = {
82563       value: d2.value,
82564       title: d2.description || d2.value
82565     };
82566     return obj;
82567   }
82568   function roleKey(d2) {
82569     return {
82570       value: d2.role,
82571       title: d2.role
82572     };
82573   }
82574   function sortKeys(a2, b2) {
82575     return a2.key.indexOf(":") === -1 && b2.key.indexOf(":") !== -1 ? -1 : a2.key.indexOf(":") !== -1 && b2.key.indexOf(":") === -1 ? 1 : 0;
82576   }
82577   var debouncedRequest2 = debounce_default(request2, 300, { leading: false });
82578   function request2(url, params, exactMatch, callback, loaded) {
82579     if (_inflight3[url])
82580       return;
82581     if (checkCache(url, params, exactMatch, callback))
82582       return;
82583     var controller = new AbortController();
82584     _inflight3[url] = controller;
82585     json_default(url, { signal: controller.signal }).then(function(result) {
82586       delete _inflight3[url];
82587       if (loaded)
82588         loaded(null, result);
82589     }).catch(function(err) {
82590       delete _inflight3[url];
82591       if (err.name === "AbortError")
82592         return;
82593       if (loaded)
82594         loaded(err.message);
82595     });
82596   }
82597   function checkCache(url, params, exactMatch, callback) {
82598     var rp = params.rp || 25;
82599     var testQuery = params.query || "";
82600     var testUrl = url;
82601     do {
82602       var hit = _taginfoCache[testUrl];
82603       if (hit && (url === testUrl || hit.length < rp)) {
82604         callback(null, hit);
82605         return true;
82606       }
82607       if (exactMatch || !testQuery.length)
82608         return false;
82609       testQuery = testQuery.slice(0, -1);
82610       testUrl = url.replace(/&query=(.*?)&/, "&query=" + testQuery + "&");
82611     } while (testQuery.length >= 0);
82612     return false;
82613   }
82614   var taginfo_default = {
82615     init: function() {
82616       _inflight3 = {};
82617       _taginfoCache = {};
82618       _popularKeys = {
82619         // manually exclude some keys – #5377, #7485
82620         postal_code: true,
82621         full_name: true,
82622         loc_name: true,
82623         reg_name: true,
82624         short_name: true,
82625         sorting_name: true,
82626         artist_name: true,
82627         nat_name: true,
82628         long_name: true,
82629         via: true,
82630         "bridge:name": true
82631       };
82632       var params = {
82633         rp: 100,
82634         sortname: "values_all",
82635         sortorder: "desc",
82636         page: 1,
82637         debounce: false,
82638         lang: _mainLocalizer.languageCode()
82639       };
82640       this.keys(params, function(err, data) {
82641         if (err)
82642           return;
82643         data.forEach(function(d2) {
82644           if (d2.value === "opening_hours")
82645             return;
82646           _popularKeys[d2.value] = true;
82647         });
82648       });
82649     },
82650     reset: function() {
82651       Object.values(_inflight3).forEach(function(controller) {
82652         controller.abort();
82653       });
82654       _inflight3 = {};
82655     },
82656     keys: function(params, callback) {
82657       var doRequest = params.debounce ? debouncedRequest2 : request2;
82658       params = clean(setSort(params));
82659       params = Object.assign({
82660         rp: 10,
82661         sortname: "count_all",
82662         sortorder: "desc",
82663         page: 1,
82664         lang: _mainLocalizer.languageCode()
82665       }, params);
82666       var url = apibase4 + "keys/all?" + utilQsString(params);
82667       doRequest(url, params, false, callback, function(err, d2) {
82668         if (err) {
82669           callback(err);
82670         } else {
82671           var f2 = filterKeys(params.filter);
82672           var result = d2.data.filter(f2).sort(sortKeys).map(valKey);
82673           _taginfoCache[url] = result;
82674           callback(null, result);
82675         }
82676       });
82677     },
82678     multikeys: function(params, callback) {
82679       var doRequest = params.debounce ? debouncedRequest2 : request2;
82680       params = clean(setSort(params));
82681       params = Object.assign({
82682         rp: 25,
82683         sortname: "count_all",
82684         sortorder: "desc",
82685         page: 1,
82686         lang: _mainLocalizer.languageCode()
82687       }, params);
82688       var prefix = params.query;
82689       var url = apibase4 + "keys/all?" + utilQsString(params);
82690       doRequest(url, params, true, callback, function(err, d2) {
82691         if (err) {
82692           callback(err);
82693         } else {
82694           var f2 = filterMultikeys(prefix);
82695           var result = d2.data.filter(f2).map(valKey);
82696           _taginfoCache[url] = result;
82697           callback(null, result);
82698         }
82699       });
82700     },
82701     values: function(params, callback) {
82702       var key = params.key;
82703       if (key && _popularKeys[key]) {
82704         callback(null, []);
82705         return;
82706       }
82707       var doRequest = params.debounce ? debouncedRequest2 : request2;
82708       params = clean(setSort(setFilter(params)));
82709       params = Object.assign({
82710         rp: 25,
82711         sortname: "count_all",
82712         sortorder: "desc",
82713         page: 1,
82714         lang: _mainLocalizer.languageCode()
82715       }, params);
82716       var url = apibase4 + "key/values?" + utilQsString(params);
82717       doRequest(url, params, false, callback, function(err, d2) {
82718         if (err) {
82719           callback(err);
82720         } else {
82721           var allowUpperCase = allowUpperCaseTagValues.test(params.key);
82722           var f2 = filterValues(allowUpperCase);
82723           var result = d2.data.filter(f2).map(valKeyDescription);
82724           _taginfoCache[url] = result;
82725           callback(null, result);
82726         }
82727       });
82728     },
82729     roles: function(params, callback) {
82730       var doRequest = params.debounce ? debouncedRequest2 : request2;
82731       var geometry = params.geometry;
82732       params = clean(setSortMembers(params));
82733       params = Object.assign({
82734         rp: 25,
82735         sortname: "count_all_members",
82736         sortorder: "desc",
82737         page: 1,
82738         lang: _mainLocalizer.languageCode()
82739       }, params);
82740       var url = apibase4 + "relation/roles?" + utilQsString(params);
82741       doRequest(url, params, true, callback, function(err, d2) {
82742         if (err) {
82743           callback(err);
82744         } else {
82745           var f2 = filterRoles(geometry);
82746           var result = d2.data.filter(f2).map(roleKey);
82747           _taginfoCache[url] = result;
82748           callback(null, result);
82749         }
82750       });
82751     },
82752     docs: function(params, callback) {
82753       var doRequest = params.debounce ? debouncedRequest2 : request2;
82754       params = clean(setSort(params));
82755       var path = "key/wiki_pages?";
82756       if (params.value) {
82757         path = "tag/wiki_pages?";
82758       } else if (params.rtype) {
82759         path = "relation/wiki_pages?";
82760       }
82761       var url = apibase4 + path + utilQsString(params);
82762       doRequest(url, params, true, callback, function(err, d2) {
82763         if (err) {
82764           callback(err);
82765         } else {
82766           _taginfoCache[url] = d2.data;
82767           callback(null, d2.data);
82768         }
82769       });
82770     },
82771     apibase: function(_2) {
82772       if (!arguments.length)
82773         return apibase4;
82774       apibase4 = _2;
82775       return this;
82776     }
82777   };
82778
82779   // modules/services/vector_tile.js
82780   var import_fast_deep_equal11 = __toESM(require_fast_deep_equal());
82781   var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify());
82782   var import_polygon_clipping = __toESM(require_polygon_clipping_umd());
82783   var import_pbf2 = __toESM(require_pbf());
82784   var import_vector_tile2 = __toESM(require_vector_tile());
82785   var tiler8 = utilTiler().tileSize(512).margin(1);
82786   var dispatch12 = dispatch_default("loadedData");
82787   var _vtCache;
82788   function abortRequest7(controller) {
82789     controller.abort();
82790   }
82791   function vtToGeoJSON(data, tile, mergeCache) {
82792     var vectorTile = new import_vector_tile2.default.VectorTile(new import_pbf2.default(data));
82793     var layers = Object.keys(vectorTile.layers);
82794     if (!Array.isArray(layers)) {
82795       layers = [layers];
82796     }
82797     var features = [];
82798     layers.forEach(function(layerID) {
82799       var layer = vectorTile.layers[layerID];
82800       if (layer) {
82801         for (var i3 = 0; i3 < layer.length; i3++) {
82802           var feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
82803           var geometry = feature3.geometry;
82804           if (geometry.type === "Polygon") {
82805             geometry.type = "MultiPolygon";
82806             geometry.coordinates = [geometry.coordinates];
82807           }
82808           var isClipped = false;
82809           if (geometry.type === "MultiPolygon") {
82810             var featureClip = bboxClip(feature3, tile.extent.rectangle());
82811             if (!(0, import_fast_deep_equal11.default)(feature3.geometry, featureClip.geometry)) {
82812               isClipped = true;
82813             }
82814             if (!feature3.geometry.coordinates.length)
82815               continue;
82816             if (!feature3.geometry.coordinates[0].length)
82817               continue;
82818           }
82819           var featurehash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3));
82820           var propertyhash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3.properties || {}));
82821           feature3.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, "_");
82822           feature3.__featurehash__ = featurehash;
82823           feature3.__propertyhash__ = propertyhash;
82824           features.push(feature3);
82825           if (isClipped && geometry.type === "MultiPolygon") {
82826             var merged = mergeCache[propertyhash];
82827             if (merged && merged.length) {
82828               var other = merged[0];
82829               var coords = import_polygon_clipping.default.union(
82830                 feature3.geometry.coordinates,
82831                 other.geometry.coordinates
82832               );
82833               if (!coords || !coords.length) {
82834                 continue;
82835               }
82836               merged.push(feature3);
82837               for (var j2 = 0; j2 < merged.length; j2++) {
82838                 merged[j2].geometry.coordinates = coords;
82839                 merged[j2].__featurehash__ = featurehash;
82840               }
82841             } else {
82842               mergeCache[propertyhash] = [feature3];
82843             }
82844           }
82845         }
82846       }
82847     });
82848     return features;
82849   }
82850   function loadTile3(source, tile) {
82851     if (source.loaded[tile.id] || source.inflight[tile.id])
82852       return;
82853     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) {
82854       var subdomains = r2.split(",");
82855       return subdomains[(tile.xyz[0] + tile.xyz[1]) % subdomains.length];
82856     });
82857     var controller = new AbortController();
82858     source.inflight[tile.id] = controller;
82859     fetch(url, { signal: controller.signal }).then(function(response) {
82860       if (!response.ok) {
82861         throw new Error(response.status + " " + response.statusText);
82862       }
82863       source.loaded[tile.id] = [];
82864       delete source.inflight[tile.id];
82865       return response.arrayBuffer();
82866     }).then(function(data) {
82867       if (!data) {
82868         throw new Error("No Data");
82869       }
82870       var z2 = tile.xyz[2];
82871       if (!source.canMerge[z2]) {
82872         source.canMerge[z2] = {};
82873       }
82874       source.loaded[tile.id] = vtToGeoJSON(data, tile, source.canMerge[z2]);
82875       dispatch12.call("loadedData");
82876     }).catch(function() {
82877       source.loaded[tile.id] = [];
82878       delete source.inflight[tile.id];
82879     });
82880   }
82881   var vector_tile_default = {
82882     init: function() {
82883       if (!_vtCache) {
82884         this.reset();
82885       }
82886       this.event = utilRebind(this, dispatch12, "on");
82887     },
82888     reset: function() {
82889       for (var sourceID in _vtCache) {
82890         var source = _vtCache[sourceID];
82891         if (source && source.inflight) {
82892           Object.values(source.inflight).forEach(abortRequest7);
82893         }
82894       }
82895       _vtCache = {};
82896     },
82897     addSource: function(sourceID, template) {
82898       _vtCache[sourceID] = { template, inflight: {}, loaded: {}, canMerge: {} };
82899       return _vtCache[sourceID];
82900     },
82901     data: function(sourceID, projection2) {
82902       var source = _vtCache[sourceID];
82903       if (!source)
82904         return [];
82905       var tiles = tiler8.getTiles(projection2);
82906       var seen = {};
82907       var results = [];
82908       for (var i3 = 0; i3 < tiles.length; i3++) {
82909         var features = source.loaded[tiles[i3].id];
82910         if (!features || !features.length)
82911           continue;
82912         for (var j2 = 0; j2 < features.length; j2++) {
82913           var feature3 = features[j2];
82914           var hash = feature3.__featurehash__;
82915           if (seen[hash])
82916             continue;
82917           seen[hash] = true;
82918           results.push(Object.assign({}, feature3));
82919         }
82920       }
82921       return results;
82922     },
82923     loadTiles: function(sourceID, template, projection2) {
82924       var source = _vtCache[sourceID];
82925       if (!source) {
82926         source = this.addSource(sourceID, template);
82927       }
82928       var tiles = tiler8.getTiles(projection2);
82929       Object.keys(source.inflight).forEach(function(k2) {
82930         var wanted = tiles.find(function(tile) {
82931           return k2 === tile.id;
82932         });
82933         if (!wanted) {
82934           abortRequest7(source.inflight[k2]);
82935           delete source.inflight[k2];
82936         }
82937       });
82938       tiles.forEach(function(tile) {
82939         loadTile3(source, tile);
82940       });
82941     },
82942     cache: function() {
82943       return _vtCache;
82944     }
82945   };
82946
82947   // modules/services/wikidata.js
82948   var apibase5 = "https://www.wikidata.org/w/api.php?";
82949   var _wikidataCache = {};
82950   var wikidata_default = {
82951     init: function() {
82952     },
82953     reset: function() {
82954       _wikidataCache = {};
82955     },
82956     // Search for Wikidata items matching the query
82957     itemsForSearchQuery: function(query, callback, language) {
82958       if (!query) {
82959         if (callback)
82960           callback("No query", {});
82961         return;
82962       }
82963       var lang = this.languagesToQuery()[0];
82964       var url = apibase5 + utilQsString({
82965         action: "wbsearchentities",
82966         format: "json",
82967         formatversion: 2,
82968         search: query,
82969         type: "item",
82970         // the language to search
82971         language: language || lang,
82972         // the language for the label and description in the result
82973         uselang: lang,
82974         limit: 10,
82975         origin: "*"
82976       });
82977       json_default(url).then((result) => {
82978         if (result && result.error) {
82979           if (result.error.code === "badvalue" && result.error.info.includes(lang) && !language && lang.includes("-")) {
82980             this.itemsForSearchQuery(query, callback, lang.split("-")[0]);
82981             return;
82982           } else {
82983             throw new Error(result.error);
82984           }
82985         }
82986         if (callback)
82987           callback(null, result.search || {});
82988       }).catch(function(err) {
82989         if (callback)
82990           callback(err.message, {});
82991       });
82992     },
82993     // Given a Wikipedia language and article title,
82994     // return an array of corresponding Wikidata entities.
82995     itemsByTitle: function(lang, title, callback) {
82996       if (!title) {
82997         if (callback)
82998           callback("No title", {});
82999         return;
83000       }
83001       lang = lang || "en";
83002       var url = apibase5 + utilQsString({
83003         action: "wbgetentities",
83004         format: "json",
83005         formatversion: 2,
83006         sites: lang.replace(/-/g, "_") + "wiki",
83007         titles: title,
83008         languages: "en",
83009         // shrink response by filtering to one language
83010         origin: "*"
83011       });
83012       json_default(url).then(function(result) {
83013         if (result && result.error) {
83014           throw new Error(result.error);
83015         }
83016         if (callback)
83017           callback(null, result.entities || {});
83018       }).catch(function(err) {
83019         if (callback)
83020           callback(err.message, {});
83021       });
83022     },
83023     languagesToQuery: function() {
83024       return _mainLocalizer.localeCodes().map(function(code) {
83025         return code.toLowerCase();
83026       }).filter(function(code) {
83027         return code !== "en-us";
83028       });
83029     },
83030     entityByQID: function(qid, callback) {
83031       if (!qid) {
83032         callback("No qid", {});
83033         return;
83034       }
83035       if (_wikidataCache[qid]) {
83036         if (callback)
83037           callback(null, _wikidataCache[qid]);
83038         return;
83039       }
83040       var langs = this.languagesToQuery();
83041       var url = apibase5 + utilQsString({
83042         action: "wbgetentities",
83043         format: "json",
83044         formatversion: 2,
83045         ids: qid,
83046         props: "labels|descriptions|claims|sitelinks",
83047         sitefilter: langs.map(function(d2) {
83048           return d2 + "wiki";
83049         }).join("|"),
83050         languages: langs.join("|"),
83051         languagefallback: 1,
83052         origin: "*"
83053       });
83054       json_default(url).then(function(result) {
83055         if (result && result.error) {
83056           throw new Error(result.error);
83057         }
83058         if (callback)
83059           callback(null, result.entities[qid] || {});
83060       }).catch(function(err) {
83061         if (callback)
83062           callback(err.message, {});
83063       });
83064     },
83065     // Pass `params` object of the form:
83066     // {
83067     //   qid: 'string'      // brand wikidata  (e.g. 'Q37158')
83068     // }
83069     //
83070     // Get an result object used to display tag documentation
83071     // {
83072     //   title:        'string',
83073     //   description:  'string',
83074     //   editURL:      'string',
83075     //   imageURL:     'string',
83076     //   wiki:         { title: 'string', text: 'string', url: 'string' }
83077     // }
83078     //
83079     getDocs: function(params, callback) {
83080       var langs = this.languagesToQuery();
83081       this.entityByQID(params.qid, function(err, entity) {
83082         if (err || !entity) {
83083           callback(err || "No entity");
83084           return;
83085         }
83086         var i3;
83087         var description;
83088         for (i3 in langs) {
83089           let code = langs[i3];
83090           if (entity.descriptions[code] && entity.descriptions[code].language === code) {
83091             description = entity.descriptions[code];
83092             break;
83093           }
83094         }
83095         if (!description && Object.values(entity.descriptions).length)
83096           description = Object.values(entity.descriptions)[0];
83097         var result = {
83098           title: entity.id,
83099           description: description ? description.value : "",
83100           descriptionLocaleCode: description ? description.language : "",
83101           editURL: "https://www.wikidata.org/wiki/" + entity.id
83102         };
83103         if (entity.claims) {
83104           var imageroot = "https://commons.wikimedia.org/w/index.php";
83105           var props = ["P154", "P18"];
83106           var prop, image;
83107           for (i3 = 0; i3 < props.length; i3++) {
83108             prop = entity.claims[props[i3]];
83109             if (prop && Object.keys(prop).length > 0) {
83110               image = prop[Object.keys(prop)[0]].mainsnak.datavalue.value;
83111               if (image) {
83112                 result.imageURL = imageroot + "?" + utilQsString({
83113                   title: "Special:Redirect/file/" + image,
83114                   width: 400
83115                 });
83116                 break;
83117               }
83118             }
83119           }
83120         }
83121         if (entity.sitelinks) {
83122           var englishLocale = _mainLocalizer.languageCode().toLowerCase() === "en";
83123           for (i3 = 0; i3 < langs.length; i3++) {
83124             var w2 = langs[i3] + "wiki";
83125             if (entity.sitelinks[w2]) {
83126               var title = entity.sitelinks[w2].title;
83127               var tKey = "inspector.wiki_reference";
83128               if (!englishLocale && langs[i3] === "en") {
83129                 tKey = "inspector.wiki_en_reference";
83130               }
83131               result.wiki = {
83132                 title,
83133                 text: tKey,
83134                 url: "https://" + langs[i3] + ".wikipedia.org/wiki/" + title.replace(/ /g, "_")
83135               };
83136               break;
83137             }
83138           }
83139         }
83140         callback(null, result);
83141       });
83142     }
83143   };
83144
83145   // modules/services/wikipedia.js
83146   var endpoint = "https://en.wikipedia.org/w/api.php?";
83147   var wikipedia_default = {
83148     init: function() {
83149     },
83150     reset: function() {
83151     },
83152     search: function(lang, query, callback) {
83153       if (!query) {
83154         if (callback)
83155           callback("No Query", []);
83156         return;
83157       }
83158       lang = lang || "en";
83159       var url = endpoint.replace("en", lang) + utilQsString({
83160         action: "query",
83161         list: "search",
83162         srlimit: "10",
83163         srinfo: "suggestion",
83164         format: "json",
83165         origin: "*",
83166         srsearch: query
83167       });
83168       json_default(url).then(function(result) {
83169         if (result && result.error) {
83170           throw new Error(result.error);
83171         } else if (!result || !result.query || !result.query.search) {
83172           throw new Error("No Results");
83173         }
83174         if (callback) {
83175           var titles = result.query.search.map(function(d2) {
83176             return d2.title;
83177           });
83178           callback(null, titles);
83179         }
83180       }).catch(function(err) {
83181         if (callback)
83182           callback(err, []);
83183       });
83184     },
83185     suggestions: function(lang, query, callback) {
83186       if (!query) {
83187         if (callback)
83188           callback("", []);
83189         return;
83190       }
83191       lang = lang || "en";
83192       var url = endpoint.replace("en", lang) + utilQsString({
83193         action: "opensearch",
83194         namespace: 0,
83195         suggest: "",
83196         format: "json",
83197         origin: "*",
83198         search: query
83199       });
83200       json_default(url).then(function(result) {
83201         if (result && result.error) {
83202           throw new Error(result.error);
83203         } else if (!result || result.length < 2) {
83204           throw new Error("No Results");
83205         }
83206         if (callback)
83207           callback(null, result[1] || []);
83208       }).catch(function(err) {
83209         if (callback)
83210           callback(err.message, []);
83211       });
83212     },
83213     translations: function(lang, title, callback) {
83214       if (!title) {
83215         if (callback)
83216           callback("No Title");
83217         return;
83218       }
83219       var url = endpoint.replace("en", lang) + utilQsString({
83220         action: "query",
83221         prop: "langlinks",
83222         format: "json",
83223         origin: "*",
83224         lllimit: 500,
83225         titles: title
83226       });
83227       json_default(url).then(function(result) {
83228         if (result && result.error) {
83229           throw new Error(result.error);
83230         } else if (!result || !result.query || !result.query.pages) {
83231           throw new Error("No Results");
83232         }
83233         if (callback) {
83234           var list2 = result.query.pages[Object.keys(result.query.pages)[0]];
83235           var translations = {};
83236           if (list2 && list2.langlinks) {
83237             list2.langlinks.forEach(function(d2) {
83238               translations[d2.lang] = d2["*"];
83239             });
83240           }
83241           callback(null, translations);
83242         }
83243       }).catch(function(err) {
83244         if (callback)
83245           callback(err.message);
83246       });
83247     }
83248   };
83249
83250   // modules/services/mapilio.js
83251   var import_pbf3 = __toESM(require_pbf());
83252   var import_rbush12 = __toESM(require_rbush_min());
83253   var import_vector_tile3 = __toESM(require_vector_tile());
83254   var apiUrl2 = "https://end.mapilio.com";
83255   var imageBaseUrl = "https://cdn.mapilio.com/im";
83256   var baseTileUrl2 = "https://geo.mapilio.com/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=mapilio:";
83257   var pointLayer = "map_points";
83258   var lineLayer = "map_roads_line";
83259   var tileStyle = "&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";
83260   var minZoom3 = 14;
83261   var dispatch13 = dispatch_default("loadedImages", "loadedLines");
83262   var imgZoom3 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
83263   var pannellumViewerCSS3 = "pannellum/pannellum.css";
83264   var pannellumViewerJS3 = "pannellum/pannellum.js";
83265   var resolution = 1080;
83266   var _activeImage;
83267   var _cache4;
83268   var _loadViewerPromise5;
83269   var _pannellumViewer3;
83270   var _sceneOptions2 = {
83271     showFullscreenCtrl: false,
83272     autoLoad: true,
83273     yaw: 0,
83274     minHfov: 10,
83275     maxHfov: 90,
83276     hfov: 60
83277   };
83278   var _currScene2 = 0;
83279   function partitionViewport5(projection2) {
83280     const z2 = geoScaleToZoom(projection2.scale());
83281     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
83282     const tiler9 = utilTiler().zoomExtent([z22, z22]);
83283     return tiler9.getTiles(projection2).map(function(tile) {
83284       return tile.extent;
83285     });
83286   }
83287   function searchLimited5(limit, projection2, rtree) {
83288     limit = limit || 5;
83289     return partitionViewport5(projection2).reduce(function(result, extent) {
83290       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
83291         return d2.data;
83292       });
83293       return found.length ? result.concat(found) : result;
83294     }, []);
83295   }
83296   function loadTiles4(which, url, maxZoom2, projection2) {
83297     const tiler9 = utilTiler().zoomExtent([minZoom3, maxZoom2]).skipNullIsland(true);
83298     const tiles = tiler9.getTiles(projection2);
83299     tiles.forEach(function(tile) {
83300       loadTile4(which, url, tile);
83301     });
83302   }
83303   function loadTile4(which, url, tile) {
83304     const cache = _cache4.requests;
83305     const tileId = "".concat(tile.id, "-").concat(which);
83306     if (cache.loaded[tileId] || cache.inflight[tileId])
83307       return;
83308     const controller = new AbortController();
83309     cache.inflight[tileId] = controller;
83310     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
83311     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
83312       if (!response.ok) {
83313         throw new Error(response.status + " " + response.statusText);
83314       }
83315       cache.loaded[tileId] = true;
83316       delete cache.inflight[tileId];
83317       return response.arrayBuffer();
83318     }).then(function(data) {
83319       if (data.byteLength === 0) {
83320         throw new Error("No Data");
83321       }
83322       loadTileDataToCache2(data, tile, which);
83323       if (which === "images") {
83324         dispatch13.call("loadedImages");
83325       } else {
83326         dispatch13.call("loadedLines");
83327       }
83328     }).catch(function(e3) {
83329       if (e3.message === "No Data") {
83330         cache.loaded[tileId] = true;
83331       } else {
83332         console.error(e3);
83333       }
83334     });
83335   }
83336   function loadTileDataToCache2(data, tile) {
83337     const vectorTile = new import_vector_tile3.VectorTile(new import_pbf3.default(data));
83338     let features, cache, layer, i3, feature3, loc, d2;
83339     if (vectorTile.layers.hasOwnProperty(pointLayer)) {
83340       features = [];
83341       cache = _cache4.images;
83342       layer = vectorTile.layers[pointLayer];
83343       for (i3 = 0; i3 < layer.length; i3++) {
83344         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83345         loc = feature3.geometry.coordinates;
83346         let resolutionArr = feature3.properties.resolution.split("x");
83347         let sourceWidth = Math.max(resolutionArr[0], resolutionArr[1]);
83348         let sourceHeight = Math.min(resolutionArr[0], resolutionArr[1]);
83349         let isPano = sourceWidth % sourceHeight === 0;
83350         d2 = {
83351           loc,
83352           capture_time: feature3.properties.capture_time,
83353           id: feature3.properties.id,
83354           sequence_id: feature3.properties.sequence_uuid,
83355           heading: feature3.properties.heading,
83356           resolution: feature3.properties.resolution,
83357           isPano
83358         };
83359         cache.forImageId[d2.id] = d2;
83360         features.push({
83361           minX: loc[0],
83362           minY: loc[1],
83363           maxX: loc[0],
83364           maxY: loc[1],
83365           data: d2
83366         });
83367       }
83368       if (cache.rtree) {
83369         cache.rtree.load(features);
83370       }
83371     }
83372     if (vectorTile.layers.hasOwnProperty(lineLayer)) {
83373       cache = _cache4.sequences;
83374       layer = vectorTile.layers[lineLayer];
83375       for (i3 = 0; i3 < layer.length; i3++) {
83376         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83377         if (cache.lineString[feature3.properties.sequence_uuid]) {
83378           cache.lineString[feature3.properties.sequence_uuid].push(feature3);
83379         } else {
83380           cache.lineString[feature3.properties.sequence_uuid] = [feature3];
83381         }
83382       }
83383     }
83384   }
83385   function getImageData(imageId, sequenceId) {
83386     return fetch(apiUrl2 + "/api/sequence-detail?sequence_uuid=".concat(sequenceId), { method: "GET" }).then(function(response) {
83387       if (!response.ok) {
83388         throw new Error(response.status + " " + response.statusText);
83389       }
83390       return response.json();
83391     }).then(function(data) {
83392       let index = data.data.findIndex((feature3) => feature3.id === imageId);
83393       const { filename, uploaded_hash } = data.data[index];
83394       _sceneOptions2.panorama = imageBaseUrl + "/" + uploaded_hash + "/" + filename + "/" + resolution;
83395     });
83396   }
83397   var mapilio_default = {
83398     // Initialize Mapilio
83399     init: function() {
83400       if (!_cache4) {
83401         this.reset();
83402       }
83403       this.event = utilRebind(this, dispatch13, "on");
83404     },
83405     // Reset cache and state
83406     reset: function() {
83407       if (_cache4) {
83408         Object.values(_cache4.requests.inflight).forEach(function(request3) {
83409           request3.abort();
83410         });
83411       }
83412       _cache4 = {
83413         images: { rtree: new import_rbush12.default(), forImageId: {} },
83414         sequences: { rtree: new import_rbush12.default(), lineString: {} },
83415         requests: { loaded: {}, inflight: {} }
83416       };
83417       _activeImage = null;
83418     },
83419     // Get visible images
83420     images: function(projection2) {
83421       const limit = 5;
83422       return searchLimited5(limit, projection2, _cache4.images.rtree);
83423     },
83424     cachedImage: function(imageKey) {
83425       return _cache4.images.forImageId[imageKey];
83426     },
83427     // Load images in the visible area
83428     loadImages: function(projection2) {
83429       let url = baseTileUrl2 + pointLayer + tileStyle;
83430       loadTiles4("images", url, 14, projection2);
83431     },
83432     // Load line in the visible area
83433     loadLines: function(projection2) {
83434       let url = baseTileUrl2 + lineLayer + tileStyle;
83435       loadTiles4("line", url, 14, projection2);
83436     },
83437     // Get visible sequences
83438     sequences: function(projection2) {
83439       const viewport = projection2.clipExtent();
83440       const min3 = [viewport[0][0], viewport[1][1]];
83441       const max3 = [viewport[1][0], viewport[0][1]];
83442       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
83443       const sequenceIds = {};
83444       let lineStrings = [];
83445       _cache4.images.rtree.search(bbox2).forEach(function(d2) {
83446         if (d2.data.sequence_id) {
83447           sequenceIds[d2.data.sequence_id] = true;
83448         }
83449       });
83450       Object.keys(sequenceIds).forEach(function(sequenceId) {
83451         if (_cache4.sequences.lineString[sequenceId]) {
83452           lineStrings = lineStrings.concat(_cache4.sequences.lineString[sequenceId]);
83453         }
83454       });
83455       return lineStrings;
83456     },
83457     // Set the currently visible image
83458     setActiveImage: function(image) {
83459       if (image) {
83460         _activeImage = {
83461           id: image.id,
83462           sequence_id: image.sequence_id
83463         };
83464       } else {
83465         _activeImage = null;
83466       }
83467     },
83468     // Update the currently highlighted sequence and selected bubble.
83469     setStyles: function(context, hovered) {
83470       const hoveredImageId = hovered && hovered.id;
83471       const hoveredSequenceId = hovered && hovered.sequence_id;
83472       const selectedSequenceId = _activeImage && _activeImage.sequence_id;
83473       const selectedImageId = _activeImage && _activeImage.id;
83474       const markers = context.container().selectAll(".layer-mapilio .viewfield-group");
83475       const sequences = context.container().selectAll(".layer-mapilio .sequence");
83476       markers.classed("highlighted", function(d2) {
83477         return d2.id === hoveredImageId;
83478       }).classed("hovered", function(d2) {
83479         return d2.id === hoveredImageId;
83480       }).classed("currentView", function(d2) {
83481         return d2.id === selectedImageId;
83482       });
83483       sequences.classed("highlighted", function(d2) {
83484         return d2.properties.sequence_uuid === hoveredSequenceId;
83485       }).classed("currentView", function(d2) {
83486         return d2.properties.sequence_uuid === selectedSequenceId;
83487       });
83488       return this;
83489     },
83490     updateUrlImage: function(imageKey) {
83491       if (!window.mocha) {
83492         var hash = utilStringQs(window.location.hash);
83493         if (imageKey) {
83494           hash.photo = "mapilio/" + imageKey;
83495         } else {
83496           delete hash.photo;
83497         }
83498         window.location.replace("#" + utilQsString(hash, true));
83499       }
83500     },
83501     initViewer: function() {
83502       if (!window.pannellum)
83503         return;
83504       if (_pannellumViewer3)
83505         return;
83506       _currScene2 += 1;
83507       const sceneID = _currScene2.toString();
83508       const options2 = {
83509         "default": { firstScene: sceneID },
83510         scenes: {}
83511       };
83512       options2.scenes[sceneID] = _sceneOptions2;
83513       _pannellumViewer3 = window.pannellum.viewer("ideditor-viewer-mapilio-pnlm", options2);
83514     },
83515     selectImage: function(context, id2) {
83516       let that = this;
83517       let d2 = this.cachedImage(id2);
83518       this.setActiveImage(d2);
83519       this.updateUrlImage(d2.id);
83520       let viewer = context.container().select(".photoviewer");
83521       if (!viewer.empty())
83522         viewer.datum(d2);
83523       this.setStyles(context, null);
83524       if (!d2)
83525         return this;
83526       let wrap2 = context.container().select(".photoviewer .mapilio-wrapper");
83527       let attribution = wrap2.selectAll(".photo-attribution").text("");
83528       if (d2.capture_time) {
83529         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
83530         attribution.append("span").text("|");
83531       }
83532       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");
83533       wrap2.transition().duration(100).call(imgZoom3.transform, identity2);
83534       wrap2.selectAll("img").remove();
83535       getImageData(d2.id, d2.sequence_id).then(function() {
83536         if (d2.isPano) {
83537           if (!_pannellumViewer3) {
83538             that.initViewer();
83539           } else {
83540             _currScene2 += 1;
83541             let sceneID = _currScene2.toString();
83542             _pannellumViewer3.addScene(sceneID, _sceneOptions2).loadScene(sceneID);
83543             if (_currScene2 > 2) {
83544               sceneID = (_currScene2 - 1).toString();
83545               _pannellumViewer3.removeScene(sceneID);
83546             }
83547           }
83548         } else {
83549           that.initOnlyPhoto(context);
83550         }
83551       });
83552       function localeDateString2(s2) {
83553         if (!s2)
83554           return null;
83555         var options2 = { day: "numeric", month: "short", year: "numeric" };
83556         var d4 = new Date(s2);
83557         if (isNaN(d4.getTime()))
83558           return null;
83559         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
83560       }
83561       return this;
83562     },
83563     initOnlyPhoto: function(context) {
83564       if (_pannellumViewer3) {
83565         _pannellumViewer3.destroy();
83566         _pannellumViewer3 = null;
83567       }
83568       let wrap2 = context.container().select("#ideditor-viewer-mapilio-simple");
83569       let imgWrap = wrap2.select("img");
83570       if (!imgWrap.empty()) {
83571         imgWrap.attr("src", _sceneOptions2.panorama);
83572       } else {
83573         wrap2.append("img").attr("src", _sceneOptions2.panorama);
83574       }
83575     },
83576     ensureViewerLoaded: function(context) {
83577       let that = this;
83578       let imgWrap = context.container().select("#ideditor-viewer-mapilio-simple > img");
83579       if (!imgWrap.empty()) {
83580         imgWrap.remove();
83581       }
83582       if (_loadViewerPromise5)
83583         return _loadViewerPromise5;
83584       let wrap2 = context.container().select(".photoviewer").selectAll(".mapilio-wrapper").data([0]);
83585       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null);
83586       wrapEnter.append("div").attr("class", "photo-attribution fillD");
83587       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio");
83588       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
83589       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
83590       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm");
83591       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple");
83592       context.ui().photoviewer.on("resize.mapilio", () => {
83593         if (_pannellumViewer3) {
83594           _pannellumViewer3.resize();
83595         }
83596       });
83597       _loadViewerPromise5 = new Promise((resolve, reject) => {
83598         let loadedCount = 0;
83599         function loaded() {
83600           loadedCount += 1;
83601           if (loadedCount === 2)
83602             resolve();
83603         }
83604         const head = select_default2("head");
83605         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() {
83606           reject();
83607         });
83608         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() {
83609           reject();
83610         });
83611       }).catch(function() {
83612         _loadViewerPromise5 = null;
83613       });
83614       function step(stepBy) {
83615         return function() {
83616           if (!_activeImage)
83617             return;
83618           const imageId = _activeImage.id;
83619           const nextIndex = imageId + stepBy;
83620           if (!nextIndex)
83621             return;
83622           const nextImage = _cache4.images.forImageId[nextIndex];
83623           context.map().centerEase(nextImage.loc);
83624           that.selectImage(context, nextImage.id);
83625         };
83626       }
83627       function zoomPan2(d3_event) {
83628         var t2 = d3_event.transform;
83629         context.container().select(".photoviewer #ideditor-viewer-mapilio-simple").call(utilSetTransform, t2.x, t2.y, t2.k);
83630       }
83631       return _loadViewerPromise5;
83632     },
83633     showViewer: function(context) {
83634       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
83635       let isHidden = wrap2.selectAll(".photo-wrapper.mapilio-wrapper.hide").size();
83636       if (isHidden) {
83637         wrap2.selectAll(".photo-wrapper:not(.mapilio-wrapper)").classed("hide", true);
83638         wrap2.selectAll(".photo-wrapper.mapilio-wrapper").classed("hide", false);
83639       }
83640       return this;
83641     },
83642     /**
83643      * hideViewer()
83644      */
83645     hideViewer: function(context) {
83646       let viewer = context.container().select(".photoviewer");
83647       if (!viewer.empty())
83648         viewer.datum(null);
83649       this.updateUrlImage(null);
83650       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
83651       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
83652       this.setActiveImage();
83653       return this.setStyles(context, null);
83654     },
83655     // Return the current cache
83656     cache: function() {
83657       return _cache4;
83658     }
83659   };
83660
83661   // modules/services/index.js
83662   var services = {
83663     geocoder: nominatim_default,
83664     keepRight: keepRight_default,
83665     improveOSM: improveOSM_default,
83666     osmose: osmose_default,
83667     mapillary: mapillary_default,
83668     nsi: nsi_default,
83669     kartaview: kartaview_default,
83670     vegbilder: vegbilder_default,
83671     osm: osm_default,
83672     osmWikibase: osm_wikibase_default,
83673     maprules: maprules_default,
83674     streetside: streetside_default,
83675     taginfo: taginfo_default,
83676     vectorTile: vector_tile_default,
83677     wikidata: wikidata_default,
83678     wikipedia: wikipedia_default,
83679     mapilio: mapilio_default
83680   };
83681
83682   // modules/modes/drag_note.js
83683   function modeDragNote(context) {
83684     var mode = {
83685       id: "drag-note",
83686       button: "browse"
83687     };
83688     var edit2 = behaviorEdit(context);
83689     var _nudgeInterval;
83690     var _lastLoc;
83691     var _note;
83692     function startNudge(d3_event, nudge) {
83693       if (_nudgeInterval)
83694         window.clearInterval(_nudgeInterval);
83695       _nudgeInterval = window.setInterval(function() {
83696         context.map().pan(nudge);
83697         doMove(d3_event, nudge);
83698       }, 50);
83699     }
83700     function stopNudge() {
83701       if (_nudgeInterval) {
83702         window.clearInterval(_nudgeInterval);
83703         _nudgeInterval = null;
83704       }
83705     }
83706     function origin(note) {
83707       return context.projection(note.loc);
83708     }
83709     function start2(d3_event, note) {
83710       _note = note;
83711       var osm = services.osm;
83712       if (osm) {
83713         _note = osm.getNote(_note.id);
83714       }
83715       context.surface().selectAll(".note-" + _note.id).classed("active", true);
83716       context.perform(actionNoop());
83717       context.enter(mode);
83718       context.selectedNoteID(_note.id);
83719     }
83720     function move(d3_event, entity, point2) {
83721       d3_event.stopPropagation();
83722       _lastLoc = context.projection.invert(point2);
83723       doMove(d3_event);
83724       var nudge = geoViewportEdge(point2, context.map().dimensions());
83725       if (nudge) {
83726         startNudge(d3_event, nudge);
83727       } else {
83728         stopNudge();
83729       }
83730     }
83731     function doMove(d3_event, nudge) {
83732       nudge = nudge || [0, 0];
83733       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
83734       var currMouse = geoVecSubtract(currPoint, nudge);
83735       var loc = context.projection.invert(currMouse);
83736       _note = _note.move(loc);
83737       var osm = services.osm;
83738       if (osm) {
83739         osm.replaceNote(_note);
83740       }
83741       context.replace(actionNoop());
83742     }
83743     function end() {
83744       context.replace(actionNoop());
83745       context.selectedNoteID(_note.id).enter(modeSelectNote(context, _note.id));
83746     }
83747     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);
83748     mode.enter = function() {
83749       context.install(edit2);
83750     };
83751     mode.exit = function() {
83752       context.ui().sidebar.hover.cancel();
83753       context.uninstall(edit2);
83754       context.surface().selectAll(".active").classed("active", false);
83755       stopNudge();
83756     };
83757     mode.behavior = drag;
83758     return mode;
83759   }
83760
83761   // modules/modes/select_data.js
83762   function modeSelectData(context, selectedDatum) {
83763     var mode = {
83764       id: "select-data",
83765       button: "browse"
83766     };
83767     var keybinding = utilKeybinding("select-data");
83768     var dataEditor = uiDataEditor(context);
83769     var behaviors = [
83770       behaviorBreathe(context),
83771       behaviorHover(context),
83772       behaviorSelect(context),
83773       behaviorLasso(context),
83774       modeDragNode(context).behavior,
83775       modeDragNote(context).behavior
83776     ];
83777     function selectData(d3_event, drawn) {
83778       var selection2 = context.surface().selectAll(".layer-mapdata .data" + selectedDatum.__featurehash__);
83779       if (selection2.empty()) {
83780         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
83781         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
83782           context.enter(modeBrowse(context));
83783         }
83784       } else {
83785         selection2.classed("selected", true);
83786       }
83787     }
83788     function esc() {
83789       if (context.container().select(".combobox").size())
83790         return;
83791       context.enter(modeBrowse(context));
83792     }
83793     mode.zoomToSelected = function() {
83794       var extent = geoExtent(bounds_default(selectedDatum));
83795       context.map().centerZoomEase(extent.center(), context.map().trimmedExtentZoom(extent));
83796     };
83797     mode.enter = function() {
83798       behaviors.forEach(context.install);
83799       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
83800       select_default2(document).call(keybinding);
83801       selectData();
83802       var sidebar = context.ui().sidebar;
83803       sidebar.show(dataEditor.datum(selectedDatum));
83804       var extent = geoExtent(bounds_default(selectedDatum));
83805       sidebar.expand(sidebar.intersects(extent));
83806       context.map().on("drawn.select-data", selectData);
83807     };
83808     mode.exit = function() {
83809       behaviors.forEach(context.uninstall);
83810       select_default2(document).call(keybinding.unbind);
83811       context.surface().selectAll(".layer-mapdata .selected").classed("selected hover", false);
83812       context.map().on("drawn.select-data", null);
83813       context.ui().sidebar.hide();
83814     };
83815     return mode;
83816   }
83817
83818   // modules/behavior/select.js
83819   function behaviorSelect(context) {
83820     var _tolerancePx = 4;
83821     var _lastMouseEvent = null;
83822     var _showMenu = false;
83823     var _downPointers = {};
83824     var _longPressTimeout = null;
83825     var _lastInteractionType = null;
83826     var _multiselectionPointerId = null;
83827     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
83828     function keydown(d3_event) {
83829       if (d3_event.keyCode === 32) {
83830         var activeNode = document.activeElement;
83831         if (activeNode && (/* @__PURE__ */ new Set(["INPUT", "TEXTAREA"])).has(activeNode.nodeName))
83832           return;
83833       }
83834       if (d3_event.keyCode === 93 || // context menu key
83835       d3_event.keyCode === 32) {
83836         d3_event.preventDefault();
83837       }
83838       if (d3_event.repeat)
83839         return;
83840       cancelLongPress();
83841       if (d3_event.shiftKey) {
83842         context.surface().classed("behavior-multiselect", true);
83843       }
83844       if (d3_event.keyCode === 32) {
83845         if (!_downPointers.spacebar && _lastMouseEvent) {
83846           cancelLongPress();
83847           _longPressTimeout = window.setTimeout(didLongPress, 500, "spacebar", "spacebar");
83848           _downPointers.spacebar = {
83849             firstEvent: _lastMouseEvent,
83850             lastEvent: _lastMouseEvent
83851           };
83852         }
83853       }
83854     }
83855     function keyup(d3_event) {
83856       cancelLongPress();
83857       if (!d3_event.shiftKey) {
83858         context.surface().classed("behavior-multiselect", false);
83859       }
83860       if (d3_event.keyCode === 93) {
83861         d3_event.preventDefault();
83862         _lastInteractionType = "menukey";
83863         contextmenu(d3_event);
83864       } else if (d3_event.keyCode === 32) {
83865         var pointer = _downPointers.spacebar;
83866         if (pointer) {
83867           delete _downPointers.spacebar;
83868           if (pointer.done)
83869             return;
83870           d3_event.preventDefault();
83871           _lastInteractionType = "spacebar";
83872           click(pointer.firstEvent, pointer.lastEvent, "spacebar");
83873         }
83874       }
83875     }
83876     function pointerdown(d3_event) {
83877       var id2 = (d3_event.pointerId || "mouse").toString();
83878       cancelLongPress();
83879       if (d3_event.buttons && d3_event.buttons !== 1)
83880         return;
83881       context.ui().closeEditMenu();
83882       if (d3_event.pointerType !== "mouse") {
83883         _longPressTimeout = window.setTimeout(didLongPress, 500, id2, "longdown-" + (d3_event.pointerType || "mouse"));
83884       }
83885       _downPointers[id2] = {
83886         firstEvent: d3_event,
83887         lastEvent: d3_event
83888       };
83889     }
83890     function didLongPress(id2, interactionType) {
83891       var pointer = _downPointers[id2];
83892       if (!pointer)
83893         return;
83894       for (var i3 in _downPointers) {
83895         _downPointers[i3].done = true;
83896       }
83897       _longPressTimeout = null;
83898       _lastInteractionType = interactionType;
83899       _showMenu = true;
83900       click(pointer.firstEvent, pointer.lastEvent, id2);
83901     }
83902     function pointermove(d3_event) {
83903       var id2 = (d3_event.pointerId || "mouse").toString();
83904       if (_downPointers[id2]) {
83905         _downPointers[id2].lastEvent = d3_event;
83906       }
83907       if (!d3_event.pointerType || d3_event.pointerType === "mouse") {
83908         _lastMouseEvent = d3_event;
83909         if (_downPointers.spacebar) {
83910           _downPointers.spacebar.lastEvent = d3_event;
83911         }
83912       }
83913     }
83914     function pointerup(d3_event) {
83915       var id2 = (d3_event.pointerId || "mouse").toString();
83916       var pointer = _downPointers[id2];
83917       if (!pointer)
83918         return;
83919       delete _downPointers[id2];
83920       if (_multiselectionPointerId === id2) {
83921         _multiselectionPointerId = null;
83922       }
83923       if (pointer.done)
83924         return;
83925       click(pointer.firstEvent, d3_event, id2);
83926     }
83927     function pointercancel(d3_event) {
83928       var id2 = (d3_event.pointerId || "mouse").toString();
83929       if (!_downPointers[id2])
83930         return;
83931       delete _downPointers[id2];
83932       if (_multiselectionPointerId === id2) {
83933         _multiselectionPointerId = null;
83934       }
83935     }
83936     function contextmenu(d3_event) {
83937       d3_event.preventDefault();
83938       if (!+d3_event.clientX && !+d3_event.clientY) {
83939         if (_lastMouseEvent) {
83940           d3_event = _lastMouseEvent;
83941         } else {
83942           return;
83943         }
83944       } else {
83945         _lastMouseEvent = d3_event;
83946         if (d3_event.pointerType === "touch" || d3_event.pointerType === "pen" || d3_event.mozInputSource && // firefox doesn't give a pointerType on contextmenu events
83947         (d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_TOUCH || d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_PEN)) {
83948           _lastInteractionType = "touch";
83949         } else {
83950           _lastInteractionType = "rightclick";
83951         }
83952       }
83953       _showMenu = true;
83954       click(d3_event, d3_event);
83955     }
83956     function click(firstEvent, lastEvent, pointerId) {
83957       cancelLongPress();
83958       var mapNode = context.container().select(".main-map").node();
83959       var pointGetter = utilFastMouse(mapNode);
83960       var p1 = pointGetter(firstEvent);
83961       var p2 = pointGetter(lastEvent);
83962       var dist = geoVecLength(p1, p2);
83963       if (dist > _tolerancePx || !mapContains(lastEvent)) {
83964         resetProperties();
83965         return;
83966       }
83967       var targetDatum = lastEvent.target.__data__;
83968       var multiselectEntityId;
83969       if (!_multiselectionPointerId) {
83970         var selectPointerInfo = pointerDownOnSelection(pointerId);
83971         if (selectPointerInfo) {
83972           _multiselectionPointerId = selectPointerInfo.pointerId;
83973           multiselectEntityId = !selectPointerInfo.selected && selectPointerInfo.entityId;
83974           _downPointers[selectPointerInfo.pointerId].done = true;
83975         }
83976       }
83977       var isMultiselect = context.mode().id === "select" && // and shift key is down
83978       (lastEvent && lastEvent.shiftKey || // or we're lasso-selecting
83979       context.surface().select(".lasso").node() || // or a pointer is down over a selected feature
83980       _multiselectionPointerId && !multiselectEntityId);
83981       processClick(targetDatum, isMultiselect, p2, multiselectEntityId);
83982       function mapContains(event) {
83983         var rect = mapNode.getBoundingClientRect();
83984         return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
83985       }
83986       function pointerDownOnSelection(skipPointerId) {
83987         var mode = context.mode();
83988         var selectedIDs = mode.id === "select" ? mode.selectedIDs() : [];
83989         for (var pointerId2 in _downPointers) {
83990           if (pointerId2 === "spacebar" || pointerId2 === skipPointerId)
83991             continue;
83992           var pointerInfo = _downPointers[pointerId2];
83993           var p12 = pointGetter(pointerInfo.firstEvent);
83994           var p22 = pointGetter(pointerInfo.lastEvent);
83995           if (geoVecLength(p12, p22) > _tolerancePx)
83996             continue;
83997           var datum2 = pointerInfo.firstEvent.target.__data__;
83998           var entity = datum2 && datum2.properties && datum2.properties.entity || datum2;
83999           if (context.graph().hasEntity(entity.id)) {
84000             return {
84001               pointerId: pointerId2,
84002               entityId: entity.id,
84003               selected: selectedIDs.indexOf(entity.id) !== -1
84004             };
84005           }
84006         }
84007         return null;
84008       }
84009     }
84010     function processClick(datum2, isMultiselect, point2, alsoSelectId) {
84011       var mode = context.mode();
84012       var showMenu = _showMenu;
84013       var interactionType = _lastInteractionType;
84014       var entity = datum2 && datum2.properties && datum2.properties.entity;
84015       if (entity)
84016         datum2 = entity;
84017       if (datum2 && datum2.type === "midpoint") {
84018         datum2 = datum2.parents[0];
84019       }
84020       var newMode;
84021       if (datum2 instanceof osmEntity) {
84022         var selectedIDs = context.selectedIDs();
84023         context.selectedNoteID(null);
84024         context.selectedErrorID(null);
84025         if (!isMultiselect) {
84026           if (!showMenu || selectedIDs.length <= 1 || selectedIDs.indexOf(datum2.id) === -1) {
84027             if (alsoSelectId === datum2.id)
84028               alsoSelectId = null;
84029             selectedIDs = (alsoSelectId ? [alsoSelectId] : []).concat([datum2.id]);
84030             newMode = mode.id === "select" ? mode.selectedIDs(selectedIDs) : modeSelect(context, selectedIDs).selectBehavior(behavior);
84031             context.enter(newMode);
84032           }
84033         } else {
84034           if (selectedIDs.indexOf(datum2.id) !== -1) {
84035             if (!showMenu) {
84036               selectedIDs = selectedIDs.filter(function(id2) {
84037                 return id2 !== datum2.id;
84038               });
84039               newMode = selectedIDs.length ? mode.selectedIDs(selectedIDs) : modeBrowse(context).selectBehavior(behavior);
84040               context.enter(newMode);
84041             }
84042           } else {
84043             selectedIDs = selectedIDs.concat([datum2.id]);
84044             newMode = mode.selectedIDs(selectedIDs);
84045             context.enter(newMode);
84046           }
84047         }
84048       } else if (datum2 && datum2.__featurehash__ && !isMultiselect) {
84049         context.selectedNoteID(null).enter(modeSelectData(context, datum2));
84050       } else if (datum2 instanceof osmNote && !isMultiselect) {
84051         context.selectedNoteID(datum2.id).enter(modeSelectNote(context, datum2.id));
84052       } else if (datum2 instanceof QAItem && !isMultiselect) {
84053         context.selectedErrorID(datum2.id).enter(modeSelectError(context, datum2.id, datum2.service));
84054       } else {
84055         context.selectedNoteID(null);
84056         context.selectedErrorID(null);
84057         if (!isMultiselect && mode.id !== "browse") {
84058           context.enter(modeBrowse(context));
84059         }
84060       }
84061       context.ui().closeEditMenu();
84062       if (showMenu)
84063         context.ui().showEditMenu(point2, interactionType);
84064       resetProperties();
84065     }
84066     function cancelLongPress() {
84067       if (_longPressTimeout)
84068         window.clearTimeout(_longPressTimeout);
84069       _longPressTimeout = null;
84070     }
84071     function resetProperties() {
84072       cancelLongPress();
84073       _showMenu = false;
84074       _lastInteractionType = null;
84075     }
84076     function behavior(selection2) {
84077       resetProperties();
84078       _lastMouseEvent = context.map().lastPointerEvent();
84079       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) {
84080         var e3 = d3_event;
84081         if (+e3.clientX === 0 && +e3.clientY === 0) {
84082           d3_event.preventDefault();
84083         }
84084       });
84085       selection2.on(_pointerPrefix + "down.select", pointerdown).on("contextmenu.select", contextmenu);
84086     }
84087     behavior.off = function(selection2) {
84088       cancelLongPress();
84089       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);
84090       selection2.on(_pointerPrefix + "down.select", null).on("contextmenu.select", null);
84091       context.surface().classed("behavior-multiselect", false);
84092     };
84093     return behavior;
84094   }
84095
84096   // modules/operations/index.js
84097   var operations_exports = {};
84098   __export(operations_exports, {
84099     operationCircularize: () => operationCircularize,
84100     operationContinue: () => operationContinue,
84101     operationCopy: () => operationCopy,
84102     operationDelete: () => operationDelete,
84103     operationDisconnect: () => operationDisconnect,
84104     operationDowngrade: () => operationDowngrade,
84105     operationExtract: () => operationExtract,
84106     operationMerge: () => operationMerge,
84107     operationMove: () => operationMove,
84108     operationOrthogonalize: () => operationOrthogonalize,
84109     operationPaste: () => operationPaste,
84110     operationReflectLong: () => operationReflectLong,
84111     operationReflectShort: () => operationReflectShort,
84112     operationReverse: () => operationReverse,
84113     operationRotate: () => operationRotate,
84114     operationSplit: () => operationSplit,
84115     operationStraighten: () => operationStraighten
84116   });
84117
84118   // modules/operations/continue.js
84119   function operationContinue(context, selectedIDs) {
84120     var _entities = selectedIDs.map(function(id2) {
84121       return context.graph().entity(id2);
84122     });
84123     var _geometries = Object.assign(
84124       { line: [], vertex: [] },
84125       utilArrayGroupBy(_entities, function(entity) {
84126         return entity.geometry(context.graph());
84127       })
84128     );
84129     var _vertex = _geometries.vertex.length && _geometries.vertex[0];
84130     function candidateWays() {
84131       return _vertex ? context.graph().parentWays(_vertex).filter(function(parent) {
84132         return parent.geometry(context.graph()) === "line" && !parent.isClosed() && parent.affix(_vertex.id) && (_geometries.line.length === 0 || _geometries.line[0] === parent);
84133       }) : [];
84134     }
84135     var _candidates = candidateWays();
84136     var operation2 = function() {
84137       var candidate = _candidates[0];
84138       context.enter(
84139         modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true)
84140       );
84141     };
84142     operation2.relatedEntityIds = function() {
84143       return _candidates.length ? [_candidates[0].id] : [];
84144     };
84145     operation2.available = function() {
84146       return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph());
84147     };
84148     operation2.disabled = function() {
84149       if (_candidates.length === 0) {
84150         return "not_eligible";
84151       } else if (_candidates.length > 1) {
84152         return "multiple";
84153       }
84154       return false;
84155     };
84156     operation2.tooltip = function() {
84157       var disable = operation2.disabled();
84158       return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description");
84159     };
84160     operation2.annotation = function() {
84161       return _t("operations.continue.annotation.line");
84162     };
84163     operation2.id = "continue";
84164     operation2.keys = [_t("operations.continue.key")];
84165     operation2.title = _t.append("operations.continue.title");
84166     operation2.behavior = behaviorOperation(context).which(operation2);
84167     return operation2;
84168   }
84169
84170   // modules/operations/copy.js
84171   function operationCopy(context, selectedIDs) {
84172     function getFilteredIdsToCopy() {
84173       return selectedIDs.filter(function(selectedID) {
84174         var entity = context.graph().hasEntity(selectedID);
84175         return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex";
84176       });
84177     }
84178     var operation2 = function() {
84179       var graph = context.graph();
84180       var selected = groupEntities(getFilteredIdsToCopy(), graph);
84181       var canCopy = [];
84182       var skip = {};
84183       var entity;
84184       var i3;
84185       for (i3 = 0; i3 < selected.relation.length; i3++) {
84186         entity = selected.relation[i3];
84187         if (!skip[entity.id] && entity.isComplete(graph)) {
84188           canCopy.push(entity.id);
84189           skip = getDescendants(entity.id, graph, skip);
84190         }
84191       }
84192       for (i3 = 0; i3 < selected.way.length; i3++) {
84193         entity = selected.way[i3];
84194         if (!skip[entity.id]) {
84195           canCopy.push(entity.id);
84196           skip = getDescendants(entity.id, graph, skip);
84197         }
84198       }
84199       for (i3 = 0; i3 < selected.node.length; i3++) {
84200         entity = selected.node[i3];
84201         if (!skip[entity.id]) {
84202           canCopy.push(entity.id);
84203         }
84204       }
84205       context.copyIDs(canCopy);
84206       if (_point && (canCopy.length !== 1 || graph.entity(canCopy[0]).type !== "node")) {
84207         context.copyLonLat(context.projection.invert(_point));
84208       } else {
84209         context.copyLonLat(null);
84210       }
84211     };
84212     function groupEntities(ids, graph) {
84213       var entities = ids.map(function(id2) {
84214         return graph.entity(id2);
84215       });
84216       return Object.assign(
84217         { relation: [], way: [], node: [] },
84218         utilArrayGroupBy(entities, "type")
84219       );
84220     }
84221     function getDescendants(id2, graph, descendants) {
84222       var entity = graph.entity(id2);
84223       var children2;
84224       descendants = descendants || {};
84225       if (entity.type === "relation") {
84226         children2 = entity.members.map(function(m2) {
84227           return m2.id;
84228         });
84229       } else if (entity.type === "way") {
84230         children2 = entity.nodes;
84231       } else {
84232         children2 = [];
84233       }
84234       for (var i3 = 0; i3 < children2.length; i3++) {
84235         if (!descendants[children2[i3]]) {
84236           descendants[children2[i3]] = true;
84237           descendants = getDescendants(children2[i3], graph, descendants);
84238         }
84239       }
84240       return descendants;
84241     }
84242     operation2.available = function() {
84243       return getFilteredIdsToCopy().length > 0;
84244     };
84245     operation2.disabled = function() {
84246       var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph());
84247       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
84248         return "too_large";
84249       }
84250       return false;
84251     };
84252     operation2.availableForKeypress = function() {
84253       var selection2 = window.getSelection && window.getSelection();
84254       return !selection2 || !selection2.toString();
84255     };
84256     operation2.tooltip = function() {
84257       var disable = operation2.disabled();
84258       return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length });
84259     };
84260     operation2.annotation = function() {
84261       return _t("operations.copy.annotation", { n: selectedIDs.length });
84262     };
84263     var _point;
84264     operation2.point = function(val) {
84265       _point = val;
84266       return operation2;
84267     };
84268     operation2.id = "copy";
84269     operation2.keys = [uiCmd("\u2318C")];
84270     operation2.title = _t.append("operations.copy.title");
84271     operation2.behavior = behaviorOperation(context).which(operation2);
84272     return operation2;
84273   }
84274
84275   // modules/operations/disconnect.js
84276   function operationDisconnect(context, selectedIDs) {
84277     var _vertexIDs = [];
84278     var _wayIDs = [];
84279     var _otherIDs = [];
84280     var _actions = [];
84281     selectedIDs.forEach(function(id2) {
84282       var entity = context.entity(id2);
84283       if (entity.type === "way") {
84284         _wayIDs.push(id2);
84285       } else if (entity.geometry(context.graph()) === "vertex") {
84286         _vertexIDs.push(id2);
84287       } else {
84288         _otherIDs.push(id2);
84289       }
84290     });
84291     var _coords, _descriptionID = "", _annotationID = "features";
84292     var _disconnectingVertexIds = [];
84293     var _disconnectingWayIds = [];
84294     if (_vertexIDs.length > 0) {
84295       _disconnectingVertexIds = _vertexIDs;
84296       _vertexIDs.forEach(function(vertexID) {
84297         var action = actionDisconnect(vertexID);
84298         if (_wayIDs.length > 0) {
84299           var waysIDsForVertex = _wayIDs.filter(function(wayID) {
84300             var way = context.entity(wayID);
84301             return way.nodes.indexOf(vertexID) !== -1;
84302           });
84303           action.limitWays(waysIDsForVertex);
84304         }
84305         _actions.push(action);
84306         _disconnectingWayIds = _disconnectingWayIds.concat(context.graph().parentWays(context.graph().entity(vertexID)).map((d2) => d2.id));
84307       });
84308       _disconnectingWayIds = utilArrayUniq(_disconnectingWayIds).filter(function(id2) {
84309         return _wayIDs.indexOf(id2) === -1;
84310       });
84311       _descriptionID += _actions.length === 1 ? "single_point." : "multiple_points.";
84312       if (_wayIDs.length === 1) {
84313         _descriptionID += "single_way." + context.graph().geometry(_wayIDs[0]);
84314       } else {
84315         _descriptionID += _wayIDs.length === 0 ? "no_ways" : "multiple_ways";
84316       }
84317     } else if (_wayIDs.length > 0) {
84318       var ways = _wayIDs.map(function(id2) {
84319         return context.entity(id2);
84320       });
84321       var nodes = utilGetAllNodes(_wayIDs, context.graph());
84322       _coords = nodes.map(function(n3) {
84323         return n3.loc;
84324       });
84325       var sharedActions = [];
84326       var sharedNodes = [];
84327       var unsharedActions = [];
84328       var unsharedNodes = [];
84329       nodes.forEach(function(node) {
84330         var action = actionDisconnect(node.id).limitWays(_wayIDs);
84331         if (action.disabled(context.graph()) !== "not_connected") {
84332           var count = 0;
84333           for (var i3 in ways) {
84334             var way = ways[i3];
84335             if (way.nodes.indexOf(node.id) !== -1) {
84336               count += 1;
84337             }
84338             if (count > 1)
84339               break;
84340           }
84341           if (count > 1) {
84342             sharedActions.push(action);
84343             sharedNodes.push(node);
84344           } else {
84345             unsharedActions.push(action);
84346             unsharedNodes.push(node);
84347           }
84348         }
84349       });
84350       _descriptionID += "no_points.";
84351       _descriptionID += _wayIDs.length === 1 ? "single_way." : "multiple_ways.";
84352       if (sharedActions.length) {
84353         _actions = sharedActions;
84354         _disconnectingVertexIds = sharedNodes.map((node) => node.id);
84355         _descriptionID += "conjoined";
84356         _annotationID = "from_each_other";
84357       } else {
84358         _actions = unsharedActions;
84359         _disconnectingVertexIds = unsharedNodes.map((node) => node.id);
84360         if (_wayIDs.length === 1) {
84361           _descriptionID += context.graph().geometry(_wayIDs[0]);
84362         } else {
84363           _descriptionID += "separate";
84364         }
84365       }
84366     }
84367     var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph());
84368     var operation2 = function() {
84369       context.perform(function(graph) {
84370         return _actions.reduce(function(graph2, action) {
84371           return action(graph2);
84372         }, graph);
84373       }, operation2.annotation());
84374       context.validator().validate();
84375     };
84376     operation2.relatedEntityIds = function() {
84377       if (_vertexIDs.length) {
84378         return _disconnectingWayIds;
84379       }
84380       return _disconnectingVertexIds;
84381     };
84382     operation2.available = function() {
84383       if (_actions.length === 0)
84384         return false;
84385       if (_otherIDs.length !== 0)
84386         return false;
84387       if (_vertexIDs.length !== 0 && _wayIDs.length !== 0 && !_wayIDs.every(function(wayID) {
84388         return _vertexIDs.some(function(vertexID) {
84389           var way = context.entity(wayID);
84390           return way.nodes.indexOf(vertexID) !== -1;
84391         });
84392       }))
84393         return false;
84394       return true;
84395     };
84396     operation2.disabled = function() {
84397       var reason;
84398       for (var actionIndex in _actions) {
84399         reason = _actions[actionIndex].disabled(context.graph());
84400         if (reason)
84401           return reason;
84402       }
84403       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84404         return "too_large." + ((_vertexIDs.length ? _vertexIDs : _wayIDs).length === 1 ? "single" : "multiple");
84405       } else if (_coords && someMissing()) {
84406         return "not_downloaded";
84407       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84408         return "connected_to_hidden";
84409       }
84410       return false;
84411       function someMissing() {
84412         if (context.inIntro())
84413           return false;
84414         var osm = context.connection();
84415         if (osm) {
84416           var missing = _coords.filter(function(loc) {
84417             return !osm.isDataLoaded(loc);
84418           });
84419           if (missing.length) {
84420             missing.forEach(function(loc) {
84421               context.loadTileAtLoc(loc);
84422             });
84423             return true;
84424           }
84425         }
84426         return false;
84427       }
84428     };
84429     operation2.tooltip = function() {
84430       var disable = operation2.disabled();
84431       return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID);
84432     };
84433     operation2.annotation = function() {
84434       return _t("operations.disconnect.annotation." + _annotationID);
84435     };
84436     operation2.id = "disconnect";
84437     operation2.keys = [_t("operations.disconnect.key")];
84438     operation2.title = _t.append("operations.disconnect.title");
84439     operation2.behavior = behaviorOperation(context).which(operation2);
84440     return operation2;
84441   }
84442
84443   // modules/operations/downgrade.js
84444   function operationDowngrade(context, selectedIDs) {
84445     var _affectedFeatureCount = 0;
84446     var _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
84447     var _multi = _affectedFeatureCount === 1 ? "single" : "multiple";
84448     function downgradeTypeForEntityIDs(entityIds) {
84449       var downgradeType;
84450       _affectedFeatureCount = 0;
84451       for (var i3 in entityIds) {
84452         var entityID = entityIds[i3];
84453         var type2 = downgradeTypeForEntityID(entityID);
84454         if (type2) {
84455           _affectedFeatureCount += 1;
84456           if (downgradeType && type2 !== downgradeType) {
84457             if (downgradeType !== "generic" && type2 !== "generic") {
84458               downgradeType = "building_address";
84459             } else {
84460               downgradeType = "generic";
84461             }
84462           } else {
84463             downgradeType = type2;
84464           }
84465         }
84466       }
84467       return downgradeType;
84468     }
84469     function downgradeTypeForEntityID(entityID) {
84470       var graph = context.graph();
84471       var entity = graph.entity(entityID);
84472       var preset = _mainPresetIndex.match(entity, graph);
84473       if (!preset || preset.isFallback())
84474         return null;
84475       if (entity.type === "node" && preset.id !== "address" && Object.keys(entity.tags).some(function(key) {
84476         return key.match(/^addr:.{1,}/);
84477       })) {
84478         return "address";
84479       }
84480       var geometry = entity.geometry(graph);
84481       if (geometry === "area" && entity.tags.building && !preset.tags.building) {
84482         return "building";
84483       }
84484       if (geometry === "vertex" && Object.keys(entity.tags).length) {
84485         return "generic";
84486       }
84487       return null;
84488     }
84489     var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"];
84490     var addressKeysToKeep = ["source"];
84491     var operation2 = function() {
84492       context.perform(function(graph) {
84493         for (var i3 in selectedIDs) {
84494           var entityID = selectedIDs[i3];
84495           var type2 = downgradeTypeForEntityID(entityID);
84496           if (!type2)
84497             continue;
84498           var tags = Object.assign({}, graph.entity(entityID).tags);
84499           for (var key in tags) {
84500             if (type2 === "address" && addressKeysToKeep.indexOf(key) !== -1)
84501               continue;
84502             if (type2 === "building") {
84503               if (buildingKeysToKeep.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
84504                 continue;
84505             }
84506             if (type2 !== "generic") {
84507               if (key.match(/^addr:.{1,}/) || key.match(/^source:.{1,}/))
84508                 continue;
84509             }
84510             delete tags[key];
84511           }
84512           graph = actionChangeTags(entityID, tags)(graph);
84513         }
84514         return graph;
84515       }, operation2.annotation());
84516       context.validator().validate();
84517       context.enter(modeSelect(context, selectedIDs));
84518     };
84519     operation2.available = function() {
84520       return _downgradeType;
84521     };
84522     operation2.disabled = function() {
84523       if (selectedIDs.some(hasWikidataTag)) {
84524         return "has_wikidata_tag";
84525       }
84526       return false;
84527       function hasWikidataTag(id2) {
84528         var entity = context.entity(id2);
84529         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
84530       }
84531     };
84532     operation2.tooltip = function() {
84533       var disable = operation2.disabled();
84534       return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType);
84535     };
84536     operation2.annotation = function() {
84537       var suffix;
84538       if (_downgradeType === "building_address") {
84539         suffix = "generic";
84540       } else {
84541         suffix = _downgradeType;
84542       }
84543       return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount });
84544     };
84545     operation2.id = "downgrade";
84546     operation2.keys = [uiCmd("\u232B")];
84547     operation2.title = _t.append("operations.downgrade.title");
84548     operation2.behavior = behaviorOperation(context).which(operation2);
84549     return operation2;
84550   }
84551
84552   // modules/operations/extract.js
84553   function operationExtract(context, selectedIDs) {
84554     var _amount = selectedIDs.length === 1 ? "single" : "multiple";
84555     var _geometries = utilArrayUniq(selectedIDs.map(function(entityID) {
84556       return context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
84557     }).filter(Boolean));
84558     var _geometryID = _geometries.length === 1 ? _geometries[0] : "feature";
84559     var _extent;
84560     var _actions = selectedIDs.map(function(entityID) {
84561       var graph = context.graph();
84562       var entity = graph.hasEntity(entityID);
84563       if (!entity || !entity.hasInterestingTags())
84564         return null;
84565       if (entity.type === "node" && graph.parentWays(entity).length === 0)
84566         return null;
84567       if (entity.type !== "node") {
84568         var preset = _mainPresetIndex.match(entity, graph);
84569         if (preset.geometry.indexOf("point") === -1)
84570           return null;
84571       }
84572       _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph);
84573       return actionExtract(entityID, context.projection);
84574     }).filter(Boolean);
84575     var operation2 = function() {
84576       var combinedAction = function(graph) {
84577         _actions.forEach(function(action) {
84578           graph = action(graph);
84579         });
84580         return graph;
84581       };
84582       context.perform(combinedAction, operation2.annotation());
84583       var extractedNodeIDs = _actions.map(function(action) {
84584         return action.getExtractedNodeID();
84585       });
84586       context.enter(modeSelect(context, extractedNodeIDs));
84587     };
84588     operation2.available = function() {
84589       return _actions.length && selectedIDs.length === _actions.length;
84590     };
84591     operation2.disabled = function() {
84592       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84593         return "too_large";
84594       } else if (selectedIDs.some(function(entityID) {
84595         return context.graph().geometry(entityID) === "vertex" && context.hasHiddenConnections(entityID);
84596       })) {
84597         return "connected_to_hidden";
84598       }
84599       return false;
84600     };
84601     operation2.tooltip = function() {
84602       var disableReason = operation2.disabled();
84603       if (disableReason) {
84604         return _t.append("operations.extract." + disableReason + "." + _amount);
84605       } else {
84606         return _t.append("operations.extract.description." + _geometryID + "." + _amount);
84607       }
84608     };
84609     operation2.annotation = function() {
84610       return _t("operations.extract.annotation", { n: selectedIDs.length });
84611     };
84612     operation2.id = "extract";
84613     operation2.keys = [_t("operations.extract.key")];
84614     operation2.title = _t.append("operations.extract.title");
84615     operation2.behavior = behaviorOperation(context).which(operation2);
84616     return operation2;
84617   }
84618
84619   // modules/operations/merge.js
84620   function operationMerge(context, selectedIDs) {
84621     var _action = getAction();
84622     function getAction() {
84623       var join = actionJoin(selectedIDs);
84624       if (!join.disabled(context.graph()))
84625         return join;
84626       var merge2 = actionMerge(selectedIDs);
84627       if (!merge2.disabled(context.graph()))
84628         return merge2;
84629       var mergePolygon = actionMergePolygon(selectedIDs);
84630       if (!mergePolygon.disabled(context.graph()))
84631         return mergePolygon;
84632       var mergeNodes = actionMergeNodes(selectedIDs);
84633       if (!mergeNodes.disabled(context.graph()))
84634         return mergeNodes;
84635       if (join.disabled(context.graph()) !== "not_eligible")
84636         return join;
84637       if (merge2.disabled(context.graph()) !== "not_eligible")
84638         return merge2;
84639       if (mergePolygon.disabled(context.graph()) !== "not_eligible")
84640         return mergePolygon;
84641       return mergeNodes;
84642     }
84643     var operation2 = function() {
84644       if (operation2.disabled())
84645         return;
84646       context.perform(_action, operation2.annotation());
84647       context.validator().validate();
84648       var resultIDs = selectedIDs.filter(context.hasEntity);
84649       if (resultIDs.length > 1) {
84650         var interestingIDs = resultIDs.filter(function(id2) {
84651           return context.entity(id2).hasInterestingTags();
84652         });
84653         if (interestingIDs.length)
84654           resultIDs = interestingIDs;
84655       }
84656       context.enter(modeSelect(context, resultIDs));
84657     };
84658     operation2.available = function() {
84659       return selectedIDs.length >= 2;
84660     };
84661     operation2.disabled = function() {
84662       var actionDisabled = _action.disabled(context.graph());
84663       if (actionDisabled)
84664         return actionDisabled;
84665       var osm = context.connection();
84666       if (osm && _action.resultingWayNodesLength && _action.resultingWayNodesLength(context.graph()) > osm.maxWayNodes()) {
84667         return "too_many_vertices";
84668       }
84669       return false;
84670     };
84671     operation2.tooltip = function() {
84672       var disabled = operation2.disabled();
84673       if (disabled) {
84674         if (disabled === "conflicting_relations") {
84675           return _t.append("operations.merge.conflicting_relations");
84676         }
84677         if (disabled === "restriction" || disabled === "connectivity") {
84678           return _t.append(
84679             "operations.merge.damage_relation",
84680             { relation: _mainPresetIndex.item("type/" + disabled).name() }
84681           );
84682         }
84683         return _t.append("operations.merge." + disabled);
84684       }
84685       return _t.append("operations.merge.description");
84686     };
84687     operation2.annotation = function() {
84688       return _t("operations.merge.annotation", { n: selectedIDs.length });
84689     };
84690     operation2.id = "merge";
84691     operation2.keys = [_t("operations.merge.key")];
84692     operation2.title = _t.append("operations.merge.title");
84693     operation2.behavior = behaviorOperation(context).which(operation2);
84694     return operation2;
84695   }
84696
84697   // modules/operations/paste.js
84698   function operationPaste(context) {
84699     var _pastePoint;
84700     var operation2 = function() {
84701       if (!_pastePoint)
84702         return;
84703       var oldIDs = context.copyIDs();
84704       if (!oldIDs.length)
84705         return;
84706       var projection2 = context.projection;
84707       var extent = geoExtent();
84708       var oldGraph = context.copyGraph();
84709       var newIDs = [];
84710       var action = actionCopyEntities(oldIDs, oldGraph);
84711       context.perform(action);
84712       var copies = action.copies();
84713       var originals = /* @__PURE__ */ new Set();
84714       Object.values(copies).forEach(function(entity) {
84715         originals.add(entity.id);
84716       });
84717       for (var id2 in copies) {
84718         var oldEntity = oldGraph.entity(id2);
84719         var newEntity = copies[id2];
84720         extent._extend(oldEntity.extent(oldGraph));
84721         var parents = context.graph().parentWays(newEntity);
84722         var parentCopied = parents.some(function(parent) {
84723           return originals.has(parent.id);
84724         });
84725         if (!parentCopied) {
84726           newIDs.push(newEntity.id);
84727         }
84728       }
84729       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
84730       var delta = geoVecSubtract(_pastePoint, copyPoint);
84731       context.replace(actionMove(newIDs, delta, projection2), operation2.annotation());
84732       context.enter(modeSelect(context, newIDs));
84733     };
84734     operation2.point = function(val) {
84735       _pastePoint = val;
84736       return operation2;
84737     };
84738     operation2.available = function() {
84739       return context.mode().id === "browse";
84740     };
84741     operation2.disabled = function() {
84742       return !context.copyIDs().length;
84743     };
84744     operation2.tooltip = function() {
84745       var oldGraph = context.copyGraph();
84746       var ids = context.copyIDs();
84747       if (!ids.length) {
84748         return _t.append("operations.paste.nothing_copied");
84749       }
84750       return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length });
84751     };
84752     operation2.annotation = function() {
84753       var ids = context.copyIDs();
84754       return _t("operations.paste.annotation", { n: ids.length });
84755     };
84756     operation2.id = "paste";
84757     operation2.keys = [uiCmd("\u2318V")];
84758     operation2.title = _t.append("operations.paste.title");
84759     return operation2;
84760   }
84761
84762   // modules/operations/reverse.js
84763   function operationReverse(context, selectedIDs) {
84764     var operation2 = function() {
84765       context.perform(function combinedReverseAction(graph) {
84766         actions().forEach(function(action) {
84767           graph = action(graph);
84768         });
84769         return graph;
84770       }, operation2.annotation());
84771       context.validator().validate();
84772     };
84773     function actions(situation) {
84774       return selectedIDs.map(function(entityID) {
84775         var entity = context.hasEntity(entityID);
84776         if (!entity)
84777           return null;
84778         if (situation === "toolbar") {
84779           if (entity.type === "way" && (!entity.isOneWay() && !entity.isSided()))
84780             return null;
84781         }
84782         var geometry = entity.geometry(context.graph());
84783         if (entity.type !== "node" && geometry !== "line")
84784           return null;
84785         var action = actionReverse(entityID);
84786         if (action.disabled(context.graph()))
84787           return null;
84788         return action;
84789       }).filter(Boolean);
84790     }
84791     function reverseTypeID() {
84792       var acts = actions();
84793       var nodeActionCount = acts.filter(function(act) {
84794         var entity = context.hasEntity(act.entityID());
84795         return entity && entity.type === "node";
84796       }).length;
84797       if (nodeActionCount === 0)
84798         return "line";
84799       if (nodeActionCount === acts.length)
84800         return "point";
84801       return "feature";
84802     }
84803     operation2.available = function(situation) {
84804       return actions(situation).length > 0;
84805     };
84806     operation2.disabled = function() {
84807       return false;
84808     };
84809     operation2.tooltip = function() {
84810       return _t.append("operations.reverse.description." + reverseTypeID());
84811     };
84812     operation2.annotation = function() {
84813       var acts = actions();
84814       return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length });
84815     };
84816     operation2.id = "reverse";
84817     operation2.keys = [_t("operations.reverse.key")];
84818     operation2.title = _t.append("operations.reverse.title");
84819     operation2.behavior = behaviorOperation(context).which(operation2);
84820     return operation2;
84821   }
84822
84823   // modules/operations/split.js
84824   function operationSplit(context, selectedIDs) {
84825     var _vertexIds = selectedIDs.filter(function(id2) {
84826       return context.graph().geometry(id2) === "vertex";
84827     });
84828     var _selectedWayIds = selectedIDs.filter(function(id2) {
84829       var entity = context.graph().hasEntity(id2);
84830       return entity && entity.type === "way";
84831     });
84832     var _isAvailable = _vertexIds.length > 0 && _vertexIds.length + _selectedWayIds.length === selectedIDs.length;
84833     var _action = actionSplit(_vertexIds);
84834     var _ways = [];
84835     var _geometry = "feature";
84836     var _waysAmount = "single";
84837     var _nodesAmount = _vertexIds.length === 1 ? "single" : "multiple";
84838     if (_isAvailable) {
84839       if (_selectedWayIds.length)
84840         _action.limitWays(_selectedWayIds);
84841       _ways = _action.ways(context.graph());
84842       var geometries = {};
84843       _ways.forEach(function(way) {
84844         geometries[way.geometry(context.graph())] = true;
84845       });
84846       if (Object.keys(geometries).length === 1) {
84847         _geometry = Object.keys(geometries)[0];
84848       }
84849       _waysAmount = _ways.length === 1 ? "single" : "multiple";
84850     }
84851     var operation2 = function() {
84852       var difference2 = context.perform(_action, operation2.annotation());
84853       var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) {
84854         return context.entity(id2).type === "way";
84855       }));
84856       context.enter(modeSelect(context, idsToSelect));
84857     };
84858     operation2.relatedEntityIds = function() {
84859       return _selectedWayIds.length ? [] : _ways.map((way) => way.id);
84860     };
84861     operation2.available = function() {
84862       return _isAvailable;
84863     };
84864     operation2.disabled = function() {
84865       var reason = _action.disabled(context.graph());
84866       if (reason) {
84867         return reason;
84868       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84869         return "connected_to_hidden";
84870       }
84871       return false;
84872     };
84873     operation2.tooltip = function() {
84874       var disable = operation2.disabled();
84875       return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node");
84876     };
84877     operation2.annotation = function() {
84878       return _t("operations.split.annotation." + _geometry, { n: _ways.length });
84879     };
84880     operation2.icon = function() {
84881       if (_waysAmount === "multiple") {
84882         return "#iD-operation-split-multiple";
84883       } else {
84884         return "#iD-operation-split";
84885       }
84886     };
84887     operation2.id = "split";
84888     operation2.keys = [_t("operations.split.key")];
84889     operation2.title = _t.append("operations.split.title");
84890     operation2.behavior = behaviorOperation(context).which(operation2);
84891     return operation2;
84892   }
84893
84894   // modules/operations/straighten.js
84895   function operationStraighten(context, selectedIDs) {
84896     var _wayIDs = selectedIDs.filter(function(id2) {
84897       return id2.charAt(0) === "w";
84898     });
84899     var _nodeIDs = selectedIDs.filter(function(id2) {
84900       return id2.charAt(0) === "n";
84901     });
84902     var _amount = (_wayIDs.length ? _wayIDs : _nodeIDs).length === 1 ? "single" : "multiple";
84903     var _nodes = utilGetAllNodes(selectedIDs, context.graph());
84904     var _coords = _nodes.map(function(n3) {
84905       return n3.loc;
84906     });
84907     var _extent = utilTotalExtent(selectedIDs, context.graph());
84908     var _action = chooseAction();
84909     var _geometry;
84910     function chooseAction() {
84911       if (_wayIDs.length === 0 && _nodeIDs.length > 2) {
84912         _geometry = "point";
84913         return actionStraightenNodes(_nodeIDs, context.projection);
84914       } else if (_wayIDs.length > 0 && (_nodeIDs.length === 0 || _nodeIDs.length === 2)) {
84915         var startNodeIDs = [];
84916         var endNodeIDs = [];
84917         for (var i3 = 0; i3 < selectedIDs.length; i3++) {
84918           var entity = context.entity(selectedIDs[i3]);
84919           if (entity.type === "node") {
84920             continue;
84921           } else if (entity.type !== "way" || entity.isClosed()) {
84922             return null;
84923           }
84924           startNodeIDs.push(entity.first());
84925           endNodeIDs.push(entity.last());
84926         }
84927         startNodeIDs = startNodeIDs.filter(function(n3) {
84928           return startNodeIDs.indexOf(n3) === startNodeIDs.lastIndexOf(n3);
84929         });
84930         endNodeIDs = endNodeIDs.filter(function(n3) {
84931           return endNodeIDs.indexOf(n3) === endNodeIDs.lastIndexOf(n3);
84932         });
84933         if (utilArrayDifference(startNodeIDs, endNodeIDs).length + utilArrayDifference(endNodeIDs, startNodeIDs).length !== 2)
84934           return null;
84935         var wayNodeIDs = utilGetAllNodes(_wayIDs, context.graph()).map(function(node) {
84936           return node.id;
84937         });
84938         if (wayNodeIDs.length <= 2)
84939           return null;
84940         if (_nodeIDs.length === 2 && (wayNodeIDs.indexOf(_nodeIDs[0]) === -1 || wayNodeIDs.indexOf(_nodeIDs[1]) === -1))
84941           return null;
84942         if (_nodeIDs.length) {
84943           _extent = utilTotalExtent(_nodeIDs, context.graph());
84944         }
84945         _geometry = "line";
84946         return actionStraightenWay(selectedIDs, context.projection);
84947       }
84948       return null;
84949     }
84950     function operation2() {
84951       if (!_action)
84952         return;
84953       context.perform(_action, operation2.annotation());
84954       window.setTimeout(function() {
84955         context.validator().validate();
84956       }, 300);
84957     }
84958     operation2.available = function() {
84959       return Boolean(_action);
84960     };
84961     operation2.disabled = function() {
84962       var reason = _action.disabled(context.graph());
84963       if (reason) {
84964         return reason;
84965       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
84966         return "too_large";
84967       } else if (someMissing()) {
84968         return "not_downloaded";
84969       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84970         return "connected_to_hidden";
84971       }
84972       return false;
84973       function someMissing() {
84974         if (context.inIntro())
84975           return false;
84976         var osm = context.connection();
84977         if (osm) {
84978           var missing = _coords.filter(function(loc) {
84979             return !osm.isDataLoaded(loc);
84980           });
84981           if (missing.length) {
84982             missing.forEach(function(loc) {
84983               context.loadTileAtLoc(loc);
84984             });
84985             return true;
84986           }
84987         }
84988         return false;
84989       }
84990     };
84991     operation2.tooltip = function() {
84992       var disable = operation2.disabled();
84993       return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s"));
84994     };
84995     operation2.annotation = function() {
84996       return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length });
84997     };
84998     operation2.id = "straighten";
84999     operation2.keys = [_t("operations.straighten.key")];
85000     operation2.title = _t.append("operations.straighten.title");
85001     operation2.behavior = behaviorOperation(context).which(operation2);
85002     return operation2;
85003   }
85004
85005   // modules/modes/select.js
85006   function modeSelect(context, selectedIDs) {
85007     var mode = {
85008       id: "select",
85009       button: "browse"
85010     };
85011     var keybinding = utilKeybinding("select");
85012     var _breatheBehavior = behaviorBreathe(context);
85013     var _modeDragNode = modeDragNode(context);
85014     var _selectBehavior;
85015     var _behaviors = [];
85016     var _operations = [];
85017     var _newFeature = false;
85018     var _follow = false;
85019     var _focusedParentWayId;
85020     var _focusedVertexIds;
85021     function singular() {
85022       if (selectedIDs && selectedIDs.length === 1) {
85023         return context.hasEntity(selectedIDs[0]);
85024       }
85025     }
85026     function selectedEntities() {
85027       return selectedIDs.map(function(id2) {
85028         return context.hasEntity(id2);
85029       }).filter(Boolean);
85030     }
85031     function checkSelectedIDs() {
85032       var ids = [];
85033       if (Array.isArray(selectedIDs)) {
85034         ids = selectedIDs.filter(function(id2) {
85035           return context.hasEntity(id2);
85036         });
85037       }
85038       if (!ids.length) {
85039         context.enter(modeBrowse(context));
85040         return false;
85041       } else if (selectedIDs.length > 1 && ids.length === 1 || selectedIDs.length === 1 && ids.length > 1) {
85042         context.enter(modeSelect(context, ids));
85043         return false;
85044       }
85045       selectedIDs = ids;
85046       return true;
85047     }
85048     function parentWaysIdsOfSelection(onlyCommonParents) {
85049       var graph = context.graph();
85050       var parents = [];
85051       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85052         var entity = context.hasEntity(selectedIDs[i3]);
85053         if (!entity || entity.geometry(graph) !== "vertex") {
85054           return [];
85055         }
85056         var currParents = graph.parentWays(entity).map(function(w2) {
85057           return w2.id;
85058         });
85059         if (!parents.length) {
85060           parents = currParents;
85061           continue;
85062         }
85063         parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
85064         if (!parents.length) {
85065           return [];
85066         }
85067       }
85068       return parents;
85069     }
85070     function childNodeIdsOfSelection(onlyCommon) {
85071       var graph = context.graph();
85072       var childs = [];
85073       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85074         var entity = context.hasEntity(selectedIDs[i3]);
85075         if (!entity || !["area", "line"].includes(entity.geometry(graph))) {
85076           return [];
85077         }
85078         var currChilds = graph.childNodes(entity).map(function(node) {
85079           return node.id;
85080         });
85081         if (!childs.length) {
85082           childs = currChilds;
85083           continue;
85084         }
85085         childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
85086         if (!childs.length) {
85087           return [];
85088         }
85089       }
85090       return childs;
85091     }
85092     function checkFocusedParent() {
85093       if (_focusedParentWayId) {
85094         var parents = parentWaysIdsOfSelection(true);
85095         if (parents.indexOf(_focusedParentWayId) === -1)
85096           _focusedParentWayId = null;
85097       }
85098     }
85099     function parentWayIdForVertexNavigation() {
85100       var parentIds = parentWaysIdsOfSelection(true);
85101       if (_focusedParentWayId && parentIds.indexOf(_focusedParentWayId) !== -1) {
85102         return _focusedParentWayId;
85103       }
85104       return parentIds.length ? parentIds[0] : null;
85105     }
85106     mode.selectedIDs = function(val) {
85107       if (!arguments.length)
85108         return selectedIDs;
85109       selectedIDs = val;
85110       return mode;
85111     };
85112     mode.zoomToSelected = function() {
85113       context.map().zoomToEase(selectedEntities());
85114     };
85115     mode.newFeature = function(val) {
85116       if (!arguments.length)
85117         return _newFeature;
85118       _newFeature = val;
85119       return mode;
85120     };
85121     mode.selectBehavior = function(val) {
85122       if (!arguments.length)
85123         return _selectBehavior;
85124       _selectBehavior = val;
85125       return mode;
85126     };
85127     mode.follow = function(val) {
85128       if (!arguments.length)
85129         return _follow;
85130       _follow = val;
85131       return mode;
85132     };
85133     function loadOperations() {
85134       _operations.forEach(function(operation2) {
85135         if (operation2.behavior) {
85136           context.uninstall(operation2.behavior);
85137         }
85138       });
85139       _operations = Object.values(operations_exports).map(function(o2) {
85140         return o2(context, selectedIDs);
85141       }).filter(function(o2) {
85142         return o2.id !== "delete" && o2.id !== "downgrade" && o2.id !== "copy";
85143       }).concat([
85144         // group copy/downgrade/delete operation together at the end of the list
85145         operationCopy(context, selectedIDs),
85146         operationDowngrade(context, selectedIDs),
85147         operationDelete(context, selectedIDs)
85148       ]).filter(function(operation2) {
85149         return operation2.available();
85150       });
85151       _operations.forEach(function(operation2) {
85152         if (operation2.behavior) {
85153           context.install(operation2.behavior);
85154         }
85155       });
85156       context.ui().closeEditMenu();
85157     }
85158     mode.operations = function() {
85159       return _operations;
85160     };
85161     mode.enter = function() {
85162       if (!checkSelectedIDs())
85163         return;
85164       context.features().forceVisible(selectedIDs);
85165       _modeDragNode.restoreSelectedIDs(selectedIDs);
85166       loadOperations();
85167       if (!_behaviors.length) {
85168         if (!_selectBehavior)
85169           _selectBehavior = behaviorSelect(context);
85170         _behaviors = [
85171           behaviorPaste(context),
85172           _breatheBehavior,
85173           behaviorHover(context).on("hover", context.ui().sidebar.hoverModeSelect),
85174           _selectBehavior,
85175           behaviorLasso(context),
85176           _modeDragNode.behavior,
85177           modeDragNote(context).behavior
85178         ];
85179       }
85180       _behaviors.forEach(context.install);
85181       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);
85182       select_default2(document).call(keybinding);
85183       context.ui().sidebar.select(selectedIDs, _newFeature);
85184       context.history().on("change.select", function() {
85185         loadOperations();
85186         selectElements();
85187       }).on("undone.select", checkSelectedIDs).on("redone.select", checkSelectedIDs);
85188       context.map().on("drawn.select", selectElements).on("crossEditableZoom.select", function() {
85189         selectElements();
85190         _breatheBehavior.restartIfNeeded(context.surface());
85191       });
85192       context.map().doubleUpHandler().on("doubleUp.modeSelect", didDoubleUp);
85193       selectElements();
85194       if (_follow) {
85195         var extent = geoExtent();
85196         var graph = context.graph();
85197         selectedIDs.forEach(function(id2) {
85198           var entity = context.entity(id2);
85199           extent._extend(entity.extent(graph));
85200         });
85201         var loc = extent.center();
85202         context.map().centerEase(loc);
85203         _follow = false;
85204       }
85205       function nudgeSelection(delta) {
85206         return function() {
85207           if (!context.map().withinEditableZoom())
85208             return;
85209           var moveOp = operationMove(context, selectedIDs);
85210           if (moveOp.disabled()) {
85211             context.ui().flash.duration(4e3).iconName("#iD-operation-" + moveOp.id).iconClass("operation disabled").label(moveOp.tooltip())();
85212           } else {
85213             context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
85214             context.validator().validate();
85215           }
85216         };
85217       }
85218       function scaleSelection(factor) {
85219         return function() {
85220           if (!context.map().withinEditableZoom())
85221             return;
85222           let nodes = utilGetAllNodes(selectedIDs, context.graph());
85223           let isUp = factor > 1;
85224           if (nodes.length <= 1)
85225             return;
85226           let extent2 = utilTotalExtent(selectedIDs, context.graph());
85227           function scalingDisabled() {
85228             if (tooSmall()) {
85229               return "too_small";
85230             } else if (extent2.percentContainedIn(context.map().extent()) < 0.8) {
85231               return "too_large";
85232             } else if (someMissing() || selectedIDs.some(incompleteRelation)) {
85233               return "not_downloaded";
85234             } else if (selectedIDs.some(context.hasHiddenConnections)) {
85235               return "connected_to_hidden";
85236             }
85237             return false;
85238             function tooSmall() {
85239               if (isUp)
85240                 return false;
85241               let dLon = Math.abs(extent2[1][0] - extent2[0][0]);
85242               let dLat = Math.abs(extent2[1][1] - extent2[0][1]);
85243               return dLon < geoMetersToLon(1, extent2[1][1]) && dLat < geoMetersToLat(1);
85244             }
85245             function someMissing() {
85246               if (context.inIntro())
85247                 return false;
85248               let osm = context.connection();
85249               if (osm) {
85250                 let missing = nodes.filter(function(n3) {
85251                   return !osm.isDataLoaded(n3.loc);
85252                 });
85253                 if (missing.length) {
85254                   missing.forEach(function(loc2) {
85255                     context.loadTileAtLoc(loc2);
85256                   });
85257                   return true;
85258                 }
85259               }
85260               return false;
85261             }
85262             function incompleteRelation(id2) {
85263               let entity = context.entity(id2);
85264               return entity.type === "relation" && !entity.isComplete(context.graph());
85265             }
85266           }
85267           const disabled = scalingDisabled();
85268           if (disabled) {
85269             let multi = selectedIDs.length === 1 ? "single" : "multiple";
85270             context.ui().flash.duration(4e3).iconName("#iD-icon-no").iconClass("operation disabled").label(_t.append("operations.scale." + disabled + "." + multi))();
85271           } else {
85272             const pivot = context.projection(extent2.center());
85273             const annotation = _t("operations.scale.annotation." + (isUp ? "up" : "down") + ".feature", { n: selectedIDs.length });
85274             context.perform(actionScale(selectedIDs, pivot, factor, context.projection), annotation);
85275             context.validator().validate();
85276           }
85277         };
85278       }
85279       function didDoubleUp(d3_event, loc2) {
85280         if (!context.map().withinEditableZoom())
85281           return;
85282         var target = select_default2(d3_event.target);
85283         var datum2 = target.datum();
85284         var entity = datum2 && datum2.properties && datum2.properties.entity;
85285         if (!entity)
85286           return;
85287         if (entity instanceof osmWay && target.classed("target")) {
85288           var choice = geoChooseEdge(context.graph().childNodes(entity), loc2, context.projection);
85289           var prev = entity.nodes[choice.index - 1];
85290           var next = entity.nodes[choice.index];
85291           context.perform(
85292             actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
85293             _t("operations.add.annotation.vertex")
85294           );
85295           context.validator().validate();
85296         } else if (entity.type === "midpoint") {
85297           context.perform(
85298             actionAddMidpoint({ loc: entity.loc, edge: entity.edge }, osmNode()),
85299             _t("operations.add.annotation.vertex")
85300           );
85301           context.validator().validate();
85302         }
85303       }
85304       function selectElements() {
85305         if (!checkSelectedIDs())
85306           return;
85307         var surface = context.surface();
85308         surface.selectAll(".selected-member").classed("selected-member", false);
85309         surface.selectAll(".selected").classed("selected", false);
85310         surface.selectAll(".related").classed("related", false);
85311         checkFocusedParent();
85312         if (_focusedParentWayId) {
85313           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85314         }
85315         if (context.map().withinEditableZoom()) {
85316           surface.selectAll(utilDeepMemberSelector(
85317             selectedIDs,
85318             context.graph(),
85319             true
85320             /* skipMultipolgonMembers */
85321           )).classed("selected-member", true);
85322           surface.selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())).classed("selected", true);
85323         }
85324       }
85325       function esc() {
85326         if (context.container().select(".combobox").size())
85327           return;
85328         context.enter(modeBrowse(context));
85329       }
85330       function firstVertex(d3_event) {
85331         d3_event.preventDefault();
85332         var entity = singular();
85333         var parentId = parentWayIdForVertexNavigation();
85334         var way;
85335         if (entity && entity.type === "way") {
85336           way = entity;
85337         } else if (parentId) {
85338           way = context.entity(parentId);
85339         }
85340         _focusedParentWayId = way && way.id;
85341         if (way) {
85342           context.enter(
85343             mode.selectedIDs([way.first()]).follow(true)
85344           );
85345         }
85346       }
85347       function lastVertex(d3_event) {
85348         d3_event.preventDefault();
85349         var entity = singular();
85350         var parentId = parentWayIdForVertexNavigation();
85351         var way;
85352         if (entity && entity.type === "way") {
85353           way = entity;
85354         } else if (parentId) {
85355           way = context.entity(parentId);
85356         }
85357         _focusedParentWayId = way && way.id;
85358         if (way) {
85359           context.enter(
85360             mode.selectedIDs([way.last()]).follow(true)
85361           );
85362         }
85363       }
85364       function previousVertex(d3_event) {
85365         d3_event.preventDefault();
85366         var parentId = parentWayIdForVertexNavigation();
85367         _focusedParentWayId = parentId;
85368         if (!parentId)
85369           return;
85370         var way = context.entity(parentId);
85371         var length2 = way.nodes.length;
85372         var curr = way.nodes.indexOf(selectedIDs[0]);
85373         var index = -1;
85374         if (curr > 0) {
85375           index = curr - 1;
85376         } else if (way.isClosed()) {
85377           index = length2 - 2;
85378         }
85379         if (index !== -1) {
85380           context.enter(
85381             mode.selectedIDs([way.nodes[index]]).follow(true)
85382           );
85383         }
85384       }
85385       function nextVertex(d3_event) {
85386         d3_event.preventDefault();
85387         var parentId = parentWayIdForVertexNavigation();
85388         _focusedParentWayId = parentId;
85389         if (!parentId)
85390           return;
85391         var way = context.entity(parentId);
85392         var length2 = way.nodes.length;
85393         var curr = way.nodes.indexOf(selectedIDs[0]);
85394         var index = -1;
85395         if (curr < length2 - 1) {
85396           index = curr + 1;
85397         } else if (way.isClosed()) {
85398           index = 0;
85399         }
85400         if (index !== -1) {
85401           context.enter(
85402             mode.selectedIDs([way.nodes[index]]).follow(true)
85403           );
85404         }
85405       }
85406       function focusNextParent(d3_event) {
85407         d3_event.preventDefault();
85408         var parents = parentWaysIdsOfSelection(true);
85409         if (!parents || parents.length < 2)
85410           return;
85411         var index = parents.indexOf(_focusedParentWayId);
85412         if (index < 0 || index > parents.length - 2) {
85413           _focusedParentWayId = parents[0];
85414         } else {
85415           _focusedParentWayId = parents[index + 1];
85416         }
85417         var surface = context.surface();
85418         surface.selectAll(".related").classed("related", false);
85419         if (_focusedParentWayId) {
85420           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85421         }
85422       }
85423       function selectParent(d3_event) {
85424         d3_event.preventDefault();
85425         var currentSelectedIds = mode.selectedIDs();
85426         var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
85427         if (!parentIds.length)
85428           return;
85429         context.enter(
85430           mode.selectedIDs(parentIds)
85431         );
85432         _focusedVertexIds = currentSelectedIds;
85433       }
85434       function selectChild(d3_event) {
85435         d3_event.preventDefault();
85436         var currentSelectedIds = mode.selectedIDs();
85437         var childIds = _focusedVertexIds ? _focusedVertexIds.filter((id2) => context.hasEntity(id2)) : childNodeIdsOfSelection(true);
85438         if (!childIds || !childIds.length)
85439           return;
85440         if (currentSelectedIds.length === 1)
85441           _focusedParentWayId = currentSelectedIds[0];
85442         context.enter(
85443           mode.selectedIDs(childIds)
85444         );
85445       }
85446     };
85447     mode.exit = function() {
85448       _newFeature = false;
85449       _focusedVertexIds = null;
85450       _operations.forEach(function(operation2) {
85451         if (operation2.behavior) {
85452           context.uninstall(operation2.behavior);
85453         }
85454       });
85455       _operations = [];
85456       _behaviors.forEach(context.uninstall);
85457       select_default2(document).call(keybinding.unbind);
85458       context.ui().closeEditMenu();
85459       context.history().on("change.select", null).on("undone.select", null).on("redone.select", null);
85460       var surface = context.surface();
85461       surface.selectAll(".selected-member").classed("selected-member", false);
85462       surface.selectAll(".selected").classed("selected", false);
85463       surface.selectAll(".highlighted").classed("highlighted", false);
85464       surface.selectAll(".related").classed("related", false);
85465       context.map().on("drawn.select", null);
85466       context.ui().sidebar.hide();
85467       context.features().forceVisible([]);
85468       var entity = singular();
85469       if (_newFeature && entity && entity.type === "relation" && // no tags
85470       Object.keys(entity.tags).length === 0 && // no parent relations
85471       context.graph().parentRelations(entity).length === 0 && // no members or one member with no role
85472       (entity.members.length === 0 || entity.members.length === 1 && !entity.members[0].role)) {
85473         var deleteAction = actionDeleteRelation(
85474           entity.id,
85475           true
85476           /* don't delete untagged members */
85477         );
85478         context.perform(deleteAction, _t("operations.delete.annotation.relation"));
85479         context.validator().validate();
85480       }
85481     };
85482     return mode;
85483   }
85484
85485   // modules/behavior/lasso.js
85486   function behaviorLasso(context) {
85487     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
85488     var behavior = function(selection2) {
85489       var lasso;
85490       function pointerdown(d3_event) {
85491         var button = 0;
85492         if (d3_event.button === button && d3_event.shiftKey === true) {
85493           lasso = null;
85494           select_default2(window).on(_pointerPrefix + "move.lasso", pointermove).on(_pointerPrefix + "up.lasso", pointerup);
85495           d3_event.stopPropagation();
85496         }
85497       }
85498       function pointermove() {
85499         if (!lasso) {
85500           lasso = uiLasso(context);
85501           context.surface().call(lasso);
85502         }
85503         lasso.p(context.map().mouse());
85504       }
85505       function normalize2(a2, b2) {
85506         return [
85507           [Math.min(a2[0], b2[0]), Math.min(a2[1], b2[1])],
85508           [Math.max(a2[0], b2[0]), Math.max(a2[1], b2[1])]
85509         ];
85510       }
85511       function lassoed() {
85512         if (!lasso)
85513           return [];
85514         var graph = context.graph();
85515         var limitToNodes;
85516         if (context.map().editableDataEnabled(
85517           true
85518           /* skipZoomCheck */
85519         ) && context.map().isInWideSelection()) {
85520           limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
85521         } else if (!context.map().editableDataEnabled()) {
85522           return [];
85523         }
85524         var bounds = lasso.extent().map(context.projection.invert);
85525         var extent = geoExtent(normalize2(bounds[0], bounds[1]));
85526         var intersects = context.history().intersects(extent).filter(function(entity) {
85527           return entity.type === "node" && (!limitToNodes || limitToNodes.has(entity)) && geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) && !context.features().isHidden(entity, graph, entity.geometry(graph));
85528         });
85529         intersects.sort(function(node1, node2) {
85530           var parents1 = graph.parentWays(node1);
85531           var parents2 = graph.parentWays(node2);
85532           if (parents1.length && parents2.length) {
85533             var sharedParents = utilArrayIntersection(parents1, parents2);
85534             if (sharedParents.length) {
85535               var sharedParentNodes = sharedParents[0].nodes;
85536               return sharedParentNodes.indexOf(node1.id) - sharedParentNodes.indexOf(node2.id);
85537             } else {
85538               return Number(parents1[0].id.slice(1)) - Number(parents2[0].id.slice(1));
85539             }
85540           } else if (parents1.length || parents2.length) {
85541             return parents1.length - parents2.length;
85542           }
85543           return node1.loc[0] - node2.loc[0];
85544         });
85545         return intersects.map(function(entity) {
85546           return entity.id;
85547         });
85548       }
85549       function pointerup() {
85550         select_default2(window).on(_pointerPrefix + "move.lasso", null).on(_pointerPrefix + "up.lasso", null);
85551         if (!lasso)
85552           return;
85553         var ids = lassoed();
85554         lasso.close();
85555         if (ids.length) {
85556           context.enter(modeSelect(context, ids));
85557         }
85558       }
85559       selection2.on(_pointerPrefix + "down.lasso", pointerdown);
85560     };
85561     behavior.off = function(selection2) {
85562       selection2.on(_pointerPrefix + "down.lasso", null);
85563     };
85564     return behavior;
85565   }
85566
85567   // modules/modes/browse.js
85568   function modeBrowse(context) {
85569     var mode = {
85570       button: "browse",
85571       id: "browse",
85572       title: _t.append("modes.browse.title"),
85573       description: _t.append("modes.browse.description")
85574     };
85575     var sidebar;
85576     var _selectBehavior;
85577     var _behaviors = [];
85578     mode.selectBehavior = function(val) {
85579       if (!arguments.length)
85580         return _selectBehavior;
85581       _selectBehavior = val;
85582       return mode;
85583     };
85584     mode.enter = function() {
85585       if (!_behaviors.length) {
85586         if (!_selectBehavior)
85587           _selectBehavior = behaviorSelect(context);
85588         _behaviors = [
85589           behaviorPaste(context),
85590           behaviorHover(context).on("hover", context.ui().sidebar.hover),
85591           _selectBehavior,
85592           behaviorLasso(context),
85593           modeDragNode(context).behavior,
85594           modeDragNote(context).behavior
85595         ];
85596       }
85597       _behaviors.forEach(context.install);
85598       if (document.activeElement && document.activeElement.blur) {
85599         document.activeElement.blur();
85600       }
85601       if (sidebar) {
85602         context.ui().sidebar.show(sidebar);
85603       } else {
85604         context.ui().sidebar.select(null);
85605       }
85606     };
85607     mode.exit = function() {
85608       context.ui().sidebar.hover.cancel();
85609       _behaviors.forEach(context.uninstall);
85610       if (sidebar) {
85611         context.ui().sidebar.hide();
85612       }
85613     };
85614     mode.sidebar = function(_2) {
85615       if (!arguments.length)
85616         return sidebar;
85617       sidebar = _2;
85618       return mode;
85619     };
85620     mode.operations = function() {
85621       return [operationPaste(context)];
85622     };
85623     return mode;
85624   }
85625
85626   // modules/behavior/add_way.js
85627   function behaviorAddWay(context) {
85628     var dispatch14 = dispatch_default("start", "startFromWay", "startFromNode");
85629     var draw = behaviorDraw(context);
85630     function behavior(surface) {
85631       draw.on("click", function() {
85632         dispatch14.apply("start", this, arguments);
85633       }).on("clickWay", function() {
85634         dispatch14.apply("startFromWay", this, arguments);
85635       }).on("clickNode", function() {
85636         dispatch14.apply("startFromNode", this, arguments);
85637       }).on("cancel", behavior.cancel).on("finish", behavior.cancel);
85638       context.map().dblclickZoomEnable(false);
85639       surface.call(draw);
85640     }
85641     behavior.off = function(surface) {
85642       surface.call(draw.off);
85643     };
85644     behavior.cancel = function() {
85645       window.setTimeout(function() {
85646         context.map().dblclickZoomEnable(true);
85647       }, 1e3);
85648       context.enter(modeBrowse(context));
85649     };
85650     return utilRebind(behavior, dispatch14, "on");
85651   }
85652
85653   // modules/behavior/hash.js
85654   function behaviorHash(context) {
85655     var _cachedHash = null;
85656     var _latitudeLimit = 90 - 1e-8;
85657     function computedHashParameters() {
85658       var map2 = context.map();
85659       var center = map2.center();
85660       var zoom = map2.zoom();
85661       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
85662       var oldParams = utilObjectOmit(
85663         utilStringQs(window.location.hash),
85664         ["comment", "source", "hashtags", "walkthrough"]
85665       );
85666       var newParams = {};
85667       delete oldParams.id;
85668       var selected = context.selectedIDs().filter(function(id2) {
85669         return context.hasEntity(id2);
85670       });
85671       if (selected.length) {
85672         newParams.id = selected.join(",");
85673       }
85674       newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
85675       return Object.assign(oldParams, newParams);
85676     }
85677     function computedHash() {
85678       return "#" + utilQsString(computedHashParameters(), true);
85679     }
85680     function computedTitle(includeChangeCount) {
85681       var baseTitle = context.documentTitleBase() || "iD";
85682       var contextual;
85683       var changeCount;
85684       var titleID;
85685       var selected = context.selectedIDs().filter(function(id2) {
85686         return context.hasEntity(id2);
85687       });
85688       if (selected.length) {
85689         var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph());
85690         if (selected.length > 1) {
85691           contextual = _t("title.labeled_and_more", {
85692             labeled: firstLabel,
85693             count: selected.length - 1
85694           });
85695         } else {
85696           contextual = firstLabel;
85697         }
85698         titleID = "context";
85699       }
85700       if (includeChangeCount) {
85701         changeCount = context.history().difference().summary().length;
85702         if (changeCount > 0) {
85703           titleID = contextual ? "changes_context" : "changes";
85704         }
85705       }
85706       if (titleID) {
85707         return _t("title.format." + titleID, {
85708           changes: changeCount,
85709           base: baseTitle,
85710           context: contextual
85711         });
85712       }
85713       return baseTitle;
85714     }
85715     function updateTitle(includeChangeCount) {
85716       if (!context.setsDocumentTitle())
85717         return;
85718       var newTitle = computedTitle(includeChangeCount);
85719       if (document.title !== newTitle) {
85720         document.title = newTitle;
85721       }
85722     }
85723     function updateHashIfNeeded() {
85724       if (context.inIntro())
85725         return;
85726       var latestHash = computedHash();
85727       if (_cachedHash !== latestHash) {
85728         _cachedHash = latestHash;
85729         window.history.replaceState(null, computedTitle(
85730           false
85731           /* includeChangeCount */
85732         ), latestHash);
85733         updateTitle(
85734           true
85735           /* includeChangeCount */
85736         );
85737         const q2 = utilStringQs(latestHash);
85738         if (q2.map) {
85739           corePreferences("map-location", q2.map);
85740         }
85741       }
85742     }
85743     var _throttledUpdate = throttle_default(updateHashIfNeeded, 500);
85744     var _throttledUpdateTitle = throttle_default(function() {
85745       updateTitle(
85746         true
85747         /* includeChangeCount */
85748       );
85749     }, 500);
85750     function hashchange() {
85751       if (window.location.hash === _cachedHash)
85752         return;
85753       _cachedHash = window.location.hash;
85754       var q2 = utilStringQs(_cachedHash);
85755       var mapArgs = (q2.map || "").split("/").map(Number);
85756       if (mapArgs.length < 3 || mapArgs.some(isNaN)) {
85757         updateHashIfNeeded();
85758       } else {
85759         if (_cachedHash === computedHash())
85760           return;
85761         var mode = context.mode();
85762         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85763         if (q2.id && mode) {
85764           var ids = q2.id.split(",").filter(function(id2) {
85765             return context.hasEntity(id2);
85766           });
85767           if (ids.length && (mode.id === "browse" || mode.id === "select" && !utilArrayIdentical(mode.selectedIDs(), ids))) {
85768             context.enter(modeSelect(context, ids));
85769             return;
85770           }
85771         }
85772         var center = context.map().center();
85773         var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]);
85774         var maxdist = 500;
85775         if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) {
85776           context.enter(modeBrowse(context));
85777           return;
85778         }
85779       }
85780     }
85781     function behavior() {
85782       context.map().on("move.behaviorHash", _throttledUpdate);
85783       context.history().on("change.behaviorHash", _throttledUpdateTitle);
85784       context.on("enter.behaviorHash", _throttledUpdate);
85785       select_default2(window).on("hashchange.behaviorHash", hashchange);
85786       var q2 = utilStringQs(window.location.hash);
85787       if (q2.id) {
85788         context.zoomToEntity(q2.id.split(",")[0], !q2.map);
85789       }
85790       if (q2.walkthrough === "true") {
85791         behavior.startWalkthrough = true;
85792       }
85793       if (q2.map) {
85794         behavior.hadLocation = true;
85795       } else if (!q2.id && corePreferences("map-location")) {
85796         const mapArgs = corePreferences("map-location").split("/").map(Number);
85797         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85798         updateHashIfNeeded();
85799         behavior.hadLocation = true;
85800       }
85801       hashchange();
85802       updateTitle(false);
85803     }
85804     behavior.off = function() {
85805       _throttledUpdate.cancel();
85806       _throttledUpdateTitle.cancel();
85807       context.map().on("move.behaviorHash", null);
85808       context.on("enter.behaviorHash", null);
85809       select_default2(window).on("hashchange.behaviorHash", null);
85810       window.location.hash = "";
85811     };
85812     return behavior;
85813   }
85814
85815   // node_modules/d3-brush/src/brush.js
85816   var { abs: abs2, max: max2, min: min2 } = Math;
85817   function number1(e3) {
85818     return [+e3[0], +e3[1]];
85819   }
85820   function number22(e3) {
85821     return [number1(e3[0]), number1(e3[1])];
85822   }
85823   var X3 = {
85824     name: "x",
85825     handles: ["w", "e"].map(type),
85826     input: function(x2, e3) {
85827       return x2 == null ? null : [[+x2[0], e3[0][1]], [+x2[1], e3[1][1]]];
85828     },
85829     output: function(xy) {
85830       return xy && [xy[0][0], xy[1][0]];
85831     }
85832   };
85833   var Y3 = {
85834     name: "y",
85835     handles: ["n", "s"].map(type),
85836     input: function(y2, e3) {
85837       return y2 == null ? null : [[e3[0][0], +y2[0]], [e3[1][0], +y2[1]]];
85838     },
85839     output: function(xy) {
85840       return xy && [xy[0][1], xy[1][1]];
85841     }
85842   };
85843   var XY = {
85844     name: "xy",
85845     handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
85846     input: function(xy) {
85847       return xy == null ? null : number22(xy);
85848     },
85849     output: function(xy) {
85850       return xy;
85851     }
85852   };
85853   function type(t2) {
85854     return { type: t2 };
85855   }
85856
85857   // modules/index.js
85858   var debug = false;
85859   var d3 = {
85860     dispatch: dispatch_default,
85861     geoMercator: mercator_default,
85862     geoProjection: projection,
85863     polygonArea: area_default3,
85864     polygonCentroid: centroid_default2,
85865     select: select_default2,
85866     selectAll: selectAll_default2,
85867     timerFlush
85868   };
85869
85870   // modules/id.js
85871   window.requestIdleCallback = window.requestIdleCallback || function(cb) {
85872     var start2 = Date.now();
85873     return window.requestAnimationFrame(function() {
85874       cb({
85875         didTimeout: false,
85876         timeRemaining: function() {
85877           return Math.max(0, 50 - (Date.now() - start2));
85878         }
85879       });
85880     });
85881   };
85882   window.cancelIdleCallback = window.cancelIdleCallback || function(id2) {
85883     window.cancelAnimationFrame(id2);
85884   };
85885   window.iD = modules_exports;
85886 })();
85887 //# sourceMappingURL=iD.js.map