]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/iD/iD.js
Merge remote-tracking branch 'upstream/pull/4717'
[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     osmJoinWays: () => osmJoinWays,
15301     osmLanes: () => osmLanes,
15302     osmLifecyclePrefixes: () => osmLifecyclePrefixes,
15303     osmNode: () => osmNode,
15304     osmNodeGeometriesForTags: () => osmNodeGeometriesForTags,
15305     osmNote: () => osmNote,
15306     osmOneWayTags: () => osmOneWayTags,
15307     osmPavedTags: () => osmPavedTags,
15308     osmPointTags: () => osmPointTags,
15309     osmRailwayTrackTagValues: () => osmRailwayTrackTagValues,
15310     osmRelation: () => osmRelation,
15311     osmRemoveLifecyclePrefix: () => osmRemoveLifecyclePrefix,
15312     osmRoutableHighwayTagValues: () => osmRoutableHighwayTagValues,
15313     osmSetAreaKeys: () => osmSetAreaKeys,
15314     osmSetPointTags: () => osmSetPointTags,
15315     osmSetVertexTags: () => osmSetVertexTags,
15316     osmTagSuggestingArea: () => osmTagSuggestingArea,
15317     osmTurn: () => osmTurn,
15318     osmVertexTags: () => osmVertexTags,
15319     osmWay: () => osmWay,
15320     prefs: () => corePreferences,
15321     presetCategory: () => presetCategory,
15322     presetCollection: () => presetCollection,
15323     presetField: () => presetField,
15324     presetIndex: () => presetIndex,
15325     presetManager: () => _mainPresetIndex,
15326     presetPreset: () => presetPreset,
15327     rendererBackground: () => rendererBackground,
15328     rendererBackgroundSource: () => rendererBackgroundSource,
15329     rendererFeatures: () => rendererFeatures,
15330     rendererMap: () => rendererMap,
15331     rendererPhotos: () => rendererPhotos,
15332     rendererTileLayer: () => rendererTileLayer,
15333     serviceImproveOSM: () => improveOSM_default,
15334     serviceKartaview: () => kartaview_default,
15335     serviceKeepRight: () => keepRight_default,
15336     serviceMapRules: () => maprules_default,
15337     serviceMapilio: () => mapilio_default,
15338     serviceMapillary: () => mapillary_default,
15339     serviceNominatim: () => nominatim_default,
15340     serviceNsi: () => nsi_default,
15341     serviceOsm: () => osm_default,
15342     serviceOsmWikibase: () => osm_wikibase_default,
15343     serviceOsmose: () => osmose_default,
15344     serviceStreetside: () => streetside_default,
15345     serviceTaginfo: () => taginfo_default,
15346     serviceVectorTile: () => vector_tile_default,
15347     serviceVegbilder: () => vegbilder_default,
15348     serviceWikidata: () => wikidata_default,
15349     serviceWikipedia: () => wikipedia_default,
15350     services: () => services,
15351     svgAreas: () => svgAreas,
15352     svgData: () => svgData,
15353     svgDebug: () => svgDebug,
15354     svgDefs: () => svgDefs,
15355     svgGeolocate: () => svgGeolocate,
15356     svgIcon: () => svgIcon,
15357     svgKartaviewImages: () => svgKartaviewImages,
15358     svgKeepRight: () => svgKeepRight,
15359     svgLabels: () => svgLabels,
15360     svgLayers: () => svgLayers,
15361     svgLines: () => svgLines,
15362     svgMapilioImages: () => svgMapilioImages,
15363     svgMapillaryImages: () => svgMapillaryImages,
15364     svgMapillarySigns: () => svgMapillarySigns,
15365     svgMarkerSegments: () => svgMarkerSegments,
15366     svgMidpoints: () => svgMidpoints,
15367     svgNotes: () => svgNotes,
15368     svgOsm: () => svgOsm,
15369     svgPassiveVertex: () => svgPassiveVertex,
15370     svgPath: () => svgPath,
15371     svgPointTransform: () => svgPointTransform,
15372     svgPoints: () => svgPoints,
15373     svgRelationMemberTags: () => svgRelationMemberTags,
15374     svgSegmentWay: () => svgSegmentWay,
15375     svgStreetside: () => svgStreetside,
15376     svgTagClasses: () => svgTagClasses,
15377     svgTagPattern: () => svgTagPattern,
15378     svgTouch: () => svgTouch,
15379     svgTurns: () => svgTurns,
15380     svgVegbilder: () => svgVegbilder,
15381     svgVertices: () => svgVertices,
15382     t: () => _t,
15383     uiAccount: () => uiAccount,
15384     uiAttribution: () => uiAttribution,
15385     uiChangesetEditor: () => uiChangesetEditor,
15386     uiCmd: () => uiCmd,
15387     uiCombobox: () => uiCombobox,
15388     uiCommit: () => uiCommit,
15389     uiCommitWarnings: () => uiCommitWarnings,
15390     uiConfirm: () => uiConfirm,
15391     uiConflicts: () => uiConflicts,
15392     uiContributors: () => uiContributors,
15393     uiCurtain: () => uiCurtain,
15394     uiDataEditor: () => uiDataEditor,
15395     uiDataHeader: () => uiDataHeader,
15396     uiDisclosure: () => uiDisclosure,
15397     uiEditMenu: () => uiEditMenu,
15398     uiEntityEditor: () => uiEntityEditor,
15399     uiFeatureInfo: () => uiFeatureInfo,
15400     uiFeatureList: () => uiFeatureList,
15401     uiField: () => uiField,
15402     uiFieldAccess: () => uiFieldAccess,
15403     uiFieldAddress: () => uiFieldAddress,
15404     uiFieldCheck: () => uiFieldCheck,
15405     uiFieldColour: () => uiFieldText,
15406     uiFieldCombo: () => uiFieldCombo,
15407     uiFieldDefaultCheck: () => uiFieldCheck,
15408     uiFieldDirectionalCombo: () => uiFieldDirectionalCombo,
15409     uiFieldEmail: () => uiFieldText,
15410     uiFieldHelp: () => uiFieldHelp,
15411     uiFieldIdentifier: () => uiFieldText,
15412     uiFieldLanes: () => uiFieldLanes,
15413     uiFieldLocalized: () => uiFieldLocalized,
15414     uiFieldManyCombo: () => uiFieldCombo,
15415     uiFieldMultiCombo: () => uiFieldCombo,
15416     uiFieldNetworkCombo: () => uiFieldCombo,
15417     uiFieldNumber: () => uiFieldText,
15418     uiFieldOnewayCheck: () => uiFieldCheck,
15419     uiFieldRadio: () => uiFieldRadio,
15420     uiFieldRestrictions: () => uiFieldRestrictions,
15421     uiFieldRoadheight: () => uiFieldRoadheight,
15422     uiFieldRoadspeed: () => uiFieldRoadspeed,
15423     uiFieldSemiCombo: () => uiFieldCombo,
15424     uiFieldStructureRadio: () => uiFieldRadio,
15425     uiFieldTel: () => uiFieldText,
15426     uiFieldText: () => uiFieldText,
15427     uiFieldTextarea: () => uiFieldTextarea,
15428     uiFieldTypeCombo: () => uiFieldCombo,
15429     uiFieldUrl: () => uiFieldText,
15430     uiFieldWikidata: () => uiFieldWikidata,
15431     uiFieldWikipedia: () => uiFieldWikipedia,
15432     uiFields: () => uiFields,
15433     uiFlash: () => uiFlash,
15434     uiFormFields: () => uiFormFields,
15435     uiFullScreen: () => uiFullScreen,
15436     uiGeolocate: () => uiGeolocate,
15437     uiImproveOsmComments: () => uiImproveOsmComments,
15438     uiImproveOsmDetails: () => uiImproveOsmDetails,
15439     uiImproveOsmEditor: () => uiImproveOsmEditor,
15440     uiImproveOsmHeader: () => uiImproveOsmHeader,
15441     uiInfo: () => uiInfo,
15442     uiInfoPanels: () => uiInfoPanels,
15443     uiInit: () => uiInit,
15444     uiInspector: () => uiInspector,
15445     uiIntro: () => uiIntro,
15446     uiIssuesInfo: () => uiIssuesInfo,
15447     uiKeepRightDetails: () => uiKeepRightDetails,
15448     uiKeepRightEditor: () => uiKeepRightEditor,
15449     uiKeepRightHeader: () => uiKeepRightHeader,
15450     uiLasso: () => uiLasso,
15451     uiLengthIndicator: () => uiLengthIndicator,
15452     uiLoading: () => uiLoading,
15453     uiMapInMap: () => uiMapInMap,
15454     uiModal: () => uiModal,
15455     uiNoteComments: () => uiNoteComments,
15456     uiNoteEditor: () => uiNoteEditor,
15457     uiNoteHeader: () => uiNoteHeader,
15458     uiNoteReport: () => uiNoteReport,
15459     uiNotice: () => uiNotice,
15460     uiPaneBackground: () => uiPaneBackground,
15461     uiPaneHelp: () => uiPaneHelp,
15462     uiPaneIssues: () => uiPaneIssues,
15463     uiPaneMapData: () => uiPaneMapData,
15464     uiPanePreferences: () => uiPanePreferences,
15465     uiPanelBackground: () => uiPanelBackground,
15466     uiPanelHistory: () => uiPanelHistory,
15467     uiPanelLocation: () => uiPanelLocation,
15468     uiPanelMeasurement: () => uiPanelMeasurement,
15469     uiPopover: () => uiPopover,
15470     uiPresetIcon: () => uiPresetIcon,
15471     uiPresetList: () => uiPresetList,
15472     uiRestore: () => uiRestore,
15473     uiScale: () => uiScale,
15474     uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions,
15475     uiSectionBackgroundList: () => uiSectionBackgroundList,
15476     uiSectionBackgroundOffset: () => uiSectionBackgroundOffset,
15477     uiSectionChanges: () => uiSectionChanges,
15478     uiSectionDataLayers: () => uiSectionDataLayers,
15479     uiSectionEntityIssues: () => uiSectionEntityIssues,
15480     uiSectionFeatureType: () => uiSectionFeatureType,
15481     uiSectionMapFeatures: () => uiSectionMapFeatures,
15482     uiSectionMapStyleOptions: () => uiSectionMapStyleOptions,
15483     uiSectionOverlayList: () => uiSectionOverlayList,
15484     uiSectionPhotoOverlays: () => uiSectionPhotoOverlays,
15485     uiSectionPresetFields: () => uiSectionPresetFields,
15486     uiSectionPrivacy: () => uiSectionPrivacy,
15487     uiSectionRawMemberEditor: () => uiSectionRawMemberEditor,
15488     uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor,
15489     uiSectionRawTagEditor: () => uiSectionRawTagEditor,
15490     uiSectionSelectionList: () => uiSectionSelectionList,
15491     uiSectionValidationIssues: () => uiSectionValidationIssues,
15492     uiSectionValidationOptions: () => uiSectionValidationOptions,
15493     uiSectionValidationRules: () => uiSectionValidationRules,
15494     uiSectionValidationStatus: () => uiSectionValidationStatus,
15495     uiSettingsCustomBackground: () => uiSettingsCustomBackground,
15496     uiSettingsCustomData: () => uiSettingsCustomData,
15497     uiSidebar: () => uiSidebar,
15498     uiSourceSwitch: () => uiSourceSwitch,
15499     uiSpinner: () => uiSpinner,
15500     uiSplash: () => uiSplash,
15501     uiStatus: () => uiStatus,
15502     uiSuccess: () => uiSuccess,
15503     uiTagReference: () => uiTagReference,
15504     uiToggle: () => uiToggle,
15505     uiTooltip: () => uiTooltip,
15506     uiVersion: () => uiVersion,
15507     uiViewOnKeepRight: () => uiViewOnKeepRight,
15508     uiViewOnOSM: () => uiViewOnOSM,
15509     uiZoom: () => uiZoom,
15510     utilAesDecrypt: () => utilAesDecrypt,
15511     utilAesEncrypt: () => utilAesEncrypt,
15512     utilArrayChunk: () => utilArrayChunk,
15513     utilArrayDifference: () => utilArrayDifference,
15514     utilArrayFlatten: () => utilArrayFlatten,
15515     utilArrayGroupBy: () => utilArrayGroupBy,
15516     utilArrayIdentical: () => utilArrayIdentical,
15517     utilArrayIntersection: () => utilArrayIntersection,
15518     utilArrayUnion: () => utilArrayUnion,
15519     utilArrayUniq: () => utilArrayUniq,
15520     utilArrayUniqBy: () => utilArrayUniqBy,
15521     utilAsyncMap: () => utilAsyncMap,
15522     utilCleanOsmString: () => utilCleanOsmString,
15523     utilCleanTags: () => utilCleanTags,
15524     utilCombinedTags: () => utilCombinedTags,
15525     utilCompareIDs: () => utilCompareIDs,
15526     utilDeepMemberSelector: () => utilDeepMemberSelector,
15527     utilDetect: () => utilDetect,
15528     utilDisplayLabel: () => utilDisplayLabel,
15529     utilDisplayName: () => utilDisplayName,
15530     utilDisplayNameForPath: () => utilDisplayNameForPath,
15531     utilDisplayType: () => utilDisplayType,
15532     utilEditDistance: () => utilEditDistance,
15533     utilEntityAndDeepMemberIDs: () => utilEntityAndDeepMemberIDs,
15534     utilEntityOrDeepMemberSelector: () => utilEntityOrDeepMemberSelector,
15535     utilEntityOrMemberSelector: () => utilEntityOrMemberSelector,
15536     utilEntityRoot: () => utilEntityRoot,
15537     utilEntitySelector: () => utilEntitySelector,
15538     utilFastMouse: () => utilFastMouse,
15539     utilFunctor: () => utilFunctor,
15540     utilGetAllNodes: () => utilGetAllNodes,
15541     utilGetSetValue: () => utilGetSetValue,
15542     utilHashcode: () => utilHashcode,
15543     utilHighlightEntities: () => utilHighlightEntities,
15544     utilKeybinding: () => utilKeybinding,
15545     utilNoAuto: () => utilNoAuto,
15546     utilObjectOmit: () => utilObjectOmit,
15547     utilOldestID: () => utilOldestID,
15548     utilPrefixCSSProperty: () => utilPrefixCSSProperty,
15549     utilPrefixDOMProperty: () => utilPrefixDOMProperty,
15550     utilQsString: () => utilQsString,
15551     utilRebind: () => utilRebind,
15552     utilSafeClassName: () => utilSafeClassName,
15553     utilSessionMutex: () => utilSessionMutex,
15554     utilSetTransform: () => utilSetTransform,
15555     utilStringQs: () => utilStringQs,
15556     utilTagDiff: () => utilTagDiff,
15557     utilTagText: () => utilTagText,
15558     utilTiler: () => utilTiler,
15559     utilTotalExtent: () => utilTotalExtent,
15560     utilTriggerEvent: () => utilTriggerEvent,
15561     utilUnicodeCharsCount: () => utilUnicodeCharsCount,
15562     utilUnicodeCharsTruncated: () => utilUnicodeCharsTruncated,
15563     utilUniqueDomId: () => utilUniqueDomId,
15564     utilWrap: () => utilWrap,
15565     validationAlmostJunction: () => validationAlmostJunction,
15566     validationCloseNodes: () => validationCloseNodes,
15567     validationCrossingWays: () => validationCrossingWays,
15568     validationDisconnectedWay: () => validationDisconnectedWay,
15569     validationFormatting: () => validationFormatting,
15570     validationHelpRequest: () => validationHelpRequest,
15571     validationImpossibleOneway: () => validationImpossibleOneway,
15572     validationIncompatibleSource: () => validationIncompatibleSource,
15573     validationMaprules: () => validationMaprules,
15574     validationMismatchedGeometry: () => validationMismatchedGeometry,
15575     validationMissingRole: () => validationMissingRole,
15576     validationMissingTag: () => validationMissingTag,
15577     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
15578     validationOutdatedTags: () => validationOutdatedTags,
15579     validationPrivateData: () => validationPrivateData,
15580     validationSuspiciousName: () => validationSuspiciousName,
15581     validationUnsquareWay: () => validationUnsquareWay
15582   });
15583
15584   // modules/actions/add_entity.js
15585   function actionAddEntity(way) {
15586     return function(graph) {
15587       return graph.replace(way);
15588     };
15589   }
15590
15591   // modules/actions/reverse.js
15592   function actionReverse(entityID, options2) {
15593     var ignoreKey = /^.*(_|:)?(description|name|note|website|ref|source|comment|watch|attribution)(_|:)?/;
15594     var numeric = /^([+\-]?)(?=[\d.])/;
15595     var directionKey = /direction$/;
15596     var turn_lanes = /^turn:lanes:?/;
15597     var keyReplacements = [
15598       [/:right$/, ":left"],
15599       [/:left$/, ":right"],
15600       [/:forward$/, ":backward"],
15601       [/:backward$/, ":forward"],
15602       [/:right:/, ":left:"],
15603       [/:left:/, ":right:"],
15604       [/:forward:/, ":backward:"],
15605       [/:backward:/, ":forward:"]
15606     ];
15607     var valueReplacements = {
15608       left: "right",
15609       right: "left",
15610       up: "down",
15611       down: "up",
15612       forward: "backward",
15613       backward: "forward",
15614       forwards: "backward",
15615       backwards: "forward"
15616     };
15617     const valueReplacementsExceptions = {
15618       "side": [
15619         { highway: "cyclist_waiting_aid" }
15620       ]
15621     };
15622     var roleReplacements = {
15623       forward: "backward",
15624       backward: "forward",
15625       forwards: "backward",
15626       backwards: "forward"
15627     };
15628     var onewayReplacements = {
15629       yes: "-1",
15630       "1": "-1",
15631       "-1": "yes"
15632     };
15633     var compassReplacements = {
15634       N: "S",
15635       NNE: "SSW",
15636       NE: "SW",
15637       ENE: "WSW",
15638       E: "W",
15639       ESE: "WNW",
15640       SE: "NW",
15641       SSE: "NNW",
15642       S: "N",
15643       SSW: "NNE",
15644       SW: "NE",
15645       WSW: "ENE",
15646       W: "E",
15647       WNW: "ESE",
15648       NW: "SE",
15649       NNW: "SSE"
15650     };
15651     function reverseKey(key) {
15652       for (var i3 = 0; i3 < keyReplacements.length; ++i3) {
15653         var replacement = keyReplacements[i3];
15654         if (replacement[0].test(key)) {
15655           return key.replace(replacement[0], replacement[1]);
15656         }
15657       }
15658       return key;
15659     }
15660     function reverseValue(key, value, includeAbsolute, allTags) {
15661       if (ignoreKey.test(key))
15662         return value;
15663       if (turn_lanes.test(key)) {
15664         return value;
15665       } else if (key === "incline" && numeric.test(value)) {
15666         return value.replace(numeric, function(_2, sign2) {
15667           return sign2 === "-" ? "" : "-";
15668         });
15669       } else if (options2 && options2.reverseOneway && key === "oneway") {
15670         return onewayReplacements[value] || value;
15671       } else if (includeAbsolute && directionKey.test(key)) {
15672         return value.split(";").map((value2) => {
15673           if (compassReplacements[value2])
15674             return compassReplacements[value2];
15675           var degrees3 = Number(value2);
15676           if (isFinite(degrees3)) {
15677             if (degrees3 < 180) {
15678               degrees3 += 180;
15679             } else {
15680               degrees3 -= 180;
15681             }
15682             return degrees3.toString();
15683           } else {
15684             return valueReplacements[value2] || value2;
15685           }
15686         }).join(";");
15687       }
15688       if (valueReplacementsExceptions[key] && valueReplacementsExceptions[key].some(
15689         (exceptionTags) => Object.keys(exceptionTags).every((k2) => {
15690           const v2 = exceptionTags[k2];
15691           return allTags[k2] && (v2 === "*" || allTags[k2] === v2);
15692         })
15693       )) {
15694         return value;
15695       }
15696       return valueReplacements[value] || value;
15697     }
15698     function reverseNodeTags(graph, nodeIDs) {
15699       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
15700         var node = graph.hasEntity(nodeIDs[i3]);
15701         if (!node || !Object.keys(node.tags).length)
15702           continue;
15703         var tags = {};
15704         for (var key in node.tags) {
15705           tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags);
15706         }
15707         graph = graph.replace(node.update({ tags }));
15708       }
15709       return graph;
15710     }
15711     function reverseWay(graph, way) {
15712       var nodes = way.nodes.slice().reverse();
15713       var tags = {};
15714       var role;
15715       for (var key in way.tags) {
15716         tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags);
15717       }
15718       graph.parentRelations(way).forEach(function(relation) {
15719         relation.members.forEach(function(member, index) {
15720           if (member.id === way.id && (role = roleReplacements[member.role])) {
15721             relation = relation.updateMember({ role }, index);
15722             graph = graph.replace(relation);
15723           }
15724         });
15725       });
15726       return reverseNodeTags(graph, nodes).replace(way.update({ nodes, tags }));
15727     }
15728     var action = function(graph) {
15729       var entity = graph.entity(entityID);
15730       if (entity.type === "way") {
15731         return reverseWay(graph, entity);
15732       }
15733       return reverseNodeTags(graph, [entityID]);
15734     };
15735     action.disabled = function(graph) {
15736       var entity = graph.hasEntity(entityID);
15737       if (!entity || entity.type === "way")
15738         return false;
15739       for (var key in entity.tags) {
15740         var value = entity.tags[key];
15741         if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) {
15742           return false;
15743         }
15744       }
15745       return "nondirectional_node";
15746     };
15747     action.entityID = function() {
15748       return entityID;
15749     };
15750     return action;
15751   }
15752
15753   // node_modules/d3-array/src/ascending.js
15754   function ascending(a2, b2) {
15755     return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
15756   }
15757
15758   // node_modules/d3-array/src/descending.js
15759   function descending(a2, b2) {
15760     return a2 == null || b2 == null ? NaN : b2 < a2 ? -1 : b2 > a2 ? 1 : b2 >= a2 ? 0 : NaN;
15761   }
15762
15763   // node_modules/d3-array/src/bisector.js
15764   function bisector(f2) {
15765     let compare1, compare2, delta;
15766     if (f2.length !== 2) {
15767       compare1 = ascending;
15768       compare2 = (d2, x2) => ascending(f2(d2), x2);
15769       delta = (d2, x2) => f2(d2) - x2;
15770     } else {
15771       compare1 = f2 === ascending || f2 === descending ? f2 : zero;
15772       compare2 = f2;
15773       delta = f2;
15774     }
15775     function left(a2, x2, lo = 0, hi = a2.length) {
15776       if (lo < hi) {
15777         if (compare1(x2, x2) !== 0)
15778           return hi;
15779         do {
15780           const mid = lo + hi >>> 1;
15781           if (compare2(a2[mid], x2) < 0)
15782             lo = mid + 1;
15783           else
15784             hi = mid;
15785         } while (lo < hi);
15786       }
15787       return lo;
15788     }
15789     function right(a2, x2, lo = 0, hi = a2.length) {
15790       if (lo < hi) {
15791         if (compare1(x2, x2) !== 0)
15792           return hi;
15793         do {
15794           const mid = lo + hi >>> 1;
15795           if (compare2(a2[mid], x2) <= 0)
15796             lo = mid + 1;
15797           else
15798             hi = mid;
15799         } while (lo < hi);
15800       }
15801       return lo;
15802     }
15803     function center(a2, x2, lo = 0, hi = a2.length) {
15804       const i3 = left(a2, x2, lo, hi - 1);
15805       return i3 > lo && delta(a2[i3 - 1], x2) > -delta(a2[i3], x2) ? i3 - 1 : i3;
15806     }
15807     return { left, center, right };
15808   }
15809   function zero() {
15810     return 0;
15811   }
15812
15813   // node_modules/d3-array/src/number.js
15814   function number(x2) {
15815     return x2 === null ? NaN : +x2;
15816   }
15817   function* numbers(values, valueof) {
15818     if (valueof === void 0) {
15819       for (let value of values) {
15820         if (value != null && (value = +value) >= value) {
15821           yield value;
15822         }
15823       }
15824     } else {
15825       let index = -1;
15826       for (let value of values) {
15827         if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
15828           yield value;
15829         }
15830       }
15831     }
15832   }
15833
15834   // node_modules/d3-array/src/bisect.js
15835   var ascendingBisect = bisector(ascending);
15836   var bisectRight = ascendingBisect.right;
15837   var bisectLeft = ascendingBisect.left;
15838   var bisectCenter = bisector(number).center;
15839   var bisect_default = bisectRight;
15840
15841   // node_modules/d3-array/src/fsum.js
15842   var Adder = class {
15843     constructor() {
15844       this._partials = new Float64Array(32);
15845       this._n = 0;
15846     }
15847     add(x2) {
15848       const p2 = this._partials;
15849       let i3 = 0;
15850       for (let j2 = 0; j2 < this._n && j2 < 32; j2++) {
15851         const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2);
15852         if (lo)
15853           p2[i3++] = lo;
15854         x2 = hi;
15855       }
15856       p2[i3] = x2;
15857       this._n = i3 + 1;
15858       return this;
15859     }
15860     valueOf() {
15861       const p2 = this._partials;
15862       let n3 = this._n, x2, y2, lo, hi = 0;
15863       if (n3 > 0) {
15864         hi = p2[--n3];
15865         while (n3 > 0) {
15866           x2 = hi;
15867           y2 = p2[--n3];
15868           hi = x2 + y2;
15869           lo = y2 - (hi - x2);
15870           if (lo)
15871             break;
15872         }
15873         if (n3 > 0 && (lo < 0 && p2[n3 - 1] < 0 || lo > 0 && p2[n3 - 1] > 0)) {
15874           y2 = lo * 2;
15875           x2 = hi + y2;
15876           if (y2 == x2 - hi)
15877             hi = x2;
15878         }
15879       }
15880       return hi;
15881     }
15882   };
15883
15884   // node_modules/d3-array/src/sort.js
15885   function compareDefined(compare2 = ascending) {
15886     if (compare2 === ascending)
15887       return ascendingDefined;
15888     if (typeof compare2 !== "function")
15889       throw new TypeError("compare is not a function");
15890     return (a2, b2) => {
15891       const x2 = compare2(a2, b2);
15892       if (x2 || x2 === 0)
15893         return x2;
15894       return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0);
15895     };
15896   }
15897   function ascendingDefined(a2, b2) {
15898     return (a2 == null || !(a2 >= a2)) - (b2 == null || !(b2 >= b2)) || (a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
15899   }
15900
15901   // node_modules/d3-array/src/ticks.js
15902   var e10 = Math.sqrt(50);
15903   var e5 = Math.sqrt(10);
15904   var e2 = Math.sqrt(2);
15905   function ticks(start2, stop, count) {
15906     var reverse, i3 = -1, n3, ticks2, step;
15907     stop = +stop, start2 = +start2, count = +count;
15908     if (start2 === stop && count > 0)
15909       return [start2];
15910     if (reverse = stop < start2)
15911       n3 = start2, start2 = stop, stop = n3;
15912     if ((step = tickIncrement(start2, stop, count)) === 0 || !isFinite(step))
15913       return [];
15914     if (step > 0) {
15915       let r0 = Math.round(start2 / step), r1 = Math.round(stop / step);
15916       if (r0 * step < start2)
15917         ++r0;
15918       if (r1 * step > stop)
15919         --r1;
15920       ticks2 = new Array(n3 = r1 - r0 + 1);
15921       while (++i3 < n3)
15922         ticks2[i3] = (r0 + i3) * step;
15923     } else {
15924       step = -step;
15925       let r0 = Math.round(start2 * step), r1 = Math.round(stop * step);
15926       if (r0 / step < start2)
15927         ++r0;
15928       if (r1 / step > stop)
15929         --r1;
15930       ticks2 = new Array(n3 = r1 - r0 + 1);
15931       while (++i3 < n3)
15932         ticks2[i3] = (r0 + i3) / step;
15933     }
15934     if (reverse)
15935       ticks2.reverse();
15936     return ticks2;
15937   }
15938   function tickIncrement(start2, stop, count) {
15939     var step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power);
15940     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);
15941   }
15942   function tickStep(start2, stop, count) {
15943     var step0 = Math.abs(stop - start2) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1;
15944     if (error >= e10)
15945       step1 *= 10;
15946     else if (error >= e5)
15947       step1 *= 5;
15948     else if (error >= e2)
15949       step1 *= 2;
15950     return stop < start2 ? -step1 : step1;
15951   }
15952
15953   // node_modules/d3-array/src/max.js
15954   function max(values, valueof) {
15955     let max3;
15956     if (valueof === void 0) {
15957       for (const value of values) {
15958         if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
15959           max3 = value;
15960         }
15961       }
15962     } else {
15963       let index = -1;
15964       for (let value of values) {
15965         if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
15966           max3 = value;
15967         }
15968       }
15969     }
15970     return max3;
15971   }
15972
15973   // node_modules/d3-array/src/min.js
15974   function min(values, valueof) {
15975     let min3;
15976     if (valueof === void 0) {
15977       for (const value of values) {
15978         if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
15979           min3 = value;
15980         }
15981       }
15982     } else {
15983       let index = -1;
15984       for (let value of values) {
15985         if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
15986           min3 = value;
15987         }
15988       }
15989     }
15990     return min3;
15991   }
15992
15993   // node_modules/d3-array/src/quickselect.js
15994   function quickselect(array2, k2, left = 0, right = array2.length - 1, compare2) {
15995     compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
15996     while (right > left) {
15997       if (right - left > 600) {
15998         const n3 = right - left + 1;
15999         const m2 = k2 - left + 1;
16000         const z2 = Math.log(n3);
16001         const s2 = 0.5 * Math.exp(2 * z2 / 3);
16002         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
16003         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
16004         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
16005         quickselect(array2, k2, newLeft, newRight, compare2);
16006       }
16007       const t2 = array2[k2];
16008       let i3 = left;
16009       let j2 = right;
16010       swap(array2, left, k2);
16011       if (compare2(array2[right], t2) > 0)
16012         swap(array2, left, right);
16013       while (i3 < j2) {
16014         swap(array2, i3, j2), ++i3, --j2;
16015         while (compare2(array2[i3], t2) < 0)
16016           ++i3;
16017         while (compare2(array2[j2], t2) > 0)
16018           --j2;
16019       }
16020       if (compare2(array2[left], t2) === 0)
16021         swap(array2, left, j2);
16022       else
16023         ++j2, swap(array2, j2, right);
16024       if (j2 <= k2)
16025         left = j2 + 1;
16026       if (k2 <= j2)
16027         right = j2 - 1;
16028     }
16029     return array2;
16030   }
16031   function swap(array2, i3, j2) {
16032     const t2 = array2[i3];
16033     array2[i3] = array2[j2];
16034     array2[j2] = t2;
16035   }
16036
16037   // node_modules/d3-array/src/quantile.js
16038   function quantile(values, p2, valueof) {
16039     values = Float64Array.from(numbers(values, valueof));
16040     if (!(n3 = values.length))
16041       return;
16042     if ((p2 = +p2) <= 0 || n3 < 2)
16043       return min(values);
16044     if (p2 >= 1)
16045       return max(values);
16046     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));
16047     return value0 + (value1 - value0) * (i3 - i0);
16048   }
16049
16050   // node_modules/d3-array/src/median.js
16051   function median(values, valueof) {
16052     return quantile(values, 0.5, valueof);
16053   }
16054
16055   // node_modules/d3-array/src/merge.js
16056   function* flatten(arrays) {
16057     for (const array2 of arrays) {
16058       yield* array2;
16059     }
16060   }
16061   function merge(arrays) {
16062     return Array.from(flatten(arrays));
16063   }
16064
16065   // node_modules/d3-array/src/pairs.js
16066   function pairs(values, pairof = pair) {
16067     const pairs2 = [];
16068     let previous;
16069     let first = false;
16070     for (const value of values) {
16071       if (first)
16072         pairs2.push(pairof(previous, value));
16073       previous = value;
16074       first = true;
16075     }
16076     return pairs2;
16077   }
16078   function pair(a2, b2) {
16079     return [a2, b2];
16080   }
16081
16082   // node_modules/d3-array/src/range.js
16083   function range(start2, stop, step) {
16084     start2 = +start2, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n3 < 3 ? 1 : +step;
16085     var i3 = -1, n3 = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range3 = new Array(n3);
16086     while (++i3 < n3) {
16087       range3[i3] = start2 + i3 * step;
16088     }
16089     return range3;
16090   }
16091
16092   // node_modules/d3-geo/src/math.js
16093   var epsilon = 1e-6;
16094   var epsilon2 = 1e-12;
16095   var pi = Math.PI;
16096   var halfPi = pi / 2;
16097   var quarterPi = pi / 4;
16098   var tau = pi * 2;
16099   var degrees = 180 / pi;
16100   var radians = pi / 180;
16101   var abs = Math.abs;
16102   var atan = Math.atan;
16103   var atan2 = Math.atan2;
16104   var cos = Math.cos;
16105   var exp = Math.exp;
16106   var log = Math.log;
16107   var sin = Math.sin;
16108   var sign = Math.sign || function(x2) {
16109     return x2 > 0 ? 1 : x2 < 0 ? -1 : 0;
16110   };
16111   var sqrt = Math.sqrt;
16112   var tan = Math.tan;
16113   function acos(x2) {
16114     return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
16115   }
16116   function asin(x2) {
16117     return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
16118   }
16119
16120   // node_modules/d3-geo/src/noop.js
16121   function noop() {
16122   }
16123
16124   // node_modules/d3-geo/src/stream.js
16125   function streamGeometry(geometry, stream) {
16126     if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
16127       streamGeometryType[geometry.type](geometry, stream);
16128     }
16129   }
16130   var streamObjectType = {
16131     Feature: function(object, stream) {
16132       streamGeometry(object.geometry, stream);
16133     },
16134     FeatureCollection: function(object, stream) {
16135       var features = object.features, i3 = -1, n3 = features.length;
16136       while (++i3 < n3)
16137         streamGeometry(features[i3].geometry, stream);
16138     }
16139   };
16140   var streamGeometryType = {
16141     Sphere: function(object, stream) {
16142       stream.sphere();
16143     },
16144     Point: function(object, stream) {
16145       object = object.coordinates;
16146       stream.point(object[0], object[1], object[2]);
16147     },
16148     MultiPoint: function(object, stream) {
16149       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16150       while (++i3 < n3)
16151         object = coordinates[i3], stream.point(object[0], object[1], object[2]);
16152     },
16153     LineString: function(object, stream) {
16154       streamLine(object.coordinates, stream, 0);
16155     },
16156     MultiLineString: function(object, stream) {
16157       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16158       while (++i3 < n3)
16159         streamLine(coordinates[i3], stream, 0);
16160     },
16161     Polygon: function(object, stream) {
16162       streamPolygon(object.coordinates, stream);
16163     },
16164     MultiPolygon: function(object, stream) {
16165       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16166       while (++i3 < n3)
16167         streamPolygon(coordinates[i3], stream);
16168     },
16169     GeometryCollection: function(object, stream) {
16170       var geometries = object.geometries, i3 = -1, n3 = geometries.length;
16171       while (++i3 < n3)
16172         streamGeometry(geometries[i3], stream);
16173     }
16174   };
16175   function streamLine(coordinates, stream, closed) {
16176     var i3 = -1, n3 = coordinates.length - closed, coordinate;
16177     stream.lineStart();
16178     while (++i3 < n3)
16179       coordinate = coordinates[i3], stream.point(coordinate[0], coordinate[1], coordinate[2]);
16180     stream.lineEnd();
16181   }
16182   function streamPolygon(coordinates, stream) {
16183     var i3 = -1, n3 = coordinates.length;
16184     stream.polygonStart();
16185     while (++i3 < n3)
16186       streamLine(coordinates[i3], stream, 1);
16187     stream.polygonEnd();
16188   }
16189   function stream_default(object, stream) {
16190     if (object && streamObjectType.hasOwnProperty(object.type)) {
16191       streamObjectType[object.type](object, stream);
16192     } else {
16193       streamGeometry(object, stream);
16194     }
16195   }
16196
16197   // node_modules/d3-geo/src/area.js
16198   var areaRingSum = new Adder();
16199   var areaSum = new Adder();
16200   var lambda00;
16201   var phi00;
16202   var lambda0;
16203   var cosPhi0;
16204   var sinPhi0;
16205   var areaStream = {
16206     point: noop,
16207     lineStart: noop,
16208     lineEnd: noop,
16209     polygonStart: function() {
16210       areaRingSum = new Adder();
16211       areaStream.lineStart = areaRingStart;
16212       areaStream.lineEnd = areaRingEnd;
16213     },
16214     polygonEnd: function() {
16215       var areaRing = +areaRingSum;
16216       areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
16217       this.lineStart = this.lineEnd = this.point = noop;
16218     },
16219     sphere: function() {
16220       areaSum.add(tau);
16221     }
16222   };
16223   function areaRingStart() {
16224     areaStream.point = areaPointFirst;
16225   }
16226   function areaRingEnd() {
16227     areaPoint(lambda00, phi00);
16228   }
16229   function areaPointFirst(lambda, phi) {
16230     areaStream.point = areaPoint;
16231     lambda00 = lambda, phi00 = phi;
16232     lambda *= radians, phi *= radians;
16233     lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
16234   }
16235   function areaPoint(lambda, phi) {
16236     lambda *= radians, phi *= radians;
16237     phi = phi / 2 + quarterPi;
16238     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);
16239     areaRingSum.add(atan2(v2, u2));
16240     lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
16241   }
16242   function area_default(object) {
16243     areaSum = new Adder();
16244     stream_default(object, areaStream);
16245     return areaSum * 2;
16246   }
16247
16248   // node_modules/d3-geo/src/cartesian.js
16249   function spherical(cartesian2) {
16250     return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
16251   }
16252   function cartesian(spherical2) {
16253     var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
16254     return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
16255   }
16256   function cartesianDot(a2, b2) {
16257     return a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
16258   }
16259   function cartesianCross(a2, b2) {
16260     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]];
16261   }
16262   function cartesianAddInPlace(a2, b2) {
16263     a2[0] += b2[0], a2[1] += b2[1], a2[2] += b2[2];
16264   }
16265   function cartesianScale(vector, k2) {
16266     return [vector[0] * k2, vector[1] * k2, vector[2] * k2];
16267   }
16268   function cartesianNormalizeInPlace(d2) {
16269     var l2 = sqrt(d2[0] * d2[0] + d2[1] * d2[1] + d2[2] * d2[2]);
16270     d2[0] /= l2, d2[1] /= l2, d2[2] /= l2;
16271   }
16272
16273   // node_modules/d3-geo/src/bounds.js
16274   var lambda02;
16275   var phi0;
16276   var lambda1;
16277   var phi1;
16278   var lambda2;
16279   var lambda002;
16280   var phi002;
16281   var p0;
16282   var deltaSum;
16283   var ranges;
16284   var range2;
16285   var boundsStream = {
16286     point: boundsPoint,
16287     lineStart: boundsLineStart,
16288     lineEnd: boundsLineEnd,
16289     polygonStart: function() {
16290       boundsStream.point = boundsRingPoint;
16291       boundsStream.lineStart = boundsRingStart;
16292       boundsStream.lineEnd = boundsRingEnd;
16293       deltaSum = new Adder();
16294       areaStream.polygonStart();
16295     },
16296     polygonEnd: function() {
16297       areaStream.polygonEnd();
16298       boundsStream.point = boundsPoint;
16299       boundsStream.lineStart = boundsLineStart;
16300       boundsStream.lineEnd = boundsLineEnd;
16301       if (areaRingSum < 0)
16302         lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16303       else if (deltaSum > epsilon)
16304         phi1 = 90;
16305       else if (deltaSum < -epsilon)
16306         phi0 = -90;
16307       range2[0] = lambda02, range2[1] = lambda1;
16308     },
16309     sphere: function() {
16310       lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16311     }
16312   };
16313   function boundsPoint(lambda, phi) {
16314     ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16315     if (phi < phi0)
16316       phi0 = phi;
16317     if (phi > phi1)
16318       phi1 = phi;
16319   }
16320   function linePoint(lambda, phi) {
16321     var p2 = cartesian([lambda * radians, phi * radians]);
16322     if (p0) {
16323       var normal = cartesianCross(p0, p2), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
16324       cartesianNormalizeInPlace(inflection);
16325       inflection = spherical(inflection);
16326       var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs(delta) > 180;
16327       if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16328         phii = inflection[1] * degrees;
16329         if (phii > phi1)
16330           phi1 = phii;
16331       } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16332         phii = -inflection[1] * degrees;
16333         if (phii < phi0)
16334           phi0 = phii;
16335       } else {
16336         if (phi < phi0)
16337           phi0 = phi;
16338         if (phi > phi1)
16339           phi1 = phi;
16340       }
16341       if (antimeridian) {
16342         if (lambda < lambda2) {
16343           if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16344             lambda1 = lambda;
16345         } else {
16346           if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16347             lambda02 = lambda;
16348         }
16349       } else {
16350         if (lambda1 >= lambda02) {
16351           if (lambda < lambda02)
16352             lambda02 = lambda;
16353           if (lambda > lambda1)
16354             lambda1 = lambda;
16355         } else {
16356           if (lambda > lambda2) {
16357             if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16358               lambda1 = lambda;
16359           } else {
16360             if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16361               lambda02 = lambda;
16362           }
16363         }
16364       }
16365     } else {
16366       ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16367     }
16368     if (phi < phi0)
16369       phi0 = phi;
16370     if (phi > phi1)
16371       phi1 = phi;
16372     p0 = p2, lambda2 = lambda;
16373   }
16374   function boundsLineStart() {
16375     boundsStream.point = linePoint;
16376   }
16377   function boundsLineEnd() {
16378     range2[0] = lambda02, range2[1] = lambda1;
16379     boundsStream.point = boundsPoint;
16380     p0 = null;
16381   }
16382   function boundsRingPoint(lambda, phi) {
16383     if (p0) {
16384       var delta = lambda - lambda2;
16385       deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
16386     } else {
16387       lambda002 = lambda, phi002 = phi;
16388     }
16389     areaStream.point(lambda, phi);
16390     linePoint(lambda, phi);
16391   }
16392   function boundsRingStart() {
16393     areaStream.lineStart();
16394   }
16395   function boundsRingEnd() {
16396     boundsRingPoint(lambda002, phi002);
16397     areaStream.lineEnd();
16398     if (abs(deltaSum) > epsilon)
16399       lambda02 = -(lambda1 = 180);
16400     range2[0] = lambda02, range2[1] = lambda1;
16401     p0 = null;
16402   }
16403   function angle(lambda04, lambda12) {
16404     return (lambda12 -= lambda04) < 0 ? lambda12 + 360 : lambda12;
16405   }
16406   function rangeCompare(a2, b2) {
16407     return a2[0] - b2[0];
16408   }
16409   function rangeContains(range3, x2) {
16410     return range3[0] <= range3[1] ? range3[0] <= x2 && x2 <= range3[1] : x2 < range3[0] || range3[1] < x2;
16411   }
16412   function bounds_default(feature3) {
16413     var i3, n3, a2, b2, merged, deltaMax, delta;
16414     phi1 = lambda1 = -(lambda02 = phi0 = Infinity);
16415     ranges = [];
16416     stream_default(feature3, boundsStream);
16417     if (n3 = ranges.length) {
16418       ranges.sort(rangeCompare);
16419       for (i3 = 1, a2 = ranges[0], merged = [a2]; i3 < n3; ++i3) {
16420         b2 = ranges[i3];
16421         if (rangeContains(a2, b2[0]) || rangeContains(a2, b2[1])) {
16422           if (angle(a2[0], b2[1]) > angle(a2[0], a2[1]))
16423             a2[1] = b2[1];
16424           if (angle(b2[0], a2[1]) > angle(a2[0], a2[1]))
16425             a2[0] = b2[0];
16426         } else {
16427           merged.push(a2 = b2);
16428         }
16429       }
16430       for (deltaMax = -Infinity, n3 = merged.length - 1, i3 = 0, a2 = merged[n3]; i3 <= n3; a2 = b2, ++i3) {
16431         b2 = merged[i3];
16432         if ((delta = angle(a2[1], b2[0])) > deltaMax)
16433           deltaMax = delta, lambda02 = b2[0], lambda1 = a2[1];
16434       }
16435     }
16436     ranges = range2 = null;
16437     return lambda02 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda02, phi0], [lambda1, phi1]];
16438   }
16439
16440   // node_modules/d3-geo/src/compose.js
16441   function compose_default(a2, b2) {
16442     function compose(x2, y2) {
16443       return x2 = a2(x2, y2), b2(x2[0], x2[1]);
16444     }
16445     if (a2.invert && b2.invert)
16446       compose.invert = function(x2, y2) {
16447         return x2 = b2.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]);
16448       };
16449     return compose;
16450   }
16451
16452   // node_modules/d3-geo/src/rotation.js
16453   function rotationIdentity(lambda, phi) {
16454     return [abs(lambda) > pi ? lambda + Math.round(-lambda / tau) * tau : lambda, phi];
16455   }
16456   rotationIdentity.invert = rotationIdentity;
16457   function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
16458     return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
16459   }
16460   function forwardRotationLambda(deltaLambda) {
16461     return function(lambda, phi) {
16462       return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
16463     };
16464   }
16465   function rotationLambda(deltaLambda) {
16466     var rotation = forwardRotationLambda(deltaLambda);
16467     rotation.invert = forwardRotationLambda(-deltaLambda);
16468     return rotation;
16469   }
16470   function rotationPhiGamma(deltaPhi, deltaGamma) {
16471     var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
16472     function rotation(lambda, phi) {
16473       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaPhi + x2 * sinDeltaPhi;
16474       return [
16475         atan2(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z2 * sinDeltaPhi),
16476         asin(k2 * cosDeltaGamma + y2 * sinDeltaGamma)
16477       ];
16478     }
16479     rotation.invert = function(lambda, phi) {
16480       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaGamma - y2 * sinDeltaGamma;
16481       return [
16482         atan2(y2 * cosDeltaGamma + z2 * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi),
16483         asin(k2 * cosDeltaPhi - x2 * sinDeltaPhi)
16484       ];
16485     };
16486     return rotation;
16487   }
16488   function rotation_default(rotate) {
16489     rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
16490     function forward(coordinates) {
16491       coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
16492       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16493     }
16494     forward.invert = function(coordinates) {
16495       coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
16496       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16497     };
16498     return forward;
16499   }
16500
16501   // node_modules/d3-geo/src/circle.js
16502   function circleStream(stream, radius, delta, direction, t0, t1) {
16503     if (!delta)
16504       return;
16505     var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
16506     if (t0 == null) {
16507       t0 = radius + direction * tau;
16508       t1 = radius - step / 2;
16509     } else {
16510       t0 = circleRadius(cosRadius, t0);
16511       t1 = circleRadius(cosRadius, t1);
16512       if (direction > 0 ? t0 < t1 : t0 > t1)
16513         t0 += direction * tau;
16514     }
16515     for (var point2, t2 = t0; direction > 0 ? t2 > t1 : t2 < t1; t2 -= step) {
16516       point2 = spherical([cosRadius, -sinRadius * cos(t2), -sinRadius * sin(t2)]);
16517       stream.point(point2[0], point2[1]);
16518     }
16519   }
16520   function circleRadius(cosRadius, point2) {
16521     point2 = cartesian(point2), point2[0] -= cosRadius;
16522     cartesianNormalizeInPlace(point2);
16523     var radius = acos(-point2[1]);
16524     return ((-point2[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
16525   }
16526
16527   // node_modules/d3-geo/src/clip/buffer.js
16528   function buffer_default() {
16529     var lines = [], line;
16530     return {
16531       point: function(x2, y2, m2) {
16532         line.push([x2, y2, m2]);
16533       },
16534       lineStart: function() {
16535         lines.push(line = []);
16536       },
16537       lineEnd: noop,
16538       rejoin: function() {
16539         if (lines.length > 1)
16540           lines.push(lines.pop().concat(lines.shift()));
16541       },
16542       result: function() {
16543         var result = lines;
16544         lines = [];
16545         line = null;
16546         return result;
16547       }
16548     };
16549   }
16550
16551   // node_modules/d3-geo/src/pointEqual.js
16552   function pointEqual_default(a2, b2) {
16553     return abs(a2[0] - b2[0]) < epsilon && abs(a2[1] - b2[1]) < epsilon;
16554   }
16555
16556   // node_modules/d3-geo/src/clip/rejoin.js
16557   function Intersection(point2, points, other, entry) {
16558     this.x = point2;
16559     this.z = points;
16560     this.o = other;
16561     this.e = entry;
16562     this.v = false;
16563     this.n = this.p = null;
16564   }
16565   function rejoin_default(segments, compareIntersection2, startInside, interpolate, stream) {
16566     var subject = [], clip = [], i3, n3;
16567     segments.forEach(function(segment) {
16568       if ((n4 = segment.length - 1) <= 0)
16569         return;
16570       var n4, p02 = segment[0], p1 = segment[n4], x2;
16571       if (pointEqual_default(p02, p1)) {
16572         if (!p02[2] && !p1[2]) {
16573           stream.lineStart();
16574           for (i3 = 0; i3 < n4; ++i3)
16575             stream.point((p02 = segment[i3])[0], p02[1]);
16576           stream.lineEnd();
16577           return;
16578         }
16579         p1[0] += 2 * epsilon;
16580       }
16581       subject.push(x2 = new Intersection(p02, segment, null, true));
16582       clip.push(x2.o = new Intersection(p02, null, x2, false));
16583       subject.push(x2 = new Intersection(p1, segment, null, false));
16584       clip.push(x2.o = new Intersection(p1, null, x2, true));
16585     });
16586     if (!subject.length)
16587       return;
16588     clip.sort(compareIntersection2);
16589     link(subject);
16590     link(clip);
16591     for (i3 = 0, n3 = clip.length; i3 < n3; ++i3) {
16592       clip[i3].e = startInside = !startInside;
16593     }
16594     var start2 = subject[0], points, point2;
16595     while (1) {
16596       var current = start2, isSubject = true;
16597       while (current.v)
16598         if ((current = current.n) === start2)
16599           return;
16600       points = current.z;
16601       stream.lineStart();
16602       do {
16603         current.v = current.o.v = true;
16604         if (current.e) {
16605           if (isSubject) {
16606             for (i3 = 0, n3 = points.length; i3 < n3; ++i3)
16607               stream.point((point2 = points[i3])[0], point2[1]);
16608           } else {
16609             interpolate(current.x, current.n.x, 1, stream);
16610           }
16611           current = current.n;
16612         } else {
16613           if (isSubject) {
16614             points = current.p.z;
16615             for (i3 = points.length - 1; i3 >= 0; --i3)
16616               stream.point((point2 = points[i3])[0], point2[1]);
16617           } else {
16618             interpolate(current.x, current.p.x, -1, stream);
16619           }
16620           current = current.p;
16621         }
16622         current = current.o;
16623         points = current.z;
16624         isSubject = !isSubject;
16625       } while (!current.v);
16626       stream.lineEnd();
16627     }
16628   }
16629   function link(array2) {
16630     if (!(n3 = array2.length))
16631       return;
16632     var n3, i3 = 0, a2 = array2[0], b2;
16633     while (++i3 < n3) {
16634       a2.n = b2 = array2[i3];
16635       b2.p = a2;
16636       a2 = b2;
16637     }
16638     a2.n = b2 = array2[0];
16639     b2.p = a2;
16640   }
16641
16642   // node_modules/d3-geo/src/polygonContains.js
16643   function longitude(point2) {
16644     return abs(point2[0]) <= pi ? point2[0] : sign(point2[0]) * ((abs(point2[0]) + pi) % tau - pi);
16645   }
16646   function polygonContains_default(polygon2, point2) {
16647     var lambda = longitude(point2), phi = point2[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
16648     var sum = new Adder();
16649     if (sinPhi === 1)
16650       phi = halfPi + epsilon;
16651     else if (sinPhi === -1)
16652       phi = -halfPi - epsilon;
16653     for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
16654       if (!(m2 = (ring = polygon2[i3]).length))
16655         continue;
16656       var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02);
16657       for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) {
16658         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;
16659         sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta)));
16660         angle2 += antimeridian ? delta + sign2 * tau : delta;
16661         if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) {
16662           var arc = cartesianCross(cartesian(point0), cartesian(point1));
16663           cartesianNormalizeInPlace(arc);
16664           var intersection2 = cartesianCross(normal, arc);
16665           cartesianNormalizeInPlace(intersection2);
16666           var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]);
16667           if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
16668             winding += antimeridian ^ delta >= 0 ? 1 : -1;
16669           }
16670         }
16671       }
16672     }
16673     return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon2) ^ winding & 1;
16674   }
16675
16676   // node_modules/d3-geo/src/clip/index.js
16677   function clip_default(pointVisible, clipLine, interpolate, start2) {
16678     return function(sink) {
16679       var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon2, segments, ring;
16680       var clip = {
16681         point: point2,
16682         lineStart,
16683         lineEnd,
16684         polygonStart: function() {
16685           clip.point = pointRing;
16686           clip.lineStart = ringStart;
16687           clip.lineEnd = ringEnd;
16688           segments = [];
16689           polygon2 = [];
16690         },
16691         polygonEnd: function() {
16692           clip.point = point2;
16693           clip.lineStart = lineStart;
16694           clip.lineEnd = lineEnd;
16695           segments = merge(segments);
16696           var startInside = polygonContains_default(polygon2, start2);
16697           if (segments.length) {
16698             if (!polygonStarted)
16699               sink.polygonStart(), polygonStarted = true;
16700             rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
16701           } else if (startInside) {
16702             if (!polygonStarted)
16703               sink.polygonStart(), polygonStarted = true;
16704             sink.lineStart();
16705             interpolate(null, null, 1, sink);
16706             sink.lineEnd();
16707           }
16708           if (polygonStarted)
16709             sink.polygonEnd(), polygonStarted = false;
16710           segments = polygon2 = null;
16711         },
16712         sphere: function() {
16713           sink.polygonStart();
16714           sink.lineStart();
16715           interpolate(null, null, 1, sink);
16716           sink.lineEnd();
16717           sink.polygonEnd();
16718         }
16719       };
16720       function point2(lambda, phi) {
16721         if (pointVisible(lambda, phi))
16722           sink.point(lambda, phi);
16723       }
16724       function pointLine(lambda, phi) {
16725         line.point(lambda, phi);
16726       }
16727       function lineStart() {
16728         clip.point = pointLine;
16729         line.lineStart();
16730       }
16731       function lineEnd() {
16732         clip.point = point2;
16733         line.lineEnd();
16734       }
16735       function pointRing(lambda, phi) {
16736         ring.push([lambda, phi]);
16737         ringSink.point(lambda, phi);
16738       }
16739       function ringStart() {
16740         ringSink.lineStart();
16741         ring = [];
16742       }
16743       function ringEnd() {
16744         pointRing(ring[0][0], ring[0][1]);
16745         ringSink.lineEnd();
16746         var clean2 = ringSink.clean(), ringSegments = ringBuffer.result(), i3, n3 = ringSegments.length, m2, segment, point3;
16747         ring.pop();
16748         polygon2.push(ring);
16749         ring = null;
16750         if (!n3)
16751           return;
16752         if (clean2 & 1) {
16753           segment = ringSegments[0];
16754           if ((m2 = segment.length - 1) > 0) {
16755             if (!polygonStarted)
16756               sink.polygonStart(), polygonStarted = true;
16757             sink.lineStart();
16758             for (i3 = 0; i3 < m2; ++i3)
16759               sink.point((point3 = segment[i3])[0], point3[1]);
16760             sink.lineEnd();
16761           }
16762           return;
16763         }
16764         if (n3 > 1 && clean2 & 2)
16765           ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
16766         segments.push(ringSegments.filter(validSegment));
16767       }
16768       return clip;
16769     };
16770   }
16771   function validSegment(segment) {
16772     return segment.length > 1;
16773   }
16774   function compareIntersection(a2, b2) {
16775     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]);
16776   }
16777
16778   // node_modules/d3-geo/src/clip/antimeridian.js
16779   var antimeridian_default = clip_default(
16780     function() {
16781       return true;
16782     },
16783     clipAntimeridianLine,
16784     clipAntimeridianInterpolate,
16785     [-pi, -halfPi]
16786   );
16787   function clipAntimeridianLine(stream) {
16788     var lambda04 = NaN, phi02 = NaN, sign0 = NaN, clean2;
16789     return {
16790       lineStart: function() {
16791         stream.lineStart();
16792         clean2 = 1;
16793       },
16794       point: function(lambda12, phi12) {
16795         var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda04);
16796         if (abs(delta - pi) < epsilon) {
16797           stream.point(lambda04, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
16798           stream.point(sign0, phi02);
16799           stream.lineEnd();
16800           stream.lineStart();
16801           stream.point(sign1, phi02);
16802           stream.point(lambda12, phi02);
16803           clean2 = 0;
16804         } else if (sign0 !== sign1 && delta >= pi) {
16805           if (abs(lambda04 - sign0) < epsilon)
16806             lambda04 -= sign0 * epsilon;
16807           if (abs(lambda12 - sign1) < epsilon)
16808             lambda12 -= sign1 * epsilon;
16809           phi02 = clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12);
16810           stream.point(sign0, phi02);
16811           stream.lineEnd();
16812           stream.lineStart();
16813           stream.point(sign1, phi02);
16814           clean2 = 0;
16815         }
16816         stream.point(lambda04 = lambda12, phi02 = phi12);
16817         sign0 = sign1;
16818       },
16819       lineEnd: function() {
16820         stream.lineEnd();
16821         lambda04 = phi02 = NaN;
16822       },
16823       clean: function() {
16824         return 2 - clean2;
16825       }
16826     };
16827   }
16828   function clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12) {
16829     var cosPhi03, cosPhi1, sinLambda0Lambda1 = sin(lambda04 - lambda12);
16830     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;
16831   }
16832   function clipAntimeridianInterpolate(from, to, direction, stream) {
16833     var phi;
16834     if (from == null) {
16835       phi = direction * halfPi;
16836       stream.point(-pi, phi);
16837       stream.point(0, phi);
16838       stream.point(pi, phi);
16839       stream.point(pi, 0);
16840       stream.point(pi, -phi);
16841       stream.point(0, -phi);
16842       stream.point(-pi, -phi);
16843       stream.point(-pi, 0);
16844       stream.point(-pi, phi);
16845     } else if (abs(from[0] - to[0]) > epsilon) {
16846       var lambda = from[0] < to[0] ? pi : -pi;
16847       phi = direction * lambda / 2;
16848       stream.point(-lambda, phi);
16849       stream.point(0, phi);
16850       stream.point(lambda, phi);
16851     } else {
16852       stream.point(to[0], to[1]);
16853     }
16854   }
16855
16856   // node_modules/d3-geo/src/clip/circle.js
16857   function circle_default(radius) {
16858     var cr = cos(radius), delta = 6 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
16859     function interpolate(from, to, direction, stream) {
16860       circleStream(stream, radius, delta, direction, from, to);
16861     }
16862     function visible(lambda, phi) {
16863       return cos(lambda) * cos(phi) > cr;
16864     }
16865     function clipLine(stream) {
16866       var point0, c0, v0, v00, clean2;
16867       return {
16868         lineStart: function() {
16869           v00 = v0 = false;
16870           clean2 = 1;
16871         },
16872         point: function(lambda, phi) {
16873           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;
16874           if (!point0 && (v00 = v0 = v2))
16875             stream.lineStart();
16876           if (v2 !== v0) {
16877             point2 = intersect2(point0, point1);
16878             if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2))
16879               point1[2] = 1;
16880           }
16881           if (v2 !== v0) {
16882             clean2 = 0;
16883             if (v2) {
16884               stream.lineStart();
16885               point2 = intersect2(point1, point0);
16886               stream.point(point2[0], point2[1]);
16887             } else {
16888               point2 = intersect2(point0, point1);
16889               stream.point(point2[0], point2[1], 2);
16890               stream.lineEnd();
16891             }
16892             point0 = point2;
16893           } else if (notHemisphere && point0 && smallRadius ^ v2) {
16894             var t2;
16895             if (!(c2 & c0) && (t2 = intersect2(point1, point0, true))) {
16896               clean2 = 0;
16897               if (smallRadius) {
16898                 stream.lineStart();
16899                 stream.point(t2[0][0], t2[0][1]);
16900                 stream.point(t2[1][0], t2[1][1]);
16901                 stream.lineEnd();
16902               } else {
16903                 stream.point(t2[1][0], t2[1][1]);
16904                 stream.lineEnd();
16905                 stream.lineStart();
16906                 stream.point(t2[0][0], t2[0][1], 3);
16907               }
16908             }
16909           }
16910           if (v2 && (!point0 || !pointEqual_default(point0, point1))) {
16911             stream.point(point1[0], point1[1]);
16912           }
16913           point0 = point1, v0 = v2, c0 = c2;
16914         },
16915         lineEnd: function() {
16916           if (v0)
16917             stream.lineEnd();
16918           point0 = null;
16919         },
16920         // Rejoin first and last segments if there were intersections and the first
16921         // and last points were visible.
16922         clean: function() {
16923           return clean2 | (v00 && v0) << 1;
16924         }
16925       };
16926     }
16927     function intersect2(a2, b2, two) {
16928       var pa = cartesian(a2), pb = cartesian(b2);
16929       var n1 = [1, 0, 0], n22 = cartesianCross(pa, pb), n2n2 = cartesianDot(n22, n22), n1n2 = n22[0], determinant = n2n2 - n1n2 * n1n2;
16930       if (!determinant)
16931         return !two && a2;
16932       var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n22), A2 = cartesianScale(n1, c1), B2 = cartesianScale(n22, c2);
16933       cartesianAddInPlace(A2, B2);
16934       var u2 = n1xn2, w2 = cartesianDot(A2, u2), uu = cartesianDot(u2, u2), t2 = w2 * w2 - uu * (cartesianDot(A2, A2) - 1);
16935       if (t2 < 0)
16936         return;
16937       var t3 = sqrt(t2), q2 = cartesianScale(u2, (-w2 - t3) / uu);
16938       cartesianAddInPlace(q2, A2);
16939       q2 = spherical(q2);
16940       if (!two)
16941         return q2;
16942       var lambda04 = a2[0], lambda12 = b2[0], phi02 = a2[1], phi12 = b2[1], z2;
16943       if (lambda12 < lambda04)
16944         z2 = lambda04, lambda04 = lambda12, lambda12 = z2;
16945       var delta2 = lambda12 - lambda04, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
16946       if (!polar && phi12 < phi02)
16947         z2 = phi02, phi02 = phi12, phi12 = z2;
16948       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)) {
16949         var q1 = cartesianScale(u2, (-w2 + t3) / uu);
16950         cartesianAddInPlace(q1, A2);
16951         return [q2, spherical(q1)];
16952       }
16953     }
16954     function code(lambda, phi) {
16955       var r2 = smallRadius ? radius : pi - radius, code2 = 0;
16956       if (lambda < -r2)
16957         code2 |= 1;
16958       else if (lambda > r2)
16959         code2 |= 2;
16960       if (phi < -r2)
16961         code2 |= 4;
16962       else if (phi > r2)
16963         code2 |= 8;
16964       return code2;
16965     }
16966     return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
16967   }
16968
16969   // node_modules/d3-geo/src/clip/line.js
16970   function line_default(a2, b2, x05, y05, x12, y12) {
16971     var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r2;
16972     r2 = x05 - ax;
16973     if (!dx && r2 > 0)
16974       return;
16975     r2 /= dx;
16976     if (dx < 0) {
16977       if (r2 < t0)
16978         return;
16979       if (r2 < t1)
16980         t1 = r2;
16981     } else if (dx > 0) {
16982       if (r2 > t1)
16983         return;
16984       if (r2 > t0)
16985         t0 = r2;
16986     }
16987     r2 = x12 - ax;
16988     if (!dx && r2 < 0)
16989       return;
16990     r2 /= dx;
16991     if (dx < 0) {
16992       if (r2 > t1)
16993         return;
16994       if (r2 > t0)
16995         t0 = r2;
16996     } else if (dx > 0) {
16997       if (r2 < t0)
16998         return;
16999       if (r2 < t1)
17000         t1 = r2;
17001     }
17002     r2 = y05 - ay;
17003     if (!dy && r2 > 0)
17004       return;
17005     r2 /= dy;
17006     if (dy < 0) {
17007       if (r2 < t0)
17008         return;
17009       if (r2 < t1)
17010         t1 = r2;
17011     } else if (dy > 0) {
17012       if (r2 > t1)
17013         return;
17014       if (r2 > t0)
17015         t0 = r2;
17016     }
17017     r2 = y12 - ay;
17018     if (!dy && r2 < 0)
17019       return;
17020     r2 /= dy;
17021     if (dy < 0) {
17022       if (r2 > t1)
17023         return;
17024       if (r2 > t0)
17025         t0 = r2;
17026     } else if (dy > 0) {
17027       if (r2 < t0)
17028         return;
17029       if (r2 < t1)
17030         t1 = r2;
17031     }
17032     if (t0 > 0)
17033       a2[0] = ax + t0 * dx, a2[1] = ay + t0 * dy;
17034     if (t1 < 1)
17035       b2[0] = ax + t1 * dx, b2[1] = ay + t1 * dy;
17036     return true;
17037   }
17038
17039   // node_modules/d3-geo/src/clip/rectangle.js
17040   var clipMax = 1e9;
17041   var clipMin = -clipMax;
17042   function clipRectangle(x05, y05, x12, y12) {
17043     function visible(x2, y2) {
17044       return x05 <= x2 && x2 <= x12 && y05 <= y2 && y2 <= y12;
17045     }
17046     function interpolate(from, to, direction, stream) {
17047       var a2 = 0, a1 = 0;
17048       if (from == null || (a2 = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
17049         do
17050           stream.point(a2 === 0 || a2 === 3 ? x05 : x12, a2 > 1 ? y12 : y05);
17051         while ((a2 = (a2 + direction + 4) % 4) !== a1);
17052       } else {
17053         stream.point(to[0], to[1]);
17054       }
17055     }
17056     function corner(p2, direction) {
17057       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;
17058     }
17059     function compareIntersection2(a2, b2) {
17060       return comparePoint(a2.x, b2.x);
17061     }
17062     function comparePoint(a2, b2) {
17063       var ca = corner(a2, 1), cb = corner(b2, 1);
17064       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];
17065     }
17066     return function(stream) {
17067       var activeStream = stream, bufferStream = buffer_default(), segments, polygon2, ring, x__, y__, v__, x_, y_, v_, first, clean2;
17068       var clipStream = {
17069         point: point2,
17070         lineStart,
17071         lineEnd,
17072         polygonStart,
17073         polygonEnd
17074       };
17075       function point2(x2, y2) {
17076         if (visible(x2, y2))
17077           activeStream.point(x2, y2);
17078       }
17079       function polygonInside() {
17080         var winding = 0;
17081         for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
17082           for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b0 = point3[0], b1 = point3[1]; j2 < m2; ++j2) {
17083             a0 = b0, a1 = b1, point3 = ring2[j2], b0 = point3[0], b1 = point3[1];
17084             if (a1 <= y12) {
17085               if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0))
17086                 ++winding;
17087             } else {
17088               if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x05 - a0))
17089                 --winding;
17090             }
17091           }
17092         }
17093         return winding;
17094       }
17095       function polygonStart() {
17096         activeStream = bufferStream, segments = [], polygon2 = [], clean2 = true;
17097       }
17098       function polygonEnd() {
17099         var startInside = polygonInside(), cleanInside = clean2 && startInside, visible2 = (segments = merge(segments)).length;
17100         if (cleanInside || visible2) {
17101           stream.polygonStart();
17102           if (cleanInside) {
17103             stream.lineStart();
17104             interpolate(null, null, 1, stream);
17105             stream.lineEnd();
17106           }
17107           if (visible2) {
17108             rejoin_default(segments, compareIntersection2, startInside, interpolate, stream);
17109           }
17110           stream.polygonEnd();
17111         }
17112         activeStream = stream, segments = polygon2 = ring = null;
17113       }
17114       function lineStart() {
17115         clipStream.point = linePoint2;
17116         if (polygon2)
17117           polygon2.push(ring = []);
17118         first = true;
17119         v_ = false;
17120         x_ = y_ = NaN;
17121       }
17122       function lineEnd() {
17123         if (segments) {
17124           linePoint2(x__, y__);
17125           if (v__ && v_)
17126             bufferStream.rejoin();
17127           segments.push(bufferStream.result());
17128         }
17129         clipStream.point = point2;
17130         if (v_)
17131           activeStream.lineEnd();
17132       }
17133       function linePoint2(x2, y2) {
17134         var v2 = visible(x2, y2);
17135         if (polygon2)
17136           ring.push([x2, y2]);
17137         if (first) {
17138           x__ = x2, y__ = y2, v__ = v2;
17139           first = false;
17140           if (v2) {
17141             activeStream.lineStart();
17142             activeStream.point(x2, y2);
17143           }
17144         } else {
17145           if (v2 && v_)
17146             activeStream.point(x2, y2);
17147           else {
17148             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))];
17149             if (line_default(a2, b2, x05, y05, x12, y12)) {
17150               if (!v_) {
17151                 activeStream.lineStart();
17152                 activeStream.point(a2[0], a2[1]);
17153               }
17154               activeStream.point(b2[0], b2[1]);
17155               if (!v2)
17156                 activeStream.lineEnd();
17157               clean2 = false;
17158             } else if (v2) {
17159               activeStream.lineStart();
17160               activeStream.point(x2, y2);
17161               clean2 = false;
17162             }
17163           }
17164         }
17165         x_ = x2, y_ = y2, v_ = v2;
17166       }
17167       return clipStream;
17168     };
17169   }
17170
17171   // node_modules/d3-geo/src/length.js
17172   var lengthSum;
17173   var lambda03;
17174   var sinPhi02;
17175   var cosPhi02;
17176   var lengthStream = {
17177     sphere: noop,
17178     point: noop,
17179     lineStart: lengthLineStart,
17180     lineEnd: noop,
17181     polygonStart: noop,
17182     polygonEnd: noop
17183   };
17184   function lengthLineStart() {
17185     lengthStream.point = lengthPointFirst;
17186     lengthStream.lineEnd = lengthLineEnd;
17187   }
17188   function lengthLineEnd() {
17189     lengthStream.point = lengthStream.lineEnd = noop;
17190   }
17191   function lengthPointFirst(lambda, phi) {
17192     lambda *= radians, phi *= radians;
17193     lambda03 = lambda, sinPhi02 = sin(phi), cosPhi02 = cos(phi);
17194     lengthStream.point = lengthPoint;
17195   }
17196   function lengthPoint(lambda, phi) {
17197     lambda *= radians, phi *= radians;
17198     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;
17199     lengthSum.add(atan2(sqrt(x2 * x2 + y2 * y2), z2));
17200     lambda03 = lambda, sinPhi02 = sinPhi, cosPhi02 = cosPhi;
17201   }
17202   function length_default(object) {
17203     lengthSum = new Adder();
17204     stream_default(object, lengthStream);
17205     return +lengthSum;
17206   }
17207
17208   // node_modules/d3-geo/src/identity.js
17209   var identity_default = (x2) => x2;
17210
17211   // node_modules/d3-geo/src/path/area.js
17212   var areaSum2 = new Adder();
17213   var areaRingSum2 = new Adder();
17214   var x00;
17215   var y00;
17216   var x0;
17217   var y0;
17218   var areaStream2 = {
17219     point: noop,
17220     lineStart: noop,
17221     lineEnd: noop,
17222     polygonStart: function() {
17223       areaStream2.lineStart = areaRingStart2;
17224       areaStream2.lineEnd = areaRingEnd2;
17225     },
17226     polygonEnd: function() {
17227       areaStream2.lineStart = areaStream2.lineEnd = areaStream2.point = noop;
17228       areaSum2.add(abs(areaRingSum2));
17229       areaRingSum2 = new Adder();
17230     },
17231     result: function() {
17232       var area = areaSum2 / 2;
17233       areaSum2 = new Adder();
17234       return area;
17235     }
17236   };
17237   function areaRingStart2() {
17238     areaStream2.point = areaPointFirst2;
17239   }
17240   function areaPointFirst2(x2, y2) {
17241     areaStream2.point = areaPoint2;
17242     x00 = x0 = x2, y00 = y0 = y2;
17243   }
17244   function areaPoint2(x2, y2) {
17245     areaRingSum2.add(y0 * x2 - x0 * y2);
17246     x0 = x2, y0 = y2;
17247   }
17248   function areaRingEnd2() {
17249     areaPoint2(x00, y00);
17250   }
17251   var area_default2 = areaStream2;
17252
17253   // node_modules/d3-geo/src/path/bounds.js
17254   var x02 = Infinity;
17255   var y02 = x02;
17256   var x1 = -x02;
17257   var y1 = x1;
17258   var boundsStream2 = {
17259     point: boundsPoint2,
17260     lineStart: noop,
17261     lineEnd: noop,
17262     polygonStart: noop,
17263     polygonEnd: noop,
17264     result: function() {
17265       var bounds = [[x02, y02], [x1, y1]];
17266       x1 = y1 = -(y02 = x02 = Infinity);
17267       return bounds;
17268     }
17269   };
17270   function boundsPoint2(x2, y2) {
17271     if (x2 < x02)
17272       x02 = x2;
17273     if (x2 > x1)
17274       x1 = x2;
17275     if (y2 < y02)
17276       y02 = y2;
17277     if (y2 > y1)
17278       y1 = y2;
17279   }
17280   var bounds_default2 = boundsStream2;
17281
17282   // node_modules/d3-geo/src/path/centroid.js
17283   var X0 = 0;
17284   var Y0 = 0;
17285   var Z0 = 0;
17286   var X1 = 0;
17287   var Y1 = 0;
17288   var Z1 = 0;
17289   var X2 = 0;
17290   var Y2 = 0;
17291   var Z2 = 0;
17292   var x002;
17293   var y002;
17294   var x03;
17295   var y03;
17296   var centroidStream = {
17297     point: centroidPoint,
17298     lineStart: centroidLineStart,
17299     lineEnd: centroidLineEnd,
17300     polygonStart: function() {
17301       centroidStream.lineStart = centroidRingStart;
17302       centroidStream.lineEnd = centroidRingEnd;
17303     },
17304     polygonEnd: function() {
17305       centroidStream.point = centroidPoint;
17306       centroidStream.lineStart = centroidLineStart;
17307       centroidStream.lineEnd = centroidLineEnd;
17308     },
17309     result: function() {
17310       var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
17311       X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
17312       return centroid;
17313     }
17314   };
17315   function centroidPoint(x2, y2) {
17316     X0 += x2;
17317     Y0 += y2;
17318     ++Z0;
17319   }
17320   function centroidLineStart() {
17321     centroidStream.point = centroidPointFirstLine;
17322   }
17323   function centroidPointFirstLine(x2, y2) {
17324     centroidStream.point = centroidPointLine;
17325     centroidPoint(x03 = x2, y03 = y2);
17326   }
17327   function centroidPointLine(x2, y2) {
17328     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17329     X1 += z2 * (x03 + x2) / 2;
17330     Y1 += z2 * (y03 + y2) / 2;
17331     Z1 += z2;
17332     centroidPoint(x03 = x2, y03 = y2);
17333   }
17334   function centroidLineEnd() {
17335     centroidStream.point = centroidPoint;
17336   }
17337   function centroidRingStart() {
17338     centroidStream.point = centroidPointFirstRing;
17339   }
17340   function centroidRingEnd() {
17341     centroidPointRing(x002, y002);
17342   }
17343   function centroidPointFirstRing(x2, y2) {
17344     centroidStream.point = centroidPointRing;
17345     centroidPoint(x002 = x03 = x2, y002 = y03 = y2);
17346   }
17347   function centroidPointRing(x2, y2) {
17348     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17349     X1 += z2 * (x03 + x2) / 2;
17350     Y1 += z2 * (y03 + y2) / 2;
17351     Z1 += z2;
17352     z2 = y03 * x2 - x03 * y2;
17353     X2 += z2 * (x03 + x2);
17354     Y2 += z2 * (y03 + y2);
17355     Z2 += z2 * 3;
17356     centroidPoint(x03 = x2, y03 = y2);
17357   }
17358   var centroid_default = centroidStream;
17359
17360   // node_modules/d3-geo/src/path/context.js
17361   function PathContext(context) {
17362     this._context = context;
17363   }
17364   PathContext.prototype = {
17365     _radius: 4.5,
17366     pointRadius: function(_2) {
17367       return this._radius = _2, this;
17368     },
17369     polygonStart: function() {
17370       this._line = 0;
17371     },
17372     polygonEnd: function() {
17373       this._line = NaN;
17374     },
17375     lineStart: function() {
17376       this._point = 0;
17377     },
17378     lineEnd: function() {
17379       if (this._line === 0)
17380         this._context.closePath();
17381       this._point = NaN;
17382     },
17383     point: function(x2, y2) {
17384       switch (this._point) {
17385         case 0: {
17386           this._context.moveTo(x2, y2);
17387           this._point = 1;
17388           break;
17389         }
17390         case 1: {
17391           this._context.lineTo(x2, y2);
17392           break;
17393         }
17394         default: {
17395           this._context.moveTo(x2 + this._radius, y2);
17396           this._context.arc(x2, y2, this._radius, 0, tau);
17397           break;
17398         }
17399       }
17400     },
17401     result: noop
17402   };
17403
17404   // node_modules/d3-geo/src/path/measure.js
17405   var lengthSum2 = new Adder();
17406   var lengthRing;
17407   var x003;
17408   var y003;
17409   var x04;
17410   var y04;
17411   var lengthStream2 = {
17412     point: noop,
17413     lineStart: function() {
17414       lengthStream2.point = lengthPointFirst2;
17415     },
17416     lineEnd: function() {
17417       if (lengthRing)
17418         lengthPoint2(x003, y003);
17419       lengthStream2.point = noop;
17420     },
17421     polygonStart: function() {
17422       lengthRing = true;
17423     },
17424     polygonEnd: function() {
17425       lengthRing = null;
17426     },
17427     result: function() {
17428       var length2 = +lengthSum2;
17429       lengthSum2 = new Adder();
17430       return length2;
17431     }
17432   };
17433   function lengthPointFirst2(x2, y2) {
17434     lengthStream2.point = lengthPoint2;
17435     x003 = x04 = x2, y003 = y04 = y2;
17436   }
17437   function lengthPoint2(x2, y2) {
17438     x04 -= x2, y04 -= y2;
17439     lengthSum2.add(sqrt(x04 * x04 + y04 * y04));
17440     x04 = x2, y04 = y2;
17441   }
17442   var measure_default = lengthStream2;
17443
17444   // node_modules/d3-geo/src/path/string.js
17445   function PathString() {
17446     this._string = [];
17447   }
17448   PathString.prototype = {
17449     _radius: 4.5,
17450     _circle: circle(4.5),
17451     pointRadius: function(_2) {
17452       if ((_2 = +_2) !== this._radius)
17453         this._radius = _2, this._circle = null;
17454       return this;
17455     },
17456     polygonStart: function() {
17457       this._line = 0;
17458     },
17459     polygonEnd: function() {
17460       this._line = NaN;
17461     },
17462     lineStart: function() {
17463       this._point = 0;
17464     },
17465     lineEnd: function() {
17466       if (this._line === 0)
17467         this._string.push("Z");
17468       this._point = NaN;
17469     },
17470     point: function(x2, y2) {
17471       switch (this._point) {
17472         case 0: {
17473           this._string.push("M", x2, ",", y2);
17474           this._point = 1;
17475           break;
17476         }
17477         case 1: {
17478           this._string.push("L", x2, ",", y2);
17479           break;
17480         }
17481         default: {
17482           if (this._circle == null)
17483             this._circle = circle(this._radius);
17484           this._string.push("M", x2, ",", y2, this._circle);
17485           break;
17486         }
17487       }
17488     },
17489     result: function() {
17490       if (this._string.length) {
17491         var result = this._string.join("");
17492         this._string = [];
17493         return result;
17494       } else {
17495         return null;
17496       }
17497     }
17498   };
17499   function circle(radius) {
17500     return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
17501   }
17502
17503   // node_modules/d3-geo/src/path/index.js
17504   function path_default(projection2, context) {
17505     var pointRadius = 4.5, projectionStream, contextStream;
17506     function path(object) {
17507       if (object) {
17508         if (typeof pointRadius === "function")
17509           contextStream.pointRadius(+pointRadius.apply(this, arguments));
17510         stream_default(object, projectionStream(contextStream));
17511       }
17512       return contextStream.result();
17513     }
17514     path.area = function(object) {
17515       stream_default(object, projectionStream(area_default2));
17516       return area_default2.result();
17517     };
17518     path.measure = function(object) {
17519       stream_default(object, projectionStream(measure_default));
17520       return measure_default.result();
17521     };
17522     path.bounds = function(object) {
17523       stream_default(object, projectionStream(bounds_default2));
17524       return bounds_default2.result();
17525     };
17526     path.centroid = function(object) {
17527       stream_default(object, projectionStream(centroid_default));
17528       return centroid_default.result();
17529     };
17530     path.projection = function(_2) {
17531       return arguments.length ? (projectionStream = _2 == null ? (projection2 = null, identity_default) : (projection2 = _2).stream, path) : projection2;
17532     };
17533     path.context = function(_2) {
17534       if (!arguments.length)
17535         return context;
17536       contextStream = _2 == null ? (context = null, new PathString()) : new PathContext(context = _2);
17537       if (typeof pointRadius !== "function")
17538         contextStream.pointRadius(pointRadius);
17539       return path;
17540     };
17541     path.pointRadius = function(_2) {
17542       if (!arguments.length)
17543         return pointRadius;
17544       pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2);
17545       return path;
17546     };
17547     return path.projection(projection2).context(context);
17548   }
17549
17550   // node_modules/d3-geo/src/transform.js
17551   function transform_default(methods2) {
17552     return {
17553       stream: transformer(methods2)
17554     };
17555   }
17556   function transformer(methods2) {
17557     return function(stream) {
17558       var s2 = new TransformStream();
17559       for (var key in methods2)
17560         s2[key] = methods2[key];
17561       s2.stream = stream;
17562       return s2;
17563     };
17564   }
17565   function TransformStream() {
17566   }
17567   TransformStream.prototype = {
17568     constructor: TransformStream,
17569     point: function(x2, y2) {
17570       this.stream.point(x2, y2);
17571     },
17572     sphere: function() {
17573       this.stream.sphere();
17574     },
17575     lineStart: function() {
17576       this.stream.lineStart();
17577     },
17578     lineEnd: function() {
17579       this.stream.lineEnd();
17580     },
17581     polygonStart: function() {
17582       this.stream.polygonStart();
17583     },
17584     polygonEnd: function() {
17585       this.stream.polygonEnd();
17586     }
17587   };
17588
17589   // node_modules/d3-geo/src/projection/fit.js
17590   function fit(projection2, fitBounds, object) {
17591     var clip = projection2.clipExtent && projection2.clipExtent();
17592     projection2.scale(150).translate([0, 0]);
17593     if (clip != null)
17594       projection2.clipExtent(null);
17595     stream_default(object, projection2.stream(bounds_default2));
17596     fitBounds(bounds_default2.result());
17597     if (clip != null)
17598       projection2.clipExtent(clip);
17599     return projection2;
17600   }
17601   function fitExtent(projection2, extent, object) {
17602     return fit(projection2, function(b2) {
17603       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;
17604       projection2.scale(150 * k2).translate([x2, y2]);
17605     }, object);
17606   }
17607   function fitSize(projection2, size, object) {
17608     return fitExtent(projection2, [[0, 0], size], object);
17609   }
17610   function fitWidth(projection2, width, object) {
17611     return fit(projection2, function(b2) {
17612       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];
17613       projection2.scale(150 * k2).translate([x2, y2]);
17614     }, object);
17615   }
17616   function fitHeight(projection2, height, object) {
17617     return fit(projection2, function(b2) {
17618       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;
17619       projection2.scale(150 * k2).translate([x2, y2]);
17620     }, object);
17621   }
17622
17623   // node_modules/d3-geo/src/projection/resample.js
17624   var maxDepth = 16;
17625   var cosMinDistance = cos(30 * radians);
17626   function resample_default(project, delta2) {
17627     return +delta2 ? resample(project, delta2) : resampleNone(project);
17628   }
17629   function resampleNone(project) {
17630     return transformer({
17631       point: function(x2, y2) {
17632         x2 = project(x2, y2);
17633         this.stream.point(x2[0], x2[1]);
17634       }
17635     });
17636   }
17637   function resample(project, delta2) {
17638     function resampleLineTo(x05, y05, lambda04, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
17639       var dx = x12 - x05, dy = y12 - y05, d2 = dx * dx + dy * dy;
17640       if (d2 > 4 * delta2 && depth--) {
17641         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;
17642         if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
17643           resampleLineTo(x05, y05, lambda04, a0, b0, c0, x2, y2, lambda22, a2 /= m2, b2 /= m2, c2, depth, stream);
17644           stream.point(x2, y2);
17645           resampleLineTo(x2, y2, lambda22, a2, b2, c2, x12, y12, lambda12, a1, b1, c1, depth, stream);
17646         }
17647       }
17648     }
17649     return function(stream) {
17650       var lambda003, x004, y004, a00, b00, c00, lambda04, x05, y05, a0, b0, c0;
17651       var resampleStream = {
17652         point: point2,
17653         lineStart,
17654         lineEnd,
17655         polygonStart: function() {
17656           stream.polygonStart();
17657           resampleStream.lineStart = ringStart;
17658         },
17659         polygonEnd: function() {
17660           stream.polygonEnd();
17661           resampleStream.lineStart = lineStart;
17662         }
17663       };
17664       function point2(x2, y2) {
17665         x2 = project(x2, y2);
17666         stream.point(x2[0], x2[1]);
17667       }
17668       function lineStart() {
17669         x05 = NaN;
17670         resampleStream.point = linePoint2;
17671         stream.lineStart();
17672       }
17673       function linePoint2(lambda, phi) {
17674         var c2 = cartesian([lambda, phi]), p2 = project(lambda, phi);
17675         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);
17676         stream.point(x05, y05);
17677       }
17678       function lineEnd() {
17679         resampleStream.point = point2;
17680         stream.lineEnd();
17681       }
17682       function ringStart() {
17683         lineStart();
17684         resampleStream.point = ringPoint;
17685         resampleStream.lineEnd = ringEnd;
17686       }
17687       function ringPoint(lambda, phi) {
17688         linePoint2(lambda003 = lambda, phi), x004 = x05, y004 = y05, a00 = a0, b00 = b0, c00 = c0;
17689         resampleStream.point = linePoint2;
17690       }
17691       function ringEnd() {
17692         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x004, y004, lambda003, a00, b00, c00, maxDepth, stream);
17693         resampleStream.lineEnd = lineEnd;
17694         lineEnd();
17695       }
17696       return resampleStream;
17697     };
17698   }
17699
17700   // node_modules/d3-geo/src/projection/index.js
17701   var transformRadians = transformer({
17702     point: function(x2, y2) {
17703       this.stream.point(x2 * radians, y2 * radians);
17704     }
17705   });
17706   function transformRotate(rotate) {
17707     return transformer({
17708       point: function(x2, y2) {
17709         var r2 = rotate(x2, y2);
17710         return this.stream.point(r2[0], r2[1]);
17711       }
17712     });
17713   }
17714   function scaleTranslate(k2, dx, dy, sx, sy) {
17715     function transform2(x2, y2) {
17716       x2 *= sx;
17717       y2 *= sy;
17718       return [dx + k2 * x2, dy - k2 * y2];
17719     }
17720     transform2.invert = function(x2, y2) {
17721       return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy];
17722     };
17723     return transform2;
17724   }
17725   function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) {
17726     if (!alpha)
17727       return scaleTranslate(k2, dx, dy, sx, sy);
17728     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;
17729     function transform2(x2, y2) {
17730       x2 *= sx;
17731       y2 *= sy;
17732       return [a2 * x2 - b2 * y2 + dx, dy - b2 * x2 - a2 * y2];
17733     }
17734     transform2.invert = function(x2, y2) {
17735       return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)];
17736     };
17737     return transform2;
17738   }
17739   function projection(project) {
17740     return projectionMutator(function() {
17741       return project;
17742     })();
17743   }
17744   function projectionMutator(projectAt) {
17745     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;
17746     function projection2(point2) {
17747       return projectRotateTransform(point2[0] * radians, point2[1] * radians);
17748     }
17749     function invert(point2) {
17750       point2 = projectRotateTransform.invert(point2[0], point2[1]);
17751       return point2 && [point2[0] * degrees, point2[1] * degrees];
17752     }
17753     projection2.stream = function(stream) {
17754       return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
17755     };
17756     projection2.preclip = function(_2) {
17757       return arguments.length ? (preclip = _2, theta = void 0, reset()) : preclip;
17758     };
17759     projection2.postclip = function(_2) {
17760       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
17761     };
17762     projection2.clipAngle = function(_2) {
17763       return arguments.length ? (preclip = +_2 ? circle_default(theta = _2 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
17764     };
17765     projection2.clipExtent = function(_2) {
17766       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]];
17767     };
17768     projection2.scale = function(_2) {
17769       return arguments.length ? (k2 = +_2, recenter()) : k2;
17770     };
17771     projection2.translate = function(_2) {
17772       return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2];
17773     };
17774     projection2.center = function(_2) {
17775       return arguments.length ? (lambda = _2[0] % 360 * radians, phi = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
17776     };
17777     projection2.rotate = function(_2) {
17778       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];
17779     };
17780     projection2.angle = function(_2) {
17781       return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees;
17782     };
17783     projection2.reflectX = function(_2) {
17784       return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0;
17785     };
17786     projection2.reflectY = function(_2) {
17787       return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0;
17788     };
17789     projection2.precision = function(_2) {
17790       return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _2 * _2), reset()) : sqrt(delta2);
17791     };
17792     projection2.fitExtent = function(extent, object) {
17793       return fitExtent(projection2, extent, object);
17794     };
17795     projection2.fitSize = function(size, object) {
17796       return fitSize(projection2, size, object);
17797     };
17798     projection2.fitWidth = function(width, object) {
17799       return fitWidth(projection2, width, object);
17800     };
17801     projection2.fitHeight = function(height, object) {
17802       return fitHeight(projection2, height, object);
17803     };
17804     function recenter() {
17805       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);
17806       rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
17807       projectTransform = compose_default(project, transform2);
17808       projectRotateTransform = compose_default(rotate, projectTransform);
17809       projectResample = resample_default(projectTransform, delta2);
17810       return reset();
17811     }
17812     function reset() {
17813       cache = cacheStream = null;
17814       return projection2;
17815     }
17816     return function() {
17817       project = projectAt.apply(this, arguments);
17818       projection2.invert = project.invert && invert;
17819       return recenter();
17820     };
17821   }
17822
17823   // node_modules/d3-geo/src/projection/mercator.js
17824   function mercatorRaw(lambda, phi) {
17825     return [lambda, log(tan((halfPi + phi) / 2))];
17826   }
17827   mercatorRaw.invert = function(x2, y2) {
17828     return [x2, 2 * atan(exp(y2)) - halfPi];
17829   };
17830   function mercator_default() {
17831     return mercatorProjection(mercatorRaw).scale(961 / tau);
17832   }
17833   function mercatorProjection(project) {
17834     var m2 = projection(project), center = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x05 = null, y05, x12, y12;
17835     m2.scale = function(_2) {
17836       return arguments.length ? (scale(_2), reclip()) : scale();
17837     };
17838     m2.translate = function(_2) {
17839       return arguments.length ? (translate(_2), reclip()) : translate();
17840     };
17841     m2.center = function(_2) {
17842       return arguments.length ? (center(_2), reclip()) : center();
17843     };
17844     m2.clipExtent = function(_2) {
17845       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]];
17846     };
17847     function reclip() {
17848       var k2 = pi * scale(), t2 = m2(rotation_default(m2.rotate()).invert([0, 0]));
17849       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)]]);
17850     }
17851     return reclip();
17852   }
17853
17854   // node_modules/d3-geo/src/projection/identity.js
17855   function identity_default2() {
17856     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({
17857       point: function(x2, y2) {
17858         var p2 = projection2([x2, y2]);
17859         this.stream.point(p2[0], p2[1]);
17860       }
17861     }), postclip = identity_default, cache, cacheStream;
17862     function reset() {
17863       kx = k2 * sx;
17864       ky = k2 * sy;
17865       cache = cacheStream = null;
17866       return projection2;
17867     }
17868     function projection2(p2) {
17869       var x2 = p2[0] * kx, y2 = p2[1] * ky;
17870       if (alpha) {
17871         var t2 = y2 * ca - x2 * sa;
17872         x2 = x2 * ca + y2 * sa;
17873         y2 = t2;
17874       }
17875       return [x2 + tx, y2 + ty];
17876     }
17877     projection2.invert = function(p2) {
17878       var x2 = p2[0] - tx, y2 = p2[1] - ty;
17879       if (alpha) {
17880         var t2 = y2 * ca + x2 * sa;
17881         x2 = x2 * ca - y2 * sa;
17882         y2 = t2;
17883       }
17884       return [x2 / kx, y2 / ky];
17885     };
17886     projection2.stream = function(stream) {
17887       return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
17888     };
17889     projection2.postclip = function(_2) {
17890       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
17891     };
17892     projection2.clipExtent = function(_2) {
17893       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]];
17894     };
17895     projection2.scale = function(_2) {
17896       return arguments.length ? (k2 = +_2, reset()) : k2;
17897     };
17898     projection2.translate = function(_2) {
17899       return arguments.length ? (tx = +_2[0], ty = +_2[1], reset()) : [tx, ty];
17900     };
17901     projection2.angle = function(_2) {
17902       return arguments.length ? (alpha = _2 % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
17903     };
17904     projection2.reflectX = function(_2) {
17905       return arguments.length ? (sx = _2 ? -1 : 1, reset()) : sx < 0;
17906     };
17907     projection2.reflectY = function(_2) {
17908       return arguments.length ? (sy = _2 ? -1 : 1, reset()) : sy < 0;
17909     };
17910     projection2.fitExtent = function(extent, object) {
17911       return fitExtent(projection2, extent, object);
17912     };
17913     projection2.fitSize = function(size, object) {
17914       return fitSize(projection2, size, object);
17915     };
17916     projection2.fitWidth = function(width, object) {
17917       return fitWidth(projection2, width, object);
17918     };
17919     projection2.fitHeight = function(height, object) {
17920       return fitHeight(projection2, height, object);
17921     };
17922     return projection2;
17923   }
17924
17925   // modules/geo/geo.js
17926   var TAU = 2 * Math.PI;
17927   var EQUATORIAL_RADIUS = 6378137;
17928   var POLAR_RADIUS = 63567523e-1;
17929   function geoLatToMeters(dLat) {
17930     return dLat * (TAU * POLAR_RADIUS / 360);
17931   }
17932   function geoLonToMeters(dLon, atLat) {
17933     return Math.abs(atLat) >= 90 ? 0 : dLon * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(atLat * (Math.PI / 180)));
17934   }
17935   function geoMetersToLat(m2) {
17936     return m2 / (TAU * POLAR_RADIUS / 360);
17937   }
17938   function geoMetersToLon(m2, atLat) {
17939     return Math.abs(atLat) >= 90 ? 0 : m2 / (TAU * EQUATORIAL_RADIUS / 360) / Math.abs(Math.cos(atLat * (Math.PI / 180)));
17940   }
17941   function geoMetersToOffset(meters, tileSize) {
17942     tileSize = tileSize || 256;
17943     return [
17944       meters[0] * tileSize / (TAU * EQUATORIAL_RADIUS),
17945       -meters[1] * tileSize / (TAU * POLAR_RADIUS)
17946     ];
17947   }
17948   function geoOffsetToMeters(offset, tileSize) {
17949     tileSize = tileSize || 256;
17950     return [
17951       offset[0] * TAU * EQUATORIAL_RADIUS / tileSize,
17952       -offset[1] * TAU * POLAR_RADIUS / tileSize
17953     ];
17954   }
17955   function geoSphericalDistance(a2, b2) {
17956     var x2 = geoLonToMeters(a2[0] - b2[0], (a2[1] + b2[1]) / 2);
17957     var y2 = geoLatToMeters(a2[1] - b2[1]);
17958     return Math.sqrt(x2 * x2 + y2 * y2);
17959   }
17960   function geoScaleToZoom(k2, tileSize) {
17961     tileSize = tileSize || 256;
17962     var log2ts = Math.log(tileSize) * Math.LOG2E;
17963     return Math.log(k2 * TAU) / Math.LN2 - log2ts;
17964   }
17965   function geoZoomToScale(z2, tileSize) {
17966     tileSize = tileSize || 256;
17967     return tileSize * Math.pow(2, z2) / TAU;
17968   }
17969   function geoSphericalClosestNode(nodes, point2) {
17970     var minDistance = Infinity, distance;
17971     var indexOfMin;
17972     for (var i3 in nodes) {
17973       distance = geoSphericalDistance(nodes[i3].loc, point2);
17974       if (distance < minDistance) {
17975         minDistance = distance;
17976         indexOfMin = i3;
17977       }
17978     }
17979     if (indexOfMin !== void 0) {
17980       return { index: indexOfMin, distance: minDistance, node: nodes[indexOfMin] };
17981     } else {
17982       return null;
17983     }
17984   }
17985
17986   // modules/geo/extent.js
17987   function geoExtent(min3, max3) {
17988     if (!(this instanceof geoExtent)) {
17989       return new geoExtent(min3, max3);
17990     } else if (min3 instanceof geoExtent) {
17991       return min3;
17992     } else if (min3 && min3.length === 2 && min3[0].length === 2 && min3[1].length === 2) {
17993       this[0] = min3[0];
17994       this[1] = min3[1];
17995     } else {
17996       this[0] = min3 || [Infinity, Infinity];
17997       this[1] = max3 || min3 || [-Infinity, -Infinity];
17998     }
17999   }
18000   geoExtent.prototype = new Array(2);
18001   Object.assign(geoExtent.prototype, {
18002     equals: function(obj) {
18003       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];
18004     },
18005     extend: function(obj) {
18006       if (!(obj instanceof geoExtent))
18007         obj = new geoExtent(obj);
18008       return geoExtent(
18009         [Math.min(obj[0][0], this[0][0]), Math.min(obj[0][1], this[0][1])],
18010         [Math.max(obj[1][0], this[1][0]), Math.max(obj[1][1], this[1][1])]
18011       );
18012     },
18013     _extend: function(extent) {
18014       this[0][0] = Math.min(extent[0][0], this[0][0]);
18015       this[0][1] = Math.min(extent[0][1], this[0][1]);
18016       this[1][0] = Math.max(extent[1][0], this[1][0]);
18017       this[1][1] = Math.max(extent[1][1], this[1][1]);
18018     },
18019     area: function() {
18020       return Math.abs((this[1][0] - this[0][0]) * (this[1][1] - this[0][1]));
18021     },
18022     center: function() {
18023       return [(this[0][0] + this[1][0]) / 2, (this[0][1] + this[1][1]) / 2];
18024     },
18025     rectangle: function() {
18026       return [this[0][0], this[0][1], this[1][0], this[1][1]];
18027     },
18028     bbox: function() {
18029       return { minX: this[0][0], minY: this[0][1], maxX: this[1][0], maxY: this[1][1] };
18030     },
18031     polygon: function() {
18032       return [
18033         [this[0][0], this[0][1]],
18034         [this[0][0], this[1][1]],
18035         [this[1][0], this[1][1]],
18036         [this[1][0], this[0][1]],
18037         [this[0][0], this[0][1]]
18038       ];
18039     },
18040     contains: function(obj) {
18041       if (!(obj instanceof geoExtent))
18042         obj = new geoExtent(obj);
18043       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];
18044     },
18045     intersects: function(obj) {
18046       if (!(obj instanceof geoExtent))
18047         obj = new geoExtent(obj);
18048       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];
18049     },
18050     intersection: function(obj) {
18051       if (!this.intersects(obj))
18052         return new geoExtent();
18053       return new geoExtent(
18054         [Math.max(obj[0][0], this[0][0]), Math.max(obj[0][1], this[0][1])],
18055         [Math.min(obj[1][0], this[1][0]), Math.min(obj[1][1], this[1][1])]
18056       );
18057     },
18058     percentContainedIn: function(obj) {
18059       if (!(obj instanceof geoExtent))
18060         obj = new geoExtent(obj);
18061       var a1 = this.intersection(obj).area();
18062       var a2 = this.area();
18063       if (a1 === Infinity || a2 === Infinity) {
18064         return 0;
18065       } else if (a1 === 0 || a2 === 0) {
18066         if (obj.contains(this)) {
18067           return 1;
18068         }
18069         return 0;
18070       } else {
18071         return a1 / a2;
18072       }
18073     },
18074     padByMeters: function(meters) {
18075       var dLat = geoMetersToLat(meters);
18076       var dLon = geoMetersToLon(meters, this.center()[1]);
18077       return geoExtent(
18078         [this[0][0] - dLon, this[0][1] - dLat],
18079         [this[1][0] + dLon, this[1][1] + dLat]
18080       );
18081     },
18082     toParam: function() {
18083       return this.rectangle().join(",");
18084     },
18085     split: function() {
18086       const center = this.center();
18087       return [
18088         geoExtent(this[0], center),
18089         geoExtent([center[0], this[0][1]], [this[1][0], center[1]]),
18090         geoExtent(center, this[1]),
18091         geoExtent([this[0][0], center[1]], [center[0], this[1][1]])
18092       ];
18093     }
18094   });
18095
18096   // node_modules/d3-polygon/src/area.js
18097   function area_default3(polygon2) {
18098     var i3 = -1, n3 = polygon2.length, a2, b2 = polygon2[n3 - 1], area = 0;
18099     while (++i3 < n3) {
18100       a2 = b2;
18101       b2 = polygon2[i3];
18102       area += a2[1] * b2[0] - a2[0] * b2[1];
18103     }
18104     return area / 2;
18105   }
18106
18107   // node_modules/d3-polygon/src/centroid.js
18108   function centroid_default2(polygon2) {
18109     var i3 = -1, n3 = polygon2.length, x2 = 0, y2 = 0, a2, b2 = polygon2[n3 - 1], c2, k2 = 0;
18110     while (++i3 < n3) {
18111       a2 = b2;
18112       b2 = polygon2[i3];
18113       k2 += c2 = a2[0] * b2[1] - b2[0] * a2[1];
18114       x2 += (a2[0] + b2[0]) * c2;
18115       y2 += (a2[1] + b2[1]) * c2;
18116     }
18117     return k2 *= 3, [x2 / k2, y2 / k2];
18118   }
18119
18120   // node_modules/d3-polygon/src/cross.js
18121   function cross_default(a2, b2, c2) {
18122     return (b2[0] - a2[0]) * (c2[1] - a2[1]) - (b2[1] - a2[1]) * (c2[0] - a2[0]);
18123   }
18124
18125   // node_modules/d3-polygon/src/hull.js
18126   function lexicographicOrder(a2, b2) {
18127     return a2[0] - b2[0] || a2[1] - b2[1];
18128   }
18129   function computeUpperHullIndexes(points) {
18130     const n3 = points.length, indexes = [0, 1];
18131     let size = 2, i3;
18132     for (i3 = 2; i3 < n3; ++i3) {
18133       while (size > 1 && cross_default(points[indexes[size - 2]], points[indexes[size - 1]], points[i3]) <= 0)
18134         --size;
18135       indexes[size++] = i3;
18136     }
18137     return indexes.slice(0, size);
18138   }
18139   function hull_default(points) {
18140     if ((n3 = points.length) < 3)
18141       return null;
18142     var i3, n3, sortedPoints = new Array(n3), flippedPoints = new Array(n3);
18143     for (i3 = 0; i3 < n3; ++i3)
18144       sortedPoints[i3] = [+points[i3][0], +points[i3][1], i3];
18145     sortedPoints.sort(lexicographicOrder);
18146     for (i3 = 0; i3 < n3; ++i3)
18147       flippedPoints[i3] = [sortedPoints[i3][0], -sortedPoints[i3][1]];
18148     var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints);
18149     var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull = [];
18150     for (i3 = upperIndexes.length - 1; i3 >= 0; --i3)
18151       hull.push(points[sortedPoints[upperIndexes[i3]][2]]);
18152     for (i3 = +skipLeft; i3 < lowerIndexes.length - skipRight; ++i3)
18153       hull.push(points[sortedPoints[lowerIndexes[i3]][2]]);
18154     return hull;
18155   }
18156
18157   // modules/geo/vector.js
18158   function geoVecEqual(a2, b2, epsilon3) {
18159     if (epsilon3) {
18160       return Math.abs(a2[0] - b2[0]) <= epsilon3 && Math.abs(a2[1] - b2[1]) <= epsilon3;
18161     } else {
18162       return a2[0] === b2[0] && a2[1] === b2[1];
18163     }
18164   }
18165   function geoVecAdd(a2, b2) {
18166     return [a2[0] + b2[0], a2[1] + b2[1]];
18167   }
18168   function geoVecSubtract(a2, b2) {
18169     return [a2[0] - b2[0], a2[1] - b2[1]];
18170   }
18171   function geoVecScale(a2, mag) {
18172     return [a2[0] * mag, a2[1] * mag];
18173   }
18174   function geoVecFloor(a2) {
18175     return [Math.floor(a2[0]), Math.floor(a2[1])];
18176   }
18177   function geoVecInterp(a2, b2, t2) {
18178     return [
18179       a2[0] + (b2[0] - a2[0]) * t2,
18180       a2[1] + (b2[1] - a2[1]) * t2
18181     ];
18182   }
18183   function geoVecLength(a2, b2) {
18184     return Math.sqrt(geoVecLengthSquare(a2, b2));
18185   }
18186   function geoVecLengthSquare(a2, b2) {
18187     b2 = b2 || [0, 0];
18188     var x2 = a2[0] - b2[0];
18189     var y2 = a2[1] - b2[1];
18190     return x2 * x2 + y2 * y2;
18191   }
18192   function geoVecNormalize(a2) {
18193     var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
18194     if (length2 !== 0) {
18195       return geoVecScale(a2, 1 / length2);
18196     }
18197     return [0, 0];
18198   }
18199   function geoVecAngle(a2, b2) {
18200     return Math.atan2(b2[1] - a2[1], b2[0] - a2[0]);
18201   }
18202   function geoVecDot(a2, b2, origin) {
18203     origin = origin || [0, 0];
18204     var p2 = geoVecSubtract(a2, origin);
18205     var q2 = geoVecSubtract(b2, origin);
18206     return p2[0] * q2[0] + p2[1] * q2[1];
18207   }
18208   function geoVecNormalizedDot(a2, b2, origin) {
18209     origin = origin || [0, 0];
18210     var p2 = geoVecNormalize(geoVecSubtract(a2, origin));
18211     var q2 = geoVecNormalize(geoVecSubtract(b2, origin));
18212     return geoVecDot(p2, q2);
18213   }
18214   function geoVecCross(a2, b2, origin) {
18215     origin = origin || [0, 0];
18216     var p2 = geoVecSubtract(a2, origin);
18217     var q2 = geoVecSubtract(b2, origin);
18218     return p2[0] * q2[1] - p2[1] * q2[0];
18219   }
18220   function geoVecProject(a2, points) {
18221     var min3 = Infinity;
18222     var idx;
18223     var target;
18224     for (var i3 = 0; i3 < points.length - 1; i3++) {
18225       var o2 = points[i3];
18226       var s2 = geoVecSubtract(points[i3 + 1], o2);
18227       var v2 = geoVecSubtract(a2, o2);
18228       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18229       var p2;
18230       if (proj < 0) {
18231         p2 = o2;
18232       } else if (proj > 1) {
18233         p2 = points[i3 + 1];
18234       } else {
18235         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18236       }
18237       var dist = geoVecLength(p2, a2);
18238       if (dist < min3) {
18239         min3 = dist;
18240         idx = i3 + 1;
18241         target = p2;
18242       }
18243     }
18244     if (idx !== void 0) {
18245       return { index: idx, distance: min3, target };
18246     } else {
18247       return null;
18248     }
18249   }
18250
18251   // modules/geo/geom.js
18252   function geoAngle(a2, b2, projection2) {
18253     return geoVecAngle(projection2(a2.loc), projection2(b2.loc));
18254   }
18255   function geoEdgeEqual(a2, b2) {
18256     return a2[0] === b2[0] && a2[1] === b2[1] || a2[0] === b2[1] && a2[1] === b2[0];
18257   }
18258   function geoRotate(points, angle2, around) {
18259     return points.map(function(point2) {
18260       var radial = geoVecSubtract(point2, around);
18261       return [
18262         radial[0] * Math.cos(angle2) - radial[1] * Math.sin(angle2) + around[0],
18263         radial[0] * Math.sin(angle2) + radial[1] * Math.cos(angle2) + around[1]
18264       ];
18265     });
18266   }
18267   function geoChooseEdge(nodes, point2, projection2, activeID) {
18268     var dist = geoVecLength;
18269     var points = nodes.map(function(n3) {
18270       return projection2(n3.loc);
18271     });
18272     var ids = nodes.map(function(n3) {
18273       return n3.id;
18274     });
18275     var min3 = Infinity;
18276     var idx;
18277     var loc;
18278     for (var i3 = 0; i3 < points.length - 1; i3++) {
18279       if (ids[i3] === activeID || ids[i3 + 1] === activeID)
18280         continue;
18281       var o2 = points[i3];
18282       var s2 = geoVecSubtract(points[i3 + 1], o2);
18283       var v2 = geoVecSubtract(point2, o2);
18284       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18285       var p2;
18286       if (proj < 0) {
18287         p2 = o2;
18288       } else if (proj > 1) {
18289         p2 = points[i3 + 1];
18290       } else {
18291         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18292       }
18293       var d2 = dist(p2, point2);
18294       if (d2 < min3) {
18295         min3 = d2;
18296         idx = i3 + 1;
18297         loc = projection2.invert(p2);
18298       }
18299     }
18300     if (idx !== void 0) {
18301       return { index: idx, distance: min3, loc };
18302     } else {
18303       return null;
18304     }
18305   }
18306   function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) {
18307     var actives = [];
18308     var inactives = [];
18309     var j2, k2, n1, n22, segment;
18310     for (j2 = 0; j2 < activeNodes.length - 1; j2++) {
18311       n1 = activeNodes[j2];
18312       n22 = activeNodes[j2 + 1];
18313       segment = [n1.loc, n22.loc];
18314       if (n1.id === activeID || n22.id === activeID) {
18315         actives.push(segment);
18316       }
18317     }
18318     for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) {
18319       n1 = inactiveNodes[j2];
18320       n22 = inactiveNodes[j2 + 1];
18321       segment = [n1.loc, n22.loc];
18322       inactives.push(segment);
18323     }
18324     for (j2 = 0; j2 < actives.length; j2++) {
18325       for (k2 = 0; k2 < inactives.length; k2++) {
18326         var p2 = actives[j2];
18327         var q2 = inactives[k2];
18328         var hit = geoLineIntersection(p2, q2);
18329         if (hit) {
18330           return true;
18331         }
18332       }
18333     }
18334     return false;
18335   }
18336   function geoHasSelfIntersections(nodes, activeID) {
18337     var actives = [];
18338     var inactives = [];
18339     var j2, k2;
18340     for (j2 = 0; j2 < nodes.length - 1; j2++) {
18341       var n1 = nodes[j2];
18342       var n22 = nodes[j2 + 1];
18343       var segment = [n1.loc, n22.loc];
18344       if (n1.id === activeID || n22.id === activeID) {
18345         actives.push(segment);
18346       } else {
18347         inactives.push(segment);
18348       }
18349     }
18350     for (j2 = 0; j2 < actives.length; j2++) {
18351       for (k2 = 0; k2 < inactives.length; k2++) {
18352         var p2 = actives[j2];
18353         var q2 = inactives[k2];
18354         if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) {
18355           continue;
18356         }
18357         var hit = geoLineIntersection(p2, q2);
18358         if (hit) {
18359           var epsilon3 = 1e-8;
18360           if (geoVecEqual(p2[1], hit, epsilon3) || geoVecEqual(p2[0], hit, epsilon3) || geoVecEqual(q2[1], hit, epsilon3) || geoVecEqual(q2[0], hit, epsilon3)) {
18361             continue;
18362           } else {
18363             return true;
18364           }
18365         }
18366       }
18367     }
18368     return false;
18369   }
18370   function geoLineIntersection(a2, b2) {
18371     var p2 = [a2[0][0], a2[0][1]];
18372     var p22 = [a2[1][0], a2[1][1]];
18373     var q2 = [b2[0][0], b2[0][1]];
18374     var q22 = [b2[1][0], b2[1][1]];
18375     var r2 = geoVecSubtract(p22, p2);
18376     var s2 = geoVecSubtract(q22, q2);
18377     var uNumerator = geoVecCross(geoVecSubtract(q2, p2), r2);
18378     var denominator = geoVecCross(r2, s2);
18379     if (uNumerator && denominator) {
18380       var u2 = uNumerator / denominator;
18381       var t2 = geoVecCross(geoVecSubtract(q2, p2), s2) / denominator;
18382       if (t2 >= 0 && t2 <= 1 && u2 >= 0 && u2 <= 1) {
18383         return geoVecInterp(p2, p22, t2);
18384       }
18385     }
18386     return null;
18387   }
18388   function geoPathIntersections(path1, path2) {
18389     var intersections = [];
18390     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18391       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18392         var a2 = [path1[i3], path1[i3 + 1]];
18393         var b2 = [path2[j2], path2[j2 + 1]];
18394         var hit = geoLineIntersection(a2, b2);
18395         if (hit) {
18396           intersections.push(hit);
18397         }
18398       }
18399     }
18400     return intersections;
18401   }
18402   function geoPathHasIntersections(path1, path2) {
18403     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18404       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18405         var a2 = [path1[i3], path1[i3 + 1]];
18406         var b2 = [path2[j2], path2[j2 + 1]];
18407         var hit = geoLineIntersection(a2, b2);
18408         if (hit) {
18409           return true;
18410         }
18411       }
18412     }
18413     return false;
18414   }
18415   function geoPointInPolygon(point2, polygon2) {
18416     var x2 = point2[0];
18417     var y2 = point2[1];
18418     var inside = false;
18419     for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) {
18420       var xi = polygon2[i3][0];
18421       var yi = polygon2[i3][1];
18422       var xj = polygon2[j2][0];
18423       var yj = polygon2[j2][1];
18424       var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
18425       if (intersect2)
18426         inside = !inside;
18427     }
18428     return inside;
18429   }
18430   function geoPolygonContainsPolygon(outer, inner) {
18431     return inner.every(function(point2) {
18432       return geoPointInPolygon(point2, outer);
18433     });
18434   }
18435   function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
18436     function testPoints(outer2, inner2) {
18437       return inner2.some(function(point2) {
18438         return geoPointInPolygon(point2, outer2);
18439       });
18440     }
18441     return testPoints(outer, inner) || !!checkSegments && geoPathHasIntersections(outer, inner);
18442   }
18443   function geoGetSmallestSurroundingRectangle(points) {
18444     var hull = hull_default(points);
18445     var centroid = centroid_default2(hull);
18446     var minArea = Infinity;
18447     var ssrExtent = [];
18448     var ssrAngle = 0;
18449     var c1 = hull[0];
18450     for (var i3 = 0; i3 <= hull.length - 1; i3++) {
18451       var c2 = i3 === hull.length - 1 ? hull[0] : hull[i3 + 1];
18452       var angle2 = Math.atan2(c2[1] - c1[1], c2[0] - c1[0]);
18453       var poly = geoRotate(hull, -angle2, centroid);
18454       var extent = poly.reduce(function(extent2, point2) {
18455         return extent2.extend(geoExtent(point2));
18456       }, geoExtent());
18457       var area = extent.area();
18458       if (area < minArea) {
18459         minArea = area;
18460         ssrExtent = extent;
18461         ssrAngle = angle2;
18462       }
18463       c1 = c2;
18464     }
18465     return {
18466       poly: geoRotate(ssrExtent.polygon(), ssrAngle, centroid),
18467       angle: ssrAngle
18468     };
18469   }
18470   function geoPathLength(path) {
18471     var length2 = 0;
18472     for (var i3 = 0; i3 < path.length - 1; i3++) {
18473       length2 += geoVecLength(path[i3], path[i3 + 1]);
18474     }
18475     return length2;
18476   }
18477   function geoViewportEdge(point2, dimensions) {
18478     var pad2 = [80, 20, 50, 20];
18479     var x2 = 0;
18480     var y2 = 0;
18481     if (point2[0] > dimensions[0] - pad2[1]) {
18482       x2 = -10;
18483     }
18484     if (point2[0] < pad2[3]) {
18485       x2 = 10;
18486     }
18487     if (point2[1] > dimensions[1] - pad2[2]) {
18488       y2 = -10;
18489     }
18490     if (point2[1] < pad2[0]) {
18491       y2 = 10;
18492     }
18493     if (x2 || y2) {
18494       return [x2, y2];
18495     } else {
18496       return null;
18497     }
18498   }
18499
18500   // node_modules/d3-dispatch/src/dispatch.js
18501   var noop2 = { value: () => {
18502   } };
18503   function dispatch() {
18504     for (var i3 = 0, n3 = arguments.length, _2 = {}, t2; i3 < n3; ++i3) {
18505       if (!(t2 = arguments[i3] + "") || t2 in _2 || /[\s.]/.test(t2))
18506         throw new Error("illegal type: " + t2);
18507       _2[t2] = [];
18508     }
18509     return new Dispatch(_2);
18510   }
18511   function Dispatch(_2) {
18512     this._ = _2;
18513   }
18514   function parseTypenames(typenames, types) {
18515     return typenames.trim().split(/^|\s+/).map(function(t2) {
18516       var name = "", i3 = t2.indexOf(".");
18517       if (i3 >= 0)
18518         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
18519       if (t2 && !types.hasOwnProperty(t2))
18520         throw new Error("unknown type: " + t2);
18521       return { type: t2, name };
18522     });
18523   }
18524   Dispatch.prototype = dispatch.prototype = {
18525     constructor: Dispatch,
18526     on: function(typename, callback) {
18527       var _2 = this._, T2 = parseTypenames(typename + "", _2), t2, i3 = -1, n3 = T2.length;
18528       if (arguments.length < 2) {
18529         while (++i3 < n3)
18530           if ((t2 = (typename = T2[i3]).type) && (t2 = get(_2[t2], typename.name)))
18531             return t2;
18532         return;
18533       }
18534       if (callback != null && typeof callback !== "function")
18535         throw new Error("invalid callback: " + callback);
18536       while (++i3 < n3) {
18537         if (t2 = (typename = T2[i3]).type)
18538           _2[t2] = set(_2[t2], typename.name, callback);
18539         else if (callback == null)
18540           for (t2 in _2)
18541             _2[t2] = set(_2[t2], typename.name, null);
18542       }
18543       return this;
18544     },
18545     copy: function() {
18546       var copy2 = {}, _2 = this._;
18547       for (var t2 in _2)
18548         copy2[t2] = _2[t2].slice();
18549       return new Dispatch(copy2);
18550     },
18551     call: function(type2, that) {
18552       if ((n3 = arguments.length - 2) > 0)
18553         for (var args = new Array(n3), i3 = 0, n3, t2; i3 < n3; ++i3)
18554           args[i3] = arguments[i3 + 2];
18555       if (!this._.hasOwnProperty(type2))
18556         throw new Error("unknown type: " + type2);
18557       for (t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18558         t2[i3].value.apply(that, args);
18559     },
18560     apply: function(type2, that, args) {
18561       if (!this._.hasOwnProperty(type2))
18562         throw new Error("unknown type: " + type2);
18563       for (var t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18564         t2[i3].value.apply(that, args);
18565     }
18566   };
18567   function get(type2, name) {
18568     for (var i3 = 0, n3 = type2.length, c2; i3 < n3; ++i3) {
18569       if ((c2 = type2[i3]).name === name) {
18570         return c2.value;
18571       }
18572     }
18573   }
18574   function set(type2, name, callback) {
18575     for (var i3 = 0, n3 = type2.length; i3 < n3; ++i3) {
18576       if (type2[i3].name === name) {
18577         type2[i3] = noop2, type2 = type2.slice(0, i3).concat(type2.slice(i3 + 1));
18578         break;
18579       }
18580     }
18581     if (callback != null)
18582       type2.push({ name, value: callback });
18583     return type2;
18584   }
18585   var dispatch_default = dispatch;
18586
18587   // node_modules/d3-selection/src/namespaces.js
18588   var xhtml = "http://www.w3.org/1999/xhtml";
18589   var namespaces_default = {
18590     svg: "http://www.w3.org/2000/svg",
18591     xhtml,
18592     xlink: "http://www.w3.org/1999/xlink",
18593     xml: "http://www.w3.org/XML/1998/namespace",
18594     xmlns: "http://www.w3.org/2000/xmlns/"
18595   };
18596
18597   // node_modules/d3-selection/src/namespace.js
18598   function namespace_default(name) {
18599     var prefix = name += "", i3 = prefix.indexOf(":");
18600     if (i3 >= 0 && (prefix = name.slice(0, i3)) !== "xmlns")
18601       name = name.slice(i3 + 1);
18602     return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name;
18603   }
18604
18605   // node_modules/d3-selection/src/creator.js
18606   function creatorInherit(name) {
18607     return function() {
18608       var document2 = this.ownerDocument, uri = this.namespaceURI;
18609       return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
18610     };
18611   }
18612   function creatorFixed(fullname) {
18613     return function() {
18614       return this.ownerDocument.createElementNS(fullname.space, fullname.local);
18615     };
18616   }
18617   function creator_default(name) {
18618     var fullname = namespace_default(name);
18619     return (fullname.local ? creatorFixed : creatorInherit)(fullname);
18620   }
18621
18622   // node_modules/d3-selection/src/selector.js
18623   function none() {
18624   }
18625   function selector_default(selector) {
18626     return selector == null ? none : function() {
18627       return this.querySelector(selector);
18628     };
18629   }
18630
18631   // node_modules/d3-selection/src/selection/select.js
18632   function select_default(select) {
18633     if (typeof select !== "function")
18634       select = selector_default(select);
18635     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18636       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
18637         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
18638           if ("__data__" in node)
18639             subnode.__data__ = node.__data__;
18640           subgroup[i3] = subnode;
18641         }
18642       }
18643     }
18644     return new Selection(subgroups, this._parents);
18645   }
18646
18647   // node_modules/d3-selection/src/array.js
18648   function array(x2) {
18649     return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2);
18650   }
18651
18652   // node_modules/d3-selection/src/selectorAll.js
18653   function empty() {
18654     return [];
18655   }
18656   function selectorAll_default(selector) {
18657     return selector == null ? empty : function() {
18658       return this.querySelectorAll(selector);
18659     };
18660   }
18661
18662   // node_modules/d3-selection/src/selection/selectAll.js
18663   function arrayAll(select) {
18664     return function() {
18665       return array(select.apply(this, arguments));
18666     };
18667   }
18668   function selectAll_default(select) {
18669     if (typeof select === "function")
18670       select = arrayAll(select);
18671     else
18672       select = selectorAll_default(select);
18673     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
18674       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
18675         if (node = group[i3]) {
18676           subgroups.push(select.call(node, node.__data__, i3, group));
18677           parents.push(node);
18678         }
18679       }
18680     }
18681     return new Selection(subgroups, parents);
18682   }
18683
18684   // node_modules/d3-selection/src/matcher.js
18685   function matcher_default(selector) {
18686     return function() {
18687       return this.matches(selector);
18688     };
18689   }
18690   function childMatcher(selector) {
18691     return function(node) {
18692       return node.matches(selector);
18693     };
18694   }
18695
18696   // node_modules/d3-selection/src/selection/selectChild.js
18697   var find = Array.prototype.find;
18698   function childFind(match) {
18699     return function() {
18700       return find.call(this.children, match);
18701     };
18702   }
18703   function childFirst() {
18704     return this.firstElementChild;
18705   }
18706   function selectChild_default(match) {
18707     return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
18708   }
18709
18710   // node_modules/d3-selection/src/selection/selectChildren.js
18711   var filter = Array.prototype.filter;
18712   function children() {
18713     return Array.from(this.children);
18714   }
18715   function childrenFilter(match) {
18716     return function() {
18717       return filter.call(this.children, match);
18718     };
18719   }
18720   function selectChildren_default(match) {
18721     return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
18722   }
18723
18724   // node_modules/d3-selection/src/selection/filter.js
18725   function filter_default(match) {
18726     if (typeof match !== "function")
18727       match = matcher_default(match);
18728     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18729       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
18730         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
18731           subgroup.push(node);
18732         }
18733       }
18734     }
18735     return new Selection(subgroups, this._parents);
18736   }
18737
18738   // node_modules/d3-selection/src/selection/sparse.js
18739   function sparse_default(update) {
18740     return new Array(update.length);
18741   }
18742
18743   // node_modules/d3-selection/src/selection/enter.js
18744   function enter_default() {
18745     return new Selection(this._enter || this._groups.map(sparse_default), this._parents);
18746   }
18747   function EnterNode(parent, datum2) {
18748     this.ownerDocument = parent.ownerDocument;
18749     this.namespaceURI = parent.namespaceURI;
18750     this._next = null;
18751     this._parent = parent;
18752     this.__data__ = datum2;
18753   }
18754   EnterNode.prototype = {
18755     constructor: EnterNode,
18756     appendChild: function(child) {
18757       return this._parent.insertBefore(child, this._next);
18758     },
18759     insertBefore: function(child, next) {
18760       return this._parent.insertBefore(child, next);
18761     },
18762     querySelector: function(selector) {
18763       return this._parent.querySelector(selector);
18764     },
18765     querySelectorAll: function(selector) {
18766       return this._parent.querySelectorAll(selector);
18767     }
18768   };
18769
18770   // node_modules/d3-selection/src/constant.js
18771   function constant_default(x2) {
18772     return function() {
18773       return x2;
18774     };
18775   }
18776
18777   // node_modules/d3-selection/src/selection/data.js
18778   function bindIndex(parent, group, enter, update, exit, data) {
18779     var i3 = 0, node, groupLength = group.length, dataLength = data.length;
18780     for (; i3 < dataLength; ++i3) {
18781       if (node = group[i3]) {
18782         node.__data__ = data[i3];
18783         update[i3] = node;
18784       } else {
18785         enter[i3] = new EnterNode(parent, data[i3]);
18786       }
18787     }
18788     for (; i3 < groupLength; ++i3) {
18789       if (node = group[i3]) {
18790         exit[i3] = node;
18791       }
18792     }
18793   }
18794   function bindKey(parent, group, enter, update, exit, data, key) {
18795     var i3, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
18796     for (i3 = 0; i3 < groupLength; ++i3) {
18797       if (node = group[i3]) {
18798         keyValues[i3] = keyValue = key.call(node, node.__data__, i3, group) + "";
18799         if (nodeByKeyValue.has(keyValue)) {
18800           exit[i3] = node;
18801         } else {
18802           nodeByKeyValue.set(keyValue, node);
18803         }
18804       }
18805     }
18806     for (i3 = 0; i3 < dataLength; ++i3) {
18807       keyValue = key.call(parent, data[i3], i3, data) + "";
18808       if (node = nodeByKeyValue.get(keyValue)) {
18809         update[i3] = node;
18810         node.__data__ = data[i3];
18811         nodeByKeyValue.delete(keyValue);
18812       } else {
18813         enter[i3] = new EnterNode(parent, data[i3]);
18814       }
18815     }
18816     for (i3 = 0; i3 < groupLength; ++i3) {
18817       if ((node = group[i3]) && nodeByKeyValue.get(keyValues[i3]) === node) {
18818         exit[i3] = node;
18819       }
18820     }
18821   }
18822   function datum(node) {
18823     return node.__data__;
18824   }
18825   function data_default(value, key) {
18826     if (!arguments.length)
18827       return Array.from(this, datum);
18828     var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
18829     if (typeof value !== "function")
18830       value = constant_default(value);
18831     for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18832       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);
18833       bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
18834       for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
18835         if (previous = enterGroup[i0]) {
18836           if (i0 >= i1)
18837             i1 = i0 + 1;
18838           while (!(next = updateGroup[i1]) && ++i1 < dataLength)
18839             ;
18840           previous._next = next || null;
18841         }
18842       }
18843     }
18844     update = new Selection(update, parents);
18845     update._enter = enter;
18846     update._exit = exit;
18847     return update;
18848   }
18849   function arraylike(data) {
18850     return typeof data === "object" && "length" in data ? data : Array.from(data);
18851   }
18852
18853   // node_modules/d3-selection/src/selection/exit.js
18854   function exit_default() {
18855     return new Selection(this._exit || this._groups.map(sparse_default), this._parents);
18856   }
18857
18858   // node_modules/d3-selection/src/selection/join.js
18859   function join_default(onenter, onupdate, onexit) {
18860     var enter = this.enter(), update = this, exit = this.exit();
18861     if (typeof onenter === "function") {
18862       enter = onenter(enter);
18863       if (enter)
18864         enter = enter.selection();
18865     } else {
18866       enter = enter.append(onenter + "");
18867     }
18868     if (onupdate != null) {
18869       update = onupdate(update);
18870       if (update)
18871         update = update.selection();
18872     }
18873     if (onexit == null)
18874       exit.remove();
18875     else
18876       onexit(exit);
18877     return enter && update ? enter.merge(update).order() : update;
18878   }
18879
18880   // node_modules/d3-selection/src/selection/merge.js
18881   function merge_default(context) {
18882     var selection2 = context.selection ? context.selection() : context;
18883     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) {
18884       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
18885         if (node = group0[i3] || group1[i3]) {
18886           merge2[i3] = node;
18887         }
18888       }
18889     }
18890     for (; j2 < m0; ++j2) {
18891       merges[j2] = groups0[j2];
18892     }
18893     return new Selection(merges, this._parents);
18894   }
18895
18896   // node_modules/d3-selection/src/selection/order.js
18897   function order_default() {
18898     for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) {
18899       for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) {
18900         if (node = group[i3]) {
18901           if (next && node.compareDocumentPosition(next) ^ 4)
18902             next.parentNode.insertBefore(node, next);
18903           next = node;
18904         }
18905       }
18906     }
18907     return this;
18908   }
18909
18910   // node_modules/d3-selection/src/selection/sort.js
18911   function sort_default(compare2) {
18912     if (!compare2)
18913       compare2 = ascending2;
18914     function compareNode(a2, b2) {
18915       return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2;
18916     }
18917     for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18918       for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
18919         if (node = group[i3]) {
18920           sortgroup[i3] = node;
18921         }
18922       }
18923       sortgroup.sort(compareNode);
18924     }
18925     return new Selection(sortgroups, this._parents).order();
18926   }
18927   function ascending2(a2, b2) {
18928     return a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
18929   }
18930
18931   // node_modules/d3-selection/src/selection/call.js
18932   function call_default() {
18933     var callback = arguments[0];
18934     arguments[0] = this;
18935     callback.apply(null, arguments);
18936     return this;
18937   }
18938
18939   // node_modules/d3-selection/src/selection/nodes.js
18940   function nodes_default() {
18941     return Array.from(this);
18942   }
18943
18944   // node_modules/d3-selection/src/selection/node.js
18945   function node_default() {
18946     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
18947       for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) {
18948         var node = group[i3];
18949         if (node)
18950           return node;
18951       }
18952     }
18953     return null;
18954   }
18955
18956   // node_modules/d3-selection/src/selection/size.js
18957   function size_default() {
18958     let size = 0;
18959     for (const node of this)
18960       ++size;
18961     return size;
18962   }
18963
18964   // node_modules/d3-selection/src/selection/empty.js
18965   function empty_default() {
18966     return !this.node();
18967   }
18968
18969   // node_modules/d3-selection/src/selection/each.js
18970   function each_default(callback) {
18971     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
18972       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
18973         if (node = group[i3])
18974           callback.call(node, node.__data__, i3, group);
18975       }
18976     }
18977     return this;
18978   }
18979
18980   // node_modules/d3-selection/src/selection/attr.js
18981   function attrRemove(name) {
18982     return function() {
18983       this.removeAttribute(name);
18984     };
18985   }
18986   function attrRemoveNS(fullname) {
18987     return function() {
18988       this.removeAttributeNS(fullname.space, fullname.local);
18989     };
18990   }
18991   function attrConstant(name, value) {
18992     return function() {
18993       this.setAttribute(name, value);
18994     };
18995   }
18996   function attrConstantNS(fullname, value) {
18997     return function() {
18998       this.setAttributeNS(fullname.space, fullname.local, value);
18999     };
19000   }
19001   function attrFunction(name, value) {
19002     return function() {
19003       var v2 = value.apply(this, arguments);
19004       if (v2 == null)
19005         this.removeAttribute(name);
19006       else
19007         this.setAttribute(name, v2);
19008     };
19009   }
19010   function attrFunctionNS(fullname, value) {
19011     return function() {
19012       var v2 = value.apply(this, arguments);
19013       if (v2 == null)
19014         this.removeAttributeNS(fullname.space, fullname.local);
19015       else
19016         this.setAttributeNS(fullname.space, fullname.local, v2);
19017     };
19018   }
19019   function attr_default(name, value) {
19020     var fullname = namespace_default(name);
19021     if (arguments.length < 2) {
19022       var node = this.node();
19023       return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
19024     }
19025     return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value));
19026   }
19027
19028   // node_modules/d3-selection/src/window.js
19029   function window_default(node) {
19030     return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
19031   }
19032
19033   // node_modules/d3-selection/src/selection/style.js
19034   function styleRemove(name) {
19035     return function() {
19036       this.style.removeProperty(name);
19037     };
19038   }
19039   function styleConstant(name, value, priority) {
19040     return function() {
19041       this.style.setProperty(name, value, priority);
19042     };
19043   }
19044   function styleFunction(name, value, priority) {
19045     return function() {
19046       var v2 = value.apply(this, arguments);
19047       if (v2 == null)
19048         this.style.removeProperty(name);
19049       else
19050         this.style.setProperty(name, v2, priority);
19051     };
19052   }
19053   function style_default(name, value, priority) {
19054     return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
19055   }
19056   function styleValue(node, name) {
19057     return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name);
19058   }
19059
19060   // node_modules/d3-selection/src/selection/property.js
19061   function propertyRemove(name) {
19062     return function() {
19063       delete this[name];
19064     };
19065   }
19066   function propertyConstant(name, value) {
19067     return function() {
19068       this[name] = value;
19069     };
19070   }
19071   function propertyFunction(name, value) {
19072     return function() {
19073       var v2 = value.apply(this, arguments);
19074       if (v2 == null)
19075         delete this[name];
19076       else
19077         this[name] = v2;
19078     };
19079   }
19080   function property_default(name, value) {
19081     return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
19082   }
19083
19084   // node_modules/d3-selection/src/selection/classed.js
19085   function classArray(string) {
19086     return string.trim().split(/^|\s+/);
19087   }
19088   function classList(node) {
19089     return node.classList || new ClassList(node);
19090   }
19091   function ClassList(node) {
19092     this._node = node;
19093     this._names = classArray(node.getAttribute("class") || "");
19094   }
19095   ClassList.prototype = {
19096     add: function(name) {
19097       var i3 = this._names.indexOf(name);
19098       if (i3 < 0) {
19099         this._names.push(name);
19100         this._node.setAttribute("class", this._names.join(" "));
19101       }
19102     },
19103     remove: function(name) {
19104       var i3 = this._names.indexOf(name);
19105       if (i3 >= 0) {
19106         this._names.splice(i3, 1);
19107         this._node.setAttribute("class", this._names.join(" "));
19108       }
19109     },
19110     contains: function(name) {
19111       return this._names.indexOf(name) >= 0;
19112     }
19113   };
19114   function classedAdd(node, names) {
19115     var list2 = classList(node), i3 = -1, n3 = names.length;
19116     while (++i3 < n3)
19117       list2.add(names[i3]);
19118   }
19119   function classedRemove(node, names) {
19120     var list2 = classList(node), i3 = -1, n3 = names.length;
19121     while (++i3 < n3)
19122       list2.remove(names[i3]);
19123   }
19124   function classedTrue(names) {
19125     return function() {
19126       classedAdd(this, names);
19127     };
19128   }
19129   function classedFalse(names) {
19130     return function() {
19131       classedRemove(this, names);
19132     };
19133   }
19134   function classedFunction(names, value) {
19135     return function() {
19136       (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
19137     };
19138   }
19139   function classed_default(name, value) {
19140     var names = classArray(name + "");
19141     if (arguments.length < 2) {
19142       var list2 = classList(this.node()), i3 = -1, n3 = names.length;
19143       while (++i3 < n3)
19144         if (!list2.contains(names[i3]))
19145           return false;
19146       return true;
19147     }
19148     return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
19149   }
19150
19151   // node_modules/d3-selection/src/selection/text.js
19152   function textRemove() {
19153     this.textContent = "";
19154   }
19155   function textConstant(value) {
19156     return function() {
19157       this.textContent = value;
19158     };
19159   }
19160   function textFunction(value) {
19161     return function() {
19162       var v2 = value.apply(this, arguments);
19163       this.textContent = v2 == null ? "" : v2;
19164     };
19165   }
19166   function text_default(value) {
19167     return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent;
19168   }
19169
19170   // node_modules/d3-selection/src/selection/html.js
19171   function htmlRemove() {
19172     this.innerHTML = "";
19173   }
19174   function htmlConstant(value) {
19175     return function() {
19176       this.innerHTML = value;
19177     };
19178   }
19179   function htmlFunction(value) {
19180     return function() {
19181       var v2 = value.apply(this, arguments);
19182       this.innerHTML = v2 == null ? "" : v2;
19183     };
19184   }
19185   function html_default(value) {
19186     return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
19187   }
19188
19189   // node_modules/d3-selection/src/selection/raise.js
19190   function raise() {
19191     if (this.nextSibling)
19192       this.parentNode.appendChild(this);
19193   }
19194   function raise_default() {
19195     return this.each(raise);
19196   }
19197
19198   // node_modules/d3-selection/src/selection/lower.js
19199   function lower() {
19200     if (this.previousSibling)
19201       this.parentNode.insertBefore(this, this.parentNode.firstChild);
19202   }
19203   function lower_default() {
19204     return this.each(lower);
19205   }
19206
19207   // node_modules/d3-selection/src/selection/append.js
19208   function append_default(name) {
19209     var create2 = typeof name === "function" ? name : creator_default(name);
19210     return this.select(function() {
19211       return this.appendChild(create2.apply(this, arguments));
19212     });
19213   }
19214
19215   // node_modules/d3-selection/src/selection/insert.js
19216   function constantNull() {
19217     return null;
19218   }
19219   function insert_default(name, before) {
19220     var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before);
19221     return this.select(function() {
19222       return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
19223     });
19224   }
19225
19226   // node_modules/d3-selection/src/selection/remove.js
19227   function remove() {
19228     var parent = this.parentNode;
19229     if (parent)
19230       parent.removeChild(this);
19231   }
19232   function remove_default() {
19233     return this.each(remove);
19234   }
19235
19236   // node_modules/d3-selection/src/selection/clone.js
19237   function selection_cloneShallow() {
19238     var clone2 = this.cloneNode(false), parent = this.parentNode;
19239     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19240   }
19241   function selection_cloneDeep() {
19242     var clone2 = this.cloneNode(true), parent = this.parentNode;
19243     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19244   }
19245   function clone_default(deep) {
19246     return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
19247   }
19248
19249   // node_modules/d3-selection/src/selection/datum.js
19250   function datum_default(value) {
19251     return arguments.length ? this.property("__data__", value) : this.node().__data__;
19252   }
19253
19254   // node_modules/d3-selection/src/selection/on.js
19255   function contextListener(listener) {
19256     return function(event) {
19257       listener.call(this, event, this.__data__);
19258     };
19259   }
19260   function parseTypenames2(typenames) {
19261     return typenames.trim().split(/^|\s+/).map(function(t2) {
19262       var name = "", i3 = t2.indexOf(".");
19263       if (i3 >= 0)
19264         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
19265       return { type: t2, name };
19266     });
19267   }
19268   function onRemove(typename) {
19269     return function() {
19270       var on = this.__on;
19271       if (!on)
19272         return;
19273       for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) {
19274         if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) {
19275           this.removeEventListener(o2.type, o2.listener, o2.options);
19276         } else {
19277           on[++i3] = o2;
19278         }
19279       }
19280       if (++i3)
19281         on.length = i3;
19282       else
19283         delete this.__on;
19284     };
19285   }
19286   function onAdd(typename, value, options2) {
19287     return function() {
19288       var on = this.__on, o2, listener = contextListener(value);
19289       if (on)
19290         for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) {
19291           if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) {
19292             this.removeEventListener(o2.type, o2.listener, o2.options);
19293             this.addEventListener(o2.type, o2.listener = listener, o2.options = options2);
19294             o2.value = value;
19295             return;
19296           }
19297         }
19298       this.addEventListener(typename.type, listener, options2);
19299       o2 = { type: typename.type, name: typename.name, value, listener, options: options2 };
19300       if (!on)
19301         this.__on = [o2];
19302       else
19303         on.push(o2);
19304     };
19305   }
19306   function on_default(typename, value, options2) {
19307     var typenames = parseTypenames2(typename + ""), i3, n3 = typenames.length, t2;
19308     if (arguments.length < 2) {
19309       var on = this.node().__on;
19310       if (on)
19311         for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) {
19312           for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) {
19313             if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) {
19314               return o2.value;
19315             }
19316           }
19317         }
19318       return;
19319     }
19320     on = value ? onAdd : onRemove;
19321     for (i3 = 0; i3 < n3; ++i3)
19322       this.each(on(typenames[i3], value, options2));
19323     return this;
19324   }
19325
19326   // node_modules/d3-selection/src/selection/dispatch.js
19327   function dispatchEvent(node, type2, params) {
19328     var window2 = window_default(node), event = window2.CustomEvent;
19329     if (typeof event === "function") {
19330       event = new event(type2, params);
19331     } else {
19332       event = window2.document.createEvent("Event");
19333       if (params)
19334         event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail;
19335       else
19336         event.initEvent(type2, false, false);
19337     }
19338     node.dispatchEvent(event);
19339   }
19340   function dispatchConstant(type2, params) {
19341     return function() {
19342       return dispatchEvent(this, type2, params);
19343     };
19344   }
19345   function dispatchFunction(type2, params) {
19346     return function() {
19347       return dispatchEvent(this, type2, params.apply(this, arguments));
19348     };
19349   }
19350   function dispatch_default2(type2, params) {
19351     return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params));
19352   }
19353
19354   // node_modules/d3-selection/src/selection/iterator.js
19355   function* iterator_default() {
19356     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19357       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
19358         if (node = group[i3])
19359           yield node;
19360       }
19361     }
19362   }
19363
19364   // node_modules/d3-selection/src/selection/index.js
19365   var root = [null];
19366   function Selection(groups, parents) {
19367     this._groups = groups;
19368     this._parents = parents;
19369   }
19370   function selection() {
19371     return new Selection([[document.documentElement]], root);
19372   }
19373   function selection_selection() {
19374     return this;
19375   }
19376   Selection.prototype = selection.prototype = {
19377     constructor: Selection,
19378     select: select_default,
19379     selectAll: selectAll_default,
19380     selectChild: selectChild_default,
19381     selectChildren: selectChildren_default,
19382     filter: filter_default,
19383     data: data_default,
19384     enter: enter_default,
19385     exit: exit_default,
19386     join: join_default,
19387     merge: merge_default,
19388     selection: selection_selection,
19389     order: order_default,
19390     sort: sort_default,
19391     call: call_default,
19392     nodes: nodes_default,
19393     node: node_default,
19394     size: size_default,
19395     empty: empty_default,
19396     each: each_default,
19397     attr: attr_default,
19398     style: style_default,
19399     property: property_default,
19400     classed: classed_default,
19401     text: text_default,
19402     html: html_default,
19403     raise: raise_default,
19404     lower: lower_default,
19405     append: append_default,
19406     insert: insert_default,
19407     remove: remove_default,
19408     clone: clone_default,
19409     datum: datum_default,
19410     on: on_default,
19411     dispatch: dispatch_default2,
19412     [Symbol.iterator]: iterator_default
19413   };
19414   var selection_default = selection;
19415
19416   // node_modules/d3-selection/src/select.js
19417   function select_default2(selector) {
19418     return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
19419   }
19420
19421   // node_modules/d3-selection/src/sourceEvent.js
19422   function sourceEvent_default(event) {
19423     let sourceEvent;
19424     while (sourceEvent = event.sourceEvent)
19425       event = sourceEvent;
19426     return event;
19427   }
19428
19429   // node_modules/d3-selection/src/pointer.js
19430   function pointer_default(event, node) {
19431     event = sourceEvent_default(event);
19432     if (node === void 0)
19433       node = event.currentTarget;
19434     if (node) {
19435       var svg2 = node.ownerSVGElement || node;
19436       if (svg2.createSVGPoint) {
19437         var point2 = svg2.createSVGPoint();
19438         point2.x = event.clientX, point2.y = event.clientY;
19439         point2 = point2.matrixTransform(node.getScreenCTM().inverse());
19440         return [point2.x, point2.y];
19441       }
19442       if (node.getBoundingClientRect) {
19443         var rect = node.getBoundingClientRect();
19444         return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
19445       }
19446     }
19447     return [event.pageX, event.pageY];
19448   }
19449
19450   // node_modules/d3-selection/src/selectAll.js
19451   function selectAll_default2(selector) {
19452     return typeof selector === "string" ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) : new Selection([array(selector)], root);
19453   }
19454
19455   // node_modules/d3-drag/src/noevent.js
19456   var nonpassive = { passive: false };
19457   var nonpassivecapture = { capture: true, passive: false };
19458   function nopropagation(event) {
19459     event.stopImmediatePropagation();
19460   }
19461   function noevent_default(event) {
19462     event.preventDefault();
19463     event.stopImmediatePropagation();
19464   }
19465
19466   // node_modules/d3-drag/src/nodrag.js
19467   function nodrag_default(view) {
19468     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture);
19469     if ("onselectstart" in root3) {
19470       selection2.on("selectstart.drag", noevent_default, nonpassivecapture);
19471     } else {
19472       root3.__noselect = root3.style.MozUserSelect;
19473       root3.style.MozUserSelect = "none";
19474     }
19475   }
19476   function yesdrag(view, noclick) {
19477     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null);
19478     if (noclick) {
19479       selection2.on("click.drag", noevent_default, nonpassivecapture);
19480       setTimeout(function() {
19481         selection2.on("click.drag", null);
19482       }, 0);
19483     }
19484     if ("onselectstart" in root3) {
19485       selection2.on("selectstart.drag", null);
19486     } else {
19487       root3.style.MozUserSelect = root3.__noselect;
19488       delete root3.__noselect;
19489     }
19490   }
19491
19492   // node_modules/d3-drag/src/constant.js
19493   var constant_default2 = (x2) => () => x2;
19494
19495   // node_modules/d3-drag/src/event.js
19496   function DragEvent(type2, {
19497     sourceEvent,
19498     subject,
19499     target,
19500     identifier,
19501     active,
19502     x: x2,
19503     y: y2,
19504     dx,
19505     dy,
19506     dispatch: dispatch14
19507   }) {
19508     Object.defineProperties(this, {
19509       type: { value: type2, enumerable: true, configurable: true },
19510       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
19511       subject: { value: subject, enumerable: true, configurable: true },
19512       target: { value: target, enumerable: true, configurable: true },
19513       identifier: { value: identifier, enumerable: true, configurable: true },
19514       active: { value: active, enumerable: true, configurable: true },
19515       x: { value: x2, enumerable: true, configurable: true },
19516       y: { value: y2, enumerable: true, configurable: true },
19517       dx: { value: dx, enumerable: true, configurable: true },
19518       dy: { value: dy, enumerable: true, configurable: true },
19519       _: { value: dispatch14 }
19520     });
19521   }
19522   DragEvent.prototype.on = function() {
19523     var value = this._.on.apply(this._, arguments);
19524     return value === this._ ? this : value;
19525   };
19526
19527   // node_modules/d3-drag/src/drag.js
19528   function defaultFilter(event) {
19529     return !event.ctrlKey && !event.button;
19530   }
19531   function defaultContainer() {
19532     return this.parentNode;
19533   }
19534   function defaultSubject(event, d2) {
19535     return d2 == null ? { x: event.x, y: event.y } : d2;
19536   }
19537   function defaultTouchable() {
19538     return navigator.maxTouchPoints || "ontouchstart" in this;
19539   }
19540   function drag_default() {
19541     var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
19542     function drag(selection2) {
19543       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)");
19544     }
19545     function mousedowned(event, d2) {
19546       if (touchending || !filter2.call(this, event, d2))
19547         return;
19548       var gesture = beforestart(this, container.call(this, event, d2), event, d2, "mouse");
19549       if (!gesture)
19550         return;
19551       select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture);
19552       nodrag_default(event.view);
19553       nopropagation(event);
19554       mousemoving = false;
19555       mousedownx = event.clientX;
19556       mousedowny = event.clientY;
19557       gesture("start", event);
19558     }
19559     function mousemoved(event) {
19560       noevent_default(event);
19561       if (!mousemoving) {
19562         var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
19563         mousemoving = dx * dx + dy * dy > clickDistance2;
19564       }
19565       gestures.mouse("drag", event);
19566     }
19567     function mouseupped(event) {
19568       select_default2(event.view).on("mousemove.drag mouseup.drag", null);
19569       yesdrag(event.view, mousemoving);
19570       noevent_default(event);
19571       gestures.mouse("end", event);
19572     }
19573     function touchstarted(event, d2) {
19574       if (!filter2.call(this, event, d2))
19575         return;
19576       var touches = event.changedTouches, c2 = container.call(this, event, d2), n3 = touches.length, i3, gesture;
19577       for (i3 = 0; i3 < n3; ++i3) {
19578         if (gesture = beforestart(this, c2, event, d2, touches[i3].identifier, touches[i3])) {
19579           nopropagation(event);
19580           gesture("start", event, touches[i3]);
19581         }
19582       }
19583     }
19584     function touchmoved(event) {
19585       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19586       for (i3 = 0; i3 < n3; ++i3) {
19587         if (gesture = gestures[touches[i3].identifier]) {
19588           noevent_default(event);
19589           gesture("drag", event, touches[i3]);
19590         }
19591       }
19592     }
19593     function touchended(event) {
19594       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19595       if (touchending)
19596         clearTimeout(touchending);
19597       touchending = setTimeout(function() {
19598         touchending = null;
19599       }, 500);
19600       for (i3 = 0; i3 < n3; ++i3) {
19601         if (gesture = gestures[touches[i3].identifier]) {
19602           nopropagation(event);
19603           gesture("end", event, touches[i3]);
19604         }
19605       }
19606     }
19607     function beforestart(that, container2, event, d2, identifier, touch) {
19608       var dispatch14 = listeners.copy(), p2 = pointer_default(touch || event, container2), dx, dy, s2;
19609       if ((s2 = subject.call(that, new DragEvent("beforestart", {
19610         sourceEvent: event,
19611         target: drag,
19612         identifier,
19613         active,
19614         x: p2[0],
19615         y: p2[1],
19616         dx: 0,
19617         dy: 0,
19618         dispatch: dispatch14
19619       }), d2)) == null)
19620         return;
19621       dx = s2.x - p2[0] || 0;
19622       dy = s2.y - p2[1] || 0;
19623       return function gesture(type2, event2, touch2) {
19624         var p02 = p2, n3;
19625         switch (type2) {
19626           case "start":
19627             gestures[identifier] = gesture, n3 = active++;
19628             break;
19629           case "end":
19630             delete gestures[identifier], --active;
19631           case "drag":
19632             p2 = pointer_default(touch2 || event2, container2), n3 = active;
19633             break;
19634         }
19635         dispatch14.call(
19636           type2,
19637           that,
19638           new DragEvent(type2, {
19639             sourceEvent: event2,
19640             subject: s2,
19641             target: drag,
19642             identifier,
19643             active: n3,
19644             x: p2[0] + dx,
19645             y: p2[1] + dy,
19646             dx: p2[0] - p02[0],
19647             dy: p2[1] - p02[1],
19648             dispatch: dispatch14
19649           }),
19650           d2
19651         );
19652       };
19653     }
19654     drag.filter = function(_2) {
19655       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : filter2;
19656     };
19657     drag.container = function(_2) {
19658       return arguments.length ? (container = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : container;
19659     };
19660     drag.subject = function(_2) {
19661       return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : subject;
19662     };
19663     drag.touchable = function(_2) {
19664       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : touchable;
19665     };
19666     drag.on = function() {
19667       var value = listeners.on.apply(listeners, arguments);
19668       return value === listeners ? drag : value;
19669     };
19670     drag.clickDistance = function(_2) {
19671       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag) : Math.sqrt(clickDistance2);
19672     };
19673     return drag;
19674   }
19675
19676   // node_modules/d3-color/src/define.js
19677   function define_default(constructor, factory, prototype) {
19678     constructor.prototype = factory.prototype = prototype;
19679     prototype.constructor = constructor;
19680   }
19681   function extend(parent, definition) {
19682     var prototype = Object.create(parent.prototype);
19683     for (var key in definition)
19684       prototype[key] = definition[key];
19685     return prototype;
19686   }
19687
19688   // node_modules/d3-color/src/color.js
19689   function Color() {
19690   }
19691   var darker = 0.7;
19692   var brighter = 1 / darker;
19693   var reI = "\\s*([+-]?\\d+)\\s*";
19694   var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
19695   var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
19696   var reHex = /^#([0-9a-f]{3,8})$/;
19697   var reRgbInteger = new RegExp("^rgb\\(".concat(reI, ",").concat(reI, ",").concat(reI, "\\)$"));
19698   var reRgbPercent = new RegExp("^rgb\\(".concat(reP, ",").concat(reP, ",").concat(reP, "\\)$"));
19699   var reRgbaInteger = new RegExp("^rgba\\(".concat(reI, ",").concat(reI, ",").concat(reI, ",").concat(reN, "\\)$"));
19700   var reRgbaPercent = new RegExp("^rgba\\(".concat(reP, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19701   var reHslPercent = new RegExp("^hsl\\(".concat(reN, ",").concat(reP, ",").concat(reP, "\\)$"));
19702   var reHslaPercent = new RegExp("^hsla\\(".concat(reN, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19703   var named = {
19704     aliceblue: 15792383,
19705     antiquewhite: 16444375,
19706     aqua: 65535,
19707     aquamarine: 8388564,
19708     azure: 15794175,
19709     beige: 16119260,
19710     bisque: 16770244,
19711     black: 0,
19712     blanchedalmond: 16772045,
19713     blue: 255,
19714     blueviolet: 9055202,
19715     brown: 10824234,
19716     burlywood: 14596231,
19717     cadetblue: 6266528,
19718     chartreuse: 8388352,
19719     chocolate: 13789470,
19720     coral: 16744272,
19721     cornflowerblue: 6591981,
19722     cornsilk: 16775388,
19723     crimson: 14423100,
19724     cyan: 65535,
19725     darkblue: 139,
19726     darkcyan: 35723,
19727     darkgoldenrod: 12092939,
19728     darkgray: 11119017,
19729     darkgreen: 25600,
19730     darkgrey: 11119017,
19731     darkkhaki: 12433259,
19732     darkmagenta: 9109643,
19733     darkolivegreen: 5597999,
19734     darkorange: 16747520,
19735     darkorchid: 10040012,
19736     darkred: 9109504,
19737     darksalmon: 15308410,
19738     darkseagreen: 9419919,
19739     darkslateblue: 4734347,
19740     darkslategray: 3100495,
19741     darkslategrey: 3100495,
19742     darkturquoise: 52945,
19743     darkviolet: 9699539,
19744     deeppink: 16716947,
19745     deepskyblue: 49151,
19746     dimgray: 6908265,
19747     dimgrey: 6908265,
19748     dodgerblue: 2003199,
19749     firebrick: 11674146,
19750     floralwhite: 16775920,
19751     forestgreen: 2263842,
19752     fuchsia: 16711935,
19753     gainsboro: 14474460,
19754     ghostwhite: 16316671,
19755     gold: 16766720,
19756     goldenrod: 14329120,
19757     gray: 8421504,
19758     green: 32768,
19759     greenyellow: 11403055,
19760     grey: 8421504,
19761     honeydew: 15794160,
19762     hotpink: 16738740,
19763     indianred: 13458524,
19764     indigo: 4915330,
19765     ivory: 16777200,
19766     khaki: 15787660,
19767     lavender: 15132410,
19768     lavenderblush: 16773365,
19769     lawngreen: 8190976,
19770     lemonchiffon: 16775885,
19771     lightblue: 11393254,
19772     lightcoral: 15761536,
19773     lightcyan: 14745599,
19774     lightgoldenrodyellow: 16448210,
19775     lightgray: 13882323,
19776     lightgreen: 9498256,
19777     lightgrey: 13882323,
19778     lightpink: 16758465,
19779     lightsalmon: 16752762,
19780     lightseagreen: 2142890,
19781     lightskyblue: 8900346,
19782     lightslategray: 7833753,
19783     lightslategrey: 7833753,
19784     lightsteelblue: 11584734,
19785     lightyellow: 16777184,
19786     lime: 65280,
19787     limegreen: 3329330,
19788     linen: 16445670,
19789     magenta: 16711935,
19790     maroon: 8388608,
19791     mediumaquamarine: 6737322,
19792     mediumblue: 205,
19793     mediumorchid: 12211667,
19794     mediumpurple: 9662683,
19795     mediumseagreen: 3978097,
19796     mediumslateblue: 8087790,
19797     mediumspringgreen: 64154,
19798     mediumturquoise: 4772300,
19799     mediumvioletred: 13047173,
19800     midnightblue: 1644912,
19801     mintcream: 16121850,
19802     mistyrose: 16770273,
19803     moccasin: 16770229,
19804     navajowhite: 16768685,
19805     navy: 128,
19806     oldlace: 16643558,
19807     olive: 8421376,
19808     olivedrab: 7048739,
19809     orange: 16753920,
19810     orangered: 16729344,
19811     orchid: 14315734,
19812     palegoldenrod: 15657130,
19813     palegreen: 10025880,
19814     paleturquoise: 11529966,
19815     palevioletred: 14381203,
19816     papayawhip: 16773077,
19817     peachpuff: 16767673,
19818     peru: 13468991,
19819     pink: 16761035,
19820     plum: 14524637,
19821     powderblue: 11591910,
19822     purple: 8388736,
19823     rebeccapurple: 6697881,
19824     red: 16711680,
19825     rosybrown: 12357519,
19826     royalblue: 4286945,
19827     saddlebrown: 9127187,
19828     salmon: 16416882,
19829     sandybrown: 16032864,
19830     seagreen: 3050327,
19831     seashell: 16774638,
19832     sienna: 10506797,
19833     silver: 12632256,
19834     skyblue: 8900331,
19835     slateblue: 6970061,
19836     slategray: 7372944,
19837     slategrey: 7372944,
19838     snow: 16775930,
19839     springgreen: 65407,
19840     steelblue: 4620980,
19841     tan: 13808780,
19842     teal: 32896,
19843     thistle: 14204888,
19844     tomato: 16737095,
19845     turquoise: 4251856,
19846     violet: 15631086,
19847     wheat: 16113331,
19848     white: 16777215,
19849     whitesmoke: 16119285,
19850     yellow: 16776960,
19851     yellowgreen: 10145074
19852   };
19853   define_default(Color, color, {
19854     copy(channels) {
19855       return Object.assign(new this.constructor(), this, channels);
19856     },
19857     displayable() {
19858       return this.rgb().displayable();
19859     },
19860     hex: color_formatHex,
19861     // Deprecated! Use color.formatHex.
19862     formatHex: color_formatHex,
19863     formatHex8: color_formatHex8,
19864     formatHsl: color_formatHsl,
19865     formatRgb: color_formatRgb,
19866     toString: color_formatRgb
19867   });
19868   function color_formatHex() {
19869     return this.rgb().formatHex();
19870   }
19871   function color_formatHex8() {
19872     return this.rgb().formatHex8();
19873   }
19874   function color_formatHsl() {
19875     return hslConvert(this).formatHsl();
19876   }
19877   function color_formatRgb() {
19878     return this.rgb().formatRgb();
19879   }
19880   function color(format2) {
19881     var m2, l2;
19882     format2 = (format2 + "").trim().toLowerCase();
19883     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;
19884   }
19885   function rgbn(n3) {
19886     return new Rgb(n3 >> 16 & 255, n3 >> 8 & 255, n3 & 255, 1);
19887   }
19888   function rgba(r2, g3, b2, a2) {
19889     if (a2 <= 0)
19890       r2 = g3 = b2 = NaN;
19891     return new Rgb(r2, g3, b2, a2);
19892   }
19893   function rgbConvert(o2) {
19894     if (!(o2 instanceof Color))
19895       o2 = color(o2);
19896     if (!o2)
19897       return new Rgb();
19898     o2 = o2.rgb();
19899     return new Rgb(o2.r, o2.g, o2.b, o2.opacity);
19900   }
19901   function rgb(r2, g3, b2, opacity) {
19902     return arguments.length === 1 ? rgbConvert(r2) : new Rgb(r2, g3, b2, opacity == null ? 1 : opacity);
19903   }
19904   function Rgb(r2, g3, b2, opacity) {
19905     this.r = +r2;
19906     this.g = +g3;
19907     this.b = +b2;
19908     this.opacity = +opacity;
19909   }
19910   define_default(Rgb, rgb, extend(Color, {
19911     brighter(k2) {
19912       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
19913       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
19914     },
19915     darker(k2) {
19916       k2 = k2 == null ? darker : Math.pow(darker, k2);
19917       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
19918     },
19919     rgb() {
19920       return this;
19921     },
19922     clamp() {
19923       return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
19924     },
19925     displayable() {
19926       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);
19927     },
19928     hex: rgb_formatHex,
19929     // Deprecated! Use color.formatHex.
19930     formatHex: rgb_formatHex,
19931     formatHex8: rgb_formatHex8,
19932     formatRgb: rgb_formatRgb,
19933     toString: rgb_formatRgb
19934   }));
19935   function rgb_formatHex() {
19936     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b));
19937   }
19938   function rgb_formatHex8() {
19939     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b)).concat(hex((isNaN(this.opacity) ? 1 : this.opacity) * 255));
19940   }
19941   function rgb_formatRgb() {
19942     const a2 = clampa(this.opacity);
19943     return "".concat(a2 === 1 ? "rgb(" : "rgba(").concat(clampi(this.r), ", ").concat(clampi(this.g), ", ").concat(clampi(this.b)).concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
19944   }
19945   function clampa(opacity) {
19946     return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
19947   }
19948   function clampi(value) {
19949     return Math.max(0, Math.min(255, Math.round(value) || 0));
19950   }
19951   function hex(value) {
19952     value = clampi(value);
19953     return (value < 16 ? "0" : "") + value.toString(16);
19954   }
19955   function hsla(h2, s2, l2, a2) {
19956     if (a2 <= 0)
19957       h2 = s2 = l2 = NaN;
19958     else if (l2 <= 0 || l2 >= 1)
19959       h2 = s2 = NaN;
19960     else if (s2 <= 0)
19961       h2 = NaN;
19962     return new Hsl(h2, s2, l2, a2);
19963   }
19964   function hslConvert(o2) {
19965     if (o2 instanceof Hsl)
19966       return new Hsl(o2.h, o2.s, o2.l, o2.opacity);
19967     if (!(o2 instanceof Color))
19968       o2 = color(o2);
19969     if (!o2)
19970       return new Hsl();
19971     if (o2 instanceof Hsl)
19972       return o2;
19973     o2 = o2.rgb();
19974     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;
19975     if (s2) {
19976       if (r2 === max3)
19977         h2 = (g3 - b2) / s2 + (g3 < b2) * 6;
19978       else if (g3 === max3)
19979         h2 = (b2 - r2) / s2 + 2;
19980       else
19981         h2 = (r2 - g3) / s2 + 4;
19982       s2 /= l2 < 0.5 ? max3 + min3 : 2 - max3 - min3;
19983       h2 *= 60;
19984     } else {
19985       s2 = l2 > 0 && l2 < 1 ? 0 : h2;
19986     }
19987     return new Hsl(h2, s2, l2, o2.opacity);
19988   }
19989   function hsl(h2, s2, l2, opacity) {
19990     return arguments.length === 1 ? hslConvert(h2) : new Hsl(h2, s2, l2, opacity == null ? 1 : opacity);
19991   }
19992   function Hsl(h2, s2, l2, opacity) {
19993     this.h = +h2;
19994     this.s = +s2;
19995     this.l = +l2;
19996     this.opacity = +opacity;
19997   }
19998   define_default(Hsl, hsl, extend(Color, {
19999     brighter(k2) {
20000       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
20001       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20002     },
20003     darker(k2) {
20004       k2 = k2 == null ? darker : Math.pow(darker, k2);
20005       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20006     },
20007     rgb() {
20008       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;
20009       return new Rgb(
20010         hsl2rgb(h2 >= 240 ? h2 - 240 : h2 + 120, m1, m2),
20011         hsl2rgb(h2, m1, m2),
20012         hsl2rgb(h2 < 120 ? h2 + 240 : h2 - 120, m1, m2),
20013         this.opacity
20014       );
20015     },
20016     clamp() {
20017       return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
20018     },
20019     displayable() {
20020       return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
20021     },
20022     formatHsl() {
20023       const a2 = clampa(this.opacity);
20024       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, ")"));
20025     }
20026   }));
20027   function clamph(value) {
20028     value = (value || 0) % 360;
20029     return value < 0 ? value + 360 : value;
20030   }
20031   function clampt(value) {
20032     return Math.max(0, Math.min(1, value || 0));
20033   }
20034   function hsl2rgb(h2, m1, m2) {
20035     return (h2 < 60 ? m1 + (m2 - m1) * h2 / 60 : h2 < 180 ? m2 : h2 < 240 ? m1 + (m2 - m1) * (240 - h2) / 60 : m1) * 255;
20036   }
20037
20038   // node_modules/d3-interpolate/src/basis.js
20039   function basis(t1, v0, v1, v2, v3) {
20040     var t2 = t1 * t1, t3 = t2 * t1;
20041     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;
20042   }
20043   function basis_default(values) {
20044     var n3 = values.length - 1;
20045     return function(t2) {
20046       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;
20047       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20048     };
20049   }
20050
20051   // node_modules/d3-interpolate/src/basisClosed.js
20052   function basisClosed_default(values) {
20053     var n3 = values.length;
20054     return function(t2) {
20055       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];
20056       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20057     };
20058   }
20059
20060   // node_modules/d3-interpolate/src/constant.js
20061   var constant_default3 = (x2) => () => x2;
20062
20063   // node_modules/d3-interpolate/src/color.js
20064   function linear(a2, d2) {
20065     return function(t2) {
20066       return a2 + t2 * d2;
20067     };
20068   }
20069   function exponential(a2, b2, y2) {
20070     return a2 = Math.pow(a2, y2), b2 = Math.pow(b2, y2) - a2, y2 = 1 / y2, function(t2) {
20071       return Math.pow(a2 + t2 * b2, y2);
20072     };
20073   }
20074   function gamma(y2) {
20075     return (y2 = +y2) === 1 ? nogamma : function(a2, b2) {
20076       return b2 - a2 ? exponential(a2, b2, y2) : constant_default3(isNaN(a2) ? b2 : a2);
20077     };
20078   }
20079   function nogamma(a2, b2) {
20080     var d2 = b2 - a2;
20081     return d2 ? linear(a2, d2) : constant_default3(isNaN(a2) ? b2 : a2);
20082   }
20083
20084   // node_modules/d3-interpolate/src/rgb.js
20085   var rgb_default = function rgbGamma(y2) {
20086     var color2 = gamma(y2);
20087     function rgb2(start2, end) {
20088       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);
20089       return function(t2) {
20090         start2.r = r2(t2);
20091         start2.g = g3(t2);
20092         start2.b = b2(t2);
20093         start2.opacity = opacity(t2);
20094         return start2 + "";
20095       };
20096     }
20097     rgb2.gamma = rgbGamma;
20098     return rgb2;
20099   }(1);
20100   function rgbSpline(spline) {
20101     return function(colors) {
20102       var n3 = colors.length, r2 = new Array(n3), g3 = new Array(n3), b2 = new Array(n3), i3, color2;
20103       for (i3 = 0; i3 < n3; ++i3) {
20104         color2 = rgb(colors[i3]);
20105         r2[i3] = color2.r || 0;
20106         g3[i3] = color2.g || 0;
20107         b2[i3] = color2.b || 0;
20108       }
20109       r2 = spline(r2);
20110       g3 = spline(g3);
20111       b2 = spline(b2);
20112       color2.opacity = 1;
20113       return function(t2) {
20114         color2.r = r2(t2);
20115         color2.g = g3(t2);
20116         color2.b = b2(t2);
20117         return color2 + "";
20118       };
20119     };
20120   }
20121   var rgbBasis = rgbSpline(basis_default);
20122   var rgbBasisClosed = rgbSpline(basisClosed_default);
20123
20124   // node_modules/d3-interpolate/src/numberArray.js
20125   function numberArray_default(a2, b2) {
20126     if (!b2)
20127       b2 = [];
20128     var n3 = a2 ? Math.min(b2.length, a2.length) : 0, c2 = b2.slice(), i3;
20129     return function(t2) {
20130       for (i3 = 0; i3 < n3; ++i3)
20131         c2[i3] = a2[i3] * (1 - t2) + b2[i3] * t2;
20132       return c2;
20133     };
20134   }
20135   function isNumberArray(x2) {
20136     return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
20137   }
20138
20139   // node_modules/d3-interpolate/src/array.js
20140   function genericArray(a2, b2) {
20141     var nb = b2 ? b2.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i3;
20142     for (i3 = 0; i3 < na; ++i3)
20143       x2[i3] = value_default(a2[i3], b2[i3]);
20144     for (; i3 < nb; ++i3)
20145       c2[i3] = b2[i3];
20146     return function(t2) {
20147       for (i3 = 0; i3 < na; ++i3)
20148         c2[i3] = x2[i3](t2);
20149       return c2;
20150     };
20151   }
20152
20153   // node_modules/d3-interpolate/src/date.js
20154   function date_default(a2, b2) {
20155     var d2 = /* @__PURE__ */ new Date();
20156     return a2 = +a2, b2 = +b2, function(t2) {
20157       return d2.setTime(a2 * (1 - t2) + b2 * t2), d2;
20158     };
20159   }
20160
20161   // node_modules/d3-interpolate/src/number.js
20162   function number_default(a2, b2) {
20163     return a2 = +a2, b2 = +b2, function(t2) {
20164       return a2 * (1 - t2) + b2 * t2;
20165     };
20166   }
20167
20168   // node_modules/d3-interpolate/src/object.js
20169   function object_default(a2, b2) {
20170     var i3 = {}, c2 = {}, k2;
20171     if (a2 === null || typeof a2 !== "object")
20172       a2 = {};
20173     if (b2 === null || typeof b2 !== "object")
20174       b2 = {};
20175     for (k2 in b2) {
20176       if (k2 in a2) {
20177         i3[k2] = value_default(a2[k2], b2[k2]);
20178       } else {
20179         c2[k2] = b2[k2];
20180       }
20181     }
20182     return function(t2) {
20183       for (k2 in i3)
20184         c2[k2] = i3[k2](t2);
20185       return c2;
20186     };
20187   }
20188
20189   // node_modules/d3-interpolate/src/string.js
20190   var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
20191   var reB = new RegExp(reA.source, "g");
20192   function zero2(b2) {
20193     return function() {
20194       return b2;
20195     };
20196   }
20197   function one(b2) {
20198     return function(t2) {
20199       return b2(t2) + "";
20200     };
20201   }
20202   function string_default(a2, b2) {
20203     var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i3 = -1, s2 = [], q2 = [];
20204     a2 = a2 + "", b2 = b2 + "";
20205     while ((am = reA.exec(a2)) && (bm = reB.exec(b2))) {
20206       if ((bs = bm.index) > bi) {
20207         bs = b2.slice(bi, bs);
20208         if (s2[i3])
20209           s2[i3] += bs;
20210         else
20211           s2[++i3] = bs;
20212       }
20213       if ((am = am[0]) === (bm = bm[0])) {
20214         if (s2[i3])
20215           s2[i3] += bm;
20216         else
20217           s2[++i3] = bm;
20218       } else {
20219         s2[++i3] = null;
20220         q2.push({ i: i3, x: number_default(am, bm) });
20221       }
20222       bi = reB.lastIndex;
20223     }
20224     if (bi < b2.length) {
20225       bs = b2.slice(bi);
20226       if (s2[i3])
20227         s2[i3] += bs;
20228       else
20229         s2[++i3] = bs;
20230     }
20231     return s2.length < 2 ? q2[0] ? one(q2[0].x) : zero2(b2) : (b2 = q2.length, function(t2) {
20232       for (var i4 = 0, o2; i4 < b2; ++i4)
20233         s2[(o2 = q2[i4]).i] = o2.x(t2);
20234       return s2.join("");
20235     });
20236   }
20237
20238   // node_modules/d3-interpolate/src/value.js
20239   function value_default(a2, b2) {
20240     var t2 = typeof b2, c2;
20241     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);
20242   }
20243
20244   // node_modules/d3-interpolate/src/round.js
20245   function round_default(a2, b2) {
20246     return a2 = +a2, b2 = +b2, function(t2) {
20247       return Math.round(a2 * (1 - t2) + b2 * t2);
20248     };
20249   }
20250
20251   // node_modules/d3-interpolate/src/transform/decompose.js
20252   var degrees2 = 180 / Math.PI;
20253   var identity = {
20254     translateX: 0,
20255     translateY: 0,
20256     rotate: 0,
20257     skewX: 0,
20258     scaleX: 1,
20259     scaleY: 1
20260   };
20261   function decompose_default(a2, b2, c2, d2, e3, f2) {
20262     var scaleX, scaleY, skewX;
20263     if (scaleX = Math.sqrt(a2 * a2 + b2 * b2))
20264       a2 /= scaleX, b2 /= scaleX;
20265     if (skewX = a2 * c2 + b2 * d2)
20266       c2 -= a2 * skewX, d2 -= b2 * skewX;
20267     if (scaleY = Math.sqrt(c2 * c2 + d2 * d2))
20268       c2 /= scaleY, d2 /= scaleY, skewX /= scaleY;
20269     if (a2 * d2 < b2 * c2)
20270       a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX;
20271     return {
20272       translateX: e3,
20273       translateY: f2,
20274       rotate: Math.atan2(b2, a2) * degrees2,
20275       skewX: Math.atan(skewX) * degrees2,
20276       scaleX,
20277       scaleY
20278     };
20279   }
20280
20281   // node_modules/d3-interpolate/src/transform/parse.js
20282   var svgNode;
20283   function parseCss(value) {
20284     const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
20285     return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f);
20286   }
20287   function parseSvg(value) {
20288     if (value == null)
20289       return identity;
20290     if (!svgNode)
20291       svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
20292     svgNode.setAttribute("transform", value);
20293     if (!(value = svgNode.transform.baseVal.consolidate()))
20294       return identity;
20295     value = value.matrix;
20296     return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f);
20297   }
20298
20299   // node_modules/d3-interpolate/src/transform/index.js
20300   function interpolateTransform(parse, pxComma, pxParen, degParen) {
20301     function pop(s2) {
20302       return s2.length ? s2.pop() + " " : "";
20303     }
20304     function translate(xa, ya, xb, yb, s2, q2) {
20305       if (xa !== xb || ya !== yb) {
20306         var i3 = s2.push("translate(", null, pxComma, null, pxParen);
20307         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20308       } else if (xb || yb) {
20309         s2.push("translate(" + xb + pxComma + yb + pxParen);
20310       }
20311     }
20312     function rotate(a2, b2, s2, q2) {
20313       if (a2 !== b2) {
20314         if (a2 - b2 > 180)
20315           b2 += 360;
20316         else if (b2 - a2 > 180)
20317           a2 += 360;
20318         q2.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: number_default(a2, b2) });
20319       } else if (b2) {
20320         s2.push(pop(s2) + "rotate(" + b2 + degParen);
20321       }
20322     }
20323     function skewX(a2, b2, s2, q2) {
20324       if (a2 !== b2) {
20325         q2.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: number_default(a2, b2) });
20326       } else if (b2) {
20327         s2.push(pop(s2) + "skewX(" + b2 + degParen);
20328       }
20329     }
20330     function scale(xa, ya, xb, yb, s2, q2) {
20331       if (xa !== xb || ya !== yb) {
20332         var i3 = s2.push(pop(s2) + "scale(", null, ",", null, ")");
20333         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20334       } else if (xb !== 1 || yb !== 1) {
20335         s2.push(pop(s2) + "scale(" + xb + "," + yb + ")");
20336       }
20337     }
20338     return function(a2, b2) {
20339       var s2 = [], q2 = [];
20340       a2 = parse(a2), b2 = parse(b2);
20341       translate(a2.translateX, a2.translateY, b2.translateX, b2.translateY, s2, q2);
20342       rotate(a2.rotate, b2.rotate, s2, q2);
20343       skewX(a2.skewX, b2.skewX, s2, q2);
20344       scale(a2.scaleX, a2.scaleY, b2.scaleX, b2.scaleY, s2, q2);
20345       a2 = b2 = null;
20346       return function(t2) {
20347         var i3 = -1, n3 = q2.length, o2;
20348         while (++i3 < n3)
20349           s2[(o2 = q2[i3]).i] = o2.x(t2);
20350         return s2.join("");
20351       };
20352     };
20353   }
20354   var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
20355   var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
20356
20357   // node_modules/d3-interpolate/src/zoom.js
20358   var epsilon22 = 1e-12;
20359   function cosh(x2) {
20360     return ((x2 = Math.exp(x2)) + 1 / x2) / 2;
20361   }
20362   function sinh(x2) {
20363     return ((x2 = Math.exp(x2)) - 1 / x2) / 2;
20364   }
20365   function tanh(x2) {
20366     return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1);
20367   }
20368   var zoom_default = function zoomRho(rho, rho2, rho4) {
20369     function zoom(p02, p1) {
20370       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;
20371       if (d2 < epsilon22) {
20372         S2 = Math.log(w1 / w0) / rho;
20373         i3 = function(t2) {
20374           return [
20375             ux0 + t2 * dx,
20376             uy0 + t2 * dy,
20377             w0 * Math.exp(rho * t2 * S2)
20378           ];
20379         };
20380       } else {
20381         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);
20382         S2 = (r1 - r0) / rho;
20383         i3 = function(t2) {
20384           var s2 = t2 * S2, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0));
20385           return [
20386             ux0 + u2 * dx,
20387             uy0 + u2 * dy,
20388             w0 * coshr0 / cosh(rho * s2 + r0)
20389           ];
20390         };
20391       }
20392       i3.duration = S2 * 1e3 * rho / Math.SQRT2;
20393       return i3;
20394     }
20395     zoom.rho = function(_2) {
20396       var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22;
20397       return zoomRho(_1, _22, _4);
20398     };
20399     return zoom;
20400   }(Math.SQRT2, 2, 4);
20401
20402   // node_modules/d3-interpolate/src/quantize.js
20403   function quantize_default(interpolator, n3) {
20404     var samples = new Array(n3);
20405     for (var i3 = 0; i3 < n3; ++i3)
20406       samples[i3] = interpolator(i3 / (n3 - 1));
20407     return samples;
20408   }
20409
20410   // node_modules/d3-timer/src/timer.js
20411   var frame = 0;
20412   var timeout = 0;
20413   var interval = 0;
20414   var pokeDelay = 1e3;
20415   var taskHead;
20416   var taskTail;
20417   var clockLast = 0;
20418   var clockNow = 0;
20419   var clockSkew = 0;
20420   var clock = typeof performance === "object" && performance.now ? performance : Date;
20421   var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) {
20422     setTimeout(f2, 17);
20423   };
20424   function now() {
20425     return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
20426   }
20427   function clearNow() {
20428     clockNow = 0;
20429   }
20430   function Timer() {
20431     this._call = this._time = this._next = null;
20432   }
20433   Timer.prototype = timer.prototype = {
20434     constructor: Timer,
20435     restart: function(callback, delay, time) {
20436       if (typeof callback !== "function")
20437         throw new TypeError("callback is not a function");
20438       time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
20439       if (!this._next && taskTail !== this) {
20440         if (taskTail)
20441           taskTail._next = this;
20442         else
20443           taskHead = this;
20444         taskTail = this;
20445       }
20446       this._call = callback;
20447       this._time = time;
20448       sleep();
20449     },
20450     stop: function() {
20451       if (this._call) {
20452         this._call = null;
20453         this._time = Infinity;
20454         sleep();
20455       }
20456     }
20457   };
20458   function timer(callback, delay, time) {
20459     var t2 = new Timer();
20460     t2.restart(callback, delay, time);
20461     return t2;
20462   }
20463   function timerFlush() {
20464     now();
20465     ++frame;
20466     var t2 = taskHead, e3;
20467     while (t2) {
20468       if ((e3 = clockNow - t2._time) >= 0)
20469         t2._call.call(void 0, e3);
20470       t2 = t2._next;
20471     }
20472     --frame;
20473   }
20474   function wake() {
20475     clockNow = (clockLast = clock.now()) + clockSkew;
20476     frame = timeout = 0;
20477     try {
20478       timerFlush();
20479     } finally {
20480       frame = 0;
20481       nap();
20482       clockNow = 0;
20483     }
20484   }
20485   function poke() {
20486     var now3 = clock.now(), delay = now3 - clockLast;
20487     if (delay > pokeDelay)
20488       clockSkew -= delay, clockLast = now3;
20489   }
20490   function nap() {
20491     var t0, t1 = taskHead, t2, time = Infinity;
20492     while (t1) {
20493       if (t1._call) {
20494         if (time > t1._time)
20495           time = t1._time;
20496         t0 = t1, t1 = t1._next;
20497       } else {
20498         t2 = t1._next, t1._next = null;
20499         t1 = t0 ? t0._next = t2 : taskHead = t2;
20500       }
20501     }
20502     taskTail = t0;
20503     sleep(time);
20504   }
20505   function sleep(time) {
20506     if (frame)
20507       return;
20508     if (timeout)
20509       timeout = clearTimeout(timeout);
20510     var delay = time - clockNow;
20511     if (delay > 24) {
20512       if (time < Infinity)
20513         timeout = setTimeout(wake, time - clock.now() - clockSkew);
20514       if (interval)
20515         interval = clearInterval(interval);
20516     } else {
20517       if (!interval)
20518         clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
20519       frame = 1, setFrame(wake);
20520     }
20521   }
20522
20523   // node_modules/d3-timer/src/timeout.js
20524   function timeout_default(callback, delay, time) {
20525     var t2 = new Timer();
20526     delay = delay == null ? 0 : +delay;
20527     t2.restart((elapsed) => {
20528       t2.stop();
20529       callback(elapsed + delay);
20530     }, delay, time);
20531     return t2;
20532   }
20533
20534   // node_modules/d3-transition/src/transition/schedule.js
20535   var emptyOn = dispatch_default("start", "end", "cancel", "interrupt");
20536   var emptyTween = [];
20537   var CREATED = 0;
20538   var SCHEDULED = 1;
20539   var STARTING = 2;
20540   var STARTED = 3;
20541   var RUNNING = 4;
20542   var ENDING = 5;
20543   var ENDED = 6;
20544   function schedule_default(node, name, id2, index, group, timing) {
20545     var schedules = node.__transition;
20546     if (!schedules)
20547       node.__transition = {};
20548     else if (id2 in schedules)
20549       return;
20550     create(node, id2, {
20551       name,
20552       index,
20553       // For context during callback.
20554       group,
20555       // For context during callback.
20556       on: emptyOn,
20557       tween: emptyTween,
20558       time: timing.time,
20559       delay: timing.delay,
20560       duration: timing.duration,
20561       ease: timing.ease,
20562       timer: null,
20563       state: CREATED
20564     });
20565   }
20566   function init(node, id2) {
20567     var schedule = get2(node, id2);
20568     if (schedule.state > CREATED)
20569       throw new Error("too late; already scheduled");
20570     return schedule;
20571   }
20572   function set2(node, id2) {
20573     var schedule = get2(node, id2);
20574     if (schedule.state > STARTED)
20575       throw new Error("too late; already running");
20576     return schedule;
20577   }
20578   function get2(node, id2) {
20579     var schedule = node.__transition;
20580     if (!schedule || !(schedule = schedule[id2]))
20581       throw new Error("transition not found");
20582     return schedule;
20583   }
20584   function create(node, id2, self2) {
20585     var schedules = node.__transition, tween;
20586     schedules[id2] = self2;
20587     self2.timer = timer(schedule, 0, self2.time);
20588     function schedule(elapsed) {
20589       self2.state = SCHEDULED;
20590       self2.timer.restart(start2, self2.delay, self2.time);
20591       if (self2.delay <= elapsed)
20592         start2(elapsed - self2.delay);
20593     }
20594     function start2(elapsed) {
20595       var i3, j2, n3, o2;
20596       if (self2.state !== SCHEDULED)
20597         return stop();
20598       for (i3 in schedules) {
20599         o2 = schedules[i3];
20600         if (o2.name !== self2.name)
20601           continue;
20602         if (o2.state === STARTED)
20603           return timeout_default(start2);
20604         if (o2.state === RUNNING) {
20605           o2.state = ENDED;
20606           o2.timer.stop();
20607           o2.on.call("interrupt", node, node.__data__, o2.index, o2.group);
20608           delete schedules[i3];
20609         } else if (+i3 < id2) {
20610           o2.state = ENDED;
20611           o2.timer.stop();
20612           o2.on.call("cancel", node, node.__data__, o2.index, o2.group);
20613           delete schedules[i3];
20614         }
20615       }
20616       timeout_default(function() {
20617         if (self2.state === STARTED) {
20618           self2.state = RUNNING;
20619           self2.timer.restart(tick, self2.delay, self2.time);
20620           tick(elapsed);
20621         }
20622       });
20623       self2.state = STARTING;
20624       self2.on.call("start", node, node.__data__, self2.index, self2.group);
20625       if (self2.state !== STARTING)
20626         return;
20627       self2.state = STARTED;
20628       tween = new Array(n3 = self2.tween.length);
20629       for (i3 = 0, j2 = -1; i3 < n3; ++i3) {
20630         if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) {
20631           tween[++j2] = o2;
20632         }
20633       }
20634       tween.length = j2 + 1;
20635     }
20636     function tick(elapsed) {
20637       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;
20638       while (++i3 < n3) {
20639         tween[i3].call(node, t2);
20640       }
20641       if (self2.state === ENDING) {
20642         self2.on.call("end", node, node.__data__, self2.index, self2.group);
20643         stop();
20644       }
20645     }
20646     function stop() {
20647       self2.state = ENDED;
20648       self2.timer.stop();
20649       delete schedules[id2];
20650       for (var i3 in schedules)
20651         return;
20652       delete node.__transition;
20653     }
20654   }
20655
20656   // node_modules/d3-transition/src/interrupt.js
20657   function interrupt_default(node, name) {
20658     var schedules = node.__transition, schedule, active, empty2 = true, i3;
20659     if (!schedules)
20660       return;
20661     name = name == null ? null : name + "";
20662     for (i3 in schedules) {
20663       if ((schedule = schedules[i3]).name !== name) {
20664         empty2 = false;
20665         continue;
20666       }
20667       active = schedule.state > STARTING && schedule.state < ENDING;
20668       schedule.state = ENDED;
20669       schedule.timer.stop();
20670       schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
20671       delete schedules[i3];
20672     }
20673     if (empty2)
20674       delete node.__transition;
20675   }
20676
20677   // node_modules/d3-transition/src/selection/interrupt.js
20678   function interrupt_default2(name) {
20679     return this.each(function() {
20680       interrupt_default(this, name);
20681     });
20682   }
20683
20684   // node_modules/d3-transition/src/transition/tween.js
20685   function tweenRemove(id2, name) {
20686     var tween0, tween1;
20687     return function() {
20688       var schedule = set2(this, id2), tween = schedule.tween;
20689       if (tween !== tween0) {
20690         tween1 = tween0 = tween;
20691         for (var i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20692           if (tween1[i3].name === name) {
20693             tween1 = tween1.slice();
20694             tween1.splice(i3, 1);
20695             break;
20696           }
20697         }
20698       }
20699       schedule.tween = tween1;
20700     };
20701   }
20702   function tweenFunction(id2, name, value) {
20703     var tween0, tween1;
20704     if (typeof value !== "function")
20705       throw new Error();
20706     return function() {
20707       var schedule = set2(this, id2), tween = schedule.tween;
20708       if (tween !== tween0) {
20709         tween1 = (tween0 = tween).slice();
20710         for (var t2 = { name, value }, i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20711           if (tween1[i3].name === name) {
20712             tween1[i3] = t2;
20713             break;
20714           }
20715         }
20716         if (i3 === n3)
20717           tween1.push(t2);
20718       }
20719       schedule.tween = tween1;
20720     };
20721   }
20722   function tween_default(name, value) {
20723     var id2 = this._id;
20724     name += "";
20725     if (arguments.length < 2) {
20726       var tween = get2(this.node(), id2).tween;
20727       for (var i3 = 0, n3 = tween.length, t2; i3 < n3; ++i3) {
20728         if ((t2 = tween[i3]).name === name) {
20729           return t2.value;
20730         }
20731       }
20732       return null;
20733     }
20734     return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
20735   }
20736   function tweenValue(transition2, name, value) {
20737     var id2 = transition2._id;
20738     transition2.each(function() {
20739       var schedule = set2(this, id2);
20740       (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
20741     });
20742     return function(node) {
20743       return get2(node, id2).value[name];
20744     };
20745   }
20746
20747   // node_modules/d3-transition/src/transition/interpolate.js
20748   function interpolate_default(a2, b2) {
20749     var c2;
20750     return (typeof b2 === "number" ? number_default : b2 instanceof color ? rgb_default : (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default)(a2, b2);
20751   }
20752
20753   // node_modules/d3-transition/src/transition/attr.js
20754   function attrRemove2(name) {
20755     return function() {
20756       this.removeAttribute(name);
20757     };
20758   }
20759   function attrRemoveNS2(fullname) {
20760     return function() {
20761       this.removeAttributeNS(fullname.space, fullname.local);
20762     };
20763   }
20764   function attrConstant2(name, interpolate, value1) {
20765     var string00, string1 = value1 + "", interpolate0;
20766     return function() {
20767       var string0 = this.getAttribute(name);
20768       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
20769     };
20770   }
20771   function attrConstantNS2(fullname, interpolate, value1) {
20772     var string00, string1 = value1 + "", interpolate0;
20773     return function() {
20774       var string0 = this.getAttributeNS(fullname.space, fullname.local);
20775       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
20776     };
20777   }
20778   function attrFunction2(name, interpolate, value) {
20779     var string00, string10, interpolate0;
20780     return function() {
20781       var string0, value1 = value(this), string1;
20782       if (value1 == null)
20783         return void this.removeAttribute(name);
20784       string0 = this.getAttribute(name);
20785       string1 = value1 + "";
20786       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
20787     };
20788   }
20789   function attrFunctionNS2(fullname, interpolate, value) {
20790     var string00, string10, interpolate0;
20791     return function() {
20792       var string0, value1 = value(this), string1;
20793       if (value1 == null)
20794         return void this.removeAttributeNS(fullname.space, fullname.local);
20795       string0 = this.getAttributeNS(fullname.space, fullname.local);
20796       string1 = value1 + "";
20797       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
20798     };
20799   }
20800   function attr_default2(name, value) {
20801     var fullname = namespace_default(name), i3 = fullname === "transform" ? interpolateTransformSvg : interpolate_default;
20802     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));
20803   }
20804
20805   // node_modules/d3-transition/src/transition/attrTween.js
20806   function attrInterpolate(name, i3) {
20807     return function(t2) {
20808       this.setAttribute(name, i3.call(this, t2));
20809     };
20810   }
20811   function attrInterpolateNS(fullname, i3) {
20812     return function(t2) {
20813       this.setAttributeNS(fullname.space, fullname.local, i3.call(this, t2));
20814     };
20815   }
20816   function attrTweenNS(fullname, value) {
20817     var t0, i0;
20818     function tween() {
20819       var i3 = value.apply(this, arguments);
20820       if (i3 !== i0)
20821         t0 = (i0 = i3) && attrInterpolateNS(fullname, i3);
20822       return t0;
20823     }
20824     tween._value = value;
20825     return tween;
20826   }
20827   function attrTween(name, value) {
20828     var t0, i0;
20829     function tween() {
20830       var i3 = value.apply(this, arguments);
20831       if (i3 !== i0)
20832         t0 = (i0 = i3) && attrInterpolate(name, i3);
20833       return t0;
20834     }
20835     tween._value = value;
20836     return tween;
20837   }
20838   function attrTween_default(name, value) {
20839     var key = "attr." + name;
20840     if (arguments.length < 2)
20841       return (key = this.tween(key)) && key._value;
20842     if (value == null)
20843       return this.tween(key, null);
20844     if (typeof value !== "function")
20845       throw new Error();
20846     var fullname = namespace_default(name);
20847     return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
20848   }
20849
20850   // node_modules/d3-transition/src/transition/delay.js
20851   function delayFunction(id2, value) {
20852     return function() {
20853       init(this, id2).delay = +value.apply(this, arguments);
20854     };
20855   }
20856   function delayConstant(id2, value) {
20857     return value = +value, function() {
20858       init(this, id2).delay = value;
20859     };
20860   }
20861   function delay_default(value) {
20862     var id2 = this._id;
20863     return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay;
20864   }
20865
20866   // node_modules/d3-transition/src/transition/duration.js
20867   function durationFunction(id2, value) {
20868     return function() {
20869       set2(this, id2).duration = +value.apply(this, arguments);
20870     };
20871   }
20872   function durationConstant(id2, value) {
20873     return value = +value, function() {
20874       set2(this, id2).duration = value;
20875     };
20876   }
20877   function duration_default(value) {
20878     var id2 = this._id;
20879     return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration;
20880   }
20881
20882   // node_modules/d3-transition/src/transition/ease.js
20883   function easeConstant(id2, value) {
20884     if (typeof value !== "function")
20885       throw new Error();
20886     return function() {
20887       set2(this, id2).ease = value;
20888     };
20889   }
20890   function ease_default(value) {
20891     var id2 = this._id;
20892     return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease;
20893   }
20894
20895   // node_modules/d3-transition/src/transition/easeVarying.js
20896   function easeVarying(id2, value) {
20897     return function() {
20898       var v2 = value.apply(this, arguments);
20899       if (typeof v2 !== "function")
20900         throw new Error();
20901       set2(this, id2).ease = v2;
20902     };
20903   }
20904   function easeVarying_default(value) {
20905     if (typeof value !== "function")
20906       throw new Error();
20907     return this.each(easeVarying(this._id, value));
20908   }
20909
20910   // node_modules/d3-transition/src/transition/filter.js
20911   function filter_default2(match) {
20912     if (typeof match !== "function")
20913       match = matcher_default(match);
20914     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
20915       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
20916         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
20917           subgroup.push(node);
20918         }
20919       }
20920     }
20921     return new Transition(subgroups, this._parents, this._name, this._id);
20922   }
20923
20924   // node_modules/d3-transition/src/transition/merge.js
20925   function merge_default2(transition2) {
20926     if (transition2._id !== this._id)
20927       throw new Error();
20928     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) {
20929       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
20930         if (node = group0[i3] || group1[i3]) {
20931           merge2[i3] = node;
20932         }
20933       }
20934     }
20935     for (; j2 < m0; ++j2) {
20936       merges[j2] = groups0[j2];
20937     }
20938     return new Transition(merges, this._parents, this._name, this._id);
20939   }
20940
20941   // node_modules/d3-transition/src/transition/on.js
20942   function start(name) {
20943     return (name + "").trim().split(/^|\s+/).every(function(t2) {
20944       var i3 = t2.indexOf(".");
20945       if (i3 >= 0)
20946         t2 = t2.slice(0, i3);
20947       return !t2 || t2 === "start";
20948     });
20949   }
20950   function onFunction(id2, name, listener) {
20951     var on0, on1, sit = start(name) ? init : set2;
20952     return function() {
20953       var schedule = sit(this, id2), on = schedule.on;
20954       if (on !== on0)
20955         (on1 = (on0 = on).copy()).on(name, listener);
20956       schedule.on = on1;
20957     };
20958   }
20959   function on_default2(name, listener) {
20960     var id2 = this._id;
20961     return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
20962   }
20963
20964   // node_modules/d3-transition/src/transition/remove.js
20965   function removeFunction(id2) {
20966     return function() {
20967       var parent = this.parentNode;
20968       for (var i3 in this.__transition)
20969         if (+i3 !== id2)
20970           return;
20971       if (parent)
20972         parent.removeChild(this);
20973     };
20974   }
20975   function remove_default2() {
20976     return this.on("end.remove", removeFunction(this._id));
20977   }
20978
20979   // node_modules/d3-transition/src/transition/select.js
20980   function select_default3(select) {
20981     var name = this._name, id2 = this._id;
20982     if (typeof select !== "function")
20983       select = selector_default(select);
20984     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
20985       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
20986         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
20987           if ("__data__" in node)
20988             subnode.__data__ = node.__data__;
20989           subgroup[i3] = subnode;
20990           schedule_default(subgroup[i3], name, id2, i3, subgroup, get2(node, id2));
20991         }
20992       }
20993     }
20994     return new Transition(subgroups, this._parents, name, id2);
20995   }
20996
20997   // node_modules/d3-transition/src/transition/selectAll.js
20998   function selectAll_default3(select) {
20999     var name = this._name, id2 = this._id;
21000     if (typeof select !== "function")
21001       select = selectorAll_default(select);
21002     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
21003       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21004         if (node = group[i3]) {
21005           for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) {
21006             if (child = children2[k2]) {
21007               schedule_default(child, name, id2, k2, children2, inherit2);
21008             }
21009           }
21010           subgroups.push(children2);
21011           parents.push(node);
21012         }
21013       }
21014     }
21015     return new Transition(subgroups, parents, name, id2);
21016   }
21017
21018   // node_modules/d3-transition/src/transition/selection.js
21019   var Selection2 = selection_default.prototype.constructor;
21020   function selection_default2() {
21021     return new Selection2(this._groups, this._parents);
21022   }
21023
21024   // node_modules/d3-transition/src/transition/style.js
21025   function styleNull(name, interpolate) {
21026     var string00, string10, interpolate0;
21027     return function() {
21028       var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
21029       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1);
21030     };
21031   }
21032   function styleRemove2(name) {
21033     return function() {
21034       this.style.removeProperty(name);
21035     };
21036   }
21037   function styleConstant2(name, interpolate, value1) {
21038     var string00, string1 = value1 + "", interpolate0;
21039     return function() {
21040       var string0 = styleValue(this, name);
21041       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21042     };
21043   }
21044   function styleFunction2(name, interpolate, value) {
21045     var string00, string10, interpolate0;
21046     return function() {
21047       var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
21048       if (value1 == null)
21049         string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
21050       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21051     };
21052   }
21053   function styleMaybeRemove(id2, name) {
21054     var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
21055     return function() {
21056       var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0;
21057       if (on !== on0 || listener0 !== listener)
21058         (on1 = (on0 = on).copy()).on(event, listener0 = listener);
21059       schedule.on = on1;
21060     };
21061   }
21062   function style_default2(name, value, priority) {
21063     var i3 = (name += "") === "transform" ? interpolateTransformCss : interpolate_default;
21064     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);
21065   }
21066
21067   // node_modules/d3-transition/src/transition/styleTween.js
21068   function styleInterpolate(name, i3, priority) {
21069     return function(t2) {
21070       this.style.setProperty(name, i3.call(this, t2), priority);
21071     };
21072   }
21073   function styleTween(name, value, priority) {
21074     var t2, i0;
21075     function tween() {
21076       var i3 = value.apply(this, arguments);
21077       if (i3 !== i0)
21078         t2 = (i0 = i3) && styleInterpolate(name, i3, priority);
21079       return t2;
21080     }
21081     tween._value = value;
21082     return tween;
21083   }
21084   function styleTween_default(name, value, priority) {
21085     var key = "style." + (name += "");
21086     if (arguments.length < 2)
21087       return (key = this.tween(key)) && key._value;
21088     if (value == null)
21089       return this.tween(key, null);
21090     if (typeof value !== "function")
21091       throw new Error();
21092     return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
21093   }
21094
21095   // node_modules/d3-transition/src/transition/text.js
21096   function textConstant2(value) {
21097     return function() {
21098       this.textContent = value;
21099     };
21100   }
21101   function textFunction2(value) {
21102     return function() {
21103       var value1 = value(this);
21104       this.textContent = value1 == null ? "" : value1;
21105     };
21106   }
21107   function text_default2(value) {
21108     return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + ""));
21109   }
21110
21111   // node_modules/d3-transition/src/transition/textTween.js
21112   function textInterpolate(i3) {
21113     return function(t2) {
21114       this.textContent = i3.call(this, t2);
21115     };
21116   }
21117   function textTween(value) {
21118     var t0, i0;
21119     function tween() {
21120       var i3 = value.apply(this, arguments);
21121       if (i3 !== i0)
21122         t0 = (i0 = i3) && textInterpolate(i3);
21123       return t0;
21124     }
21125     tween._value = value;
21126     return tween;
21127   }
21128   function textTween_default(value) {
21129     var key = "text";
21130     if (arguments.length < 1)
21131       return (key = this.tween(key)) && key._value;
21132     if (value == null)
21133       return this.tween(key, null);
21134     if (typeof value !== "function")
21135       throw new Error();
21136     return this.tween(key, textTween(value));
21137   }
21138
21139   // node_modules/d3-transition/src/transition/transition.js
21140   function transition_default() {
21141     var name = this._name, id0 = this._id, id1 = newId();
21142     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21143       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21144         if (node = group[i3]) {
21145           var inherit2 = get2(node, id0);
21146           schedule_default(node, name, id1, i3, group, {
21147             time: inherit2.time + inherit2.delay + inherit2.duration,
21148             delay: 0,
21149             duration: inherit2.duration,
21150             ease: inherit2.ease
21151           });
21152         }
21153       }
21154     }
21155     return new Transition(groups, this._parents, name, id1);
21156   }
21157
21158   // node_modules/d3-transition/src/transition/end.js
21159   function end_default() {
21160     var on0, on1, that = this, id2 = that._id, size = that.size();
21161     return new Promise(function(resolve, reject) {
21162       var cancel = { value: reject }, end = { value: function() {
21163         if (--size === 0)
21164           resolve();
21165       } };
21166       that.each(function() {
21167         var schedule = set2(this, id2), on = schedule.on;
21168         if (on !== on0) {
21169           on1 = (on0 = on).copy();
21170           on1._.cancel.push(cancel);
21171           on1._.interrupt.push(cancel);
21172           on1._.end.push(end);
21173         }
21174         schedule.on = on1;
21175       });
21176       if (size === 0)
21177         resolve();
21178     });
21179   }
21180
21181   // node_modules/d3-transition/src/transition/index.js
21182   var id = 0;
21183   function Transition(groups, parents, name, id2) {
21184     this._groups = groups;
21185     this._parents = parents;
21186     this._name = name;
21187     this._id = id2;
21188   }
21189   function transition(name) {
21190     return selection_default().transition(name);
21191   }
21192   function newId() {
21193     return ++id;
21194   }
21195   var selection_prototype = selection_default.prototype;
21196   Transition.prototype = transition.prototype = {
21197     constructor: Transition,
21198     select: select_default3,
21199     selectAll: selectAll_default3,
21200     selectChild: selection_prototype.selectChild,
21201     selectChildren: selection_prototype.selectChildren,
21202     filter: filter_default2,
21203     merge: merge_default2,
21204     selection: selection_default2,
21205     transition: transition_default,
21206     call: selection_prototype.call,
21207     nodes: selection_prototype.nodes,
21208     node: selection_prototype.node,
21209     size: selection_prototype.size,
21210     empty: selection_prototype.empty,
21211     each: selection_prototype.each,
21212     on: on_default2,
21213     attr: attr_default2,
21214     attrTween: attrTween_default,
21215     style: style_default2,
21216     styleTween: styleTween_default,
21217     text: text_default2,
21218     textTween: textTween_default,
21219     remove: remove_default2,
21220     tween: tween_default,
21221     delay: delay_default,
21222     duration: duration_default,
21223     ease: ease_default,
21224     easeVarying: easeVarying_default,
21225     end: end_default,
21226     [Symbol.iterator]: selection_prototype[Symbol.iterator]
21227   };
21228
21229   // node_modules/d3-ease/src/linear.js
21230   var linear2 = (t2) => +t2;
21231
21232   // node_modules/d3-ease/src/cubic.js
21233   function cubicInOut(t2) {
21234     return ((t2 *= 2) <= 1 ? t2 * t2 * t2 : (t2 -= 2) * t2 * t2 + 2) / 2;
21235   }
21236
21237   // node_modules/d3-transition/src/selection/transition.js
21238   var defaultTiming = {
21239     time: null,
21240     // Set on use.
21241     delay: 0,
21242     duration: 250,
21243     ease: cubicInOut
21244   };
21245   function inherit(node, id2) {
21246     var timing;
21247     while (!(timing = node.__transition) || !(timing = timing[id2])) {
21248       if (!(node = node.parentNode)) {
21249         throw new Error("transition ".concat(id2, " not found"));
21250       }
21251     }
21252     return timing;
21253   }
21254   function transition_default2(name) {
21255     var id2, timing;
21256     if (name instanceof Transition) {
21257       id2 = name._id, name = name._name;
21258     } else {
21259       id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
21260     }
21261     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21262       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21263         if (node = group[i3]) {
21264           schedule_default(node, name, id2, i3, group, timing || inherit(node, id2));
21265         }
21266       }
21267     }
21268     return new Transition(groups, this._parents, name, id2);
21269   }
21270
21271   // node_modules/d3-transition/src/selection/index.js
21272   selection_default.prototype.interrupt = interrupt_default2;
21273   selection_default.prototype.transition = transition_default2;
21274
21275   // node_modules/d3-zoom/src/constant.js
21276   var constant_default4 = (x2) => () => x2;
21277
21278   // node_modules/d3-zoom/src/event.js
21279   function ZoomEvent(type2, {
21280     sourceEvent,
21281     target,
21282     transform: transform2,
21283     dispatch: dispatch14
21284   }) {
21285     Object.defineProperties(this, {
21286       type: { value: type2, enumerable: true, configurable: true },
21287       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
21288       target: { value: target, enumerable: true, configurable: true },
21289       transform: { value: transform2, enumerable: true, configurable: true },
21290       _: { value: dispatch14 }
21291     });
21292   }
21293
21294   // node_modules/d3-zoom/src/transform.js
21295   function Transform(k2, x2, y2) {
21296     this.k = k2;
21297     this.x = x2;
21298     this.y = y2;
21299   }
21300   Transform.prototype = {
21301     constructor: Transform,
21302     scale: function(k2) {
21303       return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y);
21304     },
21305     translate: function(x2, y2) {
21306       return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2);
21307     },
21308     apply: function(point2) {
21309       return [point2[0] * this.k + this.x, point2[1] * this.k + this.y];
21310     },
21311     applyX: function(x2) {
21312       return x2 * this.k + this.x;
21313     },
21314     applyY: function(y2) {
21315       return y2 * this.k + this.y;
21316     },
21317     invert: function(location) {
21318       return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
21319     },
21320     invertX: function(x2) {
21321       return (x2 - this.x) / this.k;
21322     },
21323     invertY: function(y2) {
21324       return (y2 - this.y) / this.k;
21325     },
21326     rescaleX: function(x2) {
21327       return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2));
21328     },
21329     rescaleY: function(y2) {
21330       return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2));
21331     },
21332     toString: function() {
21333       return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
21334     }
21335   };
21336   var identity2 = new Transform(1, 0, 0);
21337   transform.prototype = Transform.prototype;
21338   function transform(node) {
21339     while (!node.__zoom)
21340       if (!(node = node.parentNode))
21341         return identity2;
21342     return node.__zoom;
21343   }
21344
21345   // node_modules/d3-zoom/src/noevent.js
21346   function nopropagation2(event) {
21347     event.stopImmediatePropagation();
21348   }
21349   function noevent_default2(event) {
21350     event.preventDefault();
21351     event.stopImmediatePropagation();
21352   }
21353
21354   // node_modules/d3-zoom/src/zoom.js
21355   function defaultFilter2(event) {
21356     return (!event.ctrlKey || event.type === "wheel") && !event.button;
21357   }
21358   function defaultExtent() {
21359     var e3 = this;
21360     if (e3 instanceof SVGElement) {
21361       e3 = e3.ownerSVGElement || e3;
21362       if (e3.hasAttribute("viewBox")) {
21363         e3 = e3.viewBox.baseVal;
21364         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
21365       }
21366       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
21367     }
21368     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
21369   }
21370   function defaultTransform() {
21371     return this.__zoom || identity2;
21372   }
21373   function defaultWheelDelta(event) {
21374     return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1);
21375   }
21376   function defaultTouchable2() {
21377     return navigator.maxTouchPoints || "ontouchstart" in this;
21378   }
21379   function defaultConstrain(transform2, extent, translateExtent) {
21380     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];
21381     return transform2.translate(
21382       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
21383       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
21384     );
21385   }
21386   function zoom_default2() {
21387     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;
21388     function zoom(selection2) {
21389       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)");
21390     }
21391     zoom.transform = function(collection, transform2, point2, event) {
21392       var selection2 = collection.selection ? collection.selection() : collection;
21393       selection2.property("__zoom", defaultTransform);
21394       if (collection !== selection2) {
21395         schedule(collection, transform2, point2, event);
21396       } else {
21397         selection2.interrupt().each(function() {
21398           gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end();
21399         });
21400       }
21401     };
21402     zoom.scaleBy = function(selection2, k2, p2, event) {
21403       zoom.scaleTo(selection2, function() {
21404         var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
21405         return k0 * k1;
21406       }, p2, event);
21407     };
21408     zoom.scaleTo = function(selection2, k2, p2, event) {
21409       zoom.transform(selection2, function() {
21410         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;
21411         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
21412       }, p2, event);
21413     };
21414     zoom.translateBy = function(selection2, x2, y2, event) {
21415       zoom.transform(selection2, function() {
21416         return constrain(this.__zoom.translate(
21417           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
21418           typeof y2 === "function" ? y2.apply(this, arguments) : y2
21419         ), extent.apply(this, arguments), translateExtent);
21420       }, null, event);
21421     };
21422     zoom.translateTo = function(selection2, x2, y2, p2, event) {
21423       zoom.transform(selection2, function() {
21424         var e3 = extent.apply(this, arguments), t2 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
21425         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
21426           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
21427           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
21428         ), e3, translateExtent);
21429       }, p2, event);
21430     };
21431     function scale(transform2, k2) {
21432       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
21433       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
21434     }
21435     function translate(transform2, p02, p1) {
21436       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
21437       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
21438     }
21439     function centroid(extent2) {
21440       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
21441     }
21442     function schedule(transition2, transform2, point2, event) {
21443       transition2.on("start.zoom", function() {
21444         gesture(this, arguments).event(event).start();
21445       }).on("interrupt.zoom end.zoom", function() {
21446         gesture(this, arguments).event(event).end();
21447       }).tween("zoom", function() {
21448         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));
21449         return function(t2) {
21450           if (t2 === 1)
21451             t2 = b2;
21452           else {
21453             var l2 = i3(t2), k2 = w2 / l2[2];
21454             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
21455           }
21456           g3.zoom(null, t2);
21457         };
21458       });
21459     }
21460     function gesture(that, args, clean2) {
21461       return !clean2 && that.__zooming || new Gesture(that, args);
21462     }
21463     function Gesture(that, args) {
21464       this.that = that;
21465       this.args = args;
21466       this.active = 0;
21467       this.sourceEvent = null;
21468       this.extent = extent.apply(that, args);
21469       this.taps = 0;
21470     }
21471     Gesture.prototype = {
21472       event: function(event) {
21473         if (event)
21474           this.sourceEvent = event;
21475         return this;
21476       },
21477       start: function() {
21478         if (++this.active === 1) {
21479           this.that.__zooming = this;
21480           this.emit("start");
21481         }
21482         return this;
21483       },
21484       zoom: function(key, transform2) {
21485         if (this.mouse && key !== "mouse")
21486           this.mouse[1] = transform2.invert(this.mouse[0]);
21487         if (this.touch0 && key !== "touch")
21488           this.touch0[1] = transform2.invert(this.touch0[0]);
21489         if (this.touch1 && key !== "touch")
21490           this.touch1[1] = transform2.invert(this.touch1[0]);
21491         this.that.__zoom = transform2;
21492         this.emit("zoom");
21493         return this;
21494       },
21495       end: function() {
21496         if (--this.active === 0) {
21497           delete this.that.__zooming;
21498           this.emit("end");
21499         }
21500         return this;
21501       },
21502       emit: function(type2) {
21503         var d2 = select_default2(this.that).datum();
21504         listeners.call(
21505           type2,
21506           this.that,
21507           new ZoomEvent(type2, {
21508             sourceEvent: this.sourceEvent,
21509             target: zoom,
21510             type: type2,
21511             transform: this.that.__zoom,
21512             dispatch: listeners
21513           }),
21514           d2
21515         );
21516       }
21517     };
21518     function wheeled(event, ...args) {
21519       if (!filter2.apply(this, arguments))
21520         return;
21521       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);
21522       if (g3.wheel) {
21523         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
21524           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
21525         }
21526         clearTimeout(g3.wheel);
21527       } else if (t2.k === k2)
21528         return;
21529       else {
21530         g3.mouse = [p2, t2.invert(p2)];
21531         interrupt_default(this);
21532         g3.start();
21533       }
21534       noevent_default2(event);
21535       g3.wheel = setTimeout(wheelidled, wheelDelay);
21536       g3.zoom("mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
21537       function wheelidled() {
21538         g3.wheel = null;
21539         g3.end();
21540       }
21541     }
21542     function mousedowned(event, ...args) {
21543       if (touchending || !filter2.apply(this, arguments))
21544         return;
21545       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;
21546       nodrag_default(event.view);
21547       nopropagation2(event);
21548       g3.mouse = [p2, this.__zoom.invert(p2)];
21549       interrupt_default(this);
21550       g3.start();
21551       function mousemoved(event2) {
21552         noevent_default2(event2);
21553         if (!g3.moved) {
21554           var dx = event2.clientX - x05, dy = event2.clientY - y05;
21555           g3.moved = dx * dx + dy * dy > clickDistance2;
21556         }
21557         g3.event(event2).zoom("mouse", constrain(translate(g3.that.__zoom, g3.mouse[0] = pointer_default(event2, currentTarget), g3.mouse[1]), g3.extent, translateExtent));
21558       }
21559       function mouseupped(event2) {
21560         v2.on("mousemove.zoom mouseup.zoom", null);
21561         yesdrag(event2.view, g3.moved);
21562         noevent_default2(event2);
21563         g3.event(event2).end();
21564       }
21565     }
21566     function dblclicked(event, ...args) {
21567       if (!filter2.apply(this, arguments))
21568         return;
21569       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);
21570       noevent_default2(event);
21571       if (duration > 0)
21572         select_default2(this).transition().duration(duration).call(schedule, t1, p02, event);
21573       else
21574         select_default2(this).call(zoom.transform, t1, p02, event);
21575     }
21576     function touchstarted(event, ...args) {
21577       if (!filter2.apply(this, arguments))
21578         return;
21579       var touches = event.touches, n3 = touches.length, g3 = gesture(this, args, event.changedTouches.length === n3).event(event), started, i3, t2, p2;
21580       nopropagation2(event);
21581       for (i3 = 0; i3 < n3; ++i3) {
21582         t2 = touches[i3], p2 = pointer_default(t2, this);
21583         p2 = [p2, this.__zoom.invert(p2), t2.identifier];
21584         if (!g3.touch0)
21585           g3.touch0 = p2, started = true, g3.taps = 1 + !!touchstarting;
21586         else if (!g3.touch1 && g3.touch0[2] !== p2[2])
21587           g3.touch1 = p2, g3.taps = 0;
21588       }
21589       if (touchstarting)
21590         touchstarting = clearTimeout(touchstarting);
21591       if (started) {
21592         if (g3.taps < 2)
21593           touchfirst = p2[0], touchstarting = setTimeout(function() {
21594             touchstarting = null;
21595           }, touchDelay);
21596         interrupt_default(this);
21597         g3.start();
21598       }
21599     }
21600     function touchmoved(event, ...args) {
21601       if (!this.__zooming)
21602         return;
21603       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2, p2, l2;
21604       noevent_default2(event);
21605       for (i3 = 0; i3 < n3; ++i3) {
21606         t2 = touches[i3], p2 = pointer_default(t2, this);
21607         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21608           g3.touch0[0] = p2;
21609         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21610           g3.touch1[0] = p2;
21611       }
21612       t2 = g3.that.__zoom;
21613       if (g3.touch1) {
21614         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;
21615         t2 = scale(t2, Math.sqrt(dp / dl));
21616         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
21617         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
21618       } else if (g3.touch0)
21619         p2 = g3.touch0[0], l2 = g3.touch0[1];
21620       else
21621         return;
21622       g3.zoom("touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
21623     }
21624     function touchended(event, ...args) {
21625       if (!this.__zooming)
21626         return;
21627       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2;
21628       nopropagation2(event);
21629       if (touchending)
21630         clearTimeout(touchending);
21631       touchending = setTimeout(function() {
21632         touchending = null;
21633       }, touchDelay);
21634       for (i3 = 0; i3 < n3; ++i3) {
21635         t2 = touches[i3];
21636         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21637           delete g3.touch0;
21638         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21639           delete g3.touch1;
21640       }
21641       if (g3.touch1 && !g3.touch0)
21642         g3.touch0 = g3.touch1, delete g3.touch1;
21643       if (g3.touch0)
21644         g3.touch0[1] = this.__zoom.invert(g3.touch0[0]);
21645       else {
21646         g3.end();
21647         if (g3.taps === 2) {
21648           t2 = pointer_default(t2, this);
21649           if (Math.hypot(touchfirst[0] - t2[0], touchfirst[1] - t2[1]) < tapDistance) {
21650             var p2 = select_default2(this).on("dblclick.zoom");
21651             if (p2)
21652               p2.apply(this, arguments);
21653           }
21654         }
21655       }
21656     }
21657     zoom.wheelDelta = function(_2) {
21658       return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant_default4(+_2), zoom) : wheelDelta;
21659     };
21660     zoom.filter = function(_2) {
21661       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : filter2;
21662     };
21663     zoom.touchable = function(_2) {
21664       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : touchable;
21665     };
21666     zoom.extent = function(_2) {
21667       return arguments.length ? (extent = typeof _2 === "function" ? _2 : constant_default4([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
21668     };
21669     zoom.scaleExtent = function(_2) {
21670       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
21671     };
21672     zoom.translateExtent = function(_2) {
21673       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]]];
21674     };
21675     zoom.constrain = function(_2) {
21676       return arguments.length ? (constrain = _2, zoom) : constrain;
21677     };
21678     zoom.duration = function(_2) {
21679       return arguments.length ? (duration = +_2, zoom) : duration;
21680     };
21681     zoom.interpolate = function(_2) {
21682       return arguments.length ? (interpolate = _2, zoom) : interpolate;
21683     };
21684     zoom.on = function() {
21685       var value = listeners.on.apply(listeners, arguments);
21686       return value === listeners ? zoom : value;
21687     };
21688     zoom.clickDistance = function(_2) {
21689       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom) : Math.sqrt(clickDistance2);
21690     };
21691     zoom.tapDistance = function(_2) {
21692       return arguments.length ? (tapDistance = +_2, zoom) : tapDistance;
21693     };
21694     return zoom;
21695   }
21696
21697   // modules/geo/raw_mercator.js
21698   function geoRawMercator() {
21699     var project = mercatorRaw;
21700     var k2 = 512 / Math.PI;
21701     var x2 = 0;
21702     var y2 = 0;
21703     var clipExtent = [[0, 0], [0, 0]];
21704     function projection2(point2) {
21705       point2 = project(point2[0] * Math.PI / 180, point2[1] * Math.PI / 180);
21706       return [point2[0] * k2 + x2, y2 - point2[1] * k2];
21707     }
21708     projection2.invert = function(point2) {
21709       point2 = project.invert((point2[0] - x2) / k2, (y2 - point2[1]) / k2);
21710       return point2 && [point2[0] * 180 / Math.PI, point2[1] * 180 / Math.PI];
21711     };
21712     projection2.scale = function(_2) {
21713       if (!arguments.length)
21714         return k2;
21715       k2 = +_2;
21716       return projection2;
21717     };
21718     projection2.translate = function(_2) {
21719       if (!arguments.length)
21720         return [x2, y2];
21721       x2 = +_2[0];
21722       y2 = +_2[1];
21723       return projection2;
21724     };
21725     projection2.clipExtent = function(_2) {
21726       if (!arguments.length)
21727         return clipExtent;
21728       clipExtent = _2;
21729       return projection2;
21730     };
21731     projection2.transform = function(obj) {
21732       if (!arguments.length)
21733         return identity2.translate(x2, y2).scale(k2);
21734       x2 = +obj.x;
21735       y2 = +obj.y;
21736       k2 = +obj.k;
21737       return projection2;
21738     };
21739     projection2.stream = transform_default({
21740       point: function(x3, y3) {
21741         var vec = projection2([x3, y3]);
21742         this.stream.point(vec[0], vec[1]);
21743       }
21744     }).stream;
21745     return projection2;
21746   }
21747
21748   // modules/geo/ortho.js
21749   function geoOrthoNormalizedDotProduct(a2, b2, origin) {
21750     if (geoVecEqual(origin, a2) || geoVecEqual(origin, b2)) {
21751       return 1;
21752     }
21753     return geoVecNormalizedDot(a2, b2, origin);
21754   }
21755   function geoOrthoFilterDotProduct(dotp, epsilon3, lowerThreshold, upperThreshold, allowStraightAngles) {
21756     var val = Math.abs(dotp);
21757     if (val < epsilon3) {
21758       return 0;
21759     } else if (allowStraightAngles && Math.abs(val - 1) < epsilon3) {
21760       return 0;
21761     } else if (val < lowerThreshold || val > upperThreshold) {
21762       return dotp;
21763     } else {
21764       return null;
21765     }
21766   }
21767   function geoOrthoCalcScore(points, isClosed, epsilon3, threshold) {
21768     var score = 0;
21769     var first = isClosed ? 0 : 1;
21770     var last = isClosed ? points.length : points.length - 1;
21771     var coords = points.map(function(p2) {
21772       return p2.coord;
21773     });
21774     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
21775     var upperThreshold = Math.cos(threshold * Math.PI / 180);
21776     for (var i3 = first; i3 < last; i3++) {
21777       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
21778       var origin = coords[i3];
21779       var b2 = coords[(i3 + 1) % coords.length];
21780       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold);
21781       if (dotp === null)
21782         continue;
21783       score = score + 2 * Math.min(Math.abs(dotp - 1), Math.min(Math.abs(dotp), Math.abs(dotp + 1)));
21784     }
21785     return score;
21786   }
21787   function geoOrthoMaxOffsetAngle(coords, isClosed, lessThan) {
21788     var max3 = -Infinity;
21789     var first = isClosed ? 0 : 1;
21790     var last = isClosed ? coords.length : coords.length - 1;
21791     for (var i3 = first; i3 < last; i3++) {
21792       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
21793       var origin = coords[i3];
21794       var b2 = coords[(i3 + 1) % coords.length];
21795       var normalizedDotP = geoOrthoNormalizedDotProduct(a2, b2, origin);
21796       var angle2 = Math.acos(Math.abs(normalizedDotP)) * 180 / Math.PI;
21797       if (angle2 > 45)
21798         angle2 = 90 - angle2;
21799       if (angle2 >= lessThan)
21800         continue;
21801       if (angle2 > max3)
21802         max3 = angle2;
21803     }
21804     if (max3 === -Infinity)
21805       return null;
21806     return max3;
21807   }
21808   function geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles) {
21809     var score = null;
21810     var first = isClosed ? 0 : 1;
21811     var last = isClosed ? coords.length : coords.length - 1;
21812     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
21813     var upperThreshold = Math.cos(threshold * Math.PI / 180);
21814     for (var i3 = first; i3 < last; i3++) {
21815       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
21816       var origin = coords[i3];
21817       var b2 = coords[(i3 + 1) % coords.length];
21818       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold, allowStraightAngles);
21819       if (dotp === null)
21820         continue;
21821       if (Math.abs(dotp) > 0)
21822         return 1;
21823       score = 0;
21824     }
21825     return score;
21826   }
21827
21828   // modules/osm/tags.js
21829   function osmIsInterestingTag(key) {
21830     return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
21831     key.indexOf("tiger:") !== 0;
21832   }
21833   var osmLifecyclePrefixes = {
21834     // nonexistent, might be built
21835     proposed: true,
21836     planned: true,
21837     // under maintentance or between groundbreaking and opening
21838     construction: true,
21839     // existent but not functional
21840     disused: true,
21841     // dilapidated to nonexistent
21842     abandoned: true,
21843     was: true,
21844     // nonexistent, still may appear in imagery
21845     dismantled: true,
21846     razed: true,
21847     demolished: true,
21848     destroyed: true,
21849     removed: true,
21850     obliterated: true,
21851     // existent occasionally, e.g. stormwater drainage basin
21852     intermittent: true
21853   };
21854   function osmRemoveLifecyclePrefix(key) {
21855     const keySegments = key.split(":");
21856     if (keySegments.length === 1)
21857       return key;
21858     if (keySegments[0] in osmLifecyclePrefixes) {
21859       return key.slice(keySegments[0].length + 1);
21860     }
21861     return key;
21862   }
21863   var osmAreaKeys = {};
21864   function osmSetAreaKeys(value) {
21865     osmAreaKeys = value;
21866   }
21867   var osmAreaKeysExceptions = {
21868     highway: {
21869       elevator: true,
21870       rest_area: true,
21871       services: true
21872     },
21873     public_transport: {
21874       platform: true
21875     },
21876     railway: {
21877       platform: true,
21878       roundhouse: true,
21879       station: true,
21880       traverser: true,
21881       turntable: true,
21882       wash: true
21883     },
21884     waterway: {
21885       dam: true
21886     },
21887     amenity: {
21888       bicycle_parking: true
21889     }
21890   };
21891   function osmTagSuggestingArea(tags) {
21892     if (tags.area === "yes")
21893       return { area: "yes" };
21894     if (tags.area === "no")
21895       return null;
21896     var returnTags = {};
21897     for (var realKey in tags) {
21898       const key = osmRemoveLifecyclePrefix(realKey);
21899       if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
21900         returnTags[realKey] = tags[realKey];
21901         return returnTags;
21902       }
21903       if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
21904         returnTags[realKey] = tags[realKey];
21905         return returnTags;
21906       }
21907     }
21908     return null;
21909   }
21910   var osmLineTags = {};
21911   function osmSetLineTags(value) {
21912     osmLineTags = value;
21913   }
21914   var osmPointTags = {};
21915   function osmSetPointTags(value) {
21916     osmPointTags = value;
21917   }
21918   var osmVertexTags = {};
21919   function osmSetVertexTags(value) {
21920     osmVertexTags = value;
21921   }
21922   function osmNodeGeometriesForTags(nodeTags) {
21923     var geometries = {};
21924     for (var key in nodeTags) {
21925       if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
21926         geometries.point = true;
21927       }
21928       if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
21929         geometries.vertex = true;
21930       }
21931       if (geometries.point && geometries.vertex)
21932         break;
21933     }
21934     return geometries;
21935   }
21936   var osmOneWayTags = {
21937     "aerialway": {
21938       "chair_lift": true,
21939       "drag_lift": true,
21940       "j-bar": true,
21941       "magic_carpet": true,
21942       "mixed_lift": true,
21943       "platter": true,
21944       "rope_tow": true,
21945       "t-bar": true,
21946       "zip_line": true
21947     },
21948     "highway": {
21949       "motorway": true
21950     },
21951     "junction": {
21952       "circular": true,
21953       "roundabout": true
21954     },
21955     "man_made": {
21956       "goods_conveyor": true,
21957       "piste:halfpipe": true
21958     },
21959     "piste:type": {
21960       "downhill": true,
21961       "sled": true,
21962       "yes": true
21963     },
21964     "seamark:type": {
21965       "two-way_route": true,
21966       "recommended_traffic_lane": true,
21967       "separation_lane": true,
21968       "separation_roundabout": true
21969     },
21970     "waterway": {
21971       "canal": true,
21972       "ditch": true,
21973       "drain": true,
21974       "fish_pass": true,
21975       "pressurised": true,
21976       "river": true,
21977       "spillway": true,
21978       "stream": true,
21979       "tidal_channel": true
21980     }
21981   };
21982   var osmPavedTags = {
21983     "surface": {
21984       "paved": true,
21985       "asphalt": true,
21986       "concrete": true,
21987       "chipseal": true,
21988       "concrete:lanes": true,
21989       "concrete:plates": true
21990     },
21991     "tracktype": {
21992       "grade1": true
21993     }
21994   };
21995   var osmSemipavedTags = {
21996     "surface": {
21997       "cobblestone": true,
21998       "cobblestone:flattened": true,
21999       "unhewn_cobblestone": true,
22000       "sett": true,
22001       "paving_stones": true,
22002       "metal": true,
22003       "wood": true
22004     }
22005   };
22006   var osmRightSideIsInsideTags = {
22007     "natural": {
22008       "cliff": true,
22009       "coastline": "coastline"
22010     },
22011     "barrier": {
22012       "retaining_wall": true,
22013       "kerb": true,
22014       "guard_rail": true,
22015       "city_wall": true
22016     },
22017     "man_made": {
22018       "embankment": true,
22019       "quay": true
22020     },
22021     "waterway": {
22022       "weir": true
22023     }
22024   };
22025   var osmRoutableHighwayTagValues = {
22026     motorway: true,
22027     trunk: true,
22028     primary: true,
22029     secondary: true,
22030     tertiary: true,
22031     residential: true,
22032     motorway_link: true,
22033     trunk_link: true,
22034     primary_link: true,
22035     secondary_link: true,
22036     tertiary_link: true,
22037     unclassified: true,
22038     road: true,
22039     service: true,
22040     track: true,
22041     living_street: true,
22042     bus_guideway: true,
22043     busway: true,
22044     path: true,
22045     footway: true,
22046     cycleway: true,
22047     bridleway: true,
22048     pedestrian: true,
22049     corridor: true,
22050     steps: true
22051   };
22052   var osmPathHighwayTagValues = {
22053     path: true,
22054     footway: true,
22055     cycleway: true,
22056     bridleway: true,
22057     pedestrian: true,
22058     corridor: true,
22059     steps: true
22060   };
22061   var osmRailwayTrackTagValues = {
22062     rail: true,
22063     light_rail: true,
22064     tram: true,
22065     subway: true,
22066     monorail: true,
22067     funicular: true,
22068     miniature: true,
22069     narrow_gauge: true,
22070     disused: true,
22071     preserved: true
22072   };
22073   var osmFlowingWaterwayTagValues = {
22074     canal: true,
22075     ditch: true,
22076     drain: true,
22077     fish_pass: true,
22078     river: true,
22079     stream: true,
22080     tidal_channel: true
22081   };
22082   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/;
22083   function isColourValid(value) {
22084     if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
22085       return false;
22086     }
22087     if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
22088       return false;
22089     }
22090     return true;
22091   }
22092   var osmMutuallyExclusiveTagPairs = [
22093     ["noname", "name"],
22094     ["noref", "ref"],
22095     ["nohousenumber", "addr:housenumber"],
22096     ["noaddress", "addr:housenumber"],
22097     ["noaddress", "addr:housename"],
22098     ["noaddress", "addr:unit"],
22099     ["addr:nostreet", "addr:street"]
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 {
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 {
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.29.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 -c config/eslint.config.mjs",
22326       "lint:fix": "eslint scripts test/spec modules -c config/eslint.config.mjs --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.37.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.2",
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.2",
22365       "@fortawesome/free-brands-svg-icons": "~6.5.2",
22366       "@fortawesome/free-regular-svg-icons": "~6.5.2",
22367       "@fortawesome/free-solid-svg-icons": "~6.5.2",
22368       "@mapbox/maki": "^8.0.1",
22369       "@openstreetmap/id-tagging-schema": "^6.7.3",
22370       "@rapideditor/mapillary_sprite_source": "^1.8.0",
22371       "@rapideditor/temaki": "^5.8.0",
22372       "@transifex/api": "^7.1.0",
22373       autoprefixer: "^10.4.19",
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": "^45.0.0",
22379       "cldr-localenames-full": "^45.0.0",
22380       "concat-files": "^0.1.1",
22381       d3: "~7.9.0",
22382       dotenv: "^16.4.5",
22383       "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
22384       esbuild: "^0.20.2",
22385       "esbuild-visualizer": "^0.6.0",
22386       eslint: "^9.1.1",
22387       "fetch-mock": "^9.11.0",
22388       gaze: "^1.1.3",
22389       glob: "^10.3.12",
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.4.0",
22401       "name-suggestion-index": "~6.0",
22402       "npm-run-all": "^4.0.0",
22403       "osm-community-index": "~5.6.2",
22404       postcss: "^8.4.38",
22405       "postcss-selector-prepend": "^0.5.0",
22406       shelljs: "^0.8.0",
22407       shx: "^0.3.0",
22408       sinon: "^11.1.2",
22409       "sinon-chai": "^3.7.0",
22410       smash: "0.0",
22411       "static-server": "^2.2.1",
22412       "svg-sprite": "2.0.4",
22413       vparse: "~1.1.0"
22414     },
22415     engines: {
22416       node: ">=18"
22417     },
22418     browserslist: [
22419       "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions"
22420     ]
22421   };
22422
22423   // modules/core/file_fetcher.js
22424   var _mainFileFetcher = coreFileFetcher();
22425   function coreFileFetcher() {
22426     const ociVersion = package_default.dependencies["osm-community-index"] || package_default.devDependencies["osm-community-index"];
22427     const v2 = (0, import_vparse.default)(ociVersion);
22428     const ociVersionMinor = "".concat(v2.major, ".").concat(v2.minor);
22429     const presetsVersion = package_default.devDependencies["@openstreetmap/id-tagging-schema"];
22430     let _this = {};
22431     let _inflight4 = {};
22432     let _fileMap = {
22433       "address_formats": "data/address_formats.min.json",
22434       "imagery": "data/imagery.min.json",
22435       "intro_graph": "data/intro_graph.min.json",
22436       "keepRight": "data/keepRight.min.json",
22437       "languages": "data/languages.min.json",
22438       "locales": "locales/index.min.json",
22439       "phone_formats": "data/phone_formats.min.json",
22440       "qa_data": "data/qa_data.min.json",
22441       "shortcuts": "data/shortcuts.min.json",
22442       "territory_languages": "data/territory_languages.min.json",
22443       "oci_defaults": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/defaults.min.json",
22444       "oci_features": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/featureCollection.min.json",
22445       "oci_resources": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/resources.min.json",
22446       "presets_package": presetsCdnUrl.replace("{presets_version}", presetsVersion) + "package.json",
22447       "deprecated": presetsCdnUrl + "dist/deprecated.min.json",
22448       "discarded": presetsCdnUrl + "dist/discarded.min.json",
22449       "preset_categories": presetsCdnUrl + "dist/preset_categories.min.json",
22450       "preset_defaults": presetsCdnUrl + "dist/preset_defaults.min.json",
22451       "preset_fields": presetsCdnUrl + "dist/fields.min.json",
22452       "preset_presets": presetsCdnUrl + "dist/presets.min.json",
22453       "wmf_sitematrix": wmfSitematrixCdnUrl.replace("{version}", "0.1") + "wikipedia.min.json"
22454     };
22455     let _cachedData = {};
22456     _this.cache = () => _cachedData;
22457     _this.get = (which) => {
22458       if (_cachedData[which]) {
22459         return Promise.resolve(_cachedData[which]);
22460       }
22461       const file = _fileMap[which];
22462       const url = file && _this.asset(file);
22463       if (!url) {
22464         return Promise.reject('Unknown data file for "'.concat(which, '"'));
22465       }
22466       if (url.includes("{presets_version}")) {
22467         return _this.get("presets_package").then((result) => {
22468           const presetsVersion2 = result.version;
22469           return getUrl(url.replace("{presets_version}", presetsVersion2), which);
22470         });
22471       } else {
22472         return getUrl(url);
22473       }
22474     };
22475     function getUrl(url, which) {
22476       let prom = _inflight4[url];
22477       if (!prom) {
22478         _inflight4[url] = prom = fetch(url).then((response) => {
22479           if (!response.ok || !response.json) {
22480             throw new Error(response.status + " " + response.statusText);
22481           }
22482           if (response.status === 204 || response.status === 205)
22483             return;
22484           return response.json();
22485         }).then((result) => {
22486           delete _inflight4[url];
22487           if (!result) {
22488             throw new Error('No data loaded for "'.concat(which, '"'));
22489           }
22490           _cachedData[which] = result;
22491           return result;
22492         }).catch((err) => {
22493           delete _inflight4[url];
22494           throw err;
22495         });
22496       }
22497       return prom;
22498     }
22499     _this.fileMap = function(val) {
22500       if (!arguments.length)
22501         return _fileMap;
22502       _fileMap = val;
22503       return _this;
22504     };
22505     let _assetPath = "";
22506     _this.assetPath = function(val) {
22507       if (!arguments.length)
22508         return _assetPath;
22509       _assetPath = val;
22510       return _this;
22511     };
22512     let _assetMap = {};
22513     _this.assetMap = function(val) {
22514       if (!arguments.length)
22515         return _assetMap;
22516       _assetMap = val;
22517       return _this;
22518     };
22519     _this.asset = (val) => {
22520       if (/^http(s)?:\/\//i.test(val))
22521         return val;
22522       const filename = _assetPath + val;
22523       return _assetMap[filename] || filename;
22524     };
22525     return _this;
22526   }
22527
22528   // node_modules/@rapideditor/country-coder/dist/country-coder.mjs
22529   var import_which_polygon = __toESM(require_which_polygon(), 1);
22530   var borders_default = { type: "FeatureCollection", features: [
22531     { 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]]]] } },
22532     { 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]]]] } },
22533     { 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]]]] } },
22534     { 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]]]] } },
22535     { 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]]]] } },
22536     { 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]]]] } },
22537     { 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]]]] } },
22538     { 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]]]] } },
22539     { 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]]]] } },
22540     { 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]]]] } },
22541     { 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]]]] } },
22542     { 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]]]] } },
22543     { 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]]]] } },
22544     { 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]]]] } },
22545     { 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]]]] } },
22546     { 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]]]] } },
22547     { 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]]]] } },
22548     { 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]]]] } },
22549     { 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]]]] } },
22550     { type: "Feature", properties: { wikidata: "Q12837", nameEn: "Iberia", level: "sharedLandform" }, geometry: null },
22551     { 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]]]] } },
22552     { 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]]]] } },
22553     { type: "Feature", properties: { wikidata: "Q22890", nameEn: "Ireland", level: "sharedLandform" }, geometry: null },
22554     { type: "Feature", properties: { wikidata: "Q23666", nameEn: "Great Britain", country: "GB", level: "sharedLandform" }, geometry: null },
22555     { 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]]]] } },
22556     { 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]]]] } },
22557     { 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]]]] } },
22558     { 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]]]] } },
22559     { 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]]]] } },
22560     { 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]]]] } },
22561     { 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]]]] } },
22562     { 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]]]] } },
22563     { 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]]]] } },
22564     { 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]]]] } },
22565     { 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]]]] } },
22566     { 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]]]] } },
22567     { type: "Feature", properties: { wikidata: "Q35657", nameEn: "US States", country: "US", level: "subcountryGroup" }, geometry: null },
22568     { type: "Feature", properties: { wikidata: "Q36117", nameEn: "Borneo", level: "sharedLandform" }, geometry: null },
22569     { 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]]]] } },
22570     { type: "Feature", properties: { wikidata: "Q37362", nameEn: "Akrotiri and Dhekelia", aliases: ["SBA"], country: "GB" }, geometry: null },
22571     { 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]]]] } },
22572     { 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]]]] } },
22573     { 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]]]] } },
22574     { 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]]]] } },
22575     { 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]]]] } },
22576     { 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]]]] } },
22577     { type: "Feature", properties: { wikidata: "Q46395", nameEn: "British Overseas Territories", aliases: ["BOTS", "UKOTS"], country: "GB", level: "subcountryGroup" }, geometry: null },
22578     { 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]]]] } },
22579     { 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]]]] } },
22580     { 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]]]] } },
22581     { 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]]]] } },
22582     { type: "Feature", properties: { wikidata: "Q105472", nameEn: "Macaronesia", level: "sharedLandform" }, geometry: null },
22583     { 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]]]] } },
22584     { 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]]]] } },
22585     { 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]]]] } },
22586     { 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]]]] } },
22587     { 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]]]] } },
22588     { 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]]]] } },
22589     { 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]]]] } },
22590     { 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]]]] } },
22591     { 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]]]] } },
22592     { 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]]]] } },
22593     { type: "Feature", properties: { wikidata: "Q153732", nameEn: "Mariana Islands", level: "sharedLandform" }, geometry: null },
22594     { 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]]]] } },
22595     { 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]]]] } },
22596     { type: "Feature", properties: { wikidata: "Q185086", nameEn: "Crown Dependencies", country: "GB", level: "subcountryGroup" }, geometry: null },
22597     { 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]]]] } },
22598     { type: "Feature", properties: { wikidata: "Q191011", nameEn: "Plazas de soberan\xEDa", country: "ES" }, geometry: null },
22599     { 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]]]] } },
22600     { 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]]]] } },
22601     { 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]]]] } },
22602     { 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]]]] } },
22603     { 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]]]] } },
22604     { type: "Feature", properties: { wikidata: "Q644636", nameEn: "Cyprus", level: "sharedLandform" }, geometry: null },
22605     { type: "Feature", properties: { wikidata: "Q851132", nameEn: "New Zealand Outlying Islands", country: "NZ", level: "subcountryGroup" }, geometry: null },
22606     { 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]]]] } },
22607     { 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]]]] } },
22608     { 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]]]] } },
22609     { 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]]]] } },
22610     { type: "Feature", properties: { wikidata: "Q1352230", nameEn: "US Territories", country: "US", level: "subcountryGroup" }, geometry: null },
22611     { type: "Feature", properties: { wikidata: "Q1451600", nameEn: "Overseas Countries and Territories of the EU", aliases: ["OCT"], level: "subunion" }, geometry: null },
22612     { 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]]]] } },
22613     { 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]]]] } },
22614     { 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]]]] } },
22615     { 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]]]] } },
22616     { 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]]]] } },
22617     { 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]]]] } },
22618     { 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]]]] } },
22619     { 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]]]] } },
22620     { type: "Feature", properties: { wikidata: "Q2914565", nameEn: "Autonomous Regions of Portugal", country: "PT", level: "subcountryGroup" }, geometry: null },
22621     { 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]]]] } },
22622     { 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]]]] } },
22623     { type: "Feature", properties: { wikidata: "Q3320166", nameEn: "Outermost Regions of the EU", aliases: ["OMR"], level: "subunion" }, geometry: null },
22624     { type: "Feature", properties: { wikidata: "Q3336843", nameEn: "Countries of the United Kingdom", aliases: ["GB-UKM"], country: "GB", level: "subcountryGroup" }, geometry: null },
22625     { 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]]]] } },
22626     { 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]]]] } },
22627     { 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]]]] } },
22628     { 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]]]] } },
22629     { 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]]]] } },
22630     { 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]]]] } },
22631     { type: "Feature", properties: { m49: "001", wikidata: "Q2", nameEn: "World", aliases: ["Earth", "Planet"], level: "world" }, geometry: null },
22632     { type: "Feature", properties: { m49: "002", wikidata: "Q15", nameEn: "Africa", level: "region" }, geometry: null },
22633     { type: "Feature", properties: { m49: "003", wikidata: "Q49", nameEn: "North America", level: "subregion" }, geometry: null },
22634     { type: "Feature", properties: { m49: "005", wikidata: "Q18", nameEn: "South America", level: "intermediateRegion" }, geometry: null },
22635     { type: "Feature", properties: { m49: "009", wikidata: "Q538", nameEn: "Oceania", level: "region" }, geometry: null },
22636     { type: "Feature", properties: { m49: "011", wikidata: "Q4412", nameEn: "Western Africa", level: "intermediateRegion" }, geometry: null },
22637     { type: "Feature", properties: { m49: "013", wikidata: "Q27611", nameEn: "Central America", level: "intermediateRegion" }, geometry: null },
22638     { type: "Feature", properties: { m49: "014", wikidata: "Q27407", nameEn: "Eastern Africa", level: "intermediateRegion" }, geometry: null },
22639     { type: "Feature", properties: { m49: "015", wikidata: "Q27381", nameEn: "Northern Africa", level: "subregion" }, geometry: null },
22640     { type: "Feature", properties: { m49: "017", wikidata: "Q27433", nameEn: "Middle Africa", level: "intermediateRegion" }, geometry: null },
22641     { type: "Feature", properties: { m49: "018", wikidata: "Q27394", nameEn: "Southern Africa", level: "intermediateRegion" }, geometry: null },
22642     { type: "Feature", properties: { m49: "019", wikidata: "Q828", nameEn: "Americas", level: "region" }, geometry: null },
22643     { type: "Feature", properties: { m49: "021", wikidata: "Q2017699", nameEn: "Northern America", level: "subregion" }, geometry: null },
22644     { type: "Feature", properties: { m49: "029", wikidata: "Q664609", nameEn: "Caribbean", level: "intermediateRegion" }, geometry: null },
22645     { type: "Feature", properties: { m49: "030", wikidata: "Q27231", nameEn: "Eastern Asia", level: "subregion" }, geometry: null },
22646     { type: "Feature", properties: { m49: "034", wikidata: "Q771405", nameEn: "Southern Asia", level: "subregion" }, geometry: null },
22647     { type: "Feature", properties: { m49: "035", wikidata: "Q11708", nameEn: "South-eastern Asia", level: "subregion" }, geometry: null },
22648     { type: "Feature", properties: { m49: "039", wikidata: "Q27449", nameEn: "Southern Europe", level: "subregion" }, geometry: null },
22649     { type: "Feature", properties: { m49: "053", wikidata: "Q45256", nameEn: "Australia and New Zealand", aliases: ["Australasia"], level: "subregion" }, geometry: null },
22650     { type: "Feature", properties: { m49: "054", wikidata: "Q37394", nameEn: "Melanesia", level: "subregion" }, geometry: null },
22651     { type: "Feature", properties: { m49: "057", wikidata: "Q3359409", nameEn: "Micronesia", level: "subregion" }, geometry: null },
22652     { type: "Feature", properties: { m49: "061", wikidata: "Q35942", nameEn: "Polynesia", level: "subregion" }, geometry: null },
22653     { type: "Feature", properties: { m49: "142", wikidata: "Q48", nameEn: "Asia", level: "region" }, geometry: null },
22654     { type: "Feature", properties: { m49: "143", wikidata: "Q27275", nameEn: "Central Asia", level: "subregion" }, geometry: null },
22655     { type: "Feature", properties: { m49: "145", wikidata: "Q27293", nameEn: "Western Asia", level: "subregion" }, geometry: null },
22656     { type: "Feature", properties: { m49: "150", wikidata: "Q46", nameEn: "Europe", level: "region" }, geometry: null },
22657     { type: "Feature", properties: { m49: "151", wikidata: "Q27468", nameEn: "Eastern Europe", level: "subregion" }, geometry: null },
22658     { type: "Feature", properties: { m49: "154", wikidata: "Q27479", nameEn: "Northern Europe", level: "subregion" }, geometry: null },
22659     { type: "Feature", properties: { m49: "155", wikidata: "Q27496", nameEn: "Western Europe", level: "subregion" }, geometry: null },
22660     { type: "Feature", properties: { m49: "202", wikidata: "Q132959", nameEn: "Sub-Saharan Africa", level: "subregion" }, geometry: null },
22661     { type: "Feature", properties: { m49: "419", wikidata: "Q72829598", nameEn: "Latin America and the Caribbean", level: "subregion" }, geometry: null },
22662     { 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]]]] } },
22663     { type: "Feature", properties: { m49: "830", wikidata: "Q42314", nameEn: "Channel Islands", level: "intermediateRegion" }, geometry: null },
22664     { 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]]]] } },
22665     { 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]]]] } },
22666     { 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]]]] } },
22667     { 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]]]] } },
22668     { 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]]]] } },
22669     { 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]]]] } },
22670     { 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]]]] } },
22671     { 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]]]] } },
22672     { 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]]]] } },
22673     { 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]]]] } },
22674     { 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]]]] } },
22675     { 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]]]] } },
22676     { 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]]]] } },
22677     { type: "Feature", properties: { iso1A2: "AU", iso1A3: "AUS", iso1N3: "036", wikidata: "Q408", nameEn: "Australia" }, geometry: null },
22678     { 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]]]] } },
22679     { 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]]]] } },
22680     { 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]]]] } },
22681     { 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]]]] } },
22682     { 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]]]] } },
22683     { 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]]]] } },
22684     { 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]]]] } },
22685     { 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]]]] } },
22686     { 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]]]] } },
22687     { 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]]]] } },
22688     { 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]]]] } },
22689     { 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]]]] } },
22690     { 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]]]] } },
22691     { 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]]]] } },
22692     { 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]]]] } },
22693     { 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]]]] } },
22694     { type: "Feature", properties: { iso1A2: "BQ", iso1A3: "BES", iso1N3: "535", wikidata: "Q27561", nameEn: "Caribbean Netherlands", country: "NL" }, geometry: null },
22695     { 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]]]] } },
22696     { 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]]]] } },
22697     { 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]]]] } },
22698     { 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]]]] } },
22699     { 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]]]] } },
22700     { 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]]]] } },
22701     { 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]]]] } },
22702     { 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]]]] } },
22703     { 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]]]] } },
22704     { 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]]]] } },
22705     { 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]]]] } },
22706     { 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]]]] } },
22707     { 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"] } },
22708     { 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]]]] } },
22709     { 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]]]] } },
22710     { 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]]]] } },
22711     { 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]]]] } },
22712     { type: "Feature", properties: { iso1A2: "CN", iso1A3: "CHN", iso1N3: "156", wikidata: "Q148", nameEn: "People's Republic of China" }, geometry: null },
22713     { 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]]]] } },
22714     { 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]]]] } },
22715     { 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]]]] } },
22716     { 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]]]] } },
22717     { 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]]]] } },
22718     { 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]]]] } },
22719     { 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]]]] } },
22720     { 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]]]] } },
22721     { 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]]]] } },
22722     { 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]]]] } },
22723     { 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]]]] } },
22724     { 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]]]] } },
22725     { type: "Feature", properties: { iso1A2: "DK", iso1A3: "DNK", iso1N3: "208", wikidata: "Q756617", nameEn: "Kingdom of Denmark" }, geometry: null },
22726     { 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]]]] } },
22727     { 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]]]] } },
22728     { 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]]]] } },
22729     { type: "Feature", properties: { iso1A2: "EA", wikidata: "Q28868874", nameEn: "Ceuta, Melilla", country: "ES", level: "territory", isoStatus: "excRes" }, geometry: null },
22730     { type: "Feature", properties: { iso1A2: "EC", iso1A3: "ECU", iso1N3: "218", wikidata: "Q736", nameEn: "Ecuador" }, geometry: null },
22731     { 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]]]] } },
22732     { 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]]]] } },
22733     { 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]]]] } },
22734     { 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]]]] } },
22735     { type: "Feature", properties: { iso1A2: "ES", iso1A3: "ESP", iso1N3: "724", wikidata: "Q29", nameEn: "Spain" }, geometry: null },
22736     { 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]]]] } },
22737     { type: "Feature", properties: { iso1A2: "EU", iso1A3: "EUE", wikidata: "Q458", nameEn: "European Union", level: "union", isoStatus: "excRes" }, geometry: null },
22738     { type: "Feature", properties: { iso1A2: "FI", iso1A3: "FIN", iso1N3: "246", wikidata: "Q33", nameEn: "Finland", aliases: ["SF"] }, geometry: null },
22739     { 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]]]] } },
22740     { 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]]]] } },
22741     { 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]]]] } },
22742     { 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]]]] } },
22743     { type: "Feature", properties: { iso1A2: "FR", iso1A3: "FRA", iso1N3: "250", wikidata: "Q142", nameEn: "France" }, geometry: null },
22744     { 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]]]] } },
22745     { 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]]]] } },
22746     { type: "Feature", properties: { iso1A2: "GB", iso1A3: "GBR", iso1N3: "826", wikidata: "Q145", ccTLD: ".uk", nameEn: "United Kingdom", aliases: ["UK"] }, geometry: null },
22747     { 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]]]] } },
22748     { 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]]]] } },
22749     { 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]]]] } },
22750     { type: "Feature", properties: { iso1A2: "GG", iso1A3: "GGY", iso1N3: "831", wikidata: "Q25230", nameEn: "Bailiwick of Guernsey", country: "GB" }, geometry: null },
22751     { 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]]]] } },
22752     { 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]]]] } },
22753     { 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]]]] } },
22754     { 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]]]] } },
22755     { 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]]]] } },
22756     { 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]]]] } },
22757     { 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]]]] } },
22758     { 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]]]] } },
22759     { 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]]]] } },
22760     { 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]]]] } },
22761     { 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]]]] } },
22762     { 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]]]] } },
22763     { 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]]]] } },
22764     { 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]]]] } },
22765     { 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]]]] } },
22766     { 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]]]] } },
22767     { 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]]]] } },
22768     { 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]]]] } },
22769     { 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]]]] } },
22770     { 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]]]] } },
22771     { type: "Feature", properties: { iso1A2: "ID", iso1A3: "IDN", iso1N3: "360", wikidata: "Q252", nameEn: "Indonesia", aliases: ["RI"] }, geometry: null },
22772     { 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"] } },
22773     { 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]]]] } },
22774     { 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]]]] } },
22775     { type: "Feature", properties: { iso1A2: "IN", iso1A3: "IND", iso1N3: "356", wikidata: "Q668", nameEn: "India" }, geometry: null },
22776     { type: "Feature", properties: { iso1A2: "IO", iso1A3: "IOT", iso1N3: "086", wikidata: "Q43448", nameEn: "British Indian Ocean Territory", country: "GB" }, geometry: null },
22777     { 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]]]] } },
22778     { 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]]]] } },
22779     { 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]]]] } },
22780     { 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]]]] } },
22781     { 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]]]] } },
22782     { 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]]]] } },
22783     { 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]]]] } },
22784     { 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]]]] } },
22785     { 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]]]] } },
22786     { 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]]]] } },
22787     { 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]]]] } },
22788     { 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]]]] } },
22789     { 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]]]] } },
22790     { 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]]]] } },
22791     { 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]]]] } },
22792     { 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]]]] } },
22793     { 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]]]] } },
22794     { 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]]]] } },
22795     { 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]]]] } },
22796     { 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]]]] } },
22797     { 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]]]] } },
22798     { 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]]]] } },
22799     { 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]]]] } },
22800     { 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]]]] } },
22801     { 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]]]] } },
22802     { 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]]]] } },
22803     { 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]]]] } },
22804     { 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]]]] } },
22805     { 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]]]] } },
22806     { 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]]]] } },
22807     { 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]]]] } },
22808     { 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]]]] } },
22809     { 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]]]] } },
22810     { 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]]]] } },
22811     { 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]]]] } },
22812     { 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]]]] } },
22813     { 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]]]] } },
22814     { 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]]]] } },
22815     { 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]]]] } },
22816     { 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]]]] } },
22817     { 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]]]] } },
22818     { 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]]]] } },
22819     { 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]]]] } },
22820     { 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]]]] } },
22821     { 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]]]] } },
22822     { 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]]]] } },
22823     { 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]]]] } },
22824     { 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]]]] } },
22825     { 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]]]] } },
22826     { 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]]]] } },
22827     { 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]]]] } },
22828     { type: "Feature", properties: { iso1A2: "MY", iso1A3: "MYS", iso1N3: "458", wikidata: "Q833", nameEn: "Malaysia" }, geometry: null },
22829     { 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]]]] } },
22830     { 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]]]] } },
22831     { 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]]]] } },
22832     { 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]]]] } },
22833     { 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]]]] } },
22834     { 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]]]] } },
22835     { 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]]]] } },
22836     { type: "Feature", properties: { iso1A2: "NL", iso1A3: "NLD", iso1N3: "528", wikidata: "Q29999", nameEn: "Kingdom of the Netherlands" }, geometry: null },
22837     { type: "Feature", properties: { iso1A2: "NO", iso1A3: "NOR", iso1N3: "578", wikidata: "Q20", nameEn: "Norway" }, geometry: null },
22838     { 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]]]] } },
22839     { 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]]]] } },
22840     { 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]]]] } },
22841     { type: "Feature", properties: { iso1A2: "NZ", iso1A3: "NZL", iso1N3: "554", wikidata: "Q664", nameEn: "New Zealand" }, geometry: null },
22842     { 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]]]] } },
22843     { 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]]]] } },
22844     { 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]]]] } },
22845     { 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]]]] } },
22846     { 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]]]] } },
22847     { 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]]]] } },
22848     { 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]]]] } },
22849     { 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]]]] } },
22850     { 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]]]] } },
22851     { 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]]]] } },
22852     { 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]]]] } },
22853     { type: "Feature", properties: { iso1A2: "PS", iso1A3: "PSE", iso1N3: "275", wikidata: "Q219060", nameEn: "Palestine" }, geometry: null },
22854     { type: "Feature", properties: { iso1A2: "PT", iso1A3: "PRT", iso1N3: "620", wikidata: "Q45", nameEn: "Portugal" }, geometry: null },
22855     { 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]]]] } },
22856     { 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]]]] } },
22857     { 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]]]] } },
22858     { 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]]]] } },
22859     { 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]]]] } },
22860     { 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]]]] } },
22861     { type: "Feature", properties: { iso1A2: "RU", iso1A3: "RUS", iso1N3: "643", wikidata: "Q159", nameEn: "Russia" }, geometry: null },
22862     { 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]]]] } },
22863     { 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]]]] } },
22864     { 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]]]] } },
22865     { 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]]]] } },
22866     { 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]]]] } },
22867     { 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]]]] } },
22868     { 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]]]] } },
22869     { type: "Feature", properties: { iso1A2: "SH", iso1A3: "SHN", iso1N3: "654", wikidata: "Q192184", nameEn: "Saint Helena, Ascension and Tristan da Cunha", country: "GB" }, geometry: null },
22870     { 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]]]] } },
22871     { type: "Feature", properties: { iso1A2: "SJ", iso1A3: "SJM", iso1N3: "744", wikidata: "Q842829", nameEn: "Svalbard and Jan Mayen", country: "NO" }, geometry: null },
22872     { 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]]]] } },
22873     { 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]]]] } },
22874     { 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]]]] } },
22875     { 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]]]] } },
22876     { 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]]]] } },
22877     { 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]]]] } },
22878     { 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]]]] } },
22879     { 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]]]] } },
22880     { 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]]]] } },
22881     { 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]]]] } },
22882     { 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]]]] } },
22883     { 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]]]] } },
22884     { 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]]]] } },
22885     { 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]]]] } },
22886     { 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]]]] } },
22887     { type: "Feature", properties: { iso1A2: "TF", iso1A3: "ATF", iso1N3: "260", wikidata: "Q129003", nameEn: "French Southern Territories", country: "FR", groups: ["EU", "UN"] }, geometry: null },
22888     { 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]]]] } },
22889     { 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]]]] } },
22890     { 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]]]] } },
22891     { 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]]]] } },
22892     { 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]]]] } },
22893     { 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]]]] } },
22894     { 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]]]] } },
22895     { 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]]]] } },
22896     { 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]]]] } },
22897     { 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]]]] } },
22898     { 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]]]] } },
22899     { 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]]]] } },
22900     { 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]]]] } },
22901     { 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]]]] } },
22902     { 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]]]] } },
22903     { type: "Feature", properties: { iso1A2: "UM", iso1A3: "UMI", iso1N3: "581", wikidata: "Q16645", nameEn: "United States Minor Outlying Islands", country: "US" }, geometry: null },
22904     { type: "Feature", properties: { iso1A2: "UN", wikidata: "Q1065", nameEn: "United Nations", level: "unitedNations", isoStatus: "excRes" }, geometry: null },
22905     { type: "Feature", properties: { iso1A2: "US", iso1A3: "USA", iso1N3: "840", wikidata: "Q30", nameEn: "United States of America" }, geometry: null },
22906     { 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]]]] } },
22907     { 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]]]] } },
22908     { 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]]]] } },
22909     { 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]]]] } },
22910     { 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]]]] } },
22911     { 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]]]] } },
22912     { 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]]]] } },
22913     { 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]]]] } },
22914     { 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]]]] } },
22915     { 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]]]] } },
22916     { 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]]]] } },
22917     { 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]]]] } },
22918     { 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]]]] } },
22919     { 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]]]] } },
22920     { 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]]]] } },
22921     { 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]]]] } },
22922     { 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]]]] } }
22923   ] };
22924   var borders = borders_default;
22925   var _whichPolygon = {};
22926   var _featuresByCode = {};
22927   var idFilterRegex = /(?=(?!^(and|the|of|el|la|de)$))(\b(and|the|of|el|la|de)\b)|[-_ .,'()&[\]/]/gi;
22928   function canonicalID(id2) {
22929     const s2 = id2 || "";
22930     if (s2.charAt(0) === ".") {
22931       return s2.toUpperCase();
22932     } else {
22933       return s2.replace(idFilterRegex, "").toUpperCase();
22934     }
22935   }
22936   var levels = [
22937     "subterritory",
22938     "territory",
22939     "subcountryGroup",
22940     "country",
22941     "sharedLandform",
22942     "intermediateRegion",
22943     "subregion",
22944     "region",
22945     "subunion",
22946     "union",
22947     "unitedNations",
22948     "world"
22949   ];
22950   loadDerivedDataAndCaches(borders);
22951   function loadDerivedDataAndCaches(borders2) {
22952     const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"];
22953     let geometryFeatures = [];
22954     for (const feature22 of borders2.features) {
22955       const props = feature22.properties;
22956       props.id = props.iso1A2 || props.m49 || props.wikidata;
22957       loadM49(feature22);
22958       loadTLD(feature22);
22959       loadIsoStatus(feature22);
22960       loadLevel(feature22);
22961       loadGroups(feature22);
22962       loadFlag(feature22);
22963       cacheFeatureByIDs(feature22);
22964       if (feature22.geometry) {
22965         geometryFeatures.push(feature22);
22966       }
22967     }
22968     for (const feature22 of borders2.features) {
22969       feature22.properties.groups = feature22.properties.groups.map((groupID) => {
22970         return _featuresByCode[groupID].properties.id;
22971       });
22972       loadMembersForGroupsOf(feature22);
22973     }
22974     for (const feature22 of borders2.features) {
22975       loadRoadSpeedUnit(feature22);
22976       loadRoadHeightUnit(feature22);
22977       loadDriveSide(feature22);
22978       loadCallingCodes(feature22);
22979       loadGroupGroups(feature22);
22980     }
22981     for (const feature22 of borders2.features) {
22982       feature22.properties.groups.sort((groupID1, groupID2) => {
22983         return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level);
22984       });
22985       if (feature22.properties.members) {
22986         feature22.properties.members.sort((id1, id2) => {
22987           const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level);
22988           if (diff === 0) {
22989             return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]);
22990           }
22991           return diff;
22992         });
22993       }
22994     }
22995     const geometryOnlyCollection = {
22996       type: "FeatureCollection",
22997       features: geometryFeatures
22998     };
22999     _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection);
23000     function loadGroups(feature22) {
23001       const props = feature22.properties;
23002       if (!props.groups) {
23003         props.groups = [];
23004       }
23005       if (feature22.geometry && props.country) {
23006         props.groups.push(props.country);
23007       }
23008       if (props.m49 !== "001") {
23009         props.groups.push("001");
23010       }
23011     }
23012     function loadM49(feature22) {
23013       const props = feature22.properties;
23014       if (!props.m49 && props.iso1N3) {
23015         props.m49 = props.iso1N3;
23016       }
23017     }
23018     function loadTLD(feature22) {
23019       const props = feature22.properties;
23020       if (props.level === "unitedNations")
23021         return;
23022       if (!props.ccTLD && props.iso1A2) {
23023         props.ccTLD = "." + props.iso1A2.toLowerCase();
23024       }
23025     }
23026     function loadIsoStatus(feature22) {
23027       const props = feature22.properties;
23028       if (!props.isoStatus && props.iso1A2) {
23029         props.isoStatus = "official";
23030       }
23031     }
23032     function loadLevel(feature22) {
23033       const props = feature22.properties;
23034       if (props.level)
23035         return;
23036       if (!props.country) {
23037         props.level = "country";
23038       } else if (!props.iso1A2 || props.isoStatus === "official") {
23039         props.level = "territory";
23040       } else {
23041         props.level = "subterritory";
23042       }
23043     }
23044     function loadGroupGroups(feature22) {
23045       const props = feature22.properties;
23046       if (feature22.geometry || !props.members)
23047         return;
23048       const featureLevelIndex = levels.indexOf(props.level);
23049       let sharedGroups = [];
23050       props.members.forEach((memberID, index) => {
23051         const member = _featuresByCode[memberID];
23052         const memberGroups = member.properties.groups.filter((groupID) => {
23053           return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level);
23054         });
23055         if (index === 0) {
23056           sharedGroups = memberGroups;
23057         } else {
23058           sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1);
23059         }
23060       });
23061       props.groups = props.groups.concat(
23062         sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1)
23063       );
23064       for (const groupID of sharedGroups) {
23065         const groupFeature = _featuresByCode[groupID];
23066         if (groupFeature.properties.members.indexOf(props.id) === -1) {
23067           groupFeature.properties.members.push(props.id);
23068         }
23069       }
23070     }
23071     function loadRoadSpeedUnit(feature22) {
23072       const props = feature22.properties;
23073       if (feature22.geometry) {
23074         if (!props.roadSpeedUnit)
23075           props.roadSpeedUnit = "km/h";
23076       } else if (props.members) {
23077         const vals = Array.from(
23078           new Set(
23079             props.members.map((id2) => {
23080               const member = _featuresByCode[id2];
23081               if (member.geometry)
23082                 return member.properties.roadSpeedUnit || "km/h";
23083             }).filter(Boolean)
23084           )
23085         );
23086         if (vals.length === 1)
23087           props.roadSpeedUnit = vals[0];
23088       }
23089     }
23090     function loadRoadHeightUnit(feature22) {
23091       const props = feature22.properties;
23092       if (feature22.geometry) {
23093         if (!props.roadHeightUnit)
23094           props.roadHeightUnit = "m";
23095       } else if (props.members) {
23096         const vals = Array.from(
23097           new Set(
23098             props.members.map((id2) => {
23099               const member = _featuresByCode[id2];
23100               if (member.geometry)
23101                 return member.properties.roadHeightUnit || "m";
23102             }).filter(Boolean)
23103           )
23104         );
23105         if (vals.length === 1)
23106           props.roadHeightUnit = vals[0];
23107       }
23108     }
23109     function loadDriveSide(feature22) {
23110       const props = feature22.properties;
23111       if (feature22.geometry) {
23112         if (!props.driveSide)
23113           props.driveSide = "right";
23114       } else if (props.members) {
23115         const vals = Array.from(
23116           new Set(
23117             props.members.map((id2) => {
23118               const member = _featuresByCode[id2];
23119               if (member.geometry)
23120                 return member.properties.driveSide || "right";
23121             }).filter(Boolean)
23122           )
23123         );
23124         if (vals.length === 1)
23125           props.driveSide = vals[0];
23126       }
23127     }
23128     function loadCallingCodes(feature22) {
23129       const props = feature22.properties;
23130       if (!feature22.geometry && props.members) {
23131         props.callingCodes = Array.from(
23132           new Set(
23133             props.members.reduce((array2, id2) => {
23134               const member = _featuresByCode[id2];
23135               if (member.geometry && member.properties.callingCodes) {
23136                 return array2.concat(member.properties.callingCodes);
23137               }
23138               return array2;
23139             }, [])
23140           )
23141         );
23142       }
23143     }
23144     function loadFlag(feature22) {
23145       if (!feature22.properties.iso1A2)
23146         return;
23147       const flag = feature22.properties.iso1A2.replace(/./g, function(char) {
23148         return String.fromCodePoint(char.charCodeAt(0) + 127397);
23149       });
23150       feature22.properties.emojiFlag = flag;
23151     }
23152     function loadMembersForGroupsOf(feature22) {
23153       for (const groupID of feature22.properties.groups) {
23154         const groupFeature = _featuresByCode[groupID];
23155         if (!groupFeature.properties.members) {
23156           groupFeature.properties.members = [];
23157         }
23158         groupFeature.properties.members.push(feature22.properties.id);
23159       }
23160     }
23161     function cacheFeatureByIDs(feature22) {
23162       let ids = [];
23163       for (const prop of identifierProps) {
23164         const id2 = feature22.properties[prop];
23165         if (id2) {
23166           ids.push(id2);
23167         }
23168       }
23169       for (const alias of feature22.properties.aliases || []) {
23170         ids.push(alias);
23171       }
23172       for (const id2 of ids) {
23173         const cid = canonicalID(id2);
23174         _featuresByCode[cid] = feature22;
23175       }
23176     }
23177   }
23178   function locArray(loc) {
23179     if (Array.isArray(loc)) {
23180       return loc;
23181     } else if (loc.coordinates) {
23182       return loc.coordinates;
23183     }
23184     return loc.geometry.coordinates;
23185   }
23186   function smallestFeature(loc) {
23187     const query = locArray(loc);
23188     const featureProperties = _whichPolygon(query);
23189     if (!featureProperties)
23190       return null;
23191     return _featuresByCode[featureProperties.id];
23192   }
23193   function countryFeature(loc) {
23194     const feature22 = smallestFeature(loc);
23195     if (!feature22)
23196       return null;
23197     const countryCode = feature22.properties.country || feature22.properties.iso1A2;
23198     return _featuresByCode[countryCode] || null;
23199   }
23200   var defaultOpts = {
23201     level: void 0,
23202     maxLevel: void 0,
23203     withProp: void 0
23204   };
23205   function featureForLoc(loc, opts) {
23206     const targetLevel = opts.level || "country";
23207     const maxLevel = opts.maxLevel || "world";
23208     const withProp = opts.withProp;
23209     const targetLevelIndex = levels.indexOf(targetLevel);
23210     if (targetLevelIndex === -1)
23211       return null;
23212     const maxLevelIndex = levels.indexOf(maxLevel);
23213     if (maxLevelIndex === -1)
23214       return null;
23215     if (maxLevelIndex < targetLevelIndex)
23216       return null;
23217     if (targetLevel === "country") {
23218       const fastFeature = countryFeature(loc);
23219       if (fastFeature) {
23220         if (!withProp || fastFeature.properties[withProp]) {
23221           return fastFeature;
23222         }
23223       }
23224     }
23225     const features = featuresContaining(loc);
23226     const match = features.find((feature22) => {
23227       let levelIndex = levels.indexOf(feature22.properties.level);
23228       if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up
23229       levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) {
23230         if (!withProp || feature22.properties[withProp]) {
23231           return feature22;
23232         }
23233       }
23234       return false;
23235     });
23236     return match || null;
23237   }
23238   function featureForID(id2) {
23239     let stringID;
23240     if (typeof id2 === "number") {
23241       stringID = id2.toString();
23242       if (stringID.length === 1) {
23243         stringID = "00" + stringID;
23244       } else if (stringID.length === 2) {
23245         stringID = "0" + stringID;
23246       }
23247     } else {
23248       stringID = canonicalID(id2);
23249     }
23250     return _featuresByCode[stringID] || null;
23251   }
23252   function smallestFeaturesForBbox(bbox2) {
23253     return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]);
23254   }
23255   function smallestOrMatchingFeature(query) {
23256     if (typeof query === "object") {
23257       return smallestFeature(query);
23258     }
23259     return featureForID(query);
23260   }
23261   function feature(query, opts = defaultOpts) {
23262     if (typeof query === "object") {
23263       return featureForLoc(query, opts);
23264     }
23265     return featureForID(query);
23266   }
23267   function iso1A2Code(query, opts = defaultOpts) {
23268     opts.withProp = "iso1A2";
23269     const match = feature(query, opts);
23270     if (!match)
23271       return null;
23272     return match.properties.iso1A2 || null;
23273   }
23274   function propertiesForQuery(query, property) {
23275     const features = featuresContaining(query, false);
23276     return features.map((feature22) => feature22.properties[property]).filter(Boolean);
23277   }
23278   function iso1A2Codes(query) {
23279     return propertiesForQuery(query, "iso1A2");
23280   }
23281   function featuresContaining(query, strict) {
23282     let matchingFeatures;
23283     if (Array.isArray(query) && query.length === 4) {
23284       matchingFeatures = smallestFeaturesForBbox(query);
23285     } else {
23286       const smallestOrMatching = smallestOrMatchingFeature(query);
23287       matchingFeatures = smallestOrMatching ? [smallestOrMatching] : [];
23288     }
23289     if (!matchingFeatures.length)
23290       return [];
23291     let returnFeatures;
23292     if (!strict || typeof query === "object") {
23293       returnFeatures = matchingFeatures.slice();
23294     } else {
23295       returnFeatures = [];
23296     }
23297     for (const feature22 of matchingFeatures) {
23298       const properties = feature22.properties;
23299       for (const groupID of properties.groups) {
23300         const groupFeature = _featuresByCode[groupID];
23301         if (returnFeatures.indexOf(groupFeature) === -1) {
23302           returnFeatures.push(groupFeature);
23303         }
23304       }
23305     }
23306     return returnFeatures;
23307   }
23308   function featuresIn(id2, strict) {
23309     const feature22 = featureForID(id2);
23310     if (!feature22)
23311       return [];
23312     let features = [];
23313     if (!strict) {
23314       features.push(feature22);
23315     }
23316     const properties = feature22.properties;
23317     for (const memberID of properties.members || []) {
23318       features.push(_featuresByCode[memberID]);
23319     }
23320     return features;
23321   }
23322   function aggregateFeature(id2) {
23323     var _a2;
23324     const features = featuresIn(id2, false);
23325     if (features.length === 0)
23326       return null;
23327     let aggregateCoordinates = [];
23328     for (const feature22 of features) {
23329       if (((_a2 = feature22.geometry) == null ? void 0 : _a2.type) === "MultiPolygon" && feature22.geometry.coordinates) {
23330         aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates);
23331       }
23332     }
23333     return {
23334       type: "Feature",
23335       properties: features[0].properties,
23336       geometry: {
23337         type: "MultiPolygon",
23338         coordinates: aggregateCoordinates
23339       }
23340     };
23341   }
23342   function roadSpeedUnit(query) {
23343     const feature22 = smallestOrMatchingFeature(query);
23344     return feature22 && feature22.properties.roadSpeedUnit || null;
23345   }
23346   function roadHeightUnit(query) {
23347     const feature22 = smallestOrMatchingFeature(query);
23348     return feature22 && feature22.properties.roadHeightUnit || null;
23349   }
23350
23351   // node_modules/polyclip-ts/dist/constant.js
23352   var constant_default5 = (x2) => {
23353     return () => {
23354       return x2;
23355     };
23356   };
23357
23358   // node_modules/polyclip-ts/dist/compare.js
23359   var compare_default = (eps) => {
23360     const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default5(false);
23361     return (a2, b2) => {
23362       if (almostEqual(a2, b2))
23363         return 0;
23364       return a2.comparedTo(b2);
23365     };
23366   };
23367
23368   // node_modules/polyclip-ts/dist/orient.js
23369   function orient_default(eps) {
23370     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);
23371     return (a2, b2, c2) => {
23372       const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y;
23373       const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy)));
23374       if (almostCollinear(area2, ax, ay, cx, cy))
23375         return 0;
23376       return area2.comparedTo(0);
23377     };
23378   }
23379
23380   // node_modules/bignumber.js/bignumber.mjs
23381   var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
23382   var mathceil = Math.ceil;
23383   var mathfloor = Math.floor;
23384   var bignumberError = "[BigNumber Error] ";
23385   var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
23386   var BASE = 1e14;
23387   var LOG_BASE = 14;
23388   var MAX_SAFE_INTEGER = 9007199254740991;
23389   var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
23390   var SQRT_BASE = 1e7;
23391   var MAX = 1e9;
23392   function clone(configObject) {
23393     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 = {
23394       prefix: "",
23395       groupSize: 3,
23396       secondaryGroupSize: 0,
23397       groupSeparator: ",",
23398       decimalSeparator: ".",
23399       fractionGroupSize: 0,
23400       fractionGroupSeparator: "\xA0",
23401       // non-breaking space
23402       suffix: ""
23403     }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
23404     function BigNumber2(v2, b2) {
23405       var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this;
23406       if (!(x2 instanceof BigNumber2))
23407         return new BigNumber2(v2, b2);
23408       if (b2 == null) {
23409         if (v2 && v2._isBigNumber === true) {
23410           x2.s = v2.s;
23411           if (!v2.c || v2.e > MAX_EXP) {
23412             x2.c = x2.e = null;
23413           } else if (v2.e < MIN_EXP) {
23414             x2.c = [x2.e = 0];
23415           } else {
23416             x2.e = v2.e;
23417             x2.c = v2.c.slice();
23418           }
23419           return;
23420         }
23421         if ((isNum = typeof v2 == "number") && v2 * 0 == 0) {
23422           x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1;
23423           if (v2 === ~~v2) {
23424             for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++)
23425               ;
23426             if (e3 > MAX_EXP) {
23427               x2.c = x2.e = null;
23428             } else {
23429               x2.e = e3;
23430               x2.c = [v2];
23431             }
23432             return;
23433           }
23434           str = String(v2);
23435         } else {
23436           if (!isNumeric.test(str = String(v2)))
23437             return parseNumeric2(x2, str, isNum);
23438           x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
23439         }
23440         if ((e3 = str.indexOf(".")) > -1)
23441           str = str.replace(".", "");
23442         if ((i3 = str.search(/e/i)) > 0) {
23443           if (e3 < 0)
23444             e3 = i3;
23445           e3 += +str.slice(i3 + 1);
23446           str = str.substring(0, i3);
23447         } else if (e3 < 0) {
23448           e3 = str.length;
23449         }
23450       } else {
23451         intCheck(b2, 2, ALPHABET.length, "Base");
23452         if (b2 == 10 && alphabetHasNormalDecimalDigits) {
23453           x2 = new BigNumber2(v2);
23454           return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE);
23455         }
23456         str = String(v2);
23457         if (isNum = typeof v2 == "number") {
23458           if (v2 * 0 != 0)
23459             return parseNumeric2(x2, str, isNum, b2);
23460           x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1;
23461           if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
23462             throw Error(tooManyDigits + v2);
23463           }
23464         } else {
23465           x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
23466         }
23467         alphabet = ALPHABET.slice(0, b2);
23468         e3 = i3 = 0;
23469         for (len = str.length; i3 < len; i3++) {
23470           if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) {
23471             if (c2 == ".") {
23472               if (i3 > e3) {
23473                 e3 = len;
23474                 continue;
23475               }
23476             } else if (!caseChanged) {
23477               if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
23478                 caseChanged = true;
23479                 i3 = -1;
23480                 e3 = 0;
23481                 continue;
23482               }
23483             }
23484             return parseNumeric2(x2, String(v2), isNum, b2);
23485           }
23486         }
23487         isNum = false;
23488         str = convertBase(str, b2, 10, x2.s);
23489         if ((e3 = str.indexOf(".")) > -1)
23490           str = str.replace(".", "");
23491         else
23492           e3 = str.length;
23493       }
23494       for (i3 = 0; str.charCodeAt(i3) === 48; i3++)
23495         ;
23496       for (len = str.length; str.charCodeAt(--len) === 48; )
23497         ;
23498       if (str = str.slice(i3, ++len)) {
23499         len -= i3;
23500         if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER || v2 !== mathfloor(v2))) {
23501           throw Error(tooManyDigits + x2.s * v2);
23502         }
23503         if ((e3 = e3 - i3 - 1) > MAX_EXP) {
23504           x2.c = x2.e = null;
23505         } else if (e3 < MIN_EXP) {
23506           x2.c = [x2.e = 0];
23507         } else {
23508           x2.e = e3;
23509           x2.c = [];
23510           i3 = (e3 + 1) % LOG_BASE;
23511           if (e3 < 0)
23512             i3 += LOG_BASE;
23513           if (i3 < len) {
23514             if (i3)
23515               x2.c.push(+str.slice(0, i3));
23516             for (len -= LOG_BASE; i3 < len; ) {
23517               x2.c.push(+str.slice(i3, i3 += LOG_BASE));
23518             }
23519             i3 = LOG_BASE - (str = str.slice(i3)).length;
23520           } else {
23521             i3 -= len;
23522           }
23523           for (; i3--; str += "0")
23524             ;
23525           x2.c.push(+str);
23526         }
23527       } else {
23528         x2.c = [x2.e = 0];
23529       }
23530     }
23531     BigNumber2.clone = clone;
23532     BigNumber2.ROUND_UP = 0;
23533     BigNumber2.ROUND_DOWN = 1;
23534     BigNumber2.ROUND_CEIL = 2;
23535     BigNumber2.ROUND_FLOOR = 3;
23536     BigNumber2.ROUND_HALF_UP = 4;
23537     BigNumber2.ROUND_HALF_DOWN = 5;
23538     BigNumber2.ROUND_HALF_EVEN = 6;
23539     BigNumber2.ROUND_HALF_CEIL = 7;
23540     BigNumber2.ROUND_HALF_FLOOR = 8;
23541     BigNumber2.EUCLID = 9;
23542     BigNumber2.config = BigNumber2.set = function(obj) {
23543       var p2, v2;
23544       if (obj != null) {
23545         if (typeof obj == "object") {
23546           if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) {
23547             v2 = obj[p2];
23548             intCheck(v2, 0, MAX, p2);
23549             DECIMAL_PLACES = v2;
23550           }
23551           if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) {
23552             v2 = obj[p2];
23553             intCheck(v2, 0, 8, p2);
23554             ROUNDING_MODE = v2;
23555           }
23556           if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) {
23557             v2 = obj[p2];
23558             if (v2 && v2.pop) {
23559               intCheck(v2[0], -MAX, 0, p2);
23560               intCheck(v2[1], 0, MAX, p2);
23561               TO_EXP_NEG = v2[0];
23562               TO_EXP_POS = v2[1];
23563             } else {
23564               intCheck(v2, -MAX, MAX, p2);
23565               TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2);
23566             }
23567           }
23568           if (obj.hasOwnProperty(p2 = "RANGE")) {
23569             v2 = obj[p2];
23570             if (v2 && v2.pop) {
23571               intCheck(v2[0], -MAX, -1, p2);
23572               intCheck(v2[1], 1, MAX, p2);
23573               MIN_EXP = v2[0];
23574               MAX_EXP = v2[1];
23575             } else {
23576               intCheck(v2, -MAX, MAX, p2);
23577               if (v2) {
23578                 MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2);
23579               } else {
23580                 throw Error(bignumberError + p2 + " cannot be zero: " + v2);
23581               }
23582             }
23583           }
23584           if (obj.hasOwnProperty(p2 = "CRYPTO")) {
23585             v2 = obj[p2];
23586             if (v2 === !!v2) {
23587               if (v2) {
23588                 if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
23589                   CRYPTO = v2;
23590                 } else {
23591                   CRYPTO = !v2;
23592                   throw Error(bignumberError + "crypto unavailable");
23593                 }
23594               } else {
23595                 CRYPTO = v2;
23596               }
23597             } else {
23598               throw Error(bignumberError + p2 + " not true or false: " + v2);
23599             }
23600           }
23601           if (obj.hasOwnProperty(p2 = "MODULO_MODE")) {
23602             v2 = obj[p2];
23603             intCheck(v2, 0, 9, p2);
23604             MODULO_MODE = v2;
23605           }
23606           if (obj.hasOwnProperty(p2 = "POW_PRECISION")) {
23607             v2 = obj[p2];
23608             intCheck(v2, 0, MAX, p2);
23609             POW_PRECISION = v2;
23610           }
23611           if (obj.hasOwnProperty(p2 = "FORMAT")) {
23612             v2 = obj[p2];
23613             if (typeof v2 == "object")
23614               FORMAT = v2;
23615             else
23616               throw Error(bignumberError + p2 + " not an object: " + v2);
23617           }
23618           if (obj.hasOwnProperty(p2 = "ALPHABET")) {
23619             v2 = obj[p2];
23620             if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) {
23621               alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789";
23622               ALPHABET = v2;
23623             } else {
23624               throw Error(bignumberError + p2 + " invalid: " + v2);
23625             }
23626           }
23627         } else {
23628           throw Error(bignumberError + "Object expected: " + obj);
23629         }
23630       }
23631       return {
23632         DECIMAL_PLACES,
23633         ROUNDING_MODE,
23634         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
23635         RANGE: [MIN_EXP, MAX_EXP],
23636         CRYPTO,
23637         MODULO_MODE,
23638         POW_PRECISION,
23639         FORMAT,
23640         ALPHABET
23641       };
23642     };
23643     BigNumber2.isBigNumber = function(v2) {
23644       if (!v2 || v2._isBigNumber !== true)
23645         return false;
23646       if (!BigNumber2.DEBUG)
23647         return true;
23648       var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s;
23649       out:
23650         if ({}.toString.call(c2) == "[object Array]") {
23651           if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) {
23652             if (c2[0] === 0) {
23653               if (e3 === 0 && c2.length === 1)
23654                 return true;
23655               break out;
23656             }
23657             i3 = (e3 + 1) % LOG_BASE;
23658             if (i3 < 1)
23659               i3 += LOG_BASE;
23660             if (String(c2[0]).length == i3) {
23661               for (i3 = 0; i3 < c2.length; i3++) {
23662                 n3 = c2[i3];
23663                 if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3))
23664                   break out;
23665               }
23666               if (n3 !== 0)
23667                 return true;
23668             }
23669           }
23670         } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) {
23671           return true;
23672         }
23673       throw Error(bignumberError + "Invalid BigNumber: " + v2);
23674     };
23675     BigNumber2.maximum = BigNumber2.max = function() {
23676       return maxOrMin(arguments, -1);
23677     };
23678     BigNumber2.minimum = BigNumber2.min = function() {
23679       return maxOrMin(arguments, 1);
23680     };
23681     BigNumber2.random = function() {
23682       var pow2_53 = 9007199254740992;
23683       var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
23684         return mathfloor(Math.random() * pow2_53);
23685       } : function() {
23686         return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
23687       };
23688       return function(dp) {
23689         var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE);
23690         if (dp == null)
23691           dp = DECIMAL_PLACES;
23692         else
23693           intCheck(dp, 0, MAX);
23694         k2 = mathceil(dp / LOG_BASE);
23695         if (CRYPTO) {
23696           if (crypto.getRandomValues) {
23697             a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2));
23698             for (; i3 < k2; ) {
23699               v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11);
23700               if (v2 >= 9e15) {
23701                 b2 = crypto.getRandomValues(new Uint32Array(2));
23702                 a2[i3] = b2[0];
23703                 a2[i3 + 1] = b2[1];
23704               } else {
23705                 c2.push(v2 % 1e14);
23706                 i3 += 2;
23707               }
23708             }
23709             i3 = k2 / 2;
23710           } else if (crypto.randomBytes) {
23711             a2 = crypto.randomBytes(k2 *= 7);
23712             for (; i3 < k2; ) {
23713               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];
23714               if (v2 >= 9e15) {
23715                 crypto.randomBytes(7).copy(a2, i3);
23716               } else {
23717                 c2.push(v2 % 1e14);
23718                 i3 += 7;
23719               }
23720             }
23721             i3 = k2 / 7;
23722           } else {
23723             CRYPTO = false;
23724             throw Error(bignumberError + "crypto unavailable");
23725           }
23726         }
23727         if (!CRYPTO) {
23728           for (; i3 < k2; ) {
23729             v2 = random53bitInt();
23730             if (v2 < 9e15)
23731               c2[i3++] = v2 % 1e14;
23732           }
23733         }
23734         k2 = c2[--i3];
23735         dp %= LOG_BASE;
23736         if (k2 && dp) {
23737           v2 = POWS_TEN[LOG_BASE - dp];
23738           c2[i3] = mathfloor(k2 / v2) * v2;
23739         }
23740         for (; c2[i3] === 0; c2.pop(), i3--)
23741           ;
23742         if (i3 < 0) {
23743           c2 = [e3 = 0];
23744         } else {
23745           for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE)
23746             ;
23747           for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++)
23748             ;
23749           if (i3 < LOG_BASE)
23750             e3 -= LOG_BASE - i3;
23751         }
23752         rand.e = e3;
23753         rand.c = c2;
23754         return rand;
23755       };
23756     }();
23757     BigNumber2.sum = function() {
23758       var i3 = 1, args = arguments, sum = new BigNumber2(args[0]);
23759       for (; i3 < args.length; )
23760         sum = sum.plus(args[i3++]);
23761       return sum;
23762     };
23763     convertBase = /* @__PURE__ */ function() {
23764       var decimal = "0123456789";
23765       function toBaseOut(str, baseIn, baseOut, alphabet) {
23766         var j2, arr = [0], arrL, i3 = 0, len = str.length;
23767         for (; i3 < len; ) {
23768           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn)
23769             ;
23770           arr[0] += alphabet.indexOf(str.charAt(i3++));
23771           for (j2 = 0; j2 < arr.length; j2++) {
23772             if (arr[j2] > baseOut - 1) {
23773               if (arr[j2 + 1] == null)
23774                 arr[j2 + 1] = 0;
23775               arr[j2 + 1] += arr[j2] / baseOut | 0;
23776               arr[j2] %= baseOut;
23777             }
23778           }
23779         }
23780         return arr.reverse();
23781       }
23782       return function(str, baseIn, baseOut, sign2, callerIsToString) {
23783         var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
23784         if (i3 >= 0) {
23785           k2 = POW_PRECISION;
23786           POW_PRECISION = 0;
23787           str = str.replace(".", "");
23788           y2 = new BigNumber2(baseIn);
23789           x2 = y2.pow(str.length - i3);
23790           POW_PRECISION = k2;
23791           y2.c = toBaseOut(
23792             toFixedPoint(coeffToString(x2.c), x2.e, "0"),
23793             10,
23794             baseOut,
23795             decimal
23796           );
23797           y2.e = y2.c.length;
23798         }
23799         xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
23800         e3 = k2 = xc.length;
23801         for (; xc[--k2] == 0; xc.pop())
23802           ;
23803         if (!xc[0])
23804           return alphabet.charAt(0);
23805         if (i3 < 0) {
23806           --e3;
23807         } else {
23808           x2.c = xc;
23809           x2.e = e3;
23810           x2.s = sign2;
23811           x2 = div(x2, y2, dp, rm, baseOut);
23812           xc = x2.c;
23813           r2 = x2.r;
23814           e3 = x2.e;
23815         }
23816         d2 = e3 + dp + 1;
23817         i3 = xc[d2];
23818         k2 = baseOut / 2;
23819         r2 = r2 || d2 < 0 || xc[d2 + 1] != null;
23820         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));
23821         if (d2 < 1 || !xc[0]) {
23822           str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
23823         } else {
23824           xc.length = d2;
23825           if (r2) {
23826             for (--baseOut; ++xc[--d2] > baseOut; ) {
23827               xc[d2] = 0;
23828               if (!d2) {
23829                 ++e3;
23830                 xc = [1].concat(xc);
23831               }
23832             }
23833           }
23834           for (k2 = xc.length; !xc[--k2]; )
23835             ;
23836           for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++]))
23837             ;
23838           str = toFixedPoint(str, e3, alphabet.charAt(0));
23839         }
23840         return str;
23841       };
23842     }();
23843     div = /* @__PURE__ */ function() {
23844       function multiply(x2, k2, base) {
23845         var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0;
23846         for (x2 = x2.slice(); i3--; ) {
23847           xlo = x2[i3] % SQRT_BASE;
23848           xhi = x2[i3] / SQRT_BASE | 0;
23849           m2 = khi * xlo + xhi * klo;
23850           temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry;
23851           carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi;
23852           x2[i3] = temp % base;
23853         }
23854         if (carry)
23855           x2 = [carry].concat(x2);
23856         return x2;
23857       }
23858       function compare2(a2, b2, aL, bL) {
23859         var i3, cmp;
23860         if (aL != bL) {
23861           cmp = aL > bL ? 1 : -1;
23862         } else {
23863           for (i3 = cmp = 0; i3 < aL; i3++) {
23864             if (a2[i3] != b2[i3]) {
23865               cmp = a2[i3] > b2[i3] ? 1 : -1;
23866               break;
23867             }
23868           }
23869         }
23870         return cmp;
23871       }
23872       function subtract(a2, b2, aL, base) {
23873         var i3 = 0;
23874         for (; aL--; ) {
23875           a2[aL] -= i3;
23876           i3 = a2[aL] < b2[aL] ? 1 : 0;
23877           a2[aL] = i3 * base + a2[aL] - b2[aL];
23878         }
23879         for (; !a2[0] && a2.length > 1; a2.splice(0, 1))
23880           ;
23881       }
23882       return function(x2, y2, dp, rm, base) {
23883         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;
23884         if (!xc || !xc[0] || !yc || !yc[0]) {
23885           return new BigNumber2(
23886             // Return NaN if either NaN, or both Infinity or 0.
23887             !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
23888               // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
23889               xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0
23890             )
23891           );
23892         }
23893         q2 = new BigNumber2(s2);
23894         qc = q2.c = [];
23895         e3 = x2.e - y2.e;
23896         s2 = dp + e3 + 1;
23897         if (!base) {
23898           base = BASE;
23899           e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE);
23900           s2 = s2 / LOG_BASE | 0;
23901         }
23902         for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++)
23903           ;
23904         if (yc[i3] > (xc[i3] || 0))
23905           e3--;
23906         if (s2 < 0) {
23907           qc.push(1);
23908           more = true;
23909         } else {
23910           xL = xc.length;
23911           yL = yc.length;
23912           i3 = 0;
23913           s2 += 2;
23914           n3 = mathfloor(base / (yc[0] + 1));
23915           if (n3 > 1) {
23916             yc = multiply(yc, n3, base);
23917             xc = multiply(xc, n3, base);
23918             yL = yc.length;
23919             xL = xc.length;
23920           }
23921           xi = yL;
23922           rem = xc.slice(0, yL);
23923           remL = rem.length;
23924           for (; remL < yL; rem[remL++] = 0)
23925             ;
23926           yz = yc.slice();
23927           yz = [0].concat(yz);
23928           yc0 = yc[0];
23929           if (yc[1] >= base / 2)
23930             yc0++;
23931           do {
23932             n3 = 0;
23933             cmp = compare2(yc, rem, yL, remL);
23934             if (cmp < 0) {
23935               rem0 = rem[0];
23936               if (yL != remL)
23937                 rem0 = rem0 * base + (rem[1] || 0);
23938               n3 = mathfloor(rem0 / yc0);
23939               if (n3 > 1) {
23940                 if (n3 >= base)
23941                   n3 = base - 1;
23942                 prod = multiply(yc, n3, base);
23943                 prodL = prod.length;
23944                 remL = rem.length;
23945                 while (compare2(prod, rem, prodL, remL) == 1) {
23946                   n3--;
23947                   subtract(prod, yL < prodL ? yz : yc, prodL, base);
23948                   prodL = prod.length;
23949                   cmp = 1;
23950                 }
23951               } else {
23952                 if (n3 == 0) {
23953                   cmp = n3 = 1;
23954                 }
23955                 prod = yc.slice();
23956                 prodL = prod.length;
23957               }
23958               if (prodL < remL)
23959                 prod = [0].concat(prod);
23960               subtract(rem, prod, remL, base);
23961               remL = rem.length;
23962               if (cmp == -1) {
23963                 while (compare2(yc, rem, yL, remL) < 1) {
23964                   n3++;
23965                   subtract(rem, yL < remL ? yz : yc, remL, base);
23966                   remL = rem.length;
23967                 }
23968               }
23969             } else if (cmp === 0) {
23970               n3++;
23971               rem = [0];
23972             }
23973             qc[i3++] = n3;
23974             if (rem[0]) {
23975               rem[remL++] = xc[xi] || 0;
23976             } else {
23977               rem = [xc[xi]];
23978               remL = 1;
23979             }
23980           } while ((xi++ < xL || rem[0] != null) && s2--);
23981           more = rem[0] != null;
23982           if (!qc[0])
23983             qc.splice(0, 1);
23984         }
23985         if (base == BASE) {
23986           for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++)
23987             ;
23988           round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more);
23989         } else {
23990           q2.e = e3;
23991           q2.r = +more;
23992         }
23993         return q2;
23994       };
23995     }();
23996     function format2(n3, i3, rm, id2) {
23997       var c0, e3, ne2, len, str;
23998       if (rm == null)
23999         rm = ROUNDING_MODE;
24000       else
24001         intCheck(rm, 0, 8);
24002       if (!n3.c)
24003         return n3.toString();
24004       c0 = n3.c[0];
24005       ne2 = n3.e;
24006       if (i3 == null) {
24007         str = coeffToString(n3.c);
24008         str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0");
24009       } else {
24010         n3 = round(new BigNumber2(n3), i3, rm);
24011         e3 = n3.e;
24012         str = coeffToString(n3.c);
24013         len = str.length;
24014         if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) {
24015           for (; len < i3; str += "0", len++)
24016             ;
24017           str = toExponential(str, e3);
24018         } else {
24019           i3 -= ne2;
24020           str = toFixedPoint(str, e3, "0");
24021           if (e3 + 1 > len) {
24022             if (--i3 > 0)
24023               for (str += "."; i3--; str += "0")
24024                 ;
24025           } else {
24026             i3 += e3 - len;
24027             if (i3 > 0) {
24028               if (e3 + 1 == len)
24029                 str += ".";
24030               for (; i3--; str += "0")
24031                 ;
24032             }
24033           }
24034         }
24035       }
24036       return n3.s < 0 && c0 ? "-" + str : str;
24037     }
24038     function maxOrMin(args, n3) {
24039       var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]);
24040       for (; i3 < args.length; i3++) {
24041         y2 = new BigNumber2(args[i3]);
24042         if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) {
24043           x2 = y2;
24044         }
24045       }
24046       return x2;
24047     }
24048     function normalise(n3, c2, e3) {
24049       var i3 = 1, j2 = c2.length;
24050       for (; !c2[--j2]; c2.pop())
24051         ;
24052       for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++)
24053         ;
24054       if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) {
24055         n3.c = n3.e = null;
24056       } else if (e3 < MIN_EXP) {
24057         n3.c = [n3.e = 0];
24058       } else {
24059         n3.e = e3;
24060         n3.c = c2;
24061       }
24062       return n3;
24063     }
24064     parseNumeric2 = /* @__PURE__ */ function() {
24065       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
24066       return function(x2, str, isNum, b2) {
24067         var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, "");
24068         if (isInfinityOrNaN.test(s2)) {
24069           x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1;
24070         } else {
24071           if (!isNum) {
24072             s2 = s2.replace(basePrefix, function(m2, p1, p2) {
24073               base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
24074               return !b2 || b2 == base ? p1 : m2;
24075             });
24076             if (b2) {
24077               base = b2;
24078               s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
24079             }
24080             if (str != s2)
24081               return new BigNumber2(s2, base);
24082           }
24083           if (BigNumber2.DEBUG) {
24084             throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str);
24085           }
24086           x2.s = null;
24087         }
24088         x2.c = x2.e = null;
24089       };
24090     }();
24091     function round(x2, sd, rm, r2) {
24092       var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN;
24093       if (xc) {
24094         out: {
24095           for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++)
24096             ;
24097           i3 = sd - d2;
24098           if (i3 < 0) {
24099             i3 += LOG_BASE;
24100             j2 = sd;
24101             n3 = xc[ni = 0];
24102             rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24103           } else {
24104             ni = mathceil((i3 + 1) / LOG_BASE);
24105             if (ni >= xc.length) {
24106               if (r2) {
24107                 for (; xc.length <= ni; xc.push(0))
24108                   ;
24109                 n3 = rd = 0;
24110                 d2 = 1;
24111                 i3 %= LOG_BASE;
24112                 j2 = i3 - LOG_BASE + 1;
24113               } else {
24114                 break out;
24115               }
24116             } else {
24117               n3 = k2 = xc[ni];
24118               for (d2 = 1; k2 >= 10; k2 /= 10, d2++)
24119                 ;
24120               i3 %= LOG_BASE;
24121               j2 = i3 - LOG_BASE + d2;
24122               rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24123             }
24124           }
24125           r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit?
24126           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right
24127           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
24128           xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]);
24129           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.
24130           (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7));
24131           if (sd < 1 || !xc[0]) {
24132             xc.length = 0;
24133             if (r2) {
24134               sd -= x2.e + 1;
24135               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
24136               x2.e = -sd || 0;
24137             } else {
24138               xc[0] = x2.e = 0;
24139             }
24140             return x2;
24141           }
24142           if (i3 == 0) {
24143             xc.length = ni;
24144             k2 = 1;
24145             ni--;
24146           } else {
24147             xc.length = ni + 1;
24148             k2 = pows10[LOG_BASE - i3];
24149             xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0;
24150           }
24151           if (r2) {
24152             for (; ; ) {
24153               if (ni == 0) {
24154                 for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++)
24155                   ;
24156                 j2 = xc[0] += k2;
24157                 for (k2 = 1; j2 >= 10; j2 /= 10, k2++)
24158                   ;
24159                 if (i3 != k2) {
24160                   x2.e++;
24161                   if (xc[0] == BASE)
24162                     xc[0] = 1;
24163                 }
24164                 break;
24165               } else {
24166                 xc[ni] += k2;
24167                 if (xc[ni] != BASE)
24168                   break;
24169                 xc[ni--] = 0;
24170                 k2 = 1;
24171               }
24172             }
24173           }
24174           for (i3 = xc.length; xc[--i3] === 0; xc.pop())
24175             ;
24176         }
24177         if (x2.e > MAX_EXP) {
24178           x2.c = x2.e = null;
24179         } else if (x2.e < MIN_EXP) {
24180           x2.c = [x2.e = 0];
24181         }
24182       }
24183       return x2;
24184     }
24185     function valueOf(n3) {
24186       var str, e3 = n3.e;
24187       if (e3 === null)
24188         return n3.toString();
24189       str = coeffToString(n3.c);
24190       str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0");
24191       return n3.s < 0 ? "-" + str : str;
24192     }
24193     P2.absoluteValue = P2.abs = function() {
24194       var x2 = new BigNumber2(this);
24195       if (x2.s < 0)
24196         x2.s = 1;
24197       return x2;
24198     };
24199     P2.comparedTo = function(y2, b2) {
24200       return compare(this, new BigNumber2(y2, b2));
24201     };
24202     P2.decimalPlaces = P2.dp = function(dp, rm) {
24203       var c2, n3, v2, x2 = this;
24204       if (dp != null) {
24205         intCheck(dp, 0, MAX);
24206         if (rm == null)
24207           rm = ROUNDING_MODE;
24208         else
24209           intCheck(rm, 0, 8);
24210         return round(new BigNumber2(x2), dp + x2.e + 1, rm);
24211       }
24212       if (!(c2 = x2.c))
24213         return null;
24214       n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
24215       if (v2 = c2[v2])
24216         for (; v2 % 10 == 0; v2 /= 10, n3--)
24217           ;
24218       if (n3 < 0)
24219         n3 = 0;
24220       return n3;
24221     };
24222     P2.dividedBy = P2.div = function(y2, b2) {
24223       return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE);
24224     };
24225     P2.dividedToIntegerBy = P2.idiv = function(y2, b2) {
24226       return div(this, new BigNumber2(y2, b2), 0, 1);
24227     };
24228     P2.exponentiatedBy = P2.pow = function(n3, m2) {
24229       var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this;
24230       n3 = new BigNumber2(n3);
24231       if (n3.c && !n3.isInteger()) {
24232         throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3));
24233       }
24234       if (m2 != null)
24235         m2 = new BigNumber2(m2);
24236       nIsBig = n3.e > 14;
24237       if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) {
24238         y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3)));
24239         return m2 ? y2.mod(m2) : y2;
24240       }
24241       nIsNeg = n3.s < 0;
24242       if (m2) {
24243         if (m2.c ? !m2.c[0] : !m2.s)
24244           return new BigNumber2(NaN);
24245         isModExp = !nIsNeg && x2.isInteger() && m2.isInteger();
24246         if (isModExp)
24247           x2 = x2.mod(m2);
24248       } 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))) {
24249         k2 = x2.s < 0 && isOdd(n3) ? -0 : 0;
24250         if (x2.e > -1)
24251           k2 = 1 / k2;
24252         return new BigNumber2(nIsNeg ? 1 / k2 : k2);
24253       } else if (POW_PRECISION) {
24254         k2 = mathceil(POW_PRECISION / LOG_BASE + 2);
24255       }
24256       if (nIsBig) {
24257         half = new BigNumber2(0.5);
24258         if (nIsNeg)
24259           n3.s = 1;
24260         nIsOdd = isOdd(n3);
24261       } else {
24262         i3 = Math.abs(+valueOf(n3));
24263         nIsOdd = i3 % 2;
24264       }
24265       y2 = new BigNumber2(ONE);
24266       for (; ; ) {
24267         if (nIsOdd) {
24268           y2 = y2.times(x2);
24269           if (!y2.c)
24270             break;
24271           if (k2) {
24272             if (y2.c.length > k2)
24273               y2.c.length = k2;
24274           } else if (isModExp) {
24275             y2 = y2.mod(m2);
24276           }
24277         }
24278         if (i3) {
24279           i3 = mathfloor(i3 / 2);
24280           if (i3 === 0)
24281             break;
24282           nIsOdd = i3 % 2;
24283         } else {
24284           n3 = n3.times(half);
24285           round(n3, n3.e + 1, 1);
24286           if (n3.e > 14) {
24287             nIsOdd = isOdd(n3);
24288           } else {
24289             i3 = +valueOf(n3);
24290             if (i3 === 0)
24291               break;
24292             nIsOdd = i3 % 2;
24293           }
24294         }
24295         x2 = x2.times(x2);
24296         if (k2) {
24297           if (x2.c && x2.c.length > k2)
24298             x2.c.length = k2;
24299         } else if (isModExp) {
24300           x2 = x2.mod(m2);
24301         }
24302       }
24303       if (isModExp)
24304         return y2;
24305       if (nIsNeg)
24306         y2 = ONE.div(y2);
24307       return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2;
24308     };
24309     P2.integerValue = function(rm) {
24310       var n3 = new BigNumber2(this);
24311       if (rm == null)
24312         rm = ROUNDING_MODE;
24313       else
24314         intCheck(rm, 0, 8);
24315       return round(n3, n3.e + 1, rm);
24316     };
24317     P2.isEqualTo = P2.eq = function(y2, b2) {
24318       return compare(this, new BigNumber2(y2, b2)) === 0;
24319     };
24320     P2.isFinite = function() {
24321       return !!this.c;
24322     };
24323     P2.isGreaterThan = P2.gt = function(y2, b2) {
24324       return compare(this, new BigNumber2(y2, b2)) > 0;
24325     };
24326     P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) {
24327       return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0;
24328     };
24329     P2.isInteger = function() {
24330       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
24331     };
24332     P2.isLessThan = P2.lt = function(y2, b2) {
24333       return compare(this, new BigNumber2(y2, b2)) < 0;
24334     };
24335     P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) {
24336       return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0;
24337     };
24338     P2.isNaN = function() {
24339       return !this.s;
24340     };
24341     P2.isNegative = function() {
24342       return this.s < 0;
24343     };
24344     P2.isPositive = function() {
24345       return this.s > 0;
24346     };
24347     P2.isZero = function() {
24348       return !!this.c && this.c[0] == 0;
24349     };
24350     P2.minus = function(y2, b2) {
24351       var i3, j2, t2, xLTy, x2 = this, a2 = x2.s;
24352       y2 = new BigNumber2(y2, b2);
24353       b2 = y2.s;
24354       if (!a2 || !b2)
24355         return new BigNumber2(NaN);
24356       if (a2 != b2) {
24357         y2.s = -b2;
24358         return x2.plus(y2);
24359       }
24360       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24361       if (!xe2 || !ye2) {
24362         if (!xc || !yc)
24363           return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN);
24364         if (!xc[0] || !yc[0]) {
24365           return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : (
24366             // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
24367             ROUNDING_MODE == 3 ? -0 : 0
24368           ));
24369         }
24370       }
24371       xe2 = bitFloor(xe2);
24372       ye2 = bitFloor(ye2);
24373       xc = xc.slice();
24374       if (a2 = xe2 - ye2) {
24375         if (xLTy = a2 < 0) {
24376           a2 = -a2;
24377           t2 = xc;
24378         } else {
24379           ye2 = xe2;
24380           t2 = yc;
24381         }
24382         t2.reverse();
24383         for (b2 = a2; b2--; t2.push(0))
24384           ;
24385         t2.reverse();
24386       } else {
24387         j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2;
24388         for (a2 = b2 = 0; b2 < j2; b2++) {
24389           if (xc[b2] != yc[b2]) {
24390             xLTy = xc[b2] < yc[b2];
24391             break;
24392           }
24393         }
24394       }
24395       if (xLTy) {
24396         t2 = xc;
24397         xc = yc;
24398         yc = t2;
24399         y2.s = -y2.s;
24400       }
24401       b2 = (j2 = yc.length) - (i3 = xc.length);
24402       if (b2 > 0)
24403         for (; b2--; xc[i3++] = 0)
24404           ;
24405       b2 = BASE - 1;
24406       for (; j2 > a2; ) {
24407         if (xc[--j2] < yc[j2]) {
24408           for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2)
24409             ;
24410           --xc[i3];
24411           xc[j2] += BASE;
24412         }
24413         xc[j2] -= yc[j2];
24414       }
24415       for (; xc[0] == 0; xc.splice(0, 1), --ye2)
24416         ;
24417       if (!xc[0]) {
24418         y2.s = ROUNDING_MODE == 3 ? -1 : 1;
24419         y2.c = [y2.e = 0];
24420         return y2;
24421       }
24422       return normalise(y2, xc, ye2);
24423     };
24424     P2.modulo = P2.mod = function(y2, b2) {
24425       var q2, s2, x2 = this;
24426       y2 = new BigNumber2(y2, b2);
24427       if (!x2.c || !y2.s || y2.c && !y2.c[0]) {
24428         return new BigNumber2(NaN);
24429       } else if (!y2.c || x2.c && !x2.c[0]) {
24430         return new BigNumber2(x2);
24431       }
24432       if (MODULO_MODE == 9) {
24433         s2 = y2.s;
24434         y2.s = 1;
24435         q2 = div(x2, y2, 0, 3);
24436         y2.s = s2;
24437         q2.s *= s2;
24438       } else {
24439         q2 = div(x2, y2, 0, MODULO_MODE);
24440       }
24441       y2 = x2.minus(q2.times(y2));
24442       if (!y2.c[0] && MODULO_MODE == 1)
24443         y2.s = x2.s;
24444       return y2;
24445     };
24446     P2.multipliedBy = P2.times = function(y2, b2) {
24447       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;
24448       if (!xc || !yc || !xc[0] || !yc[0]) {
24449         if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
24450           y2.c = y2.e = y2.s = null;
24451         } else {
24452           y2.s *= x2.s;
24453           if (!xc || !yc) {
24454             y2.c = y2.e = null;
24455           } else {
24456             y2.c = [0];
24457             y2.e = 0;
24458           }
24459         }
24460         return y2;
24461       }
24462       e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE);
24463       y2.s *= x2.s;
24464       xcL = xc.length;
24465       ycL = yc.length;
24466       if (xcL < ycL) {
24467         zc = xc;
24468         xc = yc;
24469         yc = zc;
24470         i3 = xcL;
24471         xcL = ycL;
24472         ycL = i3;
24473       }
24474       for (i3 = xcL + ycL, zc = []; i3--; zc.push(0))
24475         ;
24476       base = BASE;
24477       sqrtBase = SQRT_BASE;
24478       for (i3 = ycL; --i3 >= 0; ) {
24479         c2 = 0;
24480         ylo = yc[i3] % sqrtBase;
24481         yhi = yc[i3] / sqrtBase | 0;
24482         for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) {
24483           xlo = xc[--k2] % sqrtBase;
24484           xhi = xc[k2] / sqrtBase | 0;
24485           m2 = yhi * xlo + xhi * ylo;
24486           xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2;
24487           c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi;
24488           zc[j2--] = xlo % base;
24489         }
24490         zc[j2] = c2;
24491       }
24492       if (c2) {
24493         ++e3;
24494       } else {
24495         zc.splice(0, 1);
24496       }
24497       return normalise(y2, zc, e3);
24498     };
24499     P2.negated = function() {
24500       var x2 = new BigNumber2(this);
24501       x2.s = -x2.s || null;
24502       return x2;
24503     };
24504     P2.plus = function(y2, b2) {
24505       var t2, x2 = this, a2 = x2.s;
24506       y2 = new BigNumber2(y2, b2);
24507       b2 = y2.s;
24508       if (!a2 || !b2)
24509         return new BigNumber2(NaN);
24510       if (a2 != b2) {
24511         y2.s = -b2;
24512         return x2.minus(y2);
24513       }
24514       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24515       if (!xe2 || !ye2) {
24516         if (!xc || !yc)
24517           return new BigNumber2(a2 / 0);
24518         if (!xc[0] || !yc[0])
24519           return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0);
24520       }
24521       xe2 = bitFloor(xe2);
24522       ye2 = bitFloor(ye2);
24523       xc = xc.slice();
24524       if (a2 = xe2 - ye2) {
24525         if (a2 > 0) {
24526           ye2 = xe2;
24527           t2 = yc;
24528         } else {
24529           a2 = -a2;
24530           t2 = xc;
24531         }
24532         t2.reverse();
24533         for (; a2--; t2.push(0))
24534           ;
24535         t2.reverse();
24536       }
24537       a2 = xc.length;
24538       b2 = yc.length;
24539       if (a2 - b2 < 0) {
24540         t2 = yc;
24541         yc = xc;
24542         xc = t2;
24543         b2 = a2;
24544       }
24545       for (a2 = 0; b2; ) {
24546         a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0;
24547         xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE;
24548       }
24549       if (a2) {
24550         xc = [a2].concat(xc);
24551         ++ye2;
24552       }
24553       return normalise(y2, xc, ye2);
24554     };
24555     P2.precision = P2.sd = function(sd, rm) {
24556       var c2, n3, v2, x2 = this;
24557       if (sd != null && sd !== !!sd) {
24558         intCheck(sd, 1, MAX);
24559         if (rm == null)
24560           rm = ROUNDING_MODE;
24561         else
24562           intCheck(rm, 0, 8);
24563         return round(new BigNumber2(x2), sd, rm);
24564       }
24565       if (!(c2 = x2.c))
24566         return null;
24567       v2 = c2.length - 1;
24568       n3 = v2 * LOG_BASE + 1;
24569       if (v2 = c2[v2]) {
24570         for (; v2 % 10 == 0; v2 /= 10, n3--)
24571           ;
24572         for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++)
24573           ;
24574       }
24575       if (sd && x2.e + 1 > n3)
24576         n3 = x2.e + 1;
24577       return n3;
24578     };
24579     P2.shiftedBy = function(k2) {
24580       intCheck(k2, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
24581       return this.times("1e" + k2);
24582     };
24583     P2.squareRoot = P2.sqrt = function() {
24584       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");
24585       if (s2 !== 1 || !c2 || !c2[0]) {
24586         return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0);
24587       }
24588       s2 = Math.sqrt(+valueOf(x2));
24589       if (s2 == 0 || s2 == 1 / 0) {
24590         n3 = coeffToString(c2);
24591         if ((n3.length + e3) % 2 == 0)
24592           n3 += "0";
24593         s2 = Math.sqrt(+n3);
24594         e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
24595         if (s2 == 1 / 0) {
24596           n3 = "5e" + e3;
24597         } else {
24598           n3 = s2.toExponential();
24599           n3 = n3.slice(0, n3.indexOf("e") + 1) + e3;
24600         }
24601         r2 = new BigNumber2(n3);
24602       } else {
24603         r2 = new BigNumber2(s2 + "");
24604       }
24605       if (r2.c[0]) {
24606         e3 = r2.e;
24607         s2 = e3 + dp;
24608         if (s2 < 3)
24609           s2 = 0;
24610         for (; ; ) {
24611           t2 = r2;
24612           r2 = half.times(t2.plus(div(x2, t2, dp, 1)));
24613           if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) {
24614             if (r2.e < e3)
24615               --s2;
24616             n3 = n3.slice(s2 - 3, s2 + 1);
24617             if (n3 == "9999" || !rep && n3 == "4999") {
24618               if (!rep) {
24619                 round(t2, t2.e + DECIMAL_PLACES + 2, 0);
24620                 if (t2.times(t2).eq(x2)) {
24621                   r2 = t2;
24622                   break;
24623                 }
24624               }
24625               dp += 4;
24626               s2 += 4;
24627               rep = 1;
24628             } else {
24629               if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") {
24630                 round(r2, r2.e + DECIMAL_PLACES + 2, 1);
24631                 m2 = !r2.times(r2).eq(x2);
24632               }
24633               break;
24634             }
24635           }
24636         }
24637       }
24638       return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2);
24639     };
24640     P2.toExponential = function(dp, rm) {
24641       if (dp != null) {
24642         intCheck(dp, 0, MAX);
24643         dp++;
24644       }
24645       return format2(this, dp, rm, 1);
24646     };
24647     P2.toFixed = function(dp, rm) {
24648       if (dp != null) {
24649         intCheck(dp, 0, MAX);
24650         dp = dp + this.e + 1;
24651       }
24652       return format2(this, dp, rm);
24653     };
24654     P2.toFormat = function(dp, rm, format3) {
24655       var str, x2 = this;
24656       if (format3 == null) {
24657         if (dp != null && rm && typeof rm == "object") {
24658           format3 = rm;
24659           rm = null;
24660         } else if (dp && typeof dp == "object") {
24661           format3 = dp;
24662           dp = rm = null;
24663         } else {
24664           format3 = FORMAT;
24665         }
24666       } else if (typeof format3 != "object") {
24667         throw Error(bignumberError + "Argument not an object: " + format3);
24668       }
24669       str = x2.toFixed(dp, rm);
24670       if (x2.c) {
24671         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;
24672         if (g22) {
24673           i3 = g1;
24674           g1 = g22;
24675           g22 = i3;
24676           len -= i3;
24677         }
24678         if (g1 > 0 && len > 0) {
24679           i3 = len % g1 || g1;
24680           intPart = intDigits.substr(0, i3);
24681           for (; i3 < len; i3 += g1)
24682             intPart += groupSeparator + intDigits.substr(i3, g1);
24683           if (g22 > 0)
24684             intPart += groupSeparator + intDigits.slice(i3);
24685           if (isNeg)
24686             intPart = "-" + intPart;
24687         }
24688         str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace(
24689           new RegExp("\\d{" + g22 + "}\\B", "g"),
24690           "$&" + (format3.fractionGroupSeparator || "")
24691         ) : fractionPart) : intPart;
24692       }
24693       return (format3.prefix || "") + str + (format3.suffix || "");
24694     };
24695     P2.toFraction = function(md) {
24696       var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c;
24697       if (md != null) {
24698         n3 = new BigNumber2(md);
24699         if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) {
24700           throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3));
24701         }
24702       }
24703       if (!xc)
24704         return new BigNumber2(x2);
24705       d2 = new BigNumber2(ONE);
24706       n1 = d0 = new BigNumber2(ONE);
24707       d1 = n0 = new BigNumber2(ONE);
24708       s2 = coeffToString(xc);
24709       e3 = d2.e = s2.length - x2.e - 1;
24710       d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2];
24711       md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3;
24712       exp2 = MAX_EXP;
24713       MAX_EXP = 1 / 0;
24714       n3 = new BigNumber2(s2);
24715       n0.c[0] = 0;
24716       for (; ; ) {
24717         q2 = div(n3, d2, 0, 1);
24718         d22 = d0.plus(q2.times(d1));
24719         if (d22.comparedTo(md) == 1)
24720           break;
24721         d0 = d1;
24722         d1 = d22;
24723         n1 = n0.plus(q2.times(d22 = n1));
24724         n0 = d22;
24725         d2 = n3.minus(q2.times(d22 = d2));
24726         n3 = d22;
24727       }
24728       d22 = div(md.minus(d0), d1, 0, 1);
24729       n0 = n0.plus(d22.times(n1));
24730       d0 = d0.plus(d22.times(d1));
24731       n0.s = n1.s = x2.s;
24732       e3 = e3 * 2;
24733       r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo(
24734         div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs()
24735       ) < 1 ? [n1, d1] : [n0, d0];
24736       MAX_EXP = exp2;
24737       return r2;
24738     };
24739     P2.toNumber = function() {
24740       return +valueOf(this);
24741     };
24742     P2.toPrecision = function(sd, rm) {
24743       if (sd != null)
24744         intCheck(sd, 1, MAX);
24745       return format2(this, sd, rm, 2);
24746     };
24747     P2.toString = function(b2) {
24748       var str, n3 = this, s2 = n3.s, e3 = n3.e;
24749       if (e3 === null) {
24750         if (s2) {
24751           str = "Infinity";
24752           if (s2 < 0)
24753             str = "-" + str;
24754         } else {
24755           str = "NaN";
24756         }
24757       } else {
24758         if (b2 == null) {
24759           str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0");
24760         } else if (b2 === 10 && alphabetHasNormalDecimalDigits) {
24761           n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE);
24762           str = toFixedPoint(coeffToString(n3.c), n3.e, "0");
24763         } else {
24764           intCheck(b2, 2, ALPHABET.length, "Base");
24765           str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true);
24766         }
24767         if (s2 < 0 && n3.c[0])
24768           str = "-" + str;
24769       }
24770       return str;
24771     };
24772     P2.valueOf = P2.toJSON = function() {
24773       return valueOf(this);
24774     };
24775     P2._isBigNumber = true;
24776     P2[Symbol.toStringTag] = "BigNumber";
24777     P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf;
24778     if (configObject != null)
24779       BigNumber2.set(configObject);
24780     return BigNumber2;
24781   }
24782   function bitFloor(n3) {
24783     var i3 = n3 | 0;
24784     return n3 > 0 || n3 === i3 ? i3 : i3 - 1;
24785   }
24786   function coeffToString(a2) {
24787     var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + "";
24788     for (; i3 < j2; ) {
24789       s2 = a2[i3++] + "";
24790       z2 = LOG_BASE - s2.length;
24791       for (; z2--; s2 = "0" + s2)
24792         ;
24793       r2 += s2;
24794     }
24795     for (j2 = r2.length; r2.charCodeAt(--j2) === 48; )
24796       ;
24797     return r2.slice(0, j2 + 1 || 1);
24798   }
24799   function compare(x2, y2) {
24800     var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e;
24801     if (!i3 || !j2)
24802       return null;
24803     a2 = xc && !xc[0];
24804     b2 = yc && !yc[0];
24805     if (a2 || b2)
24806       return a2 ? b2 ? 0 : -j2 : i3;
24807     if (i3 != j2)
24808       return i3;
24809     a2 = i3 < 0;
24810     b2 = k2 == l2;
24811     if (!xc || !yc)
24812       return b2 ? 0 : !xc ^ a2 ? 1 : -1;
24813     if (!b2)
24814       return k2 > l2 ^ a2 ? 1 : -1;
24815     j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2;
24816     for (i3 = 0; i3 < j2; i3++)
24817       if (xc[i3] != yc[i3])
24818         return xc[i3] > yc[i3] ^ a2 ? 1 : -1;
24819     return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1;
24820   }
24821   function intCheck(n3, min3, max3, name) {
24822     if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) {
24823       throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3));
24824     }
24825   }
24826   function isOdd(n3) {
24827     var k2 = n3.c.length - 1;
24828     return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0;
24829   }
24830   function toExponential(str, e3) {
24831     return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3;
24832   }
24833   function toFixedPoint(str, e3, z2) {
24834     var len, zs;
24835     if (e3 < 0) {
24836       for (zs = z2 + "."; ++e3; zs += z2)
24837         ;
24838       str = zs + str;
24839     } else {
24840       len = str.length;
24841       if (++e3 > len) {
24842         for (zs = z2, e3 -= len; --e3; zs += z2)
24843           ;
24844         str += zs;
24845       } else if (e3 < len) {
24846         str = str.slice(0, e3) + "." + str.slice(e3);
24847       }
24848     }
24849     return str;
24850   }
24851   var BigNumber = clone();
24852   var bignumber_default = BigNumber;
24853
24854   // node_modules/splaytree-ts/dist/index.js
24855   var SplayTreeNode = class {
24856     constructor(key) {
24857       __publicField(this, "key");
24858       __publicField(this, "left", null);
24859       __publicField(this, "right", null);
24860       this.key = key;
24861     }
24862   };
24863   var SplayTreeSetNode = class extends SplayTreeNode {
24864     constructor(key) {
24865       super(key);
24866     }
24867   };
24868   var SplayTree = class {
24869     constructor() {
24870       __publicField(this, "size", 0);
24871       __publicField(this, "modificationCount", 0);
24872       __publicField(this, "splayCount", 0);
24873     }
24874     splay(key) {
24875       const root3 = this.root;
24876       if (root3 == null) {
24877         this.compare(key, key);
24878         return -1;
24879       }
24880       let right = null;
24881       let newTreeRight = null;
24882       let left = null;
24883       let newTreeLeft = null;
24884       let current = root3;
24885       const compare2 = this.compare;
24886       let comp;
24887       while (true) {
24888         comp = compare2(current.key, key);
24889         if (comp > 0) {
24890           let currentLeft = current.left;
24891           if (currentLeft == null)
24892             break;
24893           comp = compare2(currentLeft.key, key);
24894           if (comp > 0) {
24895             current.left = currentLeft.right;
24896             currentLeft.right = current;
24897             current = currentLeft;
24898             currentLeft = current.left;
24899             if (currentLeft == null)
24900               break;
24901           }
24902           if (right == null) {
24903             newTreeRight = current;
24904           } else {
24905             right.left = current;
24906           }
24907           right = current;
24908           current = currentLeft;
24909         } else if (comp < 0) {
24910           let currentRight = current.right;
24911           if (currentRight == null)
24912             break;
24913           comp = compare2(currentRight.key, key);
24914           if (comp < 0) {
24915             current.right = currentRight.left;
24916             currentRight.left = current;
24917             current = currentRight;
24918             currentRight = current.right;
24919             if (currentRight == null)
24920               break;
24921           }
24922           if (left == null) {
24923             newTreeLeft = current;
24924           } else {
24925             left.right = current;
24926           }
24927           left = current;
24928           current = currentRight;
24929         } else {
24930           break;
24931         }
24932       }
24933       if (left != null) {
24934         left.right = current.left;
24935         current.left = newTreeLeft;
24936       }
24937       if (right != null) {
24938         right.left = current.right;
24939         current.right = newTreeRight;
24940       }
24941       if (this.root !== current) {
24942         this.root = current;
24943         this.splayCount++;
24944       }
24945       return comp;
24946     }
24947     splayMin(node) {
24948       let current = node;
24949       let nextLeft = current.left;
24950       while (nextLeft != null) {
24951         const left = nextLeft;
24952         current.left = left.right;
24953         left.right = current;
24954         current = left;
24955         nextLeft = current.left;
24956       }
24957       return current;
24958     }
24959     splayMax(node) {
24960       let current = node;
24961       let nextRight = current.right;
24962       while (nextRight != null) {
24963         const right = nextRight;
24964         current.right = right.left;
24965         right.left = current;
24966         current = right;
24967         nextRight = current.right;
24968       }
24969       return current;
24970     }
24971     _delete(key) {
24972       if (this.root == null)
24973         return null;
24974       const comp = this.splay(key);
24975       if (comp != 0)
24976         return null;
24977       let root3 = this.root;
24978       const result = root3;
24979       const left = root3.left;
24980       this.size--;
24981       if (left == null) {
24982         this.root = root3.right;
24983       } else {
24984         const right = root3.right;
24985         root3 = this.splayMax(left);
24986         root3.right = right;
24987         this.root = root3;
24988       }
24989       this.modificationCount++;
24990       return result;
24991     }
24992     addNewRoot(node, comp) {
24993       this.size++;
24994       this.modificationCount++;
24995       const root3 = this.root;
24996       if (root3 == null) {
24997         this.root = node;
24998         return;
24999       }
25000       if (comp < 0) {
25001         node.left = root3;
25002         node.right = root3.right;
25003         root3.right = null;
25004       } else {
25005         node.right = root3;
25006         node.left = root3.left;
25007         root3.left = null;
25008       }
25009       this.root = node;
25010     }
25011     _first() {
25012       const root3 = this.root;
25013       if (root3 == null)
25014         return null;
25015       this.root = this.splayMin(root3);
25016       return this.root;
25017     }
25018     _last() {
25019       const root3 = this.root;
25020       if (root3 == null)
25021         return null;
25022       this.root = this.splayMax(root3);
25023       return this.root;
25024     }
25025     clear() {
25026       this.root = null;
25027       this.size = 0;
25028       this.modificationCount++;
25029     }
25030     has(key) {
25031       return this.validKey(key) && this.splay(key) == 0;
25032     }
25033     defaultCompare() {
25034       return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
25035     }
25036     wrap() {
25037       return {
25038         getRoot: () => {
25039           return this.root;
25040         },
25041         setRoot: (root3) => {
25042           this.root = root3;
25043         },
25044         getSize: () => {
25045           return this.size;
25046         },
25047         getModificationCount: () => {
25048           return this.modificationCount;
25049         },
25050         getSplayCount: () => {
25051           return this.splayCount;
25052         },
25053         setSplayCount: (count) => {
25054           this.splayCount = count;
25055         },
25056         splay: (key) => {
25057           return this.splay(key);
25058         },
25059         has: (key) => {
25060           return this.has(key);
25061         }
25062       };
25063     }
25064   };
25065   var _a;
25066   var _SplayTreeSet = class _SplayTreeSet extends SplayTree {
25067     constructor(compare2, isValidKey) {
25068       super();
25069       __publicField(this, "root", null);
25070       __publicField(this, "compare");
25071       __publicField(this, "validKey");
25072       __publicField(this, _a, "[object Set]");
25073       this.compare = compare2 != null ? compare2 : this.defaultCompare();
25074       this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0;
25075     }
25076     delete(element) {
25077       if (!this.validKey(element))
25078         return false;
25079       return this._delete(element) != null;
25080     }
25081     deleteAll(elements) {
25082       for (const element of elements) {
25083         this.delete(element);
25084       }
25085     }
25086     forEach(f2) {
25087       const nodes = this[Symbol.iterator]();
25088       let result;
25089       while (result = nodes.next(), !result.done) {
25090         f2(result.value, result.value, this);
25091       }
25092     }
25093     add(element) {
25094       const compare2 = this.splay(element);
25095       if (compare2 != 0)
25096         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25097       return this;
25098     }
25099     addAndReturn(element) {
25100       const compare2 = this.splay(element);
25101       if (compare2 != 0)
25102         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25103       return this.root.key;
25104     }
25105     addAll(elements) {
25106       for (const element of elements) {
25107         this.add(element);
25108       }
25109     }
25110     isEmpty() {
25111       return this.root == null;
25112     }
25113     isNotEmpty() {
25114       return this.root != null;
25115     }
25116     single() {
25117       if (this.size == 0)
25118         throw "Bad state: No element";
25119       if (this.size > 1)
25120         throw "Bad state: Too many element";
25121       return this.root.key;
25122     }
25123     first() {
25124       if (this.size == 0)
25125         throw "Bad state: No element";
25126       return this._first().key;
25127     }
25128     last() {
25129       if (this.size == 0)
25130         throw "Bad state: No element";
25131       return this._last().key;
25132     }
25133     lastBefore(element) {
25134       if (element == null)
25135         throw "Invalid arguments(s)";
25136       if (this.root == null)
25137         return null;
25138       const comp = this.splay(element);
25139       if (comp < 0)
25140         return this.root.key;
25141       let node = this.root.left;
25142       if (node == null)
25143         return null;
25144       let nodeRight = node.right;
25145       while (nodeRight != null) {
25146         node = nodeRight;
25147         nodeRight = node.right;
25148       }
25149       return node.key;
25150     }
25151     firstAfter(element) {
25152       if (element == null)
25153         throw "Invalid arguments(s)";
25154       if (this.root == null)
25155         return null;
25156       const comp = this.splay(element);
25157       if (comp > 0)
25158         return this.root.key;
25159       let node = this.root.right;
25160       if (node == null)
25161         return null;
25162       let nodeLeft = node.left;
25163       while (nodeLeft != null) {
25164         node = nodeLeft;
25165         nodeLeft = node.left;
25166       }
25167       return node.key;
25168     }
25169     retainAll(elements) {
25170       const retainSet = new _SplayTreeSet(this.compare, this.validKey);
25171       const modificationCount = this.modificationCount;
25172       for (const object of elements) {
25173         if (modificationCount != this.modificationCount) {
25174           throw "Concurrent modification during iteration.";
25175         }
25176         if (this.validKey(object) && this.splay(object) == 0) {
25177           retainSet.add(this.root.key);
25178         }
25179       }
25180       if (retainSet.size != this.size) {
25181         this.root = retainSet.root;
25182         this.size = retainSet.size;
25183         this.modificationCount++;
25184       }
25185     }
25186     lookup(object) {
25187       if (!this.validKey(object))
25188         return null;
25189       const comp = this.splay(object);
25190       if (comp != 0)
25191         return null;
25192       return this.root.key;
25193     }
25194     intersection(other) {
25195       const result = new _SplayTreeSet(this.compare, this.validKey);
25196       for (const element of this) {
25197         if (other.has(element))
25198           result.add(element);
25199       }
25200       return result;
25201     }
25202     difference(other) {
25203       const result = new _SplayTreeSet(this.compare, this.validKey);
25204       for (const element of this) {
25205         if (!other.has(element))
25206           result.add(element);
25207       }
25208       return result;
25209     }
25210     union(other) {
25211       const u2 = this.clone();
25212       u2.addAll(other);
25213       return u2;
25214     }
25215     clone() {
25216       const set4 = new _SplayTreeSet(this.compare, this.validKey);
25217       set4.size = this.size;
25218       set4.root = this.copyNode(this.root);
25219       return set4;
25220     }
25221     copyNode(node) {
25222       if (node == null)
25223         return null;
25224       function copyChildren(node2, dest) {
25225         let left;
25226         let right;
25227         do {
25228           left = node2.left;
25229           right = node2.right;
25230           if (left != null) {
25231             const newLeft = new SplayTreeSetNode(left.key);
25232             dest.left = newLeft;
25233             copyChildren(left, newLeft);
25234           }
25235           if (right != null) {
25236             const newRight = new SplayTreeSetNode(right.key);
25237             dest.right = newRight;
25238             node2 = right;
25239             dest = newRight;
25240           }
25241         } while (right != null);
25242       }
25243       const result = new SplayTreeSetNode(node.key);
25244       copyChildren(node, result);
25245       return result;
25246     }
25247     toSet() {
25248       return this.clone();
25249     }
25250     entries() {
25251       return new SplayTreeSetEntryIterableIterator(this.wrap());
25252     }
25253     keys() {
25254       return this[Symbol.iterator]();
25255     }
25256     values() {
25257       return this[Symbol.iterator]();
25258     }
25259     [Symbol.iterator]() {
25260       return new SplayTreeKeyIterableIterator(this.wrap());
25261     }
25262   };
25263   _a = Symbol.toStringTag;
25264   var SplayTreeSet = _SplayTreeSet;
25265   var SplayTreeIterableIterator = class {
25266     constructor(tree) {
25267       __publicField(this, "tree");
25268       __publicField(this, "path", new Array());
25269       __publicField(this, "modificationCount", null);
25270       __publicField(this, "splayCount");
25271       this.tree = tree;
25272       this.splayCount = tree.getSplayCount();
25273     }
25274     [Symbol.iterator]() {
25275       return this;
25276     }
25277     next() {
25278       if (this.moveNext())
25279         return { done: false, value: this.current() };
25280       return { done: true, value: null };
25281     }
25282     current() {
25283       if (!this.path.length)
25284         return null;
25285       const node = this.path[this.path.length - 1];
25286       return this.getValue(node);
25287     }
25288     rebuildPath(key) {
25289       this.path.splice(0, this.path.length);
25290       this.tree.splay(key);
25291       this.path.push(this.tree.getRoot());
25292       this.splayCount = this.tree.getSplayCount();
25293     }
25294     findLeftMostDescendent(node) {
25295       while (node != null) {
25296         this.path.push(node);
25297         node = node.left;
25298       }
25299     }
25300     moveNext() {
25301       if (this.modificationCount != this.tree.getModificationCount()) {
25302         if (this.modificationCount == null) {
25303           this.modificationCount = this.tree.getModificationCount();
25304           let node2 = this.tree.getRoot();
25305           while (node2 != null) {
25306             this.path.push(node2);
25307             node2 = node2.left;
25308           }
25309           return this.path.length > 0;
25310         }
25311         throw "Concurrent modification during iteration.";
25312       }
25313       if (!this.path.length)
25314         return false;
25315       if (this.splayCount != this.tree.getSplayCount()) {
25316         this.rebuildPath(this.path[this.path.length - 1].key);
25317       }
25318       let node = this.path[this.path.length - 1];
25319       let next = node.right;
25320       if (next != null) {
25321         while (next != null) {
25322           this.path.push(next);
25323           next = next.left;
25324         }
25325         return true;
25326       }
25327       this.path.pop();
25328       while (this.path.length && this.path[this.path.length - 1].right === node) {
25329         node = this.path.pop();
25330       }
25331       return this.path.length > 0;
25332     }
25333   };
25334   var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator {
25335     getValue(node) {
25336       return node.key;
25337     }
25338   };
25339   var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator {
25340     getValue(node) {
25341       return [node.key, node.key];
25342     }
25343   };
25344
25345   // node_modules/polyclip-ts/dist/identity.js
25346   var identity_default3 = (x2) => {
25347     return x2;
25348   };
25349
25350   // node_modules/polyclip-ts/dist/snap.js
25351   var snap_default = (eps) => {
25352     if (eps) {
25353       const xTree = new SplayTreeSet(compare_default(eps));
25354       const yTree = new SplayTreeSet(compare_default(eps));
25355       const snapCoord = (coord2, tree) => {
25356         return tree.addAndReturn(coord2);
25357       };
25358       const snap = (v2) => {
25359         return {
25360           x: snapCoord(v2.x, xTree),
25361           y: snapCoord(v2.y, yTree)
25362         };
25363       };
25364       snap({ x: new bignumber_default(0), y: new bignumber_default(0) });
25365       return snap;
25366     }
25367     return identity_default3;
25368   };
25369
25370   // node_modules/polyclip-ts/dist/precision.js
25371   var set3 = (eps) => {
25372     return {
25373       set: (eps2) => {
25374         precision = set3(eps2);
25375       },
25376       reset: () => set3(eps),
25377       compare: compare_default(eps),
25378       snap: snap_default(eps),
25379       orient: orient_default(eps)
25380     };
25381   };
25382   var precision = set3();
25383
25384   // node_modules/polyclip-ts/dist/bbox.js
25385   var isInBbox = (bbox2, point2) => {
25386     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);
25387   };
25388   var getBboxOverlap = (b1, b2) => {
25389     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))
25390       return null;
25391     const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x;
25392     const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x;
25393     const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y;
25394     const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y;
25395     return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } };
25396   };
25397
25398   // node_modules/polyclip-ts/dist/vector.js
25399   var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x));
25400   var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y));
25401   var length = (v2) => dotProduct(v2, v2).sqrt();
25402   var sineOfAngle = (pShared, pBase, pAngle) => {
25403     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25404     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25405     return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25406   };
25407   var cosineOfAngle = (pShared, pBase, pAngle) => {
25408     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25409     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25410     return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25411   };
25412   var horizontalIntersection = (pt2, v2, y2) => {
25413     if (v2.y.isZero())
25414       return null;
25415     return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 };
25416   };
25417   var verticalIntersection = (pt2, v2, x2) => {
25418     if (v2.x.isZero())
25419       return null;
25420     return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) };
25421   };
25422   var intersection = (pt1, v1, pt2, v2) => {
25423     if (v1.x.isZero())
25424       return verticalIntersection(pt2, v2, pt1.x);
25425     if (v2.x.isZero())
25426       return verticalIntersection(pt1, v1, pt2.x);
25427     if (v1.y.isZero())
25428       return horizontalIntersection(pt2, v2, pt1.y);
25429     if (v2.y.isZero())
25430       return horizontalIntersection(pt1, v1, pt2.y);
25431     const kross = crossProduct(v1, v2);
25432     if (kross.isZero())
25433       return null;
25434     const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) };
25435     const d1 = crossProduct(ve2, v1).div(kross);
25436     const d2 = crossProduct(ve2, v2).div(kross);
25437     const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x));
25438     const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y));
25439     const x3 = x12.plus(x2).div(2);
25440     const y3 = y12.plus(y2).div(2);
25441     return { x: x3, y: y3 };
25442   };
25443
25444   // node_modules/polyclip-ts/dist/sweep-event.js
25445   var SweepEvent = class _SweepEvent {
25446     // Warning: 'point' input will be modified and re-used (for performance)
25447     constructor(point2, isLeft) {
25448       __publicField(this, "point");
25449       __publicField(this, "isLeft");
25450       __publicField(this, "segment");
25451       __publicField(this, "otherSE");
25452       __publicField(this, "consumedBy");
25453       if (point2.events === void 0)
25454         point2.events = [this];
25455       else
25456         point2.events.push(this);
25457       this.point = point2;
25458       this.isLeft = isLeft;
25459     }
25460     // for ordering sweep events in the sweep event queue
25461     static compare(a2, b2) {
25462       const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point);
25463       if (ptCmp !== 0)
25464         return ptCmp;
25465       if (a2.point !== b2.point)
25466         a2.link(b2);
25467       if (a2.isLeft !== b2.isLeft)
25468         return a2.isLeft ? 1 : -1;
25469       return Segment.compare(a2.segment, b2.segment);
25470     }
25471     // for ordering points in sweep line order
25472     static comparePoints(aPt, bPt) {
25473       if (aPt.x.isLessThan(bPt.x))
25474         return -1;
25475       if (aPt.x.isGreaterThan(bPt.x))
25476         return 1;
25477       if (aPt.y.isLessThan(bPt.y))
25478         return -1;
25479       if (aPt.y.isGreaterThan(bPt.y))
25480         return 1;
25481       return 0;
25482     }
25483     link(other) {
25484       if (other.point === this.point) {
25485         throw new Error("Tried to link already linked events");
25486       }
25487       const otherEvents = other.point.events;
25488       for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
25489         const evt = otherEvents[i3];
25490         this.point.events.push(evt);
25491         evt.point = this.point;
25492       }
25493       this.checkForConsuming();
25494     }
25495     /* Do a pass over our linked events and check to see if any pair
25496      * of segments match, and should be consumed. */
25497     checkForConsuming() {
25498       const numEvents = this.point.events.length;
25499       for (let i3 = 0; i3 < numEvents; i3++) {
25500         const evt1 = this.point.events[i3];
25501         if (evt1.segment.consumedBy !== void 0)
25502           continue;
25503         for (let j2 = i3 + 1; j2 < numEvents; j2++) {
25504           const evt2 = this.point.events[j2];
25505           if (evt2.consumedBy !== void 0)
25506             continue;
25507           if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
25508             continue;
25509           evt1.segment.consume(evt2.segment);
25510         }
25511       }
25512     }
25513     getAvailableLinkedEvents() {
25514       const events = [];
25515       for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
25516         const evt = this.point.events[i3];
25517         if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
25518           events.push(evt);
25519         }
25520       }
25521       return events;
25522     }
25523     /**
25524      * Returns a comparator function for sorting linked events that will
25525      * favor the event that will give us the smallest left-side angle.
25526      * All ring construction starts as low as possible heading to the right,
25527      * so by always turning left as sharp as possible we'll get polygons
25528      * without uncessary loops & holes.
25529      *
25530      * The comparator function has a compute cache such that it avoids
25531      * re-computing already-computed values.
25532      */
25533     getLeftmostComparator(baseEvent) {
25534       const cache = /* @__PURE__ */ new Map();
25535       const fillCache = (linkedEvent) => {
25536         const nextEvent = linkedEvent.otherSE;
25537         cache.set(linkedEvent, {
25538           sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
25539           cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
25540         });
25541       };
25542       return (a2, b2) => {
25543         if (!cache.has(a2))
25544           fillCache(a2);
25545         if (!cache.has(b2))
25546           fillCache(b2);
25547         const { sine: asine, cosine: acosine } = cache.get(a2);
25548         const { sine: bsine, cosine: bcosine } = cache.get(b2);
25549         if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) {
25550           if (acosine.isLessThan(bcosine))
25551             return 1;
25552           if (acosine.isGreaterThan(bcosine))
25553             return -1;
25554           return 0;
25555         }
25556         if (asine.isLessThan(0) && bsine.isLessThan(0)) {
25557           if (acosine.isLessThan(bcosine))
25558             return -1;
25559           if (acosine.isGreaterThan(bcosine))
25560             return 1;
25561           return 0;
25562         }
25563         if (bsine.isLessThan(asine))
25564           return -1;
25565         if (bsine.isGreaterThan(asine))
25566           return 1;
25567         return 0;
25568       };
25569     }
25570   };
25571
25572   // node_modules/polyclip-ts/dist/segment.js
25573   var segmentId = 0;
25574   var Segment = class _Segment {
25575     /* Warning: a reference to ringWindings input will be stored,
25576      *  and possibly will be later modified */
25577     constructor(leftSE, rightSE, rings, windings) {
25578       __publicField(this, "id");
25579       __publicField(this, "leftSE");
25580       __publicField(this, "rightSE");
25581       __publicField(this, "rings");
25582       __publicField(this, "windings");
25583       __publicField(this, "ringOut");
25584       __publicField(this, "consumedBy");
25585       __publicField(this, "prev");
25586       __publicField(this, "_prevInResult");
25587       __publicField(this, "_beforeState");
25588       __publicField(this, "_afterState");
25589       __publicField(this, "_isInResult");
25590       this.id = ++segmentId;
25591       this.leftSE = leftSE;
25592       leftSE.segment = this;
25593       leftSE.otherSE = rightSE;
25594       this.rightSE = rightSE;
25595       rightSE.segment = this;
25596       rightSE.otherSE = leftSE;
25597       this.rings = rings;
25598       this.windings = windings;
25599     }
25600     /* This compare() function is for ordering segments in the sweep
25601      * line tree, and does so according to the following criteria:
25602      *
25603      * Consider the vertical line that lies an infinestimal step to the
25604      * right of the right-more of the two left endpoints of the input
25605      * segments. Imagine slowly moving a point up from negative infinity
25606      * in the increasing y direction. Which of the two segments will that
25607      * point intersect first? That segment comes 'before' the other one.
25608      *
25609      * If neither segment would be intersected by such a line, (if one
25610      * or more of the segments are vertical) then the line to be considered
25611      * is directly on the right-more of the two left inputs.
25612      */
25613     static compare(a2, b2) {
25614       const alx = a2.leftSE.point.x;
25615       const blx = b2.leftSE.point.x;
25616       const arx = a2.rightSE.point.x;
25617       const brx = b2.rightSE.point.x;
25618       if (brx.isLessThan(alx))
25619         return 1;
25620       if (arx.isLessThan(blx))
25621         return -1;
25622       const aly = a2.leftSE.point.y;
25623       const bly = b2.leftSE.point.y;
25624       const ary = a2.rightSE.point.y;
25625       const bry = b2.rightSE.point.y;
25626       if (alx.isLessThan(blx)) {
25627         if (bly.isLessThan(aly) && bly.isLessThan(ary))
25628           return 1;
25629         if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary))
25630           return -1;
25631         const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
25632         if (aCmpBLeft < 0)
25633           return 1;
25634         if (aCmpBLeft > 0)
25635           return -1;
25636         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25637         if (bCmpARight !== 0)
25638           return bCmpARight;
25639         return -1;
25640       }
25641       if (alx.isGreaterThan(blx)) {
25642         if (aly.isLessThan(bly) && aly.isLessThan(bry))
25643           return -1;
25644         if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry))
25645           return 1;
25646         const bCmpALeft = b2.comparePoint(a2.leftSE.point);
25647         if (bCmpALeft !== 0)
25648           return bCmpALeft;
25649         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25650         if (aCmpBRight < 0)
25651           return 1;
25652         if (aCmpBRight > 0)
25653           return -1;
25654         return 1;
25655       }
25656       if (aly.isLessThan(bly))
25657         return -1;
25658       if (aly.isGreaterThan(bly))
25659         return 1;
25660       if (arx.isLessThan(brx)) {
25661         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25662         if (bCmpARight !== 0)
25663           return bCmpARight;
25664       }
25665       if (arx.isGreaterThan(brx)) {
25666         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25667         if (aCmpBRight < 0)
25668           return 1;
25669         if (aCmpBRight > 0)
25670           return -1;
25671       }
25672       if (!arx.eq(brx)) {
25673         const ay = ary.minus(aly);
25674         const ax = arx.minus(alx);
25675         const by = bry.minus(bly);
25676         const bx = brx.minus(blx);
25677         if (ay.isGreaterThan(ax) && by.isLessThan(bx))
25678           return 1;
25679         if (ay.isLessThan(ax) && by.isGreaterThan(bx))
25680           return -1;
25681       }
25682       if (arx.isGreaterThan(brx))
25683         return 1;
25684       if (arx.isLessThan(brx))
25685         return -1;
25686       if (ary.isLessThan(bry))
25687         return -1;
25688       if (ary.isGreaterThan(bry))
25689         return 1;
25690       if (a2.id < b2.id)
25691         return -1;
25692       if (a2.id > b2.id)
25693         return 1;
25694       return 0;
25695     }
25696     static fromRing(pt1, pt2, ring) {
25697       let leftPt, rightPt, winding;
25698       const cmpPts = SweepEvent.comparePoints(pt1, pt2);
25699       if (cmpPts < 0) {
25700         leftPt = pt1;
25701         rightPt = pt2;
25702         winding = 1;
25703       } else if (cmpPts > 0) {
25704         leftPt = pt2;
25705         rightPt = pt1;
25706         winding = -1;
25707       } else
25708         throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
25709       const leftSE = new SweepEvent(leftPt, true);
25710       const rightSE = new SweepEvent(rightPt, false);
25711       return new _Segment(leftSE, rightSE, [ring], [winding]);
25712     }
25713     /* When a segment is split, the rightSE is replaced with a new sweep event */
25714     replaceRightSE(newRightSE) {
25715       this.rightSE = newRightSE;
25716       this.rightSE.segment = this;
25717       this.rightSE.otherSE = this.leftSE;
25718       this.leftSE.otherSE = this.rightSE;
25719     }
25720     bbox() {
25721       const y12 = this.leftSE.point.y;
25722       const y2 = this.rightSE.point.y;
25723       return {
25724         ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 },
25725         ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 }
25726       };
25727     }
25728     /* A vector from the left point to the right */
25729     vector() {
25730       return {
25731         x: this.rightSE.point.x.minus(this.leftSE.point.x),
25732         y: this.rightSE.point.y.minus(this.leftSE.point.y)
25733       };
25734     }
25735     isAnEndpoint(pt2) {
25736       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);
25737     }
25738     /* Compare this segment with a point.
25739      *
25740      * A point P is considered to be colinear to a segment if there
25741      * exists a distance D such that if we travel along the segment
25742      * from one * endpoint towards the other a distance D, we find
25743      * ourselves at point P.
25744      *
25745      * Return value indicates:
25746      *
25747      *   1: point lies above the segment (to the left of vertical)
25748      *   0: point is colinear to segment
25749      *  -1: point lies below the segment (to the right of vertical)
25750      */
25751     comparePoint(point2) {
25752       return precision.orient(this.leftSE.point, point2, this.rightSE.point);
25753     }
25754     /**
25755      * Given another segment, returns the first non-trivial intersection
25756      * between the two segments (in terms of sweep line ordering), if it exists.
25757      *
25758      * A 'non-trivial' intersection is one that will cause one or both of the
25759      * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
25760      *
25761      *   * endpoint of segA with endpoint of segB --> trivial
25762      *   * endpoint of segA with point along segB --> non-trivial
25763      *   * endpoint of segB with point along segA --> non-trivial
25764      *   * point along segA with point along segB --> non-trivial
25765      *
25766      * If no non-trivial intersection exists, return null
25767      * Else, return null.
25768      */
25769     getIntersection(other) {
25770       const tBbox = this.bbox();
25771       const oBbox = other.bbox();
25772       const bboxOverlap = getBboxOverlap(tBbox, oBbox);
25773       if (bboxOverlap === null)
25774         return null;
25775       const tlp = this.leftSE.point;
25776       const trp = this.rightSE.point;
25777       const olp = other.leftSE.point;
25778       const orp = other.rightSE.point;
25779       const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
25780       const touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0;
25781       const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
25782       const touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0;
25783       if (touchesThisLSE && touchesOtherLSE) {
25784         if (touchesThisRSE && !touchesOtherRSE)
25785           return trp;
25786         if (!touchesThisRSE && touchesOtherRSE)
25787           return orp;
25788         return null;
25789       }
25790       if (touchesThisLSE) {
25791         if (touchesOtherRSE) {
25792           if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y))
25793             return null;
25794         }
25795         return tlp;
25796       }
25797       if (touchesOtherLSE) {
25798         if (touchesThisRSE) {
25799           if (trp.x.eq(olp.x) && trp.y.eq(olp.y))
25800             return null;
25801         }
25802         return olp;
25803       }
25804       if (touchesThisRSE && touchesOtherRSE)
25805         return null;
25806       if (touchesThisRSE)
25807         return trp;
25808       if (touchesOtherRSE)
25809         return orp;
25810       const pt2 = intersection(tlp, this.vector(), olp, other.vector());
25811       if (pt2 === null)
25812         return null;
25813       if (!isInBbox(bboxOverlap, pt2))
25814         return null;
25815       return precision.snap(pt2);
25816     }
25817     /**
25818      * Split the given segment into multiple segments on the given points.
25819      *  * Each existing segment will retain its leftSE and a new rightSE will be
25820      *    generated for it.
25821      *  * A new segment will be generated which will adopt the original segment's
25822      *    rightSE, and a new leftSE will be generated for it.
25823      *  * If there are more than two points given to split on, new segments
25824      *    in the middle will be generated with new leftSE and rightSE's.
25825      *  * An array of the newly generated SweepEvents will be returned.
25826      *
25827      * Warning: input array of points is modified
25828      */
25829     split(point2) {
25830       const newEvents = [];
25831       const alreadyLinked = point2.events !== void 0;
25832       const newLeftSE = new SweepEvent(point2, true);
25833       const newRightSE = new SweepEvent(point2, false);
25834       const oldRightSE = this.rightSE;
25835       this.replaceRightSE(newRightSE);
25836       newEvents.push(newRightSE);
25837       newEvents.push(newLeftSE);
25838       const newSeg = new _Segment(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
25839       if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
25840         newSeg.swapEvents();
25841       }
25842       if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
25843         this.swapEvents();
25844       }
25845       if (alreadyLinked) {
25846         newLeftSE.checkForConsuming();
25847         newRightSE.checkForConsuming();
25848       }
25849       return newEvents;
25850     }
25851     /* Swap which event is left and right */
25852     swapEvents() {
25853       const tmpEvt = this.rightSE;
25854       this.rightSE = this.leftSE;
25855       this.leftSE = tmpEvt;
25856       this.leftSE.isLeft = true;
25857       this.rightSE.isLeft = false;
25858       for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
25859         this.windings[i3] *= -1;
25860       }
25861     }
25862     /* Consume another segment. We take their rings under our wing
25863      * and mark them as consumed. Use for perfectly overlapping segments */
25864     consume(other) {
25865       let consumer = this;
25866       let consumee = other;
25867       while (consumer.consumedBy)
25868         consumer = consumer.consumedBy;
25869       while (consumee.consumedBy)
25870         consumee = consumee.consumedBy;
25871       const cmp = _Segment.compare(consumer, consumee);
25872       if (cmp === 0)
25873         return;
25874       if (cmp > 0) {
25875         const tmp = consumer;
25876         consumer = consumee;
25877         consumee = tmp;
25878       }
25879       if (consumer.prev === consumee) {
25880         const tmp = consumer;
25881         consumer = consumee;
25882         consumee = tmp;
25883       }
25884       for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
25885         const ring = consumee.rings[i3];
25886         const winding = consumee.windings[i3];
25887         const index = consumer.rings.indexOf(ring);
25888         if (index === -1) {
25889           consumer.rings.push(ring);
25890           consumer.windings.push(winding);
25891         } else
25892           consumer.windings[index] += winding;
25893       }
25894       consumee.rings = null;
25895       consumee.windings = null;
25896       consumee.consumedBy = consumer;
25897       consumee.leftSE.consumedBy = consumer.leftSE;
25898       consumee.rightSE.consumedBy = consumer.rightSE;
25899     }
25900     /* The first segment previous segment chain that is in the result */
25901     prevInResult() {
25902       if (this._prevInResult !== void 0)
25903         return this._prevInResult;
25904       if (!this.prev)
25905         this._prevInResult = null;
25906       else if (this.prev.isInResult())
25907         this._prevInResult = this.prev;
25908       else
25909         this._prevInResult = this.prev.prevInResult();
25910       return this._prevInResult;
25911     }
25912     beforeState() {
25913       if (this._beforeState !== void 0)
25914         return this._beforeState;
25915       if (!this.prev)
25916         this._beforeState = {
25917           rings: [],
25918           windings: [],
25919           multiPolys: []
25920         };
25921       else {
25922         const seg = this.prev.consumedBy || this.prev;
25923         this._beforeState = seg.afterState();
25924       }
25925       return this._beforeState;
25926     }
25927     afterState() {
25928       if (this._afterState !== void 0)
25929         return this._afterState;
25930       const beforeState = this.beforeState();
25931       this._afterState = {
25932         rings: beforeState.rings.slice(0),
25933         windings: beforeState.windings.slice(0),
25934         multiPolys: []
25935       };
25936       const ringsAfter = this._afterState.rings;
25937       const windingsAfter = this._afterState.windings;
25938       const mpsAfter = this._afterState.multiPolys;
25939       for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
25940         const ring = this.rings[i3];
25941         const winding = this.windings[i3];
25942         const index = ringsAfter.indexOf(ring);
25943         if (index === -1) {
25944           ringsAfter.push(ring);
25945           windingsAfter.push(winding);
25946         } else
25947           windingsAfter[index] += winding;
25948       }
25949       const polysAfter = [];
25950       const polysExclude = [];
25951       for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
25952         if (windingsAfter[i3] === 0)
25953           continue;
25954         const ring = ringsAfter[i3];
25955         const poly = ring.poly;
25956         if (polysExclude.indexOf(poly) !== -1)
25957           continue;
25958         if (ring.isExterior)
25959           polysAfter.push(poly);
25960         else {
25961           if (polysExclude.indexOf(poly) === -1)
25962             polysExclude.push(poly);
25963           const index = polysAfter.indexOf(ring.poly);
25964           if (index !== -1)
25965             polysAfter.splice(index, 1);
25966         }
25967       }
25968       for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
25969         const mp = polysAfter[i3].multiPoly;
25970         if (mpsAfter.indexOf(mp) === -1)
25971           mpsAfter.push(mp);
25972       }
25973       return this._afterState;
25974     }
25975     /* Is this segment part of the final result? */
25976     isInResult() {
25977       if (this.consumedBy)
25978         return false;
25979       if (this._isInResult !== void 0)
25980         return this._isInResult;
25981       const mpsBefore = this.beforeState().multiPolys;
25982       const mpsAfter = this.afterState().multiPolys;
25983       switch (operation_default.type) {
25984         case "union": {
25985           const noBefores = mpsBefore.length === 0;
25986           const noAfters = mpsAfter.length === 0;
25987           this._isInResult = noBefores !== noAfters;
25988           break;
25989         }
25990         case "intersection": {
25991           let least;
25992           let most;
25993           if (mpsBefore.length < mpsAfter.length) {
25994             least = mpsBefore.length;
25995             most = mpsAfter.length;
25996           } else {
25997             least = mpsAfter.length;
25998             most = mpsBefore.length;
25999           }
26000           this._isInResult = most === operation_default.numMultiPolys && least < most;
26001           break;
26002         }
26003         case "xor": {
26004           const diff = Math.abs(mpsBefore.length - mpsAfter.length);
26005           this._isInResult = diff % 2 === 1;
26006           break;
26007         }
26008         case "difference": {
26009           const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
26010           this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
26011           break;
26012         }
26013       }
26014       return this._isInResult;
26015     }
26016   };
26017
26018   // node_modules/polyclip-ts/dist/geom-in.js
26019   var RingIn = class {
26020     constructor(geomRing, poly, isExterior) {
26021       __publicField(this, "poly");
26022       __publicField(this, "isExterior");
26023       __publicField(this, "segments");
26024       __publicField(this, "bbox");
26025       if (!Array.isArray(geomRing) || geomRing.length === 0) {
26026         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26027       }
26028       this.poly = poly;
26029       this.isExterior = isExterior;
26030       this.segments = [];
26031       if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
26032         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26033       }
26034       const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) });
26035       this.bbox = {
26036         ll: { x: firstPoint.x, y: firstPoint.y },
26037         ur: { x: firstPoint.x, y: firstPoint.y }
26038       };
26039       let prevPoint = firstPoint;
26040       for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
26041         if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
26042           throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26043         }
26044         const point2 = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) });
26045         if (point2.x.eq(prevPoint.x) && point2.y.eq(prevPoint.y))
26046           continue;
26047         this.segments.push(Segment.fromRing(prevPoint, point2, this));
26048         if (point2.x.isLessThan(this.bbox.ll.x))
26049           this.bbox.ll.x = point2.x;
26050         if (point2.y.isLessThan(this.bbox.ll.y))
26051           this.bbox.ll.y = point2.y;
26052         if (point2.x.isGreaterThan(this.bbox.ur.x))
26053           this.bbox.ur.x = point2.x;
26054         if (point2.y.isGreaterThan(this.bbox.ur.y))
26055           this.bbox.ur.y = point2.y;
26056         prevPoint = point2;
26057       }
26058       if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) {
26059         this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
26060       }
26061     }
26062     getSweepEvents() {
26063       const sweepEvents = [];
26064       for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
26065         const segment = this.segments[i3];
26066         sweepEvents.push(segment.leftSE);
26067         sweepEvents.push(segment.rightSE);
26068       }
26069       return sweepEvents;
26070     }
26071   };
26072   var PolyIn = class {
26073     constructor(geomPoly, multiPoly) {
26074       __publicField(this, "multiPoly");
26075       __publicField(this, "exteriorRing");
26076       __publicField(this, "interiorRings");
26077       __publicField(this, "bbox");
26078       if (!Array.isArray(geomPoly)) {
26079         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26080       }
26081       this.exteriorRing = new RingIn(geomPoly[0], this, true);
26082       this.bbox = {
26083         ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
26084         ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
26085       };
26086       this.interiorRings = [];
26087       for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
26088         const ring = new RingIn(geomPoly[i3], this, false);
26089         if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x))
26090           this.bbox.ll.x = ring.bbox.ll.x;
26091         if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y))
26092           this.bbox.ll.y = ring.bbox.ll.y;
26093         if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26094           this.bbox.ur.x = ring.bbox.ur.x;
26095         if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26096           this.bbox.ur.y = ring.bbox.ur.y;
26097         this.interiorRings.push(ring);
26098       }
26099       this.multiPoly = multiPoly;
26100     }
26101     getSweepEvents() {
26102       const sweepEvents = this.exteriorRing.getSweepEvents();
26103       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26104         const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
26105         for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
26106           sweepEvents.push(ringSweepEvents[j2]);
26107         }
26108       }
26109       return sweepEvents;
26110     }
26111   };
26112   var MultiPolyIn = class {
26113     constructor(geom, isSubject) {
26114       __publicField(this, "isSubject");
26115       __publicField(this, "polys");
26116       __publicField(this, "bbox");
26117       if (!Array.isArray(geom)) {
26118         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26119       }
26120       try {
26121         if (typeof geom[0][0][0] === "number")
26122           geom = [geom];
26123       } catch (ex) {
26124       }
26125       this.polys = [];
26126       this.bbox = {
26127         ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) },
26128         ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) }
26129       };
26130       for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
26131         const poly = new PolyIn(geom[i3], this);
26132         if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x))
26133           this.bbox.ll.x = poly.bbox.ll.x;
26134         if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y))
26135           this.bbox.ll.y = poly.bbox.ll.y;
26136         if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26137           this.bbox.ur.x = poly.bbox.ur.x;
26138         if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26139           this.bbox.ur.y = poly.bbox.ur.y;
26140         this.polys.push(poly);
26141       }
26142       this.isSubject = isSubject;
26143     }
26144     getSweepEvents() {
26145       const sweepEvents = [];
26146       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26147         const polySweepEvents = this.polys[i3].getSweepEvents();
26148         for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
26149           sweepEvents.push(polySweepEvents[j2]);
26150         }
26151       }
26152       return sweepEvents;
26153     }
26154   };
26155
26156   // node_modules/polyclip-ts/dist/geom-out.js
26157   var RingOut = class _RingOut {
26158     constructor(events) {
26159       __publicField(this, "events");
26160       __publicField(this, "poly");
26161       __publicField(this, "_isExteriorRing");
26162       __publicField(this, "_enclosingRing");
26163       this.events = events;
26164       for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
26165         events[i3].segment.ringOut = this;
26166       }
26167       this.poly = null;
26168     }
26169     /* Given the segments from the sweep line pass, compute & return a series
26170      * of closed rings from all the segments marked to be part of the result */
26171     static factory(allSegments) {
26172       const ringsOut = [];
26173       for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
26174         const segment = allSegments[i3];
26175         if (!segment.isInResult() || segment.ringOut)
26176           continue;
26177         let prevEvent = null;
26178         let event = segment.leftSE;
26179         let nextEvent = segment.rightSE;
26180         const events = [event];
26181         const startingPoint = event.point;
26182         const intersectionLEs = [];
26183         while (true) {
26184           prevEvent = event;
26185           event = nextEvent;
26186           events.push(event);
26187           if (event.point === startingPoint)
26188             break;
26189           while (true) {
26190             const availableLEs = event.getAvailableLinkedEvents();
26191             if (availableLEs.length === 0) {
26192               const firstPt = events[0].point;
26193               const lastPt = events[events.length - 1].point;
26194               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, "]."));
26195             }
26196             if (availableLEs.length === 1) {
26197               nextEvent = availableLEs[0].otherSE;
26198               break;
26199             }
26200             let indexLE = null;
26201             for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
26202               if (intersectionLEs[j2].point === event.point) {
26203                 indexLE = j2;
26204                 break;
26205               }
26206             }
26207             if (indexLE !== null) {
26208               const intersectionLE = intersectionLEs.splice(indexLE)[0];
26209               const ringEvents = events.splice(intersectionLE.index);
26210               ringEvents.unshift(ringEvents[0].otherSE);
26211               ringsOut.push(new _RingOut(ringEvents.reverse()));
26212               continue;
26213             }
26214             intersectionLEs.push({
26215               index: events.length,
26216               point: event.point
26217             });
26218             const comparator = event.getLeftmostComparator(prevEvent);
26219             nextEvent = availableLEs.sort(comparator)[0].otherSE;
26220             break;
26221           }
26222         }
26223         ringsOut.push(new _RingOut(events));
26224       }
26225       return ringsOut;
26226     }
26227     getGeom() {
26228       let prevPt = this.events[0].point;
26229       const points = [prevPt];
26230       for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
26231         const pt3 = this.events[i3].point;
26232         const nextPt2 = this.events[i3 + 1].point;
26233         if (precision.orient(pt3, prevPt, nextPt2) === 0)
26234           continue;
26235         points.push(pt3);
26236         prevPt = pt3;
26237       }
26238       if (points.length === 1)
26239         return null;
26240       const pt2 = points[0];
26241       const nextPt = points[1];
26242       if (precision.orient(pt2, prevPt, nextPt) === 0)
26243         points.shift();
26244       points.push(points[0]);
26245       const step = this.isExteriorRing() ? 1 : -1;
26246       const iStart = this.isExteriorRing() ? 0 : points.length - 1;
26247       const iEnd = this.isExteriorRing() ? points.length : -1;
26248       const orderedPoints = [];
26249       for (let i3 = iStart; i3 != iEnd; i3 += step)
26250         orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]);
26251       return orderedPoints;
26252     }
26253     isExteriorRing() {
26254       if (this._isExteriorRing === void 0) {
26255         const enclosing = this.enclosingRing();
26256         this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
26257       }
26258       return this._isExteriorRing;
26259     }
26260     enclosingRing() {
26261       if (this._enclosingRing === void 0) {
26262         this._enclosingRing = this._calcEnclosingRing();
26263       }
26264       return this._enclosingRing;
26265     }
26266     /* Returns the ring that encloses this one, if any */
26267     _calcEnclosingRing() {
26268       var _a2, _b;
26269       let leftMostEvt = this.events[0];
26270       for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
26271         const evt = this.events[i3];
26272         if (SweepEvent.compare(leftMostEvt, evt) > 0)
26273           leftMostEvt = evt;
26274       }
26275       let prevSeg = leftMostEvt.segment.prevInResult();
26276       let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26277       while (true) {
26278         if (!prevSeg)
26279           return null;
26280         if (!prevPrevSeg)
26281           return prevSeg.ringOut;
26282         if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
26283           if (((_a2 = prevPrevSeg.ringOut) == null ? void 0 : _a2.enclosingRing()) !== prevSeg.ringOut) {
26284             return prevSeg.ringOut;
26285           } else
26286             return (_b = prevSeg.ringOut) == null ? void 0 : _b.enclosingRing();
26287         }
26288         prevSeg = prevPrevSeg.prevInResult();
26289         prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26290       }
26291     }
26292   };
26293   var PolyOut = class {
26294     constructor(exteriorRing) {
26295       __publicField(this, "exteriorRing");
26296       __publicField(this, "interiorRings");
26297       this.exteriorRing = exteriorRing;
26298       exteriorRing.poly = this;
26299       this.interiorRings = [];
26300     }
26301     addInterior(ring) {
26302       this.interiorRings.push(ring);
26303       ring.poly = this;
26304     }
26305     getGeom() {
26306       const geom = [this.exteriorRing.getGeom()];
26307       if (geom[0] === null)
26308         return null;
26309       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26310         const ringGeom = this.interiorRings[i3].getGeom();
26311         if (ringGeom === null)
26312           continue;
26313         geom.push(ringGeom);
26314       }
26315       return geom;
26316     }
26317   };
26318   var MultiPolyOut = class {
26319     constructor(rings) {
26320       __publicField(this, "rings");
26321       __publicField(this, "polys");
26322       this.rings = rings;
26323       this.polys = this._composePolys(rings);
26324     }
26325     getGeom() {
26326       const geom = [];
26327       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26328         const polyGeom = this.polys[i3].getGeom();
26329         if (polyGeom === null)
26330           continue;
26331         geom.push(polyGeom);
26332       }
26333       return geom;
26334     }
26335     _composePolys(rings) {
26336       var _a2;
26337       const polys = [];
26338       for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
26339         const ring = rings[i3];
26340         if (ring.poly)
26341           continue;
26342         if (ring.isExteriorRing())
26343           polys.push(new PolyOut(ring));
26344         else {
26345           const enclosingRing = ring.enclosingRing();
26346           if (!(enclosingRing == null ? void 0 : enclosingRing.poly))
26347             polys.push(new PolyOut(enclosingRing));
26348           (_a2 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a2.addInterior(ring);
26349         }
26350       }
26351       return polys;
26352     }
26353   };
26354
26355   // node_modules/polyclip-ts/dist/sweep-line.js
26356   var SweepLine = class {
26357     constructor(queue, comparator = Segment.compare) {
26358       __publicField(this, "queue");
26359       __publicField(this, "tree");
26360       __publicField(this, "segments");
26361       this.queue = queue;
26362       this.tree = new SplayTreeSet(comparator);
26363       this.segments = [];
26364     }
26365     process(event) {
26366       const segment = event.segment;
26367       const newEvents = [];
26368       if (event.consumedBy) {
26369         if (event.isLeft)
26370           this.queue.delete(event.otherSE);
26371         else
26372           this.tree.delete(segment);
26373         return newEvents;
26374       }
26375       if (event.isLeft)
26376         this.tree.add(segment);
26377       let prevSeg = segment;
26378       let nextSeg = segment;
26379       do {
26380         prevSeg = this.tree.lastBefore(prevSeg);
26381       } while (prevSeg != null && prevSeg.consumedBy != void 0);
26382       do {
26383         nextSeg = this.tree.firstAfter(nextSeg);
26384       } while (nextSeg != null && nextSeg.consumedBy != void 0);
26385       if (event.isLeft) {
26386         let prevMySplitter = null;
26387         if (prevSeg) {
26388           const prevInter = prevSeg.getIntersection(segment);
26389           if (prevInter !== null) {
26390             if (!segment.isAnEndpoint(prevInter))
26391               prevMySplitter = prevInter;
26392             if (!prevSeg.isAnEndpoint(prevInter)) {
26393               const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
26394               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26395                 newEvents.push(newEventsFromSplit[i3]);
26396               }
26397             }
26398           }
26399         }
26400         let nextMySplitter = null;
26401         if (nextSeg) {
26402           const nextInter = nextSeg.getIntersection(segment);
26403           if (nextInter !== null) {
26404             if (!segment.isAnEndpoint(nextInter))
26405               nextMySplitter = nextInter;
26406             if (!nextSeg.isAnEndpoint(nextInter)) {
26407               const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
26408               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26409                 newEvents.push(newEventsFromSplit[i3]);
26410               }
26411             }
26412           }
26413         }
26414         if (prevMySplitter !== null || nextMySplitter !== null) {
26415           let mySplitter = null;
26416           if (prevMySplitter === null)
26417             mySplitter = nextMySplitter;
26418           else if (nextMySplitter === null)
26419             mySplitter = prevMySplitter;
26420           else {
26421             const cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter);
26422             mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
26423           }
26424           this.queue.delete(segment.rightSE);
26425           newEvents.push(segment.rightSE);
26426           const newEventsFromSplit = segment.split(mySplitter);
26427           for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26428             newEvents.push(newEventsFromSplit[i3]);
26429           }
26430         }
26431         if (newEvents.length > 0) {
26432           this.tree.delete(segment);
26433           newEvents.push(event);
26434         } else {
26435           this.segments.push(segment);
26436           segment.prev = prevSeg;
26437         }
26438       } else {
26439         if (prevSeg && nextSeg) {
26440           const inter = prevSeg.getIntersection(nextSeg);
26441           if (inter !== null) {
26442             if (!prevSeg.isAnEndpoint(inter)) {
26443               const newEventsFromSplit = this._splitSafely(prevSeg, inter);
26444               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26445                 newEvents.push(newEventsFromSplit[i3]);
26446               }
26447             }
26448             if (!nextSeg.isAnEndpoint(inter)) {
26449               const newEventsFromSplit = this._splitSafely(nextSeg, inter);
26450               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26451                 newEvents.push(newEventsFromSplit[i3]);
26452               }
26453             }
26454           }
26455         }
26456         this.tree.delete(segment);
26457       }
26458       return newEvents;
26459     }
26460     /* Safely split a segment that is currently in the datastructures
26461      * IE - a segment other than the one that is currently being processed. */
26462     _splitSafely(seg, pt2) {
26463       this.tree.delete(seg);
26464       const rightSE = seg.rightSE;
26465       this.queue.delete(rightSE);
26466       const newEvents = seg.split(pt2);
26467       newEvents.push(rightSE);
26468       if (seg.consumedBy === void 0)
26469         this.tree.add(seg);
26470       return newEvents;
26471     }
26472   };
26473
26474   // node_modules/polyclip-ts/dist/operation.js
26475   var Operation = class {
26476     constructor() {
26477       __publicField(this, "type");
26478       __publicField(this, "numMultiPolys");
26479     }
26480     run(type2, geom, moreGeoms) {
26481       operation.type = type2;
26482       const multipolys = [new MultiPolyIn(geom, true)];
26483       for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
26484         multipolys.push(new MultiPolyIn(moreGeoms[i3], false));
26485       }
26486       operation.numMultiPolys = multipolys.length;
26487       if (operation.type === "difference") {
26488         const subject = multipolys[0];
26489         let i3 = 1;
26490         while (i3 < multipolys.length) {
26491           if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null)
26492             i3++;
26493           else
26494             multipolys.splice(i3, 1);
26495         }
26496       }
26497       if (operation.type === "intersection") {
26498         for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26499           const mpA = multipolys[i3];
26500           for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
26501             if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null)
26502               return [];
26503           }
26504         }
26505       }
26506       const queue = new SplayTreeSet(SweepEvent.compare);
26507       for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26508         const sweepEvents = multipolys[i3].getSweepEvents();
26509         for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
26510           queue.add(sweepEvents[j2]);
26511         }
26512       }
26513       const sweepLine = new SweepLine(queue);
26514       let evt = null;
26515       if (queue.size != 0) {
26516         evt = queue.first();
26517         queue.delete(evt);
26518       }
26519       while (evt) {
26520         const newEvents = sweepLine.process(evt);
26521         for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
26522           const evt2 = newEvents[i3];
26523           if (evt2.consumedBy === void 0)
26524             queue.add(evt2);
26525         }
26526         if (queue.size != 0) {
26527           evt = queue.first();
26528           queue.delete(evt);
26529         } else {
26530           evt = null;
26531         }
26532       }
26533       precision.reset();
26534       const ringsOut = RingOut.factory(sweepLine.segments);
26535       const result = new MultiPolyOut(ringsOut);
26536       return result.getGeom();
26537     }
26538   };
26539   var operation = new Operation();
26540   var operation_default = operation;
26541
26542   // node_modules/polyclip-ts/dist/index.js
26543   var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms);
26544   var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms);
26545   var setPrecision = precision.set;
26546
26547   // node_modules/@rapideditor/location-conflation/index.mjs
26548   var import_geojson_area = __toESM(require_geojson_area(), 1);
26549   var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1);
26550   var import_geojson_precision = __toESM(require_geojson_precision(), 1);
26551   var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1);
26552   var LocationConflation = class {
26553     // constructor
26554     //
26555     // `fc`  Optional FeatureCollection of known features
26556     //
26557     // Optionally pass a GeoJSON FeatureCollection of known features which we can refer to later.
26558     // Each feature must have a filename-like `id`, for example: `something.geojson`
26559     //
26560     // {
26561     //   "type": "FeatureCollection"
26562     //   "features": [
26563     //     {
26564     //       "type": "Feature",
26565     //       "id": "philly_metro.geojson",
26566     //       "properties": { … },
26567     //       "geometry": { … }
26568     //     }
26569     //   ]
26570     // }
26571     constructor(fc) {
26572       this._cache = {};
26573       this.strict = true;
26574       if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) {
26575         fc.features.forEach((feature3) => {
26576           feature3.properties = feature3.properties || {};
26577           let props = feature3.properties;
26578           let id2 = feature3.id || props.id;
26579           if (!id2 || !/^\S+\.geojson$/i.test(id2))
26580             return;
26581           id2 = id2.toLowerCase();
26582           feature3.id = id2;
26583           props.id = id2;
26584           if (!props.area) {
26585             const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26586             props.area = Number(area.toFixed(2));
26587           }
26588           this._cache[id2] = feature3;
26589         });
26590       }
26591       let world = _cloneDeep(feature("Q2"));
26592       world.geometry = {
26593         type: "Polygon",
26594         coordinates: [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
26595       };
26596       world.id = "Q2";
26597       world.properties.id = "Q2";
26598       world.properties.area = import_geojson_area.default.geometry(world.geometry) / 1e6;
26599       this._cache.Q2 = world;
26600     }
26601     // validateLocation
26602     // `location`  The location to validate
26603     //
26604     // Pass a `location` value to validate
26605     //
26606     // Returns a result like:
26607     //   {
26608     //     type:     'point', 'geojson', or 'countrycoder'
26609     //     location:  the queried location
26610     //     id:        the stable identifier for the feature
26611     //   }
26612     // or `null` if the location is invalid
26613     //
26614     validateLocation(location) {
26615       if (Array.isArray(location) && (location.length === 2 || location.length === 3)) {
26616         const lon = location[0];
26617         const lat = location[1];
26618         const radius = location[2];
26619         if (Number.isFinite(lon) && lon >= -180 && lon <= 180 && Number.isFinite(lat) && lat >= -90 && lat <= 90 && (location.length === 2 || Number.isFinite(radius) && radius > 0)) {
26620           const id2 = "[" + location.toString() + "]";
26621           return { type: "point", location, id: id2 };
26622         }
26623       } else if (typeof location === "string" && /^\S+\.geojson$/i.test(location)) {
26624         const id2 = location.toLowerCase();
26625         if (this._cache[id2]) {
26626           return { type: "geojson", location, id: id2 };
26627         }
26628       } else if (typeof location === "string" || typeof location === "number") {
26629         const feature3 = feature(location);
26630         if (feature3) {
26631           const id2 = feature3.properties.wikidata;
26632           return { type: "countrycoder", location, id: id2 };
26633         }
26634       }
26635       if (this.strict) {
26636         throw new Error('validateLocation:  Invalid location: "'.concat(location, '".'));
26637       } else {
26638         return null;
26639       }
26640     }
26641     // resolveLocation
26642     // `location`  The location to resolve
26643     //
26644     // Pass a `location` value to resolve
26645     //
26646     // Returns a result like:
26647     //   {
26648     //     type:      'point', 'geojson', or 'countrycoder'
26649     //     location:  the queried location
26650     //     id:        a stable identifier for the feature
26651     //     feature:   the resolved GeoJSON feature
26652     //   }
26653     //  or `null` if the location is invalid
26654     //
26655     resolveLocation(location) {
26656       const valid = this.validateLocation(location);
26657       if (!valid)
26658         return null;
26659       const id2 = valid.id;
26660       if (this._cache[id2]) {
26661         return Object.assign(valid, { feature: this._cache[id2] });
26662       }
26663       if (valid.type === "point") {
26664         const lon = location[0];
26665         const lat = location[1];
26666         const radius = location[2] || 25;
26667         const EDGES = 10;
26668         const PRECISION = 3;
26669         const area = Math.PI * radius * radius;
26670         const feature3 = this._cache[id2] = (0, import_geojson_precision.default)({
26671           type: "Feature",
26672           id: id2,
26673           properties: { id: id2, area: Number(area.toFixed(2)) },
26674           geometry: (0, import_circle_to_polygon.default)([lon, lat], radius * 1e3, EDGES)
26675           // km to m
26676         }, PRECISION);
26677         return Object.assign(valid, { feature: feature3 });
26678       } else if (valid.type === "geojson") {
26679       } else if (valid.type === "countrycoder") {
26680         let feature3 = _cloneDeep(feature(id2));
26681         let props = feature3.properties;
26682         if (Array.isArray(props.members)) {
26683           let aggregate = aggregateFeature(id2);
26684           aggregate.geometry.coordinates = _clip([aggregate], "UNION").geometry.coordinates;
26685           feature3.geometry = aggregate.geometry;
26686         }
26687         if (!props.area) {
26688           const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26689           props.area = Number(area.toFixed(2));
26690         }
26691         feature3.id = id2;
26692         props.id = id2;
26693         this._cache[id2] = feature3;
26694         return Object.assign(valid, { feature: feature3 });
26695       }
26696       if (this.strict) {
26697         throw new Error("resolveLocation:  Couldn't resolve location \"".concat(location, '".'));
26698       } else {
26699         return null;
26700       }
26701     }
26702     // validateLocationSet
26703     // `locationSet`  the locationSet to validate
26704     //
26705     // Pass a locationSet Object to validate like:
26706     //   {
26707     //     include: [ Array of locations ],
26708     //     exclude: [ Array of locations ]
26709     //   }
26710     //
26711     // Returns a result like:
26712     //   {
26713     //     type:         'locationset'
26714     //     locationSet:  the queried locationSet
26715     //     id:           the stable identifier for the feature
26716     //   }
26717     // or `null` if the locationSet is invalid
26718     //
26719     validateLocationSet(locationSet) {
26720       locationSet = locationSet || {};
26721       const validator = this.validateLocation.bind(this);
26722       let include = (locationSet.include || []).map(validator).filter(Boolean);
26723       let exclude = (locationSet.exclude || []).map(validator).filter(Boolean);
26724       if (!include.length) {
26725         if (this.strict) {
26726           throw new Error("validateLocationSet:  LocationSet includes nothing.");
26727         } else {
26728           locationSet.include = ["Q2"];
26729           include = [{ type: "countrycoder", location: "Q2", id: "Q2" }];
26730         }
26731       }
26732       include.sort(_sortLocations);
26733       let id2 = "+[" + include.map((d2) => d2.id).join(",") + "]";
26734       if (exclude.length) {
26735         exclude.sort(_sortLocations);
26736         id2 += "-[" + exclude.map((d2) => d2.id).join(",") + "]";
26737       }
26738       return { type: "locationset", locationSet, id: id2 };
26739     }
26740     // resolveLocationSet
26741     // `locationSet`  the locationSet to resolve
26742     //
26743     // Pass a locationSet Object to validate like:
26744     //   {
26745     //     include: [ Array of locations ],
26746     //     exclude: [ Array of locations ]
26747     //   }
26748     //
26749     // Returns a result like:
26750     //   {
26751     //     type:         'locationset'
26752     //     locationSet:  the queried locationSet
26753     //     id:           the stable identifier for the feature
26754     //     feature:      the resolved GeoJSON feature
26755     //   }
26756     // or `null` if the locationSet is invalid
26757     //
26758     resolveLocationSet(locationSet) {
26759       locationSet = locationSet || {};
26760       const valid = this.validateLocationSet(locationSet);
26761       if (!valid)
26762         return null;
26763       const id2 = valid.id;
26764       if (this._cache[id2]) {
26765         return Object.assign(valid, { feature: this._cache[id2] });
26766       }
26767       const resolver = this.resolveLocation.bind(this);
26768       const includes = (locationSet.include || []).map(resolver).filter(Boolean);
26769       const excludes = (locationSet.exclude || []).map(resolver).filter(Boolean);
26770       if (includes.length === 1 && excludes.length === 0) {
26771         return Object.assign(valid, { feature: includes[0].feature });
26772       }
26773       const includeGeoJSON = _clip(includes.map((d2) => d2.feature), "UNION");
26774       const excludeGeoJSON = _clip(excludes.map((d2) => d2.feature), "UNION");
26775       let resultGeoJSON = excludeGeoJSON ? _clip([includeGeoJSON, excludeGeoJSON], "DIFFERENCE") : includeGeoJSON;
26776       const area = import_geojson_area.default.geometry(resultGeoJSON.geometry) / 1e6;
26777       resultGeoJSON.id = id2;
26778       resultGeoJSON.properties = { id: id2, area: Number(area.toFixed(2)) };
26779       this._cache[id2] = resultGeoJSON;
26780       return Object.assign(valid, { feature: resultGeoJSON });
26781     }
26782     // stringify
26783     // convenience method to prettyStringify the given object
26784     stringify(obj, options2) {
26785       return (0, import_json_stringify_pretty_compact.default)(obj, options2);
26786     }
26787   };
26788   function _clip(features, which) {
26789     if (!Array.isArray(features) || !features.length)
26790       return null;
26791     const fn = { UNION: union, DIFFERENCE: difference }[which];
26792     const args = features.map((feature3) => feature3.geometry.coordinates);
26793     const coords = fn.apply(null, args);
26794     return {
26795       type: "Feature",
26796       properties: {},
26797       geometry: {
26798         type: whichType(coords),
26799         coordinates: coords
26800       }
26801     };
26802     function whichType(coords2) {
26803       const a2 = Array.isArray(coords2);
26804       const b2 = a2 && Array.isArray(coords2[0]);
26805       const c2 = b2 && Array.isArray(coords2[0][0]);
26806       const d2 = c2 && Array.isArray(coords2[0][0][0]);
26807       return d2 ? "MultiPolygon" : "Polygon";
26808     }
26809   }
26810   function _cloneDeep(obj) {
26811     return JSON.parse(JSON.stringify(obj));
26812   }
26813   function _sortLocations(a2, b2) {
26814     const rank = { countrycoder: 1, geojson: 2, point: 3 };
26815     const aRank = rank[a2.type];
26816     const bRank = rank[b2.type];
26817     return aRank > bRank ? 1 : aRank < bRank ? -1 : a2.id.localeCompare(b2.id);
26818   }
26819
26820   // modules/core/LocationManager.js
26821   var import_which_polygon2 = __toESM(require_which_polygon());
26822   var import_geojson_area2 = __toESM(require_geojson_area());
26823   var _loco = new LocationConflation();
26824   var LocationManager = class {
26825     /**
26826      * @constructor
26827      */
26828     constructor() {
26829       this._wp = null;
26830       this._resolved = /* @__PURE__ */ new Map();
26831       this._knownLocationSets = /* @__PURE__ */ new Map();
26832       this._locationIncludedIn = /* @__PURE__ */ new Map();
26833       this._locationExcludedIn = /* @__PURE__ */ new Map();
26834       const world = { locationSet: { include: ["Q2"] } };
26835       this._resolveLocationSet(world);
26836       this._rebuildIndex();
26837     }
26838     /**
26839      * _validateLocationSet
26840      * Pass an Object with a `locationSet` property.
26841      * Validates the `locationSet` and sets a `locationSetID` property on the object.
26842      * To avoid so much computation we only resolve the include and exclude regions, but not the locationSet itself.
26843      *
26844      * Use `_resolveLocationSet()` instead if you need to resolve geojson of locationSet, for example to render it.
26845      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26846      *
26847      * @param  `obj`  Object to check, it should have `locationSet` property
26848      */
26849     _validateLocationSet(obj) {
26850       if (obj.locationSetID)
26851         return;
26852       try {
26853         let locationSet = obj.locationSet;
26854         if (!locationSet) {
26855           throw new Error("object missing locationSet property");
26856         }
26857         if (!locationSet.include) {
26858           locationSet.include = ["Q2"];
26859         }
26860         const locationSetID = _loco.validateLocationSet(locationSet).id;
26861         obj.locationSetID = locationSetID;
26862         if (this._knownLocationSets.has(locationSetID))
26863           return;
26864         let area = 0;
26865         (locationSet.include || []).forEach((location) => {
26866           const locationID = _loco.validateLocation(location).id;
26867           let geojson = this._resolved.get(locationID);
26868           if (!geojson) {
26869             geojson = _loco.resolveLocation(location).feature;
26870             this._resolved.set(locationID, geojson);
26871           }
26872           area += geojson.properties.area;
26873           let s2 = this._locationIncludedIn.get(locationID);
26874           if (!s2) {
26875             s2 = /* @__PURE__ */ new Set();
26876             this._locationIncludedIn.set(locationID, s2);
26877           }
26878           s2.add(locationSetID);
26879         });
26880         (locationSet.exclude || []).forEach((location) => {
26881           const locationID = _loco.validateLocation(location).id;
26882           let geojson = this._resolved.get(locationID);
26883           if (!geojson) {
26884             geojson = _loco.resolveLocation(location).feature;
26885             this._resolved.set(locationID, geojson);
26886           }
26887           area -= geojson.properties.area;
26888           let s2 = this._locationExcludedIn.get(locationID);
26889           if (!s2) {
26890             s2 = /* @__PURE__ */ new Set();
26891             this._locationExcludedIn.set(locationID, s2);
26892           }
26893           s2.add(locationSetID);
26894         });
26895         this._knownLocationSets.set(locationSetID, area);
26896       } catch {
26897         obj.locationSet = { include: ["Q2"] };
26898         obj.locationSetID = "+[Q2]";
26899       }
26900     }
26901     /**
26902      * _resolveLocationSet
26903      * Does everything that `_validateLocationSet()` does, but then "resolves" the locationSet into GeoJSON.
26904      * This step is a bit more computationally expensive, so really only needed if you intend to render the shape.
26905      *
26906      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26907      *
26908      * @param  `obj`  Object to check, it should have `locationSet` property
26909      */
26910     _resolveLocationSet(obj) {
26911       this._validateLocationSet(obj);
26912       if (this._resolved.has(obj.locationSetID))
26913         return;
26914       try {
26915         const result = _loco.resolveLocationSet(obj.locationSet);
26916         const locationSetID = result.id;
26917         obj.locationSetID = locationSetID;
26918         if (!result.feature.geometry.coordinates.length || !result.feature.properties.area) {
26919           throw new Error("locationSet ".concat(locationSetID, " resolves to an empty feature."));
26920         }
26921         let geojson = JSON.parse(JSON.stringify(result.feature));
26922         geojson.id = locationSetID;
26923         geojson.properties.id = locationSetID;
26924         this._resolved.set(locationSetID, geojson);
26925       } catch {
26926         obj.locationSet = { include: ["Q2"] };
26927         obj.locationSetID = "+[Q2]";
26928       }
26929     }
26930     /**
26931      * _rebuildIndex
26932      * Rebuilds the whichPolygon index with whatever features have been resolved into GeoJSON.
26933      */
26934     _rebuildIndex() {
26935       this._wp = (0, import_which_polygon2.default)({ features: [...this._resolved.values()] });
26936     }
26937     /**
26938      * mergeCustomGeoJSON
26939      * Accepts a FeatureCollection-like object containing custom locations
26940      * Each feature must have a filename-like `id`, for example: `something.geojson`
26941      * {
26942      *   "type": "FeatureCollection"
26943      *   "features": [
26944      *     {
26945      *       "type": "Feature",
26946      *       "id": "philly_metro.geojson",
26947      *       "properties": { … },
26948      *       "geometry": { … }
26949      *     }
26950      *   ]
26951      * }
26952      *
26953      * @param  `fc`  FeatureCollection-like Object containing custom locations
26954      */
26955     mergeCustomGeoJSON(fc) {
26956       if (!fc || fc.type !== "FeatureCollection" || !Array.isArray(fc.features))
26957         return;
26958       fc.features.forEach((feature3) => {
26959         feature3.properties = feature3.properties || {};
26960         let props = feature3.properties;
26961         let id2 = feature3.id || props.id;
26962         if (!id2 || !/^\S+\.geojson$/i.test(id2))
26963           return;
26964         id2 = id2.toLowerCase();
26965         feature3.id = id2;
26966         props.id = id2;
26967         if (!props.area) {
26968           const area = import_geojson_area2.default.geometry(feature3.geometry) / 1e6;
26969           props.area = Number(area.toFixed(2));
26970         }
26971         _loco._cache[id2] = feature3;
26972       });
26973     }
26974     /**
26975      * mergeLocationSets
26976      * Accepts an Array of Objects containing `locationSet` properties:
26977      * [
26978      *  { id: 'preset1', locationSet: {…} },
26979      *  { id: 'preset2', locationSet: {…} },
26980      *  …
26981      * ]
26982      * After validating, the Objects will be decorated with a `locationSetID` property:
26983      * [
26984      *  { id: 'preset1', locationSet: {…}, locationSetID: '+[Q2]' },
26985      *  { id: 'preset2', locationSet: {…}, locationSetID: '+[Q30]' },
26986      *  …
26987      * ]
26988      *
26989      * @param  `objects`  Objects to check - they should have `locationSet` property
26990      * @return  Promise resolved true (this function used to be slow/async, now it's faster and sync)
26991      */
26992     mergeLocationSets(objects) {
26993       if (!Array.isArray(objects))
26994         return Promise.reject("nothing to do");
26995       objects.forEach((obj) => this._validateLocationSet(obj));
26996       this._rebuildIndex();
26997       return Promise.resolve(objects);
26998     }
26999     /**
27000      * locationSetID
27001      * Returns a locationSetID for a given locationSet (fallback to `+[Q2]`, world)
27002      * (The locationSet doesn't necessarily need to be resolved to compute its `id`)
27003      *
27004      * @param  `locationSet`  A locationSet Object, e.g. `{ include: ['us'] }`
27005      * @return  String locationSetID, e.g. `+[Q30]`
27006      */
27007     locationSetID(locationSet) {
27008       let locationSetID;
27009       try {
27010         locationSetID = _loco.validateLocationSet(locationSet).id;
27011       } catch {
27012         locationSetID = "+[Q2]";
27013       }
27014       return locationSetID;
27015     }
27016     /**
27017      * feature
27018      * Returns the resolved GeoJSON feature for a given locationSetID (fallback to 'world')
27019      * A GeoJSON feature:
27020      * {
27021      *   type: 'Feature',
27022      *   id: '+[Q30]',
27023      *   properties: { id: '+[Q30]', area: 21817019.17, … },
27024      *   geometry: { … }
27025      * }
27026      *
27027      * @param  `locationSetID`  String identifier, e.g. `+[Q30]`
27028      * @return  GeoJSON object (fallback to world)
27029      */
27030     feature(locationSetID = "+[Q2]") {
27031       const feature3 = this._resolved.get(locationSetID);
27032       return feature3 || this._resolved.get("+[Q2]");
27033     }
27034     /**
27035      * locationSetsAt
27036      * Find all the locationSets valid at the given location.
27037      * Results include the area (in km²) to facilitate sorting.
27038      *
27039      * Object of locationSetIDs to areas (in km²)
27040      * {
27041      *   "+[Q2]": 511207893.3958111,
27042      *   "+[Q30]": 21817019.17,
27043      *   "+[new_jersey.geojson]": 22390.77,
27044      *   …
27045      * }
27046      *
27047      * @param  `loc`  `[lon,lat]` location to query, e.g. `[-74.4813, 40.7967]`
27048      * @return  Object of locationSetIDs valid at given location
27049      */
27050     locationSetsAt(loc) {
27051       let result = {};
27052       const hits = this._wp(loc, true) || [];
27053       const thiz = this;
27054       hits.forEach((prop) => {
27055         if (prop.id[0] !== "+")
27056           return;
27057         const locationSetID = prop.id;
27058         const area = thiz._knownLocationSets.get(locationSetID);
27059         if (area) {
27060           result[locationSetID] = area;
27061         }
27062       });
27063       hits.forEach((prop) => {
27064         if (prop.id[0] === "+")
27065           return;
27066         const locationID = prop.id;
27067         const included = thiz._locationIncludedIn.get(locationID);
27068         (included || []).forEach((locationSetID) => {
27069           const area = thiz._knownLocationSets.get(locationSetID);
27070           if (area) {
27071             result[locationSetID] = area;
27072           }
27073         });
27074       });
27075       hits.forEach((prop) => {
27076         if (prop.id[0] === "+")
27077           return;
27078         const locationID = prop.id;
27079         const excluded = thiz._locationExcludedIn.get(locationID);
27080         (excluded || []).forEach((locationSetID) => {
27081           delete result[locationSetID];
27082         });
27083       });
27084       return result;
27085     }
27086     // Direct access to the location-conflation resolver
27087     loco() {
27088       return _loco;
27089     }
27090   };
27091   var _sharedLocationManager = new LocationManager();
27092
27093   // node_modules/lodash-es/_freeGlobal.js
27094   var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
27095   var freeGlobal_default = freeGlobal;
27096
27097   // node_modules/lodash-es/_root.js
27098   var freeSelf = typeof self == "object" && self && self.Object === Object && self;
27099   var root2 = freeGlobal_default || freeSelf || Function("return this")();
27100   var root_default = root2;
27101
27102   // node_modules/lodash-es/_Symbol.js
27103   var Symbol2 = root_default.Symbol;
27104   var Symbol_default = Symbol2;
27105
27106   // node_modules/lodash-es/_getRawTag.js
27107   var objectProto = Object.prototype;
27108   var hasOwnProperty = objectProto.hasOwnProperty;
27109   var nativeObjectToString = objectProto.toString;
27110   var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
27111   function getRawTag(value) {
27112     var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag];
27113     try {
27114       value[symToStringTag] = void 0;
27115       var unmasked = true;
27116     } catch (e3) {
27117     }
27118     var result = nativeObjectToString.call(value);
27119     if (unmasked) {
27120       if (isOwn) {
27121         value[symToStringTag] = tag2;
27122       } else {
27123         delete value[symToStringTag];
27124       }
27125     }
27126     return result;
27127   }
27128   var getRawTag_default = getRawTag;
27129
27130   // node_modules/lodash-es/_objectToString.js
27131   var objectProto2 = Object.prototype;
27132   var nativeObjectToString2 = objectProto2.toString;
27133   function objectToString(value) {
27134     return nativeObjectToString2.call(value);
27135   }
27136   var objectToString_default = objectToString;
27137
27138   // node_modules/lodash-es/_baseGetTag.js
27139   var nullTag = "[object Null]";
27140   var undefinedTag = "[object Undefined]";
27141   var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
27142   function baseGetTag(value) {
27143     if (value == null) {
27144       return value === void 0 ? undefinedTag : nullTag;
27145     }
27146     return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
27147   }
27148   var baseGetTag_default = baseGetTag;
27149
27150   // node_modules/lodash-es/isObjectLike.js
27151   function isObjectLike(value) {
27152     return value != null && typeof value == "object";
27153   }
27154   var isObjectLike_default = isObjectLike;
27155
27156   // node_modules/lodash-es/isSymbol.js
27157   var symbolTag = "[object Symbol]";
27158   function isSymbol(value) {
27159     return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
27160   }
27161   var isSymbol_default = isSymbol;
27162
27163   // node_modules/lodash-es/_arrayMap.js
27164   function arrayMap(array2, iteratee) {
27165     var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
27166     while (++index < length2) {
27167       result[index] = iteratee(array2[index], index, array2);
27168     }
27169     return result;
27170   }
27171   var arrayMap_default = arrayMap;
27172
27173   // node_modules/lodash-es/isArray.js
27174   var isArray = Array.isArray;
27175   var isArray_default = isArray;
27176
27177   // node_modules/lodash-es/_baseToString.js
27178   var INFINITY = 1 / 0;
27179   var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
27180   var symbolToString = symbolProto ? symbolProto.toString : void 0;
27181   function baseToString(value) {
27182     if (typeof value == "string") {
27183       return value;
27184     }
27185     if (isArray_default(value)) {
27186       return arrayMap_default(value, baseToString) + "";
27187     }
27188     if (isSymbol_default(value)) {
27189       return symbolToString ? symbolToString.call(value) : "";
27190     }
27191     var result = value + "";
27192     return result == "0" && 1 / value == -INFINITY ? "-0" : result;
27193   }
27194   var baseToString_default = baseToString;
27195
27196   // node_modules/lodash-es/_trimmedEndIndex.js
27197   var reWhitespace = /\s/;
27198   function trimmedEndIndex(string) {
27199     var index = string.length;
27200     while (index-- && reWhitespace.test(string.charAt(index))) {
27201     }
27202     return index;
27203   }
27204   var trimmedEndIndex_default = trimmedEndIndex;
27205
27206   // node_modules/lodash-es/_baseTrim.js
27207   var reTrimStart = /^\s+/;
27208   function baseTrim(string) {
27209     return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
27210   }
27211   var baseTrim_default = baseTrim;
27212
27213   // node_modules/lodash-es/isObject.js
27214   function isObject(value) {
27215     var type2 = typeof value;
27216     return value != null && (type2 == "object" || type2 == "function");
27217   }
27218   var isObject_default = isObject;
27219
27220   // node_modules/lodash-es/toNumber.js
27221   var NAN = 0 / 0;
27222   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
27223   var reIsBinary = /^0b[01]+$/i;
27224   var reIsOctal = /^0o[0-7]+$/i;
27225   var freeParseInt = parseInt;
27226   function toNumber(value) {
27227     if (typeof value == "number") {
27228       return value;
27229     }
27230     if (isSymbol_default(value)) {
27231       return NAN;
27232     }
27233     if (isObject_default(value)) {
27234       var other = typeof value.valueOf == "function" ? value.valueOf() : value;
27235       value = isObject_default(other) ? other + "" : other;
27236     }
27237     if (typeof value != "string") {
27238       return value === 0 ? value : +value;
27239     }
27240     value = baseTrim_default(value);
27241     var isBinary = reIsBinary.test(value);
27242     return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
27243   }
27244   var toNumber_default = toNumber;
27245
27246   // node_modules/lodash-es/isFunction.js
27247   var asyncTag = "[object AsyncFunction]";
27248   var funcTag = "[object Function]";
27249   var genTag = "[object GeneratorFunction]";
27250   var proxyTag = "[object Proxy]";
27251   function isFunction(value) {
27252     if (!isObject_default(value)) {
27253       return false;
27254     }
27255     var tag2 = baseGetTag_default(value);
27256     return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag;
27257   }
27258   var isFunction_default = isFunction;
27259
27260   // node_modules/lodash-es/_coreJsData.js
27261   var coreJsData = root_default["__core-js_shared__"];
27262   var coreJsData_default = coreJsData;
27263
27264   // node_modules/lodash-es/_isMasked.js
27265   var maskSrcKey = function() {
27266     var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
27267     return uid ? "Symbol(src)_1." + uid : "";
27268   }();
27269   function isMasked(func) {
27270     return !!maskSrcKey && maskSrcKey in func;
27271   }
27272   var isMasked_default = isMasked;
27273
27274   // node_modules/lodash-es/_toSource.js
27275   var funcProto = Function.prototype;
27276   var funcToString = funcProto.toString;
27277   function toSource(func) {
27278     if (func != null) {
27279       try {
27280         return funcToString.call(func);
27281       } catch (e3) {
27282       }
27283       try {
27284         return func + "";
27285       } catch (e3) {
27286       }
27287     }
27288     return "";
27289   }
27290   var toSource_default = toSource;
27291
27292   // node_modules/lodash-es/_baseIsNative.js
27293   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
27294   var reIsHostCtor = /^\[object .+?Constructor\]$/;
27295   var funcProto2 = Function.prototype;
27296   var objectProto3 = Object.prototype;
27297   var funcToString2 = funcProto2.toString;
27298   var hasOwnProperty2 = objectProto3.hasOwnProperty;
27299   var reIsNative = RegExp(
27300     "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
27301   );
27302   function baseIsNative(value) {
27303     if (!isObject_default(value) || isMasked_default(value)) {
27304       return false;
27305     }
27306     var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
27307     return pattern.test(toSource_default(value));
27308   }
27309   var baseIsNative_default = baseIsNative;
27310
27311   // node_modules/lodash-es/_getValue.js
27312   function getValue(object, key) {
27313     return object == null ? void 0 : object[key];
27314   }
27315   var getValue_default = getValue;
27316
27317   // node_modules/lodash-es/_getNative.js
27318   function getNative(object, key) {
27319     var value = getValue_default(object, key);
27320     return baseIsNative_default(value) ? value : void 0;
27321   }
27322   var getNative_default = getNative;
27323
27324   // node_modules/lodash-es/_WeakMap.js
27325   var WeakMap = getNative_default(root_default, "WeakMap");
27326   var WeakMap_default = WeakMap;
27327
27328   // node_modules/lodash-es/_isIndex.js
27329   var MAX_SAFE_INTEGER2 = 9007199254740991;
27330   var reIsUint = /^(?:0|[1-9]\d*)$/;
27331   function isIndex(value, length2) {
27332     var type2 = typeof value;
27333     length2 = length2 == null ? MAX_SAFE_INTEGER2 : length2;
27334     return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
27335   }
27336   var isIndex_default = isIndex;
27337
27338   // node_modules/lodash-es/eq.js
27339   function eq(value, other) {
27340     return value === other || value !== value && other !== other;
27341   }
27342   var eq_default = eq;
27343
27344   // node_modules/lodash-es/isLength.js
27345   var MAX_SAFE_INTEGER3 = 9007199254740991;
27346   function isLength(value) {
27347     return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER3;
27348   }
27349   var isLength_default = isLength;
27350
27351   // node_modules/lodash-es/isArrayLike.js
27352   function isArrayLike(value) {
27353     return value != null && isLength_default(value.length) && !isFunction_default(value);
27354   }
27355   var isArrayLike_default = isArrayLike;
27356
27357   // node_modules/lodash-es/_isPrototype.js
27358   var objectProto4 = Object.prototype;
27359   function isPrototype(value) {
27360     var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto4;
27361     return value === proto;
27362   }
27363   var isPrototype_default = isPrototype;
27364
27365   // node_modules/lodash-es/_baseTimes.js
27366   function baseTimes(n3, iteratee) {
27367     var index = -1, result = Array(n3);
27368     while (++index < n3) {
27369       result[index] = iteratee(index);
27370     }
27371     return result;
27372   }
27373   var baseTimes_default = baseTimes;
27374
27375   // node_modules/lodash-es/_baseIsArguments.js
27376   var argsTag = "[object Arguments]";
27377   function baseIsArguments(value) {
27378     return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
27379   }
27380   var baseIsArguments_default = baseIsArguments;
27381
27382   // node_modules/lodash-es/isArguments.js
27383   var objectProto5 = Object.prototype;
27384   var hasOwnProperty3 = objectProto5.hasOwnProperty;
27385   var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
27386   var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
27387     return arguments;
27388   }()) ? baseIsArguments_default : function(value) {
27389     return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
27390   };
27391   var isArguments_default = isArguments;
27392
27393   // node_modules/lodash-es/stubFalse.js
27394   function stubFalse() {
27395     return false;
27396   }
27397   var stubFalse_default = stubFalse;
27398
27399   // node_modules/lodash-es/isBuffer.js
27400   var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
27401   var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
27402   var moduleExports = freeModule && freeModule.exports === freeExports;
27403   var Buffer2 = moduleExports ? root_default.Buffer : void 0;
27404   var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
27405   var isBuffer = nativeIsBuffer || stubFalse_default;
27406   var isBuffer_default = isBuffer;
27407
27408   // node_modules/lodash-es/_baseIsTypedArray.js
27409   var argsTag2 = "[object Arguments]";
27410   var arrayTag = "[object Array]";
27411   var boolTag = "[object Boolean]";
27412   var dateTag = "[object Date]";
27413   var errorTag = "[object Error]";
27414   var funcTag2 = "[object Function]";
27415   var mapTag = "[object Map]";
27416   var numberTag = "[object Number]";
27417   var objectTag = "[object Object]";
27418   var regexpTag = "[object RegExp]";
27419   var setTag = "[object Set]";
27420   var stringTag = "[object String]";
27421   var weakMapTag = "[object WeakMap]";
27422   var arrayBufferTag = "[object ArrayBuffer]";
27423   var dataViewTag = "[object DataView]";
27424   var float32Tag = "[object Float32Array]";
27425   var float64Tag = "[object Float64Array]";
27426   var int8Tag = "[object Int8Array]";
27427   var int16Tag = "[object Int16Array]";
27428   var int32Tag = "[object Int32Array]";
27429   var uint8Tag = "[object Uint8Array]";
27430   var uint8ClampedTag = "[object Uint8ClampedArray]";
27431   var uint16Tag = "[object Uint16Array]";
27432   var uint32Tag = "[object Uint32Array]";
27433   var typedArrayTags = {};
27434   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
27435   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;
27436   function baseIsTypedArray(value) {
27437     return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
27438   }
27439   var baseIsTypedArray_default = baseIsTypedArray;
27440
27441   // node_modules/lodash-es/_baseUnary.js
27442   function baseUnary(func) {
27443     return function(value) {
27444       return func(value);
27445     };
27446   }
27447   var baseUnary_default = baseUnary;
27448
27449   // node_modules/lodash-es/_nodeUtil.js
27450   var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
27451   var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
27452   var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
27453   var freeProcess = moduleExports2 && freeGlobal_default.process;
27454   var nodeUtil = function() {
27455     try {
27456       var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
27457       if (types) {
27458         return types;
27459       }
27460       return freeProcess && freeProcess.binding && freeProcess.binding("util");
27461     } catch (e3) {
27462     }
27463   }();
27464   var nodeUtil_default = nodeUtil;
27465
27466   // node_modules/lodash-es/isTypedArray.js
27467   var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
27468   var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
27469   var isTypedArray_default = isTypedArray;
27470
27471   // node_modules/lodash-es/_arrayLikeKeys.js
27472   var objectProto6 = Object.prototype;
27473   var hasOwnProperty4 = objectProto6.hasOwnProperty;
27474   function arrayLikeKeys(value, inherited) {
27475     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;
27476     for (var key in value) {
27477       if ((inherited || hasOwnProperty4.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
27478       (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
27479       isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
27480       isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
27481       isIndex_default(key, length2)))) {
27482         result.push(key);
27483       }
27484     }
27485     return result;
27486   }
27487   var arrayLikeKeys_default = arrayLikeKeys;
27488
27489   // node_modules/lodash-es/_overArg.js
27490   function overArg(func, transform2) {
27491     return function(arg) {
27492       return func(transform2(arg));
27493     };
27494   }
27495   var overArg_default = overArg;
27496
27497   // node_modules/lodash-es/_nativeKeys.js
27498   var nativeKeys = overArg_default(Object.keys, Object);
27499   var nativeKeys_default = nativeKeys;
27500
27501   // node_modules/lodash-es/_baseKeys.js
27502   var objectProto7 = Object.prototype;
27503   var hasOwnProperty5 = objectProto7.hasOwnProperty;
27504   function baseKeys(object) {
27505     if (!isPrototype_default(object)) {
27506       return nativeKeys_default(object);
27507     }
27508     var result = [];
27509     for (var key in Object(object)) {
27510       if (hasOwnProperty5.call(object, key) && key != "constructor") {
27511         result.push(key);
27512       }
27513     }
27514     return result;
27515   }
27516   var baseKeys_default = baseKeys;
27517
27518   // node_modules/lodash-es/keys.js
27519   function keys(object) {
27520     return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
27521   }
27522   var keys_default = keys;
27523
27524   // node_modules/lodash-es/_nativeCreate.js
27525   var nativeCreate = getNative_default(Object, "create");
27526   var nativeCreate_default = nativeCreate;
27527
27528   // node_modules/lodash-es/_hashClear.js
27529   function hashClear() {
27530     this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
27531     this.size = 0;
27532   }
27533   var hashClear_default = hashClear;
27534
27535   // node_modules/lodash-es/_hashDelete.js
27536   function hashDelete(key) {
27537     var result = this.has(key) && delete this.__data__[key];
27538     this.size -= result ? 1 : 0;
27539     return result;
27540   }
27541   var hashDelete_default = hashDelete;
27542
27543   // node_modules/lodash-es/_hashGet.js
27544   var HASH_UNDEFINED = "__lodash_hash_undefined__";
27545   var objectProto8 = Object.prototype;
27546   var hasOwnProperty6 = objectProto8.hasOwnProperty;
27547   function hashGet(key) {
27548     var data = this.__data__;
27549     if (nativeCreate_default) {
27550       var result = data[key];
27551       return result === HASH_UNDEFINED ? void 0 : result;
27552     }
27553     return hasOwnProperty6.call(data, key) ? data[key] : void 0;
27554   }
27555   var hashGet_default = hashGet;
27556
27557   // node_modules/lodash-es/_hashHas.js
27558   var objectProto9 = Object.prototype;
27559   var hasOwnProperty7 = objectProto9.hasOwnProperty;
27560   function hashHas(key) {
27561     var data = this.__data__;
27562     return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty7.call(data, key);
27563   }
27564   var hashHas_default = hashHas;
27565
27566   // node_modules/lodash-es/_hashSet.js
27567   var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
27568   function hashSet(key, value) {
27569     var data = this.__data__;
27570     this.size += this.has(key) ? 0 : 1;
27571     data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
27572     return this;
27573   }
27574   var hashSet_default = hashSet;
27575
27576   // node_modules/lodash-es/_Hash.js
27577   function Hash(entries) {
27578     var index = -1, length2 = entries == null ? 0 : entries.length;
27579     this.clear();
27580     while (++index < length2) {
27581       var entry = entries[index];
27582       this.set(entry[0], entry[1]);
27583     }
27584   }
27585   Hash.prototype.clear = hashClear_default;
27586   Hash.prototype["delete"] = hashDelete_default;
27587   Hash.prototype.get = hashGet_default;
27588   Hash.prototype.has = hashHas_default;
27589   Hash.prototype.set = hashSet_default;
27590   var Hash_default = Hash;
27591
27592   // node_modules/lodash-es/_listCacheClear.js
27593   function listCacheClear() {
27594     this.__data__ = [];
27595     this.size = 0;
27596   }
27597   var listCacheClear_default = listCacheClear;
27598
27599   // node_modules/lodash-es/_assocIndexOf.js
27600   function assocIndexOf(array2, key) {
27601     var length2 = array2.length;
27602     while (length2--) {
27603       if (eq_default(array2[length2][0], key)) {
27604         return length2;
27605       }
27606     }
27607     return -1;
27608   }
27609   var assocIndexOf_default = assocIndexOf;
27610
27611   // node_modules/lodash-es/_listCacheDelete.js
27612   var arrayProto = Array.prototype;
27613   var splice = arrayProto.splice;
27614   function listCacheDelete(key) {
27615     var data = this.__data__, index = assocIndexOf_default(data, key);
27616     if (index < 0) {
27617       return false;
27618     }
27619     var lastIndex = data.length - 1;
27620     if (index == lastIndex) {
27621       data.pop();
27622     } else {
27623       splice.call(data, index, 1);
27624     }
27625     --this.size;
27626     return true;
27627   }
27628   var listCacheDelete_default = listCacheDelete;
27629
27630   // node_modules/lodash-es/_listCacheGet.js
27631   function listCacheGet(key) {
27632     var data = this.__data__, index = assocIndexOf_default(data, key);
27633     return index < 0 ? void 0 : data[index][1];
27634   }
27635   var listCacheGet_default = listCacheGet;
27636
27637   // node_modules/lodash-es/_listCacheHas.js
27638   function listCacheHas(key) {
27639     return assocIndexOf_default(this.__data__, key) > -1;
27640   }
27641   var listCacheHas_default = listCacheHas;
27642
27643   // node_modules/lodash-es/_listCacheSet.js
27644   function listCacheSet(key, value) {
27645     var data = this.__data__, index = assocIndexOf_default(data, key);
27646     if (index < 0) {
27647       ++this.size;
27648       data.push([key, value]);
27649     } else {
27650       data[index][1] = value;
27651     }
27652     return this;
27653   }
27654   var listCacheSet_default = listCacheSet;
27655
27656   // node_modules/lodash-es/_ListCache.js
27657   function ListCache(entries) {
27658     var index = -1, length2 = entries == null ? 0 : entries.length;
27659     this.clear();
27660     while (++index < length2) {
27661       var entry = entries[index];
27662       this.set(entry[0], entry[1]);
27663     }
27664   }
27665   ListCache.prototype.clear = listCacheClear_default;
27666   ListCache.prototype["delete"] = listCacheDelete_default;
27667   ListCache.prototype.get = listCacheGet_default;
27668   ListCache.prototype.has = listCacheHas_default;
27669   ListCache.prototype.set = listCacheSet_default;
27670   var ListCache_default = ListCache;
27671
27672   // node_modules/lodash-es/_Map.js
27673   var Map2 = getNative_default(root_default, "Map");
27674   var Map_default = Map2;
27675
27676   // node_modules/lodash-es/_mapCacheClear.js
27677   function mapCacheClear() {
27678     this.size = 0;
27679     this.__data__ = {
27680       "hash": new Hash_default(),
27681       "map": new (Map_default || ListCache_default)(),
27682       "string": new Hash_default()
27683     };
27684   }
27685   var mapCacheClear_default = mapCacheClear;
27686
27687   // node_modules/lodash-es/_isKeyable.js
27688   function isKeyable(value) {
27689     var type2 = typeof value;
27690     return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
27691   }
27692   var isKeyable_default = isKeyable;
27693
27694   // node_modules/lodash-es/_getMapData.js
27695   function getMapData(map2, key) {
27696     var data = map2.__data__;
27697     return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
27698   }
27699   var getMapData_default = getMapData;
27700
27701   // node_modules/lodash-es/_mapCacheDelete.js
27702   function mapCacheDelete(key) {
27703     var result = getMapData_default(this, key)["delete"](key);
27704     this.size -= result ? 1 : 0;
27705     return result;
27706   }
27707   var mapCacheDelete_default = mapCacheDelete;
27708
27709   // node_modules/lodash-es/_mapCacheGet.js
27710   function mapCacheGet(key) {
27711     return getMapData_default(this, key).get(key);
27712   }
27713   var mapCacheGet_default = mapCacheGet;
27714
27715   // node_modules/lodash-es/_mapCacheHas.js
27716   function mapCacheHas(key) {
27717     return getMapData_default(this, key).has(key);
27718   }
27719   var mapCacheHas_default = mapCacheHas;
27720
27721   // node_modules/lodash-es/_mapCacheSet.js
27722   function mapCacheSet(key, value) {
27723     var data = getMapData_default(this, key), size = data.size;
27724     data.set(key, value);
27725     this.size += data.size == size ? 0 : 1;
27726     return this;
27727   }
27728   var mapCacheSet_default = mapCacheSet;
27729
27730   // node_modules/lodash-es/_MapCache.js
27731   function MapCache(entries) {
27732     var index = -1, length2 = entries == null ? 0 : entries.length;
27733     this.clear();
27734     while (++index < length2) {
27735       var entry = entries[index];
27736       this.set(entry[0], entry[1]);
27737     }
27738   }
27739   MapCache.prototype.clear = mapCacheClear_default;
27740   MapCache.prototype["delete"] = mapCacheDelete_default;
27741   MapCache.prototype.get = mapCacheGet_default;
27742   MapCache.prototype.has = mapCacheHas_default;
27743   MapCache.prototype.set = mapCacheSet_default;
27744   var MapCache_default = MapCache;
27745
27746   // node_modules/lodash-es/toString.js
27747   function toString(value) {
27748     return value == null ? "" : baseToString_default(value);
27749   }
27750   var toString_default = toString;
27751
27752   // node_modules/lodash-es/_arrayPush.js
27753   function arrayPush(array2, values) {
27754     var index = -1, length2 = values.length, offset = array2.length;
27755     while (++index < length2) {
27756       array2[offset + index] = values[index];
27757     }
27758     return array2;
27759   }
27760   var arrayPush_default = arrayPush;
27761
27762   // node_modules/lodash-es/_basePropertyOf.js
27763   function basePropertyOf(object) {
27764     return function(key) {
27765       return object == null ? void 0 : object[key];
27766     };
27767   }
27768   var basePropertyOf_default = basePropertyOf;
27769
27770   // node_modules/lodash-es/_stackClear.js
27771   function stackClear() {
27772     this.__data__ = new ListCache_default();
27773     this.size = 0;
27774   }
27775   var stackClear_default = stackClear;
27776
27777   // node_modules/lodash-es/_stackDelete.js
27778   function stackDelete(key) {
27779     var data = this.__data__, result = data["delete"](key);
27780     this.size = data.size;
27781     return result;
27782   }
27783   var stackDelete_default = stackDelete;
27784
27785   // node_modules/lodash-es/_stackGet.js
27786   function stackGet(key) {
27787     return this.__data__.get(key);
27788   }
27789   var stackGet_default = stackGet;
27790
27791   // node_modules/lodash-es/_stackHas.js
27792   function stackHas(key) {
27793     return this.__data__.has(key);
27794   }
27795   var stackHas_default = stackHas;
27796
27797   // node_modules/lodash-es/_stackSet.js
27798   var LARGE_ARRAY_SIZE = 200;
27799   function stackSet(key, value) {
27800     var data = this.__data__;
27801     if (data instanceof ListCache_default) {
27802       var pairs2 = data.__data__;
27803       if (!Map_default || pairs2.length < LARGE_ARRAY_SIZE - 1) {
27804         pairs2.push([key, value]);
27805         this.size = ++data.size;
27806         return this;
27807       }
27808       data = this.__data__ = new MapCache_default(pairs2);
27809     }
27810     data.set(key, value);
27811     this.size = data.size;
27812     return this;
27813   }
27814   var stackSet_default = stackSet;
27815
27816   // node_modules/lodash-es/_Stack.js
27817   function Stack(entries) {
27818     var data = this.__data__ = new ListCache_default(entries);
27819     this.size = data.size;
27820   }
27821   Stack.prototype.clear = stackClear_default;
27822   Stack.prototype["delete"] = stackDelete_default;
27823   Stack.prototype.get = stackGet_default;
27824   Stack.prototype.has = stackHas_default;
27825   Stack.prototype.set = stackSet_default;
27826   var Stack_default = Stack;
27827
27828   // node_modules/lodash-es/_arrayFilter.js
27829   function arrayFilter(array2, predicate) {
27830     var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
27831     while (++index < length2) {
27832       var value = array2[index];
27833       if (predicate(value, index, array2)) {
27834         result[resIndex++] = value;
27835       }
27836     }
27837     return result;
27838   }
27839   var arrayFilter_default = arrayFilter;
27840
27841   // node_modules/lodash-es/stubArray.js
27842   function stubArray() {
27843     return [];
27844   }
27845   var stubArray_default = stubArray;
27846
27847   // node_modules/lodash-es/_getSymbols.js
27848   var objectProto10 = Object.prototype;
27849   var propertyIsEnumerable2 = objectProto10.propertyIsEnumerable;
27850   var nativeGetSymbols = Object.getOwnPropertySymbols;
27851   var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
27852     if (object == null) {
27853       return [];
27854     }
27855     object = Object(object);
27856     return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
27857       return propertyIsEnumerable2.call(object, symbol);
27858     });
27859   };
27860   var getSymbols_default = getSymbols;
27861
27862   // node_modules/lodash-es/_baseGetAllKeys.js
27863   function baseGetAllKeys(object, keysFunc, symbolsFunc) {
27864     var result = keysFunc(object);
27865     return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
27866   }
27867   var baseGetAllKeys_default = baseGetAllKeys;
27868
27869   // node_modules/lodash-es/_getAllKeys.js
27870   function getAllKeys(object) {
27871     return baseGetAllKeys_default(object, keys_default, getSymbols_default);
27872   }
27873   var getAllKeys_default = getAllKeys;
27874
27875   // node_modules/lodash-es/_DataView.js
27876   var DataView2 = getNative_default(root_default, "DataView");
27877   var DataView_default = DataView2;
27878
27879   // node_modules/lodash-es/_Promise.js
27880   var Promise2 = getNative_default(root_default, "Promise");
27881   var Promise_default = Promise2;
27882
27883   // node_modules/lodash-es/_Set.js
27884   var Set2 = getNative_default(root_default, "Set");
27885   var Set_default = Set2;
27886
27887   // node_modules/lodash-es/_getTag.js
27888   var mapTag2 = "[object Map]";
27889   var objectTag2 = "[object Object]";
27890   var promiseTag = "[object Promise]";
27891   var setTag2 = "[object Set]";
27892   var weakMapTag2 = "[object WeakMap]";
27893   var dataViewTag2 = "[object DataView]";
27894   var dataViewCtorString = toSource_default(DataView_default);
27895   var mapCtorString = toSource_default(Map_default);
27896   var promiseCtorString = toSource_default(Promise_default);
27897   var setCtorString = toSource_default(Set_default);
27898   var weakMapCtorString = toSource_default(WeakMap_default);
27899   var getTag = baseGetTag_default;
27900   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) {
27901     getTag = function(value) {
27902       var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
27903       if (ctorString) {
27904         switch (ctorString) {
27905           case dataViewCtorString:
27906             return dataViewTag2;
27907           case mapCtorString:
27908             return mapTag2;
27909           case promiseCtorString:
27910             return promiseTag;
27911           case setCtorString:
27912             return setTag2;
27913           case weakMapCtorString:
27914             return weakMapTag2;
27915         }
27916       }
27917       return result;
27918     };
27919   }
27920   var getTag_default = getTag;
27921
27922   // node_modules/lodash-es/_Uint8Array.js
27923   var Uint8Array2 = root_default.Uint8Array;
27924   var Uint8Array_default = Uint8Array2;
27925
27926   // node_modules/lodash-es/_setCacheAdd.js
27927   var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
27928   function setCacheAdd(value) {
27929     this.__data__.set(value, HASH_UNDEFINED3);
27930     return this;
27931   }
27932   var setCacheAdd_default = setCacheAdd;
27933
27934   // node_modules/lodash-es/_setCacheHas.js
27935   function setCacheHas(value) {
27936     return this.__data__.has(value);
27937   }
27938   var setCacheHas_default = setCacheHas;
27939
27940   // node_modules/lodash-es/_SetCache.js
27941   function SetCache(values) {
27942     var index = -1, length2 = values == null ? 0 : values.length;
27943     this.__data__ = new MapCache_default();
27944     while (++index < length2) {
27945       this.add(values[index]);
27946     }
27947   }
27948   SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
27949   SetCache.prototype.has = setCacheHas_default;
27950   var SetCache_default = SetCache;
27951
27952   // node_modules/lodash-es/_arraySome.js
27953   function arraySome(array2, predicate) {
27954     var index = -1, length2 = array2 == null ? 0 : array2.length;
27955     while (++index < length2) {
27956       if (predicate(array2[index], index, array2)) {
27957         return true;
27958       }
27959     }
27960     return false;
27961   }
27962   var arraySome_default = arraySome;
27963
27964   // node_modules/lodash-es/_cacheHas.js
27965   function cacheHas(cache, key) {
27966     return cache.has(key);
27967   }
27968   var cacheHas_default = cacheHas;
27969
27970   // node_modules/lodash-es/_equalArrays.js
27971   var COMPARE_PARTIAL_FLAG = 1;
27972   var COMPARE_UNORDERED_FLAG = 2;
27973   function equalArrays(array2, other, bitmask, customizer, equalFunc, stack) {
27974     var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other.length;
27975     if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
27976       return false;
27977     }
27978     var arrStacked = stack.get(array2);
27979     var othStacked = stack.get(other);
27980     if (arrStacked && othStacked) {
27981       return arrStacked == other && othStacked == array2;
27982     }
27983     var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
27984     stack.set(array2, other);
27985     stack.set(other, array2);
27986     while (++index < arrLength) {
27987       var arrValue = array2[index], othValue = other[index];
27988       if (customizer) {
27989         var compared = isPartial ? customizer(othValue, arrValue, index, other, array2, stack) : customizer(arrValue, othValue, index, array2, other, stack);
27990       }
27991       if (compared !== void 0) {
27992         if (compared) {
27993           continue;
27994         }
27995         result = false;
27996         break;
27997       }
27998       if (seen) {
27999         if (!arraySome_default(other, function(othValue2, othIndex) {
28000           if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
28001             return seen.push(othIndex);
28002           }
28003         })) {
28004           result = false;
28005           break;
28006         }
28007       } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
28008         result = false;
28009         break;
28010       }
28011     }
28012     stack["delete"](array2);
28013     stack["delete"](other);
28014     return result;
28015   }
28016   var equalArrays_default = equalArrays;
28017
28018   // node_modules/lodash-es/_mapToArray.js
28019   function mapToArray(map2) {
28020     var index = -1, result = Array(map2.size);
28021     map2.forEach(function(value, key) {
28022       result[++index] = [key, value];
28023     });
28024     return result;
28025   }
28026   var mapToArray_default = mapToArray;
28027
28028   // node_modules/lodash-es/_setToArray.js
28029   function setToArray(set4) {
28030     var index = -1, result = Array(set4.size);
28031     set4.forEach(function(value) {
28032       result[++index] = value;
28033     });
28034     return result;
28035   }
28036   var setToArray_default = setToArray;
28037
28038   // node_modules/lodash-es/_equalByTag.js
28039   var COMPARE_PARTIAL_FLAG2 = 1;
28040   var COMPARE_UNORDERED_FLAG2 = 2;
28041   var boolTag2 = "[object Boolean]";
28042   var dateTag2 = "[object Date]";
28043   var errorTag2 = "[object Error]";
28044   var mapTag3 = "[object Map]";
28045   var numberTag2 = "[object Number]";
28046   var regexpTag2 = "[object RegExp]";
28047   var setTag3 = "[object Set]";
28048   var stringTag2 = "[object String]";
28049   var symbolTag2 = "[object Symbol]";
28050   var arrayBufferTag2 = "[object ArrayBuffer]";
28051   var dataViewTag3 = "[object DataView]";
28052   var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
28053   var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
28054   function equalByTag(object, other, tag2, bitmask, customizer, equalFunc, stack) {
28055     switch (tag2) {
28056       case dataViewTag3:
28057         if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
28058           return false;
28059         }
28060         object = object.buffer;
28061         other = other.buffer;
28062       case arrayBufferTag2:
28063         if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
28064           return false;
28065         }
28066         return true;
28067       case boolTag2:
28068       case dateTag2:
28069       case numberTag2:
28070         return eq_default(+object, +other);
28071       case errorTag2:
28072         return object.name == other.name && object.message == other.message;
28073       case regexpTag2:
28074       case stringTag2:
28075         return object == other + "";
28076       case mapTag3:
28077         var convert = mapToArray_default;
28078       case setTag3:
28079         var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
28080         convert || (convert = setToArray_default);
28081         if (object.size != other.size && !isPartial) {
28082           return false;
28083         }
28084         var stacked = stack.get(object);
28085         if (stacked) {
28086           return stacked == other;
28087         }
28088         bitmask |= COMPARE_UNORDERED_FLAG2;
28089         stack.set(object, other);
28090         var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
28091         stack["delete"](object);
28092         return result;
28093       case symbolTag2:
28094         if (symbolValueOf) {
28095           return symbolValueOf.call(object) == symbolValueOf.call(other);
28096         }
28097     }
28098     return false;
28099   }
28100   var equalByTag_default = equalByTag;
28101
28102   // node_modules/lodash-es/_equalObjects.js
28103   var COMPARE_PARTIAL_FLAG3 = 1;
28104   var objectProto11 = Object.prototype;
28105   var hasOwnProperty8 = objectProto11.hasOwnProperty;
28106   function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
28107     var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
28108     if (objLength != othLength && !isPartial) {
28109       return false;
28110     }
28111     var index = objLength;
28112     while (index--) {
28113       var key = objProps[index];
28114       if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
28115         return false;
28116       }
28117     }
28118     var objStacked = stack.get(object);
28119     var othStacked = stack.get(other);
28120     if (objStacked && othStacked) {
28121       return objStacked == other && othStacked == object;
28122     }
28123     var result = true;
28124     stack.set(object, other);
28125     stack.set(other, object);
28126     var skipCtor = isPartial;
28127     while (++index < objLength) {
28128       key = objProps[index];
28129       var objValue = object[key], othValue = other[key];
28130       if (customizer) {
28131         var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
28132       }
28133       if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
28134         result = false;
28135         break;
28136       }
28137       skipCtor || (skipCtor = key == "constructor");
28138     }
28139     if (result && !skipCtor) {
28140       var objCtor = object.constructor, othCtor = other.constructor;
28141       if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
28142         result = false;
28143       }
28144     }
28145     stack["delete"](object);
28146     stack["delete"](other);
28147     return result;
28148   }
28149   var equalObjects_default = equalObjects;
28150
28151   // node_modules/lodash-es/_baseIsEqualDeep.js
28152   var COMPARE_PARTIAL_FLAG4 = 1;
28153   var argsTag3 = "[object Arguments]";
28154   var arrayTag2 = "[object Array]";
28155   var objectTag3 = "[object Object]";
28156   var objectProto12 = Object.prototype;
28157   var hasOwnProperty9 = objectProto12.hasOwnProperty;
28158   function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
28159     var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
28160     objTag = objTag == argsTag3 ? objectTag3 : objTag;
28161     othTag = othTag == argsTag3 ? objectTag3 : othTag;
28162     var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
28163     if (isSameTag && isBuffer_default(object)) {
28164       if (!isBuffer_default(other)) {
28165         return false;
28166       }
28167       objIsArr = true;
28168       objIsObj = false;
28169     }
28170     if (isSameTag && !objIsObj) {
28171       stack || (stack = new Stack_default());
28172       return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
28173     }
28174     if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
28175       var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
28176       if (objIsWrapped || othIsWrapped) {
28177         var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
28178         stack || (stack = new Stack_default());
28179         return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
28180       }
28181     }
28182     if (!isSameTag) {
28183       return false;
28184     }
28185     stack || (stack = new Stack_default());
28186     return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
28187   }
28188   var baseIsEqualDeep_default = baseIsEqualDeep;
28189
28190   // node_modules/lodash-es/_baseIsEqual.js
28191   function baseIsEqual(value, other, bitmask, customizer, stack) {
28192     if (value === other) {
28193       return true;
28194     }
28195     if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
28196       return value !== value && other !== other;
28197     }
28198     return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
28199   }
28200   var baseIsEqual_default = baseIsEqual;
28201
28202   // node_modules/lodash-es/now.js
28203   var now2 = function() {
28204     return root_default.Date.now();
28205   };
28206   var now_default = now2;
28207
28208   // node_modules/lodash-es/debounce.js
28209   var FUNC_ERROR_TEXT = "Expected a function";
28210   var nativeMax = Math.max;
28211   var nativeMin = Math.min;
28212   function debounce(func, wait, options2) {
28213     var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
28214     if (typeof func != "function") {
28215       throw new TypeError(FUNC_ERROR_TEXT);
28216     }
28217     wait = toNumber_default(wait) || 0;
28218     if (isObject_default(options2)) {
28219       leading = !!options2.leading;
28220       maxing = "maxWait" in options2;
28221       maxWait = maxing ? nativeMax(toNumber_default(options2.maxWait) || 0, wait) : maxWait;
28222       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28223     }
28224     function invokeFunc(time) {
28225       var args = lastArgs, thisArg = lastThis;
28226       lastArgs = lastThis = void 0;
28227       lastInvokeTime = time;
28228       result = func.apply(thisArg, args);
28229       return result;
28230     }
28231     function leadingEdge(time) {
28232       lastInvokeTime = time;
28233       timerId = setTimeout(timerExpired, wait);
28234       return leading ? invokeFunc(time) : result;
28235     }
28236     function remainingWait(time) {
28237       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
28238       return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
28239     }
28240     function shouldInvoke(time) {
28241       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
28242       return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
28243     }
28244     function timerExpired() {
28245       var time = now_default();
28246       if (shouldInvoke(time)) {
28247         return trailingEdge(time);
28248       }
28249       timerId = setTimeout(timerExpired, remainingWait(time));
28250     }
28251     function trailingEdge(time) {
28252       timerId = void 0;
28253       if (trailing && lastArgs) {
28254         return invokeFunc(time);
28255       }
28256       lastArgs = lastThis = void 0;
28257       return result;
28258     }
28259     function cancel() {
28260       if (timerId !== void 0) {
28261         clearTimeout(timerId);
28262       }
28263       lastInvokeTime = 0;
28264       lastArgs = lastCallTime = lastThis = timerId = void 0;
28265     }
28266     function flush() {
28267       return timerId === void 0 ? result : trailingEdge(now_default());
28268     }
28269     function debounced() {
28270       var time = now_default(), isInvoking = shouldInvoke(time);
28271       lastArgs = arguments;
28272       lastThis = this;
28273       lastCallTime = time;
28274       if (isInvoking) {
28275         if (timerId === void 0) {
28276           return leadingEdge(lastCallTime);
28277         }
28278         if (maxing) {
28279           clearTimeout(timerId);
28280           timerId = setTimeout(timerExpired, wait);
28281           return invokeFunc(lastCallTime);
28282         }
28283       }
28284       if (timerId === void 0) {
28285         timerId = setTimeout(timerExpired, wait);
28286       }
28287       return result;
28288     }
28289     debounced.cancel = cancel;
28290     debounced.flush = flush;
28291     return debounced;
28292   }
28293   var debounce_default = debounce;
28294
28295   // node_modules/lodash-es/_escapeHtmlChar.js
28296   var htmlEscapes = {
28297     "&": "&amp;",
28298     "<": "&lt;",
28299     ">": "&gt;",
28300     '"': "&quot;",
28301     "'": "&#39;"
28302   };
28303   var escapeHtmlChar = basePropertyOf_default(htmlEscapes);
28304   var escapeHtmlChar_default = escapeHtmlChar;
28305
28306   // node_modules/lodash-es/escape.js
28307   var reUnescapedHtml = /[&<>"']/g;
28308   var reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
28309   function escape2(string) {
28310     string = toString_default(string);
28311     return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar_default) : string;
28312   }
28313   var escape_default = escape2;
28314
28315   // node_modules/lodash-es/isEqual.js
28316   function isEqual(value, other) {
28317     return baseIsEqual_default(value, other);
28318   }
28319   var isEqual_default = isEqual;
28320
28321   // node_modules/lodash-es/isNumber.js
28322   var numberTag3 = "[object Number]";
28323   function isNumber(value) {
28324     return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag3;
28325   }
28326   var isNumber_default = isNumber;
28327
28328   // node_modules/lodash-es/throttle.js
28329   var FUNC_ERROR_TEXT2 = "Expected a function";
28330   function throttle(func, wait, options2) {
28331     var leading = true, trailing = true;
28332     if (typeof func != "function") {
28333       throw new TypeError(FUNC_ERROR_TEXT2);
28334     }
28335     if (isObject_default(options2)) {
28336       leading = "leading" in options2 ? !!options2.leading : leading;
28337       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28338     }
28339     return debounce_default(func, wait, {
28340       "leading": leading,
28341       "maxWait": wait,
28342       "trailing": trailing
28343     });
28344   }
28345   var throttle_default = throttle;
28346
28347   // node_modules/lodash-es/_unescapeHtmlChar.js
28348   var htmlUnescapes = {
28349     "&amp;": "&",
28350     "&lt;": "<",
28351     "&gt;": ">",
28352     "&quot;": '"',
28353     "&#39;": "'"
28354   };
28355   var unescapeHtmlChar = basePropertyOf_default(htmlUnescapes);
28356   var unescapeHtmlChar_default = unescapeHtmlChar;
28357
28358   // node_modules/lodash-es/unescape.js
28359   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
28360   var reHasEscapedHtml = RegExp(reEscapedHtml.source);
28361   function unescape(string) {
28362     string = toString_default(string);
28363     return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string;
28364   }
28365   var unescape_default = unescape;
28366
28367   // modules/util/detect.js
28368   var _detected;
28369   function utilDetect(refresh2) {
28370     if (_detected && !refresh2)
28371       return _detected;
28372     _detected = {};
28373     const ua = navigator.userAgent;
28374     let m2 = null;
28375     m2 = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i);
28376     if (m2 !== null) {
28377       _detected.browser = m2[1];
28378       _detected.version = m2[2];
28379     }
28380     if (!_detected.browser) {
28381       m2 = ua.match(/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i);
28382       if (m2 !== null) {
28383         _detected.browser = "msie";
28384         _detected.version = m2[1];
28385       }
28386     }
28387     if (!_detected.browser) {
28388       m2 = ua.match(/(opr)\/?\s*(\.?\d+(\.\d+)*)/i);
28389       if (m2 !== null) {
28390         _detected.browser = "Opera";
28391         _detected.version = m2[2];
28392       }
28393     }
28394     if (!_detected.browser) {
28395       m2 = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
28396       if (m2 !== null) {
28397         _detected.browser = m2[1];
28398         _detected.version = m2[2];
28399         m2 = ua.match(/version\/([\.\d]+)/i);
28400         if (m2 !== null)
28401           _detected.version = m2[1];
28402       }
28403     }
28404     if (!_detected.browser) {
28405       _detected.browser = navigator.appName;
28406       _detected.version = navigator.appVersion;
28407     }
28408     _detected.version = _detected.version.split(/\W/).slice(0, 2).join(".");
28409     _detected.opera = _detected.browser.toLowerCase() === "opera" && Number(_detected.version) < 15;
28410     if (_detected.browser.toLowerCase() === "msie") {
28411       _detected.ie = true;
28412       _detected.browser = "Internet Explorer";
28413       _detected.support = false;
28414     } else {
28415       _detected.ie = false;
28416       _detected.support = true;
28417     }
28418     _detected.filedrop = window.FileReader && "ondrop" in window;
28419     if (/Win/.test(ua)) {
28420       _detected.os = "win";
28421       _detected.platform = "Windows";
28422     } else if (/Mac/.test(ua)) {
28423       _detected.os = "mac";
28424       _detected.platform = "Macintosh";
28425     } else if (/X11/.test(ua) || /Linux/.test(ua)) {
28426       _detected.os = "linux";
28427       _detected.platform = "Linux";
28428     } else {
28429       _detected.os = "win";
28430       _detected.platform = "Unknown";
28431     }
28432     _detected.isMobileWebKit = (/\b(iPad|iPhone|iPod)\b/.test(ua) || // HACK: iPadOS 13+ requests desktop sites by default by using a Mac user agent,
28433     // so assume any "mac" with multitouch is actually iOS
28434     navigator.platform === "MacIntel" && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 1) && /WebKit/.test(ua) && !/Edge/.test(ua) && !window.MSStream;
28435     _detected.browserLocales = Array.from(new Set(
28436       // remove duplicates
28437       [navigator.language].concat(navigator.languages || []).concat([
28438         // old property for backwards compatibility
28439         navigator.userLanguage
28440       ]).filter(Boolean)
28441     ));
28442     const loc = window.top.location;
28443     let origin = loc.origin;
28444     if (!origin) {
28445       origin = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "");
28446     }
28447     _detected.host = origin + loc.pathname;
28448     return _detected;
28449   }
28450
28451   // modules/util/aes.js
28452   var import_aes_js = __toESM(require_aes_js());
28453   var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208];
28454   function utilAesEncrypt(text, key) {
28455     key = key || DEFAULT_128;
28456     const textBytes = import_aes_js.default.utils.utf8.toBytes(text);
28457     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28458     const encryptedBytes = aesCtr.encrypt(textBytes);
28459     const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes);
28460     return encryptedHex;
28461   }
28462   function utilAesDecrypt(encryptedHex, key) {
28463     key = key || DEFAULT_128;
28464     const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex);
28465     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28466     const decryptedBytes = aesCtr.decrypt(encryptedBytes);
28467     const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes);
28468     return text;
28469   }
28470
28471   // modules/util/clean_tags.js
28472   function utilCleanTags(tags) {
28473     var out = {};
28474     for (var k2 in tags) {
28475       if (!k2)
28476         continue;
28477       var v2 = tags[k2];
28478       if (v2 !== void 0) {
28479         out[k2] = cleanValue(k2, v2);
28480       }
28481     }
28482     return out;
28483     function cleanValue(k3, v3) {
28484       function keepSpaces(k4) {
28485         return /_hours|_times|:conditional$/.test(k4);
28486       }
28487       function skip(k4) {
28488         return /^(description|note|fixme|inscription)$/.test(k4);
28489       }
28490       if (skip(k3))
28491         return v3;
28492       var cleaned = v3.split(";").map(function(s2) {
28493         return s2.trim();
28494       }).join(keepSpaces(k3) ? "; " : ";");
28495       if (k3.indexOf("website") !== -1 || k3.indexOf("email") !== -1 || cleaned.indexOf("http") === 0) {
28496         cleaned = cleaned.replace(/[\u200B-\u200F\uFEFF]/g, "");
28497       }
28498       return cleaned;
28499     }
28500   }
28501
28502   // modules/util/get_set_value.js
28503   function utilGetSetValue(selection2, value, shouldUpdate) {
28504     function setValue(value2, shouldUpdate2) {
28505       function valueNull() {
28506         delete this.value;
28507       }
28508       function valueConstant() {
28509         if (shouldUpdate2(this.value, value2)) {
28510           this.value = value2;
28511         }
28512       }
28513       function valueFunction() {
28514         var x2 = value2.apply(this, arguments);
28515         if (x2 === null || x2 === void 0) {
28516           delete this.value;
28517         } else if (shouldUpdate2(this.value, x2)) {
28518           this.value = x2;
28519         }
28520       }
28521       return value2 === null || value2 === void 0 ? valueNull : typeof value2 === "function" ? valueFunction : valueConstant;
28522     }
28523     if (arguments.length === 1) {
28524       return selection2.property("value");
28525     }
28526     if (shouldUpdate === void 0) {
28527       shouldUpdate = (a2, b2) => a2 !== b2;
28528     }
28529     return selection2.each(setValue(value, shouldUpdate));
28530   }
28531
28532   // modules/util/keybinding.js
28533   function utilKeybinding(namespace) {
28534     var _keybindings = {};
28535     function testBindings(d3_event, isCapturing) {
28536       var didMatch = false;
28537       var bindings = Object.keys(_keybindings).map(function(id2) {
28538         return _keybindings[id2];
28539       });
28540       var i3, binding;
28541       for (i3 = 0; i3 < bindings.length; i3++) {
28542         binding = bindings[i3];
28543         if (!binding.event.modifiers.shiftKey)
28544           continue;
28545         if (!!binding.capture !== isCapturing)
28546           continue;
28547         if (matches(d3_event, binding, true)) {
28548           binding.callback(d3_event);
28549           didMatch = true;
28550           break;
28551         }
28552       }
28553       if (didMatch)
28554         return;
28555       for (i3 = 0; i3 < bindings.length; i3++) {
28556         binding = bindings[i3];
28557         if (binding.event.modifiers.shiftKey)
28558           continue;
28559         if (!!binding.capture !== isCapturing)
28560           continue;
28561         if (matches(d3_event, binding, false)) {
28562           binding.callback(d3_event);
28563           break;
28564         }
28565       }
28566       function matches(d3_event2, binding2, testShift) {
28567         var event = d3_event2;
28568         var isMatch = false;
28569         var tryKeyCode = true;
28570         if (event.key !== void 0) {
28571           tryKeyCode = event.key.charCodeAt(0) > 127;
28572           isMatch = true;
28573           if (binding2.event.key === void 0) {
28574             isMatch = false;
28575           } else if (Array.isArray(binding2.event.key)) {
28576             if (binding2.event.key.map(function(s2) {
28577               return s2.toLowerCase();
28578             }).indexOf(event.key.toLowerCase()) === -1) {
28579               isMatch = false;
28580             }
28581           } else {
28582             if (event.key.toLowerCase() !== binding2.event.key.toLowerCase()) {
28583               isMatch = false;
28584             }
28585           }
28586         }
28587         if (!isMatch && (tryKeyCode || binding2.event.modifiers.altKey)) {
28588           isMatch = event.keyCode === binding2.event.keyCode;
28589         }
28590         if (!isMatch)
28591           return false;
28592         if (!(event.ctrlKey && event.altKey)) {
28593           if (event.ctrlKey !== binding2.event.modifiers.ctrlKey)
28594             return false;
28595           if (event.altKey !== binding2.event.modifiers.altKey)
28596             return false;
28597         }
28598         if (event.metaKey !== binding2.event.modifiers.metaKey)
28599           return false;
28600         if (testShift && event.shiftKey !== binding2.event.modifiers.shiftKey)
28601           return false;
28602         return true;
28603       }
28604     }
28605     function capture(d3_event) {
28606       testBindings(d3_event, true);
28607     }
28608     function bubble(d3_event) {
28609       var tagName = select_default2(d3_event.target).node().tagName;
28610       if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
28611         return;
28612       }
28613       testBindings(d3_event, false);
28614     }
28615     function keybinding(selection2) {
28616       selection2 = selection2 || select_default2(document);
28617       selection2.on("keydown.capture." + namespace, capture, true);
28618       selection2.on("keydown.bubble." + namespace, bubble, false);
28619       return keybinding;
28620     }
28621     keybinding.unbind = function(selection2) {
28622       _keybindings = [];
28623       selection2 = selection2 || select_default2(document);
28624       selection2.on("keydown.capture." + namespace, null);
28625       selection2.on("keydown.bubble." + namespace, null);
28626       return keybinding;
28627     };
28628     keybinding.clear = function() {
28629       _keybindings = {};
28630       return keybinding;
28631     };
28632     keybinding.off = function(codes, capture2) {
28633       var arr = utilArrayUniq([].concat(codes));
28634       for (var i3 = 0; i3 < arr.length; i3++) {
28635         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28636         delete _keybindings[id2];
28637       }
28638       return keybinding;
28639     };
28640     keybinding.on = function(codes, callback, capture2) {
28641       if (typeof callback !== "function") {
28642         return keybinding.off(codes, capture2);
28643       }
28644       var arr = utilArrayUniq([].concat(codes));
28645       for (var i3 = 0; i3 < arr.length; i3++) {
28646         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28647         var binding = {
28648           id: id2,
28649           capture: capture2,
28650           callback,
28651           event: {
28652             key: void 0,
28653             // preferred
28654             keyCode: 0,
28655             // fallback
28656             modifiers: {
28657               shiftKey: false,
28658               ctrlKey: false,
28659               altKey: false,
28660               metaKey: false
28661             }
28662           }
28663         };
28664         if (_keybindings[id2]) {
28665           console.warn('warning: duplicate keybinding for "' + id2 + '"');
28666         }
28667         _keybindings[id2] = binding;
28668         var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g);
28669         for (var j2 = 0; j2 < matches.length; j2++) {
28670           if (matches[j2] === "++")
28671             matches[j2] = "+";
28672           if (matches[j2] in utilKeybinding.modifierCodes) {
28673             var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]];
28674             binding.event.modifiers[prop] = true;
28675           } else {
28676             binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2];
28677             if (matches[j2] in utilKeybinding.keyCodes) {
28678               binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]];
28679             }
28680           }
28681         }
28682       }
28683       return keybinding;
28684     };
28685     return keybinding;
28686   }
28687   utilKeybinding.modifierCodes = {
28688     // Shift key, ⇧
28689     "\u21E7": 16,
28690     shift: 16,
28691     // CTRL key, on Mac: ⌃
28692     "\u2303": 17,
28693     ctrl: 17,
28694     // ALT key, on Mac: ⌥ (Alt)
28695     "\u2325": 18,
28696     alt: 18,
28697     option: 18,
28698     // META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
28699     "\u2318": 91,
28700     meta: 91,
28701     cmd: 91,
28702     "super": 91,
28703     win: 91
28704   };
28705   utilKeybinding.modifierProperties = {
28706     16: "shiftKey",
28707     17: "ctrlKey",
28708     18: "altKey",
28709     91: "metaKey"
28710   };
28711   utilKeybinding.plusKeys = ["plus", "ffplus", "=", "ffequals", "\u2260", "\xB1"];
28712   utilKeybinding.minusKeys = ["_", "-", "ffminus", "dash", "\u2013", "\u2014"];
28713   utilKeybinding.keys = {
28714     // Backspace key, on Mac: ⌫ (Backspace)
28715     "\u232B": "Backspace",
28716     backspace: "Backspace",
28717     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28718     "\u21E5": "Tab",
28719     "\u21C6": "Tab",
28720     tab: "Tab",
28721     // Return key, ↩
28722     "\u21A9": "Enter",
28723     "\u21B5": "Enter",
28724     "\u23CE": "Enter",
28725     "return": "Enter",
28726     enter: "Enter",
28727     "\u2305": "Enter",
28728     // Pause/Break key
28729     "pause": "Pause",
28730     "pause-break": "Pause",
28731     // Caps Lock key, ⇪
28732     "\u21EA": "CapsLock",
28733     caps: "CapsLock",
28734     "caps-lock": "CapsLock",
28735     // Escape key, on Mac: ⎋, on Windows: Esc
28736     "\u238B": ["Escape", "Esc"],
28737     escape: ["Escape", "Esc"],
28738     esc: ["Escape", "Esc"],
28739     // Space key
28740     space: [" ", "Spacebar"],
28741     // Page-Up key, or pgup, on Mac: ↖
28742     "\u2196": "PageUp",
28743     pgup: "PageUp",
28744     "page-up": "PageUp",
28745     // Page-Down key, or pgdown, on Mac: ↘
28746     "\u2198": "PageDown",
28747     pgdown: "PageDown",
28748     "page-down": "PageDown",
28749     // END key, on Mac: ⇟
28750     "\u21DF": "End",
28751     end: "End",
28752     // HOME key, on Mac: ⇞
28753     "\u21DE": "Home",
28754     home: "Home",
28755     // Insert key, or ins
28756     ins: "Insert",
28757     insert: "Insert",
28758     // Delete key, on Mac: ⌦ (Delete)
28759     "\u2326": ["Delete", "Del"],
28760     del: ["Delete", "Del"],
28761     "delete": ["Delete", "Del"],
28762     // Left Arrow Key, or ←
28763     "\u2190": ["ArrowLeft", "Left"],
28764     left: ["ArrowLeft", "Left"],
28765     "arrow-left": ["ArrowLeft", "Left"],
28766     // Up Arrow Key, or ↑
28767     "\u2191": ["ArrowUp", "Up"],
28768     up: ["ArrowUp", "Up"],
28769     "arrow-up": ["ArrowUp", "Up"],
28770     // Right Arrow Key, or →
28771     "\u2192": ["ArrowRight", "Right"],
28772     right: ["ArrowRight", "Right"],
28773     "arrow-right": ["ArrowRight", "Right"],
28774     // Up Arrow Key, or ↓
28775     "\u2193": ["ArrowDown", "Down"],
28776     down: ["ArrowDown", "Down"],
28777     "arrow-down": ["ArrowDown", "Down"],
28778     // odities, stuff for backward compatibility (browsers and code):
28779     // Num-Multiply, or *
28780     "*": ["*", "Multiply"],
28781     star: ["*", "Multiply"],
28782     asterisk: ["*", "Multiply"],
28783     multiply: ["*", "Multiply"],
28784     // Num-Plus or +
28785     "+": ["+", "Add"],
28786     "plus": ["+", "Add"],
28787     // Num-Subtract, or -
28788     "-": ["-", "Subtract"],
28789     subtract: ["-", "Subtract"],
28790     "dash": ["-", "Subtract"],
28791     // Semicolon
28792     semicolon: ";",
28793     // = or equals
28794     equals: "=",
28795     // Comma, or ,
28796     comma: ",",
28797     // Period, or ., or full-stop
28798     period: ".",
28799     "full-stop": ".",
28800     // Slash, or /, or forward-slash
28801     slash: "/",
28802     "forward-slash": "/",
28803     // Tick, or `, or back-quote
28804     tick: "`",
28805     "back-quote": "`",
28806     // Open bracket, or [
28807     "open-bracket": "[",
28808     // Back slash, or \
28809     "back-slash": "\\",
28810     // Close bracket, or ]
28811     "close-bracket": "]",
28812     // Apostrophe, or Quote, or '
28813     quote: "'",
28814     apostrophe: "'",
28815     // NUMPAD 0-9
28816     "num-0": "0",
28817     "num-1": "1",
28818     "num-2": "2",
28819     "num-3": "3",
28820     "num-4": "4",
28821     "num-5": "5",
28822     "num-6": "6",
28823     "num-7": "7",
28824     "num-8": "8",
28825     "num-9": "9",
28826     // F1-F25
28827     f1: "F1",
28828     f2: "F2",
28829     f3: "F3",
28830     f4: "F4",
28831     f5: "F5",
28832     f6: "F6",
28833     f7: "F7",
28834     f8: "F8",
28835     f9: "F9",
28836     f10: "F10",
28837     f11: "F11",
28838     f12: "F12",
28839     f13: "F13",
28840     f14: "F14",
28841     f15: "F15",
28842     f16: "F16",
28843     f17: "F17",
28844     f18: "F18",
28845     f19: "F19",
28846     f20: "F20",
28847     f21: "F21",
28848     f22: "F22",
28849     f23: "F23",
28850     f24: "F24",
28851     f25: "F25"
28852   };
28853   utilKeybinding.keyCodes = {
28854     // Backspace key, on Mac: ⌫ (Backspace)
28855     "\u232B": 8,
28856     backspace: 8,
28857     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28858     "\u21E5": 9,
28859     "\u21C6": 9,
28860     tab: 9,
28861     // Return key, ↩
28862     "\u21A9": 13,
28863     "\u21B5": 13,
28864     "\u23CE": 13,
28865     "return": 13,
28866     enter: 13,
28867     "\u2305": 13,
28868     // Pause/Break key
28869     "pause": 19,
28870     "pause-break": 19,
28871     // Caps Lock key, ⇪
28872     "\u21EA": 20,
28873     caps: 20,
28874     "caps-lock": 20,
28875     // Escape key, on Mac: ⎋, on Windows: Esc
28876     "\u238B": 27,
28877     escape: 27,
28878     esc: 27,
28879     // Space key
28880     space: 32,
28881     // Page-Up key, or pgup, on Mac: ↖
28882     "\u2196": 33,
28883     pgup: 33,
28884     "page-up": 33,
28885     // Page-Down key, or pgdown, on Mac: ↘
28886     "\u2198": 34,
28887     pgdown: 34,
28888     "page-down": 34,
28889     // END key, on Mac: ⇟
28890     "\u21DF": 35,
28891     end: 35,
28892     // HOME key, on Mac: ⇞
28893     "\u21DE": 36,
28894     home: 36,
28895     // Insert key, or ins
28896     ins: 45,
28897     insert: 45,
28898     // Delete key, on Mac: ⌦ (Delete)
28899     "\u2326": 46,
28900     del: 46,
28901     "delete": 46,
28902     // Left Arrow Key, or ←
28903     "\u2190": 37,
28904     left: 37,
28905     "arrow-left": 37,
28906     // Up Arrow Key, or ↑
28907     "\u2191": 38,
28908     up: 38,
28909     "arrow-up": 38,
28910     // Right Arrow Key, or →
28911     "\u2192": 39,
28912     right: 39,
28913     "arrow-right": 39,
28914     // Up Arrow Key, or ↓
28915     "\u2193": 40,
28916     down: 40,
28917     "arrow-down": 40,
28918     // odities, printing characters that come out wrong:
28919     // Firefox Equals
28920     "ffequals": 61,
28921     // Num-Multiply, or *
28922     "*": 106,
28923     star: 106,
28924     asterisk: 106,
28925     multiply: 106,
28926     // Num-Plus or +
28927     "+": 107,
28928     "plus": 107,
28929     // Num-Subtract, or -
28930     "-": 109,
28931     subtract: 109,
28932     // Vertical Bar / Pipe
28933     "|": 124,
28934     // Firefox Plus
28935     "ffplus": 171,
28936     // Firefox Minus
28937     "ffminus": 173,
28938     // Semicolon
28939     ";": 186,
28940     semicolon: 186,
28941     // = or equals
28942     "=": 187,
28943     "equals": 187,
28944     // Comma, or ,
28945     ",": 188,
28946     comma: 188,
28947     // Dash / Underscore key
28948     "dash": 189,
28949     // Period, or ., or full-stop
28950     ".": 190,
28951     period: 190,
28952     "full-stop": 190,
28953     // Slash, or /, or forward-slash
28954     "/": 191,
28955     slash: 191,
28956     "forward-slash": 191,
28957     // Tick, or `, or back-quote
28958     "`": 192,
28959     tick: 192,
28960     "back-quote": 192,
28961     // Open bracket, or [
28962     "[": 219,
28963     "open-bracket": 219,
28964     // Back slash, or \
28965     "\\": 220,
28966     "back-slash": 220,
28967     // Close bracket, or ]
28968     "]": 221,
28969     "close-bracket": 221,
28970     // Apostrophe, or Quote, or '
28971     "'": 222,
28972     quote: 222,
28973     apostrophe: 222
28974   };
28975   var i = 95;
28976   var n = 0;
28977   while (++i < 106) {
28978     utilKeybinding.keyCodes["num-" + n] = i;
28979     ++n;
28980   }
28981   i = 47;
28982   n = 0;
28983   while (++i < 58) {
28984     utilKeybinding.keyCodes[n] = i;
28985     ++n;
28986   }
28987   i = 111;
28988   n = 1;
28989   while (++i < 136) {
28990     utilKeybinding.keyCodes["f" + n] = i;
28991     ++n;
28992   }
28993   i = 64;
28994   while (++i < 91) {
28995     utilKeybinding.keyCodes[String.fromCharCode(i).toLowerCase()] = i;
28996   }
28997
28998   // modules/util/object.js
28999   function utilObjectOmit(obj, omitKeys) {
29000     return Object.keys(obj).reduce(function(result, key) {
29001       if (omitKeys.indexOf(key) === -1) {
29002         result[key] = obj[key];
29003       }
29004       return result;
29005     }, {});
29006   }
29007
29008   // modules/util/rebind.js
29009   function utilRebind(target, source) {
29010     var i3 = 1, n3 = arguments.length, method;
29011     while (++i3 < n3) {
29012       target[method = arguments[i3]] = d3_rebind(target, source, source[method]);
29013     }
29014     return target;
29015   }
29016   function d3_rebind(target, source, method) {
29017     return function() {
29018       var value = method.apply(source, arguments);
29019       return value === source ? target : value;
29020     };
29021   }
29022
29023   // modules/util/session_mutex.js
29024   function utilSessionMutex(name) {
29025     var mutex = {};
29026     var intervalID;
29027     function renew() {
29028       var expires = /* @__PURE__ */ new Date();
29029       expires.setSeconds(expires.getSeconds() + 5);
29030       document.cookie = name + "=1; expires=" + expires.toUTCString() + "; sameSite=strict";
29031     }
29032     mutex.lock = function() {
29033       if (intervalID)
29034         return true;
29035       var cookie = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1");
29036       if (cookie)
29037         return false;
29038       renew();
29039       intervalID = window.setInterval(renew, 4e3);
29040       return true;
29041     };
29042     mutex.unlock = function() {
29043       if (!intervalID)
29044         return;
29045       document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; sameSite=strict";
29046       clearInterval(intervalID);
29047       intervalID = null;
29048     };
29049     mutex.locked = function() {
29050       return !!intervalID;
29051     };
29052     return mutex;
29053   }
29054
29055   // modules/util/tiler.js
29056   function utilTiler() {
29057     var _size = [256, 256];
29058     var _scale = 256;
29059     var _tileSize = 256;
29060     var _zoomExtent = [0, 20];
29061     var _translate = [_size[0] / 2, _size[1] / 2];
29062     var _margin = 0;
29063     var _skipNullIsland = false;
29064     function clamp3(num, min3, max3) {
29065       return Math.max(min3, Math.min(num, max3));
29066     }
29067     function nearNullIsland(tile) {
29068       var x2 = tile[0];
29069       var y2 = tile[1];
29070       var z2 = tile[2];
29071       if (z2 >= 7) {
29072         var center = Math.pow(2, z2 - 1);
29073         var width = Math.pow(2, z2 - 6);
29074         var min3 = center - width / 2;
29075         var max3 = center + width / 2 - 1;
29076         return x2 >= min3 && x2 <= max3 && y2 >= min3 && y2 <= max3;
29077       }
29078       return false;
29079     }
29080     function tiler9() {
29081       var z2 = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
29082       var z0 = clamp3(Math.round(z2), _zoomExtent[0], _zoomExtent[1]);
29083       var tileMin = 0;
29084       var tileMax = Math.pow(2, z0) - 1;
29085       var log2ts = Math.log(_tileSize) * Math.LOG2E;
29086       var k2 = Math.pow(2, z2 - z0 + log2ts);
29087       var origin = [
29088         (_translate[0] - _scale / 2) / k2,
29089         (_translate[1] - _scale / 2) / k2
29090       ];
29091       var cols = range(
29092         clamp3(Math.floor(-origin[0]) - _margin, tileMin, tileMax + 1),
29093         clamp3(Math.ceil(_size[0] / k2 - origin[0]) + _margin, tileMin, tileMax + 1)
29094       );
29095       var rows = range(
29096         clamp3(Math.floor(-origin[1]) - _margin, tileMin, tileMax + 1),
29097         clamp3(Math.ceil(_size[1] / k2 - origin[1]) + _margin, tileMin, tileMax + 1)
29098       );
29099       var tiles = [];
29100       for (var i3 = 0; i3 < rows.length; i3++) {
29101         var y2 = rows[i3];
29102         for (var j2 = 0; j2 < cols.length; j2++) {
29103           var x2 = cols[j2];
29104           if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) {
29105             tiles.unshift([x2, y2, z0]);
29106           } else {
29107             tiles.push([x2, y2, z0]);
29108           }
29109         }
29110       }
29111       tiles.translate = origin;
29112       tiles.scale = k2;
29113       return tiles;
29114     }
29115     tiler9.getTiles = function(projection2) {
29116       var origin = [
29117         projection2.scale() * Math.PI - projection2.translate()[0],
29118         projection2.scale() * Math.PI - projection2.translate()[1]
29119       ];
29120       this.size(projection2.clipExtent()[1]).scale(projection2.scale() * 2 * Math.PI).translate(projection2.translate());
29121       var tiles = tiler9();
29122       var ts = tiles.scale;
29123       return tiles.map(function(tile) {
29124         if (_skipNullIsland && nearNullIsland(tile)) {
29125           return false;
29126         }
29127         var x2 = tile[0] * ts - origin[0];
29128         var y2 = tile[1] * ts - origin[1];
29129         return {
29130           id: tile.toString(),
29131           xyz: tile,
29132           extent: geoExtent(
29133             projection2.invert([x2, y2 + ts]),
29134             projection2.invert([x2 + ts, y2])
29135           )
29136         };
29137       }).filter(Boolean);
29138     };
29139     tiler9.getGeoJSON = function(projection2) {
29140       var features = tiler9.getTiles(projection2).map(function(tile) {
29141         return {
29142           type: "Feature",
29143           properties: {
29144             id: tile.id,
29145             name: tile.id
29146           },
29147           geometry: {
29148             type: "Polygon",
29149             coordinates: [tile.extent.polygon()]
29150           }
29151         };
29152       });
29153       return {
29154         type: "FeatureCollection",
29155         features
29156       };
29157     };
29158     tiler9.tileSize = function(val) {
29159       if (!arguments.length)
29160         return _tileSize;
29161       _tileSize = val;
29162       return tiler9;
29163     };
29164     tiler9.zoomExtent = function(val) {
29165       if (!arguments.length)
29166         return _zoomExtent;
29167       _zoomExtent = val;
29168       return tiler9;
29169     };
29170     tiler9.size = function(val) {
29171       if (!arguments.length)
29172         return _size;
29173       _size = val;
29174       return tiler9;
29175     };
29176     tiler9.scale = function(val) {
29177       if (!arguments.length)
29178         return _scale;
29179       _scale = val;
29180       return tiler9;
29181     };
29182     tiler9.translate = function(val) {
29183       if (!arguments.length)
29184         return _translate;
29185       _translate = val;
29186       return tiler9;
29187     };
29188     tiler9.margin = function(val) {
29189       if (!arguments.length)
29190         return _margin;
29191       _margin = +val;
29192       return tiler9;
29193     };
29194     tiler9.skipNullIsland = function(val) {
29195       if (!arguments.length)
29196         return _skipNullIsland;
29197       _skipNullIsland = val;
29198       return tiler9;
29199     };
29200     return tiler9;
29201   }
29202
29203   // modules/util/trigger_event.js
29204   function utilTriggerEvent(target, type2, eventProperties) {
29205     target.each(function() {
29206       var evt = document.createEvent("HTMLEvents");
29207       evt.initEvent(type2, true, true);
29208       for (var prop in eventProperties) {
29209         evt[prop] = eventProperties[prop];
29210       }
29211       this.dispatchEvent(evt);
29212     });
29213   }
29214
29215   // modules/util/units.js
29216   var OSM_PRECISION = 7;
29217   function displayLength(m2, isImperial) {
29218     var d2 = m2 * (isImperial ? 3.28084 : 1);
29219     var unit2;
29220     if (isImperial) {
29221       if (d2 >= 5280) {
29222         d2 /= 5280;
29223         unit2 = "miles";
29224       } else {
29225         unit2 = "feet";
29226       }
29227     } else {
29228       if (d2 >= 1e3) {
29229         d2 /= 1e3;
29230         unit2 = "kilometers";
29231       } else {
29232         unit2 = "meters";
29233       }
29234     }
29235     return _t("units." + unit2, {
29236       quantity: d2.toLocaleString(_mainLocalizer.localeCode(), {
29237         maximumSignificantDigits: 4
29238       })
29239     });
29240   }
29241   function displayArea(m2, isImperial) {
29242     var locale2 = _mainLocalizer.localeCode();
29243     var d2 = m2 * (isImperial ? 10.7639111056 : 1);
29244     var d1, d22, area;
29245     var unit1 = "";
29246     var unit2 = "";
29247     if (isImperial) {
29248       if (d2 >= 6969600) {
29249         d1 = d2 / 27878400;
29250         unit1 = "square_miles";
29251       } else {
29252         d1 = d2;
29253         unit1 = "square_feet";
29254       }
29255       if (d2 > 4356 && d2 < 4356e4) {
29256         d22 = d2 / 43560;
29257         unit2 = "acres";
29258       }
29259     } else {
29260       if (d2 >= 25e4) {
29261         d1 = d2 / 1e6;
29262         unit1 = "square_kilometers";
29263       } else {
29264         d1 = d2;
29265         unit1 = "square_meters";
29266       }
29267       if (d2 > 1e3 && d2 < 1e7) {
29268         d22 = d2 / 1e4;
29269         unit2 = "hectares";
29270       }
29271     }
29272     area = _t("units." + unit1, {
29273       quantity: d1.toLocaleString(locale2, {
29274         maximumSignificantDigits: 4
29275       })
29276     });
29277     if (d22) {
29278       return _t("units.area_pair", {
29279         area1: area,
29280         area2: _t("units." + unit2, {
29281           quantity: d22.toLocaleString(locale2, {
29282             maximumSignificantDigits: 2
29283           })
29284         })
29285       });
29286     } else {
29287       return area;
29288     }
29289   }
29290   function wrap(x2, min3, max3) {
29291     var d2 = max3 - min3;
29292     return ((x2 - min3) % d2 + d2) % d2 + min3;
29293   }
29294   function clamp(x2, min3, max3) {
29295     return Math.max(min3, Math.min(x2, max3));
29296   }
29297   function roundToDecimal(target, decimalPlace) {
29298     target = Number(target);
29299     decimalPlace = Number(decimalPlace);
29300     const factor = Math.pow(10, decimalPlace);
29301     return Math.round(target * factor) / factor;
29302   }
29303   function displayCoordinate(deg, pos, neg) {
29304     var displayCoordinate2;
29305     var locale2 = _mainLocalizer.localeCode();
29306     var degreesFloor = Math.floor(Math.abs(deg));
29307     var min3 = (Math.abs(deg) - degreesFloor) * 60;
29308     var minFloor = Math.floor(min3);
29309     var sec = (min3 - minFloor) * 60;
29310     var fix = roundToDecimal(sec, 8);
29311     var secRounded = roundToDecimal(fix, 0);
29312     if (secRounded === 60) {
29313       secRounded = 0;
29314       minFloor += 1;
29315       if (minFloor === 60) {
29316         minFloor = 0;
29317         degreesFloor += 1;
29318       }
29319     }
29320     displayCoordinate2 = _t("units.arcdegrees", {
29321       quantity: degreesFloor.toLocaleString(locale2)
29322     }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", {
29323       quantity: minFloor.toLocaleString(locale2)
29324     }) : "") + (secRounded !== 0 ? _t("units.arcseconds", {
29325       quantity: secRounded.toLocaleString(locale2)
29326     }) : "");
29327     if (deg === 0) {
29328       return displayCoordinate2;
29329     } else {
29330       return _t("units.coordinate", {
29331         coordinate: displayCoordinate2,
29332         direction: _t("units." + (deg > 0 ? pos : neg))
29333       });
29334     }
29335   }
29336   function dmsCoordinatePair(coord2) {
29337     return _t("units.coordinate_pair", {
29338       latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"),
29339       longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west")
29340     });
29341   }
29342   function decimalCoordinatePair(coord2) {
29343     return _t("units.coordinate_pair", {
29344       latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION),
29345       longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION)
29346     });
29347   }
29348   function dmsMatcher(q2) {
29349     const matchers = [
29350       // D M SS , D M SS  ex: 35 11 10.1 , 136 49 53.8
29351       {
29352         condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/,
29353         parser: function(q3) {
29354           const match = this.condition.exec(q3);
29355           const lat = +match[2] + +match[3] / 60 + +match[4] / 3600;
29356           const lng = +match[6] + +match[7] / 60 + +match[8] / 3600;
29357           const isNegLat = match[1] === "-" ? -lat : lat;
29358           const isNegLng = match[5] === "-" ? -lng : lng;
29359           const d2 = [isNegLat, isNegLng];
29360           return d2;
29361         }
29362       },
29363       // D MM , D MM ex: 35 11.1683 , 136 49.8966
29364       {
29365         condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/,
29366         parser: function(q3) {
29367           const match = this.condition.exec(q3);
29368           const lat = +match[2] + +match[3] / 60;
29369           const lng = +match[5] + +match[6] / 60;
29370           const isNegLat = match[1] === "-" ? -lat : lat;
29371           const isNegLng = match[4] === "-" ? -lng : lng;
29372           const d2 = [isNegLat, isNegLng];
29373           return d2;
29374         }
29375       }
29376     ];
29377     for (const matcher of matchers) {
29378       if (matcher.condition.test(q2)) {
29379         return matcher.parser(q2);
29380       }
29381     }
29382     return null;
29383   }
29384
29385   // modules/core/localizer.js
29386   var _mainLocalizer = coreLocalizer();
29387   var _t = _mainLocalizer.t;
29388   function coreLocalizer() {
29389     let localizer = {};
29390     let _dataLanguages = {};
29391     let _dataLocales = {};
29392     let _localeStrings = {};
29393     let _localeCode = "en-US";
29394     let _localeCodes = ["en-US", "en"];
29395     let _languageCode = "en";
29396     let _textDirection = "ltr";
29397     let _usesMetric = false;
29398     let _languageNames = {};
29399     let _scriptNames = {};
29400     localizer.localeCode = () => _localeCode;
29401     localizer.localeCodes = () => _localeCodes;
29402     localizer.languageCode = () => _languageCode;
29403     localizer.textDirection = () => _textDirection;
29404     localizer.usesMetric = () => _usesMetric;
29405     localizer.languageNames = () => _languageNames;
29406     localizer.scriptNames = () => _scriptNames;
29407     let _preferredLocaleCodes = [];
29408     localizer.preferredLocaleCodes = function(codes) {
29409       if (!arguments.length)
29410         return _preferredLocaleCodes;
29411       if (typeof codes === "string") {
29412         _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean);
29413       } else {
29414         _preferredLocaleCodes = codes;
29415       }
29416       return localizer;
29417     };
29418     var _loadPromise;
29419     localizer.ensureLoaded = () => {
29420       if (_loadPromise)
29421         return _loadPromise;
29422       let filesToFetch = [
29423         "languages",
29424         // load the list of languages
29425         "locales"
29426         // load the list of supported locales
29427       ];
29428       const localeDirs = {
29429         general: "locales",
29430         tagging: presetsCdnUrl + "dist/translations"
29431       };
29432       let fileMap = _mainFileFetcher.fileMap();
29433       for (let scopeId in localeDirs) {
29434         const key = "locales_index_".concat(scopeId);
29435         if (!fileMap[key]) {
29436           fileMap[key] = localeDirs[scopeId] + "/index.min.json";
29437         }
29438         filesToFetch.push(key);
29439       }
29440       return _loadPromise = Promise.all(filesToFetch.map((key) => _mainFileFetcher.get(key))).then((results) => {
29441         _dataLanguages = results[0];
29442         _dataLocales = results[1];
29443         let indexes = results.slice(2);
29444         let requestedLocales = (_preferredLocaleCodes || []).concat(utilDetect().browserLocales).concat(["en"]);
29445         _localeCodes = localesToUseFrom(requestedLocales);
29446         _localeCode = _localeCodes[0];
29447         let loadStringsPromises = [];
29448         indexes.forEach((index, i3) => {
29449           const fullCoverageIndex = _localeCodes.findIndex(function(locale2) {
29450             return index[locale2] && index[locale2].pct === 1;
29451           });
29452           _localeCodes.slice(0, fullCoverageIndex + 1).forEach(function(code) {
29453             let scopeId = Object.keys(localeDirs)[i3];
29454             let directory = Object.values(localeDirs)[i3];
29455             if (index[code])
29456               loadStringsPromises.push(localizer.loadLocale(code, scopeId, directory));
29457           });
29458         });
29459         return Promise.all(loadStringsPromises);
29460       }).then(() => {
29461         updateForCurrentLocale();
29462       }).catch((err) => console.error(err));
29463     };
29464     function localesToUseFrom(requestedLocales) {
29465       let supportedLocales = _dataLocales;
29466       let toUse = [];
29467       for (let i3 in requestedLocales) {
29468         let locale2 = requestedLocales[i3];
29469         if (supportedLocales[locale2])
29470           toUse.push(locale2);
29471         if (locale2.includes("-")) {
29472           let langPart = locale2.split("-")[0];
29473           if (supportedLocales[langPart])
29474             toUse.push(langPart);
29475         }
29476       }
29477       return utilArrayUniq(toUse);
29478     }
29479     function updateForCurrentLocale() {
29480       if (!_localeCode)
29481         return;
29482       _languageCode = _localeCode.split("-")[0];
29483       const currentData = _dataLocales[_localeCode] || _dataLocales[_languageCode];
29484       const hash = utilStringQs(window.location.hash);
29485       if (hash.rtl === "true") {
29486         _textDirection = "rtl";
29487       } else if (hash.rtl === "false") {
29488         _textDirection = "ltr";
29489       } else {
29490         _textDirection = currentData && currentData.rtl ? "rtl" : "ltr";
29491       }
29492       let locale2 = _localeCode;
29493       if (locale2.toLowerCase() === "en-us")
29494         locale2 = "en";
29495       _languageNames = _localeStrings.general[locale2].languageNames || _localeStrings.general[_languageCode].languageNames;
29496       _scriptNames = _localeStrings.general[locale2].scriptNames || _localeStrings.general[_languageCode].scriptNames;
29497       _usesMetric = _localeCode.slice(-3).toLowerCase() !== "-us";
29498     }
29499     localizer.loadLocale = (locale2, scopeId, directory) => {
29500       if (locale2.toLowerCase() === "en-us")
29501         locale2 = "en";
29502       if (_localeStrings[scopeId] && _localeStrings[scopeId][locale2]) {
29503         return Promise.resolve(locale2);
29504       }
29505       let fileMap = _mainFileFetcher.fileMap();
29506       const key = "locale_".concat(scopeId, "_").concat(locale2);
29507       if (!fileMap[key]) {
29508         fileMap[key] = "".concat(directory, "/").concat(locale2, ".min.json");
29509       }
29510       return _mainFileFetcher.get(key).then((d2) => {
29511         if (!_localeStrings[scopeId])
29512           _localeStrings[scopeId] = {};
29513         _localeStrings[scopeId][locale2] = d2[locale2];
29514         return locale2;
29515       });
29516     };
29517     localizer.pluralRule = function(number3) {
29518       return pluralRule(number3, _localeCode);
29519     };
29520     function pluralRule(number3, localeCode) {
29521       const rules = "Intl" in window && Intl.PluralRules && new Intl.PluralRules(localeCode);
29522       if (rules) {
29523         return rules.select(number3);
29524       }
29525       if (number3 === 1)
29526         return "one";
29527       return "other";
29528     }
29529     localizer.tInfo = function(origStringId, replacements, locale2) {
29530       let stringId = origStringId.trim();
29531       let scopeId = "general";
29532       if (stringId[0] === "_") {
29533         let split = stringId.split(".");
29534         scopeId = split[0].slice(1);
29535         stringId = split.slice(1).join(".");
29536       }
29537       locale2 = locale2 || _localeCode;
29538       let path = stringId.split(".").map((s2) => s2.replace(/<TX_DOT>/g, ".")).reverse();
29539       let stringsKey = locale2;
29540       if (stringsKey.toLowerCase() === "en-us")
29541         stringsKey = "en";
29542       let result = _localeStrings && _localeStrings[scopeId] && _localeStrings[scopeId][stringsKey];
29543       while (result !== void 0 && path.length) {
29544         result = result[path.pop()];
29545       }
29546       if (result !== void 0) {
29547         if (replacements) {
29548           if (typeof result === "object" && Object.keys(result).length) {
29549             const number3 = Object.values(replacements).find(function(value) {
29550               return typeof value === "number";
29551             });
29552             if (number3 !== void 0) {
29553               const rule = pluralRule(number3, locale2);
29554               if (result[rule]) {
29555                 result = result[rule];
29556               } else {
29557                 result = Object.values(result)[0];
29558               }
29559             }
29560           }
29561           if (typeof result === "string") {
29562             for (let key in replacements) {
29563               let value = replacements[key];
29564               if (typeof value === "number") {
29565                 if (value.toLocaleString) {
29566                   value = value.toLocaleString(locale2, {
29567                     style: "decimal",
29568                     useGrouping: true,
29569                     minimumFractionDigits: 0
29570                   });
29571                 } else {
29572                   value = value.toString();
29573                 }
29574               }
29575               const token = "{".concat(key, "}");
29576               const regex = new RegExp(token, "g");
29577               result = result.replace(regex, value);
29578             }
29579           }
29580         }
29581         if (typeof result === "string") {
29582           return {
29583             text: result,
29584             locale: locale2
29585           };
29586         }
29587       }
29588       let index = _localeCodes.indexOf(locale2);
29589       if (index >= 0 && index < _localeCodes.length - 1) {
29590         let fallback = _localeCodes[index + 1];
29591         return localizer.tInfo(origStringId, replacements, fallback);
29592       }
29593       if (replacements && "default" in replacements) {
29594         return {
29595           text: replacements.default,
29596           locale: null
29597         };
29598       }
29599       const missing = "Missing ".concat(locale2, " translation: ").concat(origStringId);
29600       if (typeof console !== "undefined")
29601         console.error(missing);
29602       return {
29603         text: missing,
29604         locale: "en"
29605       };
29606     };
29607     localizer.hasTextForStringId = function(stringId) {
29608       return !!localizer.tInfo(stringId, { default: "nothing found" }).locale;
29609     };
29610     localizer.t = function(stringId, replacements, locale2) {
29611       return localizer.tInfo(stringId, replacements, locale2).text;
29612     };
29613     localizer.t.html = function(stringId, replacements, locale2) {
29614       replacements = Object.assign({}, replacements);
29615       for (var k2 in replacements) {
29616         if (typeof replacements[k2] === "string") {
29617           replacements[k2] = escape_default(replacements[k2]);
29618         }
29619         if (typeof replacements[k2] === "object" && typeof replacements[k2].html === "string") {
29620           replacements[k2] = replacements[k2].html;
29621         }
29622       }
29623       const info = localizer.tInfo(stringId, replacements, locale2);
29624       if (info.text) {
29625         return '<span class="localized-text" lang="'.concat(info.locale || "und", '">').concat(info.text, "</span>");
29626       } else {
29627         return "";
29628       }
29629     };
29630     localizer.t.append = function(stringId, replacements, locale2) {
29631       const ret = function(selection2) {
29632         const info = localizer.tInfo(stringId, replacements, locale2);
29633         return selection2.append("span").attr("class", "localized-text").attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
29634       };
29635       ret.stringId = stringId;
29636       return ret;
29637     };
29638     localizer.languageName = (code, options2) => {
29639       if (_languageNames && _languageNames[code]) {
29640         return _languageNames[code];
29641       }
29642       if (options2 && options2.localOnly)
29643         return null;
29644       const langInfo = _dataLanguages[code];
29645       if (langInfo) {
29646         if (langInfo.nativeName) {
29647           return localizer.t("translate.language_and_code", { language: langInfo.nativeName, code });
29648         } else if (langInfo.base && langInfo.script) {
29649           const base = langInfo.base;
29650           if (_languageNames && _languageNames[base]) {
29651             const scriptCode = langInfo.script;
29652             const script = _scriptNames && _scriptNames[scriptCode] || scriptCode;
29653             return localizer.t("translate.language_and_code", { language: _languageNames[base], code: script });
29654           } else if (_dataLanguages[base] && _dataLanguages[base].nativeName) {
29655             return localizer.t("translate.language_and_code", { language: _dataLanguages[base].nativeName, code });
29656           }
29657         }
29658       }
29659       return code;
29660     };
29661     localizer.floatFormatter = (locale2) => {
29662       if (!("Intl" in window && "NumberFormat" in Intl && "formatToParts" in Intl.NumberFormat.prototype)) {
29663         return (number3, fractionDigits) => {
29664           return fractionDigits === void 0 ? number3.toString() : number3.toFixed(fractionDigits);
29665         };
29666       } else {
29667         return (number3, fractionDigits) => number3.toLocaleString(locale2, {
29668           minimumFractionDigits: fractionDigits,
29669           maximumFractionDigits: fractionDigits === void 0 ? 20 : fractionDigits
29670         });
29671       }
29672     };
29673     localizer.floatParser = (locale2) => {
29674       const polyfill = (string) => +string.trim();
29675       if (!("Intl" in window && "NumberFormat" in Intl))
29676         return polyfill;
29677       const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29678       if (!("formatToParts" in format2))
29679         return polyfill;
29680       const parts = format2.formatToParts(-12345.6);
29681       const numerals = Array.from({ length: 10 }).map((_2, i3) => format2.format(i3));
29682       const index = new Map(numerals.map((d2, i3) => [d2, i3]));
29683       const literalPart = parts.find((d2) => d2.type === "literal");
29684       const literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29685       const groupPart = parts.find((d2) => d2.type === "group");
29686       const group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29687       const decimalPart = parts.find((d2) => d2.type === "decimal");
29688       const decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29689       const numeral = new RegExp("[".concat(numerals.join(""), "]"), "g");
29690       const getIndex = (d2) => index.get(d2);
29691       return (string) => {
29692         string = string.trim();
29693         if (literal)
29694           string = string.replace(literal, "");
29695         if (group)
29696           string = string.replace(group, "");
29697         if (decimal)
29698           string = string.replace(decimal, ".");
29699         string = string.replace(numeral, getIndex);
29700         return string ? +string : NaN;
29701       };
29702     };
29703     localizer.decimalPlaceCounter = (locale2) => {
29704       var literal, group, decimal;
29705       if ("Intl" in window && "NumberFormat" in Intl) {
29706         const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29707         if ("formatToParts" in format2) {
29708           const parts = format2.formatToParts(-12345.6);
29709           const literalPart = parts.find((d2) => d2.type === "literal");
29710           literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29711           const groupPart = parts.find((d2) => d2.type === "group");
29712           group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29713           const decimalPart = parts.find((d2) => d2.type === "decimal");
29714           decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29715         }
29716       }
29717       return (string) => {
29718         string = string.trim();
29719         if (literal)
29720           string = string.replace(literal, "");
29721         if (group)
29722           string = string.replace(group, "");
29723         const parts = string.split(decimal || ".");
29724         return parts && parts[1] && parts[1].length || 0;
29725       };
29726     };
29727     return localizer;
29728   }
29729
29730   // modules/presets/collection.js
29731   function presetCollection(collection) {
29732     const MAXRESULTS = 50;
29733     let _this = {};
29734     let _memo = {};
29735     _this.collection = collection;
29736     _this.item = (id2) => {
29737       if (_memo[id2])
29738         return _memo[id2];
29739       const found = _this.collection.find((d2) => d2.id === id2);
29740       if (found)
29741         _memo[id2] = found;
29742       return found;
29743     };
29744     _this.index = (id2) => _this.collection.findIndex((d2) => d2.id === id2);
29745     _this.matchGeometry = (geometry) => {
29746       return presetCollection(
29747         _this.collection.filter((d2) => d2.matchGeometry(geometry))
29748       );
29749     };
29750     _this.matchAllGeometry = (geometries) => {
29751       return presetCollection(
29752         _this.collection.filter((d2) => d2 && d2.matchAllGeometry(geometries))
29753       );
29754     };
29755     _this.matchAnyGeometry = (geometries) => {
29756       return presetCollection(
29757         _this.collection.filter((d2) => geometries.some((geom) => d2.matchGeometry(geom)))
29758       );
29759     };
29760     _this.fallback = (geometry) => {
29761       let id2 = geometry;
29762       if (id2 === "vertex")
29763         id2 = "point";
29764       return _this.item(id2);
29765     };
29766     _this.search = (value, geometry, loc) => {
29767       if (!value)
29768         return _this;
29769       value = value.toLowerCase().trim();
29770       function leading(a2) {
29771         const index = a2.indexOf(value);
29772         return index === 0 || a2[index - 1] === " ";
29773       }
29774       function leadingStrict(a2) {
29775         const index = a2.indexOf(value);
29776         return index === 0;
29777       }
29778       function sortPresets(nameProp, aliasesProp) {
29779         return function sortNames(a2, b2) {
29780           let aCompare = a2[nameProp]();
29781           let bCompare = b2[nameProp]();
29782           if (aliasesProp) {
29783             const findMatchingAlias = (strings) => {
29784               if (strings.some((s2) => s2 === value)) {
29785                 return strings.find((s2) => s2 === value);
29786               } else {
29787                 return strings.filter((s2) => s2.includes(value)).sort((a3, b3) => a3.length - b3.length)[0];
29788               }
29789             };
29790             aCompare = findMatchingAlias([aCompare].concat(a2[aliasesProp]()));
29791             bCompare = findMatchingAlias([bCompare].concat(b2[aliasesProp]()));
29792           }
29793           if (value === aCompare)
29794             return -1;
29795           if (value === bCompare)
29796             return 1;
29797           let i3 = b2.originalScore - a2.originalScore;
29798           if (i3 !== 0)
29799             return i3;
29800           i3 = aCompare.indexOf(value) - bCompare.indexOf(value);
29801           if (i3 !== 0)
29802             return i3;
29803           return aCompare.length - bCompare.length;
29804         };
29805       }
29806       let pool = _this.collection;
29807       if (Array.isArray(loc)) {
29808         const validHere = _sharedLocationManager.locationSetsAt(loc);
29809         pool = pool.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
29810       }
29811       const searchable = pool.filter((a2) => a2.searchable !== false && a2.suggestion !== true);
29812       const suggestions = pool.filter((a2) => a2.suggestion === true);
29813       const leadingNames = searchable.filter((a2) => leading(a2.searchName()) || a2.searchAliases().some(leading)).sort(sortPresets("searchName", "searchAliases"));
29814       const leadingSuggestions = suggestions.filter((a2) => leadingStrict(a2.searchName())).sort(sortPresets("searchName"));
29815       const leadingNamesStripped = searchable.filter((a2) => leading(a2.searchNameStripped()) || a2.searchAliasesStripped().some(leading)).sort(sortPresets("searchNameStripped", "searchAliasesStripped"));
29816       const leadingSuggestionsStripped = suggestions.filter((a2) => leadingStrict(a2.searchNameStripped())).sort(sortPresets("searchNameStripped"));
29817       const leadingTerms = searchable.filter((a2) => (a2.terms() || []).some(leading));
29818       const leadingSuggestionTerms = suggestions.filter((a2) => (a2.terms() || []).some(leading));
29819       const leadingTagValues = searchable.filter((a2) => Object.values(a2.tags || {}).filter((val) => val !== "*").some(leading));
29820       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);
29821       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);
29822       const similarTerms = searchable.filter((a2) => {
29823         return (a2.terms() || []).some((b2) => {
29824           return utilEditDistance(value, b2) + Math.min(value.length - b2.length, 0) < 3;
29825         });
29826       });
29827       let leadingTagKeyValues = [];
29828       if (value.includes("=")) {
29829         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]))));
29830       }
29831       let results = leadingNames.concat(
29832         leadingSuggestions,
29833         leadingNamesStripped,
29834         leadingSuggestionsStripped,
29835         leadingTerms,
29836         leadingSuggestionTerms,
29837         leadingTagValues,
29838         similarName,
29839         similarSuggestions,
29840         similarTerms,
29841         leadingTagKeyValues
29842       ).slice(0, MAXRESULTS - 1);
29843       if (geometry) {
29844         if (typeof geometry === "string") {
29845           results.push(_this.fallback(geometry));
29846         } else {
29847           geometry.forEach((geom) => results.push(_this.fallback(geom)));
29848         }
29849       }
29850       return presetCollection(utilArrayUniq(results));
29851     };
29852     return _this;
29853   }
29854
29855   // modules/presets/category.js
29856   function presetCategory(categoryID, category, allPresets) {
29857     let _this = Object.assign({}, category);
29858     let _searchName;
29859     let _searchNameStripped;
29860     _this.id = categoryID;
29861     _this.members = presetCollection(
29862       (category.members || []).map((presetID) => allPresets[presetID]).filter(Boolean)
29863     );
29864     _this.geometry = _this.members.collection.reduce((acc, preset) => {
29865       for (let i3 in preset.geometry) {
29866         const geometry = preset.geometry[i3];
29867         if (acc.indexOf(geometry) === -1) {
29868           acc.push(geometry);
29869         }
29870       }
29871       return acc;
29872     }, []);
29873     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29874     _this.matchAllGeometry = (geometries) => _this.members.collection.some((preset) => preset.matchAllGeometry(geometries));
29875     _this.matchScore = () => -1;
29876     _this.name = () => _t("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29877     _this.nameLabel = () => _t.append("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29878     _this.terms = () => [];
29879     _this.searchName = () => {
29880       if (!_searchName) {
29881         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
29882       }
29883       return _searchName;
29884     };
29885     _this.searchNameStripped = () => {
29886       if (!_searchNameStripped) {
29887         _searchNameStripped = _this.searchName();
29888         if (_searchNameStripped.normalize)
29889           _searchNameStripped = _searchNameStripped.normalize("NFD");
29890         _searchNameStripped = _searchNameStripped.replace(/[\u0300-\u036f]/g, "");
29891       }
29892       return _searchNameStripped;
29893     };
29894     _this.searchAliases = () => [];
29895     _this.searchAliasesStripped = () => [];
29896     return _this;
29897   }
29898
29899   // modules/presets/field.js
29900   function presetField(fieldID, field, allFields) {
29901     allFields = allFields || {};
29902     let _this = Object.assign({}, field);
29903     _this.id = fieldID;
29904     _this.safeid = utilSafeClassName(fieldID);
29905     _this.matchGeometry = (geom) => !_this.geometry || _this.geometry.indexOf(geom) !== -1;
29906     _this.matchAllGeometry = (geometries) => {
29907       return !_this.geometry || geometries.every((geom) => _this.geometry.indexOf(geom) !== -1);
29908     };
29909     _this.t = (scope, options2) => _t("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29910     _this.t.html = (scope, options2) => _t.html("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29911     _this.t.append = (scope, options2) => _t.append("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29912     _this.hasTextForStringId = (scope) => _mainLocalizer.hasTextForStringId("_tagging.presets.fields.".concat(fieldID, ".").concat(scope));
29913     _this.resolveReference = (which) => {
29914       const referenceRegex = /^\{(.*)\}$/;
29915       const match = (field[which] || "").match(referenceRegex);
29916       if (match) {
29917         const field2 = allFields[match[1]];
29918         if (field2) {
29919           return field2;
29920         }
29921         console.error("Unable to resolve referenced field: ".concat(match[1]));
29922       }
29923       return _this;
29924     };
29925     _this.title = () => _this.overrideLabel || _this.resolveReference("label").t("label", { "default": fieldID });
29926     _this.label = () => _this.overrideLabel ? (selection2) => selection2.text(_this.overrideLabel) : _this.resolveReference("label").t.append("label", { "default": fieldID });
29927     _this.placeholder = () => _this.resolveReference("placeholder").t("placeholder", { "default": "" });
29928     _this.originalTerms = (_this.terms || []).join();
29929     _this.terms = () => _this.resolveReference("label").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
29930     _this.increment = _this.type === "number" ? _this.increment || 1 : void 0;
29931     return _this;
29932   }
29933
29934   // modules/presets/preset.js
29935   var import_lodash = __toESM(require_lodash());
29936   function presetPreset(presetID, preset, addable, allFields, allPresets) {
29937     allFields = allFields || {};
29938     allPresets = allPresets || {};
29939     let _this = Object.assign({}, preset);
29940     let _addable = addable || false;
29941     let _searchName;
29942     let _searchNameStripped;
29943     let _searchAliases;
29944     let _searchAliasesStripped;
29945     const referenceRegex = /^\{(.*)\}$/;
29946     _this.id = presetID;
29947     _this.safeid = utilSafeClassName(presetID);
29948     _this.originalTerms = (_this.terms || []).join();
29949     _this.originalName = _this.name || "";
29950     _this.originalAliases = (_this.aliases || []).join("\n");
29951     _this.originalScore = _this.matchScore || 1;
29952     _this.originalReference = _this.reference || {};
29953     _this.originalFields = _this.fields || [];
29954     _this.originalMoreFields = _this.moreFields || [];
29955     _this.fields = (loc) => resolveFields("fields", loc);
29956     _this.moreFields = (loc) => resolveFields("moreFields", loc);
29957     _this.tags = _this.tags || {};
29958     _this.addTags = _this.addTags || _this.tags;
29959     _this.removeTags = _this.removeTags || _this.addTags;
29960     _this.geometry = _this.geometry || [];
29961     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29962     _this.matchAllGeometry = (geoms) => geoms.every(_this.matchGeometry);
29963     _this.matchScore = (entityTags) => {
29964       const tags = _this.tags;
29965       let seen = {};
29966       let score = 0;
29967       for (let k2 in tags) {
29968         seen[k2] = true;
29969         if (entityTags[k2] === tags[k2]) {
29970           score += _this.originalScore;
29971         } else if (tags[k2] === "*" && k2 in entityTags) {
29972           score += _this.originalScore / 2;
29973         } else {
29974           return -1;
29975         }
29976       }
29977       const addTags = _this.addTags;
29978       for (let k2 in addTags) {
29979         if (!seen[k2] && entityTags[k2] === addTags[k2]) {
29980           score += _this.originalScore;
29981         }
29982       }
29983       if (_this.searchable === false) {
29984         score *= 0.999;
29985       }
29986       return score;
29987     };
29988     _this.t = (scope, options2) => {
29989       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29990       return _t(textID, options2);
29991     };
29992     _this.t.append = (scope, options2) => {
29993       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29994       return _t.append(textID, options2);
29995     };
29996     function resolveReference(which) {
29997       const match = (_this[which] || "").match(referenceRegex);
29998       if (match) {
29999         const preset2 = allPresets[match[1]];
30000         if (preset2) {
30001           return preset2;
30002         }
30003         console.error("Unable to resolve referenced preset: ".concat(match[1]));
30004       }
30005       return _this;
30006     }
30007     _this.name = () => {
30008       return resolveReference("originalName").t("name", { "default": _this.originalName || presetID });
30009     };
30010     _this.nameLabel = () => {
30011       return resolveReference("originalName").t.append("name", { "default": _this.originalName || presetID });
30012     };
30013     _this.subtitle = () => {
30014       if (_this.suggestion) {
30015         let path = presetID.split("/");
30016         path.pop();
30017         return _t("_tagging.presets.presets." + path.join("/") + ".name");
30018       }
30019       return null;
30020     };
30021     _this.subtitleLabel = () => {
30022       if (_this.suggestion) {
30023         let path = presetID.split("/");
30024         path.pop();
30025         return _t.append("_tagging.presets.presets." + path.join("/") + ".name");
30026       }
30027       return null;
30028     };
30029     _this.aliases = () => {
30030       return resolveReference("originalName").t("aliases", { "default": _this.originalAliases }).trim().split(/\s*[\r\n]+\s*/);
30031     };
30032     _this.terms = () => {
30033       return resolveReference("originalName").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
30034     };
30035     _this.searchName = () => {
30036       if (!_searchName) {
30037         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
30038       }
30039       return _searchName;
30040     };
30041     _this.searchNameStripped = () => {
30042       if (!_searchNameStripped) {
30043         _searchNameStripped = stripDiacritics(_this.searchName());
30044       }
30045       return _searchNameStripped;
30046     };
30047     _this.searchAliases = () => {
30048       if (!_searchAliases) {
30049         _searchAliases = _this.aliases().map((alias) => alias.toLowerCase());
30050       }
30051       return _searchAliases;
30052     };
30053     _this.searchAliasesStripped = () => {
30054       if (!_searchAliasesStripped) {
30055         _searchAliasesStripped = _this.searchAliases();
30056         _searchAliasesStripped = _searchAliasesStripped.map(stripDiacritics);
30057       }
30058       return _searchAliasesStripped;
30059     };
30060     _this.isFallback = () => {
30061       const tagCount = Object.keys(_this.tags).length;
30062       return tagCount === 0 || tagCount === 1 && _this.tags.hasOwnProperty("area");
30063     };
30064     _this.addable = function(val) {
30065       if (!arguments.length)
30066         return _addable;
30067       _addable = val;
30068       return _this;
30069     };
30070     _this.reference = () => {
30071       const qid = _this.tags.wikidata || _this.tags["flag:wikidata"] || _this.tags["brand:wikidata"] || _this.tags["network:wikidata"] || _this.tags["operator:wikidata"];
30072       if (qid) {
30073         return { qid };
30074       }
30075       let key = _this.originalReference.key || Object.keys(utilObjectOmit(_this.tags, "name"))[0];
30076       let value = _this.originalReference.value || _this.tags[key];
30077       if (value === "*") {
30078         return { key };
30079       } else {
30080         return { key, value };
30081       }
30082     };
30083     _this.unsetTags = (tags, geometry, ignoringKeys, skipFieldDefaults, loc) => {
30084       let removeTags = ignoringKeys ? utilObjectOmit(_this.removeTags, ignoringKeys) : _this.removeTags;
30085       tags = utilObjectOmit(tags, Object.keys(removeTags));
30086       if (geometry && !skipFieldDefaults) {
30087         _this.fields(loc).forEach((field) => {
30088           if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key] && (!ignoringKeys || ignoringKeys.indexOf(field.key) === -1)) {
30089             delete tags[field.key];
30090           }
30091         });
30092       }
30093       delete tags.area;
30094       return tags;
30095     };
30096     _this.setTags = (tags, geometry, skipFieldDefaults, loc) => {
30097       const addTags = _this.addTags;
30098       tags = Object.assign({}, tags);
30099       for (let k2 in addTags) {
30100         if (addTags[k2] === "*") {
30101           if (_this.tags[k2] || !tags[k2]) {
30102             tags[k2] = "yes";
30103           }
30104         } else {
30105           tags[k2] = addTags[k2];
30106         }
30107       }
30108       if (!addTags.hasOwnProperty("area")) {
30109         delete tags.area;
30110         if (geometry === "area") {
30111           let needsAreaTag = true;
30112           for (let k2 in addTags) {
30113             if (_this.geometry.indexOf("line") === -1 && k2 in osmAreaKeys || k2 in osmAreaKeysExceptions && addTags[k2] in osmAreaKeysExceptions[k2]) {
30114               needsAreaTag = false;
30115               break;
30116             }
30117           }
30118           if (needsAreaTag) {
30119             tags.area = "yes";
30120           }
30121         }
30122       }
30123       if (geometry && !skipFieldDefaults) {
30124         _this.fields(loc).forEach((field) => {
30125           if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field.default) {
30126             tags[field.key] = field.default;
30127           }
30128         });
30129       }
30130       return tags;
30131     };
30132     function resolveFields(which, loc) {
30133       const fieldIDs = which === "fields" ? _this.originalFields : _this.originalMoreFields;
30134       let resolved = [];
30135       fieldIDs.forEach((fieldID) => {
30136         const match = fieldID.match(referenceRegex);
30137         if (match !== null) {
30138           resolved = resolved.concat(inheritFields(allPresets[match[1]], which));
30139         } else if (allFields[fieldID]) {
30140           resolved.push(allFields[fieldID]);
30141         } else {
30142           console.log('Cannot resolve "'.concat(fieldID, '" found in ').concat(_this.id, ".").concat(which));
30143         }
30144       });
30145       if (!resolved.length) {
30146         const endIndex = _this.id.lastIndexOf("/");
30147         const parentID = endIndex && _this.id.substring(0, endIndex);
30148         if (parentID) {
30149           let parent = allPresets[parentID];
30150           if (loc) {
30151             const validHere = _sharedLocationManager.locationSetsAt(loc);
30152             if ((parent == null ? void 0 : parent.locationSetID) && !validHere[parent.locationSetID]) {
30153               const candidateIDs = Object.keys(allPresets).filter((k2) => k2.startsWith(parentID));
30154               parent = allPresets[candidateIDs.find((candidateID) => {
30155                 const candidate = allPresets[candidateID];
30156                 return validHere[candidate.locationSetID] && (0, import_lodash.isEqual)(candidate.tags, parent.tags);
30157               })];
30158             }
30159           }
30160           resolved = inheritFields(parent, which);
30161         }
30162       }
30163       return utilArrayUniq(resolved);
30164       function inheritFields(parent, which2) {
30165         if (!parent)
30166           return [];
30167         if (which2 === "fields") {
30168           return parent.fields().filter(shouldInherit);
30169         } else if (which2 === "moreFields") {
30170           return parent.moreFields();
30171         } else {
30172           return [];
30173         }
30174       }
30175       function shouldInherit(f2) {
30176         if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox
30177         f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check")
30178           return false;
30179         return true;
30180       }
30181     }
30182     function stripDiacritics(s2) {
30183       if (s2.normalize)
30184         s2 = s2.normalize("NFD");
30185       s2 = s2.replace(/[\u0300-\u036f]/g, "");
30186       return s2;
30187     }
30188     return _this;
30189   }
30190
30191   // modules/presets/index.js
30192   var _mainPresetIndex = presetIndex();
30193   function presetIndex() {
30194     const dispatch14 = dispatch_default("favoritePreset", "recentsChange");
30195     const MAXRECENTS = 30;
30196     const POINT = presetPreset("point", { name: "Point", tags: {}, geometry: ["point", "vertex"], matchScore: 0.1 });
30197     const LINE = presetPreset("line", { name: "Line", tags: {}, geometry: ["line"], matchScore: 0.1 });
30198     const AREA = presetPreset("area", { name: "Area", tags: { area: "yes" }, geometry: ["area"], matchScore: 0.1 });
30199     const RELATION = presetPreset("relation", { name: "Relation", tags: {}, geometry: ["relation"], matchScore: 0.1 });
30200     let _this = presetCollection([POINT, LINE, AREA, RELATION]);
30201     let _presets = { point: POINT, line: LINE, area: AREA, relation: RELATION };
30202     let _defaults2 = {
30203       point: presetCollection([POINT]),
30204       vertex: presetCollection([POINT]),
30205       line: presetCollection([LINE]),
30206       area: presetCollection([AREA]),
30207       relation: presetCollection([RELATION])
30208     };
30209     let _fields = {};
30210     let _categories = {};
30211     let _universal = [];
30212     let _addablePresetIDs = null;
30213     let _recents;
30214     let _favorites;
30215     let _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30216     let _loadPromise;
30217     _this.ensureLoaded = () => {
30218       if (_loadPromise)
30219         return _loadPromise;
30220       return _loadPromise = Promise.all([
30221         _mainFileFetcher.get("preset_categories"),
30222         _mainFileFetcher.get("preset_defaults"),
30223         _mainFileFetcher.get("preset_presets"),
30224         _mainFileFetcher.get("preset_fields")
30225       ]).then((vals) => {
30226         _this.merge({
30227           categories: vals[0],
30228           defaults: vals[1],
30229           presets: vals[2],
30230           fields: vals[3]
30231         });
30232         osmSetAreaKeys(_this.areaKeys());
30233         osmSetLineTags(_this.lineTags());
30234         osmSetPointTags(_this.pointTags());
30235         osmSetVertexTags(_this.vertexTags());
30236       });
30237     };
30238     _this.merge = (d2) => {
30239       let newLocationSets = [];
30240       if (d2.fields) {
30241         Object.keys(d2.fields).forEach((fieldID) => {
30242           let f2 = d2.fields[fieldID];
30243           if (f2) {
30244             f2 = presetField(fieldID, f2, _fields);
30245             if (f2.locationSet)
30246               newLocationSets.push(f2);
30247             _fields[fieldID] = f2;
30248           } else {
30249             delete _fields[fieldID];
30250           }
30251         });
30252       }
30253       if (d2.presets) {
30254         Object.keys(d2.presets).forEach((presetID) => {
30255           let p2 = d2.presets[presetID];
30256           if (p2) {
30257             const isAddable = !_addablePresetIDs || _addablePresetIDs.has(presetID);
30258             p2 = presetPreset(presetID, p2, isAddable, _fields, _presets);
30259             if (p2.locationSet)
30260               newLocationSets.push(p2);
30261             _presets[presetID] = p2;
30262           } else {
30263             const existing = _presets[presetID];
30264             if (existing && !existing.isFallback()) {
30265               delete _presets[presetID];
30266             }
30267           }
30268         });
30269       }
30270       if (d2.categories) {
30271         Object.keys(d2.categories).forEach((categoryID) => {
30272           let c2 = d2.categories[categoryID];
30273           if (c2) {
30274             c2 = presetCategory(categoryID, c2, _presets);
30275             if (c2.locationSet)
30276               newLocationSets.push(c2);
30277             _categories[categoryID] = c2;
30278           } else {
30279             delete _categories[categoryID];
30280           }
30281         });
30282       }
30283       _this.collection = Object.values(_presets).concat(Object.values(_categories));
30284       if (d2.defaults) {
30285         Object.keys(d2.defaults).forEach((geometry) => {
30286           const def2 = d2.defaults[geometry];
30287           if (Array.isArray(def2)) {
30288             _defaults2[geometry] = presetCollection(
30289               def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean)
30290             );
30291           } else {
30292             delete _defaults2[geometry];
30293           }
30294         });
30295       }
30296       _universal = Object.values(_fields).filter((field) => field.universal);
30297       _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30298       _this.collection.forEach((preset) => {
30299         (preset.geometry || []).forEach((geometry) => {
30300           let g3 = _geometryIndex[geometry];
30301           for (let key in preset.tags) {
30302             g3[key] = g3[key] || {};
30303             let value = preset.tags[key];
30304             (g3[key][value] = g3[key][value] || []).push(preset);
30305           }
30306         });
30307       });
30308       if (d2.featureCollection && Array.isArray(d2.featureCollection.features)) {
30309         _sharedLocationManager.mergeCustomGeoJSON(d2.featureCollection);
30310       }
30311       if (newLocationSets.length) {
30312         _sharedLocationManager.mergeLocationSets(newLocationSets);
30313       }
30314       return _this;
30315     };
30316     _this.match = (entity, resolver) => {
30317       return resolver.transient(entity, "presetMatch", () => {
30318         let geometry = entity.geometry(resolver);
30319         if (geometry === "vertex" && entity.isOnAddressLine(resolver)) {
30320           geometry = "point";
30321         }
30322         const entityExtent = entity.extent(resolver);
30323         return _this.matchTags(entity.tags, geometry, entityExtent.center());
30324       });
30325     };
30326     _this.matchTags = (tags, geometry, loc) => {
30327       const keyIndex = _geometryIndex[geometry];
30328       let bestScore = -1;
30329       let bestMatch;
30330       let matchCandidates = [];
30331       for (let k2 in tags) {
30332         let indexMatches = [];
30333         let valueIndex = keyIndex[k2];
30334         if (!valueIndex)
30335           continue;
30336         let keyValueMatches = valueIndex[tags[k2]];
30337         if (keyValueMatches)
30338           indexMatches.push(...keyValueMatches);
30339         let keyStarMatches = valueIndex["*"];
30340         if (keyStarMatches)
30341           indexMatches.push(...keyStarMatches);
30342         if (indexMatches.length === 0)
30343           continue;
30344         for (let i3 = 0; i3 < indexMatches.length; i3++) {
30345           const candidate = indexMatches[i3];
30346           const score = candidate.matchScore(tags);
30347           if (score === -1) {
30348             continue;
30349           }
30350           matchCandidates.push({ score, candidate });
30351           if (score > bestScore) {
30352             bestScore = score;
30353             bestMatch = candidate;
30354           }
30355         }
30356       }
30357       if (bestMatch && bestMatch.locationSetID && bestMatch.locationSetID !== "+[Q2]" && Array.isArray(loc)) {
30358         const validHere = _sharedLocationManager.locationSetsAt(loc);
30359         if (!validHere[bestMatch.locationSetID]) {
30360           matchCandidates.sort((a2, b2) => a2.score < b2.score ? 1 : -1);
30361           for (let i3 = 0; i3 < matchCandidates.length; i3++) {
30362             const candidateScore = matchCandidates[i3];
30363             if (!candidateScore.candidate.locationSetID || validHere[candidateScore.candidate.locationSetID]) {
30364               bestMatch = candidateScore.candidate;
30365               bestScore = candidateScore.score;
30366               break;
30367             }
30368           }
30369         }
30370       }
30371       if (!bestMatch || bestMatch.isFallback()) {
30372         for (let k2 in tags) {
30373           if (/^addr:/.test(k2) && keyIndex["addr:*"] && keyIndex["addr:*"]["*"]) {
30374             bestMatch = keyIndex["addr:*"]["*"][0];
30375             break;
30376           }
30377         }
30378       }
30379       return bestMatch || _this.fallback(geometry);
30380     };
30381     _this.allowsVertex = (entity, resolver) => {
30382       if (entity.type !== "node")
30383         return false;
30384       if (Object.keys(entity.tags).length === 0)
30385         return true;
30386       return resolver.transient(entity, "vertexMatch", () => {
30387         if (entity.isOnAddressLine(resolver))
30388           return true;
30389         const geometries = osmNodeGeometriesForTags(entity.tags);
30390         if (geometries.vertex)
30391           return true;
30392         if (geometries.point)
30393           return false;
30394         return true;
30395       });
30396     };
30397     _this.areaKeys = () => {
30398       const ignore = {
30399         barrier: true,
30400         highway: true,
30401         footway: true,
30402         railway: true,
30403         junction: true,
30404         type: true
30405       };
30406       let areaKeys = {};
30407       const presets = _this.collection.filter((p2) => !p2.suggestion && !p2.replacement);
30408       presets.forEach((p2) => {
30409         const keys2 = p2.tags && Object.keys(p2.tags);
30410         const key = keys2 && keys2.length && keys2[0];
30411         if (!key)
30412           return;
30413         if (ignore[key])
30414           return;
30415         if (p2.geometry.indexOf("area") !== -1) {
30416           areaKeys[key] = areaKeys[key] || {};
30417         }
30418       });
30419       presets.forEach((p2) => {
30420         let key;
30421         for (key in p2.addTags) {
30422           const value = p2.addTags[key];
30423           if (key in areaKeys && // probably an area...
30424           p2.geometry.indexOf("line") !== -1 && // but sometimes a line
30425           value !== "*") {
30426             areaKeys[key][value] = true;
30427           }
30428         }
30429       });
30430       return areaKeys;
30431     };
30432     _this.lineTags = () => {
30433       return _this.collection.filter((lineTags, d2) => {
30434         if (d2.suggestion || d2.replacement || d2.searchable === false)
30435           return lineTags;
30436         const keys2 = d2.tags && Object.keys(d2.tags);
30437         const key = keys2 && keys2.length && keys2[0];
30438         if (!key)
30439           return lineTags;
30440         if (d2.geometry.indexOf("line") !== -1) {
30441           lineTags[key] = lineTags[key] || [];
30442           lineTags[key].push(d2.tags);
30443         }
30444         return lineTags;
30445       }, {});
30446     };
30447     _this.pointTags = () => {
30448       return _this.collection.reduce((pointTags, d2) => {
30449         if (d2.suggestion || d2.replacement || d2.searchable === false)
30450           return pointTags;
30451         const keys2 = d2.tags && Object.keys(d2.tags);
30452         const key = keys2 && keys2.length && keys2[0];
30453         if (!key)
30454           return pointTags;
30455         if (d2.geometry.indexOf("point") !== -1) {
30456           pointTags[key] = pointTags[key] || {};
30457           pointTags[key][d2.tags[key]] = true;
30458         }
30459         return pointTags;
30460       }, {});
30461     };
30462     _this.vertexTags = () => {
30463       return _this.collection.reduce((vertexTags, d2) => {
30464         if (d2.suggestion || d2.replacement || d2.searchable === false)
30465           return vertexTags;
30466         const keys2 = d2.tags && Object.keys(d2.tags);
30467         const key = keys2 && keys2.length && keys2[0];
30468         if (!key)
30469           return vertexTags;
30470         if (d2.geometry.indexOf("vertex") !== -1) {
30471           vertexTags[key] = vertexTags[key] || {};
30472           vertexTags[key][d2.tags[key]] = true;
30473         }
30474         return vertexTags;
30475       }, {});
30476     };
30477     _this.field = (id2) => _fields[id2];
30478     _this.universal = () => _universal;
30479     _this.defaults = (geometry, n3, startWithRecents, loc, extraPresets) => {
30480       let recents = [];
30481       if (startWithRecents) {
30482         recents = _this.recent().matchGeometry(geometry).collection.slice(0, 4);
30483       }
30484       let defaults;
30485       if (_addablePresetIDs) {
30486         defaults = Array.from(_addablePresetIDs).map(function(id2) {
30487           var preset = _this.item(id2);
30488           if (preset && preset.matchGeometry(geometry))
30489             return preset;
30490           return null;
30491         }).filter(Boolean);
30492       } else {
30493         defaults = _defaults2[geometry].collection.concat(_this.fallback(geometry));
30494       }
30495       let result = presetCollection(
30496         utilArrayUniq(recents.concat(defaults).concat(extraPresets || [])).slice(0, n3 - 1)
30497       );
30498       if (Array.isArray(loc)) {
30499         const validHere = _sharedLocationManager.locationSetsAt(loc);
30500         result.collection = result.collection.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
30501       }
30502       return result;
30503     };
30504     _this.addablePresetIDs = function(val) {
30505       if (!arguments.length)
30506         return _addablePresetIDs;
30507       if (Array.isArray(val))
30508         val = new Set(val);
30509       _addablePresetIDs = val;
30510       if (_addablePresetIDs) {
30511         _this.collection.forEach((p2) => {
30512           if (p2.addable)
30513             p2.addable(_addablePresetIDs.has(p2.id));
30514         });
30515       } else {
30516         _this.collection.forEach((p2) => {
30517           if (p2.addable)
30518             p2.addable(true);
30519         });
30520       }
30521       return _this;
30522     };
30523     _this.recent = () => {
30524       return presetCollection(
30525         utilArrayUniq(_this.getRecents().map((d2) => d2.preset).filter((d2) => d2.searchable !== false))
30526       );
30527     };
30528     function RibbonItem(preset, source) {
30529       let item = {};
30530       item.preset = preset;
30531       item.source = source;
30532       item.isFavorite = () => item.source === "favorite";
30533       item.isRecent = () => item.source === "recent";
30534       item.matches = (preset2) => item.preset.id === preset2.id;
30535       item.minified = () => ({ pID: item.preset.id });
30536       return item;
30537     }
30538     function ribbonItemForMinified(d2, source) {
30539       if (d2 && d2.pID) {
30540         const preset = _this.item(d2.pID);
30541         if (!preset)
30542           return null;
30543         return RibbonItem(preset, source);
30544       }
30545       return null;
30546     }
30547     _this.getGenericRibbonItems = () => {
30548       return ["point", "line", "area"].map((id2) => RibbonItem(_this.item(id2), "generic"));
30549     };
30550     _this.getAddable = () => {
30551       if (!_addablePresetIDs)
30552         return [];
30553       return _addablePresetIDs.map((id2) => {
30554         const preset = _this.item(id2);
30555         if (preset)
30556           return RibbonItem(preset, "addable");
30557         return null;
30558       }).filter(Boolean);
30559     };
30560     function setRecents(items) {
30561       _recents = items;
30562       const minifiedItems = items.map((d2) => d2.minified());
30563       corePreferences("preset_recents", JSON.stringify(minifiedItems));
30564       dispatch14.call("recentsChange");
30565     }
30566     _this.getRecents = () => {
30567       if (!_recents) {
30568         _recents = (JSON.parse(corePreferences("preset_recents")) || []).reduce((acc, d2) => {
30569           let item = ribbonItemForMinified(d2, "recent");
30570           if (item && item.preset.addable())
30571             acc.push(item);
30572           return acc;
30573         }, []);
30574       }
30575       return _recents;
30576     };
30577     _this.addRecent = (preset, besidePreset, after) => {
30578       const recents = _this.getRecents();
30579       const beforeItem = _this.recentMatching(besidePreset);
30580       let toIndex = recents.indexOf(beforeItem);
30581       if (after)
30582         toIndex += 1;
30583       const newItem = RibbonItem(preset, "recent");
30584       recents.splice(toIndex, 0, newItem);
30585       setRecents(recents);
30586     };
30587     _this.removeRecent = (preset) => {
30588       const item = _this.recentMatching(preset);
30589       if (item) {
30590         let items = _this.getRecents();
30591         items.splice(items.indexOf(item), 1);
30592         setRecents(items);
30593       }
30594     };
30595     _this.recentMatching = (preset) => {
30596       const items = _this.getRecents();
30597       for (let i3 in items) {
30598         if (items[i3].matches(preset)) {
30599           return items[i3];
30600         }
30601       }
30602       return null;
30603     };
30604     _this.moveItem = (items, fromIndex, toIndex) => {
30605       if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length)
30606         return null;
30607       items.splice(toIndex, 0, items.splice(fromIndex, 1)[0]);
30608       return items;
30609     };
30610     _this.moveRecent = (item, beforeItem) => {
30611       const recents = _this.getRecents();
30612       const fromIndex = recents.indexOf(item);
30613       const toIndex = recents.indexOf(beforeItem);
30614       const items = _this.moveItem(recents, fromIndex, toIndex);
30615       if (items)
30616         setRecents(items);
30617     };
30618     _this.setMostRecent = (preset) => {
30619       if (preset.searchable === false)
30620         return;
30621       let items = _this.getRecents();
30622       let item = _this.recentMatching(preset);
30623       if (item) {
30624         items.splice(items.indexOf(item), 1);
30625       } else {
30626         item = RibbonItem(preset, "recent");
30627       }
30628       while (items.length >= MAXRECENTS) {
30629         items.pop();
30630       }
30631       items.unshift(item);
30632       setRecents(items);
30633     };
30634     function setFavorites(items) {
30635       _favorites = items;
30636       const minifiedItems = items.map((d2) => d2.minified());
30637       corePreferences("preset_favorites", JSON.stringify(minifiedItems));
30638       dispatch14.call("favoritePreset");
30639     }
30640     _this.addFavorite = (preset, besidePreset, after) => {
30641       const favorites = _this.getFavorites();
30642       const beforeItem = _this.favoriteMatching(besidePreset);
30643       let toIndex = favorites.indexOf(beforeItem);
30644       if (after)
30645         toIndex += 1;
30646       const newItem = RibbonItem(preset, "favorite");
30647       favorites.splice(toIndex, 0, newItem);
30648       setFavorites(favorites);
30649     };
30650     _this.toggleFavorite = (preset) => {
30651       const favs = _this.getFavorites();
30652       const favorite = _this.favoriteMatching(preset);
30653       if (favorite) {
30654         favs.splice(favs.indexOf(favorite), 1);
30655       } else {
30656         if (favs.length === 10) {
30657           favs.pop();
30658         }
30659         favs.push(RibbonItem(preset, "favorite"));
30660       }
30661       setFavorites(favs);
30662     };
30663     _this.removeFavorite = (preset) => {
30664       const item = _this.favoriteMatching(preset);
30665       if (item) {
30666         const items = _this.getFavorites();
30667         items.splice(items.indexOf(item), 1);
30668         setFavorites(items);
30669       }
30670     };
30671     _this.getFavorites = () => {
30672       if (!_favorites) {
30673         let rawFavorites = JSON.parse(corePreferences("preset_favorites"));
30674         if (!rawFavorites) {
30675           rawFavorites = [];
30676           corePreferences("preset_favorites", JSON.stringify(rawFavorites));
30677         }
30678         _favorites = rawFavorites.reduce((output, d2) => {
30679           const item = ribbonItemForMinified(d2, "favorite");
30680           if (item && item.preset.addable())
30681             output.push(item);
30682           return output;
30683         }, []);
30684       }
30685       return _favorites;
30686     };
30687     _this.favoriteMatching = (preset) => {
30688       const favs = _this.getFavorites();
30689       for (let index in favs) {
30690         if (favs[index].matches(preset)) {
30691           return favs[index];
30692         }
30693       }
30694       return null;
30695     };
30696     return utilRebind(_this, dispatch14, "on");
30697   }
30698
30699   // modules/util/util.js
30700   function utilTagText(entity) {
30701     var obj = entity && entity.tags || {};
30702     return Object.keys(obj).map(function(k2) {
30703       return k2 + "=" + obj[k2];
30704     }).join(", ");
30705   }
30706   function utilTotalExtent(array2, graph) {
30707     var extent = geoExtent();
30708     var val, entity;
30709     for (var i3 = 0; i3 < array2.length; i3++) {
30710       val = array2[i3];
30711       entity = typeof val === "string" ? graph.hasEntity(val) : val;
30712       if (entity) {
30713         extent._extend(entity.extent(graph));
30714       }
30715     }
30716     return extent;
30717   }
30718   function utilTagDiff(oldTags, newTags) {
30719     var tagDiff = [];
30720     var keys2 = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
30721     keys2.forEach(function(k2) {
30722       var oldVal = oldTags[k2];
30723       var newVal = newTags[k2];
30724       if ((oldVal || oldVal === "") && (newVal === void 0 || newVal !== oldVal)) {
30725         tagDiff.push({
30726           type: "-",
30727           key: k2,
30728           oldVal,
30729           newVal,
30730           display: "- " + k2 + "=" + oldVal
30731         });
30732       }
30733       if ((newVal || newVal === "") && (oldVal === void 0 || newVal !== oldVal)) {
30734         tagDiff.push({
30735           type: "+",
30736           key: k2,
30737           oldVal,
30738           newVal,
30739           display: "+ " + k2 + "=" + newVal
30740         });
30741       }
30742     });
30743     return tagDiff;
30744   }
30745   function utilEntitySelector(ids) {
30746     return ids.length ? "." + ids.join(",.") : "nothing";
30747   }
30748   function utilEntityOrMemberSelector(ids, graph) {
30749     var seen = new Set(ids);
30750     ids.forEach(collectShallowDescendants);
30751     return utilEntitySelector(Array.from(seen));
30752     function collectShallowDescendants(id2) {
30753       var entity = graph.hasEntity(id2);
30754       if (!entity || entity.type !== "relation")
30755         return;
30756       entity.members.map(function(member) {
30757         return member.id;
30758       }).forEach(function(id3) {
30759         seen.add(id3);
30760       });
30761     }
30762   }
30763   function utilEntityOrDeepMemberSelector(ids, graph) {
30764     return utilEntitySelector(utilEntityAndDeepMemberIDs(ids, graph));
30765   }
30766   function utilEntityAndDeepMemberIDs(ids, graph) {
30767     var seen = /* @__PURE__ */ new Set();
30768     ids.forEach(collectDeepDescendants);
30769     return Array.from(seen);
30770     function collectDeepDescendants(id2) {
30771       if (seen.has(id2))
30772         return;
30773       seen.add(id2);
30774       var entity = graph.hasEntity(id2);
30775       if (!entity || entity.type !== "relation")
30776         return;
30777       entity.members.map(function(member) {
30778         return member.id;
30779       }).forEach(collectDeepDescendants);
30780     }
30781   }
30782   function utilDeepMemberSelector(ids, graph, skipMultipolgonMembers) {
30783     var idsSet = new Set(ids);
30784     var seen = /* @__PURE__ */ new Set();
30785     var returners = /* @__PURE__ */ new Set();
30786     ids.forEach(collectDeepDescendants);
30787     return utilEntitySelector(Array.from(returners));
30788     function collectDeepDescendants(id2) {
30789       if (seen.has(id2))
30790         return;
30791       seen.add(id2);
30792       if (!idsSet.has(id2)) {
30793         returners.add(id2);
30794       }
30795       var entity = graph.hasEntity(id2);
30796       if (!entity || entity.type !== "relation")
30797         return;
30798       if (skipMultipolgonMembers && entity.isMultipolygon())
30799         return;
30800       entity.members.map(function(member) {
30801         return member.id;
30802       }).forEach(collectDeepDescendants);
30803     }
30804   }
30805   function utilHighlightEntities(ids, highlighted, context) {
30806     context.surface().selectAll(utilEntityOrDeepMemberSelector(ids, context.graph())).classed("highlighted", highlighted);
30807   }
30808   function utilGetAllNodes(ids, graph) {
30809     var seen = /* @__PURE__ */ new Set();
30810     var nodes = /* @__PURE__ */ new Set();
30811     ids.forEach(collectNodes);
30812     return Array.from(nodes);
30813     function collectNodes(id2) {
30814       if (seen.has(id2))
30815         return;
30816       seen.add(id2);
30817       var entity = graph.hasEntity(id2);
30818       if (!entity)
30819         return;
30820       if (entity.type === "node") {
30821         nodes.add(entity);
30822       } else if (entity.type === "way") {
30823         entity.nodes.forEach(collectNodes);
30824       } else {
30825         entity.members.map(function(member) {
30826           return member.id;
30827         }).forEach(collectNodes);
30828       }
30829     }
30830   }
30831   function utilDisplayName(entity) {
30832     var localizedNameKey = "name:" + _mainLocalizer.languageCode().toLowerCase();
30833     var name = entity.tags[localizedNameKey] || entity.tags.name || "";
30834     if (name)
30835       return name;
30836     var tags = {
30837       direction: entity.tags.direction,
30838       from: entity.tags.from,
30839       network: entity.tags.cycle_network || entity.tags.network,
30840       ref: entity.tags.ref,
30841       to: entity.tags.to,
30842       via: entity.tags.via
30843     };
30844     var keyComponents = [];
30845     if (tags.network) {
30846       keyComponents.push("network");
30847     }
30848     if (tags.ref) {
30849       keyComponents.push("ref");
30850     }
30851     if (entity.tags.route) {
30852       if (tags.direction) {
30853         keyComponents.push("direction");
30854       } else if (tags.from && tags.to) {
30855         keyComponents.push("from");
30856         keyComponents.push("to");
30857         if (tags.via) {
30858           keyComponents.push("via");
30859         }
30860       }
30861     }
30862     if (keyComponents.length) {
30863       name = _t("inspector.display_name." + keyComponents.join("_"), tags);
30864     }
30865     return name;
30866   }
30867   function utilDisplayNameForPath(entity) {
30868     var name = utilDisplayName(entity);
30869     var isFirefox = utilDetect().browser.toLowerCase().indexOf("firefox") > -1;
30870     var isNewChromium = Number(utilDetect().version.split(".")[0]) >= 96;
30871     if (!isFirefox && !isNewChromium && name && rtlRegex.test(name)) {
30872       name = fixRTLTextForSvg(name);
30873     }
30874     return name;
30875   }
30876   function utilDisplayType(id2) {
30877     return {
30878       n: _t("inspector.node"),
30879       w: _t("inspector.way"),
30880       r: _t("inspector.relation")
30881     }[id2.charAt(0)];
30882   }
30883   function utilDisplayLabel(entity, graphOrGeometry, verbose) {
30884     var result;
30885     var displayName = utilDisplayName(entity);
30886     var preset = typeof graphOrGeometry === "string" ? _mainPresetIndex.matchTags(entity.tags, graphOrGeometry) : _mainPresetIndex.match(entity, graphOrGeometry);
30887     var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
30888     if (verbose) {
30889       result = [presetName, displayName].filter(Boolean).join(" ");
30890     } else {
30891       result = displayName || presetName;
30892     }
30893     return result || utilDisplayType(entity.id);
30894   }
30895   function utilEntityRoot(entityType) {
30896     return {
30897       node: "n",
30898       way: "w",
30899       relation: "r"
30900     }[entityType];
30901   }
30902   function utilCombinedTags(entityIDs, graph) {
30903     var tags = {};
30904     var tagCounts = {};
30905     var allKeys = /* @__PURE__ */ new Set();
30906     var entities = entityIDs.map(function(entityID) {
30907       return graph.hasEntity(entityID);
30908     }).filter(Boolean);
30909     entities.forEach(function(entity) {
30910       var keys2 = Object.keys(entity.tags).filter(Boolean);
30911       keys2.forEach(function(key2) {
30912         allKeys.add(key2);
30913       });
30914     });
30915     entities.forEach(function(entity) {
30916       allKeys.forEach(function(key2) {
30917         var value = entity.tags[key2];
30918         if (!tags.hasOwnProperty(key2)) {
30919           tags[key2] = value;
30920         } else {
30921           if (!Array.isArray(tags[key2])) {
30922             if (tags[key2] !== value) {
30923               tags[key2] = [tags[key2], value];
30924             }
30925           } else {
30926             if (tags[key2].indexOf(value) === -1) {
30927               tags[key2].push(value);
30928             }
30929           }
30930         }
30931         var tagHash = key2 + "=" + value;
30932         if (!tagCounts[tagHash])
30933           tagCounts[tagHash] = 0;
30934         tagCounts[tagHash] += 1;
30935       });
30936     });
30937     for (var key in tags) {
30938       if (!Array.isArray(tags[key]))
30939         continue;
30940       tags[key] = tags[key].sort(function(val12, val2) {
30941         var key2 = key2;
30942         var count2 = tagCounts[key2 + "=" + val2];
30943         var count1 = tagCounts[key2 + "=" + val12];
30944         if (count2 !== count1) {
30945           return count2 - count1;
30946         }
30947         if (val2 && val12) {
30948           return val12.localeCompare(val2);
30949         }
30950         return val12 ? 1 : -1;
30951       });
30952     }
30953     return tags;
30954   }
30955   function utilStringQs(str) {
30956     var i3 = 0;
30957     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
30958       i3++;
30959     str = str.slice(i3);
30960     return str.split("&").reduce(function(obj, pair3) {
30961       var parts = pair3.split("=");
30962       if (parts.length === 2) {
30963         obj[parts[0]] = null === parts[1] ? "" : decodeURIComponent(parts[1]);
30964       }
30965       return obj;
30966     }, {});
30967   }
30968   function utilQsString(obj, noencode) {
30969     function softEncode(s2) {
30970       return encodeURIComponent(s2).replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent);
30971     }
30972     return Object.keys(obj).sort().map(function(key) {
30973       return encodeURIComponent(key) + "=" + (noencode ? softEncode(obj[key]) : encodeURIComponent(obj[key]));
30974     }).join("&");
30975   }
30976   function utilPrefixDOMProperty(property) {
30977     var prefixes2 = ["webkit", "ms", "moz", "o"];
30978     var i3 = -1;
30979     var n3 = prefixes2.length;
30980     var s2 = document.body;
30981     if (property in s2)
30982       return property;
30983     property = property.slice(0, 1).toUpperCase() + property.slice(1);
30984     while (++i3 < n3) {
30985       if (prefixes2[i3] + property in s2) {
30986         return prefixes2[i3] + property;
30987       }
30988     }
30989     return false;
30990   }
30991   function utilPrefixCSSProperty(property) {
30992     var prefixes2 = ["webkit", "ms", "Moz", "O"];
30993     var i3 = -1;
30994     var n3 = prefixes2.length;
30995     var s2 = document.body.style;
30996     if (property.toLowerCase() in s2) {
30997       return property.toLowerCase();
30998     }
30999     while (++i3 < n3) {
31000       if (prefixes2[i3] + property in s2) {
31001         return "-" + prefixes2[i3].toLowerCase() + property.replace(/([A-Z])/g, "-$1").toLowerCase();
31002       }
31003     }
31004     return false;
31005   }
31006   var transformProperty;
31007   function utilSetTransform(el, x2, y2, scale) {
31008     var prop = transformProperty = transformProperty || utilPrefixCSSProperty("Transform");
31009     var translate = utilDetect().opera ? "translate(" + x2 + "px," + y2 + "px)" : "translate3d(" + x2 + "px," + y2 + "px,0)";
31010     return el.style(prop, translate + (scale ? " scale(" + scale + ")" : ""));
31011   }
31012   function utilEditDistance(a2, b2) {
31013     a2 = (0, import_diacritics.remove)(a2.toLowerCase());
31014     b2 = (0, import_diacritics.remove)(b2.toLowerCase());
31015     if (a2.length === 0)
31016       return b2.length;
31017     if (b2.length === 0)
31018       return a2.length;
31019     var matrix = [];
31020     var i3, j2;
31021     for (i3 = 0; i3 <= b2.length; i3++) {
31022       matrix[i3] = [i3];
31023     }
31024     for (j2 = 0; j2 <= a2.length; j2++) {
31025       matrix[0][j2] = j2;
31026     }
31027     for (i3 = 1; i3 <= b2.length; i3++) {
31028       for (j2 = 1; j2 <= a2.length; j2++) {
31029         if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) {
31030           matrix[i3][j2] = matrix[i3 - 1][j2 - 1];
31031         } else {
31032           matrix[i3][j2] = Math.min(
31033             matrix[i3 - 1][j2 - 1] + 1,
31034             // substitution
31035             Math.min(
31036               matrix[i3][j2 - 1] + 1,
31037               // insertion
31038               matrix[i3 - 1][j2] + 1
31039             )
31040           );
31041         }
31042       }
31043     }
31044     return matrix[b2.length][a2.length];
31045   }
31046   function utilFastMouse(container) {
31047     var rect = container.getBoundingClientRect();
31048     var rectLeft = rect.left;
31049     var rectTop = rect.top;
31050     var clientLeft = +container.clientLeft;
31051     var clientTop = +container.clientTop;
31052     return function(e3) {
31053       return [
31054         e3.clientX - rectLeft - clientLeft,
31055         e3.clientY - rectTop - clientTop
31056       ];
31057     };
31058   }
31059   function utilAsyncMap(inputs, func, callback) {
31060     var remaining = inputs.length;
31061     var results = [];
31062     var errors = [];
31063     inputs.forEach(function(d2, i3) {
31064       func(d2, function done(err, data) {
31065         errors[i3] = err;
31066         results[i3] = data;
31067         remaining--;
31068         if (!remaining)
31069           callback(errors, results);
31070       });
31071     });
31072   }
31073   function utilWrap(index, length2) {
31074     if (index < 0) {
31075       index += Math.ceil(-index / length2) * length2;
31076     }
31077     return index % length2;
31078   }
31079   function utilFunctor(value) {
31080     if (typeof value === "function")
31081       return value;
31082     return function() {
31083       return value;
31084     };
31085   }
31086   function utilNoAuto(selection2) {
31087     var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea";
31088     return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("spellcheck", isText ? "true" : "false");
31089   }
31090   function utilHashcode(str) {
31091     var hash = 0;
31092     if (str.length === 0) {
31093       return hash;
31094     }
31095     for (var i3 = 0; i3 < str.length; i3++) {
31096       var char = str.charCodeAt(i3);
31097       hash = (hash << 5) - hash + char;
31098       hash = hash & hash;
31099     }
31100     return hash;
31101   }
31102   function utilSafeClassName(str) {
31103     return str.toLowerCase().replace(/[^a-z0-9]+/g, "_");
31104   }
31105   function utilUniqueDomId(val) {
31106     return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString();
31107   }
31108   function utilUnicodeCharsCount(str) {
31109     return Array.from(str).length;
31110   }
31111   function utilUnicodeCharsTruncated(str, limit) {
31112     return Array.from(str).slice(0, limit).join("");
31113   }
31114   function toNumericID(id2) {
31115     var match = id2.match(/^[cnwr](-?\d+)$/);
31116     if (match) {
31117       return parseInt(match[1], 10);
31118     }
31119     return NaN;
31120   }
31121   function compareNumericIDs(left, right) {
31122     if (isNaN(left) && isNaN(right))
31123       return -1;
31124     if (isNaN(left))
31125       return 1;
31126     if (isNaN(right))
31127       return -1;
31128     if (Math.sign(left) !== Math.sign(right))
31129       return -Math.sign(left);
31130     if (Math.sign(left) < 0)
31131       return Math.sign(right - left);
31132     return Math.sign(left - right);
31133   }
31134   function utilCompareIDs(left, right) {
31135     return compareNumericIDs(toNumericID(left), toNumericID(right));
31136   }
31137   function utilOldestID(ids) {
31138     if (ids.length === 0) {
31139       return void 0;
31140     }
31141     var oldestIDIndex = 0;
31142     var oldestID = toNumericID(ids[0]);
31143     for (var i3 = 1; i3 < ids.length; i3++) {
31144       var num = toNumericID(ids[i3]);
31145       if (compareNumericIDs(oldestID, num) === 1) {
31146         oldestIDIndex = i3;
31147         oldestID = num;
31148       }
31149     }
31150     return ids[oldestIDIndex];
31151   }
31152   function utilCleanOsmString(val, maxChars) {
31153     if (val === void 0 || val === null) {
31154       val = "";
31155     } else {
31156       val = val.toString();
31157     }
31158     val = val.trim();
31159     if (val.normalize)
31160       val = val.normalize("NFC");
31161     return utilUnicodeCharsTruncated(val, maxChars);
31162   }
31163
31164   // modules/osm/entity.js
31165   function osmEntity(attrs) {
31166     if (this instanceof osmEntity)
31167       return;
31168     if (attrs && attrs.type) {
31169       return osmEntity[attrs.type].apply(this, arguments);
31170     } else if (attrs && attrs.id) {
31171       return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
31172     }
31173     return new osmEntity().initialize(arguments);
31174   }
31175   osmEntity.id = function(type2) {
31176     return osmEntity.id.fromOSM(type2, osmEntity.id.next[type2]--);
31177   };
31178   osmEntity.id.next = {
31179     changeset: -1,
31180     node: -1,
31181     way: -1,
31182     relation: -1
31183   };
31184   osmEntity.id.fromOSM = function(type2, id2) {
31185     return type2[0] + id2;
31186   };
31187   osmEntity.id.toOSM = function(id2) {
31188     var match = id2.match(/^[cnwr](-?\d+)$/);
31189     if (match) {
31190       return match[1];
31191     }
31192     return "";
31193   };
31194   osmEntity.id.type = function(id2) {
31195     return { "c": "changeset", "n": "node", "w": "way", "r": "relation" }[id2[0]];
31196   };
31197   osmEntity.key = function(entity) {
31198     return entity.id + "v" + (entity.v || 0);
31199   };
31200   var _deprecatedTagValuesByKey;
31201   osmEntity.deprecatedTagValuesByKey = function(dataDeprecated) {
31202     if (!_deprecatedTagValuesByKey) {
31203       _deprecatedTagValuesByKey = {};
31204       dataDeprecated.forEach(function(d2) {
31205         var oldKeys = Object.keys(d2.old);
31206         if (oldKeys.length === 1) {
31207           var oldKey = oldKeys[0];
31208           var oldValue = d2.old[oldKey];
31209           if (oldValue !== "*") {
31210             if (!_deprecatedTagValuesByKey[oldKey]) {
31211               _deprecatedTagValuesByKey[oldKey] = [oldValue];
31212             } else {
31213               _deprecatedTagValuesByKey[oldKey].push(oldValue);
31214             }
31215           }
31216         }
31217       });
31218     }
31219     return _deprecatedTagValuesByKey;
31220   };
31221   osmEntity.prototype = {
31222     tags: {},
31223     initialize: function(sources) {
31224       for (var i3 = 0; i3 < sources.length; ++i3) {
31225         var source = sources[i3];
31226         for (var prop in source) {
31227           if (Object.prototype.hasOwnProperty.call(source, prop)) {
31228             if (source[prop] === void 0) {
31229               delete this[prop];
31230             } else {
31231               this[prop] = source[prop];
31232             }
31233           }
31234         }
31235       }
31236       if (!this.id && this.type) {
31237         this.id = osmEntity.id(this.type);
31238       }
31239       if (!this.hasOwnProperty("visible")) {
31240         this.visible = true;
31241       }
31242       if (debug) {
31243         Object.freeze(this);
31244         Object.freeze(this.tags);
31245         if (this.loc)
31246           Object.freeze(this.loc);
31247         if (this.nodes)
31248           Object.freeze(this.nodes);
31249         if (this.members)
31250           Object.freeze(this.members);
31251       }
31252       return this;
31253     },
31254     copy: function(resolver, copies) {
31255       if (copies[this.id])
31256         return copies[this.id];
31257       var copy2 = osmEntity(this, { id: void 0, user: void 0, version: void 0 });
31258       copies[this.id] = copy2;
31259       return copy2;
31260     },
31261     osmId: function() {
31262       return osmEntity.id.toOSM(this.id);
31263     },
31264     isNew: function() {
31265       var osmId = osmEntity.id.toOSM(this.id);
31266       return osmId.length === 0 || osmId[0] === "-";
31267     },
31268     update: function(attrs) {
31269       return osmEntity(this, attrs, { v: 1 + (this.v || 0) });
31270     },
31271     mergeTags: function(tags) {
31272       var merged = Object.assign({}, this.tags);
31273       var changed = false;
31274       for (var k2 in tags) {
31275         var t1 = merged[k2];
31276         var t2 = tags[k2];
31277         if (!t1) {
31278           changed = true;
31279           merged[k2] = t2;
31280         } else if (t1 !== t2) {
31281           changed = true;
31282           merged[k2] = utilUnicodeCharsTruncated(
31283             utilArrayUnion(t1.split(/;\s*/), t2.split(/;\s*/)).join(";"),
31284             255
31285             // avoid exceeding character limit; see also context.maxCharsForTagValue()
31286           );
31287         }
31288       }
31289       return changed ? this.update({ tags: merged }) : this;
31290     },
31291     intersects: function(extent, resolver) {
31292       return this.extent(resolver).intersects(extent);
31293     },
31294     hasNonGeometryTags: function() {
31295       return Object.keys(this.tags).some(function(k2) {
31296         return k2 !== "area";
31297       });
31298     },
31299     hasParentRelations: function(resolver) {
31300       return resolver.parentRelations(this).length > 0;
31301     },
31302     hasInterestingTags: function() {
31303       return Object.keys(this.tags).some(osmIsInterestingTag);
31304     },
31305     isHighwayIntersection: function() {
31306       return false;
31307     },
31308     isDegenerate: function() {
31309       return true;
31310     },
31311     deprecatedTags: function(dataDeprecated) {
31312       var tags = this.tags;
31313       if (Object.keys(tags).length === 0)
31314         return [];
31315       var deprecated = [];
31316       dataDeprecated.forEach(function(d2) {
31317         var oldKeys = Object.keys(d2.old);
31318         if (d2.replace) {
31319           var hasExistingValues = Object.keys(d2.replace).some(function(replaceKey) {
31320             if (!tags[replaceKey] || d2.old[replaceKey])
31321               return false;
31322             var replaceValue = d2.replace[replaceKey];
31323             if (replaceValue === "*")
31324               return false;
31325             if (replaceValue === tags[replaceKey])
31326               return false;
31327             return true;
31328           });
31329           if (hasExistingValues)
31330             return;
31331         }
31332         var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
31333           if (!tags[oldKey])
31334             return false;
31335           if (d2.old[oldKey] === "*")
31336             return true;
31337           if (d2.old[oldKey] === tags[oldKey])
31338             return true;
31339           var vals = tags[oldKey].split(";").filter(Boolean);
31340           if (vals.length === 0) {
31341             return false;
31342           } else if (vals.length > 1) {
31343             return vals.indexOf(d2.old[oldKey]) !== -1;
31344           } else {
31345             if (tags[oldKey] === d2.old[oldKey]) {
31346               if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) {
31347                 var replaceKeys = Object.keys(d2.replace);
31348                 return !replaceKeys.every(function(replaceKey) {
31349                   return tags[replaceKey] === d2.replace[replaceKey];
31350                 });
31351               } else {
31352                 return true;
31353               }
31354             }
31355           }
31356           return false;
31357         });
31358         if (matchesDeprecatedTags) {
31359           deprecated.push(d2);
31360         }
31361       });
31362       return deprecated;
31363     }
31364   };
31365
31366   // modules/osm/lanes.js
31367   function osmLanes(entity) {
31368     if (entity.type !== "way")
31369       return null;
31370     if (!entity.tags.highway)
31371       return null;
31372     var tags = entity.tags;
31373     var isOneWay = entity.isOneWay();
31374     var laneCount = getLaneCount(tags, isOneWay);
31375     var maxspeed = parseMaxspeed(tags);
31376     var laneDirections = parseLaneDirections(tags, isOneWay, laneCount);
31377     var forward = laneDirections.forward;
31378     var backward = laneDirections.backward;
31379     var bothways = laneDirections.bothways;
31380     var turnLanes = {};
31381     turnLanes.unspecified = parseTurnLanes(tags["turn:lanes"]);
31382     turnLanes.forward = parseTurnLanes(tags["turn:lanes:forward"]);
31383     turnLanes.backward = parseTurnLanes(tags["turn:lanes:backward"]);
31384     var maxspeedLanes = {};
31385     maxspeedLanes.unspecified = parseMaxspeedLanes(tags["maxspeed:lanes"], maxspeed);
31386     maxspeedLanes.forward = parseMaxspeedLanes(tags["maxspeed:lanes:forward"], maxspeed);
31387     maxspeedLanes.backward = parseMaxspeedLanes(tags["maxspeed:lanes:backward"], maxspeed);
31388     var psvLanes = {};
31389     psvLanes.unspecified = parseMiscLanes(tags["psv:lanes"]);
31390     psvLanes.forward = parseMiscLanes(tags["psv:lanes:forward"]);
31391     psvLanes.backward = parseMiscLanes(tags["psv:lanes:backward"]);
31392     var busLanes = {};
31393     busLanes.unspecified = parseMiscLanes(tags["bus:lanes"]);
31394     busLanes.forward = parseMiscLanes(tags["bus:lanes:forward"]);
31395     busLanes.backward = parseMiscLanes(tags["bus:lanes:backward"]);
31396     var taxiLanes = {};
31397     taxiLanes.unspecified = parseMiscLanes(tags["taxi:lanes"]);
31398     taxiLanes.forward = parseMiscLanes(tags["taxi:lanes:forward"]);
31399     taxiLanes.backward = parseMiscLanes(tags["taxi:lanes:backward"]);
31400     var hovLanes = {};
31401     hovLanes.unspecified = parseMiscLanes(tags["hov:lanes"]);
31402     hovLanes.forward = parseMiscLanes(tags["hov:lanes:forward"]);
31403     hovLanes.backward = parseMiscLanes(tags["hov:lanes:backward"]);
31404     var hgvLanes = {};
31405     hgvLanes.unspecified = parseMiscLanes(tags["hgv:lanes"]);
31406     hgvLanes.forward = parseMiscLanes(tags["hgv:lanes:forward"]);
31407     hgvLanes.backward = parseMiscLanes(tags["hgv:lanes:backward"]);
31408     var bicyclewayLanes = {};
31409     bicyclewayLanes.unspecified = parseBicycleWay(tags["bicycleway:lanes"]);
31410     bicyclewayLanes.forward = parseBicycleWay(tags["bicycleway:lanes:forward"]);
31411     bicyclewayLanes.backward = parseBicycleWay(tags["bicycleway:lanes:backward"]);
31412     var lanesObj = {
31413       forward: [],
31414       backward: [],
31415       unspecified: []
31416     };
31417     mapToLanesObj(lanesObj, turnLanes, "turnLane");
31418     mapToLanesObj(lanesObj, maxspeedLanes, "maxspeed");
31419     mapToLanesObj(lanesObj, psvLanes, "psv");
31420     mapToLanesObj(lanesObj, busLanes, "bus");
31421     mapToLanesObj(lanesObj, taxiLanes, "taxi");
31422     mapToLanesObj(lanesObj, hovLanes, "hov");
31423     mapToLanesObj(lanesObj, hgvLanes, "hgv");
31424     mapToLanesObj(lanesObj, bicyclewayLanes, "bicycleway");
31425     return {
31426       metadata: {
31427         count: laneCount,
31428         oneway: isOneWay,
31429         forward,
31430         backward,
31431         bothways,
31432         turnLanes,
31433         maxspeed,
31434         maxspeedLanes,
31435         psvLanes,
31436         busLanes,
31437         taxiLanes,
31438         hovLanes,
31439         hgvLanes,
31440         bicyclewayLanes
31441       },
31442       lanes: lanesObj
31443     };
31444   }
31445   function getLaneCount(tags, isOneWay) {
31446     var count;
31447     if (tags.lanes) {
31448       count = parseInt(tags.lanes, 10);
31449       if (count > 0) {
31450         return count;
31451       }
31452     }
31453     switch (tags.highway) {
31454       case "trunk":
31455       case "motorway":
31456         count = isOneWay ? 2 : 4;
31457         break;
31458       default:
31459         count = isOneWay ? 1 : 2;
31460         break;
31461     }
31462     return count;
31463   }
31464   function parseMaxspeed(tags) {
31465     var maxspeed = tags.maxspeed;
31466     if (!maxspeed)
31467       return;
31468     var maxspeedRegex = /^([0-9][\.0-9]+?)(?:[ ]?(?:km\/h|kmh|kph|mph|knots))?$/;
31469     if (!maxspeedRegex.test(maxspeed))
31470       return;
31471     return parseInt(maxspeed, 10);
31472   }
31473   function parseLaneDirections(tags, isOneWay, laneCount) {
31474     var forward = parseInt(tags["lanes:forward"], 10);
31475     var backward = parseInt(tags["lanes:backward"], 10);
31476     var bothways = parseInt(tags["lanes:both_ways"], 10) > 0 ? 1 : 0;
31477     if (parseInt(tags.oneway, 10) === -1) {
31478       forward = 0;
31479       bothways = 0;
31480       backward = laneCount;
31481     } else if (isOneWay) {
31482       forward = laneCount;
31483       bothways = 0;
31484       backward = 0;
31485     } else if (isNaN(forward) && isNaN(backward)) {
31486       backward = Math.floor((laneCount - bothways) / 2);
31487       forward = laneCount - bothways - backward;
31488     } else if (isNaN(forward)) {
31489       if (backward > laneCount - bothways) {
31490         backward = laneCount - bothways;
31491       }
31492       forward = laneCount - bothways - backward;
31493     } else if (isNaN(backward)) {
31494       if (forward > laneCount - bothways) {
31495         forward = laneCount - bothways;
31496       }
31497       backward = laneCount - bothways - forward;
31498     }
31499     return {
31500       forward,
31501       backward,
31502       bothways
31503     };
31504   }
31505   function parseTurnLanes(tag2) {
31506     if (!tag2)
31507       return;
31508     var validValues = [
31509       "left",
31510       "slight_left",
31511       "sharp_left",
31512       "through",
31513       "right",
31514       "slight_right",
31515       "sharp_right",
31516       "reverse",
31517       "merge_to_left",
31518       "merge_to_right",
31519       "none"
31520     ];
31521     return tag2.split("|").map(function(s2) {
31522       if (s2 === "")
31523         s2 = "none";
31524       return s2.split(";").map(function(d2) {
31525         return validValues.indexOf(d2) === -1 ? "unknown" : d2;
31526       });
31527     });
31528   }
31529   function parseMaxspeedLanes(tag2, maxspeed) {
31530     if (!tag2)
31531       return;
31532     return tag2.split("|").map(function(s2) {
31533       if (s2 === "none")
31534         return s2;
31535       var m2 = parseInt(s2, 10);
31536       if (s2 === "" || m2 === maxspeed)
31537         return null;
31538       return isNaN(m2) ? "unknown" : m2;
31539     });
31540   }
31541   function parseMiscLanes(tag2) {
31542     if (!tag2)
31543       return;
31544     var validValues = [
31545       "yes",
31546       "no",
31547       "designated"
31548     ];
31549     return tag2.split("|").map(function(s2) {
31550       if (s2 === "")
31551         s2 = "no";
31552       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31553     });
31554   }
31555   function parseBicycleWay(tag2) {
31556     if (!tag2)
31557       return;
31558     var validValues = [
31559       "yes",
31560       "no",
31561       "designated",
31562       "lane"
31563     ];
31564     return tag2.split("|").map(function(s2) {
31565       if (s2 === "")
31566         s2 = "no";
31567       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31568     });
31569   }
31570   function mapToLanesObj(lanesObj, data, key) {
31571     if (data.forward) {
31572       data.forward.forEach(function(l2, i3) {
31573         if (!lanesObj.forward[i3])
31574           lanesObj.forward[i3] = {};
31575         lanesObj.forward[i3][key] = l2;
31576       });
31577     }
31578     if (data.backward) {
31579       data.backward.forEach(function(l2, i3) {
31580         if (!lanesObj.backward[i3])
31581           lanesObj.backward[i3] = {};
31582         lanesObj.backward[i3][key] = l2;
31583       });
31584     }
31585     if (data.unspecified) {
31586       data.unspecified.forEach(function(l2, i3) {
31587         if (!lanesObj.unspecified[i3])
31588           lanesObj.unspecified[i3] = {};
31589         lanesObj.unspecified[i3][key] = l2;
31590       });
31591     }
31592   }
31593
31594   // modules/osm/way.js
31595   function osmWay() {
31596     if (!(this instanceof osmWay)) {
31597       return new osmWay().initialize(arguments);
31598     } else if (arguments.length) {
31599       this.initialize(arguments);
31600     }
31601   }
31602   osmEntity.way = osmWay;
31603   osmWay.prototype = Object.create(osmEntity.prototype);
31604   Object.assign(osmWay.prototype, {
31605     type: "way",
31606     nodes: [],
31607     copy: function(resolver, copies) {
31608       if (copies[this.id])
31609         return copies[this.id];
31610       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
31611       var nodes = this.nodes.map(function(id2) {
31612         return resolver.entity(id2).copy(resolver, copies).id;
31613       });
31614       copy2 = copy2.update({ nodes });
31615       copies[this.id] = copy2;
31616       return copy2;
31617     },
31618     extent: function(resolver) {
31619       return resolver.transient(this, "extent", function() {
31620         var extent = geoExtent();
31621         for (var i3 = 0; i3 < this.nodes.length; i3++) {
31622           var node = resolver.hasEntity(this.nodes[i3]);
31623           if (node) {
31624             extent._extend(node.extent());
31625           }
31626         }
31627         return extent;
31628       });
31629     },
31630     first: function() {
31631       return this.nodes[0];
31632     },
31633     last: function() {
31634       return this.nodes[this.nodes.length - 1];
31635     },
31636     contains: function(node) {
31637       return this.nodes.indexOf(node) >= 0;
31638     },
31639     affix: function(node) {
31640       if (this.nodes[0] === node)
31641         return "prefix";
31642       if (this.nodes[this.nodes.length - 1] === node)
31643         return "suffix";
31644     },
31645     layer: function() {
31646       if (isFinite(this.tags.layer)) {
31647         return Math.max(-10, Math.min(+this.tags.layer, 10));
31648       }
31649       if (this.tags.covered === "yes")
31650         return -1;
31651       if (this.tags.location === "overground")
31652         return 1;
31653       if (this.tags.location === "underground")
31654         return -1;
31655       if (this.tags.location === "underwater")
31656         return -10;
31657       if (this.tags.power === "line")
31658         return 10;
31659       if (this.tags.power === "minor_line")
31660         return 10;
31661       if (this.tags.aerialway)
31662         return 10;
31663       if (this.tags.bridge)
31664         return 1;
31665       if (this.tags.cutting)
31666         return -1;
31667       if (this.tags.tunnel)
31668         return -1;
31669       if (this.tags.waterway)
31670         return -1;
31671       if (this.tags.man_made === "pipeline")
31672         return -10;
31673       if (this.tags.boundary)
31674         return -10;
31675       return 0;
31676     },
31677     // the approximate width of the line based on its tags except its `width` tag
31678     impliedLineWidthMeters: function() {
31679       var averageWidths = {
31680         highway: {
31681           // width is for single lane
31682           motorway: 5,
31683           motorway_link: 5,
31684           trunk: 4.5,
31685           trunk_link: 4.5,
31686           primary: 4,
31687           secondary: 4,
31688           tertiary: 4,
31689           primary_link: 4,
31690           secondary_link: 4,
31691           tertiary_link: 4,
31692           unclassified: 4,
31693           road: 4,
31694           living_street: 4,
31695           bus_guideway: 4,
31696           busway: 4,
31697           pedestrian: 4,
31698           residential: 3.5,
31699           service: 3.5,
31700           track: 3,
31701           cycleway: 2.5,
31702           bridleway: 2,
31703           corridor: 2,
31704           steps: 2,
31705           path: 1.5,
31706           footway: 1.5
31707         },
31708         railway: {
31709           // width includes ties and rail bed, not just track gauge
31710           rail: 2.5,
31711           light_rail: 2.5,
31712           tram: 2.5,
31713           subway: 2.5,
31714           monorail: 2.5,
31715           funicular: 2.5,
31716           disused: 2.5,
31717           preserved: 2.5,
31718           miniature: 1.5,
31719           narrow_gauge: 1.5
31720         },
31721         waterway: {
31722           river: 50,
31723           canal: 25,
31724           stream: 5,
31725           tidal_channel: 5,
31726           fish_pass: 2.5,
31727           drain: 2.5,
31728           ditch: 1.5
31729         }
31730       };
31731       for (var key in averageWidths) {
31732         if (this.tags[key] && averageWidths[key][this.tags[key]]) {
31733           var width = averageWidths[key][this.tags[key]];
31734           if (key === "highway") {
31735             var laneCount = this.tags.lanes && parseInt(this.tags.lanes, 10);
31736             if (!laneCount)
31737               laneCount = this.isOneWay() ? 1 : 2;
31738             return width * laneCount;
31739           }
31740           return width;
31741         }
31742       }
31743       return null;
31744     },
31745     isOneWay: function() {
31746       var values = {
31747         "yes": true,
31748         "1": true,
31749         "-1": true,
31750         "reversible": true,
31751         "alternating": true,
31752         "no": false,
31753         "0": false
31754       };
31755       if (values[this.tags.oneway] !== void 0) {
31756         return values[this.tags.oneway];
31757       }
31758       for (var key in this.tags) {
31759         if (key in osmOneWayTags && this.tags[key] in osmOneWayTags[key]) {
31760           return true;
31761         }
31762       }
31763       return false;
31764     },
31765     // Some identifier for tag that implies that this way is "sided",
31766     // i.e. the right side is the 'inside' (e.g. the right side of a
31767     // natural=cliff is lower).
31768     sidednessIdentifier: function() {
31769       for (const realKey in this.tags) {
31770         const value = this.tags[realKey];
31771         const key = osmRemoveLifecyclePrefix(realKey);
31772         if (key in osmRightSideIsInsideTags && value in osmRightSideIsInsideTags[key]) {
31773           if (osmRightSideIsInsideTags[key][value] === true) {
31774             return key;
31775           } else {
31776             return osmRightSideIsInsideTags[key][value];
31777           }
31778         }
31779       }
31780       return null;
31781     },
31782     isSided: function() {
31783       if (this.tags.two_sided === "yes") {
31784         return false;
31785       }
31786       return this.sidednessIdentifier() !== null;
31787     },
31788     lanes: function() {
31789       return osmLanes(this);
31790     },
31791     isClosed: function() {
31792       return this.nodes.length > 1 && this.first() === this.last();
31793     },
31794     isConvex: function(resolver) {
31795       if (!this.isClosed() || this.isDegenerate())
31796         return null;
31797       var nodes = utilArrayUniq(resolver.childNodes(this));
31798       var coords = nodes.map(function(n3) {
31799         return n3.loc;
31800       });
31801       var curr = 0;
31802       var prev = 0;
31803       for (var i3 = 0; i3 < coords.length; i3++) {
31804         var o2 = coords[(i3 + 1) % coords.length];
31805         var a2 = coords[i3];
31806         var b2 = coords[(i3 + 2) % coords.length];
31807         var res = geoVecCross(a2, b2, o2);
31808         curr = res > 0 ? 1 : res < 0 ? -1 : 0;
31809         if (curr === 0) {
31810           continue;
31811         } else if (prev && curr !== prev) {
31812           return false;
31813         }
31814         prev = curr;
31815       }
31816       return true;
31817     },
31818     // returns an object with the tag that implies this is an area, if any
31819     tagSuggestingArea: function() {
31820       return osmTagSuggestingArea(this.tags);
31821     },
31822     isArea: function() {
31823       if (this.tags.area === "yes")
31824         return true;
31825       if (!this.isClosed() || this.tags.area === "no")
31826         return false;
31827       return this.tagSuggestingArea() !== null;
31828     },
31829     isDegenerate: function() {
31830       return new Set(this.nodes).size < (this.isArea() ? 3 : 2);
31831     },
31832     areAdjacent: function(n1, n22) {
31833       for (var i3 = 0; i3 < this.nodes.length; i3++) {
31834         if (this.nodes[i3] === n1) {
31835           if (this.nodes[i3 - 1] === n22)
31836             return true;
31837           if (this.nodes[i3 + 1] === n22)
31838             return true;
31839         }
31840       }
31841       return false;
31842     },
31843     geometry: function(graph) {
31844       return graph.transient(this, "geometry", function() {
31845         return this.isArea() ? "area" : "line";
31846       });
31847     },
31848     // returns an array of objects representing the segments between the nodes in this way
31849     segments: function(graph) {
31850       function segmentExtent(graph2) {
31851         var n1 = graph2.hasEntity(this.nodes[0]);
31852         var n22 = graph2.hasEntity(this.nodes[1]);
31853         return n1 && n22 && geoExtent([
31854           [
31855             Math.min(n1.loc[0], n22.loc[0]),
31856             Math.min(n1.loc[1], n22.loc[1])
31857           ],
31858           [
31859             Math.max(n1.loc[0], n22.loc[0]),
31860             Math.max(n1.loc[1], n22.loc[1])
31861           ]
31862         ]);
31863       }
31864       return graph.transient(this, "segments", function() {
31865         var segments = [];
31866         for (var i3 = 0; i3 < this.nodes.length - 1; i3++) {
31867           segments.push({
31868             id: this.id + "-" + i3,
31869             wayId: this.id,
31870             index: i3,
31871             nodes: [this.nodes[i3], this.nodes[i3 + 1]],
31872             extent: segmentExtent
31873           });
31874         }
31875         return segments;
31876       });
31877     },
31878     // If this way is not closed, append the beginning node to the end of the nodelist to close it.
31879     close: function() {
31880       if (this.isClosed() || !this.nodes.length)
31881         return this;
31882       var nodes = this.nodes.slice();
31883       nodes = nodes.filter(noRepeatNodes);
31884       nodes.push(nodes[0]);
31885       return this.update({ nodes });
31886     },
31887     // If this way is closed, remove any connector nodes from the end of the nodelist to unclose it.
31888     unclose: function() {
31889       if (!this.isClosed())
31890         return this;
31891       var nodes = this.nodes.slice();
31892       var connector = this.first();
31893       var i3 = nodes.length - 1;
31894       while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31895         nodes.splice(i3, 1);
31896         i3 = nodes.length - 1;
31897       }
31898       nodes = nodes.filter(noRepeatNodes);
31899       return this.update({ nodes });
31900     },
31901     // Adds a node (id) in front of the node which is currently at position index.
31902     // If index is undefined, the node will be added to the end of the way for linear ways,
31903     //   or just before the final connecting node for circular ways.
31904     // Consecutive duplicates are eliminated including existing ones.
31905     // Circularity is always preserved when adding a node.
31906     addNode: function(id2, index) {
31907       var nodes = this.nodes.slice();
31908       var isClosed = this.isClosed();
31909       var max3 = isClosed ? nodes.length - 1 : nodes.length;
31910       if (index === void 0) {
31911         index = max3;
31912       }
31913       if (index < 0 || index > max3) {
31914         throw new RangeError("index " + index + " out of range 0.." + max3);
31915       }
31916       if (isClosed) {
31917         var connector = this.first();
31918         var i3 = 1;
31919         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31920           nodes.splice(i3, 1);
31921           if (index > i3)
31922             index--;
31923         }
31924         i3 = nodes.length - 1;
31925         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31926           nodes.splice(i3, 1);
31927           if (index > i3)
31928             index--;
31929           i3 = nodes.length - 1;
31930         }
31931       }
31932       nodes.splice(index, 0, id2);
31933       nodes = nodes.filter(noRepeatNodes);
31934       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31935         nodes.push(nodes[0]);
31936       }
31937       return this.update({ nodes });
31938     },
31939     // Replaces the node which is currently at position index with the given node (id).
31940     // Consecutive duplicates are eliminated including existing ones.
31941     // Circularity is preserved when updating a node.
31942     updateNode: function(id2, index) {
31943       var nodes = this.nodes.slice();
31944       var isClosed = this.isClosed();
31945       var max3 = nodes.length - 1;
31946       if (index === void 0 || index < 0 || index > max3) {
31947         throw new RangeError("index " + index + " out of range 0.." + max3);
31948       }
31949       if (isClosed) {
31950         var connector = this.first();
31951         var i3 = 1;
31952         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31953           nodes.splice(i3, 1);
31954           if (index > i3)
31955             index--;
31956         }
31957         i3 = nodes.length - 1;
31958         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31959           nodes.splice(i3, 1);
31960           if (index === i3)
31961             index = 0;
31962           i3 = nodes.length - 1;
31963         }
31964       }
31965       nodes.splice(index, 1, id2);
31966       nodes = nodes.filter(noRepeatNodes);
31967       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31968         nodes.push(nodes[0]);
31969       }
31970       return this.update({ nodes });
31971     },
31972     // Replaces each occurrence of node id needle with replacement.
31973     // Consecutive duplicates are eliminated including existing ones.
31974     // Circularity is preserved.
31975     replaceNode: function(needleID, replacementID) {
31976       var nodes = this.nodes.slice();
31977       var isClosed = this.isClosed();
31978       for (var i3 = 0; i3 < nodes.length; i3++) {
31979         if (nodes[i3] === needleID) {
31980           nodes[i3] = replacementID;
31981         }
31982       }
31983       nodes = nodes.filter(noRepeatNodes);
31984       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31985         nodes.push(nodes[0]);
31986       }
31987       return this.update({ nodes });
31988     },
31989     // Removes each occurrence of node id.
31990     // Consecutive duplicates are eliminated including existing ones.
31991     // Circularity is preserved.
31992     removeNode: function(id2) {
31993       var nodes = this.nodes.slice();
31994       var isClosed = this.isClosed();
31995       nodes = nodes.filter(function(node) {
31996         return node !== id2;
31997       }).filter(noRepeatNodes);
31998       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31999         nodes.push(nodes[0]);
32000       }
32001       return this.update({ nodes });
32002     },
32003     asJXON: function(changeset_id) {
32004       var r2 = {
32005         way: {
32006           "@id": this.osmId(),
32007           "@version": this.version || 0,
32008           nd: this.nodes.map(function(id2) {
32009             return { keyAttributes: { ref: osmEntity.id.toOSM(id2) } };
32010           }, this),
32011           tag: Object.keys(this.tags).map(function(k2) {
32012             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32013           }, this)
32014         }
32015       };
32016       if (changeset_id) {
32017         r2.way["@changeset"] = changeset_id;
32018       }
32019       return r2;
32020     },
32021     asGeoJSON: function(resolver) {
32022       return resolver.transient(this, "GeoJSON", function() {
32023         var coordinates = resolver.childNodes(this).map(function(n3) {
32024           return n3.loc;
32025         });
32026         if (this.isArea() && this.isClosed()) {
32027           return {
32028             type: "Polygon",
32029             coordinates: [coordinates]
32030           };
32031         } else {
32032           return {
32033             type: "LineString",
32034             coordinates
32035           };
32036         }
32037       });
32038     },
32039     area: function(resolver) {
32040       return resolver.transient(this, "area", function() {
32041         var nodes = resolver.childNodes(this);
32042         var json = {
32043           type: "Polygon",
32044           coordinates: [nodes.map(function(n3) {
32045             return n3.loc;
32046           })]
32047         };
32048         if (!this.isClosed() && nodes.length) {
32049           json.coordinates[0].push(nodes[0].loc);
32050         }
32051         var area = area_default(json);
32052         if (area > 2 * Math.PI) {
32053           json.coordinates[0] = json.coordinates[0].reverse();
32054           area = area_default(json);
32055         }
32056         return isNaN(area) ? 0 : area;
32057       });
32058     }
32059   });
32060   function noRepeatNodes(node, i3, arr) {
32061     return i3 === 0 || node !== arr[i3 - 1];
32062   }
32063
32064   // modules/osm/multipolygon.js
32065   function osmJoinWays(toJoin, graph) {
32066     function resolve(member) {
32067       return graph.childNodes(graph.entity(member.id));
32068     }
32069     function reverse(item2) {
32070       var action = actionReverse(item2.id, { reverseOneway: true });
32071       sequences.actions.push(action);
32072       return item2 instanceof osmWay ? action(graph).entity(item2.id) : item2;
32073     }
32074     toJoin = toJoin.filter(function(member) {
32075       return member.type === "way" && graph.hasEntity(member.id);
32076     });
32077     var i3;
32078     var joinAsMembers = true;
32079     for (i3 = 0; i3 < toJoin.length; i3++) {
32080       if (toJoin[i3] instanceof osmWay) {
32081         joinAsMembers = false;
32082         break;
32083       }
32084     }
32085     var sequences = [];
32086     sequences.actions = [];
32087     while (toJoin.length) {
32088       var item = toJoin.shift();
32089       var currWays = [item];
32090       var currNodes = resolve(item).slice();
32091       while (toJoin.length) {
32092         var start2 = currNodes[0];
32093         var end = currNodes[currNodes.length - 1];
32094         var fn = null;
32095         var nodes = null;
32096         for (i3 = 0; i3 < toJoin.length; i3++) {
32097           item = toJoin[i3];
32098           nodes = resolve(item);
32099           if (joinAsMembers && currWays.length === 1 && nodes[0] !== end && nodes[nodes.length - 1] !== end && (nodes[nodes.length - 1] === start2 || nodes[0] === start2)) {
32100             currWays[0] = reverse(currWays[0]);
32101             currNodes.reverse();
32102             start2 = currNodes[0];
32103             end = currNodes[currNodes.length - 1];
32104           }
32105           if (nodes[0] === end) {
32106             fn = currNodes.push;
32107             nodes = nodes.slice(1);
32108             break;
32109           } else if (nodes[nodes.length - 1] === end) {
32110             fn = currNodes.push;
32111             nodes = nodes.slice(0, -1).reverse();
32112             item = reverse(item);
32113             break;
32114           } else if (nodes[nodes.length - 1] === start2) {
32115             fn = currNodes.unshift;
32116             nodes = nodes.slice(0, -1);
32117             break;
32118           } else if (nodes[0] === start2) {
32119             fn = currNodes.unshift;
32120             nodes = nodes.slice(1).reverse();
32121             item = reverse(item);
32122             break;
32123           } else {
32124             fn = nodes = null;
32125           }
32126         }
32127         if (!nodes) {
32128           break;
32129         }
32130         fn.apply(currWays, [item]);
32131         fn.apply(currNodes, nodes);
32132         toJoin.splice(i3, 1);
32133       }
32134       currWays.nodes = currNodes;
32135       sequences.push(currWays);
32136     }
32137     return sequences;
32138   }
32139
32140   // modules/actions/add_member.js
32141   function actionAddMember(relationId, member, memberIndex) {
32142     return function action(graph) {
32143       var relation = graph.entity(relationId);
32144       var isPTv2 = /stop|platform/.test(member.role);
32145       if (member.type === "way" && !isPTv2) {
32146         graph = addWayMember(relation, graph);
32147       } else {
32148         if (isPTv2 && isNaN(memberIndex)) {
32149           memberIndex = 0;
32150         }
32151         graph = graph.replace(relation.addMember(member, memberIndex));
32152       }
32153       return graph;
32154     };
32155     function addWayMember(relation, graph) {
32156       var groups, item, i3, j2, k2;
32157       var PTv2members = [];
32158       var members = [];
32159       for (i3 = 0; i3 < relation.members.length; i3++) {
32160         var m2 = relation.members[i3];
32161         if (/stop|platform/.test(m2.role)) {
32162           PTv2members.push(m2);
32163         } else {
32164           members.push(m2);
32165         }
32166       }
32167       relation = relation.update({ members });
32168       groups = utilArrayGroupBy(relation.members, "type");
32169       groups.way = groups.way || [];
32170       groups.way.push(member);
32171       members = withIndex(groups.way);
32172       var joined = osmJoinWays(members, graph);
32173       for (i3 = 0; i3 < joined.length; i3++) {
32174         var segment = joined[i3];
32175         var nodes = segment.nodes.slice();
32176         var startIndex = segment[0].index;
32177         for (j2 = 0; j2 < members.length; j2++) {
32178           if (members[j2].index === startIndex) {
32179             break;
32180           }
32181         }
32182         for (k2 = 0; k2 < segment.length; k2++) {
32183           item = segment[k2];
32184           var way = graph.entity(item.id);
32185           if (k2 > 0) {
32186             if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) {
32187               moveMember(members, item.index, j2 + k2);
32188             }
32189           }
32190           nodes.splice(0, way.nodes.length - 1);
32191         }
32192       }
32193       var wayMembers = [];
32194       for (i3 = 0; i3 < members.length; i3++) {
32195         item = members[i3];
32196         if (item.index === -1)
32197           continue;
32198         wayMembers.push(utilObjectOmit(item, ["index"]));
32199       }
32200       var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []);
32201       return graph.replace(relation.update({ members: newMembers }));
32202       function moveMember(arr, findIndex, toIndex) {
32203         var i4;
32204         for (i4 = 0; i4 < arr.length; i4++) {
32205           if (arr[i4].index === findIndex) {
32206             break;
32207           }
32208         }
32209         var item2 = Object.assign({}, arr[i4]);
32210         arr[i4].index = -1;
32211         delete item2.index;
32212         arr.splice(toIndex, 0, item2);
32213       }
32214       function withIndex(arr) {
32215         var result = new Array(arr.length);
32216         for (var i4 = 0; i4 < arr.length; i4++) {
32217           result[i4] = Object.assign({}, arr[i4]);
32218           result[i4].index = i4;
32219         }
32220         return result;
32221       }
32222     }
32223   }
32224
32225   // modules/actions/add_midpoint.js
32226   function actionAddMidpoint(midpoint, node) {
32227     return function(graph) {
32228       graph = graph.replace(node.move(midpoint.loc));
32229       var parents = utilArrayIntersection(
32230         graph.parentWays(graph.entity(midpoint.edge[0])),
32231         graph.parentWays(graph.entity(midpoint.edge[1]))
32232       );
32233       parents.forEach(function(way) {
32234         for (var i3 = 0; i3 < way.nodes.length - 1; i3++) {
32235           if (geoEdgeEqual([way.nodes[i3], way.nodes[i3 + 1]], midpoint.edge)) {
32236             graph = graph.replace(graph.entity(way.id).addNode(node.id, i3 + 1));
32237             return;
32238           }
32239         }
32240       });
32241       return graph;
32242     };
32243   }
32244
32245   // modules/actions/add_vertex.js
32246   function actionAddVertex(wayId, nodeId, index) {
32247     return function(graph) {
32248       return graph.replace(graph.entity(wayId).addNode(nodeId, index));
32249     };
32250   }
32251
32252   // modules/actions/change_member.js
32253   function actionChangeMember(relationId, member, memberIndex) {
32254     return function(graph) {
32255       return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
32256     };
32257   }
32258
32259   // modules/actions/change_preset.js
32260   function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
32261     return function action(graph) {
32262       var entity = graph.entity(entityID);
32263       var geometry = entity.geometry(graph);
32264       var tags = entity.tags;
32265       const loc = entity.extent(graph).center();
32266       var preserveKeys;
32267       if (newPreset) {
32268         preserveKeys = [];
32269         if (newPreset.addTags) {
32270           preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
32271         }
32272         if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) {
32273           newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key));
32274         }
32275       }
32276       if (oldPreset)
32277         tags = oldPreset.unsetTags(tags, geometry, preserveKeys, false, loc);
32278       if (newPreset)
32279         tags = newPreset.setTags(tags, geometry, skipFieldDefaults, loc);
32280       return graph.replace(entity.update({ tags }));
32281     };
32282   }
32283
32284   // modules/actions/change_tags.js
32285   function actionChangeTags(entityId, tags) {
32286     return function(graph) {
32287       var entity = graph.entity(entityId);
32288       return graph.replace(entity.update({ tags }));
32289     };
32290   }
32291
32292   // modules/osm/node.js
32293   var cardinal = {
32294     north: 0,
32295     n: 0,
32296     northnortheast: 22,
32297     nne: 22,
32298     northeast: 45,
32299     ne: 45,
32300     eastnortheast: 67,
32301     ene: 67,
32302     east: 90,
32303     e: 90,
32304     eastsoutheast: 112,
32305     ese: 112,
32306     southeast: 135,
32307     se: 135,
32308     southsoutheast: 157,
32309     sse: 157,
32310     south: 180,
32311     s: 180,
32312     southsouthwest: 202,
32313     ssw: 202,
32314     southwest: 225,
32315     sw: 225,
32316     westsouthwest: 247,
32317     wsw: 247,
32318     west: 270,
32319     w: 270,
32320     westnorthwest: 292,
32321     wnw: 292,
32322     northwest: 315,
32323     nw: 315,
32324     northnorthwest: 337,
32325     nnw: 337
32326   };
32327   function osmNode() {
32328     if (!(this instanceof osmNode)) {
32329       return new osmNode().initialize(arguments);
32330     } else if (arguments.length) {
32331       this.initialize(arguments);
32332     }
32333   }
32334   osmEntity.node = osmNode;
32335   osmNode.prototype = Object.create(osmEntity.prototype);
32336   Object.assign(osmNode.prototype, {
32337     type: "node",
32338     loc: [9999, 9999],
32339     extent: function() {
32340       return new geoExtent(this.loc);
32341     },
32342     geometry: function(graph) {
32343       return graph.transient(this, "geometry", function() {
32344         return graph.isPoi(this) ? "point" : "vertex";
32345       });
32346     },
32347     move: function(loc) {
32348       return this.update({ loc });
32349     },
32350     isDegenerate: function() {
32351       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);
32352     },
32353     // Inspect tags and geometry to determine which direction(s) this node/vertex points
32354     directions: function(resolver, projection2) {
32355       var val;
32356       var i3;
32357       if (this.isHighwayIntersection(resolver) && (this.tags.stop || "").toLowerCase() === "all") {
32358         val = "all";
32359       } else {
32360         val = (this.tags.direction || "").toLowerCase();
32361         var re3 = /:direction$/i;
32362         var keys2 = Object.keys(this.tags);
32363         for (i3 = 0; i3 < keys2.length; i3++) {
32364           if (re3.test(keys2[i3])) {
32365             val = this.tags[keys2[i3]].toLowerCase();
32366             break;
32367           }
32368         }
32369       }
32370       if (val === "")
32371         return [];
32372       var values = val.split(";");
32373       var results = [];
32374       values.forEach(function(v2) {
32375         if (cardinal[v2] !== void 0) {
32376           v2 = cardinal[v2];
32377         }
32378         if (v2 !== "" && !isNaN(+v2)) {
32379           results.push(+v2);
32380           return;
32381         }
32382         var lookBackward = this.tags["traffic_sign:backward"] || v2 === "backward" || v2 === "both" || v2 === "all";
32383         var lookForward = this.tags["traffic_sign:forward"] || v2 === "forward" || v2 === "both" || v2 === "all";
32384         if (!lookForward && !lookBackward)
32385           return;
32386         var nodeIds = {};
32387         resolver.parentWays(this).forEach(function(parent) {
32388           var nodes = parent.nodes;
32389           for (i3 = 0; i3 < nodes.length; i3++) {
32390             if (nodes[i3] === this.id) {
32391               if (lookForward && i3 > 0) {
32392                 nodeIds[nodes[i3 - 1]] = true;
32393               }
32394               if (lookBackward && i3 < nodes.length - 1) {
32395                 nodeIds[nodes[i3 + 1]] = true;
32396               }
32397             }
32398           }
32399         }, this);
32400         Object.keys(nodeIds).forEach(function(nodeId) {
32401           results.push(
32402             geoAngle(this, resolver.entity(nodeId), projection2) * (180 / Math.PI) + 90
32403           );
32404         }, this);
32405       }, this);
32406       return utilArrayUniq(results);
32407     },
32408     isCrossing: function() {
32409       return this.tags.highway === "crossing" || this.tags.railway && this.tags.railway.indexOf("crossing") !== -1;
32410     },
32411     isEndpoint: function(resolver) {
32412       return resolver.transient(this, "isEndpoint", function() {
32413         var id2 = this.id;
32414         return resolver.parentWays(this).filter(function(parent) {
32415           return !parent.isClosed() && !!parent.affix(id2);
32416         }).length > 0;
32417       });
32418     },
32419     isConnected: function(resolver) {
32420       return resolver.transient(this, "isConnected", function() {
32421         var parents = resolver.parentWays(this);
32422         if (parents.length > 1) {
32423           for (var i3 in parents) {
32424             if (parents[i3].geometry(resolver) === "line" && parents[i3].hasInterestingTags())
32425               return true;
32426           }
32427         } else if (parents.length === 1) {
32428           var way = parents[0];
32429           var nodes = way.nodes.slice();
32430           if (way.isClosed()) {
32431             nodes.pop();
32432           }
32433           return nodes.indexOf(this.id) !== nodes.lastIndexOf(this.id);
32434         }
32435         return false;
32436       });
32437     },
32438     parentIntersectionWays: function(resolver) {
32439       return resolver.transient(this, "parentIntersectionWays", function() {
32440         return resolver.parentWays(this).filter(function(parent) {
32441           return (parent.tags.highway || parent.tags.waterway || parent.tags.railway || parent.tags.aeroway) && parent.geometry(resolver) === "line";
32442         });
32443       });
32444     },
32445     isIntersection: function(resolver) {
32446       return this.parentIntersectionWays(resolver).length > 1;
32447     },
32448     isHighwayIntersection: function(resolver) {
32449       return resolver.transient(this, "isHighwayIntersection", function() {
32450         return resolver.parentWays(this).filter(function(parent) {
32451           return parent.tags.highway && parent.geometry(resolver) === "line";
32452         }).length > 1;
32453       });
32454     },
32455     isOnAddressLine: function(resolver) {
32456       return resolver.transient(this, "isOnAddressLine", function() {
32457         return resolver.parentWays(this).filter(function(parent) {
32458           return parent.tags.hasOwnProperty("addr:interpolation") && parent.geometry(resolver) === "line";
32459         }).length > 0;
32460       });
32461     },
32462     asJXON: function(changeset_id) {
32463       var r2 = {
32464         node: {
32465           "@id": this.osmId(),
32466           "@lon": this.loc[0],
32467           "@lat": this.loc[1],
32468           "@version": this.version || 0,
32469           tag: Object.keys(this.tags).map(function(k2) {
32470             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32471           }, this)
32472         }
32473       };
32474       if (changeset_id)
32475         r2.node["@changeset"] = changeset_id;
32476       return r2;
32477     },
32478     asGeoJSON: function() {
32479       return {
32480         type: "Point",
32481         coordinates: this.loc
32482       };
32483     }
32484   });
32485
32486   // modules/actions/circularize.js
32487   function actionCircularize(wayId, projection2, maxAngle) {
32488     maxAngle = (maxAngle || 20) * Math.PI / 180;
32489     var action = function(graph, t2) {
32490       if (t2 === null || !isFinite(t2))
32491         t2 = 1;
32492       t2 = Math.min(Math.max(+t2, 0), 1);
32493       var way = graph.entity(wayId);
32494       var origNodes = {};
32495       graph.childNodes(way).forEach(function(node2) {
32496         if (!origNodes[node2.id])
32497           origNodes[node2.id] = node2;
32498       });
32499       if (!way.isConvex(graph)) {
32500         graph = action.makeConvex(graph);
32501       }
32502       var nodes = utilArrayUniq(graph.childNodes(way));
32503       var keyNodes = nodes.filter(function(n3) {
32504         return graph.parentWays(n3).length !== 1;
32505       });
32506       var points = nodes.map(function(n3) {
32507         return projection2(n3.loc);
32508       });
32509       var keyPoints = keyNodes.map(function(n3) {
32510         return projection2(n3.loc);
32511       });
32512       var centroid = points.length === 2 ? geoVecInterp(points[0], points[1], 0.5) : centroid_default2(points);
32513       var radius = median(points, function(p2) {
32514         return geoVecLength(centroid, p2);
32515       });
32516       var sign2 = area_default3(points) > 0 ? 1 : -1;
32517       var ids, i3, j2, k2;
32518       if (!keyNodes.length) {
32519         keyNodes = [nodes[0]];
32520         keyPoints = [points[0]];
32521       }
32522       if (keyNodes.length === 1) {
32523         var index = nodes.indexOf(keyNodes[0]);
32524         var oppositeIndex = Math.floor((index + nodes.length / 2) % nodes.length);
32525         keyNodes.push(nodes[oppositeIndex]);
32526         keyPoints.push(points[oppositeIndex]);
32527       }
32528       for (i3 = 0; i3 < keyPoints.length; i3++) {
32529         var nextKeyNodeIndex = (i3 + 1) % keyNodes.length;
32530         var startNode = keyNodes[i3];
32531         var endNode = keyNodes[nextKeyNodeIndex];
32532         var startNodeIndex = nodes.indexOf(startNode);
32533         var endNodeIndex = nodes.indexOf(endNode);
32534         var numberNewPoints = -1;
32535         var indexRange = endNodeIndex - startNodeIndex;
32536         var nearNodes = {};
32537         var inBetweenNodes = [];
32538         var startAngle, endAngle, totalAngle, eachAngle;
32539         var angle2, loc, node, origNode;
32540         if (indexRange < 0) {
32541           indexRange += nodes.length;
32542         }
32543         var distance = geoVecLength(centroid, keyPoints[i3]) || 1e-4;
32544         keyPoints[i3] = [
32545           centroid[0] + (keyPoints[i3][0] - centroid[0]) / distance * radius,
32546           centroid[1] + (keyPoints[i3][1] - centroid[1]) / distance * radius
32547         ];
32548         loc = projection2.invert(keyPoints[i3]);
32549         node = keyNodes[i3];
32550         origNode = origNodes[node.id];
32551         node = node.move(geoVecInterp(origNode.loc, loc, t2));
32552         graph = graph.replace(node);
32553         startAngle = Math.atan2(keyPoints[i3][1] - centroid[1], keyPoints[i3][0] - centroid[0]);
32554         endAngle = Math.atan2(keyPoints[nextKeyNodeIndex][1] - centroid[1], keyPoints[nextKeyNodeIndex][0] - centroid[0]);
32555         totalAngle = endAngle - startAngle;
32556         if (totalAngle * sign2 > 0) {
32557           totalAngle = -sign2 * (2 * Math.PI - Math.abs(totalAngle));
32558         }
32559         do {
32560           numberNewPoints++;
32561           eachAngle = totalAngle / (indexRange + numberNewPoints);
32562         } while (Math.abs(eachAngle) > maxAngle);
32563         for (j2 = 1; j2 < indexRange; j2++) {
32564           angle2 = startAngle + j2 * eachAngle;
32565           loc = projection2.invert([
32566             centroid[0] + Math.cos(angle2) * radius,
32567             centroid[1] + Math.sin(angle2) * radius
32568           ]);
32569           node = nodes[(j2 + startNodeIndex) % nodes.length];
32570           origNode = origNodes[node.id];
32571           nearNodes[node.id] = angle2;
32572           node = node.move(geoVecInterp(origNode.loc, loc, t2));
32573           graph = graph.replace(node);
32574         }
32575         for (j2 = 0; j2 < numberNewPoints; j2++) {
32576           angle2 = startAngle + (indexRange + j2) * eachAngle;
32577           loc = projection2.invert([
32578             centroid[0] + Math.cos(angle2) * radius,
32579             centroid[1] + Math.sin(angle2) * radius
32580           ]);
32581           var min3 = Infinity;
32582           for (var nodeId in nearNodes) {
32583             var nearAngle = nearNodes[nodeId];
32584             var dist = Math.abs(nearAngle - angle2);
32585             if (dist < min3) {
32586               min3 = dist;
32587               origNode = origNodes[nodeId];
32588             }
32589           }
32590           node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) });
32591           graph = graph.replace(node);
32592           nodes.splice(endNodeIndex + j2, 0, node);
32593           inBetweenNodes.push(node.id);
32594         }
32595         if (indexRange === 1 && inBetweenNodes.length) {
32596           var startIndex1 = way.nodes.lastIndexOf(startNode.id);
32597           var endIndex1 = way.nodes.lastIndexOf(endNode.id);
32598           var wayDirection1 = endIndex1 - startIndex1;
32599           if (wayDirection1 < -1) {
32600             wayDirection1 = 1;
32601           }
32602           var parentWays = graph.parentWays(keyNodes[i3]);
32603           for (j2 = 0; j2 < parentWays.length; j2++) {
32604             var sharedWay = parentWays[j2];
32605             if (sharedWay === way)
32606               continue;
32607             if (sharedWay.areAdjacent(startNode.id, endNode.id)) {
32608               var startIndex2 = sharedWay.nodes.lastIndexOf(startNode.id);
32609               var endIndex2 = sharedWay.nodes.lastIndexOf(endNode.id);
32610               var wayDirection2 = endIndex2 - startIndex2;
32611               var insertAt = endIndex2;
32612               if (wayDirection2 < -1) {
32613                 wayDirection2 = 1;
32614               }
32615               if (wayDirection1 !== wayDirection2) {
32616                 inBetweenNodes.reverse();
32617                 insertAt = startIndex2;
32618               }
32619               for (k2 = 0; k2 < inBetweenNodes.length; k2++) {
32620                 sharedWay = sharedWay.addNode(inBetweenNodes[k2], insertAt + k2);
32621               }
32622               graph = graph.replace(sharedWay);
32623             }
32624           }
32625         }
32626       }
32627       ids = nodes.map(function(n3) {
32628         return n3.id;
32629       });
32630       ids.push(ids[0]);
32631       way = way.update({ nodes: ids });
32632       graph = graph.replace(way);
32633       return graph;
32634     };
32635     action.makeConvex = function(graph) {
32636       var way = graph.entity(wayId);
32637       var nodes = utilArrayUniq(graph.childNodes(way));
32638       var points = nodes.map(function(n3) {
32639         return projection2(n3.loc);
32640       });
32641       var sign2 = area_default3(points) > 0 ? 1 : -1;
32642       var hull = hull_default(points);
32643       var i3, j2;
32644       if (sign2 === -1) {
32645         nodes.reverse();
32646         points.reverse();
32647       }
32648       for (i3 = 0; i3 < hull.length - 1; i3++) {
32649         var startIndex = points.indexOf(hull[i3]);
32650         var endIndex = points.indexOf(hull[i3 + 1]);
32651         var indexRange = endIndex - startIndex;
32652         if (indexRange < 0) {
32653           indexRange += nodes.length;
32654         }
32655         for (j2 = 1; j2 < indexRange; j2++) {
32656           var point2 = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange);
32657           var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point2));
32658           graph = graph.replace(node);
32659         }
32660       }
32661       return graph;
32662     };
32663     action.disabled = function(graph) {
32664       if (!graph.entity(wayId).isClosed()) {
32665         return "not_closed";
32666       }
32667       var way = graph.entity(wayId);
32668       var nodes = utilArrayUniq(graph.childNodes(way));
32669       var points = nodes.map(function(n3) {
32670         return projection2(n3.loc);
32671       });
32672       var hull = hull_default(points);
32673       var epsilonAngle = Math.PI / 180;
32674       if (hull.length !== points.length || hull.length < 3) {
32675         return false;
32676       }
32677       var centroid = centroid_default2(points);
32678       var radius = geoVecLengthSquare(centroid, points[0]);
32679       var i3, actualPoint;
32680       for (i3 = 0; i3 < hull.length; i3++) {
32681         actualPoint = hull[i3];
32682         var actualDist = geoVecLengthSquare(actualPoint, centroid);
32683         var diff = Math.abs(actualDist - radius);
32684         if (diff > 0.05 * radius) {
32685           return false;
32686         }
32687       }
32688       for (i3 = 0; i3 < hull.length; i3++) {
32689         actualPoint = hull[i3];
32690         var nextPoint = hull[(i3 + 1) % hull.length];
32691         var startAngle = Math.atan2(actualPoint[1] - centroid[1], actualPoint[0] - centroid[0]);
32692         var endAngle = Math.atan2(nextPoint[1] - centroid[1], nextPoint[0] - centroid[0]);
32693         var angle2 = endAngle - startAngle;
32694         if (angle2 < 0) {
32695           angle2 = -angle2;
32696         }
32697         if (angle2 > Math.PI) {
32698           angle2 = 2 * Math.PI - angle2;
32699         }
32700         if (angle2 > maxAngle + epsilonAngle) {
32701           return false;
32702         }
32703       }
32704       return "already_circular";
32705     };
32706     action.transitionable = true;
32707     return action;
32708   }
32709
32710   // modules/actions/delete_way.js
32711   function actionDeleteWay(wayID) {
32712     function canDeleteNode(node, graph) {
32713       if (graph.parentWays(node).length || graph.parentRelations(node).length)
32714         return false;
32715       var geometries = osmNodeGeometriesForTags(node.tags);
32716       if (geometries.point)
32717         return false;
32718       if (geometries.vertex)
32719         return true;
32720       return !node.hasInterestingTags();
32721     }
32722     var action = function(graph) {
32723       var way = graph.entity(wayID);
32724       graph.parentRelations(way).forEach(function(parent) {
32725         parent = parent.removeMembersWithID(wayID);
32726         graph = graph.replace(parent);
32727         if (parent.isDegenerate()) {
32728           graph = actionDeleteRelation(parent.id)(graph);
32729         }
32730       });
32731       new Set(way.nodes).forEach(function(nodeID) {
32732         graph = graph.replace(way.removeNode(nodeID));
32733         var node = graph.entity(nodeID);
32734         if (canDeleteNode(node, graph)) {
32735           graph = graph.remove(node);
32736         }
32737       });
32738       return graph.remove(way);
32739     };
32740     return action;
32741   }
32742
32743   // modules/actions/delete_multiple.js
32744   function actionDeleteMultiple(ids) {
32745     var actions = {
32746       way: actionDeleteWay,
32747       node: actionDeleteNode,
32748       relation: actionDeleteRelation
32749     };
32750     var action = function(graph) {
32751       ids.forEach(function(id2) {
32752         if (graph.hasEntity(id2)) {
32753           graph = actions[graph.entity(id2).type](id2)(graph);
32754         }
32755       });
32756       return graph;
32757     };
32758     return action;
32759   }
32760
32761   // modules/actions/delete_relation.js
32762   function actionDeleteRelation(relationID, allowUntaggedMembers) {
32763     function canDeleteEntity(entity, graph) {
32764       return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && (!entity.hasInterestingTags() && !allowUntaggedMembers);
32765     }
32766     var action = function(graph) {
32767       var relation = graph.entity(relationID);
32768       graph.parentRelations(relation).forEach(function(parent) {
32769         parent = parent.removeMembersWithID(relationID);
32770         graph = graph.replace(parent);
32771         if (parent.isDegenerate()) {
32772           graph = actionDeleteRelation(parent.id)(graph);
32773         }
32774       });
32775       var memberIDs = utilArrayUniq(relation.members.map(function(m2) {
32776         return m2.id;
32777       }));
32778       memberIDs.forEach(function(memberID) {
32779         graph = graph.replace(relation.removeMembersWithID(memberID));
32780         var entity = graph.entity(memberID);
32781         if (canDeleteEntity(entity, graph)) {
32782           graph = actionDeleteMultiple([memberID])(graph);
32783         }
32784       });
32785       return graph.remove(relation);
32786     };
32787     return action;
32788   }
32789
32790   // modules/actions/delete_node.js
32791   function actionDeleteNode(nodeId) {
32792     var action = function(graph) {
32793       var node = graph.entity(nodeId);
32794       graph.parentWays(node).forEach(function(parent) {
32795         parent = parent.removeNode(nodeId);
32796         graph = graph.replace(parent);
32797         if (parent.isDegenerate()) {
32798           graph = actionDeleteWay(parent.id)(graph);
32799         }
32800       });
32801       graph.parentRelations(node).forEach(function(parent) {
32802         parent = parent.removeMembersWithID(nodeId);
32803         graph = graph.replace(parent);
32804         if (parent.isDegenerate()) {
32805           graph = actionDeleteRelation(parent.id)(graph);
32806         }
32807       });
32808       return graph.remove(node);
32809     };
32810     return action;
32811   }
32812
32813   // modules/actions/connect.js
32814   function actionConnect(nodeIDs) {
32815     var action = function(graph) {
32816       var survivor;
32817       var node;
32818       var parents;
32819       var i3, j2;
32820       nodeIDs.reverse();
32821       var interestingIDs = [];
32822       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32823         node = graph.entity(nodeIDs[i3]);
32824         if (node.hasInterestingTags()) {
32825           if (!node.isNew()) {
32826             interestingIDs.push(node.id);
32827           }
32828         }
32829       }
32830       survivor = graph.entity(utilOldestID(interestingIDs.length > 0 ? interestingIDs : nodeIDs));
32831       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32832         node = graph.entity(nodeIDs[i3]);
32833         if (node.id === survivor.id)
32834           continue;
32835         parents = graph.parentWays(node);
32836         for (j2 = 0; j2 < parents.length; j2++) {
32837           graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id));
32838         }
32839         parents = graph.parentRelations(node);
32840         for (j2 = 0; j2 < parents.length; j2++) {
32841           graph = graph.replace(parents[j2].replaceMember(node, survivor));
32842         }
32843         survivor = survivor.mergeTags(node.tags);
32844         graph = actionDeleteNode(node.id)(graph);
32845       }
32846       graph = graph.replace(survivor);
32847       parents = graph.parentWays(survivor);
32848       for (i3 = 0; i3 < parents.length; i3++) {
32849         if (parents[i3].isDegenerate()) {
32850           graph = actionDeleteWay(parents[i3].id)(graph);
32851         }
32852       }
32853       return graph;
32854     };
32855     action.disabled = function(graph) {
32856       var seen = {};
32857       var restrictionIDs = [];
32858       var survivor;
32859       var node, way;
32860       var relations, relation, role;
32861       var i3, j2, k2;
32862       survivor = graph.entity(utilOldestID(nodeIDs));
32863       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32864         node = graph.entity(nodeIDs[i3]);
32865         relations = graph.parentRelations(node);
32866         for (j2 = 0; j2 < relations.length; j2++) {
32867           relation = relations[j2];
32868           role = relation.memberById(node.id).role || "";
32869           if (relation.hasFromViaTo()) {
32870             restrictionIDs.push(relation.id);
32871           }
32872           if (seen[relation.id] !== void 0 && seen[relation.id] !== role) {
32873             return "relation";
32874           } else {
32875             seen[relation.id] = role;
32876           }
32877         }
32878       }
32879       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32880         node = graph.entity(nodeIDs[i3]);
32881         var parents = graph.parentWays(node);
32882         for (j2 = 0; j2 < parents.length; j2++) {
32883           var parent = parents[j2];
32884           relations = graph.parentRelations(parent);
32885           for (k2 = 0; k2 < relations.length; k2++) {
32886             relation = relations[k2];
32887             if (relation.hasFromViaTo()) {
32888               restrictionIDs.push(relation.id);
32889             }
32890           }
32891         }
32892       }
32893       restrictionIDs = utilArrayUniq(restrictionIDs);
32894       for (i3 = 0; i3 < restrictionIDs.length; i3++) {
32895         relation = graph.entity(restrictionIDs[i3]);
32896         if (!relation.isComplete(graph))
32897           continue;
32898         var memberWays = relation.members.filter(function(m2) {
32899           return m2.type === "way";
32900         }).map(function(m2) {
32901           return graph.entity(m2.id);
32902         });
32903         memberWays = utilArrayUniq(memberWays);
32904         var f2 = relation.memberByRole("from");
32905         var t2 = relation.memberByRole("to");
32906         var isUturn = f2.id === t2.id;
32907         var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] };
32908         for (j2 = 0; j2 < relation.members.length; j2++) {
32909           collectNodes(relation.members[j2], nodes);
32910         }
32911         nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates));
32912         nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates));
32913         var filter2 = keyNodeFilter(nodes.keyfrom, nodes.keyto);
32914         nodes.from = nodes.from.filter(filter2);
32915         nodes.via = nodes.via.filter(filter2);
32916         nodes.to = nodes.to.filter(filter2);
32917         var connectFrom = false;
32918         var connectVia = false;
32919         var connectTo = false;
32920         var connectKeyFrom = false;
32921         var connectKeyTo = false;
32922         for (j2 = 0; j2 < nodeIDs.length; j2++) {
32923           var n3 = nodeIDs[j2];
32924           if (nodes.from.indexOf(n3) !== -1) {
32925             connectFrom = true;
32926           }
32927           if (nodes.via.indexOf(n3) !== -1) {
32928             connectVia = true;
32929           }
32930           if (nodes.to.indexOf(n3) !== -1) {
32931             connectTo = true;
32932           }
32933           if (nodes.keyfrom.indexOf(n3) !== -1) {
32934             connectKeyFrom = true;
32935           }
32936           if (nodes.keyto.indexOf(n3) !== -1) {
32937             connectKeyTo = true;
32938           }
32939         }
32940         if (connectFrom && connectTo && !isUturn) {
32941           return "restriction";
32942         }
32943         if (connectFrom && connectVia) {
32944           return "restriction";
32945         }
32946         if (connectTo && connectVia) {
32947           return "restriction";
32948         }
32949         if (connectKeyFrom || connectKeyTo) {
32950           if (nodeIDs.length !== 2) {
32951             return "restriction";
32952           }
32953           var n0 = null;
32954           var n1 = null;
32955           for (j2 = 0; j2 < memberWays.length; j2++) {
32956             way = memberWays[j2];
32957             if (way.contains(nodeIDs[0])) {
32958               n0 = nodeIDs[0];
32959             }
32960             if (way.contains(nodeIDs[1])) {
32961               n1 = nodeIDs[1];
32962             }
32963           }
32964           if (n0 && n1) {
32965             var ok = false;
32966             for (j2 = 0; j2 < memberWays.length; j2++) {
32967               way = memberWays[j2];
32968               if (way.areAdjacent(n0, n1)) {
32969                 ok = true;
32970                 break;
32971               }
32972             }
32973             if (!ok) {
32974               return "restriction";
32975             }
32976           }
32977         }
32978         for (j2 = 0; j2 < memberWays.length; j2++) {
32979           way = memberWays[j2].update({});
32980           for (k2 = 0; k2 < nodeIDs.length; k2++) {
32981             if (nodeIDs[k2] === survivor.id)
32982               continue;
32983             if (way.areAdjacent(nodeIDs[k2], survivor.id)) {
32984               way = way.removeNode(nodeIDs[k2]);
32985             } else {
32986               way = way.replaceNode(nodeIDs[k2], survivor.id);
32987             }
32988           }
32989           if (way.isDegenerate()) {
32990             return "restriction";
32991           }
32992         }
32993       }
32994       return false;
32995       function hasDuplicates(n4, i4, arr) {
32996         return arr.indexOf(n4) !== arr.lastIndexOf(n4);
32997       }
32998       function keyNodeFilter(froms, tos) {
32999         return function(n4) {
33000           return froms.indexOf(n4) === -1 && tos.indexOf(n4) === -1;
33001         };
33002       }
33003       function collectNodes(member, collection) {
33004         var entity = graph.hasEntity(member.id);
33005         if (!entity)
33006           return;
33007         var role2 = member.role || "";
33008         if (!collection[role2]) {
33009           collection[role2] = [];
33010         }
33011         if (member.type === "node") {
33012           collection[role2].push(member.id);
33013           if (role2 === "via") {
33014             collection.keyfrom.push(member.id);
33015             collection.keyto.push(member.id);
33016           }
33017         } else if (member.type === "way") {
33018           collection[role2].push.apply(collection[role2], entity.nodes);
33019           if (role2 === "from" || role2 === "via") {
33020             collection.keyfrom.push(entity.first());
33021             collection.keyfrom.push(entity.last());
33022           }
33023           if (role2 === "to" || role2 === "via") {
33024             collection.keyto.push(entity.first());
33025             collection.keyto.push(entity.last());
33026           }
33027         }
33028       }
33029     };
33030     return action;
33031   }
33032
33033   // modules/actions/copy_entities.js
33034   function actionCopyEntities(ids, fromGraph) {
33035     var _copies = {};
33036     var action = function(graph) {
33037       ids.forEach(function(id3) {
33038         fromGraph.entity(id3).copy(fromGraph, _copies);
33039       });
33040       for (var id2 in _copies) {
33041         graph = graph.replace(_copies[id2]);
33042       }
33043       return graph;
33044     };
33045     action.copies = function() {
33046       return _copies;
33047     };
33048     return action;
33049   }
33050
33051   // modules/actions/delete_member.js
33052   function actionDeleteMember(relationId, memberIndex) {
33053     return function(graph) {
33054       var relation = graph.entity(relationId).removeMember(memberIndex);
33055       graph = graph.replace(relation);
33056       if (relation.isDegenerate()) {
33057         graph = actionDeleteRelation(relation.id)(graph);
33058       }
33059       return graph;
33060     };
33061   }
33062
33063   // modules/actions/discard_tags.js
33064   function actionDiscardTags(difference2, discardTags) {
33065     discardTags = discardTags || {};
33066     return (graph) => {
33067       difference2.modified().forEach(checkTags);
33068       difference2.created().forEach(checkTags);
33069       return graph;
33070       function checkTags(entity) {
33071         const keys2 = Object.keys(entity.tags);
33072         let didDiscard = false;
33073         let tags = {};
33074         for (let i3 = 0; i3 < keys2.length; i3++) {
33075           const k2 = keys2[i3];
33076           if (discardTags[k2] || !entity.tags[k2]) {
33077             didDiscard = true;
33078           } else {
33079             tags[k2] = entity.tags[k2];
33080           }
33081         }
33082         if (didDiscard) {
33083           graph = graph.replace(entity.update({ tags }));
33084         }
33085       }
33086     };
33087   }
33088
33089   // modules/actions/disconnect.js
33090   function actionDisconnect(nodeId, newNodeId) {
33091     var wayIds;
33092     var disconnectableRelationTypes = {
33093       "associatedStreet": true,
33094       "enforcement": true,
33095       "site": true
33096     };
33097     var action = function(graph) {
33098       var node = graph.entity(nodeId);
33099       var connections = action.connections(graph);
33100       connections.forEach(function(connection) {
33101         var way = graph.entity(connection.wayID);
33102         var newNode = osmNode({ id: newNodeId, loc: node.loc, tags: node.tags });
33103         graph = graph.replace(newNode);
33104         if (connection.index === 0 && way.isArea()) {
33105           graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
33106         } else if (way.isClosed() && connection.index === way.nodes.length - 1) {
33107           graph = graph.replace(way.unclose().addNode(newNode.id));
33108         } else {
33109           graph = graph.replace(way.updateNode(newNode.id, connection.index));
33110         }
33111       });
33112       return graph;
33113     };
33114     action.connections = function(graph) {
33115       var candidates = [];
33116       var keeping = false;
33117       var parentWays = graph.parentWays(graph.entity(nodeId));
33118       var way, waynode;
33119       for (var i3 = 0; i3 < parentWays.length; i3++) {
33120         way = parentWays[i3];
33121         if (wayIds && wayIds.indexOf(way.id) === -1) {
33122           keeping = true;
33123           continue;
33124         }
33125         if (way.isArea() && way.nodes[0] === nodeId) {
33126           candidates.push({ wayID: way.id, index: 0 });
33127         } else {
33128           for (var j2 = 0; j2 < way.nodes.length; j2++) {
33129             waynode = way.nodes[j2];
33130             if (waynode === nodeId) {
33131               if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) {
33132                 continue;
33133               }
33134               candidates.push({ wayID: way.id, index: j2 });
33135             }
33136           }
33137         }
33138       }
33139       return keeping ? candidates : candidates.slice(1);
33140     };
33141     action.disabled = function(graph) {
33142       var connections = action.connections(graph);
33143       if (connections.length === 0)
33144         return "not_connected";
33145       var parentWays = graph.parentWays(graph.entity(nodeId));
33146       var seenRelationIds = {};
33147       var sharedRelation;
33148       parentWays.forEach(function(way) {
33149         var relations = graph.parentRelations(way);
33150         relations.filter((relation) => !disconnectableRelationTypes[relation.tags.type]).forEach(function(relation) {
33151           if (relation.id in seenRelationIds) {
33152             if (wayIds) {
33153               if (wayIds.indexOf(way.id) !== -1 || wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
33154                 sharedRelation = relation;
33155               }
33156             } else {
33157               sharedRelation = relation;
33158             }
33159           } else {
33160             seenRelationIds[relation.id] = way.id;
33161           }
33162         });
33163       });
33164       if (sharedRelation)
33165         return "relation";
33166     };
33167     action.limitWays = function(val) {
33168       if (!arguments.length)
33169         return wayIds;
33170       wayIds = val;
33171       return action;
33172     };
33173     return action;
33174   }
33175
33176   // modules/actions/extract.js
33177   function actionExtract(entityID, projection2) {
33178     var extractedNodeID;
33179     var action = function(graph) {
33180       var entity = graph.entity(entityID);
33181       if (entity.type === "node") {
33182         return extractFromNode(entity, graph);
33183       }
33184       return extractFromWayOrRelation(entity, graph);
33185     };
33186     function extractFromNode(node, graph) {
33187       extractedNodeID = node.id;
33188       var replacement = osmNode({ loc: node.loc });
33189       graph = graph.replace(replacement);
33190       graph = graph.parentWays(node).reduce(function(accGraph, parentWay) {
33191         return accGraph.replace(parentWay.replaceNode(entityID, replacement.id));
33192       }, graph);
33193       return graph.parentRelations(node).reduce(function(accGraph, parentRel) {
33194         return accGraph.replace(parentRel.replaceMember(node, replacement));
33195       }, graph);
33196     }
33197     function extractFromWayOrRelation(entity, graph) {
33198       var fromGeometry = entity.geometry(graph);
33199       var keysToCopyAndRetain = ["source", "wheelchair"];
33200       var keysToRetain = ["area"];
33201       var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"];
33202       var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph));
33203       extractedLoc = extractedLoc && projection2.invert(extractedLoc);
33204       if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
33205         extractedLoc = entity.extent(graph).center();
33206       }
33207       var indoorAreaValues = {
33208         area: true,
33209         corridor: true,
33210         elevator: true,
33211         level: true,
33212         room: true
33213       };
33214       var isBuilding = entity.tags.building && entity.tags.building !== "no" || entity.tags["building:part"] && entity.tags["building:part"] !== "no";
33215       var isIndoorArea = fromGeometry === "area" && entity.tags.indoor && indoorAreaValues[entity.tags.indoor];
33216       var entityTags = Object.assign({}, entity.tags);
33217       var pointTags = {};
33218       for (var key in entityTags) {
33219         if (entity.type === "relation" && key === "type") {
33220           continue;
33221         }
33222         if (keysToRetain.indexOf(key) !== -1) {
33223           continue;
33224         }
33225         if (isBuilding) {
33226           if (buildingKeysToRetain.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
33227             continue;
33228         }
33229         if (isIndoorArea && key === "indoor") {
33230           continue;
33231         }
33232         pointTags[key] = entityTags[key];
33233         if (keysToCopyAndRetain.indexOf(key) !== -1 || key.match(/^addr:.{1,}/)) {
33234           continue;
33235         } else if (isIndoorArea && key === "level") {
33236           continue;
33237         }
33238         delete entityTags[key];
33239       }
33240       if (!isBuilding && !isIndoorArea && fromGeometry === "area") {
33241         entityTags.area = "yes";
33242       }
33243       var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
33244       graph = graph.replace(replacement);
33245       extractedNodeID = replacement.id;
33246       return graph.replace(entity.update({ tags: entityTags }));
33247     }
33248     action.getExtractedNodeID = function() {
33249       return extractedNodeID;
33250     };
33251     return action;
33252   }
33253
33254   // modules/actions/join.js
33255   function actionJoin(ids) {
33256     function groupEntitiesByGeometry(graph) {
33257       var entities = ids.map(function(id2) {
33258         return graph.entity(id2);
33259       });
33260       return Object.assign(
33261         { line: [] },
33262         utilArrayGroupBy(entities, function(entity) {
33263           return entity.geometry(graph);
33264         })
33265       );
33266     }
33267     var action = function(graph) {
33268       var ways = ids.map(graph.entity, graph);
33269       var survivorID = utilOldestID(ways.map((way) => way.id));
33270       ways.sort(function(a2, b2) {
33271         var aSided = a2.isSided();
33272         var bSided = b2.isSided();
33273         return aSided && !bSided ? -1 : bSided && !aSided ? 1 : 0;
33274       });
33275       var sequences = osmJoinWays(ways, graph);
33276       var joined = sequences[0];
33277       graph = sequences.actions.reduce(function(g3, action2) {
33278         return action2(g3);
33279       }, graph);
33280       var survivor = graph.entity(survivorID);
33281       survivor = survivor.update({ nodes: joined.nodes.map(function(n3) {
33282         return n3.id;
33283       }) });
33284       graph = graph.replace(survivor);
33285       joined.forEach(function(way) {
33286         if (way.id === survivorID)
33287           return;
33288         graph.parentRelations(way).forEach(function(parent) {
33289           graph = graph.replace(parent.replaceMember(way, survivor));
33290         });
33291         survivor = survivor.mergeTags(way.tags);
33292         graph = graph.replace(survivor);
33293         graph = actionDeleteWay(way.id)(graph);
33294       });
33295       function checkForSimpleMultipolygon() {
33296         if (!survivor.isClosed())
33297           return;
33298         var multipolygons = graph.parentMultipolygons(survivor).filter(function(multipolygon2) {
33299           return multipolygon2.members.length === 1;
33300         });
33301         if (multipolygons.length !== 1)
33302           return;
33303         var multipolygon = multipolygons[0];
33304         for (var key in survivor.tags) {
33305           if (multipolygon.tags[key] && // don't collapse if tags cannot be cleanly merged
33306           multipolygon.tags[key] !== survivor.tags[key])
33307             return;
33308         }
33309         survivor = survivor.mergeTags(multipolygon.tags);
33310         graph = graph.replace(survivor);
33311         graph = actionDeleteRelation(
33312           multipolygon.id,
33313           true
33314           /* allow untagged members */
33315         )(graph);
33316         var tags = Object.assign({}, survivor.tags);
33317         if (survivor.geometry(graph) !== "area") {
33318           tags.area = "yes";
33319         }
33320         delete tags.type;
33321         survivor = survivor.update({ tags });
33322         graph = graph.replace(survivor);
33323       }
33324       checkForSimpleMultipolygon();
33325       return graph;
33326     };
33327     action.resultingWayNodesLength = function(graph) {
33328       return ids.reduce(function(count, id2) {
33329         return count + graph.entity(id2).nodes.length;
33330       }, 0) - ids.length - 1;
33331     };
33332     action.disabled = function(graph) {
33333       var geometries = groupEntitiesByGeometry(graph);
33334       if (ids.length < 2 || ids.length !== geometries.line.length) {
33335         return "not_eligible";
33336       }
33337       var joined = osmJoinWays(ids.map(graph.entity, graph), graph);
33338       if (joined.length > 1) {
33339         return "not_adjacent";
33340       }
33341       var i3;
33342       var sortedParentRelations = function(id2) {
33343         return graph.parentRelations(graph.entity(id2)).filter((rel) => !rel.isRestriction() && !rel.isConnectivity()).sort((a2, b2) => a2.id - b2.id);
33344       };
33345       var relsA = sortedParentRelations(ids[0]);
33346       for (i3 = 1; i3 < ids.length; i3++) {
33347         var relsB = sortedParentRelations(ids[i3]);
33348         if (!utilArrayIdentical(relsA, relsB)) {
33349           return "conflicting_relations";
33350         }
33351       }
33352       for (i3 = 0; i3 < ids.length - 1; i3++) {
33353         for (var j2 = i3 + 1; j2 < ids.length; j2++) {
33354           var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) {
33355             return e3.loc;
33356           });
33357           var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) {
33358             return e3.loc;
33359           });
33360           var intersections = geoPathIntersections(path1, path2);
33361           var common = utilArrayIntersection(
33362             joined[0].nodes.map(function(n3) {
33363               return n3.loc.toString();
33364             }),
33365             intersections.map(function(n3) {
33366               return n3.toString();
33367             })
33368           );
33369           if (common.length !== intersections.length) {
33370             return "paths_intersect";
33371           }
33372         }
33373       }
33374       var nodeIds = joined[0].nodes.map(function(n3) {
33375         return n3.id;
33376       }).slice(1, -1);
33377       var relation;
33378       var tags = {};
33379       var conflicting = false;
33380       joined[0].forEach(function(way) {
33381         var parents = graph.parentRelations(way);
33382         parents.forEach(function(parent) {
33383           if ((parent.isRestriction() || parent.isConnectivity()) && parent.members.some(function(m2) {
33384             return nodeIds.indexOf(m2.id) >= 0;
33385           })) {
33386             relation = parent;
33387           }
33388         });
33389         for (var k2 in way.tags) {
33390           if (!(k2 in tags)) {
33391             tags[k2] = way.tags[k2];
33392           } else if (tags[k2] && osmIsInterestingTag(k2) && tags[k2] !== way.tags[k2]) {
33393             conflicting = true;
33394           }
33395         }
33396       });
33397       if (relation) {
33398         return relation.isRestriction() ? "restriction" : "connectivity";
33399       }
33400       if (conflicting) {
33401         return "conflicting_tags";
33402       }
33403     };
33404     return action;
33405   }
33406
33407   // modules/actions/merge.js
33408   function actionMerge(ids) {
33409     function groupEntitiesByGeometry(graph) {
33410       var entities = ids.map(function(id2) {
33411         return graph.entity(id2);
33412       });
33413       return Object.assign(
33414         { point: [], area: [], line: [], relation: [] },
33415         utilArrayGroupBy(entities, function(entity) {
33416           return entity.geometry(graph);
33417         })
33418       );
33419     }
33420     var action = function(graph) {
33421       var geometries = groupEntitiesByGeometry(graph);
33422       var target = geometries.area[0] || geometries.line[0];
33423       var points = geometries.point;
33424       points.forEach(function(point2) {
33425         target = target.mergeTags(point2.tags);
33426         graph = graph.replace(target);
33427         graph.parentRelations(point2).forEach(function(parent) {
33428           graph = graph.replace(parent.replaceMember(point2, target));
33429         });
33430         var nodes = utilArrayUniq(graph.childNodes(target));
33431         var removeNode = point2;
33432         if (!point2.isNew()) {
33433           var inserted = false;
33434           var canBeReplaced = function(node2) {
33435             return !(graph.parentWays(node2).length > 1 || graph.parentRelations(node2).length);
33436           };
33437           var replaceNode = function(node2) {
33438             graph = graph.replace(point2.update({ tags: node2.tags, loc: node2.loc }));
33439             target = target.replaceNode(node2.id, point2.id);
33440             graph = graph.replace(target);
33441             removeNode = node2;
33442             inserted = true;
33443           };
33444           var i3;
33445           var node;
33446           for (i3 = 0; i3 < nodes.length; i3++) {
33447             node = nodes[i3];
33448             if (canBeReplaced(node) && node.isNew()) {
33449               replaceNode(node);
33450               break;
33451             }
33452           }
33453           if (!inserted && point2.hasInterestingTags()) {
33454             for (i3 = 0; i3 < nodes.length; i3++) {
33455               node = nodes[i3];
33456               if (canBeReplaced(node) && !node.hasInterestingTags()) {
33457                 replaceNode(node);
33458                 break;
33459               }
33460             }
33461             if (!inserted) {
33462               for (i3 = 0; i3 < nodes.length; i3++) {
33463                 node = nodes[i3];
33464                 if (canBeReplaced(node) && utilCompareIDs(point2.id, node.id) < 0) {
33465                   replaceNode(node);
33466                   break;
33467                 }
33468               }
33469             }
33470           }
33471         }
33472         graph = graph.remove(removeNode);
33473       });
33474       if (target.tags.area === "yes") {
33475         var tags = Object.assign({}, target.tags);
33476         delete tags.area;
33477         if (osmTagSuggestingArea(tags)) {
33478           target = target.update({ tags });
33479           graph = graph.replace(target);
33480         }
33481       }
33482       return graph;
33483     };
33484     action.disabled = function(graph) {
33485       var geometries = groupEntitiesByGeometry(graph);
33486       if (geometries.point.length === 0 || geometries.area.length + geometries.line.length !== 1 || geometries.relation.length !== 0) {
33487         return "not_eligible";
33488       }
33489     };
33490     return action;
33491   }
33492
33493   // modules/actions/merge_nodes.js
33494   function actionMergeNodes(nodeIDs, loc) {
33495     function chooseLoc(graph) {
33496       if (!nodeIDs.length)
33497         return null;
33498       var sum = [0, 0];
33499       var interestingCount = 0;
33500       var interestingLoc;
33501       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33502         var node = graph.entity(nodeIDs[i3]);
33503         if (node.hasInterestingTags()) {
33504           interestingLoc = ++interestingCount === 1 ? node.loc : null;
33505         }
33506         sum = geoVecAdd(sum, node.loc);
33507       }
33508       return interestingLoc || geoVecScale(sum, 1 / nodeIDs.length);
33509     }
33510     var action = function(graph) {
33511       if (nodeIDs.length < 2)
33512         return graph;
33513       var toLoc = loc;
33514       if (!toLoc) {
33515         toLoc = chooseLoc(graph);
33516       }
33517       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33518         var node = graph.entity(nodeIDs[i3]);
33519         if (node.loc !== toLoc) {
33520           graph = graph.replace(node.move(toLoc));
33521         }
33522       }
33523       return actionConnect(nodeIDs)(graph);
33524     };
33525     action.disabled = function(graph) {
33526       if (nodeIDs.length < 2)
33527         return "not_eligible";
33528       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33529         var entity = graph.entity(nodeIDs[i3]);
33530         if (entity.type !== "node")
33531           return "not_eligible";
33532       }
33533       return actionConnect(nodeIDs).disabled(graph);
33534     };
33535     return action;
33536   }
33537
33538   // modules/osm/changeset.js
33539   function osmChangeset() {
33540     if (!(this instanceof osmChangeset)) {
33541       return new osmChangeset().initialize(arguments);
33542     } else if (arguments.length) {
33543       this.initialize(arguments);
33544     }
33545   }
33546   osmEntity.changeset = osmChangeset;
33547   osmChangeset.prototype = Object.create(osmEntity.prototype);
33548   Object.assign(osmChangeset.prototype, {
33549     type: "changeset",
33550     extent: function() {
33551       return new geoExtent();
33552     },
33553     geometry: function() {
33554       return "changeset";
33555     },
33556     asJXON: function() {
33557       return {
33558         osm: {
33559           changeset: {
33560             tag: Object.keys(this.tags).map(function(k2) {
33561               return { "@k": k2, "@v": this.tags[k2] };
33562             }, this),
33563             "@version": 0.6,
33564             "@generator": "iD"
33565           }
33566         }
33567       };
33568     },
33569     // Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
33570     // XML. Returns a string.
33571     osmChangeJXON: function(changes) {
33572       var changeset_id = this.id;
33573       function nest(x2, order) {
33574         var groups = {};
33575         for (var i3 = 0; i3 < x2.length; i3++) {
33576           var tagName = Object.keys(x2[i3])[0];
33577           if (!groups[tagName])
33578             groups[tagName] = [];
33579           groups[tagName].push(x2[i3][tagName]);
33580         }
33581         var ordered = {};
33582         order.forEach(function(o2) {
33583           if (groups[o2])
33584             ordered[o2] = groups[o2];
33585         });
33586         return ordered;
33587       }
33588       function sort(changes2) {
33589         function resolve(item) {
33590           return relations.find(function(relation2) {
33591             return item.keyAttributes.type === "relation" && item.keyAttributes.ref === relation2["@id"];
33592           });
33593         }
33594         function isNew(item) {
33595           return !sorted[item["@id"]] && !processing.find(function(proc) {
33596             return proc["@id"] === item["@id"];
33597           });
33598         }
33599         var processing = [];
33600         var sorted = {};
33601         var relations = changes2.relation;
33602         if (!relations)
33603           return changes2;
33604         for (var i3 = 0; i3 < relations.length; i3++) {
33605           var relation = relations[i3];
33606           if (!sorted[relation["@id"]]) {
33607             processing.push(relation);
33608           }
33609           while (processing.length > 0) {
33610             var next = processing[0], deps = next.member.map(resolve).filter(Boolean).filter(isNew);
33611             if (deps.length === 0) {
33612               sorted[next["@id"]] = next;
33613               processing.shift();
33614             } else {
33615               processing = deps.concat(processing);
33616             }
33617           }
33618         }
33619         changes2.relation = Object.values(sorted);
33620         return changes2;
33621       }
33622       function rep(entity) {
33623         return entity.asJXON(changeset_id);
33624       }
33625       return {
33626         osmChange: {
33627           "@version": 0.6,
33628           "@generator": "iD",
33629           "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])),
33630           "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]),
33631           "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true })
33632         }
33633       };
33634     },
33635     asGeoJSON: function() {
33636       return {};
33637     }
33638   });
33639
33640   // modules/osm/note.js
33641   function osmNote() {
33642     if (!(this instanceof osmNote)) {
33643       return new osmNote().initialize(arguments);
33644     } else if (arguments.length) {
33645       this.initialize(arguments);
33646     }
33647   }
33648   osmNote.id = function() {
33649     return osmNote.id.next--;
33650   };
33651   osmNote.id.next = -1;
33652   Object.assign(osmNote.prototype, {
33653     type: "note",
33654     initialize: function(sources) {
33655       for (var i3 = 0; i3 < sources.length; ++i3) {
33656         var source = sources[i3];
33657         for (var prop in source) {
33658           if (Object.prototype.hasOwnProperty.call(source, prop)) {
33659             if (source[prop] === void 0) {
33660               delete this[prop];
33661             } else {
33662               this[prop] = source[prop];
33663             }
33664           }
33665         }
33666       }
33667       if (!this.id) {
33668         this.id = osmNote.id().toString();
33669       }
33670       return this;
33671     },
33672     extent: function() {
33673       return new geoExtent(this.loc);
33674     },
33675     update: function(attrs) {
33676       return osmNote(this, attrs);
33677     },
33678     isNew: function() {
33679       return this.id < 0;
33680     },
33681     move: function(loc) {
33682       return this.update({ loc });
33683     }
33684   });
33685
33686   // modules/osm/relation.js
33687   function osmRelation() {
33688     if (!(this instanceof osmRelation)) {
33689       return new osmRelation().initialize(arguments);
33690     } else if (arguments.length) {
33691       this.initialize(arguments);
33692     }
33693   }
33694   osmEntity.relation = osmRelation;
33695   osmRelation.prototype = Object.create(osmEntity.prototype);
33696   osmRelation.creationOrder = function(a2, b2) {
33697     var aId = parseInt(osmEntity.id.toOSM(a2.id), 10);
33698     var bId = parseInt(osmEntity.id.toOSM(b2.id), 10);
33699     if (aId < 0 || bId < 0)
33700       return aId - bId;
33701     return bId - aId;
33702   };
33703   Object.assign(osmRelation.prototype, {
33704     type: "relation",
33705     members: [],
33706     copy: function(resolver, copies) {
33707       if (copies[this.id])
33708         return copies[this.id];
33709       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
33710       var members = this.members.map(function(member) {
33711         return Object.assign({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
33712       });
33713       copy2 = copy2.update({ members });
33714       copies[this.id] = copy2;
33715       return copy2;
33716     },
33717     extent: function(resolver, memo) {
33718       return resolver.transient(this, "extent", function() {
33719         if (memo && memo[this.id])
33720           return geoExtent();
33721         memo = memo || {};
33722         memo[this.id] = true;
33723         var extent = geoExtent();
33724         for (var i3 = 0; i3 < this.members.length; i3++) {
33725           var member = resolver.hasEntity(this.members[i3].id);
33726           if (member) {
33727             extent._extend(member.extent(resolver, memo));
33728           }
33729         }
33730         return extent;
33731       });
33732     },
33733     geometry: function(graph) {
33734       return graph.transient(this, "geometry", function() {
33735         return this.isMultipolygon() ? "area" : "relation";
33736       });
33737     },
33738     isDegenerate: function() {
33739       return this.members.length === 0;
33740     },
33741     // Return an array of members, each extended with an 'index' property whose value
33742     // is the member index.
33743     indexedMembers: function() {
33744       var result = new Array(this.members.length);
33745       for (var i3 = 0; i3 < this.members.length; i3++) {
33746         result[i3] = Object.assign({}, this.members[i3], { index: i3 });
33747       }
33748       return result;
33749     },
33750     // Return the first member with the given role. A copy of the member object
33751     // is returned, extended with an 'index' property whose value is the member index.
33752     memberByRole: function(role) {
33753       for (var i3 = 0; i3 < this.members.length; i3++) {
33754         if (this.members[i3].role === role) {
33755           return Object.assign({}, this.members[i3], { index: i3 });
33756         }
33757       }
33758     },
33759     // Same as memberByRole, but returns all members with the given role
33760     membersByRole: function(role) {
33761       var result = [];
33762       for (var i3 = 0; i3 < this.members.length; i3++) {
33763         if (this.members[i3].role === role) {
33764           result.push(Object.assign({}, this.members[i3], { index: i3 }));
33765         }
33766       }
33767       return result;
33768     },
33769     // Return the first member with the given id. A copy of the member object
33770     // is returned, extended with an 'index' property whose value is the member index.
33771     memberById: function(id2) {
33772       for (var i3 = 0; i3 < this.members.length; i3++) {
33773         if (this.members[i3].id === id2) {
33774           return Object.assign({}, this.members[i3], { index: i3 });
33775         }
33776       }
33777     },
33778     // Return the first member with the given id and role. A copy of the member object
33779     // is returned, extended with an 'index' property whose value is the member index.
33780     memberByIdAndRole: function(id2, role) {
33781       for (var i3 = 0; i3 < this.members.length; i3++) {
33782         if (this.members[i3].id === id2 && this.members[i3].role === role) {
33783           return Object.assign({}, this.members[i3], { index: i3 });
33784         }
33785       }
33786     },
33787     addMember: function(member, index) {
33788       var members = this.members.slice();
33789       members.splice(index === void 0 ? members.length : index, 0, member);
33790       return this.update({ members });
33791     },
33792     updateMember: function(member, index) {
33793       var members = this.members.slice();
33794       members.splice(index, 1, Object.assign({}, members[index], member));
33795       return this.update({ members });
33796     },
33797     removeMember: function(index) {
33798       var members = this.members.slice();
33799       members.splice(index, 1);
33800       return this.update({ members });
33801     },
33802     removeMembersWithID: function(id2) {
33803       var members = this.members.filter(function(m2) {
33804         return m2.id !== id2;
33805       });
33806       return this.update({ members });
33807     },
33808     moveMember: function(fromIndex, toIndex) {
33809       var members = this.members.slice();
33810       members.splice(toIndex, 0, members.splice(fromIndex, 1)[0]);
33811       return this.update({ members });
33812     },
33813     // Wherever a member appears with id `needle.id`, replace it with a member
33814     // with id `replacement.id`, type `replacement.type`, and the original role,
33815     // By default, adding a duplicate member (by id and role) is prevented.
33816     // Return an updated relation.
33817     replaceMember: function(needle, replacement, keepDuplicates) {
33818       if (!this.memberById(needle.id))
33819         return this;
33820       var members = [];
33821       for (var i3 = 0; i3 < this.members.length; i3++) {
33822         var member = this.members[i3];
33823         if (member.id !== needle.id) {
33824           members.push(member);
33825         } else if (keepDuplicates || !this.memberByIdAndRole(replacement.id, member.role)) {
33826           members.push({ id: replacement.id, type: replacement.type, role: member.role });
33827         }
33828       }
33829       return this.update({ members });
33830     },
33831     asJXON: function(changeset_id) {
33832       var r2 = {
33833         relation: {
33834           "@id": this.osmId(),
33835           "@version": this.version || 0,
33836           member: this.members.map(function(member) {
33837             return {
33838               keyAttributes: {
33839                 type: member.type,
33840                 role: member.role,
33841                 ref: osmEntity.id.toOSM(member.id)
33842               }
33843             };
33844           }, this),
33845           tag: Object.keys(this.tags).map(function(k2) {
33846             return { keyAttributes: { k: k2, v: this.tags[k2] } };
33847           }, this)
33848         }
33849       };
33850       if (changeset_id) {
33851         r2.relation["@changeset"] = changeset_id;
33852       }
33853       return r2;
33854     },
33855     asGeoJSON: function(resolver) {
33856       return resolver.transient(this, "GeoJSON", function() {
33857         if (this.isMultipolygon()) {
33858           return {
33859             type: "MultiPolygon",
33860             coordinates: this.multipolygon(resolver)
33861           };
33862         } else {
33863           return {
33864             type: "FeatureCollection",
33865             properties: this.tags,
33866             features: this.members.map(function(member) {
33867               return Object.assign({ role: member.role }, resolver.entity(member.id).asGeoJSON(resolver));
33868             })
33869           };
33870         }
33871       });
33872     },
33873     area: function(resolver) {
33874       return resolver.transient(this, "area", function() {
33875         return area_default(this.asGeoJSON(resolver));
33876       });
33877     },
33878     isMultipolygon: function() {
33879       return this.tags.type === "multipolygon";
33880     },
33881     isComplete: function(resolver) {
33882       for (var i3 = 0; i3 < this.members.length; i3++) {
33883         if (!resolver.hasEntity(this.members[i3].id)) {
33884           return false;
33885         }
33886       }
33887       return true;
33888     },
33889     hasFromViaTo: function() {
33890       return this.members.some(function(m2) {
33891         return m2.role === "from";
33892       }) && this.members.some(function(m2) {
33893         return m2.role === "via";
33894       }) && this.members.some(function(m2) {
33895         return m2.role === "to";
33896       });
33897     },
33898     isRestriction: function() {
33899       return !!(this.tags.type && this.tags.type.match(/^restriction:?/));
33900     },
33901     isValidRestriction: function() {
33902       if (!this.isRestriction())
33903         return false;
33904       var froms = this.members.filter(function(m2) {
33905         return m2.role === "from";
33906       });
33907       var vias = this.members.filter(function(m2) {
33908         return m2.role === "via";
33909       });
33910       var tos = this.members.filter(function(m2) {
33911         return m2.role === "to";
33912       });
33913       if (froms.length !== 1 && this.tags.restriction !== "no_entry")
33914         return false;
33915       if (froms.some(function(m2) {
33916         return m2.type !== "way";
33917       }))
33918         return false;
33919       if (tos.length !== 1 && this.tags.restriction !== "no_exit")
33920         return false;
33921       if (tos.some(function(m2) {
33922         return m2.type !== "way";
33923       }))
33924         return false;
33925       if (vias.length === 0)
33926         return false;
33927       if (vias.length > 1 && vias.some(function(m2) {
33928         return m2.type !== "way";
33929       }))
33930         return false;
33931       return true;
33932     },
33933     isConnectivity: function() {
33934       return !!(this.tags.type && this.tags.type.match(/^connectivity:?/));
33935     },
33936     // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm],
33937     // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings.
33938     //
33939     // This corresponds to the structure needed for rendering a multipolygon path using a
33940     // `evenodd` fill rule, as well as the structure of a GeoJSON MultiPolygon geometry.
33941     //
33942     // In the case of invalid geometries, this function will still return a result which
33943     // includes the nodes of all way members, but some Nds may be unclosed and some inner
33944     // rings not matched with the intended outer ring.
33945     //
33946     multipolygon: function(resolver) {
33947       var outers = this.members.filter(function(m2) {
33948         return "outer" === (m2.role || "outer");
33949       });
33950       var inners = this.members.filter(function(m2) {
33951         return "inner" === m2.role;
33952       });
33953       outers = osmJoinWays(outers, resolver);
33954       inners = osmJoinWays(inners, resolver);
33955       var sequenceToLineString = function(sequence) {
33956         if (sequence.nodes.length > 2 && sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
33957           sequence.nodes.push(sequence.nodes[0]);
33958         }
33959         return sequence.nodes.map(function(node) {
33960           return node.loc;
33961         });
33962       };
33963       outers = outers.map(sequenceToLineString);
33964       inners = inners.map(sequenceToLineString);
33965       var result = outers.map(function(o3) {
33966         return [area_default({ type: "Polygon", coordinates: [o3] }) > 2 * Math.PI ? o3.reverse() : o3];
33967       });
33968       function findOuter(inner2) {
33969         var o3, outer;
33970         for (o3 = 0; o3 < outers.length; o3++) {
33971           outer = outers[o3];
33972           if (geoPolygonContainsPolygon(outer, inner2)) {
33973             return o3;
33974           }
33975         }
33976         for (o3 = 0; o3 < outers.length; o3++) {
33977           outer = outers[o3];
33978           if (geoPolygonIntersectsPolygon(outer, inner2, false)) {
33979             return o3;
33980           }
33981         }
33982       }
33983       for (var i3 = 0; i3 < inners.length; i3++) {
33984         var inner = inners[i3];
33985         if (area_default({ type: "Polygon", coordinates: [inner] }) < 2 * Math.PI) {
33986           inner = inner.reverse();
33987         }
33988         var o2 = findOuter(inners[i3]);
33989         if (o2 !== void 0) {
33990           result[o2].push(inners[i3]);
33991         } else {
33992           result.push([inners[i3]]);
33993         }
33994       }
33995       return result;
33996     }
33997   });
33998
33999   // modules/osm/qa_item.js
34000   var QAItem = class _QAItem {
34001     constructor(loc, service, itemType, id2, props) {
34002       this.loc = loc;
34003       this.service = service.title;
34004       this.itemType = itemType;
34005       this.id = id2 ? id2 : "".concat(_QAItem.id());
34006       this.update(props);
34007       if (service && typeof service.getIcon === "function") {
34008         this.icon = service.getIcon(itemType);
34009       }
34010     }
34011     update(props) {
34012       const { loc, service, itemType, id: id2 } = this;
34013       Object.keys(props).forEach((prop) => this[prop] = props[prop]);
34014       this.loc = loc;
34015       this.service = service;
34016       this.itemType = itemType;
34017       this.id = id2;
34018       return this;
34019     }
34020     // Generic handling for newly created QAItems
34021     static id() {
34022       return this.nextId--;
34023     }
34024   };
34025   QAItem.nextId = -1;
34026
34027   // modules/actions/split.js
34028   function actionSplit(nodeIds, newWayIds) {
34029     if (typeof nodeIds === "string")
34030       nodeIds = [nodeIds];
34031     var _wayIDs;
34032     var _keepHistoryOn = "longest";
34033     const circularJunctions = ["roundabout", "circular"];
34034     var _createdWayIDs = [];
34035     function dist(graph, nA, nB) {
34036       var locA = graph.entity(nA).loc;
34037       var locB = graph.entity(nB).loc;
34038       var epsilon3 = 1e-6;
34039       return locA && locB ? geoSphericalDistance(locA, locB) : epsilon3;
34040     }
34041     function splitArea(nodes, idxA, graph) {
34042       var lengths = new Array(nodes.length);
34043       var length2;
34044       var i3;
34045       var best = 0;
34046       var idxB;
34047       function wrap2(index) {
34048         return utilWrap(index, nodes.length);
34049       }
34050       length2 = 0;
34051       for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) {
34052         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]);
34053         lengths[i3] = length2;
34054       }
34055       length2 = 0;
34056       for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) {
34057         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]);
34058         if (length2 < lengths[i3]) {
34059           lengths[i3] = length2;
34060         }
34061       }
34062       for (i3 = 0; i3 < nodes.length; i3++) {
34063         var cost = lengths[i3] / dist(graph, nodes[idxA], nodes[i3]);
34064         if (cost > best) {
34065           idxB = i3;
34066           best = cost;
34067         }
34068       }
34069       return idxB;
34070     }
34071     function totalLengthBetweenNodes(graph, nodes) {
34072       var totalLength = 0;
34073       for (var i3 = 0; i3 < nodes.length - 1; i3++) {
34074         totalLength += dist(graph, nodes[i3], nodes[i3 + 1]);
34075       }
34076       return totalLength;
34077     }
34078     function split(graph, nodeId, wayA, newWayId) {
34079       var wayB = osmWay({ id: newWayId, tags: wayA.tags });
34080       var nodesA;
34081       var nodesB;
34082       var isArea = wayA.isArea();
34083       if (wayA.isClosed()) {
34084         var nodes = wayA.nodes.slice(0, -1);
34085         var idxA = nodes.indexOf(nodeId);
34086         var idxB = splitArea(nodes, idxA, graph);
34087         if (idxB < idxA) {
34088           nodesA = nodes.slice(idxA).concat(nodes.slice(0, idxB + 1));
34089           nodesB = nodes.slice(idxB, idxA + 1);
34090         } else {
34091           nodesA = nodes.slice(idxA, idxB + 1);
34092           nodesB = nodes.slice(idxB).concat(nodes.slice(0, idxA + 1));
34093         }
34094       } else {
34095         var idx = wayA.nodes.indexOf(nodeId, 1);
34096         nodesA = wayA.nodes.slice(0, idx + 1);
34097         nodesB = wayA.nodes.slice(idx);
34098       }
34099       var lengthA = totalLengthBetweenNodes(graph, nodesA);
34100       var lengthB = totalLengthBetweenNodes(graph, nodesB);
34101       if (_keepHistoryOn === "longest" && lengthB > lengthA) {
34102         wayA = wayA.update({ nodes: nodesB });
34103         wayB = wayB.update({ nodes: nodesA });
34104         var temp = lengthA;
34105         lengthA = lengthB;
34106         lengthB = temp;
34107       } else {
34108         wayA = wayA.update({ nodes: nodesA });
34109         wayB = wayB.update({ nodes: nodesB });
34110       }
34111       if (wayA.tags.step_count) {
34112         var stepCount = Number(wayA.tags.step_count);
34113         if (stepCount && // ensure a number
34114         isFinite(stepCount) && // ensure positive
34115         stepCount > 0 && // ensure integer
34116         Math.round(stepCount) === stepCount) {
34117           var tagsA = Object.assign({}, wayA.tags);
34118           var tagsB = Object.assign({}, wayB.tags);
34119           var ratioA = lengthA / (lengthA + lengthB);
34120           var countA = Math.round(stepCount * ratioA);
34121           tagsA.step_count = countA.toString();
34122           tagsB.step_count = (stepCount - countA).toString();
34123           wayA = wayA.update({ tags: tagsA });
34124           wayB = wayB.update({ tags: tagsB });
34125         }
34126       }
34127       graph = graph.replace(wayA);
34128       graph = graph.replace(wayB);
34129       graph.parentRelations(wayA).forEach(function(relation) {
34130         if (relation.hasFromViaTo()) {
34131           var f2 = relation.memberByRole("from");
34132           var v2 = relation.membersByRole("via");
34133           var t2 = relation.memberByRole("to");
34134           var i3;
34135           if (f2.id === wayA.id || t2.id === wayA.id) {
34136             var keepB = false;
34137             if (v2.length === 1 && v2[0].type === "node") {
34138               keepB = wayB.contains(v2[0].id);
34139             } else {
34140               for (i3 = 0; i3 < v2.length; i3++) {
34141                 if (v2[i3].type === "way") {
34142                   var wayVia = graph.hasEntity(v2[i3].id);
34143                   if (wayVia && utilArrayIntersection(wayB.nodes, wayVia.nodes).length) {
34144                     keepB = true;
34145                     break;
34146                   }
34147                 }
34148               }
34149             }
34150             if (keepB) {
34151               relation = relation.replaceMember(wayA, wayB);
34152               graph = graph.replace(relation);
34153             }
34154           } else {
34155             for (i3 = 0; i3 < v2.length; i3++) {
34156               if (v2[i3].type === "way" && v2[i3].id === wayA.id) {
34157                 graph = splitWayMember(graph, relation.id, wayA, wayB);
34158               }
34159             }
34160           }
34161         } else {
34162           graph = splitWayMember(graph, relation.id, wayA, wayB);
34163         }
34164       });
34165       if (isArea) {
34166         var multipolygon = osmRelation({
34167           tags: Object.assign({}, wayA.tags, { type: "multipolygon" }),
34168           members: [
34169             { id: wayA.id, role: "outer", type: "way" },
34170             { id: wayB.id, role: "outer", type: "way" }
34171           ]
34172         });
34173         graph = graph.replace(multipolygon);
34174         graph = graph.replace(wayA.update({ tags: {} }));
34175         graph = graph.replace(wayB.update({ tags: {} }));
34176       }
34177       _createdWayIDs.push(wayB.id);
34178       return graph;
34179     }
34180     function splitWayMember(graph, relationId, wayA, wayB) {
34181       function connects(way1, way2) {
34182         if (way1.nodes.length < 2 || way2.nodes.length < 2)
34183           return false;
34184         if (circularJunctions.includes(way1.tags.junction) && way1.isClosed()) {
34185           return way1.nodes.some((nodeId) => nodeId === way2.nodes[0] || nodeId === way2.nodes[way2.nodes.length - 1]);
34186         } else if (circularJunctions.includes(way2.tags.junction) && way2.isClosed()) {
34187           return way2.nodes.some((nodeId) => nodeId === way1.nodes[0] || nodeId === way1.nodes[way1.nodes.length - 1]);
34188         }
34189         if (way1.nodes[0] === way2.nodes[0])
34190           return true;
34191         if (way1.nodes[0] === way2.nodes[way2.nodes.length - 1])
34192           return true;
34193         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[way2.nodes.length - 1])
34194           return true;
34195         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[0])
34196           return true;
34197         return false;
34198       }
34199       let relation = graph.entity(relationId);
34200       const insertMembers = [];
34201       const members = relation.members;
34202       for (let i3 = 0; i3 < members.length; i3++) {
34203         const member = members[i3];
34204         if (member.id === wayA.id) {
34205           let wayAconnectsPrev = false;
34206           let wayAconnectsNext = false;
34207           let wayBconnectsPrev = false;
34208           let wayBconnectsNext = false;
34209           if (i3 > 0 && graph.hasEntity(members[i3 - 1].id)) {
34210             const prevEntity = graph.entity(members[i3 - 1].id);
34211             if (prevEntity.type === "way") {
34212               wayAconnectsPrev = connects(prevEntity, wayA);
34213               wayBconnectsPrev = connects(prevEntity, wayB);
34214             }
34215           }
34216           if (i3 < members.length - 1 && graph.hasEntity(members[i3 + 1].id)) {
34217             const nextEntity = graph.entity(members[i3 + 1].id);
34218             if (nextEntity.type === "way") {
34219               wayAconnectsNext = connects(nextEntity, wayA);
34220               wayBconnectsNext = connects(nextEntity, wayB);
34221             }
34222           }
34223           if (wayAconnectsPrev && !wayAconnectsNext || !wayBconnectsPrev && wayBconnectsNext && !(!wayAconnectsPrev && wayAconnectsNext)) {
34224             insertMembers.push({ at: i3 + 1, role: member.role });
34225             continue;
34226           }
34227           if (!wayAconnectsPrev && wayAconnectsNext || wayBconnectsPrev && !wayBconnectsNext && !(wayAconnectsPrev && !wayAconnectsNext)) {
34228             insertMembers.push({ at: i3, role: member.role });
34229             continue;
34230           }
34231           if (wayAconnectsPrev && wayBconnectsPrev && wayAconnectsNext && wayBconnectsNext) {
34232             if (i3 > 2 && graph.hasEntity(members[i3 - 2].id)) {
34233               const prev2Entity = graph.entity(members[i3 - 2].id);
34234               if (connects(prev2Entity, wayA) && !connects(prev2Entity, wayB)) {
34235                 insertMembers.push({ at: i3, role: member.role });
34236                 continue;
34237               }
34238               if (connects(prev2Entity, wayB) && !connects(prev2Entity, wayA)) {
34239                 insertMembers.push({ at: i3 + 1, role: member.role });
34240                 continue;
34241               }
34242             }
34243             if (i3 < members.length - 2 && graph.hasEntity(members[i3 + 2].id)) {
34244               const next2Entity = graph.entity(members[i3 + 2].id);
34245               if (connects(next2Entity, wayA) && !connects(next2Entity, wayB)) {
34246                 insertMembers.push({ at: i3 + 1, role: member.role });
34247                 continue;
34248               }
34249               if (connects(next2Entity, wayB) && !connects(next2Entity, wayA)) {
34250                 insertMembers.push({ at: i3, role: member.role });
34251                 continue;
34252               }
34253             }
34254           }
34255           if (wayA.nodes[wayA.nodes.length - 1] === wayB.nodes[0]) {
34256             insertMembers.push({ at: i3 + 1, role: member.role });
34257           } else {
34258             insertMembers.push({ at: i3, role: member.role });
34259           }
34260         }
34261       }
34262       insertMembers.reverse().forEach((item) => {
34263         graph = graph.replace(relation.addMember({
34264           id: wayB.id,
34265           type: "way",
34266           role: item.role
34267         }, item.at));
34268         relation = graph.entity(relation.id);
34269       });
34270       return graph;
34271     }
34272     var action = function(graph) {
34273       _createdWayIDs = [];
34274       var newWayIndex = 0;
34275       for (var i3 = 0; i3 < nodeIds.length; i3++) {
34276         var nodeId = nodeIds[i3];
34277         var candidates = action.waysForNode(nodeId, graph);
34278         for (var j2 = 0; j2 < candidates.length; j2++) {
34279           graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex]);
34280           newWayIndex += 1;
34281         }
34282       }
34283       return graph;
34284     };
34285     action.getCreatedWayIDs = function() {
34286       return _createdWayIDs;
34287     };
34288     action.waysForNode = function(nodeId, graph) {
34289       var node = graph.entity(nodeId);
34290       var splittableParents = graph.parentWays(node).filter(isSplittable);
34291       if (!_wayIDs) {
34292         var hasLine = splittableParents.some(function(parent) {
34293           return parent.geometry(graph) === "line";
34294         });
34295         if (hasLine) {
34296           return splittableParents.filter(function(parent) {
34297             return parent.geometry(graph) === "line";
34298           });
34299         }
34300       }
34301       return splittableParents;
34302       function isSplittable(parent) {
34303         if (_wayIDs && _wayIDs.indexOf(parent.id) === -1)
34304           return false;
34305         if (parent.isClosed())
34306           return true;
34307         for (var i3 = 1; i3 < parent.nodes.length - 1; i3++) {
34308           if (parent.nodes[i3] === nodeId)
34309             return true;
34310         }
34311         return false;
34312       }
34313     };
34314     action.ways = function(graph) {
34315       return utilArrayUniq([].concat.apply([], nodeIds.map(function(nodeId) {
34316         return action.waysForNode(nodeId, graph);
34317       })));
34318     };
34319     action.disabled = function(graph) {
34320       for (const nodeId of nodeIds) {
34321         const candidates = action.waysForNode(nodeId, graph);
34322         if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) {
34323           return "not_eligible";
34324         }
34325         for (const way of candidates) {
34326           const parentRelations = graph.parentRelations(way);
34327           for (const parentRelation of parentRelations) {
34328             if (parentRelation.hasFromViaTo()) {
34329               const vias = parentRelation.membersByRole("via");
34330               if (!vias.every((via) => graph.hasEntity(via.id))) {
34331                 return "parent_incomplete";
34332               }
34333             } else {
34334               for (let i3 = 0; i3 < parentRelation.members.length; i3++) {
34335                 if (parentRelation.members[i3].id === way.id) {
34336                   const memberBeforePresent = i3 > 0 && graph.hasEntity(parentRelation.members[i3 - 1].id);
34337                   const memberAfterPresent = i3 < parentRelation.members.length - 1 && graph.hasEntity(parentRelation.members[i3 + 1].id);
34338                   if (!memberBeforePresent && !memberAfterPresent && parentRelation.members.length > 1) {
34339                     return "parent_incomplete";
34340                   }
34341                 }
34342               }
34343             }
34344             const relTypesExceptions = ["junction", "enforcement"];
34345             if (circularJunctions.includes(way.tags.junction) && way.isClosed() && !relTypesExceptions.includes(parentRelation.tags.type)) {
34346               return "simple_roundabout";
34347             }
34348           }
34349         }
34350       }
34351     };
34352     action.limitWays = function(val) {
34353       if (!arguments.length)
34354         return _wayIDs;
34355       _wayIDs = val;
34356       return action;
34357     };
34358     action.keepHistoryOn = function(val) {
34359       if (!arguments.length)
34360         return _keepHistoryOn;
34361       _keepHistoryOn = val;
34362       return action;
34363     };
34364     return action;
34365   }
34366
34367   // modules/core/graph.js
34368   function coreGraph(other, mutable) {
34369     if (!(this instanceof coreGraph))
34370       return new coreGraph(other, mutable);
34371     if (other instanceof coreGraph) {
34372       var base = other.base();
34373       this.entities = Object.assign(Object.create(base.entities), other.entities);
34374       this._parentWays = Object.assign(Object.create(base.parentWays), other._parentWays);
34375       this._parentRels = Object.assign(Object.create(base.parentRels), other._parentRels);
34376     } else {
34377       this.entities = /* @__PURE__ */ Object.create({});
34378       this._parentWays = /* @__PURE__ */ Object.create({});
34379       this._parentRels = /* @__PURE__ */ Object.create({});
34380       this.rebase(other || [], [this]);
34381     }
34382     this.transients = {};
34383     this._childNodes = {};
34384     this.frozen = !mutable;
34385   }
34386   coreGraph.prototype = {
34387     hasEntity: function(id2) {
34388       return this.entities[id2];
34389     },
34390     entity: function(id2) {
34391       var entity = this.entities[id2];
34392       if (!entity) {
34393         entity = this.entities.__proto__[id2];
34394       }
34395       if (!entity) {
34396         throw new Error("entity " + id2 + " not found");
34397       }
34398       return entity;
34399     },
34400     geometry: function(id2) {
34401       return this.entity(id2).geometry(this);
34402     },
34403     transient: function(entity, key, fn) {
34404       var id2 = entity.id;
34405       var transients = this.transients[id2] || (this.transients[id2] = {});
34406       if (transients[key] !== void 0) {
34407         return transients[key];
34408       }
34409       transients[key] = fn.call(entity);
34410       return transients[key];
34411     },
34412     parentWays: function(entity) {
34413       var parents = this._parentWays[entity.id];
34414       var result = [];
34415       if (parents) {
34416         parents.forEach(function(id2) {
34417           result.push(this.entity(id2));
34418         }, this);
34419       }
34420       return result;
34421     },
34422     isPoi: function(entity) {
34423       var parents = this._parentWays[entity.id];
34424       return !parents || parents.size === 0;
34425     },
34426     isShared: function(entity) {
34427       var parents = this._parentWays[entity.id];
34428       return parents && parents.size > 1;
34429     },
34430     parentRelations: function(entity) {
34431       var parents = this._parentRels[entity.id];
34432       var result = [];
34433       if (parents) {
34434         parents.forEach(function(id2) {
34435           result.push(this.entity(id2));
34436         }, this);
34437       }
34438       return result;
34439     },
34440     parentMultipolygons: function(entity) {
34441       return this.parentRelations(entity).filter(function(relation) {
34442         return relation.isMultipolygon();
34443       });
34444     },
34445     childNodes: function(entity) {
34446       if (this._childNodes[entity.id])
34447         return this._childNodes[entity.id];
34448       if (!entity.nodes)
34449         return [];
34450       var nodes = [];
34451       for (var i3 = 0; i3 < entity.nodes.length; i3++) {
34452         nodes[i3] = this.entity(entity.nodes[i3]);
34453       }
34454       if (debug)
34455         Object.freeze(nodes);
34456       this._childNodes[entity.id] = nodes;
34457       return this._childNodes[entity.id];
34458     },
34459     base: function() {
34460       return {
34461         "entities": Object.getPrototypeOf(this.entities),
34462         "parentWays": Object.getPrototypeOf(this._parentWays),
34463         "parentRels": Object.getPrototypeOf(this._parentRels)
34464       };
34465     },
34466     // Unlike other graph methods, rebase mutates in place. This is because it
34467     // is used only during the history operation that merges newly downloaded
34468     // data into each state. To external consumers, it should appear as if the
34469     // graph always contained the newly downloaded data.
34470     rebase: function(entities, stack, force) {
34471       var base = this.base();
34472       var i3, j2, k2, id2;
34473       for (i3 = 0; i3 < entities.length; i3++) {
34474         var entity = entities[i3];
34475         if (!entity.visible || !force && base.entities[entity.id])
34476           continue;
34477         base.entities[entity.id] = entity;
34478         this._updateCalculated(void 0, entity, base.parentWays, base.parentRels);
34479         if (entity.type === "way") {
34480           for (j2 = 0; j2 < entity.nodes.length; j2++) {
34481             id2 = entity.nodes[j2];
34482             for (k2 = 1; k2 < stack.length; k2++) {
34483               var ents = stack[k2].entities;
34484               if (ents.hasOwnProperty(id2) && ents[id2] === void 0) {
34485                 delete ents[id2];
34486               }
34487             }
34488           }
34489         }
34490       }
34491       for (i3 = 0; i3 < stack.length; i3++) {
34492         stack[i3]._updateRebased();
34493       }
34494     },
34495     _updateRebased: function() {
34496       var base = this.base();
34497       Object.keys(this._parentWays).forEach(function(child) {
34498         if (base.parentWays[child]) {
34499           base.parentWays[child].forEach(function(id2) {
34500             if (!this.entities.hasOwnProperty(id2)) {
34501               this._parentWays[child].add(id2);
34502             }
34503           }, this);
34504         }
34505       }, this);
34506       Object.keys(this._parentRels).forEach(function(child) {
34507         if (base.parentRels[child]) {
34508           base.parentRels[child].forEach(function(id2) {
34509             if (!this.entities.hasOwnProperty(id2)) {
34510               this._parentRels[child].add(id2);
34511             }
34512           }, this);
34513         }
34514       }, this);
34515       this.transients = {};
34516     },
34517     // Updates calculated properties (parentWays, parentRels) for the specified change
34518     _updateCalculated: function(oldentity, entity, parentWays, parentRels) {
34519       parentWays = parentWays || this._parentWays;
34520       parentRels = parentRels || this._parentRels;
34521       var type2 = entity && entity.type || oldentity && oldentity.type;
34522       var removed, added, i3;
34523       if (type2 === "way") {
34524         if (oldentity && entity) {
34525           removed = utilArrayDifference(oldentity.nodes, entity.nodes);
34526           added = utilArrayDifference(entity.nodes, oldentity.nodes);
34527         } else if (oldentity) {
34528           removed = oldentity.nodes;
34529           added = [];
34530         } else if (entity) {
34531           removed = [];
34532           added = entity.nodes;
34533         }
34534         for (i3 = 0; i3 < removed.length; i3++) {
34535           parentWays[removed[i3]] = new Set(parentWays[removed[i3]]);
34536           parentWays[removed[i3]].delete(oldentity.id);
34537         }
34538         for (i3 = 0; i3 < added.length; i3++) {
34539           parentWays[added[i3]] = new Set(parentWays[added[i3]]);
34540           parentWays[added[i3]].add(entity.id);
34541         }
34542       } else if (type2 === "relation") {
34543         var oldentityMemberIDs = oldentity ? oldentity.members.map(function(m2) {
34544           return m2.id;
34545         }) : [];
34546         var entityMemberIDs = entity ? entity.members.map(function(m2) {
34547           return m2.id;
34548         }) : [];
34549         if (oldentity && entity) {
34550           removed = utilArrayDifference(oldentityMemberIDs, entityMemberIDs);
34551           added = utilArrayDifference(entityMemberIDs, oldentityMemberIDs);
34552         } else if (oldentity) {
34553           removed = oldentityMemberIDs;
34554           added = [];
34555         } else if (entity) {
34556           removed = [];
34557           added = entityMemberIDs;
34558         }
34559         for (i3 = 0; i3 < removed.length; i3++) {
34560           parentRels[removed[i3]] = new Set(parentRels[removed[i3]]);
34561           parentRels[removed[i3]].delete(oldentity.id);
34562         }
34563         for (i3 = 0; i3 < added.length; i3++) {
34564           parentRels[added[i3]] = new Set(parentRels[added[i3]]);
34565           parentRels[added[i3]].add(entity.id);
34566         }
34567       }
34568     },
34569     replace: function(entity) {
34570       if (this.entities[entity.id] === entity)
34571         return this;
34572       return this.update(function() {
34573         this._updateCalculated(this.entities[entity.id], entity);
34574         this.entities[entity.id] = entity;
34575       });
34576     },
34577     remove: function(entity) {
34578       return this.update(function() {
34579         this._updateCalculated(entity, void 0);
34580         this.entities[entity.id] = void 0;
34581       });
34582     },
34583     revert: function(id2) {
34584       var baseEntity = this.base().entities[id2];
34585       var headEntity = this.entities[id2];
34586       if (headEntity === baseEntity)
34587         return this;
34588       return this.update(function() {
34589         this._updateCalculated(headEntity, baseEntity);
34590         delete this.entities[id2];
34591       });
34592     },
34593     update: function() {
34594       var graph = this.frozen ? coreGraph(this, true) : this;
34595       for (var i3 = 0; i3 < arguments.length; i3++) {
34596         arguments[i3].call(graph, graph);
34597       }
34598       if (this.frozen)
34599         graph.frozen = true;
34600       return graph;
34601     },
34602     // Obliterates any existing entities
34603     load: function(entities) {
34604       var base = this.base();
34605       this.entities = Object.create(base.entities);
34606       for (var i3 in entities) {
34607         this.entities[i3] = entities[i3];
34608         this._updateCalculated(base.entities[i3], this.entities[i3]);
34609       }
34610       return this;
34611     }
34612   };
34613
34614   // modules/osm/intersection.js
34615   function osmTurn(turn) {
34616     if (!(this instanceof osmTurn)) {
34617       return new osmTurn(turn);
34618     }
34619     Object.assign(this, turn);
34620   }
34621   function osmIntersection(graph, startVertexId, maxDistance) {
34622     maxDistance = maxDistance || 30;
34623     var vgraph = coreGraph();
34624     var i3, j2, k2;
34625     function memberOfRestriction(entity) {
34626       return graph.parentRelations(entity).some(function(r2) {
34627         return r2.isRestriction();
34628       });
34629     }
34630     function isRoad(way2) {
34631       if (way2.isArea() || way2.isDegenerate())
34632         return false;
34633       var roads = {
34634         "motorway": true,
34635         "motorway_link": true,
34636         "trunk": true,
34637         "trunk_link": true,
34638         "primary": true,
34639         "primary_link": true,
34640         "secondary": true,
34641         "secondary_link": true,
34642         "tertiary": true,
34643         "tertiary_link": true,
34644         "residential": true,
34645         "unclassified": true,
34646         "living_street": true,
34647         "service": true,
34648         "busway": true,
34649         "road": true,
34650         "track": true
34651       };
34652       return roads[way2.tags.highway];
34653     }
34654     var startNode = graph.entity(startVertexId);
34655     var checkVertices = [startNode];
34656     var checkWays;
34657     var vertices = [];
34658     var vertexIds = [];
34659     var vertex;
34660     var ways = [];
34661     var wayIds = [];
34662     var way;
34663     var nodes = [];
34664     var node;
34665     var parents = [];
34666     var parent;
34667     var actions = [];
34668     while (checkVertices.length) {
34669       vertex = checkVertices.pop();
34670       checkWays = graph.parentWays(vertex);
34671       var hasWays = false;
34672       for (i3 = 0; i3 < checkWays.length; i3++) {
34673         way = checkWays[i3];
34674         if (!isRoad(way) && !memberOfRestriction(way))
34675           continue;
34676         ways.push(way);
34677         hasWays = true;
34678         nodes = utilArrayUniq(graph.childNodes(way));
34679         for (j2 = 0; j2 < nodes.length; j2++) {
34680           node = nodes[j2];
34681           if (node === vertex)
34682             continue;
34683           if (vertices.indexOf(node) !== -1)
34684             continue;
34685           if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance)
34686             continue;
34687           var hasParents = false;
34688           parents = graph.parentWays(node);
34689           for (k2 = 0; k2 < parents.length; k2++) {
34690             parent = parents[k2];
34691             if (parent === way)
34692               continue;
34693             if (ways.indexOf(parent) !== -1)
34694               continue;
34695             if (!isRoad(parent))
34696               continue;
34697             hasParents = true;
34698             break;
34699           }
34700           if (hasParents) {
34701             checkVertices.push(node);
34702           }
34703         }
34704       }
34705       if (hasWays) {
34706         vertices.push(vertex);
34707       }
34708     }
34709     vertices = utilArrayUniq(vertices);
34710     ways = utilArrayUniq(ways);
34711     ways.forEach(function(way2) {
34712       graph.childNodes(way2).forEach(function(node2) {
34713         vgraph = vgraph.replace(node2);
34714       });
34715       vgraph = vgraph.replace(way2);
34716       graph.parentRelations(way2).forEach(function(relation) {
34717         if (relation.isRestriction()) {
34718           if (relation.isValidRestriction(graph)) {
34719             vgraph = vgraph.replace(relation);
34720           } else if (relation.isComplete(graph)) {
34721             actions.push(actionDeleteRelation(relation.id));
34722           }
34723         }
34724       });
34725     });
34726     ways.forEach(function(w2) {
34727       var way2 = vgraph.entity(w2.id);
34728       if (way2.tags.oneway === "-1") {
34729         var action = actionReverse(way2.id, { reverseOneway: true });
34730         actions.push(action);
34731         vgraph = action(vgraph);
34732       }
34733     });
34734     var origCount = osmEntity.id.next.way;
34735     vertices.forEach(function(v2) {
34736       var splitAll = actionSplit([v2.id]).keepHistoryOn("first");
34737       if (!splitAll.disabled(vgraph)) {
34738         splitAll.ways(vgraph).forEach(function(way2) {
34739           var splitOne = actionSplit([v2.id]).limitWays([way2.id]).keepHistoryOn("first");
34740           actions.push(splitOne);
34741           vgraph = splitOne(vgraph);
34742         });
34743       }
34744     });
34745     osmEntity.id.next.way = origCount;
34746     vertexIds = vertices.map(function(v2) {
34747       return v2.id;
34748     });
34749     vertices = [];
34750     ways = [];
34751     vertexIds.forEach(function(id2) {
34752       var vertex2 = vgraph.entity(id2);
34753       var parents2 = vgraph.parentWays(vertex2);
34754       vertices.push(vertex2);
34755       ways = ways.concat(parents2);
34756     });
34757     vertices = utilArrayUniq(vertices);
34758     ways = utilArrayUniq(ways);
34759     vertexIds = vertices.map(function(v2) {
34760       return v2.id;
34761     });
34762     wayIds = ways.map(function(w2) {
34763       return w2.id;
34764     });
34765     function withMetadata(way2, vertexIds2) {
34766       var __oneWay = way2.isOneWay();
34767       var __first = vertexIds2.indexOf(way2.first()) !== -1;
34768       var __last = vertexIds2.indexOf(way2.last()) !== -1;
34769       var __via = __first && __last;
34770       var __from = __first && !__oneWay || __last;
34771       var __to = __first || __last && !__oneWay;
34772       return way2.update({
34773         __first,
34774         __last,
34775         __from,
34776         __via,
34777         __to,
34778         __oneWay
34779       });
34780     }
34781     ways = [];
34782     wayIds.forEach(function(id2) {
34783       var way2 = withMetadata(vgraph.entity(id2), vertexIds);
34784       vgraph = vgraph.replace(way2);
34785       ways.push(way2);
34786     });
34787     var keepGoing;
34788     var removeWayIds = [];
34789     var removeVertexIds = [];
34790     do {
34791       keepGoing = false;
34792       checkVertices = vertexIds.slice();
34793       for (i3 = 0; i3 < checkVertices.length; i3++) {
34794         var vertexId = checkVertices[i3];
34795         vertex = vgraph.hasEntity(vertexId);
34796         if (!vertex) {
34797           if (vertexIds.indexOf(vertexId) !== -1) {
34798             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34799           }
34800           removeVertexIds.push(vertexId);
34801           continue;
34802         }
34803         parents = vgraph.parentWays(vertex);
34804         if (parents.length < 3) {
34805           if (vertexIds.indexOf(vertexId) !== -1) {
34806             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34807           }
34808         }
34809         if (parents.length === 2) {
34810           var a2 = parents[0];
34811           var b2 = parents[1];
34812           var aIsLeaf = a2 && !a2.__via;
34813           var bIsLeaf = b2 && !b2.__via;
34814           var leaf, survivor;
34815           if (aIsLeaf && !bIsLeaf) {
34816             leaf = a2;
34817             survivor = b2;
34818           } else if (!aIsLeaf && bIsLeaf) {
34819             leaf = b2;
34820             survivor = a2;
34821           }
34822           if (leaf && survivor) {
34823             survivor = withMetadata(survivor, vertexIds);
34824             vgraph = vgraph.replace(survivor).remove(leaf);
34825             removeWayIds.push(leaf.id);
34826             keepGoing = true;
34827           }
34828         }
34829         parents = vgraph.parentWays(vertex);
34830         if (parents.length < 2) {
34831           if (vertexIds.indexOf(vertexId) !== -1) {
34832             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34833           }
34834           removeVertexIds.push(vertexId);
34835           keepGoing = true;
34836         }
34837         if (parents.length < 1) {
34838           vgraph = vgraph.remove(vertex);
34839         }
34840       }
34841     } while (keepGoing);
34842     vertices = vertices.filter(function(vertex2) {
34843       return removeVertexIds.indexOf(vertex2.id) === -1;
34844     }).map(function(vertex2) {
34845       return vgraph.entity(vertex2.id);
34846     });
34847     ways = ways.filter(function(way2) {
34848       return removeWayIds.indexOf(way2.id) === -1;
34849     }).map(function(way2) {
34850       return vgraph.entity(way2.id);
34851     });
34852     var intersection2 = {
34853       graph: vgraph,
34854       actions,
34855       vertices,
34856       ways
34857     };
34858     intersection2.turns = function(fromWayId, maxViaWay) {
34859       if (!fromWayId)
34860         return [];
34861       if (!maxViaWay)
34862         maxViaWay = 0;
34863       var vgraph2 = intersection2.graph;
34864       var keyVertexIds = intersection2.vertices.map(function(v2) {
34865         return v2.id;
34866       });
34867       var start2 = vgraph2.entity(fromWayId);
34868       if (!start2 || !(start2.__from || start2.__via))
34869         return [];
34870       var maxPathLength = maxViaWay * 2 + 3;
34871       var turns = [];
34872       step(start2);
34873       return turns;
34874       function step(entity, currPath, currRestrictions, matchedRestriction) {
34875         currPath = (currPath || []).slice();
34876         if (currPath.length >= maxPathLength)
34877           return;
34878         currPath.push(entity.id);
34879         currRestrictions = (currRestrictions || []).slice();
34880         if (entity.type === "node") {
34881           stepNode(entity, currPath, currRestrictions);
34882         } else {
34883           stepWay(entity, currPath, currRestrictions, matchedRestriction);
34884         }
34885       }
34886       function stepNode(entity, currPath, currRestrictions) {
34887         var i4, j3;
34888         var parents2 = vgraph2.parentWays(entity);
34889         var nextWays = [];
34890         for (i4 = 0; i4 < parents2.length; i4++) {
34891           var way2 = parents2[i4];
34892           if (way2.__oneWay && way2.nodes[0] !== entity.id)
34893             continue;
34894           if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3)
34895             continue;
34896           var restrict = null;
34897           for (j3 = 0; j3 < currRestrictions.length; j3++) {
34898             var restriction = currRestrictions[j3];
34899             var f2 = restriction.memberByRole("from");
34900             var v2 = restriction.membersByRole("via");
34901             var t2 = restriction.memberByRole("to");
34902             var isNo = /^no_/.test(restriction.tags.restriction);
34903             var isOnly = /^only_/.test(restriction.tags.restriction);
34904             if (!(isNo || isOnly)) {
34905               continue;
34906             }
34907             var matchesFrom = f2.id === fromWayId;
34908             var matchesViaTo = false;
34909             var isAlongOnlyPath = false;
34910             if (t2.id === way2.id) {
34911               if (v2.length === 1 && v2[0].type === "node") {
34912                 matchesViaTo = v2[0].id === entity.id && (matchesFrom && currPath.length === 2 || !matchesFrom && currPath.length > 2);
34913               } else {
34914                 var pathVias = [];
34915                 for (k2 = 2; k2 < currPath.length; k2 += 2) {
34916                   pathVias.push(currPath[k2]);
34917                 }
34918                 var restrictionVias = [];
34919                 for (k2 = 0; k2 < v2.length; k2++) {
34920                   if (v2[k2].type === "way") {
34921                     restrictionVias.push(v2[k2].id);
34922                   }
34923                 }
34924                 var diff = utilArrayDifference(pathVias, restrictionVias);
34925                 matchesViaTo = !diff.length;
34926               }
34927             } else if (isOnly) {
34928               for (k2 = 0; k2 < v2.length; k2++) {
34929                 if (v2[k2].type === "way" && v2[k2].id === way2.id) {
34930                   isAlongOnlyPath = true;
34931                   break;
34932                 }
34933               }
34934             }
34935             if (matchesViaTo) {
34936               if (isOnly) {
34937                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true };
34938               } else {
34939                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true };
34940               }
34941             } else {
34942               if (isAlongOnlyPath) {
34943                 restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false };
34944               } else if (isOnly) {
34945                 restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true };
34946               }
34947             }
34948             if (restrict && restrict.direct)
34949               break;
34950           }
34951           nextWays.push({ way: way2, restrict });
34952         }
34953         nextWays.forEach(function(nextWay) {
34954           step(nextWay.way, currPath, currRestrictions, nextWay.restrict);
34955         });
34956       }
34957       function stepWay(entity, currPath, currRestrictions, matchedRestriction) {
34958         var i4;
34959         if (currPath.length >= 3) {
34960           var turnPath = currPath.slice();
34961           if (matchedRestriction && matchedRestriction.direct === false) {
34962             for (i4 = 0; i4 < turnPath.length; i4++) {
34963               if (turnPath[i4] === matchedRestriction.from) {
34964                 turnPath = turnPath.slice(i4);
34965                 break;
34966               }
34967             }
34968           }
34969           var turn = pathToTurn(turnPath);
34970           if (turn) {
34971             if (matchedRestriction) {
34972               turn.restrictionID = matchedRestriction.id;
34973               turn.no = matchedRestriction.no;
34974               turn.only = matchedRestriction.only;
34975               turn.direct = matchedRestriction.direct;
34976             }
34977             turns.push(osmTurn(turn));
34978           }
34979           if (currPath[0] === currPath[2])
34980             return;
34981         }
34982         if (matchedRestriction && matchedRestriction.end)
34983           return;
34984         var n1 = vgraph2.entity(entity.first());
34985         var n22 = vgraph2.entity(entity.last());
34986         var dist = geoSphericalDistance(n1.loc, n22.loc);
34987         var nextNodes = [];
34988         if (currPath.length > 1) {
34989           if (dist > maxDistance)
34990             return;
34991           if (!entity.__via)
34992             return;
34993         }
34994         if (!entity.__oneWay && // bidirectional..
34995         keyVertexIds.indexOf(n1.id) !== -1 && // key vertex..
34996         currPath.indexOf(n1.id) === -1) {
34997           nextNodes.push(n1);
34998         }
34999         if (keyVertexIds.indexOf(n22.id) !== -1 && // key vertex..
35000         currPath.indexOf(n22.id) === -1) {
35001           nextNodes.push(n22);
35002         }
35003         nextNodes.forEach(function(nextNode) {
35004           var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) {
35005             if (!r2.isRestriction())
35006               return false;
35007             var f2 = r2.memberByRole("from");
35008             if (!f2 || f2.id !== entity.id)
35009               return false;
35010             var isOnly = /^only_/.test(r2.tags.restriction);
35011             if (!isOnly)
35012               return true;
35013             var isOnlyVia = false;
35014             var v2 = r2.membersByRole("via");
35015             if (v2.length === 1 && v2[0].type === "node") {
35016               isOnlyVia = v2[0].id === nextNode.id;
35017             } else {
35018               for (var i5 = 0; i5 < v2.length; i5++) {
35019                 if (v2[i5].type !== "way")
35020                   continue;
35021                 var viaWay = vgraph2.entity(v2[i5].id);
35022                 if (viaWay.first() === nextNode.id || viaWay.last() === nextNode.id) {
35023                   isOnlyVia = true;
35024                   break;
35025                 }
35026               }
35027             }
35028             return isOnlyVia;
35029           });
35030           step(nextNode, currPath, currRestrictions.concat(fromRestrictions), false);
35031         });
35032       }
35033       function pathToTurn(path) {
35034         if (path.length < 3)
35035           return;
35036         var fromWayId2, fromNodeId, fromVertexId;
35037         var toWayId, toNodeId, toVertexId;
35038         var viaWayIds, viaNodeId, isUturn;
35039         fromWayId2 = path[0];
35040         toWayId = path[path.length - 1];
35041         if (path.length === 3 && fromWayId2 === toWayId) {
35042           var way2 = vgraph2.entity(fromWayId2);
35043           if (way2.__oneWay)
35044             return null;
35045           isUturn = true;
35046           viaNodeId = fromVertexId = toVertexId = path[1];
35047           fromNodeId = toNodeId = adjacentNode(fromWayId2, viaNodeId);
35048         } else {
35049           isUturn = false;
35050           fromVertexId = path[1];
35051           fromNodeId = adjacentNode(fromWayId2, fromVertexId);
35052           toVertexId = path[path.length - 2];
35053           toNodeId = adjacentNode(toWayId, toVertexId);
35054           if (path.length === 3) {
35055             viaNodeId = path[1];
35056           } else {
35057             viaWayIds = path.filter(function(entityId) {
35058               return entityId[0] === "w";
35059             });
35060             viaWayIds = viaWayIds.slice(1, viaWayIds.length - 1);
35061           }
35062         }
35063         return {
35064           key: path.join("_"),
35065           path,
35066           from: { node: fromNodeId, way: fromWayId2, vertex: fromVertexId },
35067           via: { node: viaNodeId, ways: viaWayIds },
35068           to: { node: toNodeId, way: toWayId, vertex: toVertexId },
35069           u: isUturn
35070         };
35071         function adjacentNode(wayId, affixId) {
35072           var nodes2 = vgraph2.entity(wayId).nodes;
35073           return affixId === nodes2[0] ? nodes2[1] : nodes2[nodes2.length - 2];
35074         }
35075       }
35076     };
35077     return intersection2;
35078   }
35079   function osmInferRestriction(graph, turn, projection2) {
35080     var fromWay = graph.entity(turn.from.way);
35081     var fromNode = graph.entity(turn.from.node);
35082     var fromVertex = graph.entity(turn.from.vertex);
35083     var toWay = graph.entity(turn.to.way);
35084     var toNode = graph.entity(turn.to.node);
35085     var toVertex = graph.entity(turn.to.vertex);
35086     var fromOneWay = fromWay.tags.oneway === "yes";
35087     var toOneWay = toWay.tags.oneway === "yes";
35088     var angle2 = (geoAngle(fromVertex, fromNode, projection2) - geoAngle(toVertex, toNode, projection2)) * 180 / Math.PI;
35089     while (angle2 < 0) {
35090       angle2 += 360;
35091     }
35092     if (fromNode === toNode) {
35093       return "no_u_turn";
35094     }
35095     if ((angle2 < 23 || angle2 > 336) && fromOneWay && toOneWay) {
35096       return "no_u_turn";
35097     }
35098     if ((angle2 < 40 || angle2 > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
35099       return "no_u_turn";
35100     }
35101     if (angle2 < 158) {
35102       return "no_right_turn";
35103     }
35104     if (angle2 > 202) {
35105       return "no_left_turn";
35106     }
35107     return "no_straight_on";
35108   }
35109
35110   // modules/actions/merge_polygon.js
35111   function actionMergePolygon(ids, newRelationId) {
35112     function groupEntities(graph) {
35113       var entities = ids.map(function(id2) {
35114         return graph.entity(id2);
35115       });
35116       var geometryGroups = utilArrayGroupBy(entities, function(entity) {
35117         if (entity.type === "way" && entity.isClosed()) {
35118           return "closedWay";
35119         } else if (entity.type === "relation" && entity.isMultipolygon()) {
35120           return "multipolygon";
35121         } else {
35122           return "other";
35123         }
35124       });
35125       return Object.assign(
35126         { closedWay: [], multipolygon: [], other: [] },
35127         geometryGroups
35128       );
35129     }
35130     var action = function(graph) {
35131       var entities = groupEntities(graph);
35132       var polygons = entities.multipolygon.reduce(function(polygons2, m2) {
35133         return polygons2.concat(osmJoinWays(m2.members, graph));
35134       }, []).concat(entities.closedWay.map(function(d2) {
35135         var member = [{ id: d2.id }];
35136         member.nodes = graph.childNodes(d2);
35137         return member;
35138       }));
35139       var contained = polygons.map(function(w2, i3) {
35140         return polygons.map(function(d2, n3) {
35141           if (i3 === n3)
35142             return null;
35143           return geoPolygonContainsPolygon(
35144             d2.nodes.map(function(n4) {
35145               return n4.loc;
35146             }),
35147             w2.nodes.map(function(n4) {
35148               return n4.loc;
35149             })
35150           );
35151         });
35152       });
35153       var members = [];
35154       var outer = true;
35155       while (polygons.length) {
35156         extractUncontained(polygons);
35157         polygons = polygons.filter(isContained);
35158         contained = contained.filter(isContained).map(filterContained);
35159       }
35160       function isContained(d2, i3) {
35161         return contained[i3].some(function(val) {
35162           return val;
35163         });
35164       }
35165       function filterContained(d2) {
35166         return d2.filter(isContained);
35167       }
35168       function extractUncontained(polygons2) {
35169         polygons2.forEach(function(d2, i3) {
35170           if (!isContained(d2, i3)) {
35171             d2.forEach(function(member) {
35172               members.push({
35173                 type: "way",
35174                 id: member.id,
35175                 role: outer ? "outer" : "inner"
35176               });
35177             });
35178           }
35179         });
35180         outer = !outer;
35181       }
35182       var relation;
35183       if (entities.multipolygon.length > 0) {
35184         var oldestID = utilOldestID(entities.multipolygon.map((entity) => entity.id));
35185         relation = entities.multipolygon.find((entity) => entity.id === oldestID);
35186       } else {
35187         relation = osmRelation({ id: newRelationId, tags: { type: "multipolygon" } });
35188       }
35189       entities.multipolygon.forEach(function(m2) {
35190         if (m2.id !== relation.id) {
35191           relation = relation.mergeTags(m2.tags);
35192           graph = graph.remove(m2);
35193         }
35194       });
35195       entities.closedWay.forEach(function(way) {
35196         function isThisOuter(m2) {
35197           return m2.id === way.id && m2.role !== "inner";
35198         }
35199         if (members.some(isThisOuter)) {
35200           relation = relation.mergeTags(way.tags);
35201           graph = graph.replace(way.update({ tags: {} }));
35202         }
35203       });
35204       return graph.replace(relation.update({
35205         members,
35206         tags: utilObjectOmit(relation.tags, ["area"])
35207       }));
35208     };
35209     action.disabled = function(graph) {
35210       var entities = groupEntities(graph);
35211       if (entities.other.length > 0 || entities.closedWay.length + entities.multipolygon.length < 2) {
35212         return "not_eligible";
35213       }
35214       if (!entities.multipolygon.every(function(r2) {
35215         return r2.isComplete(graph);
35216       })) {
35217         return "incomplete_relation";
35218       }
35219       if (!entities.multipolygon.length) {
35220         var sharedMultipolygons = [];
35221         entities.closedWay.forEach(function(way, i3) {
35222           if (i3 === 0) {
35223             sharedMultipolygons = graph.parentMultipolygons(way);
35224           } else {
35225             sharedMultipolygons = utilArrayIntersection(sharedMultipolygons, graph.parentMultipolygons(way));
35226           }
35227         });
35228         sharedMultipolygons = sharedMultipolygons.filter(function(relation) {
35229           return relation.members.length === entities.closedWay.length;
35230         });
35231         if (sharedMultipolygons.length) {
35232           return "not_eligible";
35233         }
35234       } else if (entities.closedWay.some(function(way) {
35235         return utilArrayIntersection(graph.parentMultipolygons(way), entities.multipolygon).length;
35236       })) {
35237         return "not_eligible";
35238       }
35239     };
35240     return action;
35241   }
35242
35243   // modules/actions/merge_remote_changes.js
35244   var import_fast_deep_equal = __toESM(require_fast_deep_equal());
35245
35246   // node_modules/node-diff3/index.mjs
35247   function LCS(buffer1, buffer2) {
35248     let equivalenceClasses = {};
35249     for (let j2 = 0; j2 < buffer2.length; j2++) {
35250       const item = buffer2[j2];
35251       if (equivalenceClasses[item]) {
35252         equivalenceClasses[item].push(j2);
35253       } else {
35254         equivalenceClasses[item] = [j2];
35255       }
35256     }
35257     const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null };
35258     let candidates = [NULLRESULT];
35259     for (let i3 = 0; i3 < buffer1.length; i3++) {
35260       const item = buffer1[i3];
35261       const buffer2indices = equivalenceClasses[item] || [];
35262       let r2 = 0;
35263       let c2 = candidates[0];
35264       for (let jx = 0; jx < buffer2indices.length; jx++) {
35265         const j2 = buffer2indices[jx];
35266         let s2;
35267         for (s2 = r2; s2 < candidates.length; s2++) {
35268           if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) {
35269             break;
35270           }
35271         }
35272         if (s2 < candidates.length) {
35273           const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] };
35274           if (r2 === candidates.length) {
35275             candidates.push(c2);
35276           } else {
35277             candidates[r2] = c2;
35278           }
35279           r2 = s2 + 1;
35280           c2 = newCandidate;
35281           if (r2 === candidates.length) {
35282             break;
35283           }
35284         }
35285       }
35286       candidates[r2] = c2;
35287     }
35288     return candidates[candidates.length - 1];
35289   }
35290   function diffIndices(buffer1, buffer2) {
35291     const lcs = LCS(buffer1, buffer2);
35292     let result = [];
35293     let tail1 = buffer1.length;
35294     let tail2 = buffer2.length;
35295     for (let candidate = lcs; candidate !== null; candidate = candidate.chain) {
35296       const mismatchLength1 = tail1 - candidate.buffer1index - 1;
35297       const mismatchLength2 = tail2 - candidate.buffer2index - 1;
35298       tail1 = candidate.buffer1index;
35299       tail2 = candidate.buffer2index;
35300       if (mismatchLength1 || mismatchLength2) {
35301         result.push({
35302           buffer1: [tail1 + 1, mismatchLength1],
35303           buffer1Content: buffer1.slice(tail1 + 1, tail1 + 1 + mismatchLength1),
35304           buffer2: [tail2 + 1, mismatchLength2],
35305           buffer2Content: buffer2.slice(tail2 + 1, tail2 + 1 + mismatchLength2)
35306         });
35307       }
35308     }
35309     result.reverse();
35310     return result;
35311   }
35312   function diff3MergeRegions(a2, o2, b2) {
35313     let hunks = [];
35314     function addHunk(h2, ab) {
35315       hunks.push({
35316         ab,
35317         oStart: h2.buffer1[0],
35318         oLength: h2.buffer1[1],
35319         // length of o to remove
35320         abStart: h2.buffer2[0],
35321         abLength: h2.buffer2[1]
35322         // length of a/b to insert
35323         // abContent: (ab === 'a' ? a : b).slice(h.buffer2[0], h.buffer2[0] + h.buffer2[1])
35324       });
35325     }
35326     diffIndices(o2, a2).forEach((item) => addHunk(item, "a"));
35327     diffIndices(o2, b2).forEach((item) => addHunk(item, "b"));
35328     hunks.sort((x2, y2) => x2.oStart - y2.oStart);
35329     let results = [];
35330     let currOffset = 0;
35331     function advanceTo(endOffset) {
35332       if (endOffset > currOffset) {
35333         results.push({
35334           stable: true,
35335           buffer: "o",
35336           bufferStart: currOffset,
35337           bufferLength: endOffset - currOffset,
35338           bufferContent: o2.slice(currOffset, endOffset)
35339         });
35340         currOffset = endOffset;
35341       }
35342     }
35343     while (hunks.length) {
35344       let hunk = hunks.shift();
35345       let regionStart = hunk.oStart;
35346       let regionEnd = hunk.oStart + hunk.oLength;
35347       let regionHunks = [hunk];
35348       advanceTo(regionStart);
35349       while (hunks.length) {
35350         const nextHunk = hunks[0];
35351         const nextHunkStart = nextHunk.oStart;
35352         if (nextHunkStart > regionEnd)
35353           break;
35354         regionEnd = Math.max(regionEnd, nextHunkStart + nextHunk.oLength);
35355         regionHunks.push(hunks.shift());
35356       }
35357       if (regionHunks.length === 1) {
35358         if (hunk.abLength > 0) {
35359           const buffer = hunk.ab === "a" ? a2 : b2;
35360           results.push({
35361             stable: true,
35362             buffer: hunk.ab,
35363             bufferStart: hunk.abStart,
35364             bufferLength: hunk.abLength,
35365             bufferContent: buffer.slice(hunk.abStart, hunk.abStart + hunk.abLength)
35366           });
35367         }
35368       } else {
35369         let bounds = {
35370           a: [a2.length, -1, o2.length, -1],
35371           b: [b2.length, -1, o2.length, -1]
35372         };
35373         while (regionHunks.length) {
35374           hunk = regionHunks.shift();
35375           const oStart = hunk.oStart;
35376           const oEnd = oStart + hunk.oLength;
35377           const abStart = hunk.abStart;
35378           const abEnd = abStart + hunk.abLength;
35379           let b3 = bounds[hunk.ab];
35380           b3[0] = Math.min(abStart, b3[0]);
35381           b3[1] = Math.max(abEnd, b3[1]);
35382           b3[2] = Math.min(oStart, b3[2]);
35383           b3[3] = Math.max(oEnd, b3[3]);
35384         }
35385         const aStart = bounds.a[0] + (regionStart - bounds.a[2]);
35386         const aEnd = bounds.a[1] + (regionEnd - bounds.a[3]);
35387         const bStart = bounds.b[0] + (regionStart - bounds.b[2]);
35388         const bEnd = bounds.b[1] + (regionEnd - bounds.b[3]);
35389         let result = {
35390           stable: false,
35391           aStart,
35392           aLength: aEnd - aStart,
35393           aContent: a2.slice(aStart, aEnd),
35394           oStart: regionStart,
35395           oLength: regionEnd - regionStart,
35396           oContent: o2.slice(regionStart, regionEnd),
35397           bStart,
35398           bLength: bEnd - bStart,
35399           bContent: b2.slice(bStart, bEnd)
35400         };
35401         results.push(result);
35402       }
35403       currOffset = regionEnd;
35404     }
35405     advanceTo(o2.length);
35406     return results;
35407   }
35408   function diff3Merge(a2, o2, b2, options2) {
35409     let defaults = {
35410       excludeFalseConflicts: true,
35411       stringSeparator: /\s+/
35412     };
35413     options2 = Object.assign(defaults, options2);
35414     if (typeof a2 === "string")
35415       a2 = a2.split(options2.stringSeparator);
35416     if (typeof o2 === "string")
35417       o2 = o2.split(options2.stringSeparator);
35418     if (typeof b2 === "string")
35419       b2 = b2.split(options2.stringSeparator);
35420     let results = [];
35421     const regions = diff3MergeRegions(a2, o2, b2);
35422     let okBuffer = [];
35423     function flushOk() {
35424       if (okBuffer.length) {
35425         results.push({ ok: okBuffer });
35426       }
35427       okBuffer = [];
35428     }
35429     function isFalseConflict(a3, b3) {
35430       if (a3.length !== b3.length)
35431         return false;
35432       for (let i3 = 0; i3 < a3.length; i3++) {
35433         if (a3[i3] !== b3[i3])
35434           return false;
35435       }
35436       return true;
35437     }
35438     regions.forEach((region) => {
35439       if (region.stable) {
35440         okBuffer.push(...region.bufferContent);
35441       } else {
35442         if (options2.excludeFalseConflicts && isFalseConflict(region.aContent, region.bContent)) {
35443           okBuffer.push(...region.aContent);
35444         } else {
35445           flushOk();
35446           results.push({
35447             conflict: {
35448               a: region.aContent,
35449               aIndex: region.aStart,
35450               o: region.oContent,
35451               oIndex: region.oStart,
35452               b: region.bContent,
35453               bIndex: region.bStart
35454             }
35455           });
35456         }
35457       }
35458     });
35459     flushOk();
35460     return results;
35461   }
35462
35463   // modules/actions/merge_remote_changes.js
35464   var import_lodash2 = __toESM(require_lodash());
35465   function actionMergeRemoteChanges(id2, localGraph, remoteGraph, discardTags, formatUser) {
35466     discardTags = discardTags || {};
35467     var _option = "safe";
35468     var _conflicts = [];
35469     function user(d2) {
35470       return typeof formatUser === "function" ? formatUser(d2) : (0, import_lodash2.escape)(d2);
35471     }
35472     function mergeLocation(remote, target) {
35473       function pointEqual(a2, b2) {
35474         var epsilon3 = 1e-6;
35475         return Math.abs(a2[0] - b2[0]) < epsilon3 && Math.abs(a2[1] - b2[1]) < epsilon3;
35476       }
35477       if (_option === "force_local" || pointEqual(target.loc, remote.loc)) {
35478         return target;
35479       }
35480       if (_option === "force_remote") {
35481         return target.update({ loc: remote.loc });
35482       }
35483       _conflicts.push(_t.html("merge_remote_changes.conflict.location", { user: { html: user(remote.user) } }));
35484       return target;
35485     }
35486     function mergeNodes(base, remote, target) {
35487       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.nodes, remote.nodes)) {
35488         return target;
35489       }
35490       if (_option === "force_remote") {
35491         return target.update({ nodes: remote.nodes });
35492       }
35493       var ccount = _conflicts.length;
35494       var o2 = base.nodes || [];
35495       var a2 = target.nodes || [];
35496       var b2 = remote.nodes || [];
35497       var nodes = [];
35498       var hunks = diff3Merge(a2, o2, b2, { excludeFalseConflicts: true });
35499       for (var i3 = 0; i3 < hunks.length; i3++) {
35500         var hunk = hunks[i3];
35501         if (hunk.ok) {
35502           nodes.push.apply(nodes, hunk.ok);
35503         } else {
35504           var c2 = hunk.conflict;
35505           if ((0, import_fast_deep_equal.default)(c2.o, c2.a)) {
35506             nodes.push.apply(nodes, c2.b);
35507           } else if ((0, import_fast_deep_equal.default)(c2.o, c2.b)) {
35508             nodes.push.apply(nodes, c2.a);
35509           } else {
35510             _conflicts.push(_t.html("merge_remote_changes.conflict.nodelist", { user: { html: user(remote.user) } }));
35511             break;
35512           }
35513         }
35514       }
35515       return _conflicts.length === ccount ? target.update({ nodes }) : target;
35516     }
35517     function mergeChildren(targetWay, children2, updates, graph) {
35518       function isUsed(node2, targetWay2) {
35519         var hasInterestingParent = graph.parentWays(node2).some(function(way) {
35520           return way.id !== targetWay2.id;
35521         });
35522         return node2.hasInterestingTags() || hasInterestingParent || graph.parentRelations(node2).length > 0;
35523       }
35524       var ccount = _conflicts.length;
35525       for (var i3 = 0; i3 < children2.length; i3++) {
35526         var id3 = children2[i3];
35527         var node = graph.hasEntity(id3);
35528         if (targetWay.nodes.indexOf(id3) === -1) {
35529           if (node && !isUsed(node, targetWay)) {
35530             updates.removeIds.push(id3);
35531           }
35532           continue;
35533         }
35534         var local = localGraph.hasEntity(id3);
35535         var remote = remoteGraph.hasEntity(id3);
35536         var target;
35537         if (_option === "force_remote" && remote && remote.visible) {
35538           updates.replacements.push(remote);
35539         } else if (_option === "force_local" && local) {
35540           target = osmEntity(local);
35541           if (remote) {
35542             target = target.update({ version: remote.version });
35543           }
35544           updates.replacements.push(target);
35545         } else if (_option === "safe" && local && remote && local.version !== remote.version) {
35546           target = osmEntity(local, { version: remote.version });
35547           if (remote.visible) {
35548             target = mergeLocation(remote, target);
35549           } else {
35550             _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35551           }
35552           if (_conflicts.length !== ccount)
35553             break;
35554           updates.replacements.push(target);
35555         }
35556       }
35557       return targetWay;
35558     }
35559     function updateChildren(updates, graph) {
35560       for (var i3 = 0; i3 < updates.replacements.length; i3++) {
35561         graph = graph.replace(updates.replacements[i3]);
35562       }
35563       if (updates.removeIds.length) {
35564         graph = actionDeleteMultiple(updates.removeIds)(graph);
35565       }
35566       return graph;
35567     }
35568     function mergeMembers(remote, target) {
35569       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.members, remote.members)) {
35570         return target;
35571       }
35572       if (_option === "force_remote") {
35573         return target.update({ members: remote.members });
35574       }
35575       _conflicts.push(_t.html("merge_remote_changes.conflict.memberlist", { user: { html: user(remote.user) } }));
35576       return target;
35577     }
35578     function mergeTags(base, remote, target) {
35579       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.tags, remote.tags)) {
35580         return target;
35581       }
35582       if (_option === "force_remote") {
35583         return target.update({ tags: remote.tags });
35584       }
35585       var ccount = _conflicts.length;
35586       var o2 = base.tags || {};
35587       var a2 = target.tags || {};
35588       var b2 = remote.tags || {};
35589       var keys2 = utilArrayUnion(utilArrayUnion(Object.keys(o2), Object.keys(a2)), Object.keys(b2)).filter(function(k3) {
35590         return !discardTags[k3];
35591       });
35592       var tags = Object.assign({}, a2);
35593       var changed = false;
35594       for (var i3 = 0; i3 < keys2.length; i3++) {
35595         var k2 = keys2[i3];
35596         if (o2[k2] !== b2[k2] && a2[k2] !== b2[k2]) {
35597           if (o2[k2] !== a2[k2]) {
35598             _conflicts.push(_t.html(
35599               "merge_remote_changes.conflict.tags",
35600               { tag: k2, local: a2[k2], remote: b2[k2], user: { html: user(remote.user) } }
35601             ));
35602           } else {
35603             if (b2.hasOwnProperty(k2)) {
35604               tags[k2] = b2[k2];
35605             } else {
35606               delete tags[k2];
35607             }
35608             changed = true;
35609           }
35610         }
35611       }
35612       return changed && _conflicts.length === ccount ? target.update({ tags }) : target;
35613     }
35614     var action = function(graph) {
35615       var updates = { replacements: [], removeIds: [] };
35616       var base = graph.base().entities[id2];
35617       var local = localGraph.entity(id2);
35618       var remote = remoteGraph.entity(id2);
35619       var target = osmEntity(local, { version: remote.version });
35620       if (!remote.visible) {
35621         if (_option === "force_remote") {
35622           return actionDeleteMultiple([id2])(graph);
35623         } else if (_option === "force_local") {
35624           if (target.type === "way") {
35625             target = mergeChildren(target, utilArrayUniq(local.nodes), updates, graph);
35626             graph = updateChildren(updates, graph);
35627           }
35628           return graph.replace(target);
35629         } else {
35630           _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35631           return graph;
35632         }
35633       }
35634       if (target.type === "node") {
35635         target = mergeLocation(remote, target);
35636       } else if (target.type === "way") {
35637         graph.rebase(remoteGraph.childNodes(remote), [graph], false);
35638         target = mergeNodes(base, remote, target);
35639         target = mergeChildren(target, utilArrayUnion(local.nodes, remote.nodes), updates, graph);
35640       } else if (target.type === "relation") {
35641         target = mergeMembers(remote, target);
35642       }
35643       target = mergeTags(base, remote, target);
35644       if (!_conflicts.length) {
35645         graph = updateChildren(updates, graph).replace(target);
35646       }
35647       return graph;
35648     };
35649     action.withOption = function(opt) {
35650       _option = opt;
35651       return action;
35652     };
35653     action.conflicts = function() {
35654       return _conflicts;
35655     };
35656     return action;
35657   }
35658
35659   // modules/actions/move.js
35660   function actionMove(moveIDs, tryDelta, projection2, cache) {
35661     var _delta = tryDelta;
35662     function setupCache(graph) {
35663       function canMove(nodeID) {
35664         if (moveIDs.indexOf(nodeID) !== -1)
35665           return true;
35666         var parents = graph.parentWays(graph.entity(nodeID));
35667         if (parents.length < 3)
35668           return true;
35669         var parentsMoving = parents.every(function(way) {
35670           return cache.moving[way.id];
35671         });
35672         if (!parentsMoving)
35673           delete cache.moving[nodeID];
35674         return parentsMoving;
35675       }
35676       function cacheEntities(ids) {
35677         for (var i3 = 0; i3 < ids.length; i3++) {
35678           var id2 = ids[i3];
35679           if (cache.moving[id2])
35680             continue;
35681           cache.moving[id2] = true;
35682           var entity = graph.hasEntity(id2);
35683           if (!entity)
35684             continue;
35685           if (entity.type === "node") {
35686             cache.nodes.push(id2);
35687             cache.startLoc[id2] = entity.loc;
35688           } else if (entity.type === "way") {
35689             cache.ways.push(id2);
35690             cacheEntities(entity.nodes);
35691           } else {
35692             cacheEntities(entity.members.map(function(member) {
35693               return member.id;
35694             }));
35695           }
35696         }
35697       }
35698       function cacheIntersections(ids) {
35699         function isEndpoint(way2, id3) {
35700           return !way2.isClosed() && !!way2.affix(id3);
35701         }
35702         for (var i3 = 0; i3 < ids.length; i3++) {
35703           var id2 = ids[i3];
35704           var childNodes = graph.childNodes(graph.entity(id2));
35705           for (var j2 = 0; j2 < childNodes.length; j2++) {
35706             var node = childNodes[j2];
35707             var parents = graph.parentWays(node);
35708             if (parents.length !== 2)
35709               continue;
35710             var moved = graph.entity(id2);
35711             var unmoved = null;
35712             for (var k2 = 0; k2 < parents.length; k2++) {
35713               var way = parents[k2];
35714               if (!cache.moving[way.id]) {
35715                 unmoved = way;
35716                 break;
35717               }
35718             }
35719             if (!unmoved)
35720               continue;
35721             if (utilArrayIntersection(moved.nodes, unmoved.nodes).length > 2)
35722               continue;
35723             if (moved.isArea() || unmoved.isArea())
35724               continue;
35725             cache.intersections.push({
35726               nodeId: node.id,
35727               movedId: moved.id,
35728               unmovedId: unmoved.id,
35729               movedIsEP: isEndpoint(moved, node.id),
35730               unmovedIsEP: isEndpoint(unmoved, node.id)
35731             });
35732           }
35733         }
35734       }
35735       if (!cache) {
35736         cache = {};
35737       }
35738       if (!cache.ok) {
35739         cache.moving = {};
35740         cache.intersections = [];
35741         cache.replacedVertex = {};
35742         cache.startLoc = {};
35743         cache.nodes = [];
35744         cache.ways = [];
35745         cacheEntities(moveIDs);
35746         cacheIntersections(cache.ways);
35747         cache.nodes = cache.nodes.filter(canMove);
35748         cache.ok = true;
35749       }
35750     }
35751     function replaceMovedVertex(nodeId, wayId, graph, delta) {
35752       var way = graph.entity(wayId);
35753       var moved = graph.entity(nodeId);
35754       var movedIndex = way.nodes.indexOf(nodeId);
35755       var len, prevIndex, nextIndex;
35756       if (way.isClosed()) {
35757         len = way.nodes.length - 1;
35758         prevIndex = (movedIndex + len - 1) % len;
35759         nextIndex = (movedIndex + len + 1) % len;
35760       } else {
35761         len = way.nodes.length;
35762         prevIndex = movedIndex - 1;
35763         nextIndex = movedIndex + 1;
35764       }
35765       var prev = graph.hasEntity(way.nodes[prevIndex]);
35766       var next = graph.hasEntity(way.nodes[nextIndex]);
35767       if (!prev || !next)
35768         return graph;
35769       var key = wayId + "_" + nodeId;
35770       var orig = cache.replacedVertex[key];
35771       if (!orig) {
35772         orig = osmNode();
35773         cache.replacedVertex[key] = orig;
35774         cache.startLoc[orig.id] = cache.startLoc[nodeId];
35775       }
35776       var start2, end;
35777       if (delta) {
35778         start2 = projection2(cache.startLoc[nodeId]);
35779         end = projection2.invert(geoVecAdd(start2, delta));
35780       } else {
35781         end = cache.startLoc[nodeId];
35782       }
35783       orig = orig.move(end);
35784       var angle2 = Math.abs(geoAngle(orig, prev, projection2) - geoAngle(orig, next, projection2)) * 180 / Math.PI;
35785       if (angle2 > 175 && angle2 < 185)
35786         return graph;
35787       var p1 = [prev.loc, orig.loc, moved.loc, next.loc].map(projection2);
35788       var p2 = [prev.loc, moved.loc, orig.loc, next.loc].map(projection2);
35789       var d1 = geoPathLength(p1);
35790       var d2 = geoPathLength(p2);
35791       var insertAt = d1 <= d2 ? movedIndex : nextIndex;
35792       if (way.isClosed() && insertAt === 0)
35793         insertAt = len;
35794       way = way.addNode(orig.id, insertAt);
35795       return graph.replace(orig).replace(way);
35796     }
35797     function removeDuplicateVertices(wayId, graph) {
35798       var way = graph.entity(wayId);
35799       var epsilon3 = 1e-6;
35800       var prev, curr;
35801       function isInteresting(node, graph2) {
35802         return graph2.parentWays(node).length > 1 || graph2.parentRelations(node).length || node.hasInterestingTags();
35803       }
35804       for (var i3 = 0; i3 < way.nodes.length; i3++) {
35805         curr = graph.entity(way.nodes[i3]);
35806         if (prev && curr && geoVecEqual(prev.loc, curr.loc, epsilon3)) {
35807           if (!isInteresting(prev, graph)) {
35808             way = way.removeNode(prev.id);
35809             graph = graph.replace(way).remove(prev);
35810           } else if (!isInteresting(curr, graph)) {
35811             way = way.removeNode(curr.id);
35812             graph = graph.replace(way).remove(curr);
35813           }
35814         }
35815         prev = curr;
35816       }
35817       return graph;
35818     }
35819     function unZorroIntersection(intersection2, graph) {
35820       var vertex = graph.entity(intersection2.nodeId);
35821       var way1 = graph.entity(intersection2.movedId);
35822       var way2 = graph.entity(intersection2.unmovedId);
35823       var isEP1 = intersection2.movedIsEP;
35824       var isEP2 = intersection2.unmovedIsEP;
35825       if (isEP1 && isEP2)
35826         return graph;
35827       var nodes1 = graph.childNodes(way1).filter(function(n3) {
35828         return n3 !== vertex;
35829       });
35830       var nodes2 = graph.childNodes(way2).filter(function(n3) {
35831         return n3 !== vertex;
35832       });
35833       if (way1.isClosed() && way1.first() === vertex.id)
35834         nodes1.push(nodes1[0]);
35835       if (way2.isClosed() && way2.first() === vertex.id)
35836         nodes2.push(nodes2[0]);
35837       var edge1 = !isEP1 && geoChooseEdge(nodes1, projection2(vertex.loc), projection2);
35838       var edge2 = !isEP2 && geoChooseEdge(nodes2, projection2(vertex.loc), projection2);
35839       var loc;
35840       if (!isEP1 && !isEP2) {
35841         var epsilon3 = 1e-6, maxIter = 10;
35842         for (var i3 = 0; i3 < maxIter; i3++) {
35843           loc = geoVecInterp(edge1.loc, edge2.loc, 0.5);
35844           edge1 = geoChooseEdge(nodes1, projection2(loc), projection2);
35845           edge2 = geoChooseEdge(nodes2, projection2(loc), projection2);
35846           if (Math.abs(edge1.distance - edge2.distance) < epsilon3)
35847             break;
35848         }
35849       } else if (!isEP1) {
35850         loc = edge1.loc;
35851       } else {
35852         loc = edge2.loc;
35853       }
35854       graph = graph.replace(vertex.move(loc));
35855       if (!isEP1 && edge1.index !== way1.nodes.indexOf(vertex.id)) {
35856         way1 = way1.removeNode(vertex.id).addNode(vertex.id, edge1.index);
35857         graph = graph.replace(way1);
35858       }
35859       if (!isEP2 && edge2.index !== way2.nodes.indexOf(vertex.id)) {
35860         way2 = way2.removeNode(vertex.id).addNode(vertex.id, edge2.index);
35861         graph = graph.replace(way2);
35862       }
35863       return graph;
35864     }
35865     function cleanupIntersections(graph) {
35866       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35867         var obj = cache.intersections[i3];
35868         graph = replaceMovedVertex(obj.nodeId, obj.movedId, graph, _delta);
35869         graph = replaceMovedVertex(obj.nodeId, obj.unmovedId, graph, null);
35870         graph = unZorroIntersection(obj, graph);
35871         graph = removeDuplicateVertices(obj.movedId, graph);
35872         graph = removeDuplicateVertices(obj.unmovedId, graph);
35873       }
35874       return graph;
35875     }
35876     function limitDelta(graph) {
35877       function moveNode(loc) {
35878         return geoVecAdd(projection2(loc), _delta);
35879       }
35880       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35881         var obj = cache.intersections[i3];
35882         if (obj.movedIsEP && obj.unmovedIsEP)
35883           continue;
35884         if (!obj.movedIsEP)
35885           continue;
35886         var node = graph.entity(obj.nodeId);
35887         var start2 = projection2(node.loc);
35888         var end = geoVecAdd(start2, _delta);
35889         var movedNodes = graph.childNodes(graph.entity(obj.movedId));
35890         var movedPath = movedNodes.map(function(n3) {
35891           return moveNode(n3.loc);
35892         });
35893         var unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId));
35894         var unmovedPath = unmovedNodes.map(function(n3) {
35895           return projection2(n3.loc);
35896         });
35897         var hits = geoPathIntersections(movedPath, unmovedPath);
35898         for (var j2 = 0; i3 < hits.length; i3++) {
35899           if (geoVecEqual(hits[j2], end))
35900             continue;
35901           var edge = geoChooseEdge(unmovedNodes, end, projection2);
35902           _delta = geoVecSubtract(projection2(edge.loc), start2);
35903         }
35904       }
35905     }
35906     var action = function(graph) {
35907       if (_delta[0] === 0 && _delta[1] === 0)
35908         return graph;
35909       setupCache(graph);
35910       if (cache.intersections.length) {
35911         limitDelta(graph);
35912       }
35913       for (var i3 = 0; i3 < cache.nodes.length; i3++) {
35914         var node = graph.entity(cache.nodes[i3]);
35915         var start2 = projection2(node.loc);
35916         var end = geoVecAdd(start2, _delta);
35917         graph = graph.replace(node.move(projection2.invert(end)));
35918       }
35919       if (cache.intersections.length) {
35920         graph = cleanupIntersections(graph);
35921       }
35922       return graph;
35923     };
35924     action.delta = function() {
35925       return _delta;
35926     };
35927     return action;
35928   }
35929
35930   // modules/actions/move_member.js
35931   function actionMoveMember(relationId, fromIndex, toIndex) {
35932     return function(graph) {
35933       return graph.replace(graph.entity(relationId).moveMember(fromIndex, toIndex));
35934     };
35935   }
35936
35937   // modules/actions/move_node.js
35938   function actionMoveNode(nodeID, toLoc) {
35939     var action = function(graph, t2) {
35940       if (t2 === null || !isFinite(t2))
35941         t2 = 1;
35942       t2 = Math.min(Math.max(+t2, 0), 1);
35943       var node = graph.entity(nodeID);
35944       return graph.replace(
35945         node.move(geoVecInterp(node.loc, toLoc, t2))
35946       );
35947     };
35948     action.transitionable = true;
35949     return action;
35950   }
35951
35952   // modules/actions/noop.js
35953   function actionNoop() {
35954     return function(graph) {
35955       return graph;
35956     };
35957   }
35958
35959   // modules/actions/orthogonalize.js
35960   function actionOrthogonalize(wayID, projection2, vertexID, degThresh, ep) {
35961     var epsilon3 = ep || 1e-4;
35962     var threshold = degThresh || 13;
35963     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
35964     var upperThreshold = Math.cos(threshold * Math.PI / 180);
35965     var action = function(graph, t2) {
35966       if (t2 === null || !isFinite(t2))
35967         t2 = 1;
35968       t2 = Math.min(Math.max(+t2, 0), 1);
35969       var way = graph.entity(wayID);
35970       way = way.removeNode("");
35971       if (way.tags.nonsquare) {
35972         var tags = Object.assign({}, way.tags);
35973         delete tags.nonsquare;
35974         way = way.update({ tags });
35975       }
35976       graph = graph.replace(way);
35977       var isClosed = way.isClosed();
35978       var nodes = graph.childNodes(way).slice();
35979       if (isClosed)
35980         nodes.pop();
35981       if (vertexID !== void 0) {
35982         nodes = nodeSubset(nodes, vertexID, isClosed);
35983         if (nodes.length !== 3)
35984           return graph;
35985       }
35986       var nodeCount = {};
35987       var points = [];
35988       var corner = { i: 0, dotp: 1 };
35989       var node, point2, loc, score, motions, i3, j2;
35990       for (i3 = 0; i3 < nodes.length; i3++) {
35991         node = nodes[i3];
35992         nodeCount[node.id] = (nodeCount[node.id] || 0) + 1;
35993         points.push({ id: node.id, coord: projection2(node.loc) });
35994       }
35995       if (points.length === 3) {
35996         for (i3 = 0; i3 < 1e3; i3++) {
35997           motions = points.map(calcMotion);
35998           points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]);
35999           score = corner.dotp;
36000           if (score < epsilon3) {
36001             break;
36002           }
36003         }
36004         node = graph.entity(nodes[corner.i].id);
36005         loc = projection2.invert(points[corner.i].coord);
36006         graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36007       } else {
36008         var straights = [];
36009         var simplified = [];
36010         for (i3 = 0; i3 < points.length; i3++) {
36011           point2 = points[i3];
36012           var dotp = 0;
36013           if (isClosed || i3 > 0 && i3 < points.length - 1) {
36014             var a2 = points[(i3 - 1 + points.length) % points.length];
36015             var b2 = points[(i3 + 1) % points.length];
36016             dotp = Math.abs(geoOrthoNormalizedDotProduct(a2.coord, b2.coord, point2.coord));
36017           }
36018           if (dotp > upperThreshold) {
36019             straights.push(point2);
36020           } else {
36021             simplified.push(point2);
36022           }
36023         }
36024         var bestPoints = clonePoints(simplified);
36025         var originalPoints = clonePoints(simplified);
36026         score = Infinity;
36027         for (i3 = 0; i3 < 1e3; i3++) {
36028           motions = simplified.map(calcMotion);
36029           for (j2 = 0; j2 < motions.length; j2++) {
36030             simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]);
36031           }
36032           var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold);
36033           if (newScore < score) {
36034             bestPoints = clonePoints(simplified);
36035             score = newScore;
36036           }
36037           if (score < epsilon3) {
36038             break;
36039           }
36040         }
36041         var bestCoords = bestPoints.map(function(p2) {
36042           return p2.coord;
36043         });
36044         if (isClosed)
36045           bestCoords.push(bestCoords[0]);
36046         for (i3 = 0; i3 < bestPoints.length; i3++) {
36047           point2 = bestPoints[i3];
36048           if (!geoVecEqual(originalPoints[i3].coord, point2.coord)) {
36049             node = graph.entity(point2.id);
36050             loc = projection2.invert(point2.coord);
36051             graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36052           }
36053         }
36054         for (i3 = 0; i3 < straights.length; i3++) {
36055           point2 = straights[i3];
36056           if (nodeCount[point2.id] > 1)
36057             continue;
36058           node = graph.entity(point2.id);
36059           if (t2 === 1 && graph.parentWays(node).length === 1 && graph.parentRelations(node).length === 0 && !node.hasInterestingTags()) {
36060             graph = actionDeleteNode(node.id)(graph);
36061           } else {
36062             var choice = geoVecProject(point2.coord, bestCoords);
36063             if (choice) {
36064               loc = projection2.invert(choice.target);
36065               graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36066             }
36067           }
36068         }
36069       }
36070       return graph;
36071       function clonePoints(array2) {
36072         return array2.map(function(p2) {
36073           return { id: p2.id, coord: [p2.coord[0], p2.coord[1]] };
36074         });
36075       }
36076       function calcMotion(point3, i4, array2) {
36077         if (!isClosed && (i4 === 0 || i4 === array2.length - 1))
36078           return [0, 0];
36079         if (nodeCount[array2[i4].id] > 1)
36080           return [0, 0];
36081         var a3 = array2[(i4 - 1 + array2.length) % array2.length].coord;
36082         var origin = point3.coord;
36083         var b3 = array2[(i4 + 1) % array2.length].coord;
36084         var p2 = geoVecSubtract(a3, origin);
36085         var q2 = geoVecSubtract(b3, origin);
36086         var scale = 2 * Math.min(geoVecLength(p2), geoVecLength(q2));
36087         p2 = geoVecNormalize(p2);
36088         q2 = geoVecNormalize(q2);
36089         var dotp2 = p2[0] * q2[0] + p2[1] * q2[1];
36090         var val = Math.abs(dotp2);
36091         if (val < lowerThreshold) {
36092           corner.i = i4;
36093           corner.dotp = val;
36094           var vec = geoVecNormalize(geoVecAdd(p2, q2));
36095           return geoVecScale(vec, 0.1 * dotp2 * scale);
36096         }
36097         return [0, 0];
36098       }
36099     };
36100     function nodeSubset(nodes, vertexID2, isClosed) {
36101       var first = isClosed ? 0 : 1;
36102       var last = isClosed ? nodes.length : nodes.length - 1;
36103       for (var i3 = first; i3 < last; i3++) {
36104         if (nodes[i3].id === vertexID2) {
36105           return [
36106             nodes[(i3 - 1 + nodes.length) % nodes.length],
36107             nodes[i3],
36108             nodes[(i3 + 1) % nodes.length]
36109           ];
36110         }
36111       }
36112       return [];
36113     }
36114     action.disabled = function(graph) {
36115       var way = graph.entity(wayID);
36116       way = way.removeNode("");
36117       graph = graph.replace(way);
36118       var isClosed = way.isClosed();
36119       var nodes = graph.childNodes(way).slice();
36120       if (isClosed)
36121         nodes.pop();
36122       var allowStraightAngles = false;
36123       if (vertexID !== void 0) {
36124         allowStraightAngles = true;
36125         nodes = nodeSubset(nodes, vertexID, isClosed);
36126         if (nodes.length !== 3)
36127           return "end_vertex";
36128       }
36129       var coords = nodes.map(function(n3) {
36130         return projection2(n3.loc);
36131       });
36132       var score = geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles);
36133       if (score === null) {
36134         return "not_squarish";
36135       } else if (score === 0) {
36136         return "square_enough";
36137       } else {
36138         return false;
36139       }
36140     };
36141     action.transitionable = true;
36142     return action;
36143   }
36144
36145   // modules/actions/restrict_turn.js
36146   function actionRestrictTurn(turn, restrictionType, restrictionID) {
36147     return function(graph) {
36148       var fromWay = graph.entity(turn.from.way);
36149       var toWay = graph.entity(turn.to.way);
36150       var viaNode = turn.via.node && graph.entity(turn.via.node);
36151       var viaWays = turn.via.ways && turn.via.ways.map(function(id2) {
36152         return graph.entity(id2);
36153       });
36154       var members = [];
36155       members.push({ id: fromWay.id, type: "way", role: "from" });
36156       if (viaNode) {
36157         members.push({ id: viaNode.id, type: "node", role: "via" });
36158       } else if (viaWays) {
36159         viaWays.forEach(function(viaWay) {
36160           members.push({ id: viaWay.id, type: "way", role: "via" });
36161         });
36162       }
36163       members.push({ id: toWay.id, type: "way", role: "to" });
36164       return graph.replace(osmRelation({
36165         id: restrictionID,
36166         tags: {
36167           type: "restriction",
36168           restriction: restrictionType
36169         },
36170         members
36171       }));
36172     };
36173   }
36174
36175   // modules/actions/revert.js
36176   function actionRevert(id2) {
36177     var action = function(graph) {
36178       var entity = graph.hasEntity(id2), base = graph.base().entities[id2];
36179       if (entity && !base) {
36180         if (entity.type === "node") {
36181           graph.parentWays(entity).forEach(function(parent) {
36182             parent = parent.removeNode(id2);
36183             graph = graph.replace(parent);
36184             if (parent.isDegenerate()) {
36185               graph = actionDeleteWay(parent.id)(graph);
36186             }
36187           });
36188         }
36189         graph.parentRelations(entity).forEach(function(parent) {
36190           parent = parent.removeMembersWithID(id2);
36191           graph = graph.replace(parent);
36192           if (parent.isDegenerate()) {
36193             graph = actionDeleteRelation(parent.id)(graph);
36194           }
36195         });
36196       }
36197       return graph.revert(id2);
36198     };
36199     return action;
36200   }
36201
36202   // modules/actions/rotate.js
36203   function actionRotate(rotateIds, pivot, angle2, projection2) {
36204     var action = function(graph) {
36205       return graph.update(function(graph2) {
36206         utilGetAllNodes(rotateIds, graph2).forEach(function(node) {
36207           var point2 = geoRotate([projection2(node.loc)], angle2, pivot)[0];
36208           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36209         });
36210       });
36211     };
36212     return action;
36213   }
36214
36215   // modules/actions/scale.js
36216   function actionScale(ids, pivotLoc, scaleFactor, projection2) {
36217     return function(graph) {
36218       return graph.update(function(graph2) {
36219         let point2, radial;
36220         utilGetAllNodes(ids, graph2).forEach(function(node) {
36221           point2 = projection2(node.loc);
36222           radial = [
36223             point2[0] - pivotLoc[0],
36224             point2[1] - pivotLoc[1]
36225           ];
36226           point2 = [
36227             pivotLoc[0] + scaleFactor * radial[0],
36228             pivotLoc[1] + scaleFactor * radial[1]
36229           ];
36230           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36231         });
36232       });
36233     };
36234   }
36235
36236   // modules/actions/straighten_nodes.js
36237   function actionStraightenNodes(nodeIDs, projection2) {
36238     function positionAlongWay(a2, o2, b2) {
36239       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36240     }
36241     function getEndpoints(points) {
36242       var ssr = geoGetSmallestSurroundingRectangle(points);
36243       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36244       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36245       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36246       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36247       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36248       if (isLong) {
36249         return [p1, q1];
36250       }
36251       return [p2, q2];
36252     }
36253     var action = function(graph, t2) {
36254       if (t2 === null || !isFinite(t2))
36255         t2 = 1;
36256       t2 = Math.min(Math.max(+t2, 0), 1);
36257       var nodes = nodeIDs.map(function(id2) {
36258         return graph.entity(id2);
36259       });
36260       var points = nodes.map(function(n3) {
36261         return projection2(n3.loc);
36262       });
36263       var endpoints = getEndpoints(points);
36264       var startPoint = endpoints[0];
36265       var endPoint = endpoints[1];
36266       for (var i3 = 0; i3 < points.length; i3++) {
36267         var node = nodes[i3];
36268         var point2 = points[i3];
36269         var u2 = positionAlongWay(point2, startPoint, endPoint);
36270         var point22 = geoVecInterp(startPoint, endPoint, u2);
36271         var loc2 = projection2.invert(point22);
36272         graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36273       }
36274       return graph;
36275     };
36276     action.disabled = function(graph) {
36277       var nodes = nodeIDs.map(function(id2) {
36278         return graph.entity(id2);
36279       });
36280       var points = nodes.map(function(n3) {
36281         return projection2(n3.loc);
36282       });
36283       var endpoints = getEndpoints(points);
36284       var startPoint = endpoints[0];
36285       var endPoint = endpoints[1];
36286       var maxDistance = 0;
36287       for (var i3 = 0; i3 < points.length; i3++) {
36288         var point2 = points[i3];
36289         var u2 = positionAlongWay(point2, startPoint, endPoint);
36290         var p2 = geoVecInterp(startPoint, endPoint, u2);
36291         var dist = geoVecLength(p2, point2);
36292         if (!isNaN(dist) && dist > maxDistance) {
36293           maxDistance = dist;
36294         }
36295       }
36296       if (maxDistance < 1e-4) {
36297         return "straight_enough";
36298       }
36299     };
36300     action.transitionable = true;
36301     return action;
36302   }
36303
36304   // modules/actions/straighten_way.js
36305   function actionStraightenWay(selectedIDs, projection2) {
36306     function positionAlongWay(a2, o2, b2) {
36307       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36308     }
36309     function allNodes(graph) {
36310       var nodes = [];
36311       var startNodes = [];
36312       var endNodes = [];
36313       var remainingWays = [];
36314       var selectedWays = selectedIDs.filter(function(w2) {
36315         return graph.entity(w2).type === "way";
36316       });
36317       var selectedNodes = selectedIDs.filter(function(n3) {
36318         return graph.entity(n3).type === "node";
36319       });
36320       for (var i3 = 0; i3 < selectedWays.length; i3++) {
36321         var way = graph.entity(selectedWays[i3]);
36322         nodes = way.nodes.slice(0);
36323         remainingWays.push(nodes);
36324         startNodes.push(nodes[0]);
36325         endNodes.push(nodes[nodes.length - 1]);
36326       }
36327       startNodes = startNodes.filter(function(n3) {
36328         return startNodes.indexOf(n3) === startNodes.lastIndexOf(n3);
36329       });
36330       endNodes = endNodes.filter(function(n3) {
36331         return endNodes.indexOf(n3) === endNodes.lastIndexOf(n3);
36332       });
36333       var currNode = utilArrayDifference(startNodes, endNodes).concat(utilArrayDifference(endNodes, startNodes))[0];
36334       var nextWay = [];
36335       nodes = [];
36336       var getNextWay = function(currNode2, remainingWays2) {
36337         return remainingWays2.filter(function(way2) {
36338           return way2[0] === currNode2 || way2[way2.length - 1] === currNode2;
36339         })[0];
36340       };
36341       while (remainingWays.length) {
36342         nextWay = getNextWay(currNode, remainingWays);
36343         remainingWays = utilArrayDifference(remainingWays, [nextWay]);
36344         if (nextWay[0] !== currNode) {
36345           nextWay.reverse();
36346         }
36347         nodes = nodes.concat(nextWay);
36348         currNode = nodes[nodes.length - 1];
36349       }
36350       if (selectedNodes.length === 2) {
36351         var startNodeIdx = nodes.indexOf(selectedNodes[0]);
36352         var endNodeIdx = nodes.indexOf(selectedNodes[1]);
36353         var sortedStartEnd = [startNodeIdx, endNodeIdx];
36354         sortedStartEnd.sort(function(a2, b2) {
36355           return a2 - b2;
36356         });
36357         nodes = nodes.slice(sortedStartEnd[0], sortedStartEnd[1] + 1);
36358       }
36359       return nodes.map(function(n3) {
36360         return graph.entity(n3);
36361       });
36362     }
36363     function shouldKeepNode(node, graph) {
36364       return graph.parentWays(node).length > 1 || graph.parentRelations(node).length || node.hasInterestingTags();
36365     }
36366     var action = function(graph, t2) {
36367       if (t2 === null || !isFinite(t2))
36368         t2 = 1;
36369       t2 = Math.min(Math.max(+t2, 0), 1);
36370       var nodes = allNodes(graph);
36371       var points = nodes.map(function(n3) {
36372         return projection2(n3.loc);
36373       });
36374       var startPoint = points[0];
36375       var endPoint = points[points.length - 1];
36376       var toDelete = [];
36377       var i3;
36378       for (i3 = 1; i3 < points.length - 1; i3++) {
36379         var node = nodes[i3];
36380         var point2 = points[i3];
36381         if (t2 < 1 || shouldKeepNode(node, graph)) {
36382           var u2 = positionAlongWay(point2, startPoint, endPoint);
36383           var p2 = geoVecInterp(startPoint, endPoint, u2);
36384           var loc2 = projection2.invert(p2);
36385           graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36386         } else {
36387           if (toDelete.indexOf(node) === -1) {
36388             toDelete.push(node);
36389           }
36390         }
36391       }
36392       for (i3 = 0; i3 < toDelete.length; i3++) {
36393         graph = actionDeleteNode(toDelete[i3].id)(graph);
36394       }
36395       return graph;
36396     };
36397     action.disabled = function(graph) {
36398       var nodes = allNodes(graph);
36399       var points = nodes.map(function(n3) {
36400         return projection2(n3.loc);
36401       });
36402       var startPoint = points[0];
36403       var endPoint = points[points.length - 1];
36404       var threshold = 0.2 * geoVecLength(startPoint, endPoint);
36405       var i3;
36406       if (threshold === 0) {
36407         return "too_bendy";
36408       }
36409       var maxDistance = 0;
36410       for (i3 = 1; i3 < points.length - 1; i3++) {
36411         var point2 = points[i3];
36412         var u2 = positionAlongWay(point2, startPoint, endPoint);
36413         var p2 = geoVecInterp(startPoint, endPoint, u2);
36414         var dist = geoVecLength(p2, point2);
36415         if (isNaN(dist) || dist > threshold) {
36416           return "too_bendy";
36417         } else if (dist > maxDistance) {
36418           maxDistance = dist;
36419         }
36420       }
36421       var keepingAllNodes = nodes.every(function(node, i4) {
36422         return i4 === 0 || i4 === nodes.length - 1 || shouldKeepNode(node, graph);
36423       });
36424       if (maxDistance < 1e-4 && // Allow straightening even if already straight in order to remove extraneous nodes
36425       keepingAllNodes) {
36426         return "straight_enough";
36427       }
36428     };
36429     action.transitionable = true;
36430     return action;
36431   }
36432
36433   // modules/actions/unrestrict_turn.js
36434   function actionUnrestrictTurn(turn) {
36435     return function(graph) {
36436       return actionDeleteRelation(turn.restrictionID)(graph);
36437     };
36438   }
36439
36440   // modules/actions/reflect.js
36441   function actionReflect(reflectIds, projection2) {
36442     var _useLongAxis = true;
36443     var action = function(graph, t2) {
36444       if (t2 === null || !isFinite(t2))
36445         t2 = 1;
36446       t2 = Math.min(Math.max(+t2, 0), 1);
36447       var nodes = utilGetAllNodes(reflectIds, graph);
36448       var points = nodes.map(function(n3) {
36449         return projection2(n3.loc);
36450       });
36451       var ssr = geoGetSmallestSurroundingRectangle(points);
36452       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36453       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36454       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36455       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36456       var p3, q3;
36457       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36458       if (_useLongAxis && isLong || !_useLongAxis && !isLong) {
36459         p3 = p1;
36460         q3 = q1;
36461       } else {
36462         p3 = p2;
36463         q3 = q2;
36464       }
36465       var dx = q3[0] - p3[0];
36466       var dy = q3[1] - p3[1];
36467       var a2 = (dx * dx - dy * dy) / (dx * dx + dy * dy);
36468       var b2 = 2 * dx * dy / (dx * dx + dy * dy);
36469       for (var i3 = 0; i3 < nodes.length; i3++) {
36470         var node = nodes[i3];
36471         var c2 = projection2(node.loc);
36472         var c22 = [
36473           a2 * (c2[0] - p3[0]) + b2 * (c2[1] - p3[1]) + p3[0],
36474           b2 * (c2[0] - p3[0]) - a2 * (c2[1] - p3[1]) + p3[1]
36475         ];
36476         var loc2 = projection2.invert(c22);
36477         node = node.move(geoVecInterp(node.loc, loc2, t2));
36478         graph = graph.replace(node);
36479       }
36480       return graph;
36481     };
36482     action.useLongAxis = function(val) {
36483       if (!arguments.length)
36484         return _useLongAxis;
36485       _useLongAxis = val;
36486       return action;
36487     };
36488     action.transitionable = true;
36489     return action;
36490   }
36491
36492   // modules/actions/upgrade_tags.js
36493   function actionUpgradeTags(entityId, oldTags, replaceTags) {
36494     return function(graph) {
36495       var entity = graph.entity(entityId);
36496       var tags = Object.assign({}, entity.tags);
36497       var transferValue;
36498       var semiIndex;
36499       for (var oldTagKey in oldTags) {
36500         if (!(oldTagKey in tags))
36501           continue;
36502         if (oldTags[oldTagKey] === "*") {
36503           transferValue = tags[oldTagKey];
36504           delete tags[oldTagKey];
36505         } else if (oldTags[oldTagKey] === tags[oldTagKey]) {
36506           delete tags[oldTagKey];
36507         } else {
36508           var vals = tags[oldTagKey].split(";").filter(Boolean);
36509           var oldIndex = vals.indexOf(oldTags[oldTagKey]);
36510           if (vals.length === 1 || oldIndex === -1) {
36511             delete tags[oldTagKey];
36512           } else {
36513             if (replaceTags && replaceTags[oldTagKey]) {
36514               semiIndex = oldIndex;
36515             }
36516             vals.splice(oldIndex, 1);
36517             tags[oldTagKey] = vals.join(";");
36518           }
36519         }
36520       }
36521       if (replaceTags) {
36522         for (var replaceKey in replaceTags) {
36523           var replaceValue = replaceTags[replaceKey];
36524           if (replaceValue === "*") {
36525             if (tags[replaceKey] && tags[replaceKey] !== "no") {
36526               continue;
36527             } else {
36528               tags[replaceKey] = "yes";
36529             }
36530           } else if (replaceValue === "$1") {
36531             tags[replaceKey] = transferValue;
36532           } else {
36533             if (tags[replaceKey] && oldTags[replaceKey] && semiIndex !== void 0) {
36534               var existingVals = tags[replaceKey].split(";").filter(Boolean);
36535               if (existingVals.indexOf(replaceValue) === -1) {
36536                 existingVals.splice(semiIndex, 0, replaceValue);
36537                 tags[replaceKey] = existingVals.join(";");
36538               }
36539             } else {
36540               tags[replaceKey] = replaceValue;
36541             }
36542           }
36543         }
36544       }
36545       return graph.replace(entity.update({ tags }));
36546     };
36547   }
36548
36549   // modules/behavior/edit.js
36550   function behaviorEdit(context) {
36551     function behavior() {
36552       context.map().minzoom(context.minEditableZoom());
36553     }
36554     behavior.off = function() {
36555       context.map().minzoom(0);
36556     };
36557     return behavior;
36558   }
36559
36560   // modules/behavior/hover.js
36561   function behaviorHover(context) {
36562     var dispatch14 = dispatch_default("hover");
36563     var _selection = select_default2(null);
36564     var _newNodeId = null;
36565     var _initialNodeID = null;
36566     var _altDisables;
36567     var _ignoreVertex;
36568     var _targets = [];
36569     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36570     function keydown(d3_event) {
36571       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36572         _selection.selectAll(".hover").classed("hover-suppressed", true).classed("hover", false);
36573         _selection.classed("hover-disabled", true);
36574         dispatch14.call("hover", this, null);
36575       }
36576     }
36577     function keyup(d3_event) {
36578       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36579         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false).classed("hover", true);
36580         _selection.classed("hover-disabled", false);
36581         dispatch14.call("hover", this, _targets);
36582       }
36583     }
36584     function behavior(selection2) {
36585       _selection = selection2;
36586       _targets = [];
36587       if (_initialNodeID) {
36588         _newNodeId = _initialNodeID;
36589         _initialNodeID = null;
36590       } else {
36591         _newNodeId = null;
36592       }
36593       _selection.on(_pointerPrefix + "over.hover", pointerover).on(_pointerPrefix + "out.hover", pointerout).on(_pointerPrefix + "down.hover", pointerover);
36594       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", pointerout, true).on("keydown.hover", keydown).on("keyup.hover", keyup);
36595       function eventTarget(d3_event) {
36596         var datum2 = d3_event.target && d3_event.target.__data__;
36597         if (typeof datum2 !== "object")
36598           return null;
36599         if (!(datum2 instanceof osmEntity) && datum2.properties && datum2.properties.entity instanceof osmEntity) {
36600           return datum2.properties.entity;
36601         }
36602         return datum2;
36603       }
36604       function pointerover(d3_event) {
36605         if (context.mode().id.indexOf("drag") === -1 && (!d3_event.pointerType || d3_event.pointerType === "mouse") && d3_event.buttons)
36606           return;
36607         var target = eventTarget(d3_event);
36608         if (target && _targets.indexOf(target) === -1) {
36609           _targets.push(target);
36610           updateHover(d3_event, _targets);
36611         }
36612       }
36613       function pointerout(d3_event) {
36614         var target = eventTarget(d3_event);
36615         var index = _targets.indexOf(target);
36616         if (index !== -1) {
36617           _targets.splice(index);
36618           updateHover(d3_event, _targets);
36619         }
36620       }
36621       function allowsVertex(d2) {
36622         return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36623       }
36624       function modeAllowsHover(target) {
36625         var mode = context.mode();
36626         if (mode.id === "add-point") {
36627           return mode.preset.matchGeometry("vertex") || target.type !== "way" && target.geometry(context.graph()) !== "vertex";
36628         }
36629         return true;
36630       }
36631       function updateHover(d3_event, targets) {
36632         _selection.selectAll(".hover").classed("hover", false);
36633         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36634         var mode = context.mode();
36635         if (!_newNodeId && (mode.id === "draw-line" || mode.id === "draw-area")) {
36636           var node = targets.find(function(target) {
36637             return target instanceof osmEntity && target.type === "node";
36638           });
36639           _newNodeId = node && node.id;
36640         }
36641         targets = targets.filter(function(datum3) {
36642           if (datum3 instanceof osmEntity) {
36643             return datum3.id !== _newNodeId && (datum3.type !== "node" || !_ignoreVertex || allowsVertex(datum3)) && modeAllowsHover(datum3);
36644           }
36645           return true;
36646         });
36647         var selector = "";
36648         for (var i3 in targets) {
36649           var datum2 = targets[i3];
36650           if (datum2.__featurehash__) {
36651             selector += ", .data" + datum2.__featurehash__;
36652           } else if (datum2 instanceof QAItem) {
36653             selector += ", ." + datum2.service + ".itemId-" + datum2.id;
36654           } else if (datum2 instanceof osmNote) {
36655             selector += ", .note-" + datum2.id;
36656           } else if (datum2 instanceof osmEntity) {
36657             selector += ", ." + datum2.id;
36658             if (datum2.type === "relation") {
36659               for (var j2 in datum2.members) {
36660                 selector += ", ." + datum2.members[j2].id;
36661               }
36662             }
36663           }
36664         }
36665         var suppressed = _altDisables && d3_event && d3_event.altKey;
36666         if (selector.trim().length) {
36667           selector = selector.slice(1);
36668           _selection.selectAll(selector).classed(suppressed ? "hover-suppressed" : "hover", true);
36669         }
36670         dispatch14.call("hover", this, !suppressed && targets);
36671       }
36672     }
36673     behavior.off = function(selection2) {
36674       selection2.selectAll(".hover").classed("hover", false);
36675       selection2.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36676       selection2.classed("hover-disabled", false);
36677       selection2.on(_pointerPrefix + "over.hover", null).on(_pointerPrefix + "out.hover", null).on(_pointerPrefix + "down.hover", null);
36678       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", null, true).on("keydown.hover", null).on("keyup.hover", null);
36679     };
36680     behavior.altDisables = function(val) {
36681       if (!arguments.length)
36682         return _altDisables;
36683       _altDisables = val;
36684       return behavior;
36685     };
36686     behavior.ignoreVertex = function(val) {
36687       if (!arguments.length)
36688         return _ignoreVertex;
36689       _ignoreVertex = val;
36690       return behavior;
36691     };
36692     behavior.initialNodeID = function(nodeId) {
36693       _initialNodeID = nodeId;
36694       return behavior;
36695     };
36696     return utilRebind(behavior, dispatch14, "on");
36697   }
36698
36699   // modules/behavior/draw.js
36700   var _disableSpace = false;
36701   var _lastSpace = null;
36702   function behaviorDraw(context) {
36703     var dispatch14 = dispatch_default(
36704       "move",
36705       "down",
36706       "downcancel",
36707       "click",
36708       "clickWay",
36709       "clickNode",
36710       "undo",
36711       "cancel",
36712       "finish"
36713     );
36714     var keybinding = utilKeybinding("draw");
36715     var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true).on("hover", context.ui().sidebar.hover);
36716     var _edit = behaviorEdit(context);
36717     var _closeTolerance = 4;
36718     var _tolerance = 12;
36719     var _mouseLeave = false;
36720     var _lastMouse = null;
36721     var _lastPointerUpEvent;
36722     var _downPointer;
36723     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36724     function datum2(d3_event) {
36725       var mode = context.mode();
36726       var isNote = mode && mode.id.indexOf("note") !== -1;
36727       if (d3_event.altKey || isNote)
36728         return {};
36729       var element;
36730       if (d3_event.type === "keydown") {
36731         element = _lastMouse && _lastMouse.target;
36732       } else {
36733         element = d3_event.target;
36734       }
36735       var d2 = element.__data__;
36736       return d2 && d2.properties && d2.properties.target ? d2 : {};
36737     }
36738     function pointerdown(d3_event) {
36739       if (_downPointer)
36740         return;
36741       var pointerLocGetter = utilFastMouse(this);
36742       _downPointer = {
36743         id: d3_event.pointerId || "mouse",
36744         pointerLocGetter,
36745         downTime: +/* @__PURE__ */ new Date(),
36746         downLoc: pointerLocGetter(d3_event)
36747       };
36748       dispatch14.call("down", this, d3_event, datum2(d3_event));
36749     }
36750     function pointerup(d3_event) {
36751       if (!_downPointer || _downPointer.id !== (d3_event.pointerId || "mouse"))
36752         return;
36753       var downPointer = _downPointer;
36754       _downPointer = null;
36755       _lastPointerUpEvent = d3_event;
36756       if (downPointer.isCancelled)
36757         return;
36758       var t2 = +/* @__PURE__ */ new Date();
36759       var p2 = downPointer.pointerLocGetter(d3_event);
36760       var dist = geoVecLength(downPointer.downLoc, p2);
36761       if (dist < _closeTolerance || dist < _tolerance && t2 - downPointer.downTime < 500) {
36762         select_default2(window).on("click.draw-block", function() {
36763           d3_event.stopPropagation();
36764         }, true);
36765         context.map().dblclickZoomEnable(false);
36766         window.setTimeout(function() {
36767           context.map().dblclickZoomEnable(true);
36768           select_default2(window).on("click.draw-block", null);
36769         }, 500);
36770         click(d3_event, p2);
36771       }
36772     }
36773     function pointermove(d3_event) {
36774       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse") && !_downPointer.isCancelled) {
36775         var p2 = _downPointer.pointerLocGetter(d3_event);
36776         var dist = geoVecLength(_downPointer.downLoc, p2);
36777         if (dist >= _closeTolerance) {
36778           _downPointer.isCancelled = true;
36779           dispatch14.call("downcancel", this);
36780         }
36781       }
36782       if (d3_event.pointerType && d3_event.pointerType !== "mouse" || d3_event.buttons || _downPointer)
36783         return;
36784       if (_lastPointerUpEvent && _lastPointerUpEvent.pointerType !== "mouse" && d3_event.timeStamp - _lastPointerUpEvent.timeStamp < 100)
36785         return;
36786       _lastMouse = d3_event;
36787       dispatch14.call("move", this, d3_event, datum2(d3_event));
36788     }
36789     function pointercancel(d3_event) {
36790       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse")) {
36791         if (!_downPointer.isCancelled) {
36792           dispatch14.call("downcancel", this);
36793         }
36794         _downPointer = null;
36795       }
36796     }
36797     function mouseenter() {
36798       _mouseLeave = false;
36799     }
36800     function mouseleave() {
36801       _mouseLeave = true;
36802     }
36803     function allowsVertex(d2) {
36804       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36805     }
36806     function click(d3_event, loc) {
36807       var d2 = datum2(d3_event);
36808       var target = d2 && d2.properties && d2.properties.entity;
36809       var mode = context.mode();
36810       if (target && target.type === "node" && allowsVertex(target)) {
36811         dispatch14.call("clickNode", this, target, d2);
36812         return;
36813       } else if (target && target.type === "way" && (mode.id !== "add-point" || mode.preset.matchGeometry("vertex"))) {
36814         var choice = geoChooseEdge(
36815           context.graph().childNodes(target),
36816           loc,
36817           context.projection,
36818           context.activeID()
36819         );
36820         if (choice) {
36821           var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
36822           dispatch14.call("clickWay", this, choice.loc, edge, d2);
36823           return;
36824         }
36825       } else if (mode.id !== "add-point" || mode.preset.matchGeometry("point")) {
36826         var locLatLng = context.projection.invert(loc);
36827         dispatch14.call("click", this, locLatLng, d2);
36828       }
36829     }
36830     function space(d3_event) {
36831       d3_event.preventDefault();
36832       d3_event.stopPropagation();
36833       var currSpace = context.map().mouse();
36834       if (_disableSpace && _lastSpace) {
36835         var dist = geoVecLength(_lastSpace, currSpace);
36836         if (dist > _tolerance) {
36837           _disableSpace = false;
36838         }
36839       }
36840       if (_disableSpace || _mouseLeave || !_lastMouse)
36841         return;
36842       _lastSpace = currSpace;
36843       _disableSpace = true;
36844       select_default2(window).on("keyup.space-block", function() {
36845         d3_event.preventDefault();
36846         d3_event.stopPropagation();
36847         _disableSpace = false;
36848         select_default2(window).on("keyup.space-block", null);
36849       });
36850       var loc = context.map().mouse() || // or the map center if the mouse has never entered the map
36851       context.projection(context.map().center());
36852       click(d3_event, loc);
36853     }
36854     function backspace(d3_event) {
36855       d3_event.preventDefault();
36856       dispatch14.call("undo");
36857     }
36858     function del(d3_event) {
36859       d3_event.preventDefault();
36860       dispatch14.call("cancel");
36861     }
36862     function ret(d3_event) {
36863       d3_event.preventDefault();
36864       dispatch14.call("finish");
36865     }
36866     function behavior(selection2) {
36867       context.install(_hover);
36868       context.install(_edit);
36869       _downPointer = null;
36870       keybinding.on("\u232B", backspace).on("\u2326", del).on("\u238B", ret).on("\u21A9", ret).on("space", space).on("\u2325space", space);
36871       selection2.on("mouseenter.draw", mouseenter).on("mouseleave.draw", mouseleave).on(_pointerPrefix + "down.draw", pointerdown).on(_pointerPrefix + "move.draw", pointermove);
36872       select_default2(window).on(_pointerPrefix + "up.draw", pointerup, true).on("pointercancel.draw", pointercancel, true);
36873       select_default2(document).call(keybinding);
36874       return behavior;
36875     }
36876     behavior.off = function(selection2) {
36877       context.ui().sidebar.hover.cancel();
36878       context.uninstall(_hover);
36879       context.uninstall(_edit);
36880       selection2.on("mouseenter.draw", null).on("mouseleave.draw", null).on(_pointerPrefix + "down.draw", null).on(_pointerPrefix + "move.draw", null);
36881       select_default2(window).on(_pointerPrefix + "up.draw", null).on("pointercancel.draw", null);
36882       select_default2(document).call(keybinding.unbind);
36883     };
36884     behavior.hover = function() {
36885       return _hover;
36886     };
36887     return utilRebind(behavior, dispatch14, "on");
36888   }
36889
36890   // modules/behavior/breathe.js
36891   var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
36892
36893   // node_modules/d3-scale/src/init.js
36894   function initRange(domain, range3) {
36895     switch (arguments.length) {
36896       case 0:
36897         break;
36898       case 1:
36899         this.range(domain);
36900         break;
36901       default:
36902         this.range(range3).domain(domain);
36903         break;
36904     }
36905     return this;
36906   }
36907
36908   // node_modules/d3-scale/src/constant.js
36909   function constants(x2) {
36910     return function() {
36911       return x2;
36912     };
36913   }
36914
36915   // node_modules/d3-scale/src/number.js
36916   function number2(x2) {
36917     return +x2;
36918   }
36919
36920   // node_modules/d3-scale/src/continuous.js
36921   var unit = [0, 1];
36922   function identity3(x2) {
36923     return x2;
36924   }
36925   function normalize(a2, b2) {
36926     return (b2 -= a2 = +a2) ? function(x2) {
36927       return (x2 - a2) / b2;
36928     } : constants(isNaN(b2) ? NaN : 0.5);
36929   }
36930   function clamper(a2, b2) {
36931     var t2;
36932     if (a2 > b2)
36933       t2 = a2, a2 = b2, b2 = t2;
36934     return function(x2) {
36935       return Math.max(a2, Math.min(b2, x2));
36936     };
36937   }
36938   function bimap(domain, range3, interpolate) {
36939     var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1];
36940     if (d1 < d0)
36941       d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
36942     else
36943       d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
36944     return function(x2) {
36945       return r0(d0(x2));
36946     };
36947   }
36948   function polymap(domain, range3, interpolate) {
36949     var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1;
36950     if (domain[j2] < domain[0]) {
36951       domain = domain.slice().reverse();
36952       range3 = range3.slice().reverse();
36953     }
36954     while (++i3 < j2) {
36955       d2[i3] = normalize(domain[i3], domain[i3 + 1]);
36956       r2[i3] = interpolate(range3[i3], range3[i3 + 1]);
36957     }
36958     return function(x2) {
36959       var i4 = bisect_default(domain, x2, 1, j2) - 1;
36960       return r2[i4](d2[i4](x2));
36961     };
36962   }
36963   function copy(source, target) {
36964     return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
36965   }
36966   function transformer2() {
36967     var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input;
36968     function rescale() {
36969       var n3 = Math.min(domain.length, range3.length);
36970       if (clamp3 !== identity3)
36971         clamp3 = clamper(domain[0], domain[n3 - 1]);
36972       piecewise = n3 > 2 ? polymap : bimap;
36973       output = input = null;
36974       return scale;
36975     }
36976     function scale(x2) {
36977       return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2)));
36978     }
36979     scale.invert = function(y2) {
36980       return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2)));
36981     };
36982     scale.domain = function(_2) {
36983       return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice();
36984     };
36985     scale.range = function(_2) {
36986       return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice();
36987     };
36988     scale.rangeRound = function(_2) {
36989       return range3 = Array.from(_2), interpolate = round_default, rescale();
36990     };
36991     scale.clamp = function(_2) {
36992       return arguments.length ? (clamp3 = _2 ? true : identity3, rescale()) : clamp3 !== identity3;
36993     };
36994     scale.interpolate = function(_2) {
36995       return arguments.length ? (interpolate = _2, rescale()) : interpolate;
36996     };
36997     scale.unknown = function(_2) {
36998       return arguments.length ? (unknown = _2, scale) : unknown;
36999     };
37000     return function(t2, u2) {
37001       transform2 = t2, untransform = u2;
37002       return rescale();
37003     };
37004   }
37005   function continuous() {
37006     return transformer2()(identity3, identity3);
37007   }
37008
37009   // node_modules/d3-format/src/formatDecimal.js
37010   function formatDecimal_default(x2) {
37011     return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
37012   }
37013   function formatDecimalParts(x2, p2) {
37014     if ((i3 = (x2 = p2 ? x2.toExponential(p2 - 1) : x2.toExponential()).indexOf("e")) < 0)
37015       return null;
37016     var i3, coefficient = x2.slice(0, i3);
37017     return [
37018       coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
37019       +x2.slice(i3 + 1)
37020     ];
37021   }
37022
37023   // node_modules/d3-format/src/exponent.js
37024   function exponent_default(x2) {
37025     return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
37026   }
37027
37028   // node_modules/d3-format/src/formatGroup.js
37029   function formatGroup_default(grouping, thousands) {
37030     return function(value, width) {
37031       var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0;
37032       while (i3 > 0 && g3 > 0) {
37033         if (length2 + g3 + 1 > width)
37034           g3 = Math.max(1, width - length2);
37035         t2.push(value.substring(i3 -= g3, i3 + g3));
37036         if ((length2 += g3 + 1) > width)
37037           break;
37038         g3 = grouping[j2 = (j2 + 1) % grouping.length];
37039       }
37040       return t2.reverse().join(thousands);
37041     };
37042   }
37043
37044   // node_modules/d3-format/src/formatNumerals.js
37045   function formatNumerals_default(numerals) {
37046     return function(value) {
37047       return value.replace(/[0-9]/g, function(i3) {
37048         return numerals[+i3];
37049       });
37050     };
37051   }
37052
37053   // node_modules/d3-format/src/formatSpecifier.js
37054   var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
37055   function formatSpecifier(specifier) {
37056     if (!(match = re.exec(specifier)))
37057       throw new Error("invalid format: " + specifier);
37058     var match;
37059     return new FormatSpecifier({
37060       fill: match[1],
37061       align: match[2],
37062       sign: match[3],
37063       symbol: match[4],
37064       zero: match[5],
37065       width: match[6],
37066       comma: match[7],
37067       precision: match[8] && match[8].slice(1),
37068       trim: match[9],
37069       type: match[10]
37070     });
37071   }
37072   formatSpecifier.prototype = FormatSpecifier.prototype;
37073   function FormatSpecifier(specifier) {
37074     this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
37075     this.align = specifier.align === void 0 ? ">" : specifier.align + "";
37076     this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
37077     this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
37078     this.zero = !!specifier.zero;
37079     this.width = specifier.width === void 0 ? void 0 : +specifier.width;
37080     this.comma = !!specifier.comma;
37081     this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
37082     this.trim = !!specifier.trim;
37083     this.type = specifier.type === void 0 ? "" : specifier.type + "";
37084   }
37085   FormatSpecifier.prototype.toString = function() {
37086     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;
37087   };
37088
37089   // node_modules/d3-format/src/formatTrim.js
37090   function formatTrim_default(s2) {
37091     out:
37092       for (var n3 = s2.length, i3 = 1, i0 = -1, i1; i3 < n3; ++i3) {
37093         switch (s2[i3]) {
37094           case ".":
37095             i0 = i1 = i3;
37096             break;
37097           case "0":
37098             if (i0 === 0)
37099               i0 = i3;
37100             i1 = i3;
37101             break;
37102           default:
37103             if (!+s2[i3])
37104               break out;
37105             if (i0 > 0)
37106               i0 = 0;
37107             break;
37108         }
37109       }
37110     return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2;
37111   }
37112
37113   // node_modules/d3-format/src/formatPrefixAuto.js
37114   var prefixExponent;
37115   function formatPrefixAuto_default(x2, p2) {
37116     var d2 = formatDecimalParts(x2, p2);
37117     if (!d2)
37118       return x2 + "";
37119     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;
37120     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];
37121   }
37122
37123   // node_modules/d3-format/src/formatRounded.js
37124   function formatRounded_default(x2, p2) {
37125     var d2 = formatDecimalParts(x2, p2);
37126     if (!d2)
37127       return x2 + "";
37128     var coefficient = d2[0], exponent = d2[1];
37129     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");
37130   }
37131
37132   // node_modules/d3-format/src/formatTypes.js
37133   var formatTypes_default = {
37134     "%": (x2, p2) => (x2 * 100).toFixed(p2),
37135     "b": (x2) => Math.round(x2).toString(2),
37136     "c": (x2) => x2 + "",
37137     "d": formatDecimal_default,
37138     "e": (x2, p2) => x2.toExponential(p2),
37139     "f": (x2, p2) => x2.toFixed(p2),
37140     "g": (x2, p2) => x2.toPrecision(p2),
37141     "o": (x2) => Math.round(x2).toString(8),
37142     "p": (x2, p2) => formatRounded_default(x2 * 100, p2),
37143     "r": formatRounded_default,
37144     "s": formatPrefixAuto_default,
37145     "X": (x2) => Math.round(x2).toString(16).toUpperCase(),
37146     "x": (x2) => Math.round(x2).toString(16)
37147   };
37148
37149   // node_modules/d3-format/src/identity.js
37150   function identity_default4(x2) {
37151     return x2;
37152   }
37153
37154   // node_modules/d3-format/src/locale.js
37155   var map = Array.prototype.map;
37156   var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
37157   function locale_default(locale2) {
37158     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 + "";
37159     function newFormat(specifier) {
37160       specifier = formatSpecifier(specifier);
37161       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;
37162       if (type2 === "n")
37163         comma = true, type2 = "g";
37164       else if (!formatTypes_default[type2])
37165         precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g";
37166       if (zero3 || fill === "0" && align === "=")
37167         zero3 = true, fill = "0", align = "=";
37168       var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : "";
37169       var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2);
37170       precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3));
37171       function format2(value) {
37172         var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2;
37173         if (type2 === "c") {
37174           valueSuffix = formatType(value) + valueSuffix;
37175           value = "";
37176         } else {
37177           value = +value;
37178           var valueNegative = value < 0 || 1 / value < 0;
37179           value = isNaN(value) ? nan : formatType(Math.abs(value), precision3);
37180           if (trim)
37181             value = formatTrim_default(value);
37182           if (valueNegative && +value === 0 && sign2 !== "+")
37183             valueNegative = false;
37184           valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
37185           valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
37186           if (maybeSuffix) {
37187             i3 = -1, n3 = value.length;
37188             while (++i3 < n3) {
37189               if (c2 = value.charCodeAt(i3), 48 > c2 || c2 > 57) {
37190                 valueSuffix = (c2 === 46 ? decimal + value.slice(i3 + 1) : value.slice(i3)) + valueSuffix;
37191                 value = value.slice(0, i3);
37192                 break;
37193               }
37194             }
37195           }
37196         }
37197         if (comma && !zero3)
37198           value = group(value, Infinity);
37199         var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : "";
37200         if (comma && zero3)
37201           value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
37202         switch (align) {
37203           case "<":
37204             value = valuePrefix + value + valueSuffix + padding;
37205             break;
37206           case "=":
37207             value = valuePrefix + padding + value + valueSuffix;
37208             break;
37209           case "^":
37210             value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2);
37211             break;
37212           default:
37213             value = padding + valuePrefix + value + valueSuffix;
37214             break;
37215         }
37216         return numerals(value);
37217       }
37218       format2.toString = function() {
37219         return specifier + "";
37220       };
37221       return format2;
37222     }
37223     function formatPrefix2(specifier, value) {
37224       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];
37225       return function(value2) {
37226         return f2(k2 * value2) + prefix;
37227       };
37228     }
37229     return {
37230       format: newFormat,
37231       formatPrefix: formatPrefix2
37232     };
37233   }
37234
37235   // node_modules/d3-format/src/defaultLocale.js
37236   var locale;
37237   var format;
37238   var formatPrefix;
37239   defaultLocale({
37240     thousands: ",",
37241     grouping: [3],
37242     currency: ["$", ""]
37243   });
37244   function defaultLocale(definition) {
37245     locale = locale_default(definition);
37246     format = locale.format;
37247     formatPrefix = locale.formatPrefix;
37248     return locale;
37249   }
37250
37251   // node_modules/d3-format/src/precisionFixed.js
37252   function precisionFixed_default(step) {
37253     return Math.max(0, -exponent_default(Math.abs(step)));
37254   }
37255
37256   // node_modules/d3-format/src/precisionPrefix.js
37257   function precisionPrefix_default(step, value) {
37258     return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
37259   }
37260
37261   // node_modules/d3-format/src/precisionRound.js
37262   function precisionRound_default(step, max3) {
37263     step = Math.abs(step), max3 = Math.abs(max3) - step;
37264     return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
37265   }
37266
37267   // node_modules/d3-scale/src/tickFormat.js
37268   function tickFormat(start2, stop, count, specifier) {
37269     var step = tickStep(start2, stop, count), precision3;
37270     specifier = formatSpecifier(specifier == null ? ",f" : specifier);
37271     switch (specifier.type) {
37272       case "s": {
37273         var value = Math.max(Math.abs(start2), Math.abs(stop));
37274         if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value)))
37275           specifier.precision = precision3;
37276         return formatPrefix(specifier, value);
37277       }
37278       case "":
37279       case "e":
37280       case "g":
37281       case "p":
37282       case "r": {
37283         if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop)))))
37284           specifier.precision = precision3 - (specifier.type === "e");
37285         break;
37286       }
37287       case "f":
37288       case "%": {
37289         if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step)))
37290           specifier.precision = precision3 - (specifier.type === "%") * 2;
37291         break;
37292       }
37293     }
37294     return format(specifier);
37295   }
37296
37297   // node_modules/d3-scale/src/linear.js
37298   function linearish(scale) {
37299     var domain = scale.domain;
37300     scale.ticks = function(count) {
37301       var d2 = domain();
37302       return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count);
37303     };
37304     scale.tickFormat = function(count, specifier) {
37305       var d2 = domain();
37306       return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier);
37307     };
37308     scale.nice = function(count) {
37309       if (count == null)
37310         count = 10;
37311       var d2 = domain();
37312       var i0 = 0;
37313       var i1 = d2.length - 1;
37314       var start2 = d2[i0];
37315       var stop = d2[i1];
37316       var prestep;
37317       var step;
37318       var maxIter = 10;
37319       if (stop < start2) {
37320         step = start2, start2 = stop, stop = step;
37321         step = i0, i0 = i1, i1 = step;
37322       }
37323       while (maxIter-- > 0) {
37324         step = tickIncrement(start2, stop, count);
37325         if (step === prestep) {
37326           d2[i0] = start2;
37327           d2[i1] = stop;
37328           return domain(d2);
37329         } else if (step > 0) {
37330           start2 = Math.floor(start2 / step) * step;
37331           stop = Math.ceil(stop / step) * step;
37332         } else if (step < 0) {
37333           start2 = Math.ceil(start2 * step) / step;
37334           stop = Math.floor(stop * step) / step;
37335         } else {
37336           break;
37337         }
37338         prestep = step;
37339       }
37340       return scale;
37341     };
37342     return scale;
37343   }
37344   function linear3() {
37345     var scale = continuous();
37346     scale.copy = function() {
37347       return copy(scale, linear3());
37348     };
37349     initRange.apply(scale, arguments);
37350     return linearish(scale);
37351   }
37352
37353   // node_modules/d3-scale/src/quantize.js
37354   function quantize() {
37355     var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown;
37356     function scale(x2) {
37357       return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown;
37358     }
37359     function rescale() {
37360       var i3 = -1;
37361       domain = new Array(n3);
37362       while (++i3 < n3)
37363         domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1);
37364       return scale;
37365     }
37366     scale.domain = function(_2) {
37367       return arguments.length ? ([x05, x12] = _2, x05 = +x05, x12 = +x12, rescale()) : [x05, x12];
37368     };
37369     scale.range = function(_2) {
37370       return arguments.length ? (n3 = (range3 = Array.from(_2)).length - 1, rescale()) : range3.slice();
37371     };
37372     scale.invertExtent = function(y2) {
37373       var i3 = range3.indexOf(y2);
37374       return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]];
37375     };
37376     scale.unknown = function(_2) {
37377       return arguments.length ? (unknown = _2, scale) : scale;
37378     };
37379     scale.thresholds = function() {
37380       return domain.slice();
37381     };
37382     scale.copy = function() {
37383       return quantize().domain([x05, x12]).range(range3).unknown(unknown);
37384     };
37385     return initRange.apply(linearish(scale), arguments);
37386   }
37387
37388   // modules/behavior/breathe.js
37389   function behaviorBreathe() {
37390     var duration = 800;
37391     var steps = 4;
37392     var selector = ".selected.shadow, .selected .shadow";
37393     var _selected = select_default2(null);
37394     var _classed = "";
37395     var _params = {};
37396     var _done = false;
37397     var _timer;
37398     function ratchetyInterpolator(a2, b2, steps2, units) {
37399       a2 = Number(a2);
37400       b2 = Number(b2);
37401       var sample = quantize().domain([0, 1]).range(quantize_default(number_default(a2, b2), steps2));
37402       return function(t2) {
37403         return String(sample(t2)) + (units || "");
37404       };
37405     }
37406     function reset(selection2) {
37407       selection2.style("stroke-opacity", null).style("stroke-width", null).style("fill-opacity", null).style("r", null);
37408     }
37409     function setAnimationParams(transition2, fromTo) {
37410       var toFrom = fromTo === "from" ? "to" : "from";
37411       transition2.styleTween("stroke-opacity", function(d2) {
37412         return ratchetyInterpolator(
37413           _params[d2.id][toFrom].opacity,
37414           _params[d2.id][fromTo].opacity,
37415           steps
37416         );
37417       }).styleTween("stroke-width", function(d2) {
37418         return ratchetyInterpolator(
37419           _params[d2.id][toFrom].width,
37420           _params[d2.id][fromTo].width,
37421           steps,
37422           "px"
37423         );
37424       }).styleTween("fill-opacity", function(d2) {
37425         return ratchetyInterpolator(
37426           _params[d2.id][toFrom].opacity,
37427           _params[d2.id][fromTo].opacity,
37428           steps
37429         );
37430       }).styleTween("r", function(d2) {
37431         return ratchetyInterpolator(
37432           _params[d2.id][toFrom].width,
37433           _params[d2.id][fromTo].width,
37434           steps,
37435           "px"
37436         );
37437       });
37438     }
37439     function calcAnimationParams(selection2) {
37440       selection2.call(reset).each(function(d2) {
37441         var s2 = select_default2(this);
37442         var tag2 = s2.node().tagName;
37443         var p2 = { "from": {}, "to": {} };
37444         var opacity;
37445         var width;
37446         if (tag2 === "circle") {
37447           opacity = Number(s2.style("fill-opacity") || 0.5);
37448           width = Number(s2.style("r") || 15.5);
37449         } else {
37450           opacity = Number(s2.style("stroke-opacity") || 0.7);
37451           width = Number(s2.style("stroke-width") || 10);
37452         }
37453         p2.tag = tag2;
37454         p2.from.opacity = opacity * 0.6;
37455         p2.to.opacity = opacity * 1.25;
37456         p2.from.width = width * 0.7;
37457         p2.to.width = width * (tag2 === "circle" ? 1.5 : 1);
37458         _params[d2.id] = p2;
37459       });
37460     }
37461     function run(surface, fromTo) {
37462       var toFrom = fromTo === "from" ? "to" : "from";
37463       var currSelected = surface.selectAll(selector);
37464       var currClassed = surface.attr("class");
37465       if (_done || currSelected.empty()) {
37466         _selected.call(reset);
37467         _selected = select_default2(null);
37468         return;
37469       }
37470       if (!(0, import_fast_deep_equal2.default)(currSelected.data(), _selected.data()) || currClassed !== _classed) {
37471         _selected.call(reset);
37472         _classed = currClassed;
37473         _selected = currSelected.call(calcAnimationParams);
37474       }
37475       var didCallNextRun = false;
37476       _selected.transition().duration(duration).call(setAnimationParams, fromTo).on("end", function() {
37477         if (!didCallNextRun) {
37478           surface.call(run, toFrom);
37479           didCallNextRun = true;
37480         }
37481         if (!select_default2(this).classed("selected")) {
37482           reset(select_default2(this));
37483         }
37484       });
37485     }
37486     function behavior(surface) {
37487       _done = false;
37488       _timer = timer(function() {
37489         if (surface.selectAll(selector).empty()) {
37490           return false;
37491         }
37492         surface.call(run, "from");
37493         _timer.stop();
37494         return true;
37495       }, 20);
37496     }
37497     behavior.restartIfNeeded = function(surface) {
37498       if (_selected.empty()) {
37499         surface.call(run, "from");
37500         if (_timer) {
37501           _timer.stop();
37502         }
37503       }
37504     };
37505     behavior.off = function() {
37506       _done = true;
37507       if (_timer) {
37508         _timer.stop();
37509       }
37510       _selected.interrupt().call(reset);
37511     };
37512     return behavior;
37513   }
37514
37515   // modules/behavior/operation.js
37516   function behaviorOperation(context) {
37517     var _operation;
37518     function keypress(d3_event) {
37519       if (!context.map().withinEditableZoom())
37520         return;
37521       if (_operation.availableForKeypress && !_operation.availableForKeypress())
37522         return;
37523       d3_event.preventDefault();
37524       var disabled = _operation.disabled();
37525       if (disabled) {
37526         context.ui().flash.duration(4e3).iconName("#iD-operation-" + _operation.id).iconClass("operation disabled").label(_operation.tooltip())();
37527       } else {
37528         context.ui().flash.duration(2e3).iconName("#iD-operation-" + _operation.id).iconClass("operation").label(_operation.annotation() || _operation.title)();
37529         if (_operation.point)
37530           _operation.point(null);
37531         _operation();
37532       }
37533     }
37534     function behavior() {
37535       if (_operation && _operation.available()) {
37536         context.keybinding().on(_operation.keys, keypress);
37537       }
37538       return behavior;
37539     }
37540     behavior.off = function() {
37541       context.keybinding().off(_operation.keys);
37542     };
37543     behavior.which = function(_2) {
37544       if (!arguments.length)
37545         return _operation;
37546       _operation = _2;
37547       return behavior;
37548     };
37549     return behavior;
37550   }
37551
37552   // modules/operations/circularize.js
37553   function operationCircularize(context, selectedIDs) {
37554     var _extent;
37555     var _actions = selectedIDs.map(getAction).filter(Boolean);
37556     var _amount = _actions.length === 1 ? "single" : "multiple";
37557     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37558       return n3.loc;
37559     });
37560     function getAction(entityID) {
37561       var entity = context.entity(entityID);
37562       if (entity.type !== "way" || new Set(entity.nodes).size <= 1)
37563         return null;
37564       if (!_extent) {
37565         _extent = entity.extent(context.graph());
37566       } else {
37567         _extent = _extent.extend(entity.extent(context.graph()));
37568       }
37569       return actionCircularize(entityID, context.projection);
37570     }
37571     var operation2 = function() {
37572       if (!_actions.length)
37573         return;
37574       var combinedAction = function(graph, t2) {
37575         _actions.forEach(function(action) {
37576           if (!action.disabled(graph)) {
37577             graph = action(graph, t2);
37578           }
37579         });
37580         return graph;
37581       };
37582       combinedAction.transitionable = true;
37583       context.perform(combinedAction, operation2.annotation());
37584       window.setTimeout(function() {
37585         context.validator().validate();
37586       }, 300);
37587     };
37588     operation2.available = function() {
37589       return _actions.length && selectedIDs.length === _actions.length;
37590     };
37591     operation2.disabled = function() {
37592       if (!_actions.length)
37593         return "";
37594       var actionDisableds = _actions.map(function(action) {
37595         return action.disabled(context.graph());
37596       }).filter(Boolean);
37597       if (actionDisableds.length === _actions.length) {
37598         if (new Set(actionDisableds).size > 1) {
37599           return "multiple_blockers";
37600         }
37601         return actionDisableds[0];
37602       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
37603         return "too_large";
37604       } else if (someMissing()) {
37605         return "not_downloaded";
37606       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37607         return "connected_to_hidden";
37608       }
37609       return false;
37610       function someMissing() {
37611         if (context.inIntro())
37612           return false;
37613         var osm = context.connection();
37614         if (osm) {
37615           var missing = _coords.filter(function(loc) {
37616             return !osm.isDataLoaded(loc);
37617           });
37618           if (missing.length) {
37619             missing.forEach(function(loc) {
37620               context.loadTileAtLoc(loc);
37621             });
37622             return true;
37623           }
37624         }
37625         return false;
37626       }
37627     };
37628     operation2.tooltip = function() {
37629       var disable = operation2.disabled();
37630       return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount);
37631     };
37632     operation2.annotation = function() {
37633       return _t("operations.circularize.annotation.feature", { n: _actions.length });
37634     };
37635     operation2.id = "circularize";
37636     operation2.keys = [_t("operations.circularize.key")];
37637     operation2.title = _t.append("operations.circularize.title");
37638     operation2.behavior = behaviorOperation(context).which(operation2);
37639     return operation2;
37640   }
37641
37642   // modules/ui/cmd.js
37643   var uiCmd = function(code) {
37644     var detected = utilDetect();
37645     if (detected.os === "mac") {
37646       return code;
37647     }
37648     if (detected.os === "win") {
37649       if (code === "\u2318\u21E7Z")
37650         return "Ctrl+Y";
37651     }
37652     var result = "", replacements = {
37653       "\u2318": "Ctrl",
37654       "\u21E7": "Shift",
37655       "\u2325": "Alt",
37656       "\u232B": "Backspace",
37657       "\u2326": "Delete"
37658     };
37659     for (var i3 = 0; i3 < code.length; i3++) {
37660       if (code[i3] in replacements) {
37661         result += replacements[code[i3]] + (i3 < code.length - 1 ? "+" : "");
37662       } else {
37663         result += code[i3];
37664       }
37665     }
37666     return result;
37667   };
37668   uiCmd.display = function(code) {
37669     if (code.length !== 1)
37670       return code;
37671     var detected = utilDetect();
37672     var mac = detected.os === "mac";
37673     var replacements = {
37674       "\u2318": mac ? "\u2318 " + _t("shortcuts.key.cmd") : _t("shortcuts.key.ctrl"),
37675       "\u21E7": mac ? "\u21E7 " + _t("shortcuts.key.shift") : _t("shortcuts.key.shift"),
37676       "\u2325": mac ? "\u2325 " + _t("shortcuts.key.option") : _t("shortcuts.key.alt"),
37677       "\u2303": mac ? "\u2303 " + _t("shortcuts.key.ctrl") : _t("shortcuts.key.ctrl"),
37678       "\u232B": mac ? "\u232B " + _t("shortcuts.key.delete") : _t("shortcuts.key.backspace"),
37679       "\u2326": mac ? "\u2326 " + _t("shortcuts.key.del") : _t("shortcuts.key.del"),
37680       "\u2196": mac ? "\u2196 " + _t("shortcuts.key.pgup") : _t("shortcuts.key.pgup"),
37681       "\u2198": mac ? "\u2198 " + _t("shortcuts.key.pgdn") : _t("shortcuts.key.pgdn"),
37682       "\u21DE": mac ? "\u21DE " + _t("shortcuts.key.home") : _t("shortcuts.key.home"),
37683       "\u21DF": mac ? "\u21DF " + _t("shortcuts.key.end") : _t("shortcuts.key.end"),
37684       "\u21B5": mac ? "\u23CE " + _t("shortcuts.key.return") : _t("shortcuts.key.enter"),
37685       "\u238B": mac ? "\u238B " + _t("shortcuts.key.esc") : _t("shortcuts.key.esc"),
37686       "\u2630": mac ? "\u2630 " + _t("shortcuts.key.menu") : _t("shortcuts.key.menu")
37687     };
37688     return replacements[code] || code;
37689   };
37690
37691   // modules/operations/delete.js
37692   function operationDelete(context, selectedIDs) {
37693     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37694     var action = actionDeleteMultiple(selectedIDs);
37695     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37696     var coords = nodes.map(function(n3) {
37697       return n3.loc;
37698     });
37699     var extent = utilTotalExtent(selectedIDs, context.graph());
37700     var operation2 = function() {
37701       var nextSelectedID;
37702       var nextSelectedLoc;
37703       if (selectedIDs.length === 1) {
37704         var id2 = selectedIDs[0];
37705         var entity = context.entity(id2);
37706         var geometry = entity.geometry(context.graph());
37707         var parents = context.graph().parentWays(entity);
37708         var parent = parents[0];
37709         if (geometry === "vertex") {
37710           var nodes2 = parent.nodes;
37711           var i3 = nodes2.indexOf(id2);
37712           if (i3 === 0) {
37713             i3++;
37714           } else if (i3 === nodes2.length - 1) {
37715             i3--;
37716           } else {
37717             var a2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 - 1]).loc);
37718             var b2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 + 1]).loc);
37719             i3 = a2 < b2 ? i3 - 1 : i3 + 1;
37720           }
37721           nextSelectedID = nodes2[i3];
37722           nextSelectedLoc = context.entity(nextSelectedID).loc;
37723         }
37724       }
37725       context.perform(action, operation2.annotation());
37726       context.validator().validate();
37727       if (nextSelectedID && nextSelectedLoc) {
37728         if (context.hasEntity(nextSelectedID)) {
37729           context.enter(modeSelect(context, [nextSelectedID]).follow(true));
37730         } else {
37731           context.map().centerEase(nextSelectedLoc);
37732           context.enter(modeBrowse(context));
37733         }
37734       } else {
37735         context.enter(modeBrowse(context));
37736       }
37737     };
37738     operation2.available = function() {
37739       return true;
37740     };
37741     operation2.disabled = function() {
37742       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37743         return "too_large";
37744       } else if (someMissing()) {
37745         return "not_downloaded";
37746       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37747         return "connected_to_hidden";
37748       } else if (selectedIDs.some(protectedMember)) {
37749         return "part_of_relation";
37750       } else if (selectedIDs.some(incompleteRelation)) {
37751         return "incomplete_relation";
37752       } else if (selectedIDs.some(hasWikidataTag)) {
37753         return "has_wikidata_tag";
37754       }
37755       return false;
37756       function someMissing() {
37757         if (context.inIntro())
37758           return false;
37759         var osm = context.connection();
37760         if (osm) {
37761           var missing = coords.filter(function(loc) {
37762             return !osm.isDataLoaded(loc);
37763           });
37764           if (missing.length) {
37765             missing.forEach(function(loc) {
37766               context.loadTileAtLoc(loc);
37767             });
37768             return true;
37769           }
37770         }
37771         return false;
37772       }
37773       function hasWikidataTag(id2) {
37774         var entity = context.entity(id2);
37775         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
37776       }
37777       function incompleteRelation(id2) {
37778         var entity = context.entity(id2);
37779         return entity.type === "relation" && !entity.isComplete(context.graph());
37780       }
37781       function protectedMember(id2) {
37782         var entity = context.entity(id2);
37783         if (entity.type !== "way")
37784           return false;
37785         var parents = context.graph().parentRelations(entity);
37786         for (var i3 = 0; i3 < parents.length; i3++) {
37787           var parent = parents[i3];
37788           var type2 = parent.tags.type;
37789           var role = parent.memberById(id2).role || "outer";
37790           if (type2 === "route" || type2 === "boundary" || type2 === "multipolygon" && role === "outer") {
37791             return true;
37792           }
37793         }
37794         return false;
37795       }
37796     };
37797     operation2.tooltip = function() {
37798       var disable = operation2.disabled();
37799       return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi);
37800     };
37801     operation2.annotation = function() {
37802       return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length });
37803     };
37804     operation2.id = "delete";
37805     operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")];
37806     operation2.title = _t.append("operations.delete.title");
37807     operation2.behavior = behaviorOperation(context).which(operation2);
37808     return operation2;
37809   }
37810
37811   // modules/operations/orthogonalize.js
37812   function operationOrthogonalize(context, selectedIDs) {
37813     var _extent;
37814     var _type;
37815     var _actions = selectedIDs.map(chooseAction).filter(Boolean);
37816     var _amount = _actions.length === 1 ? "single" : "multiple";
37817     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37818       return n3.loc;
37819     });
37820     function chooseAction(entityID) {
37821       var entity = context.entity(entityID);
37822       var geometry = entity.geometry(context.graph());
37823       if (!_extent) {
37824         _extent = entity.extent(context.graph());
37825       } else {
37826         _extent = _extent.extend(entity.extent(context.graph()));
37827       }
37828       if (entity.type === "way" && new Set(entity.nodes).size > 2) {
37829         if (_type && _type !== "feature")
37830           return null;
37831         _type = "feature";
37832         return actionOrthogonalize(entityID, context.projection);
37833       } else if (geometry === "vertex") {
37834         if (_type && _type !== "corner")
37835           return null;
37836         _type = "corner";
37837         var graph = context.graph();
37838         var parents = graph.parentWays(entity);
37839         if (parents.length === 1) {
37840           var way = parents[0];
37841           if (way.nodes.indexOf(entityID) !== -1) {
37842             return actionOrthogonalize(way.id, context.projection, entityID);
37843           }
37844         }
37845       }
37846       return null;
37847     }
37848     var operation2 = function() {
37849       if (!_actions.length)
37850         return;
37851       var combinedAction = function(graph, t2) {
37852         _actions.forEach(function(action) {
37853           if (!action.disabled(graph)) {
37854             graph = action(graph, t2);
37855           }
37856         });
37857         return graph;
37858       };
37859       combinedAction.transitionable = true;
37860       context.perform(combinedAction, operation2.annotation());
37861       window.setTimeout(function() {
37862         context.validator().validate();
37863       }, 300);
37864     };
37865     operation2.available = function() {
37866       return _actions.length && selectedIDs.length === _actions.length;
37867     };
37868     operation2.disabled = function() {
37869       if (!_actions.length)
37870         return "";
37871       var actionDisableds = _actions.map(function(action) {
37872         return action.disabled(context.graph());
37873       }).filter(Boolean);
37874       if (actionDisableds.length === _actions.length) {
37875         if (new Set(actionDisableds).size > 1) {
37876           return "multiple_blockers";
37877         }
37878         return actionDisableds[0];
37879       } else if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
37880         return "too_large";
37881       } else if (someMissing()) {
37882         return "not_downloaded";
37883       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37884         return "connected_to_hidden";
37885       }
37886       return false;
37887       function someMissing() {
37888         if (context.inIntro())
37889           return false;
37890         var osm = context.connection();
37891         if (osm) {
37892           var missing = _coords.filter(function(loc) {
37893             return !osm.isDataLoaded(loc);
37894           });
37895           if (missing.length) {
37896             missing.forEach(function(loc) {
37897               context.loadTileAtLoc(loc);
37898             });
37899             return true;
37900           }
37901         }
37902         return false;
37903       }
37904     };
37905     operation2.tooltip = function() {
37906       var disable = operation2.disabled();
37907       return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount);
37908     };
37909     operation2.annotation = function() {
37910       return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length });
37911     };
37912     operation2.id = "orthogonalize";
37913     operation2.keys = [_t("operations.orthogonalize.key")];
37914     operation2.title = _t.append("operations.orthogonalize.title");
37915     operation2.behavior = behaviorOperation(context).which(operation2);
37916     return operation2;
37917   }
37918
37919   // modules/operations/reflect.js
37920   function operationReflectShort(context, selectedIDs) {
37921     return operationReflect(context, selectedIDs, "short");
37922   }
37923   function operationReflectLong(context, selectedIDs) {
37924     return operationReflect(context, selectedIDs, "long");
37925   }
37926   function operationReflect(context, selectedIDs, axis) {
37927     axis = axis || "long";
37928     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37929     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37930     var coords = nodes.map(function(n3) {
37931       return n3.loc;
37932     });
37933     var extent = utilTotalExtent(selectedIDs, context.graph());
37934     var operation2 = function() {
37935       var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long"));
37936       context.perform(action, operation2.annotation());
37937       window.setTimeout(function() {
37938         context.validator().validate();
37939       }, 300);
37940     };
37941     operation2.available = function() {
37942       return nodes.length >= 3;
37943     };
37944     operation2.disabled = function() {
37945       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37946         return "too_large";
37947       } else if (someMissing()) {
37948         return "not_downloaded";
37949       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37950         return "connected_to_hidden";
37951       } else if (selectedIDs.some(incompleteRelation)) {
37952         return "incomplete_relation";
37953       }
37954       return false;
37955       function someMissing() {
37956         if (context.inIntro())
37957           return false;
37958         var osm = context.connection();
37959         if (osm) {
37960           var missing = coords.filter(function(loc) {
37961             return !osm.isDataLoaded(loc);
37962           });
37963           if (missing.length) {
37964             missing.forEach(function(loc) {
37965               context.loadTileAtLoc(loc);
37966             });
37967             return true;
37968           }
37969         }
37970         return false;
37971       }
37972       function incompleteRelation(id2) {
37973         var entity = context.entity(id2);
37974         return entity.type === "relation" && !entity.isComplete(context.graph());
37975       }
37976     };
37977     operation2.tooltip = function() {
37978       var disable = operation2.disabled();
37979       return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi);
37980     };
37981     operation2.annotation = function() {
37982       return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length });
37983     };
37984     operation2.id = "reflect-" + axis;
37985     operation2.keys = [_t("operations.reflect.key." + axis)];
37986     operation2.title = _t.append("operations.reflect.title." + axis);
37987     operation2.behavior = behaviorOperation(context).which(operation2);
37988     return operation2;
37989   }
37990
37991   // modules/operations/move.js
37992   function operationMove(context, selectedIDs) {
37993     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37994     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37995     var coords = nodes.map(function(n3) {
37996       return n3.loc;
37997     });
37998     var extent = utilTotalExtent(selectedIDs, context.graph());
37999     var operation2 = function() {
38000       context.enter(modeMove(context, selectedIDs));
38001     };
38002     operation2.available = function() {
38003       return selectedIDs.length > 0;
38004     };
38005     operation2.disabled = function() {
38006       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38007         return "too_large";
38008       } else if (someMissing()) {
38009         return "not_downloaded";
38010       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38011         return "connected_to_hidden";
38012       } else if (selectedIDs.some(incompleteRelation)) {
38013         return "incomplete_relation";
38014       }
38015       return false;
38016       function someMissing() {
38017         if (context.inIntro())
38018           return false;
38019         var osm = context.connection();
38020         if (osm) {
38021           var missing = coords.filter(function(loc) {
38022             return !osm.isDataLoaded(loc);
38023           });
38024           if (missing.length) {
38025             missing.forEach(function(loc) {
38026               context.loadTileAtLoc(loc);
38027             });
38028             return true;
38029           }
38030         }
38031         return false;
38032       }
38033       function incompleteRelation(id2) {
38034         var entity = context.entity(id2);
38035         return entity.type === "relation" && !entity.isComplete(context.graph());
38036       }
38037     };
38038     operation2.tooltip = function() {
38039       var disable = operation2.disabled();
38040       return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi);
38041     };
38042     operation2.annotation = function() {
38043       return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length });
38044     };
38045     operation2.id = "move";
38046     operation2.keys = [_t("operations.move.key")];
38047     operation2.title = _t.append("operations.move.title");
38048     operation2.behavior = behaviorOperation(context).which(operation2);
38049     operation2.mouseOnly = true;
38050     return operation2;
38051   }
38052
38053   // modules/modes/rotate.js
38054   function modeRotate(context, entityIDs) {
38055     var _tolerancePx = 4;
38056     var mode = {
38057       id: "rotate",
38058       button: "browse"
38059     };
38060     var keybinding = utilKeybinding("rotate");
38061     var behaviors = [
38062       behaviorEdit(context),
38063       operationCircularize(context, entityIDs).behavior,
38064       operationDelete(context, entityIDs).behavior,
38065       operationMove(context, entityIDs).behavior,
38066       operationOrthogonalize(context, entityIDs).behavior,
38067       operationReflectLong(context, entityIDs).behavior,
38068       operationReflectShort(context, entityIDs).behavior
38069     ];
38070     var annotation = entityIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.rotate.annotation.feature", { n: entityIDs.length });
38071     var _prevGraph;
38072     var _prevAngle;
38073     var _prevTransform;
38074     var _pivot;
38075     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38076     function doRotate(d3_event) {
38077       var fn;
38078       if (context.graph() !== _prevGraph) {
38079         fn = context.perform;
38080       } else {
38081         fn = context.replace;
38082       }
38083       var projection2 = context.projection;
38084       var currTransform = projection2.transform();
38085       if (!_prevTransform || currTransform.k !== _prevTransform.k || currTransform.x !== _prevTransform.x || currTransform.y !== _prevTransform.y) {
38086         var nodes = utilGetAllNodes(entityIDs, context.graph());
38087         var points = nodes.map(function(n3) {
38088           return projection2(n3.loc);
38089         });
38090         _pivot = getPivot(points);
38091         _prevAngle = void 0;
38092       }
38093       var currMouse = context.map().mouse(d3_event);
38094       var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
38095       if (typeof _prevAngle === "undefined")
38096         _prevAngle = currAngle;
38097       var delta = currAngle - _prevAngle;
38098       fn(actionRotate(entityIDs, _pivot, delta, projection2));
38099       _prevTransform = currTransform;
38100       _prevAngle = currAngle;
38101       _prevGraph = context.graph();
38102     }
38103     function getPivot(points) {
38104       var _pivot2;
38105       if (points.length === 1) {
38106         _pivot2 = points[0];
38107       } else if (points.length === 2) {
38108         _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38109       } else {
38110         var polygonHull = hull_default(points);
38111         if (polygonHull.length === 2) {
38112           _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38113         } else {
38114           _pivot2 = centroid_default2(hull_default(points));
38115         }
38116       }
38117       return _pivot2;
38118     }
38119     function finish(d3_event) {
38120       d3_event.stopPropagation();
38121       context.replace(actionNoop(), annotation);
38122       context.enter(modeSelect(context, entityIDs));
38123     }
38124     function cancel() {
38125       if (_prevGraph)
38126         context.pop();
38127       context.enter(modeSelect(context, entityIDs));
38128     }
38129     function undone() {
38130       context.enter(modeBrowse(context));
38131     }
38132     mode.enter = function() {
38133       _prevGraph = null;
38134       context.features().forceVisible(entityIDs);
38135       behaviors.forEach(context.install);
38136       var downEvent;
38137       context.surface().on(_pointerPrefix + "down.modeRotate", function(d3_event) {
38138         downEvent = d3_event;
38139       });
38140       select_default2(window).on(_pointerPrefix + "move.modeRotate", doRotate, true).on(_pointerPrefix + "up.modeRotate", function(d3_event) {
38141         if (!downEvent)
38142           return;
38143         var mapNode = context.container().select(".main-map").node();
38144         var pointGetter = utilFastMouse(mapNode);
38145         var p1 = pointGetter(downEvent);
38146         var p2 = pointGetter(d3_event);
38147         var dist = geoVecLength(p1, p2);
38148         if (dist <= _tolerancePx)
38149           finish(d3_event);
38150         downEvent = null;
38151       }, true);
38152       context.history().on("undone.modeRotate", undone);
38153       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38154       select_default2(document).call(keybinding);
38155     };
38156     mode.exit = function() {
38157       behaviors.forEach(context.uninstall);
38158       context.surface().on(_pointerPrefix + "down.modeRotate", null);
38159       select_default2(window).on(_pointerPrefix + "move.modeRotate", null, true).on(_pointerPrefix + "up.modeRotate", null, true);
38160       context.history().on("undone.modeRotate", null);
38161       select_default2(document).call(keybinding.unbind);
38162       context.features().forceVisible([]);
38163     };
38164     mode.selectedIDs = function() {
38165       if (!arguments.length)
38166         return entityIDs;
38167       return mode;
38168     };
38169     return mode;
38170   }
38171
38172   // modules/operations/rotate.js
38173   function operationRotate(context, selectedIDs) {
38174     var multi = selectedIDs.length === 1 ? "single" : "multiple";
38175     var nodes = utilGetAllNodes(selectedIDs, context.graph());
38176     var coords = nodes.map(function(n3) {
38177       return n3.loc;
38178     });
38179     var extent = utilTotalExtent(selectedIDs, context.graph());
38180     var operation2 = function() {
38181       context.enter(modeRotate(context, selectedIDs));
38182     };
38183     operation2.available = function() {
38184       return nodes.length >= 2;
38185     };
38186     operation2.disabled = function() {
38187       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38188         return "too_large";
38189       } else if (someMissing()) {
38190         return "not_downloaded";
38191       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38192         return "connected_to_hidden";
38193       } else if (selectedIDs.some(incompleteRelation)) {
38194         return "incomplete_relation";
38195       }
38196       return false;
38197       function someMissing() {
38198         if (context.inIntro())
38199           return false;
38200         var osm = context.connection();
38201         if (osm) {
38202           var missing = coords.filter(function(loc) {
38203             return !osm.isDataLoaded(loc);
38204           });
38205           if (missing.length) {
38206             missing.forEach(function(loc) {
38207               context.loadTileAtLoc(loc);
38208             });
38209             return true;
38210           }
38211         }
38212         return false;
38213       }
38214       function incompleteRelation(id2) {
38215         var entity = context.entity(id2);
38216         return entity.type === "relation" && !entity.isComplete(context.graph());
38217       }
38218     };
38219     operation2.tooltip = function() {
38220       var disable = operation2.disabled();
38221       return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi);
38222     };
38223     operation2.annotation = function() {
38224       return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length });
38225     };
38226     operation2.id = "rotate";
38227     operation2.keys = [_t("operations.rotate.key")];
38228     operation2.title = _t.append("operations.rotate.title");
38229     operation2.behavior = behaviorOperation(context).which(operation2);
38230     operation2.mouseOnly = true;
38231     return operation2;
38232   }
38233
38234   // modules/modes/move.js
38235   function modeMove(context, entityIDs, baseGraph) {
38236     var _tolerancePx = 4;
38237     var mode = {
38238       id: "move",
38239       button: "browse"
38240     };
38241     var keybinding = utilKeybinding("move");
38242     var behaviors = [
38243       behaviorEdit(context),
38244       operationCircularize(context, entityIDs).behavior,
38245       operationDelete(context, entityIDs).behavior,
38246       operationOrthogonalize(context, entityIDs).behavior,
38247       operationReflectLong(context, entityIDs).behavior,
38248       operationReflectShort(context, entityIDs).behavior,
38249       operationRotate(context, entityIDs).behavior
38250     ];
38251     var annotation = entityIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.move.annotation.feature", { n: entityIDs.length });
38252     var _prevGraph;
38253     var _cache5;
38254     var _origin;
38255     var _nudgeInterval;
38256     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38257     function doMove(nudge) {
38258       nudge = nudge || [0, 0];
38259       var fn;
38260       if (_prevGraph !== context.graph()) {
38261         _cache5 = {};
38262         _origin = context.map().mouseCoordinates();
38263         fn = context.perform;
38264       } else {
38265         fn = context.overwrite;
38266       }
38267       var currMouse = context.map().mouse();
38268       var origMouse = context.projection(_origin);
38269       var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
38270       fn(actionMove(entityIDs, delta, context.projection, _cache5));
38271       _prevGraph = context.graph();
38272     }
38273     function startNudge(nudge) {
38274       if (_nudgeInterval)
38275         window.clearInterval(_nudgeInterval);
38276       _nudgeInterval = window.setInterval(function() {
38277         context.map().pan(nudge);
38278         doMove(nudge);
38279       }, 50);
38280     }
38281     function stopNudge() {
38282       if (_nudgeInterval) {
38283         window.clearInterval(_nudgeInterval);
38284         _nudgeInterval = null;
38285       }
38286     }
38287     function move() {
38288       doMove();
38289       var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
38290       if (nudge) {
38291         startNudge(nudge);
38292       } else {
38293         stopNudge();
38294       }
38295     }
38296     function finish(d3_event) {
38297       d3_event.stopPropagation();
38298       context.replace(actionNoop(), annotation);
38299       context.enter(modeSelect(context, entityIDs));
38300       stopNudge();
38301     }
38302     function cancel() {
38303       if (baseGraph) {
38304         while (context.graph() !== baseGraph)
38305           context.pop();
38306         context.enter(modeBrowse(context));
38307       } else {
38308         if (_prevGraph)
38309           context.pop();
38310         context.enter(modeSelect(context, entityIDs));
38311       }
38312       stopNudge();
38313     }
38314     function undone() {
38315       context.enter(modeBrowse(context));
38316     }
38317     mode.enter = function() {
38318       _origin = context.map().mouseCoordinates();
38319       _prevGraph = null;
38320       _cache5 = {};
38321       context.features().forceVisible(entityIDs);
38322       behaviors.forEach(context.install);
38323       var downEvent;
38324       context.surface().on(_pointerPrefix + "down.modeMove", function(d3_event) {
38325         downEvent = d3_event;
38326       });
38327       select_default2(window).on(_pointerPrefix + "move.modeMove", move, true).on(_pointerPrefix + "up.modeMove", function(d3_event) {
38328         if (!downEvent)
38329           return;
38330         var mapNode = context.container().select(".main-map").node();
38331         var pointGetter = utilFastMouse(mapNode);
38332         var p1 = pointGetter(downEvent);
38333         var p2 = pointGetter(d3_event);
38334         var dist = geoVecLength(p1, p2);
38335         if (dist <= _tolerancePx)
38336           finish(d3_event);
38337         downEvent = null;
38338       }, true);
38339       context.history().on("undone.modeMove", undone);
38340       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38341       select_default2(document).call(keybinding);
38342     };
38343     mode.exit = function() {
38344       stopNudge();
38345       behaviors.forEach(function(behavior) {
38346         context.uninstall(behavior);
38347       });
38348       context.surface().on(_pointerPrefix + "down.modeMove", null);
38349       select_default2(window).on(_pointerPrefix + "move.modeMove", null, true).on(_pointerPrefix + "up.modeMove", null, true);
38350       context.history().on("undone.modeMove", null);
38351       select_default2(document).call(keybinding.unbind);
38352       context.features().forceVisible([]);
38353     };
38354     mode.selectedIDs = function() {
38355       if (!arguments.length)
38356         return entityIDs;
38357       return mode;
38358     };
38359     return mode;
38360   }
38361
38362   // modules/behavior/paste.js
38363   function behaviorPaste(context) {
38364     function doPaste(d3_event) {
38365       if (!context.map().withinEditableZoom())
38366         return;
38367       d3_event.preventDefault();
38368       var baseGraph = context.graph();
38369       var mouse = context.map().mouse();
38370       var projection2 = context.projection;
38371       var viewport = geoExtent(projection2.clipExtent()).polygon();
38372       if (!geoPointInPolygon(mouse, viewport))
38373         return;
38374       var oldIDs = context.copyIDs();
38375       if (!oldIDs.length)
38376         return;
38377       var extent = geoExtent();
38378       var oldGraph = context.copyGraph();
38379       var newIDs = [];
38380       var action = actionCopyEntities(oldIDs, oldGraph);
38381       context.perform(action);
38382       var copies = action.copies();
38383       var originals = /* @__PURE__ */ new Set();
38384       Object.values(copies).forEach(function(entity) {
38385         originals.add(entity.id);
38386       });
38387       for (var id2 in copies) {
38388         var oldEntity = oldGraph.entity(id2);
38389         var newEntity = copies[id2];
38390         extent._extend(oldEntity.extent(oldGraph));
38391         var parents = context.graph().parentWays(newEntity);
38392         var parentCopied = parents.some(function(parent) {
38393           return originals.has(parent.id);
38394         });
38395         if (!parentCopied) {
38396           newIDs.push(newEntity.id);
38397         }
38398       }
38399       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
38400       var delta = geoVecSubtract(mouse, copyPoint);
38401       context.perform(actionMove(newIDs, delta, projection2));
38402       context.enter(modeMove(context, newIDs, baseGraph));
38403     }
38404     function behavior() {
38405       context.keybinding().on(uiCmd("\u2318V"), doPaste);
38406       return behavior;
38407     }
38408     behavior.off = function() {
38409       context.keybinding().off(uiCmd("\u2318V"));
38410     };
38411     return behavior;
38412   }
38413
38414   // modules/behavior/drag.js
38415   function behaviorDrag() {
38416     var dispatch14 = dispatch_default("start", "move", "end");
38417     var _tolerancePx = 1;
38418     var _penTolerancePx = 4;
38419     var _origin = null;
38420     var _selector = "";
38421     var _targetNode;
38422     var _targetEntity;
38423     var _surface;
38424     var _pointerId;
38425     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38426     var d3_event_userSelectProperty = utilPrefixCSSProperty("UserSelect");
38427     var d3_event_userSelectSuppress = function() {
38428       var selection2 = selection_default();
38429       var select = selection2.style(d3_event_userSelectProperty);
38430       selection2.style(d3_event_userSelectProperty, "none");
38431       return function() {
38432         selection2.style(d3_event_userSelectProperty, select);
38433       };
38434     };
38435     function pointerdown(d3_event) {
38436       if (_pointerId)
38437         return;
38438       _pointerId = d3_event.pointerId || "mouse";
38439       _targetNode = this;
38440       var pointerLocGetter = utilFastMouse(_surface || _targetNode.parentNode);
38441       var offset;
38442       var startOrigin = pointerLocGetter(d3_event);
38443       var started = false;
38444       var selectEnable = d3_event_userSelectSuppress();
38445       select_default2(window).on(_pointerPrefix + "move.drag", pointermove).on(_pointerPrefix + "up.drag pointercancel.drag", pointerup, true);
38446       if (_origin) {
38447         offset = _origin.call(_targetNode, _targetEntity);
38448         offset = [offset[0] - startOrigin[0], offset[1] - startOrigin[1]];
38449       } else {
38450         offset = [0, 0];
38451       }
38452       d3_event.stopPropagation();
38453       function pointermove(d3_event2) {
38454         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38455           return;
38456         var p2 = pointerLocGetter(d3_event2);
38457         if (!started) {
38458           var dist = geoVecLength(startOrigin, p2);
38459           var tolerance = d3_event2.pointerType === "pen" ? _penTolerancePx : _tolerancePx;
38460           if (dist < tolerance)
38461             return;
38462           started = true;
38463           dispatch14.call("start", this, d3_event2, _targetEntity);
38464         } else {
38465           startOrigin = p2;
38466           d3_event2.stopPropagation();
38467           d3_event2.preventDefault();
38468           var dx = p2[0] - startOrigin[0];
38469           var dy = p2[1] - startOrigin[1];
38470           dispatch14.call("move", this, d3_event2, _targetEntity, [p2[0] + offset[0], p2[1] + offset[1]], [dx, dy]);
38471         }
38472       }
38473       function pointerup(d3_event2) {
38474         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38475           return;
38476         _pointerId = null;
38477         if (started) {
38478           dispatch14.call("end", this, d3_event2, _targetEntity);
38479           d3_event2.preventDefault();
38480         }
38481         select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38482         selectEnable();
38483       }
38484     }
38485     function behavior(selection2) {
38486       var matchesSelector = utilPrefixDOMProperty("matchesSelector");
38487       var delegate = pointerdown;
38488       if (_selector) {
38489         delegate = function(d3_event) {
38490           var root3 = this;
38491           var target = d3_event.target;
38492           for (; target && target !== root3; target = target.parentNode) {
38493             var datum2 = target.__data__;
38494             _targetEntity = datum2 instanceof osmNote ? datum2 : datum2 && datum2.properties && datum2.properties.entity;
38495             if (_targetEntity && target[matchesSelector](_selector)) {
38496               return pointerdown.call(target, d3_event);
38497             }
38498           }
38499         };
38500       }
38501       selection2.on(_pointerPrefix + "down.drag" + _selector, delegate);
38502     }
38503     behavior.off = function(selection2) {
38504       selection2.on(_pointerPrefix + "down.drag" + _selector, null);
38505     };
38506     behavior.selector = function(_2) {
38507       if (!arguments.length)
38508         return _selector;
38509       _selector = _2;
38510       return behavior;
38511     };
38512     behavior.origin = function(_2) {
38513       if (!arguments.length)
38514         return _origin;
38515       _origin = _2;
38516       return behavior;
38517     };
38518     behavior.cancel = function() {
38519       select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38520       return behavior;
38521     };
38522     behavior.targetNode = function(_2) {
38523       if (!arguments.length)
38524         return _targetNode;
38525       _targetNode = _2;
38526       return behavior;
38527     };
38528     behavior.targetEntity = function(_2) {
38529       if (!arguments.length)
38530         return _targetEntity;
38531       _targetEntity = _2;
38532       return behavior;
38533     };
38534     behavior.surface = function(_2) {
38535       if (!arguments.length)
38536         return _surface;
38537       _surface = _2;
38538       return behavior;
38539     };
38540     return utilRebind(behavior, dispatch14, "on");
38541   }
38542
38543   // modules/modes/drag_node.js
38544   function modeDragNode(context) {
38545     var mode = {
38546       id: "drag-node",
38547       button: "browse"
38548     };
38549     var hover = behaviorHover(context).altDisables(true).on("hover", context.ui().sidebar.hover);
38550     var edit2 = behaviorEdit(context);
38551     var _nudgeInterval;
38552     var _restoreSelectedIDs = [];
38553     var _wasMidpoint = false;
38554     var _isCancelled = false;
38555     var _activeEntity;
38556     var _startLoc;
38557     var _lastLoc;
38558     function startNudge(d3_event, entity, nudge) {
38559       if (_nudgeInterval)
38560         window.clearInterval(_nudgeInterval);
38561       _nudgeInterval = window.setInterval(function() {
38562         context.map().pan(nudge);
38563         doMove(d3_event, entity, nudge);
38564       }, 50);
38565     }
38566     function stopNudge() {
38567       if (_nudgeInterval) {
38568         window.clearInterval(_nudgeInterval);
38569         _nudgeInterval = null;
38570       }
38571     }
38572     function moveAnnotation(entity) {
38573       return _t("operations.move.annotation." + entity.geometry(context.graph()));
38574     }
38575     function connectAnnotation(nodeEntity, targetEntity) {
38576       var nodeGeometry = nodeEntity.geometry(context.graph());
38577       var targetGeometry = targetEntity.geometry(context.graph());
38578       if (nodeGeometry === "vertex" && targetGeometry === "vertex") {
38579         var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
38580         var targetParentWayIDs = context.graph().parentWays(targetEntity);
38581         var sharedParentWays = utilArrayIntersection(nodeParentWayIDs, targetParentWayIDs);
38582         if (sharedParentWays.length !== 0) {
38583           if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
38584             return _t("operations.connect.annotation.from_vertex.to_adjacent_vertex");
38585           }
38586           return _t("operations.connect.annotation.from_vertex.to_sibling_vertex");
38587         }
38588       }
38589       return _t("operations.connect.annotation.from_" + nodeGeometry + ".to_" + targetGeometry);
38590     }
38591     function shouldSnapToNode(target) {
38592       if (!_activeEntity)
38593         return false;
38594       return _activeEntity.geometry(context.graph()) !== "vertex" || (target.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(target, context.graph()));
38595     }
38596     function origin(entity) {
38597       return context.projection(entity.loc);
38598     }
38599     function keydown(d3_event) {
38600       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38601         if (context.surface().classed("nope")) {
38602           context.surface().classed("nope-suppressed", true);
38603         }
38604         context.surface().classed("nope", false).classed("nope-disabled", true);
38605       }
38606     }
38607     function keyup(d3_event) {
38608       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38609         if (context.surface().classed("nope-suppressed")) {
38610           context.surface().classed("nope", true);
38611         }
38612         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
38613       }
38614     }
38615     function start2(d3_event, entity) {
38616       _wasMidpoint = entity.type === "midpoint";
38617       var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
38618       _isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
38619       if (_isCancelled) {
38620         if (hasHidden) {
38621           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("modes.drag_node.connected_to_hidden"))();
38622         }
38623         return drag.cancel();
38624       }
38625       if (_wasMidpoint) {
38626         var midpoint = entity;
38627         entity = osmNode();
38628         context.perform(actionAddMidpoint(midpoint, entity));
38629         entity = context.entity(entity.id);
38630         var vertex = context.surface().selectAll("." + entity.id);
38631         drag.targetNode(vertex.node()).targetEntity(entity);
38632       } else {
38633         context.perform(actionNoop());
38634       }
38635       _activeEntity = entity;
38636       _startLoc = entity.loc;
38637       hover.ignoreVertex(entity.geometry(context.graph()) === "vertex");
38638       context.surface().selectAll("." + _activeEntity.id).classed("active", true);
38639       context.enter(mode);
38640     }
38641     function datum2(d3_event) {
38642       if (!d3_event || d3_event.altKey) {
38643         return {};
38644       } else {
38645         var d2 = d3_event.target.__data__;
38646         return d2 && d2.properties && d2.properties.target ? d2 : {};
38647       }
38648     }
38649     function doMove(d3_event, entity, nudge) {
38650       nudge = nudge || [0, 0];
38651       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
38652       var currMouse = geoVecSubtract(currPoint, nudge);
38653       var loc = context.projection.invert(currMouse);
38654       var target, edge;
38655       if (!_nudgeInterval) {
38656         var d2 = datum2(d3_event);
38657         target = d2 && d2.properties && d2.properties.entity;
38658         var targetLoc = target && target.loc;
38659         var targetNodes = d2 && d2.properties && d2.properties.nodes;
38660         if (targetLoc) {
38661           if (shouldSnapToNode(target)) {
38662             loc = targetLoc;
38663           }
38664         } else if (targetNodes) {
38665           edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
38666           if (edge) {
38667             loc = edge.loc;
38668           }
38669         }
38670       }
38671       context.replace(
38672         actionMoveNode(entity.id, loc)
38673       );
38674       var isInvalid = false;
38675       if (target) {
38676         isInvalid = hasRelationConflict(entity, target, edge, context.graph());
38677       }
38678       if (!isInvalid) {
38679         isInvalid = hasInvalidGeometry(entity, context.graph());
38680       }
38681       var nope = context.surface().classed("nope");
38682       if (isInvalid === "relation" || isInvalid === "restriction") {
38683         if (!nope) {
38684           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(
38685             "operations.connect." + isInvalid,
38686             { relation: _mainPresetIndex.item("type/restriction").name() }
38687           ))();
38688         }
38689       } else if (isInvalid) {
38690         var errorID = isInvalid === "line" ? "lines" : "areas";
38691         context.ui().flash.duration(3e3).iconName("#iD-icon-no").label(_t.append("self_intersection.error." + errorID))();
38692       } else {
38693         if (nope) {
38694           context.ui().flash.duration(1).label("")();
38695         }
38696       }
38697       var nopeDisabled = context.surface().classed("nope-disabled");
38698       if (nopeDisabled) {
38699         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
38700       } else {
38701         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
38702       }
38703       _lastLoc = loc;
38704     }
38705     function hasRelationConflict(entity, target, edge, graph) {
38706       var testGraph = graph.update();
38707       if (edge) {
38708         var midpoint = osmNode();
38709         var action = actionAddMidpoint({
38710           loc: edge.loc,
38711           edge: [target.nodes[edge.index - 1], target.nodes[edge.index]]
38712         }, midpoint);
38713         testGraph = action(testGraph);
38714         target = midpoint;
38715       }
38716       var ids = [entity.id, target.id];
38717       return actionConnect(ids).disabled(testGraph);
38718     }
38719     function hasInvalidGeometry(entity, graph) {
38720       var parents = graph.parentWays(entity);
38721       var i3, j2, k2;
38722       for (i3 = 0; i3 < parents.length; i3++) {
38723         var parent = parents[i3];
38724         var nodes = [];
38725         var activeIndex = null;
38726         var relations = graph.parentRelations(parent);
38727         for (j2 = 0; j2 < relations.length; j2++) {
38728           if (!relations[j2].isMultipolygon())
38729             continue;
38730           var rings = osmJoinWays(relations[j2].members, graph);
38731           for (k2 = 0; k2 < rings.length; k2++) {
38732             nodes = rings[k2].nodes;
38733             if (nodes.find(function(n3) {
38734               return n3.id === entity.id;
38735             })) {
38736               activeIndex = k2;
38737               if (geoHasSelfIntersections(nodes, entity.id)) {
38738                 return "multipolygonMember";
38739               }
38740             }
38741             rings[k2].coords = nodes.map(function(n3) {
38742               return n3.loc;
38743             });
38744           }
38745           for (k2 = 0; k2 < rings.length; k2++) {
38746             if (k2 === activeIndex)
38747               continue;
38748             if (geoHasLineIntersections(rings[activeIndex].nodes, rings[k2].nodes, entity.id)) {
38749               return "multipolygonRing";
38750             }
38751           }
38752         }
38753         if (activeIndex === null) {
38754           nodes = parent.nodes.map(function(nodeID) {
38755             return graph.entity(nodeID);
38756           });
38757           if (nodes.length && geoHasSelfIntersections(nodes, entity.id)) {
38758             return parent.geometry(graph);
38759           }
38760         }
38761       }
38762       return false;
38763     }
38764     function move(d3_event, entity, point2) {
38765       if (_isCancelled)
38766         return;
38767       d3_event.stopPropagation();
38768       context.surface().classed("nope-disabled", d3_event.altKey);
38769       _lastLoc = context.projection.invert(point2);
38770       doMove(d3_event, entity);
38771       var nudge = geoViewportEdge(point2, context.map().dimensions());
38772       if (nudge) {
38773         startNudge(d3_event, entity, nudge);
38774       } else {
38775         stopNudge();
38776       }
38777     }
38778     function end(d3_event, entity) {
38779       if (_isCancelled)
38780         return;
38781       var wasPoint = entity.geometry(context.graph()) === "point";
38782       var d2 = datum2(d3_event);
38783       var nope = d2 && d2.properties && d2.properties.nope || context.surface().classed("nope");
38784       var target = d2 && d2.properties && d2.properties.entity;
38785       if (nope) {
38786         context.perform(
38787           _actionBounceBack(entity.id, _startLoc)
38788         );
38789       } else if (target && target.type === "way") {
38790         var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
38791         context.replace(
38792           actionAddMidpoint({
38793             loc: choice.loc,
38794             edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
38795           }, entity),
38796           connectAnnotation(entity, target)
38797         );
38798       } else if (target && target.type === "node" && shouldSnapToNode(target)) {
38799         context.replace(
38800           actionConnect([target.id, entity.id]),
38801           connectAnnotation(entity, target)
38802         );
38803       } else if (_wasMidpoint) {
38804         context.replace(
38805           actionNoop(),
38806           _t("operations.add.annotation.vertex")
38807         );
38808       } else {
38809         context.replace(
38810           actionNoop(),
38811           moveAnnotation(entity)
38812         );
38813       }
38814       if (wasPoint) {
38815         context.enter(modeSelect(context, [entity.id]));
38816       } else {
38817         var reselection = _restoreSelectedIDs.filter(function(id2) {
38818           return context.graph().hasEntity(id2);
38819         });
38820         if (reselection.length) {
38821           context.enter(modeSelect(context, reselection));
38822         } else {
38823           context.enter(modeBrowse(context));
38824         }
38825       }
38826     }
38827     function _actionBounceBack(nodeID, toLoc) {
38828       var moveNode = actionMoveNode(nodeID, toLoc);
38829       var action = function(graph, t2) {
38830         if (t2 === 1)
38831           context.pop();
38832         return moveNode(graph, t2);
38833       };
38834       action.transitionable = true;
38835       return action;
38836     }
38837     function cancel() {
38838       drag.cancel();
38839       context.enter(modeBrowse(context));
38840     }
38841     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);
38842     mode.enter = function() {
38843       context.install(hover);
38844       context.install(edit2);
38845       select_default2(window).on("keydown.dragNode", keydown).on("keyup.dragNode", keyup);
38846       context.history().on("undone.drag-node", cancel);
38847     };
38848     mode.exit = function() {
38849       context.ui().sidebar.hover.cancel();
38850       context.uninstall(hover);
38851       context.uninstall(edit2);
38852       select_default2(window).on("keydown.dragNode", null).on("keyup.dragNode", null);
38853       context.history().on("undone.drag-node", null);
38854       _activeEntity = null;
38855       context.surface().classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false).selectAll(".active").classed("active", false);
38856       stopNudge();
38857     };
38858     mode.selectedIDs = function() {
38859       if (!arguments.length)
38860         return _activeEntity ? [_activeEntity.id] : [];
38861       return mode;
38862     };
38863     mode.activeID = function() {
38864       if (!arguments.length)
38865         return _activeEntity && _activeEntity.id;
38866       return mode;
38867     };
38868     mode.restoreSelectedIDs = function(_2) {
38869       if (!arguments.length)
38870         return _restoreSelectedIDs;
38871       _restoreSelectedIDs = _2;
38872       return mode;
38873     };
38874     mode.behavior = drag;
38875     return mode;
38876   }
38877
38878   // modules/services/keepRight.js
38879   var import_rbush = __toESM(require_rbush_min());
38880
38881   // node_modules/d3-fetch/src/text.js
38882   function responseText(response) {
38883     if (!response.ok)
38884       throw new Error(response.status + " " + response.statusText);
38885     return response.text();
38886   }
38887   function text_default3(input, init2) {
38888     return fetch(input, init2).then(responseText);
38889   }
38890
38891   // node_modules/d3-fetch/src/json.js
38892   function responseJson(response) {
38893     if (!response.ok)
38894       throw new Error(response.status + " " + response.statusText);
38895     if (response.status === 204 || response.status === 205)
38896       return;
38897     return response.json();
38898   }
38899   function json_default(input, init2) {
38900     return fetch(input, init2).then(responseJson);
38901   }
38902
38903   // node_modules/d3-fetch/src/xml.js
38904   function parser(type2) {
38905     return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2));
38906   }
38907   var xml_default = parser("application/xml");
38908   var html = parser("text/html");
38909   var svg = parser("image/svg+xml");
38910
38911   // modules/services/keepRight.js
38912   var tiler = utilTiler();
38913   var dispatch2 = dispatch_default("loaded");
38914   var _tileZoom = 14;
38915   var _krUrlRoot = "https://www.keepright.at";
38916   var _krData = { errorTypes: {}, localizeStrings: {} };
38917   var _cache;
38918   var _krRuleset = [
38919     // no 20 - multiple node on same spot - these are mostly boundaries overlapping roads
38920     30,
38921     40,
38922     50,
38923     60,
38924     70,
38925     90,
38926     100,
38927     110,
38928     120,
38929     130,
38930     150,
38931     160,
38932     170,
38933     180,
38934     190,
38935     191,
38936     192,
38937     193,
38938     194,
38939     195,
38940     196,
38941     197,
38942     198,
38943     200,
38944     201,
38945     202,
38946     203,
38947     204,
38948     205,
38949     206,
38950     207,
38951     208,
38952     210,
38953     220,
38954     230,
38955     231,
38956     232,
38957     270,
38958     280,
38959     281,
38960     282,
38961     283,
38962     284,
38963     285,
38964     290,
38965     291,
38966     292,
38967     293,
38968     294,
38969     295,
38970     296,
38971     297,
38972     298,
38973     300,
38974     310,
38975     311,
38976     312,
38977     313,
38978     320,
38979     350,
38980     360,
38981     370,
38982     380,
38983     390,
38984     400,
38985     401,
38986     402,
38987     410,
38988     411,
38989     412,
38990     413
38991   ];
38992   function abortRequest(controller) {
38993     if (controller) {
38994       controller.abort();
38995     }
38996   }
38997   function abortUnwantedRequests(cache, tiles) {
38998     Object.keys(cache.inflightTile).forEach((k2) => {
38999       const wanted = tiles.find((tile) => k2 === tile.id);
39000       if (!wanted) {
39001         abortRequest(cache.inflightTile[k2]);
39002         delete cache.inflightTile[k2];
39003       }
39004     });
39005   }
39006   function encodeIssueRtree(d2) {
39007     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39008   }
39009   function updateRtree(item, replace) {
39010     _cache.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39011     if (replace) {
39012       _cache.rtree.insert(item);
39013     }
39014   }
39015   function tokenReplacements(d2) {
39016     if (!(d2 instanceof QAItem))
39017       return;
39018     const replacements = {};
39019     const issueTemplate = _krData.errorTypes[d2.whichType];
39020     if (!issueTemplate) {
39021       console.log("No Template: ", d2.whichType);
39022       console.log("  ", d2.description);
39023       return;
39024     }
39025     if (!issueTemplate.regex)
39026       return;
39027     const errorRegex = new RegExp(issueTemplate.regex, "i");
39028     const errorMatch = errorRegex.exec(d2.description);
39029     if (!errorMatch) {
39030       console.log("Unmatched: ", d2.whichType);
39031       console.log("  ", d2.description);
39032       console.log("  ", errorRegex);
39033       return;
39034     }
39035     for (let i3 = 1; i3 < errorMatch.length; i3++) {
39036       let capture = errorMatch[i3];
39037       let idType;
39038       idType = "IDs" in issueTemplate ? issueTemplate.IDs[i3 - 1] : "";
39039       if (idType && capture) {
39040         capture = parseError(capture, idType);
39041       } else {
39042         const compare2 = capture.toLowerCase();
39043         if (_krData.localizeStrings[compare2]) {
39044           capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39045         } else {
39046           capture = unescape_default(capture);
39047         }
39048       }
39049       replacements["var" + i3] = capture;
39050     }
39051     return replacements;
39052   }
39053   function parseError(capture, idType) {
39054     const compare2 = capture.toLowerCase();
39055     if (_krData.localizeStrings[compare2]) {
39056       capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39057     }
39058     switch (idType) {
39059       case "this":
39060         capture = linkErrorObject2(capture);
39061         break;
39062       case "url":
39063         capture = linkURL(capture);
39064         break;
39065       case "n":
39066       case "w":
39067       case "r":
39068         capture = linkEntity2(idType + capture);
39069         break;
39070       case "20":
39071         capture = parse20(capture);
39072         break;
39073       case "211":
39074         capture = parse211(capture);
39075         break;
39076       case "231":
39077         capture = parse231(capture);
39078         break;
39079       case "294":
39080         capture = parse294(capture);
39081         break;
39082       case "370":
39083         capture = parse370(capture);
39084         break;
39085     }
39086     return capture;
39087     function linkErrorObject2(d2) {
39088       return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39089     }
39090     function linkEntity2(d2) {
39091       return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39092     }
39093     function linkURL(d2) {
39094       return { html: '<a class="kr_external_link" target="_blank" href="'.concat(d2, '">').concat(d2, "</a>") };
39095     }
39096     function parse211(capture2) {
39097       let newList = [];
39098       const items = capture2.split(", ");
39099       items.forEach((item) => {
39100         let id2 = linkEntity2("n" + item.slice(1));
39101         newList.push(id2);
39102       });
39103       return newList.join(", ");
39104     }
39105     function parse231(capture2) {
39106       let newList = [];
39107       const items = capture2.split("),");
39108       items.forEach((item) => {
39109         const match = item.match(/\#(\d+)\((.+)\)?/);
39110         if (match !== null && match.length > 2) {
39111           newList.push(
39112             linkEntity2("w" + match[1]) + " " + _t("QA.keepRight.errorTypes.231.layer", { layer: match[2] })
39113           );
39114         }
39115       });
39116       return newList.join(", ");
39117     }
39118     function parse294(capture2) {
39119       let newList = [];
39120       const items = capture2.split(",");
39121       items.forEach((item) => {
39122         item = item.split(" ");
39123         const role = '"'.concat(item[0], '"');
39124         const idType2 = item[1].slice(0, 1);
39125         let id2 = item[2].slice(1);
39126         id2 = linkEntity2(idType2 + id2);
39127         newList.push("".concat(role, " ").concat(item[1], " ").concat(id2));
39128       });
39129       return newList.join(", ");
39130     }
39131     function parse370(capture2) {
39132       if (!capture2)
39133         return "";
39134       const match = capture2.match(/\(including the name (\'.+\')\)/);
39135       if (match && match.length) {
39136         return _t("QA.keepRight.errorTypes.370.including_the_name", { name: match[1] });
39137       }
39138       return "";
39139     }
39140     function parse20(capture2) {
39141       let newList = [];
39142       const items = capture2.split(",");
39143       items.forEach((item) => {
39144         const id2 = linkEntity2("n" + item.slice(1));
39145         newList.push(id2);
39146       });
39147       return newList.join(", ");
39148     }
39149   }
39150   var keepRight_default = {
39151     title: "keepRight",
39152     init() {
39153       _mainFileFetcher.get("keepRight").then((d2) => _krData = d2);
39154       if (!_cache) {
39155         this.reset();
39156       }
39157       this.event = utilRebind(this, dispatch2, "on");
39158     },
39159     reset() {
39160       if (_cache) {
39161         Object.values(_cache.inflightTile).forEach(abortRequest);
39162       }
39163       _cache = {
39164         data: {},
39165         loadedTile: {},
39166         inflightTile: {},
39167         inflightPost: {},
39168         closed: {},
39169         rtree: new import_rbush.default()
39170       };
39171     },
39172     // KeepRight API:  http://osm.mueschelsoft.de/keepright/interfacing.php
39173     loadIssues(projection2) {
39174       const options2 = {
39175         format: "geojson",
39176         ch: _krRuleset
39177       };
39178       const tiles = tiler.zoomExtent([_tileZoom, _tileZoom]).getTiles(projection2);
39179       abortUnwantedRequests(_cache, tiles);
39180       tiles.forEach((tile) => {
39181         if (_cache.loadedTile[tile.id] || _cache.inflightTile[tile.id])
39182           return;
39183         const [left, top, right, bottom] = tile.extent.rectangle();
39184         const params = Object.assign({}, options2, { left, bottom, right, top });
39185         const url = "".concat(_krUrlRoot, "/export.php?") + utilQsString(params);
39186         const controller = new AbortController();
39187         _cache.inflightTile[tile.id] = controller;
39188         json_default(url, { signal: controller.signal }).then((data) => {
39189           delete _cache.inflightTile[tile.id];
39190           _cache.loadedTile[tile.id] = true;
39191           if (!data || !data.features || !data.features.length) {
39192             throw new Error("No Data");
39193           }
39194           data.features.forEach((feature3) => {
39195             const {
39196               properties: {
39197                 error_type: itemType,
39198                 error_id: id2,
39199                 comment = null,
39200                 object_id: objectId,
39201                 object_type: objectType,
39202                 schema,
39203                 title
39204               }
39205             } = feature3;
39206             let {
39207               geometry: { coordinates: loc },
39208               properties: { description = "" }
39209             } = feature3;
39210             const issueTemplate = _krData.errorTypes[itemType];
39211             const parentIssueType = (Math.floor(itemType / 10) * 10).toString();
39212             const whichType = issueTemplate ? itemType : parentIssueType;
39213             const whichTemplate = _krData.errorTypes[whichType];
39214             switch (whichType) {
39215               case "170":
39216                 description = "This feature has a FIXME tag: ".concat(description);
39217                 break;
39218               case "292":
39219               case "293":
39220                 description = description.replace("A turn-", "This turn-");
39221                 break;
39222               case "294":
39223               case "295":
39224               case "296":
39225               case "297":
39226               case "298":
39227                 description = "This turn-restriction~".concat(description);
39228                 break;
39229               case "300":
39230                 description = "This highway is missing a maxspeed tag";
39231                 break;
39232               case "411":
39233               case "412":
39234               case "413":
39235                 description = "This feature~".concat(description);
39236                 break;
39237             }
39238             let coincident = false;
39239             do {
39240               let delta = coincident ? [1e-5, 0] : [0, 1e-5];
39241               loc = geoVecAdd(loc, delta);
39242               let bbox2 = geoExtent(loc).bbox();
39243               coincident = _cache.rtree.search(bbox2).length;
39244             } while (coincident);
39245             let d2 = new QAItem(loc, this, itemType, id2, {
39246               comment,
39247               description,
39248               whichType,
39249               parentIssueType,
39250               severity: whichTemplate.severity || "error",
39251               objectId,
39252               objectType,
39253               schema,
39254               title
39255             });
39256             d2.replacements = tokenReplacements(d2);
39257             _cache.data[id2] = d2;
39258             _cache.rtree.insert(encodeIssueRtree(d2));
39259           });
39260           dispatch2.call("loaded");
39261         }).catch(() => {
39262           delete _cache.inflightTile[tile.id];
39263           _cache.loadedTile[tile.id] = true;
39264         });
39265       });
39266     },
39267     postUpdate(d2, callback) {
39268       if (_cache.inflightPost[d2.id]) {
39269         return callback({ message: "Error update already inflight", status: -2 }, d2);
39270       }
39271       const params = { schema: d2.schema, id: d2.id };
39272       if (d2.newStatus) {
39273         params.st = d2.newStatus;
39274       }
39275       if (d2.newComment !== void 0) {
39276         params.co = d2.newComment;
39277       }
39278       const url = "".concat(_krUrlRoot, "/comment.php?") + utilQsString(params);
39279       const controller = new AbortController();
39280       _cache.inflightPost[d2.id] = controller;
39281       json_default(url, { signal: controller.signal }).finally(() => {
39282         delete _cache.inflightPost[d2.id];
39283         if (d2.newStatus === "ignore") {
39284           this.removeItem(d2);
39285         } else if (d2.newStatus === "ignore_t") {
39286           this.removeItem(d2);
39287           _cache.closed["".concat(d2.schema, ":").concat(d2.id)] = true;
39288         } else {
39289           d2 = this.replaceItem(d2.update({
39290             comment: d2.newComment,
39291             newComment: void 0,
39292             newState: void 0
39293           }));
39294         }
39295         if (callback)
39296           callback(null, d2);
39297       });
39298     },
39299     // Get all cached QAItems covering the viewport
39300     getItems(projection2) {
39301       const viewport = projection2.clipExtent();
39302       const min3 = [viewport[0][0], viewport[1][1]];
39303       const max3 = [viewport[1][0], viewport[0][1]];
39304       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39305       return _cache.rtree.search(bbox2).map((d2) => d2.data);
39306     },
39307     // Get a QAItem from cache
39308     // NOTE: Don't change method name until UI v3 is merged
39309     getError(id2) {
39310       return _cache.data[id2];
39311     },
39312     // Replace a single QAItem in the cache
39313     replaceItem(item) {
39314       if (!(item instanceof QAItem) || !item.id)
39315         return;
39316       _cache.data[item.id] = item;
39317       updateRtree(encodeIssueRtree(item), true);
39318       return item;
39319     },
39320     // Remove a single QAItem from the cache
39321     removeItem(item) {
39322       if (!(item instanceof QAItem) || !item.id)
39323         return;
39324       delete _cache.data[item.id];
39325       updateRtree(encodeIssueRtree(item), false);
39326     },
39327     issueURL(item) {
39328       return "".concat(_krUrlRoot, "/report_map.php?schema=").concat(item.schema, "&error=").concat(item.id);
39329     },
39330     // Get an array of issues closed during this session.
39331     // Used to populate `closed:keepright` changeset tag
39332     getClosedIDs() {
39333       return Object.keys(_cache.closed).sort();
39334     }
39335   };
39336
39337   // modules/services/improveOSM.js
39338   var import_rbush2 = __toESM(require_rbush_min());
39339   var tiler2 = utilTiler();
39340   var dispatch3 = dispatch_default("loaded");
39341   var _tileZoom2 = 14;
39342   var _impOsmUrls = {
39343     ow: "https://grab.community.improve-osm.org/directionOfFlowService",
39344     mr: "https://grab.community.improve-osm.org/missingGeoService",
39345     tr: "https://grab.community.improve-osm.org/turnRestrictionService"
39346   };
39347   var _impOsmData = { icons: {} };
39348   var _cache2;
39349   function abortRequest2(i3) {
39350     Object.values(i3).forEach((controller) => {
39351       if (controller) {
39352         controller.abort();
39353       }
39354     });
39355   }
39356   function abortUnwantedRequests2(cache, tiles) {
39357     Object.keys(cache.inflightTile).forEach((k2) => {
39358       const wanted = tiles.find((tile) => k2 === tile.id);
39359       if (!wanted) {
39360         abortRequest2(cache.inflightTile[k2]);
39361         delete cache.inflightTile[k2];
39362       }
39363     });
39364   }
39365   function encodeIssueRtree2(d2) {
39366     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39367   }
39368   function updateRtree2(item, replace) {
39369     _cache2.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39370     if (replace) {
39371       _cache2.rtree.insert(item);
39372     }
39373   }
39374   function linkErrorObject(d2) {
39375     return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39376   }
39377   function linkEntity(d2) {
39378     return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39379   }
39380   function pointAverage(points) {
39381     if (points.length) {
39382       const sum = points.reduce(
39383         (acc, point2) => geoVecAdd(acc, [point2.lon, point2.lat]),
39384         [0, 0]
39385       );
39386       return geoVecScale(sum, 1 / points.length);
39387     } else {
39388       return [0, 0];
39389     }
39390   }
39391   function relativeBearing(p1, p2) {
39392     let angle2 = Math.atan2(p2.lon - p1.lon, p2.lat - p1.lat);
39393     if (angle2 < 0) {
39394       angle2 += 2 * Math.PI;
39395     }
39396     return angle2 * 180 / Math.PI;
39397   }
39398   function cardinalDirection(bearing) {
39399     const dir = 45 * Math.round(bearing / 45);
39400     const compass = {
39401       0: "north",
39402       45: "northeast",
39403       90: "east",
39404       135: "southeast",
39405       180: "south",
39406       225: "southwest",
39407       270: "west",
39408       315: "northwest",
39409       360: "north"
39410     };
39411     return _t("QA.improveOSM.directions.".concat(compass[dir]));
39412   }
39413   function preventCoincident(loc, bumpUp) {
39414     let coincident = false;
39415     do {
39416       let delta = coincident ? [1e-5, 0] : bumpUp ? [0, 1e-5] : [0, 0];
39417       loc = geoVecAdd(loc, delta);
39418       let bbox2 = geoExtent(loc).bbox();
39419       coincident = _cache2.rtree.search(bbox2).length;
39420     } while (coincident);
39421     return loc;
39422   }
39423   var improveOSM_default = {
39424     title: "improveOSM",
39425     init() {
39426       _mainFileFetcher.get("qa_data").then((d2) => _impOsmData = d2.improveOSM);
39427       if (!_cache2) {
39428         this.reset();
39429       }
39430       this.event = utilRebind(this, dispatch3, "on");
39431     },
39432     reset() {
39433       if (_cache2) {
39434         Object.values(_cache2.inflightTile).forEach(abortRequest2);
39435       }
39436       _cache2 = {
39437         data: {},
39438         loadedTile: {},
39439         inflightTile: {},
39440         inflightPost: {},
39441         closed: {},
39442         rtree: new import_rbush2.default()
39443       };
39444     },
39445     loadIssues(projection2) {
39446       const options2 = {
39447         client: "iD",
39448         status: "OPEN",
39449         zoom: "19"
39450         // Use a high zoom so that clusters aren't returned
39451       };
39452       const tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2);
39453       abortUnwantedRequests2(_cache2, tiles);
39454       tiles.forEach((tile) => {
39455         if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id])
39456           return;
39457         const [east, north, west, south] = tile.extent.rectangle();
39458         const params = Object.assign({}, options2, { east, south, west, north });
39459         const requests = {};
39460         Object.keys(_impOsmUrls).forEach((k2) => {
39461           const kParams = Object.assign(
39462             {},
39463             params,
39464             k2 === "mr" ? { type: "PARKING,ROAD,BOTH,PATH" } : { confidenceLevel: "C1" }
39465           );
39466           const url = "".concat(_impOsmUrls[k2], "/search?") + utilQsString(kParams);
39467           const controller = new AbortController();
39468           requests[k2] = controller;
39469           json_default(url, { signal: controller.signal }).then((data) => {
39470             delete _cache2.inflightTile[tile.id][k2];
39471             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39472               delete _cache2.inflightTile[tile.id];
39473               _cache2.loadedTile[tile.id] = true;
39474             }
39475             if (data.roadSegments) {
39476               data.roadSegments.forEach((feature3) => {
39477                 const { points, wayId, fromNodeId, toNodeId } = feature3;
39478                 const itemId = "".concat(wayId).concat(fromNodeId).concat(toNodeId);
39479                 let mid = points.length / 2;
39480                 let loc;
39481                 if (mid % 1 === 0) {
39482                   loc = pointAverage([points[mid - 1], points[mid]]);
39483                 } else {
39484                   mid = points[Math.floor(mid)];
39485                   loc = [mid.lon, mid.lat];
39486                 }
39487                 loc = preventCoincident(loc, false);
39488                 let d2 = new QAItem(loc, this, k2, itemId, {
39489                   issueKey: k2,
39490                   // used as a category
39491                   identifier: {
39492                     // used to post changes
39493                     wayId,
39494                     fromNodeId,
39495                     toNodeId
39496                   },
39497                   objectId: wayId,
39498                   objectType: "way"
39499                 });
39500                 d2.replacements = {
39501                   percentage: feature3.percentOfTrips,
39502                   num_trips: feature3.numberOfTrips,
39503                   highway: linkErrorObject(_t("QA.keepRight.error_parts.highway")),
39504                   from_node: linkEntity("n" + feature3.fromNodeId),
39505                   to_node: linkEntity("n" + feature3.toNodeId)
39506                 };
39507                 _cache2.data[d2.id] = d2;
39508                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39509               });
39510             }
39511             if (data.tiles) {
39512               data.tiles.forEach((feature3) => {
39513                 const { type: type2, x: x2, y: y2, numberOfTrips } = feature3;
39514                 const geoType = type2.toLowerCase();
39515                 const itemId = "".concat(geoType).concat(x2).concat(y2).concat(numberOfTrips);
39516                 let loc = pointAverage(feature3.points);
39517                 loc = preventCoincident(loc, false);
39518                 let d2 = new QAItem(loc, this, "".concat(k2, "-").concat(geoType), itemId, {
39519                   issueKey: k2,
39520                   identifier: { x: x2, y: y2 }
39521                 });
39522                 d2.replacements = {
39523                   num_trips: numberOfTrips,
39524                   geometry_type: _t("QA.improveOSM.geometry_types.".concat(geoType))
39525                 };
39526                 if (numberOfTrips === -1) {
39527                   d2.desc = _t("QA.improveOSM.error_types.mr.description_alt", d2.replacements);
39528                 }
39529                 _cache2.data[d2.id] = d2;
39530                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39531               });
39532             }
39533             if (data.entities) {
39534               data.entities.forEach((feature3) => {
39535                 const { point: point2, id: id2, segments, numberOfPasses, turnType } = feature3;
39536                 const itemId = "".concat(id2.replace(/[,:+#]/g, "_"));
39537                 const loc = preventCoincident([point2.lon, point2.lat], true);
39538                 const ids = id2.split(",");
39539                 const from_way = ids[0];
39540                 const via_node = ids[3];
39541                 const to_way = ids[2].split(":")[1];
39542                 let d2 = new QAItem(loc, this, k2, itemId, {
39543                   issueKey: k2,
39544                   identifier: id2,
39545                   objectId: via_node,
39546                   objectType: "node"
39547                 });
39548                 const [p1, p2] = segments[0].points;
39549                 const dir_of_travel = cardinalDirection(relativeBearing(p1, p2));
39550                 d2.replacements = {
39551                   num_passed: numberOfPasses,
39552                   num_trips: segments[0].numberOfTrips,
39553                   turn_restriction: turnType.toLowerCase(),
39554                   from_way: linkEntity("w" + from_way),
39555                   to_way: linkEntity("w" + to_way),
39556                   travel_direction: dir_of_travel,
39557                   junction: linkErrorObject(_t("QA.keepRight.error_parts.this_node"))
39558                 };
39559                 _cache2.data[d2.id] = d2;
39560                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39561                 dispatch3.call("loaded");
39562               });
39563             }
39564           }).catch(() => {
39565             delete _cache2.inflightTile[tile.id][k2];
39566             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39567               delete _cache2.inflightTile[tile.id];
39568               _cache2.loadedTile[tile.id] = true;
39569             }
39570           });
39571         });
39572         _cache2.inflightTile[tile.id] = requests;
39573       });
39574     },
39575     getComments(item) {
39576       if (item.comments) {
39577         return Promise.resolve(item);
39578       }
39579       const key = item.issueKey;
39580       let qParams = {};
39581       if (key === "ow") {
39582         qParams = item.identifier;
39583       } else if (key === "mr") {
39584         qParams.tileX = item.identifier.x;
39585         qParams.tileY = item.identifier.y;
39586       } else if (key === "tr") {
39587         qParams.targetId = item.identifier;
39588       }
39589       const url = "".concat(_impOsmUrls[key], "/retrieveComments?") + utilQsString(qParams);
39590       const cacheComments = (data) => {
39591         item.comments = data.comments ? data.comments.reverse() : [];
39592         this.replaceItem(item);
39593       };
39594       return json_default(url).then(cacheComments).then(() => item);
39595     },
39596     postUpdate(d2, callback) {
39597       if (!osm_default.authenticated()) {
39598         return callback({ message: "Not Authenticated", status: -3 }, d2);
39599       }
39600       if (_cache2.inflightPost[d2.id]) {
39601         return callback({ message: "Error update already inflight", status: -2 }, d2);
39602       }
39603       osm_default.userDetails(sendPayload.bind(this));
39604       function sendPayload(err, user) {
39605         if (err) {
39606           return callback(err, d2);
39607         }
39608         const key = d2.issueKey;
39609         const url = "".concat(_impOsmUrls[key], "/comment");
39610         const payload = {
39611           username: user.display_name,
39612           targetIds: [d2.identifier]
39613         };
39614         if (d2.newStatus) {
39615           payload.status = d2.newStatus;
39616           payload.text = "status changed";
39617         }
39618         if (d2.newComment) {
39619           payload.text = d2.newComment;
39620         }
39621         const controller = new AbortController();
39622         _cache2.inflightPost[d2.id] = controller;
39623         const options2 = {
39624           method: "POST",
39625           signal: controller.signal,
39626           body: JSON.stringify(payload)
39627         };
39628         json_default(url, options2).then(() => {
39629           delete _cache2.inflightPost[d2.id];
39630           if (!d2.newStatus) {
39631             const now3 = /* @__PURE__ */ new Date();
39632             let comments = d2.comments ? d2.comments : [];
39633             comments.push({
39634               username: payload.username,
39635               text: payload.text,
39636               timestamp: now3.getTime() / 1e3
39637             });
39638             this.replaceItem(d2.update({
39639               comments,
39640               newComment: void 0
39641             }));
39642           } else {
39643             this.removeItem(d2);
39644             if (d2.newStatus === "SOLVED") {
39645               if (!(d2.issueKey in _cache2.closed)) {
39646                 _cache2.closed[d2.issueKey] = 0;
39647               }
39648               _cache2.closed[d2.issueKey] += 1;
39649             }
39650           }
39651           if (callback)
39652             callback(null, d2);
39653         }).catch((err2) => {
39654           delete _cache2.inflightPost[d2.id];
39655           if (callback)
39656             callback(err2.message);
39657         });
39658       }
39659     },
39660     // Get all cached QAItems covering the viewport
39661     getItems(projection2) {
39662       const viewport = projection2.clipExtent();
39663       const min3 = [viewport[0][0], viewport[1][1]];
39664       const max3 = [viewport[1][0], viewport[0][1]];
39665       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39666       return _cache2.rtree.search(bbox2).map((d2) => d2.data);
39667     },
39668     // Get a QAItem from cache
39669     // NOTE: Don't change method name until UI v3 is merged
39670     getError(id2) {
39671       return _cache2.data[id2];
39672     },
39673     // get the name of the icon to display for this item
39674     getIcon(itemType) {
39675       return _impOsmData.icons[itemType];
39676     },
39677     // Replace a single QAItem in the cache
39678     replaceItem(issue) {
39679       if (!(issue instanceof QAItem) || !issue.id)
39680         return;
39681       _cache2.data[issue.id] = issue;
39682       updateRtree2(encodeIssueRtree2(issue), true);
39683       return issue;
39684     },
39685     // Remove a single QAItem from the cache
39686     removeItem(issue) {
39687       if (!(issue instanceof QAItem) || !issue.id)
39688         return;
39689       delete _cache2.data[issue.id];
39690       updateRtree2(encodeIssueRtree2(issue), false);
39691     },
39692     // Used to populate `closed:improveosm:*` changeset tags
39693     getClosedCounts() {
39694       return _cache2.closed;
39695     }
39696   };
39697
39698   // modules/services/osmose.js
39699   var import_rbush3 = __toESM(require_rbush_min());
39700
39701   // node_modules/marked/lib/marked.esm.js
39702   function _getDefaults() {
39703     return {
39704       async: false,
39705       breaks: false,
39706       extensions: null,
39707       gfm: true,
39708       hooks: null,
39709       pedantic: false,
39710       renderer: null,
39711       silent: false,
39712       tokenizer: null,
39713       walkTokens: null
39714     };
39715   }
39716   var _defaults = _getDefaults();
39717   function changeDefaults(newDefaults) {
39718     _defaults = newDefaults;
39719   }
39720   var escapeTest = /[&<>"']/;
39721   var escapeReplace = new RegExp(escapeTest.source, "g");
39722   var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
39723   var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
39724   var escapeReplacements = {
39725     "&": "&amp;",
39726     "<": "&lt;",
39727     ">": "&gt;",
39728     '"': "&quot;",
39729     "'": "&#39;"
39730   };
39731   var getEscapeReplacement = (ch) => escapeReplacements[ch];
39732   function escape$1(html3, encode) {
39733     if (encode) {
39734       if (escapeTest.test(html3)) {
39735         return html3.replace(escapeReplace, getEscapeReplacement);
39736       }
39737     } else {
39738       if (escapeTestNoEncode.test(html3)) {
39739         return html3.replace(escapeReplaceNoEncode, getEscapeReplacement);
39740       }
39741     }
39742     return html3;
39743   }
39744   var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
39745   function unescape2(html3) {
39746     return html3.replace(unescapeTest, (_2, n3) => {
39747       n3 = n3.toLowerCase();
39748       if (n3 === "colon")
39749         return ":";
39750       if (n3.charAt(0) === "#") {
39751         return n3.charAt(1) === "x" ? String.fromCharCode(parseInt(n3.substring(2), 16)) : String.fromCharCode(+n3.substring(1));
39752       }
39753       return "";
39754     });
39755   }
39756   var caret = /(^|[^\[])\^/g;
39757   function edit(regex, opt) {
39758     let source = typeof regex === "string" ? regex : regex.source;
39759     opt = opt || "";
39760     const obj = {
39761       replace: (name, val) => {
39762         let valSource = typeof val === "string" ? val : val.source;
39763         valSource = valSource.replace(caret, "$1");
39764         source = source.replace(name, valSource);
39765         return obj;
39766       },
39767       getRegex: () => {
39768         return new RegExp(source, opt);
39769       }
39770     };
39771     return obj;
39772   }
39773   function cleanUrl(href) {
39774     try {
39775       href = encodeURI(href).replace(/%25/g, "%");
39776     } catch (e3) {
39777       return null;
39778     }
39779     return href;
39780   }
39781   var noopTest = { exec: () => null };
39782   function splitCells(tableRow, count) {
39783     const row = tableRow.replace(/\|/g, (match, offset, str) => {
39784       let escaped = false;
39785       let curr = offset;
39786       while (--curr >= 0 && str[curr] === "\\")
39787         escaped = !escaped;
39788       if (escaped) {
39789         return "|";
39790       } else {
39791         return " |";
39792       }
39793     }), cells = row.split(/ \|/);
39794     let i3 = 0;
39795     if (!cells[0].trim()) {
39796       cells.shift();
39797     }
39798     if (cells.length > 0 && !cells[cells.length - 1].trim()) {
39799       cells.pop();
39800     }
39801     if (count) {
39802       if (cells.length > count) {
39803         cells.splice(count);
39804       } else {
39805         while (cells.length < count)
39806           cells.push("");
39807       }
39808     }
39809     for (; i3 < cells.length; i3++) {
39810       cells[i3] = cells[i3].trim().replace(/\\\|/g, "|");
39811     }
39812     return cells;
39813   }
39814   function rtrim(str, c2, invert) {
39815     const l2 = str.length;
39816     if (l2 === 0) {
39817       return "";
39818     }
39819     let suffLen = 0;
39820     while (suffLen < l2) {
39821       const currChar = str.charAt(l2 - suffLen - 1);
39822       if (currChar === c2 && !invert) {
39823         suffLen++;
39824       } else if (currChar !== c2 && invert) {
39825         suffLen++;
39826       } else {
39827         break;
39828       }
39829     }
39830     return str.slice(0, l2 - suffLen);
39831   }
39832   function findClosingBracket(str, b2) {
39833     if (str.indexOf(b2[1]) === -1) {
39834       return -1;
39835     }
39836     let level = 0;
39837     for (let i3 = 0; i3 < str.length; i3++) {
39838       if (str[i3] === "\\") {
39839         i3++;
39840       } else if (str[i3] === b2[0]) {
39841         level++;
39842       } else if (str[i3] === b2[1]) {
39843         level--;
39844         if (level < 0) {
39845           return i3;
39846         }
39847       }
39848     }
39849     return -1;
39850   }
39851   function outputLink(cap, link3, raw, lexer2) {
39852     const href = link3.href;
39853     const title = link3.title ? escape$1(link3.title) : null;
39854     const text = cap[1].replace(/\\([\[\]])/g, "$1");
39855     if (cap[0].charAt(0) !== "!") {
39856       lexer2.state.inLink = true;
39857       const token = {
39858         type: "link",
39859         raw,
39860         href,
39861         title,
39862         text,
39863         tokens: lexer2.inlineTokens(text)
39864       };
39865       lexer2.state.inLink = false;
39866       return token;
39867     }
39868     return {
39869       type: "image",
39870       raw,
39871       href,
39872       title,
39873       text: escape$1(text)
39874     };
39875   }
39876   function indentCodeCompensation(raw, text) {
39877     const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
39878     if (matchIndentToCode === null) {
39879       return text;
39880     }
39881     const indentToCode = matchIndentToCode[1];
39882     return text.split("\n").map((node) => {
39883       const matchIndentInNode = node.match(/^\s+/);
39884       if (matchIndentInNode === null) {
39885         return node;
39886       }
39887       const [indentInNode] = matchIndentInNode;
39888       if (indentInNode.length >= indentToCode.length) {
39889         return node.slice(indentToCode.length);
39890       }
39891       return node;
39892     }).join("\n");
39893   }
39894   var _Tokenizer = class {
39895     // set by the lexer
39896     constructor(options2) {
39897       __publicField(this, "options");
39898       __publicField(this, "rules");
39899       // set by the lexer
39900       __publicField(this, "lexer");
39901       this.options = options2 || _defaults;
39902     }
39903     space(src) {
39904       const cap = this.rules.block.newline.exec(src);
39905       if (cap && cap[0].length > 0) {
39906         return {
39907           type: "space",
39908           raw: cap[0]
39909         };
39910       }
39911     }
39912     code(src) {
39913       const cap = this.rules.block.code.exec(src);
39914       if (cap) {
39915         const text = cap[0].replace(/^ {1,4}/gm, "");
39916         return {
39917           type: "code",
39918           raw: cap[0],
39919           codeBlockStyle: "indented",
39920           text: !this.options.pedantic ? rtrim(text, "\n") : text
39921         };
39922       }
39923     }
39924     fences(src) {
39925       const cap = this.rules.block.fences.exec(src);
39926       if (cap) {
39927         const raw = cap[0];
39928         const text = indentCodeCompensation(raw, cap[3] || "");
39929         return {
39930           type: "code",
39931           raw,
39932           lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
39933           text
39934         };
39935       }
39936     }
39937     heading(src) {
39938       const cap = this.rules.block.heading.exec(src);
39939       if (cap) {
39940         let text = cap[2].trim();
39941         if (/#$/.test(text)) {
39942           const trimmed = rtrim(text, "#");
39943           if (this.options.pedantic) {
39944             text = trimmed.trim();
39945           } else if (!trimmed || / $/.test(trimmed)) {
39946             text = trimmed.trim();
39947           }
39948         }
39949         return {
39950           type: "heading",
39951           raw: cap[0],
39952           depth: cap[1].length,
39953           text,
39954           tokens: this.lexer.inline(text)
39955         };
39956       }
39957     }
39958     hr(src) {
39959       const cap = this.rules.block.hr.exec(src);
39960       if (cap) {
39961         return {
39962           type: "hr",
39963           raw: cap[0]
39964         };
39965       }
39966     }
39967     blockquote(src) {
39968       const cap = this.rules.block.blockquote.exec(src);
39969       if (cap) {
39970         let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n    $1");
39971         text = rtrim(text.replace(/^ *>[ \t]?/gm, ""), "\n");
39972         const top = this.lexer.state.top;
39973         this.lexer.state.top = true;
39974         const tokens = this.lexer.blockTokens(text);
39975         this.lexer.state.top = top;
39976         return {
39977           type: "blockquote",
39978           raw: cap[0],
39979           tokens,
39980           text
39981         };
39982       }
39983     }
39984     list(src) {
39985       let cap = this.rules.block.list.exec(src);
39986       if (cap) {
39987         let bull = cap[1].trim();
39988         const isordered = bull.length > 1;
39989         const list2 = {
39990           type: "list",
39991           raw: "",
39992           ordered: isordered,
39993           start: isordered ? +bull.slice(0, -1) : "",
39994           loose: false,
39995           items: []
39996         };
39997         bull = isordered ? "\\d{1,9}\\".concat(bull.slice(-1)) : "\\".concat(bull);
39998         if (this.options.pedantic) {
39999           bull = isordered ? bull : "[*+-]";
40000         }
40001         const itemRegex = new RegExp("^( {0,3}".concat(bull, ")((?:[     ][^\\n]*)?(?:\\n|$))"));
40002         let raw = "";
40003         let itemContents = "";
40004         let endsWithBlankLine = false;
40005         while (src) {
40006           let endEarly = false;
40007           if (!(cap = itemRegex.exec(src))) {
40008             break;
40009           }
40010           if (this.rules.block.hr.test(src)) {
40011             break;
40012           }
40013           raw = cap[0];
40014           src = src.substring(raw.length);
40015           let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
40016           let nextLine = src.split("\n", 1)[0];
40017           let indent = 0;
40018           if (this.options.pedantic) {
40019             indent = 2;
40020             itemContents = line.trimStart();
40021           } else {
40022             indent = cap[2].search(/[^ ]/);
40023             indent = indent > 4 ? 1 : indent;
40024             itemContents = line.slice(indent);
40025             indent += cap[1].length;
40026           }
40027           let blankLine = false;
40028           if (!line && /^ *$/.test(nextLine)) {
40029             raw += nextLine + "\n";
40030             src = src.substring(nextLine.length + 1);
40031             endEarly = true;
40032           }
40033           if (!endEarly) {
40034             const nextBulletRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[    ][^\\n]*)?(?:\\n|$))"));
40035             const hrRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)"));
40036             const fencesBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)"));
40037             const headingBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#"));
40038             while (src) {
40039               const rawLine = src.split("\n", 1)[0];
40040               nextLine = rawLine;
40041               if (this.options.pedantic) {
40042                 nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ");
40043               }
40044               if (fencesBeginRegex.test(nextLine)) {
40045                 break;
40046               }
40047               if (headingBeginRegex.test(nextLine)) {
40048                 break;
40049               }
40050               if (nextBulletRegex.test(nextLine)) {
40051                 break;
40052               }
40053               if (hrRegex.test(src)) {
40054                 break;
40055               }
40056               if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
40057                 itemContents += "\n" + nextLine.slice(indent);
40058               } else {
40059                 if (blankLine) {
40060                   break;
40061                 }
40062                 if (line.search(/[^ ]/) >= 4) {
40063                   break;
40064                 }
40065                 if (fencesBeginRegex.test(line)) {
40066                   break;
40067                 }
40068                 if (headingBeginRegex.test(line)) {
40069                   break;
40070                 }
40071                 if (hrRegex.test(line)) {
40072                   break;
40073                 }
40074                 itemContents += "\n" + nextLine;
40075               }
40076               if (!blankLine && !nextLine.trim()) {
40077                 blankLine = true;
40078               }
40079               raw += rawLine + "\n";
40080               src = src.substring(rawLine.length + 1);
40081               line = nextLine.slice(indent);
40082             }
40083           }
40084           if (!list2.loose) {
40085             if (endsWithBlankLine) {
40086               list2.loose = true;
40087             } else if (/\n *\n *$/.test(raw)) {
40088               endsWithBlankLine = true;
40089             }
40090           }
40091           let istask = null;
40092           let ischecked;
40093           if (this.options.gfm) {
40094             istask = /^\[[ xX]\] /.exec(itemContents);
40095             if (istask) {
40096               ischecked = istask[0] !== "[ ] ";
40097               itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
40098             }
40099           }
40100           list2.items.push({
40101             type: "list_item",
40102             raw,
40103             task: !!istask,
40104             checked: ischecked,
40105             loose: false,
40106             text: itemContents,
40107             tokens: []
40108           });
40109           list2.raw += raw;
40110         }
40111         list2.items[list2.items.length - 1].raw = raw.trimEnd();
40112         list2.items[list2.items.length - 1].text = itemContents.trimEnd();
40113         list2.raw = list2.raw.trimEnd();
40114         for (let i3 = 0; i3 < list2.items.length; i3++) {
40115           this.lexer.state.top = false;
40116           list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
40117           if (!list2.loose) {
40118             const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space");
40119             const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => /\n.*\n/.test(t2.raw));
40120             list2.loose = hasMultipleLineBreaks;
40121           }
40122         }
40123         if (list2.loose) {
40124           for (let i3 = 0; i3 < list2.items.length; i3++) {
40125             list2.items[i3].loose = true;
40126           }
40127         }
40128         return list2;
40129       }
40130     }
40131     html(src) {
40132       const cap = this.rules.block.html.exec(src);
40133       if (cap) {
40134         const token = {
40135           type: "html",
40136           block: true,
40137           raw: cap[0],
40138           pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
40139           text: cap[0]
40140         };
40141         return token;
40142       }
40143     }
40144     def(src) {
40145       const cap = this.rules.block.def.exec(src);
40146       if (cap) {
40147         const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
40148         const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
40149         const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
40150         return {
40151           type: "def",
40152           tag: tag2,
40153           raw: cap[0],
40154           href,
40155           title
40156         };
40157       }
40158     }
40159     table(src) {
40160       const cap = this.rules.block.table.exec(src);
40161       if (!cap) {
40162         return;
40163       }
40164       if (!/[:|]/.test(cap[2])) {
40165         return;
40166       }
40167       const headers = splitCells(cap[1]);
40168       const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
40169       const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
40170       const item = {
40171         type: "table",
40172         raw: cap[0],
40173         header: [],
40174         align: [],
40175         rows: []
40176       };
40177       if (headers.length !== aligns.length) {
40178         return;
40179       }
40180       for (const align of aligns) {
40181         if (/^ *-+: *$/.test(align)) {
40182           item.align.push("right");
40183         } else if (/^ *:-+: *$/.test(align)) {
40184           item.align.push("center");
40185         } else if (/^ *:-+ *$/.test(align)) {
40186           item.align.push("left");
40187         } else {
40188           item.align.push(null);
40189         }
40190       }
40191       for (const header of headers) {
40192         item.header.push({
40193           text: header,
40194           tokens: this.lexer.inline(header)
40195         });
40196       }
40197       for (const row of rows) {
40198         item.rows.push(splitCells(row, item.header.length).map((cell) => {
40199           return {
40200             text: cell,
40201             tokens: this.lexer.inline(cell)
40202           };
40203         }));
40204       }
40205       return item;
40206     }
40207     lheading(src) {
40208       const cap = this.rules.block.lheading.exec(src);
40209       if (cap) {
40210         return {
40211           type: "heading",
40212           raw: cap[0],
40213           depth: cap[2].charAt(0) === "=" ? 1 : 2,
40214           text: cap[1],
40215           tokens: this.lexer.inline(cap[1])
40216         };
40217       }
40218     }
40219     paragraph(src) {
40220       const cap = this.rules.block.paragraph.exec(src);
40221       if (cap) {
40222         const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
40223         return {
40224           type: "paragraph",
40225           raw: cap[0],
40226           text,
40227           tokens: this.lexer.inline(text)
40228         };
40229       }
40230     }
40231     text(src) {
40232       const cap = this.rules.block.text.exec(src);
40233       if (cap) {
40234         return {
40235           type: "text",
40236           raw: cap[0],
40237           text: cap[0],
40238           tokens: this.lexer.inline(cap[0])
40239         };
40240       }
40241     }
40242     escape(src) {
40243       const cap = this.rules.inline.escape.exec(src);
40244       if (cap) {
40245         return {
40246           type: "escape",
40247           raw: cap[0],
40248           text: escape$1(cap[1])
40249         };
40250       }
40251     }
40252     tag(src) {
40253       const cap = this.rules.inline.tag.exec(src);
40254       if (cap) {
40255         if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
40256           this.lexer.state.inLink = true;
40257         } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
40258           this.lexer.state.inLink = false;
40259         }
40260         if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40261           this.lexer.state.inRawBlock = true;
40262         } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40263           this.lexer.state.inRawBlock = false;
40264         }
40265         return {
40266           type: "html",
40267           raw: cap[0],
40268           inLink: this.lexer.state.inLink,
40269           inRawBlock: this.lexer.state.inRawBlock,
40270           block: false,
40271           text: cap[0]
40272         };
40273       }
40274     }
40275     link(src) {
40276       const cap = this.rules.inline.link.exec(src);
40277       if (cap) {
40278         const trimmedUrl = cap[2].trim();
40279         if (!this.options.pedantic && /^</.test(trimmedUrl)) {
40280           if (!/>$/.test(trimmedUrl)) {
40281             return;
40282           }
40283           const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
40284           if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
40285             return;
40286           }
40287         } else {
40288           const lastParenIndex = findClosingBracket(cap[2], "()");
40289           if (lastParenIndex > -1) {
40290             const start2 = cap[0].indexOf("!") === 0 ? 5 : 4;
40291             const linkLen = start2 + cap[1].length + lastParenIndex;
40292             cap[2] = cap[2].substring(0, lastParenIndex);
40293             cap[0] = cap[0].substring(0, linkLen).trim();
40294             cap[3] = "";
40295           }
40296         }
40297         let href = cap[2];
40298         let title = "";
40299         if (this.options.pedantic) {
40300           const link3 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
40301           if (link3) {
40302             href = link3[1];
40303             title = link3[3];
40304           }
40305         } else {
40306           title = cap[3] ? cap[3].slice(1, -1) : "";
40307         }
40308         href = href.trim();
40309         if (/^</.test(href)) {
40310           if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
40311             href = href.slice(1);
40312           } else {
40313             href = href.slice(1, -1);
40314           }
40315         }
40316         return outputLink(cap, {
40317           href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
40318           title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
40319         }, cap[0], this.lexer);
40320       }
40321     }
40322     reflink(src, links) {
40323       let cap;
40324       if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
40325         const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
40326         const link3 = links[linkString.toLowerCase()];
40327         if (!link3) {
40328           const text = cap[0].charAt(0);
40329           return {
40330             type: "text",
40331             raw: text,
40332             text
40333           };
40334         }
40335         return outputLink(cap, link3, cap[0], this.lexer);
40336       }
40337     }
40338     emStrong(src, maskedSrc, prevChar = "") {
40339       let match = this.rules.inline.emStrongLDelim.exec(src);
40340       if (!match)
40341         return;
40342       if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
40343         return;
40344       const nextChar = match[1] || match[2] || "";
40345       if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
40346         const lLength = [...match[0]].length - 1;
40347         let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
40348         const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
40349         endReg.lastIndex = 0;
40350         maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
40351         while ((match = endReg.exec(maskedSrc)) != null) {
40352           rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
40353           if (!rDelim)
40354             continue;
40355           rLength = [...rDelim].length;
40356           if (match[3] || match[4]) {
40357             delimTotal += rLength;
40358             continue;
40359           } else if (match[5] || match[6]) {
40360             if (lLength % 3 && !((lLength + rLength) % 3)) {
40361               midDelimTotal += rLength;
40362               continue;
40363             }
40364           }
40365           delimTotal -= rLength;
40366           if (delimTotal > 0)
40367             continue;
40368           rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
40369           const lastCharLength = [...match[0]][0].length;
40370           const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
40371           if (Math.min(lLength, rLength) % 2) {
40372             const text2 = raw.slice(1, -1);
40373             return {
40374               type: "em",
40375               raw,
40376               text: text2,
40377               tokens: this.lexer.inlineTokens(text2)
40378             };
40379           }
40380           const text = raw.slice(2, -2);
40381           return {
40382             type: "strong",
40383             raw,
40384             text,
40385             tokens: this.lexer.inlineTokens(text)
40386           };
40387         }
40388       }
40389     }
40390     codespan(src) {
40391       const cap = this.rules.inline.code.exec(src);
40392       if (cap) {
40393         let text = cap[2].replace(/\n/g, " ");
40394         const hasNonSpaceChars = /[^ ]/.test(text);
40395         const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
40396         if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
40397           text = text.substring(1, text.length - 1);
40398         }
40399         text = escape$1(text, true);
40400         return {
40401           type: "codespan",
40402           raw: cap[0],
40403           text
40404         };
40405       }
40406     }
40407     br(src) {
40408       const cap = this.rules.inline.br.exec(src);
40409       if (cap) {
40410         return {
40411           type: "br",
40412           raw: cap[0]
40413         };
40414       }
40415     }
40416     del(src) {
40417       const cap = this.rules.inline.del.exec(src);
40418       if (cap) {
40419         return {
40420           type: "del",
40421           raw: cap[0],
40422           text: cap[2],
40423           tokens: this.lexer.inlineTokens(cap[2])
40424         };
40425       }
40426     }
40427     autolink(src) {
40428       const cap = this.rules.inline.autolink.exec(src);
40429       if (cap) {
40430         let text, href;
40431         if (cap[2] === "@") {
40432           text = escape$1(cap[1]);
40433           href = "mailto:" + text;
40434         } else {
40435           text = escape$1(cap[1]);
40436           href = text;
40437         }
40438         return {
40439           type: "link",
40440           raw: cap[0],
40441           text,
40442           href,
40443           tokens: [
40444             {
40445               type: "text",
40446               raw: text,
40447               text
40448             }
40449           ]
40450         };
40451       }
40452     }
40453     url(src) {
40454       var _a2, _b;
40455       let cap;
40456       if (cap = this.rules.inline.url.exec(src)) {
40457         let text, href;
40458         if (cap[2] === "@") {
40459           text = escape$1(cap[0]);
40460           href = "mailto:" + text;
40461         } else {
40462           let prevCapZero;
40463           do {
40464             prevCapZero = cap[0];
40465             cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
40466           } while (prevCapZero !== cap[0]);
40467           text = escape$1(cap[0]);
40468           if (cap[1] === "www.") {
40469             href = "http://" + cap[0];
40470           } else {
40471             href = cap[0];
40472           }
40473         }
40474         return {
40475           type: "link",
40476           raw: cap[0],
40477           text,
40478           href,
40479           tokens: [
40480             {
40481               type: "text",
40482               raw: text,
40483               text
40484             }
40485           ]
40486         };
40487       }
40488     }
40489     inlineText(src) {
40490       const cap = this.rules.inline.text.exec(src);
40491       if (cap) {
40492         let text;
40493         if (this.lexer.state.inRawBlock) {
40494           text = cap[0];
40495         } else {
40496           text = escape$1(cap[0]);
40497         }
40498         return {
40499           type: "text",
40500           raw: cap[0],
40501           text
40502         };
40503       }
40504     }
40505   };
40506   var newline = /^(?: *(?:\n|$))+/;
40507   var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
40508   var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
40509   var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
40510   var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
40511   var bullet = /(?:[*+-]|\d{1,9}[.)])/;
40512   var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
40513   var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
40514   var blockText = /^[^\n]+/;
40515   var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
40516   var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
40517   var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
40518   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";
40519   var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
40520   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();
40521   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();
40522   var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
40523   var blockNormal = {
40524     blockquote,
40525     code: blockCode,
40526     def,
40527     fences,
40528     heading,
40529     hr,
40530     html: html2,
40531     lheading,
40532     list,
40533     newline,
40534     paragraph,
40535     table: noopTest,
40536     text: blockText
40537   };
40538   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();
40539   var blockGfm = {
40540     ...blockNormal,
40541     table: gfmTable,
40542     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()
40543   };
40544   var blockPedantic = {
40545     ...blockNormal,
40546     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(),
40547     def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
40548     heading: /^(#{1,6})(.*)(?:\n+|$)/,
40549     fences: noopTest,
40550     // fences not supported
40551     lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
40552     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()
40553   };
40554   var escape4 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
40555   var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
40556   var br = /^( {2,}|\\)\n(?!\s*$)/;
40557   var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
40558   var _punctuation = "\\p{P}\\p{S}";
40559   var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
40560   var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
40561   var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
40562   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();
40563   var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
40564   var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
40565   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();
40566   var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
40567   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();
40568   var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
40569   var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
40570   var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
40571   var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
40572   var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
40573   var inlineNormal = {
40574     _backpedal: noopTest,
40575     // only used for GFM url
40576     anyPunctuation,
40577     autolink,
40578     blockSkip,
40579     br,
40580     code: inlineCode,
40581     del: noopTest,
40582     emStrongLDelim,
40583     emStrongRDelimAst,
40584     emStrongRDelimUnd,
40585     escape: escape4,
40586     link: link2,
40587     nolink,
40588     punctuation,
40589     reflink,
40590     reflinkSearch,
40591     tag,
40592     text: inlineText,
40593     url: noopTest
40594   };
40595   var inlinePedantic = {
40596     ...inlineNormal,
40597     link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
40598     reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
40599   };
40600   var inlineGfm = {
40601     ...inlineNormal,
40602     escape: edit(escape4).replace("])", "~|])").getRegex(),
40603     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(),
40604     _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
40605     del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
40606     text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
40607   };
40608   var inlineBreaks = {
40609     ...inlineGfm,
40610     br: edit(br).replace("{2,}", "*").getRegex(),
40611     text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
40612   };
40613   var block = {
40614     normal: blockNormal,
40615     gfm: blockGfm,
40616     pedantic: blockPedantic
40617   };
40618   var inline = {
40619     normal: inlineNormal,
40620     gfm: inlineGfm,
40621     breaks: inlineBreaks,
40622     pedantic: inlinePedantic
40623   };
40624   var _Lexer = class __Lexer {
40625     constructor(options2) {
40626       __publicField(this, "tokens");
40627       __publicField(this, "options");
40628       __publicField(this, "state");
40629       __publicField(this, "tokenizer");
40630       __publicField(this, "inlineQueue");
40631       this.tokens = [];
40632       this.tokens.links = /* @__PURE__ */ Object.create(null);
40633       this.options = options2 || _defaults;
40634       this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
40635       this.tokenizer = this.options.tokenizer;
40636       this.tokenizer.options = this.options;
40637       this.tokenizer.lexer = this;
40638       this.inlineQueue = [];
40639       this.state = {
40640         inLink: false,
40641         inRawBlock: false,
40642         top: true
40643       };
40644       const rules = {
40645         block: block.normal,
40646         inline: inline.normal
40647       };
40648       if (this.options.pedantic) {
40649         rules.block = block.pedantic;
40650         rules.inline = inline.pedantic;
40651       } else if (this.options.gfm) {
40652         rules.block = block.gfm;
40653         if (this.options.breaks) {
40654           rules.inline = inline.breaks;
40655         } else {
40656           rules.inline = inline.gfm;
40657         }
40658       }
40659       this.tokenizer.rules = rules;
40660     }
40661     /**
40662      * Expose Rules
40663      */
40664     static get rules() {
40665       return {
40666         block,
40667         inline
40668       };
40669     }
40670     /**
40671      * Static Lex Method
40672      */
40673     static lex(src, options2) {
40674       const lexer2 = new __Lexer(options2);
40675       return lexer2.lex(src);
40676     }
40677     /**
40678      * Static Lex Inline Method
40679      */
40680     static lexInline(src, options2) {
40681       const lexer2 = new __Lexer(options2);
40682       return lexer2.inlineTokens(src);
40683     }
40684     /**
40685      * Preprocessing
40686      */
40687     lex(src) {
40688       src = src.replace(/\r\n|\r/g, "\n");
40689       this.blockTokens(src, this.tokens);
40690       for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
40691         const next = this.inlineQueue[i3];
40692         this.inlineTokens(next.src, next.tokens);
40693       }
40694       this.inlineQueue = [];
40695       return this.tokens;
40696     }
40697     blockTokens(src, tokens = []) {
40698       if (this.options.pedantic) {
40699         src = src.replace(/\t/g, "    ").replace(/^ +$/gm, "");
40700       } else {
40701         src = src.replace(/^( *)(\t+)/gm, (_2, leading, tabs) => {
40702           return leading + "    ".repeat(tabs.length);
40703         });
40704       }
40705       let token;
40706       let lastToken;
40707       let cutSrc;
40708       let lastParagraphClipped;
40709       while (src) {
40710         if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
40711           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40712             src = src.substring(token.raw.length);
40713             tokens.push(token);
40714             return true;
40715           }
40716           return false;
40717         })) {
40718           continue;
40719         }
40720         if (token = this.tokenizer.space(src)) {
40721           src = src.substring(token.raw.length);
40722           if (token.raw.length === 1 && tokens.length > 0) {
40723             tokens[tokens.length - 1].raw += "\n";
40724           } else {
40725             tokens.push(token);
40726           }
40727           continue;
40728         }
40729         if (token = this.tokenizer.code(src)) {
40730           src = src.substring(token.raw.length);
40731           lastToken = tokens[tokens.length - 1];
40732           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40733             lastToken.raw += "\n" + token.raw;
40734             lastToken.text += "\n" + token.text;
40735             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40736           } else {
40737             tokens.push(token);
40738           }
40739           continue;
40740         }
40741         if (token = this.tokenizer.fences(src)) {
40742           src = src.substring(token.raw.length);
40743           tokens.push(token);
40744           continue;
40745         }
40746         if (token = this.tokenizer.heading(src)) {
40747           src = src.substring(token.raw.length);
40748           tokens.push(token);
40749           continue;
40750         }
40751         if (token = this.tokenizer.hr(src)) {
40752           src = src.substring(token.raw.length);
40753           tokens.push(token);
40754           continue;
40755         }
40756         if (token = this.tokenizer.blockquote(src)) {
40757           src = src.substring(token.raw.length);
40758           tokens.push(token);
40759           continue;
40760         }
40761         if (token = this.tokenizer.list(src)) {
40762           src = src.substring(token.raw.length);
40763           tokens.push(token);
40764           continue;
40765         }
40766         if (token = this.tokenizer.html(src)) {
40767           src = src.substring(token.raw.length);
40768           tokens.push(token);
40769           continue;
40770         }
40771         if (token = this.tokenizer.def(src)) {
40772           src = src.substring(token.raw.length);
40773           lastToken = tokens[tokens.length - 1];
40774           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40775             lastToken.raw += "\n" + token.raw;
40776             lastToken.text += "\n" + token.raw;
40777             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40778           } else if (!this.tokens.links[token.tag]) {
40779             this.tokens.links[token.tag] = {
40780               href: token.href,
40781               title: token.title
40782             };
40783           }
40784           continue;
40785         }
40786         if (token = this.tokenizer.table(src)) {
40787           src = src.substring(token.raw.length);
40788           tokens.push(token);
40789           continue;
40790         }
40791         if (token = this.tokenizer.lheading(src)) {
40792           src = src.substring(token.raw.length);
40793           tokens.push(token);
40794           continue;
40795         }
40796         cutSrc = src;
40797         if (this.options.extensions && this.options.extensions.startBlock) {
40798           let startIndex = Infinity;
40799           const tempSrc = src.slice(1);
40800           let tempStart;
40801           this.options.extensions.startBlock.forEach((getStartIndex) => {
40802             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40803             if (typeof tempStart === "number" && tempStart >= 0) {
40804               startIndex = Math.min(startIndex, tempStart);
40805             }
40806           });
40807           if (startIndex < Infinity && startIndex >= 0) {
40808             cutSrc = src.substring(0, startIndex + 1);
40809           }
40810         }
40811         if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
40812           lastToken = tokens[tokens.length - 1];
40813           if (lastParagraphClipped && lastToken.type === "paragraph") {
40814             lastToken.raw += "\n" + token.raw;
40815             lastToken.text += "\n" + token.text;
40816             this.inlineQueue.pop();
40817             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40818           } else {
40819             tokens.push(token);
40820           }
40821           lastParagraphClipped = cutSrc.length !== src.length;
40822           src = src.substring(token.raw.length);
40823           continue;
40824         }
40825         if (token = this.tokenizer.text(src)) {
40826           src = src.substring(token.raw.length);
40827           lastToken = tokens[tokens.length - 1];
40828           if (lastToken && lastToken.type === "text") {
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           continue;
40837         }
40838         if (src) {
40839           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
40840           if (this.options.silent) {
40841             console.error(errMsg);
40842             break;
40843           } else {
40844             throw new Error(errMsg);
40845           }
40846         }
40847       }
40848       this.state.top = true;
40849       return tokens;
40850     }
40851     inline(src, tokens = []) {
40852       this.inlineQueue.push({ src, tokens });
40853       return tokens;
40854     }
40855     /**
40856      * Lexing/Compiling
40857      */
40858     inlineTokens(src, tokens = []) {
40859       let token, lastToken, cutSrc;
40860       let maskedSrc = src;
40861       let match;
40862       let keepPrevChar, prevChar;
40863       if (this.tokens.links) {
40864         const links = Object.keys(this.tokens.links);
40865         if (links.length > 0) {
40866           while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
40867             if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
40868               maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
40869             }
40870           }
40871         }
40872       }
40873       while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
40874         maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
40875       }
40876       while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
40877         maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
40878       }
40879       while (src) {
40880         if (!keepPrevChar) {
40881           prevChar = "";
40882         }
40883         keepPrevChar = false;
40884         if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
40885           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40886             src = src.substring(token.raw.length);
40887             tokens.push(token);
40888             return true;
40889           }
40890           return false;
40891         })) {
40892           continue;
40893         }
40894         if (token = this.tokenizer.escape(src)) {
40895           src = src.substring(token.raw.length);
40896           tokens.push(token);
40897           continue;
40898         }
40899         if (token = this.tokenizer.tag(src)) {
40900           src = src.substring(token.raw.length);
40901           lastToken = tokens[tokens.length - 1];
40902           if (lastToken && token.type === "text" && lastToken.type === "text") {
40903             lastToken.raw += token.raw;
40904             lastToken.text += token.text;
40905           } else {
40906             tokens.push(token);
40907           }
40908           continue;
40909         }
40910         if (token = this.tokenizer.link(src)) {
40911           src = src.substring(token.raw.length);
40912           tokens.push(token);
40913           continue;
40914         }
40915         if (token = this.tokenizer.reflink(src, this.tokens.links)) {
40916           src = src.substring(token.raw.length);
40917           lastToken = tokens[tokens.length - 1];
40918           if (lastToken && token.type === "text" && lastToken.type === "text") {
40919             lastToken.raw += token.raw;
40920             lastToken.text += token.text;
40921           } else {
40922             tokens.push(token);
40923           }
40924           continue;
40925         }
40926         if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
40927           src = src.substring(token.raw.length);
40928           tokens.push(token);
40929           continue;
40930         }
40931         if (token = this.tokenizer.codespan(src)) {
40932           src = src.substring(token.raw.length);
40933           tokens.push(token);
40934           continue;
40935         }
40936         if (token = this.tokenizer.br(src)) {
40937           src = src.substring(token.raw.length);
40938           tokens.push(token);
40939           continue;
40940         }
40941         if (token = this.tokenizer.del(src)) {
40942           src = src.substring(token.raw.length);
40943           tokens.push(token);
40944           continue;
40945         }
40946         if (token = this.tokenizer.autolink(src)) {
40947           src = src.substring(token.raw.length);
40948           tokens.push(token);
40949           continue;
40950         }
40951         if (!this.state.inLink && (token = this.tokenizer.url(src))) {
40952           src = src.substring(token.raw.length);
40953           tokens.push(token);
40954           continue;
40955         }
40956         cutSrc = src;
40957         if (this.options.extensions && this.options.extensions.startInline) {
40958           let startIndex = Infinity;
40959           const tempSrc = src.slice(1);
40960           let tempStart;
40961           this.options.extensions.startInline.forEach((getStartIndex) => {
40962             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40963             if (typeof tempStart === "number" && tempStart >= 0) {
40964               startIndex = Math.min(startIndex, tempStart);
40965             }
40966           });
40967           if (startIndex < Infinity && startIndex >= 0) {
40968             cutSrc = src.substring(0, startIndex + 1);
40969           }
40970         }
40971         if (token = this.tokenizer.inlineText(cutSrc)) {
40972           src = src.substring(token.raw.length);
40973           if (token.raw.slice(-1) !== "_") {
40974             prevChar = token.raw.slice(-1);
40975           }
40976           keepPrevChar = true;
40977           lastToken = tokens[tokens.length - 1];
40978           if (lastToken && lastToken.type === "text") {
40979             lastToken.raw += token.raw;
40980             lastToken.text += token.text;
40981           } else {
40982             tokens.push(token);
40983           }
40984           continue;
40985         }
40986         if (src) {
40987           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
40988           if (this.options.silent) {
40989             console.error(errMsg);
40990             break;
40991           } else {
40992             throw new Error(errMsg);
40993           }
40994         }
40995       }
40996       return tokens;
40997     }
40998   };
40999   var _Renderer = class {
41000     constructor(options2) {
41001       __publicField(this, "options");
41002       this.options = options2 || _defaults;
41003     }
41004     code(code, infostring, escaped) {
41005       var _a2;
41006       const lang = (_a2 = (infostring || "").match(/^\S*/)) == null ? void 0 : _a2[0];
41007       code = code.replace(/\n$/, "") + "\n";
41008       if (!lang) {
41009         return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41010       }
41011       return '<pre><code class="language-' + escape$1(lang) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41012     }
41013     blockquote(quote) {
41014       return "<blockquote>\n".concat(quote, "</blockquote>\n");
41015     }
41016     html(html3, block2) {
41017       return html3;
41018     }
41019     heading(text, level, raw) {
41020       return "<h".concat(level, ">").concat(text, "</h").concat(level, ">\n");
41021     }
41022     hr() {
41023       return "<hr>\n";
41024     }
41025     list(body, ordered, start2) {
41026       const type2 = ordered ? "ol" : "ul";
41027       const startatt = ordered && start2 !== 1 ? ' start="' + start2 + '"' : "";
41028       return "<" + type2 + startatt + ">\n" + body + "</" + type2 + ">\n";
41029     }
41030     listitem(text, task, checked) {
41031       return "<li>".concat(text, "</li>\n");
41032     }
41033     checkbox(checked) {
41034       return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
41035     }
41036     paragraph(text) {
41037       return "<p>".concat(text, "</p>\n");
41038     }
41039     table(header, body) {
41040       if (body)
41041         body = "<tbody>".concat(body, "</tbody>");
41042       return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
41043     }
41044     tablerow(content) {
41045       return "<tr>\n".concat(content, "</tr>\n");
41046     }
41047     tablecell(content, flags) {
41048       const type2 = flags.header ? "th" : "td";
41049       const tag2 = flags.align ? "<".concat(type2, ' align="').concat(flags.align, '">') : "<".concat(type2, ">");
41050       return tag2 + content + "</".concat(type2, ">\n");
41051     }
41052     /**
41053      * span level renderer
41054      */
41055     strong(text) {
41056       return "<strong>".concat(text, "</strong>");
41057     }
41058     em(text) {
41059       return "<em>".concat(text, "</em>");
41060     }
41061     codespan(text) {
41062       return "<code>".concat(text, "</code>");
41063     }
41064     br() {
41065       return "<br>";
41066     }
41067     del(text) {
41068       return "<del>".concat(text, "</del>");
41069     }
41070     link(href, title, text) {
41071       const cleanHref = cleanUrl(href);
41072       if (cleanHref === null) {
41073         return text;
41074       }
41075       href = cleanHref;
41076       let out = '<a href="' + href + '"';
41077       if (title) {
41078         out += ' title="' + title + '"';
41079       }
41080       out += ">" + text + "</a>";
41081       return out;
41082     }
41083     image(href, title, text) {
41084       const cleanHref = cleanUrl(href);
41085       if (cleanHref === null) {
41086         return text;
41087       }
41088       href = cleanHref;
41089       let out = '<img src="'.concat(href, '" alt="').concat(text, '"');
41090       if (title) {
41091         out += ' title="'.concat(title, '"');
41092       }
41093       out += ">";
41094       return out;
41095     }
41096     text(text) {
41097       return text;
41098     }
41099   };
41100   var _TextRenderer = class {
41101     // no need for block level renderers
41102     strong(text) {
41103       return text;
41104     }
41105     em(text) {
41106       return text;
41107     }
41108     codespan(text) {
41109       return text;
41110     }
41111     del(text) {
41112       return text;
41113     }
41114     html(text) {
41115       return text;
41116     }
41117     text(text) {
41118       return text;
41119     }
41120     link(href, title, text) {
41121       return "" + text;
41122     }
41123     image(href, title, text) {
41124       return "" + text;
41125     }
41126     br() {
41127       return "";
41128     }
41129   };
41130   var _Parser = class __Parser {
41131     constructor(options2) {
41132       __publicField(this, "options");
41133       __publicField(this, "renderer");
41134       __publicField(this, "textRenderer");
41135       this.options = options2 || _defaults;
41136       this.options.renderer = this.options.renderer || new _Renderer();
41137       this.renderer = this.options.renderer;
41138       this.renderer.options = this.options;
41139       this.textRenderer = new _TextRenderer();
41140     }
41141     /**
41142      * Static Parse Method
41143      */
41144     static parse(tokens, options2) {
41145       const parser3 = new __Parser(options2);
41146       return parser3.parse(tokens);
41147     }
41148     /**
41149      * Static Parse Inline Method
41150      */
41151     static parseInline(tokens, options2) {
41152       const parser3 = new __Parser(options2);
41153       return parser3.parseInline(tokens);
41154     }
41155     /**
41156      * Parse Loop
41157      */
41158     parse(tokens, top = true) {
41159       let out = "";
41160       for (let i3 = 0; i3 < tokens.length; i3++) {
41161         const token = tokens[i3];
41162         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41163           const genericToken = token;
41164           const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
41165           if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
41166             out += ret || "";
41167             continue;
41168           }
41169         }
41170         switch (token.type) {
41171           case "space": {
41172             continue;
41173           }
41174           case "hr": {
41175             out += this.renderer.hr();
41176             continue;
41177           }
41178           case "heading": {
41179             const headingToken = token;
41180             out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape2(this.parseInline(headingToken.tokens, this.textRenderer)));
41181             continue;
41182           }
41183           case "code": {
41184             const codeToken = token;
41185             out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
41186             continue;
41187           }
41188           case "table": {
41189             const tableToken = token;
41190             let header = "";
41191             let cell = "";
41192             for (let j2 = 0; j2 < tableToken.header.length; j2++) {
41193               cell += this.renderer.tablecell(this.parseInline(tableToken.header[j2].tokens), { header: true, align: tableToken.align[j2] });
41194             }
41195             header += this.renderer.tablerow(cell);
41196             let body = "";
41197             for (let j2 = 0; j2 < tableToken.rows.length; j2++) {
41198               const row = tableToken.rows[j2];
41199               cell = "";
41200               for (let k2 = 0; k2 < row.length; k2++) {
41201                 cell += this.renderer.tablecell(this.parseInline(row[k2].tokens), { header: false, align: tableToken.align[k2] });
41202               }
41203               body += this.renderer.tablerow(cell);
41204             }
41205             out += this.renderer.table(header, body);
41206             continue;
41207           }
41208           case "blockquote": {
41209             const blockquoteToken = token;
41210             const body = this.parse(blockquoteToken.tokens);
41211             out += this.renderer.blockquote(body);
41212             continue;
41213           }
41214           case "list": {
41215             const listToken = token;
41216             const ordered = listToken.ordered;
41217             const start2 = listToken.start;
41218             const loose = listToken.loose;
41219             let body = "";
41220             for (let j2 = 0; j2 < listToken.items.length; j2++) {
41221               const item = listToken.items[j2];
41222               const checked = item.checked;
41223               const task = item.task;
41224               let itemBody = "";
41225               if (item.task) {
41226                 const checkbox = this.renderer.checkbox(!!checked);
41227                 if (loose) {
41228                   if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
41229                     item.tokens[0].text = checkbox + " " + item.tokens[0].text;
41230                     if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
41231                       item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
41232                     }
41233                   } else {
41234                     item.tokens.unshift({
41235                       type: "text",
41236                       text: checkbox + " "
41237                     });
41238                   }
41239                 } else {
41240                   itemBody += checkbox + " ";
41241                 }
41242               }
41243               itemBody += this.parse(item.tokens, loose);
41244               body += this.renderer.listitem(itemBody, task, !!checked);
41245             }
41246             out += this.renderer.list(body, ordered, start2);
41247             continue;
41248           }
41249           case "html": {
41250             const htmlToken = token;
41251             out += this.renderer.html(htmlToken.text, htmlToken.block);
41252             continue;
41253           }
41254           case "paragraph": {
41255             const paragraphToken = token;
41256             out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
41257             continue;
41258           }
41259           case "text": {
41260             let textToken = token;
41261             let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
41262             while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
41263               textToken = tokens[++i3];
41264               body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
41265             }
41266             out += top ? this.renderer.paragraph(body) : body;
41267             continue;
41268           }
41269           default: {
41270             const errMsg = 'Token with "' + token.type + '" type was not found.';
41271             if (this.options.silent) {
41272               console.error(errMsg);
41273               return "";
41274             } else {
41275               throw new Error(errMsg);
41276             }
41277           }
41278         }
41279       }
41280       return out;
41281     }
41282     /**
41283      * Parse Inline Tokens
41284      */
41285     parseInline(tokens, renderer) {
41286       renderer = renderer || this.renderer;
41287       let out = "";
41288       for (let i3 = 0; i3 < tokens.length; i3++) {
41289         const token = tokens[i3];
41290         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41291           const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
41292           if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
41293             out += ret || "";
41294             continue;
41295           }
41296         }
41297         switch (token.type) {
41298           case "escape": {
41299             const escapeToken = token;
41300             out += renderer.text(escapeToken.text);
41301             break;
41302           }
41303           case "html": {
41304             const tagToken = token;
41305             out += renderer.html(tagToken.text);
41306             break;
41307           }
41308           case "link": {
41309             const linkToken = token;
41310             out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
41311             break;
41312           }
41313           case "image": {
41314             const imageToken = token;
41315             out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
41316             break;
41317           }
41318           case "strong": {
41319             const strongToken = token;
41320             out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
41321             break;
41322           }
41323           case "em": {
41324             const emToken = token;
41325             out += renderer.em(this.parseInline(emToken.tokens, renderer));
41326             break;
41327           }
41328           case "codespan": {
41329             const codespanToken = token;
41330             out += renderer.codespan(codespanToken.text);
41331             break;
41332           }
41333           case "br": {
41334             out += renderer.br();
41335             break;
41336           }
41337           case "del": {
41338             const delToken = token;
41339             out += renderer.del(this.parseInline(delToken.tokens, renderer));
41340             break;
41341           }
41342           case "text": {
41343             const textToken = token;
41344             out += renderer.text(textToken.text);
41345             break;
41346           }
41347           default: {
41348             const errMsg = 'Token with "' + token.type + '" type was not found.';
41349             if (this.options.silent) {
41350               console.error(errMsg);
41351               return "";
41352             } else {
41353               throw new Error(errMsg);
41354             }
41355           }
41356         }
41357       }
41358       return out;
41359     }
41360   };
41361   var _Hooks = class {
41362     constructor(options2) {
41363       __publicField(this, "options");
41364       this.options = options2 || _defaults;
41365     }
41366     /**
41367      * Process markdown before marked
41368      */
41369     preprocess(markdown) {
41370       return markdown;
41371     }
41372     /**
41373      * Process HTML after marked is finished
41374      */
41375     postprocess(html3) {
41376       return html3;
41377     }
41378     /**
41379      * Process all tokens before walk tokens
41380      */
41381     processAllTokens(tokens) {
41382       return tokens;
41383     }
41384   };
41385   __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
41386     "preprocess",
41387     "postprocess",
41388     "processAllTokens"
41389   ]));
41390   var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
41391   var Marked = class {
41392     constructor(...args) {
41393       __privateAdd(this, _parseMarkdown);
41394       __privateAdd(this, _onError);
41395       __publicField(this, "defaults", _getDefaults());
41396       __publicField(this, "options", this.setOptions);
41397       __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
41398       __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
41399       __publicField(this, "Parser", _Parser);
41400       __publicField(this, "Renderer", _Renderer);
41401       __publicField(this, "TextRenderer", _TextRenderer);
41402       __publicField(this, "Lexer", _Lexer);
41403       __publicField(this, "Tokenizer", _Tokenizer);
41404       __publicField(this, "Hooks", _Hooks);
41405       this.use(...args);
41406     }
41407     /**
41408      * Run callback for every token
41409      */
41410     walkTokens(tokens, callback) {
41411       var _a2, _b;
41412       let values = [];
41413       for (const token of tokens) {
41414         values = values.concat(callback.call(this, token));
41415         switch (token.type) {
41416           case "table": {
41417             const tableToken = token;
41418             for (const cell of tableToken.header) {
41419               values = values.concat(this.walkTokens(cell.tokens, callback));
41420             }
41421             for (const row of tableToken.rows) {
41422               for (const cell of row) {
41423                 values = values.concat(this.walkTokens(cell.tokens, callback));
41424               }
41425             }
41426             break;
41427           }
41428           case "list": {
41429             const listToken = token;
41430             values = values.concat(this.walkTokens(listToken.items, callback));
41431             break;
41432           }
41433           default: {
41434             const genericToken = token;
41435             if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) {
41436               this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
41437                 const tokens2 = genericToken[childTokens].flat(Infinity);
41438                 values = values.concat(this.walkTokens(tokens2, callback));
41439               });
41440             } else if (genericToken.tokens) {
41441               values = values.concat(this.walkTokens(genericToken.tokens, callback));
41442             }
41443           }
41444         }
41445       }
41446       return values;
41447     }
41448     use(...args) {
41449       const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
41450       args.forEach((pack) => {
41451         const opts = { ...pack };
41452         opts.async = this.defaults.async || opts.async || false;
41453         if (pack.extensions) {
41454           pack.extensions.forEach((ext) => {
41455             if (!ext.name) {
41456               throw new Error("extension name required");
41457             }
41458             if ("renderer" in ext) {
41459               const prevRenderer = extensions.renderers[ext.name];
41460               if (prevRenderer) {
41461                 extensions.renderers[ext.name] = function(...args2) {
41462                   let ret = ext.renderer.apply(this, args2);
41463                   if (ret === false) {
41464                     ret = prevRenderer.apply(this, args2);
41465                   }
41466                   return ret;
41467                 };
41468               } else {
41469                 extensions.renderers[ext.name] = ext.renderer;
41470               }
41471             }
41472             if ("tokenizer" in ext) {
41473               if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
41474                 throw new Error("extension level must be 'block' or 'inline'");
41475               }
41476               const extLevel = extensions[ext.level];
41477               if (extLevel) {
41478                 extLevel.unshift(ext.tokenizer);
41479               } else {
41480                 extensions[ext.level] = [ext.tokenizer];
41481               }
41482               if (ext.start) {
41483                 if (ext.level === "block") {
41484                   if (extensions.startBlock) {
41485                     extensions.startBlock.push(ext.start);
41486                   } else {
41487                     extensions.startBlock = [ext.start];
41488                   }
41489                 } else if (ext.level === "inline") {
41490                   if (extensions.startInline) {
41491                     extensions.startInline.push(ext.start);
41492                   } else {
41493                     extensions.startInline = [ext.start];
41494                   }
41495                 }
41496               }
41497             }
41498             if ("childTokens" in ext && ext.childTokens) {
41499               extensions.childTokens[ext.name] = ext.childTokens;
41500             }
41501           });
41502           opts.extensions = extensions;
41503         }
41504         if (pack.renderer) {
41505           const renderer = this.defaults.renderer || new _Renderer(this.defaults);
41506           for (const prop in pack.renderer) {
41507             if (!(prop in renderer)) {
41508               throw new Error("renderer '".concat(prop, "' does not exist"));
41509             }
41510             if (prop === "options") {
41511               continue;
41512             }
41513             const rendererProp = prop;
41514             const rendererFunc = pack.renderer[rendererProp];
41515             const prevRenderer = renderer[rendererProp];
41516             renderer[rendererProp] = (...args2) => {
41517               let ret = rendererFunc.apply(renderer, args2);
41518               if (ret === false) {
41519                 ret = prevRenderer.apply(renderer, args2);
41520               }
41521               return ret || "";
41522             };
41523           }
41524           opts.renderer = renderer;
41525         }
41526         if (pack.tokenizer) {
41527           const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
41528           for (const prop in pack.tokenizer) {
41529             if (!(prop in tokenizer)) {
41530               throw new Error("tokenizer '".concat(prop, "' does not exist"));
41531             }
41532             if (["options", "rules", "lexer"].includes(prop)) {
41533               continue;
41534             }
41535             const tokenizerProp = prop;
41536             const tokenizerFunc = pack.tokenizer[tokenizerProp];
41537             const prevTokenizer = tokenizer[tokenizerProp];
41538             tokenizer[tokenizerProp] = (...args2) => {
41539               let ret = tokenizerFunc.apply(tokenizer, args2);
41540               if (ret === false) {
41541                 ret = prevTokenizer.apply(tokenizer, args2);
41542               }
41543               return ret;
41544             };
41545           }
41546           opts.tokenizer = tokenizer;
41547         }
41548         if (pack.hooks) {
41549           const hooks = this.defaults.hooks || new _Hooks();
41550           for (const prop in pack.hooks) {
41551             if (!(prop in hooks)) {
41552               throw new Error("hook '".concat(prop, "' does not exist"));
41553             }
41554             if (prop === "options") {
41555               continue;
41556             }
41557             const hooksProp = prop;
41558             const hooksFunc = pack.hooks[hooksProp];
41559             const prevHook = hooks[hooksProp];
41560             if (_Hooks.passThroughHooks.has(prop)) {
41561               hooks[hooksProp] = (arg) => {
41562                 if (this.defaults.async) {
41563                   return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
41564                     return prevHook.call(hooks, ret2);
41565                   });
41566                 }
41567                 const ret = hooksFunc.call(hooks, arg);
41568                 return prevHook.call(hooks, ret);
41569               };
41570             } else {
41571               hooks[hooksProp] = (...args2) => {
41572                 let ret = hooksFunc.apply(hooks, args2);
41573                 if (ret === false) {
41574                   ret = prevHook.apply(hooks, args2);
41575                 }
41576                 return ret;
41577               };
41578             }
41579           }
41580           opts.hooks = hooks;
41581         }
41582         if (pack.walkTokens) {
41583           const walkTokens2 = this.defaults.walkTokens;
41584           const packWalktokens = pack.walkTokens;
41585           opts.walkTokens = function(token) {
41586             let values = [];
41587             values.push(packWalktokens.call(this, token));
41588             if (walkTokens2) {
41589               values = values.concat(walkTokens2.call(this, token));
41590             }
41591             return values;
41592           };
41593         }
41594         this.defaults = { ...this.defaults, ...opts };
41595       });
41596       return this;
41597     }
41598     setOptions(opt) {
41599       this.defaults = { ...this.defaults, ...opt };
41600       return this;
41601     }
41602     lexer(src, options2) {
41603       return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
41604     }
41605     parser(tokens, options2) {
41606       return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
41607     }
41608   };
41609   _parseMarkdown = new WeakSet();
41610   parseMarkdown_fn = function(lexer2, parser3) {
41611     return (src, options2) => {
41612       const origOpt = { ...options2 };
41613       const opt = { ...this.defaults, ...origOpt };
41614       if (this.defaults.async === true && origOpt.async === false) {
41615         if (!opt.silent) {
41616           console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
41617         }
41618         opt.async = true;
41619       }
41620       const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async);
41621       if (typeof src === "undefined" || src === null) {
41622         return throwError(new Error("marked(): input parameter is undefined or null"));
41623       }
41624       if (typeof src !== "string") {
41625         return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
41626       }
41627       if (opt.hooks) {
41628         opt.hooks.options = opt;
41629       }
41630       if (opt.async) {
41631         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);
41632       }
41633       try {
41634         if (opt.hooks) {
41635           src = opt.hooks.preprocess(src);
41636         }
41637         let tokens = lexer2(src, opt);
41638         if (opt.hooks) {
41639           tokens = opt.hooks.processAllTokens(tokens);
41640         }
41641         if (opt.walkTokens) {
41642           this.walkTokens(tokens, opt.walkTokens);
41643         }
41644         let html3 = parser3(tokens, opt);
41645         if (opt.hooks) {
41646           html3 = opt.hooks.postprocess(html3);
41647         }
41648         return html3;
41649       } catch (e3) {
41650         return throwError(e3);
41651       }
41652     };
41653   };
41654   _onError = new WeakSet();
41655   onError_fn = function(silent, async) {
41656     return (e3) => {
41657       e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
41658       if (silent) {
41659         const msg = "<p>An error occurred:</p><pre>" + escape$1(e3.message + "", true) + "</pre>";
41660         if (async) {
41661           return Promise.resolve(msg);
41662         }
41663         return msg;
41664       }
41665       if (async) {
41666         return Promise.reject(e3);
41667       }
41668       throw e3;
41669     };
41670   };
41671   var markedInstance = new Marked();
41672   function marked(src, opt) {
41673     return markedInstance.parse(src, opt);
41674   }
41675   marked.options = marked.setOptions = function(options2) {
41676     markedInstance.setOptions(options2);
41677     marked.defaults = markedInstance.defaults;
41678     changeDefaults(marked.defaults);
41679     return marked;
41680   };
41681   marked.getDefaults = _getDefaults;
41682   marked.defaults = _defaults;
41683   marked.use = function(...args) {
41684     markedInstance.use(...args);
41685     marked.defaults = markedInstance.defaults;
41686     changeDefaults(marked.defaults);
41687     return marked;
41688   };
41689   marked.walkTokens = function(tokens, callback) {
41690     return markedInstance.walkTokens(tokens, callback);
41691   };
41692   marked.parseInline = markedInstance.parseInline;
41693   marked.Parser = _Parser;
41694   marked.parser = _Parser.parse;
41695   marked.Renderer = _Renderer;
41696   marked.TextRenderer = _TextRenderer;
41697   marked.Lexer = _Lexer;
41698   marked.lexer = _Lexer.lex;
41699   marked.Tokenizer = _Tokenizer;
41700   marked.Hooks = _Hooks;
41701   marked.parse = marked;
41702   var options = marked.options;
41703   var setOptions = marked.setOptions;
41704   var use = marked.use;
41705   var walkTokens = marked.walkTokens;
41706   var parseInline = marked.parseInline;
41707   var parser2 = _Parser.parse;
41708   var lexer = _Lexer.lex;
41709
41710   // modules/services/osmose.js
41711   var tiler3 = utilTiler();
41712   var dispatch4 = dispatch_default("loaded");
41713   var _tileZoom3 = 14;
41714   var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3";
41715   var _osmoseData = { icons: {}, items: [] };
41716   var _cache3;
41717   function abortRequest3(controller) {
41718     if (controller) {
41719       controller.abort();
41720     }
41721   }
41722   function abortUnwantedRequests3(cache, tiles) {
41723     Object.keys(cache.inflightTile).forEach((k2) => {
41724       let wanted = tiles.find((tile) => k2 === tile.id);
41725       if (!wanted) {
41726         abortRequest3(cache.inflightTile[k2]);
41727         delete cache.inflightTile[k2];
41728       }
41729     });
41730   }
41731   function encodeIssueRtree3(d2) {
41732     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
41733   }
41734   function updateRtree3(item, replace) {
41735     _cache3.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
41736     if (replace) {
41737       _cache3.rtree.insert(item);
41738     }
41739   }
41740   function preventCoincident2(loc) {
41741     let coincident = false;
41742     do {
41743       let delta = coincident ? [1e-5, 0] : [0, 1e-5];
41744       loc = geoVecAdd(loc, delta);
41745       let bbox2 = geoExtent(loc).bbox();
41746       coincident = _cache3.rtree.search(bbox2).length;
41747     } while (coincident);
41748     return loc;
41749   }
41750   var osmose_default = {
41751     title: "osmose",
41752     init() {
41753       _mainFileFetcher.get("qa_data").then((d2) => {
41754         _osmoseData = d2.osmose;
41755         _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []);
41756       });
41757       if (!_cache3) {
41758         this.reset();
41759       }
41760       this.event = utilRebind(this, dispatch4, "on");
41761     },
41762     reset() {
41763       let _strings = {};
41764       let _colors = {};
41765       if (_cache3) {
41766         Object.values(_cache3.inflightTile).forEach(abortRequest3);
41767         _strings = _cache3.strings;
41768         _colors = _cache3.colors;
41769       }
41770       _cache3 = {
41771         data: {},
41772         loadedTile: {},
41773         inflightTile: {},
41774         inflightPost: {},
41775         closed: {},
41776         rtree: new import_rbush3.default(),
41777         strings: _strings,
41778         colors: _colors
41779       };
41780     },
41781     loadIssues(projection2) {
41782       let params = {
41783         // Tiles return a maximum # of issues
41784         // So we want to filter our request for only types iD supports
41785         item: _osmoseData.items
41786       };
41787       let tiles = tiler3.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
41788       abortUnwantedRequests3(_cache3, tiles);
41789       tiles.forEach((tile) => {
41790         if (_cache3.loadedTile[tile.id] || _cache3.inflightTile[tile.id])
41791           return;
41792         let [x2, y2, z2] = tile.xyz;
41793         let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params);
41794         let controller = new AbortController();
41795         _cache3.inflightTile[tile.id] = controller;
41796         json_default(url, { signal: controller.signal }).then((data) => {
41797           delete _cache3.inflightTile[tile.id];
41798           _cache3.loadedTile[tile.id] = true;
41799           if (data.features) {
41800             data.features.forEach((issue) => {
41801               const { item, class: cl, uuid: id2 } = issue.properties;
41802               const itemType = "".concat(item, "-").concat(cl);
41803               if (itemType in _osmoseData.icons) {
41804                 let loc = issue.geometry.coordinates;
41805                 loc = preventCoincident2(loc);
41806                 let d2 = new QAItem(loc, this, itemType, id2, { item });
41807                 if (item === 8300 || item === 8360) {
41808                   d2.elems = [];
41809                 }
41810                 _cache3.data[d2.id] = d2;
41811                 _cache3.rtree.insert(encodeIssueRtree3(d2));
41812               }
41813             });
41814           }
41815           dispatch4.call("loaded");
41816         }).catch(() => {
41817           delete _cache3.inflightTile[tile.id];
41818           _cache3.loadedTile[tile.id] = true;
41819         });
41820       });
41821     },
41822     loadIssueDetail(issue) {
41823       if (issue.elems !== void 0) {
41824         return Promise.resolve(issue);
41825       }
41826       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode());
41827       const cacheDetails = (data) => {
41828         issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id);
41829         issue.detail = data.subtitle ? marked(data.subtitle.auto) : "";
41830         this.replaceItem(issue);
41831       };
41832       return json_default(url).then(cacheDetails).then(() => issue);
41833     },
41834     loadStrings(locale2 = _mainLocalizer.localeCode()) {
41835       const items = Object.keys(_osmoseData.icons);
41836       if (locale2 in _cache3.strings && Object.keys(_cache3.strings[locale2]).length === items.length) {
41837         return Promise.resolve(_cache3.strings[locale2]);
41838       }
41839       if (!(locale2 in _cache3.strings)) {
41840         _cache3.strings[locale2] = {};
41841       }
41842       const allRequests = items.map((itemType) => {
41843         if (itemType in _cache3.strings[locale2])
41844           return null;
41845         const cacheData = (data) => {
41846           const [cat = { items: [] }] = data.categories;
41847           const [item2 = { class: [] }] = cat.items;
41848           const [cl2 = null] = item2.class;
41849           if (!cl2) {
41850             console.log("Osmose strings request (".concat(itemType, ") had unexpected data"));
41851             return;
41852           }
41853           const { item: itemInt, color: color2 } = item2;
41854           if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) {
41855             _cache3.colors[itemInt] = color2;
41856           }
41857           const { title, detail, fix, trap } = cl2;
41858           let issueStrings = {};
41859           if (title)
41860             issueStrings.title = title.auto;
41861           if (detail)
41862             issueStrings.detail = marked(detail.auto);
41863           if (trap)
41864             issueStrings.trap = marked(trap.auto);
41865           if (fix)
41866             issueStrings.fix = marked(fix.auto);
41867           _cache3.strings[locale2][itemType] = issueStrings;
41868         };
41869         const [item, cl] = itemType.split("-");
41870         const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2);
41871         return json_default(url).then(cacheData);
41872       }).filter(Boolean);
41873       return Promise.all(allRequests).then(() => _cache3.strings[locale2]);
41874     },
41875     getStrings(itemType, locale2 = _mainLocalizer.localeCode()) {
41876       return locale2 in _cache3.strings ? _cache3.strings[locale2][itemType] : {};
41877     },
41878     getColor(itemType) {
41879       return itemType in _cache3.colors ? _cache3.colors[itemType] : "#FFFFFF";
41880     },
41881     postUpdate(issue, callback) {
41882       if (_cache3.inflightPost[issue.id]) {
41883         return callback({ message: "Issue update already inflight", status: -2 }, issue);
41884       }
41885       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus);
41886       const controller = new AbortController();
41887       const after = () => {
41888         delete _cache3.inflightPost[issue.id];
41889         this.removeItem(issue);
41890         if (issue.newStatus === "done") {
41891           if (!(issue.item in _cache3.closed)) {
41892             _cache3.closed[issue.item] = 0;
41893           }
41894           _cache3.closed[issue.item] += 1;
41895         }
41896         if (callback)
41897           callback(null, issue);
41898       };
41899       _cache3.inflightPost[issue.id] = controller;
41900       fetch(url, { signal: controller.signal }).then(after).catch((err) => {
41901         delete _cache3.inflightPost[issue.id];
41902         if (callback)
41903           callback(err.message);
41904       });
41905     },
41906     // Get all cached QAItems covering the viewport
41907     getItems(projection2) {
41908       const viewport = projection2.clipExtent();
41909       const min3 = [viewport[0][0], viewport[1][1]];
41910       const max3 = [viewport[1][0], viewport[0][1]];
41911       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
41912       return _cache3.rtree.search(bbox2).map((d2) => d2.data);
41913     },
41914     // Get a QAItem from cache
41915     // NOTE: Don't change method name until UI v3 is merged
41916     getError(id2) {
41917       return _cache3.data[id2];
41918     },
41919     // get the name of the icon to display for this item
41920     getIcon(itemType) {
41921       return _osmoseData.icons[itemType];
41922     },
41923     // Replace a single QAItem in the cache
41924     replaceItem(item) {
41925       if (!(item instanceof QAItem) || !item.id)
41926         return;
41927       _cache3.data[item.id] = item;
41928       updateRtree3(encodeIssueRtree3(item), true);
41929       return item;
41930     },
41931     // Remove a single QAItem from the cache
41932     removeItem(item) {
41933       if (!(item instanceof QAItem) || !item.id)
41934         return;
41935       delete _cache3.data[item.id];
41936       updateRtree3(encodeIssueRtree3(item), false);
41937     },
41938     // Used to populate `closed:osmose:*` changeset tags
41939     getClosedCounts() {
41940       return _cache3.closed;
41941     },
41942     itemURL(item) {
41943       return "https://osmose.openstreetmap.fr/en/error/".concat(item.id);
41944     }
41945   };
41946
41947   // modules/services/mapillary.js
41948   var import_pbf = __toESM(require_pbf());
41949   var import_rbush4 = __toESM(require_rbush_min());
41950   var import_vector_tile = __toESM(require_vector_tile());
41951   var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf";
41952   var apiUrl = "https://graph.mapillary.com/";
41953   var baseTileUrl = "https://tiles.mapillary.com/maps/vtp";
41954   var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41955   var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41956   var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41957   var viewercss = "mapillary-js/mapillary.css";
41958   var viewerjs = "mapillary-js/mapillary.js";
41959   var minZoom = 14;
41960   var dispatch5 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged");
41961   var _loadViewerPromise;
41962   var _mlyActiveImage;
41963   var _mlyCache;
41964   var _mlyFallback = false;
41965   var _mlyHighlightedDetection;
41966   var _mlyShowFeatureDetections = false;
41967   var _mlyShowSignDetections = false;
41968   var _mlyViewer;
41969   var _mlyViewerFilter = ["all"];
41970   function loadTiles(which, url, maxZoom2, projection2) {
41971     const tiler9 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true);
41972     const tiles = tiler9.getTiles(projection2);
41973     tiles.forEach(function(tile) {
41974       loadTile(which, url, tile);
41975     });
41976   }
41977   function loadTile(which, url, tile) {
41978     const cache = _mlyCache.requests;
41979     const tileId = "".concat(tile.id, "-").concat(which);
41980     if (cache.loaded[tileId] || cache.inflight[tileId])
41981       return;
41982     const controller = new AbortController();
41983     cache.inflight[tileId] = controller;
41984     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
41985     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
41986       if (!response.ok) {
41987         throw new Error(response.status + " " + response.statusText);
41988       }
41989       cache.loaded[tileId] = true;
41990       delete cache.inflight[tileId];
41991       return response.arrayBuffer();
41992     }).then(function(data) {
41993       if (!data) {
41994         throw new Error("No Data");
41995       }
41996       loadTileDataToCache(data, tile, which);
41997       if (which === "images") {
41998         dispatch5.call("loadedImages");
41999       } else if (which === "signs") {
42000         dispatch5.call("loadedSigns");
42001       } else if (which === "points") {
42002         dispatch5.call("loadedMapFeatures");
42003       }
42004     }).catch(function() {
42005       cache.loaded[tileId] = true;
42006       delete cache.inflight[tileId];
42007     });
42008   }
42009   function loadTileDataToCache(data, tile, which) {
42010     const vectorTile = new import_vector_tile.VectorTile(new import_pbf.default(data));
42011     let features, cache, layer, i3, feature3, loc, d2;
42012     if (vectorTile.layers.hasOwnProperty("image")) {
42013       features = [];
42014       cache = _mlyCache.images;
42015       layer = vectorTile.layers.image;
42016       for (i3 = 0; i3 < layer.length; i3++) {
42017         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42018         loc = feature3.geometry.coordinates;
42019         d2 = {
42020           loc,
42021           captured_at: feature3.properties.captured_at,
42022           ca: feature3.properties.compass_angle,
42023           id: feature3.properties.id,
42024           is_pano: feature3.properties.is_pano,
42025           sequence_id: feature3.properties.sequence_id
42026         };
42027         cache.forImageId[d2.id] = d2;
42028         features.push({
42029           minX: loc[0],
42030           minY: loc[1],
42031           maxX: loc[0],
42032           maxY: loc[1],
42033           data: d2
42034         });
42035       }
42036       if (cache.rtree) {
42037         cache.rtree.load(features);
42038       }
42039     }
42040     if (vectorTile.layers.hasOwnProperty("sequence")) {
42041       features = [];
42042       cache = _mlyCache.sequences;
42043       layer = vectorTile.layers.sequence;
42044       for (i3 = 0; i3 < layer.length; i3++) {
42045         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42046         if (cache.lineString[feature3.properties.id]) {
42047           cache.lineString[feature3.properties.id].push(feature3);
42048         } else {
42049           cache.lineString[feature3.properties.id] = [feature3];
42050         }
42051       }
42052     }
42053     if (vectorTile.layers.hasOwnProperty("point")) {
42054       features = [];
42055       cache = _mlyCache[which];
42056       layer = vectorTile.layers.point;
42057       for (i3 = 0; i3 < layer.length; i3++) {
42058         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42059         loc = feature3.geometry.coordinates;
42060         d2 = {
42061           loc,
42062           id: feature3.properties.id,
42063           first_seen_at: feature3.properties.first_seen_at,
42064           last_seen_at: feature3.properties.last_seen_at,
42065           value: feature3.properties.value
42066         };
42067         features.push({
42068           minX: loc[0],
42069           minY: loc[1],
42070           maxX: loc[0],
42071           maxY: loc[1],
42072           data: d2
42073         });
42074       }
42075       if (cache.rtree) {
42076         cache.rtree.load(features);
42077       }
42078     }
42079     if (vectorTile.layers.hasOwnProperty("traffic_sign")) {
42080       features = [];
42081       cache = _mlyCache[which];
42082       layer = vectorTile.layers.traffic_sign;
42083       for (i3 = 0; i3 < layer.length; i3++) {
42084         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42085         loc = feature3.geometry.coordinates;
42086         d2 = {
42087           loc,
42088           id: feature3.properties.id,
42089           first_seen_at: feature3.properties.first_seen_at,
42090           last_seen_at: feature3.properties.last_seen_at,
42091           value: feature3.properties.value
42092         };
42093         features.push({
42094           minX: loc[0],
42095           minY: loc[1],
42096           maxX: loc[0],
42097           maxY: loc[1],
42098           data: d2
42099         });
42100       }
42101       if (cache.rtree) {
42102         cache.rtree.load(features);
42103       }
42104     }
42105   }
42106   function loadData(url) {
42107     return fetch(url).then(function(response) {
42108       if (!response.ok) {
42109         throw new Error(response.status + " " + response.statusText);
42110       }
42111       return response.json();
42112     }).then(function(result) {
42113       if (!result) {
42114         return [];
42115       }
42116       return result.data || [];
42117     });
42118   }
42119   function partitionViewport(projection2) {
42120     const z2 = geoScaleToZoom(projection2.scale());
42121     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
42122     const tiler9 = utilTiler().zoomExtent([z22, z22]);
42123     return tiler9.getTiles(projection2).map(function(tile) {
42124       return tile.extent;
42125     });
42126   }
42127   function searchLimited(limit, projection2, rtree) {
42128     limit = limit || 5;
42129     return partitionViewport(projection2).reduce(function(result, extent) {
42130       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
42131         return d2.data;
42132       });
42133       return found.length ? result.concat(found) : result;
42134     }, []);
42135   }
42136   var mapillary_default = {
42137     // Initialize Mapillary
42138     init: function() {
42139       if (!_mlyCache) {
42140         this.reset();
42141       }
42142       this.event = utilRebind(this, dispatch5, "on");
42143     },
42144     // Reset cache and state
42145     reset: function() {
42146       if (_mlyCache) {
42147         Object.values(_mlyCache.requests.inflight).forEach(function(request3) {
42148           request3.abort();
42149         });
42150       }
42151       _mlyCache = {
42152         images: { rtree: new import_rbush4.default(), forImageId: {} },
42153         image_detections: { forImageId: {} },
42154         signs: { rtree: new import_rbush4.default() },
42155         points: { rtree: new import_rbush4.default() },
42156         sequences: { rtree: new import_rbush4.default(), lineString: {} },
42157         requests: { loaded: {}, inflight: {} }
42158       };
42159       _mlyActiveImage = null;
42160     },
42161     // Get visible images
42162     images: function(projection2) {
42163       const limit = 5;
42164       return searchLimited(limit, projection2, _mlyCache.images.rtree);
42165     },
42166     // Get visible traffic signs
42167     signs: function(projection2) {
42168       const limit = 5;
42169       return searchLimited(limit, projection2, _mlyCache.signs.rtree);
42170     },
42171     // Get visible map (point) features
42172     mapFeatures: function(projection2) {
42173       const limit = 5;
42174       return searchLimited(limit, projection2, _mlyCache.points.rtree);
42175     },
42176     // Get cached image by id
42177     cachedImage: function(imageId) {
42178       return _mlyCache.images.forImageId[imageId];
42179     },
42180     // Get visible sequences
42181     sequences: function(projection2) {
42182       const viewport = projection2.clipExtent();
42183       const min3 = [viewport[0][0], viewport[1][1]];
42184       const max3 = [viewport[1][0], viewport[0][1]];
42185       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
42186       const sequenceIds = {};
42187       let lineStrings = [];
42188       _mlyCache.images.rtree.search(bbox2).forEach(function(d2) {
42189         if (d2.data.sequence_id) {
42190           sequenceIds[d2.data.sequence_id] = true;
42191         }
42192       });
42193       Object.keys(sequenceIds).forEach(function(sequenceId) {
42194         if (_mlyCache.sequences.lineString[sequenceId]) {
42195           lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]);
42196         }
42197       });
42198       return lineStrings;
42199     },
42200     // Load images in the visible area
42201     loadImages: function(projection2) {
42202       loadTiles("images", tileUrl, 14, projection2);
42203     },
42204     // Load traffic signs in the visible area
42205     loadSigns: function(projection2) {
42206       loadTiles("signs", trafficSignTileUrl, 14, projection2);
42207     },
42208     // Load map (point) features in the visible area
42209     loadMapFeatures: function(projection2) {
42210       loadTiles("points", mapFeatureTileUrl, 14, projection2);
42211     },
42212     // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading
42213     ensureViewerLoaded: function(context) {
42214       if (_loadViewerPromise)
42215         return _loadViewerPromise;
42216       const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]);
42217       wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true);
42218       const that = this;
42219       _loadViewerPromise = new Promise((resolve, reject) => {
42220         let loadedCount = 0;
42221         function loaded() {
42222           loadedCount += 1;
42223           if (loadedCount === 2)
42224             resolve();
42225         }
42226         const head = select_default2("head");
42227         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() {
42228           reject();
42229         });
42230         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() {
42231           reject();
42232         });
42233       }).catch(function() {
42234         _loadViewerPromise = null;
42235       }).then(function() {
42236         that.initViewer(context);
42237       });
42238       return _loadViewerPromise;
42239     },
42240     // Load traffic sign image sprites
42241     loadSignResources: function(context) {
42242       context.ui().svgDefs.addSprites(
42243         ["mapillary-sprite"],
42244         false
42245         /* don't override colors */
42246       );
42247       return this;
42248     },
42249     // Load map (point) feature image sprites
42250     loadObjectResources: function(context) {
42251       context.ui().svgDefs.addSprites(
42252         ["mapillary-object-sprite"],
42253         false
42254         /* don't override colors */
42255       );
42256       return this;
42257     },
42258     // Remove previous detections in image viewer
42259     resetTags: function() {
42260       if (_mlyViewer && !_mlyFallback) {
42261         _mlyViewer.getComponent("tag").removeAll();
42262       }
42263     },
42264     // Show map feature detections in image viewer
42265     showFeatureDetections: function(value) {
42266       _mlyShowFeatureDetections = value;
42267       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42268         this.resetTags();
42269       }
42270     },
42271     // Show traffic sign detections in image viewer
42272     showSignDetections: function(value) {
42273       _mlyShowSignDetections = value;
42274       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42275         this.resetTags();
42276       }
42277     },
42278     // Apply filter to image viewer
42279     filterViewer: function(context) {
42280       const showsPano = context.photos().showsPanoramic();
42281       const showsFlat = context.photos().showsFlat();
42282       const fromDate = context.photos().fromDate();
42283       const toDate = context.photos().toDate();
42284       const filter2 = ["all"];
42285       if (!showsPano)
42286         filter2.push(["!=", "cameraType", "spherical"]);
42287       if (!showsFlat && showsPano)
42288         filter2.push(["==", "pano", true]);
42289       if (fromDate) {
42290         filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]);
42291       }
42292       if (toDate) {
42293         filter2.push([">=", "capturedAt", new Date(toDate).getTime()]);
42294       }
42295       if (_mlyViewer) {
42296         _mlyViewer.setFilter(filter2);
42297       }
42298       _mlyViewerFilter = filter2;
42299       return filter2;
42300     },
42301     // Make the image viewer visible
42302     showViewer: function(context) {
42303       const wrap2 = context.container().select(".photoviewer").classed("hide", false);
42304       const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size();
42305       if (isHidden && _mlyViewer) {
42306         wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true);
42307         wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false);
42308         _mlyViewer.resize();
42309       }
42310       return this;
42311     },
42312     // Hide the image viewer and resets map markers
42313     hideViewer: function(context) {
42314       _mlyActiveImage = null;
42315       if (!_mlyFallback && _mlyViewer) {
42316         _mlyViewer.getComponent("sequence").stop();
42317       }
42318       const viewer = context.container().select(".photoviewer");
42319       if (!viewer.empty())
42320         viewer.datum(null);
42321       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
42322       this.updateUrlImage(null);
42323       dispatch5.call("imageChanged");
42324       dispatch5.call("loadedMapFeatures");
42325       dispatch5.call("loadedSigns");
42326       return this.setStyles(context, null);
42327     },
42328     // Update the URL with current image id
42329     updateUrlImage: function(imageId) {
42330       if (!window.mocha) {
42331         const hash = utilStringQs(window.location.hash);
42332         if (imageId) {
42333           hash.photo = "mapillary/" + imageId;
42334         } else {
42335           delete hash.photo;
42336         }
42337         window.location.replace("#" + utilQsString(hash, true));
42338       }
42339     },
42340     // Highlight the detection in the viewer that is related to the clicked map feature
42341     highlightDetection: function(detection) {
42342       if (detection) {
42343         _mlyHighlightedDetection = detection.id;
42344       }
42345       return this;
42346     },
42347     // Initialize image viewer (Mapillar JS)
42348     initViewer: function(context) {
42349       const that = this;
42350       if (!window.mapillary)
42351         return;
42352       const opts = {
42353         accessToken,
42354         component: {
42355           cover: false,
42356           keyboard: false,
42357           tag: true
42358         },
42359         container: "ideditor-mly"
42360       };
42361       if (!mapillary.isSupported() && mapillary.isFallbackSupported()) {
42362         _mlyFallback = true;
42363         opts.component = {
42364           cover: false,
42365           direction: false,
42366           imagePlane: false,
42367           keyboard: false,
42368           mouse: false,
42369           sequence: false,
42370           tag: false,
42371           image: true,
42372           // fallback
42373           navigation: true
42374           // fallback
42375         };
42376       }
42377       _mlyViewer = new mapillary.Viewer(opts);
42378       _mlyViewer.on("image", imageChanged);
42379       _mlyViewer.on("bearing", bearingChanged);
42380       if (_mlyViewerFilter) {
42381         _mlyViewer.setFilter(_mlyViewerFilter);
42382       }
42383       context.ui().photoviewer.on("resize.mapillary", function() {
42384         if (_mlyViewer)
42385           _mlyViewer.resize();
42386       });
42387       function imageChanged(node) {
42388         that.resetTags();
42389         const image = node.image;
42390         that.setActiveImage(image);
42391         that.setStyles(context, null);
42392         const loc = [image.originalLngLat.lng, image.originalLngLat.lat];
42393         context.map().centerEase(loc);
42394         that.updateUrlImage(image.id);
42395         if (_mlyShowFeatureDetections || _mlyShowSignDetections) {
42396           that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value"));
42397         }
42398         dispatch5.call("imageChanged");
42399       }
42400       function bearingChanged(e3) {
42401         dispatch5.call("bearingChanged", void 0, e3);
42402       }
42403     },
42404     // Move to an image
42405     selectImage: function(context, imageId) {
42406       if (_mlyViewer && imageId) {
42407         _mlyViewer.moveTo(imageId).catch(function(e3) {
42408           console.error("mly3", e3);
42409         });
42410       }
42411       return this;
42412     },
42413     // Return the currently displayed image
42414     getActiveImage: function() {
42415       return _mlyActiveImage;
42416     },
42417     // Return a list of detection objects for the given id
42418     getDetections: function(id2) {
42419       return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image"));
42420     },
42421     // Set the currently visible image
42422     setActiveImage: function(image) {
42423       if (image) {
42424         _mlyActiveImage = {
42425           ca: image.originalCompassAngle,
42426           id: image.id,
42427           loc: [image.originalLngLat.lng, image.originalLngLat.lat],
42428           is_pano: image.cameraType === "spherical",
42429           sequence_id: image.sequenceId
42430         };
42431       } else {
42432         _mlyActiveImage = null;
42433       }
42434     },
42435     // Update the currently highlighted sequence and selected bubble.
42436     setStyles: function(context, hovered) {
42437       const hoveredImageId = hovered && hovered.id;
42438       const hoveredSequenceId = hovered && hovered.sequence_id;
42439       const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id;
42440       context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) {
42441         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
42442       }).classed("hovered", function(d2) {
42443         return d2.id === hoveredImageId;
42444       });
42445       context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) {
42446         return d2.properties.id === hoveredSequenceId;
42447       }).classed("currentView", function(d2) {
42448         return d2.properties.id === selectedSequenceId;
42449       });
42450       return this;
42451     },
42452     // Get detections for the current image and shows them in the image viewer
42453     updateDetections: function(imageId, url) {
42454       if (!_mlyViewer || _mlyFallback)
42455         return;
42456       if (!imageId)
42457         return;
42458       const cache = _mlyCache.image_detections;
42459       if (cache.forImageId[imageId]) {
42460         showDetections(_mlyCache.image_detections.forImageId[imageId]);
42461       } else {
42462         loadData(url).then((detections) => {
42463           detections.forEach(function(detection) {
42464             if (!cache.forImageId[imageId]) {
42465               cache.forImageId[imageId] = [];
42466             }
42467             cache.forImageId[imageId].push({
42468               geometry: detection.geometry,
42469               id: detection.id,
42470               image_id: imageId,
42471               value: detection.value
42472             });
42473           });
42474           showDetections(_mlyCache.image_detections.forImageId[imageId] || []);
42475         });
42476       }
42477       function showDetections(detections) {
42478         const tagComponent = _mlyViewer.getComponent("tag");
42479         detections.forEach(function(data) {
42480           const tag2 = makeTag(data);
42481           if (tag2) {
42482             tagComponent.add([tag2]);
42483           }
42484         });
42485       }
42486       function makeTag(data) {
42487         const valueParts = data.value.split("--");
42488         if (!valueParts.length)
42489           return;
42490         let tag2;
42491         let text;
42492         let color2 = 16777215;
42493         if (_mlyHighlightedDetection === data.id) {
42494           color2 = 16776960;
42495           text = valueParts[1];
42496           if (text === "flat" || text === "discrete" || text === "sign") {
42497             text = valueParts[2];
42498           }
42499           text = text.replace(/-/g, " ");
42500           text = text.charAt(0).toUpperCase() + text.slice(1);
42501           _mlyHighlightedDetection = null;
42502         }
42503         var decodedGeometry = window.atob(data.geometry);
42504         var uintArray = new Uint8Array(decodedGeometry.length);
42505         for (var i3 = 0; i3 < decodedGeometry.length; i3++) {
42506           uintArray[i3] = decodedGeometry.charCodeAt(i3);
42507         }
42508         const tile = new import_vector_tile.VectorTile(new import_pbf.default(uintArray.buffer));
42509         const layer = tile.layers["mpy-or"];
42510         const geometries = layer.feature(0).loadGeometry();
42511         const polygon2 = geometries.map((ring) => ring.map((point2) => [point2.x / layer.extent, point2.y / layer.extent]));
42512         tag2 = new mapillary.OutlineTag(
42513           data.id,
42514           new mapillary.PolygonGeometry(polygon2[0]),
42515           {
42516             text,
42517             textColor: color2,
42518             lineColor: color2,
42519             lineWidth: 2,
42520             fillColor: color2,
42521             fillOpacity: 0.3
42522           }
42523         );
42524         return tag2;
42525       }
42526     },
42527     // Return the current cache
42528     cache: function() {
42529       return _mlyCache;
42530     }
42531   };
42532
42533   // modules/core/validation/models.js
42534   function validationIssue(attrs) {
42535     this.type = attrs.type;
42536     this.subtype = attrs.subtype;
42537     this.severity = attrs.severity;
42538     this.message = attrs.message;
42539     this.reference = attrs.reference;
42540     this.entityIds = attrs.entityIds;
42541     this.loc = attrs.loc;
42542     this.data = attrs.data;
42543     this.dynamicFixes = attrs.dynamicFixes;
42544     this.hash = attrs.hash;
42545     this.id = generateID.apply(this);
42546     this.key = generateKey.apply(this);
42547     this.autoFix = null;
42548     function generateID() {
42549       var parts = [this.type];
42550       if (this.hash) {
42551         parts.push(this.hash);
42552       }
42553       if (this.subtype) {
42554         parts.push(this.subtype);
42555       }
42556       if (this.entityIds) {
42557         var entityKeys = this.entityIds.slice().sort();
42558         parts.push.apply(parts, entityKeys);
42559       }
42560       return parts.join(":");
42561     }
42562     function generateKey() {
42563       return this.id + ":" + Date.now().toString();
42564     }
42565     this.extent = function(resolver) {
42566       if (this.loc) {
42567         return geoExtent(this.loc);
42568       }
42569       if (this.entityIds && this.entityIds.length) {
42570         return this.entityIds.reduce(function(extent, entityId) {
42571           return extent.extend(resolver.entity(entityId).extent(resolver));
42572         }, geoExtent());
42573       }
42574       return null;
42575     };
42576     this.fixes = function(context) {
42577       var fixes = this.dynamicFixes ? this.dynamicFixes(context) : [];
42578       var issue = this;
42579       if (issue.severity === "warning") {
42580         fixes.push(new validationIssueFix({
42581           title: _t.append("issues.fix.ignore_issue.title"),
42582           icon: "iD-icon-close",
42583           onClick: function() {
42584             context.validator().ignoreIssue(this.issue.id);
42585           }
42586         }));
42587       }
42588       fixes.forEach(function(fix) {
42589         fix.id = fix.title.stringId;
42590         fix.issue = issue;
42591         if (fix.autoArgs) {
42592           issue.autoFix = fix;
42593         }
42594       });
42595       return fixes;
42596     };
42597   }
42598   function validationIssueFix(attrs) {
42599     this.title = attrs.title;
42600     this.onClick = attrs.onClick;
42601     this.disabledReason = attrs.disabledReason;
42602     this.icon = attrs.icon;
42603     this.entityIds = attrs.entityIds || [];
42604     this.autoArgs = attrs.autoArgs;
42605     this.issue = null;
42606   }
42607
42608   // modules/services/maprules.js
42609   var buildRuleChecks = function() {
42610     return {
42611       equals: function(equals) {
42612         return function(tags) {
42613           return Object.keys(equals).every(function(k2) {
42614             return equals[k2] === tags[k2];
42615           });
42616         };
42617       },
42618       notEquals: function(notEquals) {
42619         return function(tags) {
42620           return Object.keys(notEquals).some(function(k2) {
42621             return notEquals[k2] !== tags[k2];
42622           });
42623         };
42624       },
42625       absence: function(absence) {
42626         return function(tags) {
42627           return Object.keys(tags).indexOf(absence) === -1;
42628         };
42629       },
42630       presence: function(presence) {
42631         return function(tags) {
42632           return Object.keys(tags).indexOf(presence) > -1;
42633         };
42634       },
42635       greaterThan: function(greaterThan) {
42636         var key = Object.keys(greaterThan)[0];
42637         var value = greaterThan[key];
42638         return function(tags) {
42639           return tags[key] > value;
42640         };
42641       },
42642       greaterThanEqual: function(greaterThanEqual) {
42643         var key = Object.keys(greaterThanEqual)[0];
42644         var value = greaterThanEqual[key];
42645         return function(tags) {
42646           return tags[key] >= value;
42647         };
42648       },
42649       lessThan: function(lessThan) {
42650         var key = Object.keys(lessThan)[0];
42651         var value = lessThan[key];
42652         return function(tags) {
42653           return tags[key] < value;
42654         };
42655       },
42656       lessThanEqual: function(lessThanEqual) {
42657         var key = Object.keys(lessThanEqual)[0];
42658         var value = lessThanEqual[key];
42659         return function(tags) {
42660           return tags[key] <= value;
42661         };
42662       },
42663       positiveRegex: function(positiveRegex) {
42664         var tagKey = Object.keys(positiveRegex)[0];
42665         var expression = positiveRegex[tagKey].join("|");
42666         var regex = new RegExp(expression);
42667         return function(tags) {
42668           return regex.test(tags[tagKey]);
42669         };
42670       },
42671       negativeRegex: function(negativeRegex) {
42672         var tagKey = Object.keys(negativeRegex)[0];
42673         var expression = negativeRegex[tagKey].join("|");
42674         var regex = new RegExp(expression);
42675         return function(tags) {
42676           return !regex.test(tags[tagKey]);
42677         };
42678       }
42679     };
42680   };
42681   var buildLineKeys = function() {
42682     return {
42683       highway: {
42684         rest_area: true,
42685         services: true
42686       },
42687       railway: {
42688         roundhouse: true,
42689         station: true,
42690         traverser: true,
42691         turntable: true,
42692         wash: true
42693       }
42694     };
42695   };
42696   var maprules_default = {
42697     init: function() {
42698       this._ruleChecks = buildRuleChecks();
42699       this._validationRules = [];
42700       this._areaKeys = osmAreaKeys;
42701       this._lineKeys = buildLineKeys();
42702     },
42703     // list of rules only relevant to tag checks...
42704     filterRuleChecks: function(selector) {
42705       var _ruleChecks = this._ruleChecks;
42706       return Object.keys(selector).reduce(function(rules, key) {
42707         if (["geometry", "error", "warning"].indexOf(key) === -1) {
42708           rules.push(_ruleChecks[key](selector[key]));
42709         }
42710         return rules;
42711       }, []);
42712     },
42713     // builds tagMap from mapcss-parse selector object...
42714     buildTagMap: function(selector) {
42715       var getRegexValues = function(regexes) {
42716         return regexes.map(function(regex) {
42717           return regex.replace(/\$|\^/g, "");
42718         });
42719       };
42720       var tagMap = Object.keys(selector).reduce(function(expectedTags, key) {
42721         var values;
42722         var isRegex = /regex/gi.test(key);
42723         var isEqual4 = /equals/gi.test(key);
42724         if (isRegex || isEqual4) {
42725           Object.keys(selector[key]).forEach(function(selectorKey) {
42726             values = isEqual4 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]);
42727             if (expectedTags.hasOwnProperty(selectorKey)) {
42728               values = values.concat(expectedTags[selectorKey]);
42729             }
42730             expectedTags[selectorKey] = values;
42731           });
42732         } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) {
42733           var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0];
42734           values = [selector[key][tagKey]];
42735           if (expectedTags.hasOwnProperty(tagKey)) {
42736             values = values.concat(expectedTags[tagKey]);
42737           }
42738           expectedTags[tagKey] = values;
42739         }
42740         return expectedTags;
42741       }, {});
42742       return tagMap;
42743     },
42744     // inspired by osmWay#isArea()
42745     inferGeometry: function(tagMap) {
42746       var _lineKeys = this._lineKeys;
42747       var _areaKeys = this._areaKeys;
42748       var keyValueDoesNotImplyArea = function(key2) {
42749         return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0;
42750       };
42751       var keyValueImpliesLine = function(key2) {
42752         return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0;
42753       };
42754       if (tagMap.hasOwnProperty("area")) {
42755         if (tagMap.area.indexOf("yes") > -1) {
42756           return "area";
42757         }
42758         if (tagMap.area.indexOf("no") > -1) {
42759           return "line";
42760         }
42761       }
42762       for (var key in tagMap) {
42763         if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) {
42764           return "area";
42765         }
42766         if (key in _lineKeys && keyValueImpliesLine(key)) {
42767           return "area";
42768         }
42769       }
42770       return "line";
42771     },
42772     // adds from mapcss-parse selector check...
42773     addRule: function(selector) {
42774       var rule = {
42775         // checks relevant to mapcss-selector
42776         checks: this.filterRuleChecks(selector),
42777         // true if all conditions for a tag error are true..
42778         matches: function(entity) {
42779           return this.checks.every(function(check) {
42780             return check(entity.tags);
42781           });
42782         },
42783         // borrowed from Way#isArea()
42784         inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys),
42785         geometryMatches: function(entity, graph) {
42786           if (entity.type === "node" || entity.type === "relation") {
42787             return selector.geometry === entity.type;
42788           } else if (entity.type === "way") {
42789             return this.inferredGeometry === entity.geometry(graph);
42790           }
42791         },
42792         // when geometries match and tag matches are present, return a warning...
42793         findIssues: function(entity, graph, issues) {
42794           if (this.geometryMatches(entity, graph) && this.matches(entity)) {
42795             var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning";
42796             var message = selector[severity];
42797             issues.push(new validationIssue({
42798               type: "maprules",
42799               severity,
42800               message: function() {
42801                 return message;
42802               },
42803               entityIds: [entity.id]
42804             }));
42805           }
42806         }
42807       };
42808       this._validationRules.push(rule);
42809     },
42810     clearRules: function() {
42811       this._validationRules = [];
42812     },
42813     // returns validationRules...
42814     validationRules: function() {
42815       return this._validationRules;
42816     },
42817     // returns ruleChecks
42818     ruleChecks: function() {
42819       return this._ruleChecks;
42820     }
42821   };
42822
42823   // modules/services/nominatim.js
42824   var import_rbush7 = __toESM(require_rbush_min());
42825
42826   // modules/core/difference.js
42827   var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
42828   function coreDifference(base, head) {
42829     var _changes = {};
42830     var _didChange = {};
42831     var _diff = {};
42832     function checkEntityID(id2) {
42833       var h2 = head.entities[id2];
42834       var b2 = base.entities[id2];
42835       if (h2 === b2)
42836         return;
42837       if (_changes[id2])
42838         return;
42839       if (!h2 && b2) {
42840         _changes[id2] = { base: b2, head: h2 };
42841         _didChange.deletion = true;
42842         return;
42843       }
42844       if (h2 && !b2) {
42845         _changes[id2] = { base: b2, head: h2 };
42846         _didChange.addition = true;
42847         return;
42848       }
42849       if (h2 && b2) {
42850         if (h2.members && b2.members && !(0, import_fast_deep_equal3.default)(h2.members, b2.members)) {
42851           _changes[id2] = { base: b2, head: h2 };
42852           _didChange.geometry = true;
42853           _didChange.properties = true;
42854           return;
42855         }
42856         if (h2.loc && b2.loc && !geoVecEqual(h2.loc, b2.loc)) {
42857           _changes[id2] = { base: b2, head: h2 };
42858           _didChange.geometry = true;
42859         }
42860         if (h2.nodes && b2.nodes && !(0, import_fast_deep_equal3.default)(h2.nodes, b2.nodes)) {
42861           _changes[id2] = { base: b2, head: h2 };
42862           _didChange.geometry = true;
42863         }
42864         if (h2.tags && b2.tags && !(0, import_fast_deep_equal3.default)(h2.tags, b2.tags)) {
42865           _changes[id2] = { base: b2, head: h2 };
42866           _didChange.properties = true;
42867         }
42868       }
42869     }
42870     function load() {
42871       var ids = utilArrayUniq(Object.keys(head.entities).concat(Object.keys(base.entities)));
42872       for (var i3 = 0; i3 < ids.length; i3++) {
42873         checkEntityID(ids[i3]);
42874       }
42875     }
42876     load();
42877     _diff.length = function length2() {
42878       return Object.keys(_changes).length;
42879     };
42880     _diff.changes = function changes() {
42881       return _changes;
42882     };
42883     _diff.didChange = _didChange;
42884     _diff.extantIDs = function extantIDs(includeRelMembers) {
42885       var result = /* @__PURE__ */ new Set();
42886       Object.keys(_changes).forEach(function(id2) {
42887         if (_changes[id2].head) {
42888           result.add(id2);
42889         }
42890         var h2 = _changes[id2].head;
42891         var b2 = _changes[id2].base;
42892         var entity = h2 || b2;
42893         if (includeRelMembers && entity.type === "relation") {
42894           var mh = h2 ? h2.members.map(function(m2) {
42895             return m2.id;
42896           }) : [];
42897           var mb = b2 ? b2.members.map(function(m2) {
42898             return m2.id;
42899           }) : [];
42900           utilArrayUnion(mh, mb).forEach(function(memberID) {
42901             if (head.hasEntity(memberID)) {
42902               result.add(memberID);
42903             }
42904           });
42905         }
42906       });
42907       return Array.from(result);
42908     };
42909     _diff.modified = function modified() {
42910       var result = [];
42911       Object.values(_changes).forEach(function(change) {
42912         if (change.base && change.head) {
42913           result.push(change.head);
42914         }
42915       });
42916       return result;
42917     };
42918     _diff.created = function created() {
42919       var result = [];
42920       Object.values(_changes).forEach(function(change) {
42921         if (!change.base && change.head) {
42922           result.push(change.head);
42923         }
42924       });
42925       return result;
42926     };
42927     _diff.deleted = function deleted() {
42928       var result = [];
42929       Object.values(_changes).forEach(function(change) {
42930         if (change.base && !change.head) {
42931           result.push(change.base);
42932         }
42933       });
42934       return result;
42935     };
42936     _diff.summary = function summary() {
42937       var relevant = {};
42938       var keys2 = Object.keys(_changes);
42939       for (var i3 = 0; i3 < keys2.length; i3++) {
42940         var change = _changes[keys2[i3]];
42941         if (change.head && change.head.geometry(head) !== "vertex") {
42942           addEntity(change.head, head, change.base ? "modified" : "created");
42943         } else if (change.base && change.base.geometry(base) !== "vertex") {
42944           addEntity(change.base, base, "deleted");
42945         } else if (change.base && change.head) {
42946           var moved = !(0, import_fast_deep_equal3.default)(change.base.loc, change.head.loc);
42947           var retagged = !(0, import_fast_deep_equal3.default)(change.base.tags, change.head.tags);
42948           if (moved) {
42949             addParents(change.head);
42950           }
42951           if (retagged || moved && change.head.hasInterestingTags()) {
42952             addEntity(change.head, head, "modified");
42953           }
42954         } else if (change.head && change.head.hasInterestingTags()) {
42955           addEntity(change.head, head, "created");
42956         } else if (change.base && change.base.hasInterestingTags()) {
42957           addEntity(change.base, base, "deleted");
42958         }
42959       }
42960       return Object.values(relevant);
42961       function addEntity(entity, graph, changeType) {
42962         relevant[entity.id] = {
42963           entity,
42964           graph,
42965           changeType
42966         };
42967       }
42968       function addParents(entity) {
42969         var parents = head.parentWays(entity);
42970         for (var j2 = parents.length - 1; j2 >= 0; j2--) {
42971           var parent = parents[j2];
42972           if (!(parent.id in relevant)) {
42973             addEntity(parent, head, "modified");
42974           }
42975         }
42976       }
42977     };
42978     _diff.complete = function complete(extent) {
42979       var result = {};
42980       var id2, change;
42981       for (id2 in _changes) {
42982         change = _changes[id2];
42983         var h2 = change.head;
42984         var b2 = change.base;
42985         var entity = h2 || b2;
42986         var i3;
42987         if (extent && (!h2 || !h2.intersects(extent, head)) && (!b2 || !b2.intersects(extent, base))) {
42988           continue;
42989         }
42990         result[id2] = h2;
42991         if (entity.type === "way") {
42992           var nh = h2 ? h2.nodes : [];
42993           var nb = b2 ? b2.nodes : [];
42994           var diff;
42995           diff = utilArrayDifference(nh, nb);
42996           for (i3 = 0; i3 < diff.length; i3++) {
42997             result[diff[i3]] = head.hasEntity(diff[i3]);
42998           }
42999           diff = utilArrayDifference(nb, nh);
43000           for (i3 = 0; i3 < diff.length; i3++) {
43001             result[diff[i3]] = head.hasEntity(diff[i3]);
43002           }
43003         }
43004         if (entity.type === "relation" && entity.isMultipolygon()) {
43005           var mh = h2 ? h2.members.map(function(m2) {
43006             return m2.id;
43007           }) : [];
43008           var mb = b2 ? b2.members.map(function(m2) {
43009             return m2.id;
43010           }) : [];
43011           var ids = utilArrayUnion(mh, mb);
43012           for (i3 = 0; i3 < ids.length; i3++) {
43013             var member = head.hasEntity(ids[i3]);
43014             if (!member)
43015               continue;
43016             if (extent && !member.intersects(extent, head))
43017               continue;
43018             result[ids[i3]] = member;
43019           }
43020         }
43021         addParents(head.parentWays(entity), result);
43022         addParents(head.parentRelations(entity), result);
43023       }
43024       return result;
43025       function addParents(parents, result2) {
43026         for (var i4 = 0; i4 < parents.length; i4++) {
43027           var parent = parents[i4];
43028           if (parent.id in result2)
43029             continue;
43030           result2[parent.id] = parent;
43031           addParents(head.parentRelations(parent), result2);
43032         }
43033       }
43034     };
43035     return _diff;
43036   }
43037
43038   // modules/core/tree.js
43039   var import_rbush5 = __toESM(require_rbush_min());
43040   function coreTree(head) {
43041     var _rtree = new import_rbush5.default();
43042     var _bboxes = {};
43043     var _segmentsRTree = new import_rbush5.default();
43044     var _segmentsBBoxes = {};
43045     var _segmentsByWayId = {};
43046     var tree = {};
43047     function entityBBox(entity) {
43048       var bbox2 = entity.extent(head).bbox();
43049       bbox2.id = entity.id;
43050       _bboxes[entity.id] = bbox2;
43051       return bbox2;
43052     }
43053     function segmentBBox(segment) {
43054       var extent = segment.extent(head);
43055       if (!extent)
43056         return null;
43057       var bbox2 = extent.bbox();
43058       bbox2.segment = segment;
43059       _segmentsBBoxes[segment.id] = bbox2;
43060       return bbox2;
43061     }
43062     function removeEntity(entity) {
43063       _rtree.remove(_bboxes[entity.id]);
43064       delete _bboxes[entity.id];
43065       if (_segmentsByWayId[entity.id]) {
43066         _segmentsByWayId[entity.id].forEach(function(segment) {
43067           _segmentsRTree.remove(_segmentsBBoxes[segment.id]);
43068           delete _segmentsBBoxes[segment.id];
43069         });
43070         delete _segmentsByWayId[entity.id];
43071       }
43072     }
43073     function loadEntities(entities) {
43074       _rtree.load(entities.map(entityBBox));
43075       var segments = [];
43076       entities.forEach(function(entity) {
43077         if (entity.segments) {
43078           var entitySegments = entity.segments(head);
43079           _segmentsByWayId[entity.id] = entitySegments;
43080           segments = segments.concat(entitySegments);
43081         }
43082       });
43083       if (segments.length)
43084         _segmentsRTree.load(segments.map(segmentBBox).filter(Boolean));
43085     }
43086     function updateParents(entity, insertions, memo) {
43087       head.parentWays(entity).forEach(function(way) {
43088         if (_bboxes[way.id]) {
43089           removeEntity(way);
43090           insertions[way.id] = way;
43091         }
43092         updateParents(way, insertions, memo);
43093       });
43094       head.parentRelations(entity).forEach(function(relation) {
43095         if (memo[entity.id])
43096           return;
43097         memo[entity.id] = true;
43098         if (_bboxes[relation.id]) {
43099           removeEntity(relation);
43100           insertions[relation.id] = relation;
43101         }
43102         updateParents(relation, insertions, memo);
43103       });
43104     }
43105     tree.rebase = function(entities, force) {
43106       var insertions = {};
43107       for (var i3 = 0; i3 < entities.length; i3++) {
43108         var entity = entities[i3];
43109         if (!entity.visible)
43110           continue;
43111         if (head.entities.hasOwnProperty(entity.id) || _bboxes[entity.id]) {
43112           if (!force) {
43113             continue;
43114           } else if (_bboxes[entity.id]) {
43115             removeEntity(entity);
43116           }
43117         }
43118         insertions[entity.id] = entity;
43119         updateParents(entity, insertions, {});
43120       }
43121       loadEntities(Object.values(insertions));
43122       return tree;
43123     };
43124     function updateToGraph(graph) {
43125       if (graph === head)
43126         return;
43127       var diff = coreDifference(head, graph);
43128       head = graph;
43129       var changed = diff.didChange;
43130       if (!changed.addition && !changed.deletion && !changed.geometry)
43131         return;
43132       var insertions = {};
43133       if (changed.deletion) {
43134         diff.deleted().forEach(function(entity) {
43135           removeEntity(entity);
43136         });
43137       }
43138       if (changed.geometry) {
43139         diff.modified().forEach(function(entity) {
43140           removeEntity(entity);
43141           insertions[entity.id] = entity;
43142           updateParents(entity, insertions, {});
43143         });
43144       }
43145       if (changed.addition) {
43146         diff.created().forEach(function(entity) {
43147           insertions[entity.id] = entity;
43148         });
43149       }
43150       loadEntities(Object.values(insertions));
43151     }
43152     tree.intersects = function(extent, graph) {
43153       updateToGraph(graph);
43154       return _rtree.search(extent.bbox()).map(function(bbox2) {
43155         return graph.entity(bbox2.id);
43156       });
43157     };
43158     tree.waySegments = function(extent, graph) {
43159       updateToGraph(graph);
43160       return _segmentsRTree.search(extent.bbox()).map(function(bbox2) {
43161         return bbox2.segment;
43162       });
43163     };
43164     return tree;
43165   }
43166
43167   // modules/svg/icon.js
43168   function svgIcon(name, svgklass, useklass) {
43169     return function drawIcon(selection2) {
43170       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);
43171     };
43172   }
43173
43174   // modules/ui/modal.js
43175   function uiModal(selection2, blocking) {
43176     let keybinding = utilKeybinding("modal");
43177     let previous = selection2.select("div.modal");
43178     let animate = previous.empty();
43179     previous.transition().duration(200).style("opacity", 0).remove();
43180     let shaded = selection2.append("div").attr("class", "shaded").style("opacity", 0);
43181     shaded.close = () => {
43182       shaded.transition().duration(200).style("opacity", 0).remove();
43183       modal.transition().duration(200).style("top", "0px");
43184       select_default2(document).call(keybinding.unbind);
43185     };
43186     let modal = shaded.append("div").attr("class", "modal fillL");
43187     modal.append("input").attr("class", "keytrap keytrap-first").on("focus.keytrap", moveFocusToLast);
43188     if (!blocking) {
43189       shaded.on("click.remove-modal", (d3_event) => {
43190         if (d3_event.target === this) {
43191           shaded.close();
43192         }
43193       });
43194       modal.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", shaded.close).call(svgIcon("#iD-icon-close"));
43195       keybinding.on("\u232B", shaded.close).on("\u238B", shaded.close);
43196       select_default2(document).call(keybinding);
43197     }
43198     modal.append("div").attr("class", "content");
43199     modal.append("input").attr("class", "keytrap keytrap-last").on("focus.keytrap", moveFocusToFirst);
43200     if (animate) {
43201       shaded.transition().style("opacity", 1);
43202     } else {
43203       shaded.style("opacity", 1);
43204     }
43205     return shaded;
43206     function moveFocusToFirst() {
43207       let node = modal.select("a, button, input:not(.keytrap), select, textarea").node();
43208       if (node) {
43209         node.focus();
43210       } else {
43211         select_default2(this).node().blur();
43212       }
43213     }
43214     function moveFocusToLast() {
43215       let nodes = modal.selectAll("a, button, input:not(.keytrap), select, textarea").nodes();
43216       if (nodes.length) {
43217         nodes[nodes.length - 1].focus();
43218       } else {
43219         select_default2(this).node().blur();
43220       }
43221     }
43222   }
43223
43224   // modules/ui/loading.js
43225   function uiLoading(context) {
43226     let _modalSelection = select_default2(null);
43227     let _message = "";
43228     let _blocking = false;
43229     let loading = (selection2) => {
43230       _modalSelection = uiModal(selection2, _blocking);
43231       let loadertext = _modalSelection.select(".content").classed("loading-modal", true).append("div").attr("class", "modal-section fillL");
43232       loadertext.append("img").attr("class", "loader").attr("src", context.imagePath("loader-white.gif"));
43233       loadertext.append("h3").html(_message);
43234       _modalSelection.select("button.close").attr("class", "hide");
43235       return loading;
43236     };
43237     loading.message = function(val) {
43238       if (!arguments.length)
43239         return _message;
43240       _message = val;
43241       return loading;
43242     };
43243     loading.blocking = function(val) {
43244       if (!arguments.length)
43245         return _blocking;
43246       _blocking = val;
43247       return loading;
43248     };
43249     loading.close = () => {
43250       _modalSelection.remove();
43251     };
43252     loading.isShown = () => {
43253       return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode;
43254     };
43255     return loading;
43256   }
43257
43258   // modules/core/history.js
43259   function coreHistory(context) {
43260     var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error");
43261     var lock = utilSessionMutex("lock");
43262     var _hasUnresolvedRestorableChanges = lock.lock() && !!corePreferences(getKey("saved_history"));
43263     var duration = 150;
43264     var _imageryUsed = [];
43265     var _photoOverlaysUsed = [];
43266     var _checkpoints = {};
43267     var _pausedGraph;
43268     var _stack;
43269     var _index;
43270     var _tree;
43271     function _act(actions, t2) {
43272       actions = Array.prototype.slice.call(actions);
43273       var annotation;
43274       if (typeof actions[actions.length - 1] !== "function") {
43275         annotation = actions.pop();
43276       }
43277       var graph = _stack[_index].graph;
43278       for (var i3 = 0; i3 < actions.length; i3++) {
43279         graph = actions[i3](graph, t2);
43280       }
43281       return {
43282         graph,
43283         annotation,
43284         imageryUsed: _imageryUsed,
43285         photoOverlaysUsed: _photoOverlaysUsed,
43286         transform: context.projection.transform(),
43287         selectedIDs: context.selectedIDs()
43288       };
43289     }
43290     function _perform(args, t2) {
43291       var previous = _stack[_index].graph;
43292       _stack = _stack.slice(0, _index + 1);
43293       var actionResult = _act(args, t2);
43294       _stack.push(actionResult);
43295       _index++;
43296       return change(previous);
43297     }
43298     function _replace(args, t2) {
43299       var previous = _stack[_index].graph;
43300       var actionResult = _act(args, t2);
43301       _stack[_index] = actionResult;
43302       return change(previous);
43303     }
43304     function _overwrite(args, t2) {
43305       var previous = _stack[_index].graph;
43306       if (_index > 0) {
43307         _index--;
43308         _stack.pop();
43309       }
43310       _stack = _stack.slice(0, _index + 1);
43311       var actionResult = _act(args, t2);
43312       _stack.push(actionResult);
43313       _index++;
43314       return change(previous);
43315     }
43316     function change(previous) {
43317       var difference2 = coreDifference(previous, history.graph());
43318       if (!_pausedGraph) {
43319         dispatch14.call("change", this, difference2);
43320       }
43321       return difference2;
43322     }
43323     function getKey(n3) {
43324       return "iD_" + window.location.origin + "_" + n3;
43325     }
43326     var history = {
43327       graph: function() {
43328         return _stack[_index].graph;
43329       },
43330       tree: function() {
43331         return _tree;
43332       },
43333       base: function() {
43334         return _stack[0].graph;
43335       },
43336       merge: function(entities) {
43337         var stack = _stack.map(function(state) {
43338           return state.graph;
43339         });
43340         _stack[0].graph.rebase(entities, stack, false);
43341         _tree.rebase(entities, false);
43342         dispatch14.call("merge", this, entities);
43343       },
43344       perform: function() {
43345         select_default2(document).interrupt("history.perform");
43346         var transitionable = false;
43347         var action0 = arguments[0];
43348         if (arguments.length === 1 || arguments.length === 2 && typeof arguments[1] !== "function") {
43349           transitionable = !!action0.transitionable;
43350         }
43351         if (transitionable) {
43352           var origArguments = arguments;
43353           select_default2(document).transition("history.perform").duration(duration).ease(linear2).tween("history.tween", function() {
43354             return function(t2) {
43355               if (t2 < 1)
43356                 _overwrite([action0], t2);
43357             };
43358           }).on("start", function() {
43359             _perform([action0], 0);
43360           }).on("end interrupt", function() {
43361             _overwrite(origArguments, 1);
43362           });
43363         } else {
43364           return _perform(arguments);
43365         }
43366       },
43367       replace: function() {
43368         select_default2(document).interrupt("history.perform");
43369         return _replace(arguments, 1);
43370       },
43371       // Same as calling pop and then perform
43372       overwrite: function() {
43373         select_default2(document).interrupt("history.perform");
43374         return _overwrite(arguments, 1);
43375       },
43376       pop: function(n3) {
43377         select_default2(document).interrupt("history.perform");
43378         var previous = _stack[_index].graph;
43379         if (isNaN(+n3) || +n3 < 0) {
43380           n3 = 1;
43381         }
43382         while (n3-- > 0 && _index > 0) {
43383           _index--;
43384           _stack.pop();
43385         }
43386         return change(previous);
43387       },
43388       // Back to the previous annotated state or _index = 0.
43389       undo: function() {
43390         select_default2(document).interrupt("history.perform");
43391         var previousStack = _stack[_index];
43392         var previous = previousStack.graph;
43393         while (_index > 0) {
43394           _index--;
43395           if (_stack[_index].annotation)
43396             break;
43397         }
43398         dispatch14.call("undone", this, _stack[_index], previousStack);
43399         return change(previous);
43400       },
43401       // Forward to the next annotated state.
43402       redo: function() {
43403         select_default2(document).interrupt("history.perform");
43404         var previousStack = _stack[_index];
43405         var previous = previousStack.graph;
43406         var tryIndex = _index;
43407         while (tryIndex < _stack.length - 1) {
43408           tryIndex++;
43409           if (_stack[tryIndex].annotation) {
43410             _index = tryIndex;
43411             dispatch14.call("redone", this, _stack[_index], previousStack);
43412             break;
43413           }
43414         }
43415         return change(previous);
43416       },
43417       pauseChangeDispatch: function() {
43418         if (!_pausedGraph) {
43419           _pausedGraph = _stack[_index].graph;
43420         }
43421       },
43422       resumeChangeDispatch: function() {
43423         if (_pausedGraph) {
43424           var previous = _pausedGraph;
43425           _pausedGraph = null;
43426           return change(previous);
43427         }
43428       },
43429       undoAnnotation: function() {
43430         var i3 = _index;
43431         while (i3 >= 0) {
43432           if (_stack[i3].annotation)
43433             return _stack[i3].annotation;
43434           i3--;
43435         }
43436       },
43437       redoAnnotation: function() {
43438         var i3 = _index + 1;
43439         while (i3 <= _stack.length - 1) {
43440           if (_stack[i3].annotation)
43441             return _stack[i3].annotation;
43442           i3++;
43443         }
43444       },
43445       // Returns the entities from the active graph with bounding boxes
43446       // overlapping the given `extent`.
43447       intersects: function(extent) {
43448         return _tree.intersects(extent, _stack[_index].graph);
43449       },
43450       difference: function() {
43451         var base = _stack[0].graph;
43452         var head = _stack[_index].graph;
43453         return coreDifference(base, head);
43454       },
43455       changes: function(action) {
43456         var base = _stack[0].graph;
43457         var head = _stack[_index].graph;
43458         if (action) {
43459           head = action(head);
43460         }
43461         var difference2 = coreDifference(base, head);
43462         return {
43463           modified: difference2.modified(),
43464           created: difference2.created(),
43465           deleted: difference2.deleted()
43466         };
43467       },
43468       hasChanges: function() {
43469         return this.difference().length() > 0;
43470       },
43471       imageryUsed: function(sources) {
43472         if (sources) {
43473           _imageryUsed = sources;
43474           return history;
43475         } else {
43476           var s2 = /* @__PURE__ */ new Set();
43477           _stack.slice(1, _index + 1).forEach(function(state) {
43478             state.imageryUsed.forEach(function(source) {
43479               if (source !== "Custom") {
43480                 s2.add(source);
43481               }
43482             });
43483           });
43484           return Array.from(s2);
43485         }
43486       },
43487       photoOverlaysUsed: function(sources) {
43488         if (sources) {
43489           _photoOverlaysUsed = sources;
43490           return history;
43491         } else {
43492           var s2 = /* @__PURE__ */ new Set();
43493           _stack.slice(1, _index + 1).forEach(function(state) {
43494             if (state.photoOverlaysUsed && Array.isArray(state.photoOverlaysUsed)) {
43495               state.photoOverlaysUsed.forEach(function(photoOverlay) {
43496                 s2.add(photoOverlay);
43497               });
43498             }
43499           });
43500           return Array.from(s2);
43501         }
43502       },
43503       // save the current history state
43504       checkpoint: function(key) {
43505         _checkpoints[key] = {
43506           stack: _stack,
43507           index: _index
43508         };
43509         return history;
43510       },
43511       // restore history state to a given checkpoint or reset completely
43512       reset: function(key) {
43513         if (key !== void 0 && _checkpoints.hasOwnProperty(key)) {
43514           _stack = _checkpoints[key].stack;
43515           _index = _checkpoints[key].index;
43516         } else {
43517           _stack = [{ graph: coreGraph() }];
43518           _index = 0;
43519           _tree = coreTree(_stack[0].graph);
43520           _checkpoints = {};
43521         }
43522         dispatch14.call("reset");
43523         dispatch14.call("change");
43524         return history;
43525       },
43526       // `toIntroGraph()` is used to export the intro graph used by the walkthrough.
43527       //
43528       // To use it:
43529       //  1. Start the walkthrough.
43530       //  2. Get to a "free editing" tutorial step
43531       //  3. Make your edits to the walkthrough map
43532       //  4. In your browser dev console run:
43533       //        `id.history().toIntroGraph()`
43534       //  5. This outputs stringified JSON to the browser console
43535       //  6. Copy it to `data/intro_graph.json` and prettify it in your code editor
43536       toIntroGraph: function() {
43537         var nextID = { n: 0, r: 0, w: 0 };
43538         var permIDs = {};
43539         var graph = this.graph();
43540         var baseEntities = {};
43541         Object.values(graph.base().entities).forEach(function(entity) {
43542           var copy2 = copyIntroEntity(entity);
43543           baseEntities[copy2.id] = copy2;
43544         });
43545         Object.keys(graph.entities).forEach(function(id2) {
43546           var entity = graph.entities[id2];
43547           if (entity) {
43548             var copy2 = copyIntroEntity(entity);
43549             baseEntities[copy2.id] = copy2;
43550           } else {
43551             delete baseEntities[id2];
43552           }
43553         });
43554         Object.values(baseEntities).forEach(function(entity) {
43555           if (Array.isArray(entity.nodes)) {
43556             entity.nodes = entity.nodes.map(function(node) {
43557               return permIDs[node] || node;
43558             });
43559           }
43560           if (Array.isArray(entity.members)) {
43561             entity.members = entity.members.map(function(member) {
43562               member.id = permIDs[member.id] || member.id;
43563               return member;
43564             });
43565           }
43566         });
43567         return JSON.stringify({ dataIntroGraph: baseEntities });
43568         function copyIntroEntity(source) {
43569           var copy2 = utilObjectOmit(source, ["type", "user", "v", "version", "visible"]);
43570           if (copy2.tags && !Object.keys(copy2.tags)) {
43571             delete copy2.tags;
43572           }
43573           if (Array.isArray(copy2.loc)) {
43574             copy2.loc[0] = +copy2.loc[0].toFixed(6);
43575             copy2.loc[1] = +copy2.loc[1].toFixed(6);
43576           }
43577           var match = source.id.match(/([nrw])-\d*/);
43578           if (match !== null) {
43579             var nrw = match[1];
43580             var permID;
43581             do {
43582               permID = nrw + ++nextID[nrw];
43583             } while (baseEntities.hasOwnProperty(permID));
43584             copy2.id = permIDs[source.id] = permID;
43585           }
43586           return copy2;
43587         }
43588       },
43589       toJSON: function() {
43590         if (!this.hasChanges())
43591           return;
43592         var allEntities = {};
43593         var baseEntities = {};
43594         var base = _stack[0];
43595         var s2 = _stack.map(function(i3) {
43596           var modified = [];
43597           var deleted = [];
43598           Object.keys(i3.graph.entities).forEach(function(id2) {
43599             var entity = i3.graph.entities[id2];
43600             if (entity) {
43601               var key = osmEntity.key(entity);
43602               allEntities[key] = entity;
43603               modified.push(key);
43604             } else {
43605               deleted.push(id2);
43606             }
43607             if (id2 in base.graph.entities) {
43608               baseEntities[id2] = base.graph.entities[id2];
43609             }
43610             if (entity && entity.nodes) {
43611               entity.nodes.forEach(function(nodeID) {
43612                 if (nodeID in base.graph.entities) {
43613                   baseEntities[nodeID] = base.graph.entities[nodeID];
43614                 }
43615               });
43616             }
43617             var baseParents = base.graph._parentWays[id2];
43618             if (baseParents) {
43619               baseParents.forEach(function(parentID) {
43620                 if (parentID in base.graph.entities) {
43621                   baseEntities[parentID] = base.graph.entities[parentID];
43622                 }
43623               });
43624             }
43625           });
43626           var x2 = {};
43627           if (modified.length)
43628             x2.modified = modified;
43629           if (deleted.length)
43630             x2.deleted = deleted;
43631           if (i3.imageryUsed)
43632             x2.imageryUsed = i3.imageryUsed;
43633           if (i3.photoOverlaysUsed)
43634             x2.photoOverlaysUsed = i3.photoOverlaysUsed;
43635           if (i3.annotation)
43636             x2.annotation = i3.annotation;
43637           if (i3.transform)
43638             x2.transform = i3.transform;
43639           if (i3.selectedIDs)
43640             x2.selectedIDs = i3.selectedIDs;
43641           return x2;
43642         });
43643         return JSON.stringify({
43644           version: 3,
43645           entities: Object.values(allEntities),
43646           baseEntities: Object.values(baseEntities),
43647           stack: s2,
43648           nextIDs: osmEntity.id.next,
43649           index: _index,
43650           // note the time the changes were saved
43651           timestamp: (/* @__PURE__ */ new Date()).getTime()
43652         });
43653       },
43654       fromJSON: function(json, loadChildNodes) {
43655         var h2 = JSON.parse(json);
43656         var loadComplete = true;
43657         osmEntity.id.next = h2.nextIDs;
43658         _index = h2.index;
43659         if (h2.version === 2 || h2.version === 3) {
43660           var allEntities = {};
43661           h2.entities.forEach(function(entity) {
43662             allEntities[osmEntity.key(entity)] = osmEntity(entity);
43663           });
43664           if (h2.version === 3) {
43665             var baseEntities = h2.baseEntities.map(function(d2) {
43666               return osmEntity(d2);
43667             });
43668             var stack = _stack.map(function(state) {
43669               return state.graph;
43670             });
43671             _stack[0].graph.rebase(baseEntities, stack, true);
43672             _tree.rebase(baseEntities, true);
43673             if (loadChildNodes) {
43674               var osm = context.connection();
43675               var baseWays = baseEntities.filter(function(e3) {
43676                 return e3.type === "way";
43677               });
43678               var nodeIDs = baseWays.reduce(function(acc, way) {
43679                 return utilArrayUnion(acc, way.nodes);
43680               }, []);
43681               var missing = nodeIDs.filter(function(n3) {
43682                 return !_stack[0].graph.hasEntity(n3);
43683               });
43684               if (missing.length && osm) {
43685                 loadComplete = false;
43686                 context.map().redrawEnable(false);
43687                 var loading = uiLoading(context).blocking(true);
43688                 context.container().call(loading);
43689                 var childNodesLoaded = function(err, result) {
43690                   if (!err) {
43691                     var visibleGroups = utilArrayGroupBy(result.data, "visible");
43692                     var visibles = visibleGroups.true || [];
43693                     var invisibles = visibleGroups.false || [];
43694                     if (visibles.length) {
43695                       var visibleIDs = visibles.map(function(entity) {
43696                         return entity.id;
43697                       });
43698                       var stack2 = _stack.map(function(state) {
43699                         return state.graph;
43700                       });
43701                       missing = utilArrayDifference(missing, visibleIDs);
43702                       _stack[0].graph.rebase(visibles, stack2, true);
43703                       _tree.rebase(visibles, true);
43704                     }
43705                     invisibles.forEach(function(entity) {
43706                       osm.loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded);
43707                     });
43708                   }
43709                   if (err || !missing.length) {
43710                     loading.close();
43711                     context.map().redrawEnable(true);
43712                     dispatch14.call("change");
43713                     dispatch14.call("restore", this);
43714                   }
43715                 };
43716                 osm.loadMultiple(missing, childNodesLoaded);
43717               }
43718             }
43719           }
43720           _stack = h2.stack.map(function(d2) {
43721             var entities = {}, entity;
43722             if (d2.modified) {
43723               d2.modified.forEach(function(key) {
43724                 entity = allEntities[key];
43725                 entities[entity.id] = entity;
43726               });
43727             }
43728             if (d2.deleted) {
43729               d2.deleted.forEach(function(id2) {
43730                 entities[id2] = void 0;
43731               });
43732             }
43733             return {
43734               graph: coreGraph(_stack[0].graph).load(entities),
43735               annotation: d2.annotation,
43736               imageryUsed: d2.imageryUsed,
43737               photoOverlaysUsed: d2.photoOverlaysUsed,
43738               transform: d2.transform,
43739               selectedIDs: d2.selectedIDs
43740             };
43741           });
43742         } else {
43743           _stack = h2.stack.map(function(d2) {
43744             var entities = {};
43745             for (var i3 in d2.entities) {
43746               var entity = d2.entities[i3];
43747               entities[i3] = entity === "undefined" ? void 0 : osmEntity(entity);
43748             }
43749             d2.graph = coreGraph(_stack[0].graph).load(entities);
43750             return d2;
43751           });
43752         }
43753         var transform2 = _stack[_index].transform;
43754         if (transform2) {
43755           context.map().transformEase(transform2, 0);
43756         }
43757         if (loadComplete) {
43758           dispatch14.call("change");
43759           dispatch14.call("restore", this);
43760         }
43761         return history;
43762       },
43763       lock: function() {
43764         return lock.lock();
43765       },
43766       unlock: function() {
43767         lock.unlock();
43768       },
43769       save: function() {
43770         if (lock.locked() && // don't overwrite existing, unresolved changes
43771         !_hasUnresolvedRestorableChanges) {
43772           const success = corePreferences(getKey("saved_history"), history.toJSON() || null);
43773           if (!success)
43774             dispatch14.call("storage_error");
43775         }
43776         return history;
43777       },
43778       // delete the history version saved in localStorage
43779       clearSaved: function() {
43780         context.debouncedSave.cancel();
43781         if (lock.locked()) {
43782           _hasUnresolvedRestorableChanges = false;
43783           corePreferences(getKey("saved_history"), null);
43784           corePreferences("comment", null);
43785           corePreferences("hashtags", null);
43786           corePreferences("source", null);
43787         }
43788         return history;
43789       },
43790       savedHistoryJSON: function() {
43791         return corePreferences(getKey("saved_history"));
43792       },
43793       hasRestorableChanges: function() {
43794         return _hasUnresolvedRestorableChanges;
43795       },
43796       // load history from a version stored in localStorage
43797       restore: function() {
43798         if (lock.locked()) {
43799           _hasUnresolvedRestorableChanges = false;
43800           var json = this.savedHistoryJSON();
43801           if (json)
43802             history.fromJSON(json, true);
43803         }
43804       },
43805       _getKey: getKey
43806     };
43807     history.reset();
43808     return utilRebind(history, dispatch14, "on");
43809   }
43810
43811   // modules/validations/index.js
43812   var validations_exports = {};
43813   __export(validations_exports, {
43814     validationAlmostJunction: () => validationAlmostJunction,
43815     validationCloseNodes: () => validationCloseNodes,
43816     validationCrossingWays: () => validationCrossingWays,
43817     validationDisconnectedWay: () => validationDisconnectedWay,
43818     validationFormatting: () => validationFormatting,
43819     validationHelpRequest: () => validationHelpRequest,
43820     validationImpossibleOneway: () => validationImpossibleOneway,
43821     validationIncompatibleSource: () => validationIncompatibleSource,
43822     validationMaprules: () => validationMaprules,
43823     validationMismatchedGeometry: () => validationMismatchedGeometry,
43824     validationMissingRole: () => validationMissingRole,
43825     validationMissingTag: () => validationMissingTag,
43826     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
43827     validationOutdatedTags: () => validationOutdatedTags,
43828     validationPrivateData: () => validationPrivateData,
43829     validationSuspiciousName: () => validationSuspiciousName,
43830     validationUnsquareWay: () => validationUnsquareWay
43831   });
43832
43833   // modules/validations/almost_junction.js
43834   function validationAlmostJunction(context) {
43835     const type2 = "almost_junction";
43836     const EXTEND_TH_METERS = 5;
43837     const WELD_TH_METERS = 0.75;
43838     const CLOSE_NODE_TH = EXTEND_TH_METERS - WELD_TH_METERS;
43839     const SIG_ANGLE_TH = Math.atan(WELD_TH_METERS / EXTEND_TH_METERS);
43840     function isHighway(entity) {
43841       return entity.type === "way" && osmRoutableHighwayTagValues[entity.tags.highway];
43842     }
43843     function isTaggedAsNotContinuing(node) {
43844       return node.tags.noexit === "yes" || node.tags.amenity === "parking_entrance" || node.tags.entrance && node.tags.entrance !== "no";
43845     }
43846     const validation = function checkAlmostJunction(entity, graph) {
43847       if (!isHighway(entity))
43848         return [];
43849       if (entity.isDegenerate())
43850         return [];
43851       const tree = context.history().tree();
43852       const extendableNodeInfos = findConnectableEndNodesByExtension(entity);
43853       let issues = [];
43854       extendableNodeInfos.forEach((extendableNodeInfo) => {
43855         issues.push(new validationIssue({
43856           type: type2,
43857           subtype: "highway-highway",
43858           severity: "warning",
43859           message: function(context2) {
43860             const entity1 = context2.hasEntity(this.entityIds[0]);
43861             if (this.entityIds[0] === this.entityIds[2]) {
43862               return entity1 ? _t.append("issues.almost_junction.self.message", {
43863                 feature: utilDisplayLabel(entity1, context2.graph())
43864               }) : "";
43865             } else {
43866               const entity2 = context2.hasEntity(this.entityIds[2]);
43867               return entity1 && entity2 ? _t.append("issues.almost_junction.message", {
43868                 feature: utilDisplayLabel(entity1, context2.graph()),
43869                 feature2: utilDisplayLabel(entity2, context2.graph())
43870               }) : "";
43871             }
43872           },
43873           reference: showReference,
43874           entityIds: [
43875             entity.id,
43876             extendableNodeInfo.node.id,
43877             extendableNodeInfo.wid
43878           ],
43879           loc: extendableNodeInfo.node.loc,
43880           hash: JSON.stringify(extendableNodeInfo.node.loc),
43881           data: {
43882             midId: extendableNodeInfo.mid.id,
43883             edge: extendableNodeInfo.edge,
43884             cross_loc: extendableNodeInfo.cross_loc
43885           },
43886           dynamicFixes: makeFixes
43887         }));
43888       });
43889       return issues;
43890       function makeFixes(context2) {
43891         let fixes = [new validationIssueFix({
43892           icon: "iD-icon-abutment",
43893           title: _t.append("issues.fix.connect_features.title"),
43894           onClick: function(context3) {
43895             const annotation = _t("issues.fix.connect_almost_junction.annotation");
43896             const [, endNodeId, crossWayId] = this.issue.entityIds;
43897             const midNode = context3.entity(this.issue.data.midId);
43898             const endNode = context3.entity(endNodeId);
43899             const crossWay = context3.entity(crossWayId);
43900             const nearEndNodes = findNearbyEndNodes(endNode, crossWay);
43901             if (nearEndNodes.length > 0) {
43902               const collinear = findSmallJoinAngle(midNode, endNode, nearEndNodes);
43903               if (collinear) {
43904                 context3.perform(
43905                   actionMergeNodes([collinear.id, endNode.id], collinear.loc),
43906                   annotation
43907                 );
43908                 return;
43909               }
43910             }
43911             const targetEdge = this.issue.data.edge;
43912             const crossLoc = this.issue.data.cross_loc;
43913             const edgeNodes = [context3.entity(targetEdge[0]), context3.entity(targetEdge[1])];
43914             const closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
43915             if (closestNodeInfo.distance < WELD_TH_METERS) {
43916               context3.perform(
43917                 actionMergeNodes([closestNodeInfo.node.id, endNode.id], closestNodeInfo.node.loc),
43918                 annotation
43919               );
43920             } else {
43921               context3.perform(
43922                 actionAddMidpoint({ loc: crossLoc, edge: targetEdge }, endNode),
43923                 annotation
43924               );
43925             }
43926           }
43927         })];
43928         const node = context2.hasEntity(this.entityIds[1]);
43929         if (node && !node.hasInterestingTags()) {
43930           fixes.push(new validationIssueFix({
43931             icon: "maki-barrier",
43932             title: _t.append("issues.fix.tag_as_disconnected.title"),
43933             onClick: function(context3) {
43934               const nodeID = this.issue.entityIds[1];
43935               const tags = Object.assign({}, context3.entity(nodeID).tags);
43936               tags.noexit = "yes";
43937               context3.perform(
43938                 actionChangeTags(nodeID, tags),
43939                 _t("issues.fix.tag_as_disconnected.annotation")
43940               );
43941             }
43942           }));
43943         }
43944         return fixes;
43945       }
43946       function showReference(selection2) {
43947         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.almost_junction.highway-highway.reference"));
43948       }
43949       function isExtendableCandidate(node, way) {
43950         const osm = services.osm;
43951         if (osm && !osm.isDataLoaded(node.loc)) {
43952           return false;
43953         }
43954         if (isTaggedAsNotContinuing(node) || graph.parentWays(node).length !== 1) {
43955           return false;
43956         }
43957         let occurrences = 0;
43958         for (const index in way.nodes) {
43959           if (way.nodes[index] === node.id) {
43960             occurrences += 1;
43961             if (occurrences > 1) {
43962               return false;
43963             }
43964           }
43965         }
43966         return true;
43967       }
43968       function findConnectableEndNodesByExtension(way) {
43969         let results = [];
43970         if (way.isClosed())
43971           return results;
43972         let testNodes;
43973         const indices = [0, way.nodes.length - 1];
43974         indices.forEach((nodeIndex) => {
43975           const nodeID = way.nodes[nodeIndex];
43976           const node = graph.entity(nodeID);
43977           if (!isExtendableCandidate(node, way))
43978             return;
43979           const connectionInfo = canConnectByExtend(way, nodeIndex);
43980           if (!connectionInfo)
43981             return;
43982           testNodes = graph.childNodes(way).slice();
43983           testNodes[nodeIndex] = testNodes[nodeIndex].move(connectionInfo.cross_loc);
43984           if (geoHasSelfIntersections(testNodes, nodeID))
43985             return;
43986           results.push(connectionInfo);
43987         });
43988         return results;
43989       }
43990       function findNearbyEndNodes(node, way) {
43991         return [
43992           way.nodes[0],
43993           way.nodes[way.nodes.length - 1]
43994         ].map((d2) => graph.entity(d2)).filter((d2) => {
43995           return d2.id !== node.id && geoSphericalDistance(node.loc, d2.loc) <= CLOSE_NODE_TH;
43996         });
43997       }
43998       function findSmallJoinAngle(midNode, tipNode, endNodes) {
43999         let joinTo;
44000         let minAngle = Infinity;
44001         endNodes.forEach((endNode) => {
44002           const a1 = geoAngle(midNode, tipNode, context.projection) + Math.PI;
44003           const a2 = geoAngle(midNode, endNode, context.projection) + Math.PI;
44004           const diff = Math.max(a1, a2) - Math.min(a1, a2);
44005           if (diff < minAngle) {
44006             joinTo = endNode;
44007             minAngle = diff;
44008           }
44009         });
44010         if (minAngle <= SIG_ANGLE_TH)
44011           return joinTo;
44012         return null;
44013       }
44014       function hasTag(tags, key) {
44015         return tags[key] !== void 0 && tags[key] !== "no";
44016       }
44017       function canConnectWays(way, way2) {
44018         if (way.id === way2.id)
44019           return true;
44020         if ((hasTag(way.tags, "bridge") || hasTag(way2.tags, "bridge")) && !(hasTag(way.tags, "bridge") && hasTag(way2.tags, "bridge")))
44021           return false;
44022         if ((hasTag(way.tags, "tunnel") || hasTag(way2.tags, "tunnel")) && !(hasTag(way.tags, "tunnel") && hasTag(way2.tags, "tunnel")))
44023           return false;
44024         const layer1 = way.tags.layer || "0", layer2 = way2.tags.layer || "0";
44025         if (layer1 !== layer2)
44026           return false;
44027         const level1 = way.tags.level || "0", level2 = way2.tags.level || "0";
44028         if (level1 !== level2)
44029           return false;
44030         return true;
44031       }
44032       function canConnectByExtend(way, endNodeIdx) {
44033         const tipNid = way.nodes[endNodeIdx];
44034         const midNid = endNodeIdx === 0 ? way.nodes[1] : way.nodes[way.nodes.length - 2];
44035         const tipNode = graph.entity(tipNid);
44036         const midNode = graph.entity(midNid);
44037         const lon = tipNode.loc[0];
44038         const lat = tipNode.loc[1];
44039         const lon_range = geoMetersToLon(EXTEND_TH_METERS, lat) / 2;
44040         const lat_range = geoMetersToLat(EXTEND_TH_METERS) / 2;
44041         const queryExtent = geoExtent([
44042           [lon - lon_range, lat - lat_range],
44043           [lon + lon_range, lat + lat_range]
44044         ]);
44045         const edgeLen = geoSphericalDistance(midNode.loc, tipNode.loc);
44046         const t2 = EXTEND_TH_METERS / edgeLen + 1;
44047         const extTipLoc = geoVecInterp(midNode.loc, tipNode.loc, t2);
44048         const segmentInfos = tree.waySegments(queryExtent, graph);
44049         for (let i3 = 0; i3 < segmentInfos.length; i3++) {
44050           let segmentInfo = segmentInfos[i3];
44051           let way2 = graph.entity(segmentInfo.wayId);
44052           if (!isHighway(way2))
44053             continue;
44054           if (!canConnectWays(way, way2))
44055             continue;
44056           let nAid = segmentInfo.nodes[0], nBid = segmentInfo.nodes[1];
44057           if (nAid === tipNid || nBid === tipNid)
44058             continue;
44059           let nA = graph.entity(nAid), nB = graph.entity(nBid);
44060           let crossLoc = geoLineIntersection([tipNode.loc, extTipLoc], [nA.loc, nB.loc]);
44061           if (crossLoc) {
44062             return {
44063               mid: midNode,
44064               node: tipNode,
44065               wid: way2.id,
44066               edge: [nA.id, nB.id],
44067               cross_loc: crossLoc
44068             };
44069           }
44070         }
44071         return null;
44072       }
44073     };
44074     validation.type = type2;
44075     return validation;
44076   }
44077
44078   // modules/validations/close_nodes.js
44079   function validationCloseNodes(context) {
44080     var type2 = "close_nodes";
44081     var pointThresholdMeters = 0.2;
44082     var validation = function(entity, graph) {
44083       if (entity.type === "node") {
44084         return getIssuesForNode(entity);
44085       } else if (entity.type === "way") {
44086         return getIssuesForWay(entity);
44087       }
44088       return [];
44089       function getIssuesForNode(node) {
44090         var parentWays = graph.parentWays(node);
44091         if (parentWays.length) {
44092           return getIssuesForVertex(node, parentWays);
44093         } else {
44094           return getIssuesForDetachedPoint(node);
44095         }
44096       }
44097       function wayTypeFor(way) {
44098         if (way.tags.boundary && way.tags.boundary !== "no")
44099           return "boundary";
44100         if (way.tags.indoor && way.tags.indoor !== "no")
44101           return "indoor";
44102         if (way.tags.building && way.tags.building !== "no" || way.tags["building:part"] && way.tags["building:part"] !== "no")
44103           return "building";
44104         if (osmPathHighwayTagValues[way.tags.highway])
44105           return "path";
44106         var parentRelations = graph.parentRelations(way);
44107         for (var i3 in parentRelations) {
44108           var relation = parentRelations[i3];
44109           if (relation.tags.type === "boundary")
44110             return "boundary";
44111           if (relation.isMultipolygon()) {
44112             if (relation.tags.indoor && relation.tags.indoor !== "no")
44113               return "indoor";
44114             if (relation.tags.building && relation.tags.building !== "no" || relation.tags["building:part"] && relation.tags["building:part"] !== "no")
44115               return "building";
44116           }
44117         }
44118         return "other";
44119       }
44120       function shouldCheckWay(way) {
44121         if (way.nodes.length <= 2 || way.isClosed() && way.nodes.length <= 4)
44122           return false;
44123         var bbox2 = way.extent(graph).bbox();
44124         var hypotenuseMeters = geoSphericalDistance([bbox2.minX, bbox2.minY], [bbox2.maxX, bbox2.maxY]);
44125         if (hypotenuseMeters < 1.5)
44126           return false;
44127         return true;
44128       }
44129       function getIssuesForWay(way) {
44130         if (!shouldCheckWay(way))
44131           return [];
44132         var issues = [], nodes = graph.childNodes(way);
44133         for (var i3 = 0; i3 < nodes.length - 1; i3++) {
44134           var node1 = nodes[i3];
44135           var node2 = nodes[i3 + 1];
44136           var issue = getWayIssueIfAny(node1, node2, way);
44137           if (issue)
44138             issues.push(issue);
44139         }
44140         return issues;
44141       }
44142       function getIssuesForVertex(node, parentWays) {
44143         var issues = [];
44144         function checkForCloseness(node1, node2, way) {
44145           var issue = getWayIssueIfAny(node1, node2, way);
44146           if (issue)
44147             issues.push(issue);
44148         }
44149         for (var i3 = 0; i3 < parentWays.length; i3++) {
44150           var parentWay = parentWays[i3];
44151           if (!shouldCheckWay(parentWay))
44152             continue;
44153           var lastIndex = parentWay.nodes.length - 1;
44154           for (var j2 = 0; j2 < parentWay.nodes.length; j2++) {
44155             if (j2 !== 0) {
44156               if (parentWay.nodes[j2 - 1] === node.id) {
44157                 checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay);
44158               }
44159             }
44160             if (j2 !== lastIndex) {
44161               if (parentWay.nodes[j2 + 1] === node.id) {
44162                 checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay);
44163               }
44164             }
44165           }
44166         }
44167         return issues;
44168       }
44169       function thresholdMetersForWay(way) {
44170         if (!shouldCheckWay(way))
44171           return 0;
44172         var wayType = wayTypeFor(way);
44173         if (wayType === "boundary")
44174           return 0;
44175         if (wayType === "indoor")
44176           return 0.01;
44177         if (wayType === "building")
44178           return 0.05;
44179         if (wayType === "path")
44180           return 0.1;
44181         return 0.2;
44182       }
44183       function getIssuesForDetachedPoint(node) {
44184         var issues = [];
44185         var lon = node.loc[0];
44186         var lat = node.loc[1];
44187         var lon_range = geoMetersToLon(pointThresholdMeters, lat) / 2;
44188         var lat_range = geoMetersToLat(pointThresholdMeters) / 2;
44189         var queryExtent = geoExtent([
44190           [lon - lon_range, lat - lat_range],
44191           [lon + lon_range, lat + lat_range]
44192         ]);
44193         var intersected = context.history().tree().intersects(queryExtent, graph);
44194         for (var j2 = 0; j2 < intersected.length; j2++) {
44195           var nearby = intersected[j2];
44196           if (nearby.id === node.id)
44197             continue;
44198           if (nearby.type !== "node" || nearby.geometry(graph) !== "point")
44199             continue;
44200           if (nearby.loc === node.loc || geoSphericalDistance(node.loc, nearby.loc) < pointThresholdMeters) {
44201             if ("memorial:type" in node.tags && "memorial:type" in nearby.tags && node.tags["memorial:type"] === "stolperstein" && nearby.tags["memorial:type"] === "stolperstein")
44202               continue;
44203             if ("memorial" in node.tags && "memorial" in nearby.tags && node.tags.memorial === "stolperstein" && nearby.tags.memorial === "stolperstein")
44204               continue;
44205             var zAxisKeys = { layer: true, level: true, "addr:housenumber": true, "addr:unit": true };
44206             var zAxisDifferentiates = false;
44207             for (var key in zAxisKeys) {
44208               var nodeValue = node.tags[key] || "0";
44209               var nearbyValue = nearby.tags[key] || "0";
44210               if (nodeValue !== nearbyValue) {
44211                 zAxisDifferentiates = true;
44212                 break;
44213               }
44214             }
44215             if (zAxisDifferentiates)
44216               continue;
44217             issues.push(new validationIssue({
44218               type: type2,
44219               subtype: "detached",
44220               severity: "warning",
44221               message: function(context2) {
44222                 var entity2 = context2.hasEntity(this.entityIds[0]), entity22 = context2.hasEntity(this.entityIds[1]);
44223                 return entity2 && entity22 ? _t.append("issues.close_nodes.detached.message", {
44224                   feature: utilDisplayLabel(entity2, context2.graph()),
44225                   feature2: utilDisplayLabel(entity22, context2.graph())
44226                 }) : "";
44227               },
44228               reference: showReference,
44229               entityIds: [node.id, nearby.id],
44230               dynamicFixes: function() {
44231                 return [
44232                   new validationIssueFix({
44233                     icon: "iD-operation-disconnect",
44234                     title: _t.append("issues.fix.move_points_apart.title")
44235                   }),
44236                   new validationIssueFix({
44237                     icon: "iD-icon-layers",
44238                     title: _t.append("issues.fix.use_different_layers_or_levels.title")
44239                   })
44240                 ];
44241               }
44242             }));
44243           }
44244         }
44245         return issues;
44246         function showReference(selection2) {
44247           var referenceText = _t("issues.close_nodes.detached.reference");
44248           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44249         }
44250       }
44251       function getWayIssueIfAny(node1, node2, way) {
44252         if (node1.id === node2.id || node1.hasInterestingTags() && node2.hasInterestingTags()) {
44253           return null;
44254         }
44255         if (node1.loc !== node2.loc) {
44256           var parentWays1 = graph.parentWays(node1);
44257           var parentWays2 = new Set(graph.parentWays(node2));
44258           var sharedWays = parentWays1.filter(function(parentWay) {
44259             return parentWays2.has(parentWay);
44260           });
44261           var thresholds = sharedWays.map(function(parentWay) {
44262             return thresholdMetersForWay(parentWay);
44263           });
44264           var threshold = Math.min(...thresholds);
44265           var distance = geoSphericalDistance(node1.loc, node2.loc);
44266           if (distance > threshold)
44267             return null;
44268         }
44269         return new validationIssue({
44270           type: type2,
44271           subtype: "vertices",
44272           severity: "warning",
44273           message: function(context2) {
44274             var entity2 = context2.hasEntity(this.entityIds[0]);
44275             return entity2 ? _t.append("issues.close_nodes.message", { way: utilDisplayLabel(entity2, context2.graph()) }) : "";
44276           },
44277           reference: showReference,
44278           entityIds: [way.id, node1.id, node2.id],
44279           loc: node1.loc,
44280           dynamicFixes: function() {
44281             return [
44282               new validationIssueFix({
44283                 icon: "iD-icon-plus",
44284                 title: _t.append("issues.fix.merge_points.title"),
44285                 onClick: function(context2) {
44286                   var entityIds = this.issue.entityIds;
44287                   var action = actionMergeNodes([entityIds[1], entityIds[2]]);
44288                   context2.perform(action, _t("issues.fix.merge_close_vertices.annotation"));
44289                 }
44290               }),
44291               new validationIssueFix({
44292                 icon: "iD-operation-disconnect",
44293                 title: _t.append("issues.fix.move_points_apart.title")
44294               })
44295             ];
44296           }
44297         });
44298         function showReference(selection2) {
44299           var referenceText = _t("issues.close_nodes.reference");
44300           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44301         }
44302       }
44303     };
44304     validation.type = type2;
44305     return validation;
44306   }
44307
44308   // modules/validations/crossing_ways.js
44309   var import_lodash3 = __toESM(require_lodash());
44310   function validationCrossingWays(context) {
44311     var type2 = "crossing_ways";
44312     function getFeatureWithFeatureTypeTagsForWay(way, graph) {
44313       if (getFeatureType(way, graph) === null) {
44314         var parentRels = graph.parentRelations(way);
44315         for (var i3 = 0; i3 < parentRels.length; i3++) {
44316           var rel = parentRels[i3];
44317           if (getFeatureType(rel, graph) !== null) {
44318             return rel;
44319           }
44320         }
44321       }
44322       return way;
44323     }
44324     function hasTag(tags, key) {
44325       return tags[key] !== void 0 && tags[key] !== "no";
44326     }
44327     function taggedAsIndoor(tags) {
44328       return hasTag(tags, "indoor") || hasTag(tags, "level") || tags.highway === "corridor";
44329     }
44330     function allowsBridge(featureType) {
44331       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44332     }
44333     function allowsTunnel(featureType) {
44334       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44335     }
44336     var ignoredBuildings = {
44337       demolished: true,
44338       dismantled: true,
44339       proposed: true,
44340       razed: true
44341     };
44342     function getFeatureType(entity, graph) {
44343       var geometry = entity.geometry(graph);
44344       if (geometry !== "line" && geometry !== "area")
44345         return null;
44346       var tags = entity.tags;
44347       if (hasTag(tags, "building") && !ignoredBuildings[tags.building])
44348         return "building";
44349       if (hasTag(tags, "highway") && osmRoutableHighwayTagValues[tags.highway])
44350         return "highway";
44351       if (geometry !== "line")
44352         return null;
44353       if (hasTag(tags, "railway") && osmRailwayTrackTagValues[tags.railway])
44354         return "railway";
44355       if (hasTag(tags, "waterway") && osmFlowingWaterwayTagValues[tags.waterway])
44356         return "waterway";
44357       return null;
44358     }
44359     function isLegitCrossing(tags1, featureType1, tags2, featureType2) {
44360       var level1 = tags1.level || "0";
44361       var level2 = tags2.level || "0";
44362       if (taggedAsIndoor(tags1) && taggedAsIndoor(tags2) && level1 !== level2) {
44363         return true;
44364       }
44365       var layer1 = tags1.layer || "0";
44366       var layer2 = tags2.layer || "0";
44367       if (allowsBridge(featureType1) && allowsBridge(featureType2)) {
44368         if (hasTag(tags1, "bridge") && !hasTag(tags2, "bridge"))
44369           return true;
44370         if (!hasTag(tags1, "bridge") && hasTag(tags2, "bridge"))
44371           return true;
44372         if (hasTag(tags1, "bridge") && hasTag(tags2, "bridge") && layer1 !== layer2)
44373           return true;
44374       } else if (allowsBridge(featureType1) && hasTag(tags1, "bridge"))
44375         return true;
44376       else if (allowsBridge(featureType2) && hasTag(tags2, "bridge"))
44377         return true;
44378       if (allowsTunnel(featureType1) && allowsTunnel(featureType2)) {
44379         if (hasTag(tags1, "tunnel") && !hasTag(tags2, "tunnel"))
44380           return true;
44381         if (!hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel"))
44382           return true;
44383         if (hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel") && layer1 !== layer2)
44384           return true;
44385       } else if (allowsTunnel(featureType1) && hasTag(tags1, "tunnel"))
44386         return true;
44387       else if (allowsTunnel(featureType2) && hasTag(tags2, "tunnel"))
44388         return true;
44389       if (featureType1 === "waterway" && featureType2 === "highway" && tags2.man_made === "pier")
44390         return true;
44391       if (featureType2 === "waterway" && featureType1 === "highway" && tags1.man_made === "pier")
44392         return true;
44393       if (featureType1 === "building" || featureType2 === "building" || taggedAsIndoor(tags1) || taggedAsIndoor(tags2)) {
44394         if (layer1 !== layer2)
44395           return true;
44396       }
44397       return false;
44398     }
44399     var highwaysDisallowingFords = {
44400       motorway: true,
44401       motorway_link: true,
44402       trunk: true,
44403       trunk_link: true,
44404       primary: true,
44405       primary_link: true,
44406       secondary: true,
44407       secondary_link: true
44408     };
44409     function tagsForConnectionNodeIfAllowed(entity1, entity2, graph, lessLikelyTags) {
44410       var featureType1 = getFeatureType(entity1, graph);
44411       var featureType2 = getFeatureType(entity2, graph);
44412       var geometry1 = entity1.geometry(graph);
44413       var geometry2 = entity2.geometry(graph);
44414       var bothLines = geometry1 === "line" && geometry2 === "line";
44415       if (featureType1 === featureType2) {
44416         if (featureType1 === "highway") {
44417           var entity1IsPath = osmPathHighwayTagValues[entity1.tags.highway];
44418           var entity2IsPath = osmPathHighwayTagValues[entity2.tags.highway];
44419           if ((entity1IsPath || entity2IsPath) && entity1IsPath !== entity2IsPath) {
44420             var roadFeature = entity1IsPath ? entity2 : entity1;
44421             var pathFeature = entity1IsPath ? entity1 : entity2;
44422             if (roadFeature.tags.highway === "track") {
44423               return {};
44424             }
44425             if (!lessLikelyTags && roadFeature.tags.highway === "service" && pathFeature.tags.highway === "footway" && pathFeature.tags.footway === "sidewalk") {
44426               return {};
44427             }
44428             if (["marked", "unmarked", "traffic_signals", "uncontrolled"].indexOf(pathFeature.tags.crossing) !== -1) {
44429               return bothLines ? { highway: "crossing", crossing: pathFeature.tags.crossing } : {};
44430             }
44431             return bothLines ? { highway: "crossing" } : {};
44432           }
44433           return {};
44434         }
44435         if (featureType1 === "waterway")
44436           return {};
44437         if (featureType1 === "railway")
44438           return {};
44439       } else {
44440         var featureTypes = [featureType1, featureType2];
44441         if (featureTypes.indexOf("highway") !== -1) {
44442           if (featureTypes.indexOf("railway") !== -1) {
44443             if (!bothLines)
44444               return {};
44445             var isTram = entity1.tags.railway === "tram" || entity2.tags.railway === "tram";
44446             if (osmPathHighwayTagValues[entity1.tags.highway] || osmPathHighwayTagValues[entity2.tags.highway]) {
44447               if (isTram)
44448                 return { railway: "tram_crossing" };
44449               return { railway: "crossing" };
44450             } else {
44451               if (isTram)
44452                 return { railway: "tram_level_crossing" };
44453               return { railway: "level_crossing" };
44454             }
44455           }
44456           if (featureTypes.indexOf("waterway") !== -1) {
44457             if (hasTag(entity1.tags, "tunnel") && hasTag(entity2.tags, "tunnel"))
44458               return null;
44459             if (hasTag(entity1.tags, "bridge") && hasTag(entity2.tags, "bridge"))
44460               return null;
44461             if (highwaysDisallowingFords[entity1.tags.highway] || highwaysDisallowingFords[entity2.tags.highway]) {
44462               return null;
44463             }
44464             return bothLines ? { ford: "yes" } : {};
44465           }
44466         }
44467       }
44468       return null;
44469     }
44470     function findCrossingsByWay(way1, graph, tree) {
44471       var edgeCrossInfos = [];
44472       if (way1.type !== "way")
44473         return edgeCrossInfos;
44474       var taggedFeature1 = getFeatureWithFeatureTypeTagsForWay(way1, graph);
44475       var way1FeatureType = getFeatureType(taggedFeature1, graph);
44476       if (way1FeatureType === null)
44477         return edgeCrossInfos;
44478       var checkedSingleCrossingWays = {};
44479       var i3, j2;
44480       var extent;
44481       var n1, n22, nA, nB, nAId, nBId;
44482       var segment1, segment2;
44483       var oneOnly;
44484       var segmentInfos, segment2Info, way2, taggedFeature2, way2FeatureType;
44485       var way1Nodes = graph.childNodes(way1);
44486       var comparedWays = {};
44487       for (i3 = 0; i3 < way1Nodes.length - 1; i3++) {
44488         n1 = way1Nodes[i3];
44489         n22 = way1Nodes[i3 + 1];
44490         extent = geoExtent([
44491           [
44492             Math.min(n1.loc[0], n22.loc[0]),
44493             Math.min(n1.loc[1], n22.loc[1])
44494           ],
44495           [
44496             Math.max(n1.loc[0], n22.loc[0]),
44497             Math.max(n1.loc[1], n22.loc[1])
44498           ]
44499         ]);
44500         segmentInfos = tree.waySegments(extent, graph);
44501         for (j2 = 0; j2 < segmentInfos.length; j2++) {
44502           segment2Info = segmentInfos[j2];
44503           if (segment2Info.wayId === way1.id)
44504             continue;
44505           if (checkedSingleCrossingWays[segment2Info.wayId])
44506             continue;
44507           comparedWays[segment2Info.wayId] = true;
44508           way2 = graph.hasEntity(segment2Info.wayId);
44509           if (!way2)
44510             continue;
44511           taggedFeature2 = getFeatureWithFeatureTypeTagsForWay(way2, graph);
44512           way2FeatureType = getFeatureType(taggedFeature2, graph);
44513           if (way2FeatureType === null || isLegitCrossing(taggedFeature1.tags, way1FeatureType, taggedFeature2.tags, way2FeatureType)) {
44514             continue;
44515           }
44516           oneOnly = way1FeatureType === "building" || way2FeatureType === "building";
44517           nAId = segment2Info.nodes[0];
44518           nBId = segment2Info.nodes[1];
44519           if (nAId === n1.id || nAId === n22.id || nBId === n1.id || nBId === n22.id) {
44520             continue;
44521           }
44522           nA = graph.hasEntity(nAId);
44523           if (!nA)
44524             continue;
44525           nB = graph.hasEntity(nBId);
44526           if (!nB)
44527             continue;
44528           segment1 = [n1.loc, n22.loc];
44529           segment2 = [nA.loc, nB.loc];
44530           var point2 = geoLineIntersection(segment1, segment2);
44531           if (point2) {
44532             edgeCrossInfos.push({
44533               wayInfos: [
44534                 {
44535                   way: way1,
44536                   featureType: way1FeatureType,
44537                   edge: [n1.id, n22.id]
44538                 },
44539                 {
44540                   way: way2,
44541                   featureType: way2FeatureType,
44542                   edge: [nA.id, nB.id]
44543                 }
44544               ],
44545               crossPoint: point2
44546             });
44547             if (oneOnly) {
44548               checkedSingleCrossingWays[way2.id] = true;
44549               break;
44550             }
44551           }
44552         }
44553       }
44554       return edgeCrossInfos;
44555     }
44556     function waysToCheck(entity, graph) {
44557       var featureType = getFeatureType(entity, graph);
44558       if (!featureType)
44559         return [];
44560       if (entity.type === "way") {
44561         return [entity];
44562       } else if (entity.type === "relation") {
44563         return entity.members.reduce(function(array2, member) {
44564           if (member.type === "way" && // only look at geometry ways
44565           (!member.role || member.role === "outer" || member.role === "inner")) {
44566             var entity2 = graph.hasEntity(member.id);
44567             if (entity2 && array2.indexOf(entity2) === -1) {
44568               array2.push(entity2);
44569             }
44570           }
44571           return array2;
44572         }, []);
44573       }
44574       return [];
44575     }
44576     var validation = function checkCrossingWays(entity, graph) {
44577       var tree = context.history().tree();
44578       var ways = waysToCheck(entity, graph);
44579       var issues = [];
44580       var wayIndex, crossingIndex, crossings;
44581       for (wayIndex in ways) {
44582         crossings = findCrossingsByWay(ways[wayIndex], graph, tree);
44583         for (crossingIndex in crossings) {
44584           issues.push(createIssue(crossings[crossingIndex], graph));
44585         }
44586       }
44587       return issues;
44588     };
44589     function createIssue(crossing, graph) {
44590       crossing.wayInfos.sort(function(way1Info, way2Info) {
44591         var type1 = way1Info.featureType;
44592         var type22 = way2Info.featureType;
44593         if (type1 === type22) {
44594           return utilDisplayLabel(way1Info.way, graph) > utilDisplayLabel(way2Info.way, graph);
44595         } else if (type1 === "waterway") {
44596           return true;
44597         } else if (type22 === "waterway") {
44598           return false;
44599         }
44600         return type1 < type22;
44601       });
44602       var entities = crossing.wayInfos.map(function(wayInfo) {
44603         return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
44604       });
44605       var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
44606       var featureTypes = [crossing.wayInfos[0].featureType, crossing.wayInfos[1].featureType];
44607       var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph);
44608       var featureType1 = crossing.wayInfos[0].featureType;
44609       var featureType2 = crossing.wayInfos[1].featureType;
44610       var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
44611       var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, "tunnel") && allowsTunnel(featureType2) && hasTag(entities[1].tags, "tunnel");
44612       var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, "bridge") && allowsBridge(featureType2) && hasTag(entities[1].tags, "bridge");
44613       var subtype = [featureType1, featureType2].sort().join("-");
44614       var crossingTypeID = subtype;
44615       if (isCrossingIndoors) {
44616         crossingTypeID = "indoor-indoor";
44617       } else if (isCrossingTunnels) {
44618         crossingTypeID = "tunnel-tunnel";
44619       } else if (isCrossingBridges) {
44620         crossingTypeID = "bridge-bridge";
44621       }
44622       if (connectionTags && (isCrossingIndoors || isCrossingTunnels || isCrossingBridges)) {
44623         crossingTypeID += "_connectable";
44624       }
44625       var uniqueID = crossing.crossPoint[0].toFixed(4) + "," + crossing.crossPoint[1].toFixed(4);
44626       return new validationIssue({
44627         type: type2,
44628         subtype,
44629         severity: "warning",
44630         message: function(context2) {
44631           var graph2 = context2.graph();
44632           var entity1 = graph2.hasEntity(this.entityIds[0]), entity2 = graph2.hasEntity(this.entityIds[1]);
44633           return entity1 && entity2 ? _t.append("issues.crossing_ways.message", {
44634             feature: utilDisplayLabel(entity1, graph2),
44635             feature2: utilDisplayLabel(entity2, graph2)
44636           }) : "";
44637         },
44638         reference: showReference,
44639         entityIds: entities.map(function(entity) {
44640           return entity.id;
44641         }),
44642         data: {
44643           edges,
44644           featureTypes,
44645           connectionTags
44646         },
44647         hash: uniqueID,
44648         loc: crossing.crossPoint,
44649         dynamicFixes: function(context2) {
44650           var mode = context2.mode();
44651           if (!mode || mode.id !== "select" || mode.selectedIDs().length !== 1)
44652             return [];
44653           var selectedIndex = this.entityIds[0] === mode.selectedIDs()[0] ? 0 : 1;
44654           var selectedFeatureType = this.data.featureTypes[selectedIndex];
44655           var otherFeatureType = this.data.featureTypes[selectedIndex === 0 ? 1 : 0];
44656           var fixes = [];
44657           if (connectionTags) {
44658             fixes.push(makeConnectWaysFix(this.data.connectionTags));
44659             let lessLikelyConnectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph, true);
44660             if (lessLikelyConnectionTags && !(0, import_lodash3.isEqual)(connectionTags, lessLikelyConnectionTags)) {
44661               fixes.push(makeConnectWaysFix(lessLikelyConnectionTags));
44662             }
44663           }
44664           if (isCrossingIndoors) {
44665             fixes.push(new validationIssueFix({
44666               icon: "iD-icon-layers",
44667               title: _t.append("issues.fix.use_different_levels.title")
44668             }));
44669           } else if (isCrossingTunnels || isCrossingBridges || featureType1 === "building" || featureType2 === "building") {
44670             fixes.push(makeChangeLayerFix("higher"));
44671             fixes.push(makeChangeLayerFix("lower"));
44672           } else if (context2.graph().geometry(this.entityIds[0]) === "line" && context2.graph().geometry(this.entityIds[1]) === "line") {
44673             if (allowsBridge(selectedFeatureType) && selectedFeatureType !== "waterway") {
44674               fixes.push(makeAddBridgeOrTunnelFix("add_a_bridge", "temaki-bridge", "bridge"));
44675             }
44676             var skipTunnelFix = otherFeatureType === "waterway" && selectedFeatureType !== "waterway";
44677             if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) {
44678               fixes.push(makeAddBridgeOrTunnelFix("add_a_tunnel", "temaki-tunnel", "tunnel"));
44679             }
44680           }
44681           fixes.push(new validationIssueFix({
44682             icon: "iD-operation-move",
44683             title: _t.append("issues.fix.reposition_features.title")
44684           }));
44685           return fixes;
44686         }
44687       });
44688       function showReference(selection2) {
44689         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.crossing_ways." + crossingTypeID + ".reference"));
44690       }
44691     }
44692     function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
44693       return new validationIssueFix({
44694         icon: iconName,
44695         title: _t.append("issues.fix." + fixTitleID + ".title"),
44696         onClick: function(context2) {
44697           var mode = context2.mode();
44698           if (!mode || mode.id !== "select")
44699             return;
44700           var selectedIDs = mode.selectedIDs();
44701           if (selectedIDs.length !== 1)
44702             return;
44703           var selectedWayID = selectedIDs[0];
44704           if (!context2.hasEntity(selectedWayID))
44705             return;
44706           var resultWayIDs = [selectedWayID];
44707           var edge, crossedEdge, crossedWayID;
44708           if (this.issue.entityIds[0] === selectedWayID) {
44709             edge = this.issue.data.edges[0];
44710             crossedEdge = this.issue.data.edges[1];
44711             crossedWayID = this.issue.entityIds[1];
44712           } else {
44713             edge = this.issue.data.edges[1];
44714             crossedEdge = this.issue.data.edges[0];
44715             crossedWayID = this.issue.entityIds[0];
44716           }
44717           var crossingLoc = this.issue.loc;
44718           var projection2 = context2.projection;
44719           var action = function actionAddStructure(graph) {
44720             var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44721             var crossedWay = graph.hasEntity(crossedWayID);
44722             var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width);
44723             if (!structLengthMeters) {
44724               structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters();
44725             }
44726             if (structLengthMeters) {
44727               if (getFeatureType(crossedWay, graph) === "railway") {
44728                 structLengthMeters *= 2;
44729               }
44730             } else {
44731               structLengthMeters = 8;
44732             }
44733             var a1 = geoAngle(edgeNodes[0], edgeNodes[1], projection2) + Math.PI;
44734             var a2 = geoAngle(graph.entity(crossedEdge[0]), graph.entity(crossedEdge[1]), projection2) + Math.PI;
44735             var crossingAngle = Math.max(a1, a2) - Math.min(a1, a2);
44736             if (crossingAngle > Math.PI)
44737               crossingAngle -= Math.PI;
44738             structLengthMeters = structLengthMeters / 2 / Math.sin(crossingAngle) * 2;
44739             structLengthMeters += 4;
44740             structLengthMeters = Math.min(Math.max(structLengthMeters, 4), 50);
44741             function geomToProj(geoPoint) {
44742               return [
44743                 geoLonToMeters(geoPoint[0], geoPoint[1]),
44744                 geoLatToMeters(geoPoint[1])
44745               ];
44746             }
44747             function projToGeom(projPoint) {
44748               var lat = geoMetersToLat(projPoint[1]);
44749               return [
44750                 geoMetersToLon(projPoint[0], lat),
44751                 lat
44752               ];
44753             }
44754             var projEdgeNode1 = geomToProj(edgeNodes[0].loc);
44755             var projEdgeNode2 = geomToProj(edgeNodes[1].loc);
44756             var projectedAngle = geoVecAngle(projEdgeNode1, projEdgeNode2);
44757             var projectedCrossingLoc = geomToProj(crossingLoc);
44758             var linearToSphericalMetersRatio = geoVecLength(projEdgeNode1, projEdgeNode2) / geoSphericalDistance(edgeNodes[0].loc, edgeNodes[1].loc);
44759             function locSphericalDistanceFromCrossingLoc(angle2, distanceMeters) {
44760               var lengthSphericalMeters = distanceMeters * linearToSphericalMetersRatio;
44761               return projToGeom([
44762                 projectedCrossingLoc[0] + Math.cos(angle2) * lengthSphericalMeters,
44763                 projectedCrossingLoc[1] + Math.sin(angle2) * lengthSphericalMeters
44764               ]);
44765             }
44766             var endpointLocGetter1 = function(lengthMeters) {
44767               return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
44768             };
44769             var endpointLocGetter2 = function(lengthMeters) {
44770               return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
44771             };
44772             var minEdgeLengthMeters = 0.55;
44773             function determineEndpoint(edge2, endNode, locGetter) {
44774               var newNode;
44775               var idealLengthMeters = structLengthMeters / 2;
44776               var crossingToEdgeEndDistance = geoSphericalDistance(crossingLoc, endNode.loc);
44777               if (crossingToEdgeEndDistance - idealLengthMeters > minEdgeLengthMeters) {
44778                 var idealNodeLoc = locGetter(idealLengthMeters);
44779                 newNode = osmNode();
44780                 graph = actionAddMidpoint({ loc: idealNodeLoc, edge: edge2 }, newNode)(graph);
44781               } else {
44782                 var edgeCount = 0;
44783                 endNode.parentIntersectionWays(graph).forEach(function(way) {
44784                   way.nodes.forEach(function(nodeID) {
44785                     if (nodeID === endNode.id) {
44786                       if (endNode.id === way.first() && endNode.id !== way.last() || endNode.id === way.last() && endNode.id !== way.first()) {
44787                         edgeCount += 1;
44788                       } else {
44789                         edgeCount += 2;
44790                       }
44791                     }
44792                   });
44793                 });
44794                 if (edgeCount >= 3) {
44795                   var insetLength = crossingToEdgeEndDistance - minEdgeLengthMeters;
44796                   if (insetLength > minEdgeLengthMeters) {
44797                     var insetNodeLoc = locGetter(insetLength);
44798                     newNode = osmNode();
44799                     graph = actionAddMidpoint({ loc: insetNodeLoc, edge: edge2 }, newNode)(graph);
44800                   }
44801                 }
44802               }
44803               if (!newNode)
44804                 newNode = endNode;
44805               var splitAction = actionSplit([newNode.id]).limitWays(resultWayIDs);
44806               graph = splitAction(graph);
44807               if (splitAction.getCreatedWayIDs().length) {
44808                 resultWayIDs.push(splitAction.getCreatedWayIDs()[0]);
44809               }
44810               return newNode;
44811             }
44812             var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
44813             var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
44814             var structureWay = resultWayIDs.map(function(id2) {
44815               return graph.entity(id2);
44816             }).find(function(way) {
44817               return way.nodes.indexOf(structEndNode1.id) !== -1 && way.nodes.indexOf(structEndNode2.id) !== -1;
44818             });
44819             var tags = Object.assign({}, structureWay.tags);
44820             if (bridgeOrTunnel === "bridge") {
44821               tags.bridge = "yes";
44822               tags.layer = "1";
44823             } else {
44824               var tunnelValue = "yes";
44825               if (getFeatureType(structureWay, graph) === "waterway") {
44826                 tunnelValue = "culvert";
44827               }
44828               tags.tunnel = tunnelValue;
44829               tags.layer = "-1";
44830             }
44831             graph = actionChangeTags(structureWay.id, tags)(graph);
44832             return graph;
44833           };
44834           context2.perform(action, _t("issues.fix." + fixTitleID + ".annotation"));
44835           context2.enter(modeSelect(context2, resultWayIDs));
44836         }
44837       });
44838     }
44839     function makeConnectWaysFix(connectionTags) {
44840       var fixTitleID = "connect_features";
44841       var fixIcon = "iD-icon-crossing";
44842       if (connectionTags.highway === "crossing") {
44843         fixTitleID = "connect_using_crossing";
44844         fixIcon = "temaki-pedestrian";
44845       }
44846       if (connectionTags.ford) {
44847         fixTitleID = "connect_using_ford";
44848         fixIcon = "roentgen-ford";
44849       }
44850       const fix = new validationIssueFix({
44851         icon: fixIcon,
44852         title: _t.append("issues.fix." + fixTitleID + ".title"),
44853         onClick: function(context2) {
44854           var loc = this.issue.loc;
44855           var edges = this.issue.data.edges;
44856           context2.perform(
44857             function actionConnectCrossingWays(graph) {
44858               var node = osmNode({ loc, tags: connectionTags });
44859               graph = graph.replace(node);
44860               var nodesToMerge = [node.id];
44861               var mergeThresholdInMeters = 0.75;
44862               edges.forEach(function(edge) {
44863                 var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44864                 var nearby = geoSphericalClosestNode(edgeNodes, loc);
44865                 if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
44866                   nodesToMerge.push(nearby.node.id);
44867                 } else {
44868                   graph = actionAddMidpoint({ loc, edge }, node)(graph);
44869                 }
44870               });
44871               if (nodesToMerge.length > 1) {
44872                 graph = actionMergeNodes(nodesToMerge, loc)(graph);
44873               }
44874               return graph;
44875             },
44876             _t("issues.fix.connect_crossing_features.annotation")
44877           );
44878         }
44879       });
44880       fix._connectionTags = connectionTags;
44881       return fix;
44882     }
44883     function makeChangeLayerFix(higherOrLower) {
44884       return new validationIssueFix({
44885         icon: "iD-icon-" + (higherOrLower === "higher" ? "up" : "down"),
44886         title: _t.append("issues.fix.tag_this_as_" + higherOrLower + ".title"),
44887         onClick: function(context2) {
44888           var mode = context2.mode();
44889           if (!mode || mode.id !== "select")
44890             return;
44891           var selectedIDs = mode.selectedIDs();
44892           if (selectedIDs.length !== 1)
44893             return;
44894           var selectedID = selectedIDs[0];
44895           if (!this.issue.entityIds.some(function(entityId) {
44896             return entityId === selectedID;
44897           }))
44898             return;
44899           var entity = context2.hasEntity(selectedID);
44900           if (!entity)
44901             return;
44902           var tags = Object.assign({}, entity.tags);
44903           var layer = tags.layer && Number(tags.layer);
44904           if (layer && !isNaN(layer)) {
44905             if (higherOrLower === "higher") {
44906               layer += 1;
44907             } else {
44908               layer -= 1;
44909             }
44910           } else {
44911             if (higherOrLower === "higher") {
44912               layer = 1;
44913             } else {
44914               layer = -1;
44915             }
44916           }
44917           tags.layer = layer.toString();
44918           context2.perform(
44919             actionChangeTags(entity.id, tags),
44920             _t("operations.change_tags.annotation")
44921           );
44922         }
44923       });
44924     }
44925     validation.type = type2;
44926     return validation;
44927   }
44928
44929   // modules/behavior/draw_way.js
44930   function behaviorDrawWay(context, wayID, mode, startGraph) {
44931     const keybinding = utilKeybinding("drawWay");
44932     var dispatch14 = dispatch_default("rejectedSelfIntersection");
44933     var behavior = behaviorDraw(context);
44934     var _nodeIndex;
44935     var _origWay;
44936     var _wayGeometry;
44937     var _headNodeID;
44938     var _annotation;
44939     var _pointerHasMoved = false;
44940     var _drawNode;
44941     var _didResolveTempEdit = false;
44942     function createDrawNode(loc) {
44943       _drawNode = osmNode({ loc });
44944       context.pauseChangeDispatch();
44945       context.replace(function actionAddDrawNode(graph) {
44946         var way = graph.entity(wayID);
44947         return graph.replace(_drawNode).replace(way.addNode(_drawNode.id, _nodeIndex));
44948       }, _annotation);
44949       context.resumeChangeDispatch();
44950       setActiveElements();
44951     }
44952     function removeDrawNode() {
44953       context.pauseChangeDispatch();
44954       context.replace(
44955         function actionDeleteDrawNode(graph) {
44956           var way = graph.entity(wayID);
44957           return graph.replace(way.removeNode(_drawNode.id)).remove(_drawNode);
44958         },
44959         _annotation
44960       );
44961       _drawNode = void 0;
44962       context.resumeChangeDispatch();
44963     }
44964     function keydown(d3_event) {
44965       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44966         if (context.surface().classed("nope")) {
44967           context.surface().classed("nope-suppressed", true);
44968         }
44969         context.surface().classed("nope", false).classed("nope-disabled", true);
44970       }
44971     }
44972     function keyup(d3_event) {
44973       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44974         if (context.surface().classed("nope-suppressed")) {
44975           context.surface().classed("nope", true);
44976         }
44977         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
44978       }
44979     }
44980     function allowsVertex(d2) {
44981       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
44982     }
44983     function move(d3_event, datum2) {
44984       var loc = context.map().mouseCoordinates();
44985       if (!_drawNode)
44986         createDrawNode(loc);
44987       context.surface().classed("nope-disabled", d3_event.altKey);
44988       var targetLoc = datum2 && datum2.properties && datum2.properties.entity && allowsVertex(datum2.properties.entity) && datum2.properties.entity.loc;
44989       var targetNodes = datum2 && datum2.properties && datum2.properties.nodes;
44990       if (targetLoc) {
44991         loc = targetLoc;
44992       } else if (targetNodes) {
44993         var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
44994         if (choice) {
44995           loc = choice.loc;
44996         }
44997       }
44998       context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
44999       _drawNode = context.entity(_drawNode.id);
45000       checkGeometry(
45001         true
45002         /* includeDrawNode */
45003       );
45004     }
45005     function checkGeometry(includeDrawNode) {
45006       var nopeDisabled = context.surface().classed("nope-disabled");
45007       var isInvalid = isInvalidGeometry(includeDrawNode);
45008       if (nopeDisabled) {
45009         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
45010       } else {
45011         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
45012       }
45013     }
45014     function isInvalidGeometry(includeDrawNode) {
45015       var testNode = _drawNode;
45016       var parentWay = context.graph().entity(wayID);
45017       var nodes = context.graph().childNodes(parentWay).slice();
45018       if (includeDrawNode) {
45019         if (parentWay.isClosed()) {
45020           nodes.pop();
45021         }
45022       } else {
45023         if (parentWay.isClosed()) {
45024           if (nodes.length < 3)
45025             return false;
45026           if (_drawNode)
45027             nodes.splice(-2, 1);
45028           testNode = nodes[nodes.length - 2];
45029         } else {
45030           return false;
45031         }
45032       }
45033       return testNode && geoHasSelfIntersections(nodes, testNode.id);
45034     }
45035     function undone() {
45036       _didResolveTempEdit = true;
45037       context.pauseChangeDispatch();
45038       var nextMode;
45039       if (context.graph() === startGraph) {
45040         nextMode = modeSelect(context, [wayID]);
45041       } else {
45042         context.pop(1);
45043         nextMode = mode;
45044       }
45045       context.perform(actionNoop());
45046       context.pop(1);
45047       context.resumeChangeDispatch();
45048       context.enter(nextMode);
45049     }
45050     function setActiveElements() {
45051       if (!_drawNode)
45052         return;
45053       context.surface().selectAll("." + _drawNode.id).classed("active", true);
45054     }
45055     function resetToStartGraph() {
45056       while (context.graph() !== startGraph) {
45057         context.pop();
45058       }
45059     }
45060     var drawWay = function(surface) {
45061       _drawNode = void 0;
45062       _didResolveTempEdit = false;
45063       _origWay = context.entity(wayID);
45064       if (typeof _nodeIndex === "number") {
45065         _headNodeID = _origWay.nodes[_nodeIndex];
45066       } else if (_origWay.isClosed()) {
45067         _headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
45068       } else {
45069         _headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
45070       }
45071       _wayGeometry = _origWay.geometry(context.graph());
45072       _annotation = _t(
45073         (_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ? "operations.start.annotation." : "operations.continue.annotation.") + _wayGeometry
45074       );
45075       _pointerHasMoved = false;
45076       context.pauseChangeDispatch();
45077       context.perform(actionNoop(), _annotation);
45078       context.resumeChangeDispatch();
45079       behavior.hover().initialNodeID(_headNodeID);
45080       behavior.on("move", function() {
45081         _pointerHasMoved = true;
45082         move.apply(this, arguments);
45083       }).on("down", function() {
45084         move.apply(this, arguments);
45085       }).on("downcancel", function() {
45086         if (_drawNode)
45087           removeDrawNode();
45088       }).on("click", drawWay.add).on("clickWay", drawWay.addWay).on("clickNode", drawWay.addNode).on("undo", context.undo).on("cancel", drawWay.cancel).on("finish", drawWay.finish);
45089       select_default2(window).on("keydown.drawWay", keydown).on("keyup.drawWay", keyup);
45090       context.map().dblclickZoomEnable(false).on("drawn.draw", setActiveElements);
45091       setActiveElements();
45092       surface.call(behavior);
45093       context.history().on("undone.draw", undone);
45094     };
45095     drawWay.off = function(surface) {
45096       if (!_didResolveTempEdit) {
45097         context.pauseChangeDispatch();
45098         resetToStartGraph();
45099         context.resumeChangeDispatch();
45100       }
45101       _drawNode = void 0;
45102       _nodeIndex = void 0;
45103       context.map().on("drawn.draw", null);
45104       surface.call(behavior.off).selectAll(".active").classed("active", false);
45105       surface.classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false);
45106       select_default2(window).on("keydown.drawWay", null).on("keyup.drawWay", null);
45107       context.history().on("undone.draw", null);
45108     };
45109     function attemptAdd(d2, loc, doAdd) {
45110       if (_drawNode) {
45111         context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
45112         _drawNode = context.entity(_drawNode.id);
45113       } else {
45114         createDrawNode(loc);
45115       }
45116       checkGeometry(
45117         true
45118         /* includeDrawNode */
45119       );
45120       if (d2 && d2.properties && d2.properties.nope || context.surface().classed("nope")) {
45121         if (!_pointerHasMoved) {
45122           removeDrawNode();
45123         }
45124         dispatch14.call("rejectedSelfIntersection", this);
45125         return;
45126       }
45127       context.pauseChangeDispatch();
45128       doAdd();
45129       _didResolveTempEdit = true;
45130       context.resumeChangeDispatch();
45131       context.enter(mode);
45132     }
45133     drawWay.add = function(loc, d2) {
45134       attemptAdd(d2, loc, function() {
45135       });
45136     };
45137     drawWay.addWay = function(loc, edge, d2) {
45138       attemptAdd(d2, loc, function() {
45139         context.replace(
45140           actionAddMidpoint({ loc, edge }, _drawNode),
45141           _annotation
45142         );
45143       });
45144     };
45145     drawWay.addNode = function(node, d2) {
45146       if (node.id === _headNodeID || // or the first node when drawing an area
45147       _origWay.isClosed() && node.id === _origWay.first()) {
45148         drawWay.finish();
45149         return;
45150       }
45151       attemptAdd(d2, node.loc, function() {
45152         context.replace(
45153           function actionReplaceDrawNode(graph) {
45154             graph = graph.replace(graph.entity(wayID).removeNode(_drawNode.id)).remove(_drawNode);
45155             return graph.replace(graph.entity(wayID).addNode(node.id, _nodeIndex));
45156           },
45157           _annotation
45158         );
45159       });
45160     };
45161     function getFeatureType(ways) {
45162       if (ways.every((way) => way.isClosed()))
45163         return "area";
45164       if (ways.every((way) => !way.isClosed()))
45165         return "line";
45166       return "generic";
45167     }
45168     function followMode() {
45169       if (_didResolveTempEdit)
45170         return;
45171       try {
45172         const isDrawingArea = _origWay.nodes[0] === _origWay.nodes.slice(-1)[0];
45173         const [secondLastNodeId, lastNodeId] = _origWay.nodes.slice(isDrawingArea ? -3 : -2);
45174         const historyGraph = context.history().graph();
45175         if (!lastNodeId || !secondLastNodeId || !historyGraph.hasEntity(lastNodeId) || !historyGraph.hasEntity(secondLastNodeId)) {
45176           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.needs_more_initial_nodes"))();
45177           return;
45178         }
45179         const lastNodesParents = historyGraph.parentWays(historyGraph.entity(lastNodeId)).filter((w2) => w2.id !== wayID);
45180         const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID);
45181         const featureType = getFeatureType(lastNodesParents);
45182         if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) {
45183           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))();
45184           return;
45185         }
45186         if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) {
45187           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))();
45188           return;
45189         }
45190         const way = lastNodesParents[0];
45191         const indexOfLast = way.nodes.indexOf(lastNodeId);
45192         const indexOfSecondLast = way.nodes.indexOf(secondLastNodeId);
45193         const isDescendingPastZero = indexOfLast === way.nodes.length - 2 && indexOfSecondLast === 0;
45194         let nextNodeIndex = indexOfLast + (indexOfLast > indexOfSecondLast && !isDescendingPastZero ? 1 : -1);
45195         if (nextNodeIndex === -1)
45196           nextNodeIndex = indexOfSecondLast === 1 ? way.nodes.length - 2 : 1;
45197         const nextNode = historyGraph.entity(way.nodes[nextNodeIndex]);
45198         drawWay.addNode(nextNode, {
45199           geometry: { type: "Point", coordinates: nextNode.loc },
45200           id: nextNode.id,
45201           properties: { target: true, entity: nextNode }
45202         });
45203       } catch {
45204         context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))();
45205       }
45206     }
45207     keybinding.on(_t("operations.follow.key"), followMode);
45208     select_default2(document).call(keybinding);
45209     drawWay.finish = function() {
45210       checkGeometry(
45211         false
45212         /* includeDrawNode */
45213       );
45214       if (context.surface().classed("nope")) {
45215         dispatch14.call("rejectedSelfIntersection", this);
45216         return;
45217       }
45218       context.pauseChangeDispatch();
45219       context.pop(1);
45220       _didResolveTempEdit = true;
45221       context.resumeChangeDispatch();
45222       var way = context.hasEntity(wayID);
45223       if (!way || way.isDegenerate()) {
45224         drawWay.cancel();
45225         return;
45226       }
45227       window.setTimeout(function() {
45228         context.map().dblclickZoomEnable(true);
45229       }, 1e3);
45230       var isNewFeature = !mode.isContinuing;
45231       context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature));
45232     };
45233     drawWay.cancel = function() {
45234       context.pauseChangeDispatch();
45235       resetToStartGraph();
45236       context.resumeChangeDispatch();
45237       window.setTimeout(function() {
45238         context.map().dblclickZoomEnable(true);
45239       }, 1e3);
45240       context.surface().classed("nope", false).classed("nope-disabled", false).classed("nope-suppressed", false);
45241       context.enter(modeBrowse(context));
45242     };
45243     drawWay.nodeIndex = function(val) {
45244       if (!arguments.length)
45245         return _nodeIndex;
45246       _nodeIndex = val;
45247       return drawWay;
45248     };
45249     drawWay.activeID = function() {
45250       if (!arguments.length)
45251         return _drawNode && _drawNode.id;
45252       return drawWay;
45253     };
45254     return utilRebind(drawWay, dispatch14, "on");
45255   }
45256
45257   // modules/modes/draw_line.js
45258   function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
45259     var mode = {
45260       button,
45261       id: "draw-line"
45262     };
45263     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawLine", function() {
45264       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.lines"))();
45265     });
45266     mode.wayID = wayID;
45267     mode.isContinuing = continuing;
45268     mode.enter = function() {
45269       behavior.nodeIndex(affix === "prefix" ? 0 : void 0);
45270       context.install(behavior);
45271     };
45272     mode.exit = function() {
45273       context.uninstall(behavior);
45274     };
45275     mode.selectedIDs = function() {
45276       return [wayID];
45277     };
45278     mode.activeID = function() {
45279       return behavior && behavior.activeID() || [];
45280     };
45281     return mode;
45282   }
45283
45284   // modules/validations/disconnected_way.js
45285   function validationDisconnectedWay() {
45286     var type2 = "disconnected_way";
45287     function isTaggedAsHighway(entity) {
45288       return osmRoutableHighwayTagValues[entity.tags.highway];
45289     }
45290     var validation = function checkDisconnectedWay(entity, graph) {
45291       var routingIslandWays = routingIslandForEntity(entity);
45292       if (!routingIslandWays)
45293         return [];
45294       return [new validationIssue({
45295         type: type2,
45296         subtype: "highway",
45297         severity: "warning",
45298         message: function(context) {
45299           var entity2 = this.entityIds.length && context.hasEntity(this.entityIds[0]);
45300           var label = entity2 && utilDisplayLabel(entity2, context.graph());
45301           return _t.append("issues.disconnected_way.routable.message", { count: this.entityIds.length, highway: label });
45302         },
45303         reference: showReference,
45304         entityIds: Array.from(routingIslandWays).map(function(way) {
45305           return way.id;
45306         }),
45307         dynamicFixes: makeFixes
45308       })];
45309       function makeFixes(context) {
45310         var fixes = [];
45311         var singleEntity = this.entityIds.length === 1 && context.hasEntity(this.entityIds[0]);
45312         if (singleEntity) {
45313           if (singleEntity.type === "way" && !singleEntity.isClosed()) {
45314             var textDirection = _mainLocalizer.textDirection();
45315             var startFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.first(), "start");
45316             if (startFix)
45317               fixes.push(startFix);
45318             var endFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.last(), "end");
45319             if (endFix)
45320               fixes.push(endFix);
45321           }
45322           if (!fixes.length) {
45323             fixes.push(new validationIssueFix({
45324               title: _t.append("issues.fix.connect_feature.title")
45325             }));
45326           }
45327           fixes.push(new validationIssueFix({
45328             icon: "iD-operation-delete",
45329             title: _t.append("issues.fix.delete_feature.title"),
45330             entityIds: [singleEntity.id],
45331             onClick: function(context2) {
45332               var id2 = this.issue.entityIds[0];
45333               var operation2 = operationDelete(context2, [id2]);
45334               if (!operation2.disabled()) {
45335                 operation2();
45336               }
45337             }
45338           }));
45339         } else {
45340           fixes.push(new validationIssueFix({
45341             title: _t.append("issues.fix.connect_features.title")
45342           }));
45343         }
45344         return fixes;
45345       }
45346       function showReference(selection2) {
45347         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.disconnected_way.routable.reference"));
45348       }
45349       function routingIslandForEntity(entity2) {
45350         var routingIsland = /* @__PURE__ */ new Set();
45351         var waysToCheck = [];
45352         function queueParentWays(node) {
45353           graph.parentWays(node).forEach(function(parentWay) {
45354             if (!routingIsland.has(parentWay) && // only check each feature once
45355             isRoutableWay(parentWay, false)) {
45356               routingIsland.add(parentWay);
45357               waysToCheck.push(parentWay);
45358             }
45359           });
45360         }
45361         if (entity2.type === "way" && isRoutableWay(entity2, true)) {
45362           routingIsland.add(entity2);
45363           waysToCheck.push(entity2);
45364         } else if (entity2.type === "node" && isRoutableNode(entity2)) {
45365           routingIsland.add(entity2);
45366           queueParentWays(entity2);
45367         } else {
45368           return null;
45369         }
45370         while (waysToCheck.length) {
45371           var wayToCheck = waysToCheck.pop();
45372           var childNodes = graph.childNodes(wayToCheck);
45373           for (var i3 in childNodes) {
45374             var vertex = childNodes[i3];
45375             if (isConnectedVertex(vertex)) {
45376               return null;
45377             }
45378             if (isRoutableNode(vertex)) {
45379               routingIsland.add(vertex);
45380             }
45381             queueParentWays(vertex);
45382           }
45383         }
45384         return routingIsland;
45385       }
45386       function isConnectedVertex(vertex) {
45387         var osm = services.osm;
45388         if (osm && !osm.isDataLoaded(vertex.loc))
45389           return true;
45390         if (vertex.tags.entrance && vertex.tags.entrance !== "no")
45391           return true;
45392         if (vertex.tags.amenity === "parking_entrance")
45393           return true;
45394         return false;
45395       }
45396       function isRoutableNode(node) {
45397         if (node.tags.highway === "elevator")
45398           return true;
45399         return false;
45400       }
45401       function isRoutableWay(way, ignoreInnerWays) {
45402         if (isTaggedAsHighway(way) || way.tags.route === "ferry")
45403           return true;
45404         return graph.parentRelations(way).some(function(parentRelation) {
45405           if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45406             return true;
45407           if (parentRelation.isMultipolygon() && isTaggedAsHighway(parentRelation) && (!ignoreInnerWays || parentRelation.memberById(way.id).role !== "inner"))
45408             return true;
45409           return false;
45410         });
45411       }
45412       function makeContinueDrawingFixIfAllowed(textDirection, vertexID, whichEnd) {
45413         var vertex = graph.hasEntity(vertexID);
45414         if (!vertex || vertex.tags.noexit === "yes")
45415           return null;
45416         var useLeftContinue = whichEnd === "start" && textDirection === "ltr" || whichEnd === "end" && textDirection === "rtl";
45417         return new validationIssueFix({
45418           icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45419           title: _t.append("issues.fix.continue_from_" + whichEnd + ".title"),
45420           entityIds: [vertexID],
45421           onClick: function(context) {
45422             var wayId = this.issue.entityIds[0];
45423             var way = context.hasEntity(wayId);
45424             var vertexId = this.entityIds[0];
45425             var vertex2 = context.hasEntity(vertexId);
45426             if (!way || !vertex2)
45427               return;
45428             var map2 = context.map();
45429             if (!context.editable() || !map2.trimmedExtent().contains(vertex2.loc)) {
45430               map2.zoomToEase(vertex2);
45431             }
45432             context.enter(
45433               modeDrawLine(context, wayId, context.graph(), "line", way.affix(vertexId), true)
45434             );
45435           }
45436         });
45437       }
45438     };
45439     validation.type = type2;
45440     return validation;
45441   }
45442
45443   // modules/validations/invalid_format.js
45444   function validationFormatting() {
45445     var type2 = "invalid_format";
45446     var validation = function(entity) {
45447       var issues = [];
45448       function isValidEmail(email) {
45449         var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
45450         return !email || valid_email.test(email);
45451       }
45452       function showReferenceEmail(selection2) {
45453         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.invalid_format.email.reference"));
45454       }
45455       if (entity.tags.email) {
45456         var emails = entity.tags.email.split(";").map(function(s2) {
45457           return s2.trim();
45458         }).filter(function(x2) {
45459           return !isValidEmail(x2);
45460         });
45461         if (emails.length) {
45462           issues.push(new validationIssue({
45463             type: type2,
45464             subtype: "email",
45465             severity: "warning",
45466             message: function(context) {
45467               var entity2 = context.hasEntity(this.entityIds[0]);
45468               return entity2 ? _t.append(
45469                 "issues.invalid_format.email.message" + this.data,
45470                 { feature: utilDisplayLabel(entity2, context.graph()), email: emails.join(", ") }
45471               ) : "";
45472             },
45473             reference: showReferenceEmail,
45474             entityIds: [entity.id],
45475             hash: emails.join(),
45476             data: emails.length > 1 ? "_multi" : ""
45477           }));
45478         }
45479       }
45480       return issues;
45481     };
45482     validation.type = type2;
45483     return validation;
45484   }
45485
45486   // modules/validations/help_request.js
45487   function validationHelpRequest(context) {
45488     var type2 = "help_request";
45489     var validation = function checkFixmeTag(entity) {
45490       if (!entity.tags.fixme)
45491         return [];
45492       if (entity.version === void 0)
45493         return [];
45494       if (entity.v !== void 0) {
45495         var baseEntity = context.history().base().hasEntity(entity.id);
45496         if (!baseEntity || !baseEntity.tags.fixme)
45497           return [];
45498       }
45499       return [new validationIssue({
45500         type: type2,
45501         subtype: "fixme_tag",
45502         severity: "warning",
45503         message: function(context2) {
45504           var entity2 = context2.hasEntity(this.entityIds[0]);
45505           return entity2 ? _t.append("issues.fixme_tag.message", {
45506             feature: utilDisplayLabel(
45507               entity2,
45508               context2.graph(),
45509               true
45510               /* verbose */
45511             )
45512           }) : "";
45513         },
45514         dynamicFixes: function() {
45515           return [
45516             new validationIssueFix({
45517               title: _t.append("issues.fix.address_the_concern.title")
45518             })
45519           ];
45520         },
45521         reference: showReference,
45522         entityIds: [entity.id]
45523       })];
45524       function showReference(selection2) {
45525         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.fixme_tag.reference"));
45526       }
45527     };
45528     validation.type = type2;
45529     return validation;
45530   }
45531
45532   // modules/validations/impossible_oneway.js
45533   function validationImpossibleOneway() {
45534     var type2 = "impossible_oneway";
45535     var validation = function checkImpossibleOneway(entity, graph) {
45536       if (entity.type !== "way" || entity.geometry(graph) !== "line")
45537         return [];
45538       if (entity.isClosed())
45539         return [];
45540       if (!typeForWay(entity))
45541         return [];
45542       if (!isOneway(entity))
45543         return [];
45544       var firstIssues = issuesForNode(entity, entity.first());
45545       var lastIssues = issuesForNode(entity, entity.last());
45546       return firstIssues.concat(lastIssues);
45547       function typeForWay(way) {
45548         if (way.geometry(graph) !== "line")
45549           return null;
45550         if (osmRoutableHighwayTagValues[way.tags.highway])
45551           return "highway";
45552         if (osmFlowingWaterwayTagValues[way.tags.waterway])
45553           return "waterway";
45554         return null;
45555       }
45556       function isOneway(way) {
45557         if (way.tags.oneway === "yes")
45558           return true;
45559         if (way.tags.oneway)
45560           return false;
45561         for (var key in way.tags) {
45562           if (osmOneWayTags[key] && osmOneWayTags[key][way.tags[key]]) {
45563             return true;
45564           }
45565         }
45566         return false;
45567       }
45568       function nodeOccursMoreThanOnce(way, nodeID) {
45569         var occurrences = 0;
45570         for (var index in way.nodes) {
45571           if (way.nodes[index] === nodeID) {
45572             occurrences += 1;
45573             if (occurrences > 1)
45574               return true;
45575           }
45576         }
45577         return false;
45578       }
45579       function isConnectedViaOtherTypes(way, node) {
45580         var wayType = typeForWay(way);
45581         if (wayType === "highway") {
45582           if (node.tags.entrance && node.tags.entrance !== "no")
45583             return true;
45584           if (node.tags.amenity === "parking_entrance")
45585             return true;
45586         } else if (wayType === "waterway") {
45587           if (node.id === way.first()) {
45588             if (node.tags.natural === "spring")
45589               return true;
45590           } else {
45591             if (node.tags.manhole === "drain")
45592               return true;
45593           }
45594         }
45595         return graph.parentWays(node).some(function(parentWay) {
45596           if (parentWay.id === way.id)
45597             return false;
45598           if (wayType === "highway") {
45599             if (parentWay.geometry(graph) === "area" && osmRoutableHighwayTagValues[parentWay.tags.highway])
45600               return true;
45601             if (parentWay.tags.route === "ferry")
45602               return true;
45603             return graph.parentRelations(parentWay).some(function(parentRelation) {
45604               if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45605                 return true;
45606               return parentRelation.isMultipolygon() && osmRoutableHighwayTagValues[parentRelation.tags.highway];
45607             });
45608           } else if (wayType === "waterway") {
45609             if (parentWay.tags.natural === "water" || parentWay.tags.natural === "coastline")
45610               return true;
45611           }
45612           return false;
45613         });
45614       }
45615       function issuesForNode(way, nodeID) {
45616         var isFirst = nodeID === way.first();
45617         var wayType = typeForWay(way);
45618         if (nodeOccursMoreThanOnce(way, nodeID))
45619           return [];
45620         var osm = services.osm;
45621         if (!osm)
45622           return [];
45623         var node = graph.hasEntity(nodeID);
45624         if (!node || !osm.isDataLoaded(node.loc))
45625           return [];
45626         if (isConnectedViaOtherTypes(way, node))
45627           return [];
45628         var attachedWaysOfSameType = graph.parentWays(node).filter(function(parentWay) {
45629           if (parentWay.id === way.id)
45630             return false;
45631           return typeForWay(parentWay) === wayType;
45632         });
45633         if (wayType === "waterway" && attachedWaysOfSameType.length === 0)
45634           return [];
45635         var attachedOneways = attachedWaysOfSameType.filter(function(attachedWay) {
45636           return isOneway(attachedWay);
45637         });
45638         if (attachedOneways.length < attachedWaysOfSameType.length)
45639           return [];
45640         if (attachedOneways.length) {
45641           var connectedEndpointsOkay = attachedOneways.some(function(attachedOneway) {
45642             if ((isFirst ? attachedOneway.first() : attachedOneway.last()) !== nodeID)
45643               return true;
45644             if (nodeOccursMoreThanOnce(attachedOneway, nodeID))
45645               return true;
45646             return false;
45647           });
45648           if (connectedEndpointsOkay)
45649             return [];
45650         }
45651         var placement = isFirst ? "start" : "end", messageID = wayType + ".", referenceID = wayType + ".";
45652         if (wayType === "waterway") {
45653           messageID += "connected." + placement;
45654           referenceID += "connected";
45655         } else {
45656           messageID += placement;
45657           referenceID += placement;
45658         }
45659         return [new validationIssue({
45660           type: type2,
45661           subtype: wayType,
45662           severity: "warning",
45663           message: function(context) {
45664             var entity2 = context.hasEntity(this.entityIds[0]);
45665             return entity2 ? _t.append("issues.impossible_oneway." + messageID + ".message", {
45666               feature: utilDisplayLabel(entity2, context.graph())
45667             }) : "";
45668           },
45669           reference: getReference(referenceID),
45670           entityIds: [way.id, node.id],
45671           dynamicFixes: function() {
45672             var fixes = [];
45673             if (attachedOneways.length) {
45674               fixes.push(new validationIssueFix({
45675                 icon: "iD-operation-reverse",
45676                 title: _t.append("issues.fix.reverse_feature.title"),
45677                 entityIds: [way.id],
45678                 onClick: function(context) {
45679                   var id2 = this.issue.entityIds[0];
45680                   context.perform(actionReverse(id2), _t("operations.reverse.annotation.line", { n: 1 }));
45681                 }
45682               }));
45683             }
45684             if (node.tags.noexit !== "yes") {
45685               var textDirection = _mainLocalizer.textDirection();
45686               var useLeftContinue = isFirst && textDirection === "ltr" || !isFirst && textDirection === "rtl";
45687               fixes.push(new validationIssueFix({
45688                 icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45689                 title: _t.append("issues.fix.continue_from_" + (isFirst ? "start" : "end") + ".title"),
45690                 onClick: function(context) {
45691                   var entityID = this.issue.entityIds[0];
45692                   var vertexID = this.issue.entityIds[1];
45693                   var way2 = context.entity(entityID);
45694                   var vertex = context.entity(vertexID);
45695                   continueDrawing(way2, vertex, context);
45696                 }
45697               }));
45698             }
45699             return fixes;
45700           },
45701           loc: node.loc
45702         })];
45703         function getReference(referenceID2) {
45704           return function showReference(selection2) {
45705             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.impossible_oneway." + referenceID2 + ".reference"));
45706           };
45707         }
45708       }
45709     };
45710     function continueDrawing(way, vertex, context) {
45711       var map2 = context.map();
45712       if (!context.editable() || !map2.trimmedExtent().contains(vertex.loc)) {
45713         map2.zoomToEase(vertex);
45714       }
45715       context.enter(
45716         modeDrawLine(context, way.id, context.graph(), "line", way.affix(vertex.id), true)
45717       );
45718     }
45719     validation.type = type2;
45720     return validation;
45721   }
45722
45723   // modules/validations/incompatible_source.js
45724   function validationIncompatibleSource() {
45725     const type2 = "incompatible_source";
45726     const incompatibleRules = [
45727       {
45728         id: "amap",
45729         regex: /(^amap$|^amap\.com|autonavi|mapabc|高德)/i
45730       },
45731       {
45732         id: "baidu",
45733         regex: /(baidu|mapbar|百度)/i
45734       },
45735       {
45736         id: "google",
45737         regex: /google/i,
45738         exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))|(esri\/Google_Africa_Buildings)/i
45739       }
45740     ];
45741     const validation = function checkIncompatibleSource(entity) {
45742       const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(";");
45743       if (!entitySources)
45744         return [];
45745       const entityID = entity.id;
45746       return entitySources.map((source) => {
45747         const matchRule = incompatibleRules.find((rule) => {
45748           if (!rule.regex.test(source))
45749             return false;
45750           if (rule.exceptRegex && rule.exceptRegex.test(source))
45751             return false;
45752           return true;
45753         });
45754         if (!matchRule)
45755           return null;
45756         return new validationIssue({
45757           type: type2,
45758           severity: "warning",
45759           message: (context) => {
45760             const entity2 = context.hasEntity(entityID);
45761             return entity2 ? _t.append("issues.incompatible_source.feature.message", {
45762               feature: utilDisplayLabel(
45763                 entity2,
45764                 context.graph(),
45765                 true
45766                 /* verbose */
45767               ),
45768               value: source
45769             }) : "";
45770           },
45771           reference: getReference(matchRule.id),
45772           entityIds: [entityID],
45773           hash: source,
45774           dynamicFixes: () => {
45775             return [
45776               new validationIssueFix({ title: _t.append("issues.fix.remove_proprietary_data.title") })
45777             ];
45778           }
45779         });
45780       }).filter(Boolean);
45781       function getReference(id2) {
45782         return function showReference(selection2) {
45783           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2)));
45784         };
45785       }
45786     };
45787     validation.type = type2;
45788     return validation;
45789   }
45790
45791   // modules/validations/maprules.js
45792   function validationMaprules() {
45793     var type2 = "maprules";
45794     var validation = function checkMaprules(entity, graph) {
45795       if (!services.maprules)
45796         return [];
45797       var rules = services.maprules.validationRules();
45798       var issues = [];
45799       for (var i3 = 0; i3 < rules.length; i3++) {
45800         var rule = rules[i3];
45801         rule.findIssues(entity, graph, issues);
45802       }
45803       return issues;
45804     };
45805     validation.type = type2;
45806     return validation;
45807   }
45808
45809   // modules/validations/mismatched_geometry.js
45810   var import_fast_deep_equal4 = __toESM(require_fast_deep_equal());
45811   function validationMismatchedGeometry() {
45812     var type2 = "mismatched_geometry";
45813     function tagSuggestingLineIsArea(entity) {
45814       if (entity.type !== "way" || entity.isClosed())
45815         return null;
45816       var tagSuggestingArea = entity.tagSuggestingArea();
45817       if (!tagSuggestingArea) {
45818         return null;
45819       }
45820       var asLine = _mainPresetIndex.matchTags(tagSuggestingArea, "line");
45821       var asArea = _mainPresetIndex.matchTags(tagSuggestingArea, "area");
45822       if (asLine && asArea && (0, import_fast_deep_equal4.default)(asLine.tags, asArea.tags)) {
45823         return null;
45824       }
45825       return tagSuggestingArea;
45826     }
45827     function makeConnectEndpointsFixOnClick(way, graph) {
45828       if (way.nodes.length < 3)
45829         return null;
45830       var nodes = graph.childNodes(way), testNodes;
45831       var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length - 1].loc);
45832       if (firstToLastDistanceMeters < 0.75) {
45833         testNodes = nodes.slice();
45834         testNodes.pop();
45835         testNodes.push(testNodes[0]);
45836         if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45837           return function(context) {
45838             var way2 = context.entity(this.issue.entityIds[0]);
45839             context.perform(
45840               actionMergeNodes([way2.nodes[0], way2.nodes[way2.nodes.length - 1]], nodes[0].loc),
45841               _t("issues.fix.connect_endpoints.annotation")
45842             );
45843           };
45844         }
45845       }
45846       testNodes = nodes.slice();
45847       testNodes.push(testNodes[0]);
45848       if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45849         return function(context) {
45850           var wayId = this.issue.entityIds[0];
45851           var way2 = context.entity(wayId);
45852           var nodeId = way2.nodes[0];
45853           var index = way2.nodes.length;
45854           context.perform(
45855             actionAddVertex(wayId, nodeId, index),
45856             _t("issues.fix.connect_endpoints.annotation")
45857           );
45858         };
45859       }
45860     }
45861     function lineTaggedAsAreaIssue(entity) {
45862       var tagSuggestingArea = tagSuggestingLineIsArea(entity);
45863       if (!tagSuggestingArea)
45864         return null;
45865       var validAsLine = false;
45866       var presetAsLine = _mainPresetIndex.matchTags(entity.tags, "line");
45867       if (presetAsLine) {
45868         validAsLine = true;
45869         var key = Object.keys(tagSuggestingArea)[0];
45870         if (presetAsLine.tags[key] && presetAsLine.tags[key] === "*") {
45871           validAsLine = false;
45872         }
45873         if (Object.keys(presetAsLine.tags).length === 0) {
45874           validAsLine = false;
45875         }
45876       }
45877       return new validationIssue({
45878         type: type2,
45879         subtype: "area_as_line",
45880         severity: "warning",
45881         message: function(context) {
45882           var entity2 = context.hasEntity(this.entityIds[0]);
45883           return entity2 ? _t.append("issues.tag_suggests_area.message", {
45884             feature: utilDisplayLabel(
45885               entity2,
45886               "area",
45887               true
45888               /* verbose */
45889             ),
45890             tag: utilTagText({ tags: tagSuggestingArea })
45891           }) : "";
45892         },
45893         reference: showReference,
45894         entityIds: [entity.id],
45895         hash: JSON.stringify(tagSuggestingArea),
45896         dynamicFixes: function(context) {
45897           var fixes = [];
45898           var entity2 = context.entity(this.entityIds[0]);
45899           var connectEndsOnClick = makeConnectEndpointsFixOnClick(entity2, context.graph());
45900           if (!validAsLine) {
45901             fixes.push(new validationIssueFix({
45902               title: _t.append("issues.fix.connect_endpoints.title"),
45903               onClick: connectEndsOnClick
45904             }));
45905           }
45906           fixes.push(new validationIssueFix({
45907             icon: "iD-operation-delete",
45908             title: _t.append("issues.fix.remove_tag.title"),
45909             onClick: function(context2) {
45910               var entityId = this.issue.entityIds[0];
45911               var entity3 = context2.entity(entityId);
45912               var tags = Object.assign({}, entity3.tags);
45913               for (var key2 in tagSuggestingArea) {
45914                 delete tags[key2];
45915               }
45916               context2.perform(
45917                 actionChangeTags(entityId, tags),
45918                 _t("issues.fix.remove_tag.annotation")
45919               );
45920             }
45921           }));
45922           return fixes;
45923         }
45924       });
45925       function showReference(selection2) {
45926         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.tag_suggests_area.reference"));
45927       }
45928     }
45929     function vertexPointIssue(entity, graph) {
45930       if (entity.type !== "node")
45931         return null;
45932       if (Object.keys(entity.tags).length === 0)
45933         return null;
45934       if (entity.isOnAddressLine(graph))
45935         return null;
45936       var geometry = entity.geometry(graph);
45937       var allowedGeometries = osmNodeGeometriesForTags(entity.tags);
45938       if (geometry === "point" && !allowedGeometries.point && allowedGeometries.vertex) {
45939         return new validationIssue({
45940           type: type2,
45941           subtype: "vertex_as_point",
45942           severity: "warning",
45943           message: function(context) {
45944             var entity2 = context.hasEntity(this.entityIds[0]);
45945             return entity2 ? _t.append("issues.vertex_as_point.message", {
45946               feature: utilDisplayLabel(
45947                 entity2,
45948                 "vertex",
45949                 true
45950                 /* verbose */
45951               )
45952             }) : "";
45953           },
45954           reference: function showReference(selection2) {
45955             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.vertex_as_point.reference"));
45956           },
45957           entityIds: [entity.id]
45958         });
45959       } else if (geometry === "vertex" && !allowedGeometries.vertex && allowedGeometries.point) {
45960         return new validationIssue({
45961           type: type2,
45962           subtype: "point_as_vertex",
45963           severity: "warning",
45964           message: function(context) {
45965             var entity2 = context.hasEntity(this.entityIds[0]);
45966             return entity2 ? _t.append("issues.point_as_vertex.message", {
45967               feature: utilDisplayLabel(
45968                 entity2,
45969                 "point",
45970                 true
45971                 /* verbose */
45972               )
45973             }) : "";
45974           },
45975           reference: function showReference(selection2) {
45976             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.point_as_vertex.reference"));
45977           },
45978           entityIds: [entity.id],
45979           dynamicFixes: extractPointDynamicFixes
45980         });
45981       }
45982       return null;
45983     }
45984     function otherMismatchIssue(entity, graph) {
45985       if (!entity.hasInterestingTags())
45986         return null;
45987       if (entity.type !== "node" && entity.type !== "way")
45988         return null;
45989       if (entity.type === "node" && entity.isOnAddressLine(graph))
45990         return null;
45991       var sourceGeom = entity.geometry(graph);
45992       var targetGeoms = entity.type === "way" ? ["point", "vertex"] : ["line", "area"];
45993       if (sourceGeom === "area")
45994         targetGeoms.unshift("line");
45995       var asSource = _mainPresetIndex.match(entity, graph);
45996       var targetGeom = targetGeoms.find((nodeGeom) => {
45997         var asTarget = _mainPresetIndex.matchTags(entity.tags, nodeGeom);
45998         if (!asSource || !asTarget || asSource === asTarget || // sometimes there are two presets with the same tags for different geometries
45999         (0, import_fast_deep_equal4.default)(asSource.tags, asTarget.tags))
46000           return false;
46001         if (asTarget.isFallback())
46002           return false;
46003         var primaryKey = Object.keys(asTarget.tags)[0];
46004         if (primaryKey === "building")
46005           return false;
46006         if (asTarget.tags[primaryKey] === "*")
46007           return false;
46008         return asSource.isFallback() || asSource.tags[primaryKey] === "*";
46009       });
46010       if (!targetGeom)
46011         return null;
46012       var subtype = targetGeom + "_as_" + sourceGeom;
46013       if (targetGeom === "vertex")
46014         targetGeom = "point";
46015       if (sourceGeom === "vertex")
46016         sourceGeom = "point";
46017       var referenceId = targetGeom + "_as_" + sourceGeom;
46018       var dynamicFixes;
46019       if (targetGeom === "point") {
46020         dynamicFixes = extractPointDynamicFixes;
46021       } else if (sourceGeom === "area" && targetGeom === "line") {
46022         dynamicFixes = lineToAreaDynamicFixes;
46023       }
46024       return new validationIssue({
46025         type: type2,
46026         subtype,
46027         severity: "warning",
46028         message: function(context) {
46029           var entity2 = context.hasEntity(this.entityIds[0]);
46030           return entity2 ? _t.append("issues." + referenceId + ".message", {
46031             feature: utilDisplayLabel(
46032               entity2,
46033               targetGeom,
46034               true
46035               /* verbose */
46036             )
46037           }) : "";
46038         },
46039         reference: function showReference(selection2) {
46040           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.mismatched_geometry.reference"));
46041         },
46042         entityIds: [entity.id],
46043         dynamicFixes
46044       });
46045     }
46046     function lineToAreaDynamicFixes(context) {
46047       var convertOnClick;
46048       var entityId = this.entityIds[0];
46049       var entity = context.entity(entityId);
46050       var tags = Object.assign({}, entity.tags);
46051       delete tags.area;
46052       if (!osmTagSuggestingArea(tags)) {
46053         convertOnClick = function(context2) {
46054           var entityId2 = this.issue.entityIds[0];
46055           var entity2 = context2.entity(entityId2);
46056           var tags2 = Object.assign({}, entity2.tags);
46057           if (tags2.area) {
46058             delete tags2.area;
46059           }
46060           context2.perform(
46061             actionChangeTags(entityId2, tags2),
46062             _t("issues.fix.convert_to_line.annotation")
46063           );
46064         };
46065       }
46066       return [
46067         new validationIssueFix({
46068           icon: "iD-icon-line",
46069           title: _t.append("issues.fix.convert_to_line.title"),
46070           onClick: convertOnClick
46071         })
46072       ];
46073     }
46074     function extractPointDynamicFixes(context) {
46075       var entityId = this.entityIds[0];
46076       var extractOnClick = null;
46077       if (!context.hasHiddenConnections(entityId)) {
46078         extractOnClick = function(context2) {
46079           var entityId2 = this.issue.entityIds[0];
46080           var action = actionExtract(entityId2, context2.projection);
46081           context2.perform(
46082             action,
46083             _t("operations.extract.annotation", { n: 1 })
46084           );
46085           context2.enter(modeSelect(context2, [action.getExtractedNodeID()]));
46086         };
46087       }
46088       return [
46089         new validationIssueFix({
46090           icon: "iD-operation-extract",
46091           title: _t.append("issues.fix.extract_point.title"),
46092           onClick: extractOnClick
46093         })
46094       ];
46095     }
46096     function unclosedMultipolygonPartIssues(entity, graph) {
46097       if (entity.type !== "relation" || !entity.isMultipolygon() || entity.isDegenerate() || // cannot determine issues for incompletely-downloaded relations
46098       !entity.isComplete(graph))
46099         return [];
46100       var sequences = osmJoinWays(entity.members, graph);
46101       var issues = [];
46102       for (var i3 in sequences) {
46103         var sequence = sequences[i3];
46104         if (!sequence.nodes)
46105           continue;
46106         var firstNode = sequence.nodes[0];
46107         var lastNode = sequence.nodes[sequence.nodes.length - 1];
46108         if (firstNode === lastNode)
46109           continue;
46110         var issue = new validationIssue({
46111           type: type2,
46112           subtype: "unclosed_multipolygon_part",
46113           severity: "warning",
46114           message: function(context) {
46115             var entity2 = context.hasEntity(this.entityIds[0]);
46116             return entity2 ? _t.append("issues.unclosed_multipolygon_part.message", {
46117               feature: utilDisplayLabel(
46118                 entity2,
46119                 context.graph(),
46120                 true
46121                 /* verbose */
46122               )
46123             }) : "";
46124           },
46125           reference: showReference,
46126           loc: sequence.nodes[0].loc,
46127           entityIds: [entity.id],
46128           hash: sequence.map(function(way) {
46129             return way.id;
46130           }).join()
46131         });
46132         issues.push(issue);
46133       }
46134       return issues;
46135       function showReference(selection2) {
46136         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unclosed_multipolygon_part.reference"));
46137       }
46138     }
46139     var validation = function checkMismatchedGeometry(entity, graph) {
46140       var vertexPoint = vertexPointIssue(entity, graph);
46141       if (vertexPoint)
46142         return [vertexPoint];
46143       var lineAsArea = lineTaggedAsAreaIssue(entity);
46144       if (lineAsArea)
46145         return [lineAsArea];
46146       var mismatch = otherMismatchIssue(entity, graph);
46147       if (mismatch)
46148         return [mismatch];
46149       return unclosedMultipolygonPartIssues(entity, graph);
46150     };
46151     validation.type = type2;
46152     return validation;
46153   }
46154
46155   // modules/validations/missing_role.js
46156   function validationMissingRole() {
46157     var type2 = "missing_role";
46158     var validation = function checkMissingRole(entity, graph) {
46159       var issues = [];
46160       if (entity.type === "way") {
46161         graph.parentRelations(entity).forEach(function(relation) {
46162           if (!relation.isMultipolygon())
46163             return;
46164           var member = relation.memberById(entity.id);
46165           if (member && isMissingRole(member)) {
46166             issues.push(makeIssue(entity, relation, member));
46167           }
46168         });
46169       } else if (entity.type === "relation" && entity.isMultipolygon()) {
46170         entity.indexedMembers().forEach(function(member) {
46171           var way = graph.hasEntity(member.id);
46172           if (way && isMissingRole(member)) {
46173             issues.push(makeIssue(way, entity, member));
46174           }
46175         });
46176       }
46177       return issues;
46178     };
46179     function isMissingRole(member) {
46180       return !member.role || !member.role.trim().length;
46181     }
46182     function makeIssue(way, relation, member) {
46183       return new validationIssue({
46184         type: type2,
46185         severity: "warning",
46186         message: function(context) {
46187           var member2 = context.hasEntity(this.entityIds[1]), relation2 = context.hasEntity(this.entityIds[0]);
46188           return member2 && relation2 ? _t.append("issues.missing_role.message", {
46189             member: utilDisplayLabel(member2, context.graph()),
46190             relation: utilDisplayLabel(relation2, context.graph())
46191           }) : "";
46192         },
46193         reference: showReference,
46194         entityIds: [relation.id, way.id],
46195         data: {
46196           member
46197         },
46198         hash: member.index.toString(),
46199         dynamicFixes: function() {
46200           return [
46201             makeAddRoleFix("inner"),
46202             makeAddRoleFix("outer"),
46203             new validationIssueFix({
46204               icon: "iD-operation-delete",
46205               title: _t.append("issues.fix.remove_from_relation.title"),
46206               onClick: function(context) {
46207                 context.perform(
46208                   actionDeleteMember(this.issue.entityIds[0], this.issue.data.member.index),
46209                   _t("operations.delete_member.annotation", {
46210                     n: 1
46211                   })
46212                 );
46213               }
46214             })
46215           ];
46216         }
46217       });
46218       function showReference(selection2) {
46219         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.missing_role.multipolygon.reference"));
46220       }
46221     }
46222     function makeAddRoleFix(role) {
46223       return new validationIssueFix({
46224         title: _t.append("issues.fix.set_as_" + role + ".title"),
46225         onClick: function(context) {
46226           var oldMember = this.issue.data.member;
46227           var member = { id: this.issue.entityIds[1], type: oldMember.type, role };
46228           context.perform(
46229             actionChangeMember(this.issue.entityIds[0], member, oldMember.index),
46230             _t("operations.change_role.annotation", {
46231               n: 1
46232             })
46233           );
46234         }
46235       });
46236     }
46237     validation.type = type2;
46238     return validation;
46239   }
46240
46241   // modules/validations/missing_tag.js
46242   function validationMissingTag(context) {
46243     var type2 = "missing_tag";
46244     function hasDescriptiveTags(entity) {
46245       var onlyAttributeKeys = ["description", "name", "note", "start_date"];
46246       var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) {
46247         if (k2 === "area" || !osmIsInterestingTag(k2))
46248           return false;
46249         return !onlyAttributeKeys.some(function(attributeKey) {
46250           return k2 === attributeKey || k2.indexOf(attributeKey + ":") === 0;
46251         });
46252       });
46253       if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") {
46254         return false;
46255       }
46256       return entityDescriptiveKeys.length > 0;
46257     }
46258     function isUnknownRoad(entity) {
46259       return entity.type === "way" && entity.tags.highway === "road";
46260     }
46261     function isUntypedRelation(entity) {
46262       return entity.type === "relation" && !entity.tags.type;
46263     }
46264     var validation = function checkMissingTag(entity, graph) {
46265       var subtype;
46266       var osm = context.connection();
46267       var isUnloadedNode = entity.type === "node" && osm && !osm.isDataLoaded(entity.loc);
46268       if (!isUnloadedNode && // allow untagged nodes that are part of ways
46269       entity.geometry(graph) !== "vertex" && // allow untagged entities that are part of relations
46270       !entity.hasParentRelations(graph)) {
46271         if (Object.keys(entity.tags).length === 0) {
46272           subtype = "any";
46273         } else if (!hasDescriptiveTags(entity)) {
46274           subtype = "descriptive";
46275         } else if (isUntypedRelation(entity)) {
46276           subtype = "relation_type";
46277         }
46278       }
46279       if (!subtype && isUnknownRoad(entity)) {
46280         subtype = "highway_classification";
46281       }
46282       if (!subtype)
46283         return [];
46284       var messageID = subtype === "highway_classification" ? "unknown_road" : "missing_tag." + subtype;
46285       var referenceID = subtype === "highway_classification" ? "unknown_road" : "missing_tag";
46286       var canDelete = entity.version === void 0 || entity.v !== void 0;
46287       var severity = canDelete && subtype !== "highway_classification" ? "error" : "warning";
46288       return [new validationIssue({
46289         type: type2,
46290         subtype,
46291         severity,
46292         message: function(context2) {
46293           var entity2 = context2.hasEntity(this.entityIds[0]);
46294           return entity2 ? _t.append("issues." + messageID + ".message", {
46295             feature: utilDisplayLabel(entity2, context2.graph())
46296           }) : "";
46297         },
46298         reference: showReference,
46299         entityIds: [entity.id],
46300         dynamicFixes: function(context2) {
46301           var fixes = [];
46302           var selectFixType = subtype === "highway_classification" ? "select_road_type" : "select_preset";
46303           fixes.push(new validationIssueFix({
46304             icon: "iD-icon-search",
46305             title: _t.append("issues.fix." + selectFixType + ".title"),
46306             onClick: function(context3) {
46307               context3.ui().sidebar.showPresetList();
46308             }
46309           }));
46310           var deleteOnClick;
46311           var id2 = this.entityIds[0];
46312           var operation2 = operationDelete(context2, [id2]);
46313           var disabledReasonID = operation2.disabled();
46314           if (!disabledReasonID) {
46315             deleteOnClick = function(context3) {
46316               var id3 = this.issue.entityIds[0];
46317               var operation3 = operationDelete(context3, [id3]);
46318               if (!operation3.disabled()) {
46319                 operation3();
46320               }
46321             };
46322           }
46323           fixes.push(
46324             new validationIssueFix({
46325               icon: "iD-operation-delete",
46326               title: _t.append("issues.fix.delete_feature.title"),
46327               disabledReason: disabledReasonID ? _t("operations.delete." + disabledReasonID + ".single") : void 0,
46328               onClick: deleteOnClick
46329             })
46330           );
46331           return fixes;
46332         }
46333       })];
46334       function showReference(selection2) {
46335         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues." + referenceID + ".reference"));
46336       }
46337     };
46338     validation.type = type2;
46339     return validation;
46340   }
46341
46342   // modules/validations/mutually_exclusive_tags.js
46343   function validationMutuallyExclusiveTags() {
46344     const type2 = "mutually_exclusive_tags";
46345     const tagKeyPairs = osmMutuallyExclusiveTagPairs;
46346     const validation = function checkMutuallyExclusiveTags(entity) {
46347       let pairsFounds = tagKeyPairs.filter((pair3) => {
46348         return pair3[0] in entity.tags && pair3[1] in entity.tags;
46349       }).filter((pair3) => {
46350         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");
46351       });
46352       Object.keys(entity.tags).forEach((key) => {
46353         let negative_key = "not:" + key;
46354         if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46355           pairsFounds.push([negative_key, key, "same_value"]);
46356         }
46357         if (key.match(/^name:[a-z]+/)) {
46358           negative_key = "not:name";
46359           if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46360             pairsFounds.push([negative_key, key, "same_value"]);
46361           }
46362         }
46363       });
46364       let issues = pairsFounds.map((pair3) => {
46365         const subtype = pair3[2] || "default";
46366         return new validationIssue({
46367           type: type2,
46368           subtype,
46369           severity: "warning",
46370           message: function(context) {
46371             let entity2 = context.hasEntity(this.entityIds[0]);
46372             return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), {
46373               feature: utilDisplayLabel(entity2, context.graph()),
46374               tag1: pair3[0],
46375               tag2: pair3[1]
46376             }) : "";
46377           },
46378           reference: (selection2) => showReference(selection2, pair3, subtype),
46379           entityIds: [entity.id],
46380           dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove))
46381         });
46382       });
46383       function createIssueFix(tagToRemove) {
46384         return new validationIssueFix({
46385           icon: "iD-operation-delete",
46386           title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }),
46387           onClick: function(context) {
46388             const entityId = this.issue.entityIds[0];
46389             const entity2 = context.entity(entityId);
46390             let tags = Object.assign({}, entity2.tags);
46391             delete tags[tagToRemove];
46392             context.perform(
46393               actionChangeTags(entityId, tags),
46394               _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove })
46395             );
46396           }
46397         });
46398       }
46399       function showReference(selection2, pair3, subtype) {
46400         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] }));
46401       }
46402       return issues;
46403     };
46404     validation.type = type2;
46405     return validation;
46406   }
46407
46408   // modules/validations/outdated_tags.js
46409   function validationOutdatedTags() {
46410     const type2 = "outdated_tags";
46411     let _waitingForDeprecated = true;
46412     let _dataDeprecated;
46413     _mainFileFetcher.get("deprecated").then((d2) => _dataDeprecated = d2).catch(() => {
46414     }).finally(() => _waitingForDeprecated = false);
46415     function oldTagIssues(entity, graph) {
46416       if (!entity.hasInterestingTags())
46417         return [];
46418       let preset = _mainPresetIndex.match(entity, graph);
46419       if (!preset)
46420         return [];
46421       const oldTags = Object.assign({}, entity.tags);
46422       let subtype = "deprecated_tags";
46423       if (preset.replacement) {
46424         const newPreset = _mainPresetIndex.item(preset.replacement);
46425         graph = actionChangePreset(
46426           entity.id,
46427           preset,
46428           newPreset,
46429           true
46430           /* skip field defaults */
46431         )(graph);
46432         entity = graph.entity(entity.id);
46433         preset = newPreset;
46434       }
46435       const upgradeReasons = [];
46436       if (_dataDeprecated) {
46437         const deprecatedTags = entity.deprecatedTags(_dataDeprecated);
46438         if (entity.type === "way" && entity.isClosed() && entity.tags.traffic_calming === "island" && !entity.tags.highway) {
46439           deprecatedTags.push({
46440             old: { traffic_calming: "island" },
46441             replace: { "area:highway": "traffic_island" }
46442           });
46443         }
46444         if (deprecatedTags.length) {
46445           deprecatedTags.forEach((tag2) => {
46446             graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph);
46447             upgradeReasons.push({
46448               source: "id-tagging-schema--deprecated",
46449               data: tag2
46450             });
46451           });
46452           entity = graph.entity(entity.id);
46453         }
46454       }
46455       let newTags = Object.assign({}, entity.tags);
46456       if (preset.tags !== preset.addTags) {
46457         Object.keys(preset.addTags).forEach((k2) => {
46458           if (!newTags[k2]) {
46459             if (preset.addTags[k2] === "*") {
46460               newTags[k2] = "yes";
46461             } else if (preset.addTags[k2]) {
46462               newTags[k2] = preset.addTags[k2];
46463             }
46464             upgradeReasons.push({
46465               source: "id-tagging-schema--preset-addTags",
46466               data: preset
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             upgradeReasons.push({
46483               source: "name-suggestion-index",
46484               data: nsiResult
46485             });
46486           }
46487         }
46488       }
46489       let issues = [];
46490       issues.provisional = _waitingForDeprecated || waitingForNsi;
46491       const tagDiff = utilTagDiff(oldTags, newTags);
46492       if (!tagDiff.length)
46493         return issues;
46494       const isOnlyAddingTags = tagDiff.every((d2) => d2.type === "+");
46495       let prefix = "";
46496       if (nsiResult) {
46497         prefix = "noncanonical_brand.";
46498       } else if (subtype === "deprecated_tags" && isOnlyAddingTags) {
46499         subtype = "incomplete_tags";
46500         prefix = "incomplete.";
46501       }
46502       let autoArgs = subtype !== "noncanonical_brand" ? [doUpgrade, _t("issues.fix.upgrade_tags.annotation")] : null;
46503       issues.push(new validationIssue({
46504         type: type2,
46505         subtype,
46506         severity: "warning",
46507         message: showMessage,
46508         reference: showReference,
46509         entityIds: [entity.id],
46510         hash: utilHashcode(JSON.stringify(tagDiff)),
46511         dynamicFixes: () => {
46512           let fixes = [
46513             new validationIssueFix({
46514               autoArgs,
46515               title: _t.append("issues.fix.upgrade_tags.title"),
46516               onClick: (context) => {
46517                 context.perform(doUpgrade, _t("issues.fix.upgrade_tags.annotation"));
46518               }
46519             })
46520           ];
46521           const item = nsiResult && nsiResult.matched;
46522           if (item) {
46523             fixes.push(
46524               new validationIssueFix({
46525                 title: _t.append("issues.fix.tag_as_not.title", { name: item.displayName }),
46526                 onClick: (context) => {
46527                   context.perform(addNotTag, _t("issues.fix.tag_as_not.annotation"));
46528                 }
46529               })
46530             );
46531           }
46532           return fixes;
46533         }
46534       }));
46535       return issues;
46536       function doUpgrade(graph2) {
46537         const currEntity = graph2.hasEntity(entity.id);
46538         if (!currEntity)
46539           return graph2;
46540         let newTags2 = Object.assign({}, currEntity.tags);
46541         tagDiff.forEach((diff) => {
46542           if (diff.type === "-") {
46543             delete newTags2[diff.key];
46544           } else if (diff.type === "+") {
46545             newTags2[diff.key] = diff.newVal;
46546           }
46547         });
46548         return actionChangeTags(currEntity.id, newTags2)(graph2);
46549       }
46550       function addNotTag(graph2) {
46551         const currEntity = graph2.hasEntity(entity.id);
46552         if (!currEntity)
46553           return graph2;
46554         const item = nsiResult && nsiResult.matched;
46555         if (!item)
46556           return graph2;
46557         let newTags2 = Object.assign({}, currEntity.tags);
46558         const wd = item.mainTag;
46559         const notwd = "not:".concat(wd);
46560         const qid = item.tags[wd];
46561         newTags2[notwd] = qid;
46562         if (newTags2[wd] === qid) {
46563           const wp = item.mainTag.replace("wikidata", "wikipedia");
46564           delete newTags2[wd];
46565           delete newTags2[wp];
46566         }
46567         return actionChangeTags(currEntity.id, newTags2)(graph2);
46568       }
46569       function showMessage(context) {
46570         const currEntity = context.hasEntity(entity.id);
46571         if (!currEntity)
46572           return "";
46573         let messageID = "issues.outdated_tags.".concat(prefix, "message");
46574         if (subtype === "noncanonical_brand" && isOnlyAddingTags) {
46575           messageID += "_incomplete";
46576         }
46577         return _t.append(messageID, {
46578           feature: utilDisplayLabel(
46579             currEntity,
46580             context.graph(),
46581             true
46582             /* verbose */
46583           )
46584         });
46585       }
46586       function showReference(selection2) {
46587         let enter = selection2.selectAll(".issue-reference").data([0]).enter();
46588         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.outdated_tags.".concat(prefix, "reference")));
46589         enter.append("strong").call(_t.append("issues.suggested"));
46590         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => {
46591           let klass = d2.type === "+" ? "add" : "remove";
46592           return "tagDiff-cell tagDiff-cell-".concat(klass);
46593         }).html((d2) => d2.display);
46594       }
46595     }
46596     let validation = oldTagIssues;
46597     validation.type = type2;
46598     return validation;
46599   }
46600
46601   // modules/validations/private_data.js
46602   function validationPrivateData() {
46603     var type2 = "private_data";
46604     var privateBuildingValues = {
46605       detached: true,
46606       farm: true,
46607       house: true,
46608       houseboat: true,
46609       residential: true,
46610       semidetached_house: true,
46611       static_caravan: true
46612     };
46613     var publicKeys = {
46614       amenity: true,
46615       craft: true,
46616       historic: true,
46617       leisure: true,
46618       office: true,
46619       shop: true,
46620       tourism: true
46621     };
46622     var personalTags = {
46623       "contact:email": true,
46624       "contact:fax": true,
46625       "contact:phone": true,
46626       email: true,
46627       fax: true,
46628       phone: true
46629     };
46630     var validation = function checkPrivateData(entity) {
46631       var tags = entity.tags;
46632       if (!tags.building || !privateBuildingValues[tags.building])
46633         return [];
46634       var keepTags = {};
46635       for (var k2 in tags) {
46636         if (publicKeys[k2])
46637           return [];
46638         if (!personalTags[k2]) {
46639           keepTags[k2] = tags[k2];
46640         }
46641       }
46642       var tagDiff = utilTagDiff(tags, keepTags);
46643       if (!tagDiff.length)
46644         return [];
46645       var fixID = tagDiff.length === 1 ? "remove_tag" : "remove_tags";
46646       return [new validationIssue({
46647         type: type2,
46648         severity: "warning",
46649         message: showMessage,
46650         reference: showReference,
46651         entityIds: [entity.id],
46652         dynamicFixes: function() {
46653           return [
46654             new validationIssueFix({
46655               icon: "iD-operation-delete",
46656               title: _t.append("issues.fix." + fixID + ".title"),
46657               onClick: function(context) {
46658                 context.perform(doUpgrade, _t("issues.fix.remove_tag.annotation"));
46659               }
46660             })
46661           ];
46662         }
46663       })];
46664       function doUpgrade(graph) {
46665         var currEntity = graph.hasEntity(entity.id);
46666         if (!currEntity)
46667           return graph;
46668         var newTags = Object.assign({}, currEntity.tags);
46669         tagDiff.forEach(function(diff) {
46670           if (diff.type === "-") {
46671             delete newTags[diff.key];
46672           } else if (diff.type === "+") {
46673             newTags[diff.key] = diff.newVal;
46674           }
46675         });
46676         return actionChangeTags(currEntity.id, newTags)(graph);
46677       }
46678       function showMessage(context) {
46679         var currEntity = context.hasEntity(this.entityIds[0]);
46680         if (!currEntity)
46681           return "";
46682         return _t.append(
46683           "issues.private_data.contact.message",
46684           { feature: utilDisplayLabel(currEntity, context.graph()) }
46685         );
46686       }
46687       function showReference(selection2) {
46688         var enter = selection2.selectAll(".issue-reference").data([0]).enter();
46689         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.private_data.reference"));
46690         enter.append("strong").call(_t.append("issues.suggested"));
46691         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) {
46692           var klass = d2.type === "+" ? "add" : "remove";
46693           return "tagDiff-cell tagDiff-cell-" + klass;
46694         }).html(function(d2) {
46695           return d2.display;
46696         });
46697       }
46698     };
46699     validation.type = type2;
46700     return validation;
46701   }
46702
46703   // modules/validations/suspicious_name.js
46704   function validationSuspiciousName() {
46705     const type2 = "suspicious_name";
46706     const keysToTestForGenericValues = [
46707       "aerialway",
46708       "aeroway",
46709       "amenity",
46710       "building",
46711       "craft",
46712       "highway",
46713       "leisure",
46714       "railway",
46715       "man_made",
46716       "office",
46717       "shop",
46718       "tourism",
46719       "waterway"
46720     ];
46721     let _waitingForNsi = false;
46722     function isGenericMatchInNsi(tags) {
46723       const nsi = services.nsi;
46724       if (nsi) {
46725         _waitingForNsi = nsi.status() === "loading";
46726         if (!_waitingForNsi) {
46727           return nsi.isGenericName(tags);
46728         }
46729       }
46730       return false;
46731     }
46732     function nameMatchesRawTag(lowercaseName, tags) {
46733       for (let i3 = 0; i3 < keysToTestForGenericValues.length; i3++) {
46734         let key = keysToTestForGenericValues[i3];
46735         let val = tags[key];
46736         if (val) {
46737           val = val.toLowerCase();
46738           if (key === lowercaseName || val === lowercaseName || key.replace(/\_/g, " ") === lowercaseName || val.replace(/\_/g, " ") === lowercaseName) {
46739             return true;
46740           }
46741         }
46742       }
46743       return false;
46744     }
46745     function isGenericName(name, tags) {
46746       name = name.toLowerCase();
46747       return nameMatchesRawTag(name, tags) || isGenericMatchInNsi(tags);
46748     }
46749     function makeGenericNameIssue(entityId, nameKey, genericName, langCode) {
46750       return new validationIssue({
46751         type: type2,
46752         subtype: "generic_name",
46753         severity: "warning",
46754         message: function(context) {
46755           let entity = context.hasEntity(this.entityIds[0]);
46756           if (!entity)
46757             return "";
46758           let preset = _mainPresetIndex.match(entity, context.graph());
46759           let langName = langCode && _mainLocalizer.languageName(langCode);
46760           return _t.append(
46761             "issues.generic_name.message" + (langName ? "_language" : ""),
46762             { feature: preset.name(), name: genericName, language: langName }
46763           );
46764         },
46765         reference: showReference,
46766         entityIds: [entityId],
46767         hash: "".concat(nameKey, "=").concat(genericName),
46768         dynamicFixes: function() {
46769           return [
46770             new validationIssueFix({
46771               icon: "iD-operation-delete",
46772               title: _t.append("issues.fix.remove_the_name.title"),
46773               onClick: function(context) {
46774                 let entityId2 = this.issue.entityIds[0];
46775                 let entity = context.entity(entityId2);
46776                 let tags = Object.assign({}, entity.tags);
46777                 delete tags[nameKey];
46778                 context.perform(
46779                   actionChangeTags(entityId2, tags),
46780                   _t("issues.fix.remove_generic_name.annotation")
46781                 );
46782               }
46783             })
46784           ];
46785         }
46786       });
46787       function showReference(selection2) {
46788         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference"));
46789       }
46790     }
46791     let validation = function checkGenericName(entity) {
46792       const tags = entity.tags;
46793       const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"];
46794       if (hasWikidata)
46795         return [];
46796       let issues = [];
46797       for (let key in tags) {
46798         const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/);
46799         if (!m2)
46800           continue;
46801         const langCode = m2.length >= 2 ? m2[1] : null;
46802         const value = tags[key];
46803         if (isGenericName(value, tags)) {
46804           issues.provisional = _waitingForNsi;
46805           issues.push(makeGenericNameIssue(entity.id, key, value, langCode));
46806         }
46807       }
46808       return issues;
46809     };
46810     validation.type = type2;
46811     return validation;
46812   }
46813
46814   // modules/validations/unsquare_way.js
46815   function validationUnsquareWay(context) {
46816     var type2 = "unsquare_way";
46817     var DEFAULT_DEG_THRESHOLD = 5;
46818     var epsilon3 = 0.05;
46819     var nodeThreshold = 10;
46820     function isBuilding(entity, graph) {
46821       if (entity.type !== "way" || entity.geometry(graph) !== "area")
46822         return false;
46823       return entity.tags.building && entity.tags.building !== "no";
46824     }
46825     var validation = function checkUnsquareWay(entity, graph) {
46826       if (!isBuilding(entity, graph))
46827         return [];
46828       if (entity.tags.nonsquare === "yes")
46829         return [];
46830       var isClosed = entity.isClosed();
46831       if (!isClosed)
46832         return [];
46833       var nodes = graph.childNodes(entity).slice();
46834       if (nodes.length > nodeThreshold + 1)
46835         return [];
46836       var osm = services.osm;
46837       if (!osm || nodes.some(function(node) {
46838         return !osm.isDataLoaded(node.loc);
46839       }))
46840         return [];
46841       var hasConnectedSquarableWays = nodes.some(function(node) {
46842         return graph.parentWays(node).some(function(way) {
46843           if (way.id === entity.id)
46844             return false;
46845           if (isBuilding(way, graph))
46846             return true;
46847           return graph.parentRelations(way).some(function(parentRelation) {
46848             return parentRelation.isMultipolygon() && parentRelation.tags.building && parentRelation.tags.building !== "no";
46849           });
46850         });
46851       });
46852       if (hasConnectedSquarableWays)
46853         return [];
46854       var storedDegreeThreshold = corePreferences("validate-square-degrees");
46855       var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD;
46856       var points = nodes.map(function(node) {
46857         return context.projection(node.loc);
46858       });
46859       if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon3, degreeThreshold, true))
46860         return [];
46861       var autoArgs;
46862       if (!entity.tags.wikidata) {
46863         var autoAction = actionOrthogonalize(entity.id, context.projection, void 0, degreeThreshold);
46864         autoAction.transitionable = false;
46865         autoArgs = [autoAction, _t("operations.orthogonalize.annotation.feature", { n: 1 })];
46866       }
46867       return [new validationIssue({
46868         type: type2,
46869         subtype: "building",
46870         severity: "warning",
46871         message: function(context2) {
46872           var entity2 = context2.hasEntity(this.entityIds[0]);
46873           return entity2 ? _t.append("issues.unsquare_way.message", {
46874             feature: utilDisplayLabel(entity2, context2.graph())
46875           }) : "";
46876         },
46877         reference: showReference,
46878         entityIds: [entity.id],
46879         hash: degreeThreshold,
46880         dynamicFixes: function() {
46881           return [
46882             new validationIssueFix({
46883               icon: "iD-operation-orthogonalize",
46884               title: _t.append("issues.fix.square_feature.title"),
46885               autoArgs,
46886               onClick: function(context2, completionHandler) {
46887                 var entityId = this.issue.entityIds[0];
46888                 context2.perform(
46889                   actionOrthogonalize(entityId, context2.projection, void 0, degreeThreshold),
46890                   _t("operations.orthogonalize.annotation.feature", { n: 1 })
46891                 );
46892                 window.setTimeout(function() {
46893                   completionHandler();
46894                 }, 175);
46895               }
46896             })
46897             /*
46898             new validationIssueFix({
46899                 title: t.append('issues.fix.tag_as_unsquare.title'),
46900                 onClick: function(context) {
46901                     var entityId = this.issue.entityIds[0];
46902                     var entity = context.entity(entityId);
46903                     var tags = Object.assign({}, entity.tags);  // shallow copy
46904                     tags.nonsquare = 'yes';
46905                     context.perform(
46906                         actionChangeTags(entityId, tags),
46907                         t('issues.fix.tag_as_unsquare.annotation')
46908                     );
46909                 }
46910             })
46911             */
46912           ];
46913         }
46914       })];
46915       function showReference(selection2) {
46916         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unsquare_way.buildings.reference"));
46917       }
46918     };
46919     validation.type = type2;
46920     return validation;
46921   }
46922
46923   // modules/core/validator.js
46924   function coreValidator(context) {
46925     let dispatch14 = dispatch_default("validated", "focusedIssue");
46926     let validator = utilRebind({}, dispatch14, "on");
46927     let _rules = {};
46928     let _disabledRules = {};
46929     let _ignoredIssueIDs = /* @__PURE__ */ new Set();
46930     let _resolvedIssueIDs = /* @__PURE__ */ new Set();
46931     let _baseCache = validationCache("base");
46932     let _headCache = validationCache("head");
46933     let _completeDiff = {};
46934     let _headIsCurrent = false;
46935     let _deferredRIC = {};
46936     let _deferredST = /* @__PURE__ */ new Set();
46937     let _headPromise;
46938     const RETRY = 5e3;
46939     const _errorOverrides = parseHashParam(context.initialHashParams.validationError);
46940     const _warningOverrides = parseHashParam(context.initialHashParams.validationWarning);
46941     const _disableOverrides = parseHashParam(context.initialHashParams.validationDisable);
46942     function parseHashParam(param) {
46943       let result = [];
46944       let rules = (param || "").split(",");
46945       rules.forEach((rule) => {
46946         rule = rule.trim();
46947         const parts = rule.split("/", 2);
46948         const type2 = parts[0];
46949         const subtype = parts[1] || "*";
46950         if (!type2 || !subtype)
46951           return;
46952         result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) });
46953       });
46954       return result;
46955       function makeRegExp(str) {
46956         const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
46957         return new RegExp("^" + escaped + "$");
46958       }
46959     }
46960     validator.init = () => {
46961       Object.values(validations_exports).forEach((validation) => {
46962         if (typeof validation !== "function")
46963           return;
46964         const fn = validation(context);
46965         const key = fn.type;
46966         _rules[key] = fn;
46967       });
46968       let disabledRules = corePreferences("validate-disabledRules");
46969       if (disabledRules) {
46970         disabledRules.split(",").forEach((k2) => _disabledRules[k2] = true);
46971       }
46972     };
46973     function reset(resetIgnored) {
46974       _baseCache.queue = [];
46975       _headCache.queue = [];
46976       Object.keys(_deferredRIC).forEach((key) => {
46977         window.cancelIdleCallback(key);
46978         _deferredRIC[key]();
46979       });
46980       _deferredRIC = {};
46981       _deferredST.forEach(window.clearTimeout);
46982       _deferredST.clear();
46983       if (resetIgnored)
46984         _ignoredIssueIDs.clear();
46985       _resolvedIssueIDs.clear();
46986       _baseCache = validationCache("base");
46987       _headCache = validationCache("head");
46988       _completeDiff = {};
46989       _headIsCurrent = false;
46990     }
46991     validator.reset = () => {
46992       reset(true);
46993     };
46994     validator.resetIgnoredIssues = () => {
46995       _ignoredIssueIDs.clear();
46996       dispatch14.call("validated");
46997     };
46998     validator.revalidateUnsquare = () => {
46999       revalidateUnsquare(_headCache);
47000       revalidateUnsquare(_baseCache);
47001       dispatch14.call("validated");
47002     };
47003     function revalidateUnsquare(cache) {
47004       const checkUnsquareWay = _rules.unsquare_way;
47005       if (!cache.graph || typeof checkUnsquareWay !== "function")
47006         return;
47007       cache.uncacheIssuesOfType("unsquare_way");
47008       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");
47009       buildings.forEach((entity) => {
47010         const detected = checkUnsquareWay(entity, cache.graph);
47011         if (!detected.length)
47012           return;
47013         cache.cacheIssues(detected);
47014       });
47015     }
47016     validator.getIssues = (options2) => {
47017       const opts = Object.assign({ what: "all", where: "all", includeIgnored: false, includeDisabledRules: false }, options2);
47018       const view = context.map().extent();
47019       let seen = /* @__PURE__ */ new Set();
47020       let results = [];
47021       if (_headCache.graph && _headCache.graph !== _baseCache.graph) {
47022         Object.values(_headCache.issuesByIssueID).forEach((issue) => {
47023           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47024           if (opts.what === "edited" && !userModified)
47025             return;
47026           if (!filter2(issue))
47027             return;
47028           seen.add(issue.id);
47029           results.push(issue);
47030         });
47031       }
47032       if (opts.what === "all") {
47033         Object.values(_baseCache.issuesByIssueID).forEach((issue) => {
47034           if (!filter2(issue))
47035             return;
47036           seen.add(issue.id);
47037           results.push(issue);
47038         });
47039       }
47040       return results;
47041       function filter2(issue) {
47042         if (!issue)
47043           return false;
47044         if (seen.has(issue.id))
47045           return false;
47046         if (_resolvedIssueIDs.has(issue.id))
47047           return false;
47048         if (opts.includeDisabledRules === "only" && !_disabledRules[issue.type])
47049           return false;
47050         if (!opts.includeDisabledRules && _disabledRules[issue.type])
47051           return false;
47052         if (opts.includeIgnored === "only" && !_ignoredIssueIDs.has(issue.id))
47053           return false;
47054         if (!opts.includeIgnored && _ignoredIssueIDs.has(issue.id))
47055           return false;
47056         if ((issue.entityIds || []).some((id2) => !context.hasEntity(id2)))
47057           return false;
47058         if (opts.where === "visible") {
47059           const extent = issue.extent(context.graph());
47060           if (!view.intersects(extent))
47061             return false;
47062         }
47063         return true;
47064       }
47065     };
47066     validator.getResolvedIssues = () => {
47067       return Array.from(_resolvedIssueIDs).map((issueID) => _baseCache.issuesByIssueID[issueID]).filter(Boolean);
47068     };
47069     validator.focusIssue = (issue) => {
47070       const graph = context.graph();
47071       let selectID;
47072       let focusCenter;
47073       const issueExtent = issue.extent(graph);
47074       if (issueExtent) {
47075         focusCenter = issueExtent.center();
47076       }
47077       if (issue.entityIds && issue.entityIds.length) {
47078         selectID = issue.entityIds[0];
47079         if (selectID && selectID.charAt(0) === "r") {
47080           const ids = utilEntityAndDeepMemberIDs([selectID], graph);
47081           let nodeID = ids.find((id2) => id2.charAt(0) === "n" && graph.hasEntity(id2));
47082           if (!nodeID) {
47083             const wayID = ids.find((id2) => id2.charAt(0) === "w" && graph.hasEntity(id2));
47084             if (wayID) {
47085               nodeID = graph.entity(wayID).first();
47086             }
47087           }
47088           if (nodeID) {
47089             focusCenter = graph.entity(nodeID).loc;
47090           }
47091         }
47092       }
47093       if (focusCenter) {
47094         const setZoom = Math.max(context.map().zoom(), 19);
47095         context.map().unobscuredCenterZoomEase(focusCenter, setZoom);
47096       }
47097       if (selectID) {
47098         window.setTimeout(() => {
47099           context.enter(modeSelect(context, [selectID]));
47100           dispatch14.call("focusedIssue", this, issue);
47101         }, 250);
47102       }
47103     };
47104     validator.getIssuesBySeverity = (options2) => {
47105       let groups = utilArrayGroupBy(validator.getIssues(options2), "severity");
47106       groups.error = groups.error || [];
47107       groups.warning = groups.warning || [];
47108       return groups;
47109     };
47110     validator.getSharedEntityIssues = (entityIDs, options2) => {
47111       const orderedIssueTypes = [
47112         // Show some issue types in a particular order:
47113         "missing_tag",
47114         "missing_role",
47115         // - missing data first
47116         "outdated_tags",
47117         "mismatched_geometry",
47118         // - identity issues
47119         "crossing_ways",
47120         "almost_junction",
47121         // - geometry issues where fixing them might solve connectivity issues
47122         "disconnected_way",
47123         "impossible_oneway"
47124         // - finally connectivity issues
47125       ];
47126       const allIssues = validator.getIssues(options2);
47127       const forEntityIDs = new Set(entityIDs);
47128       return allIssues.filter((issue) => (issue.entityIds || []).some((entityID) => forEntityIDs.has(entityID))).sort((issue1, issue2) => {
47129         if (issue1.type === issue2.type) {
47130           return issue1.id < issue2.id ? -1 : 1;
47131         }
47132         const index1 = orderedIssueTypes.indexOf(issue1.type);
47133         const index2 = orderedIssueTypes.indexOf(issue2.type);
47134         if (index1 !== -1 && index2 !== -1) {
47135           return index1 - index2;
47136         } else if (index1 === -1 && index2 === -1) {
47137           return issue1.type < issue2.type ? -1 : 1;
47138         } else {
47139           return index1 !== -1 ? -1 : 1;
47140         }
47141       });
47142     };
47143     validator.getEntityIssues = (entityID, options2) => {
47144       return validator.getSharedEntityIssues([entityID], options2);
47145     };
47146     validator.getRuleKeys = () => {
47147       return Object.keys(_rules);
47148     };
47149     validator.isRuleEnabled = (key) => {
47150       return !_disabledRules[key];
47151     };
47152     validator.toggleRule = (key) => {
47153       if (_disabledRules[key]) {
47154         delete _disabledRules[key];
47155       } else {
47156         _disabledRules[key] = true;
47157       }
47158       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47159       validator.validate();
47160     };
47161     validator.disableRules = (keys2) => {
47162       _disabledRules = {};
47163       keys2.forEach((k2) => _disabledRules[k2] = true);
47164       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47165       validator.validate();
47166     };
47167     validator.ignoreIssue = (issueID) => {
47168       _ignoredIssueIDs.add(issueID);
47169     };
47170     validator.validate = () => {
47171       const baseGraph = context.history().base();
47172       if (!_headCache.graph)
47173         _headCache.graph = baseGraph;
47174       if (!_baseCache.graph)
47175         _baseCache.graph = baseGraph;
47176       const prevGraph = _headCache.graph;
47177       const currGraph = context.graph();
47178       if (currGraph === prevGraph) {
47179         _headIsCurrent = true;
47180         dispatch14.call("validated");
47181         return Promise.resolve();
47182       }
47183       if (_headPromise) {
47184         _headIsCurrent = false;
47185         return _headPromise;
47186       }
47187       _headCache.graph = currGraph;
47188       _completeDiff = context.history().difference().complete();
47189       const incrementalDiff = coreDifference(prevGraph, currGraph);
47190       let entityIDs = Object.keys(incrementalDiff.complete());
47191       entityIDs = _headCache.withAllRelatedEntities(entityIDs);
47192       if (!entityIDs.size) {
47193         dispatch14.call("validated");
47194         return Promise.resolve();
47195       }
47196       _headPromise = validateEntitiesAsync(entityIDs, _headCache).then(() => updateResolvedIssues(entityIDs)).then(() => dispatch14.call("validated")).catch(() => {
47197       }).then(() => {
47198         _headPromise = null;
47199         if (!_headIsCurrent) {
47200           validator.validate();
47201         }
47202       });
47203       return _headPromise;
47204     };
47205     context.history().on("restore.validator", validator.validate).on("undone.validator", validator.validate).on("redone.validator", validator.validate).on("reset.validator", () => {
47206       reset(false);
47207       validator.validate();
47208     });
47209     context.on("exit.validator", validator.validate);
47210     context.history().on("merge.validator", (entities) => {
47211       if (!entities)
47212         return;
47213       const baseGraph = context.history().base();
47214       if (!_headCache.graph)
47215         _headCache.graph = baseGraph;
47216       if (!_baseCache.graph)
47217         _baseCache.graph = baseGraph;
47218       let entityIDs = entities.map((entity) => entity.id);
47219       entityIDs = _baseCache.withAllRelatedEntities(entityIDs);
47220       validateEntitiesAsync(entityIDs, _baseCache);
47221     });
47222     function validateEntity(entity, graph) {
47223       let result = { issues: [], provisional: false };
47224       Object.keys(_rules).forEach(runValidation);
47225       return result;
47226       function runValidation(key) {
47227         const fn = _rules[key];
47228         if (typeof fn !== "function") {
47229           console.error("no such validation rule = " + key);
47230           return;
47231         }
47232         let detected = fn(entity, graph);
47233         if (detected.provisional) {
47234           result.provisional = true;
47235         }
47236         detected = detected.filter(applySeverityOverrides);
47237         result.issues = result.issues.concat(detected);
47238         function applySeverityOverrides(issue) {
47239           const type2 = issue.type;
47240           const subtype = issue.subtype || "";
47241           let i3;
47242           for (i3 = 0; i3 < _errorOverrides.length; i3++) {
47243             if (_errorOverrides[i3].type.test(type2) && _errorOverrides[i3].subtype.test(subtype)) {
47244               issue.severity = "error";
47245               return true;
47246             }
47247           }
47248           for (i3 = 0; i3 < _warningOverrides.length; i3++) {
47249             if (_warningOverrides[i3].type.test(type2) && _warningOverrides[i3].subtype.test(subtype)) {
47250               issue.severity = "warning";
47251               return true;
47252             }
47253           }
47254           for (i3 = 0; i3 < _disableOverrides.length; i3++) {
47255             if (_disableOverrides[i3].type.test(type2) && _disableOverrides[i3].subtype.test(subtype)) {
47256               return false;
47257             }
47258           }
47259           return true;
47260         }
47261       }
47262     }
47263     function updateResolvedIssues(entityIDs) {
47264       entityIDs.forEach((entityID) => {
47265         const baseIssues = _baseCache.issuesByEntityID[entityID];
47266         if (!baseIssues)
47267           return;
47268         baseIssues.forEach((issueID) => {
47269           const issue = _baseCache.issuesByIssueID[issueID];
47270           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47271           if (userModified && !_headCache.issuesByIssueID[issueID]) {
47272             _resolvedIssueIDs.add(issueID);
47273           } else {
47274             _resolvedIssueIDs.delete(issueID);
47275           }
47276         });
47277       });
47278     }
47279     function validateEntitiesAsync(entityIDs, cache) {
47280       const jobs = Array.from(entityIDs).map((entityID) => {
47281         if (cache.queuedEntityIDs.has(entityID))
47282           return null;
47283         cache.queuedEntityIDs.add(entityID);
47284         cache.uncacheEntityID(entityID);
47285         return () => {
47286           cache.queuedEntityIDs.delete(entityID);
47287           const graph = cache.graph;
47288           if (!graph)
47289             return;
47290           const entity = graph.hasEntity(entityID);
47291           if (!entity)
47292             return;
47293           const result = validateEntity(entity, graph);
47294           if (result.provisional) {
47295             cache.provisionalEntityIDs.add(entityID);
47296           }
47297           cache.cacheIssues(result.issues);
47298         };
47299       }).filter(Boolean);
47300       cache.queue = cache.queue.concat(utilArrayChunk(jobs, 100));
47301       if (cache.queuePromise)
47302         return cache.queuePromise;
47303       cache.queuePromise = processQueue(cache).then(() => revalidateProvisionalEntities(cache)).catch(() => {
47304       }).finally(() => cache.queuePromise = null);
47305       return cache.queuePromise;
47306     }
47307     function revalidateProvisionalEntities(cache) {
47308       if (!cache.provisionalEntityIDs.size)
47309         return;
47310       const handle = window.setTimeout(() => {
47311         _deferredST.delete(handle);
47312         if (!cache.provisionalEntityIDs.size)
47313           return;
47314         validateEntitiesAsync(Array.from(cache.provisionalEntityIDs), cache);
47315       }, RETRY);
47316       _deferredST.add(handle);
47317     }
47318     function processQueue(cache) {
47319       if (!cache.queue.length)
47320         return Promise.resolve();
47321       const chunk = cache.queue.pop();
47322       return new Promise((resolvePromise, rejectPromise) => {
47323         const handle = window.requestIdleCallback(() => {
47324           delete _deferredRIC[handle];
47325           chunk.forEach((job) => job());
47326           resolvePromise();
47327         });
47328         _deferredRIC[handle] = rejectPromise;
47329       }).then(() => {
47330         if (cache.queue.length % 25 === 0)
47331           dispatch14.call("validated");
47332       }).then(() => processQueue(cache));
47333     }
47334     return validator;
47335   }
47336   function validationCache(which) {
47337     let cache = {
47338       which,
47339       graph: null,
47340       queue: [],
47341       queuePromise: null,
47342       queuedEntityIDs: /* @__PURE__ */ new Set(),
47343       provisionalEntityIDs: /* @__PURE__ */ new Set(),
47344       issuesByIssueID: {},
47345       // issue.id -> issue
47346       issuesByEntityID: {}
47347       // entity.id -> Set(issue.id)
47348     };
47349     cache.cacheIssue = (issue) => {
47350       (issue.entityIds || []).forEach((entityID) => {
47351         if (!cache.issuesByEntityID[entityID]) {
47352           cache.issuesByEntityID[entityID] = /* @__PURE__ */ new Set();
47353         }
47354         cache.issuesByEntityID[entityID].add(issue.id);
47355       });
47356       cache.issuesByIssueID[issue.id] = issue;
47357     };
47358     cache.uncacheIssue = (issue) => {
47359       (issue.entityIds || []).forEach((entityID) => {
47360         if (cache.issuesByEntityID[entityID]) {
47361           cache.issuesByEntityID[entityID].delete(issue.id);
47362         }
47363       });
47364       delete cache.issuesByIssueID[issue.id];
47365     };
47366     cache.cacheIssues = (issues) => {
47367       issues.forEach(cache.cacheIssue);
47368     };
47369     cache.uncacheIssues = (issues) => {
47370       issues.forEach(cache.uncacheIssue);
47371     };
47372     cache.uncacheIssuesOfType = (type2) => {
47373       const issuesOfType = Object.values(cache.issuesByIssueID).filter((issue) => issue.type === type2);
47374       cache.uncacheIssues(issuesOfType);
47375     };
47376     cache.uncacheEntityID = (entityID) => {
47377       const entityIssueIDs = cache.issuesByEntityID[entityID];
47378       if (entityIssueIDs) {
47379         entityIssueIDs.forEach((issueID) => {
47380           const issue = cache.issuesByIssueID[issueID];
47381           if (issue) {
47382             cache.uncacheIssue(issue);
47383           } else {
47384             delete cache.issuesByIssueID[issueID];
47385           }
47386         });
47387       }
47388       delete cache.issuesByEntityID[entityID];
47389       cache.provisionalEntityIDs.delete(entityID);
47390     };
47391     cache.withAllRelatedEntities = (entityIDs) => {
47392       let result = /* @__PURE__ */ new Set();
47393       (entityIDs || []).forEach((entityID) => {
47394         result.add(entityID);
47395         const entityIssueIDs = cache.issuesByEntityID[entityID];
47396         if (entityIssueIDs) {
47397           entityIssueIDs.forEach((issueID) => {
47398             const issue = cache.issuesByIssueID[issueID];
47399             if (issue) {
47400               (issue.entityIds || []).forEach((relatedID) => result.add(relatedID));
47401             } else {
47402               delete cache.issuesByIssueID[issueID];
47403             }
47404           });
47405         }
47406       });
47407       return result;
47408     };
47409     return cache;
47410   }
47411
47412   // modules/core/uploader.js
47413   function coreUploader(context) {
47414     var dispatch14 = dispatch_default(
47415       // Start and end events are dispatched exactly once each per legitimate outside call to `save`
47416       "saveStarted",
47417       // dispatched as soon as a call to `save` has been deemed legitimate
47418       "saveEnded",
47419       // dispatched after the result event has been dispatched
47420       "willAttemptUpload",
47421       // dispatched before the actual upload call occurs, if it will
47422       "progressChanged",
47423       // Each save results in one of these outcomes:
47424       "resultNoChanges",
47425       // upload wasn't attempted since there were no edits
47426       "resultErrors",
47427       // upload failed due to errors
47428       "resultConflicts",
47429       // upload failed due to data conflicts
47430       "resultSuccess"
47431       // upload completed without errors
47432     );
47433     var _isSaving = false;
47434     var _conflicts = [];
47435     var _errors = [];
47436     var _origChanges;
47437     var _discardTags = {};
47438     _mainFileFetcher.get("discarded").then(function(d2) {
47439       _discardTags = d2;
47440     }).catch(function() {
47441     });
47442     var uploader = utilRebind({}, dispatch14, "on");
47443     uploader.isSaving = function() {
47444       return _isSaving;
47445     };
47446     uploader.save = function(changeset, tryAgain, checkConflicts) {
47447       if (_isSaving && !tryAgain) {
47448         return;
47449       }
47450       var osm = context.connection();
47451       if (!osm)
47452         return;
47453       if (!osm.authenticated()) {
47454         osm.authenticate(function(err) {
47455           if (!err) {
47456             uploader.save(changeset, tryAgain, checkConflicts);
47457           }
47458         });
47459         return;
47460       }
47461       if (!_isSaving) {
47462         _isSaving = true;
47463         dispatch14.call("saveStarted", this);
47464       }
47465       var history = context.history();
47466       _conflicts = [];
47467       _errors = [];
47468       _origChanges = history.changes(actionDiscardTags(history.difference(), _discardTags));
47469       if (!tryAgain) {
47470         history.perform(actionNoop());
47471       }
47472       if (!checkConflicts) {
47473         upload(changeset);
47474       } else {
47475         performFullConflictCheck(changeset);
47476       }
47477     };
47478     function performFullConflictCheck(changeset) {
47479       var osm = context.connection();
47480       if (!osm)
47481         return;
47482       var history = context.history();
47483       var localGraph = context.graph();
47484       var remoteGraph = coreGraph(history.base(), true);
47485       var summary = history.difference().summary();
47486       var _toCheck = [];
47487       for (var i3 = 0; i3 < summary.length; i3++) {
47488         var item = summary[i3];
47489         if (item.changeType === "modified") {
47490           _toCheck.push(item.entity.id);
47491         }
47492       }
47493       var _toLoad = withChildNodes(_toCheck, localGraph);
47494       var _loaded = {};
47495       var _toLoadCount = 0;
47496       var _toLoadTotal = _toLoad.length;
47497       if (_toCheck.length) {
47498         dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47499         _toLoad.forEach(function(id2) {
47500           _loaded[id2] = false;
47501         });
47502         osm.loadMultiple(_toLoad, loaded);
47503       } else {
47504         upload(changeset);
47505       }
47506       return;
47507       function withChildNodes(ids, graph) {
47508         var s2 = new Set(ids);
47509         ids.forEach(function(id2) {
47510           var entity = graph.entity(id2);
47511           if (entity.type !== "way")
47512             return;
47513           graph.childNodes(entity).forEach(function(child) {
47514             if (child.version !== void 0) {
47515               s2.add(child.id);
47516             }
47517           });
47518         });
47519         return Array.from(s2);
47520       }
47521       function loaded(err, result) {
47522         if (_errors.length)
47523           return;
47524         if (err) {
47525           _errors.push({
47526             msg: err.message || err.responseText,
47527             details: [_t("save.status_code", { code: err.status })]
47528           });
47529           didResultInErrors();
47530         } else {
47531           var loadMore = [];
47532           result.data.forEach(function(entity) {
47533             remoteGraph.replace(entity);
47534             _loaded[entity.id] = true;
47535             _toLoad = _toLoad.filter(function(val) {
47536               return val !== entity.id;
47537             });
47538             if (!entity.visible)
47539               return;
47540             var i4, id2;
47541             if (entity.type === "way") {
47542               for (i4 = 0; i4 < entity.nodes.length; i4++) {
47543                 id2 = entity.nodes[i4];
47544                 if (_loaded[id2] === void 0) {
47545                   _loaded[id2] = false;
47546                   loadMore.push(id2);
47547                 }
47548               }
47549             } else if (entity.type === "relation" && entity.isMultipolygon()) {
47550               for (i4 = 0; i4 < entity.members.length; i4++) {
47551                 id2 = entity.members[i4].id;
47552                 if (_loaded[id2] === void 0) {
47553                   _loaded[id2] = false;
47554                   loadMore.push(id2);
47555                 }
47556               }
47557             }
47558           });
47559           _toLoadCount += result.data.length;
47560           _toLoadTotal += loadMore.length;
47561           dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47562           if (loadMore.length) {
47563             _toLoad.push.apply(_toLoad, loadMore);
47564             osm.loadMultiple(loadMore, loaded);
47565           }
47566           if (!_toLoad.length) {
47567             detectConflicts();
47568             upload(changeset);
47569           }
47570         }
47571       }
47572       function detectConflicts() {
47573         function choice(id2, text, action) {
47574           return {
47575             id: id2,
47576             text,
47577             action: function() {
47578               history.replace(action);
47579             }
47580           };
47581         }
47582         function formatUser(d2) {
47583           return '<a href="' + osm.userURL(d2) + '" target="_blank">' + escape_default(d2) + "</a>";
47584         }
47585         function entityName(entity) {
47586           return utilDisplayName(entity) || utilDisplayType(entity.id) + " " + entity.id;
47587         }
47588         function sameVersions(local, remote) {
47589           if (local.version !== remote.version)
47590             return false;
47591           if (local.type === "way") {
47592             var children2 = utilArrayUnion(local.nodes, remote.nodes);
47593             for (var i4 = 0; i4 < children2.length; i4++) {
47594               var a2 = localGraph.hasEntity(children2[i4]);
47595               var b2 = remoteGraph.hasEntity(children2[i4]);
47596               if (a2 && b2 && a2.version !== b2.version)
47597                 return false;
47598             }
47599           }
47600           return true;
47601         }
47602         _toCheck.forEach(function(id2) {
47603           var local = localGraph.entity(id2);
47604           var remote = remoteGraph.entity(id2);
47605           if (sameVersions(local, remote))
47606             return;
47607           var merge2 = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags, formatUser);
47608           history.replace(merge2);
47609           var mergeConflicts = merge2.conflicts();
47610           if (!mergeConflicts.length)
47611             return;
47612           var forceLocal = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_local");
47613           var forceRemote = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_remote");
47614           var keepMine = _t("save.conflict." + (remote.visible ? "keep_local" : "restore"));
47615           var keepTheirs = _t("save.conflict." + (remote.visible ? "keep_remote" : "delete"));
47616           _conflicts.push({
47617             id: id2,
47618             name: entityName(local),
47619             details: mergeConflicts,
47620             chosen: 1,
47621             choices: [
47622               choice(id2, keepMine, forceLocal),
47623               choice(id2, keepTheirs, forceRemote)
47624             ]
47625           });
47626         });
47627       }
47628     }
47629     function upload(changeset) {
47630       var osm = context.connection();
47631       if (!osm) {
47632         _errors.push({ msg: "No OSM Service" });
47633       }
47634       if (_conflicts.length) {
47635         didResultInConflicts(changeset);
47636       } else if (_errors.length) {
47637         didResultInErrors();
47638       } else {
47639         var history = context.history();
47640         var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
47641         if (changes.modified.length || changes.created.length || changes.deleted.length) {
47642           dispatch14.call("willAttemptUpload", this);
47643           osm.putChangeset(changeset, changes, uploadCallback);
47644         } else {
47645           didResultInNoChanges();
47646         }
47647       }
47648     }
47649     function uploadCallback(err, changeset) {
47650       if (err) {
47651         if (err.status === 409) {
47652           uploader.save(changeset, true, true);
47653         } else {
47654           _errors.push({
47655             msg: err.message || err.responseText,
47656             details: [_t("save.status_code", { code: err.status })]
47657           });
47658           didResultInErrors();
47659         }
47660       } else {
47661         didResultInSuccess(changeset);
47662       }
47663     }
47664     function didResultInNoChanges() {
47665       dispatch14.call("resultNoChanges", this);
47666       endSave();
47667       context.flush();
47668     }
47669     function didResultInErrors() {
47670       context.history().pop();
47671       dispatch14.call("resultErrors", this, _errors);
47672       endSave();
47673     }
47674     function didResultInConflicts(changeset) {
47675       _conflicts.sort(function(a2, b2) {
47676         return b2.id.localeCompare(a2.id);
47677       });
47678       dispatch14.call("resultConflicts", this, changeset, _conflicts, _origChanges);
47679       endSave();
47680     }
47681     function didResultInSuccess(changeset) {
47682       context.history().clearSaved();
47683       dispatch14.call("resultSuccess", this, changeset);
47684       window.setTimeout(function() {
47685         endSave();
47686         context.flush();
47687       }, 2500);
47688     }
47689     function endSave() {
47690       _isSaving = false;
47691       dispatch14.call("saveEnded", this);
47692     }
47693     uploader.cancelConflictResolution = function() {
47694       context.history().pop();
47695     };
47696     uploader.processResolvedConflicts = function(changeset) {
47697       var history = context.history();
47698       for (var i3 = 0; i3 < _conflicts.length; i3++) {
47699         if (_conflicts[i3].chosen === 1) {
47700           var entity = context.hasEntity(_conflicts[i3].id);
47701           if (entity && entity.type === "way") {
47702             var children2 = utilArrayUniq(entity.nodes);
47703             for (var j2 = 0; j2 < children2.length; j2++) {
47704               history.replace(actionRevert(children2[j2]));
47705             }
47706           }
47707           history.replace(actionRevert(_conflicts[i3].id));
47708         }
47709       }
47710       uploader.save(changeset, true, false);
47711     };
47712     uploader.reset = function() {
47713     };
47714     return uploader;
47715   }
47716
47717   // modules/renderer/background_source.js
47718   var import_lodash4 = __toESM(require_lodash());
47719
47720   // modules/util/IntervalTasksQueue.js
47721   var IntervalTasksQueue = class {
47722     /**
47723      * Interval in milliseconds inside which only 1 task can execute.
47724      * e.g. if interval is 200ms, and 5 async tasks are unqueued,
47725      * they will complete in ~1s if not cleared
47726      * @param {number} intervalInMs
47727      */
47728     constructor(intervalInMs) {
47729       this.intervalInMs = intervalInMs;
47730       this.pendingHandles = [];
47731       this.time = 0;
47732     }
47733     enqueue(task) {
47734       let taskTimeout = this.time;
47735       this.time += this.intervalInMs;
47736       this.pendingHandles.push(setTimeout(() => {
47737         this.time -= this.intervalInMs;
47738         task();
47739       }, taskTimeout));
47740     }
47741     clear() {
47742       this.pendingHandles.forEach((timeoutHandle) => {
47743         clearTimeout(timeoutHandle);
47744       });
47745       this.pendingHandles = [];
47746       this.time = 0;
47747     }
47748   };
47749
47750   // modules/renderer/background_source.js
47751   var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47752   window.matchMedia("\n        (-webkit-min-device-pixel-ratio: 2), /* Safari */\n        (min-resolution: 2dppx),             /* standard */\n        (min-resolution: 192dpi)             /* fallback */\n    ").addListener(function() {
47753     isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47754   });
47755   function localeDateString(s2) {
47756     if (!s2)
47757       return null;
47758     var options2 = { day: "numeric", month: "short", year: "numeric" };
47759     var d2 = new Date(s2);
47760     if (isNaN(d2.getTime()))
47761       return null;
47762     return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
47763   }
47764   function vintageRange(vintage) {
47765     var s2;
47766     if (vintage.start || vintage.end) {
47767       s2 = vintage.start || "?";
47768       if (vintage.start !== vintage.end) {
47769         s2 += " - " + (vintage.end || "?");
47770       }
47771     }
47772     return s2;
47773   }
47774   function rendererBackgroundSource(data) {
47775     var source = Object.assign({}, data);
47776     var _offset = [0, 0];
47777     var _name = source.name;
47778     var _description = source.description;
47779     var _best = !!source.best;
47780     var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template;
47781     source.tileSize = data.tileSize || 256;
47782     source.zoomExtent = data.zoomExtent || [0, 22];
47783     source.overzoom = data.overzoom !== false;
47784     source.offset = function(val) {
47785       if (!arguments.length)
47786         return _offset;
47787       _offset = val;
47788       return source;
47789     };
47790     source.nudge = function(val, zoomlevel) {
47791       _offset[0] += val[0] / Math.pow(2, zoomlevel);
47792       _offset[1] += val[1] / Math.pow(2, zoomlevel);
47793       return source;
47794     };
47795     source.name = function() {
47796       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47797       return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47798     };
47799     source.label = function() {
47800       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47801       return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47802     };
47803     source.hasDescription = function() {
47804       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47805       var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text;
47806       return descriptionText !== "";
47807     };
47808     source.description = function() {
47809       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47810       return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) });
47811     };
47812     source.best = function() {
47813       return _best;
47814     };
47815     source.area = function() {
47816       if (!data.polygon)
47817         return Number.MAX_VALUE;
47818       var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] });
47819       return isNaN(area) ? 0 : area;
47820     };
47821     source.imageryUsed = function() {
47822       return _name || source.id;
47823     };
47824     source.template = function(val) {
47825       if (!arguments.length)
47826         return _template;
47827       if (source.id === "custom" || source.id === "Bing") {
47828         _template = val;
47829       }
47830       return source;
47831     };
47832     source.url = function(coord2) {
47833       var result = _template.replace(/#[\s\S]*/u, "");
47834       if (result === "")
47835         return result;
47836       if (!source.type || source.id === "custom") {
47837         if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
47838           source.type = "wms";
47839           source.projection = "EPSG:3857";
47840         } else if (/\{(x|y)\}/.test(result)) {
47841           source.type = "tms";
47842         } else if (/\{u\}/.test(result)) {
47843           source.type = "bing";
47844         }
47845       }
47846       if (source.type === "wms") {
47847         var tileToProjectedCoords = function(x2, y2, z2) {
47848           var zoomSize = Math.pow(2, z2);
47849           var lon = x2 / zoomSize * Math.PI * 2 - Math.PI;
47850           var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize)));
47851           switch (source.projection) {
47852             case "EPSG:4326":
47853               return {
47854                 x: lon * 180 / Math.PI,
47855                 y: lat * 180 / Math.PI
47856               };
47857             default:
47858               var mercCoords = mercatorRaw(lon, lat);
47859               return {
47860                 x: 2003750834e-2 / Math.PI * mercCoords[0],
47861                 y: 2003750834e-2 / Math.PI * mercCoords[1]
47862               };
47863           }
47864         };
47865         var tileSize = source.tileSize;
47866         var projection2 = source.projection;
47867         var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]);
47868         var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]);
47869         result = result.replace(/\{(\w+)\}/g, function(token, key) {
47870           switch (key) {
47871             case "width":
47872             case "height":
47873               return tileSize;
47874             case "proj":
47875               return projection2;
47876             case "wkid":
47877               return projection2.replace(/^EPSG:/, "");
47878             case "bbox":
47879               if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS)
47880               /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) {
47881                 return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x;
47882               } else {
47883                 return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y;
47884               }
47885             case "w":
47886               return minXmaxY.x;
47887             case "s":
47888               return maxXminY.y;
47889             case "n":
47890               return maxXminY.x;
47891             case "e":
47892               return minXmaxY.y;
47893             default:
47894               return token;
47895           }
47896         });
47897       } else if (source.type === "tms") {
47898         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" : "");
47899       } else if (source.type === "bing") {
47900         result = result.replace("{u}", function() {
47901           var u2 = "";
47902           for (var zoom = coord2[2]; zoom > 0; zoom--) {
47903             var b2 = 0;
47904             var mask = 1 << zoom - 1;
47905             if ((coord2[0] & mask) !== 0)
47906               b2++;
47907             if ((coord2[1] & mask) !== 0)
47908               b2 += 2;
47909             u2 += b2.toString();
47910           }
47911           return u2;
47912         });
47913       }
47914       result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) {
47915         var subdomains = r2.split(",");
47916         return subdomains[(coord2[0] + coord2[1]) % subdomains.length];
47917       });
47918       return result;
47919     };
47920     source.validZoom = function(z2) {
47921       return source.zoomExtent[0] <= z2 && (source.overzoom || source.zoomExtent[1] > z2);
47922     };
47923     source.isLocatorOverlay = function() {
47924       return source.id === "mapbox_locator_overlay";
47925     };
47926     source.isHidden = function() {
47927       return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage";
47928     };
47929     source.copyrightNotices = function() {
47930     };
47931     source.getMetadata = function(center, tileCoord, callback) {
47932       var vintage = {
47933         start: localeDateString(source.startDate),
47934         end: localeDateString(source.endDate)
47935       };
47936       vintage.range = vintageRange(vintage);
47937       var metadata = { vintage };
47938       callback(null, metadata);
47939     };
47940     return source;
47941   }
47942   rendererBackgroundSource.Bing = function(data, dispatch14) {
47943     data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z";
47944     var bing = rendererBackgroundSource(data);
47945     var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
47946     const strictParam = "n";
47947     var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key;
47948     var cache = {};
47949     var inflight = {};
47950     var providers = [];
47951     var taskQueue = new IntervalTasksQueue(250);
47952     var metadataLastZoom = -1;
47953     json_default(url).then(function(json) {
47954       let imageryResource = json.resourceSets[0].resources[0];
47955       let template = imageryResource.imageUrl;
47956       let subDomains = imageryResource.imageUrlSubdomains;
47957       let subDomainNumbers = subDomains.map((subDomain) => {
47958         return subDomain.substring(1);
47959       }).join(",");
47960       template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}");
47961       if (!new URLSearchParams(template).has(strictParam)) {
47962         template += "&".concat(strictParam, "=z");
47963       }
47964       bing.template(template);
47965       providers = imageryResource.imageryProviders.map(function(provider) {
47966         return {
47967           attribution: provider.attribution,
47968           areas: provider.coverageAreas.map(function(area) {
47969             return {
47970               zoom: [area.zoomMin, area.zoomMax],
47971               extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
47972             };
47973           })
47974         };
47975       });
47976       dispatch14.call("change");
47977     }).catch(function() {
47978     });
47979     bing.copyrightNotices = function(zoom, extent) {
47980       zoom = Math.min(zoom, 21);
47981       return providers.filter(function(provider) {
47982         return provider.areas.some(function(area) {
47983           return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom;
47984         });
47985       }).map(function(provider) {
47986         return provider.attribution;
47987       }).join(", ");
47988     };
47989     bing.getMetadata = function(center, tileCoord, callback) {
47990       var tileID = tileCoord.slice(0, 3).join("/");
47991       var zoom = Math.min(tileCoord[2], 21);
47992       var centerPoint = center[1] + "," + center[0];
47993       var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key;
47994       if (inflight[tileID])
47995         return;
47996       if (!cache[tileID]) {
47997         cache[tileID] = {};
47998       }
47999       if (cache[tileID] && cache[tileID].metadata) {
48000         return callback(null, cache[tileID].metadata);
48001       }
48002       inflight[tileID] = true;
48003       if (metadataLastZoom !== tileCoord[2]) {
48004         metadataLastZoom = tileCoord[2];
48005         taskQueue.clear();
48006       }
48007       taskQueue.enqueue(() => {
48008         json_default(url2).then(function(result) {
48009           delete inflight[tileID];
48010           if (!result) {
48011             throw new Error("Unknown Error");
48012           }
48013           var vintage = {
48014             start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
48015             end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
48016           };
48017           vintage.range = vintageRange(vintage);
48018           var metadata = { vintage };
48019           cache[tileID].metadata = metadata;
48020           if (callback)
48021             callback(null, metadata);
48022         }).catch(function(err) {
48023           delete inflight[tileID];
48024           if (callback)
48025             callback(err.message);
48026         });
48027       });
48028     };
48029     bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details";
48030     return bing;
48031   };
48032   rendererBackgroundSource.Esri = function(data) {
48033     if (data.template.match(/blankTile/) === null) {
48034       data.template = data.template + "?blankTile=false";
48035     }
48036     var esri = rendererBackgroundSource(data);
48037     var cache = {};
48038     var inflight = {};
48039     var _prevCenter;
48040     esri.fetchTilemap = function(center) {
48041       if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3)
48042         return;
48043       _prevCenter = center;
48044       var z2 = 20;
48045       var dummyUrl = esri.url([1, 2, 3]);
48046       var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2));
48047       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));
48048       var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8";
48049       json_default(tilemapUrl).then(function(tilemap) {
48050         if (!tilemap) {
48051           throw new Error("Unknown Error");
48052         }
48053         var hasTiles = true;
48054         for (var i3 = 0; i3 < tilemap.data.length; i3++) {
48055           if (!tilemap.data[i3]) {
48056             hasTiles = false;
48057             break;
48058           }
48059         }
48060         esri.zoomExtent[1] = hasTiles ? 22 : 19;
48061       }).catch(function() {
48062       });
48063     };
48064     esri.getMetadata = function(center, tileCoord, callback) {
48065       if (esri.id !== "EsriWorldImagery") {
48066         return callback(null, {});
48067       }
48068       var tileID = tileCoord.slice(0, 3).join("/");
48069       var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]);
48070       var centerPoint = center[0] + "," + center[1];
48071       var unknown = _t("info_panels.background.unknown");
48072       var vintage = {};
48073       var metadata = {};
48074       if (inflight[tileID])
48075         return;
48076       var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query";
48077       url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json";
48078       if (!cache[tileID]) {
48079         cache[tileID] = {};
48080       }
48081       if (cache[tileID] && cache[tileID].metadata) {
48082         return callback(null, cache[tileID].metadata);
48083       }
48084       inflight[tileID] = true;
48085       json_default(url).then(function(result) {
48086         delete inflight[tileID];
48087         result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0];
48088         if (!result) {
48089           throw new Error("Unknown Error");
48090         } else if (result.features && result.features.length < 1) {
48091           throw new Error("No Results");
48092         } else if (result.error && result.error.message) {
48093           throw new Error(result.error.message);
48094         }
48095         var captureDate = localeDateString(result.SRC_DATE2);
48096         vintage = {
48097           start: captureDate,
48098           end: captureDate,
48099           range: captureDate
48100         };
48101         metadata = {
48102           vintage,
48103           source: clean2(result.NICE_NAME),
48104           description: clean2(result.NICE_DESC),
48105           resolution: clean2(+Number(result.SRC_RES).toFixed(4)),
48106           accuracy: clean2(+Number(result.SRC_ACC).toFixed(4))
48107         };
48108         if (isFinite(metadata.resolution)) {
48109           metadata.resolution += " m";
48110         }
48111         if (isFinite(metadata.accuracy)) {
48112           metadata.accuracy += " m";
48113         }
48114         cache[tileID].metadata = metadata;
48115         if (callback)
48116           callback(null, metadata);
48117       }).catch(function(err) {
48118         delete inflight[tileID];
48119         if (callback)
48120           callback(err.message);
48121       });
48122       function clean2(val) {
48123         return String(val).trim() || unknown;
48124       }
48125     };
48126     return esri;
48127   };
48128   rendererBackgroundSource.None = function() {
48129     var source = rendererBackgroundSource({ id: "none", template: "" });
48130     source.name = function() {
48131       return _t("background.none");
48132     };
48133     source.label = function() {
48134       return _t.append("background.none");
48135     };
48136     source.imageryUsed = function() {
48137       return null;
48138     };
48139     source.area = function() {
48140       return -1;
48141     };
48142     return source;
48143   };
48144   rendererBackgroundSource.Custom = function(template) {
48145     var source = rendererBackgroundSource({ id: "custom", template });
48146     source.name = function() {
48147       return _t("background.custom");
48148     };
48149     source.label = function() {
48150       return _t.append("background.custom");
48151     };
48152     source.imageryUsed = function() {
48153       var cleaned = source.template();
48154       if (cleaned.indexOf("?") !== -1) {
48155         var parts = cleaned.split("?", 2);
48156         var qs = utilStringQs(parts[1]);
48157         ["access_token", "connectId", "token", "Signature"].forEach(function(param) {
48158           if (qs[param]) {
48159             qs[param] = "{apikey}";
48160           }
48161         });
48162         cleaned = parts[0] + "?" + utilQsString(qs, true);
48163       }
48164       cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}");
48165       return "Custom (" + cleaned + " )";
48166     };
48167     source.area = function() {
48168       return -2;
48169     };
48170     return source;
48171   };
48172
48173   // node_modules/@turf/helpers/dist/es/index.js
48174   var earthRadius = 63710088e-1;
48175   var factors = {
48176     centimeters: earthRadius * 100,
48177     centimetres: earthRadius * 100,
48178     degrees: earthRadius / 111325,
48179     feet: earthRadius * 3.28084,
48180     inches: earthRadius * 39.37,
48181     kilometers: earthRadius / 1e3,
48182     kilometres: earthRadius / 1e3,
48183     meters: earthRadius,
48184     metres: earthRadius,
48185     miles: earthRadius / 1609.344,
48186     millimeters: earthRadius * 1e3,
48187     millimetres: earthRadius * 1e3,
48188     nauticalmiles: earthRadius / 1852,
48189     radians: 1,
48190     yards: earthRadius * 1.0936
48191   };
48192   var unitsFactors = {
48193     centimeters: 100,
48194     centimetres: 100,
48195     degrees: 1 / 111325,
48196     feet: 3.28084,
48197     inches: 39.37,
48198     kilometers: 1 / 1e3,
48199     kilometres: 1 / 1e3,
48200     meters: 1,
48201     metres: 1,
48202     miles: 1 / 1609.344,
48203     millimeters: 1e3,
48204     millimetres: 1e3,
48205     nauticalmiles: 1 / 1852,
48206     radians: 1 / earthRadius,
48207     yards: 1.0936133
48208   };
48209   function feature2(geom, properties, options2) {
48210     if (options2 === void 0) {
48211       options2 = {};
48212     }
48213     var feat = { type: "Feature" };
48214     if (options2.id === 0 || options2.id) {
48215       feat.id = options2.id;
48216     }
48217     if (options2.bbox) {
48218       feat.bbox = options2.bbox;
48219     }
48220     feat.properties = properties || {};
48221     feat.geometry = geom;
48222     return feat;
48223   }
48224   function polygon(coordinates, properties, options2) {
48225     if (options2 === void 0) {
48226       options2 = {};
48227     }
48228     for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
48229       var ring = coordinates_1[_i];
48230       if (ring.length < 4) {
48231         throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
48232       }
48233       for (var j2 = 0; j2 < ring[ring.length - 1].length; j2++) {
48234         if (ring[ring.length - 1][j2] !== ring[0][j2]) {
48235           throw new Error("First and last Position are not equivalent.");
48236         }
48237       }
48238     }
48239     var geom = {
48240       type: "Polygon",
48241       coordinates
48242     };
48243     return feature2(geom, properties, options2);
48244   }
48245   function lineString(coordinates, properties, options2) {
48246     if (options2 === void 0) {
48247       options2 = {};
48248     }
48249     if (coordinates.length < 2) {
48250       throw new Error("coordinates must be an array of two or more positions");
48251     }
48252     var geom = {
48253       type: "LineString",
48254       coordinates
48255     };
48256     return feature2(geom, properties, options2);
48257   }
48258   function multiLineString(coordinates, properties, options2) {
48259     if (options2 === void 0) {
48260       options2 = {};
48261     }
48262     var geom = {
48263       type: "MultiLineString",
48264       coordinates
48265     };
48266     return feature2(geom, properties, options2);
48267   }
48268   function multiPolygon(coordinates, properties, options2) {
48269     if (options2 === void 0) {
48270       options2 = {};
48271     }
48272     var geom = {
48273       type: "MultiPolygon",
48274       coordinates
48275     };
48276     return feature2(geom, properties, options2);
48277   }
48278
48279   // node_modules/@turf/invariant/dist/es/index.js
48280   function getGeom(geojson) {
48281     if (geojson.type === "Feature") {
48282       return geojson.geometry;
48283     }
48284     return geojson;
48285   }
48286
48287   // node_modules/@turf/bbox-clip/dist/es/lib/lineclip.js
48288   function lineclip(points, bbox2, result) {
48289     var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode;
48290     var a2;
48291     var b2;
48292     if (!result)
48293       result = [];
48294     for (i3 = 1; i3 < len; i3++) {
48295       a2 = points[i3 - 1];
48296       b2 = points[i3];
48297       codeB = lastCode = bitCode(b2, bbox2);
48298       while (true) {
48299         if (!(codeA | codeB)) {
48300           part.push(a2);
48301           if (codeB !== lastCode) {
48302             part.push(b2);
48303             if (i3 < len - 1) {
48304               result.push(part);
48305               part = [];
48306             }
48307           } else if (i3 === len - 1) {
48308             part.push(b2);
48309           }
48310           break;
48311         } else if (codeA & codeB) {
48312           break;
48313         } else if (codeA) {
48314           a2 = intersect(a2, b2, codeA, bbox2);
48315           codeA = bitCode(a2, bbox2);
48316         } else {
48317           b2 = intersect(a2, b2, codeB, bbox2);
48318           codeB = bitCode(b2, bbox2);
48319         }
48320       }
48321       codeA = lastCode;
48322     }
48323     if (part.length)
48324       result.push(part);
48325     return result;
48326   }
48327   function polygonclip(points, bbox2) {
48328     var result, edge, prev, prevInside, i3, p2, inside;
48329     for (edge = 1; edge <= 8; edge *= 2) {
48330       result = [];
48331       prev = points[points.length - 1];
48332       prevInside = !(bitCode(prev, bbox2) & edge);
48333       for (i3 = 0; i3 < points.length; i3++) {
48334         p2 = points[i3];
48335         inside = !(bitCode(p2, bbox2) & edge);
48336         if (inside !== prevInside)
48337           result.push(intersect(prev, p2, edge, bbox2));
48338         if (inside)
48339           result.push(p2);
48340         prev = p2;
48341         prevInside = inside;
48342       }
48343       points = result;
48344       if (!points.length)
48345         break;
48346     }
48347     return result;
48348   }
48349   function intersect(a2, b2, edge, bbox2) {
48350     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;
48351   }
48352   function bitCode(p2, bbox2) {
48353     var code = 0;
48354     if (p2[0] < bbox2[0])
48355       code |= 1;
48356     else if (p2[0] > bbox2[2])
48357       code |= 2;
48358     if (p2[1] < bbox2[1])
48359       code |= 4;
48360     else if (p2[1] > bbox2[3])
48361       code |= 8;
48362     return code;
48363   }
48364
48365   // node_modules/@turf/bbox-clip/dist/es/index.js
48366   function bboxClip(feature3, bbox2) {
48367     var geom = getGeom(feature3);
48368     var type2 = geom.type;
48369     var properties = feature3.type === "Feature" ? feature3.properties : {};
48370     var coords = geom.coordinates;
48371     switch (type2) {
48372       case "LineString":
48373       case "MultiLineString": {
48374         var lines_1 = [];
48375         if (type2 === "LineString") {
48376           coords = [coords];
48377         }
48378         coords.forEach(function(line) {
48379           lineclip(line, bbox2, lines_1);
48380         });
48381         if (lines_1.length === 1) {
48382           return lineString(lines_1[0], properties);
48383         }
48384         return multiLineString(lines_1, properties);
48385       }
48386       case "Polygon":
48387         return polygon(clipPolygon(coords, bbox2), properties);
48388       case "MultiPolygon":
48389         return multiPolygon(coords.map(function(poly) {
48390           return clipPolygon(poly, bbox2);
48391         }), properties);
48392       default:
48393         throw new Error("geometry " + type2 + " not supported");
48394     }
48395   }
48396   function clipPolygon(rings, bbox2) {
48397     var outRings = [];
48398     for (var _i = 0, rings_1 = rings; _i < rings_1.length; _i++) {
48399       var ring = rings_1[_i];
48400       var clipped = polygonclip(ring, bbox2);
48401       if (clipped.length > 0) {
48402         if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
48403           clipped.push(clipped[0]);
48404         }
48405         if (clipped.length >= 4) {
48406           outRings.push(clipped);
48407         }
48408       }
48409     }
48410     return outRings;
48411   }
48412
48413   // node_modules/@turf/meta/dist/es/index.js
48414   function coordEach(geojson, callback, excludeWrapCoord) {
48415     if (geojson === null)
48416       return;
48417     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;
48418     for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
48419       geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
48420       isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
48421       stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
48422       for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
48423         var multiFeatureIndex = 0;
48424         var geometryIndex = 0;
48425         geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
48426         if (geometry === null)
48427           continue;
48428         coords = geometry.coordinates;
48429         var geomType = geometry.type;
48430         wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
48431         switch (geomType) {
48432           case null:
48433             break;
48434           case "Point":
48435             if (callback(
48436               coords,
48437               coordIndex,
48438               featureIndex,
48439               multiFeatureIndex,
48440               geometryIndex
48441             ) === false)
48442               return false;
48443             coordIndex++;
48444             multiFeatureIndex++;
48445             break;
48446           case "LineString":
48447           case "MultiPoint":
48448             for (j2 = 0; j2 < coords.length; j2++) {
48449               if (callback(
48450                 coords[j2],
48451                 coordIndex,
48452                 featureIndex,
48453                 multiFeatureIndex,
48454                 geometryIndex
48455               ) === false)
48456                 return false;
48457               coordIndex++;
48458               if (geomType === "MultiPoint")
48459                 multiFeatureIndex++;
48460             }
48461             if (geomType === "LineString")
48462               multiFeatureIndex++;
48463             break;
48464           case "Polygon":
48465           case "MultiLineString":
48466             for (j2 = 0; j2 < coords.length; j2++) {
48467               for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) {
48468                 if (callback(
48469                   coords[j2][k2],
48470                   coordIndex,
48471                   featureIndex,
48472                   multiFeatureIndex,
48473                   geometryIndex
48474                 ) === false)
48475                   return false;
48476                 coordIndex++;
48477               }
48478               if (geomType === "MultiLineString")
48479                 multiFeatureIndex++;
48480               if (geomType === "Polygon")
48481                 geometryIndex++;
48482             }
48483             if (geomType === "Polygon")
48484               multiFeatureIndex++;
48485             break;
48486           case "MultiPolygon":
48487             for (j2 = 0; j2 < coords.length; j2++) {
48488               geometryIndex = 0;
48489               for (k2 = 0; k2 < coords[j2].length; k2++) {
48490                 for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) {
48491                   if (callback(
48492                     coords[j2][k2][l2],
48493                     coordIndex,
48494                     featureIndex,
48495                     multiFeatureIndex,
48496                     geometryIndex
48497                   ) === false)
48498                     return false;
48499                   coordIndex++;
48500                 }
48501                 geometryIndex++;
48502               }
48503               multiFeatureIndex++;
48504             }
48505             break;
48506           case "GeometryCollection":
48507             for (j2 = 0; j2 < geometry.geometries.length; j2++)
48508               if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false)
48509                 return false;
48510             break;
48511           default:
48512             throw new Error("Unknown Geometry Type");
48513         }
48514       }
48515     }
48516   }
48517
48518   // node_modules/@turf/bbox/dist/es/index.js
48519   function bbox(geojson) {
48520     var result = [Infinity, Infinity, -Infinity, -Infinity];
48521     coordEach(geojson, function(coord2) {
48522       if (result[0] > coord2[0]) {
48523         result[0] = coord2[0];
48524       }
48525       if (result[1] > coord2[1]) {
48526         result[1] = coord2[1];
48527       }
48528       if (result[2] < coord2[0]) {
48529         result[2] = coord2[0];
48530       }
48531       if (result[3] < coord2[1]) {
48532         result[3] = coord2[1];
48533       }
48534     });
48535     return result;
48536   }
48537   bbox["default"] = bbox;
48538   var es_default = bbox;
48539
48540   // modules/renderer/background.js
48541   var import_which_polygon3 = __toESM(require_which_polygon());
48542
48543   // modules/renderer/tile_layer.js
48544   function rendererTileLayer(context) {
48545     var transformProp = utilPrefixCSSProperty("Transform");
48546     var tiler9 = utilTiler();
48547     var _tileSize = 256;
48548     var _projection;
48549     var _cache5 = {};
48550     var _tileOrigin;
48551     var _zoom;
48552     var _source;
48553     function tileSizeAtZoom(d2, z2) {
48554       var EPSILON = 2e-3;
48555       return _tileSize * Math.pow(2, z2 - d2[2]) / _tileSize + EPSILON;
48556     }
48557     function atZoom(t2, distance) {
48558       var power = Math.pow(2, distance);
48559       return [
48560         Math.floor(t2[0] * power),
48561         Math.floor(t2[1] * power),
48562         t2[2] + distance
48563       ];
48564     }
48565     function lookUp(d2) {
48566       for (var up = -1; up > -d2[2]; up--) {
48567         var tile = atZoom(d2, up);
48568         if (_cache5[_source.url(tile)] !== false) {
48569           return tile;
48570         }
48571       }
48572     }
48573     function uniqueBy(a2, n3) {
48574       var o2 = [];
48575       var seen = {};
48576       for (var i3 = 0; i3 < a2.length; i3++) {
48577         if (seen[a2[i3][n3]] === void 0) {
48578           o2.push(a2[i3]);
48579           seen[a2[i3][n3]] = true;
48580         }
48581       }
48582       return o2;
48583     }
48584     function addSource(d2) {
48585       d2.push(_source.url(d2));
48586       return d2;
48587     }
48588     function background(selection2) {
48589       _zoom = geoScaleToZoom(_projection.scale(), _tileSize);
48590       var pixelOffset;
48591       if (_source) {
48592         pixelOffset = [
48593           _source.offset()[0] * Math.pow(2, _zoom),
48594           _source.offset()[1] * Math.pow(2, _zoom)
48595         ];
48596       } else {
48597         pixelOffset = [0, 0];
48598       }
48599       var translate = [
48600         _projection.translate()[0] + pixelOffset[0],
48601         _projection.translate()[1] + pixelOffset[1]
48602       ];
48603       tiler9.scale(_projection.scale() * 2 * Math.PI).translate(translate);
48604       _tileOrigin = [
48605         _projection.scale() * Math.PI - translate[0],
48606         _projection.scale() * Math.PI - translate[1]
48607       ];
48608       render(selection2);
48609     }
48610     function render(selection2) {
48611       if (!_source)
48612         return;
48613       var requests = [];
48614       var showDebug = context.getDebug("tile") && !_source.overlay;
48615       if (_source.validZoom(_zoom)) {
48616         tiler9.skipNullIsland(!!_source.overlay);
48617         tiler9().forEach(function(d2) {
48618           addSource(d2);
48619           if (d2[3] === "")
48620             return;
48621           if (typeof d2[3] !== "string")
48622             return;
48623           requests.push(d2);
48624           if (_cache5[d2[3]] === false && lookUp(d2)) {
48625             requests.push(addSource(lookUp(d2)));
48626           }
48627         });
48628         requests = uniqueBy(requests, 3).filter(function(r2) {
48629           return _cache5[r2[3]] !== false;
48630         });
48631       }
48632       function load(d3_event, d2) {
48633         _cache5[d2[3]] = true;
48634         select_default2(this).on("error", null).on("load", null).classed("tile-loaded", true);
48635         render(selection2);
48636       }
48637       function error(d3_event, d2) {
48638         _cache5[d2[3]] = false;
48639         select_default2(this).on("error", null).on("load", null).remove();
48640         render(selection2);
48641       }
48642       function imageTransform(d2) {
48643         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48644         var scale = tileSizeAtZoom(d2, _zoom);
48645         return "translate(" + (d2[0] * ts - _tileOrigin[0]) + "px," + (d2[1] * ts - _tileOrigin[1]) + "px) scale(" + scale + "," + scale + ")";
48646       }
48647       function tileCenter(d2) {
48648         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48649         return [
48650           d2[0] * ts - _tileOrigin[0] + ts / 2,
48651           d2[1] * ts - _tileOrigin[1] + ts / 2
48652         ];
48653       }
48654       function debugTransform(d2) {
48655         var coord2 = tileCenter(d2);
48656         return "translate(" + coord2[0] + "px," + coord2[1] + "px)";
48657       }
48658       var dims = tiler9.size();
48659       var mapCenter = [dims[0] / 2, dims[1] / 2];
48660       var minDist = Math.max(dims[0], dims[1]);
48661       var nearCenter;
48662       requests.forEach(function(d2) {
48663         var c2 = tileCenter(d2);
48664         var dist = geoVecLength(c2, mapCenter);
48665         if (dist < minDist) {
48666           minDist = dist;
48667           nearCenter = d2;
48668         }
48669       });
48670       var image = selection2.selectAll("img").data(requests, function(d2) {
48671         return d2[3];
48672       });
48673       image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).each(function() {
48674         var tile = select_default2(this);
48675         window.setTimeout(function() {
48676           if (tile.classed("tile-removing")) {
48677             tile.remove();
48678           }
48679         }, 300);
48680       });
48681       image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) {
48682         return d2[3];
48683       }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) {
48684         return d2 === nearCenter;
48685       });
48686       var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) {
48687         return d2[3];
48688       });
48689       debug2.exit().remove();
48690       if (showDebug) {
48691         var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug");
48692         debugEnter.append("div").attr("class", "tile-label-debug-coord");
48693         debugEnter.append("div").attr("class", "tile-label-debug-vintage");
48694         debug2 = debug2.merge(debugEnter);
48695         debug2.style(transformProp, debugTransform);
48696         debug2.selectAll(".tile-label-debug-coord").text(function(d2) {
48697           return d2[2] + " / " + d2[0] + " / " + d2[1];
48698         });
48699         debug2.selectAll(".tile-label-debug-vintage").each(function(d2) {
48700           var span = select_default2(this);
48701           var center = context.projection.invert(tileCenter(d2));
48702           _source.getMetadata(center, d2, function(err, result) {
48703             if (result && result.vintage && result.vintage.range) {
48704               span.text(result.vintage.range);
48705             } else {
48706               span.text("");
48707               span.call(_t.append("info_panels.background.vintage"));
48708               span.append("span").text(": ");
48709               span.call(_t.append("info_panels.background.unknown"));
48710             }
48711           });
48712         });
48713       }
48714     }
48715     background.projection = function(val) {
48716       if (!arguments.length)
48717         return _projection;
48718       _projection = val;
48719       return background;
48720     };
48721     background.dimensions = function(val) {
48722       if (!arguments.length)
48723         return tiler9.size();
48724       tiler9.size(val);
48725       return background;
48726     };
48727     background.source = function(val) {
48728       if (!arguments.length)
48729         return _source;
48730       _source = val;
48731       _tileSize = _source.tileSize;
48732       _cache5 = {};
48733       tiler9.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
48734       return background;
48735     };
48736     return background;
48737   }
48738
48739   // modules/renderer/background.js
48740   var _imageryIndex = null;
48741   function rendererBackground(context) {
48742     const dispatch14 = dispatch_default("change");
48743     const baseLayer = rendererTileLayer(context).projection(context.projection);
48744     let _checkedBlocklists = [];
48745     let _isValid = true;
48746     let _overlayLayers = [];
48747     let _brightness = 1;
48748     let _contrast = 1;
48749     let _saturation = 1;
48750     let _sharpness = 1;
48751     function ensureImageryIndex() {
48752       return _mainFileFetcher.get("imagery").then((sources) => {
48753         if (_imageryIndex)
48754           return _imageryIndex;
48755         _imageryIndex = {
48756           imagery: sources,
48757           features: {}
48758         };
48759         const features = sources.map((source) => {
48760           if (!source.polygon)
48761             return null;
48762           const rings = source.polygon.map((ring) => [ring]);
48763           const feature3 = {
48764             type: "Feature",
48765             properties: { id: source.id },
48766             geometry: { type: "MultiPolygon", coordinates: rings }
48767           };
48768           _imageryIndex.features[source.id] = feature3;
48769           return feature3;
48770         }).filter(Boolean);
48771         _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features });
48772         _imageryIndex.backgrounds = sources.map((source) => {
48773           if (source.type === "bing") {
48774             return rendererBackgroundSource.Bing(source, dispatch14);
48775           } else if (/^EsriWorldImagery/.test(source.id)) {
48776             return rendererBackgroundSource.Esri(source);
48777           } else {
48778             return rendererBackgroundSource(source);
48779           }
48780         });
48781         _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None());
48782         let template = corePreferences("background-custom-template") || "";
48783         const custom = rendererBackgroundSource.Custom(template);
48784         _imageryIndex.backgrounds.unshift(custom);
48785         return _imageryIndex;
48786       });
48787     }
48788     function background(selection2) {
48789       const currSource = baseLayer.source();
48790       if (context.map().zoom() > 18) {
48791         if (currSource && /^EsriWorldImagery/.test(currSource.id)) {
48792           const center = context.map().center();
48793           currSource.fetchTilemap(center);
48794         }
48795       }
48796       const sources = background.sources(context.map().extent());
48797       const wasValid = _isValid;
48798       _isValid = !!sources.filter((d2) => d2 === currSource).length;
48799       if (wasValid !== _isValid) {
48800         background.updateImagery();
48801       }
48802       let baseFilter = "";
48803       if (_brightness !== 1) {
48804         baseFilter += " brightness(".concat(_brightness, ")");
48805       }
48806       if (_contrast !== 1) {
48807         baseFilter += " contrast(".concat(_contrast, ")");
48808       }
48809       if (_saturation !== 1) {
48810         baseFilter += " saturate(".concat(_saturation, ")");
48811       }
48812       if (_sharpness < 1) {
48813         const blur = number_default(0.5, 5)(1 - _sharpness);
48814         baseFilter += " blur(".concat(blur, "px)");
48815       }
48816       let base = selection2.selectAll(".layer-background").data([0]);
48817       base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base);
48818       base.style("filter", baseFilter || null);
48819       let imagery = base.selectAll(".layer-imagery").data([0]);
48820       imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer);
48821       let maskFilter = "";
48822       let mixBlendMode = "";
48823       if (_sharpness > 1) {
48824         mixBlendMode = "overlay";
48825         maskFilter = "saturate(0) blur(3px) invert(1)";
48826         let contrast = _sharpness - 1;
48827         maskFilter += " contrast(".concat(contrast, ")");
48828         let brightness = number_default(1, 0.85)(_sharpness - 1);
48829         maskFilter += " brightness(".concat(brightness, ")");
48830       }
48831       let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []);
48832       mask.exit().remove();
48833       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);
48834       let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name());
48835       overlays.exit().remove();
48836       overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer));
48837     }
48838     background.updateImagery = function() {
48839       let currSource = baseLayer.source();
48840       if (context.inIntro() || !currSource)
48841         return;
48842       let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(",");
48843       const meters = geoOffsetToMeters(currSource.offset());
48844       const EPSILON = 0.01;
48845       const x2 = +meters[0].toFixed(2);
48846       const y2 = +meters[1].toFixed(2);
48847       let hash = utilStringQs(window.location.hash);
48848       let id2 = currSource.id;
48849       if (id2 === "custom") {
48850         id2 = "custom:".concat(currSource.template());
48851       }
48852       if (id2) {
48853         hash.background = id2;
48854       } else {
48855         delete hash.background;
48856       }
48857       if (o2) {
48858         hash.overlays = o2;
48859       } else {
48860         delete hash.overlays;
48861       }
48862       if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) {
48863         hash.offset = "".concat(x2, ",").concat(y2);
48864       } else {
48865         delete hash.offset;
48866       }
48867       if (!window.mocha) {
48868         window.location.replace("#" + utilQsString(hash, true));
48869       }
48870       let imageryUsed = [];
48871       let photoOverlaysUsed = [];
48872       const currUsed = currSource.imageryUsed();
48873       if (currUsed && _isValid) {
48874         imageryUsed.push(currUsed);
48875       }
48876       _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed()));
48877       const dataLayer = context.layers().layer("data");
48878       if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) {
48879         imageryUsed.push(dataLayer.getSrc());
48880       }
48881       const photoOverlayLayers = {
48882         streetside: "Bing Streetside",
48883         mapillary: "Mapillary Images",
48884         "mapillary-map-features": "Mapillary Map Features",
48885         "mapillary-signs": "Mapillary Signs",
48886         kartaview: "KartaView Images",
48887         vegbilder: "Norwegian Road Administration Images",
48888         mapilio: "Mapilio Images"
48889       };
48890       for (let layerID in photoOverlayLayers) {
48891         const layer = context.layers().layer(layerID);
48892         if (layer && layer.enabled()) {
48893           photoOverlaysUsed.push(layerID);
48894           imageryUsed.push(photoOverlayLayers[layerID]);
48895         }
48896       }
48897       context.history().imageryUsed(imageryUsed);
48898       context.history().photoOverlaysUsed(photoOverlaysUsed);
48899     };
48900     background.sources = (extent, zoom, includeCurrent) => {
48901       if (!_imageryIndex)
48902         return [];
48903       let visible = {};
48904       (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true);
48905       const currSource = baseLayer.source();
48906       const osm = context.connection();
48907       const blocklists = osm && osm.imageryBlocklists() || [];
48908       const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]);
48909       if (blocklistChanged) {
48910         _imageryIndex.backgrounds.forEach((source) => {
48911           source.isBlocked = blocklists.some((regex) => regex.test(source.template()));
48912         });
48913         _checkedBlocklists = blocklists.map((regex) => String(regex));
48914       }
48915       return _imageryIndex.backgrounds.filter((source) => {
48916         if (includeCurrent && currSource === source)
48917           return true;
48918         if (source.isBlocked)
48919           return false;
48920         if (!source.polygon)
48921           return true;
48922         if (zoom && zoom < 6)
48923           return false;
48924         return visible[source.id];
48925       });
48926     };
48927     background.dimensions = (val) => {
48928       if (!val)
48929         return;
48930       baseLayer.dimensions(val);
48931       _overlayLayers.forEach((layer) => layer.dimensions(val));
48932     };
48933     background.baseLayerSource = function(d2) {
48934       if (!arguments.length)
48935         return baseLayer.source();
48936       const osm = context.connection();
48937       if (!osm)
48938         return background;
48939       const blocklists = osm.imageryBlocklists();
48940       const template = d2.template();
48941       let fail = false;
48942       let tested = 0;
48943       let regex;
48944       for (let i3 = 0; i3 < blocklists.length; i3++) {
48945         regex = blocklists[i3];
48946         fail = regex.test(template);
48947         tested++;
48948         if (fail)
48949           break;
48950       }
48951       if (!tested) {
48952         regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
48953         fail = regex.test(template);
48954       }
48955       baseLayer.source(!fail ? d2 : background.findSource("none"));
48956       dispatch14.call("change");
48957       background.updateImagery();
48958       return background;
48959     };
48960     background.findSource = (id2) => {
48961       if (!id2 || !_imageryIndex)
48962         return null;
48963       return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2);
48964     };
48965     background.bing = () => {
48966       background.baseLayerSource(background.findSource("Bing"));
48967     };
48968     background.showsLayer = (d2) => {
48969       const currSource = baseLayer.source();
48970       if (!d2 || !currSource)
48971         return false;
48972       return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id);
48973     };
48974     background.overlayLayerSources = () => {
48975       return _overlayLayers.map((layer) => layer.source());
48976     };
48977     background.toggleOverlayLayer = (d2) => {
48978       let layer;
48979       for (let i3 = 0; i3 < _overlayLayers.length; i3++) {
48980         layer = _overlayLayers[i3];
48981         if (layer.source() === d2) {
48982           _overlayLayers.splice(i3, 1);
48983           dispatch14.call("change");
48984           background.updateImagery();
48985           return;
48986         }
48987       }
48988       layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions(
48989         baseLayer.dimensions()
48990       );
48991       _overlayLayers.push(layer);
48992       dispatch14.call("change");
48993       background.updateImagery();
48994     };
48995     background.nudge = (d2, zoom) => {
48996       const currSource = baseLayer.source();
48997       if (currSource) {
48998         currSource.nudge(d2, zoom);
48999         dispatch14.call("change");
49000         background.updateImagery();
49001       }
49002       return background;
49003     };
49004     background.offset = function(d2) {
49005       const currSource = baseLayer.source();
49006       if (!arguments.length) {
49007         return currSource && currSource.offset() || [0, 0];
49008       }
49009       if (currSource) {
49010         currSource.offset(d2);
49011         dispatch14.call("change");
49012         background.updateImagery();
49013       }
49014       return background;
49015     };
49016     background.brightness = function(d2) {
49017       if (!arguments.length)
49018         return _brightness;
49019       _brightness = d2;
49020       if (context.mode())
49021         dispatch14.call("change");
49022       return background;
49023     };
49024     background.contrast = function(d2) {
49025       if (!arguments.length)
49026         return _contrast;
49027       _contrast = d2;
49028       if (context.mode())
49029         dispatch14.call("change");
49030       return background;
49031     };
49032     background.saturation = function(d2) {
49033       if (!arguments.length)
49034         return _saturation;
49035       _saturation = d2;
49036       if (context.mode())
49037         dispatch14.call("change");
49038       return background;
49039     };
49040     background.sharpness = function(d2) {
49041       if (!arguments.length)
49042         return _sharpness;
49043       _sharpness = d2;
49044       if (context.mode())
49045         dispatch14.call("change");
49046       return background;
49047     };
49048     let _loadPromise;
49049     background.ensureLoaded = () => {
49050       if (_loadPromise)
49051         return _loadPromise;
49052       return _loadPromise = ensureImageryIndex();
49053     };
49054     background.init = () => {
49055       const loadPromise = background.ensureLoaded();
49056       const hash = utilStringQs(window.location.hash);
49057       const requestedBackground = hash.background || hash.layer;
49058       const lastUsedBackground = corePreferences("background-last-used");
49059       return loadPromise.then((imageryIndex) => {
49060         const extent = context.map().extent();
49061         const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom");
49062         const first = validBackgrounds.length && validBackgrounds[0];
49063         const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground);
49064         let best;
49065         if (!requestedBackground && extent) {
49066           const viewArea = extent.area();
49067           best = validBackgrounds.find((s2) => {
49068             if (!s2.best() || s2.overlay)
49069               return false;
49070             let bbox2 = es_default(bboxClip(
49071               { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] },
49072               extent.rectangle()
49073             ));
49074             let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area();
49075             return area / viewArea > 0.5;
49076           });
49077         }
49078         if (requestedBackground && requestedBackground.indexOf("custom:") === 0) {
49079           const template = requestedBackground.replace(/^custom:/, "");
49080           const custom = background.findSource("custom");
49081           background.baseLayerSource(custom.template(template));
49082           corePreferences("background-custom-template", template);
49083         } else {
49084           background.baseLayerSource(
49085             background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none")
49086           );
49087         }
49088         const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default);
49089         if (locator) {
49090           background.toggleOverlayLayer(locator);
49091         }
49092         const overlays = (hash.overlays || "").split(",");
49093         overlays.forEach((overlay) => {
49094           overlay = background.findSource(overlay);
49095           if (overlay) {
49096             background.toggleOverlayLayer(overlay);
49097           }
49098         });
49099         if (hash.gpx) {
49100           const gpx2 = context.layers().layer("data");
49101           if (gpx2) {
49102             gpx2.url(hash.gpx, ".gpx");
49103           }
49104         }
49105         if (hash.offset) {
49106           const offset = hash.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3);
49107           if (offset.length === 2) {
49108             background.offset(geoMetersToOffset(offset));
49109           }
49110         }
49111       }).catch((err) => {
49112         console.error(err);
49113       });
49114     };
49115     return utilRebind(background, dispatch14, "on");
49116   }
49117
49118   // modules/renderer/features.js
49119   function rendererFeatures(context) {
49120     var dispatch14 = dispatch_default("change", "redraw");
49121     var features = utilRebind({}, dispatch14, "on");
49122     var _deferred2 = /* @__PURE__ */ new Set();
49123     var traffic_roads = {
49124       "motorway": true,
49125       "motorway_link": true,
49126       "trunk": true,
49127       "trunk_link": true,
49128       "primary": true,
49129       "primary_link": true,
49130       "secondary": true,
49131       "secondary_link": true,
49132       "tertiary": true,
49133       "tertiary_link": true,
49134       "residential": true,
49135       "unclassified": true,
49136       "living_street": true,
49137       "busway": true
49138     };
49139     var service_roads = {
49140       "service": true,
49141       "road": true,
49142       "track": true
49143     };
49144     var paths = {
49145       "path": true,
49146       "footway": true,
49147       "cycleway": true,
49148       "bridleway": true,
49149       "steps": true,
49150       "pedestrian": true
49151     };
49152     var _cullFactor = 1;
49153     var _cache5 = {};
49154     var _rules = {};
49155     var _stats = {};
49156     var _keys = [];
49157     var _hidden = [];
49158     var _forceVisible = {};
49159     function update() {
49160       if (!window.mocha) {
49161         var hash = utilStringQs(window.location.hash);
49162         var disabled = features.disabled();
49163         if (disabled.length) {
49164           hash.disable_features = disabled.join(",");
49165         } else {
49166           delete hash.disable_features;
49167         }
49168         window.location.replace("#" + utilQsString(hash, true));
49169         corePreferences("disabled-features", disabled.join(","));
49170       }
49171       _hidden = features.hidden();
49172       dispatch14.call("change");
49173       dispatch14.call("redraw");
49174     }
49175     function defineRule(k2, filter2, max3) {
49176       var isEnabled = true;
49177       _keys.push(k2);
49178       _rules[k2] = {
49179         filter: filter2,
49180         enabled: isEnabled,
49181         // whether the user wants it enabled..
49182         count: 0,
49183         currentMax: max3 || Infinity,
49184         defaultMax: max3 || Infinity,
49185         enable: function() {
49186           this.enabled = true;
49187           this.currentMax = this.defaultMax;
49188         },
49189         disable: function() {
49190           this.enabled = false;
49191           this.currentMax = 0;
49192         },
49193         hidden: function() {
49194           return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor;
49195         },
49196         autoHidden: function() {
49197           return this.hidden() && this.currentMax > 0;
49198         }
49199       };
49200     }
49201     defineRule("points", function isPoint(tags, geometry) {
49202       return geometry === "point";
49203     }, 200);
49204     defineRule("traffic_roads", function isTrafficRoad(tags) {
49205       return traffic_roads[tags.highway];
49206     });
49207     defineRule("service_roads", function isServiceRoad(tags) {
49208       return service_roads[tags.highway];
49209     });
49210     defineRule("paths", function isPath(tags) {
49211       return paths[tags.highway];
49212     });
49213     defineRule("buildings", function isBuilding(tags) {
49214       return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes";
49215     }, 250);
49216     defineRule("building_parts", function isBuildingPart(tags) {
49217       return tags["building:part"];
49218     });
49219     defineRule("indoor", function isIndoor(tags) {
49220       return tags.indoor;
49221     });
49222     defineRule("landuse", function isLanduse(tags, geometry) {
49223       return geometry === "area" && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags);
49224     });
49225     defineRule("boundaries", function isBoundary(tags, geometry) {
49226       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);
49227     });
49228     defineRule("water", function isWater(tags) {
49229       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";
49230     });
49231     defineRule("rail", function isRail(tags) {
49232       return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]);
49233     });
49234     defineRule("pistes", function isPiste(tags) {
49235       return tags["piste:type"];
49236     });
49237     defineRule("aerialways", function isPiste(tags) {
49238       return tags.aerialway && tags.aerialway !== "yes" && tags.aerialway !== "station";
49239     });
49240     defineRule("power", function isPower(tags) {
49241       return !!tags.power;
49242     });
49243     defineRule("past_future", function isPastFuture(tags) {
49244       if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) {
49245         return false;
49246       }
49247       var strings = Object.keys(tags);
49248       for (var i3 = 0; i3 < strings.length; i3++) {
49249         var s2 = strings[i3];
49250         if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[s2]])
49251           return true;
49252       }
49253       return false;
49254     });
49255     defineRule("others", function isOther(tags, geometry) {
49256       return geometry === "line" || geometry === "area";
49257     });
49258     features.features = function() {
49259       return _rules;
49260     };
49261     features.keys = function() {
49262       return _keys;
49263     };
49264     features.enabled = function(k2) {
49265       if (!arguments.length) {
49266         return _keys.filter(function(k3) {
49267           return _rules[k3].enabled;
49268         });
49269       }
49270       return _rules[k2] && _rules[k2].enabled;
49271     };
49272     features.disabled = function(k2) {
49273       if (!arguments.length) {
49274         return _keys.filter(function(k3) {
49275           return !_rules[k3].enabled;
49276         });
49277       }
49278       return _rules[k2] && !_rules[k2].enabled;
49279     };
49280     features.hidden = function(k2) {
49281       if (!arguments.length) {
49282         return _keys.filter(function(k3) {
49283           return _rules[k3].hidden();
49284         });
49285       }
49286       return _rules[k2] && _rules[k2].hidden();
49287     };
49288     features.autoHidden = function(k2) {
49289       if (!arguments.length) {
49290         return _keys.filter(function(k3) {
49291           return _rules[k3].autoHidden();
49292         });
49293       }
49294       return _rules[k2] && _rules[k2].autoHidden();
49295     };
49296     features.enable = function(k2) {
49297       if (_rules[k2] && !_rules[k2].enabled) {
49298         _rules[k2].enable();
49299         update();
49300       }
49301     };
49302     features.enableAll = function() {
49303       var didEnable = false;
49304       for (var k2 in _rules) {
49305         if (!_rules[k2].enabled) {
49306           didEnable = true;
49307           _rules[k2].enable();
49308         }
49309       }
49310       if (didEnable)
49311         update();
49312     };
49313     features.disable = function(k2) {
49314       if (_rules[k2] && _rules[k2].enabled) {
49315         _rules[k2].disable();
49316         update();
49317       }
49318     };
49319     features.disableAll = function() {
49320       var didDisable = false;
49321       for (var k2 in _rules) {
49322         if (_rules[k2].enabled) {
49323           didDisable = true;
49324           _rules[k2].disable();
49325         }
49326       }
49327       if (didDisable)
49328         update();
49329     };
49330     features.toggle = function(k2) {
49331       if (_rules[k2]) {
49332         (function(f2) {
49333           return f2.enabled ? f2.disable() : f2.enable();
49334         })(_rules[k2]);
49335         update();
49336       }
49337     };
49338     features.resetStats = function() {
49339       for (var i3 = 0; i3 < _keys.length; i3++) {
49340         _rules[_keys[i3]].count = 0;
49341       }
49342       dispatch14.call("change");
49343     };
49344     features.gatherStats = function(d2, resolver, dimensions) {
49345       var needsRedraw = false;
49346       var types = utilArrayGroupBy(d2, "type");
49347       var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49348       var currHidden, geometry, matches, i3, j2;
49349       for (i3 = 0; i3 < _keys.length; i3++) {
49350         _rules[_keys[i3]].count = 0;
49351       }
49352       _cullFactor = dimensions[0] * dimensions[1] / 1e6;
49353       for (i3 = 0; i3 < entities.length; i3++) {
49354         geometry = entities[i3].geometry(resolver);
49355         matches = Object.keys(features.getMatches(entities[i3], resolver, geometry));
49356         for (j2 = 0; j2 < matches.length; j2++) {
49357           _rules[matches[j2]].count++;
49358         }
49359       }
49360       currHidden = features.hidden();
49361       if (currHidden !== _hidden) {
49362         _hidden = currHidden;
49363         needsRedraw = true;
49364         dispatch14.call("change");
49365       }
49366       return needsRedraw;
49367     };
49368     features.stats = function() {
49369       for (var i3 = 0; i3 < _keys.length; i3++) {
49370         _stats[_keys[i3]] = _rules[_keys[i3]].count;
49371       }
49372       return _stats;
49373     };
49374     features.clear = function(d2) {
49375       for (var i3 = 0; i3 < d2.length; i3++) {
49376         features.clearEntity(d2[i3]);
49377       }
49378     };
49379     features.clearEntity = function(entity) {
49380       delete _cache5[osmEntity.key(entity)];
49381     };
49382     features.reset = function() {
49383       Array.from(_deferred2).forEach(function(handle) {
49384         window.cancelIdleCallback(handle);
49385         _deferred2.delete(handle);
49386       });
49387       _cache5 = {};
49388     };
49389     function relationShouldBeChecked(relation) {
49390       return relation.tags.type === "boundary";
49391     }
49392     features.getMatches = function(entity, resolver, geometry) {
49393       if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity))
49394         return {};
49395       var ent = osmEntity.key(entity);
49396       if (!_cache5[ent]) {
49397         _cache5[ent] = {};
49398       }
49399       if (!_cache5[ent].matches) {
49400         var matches = {};
49401         var hasMatch = false;
49402         for (var i3 = 0; i3 < _keys.length; i3++) {
49403           if (_keys[i3] === "others") {
49404             if (hasMatch)
49405               continue;
49406             if (entity.type === "way") {
49407               var parents = features.getParents(entity, resolver, geometry);
49408               if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations
49409               parents.length > 0 && parents.every(function(parent) {
49410                 return parent.tags.type === "boundary";
49411               })) {
49412                 var pkey = osmEntity.key(parents[0]);
49413                 if (_cache5[pkey] && _cache5[pkey].matches) {
49414                   matches = Object.assign({}, _cache5[pkey].matches);
49415                   continue;
49416                 }
49417               }
49418             }
49419           }
49420           if (_rules[_keys[i3]].filter(entity.tags, geometry)) {
49421             matches[_keys[i3]] = hasMatch = true;
49422           }
49423         }
49424         _cache5[ent].matches = matches;
49425       }
49426       return _cache5[ent].matches;
49427     };
49428     features.getParents = function(entity, resolver, geometry) {
49429       if (geometry === "point")
49430         return [];
49431       var ent = osmEntity.key(entity);
49432       if (!_cache5[ent]) {
49433         _cache5[ent] = {};
49434       }
49435       if (!_cache5[ent].parents) {
49436         var parents = [];
49437         if (geometry === "vertex") {
49438           parents = resolver.parentWays(entity);
49439         } else {
49440           parents = resolver.parentRelations(entity);
49441         }
49442         _cache5[ent].parents = parents;
49443       }
49444       return _cache5[ent].parents;
49445     };
49446     features.isHiddenPreset = function(preset, geometry) {
49447       if (!_hidden.length)
49448         return false;
49449       if (!preset.tags)
49450         return false;
49451       var test = preset.setTags({}, geometry);
49452       for (var key in _rules) {
49453         if (_rules[key].filter(test, geometry)) {
49454           if (_hidden.indexOf(key) !== -1) {
49455             return key;
49456           }
49457           return false;
49458         }
49459       }
49460       return false;
49461     };
49462     features.isHiddenFeature = function(entity, resolver, geometry) {
49463       if (!_hidden.length)
49464         return false;
49465       if (!entity.version)
49466         return false;
49467       if (_forceVisible[entity.id])
49468         return false;
49469       var matches = Object.keys(features.getMatches(entity, resolver, geometry));
49470       return matches.length && matches.every(function(k2) {
49471         return features.hidden(k2);
49472       });
49473     };
49474     features.isHiddenChild = function(entity, resolver, geometry) {
49475       if (!_hidden.length)
49476         return false;
49477       if (!entity.version || geometry === "point")
49478         return false;
49479       if (_forceVisible[entity.id])
49480         return false;
49481       var parents = features.getParents(entity, resolver, geometry);
49482       if (!parents.length)
49483         return false;
49484       for (var i3 = 0; i3 < parents.length; i3++) {
49485         if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) {
49486           return false;
49487         }
49488       }
49489       return true;
49490     };
49491     features.hasHiddenConnections = function(entity, resolver) {
49492       if (!_hidden.length)
49493         return false;
49494       var childNodes, connections;
49495       if (entity.type === "midpoint") {
49496         childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
49497         connections = [];
49498       } else {
49499         childNodes = entity.nodes ? resolver.childNodes(entity) : [];
49500         connections = features.getParents(entity, resolver, entity.geometry(resolver));
49501       }
49502       connections = childNodes.reduce(function(result, e3) {
49503         return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result;
49504       }, connections);
49505       return connections.some(function(e3) {
49506         return features.isHidden(e3, resolver, e3.geometry(resolver));
49507       });
49508     };
49509     features.isHidden = function(entity, resolver, geometry) {
49510       if (!_hidden.length)
49511         return false;
49512       if (!entity.version)
49513         return false;
49514       var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature;
49515       return fn(entity, resolver, geometry);
49516     };
49517     features.filter = function(d2, resolver) {
49518       if (!_hidden.length)
49519         return d2;
49520       var result = [];
49521       for (var i3 = 0; i3 < d2.length; i3++) {
49522         var entity = d2[i3];
49523         if (!features.isHidden(entity, resolver, entity.geometry(resolver))) {
49524           result.push(entity);
49525         }
49526       }
49527       return result;
49528     };
49529     features.forceVisible = function(entityIDs) {
49530       if (!arguments.length)
49531         return Object.keys(_forceVisible);
49532       _forceVisible = {};
49533       for (var i3 = 0; i3 < entityIDs.length; i3++) {
49534         _forceVisible[entityIDs[i3]] = true;
49535         var entity = context.hasEntity(entityIDs[i3]);
49536         if (entity && entity.type === "relation") {
49537           for (var j2 in entity.members) {
49538             _forceVisible[entity.members[j2].id] = true;
49539           }
49540         }
49541       }
49542       return features;
49543     };
49544     features.init = function() {
49545       var storage = corePreferences("disabled-features");
49546       if (storage) {
49547         var storageDisabled = storage.replace(/;/g, ",").split(",");
49548         storageDisabled.forEach(features.disable);
49549       }
49550       var hash = utilStringQs(window.location.hash);
49551       if (hash.disable_features) {
49552         var hashDisabled = hash.disable_features.replace(/;/g, ",").split(",");
49553         hashDisabled.forEach(features.disable);
49554       }
49555     };
49556     context.history().on("merge.features", function(newEntities) {
49557       if (!newEntities)
49558         return;
49559       var handle = window.requestIdleCallback(function() {
49560         var graph = context.graph();
49561         var types = utilArrayGroupBy(newEntities, "type");
49562         var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49563         for (var i3 = 0; i3 < entities.length; i3++) {
49564           var geometry = entities[i3].geometry(graph);
49565           features.getMatches(entities[i3], graph, geometry);
49566         }
49567       });
49568       _deferred2.add(handle);
49569     });
49570     return features;
49571   }
49572
49573   // modules/svg/areas.js
49574   var import_fast_deep_equal5 = __toESM(require_fast_deep_equal());
49575
49576   // modules/svg/helpers.js
49577   function svgPassiveVertex(node, graph, activeID) {
49578     if (!activeID)
49579       return 1;
49580     if (activeID === node.id)
49581       return 0;
49582     var parents = graph.parentWays(node);
49583     var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3;
49584     for (i3 = 0; i3 < parents.length; i3++) {
49585       nodes = parents[i3].nodes;
49586       isClosed = parents[i3].isClosed();
49587       for (j2 = 0; j2 < nodes.length; j2++) {
49588         if (nodes[j2] === node.id) {
49589           ix1 = j2 - 2;
49590           ix2 = j2 - 1;
49591           ix3 = j2 + 1;
49592           ix4 = j2 + 2;
49593           if (isClosed) {
49594             max3 = nodes.length - 1;
49595             if (ix1 < 0)
49596               ix1 = max3 + ix1;
49597             if (ix2 < 0)
49598               ix2 = max3 + ix2;
49599             if (ix3 > max3)
49600               ix3 = ix3 - max3;
49601             if (ix4 > max3)
49602               ix4 = ix4 - max3;
49603           }
49604           if (nodes[ix1] === activeID)
49605             return 0;
49606           else if (nodes[ix2] === activeID)
49607             return 2;
49608           else if (nodes[ix3] === activeID)
49609             return 2;
49610           else if (nodes[ix4] === activeID)
49611             return 0;
49612           else if (isClosed && nodes.indexOf(activeID) !== -1)
49613             return 0;
49614         }
49615       }
49616     }
49617     return 1;
49618   }
49619   function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) {
49620     return function(entity) {
49621       var i3 = 0;
49622       var offset = dt2;
49623       var segments = [];
49624       var clip = identity_default2().clipExtent(projection2.clipExtent()).stream;
49625       var coordinates = graph.childNodes(entity).map(function(n3) {
49626         return n3.loc;
49627       });
49628       var a2, b2;
49629       if (shouldReverse(entity)) {
49630         coordinates.reverse();
49631       }
49632       stream_default({
49633         type: "LineString",
49634         coordinates
49635       }, projection2.stream(clip({
49636         lineStart: function() {
49637         },
49638         lineEnd: function() {
49639           a2 = null;
49640         },
49641         point: function(x2, y2) {
49642           b2 = [x2, y2];
49643           if (a2) {
49644             var span = geoVecLength(a2, b2) - offset;
49645             if (span >= 0) {
49646               var heading2 = geoVecAngle(a2, b2);
49647               var dx = dt2 * Math.cos(heading2);
49648               var dy = dt2 * Math.sin(heading2);
49649               var p2 = [
49650                 a2[0] + offset * Math.cos(heading2),
49651                 a2[1] + offset * Math.sin(heading2)
49652               ];
49653               var coord2 = [a2, p2];
49654               for (span -= dt2; span >= 0; span -= dt2) {
49655                 p2 = geoVecAdd(p2, [dx, dy]);
49656                 coord2.push(p2);
49657               }
49658               coord2.push(b2);
49659               var segment = "";
49660               var j2;
49661               for (j2 = 0; j2 < coord2.length; j2++) {
49662                 segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49663               }
49664               segments.push({ id: entity.id, index: i3++, d: segment });
49665               if (bothDirections(entity)) {
49666                 segment = "";
49667                 for (j2 = coord2.length - 1; j2 >= 0; j2--) {
49668                   segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49669                 }
49670                 segments.push({ id: entity.id, index: i3++, d: segment });
49671               }
49672             }
49673             offset = -span;
49674           }
49675           a2 = b2;
49676         }
49677       })));
49678       return segments;
49679     };
49680   }
49681   function svgPath(projection2, graph, isArea) {
49682     var cache = {};
49683     var padding = isArea ? 65 : 5;
49684     var viewport = projection2.clipExtent();
49685     var paddedExtent = [
49686       [viewport[0][0] - padding, viewport[0][1] - padding],
49687       [viewport[1][0] + padding, viewport[1][1] + padding]
49688     ];
49689     var clip = identity_default2().clipExtent(paddedExtent).stream;
49690     var project = projection2.stream;
49691     var path = path_default().projection({ stream: function(output) {
49692       return project(clip(output));
49693     } });
49694     var svgpath = function(entity) {
49695       if (entity.id in cache) {
49696         return cache[entity.id];
49697       } else {
49698         return cache[entity.id] = path(entity.asGeoJSON(graph));
49699       }
49700     };
49701     svgpath.geojson = function(d2) {
49702       if (d2.__featurehash__ !== void 0) {
49703         if (d2.__featurehash__ in cache) {
49704           return cache[d2.__featurehash__];
49705         } else {
49706           return cache[d2.__featurehash__] = path(d2);
49707         }
49708       } else {
49709         return path(d2);
49710       }
49711     };
49712     return svgpath;
49713   }
49714   function svgPointTransform(projection2) {
49715     var svgpoint = function(entity) {
49716       var pt2 = projection2(entity.loc);
49717       return "translate(" + pt2[0] + "," + pt2[1] + ")";
49718     };
49719     svgpoint.geojson = function(d2) {
49720       return svgpoint(d2.properties.entity);
49721     };
49722     return svgpoint;
49723   }
49724   function svgRelationMemberTags(graph) {
49725     return function(entity) {
49726       var tags = entity.tags;
49727       var shouldCopyMultipolygonTags = !entity.hasInterestingTags();
49728       graph.parentRelations(entity).forEach(function(relation) {
49729         var type2 = relation.tags.type;
49730         if (type2 === "multipolygon" && shouldCopyMultipolygonTags || type2 === "boundary") {
49731           tags = Object.assign({}, relation.tags, tags);
49732         }
49733       });
49734       return tags;
49735     };
49736   }
49737   function svgSegmentWay(way, graph, activeID) {
49738     if (activeID === void 0) {
49739       return graph.transient(way, "waySegments", getWaySegments);
49740     } else {
49741       return getWaySegments();
49742     }
49743     function getWaySegments() {
49744       var isActiveWay = way.nodes.indexOf(activeID) !== -1;
49745       var features = { passive: [], active: [] };
49746       var start2 = {};
49747       var end = {};
49748       var node, type2;
49749       for (var i3 = 0; i3 < way.nodes.length; i3++) {
49750         node = graph.entity(way.nodes[i3]);
49751         type2 = svgPassiveVertex(node, graph, activeID);
49752         end = { node, type: type2 };
49753         if (start2.type !== void 0) {
49754           if (start2.node.id === activeID || end.node.id === activeID) {
49755           } else if (isActiveWay && (start2.type === 2 || end.type === 2)) {
49756             pushActive(start2, end, i3);
49757           } else if (start2.type === 0 && end.type === 0) {
49758             pushActive(start2, end, i3);
49759           } else {
49760             pushPassive(start2, end, i3);
49761           }
49762         }
49763         start2 = end;
49764       }
49765       return features;
49766       function pushActive(start3, end2, index) {
49767         features.active.push({
49768           type: "Feature",
49769           id: way.id + "-" + index + "-nope",
49770           properties: {
49771             nope: true,
49772             target: true,
49773             entity: way,
49774             nodes: [start3.node, end2.node],
49775             index
49776           },
49777           geometry: {
49778             type: "LineString",
49779             coordinates: [start3.node.loc, end2.node.loc]
49780           }
49781         });
49782       }
49783       function pushPassive(start3, end2, index) {
49784         features.passive.push({
49785           type: "Feature",
49786           id: way.id + "-" + index,
49787           properties: {
49788             target: true,
49789             entity: way,
49790             nodes: [start3.node, end2.node],
49791             index
49792           },
49793           geometry: {
49794             type: "LineString",
49795             coordinates: [start3.node.loc, end2.node.loc]
49796           }
49797         });
49798       }
49799     }
49800   }
49801
49802   // modules/svg/tag_classes.js
49803   function svgTagClasses() {
49804     var primaries = [
49805       "building",
49806       "highway",
49807       "railway",
49808       "waterway",
49809       "aeroway",
49810       "aerialway",
49811       "piste:type",
49812       "boundary",
49813       "power",
49814       "amenity",
49815       "natural",
49816       "landuse",
49817       "leisure",
49818       "military",
49819       "place",
49820       "man_made",
49821       "route",
49822       "attraction",
49823       "roller_coaster",
49824       "building:part",
49825       "indoor"
49826     ];
49827     var statuses = Object.keys(osmLifecyclePrefixes);
49828     var secondaries = [
49829       "oneway",
49830       "bridge",
49831       "tunnel",
49832       "embankment",
49833       "cutting",
49834       "barrier",
49835       "surface",
49836       "tracktype",
49837       "footway",
49838       "crossing",
49839       "service",
49840       "sport",
49841       "public_transport",
49842       "location",
49843       "parking",
49844       "golf",
49845       "type",
49846       "leisure",
49847       "man_made",
49848       "indoor",
49849       "construction",
49850       "proposed"
49851     ];
49852     var _tags = function(entity) {
49853       return entity.tags;
49854     };
49855     var tagClasses = function(selection2) {
49856       selection2.each(function tagClassesEach(entity) {
49857         var value = this.className;
49858         if (value.baseVal !== void 0) {
49859           value = value.baseVal;
49860         }
49861         var t2 = _tags(entity);
49862         var computed = tagClasses.getClassesString(t2, value);
49863         if (computed !== value) {
49864           select_default2(this).attr("class", computed);
49865         }
49866       });
49867     };
49868     tagClasses.getClassesString = function(t2, value) {
49869       var primary, status;
49870       var i3, j2, k2, v2;
49871       var overrideGeometry;
49872       if (/\bstroke\b/.test(value)) {
49873         if (!!t2.barrier && t2.barrier !== "no") {
49874           overrideGeometry = "line";
49875         }
49876       }
49877       var classes = value.trim().split(/\s+/).filter(function(klass) {
49878         return klass.length && !/^tag-/.test(klass);
49879       }).map(function(klass) {
49880         return klass === "line" || klass === "area" ? overrideGeometry || klass : klass;
49881       });
49882       for (i3 = 0; i3 < primaries.length; i3++) {
49883         k2 = primaries[i3];
49884         v2 = t2[k2];
49885         if (!v2 || v2 === "no")
49886           continue;
49887         if (k2 === "piste:type") {
49888           k2 = "piste";
49889         } else if (k2 === "building:part") {
49890           k2 = "building_part";
49891         }
49892         primary = k2;
49893         if (statuses.indexOf(v2) !== -1) {
49894           status = v2;
49895           classes.push("tag-" + k2);
49896         } else {
49897           classes.push("tag-" + k2);
49898           classes.push("tag-" + k2 + "-" + v2);
49899         }
49900         break;
49901       }
49902       if (!primary) {
49903         for (i3 = 0; i3 < statuses.length; i3++) {
49904           for (j2 = 0; j2 < primaries.length; j2++) {
49905             k2 = statuses[i3] + ":" + primaries[j2];
49906             v2 = t2[k2];
49907             if (!v2 || v2 === "no")
49908               continue;
49909             status = statuses[i3];
49910             break;
49911           }
49912         }
49913       }
49914       if (!status) {
49915         for (i3 = 0; i3 < statuses.length; i3++) {
49916           k2 = statuses[i3];
49917           v2 = t2[k2];
49918           if (!v2 || v2 === "no")
49919             continue;
49920           if (v2 === "yes") {
49921             status = k2;
49922           } else if (primary && primary === v2) {
49923             status = k2;
49924           } else if (!primary && primaries.indexOf(v2) !== -1) {
49925             status = k2;
49926             primary = v2;
49927             classes.push("tag-" + v2);
49928           }
49929           if (status)
49930             break;
49931         }
49932       }
49933       if (status) {
49934         classes.push("tag-status");
49935         classes.push("tag-status-" + status);
49936       }
49937       for (i3 = 0; i3 < secondaries.length; i3++) {
49938         k2 = secondaries[i3];
49939         v2 = t2[k2];
49940         if (!v2 || v2 === "no" || k2 === primary)
49941           continue;
49942         classes.push("tag-" + k2);
49943         classes.push("tag-" + k2 + "-" + v2);
49944       }
49945       if (primary === "highway" && !osmPathHighwayTagValues[t2.highway] || primary === "aeroway") {
49946         var surface = t2.highway === "track" ? "unpaved" : "paved";
49947         for (k2 in t2) {
49948           v2 = t2[k2];
49949           if (k2 in osmPavedTags) {
49950             surface = osmPavedTags[k2][v2] ? "paved" : "unpaved";
49951           }
49952           if (k2 in osmSemipavedTags && !!osmSemipavedTags[k2][v2]) {
49953             surface = "semipaved";
49954           }
49955         }
49956         classes.push("tag-" + surface);
49957       }
49958       var qid = t2.wikidata || t2["flag:wikidata"] || t2["brand:wikidata"] || t2["network:wikidata"] || t2["operator:wikidata"];
49959       if (qid) {
49960         classes.push("tag-wikidata");
49961       }
49962       return classes.filter((klass) => /^[-_a-z0-9]+$/.test(klass)).join(" ").trim();
49963     };
49964     tagClasses.tags = function(val) {
49965       if (!arguments.length)
49966         return _tags;
49967       _tags = val;
49968       return tagClasses;
49969     };
49970     return tagClasses;
49971   }
49972
49973   // modules/svg/tag_pattern.js
49974   var patterns = {
49975     // tag - pattern name
49976     // -or-
49977     // tag - value - pattern name
49978     // -or-
49979     // tag - value - rules (optional tag-values, pattern name)
49980     // (matches earlier rules first, so fallback should be last entry)
49981     amenity: {
49982       grave_yard: "cemetery",
49983       fountain: "water_standing"
49984     },
49985     landuse: {
49986       cemetery: [
49987         { religion: "christian", pattern: "cemetery_christian" },
49988         { religion: "buddhist", pattern: "cemetery_buddhist" },
49989         { religion: "muslim", pattern: "cemetery_muslim" },
49990         { religion: "jewish", pattern: "cemetery_jewish" },
49991         { pattern: "cemetery" }
49992       ],
49993       construction: "construction",
49994       farmland: "farmland",
49995       farmyard: "farmyard",
49996       forest: [
49997         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
49998         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
49999         { leaf_type: "leafless", pattern: "forest_leafless" },
50000         { pattern: "forest" }
50001         // same as 'leaf_type:mixed'
50002       ],
50003       grave_yard: "cemetery",
50004       grass: "grass",
50005       landfill: "landfill",
50006       meadow: "meadow",
50007       military: "construction",
50008       orchard: "orchard",
50009       quarry: "quarry",
50010       vineyard: "vineyard"
50011     },
50012     leisure: {
50013       horse_riding: "farmyard"
50014     },
50015     natural: {
50016       beach: "beach",
50017       grassland: "grass",
50018       sand: "beach",
50019       scrub: "scrub",
50020       water: [
50021         { water: "pond", pattern: "pond" },
50022         { water: "reservoir", pattern: "water_standing" },
50023         { pattern: "waves" }
50024       ],
50025       wetland: [
50026         { wetland: "marsh", pattern: "wetland_marsh" },
50027         { wetland: "swamp", pattern: "wetland_swamp" },
50028         { wetland: "bog", pattern: "wetland_bog" },
50029         { wetland: "reedbed", pattern: "wetland_reedbed" },
50030         { pattern: "wetland" }
50031       ],
50032       wood: [
50033         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
50034         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
50035         { leaf_type: "leafless", pattern: "forest_leafless" },
50036         { pattern: "forest" }
50037         // same as 'leaf_type:mixed'
50038       ]
50039     },
50040     golf: {
50041       green: "golf_green",
50042       tee: "grass",
50043       fairway: "grass",
50044       rough: "scrub"
50045     },
50046     surface: {
50047       grass: "grass",
50048       sand: "beach"
50049     }
50050   };
50051   function svgTagPattern(tags) {
50052     if (tags.building && tags.building !== "no") {
50053       return null;
50054     }
50055     for (var tag2 in patterns) {
50056       var entityValue = tags[tag2];
50057       if (!entityValue)
50058         continue;
50059       if (typeof patterns[tag2] === "string") {
50060         return "pattern-" + patterns[tag2];
50061       } else {
50062         var values = patterns[tag2];
50063         for (var value in values) {
50064           if (entityValue !== value)
50065             continue;
50066           var rules = values[value];
50067           if (typeof rules === "string") {
50068             return "pattern-" + rules;
50069           }
50070           for (var ruleKey in rules) {
50071             var rule = rules[ruleKey];
50072             var pass = true;
50073             for (var criterion in rule) {
50074               if (criterion !== "pattern") {
50075                 var v2 = tags[criterion];
50076                 if (!v2 || v2 !== rule[criterion]) {
50077                   pass = false;
50078                   break;
50079                 }
50080               }
50081             }
50082             if (pass) {
50083               return "pattern-" + rule.pattern;
50084             }
50085           }
50086         }
50087       }
50088     }
50089     return null;
50090   }
50091
50092   // modules/svg/areas.js
50093   function svgAreas(projection2, context) {
50094     function getPatternStyle(tags) {
50095       var imageID = svgTagPattern(tags);
50096       if (imageID) {
50097         return 'url("#ideditor-' + imageID + '")';
50098       }
50099       return "";
50100     }
50101     function drawTargets(selection2, graph, entities, filter2) {
50102       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
50103       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
50104       var getPath = svgPath(projection2).geojson;
50105       var activeID = context.activeID();
50106       var base = context.history().base();
50107       var data = { targets: [], nopes: [] };
50108       entities.forEach(function(way) {
50109         var features = svgSegmentWay(way, graph, activeID);
50110         data.targets.push.apply(data.targets, features.passive);
50111         data.nopes.push.apply(data.nopes, features.active);
50112       });
50113       var targetData = data.targets.filter(getPath);
50114       var targets = selection2.selectAll(".area.target-allowed").filter(function(d2) {
50115         return filter2(d2.properties.entity);
50116       }).data(targetData, function key(d2) {
50117         return d2.id;
50118       });
50119       targets.exit().remove();
50120       var segmentWasEdited = function(d2) {
50121         var wayID = d2.properties.entity.id;
50122         if (!base.entities[wayID] || !(0, import_fast_deep_equal5.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
50123           return false;
50124         }
50125         return d2.properties.nodes.some(function(n3) {
50126           return !base.entities[n3.id] || !(0, import_fast_deep_equal5.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
50127         });
50128       };
50129       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
50130         return "way area target target-allowed " + targetClass + d2.id;
50131       }).classed("segment-edited", segmentWasEdited);
50132       var nopeData = data.nopes.filter(getPath);
50133       var nopes = selection2.selectAll(".area.target-nope").filter(function(d2) {
50134         return filter2(d2.properties.entity);
50135       }).data(nopeData, function key(d2) {
50136         return d2.id;
50137       });
50138       nopes.exit().remove();
50139       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
50140         return "way area target target-nope " + nopeClass + d2.id;
50141       }).classed("segment-edited", segmentWasEdited);
50142     }
50143     function drawAreas(selection2, graph, entities, filter2) {
50144       var path = svgPath(projection2, graph, true);
50145       var areas = {};
50146       var base = context.history().base();
50147       for (var i3 = 0; i3 < entities.length; i3++) {
50148         var entity = entities[i3];
50149         if (entity.geometry(graph) !== "area")
50150           continue;
50151         if (!areas[entity.id]) {
50152           areas[entity.id] = {
50153             entity,
50154             area: Math.abs(entity.area(graph))
50155           };
50156         }
50157       }
50158       var fills = Object.values(areas).filter(function hasPath(a2) {
50159         return path(a2.entity);
50160       });
50161       fills.sort(function areaSort(a2, b2) {
50162         return b2.area - a2.area;
50163       });
50164       fills = fills.map(function(a2) {
50165         return a2.entity;
50166       });
50167       var strokes = fills.filter(function(area) {
50168         return area.type === "way";
50169       });
50170       var data = {
50171         clip: fills,
50172         shadow: strokes,
50173         stroke: strokes,
50174         fill: fills
50175       };
50176       var clipPaths = context.surface().selectAll("defs").selectAll(".clipPath-osm").filter(filter2).data(data.clip, osmEntity.key);
50177       clipPaths.exit().remove();
50178       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-osm").attr("id", function(entity2) {
50179         return "ideditor-" + entity2.id + "-clippath";
50180       });
50181       clipPathsEnter.append("path");
50182       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", path);
50183       var drawLayer = selection2.selectAll(".layer-osm.areas");
50184       var touchLayer = selection2.selectAll(".layer-touch.areas");
50185       var areagroup = drawLayer.selectAll("g.areagroup").data(["fill", "shadow", "stroke"]);
50186       areagroup = areagroup.enter().append("g").attr("class", function(d2) {
50187         return "areagroup area-" + d2;
50188       }).merge(areagroup);
50189       var paths = areagroup.selectAll("path").filter(filter2).data(function(layer) {
50190         return data[layer];
50191       }, osmEntity.key);
50192       paths.exit().remove();
50193       var fillpaths = selection2.selectAll(".area-fill path.area").nodes();
50194       var bisect = bisector(function(node) {
50195         return -node.__data__.area(graph);
50196       }).left;
50197       function sortedByArea(entity2) {
50198         if (this._parent.__data__ === "fill") {
50199           return fillpaths[bisect(fillpaths, -entity2.area(graph))];
50200         }
50201       }
50202       paths = paths.enter().insert("path", sortedByArea).merge(paths).each(function(entity2) {
50203         var layer = this.parentNode.__data__;
50204         this.setAttribute("class", entity2.type + " area " + layer + " " + entity2.id);
50205         if (layer === "fill") {
50206           this.setAttribute("clip-path", "url(#ideditor-" + entity2.id + "-clippath)");
50207           this.style.fill = this.style.stroke = getPatternStyle(entity2.tags);
50208         }
50209       }).classed("added", function(d2) {
50210         return !base.entities[d2.id];
50211       }).classed("geometry-edited", function(d2) {
50212         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);
50213       }).classed("retagged", function(d2) {
50214         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);
50215       }).call(svgTagClasses()).attr("d", path);
50216       touchLayer.call(drawTargets, graph, data.stroke, filter2);
50217     }
50218     return drawAreas;
50219   }
50220
50221   // modules/svg/data.js
50222   var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify());
50223
50224   // node_modules/@tmcw/togeojson/dist/togeojson.es.mjs
50225   function $(element, tagName) {
50226     return Array.from(element.getElementsByTagName(tagName));
50227   }
50228   function normalizeId(id2) {
50229     return id2[0] === "#" ? id2 : "#".concat(id2);
50230   }
50231   function $ns(element, tagName, ns) {
50232     return Array.from(element.getElementsByTagNameNS(ns, tagName));
50233   }
50234   function nodeVal(node) {
50235     node == null ? void 0 : node.normalize();
50236     return node && node.textContent || "";
50237   }
50238   function get1(node, tagName, callback) {
50239     const n3 = node.getElementsByTagName(tagName);
50240     const result = n3.length ? n3[0] : null;
50241     if (result && callback)
50242       callback(result);
50243     return result;
50244   }
50245   function get3(node, tagName, callback) {
50246     const properties = {};
50247     if (!node)
50248       return properties;
50249     const n3 = node.getElementsByTagName(tagName);
50250     const result = n3.length ? n3[0] : null;
50251     if (result && callback) {
50252       return callback(result, properties);
50253     }
50254     return properties;
50255   }
50256   function val1(node, tagName, callback) {
50257     const val = nodeVal(get1(node, tagName));
50258     if (val && callback)
50259       return callback(val) || {};
50260     return {};
50261   }
50262   function $num(node, tagName, callback) {
50263     const val = parseFloat(nodeVal(get1(node, tagName)));
50264     if (isNaN(val))
50265       return void 0;
50266     if (val && callback)
50267       return callback(val) || {};
50268     return {};
50269   }
50270   function num1(node, tagName, callback) {
50271     const val = parseFloat(nodeVal(get1(node, tagName)));
50272     if (isNaN(val))
50273       return void 0;
50274     if (callback)
50275       callback(val);
50276     return val;
50277   }
50278   function getMulti(node, propertyNames) {
50279     const properties = {};
50280     for (const property of propertyNames) {
50281       val1(node, property, (val) => {
50282         properties[property] = val;
50283       });
50284     }
50285     return properties;
50286   }
50287   function isElement(node) {
50288     return (node == null ? void 0 : node.nodeType) === 1;
50289   }
50290   function getLineStyle(node) {
50291     return get3(node, "line", (lineStyle) => {
50292       const val = Object.assign({}, val1(lineStyle, "color", (color2) => {
50293         return { stroke: "#".concat(color2) };
50294       }), $num(lineStyle, "opacity", (opacity) => {
50295         return { "stroke-opacity": opacity };
50296       }), $num(lineStyle, "width", (width) => {
50297         return { "stroke-width": width * 96 / 25.4 };
50298       }));
50299       return val;
50300     });
50301   }
50302   function getExtensions(node) {
50303     let values = [];
50304     if (node === null)
50305       return values;
50306     for (const child of Array.from(node.childNodes)) {
50307       if (!isElement(child))
50308         continue;
50309       const name = abbreviateName(child.nodeName);
50310       if (name === "gpxtpx:TrackPointExtension") {
50311         values = values.concat(getExtensions(child));
50312       } else {
50313         const val = nodeVal(child);
50314         values.push([name, parseNumeric(val)]);
50315       }
50316     }
50317     return values;
50318   }
50319   function abbreviateName(name) {
50320     return ["heart", "gpxtpx:hr", "hr"].includes(name) ? "heart" : name;
50321   }
50322   function parseNumeric(val) {
50323     const num = parseFloat(val);
50324     return isNaN(num) ? val : num;
50325   }
50326   function coordPair$1(node) {
50327     const ll = [
50328       parseFloat(node.getAttribute("lon") || ""),
50329       parseFloat(node.getAttribute("lat") || "")
50330     ];
50331     if (isNaN(ll[0]) || isNaN(ll[1])) {
50332       return null;
50333     }
50334     num1(node, "ele", (val) => {
50335       ll.push(val);
50336     });
50337     const time = get1(node, "time");
50338     return {
50339       coordinates: ll,
50340       time: time ? nodeVal(time) : null,
50341       extendedValues: getExtensions(get1(node, "extensions"))
50342     };
50343   }
50344   function extractProperties(node) {
50345     var _a2;
50346     const properties = getMulti(node, [
50347       "name",
50348       "cmt",
50349       "desc",
50350       "type",
50351       "time",
50352       "keywords"
50353     ]);
50354     const extensions = Array.from(node.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*"));
50355     for (const child of extensions) {
50356       if (((_a2 = child.parentNode) == null ? void 0 : _a2.parentNode) === node) {
50357         properties[child.tagName.replace(":", "_")] = nodeVal(child);
50358       }
50359     }
50360     const links = $(node, "link");
50361     if (links.length) {
50362       properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"])));
50363     }
50364     return properties;
50365   }
50366   function getPoints$1(node, pointname) {
50367     const pts = $(node, pointname);
50368     const line = [];
50369     const times = [];
50370     const extendedValues = {};
50371     for (let i3 = 0; i3 < pts.length; i3++) {
50372       const c2 = coordPair$1(pts[i3]);
50373       if (!c2) {
50374         continue;
50375       }
50376       line.push(c2.coordinates);
50377       if (c2.time)
50378         times.push(c2.time);
50379       for (const [name, val] of c2.extendedValues) {
50380         const plural = name === "heart" ? name : name.replace("gpxtpx:", "") + "s";
50381         if (!extendedValues[plural]) {
50382           extendedValues[plural] = Array(pts.length).fill(null);
50383         }
50384         extendedValues[plural][i3] = val;
50385       }
50386     }
50387     if (line.length < 2)
50388       return;
50389     return {
50390       line,
50391       times,
50392       extendedValues
50393     };
50394   }
50395   function getRoute(node) {
50396     const line = getPoints$1(node, "rtept");
50397     if (!line)
50398       return;
50399     return {
50400       type: "Feature",
50401       properties: Object.assign({ _gpxType: "rte" }, extractProperties(node), getLineStyle(get1(node, "extensions"))),
50402       geometry: {
50403         type: "LineString",
50404         coordinates: line.line
50405       }
50406     };
50407   }
50408   function getTrack(node) {
50409     const segments = $(node, "trkseg");
50410     const track = [];
50411     const times = [];
50412     const extractedLines = [];
50413     for (const segment of segments) {
50414       const line = getPoints$1(segment, "trkpt");
50415       if (line) {
50416         extractedLines.push(line);
50417         if (line.times && line.times.length)
50418           times.push(line.times);
50419       }
50420     }
50421     if (extractedLines.length === 0)
50422       return null;
50423     const multi = extractedLines.length > 1;
50424     const properties = Object.assign({ _gpxType: "trk" }, extractProperties(node), getLineStyle(get1(node, "extensions")), times.length ? {
50425       coordinateProperties: {
50426         times: multi ? times : times[0]
50427       }
50428     } : {});
50429     for (const line of extractedLines) {
50430       track.push(line.line);
50431       if (!properties.coordinateProperties) {
50432         properties.coordinateProperties = {};
50433       }
50434       const props = properties.coordinateProperties;
50435       const entries = Object.entries(line.extendedValues);
50436       for (let i3 = 0; i3 < entries.length; i3++) {
50437         const [name, val] = entries[i3];
50438         if (multi) {
50439           if (!props[name]) {
50440             props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
50441           }
50442           props[name][i3] = val;
50443         } else {
50444           props[name] = val;
50445         }
50446       }
50447     }
50448     return {
50449       type: "Feature",
50450       properties,
50451       geometry: multi ? {
50452         type: "MultiLineString",
50453         coordinates: track
50454       } : {
50455         type: "LineString",
50456         coordinates: track[0]
50457       }
50458     };
50459   }
50460   function getPoint(node) {
50461     const properties = Object.assign(extractProperties(node), getMulti(node, ["sym"]));
50462     const pair3 = coordPair$1(node);
50463     if (!pair3)
50464       return null;
50465     return {
50466       type: "Feature",
50467       properties,
50468       geometry: {
50469         type: "Point",
50470         coordinates: pair3.coordinates
50471       }
50472     };
50473   }
50474   function* gpxGen(node) {
50475     for (const track of $(node, "trk")) {
50476       const feature3 = getTrack(track);
50477       if (feature3)
50478         yield feature3;
50479     }
50480     for (const route of $(node, "rte")) {
50481       const feature3 = getRoute(route);
50482       if (feature3)
50483         yield feature3;
50484     }
50485     for (const waypoint of $(node, "wpt")) {
50486       const point2 = getPoint(waypoint);
50487       if (point2)
50488         yield point2;
50489     }
50490   }
50491   function gpx(node) {
50492     return {
50493       type: "FeatureCollection",
50494       features: Array.from(gpxGen(node))
50495     };
50496   }
50497   function fixColor(v2, prefix) {
50498     const properties = {};
50499     const colorProp = prefix == "stroke" || prefix === "fill" ? prefix : prefix + "-color";
50500     if (v2[0] === "#") {
50501       v2 = v2.substring(1);
50502     }
50503     if (v2.length === 6 || v2.length === 3) {
50504       properties[colorProp] = "#" + v2;
50505     } else if (v2.length === 8) {
50506       properties[prefix + "-opacity"] = parseInt(v2.substring(0, 2), 16) / 255;
50507       properties[colorProp] = "#" + v2.substring(6, 8) + v2.substring(4, 6) + v2.substring(2, 4);
50508     }
50509     return properties;
50510   }
50511   function numericProperty(node, source, target) {
50512     const properties = {};
50513     num1(node, source, (val) => {
50514       properties[target] = val;
50515     });
50516     return properties;
50517   }
50518   function getColor(node, output) {
50519     return get3(node, "color", (elem) => fixColor(nodeVal(elem), output));
50520   }
50521   function extractIconHref(node) {
50522     return get3(node, "Icon", (icon2, properties) => {
50523       val1(icon2, "href", (href) => {
50524         properties.icon = href;
50525       });
50526       return properties;
50527     });
50528   }
50529   function extractIcon(node) {
50530     return get3(node, "IconStyle", (iconStyle) => {
50531       return Object.assign(getColor(iconStyle, "icon"), numericProperty(iconStyle, "scale", "icon-scale"), numericProperty(iconStyle, "heading", "icon-heading"), get3(iconStyle, "hotSpot", (hotspot) => {
50532         const left = parseFloat(hotspot.getAttribute("x") || "");
50533         const top = parseFloat(hotspot.getAttribute("y") || "");
50534         const xunits = hotspot.getAttribute("xunits") || "";
50535         const yunits = hotspot.getAttribute("yunits") || "";
50536         if (!isNaN(left) && !isNaN(top))
50537           return {
50538             "icon-offset": [left, top],
50539             "icon-offset-units": [xunits, yunits]
50540           };
50541         return {};
50542       }), extractIconHref(iconStyle));
50543     });
50544   }
50545   function extractLabel(node) {
50546     return get3(node, "LabelStyle", (labelStyle) => {
50547       return Object.assign(getColor(labelStyle, "label"), numericProperty(labelStyle, "scale", "label-scale"));
50548     });
50549   }
50550   function extractLine(node) {
50551     return get3(node, "LineStyle", (lineStyle) => {
50552       return Object.assign(getColor(lineStyle, "stroke"), numericProperty(lineStyle, "width", "stroke-width"));
50553     });
50554   }
50555   function extractPoly(node) {
50556     return get3(node, "PolyStyle", (polyStyle, properties) => {
50557       return Object.assign(properties, get3(polyStyle, "color", (elem) => fixColor(nodeVal(elem), "fill")), val1(polyStyle, "fill", (fill) => {
50558         if (fill === "0")
50559           return { "fill-opacity": 0 };
50560       }), val1(polyStyle, "outline", (outline) => {
50561         if (outline === "0")
50562           return { "stroke-opacity": 0 };
50563       }));
50564     });
50565   }
50566   function extractStyle(node) {
50567     return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node));
50568   }
50569   var toNumber2 = (x2) => Number(x2);
50570   var typeConverters = {
50571     string: (x2) => x2,
50572     int: toNumber2,
50573     uint: toNumber2,
50574     short: toNumber2,
50575     ushort: toNumber2,
50576     float: toNumber2,
50577     double: toNumber2,
50578     bool: (x2) => Boolean(x2)
50579   };
50580   function extractExtendedData(node, schema) {
50581     return get3(node, "ExtendedData", (extendedData, properties) => {
50582       for (const data of $(extendedData, "Data")) {
50583         properties[data.getAttribute("name") || ""] = nodeVal(get1(data, "value"));
50584       }
50585       for (const simpleData of $(extendedData, "SimpleData")) {
50586         const name = simpleData.getAttribute("name") || "";
50587         const typeConverter = schema[name] || typeConverters.string;
50588         properties[name] = typeConverter(nodeVal(simpleData));
50589       }
50590       return properties;
50591     });
50592   }
50593   function getMaybeHTMLDescription(node) {
50594     const descriptionNode = get1(node, "description");
50595     for (const c2 of Array.from((descriptionNode == null ? void 0 : descriptionNode.childNodes) || [])) {
50596       if (c2.nodeType === 4) {
50597         return {
50598           description: {
50599             "@type": "html",
50600             value: nodeVal(c2)
50601           }
50602         };
50603       }
50604     }
50605     return {};
50606   }
50607   function extractTimeSpan(node) {
50608     return get3(node, "TimeSpan", (timeSpan) => {
50609       return {
50610         timespan: {
50611           begin: nodeVal(get1(timeSpan, "begin")),
50612           end: nodeVal(get1(timeSpan, "end"))
50613         }
50614       };
50615     });
50616   }
50617   function extractTimeStamp(node) {
50618     return get3(node, "TimeStamp", (timeStamp) => {
50619       return { timestamp: nodeVal(get1(timeStamp, "when")) };
50620     });
50621   }
50622   function extractCascadedStyle(node, styleMap) {
50623     return val1(node, "styleUrl", (styleUrl) => {
50624       styleUrl = normalizeId(styleUrl);
50625       if (styleMap[styleUrl]) {
50626         return Object.assign({ styleUrl }, styleMap[styleUrl]);
50627       }
50628       return { styleUrl };
50629     });
50630   }
50631   var removeSpace = /\s*/g;
50632   var trimSpace = /^\s*|\s*$/g;
50633   var splitSpace = /\s+/;
50634   function coord1(value) {
50635     return value.replace(removeSpace, "").split(",").map(parseFloat).filter((num) => !isNaN(num)).slice(0, 3);
50636   }
50637   function coord(value) {
50638     return value.replace(trimSpace, "").split(splitSpace).map(coord1).filter((coord2) => {
50639       return coord2.length >= 2;
50640     });
50641   }
50642   function gxCoords(node) {
50643     let elems = $(node, "coord");
50644     if (elems.length === 0) {
50645       elems = $ns(node, "coord", "*");
50646     }
50647     const coordinates = elems.map((elem) => {
50648       return nodeVal(elem).split(" ").map(parseFloat);
50649     });
50650     if (coordinates.length === 0) {
50651       return null;
50652     }
50653     return {
50654       geometry: coordinates.length > 2 ? {
50655         type: "LineString",
50656         coordinates
50657       } : {
50658         type: "Point",
50659         coordinates: coordinates[0]
50660       },
50661       times: $(node, "when").map((elem) => nodeVal(elem))
50662     };
50663   }
50664   function fixRing(ring) {
50665     if (ring.length === 0)
50666       return ring;
50667     const first = ring[0];
50668     const last = ring[ring.length - 1];
50669     let equal = true;
50670     for (let i3 = 0; i3 < Math.max(first.length, last.length); i3++) {
50671       if (first[i3] !== last[i3]) {
50672         equal = false;
50673         break;
50674       }
50675     }
50676     if (!equal) {
50677       return ring.concat([ring[0]]);
50678     }
50679     return ring;
50680   }
50681   function getCoordinates(node) {
50682     return nodeVal(get1(node, "coordinates"));
50683   }
50684   function getGeometry(node) {
50685     let geometries = [];
50686     let coordTimes = [];
50687     for (let i3 = 0; i3 < node.childNodes.length; i3++) {
50688       const child = node.childNodes.item(i3);
50689       if (isElement(child)) {
50690         switch (child.tagName) {
50691           case "MultiGeometry":
50692           case "MultiTrack":
50693           case "gx:MultiTrack": {
50694             const childGeometries = getGeometry(child);
50695             geometries = geometries.concat(childGeometries.geometries);
50696             coordTimes = coordTimes.concat(childGeometries.coordTimes);
50697             break;
50698           }
50699           case "Point": {
50700             const coordinates = coord1(getCoordinates(child));
50701             if (coordinates.length >= 2) {
50702               geometries.push({
50703                 type: "Point",
50704                 coordinates
50705               });
50706             }
50707             break;
50708           }
50709           case "LinearRing":
50710           case "LineString": {
50711             const coordinates = coord(getCoordinates(child));
50712             if (coordinates.length >= 2) {
50713               geometries.push({
50714                 type: "LineString",
50715                 coordinates
50716               });
50717             }
50718             break;
50719           }
50720           case "Polygon": {
50721             const coords = [];
50722             for (const linearRing of $(child, "LinearRing")) {
50723               const ring = fixRing(coord(getCoordinates(linearRing)));
50724               if (ring.length >= 4) {
50725                 coords.push(ring);
50726               }
50727             }
50728             if (coords.length) {
50729               geometries.push({
50730                 type: "Polygon",
50731                 coordinates: coords
50732               });
50733             }
50734             break;
50735           }
50736           case "Track":
50737           case "gx:Track": {
50738             const gx = gxCoords(child);
50739             if (!gx)
50740               break;
50741             const { times, geometry } = gx;
50742             geometries.push(geometry);
50743             if (times.length)
50744               coordTimes.push(times);
50745             break;
50746           }
50747         }
50748       }
50749     }
50750     return {
50751       geometries,
50752       coordTimes
50753     };
50754   }
50755   function geometryListToGeometry(geometries) {
50756     return geometries.length === 0 ? null : geometries.length === 1 ? geometries[0] : {
50757       type: "GeometryCollection",
50758       geometries
50759     };
50760   }
50761   function getPlacemark(node, styleMap, schema, options2) {
50762     var _a2;
50763     const { coordTimes, geometries } = getGeometry(node);
50764     const geometry = geometryListToGeometry(geometries);
50765     if (!geometry && options2.skipNullGeometry) {
50766       return null;
50767     }
50768     const feature3 = {
50769       type: "Feature",
50770       geometry,
50771       properties: Object.assign(getMulti(node, [
50772         "name",
50773         "address",
50774         "visibility",
50775         "open",
50776         "phoneNumber",
50777         "description"
50778       ]), getMaybeHTMLDescription(node), extractCascadedStyle(node, styleMap), extractStyle(node), extractExtendedData(node, schema), extractTimeSpan(node), extractTimeStamp(node), coordTimes.length ? {
50779         coordinateProperties: {
50780           times: coordTimes.length === 1 ? coordTimes[0] : coordTimes
50781         }
50782       } : {})
50783     };
50784     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50785       feature3.properties.visibility = feature3.properties.visibility !== "0";
50786     }
50787     const id2 = node.getAttribute("id");
50788     if (id2 !== null && id2 !== "")
50789       feature3.id = id2;
50790     return feature3;
50791   }
50792   function getGroundOverlayBox(node) {
50793     const latLonQuad = get1(node, "gx:LatLonQuad");
50794     if (latLonQuad) {
50795       const ring = fixRing(coord(getCoordinates(node)));
50796       return {
50797         geometry: {
50798           type: "Polygon",
50799           coordinates: [ring]
50800         }
50801       };
50802     }
50803     return getLatLonBox(node);
50804   }
50805   var DEGREES_TO_RADIANS = Math.PI / 180;
50806   function rotateBox(bbox2, coordinates, rotation) {
50807     const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2];
50808     return [
50809       coordinates[0].map((coordinate) => {
50810         const dy = coordinate[1] - center[1];
50811         const dx = coordinate[0] - center[0];
50812         const distance = Math.sqrt(Math.pow(dy, 2) + Math.pow(dx, 2));
50813         const angle2 = Math.atan2(dy, dx) + rotation * DEGREES_TO_RADIANS;
50814         return [
50815           center[0] + Math.cos(angle2) * distance,
50816           center[1] + Math.sin(angle2) * distance
50817         ];
50818       })
50819     ];
50820   }
50821   function getLatLonBox(node) {
50822     const latLonBox = get1(node, "LatLonBox");
50823     if (latLonBox) {
50824       const north = num1(latLonBox, "north");
50825       const west = num1(latLonBox, "west");
50826       const east = num1(latLonBox, "east");
50827       const south = num1(latLonBox, "south");
50828       const rotation = num1(latLonBox, "rotation");
50829       if (typeof north === "number" && typeof south === "number" && typeof west === "number" && typeof east === "number") {
50830         const bbox2 = [west, south, east, north];
50831         let coordinates = [
50832           [
50833             [west, north],
50834             [east, north],
50835             [east, south],
50836             [west, south],
50837             [west, north]
50838             // top left (again)
50839           ]
50840         ];
50841         if (typeof rotation === "number") {
50842           coordinates = rotateBox(bbox2, coordinates, rotation);
50843         }
50844         return {
50845           bbox: bbox2,
50846           geometry: {
50847             type: "Polygon",
50848             coordinates
50849           }
50850         };
50851       }
50852     }
50853     return null;
50854   }
50855   function getGroundOverlay(node, styleMap, schema, options2) {
50856     var _a2;
50857     const box = getGroundOverlayBox(node);
50858     const geometry = (box == null ? void 0 : box.geometry) || null;
50859     if (!geometry && options2.skipNullGeometry) {
50860       return null;
50861     }
50862     const feature3 = {
50863       type: "Feature",
50864       geometry,
50865       properties: Object.assign(
50866         /**
50867          * Related to
50868          * https://gist.github.com/tmcw/037a1cb6660d74a392e9da7446540f46
50869          */
50870         { "@geometry-type": "groundoverlay" },
50871         getMulti(node, [
50872           "name",
50873           "address",
50874           "visibility",
50875           "open",
50876           "phoneNumber",
50877           "description"
50878         ]),
50879         getMaybeHTMLDescription(node),
50880         extractCascadedStyle(node, styleMap),
50881         extractStyle(node),
50882         extractIconHref(node),
50883         extractExtendedData(node, schema),
50884         extractTimeSpan(node),
50885         extractTimeStamp(node)
50886       )
50887     };
50888     if (box == null ? void 0 : box.bbox) {
50889       feature3.bbox = box.bbox;
50890     }
50891     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50892       feature3.properties.visibility = feature3.properties.visibility !== "0";
50893     }
50894     const id2 = node.getAttribute("id");
50895     if (id2 !== null && id2 !== "")
50896       feature3.id = id2;
50897     return feature3;
50898   }
50899   function getStyleId(style) {
50900     let id2 = style.getAttribute("id");
50901     const parentNode = style.parentNode;
50902     if (!id2 && isElement(parentNode) && parentNode.localName === "CascadingStyle") {
50903       id2 = parentNode.getAttribute("kml:id") || parentNode.getAttribute("id");
50904     }
50905     return normalizeId(id2 || "");
50906   }
50907   function buildStyleMap(node) {
50908     const styleMap = {};
50909     for (const style of $(node, "Style")) {
50910       styleMap[getStyleId(style)] = extractStyle(style);
50911     }
50912     for (const map2 of $(node, "StyleMap")) {
50913       const id2 = normalizeId(map2.getAttribute("id") || "");
50914       val1(map2, "styleUrl", (styleUrl) => {
50915         styleUrl = normalizeId(styleUrl);
50916         if (styleMap[styleUrl]) {
50917           styleMap[id2] = styleMap[styleUrl];
50918         }
50919       });
50920     }
50921     return styleMap;
50922   }
50923   function buildSchema(node) {
50924     const schema = {};
50925     for (const field of $(node, "SimpleField")) {
50926       schema[field.getAttribute("name") || ""] = typeConverters[field.getAttribute("type") || ""] || typeConverters["string"];
50927     }
50928     return schema;
50929   }
50930   function* kmlGen(node, options2 = {
50931     skipNullGeometry: false
50932   }) {
50933     const styleMap = buildStyleMap(node);
50934     const schema = buildSchema(node);
50935     for (const placemark of $(node, "Placemark")) {
50936       const feature3 = getPlacemark(placemark, styleMap, schema, options2);
50937       if (feature3)
50938         yield feature3;
50939     }
50940     for (const groundOverlay of $(node, "GroundOverlay")) {
50941       const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2);
50942       if (feature3)
50943         yield feature3;
50944     }
50945   }
50946   function kml(node, options2 = {
50947     skipNullGeometry: false
50948   }) {
50949     return {
50950       type: "FeatureCollection",
50951       features: Array.from(kmlGen(node, options2))
50952     };
50953   }
50954
50955   // modules/svg/data.js
50956   var _initialized = false;
50957   var _enabled = false;
50958   var _geojson;
50959   function svgData(projection2, context, dispatch14) {
50960     var throttledRedraw = throttle_default(function() {
50961       dispatch14.call("change");
50962     }, 1e3);
50963     var _showLabels = true;
50964     var detected = utilDetect();
50965     var layer = select_default2(null);
50966     var _vtService;
50967     var _fileList;
50968     var _template;
50969     var _src;
50970     const supportedFormats = [
50971       ".gpx",
50972       ".kml",
50973       ".geojson",
50974       ".json"
50975     ];
50976     function init2() {
50977       if (_initialized)
50978         return;
50979       _geojson = {};
50980       _enabled = true;
50981       function over(d3_event) {
50982         d3_event.stopPropagation();
50983         d3_event.preventDefault();
50984         d3_event.dataTransfer.dropEffect = "copy";
50985       }
50986       context.container().attr("dropzone", "copy").on("drop.svgData", function(d3_event) {
50987         d3_event.stopPropagation();
50988         d3_event.preventDefault();
50989         if (!detected.filedrop)
50990           return;
50991         var f2 = d3_event.dataTransfer.files[0];
50992         var extension = getExtension(f2.name);
50993         if (!supportedFormats.includes(extension))
50994           return;
50995         drawData.fileList(d3_event.dataTransfer.files);
50996       }).on("dragenter.svgData", over).on("dragexit.svgData", over).on("dragover.svgData", over);
50997       _initialized = true;
50998     }
50999     function getService() {
51000       if (services.vectorTile && !_vtService) {
51001         _vtService = services.vectorTile;
51002         _vtService.event.on("loadedData", throttledRedraw);
51003       } else if (!services.vectorTile && _vtService) {
51004         _vtService = null;
51005       }
51006       return _vtService;
51007     }
51008     function showLayer() {
51009       layerOn();
51010       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
51011         dispatch14.call("change");
51012       });
51013     }
51014     function hideLayer() {
51015       throttledRedraw.cancel();
51016       layer.transition().duration(250).style("opacity", 0).on("end", layerOff);
51017     }
51018     function layerOn() {
51019       layer.style("display", "block");
51020     }
51021     function layerOff() {
51022       layer.selectAll(".viewfield-group").remove();
51023       layer.style("display", "none");
51024     }
51025     function ensureIDs(gj) {
51026       if (!gj)
51027         return null;
51028       if (gj.type === "FeatureCollection") {
51029         for (var i3 = 0; i3 < gj.features.length; i3++) {
51030           ensureFeatureID(gj.features[i3]);
51031         }
51032       } else {
51033         ensureFeatureID(gj);
51034       }
51035       return gj;
51036     }
51037     function ensureFeatureID(feature3) {
51038       if (!feature3)
51039         return;
51040       feature3.__featurehash__ = utilHashcode((0, import_fast_json_stable_stringify.default)(feature3));
51041       return feature3;
51042     }
51043     function getFeatures(gj) {
51044       if (!gj)
51045         return [];
51046       if (gj.type === "FeatureCollection") {
51047         return gj.features;
51048       } else {
51049         return [gj];
51050       }
51051     }
51052     function featureKey(d2) {
51053       return d2.__featurehash__;
51054     }
51055     function isPolygon(d2) {
51056       return d2.geometry.type === "Polygon" || d2.geometry.type === "MultiPolygon";
51057     }
51058     function clipPathID(d2) {
51059       return "ideditor-data-" + d2.__featurehash__ + "-clippath";
51060     }
51061     function featureClasses(d2) {
51062       return [
51063         "data" + d2.__featurehash__,
51064         d2.geometry.type,
51065         isPolygon(d2) ? "area" : "",
51066         d2.__layerID__ || ""
51067       ].filter(Boolean).join(" ");
51068     }
51069     function drawData(selection2) {
51070       var vtService = getService();
51071       var getPath = svgPath(projection2).geojson;
51072       var getAreaPath = svgPath(projection2, null, true).geojson;
51073       var hasData = drawData.hasData();
51074       layer = selection2.selectAll(".layer-mapdata").data(_enabled && hasData ? [0] : []);
51075       layer.exit().remove();
51076       layer = layer.enter().append("g").attr("class", "layer-mapdata").merge(layer);
51077       var surface = context.surface();
51078       if (!surface || surface.empty())
51079         return;
51080       var geoData, polygonData;
51081       if (_template && vtService) {
51082         var sourceID = _template;
51083         vtService.loadTiles(sourceID, _template, projection2);
51084         geoData = vtService.data(sourceID, projection2);
51085       } else {
51086         geoData = getFeatures(_geojson);
51087       }
51088       geoData = geoData.filter(getPath);
51089       polygonData = geoData.filter(isPolygon);
51090       var clipPaths = surface.selectAll("defs").selectAll(".clipPath-data").data(polygonData, featureKey);
51091       clipPaths.exit().remove();
51092       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-data").attr("id", clipPathID);
51093       clipPathsEnter.append("path");
51094       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", getAreaPath);
51095       var datagroups = layer.selectAll("g.datagroup").data(["fill", "shadow", "stroke"]);
51096       datagroups = datagroups.enter().append("g").attr("class", function(d2) {
51097         return "datagroup datagroup-" + d2;
51098       }).merge(datagroups);
51099       var pathData = {
51100         fill: polygonData,
51101         shadow: geoData,
51102         stroke: geoData
51103       };
51104       var paths = datagroups.selectAll("path").data(function(layer2) {
51105         return pathData[layer2];
51106       }, featureKey);
51107       paths.exit().remove();
51108       paths = paths.enter().append("path").attr("class", function(d2) {
51109         var datagroup = this.parentNode.__data__;
51110         return "pathdata " + datagroup + " " + featureClasses(d2);
51111       }).attr("clip-path", function(d2) {
51112         var datagroup = this.parentNode.__data__;
51113         return datagroup === "fill" ? "url(#" + clipPathID(d2) + ")" : null;
51114       }).merge(paths).attr("d", function(d2) {
51115         var datagroup = this.parentNode.__data__;
51116         return datagroup === "fill" ? getAreaPath(d2) : getPath(d2);
51117       });
51118       layer.call(drawLabels, "label-halo", geoData).call(drawLabels, "label", geoData);
51119       function drawLabels(selection3, textClass, data) {
51120         var labelPath = path_default(projection2);
51121         var labelData = data.filter(function(d2) {
51122           return _showLabels && d2.properties && (d2.properties.desc || d2.properties.name);
51123         });
51124         var labels = selection3.selectAll("text." + textClass).data(labelData, featureKey);
51125         labels.exit().remove();
51126         labels = labels.enter().append("text").attr("class", function(d2) {
51127           return textClass + " " + featureClasses(d2);
51128         }).merge(labels).text(function(d2) {
51129           return d2.properties.desc || d2.properties.name;
51130         }).attr("x", function(d2) {
51131           var centroid = labelPath.centroid(d2);
51132           return centroid[0] + 11;
51133         }).attr("y", function(d2) {
51134           var centroid = labelPath.centroid(d2);
51135           return centroid[1];
51136         });
51137       }
51138     }
51139     function getExtension(fileName) {
51140       if (!fileName)
51141         return;
51142       var re3 = /\.(gpx|kml|(geo)?json|png)$/i;
51143       var match = fileName.toLowerCase().match(re3);
51144       return match && match.length && match[0];
51145     }
51146     function xmlToDom(textdata) {
51147       return new DOMParser().parseFromString(textdata, "text/xml");
51148     }
51149     function stringifyGeojsonProperties(feature3) {
51150       const properties = feature3.properties;
51151       for (const key in properties) {
51152         const property = properties[key];
51153         if (typeof property === "number" || typeof property === "boolean" || Array.isArray(property)) {
51154           properties[key] = property.toString();
51155         } else if (property === null) {
51156           properties[key] = "null";
51157         } else if (typeof property === "object") {
51158           properties[key] = JSON.stringify(property);
51159         }
51160       }
51161     }
51162     drawData.setFile = function(extension, data) {
51163       _template = null;
51164       _fileList = null;
51165       _geojson = null;
51166       _src = null;
51167       var gj;
51168       switch (extension) {
51169         case ".gpx":
51170           gj = gpx(xmlToDom(data));
51171           break;
51172         case ".kml":
51173           gj = kml(xmlToDom(data));
51174           break;
51175         case ".geojson":
51176         case ".json":
51177           gj = JSON.parse(data);
51178           if (gj.type === "FeatureCollection") {
51179             gj.features.forEach(stringifyGeojsonProperties);
51180           } else if (gj.type === "Feature") {
51181             stringifyGeojsonProperties(gj);
51182           }
51183           break;
51184       }
51185       gj = gj || {};
51186       if (Object.keys(gj).length) {
51187         _geojson = ensureIDs(gj);
51188         _src = extension + " data file";
51189         this.fitZoom();
51190       }
51191       dispatch14.call("change");
51192       return this;
51193     };
51194     drawData.showLabels = function(val) {
51195       if (!arguments.length)
51196         return _showLabels;
51197       _showLabels = val;
51198       return this;
51199     };
51200     drawData.enabled = function(val) {
51201       if (!arguments.length)
51202         return _enabled;
51203       _enabled = val;
51204       if (_enabled) {
51205         showLayer();
51206       } else {
51207         hideLayer();
51208       }
51209       dispatch14.call("change");
51210       return this;
51211     };
51212     drawData.hasData = function() {
51213       var gj = _geojson || {};
51214       return !!(_template || Object.keys(gj).length);
51215     };
51216     drawData.template = function(val, src) {
51217       if (!arguments.length)
51218         return _template;
51219       var osm = context.connection();
51220       if (osm) {
51221         var blocklists = osm.imageryBlocklists();
51222         var fail = false;
51223         var tested = 0;
51224         var regex;
51225         for (var i3 = 0; i3 < blocklists.length; i3++) {
51226           regex = blocklists[i3];
51227           fail = regex.test(val);
51228           tested++;
51229           if (fail)
51230             break;
51231         }
51232         if (!tested) {
51233           regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
51234           fail = regex.test(val);
51235         }
51236       }
51237       _template = val;
51238       _fileList = null;
51239       _geojson = null;
51240       _src = src || "vectortile:" + val.split(/[?#]/)[0];
51241       dispatch14.call("change");
51242       return this;
51243     };
51244     drawData.geojson = function(gj, src) {
51245       if (!arguments.length)
51246         return _geojson;
51247       _template = null;
51248       _fileList = null;
51249       _geojson = null;
51250       _src = null;
51251       gj = gj || {};
51252       if (Object.keys(gj).length) {
51253         _geojson = ensureIDs(gj);
51254         _src = src || "unknown.geojson";
51255       }
51256       dispatch14.call("change");
51257       return this;
51258     };
51259     drawData.fileList = function(fileList) {
51260       if (!arguments.length)
51261         return _fileList;
51262       _template = null;
51263       _geojson = null;
51264       _src = null;
51265       _fileList = fileList;
51266       if (!fileList || !fileList.length)
51267         return this;
51268       var f2 = fileList[0];
51269       var extension = getExtension(f2.name);
51270       var reader = new FileReader();
51271       reader.onload = /* @__PURE__ */ function() {
51272         return function(e3) {
51273           drawData.setFile(extension, e3.target.result);
51274         };
51275       }(f2);
51276       reader.readAsText(f2);
51277       return this;
51278     };
51279     drawData.url = function(url, defaultExtension) {
51280       _template = null;
51281       _fileList = null;
51282       _geojson = null;
51283       _src = null;
51284       var testUrl = url.split(/[?#]/)[0];
51285       var extension = getExtension(testUrl) || defaultExtension;
51286       if (extension) {
51287         _template = null;
51288         text_default3(url).then(function(data) {
51289           drawData.setFile(extension, data);
51290         }).catch(function() {
51291         });
51292       } else {
51293         drawData.template(url);
51294       }
51295       return this;
51296     };
51297     drawData.getSrc = function() {
51298       return _src || "";
51299     };
51300     drawData.fitZoom = function() {
51301       var features = getFeatures(_geojson);
51302       if (!features.length)
51303         return;
51304       var map2 = context.map();
51305       var viewport = map2.trimmedExtent().polygon();
51306       var coords = features.reduce(function(coords2, feature3) {
51307         var geom = feature3.geometry;
51308         if (!geom)
51309           return coords2;
51310         var c2 = geom.coordinates;
51311         switch (geom.type) {
51312           case "Point":
51313             c2 = [c2];
51314           case "MultiPoint":
51315           case "LineString":
51316             break;
51317           case "MultiPolygon":
51318             c2 = utilArrayFlatten(c2);
51319           case "Polygon":
51320           case "MultiLineString":
51321             c2 = utilArrayFlatten(c2);
51322             break;
51323         }
51324         return utilArrayUnion(coords2, c2);
51325       }, []);
51326       if (!geoPolygonIntersectsPolygon(viewport, coords, true)) {
51327         var extent = geoExtent(bounds_default({ type: "LineString", coordinates: coords }));
51328         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
51329       }
51330       return this;
51331     };
51332     init2();
51333     return drawData;
51334   }
51335
51336   // modules/svg/debug.js
51337   function svgDebug(projection2, context) {
51338     function drawDebug(selection2) {
51339       const showTile = context.getDebug("tile");
51340       const showCollision = context.getDebug("collision");
51341       const showImagery = context.getDebug("imagery");
51342       const showTouchTargets = context.getDebug("target");
51343       const showDownloaded = context.getDebug("downloaded");
51344       let debugData = [];
51345       if (showTile) {
51346         debugData.push({ class: "red", label: "tile" });
51347       }
51348       if (showCollision) {
51349         debugData.push({ class: "yellow", label: "collision" });
51350       }
51351       if (showImagery) {
51352         debugData.push({ class: "orange", label: "imagery" });
51353       }
51354       if (showTouchTargets) {
51355         debugData.push({ class: "pink", label: "touchTargets" });
51356       }
51357       if (showDownloaded) {
51358         debugData.push({ class: "purple", label: "downloaded" });
51359       }
51360       let legend = context.container().select(".main-content").selectAll(".debug-legend").data(debugData.length ? [0] : []);
51361       legend.exit().remove();
51362       legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend);
51363       let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label);
51364       legendItems.exit().remove();
51365       legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label);
51366       let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []);
51367       layer.exit().remove();
51368       layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer);
51369       const extent = context.map().extent();
51370       _mainFileFetcher.get("imagery").then((d2) => {
51371         const hits = showImagery && d2.query.bbox(extent.rectangle(), true) || [];
51372         const features = hits.map((d4) => d4.features[d4.id]);
51373         let imagery = layer.selectAll("path.debug-imagery").data(features);
51374         imagery.exit().remove();
51375         imagery.enter().append("path").attr("class", "debug-imagery debug orange");
51376       }).catch(() => {
51377       });
51378       const osm = context.connection();
51379       let dataDownloaded = [];
51380       if (osm && showDownloaded) {
51381         const rtree = osm.caches("get").tile.rtree;
51382         dataDownloaded = rtree.all().map((bbox2) => {
51383           return {
51384             type: "Feature",
51385             properties: { id: bbox2.id },
51386             geometry: {
51387               type: "Polygon",
51388               coordinates: [[
51389                 [bbox2.minX, bbox2.minY],
51390                 [bbox2.minX, bbox2.maxY],
51391                 [bbox2.maxX, bbox2.maxY],
51392                 [bbox2.maxX, bbox2.minY],
51393                 [bbox2.minX, bbox2.minY]
51394               ]]
51395             }
51396           };
51397         });
51398       }
51399       let downloaded = layer.selectAll("path.debug-downloaded").data(showDownloaded ? dataDownloaded : []);
51400       downloaded.exit().remove();
51401       downloaded.enter().append("path").attr("class", "debug-downloaded debug purple");
51402       layer.selectAll("path").attr("d", svgPath(projection2).geojson);
51403     }
51404     drawDebug.enabled = function() {
51405       if (!arguments.length) {
51406         return context.getDebug("tile") || context.getDebug("collision") || context.getDebug("imagery") || context.getDebug("target") || context.getDebug("downloaded");
51407       } else {
51408         return this;
51409       }
51410     };
51411     return drawDebug;
51412   }
51413
51414   // modules/svg/defs.js
51415   function svgDefs(context) {
51416     var _defsSelection = select_default2(null);
51417     var _spritesheetIds = [
51418       "iD-sprite",
51419       "maki-sprite",
51420       "temaki-sprite",
51421       "fa-sprite",
51422       "roentgen-sprite",
51423       "community-sprite"
51424     ];
51425     function drawDefs(selection2) {
51426       _defsSelection = selection2.append("defs");
51427       _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");
51428       function addSidedMarker(name, color2, offset) {
51429         _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);
51430       }
51431       addSidedMarker("natural", "rgb(170, 170, 170)", 0);
51432       addSidedMarker("coastline", "#77dede", 1);
51433       addSidedMarker("waterway", "#77dede", 1);
51434       addSidedMarker("barrier", "#ddd", 1);
51435       addSidedMarker("man_made", "#fff", 0);
51436       _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");
51437       _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");
51438       var patterns2 = _defsSelection.selectAll("pattern").data([
51439         // pattern name, pattern image name
51440         ["beach", "dots"],
51441         ["construction", "construction"],
51442         ["cemetery", "cemetery"],
51443         ["cemetery_christian", "cemetery_christian"],
51444         ["cemetery_buddhist", "cemetery_buddhist"],
51445         ["cemetery_muslim", "cemetery_muslim"],
51446         ["cemetery_jewish", "cemetery_jewish"],
51447         ["farmland", "farmland"],
51448         ["farmyard", "farmyard"],
51449         ["forest", "forest"],
51450         ["forest_broadleaved", "forest_broadleaved"],
51451         ["forest_needleleaved", "forest_needleleaved"],
51452         ["forest_leafless", "forest_leafless"],
51453         ["golf_green", "grass"],
51454         ["grass", "grass"],
51455         ["landfill", "landfill"],
51456         ["meadow", "grass"],
51457         ["orchard", "orchard"],
51458         ["pond", "pond"],
51459         ["quarry", "quarry"],
51460         ["scrub", "bushes"],
51461         ["vineyard", "vineyard"],
51462         ["water_standing", "lines"],
51463         ["waves", "waves"],
51464         ["wetland", "wetland"],
51465         ["wetland_marsh", "wetland_marsh"],
51466         ["wetland_swamp", "wetland_swamp"],
51467         ["wetland_bog", "wetland_bog"],
51468         ["wetland_reedbed", "wetland_reedbed"]
51469       ]).enter().append("pattern").attr("id", function(d2) {
51470         return "ideditor-pattern-" + d2[0];
51471       }).attr("width", 32).attr("height", 32).attr("patternUnits", "userSpaceOnUse");
51472       patterns2.append("rect").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("class", function(d2) {
51473         return "pattern-color-" + d2[0];
51474       });
51475       patterns2.append("image").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("xlink:href", function(d2) {
51476         return context.imagePath("pattern/" + d2[1] + ".png");
51477       });
51478       _defsSelection.selectAll("clipPath").data([12, 18, 20, 32, 45]).enter().append("clipPath").attr("id", function(d2) {
51479         return "ideditor-clip-square-" + d2;
51480       }).append("rect").attr("x", 0).attr("y", 0).attr("width", function(d2) {
51481         return d2;
51482       }).attr("height", function(d2) {
51483         return d2;
51484       });
51485       addSprites(_spritesheetIds, true);
51486     }
51487     function addSprites(ids, overrideColors) {
51488       _spritesheetIds = utilArrayUniq(_spritesheetIds.concat(ids));
51489       var spritesheets = _defsSelection.selectAll(".spritesheet").data(_spritesheetIds);
51490       spritesheets.enter().append("g").attr("class", function(d2) {
51491         return "spritesheet spritesheet-" + d2;
51492       }).each(function(d2) {
51493         var url = context.imagePath(d2 + ".svg");
51494         var node = select_default2(this).node();
51495         svg(url).then(function(svg2) {
51496           node.appendChild(
51497             select_default2(svg2.documentElement).attr("id", "ideditor-" + d2).node()
51498           );
51499           if (overrideColors && d2 !== "iD-sprite") {
51500             select_default2(node).selectAll("path").attr("fill", "currentColor");
51501           }
51502         }).catch(function() {
51503         });
51504       });
51505       spritesheets.exit().remove();
51506     }
51507     drawDefs.addSprites = addSprites;
51508     return drawDefs;
51509   }
51510
51511   // modules/svg/keepRight.js
51512   var _layerEnabled = false;
51513   var _qaService;
51514   function svgKeepRight(projection2, context, dispatch14) {
51515     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
51516     const minZoom4 = 12;
51517     let touchLayer = select_default2(null);
51518     let drawLayer = select_default2(null);
51519     let layerVisible = false;
51520     function markerPath(selection2, klass) {
51521       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");
51522     }
51523     function getService() {
51524       if (services.keepRight && !_qaService) {
51525         _qaService = services.keepRight;
51526         _qaService.on("loaded", throttledRedraw);
51527       } else if (!services.keepRight && _qaService) {
51528         _qaService = null;
51529       }
51530       return _qaService;
51531     }
51532     function editOn() {
51533       if (!layerVisible) {
51534         layerVisible = true;
51535         drawLayer.style("display", "block");
51536       }
51537     }
51538     function editOff() {
51539       if (layerVisible) {
51540         layerVisible = false;
51541         drawLayer.style("display", "none");
51542         drawLayer.selectAll(".qaItem.keepRight").remove();
51543         touchLayer.selectAll(".qaItem.keepRight").remove();
51544       }
51545     }
51546     function layerOn() {
51547       editOn();
51548       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
51549     }
51550     function layerOff() {
51551       throttledRedraw.cancel();
51552       drawLayer.interrupt();
51553       touchLayer.selectAll(".qaItem.keepRight").remove();
51554       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
51555         editOff();
51556         dispatch14.call("change");
51557       });
51558     }
51559     function updateMarkers() {
51560       if (!layerVisible || !_layerEnabled)
51561         return;
51562       const service = getService();
51563       const selectedID = context.selectedErrorID();
51564       const data = service ? service.getItems(projection2) : [];
51565       const getTransform = svgPointTransform(projection2);
51566       const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51567       markers.exit().remove();
51568       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType));
51569       markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
51570       markersEnter.append("path").call(markerPath, "shadow");
51571       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");
51572       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
51573       if (touchLayer.empty())
51574         return;
51575       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
51576       const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51577       targets.exit().remove();
51578       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);
51579       function sortY(a2, b2) {
51580         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];
51581       }
51582     }
51583     function drawKeepRight(selection2) {
51584       const service = getService();
51585       const surface = context.surface();
51586       if (surface && !surface.empty()) {
51587         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
51588       }
51589       drawLayer = selection2.selectAll(".layer-keepRight").data(service ? [0] : []);
51590       drawLayer.exit().remove();
51591       drawLayer = drawLayer.enter().append("g").attr("class", "layer-keepRight").style("display", _layerEnabled ? "block" : "none").merge(drawLayer);
51592       if (_layerEnabled) {
51593         if (service && ~~context.map().zoom() >= minZoom4) {
51594           editOn();
51595           service.loadIssues(projection2);
51596           updateMarkers();
51597         } else {
51598           editOff();
51599         }
51600       }
51601     }
51602     drawKeepRight.enabled = function(val) {
51603       if (!arguments.length)
51604         return _layerEnabled;
51605       _layerEnabled = val;
51606       if (_layerEnabled) {
51607         layerOn();
51608       } else {
51609         layerOff();
51610         if (context.selectedErrorID()) {
51611           context.enter(modeBrowse(context));
51612         }
51613       }
51614       dispatch14.call("change");
51615       return this;
51616     };
51617     drawKeepRight.supported = () => !!getService();
51618     return drawKeepRight;
51619   }
51620
51621   // modules/svg/geolocate.js
51622   function svgGeolocate(projection2) {
51623     var layer = select_default2(null);
51624     var _position;
51625     function init2() {
51626       if (svgGeolocate.initialized)
51627         return;
51628       svgGeolocate.enabled = false;
51629       svgGeolocate.initialized = true;
51630     }
51631     function showLayer() {
51632       layer.style("display", "block");
51633     }
51634     function hideLayer() {
51635       layer.transition().duration(250).style("opacity", 0);
51636     }
51637     function layerOn() {
51638       layer.style("opacity", 0).transition().duration(250).style("opacity", 1);
51639     }
51640     function layerOff() {
51641       layer.style("display", "none");
51642     }
51643     function transform2(d2) {
51644       return svgPointTransform(projection2)(d2);
51645     }
51646     function accuracy(accuracy2, loc) {
51647       var degreesRadius = geoMetersToLat(accuracy2), tangentLoc = [loc[0], loc[1] + degreesRadius], projectedTangent = projection2(tangentLoc), projectedLoc = projection2([loc[0], loc[1]]);
51648       return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
51649     }
51650     function update() {
51651       var geolocation = { loc: [_position.coords.longitude, _position.coords.latitude] };
51652       var groups = layer.selectAll(".geolocations").selectAll(".geolocation").data([geolocation]);
51653       groups.exit().remove();
51654       var pointsEnter = groups.enter().append("g").attr("class", "geolocation");
51655       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");
51656       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");
51657       groups.merge(pointsEnter).attr("transform", transform2);
51658       layer.select(".geolocate-radius").attr("r", accuracy(_position.coords.accuracy, geolocation.loc));
51659     }
51660     function drawLocation(selection2) {
51661       var enabled = svgGeolocate.enabled;
51662       layer = selection2.selectAll(".layer-geolocate").data([0]);
51663       layer.exit().remove();
51664       var layerEnter = layer.enter().append("g").attr("class", "layer-geolocate").style("display", enabled ? "block" : "none");
51665       layerEnter.append("g").attr("class", "geolocations");
51666       layer = layerEnter.merge(layer);
51667       if (enabled) {
51668         update();
51669       } else {
51670         layerOff();
51671       }
51672     }
51673     drawLocation.enabled = function(position, enabled) {
51674       if (!arguments.length)
51675         return svgGeolocate.enabled;
51676       _position = position;
51677       svgGeolocate.enabled = enabled;
51678       if (svgGeolocate.enabled) {
51679         showLayer();
51680         layerOn();
51681       } else {
51682         hideLayer();
51683       }
51684       return this;
51685     };
51686     init2();
51687     return drawLocation;
51688   }
51689
51690   // modules/svg/labels.js
51691   var import_rbush6 = __toESM(require_rbush_min());
51692   function svgLabels(projection2, context) {
51693     var path = path_default(projection2);
51694     var detected = utilDetect();
51695     var baselineHack = detected.ie || detected.browser.toLowerCase() === "edge" || detected.browser.toLowerCase() === "firefox" && detected.version >= 70;
51696     var _rdrawn = new import_rbush6.default();
51697     var _rskipped = new import_rbush6.default();
51698     var _textWidthCache = {};
51699     var _entitybboxes = {};
51700     var labelStack = [
51701       ["line", "aeroway", "*", 12],
51702       ["line", "highway", "motorway", 12],
51703       ["line", "highway", "trunk", 12],
51704       ["line", "highway", "primary", 12],
51705       ["line", "highway", "secondary", 12],
51706       ["line", "highway", "tertiary", 12],
51707       ["line", "highway", "*", 12],
51708       ["line", "railway", "*", 12],
51709       ["line", "waterway", "*", 12],
51710       ["area", "aeroway", "*", 12],
51711       ["area", "amenity", "*", 12],
51712       ["area", "building", "*", 12],
51713       ["area", "historic", "*", 12],
51714       ["area", "leisure", "*", 12],
51715       ["area", "man_made", "*", 12],
51716       ["area", "natural", "*", 12],
51717       ["area", "shop", "*", 12],
51718       ["area", "tourism", "*", 12],
51719       ["area", "camp_site", "*", 12],
51720       ["point", "aeroway", "*", 10],
51721       ["point", "amenity", "*", 10],
51722       ["point", "building", "*", 10],
51723       ["point", "historic", "*", 10],
51724       ["point", "leisure", "*", 10],
51725       ["point", "man_made", "*", 10],
51726       ["point", "natural", "*", 10],
51727       ["point", "shop", "*", 10],
51728       ["point", "tourism", "*", 10],
51729       ["point", "camp_site", "*", 10],
51730       ["line", "ref", "*", 12],
51731       ["area", "ref", "*", 12],
51732       ["point", "ref", "*", 10],
51733       ["line", "name", "*", 12],
51734       ["area", "name", "*", 12],
51735       ["point", "name", "*", 10]
51736     ];
51737     function shouldSkipIcon(preset) {
51738       var noIcons = ["building", "landuse", "natural"];
51739       return noIcons.some(function(s2) {
51740         return preset.id.indexOf(s2) >= 0;
51741       });
51742     }
51743     function get4(array2, prop) {
51744       return function(d2, i3) {
51745         return array2[i3][prop];
51746       };
51747     }
51748     function textWidth(text, size, elem) {
51749       var c2 = _textWidthCache[size];
51750       if (!c2)
51751         c2 = _textWidthCache[size] = {};
51752       if (c2[text]) {
51753         return c2[text];
51754       } else if (elem) {
51755         c2[text] = elem.getComputedTextLength();
51756         return c2[text];
51757       } else {
51758         var str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
51759         if (str === null) {
51760           return size / 3 * 2 * text.length;
51761         } else {
51762           return size / 3 * (2 * text.length + str.length);
51763         }
51764       }
51765     }
51766     function drawLinePaths(selection2, entities, filter2, classes, labels) {
51767       var paths = selection2.selectAll("path").filter(filter2).data(entities, osmEntity.key);
51768       paths.exit().remove();
51769       paths.enter().append("path").style("stroke-width", get4(labels, "font-size")).attr("id", function(d2) {
51770         return "ideditor-labelpath-" + d2.id;
51771       }).attr("class", classes).merge(paths).attr("d", get4(labels, "lineString"));
51772     }
51773     function drawLineLabels(selection2, entities, filter2, classes, labels) {
51774       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51775       texts.exit().remove();
51776       texts.enter().append("text").attr("class", function(d2, i3) {
51777         return classes + " " + labels[i3].classes + " " + d2.id;
51778       }).attr("dy", baselineHack ? "0.35em" : null).append("textPath").attr("class", "textpath");
51779       selection2.selectAll("text." + classes).selectAll(".textpath").filter(filter2).data(entities, osmEntity.key).attr("startOffset", "50%").attr("xlink:href", function(d2) {
51780         return "#ideditor-labelpath-" + d2.id;
51781       }).text(utilDisplayNameForPath);
51782     }
51783     function drawPointLabels(selection2, entities, filter2, classes, labels) {
51784       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51785       texts.exit().remove();
51786       texts.enter().append("text").attr("class", function(d2, i3) {
51787         return classes + " " + labels[i3].classes + " " + d2.id;
51788       }).merge(texts).attr("x", get4(labels, "x")).attr("y", get4(labels, "y")).style("text-anchor", get4(labels, "textAnchor")).text(utilDisplayName).each(function(d2, i3) {
51789         textWidth(utilDisplayName(d2), labels[i3].height, this);
51790       });
51791     }
51792     function drawAreaLabels(selection2, entities, filter2, classes, labels) {
51793       entities = entities.filter(hasText);
51794       labels = labels.filter(hasText);
51795       drawPointLabels(selection2, entities, filter2, classes, labels);
51796       function hasText(d2, i3) {
51797         return labels[i3].hasOwnProperty("x") && labels[i3].hasOwnProperty("y");
51798       }
51799     }
51800     function drawAreaIcons(selection2, entities, filter2, classes, labels) {
51801       var icons = selection2.selectAll("use." + classes).filter(filter2).data(entities, osmEntity.key);
51802       icons.exit().remove();
51803       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) {
51804         var preset = _mainPresetIndex.match(d2, context.graph());
51805         var picon = preset && preset.icon;
51806         return picon ? "#" + picon : "";
51807       });
51808     }
51809     function drawCollisionBoxes(selection2, rtree, which) {
51810       var classes = "debug " + which + " " + (which === "debug-skipped" ? "orange" : "yellow");
51811       var gj = [];
51812       if (context.getDebug("collision")) {
51813         gj = rtree.all().map(function(d2) {
51814           return { type: "Polygon", coordinates: [[
51815             [d2.minX, d2.minY],
51816             [d2.maxX, d2.minY],
51817             [d2.maxX, d2.maxY],
51818             [d2.minX, d2.maxY],
51819             [d2.minX, d2.minY]
51820           ]] };
51821         });
51822       }
51823       var boxes = selection2.selectAll("." + which).data(gj);
51824       boxes.exit().remove();
51825       boxes.enter().append("path").attr("class", classes).merge(boxes).attr("d", path_default());
51826     }
51827     function drawLabels(selection2, graph, entities, filter2, dimensions, fullRedraw) {
51828       var wireframe = context.surface().classed("fill-wireframe");
51829       var zoom = geoScaleToZoom(projection2.scale());
51830       var labelable = [];
51831       var renderNodeAs = {};
51832       var i3, j2, k2, entity, geometry;
51833       for (i3 = 0; i3 < labelStack.length; i3++) {
51834         labelable.push([]);
51835       }
51836       if (fullRedraw) {
51837         _rdrawn.clear();
51838         _rskipped.clear();
51839         _entitybboxes = {};
51840       } else {
51841         for (i3 = 0; i3 < entities.length; i3++) {
51842           entity = entities[i3];
51843           var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []);
51844           for (j2 = 0; j2 < toRemove.length; j2++) {
51845             _rdrawn.remove(toRemove[j2]);
51846             _rskipped.remove(toRemove[j2]);
51847           }
51848         }
51849       }
51850       for (i3 = 0; i3 < entities.length; i3++) {
51851         entity = entities[i3];
51852         geometry = entity.geometry(graph);
51853         if (geometry === "point" || geometry === "vertex" && isInterestingVertex(entity)) {
51854           var hasDirections = entity.directions(graph, projection2).length;
51855           var markerPadding;
51856           if (!wireframe && geometry === "point" && !(zoom >= 18 && hasDirections)) {
51857             renderNodeAs[entity.id] = "point";
51858             markerPadding = 20;
51859           } else {
51860             renderNodeAs[entity.id] = "vertex";
51861             markerPadding = 0;
51862           }
51863           var coord2 = projection2(entity.loc);
51864           var nodePadding = 10;
51865           var bbox2 = {
51866             minX: coord2[0] - nodePadding,
51867             minY: coord2[1] - nodePadding - markerPadding,
51868             maxX: coord2[0] + nodePadding,
51869             maxY: coord2[1] + nodePadding
51870           };
51871           doInsert(bbox2, entity.id + "P");
51872         }
51873         if (geometry === "vertex") {
51874           geometry = "point";
51875         }
51876         var preset = geometry === "area" && _mainPresetIndex.match(entity, graph);
51877         var icon2 = preset && !shouldSkipIcon(preset) && preset.icon;
51878         if (!icon2 && !utilDisplayName(entity))
51879           continue;
51880         for (k2 = 0; k2 < labelStack.length; k2++) {
51881           var matchGeom = labelStack[k2][0];
51882           var matchKey = labelStack[k2][1];
51883           var matchVal = labelStack[k2][2];
51884           var hasVal = entity.tags[matchKey];
51885           if (geometry === matchGeom && hasVal && (matchVal === "*" || matchVal === hasVal)) {
51886             labelable[k2].push(entity);
51887             break;
51888           }
51889         }
51890       }
51891       var positions = {
51892         point: [],
51893         line: [],
51894         area: []
51895       };
51896       var labelled = {
51897         point: [],
51898         line: [],
51899         area: []
51900       };
51901       for (k2 = 0; k2 < labelable.length; k2++) {
51902         var fontSize = labelStack[k2][3];
51903         for (i3 = 0; i3 < labelable[k2].length; i3++) {
51904           entity = labelable[k2][i3];
51905           geometry = entity.geometry(graph);
51906           var getName = geometry === "line" ? utilDisplayNameForPath : utilDisplayName;
51907           var name = getName(entity);
51908           var width = name && textWidth(name, fontSize);
51909           var p2 = null;
51910           if (geometry === "point" || geometry === "vertex") {
51911             if (wireframe)
51912               continue;
51913             var renderAs = renderNodeAs[entity.id];
51914             if (renderAs === "vertex" && zoom < 17)
51915               continue;
51916             p2 = getPointLabel(entity, width, fontSize, renderAs);
51917           } else if (geometry === "line") {
51918             p2 = getLineLabel(entity, width, fontSize);
51919           } else if (geometry === "area") {
51920             p2 = getAreaLabel(entity, width, fontSize);
51921           }
51922           if (p2) {
51923             if (geometry === "vertex") {
51924               geometry = "point";
51925             }
51926             p2.classes = geometry + " tag-" + labelStack[k2][1];
51927             positions[geometry].push(p2);
51928             labelled[geometry].push(entity);
51929           }
51930         }
51931       }
51932       function isInterestingVertex(entity2) {
51933         var selectedIDs = context.selectedIDs();
51934         return entity2.hasInterestingTags() || entity2.isEndpoint(graph) || entity2.isConnected(graph) || selectedIDs.indexOf(entity2.id) !== -1 || graph.parentWays(entity2).some(function(parent) {
51935           return selectedIDs.indexOf(parent.id) !== -1;
51936         });
51937       }
51938       function getPointLabel(entity2, width2, height, geometry2) {
51939         var y2 = geometry2 === "point" ? -12 : 0;
51940         var pointOffsets = {
51941           ltr: [15, y2, "start"],
51942           rtl: [-15, y2, "end"]
51943         };
51944         var textDirection = _mainLocalizer.textDirection();
51945         var coord3 = projection2(entity2.loc);
51946         var textPadding = 2;
51947         var offset = pointOffsets[textDirection];
51948         var p3 = {
51949           height,
51950           width: width2,
51951           x: coord3[0] + offset[0],
51952           y: coord3[1] + offset[1],
51953           textAnchor: offset[2]
51954         };
51955         var bbox3;
51956         if (textDirection === "rtl") {
51957           bbox3 = {
51958             minX: p3.x - width2 - textPadding,
51959             minY: p3.y - height / 2 - textPadding,
51960             maxX: p3.x + textPadding,
51961             maxY: p3.y + height / 2 + textPadding
51962           };
51963         } else {
51964           bbox3 = {
51965             minX: p3.x - textPadding,
51966             minY: p3.y - height / 2 - textPadding,
51967             maxX: p3.x + width2 + textPadding,
51968             maxY: p3.y + height / 2 + textPadding
51969           };
51970         }
51971         if (tryInsert([bbox3], entity2.id, true)) {
51972           return p3;
51973         }
51974       }
51975       function getLineLabel(entity2, width2, height) {
51976         var viewport = geoExtent(context.projection.clipExtent()).polygon();
51977         var points = graph.childNodes(entity2).map(function(node) {
51978           return projection2(node.loc);
51979         });
51980         var length2 = geoPathLength(points);
51981         if (length2 < width2 + 20)
51982           return;
51983         var lineOffsets = [
51984           50,
51985           45,
51986           55,
51987           40,
51988           60,
51989           35,
51990           65,
51991           30,
51992           70,
51993           25,
51994           75,
51995           20,
51996           80,
51997           15,
51998           95,
51999           10,
52000           90,
52001           5,
52002           95
52003         ];
52004         var padding = 3;
52005         for (var i4 = 0; i4 < lineOffsets.length; i4++) {
52006           var offset = lineOffsets[i4];
52007           var middle = offset / 100 * length2;
52008           var start2 = middle - width2 / 2;
52009           if (start2 < 0 || start2 + width2 > length2)
52010             continue;
52011           var sub = subpath(points, start2, start2 + width2);
52012           if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) {
52013             continue;
52014           }
52015           var isReverse = reverse(sub);
52016           if (isReverse) {
52017             sub = sub.reverse();
52018           }
52019           var bboxes = [];
52020           var boxsize = (height + 2) / 2;
52021           for (var j3 = 0; j3 < sub.length - 1; j3++) {
52022             var a2 = sub[j3];
52023             var b2 = sub[j3 + 1];
52024             var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2));
52025             for (var box = 0; box < num; box++) {
52026               var p3 = geoVecInterp(a2, b2, box / num);
52027               var x05 = p3[0] - boxsize - padding;
52028               var y05 = p3[1] - boxsize - padding;
52029               var x12 = p3[0] + boxsize + padding;
52030               var y12 = p3[1] + boxsize + padding;
52031               bboxes.push({
52032                 minX: Math.min(x05, x12),
52033                 minY: Math.min(y05, y12),
52034                 maxX: Math.max(x05, x12),
52035                 maxY: Math.max(y05, y12)
52036               });
52037             }
52038           }
52039           if (tryInsert(bboxes, entity2.id, false)) {
52040             return {
52041               "font-size": height + 2,
52042               lineString: lineString2(sub),
52043               startOffset: offset + "%"
52044             };
52045           }
52046         }
52047         function reverse(p4) {
52048           var angle2 = Math.atan2(p4[1][1] - p4[0][1], p4[1][0] - p4[0][0]);
52049           return !(p4[0][0] < p4[p4.length - 1][0] && angle2 < Math.PI / 2 && angle2 > -Math.PI / 2);
52050         }
52051         function lineString2(points2) {
52052           return "M" + points2.join("L");
52053         }
52054         function subpath(points2, from, to) {
52055           var sofar = 0;
52056           var start3, end, i0, i1;
52057           for (var i5 = 0; i5 < points2.length - 1; i5++) {
52058             var a3 = points2[i5];
52059             var b3 = points2[i5 + 1];
52060             var current = geoVecLength(a3, b3);
52061             var portion;
52062             if (!start3 && sofar + current >= from) {
52063               portion = (from - sofar) / current;
52064               start3 = [
52065                 a3[0] + portion * (b3[0] - a3[0]),
52066                 a3[1] + portion * (b3[1] - a3[1])
52067               ];
52068               i0 = i5 + 1;
52069             }
52070             if (!end && sofar + current >= to) {
52071               portion = (to - sofar) / current;
52072               end = [
52073                 a3[0] + portion * (b3[0] - a3[0]),
52074                 a3[1] + portion * (b3[1] - a3[1])
52075               ];
52076               i1 = i5 + 1;
52077             }
52078             sofar += current;
52079           }
52080           var result = points2.slice(i0, i1);
52081           result.unshift(start3);
52082           result.push(end);
52083           return result;
52084         }
52085       }
52086       function getAreaLabel(entity2, width2, height) {
52087         var centroid = path.centroid(entity2.asGeoJSON(graph));
52088         var extent = entity2.extent(graph);
52089         var areaWidth = projection2(extent[1])[0] - projection2(extent[0])[0];
52090         if (isNaN(centroid[0]) || areaWidth < 20)
52091           return;
52092         var preset2 = _mainPresetIndex.match(entity2, context.graph());
52093         var picon = preset2 && preset2.icon;
52094         var iconSize = 17;
52095         var padding = 2;
52096         var p3 = {};
52097         if (picon) {
52098           if (addIcon()) {
52099             addLabel(iconSize + padding);
52100             return p3;
52101           }
52102         } else {
52103           if (addLabel(0)) {
52104             return p3;
52105           }
52106         }
52107         function addIcon() {
52108           var iconX = centroid[0] - iconSize / 2;
52109           var iconY = centroid[1] - iconSize / 2;
52110           var bbox3 = {
52111             minX: iconX,
52112             minY: iconY,
52113             maxX: iconX + iconSize,
52114             maxY: iconY + iconSize
52115           };
52116           if (tryInsert([bbox3], entity2.id + "I", true)) {
52117             p3.transform = "translate(" + iconX + "," + iconY + ")";
52118             return true;
52119           }
52120           return false;
52121         }
52122         function addLabel(yOffset) {
52123           if (width2 && areaWidth >= width2 + 20) {
52124             var labelX = centroid[0];
52125             var labelY = centroid[1] + yOffset;
52126             var bbox3 = {
52127               minX: labelX - width2 / 2 - padding,
52128               minY: labelY - height / 2 - padding,
52129               maxX: labelX + width2 / 2 + padding,
52130               maxY: labelY + height / 2 + padding
52131             };
52132             if (tryInsert([bbox3], entity2.id, true)) {
52133               p3.x = labelX;
52134               p3.y = labelY;
52135               p3.textAnchor = "middle";
52136               p3.height = height;
52137               return true;
52138             }
52139           }
52140           return false;
52141         }
52142       }
52143       function doInsert(bbox3, id2) {
52144         bbox3.id = id2;
52145         var oldbox = _entitybboxes[id2];
52146         if (oldbox) {
52147           _rdrawn.remove(oldbox);
52148         }
52149         _entitybboxes[id2] = bbox3;
52150         _rdrawn.insert(bbox3);
52151       }
52152       function tryInsert(bboxes, id2, saveSkipped) {
52153         var skipped = false;
52154         for (var i4 = 0; i4 < bboxes.length; i4++) {
52155           var bbox3 = bboxes[i4];
52156           bbox3.id = id2;
52157           if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) {
52158             skipped = true;
52159             break;
52160           }
52161           if (_rdrawn.collides(bbox3)) {
52162             skipped = true;
52163             break;
52164           }
52165         }
52166         _entitybboxes[id2] = bboxes;
52167         if (skipped) {
52168           if (saveSkipped) {
52169             _rskipped.load(bboxes);
52170           }
52171         } else {
52172           _rdrawn.load(bboxes);
52173         }
52174         return !skipped;
52175       }
52176       var layer = selection2.selectAll(".layer-osm.labels");
52177       layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) {
52178         return "labels-group " + d2;
52179       });
52180       var halo = layer.selectAll(".labels-group.halo");
52181       var label = layer.selectAll(".labels-group.label");
52182       var debug2 = layer.selectAll(".labels-group.debug");
52183       drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point);
52184       drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point);
52185       drawLinePaths(layer, labelled.line, filter2, "", positions.line);
52186       drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line);
52187       drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line);
52188       drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area);
52189       drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area);
52190       drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area);
52191       drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area);
52192       drawCollisionBoxes(debug2, _rskipped, "debug-skipped");
52193       drawCollisionBoxes(debug2, _rdrawn, "debug-drawn");
52194       layer.call(filterLabels);
52195     }
52196     function filterLabels(selection2) {
52197       var drawLayer = selection2.selectAll(".layer-osm.labels");
52198       var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label");
52199       layers.selectAll(".nolabel").classed("nolabel", false);
52200       var mouse = context.map().mouse();
52201       var graph = context.graph();
52202       var selectedIDs = context.selectedIDs();
52203       var ids = [];
52204       var pad2, bbox2;
52205       if (mouse) {
52206         pad2 = 20;
52207         bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 };
52208         var nearMouse = _rdrawn.search(bbox2).map(function(entity2) {
52209           return entity2.id;
52210         });
52211         ids.push.apply(ids, nearMouse);
52212       }
52213       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
52214         var entity = graph.hasEntity(selectedIDs[i3]);
52215         if (entity && entity.type === "node") {
52216           ids.push(selectedIDs[i3]);
52217         }
52218       }
52219       layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true);
52220       var debug2 = selection2.selectAll(".labels-group.debug");
52221       var gj = [];
52222       if (context.getDebug("collision")) {
52223         gj = bbox2 ? [{
52224           type: "Polygon",
52225           coordinates: [[
52226             [bbox2.minX, bbox2.minY],
52227             [bbox2.maxX, bbox2.minY],
52228             [bbox2.maxX, bbox2.maxY],
52229             [bbox2.minX, bbox2.maxY],
52230             [bbox2.minX, bbox2.minY]
52231           ]]
52232         }] : [];
52233       }
52234       var box = debug2.selectAll(".debug-mouse").data(gj);
52235       box.exit().remove();
52236       box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default());
52237     }
52238     var throttleFilterLabels = throttle_default(filterLabels, 100);
52239     drawLabels.observe = function(selection2) {
52240       var listener = function() {
52241         throttleFilterLabels(selection2);
52242       };
52243       selection2.on("mousemove.hidelabels", listener);
52244       context.on("enter.hidelabels", listener);
52245     };
52246     drawLabels.off = function(selection2) {
52247       throttleFilterLabels.cancel();
52248       selection2.on("mousemove.hidelabels", null);
52249       context.on("enter.hidelabels", null);
52250     };
52251     return drawLabels;
52252   }
52253
52254   // node_modules/exifr/dist/full.esm.mjs
52255   var e = "undefined" != typeof self ? self : global;
52256   var t = "undefined" != typeof navigator;
52257   var i2 = t && "undefined" == typeof HTMLImageElement;
52258   var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node);
52259   var s = e.Buffer;
52260   var r = e.BigInt;
52261   var a = !!s;
52262   var o = (e3) => e3;
52263   function l(e3, t2 = o) {
52264     if (n2)
52265       try {
52266         return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import(
52267           /* webpackIgnore: true */
52268           e3
52269         ).then(t2);
52270       } catch (t3) {
52271         console.warn("Couldn't load ".concat(e3));
52272       }
52273   }
52274   var h = e.fetch;
52275   var u = (e3) => h = e3;
52276   if (!e.fetch) {
52277     const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => {
52278       let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3);
52279       const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 };
52280       "" !== o2 && (f2.port = Number(o2));
52281       const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => {
52282         if (301 === e4.statusCode || 302 === e4.statusCode) {
52283           let t3 = new URL(e4.headers.location, n3).toString();
52284           return i3(t3, { headers: s2 }).then(r2).catch(a2);
52285         }
52286         r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => {
52287           let i4 = [];
52288           e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4)));
52289         }) });
52290       });
52291       d2.on("error", a2), d2.end();
52292     });
52293     u(i3);
52294   }
52295   function c(e3, t2, i3) {
52296     return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3;
52297   }
52298   var f = (e3) => p(e3) ? void 0 : e3;
52299   var d = (e3) => void 0 !== e3;
52300   function p(e3) {
52301     return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length);
52302   }
52303   function g2(e3) {
52304     let t2 = new Error(e3);
52305     throw delete t2.stack, t2;
52306   }
52307   function m(e3) {
52308     return "" === (e3 = function(e4) {
52309       for (; e4.endsWith("\0"); )
52310         e4 = e4.slice(0, -1);
52311       return e4;
52312     }(e3).trim()) ? void 0 : e3;
52313   }
52314   function S(e3) {
52315     let t2 = function(e4) {
52316       let t3 = 0;
52317       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;
52318     }(e3);
52319     return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2;
52320   }
52321   var C = (e3) => String.fromCharCode.apply(null, e3);
52322   var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0;
52323   function b(e3) {
52324     return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3)));
52325   }
52326   var I = class _I {
52327     static from(e3, t2) {
52328       return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2);
52329     }
52330     constructor(e3, t2 = 0, i3, n3) {
52331       if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3)
52332         this.byteOffset = 0, this.byteLength = 0;
52333       else if (e3 instanceof ArrayBuffer) {
52334         void 0 === i3 && (i3 = e3.byteLength - t2);
52335         let n4 = new DataView(e3, t2, i3);
52336         this._swapDataView(n4);
52337       } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) {
52338         void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer");
52339         let n4 = new DataView(e3.buffer, t2, i3);
52340         this._swapDataView(n4);
52341       } else if ("number" == typeof e3) {
52342         let t3 = new DataView(new ArrayBuffer(e3));
52343         this._swapDataView(t3);
52344       } else
52345         g2("Invalid input argument for BufferView: " + e3);
52346     }
52347     _swapArrayBuffer(e3) {
52348       this._swapDataView(new DataView(e3));
52349     }
52350     _swapBuffer(e3) {
52351       this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength));
52352     }
52353     _swapDataView(e3) {
52354       this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength;
52355     }
52356     _lengthToEnd(e3) {
52357       return this.byteLength - e3;
52358     }
52359     set(e3, t2, i3 = _I) {
52360       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);
52361     }
52362     subarray(e3, t2) {
52363       return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2);
52364     }
52365     toUint8() {
52366       return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
52367     }
52368     getUint8Array(e3, t2) {
52369       return new Uint8Array(this.buffer, this.byteOffset + e3, t2);
52370     }
52371     getString(e3 = 0, t2 = this.byteLength) {
52372       return b(this.getUint8Array(e3, t2));
52373     }
52374     getLatin1String(e3 = 0, t2 = this.byteLength) {
52375       let i3 = this.getUint8Array(e3, t2);
52376       return C(i3);
52377     }
52378     getUnicodeString(e3 = 0, t2 = this.byteLength) {
52379       const i3 = [];
52380       for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2)
52381         i3.push(this.getUint16(e3 + n3));
52382       return C(i3);
52383     }
52384     getInt8(e3) {
52385       return this.dataView.getInt8(e3);
52386     }
52387     getUint8(e3) {
52388       return this.dataView.getUint8(e3);
52389     }
52390     getInt16(e3, t2 = this.le) {
52391       return this.dataView.getInt16(e3, t2);
52392     }
52393     getInt32(e3, t2 = this.le) {
52394       return this.dataView.getInt32(e3, t2);
52395     }
52396     getUint16(e3, t2 = this.le) {
52397       return this.dataView.getUint16(e3, t2);
52398     }
52399     getUint32(e3, t2 = this.le) {
52400       return this.dataView.getUint32(e3, t2);
52401     }
52402     getFloat32(e3, t2 = this.le) {
52403       return this.dataView.getFloat32(e3, t2);
52404     }
52405     getFloat64(e3, t2 = this.le) {
52406       return this.dataView.getFloat64(e3, t2);
52407     }
52408     getFloat(e3, t2 = this.le) {
52409       return this.dataView.getFloat32(e3, t2);
52410     }
52411     getDouble(e3, t2 = this.le) {
52412       return this.dataView.getFloat64(e3, t2);
52413     }
52414     getUintBytes(e3, t2, i3) {
52415       switch (t2) {
52416         case 1:
52417           return this.getUint8(e3, i3);
52418         case 2:
52419           return this.getUint16(e3, i3);
52420         case 4:
52421           return this.getUint32(e3, i3);
52422         case 8:
52423           return this.getUint64 && this.getUint64(e3, i3);
52424       }
52425     }
52426     getUint(e3, t2, i3) {
52427       switch (t2) {
52428         case 8:
52429           return this.getUint8(e3, i3);
52430         case 16:
52431           return this.getUint16(e3, i3);
52432         case 32:
52433           return this.getUint32(e3, i3);
52434         case 64:
52435           return this.getUint64 && this.getUint64(e3, i3);
52436       }
52437     }
52438     toString(e3) {
52439       return this.dataView.toString(e3, this.constructor.name);
52440     }
52441     ensureChunk() {
52442     }
52443   };
52444   function P(e3, t2) {
52445     g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr."));
52446   }
52447   var k = class extends Map {
52448     constructor(e3) {
52449       super(), this.kind = e3;
52450     }
52451     get(e3, t2) {
52452       return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) {
52453         g2("Unknown ".concat(e4, " '").concat(t3, "'."));
52454       }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3);
52455     }
52456     keyList() {
52457       return Array.from(this.keys());
52458     }
52459   };
52460   var w = new k("file parser");
52461   var T = new k("segment parser");
52462   var A = new k("file reader");
52463   function D(e3, n3) {
52464     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");
52465   }
52466   function O(e3, i3) {
52467     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");
52468     var s2;
52469   }
52470   async function x(e3, t2, i3, n3) {
52471     return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) {
52472       let i4 = await t3(e4);
52473       return new I(i4);
52474     }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded"));
52475   }
52476   async function v(e3, t2, i3) {
52477     let n3 = new (A.get(i3))(e3, t2);
52478     return await n3.read(), n3;
52479   }
52480   var M = (e3) => h(e3).then((e4) => e4.arrayBuffer());
52481   var R = (e3) => new Promise((t2, i3) => {
52482     let n3 = new FileReader();
52483     n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3);
52484   });
52485   var L = class extends Map {
52486     get tagKeys() {
52487       return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys;
52488     }
52489     get tagValues() {
52490       return this.allValues || (this.allValues = Array.from(this.values())), this.allValues;
52491     }
52492   };
52493   function U(e3, t2, i3) {
52494     let n3 = new L();
52495     for (let [e4, t3] of i3)
52496       n3.set(e4, t3);
52497     if (Array.isArray(t2))
52498       for (let i4 of t2)
52499         e3.set(i4, n3);
52500     else
52501       e3.set(t2, n3);
52502     return n3;
52503   }
52504   function F(e3, t2, i3) {
52505     let n3, s2 = e3.get(t2);
52506     for (n3 of i3)
52507       s2.set(n3[0], n3[1]);
52508   }
52509   var E = /* @__PURE__ */ new Map();
52510   var B = /* @__PURE__ */ new Map();
52511   var N = /* @__PURE__ */ new Map();
52512   var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"];
52513   var V = ["jfif", "xmp", "icc", "iptc", "ihdr"];
52514   var z = ["tiff", ...V];
52515   var H = ["ifd0", "ifd1", "exif", "gps", "interop"];
52516   var j = [...z, ...H];
52517   var W = ["makerNote", "userComment"];
52518   var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"];
52519   var X = [...K, "sanitize", "mergeOutput", "silentErrors"];
52520   var _ = class {
52521     get translate() {
52522       return this.translateKeys || this.translateValues || this.reviveValues;
52523     }
52524   };
52525   var Y = class extends _ {
52526     get needed() {
52527       return this.enabled || this.deps.size > 0;
52528     }
52529     constructor(e3, t2, i3, n3) {
52530       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)
52531         if (Array.isArray(i3))
52532           this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick);
52533         else if ("object" == typeof i3) {
52534           if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) {
52535             let { pick: e4, skip: t3 } = i3;
52536             e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip);
52537           }
52538           this.applyInheritables(i3);
52539         } else
52540           true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3));
52541     }
52542     applyInheritables(e3) {
52543       let t2, i3;
52544       for (t2 of K)
52545         i3 = e3[t2], void 0 !== i3 && (this[t2] = i3);
52546     }
52547     translateTagSet(e3, t2) {
52548       if (this.dict) {
52549         let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict;
52550         for (i3 of e3)
52551           "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3);
52552       } else
52553         for (let i3 of e3)
52554           t2.add(i3);
52555     }
52556     finalizeFilters() {
52557       !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);
52558     }
52559   };
52560   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 };
52561   var J = /* @__PURE__ */ new Map();
52562   var q = class extends _ {
52563     static useCached(e3) {
52564       let t2 = J.get(e3);
52565       return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2;
52566     }
52567     constructor(e3) {
52568       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();
52569     }
52570     setupFromUndefined() {
52571       let e3;
52572       for (e3 of G)
52573         this[e3] = $2[e3];
52574       for (e3 of X)
52575         this[e3] = $2[e3];
52576       for (e3 of W)
52577         this[e3] = $2[e3];
52578       for (e3 of j)
52579         this[e3] = new Y(e3, $2[e3], void 0, this);
52580     }
52581     setupFromTrue() {
52582       let e3;
52583       for (e3 of G)
52584         this[e3] = $2[e3];
52585       for (e3 of X)
52586         this[e3] = $2[e3];
52587       for (e3 of W)
52588         this[e3] = true;
52589       for (e3 of j)
52590         this[e3] = new Y(e3, true, void 0, this);
52591     }
52592     setupFromArray(e3) {
52593       let t2;
52594       for (t2 of G)
52595         this[t2] = $2[t2];
52596       for (t2 of X)
52597         this[t2] = $2[t2];
52598       for (t2 of W)
52599         this[t2] = $2[t2];
52600       for (t2 of j)
52601         this[t2] = new Y(t2, false, void 0, this);
52602       this.setupGlobalFilters(e3, void 0, H);
52603     }
52604     setupFromObject(e3) {
52605       let t2;
52606       for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G))
52607         this[t2] = Z(e3[t2], $2[t2]);
52608       for (t2 of X)
52609         this[t2] = Z(e3[t2], $2[t2]);
52610       for (t2 of W)
52611         this[t2] = Z(e3[t2], $2[t2]);
52612       for (t2 of z)
52613         this[t2] = new Y(t2, $2[t2], e3[t2], this);
52614       for (t2 of H)
52615         this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff);
52616       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);
52617     }
52618     batchEnableWithBool(e3, t2) {
52619       for (let i3 of e3)
52620         this[i3].enabled = t2;
52621     }
52622     batchEnableWithUserValue(e3, t2) {
52623       for (let i3 of e3) {
52624         let e4 = t2[i3];
52625         this[i3].enabled = false !== e4 && void 0 !== e4;
52626       }
52627     }
52628     setupGlobalFilters(e3, t2, i3, n3 = i3) {
52629       if (e3 && e3.length) {
52630         for (let e4 of n3)
52631           this[e4].enabled = false;
52632         let t3 = Q(e3, i3);
52633         for (let [e4, i4] of t3)
52634           ee(this[e4].pick, i4), this[e4].enabled = true;
52635       } else if (t2 && t2.length) {
52636         let e4 = Q(t2, i3);
52637         for (let [t3, i4] of e4)
52638           ee(this[t3].skip, i4);
52639       }
52640     }
52641     filterNestedSegmentTags() {
52642       let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this;
52643       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);
52644     }
52645     traverseTiffDependencyTree() {
52646       let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this;
52647       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;
52648       for (let e4 of H)
52649         this[e4].finalizeFilters();
52650     }
52651     get onlyTiff() {
52652       return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled;
52653     }
52654     checkLoadedPlugins() {
52655       for (let e3 of z)
52656         this[e3].enabled && !T.has(e3) && P("segment parser", e3);
52657     }
52658   };
52659   function Q(e3, t2) {
52660     let i3, n3, s2, r2, a2 = [];
52661     for (s2 of t2) {
52662       for (r2 of (i3 = E.get(s2), n3 = [], i3))
52663         (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]);
52664       n3.length && a2.push([s2, n3]);
52665     }
52666     return a2;
52667   }
52668   function Z(e3, t2) {
52669     return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0;
52670   }
52671   function ee(e3, t2) {
52672     for (let i3 of t2)
52673       e3.add(i3);
52674   }
52675   c(q, "default", $2);
52676   var te = class {
52677     constructor(e3) {
52678       c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3);
52679     }
52680     async read(e3) {
52681       this.file = await D(e3, this.options);
52682     }
52683     setup() {
52684       if (this.fileParser)
52685         return;
52686       let { file: e3 } = this, t2 = e3.getUint16(0);
52687       for (let [i3, n3] of w)
52688         if (n3.canHandle(e3, t2))
52689           return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true;
52690       this.file.close && this.file.close(), g2("Unknown file format");
52691     }
52692     async parse() {
52693       let { output: e3, errors: t2 } = this;
52694       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);
52695     }
52696     async executeParsers() {
52697       let { output: e3 } = this;
52698       await this.fileParser.parse();
52699       let t2 = Object.values(this.parsers).map(async (t3) => {
52700         let i3 = await t3.parse();
52701         t3.assignToOutput(e3, i3);
52702       });
52703       this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2);
52704     }
52705     async extractThumbnail() {
52706       this.setup();
52707       let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3);
52708       var n3;
52709       if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3)
52710         return;
52711       let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail();
52712       return t2.close && t2.close(), a2;
52713     }
52714   };
52715   async function ie(e3, t2) {
52716     let i3 = new te(t2);
52717     return await i3.read(e3), i3.parse();
52718   }
52719   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 });
52720   var se = class {
52721     constructor(e3, t2, i3) {
52722       c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => {
52723         let t3 = e4.start, i4 = e4.size || 65536;
52724         if (this.file.chunked)
52725           if (this.file.available(t3, i4))
52726             e4.chunk = this.file.subarray(t3, i4);
52727           else
52728             try {
52729               e4.chunk = await this.file.readChunk(t3, i4);
52730             } catch (t4) {
52731               g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message));
52732             }
52733         else
52734           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));
52735         return e4.chunk;
52736       }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3;
52737     }
52738     injectSegment(e3, t2) {
52739       this.options[e3].enabled && this.createParser(e3, t2);
52740     }
52741     createParser(e3, t2) {
52742       let i3 = new (T.get(e3))(t2, this.options, this.file);
52743       return this.parsers[e3] = i3;
52744     }
52745     createParsers(e3) {
52746       for (let t2 of e3) {
52747         let { type: e4, chunk: i3 } = t2, n3 = this.options[e4];
52748         if (n3 && n3.enabled) {
52749           let t3 = this.parsers[e4];
52750           t3 && t3.append || t3 || this.createParser(e4, i3);
52751         }
52752       }
52753     }
52754     async readSegments(e3) {
52755       let t2 = e3.map(this.ensureSegmentChunk);
52756       await Promise.all(t2);
52757     }
52758   };
52759   var re2 = class {
52760     static findPosition(e3, t2) {
52761       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;
52762       return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 };
52763     }
52764     static parse(e3, t2 = {}) {
52765       return new this(e3, new q({ [this.type]: t2 }), e3).parse();
52766     }
52767     normalizeInput(e3) {
52768       return e3 instanceof I ? e3 : new I(e3);
52769     }
52770     constructor(e3, t2 = {}, i3) {
52771       c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => {
52772         if (!this.options.silentErrors)
52773           throw e4;
52774         this.errors.push(e4.message);
52775       }), 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;
52776     }
52777     translate() {
52778       this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type));
52779     }
52780     get output() {
52781       return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0;
52782     }
52783     translateBlock(e3, t2) {
52784       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 = {};
52785       for (let [t3, r3] of e3)
52786         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;
52787       return h2;
52788     }
52789     translateValue(e3, t2) {
52790       return t2[e3] || t2.DEFAULT || e3;
52791     }
52792     assignToOutput(e3, t2) {
52793       this.assignObjectToOutput(e3, this.constructor.type, t2);
52794     }
52795     assignObjectToOutput(e3, t2, i3) {
52796       if (this.globalOptions.mergeOutput)
52797         return Object.assign(e3, i3);
52798       e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3;
52799     }
52800   };
52801   c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false);
52802   function ae(e3) {
52803     return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3;
52804   }
52805   function oe(e3) {
52806     return e3 >= 224 && e3 <= 239;
52807   }
52808   function le(e3, t2, i3) {
52809     for (let [n3, s2] of T)
52810       if (s2.canHandle(e3, t2, i3))
52811         return n3;
52812   }
52813   var he = class extends se {
52814     constructor(...e3) {
52815       super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []);
52816     }
52817     static canHandle(e3, t2) {
52818       return 65496 === t2;
52819     }
52820     async parse() {
52821       await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments);
52822     }
52823     setupSegmentFinderArgs(e3) {
52824       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;
52825     }
52826     async findAppSegments(e3 = 0, t2) {
52827       this.setupSegmentFinderArgs(t2);
52828       let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this;
52829       if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => {
52830         let t3 = T.get(e4), i4 = this.options[e4];
52831         return t3.multiSegment && i4.multiSegment;
52832       }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) {
52833         let t3 = false;
52834         for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) {
52835           let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size));
52836           if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength)))
52837             return;
52838         }
52839       }
52840     }
52841     findAppSegmentsInRange(e3, t2) {
52842       t2 -= 2;
52843       let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this;
52844       for (; e3 < t2; e3++)
52845         if (255 === l2.getUint8(e3)) {
52846           if (i3 = l2.getUint8(e3 + 1), oe(i3)) {
52847             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)))
52848               break;
52849             f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1;
52850           } else if (ae(i3)) {
52851             if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos)
52852               return;
52853             f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1;
52854           }
52855         }
52856       return e3;
52857     }
52858     mergeMultiSegments() {
52859       if (!this.appSegments.some((e4) => e4.multiSegment))
52860         return;
52861       let e3 = function(e4, t2) {
52862         let i3, n3, s2, r2 = /* @__PURE__ */ new Map();
52863         for (let a2 = 0; a2 < e4.length; a2++)
52864           i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3);
52865         return Array.from(r2);
52866       }(this.appSegments, "type");
52867       this.mergedAppSegments = e3.map(([e4, t2]) => {
52868         let i3 = T.get(e4, this.options);
52869         if (i3.handleMultiSegments) {
52870           return { type: e4, chunk: i3.handleMultiSegments(t2) };
52871         }
52872         return t2[0];
52873       });
52874     }
52875     getSegment(e3) {
52876       return this.appSegments.find((t2) => t2.type === e3);
52877     }
52878     async getOrFindSegment(e3) {
52879       let t2 = this.getSegment(e3);
52880       return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2;
52881     }
52882   };
52883   c(he, "type", "jpeg"), w.set("jpeg", he);
52884   var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4];
52885   var ce = class extends re2 {
52886     parseHeader() {
52887       var e3 = this.chunk.getUint16();
52888       18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true;
52889     }
52890     parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) {
52891       let { pick: n3, skip: s2 } = this.options[t2];
52892       n3 = new Set(n3);
52893       let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3);
52894       e3 += 2;
52895       for (let l2 = 0; l2 < o2; l2++) {
52896         let o3 = this.chunk.getUint16(e3);
52897         if (r2) {
52898           if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size))
52899             break;
52900         } else
52901           !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2));
52902         e3 += 12;
52903       }
52904       return i3;
52905     }
52906     parseTag(e3, t2, i3) {
52907       let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2];
52908       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)
52909         return n3.getUint8Array(e3, r2);
52910       if (2 === s2)
52911         return m(n3.getString(e3, r2));
52912       if (7 === s2)
52913         return n3.getUint8Array(e3, r2);
52914       if (1 === r2)
52915         return this.parseTagValue(s2, e3);
52916       {
52917         let t3 = new (function(e4) {
52918           switch (e4) {
52919             case 1:
52920               return Uint8Array;
52921             case 3:
52922               return Uint16Array;
52923             case 4:
52924               return Uint32Array;
52925             case 5:
52926               return Array;
52927             case 6:
52928               return Int8Array;
52929             case 8:
52930               return Int16Array;
52931             case 9:
52932               return Int32Array;
52933             case 10:
52934               return Array;
52935             case 11:
52936               return Float32Array;
52937             case 12:
52938               return Float64Array;
52939             default:
52940               return Array;
52941           }
52942         }(s2))(r2), i4 = a2;
52943         for (let n4 = 0; n4 < r2; n4++)
52944           t3[n4] = this.parseTagValue(s2, e3), e3 += i4;
52945         return t3;
52946       }
52947     }
52948     parseTagValue(e3, t2) {
52949       let { chunk: i3 } = this;
52950       switch (e3) {
52951         case 1:
52952           return i3.getUint8(t2);
52953         case 3:
52954           return i3.getUint16(t2);
52955         case 4:
52956           return i3.getUint32(t2);
52957         case 5:
52958           return i3.getUint32(t2) / i3.getUint32(t2 + 4);
52959         case 6:
52960           return i3.getInt8(t2);
52961         case 8:
52962           return i3.getInt16(t2);
52963         case 9:
52964           return i3.getInt32(t2);
52965         case 10:
52966           return i3.getInt32(t2) / i3.getInt32(t2 + 4);
52967         case 11:
52968           return i3.getFloat(t2);
52969         case 12:
52970           return i3.getDouble(t2);
52971         case 13:
52972           return i3.getUint32(t2);
52973         default:
52974           g2("Invalid tiff type ".concat(e3));
52975       }
52976     }
52977   };
52978   var fe = class extends ce {
52979     static canHandle(e3, t2) {
52980       return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8);
52981     }
52982     async parse() {
52983       this.parseHeader();
52984       let { options: e3 } = this;
52985       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();
52986     }
52987     safeParse(e3) {
52988       let t2 = this[e3]();
52989       return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2;
52990     }
52991     findIfd0Offset() {
52992       void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4));
52993     }
52994     findIfd1Offset() {
52995       if (void 0 === this.ifd1Offset) {
52996         this.findIfd0Offset();
52997         let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3;
52998         this.ifd1Offset = this.chunk.getUint32(t2);
52999       }
53000     }
53001     parseBlock(e3, t2) {
53002       let i3 = /* @__PURE__ */ new Map();
53003       return this[t2] = i3, this.parseTags(e3, t2, i3), i3;
53004     }
53005     async parseIfd0Block() {
53006       if (this.ifd0)
53007         return;
53008       let { file: e3 } = this;
53009       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));
53010       let t2 = this.parseBlock(this.ifd0Offset, "ifd0");
53011       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;
53012     }
53013     async parseExifBlock() {
53014       if (this.exif)
53015         return;
53016       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset)
53017         return;
53018       this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options));
53019       let e3 = this.parseBlock(this.exifOffset, "exif");
53020       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;
53021     }
53022     unpack(e3, t2) {
53023       let i3 = e3.get(t2);
53024       i3 && 1 === i3.length && e3.set(t2, i3[0]);
53025     }
53026     async parseGpsBlock() {
53027       if (this.gps)
53028         return;
53029       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset)
53030         return;
53031       let e3 = this.parseBlock(this.gpsOffset, "gps");
53032       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;
53033     }
53034     async parseInteropBlock() {
53035       if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset))
53036         return this.parseBlock(this.interopOffset, "interop");
53037     }
53038     async parseThumbnailBlock(e3 = false) {
53039       if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3))
53040         return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1;
53041     }
53042     async extractThumbnail() {
53043       if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1)
53044         return;
53045       let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514);
53046       return this.chunk.getUint8Array(e3, t2);
53047     }
53048     get image() {
53049       return this.ifd0;
53050     }
53051     get thumbnail() {
53052       return this.ifd1;
53053     }
53054     createOutput() {
53055       let e3, t2, i3, n3 = {};
53056       for (t2 of H)
53057         if (e3 = this[t2], !p(e3))
53058           if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) {
53059             if ("ifd1" === t2)
53060               continue;
53061             Object.assign(n3, i3);
53062           } else
53063             n3[t2] = i3;
53064       return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3;
53065     }
53066     assignToOutput(e3, t2) {
53067       if (this.globalOptions.mergeOutput)
53068         Object.assign(e3, t2);
53069       else
53070         for (let [i3, n3] of Object.entries(t2))
53071           this.assignObjectToOutput(e3, i3, n3);
53072     }
53073   };
53074   function de(e3, t2, i3, n3) {
53075     var s2 = e3 + t2 / 60 + i3 / 3600;
53076     return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2;
53077   }
53078   c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe);
53079   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 });
53080   var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false };
53081   var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] });
53082   async function Se(e3) {
53083     let t2 = new te(me);
53084     await t2.read(e3);
53085     let i3 = await t2.parse();
53086     if (i3 && i3.gps) {
53087       let { latitude: e4, longitude: t3 } = i3.gps;
53088       return { latitude: e4, longitude: t3 };
53089     }
53090   }
53091   var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false });
53092   async function ye(e3) {
53093     let t2 = new te(Ce);
53094     await t2.read(e3);
53095     let i3 = await t2.extractThumbnail();
53096     return i3 && a ? s.from(i3) : i3;
53097   }
53098   async function be(e3) {
53099     let t2 = await this.thumbnail(e3);
53100     if (void 0 !== t2) {
53101       let e4 = new Blob([t2]);
53102       return URL.createObjectURL(e4);
53103     }
53104   }
53105   var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] });
53106   async function Pe(e3) {
53107     let t2 = new te(Ie);
53108     await t2.read(e3);
53109     let i3 = await t2.parse();
53110     if (i3 && i3.ifd0)
53111       return i3.ifd0[274];
53112   }
53113   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 } });
53114   var we = true;
53115   var Te = true;
53116   if ("object" == typeof navigator) {
53117     let e3 = navigator.userAgent;
53118     if (e3.includes("iPad") || e3.includes("iPhone")) {
53119       let t2 = e3.match(/OS (\d+)_(\d+)/);
53120       if (t2) {
53121         let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3);
53122         we = n3 < 13.4, Te = false;
53123       }
53124     } else if (e3.includes("OS X 10")) {
53125       let [, t2] = e3.match(/OS X 10[_.](\d+)/);
53126       we = Te = Number(t2) < 15;
53127     }
53128     if (e3.includes("Chrome/")) {
53129       let [, t2] = e3.match(/Chrome\/(\d+)/);
53130       we = Te = Number(t2) < 81;
53131     } else if (e3.includes("Firefox/")) {
53132       let [, t2] = e3.match(/Firefox\/(\d+)/);
53133       we = Te = Number(t2) < 77;
53134     }
53135   }
53136   async function Ae(e3) {
53137     let t2 = await Pe(e3);
53138     return Object.assign({ canvas: we, css: Te }, ke[t2]);
53139   }
53140   var De = class extends I {
53141     constructor(...e3) {
53142       super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength);
53143     }
53144     _tryExtend(e3, t2, i3) {
53145       if (0 === e3 && 0 === this.byteLength && i3) {
53146         let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength);
53147         this._swapDataView(e4);
53148       } else {
53149         let i4 = e3 + t2;
53150         if (i4 > this.byteLength) {
53151           let { dataView: e4 } = this._extend(i4);
53152           this._swapDataView(e4);
53153         }
53154       }
53155     }
53156     _extend(e3) {
53157       let t2;
53158       t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3);
53159       let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength);
53160       return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 };
53161     }
53162     subarray(e3, t2, i3 = false) {
53163       return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2);
53164     }
53165     set(e3, t2, i3 = false) {
53166       i3 && this._tryExtend(t2, e3.byteLength, e3);
53167       let n3 = super.set(e3, t2);
53168       return this.ranges.add(t2, n3.byteLength), n3;
53169     }
53170     async ensureChunk(e3, t2) {
53171       this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2));
53172     }
53173     available(e3, t2) {
53174       return this.ranges.available(e3, t2);
53175     }
53176   };
53177   var Oe = class {
53178     constructor() {
53179       c(this, "list", []);
53180     }
53181     get length() {
53182       return this.list.length;
53183     }
53184     add(e3, t2, i3 = 0) {
53185       let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3));
53186       if (s2.length > 0) {
53187         e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3;
53188         let i4 = s2.shift();
53189         i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4));
53190       } else
53191         this.list.push({ offset: e3, length: t2, end: n3 });
53192     }
53193     available(e3, t2) {
53194       let i3 = e3 + t2;
53195       return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end);
53196     }
53197   };
53198   function xe(e3, t2, i3) {
53199     return e3 <= t2 && t2 <= i3;
53200   }
53201   var ve = class extends De {
53202     constructor(e3, t2) {
53203       super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2;
53204     }
53205     async readWhole() {
53206       this.chunked = false, await this.readChunk(this.nextChunkOffset);
53207     }
53208     async readChunked() {
53209       this.chunked = true, await this.readChunk(0, this.options.firstChunkSize);
53210     }
53211     async readNextChunk(e3 = this.nextChunkOffset) {
53212       if (this.fullyRead)
53213         return this.chunksRead++, false;
53214       let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2);
53215       return !!i3 && i3.byteLength === t2;
53216     }
53217     async readChunk(e3, t2) {
53218       if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2)))
53219         return this._readChunk(e3, t2);
53220     }
53221     safeWrapAddress(e3, t2) {
53222       return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2;
53223     }
53224     get nextChunkOffset() {
53225       if (0 !== this.ranges.list.length)
53226         return this.ranges.list[0].length;
53227     }
53228     get canReadNextChunk() {
53229       return this.chunksRead < this.options.chunkLimit;
53230     }
53231     get fullyRead() {
53232       return void 0 !== this.size && this.nextChunkOffset === this.size;
53233     }
53234     read() {
53235       return this.options.chunked ? this.readChunked() : this.readWhole();
53236     }
53237     close() {
53238     }
53239   };
53240   A.set("blob", class extends ve {
53241     async readWhole() {
53242       this.chunked = false;
53243       let e3 = await R(this.input);
53244       this._swapArrayBuffer(e3);
53245     }
53246     readChunked() {
53247       return this.chunked = true, this.size = this.input.size, super.readChunked();
53248     }
53249     async _readChunk(e3, t2) {
53250       let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3);
53251       return this.set(s2, e3, true);
53252     }
53253   });
53254   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() {
53255     return we;
53256   }, get rotateCss() {
53257     return Te;
53258   }, rotation: Ae });
53259   A.set("url", class extends ve {
53260     async readWhole() {
53261       this.chunked = false;
53262       let e3 = await M(this.input);
53263       e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3);
53264     }
53265     async _readChunk(e3, t2) {
53266       let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {};
53267       (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-")));
53268       let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength;
53269       if (416 !== s2.status)
53270         return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true);
53271     }
53272   });
53273   I.prototype.getUint64 = function(e3) {
53274     let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4);
53275     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.");
53276   };
53277   var Re = class extends se {
53278     parseBoxes(e3 = 0) {
53279       let t2 = [];
53280       for (; e3 < this.file.byteLength - 4; ) {
53281         let i3 = this.parseBoxHead(e3);
53282         if (t2.push(i3), 0 === i3.length)
53283           break;
53284         e3 += i3.length;
53285       }
53286       return t2;
53287     }
53288     parseSubBoxes(e3) {
53289       e3.boxes = this.parseBoxes(e3.start);
53290     }
53291     findBox(e3, t2) {
53292       return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2);
53293     }
53294     parseBoxHead(e3) {
53295       let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8;
53296       return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 };
53297     }
53298     parseBoxFullHead(e3) {
53299       if (void 0 !== e3.version)
53300         return;
53301       let t2 = this.file.getUint32(e3.start);
53302       e3.version = t2 >> 24, e3.start += 4;
53303     }
53304   };
53305   var Le = class extends Re {
53306     static canHandle(e3, t2) {
53307       if (0 !== t2)
53308         return false;
53309       let i3 = e3.getUint16(2);
53310       if (i3 > 50)
53311         return false;
53312       let n3 = 16, s2 = [];
53313       for (; n3 < i3; )
53314         s2.push(e3.getString(n3, 4)), n3 += 4;
53315       return s2.includes(this.type);
53316     }
53317     async parse() {
53318       let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3);
53319       for (; "meta" !== t2.kind; )
53320         e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3);
53321       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);
53322     }
53323     async registerSegment(e3, t2, i3) {
53324       await this.file.ensureChunk(t2, i3);
53325       let n3 = this.file.subarray(t2, i3);
53326       this.createParser(e3, n3);
53327     }
53328     async findIcc(e3) {
53329       let t2 = this.findBox(e3, "iprp");
53330       if (void 0 === t2)
53331         return;
53332       let i3 = this.findBox(t2, "ipco");
53333       if (void 0 === i3)
53334         return;
53335       let n3 = this.findBox(i3, "colr");
53336       void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length);
53337     }
53338     async findExif(e3) {
53339       let t2 = this.findBox(e3, "iinf");
53340       if (void 0 === t2)
53341         return;
53342       let i3 = this.findBox(e3, "iloc");
53343       if (void 0 === i3)
53344         return;
53345       let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3);
53346       if (void 0 === s2)
53347         return;
53348       let [r2, a2] = s2;
53349       await this.file.ensureChunk(r2, a2);
53350       let o2 = 4 + this.file.getUint32(r2);
53351       r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2);
53352     }
53353     findExifLocIdInIinf(e3) {
53354       this.parseBoxFullHead(e3);
53355       let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2);
53356       for (r2 += 2; a2--; ) {
53357         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))
53358           return this.file.getUintBytes(i3, n3);
53359         r2 += t2.length;
53360       }
53361     }
53362     get8bits(e3) {
53363       let t2 = this.file.getUint8(e3);
53364       return [t2 >> 4, 15 & t2];
53365     }
53366     findExtentInIloc(e3, t2) {
53367       this.parseBoxFullHead(e3);
53368       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);
53369       for (i3 += u2; c2--; ) {
53370         let e4 = this.file.getUintBytes(i3, o2);
53371         i3 += o2 + l2 + 2 + r2;
53372         let u3 = this.file.getUint16(i3);
53373         if (i3 += 2, e4 === t2)
53374           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)];
53375         i3 += u3 * h2;
53376       }
53377     }
53378   };
53379   var Ue = class extends Le {
53380   };
53381   c(Ue, "type", "heic");
53382   var Fe = class extends Le {
53383   };
53384   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" }]]);
53385   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" }]]);
53386   var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" };
53387   Ee.set(37392, Be), Ee.set(41488, Be);
53388   var Ne = { 0: "Normal", 1: "Low", 2: "High" };
53389   function Ge(e3) {
53390     return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3;
53391   }
53392   function Ve(e3) {
53393     let t2 = Array.from(e3).slice(1);
53394     return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join(".");
53395   }
53396   function ze(e3) {
53397     if ("string" == typeof e3) {
53398       var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3);
53399       return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2;
53400     }
53401   }
53402   function He(e3) {
53403     if ("string" == typeof e3)
53404       return e3;
53405     let t2 = [];
53406     if (0 === e3[1] && 0 === e3[e3.length - 1])
53407       for (let i3 = 0; i3 < e3.length; i3 += 2)
53408         t2.push(je(e3[i3 + 1], e3[i3]));
53409     else
53410       for (let i3 = 0; i3 < e3.length; i3 += 2)
53411         t2.push(je(e3[i3], e3[i3 + 1]));
53412     return m(String.fromCodePoint(...t2));
53413   }
53414   function je(e3, t2) {
53415     return e3 << 8 | t2;
53416   }
53417   Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) {
53418     return "string" != typeof e3 ? b(e3) : e3;
53419   }], [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(":")]]);
53420   var We = class extends re2 {
53421     static canHandle(e3, t2) {
53422       return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length);
53423     }
53424     static headerLength(e3, t2) {
53425       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;
53426     }
53427     static findPosition(e3, t2) {
53428       let i3 = super.findPosition(e3, t2);
53429       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;
53430     }
53431     static handleMultiSegments(e3) {
53432       return e3.map((e4) => e4.chunk.getString()).join("");
53433     }
53434     normalizeInput(e3) {
53435       return "string" == typeof e3 ? e3 : I.from(e3).getString();
53436     }
53437     parse(e3 = this.chunk) {
53438       if (!this.localOptions.parse)
53439         return e3;
53440       e3 = function(e4) {
53441         let t3 = {}, i4 = {};
53442         for (let e6 of Ze)
53443           t3[e6] = [], i4[e6] = 0;
53444         return e4.replace(et, (e6, n4, s2) => {
53445           if ("<" === n4) {
53446             let n5 = ++i4[s2];
53447             return t3[s2].push(n5), "".concat(e6, "#").concat(n5);
53448           }
53449           return "".concat(e6, "#").concat(t3[s2].pop());
53450         });
53451       }(e3);
53452       let t2 = Xe.findAll(e3, "rdf", "Description");
53453       0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3));
53454       let i3, n3 = {};
53455       for (let e4 of t2)
53456         for (let t3 of e4.properties)
53457           i3 = Je(t3.ns, n3), _e(t3, i3);
53458       return function(e4) {
53459         let t3;
53460         for (let i4 in e4)
53461           t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4];
53462         return f(e4);
53463       }(n3);
53464     }
53465     assignToOutput(e3, t2) {
53466       if (this.localOptions.parse)
53467         for (let [i3, n3] of Object.entries(t2))
53468           switch (i3) {
53469             case "tiff":
53470               this.assignObjectToOutput(e3, "ifd0", n3);
53471               break;
53472             case "exif":
53473               this.assignObjectToOutput(e3, "exif", n3);
53474               break;
53475             case "xmlns":
53476               break;
53477             default:
53478               this.assignObjectToOutput(e3, i3, n3);
53479           }
53480       else
53481         e3.xmp = t2;
53482     }
53483   };
53484   c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We);
53485   var Ke = class _Ke {
53486     static findAll(e3) {
53487       return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch);
53488     }
53489     static unpackMatch(e3) {
53490       let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1);
53491       return n3 = Qe(n3), new _Ke(t2, i3, n3);
53492     }
53493     constructor(e3, t2, i3) {
53494       this.ns = e3, this.name = t2, this.value = i3;
53495     }
53496     serialize() {
53497       return this.value;
53498     }
53499   };
53500   var Xe = class _Xe {
53501     static findAll(e3, t2, i3) {
53502       if (void 0 !== t2 || void 0 !== i3) {
53503         t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+";
53504         var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm");
53505       } else
53506         n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;
53507       return qe(e3, n3).map(_Xe.unpackMatch);
53508     }
53509     static unpackMatch(e3) {
53510       let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8];
53511       return new _Xe(t2, i3, n3, s2);
53512     }
53513     constructor(e3, t2, i3, n3) {
53514       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];
53515     }
53516     get isPrimitive() {
53517       return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length;
53518     }
53519     get isListContainer() {
53520       return 1 === this.children.length && this.children[0].isList;
53521     }
53522     get isList() {
53523       let { ns: e3, name: t2 } = this;
53524       return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2);
53525     }
53526     get isListItem() {
53527       return "rdf" === this.ns && "li" === this.name;
53528     }
53529     serialize() {
53530       if (0 === this.properties.length && void 0 === this.value)
53531         return;
53532       if (this.isPrimitive)
53533         return this.value;
53534       if (this.isListContainer)
53535         return this.children[0].serialize();
53536       if (this.isList)
53537         return $e(this.children.map(Ye));
53538       if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length)
53539         return this.children[0].serialize();
53540       let e3 = {};
53541       for (let t2 of this.properties)
53542         _e(t2, e3);
53543       return void 0 !== this.value && (e3.value = this.value), f(e3);
53544     }
53545   };
53546   function _e(e3, t2) {
53547     let i3 = e3.serialize();
53548     void 0 !== i3 && (t2[e3.name] = i3);
53549   }
53550   var Ye = (e3) => e3.serialize();
53551   var $e = (e3) => 1 === e3.length ? e3[0] : e3;
53552   var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {};
53553   function qe(e3, t2) {
53554     let i3, n3 = [];
53555     if (!e3)
53556       return n3;
53557     for (; null !== (i3 = t2.exec(e3)); )
53558       n3.push(i3);
53559     return n3;
53560   }
53561   function Qe(e3) {
53562     if (function(e4) {
53563       return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim();
53564     }(e3))
53565       return;
53566     let t2 = Number(e3);
53567     if (!Number.isNaN(t2))
53568       return t2;
53569     let i3 = e3.toLowerCase();
53570     return "true" === i3 || "false" !== i3 && e3.trim();
53571   }
53572   var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"];
53573   var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g");
53574   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() {
53575     return we;
53576   }, get rotateCss() {
53577     return Te;
53578   }, rotation: Ae });
53579   var at = l("fs", (e3) => e3.promises);
53580   A.set("fs", class extends ve {
53581     async readWhole() {
53582       this.chunked = false, this.fs = await at;
53583       let e3 = await this.fs.readFile(this.input);
53584       this._swapBuffer(e3);
53585     }
53586     async readChunked() {
53587       this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize);
53588     }
53589     async open() {
53590       void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size);
53591     }
53592     async _readChunk(e3, t2) {
53593       void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3);
53594       var i3 = this.subarray(e3, t2, true);
53595       return await this.fh.read(i3.dataView, 0, t2, e3), i3;
53596     }
53597     async close() {
53598       if (this.fh) {
53599         let e3 = this.fh;
53600         this.fh = void 0, await e3.close();
53601       }
53602     }
53603   });
53604   A.set("base64", class extends ve {
53605     constructor(...e3) {
53606       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);
53607     }
53608     async _readChunk(e3, t2) {
53609       let i3, n3, r2 = this.input;
53610       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);
53611       let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3);
53612       r2 = r2.slice(i3, l2);
53613       let h2 = Math.min(t2, this.size - e3);
53614       if (a) {
53615         let t3 = s.from(r2, "base64").slice(n3, n3 + h2);
53616         return this.set(t3, e3, true);
53617       }
53618       {
53619         let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8();
53620         for (let e4 = 0; e4 < h2; e4++)
53621           s2[e4] = i4.charCodeAt(n3 + e4);
53622         return t3;
53623       }
53624     }
53625   });
53626   var ot = class extends se {
53627     static canHandle(e3, t2) {
53628       return 18761 === t2 || 19789 === t2;
53629     }
53630     extendOptions(e3) {
53631       let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3;
53632       i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters();
53633     }
53634     async parse() {
53635       let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options;
53636       if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) {
53637         let e4 = Math.max(S(this.options), this.options.chunkSize);
53638         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");
53639       }
53640     }
53641     adaptTiffPropAsSegment(e3) {
53642       if (this.parsers.tiff[e3]) {
53643         let t2 = this.parsers.tiff[e3];
53644         this.injectSegment(e3, t2);
53645       }
53646     }
53647   };
53648   c(ot, "type", "tiff"), w.set("tiff", ot);
53649   var lt = l("zlib");
53650   var ht = ["ihdr", "iccp", "text", "itxt", "exif"];
53651   var ut = class extends se {
53652     constructor(...e3) {
53653       super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []);
53654     }
53655     static canHandle(e3, t2) {
53656       return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4);
53657     }
53658     async parse() {
53659       let { file: e3 } = this;
53660       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);
53661     }
53662     async findPngChunksInRange(e3, t2) {
53663       let { file: i3 } = this;
53664       for (; e3 < t2; ) {
53665         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 };
53666         ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2;
53667       }
53668     }
53669     parseTextChunks() {
53670       let e3 = this.metaChunks.filter((e4) => "text" === e4.type);
53671       for (let t2 of e3) {
53672         let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0");
53673         this.injectKeyValToIhdr(e4, i3);
53674       }
53675     }
53676     injectKeyValToIhdr(e3, t2) {
53677       let i3 = this.parsers.ihdr;
53678       i3 && i3.raw.set(e3, t2);
53679     }
53680     findIhdr() {
53681       let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type);
53682       e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk);
53683     }
53684     async findExif() {
53685       let e3 = this.metaChunks.find((e4) => "exif" === e4.type);
53686       e3 && this.injectSegment("tiff", e3.chunk);
53687     }
53688     async findXmp() {
53689       let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type);
53690       for (let t2 of e3) {
53691         "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk);
53692       }
53693     }
53694     async findIcc() {
53695       let e3 = this.metaChunks.find((e4) => "iccp" === e4.type);
53696       if (!e3)
53697         return;
53698       let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0;
53699       for (; s2 < 80 && 0 !== i3[s2]; )
53700         s2++;
53701       let r2 = s2 + 2, a2 = t2.getString(0, s2);
53702       if (this.injectKeyValToIhdr("ProfileName", a2), n2) {
53703         let e4 = await lt, i4 = t2.getUint8Array(r2);
53704         i4 = e4.inflateSync(i4), this.injectSegment("icc", i4);
53705       }
53706     }
53707   };
53708   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"]]);
53709   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"]];
53710   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" }]]);
53711   var ft = class extends re2 {
53712     static canHandle(e3, t2) {
53713       return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8);
53714     }
53715     parse() {
53716       return this.parseTags(), this.translate(), this.output;
53717     }
53718     parseTags() {
53719       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)]]);
53720     }
53721   };
53722   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"]]);
53723   var dt = class extends re2 {
53724     parse() {
53725       return this.parseTags(), this.translate(), this.output;
53726     }
53727     parseTags() {
53728       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)]);
53729     }
53730   };
53731   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" }]]);
53732   var pt = class extends re2 {
53733     static canHandle(e3, t2) {
53734       return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4);
53735     }
53736     static findPosition(e3, t2) {
53737       let i3 = super.findPosition(e3, t2);
53738       return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3;
53739     }
53740     static handleMultiSegments(e3) {
53741       return function(e4) {
53742         let t2 = function(e6) {
53743           let t3 = e6[0].constructor, i3 = 0;
53744           for (let t4 of e6)
53745             i3 += t4.length;
53746           let n3 = new t3(i3), s2 = 0;
53747           for (let t4 of e6)
53748             n3.set(t4, s2), s2 += t4.length;
53749           return n3;
53750         }(e4.map((e6) => e6.chunk.toUint8()));
53751         return new I(t2);
53752       }(e3);
53753     }
53754     parse() {
53755       return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output;
53756     }
53757     parseHeader() {
53758       let { raw: e3 } = this;
53759       this.chunk.byteLength < 84 && g2("ICC header is too short");
53760       for (let [t2, i3] of Object.entries(gt)) {
53761         t2 = parseInt(t2, 10);
53762         let n3 = i3(this.chunk, t2);
53763         "\0\0\0\0" !== n3 && e3.set(t2, n3);
53764       }
53765     }
53766     parseTags() {
53767       let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength;
53768       for (; a2--; ) {
53769         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)
53770           return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments.");
53771         s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12;
53772       }
53773     }
53774     parseTag(e3, t2, i3) {
53775       switch (e3) {
53776         case "desc":
53777           return this.parseDesc(t2);
53778         case "mluc":
53779           return this.parseMluc(t2);
53780         case "text":
53781           return this.parseText(t2, i3);
53782         case "sig ":
53783           return this.parseSig(t2);
53784       }
53785       if (!(t2 + i3 > this.chunk.byteLength))
53786         return this.chunk.getUint8Array(t2, i3);
53787     }
53788     parseDesc(e3) {
53789       let t2 = this.chunk.getUint32(e3 + 8) - 1;
53790       return m(this.chunk.getString(e3 + 12, t2));
53791     }
53792     parseText(e3, t2) {
53793       return m(this.chunk.getString(e3 + 8, t2 - 8));
53794     }
53795     parseSig(e3) {
53796       return m(this.chunk.getString(e3 + 8, 4));
53797     }
53798     parseMluc(e3) {
53799       let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = [];
53800       for (let a2 = 0; a2 < i3; a2++) {
53801         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));
53802         r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3;
53803       }
53804       return 1 === i3 ? r2[0].text : r2;
53805     }
53806     translateValue(e3, t2) {
53807       return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3;
53808     }
53809   };
53810   c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18);
53811   var gt = { 4: mt, 8: function(e3, t2) {
53812     return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join(".");
53813   }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) {
53814     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);
53815     return new Date(Date.UTC(i3, n3, s2, r2, a2, o2));
53816   }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt };
53817   function mt(e3, t2) {
53818     return m(e3.getString(t2, 4));
53819   }
53820   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"]]);
53821   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" };
53822   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!)" };
53823   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" }]]);
53824   var yt = class extends re2 {
53825     static canHandle(e3, t2, i3) {
53826       return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3);
53827     }
53828     static headerLength(e3, t2, i3) {
53829       let n3, s2 = this.containsIptc8bim(e3, t2, i3);
53830       if (void 0 !== s2)
53831         return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3;
53832     }
53833     static containsIptc8bim(e3, t2, i3) {
53834       for (let n3 = 0; n3 < i3; n3++)
53835         if (this.isIptcSegmentHead(e3, t2 + n3))
53836           return n3;
53837     }
53838     static isIptcSegmentHead(e3, t2) {
53839       return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4);
53840     }
53841     parse() {
53842       let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false;
53843       for (let n3 = 0; n3 < t2; n3++)
53844         if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) {
53845           i3 = true;
53846           let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3);
53847           e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3;
53848         } else if (i3)
53849           break;
53850       return this.translate(), this.output;
53851     }
53852     pluralizeValue(e3, t2) {
53853       return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2;
53854     }
53855   };
53856   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" }]]);
53857   var full_esm_default = tt;
53858
53859   // modules/services/plane_photo.js
53860   var dispatch6 = dispatch_default("viewerChanged");
53861   var _photo;
53862   var _wrapper;
53863   var imgZoom;
53864   var _widthOverflow;
53865   function zoomPan(d3_event) {
53866     let t2 = d3_event.transform;
53867     _photo.call(utilSetTransform, t2.x, t2.y, t2.k);
53868   }
53869   function zoomBeahvior() {
53870     const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect();
53871     const { naturalHeight, naturalWidth } = _photo.node();
53872     const intrinsicRatio = naturalWidth / naturalHeight;
53873     _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth;
53874     return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan);
53875   }
53876   function loadImage(selection2, path) {
53877     return new Promise((resolve) => {
53878       selection2.attr("src", path);
53879       selection2.on("load", () => {
53880         resolve(selection2);
53881       });
53882     });
53883   }
53884   var plane_photo_default = {
53885     init: async function(context, selection2) {
53886       this.event = utilRebind(this, dispatch6, "on");
53887       _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true);
53888       _photo = _wrapper.append("img").attr("class", "plane-photo");
53889       context.ui().photoviewer.on("resize.plane", () => {
53890         imgZoom = zoomBeahvior();
53891         _wrapper.call(imgZoom);
53892       });
53893       await Promise.resolve();
53894       return this;
53895     },
53896     showPhotoFrame: function(context) {
53897       const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size();
53898       if (isHidden) {
53899         context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true);
53900         context.selectAll(".photo-frame.plane-frame").classed("hide", false);
53901       }
53902       return this;
53903     },
53904     hidePhotoFrame: function(context) {
53905       context.select("photo-frame.plane-frame").classed("hide", false);
53906       return this;
53907     },
53908     selectPhoto: function(data, keepOrientation) {
53909       dispatch6.call("viewerChanged");
53910       loadImage(_photo, "");
53911       loadImage(_photo, data.image_path).then(() => {
53912         if (!keepOrientation) {
53913           imgZoom = zoomBeahvior();
53914           _wrapper.call(imgZoom);
53915           _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0));
53916         }
53917       });
53918       return this;
53919     },
53920     getYaw: function() {
53921       return 0;
53922     }
53923   };
53924
53925   // modules/svg/local_photos.js
53926   var _initialized2 = false;
53927   var _enabled2 = false;
53928   var minViewfieldZoom = 16;
53929   function svgLocalPhotos(projection2, context, dispatch14) {
53930     const detected = utilDetect();
53931     let layer = select_default2(null);
53932     let _fileList;
53933     let _photos = [];
53934     let _idAutoinc = 0;
53935     let _photoFrame;
53936     function init2() {
53937       if (_initialized2)
53938         return;
53939       _enabled2 = true;
53940       function over(d3_event) {
53941         d3_event.stopPropagation();
53942         d3_event.preventDefault();
53943         d3_event.dataTransfer.dropEffect = "copy";
53944       }
53945       context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) {
53946         d3_event.stopPropagation();
53947         d3_event.preventDefault();
53948         if (!detected.filedrop)
53949           return;
53950         drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => {
53951           if (loaded.length > 0) {
53952             drawPhotos.fitZoom(false);
53953           }
53954         });
53955       }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over);
53956       _initialized2 = true;
53957     }
53958     function ensureViewerLoaded(context2) {
53959       if (_photoFrame) {
53960         return Promise.resolve(_photoFrame);
53961       }
53962       const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]);
53963       const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true);
53964       viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD");
53965       return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => {
53966         _photoFrame = planePhotoFrame;
53967       });
53968     }
53969     function click(d3_event, image, zoomTo) {
53970       ensureViewerLoaded(context).then(() => {
53971         const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false);
53972         const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false);
53973         const attribution = viewerWrap.selectAll(".photo-attribution").text("");
53974         if (image.date) {
53975           attribution.append("span").text(image.date.toLocaleString());
53976         }
53977         if (image.name) {
53978           attribution.append("span").classed("filename", true).text(image.name);
53979         }
53980         _photoFrame.selectPhoto({ image_path: "" });
53981         image.getSrc().then((src) => {
53982           _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap);
53983           setStyles();
53984         });
53985       });
53986       if (zoomTo) {
53987         context.map().centerEase(image.loc);
53988       }
53989     }
53990     function transform2(d2) {
53991       var svgpoint = projection2(d2.loc);
53992       return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")";
53993     }
53994     function setStyles(hovered) {
53995       const viewer = context.container().select(".photoviewer");
53996       const selected = viewer.empty() ? void 0 : viewer.datum();
53997       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));
53998     }
53999     function display_markers(imageList) {
54000       imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1]));
54001       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) {
54002         return d2.id;
54003       });
54004       groups.exit().remove();
54005       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click);
54006       groupsEnter.append("g").attr("class", "viewfield-scale");
54007       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
54008       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54009       const showViewfields = context.map().zoom() >= minViewfieldZoom;
54010       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54011       viewfields.exit().remove();
54012       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() {
54013         var _a2;
54014         const d2 = this.parentNode.__data__;
54015         return "rotate(".concat(Math.round((_a2 = d2.direction) != null ? _a2 : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)");
54016       }).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() {
54017         const d2 = this.parentNode.__data__;
54018         return isNumber_default(d2.direction) ? "visible" : "hidden";
54019       });
54020     }
54021     function drawPhotos(selection2) {
54022       layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []);
54023       layer.exit().remove();
54024       const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos");
54025       layerEnter.append("g").attr("class", "markers");
54026       layer = layerEnter.merge(layer);
54027       if (_photos) {
54028         display_markers(_photos);
54029       }
54030     }
54031     function readFileAsDataURL(file) {
54032       return new Promise((resolve, reject) => {
54033         const reader = new FileReader();
54034         reader.onload = () => resolve(reader.result);
54035         reader.onerror = (error) => reject(error);
54036         reader.readAsDataURL(file);
54037       });
54038     }
54039     async function readmultifiles(files, callback) {
54040       const loaded = [];
54041       for (const file of files) {
54042         try {
54043           const exifData = await full_esm_default.parse(file);
54044           const photo = {
54045             id: _idAutoinc++,
54046             name: file.name,
54047             getSrc: () => readFileAsDataURL(file),
54048             file,
54049             loc: [exifData.longitude, exifData.latitude],
54050             direction: exifData.GPSImgDirection,
54051             date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate
54052           };
54053           loaded.push(photo);
54054           const sameName = _photos.filter((i3) => i3.name === photo.name);
54055           if (sameName.length === 0) {
54056             _photos.push(photo);
54057           } else {
54058             const thisContent = await photo.getSrc();
54059             const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc()));
54060             if (!sameNameContent.some((i3) => i3.value === thisContent)) {
54061               _photos.push(photo);
54062             }
54063           }
54064         } catch {
54065         }
54066       }
54067       if (typeof callback === "function")
54068         callback(loaded);
54069       dispatch14.call("change");
54070     }
54071     drawPhotos.setFiles = function(fileList, callback) {
54072       readmultifiles(Array.from(fileList), callback);
54073       return this;
54074     };
54075     drawPhotos.fileList = function(fileList, callback) {
54076       if (!arguments.length)
54077         return _fileList;
54078       _fileList = fileList;
54079       if (!fileList || !fileList.length)
54080         return this;
54081       drawPhotos.setFiles(_fileList, callback);
54082       return this;
54083     };
54084     drawPhotos.getPhotos = function() {
54085       return _photos;
54086     };
54087     drawPhotos.removePhoto = function(id2) {
54088       _photos = _photos.filter((i3) => i3.id !== id2);
54089       dispatch14.call("change");
54090       return _photos;
54091     };
54092     drawPhotos.openPhoto = click;
54093     drawPhotos.fitZoom = function(force) {
54094       const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1]));
54095       if (coords.length === 0)
54096         return;
54097       const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2));
54098       const map2 = context.map();
54099       var viewport = map2.trimmedExtent().polygon();
54100       if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) {
54101         map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent)));
54102       }
54103     };
54104     function showLayer() {
54105       layer.style("display", "block");
54106       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54107         dispatch14.call("change");
54108       });
54109     }
54110     function hideLayer() {
54111       layer.transition().duration(250).style("opacity", 0).on("end", () => {
54112         layer.selectAll(".viewfield-group").remove();
54113         layer.style("display", "none");
54114       });
54115     }
54116     drawPhotos.enabled = function(val) {
54117       if (!arguments.length)
54118         return _enabled2;
54119       _enabled2 = val;
54120       if (_enabled2) {
54121         showLayer();
54122       } else {
54123         hideLayer();
54124       }
54125       dispatch14.call("change");
54126       return this;
54127     };
54128     drawPhotos.hasData = function() {
54129       return isArray_default(_photos) && _photos.length > 0;
54130     };
54131     init2();
54132     return drawPhotos;
54133   }
54134
54135   // modules/svg/improveOSM.js
54136   var _layerEnabled2 = false;
54137   var _qaService2;
54138   function svgImproveOSM(projection2, context, dispatch14) {
54139     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54140     const minZoom4 = 12;
54141     let touchLayer = select_default2(null);
54142     let drawLayer = select_default2(null);
54143     let layerVisible = false;
54144     function markerPath(selection2, klass) {
54145       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");
54146     }
54147     function getService() {
54148       if (services.improveOSM && !_qaService2) {
54149         _qaService2 = services.improveOSM;
54150         _qaService2.on("loaded", throttledRedraw);
54151       } else if (!services.improveOSM && _qaService2) {
54152         _qaService2 = null;
54153       }
54154       return _qaService2;
54155     }
54156     function editOn() {
54157       if (!layerVisible) {
54158         layerVisible = true;
54159         drawLayer.style("display", "block");
54160       }
54161     }
54162     function editOff() {
54163       if (layerVisible) {
54164         layerVisible = false;
54165         drawLayer.style("display", "none");
54166         drawLayer.selectAll(".qaItem.improveOSM").remove();
54167         touchLayer.selectAll(".qaItem.improveOSM").remove();
54168       }
54169     }
54170     function layerOn() {
54171       editOn();
54172       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54173     }
54174     function layerOff() {
54175       throttledRedraw.cancel();
54176       drawLayer.interrupt();
54177       touchLayer.selectAll(".qaItem.improveOSM").remove();
54178       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54179         editOff();
54180         dispatch14.call("change");
54181       });
54182     }
54183     function updateMarkers() {
54184       if (!layerVisible || !_layerEnabled2)
54185         return;
54186       const service = getService();
54187       const selectedID = context.selectedErrorID();
54188       const data = service ? service.getItems(projection2) : [];
54189       const getTransform = svgPointTransform(projection2);
54190       const markers = drawLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54191       markers.exit().remove();
54192       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54193       markersEnter.append("polygon").call(markerPath, "shadow");
54194       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54195       markersEnter.append("polygon").attr("fill", "currentColor").call(markerPath, "qaItem-fill");
54196       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 : "");
54197       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54198       if (touchLayer.empty())
54199         return;
54200       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
54201       const targets = touchLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54202       targets.exit().remove();
54203       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);
54204       function sortY(a2, b2) {
54205         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54206       }
54207     }
54208     function drawImproveOSM(selection2) {
54209       const service = getService();
54210       const surface = context.surface();
54211       if (surface && !surface.empty()) {
54212         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54213       }
54214       drawLayer = selection2.selectAll(".layer-improveOSM").data(service ? [0] : []);
54215       drawLayer.exit().remove();
54216       drawLayer = drawLayer.enter().append("g").attr("class", "layer-improveOSM").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer);
54217       if (_layerEnabled2) {
54218         if (service && ~~context.map().zoom() >= minZoom4) {
54219           editOn();
54220           service.loadIssues(projection2);
54221           updateMarkers();
54222         } else {
54223           editOff();
54224         }
54225       }
54226     }
54227     drawImproveOSM.enabled = function(val) {
54228       if (!arguments.length)
54229         return _layerEnabled2;
54230       _layerEnabled2 = val;
54231       if (_layerEnabled2) {
54232         layerOn();
54233       } else {
54234         layerOff();
54235         if (context.selectedErrorID()) {
54236           context.enter(modeBrowse(context));
54237         }
54238       }
54239       dispatch14.call("change");
54240       return this;
54241     };
54242     drawImproveOSM.supported = () => !!getService();
54243     return drawImproveOSM;
54244   }
54245
54246   // modules/svg/osmose.js
54247   var _layerEnabled3 = false;
54248   var _qaService3;
54249   function svgOsmose(projection2, context, dispatch14) {
54250     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54251     const minZoom4 = 12;
54252     let touchLayer = select_default2(null);
54253     let drawLayer = select_default2(null);
54254     let layerVisible = false;
54255     function markerPath(selection2, klass) {
54256       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");
54257     }
54258     function getService() {
54259       if (services.osmose && !_qaService3) {
54260         _qaService3 = services.osmose;
54261         _qaService3.on("loaded", throttledRedraw);
54262       } else if (!services.osmose && _qaService3) {
54263         _qaService3 = null;
54264       }
54265       return _qaService3;
54266     }
54267     function editOn() {
54268       if (!layerVisible) {
54269         layerVisible = true;
54270         drawLayer.style("display", "block");
54271       }
54272     }
54273     function editOff() {
54274       if (layerVisible) {
54275         layerVisible = false;
54276         drawLayer.style("display", "none");
54277         drawLayer.selectAll(".qaItem.osmose").remove();
54278         touchLayer.selectAll(".qaItem.osmose").remove();
54279       }
54280     }
54281     function layerOn() {
54282       editOn();
54283       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54284     }
54285     function layerOff() {
54286       throttledRedraw.cancel();
54287       drawLayer.interrupt();
54288       touchLayer.selectAll(".qaItem.osmose").remove();
54289       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54290         editOff();
54291         dispatch14.call("change");
54292       });
54293     }
54294     function updateMarkers() {
54295       if (!layerVisible || !_layerEnabled3)
54296         return;
54297       const service = getService();
54298       const selectedID = context.selectedErrorID();
54299       const data = service ? service.getItems(projection2) : [];
54300       const getTransform = svgPointTransform(projection2);
54301       const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54302       markers.exit().remove();
54303       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54304       markersEnter.append("polygon").call(markerPath, "shadow");
54305       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54306       markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill");
54307       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 : "");
54308       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54309       if (touchLayer.empty())
54310         return;
54311       const fillClass = context.getDebug("target") ? "pink" : "nocolor";
54312       const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54313       targets.exit().remove();
54314       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);
54315       function sortY(a2, b2) {
54316         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54317       }
54318     }
54319     function drawOsmose(selection2) {
54320       const service = getService();
54321       const surface = context.surface();
54322       if (surface && !surface.empty()) {
54323         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54324       }
54325       drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []);
54326       drawLayer.exit().remove();
54327       drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled3 ? "block" : "none").merge(drawLayer);
54328       if (_layerEnabled3) {
54329         if (service && ~~context.map().zoom() >= minZoom4) {
54330           editOn();
54331           service.loadIssues(projection2);
54332           updateMarkers();
54333         } else {
54334           editOff();
54335         }
54336       }
54337     }
54338     drawOsmose.enabled = function(val) {
54339       if (!arguments.length)
54340         return _layerEnabled3;
54341       _layerEnabled3 = val;
54342       if (_layerEnabled3) {
54343         getService().loadStrings().then(layerOn).catch((err) => {
54344           console.log(err);
54345         });
54346       } else {
54347         layerOff();
54348         if (context.selectedErrorID()) {
54349           context.enter(modeBrowse(context));
54350         }
54351       }
54352       dispatch14.call("change");
54353       return this;
54354     };
54355     drawOsmose.supported = () => !!getService();
54356     return drawOsmose;
54357   }
54358
54359   // modules/svg/streetside.js
54360   function svgStreetside(projection2, context, dispatch14) {
54361     var throttledRedraw = throttle_default(function() {
54362       dispatch14.call("change");
54363     }, 1e3);
54364     var minZoom4 = 14;
54365     var minMarkerZoom = 16;
54366     var minViewfieldZoom2 = 18;
54367     var layer = select_default2(null);
54368     var _viewerYaw = 0;
54369     var _selectedSequence = null;
54370     var _streetside;
54371     function init2() {
54372       if (svgStreetside.initialized)
54373         return;
54374       svgStreetside.enabled = false;
54375       svgStreetside.initialized = true;
54376     }
54377     function getService() {
54378       if (services.streetside && !_streetside) {
54379         _streetside = services.streetside;
54380         _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw);
54381       } else if (!services.streetside && _streetside) {
54382         _streetside = null;
54383       }
54384       return _streetside;
54385     }
54386     function showLayer() {
54387       var service = getService();
54388       if (!service)
54389         return;
54390       editOn();
54391       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54392         dispatch14.call("change");
54393       });
54394     }
54395     function hideLayer() {
54396       throttledRedraw.cancel();
54397       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54398     }
54399     function editOn() {
54400       layer.style("display", "block");
54401     }
54402     function editOff() {
54403       layer.selectAll(".viewfield-group").remove();
54404       layer.style("display", "none");
54405     }
54406     function click(d3_event, d2) {
54407       var service = getService();
54408       if (!service)
54409         return;
54410       if (d2.sequenceKey !== _selectedSequence) {
54411         _viewerYaw = 0;
54412       }
54413       _selectedSequence = d2.sequenceKey;
54414       service.ensureViewerLoaded(context).then(function() {
54415         service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context);
54416       });
54417       context.map().centerEase(d2.loc);
54418     }
54419     function mouseover(d3_event, d2) {
54420       var service = getService();
54421       if (service)
54422         service.setStyles(context, d2);
54423     }
54424     function mouseout() {
54425       var service = getService();
54426       if (service)
54427         service.setStyles(context, null);
54428     }
54429     function transform2(d2) {
54430       var t2 = svgPointTransform(projection2)(d2);
54431       var rot = d2.ca + _viewerYaw;
54432       if (rot) {
54433         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54434       }
54435       return t2;
54436     }
54437     function viewerChanged() {
54438       var service = getService();
54439       if (!service)
54440         return;
54441       var viewer = service.viewer();
54442       if (!viewer)
54443         return;
54444       _viewerYaw = viewer.getYaw();
54445       if (context.map().isTransformed())
54446         return;
54447       layer.selectAll(".viewfield-group.currentView").attr("transform", transform2);
54448     }
54449     function filterBubbles(bubbles) {
54450       var fromDate = context.photos().fromDate();
54451       var toDate = context.photos().toDate();
54452       var usernames = context.photos().usernames();
54453       if (fromDate) {
54454         var fromTimestamp = new Date(fromDate).getTime();
54455         bubbles = bubbles.filter(function(bubble) {
54456           return new Date(bubble.captured_at).getTime() >= fromTimestamp;
54457         });
54458       }
54459       if (toDate) {
54460         var toTimestamp = new Date(toDate).getTime();
54461         bubbles = bubbles.filter(function(bubble) {
54462           return new Date(bubble.captured_at).getTime() <= toTimestamp;
54463         });
54464       }
54465       if (usernames) {
54466         bubbles = bubbles.filter(function(bubble) {
54467           return usernames.indexOf(bubble.captured_by) !== -1;
54468         });
54469       }
54470       return bubbles;
54471     }
54472     function filterSequences(sequences) {
54473       var fromDate = context.photos().fromDate();
54474       var toDate = context.photos().toDate();
54475       var usernames = context.photos().usernames();
54476       if (fromDate) {
54477         var fromTimestamp = new Date(fromDate).getTime();
54478         sequences = sequences.filter(function(sequences2) {
54479           return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp;
54480         });
54481       }
54482       if (toDate) {
54483         var toTimestamp = new Date(toDate).getTime();
54484         sequences = sequences.filter(function(sequences2) {
54485           return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp;
54486         });
54487       }
54488       if (usernames) {
54489         sequences = sequences.filter(function(sequences2) {
54490           return usernames.indexOf(sequences2.properties.captured_by) !== -1;
54491         });
54492       }
54493       return sequences;
54494     }
54495     function update() {
54496       var viewer = context.container().select(".photoviewer");
54497       var selected = viewer.empty() ? void 0 : viewer.datum();
54498       var z2 = ~~context.map().zoom();
54499       var showMarkers = z2 >= minMarkerZoom;
54500       var showViewfields = z2 >= minViewfieldZoom2;
54501       var service = getService();
54502       var sequences = [];
54503       var bubbles = [];
54504       if (context.photos().showsPanoramic()) {
54505         sequences = service ? service.sequences(projection2) : [];
54506         bubbles = service && showMarkers ? service.bubbles(projection2) : [];
54507         sequences = filterSequences(sequences);
54508         bubbles = filterBubbles(bubbles);
54509       }
54510       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54511         return d2.properties.key;
54512       });
54513       traces.exit().remove();
54514       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54515       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) {
54516         return d2.key + (d2.sequenceKey ? "v1" : "v0");
54517       });
54518       groups.exit().remove();
54519       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54520       groupsEnter.append("g").attr("class", "viewfield-scale");
54521       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54522         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54523       }).attr("transform", transform2).select(".viewfield-scale");
54524       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54525       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54526       viewfields.exit().remove();
54527       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54528       function viewfieldPath() {
54529         var d2 = this.parentNode.__data__;
54530         if (d2.pano) {
54531           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54532         } else {
54533           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54534         }
54535       }
54536     }
54537     function drawImages(selection2) {
54538       var enabled = svgStreetside.enabled;
54539       var service = getService();
54540       layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []);
54541       layer.exit().remove();
54542       var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none");
54543       layerEnter.append("g").attr("class", "sequences");
54544       layerEnter.append("g").attr("class", "markers");
54545       layer = layerEnter.merge(layer);
54546       if (enabled) {
54547         if (service && ~~context.map().zoom() >= minZoom4) {
54548           editOn();
54549           update();
54550           service.loadBubbles(projection2);
54551         } else {
54552           editOff();
54553         }
54554       }
54555     }
54556     drawImages.enabled = function(_2) {
54557       if (!arguments.length)
54558         return svgStreetside.enabled;
54559       svgStreetside.enabled = _2;
54560       if (svgStreetside.enabled) {
54561         showLayer();
54562         context.photos().on("change.streetside", update);
54563       } else {
54564         hideLayer();
54565         context.photos().on("change.streetside", null);
54566       }
54567       dispatch14.call("change");
54568       return this;
54569     };
54570     drawImages.supported = function() {
54571       return !!getService();
54572     };
54573     drawImages.rendered = function(zoom) {
54574       return zoom >= minZoom4;
54575     };
54576     init2();
54577     return drawImages;
54578   }
54579
54580   // modules/svg/vegbilder.js
54581   function svgVegbilder(projection2, context, dispatch14) {
54582     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54583     const minZoom4 = 14;
54584     const minMarkerZoom = 16;
54585     const minViewfieldZoom2 = 18;
54586     let layer = select_default2(null);
54587     let _viewerYaw = 0;
54588     let _vegbilder;
54589     function init2() {
54590       if (svgVegbilder.initialized)
54591         return;
54592       svgVegbilder.enabled = false;
54593       svgVegbilder.initialized = true;
54594     }
54595     function getService() {
54596       if (services.vegbilder && !_vegbilder) {
54597         _vegbilder = services.vegbilder;
54598         _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw);
54599       } else if (!services.vegbilder && _vegbilder) {
54600         _vegbilder = null;
54601       }
54602       return _vegbilder;
54603     }
54604     function showLayer() {
54605       const service = getService();
54606       if (!service)
54607         return;
54608       editOn();
54609       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change"));
54610     }
54611     function hideLayer() {
54612       throttledRedraw.cancel();
54613       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54614     }
54615     function editOn() {
54616       layer.style("display", "block");
54617     }
54618     function editOff() {
54619       layer.selectAll(".viewfield-group").remove();
54620       layer.style("display", "none");
54621     }
54622     function click(d3_event, d2) {
54623       const service = getService();
54624       if (!service)
54625         return;
54626       service.ensureViewerLoaded(context).then(() => {
54627         service.selectImage(context, d2.key).showViewer(context);
54628       });
54629       context.map().centerEase(d2.loc);
54630     }
54631     function mouseover(d3_event, d2) {
54632       const service = getService();
54633       if (service)
54634         service.setStyles(context, d2);
54635     }
54636     function mouseout() {
54637       const service = getService();
54638       if (service)
54639         service.setStyles(context, null);
54640     }
54641     function transform2(d2, selected) {
54642       let t2 = svgPointTransform(projection2)(d2);
54643       let rot = d2.ca;
54644       if (d2 === selected) {
54645         rot += _viewerYaw;
54646       }
54647       if (rot) {
54648         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54649       }
54650       return t2;
54651     }
54652     function viewerChanged() {
54653       const service = getService();
54654       if (!service)
54655         return;
54656       const frame2 = service.photoFrame();
54657       _viewerYaw = frame2.getYaw();
54658       if (context.map().isTransformed())
54659         return;
54660       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2));
54661     }
54662     function filterImages(images) {
54663       const photoContext = context.photos();
54664       const fromDateString = photoContext.fromDate();
54665       const toDateString = photoContext.toDate();
54666       const showsFlat = photoContext.showsFlat();
54667       const showsPano = photoContext.showsPanoramic();
54668       if (fromDateString) {
54669         const fromDate = new Date(fromDateString);
54670         images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime());
54671       }
54672       if (toDateString) {
54673         const toDate = new Date(toDateString);
54674         images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime());
54675       }
54676       if (!showsPano) {
54677         images = images.filter((image) => !image.is_sphere);
54678       }
54679       if (!showsFlat) {
54680         images = images.filter((image) => image.is_sphere);
54681       }
54682       return images;
54683     }
54684     function filterSequences(sequences) {
54685       const photoContext = context.photos();
54686       const fromDateString = photoContext.fromDate();
54687       const toDateString = photoContext.toDate();
54688       const showsFlat = photoContext.showsFlat();
54689       const showsPano = photoContext.showsPanoramic();
54690       if (fromDateString) {
54691         const fromDate = new Date(fromDateString);
54692         sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime());
54693       }
54694       if (toDateString) {
54695         const toDate = new Date(toDateString);
54696         sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime());
54697       }
54698       if (!showsPano) {
54699         sequences = sequences.filter(({ images }) => !images[0].is_sphere);
54700       }
54701       if (!showsFlat) {
54702         sequences = sequences.filter(({ images }) => images[0].is_sphere);
54703       }
54704       return sequences;
54705     }
54706     function update() {
54707       const viewer = context.container().select(".photoviewer");
54708       const selected = viewer.empty() ? void 0 : viewer.datum();
54709       const z2 = ~~context.map().zoom();
54710       const showMarkers = z2 >= minMarkerZoom;
54711       const showViewfields = z2 >= minViewfieldZoom2;
54712       const service = getService();
54713       let sequences = [];
54714       let images = [];
54715       if (service) {
54716         service.loadImages(context);
54717         sequences = service.sequences(projection2);
54718         images = showMarkers ? service.images(projection2) : [];
54719         images = filterImages(images);
54720         sequences = filterSequences(sequences);
54721       }
54722       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key);
54723       traces.exit().remove();
54724       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54725       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key);
54726       groups.exit().remove();
54727       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54728       groupsEnter.append("g").attr("class", "viewfield-scale");
54729       const markers = groups.merge(groupsEnter).sort((a2, b2) => {
54730         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54731       }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale");
54732       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54733       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54734       viewfields.exit().remove();
54735       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54736       function viewfieldPath() {
54737         const d2 = this.parentNode.__data__;
54738         if (d2.is_sphere) {
54739           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54740         } else {
54741           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54742         }
54743       }
54744     }
54745     function drawImages(selection2) {
54746       const enabled = svgVegbilder.enabled;
54747       const service = getService();
54748       layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []);
54749       layer.exit().remove();
54750       const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none");
54751       layerEnter.append("g").attr("class", "sequences");
54752       layerEnter.append("g").attr("class", "markers");
54753       layer = layerEnter.merge(layer);
54754       if (enabled) {
54755         if (service && ~~context.map().zoom() >= minZoom4) {
54756           editOn();
54757           update();
54758           service.loadImages(context);
54759         } else {
54760           editOff();
54761         }
54762       }
54763     }
54764     drawImages.enabled = function(_2) {
54765       if (!arguments.length)
54766         return svgVegbilder.enabled;
54767       svgVegbilder.enabled = _2;
54768       if (svgVegbilder.enabled) {
54769         showLayer();
54770         context.photos().on("change.vegbilder", update);
54771       } else {
54772         hideLayer();
54773         context.photos().on("change.vegbilder", null);
54774       }
54775       dispatch14.call("change");
54776       return this;
54777     };
54778     drawImages.supported = function() {
54779       return !!getService();
54780     };
54781     drawImages.rendered = function(zoom) {
54782       return zoom >= minZoom4;
54783     };
54784     drawImages.validHere = function(extent, zoom) {
54785       return zoom >= minZoom4 - 2 && getService().validHere(extent);
54786     };
54787     init2();
54788     return drawImages;
54789   }
54790
54791   // modules/svg/mapillary_images.js
54792   function svgMapillaryImages(projection2, context, dispatch14) {
54793     const throttledRedraw = throttle_default(function() {
54794       dispatch14.call("change");
54795     }, 1e3);
54796     const minZoom4 = 12;
54797     const minMarkerZoom = 16;
54798     const minViewfieldZoom2 = 18;
54799     let layer = select_default2(null);
54800     let _mapillary;
54801     function init2() {
54802       if (svgMapillaryImages.initialized)
54803         return;
54804       svgMapillaryImages.enabled = false;
54805       svgMapillaryImages.initialized = true;
54806     }
54807     function getService() {
54808       if (services.mapillary && !_mapillary) {
54809         _mapillary = services.mapillary;
54810         _mapillary.event.on("loadedImages", throttledRedraw);
54811       } else if (!services.mapillary && _mapillary) {
54812         _mapillary = null;
54813       }
54814       return _mapillary;
54815     }
54816     function showLayer() {
54817       const service = getService();
54818       if (!service)
54819         return;
54820       editOn();
54821       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54822         dispatch14.call("change");
54823       });
54824     }
54825     function hideLayer() {
54826       throttledRedraw.cancel();
54827       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54828     }
54829     function editOn() {
54830       layer.style("display", "block");
54831     }
54832     function editOff() {
54833       layer.selectAll(".viewfield-group").remove();
54834       layer.style("display", "none");
54835     }
54836     function click(d3_event, image) {
54837       const service = getService();
54838       if (!service)
54839         return;
54840       service.ensureViewerLoaded(context).then(function() {
54841         service.selectImage(context, image.id).showViewer(context);
54842       });
54843       context.map().centerEase(image.loc);
54844     }
54845     function mouseover(d3_event, image) {
54846       const service = getService();
54847       if (service)
54848         service.setStyles(context, image);
54849     }
54850     function mouseout() {
54851       const service = getService();
54852       if (service)
54853         service.setStyles(context, null);
54854     }
54855     function transform2(d2) {
54856       let t2 = svgPointTransform(projection2)(d2);
54857       if (d2.ca) {
54858         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
54859       }
54860       return t2;
54861     }
54862     function filterImages(images) {
54863       const showsPano = context.photos().showsPanoramic();
54864       const showsFlat = context.photos().showsFlat();
54865       const fromDate = context.photos().fromDate();
54866       const toDate = context.photos().toDate();
54867       if (!showsPano || !showsFlat) {
54868         images = images.filter(function(image) {
54869           if (image.is_pano)
54870             return showsPano;
54871           return showsFlat;
54872         });
54873       }
54874       if (fromDate) {
54875         images = images.filter(function(image) {
54876           return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime();
54877         });
54878       }
54879       if (toDate) {
54880         images = images.filter(function(image) {
54881           return new Date(image.captured_at).getTime() <= new Date(toDate).getTime();
54882         });
54883       }
54884       return images;
54885     }
54886     function filterSequences(sequences) {
54887       const showsPano = context.photos().showsPanoramic();
54888       const showsFlat = context.photos().showsFlat();
54889       const fromDate = context.photos().fromDate();
54890       const toDate = context.photos().toDate();
54891       if (!showsPano || !showsFlat) {
54892         sequences = sequences.filter(function(sequence) {
54893           if (sequence.properties.hasOwnProperty("is_pano")) {
54894             if (sequence.properties.is_pano)
54895               return showsPano;
54896             return showsFlat;
54897           }
54898           return false;
54899         });
54900       }
54901       if (fromDate) {
54902         sequences = sequences.filter(function(sequence) {
54903           return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString();
54904         });
54905       }
54906       if (toDate) {
54907         sequences = sequences.filter(function(sequence) {
54908           return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString();
54909         });
54910       }
54911       return sequences;
54912     }
54913     function update() {
54914       const z2 = ~~context.map().zoom();
54915       const showMarkers = z2 >= minMarkerZoom;
54916       const showViewfields = z2 >= minViewfieldZoom2;
54917       const service = getService();
54918       let sequences = service ? service.sequences(projection2) : [];
54919       let images = service && showMarkers ? service.images(projection2) : [];
54920       images = filterImages(images);
54921       sequences = filterSequences(sequences, service);
54922       service.filterViewer(context);
54923       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54924         return d2.properties.id;
54925       });
54926       traces.exit().remove();
54927       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54928       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54929         return d2.id;
54930       });
54931       groups.exit().remove();
54932       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54933       groupsEnter.append("g").attr("class", "viewfield-scale");
54934       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54935         return b2.loc[1] - a2.loc[1];
54936       }).attr("transform", transform2).select(".viewfield-scale");
54937       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54938       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54939       viewfields.exit().remove();
54940       viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() {
54941         return this.parentNode.__data__.is_pano;
54942       }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54943       function viewfieldPath() {
54944         if (this.parentNode.__data__.is_pano) {
54945           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54946         } else {
54947           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54948         }
54949       }
54950     }
54951     function drawImages(selection2) {
54952       const enabled = svgMapillaryImages.enabled;
54953       const service = getService();
54954       layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []);
54955       layer.exit().remove();
54956       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none");
54957       layerEnter.append("g").attr("class", "sequences");
54958       layerEnter.append("g").attr("class", "markers");
54959       layer = layerEnter.merge(layer);
54960       if (enabled) {
54961         if (service && ~~context.map().zoom() >= minZoom4) {
54962           editOn();
54963           update();
54964           service.loadImages(projection2);
54965         } else {
54966           editOff();
54967         }
54968       }
54969     }
54970     drawImages.enabled = function(_2) {
54971       if (!arguments.length)
54972         return svgMapillaryImages.enabled;
54973       svgMapillaryImages.enabled = _2;
54974       if (svgMapillaryImages.enabled) {
54975         showLayer();
54976         context.photos().on("change.mapillary_images", update);
54977       } else {
54978         hideLayer();
54979         context.photos().on("change.mapillary_images", null);
54980       }
54981       dispatch14.call("change");
54982       return this;
54983     };
54984     drawImages.supported = function() {
54985       return !!getService();
54986     };
54987     drawImages.rendered = function(zoom) {
54988       return zoom >= minZoom4;
54989     };
54990     init2();
54991     return drawImages;
54992   }
54993
54994   // modules/svg/mapillary_position.js
54995   function svgMapillaryPosition(projection2, context) {
54996     const throttledRedraw = throttle_default(function() {
54997       update();
54998     }, 1e3);
54999     const minZoom4 = 12;
55000     const minViewfieldZoom2 = 18;
55001     let layer = select_default2(null);
55002     let _mapillary;
55003     let viewerCompassAngle;
55004     function init2() {
55005       if (svgMapillaryPosition.initialized)
55006         return;
55007       svgMapillaryPosition.initialized = true;
55008     }
55009     function getService() {
55010       if (services.mapillary && !_mapillary) {
55011         _mapillary = services.mapillary;
55012         _mapillary.event.on("imageChanged", throttledRedraw);
55013         _mapillary.event.on("bearingChanged", function(e3) {
55014           viewerCompassAngle = e3.bearing;
55015           if (context.map().isTransformed())
55016             return;
55017           layer.selectAll(".viewfield-group.currentView").filter(function(d2) {
55018             return d2.is_pano;
55019           }).attr("transform", transform2);
55020         });
55021       } else if (!services.mapillary && _mapillary) {
55022         _mapillary = null;
55023       }
55024       return _mapillary;
55025     }
55026     function editOn() {
55027       layer.style("display", "block");
55028     }
55029     function editOff() {
55030       layer.selectAll(".viewfield-group").remove();
55031       layer.style("display", "none");
55032     }
55033     function transform2(d2) {
55034       let t2 = svgPointTransform(projection2)(d2);
55035       if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) {
55036         t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)";
55037       } else if (d2.ca) {
55038         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55039       }
55040       return t2;
55041     }
55042     function update() {
55043       const z2 = ~~context.map().zoom();
55044       const showViewfields = z2 >= minViewfieldZoom2;
55045       const service = getService();
55046       const image = service && service.getActiveImage();
55047       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) {
55048         return d2.id;
55049       });
55050       groups.exit().remove();
55051       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted");
55052       groupsEnter.append("g").attr("class", "viewfield-scale");
55053       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
55054       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55055       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55056       viewfields.exit().remove();
55057       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");
55058     }
55059     function drawImages(selection2) {
55060       const service = getService();
55061       layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []);
55062       layer.exit().remove();
55063       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position");
55064       layerEnter.append("g").attr("class", "markers");
55065       layer = layerEnter.merge(layer);
55066       if (service && ~~context.map().zoom() >= minZoom4) {
55067         editOn();
55068         update();
55069       } else {
55070         editOff();
55071       }
55072     }
55073     drawImages.enabled = function() {
55074       update();
55075       return this;
55076     };
55077     drawImages.supported = function() {
55078       return !!getService();
55079     };
55080     drawImages.rendered = function(zoom) {
55081       return zoom >= minZoom4;
55082     };
55083     init2();
55084     return drawImages;
55085   }
55086
55087   // modules/svg/mapillary_signs.js
55088   function svgMapillarySigns(projection2, context, dispatch14) {
55089     const throttledRedraw = throttle_default(function() {
55090       dispatch14.call("change");
55091     }, 1e3);
55092     const minZoom4 = 12;
55093     let layer = select_default2(null);
55094     let _mapillary;
55095     function init2() {
55096       if (svgMapillarySigns.initialized)
55097         return;
55098       svgMapillarySigns.enabled = false;
55099       svgMapillarySigns.initialized = true;
55100     }
55101     function getService() {
55102       if (services.mapillary && !_mapillary) {
55103         _mapillary = services.mapillary;
55104         _mapillary.event.on("loadedSigns", throttledRedraw);
55105       } else if (!services.mapillary && _mapillary) {
55106         _mapillary = null;
55107       }
55108       return _mapillary;
55109     }
55110     function showLayer() {
55111       const service = getService();
55112       if (!service)
55113         return;
55114       service.loadSignResources(context);
55115       editOn();
55116     }
55117     function hideLayer() {
55118       throttledRedraw.cancel();
55119       editOff();
55120     }
55121     function editOn() {
55122       layer.style("display", "block");
55123     }
55124     function editOff() {
55125       layer.selectAll(".icon-sign").remove();
55126       layer.style("display", "none");
55127     }
55128     function click(d3_event, d2) {
55129       const service = getService();
55130       if (!service)
55131         return;
55132       context.map().centerEase(d2.loc);
55133       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55134       service.getDetections(d2.id).then((detections) => {
55135         if (detections.length) {
55136           const imageId = detections[0].image.id;
55137           if (imageId === selectedImageId) {
55138             service.highlightDetection(detections[0]).selectImage(context, imageId);
55139           } else {
55140             service.ensureViewerLoaded(context).then(function() {
55141               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55142             });
55143           }
55144         }
55145       });
55146     }
55147     function filterData(detectedFeatures) {
55148       var fromDate = context.photos().fromDate();
55149       var toDate = context.photos().toDate();
55150       if (fromDate) {
55151         var fromTimestamp = new Date(fromDate).getTime();
55152         detectedFeatures = detectedFeatures.filter(function(feature3) {
55153           return new Date(feature3.last_seen_at).getTime() >= fromTimestamp;
55154         });
55155       }
55156       if (toDate) {
55157         var toTimestamp = new Date(toDate).getTime();
55158         detectedFeatures = detectedFeatures.filter(function(feature3) {
55159           return new Date(feature3.first_seen_at).getTime() <= toTimestamp;
55160         });
55161       }
55162       return detectedFeatures;
55163     }
55164     function update() {
55165       const service = getService();
55166       let data = service ? service.signs(projection2) : [];
55167       data = filterData(data);
55168       const transform2 = svgPointTransform(projection2);
55169       const signs = layer.selectAll(".icon-sign").data(data, function(d2) {
55170         return d2.id;
55171       });
55172       signs.exit().remove();
55173       const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click);
55174       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55175         return "#" + d2.value;
55176       });
55177       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55178       signs.merge(enter).attr("transform", transform2);
55179     }
55180     function drawSigns(selection2) {
55181       const enabled = svgMapillarySigns.enabled;
55182       const service = getService();
55183       layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []);
55184       layer.exit().remove();
55185       layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55186       if (enabled) {
55187         if (service && ~~context.map().zoom() >= minZoom4) {
55188           editOn();
55189           update();
55190           service.loadSigns(projection2);
55191           service.showSignDetections(true);
55192         } else {
55193           editOff();
55194         }
55195       } else if (service) {
55196         service.showSignDetections(false);
55197       }
55198     }
55199     drawSigns.enabled = function(_2) {
55200       if (!arguments.length)
55201         return svgMapillarySigns.enabled;
55202       svgMapillarySigns.enabled = _2;
55203       if (svgMapillarySigns.enabled) {
55204         showLayer();
55205         context.photos().on("change.mapillary_signs", update);
55206       } else {
55207         hideLayer();
55208         context.photos().on("change.mapillary_signs", null);
55209       }
55210       dispatch14.call("change");
55211       return this;
55212     };
55213     drawSigns.supported = function() {
55214       return !!getService();
55215     };
55216     drawSigns.rendered = function(zoom) {
55217       return zoom >= minZoom4;
55218     };
55219     init2();
55220     return drawSigns;
55221   }
55222
55223   // modules/svg/mapillary_map_features.js
55224   function svgMapillaryMapFeatures(projection2, context, dispatch14) {
55225     const throttledRedraw = throttle_default(function() {
55226       dispatch14.call("change");
55227     }, 1e3);
55228     const minZoom4 = 12;
55229     let layer = select_default2(null);
55230     let _mapillary;
55231     function init2() {
55232       if (svgMapillaryMapFeatures.initialized)
55233         return;
55234       svgMapillaryMapFeatures.enabled = false;
55235       svgMapillaryMapFeatures.initialized = true;
55236     }
55237     function getService() {
55238       if (services.mapillary && !_mapillary) {
55239         _mapillary = services.mapillary;
55240         _mapillary.event.on("loadedMapFeatures", throttledRedraw);
55241       } else if (!services.mapillary && _mapillary) {
55242         _mapillary = null;
55243       }
55244       return _mapillary;
55245     }
55246     function showLayer() {
55247       const service = getService();
55248       if (!service)
55249         return;
55250       service.loadObjectResources(context);
55251       editOn();
55252     }
55253     function hideLayer() {
55254       throttledRedraw.cancel();
55255       editOff();
55256     }
55257     function editOn() {
55258       layer.style("display", "block");
55259     }
55260     function editOff() {
55261       layer.selectAll(".icon-map-feature").remove();
55262       layer.style("display", "none");
55263     }
55264     function click(d3_event, d2) {
55265       const service = getService();
55266       if (!service)
55267         return;
55268       context.map().centerEase(d2.loc);
55269       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55270       service.getDetections(d2.id).then((detections) => {
55271         if (detections.length) {
55272           const imageId = detections[0].image.id;
55273           if (imageId === selectedImageId) {
55274             service.highlightDetection(detections[0]).selectImage(context, imageId);
55275           } else {
55276             service.ensureViewerLoaded(context).then(function() {
55277               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55278             });
55279           }
55280         }
55281       });
55282     }
55283     function filterData(detectedFeatures) {
55284       const fromDate = context.photos().fromDate();
55285       const toDate = context.photos().toDate();
55286       if (fromDate) {
55287         detectedFeatures = detectedFeatures.filter(function(feature3) {
55288           return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime();
55289         });
55290       }
55291       if (toDate) {
55292         detectedFeatures = detectedFeatures.filter(function(feature3) {
55293           return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime();
55294         });
55295       }
55296       return detectedFeatures;
55297     }
55298     function update() {
55299       const service = getService();
55300       let data = service ? service.mapFeatures(projection2) : [];
55301       data = filterData(data);
55302       const transform2 = svgPointTransform(projection2);
55303       const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) {
55304         return d2.id;
55305       });
55306       mapFeatures.exit().remove();
55307       const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click);
55308       enter.append("title").text(function(d2) {
55309         var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_");
55310         return _t("mapillary_map_features." + id2);
55311       });
55312       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55313         if (d2.value === "object--billboard") {
55314           return "#object--sign--advertisement";
55315         }
55316         return "#" + d2.value;
55317       });
55318       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55319       mapFeatures.merge(enter).attr("transform", transform2);
55320     }
55321     function drawMapFeatures(selection2) {
55322       const enabled = svgMapillaryMapFeatures.enabled;
55323       const service = getService();
55324       layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []);
55325       layer.exit().remove();
55326       layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55327       if (enabled) {
55328         if (service && ~~context.map().zoom() >= minZoom4) {
55329           editOn();
55330           update();
55331           service.loadMapFeatures(projection2);
55332           service.showFeatureDetections(true);
55333         } else {
55334           editOff();
55335         }
55336       } else if (service) {
55337         service.showFeatureDetections(false);
55338       }
55339     }
55340     drawMapFeatures.enabled = function(_2) {
55341       if (!arguments.length)
55342         return svgMapillaryMapFeatures.enabled;
55343       svgMapillaryMapFeatures.enabled = _2;
55344       if (svgMapillaryMapFeatures.enabled) {
55345         showLayer();
55346         context.photos().on("change.mapillary_map_features", update);
55347       } else {
55348         hideLayer();
55349         context.photos().on("change.mapillary_map_features", null);
55350       }
55351       dispatch14.call("change");
55352       return this;
55353     };
55354     drawMapFeatures.supported = function() {
55355       return !!getService();
55356     };
55357     drawMapFeatures.rendered = function(zoom) {
55358       return zoom >= minZoom4;
55359     };
55360     init2();
55361     return drawMapFeatures;
55362   }
55363
55364   // modules/svg/kartaview_images.js
55365   function svgKartaviewImages(projection2, context, dispatch14) {
55366     var throttledRedraw = throttle_default(function() {
55367       dispatch14.call("change");
55368     }, 1e3);
55369     var minZoom4 = 12;
55370     var minMarkerZoom = 16;
55371     var minViewfieldZoom2 = 18;
55372     var layer = select_default2(null);
55373     var _kartaview;
55374     function init2() {
55375       if (svgKartaviewImages.initialized)
55376         return;
55377       svgKartaviewImages.enabled = false;
55378       svgKartaviewImages.initialized = true;
55379     }
55380     function getService() {
55381       if (services.kartaview && !_kartaview) {
55382         _kartaview = services.kartaview;
55383         _kartaview.event.on("loadedImages", throttledRedraw);
55384       } else if (!services.kartaview && _kartaview) {
55385         _kartaview = null;
55386       }
55387       return _kartaview;
55388     }
55389     function showLayer() {
55390       var service = getService();
55391       if (!service)
55392         return;
55393       editOn();
55394       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55395         dispatch14.call("change");
55396       });
55397     }
55398     function hideLayer() {
55399       throttledRedraw.cancel();
55400       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55401     }
55402     function editOn() {
55403       layer.style("display", "block");
55404     }
55405     function editOff() {
55406       layer.selectAll(".viewfield-group").remove();
55407       layer.style("display", "none");
55408     }
55409     function click(d3_event, d2) {
55410       var service = getService();
55411       if (!service)
55412         return;
55413       service.ensureViewerLoaded(context).then(function() {
55414         service.selectImage(context, d2.key).showViewer(context);
55415       });
55416       context.map().centerEase(d2.loc);
55417     }
55418     function mouseover(d3_event, d2) {
55419       var service = getService();
55420       if (service)
55421         service.setStyles(context, d2);
55422     }
55423     function mouseout() {
55424       var service = getService();
55425       if (service)
55426         service.setStyles(context, null);
55427     }
55428     function transform2(d2) {
55429       var t2 = svgPointTransform(projection2)(d2);
55430       if (d2.ca) {
55431         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55432       }
55433       return t2;
55434     }
55435     function filterImages(images) {
55436       var fromDate = context.photos().fromDate();
55437       var toDate = context.photos().toDate();
55438       var usernames = context.photos().usernames();
55439       if (fromDate) {
55440         var fromTimestamp = new Date(fromDate).getTime();
55441         images = images.filter(function(item) {
55442           return new Date(item.captured_at).getTime() >= fromTimestamp;
55443         });
55444       }
55445       if (toDate) {
55446         var toTimestamp = new Date(toDate).getTime();
55447         images = images.filter(function(item) {
55448           return new Date(item.captured_at).getTime() <= toTimestamp;
55449         });
55450       }
55451       if (usernames) {
55452         images = images.filter(function(item) {
55453           return usernames.indexOf(item.captured_by) !== -1;
55454         });
55455       }
55456       return images;
55457     }
55458     function filterSequences(sequences) {
55459       var fromDate = context.photos().fromDate();
55460       var toDate = context.photos().toDate();
55461       var usernames = context.photos().usernames();
55462       if (fromDate) {
55463         var fromTimestamp = new Date(fromDate).getTime();
55464         sequences = sequences.filter(function(image) {
55465           return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
55466         });
55467       }
55468       if (toDate) {
55469         var toTimestamp = new Date(toDate).getTime();
55470         sequences = sequences.filter(function(image) {
55471           return new Date(image.properties.captured_at).getTime() <= toTimestamp;
55472         });
55473       }
55474       if (usernames) {
55475         sequences = sequences.filter(function(image) {
55476           return usernames.indexOf(image.properties.captured_by) !== -1;
55477         });
55478       }
55479       return sequences;
55480     }
55481     function update() {
55482       var viewer = context.container().select(".photoviewer");
55483       var selected = viewer.empty() ? void 0 : viewer.datum();
55484       var z2 = ~~context.map().zoom();
55485       var showMarkers = z2 >= minMarkerZoom;
55486       var showViewfields = z2 >= minViewfieldZoom2;
55487       var service = getService();
55488       var sequences = [];
55489       var images = [];
55490       if (context.photos().showsFlat()) {
55491         sequences = service ? service.sequences(projection2) : [];
55492         images = service && showMarkers ? service.images(projection2) : [];
55493         sequences = filterSequences(sequences);
55494         images = filterImages(images);
55495       }
55496       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55497         return d2.properties.key;
55498       });
55499       traces.exit().remove();
55500       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55501       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55502         return d2.key;
55503       });
55504       groups.exit().remove();
55505       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55506       groupsEnter.append("g").attr("class", "viewfield-scale");
55507       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55508         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
55509       }).attr("transform", transform2).select(".viewfield-scale");
55510       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55511       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55512       viewfields.exit().remove();
55513       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");
55514     }
55515     function drawImages(selection2) {
55516       var enabled = svgKartaviewImages.enabled, service = getService();
55517       layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []);
55518       layer.exit().remove();
55519       var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none");
55520       layerEnter.append("g").attr("class", "sequences");
55521       layerEnter.append("g").attr("class", "markers");
55522       layer = layerEnter.merge(layer);
55523       if (enabled) {
55524         if (service && ~~context.map().zoom() >= minZoom4) {
55525           editOn();
55526           update();
55527           service.loadImages(projection2);
55528         } else {
55529           editOff();
55530         }
55531       }
55532     }
55533     drawImages.enabled = function(_2) {
55534       if (!arguments.length)
55535         return svgKartaviewImages.enabled;
55536       svgKartaviewImages.enabled = _2;
55537       if (svgKartaviewImages.enabled) {
55538         showLayer();
55539         context.photos().on("change.kartaview_images", update);
55540       } else {
55541         hideLayer();
55542         context.photos().on("change.kartaview_images", null);
55543       }
55544       dispatch14.call("change");
55545       return this;
55546     };
55547     drawImages.supported = function() {
55548       return !!getService();
55549     };
55550     drawImages.rendered = function(zoom) {
55551       return zoom >= minZoom4;
55552     };
55553     init2();
55554     return drawImages;
55555   }
55556
55557   // modules/svg/mapilio_images.js
55558   function svgMapilioImages(projection2, context, dispatch14) {
55559     const throttledRedraw = throttle_default(function() {
55560       dispatch14.call("change");
55561     }, 1e3);
55562     const minZoom4 = 12;
55563     let layer = select_default2(null);
55564     let _mapilio;
55565     const viewFieldZoomLevel = 18;
55566     function init2() {
55567       if (svgMapilioImages.initialized)
55568         return;
55569       svgMapilioImages.enabled = false;
55570       svgMapilioImages.initialized = true;
55571     }
55572     function getService() {
55573       if (services.mapilio && !_mapilio) {
55574         _mapilio = services.mapilio;
55575         _mapilio.event.on("loadedImages", throttledRedraw);
55576       } else if (!services.mapilio && _mapilio) {
55577         _mapilio = null;
55578       }
55579       return _mapilio;
55580     }
55581     function showLayer() {
55582       const service = getService();
55583       if (!service)
55584         return;
55585       editOn();
55586       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55587         dispatch14.call("change");
55588       });
55589     }
55590     function hideLayer() {
55591       throttledRedraw.cancel();
55592       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55593     }
55594     function transform2(d2) {
55595       let t2 = svgPointTransform(projection2)(d2);
55596       if (d2.heading) {
55597         t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)";
55598       }
55599       return t2;
55600     }
55601     function editOn() {
55602       layer.style("display", "block");
55603     }
55604     function editOff() {
55605       layer.selectAll(".viewfield-group").remove();
55606       layer.style("display", "none");
55607     }
55608     function click(d3_event, image) {
55609       const service = getService();
55610       if (!service)
55611         return;
55612       service.ensureViewerLoaded(context, image.id).then(function() {
55613         service.selectImage(context, image.id).showViewer(context);
55614       });
55615       context.map().centerEase(image.loc);
55616     }
55617     function mouseover(d3_event, image) {
55618       const service = getService();
55619       if (service)
55620         service.setStyles(context, image);
55621     }
55622     function mouseout() {
55623       const service = getService();
55624       if (service)
55625         service.setStyles(context, null);
55626     }
55627     function update() {
55628       const z2 = ~~context.map().zoom();
55629       const showViewfields = z2 >= viewFieldZoomLevel;
55630       const service = getService();
55631       let sequences = service ? service.sequences(projection2) : [];
55632       let images = service ? service.images(projection2) : [];
55633       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55634         return d2.properties.id;
55635       });
55636       traces.exit().remove();
55637       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55638       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55639         return d2.id;
55640       });
55641       groups.exit().remove();
55642       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55643       groupsEnter.append("g").attr("class", "viewfield-scale");
55644       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55645         return b2.loc[1] - a2.loc[1];
55646       }).attr("transform", transform2).select(".viewfield-scale");
55647       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55648       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55649       viewfields.exit().remove();
55650       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
55651       function viewfieldPath() {
55652         if (this.parentNode.__data__.isPano) {
55653           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
55654         } else {
55655           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
55656         }
55657       }
55658     }
55659     function drawImages(selection2) {
55660       const enabled = svgMapilioImages.enabled;
55661       const service = getService();
55662       layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []);
55663       layer.exit().remove();
55664       const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none");
55665       layerEnter.append("g").attr("class", "sequences");
55666       layerEnter.append("g").attr("class", "markers");
55667       layer = layerEnter.merge(layer);
55668       if (enabled) {
55669         if (service && ~~context.map().zoom() >= minZoom4) {
55670           editOn();
55671           update();
55672           service.loadImages(projection2);
55673           service.loadLines(projection2);
55674         } else {
55675           editOff();
55676         }
55677       }
55678     }
55679     drawImages.enabled = function(_2) {
55680       if (!arguments.length)
55681         return svgMapilioImages.enabled;
55682       svgMapilioImages.enabled = _2;
55683       if (svgMapilioImages.enabled) {
55684         showLayer();
55685         context.photos().on("change.mapilio_images", null);
55686       } else {
55687         hideLayer();
55688         context.photos().on("change.mapilio_images", null);
55689       }
55690       dispatch14.call("change");
55691       return this;
55692     };
55693     drawImages.supported = function() {
55694       return !!getService();
55695     };
55696     drawImages.rendered = function(zoom) {
55697       return zoom >= minZoom4;
55698     };
55699     init2();
55700     return drawImages;
55701   }
55702
55703   // modules/svg/osm.js
55704   function svgOsm(projection2, context, dispatch14) {
55705     var enabled = true;
55706     function drawOsm(selection2) {
55707       selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) {
55708         return "layer-osm " + d2;
55709       });
55710       selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) {
55711         return "points-group " + d2;
55712       });
55713     }
55714     function showLayer() {
55715       var layer = context.surface().selectAll(".data-layer.osm");
55716       layer.interrupt();
55717       layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55718         dispatch14.call("change");
55719       });
55720     }
55721     function hideLayer() {
55722       var layer = context.surface().selectAll(".data-layer.osm");
55723       layer.interrupt();
55724       layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55725         layer.classed("disabled", true);
55726         dispatch14.call("change");
55727       });
55728     }
55729     drawOsm.enabled = function(val) {
55730       if (!arguments.length)
55731         return enabled;
55732       enabled = val;
55733       if (enabled) {
55734         showLayer();
55735       } else {
55736         hideLayer();
55737       }
55738       dispatch14.call("change");
55739       return this;
55740     };
55741     return drawOsm;
55742   }
55743
55744   // modules/svg/notes.js
55745   var _notesEnabled = false;
55746   var _osmService;
55747   function svgNotes(projection2, context, dispatch14) {
55748     if (!dispatch14) {
55749       dispatch14 = dispatch_default("change");
55750     }
55751     var throttledRedraw = throttle_default(function() {
55752       dispatch14.call("change");
55753     }, 1e3);
55754     var minZoom4 = 12;
55755     var touchLayer = select_default2(null);
55756     var drawLayer = select_default2(null);
55757     var _notesVisible = false;
55758     function markerPath(selection2, klass) {
55759       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");
55760     }
55761     function getService() {
55762       if (services.osm && !_osmService) {
55763         _osmService = services.osm;
55764         _osmService.on("loadedNotes", throttledRedraw);
55765       } else if (!services.osm && _osmService) {
55766         _osmService = null;
55767       }
55768       return _osmService;
55769     }
55770     function editOn() {
55771       if (!_notesVisible) {
55772         _notesVisible = true;
55773         drawLayer.style("display", "block");
55774       }
55775     }
55776     function editOff() {
55777       if (_notesVisible) {
55778         _notesVisible = false;
55779         drawLayer.style("display", "none");
55780         drawLayer.selectAll(".note").remove();
55781         touchLayer.selectAll(".note").remove();
55782       }
55783     }
55784     function layerOn() {
55785       editOn();
55786       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55787         dispatch14.call("change");
55788       });
55789     }
55790     function layerOff() {
55791       throttledRedraw.cancel();
55792       drawLayer.interrupt();
55793       touchLayer.selectAll(".note").remove();
55794       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55795         editOff();
55796         dispatch14.call("change");
55797       });
55798     }
55799     function updateMarkers() {
55800       if (!_notesVisible || !_notesEnabled)
55801         return;
55802       var service = getService();
55803       var selectedID = context.selectedNoteID();
55804       var data = service ? service.notes(projection2) : [];
55805       var getTransform = svgPointTransform(projection2);
55806       var notes = drawLayer.selectAll(".note").data(data, function(d2) {
55807         return d2.status + d2.id;
55808       });
55809       notes.exit().remove();
55810       var notesEnter = notes.enter().append("g").attr("class", function(d2) {
55811         return "note note-" + d2.id + " " + d2.status;
55812       }).classed("new", function(d2) {
55813         return d2.id < 0;
55814       });
55815       notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55816       notesEnter.append("path").call(markerPath, "shadow");
55817       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");
55818       notesEnter.selectAll(".icon-annotation").data(function(d2) {
55819         return [d2];
55820       }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) {
55821         if (d2.id < 0)
55822           return "#iD-icon-plus";
55823         if (d2.status === "open")
55824           return "#iD-icon-close";
55825         return "#iD-icon-apply";
55826       });
55827       notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) {
55828         var mode = context.mode();
55829         var isMoving = mode && mode.id === "drag-note";
55830         return !isMoving && d2.id === selectedID;
55831       }).attr("transform", getTransform);
55832       if (touchLayer.empty())
55833         return;
55834       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55835       var targets = touchLayer.selectAll(".note").data(data, function(d2) {
55836         return d2.id;
55837       });
55838       targets.exit().remove();
55839       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) {
55840         var newClass = d2.id < 0 ? "new" : "";
55841         return "note target note-" + d2.id + " " + fillClass + newClass;
55842       }).attr("transform", getTransform);
55843       function sortY(a2, b2) {
55844         if (a2.id === selectedID)
55845           return 1;
55846         if (b2.id === selectedID)
55847           return -1;
55848         return b2.loc[1] - a2.loc[1];
55849       }
55850     }
55851     function drawNotes(selection2) {
55852       var service = getService();
55853       var surface = context.surface();
55854       if (surface && !surface.empty()) {
55855         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
55856       }
55857       drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []);
55858       drawLayer.exit().remove();
55859       drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer);
55860       if (_notesEnabled) {
55861         if (service && ~~context.map().zoom() >= minZoom4) {
55862           editOn();
55863           service.loadNotes(projection2);
55864           updateMarkers();
55865         } else {
55866           editOff();
55867         }
55868       }
55869     }
55870     drawNotes.enabled = function(val) {
55871       if (!arguments.length)
55872         return _notesEnabled;
55873       _notesEnabled = val;
55874       if (_notesEnabled) {
55875         layerOn();
55876       } else {
55877         layerOff();
55878         if (context.selectedNoteID()) {
55879           context.enter(modeBrowse(context));
55880         }
55881       }
55882       dispatch14.call("change");
55883       return this;
55884     };
55885     return drawNotes;
55886   }
55887
55888   // modules/svg/touch.js
55889   function svgTouch() {
55890     function drawTouch(selection2) {
55891       selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) {
55892         return "layer-touch " + d2;
55893       });
55894     }
55895     return drawTouch;
55896   }
55897
55898   // modules/util/dimensions.js
55899   function refresh(selection2, node) {
55900     var cr = node.getBoundingClientRect();
55901     var prop = [cr.width, cr.height];
55902     selection2.property("__dimensions__", prop);
55903     return prop;
55904   }
55905   function utilGetDimensions(selection2, force) {
55906     if (!selection2 || selection2.empty()) {
55907       return [0, 0];
55908     }
55909     var node = selection2.node(), cached = selection2.property("__dimensions__");
55910     return !cached || force ? refresh(selection2, node) : cached;
55911   }
55912   function utilSetDimensions(selection2, dimensions) {
55913     if (!selection2 || selection2.empty()) {
55914       return selection2;
55915     }
55916     var node = selection2.node();
55917     if (dimensions === null) {
55918       refresh(selection2, node);
55919       return selection2;
55920     }
55921     return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]);
55922   }
55923
55924   // modules/svg/layers.js
55925   function svgLayers(projection2, context) {
55926     var dispatch14 = dispatch_default("change");
55927     var svg2 = select_default2(null);
55928     var _layers = [
55929       { id: "osm", layer: svgOsm(projection2, context, dispatch14) },
55930       { id: "notes", layer: svgNotes(projection2, context, dispatch14) },
55931       { id: "data", layer: svgData(projection2, context, dispatch14) },
55932       { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) },
55933       { id: "improveOSM", layer: svgImproveOSM(projection2, context, dispatch14) },
55934       { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) },
55935       { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) },
55936       { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) },
55937       { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) },
55938       { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) },
55939       { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) },
55940       { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) },
55941       { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) },
55942       { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) },
55943       { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) },
55944       { id: "debug", layer: svgDebug(projection2, context, dispatch14) },
55945       { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) },
55946       { id: "touch", layer: svgTouch(projection2, context, dispatch14) }
55947     ];
55948     function drawLayers(selection2) {
55949       svg2 = selection2.selectAll(".surface").data([0]);
55950       svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2);
55951       var defs = svg2.selectAll(".surface-defs").data([0]);
55952       defs.enter().append("defs").attr("class", "surface-defs");
55953       var groups = svg2.selectAll(".data-layer").data(_layers);
55954       groups.exit().remove();
55955       groups.enter().append("g").attr("class", function(d2) {
55956         return "data-layer " + d2.id;
55957       }).merge(groups).each(function(d2) {
55958         select_default2(this).call(d2.layer);
55959       });
55960     }
55961     drawLayers.all = function() {
55962       return _layers;
55963     };
55964     drawLayers.layer = function(id2) {
55965       var obj = _layers.find(function(o2) {
55966         return o2.id === id2;
55967       });
55968       return obj && obj.layer;
55969     };
55970     drawLayers.only = function(what) {
55971       var arr = [].concat(what);
55972       var all = _layers.map(function(layer) {
55973         return layer.id;
55974       });
55975       return drawLayers.remove(utilArrayDifference(all, arr));
55976     };
55977     drawLayers.remove = function(what) {
55978       var arr = [].concat(what);
55979       arr.forEach(function(id2) {
55980         _layers = _layers.filter(function(o2) {
55981           return o2.id !== id2;
55982         });
55983       });
55984       dispatch14.call("change");
55985       return this;
55986     };
55987     drawLayers.add = function(what) {
55988       var arr = [].concat(what);
55989       arr.forEach(function(obj) {
55990         if ("id" in obj && "layer" in obj) {
55991           _layers.push(obj);
55992         }
55993       });
55994       dispatch14.call("change");
55995       return this;
55996     };
55997     drawLayers.dimensions = function(val) {
55998       if (!arguments.length)
55999         return utilGetDimensions(svg2);
56000       utilSetDimensions(svg2, val);
56001       return this;
56002     };
56003     return utilRebind(drawLayers, dispatch14, "on");
56004   }
56005
56006   // modules/svg/lines.js
56007   var import_fast_deep_equal6 = __toESM(require_fast_deep_equal());
56008   function svgLines(projection2, context) {
56009     var detected = utilDetect();
56010     var highway_stack = {
56011       motorway: 0,
56012       motorway_link: 1,
56013       trunk: 2,
56014       trunk_link: 3,
56015       primary: 4,
56016       primary_link: 5,
56017       secondary: 6,
56018       tertiary: 7,
56019       unclassified: 8,
56020       residential: 9,
56021       service: 10,
56022       busway: 11,
56023       footway: 12
56024     };
56025     function drawTargets(selection2, graph, entities, filter2) {
56026       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56027       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56028       var getPath = svgPath(projection2).geojson;
56029       var activeID = context.activeID();
56030       var base = context.history().base();
56031       var data = { targets: [], nopes: [] };
56032       entities.forEach(function(way) {
56033         var features = svgSegmentWay(way, graph, activeID);
56034         data.targets.push.apply(data.targets, features.passive);
56035         data.nopes.push.apply(data.nopes, features.active);
56036       });
56037       var targetData = data.targets.filter(getPath);
56038       var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) {
56039         return filter2(d2.properties.entity);
56040       }).data(targetData, function key(d2) {
56041         return d2.id;
56042       });
56043       targets.exit().remove();
56044       var segmentWasEdited = function(d2) {
56045         var wayID = d2.properties.entity.id;
56046         if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
56047           return false;
56048         }
56049         return d2.properties.nodes.some(function(n3) {
56050           return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
56051         });
56052       };
56053       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
56054         return "way line target target-allowed " + targetClass + d2.id;
56055       }).classed("segment-edited", segmentWasEdited);
56056       var nopeData = data.nopes.filter(getPath);
56057       var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) {
56058         return filter2(d2.properties.entity);
56059       }).data(nopeData, function key(d2) {
56060         return d2.id;
56061       });
56062       nopes.exit().remove();
56063       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
56064         return "way line target target-nope " + nopeClass + d2.id;
56065       }).classed("segment-edited", segmentWasEdited);
56066     }
56067     function drawLines(selection2, graph, entities, filter2) {
56068       var base = context.history().base();
56069       function waystack(a2, b2) {
56070         var selected = context.selectedIDs();
56071         var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0;
56072         var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0;
56073         if (a2.tags.highway) {
56074           scoreA -= highway_stack[a2.tags.highway];
56075         }
56076         if (b2.tags.highway) {
56077           scoreB -= highway_stack[b2.tags.highway];
56078         }
56079         return scoreA - scoreB;
56080       }
56081       function drawLineGroup(selection3, klass, isSelected) {
56082         var mode = context.mode();
56083         var isDrawing = mode && /^draw/.test(mode.id);
56084         var selectedClass = !isDrawing && isSelected ? "selected " : "";
56085         var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key);
56086         lines.exit().remove();
56087         lines.enter().append("path").attr("class", function(d2) {
56088           var prefix = "way line";
56089           if (!d2.hasInterestingTags()) {
56090             var parentRelations = graph.parentRelations(d2);
56091             var parentMultipolygons = parentRelations.filter(function(relation) {
56092               return relation.isMultipolygon();
56093             });
56094             if (parentMultipolygons.length > 0 && // and only multipolygon relations
56095             parentRelations.length === parentMultipolygons.length) {
56096               prefix = "relation area";
56097             }
56098           }
56099           var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : "";
56100           return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id;
56101         }).classed("added", function(d2) {
56102           return !base.entities[d2.id];
56103         }).classed("geometry-edited", function(d2) {
56104           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);
56105         }).classed("retagged", function(d2) {
56106           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);
56107         }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph)));
56108         return selection3;
56109       }
56110       function getPathData(isSelected) {
56111         return function() {
56112           var layer = this.parentNode.__data__;
56113           var data = pathdata[layer] || [];
56114           return data.filter(function(d2) {
56115             if (isSelected) {
56116               return context.selectedIDs().indexOf(d2.id) !== -1;
56117             } else {
56118               return context.selectedIDs().indexOf(d2.id) === -1;
56119             }
56120           });
56121         };
56122       }
56123       function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) {
56124         var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]);
56125         markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup);
56126         var markers = markergroup.selectAll("path").filter(filter2).data(
56127           function data() {
56128             return groupdata[this.parentNode.__data__] || [];
56129           },
56130           function key(d2) {
56131             return [d2.id, d2.index];
56132           }
56133         );
56134         markers.exit().remove();
56135         markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) {
56136           return d2.d;
56137         });
56138         if (detected.ie) {
56139           markers.each(function() {
56140             this.parentNode.insertBefore(this, this);
56141           });
56142         }
56143       }
56144       var getPath = svgPath(projection2, graph);
56145       var ways = [];
56146       var onewaydata = {};
56147       var sideddata = {};
56148       var oldMultiPolygonOuters = {};
56149       for (var i3 = 0; i3 < entities.length; i3++) {
56150         var entity = entities[i3];
56151         if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") {
56152           ways.push(entity);
56153         }
56154       }
56155       ways = ways.filter(getPath);
56156       var pathdata = utilArrayGroupBy(ways, function(way) {
56157         return way.layer();
56158       });
56159       Object.keys(pathdata).forEach(function(k2) {
56160         var v2 = pathdata[k2];
56161         var onewayArr = v2.filter(function(d2) {
56162           return d2.isOneWay();
56163         });
56164         var onewaySegments = svgMarkerSegments(
56165           projection2,
56166           graph,
56167           35,
56168           function shouldReverse(entity2) {
56169             return entity2.tags.oneway === "-1";
56170           },
56171           function bothDirections(entity2) {
56172             return entity2.tags.oneway === "reversible" || entity2.tags.oneway === "alternating";
56173           }
56174         );
56175         onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments));
56176         var sidedArr = v2.filter(function(d2) {
56177           return d2.isSided();
56178         });
56179         var sidedSegments = svgMarkerSegments(
56180           projection2,
56181           graph,
56182           30,
56183           function shouldReverse() {
56184             return false;
56185           },
56186           function bothDirections() {
56187             return false;
56188           }
56189         );
56190         sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments));
56191       });
56192       var covered = selection2.selectAll(".layer-osm.covered");
56193       var uncovered = selection2.selectAll(".layer-osm.lines");
56194       var touchLayer = selection2.selectAll(".layer-touch.lines");
56195       [covered, uncovered].forEach(function(selection3) {
56196         var range3 = selection3 === covered ? range(-10, 0) : range(0, 11);
56197         var layergroup = selection3.selectAll("g.layergroup").data(range3);
56198         layergroup = layergroup.enter().append("g").attr("class", function(d2) {
56199           return "layergroup layer" + String(d2);
56200         }).merge(layergroup);
56201         layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) {
56202           return "linegroup line-" + d2;
56203         });
56204         layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false);
56205         layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false);
56206         layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false);
56207         layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true);
56208         layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true);
56209         layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true);
56210         addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, "url(#ideditor-oneway-marker)");
56211         addMarkers(
56212           layergroup,
56213           "sided",
56214           "sidedgroup",
56215           sideddata,
56216           function marker(d2) {
56217             var category = graph.entity(d2.id).sidednessIdentifier();
56218             return "url(#ideditor-sided-marker-" + category + ")";
56219           }
56220         );
56221       });
56222       touchLayer.call(drawTargets, graph, ways, filter2);
56223     }
56224     return drawLines;
56225   }
56226
56227   // modules/svg/midpoints.js
56228   function svgMidpoints(projection2, context) {
56229     var targetRadius = 8;
56230     function drawTargets(selection2, graph, entities, filter2) {
56231       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56232       var getTransform = svgPointTransform(projection2).geojson;
56233       var data = entities.map(function(midpoint) {
56234         return {
56235           type: "Feature",
56236           id: midpoint.id,
56237           properties: {
56238             target: true,
56239             entity: midpoint
56240           },
56241           geometry: {
56242             type: "Point",
56243             coordinates: midpoint.loc
56244           }
56245         };
56246       });
56247       var targets = selection2.selectAll(".midpoint.target").filter(function(d2) {
56248         return filter2(d2.properties.entity);
56249       }).data(data, function key(d2) {
56250         return d2.id;
56251       });
56252       targets.exit().remove();
56253       targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) {
56254         return "node midpoint target " + fillClass + d2.id;
56255       }).attr("transform", getTransform);
56256     }
56257     function drawMidpoints(selection2, graph, entities, filter2, extent) {
56258       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints");
56259       var touchLayer = selection2.selectAll(".layer-touch.points");
56260       var mode = context.mode();
56261       if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) {
56262         drawLayer.selectAll(".midpoint").remove();
56263         touchLayer.selectAll(".midpoint.target").remove();
56264         return;
56265       }
56266       var poly = extent.polygon();
56267       var midpoints = {};
56268       for (var i3 = 0; i3 < entities.length; i3++) {
56269         var entity = entities[i3];
56270         if (entity.type !== "way")
56271           continue;
56272         if (!filter2(entity))
56273           continue;
56274         if (context.selectedIDs().indexOf(entity.id) < 0)
56275           continue;
56276         var nodes = graph.childNodes(entity);
56277         for (var j2 = 0; j2 < nodes.length - 1; j2++) {
56278           var a2 = nodes[j2];
56279           var b2 = nodes[j2 + 1];
56280           var id2 = [a2.id, b2.id].sort().join("-");
56281           if (midpoints[id2]) {
56282             midpoints[id2].parents.push(entity);
56283           } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) {
56284             var point2 = geoVecInterp(a2.loc, b2.loc, 0.5);
56285             var loc = null;
56286             if (extent.intersects(point2)) {
56287               loc = point2;
56288             } else {
56289               for (var k2 = 0; k2 < 4; k2++) {
56290                 point2 = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]);
56291                 if (point2 && geoVecLength(projection2(a2.loc), projection2(point2)) > 20 && geoVecLength(projection2(b2.loc), projection2(point2)) > 20) {
56292                   loc = point2;
56293                   break;
56294                 }
56295               }
56296             }
56297             if (loc) {
56298               midpoints[id2] = {
56299                 type: "midpoint",
56300                 id: id2,
56301                 loc,
56302                 edge: [a2.id, b2.id],
56303                 parents: [entity]
56304               };
56305             }
56306           }
56307         }
56308       }
56309       function midpointFilter(d2) {
56310         if (midpoints[d2.id])
56311           return true;
56312         for (var i4 = 0; i4 < d2.parents.length; i4++) {
56313           if (filter2(d2.parents[i4])) {
56314             return true;
56315           }
56316         }
56317         return false;
56318       }
56319       var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) {
56320         return d2.id;
56321       });
56322       groups.exit().remove();
56323       var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint");
56324       enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow");
56325       enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill");
56326       groups = groups.merge(enter).attr("transform", function(d2) {
56327         var translate = svgPointTransform(projection2);
56328         var a3 = graph.entity(d2.edge[0]);
56329         var b3 = graph.entity(d2.edge[1]);
56330         var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI);
56331         return translate(d2) + " rotate(" + angle2 + ")";
56332       }).call(svgTagClasses().tags(
56333         function(d2) {
56334           return d2.parents[0].tags;
56335         }
56336       ));
56337       groups.select("polygon.shadow");
56338       groups.select("polygon.fill");
56339       touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter);
56340     }
56341     return drawMidpoints;
56342   }
56343
56344   // modules/svg/points.js
56345   var import_fast_deep_equal7 = __toESM(require_fast_deep_equal());
56346   function svgPoints(projection2, context) {
56347     function markerPath(selection2, klass) {
56348       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");
56349     }
56350     function sortY(a2, b2) {
56351       return b2.loc[1] - a2.loc[1];
56352     }
56353     function fastEntityKey(d2) {
56354       var mode = context.mode();
56355       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56356       return isMoving ? d2.id : osmEntity.key(d2);
56357     }
56358     function drawTargets(selection2, graph, entities, filter2) {
56359       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56360       var getTransform = svgPointTransform(projection2).geojson;
56361       var activeID = context.activeID();
56362       var data = [];
56363       entities.forEach(function(node) {
56364         if (activeID === node.id)
56365           return;
56366         data.push({
56367           type: "Feature",
56368           id: node.id,
56369           properties: {
56370             target: true,
56371             entity: node
56372           },
56373           geometry: node.asGeoJSON()
56374         });
56375       });
56376       var targets = selection2.selectAll(".point.target").filter(function(d2) {
56377         return filter2(d2.properties.entity);
56378       }).data(data, function key(d2) {
56379         return d2.id;
56380       });
56381       targets.exit().remove();
56382       targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) {
56383         return "node point target " + fillClass + d2.id;
56384       }).attr("transform", getTransform);
56385     }
56386     function drawPoints(selection2, graph, entities, filter2) {
56387       var wireframe = context.surface().classed("fill-wireframe");
56388       var zoom = geoScaleToZoom(projection2.scale());
56389       var base = context.history().base();
56390       function renderAsPoint(entity) {
56391         return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length);
56392       }
56393       var points = wireframe ? [] : entities.filter(renderAsPoint);
56394       points.sort(sortY);
56395       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points");
56396       var touchLayer = selection2.selectAll(".layer-touch.points");
56397       var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey);
56398       groups.exit().remove();
56399       var enter = groups.enter().append("g").attr("class", function(d2) {
56400         return "node point " + d2.id;
56401       }).order();
56402       enter.append("path").call(markerPath, "shadow");
56403       enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
56404       enter.append("path").call(markerPath, "stroke");
56405       enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px");
56406       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) {
56407         return !base.entities[d2.id];
56408       }).classed("moved", function(d2) {
56409         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56410       }).classed("retagged", function(d2) {
56411         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56412       }).call(svgTagClasses());
56413       groups.select(".shadow");
56414       groups.select(".stroke");
56415       groups.select(".icon").attr("xlink:href", function(entity) {
56416         var preset = _mainPresetIndex.match(entity, graph);
56417         var picon = preset && preset.icon;
56418         return picon ? "#" + picon : "";
56419       });
56420       touchLayer.call(drawTargets, graph, points, filter2);
56421     }
56422     return drawPoints;
56423   }
56424
56425   // modules/svg/turns.js
56426   function svgTurns(projection2, context) {
56427     function icon2(turn) {
56428       var u2 = turn.u ? "-u" : "";
56429       if (turn.no)
56430         return "#iD-turn-no" + u2;
56431       if (turn.only)
56432         return "#iD-turn-only" + u2;
56433       return "#iD-turn-yes" + u2;
56434     }
56435     function drawTurns(selection2, graph, turns) {
56436       function turnTransform(d2) {
56437         var pxRadius = 50;
56438         var toWay = graph.entity(d2.to.way);
56439         var toPoints = graph.childNodes(toWay).map(function(n3) {
56440           return n3.loc;
56441         }).map(projection2);
56442         var toLength = geoPathLength(toPoints);
56443         var mid = toLength / 2;
56444         var toNode = graph.entity(d2.to.node);
56445         var toVertex = graph.entity(d2.to.vertex);
56446         var a2 = geoAngle(toVertex, toNode, projection2);
56447         var o2 = projection2(toVertex.loc);
56448         var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius);
56449         return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")";
56450       }
56451       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns");
56452       var touchLayer = selection2.selectAll(".layer-touch.turns");
56453       var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) {
56454         return d2.key;
56455       });
56456       groups.exit().remove();
56457       var groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56458         return "turn " + d2.key;
56459       });
56460       var turnsEnter = groupsEnter.filter(function(d2) {
56461         return !d2.u;
56462       });
56463       turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56464       turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56465       var uEnter = groupsEnter.filter(function(d2) {
56466         return d2.u;
56467       });
56468       uEnter.append("circle").attr("r", "16");
56469       uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32");
56470       groups = groups.merge(groupsEnter).attr("opacity", function(d2) {
56471         return d2.direct === false ? "0.7" : null;
56472       }).attr("transform", turnTransform);
56473       groups.select("use").attr("xlink:href", icon2);
56474       groups.select("rect");
56475       groups.select("circle");
56476       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56477       groups = touchLayer.selectAll("g.turn").data(turns, function(d2) {
56478         return d2.key;
56479       });
56480       groups.exit().remove();
56481       groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56482         return "turn " + d2.key;
56483       });
56484       turnsEnter = groupsEnter.filter(function(d2) {
56485         return !d2.u;
56486       });
56487       turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56488       uEnter = groupsEnter.filter(function(d2) {
56489         return d2.u;
56490       });
56491       uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16");
56492       groups = groups.merge(groupsEnter).attr("transform", turnTransform);
56493       groups.select("rect");
56494       groups.select("circle");
56495       return this;
56496     }
56497     return drawTurns;
56498   }
56499
56500   // modules/svg/vertices.js
56501   var import_fast_deep_equal8 = __toESM(require_fast_deep_equal());
56502   function svgVertices(projection2, context) {
56503     var radiuses = {
56504       //       z16-, z17,   z18+,  w/icon
56505       shadow: [6, 7.5, 7.5, 12],
56506       stroke: [2.5, 3.5, 3.5, 8],
56507       fill: [1, 1.5, 1.5, 1.5]
56508     };
56509     var _currHoverTarget;
56510     var _currPersistent = {};
56511     var _currHover = {};
56512     var _prevHover = {};
56513     var _currSelected = {};
56514     var _prevSelected = {};
56515     var _radii = {};
56516     function sortY(a2, b2) {
56517       return b2.loc[1] - a2.loc[1];
56518     }
56519     function fastEntityKey(d2) {
56520       var mode = context.mode();
56521       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56522       return isMoving ? d2.id : osmEntity.key(d2);
56523     }
56524     function draw(selection2, graph, vertices, sets2, filter2) {
56525       sets2 = sets2 || { selected: {}, important: {}, hovered: {} };
56526       var icons = {};
56527       var directions = {};
56528       var wireframe = context.surface().classed("fill-wireframe");
56529       var zoom = geoScaleToZoom(projection2.scale());
56530       var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2;
56531       var activeID = context.activeID();
56532       var base = context.history().base();
56533       function getIcon(d2) {
56534         var entity = graph.entity(d2.id);
56535         if (entity.id in icons)
56536           return icons[entity.id];
56537         icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon;
56538         return icons[entity.id];
56539       }
56540       function getDirections(entity) {
56541         if (entity.id in directions)
56542           return directions[entity.id];
56543         var angles = entity.directions(graph, projection2);
56544         directions[entity.id] = angles.length ? angles : false;
56545         return angles;
56546       }
56547       function updateAttributes(selection3) {
56548         ["shadow", "stroke", "fill"].forEach(function(klass) {
56549           var rads = radiuses[klass];
56550           selection3.selectAll("." + klass).each(function(entity) {
56551             var i3 = z2 && getIcon(entity);
56552             var r2 = rads[i3 ? 3 : z2];
56553             if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) {
56554               r2 += 1.5;
56555             }
56556             if (klass === "shadow") {
56557               _radii[entity.id] = r2;
56558             }
56559             select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null);
56560           });
56561         });
56562       }
56563       vertices.sort(sortY);
56564       var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey);
56565       groups.exit().remove();
56566       var enter = groups.enter().append("g").attr("class", function(d2) {
56567         return "node vertex " + d2.id;
56568       }).order();
56569       enter.append("circle").attr("class", "shadow");
56570       enter.append("circle").attr("class", "stroke");
56571       enter.filter(function(d2) {
56572         return d2.hasInterestingTags();
56573       }).append("circle").attr("class", "fill");
56574       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) {
56575         return d2.id in sets2.selected;
56576       }).classed("shared", function(d2) {
56577         return graph.isShared(d2);
56578       }).classed("endpoint", function(d2) {
56579         return d2.isEndpoint(graph);
56580       }).classed("added", function(d2) {
56581         return !base.entities[d2.id];
56582       }).classed("moved", function(d2) {
56583         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56584       }).classed("retagged", function(d2) {
56585         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56586       }).call(updateAttributes);
56587       var iconUse = groups.selectAll(".icon").data(function data(d2) {
56588         return zoom >= 17 && getIcon(d2) ? [d2] : [];
56589       }, fastEntityKey);
56590       iconUse.exit().remove();
56591       iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) {
56592         var picon = getIcon(d2);
56593         return picon ? "#" + picon : "";
56594       });
56595       var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) {
56596         return zoom >= 18 && getDirections(d2) ? [d2] : [];
56597       }, fastEntityKey);
56598       dgroups.exit().remove();
56599       dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups);
56600       var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) {
56601         return osmEntity.key(d2);
56602       });
56603       viewfields.exit().remove();
56604       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) {
56605         return "rotate(" + d2 + ")";
56606       });
56607     }
56608     function drawTargets(selection2, graph, entities, filter2) {
56609       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56610       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56611       var getTransform = svgPointTransform(projection2).geojson;
56612       var activeID = context.activeID();
56613       var data = { targets: [], nopes: [] };
56614       entities.forEach(function(node) {
56615         if (activeID === node.id)
56616           return;
56617         var vertexType = svgPassiveVertex(node, graph, activeID);
56618         if (vertexType !== 0) {
56619           data.targets.push({
56620             type: "Feature",
56621             id: node.id,
56622             properties: {
56623               target: true,
56624               entity: node
56625             },
56626             geometry: node.asGeoJSON()
56627           });
56628         } else {
56629           data.nopes.push({
56630             type: "Feature",
56631             id: node.id + "-nope",
56632             properties: {
56633               nope: true,
56634               target: true,
56635               entity: node
56636             },
56637             geometry: node.asGeoJSON()
56638           });
56639         }
56640       });
56641       var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) {
56642         return filter2(d2.properties.entity);
56643       }).data(data.targets, function key(d2) {
56644         return d2.id;
56645       });
56646       targets.exit().remove();
56647       targets.enter().append("circle").attr("r", function(d2) {
56648         return _radii[d2.id] || radiuses.shadow[3];
56649       }).merge(targets).attr("class", function(d2) {
56650         return "node vertex target target-allowed " + targetClass + d2.id;
56651       }).attr("transform", getTransform);
56652       var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) {
56653         return filter2(d2.properties.entity);
56654       }).data(data.nopes, function key(d2) {
56655         return d2.id;
56656       });
56657       nopes.exit().remove();
56658       nopes.enter().append("circle").attr("r", function(d2) {
56659         return _radii[d2.properties.entity.id] || radiuses.shadow[3];
56660       }).merge(nopes).attr("class", function(d2) {
56661         return "node vertex target target-nope " + nopeClass + d2.id;
56662       }).attr("transform", getTransform);
56663     }
56664     function renderAsVertex(entity, graph, wireframe, zoom) {
56665       var geometry = entity.geometry(graph);
56666       return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length);
56667     }
56668     function isEditedNode(node, base, head) {
56669       var baseNode = base.entities[node.id];
56670       var headNode = head.entities[node.id];
56671       return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc);
56672     }
56673     function getSiblingAndChildVertices(ids, graph, wireframe, zoom) {
56674       var results = {};
56675       var seenIds = {};
56676       function addChildVertices(entity) {
56677         if (seenIds[entity.id])
56678           return;
56679         seenIds[entity.id] = true;
56680         var geometry = entity.geometry(graph);
56681         if (!context.features().isHiddenFeature(entity, graph, geometry)) {
56682           var i3;
56683           if (entity.type === "way") {
56684             for (i3 = 0; i3 < entity.nodes.length; i3++) {
56685               var child = graph.hasEntity(entity.nodes[i3]);
56686               if (child) {
56687                 addChildVertices(child);
56688               }
56689             }
56690           } else if (entity.type === "relation") {
56691             for (i3 = 0; i3 < entity.members.length; i3++) {
56692               var member = graph.hasEntity(entity.members[i3].id);
56693               if (member) {
56694                 addChildVertices(member);
56695               }
56696             }
56697           } else if (renderAsVertex(entity, graph, wireframe, zoom)) {
56698             results[entity.id] = entity;
56699           }
56700         }
56701       }
56702       ids.forEach(function(id2) {
56703         var entity = graph.hasEntity(id2);
56704         if (!entity)
56705           return;
56706         if (entity.type === "node") {
56707           if (renderAsVertex(entity, graph, wireframe, zoom)) {
56708             results[entity.id] = entity;
56709             graph.parentWays(entity).forEach(function(entity2) {
56710               addChildVertices(entity2);
56711             });
56712           }
56713         } else {
56714           addChildVertices(entity);
56715         }
56716       });
56717       return results;
56718     }
56719     function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) {
56720       var wireframe = context.surface().classed("fill-wireframe");
56721       var visualDiff = context.surface().classed("highlight-edited");
56722       var zoom = geoScaleToZoom(projection2.scale());
56723       var mode = context.mode();
56724       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56725       var base = context.history().base();
56726       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices");
56727       var touchLayer = selection2.selectAll(".layer-touch.points");
56728       if (fullRedraw) {
56729         _currPersistent = {};
56730         _radii = {};
56731       }
56732       for (var i3 = 0; i3 < entities.length; i3++) {
56733         var entity = entities[i3];
56734         var geometry = entity.geometry(graph);
56735         var keep = false;
56736         if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) {
56737           _currPersistent[entity.id] = entity;
56738           keep = true;
56739         } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) {
56740           _currPersistent[entity.id] = entity;
56741           keep = true;
56742         }
56743         if (!keep && !fullRedraw) {
56744           delete _currPersistent[entity.id];
56745         }
56746       }
56747       var sets2 = {
56748         persistent: _currPersistent,
56749         // persistent = important vertices (render always)
56750         selected: _currSelected,
56751         // selected + siblings of selected (render always)
56752         hovered: _currHover
56753         // hovered + siblings of hovered (render only in draw modes)
56754       };
56755       var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent);
56756       var filterRendered = function(d2) {
56757         return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2);
56758       };
56759       drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered);
56760       var filterTouch = function(d2) {
56761         return isMoving ? true : filterRendered(d2);
56762       };
56763       touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch);
56764       function currentVisible(which) {
56765         return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) {
56766           return entity2 && entity2.intersects(extent, graph);
56767         });
56768       }
56769     }
56770     drawVertices.drawSelected = function(selection2, graph, extent) {
56771       var wireframe = context.surface().classed("fill-wireframe");
56772       var zoom = geoScaleToZoom(projection2.scale());
56773       _prevSelected = _currSelected || {};
56774       if (context.map().isInWideSelection()) {
56775         _currSelected = {};
56776         context.selectedIDs().forEach(function(id2) {
56777           var entity = graph.hasEntity(id2);
56778           if (!entity)
56779             return;
56780           if (entity.type === "node") {
56781             if (renderAsVertex(entity, graph, wireframe, zoom)) {
56782               _currSelected[entity.id] = entity;
56783             }
56784           }
56785         });
56786       } else {
56787         _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom);
56788       }
56789       var filter2 = function(d2) {
56790         return d2.id in _prevSelected;
56791       };
56792       drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false);
56793     };
56794     drawVertices.drawHover = function(selection2, graph, target, extent) {
56795       if (target === _currHoverTarget)
56796         return;
56797       var wireframe = context.surface().classed("fill-wireframe");
56798       var zoom = geoScaleToZoom(projection2.scale());
56799       _prevHover = _currHover || {};
56800       _currHoverTarget = target;
56801       var entity = target && target.properties && target.properties.entity;
56802       if (entity) {
56803         _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom);
56804       } else {
56805         _currHover = {};
56806       }
56807       var filter2 = function(d2) {
56808         return d2.id in _prevHover;
56809       };
56810       drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false);
56811     };
56812     return drawVertices;
56813   }
56814
56815   // modules/util/bind_once.js
56816   function utilBindOnce(target, type2, listener, capture) {
56817     var typeOnce = type2 + ".once";
56818     function one2() {
56819       target.on(typeOnce, null);
56820       listener.apply(this, arguments);
56821     }
56822     target.on(typeOnce, one2, capture);
56823     return this;
56824   }
56825
56826   // modules/util/zoom_pan.js
56827   function defaultFilter3(d3_event) {
56828     return !d3_event.ctrlKey && !d3_event.button;
56829   }
56830   function defaultExtent2() {
56831     var e3 = this;
56832     if (e3 instanceof SVGElement) {
56833       e3 = e3.ownerSVGElement || e3;
56834       if (e3.hasAttribute("viewBox")) {
56835         e3 = e3.viewBox.baseVal;
56836         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
56837       }
56838       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
56839     }
56840     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
56841   }
56842   function defaultWheelDelta2(d3_event) {
56843     return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3);
56844   }
56845   function defaultConstrain2(transform2, extent, translateExtent) {
56846     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];
56847     return transform2.translate(
56848       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
56849       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
56850     );
56851   }
56852   function utilZoomPan() {
56853     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;
56854     function zoom(selection2) {
56855       selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
56856       select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup);
56857     }
56858     zoom.transform = function(collection, transform2, point2) {
56859       var selection2 = collection.selection ? collection.selection() : collection;
56860       if (collection !== selection2) {
56861         schedule(collection, transform2, point2);
56862       } else {
56863         selection2.interrupt().each(function() {
56864           gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null);
56865         });
56866       }
56867     };
56868     zoom.scaleBy = function(selection2, k2, p2) {
56869       zoom.scaleTo(selection2, function() {
56870         var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
56871         return k0 * k1;
56872       }, p2);
56873     };
56874     zoom.scaleTo = function(selection2, k2, p2) {
56875       zoom.transform(selection2, function() {
56876         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;
56877         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
56878       }, p2);
56879     };
56880     zoom.translateBy = function(selection2, x2, y2) {
56881       zoom.transform(selection2, function() {
56882         return constrain(_transform.translate(
56883           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
56884           typeof y2 === "function" ? y2.apply(this, arguments) : y2
56885         ), extent.apply(this, arguments), translateExtent);
56886       });
56887     };
56888     zoom.translateTo = function(selection2, x2, y2, p2) {
56889       zoom.transform(selection2, function() {
56890         var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
56891         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
56892           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
56893           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
56894         ), e3, translateExtent);
56895       }, p2);
56896     };
56897     function scale(transform2, k2) {
56898       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
56899       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
56900     }
56901     function translate(transform2, p02, p1) {
56902       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
56903       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
56904     }
56905     function centroid(extent2) {
56906       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
56907     }
56908     function schedule(transition2, transform2, point2) {
56909       transition2.on("start.zoom", function() {
56910         gesture(this, arguments).start(null);
56911       }).on("interrupt.zoom end.zoom", function() {
56912         gesture(this, arguments).end(null);
56913       }).tween("zoom", function() {
56914         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));
56915         return function(t2) {
56916           if (t2 === 1) {
56917             t2 = b2;
56918           } else {
56919             var l2 = i3(t2);
56920             var k2 = w2 / l2[2];
56921             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
56922           }
56923           g3.zoom(null, null, t2);
56924         };
56925       });
56926     }
56927     function gesture(that, args, clean2) {
56928       return !clean2 && _activeGesture || new Gesture(that, args);
56929     }
56930     function Gesture(that, args) {
56931       this.that = that;
56932       this.args = args;
56933       this.active = 0;
56934       this.extent = extent.apply(that, args);
56935     }
56936     Gesture.prototype = {
56937       start: function(d3_event) {
56938         if (++this.active === 1) {
56939           _activeGesture = this;
56940           dispatch14.call("start", this, d3_event);
56941         }
56942         return this;
56943       },
56944       zoom: function(d3_event, key, transform2) {
56945         if (this.mouse && key !== "mouse")
56946           this.mouse[1] = transform2.invert(this.mouse[0]);
56947         if (this.pointer0 && key !== "touch")
56948           this.pointer0[1] = transform2.invert(this.pointer0[0]);
56949         if (this.pointer1 && key !== "touch")
56950           this.pointer1[1] = transform2.invert(this.pointer1[0]);
56951         _transform = transform2;
56952         dispatch14.call("zoom", this, d3_event, key, transform2);
56953         return this;
56954       },
56955       end: function(d3_event) {
56956         if (--this.active === 0) {
56957           _activeGesture = null;
56958           dispatch14.call("end", this, d3_event);
56959         }
56960         return this;
56961       }
56962     };
56963     function wheeled(d3_event) {
56964       if (!filter2.apply(this, arguments))
56965         return;
56966       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);
56967       if (g3.wheel) {
56968         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
56969           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
56970         }
56971         clearTimeout(g3.wheel);
56972       } else {
56973         g3.mouse = [p2, t2.invert(p2)];
56974         interrupt_default(this);
56975         g3.start(d3_event);
56976       }
56977       d3_event.preventDefault();
56978       d3_event.stopImmediatePropagation();
56979       g3.wheel = setTimeout(wheelidled, _wheelDelay);
56980       g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
56981       function wheelidled() {
56982         g3.wheel = null;
56983         g3.end(d3_event);
56984       }
56985     }
56986     var _downPointerIDs = /* @__PURE__ */ new Set();
56987     var _pointerLocGetter;
56988     function pointerdown(d3_event) {
56989       _downPointerIDs.add(d3_event.pointerId);
56990       if (!filter2.apply(this, arguments))
56991         return;
56992       var g3 = gesture(this, arguments, _downPointerIDs.size === 1);
56993       var started;
56994       d3_event.stopImmediatePropagation();
56995       _pointerLocGetter = utilFastMouse(this);
56996       var loc = _pointerLocGetter(d3_event);
56997       var p2 = [loc, _transform.invert(loc), d3_event.pointerId];
56998       if (!g3.pointer0) {
56999         g3.pointer0 = p2;
57000         started = true;
57001       } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) {
57002         g3.pointer1 = p2;
57003       }
57004       if (started) {
57005         interrupt_default(this);
57006         g3.start(d3_event);
57007       }
57008     }
57009     function pointermove(d3_event) {
57010       if (!_downPointerIDs.has(d3_event.pointerId))
57011         return;
57012       if (!_activeGesture || !_pointerLocGetter)
57013         return;
57014       var g3 = gesture(this, arguments);
57015       var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId;
57016       var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId;
57017       if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) {
57018         if (g3.pointer0)
57019           _downPointerIDs.delete(g3.pointer0[2]);
57020         if (g3.pointer1)
57021           _downPointerIDs.delete(g3.pointer1[2]);
57022         g3.end(d3_event);
57023         return;
57024       }
57025       d3_event.preventDefault();
57026       d3_event.stopImmediatePropagation();
57027       var loc = _pointerLocGetter(d3_event);
57028       var t2, p2, l2;
57029       if (isPointer0)
57030         g3.pointer0[0] = loc;
57031       else if (isPointer1)
57032         g3.pointer1[0] = loc;
57033       t2 = _transform;
57034       if (g3.pointer1) {
57035         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;
57036         t2 = scale(t2, Math.sqrt(dp / dl));
57037         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
57038         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
57039       } else if (g3.pointer0) {
57040         p2 = g3.pointer0[0];
57041         l2 = g3.pointer0[1];
57042       } else {
57043         return;
57044       }
57045       g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
57046     }
57047     function pointerup(d3_event) {
57048       if (!_downPointerIDs.has(d3_event.pointerId))
57049         return;
57050       _downPointerIDs.delete(d3_event.pointerId);
57051       if (!_activeGesture)
57052         return;
57053       var g3 = gesture(this, arguments);
57054       d3_event.stopImmediatePropagation();
57055       if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId)
57056         delete g3.pointer0;
57057       else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId)
57058         delete g3.pointer1;
57059       if (g3.pointer1 && !g3.pointer0) {
57060         g3.pointer0 = g3.pointer1;
57061         delete g3.pointer1;
57062       }
57063       if (g3.pointer0) {
57064         g3.pointer0[1] = _transform.invert(g3.pointer0[0]);
57065       } else {
57066         g3.end(d3_event);
57067       }
57068     }
57069     zoom.wheelDelta = function(_2) {
57070       return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta;
57071     };
57072     zoom.filter = function(_2) {
57073       return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2;
57074     };
57075     zoom.extent = function(_2) {
57076       return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
57077     };
57078     zoom.scaleExtent = function(_2) {
57079       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
57080     };
57081     zoom.translateExtent = function(_2) {
57082       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]]];
57083     };
57084     zoom.constrain = function(_2) {
57085       return arguments.length ? (constrain = _2, zoom) : constrain;
57086     };
57087     zoom.interpolate = function(_2) {
57088       return arguments.length ? (interpolate = _2, zoom) : interpolate;
57089     };
57090     zoom._transform = function(_2) {
57091       return arguments.length ? (_transform = _2, zoom) : _transform;
57092     };
57093     return utilRebind(zoom, dispatch14, "on");
57094   }
57095
57096   // modules/util/double_up.js
57097   function utilDoubleUp() {
57098     var dispatch14 = dispatch_default("doubleUp");
57099     var _maxTimespan = 500;
57100     var _maxDistance = 20;
57101     var _pointer;
57102     function pointerIsValidFor(loc) {
57103       return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown
57104       geoVecLength(_pointer.startLoc, loc) <= _maxDistance;
57105     }
57106     function pointerdown(d3_event) {
57107       if (d3_event.ctrlKey || d3_event.button === 2)
57108         return;
57109       var loc = [d3_event.clientX, d3_event.clientY];
57110       if (_pointer && !pointerIsValidFor(loc)) {
57111         _pointer = void 0;
57112       }
57113       if (!_pointer) {
57114         _pointer = {
57115           startLoc: loc,
57116           startTime: (/* @__PURE__ */ new Date()).getTime(),
57117           upCount: 0,
57118           pointerId: d3_event.pointerId
57119         };
57120       } else {
57121         _pointer.pointerId = d3_event.pointerId;
57122       }
57123     }
57124     function pointerup(d3_event) {
57125       if (d3_event.ctrlKey || d3_event.button === 2)
57126         return;
57127       if (!_pointer || _pointer.pointerId !== d3_event.pointerId)
57128         return;
57129       _pointer.upCount += 1;
57130       if (_pointer.upCount === 2) {
57131         var loc = [d3_event.clientX, d3_event.clientY];
57132         if (pointerIsValidFor(loc)) {
57133           var locInThis = utilFastMouse(this)(d3_event);
57134           dispatch14.call("doubleUp", this, d3_event, locInThis);
57135         }
57136         _pointer = void 0;
57137       }
57138     }
57139     function doubleUp(selection2) {
57140       if ("PointerEvent" in window) {
57141         selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup);
57142       } else {
57143         selection2.on("dblclick.doubleUp", function(d3_event) {
57144           dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event));
57145         });
57146       }
57147     }
57148     doubleUp.off = function(selection2) {
57149       selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null);
57150     };
57151     return utilRebind(doubleUp, dispatch14, "on");
57152   }
57153
57154   // modules/renderer/map.js
57155   var TILESIZE = 256;
57156   var minZoom2 = 2;
57157   var maxZoom = 24;
57158   var kMin = geoZoomToScale(minZoom2, TILESIZE);
57159   var kMax = geoZoomToScale(maxZoom, TILESIZE);
57160   function clamp2(num, min3, max3) {
57161     return Math.max(min3, Math.min(num, max3));
57162   }
57163   function rendererMap(context) {
57164     var dispatch14 = dispatch_default(
57165       "move",
57166       "drawn",
57167       "crossEditableZoom",
57168       "hitMinZoom",
57169       "changeHighlighting",
57170       "changeAreaFill"
57171     );
57172     var projection2 = context.projection;
57173     var curtainProjection = context.curtainProjection;
57174     var drawLayers;
57175     var drawPoints;
57176     var drawVertices;
57177     var drawLines;
57178     var drawAreas;
57179     var drawMidpoints;
57180     var drawLabels;
57181     var _selection = select_default2(null);
57182     var supersurface = select_default2(null);
57183     var wrapper = select_default2(null);
57184     var surface = select_default2(null);
57185     var _dimensions = [1, 1];
57186     var _dblClickZoomEnabled = true;
57187     var _redrawEnabled = true;
57188     var _gestureTransformStart;
57189     var _transformStart = projection2.transform();
57190     var _transformLast;
57191     var _isTransformed = false;
57192     var _minzoom = 0;
57193     var _getMouseCoords;
57194     var _lastPointerEvent;
57195     var _lastWithinEditableZoom;
57196     var _pointerDown = false;
57197     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
57198     var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2;
57199     var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) {
57200       _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown");
57201     }).on("end.map", function() {
57202       _pointerDown = false;
57203     });
57204     var _doubleUpHandler = utilDoubleUp();
57205     var scheduleRedraw = throttle_default(redraw, 750);
57206     function cancelPendingRedraw() {
57207       scheduleRedraw.cancel();
57208     }
57209     function map2(selection2) {
57210       _selection = selection2;
57211       context.on("change.map", immediateRedraw);
57212       var osm = context.connection();
57213       if (osm) {
57214         osm.on("change.map", immediateRedraw);
57215       }
57216       function didUndoOrRedo(targetTransform) {
57217         var mode = context.mode().id;
57218         if (mode !== "browse" && mode !== "select")
57219           return;
57220         if (targetTransform) {
57221           map2.transformEase(targetTransform);
57222         }
57223       }
57224       context.history().on("merge.map", function() {
57225         scheduleRedraw();
57226       }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) {
57227         didUndoOrRedo(fromStack.transform);
57228       }).on("redone.map", function(stack) {
57229         didUndoOrRedo(stack.transform);
57230       });
57231       context.background().on("change.map", immediateRedraw);
57232       context.features().on("redraw.map", immediateRedraw);
57233       drawLayers.on("change.map", function() {
57234         context.background().updateImagery();
57235         immediateRedraw();
57236       });
57237       selection2.on("wheel.map mousewheel.map", function(d3_event) {
57238         d3_event.preventDefault();
57239       }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null);
57240       map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0);
57241       wrapper = supersurface.append("div").attr("class", "layer layer-data");
57242       map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface");
57243       surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) {
57244         _lastPointerEvent = d3_event;
57245         if (d3_event.button === 2) {
57246           d3_event.stopPropagation();
57247         }
57248       }, true).on(_pointerPrefix + "up.zoom", function(d3_event) {
57249         _lastPointerEvent = d3_event;
57250         if (resetTransform()) {
57251           immediateRedraw();
57252         }
57253       }).on(_pointerPrefix + "move.map", function(d3_event) {
57254         _lastPointerEvent = d3_event;
57255       }).on(_pointerPrefix + "over.vertices", function(d3_event) {
57256         if (map2.editableDataEnabled() && !_isTransformed) {
57257           var hover = d3_event.target.__data__;
57258           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57259           dispatch14.call("drawn", this, { full: false });
57260         }
57261       }).on(_pointerPrefix + "out.vertices", function(d3_event) {
57262         if (map2.editableDataEnabled() && !_isTransformed) {
57263           var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
57264           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57265           dispatch14.call("drawn", this, { full: false });
57266         }
57267       });
57268       var detected = utilDetect();
57269       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
57270       // but we only need to do this on desktop Safari anyway. – #7694
57271       !detected.isMobileWebKit) {
57272         surface.on("gesturestart.surface", function(d3_event) {
57273           d3_event.preventDefault();
57274           _gestureTransformStart = projection2.transform();
57275         }).on("gesturechange.surface", gestureChange);
57276       }
57277       updateAreaFill();
57278       _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) {
57279         if (!_dblClickZoomEnabled)
57280           return;
57281         if (typeof d3_event.target.__data__ === "object" && // or area fills
57282         !select_default2(d3_event.target).classed("fill"))
57283           return;
57284         var zoomOut2 = d3_event.shiftKey;
57285         var t2 = projection2.transform();
57286         var p1 = t2.invert(p02);
57287         t2 = t2.scale(zoomOut2 ? 0.5 : 2);
57288         t2.x = p02[0] - p1[0] * t2.k;
57289         t2.y = p02[1] - p1[1] * t2.k;
57290         map2.transformEase(t2);
57291       });
57292       context.on("enter.map", function() {
57293         if (!map2.editableDataEnabled(
57294           true
57295           /* skip zoom check */
57296         ))
57297           return;
57298         if (_isTransformed)
57299           return;
57300         var graph = context.graph();
57301         var selectedAndParents = {};
57302         context.selectedIDs().forEach(function(id2) {
57303           var entity = graph.hasEntity(id2);
57304           if (entity) {
57305             selectedAndParents[entity.id] = entity;
57306             if (entity.type === "node") {
57307               graph.parentWays(entity).forEach(function(parent) {
57308                 selectedAndParents[parent.id] = parent;
57309               });
57310             }
57311           }
57312         });
57313         var data = Object.values(selectedAndParents);
57314         var filter2 = function(d2) {
57315           return d2.id in selectedAndParents;
57316         };
57317         data = context.features().filter(data, graph);
57318         surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent());
57319         dispatch14.call("drawn", this, { full: false });
57320         scheduleRedraw();
57321       });
57322       map2.dimensions(utilGetDimensions(selection2));
57323     }
57324     function zoomEventFilter(d3_event) {
57325       if (d3_event.type === "mousedown") {
57326         var hasOrphan = false;
57327         var listeners = window.__on;
57328         for (var i3 = 0; i3 < listeners.length; i3++) {
57329           var listener = listeners[i3];
57330           if (listener.name === "zoom" && listener.type === "mouseup") {
57331             hasOrphan = true;
57332             break;
57333           }
57334         }
57335         if (hasOrphan) {
57336           var event = window.CustomEvent;
57337           if (event) {
57338             event = new event("mouseup");
57339           } else {
57340             event = window.document.createEvent("Event");
57341             event.initEvent("mouseup", false, false);
57342           }
57343           event.view = window;
57344           window.dispatchEvent(event);
57345         }
57346       }
57347       return d3_event.button !== 2;
57348     }
57349     function pxCenter() {
57350       return [_dimensions[0] / 2, _dimensions[1] / 2];
57351     }
57352     function drawEditable(difference2, extent) {
57353       var mode = context.mode();
57354       var graph = context.graph();
57355       var features = context.features();
57356       var all = context.history().intersects(map2.extent());
57357       var fullRedraw = false;
57358       var data;
57359       var set4;
57360       var filter2;
57361       var applyFeatureLayerFilters = true;
57362       if (map2.isInWideSelection()) {
57363         data = [];
57364         utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) {
57365           var entity = context.hasEntity(id2);
57366           if (entity)
57367             data.push(entity);
57368         });
57369         fullRedraw = true;
57370         filter2 = utilFunctor(true);
57371         applyFeatureLayerFilters = false;
57372       } else if (difference2) {
57373         var complete = difference2.complete(map2.extent());
57374         data = Object.values(complete).filter(Boolean);
57375         set4 = new Set(Object.keys(complete));
57376         filter2 = function(d2) {
57377           return set4.has(d2.id);
57378         };
57379         features.clear(data);
57380       } else {
57381         if (features.gatherStats(all, graph, _dimensions)) {
57382           extent = void 0;
57383         }
57384         if (extent) {
57385           data = context.history().intersects(map2.extent().intersection(extent));
57386           set4 = new Set(data.map(function(entity) {
57387             return entity.id;
57388           }));
57389           filter2 = function(d2) {
57390             return set4.has(d2.id);
57391           };
57392         } else {
57393           data = all;
57394           fullRedraw = true;
57395           filter2 = utilFunctor(true);
57396         }
57397       }
57398       if (applyFeatureLayerFilters) {
57399         data = features.filter(data, graph);
57400       } else {
57401         context.features().resetStats();
57402       }
57403       if (mode && mode.id === "select") {
57404         surface.call(drawVertices.drawSelected, graph, map2.extent());
57405       }
57406       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);
57407       dispatch14.call("drawn", this, { full: true });
57408     }
57409     map2.init = function() {
57410       drawLayers = svgLayers(projection2, context);
57411       drawPoints = svgPoints(projection2, context);
57412       drawVertices = svgVertices(projection2, context);
57413       drawLines = svgLines(projection2, context);
57414       drawAreas = svgAreas(projection2, context);
57415       drawMidpoints = svgMidpoints(projection2, context);
57416       drawLabels = svgLabels(projection2, context);
57417     };
57418     function editOff() {
57419       context.features().resetStats();
57420       surface.selectAll(".layer-osm *").remove();
57421       surface.selectAll(".layer-touch:not(.markers) *").remove();
57422       var allowed = {
57423         "browse": true,
57424         "save": true,
57425         "select-note": true,
57426         "select-data": true,
57427         "select-error": true
57428       };
57429       var mode = context.mode();
57430       if (mode && !allowed[mode.id]) {
57431         context.enter(modeBrowse(context));
57432       }
57433       dispatch14.call("drawn", this, { full: true });
57434     }
57435     function gestureChange(d3_event) {
57436       var e3 = d3_event;
57437       e3.preventDefault();
57438       var props = {
57439         deltaMode: 0,
57440         // dummy values to ignore in zoomPan
57441         deltaY: 1,
57442         // dummy values to ignore in zoomPan
57443         clientX: e3.clientX,
57444         clientY: e3.clientY,
57445         screenX: e3.screenX,
57446         screenY: e3.screenY,
57447         x: e3.x,
57448         y: e3.y
57449       };
57450       var e22 = new WheelEvent("wheel", props);
57451       e22._scale = e3.scale;
57452       e22._rotation = e3.rotation;
57453       _selection.node().dispatchEvent(e22);
57454     }
57455     function zoomPan2(event, key, transform2) {
57456       var source = event && event.sourceEvent || event;
57457       var eventTransform = transform2 || event && event.transform;
57458       var x2 = eventTransform.x;
57459       var y2 = eventTransform.y;
57460       var k2 = eventTransform.k;
57461       if (source && source.type === "wheel") {
57462         if (_pointerDown)
57463           return;
57464         var detected = utilDetect();
57465         var dX = source.deltaX;
57466         var dY = source.deltaY;
57467         var x22 = x2;
57468         var y22 = y2;
57469         var k22 = k2;
57470         var t0, p02, p1;
57471         if (source.deltaMode === 1) {
57472           var lines = Math.abs(source.deltaY);
57473           var sign2 = source.deltaY > 0 ? 1 : -1;
57474           dY = sign2 * clamp2(
57475             Math.exp((lines - 1) * 0.75) * 4.000244140625,
57476             4.000244140625,
57477             // min
57478             350.000244140625
57479             // max
57480           );
57481           if (detected.os !== "mac") {
57482             dY *= 5;
57483           }
57484           t0 = _isTransformed ? _transformLast : _transformStart;
57485           p02 = _getMouseCoords(source);
57486           p1 = t0.invert(p02);
57487           k22 = t0.k * Math.pow(2, -dY / 500);
57488           k22 = clamp2(k22, kMin, kMax);
57489           x22 = p02[0] - p1[0] * k22;
57490           y22 = p02[1] - p1[1] * k22;
57491         } else if (source._scale) {
57492           t0 = _gestureTransformStart;
57493           p02 = _getMouseCoords(source);
57494           p1 = t0.invert(p02);
57495           k22 = t0.k * source._scale;
57496           k22 = clamp2(k22, kMin, kMax);
57497           x22 = p02[0] - p1[0] * k22;
57498           y22 = p02[1] - p1[1] * k22;
57499         } else if (source.ctrlKey && !isInteger(dY)) {
57500           dY *= 6;
57501           t0 = _isTransformed ? _transformLast : _transformStart;
57502           p02 = _getMouseCoords(source);
57503           p1 = t0.invert(p02);
57504           k22 = t0.k * Math.pow(2, -dY / 500);
57505           k22 = clamp2(k22, kMin, kMax);
57506           x22 = p02[0] - p1[0] * k22;
57507           y22 = p02[1] - p1[1] * k22;
57508         } else if ((source.altKey || source.shiftKey) && isInteger(dY)) {
57509           t0 = _isTransformed ? _transformLast : _transformStart;
57510           p02 = _getMouseCoords(source);
57511           p1 = t0.invert(p02);
57512           k22 = t0.k * Math.pow(2, -dY / 500);
57513           k22 = clamp2(k22, kMin, kMax);
57514           x22 = p02[0] - p1[0] * k22;
57515           y22 = p02[1] - p1[1] * k22;
57516         } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) {
57517           p1 = projection2.translate();
57518           x22 = p1[0] - dX;
57519           y22 = p1[1] - dY;
57520           k22 = projection2.scale();
57521           k22 = clamp2(k22, kMin, kMax);
57522         }
57523         if (x22 !== x2 || y22 !== y2 || k22 !== k2) {
57524           x2 = x22;
57525           y2 = y22;
57526           k2 = k22;
57527           eventTransform = identity2.translate(x22, y22).scale(k22);
57528           if (_zoomerPanner._transform) {
57529             _zoomerPanner._transform(eventTransform);
57530           } else {
57531             _selection.node().__zoom = eventTransform;
57532           }
57533         }
57534       }
57535       if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) {
57536         return;
57537       }
57538       if (geoScaleToZoom(k2, TILESIZE) < _minzoom) {
57539         surface.interrupt();
57540         dispatch14.call("hitMinZoom", this, map2);
57541         setCenterZoom(map2.center(), context.minEditableZoom(), 0, true);
57542         scheduleRedraw();
57543         dispatch14.call("move", this, map2);
57544         return;
57545       }
57546       projection2.transform(eventTransform);
57547       var withinEditableZoom = map2.withinEditableZoom();
57548       if (_lastWithinEditableZoom !== withinEditableZoom) {
57549         if (_lastWithinEditableZoom !== void 0) {
57550           dispatch14.call("crossEditableZoom", this, withinEditableZoom);
57551         }
57552         _lastWithinEditableZoom = withinEditableZoom;
57553       }
57554       var scale = k2 / _transformStart.k;
57555       var tX = (x2 / scale - _transformStart.x) * scale;
57556       var tY = (y2 / scale - _transformStart.y) * scale;
57557       if (context.inIntro()) {
57558         curtainProjection.transform({
57559           x: x2 - tX,
57560           y: y2 - tY,
57561           k: k2
57562         });
57563       }
57564       if (source) {
57565         _lastPointerEvent = event;
57566       }
57567       _isTransformed = true;
57568       _transformLast = eventTransform;
57569       utilSetTransform(supersurface, tX, tY, scale);
57570       scheduleRedraw();
57571       dispatch14.call("move", this, map2);
57572       function isInteger(val) {
57573         return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
57574       }
57575     }
57576     function resetTransform() {
57577       if (!_isTransformed)
57578         return false;
57579       utilSetTransform(supersurface, 0, 0);
57580       _isTransformed = false;
57581       if (context.inIntro()) {
57582         curtainProjection.transform(projection2.transform());
57583       }
57584       return true;
57585     }
57586     function redraw(difference2, extent) {
57587       if (surface.empty() || !_redrawEnabled)
57588         return;
57589       if (resetTransform()) {
57590         difference2 = extent = void 0;
57591       }
57592       var zoom = map2.zoom();
57593       var z2 = String(~~zoom);
57594       if (surface.attr("data-zoom") !== z2) {
57595         surface.attr("data-zoom", z2);
57596       }
57597       var lat = map2.center()[1];
57598       var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true);
57599       surface.classed("low-zoom", zoom <= lowzoom(lat));
57600       if (!difference2) {
57601         supersurface.call(context.background());
57602         wrapper.call(drawLayers);
57603       }
57604       if (map2.editableDataEnabled() || map2.isInWideSelection()) {
57605         context.loadTiles(projection2);
57606         drawEditable(difference2, extent);
57607       } else {
57608         editOff();
57609       }
57610       _transformStart = projection2.transform();
57611       return map2;
57612     }
57613     var immediateRedraw = function(difference2, extent) {
57614       if (!difference2 && !extent)
57615         cancelPendingRedraw();
57616       redraw(difference2, extent);
57617     };
57618     map2.lastPointerEvent = function() {
57619       return _lastPointerEvent;
57620     };
57621     map2.mouse = function(d3_event) {
57622       var event = d3_event || _lastPointerEvent;
57623       if (event) {
57624         var s2;
57625         while (s2 = event.sourceEvent) {
57626           event = s2;
57627         }
57628         return _getMouseCoords(event);
57629       }
57630       return null;
57631     };
57632     map2.mouseCoordinates = function() {
57633       var coord2 = map2.mouse() || pxCenter();
57634       return projection2.invert(coord2);
57635     };
57636     map2.dblclickZoomEnable = function(val) {
57637       if (!arguments.length)
57638         return _dblClickZoomEnabled;
57639       _dblClickZoomEnabled = val;
57640       return map2;
57641     };
57642     map2.redrawEnable = function(val) {
57643       if (!arguments.length)
57644         return _redrawEnabled;
57645       _redrawEnabled = val;
57646       return map2;
57647     };
57648     map2.isTransformed = function() {
57649       return _isTransformed;
57650     };
57651     function setTransform(t2, duration, force) {
57652       var t3 = projection2.transform();
57653       if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y)
57654         return false;
57655       if (duration) {
57656         _selection.transition().duration(duration).on("start", function() {
57657           map2.startEase();
57658         }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k));
57659       } else {
57660         projection2.transform(t2);
57661         _transformStart = t2;
57662         _selection.call(_zoomerPanner.transform, _transformStart);
57663       }
57664       return true;
57665     }
57666     function setCenterZoom(loc2, z2, duration, force) {
57667       var c2 = map2.center();
57668       var z3 = map2.zoom();
57669       if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force)
57670         return false;
57671       var proj = geoRawMercator().transform(projection2.transform());
57672       var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax);
57673       proj.scale(k2);
57674       var t2 = proj.translate();
57675       var point2 = proj(loc2);
57676       var center = pxCenter();
57677       t2[0] += center[0] - point2[0];
57678       t2[1] += center[1] - point2[1];
57679       return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force);
57680     }
57681     map2.pan = function(delta, duration) {
57682       var t2 = projection2.translate();
57683       var k2 = projection2.scale();
57684       t2[0] += delta[0];
57685       t2[1] += delta[1];
57686       if (duration) {
57687         _selection.transition().duration(duration).on("start", function() {
57688           map2.startEase();
57689         }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2));
57690       } else {
57691         projection2.translate(t2);
57692         _transformStart = projection2.transform();
57693         _selection.call(_zoomerPanner.transform, _transformStart);
57694         dispatch14.call("move", this, map2);
57695         immediateRedraw();
57696       }
57697       return map2;
57698     };
57699     map2.dimensions = function(val) {
57700       if (!arguments.length)
57701         return _dimensions;
57702       _dimensions = val;
57703       drawLayers.dimensions(_dimensions);
57704       context.background().dimensions(_dimensions);
57705       projection2.clipExtent([[0, 0], _dimensions]);
57706       _getMouseCoords = utilFastMouse(supersurface.node());
57707       scheduleRedraw();
57708       return map2;
57709     };
57710     function zoomIn(delta) {
57711       setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true);
57712     }
57713     function zoomOut(delta) {
57714       setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true);
57715     }
57716     map2.zoomIn = function() {
57717       zoomIn(1);
57718     };
57719     map2.zoomInFurther = function() {
57720       zoomIn(4);
57721     };
57722     map2.canZoomIn = function() {
57723       return map2.zoom() < maxZoom;
57724     };
57725     map2.zoomOut = function() {
57726       zoomOut(1);
57727     };
57728     map2.zoomOutFurther = function() {
57729       zoomOut(4);
57730     };
57731     map2.canZoomOut = function() {
57732       return map2.zoom() > minZoom2;
57733     };
57734     map2.center = function(loc2) {
57735       if (!arguments.length) {
57736         return projection2.invert(pxCenter());
57737       }
57738       if (setCenterZoom(loc2, map2.zoom())) {
57739         dispatch14.call("move", this, map2);
57740       }
57741       scheduleRedraw();
57742       return map2;
57743     };
57744     map2.unobscuredCenterZoomEase = function(loc, zoom) {
57745       var offset = map2.unobscuredOffsetPx();
57746       var proj = geoRawMercator().transform(projection2.transform());
57747       proj.scale(geoZoomToScale(zoom, TILESIZE));
57748       var locPx = proj(loc);
57749       var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
57750       var offsetLoc = proj.invert(offsetLocPx);
57751       map2.centerZoomEase(offsetLoc, zoom);
57752     };
57753     map2.unobscuredOffsetPx = function() {
57754       var openPane = context.container().select(".map-panes .map-pane.shown");
57755       if (!openPane.empty()) {
57756         return [openPane.node().offsetWidth / 2, 0];
57757       }
57758       return [0, 0];
57759     };
57760     map2.zoom = function(z2) {
57761       if (!arguments.length) {
57762         return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0);
57763       }
57764       if (z2 < _minzoom) {
57765         surface.interrupt();
57766         dispatch14.call("hitMinZoom", this, map2);
57767         z2 = context.minEditableZoom();
57768       }
57769       if (setCenterZoom(map2.center(), z2)) {
57770         dispatch14.call("move", this, map2);
57771       }
57772       scheduleRedraw();
57773       return map2;
57774     };
57775     map2.centerZoom = function(loc2, z2) {
57776       if (setCenterZoom(loc2, z2)) {
57777         dispatch14.call("move", this, map2);
57778       }
57779       scheduleRedraw();
57780       return map2;
57781     };
57782     map2.zoomTo = function(entity) {
57783       var extent = entity.extent(context.graph());
57784       if (!isFinite(extent.area()))
57785         return map2;
57786       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57787       return map2.centerZoom(extent.center(), z2);
57788     };
57789     map2.centerEase = function(loc2, duration) {
57790       duration = duration || 250;
57791       setCenterZoom(loc2, map2.zoom(), duration);
57792       return map2;
57793     };
57794     map2.zoomEase = function(z2, duration) {
57795       duration = duration || 250;
57796       setCenterZoom(map2.center(), z2, duration, false);
57797       return map2;
57798     };
57799     map2.centerZoomEase = function(loc2, z2, duration) {
57800       duration = duration || 250;
57801       setCenterZoom(loc2, z2, duration, false);
57802       return map2;
57803     };
57804     map2.transformEase = function(t2, duration) {
57805       duration = duration || 250;
57806       setTransform(
57807         t2,
57808         duration,
57809         false
57810         /* don't force */
57811       );
57812       return map2;
57813     };
57814     map2.zoomToEase = function(obj, duration) {
57815       var extent;
57816       if (Array.isArray(obj)) {
57817         obj.forEach(function(entity) {
57818           var entityExtent = entity.extent(context.graph());
57819           if (!extent) {
57820             extent = entityExtent;
57821           } else {
57822             extent = extent.extend(entityExtent);
57823           }
57824         });
57825       } else {
57826         extent = obj.extent(context.graph());
57827       }
57828       if (!isFinite(extent.area()))
57829         return map2;
57830       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57831       return map2.centerZoomEase(extent.center(), z2, duration);
57832     };
57833     map2.startEase = function() {
57834       utilBindOnce(surface, _pointerPrefix + "down.ease", function() {
57835         map2.cancelEase();
57836       });
57837       return map2;
57838     };
57839     map2.cancelEase = function() {
57840       _selection.interrupt();
57841       return map2;
57842     };
57843     map2.extent = function(val) {
57844       if (!arguments.length) {
57845         return new geoExtent(
57846           projection2.invert([0, _dimensions[1]]),
57847           projection2.invert([_dimensions[0], 0])
57848         );
57849       } else {
57850         var extent = geoExtent(val);
57851         map2.centerZoom(extent.center(), map2.extentZoom(extent));
57852       }
57853     };
57854     map2.trimmedExtent = function(val) {
57855       if (!arguments.length) {
57856         var headerY = 71;
57857         var footerY = 30;
57858         var pad2 = 10;
57859         return new geoExtent(
57860           projection2.invert([pad2, _dimensions[1] - footerY - pad2]),
57861           projection2.invert([_dimensions[0] - pad2, headerY + pad2])
57862         );
57863       } else {
57864         var extent = geoExtent(val);
57865         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
57866       }
57867     };
57868     function calcExtentZoom(extent, dim) {
57869       var tl = projection2([extent[0][0], extent[1][1]]);
57870       var br2 = projection2([extent[1][0], extent[0][1]]);
57871       var hFactor = (br2[0] - tl[0]) / dim[0];
57872       var vFactor = (br2[1] - tl[1]) / dim[1];
57873       var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
57874       var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
57875       var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff);
57876       return newZoom;
57877     }
57878     map2.extentZoom = function(val) {
57879       return calcExtentZoom(geoExtent(val), _dimensions);
57880     };
57881     map2.trimmedExtentZoom = function(val) {
57882       var trimY = 120;
57883       var trimX = 40;
57884       var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY];
57885       return calcExtentZoom(geoExtent(val), trimmed);
57886     };
57887     map2.withinEditableZoom = function() {
57888       return map2.zoom() >= context.minEditableZoom();
57889     };
57890     map2.isInWideSelection = function() {
57891       return !map2.withinEditableZoom() && context.selectedIDs().length;
57892     };
57893     map2.editableDataEnabled = function(skipZoomCheck) {
57894       var layer = context.layers().layer("osm");
57895       if (!layer || !layer.enabled())
57896         return false;
57897       return skipZoomCheck || map2.withinEditableZoom();
57898     };
57899     map2.notesEditable = function() {
57900       var layer = context.layers().layer("notes");
57901       if (!layer || !layer.enabled())
57902         return false;
57903       return map2.withinEditableZoom();
57904     };
57905     map2.minzoom = function(val) {
57906       if (!arguments.length)
57907         return _minzoom;
57908       _minzoom = val;
57909       return map2;
57910     };
57911     map2.toggleHighlightEdited = function() {
57912       surface.classed("highlight-edited", !surface.classed("highlight-edited"));
57913       map2.pan([0, 0]);
57914       dispatch14.call("changeHighlighting", this);
57915     };
57916     map2.areaFillOptions = ["wireframe", "partial", "full"];
57917     map2.activeAreaFill = function(val) {
57918       if (!arguments.length)
57919         return corePreferences("area-fill") || "partial";
57920       corePreferences("area-fill", val);
57921       if (val !== "wireframe") {
57922         corePreferences("area-fill-toggle", val);
57923       }
57924       updateAreaFill();
57925       map2.pan([0, 0]);
57926       dispatch14.call("changeAreaFill", this);
57927       return map2;
57928     };
57929     map2.toggleWireframe = function() {
57930       var activeFill = map2.activeAreaFill();
57931       if (activeFill === "wireframe") {
57932         activeFill = corePreferences("area-fill-toggle") || "partial";
57933       } else {
57934         activeFill = "wireframe";
57935       }
57936       map2.activeAreaFill(activeFill);
57937     };
57938     function updateAreaFill() {
57939       var activeFill = map2.activeAreaFill();
57940       map2.areaFillOptions.forEach(function(opt) {
57941         surface.classed("fill-" + opt, Boolean(opt === activeFill));
57942       });
57943     }
57944     map2.layers = () => drawLayers;
57945     map2.doubleUpHandler = function() {
57946       return _doubleUpHandler;
57947     };
57948     return utilRebind(map2, dispatch14, "on");
57949   }
57950
57951   // modules/renderer/photos.js
57952   function rendererPhotos(context) {
57953     var dispatch14 = dispatch_default("change");
57954     var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder"];
57955     var _allPhotoTypes = ["flat", "panoramic"];
57956     var _shownPhotoTypes = _allPhotoTypes.slice();
57957     var _dateFilters = ["fromDate", "toDate"];
57958     var _fromDate;
57959     var _toDate;
57960     var _usernames;
57961     function photos() {
57962     }
57963     function updateStorage() {
57964       if (window.mocha)
57965         return;
57966       var hash = utilStringQs(window.location.hash);
57967       var enabled = context.layers().all().filter(function(d2) {
57968         return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled();
57969       }).map(function(d2) {
57970         return d2.id;
57971       });
57972       if (enabled.length) {
57973         hash.photo_overlay = enabled.join(",");
57974       } else {
57975         delete hash.photo_overlay;
57976       }
57977       window.location.replace("#" + utilQsString(hash, true));
57978     }
57979     photos.overlayLayerIDs = function() {
57980       return _layerIDs;
57981     };
57982     photos.allPhotoTypes = function() {
57983       return _allPhotoTypes;
57984     };
57985     photos.dateFilters = function() {
57986       return _dateFilters;
57987     };
57988     photos.dateFilterValue = function(val) {
57989       return val === _dateFilters[0] ? _fromDate : _toDate;
57990     };
57991     photos.setDateFilter = function(type2, val, updateUrl) {
57992       var date = val && new Date(val);
57993       if (date && !isNaN(date)) {
57994         val = date.toISOString().slice(0, 10);
57995       } else {
57996         val = null;
57997       }
57998       if (type2 === _dateFilters[0]) {
57999         _fromDate = val;
58000         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58001           _toDate = _fromDate;
58002         }
58003       }
58004       if (type2 === _dateFilters[1]) {
58005         _toDate = val;
58006         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58007           _fromDate = _toDate;
58008         }
58009       }
58010       dispatch14.call("change", this);
58011       if (updateUrl) {
58012         var rangeString;
58013         if (_fromDate || _toDate) {
58014           rangeString = (_fromDate || "") + "_" + (_toDate || "");
58015         }
58016         setUrlFilterValue("photo_dates", rangeString);
58017       }
58018     };
58019     photos.setUsernameFilter = function(val, updateUrl) {
58020       if (val && typeof val === "string")
58021         val = val.replace(/;/g, ",").split(",");
58022       if (val) {
58023         val = val.map((d2) => d2.trim()).filter(Boolean);
58024         if (!val.length) {
58025           val = null;
58026         }
58027       }
58028       _usernames = val;
58029       dispatch14.call("change", this);
58030       if (updateUrl) {
58031         var hashString;
58032         if (_usernames) {
58033           hashString = _usernames.join(",");
58034         }
58035         setUrlFilterValue("photo_username", hashString);
58036       }
58037     };
58038     function setUrlFilterValue(property, val) {
58039       if (!window.mocha) {
58040         var hash = utilStringQs(window.location.hash);
58041         if (val) {
58042           if (hash[property] === val)
58043             return;
58044           hash[property] = val;
58045         } else {
58046           if (!(property in hash))
58047             return;
58048           delete hash[property];
58049         }
58050         window.location.replace("#" + utilQsString(hash, true));
58051       }
58052     }
58053     function showsLayer(id2) {
58054       var layer = context.layers().layer(id2);
58055       return layer && layer.supported() && layer.enabled();
58056     }
58057     photos.shouldFilterByDate = function() {
58058       return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder");
58059     };
58060     photos.shouldFilterByPhotoType = function() {
58061       return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder");
58062     };
58063     photos.shouldFilterByUsername = function() {
58064       return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside");
58065     };
58066     photos.showsPhotoType = function(val) {
58067       if (!photos.shouldFilterByPhotoType())
58068         return true;
58069       return _shownPhotoTypes.indexOf(val) !== -1;
58070     };
58071     photos.showsFlat = function() {
58072       return photos.showsPhotoType("flat");
58073     };
58074     photos.showsPanoramic = function() {
58075       return photos.showsPhotoType("panoramic");
58076     };
58077     photos.fromDate = function() {
58078       return _fromDate;
58079     };
58080     photos.toDate = function() {
58081       return _toDate;
58082     };
58083     photos.togglePhotoType = function(val) {
58084       var index = _shownPhotoTypes.indexOf(val);
58085       if (index !== -1) {
58086         _shownPhotoTypes.splice(index, 1);
58087       } else {
58088         _shownPhotoTypes.push(val);
58089       }
58090       dispatch14.call("change", this);
58091       return photos;
58092     };
58093     photos.usernames = function() {
58094       return _usernames;
58095     };
58096     photos.init = function() {
58097       var hash = utilStringQs(window.location.hash);
58098       if (hash.photo_dates) {
58099         var parts = /^(.*)[–_](.*)$/g.exec(hash.photo_dates.trim());
58100         this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false);
58101         this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false);
58102       }
58103       if (hash.photo_username) {
58104         this.setUsernameFilter(hash.photo_username, false);
58105       }
58106       if (hash.photo_overlay) {
58107         var hashOverlayIDs = hash.photo_overlay.replace(/;/g, ",").split(",");
58108         hashOverlayIDs.forEach(function(id2) {
58109           if (id2 === "openstreetcam")
58110             id2 = "kartaview";
58111           var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2);
58112           if (layer2 && !layer2.enabled())
58113             layer2.enabled(true);
58114         });
58115       }
58116       if (hash.photo) {
58117         var photoIds = hash.photo.replace(/;/g, ",").split(",");
58118         var photoId = photoIds.length && photoIds[0].trim();
58119         var results = /(.*)\/(.*)/g.exec(photoId);
58120         if (results && results.length >= 3) {
58121           var serviceId = results[1];
58122           if (serviceId === "openstreetcam")
58123             serviceId = "kartaview";
58124           var photoKey = results[2];
58125           var service = services[serviceId];
58126           if (service && service.ensureViewerLoaded) {
58127             var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId);
58128             if (layer && !layer.enabled())
58129               layer.enabled(true);
58130             var baselineTime = Date.now();
58131             service.on("loadedImages.rendererPhotos", function() {
58132               if (Date.now() - baselineTime > 45e3) {
58133                 service.on("loadedImages.rendererPhotos", null);
58134                 return;
58135               }
58136               if (!service.cachedImage(photoKey))
58137                 return;
58138               service.on("loadedImages.rendererPhotos", null);
58139               service.ensureViewerLoaded(context).then(function() {
58140                 service.selectImage(context, photoKey).showViewer(context);
58141               });
58142             });
58143           }
58144         }
58145       }
58146       context.layers().on("change.rendererPhotos", updateStorage);
58147     };
58148     return utilRebind(photos, dispatch14, "on");
58149   }
58150
58151   // modules/ui/account.js
58152   function uiAccount(context) {
58153     const osm = context.connection();
58154     function updateUserDetails(selection2) {
58155       if (!osm)
58156         return;
58157       if (!osm.authenticated()) {
58158         render(selection2, null);
58159       } else {
58160         osm.userDetails((err, user) => render(selection2, user));
58161       }
58162     }
58163     function render(selection2, user) {
58164       let userInfo = selection2.select(".userInfo");
58165       let loginLogout = selection2.select(".loginLogout");
58166       if (user) {
58167         userInfo.html("").classed("hide", false);
58168         let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
58169         if (user.image_url) {
58170           userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url);
58171         } else {
58172           userLink.call(svgIcon("#iD-icon-avatar", "pre-text light"));
58173         }
58174         userLink.append("span").attr("class", "label").text(user.display_name);
58175         loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => {
58176           e3.preventDefault();
58177           osm.logout();
58178           tryLogout();
58179         });
58180       } else {
58181         userInfo.html("").classed("hide", true);
58182         loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => {
58183           e3.preventDefault();
58184           osm.authenticate();
58185         });
58186       }
58187     }
58188     function tryLogout() {
58189       if (!osm)
58190         return;
58191       const url = osm.getUrlRoot() + "/logout?referer=%2Flogin";
58192       const w2 = 600;
58193       const h2 = 550;
58194       const settings = [
58195         ["width", w2],
58196         ["height", h2],
58197         ["left", window.screen.width / 2 - w2 / 2],
58198         ["top", window.screen.height / 2 - h2 / 2]
58199       ].map((x2) => x2.join("=")).join(",");
58200       window.open(url, "_blank", settings);
58201     }
58202     return function(selection2) {
58203       if (!osm)
58204         return;
58205       selection2.append("li").attr("class", "userInfo").classed("hide", true);
58206       selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#");
58207       osm.on("change.account", () => updateUserDetails(selection2));
58208       updateUserDetails(selection2);
58209     };
58210   }
58211
58212   // modules/ui/attribution.js
58213   function uiAttribution(context) {
58214     let _selection = select_default2(null);
58215     function render(selection2, data, klass) {
58216       let div = selection2.selectAll(".".concat(klass)).data([0]);
58217       div = div.enter().append("div").attr("class", klass).merge(div);
58218       let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id);
58219       attributions.exit().remove();
58220       attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => {
58221         let attribution = select_default2(nodes[i3]);
58222         if (d2.terms_html) {
58223           attribution.html(d2.terms_html);
58224           return;
58225         }
58226         if (d2.terms_url) {
58227           attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank");
58228         }
58229         const sourceID = d2.id.replace(/\./g, "<TX_DOT>");
58230         const terms_text = _t(
58231           "imagery.".concat(sourceID, ".attribution.text"),
58232           { default: d2.terms_text || d2.id || d2.name() }
58233         );
58234         if (d2.icon && !d2.overlay) {
58235           attribution.append("img").attr("class", "source-image").attr("src", d2.icon);
58236         }
58237         attribution.append("span").attr("class", "attribution-text").text(terms_text);
58238       }).merge(attributions);
58239       let copyright = attributions.selectAll(".copyright-notice").data((d2) => {
58240         let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent());
58241         return notice ? [notice] : [];
58242       });
58243       copyright.exit().remove();
58244       copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright);
58245       copyright.text(String);
58246     }
58247     function update() {
58248       let baselayer = context.background().baseLayerSource();
58249       _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution");
58250       const z2 = context.map().zoom();
58251       let overlays = context.background().overlayLayerSources() || [];
58252       _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution");
58253     }
58254     return function(selection2) {
58255       _selection = selection2;
58256       context.background().on("change.attribution", update);
58257       context.map().on("move.attribution", throttle_default(update, 400, { leading: false }));
58258       update();
58259     };
58260   }
58261
58262   // modules/ui/contributors.js
58263   function uiContributors(context) {
58264     var osm = context.connection(), debouncedUpdate = debounce_default(function() {
58265       update();
58266     }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null);
58267     function update() {
58268       if (!osm)
58269         return;
58270       var users = {}, entities = context.history().intersects(context.map().extent());
58271       entities.forEach(function(entity) {
58272         if (entity && entity.user)
58273           users[entity.user] = true;
58274       });
58275       var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit);
58276       wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light"));
58277       var userList = select_default2(document.createElement("span"));
58278       userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) {
58279         return osm.userURL(d2);
58280       }).attr("target", "_blank").text(String);
58281       if (u2.length > limit) {
58282         var count = select_default2(document.createElement("span"));
58283         var othersNum = u2.length - limit + 1;
58284         count.append("a").attr("target", "_blank").attr("href", function() {
58285           return osm.changesetsURL(context.map().center(), context.map().zoom());
58286         }).text(othersNum);
58287         wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } }));
58288       } else {
58289         wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } }));
58290       }
58291       if (!u2.length) {
58292         hidden = true;
58293         wrap2.transition().style("opacity", 0);
58294       } else if (hidden) {
58295         wrap2.transition().style("opacity", 1);
58296       }
58297     }
58298     return function(selection2) {
58299       if (!osm)
58300         return;
58301       wrap2 = selection2;
58302       update();
58303       osm.on("loaded.contributors", debouncedUpdate);
58304       context.map().on("move.contributors", debouncedUpdate);
58305     };
58306   }
58307
58308   // modules/ui/popover.js
58309   var _popoverID = 0;
58310   function uiPopover(klass) {
58311     var _id = _popoverID++;
58312     var _anchorSelection = select_default2(null);
58313     var popover = function(selection2) {
58314       _anchorSelection = selection2;
58315       selection2.each(setup);
58316     };
58317     var _animation = utilFunctor(false);
58318     var _placement = utilFunctor("top");
58319     var _alignment = utilFunctor("center");
58320     var _scrollContainer = utilFunctor(select_default2(null));
58321     var _content;
58322     var _displayType = utilFunctor("");
58323     var _hasArrow = utilFunctor(true);
58324     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
58325     popover.displayType = function(val) {
58326       if (arguments.length) {
58327         _displayType = utilFunctor(val);
58328         return popover;
58329       } else {
58330         return _displayType;
58331       }
58332     };
58333     popover.hasArrow = function(val) {
58334       if (arguments.length) {
58335         _hasArrow = utilFunctor(val);
58336         return popover;
58337       } else {
58338         return _hasArrow;
58339       }
58340     };
58341     popover.placement = function(val) {
58342       if (arguments.length) {
58343         _placement = utilFunctor(val);
58344         return popover;
58345       } else {
58346         return _placement;
58347       }
58348     };
58349     popover.alignment = function(val) {
58350       if (arguments.length) {
58351         _alignment = utilFunctor(val);
58352         return popover;
58353       } else {
58354         return _alignment;
58355       }
58356     };
58357     popover.scrollContainer = function(val) {
58358       if (arguments.length) {
58359         _scrollContainer = utilFunctor(val);
58360         return popover;
58361       } else {
58362         return _scrollContainer;
58363       }
58364     };
58365     popover.content = function(val) {
58366       if (arguments.length) {
58367         _content = val;
58368         return popover;
58369       } else {
58370         return _content;
58371       }
58372     };
58373     popover.isShown = function() {
58374       var popoverSelection = _anchorSelection.select(".popover-" + _id);
58375       return !popoverSelection.empty() && popoverSelection.classed("in");
58376     };
58377     popover.show = function() {
58378       _anchorSelection.each(show);
58379     };
58380     popover.updateContent = function() {
58381       _anchorSelection.each(updateContent);
58382     };
58383     popover.hide = function() {
58384       _anchorSelection.each(hide);
58385     };
58386     popover.toggle = function() {
58387       _anchorSelection.each(toggle);
58388     };
58389     popover.destroy = function(selection2, selector) {
58390       selector = selector || ".popover-" + _id;
58391       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() {
58392         return this.getAttribute("data-original-title") || this.getAttribute("title");
58393       }).attr("data-original-title", null).selectAll(selector).remove();
58394     };
58395     popover.destroyAny = function(selection2) {
58396       selection2.call(popover.destroy, ".popover");
58397     };
58398     function setup() {
58399       var anchor = select_default2(this);
58400       var animate = _animation.apply(this, arguments);
58401       var popoverSelection = anchor.selectAll(".popover-" + _id).data([0]);
58402       var enter = popoverSelection.enter().append("div").attr("class", "popover popover-" + _id + " " + (klass ? klass : "")).classed("arrowed", _hasArrow.apply(this, arguments));
58403       enter.append("div").attr("class", "popover-arrow");
58404       enter.append("div").attr("class", "popover-inner");
58405       popoverSelection = enter.merge(popoverSelection);
58406       if (animate) {
58407         popoverSelection.classed("fade", true);
58408       }
58409       var display = _displayType.apply(this, arguments);
58410       if (display === "hover") {
58411         var _lastNonMouseEnterTime;
58412         anchor.on(_pointerPrefix + "enter.popover", function(d3_event) {
58413           if (d3_event.pointerType) {
58414             if (d3_event.pointerType !== "mouse") {
58415               _lastNonMouseEnterTime = d3_event.timeStamp;
58416               return;
58417             } else if (_lastNonMouseEnterTime && d3_event.timeStamp - _lastNonMouseEnterTime < 1500) {
58418               return;
58419             }
58420           }
58421           if (d3_event.buttons !== 0)
58422             return;
58423           show.apply(this, arguments);
58424         }).on(_pointerPrefix + "leave.popover", function() {
58425           hide.apply(this, arguments);
58426         }).on("focus.popover", function() {
58427           show.apply(this, arguments);
58428         }).on("blur.popover", function() {
58429           hide.apply(this, arguments);
58430         });
58431       } else if (display === "clickFocus") {
58432         anchor.on(_pointerPrefix + "down.popover", function(d3_event) {
58433           d3_event.preventDefault();
58434           d3_event.stopPropagation();
58435         }).on(_pointerPrefix + "up.popover", function(d3_event) {
58436           d3_event.preventDefault();
58437           d3_event.stopPropagation();
58438         }).on("click.popover", toggle);
58439         popoverSelection.attr("tabindex", 0).on("blur.popover", function() {
58440           anchor.each(function() {
58441             hide.apply(this, arguments);
58442           });
58443         });
58444       }
58445     }
58446     function show() {
58447       var anchor = select_default2(this);
58448       var popoverSelection = anchor.selectAll(".popover-" + _id);
58449       if (popoverSelection.empty()) {
58450         anchor.call(popover.destroy);
58451         anchor.each(setup);
58452         popoverSelection = anchor.selectAll(".popover-" + _id);
58453       }
58454       popoverSelection.classed("in", true);
58455       var displayType = _displayType.apply(this, arguments);
58456       if (displayType === "clickFocus") {
58457         anchor.classed("active", true);
58458         popoverSelection.node().focus();
58459       }
58460       anchor.each(updateContent);
58461     }
58462     function updateContent() {
58463       var anchor = select_default2(this);
58464       if (_content) {
58465         anchor.selectAll(".popover-" + _id + " > .popover-inner").call(_content.apply(this, arguments));
58466       }
58467       updatePosition.apply(this, arguments);
58468       updatePosition.apply(this, arguments);
58469       updatePosition.apply(this, arguments);
58470     }
58471     function updatePosition() {
58472       var anchor = select_default2(this);
58473       var popoverSelection = anchor.selectAll(".popover-" + _id);
58474       var scrollContainer = _scrollContainer && _scrollContainer.apply(this, arguments);
58475       var scrollNode = scrollContainer && !scrollContainer.empty() && scrollContainer.node();
58476       var scrollLeft = scrollNode ? scrollNode.scrollLeft : 0;
58477       var scrollTop = scrollNode ? scrollNode.scrollTop : 0;
58478       var placement = _placement.apply(this, arguments);
58479       popoverSelection.classed("left", false).classed("right", false).classed("top", false).classed("bottom", false).classed(placement, true);
58480       var alignment = _alignment.apply(this, arguments);
58481       var alignFactor = 0.5;
58482       if (alignment === "leading") {
58483         alignFactor = 0;
58484       } else if (alignment === "trailing") {
58485         alignFactor = 1;
58486       }
58487       var anchorFrame = getFrame(anchor.node());
58488       var popoverFrame = getFrame(popoverSelection.node());
58489       var position;
58490       switch (placement) {
58491         case "top":
58492           position = {
58493             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58494             y: anchorFrame.y - popoverFrame.h
58495           };
58496           break;
58497         case "bottom":
58498           position = {
58499             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58500             y: anchorFrame.y + anchorFrame.h
58501           };
58502           break;
58503         case "left":
58504           position = {
58505             x: anchorFrame.x - popoverFrame.w,
58506             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58507           };
58508           break;
58509         case "right":
58510           position = {
58511             x: anchorFrame.x + anchorFrame.w,
58512             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58513           };
58514           break;
58515       }
58516       if (position) {
58517         if (scrollNode && (placement === "top" || placement === "bottom")) {
58518           var initialPosX = position.x;
58519           if (position.x + popoverFrame.w > scrollNode.offsetWidth - 10) {
58520             position.x = scrollNode.offsetWidth - 10 - popoverFrame.w;
58521           } else if (position.x < 10) {
58522             position.x = 10;
58523           }
58524           var arrow = anchor.selectAll(".popover-" + _id + " > .popover-arrow");
58525           var arrowPosX = Math.min(Math.max(popoverFrame.w / 2 - (position.x - initialPosX), 10), popoverFrame.w - 10);
58526           arrow.style("left", ~~arrowPosX + "px");
58527         }
58528         popoverSelection.style("left", ~~position.x + "px").style("top", ~~position.y + "px");
58529       } else {
58530         popoverSelection.style("left", null).style("top", null);
58531       }
58532       function getFrame(node) {
58533         var positionStyle = select_default2(node).style("position");
58534         if (positionStyle === "absolute" || positionStyle === "static") {
58535           return {
58536             x: node.offsetLeft - scrollLeft,
58537             y: node.offsetTop - scrollTop,
58538             w: node.offsetWidth,
58539             h: node.offsetHeight
58540           };
58541         } else {
58542           return {
58543             x: 0,
58544             y: 0,
58545             w: node.offsetWidth,
58546             h: node.offsetHeight
58547           };
58548         }
58549       }
58550     }
58551     function hide() {
58552       var anchor = select_default2(this);
58553       if (_displayType.apply(this, arguments) === "clickFocus") {
58554         anchor.classed("active", false);
58555       }
58556       anchor.selectAll(".popover-" + _id).classed("in", false);
58557     }
58558     function toggle() {
58559       if (select_default2(this).select(".popover-" + _id).classed("in")) {
58560         hide.apply(this, arguments);
58561       } else {
58562         show.apply(this, arguments);
58563       }
58564     }
58565     return popover;
58566   }
58567
58568   // modules/ui/tooltip.js
58569   function uiTooltip(klass) {
58570     var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover");
58571     var _title = function() {
58572       var title = this.getAttribute("data-original-title");
58573       if (title) {
58574         return title;
58575       } else {
58576         title = this.getAttribute("title");
58577         this.removeAttribute("title");
58578         this.setAttribute("data-original-title", title);
58579       }
58580       return title;
58581     };
58582     var _heading = utilFunctor(null);
58583     var _keys = utilFunctor(null);
58584     tooltip.title = function(val) {
58585       if (!arguments.length)
58586         return _title;
58587       _title = utilFunctor(val);
58588       return tooltip;
58589     };
58590     tooltip.heading = function(val) {
58591       if (!arguments.length)
58592         return _heading;
58593       _heading = utilFunctor(val);
58594       return tooltip;
58595     };
58596     tooltip.keys = function(val) {
58597       if (!arguments.length)
58598         return _keys;
58599       _keys = utilFunctor(val);
58600       return tooltip;
58601     };
58602     tooltip.content(function() {
58603       var heading2 = _heading.apply(this, arguments);
58604       var text = _title.apply(this, arguments);
58605       var keys2 = _keys.apply(this, arguments);
58606       var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2);
58607       var textCallback = typeof text === "function" ? text : (s2) => s2.text(text);
58608       return function(selection2) {
58609         var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []);
58610         headingSelect.exit().remove();
58611         headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback);
58612         var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []);
58613         textSelect.exit().remove();
58614         textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback);
58615         var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []);
58616         keyhintWrap.exit().remove();
58617         var keyhintWrapEnter = keyhintWrap.enter().append("div").attr("class", "keyhint-wrap");
58618         keyhintWrapEnter.append("span").call(_t.append("tooltip_keyhint"));
58619         keyhintWrap = keyhintWrapEnter.merge(keyhintWrap);
58620         keyhintWrap.selectAll("kbd.shortcut").data(keys2 && keys2.length ? keys2 : []).enter().append("kbd").attr("class", "shortcut").text(function(d2) {
58621           return d2;
58622         });
58623       };
58624     });
58625     return tooltip;
58626   }
58627
58628   // modules/ui/edit_menu.js
58629   function uiEditMenu(context) {
58630     var dispatch14 = dispatch_default("toggled");
58631     var _menu = select_default2(null);
58632     var _operations = [];
58633     var _anchorLoc = [0, 0];
58634     var _anchorLocLonLat = [0, 0];
58635     var _triggerType = "";
58636     var _vpTopMargin = 85;
58637     var _vpBottomMargin = 45;
58638     var _vpSideMargin = 35;
58639     var _menuTop = false;
58640     var _menuHeight;
58641     var _menuWidth;
58642     var _verticalPadding = 4;
58643     var _tooltipWidth = 210;
58644     var _menuSideMargin = 10;
58645     var _tooltips = [];
58646     var editMenu = function(selection2) {
58647       var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen");
58648       var ops = _operations.filter(function(op) {
58649         return !isTouchMenu || !op.mouseOnly;
58650       });
58651       if (!ops.length)
58652         return;
58653       _tooltips = [];
58654       _menuTop = isTouchMenu;
58655       var showLabels = isTouchMenu;
58656       var buttonHeight = showLabels ? 32 : 34;
58657       if (showLabels) {
58658         _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) {
58659           return op.title.length;
58660         })));
58661       } else {
58662         _menuWidth = 44;
58663       }
58664       _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight;
58665       _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0");
58666       var buttons = _menu.selectAll(".edit-menu-item").data(ops);
58667       var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
58668         return "edit-menu-item edit-menu-item-" + d2.id;
58669       }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) {
58670         d3_event.stopPropagation();
58671       }).on("mouseenter.highlight", function(d3_event, d2) {
58672         if (!d2.relatedEntityIds || select_default2(this).classed("disabled"))
58673           return;
58674         utilHighlightEntities(d2.relatedEntityIds(), true, context);
58675       }).on("mouseleave.highlight", function(d3_event, d2) {
58676         if (!d2.relatedEntityIds)
58677           return;
58678         utilHighlightEntities(d2.relatedEntityIds(), false, context);
58679       });
58680       buttonsEnter.each(function(d2) {
58681         var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]);
58682         _tooltips.push(tooltip);
58683         select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation"));
58684       });
58685       if (showLabels) {
58686         buttonsEnter.append("span").attr("class", "label").each(function(d2) {
58687           select_default2(this).call(d2.title);
58688         });
58689       }
58690       buttonsEnter.merge(buttons).classed("disabled", function(d2) {
58691         return d2.disabled();
58692       });
58693       updatePosition();
58694       var initialScale = context.projection.scale();
58695       context.map().on("move.edit-menu", function() {
58696         if (initialScale !== context.projection.scale()) {
58697           editMenu.close();
58698         }
58699       }).on("drawn.edit-menu", function(info) {
58700         if (info.full)
58701           updatePosition();
58702       });
58703       var lastPointerUpType;
58704       function pointerup(d3_event) {
58705         lastPointerUpType = d3_event.pointerType;
58706       }
58707       function click(d3_event, operation2) {
58708         d3_event.stopPropagation();
58709         if (operation2.relatedEntityIds) {
58710           utilHighlightEntities(operation2.relatedEntityIds(), false, context);
58711         }
58712         if (operation2.disabled()) {
58713           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58714             context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())();
58715           }
58716         } else {
58717           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58718             context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)();
58719           }
58720           operation2();
58721           editMenu.close();
58722         }
58723         lastPointerUpType = null;
58724       }
58725       dispatch14.call("toggled", this, true);
58726     };
58727     function updatePosition() {
58728       if (!_menu || _menu.empty())
58729         return;
58730       var anchorLoc = context.projection(_anchorLocLonLat);
58731       var viewport = context.surfaceRect();
58732       if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) {
58733         editMenu.close();
58734         return;
58735       }
58736       var menuLeft = displayOnLeft(viewport);
58737       var offset = [0, 0];
58738       offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin;
58739       if (_menuTop) {
58740         if (anchorLoc[1] - _menuHeight < _vpTopMargin) {
58741           offset[1] = -anchorLoc[1] + _vpTopMargin;
58742         } else {
58743           offset[1] = -_menuHeight;
58744         }
58745       } else {
58746         if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) {
58747           offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin;
58748         } else {
58749           offset[1] = 0;
58750         }
58751       }
58752       var origin = geoVecAdd(anchorLoc, offset);
58753       _menu.style("left", origin[0] + "px").style("top", origin[1] + "px");
58754       var tooltipSide = tooltipPosition(viewport, menuLeft);
58755       _tooltips.forEach(function(tooltip) {
58756         tooltip.placement(tooltipSide);
58757       });
58758       function displayOnLeft(viewport2) {
58759         if (_mainLocalizer.textDirection() === "ltr") {
58760           if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) {
58761             return true;
58762           }
58763           return false;
58764         } else {
58765           if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) {
58766             return false;
58767           }
58768           return true;
58769         }
58770       }
58771       function tooltipPosition(viewport2, menuLeft2) {
58772         if (_mainLocalizer.textDirection() === "ltr") {
58773           if (menuLeft2) {
58774             return "left";
58775           }
58776           if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) {
58777             return "left";
58778           }
58779           return "right";
58780         } else {
58781           if (!menuLeft2) {
58782             return "right";
58783           }
58784           if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) {
58785             return "right";
58786           }
58787           return "left";
58788         }
58789       }
58790     }
58791     editMenu.close = function() {
58792       context.map().on("move.edit-menu", null).on("drawn.edit-menu", null);
58793       _menu.remove();
58794       _tooltips = [];
58795       dispatch14.call("toggled", this, false);
58796     };
58797     editMenu.anchorLoc = function(val) {
58798       if (!arguments.length)
58799         return _anchorLoc;
58800       _anchorLoc = val;
58801       _anchorLocLonLat = context.projection.invert(_anchorLoc);
58802       return editMenu;
58803     };
58804     editMenu.triggerType = function(val) {
58805       if (!arguments.length)
58806         return _triggerType;
58807       _triggerType = val;
58808       return editMenu;
58809     };
58810     editMenu.operations = function(val) {
58811       if (!arguments.length)
58812         return _operations;
58813       _operations = val;
58814       return editMenu;
58815     };
58816     return utilRebind(editMenu, dispatch14, "on");
58817   }
58818
58819   // modules/ui/feature_info.js
58820   function uiFeatureInfo(context) {
58821     function update(selection2) {
58822       var features = context.features();
58823       var stats = features.stats();
58824       var count = 0;
58825       var hiddenList = features.hidden().map(function(k2) {
58826         if (stats[k2]) {
58827           count += stats[k2];
58828           return _t.append("inspector.title_count", {
58829             title: _t("feature." + k2 + ".description"),
58830             count: stats[k2]
58831           });
58832         }
58833         return null;
58834       }).filter(Boolean);
58835       selection2.text("");
58836       if (hiddenList.length) {
58837         var tooltipBehavior = uiTooltip().placement("top").title(function() {
58838           return (selection3) => {
58839             hiddenList.forEach((hiddenFeature) => {
58840               selection3.append("div").call(hiddenFeature);
58841             });
58842           };
58843         });
58844         selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) {
58845           tooltipBehavior.hide();
58846           d3_event.preventDefault();
58847           context.ui().togglePanes(context.container().select(".map-panes .map-data-pane"));
58848         });
58849       }
58850       selection2.classed("hide", !hiddenList.length);
58851     }
58852     return function(selection2) {
58853       update(selection2);
58854       context.features().on("change.feature_info", function() {
58855         update(selection2);
58856       });
58857     };
58858   }
58859
58860   // modules/ui/flash.js
58861   function uiFlash(context) {
58862     var _flashTimer;
58863     var _duration = 2e3;
58864     var _iconName = "#iD-icon-no";
58865     var _iconClass = "disabled";
58866     var _label = (s2) => s2.text("");
58867     function flash() {
58868       if (_flashTimer) {
58869         _flashTimer.stop();
58870       }
58871       context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false);
58872       context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true);
58873       var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]);
58874       var contentEnter = content.enter().append("div").attr("class", "flash-content");
58875       var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)");
58876       iconEnter.append("circle").attr("r", 9);
58877       iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14");
58878       contentEnter.append("div").attr("class", "flash-text");
58879       content = content.merge(contentEnter);
58880       content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || ""));
58881       content.selectAll(".flash-icon use").attr("xlink:href", _iconName);
58882       content.selectAll(".flash-text").attr("class", "flash-text").call(_label);
58883       _flashTimer = timeout_default(function() {
58884         _flashTimer = null;
58885         context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true);
58886         context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false);
58887       }, _duration);
58888       return content;
58889     }
58890     flash.duration = function(_2) {
58891       if (!arguments.length)
58892         return _duration;
58893       _duration = _2;
58894       return flash;
58895     };
58896     flash.label = function(_2) {
58897       if (!arguments.length)
58898         return _label;
58899       if (typeof _2 !== "function") {
58900         _label = (selection2) => selection2.text(_2);
58901       } else {
58902         _label = (selection2) => selection2.text("").call(_2);
58903       }
58904       return flash;
58905     };
58906     flash.iconName = function(_2) {
58907       if (!arguments.length)
58908         return _iconName;
58909       _iconName = _2;
58910       return flash;
58911     };
58912     flash.iconClass = function(_2) {
58913       if (!arguments.length)
58914         return _iconClass;
58915       _iconClass = _2;
58916       return flash;
58917     };
58918     return flash;
58919   }
58920
58921   // modules/ui/full_screen.js
58922   function uiFullScreen(context) {
58923     var element = context.container().node();
58924     function getFullScreenFn() {
58925       if (element.requestFullscreen) {
58926         return element.requestFullscreen;
58927       } else if (element.msRequestFullscreen) {
58928         return element.msRequestFullscreen;
58929       } else if (element.mozRequestFullScreen) {
58930         return element.mozRequestFullScreen;
58931       } else if (element.webkitRequestFullscreen) {
58932         return element.webkitRequestFullscreen;
58933       }
58934     }
58935     function getExitFullScreenFn() {
58936       if (document.exitFullscreen) {
58937         return document.exitFullscreen;
58938       } else if (document.msExitFullscreen) {
58939         return document.msExitFullscreen;
58940       } else if (document.mozCancelFullScreen) {
58941         return document.mozCancelFullScreen;
58942       } else if (document.webkitExitFullscreen) {
58943         return document.webkitExitFullscreen;
58944       }
58945     }
58946     function isFullScreen() {
58947       return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
58948     }
58949     function isSupported() {
58950       return !!getFullScreenFn();
58951     }
58952     function fullScreen(d3_event) {
58953       d3_event.preventDefault();
58954       if (!isFullScreen()) {
58955         getFullScreenFn().apply(element);
58956       } else {
58957         getExitFullScreenFn().apply(document);
58958       }
58959     }
58960     return function() {
58961       if (!isSupported())
58962         return;
58963       var detected = utilDetect();
58964       var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"];
58965       context.keybinding().on(keys2, fullScreen);
58966     };
58967   }
58968
58969   // modules/ui/geolocate.js
58970   function uiGeolocate(context) {
58971     var _geolocationOptions = {
58972       // prioritize speed and power usage over precision
58973       enableHighAccuracy: false,
58974       // don't hang indefinitely getting the location
58975       timeout: 6e3
58976       // 6sec
58977     };
58978     var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true);
58979     var _layer = context.layers().layer("geolocate");
58980     var _position;
58981     var _extent;
58982     var _timeoutID;
58983     var _button = select_default2(null);
58984     function click() {
58985       if (context.inIntro())
58986         return;
58987       if (!_layer.enabled() && !_locating.isShown()) {
58988         _timeoutID = setTimeout(
58989           error,
58990           1e4
58991           /* 10sec */
58992         );
58993         context.container().call(_locating);
58994         navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions);
58995       } else {
58996         _locating.close();
58997         _layer.enabled(null, false);
58998         updateButtonState();
58999       }
59000     }
59001     function zoomTo() {
59002       context.enter(modeBrowse(context));
59003       var map2 = context.map();
59004       _layer.enabled(_position, true);
59005       updateButtonState();
59006       map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent)));
59007     }
59008     function success(geolocation) {
59009       _position = geolocation;
59010       var coords = _position.coords;
59011       _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy);
59012       zoomTo();
59013       finish();
59014     }
59015     function error() {
59016       if (_position) {
59017         zoomTo();
59018       } else {
59019         context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")();
59020       }
59021       finish();
59022     }
59023     function finish() {
59024       _locating.close();
59025       if (_timeoutID) {
59026         clearTimeout(_timeoutID);
59027       }
59028       _timeoutID = void 0;
59029     }
59030     function updateButtonState() {
59031       _button.classed("active", _layer.enabled());
59032       _button.attr("aria-pressed", _layer.enabled());
59033     }
59034     return function(selection2) {
59035       if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition)
59036         return;
59037       _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call(
59038         uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title")).keys([_t("geolocate.key")])
59039       );
59040       context.keybinding().on(_t("geolocate.key"), click);
59041     };
59042   }
59043
59044   // modules/ui/panels/background.js
59045   function uiPanelBackground(context) {
59046     var background = context.background();
59047     var _currSourceName = null;
59048     var _metadata = {};
59049     var _metadataKeys = [
59050       "zoom",
59051       "vintage",
59052       "source",
59053       "description",
59054       "resolution",
59055       "accuracy"
59056     ];
59057     var debouncedRedraw = debounce_default(redraw, 250);
59058     function redraw(selection2) {
59059       var source = background.baseLayerSource();
59060       if (!source)
59061         return;
59062       var isDG = source.id.match(/^DigitalGlobe/i) !== null;
59063       var sourceLabel = source.label();
59064       if (_currSourceName !== sourceLabel) {
59065         _currSourceName = sourceLabel;
59066         _metadata = {};
59067       }
59068       selection2.text("");
59069       var list2 = selection2.append("ul").attr("class", "background-info");
59070       list2.append("li").call(_currSourceName);
59071       _metadataKeys.forEach(function(k2) {
59072         if (isDG && k2 === "vintage")
59073           return;
59074         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]);
59075       });
59076       debouncedGetMetadata(selection2);
59077       var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles";
59078       selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) {
59079         d3_event.preventDefault();
59080         context.setDebug("tile", !context.getDebug("tile"));
59081         selection2.call(redraw);
59082       });
59083       if (isDG) {
59084         var key = source.id + "-vintage";
59085         var sourceVintage = context.background().findSource(key);
59086         var showsVintage = context.background().showsLayer(sourceVintage);
59087         var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage";
59088         selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) {
59089           d3_event.preventDefault();
59090           context.background().toggleOverlayLayer(sourceVintage);
59091           selection2.call(redraw);
59092         });
59093       }
59094       ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) {
59095         if (source.id !== layerId) {
59096           var key2 = layerId + "-vintage";
59097           var sourceVintage2 = context.background().findSource(key2);
59098           if (context.background().showsLayer(sourceVintage2)) {
59099             context.background().toggleOverlayLayer(sourceVintage2);
59100           }
59101         }
59102       });
59103     }
59104     var debouncedGetMetadata = debounce_default(getMetadata, 250);
59105     function getMetadata(selection2) {
59106       var tile = context.container().select(".layer-background img.tile-center");
59107       if (tile.empty())
59108         return;
59109       var sourceName = _currSourceName;
59110       var d2 = tile.datum();
59111       var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom());
59112       var center = context.map().center();
59113       _metadata.zoom = String(zoom);
59114       selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom);
59115       if (!d2 || !d2.length >= 3)
59116         return;
59117       background.baseLayerSource().getMetadata(center, d2, function(err, result) {
59118         if (err || _currSourceName !== sourceName)
59119           return;
59120         var vintage = result.vintage;
59121         _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown");
59122         selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage);
59123         _metadataKeys.forEach(function(k2) {
59124           if (k2 === "zoom" || k2 === "vintage")
59125             return;
59126           var val = result[k2];
59127           _metadata[k2] = val;
59128           selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val);
59129         });
59130       });
59131     }
59132     var panel = function(selection2) {
59133       selection2.call(redraw);
59134       context.map().on("drawn.info-background", function() {
59135         selection2.call(debouncedRedraw);
59136       }).on("move.info-background", function() {
59137         selection2.call(debouncedGetMetadata);
59138       });
59139     };
59140     panel.off = function() {
59141       context.map().on("drawn.info-background", null).on("move.info-background", null);
59142     };
59143     panel.id = "background";
59144     panel.label = _t.append("info_panels.background.title");
59145     panel.key = _t("info_panels.background.key");
59146     return panel;
59147   }
59148
59149   // modules/ui/panels/history.js
59150   function uiPanelHistory(context) {
59151     var osm;
59152     function displayTimestamp(timestamp) {
59153       if (!timestamp)
59154         return _t("info_panels.history.unknown");
59155       var options2 = {
59156         day: "numeric",
59157         month: "short",
59158         year: "numeric",
59159         hour: "numeric",
59160         minute: "numeric",
59161         second: "numeric"
59162       };
59163       var d2 = new Date(timestamp);
59164       if (isNaN(d2.getTime()))
59165         return _t("info_panels.history.unknown");
59166       return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
59167     }
59168     function displayUser(selection2, userName) {
59169       if (!userName) {
59170         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59171         return;
59172       }
59173       selection2.append("span").attr("class", "user-name").text(userName);
59174       var links = selection2.append("div").attr("class", "links");
59175       if (osm) {
59176         links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link"));
59177       }
59178       links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC");
59179     }
59180     function displayChangeset(selection2, changeset) {
59181       if (!changeset) {
59182         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59183         return;
59184       }
59185       selection2.append("span").attr("class", "changeset-id").text(changeset);
59186       var links = selection2.append("div").attr("class", "links");
59187       if (osm) {
59188         links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link"));
59189       }
59190       links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha");
59191       links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi");
59192     }
59193     function redraw(selection2) {
59194       var selectedNoteID = context.selectedNoteID();
59195       osm = context.connection();
59196       var selected, note, entity;
59197       if (selectedNoteID && osm) {
59198         selected = [_t.html("note.note") + " " + selectedNoteID];
59199         note = osm.getNote(selectedNoteID);
59200       } else {
59201         selected = context.selectedIDs().filter(function(e3) {
59202           return context.hasEntity(e3);
59203         });
59204         if (selected.length) {
59205           entity = context.entity(selected[0]);
59206         }
59207       }
59208       var singular = selected.length === 1 ? selected[0] : null;
59209       selection2.html("");
59210       if (singular) {
59211         selection2.append("h4").attr("class", "history-heading").html(singular);
59212       } else {
59213         selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length }));
59214       }
59215       if (!singular)
59216         return;
59217       if (entity) {
59218         selection2.call(redrawEntity, entity);
59219       } else if (note) {
59220         selection2.call(redrawNote, note);
59221       }
59222     }
59223     function redrawNote(selection2, note) {
59224       if (!note || note.isNew()) {
59225         selection2.append("div").call(_t.append("info_panels.history.note_no_history"));
59226         return;
59227       }
59228       var list2 = selection2.append("ul");
59229       list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length);
59230       if (note.comments.length) {
59231         list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date));
59232         list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user);
59233       }
59234       if (osm) {
59235         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"));
59236       }
59237     }
59238     function redrawEntity(selection2, entity) {
59239       if (!entity || entity.isNew()) {
59240         selection2.append("div").call(_t.append("info_panels.history.no_history"));
59241         return;
59242       }
59243       var links = selection2.append("div").attr("class", "links");
59244       if (osm) {
59245         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"));
59246       }
59247       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");
59248       var list2 = selection2.append("ul");
59249       list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version);
59250       list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp));
59251       list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user);
59252       list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset);
59253     }
59254     var panel = function(selection2) {
59255       selection2.call(redraw);
59256       context.map().on("drawn.info-history", function() {
59257         selection2.call(redraw);
59258       });
59259       context.on("enter.info-history", function() {
59260         selection2.call(redraw);
59261       });
59262     };
59263     panel.off = function() {
59264       context.map().on("drawn.info-history", null);
59265       context.on("enter.info-history", null);
59266     };
59267     panel.id = "history";
59268     panel.label = _t.append("info_panels.history.title");
59269     panel.key = _t("info_panels.history.key");
59270     return panel;
59271   }
59272
59273   // modules/ui/panels/location.js
59274   function uiPanelLocation(context) {
59275     var currLocation = "";
59276     function redraw(selection2) {
59277       selection2.html("");
59278       var list2 = selection2.append("ul");
59279       var coord2 = context.map().mouseCoordinates();
59280       if (coord2.some(isNaN)) {
59281         coord2 = context.map().center();
59282       }
59283       list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2));
59284       selection2.append("div").attr("class", "location-info").text(currLocation || " ");
59285       debouncedGetLocation(selection2, coord2);
59286     }
59287     var debouncedGetLocation = debounce_default(getLocation, 250);
59288     function getLocation(selection2, coord2) {
59289       if (!services.geocoder) {
59290         currLocation = _t("info_panels.location.unknown_location");
59291         selection2.selectAll(".location-info").text(currLocation);
59292       } else {
59293         services.geocoder.reverse(coord2, function(err, result) {
59294           currLocation = result ? result.display_name : _t("info_panels.location.unknown_location");
59295           selection2.selectAll(".location-info").text(currLocation);
59296         });
59297       }
59298     }
59299     var panel = function(selection2) {
59300       selection2.call(redraw);
59301       context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() {
59302         selection2.call(redraw);
59303       });
59304     };
59305     panel.off = function() {
59306       context.surface().on(".info-location", null);
59307     };
59308     panel.id = "location";
59309     panel.label = _t.append("info_panels.location.title");
59310     panel.key = _t("info_panels.location.key");
59311     return panel;
59312   }
59313
59314   // modules/ui/panels/measurement.js
59315   function uiPanelMeasurement(context) {
59316     function radiansToMeters(r2) {
59317       return r2 * 63710071809e-4;
59318     }
59319     function steradiansToSqmeters(r2) {
59320       return r2 / (4 * Math.PI) * 510065621724e3;
59321     }
59322     function toLineString(feature3) {
59323       if (feature3.type === "LineString")
59324         return feature3;
59325       var result = { type: "LineString", coordinates: [] };
59326       if (feature3.type === "Polygon") {
59327         result.coordinates = feature3.coordinates[0];
59328       } else if (feature3.type === "MultiPolygon") {
59329         result.coordinates = feature3.coordinates[0][0];
59330       }
59331       return result;
59332     }
59333     var _isImperial = !_mainLocalizer.usesMetric();
59334     function redraw(selection2) {
59335       var graph = context.graph();
59336       var selectedNoteID = context.selectedNoteID();
59337       var osm = services.osm;
59338       var localeCode = _mainLocalizer.localeCode();
59339       var heading2;
59340       var center, location, centroid;
59341       var closed, geometry;
59342       var totalNodeCount, length2 = 0, area = 0, distance;
59343       if (selectedNoteID && osm) {
59344         var note = osm.getNote(selectedNoteID);
59345         heading2 = _t.html("note.note") + " " + selectedNoteID;
59346         location = note.loc;
59347         geometry = "note";
59348       } else {
59349         var selectedIDs = context.selectedIDs().filter(function(id2) {
59350           return context.hasEntity(id2);
59351         });
59352         var selected = selectedIDs.map(function(id2) {
59353           return context.entity(id2);
59354         });
59355         heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length });
59356         if (selected.length) {
59357           var extent = geoExtent();
59358           for (var i3 in selected) {
59359             var entity = selected[i3];
59360             extent._extend(entity.extent(graph));
59361             geometry = entity.geometry(graph);
59362             if (geometry === "line" || geometry === "area") {
59363               closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate();
59364               var feature3 = entity.asGeoJSON(graph);
59365               length2 += radiansToMeters(length_default(toLineString(feature3)));
59366               centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph));
59367               centroid = centroid && context.projection.invert(centroid);
59368               if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) {
59369                 centroid = entity.extent(graph).center();
59370               }
59371               if (closed) {
59372                 area += steradiansToSqmeters(entity.area(graph));
59373               }
59374             }
59375           }
59376           if (selected.length > 1) {
59377             geometry = null;
59378             closed = null;
59379             centroid = null;
59380           }
59381           if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") {
59382             distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
59383           }
59384           if (selected.length === 1 && selected[0].type === "node") {
59385             location = selected[0].loc;
59386           } else {
59387             totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length;
59388           }
59389           if (!location && !centroid) {
59390             center = extent.center();
59391           }
59392         }
59393       }
59394       selection2.html("");
59395       if (heading2) {
59396         selection2.append("h4").attr("class", "measurement-heading").html(heading2);
59397       }
59398       var list2 = selection2.append("ul");
59399       var coordItem;
59400       if (geometry) {
59401         list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html(
59402           closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry)
59403         );
59404       }
59405       if (totalNodeCount) {
59406         list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode));
59407       }
59408       if (area) {
59409         list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial));
59410       }
59411       if (length2) {
59412         list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial));
59413       }
59414       if (typeof distance === "number") {
59415         list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial));
59416       }
59417       if (location) {
59418         coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" }));
59419         coordItem.append("span").text(dmsCoordinatePair(location));
59420         coordItem.append("span").text(decimalCoordinatePair(location));
59421       }
59422       if (centroid) {
59423         coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" }));
59424         coordItem.append("span").text(dmsCoordinatePair(centroid));
59425         coordItem.append("span").text(decimalCoordinatePair(centroid));
59426       }
59427       if (center) {
59428         coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" }));
59429         coordItem.append("span").text(dmsCoordinatePair(center));
59430         coordItem.append("span").text(decimalCoordinatePair(center));
59431       }
59432       if (length2 || area || typeof distance === "number") {
59433         var toggle = _isImperial ? "imperial" : "metric";
59434         selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) {
59435           d3_event.preventDefault();
59436           _isImperial = !_isImperial;
59437           selection2.call(redraw);
59438         });
59439       }
59440     }
59441     var panel = function(selection2) {
59442       selection2.call(redraw);
59443       context.map().on("drawn.info-measurement", function() {
59444         selection2.call(redraw);
59445       });
59446       context.on("enter.info-measurement", function() {
59447         selection2.call(redraw);
59448       });
59449     };
59450     panel.off = function() {
59451       context.map().on("drawn.info-measurement", null);
59452       context.on("enter.info-measurement", null);
59453     };
59454     panel.id = "measurement";
59455     panel.label = _t.append("info_panels.measurement.title");
59456     panel.key = _t("info_panels.measurement.key");
59457     return panel;
59458   }
59459
59460   // modules/ui/panels/index.js
59461   var uiInfoPanels = {
59462     background: uiPanelBackground,
59463     history: uiPanelHistory,
59464     location: uiPanelLocation,
59465     measurement: uiPanelMeasurement
59466   };
59467
59468   // modules/ui/info.js
59469   function uiInfo(context) {
59470     var ids = Object.keys(uiInfoPanels);
59471     var wasActive = ["measurement"];
59472     var panels = {};
59473     var active = {};
59474     ids.forEach(function(k2) {
59475       if (!panels[k2]) {
59476         panels[k2] = uiInfoPanels[k2](context);
59477         active[k2] = false;
59478       }
59479     });
59480     function info(selection2) {
59481       function redraw() {
59482         var activeids = ids.filter(function(k2) {
59483           return active[k2];
59484         }).sort();
59485         var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) {
59486           return k2;
59487         });
59488         containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) {
59489           select_default2(this).call(panels[d2].off).remove();
59490         });
59491         var enter = containers.enter().append("div").attr("class", function(d2) {
59492           return "fillD2 panel-container panel-container-" + d2;
59493         });
59494         enter.style("opacity", 0).transition().duration(200).style("opacity", 1);
59495         var title = enter.append("div").attr("class", "panel-title fillD2");
59496         title.append("h3").each(function(d2) {
59497           return panels[d2].label(select_default2(this));
59498         });
59499         title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) {
59500           d3_event.stopImmediatePropagation();
59501           d3_event.preventDefault();
59502           info.toggle(d2);
59503         }).call(svgIcon("#iD-icon-close"));
59504         enter.append("div").attr("class", function(d2) {
59505           return "panel-content panel-content-" + d2;
59506         });
59507         infoPanels.selectAll(".panel-content").each(function(d2) {
59508           select_default2(this).call(panels[d2]);
59509         });
59510       }
59511       info.toggle = function(which) {
59512         var activeids = ids.filter(function(k2) {
59513           return active[k2];
59514         });
59515         if (which) {
59516           active[which] = !active[which];
59517           if (activeids.length === 1 && activeids[0] === which) {
59518             wasActive = [which];
59519           }
59520           context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]);
59521         } else {
59522           if (activeids.length) {
59523             wasActive = activeids;
59524             activeids.forEach(function(k2) {
59525               active[k2] = false;
59526             });
59527           } else {
59528             wasActive.forEach(function(k2) {
59529               active[k2] = true;
59530             });
59531           }
59532         }
59533         redraw();
59534       };
59535       var infoPanels = selection2.selectAll(".info-panels").data([0]);
59536       infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels);
59537       redraw();
59538       context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) {
59539         d3_event.stopImmediatePropagation();
59540         d3_event.preventDefault();
59541         info.toggle();
59542       });
59543       ids.forEach(function(k2) {
59544         var key = _t("info_panels." + k2 + ".key", { default: null });
59545         if (!key)
59546           return;
59547         context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) {
59548           d3_event.stopImmediatePropagation();
59549           d3_event.preventDefault();
59550           info.toggle(k2);
59551         });
59552       });
59553     }
59554     return info;
59555   }
59556
59557   // modules/ui/intro/helper.js
59558   function pointBox(loc, context) {
59559     var rect = context.surfaceRect();
59560     var point2 = context.curtainProjection(loc);
59561     return {
59562       left: point2[0] + rect.left - 40,
59563       top: point2[1] + rect.top - 60,
59564       width: 80,
59565       height: 90
59566     };
59567   }
59568   function pad(locOrBox, padding, context) {
59569     var box;
59570     if (locOrBox instanceof Array) {
59571       var rect = context.surfaceRect();
59572       var point2 = context.curtainProjection(locOrBox);
59573       box = {
59574         left: point2[0] + rect.left,
59575         top: point2[1] + rect.top
59576       };
59577     } else {
59578       box = locOrBox;
59579     }
59580     return {
59581       left: box.left - padding,
59582       top: box.top - padding,
59583       width: (box.width || 0) + 2 * padding,
59584       height: (box.width || 0) + 2 * padding
59585     };
59586   }
59587   function icon(name, svgklass, useklass) {
59588     return '<svg class="icon ' + (svgklass || "") + '"><use xlink:href="' + name + '"' + (useklass ? ' class="' + useklass + '"' : "") + "></use></svg>";
59589   }
59590   var helpStringReplacements;
59591   function helpHtml(id2, replacements) {
59592     if (!helpStringReplacements) {
59593       helpStringReplacements = {
59594         // insert icons corresponding to various UI elements
59595         point_icon: icon("#iD-icon-point", "inline"),
59596         line_icon: icon("#iD-icon-line", "inline"),
59597         area_icon: icon("#iD-icon-area", "inline"),
59598         note_icon: icon("#iD-icon-note", "inline add-note"),
59599         plus: icon("#iD-icon-plus", "inline"),
59600         minus: icon("#iD-icon-minus", "inline"),
59601         layers_icon: icon("#iD-icon-layers", "inline"),
59602         data_icon: icon("#iD-icon-data", "inline"),
59603         inspect: icon("#iD-icon-inspect", "inline"),
59604         help_icon: icon("#iD-icon-help", "inline"),
59605         undo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo", "inline"),
59606         redo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-undo" : "#iD-icon-redo", "inline"),
59607         save_icon: icon("#iD-icon-save", "inline"),
59608         // operation icons
59609         circularize_icon: icon("#iD-operation-circularize", "inline operation"),
59610         continue_icon: icon("#iD-operation-continue", "inline operation"),
59611         copy_icon: icon("#iD-operation-copy", "inline operation"),
59612         delete_icon: icon("#iD-operation-delete", "inline operation"),
59613         disconnect_icon: icon("#iD-operation-disconnect", "inline operation"),
59614         downgrade_icon: icon("#iD-operation-downgrade", "inline operation"),
59615         extract_icon: icon("#iD-operation-extract", "inline operation"),
59616         merge_icon: icon("#iD-operation-merge", "inline operation"),
59617         move_icon: icon("#iD-operation-move", "inline operation"),
59618         orthogonalize_icon: icon("#iD-operation-orthogonalize", "inline operation"),
59619         paste_icon: icon("#iD-operation-paste", "inline operation"),
59620         reflect_long_icon: icon("#iD-operation-reflect-long", "inline operation"),
59621         reflect_short_icon: icon("#iD-operation-reflect-short", "inline operation"),
59622         reverse_icon: icon("#iD-operation-reverse", "inline operation"),
59623         rotate_icon: icon("#iD-operation-rotate", "inline operation"),
59624         split_icon: icon("#iD-operation-split", "inline operation"),
59625         straighten_icon: icon("#iD-operation-straighten", "inline operation"),
59626         // interaction icons
59627         leftclick: icon("#iD-walkthrough-mouse-left", "inline operation"),
59628         rightclick: icon("#iD-walkthrough-mouse-right", "inline operation"),
59629         mousewheel_icon: icon("#iD-walkthrough-mousewheel", "inline operation"),
59630         tap_icon: icon("#iD-walkthrough-tap", "inline operation"),
59631         doubletap_icon: icon("#iD-walkthrough-doubletap", "inline operation"),
59632         longpress_icon: icon("#iD-walkthrough-longpress", "inline operation"),
59633         touchdrag_icon: icon("#iD-walkthrough-touchdrag", "inline operation"),
59634         pinch_icon: icon("#iD-walkthrough-pinch-apart", "inline operation"),
59635         // insert keys; may be localized and platform-dependent
59636         shift: uiCmd.display("\u21E7"),
59637         alt: uiCmd.display("\u2325"),
59638         return: uiCmd.display("\u21B5"),
59639         esc: _t.html("shortcuts.key.esc"),
59640         space: _t.html("shortcuts.key.space"),
59641         add_note_key: _t.html("modes.add_note.key"),
59642         help_key: _t.html("help.key"),
59643         shortcuts_key: _t.html("shortcuts.toggle.key"),
59644         // reference localized UI labels directly so that they'll always match
59645         save: _t.html("save.title"),
59646         undo: _t.html("undo.title"),
59647         redo: _t.html("redo.title"),
59648         upload: _t.html("commit.save"),
59649         point: _t.html("modes.add_point.title"),
59650         line: _t.html("modes.add_line.title"),
59651         area: _t.html("modes.add_area.title"),
59652         note: _t.html("modes.add_note.label"),
59653         circularize: _t.html("operations.circularize.title"),
59654         continue: _t.html("operations.continue.title"),
59655         copy: _t.html("operations.copy.title"),
59656         delete: _t.html("operations.delete.title"),
59657         disconnect: _t.html("operations.disconnect.title"),
59658         downgrade: _t.html("operations.downgrade.title"),
59659         extract: _t.html("operations.extract.title"),
59660         merge: _t.html("operations.merge.title"),
59661         move: _t.html("operations.move.title"),
59662         orthogonalize: _t.html("operations.orthogonalize.title"),
59663         paste: _t.html("operations.paste.title"),
59664         reflect_long: _t.html("operations.reflect.title.long"),
59665         reflect_short: _t.html("operations.reflect.title.short"),
59666         reverse: _t.html("operations.reverse.title"),
59667         rotate: _t.html("operations.rotate.title"),
59668         split: _t.html("operations.split.title"),
59669         straighten: _t.html("operations.straighten.title"),
59670         map_data: _t.html("map_data.title"),
59671         osm_notes: _t.html("map_data.layers.notes.title"),
59672         fields: _t.html("inspector.fields"),
59673         tags: _t.html("inspector.tags"),
59674         relations: _t.html("inspector.relations"),
59675         new_relation: _t.html("inspector.new_relation"),
59676         turn_restrictions: _t.html("_tagging.presets.fields.restrictions.label"),
59677         background_settings: _t.html("background.description"),
59678         imagery_offset: _t.html("background.fix_misalignment"),
59679         start_the_walkthrough: _t.html("splash.walkthrough"),
59680         help: _t.html("help.title"),
59681         ok: _t.html("intro.ok")
59682       };
59683       for (var key in helpStringReplacements) {
59684         helpStringReplacements[key] = { html: helpStringReplacements[key] };
59685       }
59686     }
59687     var reps;
59688     if (replacements) {
59689       reps = Object.assign(replacements, helpStringReplacements);
59690     } else {
59691       reps = helpStringReplacements;
59692     }
59693     return _t.html(id2, reps).replace(/\`(.*?)\`/g, "<kbd>$1</kbd>");
59694   }
59695   function slugify(text) {
59696     return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
59697   }
59698   var missingStrings = {};
59699   function checkKey(key, text) {
59700     if (_t(key, { default: void 0 }) === void 0) {
59701       if (missingStrings.hasOwnProperty(key))
59702         return;
59703       missingStrings[key] = text;
59704       var missing = key + ": " + text;
59705       if (typeof console !== "undefined")
59706         console.log(missing);
59707     }
59708   }
59709   function localize(obj) {
59710     var key;
59711     var name = obj.tags && obj.tags.name;
59712     if (name) {
59713       key = "intro.graph.name." + slugify(name);
59714       obj.tags.name = _t(key, { default: name });
59715       checkKey(key, name);
59716     }
59717     var street = obj.tags && obj.tags["addr:street"];
59718     if (street) {
59719       key = "intro.graph.name." + slugify(street);
59720       obj.tags["addr:street"] = _t(key, { default: street });
59721       checkKey(key, street);
59722       var addrTags = [
59723         "block_number",
59724         "city",
59725         "county",
59726         "district",
59727         "hamlet",
59728         "neighbourhood",
59729         "postcode",
59730         "province",
59731         "quarter",
59732         "state",
59733         "subdistrict",
59734         "suburb"
59735       ];
59736       addrTags.forEach(function(k2) {
59737         var key2 = "intro.graph." + k2;
59738         var tag2 = "addr:" + k2;
59739         var val = obj.tags && obj.tags[tag2];
59740         var str = _t(key2, { default: val });
59741         if (str) {
59742           if (str.match(/^<.*>$/) !== null) {
59743             delete obj.tags[tag2];
59744           } else {
59745             obj.tags[tag2] = str;
59746           }
59747         }
59748       });
59749     }
59750     return obj;
59751   }
59752   function isMostlySquare(points) {
59753     var threshold = 15;
59754     var lowerBound = Math.cos((90 - threshold) * Math.PI / 180);
59755     var upperBound = Math.cos(threshold * Math.PI / 180);
59756     for (var i3 = 0; i3 < points.length; i3++) {
59757       var a2 = points[(i3 - 1 + points.length) % points.length];
59758       var origin = points[i3];
59759       var b2 = points[(i3 + 1) % points.length];
59760       var dotp = geoVecNormalizedDot(a2, b2, origin);
59761       var mag = Math.abs(dotp);
59762       if (mag > lowerBound && mag < upperBound) {
59763         return false;
59764       }
59765     }
59766     return true;
59767   }
59768   function selectMenuItem(context, operation2) {
59769     return context.container().select(".edit-menu .edit-menu-item-" + operation2);
59770   }
59771   function transitionTime(point1, point2) {
59772     var distance = geoSphericalDistance(point1, point2);
59773     if (distance === 0) {
59774       return 0;
59775     } else if (distance < 80) {
59776       return 500;
59777     } else {
59778       return 1e3;
59779     }
59780   }
59781
59782   // modules/ui/toggle.js
59783   function uiToggle(show, callback) {
59784     return function(selection2) {
59785       selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() {
59786         select_default2(this).classed("hide", !show).style("opacity", null);
59787         if (callback)
59788           callback.apply(this);
59789       });
59790     };
59791   }
59792
59793   // modules/ui/curtain.js
59794   function uiCurtain(containerNode) {
59795     var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null);
59796     function curtain(selection2) {
59797       surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0);
59798       darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness");
59799       select_default2(window).on("resize.curtain", resize);
59800       tooltip = selection2.append("div").attr("class", "tooltip");
59801       tooltip.append("div").attr("class", "popover-arrow");
59802       tooltip.append("div").attr("class", "popover-inner");
59803       resize();
59804       function resize() {
59805         surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight);
59806         curtain.cut(darkness.datum());
59807       }
59808     }
59809     curtain.reveal = function(box, html3, options2) {
59810       options2 = options2 || {};
59811       if (typeof box === "string") {
59812         box = select_default2(box).node();
59813       }
59814       if (box && box.getBoundingClientRect) {
59815         box = copyBox(box.getBoundingClientRect());
59816         var containerRect = containerNode.getBoundingClientRect();
59817         box.top -= containerRect.top;
59818         box.left -= containerRect.left;
59819       }
59820       if (box && options2.padding) {
59821         box.top -= options2.padding;
59822         box.left -= options2.padding;
59823         box.bottom += options2.padding;
59824         box.right += options2.padding;
59825         box.height += options2.padding * 2;
59826         box.width += options2.padding * 2;
59827       }
59828       var tooltipBox;
59829       if (options2.tooltipBox) {
59830         tooltipBox = options2.tooltipBox;
59831         if (typeof tooltipBox === "string") {
59832           tooltipBox = select_default2(tooltipBox).node();
59833         }
59834         if (tooltipBox && tooltipBox.getBoundingClientRect) {
59835           tooltipBox = copyBox(tooltipBox.getBoundingClientRect());
59836         }
59837       } else {
59838         tooltipBox = box;
59839       }
59840       if (tooltipBox && html3) {
59841         if (html3.indexOf("**") !== -1) {
59842           if (html3.indexOf("<span") === 0) {
59843             html3 = html3.replace(/^(<span.*?>)(.+?)(\*\*)/, "$1<span>$2</span>$3");
59844           } else {
59845             html3 = html3.replace(/^(.+?)(\*\*)/, "<span>$1</span>$2");
59846           }
59847           html3 = html3.replace(/\*\*(.*?)\*\*/g, '<span class="instruction">$1</span>');
59848         }
59849         html3 = html3.replace(/\*(.*?)\*/g, "<em>$1</em>");
59850         html3 = html3.replace(/\{br\}/g, "<br/><br/>");
59851         if (options2.buttonText && options2.buttonCallback) {
59852           html3 += '<div class="button-section"><button href="#" class="button action">' + options2.buttonText + "</button></div>";
59853         }
59854         var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || "");
59855         tooltip.classed(classes, true).selectAll(".popover-inner").html(html3);
59856         if (options2.buttonText && options2.buttonCallback) {
59857           var button = tooltip.selectAll(".button-section .button.action");
59858           button.on("click", function(d3_event) {
59859             d3_event.preventDefault();
59860             options2.buttonCallback();
59861           });
59862         }
59863         var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos;
59864         if (options2.tooltipClass === "intro-mouse") {
59865           tip.height += 80;
59866         }
59867         if (tooltipBox.top + tooltipBox.height > h2) {
59868           tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2;
59869         }
59870         if (tooltipBox.left + tooltipBox.width > w2) {
59871           tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2;
59872         }
59873         if (tooltipBox.top + tooltipBox.height < 100) {
59874           side = "bottom";
59875           pos = [
59876             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59877             tooltipBox.top + tooltipBox.height
59878           ];
59879         } else if (tooltipBox.top > h2 - 140) {
59880           side = "top";
59881           pos = [
59882             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59883             tooltipBox.top - tip.height
59884           ];
59885         } else {
59886           var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2;
59887           if (_mainLocalizer.textDirection() === "rtl") {
59888             if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) {
59889               side = "right";
59890               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59891             } else {
59892               side = "left";
59893               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59894             }
59895           } else {
59896             if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) {
59897               side = "left";
59898               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59899             } else {
59900               side = "right";
59901               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59902             }
59903           }
59904         }
59905         if (options2.duration !== 0 || !tooltip.classed(side)) {
59906           tooltip.call(uiToggle(true));
59907         }
59908         tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side);
59909         var shiftY = 0;
59910         if (side === "left" || side === "right") {
59911           if (pos[1] < 60) {
59912             shiftY = 60 - pos[1];
59913           } else if (pos[1] + tip.height > h2 - 100) {
59914             shiftY = h2 - pos[1] - tip.height - 100;
59915           }
59916         }
59917         tooltip.selectAll(".popover-inner").style("top", shiftY + "px");
59918       } else {
59919         tooltip.classed("in", false).call(uiToggle(false));
59920       }
59921       curtain.cut(box, options2.duration);
59922       return tooltip;
59923     };
59924     curtain.cut = function(datum2, duration) {
59925       darkness.datum(datum2).interrupt();
59926       var selection2;
59927       if (duration === 0) {
59928         selection2 = darkness;
59929       } else {
59930         selection2 = darkness.transition().duration(duration || 600).ease(linear2);
59931       }
59932       selection2.attr("d", function(d2) {
59933         var containerWidth = containerNode.clientWidth;
59934         var containerHeight = containerNode.clientHeight;
59935         var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z";
59936         if (!d2)
59937           return string;
59938         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";
59939       });
59940     };
59941     curtain.remove = function() {
59942       surface.remove();
59943       tooltip.remove();
59944       select_default2(window).on("resize.curtain", null);
59945     };
59946     function copyBox(src) {
59947       return {
59948         top: src.top,
59949         right: src.right,
59950         bottom: src.bottom,
59951         left: src.left,
59952         width: src.width,
59953         height: src.height
59954       };
59955     }
59956     return curtain;
59957   }
59958
59959   // modules/ui/intro/welcome.js
59960   function uiIntroWelcome(context, reveal) {
59961     var dispatch14 = dispatch_default("done");
59962     var chapter = {
59963       title: "intro.welcome.title"
59964     };
59965     function welcome() {
59966       context.map().centerZoom([-85.63591, 41.94285], 19);
59967       reveal(
59968         ".intro-nav-wrap .chapter-welcome",
59969         helpHtml("intro.welcome.welcome"),
59970         { buttonText: _t.html("intro.ok"), buttonCallback: practice }
59971       );
59972     }
59973     function practice() {
59974       reveal(
59975         ".intro-nav-wrap .chapter-welcome",
59976         helpHtml("intro.welcome.practice"),
59977         { buttonText: _t.html("intro.ok"), buttonCallback: words }
59978       );
59979     }
59980     function words() {
59981       reveal(
59982         ".intro-nav-wrap .chapter-welcome",
59983         helpHtml("intro.welcome.words"),
59984         { buttonText: _t.html("intro.ok"), buttonCallback: chapters }
59985       );
59986     }
59987     function chapters() {
59988       dispatch14.call("done");
59989       reveal(
59990         ".intro-nav-wrap .chapter-navigation",
59991         helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") })
59992       );
59993     }
59994     chapter.enter = function() {
59995       welcome();
59996     };
59997     chapter.exit = function() {
59998       context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove();
59999     };
60000     chapter.restart = function() {
60001       chapter.exit();
60002       chapter.enter();
60003     };
60004     return utilRebind(chapter, dispatch14, "on");
60005   }
60006
60007   // modules/ui/intro/navigation.js
60008   function uiIntroNavigation(context, reveal) {
60009     var dispatch14 = dispatch_default("done");
60010     var timeouts = [];
60011     var hallId = "n2061";
60012     var townHall = [-85.63591, 41.94285];
60013     var springStreetId = "w397";
60014     var springStreetEndId = "n1834";
60015     var springStreet = [-85.63582, 41.94255];
60016     var onewayField = _mainPresetIndex.field("oneway");
60017     var maxspeedField = _mainPresetIndex.field("maxspeed");
60018     var chapter = {
60019       title: "intro.navigation.title"
60020     };
60021     function timeout2(f2, t2) {
60022       timeouts.push(window.setTimeout(f2, t2));
60023     }
60024     function eventCancel(d3_event) {
60025       d3_event.stopPropagation();
60026       d3_event.preventDefault();
60027     }
60028     function isTownHallSelected() {
60029       var ids = context.selectedIDs();
60030       return ids.length === 1 && ids[0] === hallId;
60031     }
60032     function dragMap() {
60033       context.enter(modeBrowse(context));
60034       context.history().reset("initial");
60035       var msec = transitionTime(townHall, context.map().center());
60036       if (msec) {
60037         reveal(null, null, { duration: 0 });
60038       }
60039       context.map().centerZoomEase(townHall, 19, msec);
60040       timeout2(function() {
60041         var centerStart = context.map().center();
60042         var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch";
60043         var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId);
60044         reveal(".surface", dragString);
60045         context.map().on("drawn.intro", function() {
60046           reveal(".surface", dragString, { duration: 0 });
60047         });
60048         context.map().on("move.intro", function() {
60049           var centerNow = context.map().center();
60050           if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) {
60051             context.map().on("move.intro", null);
60052             timeout2(function() {
60053               continueTo(zoomMap);
60054             }, 3e3);
60055           }
60056         });
60057       }, msec + 100);
60058       function continueTo(nextStep) {
60059         context.map().on("move.intro drawn.intro", null);
60060         nextStep();
60061       }
60062     }
60063     function zoomMap() {
60064       var zoomStart = context.map().zoom();
60065       var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch";
60066       var zoomString = helpHtml("intro.navigation." + textId);
60067       reveal(".surface", zoomString);
60068       context.map().on("drawn.intro", function() {
60069         reveal(".surface", zoomString, { duration: 0 });
60070       });
60071       context.map().on("move.intro", function() {
60072         if (context.map().zoom() !== zoomStart) {
60073           context.map().on("move.intro", null);
60074           timeout2(function() {
60075             continueTo(features);
60076           }, 3e3);
60077         }
60078       });
60079       function continueTo(nextStep) {
60080         context.map().on("move.intro drawn.intro", null);
60081         nextStep();
60082       }
60083     }
60084     function features() {
60085       var onClick = function() {
60086         continueTo(pointsLinesAreas);
60087       };
60088       reveal(
60089         ".surface",
60090         helpHtml("intro.navigation.features"),
60091         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60092       );
60093       context.map().on("drawn.intro", function() {
60094         reveal(
60095           ".surface",
60096           helpHtml("intro.navigation.features"),
60097           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60098         );
60099       });
60100       function continueTo(nextStep) {
60101         context.map().on("drawn.intro", null);
60102         nextStep();
60103       }
60104     }
60105     function pointsLinesAreas() {
60106       var onClick = function() {
60107         continueTo(nodesWays);
60108       };
60109       reveal(
60110         ".surface",
60111         helpHtml("intro.navigation.points_lines_areas"),
60112         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60113       );
60114       context.map().on("drawn.intro", function() {
60115         reveal(
60116           ".surface",
60117           helpHtml("intro.navigation.points_lines_areas"),
60118           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60119         );
60120       });
60121       function continueTo(nextStep) {
60122         context.map().on("drawn.intro", null);
60123         nextStep();
60124       }
60125     }
60126     function nodesWays() {
60127       var onClick = function() {
60128         continueTo(clickTownHall);
60129       };
60130       reveal(
60131         ".surface",
60132         helpHtml("intro.navigation.nodes_ways"),
60133         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60134       );
60135       context.map().on("drawn.intro", function() {
60136         reveal(
60137           ".surface",
60138           helpHtml("intro.navigation.nodes_ways"),
60139           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60140         );
60141       });
60142       function continueTo(nextStep) {
60143         context.map().on("drawn.intro", null);
60144         nextStep();
60145       }
60146     }
60147     function clickTownHall() {
60148       context.enter(modeBrowse(context));
60149       context.history().reset("initial");
60150       var entity = context.hasEntity(hallId);
60151       if (!entity)
60152         return;
60153       reveal(null, null, { duration: 0 });
60154       context.map().centerZoomEase(entity.loc, 19, 500);
60155       timeout2(function() {
60156         var entity2 = context.hasEntity(hallId);
60157         if (!entity2)
60158           return;
60159         var box = pointBox(entity2.loc, context);
60160         var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall";
60161         reveal(box, helpHtml("intro.navigation." + textId));
60162         context.map().on("move.intro drawn.intro", function() {
60163           var entity3 = context.hasEntity(hallId);
60164           if (!entity3)
60165             return;
60166           var box2 = pointBox(entity3.loc, context);
60167           reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 });
60168         });
60169         context.on("enter.intro", function() {
60170           if (isTownHallSelected())
60171             continueTo(selectedTownHall);
60172         });
60173       }, 550);
60174       context.history().on("change.intro", function() {
60175         if (!context.hasEntity(hallId)) {
60176           continueTo(clickTownHall);
60177         }
60178       });
60179       function continueTo(nextStep) {
60180         context.on("enter.intro", null);
60181         context.map().on("move.intro drawn.intro", null);
60182         context.history().on("change.intro", null);
60183         nextStep();
60184       }
60185     }
60186     function selectedTownHall() {
60187       if (!isTownHallSelected())
60188         return clickTownHall();
60189       var entity = context.hasEntity(hallId);
60190       if (!entity)
60191         return clickTownHall();
60192       var box = pointBox(entity.loc, context);
60193       var onClick = function() {
60194         continueTo(editorTownHall);
60195       };
60196       reveal(
60197         box,
60198         helpHtml("intro.navigation.selected_townhall"),
60199         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60200       );
60201       context.map().on("move.intro drawn.intro", function() {
60202         var entity2 = context.hasEntity(hallId);
60203         if (!entity2)
60204           return;
60205         var box2 = pointBox(entity2.loc, context);
60206         reveal(
60207           box2,
60208           helpHtml("intro.navigation.selected_townhall"),
60209           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60210         );
60211       });
60212       context.history().on("change.intro", function() {
60213         if (!context.hasEntity(hallId)) {
60214           continueTo(clickTownHall);
60215         }
60216       });
60217       function continueTo(nextStep) {
60218         context.map().on("move.intro drawn.intro", null);
60219         context.history().on("change.intro", null);
60220         nextStep();
60221       }
60222     }
60223     function editorTownHall() {
60224       if (!isTownHallSelected())
60225         return clickTownHall();
60226       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60227       var onClick = function() {
60228         continueTo(presetTownHall);
60229       };
60230       reveal(
60231         ".entity-editor-pane",
60232         helpHtml("intro.navigation.editor_townhall"),
60233         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60234       );
60235       context.on("exit.intro", function() {
60236         continueTo(clickTownHall);
60237       });
60238       context.history().on("change.intro", function() {
60239         if (!context.hasEntity(hallId)) {
60240           continueTo(clickTownHall);
60241         }
60242       });
60243       function continueTo(nextStep) {
60244         context.on("exit.intro", null);
60245         context.history().on("change.intro", null);
60246         context.container().select(".inspector-wrap").on("wheel.intro", null);
60247         nextStep();
60248       }
60249     }
60250     function presetTownHall() {
60251       if (!isTownHallSelected())
60252         return clickTownHall();
60253       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60254       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60255       var entity = context.entity(context.selectedIDs()[0]);
60256       var preset = _mainPresetIndex.match(entity, context.graph());
60257       var onClick = function() {
60258         continueTo(fieldsTownHall);
60259       };
60260       reveal(
60261         ".entity-editor-pane .section-feature-type",
60262         helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }),
60263         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60264       );
60265       context.on("exit.intro", function() {
60266         continueTo(clickTownHall);
60267       });
60268       context.history().on("change.intro", function() {
60269         if (!context.hasEntity(hallId)) {
60270           continueTo(clickTownHall);
60271         }
60272       });
60273       function continueTo(nextStep) {
60274         context.on("exit.intro", null);
60275         context.history().on("change.intro", null);
60276         context.container().select(".inspector-wrap").on("wheel.intro", null);
60277         nextStep();
60278       }
60279     }
60280     function fieldsTownHall() {
60281       if (!isTownHallSelected())
60282         return clickTownHall();
60283       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60284       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60285       var onClick = function() {
60286         continueTo(closeTownHall);
60287       };
60288       reveal(
60289         ".entity-editor-pane .section-preset-fields",
60290         helpHtml("intro.navigation.fields_townhall"),
60291         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60292       );
60293       context.on("exit.intro", function() {
60294         continueTo(clickTownHall);
60295       });
60296       context.history().on("change.intro", function() {
60297         if (!context.hasEntity(hallId)) {
60298           continueTo(clickTownHall);
60299         }
60300       });
60301       function continueTo(nextStep) {
60302         context.on("exit.intro", null);
60303         context.history().on("change.intro", null);
60304         context.container().select(".inspector-wrap").on("wheel.intro", null);
60305         nextStep();
60306       }
60307     }
60308     function closeTownHall() {
60309       if (!isTownHallSelected())
60310         return clickTownHall();
60311       var selector = ".entity-editor-pane button.close svg use";
60312       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60313       reveal(
60314         ".entity-editor-pane",
60315         helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } })
60316       );
60317       context.on("exit.intro", function() {
60318         continueTo(searchStreet);
60319       });
60320       context.history().on("change.intro", function() {
60321         var selector2 = ".entity-editor-pane button.close svg use";
60322         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60323         reveal(
60324           ".entity-editor-pane",
60325           helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }),
60326           { duration: 0 }
60327         );
60328       });
60329       function continueTo(nextStep) {
60330         context.on("exit.intro", null);
60331         context.history().on("change.intro", null);
60332         nextStep();
60333       }
60334     }
60335     function searchStreet() {
60336       context.enter(modeBrowse(context));
60337       context.history().reset("initial");
60338       var msec = transitionTime(springStreet, context.map().center());
60339       if (msec) {
60340         reveal(null, null, { duration: 0 });
60341       }
60342       context.map().centerZoomEase(springStreet, 19, msec);
60343       timeout2(function() {
60344         reveal(
60345           ".search-header input",
60346           helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") })
60347         );
60348         context.container().select(".search-header input").on("keyup.intro", checkSearchResult);
60349       }, msec + 100);
60350     }
60351     function checkSearchResult() {
60352       var first = context.container().select(".feature-list-item:nth-child(0n+2)");
60353       var firstName = first.select(".entity-name");
60354       var name = _t("intro.graph.name.spring-street");
60355       if (!firstName.empty() && firstName.html() === name) {
60356         reveal(
60357           first.node(),
60358           helpHtml("intro.navigation.choose_street", { name }),
60359           { duration: 300 }
60360         );
60361         context.on("exit.intro", function() {
60362           continueTo(selectedStreet);
60363         });
60364         context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60365       }
60366       function continueTo(nextStep) {
60367         context.on("exit.intro", null);
60368         context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null);
60369         nextStep();
60370       }
60371     }
60372     function selectedStreet() {
60373       if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60374         return searchStreet();
60375       }
60376       var onClick = function() {
60377         continueTo(editorStreet);
60378       };
60379       var entity = context.entity(springStreetEndId);
60380       var box = pointBox(entity.loc, context);
60381       box.height = 500;
60382       reveal(
60383         box,
60384         helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60385         { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60386       );
60387       timeout2(function() {
60388         context.map().on("move.intro drawn.intro", function() {
60389           var entity2 = context.hasEntity(springStreetEndId);
60390           if (!entity2)
60391             return;
60392           var box2 = pointBox(entity2.loc, context);
60393           box2.height = 500;
60394           reveal(
60395             box2,
60396             helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60397             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60398           );
60399         });
60400       }, 600);
60401       context.on("enter.intro", function(mode) {
60402         if (!context.hasEntity(springStreetId)) {
60403           return continueTo(searchStreet);
60404         }
60405         var ids = context.selectedIDs();
60406         if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) {
60407           context.enter(modeSelect(context, [springStreetId]));
60408         }
60409       });
60410       context.history().on("change.intro", function() {
60411         if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60412           timeout2(function() {
60413             continueTo(searchStreet);
60414           }, 300);
60415         }
60416       });
60417       function continueTo(nextStep) {
60418         context.map().on("move.intro drawn.intro", null);
60419         context.on("enter.intro", null);
60420         context.history().on("change.intro", null);
60421         nextStep();
60422       }
60423     }
60424     function editorStreet() {
60425       var selector = ".entity-editor-pane button.close svg use";
60426       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60427       reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60428         button: { html: icon(href, "inline") },
60429         field1: onewayField.title(),
60430         field2: maxspeedField.title()
60431       }));
60432       context.on("exit.intro", function() {
60433         continueTo(play);
60434       });
60435       context.history().on("change.intro", function() {
60436         var selector2 = ".entity-editor-pane button.close svg use";
60437         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60438         reveal(
60439           ".entity-editor-pane",
60440           helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60441             button: { html: icon(href2, "inline") },
60442             field1: onewayField.title(),
60443             field2: maxspeedField.title()
60444           }),
60445           { duration: 0 }
60446         );
60447       });
60448       function continueTo(nextStep) {
60449         context.on("exit.intro", null);
60450         context.history().on("change.intro", null);
60451         nextStep();
60452       }
60453     }
60454     function play() {
60455       dispatch14.call("done");
60456       reveal(
60457         ".ideditor",
60458         helpHtml("intro.navigation.play", { next: _t("intro.points.title") }),
60459         {
60460           tooltipBox: ".intro-nav-wrap .chapter-point",
60461           buttonText: _t.html("intro.ok"),
60462           buttonCallback: function() {
60463             reveal(".ideditor");
60464           }
60465         }
60466       );
60467     }
60468     chapter.enter = function() {
60469       dragMap();
60470     };
60471     chapter.exit = function() {
60472       timeouts.forEach(window.clearTimeout);
60473       context.on("enter.intro exit.intro", null);
60474       context.map().on("move.intro drawn.intro", null);
60475       context.history().on("change.intro", null);
60476       context.container().select(".inspector-wrap").on("wheel.intro", null);
60477       context.container().select(".search-header input").on("keydown.intro keyup.intro", null);
60478     };
60479     chapter.restart = function() {
60480       chapter.exit();
60481       chapter.enter();
60482     };
60483     return utilRebind(chapter, dispatch14, "on");
60484   }
60485
60486   // modules/ui/intro/point.js
60487   function uiIntroPoint(context, reveal) {
60488     var dispatch14 = dispatch_default("done");
60489     var timeouts = [];
60490     var intersection2 = [-85.63279, 41.94394];
60491     var building = [-85.632422, 41.944045];
60492     var cafePreset = _mainPresetIndex.item("amenity/cafe");
60493     var _pointID = null;
60494     var chapter = {
60495       title: "intro.points.title"
60496     };
60497     function timeout2(f2, t2) {
60498       timeouts.push(window.setTimeout(f2, t2));
60499     }
60500     function eventCancel(d3_event) {
60501       d3_event.stopPropagation();
60502       d3_event.preventDefault();
60503     }
60504     function addPoint() {
60505       context.enter(modeBrowse(context));
60506       context.history().reset("initial");
60507       var msec = transitionTime(intersection2, context.map().center());
60508       if (msec) {
60509         reveal(null, null, { duration: 0 });
60510       }
60511       context.map().centerZoomEase(intersection2, 19, msec);
60512       timeout2(function() {
60513         var tooltip = reveal(
60514           "button.add-point",
60515           helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point")
60516         );
60517         _pointID = null;
60518         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points");
60519         context.on("enter.intro", function(mode) {
60520           if (mode.id !== "add-point")
60521             return;
60522           continueTo(placePoint);
60523         });
60524       }, msec + 100);
60525       function continueTo(nextStep) {
60526         context.on("enter.intro", null);
60527         nextStep();
60528       }
60529     }
60530     function placePoint() {
60531       if (context.mode().id !== "add-point") {
60532         return chapter.restart();
60533       }
60534       var pointBox2 = pad(building, 150, context);
60535       var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch";
60536       reveal(pointBox2, helpHtml("intro.points." + textId));
60537       context.map().on("move.intro drawn.intro", function() {
60538         pointBox2 = pad(building, 150, context);
60539         reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 });
60540       });
60541       context.on("enter.intro", function(mode) {
60542         if (mode.id !== "select")
60543           return chapter.restart();
60544         _pointID = context.mode().selectedIDs()[0];
60545         if (context.graph().geometry(_pointID) === "vertex") {
60546           context.map().on("move.intro drawn.intro", null);
60547           context.on("enter.intro", null);
60548           reveal(pointBox2, helpHtml("intro.points.place_point_error"), {
60549             buttonText: _t.html("intro.ok"),
60550             buttonCallback: function() {
60551               return chapter.restart();
60552             }
60553           });
60554         } else {
60555           continueTo(searchPreset);
60556         }
60557       });
60558       function continueTo(nextStep) {
60559         context.map().on("move.intro drawn.intro", null);
60560         context.on("enter.intro", null);
60561         nextStep();
60562       }
60563     }
60564     function searchPreset() {
60565       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60566         return addPoint();
60567       }
60568       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60569       context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60570       reveal(
60571         ".preset-search-input",
60572         helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60573       );
60574       context.on("enter.intro", function(mode) {
60575         if (!_pointID || !context.hasEntity(_pointID)) {
60576           return continueTo(addPoint);
60577         }
60578         var ids = context.selectedIDs();
60579         if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) {
60580           context.enter(modeSelect(context, [_pointID]));
60581           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60582           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60583           reveal(
60584             ".preset-search-input",
60585             helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60586           );
60587           context.history().on("change.intro", null);
60588         }
60589       });
60590       function checkPresetSearch() {
60591         var first = context.container().select(".preset-list-item:first-child");
60592         if (first.classed("preset-amenity-cafe")) {
60593           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60594           reveal(
60595             first.select(".preset-list-button").node(),
60596             helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }),
60597             { duration: 300 }
60598           );
60599           context.history().on("change.intro", function() {
60600             continueTo(aboutFeatureEditor);
60601           });
60602         }
60603       }
60604       function continueTo(nextStep) {
60605         context.on("enter.intro", null);
60606         context.history().on("change.intro", null);
60607         context.container().select(".inspector-wrap").on("wheel.intro", null);
60608         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60609         nextStep();
60610       }
60611     }
60612     function aboutFeatureEditor() {
60613       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60614         return addPoint();
60615       }
60616       timeout2(function() {
60617         reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), {
60618           tooltipClass: "intro-points-describe",
60619           buttonText: _t.html("intro.ok"),
60620           buttonCallback: function() {
60621             continueTo(addName);
60622           }
60623         });
60624       }, 400);
60625       context.on("exit.intro", function() {
60626         continueTo(reselectPoint);
60627       });
60628       function continueTo(nextStep) {
60629         context.on("exit.intro", null);
60630         nextStep();
60631       }
60632     }
60633     function addName() {
60634       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60635         return addPoint();
60636       }
60637       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60638       var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name");
60639       timeout2(function() {
60640         var entity = context.entity(_pointID);
60641         if (entity.tags.name) {
60642           var tooltip = reveal(".entity-editor-pane", addNameString, {
60643             tooltipClass: "intro-points-describe",
60644             buttonText: _t.html("intro.ok"),
60645             buttonCallback: function() {
60646               continueTo(addCloseEditor);
60647             }
60648           });
60649           tooltip.select(".instruction").style("display", "none");
60650         } else {
60651           reveal(
60652             ".entity-editor-pane",
60653             addNameString,
60654             { tooltipClass: "intro-points-describe" }
60655           );
60656         }
60657       }, 400);
60658       context.history().on("change.intro", function() {
60659         continueTo(addCloseEditor);
60660       });
60661       context.on("exit.intro", function() {
60662         continueTo(reselectPoint);
60663       });
60664       function continueTo(nextStep) {
60665         context.on("exit.intro", null);
60666         context.history().on("change.intro", null);
60667         nextStep();
60668       }
60669     }
60670     function addCloseEditor() {
60671       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60672       var selector = ".entity-editor-pane button.close svg use";
60673       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60674       context.on("exit.intro", function() {
60675         continueTo(reselectPoint);
60676       });
60677       reveal(
60678         ".entity-editor-pane",
60679         helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } })
60680       );
60681       function continueTo(nextStep) {
60682         context.on("exit.intro", null);
60683         nextStep();
60684       }
60685     }
60686     function reselectPoint() {
60687       if (!_pointID)
60688         return chapter.restart();
60689       var entity = context.hasEntity(_pointID);
60690       if (!entity)
60691         return chapter.restart();
60692       var oldPreset = _mainPresetIndex.match(entity, context.graph());
60693       context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
60694       context.enter(modeBrowse(context));
60695       var msec = transitionTime(entity.loc, context.map().center());
60696       if (msec) {
60697         reveal(null, null, { duration: 0 });
60698       }
60699       context.map().centerEase(entity.loc, msec);
60700       timeout2(function() {
60701         var box = pointBox(entity.loc, context);
60702         reveal(box, helpHtml("intro.points.reselect"), { duration: 600 });
60703         timeout2(function() {
60704           context.map().on("move.intro drawn.intro", function() {
60705             var entity2 = context.hasEntity(_pointID);
60706             if (!entity2)
60707               return chapter.restart();
60708             var box2 = pointBox(entity2.loc, context);
60709             reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 });
60710           });
60711         }, 600);
60712         context.on("enter.intro", function(mode) {
60713           if (mode.id !== "select")
60714             return;
60715           continueTo(updatePoint);
60716         });
60717       }, msec + 100);
60718       function continueTo(nextStep) {
60719         context.map().on("move.intro drawn.intro", null);
60720         context.on("enter.intro", null);
60721         nextStep();
60722       }
60723     }
60724     function updatePoint() {
60725       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60726         return continueTo(reselectPoint);
60727       }
60728       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60729       context.on("exit.intro", function() {
60730         continueTo(reselectPoint);
60731       });
60732       context.history().on("change.intro", function() {
60733         continueTo(updateCloseEditor);
60734       });
60735       timeout2(function() {
60736         reveal(
60737           ".entity-editor-pane",
60738           helpHtml("intro.points.update"),
60739           { tooltipClass: "intro-points-describe" }
60740         );
60741       }, 400);
60742       function continueTo(nextStep) {
60743         context.on("exit.intro", null);
60744         context.history().on("change.intro", null);
60745         nextStep();
60746       }
60747     }
60748     function updateCloseEditor() {
60749       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60750         return continueTo(reselectPoint);
60751       }
60752       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60753       context.on("exit.intro", function() {
60754         continueTo(rightClickPoint);
60755       });
60756       timeout2(function() {
60757         reveal(
60758           ".entity-editor-pane",
60759           helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } })
60760         );
60761       }, 500);
60762       function continueTo(nextStep) {
60763         context.on("exit.intro", null);
60764         nextStep();
60765       }
60766     }
60767     function rightClickPoint() {
60768       if (!_pointID)
60769         return chapter.restart();
60770       var entity = context.hasEntity(_pointID);
60771       if (!entity)
60772         return chapter.restart();
60773       context.enter(modeBrowse(context));
60774       var box = pointBox(entity.loc, context);
60775       var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch";
60776       reveal(box, helpHtml("intro.points." + textId), { duration: 600 });
60777       timeout2(function() {
60778         context.map().on("move.intro", function() {
60779           var entity2 = context.hasEntity(_pointID);
60780           if (!entity2)
60781             return chapter.restart();
60782           var box2 = pointBox(entity2.loc, context);
60783           reveal(box2, helpHtml("intro.points." + textId), { duration: 0 });
60784         });
60785       }, 600);
60786       context.on("enter.intro", function(mode) {
60787         if (mode.id !== "select")
60788           return;
60789         var ids = context.selectedIDs();
60790         if (ids.length !== 1 || ids[0] !== _pointID)
60791           return;
60792         timeout2(function() {
60793           var node = selectMenuItem(context, "delete").node();
60794           if (!node)
60795             return;
60796           continueTo(enterDelete);
60797         }, 50);
60798       });
60799       function continueTo(nextStep) {
60800         context.on("enter.intro", null);
60801         context.map().on("move.intro", null);
60802         nextStep();
60803       }
60804     }
60805     function enterDelete() {
60806       if (!_pointID)
60807         return chapter.restart();
60808       var entity = context.hasEntity(_pointID);
60809       if (!entity)
60810         return chapter.restart();
60811       var node = selectMenuItem(context, "delete").node();
60812       if (!node) {
60813         return continueTo(rightClickPoint);
60814       }
60815       reveal(
60816         ".edit-menu",
60817         helpHtml("intro.points.delete"),
60818         { padding: 50 }
60819       );
60820       timeout2(function() {
60821         context.map().on("move.intro", function() {
60822           reveal(
60823             ".edit-menu",
60824             helpHtml("intro.points.delete"),
60825             { duration: 0, padding: 50 }
60826           );
60827         });
60828       }, 300);
60829       context.on("exit.intro", function() {
60830         if (!_pointID)
60831           return chapter.restart();
60832         var entity2 = context.hasEntity(_pointID);
60833         if (entity2)
60834           return continueTo(rightClickPoint);
60835       });
60836       context.history().on("change.intro", function(changed) {
60837         if (changed.deleted().length) {
60838           continueTo(undo);
60839         }
60840       });
60841       function continueTo(nextStep) {
60842         context.map().on("move.intro", null);
60843         context.history().on("change.intro", null);
60844         context.on("exit.intro", null);
60845         nextStep();
60846       }
60847     }
60848     function undo() {
60849       context.history().on("change.intro", function() {
60850         continueTo(play);
60851       });
60852       reveal(
60853         ".top-toolbar button.undo-button",
60854         helpHtml("intro.points.undo")
60855       );
60856       function continueTo(nextStep) {
60857         context.history().on("change.intro", null);
60858         nextStep();
60859       }
60860     }
60861     function play() {
60862       dispatch14.call("done");
60863       reveal(
60864         ".ideditor",
60865         helpHtml("intro.points.play", { next: _t("intro.areas.title") }),
60866         {
60867           tooltipBox: ".intro-nav-wrap .chapter-area",
60868           buttonText: _t.html("intro.ok"),
60869           buttonCallback: function() {
60870             reveal(".ideditor");
60871           }
60872         }
60873       );
60874     }
60875     chapter.enter = function() {
60876       addPoint();
60877     };
60878     chapter.exit = function() {
60879       timeouts.forEach(window.clearTimeout);
60880       context.on("enter.intro exit.intro", null);
60881       context.map().on("move.intro drawn.intro", null);
60882       context.history().on("change.intro", null);
60883       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60884       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60885     };
60886     chapter.restart = function() {
60887       chapter.exit();
60888       chapter.enter();
60889     };
60890     return utilRebind(chapter, dispatch14, "on");
60891   }
60892
60893   // modules/ui/intro/area.js
60894   function uiIntroArea(context, reveal) {
60895     var dispatch14 = dispatch_default("done");
60896     var playground = [-85.63552, 41.94159];
60897     var playgroundPreset = _mainPresetIndex.item("leisure/playground");
60898     var nameField = _mainPresetIndex.field("name");
60899     var descriptionField = _mainPresetIndex.field("description");
60900     var timeouts = [];
60901     var _areaID;
60902     var chapter = {
60903       title: "intro.areas.title"
60904     };
60905     function timeout2(f2, t2) {
60906       timeouts.push(window.setTimeout(f2, t2));
60907     }
60908     function eventCancel(d3_event) {
60909       d3_event.stopPropagation();
60910       d3_event.preventDefault();
60911     }
60912     function revealPlayground(center, text, options2) {
60913       var padding = 180 * Math.pow(2, context.map().zoom() - 19.5);
60914       var box = pad(center, padding, context);
60915       reveal(box, text, options2);
60916     }
60917     function addArea() {
60918       context.enter(modeBrowse(context));
60919       context.history().reset("initial");
60920       _areaID = null;
60921       var msec = transitionTime(playground, context.map().center());
60922       if (msec) {
60923         reveal(null, null, { duration: 0 });
60924       }
60925       context.map().centerZoomEase(playground, 19, msec);
60926       timeout2(function() {
60927         var tooltip = reveal(
60928           "button.add-area",
60929           helpHtml("intro.areas.add_playground")
60930         );
60931         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas");
60932         context.on("enter.intro", function(mode) {
60933           if (mode.id !== "add-area")
60934             return;
60935           continueTo(startPlayground);
60936         });
60937       }, msec + 100);
60938       function continueTo(nextStep) {
60939         context.on("enter.intro", null);
60940         nextStep();
60941       }
60942     }
60943     function startPlayground() {
60944       if (context.mode().id !== "add-area") {
60945         return chapter.restart();
60946       }
60947       _areaID = null;
60948       context.map().zoomEase(19.5, 500);
60949       timeout2(function() {
60950         var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap";
60951         var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId);
60952         revealPlayground(
60953           playground,
60954           startDrawString,
60955           { duration: 250 }
60956         );
60957         timeout2(function() {
60958           context.map().on("move.intro drawn.intro", function() {
60959             revealPlayground(
60960               playground,
60961               startDrawString,
60962               { duration: 0 }
60963             );
60964           });
60965           context.on("enter.intro", function(mode) {
60966             if (mode.id !== "draw-area")
60967               return chapter.restart();
60968             continueTo(continuePlayground);
60969           });
60970         }, 250);
60971       }, 550);
60972       function continueTo(nextStep) {
60973         context.map().on("move.intro drawn.intro", null);
60974         context.on("enter.intro", null);
60975         nextStep();
60976       }
60977     }
60978     function continuePlayground() {
60979       if (context.mode().id !== "draw-area") {
60980         return chapter.restart();
60981       }
60982       _areaID = null;
60983       revealPlayground(
60984         playground,
60985         helpHtml("intro.areas.continue_playground"),
60986         { duration: 250 }
60987       );
60988       timeout2(function() {
60989         context.map().on("move.intro drawn.intro", function() {
60990           revealPlayground(
60991             playground,
60992             helpHtml("intro.areas.continue_playground"),
60993             { duration: 0 }
60994           );
60995         });
60996       }, 250);
60997       context.on("enter.intro", function(mode) {
60998         if (mode.id === "draw-area") {
60999           var entity = context.hasEntity(context.selectedIDs()[0]);
61000           if (entity && entity.nodes.length >= 6) {
61001             return continueTo(finishPlayground);
61002           } else {
61003             return;
61004           }
61005         } else if (mode.id === "select") {
61006           _areaID = context.selectedIDs()[0];
61007           return continueTo(searchPresets);
61008         } else {
61009           return chapter.restart();
61010         }
61011       });
61012       function continueTo(nextStep) {
61013         context.map().on("move.intro drawn.intro", null);
61014         context.on("enter.intro", null);
61015         nextStep();
61016       }
61017     }
61018     function finishPlayground() {
61019       if (context.mode().id !== "draw-area") {
61020         return chapter.restart();
61021       }
61022       _areaID = null;
61023       var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground");
61024       revealPlayground(
61025         playground,
61026         finishString,
61027         { duration: 250 }
61028       );
61029       timeout2(function() {
61030         context.map().on("move.intro drawn.intro", function() {
61031           revealPlayground(
61032             playground,
61033             finishString,
61034             { duration: 0 }
61035           );
61036         });
61037       }, 250);
61038       context.on("enter.intro", function(mode) {
61039         if (mode.id === "draw-area") {
61040           return;
61041         } else if (mode.id === "select") {
61042           _areaID = context.selectedIDs()[0];
61043           return continueTo(searchPresets);
61044         } else {
61045           return chapter.restart();
61046         }
61047       });
61048       function continueTo(nextStep) {
61049         context.map().on("move.intro drawn.intro", null);
61050         context.on("enter.intro", null);
61051         nextStep();
61052       }
61053     }
61054     function searchPresets() {
61055       if (!_areaID || !context.hasEntity(_areaID)) {
61056         return addArea();
61057       }
61058       var ids = context.selectedIDs();
61059       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61060         context.enter(modeSelect(context, [_areaID]));
61061       }
61062       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61063       timeout2(function() {
61064         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61065         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61066         reveal(
61067           ".preset-search-input",
61068           helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61069         );
61070       }, 400);
61071       context.on("enter.intro", function(mode) {
61072         if (!_areaID || !context.hasEntity(_areaID)) {
61073           return continueTo(addArea);
61074         }
61075         var ids2 = context.selectedIDs();
61076         if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) {
61077           context.enter(modeSelect(context, [_areaID]));
61078           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61079           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61080           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61081           reveal(
61082             ".preset-search-input",
61083             helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61084           );
61085           context.history().on("change.intro", null);
61086         }
61087       });
61088       function checkPresetSearch() {
61089         var first = context.container().select(".preset-list-item:first-child");
61090         if (first.classed("preset-leisure-playground")) {
61091           reveal(
61092             first.select(".preset-list-button").node(),
61093             helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }),
61094             { duration: 300 }
61095           );
61096           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
61097           context.history().on("change.intro", function() {
61098             continueTo(clickAddField);
61099           });
61100         }
61101       }
61102       function continueTo(nextStep) {
61103         context.container().select(".inspector-wrap").on("wheel.intro", null);
61104         context.on("enter.intro", null);
61105         context.history().on("change.intro", null);
61106         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61107         nextStep();
61108       }
61109     }
61110     function clickAddField() {
61111       if (!_areaID || !context.hasEntity(_areaID)) {
61112         return addArea();
61113       }
61114       var ids = context.selectedIDs();
61115       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61116         return searchPresets();
61117       }
61118       if (!context.container().select(".form-field-description").empty()) {
61119         return continueTo(describePlayground);
61120       }
61121       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61122       timeout2(function() {
61123         context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61124         var entity = context.entity(_areaID);
61125         if (entity.tags.description) {
61126           return continueTo(play);
61127         }
61128         var box = context.container().select(".more-fields").node().getBoundingClientRect();
61129         if (box.top > 300) {
61130           var pane = context.container().select(".entity-editor-pane .inspector-body");
61131           var start2 = pane.node().scrollTop;
61132           var end = start2 + (box.top - 300);
61133           pane.transition().duration(250).tween("scroll.inspector", function() {
61134             var node = this;
61135             var i3 = number_default(start2, end);
61136             return function(t2) {
61137               node.scrollTop = i3(t2);
61138             };
61139           });
61140         }
61141         timeout2(function() {
61142           reveal(
61143             ".more-fields .combobox-input",
61144             helpHtml("intro.areas.add_field", {
61145               name: nameField.title(),
61146               description: descriptionField.title()
61147             }),
61148             { duration: 300 }
61149           );
61150           context.container().select(".more-fields .combobox-input").on("click.intro", function() {
61151             var watcher;
61152             watcher = window.setInterval(function() {
61153               if (!context.container().select("div.combobox").empty()) {
61154                 window.clearInterval(watcher);
61155                 continueTo(chooseDescriptionField);
61156               }
61157             }, 300);
61158           });
61159         }, 300);
61160       }, 400);
61161       context.on("exit.intro", function() {
61162         return continueTo(searchPresets);
61163       });
61164       function continueTo(nextStep) {
61165         context.container().select(".inspector-wrap").on("wheel.intro", null);
61166         context.container().select(".more-fields .combobox-input").on("click.intro", null);
61167         context.on("exit.intro", null);
61168         nextStep();
61169       }
61170     }
61171     function chooseDescriptionField() {
61172       if (!_areaID || !context.hasEntity(_areaID)) {
61173         return addArea();
61174       }
61175       var ids = context.selectedIDs();
61176       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61177         return searchPresets();
61178       }
61179       if (!context.container().select(".form-field-description").empty()) {
61180         return continueTo(describePlayground);
61181       }
61182       if (context.container().select("div.combobox").empty()) {
61183         return continueTo(clickAddField);
61184       }
61185       var watcher;
61186       watcher = window.setInterval(function() {
61187         if (context.container().select("div.combobox").empty()) {
61188           window.clearInterval(watcher);
61189           timeout2(function() {
61190             if (context.container().select(".form-field-description").empty()) {
61191               continueTo(retryChooseDescription);
61192             } else {
61193               continueTo(describePlayground);
61194             }
61195           }, 300);
61196         }
61197       }, 300);
61198       reveal(
61199         "div.combobox",
61200         helpHtml("intro.areas.choose_field", { field: descriptionField.title() }),
61201         { duration: 300 }
61202       );
61203       context.on("exit.intro", function() {
61204         return continueTo(searchPresets);
61205       });
61206       function continueTo(nextStep) {
61207         if (watcher)
61208           window.clearInterval(watcher);
61209         context.on("exit.intro", null);
61210         nextStep();
61211       }
61212     }
61213     function describePlayground() {
61214       if (!_areaID || !context.hasEntity(_areaID)) {
61215         return addArea();
61216       }
61217       var ids = context.selectedIDs();
61218       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61219         return searchPresets();
61220       }
61221       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61222       if (context.container().select(".form-field-description").empty()) {
61223         return continueTo(retryChooseDescription);
61224       }
61225       context.on("exit.intro", function() {
61226         continueTo(play);
61227       });
61228       reveal(
61229         ".entity-editor-pane",
61230         helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }),
61231         { duration: 300 }
61232       );
61233       function continueTo(nextStep) {
61234         context.on("exit.intro", null);
61235         nextStep();
61236       }
61237     }
61238     function retryChooseDescription() {
61239       if (!_areaID || !context.hasEntity(_areaID)) {
61240         return addArea();
61241       }
61242       var ids = context.selectedIDs();
61243       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61244         return searchPresets();
61245       }
61246       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61247       reveal(
61248         ".entity-editor-pane",
61249         helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }),
61250         {
61251           buttonText: _t.html("intro.ok"),
61252           buttonCallback: function() {
61253             continueTo(clickAddField);
61254           }
61255         }
61256       );
61257       context.on("exit.intro", function() {
61258         return continueTo(searchPresets);
61259       });
61260       function continueTo(nextStep) {
61261         context.on("exit.intro", null);
61262         nextStep();
61263       }
61264     }
61265     function play() {
61266       dispatch14.call("done");
61267       reveal(
61268         ".ideditor",
61269         helpHtml("intro.areas.play", { next: _t("intro.lines.title") }),
61270         {
61271           tooltipBox: ".intro-nav-wrap .chapter-line",
61272           buttonText: _t.html("intro.ok"),
61273           buttonCallback: function() {
61274             reveal(".ideditor");
61275           }
61276         }
61277       );
61278     }
61279     chapter.enter = function() {
61280       addArea();
61281     };
61282     chapter.exit = function() {
61283       timeouts.forEach(window.clearTimeout);
61284       context.on("enter.intro exit.intro", null);
61285       context.map().on("move.intro drawn.intro", null);
61286       context.history().on("change.intro", null);
61287       context.container().select(".inspector-wrap").on("wheel.intro", null);
61288       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61289       context.container().select(".more-fields .combobox-input").on("click.intro", null);
61290     };
61291     chapter.restart = function() {
61292       chapter.exit();
61293       chapter.enter();
61294     };
61295     return utilRebind(chapter, dispatch14, "on");
61296   }
61297
61298   // modules/ui/intro/line.js
61299   function uiIntroLine(context, reveal) {
61300     var dispatch14 = dispatch_default("done");
61301     var timeouts = [];
61302     var _tulipRoadID = null;
61303     var flowerRoadID = "w646";
61304     var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
61305     var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
61306     var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
61307     var roadCategory = _mainPresetIndex.item("category-road_minor");
61308     var residentialPreset = _mainPresetIndex.item("highway/residential");
61309     var woodRoadID = "w525";
61310     var woodRoadEndID = "n2862";
61311     var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
61312     var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
61313     var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
61314     var washingtonStreetID = "w522";
61315     var twelfthAvenueID = "w1";
61316     var eleventhAvenueEndID = "n3550";
61317     var twelfthAvenueEndID = "n5";
61318     var _washingtonSegmentID = null;
61319     var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
61320     var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
61321     var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
61322     var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
61323     var chapter = {
61324       title: "intro.lines.title"
61325     };
61326     function timeout2(f2, t2) {
61327       timeouts.push(window.setTimeout(f2, t2));
61328     }
61329     function eventCancel(d3_event) {
61330       d3_event.stopPropagation();
61331       d3_event.preventDefault();
61332     }
61333     function addLine() {
61334       context.enter(modeBrowse(context));
61335       context.history().reset("initial");
61336       var msec = transitionTime(tulipRoadStart, context.map().center());
61337       if (msec) {
61338         reveal(null, null, { duration: 0 });
61339       }
61340       context.map().centerZoomEase(tulipRoadStart, 18.5, msec);
61341       timeout2(function() {
61342         var tooltip = reveal(
61343           "button.add-line",
61344           helpHtml("intro.lines.add_line")
61345         );
61346         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines");
61347         context.on("enter.intro", function(mode) {
61348           if (mode.id !== "add-line")
61349             return;
61350           continueTo(startLine);
61351         });
61352       }, msec + 100);
61353       function continueTo(nextStep) {
61354         context.on("enter.intro", null);
61355         nextStep();
61356       }
61357     }
61358     function startLine() {
61359       if (context.mode().id !== "add-line")
61360         return chapter.restart();
61361       _tulipRoadID = null;
61362       var padding = 70 * Math.pow(2, context.map().zoom() - 18);
61363       var box = pad(tulipRoadStart, padding, context);
61364       box.height = box.height + 100;
61365       var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap";
61366       var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId);
61367       reveal(box, startLineString);
61368       context.map().on("move.intro drawn.intro", function() {
61369         padding = 70 * Math.pow(2, context.map().zoom() - 18);
61370         box = pad(tulipRoadStart, padding, context);
61371         box.height = box.height + 100;
61372         reveal(box, startLineString, { duration: 0 });
61373       });
61374       context.on("enter.intro", function(mode) {
61375         if (mode.id !== "draw-line")
61376           return chapter.restart();
61377         continueTo(drawLine);
61378       });
61379       function continueTo(nextStep) {
61380         context.map().on("move.intro drawn.intro", null);
61381         context.on("enter.intro", null);
61382         nextStep();
61383       }
61384     }
61385     function drawLine() {
61386       if (context.mode().id !== "draw-line")
61387         return chapter.restart();
61388       _tulipRoadID = context.mode().selectedIDs()[0];
61389       context.map().centerEase(tulipRoadMidpoint, 500);
61390       timeout2(function() {
61391         var padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61392         var box = pad(tulipRoadMidpoint, padding, context);
61393         box.height = box.height * 2;
61394         reveal(
61395           box,
61396           helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") })
61397         );
61398         context.map().on("move.intro drawn.intro", function() {
61399           padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61400           box = pad(tulipRoadMidpoint, padding, context);
61401           box.height = box.height * 2;
61402           reveal(
61403             box,
61404             helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }),
61405             { duration: 0 }
61406           );
61407         });
61408       }, 550);
61409       context.history().on("change.intro", function() {
61410         if (isLineConnected()) {
61411           continueTo(continueLine);
61412         }
61413       });
61414       context.on("enter.intro", function(mode) {
61415         if (mode.id === "draw-line") {
61416           return;
61417         } else if (mode.id === "select") {
61418           continueTo(retryIntersect);
61419           return;
61420         } else {
61421           return chapter.restart();
61422         }
61423       });
61424       function continueTo(nextStep) {
61425         context.map().on("move.intro drawn.intro", null);
61426         context.history().on("change.intro", null);
61427         context.on("enter.intro", null);
61428         nextStep();
61429       }
61430     }
61431     function isLineConnected() {
61432       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61433       if (!entity)
61434         return false;
61435       var drawNodes = context.graph().childNodes(entity);
61436       return drawNodes.some(function(node) {
61437         return context.graph().parentWays(node).some(function(parent) {
61438           return parent.id === flowerRoadID;
61439         });
61440       });
61441     }
61442     function retryIntersect() {
61443       select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true);
61444       var box = pad(tulipRoadIntersection, 80, context);
61445       reveal(
61446         box,
61447         helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") })
61448       );
61449       timeout2(chapter.restart, 3e3);
61450     }
61451     function continueLine() {
61452       if (context.mode().id !== "draw-line")
61453         return chapter.restart();
61454       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61455       if (!entity)
61456         return chapter.restart();
61457       context.map().centerEase(tulipRoadIntersection, 500);
61458       var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road");
61459       reveal(".surface", continueLineText);
61460       context.on("enter.intro", function(mode) {
61461         if (mode.id === "draw-line") {
61462           return;
61463         } else if (mode.id === "select") {
61464           return continueTo(chooseCategoryRoad);
61465         } else {
61466           return chapter.restart();
61467         }
61468       });
61469       function continueTo(nextStep) {
61470         context.on("enter.intro", null);
61471         nextStep();
61472       }
61473     }
61474     function chooseCategoryRoad() {
61475       if (context.mode().id !== "select")
61476         return chapter.restart();
61477       context.on("exit.intro", function() {
61478         return chapter.restart();
61479       });
61480       var button = context.container().select(".preset-category-road_minor .preset-list-button");
61481       if (button.empty())
61482         return chapter.restart();
61483       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61484       timeout2(function() {
61485         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61486         reveal(
61487           button.node(),
61488           helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() })
61489         );
61490         button.on("click.intro", function() {
61491           continueTo(choosePresetResidential);
61492         });
61493       }, 400);
61494       function continueTo(nextStep) {
61495         context.container().select(".inspector-wrap").on("wheel.intro", null);
61496         context.container().select(".preset-list-button").on("click.intro", null);
61497         context.on("exit.intro", null);
61498         nextStep();
61499       }
61500     }
61501     function choosePresetResidential() {
61502       if (context.mode().id !== "select")
61503         return chapter.restart();
61504       context.on("exit.intro", function() {
61505         return chapter.restart();
61506       });
61507       var subgrid = context.container().select(".preset-category-road_minor .subgrid");
61508       if (subgrid.empty())
61509         return chapter.restart();
61510       subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() {
61511         continueTo(retryPresetResidential);
61512       });
61513       subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() {
61514         continueTo(nameRoad);
61515       });
61516       timeout2(function() {
61517         reveal(
61518           subgrid.node(),
61519           helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }),
61520           { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 }
61521         );
61522       }, 300);
61523       function continueTo(nextStep) {
61524         context.container().select(".preset-list-button").on("click.intro", null);
61525         context.on("exit.intro", null);
61526         nextStep();
61527       }
61528     }
61529     function retryPresetResidential() {
61530       if (context.mode().id !== "select")
61531         return chapter.restart();
61532       context.on("exit.intro", function() {
61533         return chapter.restart();
61534       });
61535       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61536       timeout2(function() {
61537         var button = context.container().select(".entity-editor-pane .preset-list-button");
61538         reveal(
61539           button.node(),
61540           helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() })
61541         );
61542         button.on("click.intro", function() {
61543           continueTo(chooseCategoryRoad);
61544         });
61545       }, 500);
61546       function continueTo(nextStep) {
61547         context.container().select(".inspector-wrap").on("wheel.intro", null);
61548         context.container().select(".preset-list-button").on("click.intro", null);
61549         context.on("exit.intro", null);
61550         nextStep();
61551       }
61552     }
61553     function nameRoad() {
61554       context.on("exit.intro", function() {
61555         continueTo(didNameRoad);
61556       });
61557       timeout2(function() {
61558         reveal(
61559           ".entity-editor-pane",
61560           helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }),
61561           { tooltipClass: "intro-lines-name_road" }
61562         );
61563       }, 500);
61564       function continueTo(nextStep) {
61565         context.on("exit.intro", null);
61566         nextStep();
61567       }
61568     }
61569     function didNameRoad() {
61570       context.history().checkpoint("doneAddLine");
61571       timeout2(function() {
61572         reveal(".surface", helpHtml("intro.lines.did_name_road"), {
61573           buttonText: _t.html("intro.ok"),
61574           buttonCallback: function() {
61575             continueTo(updateLine);
61576           }
61577         });
61578       }, 500);
61579       function continueTo(nextStep) {
61580         nextStep();
61581       }
61582     }
61583     function updateLine() {
61584       context.history().reset("doneAddLine");
61585       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61586         return chapter.restart();
61587       }
61588       var msec = transitionTime(woodRoadDragMidpoint, context.map().center());
61589       if (msec) {
61590         reveal(null, null, { duration: 0 });
61591       }
61592       context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec);
61593       timeout2(function() {
61594         var padding = 250 * Math.pow(2, context.map().zoom() - 19);
61595         var box = pad(woodRoadDragMidpoint, padding, context);
61596         var advance = function() {
61597           continueTo(addNode);
61598         };
61599         reveal(
61600           box,
61601           helpHtml("intro.lines.update_line"),
61602           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61603         );
61604         context.map().on("move.intro drawn.intro", function() {
61605           var padding2 = 250 * Math.pow(2, context.map().zoom() - 19);
61606           var box2 = pad(woodRoadDragMidpoint, padding2, context);
61607           reveal(
61608             box2,
61609             helpHtml("intro.lines.update_line"),
61610             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61611           );
61612         });
61613       }, msec + 100);
61614       function continueTo(nextStep) {
61615         context.map().on("move.intro drawn.intro", null);
61616         nextStep();
61617       }
61618     }
61619     function addNode() {
61620       context.history().reset("doneAddLine");
61621       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61622         return chapter.restart();
61623       }
61624       var padding = 40 * Math.pow(2, context.map().zoom() - 19);
61625       var box = pad(woodRoadAddNode, padding, context);
61626       var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61627       reveal(box, addNodeString);
61628       context.map().on("move.intro drawn.intro", function() {
61629         var padding2 = 40 * Math.pow(2, context.map().zoom() - 19);
61630         var box2 = pad(woodRoadAddNode, padding2, context);
61631         reveal(box2, addNodeString, { duration: 0 });
61632       });
61633       context.history().on("change.intro", function(changed) {
61634         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61635           return continueTo(updateLine);
61636         }
61637         if (changed.created().length === 1) {
61638           timeout2(function() {
61639             continueTo(startDragEndpoint);
61640           }, 500);
61641         }
61642       });
61643       context.on("enter.intro", function(mode) {
61644         if (mode.id !== "select") {
61645           continueTo(updateLine);
61646         }
61647       });
61648       function continueTo(nextStep) {
61649         context.map().on("move.intro drawn.intro", null);
61650         context.history().on("change.intro", null);
61651         context.on("enter.intro", null);
61652         nextStep();
61653       }
61654     }
61655     function startDragEndpoint() {
61656       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61657         return continueTo(updateLine);
61658       }
61659       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61660       var box = pad(woodRoadDragEndpoint, padding, context);
61661       var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection");
61662       reveal(box, startDragString);
61663       context.map().on("move.intro drawn.intro", function() {
61664         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61665           return continueTo(updateLine);
61666         }
61667         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61668         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61669         reveal(box2, startDragString, { duration: 0 });
61670         var entity = context.entity(woodRoadEndID);
61671         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
61672           continueTo(finishDragEndpoint);
61673         }
61674       });
61675       function continueTo(nextStep) {
61676         context.map().on("move.intro drawn.intro", null);
61677         nextStep();
61678       }
61679     }
61680     function finishDragEndpoint() {
61681       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61682         return continueTo(updateLine);
61683       }
61684       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61685       var box = pad(woodRoadDragEndpoint, padding, context);
61686       var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61687       reveal(box, finishDragString);
61688       context.map().on("move.intro drawn.intro", function() {
61689         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61690           return continueTo(updateLine);
61691         }
61692         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61693         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61694         reveal(box2, finishDragString, { duration: 0 });
61695         var entity = context.entity(woodRoadEndID);
61696         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
61697           continueTo(startDragEndpoint);
61698         }
61699       });
61700       context.on("enter.intro", function() {
61701         continueTo(startDragMidpoint);
61702       });
61703       function continueTo(nextStep) {
61704         context.map().on("move.intro drawn.intro", null);
61705         context.on("enter.intro", null);
61706         nextStep();
61707       }
61708     }
61709     function startDragMidpoint() {
61710       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61711         return continueTo(updateLine);
61712       }
61713       if (context.selectedIDs().indexOf(woodRoadID) === -1) {
61714         context.enter(modeSelect(context, [woodRoadID]));
61715       }
61716       var padding = 80 * Math.pow(2, context.map().zoom() - 19);
61717       var box = pad(woodRoadDragMidpoint, padding, context);
61718       reveal(box, helpHtml("intro.lines.start_drag_midpoint"));
61719       context.map().on("move.intro drawn.intro", function() {
61720         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61721           return continueTo(updateLine);
61722         }
61723         var padding2 = 80 * Math.pow(2, context.map().zoom() - 19);
61724         var box2 = pad(woodRoadDragMidpoint, padding2, context);
61725         reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 });
61726       });
61727       context.history().on("change.intro", function(changed) {
61728         if (changed.created().length === 1) {
61729           continueTo(continueDragMidpoint);
61730         }
61731       });
61732       context.on("enter.intro", function(mode) {
61733         if (mode.id !== "select") {
61734           context.enter(modeSelect(context, [woodRoadID]));
61735         }
61736       });
61737       function continueTo(nextStep) {
61738         context.map().on("move.intro drawn.intro", null);
61739         context.history().on("change.intro", null);
61740         context.on("enter.intro", null);
61741         nextStep();
61742       }
61743     }
61744     function continueDragMidpoint() {
61745       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61746         return continueTo(updateLine);
61747       }
61748       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61749       var box = pad(woodRoadDragEndpoint, padding, context);
61750       box.height += 400;
61751       var advance = function() {
61752         context.history().checkpoint("doneUpdateLine");
61753         continueTo(deleteLines);
61754       };
61755       reveal(
61756         box,
61757         helpHtml("intro.lines.continue_drag_midpoint"),
61758         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61759       );
61760       context.map().on("move.intro drawn.intro", function() {
61761         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61762           return continueTo(updateLine);
61763         }
61764         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61765         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61766         box2.height += 400;
61767         reveal(
61768           box2,
61769           helpHtml("intro.lines.continue_drag_midpoint"),
61770           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61771         );
61772       });
61773       function continueTo(nextStep) {
61774         context.map().on("move.intro drawn.intro", null);
61775         nextStep();
61776       }
61777     }
61778     function deleteLines() {
61779       context.history().reset("doneUpdateLine");
61780       context.enter(modeBrowse(context));
61781       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61782         return chapter.restart();
61783       }
61784       var msec = transitionTime(deleteLinesLoc, context.map().center());
61785       if (msec) {
61786         reveal(null, null, { duration: 0 });
61787       }
61788       context.map().centerZoomEase(deleteLinesLoc, 18, msec);
61789       timeout2(function() {
61790         var padding = 200 * Math.pow(2, context.map().zoom() - 18);
61791         var box = pad(deleteLinesLoc, padding, context);
61792         box.top -= 200;
61793         box.height += 400;
61794         var advance = function() {
61795           continueTo(rightClickIntersection);
61796         };
61797         reveal(
61798           box,
61799           helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61800           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61801         );
61802         context.map().on("move.intro drawn.intro", function() {
61803           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
61804           var box2 = pad(deleteLinesLoc, padding2, context);
61805           box2.top -= 200;
61806           box2.height += 400;
61807           reveal(
61808             box2,
61809             helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61810             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61811           );
61812         });
61813         context.history().on("change.intro", function() {
61814           timeout2(function() {
61815             continueTo(deleteLines);
61816           }, 500);
61817         });
61818       }, msec + 100);
61819       function continueTo(nextStep) {
61820         context.map().on("move.intro drawn.intro", null);
61821         context.history().on("change.intro", null);
61822         nextStep();
61823       }
61824     }
61825     function rightClickIntersection() {
61826       context.history().reset("doneUpdateLine");
61827       context.enter(modeBrowse(context));
61828       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61829       var rightClickString = helpHtml("intro.lines.split_street", {
61830         street1: _t("intro.graph.name.11th-avenue"),
61831         street2: _t("intro.graph.name.washington-street")
61832       }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch"));
61833       timeout2(function() {
61834         var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61835         var box = pad(eleventhAvenueEnd, padding, context);
61836         reveal(box, rightClickString);
61837         context.map().on("move.intro drawn.intro", function() {
61838           var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61839           var box2 = pad(eleventhAvenueEnd, padding2, context);
61840           reveal(
61841             box2,
61842             rightClickString,
61843             { duration: 0 }
61844           );
61845         });
61846         context.on("enter.intro", function(mode) {
61847           if (mode.id !== "select")
61848             return;
61849           var ids = context.selectedIDs();
61850           if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID)
61851             return;
61852           timeout2(function() {
61853             var node = selectMenuItem(context, "split").node();
61854             if (!node)
61855               return;
61856             continueTo(splitIntersection);
61857           }, 50);
61858         });
61859         context.history().on("change.intro", function() {
61860           timeout2(function() {
61861             continueTo(deleteLines);
61862           }, 300);
61863         });
61864       }, 600);
61865       function continueTo(nextStep) {
61866         context.map().on("move.intro drawn.intro", null);
61867         context.on("enter.intro", null);
61868         context.history().on("change.intro", null);
61869         nextStep();
61870       }
61871     }
61872     function splitIntersection() {
61873       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61874         return continueTo(deleteLines);
61875       }
61876       var node = selectMenuItem(context, "split").node();
61877       if (!node) {
61878         return continueTo(rightClickIntersection);
61879       }
61880       var wasChanged = false;
61881       _washingtonSegmentID = null;
61882       reveal(
61883         ".edit-menu",
61884         helpHtml(
61885           "intro.lines.split_intersection",
61886           { street: _t("intro.graph.name.washington-street") }
61887         ),
61888         { padding: 50 }
61889       );
61890       context.map().on("move.intro drawn.intro", function() {
61891         var node2 = selectMenuItem(context, "split").node();
61892         if (!wasChanged && !node2) {
61893           return continueTo(rightClickIntersection);
61894         }
61895         reveal(
61896           ".edit-menu",
61897           helpHtml(
61898             "intro.lines.split_intersection",
61899             { street: _t("intro.graph.name.washington-street") }
61900           ),
61901           { duration: 0, padding: 50 }
61902         );
61903       });
61904       context.history().on("change.intro", function(changed) {
61905         wasChanged = true;
61906         timeout2(function() {
61907           if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) {
61908             _washingtonSegmentID = changed.created()[0].id;
61909             continueTo(didSplit);
61910           } else {
61911             _washingtonSegmentID = null;
61912             continueTo(retrySplit);
61913           }
61914         }, 300);
61915       });
61916       function continueTo(nextStep) {
61917         context.map().on("move.intro drawn.intro", null);
61918         context.history().on("change.intro", null);
61919         nextStep();
61920       }
61921     }
61922     function retrySplit() {
61923       context.enter(modeBrowse(context));
61924       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61925       var advance = function() {
61926         continueTo(rightClickIntersection);
61927       };
61928       var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61929       var box = pad(eleventhAvenueEnd, padding, context);
61930       reveal(
61931         box,
61932         helpHtml("intro.lines.retry_split"),
61933         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61934       );
61935       context.map().on("move.intro drawn.intro", function() {
61936         var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61937         var box2 = pad(eleventhAvenueEnd, padding2, context);
61938         reveal(
61939           box2,
61940           helpHtml("intro.lines.retry_split"),
61941           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61942         );
61943       });
61944       function continueTo(nextStep) {
61945         context.map().on("move.intro drawn.intro", null);
61946         nextStep();
61947       }
61948     }
61949     function didSplit() {
61950       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61951         return continueTo(rightClickIntersection);
61952       }
61953       var ids = context.selectedIDs();
61954       var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single");
61955       var street = _t("intro.graph.name.washington-street");
61956       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
61957       var box = pad(twelfthAvenue, padding, context);
61958       box.width = box.width / 2;
61959       reveal(
61960         box,
61961         helpHtml(string, { street1: street, street2: street }),
61962         { duration: 500 }
61963       );
61964       timeout2(function() {
61965         context.map().centerZoomEase(twelfthAvenue, 18, 500);
61966         context.map().on("move.intro drawn.intro", function() {
61967           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
61968           var box2 = pad(twelfthAvenue, padding2, context);
61969           box2.width = box2.width / 2;
61970           reveal(
61971             box2,
61972             helpHtml(string, { street1: street, street2: street }),
61973             { duration: 0 }
61974           );
61975         });
61976       }, 600);
61977       context.on("enter.intro", function() {
61978         var ids2 = context.selectedIDs();
61979         if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) {
61980           continueTo(multiSelect);
61981         }
61982       });
61983       context.history().on("change.intro", function() {
61984         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61985           return continueTo(rightClickIntersection);
61986         }
61987       });
61988       function continueTo(nextStep) {
61989         context.map().on("move.intro drawn.intro", null);
61990         context.on("enter.intro", null);
61991         context.history().on("change.intro", null);
61992         nextStep();
61993       }
61994     }
61995     function multiSelect() {
61996       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61997         return continueTo(rightClickIntersection);
61998       }
61999       var ids = context.selectedIDs();
62000       var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
62001       var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
62002       if (hasWashington && hasTwelfth) {
62003         return continueTo(multiRightClick);
62004       } else if (!hasWashington && !hasTwelfth) {
62005         return continueTo(didSplit);
62006       }
62007       context.map().centerZoomEase(twelfthAvenue, 18, 500);
62008       timeout2(function() {
62009         var selected, other, padding, box;
62010         if (hasWashington) {
62011           selected = _t("intro.graph.name.washington-street");
62012           other = _t("intro.graph.name.12th-avenue");
62013           padding = 60 * Math.pow(2, context.map().zoom() - 18);
62014           box = pad(twelfthAvenueEnd, padding, context);
62015           box.width *= 3;
62016         } else {
62017           selected = _t("intro.graph.name.12th-avenue");
62018           other = _t("intro.graph.name.washington-street");
62019           padding = 200 * Math.pow(2, context.map().zoom() - 18);
62020           box = pad(twelfthAvenue, padding, context);
62021           box.width /= 2;
62022         }
62023         reveal(
62024           box,
62025           helpHtml(
62026             "intro.lines.multi_select",
62027             { selected, other1: other }
62028           ) + " " + helpHtml(
62029             "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62030             { selected, other2: other }
62031           )
62032         );
62033         context.map().on("move.intro drawn.intro", function() {
62034           if (hasWashington) {
62035             selected = _t("intro.graph.name.washington-street");
62036             other = _t("intro.graph.name.12th-avenue");
62037             padding = 60 * Math.pow(2, context.map().zoom() - 18);
62038             box = pad(twelfthAvenueEnd, padding, context);
62039             box.width *= 3;
62040           } else {
62041             selected = _t("intro.graph.name.12th-avenue");
62042             other = _t("intro.graph.name.washington-street");
62043             padding = 200 * Math.pow(2, context.map().zoom() - 18);
62044             box = pad(twelfthAvenue, padding, context);
62045             box.width /= 2;
62046           }
62047           reveal(
62048             box,
62049             helpHtml(
62050               "intro.lines.multi_select",
62051               { selected, other1: other }
62052             ) + " " + helpHtml(
62053               "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62054               { selected, other2: other }
62055             ),
62056             { duration: 0 }
62057           );
62058         });
62059         context.on("enter.intro", function() {
62060           continueTo(multiSelect);
62061         });
62062         context.history().on("change.intro", function() {
62063           if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62064             return continueTo(rightClickIntersection);
62065           }
62066         });
62067       }, 600);
62068       function continueTo(nextStep) {
62069         context.map().on("move.intro drawn.intro", null);
62070         context.on("enter.intro", null);
62071         context.history().on("change.intro", null);
62072         nextStep();
62073       }
62074     }
62075     function multiRightClick() {
62076       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62077         return continueTo(rightClickIntersection);
62078       }
62079       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62080       var box = pad(twelfthAvenue, padding, context);
62081       var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"));
62082       reveal(box, rightClickString);
62083       context.map().on("move.intro drawn.intro", function() {
62084         var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
62085         var box2 = pad(twelfthAvenue, padding2, context);
62086         reveal(box2, rightClickString, { duration: 0 });
62087       });
62088       context.ui().editMenu().on("toggled.intro", function(open) {
62089         if (!open)
62090           return;
62091         timeout2(function() {
62092           var ids = context.selectedIDs();
62093           if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62094             var node = selectMenuItem(context, "delete").node();
62095             if (!node)
62096               return;
62097             continueTo(multiDelete);
62098           } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62099             return continueTo(multiSelect);
62100           } else {
62101             return continueTo(didSplit);
62102           }
62103         }, 300);
62104       });
62105       context.history().on("change.intro", function() {
62106         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62107           return continueTo(rightClickIntersection);
62108         }
62109       });
62110       function continueTo(nextStep) {
62111         context.map().on("move.intro drawn.intro", null);
62112         context.ui().editMenu().on("toggled.intro", null);
62113         context.history().on("change.intro", null);
62114         nextStep();
62115       }
62116     }
62117     function multiDelete() {
62118       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62119         return continueTo(rightClickIntersection);
62120       }
62121       var node = selectMenuItem(context, "delete").node();
62122       if (!node)
62123         return continueTo(multiRightClick);
62124       reveal(
62125         ".edit-menu",
62126         helpHtml("intro.lines.multi_delete"),
62127         { padding: 50 }
62128       );
62129       context.map().on("move.intro drawn.intro", function() {
62130         reveal(
62131           ".edit-menu",
62132           helpHtml("intro.lines.multi_delete"),
62133           { duration: 0, padding: 50 }
62134         );
62135       });
62136       context.on("exit.intro", function() {
62137         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62138           return continueTo(multiSelect);
62139         }
62140       });
62141       context.history().on("change.intro", function() {
62142         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62143           continueTo(retryDelete);
62144         } else {
62145           continueTo(play);
62146         }
62147       });
62148       function continueTo(nextStep) {
62149         context.map().on("move.intro drawn.intro", null);
62150         context.on("exit.intro", null);
62151         context.history().on("change.intro", null);
62152         nextStep();
62153       }
62154     }
62155     function retryDelete() {
62156       context.enter(modeBrowse(context));
62157       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62158       var box = pad(twelfthAvenue, padding, context);
62159       reveal(box, helpHtml("intro.lines.retry_delete"), {
62160         buttonText: _t.html("intro.ok"),
62161         buttonCallback: function() {
62162           continueTo(multiSelect);
62163         }
62164       });
62165       function continueTo(nextStep) {
62166         nextStep();
62167       }
62168     }
62169     function play() {
62170       dispatch14.call("done");
62171       reveal(
62172         ".ideditor",
62173         helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }),
62174         {
62175           tooltipBox: ".intro-nav-wrap .chapter-building",
62176           buttonText: _t.html("intro.ok"),
62177           buttonCallback: function() {
62178             reveal(".ideditor");
62179           }
62180         }
62181       );
62182     }
62183     chapter.enter = function() {
62184       addLine();
62185     };
62186     chapter.exit = function() {
62187       timeouts.forEach(window.clearTimeout);
62188       select_default2(window).on("pointerdown.intro mousedown.intro", null, true);
62189       context.on("enter.intro exit.intro", null);
62190       context.map().on("move.intro drawn.intro", null);
62191       context.history().on("change.intro", null);
62192       context.container().select(".inspector-wrap").on("wheel.intro", null);
62193       context.container().select(".preset-list-button").on("click.intro", null);
62194     };
62195     chapter.restart = function() {
62196       chapter.exit();
62197       chapter.enter();
62198     };
62199     return utilRebind(chapter, dispatch14, "on");
62200   }
62201
62202   // modules/ui/intro/building.js
62203   function uiIntroBuilding(context, reveal) {
62204     var dispatch14 = dispatch_default("done");
62205     var house = [-85.62815, 41.95638];
62206     var tank = [-85.62732, 41.95347];
62207     var buildingCatetory = _mainPresetIndex.item("category-building");
62208     var housePreset = _mainPresetIndex.item("building/house");
62209     var tankPreset = _mainPresetIndex.item("man_made/storage_tank");
62210     var timeouts = [];
62211     var _houseID = null;
62212     var _tankID = null;
62213     var chapter = {
62214       title: "intro.buildings.title"
62215     };
62216     function timeout2(f2, t2) {
62217       timeouts.push(window.setTimeout(f2, t2));
62218     }
62219     function eventCancel(d3_event) {
62220       d3_event.stopPropagation();
62221       d3_event.preventDefault();
62222     }
62223     function revealHouse(center, text, options2) {
62224       var padding = 160 * Math.pow(2, context.map().zoom() - 20);
62225       var box = pad(center, padding, context);
62226       reveal(box, text, options2);
62227     }
62228     function revealTank(center, text, options2) {
62229       var padding = 190 * Math.pow(2, context.map().zoom() - 19.5);
62230       var box = pad(center, padding, context);
62231       reveal(box, text, options2);
62232     }
62233     function addHouse() {
62234       context.enter(modeBrowse(context));
62235       context.history().reset("initial");
62236       _houseID = null;
62237       var msec = transitionTime(house, context.map().center());
62238       if (msec) {
62239         reveal(null, null, { duration: 0 });
62240       }
62241       context.map().centerZoomEase(house, 19, msec);
62242       timeout2(function() {
62243         var tooltip = reveal(
62244           "button.add-area",
62245           helpHtml("intro.buildings.add_building")
62246         );
62247         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings");
62248         context.on("enter.intro", function(mode) {
62249           if (mode.id !== "add-area")
62250             return;
62251           continueTo(startHouse);
62252         });
62253       }, msec + 100);
62254       function continueTo(nextStep) {
62255         context.on("enter.intro", null);
62256         nextStep();
62257       }
62258     }
62259     function startHouse() {
62260       if (context.mode().id !== "add-area") {
62261         return continueTo(addHouse);
62262       }
62263       _houseID = null;
62264       context.map().zoomEase(20, 500);
62265       timeout2(function() {
62266         var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62267         revealHouse(house, startString);
62268         context.map().on("move.intro drawn.intro", function() {
62269           revealHouse(house, startString, { duration: 0 });
62270         });
62271         context.on("enter.intro", function(mode) {
62272           if (mode.id !== "draw-area")
62273             return chapter.restart();
62274           continueTo(continueHouse);
62275         });
62276       }, 550);
62277       function continueTo(nextStep) {
62278         context.map().on("move.intro drawn.intro", null);
62279         context.on("enter.intro", null);
62280         nextStep();
62281       }
62282     }
62283     function continueHouse() {
62284       if (context.mode().id !== "draw-area") {
62285         return continueTo(addHouse);
62286       }
62287       _houseID = null;
62288       var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building");
62289       revealHouse(house, continueString);
62290       context.map().on("move.intro drawn.intro", function() {
62291         revealHouse(house, continueString, { duration: 0 });
62292       });
62293       context.on("enter.intro", function(mode) {
62294         if (mode.id === "draw-area") {
62295           return;
62296         } else if (mode.id === "select") {
62297           var graph = context.graph();
62298           var way = context.entity(context.selectedIDs()[0]);
62299           var nodes = graph.childNodes(way);
62300           var points = utilArrayUniq(nodes).map(function(n3) {
62301             return context.projection(n3.loc);
62302           });
62303           if (isMostlySquare(points)) {
62304             _houseID = way.id;
62305             return continueTo(chooseCategoryBuilding);
62306           } else {
62307             return continueTo(retryHouse);
62308           }
62309         } else {
62310           return chapter.restart();
62311         }
62312       });
62313       function continueTo(nextStep) {
62314         context.map().on("move.intro drawn.intro", null);
62315         context.on("enter.intro", null);
62316         nextStep();
62317       }
62318     }
62319     function retryHouse() {
62320       var onClick = function() {
62321         continueTo(addHouse);
62322       };
62323       revealHouse(
62324         house,
62325         helpHtml("intro.buildings.retry_building"),
62326         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62327       );
62328       context.map().on("move.intro drawn.intro", function() {
62329         revealHouse(
62330           house,
62331           helpHtml("intro.buildings.retry_building"),
62332           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62333         );
62334       });
62335       function continueTo(nextStep) {
62336         context.map().on("move.intro drawn.intro", null);
62337         nextStep();
62338       }
62339     }
62340     function chooseCategoryBuilding() {
62341       if (!_houseID || !context.hasEntity(_houseID)) {
62342         return addHouse();
62343       }
62344       var ids = context.selectedIDs();
62345       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62346         context.enter(modeSelect(context, [_houseID]));
62347       }
62348       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62349       timeout2(function() {
62350         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62351         var button = context.container().select(".preset-category-building .preset-list-button");
62352         reveal(
62353           button.node(),
62354           helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() })
62355         );
62356         button.on("click.intro", function() {
62357           button.on("click.intro", null);
62358           continueTo(choosePresetHouse);
62359         });
62360       }, 400);
62361       context.on("enter.intro", function(mode) {
62362         if (!_houseID || !context.hasEntity(_houseID)) {
62363           return continueTo(addHouse);
62364         }
62365         var ids2 = context.selectedIDs();
62366         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62367           return continueTo(chooseCategoryBuilding);
62368         }
62369       });
62370       function continueTo(nextStep) {
62371         context.container().select(".inspector-wrap").on("wheel.intro", null);
62372         context.container().select(".preset-list-button").on("click.intro", null);
62373         context.on("enter.intro", null);
62374         nextStep();
62375       }
62376     }
62377     function choosePresetHouse() {
62378       if (!_houseID || !context.hasEntity(_houseID)) {
62379         return addHouse();
62380       }
62381       var ids = context.selectedIDs();
62382       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62383         context.enter(modeSelect(context, [_houseID]));
62384       }
62385       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62386       timeout2(function() {
62387         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62388         var button = context.container().select(".preset-building-house .preset-list-button");
62389         reveal(
62390           button.node(),
62391           helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }),
62392           { duration: 300 }
62393         );
62394         button.on("click.intro", function() {
62395           button.on("click.intro", null);
62396           continueTo(closeEditorHouse);
62397         });
62398       }, 400);
62399       context.on("enter.intro", function(mode) {
62400         if (!_houseID || !context.hasEntity(_houseID)) {
62401           return continueTo(addHouse);
62402         }
62403         var ids2 = context.selectedIDs();
62404         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62405           return continueTo(chooseCategoryBuilding);
62406         }
62407       });
62408       function continueTo(nextStep) {
62409         context.container().select(".inspector-wrap").on("wheel.intro", null);
62410         context.container().select(".preset-list-button").on("click.intro", null);
62411         context.on("enter.intro", null);
62412         nextStep();
62413       }
62414     }
62415     function closeEditorHouse() {
62416       if (!_houseID || !context.hasEntity(_houseID)) {
62417         return addHouse();
62418       }
62419       var ids = context.selectedIDs();
62420       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62421         context.enter(modeSelect(context, [_houseID]));
62422       }
62423       context.history().checkpoint("hasHouse");
62424       context.on("exit.intro", function() {
62425         continueTo(rightClickHouse);
62426       });
62427       timeout2(function() {
62428         reveal(
62429           ".entity-editor-pane",
62430           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62431         );
62432       }, 500);
62433       function continueTo(nextStep) {
62434         context.on("exit.intro", null);
62435         nextStep();
62436       }
62437     }
62438     function rightClickHouse() {
62439       if (!_houseID)
62440         return chapter.restart();
62441       context.enter(modeBrowse(context));
62442       context.history().reset("hasHouse");
62443       var zoom = context.map().zoom();
62444       if (zoom < 20) {
62445         zoom = 20;
62446       }
62447       context.map().centerZoomEase(house, zoom, 500);
62448       context.on("enter.intro", function(mode) {
62449         if (mode.id !== "select")
62450           return;
62451         var ids = context.selectedIDs();
62452         if (ids.length !== 1 || ids[0] !== _houseID)
62453           return;
62454         timeout2(function() {
62455           var node = selectMenuItem(context, "orthogonalize").node();
62456           if (!node)
62457             return;
62458           continueTo(clickSquare);
62459         }, 50);
62460       });
62461       context.map().on("move.intro drawn.intro", function() {
62462         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch"));
62463         revealHouse(house, rightclickString, { duration: 0 });
62464       });
62465       context.history().on("change.intro", function() {
62466         continueTo(rightClickHouse);
62467       });
62468       function continueTo(nextStep) {
62469         context.on("enter.intro", null);
62470         context.map().on("move.intro drawn.intro", null);
62471         context.history().on("change.intro", null);
62472         nextStep();
62473       }
62474     }
62475     function clickSquare() {
62476       if (!_houseID)
62477         return chapter.restart();
62478       var entity = context.hasEntity(_houseID);
62479       if (!entity)
62480         return continueTo(rightClickHouse);
62481       var node = selectMenuItem(context, "orthogonalize").node();
62482       if (!node) {
62483         return continueTo(rightClickHouse);
62484       }
62485       var wasChanged = false;
62486       reveal(
62487         ".edit-menu",
62488         helpHtml("intro.buildings.square_building"),
62489         { padding: 50 }
62490       );
62491       context.on("enter.intro", function(mode) {
62492         if (mode.id === "browse") {
62493           continueTo(rightClickHouse);
62494         } else if (mode.id === "move" || mode.id === "rotate") {
62495           continueTo(retryClickSquare);
62496         }
62497       });
62498       context.map().on("move.intro", function() {
62499         var node2 = selectMenuItem(context, "orthogonalize").node();
62500         if (!wasChanged && !node2) {
62501           return continueTo(rightClickHouse);
62502         }
62503         reveal(
62504           ".edit-menu",
62505           helpHtml("intro.buildings.square_building"),
62506           { duration: 0, padding: 50 }
62507         );
62508       });
62509       context.history().on("change.intro", function() {
62510         wasChanged = true;
62511         context.history().on("change.intro", null);
62512         timeout2(function() {
62513           if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) {
62514             continueTo(doneSquare);
62515           } else {
62516             continueTo(retryClickSquare);
62517           }
62518         }, 500);
62519       });
62520       function continueTo(nextStep) {
62521         context.on("enter.intro", null);
62522         context.map().on("move.intro", null);
62523         context.history().on("change.intro", null);
62524         nextStep();
62525       }
62526     }
62527     function retryClickSquare() {
62528       context.enter(modeBrowse(context));
62529       revealHouse(house, helpHtml("intro.buildings.retry_square"), {
62530         buttonText: _t.html("intro.ok"),
62531         buttonCallback: function() {
62532           continueTo(rightClickHouse);
62533         }
62534       });
62535       function continueTo(nextStep) {
62536         nextStep();
62537       }
62538     }
62539     function doneSquare() {
62540       context.history().checkpoint("doneSquare");
62541       revealHouse(house, helpHtml("intro.buildings.done_square"), {
62542         buttonText: _t.html("intro.ok"),
62543         buttonCallback: function() {
62544           continueTo(addTank);
62545         }
62546       });
62547       function continueTo(nextStep) {
62548         nextStep();
62549       }
62550     }
62551     function addTank() {
62552       context.enter(modeBrowse(context));
62553       context.history().reset("doneSquare");
62554       _tankID = null;
62555       var msec = transitionTime(tank, context.map().center());
62556       if (msec) {
62557         reveal(null, null, { duration: 0 });
62558       }
62559       context.map().centerZoomEase(tank, 19.5, msec);
62560       timeout2(function() {
62561         reveal(
62562           "button.add-area",
62563           helpHtml("intro.buildings.add_tank")
62564         );
62565         context.on("enter.intro", function(mode) {
62566           if (mode.id !== "add-area")
62567             return;
62568           continueTo(startTank);
62569         });
62570       }, msec + 100);
62571       function continueTo(nextStep) {
62572         context.on("enter.intro", null);
62573         nextStep();
62574       }
62575     }
62576     function startTank() {
62577       if (context.mode().id !== "add-area") {
62578         return continueTo(addTank);
62579       }
62580       _tankID = null;
62581       timeout2(function() {
62582         var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62583         revealTank(tank, startString);
62584         context.map().on("move.intro drawn.intro", function() {
62585           revealTank(tank, startString, { duration: 0 });
62586         });
62587         context.on("enter.intro", function(mode) {
62588           if (mode.id !== "draw-area")
62589             return chapter.restart();
62590           continueTo(continueTank);
62591         });
62592       }, 550);
62593       function continueTo(nextStep) {
62594         context.map().on("move.intro drawn.intro", null);
62595         context.on("enter.intro", null);
62596         nextStep();
62597       }
62598     }
62599     function continueTank() {
62600       if (context.mode().id !== "draw-area") {
62601         return continueTo(addTank);
62602       }
62603       _tankID = null;
62604       var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank");
62605       revealTank(tank, continueString);
62606       context.map().on("move.intro drawn.intro", function() {
62607         revealTank(tank, continueString, { duration: 0 });
62608       });
62609       context.on("enter.intro", function(mode) {
62610         if (mode.id === "draw-area") {
62611           return;
62612         } else if (mode.id === "select") {
62613           _tankID = context.selectedIDs()[0];
62614           return continueTo(searchPresetTank);
62615         } else {
62616           return continueTo(addTank);
62617         }
62618       });
62619       function continueTo(nextStep) {
62620         context.map().on("move.intro drawn.intro", null);
62621         context.on("enter.intro", null);
62622         nextStep();
62623       }
62624     }
62625     function searchPresetTank() {
62626       if (!_tankID || !context.hasEntity(_tankID)) {
62627         return addTank();
62628       }
62629       var ids = context.selectedIDs();
62630       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62631         context.enter(modeSelect(context, [_tankID]));
62632       }
62633       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62634       timeout2(function() {
62635         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62636         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62637         reveal(
62638           ".preset-search-input",
62639           helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62640         );
62641       }, 400);
62642       context.on("enter.intro", function(mode) {
62643         if (!_tankID || !context.hasEntity(_tankID)) {
62644           return continueTo(addTank);
62645         }
62646         var ids2 = context.selectedIDs();
62647         if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) {
62648           context.enter(modeSelect(context, [_tankID]));
62649           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62650           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62651           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62652           reveal(
62653             ".preset-search-input",
62654             helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62655           );
62656           context.history().on("change.intro", null);
62657         }
62658       });
62659       function checkPresetSearch() {
62660         var first = context.container().select(".preset-list-item:first-child");
62661         if (first.classed("preset-man_made-storage_tank")) {
62662           reveal(
62663             first.select(".preset-list-button").node(),
62664             helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }),
62665             { duration: 300 }
62666           );
62667           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
62668           context.history().on("change.intro", function() {
62669             continueTo(closeEditorTank);
62670           });
62671         }
62672       }
62673       function continueTo(nextStep) {
62674         context.container().select(".inspector-wrap").on("wheel.intro", null);
62675         context.on("enter.intro", null);
62676         context.history().on("change.intro", null);
62677         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62678         nextStep();
62679       }
62680     }
62681     function closeEditorTank() {
62682       if (!_tankID || !context.hasEntity(_tankID)) {
62683         return addTank();
62684       }
62685       var ids = context.selectedIDs();
62686       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62687         context.enter(modeSelect(context, [_tankID]));
62688       }
62689       context.history().checkpoint("hasTank");
62690       context.on("exit.intro", function() {
62691         continueTo(rightClickTank);
62692       });
62693       timeout2(function() {
62694         reveal(
62695           ".entity-editor-pane",
62696           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62697         );
62698       }, 500);
62699       function continueTo(nextStep) {
62700         context.on("exit.intro", null);
62701         nextStep();
62702       }
62703     }
62704     function rightClickTank() {
62705       if (!_tankID)
62706         return continueTo(addTank);
62707       context.enter(modeBrowse(context));
62708       context.history().reset("hasTank");
62709       context.map().centerEase(tank, 500);
62710       timeout2(function() {
62711         context.on("enter.intro", function(mode) {
62712           if (mode.id !== "select")
62713             return;
62714           var ids = context.selectedIDs();
62715           if (ids.length !== 1 || ids[0] !== _tankID)
62716             return;
62717           timeout2(function() {
62718             var node = selectMenuItem(context, "circularize").node();
62719             if (!node)
62720               return;
62721             continueTo(clickCircle);
62722           }, 50);
62723         });
62724         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch"));
62725         revealTank(tank, rightclickString);
62726         context.map().on("move.intro drawn.intro", function() {
62727           revealTank(tank, rightclickString, { duration: 0 });
62728         });
62729         context.history().on("change.intro", function() {
62730           continueTo(rightClickTank);
62731         });
62732       }, 600);
62733       function continueTo(nextStep) {
62734         context.on("enter.intro", null);
62735         context.map().on("move.intro drawn.intro", null);
62736         context.history().on("change.intro", null);
62737         nextStep();
62738       }
62739     }
62740     function clickCircle() {
62741       if (!_tankID)
62742         return chapter.restart();
62743       var entity = context.hasEntity(_tankID);
62744       if (!entity)
62745         return continueTo(rightClickTank);
62746       var node = selectMenuItem(context, "circularize").node();
62747       if (!node) {
62748         return continueTo(rightClickTank);
62749       }
62750       var wasChanged = false;
62751       reveal(
62752         ".edit-menu",
62753         helpHtml("intro.buildings.circle_tank"),
62754         { padding: 50 }
62755       );
62756       context.on("enter.intro", function(mode) {
62757         if (mode.id === "browse") {
62758           continueTo(rightClickTank);
62759         } else if (mode.id === "move" || mode.id === "rotate") {
62760           continueTo(retryClickCircle);
62761         }
62762       });
62763       context.map().on("move.intro", function() {
62764         var node2 = selectMenuItem(context, "circularize").node();
62765         if (!wasChanged && !node2) {
62766           return continueTo(rightClickTank);
62767         }
62768         reveal(
62769           ".edit-menu",
62770           helpHtml("intro.buildings.circle_tank"),
62771           { duration: 0, padding: 50 }
62772         );
62773       });
62774       context.history().on("change.intro", function() {
62775         wasChanged = true;
62776         context.history().on("change.intro", null);
62777         timeout2(function() {
62778           if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) {
62779             continueTo(play);
62780           } else {
62781             continueTo(retryClickCircle);
62782           }
62783         }, 500);
62784       });
62785       function continueTo(nextStep) {
62786         context.on("enter.intro", null);
62787         context.map().on("move.intro", null);
62788         context.history().on("change.intro", null);
62789         nextStep();
62790       }
62791     }
62792     function retryClickCircle() {
62793       context.enter(modeBrowse(context));
62794       revealTank(tank, helpHtml("intro.buildings.retry_circle"), {
62795         buttonText: _t.html("intro.ok"),
62796         buttonCallback: function() {
62797           continueTo(rightClickTank);
62798         }
62799       });
62800       function continueTo(nextStep) {
62801         nextStep();
62802       }
62803     }
62804     function play() {
62805       dispatch14.call("done");
62806       reveal(
62807         ".ideditor",
62808         helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }),
62809         {
62810           tooltipBox: ".intro-nav-wrap .chapter-startEditing",
62811           buttonText: _t.html("intro.ok"),
62812           buttonCallback: function() {
62813             reveal(".ideditor");
62814           }
62815         }
62816       );
62817     }
62818     chapter.enter = function() {
62819       addHouse();
62820     };
62821     chapter.exit = function() {
62822       timeouts.forEach(window.clearTimeout);
62823       context.on("enter.intro exit.intro", null);
62824       context.map().on("move.intro drawn.intro", null);
62825       context.history().on("change.intro", null);
62826       context.container().select(".inspector-wrap").on("wheel.intro", null);
62827       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62828       context.container().select(".more-fields .combobox-input").on("click.intro", null);
62829     };
62830     chapter.restart = function() {
62831       chapter.exit();
62832       chapter.enter();
62833     };
62834     return utilRebind(chapter, dispatch14, "on");
62835   }
62836
62837   // modules/ui/intro/start_editing.js
62838   function uiIntroStartEditing(context, reveal) {
62839     var dispatch14 = dispatch_default("done", "startEditing");
62840     var modalSelection = select_default2(null);
62841     var chapter = {
62842       title: "intro.startediting.title"
62843     };
62844     function showHelp() {
62845       reveal(
62846         ".map-control.help-control",
62847         helpHtml("intro.startediting.help"),
62848         {
62849           buttonText: _t.html("intro.ok"),
62850           buttonCallback: function() {
62851             shortcuts();
62852           }
62853         }
62854       );
62855     }
62856     function shortcuts() {
62857       reveal(
62858         ".map-control.help-control",
62859         helpHtml("intro.startediting.shortcuts"),
62860         {
62861           buttonText: _t.html("intro.ok"),
62862           buttonCallback: function() {
62863             showSave();
62864           }
62865         }
62866       );
62867     }
62868     function showSave() {
62869       context.container().selectAll(".shaded").remove();
62870       reveal(
62871         ".top-toolbar button.save",
62872         helpHtml("intro.startediting.save"),
62873         {
62874           buttonText: _t.html("intro.ok"),
62875           buttonCallback: function() {
62876             showStart();
62877           }
62878         }
62879       );
62880     }
62881     function showStart() {
62882       context.container().selectAll(".shaded").remove();
62883       modalSelection = uiModal(context.container());
62884       modalSelection.select(".modal").attr("class", "modal-splash modal");
62885       modalSelection.selectAll(".close").remove();
62886       var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() {
62887         modalSelection.remove();
62888       });
62889       startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough");
62890       startbutton.append("h2").call(_t.append("intro.startediting.start"));
62891       dispatch14.call("startEditing");
62892     }
62893     chapter.enter = function() {
62894       showHelp();
62895     };
62896     chapter.exit = function() {
62897       modalSelection.remove();
62898       context.container().selectAll(".shaded").remove();
62899     };
62900     return utilRebind(chapter, dispatch14, "on");
62901   }
62902
62903   // modules/ui/intro/intro.js
62904   var chapterUi = {
62905     welcome: uiIntroWelcome,
62906     navigation: uiIntroNavigation,
62907     point: uiIntroPoint,
62908     area: uiIntroArea,
62909     line: uiIntroLine,
62910     building: uiIntroBuilding,
62911     startEditing: uiIntroStartEditing
62912   };
62913   var chapterFlow = [
62914     "welcome",
62915     "navigation",
62916     "point",
62917     "area",
62918     "line",
62919     "building",
62920     "startEditing"
62921   ];
62922   function uiIntro(context) {
62923     const INTRO_IMAGERY = "EsriWorldImageryClarity";
62924     let _introGraph = {};
62925     let _currChapter;
62926     function intro(selection2) {
62927       _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => {
62928         for (let id2 in dataIntroGraph) {
62929           if (!_introGraph[id2]) {
62930             _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2]));
62931           }
62932         }
62933         selection2.call(startIntro);
62934       }).catch(function() {
62935       });
62936     }
62937     function startIntro(selection2) {
62938       context.enter(modeBrowse(context));
62939       let osm = context.connection();
62940       let history = context.history().toJSON();
62941       let hash = window.location.hash;
62942       let center = context.map().center();
62943       let zoom = context.map().zoom();
62944       let background = context.background().baseLayerSource();
62945       let overlays = context.background().overlayLayerSources();
62946       let opacity = context.container().selectAll(".main-map .layer-background").style("opacity");
62947       let caches = osm && osm.caches();
62948       let baseEntities = context.history().graph().base().entities;
62949       context.ui().sidebar.expand();
62950       context.container().selectAll("button.sidebar-toggle").classed("disabled", true);
62951       context.inIntro(true);
62952       if (osm) {
62953         osm.toggle(false).reset();
62954       }
62955       context.history().reset();
62956       context.history().merge(Object.values(coreGraph().load(_introGraph).entities));
62957       context.history().checkpoint("initial");
62958       let imagery = context.background().findSource(INTRO_IMAGERY);
62959       if (imagery) {
62960         context.background().baseLayerSource(imagery);
62961       } else {
62962         context.background().bing();
62963       }
62964       overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
62965       let layers = context.layers();
62966       layers.all().forEach((item) => {
62967         if (typeof item.layer.enabled === "function") {
62968           item.layer.enabled(item.id === "osm");
62969         }
62970       });
62971       context.container().selectAll(".main-map .layer-background").style("opacity", 1);
62972       let curtain = uiCurtain(context.container().node());
62973       selection2.call(curtain);
62974       corePreferences("walkthrough_started", "yes");
62975       let storedProgress = corePreferences("walkthrough_progress") || "";
62976       let progress = storedProgress.split(";").filter(Boolean);
62977       let chapters = chapterFlow.map((chapter, i3) => {
62978         let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => {
62979           buttons.filter((d2) => d2.title === s2.title).classed("finished", true);
62980           if (i3 < chapterFlow.length - 1) {
62981             const next = chapterFlow[i3 + 1];
62982             context.container().select("button.chapter-".concat(next)).classed("next", true);
62983           }
62984           progress.push(chapter);
62985           corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
62986         });
62987         return s2;
62988       });
62989       chapters[chapters.length - 1].on("startEditing", () => {
62990         progress.push("startEditing");
62991         corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
62992         let incomplete = utilArrayDifference(chapterFlow, progress);
62993         if (!incomplete.length) {
62994           corePreferences("walkthrough_completed", "yes");
62995         }
62996         curtain.remove();
62997         navwrap.remove();
62998         context.container().selectAll(".main-map .layer-background").style("opacity", opacity);
62999         context.container().selectAll("button.sidebar-toggle").classed("disabled", false);
63000         if (osm) {
63001           osm.toggle(true).reset().caches(caches);
63002         }
63003         context.history().reset().merge(Object.values(baseEntities));
63004         context.background().baseLayerSource(background);
63005         overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
63006         if (history) {
63007           context.history().fromJSON(history, false);
63008         }
63009         context.map().centerZoom(center, zoom);
63010         window.location.replace(hash);
63011         context.inIntro(false);
63012       });
63013       let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD");
63014       navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough");
63015       let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter");
63016       let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter);
63017       buttons.append("span").html((d2) => _t.html(d2.title));
63018       buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
63019       enterChapter(null, chapters[0]);
63020       function enterChapter(d3_event, newChapter) {
63021         if (_currChapter) {
63022           _currChapter.exit();
63023         }
63024         context.enter(modeBrowse(context));
63025         _currChapter = newChapter;
63026         _currChapter.enter();
63027         buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title);
63028       }
63029     }
63030     return intro;
63031   }
63032
63033   // modules/ui/issues_info.js
63034   function uiIssuesInfo(context) {
63035     var warningsItem = {
63036       id: "warnings",
63037       count: 0,
63038       iconID: "iD-icon-alert",
63039       descriptionID: "issues.warnings_and_errors"
63040     };
63041     var resolvedItem = {
63042       id: "resolved",
63043       count: 0,
63044       iconID: "iD-icon-apply",
63045       descriptionID: "issues.user_resolved_issues"
63046     };
63047     function update(selection2) {
63048       var shownItems = [];
63049       var liveIssues = context.validator().getIssues({
63050         what: corePreferences("validate-what") || "edited",
63051         where: corePreferences("validate-where") || "all"
63052       });
63053       if (liveIssues.length) {
63054         warningsItem.count = liveIssues.length;
63055         shownItems.push(warningsItem);
63056       }
63057       if (corePreferences("validate-what") === "all") {
63058         var resolvedIssues = context.validator().getResolvedIssues();
63059         if (resolvedIssues.length) {
63060           resolvedItem.count = resolvedIssues.length;
63061           shownItems.push(resolvedItem);
63062         }
63063       }
63064       var chips = selection2.selectAll(".chip").data(shownItems, function(d2) {
63065         return d2.id;
63066       });
63067       chips.exit().remove();
63068       var enter = chips.enter().append("a").attr("class", function(d2) {
63069         return "chip " + d2.id + "-count";
63070       }).attr("href", "#").each(function(d2) {
63071         var chipSelection = select_default2(this);
63072         var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID));
63073         chipSelection.call(tooltipBehavior).on("click", function(d3_event) {
63074           d3_event.preventDefault();
63075           tooltipBehavior.hide(select_default2(this));
63076           context.ui().togglePanes(context.container().select(".map-panes .issues-pane"));
63077         });
63078         chipSelection.call(svgIcon("#" + d2.iconID));
63079       });
63080       enter.append("span").attr("class", "count");
63081       enter.merge(chips).selectAll("span.count").text(function(d2) {
63082         return d2.count.toString();
63083       });
63084     }
63085     return function(selection2) {
63086       update(selection2);
63087       context.validator().on("validated.infobox", function() {
63088         update(selection2);
63089       });
63090     };
63091   }
63092
63093   // modules/ui/map_in_map.js
63094   function uiMapInMap(context) {
63095     function mapInMap(selection2) {
63096       var backgroundLayer = rendererTileLayer(context);
63097       var overlayLayers = {};
63098       var projection2 = geoRawMercator();
63099       var dataLayer = svgData(projection2, context).showLabels(false);
63100       var debugLayer = svgDebug(projection2, context);
63101       var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded);
63102       var wrap2 = select_default2(null);
63103       var tiles = select_default2(null);
63104       var viewport = select_default2(null);
63105       var _isTransformed = false;
63106       var _isHidden = true;
63107       var _skipEvents = false;
63108       var _gesture = null;
63109       var _zDiff = 6;
63110       var _dMini;
63111       var _cMini;
63112       var _tStart;
63113       var _tCurr;
63114       var _timeoutID;
63115       function zoomStarted() {
63116         if (_skipEvents)
63117           return;
63118         _tStart = _tCurr = projection2.transform();
63119         _gesture = null;
63120       }
63121       function zoomed(d3_event) {
63122         if (_skipEvents)
63123           return;
63124         var x2 = d3_event.transform.x;
63125         var y2 = d3_event.transform.y;
63126         var k2 = d3_event.transform.k;
63127         var isZooming = k2 !== _tStart.k;
63128         var isPanning = x2 !== _tStart.x || y2 !== _tStart.y;
63129         if (!isZooming && !isPanning) {
63130           return;
63131         }
63132         if (!_gesture) {
63133           _gesture = isZooming ? "zoom" : "pan";
63134         }
63135         var tMini = projection2.transform();
63136         var tX, tY, scale;
63137         if (_gesture === "zoom") {
63138           scale = k2 / tMini.k;
63139           tX = (_cMini[0] / scale - _cMini[0]) * scale;
63140           tY = (_cMini[1] / scale - _cMini[1]) * scale;
63141         } else {
63142           k2 = tMini.k;
63143           scale = 1;
63144           tX = x2 - tMini.x;
63145           tY = y2 - tMini.y;
63146         }
63147         utilSetTransform(tiles, tX, tY, scale);
63148         utilSetTransform(viewport, 0, 0, scale);
63149         _isTransformed = true;
63150         _tCurr = identity2.translate(x2, y2).scale(k2);
63151         var zMain = geoScaleToZoom(context.projection.scale());
63152         var zMini = geoScaleToZoom(k2);
63153         _zDiff = zMain - zMini;
63154         queueRedraw();
63155       }
63156       function zoomEnded() {
63157         if (_skipEvents)
63158           return;
63159         if (_gesture !== "pan")
63160           return;
63161         updateProjection();
63162         _gesture = null;
63163         context.map().center(projection2.invert(_cMini));
63164       }
63165       function updateProjection() {
63166         var loc = context.map().center();
63167         var tMain = context.projection.transform();
63168         var zMain = geoScaleToZoom(tMain.k);
63169         var zMini = Math.max(zMain - _zDiff, 0.5);
63170         var kMini = geoZoomToScale(zMini);
63171         projection2.translate([tMain.x, tMain.y]).scale(kMini);
63172         var point2 = projection2(loc);
63173         var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0];
63174         var xMini = _cMini[0] - point2[0] + tMain.x + mouse[0];
63175         var yMini = _cMini[1] - point2[1] + tMain.y + mouse[1];
63176         projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]);
63177         _tCurr = projection2.transform();
63178         if (_isTransformed) {
63179           utilSetTransform(tiles, 0, 0);
63180           utilSetTransform(viewport, 0, 0);
63181           _isTransformed = false;
63182         }
63183         zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]);
63184         _skipEvents = true;
63185         wrap2.call(zoom.transform, _tCurr);
63186         _skipEvents = false;
63187       }
63188       function redraw() {
63189         clearTimeout(_timeoutID);
63190         if (_isHidden)
63191           return;
63192         updateProjection();
63193         var zMini = geoScaleToZoom(projection2.scale());
63194         tiles = wrap2.selectAll(".map-in-map-tiles").data([0]);
63195         tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles);
63196         backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini);
63197         var background = tiles.selectAll(".map-in-map-background").data([0]);
63198         background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer);
63199         var overlaySources = context.background().overlayLayerSources();
63200         var activeOverlayLayers = [];
63201         for (var i3 = 0; i3 < overlaySources.length; i3++) {
63202           if (overlaySources[i3].validZoom(zMini)) {
63203             if (!overlayLayers[i3])
63204               overlayLayers[i3] = rendererTileLayer(context);
63205             activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini));
63206           }
63207         }
63208         var overlay = tiles.selectAll(".map-in-map-overlay").data([0]);
63209         overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay);
63210         var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) {
63211           return d2.source().name();
63212         });
63213         overlays.exit().remove();
63214         overlays = overlays.enter().append("div").merge(overlays).each(function(layer) {
63215           select_default2(this).call(layer);
63216         });
63217         var dataLayers = tiles.selectAll(".map-in-map-data").data([0]);
63218         dataLayers.exit().remove();
63219         dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer);
63220         if (_gesture !== "pan") {
63221           var getPath = path_default(projection2);
63222           var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] };
63223           viewport = wrap2.selectAll(".map-in-map-viewport").data([0]);
63224           viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport);
63225           var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]);
63226           path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) {
63227             return getPath.area(d2) < 30;
63228           });
63229         }
63230       }
63231       function queueRedraw() {
63232         clearTimeout(_timeoutID);
63233         _timeoutID = setTimeout(function() {
63234           redraw();
63235         }, 750);
63236       }
63237       function toggle(d3_event) {
63238         if (d3_event)
63239           d3_event.preventDefault();
63240         _isHidden = !_isHidden;
63241         context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden);
63242         if (_isHidden) {
63243           wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() {
63244             selection2.selectAll(".map-in-map").style("display", "none");
63245           });
63246         } else {
63247           wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() {
63248             redraw();
63249           });
63250         }
63251       }
63252       uiMapInMap.toggle = toggle;
63253       wrap2 = selection2.selectAll(".map-in-map").data([0]);
63254       wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2);
63255       _dMini = [200, 150];
63256       _cMini = geoVecScale(_dMini, 0.5);
63257       context.map().on("drawn.map-in-map", function(drawn) {
63258         if (drawn.full === true) {
63259           redraw();
63260         }
63261       });
63262       redraw();
63263       context.keybinding().on(_t("background.minimap.key"), toggle);
63264     }
63265     return mapInMap;
63266   }
63267
63268   // modules/ui/notice.js
63269   function uiNotice(context) {
63270     return function(selection2) {
63271       var div = selection2.append("div").attr("class", "notice");
63272       var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() {
63273         context.map().zoomEase(context.minEditableZoom());
63274       }).on("wheel", function(d3_event) {
63275         var e22 = new WheelEvent(d3_event.type, d3_event);
63276         context.surface().node().dispatchEvent(e22);
63277       });
63278       button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit"));
63279       function disableTooHigh() {
63280         var canEdit = context.map().zoom() >= context.minEditableZoom();
63281         div.style("display", canEdit ? "none" : "block");
63282       }
63283       context.map().on("move.notice", debounce_default(disableTooHigh, 500));
63284       disableTooHigh();
63285     };
63286   }
63287
63288   // modules/ui/photoviewer.js
63289   function uiPhotoviewer(context) {
63290     var dispatch14 = dispatch_default("resize");
63291     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
63292     function photoviewer(selection2) {
63293       selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() {
63294         if (services.streetside) {
63295           services.streetside.hideViewer(context);
63296         }
63297         if (services.mapillary) {
63298           services.mapillary.hideViewer(context);
63299         }
63300         if (services.kartaview) {
63301           services.kartaview.hideViewer(context);
63302         }
63303         if (services.mapilio) {
63304           services.mapilio.hideViewer(context);
63305         }
63306         if (services.vegbilder) {
63307           services.vegbilder.hideViewer(context);
63308         }
63309       }).append("div").call(svgIcon("#iD-icon-close"));
63310       function preventDefault(d3_event) {
63311         d3_event.preventDefault();
63312       }
63313       selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on(
63314         _pointerPrefix + "down",
63315         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true })
63316       );
63317       selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on(
63318         _pointerPrefix + "down",
63319         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true })
63320       );
63321       selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on(
63322         _pointerPrefix + "down",
63323         buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true })
63324       );
63325       function buildResizeListener(target, eventName, dispatch15, options2) {
63326         var resizeOnX = !!options2.resizeOnX;
63327         var resizeOnY = !!options2.resizeOnY;
63328         var minHeight = options2.minHeight || 240;
63329         var minWidth = options2.minWidth || 320;
63330         var pointerId;
63331         var startX;
63332         var startY;
63333         var startWidth;
63334         var startHeight;
63335         function startResize(d3_event) {
63336           if (pointerId !== (d3_event.pointerId || "mouse"))
63337             return;
63338           d3_event.preventDefault();
63339           d3_event.stopPropagation();
63340           var mapSize = context.map().dimensions();
63341           if (resizeOnX) {
63342             var maxWidth = mapSize[0];
63343             var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, maxWidth);
63344             target.style("width", newWidth + "px");
63345           }
63346           if (resizeOnY) {
63347             var maxHeight = mapSize[1] - 90;
63348             var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight);
63349             target.style("height", newHeight + "px");
63350           }
63351           dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target));
63352         }
63353         function clamp3(num, min3, max3) {
63354           return Math.max(min3, Math.min(num, max3));
63355         }
63356         function stopResize(d3_event) {
63357           if (pointerId !== (d3_event.pointerId || "mouse"))
63358             return;
63359           d3_event.preventDefault();
63360           d3_event.stopPropagation();
63361           select_default2(window).on("." + eventName, null);
63362         }
63363         return function initResize(d3_event) {
63364           d3_event.preventDefault();
63365           d3_event.stopPropagation();
63366           pointerId = d3_event.pointerId || "mouse";
63367           startX = d3_event.clientX;
63368           startY = d3_event.clientY;
63369           var targetRect = target.node().getBoundingClientRect();
63370           startWidth = targetRect.width;
63371           startHeight = targetRect.height;
63372           select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false);
63373           if (_pointerPrefix === "pointer") {
63374             select_default2(window).on("pointercancel." + eventName, stopResize, false);
63375           }
63376         };
63377       }
63378     }
63379     photoviewer.onMapResize = function() {
63380       var photoviewer2 = context.container().select(".photoviewer");
63381       var content = context.container().select(".main-content");
63382       var mapDimensions = utilGetDimensions(content, true);
63383       var photoDimensions = utilGetDimensions(photoviewer2, true);
63384       if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - 90) {
63385         var setPhotoDimensions = [
63386           Math.min(photoDimensions[0], mapDimensions[0]),
63387           Math.min(photoDimensions[1], mapDimensions[1] - 90)
63388         ];
63389         photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px");
63390         dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2));
63391       }
63392     };
63393     function subtractPadding(dimensions, selection2) {
63394       return [
63395         dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")),
63396         dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom"))
63397       ];
63398     }
63399     return utilRebind(photoviewer, dispatch14, "on");
63400   }
63401
63402   // modules/ui/restore.js
63403   function uiRestore(context) {
63404     return function(selection2) {
63405       if (!context.history().hasRestorableChanges())
63406         return;
63407       let modalSelection = uiModal(selection2, true);
63408       modalSelection.select(".modal").attr("class", "modal fillL");
63409       let introModal = modalSelection.select(".content");
63410       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading"));
63411       introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description"));
63412       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
63413       let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => {
63414         context.history().restore();
63415         modalSelection.remove();
63416       });
63417       restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore");
63418       restore.append("div").call(_t.append("restore.restore"));
63419       let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => {
63420         context.history().clearSaved();
63421         modalSelection.remove();
63422       });
63423       reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset");
63424       reset.append("div").call(_t.append("restore.reset"));
63425       restore.node().focus();
63426     };
63427   }
63428
63429   // modules/ui/scale.js
63430   function uiScale(context) {
63431     var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8;
63432     function scaleDefs(loc1, loc2) {
63433       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;
63434       if (isImperial) {
63435         buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1];
63436       } else {
63437         buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1];
63438       }
63439       for (i3 = 0; i3 < buckets.length; i3++) {
63440         val = buckets[i3];
63441         if (dist >= val) {
63442           scale.dist = Math.floor(dist / val) * val;
63443           break;
63444         } else {
63445           scale.dist = +dist.toFixed(2);
63446         }
63447       }
63448       dLon = geoMetersToLon(scale.dist / conversion, lat);
63449       scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]);
63450       scale.text = displayLength(scale.dist / conversion, isImperial);
63451       return scale;
63452     }
63453     function update(selection2) {
63454       var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2);
63455       selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight);
63456       selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text);
63457     }
63458     return function(selection2) {
63459       function switchUnits() {
63460         isImperial = !isImperial;
63461         selection2.call(update);
63462       }
63463       var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)");
63464       scalegroup.append("path").attr("class", "scale-path");
63465       selection2.append("div").attr("class", "scale-text");
63466       selection2.call(update);
63467       context.map().on("move.scale", function() {
63468         update(selection2);
63469       });
63470     };
63471   }
63472
63473   // modules/ui/shortcuts.js
63474   function uiShortcuts(context) {
63475     var detected = utilDetect();
63476     var _activeTab = 0;
63477     var _modalSelection;
63478     var _selection = select_default2(null);
63479     var _dataShortcuts;
63480     function shortcutsModal(_modalSelection2) {
63481       _modalSelection2.select(".modal").classed("modal-shortcuts", true);
63482       var content = _modalSelection2.select(".content");
63483       content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title"));
63484       _mainFileFetcher.get("shortcuts").then(function(data) {
63485         _dataShortcuts = data;
63486         content.call(render);
63487       }).catch(function() {
63488       });
63489     }
63490     function render(selection2) {
63491       if (!_dataShortcuts)
63492         return;
63493       var wrapper = selection2.selectAll(".wrapper").data([0]);
63494       var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section");
63495       var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar");
63496       var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list");
63497       wrapper = wrapper.merge(wrapperEnter);
63498       var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts);
63499       var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) {
63500         d3_event.preventDefault();
63501         var i3 = _dataShortcuts.indexOf(d2);
63502         _activeTab = i3;
63503         render(selection2);
63504       });
63505       tabsEnter.append("span").html(function(d2) {
63506         return _t.html(d2.text);
63507       });
63508       wrapper.selectAll(".tab").classed("active", function(d2, i3) {
63509         return i3 === _activeTab;
63510       });
63511       var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts);
63512       var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) {
63513         return "shortcut-tab shortcut-tab-" + d2.tab;
63514       });
63515       var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) {
63516         return d2.columns;
63517       }).enter().append("table").attr("class", "shortcut-column");
63518       var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) {
63519         return d2.rows;
63520       }).enter().append("tr").attr("class", "shortcut-row");
63521       var sectionRows = rowsEnter.filter(function(d2) {
63522         return !d2.shortcuts;
63523       });
63524       sectionRows.append("td");
63525       sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) {
63526         return _t.html(d2.text);
63527       });
63528       var shortcutRows = rowsEnter.filter(function(d2) {
63529         return d2.shortcuts;
63530       });
63531       var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys");
63532       var modifierKeys = shortcutKeys.filter(function(d2) {
63533         return d2.modifiers;
63534       });
63535       modifierKeys.selectAll("kbd.modifier").data(function(d2) {
63536         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63537           return ["\u2318"];
63538         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63539           return [];
63540         } else {
63541           return d2.modifiers;
63542         }
63543       }).enter().each(function() {
63544         var selection3 = select_default2(this);
63545         selection3.append("kbd").attr("class", "modifier").text(function(d2) {
63546           return uiCmd.display(d2);
63547         });
63548         selection3.append("span").text("+");
63549       });
63550       shortcutKeys.selectAll("kbd.shortcut").data(function(d2) {
63551         var arr = d2.shortcuts;
63552         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63553           arr = ["Y"];
63554         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63555           arr = ["F11"];
63556         }
63557         arr = arr.map(function(s2) {
63558           return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2);
63559         });
63560         return utilArrayUniq(arr).map(function(s2) {
63561           return {
63562             shortcut: s2,
63563             separator: d2.separator,
63564             suffix: d2.suffix
63565           };
63566         });
63567       }).enter().each(function(d2, i3, nodes) {
63568         var selection3 = select_default2(this);
63569         var click = d2.shortcut.toLowerCase().match(/(.*).click/);
63570         if (click && click[1]) {
63571           selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation"));
63572         } else if (d2.shortcut.toLowerCase() === "long-press") {
63573           selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation"));
63574         } else if (d2.shortcut.toLowerCase() === "tap") {
63575           selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation"));
63576         } else {
63577           selection3.append("kbd").attr("class", "shortcut").text(function(d4) {
63578             return d4.shortcut;
63579           });
63580         }
63581         if (i3 < nodes.length - 1) {
63582           selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0");
63583         } else if (i3 === nodes.length - 1 && d2.suffix) {
63584           selection3.append("span").text(d2.suffix);
63585         }
63586       });
63587       shortcutKeys.filter(function(d2) {
63588         return d2.gesture;
63589       }).each(function() {
63590         var selection3 = select_default2(this);
63591         selection3.append("span").text("+");
63592         selection3.append("span").attr("class", "gesture").html(function(d2) {
63593           return _t.html(d2.gesture);
63594         });
63595       });
63596       shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) {
63597         return d2.text ? _t.html(d2.text) : "\xA0";
63598       });
63599       wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) {
63600         return i3 === _activeTab ? "flex" : "none";
63601       });
63602     }
63603     return function(selection2, show) {
63604       _selection = selection2;
63605       if (show) {
63606         _modalSelection = uiModal(selection2);
63607         _modalSelection.call(shortcutsModal);
63608       } else {
63609         context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() {
63610           if (context.container().selectAll(".modal-shortcuts").size()) {
63611             if (_modalSelection) {
63612               _modalSelection.close();
63613               _modalSelection = null;
63614             }
63615           } else {
63616             _modalSelection = uiModal(_selection);
63617             _modalSelection.call(shortcutsModal);
63618           }
63619         });
63620       }
63621     };
63622   }
63623
63624   // modules/ui/data_header.js
63625   function uiDataHeader() {
63626     var _datum;
63627     function dataHeader(selection2) {
63628       var header = selection2.selectAll(".data-header").data(
63629         _datum ? [_datum] : [],
63630         function(d2) {
63631           return d2.__featurehash__;
63632         }
63633       );
63634       header.exit().remove();
63635       var headerEnter = header.enter().append("div").attr("class", "data-header");
63636       var iconEnter = headerEnter.append("div").attr("class", "data-header-icon");
63637       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill"));
63638       headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title"));
63639     }
63640     dataHeader.datum = function(val) {
63641       if (!arguments.length)
63642         return _datum;
63643       _datum = val;
63644       return this;
63645     };
63646     return dataHeader;
63647   }
63648
63649   // modules/ui/combobox.js
63650   var _comboHideTimerID;
63651   function uiCombobox(context, klass) {
63652     var dispatch14 = dispatch_default("accept", "cancel", "update");
63653     var container = context.container();
63654     var _suggestions = [];
63655     var _data = [];
63656     var _fetched = {};
63657     var _selected = null;
63658     var _canAutocomplete = true;
63659     var _caseSensitive = false;
63660     var _cancelFetch = false;
63661     var _minItems = 2;
63662     var _tDown = 0;
63663     var _mouseEnterHandler, _mouseLeaveHandler;
63664     var _fetcher = function(val, cb) {
63665       cb(_data.filter(function(d2) {
63666         var terms = d2.terms || [];
63667         terms.push(d2.value);
63668         if (d2.key) {
63669           terms.push(d2.key);
63670         }
63671         return terms.some(function(term) {
63672           return term.toString().toLowerCase().indexOf(val.toLowerCase()) !== -1;
63673         });
63674       }));
63675     };
63676     var combobox = function(input, attachTo) {
63677       if (!input || input.empty())
63678         return;
63679       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() {
63680         var parent = this.parentNode;
63681         var sibling = this.nextSibling;
63682         select_default2(parent).selectAll(".combobox-caret").filter(function(d2) {
63683           return d2 === input.node();
63684         }).data([input.node()]).enter().insert("div", function() {
63685           return sibling;
63686         }).attr("class", "combobox-caret").on("mousedown.combo-caret", function(d3_event) {
63687           d3_event.preventDefault();
63688           input.node().focus();
63689           mousedown(d3_event);
63690         }).on("mouseup.combo-caret", function(d3_event) {
63691           d3_event.preventDefault();
63692           mouseup(d3_event);
63693         });
63694       });
63695       function mousedown(d3_event) {
63696         if (d3_event.button !== 0)
63697           return;
63698         if (input.classed("disabled"))
63699           return;
63700         _tDown = +/* @__PURE__ */ new Date();
63701         var start2 = input.property("selectionStart");
63702         var end = input.property("selectionEnd");
63703         if (start2 !== end) {
63704           var val = utilGetSetValue(input);
63705           input.node().setSelectionRange(val.length, val.length);
63706           return;
63707         }
63708         input.on("mouseup.combo-input", mouseup);
63709       }
63710       function mouseup(d3_event) {
63711         input.on("mouseup.combo-input", null);
63712         if (d3_event.button !== 0)
63713           return;
63714         if (input.classed("disabled"))
63715           return;
63716         if (input.node() !== document.activeElement)
63717           return;
63718         var start2 = input.property("selectionStart");
63719         var end = input.property("selectionEnd");
63720         if (start2 !== end)
63721           return;
63722         var combo = container.selectAll(".combobox");
63723         if (combo.empty() || combo.datum() !== input.node()) {
63724           var tOrig = _tDown;
63725           window.setTimeout(function() {
63726             if (tOrig !== _tDown)
63727               return;
63728             fetchComboData("", function() {
63729               show();
63730               render();
63731             });
63732           }, 250);
63733         } else {
63734           hide();
63735         }
63736       }
63737       function focus() {
63738         fetchComboData("");
63739       }
63740       function blur() {
63741         _comboHideTimerID = window.setTimeout(hide, 75);
63742       }
63743       function show() {
63744         hide();
63745         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) {
63746           d3_event.preventDefault();
63747         });
63748         container.on("scroll.combo-scroll", render, true);
63749       }
63750       function hide() {
63751         if (_comboHideTimerID) {
63752           window.clearTimeout(_comboHideTimerID);
63753           _comboHideTimerID = void 0;
63754         }
63755         container.selectAll(".combobox").remove();
63756         container.on("scroll.combo-scroll", null);
63757       }
63758       function keydown(d3_event) {
63759         var shown = !container.selectAll(".combobox").empty();
63760         var tagName = input.node() ? input.node().tagName.toLowerCase() : "";
63761         switch (d3_event.keyCode) {
63762           case 8:
63763           case 46:
63764             d3_event.stopPropagation();
63765             _selected = null;
63766             render();
63767             input.on("input.combo-input", function() {
63768               var start2 = input.property("selectionStart");
63769               input.node().setSelectionRange(start2, start2);
63770               input.on("input.combo-input", change);
63771               change(false);
63772             });
63773             break;
63774           case 9:
63775             accept(d3_event);
63776             break;
63777           case 13:
63778             d3_event.preventDefault();
63779             d3_event.stopPropagation();
63780             accept(d3_event);
63781             break;
63782           case 38:
63783             if (tagName === "textarea" && !shown)
63784               return;
63785             d3_event.preventDefault();
63786             if (tagName === "input" && !shown) {
63787               show();
63788             }
63789             nav(-1);
63790             break;
63791           case 40:
63792             if (tagName === "textarea" && !shown)
63793               return;
63794             d3_event.preventDefault();
63795             if (tagName === "input" && !shown) {
63796               show();
63797             }
63798             nav(1);
63799             break;
63800         }
63801       }
63802       function keyup(d3_event) {
63803         switch (d3_event.keyCode) {
63804           case 27:
63805             cancel();
63806             break;
63807         }
63808       }
63809       function change(doAutoComplete) {
63810         if (doAutoComplete === void 0)
63811           doAutoComplete = true;
63812         fetchComboData(value(), function(skipAutosuggest) {
63813           _selected = null;
63814           var val = input.property("value");
63815           if (_suggestions.length) {
63816             if (doAutoComplete && !skipAutosuggest && input.property("selectionEnd") === val.length) {
63817               _selected = tryAutocomplete();
63818             }
63819             if (!_selected) {
63820               _selected = val;
63821             }
63822           }
63823           if (val.length) {
63824             var combo = container.selectAll(".combobox");
63825             if (combo.empty()) {
63826               show();
63827             }
63828           } else {
63829             hide();
63830           }
63831           render();
63832         });
63833       }
63834       function nav(dir) {
63835         if (_suggestions.length) {
63836           var index = -1;
63837           for (var i3 = 0; i3 < _suggestions.length; i3++) {
63838             if (_selected && _suggestions[i3].value === _selected) {
63839               index = i3;
63840               break;
63841             }
63842           }
63843           index = Math.max(Math.min(index + dir, _suggestions.length - 1), 0);
63844           _selected = _suggestions[index].value;
63845           utilGetSetValue(input, _selected);
63846           dispatch14.call("update");
63847         }
63848         render();
63849         ensureVisible();
63850       }
63851       function ensureVisible() {
63852         var combo = container.selectAll(".combobox");
63853         if (combo.empty())
63854           return;
63855         var containerRect = container.node().getBoundingClientRect();
63856         var comboRect = combo.node().getBoundingClientRect();
63857         if (comboRect.bottom > containerRect.bottom) {
63858           var node = attachTo ? attachTo.node() : input.node();
63859           node.scrollIntoView({ behavior: "instant", block: "center" });
63860           render();
63861         }
63862         var selected = combo.selectAll(".combobox-option.selected").node();
63863         if (selected) {
63864           selected.scrollIntoView({ behavior: "smooth", block: "nearest" });
63865         }
63866       }
63867       function value() {
63868         var value2 = input.property("value");
63869         var start2 = input.property("selectionStart");
63870         var end = input.property("selectionEnd");
63871         if (start2 && end) {
63872           value2 = value2.substring(0, start2);
63873         }
63874         return value2;
63875       }
63876       function fetchComboData(v2, cb) {
63877         _cancelFetch = false;
63878         _fetcher.call(input, v2, function(results, skipAutosuggest) {
63879           if (_cancelFetch)
63880             return;
63881           _suggestions = results;
63882           results.forEach(function(d2) {
63883             _fetched[d2.value] = d2;
63884           });
63885           if (cb) {
63886             cb(skipAutosuggest);
63887           }
63888         });
63889       }
63890       function tryAutocomplete() {
63891         if (!_canAutocomplete)
63892           return;
63893         var val = _caseSensitive ? value() : value().toLowerCase();
63894         if (!val)
63895           return;
63896         if (isFinite(val))
63897           return;
63898         const suggestionValues = [];
63899         _suggestions.forEach((s2) => {
63900           suggestionValues.push(s2.value);
63901           if (s2.key && s2.key !== s2.value) {
63902             suggestionValues.push(s2.key);
63903           }
63904         });
63905         var bestIndex = -1;
63906         for (var i3 = 0; i3 < suggestionValues.length; i3++) {
63907           var suggestion = suggestionValues[i3];
63908           var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase();
63909           if (compare2 === val) {
63910             bestIndex = i3;
63911             break;
63912           } else if (bestIndex === -1 && compare2.indexOf(val) === 0) {
63913             bestIndex = i3;
63914           }
63915         }
63916         if (bestIndex !== -1) {
63917           var bestVal = suggestionValues[bestIndex];
63918           input.property("value", bestVal);
63919           input.node().setSelectionRange(val.length, bestVal.length);
63920           dispatch14.call("update");
63921           return bestVal;
63922         }
63923       }
63924       function render() {
63925         if (_suggestions.length < _minItems || document.activeElement !== input.node()) {
63926           hide();
63927           return;
63928         }
63929         var shown = !container.selectAll(".combobox").empty();
63930         if (!shown)
63931           return;
63932         var combo = container.selectAll(".combobox");
63933         var options2 = combo.selectAll(".combobox-option").data(_suggestions, function(d2) {
63934           return d2.value;
63935         });
63936         options2.exit().remove();
63937         options2.enter().append("a").attr("class", function(d2) {
63938           return "combobox-option " + (d2.klass || "");
63939         }).attr("title", function(d2) {
63940           return d2.title;
63941         }).each(function(d2) {
63942           if (d2.display) {
63943             d2.display(select_default2(this));
63944           } else {
63945             select_default2(this).text(d2.value);
63946           }
63947         }).on("mouseenter", _mouseEnterHandler).on("mouseleave", _mouseLeaveHandler).merge(options2).classed("selected", function(d2) {
63948           return d2.value === _selected || d2.key === _selected;
63949         }).on("click.combo-option", accept).order();
63950         var node = attachTo ? attachTo.node() : input.node();
63951         var containerRect = container.node().getBoundingClientRect();
63952         var rect = node.getBoundingClientRect();
63953         combo.style("left", rect.left + 5 - containerRect.left + "px").style("width", rect.width - 10 + "px").style("top", rect.height + rect.top - containerRect.top + "px");
63954       }
63955       function accept(d3_event, d2) {
63956         _cancelFetch = true;
63957         var thiz = input.node();
63958         if (d2) {
63959           utilGetSetValue(input, d2.value);
63960           utilTriggerEvent(input, "change");
63961         }
63962         var val = utilGetSetValue(input);
63963         thiz.setSelectionRange(val.length, val.length);
63964         d2 = _fetched[val];
63965         dispatch14.call("accept", thiz, d2, val);
63966         hide();
63967       }
63968       function cancel() {
63969         _cancelFetch = true;
63970         var thiz = input.node();
63971         var val = utilGetSetValue(input);
63972         var start2 = input.property("selectionStart");
63973         var end = input.property("selectionEnd");
63974         val = val.slice(0, start2) + val.slice(end);
63975         utilGetSetValue(input, val);
63976         thiz.setSelectionRange(val.length, val.length);
63977         dispatch14.call("cancel", thiz);
63978         hide();
63979       }
63980     };
63981     combobox.canAutocomplete = function(val) {
63982       if (!arguments.length)
63983         return _canAutocomplete;
63984       _canAutocomplete = val;
63985       return combobox;
63986     };
63987     combobox.caseSensitive = function(val) {
63988       if (!arguments.length)
63989         return _caseSensitive;
63990       _caseSensitive = val;
63991       return combobox;
63992     };
63993     combobox.data = function(val) {
63994       if (!arguments.length)
63995         return _data;
63996       _data = val;
63997       return combobox;
63998     };
63999     combobox.fetcher = function(val) {
64000       if (!arguments.length)
64001         return _fetcher;
64002       _fetcher = val;
64003       return combobox;
64004     };
64005     combobox.minItems = function(val) {
64006       if (!arguments.length)
64007         return _minItems;
64008       _minItems = val;
64009       return combobox;
64010     };
64011     combobox.itemsMouseEnter = function(val) {
64012       if (!arguments.length)
64013         return _mouseEnterHandler;
64014       _mouseEnterHandler = val;
64015       return combobox;
64016     };
64017     combobox.itemsMouseLeave = function(val) {
64018       if (!arguments.length)
64019         return _mouseLeaveHandler;
64020       _mouseLeaveHandler = val;
64021       return combobox;
64022     };
64023     return utilRebind(combobox, dispatch14, "on");
64024   }
64025   uiCombobox.off = function(input, context) {
64026     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);
64027     context.container().on("scroll.combo-scroll", null);
64028   };
64029
64030   // modules/ui/disclosure.js
64031   function uiDisclosure(context, key, expandedDefault) {
64032     var dispatch14 = dispatch_default("toggled");
64033     var _expanded;
64034     var _label = utilFunctor("");
64035     var _updatePreference = true;
64036     var _content = function() {
64037     };
64038     var disclosure = function(selection2) {
64039       if (_expanded === void 0 || _expanded === null) {
64040         var preference = corePreferences("disclosure." + key + ".expanded");
64041         _expanded = preference === null ? !!expandedDefault : preference === "true";
64042       }
64043       var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]);
64044       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"));
64045       hideToggleEnter.append("span").attr("class", "hide-toggle-text");
64046       hideToggle = hideToggleEnter.merge(hideToggle);
64047       hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded);
64048       const label = _label();
64049       const labelSelection = hideToggle.selectAll(".hide-toggle-text");
64050       if (typeof label !== "function") {
64051         labelSelection.text(_label());
64052       } else {
64053         labelSelection.text("").call(label);
64054       }
64055       hideToggle.selectAll(".hide-toggle-icon").attr(
64056         "xlink:href",
64057         _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64058       );
64059       var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]);
64060       wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded);
64061       if (_expanded) {
64062         wrap2.call(_content);
64063       }
64064       function toggle(d3_event) {
64065         d3_event.preventDefault();
64066         _expanded = !_expanded;
64067         if (_updatePreference) {
64068           corePreferences("disclosure." + key + ".expanded", _expanded);
64069         }
64070         hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand")));
64071         hideToggle.selectAll(".hide-toggle-icon").attr(
64072           "xlink:href",
64073           _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64074         );
64075         wrap2.call(uiToggle(_expanded));
64076         if (_expanded) {
64077           wrap2.call(_content);
64078         }
64079         dispatch14.call("toggled", this, _expanded);
64080       }
64081     };
64082     disclosure.label = function(val) {
64083       if (!arguments.length)
64084         return _label;
64085       _label = utilFunctor(val);
64086       return disclosure;
64087     };
64088     disclosure.expanded = function(val) {
64089       if (!arguments.length)
64090         return _expanded;
64091       _expanded = val;
64092       return disclosure;
64093     };
64094     disclosure.updatePreference = function(val) {
64095       if (!arguments.length)
64096         return _updatePreference;
64097       _updatePreference = val;
64098       return disclosure;
64099     };
64100     disclosure.content = function(val) {
64101       if (!arguments.length)
64102         return _content;
64103       _content = val;
64104       return disclosure;
64105     };
64106     return utilRebind(disclosure, dispatch14, "on");
64107   }
64108
64109   // modules/ui/section.js
64110   function uiSection(id2, context) {
64111     var _classes = utilFunctor("");
64112     var _shouldDisplay;
64113     var _content;
64114     var _disclosure;
64115     var _label;
64116     var _expandedByDefault = utilFunctor(true);
64117     var _disclosureContent;
64118     var _disclosureExpanded;
64119     var _containerSelection = select_default2(null);
64120     var section = {
64121       id: id2
64122     };
64123     section.classes = function(val) {
64124       if (!arguments.length)
64125         return _classes;
64126       _classes = utilFunctor(val);
64127       return section;
64128     };
64129     section.label = function(val) {
64130       if (!arguments.length)
64131         return _label;
64132       _label = utilFunctor(val);
64133       return section;
64134     };
64135     section.expandedByDefault = function(val) {
64136       if (!arguments.length)
64137         return _expandedByDefault;
64138       _expandedByDefault = utilFunctor(val);
64139       return section;
64140     };
64141     section.shouldDisplay = function(val) {
64142       if (!arguments.length)
64143         return _shouldDisplay;
64144       _shouldDisplay = utilFunctor(val);
64145       return section;
64146     };
64147     section.content = function(val) {
64148       if (!arguments.length)
64149         return _content;
64150       _content = val;
64151       return section;
64152     };
64153     section.disclosureContent = function(val) {
64154       if (!arguments.length)
64155         return _disclosureContent;
64156       _disclosureContent = val;
64157       return section;
64158     };
64159     section.disclosureExpanded = function(val) {
64160       if (!arguments.length)
64161         return _disclosureExpanded;
64162       _disclosureExpanded = val;
64163       return section;
64164     };
64165     section.render = function(selection2) {
64166       _containerSelection = selection2.selectAll(".section-" + id2).data([0]);
64167       var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || ""));
64168       _containerSelection = sectionEnter.merge(_containerSelection);
64169       _containerSelection.call(renderContent);
64170     };
64171     section.reRender = function() {
64172       _containerSelection.call(renderContent);
64173     };
64174     section.selection = function() {
64175       return _containerSelection;
64176     };
64177     section.disclosure = function() {
64178       return _disclosure;
64179     };
64180     function renderContent(selection2) {
64181       if (_shouldDisplay) {
64182         var shouldDisplay = _shouldDisplay();
64183         selection2.classed("hide", !shouldDisplay);
64184         if (!shouldDisplay) {
64185           selection2.html("");
64186           return;
64187         }
64188       }
64189       if (_disclosureContent) {
64190         if (!_disclosure) {
64191           _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent);
64192         }
64193         if (_disclosureExpanded !== void 0) {
64194           _disclosure.expanded(_disclosureExpanded);
64195           _disclosureExpanded = void 0;
64196         }
64197         selection2.call(_disclosure);
64198         return;
64199       }
64200       if (_content) {
64201         selection2.call(_content);
64202       }
64203     }
64204     return section;
64205   }
64206
64207   // modules/ui/tag_reference.js
64208   function uiTagReference(what) {
64209     var wikibase = what.qid ? services.wikidata : services.osmWikibase;
64210     var tagReference = {};
64211     var _button = select_default2(null);
64212     var _body = select_default2(null);
64213     var _loaded;
64214     var _showing;
64215     function load() {
64216       if (!wikibase)
64217         return;
64218       _button.classed("tag-reference-loading", true);
64219       wikibase.getDocs(what, gotDocs);
64220     }
64221     function gotDocs(err, docs) {
64222       _body.html("");
64223       if (!docs || !docs.title) {
64224         _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key"));
64225         done();
64226         return;
64227       }
64228       if (docs.imageURL) {
64229         _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.description).attr("src", docs.imageURL).on("load", function() {
64230           done();
64231         }).on("error", function() {
64232           select_default2(this).remove();
64233           done();
64234         });
64235       } else {
64236         done();
64237       }
64238       var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span");
64239       if (docs.description) {
64240         tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").text(docs.description);
64241       } else {
64242         tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key"));
64243       }
64244       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"));
64245       if (docs.wiki) {
64246         _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));
64247       }
64248       if (what.key === "comment") {
64249         _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"));
64250       }
64251     }
64252     function done() {
64253       _loaded = true;
64254       _button.classed("tag-reference-loading", false);
64255       _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1");
64256       _showing = true;
64257       _button.selectAll("svg.icon use").each(function() {
64258         var iconUse = select_default2(this);
64259         if (iconUse.attr("href") === "#iD-icon-info") {
64260           iconUse.attr("href", "#iD-icon-info-filled");
64261         }
64262       });
64263     }
64264     function hide() {
64265       _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
64266         _body.classed("expanded", false);
64267       });
64268       _showing = false;
64269       _button.selectAll("svg.icon use").each(function() {
64270         var iconUse = select_default2(this);
64271         if (iconUse.attr("href") === "#iD-icon-info-filled") {
64272           iconUse.attr("href", "#iD-icon-info");
64273         }
64274       });
64275     }
64276     tagReference.button = function(selection2, klass, iconName) {
64277       _button = selection2.selectAll(".tag-reference-button").data([0]);
64278       _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button);
64279       _button.on("click", function(d3_event) {
64280         d3_event.stopPropagation();
64281         d3_event.preventDefault();
64282         this.blur();
64283         if (_showing) {
64284           hide();
64285         } else if (_loaded) {
64286           done();
64287         } else {
64288           load();
64289         }
64290       });
64291     };
64292     tagReference.body = function(selection2) {
64293       var itemID = what.qid || what.key + "-" + (what.value || "");
64294       _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) {
64295         return d2;
64296       });
64297       _body.exit().remove();
64298       _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body);
64299       if (_showing === false) {
64300         hide();
64301       }
64302     };
64303     tagReference.showing = function(val) {
64304       if (!arguments.length)
64305         return _showing;
64306       _showing = val;
64307       return tagReference;
64308     };
64309     return tagReference;
64310   }
64311
64312   // modules/ui/field_help.js
64313   function uiFieldHelp(context, fieldName) {
64314     var fieldHelp = {};
64315     var _inspector = select_default2(null);
64316     var _wrap = select_default2(null);
64317     var _body = select_default2(null);
64318     var fieldHelpKeys = {
64319       restrictions: [
64320         ["about", [
64321           "about",
64322           "from_via_to",
64323           "maxdist",
64324           "maxvia"
64325         ]],
64326         ["inspecting", [
64327           "about",
64328           "from_shadow",
64329           "allow_shadow",
64330           "restrict_shadow",
64331           "only_shadow",
64332           "restricted",
64333           "only"
64334         ]],
64335         ["modifying", [
64336           "about",
64337           "indicators",
64338           "allow_turn",
64339           "restrict_turn",
64340           "only_turn"
64341         ]],
64342         ["tips", [
64343           "simple",
64344           "simple_example",
64345           "indirect",
64346           "indirect_example",
64347           "indirect_noedit"
64348         ]]
64349       ]
64350     };
64351     var fieldHelpHeadings = {};
64352     var replacements = {
64353       distField: { html: _t.html("restriction.controls.distance") },
64354       viaField: { html: _t.html("restriction.controls.via") },
64355       fromShadow: { html: icon("#iD-turn-shadow", "inline shadow from") },
64356       allowShadow: { html: icon("#iD-turn-shadow", "inline shadow allow") },
64357       restrictShadow: { html: icon("#iD-turn-shadow", "inline shadow restrict") },
64358       onlyShadow: { html: icon("#iD-turn-shadow", "inline shadow only") },
64359       allowTurn: { html: icon("#iD-turn-yes", "inline turn") },
64360       restrictTurn: { html: icon("#iD-turn-no", "inline turn") },
64361       onlyTurn: { html: icon("#iD-turn-only", "inline turn") }
64362     };
64363     var docs = fieldHelpKeys[fieldName].map(function(key) {
64364       var helpkey = "help.field." + fieldName + "." + key[0];
64365       var text = key[1].reduce(function(all, part) {
64366         var subkey = helpkey + "." + part;
64367         var depth = fieldHelpHeadings[subkey];
64368         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
64369         return all + hhh + _t.html(subkey, replacements) + "\n\n";
64370       }, "");
64371       return {
64372         key: helpkey,
64373         title: _t.html(helpkey + ".title"),
64374         html: marked(text.trim())
64375       };
64376     });
64377     function show() {
64378       updatePosition();
64379       _body.classed("hide", false).style("opacity", "0").transition().duration(200).style("opacity", "1");
64380     }
64381     function hide() {
64382       _body.classed("hide", true).transition().duration(200).style("opacity", "0").on("end", function() {
64383         _body.classed("hide", true);
64384       });
64385     }
64386     function clickHelp(index) {
64387       var d2 = docs[index];
64388       var tkeys = fieldHelpKeys[fieldName][index][1];
64389       _body.selectAll(".field-help-nav-item").classed("active", function(d4, i3) {
64390         return i3 === index;
64391       });
64392       var content = _body.selectAll(".field-help-content").html(d2.html);
64393       content.selectAll("p").attr("class", function(d4, i3) {
64394         return tkeys[i3];
64395       });
64396       if (d2.key === "help.field.restrictions.inspecting") {
64397         content.insert("img", "p.from_shadow").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_inspect.gif"));
64398       } else if (d2.key === "help.field.restrictions.modifying") {
64399         content.insert("img", "p.allow_turn").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_modify.gif"));
64400       }
64401     }
64402     fieldHelp.button = function(selection2) {
64403       if (_body.empty())
64404         return;
64405       var button = selection2.selectAll(".field-help-button").data([0]);
64406       button.enter().append("button").attr("class", "field-help-button").call(svgIcon("#iD-icon-help")).merge(button).on("click", function(d3_event) {
64407         d3_event.stopPropagation();
64408         d3_event.preventDefault();
64409         if (_body.classed("hide")) {
64410           show();
64411         } else {
64412           hide();
64413         }
64414       });
64415     };
64416     function updatePosition() {
64417       var wrap2 = _wrap.node();
64418       var inspector = _inspector.node();
64419       var wRect = wrap2.getBoundingClientRect();
64420       var iRect = inspector.getBoundingClientRect();
64421       _body.style("top", wRect.top + inspector.scrollTop - iRect.top + "px");
64422     }
64423     fieldHelp.body = function(selection2) {
64424       _wrap = selection2.selectAll(".form-field-input-wrap");
64425       if (_wrap.empty())
64426         return;
64427       _inspector = context.container().select(".sidebar .entity-editor-pane .inspector-body");
64428       if (_inspector.empty())
64429         return;
64430       _body = _inspector.selectAll(".field-help-body").data([0]);
64431       var enter = _body.enter().append("div").attr("class", "field-help-body hide");
64432       var titleEnter = enter.append("div").attr("class", "field-help-title cf");
64433       titleEnter.append("h2").attr("class", _mainLocalizer.textDirection() === "rtl" ? "fr" : "fl").call(_t.append("help.field." + fieldName + ".title"));
64434       titleEnter.append("button").attr("class", "fr close").attr("title", _t("icons.close")).on("click", function(d3_event) {
64435         d3_event.stopPropagation();
64436         d3_event.preventDefault();
64437         hide();
64438       }).call(svgIcon("#iD-icon-close"));
64439       var navEnter = enter.append("div").attr("class", "field-help-nav cf");
64440       var titles = docs.map(function(d2) {
64441         return d2.title;
64442       });
64443       navEnter.selectAll(".field-help-nav-item").data(titles).enter().append("div").attr("class", "field-help-nav-item").html(function(d2) {
64444         return d2;
64445       }).on("click", function(d3_event, d2) {
64446         d3_event.stopPropagation();
64447         d3_event.preventDefault();
64448         clickHelp(titles.indexOf(d2));
64449       });
64450       enter.append("div").attr("class", "field-help-content");
64451       _body = _body.merge(enter);
64452       clickHelp(0);
64453     };
64454     return fieldHelp;
64455   }
64456
64457   // modules/ui/fields/check.js
64458   function uiFieldCheck(field, context) {
64459     var dispatch14 = dispatch_default("change");
64460     var options2 = field.options;
64461     var values = [];
64462     var texts = [];
64463     var _tags;
64464     var input = select_default2(null);
64465     var text = select_default2(null);
64466     var label = select_default2(null);
64467     var reverser = select_default2(null);
64468     var _impliedYes;
64469     var _entityIDs = [];
64470     var _value;
64471     var stringsField = field.resolveReference("stringsCrossReference");
64472     if (!options2 && stringsField.options) {
64473       options2 = stringsField.options;
64474     }
64475     if (options2) {
64476       for (var i3 in options2) {
64477         var v2 = options2[i3];
64478         values.push(v2 === "undefined" ? void 0 : v2);
64479         texts.push(stringsField.t.html("options." + v2, { "default": v2 }));
64480       }
64481     } else {
64482       values = [void 0, "yes"];
64483       texts = [_t.html("inspector.unknown"), _t.html("inspector.check.yes")];
64484       if (field.type !== "defaultCheck") {
64485         values.push("no");
64486         texts.push(_t.html("inspector.check.no"));
64487       }
64488     }
64489     function checkImpliedYes() {
64490       _impliedYes = field.id === "oneway_yes";
64491       if (field.id === "oneway") {
64492         var entity = context.entity(_entityIDs[0]);
64493         for (var key in entity.tags) {
64494           if (key in osmOneWayTags && entity.tags[key] in osmOneWayTags[key]) {
64495             _impliedYes = true;
64496             texts[0] = _t.html("_tagging.presets.fields.oneway_yes.options.undefined");
64497             break;
64498           }
64499         }
64500       }
64501     }
64502     function reverserHidden() {
64503       if (!context.container().select("div.inspector-hover").empty())
64504         return true;
64505       return !(_value === "yes" || _impliedYes && !_value);
64506     }
64507     function reverserSetText(selection2) {
64508       var entity = _entityIDs.length && context.hasEntity(_entityIDs[0]);
64509       if (reverserHidden() || !entity)
64510         return selection2;
64511       var first = entity.first();
64512       var last = entity.isClosed() ? entity.nodes[entity.nodes.length - 2] : entity.last();
64513       var pseudoDirection = first < last;
64514       var icon2 = pseudoDirection ? "#iD-icon-forward" : "#iD-icon-backward";
64515       selection2.selectAll(".reverser-span").html("").call(_t.append("inspector.check.reverser")).call(svgIcon(icon2, "inline"));
64516       return selection2;
64517     }
64518     var check = function(selection2) {
64519       checkImpliedYes();
64520       label = selection2.selectAll(".form-field-input-wrap").data([0]);
64521       var enter = label.enter().append("label").attr("class", "form-field-input-wrap form-field-input-check");
64522       enter.append("input").property("indeterminate", field.type !== "defaultCheck").attr("type", "checkbox").attr("id", field.domId);
64523       enter.append("span").html(texts[0]).attr("class", "value");
64524       if (field.type === "onewayCheck") {
64525         enter.append("button").attr("class", "reverser" + (reverserHidden() ? " hide" : "")).append("span").attr("class", "reverser-span");
64526       }
64527       label = label.merge(enter);
64528       input = label.selectAll("input");
64529       text = label.selectAll("span.value");
64530       input.on("click", function(d3_event) {
64531         d3_event.stopPropagation();
64532         var t2 = {};
64533         if (Array.isArray(_tags[field.key])) {
64534           if (values.indexOf("yes") !== -1) {
64535             t2[field.key] = "yes";
64536           } else {
64537             t2[field.key] = values[0];
64538           }
64539         } else {
64540           t2[field.key] = values[(values.indexOf(_value) + 1) % values.length];
64541         }
64542         if (t2[field.key] === "reversible" || t2[field.key] === "alternating") {
64543           t2[field.key] = values[0];
64544         }
64545         dispatch14.call("change", this, t2);
64546       });
64547       if (field.type === "onewayCheck") {
64548         reverser = label.selectAll(".reverser");
64549         reverser.call(reverserSetText).on("click", function(d3_event) {
64550           d3_event.preventDefault();
64551           d3_event.stopPropagation();
64552           context.perform(
64553             function(graph) {
64554               for (var i4 in _entityIDs) {
64555                 graph = actionReverse(_entityIDs[i4])(graph);
64556               }
64557               return graph;
64558             },
64559             _t("operations.reverse.annotation.line", { n: 1 })
64560           );
64561           context.validator().validate();
64562           select_default2(this).call(reverserSetText);
64563         });
64564       }
64565     };
64566     check.entityIDs = function(val) {
64567       if (!arguments.length)
64568         return _entityIDs;
64569       _entityIDs = val;
64570       return check;
64571     };
64572     check.tags = function(tags) {
64573       _tags = tags;
64574       function isChecked(val) {
64575         return val !== "no" && val !== "" && val !== void 0 && val !== null;
64576       }
64577       function textFor(val) {
64578         if (val === "")
64579           val = void 0;
64580         var index = values.indexOf(val);
64581         return index !== -1 ? texts[index] : '"' + val + '"';
64582       }
64583       checkImpliedYes();
64584       var isMixed = Array.isArray(tags[field.key]);
64585       _value = !isMixed && tags[field.key] && tags[field.key].toLowerCase();
64586       if (field.type === "onewayCheck" && (_value === "1" || _value === "-1")) {
64587         _value = "yes";
64588       }
64589       input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value));
64590       text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed);
64591       label.classed("set", !!_value);
64592       if (field.type === "onewayCheck") {
64593         reverser.classed("hide", reverserHidden()).call(reverserSetText);
64594       }
64595     };
64596     check.focus = function() {
64597       input.node().focus();
64598     };
64599     return utilRebind(check, dispatch14, "on");
64600   }
64601
64602   // modules/ui/length_indicator.js
64603   function uiLengthIndicator(maxChars) {
64604     var _wrap = select_default2(null);
64605     var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => {
64606       selection2.text("");
64607       selection2.call(svgIcon("#iD-icon-alert", "inline"));
64608       selection2.call(_t.append("inspector.max_length_reached", { maxChars }));
64609     });
64610     var _silent = false;
64611     var lengthIndicator = function(selection2) {
64612       _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]);
64613       _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true);
64614       selection2.call(_tooltip);
64615     };
64616     lengthIndicator.update = function(val) {
64617       const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY));
64618       let indicator = _wrap.selectAll("span.length-indicator").data([strLen]);
64619       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");
64620       if (_silent)
64621         return;
64622       if (strLen > maxChars) {
64623         _tooltip.show();
64624       } else {
64625         _tooltip.hide();
64626       }
64627     };
64628     lengthIndicator.silent = function(val) {
64629       if (!arguments.length)
64630         return _silent;
64631       _silent = val;
64632       return lengthIndicator;
64633     };
64634     return lengthIndicator;
64635   }
64636
64637   // modules/ui/fields/combo.js
64638   function uiFieldCombo(field, context) {
64639     var dispatch14 = dispatch_default("change");
64640     var _isMulti = field.type === "multiCombo" || field.type === "manyCombo";
64641     var _isNetwork = field.type === "networkCombo";
64642     var _isSemi = field.type === "semiCombo";
64643     var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false;
64644     var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false;
64645     var _snake_case = field.snake_case || field.snake_case === void 0;
64646     var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1);
64647     var _container = select_default2(null);
64648     var _inputWrap = select_default2(null);
64649     var _input = select_default2(null);
64650     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
64651     var _comboData = [];
64652     var _multiData = [];
64653     var _entityIDs = [];
64654     var _tags;
64655     var _countryCode;
64656     var _staticPlaceholder;
64657     var _dataDeprecated = [];
64658     _mainFileFetcher.get("deprecated").then(function(d2) {
64659       _dataDeprecated = d2;
64660     }).catch(function() {
64661     });
64662     if (_isMulti && field.key && /[^:]$/.test(field.key)) {
64663       field.key += ":";
64664     }
64665     function snake(s2) {
64666       return s2.replace(/\s+/g, "_");
64667     }
64668     function clean2(s2) {
64669       return s2.split(";").map(function(s3) {
64670         return s3.trim();
64671       }).join(";");
64672     }
64673     function tagValue(dval) {
64674       dval = clean2(dval || "");
64675       var found = getOptions(true).find(function(o2) {
64676         return o2.key && clean2(o2.value) === dval;
64677       });
64678       if (found)
64679         return found.key;
64680       if (field.type === "typeCombo" && !dval) {
64681         return "yes";
64682       }
64683       return restrictTagValueSpelling(dval) || void 0;
64684     }
64685     function restrictTagValueSpelling(dval) {
64686       if (_snake_case) {
64687         dval = snake(dval);
64688       }
64689       if (!field.caseSensitive) {
64690         dval = dval.toLowerCase();
64691       }
64692       return dval;
64693     }
64694     function getLabelId(field2, v2) {
64695       return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2);
64696     }
64697     function displayValue(tval) {
64698       tval = tval || "";
64699       var stringsField = field.resolveReference("stringsCrossReference");
64700       const labelId = getLabelId(stringsField, tval);
64701       if (stringsField.hasTextForStringId(labelId)) {
64702         return stringsField.t(labelId, { default: tval });
64703       }
64704       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64705         return "";
64706       }
64707       return tval;
64708     }
64709     function renderValue(tval) {
64710       tval = tval || "";
64711       var stringsField = field.resolveReference("stringsCrossReference");
64712       const labelId = getLabelId(stringsField, tval);
64713       if (stringsField.hasTextForStringId(labelId)) {
64714         return stringsField.t.append(labelId, { default: tval });
64715       }
64716       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64717         tval = "";
64718       }
64719       return (selection2) => selection2.text(tval);
64720     }
64721     function objectDifference(a2, b2) {
64722       return a2.filter(function(d1) {
64723         return !b2.some(function(d2) {
64724           return d1.value === d2.value;
64725         });
64726       });
64727     }
64728     function initCombo(selection2, attachTo) {
64729       if (!_allowCustomValues) {
64730         selection2.attr("readonly", "readonly");
64731       }
64732       if (_showTagInfoSuggestions && services.taginfo) {
64733         selection2.call(_combobox.fetcher(setTaginfoValues), attachTo);
64734         setTaginfoValues("", setPlaceholder);
64735       } else {
64736         selection2.call(_combobox, attachTo);
64737         setTimeout(() => setStaticValues(setPlaceholder), 0);
64738       }
64739     }
64740     function getOptions(allOptions) {
64741       var stringsField = field.resolveReference("stringsCrossReference");
64742       if (!(field.options || stringsField.options))
64743         return [];
64744       let options2;
64745       if (allOptions !== true) {
64746         options2 = field.options || stringsField.options;
64747       } else {
64748         options2 = [].concat(field.options, stringsField.options).filter(Boolean);
64749       }
64750       return options2.map(function(v2) {
64751         const labelId = getLabelId(stringsField, v2);
64752         return {
64753           key: v2,
64754           value: stringsField.t(labelId, { default: v2 }),
64755           title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }),
64756           display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64757           klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option"
64758         };
64759       });
64760     }
64761     function hasStaticValues() {
64762       return getOptions().length > 0;
64763     }
64764     function setStaticValues(callback, filter2) {
64765       _comboData = getOptions();
64766       if (filter2 !== void 0) {
64767         _comboData = _comboData.filter(filter2);
64768       }
64769       _comboData = objectDifference(_comboData, _multiData);
64770       _combobox.data(_comboData);
64771       if (callback)
64772         callback(_comboData);
64773     }
64774     function setTaginfoValues(q2, callback) {
64775       var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase());
64776       if (hasStaticValues()) {
64777         setStaticValues(callback, queryFilter);
64778       }
64779       var stringsField = field.resolveReference("stringsCrossReference");
64780       var fn = _isMulti ? "multikeys" : "values";
64781       var query = (_isMulti ? field.key : "") + q2;
64782       var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0;
64783       if (hasCountryPrefix) {
64784         query = _countryCode + ":";
64785       }
64786       var params = {
64787         debounce: q2 !== "",
64788         key: field.key,
64789         query
64790       };
64791       if (_entityIDs.length) {
64792         params.geometry = context.graph().geometry(_entityIDs[0]);
64793       }
64794       services.taginfo[fn](params, function(err, data) {
64795         if (err)
64796           return;
64797         data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes");
64798         data = data.filter((d2) => {
64799           var value = d2.value;
64800           if (_isMulti) {
64801             value = value.slice(field.key.length);
64802           }
64803           return value === restrictTagValueSpelling(value);
64804         });
64805         var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key];
64806         if (deprecatedValues) {
64807           data = data.filter((d2) => !deprecatedValues.includes(d2.value));
64808         }
64809         if (hasCountryPrefix) {
64810           data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0);
64811         }
64812         const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 }));
64813         _container.classed("empty-combobox", data.length === 0);
64814         _comboData = data.concat(additionalOptions).map(function(d2) {
64815           var v2 = d2.value;
64816           if (_isMulti)
64817             v2 = v2.replace(field.key, "");
64818           const labelId = getLabelId(stringsField, v2);
64819           var isLocalizable = stringsField.hasTextForStringId(labelId);
64820           var label = stringsField.t(labelId, { default: v2 });
64821           return {
64822             key: v2,
64823             value: label,
64824             title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }),
64825             display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64826             klass: isLocalizable ? "" : "raw-option"
64827           };
64828         });
64829         _comboData = _comboData.filter(queryFilter);
64830         _comboData = objectDifference(_comboData, _multiData);
64831         if (callback)
64832           callback(_comboData, hasStaticValues());
64833       });
64834     }
64835     function addComboboxIcons(disp, value) {
64836       const iconsField = field.resolveReference("iconsCrossReference");
64837       if (iconsField.icons) {
64838         return function(selection2) {
64839           var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon");
64840           if (iconsField.icons[value]) {
64841             span.call(svgIcon("#".concat(iconsField.icons[value])));
64842           }
64843           disp.call(this, selection2);
64844         };
64845       }
64846       return disp;
64847     }
64848     function setPlaceholder(values) {
64849       if (_isMulti || _isSemi) {
64850         _staticPlaceholder = field.placeholder() || _t("inspector.add");
64851       } else {
64852         var vals = values.map(function(d2) {
64853           return d2.value;
64854         }).filter(function(s2) {
64855           return s2.length < 20;
64856         });
64857         var placeholders = vals.length > 1 ? vals : values.map(function(d2) {
64858           return d2.key;
64859         });
64860         _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", ");
64861       }
64862       if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) {
64863         _staticPlaceholder += "\u2026";
64864       }
64865       var ph;
64866       if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
64867         ph = _t("inspector.multiple_values");
64868       } else {
64869         ph = _staticPlaceholder;
64870       }
64871       _container.selectAll("input").attr("placeholder", ph);
64872       var hideAdd = !_allowCustomValues && !values.length;
64873       _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
64874     }
64875     function change() {
64876       var t2 = {};
64877       var val;
64878       if (_isMulti || _isSemi) {
64879         var vals;
64880         if (_isMulti) {
64881           vals = [tagValue(utilGetSetValue(_input))];
64882         } else if (_isSemi) {
64883           val = tagValue(utilGetSetValue(_input)) || "";
64884           val = val.replace(/,/g, ";");
64885           vals = val.split(";");
64886         }
64887         vals = vals.filter(Boolean);
64888         if (!vals.length)
64889           return;
64890         _container.classed("active", false);
64891         utilGetSetValue(_input, "");
64892         if (_isMulti) {
64893           utilArrayUniq(vals).forEach(function(v2) {
64894             var key = (field.key || "") + v2;
64895             if (_tags) {
64896               var old = _tags[key];
64897               if (typeof old === "string" && old.toLowerCase() !== "no")
64898                 return;
64899             }
64900             key = context.cleanTagKey(key);
64901             field.keys.push(key);
64902             t2[key] = "yes";
64903           });
64904         } else if (_isSemi) {
64905           var arr = _multiData.map(function(d2) {
64906             return d2.key;
64907           });
64908           arr = arr.concat(vals);
64909           t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";"));
64910         }
64911         window.setTimeout(function() {
64912           _input.node().focus();
64913         }, 10);
64914       } else {
64915         var rawValue = utilGetSetValue(_input);
64916         if (!rawValue && Array.isArray(_tags[field.key]))
64917           return;
64918         val = context.cleanTagValue(tagValue(rawValue));
64919         t2[field.key] = val || void 0;
64920       }
64921       dispatch14.call("change", this, t2);
64922     }
64923     function removeMultikey(d3_event, d2) {
64924       d3_event.preventDefault();
64925       d3_event.stopPropagation();
64926       var t2 = {};
64927       if (_isMulti) {
64928         t2[d2.key] = void 0;
64929       } else if (_isSemi) {
64930         var arr = _multiData.map(function(md) {
64931           return md.key === d2.key ? null : md.key;
64932         }).filter(Boolean);
64933         arr = utilArrayUniq(arr);
64934         t2[field.key] = arr.length ? arr.join(";") : void 0;
64935         _lengthIndicator.update(t2[field.key]);
64936       }
64937       dispatch14.call("change", this, t2);
64938     }
64939     function invertMultikey(d3_event, d2) {
64940       d3_event.preventDefault();
64941       d3_event.stopPropagation();
64942       var t2 = {};
64943       if (_isMulti) {
64944         t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes";
64945       }
64946       dispatch14.call("change", this, t2);
64947     }
64948     function combo(selection2) {
64949       _container = selection2.selectAll(".form-field-input-wrap").data([0]);
64950       var type2 = _isMulti || _isSemi ? "multicombo" : "combo";
64951       _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container);
64952       if (_isMulti || _isSemi) {
64953         _container = _container.selectAll(".chiplist").data([0]);
64954         var listClass = "chiplist";
64955         if (field.key === "destination" || field.key === "via") {
64956           listClass += " full-line-chips";
64957         }
64958         _container = _container.enter().append("ul").attr("class", listClass).on("click", function() {
64959           window.setTimeout(function() {
64960             _input.node().focus();
64961           }, 10);
64962         }).merge(_container);
64963         _inputWrap = _container.selectAll(".input-wrap").data([0]);
64964         _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap);
64965         var hideAdd = !_allowCustomValues && !_comboData.length;
64966         _inputWrap.style("display", hideAdd ? "none" : null);
64967         _input = _inputWrap.selectAll("input").data([0]);
64968       } else {
64969         _input = _container.selectAll("input").data([0]);
64970       }
64971       _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input);
64972       if (_isSemi) {
64973         _inputWrap.call(_lengthIndicator);
64974       } else if (!_isMulti) {
64975         _container.call(_lengthIndicator);
64976       }
64977       if (_isNetwork) {
64978         var extent = combinedEntityExtent();
64979         var countryCode = extent && iso1A2Code(extent.center());
64980         _countryCode = countryCode && countryCode.toLowerCase();
64981       }
64982       _input.on("change", change).on("blur", change).on("input", function() {
64983         let val = utilGetSetValue(_input);
64984         updateIcon(val);
64985         if (_isSemi && _tags[field.key]) {
64986           val += ";" + _tags[field.key];
64987         }
64988         _lengthIndicator.update(val);
64989       });
64990       _input.on("keydown.field", function(d3_event) {
64991         switch (d3_event.keyCode) {
64992           case 13:
64993             _input.node().blur();
64994             d3_event.stopPropagation();
64995             break;
64996         }
64997       });
64998       if (_isMulti || _isSemi) {
64999         _combobox.on("accept", function() {
65000           _input.node().blur();
65001           _input.node().focus();
65002         });
65003         _input.on("focus", function() {
65004           _container.classed("active", true);
65005         });
65006       }
65007       _combobox.on("cancel", function() {
65008         _input.node().blur();
65009       }).on("update", function() {
65010         updateIcon(utilGetSetValue(_input));
65011       });
65012     }
65013     function updateIcon(value) {
65014       value = tagValue(value);
65015       let container = _container;
65016       if (field.type === "multiCombo" || field.type === "semiCombo") {
65017         container = _container.select(".input-wrap");
65018       }
65019       const iconsField = field.resolveReference("iconsCrossReference");
65020       if (iconsField.icons) {
65021         container.selectAll(".tag-value-icon").remove();
65022         if (iconsField.icons[value]) {
65023           container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value])));
65024         }
65025       }
65026     }
65027     combo.tags = function(tags) {
65028       _tags = tags;
65029       var stringsField = field.resolveReference("stringsCrossReference");
65030       var isMixed = Array.isArray(tags[field.key]);
65031       var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes");
65032       var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title"));
65033       var isKnownValue = (value) => showsValue(value) && !isRawValue(value);
65034       var isReadOnly = !_allowCustomValues;
65035       if (_isMulti || _isSemi) {
65036         _multiData = [];
65037         var maxLength;
65038         if (_isMulti) {
65039           for (var k2 in tags) {
65040             if (field.key && k2.indexOf(field.key) !== 0)
65041               continue;
65042             if (!field.key && field.keys.indexOf(k2) === -1)
65043               continue;
65044             var v2 = tags[k2];
65045             var suffix = field.key ? k2.slice(field.key.length) : k2;
65046             _multiData.push({
65047               key: k2,
65048               value: displayValue(suffix),
65049               display: addComboboxIcons(renderValue(suffix), suffix),
65050               state: typeof v2 === "string" ? v2.toLowerCase() : "",
65051               isMixed: Array.isArray(v2)
65052             });
65053           }
65054           if (field.key) {
65055             field.keys = _multiData.map(function(d2) {
65056               return d2.key;
65057             });
65058             maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
65059           } else {
65060             maxLength = context.maxCharsForTagKey();
65061           }
65062         } else if (_isSemi) {
65063           var allValues = [];
65064           var commonValues;
65065           if (Array.isArray(tags[field.key])) {
65066             tags[field.key].forEach(function(tagVal) {
65067               var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean);
65068               allValues = allValues.concat(thisVals);
65069               if (!commonValues) {
65070                 commonValues = thisVals;
65071               } else {
65072                 commonValues = commonValues.filter((value) => thisVals.includes(value));
65073               }
65074             });
65075             allValues = utilArrayUniq(allValues).filter(Boolean);
65076           } else {
65077             allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean);
65078             commonValues = allValues;
65079           }
65080           _multiData = allValues.map(function(v3) {
65081             return {
65082               key: v3,
65083               value: displayValue(v3),
65084               display: addComboboxIcons(renderValue(v3), v3),
65085               isMixed: !commonValues.includes(v3)
65086             };
65087           });
65088           var currLength = utilUnicodeCharsCount(commonValues.join(";"));
65089           maxLength = context.maxCharsForTagValue() - currLength;
65090           if (currLength > 0) {
65091             maxLength -= 1;
65092           }
65093         }
65094         maxLength = Math.max(0, maxLength);
65095         var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length;
65096         _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
65097         var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]);
65098         var chips = _container.selectAll(".chip").data(_multiData);
65099         chips.exit().remove();
65100         var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip");
65101         enter.append("span");
65102         const field_buttons = enter.append("div").attr("class", "field_buttons");
65103         field_buttons.append("a").attr("class", "remove");
65104         chips = chips.merge(enter).order().classed("raw-value", function(d2) {
65105           var k3 = d2.key;
65106           if (_isMulti)
65107             k3 = k3.replace(field.key, "");
65108           return !stringsField.hasTextForStringId("options." + k3);
65109         }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) {
65110           return d2.isMixed;
65111         }).attr("title", function(d2) {
65112           if (d2.isMixed) {
65113             return _t("inspector.unshared_value_tooltip");
65114           }
65115           if (!["yes", "no"].includes(d2.state)) {
65116             return d2.state;
65117           }
65118           return null;
65119         }).classed("negated", (d2) => d2.state === "no");
65120         if (!_isSemi) {
65121           chips.selectAll("input[type=checkbox]").remove();
65122           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);
65123         }
65124         if (allowDragAndDrop) {
65125           registerDragAndDrop(chips);
65126         }
65127         chips.each(function(d2) {
65128           const selection2 = select_default2(this);
65129           const text_span = selection2.select("span");
65130           const field_buttons2 = selection2.select(".field_buttons");
65131           const clean_value = d2.value.trim();
65132           text_span.text("");
65133           if (!field_buttons2.select("button").empty()) {
65134             field_buttons2.select("button").remove();
65135           }
65136           if (clean_value.startsWith("https://")) {
65137             text_span.text(clean_value);
65138             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) {
65139               d3_event.preventDefault();
65140               window.open(clean_value, "_blank");
65141             });
65142             return;
65143           }
65144           if (d2.display) {
65145             d2.display(text_span);
65146             return;
65147           }
65148           text_span.text(d2.value);
65149         });
65150         chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7");
65151         updateIcon("");
65152       } else {
65153         var mixedValues = isMixed && tags[field.key].map(function(val) {
65154           return displayValue(val);
65155         }).filter(Boolean);
65156         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) {
65157           if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
65158             d3_event.preventDefault();
65159             d3_event.stopPropagation();
65160             var t2 = {};
65161             t2[field.key] = void 0;
65162             dispatch14.call("change", this, t2);
65163           }
65164         });
65165         if (!Array.isArray(tags[field.key])) {
65166           updateIcon(tags[field.key]);
65167         }
65168         if (!isMixed) {
65169           _lengthIndicator.update(tags[field.key]);
65170         }
65171       }
65172       const refreshStyles = () => {
65173         _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue);
65174       };
65175       _input.on("input.refreshStyles", refreshStyles);
65176       _combobox.on("update.refreshStyles", refreshStyles);
65177       refreshStyles();
65178     };
65179     function registerDragAndDrop(selection2) {
65180       var dragOrigin, targetIndex;
65181       selection2.call(
65182         drag_default().on("start", function(d3_event) {
65183           dragOrigin = {
65184             x: d3_event.x,
65185             y: d3_event.y
65186           };
65187           targetIndex = null;
65188         }).on("drag", function(d3_event) {
65189           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
65190           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
65191           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
65192             return;
65193           var index = selection2.nodes().indexOf(this);
65194           select_default2(this).classed("dragging", true);
65195           targetIndex = null;
65196           var targetIndexOffsetTop = null;
65197           var draggedTagWidth = select_default2(this).node().offsetWidth;
65198           if (field.key === "destination" || field.key === "via") {
65199             _container.selectAll(".chip").style("transform", function(d2, index2) {
65200               var node = select_default2(this).node();
65201               if (index === index2) {
65202                 return "translate(" + x2 + "px, " + y2 + "px)";
65203               } else if (index2 > index && d3_event.y > node.offsetTop) {
65204                 if (targetIndex === null || index2 > targetIndex) {
65205                   targetIndex = index2;
65206                 }
65207                 return "translateY(-100%)";
65208               } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
65209                 if (targetIndex === null || index2 < targetIndex) {
65210                   targetIndex = index2;
65211                 }
65212                 return "translateY(100%)";
65213               }
65214               return null;
65215             });
65216           } else {
65217             _container.selectAll(".chip").each(function(d2, index2) {
65218               var node = select_default2(this).node();
65219               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) {
65220                 targetIndex = index2;
65221                 targetIndexOffsetTop = node.offsetTop;
65222               }
65223             }).style("transform", function(d2, index2) {
65224               var node = select_default2(this).node();
65225               if (index === index2) {
65226                 return "translate(" + x2 + "px, " + y2 + "px)";
65227               }
65228               if (node.offsetTop === targetIndexOffsetTop) {
65229                 if (index2 < index && index2 >= targetIndex) {
65230                   return "translateX(" + draggedTagWidth + "px)";
65231                 } else if (index2 > index && index2 <= targetIndex) {
65232                   return "translateX(-" + draggedTagWidth + "px)";
65233                 }
65234               }
65235               return null;
65236             });
65237           }
65238         }).on("end", function() {
65239           if (!select_default2(this).classed("dragging")) {
65240             return;
65241           }
65242           var index = selection2.nodes().indexOf(this);
65243           select_default2(this).classed("dragging", false);
65244           _container.selectAll(".chip").style("transform", null);
65245           if (typeof targetIndex === "number") {
65246             var element = _multiData[index];
65247             _multiData.splice(index, 1);
65248             _multiData.splice(targetIndex, 0, element);
65249             var t2 = {};
65250             if (_multiData.length) {
65251               t2[field.key] = _multiData.map(function(element2) {
65252                 return element2.key;
65253               }).join(";");
65254             } else {
65255               t2[field.key] = void 0;
65256             }
65257             dispatch14.call("change", this, t2);
65258           }
65259           dragOrigin = void 0;
65260           targetIndex = void 0;
65261         })
65262       );
65263     }
65264     combo.focus = function() {
65265       _input.node().focus();
65266     };
65267     combo.entityIDs = function(val) {
65268       if (!arguments.length)
65269         return _entityIDs;
65270       _entityIDs = val;
65271       return combo;
65272     };
65273     function combinedEntityExtent() {
65274       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65275     }
65276     return utilRebind(combo, dispatch14, "on");
65277   }
65278
65279   // modules/ui/fields/input.js
65280   var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
65281   function uiFieldText(field, context) {
65282     var dispatch14 = dispatch_default("change");
65283     var input = select_default2(null);
65284     var outlinkButton = select_default2(null);
65285     var wrap2 = select_default2(null);
65286     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
65287     var _entityIDs = [];
65288     var _tags;
65289     var _phoneFormats = {};
65290     const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
65291     const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
65292     const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
65293     const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
65294     if (field.type === "tel") {
65295       _mainFileFetcher.get("phone_formats").then(function(d2) {
65296         _phoneFormats = d2;
65297         updatePhonePlaceholder();
65298       }).catch(function() {
65299       });
65300     }
65301     function calcLocked() {
65302       var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
65303         var entity = context.graph().hasEntity(entityID);
65304         if (!entity)
65305           return false;
65306         if (entity.tags.wikidata)
65307           return true;
65308         var preset = _mainPresetIndex.match(entity, context.graph());
65309         var isSuggestion = preset && preset.suggestion;
65310         var which = field.id;
65311         return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
65312       });
65313       field.locked(isLocked);
65314     }
65315     function i3(selection2) {
65316       calcLocked();
65317       var isLocked = field.locked();
65318       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65319       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65320       input = wrap2.selectAll("input").data([0]);
65321       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);
65322       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
65323       wrap2.call(_lengthIndicator);
65324       if (field.type === "tel") {
65325         updatePhonePlaceholder();
65326       } else if (field.type === "number") {
65327         var rtl = _mainLocalizer.textDirection() === "rtl";
65328         input.attr("type", "text");
65329         var inc = field.increment;
65330         var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
65331         buttons.enter().append("button").attr("class", function(d2) {
65332           var which = d2 > 0 ? "increment" : "decrement";
65333           return "form-field-button " + which;
65334         }).attr("title", function(d2) {
65335           var which = d2 > 0 ? "increment" : "decrement";
65336           return _t("inspector.".concat(which));
65337         }).merge(buttons).on("click", function(d3_event, d2) {
65338           d3_event.preventDefault();
65339           var isMixed = Array.isArray(_tags[field.key]);
65340           if (isMixed)
65341             return;
65342           var raw_vals = input.node().value || "0";
65343           var vals = raw_vals.split(";");
65344           vals = vals.map(function(v2) {
65345             v2 = v2.trim();
65346             const isRawNumber = likelyRawNumberFormat.test(v2);
65347             var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
65348             if (isDirectionField) {
65349               const compassDir = cardinal[v2.toLowerCase()];
65350               if (compassDir !== void 0) {
65351                 num = compassDir;
65352               }
65353             }
65354             if (!isFinite(num))
65355               return v2;
65356             num = parseFloat(num);
65357             if (!isFinite(num))
65358               return v2;
65359             num += d2;
65360             if (isDirectionField) {
65361               num = (num % 360 + 360) % 360;
65362             }
65363             return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
65364           });
65365           input.node().value = vals.join(";");
65366           change()();
65367         });
65368       } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
65369         input.attr("type", "text");
65370         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65371         outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
65372           var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
65373           if (domainResults.length >= 2 && domainResults[1]) {
65374             var domain = domainResults[1];
65375             return _t("icons.view_on", { domain });
65376           }
65377           return "";
65378         }).merge(outlinkButton);
65379         outlinkButton.on("click", function(d3_event) {
65380           d3_event.preventDefault();
65381           var value = validIdentifierValueForLink();
65382           if (value) {
65383             var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
65384             window.open(url, "_blank");
65385           }
65386         }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
65387       } else if (field.type === "url") {
65388         input.attr("type", "text");
65389         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65390         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) {
65391           d3_event.preventDefault();
65392           const value = validIdentifierValueForLink();
65393           if (value)
65394             window.open(value, "_blank");
65395         }).merge(outlinkButton);
65396       } else if (field.type === "colour") {
65397         input.attr("type", "text");
65398         updateColourPreview();
65399       } else if (field.type === "date") {
65400         input.attr("type", "text");
65401         updateDateField();
65402       }
65403     }
65404     function updateColourPreview() {
65405       wrap2.selectAll(".colour-preview").remove();
65406       const colour = utilGetSetValue(input);
65407       if (!isColourValid(colour) && colour !== "") {
65408         wrap2.selectAll("input.colour-selector").remove();
65409         wrap2.selectAll(".form-field-button").remove();
65410         return;
65411       }
65412       var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
65413       colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
65414         d3_event.preventDefault();
65415         var colour2 = this.value;
65416         if (!isColourValid(colour2))
65417           return;
65418         utilGetSetValue(input, this.value);
65419         change()();
65420         updateColourPreview();
65421       }, 100));
65422       wrap2.selectAll("input.colour-selector").attr("value", colour);
65423       var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
65424       chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
65425       if (colour === "") {
65426         chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
65427       }
65428       chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
65429     }
65430     function updateDateField() {
65431       function isDateValid(date2) {
65432         return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
65433       }
65434       const date = utilGetSetValue(input);
65435       const now3 = /* @__PURE__ */ new Date();
65436       const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
65437       if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
65438         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", () => {
65439           utilGetSetValue(input, today);
65440           change()();
65441           updateDateField();
65442         });
65443       } else {
65444         wrap2.selectAll(".date-set-today").remove();
65445       }
65446       if (!isDateValid(date) && date !== "") {
65447         wrap2.selectAll("input.date-selector").remove();
65448         wrap2.selectAll(".date-calendar").remove();
65449         return;
65450       }
65451       if (utilDetect().browser !== "Safari") {
65452         var dateSelector = wrap2.selectAll(".date-selector").data([0]);
65453         dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
65454           d3_event.preventDefault();
65455           var date2 = this.value;
65456           if (!isDateValid(date2))
65457             return;
65458           utilGetSetValue(input, this.value);
65459           change()();
65460           updateDateField();
65461         }, 100));
65462         wrap2.selectAll("input.date-selector").attr("value", date);
65463         var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
65464         calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
65465         calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
65466       }
65467     }
65468     function updatePhonePlaceholder() {
65469       if (input.empty() || !Object.keys(_phoneFormats).length)
65470         return;
65471       var extent = combinedEntityExtent();
65472       var countryCode = extent && iso1A2Code(extent.center());
65473       var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
65474       if (format2)
65475         input.attr("placeholder", format2);
65476     }
65477     function validIdentifierValueForLink() {
65478       var _a2;
65479       const value = utilGetSetValue(input).trim();
65480       if (field.type === "url" && value) {
65481         try {
65482           return new URL(value).href;
65483         } catch {
65484           return null;
65485         }
65486       }
65487       if (field.type === "identifier" && field.pattern) {
65488         return value && ((_a2 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a2[0]);
65489       }
65490       return null;
65491     }
65492     function clamped(num) {
65493       if (field.minValue !== void 0) {
65494         num = Math.max(num, field.minValue);
65495       }
65496       if (field.maxValue !== void 0) {
65497         num = Math.min(num, field.maxValue);
65498       }
65499       return num;
65500     }
65501     function getVals(tags) {
65502       if (field.keys) {
65503         const multiSelection = context.selectedIDs();
65504         tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
65505         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]));
65506       } else {
65507         return new Set([].concat(tags[field.key]));
65508       }
65509     }
65510     function change(onInput) {
65511       return function() {
65512         var t2 = {};
65513         var val = utilGetSetValue(input);
65514         if (!onInput)
65515           val = context.cleanTagValue(val);
65516         if (!val && getVals(_tags).size > 1)
65517           return;
65518         var displayVal = val;
65519         if (field.type === "number" && val) {
65520           var numbers2 = val.split(";");
65521           numbers2 = numbers2.map(function(v2) {
65522             if (likelyRawNumberFormat.test(v2)) {
65523               return v2;
65524             }
65525             var num = parseLocaleFloat(v2);
65526             const fractionDigits = countDecimalPlaces(v2);
65527             return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
65528           });
65529           val = numbers2.join(";");
65530         }
65531         if (!onInput)
65532           utilGetSetValue(input, displayVal);
65533         t2[field.key] = val || void 0;
65534         if (field.keys) {
65535           dispatch14.call("change", this, (tags) => {
65536             if (field.keys.some((key) => tags[key])) {
65537               field.keys.filter((key) => tags[key]).forEach((key) => {
65538                 tags[key] = val || void 0;
65539               });
65540             } else {
65541               tags[field.key] = val || void 0;
65542             }
65543             return tags;
65544           }, onInput);
65545         } else {
65546           dispatch14.call("change", this, t2, onInput);
65547         }
65548       };
65549     }
65550     i3.entityIDs = function(val) {
65551       if (!arguments.length)
65552         return _entityIDs;
65553       _entityIDs = val;
65554       return i3;
65555     };
65556     i3.tags = function(tags) {
65557       var _a2;
65558       _tags = tags;
65559       const vals = getVals(tags);
65560       const isMixed = vals.size > 1;
65561       var val = vals.size === 1 ? (_a2 = [...vals][0]) != null ? _a2 : "" : "";
65562       var shouldUpdate;
65563       if (field.type === "number" && val) {
65564         var numbers2 = val.split(";");
65565         var oriNumbers = utilGetSetValue(input).split(";");
65566         if (numbers2.length !== oriNumbers.length)
65567           shouldUpdate = true;
65568         numbers2 = numbers2.map(function(v2) {
65569           v2 = v2.trim();
65570           var num = Number(v2);
65571           if (!isFinite(num) || v2 === "")
65572             return v2;
65573           const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
65574           return formatFloat(num, fractionDigits);
65575         });
65576         val = numbers2.join(";");
65577         shouldUpdate = (inputValue, setValue) => {
65578           const inputNums = inputValue.split(";").map(
65579             (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
65580           );
65581           const setNums = setValue.split(";").map(parseLocaleFloat);
65582           return !isEqual_default(inputNums, setNums);
65583         };
65584       }
65585       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);
65586       if (field.type === "number") {
65587         const buttons = wrap2.selectAll(".increment, .decrement");
65588         if (isMixed) {
65589           buttons.attr("disabled", "disabled").classed("disabled", true);
65590         } else {
65591           var raw_vals = tags[field.key] || "0";
65592           const canIncDec = raw_vals.split(";").some((val2) => isFinite(Number(val2)) || isDirectionField && cardinal[val2.trim().toLowerCase()]);
65593           buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
65594         }
65595       }
65596       if (field.type === "tel")
65597         updatePhonePlaceholder();
65598       if (field.type === "colour")
65599         updateColourPreview();
65600       if (field.type === "date")
65601         updateDateField();
65602       if (outlinkButton && !outlinkButton.empty()) {
65603         var disabled = !validIdentifierValueForLink();
65604         outlinkButton.classed("disabled", disabled);
65605       }
65606       if (!isMixed) {
65607         _lengthIndicator.update(tags[field.key]);
65608       }
65609     };
65610     i3.focus = function() {
65611       var node = input.node();
65612       if (node)
65613         node.focus();
65614     };
65615     function combinedEntityExtent() {
65616       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65617     }
65618     return utilRebind(i3, dispatch14, "on");
65619   }
65620
65621   // modules/ui/fields/access.js
65622   function uiFieldAccess(field, context) {
65623     var dispatch14 = dispatch_default("change");
65624     var items = select_default2(null);
65625     var _tags;
65626     function access(selection2) {
65627       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65628       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65629       var list2 = wrap2.selectAll("ul").data([0]);
65630       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
65631       items = list2.selectAll("li").data(field.keys);
65632       var enter = items.enter().append("li").attr("class", function(d2) {
65633         return "labeled-input preset-access-" + d2;
65634       });
65635       enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
65636         return "preset-input-access-" + d2;
65637       }).html(function(d2) {
65638         return field.t.html("types." + d2);
65639       });
65640       enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
65641         return "preset-input-access preset-input-access-" + d2;
65642       }).call(utilNoAuto).each(function(d2) {
65643         select_default2(this).call(
65644           uiCombobox(context, "access-" + d2).data(access.options(d2))
65645         );
65646       });
65647       items = items.merge(enter);
65648       wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
65649     }
65650     function change(d3_event, d2) {
65651       var tag2 = {};
65652       var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
65653       if (!value && typeof _tags[d2] !== "string")
65654         return;
65655       tag2[d2] = value || void 0;
65656       dispatch14.call("change", this, tag2);
65657     }
65658     access.options = function(type2) {
65659       var options2 = [
65660         "yes",
65661         "no",
65662         "designated",
65663         "permissive",
65664         "destination",
65665         "customers",
65666         "private",
65667         "permit",
65668         "unknown"
65669       ];
65670       if (type2 === "access") {
65671         options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
65672       }
65673       if (type2 === "bicycle") {
65674         options2.splice(options2.length - 4, 0, "dismount");
65675       }
65676       var stringsField = field.resolveReference("stringsCrossReference");
65677       return options2.map(function(option) {
65678         return {
65679           title: stringsField.t("options." + option + ".description"),
65680           value: option
65681         };
65682       });
65683     };
65684     const placeholdersByTag = {
65685       highway: {
65686         footway: {
65687           foot: "designated",
65688           motor_vehicle: "no"
65689         },
65690         steps: {
65691           foot: "yes",
65692           motor_vehicle: "no",
65693           bicycle: "no",
65694           horse: "no"
65695         },
65696         pedestrian: {
65697           foot: "yes",
65698           motor_vehicle: "no"
65699         },
65700         cycleway: {
65701           motor_vehicle: "no",
65702           bicycle: "designated"
65703         },
65704         bridleway: {
65705           motor_vehicle: "no",
65706           horse: "designated"
65707         },
65708         path: {
65709           foot: "yes",
65710           motor_vehicle: "no",
65711           bicycle: "yes",
65712           horse: "yes"
65713         },
65714         motorway: {
65715           foot: "no",
65716           motor_vehicle: "yes",
65717           bicycle: "no",
65718           horse: "no"
65719         },
65720         trunk: {
65721           motor_vehicle: "yes"
65722         },
65723         primary: {
65724           foot: "yes",
65725           motor_vehicle: "yes",
65726           bicycle: "yes",
65727           horse: "yes"
65728         },
65729         secondary: {
65730           foot: "yes",
65731           motor_vehicle: "yes",
65732           bicycle: "yes",
65733           horse: "yes"
65734         },
65735         tertiary: {
65736           foot: "yes",
65737           motor_vehicle: "yes",
65738           bicycle: "yes",
65739           horse: "yes"
65740         },
65741         residential: {
65742           foot: "yes",
65743           motor_vehicle: "yes",
65744           bicycle: "yes",
65745           horse: "yes"
65746         },
65747         unclassified: {
65748           foot: "yes",
65749           motor_vehicle: "yes",
65750           bicycle: "yes",
65751           horse: "yes"
65752         },
65753         service: {
65754           foot: "yes",
65755           motor_vehicle: "yes",
65756           bicycle: "yes",
65757           horse: "yes"
65758         },
65759         motorway_link: {
65760           foot: "no",
65761           motor_vehicle: "yes",
65762           bicycle: "no",
65763           horse: "no"
65764         },
65765         trunk_link: {
65766           motor_vehicle: "yes"
65767         },
65768         primary_link: {
65769           foot: "yes",
65770           motor_vehicle: "yes",
65771           bicycle: "yes",
65772           horse: "yes"
65773         },
65774         secondary_link: {
65775           foot: "yes",
65776           motor_vehicle: "yes",
65777           bicycle: "yes",
65778           horse: "yes"
65779         },
65780         tertiary_link: {
65781           foot: "yes",
65782           motor_vehicle: "yes",
65783           bicycle: "yes",
65784           horse: "yes"
65785         },
65786         construction: {
65787           access: "no"
65788         },
65789         busway: {
65790           access: "no",
65791           bus: "designated",
65792           emergency: "yes"
65793         }
65794       },
65795       barrier: {
65796         bollard: {
65797           access: "no",
65798           bicycle: "yes",
65799           foot: "yes"
65800         },
65801         bus_trap: {
65802           motor_vehicle: "no",
65803           psv: "yes",
65804           foot: "yes",
65805           bicycle: "yes"
65806         },
65807         city_wall: {
65808           access: "no"
65809         },
65810         coupure: {
65811           access: "yes"
65812         },
65813         cycle_barrier: {
65814           motor_vehicle: "no"
65815         },
65816         ditch: {
65817           access: "no"
65818         },
65819         entrance: {
65820           access: "yes"
65821         },
65822         fence: {
65823           access: "no"
65824         },
65825         hedge: {
65826           access: "no"
65827         },
65828         jersey_barrier: {
65829           access: "no"
65830         },
65831         motorcycle_barrier: {
65832           motor_vehicle: "no"
65833         },
65834         rail_guard: {
65835           access: "no"
65836         }
65837       }
65838     };
65839     access.tags = function(tags) {
65840       _tags = tags;
65841       utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
65842         return typeof tags[d2] === "string" ? tags[d2] : "";
65843       }).classed("mixed", function(d2) {
65844         return tags[d2] && Array.isArray(tags[d2]);
65845       }).attr("title", function(d2) {
65846         return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
65847       }).attr("placeholder", function(d2) {
65848         if (tags[d2] && Array.isArray(tags[d2])) {
65849           return _t("inspector.multiple_values");
65850         }
65851         if (d2 === "bicycle" || d2 === "motor_vehicle") {
65852           if (tags.vehicle && typeof tags.vehicle === "string") {
65853             return tags.vehicle;
65854           }
65855         }
65856         if (tags.access && typeof tags.access === "string") {
65857           return tags.access;
65858         }
65859         function getPlaceholdersByTag(key, placeholdersByKey) {
65860           if (typeof tags[key] === "string") {
65861             if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
65862               return placeholdersByKey[tags[key]][d2];
65863             }
65864           } else {
65865             var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
65866               return placeholdersByKey[val] && placeholdersByKey[val][d2];
65867             }).filter(Boolean);
65868             if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
65869               return impliedAccesses[0];
65870             }
65871           }
65872         }
65873         for (const key in placeholdersByTag) {
65874           if (tags[key]) {
65875             const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
65876             if (impliedAccess) {
65877               return impliedAccess;
65878             }
65879           }
65880         }
65881         if (d2 === "access" && !tags.barrier) {
65882           return "yes";
65883         }
65884         return field.placeholder();
65885       });
65886     };
65887     access.focus = function() {
65888       items.selectAll(".preset-input-access").node().focus();
65889     };
65890     return utilRebind(access, dispatch14, "on");
65891   }
65892
65893   // modules/ui/fields/address.js
65894   function uiFieldAddress(field, context) {
65895     var dispatch14 = dispatch_default("change");
65896     var _selection = select_default2(null);
65897     var _wrap = select_default2(null);
65898     var addrField = _mainPresetIndex.field("address");
65899     var _entityIDs = [];
65900     var _tags;
65901     var _countryCode;
65902     var _addressFormats = [{
65903       format: [
65904         ["housenumber", "street"],
65905         ["city", "postcode"]
65906       ]
65907     }];
65908     _mainFileFetcher.get("address_formats").then(function(d2) {
65909       _addressFormats = d2;
65910       if (!_selection.empty()) {
65911         _selection.call(address);
65912       }
65913     }).catch(function() {
65914     });
65915     function getNear(isAddressable, type2, searchRadius, resultProp) {
65916       var extent = combinedEntityExtent();
65917       var l2 = extent.center();
65918       var box = geoExtent(l2).padByMeters(searchRadius);
65919       var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
65920         let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
65921         if (d2.geometry(context.graph()) === "line") {
65922           var loc = context.projection([
65923             (extent[0][0] + extent[1][0]) / 2,
65924             (extent[0][1] + extent[1][1]) / 2
65925           ]);
65926           var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
65927           dist = geoSphericalDistance(choice.loc, l2);
65928         }
65929         const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
65930         let title = value;
65931         if (type2 === "street") {
65932           title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
65933         } else if (type2 === "place") {
65934           title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
65935         }
65936         return {
65937           title,
65938           value,
65939           dist,
65940           type: type2,
65941           klass: "address-".concat(type2)
65942         };
65943       }).sort(function(a2, b2) {
65944         return a2.dist - b2.dist;
65945       });
65946       return utilArrayUniqBy(features, "value");
65947     }
65948     function getNearStreets() {
65949       function isAddressable(d2) {
65950         return d2.tags.highway && d2.tags.name && d2.type === "way";
65951       }
65952       return getNear(isAddressable, "street", 200);
65953     }
65954     function getNearPlaces() {
65955       function isAddressable(d2) {
65956         if (d2.tags.name) {
65957           if (d2.tags.place)
65958             return true;
65959           if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8)
65960             return true;
65961         }
65962         return false;
65963       }
65964       return getNear(isAddressable, "place", 200);
65965     }
65966     function getNearCities() {
65967       function isAddressable(d2) {
65968         if (d2.tags.name) {
65969           if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8")
65970             return true;
65971           if (d2.tags.border_type === "city")
65972             return true;
65973           if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village")
65974             return true;
65975         }
65976         if (d2.tags["".concat(field.key, ":city")])
65977           return true;
65978         return false;
65979       }
65980       return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
65981     }
65982     function getNearPostcodes() {
65983       return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
65984     }
65985     function getNearValues(key) {
65986       const tagKey = "".concat(field.key, ":").concat(key);
65987       function hasTag(d2) {
65988         return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
65989       }
65990       return getNear(hasTag, key, 200, tagKey);
65991     }
65992     function updateForCountryCode() {
65993       if (!_countryCode)
65994         return;
65995       var addressFormat;
65996       for (var i3 = 0; i3 < _addressFormats.length; i3++) {
65997         var format2 = _addressFormats[i3];
65998         if (!format2.countryCodes) {
65999           addressFormat = format2;
66000         } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
66001           addressFormat = format2;
66002           break;
66003         }
66004       }
66005       var dropdowns = addressFormat.dropdowns || [
66006         "city",
66007         "county",
66008         "country",
66009         "district",
66010         "hamlet",
66011         "neighbourhood",
66012         "place",
66013         "postcode",
66014         "province",
66015         "quarter",
66016         "state",
66017         "street",
66018         "street+place",
66019         "subdistrict",
66020         "suburb"
66021       ];
66022       var widths = addressFormat.widths || {
66023         housenumber: 1 / 5,
66024         unit: 1 / 5,
66025         street: 1 / 2,
66026         place: 1 / 2,
66027         city: 2 / 3,
66028         state: 1 / 4,
66029         postcode: 1 / 3
66030       };
66031       function row(r2) {
66032         var total = r2.reduce(function(sum, key) {
66033           return sum + (widths[key] || 0.5);
66034         }, 0);
66035         return r2.map(function(key) {
66036           return {
66037             id: key,
66038             width: (widths[key] || 0.5) / total
66039           };
66040         });
66041       }
66042       var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
66043         return d2.toString();
66044       });
66045       rows.exit().remove();
66046       rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").call(updatePlaceholder).attr("class", function(d2) {
66047         return "addr-" + d2.id;
66048       }).call(utilNoAuto).each(addDropdown).style("width", function(d2) {
66049         return d2.width * 100 + "%";
66050       });
66051       function addDropdown(d2) {
66052         if (dropdowns.indexOf(d2.id) === -1)
66053           return;
66054         var nearValues;
66055         switch (d2.id) {
66056           case "street":
66057             nearValues = getNearStreets;
66058             break;
66059           case "place":
66060             nearValues = getNearPlaces;
66061             break;
66062           case "street+place":
66063             nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
66064             d2.isAutoStreetPlace = true;
66065             d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
66066             break;
66067           case "city":
66068             nearValues = getNearCities;
66069             break;
66070           case "postcode":
66071             nearValues = getNearPostcodes;
66072             break;
66073           default:
66074             nearValues = getNearValues;
66075         }
66076         select_default2(this).call(
66077           uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
66078             typedValue = typedValue.toLowerCase();
66079             callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
66080           }).on("accept", function(selected) {
66081             if (d2.isAutoStreetPlace) {
66082               d2.id = selected ? selected.type : "street";
66083             }
66084           })
66085         );
66086       }
66087       _wrap.selectAll("input").on("blur", change()).on("change", change());
66088       _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
66089       if (_tags)
66090         updateTags(_tags);
66091     }
66092     function address(selection2) {
66093       _selection = selection2;
66094       _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
66095       _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
66096       var extent = combinedEntityExtent();
66097       if (extent) {
66098         var countryCode;
66099         if (context.inIntro()) {
66100           countryCode = _t("intro.graph.countrycode");
66101         } else {
66102           var center = extent.center();
66103           countryCode = iso1A2Code(center);
66104         }
66105         if (countryCode) {
66106           _countryCode = countryCode.toLowerCase();
66107           updateForCountryCode();
66108         }
66109       }
66110     }
66111     function change(onInput) {
66112       return function() {
66113         setTimeout(() => {
66114           var tags = {};
66115           _wrap.selectAll("input").each(function(subfield) {
66116             var key = field.key + ":" + subfield.id;
66117             var value = this.value;
66118             if (!onInput)
66119               value = context.cleanTagValue(value);
66120             if (Array.isArray(_tags[key]) && !value)
66121               return;
66122             if (subfield.isAutoStreetPlace) {
66123               if (subfield.id === "street") {
66124                 tags["".concat(field.key, ":place")] = void 0;
66125               } else if (subfield.id === "place") {
66126                 tags["".concat(field.key, ":street")] = void 0;
66127               }
66128             }
66129             tags[key] = value || void 0;
66130           });
66131           Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
66132           dispatch14.call("change", this, tags, onInput);
66133         }, 0);
66134       };
66135     }
66136     function updatePlaceholder(inputSelection) {
66137       return inputSelection.attr("placeholder", function(subfield) {
66138         if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
66139           return _t("inspector.multiple_values");
66140         }
66141         if (subfield.isAutoStreetPlace) {
66142           return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
66143         }
66144         return getLocalPlaceholder(subfield.id);
66145       });
66146     }
66147     function getLocalPlaceholder(key) {
66148       if (_countryCode) {
66149         var localkey = key + "!" + _countryCode;
66150         var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
66151         return addrField.t("placeholders." + tkey);
66152       }
66153     }
66154     function updateTags(tags) {
66155       utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
66156         var val;
66157         if (subfield.isAutoStreetPlace) {
66158           const streetKey = "".concat(field.key, ":street");
66159           const placeKey = "".concat(field.key, ":place");
66160           if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
66161             val = tags[streetKey];
66162             subfield.id = "street";
66163           } else {
66164             val = tags[placeKey];
66165             subfield.id = "place";
66166           }
66167         } else {
66168           val = tags["".concat(field.key, ":").concat(subfield.id)];
66169         }
66170         return typeof val === "string" ? val : "";
66171       }).attr("title", function(subfield) {
66172         var val = tags[field.key + ":" + subfield.id];
66173         return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
66174       }).classed("mixed", function(subfield) {
66175         return Array.isArray(tags[field.key + ":" + subfield.id]);
66176       }).call(updatePlaceholder);
66177     }
66178     function combinedEntityExtent() {
66179       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66180     }
66181     address.entityIDs = function(val) {
66182       if (!arguments.length)
66183         return _entityIDs;
66184       _entityIDs = val;
66185       return address;
66186     };
66187     address.tags = function(tags) {
66188       _tags = tags;
66189       updateTags(tags);
66190     };
66191     address.focus = function() {
66192       var node = _wrap.selectAll("input").node();
66193       if (node)
66194         node.focus();
66195     };
66196     return utilRebind(address, dispatch14, "on");
66197   }
66198
66199   // modules/ui/fields/directional_combo.js
66200   function uiFieldDirectionalCombo(field, context) {
66201     var dispatch14 = dispatch_default("change");
66202     var items = select_default2(null);
66203     var wrap2 = select_default2(null);
66204     var _tags;
66205     var _combos = {};
66206     if (field.type === "cycleway") {
66207       field = {
66208         ...field,
66209         key: field.keys[0],
66210         keys: field.keys.slice(1)
66211       };
66212     }
66213     function directionalCombo(selection2) {
66214       function stripcolon(s2) {
66215         return s2.replace(":", "");
66216       }
66217       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66218       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66219       var div = wrap2.selectAll("ul").data([0]);
66220       div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
66221       items = div.selectAll("li").data(field.keys);
66222       var enter = items.enter().append("li").attr("class", function(d2) {
66223         return "labeled-input preset-directionalcombo-" + stripcolon(d2);
66224       });
66225       enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
66226         return "preset-input-directionalcombo-" + stripcolon(d2);
66227       }).html(function(d2) {
66228         return field.t.html("types." + d2);
66229       });
66230       enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
66231         const subField = {
66232           ...field,
66233           type: "combo",
66234           key
66235         };
66236         const combo = uiFieldCombo(subField, context);
66237         combo.on("change", (t2) => change(key, t2[key]));
66238         _combos[key] = combo;
66239         select_default2(this).call(combo);
66240       });
66241       items = items.merge(enter);
66242       wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
66243     }
66244     function change(key, newValue) {
66245       const commonKey = field.key;
66246       const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
66247       dispatch14.call("change", this, (tags) => {
66248         const otherValue = tags[otherKey] || tags[commonKey];
66249         if (newValue === otherValue) {
66250           tags[commonKey] = newValue;
66251           delete tags[key];
66252           delete tags[otherKey];
66253         } else {
66254           tags[key] = newValue;
66255           delete tags[commonKey];
66256           tags[otherKey] = otherValue;
66257         }
66258         return tags;
66259       });
66260     }
66261     directionalCombo.tags = function(tags) {
66262       _tags = tags;
66263       const commonKey = field.key;
66264       for (let key in _combos) {
66265         const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags[key]).filter(Boolean))];
66266         _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
66267       }
66268     };
66269     directionalCombo.focus = function() {
66270       var node = wrap2.selectAll("input").node();
66271       if (node)
66272         node.focus();
66273     };
66274     return utilRebind(directionalCombo, dispatch14, "on");
66275   }
66276
66277   // modules/ui/fields/lanes.js
66278   function uiFieldLanes(field, context) {
66279     var dispatch14 = dispatch_default("change");
66280     var LANE_WIDTH = 40;
66281     var LANE_HEIGHT = 200;
66282     var _entityIDs = [];
66283     function lanes(selection2) {
66284       var lanesData = context.entity(_entityIDs[0]).lanes();
66285       if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
66286         selection2.call(lanes.off);
66287         return;
66288       }
66289       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66290       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66291       var surface = wrap2.selectAll(".surface").data([0]);
66292       var d2 = utilGetDimensions(wrap2);
66293       var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
66294       surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
66295       var lanesSelection = surface.selectAll(".lanes").data([0]);
66296       lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
66297       lanesSelection.attr("transform", function() {
66298         return "translate(" + freeSpace / 2 + ", 0)";
66299       });
66300       var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
66301       lane.exit().remove();
66302       var enter = lane.enter().append("g").attr("class", "lane");
66303       enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
66304       enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
66305       enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
66306       enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
66307       lane = lane.merge(enter);
66308       lane.attr("transform", function(d4) {
66309         return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
66310       });
66311       lane.select(".forward").style("visibility", function(d4) {
66312         return d4.direction === "forward" ? "visible" : "hidden";
66313       });
66314       lane.select(".bothways").style("visibility", function(d4) {
66315         return d4.direction === "bothways" ? "visible" : "hidden";
66316       });
66317       lane.select(".backward").style("visibility", function(d4) {
66318         return d4.direction === "backward" ? "visible" : "hidden";
66319       });
66320     }
66321     lanes.entityIDs = function(val) {
66322       _entityIDs = val;
66323     };
66324     lanes.tags = function() {
66325     };
66326     lanes.focus = function() {
66327     };
66328     lanes.off = function() {
66329     };
66330     return utilRebind(lanes, dispatch14, "on");
66331   }
66332   uiFieldLanes.supportsMultiselection = false;
66333
66334   // modules/ui/fields/localized.js
66335   var _languagesArray = [];
66336   function uiFieldLocalized(field, context) {
66337     var dispatch14 = dispatch_default("change", "input");
66338     var wikipedia = services.wikipedia;
66339     var input = select_default2(null);
66340     var localizedInputs = select_default2(null);
66341     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
66342     var _countryCode;
66343     var _tags;
66344     _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
66345     });
66346     var _territoryLanguages = {};
66347     _mainFileFetcher.get("territory_languages").then(function(d2) {
66348       _territoryLanguages = d2;
66349     }).catch(function() {
66350     });
66351     var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
66352     var _selection = select_default2(null);
66353     var _multilingual = [];
66354     var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
66355     var _wikiTitles;
66356     var _entityIDs = [];
66357     function loadLanguagesArray(dataLanguages) {
66358       if (_languagesArray.length !== 0)
66359         return;
66360       var replacements = {
66361         sr: "sr-Cyrl",
66362         // in OSM, `sr` implies Cyrillic
66363         "sr-Cyrl": false
66364         // `sr-Cyrl` isn't used in OSM
66365       };
66366       for (var code in dataLanguages) {
66367         if (replacements[code] === false)
66368           continue;
66369         var metaCode = code;
66370         if (replacements[code])
66371           metaCode = replacements[code];
66372         _languagesArray.push({
66373           localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
66374           nativeName: dataLanguages[metaCode].nativeName,
66375           code,
66376           label: _mainLocalizer.languageName(metaCode)
66377         });
66378       }
66379     }
66380     function calcLocked() {
66381       var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
66382         var entity = context.graph().hasEntity(entityID);
66383         if (!entity)
66384           return false;
66385         if (entity.tags.wikidata)
66386           return true;
66387         if (entity.tags["name:etymology:wikidata"])
66388           return true;
66389         var preset = _mainPresetIndex.match(entity, context.graph());
66390         if (preset) {
66391           var isSuggestion = preset.suggestion;
66392           var fields = preset.fields(entity.extent(context.graph()).center());
66393           var showsBrandField = fields.some(function(d2) {
66394             return d2.id === "brand";
66395           });
66396           var showsOperatorField = fields.some(function(d2) {
66397             return d2.id === "operator";
66398           });
66399           var setsName = preset.addTags.name;
66400           var setsBrandWikidata = preset.addTags["brand:wikidata"];
66401           var setsOperatorWikidata = preset.addTags["operator:wikidata"];
66402           return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
66403         }
66404         return false;
66405       });
66406       field.locked(isLocked);
66407     }
66408     function calcMultilingual(tags) {
66409       var existingLangsOrdered = _multilingual.map(function(item2) {
66410         return item2.lang;
66411       });
66412       var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
66413       for (var k2 in tags) {
66414         var m2 = k2.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/);
66415         if (m2 && m2[1] === field.key && m2[2]) {
66416           var item = { lang: m2[2], value: tags[k2] };
66417           if (existingLangs.has(item.lang)) {
66418             _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
66419             existingLangs.delete(item.lang);
66420           } else {
66421             _multilingual.push(item);
66422           }
66423         }
66424       }
66425       _multilingual.forEach(function(item2) {
66426         if (item2.lang && existingLangs.has(item2.lang)) {
66427           item2.value = "";
66428         }
66429       });
66430     }
66431     function localized(selection2) {
66432       _selection = selection2;
66433       calcLocked();
66434       var isLocked = field.locked();
66435       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66436       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66437       input = wrap2.selectAll(".localized-main").data([0]);
66438       input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
66439       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
66440       wrap2.call(_lengthIndicator);
66441       var translateButton = wrap2.selectAll(".localized-add").data([0]);
66442       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);
66443       translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
66444       if (_tags && !_multilingual.length) {
66445         calcMultilingual(_tags);
66446       }
66447       localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
66448       localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
66449       localizedInputs.call(renderMultilingual);
66450       localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
66451       selection2.selectAll(".combobox-caret").classed("nope", true);
66452       function addNew(d3_event) {
66453         d3_event.preventDefault();
66454         if (field.locked())
66455           return;
66456         var defaultLang = _mainLocalizer.languageCode().toLowerCase();
66457         var langExists = _multilingual.find(function(datum2) {
66458           return datum2.lang === defaultLang;
66459         });
66460         var isLangEn = defaultLang.indexOf("en") > -1;
66461         if (isLangEn || langExists) {
66462           defaultLang = "";
66463           langExists = _multilingual.find(function(datum2) {
66464             return datum2.lang === defaultLang;
66465           });
66466         }
66467         if (!langExists) {
66468           _multilingual.unshift({ lang: defaultLang, value: "" });
66469           localizedInputs.call(renderMultilingual);
66470         }
66471       }
66472       function change(onInput) {
66473         return function(d3_event) {
66474           if (field.locked()) {
66475             d3_event.preventDefault();
66476             return;
66477           }
66478           var val = utilGetSetValue(select_default2(this));
66479           if (!onInput)
66480             val = context.cleanTagValue(val);
66481           if (!val && Array.isArray(_tags[field.key]))
66482             return;
66483           var t2 = {};
66484           t2[field.key] = val || void 0;
66485           dispatch14.call("change", this, t2, onInput);
66486         };
66487       }
66488     }
66489     function key(lang) {
66490       return field.key + ":" + lang;
66491     }
66492     function changeLang(d3_event, d2) {
66493       var tags = {};
66494       var lang = utilGetSetValue(select_default2(this)).toLowerCase();
66495       var language = _languagesArray.find(function(d4) {
66496         return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
66497       });
66498       if (language)
66499         lang = language.code;
66500       if (d2.lang && d2.lang !== lang) {
66501         tags[key(d2.lang)] = void 0;
66502       }
66503       var newKey = lang && context.cleanTagKey(key(lang));
66504       var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
66505       if (newKey && value) {
66506         tags[newKey] = value;
66507       } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
66508         tags[newKey] = _wikiTitles[d2.lang];
66509       }
66510       d2.lang = lang;
66511       dispatch14.call("change", this, tags);
66512     }
66513     function changeValue(d3_event, d2) {
66514       if (!d2.lang)
66515         return;
66516       var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
66517       if (!value && Array.isArray(d2.value))
66518         return;
66519       var t2 = {};
66520       t2[key(d2.lang)] = value;
66521       d2.value = value;
66522       dispatch14.call("change", this, t2);
66523     }
66524     function fetchLanguages(value, cb) {
66525       var v2 = value.toLowerCase();
66526       var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
66527       if (_countryCode && _territoryLanguages[_countryCode]) {
66528         langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
66529       }
66530       var langItems = [];
66531       langCodes.forEach(function(code) {
66532         var langItem = _languagesArray.find(function(item) {
66533           return item.code === code;
66534         });
66535         if (langItem)
66536           langItems.push(langItem);
66537       });
66538       langItems = utilArrayUniq(langItems.concat(_languagesArray));
66539       cb(langItems.filter(function(d2) {
66540         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;
66541       }).map(function(d2) {
66542         return { value: d2.label };
66543       }));
66544     }
66545     function renderMultilingual(selection2) {
66546       var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
66547         return d2.lang;
66548       });
66549       entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
66550       var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
66551         var wrap2 = select_default2(this);
66552         var domId = utilUniqueDomId(index);
66553         var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
66554         var text = label.append("span").attr("class", "label-text");
66555         text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
66556         text.append("span").attr("class", "label-textannotation");
66557         label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
66558           if (field.locked())
66559             return;
66560           d3_event.preventDefault();
66561           _multilingual.splice(_multilingual.indexOf(d2), 1);
66562           var langKey = d2.lang && key(d2.lang);
66563           if (langKey && langKey in _tags) {
66564             delete _tags[langKey];
66565             var t2 = {};
66566             t2[langKey] = void 0;
66567             dispatch14.call("change", this, t2);
66568             return;
66569           }
66570           renderMultilingual(selection2);
66571         }).call(svgIcon("#iD-operation-delete"));
66572         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);
66573         wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
66574       });
66575       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() {
66576         select_default2(this).style("max-height", "").style("overflow", "visible");
66577       });
66578       entries = entries.merge(entriesEnter);
66579       entries.order();
66580       entries.classed("present", true);
66581       utilGetSetValue(entries.select(".localized-lang"), function(d2) {
66582         var langItem = _languagesArray.find(function(item) {
66583           return item.code === d2.lang;
66584         });
66585         if (langItem)
66586           return langItem.label;
66587         return d2.lang;
66588       });
66589       utilGetSetValue(entries.select(".localized-value"), function(d2) {
66590         return typeof d2.value === "string" ? d2.value : "";
66591       }).attr("title", function(d2) {
66592         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
66593       }).attr("placeholder", function(d2) {
66594         return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
66595       }).classed("mixed", function(d2) {
66596         return Array.isArray(d2.value);
66597       });
66598     }
66599     localized.tags = function(tags) {
66600       _tags = tags;
66601       if (typeof tags.wikipedia === "string" && !_wikiTitles) {
66602         _wikiTitles = {};
66603         var wm = tags.wikipedia.match(/([^:]+):(.+)/);
66604         if (wm && wm[0] && wm[1]) {
66605           wikipedia.translations(wm[1], wm[2], function(err, d2) {
66606             if (err || !d2)
66607               return;
66608             _wikiTitles = d2;
66609           });
66610         }
66611       }
66612       var isMixed = Array.isArray(tags[field.key]);
66613       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);
66614       calcMultilingual(tags);
66615       _selection.call(localized);
66616       if (!isMixed) {
66617         _lengthIndicator.update(tags[field.key]);
66618       }
66619     };
66620     localized.focus = function() {
66621       input.node().focus();
66622     };
66623     localized.entityIDs = function(val) {
66624       if (!arguments.length)
66625         return _entityIDs;
66626       _entityIDs = val;
66627       _multilingual = [];
66628       loadCountryCode();
66629       return localized;
66630     };
66631     function loadCountryCode() {
66632       var extent = combinedEntityExtent();
66633       var countryCode = extent && iso1A2Code(extent.center());
66634       _countryCode = countryCode && countryCode.toLowerCase();
66635     }
66636     function combinedEntityExtent() {
66637       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66638     }
66639     return utilRebind(localized, dispatch14, "on");
66640   }
66641
66642   // modules/ui/fields/roadheight.js
66643   function uiFieldRoadheight(field, context) {
66644     var dispatch14 = dispatch_default("change");
66645     var primaryUnitInput = select_default2(null);
66646     var primaryInput = select_default2(null);
66647     var secondaryInput = select_default2(null);
66648     var secondaryUnitInput = select_default2(null);
66649     var _entityIDs = [];
66650     var _tags;
66651     var _isImperial;
66652     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66653     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66654     var primaryUnits = [
66655       {
66656         value: "m",
66657         title: _t("inspector.roadheight.meter")
66658       },
66659       {
66660         value: "ft",
66661         title: _t("inspector.roadheight.foot")
66662       }
66663     ];
66664     var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
66665     function roadheight(selection2) {
66666       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66667       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66668       primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
66669       primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
66670       primaryInput.on("change", change).on("blur", change);
66671       var loc = combinedEntityExtent().center();
66672       _isImperial = roadHeightUnit(loc) === "ft";
66673       primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
66674       primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
66675       primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
66676       secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
66677       secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
66678       secondaryInput.on("change", change).on("blur", change);
66679       secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
66680       secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
66681       function changeUnits() {
66682         var primaryUnit = utilGetSetValue(primaryUnitInput);
66683         if (primaryUnit === "m") {
66684           _isImperial = false;
66685         } else if (primaryUnit === "ft") {
66686           _isImperial = true;
66687         }
66688         utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66689         setUnitSuggestions();
66690         change();
66691       }
66692     }
66693     function setUnitSuggestions() {
66694       utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66695     }
66696     function change() {
66697       var tag2 = {};
66698       var primaryValue = utilGetSetValue(primaryInput).trim();
66699       var secondaryValue = utilGetSetValue(secondaryInput).trim();
66700       if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key]))
66701         return;
66702       if (!primaryValue && !secondaryValue) {
66703         tag2[field.key] = void 0;
66704       } else {
66705         var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
66706         if (isNaN(rawPrimaryValue))
66707           rawPrimaryValue = primaryValue;
66708         var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
66709         if (isNaN(rawSecondaryValue))
66710           rawSecondaryValue = secondaryValue;
66711         if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
66712           tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
66713         } else {
66714           if (rawPrimaryValue !== "") {
66715             rawPrimaryValue = rawPrimaryValue + "'";
66716           }
66717           if (rawSecondaryValue !== "") {
66718             rawSecondaryValue = rawSecondaryValue + '"';
66719           }
66720           tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
66721         }
66722       }
66723       dispatch14.call("change", this, tag2);
66724     }
66725     roadheight.tags = function(tags) {
66726       _tags = tags;
66727       var primaryValue = tags[field.key];
66728       var secondaryValue;
66729       var isMixed = Array.isArray(primaryValue);
66730       if (!isMixed) {
66731         if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
66732           secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
66733           if (secondaryValue !== null) {
66734             secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
66735           }
66736           primaryValue = primaryValue.match(/(-?[\d.]+)'/);
66737           if (primaryValue !== null) {
66738             primaryValue = formatFloat(parseFloat(primaryValue[1]));
66739           }
66740           _isImperial = true;
66741         } else if (primaryValue) {
66742           var rawValue = primaryValue;
66743           primaryValue = parseFloat(rawValue);
66744           if (isNaN(primaryValue)) {
66745             primaryValue = rawValue;
66746           } else {
66747             primaryValue = formatFloat(primaryValue);
66748           }
66749           _isImperial = false;
66750         }
66751       }
66752       setUnitSuggestions();
66753       var inchesPlaceholder = formatFloat(0);
66754       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);
66755       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");
66756       secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
66757     };
66758     roadheight.focus = function() {
66759       primaryInput.node().focus();
66760     };
66761     roadheight.entityIDs = function(val) {
66762       _entityIDs = val;
66763     };
66764     function combinedEntityExtent() {
66765       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66766     }
66767     return utilRebind(roadheight, dispatch14, "on");
66768   }
66769
66770   // modules/ui/fields/roadspeed.js
66771   function uiFieldRoadspeed(field, context) {
66772     var dispatch14 = dispatch_default("change");
66773     var unitInput = select_default2(null);
66774     var input = select_default2(null);
66775     var _entityIDs = [];
66776     var _tags;
66777     var _isImperial;
66778     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66779     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66780     var speedCombo = uiCombobox(context, "roadspeed");
66781     var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
66782     var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
66783     var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
66784     function roadspeed(selection2) {
66785       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66786       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66787       input = wrap2.selectAll("input.roadspeed-number").data([0]);
66788       input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
66789       input.on("change", change).on("blur", change);
66790       var loc = combinedEntityExtent().center();
66791       _isImperial = roadSpeedUnit(loc) === "mph";
66792       unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
66793       unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
66794       unitInput.on("blur", changeUnits).on("change", changeUnits);
66795       function changeUnits() {
66796         var unit2 = utilGetSetValue(unitInput);
66797         if (unit2 === "km/h") {
66798           _isImperial = false;
66799         } else if (unit2 === "mph") {
66800           _isImperial = true;
66801         }
66802         utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66803         setUnitSuggestions();
66804         change();
66805       }
66806     }
66807     function setUnitSuggestions() {
66808       speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
66809       utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66810     }
66811     function comboValues(d2) {
66812       return {
66813         value: formatFloat(d2),
66814         title: formatFloat(d2)
66815       };
66816     }
66817     function change() {
66818       var tag2 = {};
66819       var value = utilGetSetValue(input).trim();
66820       if (!value && Array.isArray(_tags[field.key]))
66821         return;
66822       if (!value) {
66823         tag2[field.key] = void 0;
66824       } else {
66825         var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
66826         if (isNaN(rawValue))
66827           rawValue = value;
66828         if (isNaN(rawValue) || !_isImperial) {
66829           tag2[field.key] = context.cleanTagValue(rawValue);
66830         } else {
66831           tag2[field.key] = context.cleanTagValue(rawValue + " mph");
66832         }
66833       }
66834       dispatch14.call("change", this, tag2);
66835     }
66836     roadspeed.tags = function(tags) {
66837       _tags = tags;
66838       var rawValue = tags[field.key];
66839       var value = rawValue;
66840       var isMixed = Array.isArray(value);
66841       if (!isMixed) {
66842         if (rawValue && rawValue.indexOf("mph") >= 0) {
66843           _isImperial = true;
66844         } else if (rawValue) {
66845           _isImperial = false;
66846         }
66847         value = parseInt(value, 10);
66848         if (isNaN(value)) {
66849           value = rawValue;
66850         } else {
66851           value = formatFloat(value);
66852         }
66853       }
66854       setUnitSuggestions();
66855       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);
66856     };
66857     roadspeed.focus = function() {
66858       input.node().focus();
66859     };
66860     roadspeed.entityIDs = function(val) {
66861       _entityIDs = val;
66862     };
66863     function combinedEntityExtent() {
66864       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66865     }
66866     return utilRebind(roadspeed, dispatch14, "on");
66867   }
66868
66869   // modules/ui/fields/radio.js
66870   function uiFieldRadio(field, context) {
66871     var dispatch14 = dispatch_default("change");
66872     var placeholder = select_default2(null);
66873     var wrap2 = select_default2(null);
66874     var labels = select_default2(null);
66875     var radios = select_default2(null);
66876     var radioData = (field.options || field.keys).slice();
66877     var typeField;
66878     var layerField;
66879     var _oldType = {};
66880     var _entityIDs = [];
66881     function selectedKey() {
66882       var node = wrap2.selectAll(".form-field-input-radio label.active input");
66883       return !node.empty() && node.datum();
66884     }
66885     function radio(selection2) {
66886       selection2.classed("preset-radio", true);
66887       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66888       var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
66889       enter.append("span").attr("class", "placeholder");
66890       wrap2 = wrap2.merge(enter);
66891       placeholder = wrap2.selectAll(".placeholder");
66892       labels = wrap2.selectAll("label").data(radioData);
66893       enter = labels.enter().append("label");
66894       var stringsField = field.resolveReference("stringsCrossReference");
66895       enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
66896         return stringsField.t("options." + d2, { "default": d2 });
66897       }).attr("checked", false);
66898       enter.append("span").each(function(d2) {
66899         stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
66900       });
66901       labels = labels.merge(enter);
66902       radios = labels.selectAll("input").on("change", changeRadio);
66903     }
66904     function structureExtras(selection2, tags) {
66905       var selected = selectedKey() || tags.layer !== void 0;
66906       var type2 = _mainPresetIndex.field(selected);
66907       var layer = _mainPresetIndex.field("layer");
66908       var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
66909       var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
66910       extrasWrap.exit().remove();
66911       extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
66912       var list2 = extrasWrap.selectAll("ul").data([0]);
66913       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
66914       if (type2) {
66915         if (!typeField || typeField.id !== selected) {
66916           typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
66917         }
66918         typeField.tags(tags);
66919       } else {
66920         typeField = null;
66921       }
66922       var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
66923         return d2.id;
66924       });
66925       typeItem.exit().remove();
66926       var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
66927       typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
66928       typeEnter.append("div").attr("class", "structure-input-type-wrap");
66929       typeItem = typeItem.merge(typeEnter);
66930       if (typeField) {
66931         typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
66932       }
66933       if (layer && showLayer) {
66934         if (!layerField) {
66935           layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
66936         }
66937         layerField.tags(tags);
66938         field.keys = utilArrayUnion(field.keys, ["layer"]);
66939       } else {
66940         layerField = null;
66941         field.keys = field.keys.filter(function(k2) {
66942           return k2 !== "layer";
66943         });
66944       }
66945       var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
66946       layerItem.exit().remove();
66947       var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
66948       layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
66949       layerEnter.append("div").attr("class", "structure-input-layer-wrap");
66950       layerItem = layerItem.merge(layerEnter);
66951       if (layerField) {
66952         layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
66953       }
66954     }
66955     function changeType(t2, onInput) {
66956       var key = selectedKey();
66957       if (!key)
66958         return;
66959       var val = t2[key];
66960       if (val !== "no") {
66961         _oldType[key] = val;
66962       }
66963       if (field.type === "structureRadio") {
66964         if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
66965           t2.layer = void 0;
66966         }
66967         if (t2.layer === void 0) {
66968           if (key === "bridge" && val !== "no") {
66969             t2.layer = "1";
66970           }
66971           if (key === "tunnel" && val !== "no" && val !== "building_passage") {
66972             t2.layer = "-1";
66973           }
66974         }
66975       }
66976       dispatch14.call("change", this, t2, onInput);
66977     }
66978     function changeLayer(t2, onInput) {
66979       if (t2.layer === "0") {
66980         t2.layer = void 0;
66981       }
66982       dispatch14.call("change", this, t2, onInput);
66983     }
66984     function changeRadio() {
66985       var t2 = {};
66986       var activeKey;
66987       if (field.key) {
66988         t2[field.key] = void 0;
66989       }
66990       radios.each(function(d2) {
66991         var active = select_default2(this).property("checked");
66992         if (active)
66993           activeKey = d2;
66994         if (field.key) {
66995           if (active)
66996             t2[field.key] = d2;
66997         } else {
66998           var val = _oldType[activeKey] || "yes";
66999           t2[d2] = active ? val : void 0;
67000         }
67001       });
67002       if (field.type === "structureRadio") {
67003         if (activeKey === "bridge") {
67004           t2.layer = "1";
67005         } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
67006           t2.layer = "-1";
67007         } else {
67008           t2.layer = void 0;
67009         }
67010       }
67011       dispatch14.call("change", this, t2);
67012     }
67013     radio.tags = function(tags) {
67014       function isOptionChecked(d2) {
67015         if (field.key) {
67016           return tags[field.key] === d2;
67017         }
67018         return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67019       }
67020       function isMixed(d2) {
67021         if (field.key) {
67022           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
67023         }
67024         return Array.isArray(tags[d2]);
67025       }
67026       radios.property("checked", function(d2) {
67027         return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
67028       });
67029       labels.classed("active", function(d2) {
67030         if (field.key) {
67031           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
67032         }
67033         return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67034       }).classed("mixed", isMixed).attr("title", function(d2) {
67035         return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
67036       });
67037       var selection2 = radios.filter(function() {
67038         return this.checked;
67039       });
67040       if (selection2.empty()) {
67041         placeholder.text("");
67042         placeholder.call(_t.append("inspector.none"));
67043       } else {
67044         placeholder.text(selection2.attr("value"));
67045         _oldType[selection2.datum()] = tags[selection2.datum()];
67046       }
67047       if (field.type === "structureRadio") {
67048         if (!!tags.waterway && !_oldType.tunnel) {
67049           _oldType.tunnel = "culvert";
67050         }
67051         wrap2.call(structureExtras, tags);
67052       }
67053     };
67054     radio.focus = function() {
67055       radios.node().focus();
67056     };
67057     radio.entityIDs = function(val) {
67058       if (!arguments.length)
67059         return _entityIDs;
67060       _entityIDs = val;
67061       _oldType = {};
67062       return radio;
67063     };
67064     radio.isAllowed = function() {
67065       return _entityIDs.length === 1;
67066     };
67067     return utilRebind(radio, dispatch14, "on");
67068   }
67069
67070   // modules/ui/fields/restrictions.js
67071   function uiFieldRestrictions(field, context) {
67072     var dispatch14 = dispatch_default("change");
67073     var breathe = behaviorBreathe(context);
67074     corePreferences("turn-restriction-via-way", null);
67075     var storedViaWay = corePreferences("turn-restriction-via-way0");
67076     var storedDistance = corePreferences("turn-restriction-distance");
67077     var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
67078     var _maxDistance = storedDistance ? +storedDistance : 30;
67079     var _initialized3 = false;
67080     var _parent = select_default2(null);
67081     var _container = select_default2(null);
67082     var _oldTurns;
67083     var _graph;
67084     var _vertexID;
67085     var _intersection;
67086     var _fromWayID;
67087     var _lastXPos;
67088     function restrictions(selection2) {
67089       _parent = selection2;
67090       if (_vertexID && (context.graph() !== _graph || !_intersection)) {
67091         _graph = context.graph();
67092         _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
67093       }
67094       var isOK = _intersection && _intersection.vertices.length && // has vertices
67095       _intersection.vertices.filter(function(vertex) {
67096         return vertex.id === _vertexID;
67097       }).length && _intersection.ways.length > 2;
67098       select_default2(selection2.node().parentNode).classed("hide", !isOK);
67099       if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
67100         selection2.call(restrictions.off);
67101         return;
67102       }
67103       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67104       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67105       var container = wrap2.selectAll(".restriction-container").data([0]);
67106       var containerEnter = container.enter().append("div").attr("class", "restriction-container");
67107       containerEnter.append("div").attr("class", "restriction-help");
67108       _container = containerEnter.merge(container).call(renderViewer);
67109       var controls = wrap2.selectAll(".restriction-controls").data([0]);
67110       controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
67111     }
67112     function renderControls(selection2) {
67113       var distControl = selection2.selectAll(".restriction-distance").data([0]);
67114       distControl.exit().remove();
67115       var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
67116       distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
67117       distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
67118       distControlEnter.append("span").attr("class", "restriction-distance-text");
67119       selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
67120         var val = select_default2(this).property("value");
67121         _maxDistance = +val;
67122         _intersection = null;
67123         _container.selectAll(".layer-osm .layer-turns *").remove();
67124         corePreferences("turn-restriction-distance", _maxDistance);
67125         _parent.call(restrictions);
67126       });
67127       selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
67128       var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
67129       viaControl.exit().remove();
67130       var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
67131       viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
67132       viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
67133       viaControlEnter.append("span").attr("class", "restriction-via-way-text");
67134       selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
67135         var val = select_default2(this).property("value");
67136         _maxViaWay = +val;
67137         _container.selectAll(".layer-osm .layer-turns *").remove();
67138         corePreferences("turn-restriction-via-way0", _maxViaWay);
67139         _parent.call(restrictions);
67140       });
67141       selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
67142     }
67143     function renderViewer(selection2) {
67144       if (!_intersection)
67145         return;
67146       var vgraph = _intersection.graph;
67147       var filter2 = utilFunctor(true);
67148       var projection2 = geoRawMercator();
67149       var sdims = utilGetDimensions(context.container().select(".sidebar"));
67150       var d2 = [sdims[0] - 50, 370];
67151       var c2 = geoVecScale(d2, 0.5);
67152       var z2 = 22;
67153       projection2.scale(geoZoomToScale(z2));
67154       var extent = geoExtent();
67155       for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
67156         extent._extend(_intersection.vertices[i3].extent());
67157       }
67158       var padTop = 35;
67159       if (_intersection.vertices.length > 1) {
67160         var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
67161         var vPadding = 160;
67162         var tl = projection2([extent[0][0], extent[1][1]]);
67163         var br2 = projection2([extent[1][0], extent[0][1]]);
67164         var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
67165         var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
67166         var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
67167         var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
67168         z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
67169         projection2.scale(geoZoomToScale(z2));
67170       }
67171       var extentCenter = projection2(extent.center());
67172       extentCenter[1] = extentCenter[1] - padTop / 2;
67173       projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
67174       var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
67175       var drawVertices = svgVertices(projection2, context);
67176       var drawLines = svgLines(projection2, context);
67177       var drawTurns = svgTurns(projection2, context);
67178       var firstTime = selection2.selectAll(".surface").empty();
67179       selection2.call(drawLayers);
67180       var surface = selection2.selectAll(".surface").classed("tr", true);
67181       if (firstTime) {
67182         _initialized3 = true;
67183         surface.call(breathe);
67184       }
67185       if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
67186         _fromWayID = null;
67187         _oldTurns = null;
67188       }
67189       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));
67190       surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
67191       surface.selectAll(".selected").classed("selected", false);
67192       surface.selectAll(".related").classed("related", false);
67193       var way;
67194       if (_fromWayID) {
67195         way = vgraph.entity(_fromWayID);
67196         surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67197       }
67198       document.addEventListener("resizeWindow", function() {
67199         utilSetDimensions(_container, null);
67200         redraw(1);
67201       }, false);
67202       updateHints(null);
67203       function click(d3_event) {
67204         surface.call(breathe.off).call(breathe);
67205         var datum2 = d3_event.target.__data__;
67206         var entity = datum2 && datum2.properties && datum2.properties.entity;
67207         if (entity) {
67208           datum2 = entity;
67209         }
67210         if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
67211           _fromWayID = datum2.id;
67212           _oldTurns = null;
67213           redraw();
67214         } else if (datum2 instanceof osmTurn) {
67215           var actions, extraActions, turns, i4;
67216           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67217           if (datum2.restrictionID && !datum2.direct) {
67218             return;
67219           } else if (datum2.restrictionID && !datum2.only) {
67220             var seen = {};
67221             var datumOnly = JSON.parse(JSON.stringify(datum2));
67222             datumOnly.only = true;
67223             restrictionType = restrictionType.replace(/^no/, "only");
67224             turns = _intersection.turns(_fromWayID, 2);
67225             extraActions = [];
67226             _oldTurns = [];
67227             for (i4 = 0; i4 < turns.length; i4++) {
67228               var turn = turns[i4];
67229               if (seen[turn.restrictionID])
67230                 continue;
67231               if (turn.direct && turn.path[1] === datum2.path[1]) {
67232                 seen[turns[i4].restrictionID] = true;
67233                 turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
67234                 _oldTurns.push(turn);
67235                 extraActions.push(actionUnrestrictTurn(turn));
67236               }
67237             }
67238             actions = _intersection.actions.concat(extraActions, [
67239               actionRestrictTurn(datumOnly, restrictionType),
67240               _t("operations.restriction.annotation.create")
67241             ]);
67242           } else if (datum2.restrictionID) {
67243             turns = _oldTurns || [];
67244             extraActions = [];
67245             for (i4 = 0; i4 < turns.length; i4++) {
67246               if (turns[i4].key !== datum2.key) {
67247                 extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
67248               }
67249             }
67250             _oldTurns = null;
67251             actions = _intersection.actions.concat(extraActions, [
67252               actionUnrestrictTurn(datum2),
67253               _t("operations.restriction.annotation.delete")
67254             ]);
67255           } else {
67256             actions = _intersection.actions.concat([
67257               actionRestrictTurn(datum2, restrictionType),
67258               _t("operations.restriction.annotation.create")
67259             ]);
67260           }
67261           context.perform.apply(context, actions);
67262           var s2 = surface.selectAll("." + datum2.key);
67263           datum2 = s2.empty() ? null : s2.datum();
67264           updateHints(datum2);
67265         } else {
67266           _fromWayID = null;
67267           _oldTurns = null;
67268           redraw();
67269         }
67270       }
67271       function mouseover(d3_event) {
67272         var datum2 = d3_event.target.__data__;
67273         updateHints(datum2);
67274       }
67275       _lastXPos = _lastXPos || sdims[0];
67276       function redraw(minChange) {
67277         var xPos = -1;
67278         if (minChange) {
67279           xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
67280         }
67281         if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
67282           if (context.hasEntity(_vertexID)) {
67283             _lastXPos = xPos;
67284             _container.call(renderViewer);
67285           }
67286         }
67287       }
67288       function highlightPathsFrom(wayID) {
67289         surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
67290         surface.selectAll("." + wayID).classed("related", true);
67291         if (wayID) {
67292           var turns = _intersection.turns(wayID, _maxViaWay);
67293           for (var i4 = 0; i4 < turns.length; i4++) {
67294             var turn = turns[i4];
67295             var ids = [turn.to.way];
67296             var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
67297             if (turn.only || turns.length === 1) {
67298               if (turn.via.ways) {
67299                 ids = ids.concat(turn.via.ways);
67300               }
67301             } else if (turn.to.way === wayID) {
67302               continue;
67303             }
67304             surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67305           }
67306         }
67307       }
67308       function updateHints(datum2) {
67309         var help = _container.selectAll(".restriction-help").html("");
67310         var placeholders = {};
67311         ["from", "via", "to"].forEach(function(k2) {
67312           placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
67313         });
67314         var entity = datum2 && datum2.properties && datum2.properties.entity;
67315         if (entity) {
67316           datum2 = entity;
67317         }
67318         if (_fromWayID) {
67319           way = vgraph.entity(_fromWayID);
67320           surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67321         }
67322         if (datum2 instanceof osmWay && datum2.__from) {
67323           way = datum2;
67324           highlightPathsFrom(_fromWayID ? null : way.id);
67325           surface.selectAll("." + way.id).classed("related", true);
67326           var clickSelect = !_fromWayID || _fromWayID !== way.id;
67327           help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
67328             from: placeholders.from,
67329             fromName: displayName(way.id, vgraph)
67330           }));
67331         } else if (datum2 instanceof osmTurn) {
67332           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67333           var turnType = restrictionType.replace(/^(only|no)\_/, "");
67334           var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
67335           var klass, turnText, nextText;
67336           if (datum2.no) {
67337             klass = "restrict";
67338             turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
67339             nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
67340           } else if (datum2.only) {
67341             klass = "only";
67342             turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
67343             nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
67344           } else {
67345             klass = "allow";
67346             turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
67347             nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
67348           }
67349           help.append("div").attr("class", "qualifier " + klass).html(turnText);
67350           help.append("div").html(_t.html("restriction.help.from_name_to_name", {
67351             from: placeholders.from,
67352             fromName: displayName(datum2.from.way, vgraph),
67353             to: placeholders.to,
67354             toName: displayName(datum2.to.way, vgraph)
67355           }));
67356           if (datum2.via.ways && datum2.via.ways.length) {
67357             var names = [];
67358             for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
67359               var prev = names[names.length - 1];
67360               var curr = displayName(datum2.via.ways[i4], vgraph);
67361               if (!prev || curr !== prev) {
67362                 names.push(curr);
67363               }
67364             }
67365             help.append("div").html(_t.html("restriction.help.via_names", {
67366               via: placeholders.via,
67367               viaNames: names.join(", ")
67368             }));
67369           }
67370           if (!indirect) {
67371             help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
67372           }
67373           highlightPathsFrom(null);
67374           var alongIDs = datum2.path.slice();
67375           surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67376         } else {
67377           highlightPathsFrom(null);
67378           if (_fromWayID) {
67379             help.append("div").html(_t.html("restriction.help.from_name", {
67380               from: placeholders.from,
67381               fromName: displayName(_fromWayID, vgraph)
67382             }));
67383           } else {
67384             help.append("div").html(_t.html("restriction.help.select_from", {
67385               from: placeholders.from
67386             }));
67387           }
67388         }
67389       }
67390     }
67391     function displayMaxDistance(maxDist) {
67392       return (selection2) => {
67393         var isImperial = !_mainLocalizer.usesMetric();
67394         var opts;
67395         if (isImperial) {
67396           var distToFeet = {
67397             // imprecise conversion for prettier display
67398             20: 70,
67399             25: 85,
67400             30: 100,
67401             35: 115,
67402             40: 130,
67403             45: 145,
67404             50: 160
67405           }[maxDist];
67406           opts = { distance: _t("units.feet", { quantity: distToFeet }) };
67407         } else {
67408           opts = { distance: _t("units.meters", { quantity: maxDist }) };
67409         }
67410         return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
67411       };
67412     }
67413     function displayMaxVia(maxVia) {
67414       return (selection2) => {
67415         selection2 = selection2.html("");
67416         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"));
67417       };
67418     }
67419     function displayName(entityID, graph) {
67420       var entity = graph.entity(entityID);
67421       var name = utilDisplayName(entity) || "";
67422       var matched = _mainPresetIndex.match(entity, graph);
67423       var type2 = matched && matched.name() || utilDisplayType(entity.id);
67424       return name || type2;
67425     }
67426     restrictions.entityIDs = function(val) {
67427       _intersection = null;
67428       _fromWayID = null;
67429       _oldTurns = null;
67430       _vertexID = val[0];
67431     };
67432     restrictions.tags = function() {
67433     };
67434     restrictions.focus = function() {
67435     };
67436     restrictions.off = function(selection2) {
67437       if (!_initialized3)
67438         return;
67439       selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
67440       select_default2(window).on("resize.restrictions", null);
67441     };
67442     return utilRebind(restrictions, dispatch14, "on");
67443   }
67444   uiFieldRestrictions.supportsMultiselection = false;
67445
67446   // modules/ui/fields/textarea.js
67447   function uiFieldTextarea(field, context) {
67448     var dispatch14 = dispatch_default("change");
67449     var input = select_default2(null);
67450     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
67451     var _tags;
67452     function textarea(selection2) {
67453       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67454       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
67455       input = wrap2.selectAll("textarea").data([0]);
67456       input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
67457       wrap2.call(_lengthIndicator);
67458       function change(onInput) {
67459         return function() {
67460           var val = utilGetSetValue(input);
67461           if (!onInput)
67462             val = context.cleanTagValue(val);
67463           if (!val && Array.isArray(_tags[field.key]))
67464             return;
67465           var t2 = {};
67466           t2[field.key] = val || void 0;
67467           dispatch14.call("change", this, t2, onInput);
67468         };
67469       }
67470     }
67471     textarea.tags = function(tags) {
67472       _tags = tags;
67473       var isMixed = Array.isArray(tags[field.key]);
67474       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);
67475       if (!isMixed) {
67476         _lengthIndicator.update(tags[field.key]);
67477       }
67478     };
67479     textarea.focus = function() {
67480       input.node().focus();
67481     };
67482     return utilRebind(textarea, dispatch14, "on");
67483   }
67484
67485   // modules/ui/fields/wikidata.js
67486   function uiFieldWikidata(field, context) {
67487     var wikidata = services.wikidata;
67488     var dispatch14 = dispatch_default("change");
67489     var _selection = select_default2(null);
67490     var _searchInput = select_default2(null);
67491     var _qid = null;
67492     var _wikidataEntity = null;
67493     var _wikiURL = "";
67494     var _entityIDs = [];
67495     var _wikipediaKey = field.keys && field.keys.find(function(key) {
67496       return key.includes("wikipedia");
67497     });
67498     var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
67499     var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
67500     function wiki(selection2) {
67501       _selection = selection2;
67502       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67503       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67504       var list2 = wrap2.selectAll("ul").data([0]);
67505       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
67506       var searchRow = list2.selectAll("li.wikidata-search").data([0]);
67507       var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
67508       searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
67509         var node = select_default2(this).node();
67510         node.setSelectionRange(0, node.value.length);
67511       }).on("blur", function() {
67512         setLabelForEntity();
67513       }).call(combobox.fetcher(fetchWikidataItems));
67514       combobox.on("accept", function(d2) {
67515         if (d2) {
67516           _qid = d2.id;
67517           change();
67518         }
67519       }).on("cancel", function() {
67520         setLabelForEntity();
67521       });
67522       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) {
67523         d3_event.preventDefault();
67524         if (_wikiURL)
67525           window.open(_wikiURL, "_blank");
67526       });
67527       searchRow = searchRow.merge(searchRowEnter);
67528       _searchInput = searchRow.select("input");
67529       var wikidataProperties = ["description", "identifier"];
67530       var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
67531       var enter = items.enter().append("li").attr("class", function(d2) {
67532         return "labeled-input preset-wikidata-" + d2;
67533       });
67534       enter.append("div").attr("class", "label").html(function(d2) {
67535         return _t.html("wikidata." + d2);
67536       });
67537       enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
67538       enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
67539         d3_event.preventDefault();
67540         select_default2(this.parentNode).select("input").node().select();
67541         document.execCommand("copy");
67542       });
67543     }
67544     function fetchWikidataItems(q2, callback) {
67545       if (!q2 && _hintKey) {
67546         for (var i3 in _entityIDs) {
67547           var entity = context.hasEntity(_entityIDs[i3]);
67548           if (entity.tags[_hintKey]) {
67549             q2 = entity.tags[_hintKey];
67550             break;
67551           }
67552         }
67553       }
67554       wikidata.itemsForSearchQuery(q2, function(err, data) {
67555         if (err) {
67556           if (err !== "No query")
67557             console.error(err);
67558           return;
67559         }
67560         var result = data.map(function(item) {
67561           return {
67562             id: item.id,
67563             value: item.display.label.value + " (" + item.id + ")",
67564             display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
67565             title: item.display.description && item.display.description.value,
67566             terms: item.aliases
67567           };
67568         });
67569         if (callback)
67570           callback(result);
67571       });
67572     }
67573     function change() {
67574       var syncTags = {};
67575       syncTags[field.key] = _qid;
67576       dispatch14.call("change", this, syncTags);
67577       var initGraph = context.graph();
67578       var initEntityIDs = _entityIDs;
67579       wikidata.entityByQID(_qid, function(err, entity) {
67580         if (err)
67581           return;
67582         if (context.graph() !== initGraph)
67583           return;
67584         if (!entity.sitelinks)
67585           return;
67586         var langs = wikidata.languagesToQuery();
67587         ["labels", "descriptions"].forEach(function(key) {
67588           if (!entity[key])
67589             return;
67590           var valueLangs = Object.keys(entity[key]);
67591           if (valueLangs.length === 0)
67592             return;
67593           var valueLang = valueLangs[0];
67594           if (langs.indexOf(valueLang) === -1) {
67595             langs.push(valueLang);
67596           }
67597         });
67598         var newWikipediaValue;
67599         if (_wikipediaKey) {
67600           var foundPreferred;
67601           for (var i3 in langs) {
67602             var lang = langs[i3];
67603             var siteID = lang.replace("-", "_") + "wiki";
67604             if (entity.sitelinks[siteID]) {
67605               foundPreferred = true;
67606               newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
67607               break;
67608             }
67609           }
67610           if (!foundPreferred) {
67611             var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
67612               return site.endsWith("wiki");
67613             });
67614             if (wikiSiteKeys.length === 0) {
67615               newWikipediaValue = null;
67616             } else {
67617               var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
67618               var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
67619               newWikipediaValue = wikiLang + ":" + wikiTitle;
67620             }
67621           }
67622         }
67623         if (newWikipediaValue) {
67624           newWikipediaValue = context.cleanTagValue(newWikipediaValue);
67625         }
67626         if (typeof newWikipediaValue === "undefined")
67627           return;
67628         var actions = initEntityIDs.map(function(entityID) {
67629           var entity2 = context.hasEntity(entityID);
67630           if (!entity2)
67631             return null;
67632           var currTags = Object.assign({}, entity2.tags);
67633           if (newWikipediaValue === null) {
67634             if (!currTags[_wikipediaKey])
67635               return null;
67636             delete currTags[_wikipediaKey];
67637           } else {
67638             currTags[_wikipediaKey] = newWikipediaValue;
67639           }
67640           return actionChangeTags(entityID, currTags);
67641         }).filter(Boolean);
67642         if (!actions.length)
67643           return;
67644         context.overwrite(
67645           function actionUpdateWikipediaTags(graph) {
67646             actions.forEach(function(action) {
67647               graph = action(graph);
67648             });
67649             return graph;
67650           },
67651           context.history().undoAnnotation()
67652         );
67653       });
67654     }
67655     function setLabelForEntity() {
67656       var label = "";
67657       if (_wikidataEntity) {
67658         label = entityPropertyForDisplay(_wikidataEntity, "labels");
67659         if (label.length === 0) {
67660           label = _wikidataEntity.id.toString();
67661         }
67662       }
67663       utilGetSetValue(_searchInput, label);
67664     }
67665     wiki.tags = function(tags) {
67666       var isMixed = Array.isArray(tags[field.key]);
67667       _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
67668       _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
67669       if (!/^Q[0-9]*$/.test(_qid)) {
67670         unrecognized();
67671         return;
67672       }
67673       _wikiURL = "https://wikidata.org/wiki/" + _qid;
67674       wikidata.entityByQID(_qid, function(err, entity) {
67675         if (err) {
67676           unrecognized();
67677           return;
67678         }
67679         _wikidataEntity = entity;
67680         setLabelForEntity();
67681         var description = entityPropertyForDisplay(entity, "descriptions");
67682         _selection.select("button.wiki-link").classed("disabled", false);
67683         _selection.select(".preset-wikidata-description").style("display", function() {
67684           return description.length > 0 ? "flex" : "none";
67685         }).select("input").attr("value", description);
67686         _selection.select(".preset-wikidata-identifier").style("display", function() {
67687           return entity.id ? "flex" : "none";
67688         }).select("input").attr("value", entity.id);
67689       });
67690       function unrecognized() {
67691         _wikidataEntity = null;
67692         setLabelForEntity();
67693         _selection.select(".preset-wikidata-description").style("display", "none");
67694         _selection.select(".preset-wikidata-identifier").style("display", "none");
67695         _selection.select("button.wiki-link").classed("disabled", true);
67696         if (_qid && _qid !== "") {
67697           _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
67698         } else {
67699           _wikiURL = "";
67700         }
67701       }
67702     };
67703     function entityPropertyForDisplay(wikidataEntity, propKey) {
67704       if (!wikidataEntity[propKey])
67705         return "";
67706       var propObj = wikidataEntity[propKey];
67707       var langKeys = Object.keys(propObj);
67708       if (langKeys.length === 0)
67709         return "";
67710       var langs = wikidata.languagesToQuery();
67711       for (var i3 in langs) {
67712         var lang = langs[i3];
67713         var valueObj = propObj[lang];
67714         if (valueObj && valueObj.value && valueObj.value.length > 0)
67715           return valueObj.value;
67716       }
67717       return propObj[langKeys[0]].value;
67718     }
67719     wiki.entityIDs = function(val) {
67720       if (!arguments.length)
67721         return _entityIDs;
67722       _entityIDs = val;
67723       return wiki;
67724     };
67725     wiki.focus = function() {
67726       _searchInput.node().focus();
67727     };
67728     return utilRebind(wiki, dispatch14, "on");
67729   }
67730
67731   // modules/ui/fields/wikipedia.js
67732   function uiFieldWikipedia(field, context) {
67733     const scheme = "https://";
67734     const domain = "wikipedia.org";
67735     const dispatch14 = dispatch_default("change");
67736     const wikipedia = services.wikipedia;
67737     const wikidata = services.wikidata;
67738     let _langInput = select_default2(null);
67739     let _titleInput = select_default2(null);
67740     let _wikiURL = "";
67741     let _entityIDs;
67742     let _tags;
67743     let _dataWikipedia = [];
67744     _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
67745       _dataWikipedia = d2;
67746       if (_tags)
67747         updateForTags(_tags);
67748     }).catch(() => {
67749     });
67750     const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
67751       const v2 = value.toLowerCase();
67752       callback(
67753         _dataWikipedia.filter((d2) => {
67754           return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
67755         }).map((d2) => ({ value: d2[1] }))
67756       );
67757     });
67758     const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
67759       if (!value) {
67760         value = "";
67761         for (let i3 in _entityIDs) {
67762           let entity = context.hasEntity(_entityIDs[i3]);
67763           if (entity.tags.name) {
67764             value = entity.tags.name;
67765             break;
67766           }
67767         }
67768       }
67769       const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
67770       searchfn(language()[2], value, (query, data) => {
67771         callback(data.map((d2) => ({ value: d2 })));
67772       });
67773     });
67774     function wiki(selection2) {
67775       let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67776       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
67777       let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
67778       langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
67779       _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
67780       _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);
67781       _langInput.on("blur", changeLang).on("change", changeLang);
67782       let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
67783       titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
67784       _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
67785       _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
67786       _titleInput.on("blur", function() {
67787         change(true);
67788       }).on("change", function() {
67789         change(false);
67790       });
67791       let link3 = titleContainer.selectAll(".wiki-link").data([0]);
67792       link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain })).call(svgIcon("#iD-icon-out-link")).merge(link3);
67793       link3.on("click", (d3_event) => {
67794         d3_event.preventDefault();
67795         if (_wikiURL)
67796           window.open(_wikiURL, "_blank");
67797       });
67798     }
67799     function defaultLanguageInfo(skipEnglishFallback) {
67800       const langCode = _mainLocalizer.languageCode().toLowerCase();
67801       for (let i3 in _dataWikipedia) {
67802         let d2 = _dataWikipedia[i3];
67803         if (d2[2] === langCode)
67804           return d2;
67805       }
67806       return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
67807     }
67808     function language(skipEnglishFallback) {
67809       const value = utilGetSetValue(_langInput).toLowerCase();
67810       for (let i3 in _dataWikipedia) {
67811         let d2 = _dataWikipedia[i3];
67812         if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value)
67813           return d2;
67814       }
67815       return defaultLanguageInfo(skipEnglishFallback);
67816     }
67817     function changeLang() {
67818       utilGetSetValue(_langInput, language()[1]);
67819       change(true);
67820     }
67821     function change(skipWikidata) {
67822       let value = utilGetSetValue(_titleInput);
67823       const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
67824       const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
67825       let syncTags = {};
67826       if (langInfo) {
67827         const nativeLangName = langInfo[1];
67828         value = decodeURIComponent(m2[2]).replace(/_/g, " ");
67829         if (m2[3]) {
67830           let anchor;
67831           anchor = decodeURIComponent(m2[3]);
67832           value += "#" + anchor.replace(/_/g, " ");
67833         }
67834         value = value.slice(0, 1).toUpperCase() + value.slice(1);
67835         utilGetSetValue(_langInput, nativeLangName);
67836         utilGetSetValue(_titleInput, value);
67837       }
67838       if (value) {
67839         syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
67840       } else {
67841         syncTags.wikipedia = void 0;
67842       }
67843       dispatch14.call("change", this, syncTags);
67844       if (skipWikidata || !value || !language()[2])
67845         return;
67846       const initGraph = context.graph();
67847       const initEntityIDs = _entityIDs;
67848       wikidata.itemsByTitle(language()[2], value, (err, data) => {
67849         if (err || !data || !Object.keys(data).length)
67850           return;
67851         if (context.graph() !== initGraph)
67852           return;
67853         const qids = Object.keys(data);
67854         const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
67855         let actions = initEntityIDs.map((entityID) => {
67856           let entity = context.entity(entityID).tags;
67857           let currTags = Object.assign({}, entity);
67858           if (currTags.wikidata !== value2) {
67859             currTags.wikidata = value2;
67860             return actionChangeTags(entityID, currTags);
67861           }
67862           return null;
67863         }).filter(Boolean);
67864         if (!actions.length)
67865           return;
67866         context.overwrite(
67867           function actionUpdateWikidataTags(graph) {
67868             actions.forEach(function(action) {
67869               graph = action(graph);
67870             });
67871             return graph;
67872           },
67873           context.history().undoAnnotation()
67874         );
67875       });
67876     }
67877     wiki.tags = (tags) => {
67878       _tags = tags;
67879       updateForTags(tags);
67880     };
67881     function updateForTags(tags) {
67882       const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
67883       const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
67884       const tagLang = m2 && m2[1];
67885       const tagArticleTitle = m2 && m2[2];
67886       let anchor = m2 && m2[3];
67887       const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
67888       if (tagLangInfo) {
67889         const nativeLangName = tagLangInfo[1];
67890         utilGetSetValue(_langInput, nativeLangName);
67891         utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
67892         _wikiURL = "".concat(scheme).concat(tagLang, ".").concat(domain, "/wiki/").concat(wiki.encodePath(tagArticleTitle, anchor));
67893       } else {
67894         utilGetSetValue(_titleInput, value);
67895         if (value && value !== "") {
67896           utilGetSetValue(_langInput, "");
67897           const defaultLangInfo = defaultLanguageInfo();
67898           _wikiURL = "".concat(scheme).concat(defaultLangInfo[2], ".").concat(domain, "/w/index.php?fulltext=1&search=").concat(value);
67899         } else {
67900           const shownOrDefaultLangInfo = language(
67901             true
67902             /* skipEnglishFallback */
67903           );
67904           utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
67905           _wikiURL = "";
67906         }
67907       }
67908     }
67909     wiki.encodePath = (tagArticleTitle, anchor) => {
67910       const underscoredTitle = tagArticleTitle.replace(/ /g, "_");
67911       const uriEncodedUnderscoredTitle = encodeURIComponent(underscoredTitle);
67912       const uriEncodedAnchorFragment = wiki.encodeURIAnchorFragment(anchor);
67913       return "".concat(uriEncodedUnderscoredTitle).concat(uriEncodedAnchorFragment);
67914     };
67915     wiki.encodeURIAnchorFragment = (anchor) => {
67916       if (!anchor)
67917         return "";
67918       const underscoredAnchor = anchor.replace(/ /g, "_");
67919       return "#" + encodeURIComponent(underscoredAnchor);
67920     };
67921     wiki.entityIDs = (val) => {
67922       if (!arguments.length)
67923         return _entityIDs;
67924       _entityIDs = val;
67925       return wiki;
67926     };
67927     wiki.focus = () => {
67928       _titleInput.node().focus();
67929     };
67930     return utilRebind(wiki, dispatch14, "on");
67931   }
67932   uiFieldWikipedia.supportsMultiselection = false;
67933
67934   // modules/ui/fields/index.js
67935   var uiFields = {
67936     access: uiFieldAccess,
67937     address: uiFieldAddress,
67938     check: uiFieldCheck,
67939     colour: uiFieldText,
67940     combo: uiFieldCombo,
67941     cycleway: uiFieldDirectionalCombo,
67942     date: uiFieldText,
67943     defaultCheck: uiFieldCheck,
67944     directionalCombo: uiFieldDirectionalCombo,
67945     email: uiFieldText,
67946     identifier: uiFieldText,
67947     lanes: uiFieldLanes,
67948     localized: uiFieldLocalized,
67949     roadheight: uiFieldRoadheight,
67950     roadspeed: uiFieldRoadspeed,
67951     manyCombo: uiFieldCombo,
67952     multiCombo: uiFieldCombo,
67953     networkCombo: uiFieldCombo,
67954     number: uiFieldText,
67955     onewayCheck: uiFieldCheck,
67956     radio: uiFieldRadio,
67957     restrictions: uiFieldRestrictions,
67958     semiCombo: uiFieldCombo,
67959     structureRadio: uiFieldRadio,
67960     tel: uiFieldText,
67961     text: uiFieldText,
67962     textarea: uiFieldTextarea,
67963     typeCombo: uiFieldCombo,
67964     url: uiFieldText,
67965     wikidata: uiFieldWikidata,
67966     wikipedia: uiFieldWikipedia
67967   };
67968
67969   // modules/ui/field.js
67970   function uiField(context, presetField2, entityIDs, options2) {
67971     options2 = Object.assign({
67972       show: true,
67973       wrap: true,
67974       remove: true,
67975       revert: true,
67976       info: true
67977     }, options2);
67978     var dispatch14 = dispatch_default("change", "revert");
67979     var field = Object.assign({}, presetField2);
67980     field.domId = utilUniqueDomId("form-field-" + field.safeid);
67981     var _show = options2.show;
67982     var _state = "";
67983     var _tags = {};
67984     var _entityExtent;
67985     if (entityIDs && entityIDs.length) {
67986       _entityExtent = entityIDs.reduce(function(extent, entityID) {
67987         var entity = context.graph().entity(entityID);
67988         return extent.extend(entity.extent(context.graph()));
67989       }, geoExtent());
67990     }
67991     var _locked = false;
67992     var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
67993     if (_show && !field.impl) {
67994       createField();
67995     }
67996     function createField() {
67997       field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
67998         dispatch14.call("change", field, t2, onInput);
67999       });
68000       if (entityIDs) {
68001         field.entityIDs = entityIDs;
68002         if (field.impl.entityIDs) {
68003           field.impl.entityIDs(entityIDs);
68004         }
68005       }
68006     }
68007     function allKeys() {
68008       let keys2 = field.keys || [field.key];
68009       if (field.type === "directionalCombo" && field.key) {
68010         keys2 = keys2.concat(field.key);
68011       }
68012       return keys2;
68013     }
68014     function isModified() {
68015       if (!entityIDs || !entityIDs.length)
68016         return false;
68017       return entityIDs.some(function(entityID) {
68018         var original = context.graph().base().entities[entityID];
68019         var latest = context.graph().entity(entityID);
68020         return allKeys().some(function(key) {
68021           return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
68022         });
68023       });
68024     }
68025     function tagsContainFieldKey() {
68026       return allKeys().some(function(key) {
68027         if (field.type === "multiCombo") {
68028           for (var tagKey in _tags) {
68029             if (tagKey.indexOf(key) === 0) {
68030               return true;
68031             }
68032           }
68033           return false;
68034         }
68035         return _tags[key] !== void 0;
68036       });
68037     }
68038     function revert(d3_event, d2) {
68039       d3_event.stopPropagation();
68040       d3_event.preventDefault();
68041       if (!entityIDs || _locked)
68042         return;
68043       dispatch14.call("revert", d2, allKeys());
68044     }
68045     function remove2(d3_event, d2) {
68046       d3_event.stopPropagation();
68047       d3_event.preventDefault();
68048       if (_locked)
68049         return;
68050       var t2 = {};
68051       allKeys().forEach(function(key) {
68052         t2[key] = void 0;
68053       });
68054       dispatch14.call("change", d2, t2);
68055     }
68056     field.render = function(selection2) {
68057       var container = selection2.selectAll(".form-field").data([field]);
68058       var enter = container.enter().append("div").attr("class", function(d2) {
68059         return "form-field form-field-" + d2.safeid;
68060       }).classed("nowrap", !options2.wrap);
68061       if (options2.wrap) {
68062         var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
68063           return d2.domId;
68064         });
68065         var textEnter = labelEnter.append("span").attr("class", "label-text");
68066         textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
68067           d2.label()(select_default2(this));
68068         });
68069         textEnter.append("span").attr("class", "label-textannotation");
68070         if (options2.remove) {
68071           labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
68072         }
68073         if (options2.revert) {
68074           labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
68075         }
68076       }
68077       container = container.merge(enter);
68078       container.select(".field-label > .remove-icon").on("click", remove2);
68079       container.select(".field-label > .modified-icon").on("click", revert);
68080       container.each(function(d2) {
68081         var selection3 = select_default2(this);
68082         if (!d2.impl) {
68083           createField();
68084         }
68085         var reference, help;
68086         if (options2.wrap && field.type === "restrictions") {
68087           help = uiFieldHelp(context, "restrictions");
68088         }
68089         if (options2.wrap && options2.info) {
68090           var referenceKey = d2.key || "";
68091           if (d2.type === "multiCombo") {
68092             referenceKey = referenceKey.replace(/:$/, "");
68093           }
68094           var referenceOptions = d2.reference || {
68095             key: referenceKey,
68096             value: _tags[referenceKey]
68097           };
68098           reference = uiTagReference(referenceOptions, context);
68099           if (_state === "hover") {
68100             reference.showing(false);
68101           }
68102         }
68103         selection3.call(d2.impl);
68104         if (help) {
68105           selection3.call(help.body).select(".field-label").call(help.button);
68106         }
68107         if (reference) {
68108           selection3.call(reference.body).select(".field-label").call(reference.button);
68109         }
68110         d2.impl.tags(_tags);
68111       });
68112       container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
68113       var annotation = container.selectAll(".field-label .label-textannotation");
68114       var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
68115       icon2.exit().remove();
68116       icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
68117       container.call(_locked ? _lockedTip : _lockedTip.destroy);
68118     };
68119     field.state = function(val) {
68120       if (!arguments.length)
68121         return _state;
68122       _state = val;
68123       return field;
68124     };
68125     field.tags = function(val) {
68126       if (!arguments.length)
68127         return _tags;
68128       _tags = val;
68129       if (tagsContainFieldKey() && !_show) {
68130         _show = true;
68131         if (!field.impl) {
68132           createField();
68133         }
68134       }
68135       return field;
68136     };
68137     field.locked = function(val) {
68138       if (!arguments.length)
68139         return _locked;
68140       _locked = val;
68141       return field;
68142     };
68143     field.show = function() {
68144       _show = true;
68145       if (!field.impl) {
68146         createField();
68147       }
68148       if (field.default && field.key && _tags[field.key] !== field.default) {
68149         var t2 = {};
68150         t2[field.key] = field.default;
68151         dispatch14.call("change", this, t2);
68152       }
68153     };
68154     field.isShown = function() {
68155       return _show;
68156     };
68157     field.isAllowed = function() {
68158       if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false)
68159         return false;
68160       if (field.geometry && !entityIDs.every(function(entityID) {
68161         return field.matchGeometry(context.graph().geometry(entityID));
68162       }))
68163         return false;
68164       if (entityIDs && _entityExtent && field.locationSetID) {
68165         var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
68166         if (!validHere[field.locationSetID])
68167           return false;
68168       }
68169       var prerequisiteTag = field.prerequisiteTag;
68170       if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
68171       prerequisiteTag) {
68172         if (!entityIDs.every(function(entityID) {
68173           var entity = context.graph().entity(entityID);
68174           if (prerequisiteTag.key) {
68175             var value = entity.tags[prerequisiteTag.key];
68176             if (!value)
68177               return false;
68178             if (prerequisiteTag.valueNot) {
68179               return prerequisiteTag.valueNot !== value;
68180             }
68181             if (prerequisiteTag.value) {
68182               return prerequisiteTag.value === value;
68183             }
68184           } else if (prerequisiteTag.keyNot) {
68185             if (entity.tags[prerequisiteTag.keyNot])
68186               return false;
68187           }
68188           return true;
68189         }))
68190           return false;
68191       }
68192       return true;
68193     };
68194     field.focus = function() {
68195       if (field.impl) {
68196         field.impl.focus();
68197       }
68198     };
68199     return utilRebind(field, dispatch14, "on");
68200   }
68201
68202   // modules/ui/form_fields.js
68203   function uiFormFields(context) {
68204     var moreCombo = uiCombobox(context, "more-fields").minItems(1);
68205     var _fieldsArr = [];
68206     var _lastPlaceholder = "";
68207     var _state = "";
68208     var _klass = "";
68209     function formFields(selection2) {
68210       var allowedFields = _fieldsArr.filter(function(field) {
68211         return field.isAllowed();
68212       });
68213       var shown = allowedFields.filter(function(field) {
68214         return field.isShown();
68215       });
68216       var notShown = allowedFields.filter(function(field) {
68217         return !field.isShown();
68218       });
68219       var container = selection2.selectAll(".form-fields-container").data([0]);
68220       container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container);
68221       var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) {
68222         return d2.id + (d2.entityIDs ? d2.entityIDs.join() : "");
68223       });
68224       fields.exit().remove();
68225       var enter = fields.enter().append("div").attr("class", function(d2) {
68226         return "wrap-form-field wrap-form-field-" + d2.safeid;
68227       });
68228       fields = fields.merge(enter);
68229       fields.order().each(function(d2) {
68230         select_default2(this).call(d2.render);
68231       });
68232       var titles = [];
68233       var moreFields = notShown.map(function(field) {
68234         var title = field.title();
68235         titles.push(title);
68236         var terms = field.terms();
68237         if (field.key)
68238           terms.push(field.key);
68239         if (field.keys)
68240           terms = terms.concat(field.keys);
68241         return {
68242           display: field.label(),
68243           value: title,
68244           title,
68245           field,
68246           terms
68247         };
68248       });
68249       var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : "");
68250       var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]);
68251       more.exit().remove();
68252       var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label");
68253       moreEnter.append("span").call(_t.append("inspector.add_fields"));
68254       more = moreEnter.merge(more);
68255       var input = more.selectAll(".value").data([0]);
68256       input.exit().remove();
68257       input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input);
68258       input.call(utilGetSetValue, "").call(
68259         moreCombo.data(moreFields).on("accept", function(d2) {
68260           if (!d2)
68261             return;
68262           var field = d2.field;
68263           field.show();
68264           selection2.call(formFields);
68265           field.focus();
68266         })
68267       );
68268       if (_lastPlaceholder !== placeholder) {
68269         input.attr("placeholder", placeholder);
68270         _lastPlaceholder = placeholder;
68271       }
68272     }
68273     formFields.fieldsArr = function(val) {
68274       if (!arguments.length)
68275         return _fieldsArr;
68276       _fieldsArr = val || [];
68277       return formFields;
68278     };
68279     formFields.state = function(val) {
68280       if (!arguments.length)
68281         return _state;
68282       _state = val;
68283       return formFields;
68284     };
68285     formFields.klass = function(val) {
68286       if (!arguments.length)
68287         return _klass;
68288       _klass = val;
68289       return formFields;
68290     };
68291     return formFields;
68292   }
68293
68294   // modules/ui/changeset_editor.js
68295   function uiChangesetEditor(context) {
68296     var dispatch14 = dispatch_default("change");
68297     var formFields = uiFormFields(context);
68298     var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
68299     var _fieldsArr;
68300     var _tags;
68301     var _changesetID;
68302     function changesetEditor(selection2) {
68303       render(selection2);
68304     }
68305     function render(selection2) {
68306       var initial = false;
68307       if (!_fieldsArr) {
68308         initial = true;
68309         var presets = _mainPresetIndex;
68310         _fieldsArr = [
68311           uiField(context, presets.field("comment"), null, { show: true, revert: false }),
68312           uiField(context, presets.field("source"), null, { show: true, revert: false }),
68313           uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
68314         ];
68315         _fieldsArr.forEach(function(field) {
68316           field.on("change", function(t2, onInput) {
68317             dispatch14.call("change", field, void 0, t2, onInput);
68318           });
68319         });
68320       }
68321       _fieldsArr.forEach(function(field) {
68322         field.tags(_tags);
68323       });
68324       selection2.call(formFields.fieldsArr(_fieldsArr));
68325       if (initial) {
68326         var commentField = selection2.select(".form-field-comment textarea");
68327         var commentNode = commentField.node();
68328         if (commentNode) {
68329           commentNode.focus();
68330           commentNode.select();
68331         }
68332         utilTriggerEvent(commentField, "blur");
68333         var osm = context.connection();
68334         if (osm) {
68335           osm.userChangesets(function(err, changesets) {
68336             if (err)
68337               return;
68338             var comments = changesets.map(function(changeset) {
68339               var comment = changeset.tags.comment;
68340               return comment ? { title: comment, value: comment } : null;
68341             }).filter(Boolean);
68342             commentField.call(
68343               commentCombo.data(utilArrayUniqBy(comments, "title"))
68344             );
68345           });
68346         }
68347       }
68348       const warnings = [];
68349       if (_tags.comment.match(/google/i)) {
68350         warnings.push({
68351           id: 'contains "google"',
68352           msg: _t.append("commit.google_warning"),
68353           link: _t("commit.google_warning_link")
68354         });
68355       }
68356       const maxChars = context.maxCharsForTagValue();
68357       const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
68358       if (strLen > maxChars || false) {
68359         warnings.push({
68360           id: "message too long",
68361           msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
68362         });
68363       }
68364       var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
68365       commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
68366       var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
68367       commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
68368       commentEnter.transition().duration(200).style("opacity", 1);
68369       commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
68370         let selection3 = select_default2(this);
68371         if (d2.link) {
68372           selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
68373         }
68374         selection3.call(d2.msg);
68375       });
68376     }
68377     changesetEditor.tags = function(_2) {
68378       if (!arguments.length)
68379         return _tags;
68380       _tags = _2;
68381       return changesetEditor;
68382     };
68383     changesetEditor.changesetID = function(_2) {
68384       if (!arguments.length)
68385         return _changesetID;
68386       if (_changesetID === _2)
68387         return changesetEditor;
68388       _changesetID = _2;
68389       _fieldsArr = null;
68390       return changesetEditor;
68391     };
68392     return utilRebind(changesetEditor, dispatch14, "on");
68393   }
68394
68395   // modules/ui/commit.js
68396   var import_fast_deep_equal9 = __toESM(require_fast_deep_equal());
68397
68398   // modules/util/jxon.js
68399   var JXON = new function() {
68400     var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i;
68401     function parseText(sValue) {
68402       if (rIsNull.test(sValue)) {
68403         return null;
68404       }
68405       if (rIsBool.test(sValue)) {
68406         return sValue.toLowerCase() === "true";
68407       }
68408       if (isFinite(sValue)) {
68409         return parseFloat(sValue);
68410       }
68411       if (isFinite(Date.parse(sValue))) {
68412         return new Date(sValue);
68413       }
68414       return sValue;
68415     }
68416     function EmptyTree() {
68417     }
68418     EmptyTree.prototype.toString = function() {
68419       return "null";
68420     };
68421     EmptyTree.prototype.valueOf = function() {
68422       return null;
68423     };
68424     function objectify(vValue) {
68425       return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
68426     }
68427     function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
68428       var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2);
68429       var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : (
68430         /* put here the default value for empty nodes: */
68431         true
68432       );
68433       if (bChildren) {
68434         for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
68435           oNode = oParentNode.childNodes.item(nItem);
68436           if (oNode.nodeType === 4) {
68437             sCollectedTxt += oNode.nodeValue;
68438           } else if (oNode.nodeType === 3) {
68439             sCollectedTxt += oNode.nodeValue.trim();
68440           } else if (oNode.nodeType === 1 && !oNode.prefix) {
68441             aCache.push(oNode);
68442           }
68443         }
68444       }
68445       var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt);
68446       if (!bHighVerb && (bChildren || bAttributes)) {
68447         vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
68448       }
68449       for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
68450         sProp = aCache[nElId].nodeName.toLowerCase();
68451         vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
68452         if (vResult.hasOwnProperty(sProp)) {
68453           if (vResult[sProp].constructor !== Array) {
68454             vResult[sProp] = [vResult[sProp]];
68455           }
68456           vResult[sProp].push(vContent);
68457         } else {
68458           vResult[sProp] = vContent;
68459           nLength++;
68460         }
68461       }
68462       if (bAttributes) {
68463         var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult;
68464         for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
68465           oAttrib = oParentNode.attributes.item(nAttrib);
68466           oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim());
68467         }
68468         if (bNesteAttr) {
68469           if (bFreeze) {
68470             Object.freeze(oAttrParent);
68471           }
68472           vResult[sAttributesProp] = oAttrParent;
68473           nLength -= nAttrLen - 1;
68474         }
68475       }
68476       if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
68477         vResult[sValueProp] = vBuiltVal;
68478       } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
68479         vResult = vBuiltVal;
68480       }
68481       if (bFreeze && (bHighVerb || nLength > 0)) {
68482         Object.freeze(vResult);
68483       }
68484       aCache.length = nLevelStart;
68485       return vResult;
68486     }
68487     function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
68488       var vValue, oChild;
68489       if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) {
68490         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString()));
68491       } else if (oParentObj.constructor === Date) {
68492         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString()));
68493       }
68494       for (var sName in oParentObj) {
68495         vValue = oParentObj[sName];
68496         if (isFinite(sName) || vValue instanceof Function) {
68497           continue;
68498         }
68499         if (sName === sValueProp) {
68500           if (vValue !== null && vValue !== true) {
68501             oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue)));
68502           }
68503         } else if (sName === sAttributesProp) {
68504           for (var sAttrib in vValue) {
68505             oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
68506           }
68507         } else if (sName.charAt(0) === sAttrPref) {
68508           oParentEl.setAttribute(sName.slice(1), vValue);
68509         } else if (vValue.constructor === Array) {
68510           for (var nItem = 0; nItem < vValue.length; nItem++) {
68511             oChild = oXMLDoc.createElement(sName);
68512             loadObjTree(oXMLDoc, oChild, vValue[nItem]);
68513             oParentEl.appendChild(oChild);
68514           }
68515         } else {
68516           oChild = oXMLDoc.createElement(sName);
68517           if (vValue instanceof Object) {
68518             loadObjTree(oXMLDoc, oChild, vValue);
68519           } else if (vValue !== null && vValue !== true) {
68520             oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
68521           }
68522           oParentEl.appendChild(oChild);
68523         }
68524       }
68525     }
68526     this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) {
68527       var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : (
68528         /* put here the default verbosity level: */
68529         1
68530       );
68531       return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
68532     };
68533     this.unbuild = function(oObjTree) {
68534       var oNewDoc = document.implementation.createDocument("", "", null);
68535       loadObjTree(oNewDoc, oNewDoc, oObjTree);
68536       return oNewDoc;
68537     };
68538     this.stringify = function(oObjTree) {
68539       return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree));
68540     };
68541   }();
68542
68543   // modules/ui/sections/changes.js
68544   function uiSectionChanges(context) {
68545     var _discardTags = {};
68546     _mainFileFetcher.get("discarded").then(function(d2) {
68547       _discardTags = d2;
68548     }).catch(function() {
68549     });
68550     var section = uiSection("changes-list", context).label(function() {
68551       var history = context.history();
68552       var summary = history.difference().summary();
68553       return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
68554     }).disclosureContent(renderDisclosureContent);
68555     function renderDisclosureContent(selection2) {
68556       var history = context.history();
68557       var summary = history.difference().summary();
68558       var container = selection2.selectAll(".commit-section").data([0]);
68559       var containerEnter = container.enter().append("div").attr("class", "commit-section");
68560       containerEnter.append("ul").attr("class", "changeset-list");
68561       container = containerEnter.merge(container);
68562       var items = container.select("ul").selectAll("li").data(summary);
68563       var itemsEnter = items.enter().append("li").attr("class", "change-item");
68564       var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
68565       buttons.each(function(d2) {
68566         select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
68567       });
68568       buttons.append("span").attr("class", "change-type").html(function(d2) {
68569         return _t.html("commit." + d2.changeType) + " ";
68570       });
68571       buttons.append("strong").attr("class", "entity-type").text(function(d2) {
68572         var matched = _mainPresetIndex.match(d2.entity, d2.graph);
68573         return matched && matched.name() || utilDisplayType(d2.entity.id);
68574       });
68575       buttons.append("span").attr("class", "entity-name").text(function(d2) {
68576         var name = utilDisplayName(d2.entity) || "", string = "";
68577         if (name !== "") {
68578           string += ":";
68579         }
68580         return string += " " + name;
68581       });
68582       items = itemsEnter.merge(items);
68583       var changeset = new osmChangeset().update({ id: void 0 });
68584       var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
68585       delete changeset.id;
68586       var data = JXON.stringify(changeset.osmChangeJXON(changes));
68587       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
68588       var fileName = "changes.osc";
68589       var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
68590       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
68591       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
68592       function mouseover(d2) {
68593         if (d2.entity) {
68594           context.surface().selectAll(
68595             utilEntityOrMemberSelector([d2.entity.id], context.graph())
68596           ).classed("hover", true);
68597         }
68598       }
68599       function mouseout() {
68600         context.surface().selectAll(".hover").classed("hover", false);
68601       }
68602       function click(d3_event, change) {
68603         if (change.changeType !== "deleted") {
68604           var entity = change.entity;
68605           context.map().zoomToEase(entity);
68606           context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
68607         }
68608       }
68609     }
68610     return section;
68611   }
68612
68613   // modules/ui/commit_warnings.js
68614   function uiCommitWarnings(context) {
68615     function commitWarnings(selection2) {
68616       var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
68617       for (var severity in issuesBySeverity) {
68618         var issues = issuesBySeverity[severity];
68619         if (severity !== "error") {
68620           issues = issues.filter(function(issue) {
68621             return issue.type !== "help_request";
68622           });
68623         }
68624         var section = severity + "-section";
68625         var issueItem = severity + "-item";
68626         var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
68627         container.exit().remove();
68628         var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
68629         containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
68630         containerEnter.append("ul").attr("class", "changeset-list");
68631         container = containerEnter.merge(container);
68632         var items = container.select("ul").selectAll("li").data(issues, function(d2) {
68633           return d2.key;
68634         });
68635         items.exit().remove();
68636         var itemsEnter = items.enter().append("li").attr("class", issueItem);
68637         var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
68638           if (d2.entityIds) {
68639             context.surface().selectAll(
68640               utilEntityOrMemberSelector(
68641                 d2.entityIds,
68642                 context.graph()
68643               )
68644             ).classed("hover", true);
68645           }
68646         }).on("mouseout", function() {
68647           context.surface().selectAll(".hover").classed("hover", false);
68648         }).on("click", function(d3_event, d2) {
68649           context.validator().focusIssue(d2);
68650         });
68651         buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
68652         buttons.append("strong").attr("class", "issue-message");
68653         buttons.filter(function(d2) {
68654           return d2.tooltip;
68655         }).call(
68656           uiTooltip().title(function(d2) {
68657             return d2.tooltip;
68658           }).placement("top")
68659         );
68660         items = itemsEnter.merge(items);
68661         items.selectAll(".issue-message").text("").each(function(d2) {
68662           return d2.message(context)(select_default2(this));
68663         });
68664       }
68665     }
68666     return commitWarnings;
68667   }
68668
68669   // modules/ui/commit.js
68670   var readOnlyTags = [
68671     /^changesets_count$/,
68672     /^created_by$/,
68673     /^ideditor:/,
68674     /^imagery_used$/,
68675     /^host$/,
68676     /^locale$/,
68677     /^warnings:/,
68678     /^resolved:/,
68679     /^closed:note$/,
68680     /^closed:keepright$/,
68681     /^closed:improveosm:/,
68682     /^closed:osmose:/
68683   ];
68684   var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
68685   function uiCommit(context) {
68686     var dispatch14 = dispatch_default("cancel");
68687     var _userDetails2;
68688     var _selection;
68689     var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
68690     var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
68691     var commitChanges = uiSectionChanges(context);
68692     var commitWarnings = uiCommitWarnings(context);
68693     function commit(selection2) {
68694       _selection = selection2;
68695       if (!context.changeset)
68696         initChangeset();
68697       loadDerivedChangesetTags();
68698       selection2.call(render);
68699     }
68700     function initChangeset() {
68701       var commentDate = +corePreferences("commentDate") || 0;
68702       var currDate = Date.now();
68703       var cutoff = 2 * 86400 * 1e3;
68704       if (commentDate > currDate || currDate - commentDate > cutoff) {
68705         corePreferences("comment", null);
68706         corePreferences("hashtags", null);
68707         corePreferences("source", null);
68708       }
68709       if (context.defaultChangesetComment()) {
68710         corePreferences("comment", context.defaultChangesetComment());
68711         corePreferences("commentDate", Date.now());
68712       }
68713       if (context.defaultChangesetSource()) {
68714         corePreferences("source", context.defaultChangesetSource());
68715         corePreferences("commentDate", Date.now());
68716       }
68717       if (context.defaultChangesetHashtags()) {
68718         corePreferences("hashtags", context.defaultChangesetHashtags());
68719         corePreferences("commentDate", Date.now());
68720       }
68721       var detected = utilDetect();
68722       var tags = {
68723         comment: corePreferences("comment") || "",
68724         created_by: context.cleanTagValue("iD " + context.version),
68725         host: context.cleanTagValue(detected.host),
68726         locale: context.cleanTagValue(_mainLocalizer.localeCode())
68727       };
68728       findHashtags(tags, true);
68729       var hashtags = corePreferences("hashtags");
68730       if (hashtags) {
68731         tags.hashtags = hashtags;
68732       }
68733       var source = corePreferences("source");
68734       if (source) {
68735         tags.source = source;
68736       }
68737       var photoOverlaysUsed = context.history().photoOverlaysUsed();
68738       if (photoOverlaysUsed.length) {
68739         var sources = (tags.source || "").split(";");
68740         if (sources.indexOf("streetlevel imagery") === -1) {
68741           sources.push("streetlevel imagery");
68742         }
68743         photoOverlaysUsed.forEach(function(photoOverlay) {
68744           if (sources.indexOf(photoOverlay) === -1) {
68745             sources.push(photoOverlay);
68746           }
68747         });
68748         tags.source = context.cleanTagValue(sources.join(";"));
68749       }
68750       context.changeset = new osmChangeset({ tags });
68751     }
68752     function loadDerivedChangesetTags() {
68753       var osm = context.connection();
68754       if (!osm)
68755         return;
68756       var tags = Object.assign({}, context.changeset.tags);
68757       var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
68758       tags.imagery_used = imageryUsed || "None";
68759       var osmClosed = osm.getClosedIDs();
68760       var itemType;
68761       if (osmClosed.length) {
68762         tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
68763       }
68764       if (services.keepRight) {
68765         var krClosed = services.keepRight.getClosedIDs();
68766         if (krClosed.length) {
68767           tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
68768         }
68769       }
68770       if (services.improveOSM) {
68771         var iOsmClosed = services.improveOSM.getClosedCounts();
68772         for (itemType in iOsmClosed) {
68773           tags["closed:improveosm:" + itemType] = context.cleanTagValue(iOsmClosed[itemType].toString());
68774         }
68775       }
68776       if (services.osmose) {
68777         var osmoseClosed = services.osmose.getClosedCounts();
68778         for (itemType in osmoseClosed) {
68779           tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
68780         }
68781       }
68782       for (var key in tags) {
68783         if (key.match(/(^warnings:)|(^resolved:)/)) {
68784           delete tags[key];
68785         }
68786       }
68787       function addIssueCounts(issues, prefix) {
68788         var issuesByType = utilArrayGroupBy(issues, "type");
68789         for (var issueType in issuesByType) {
68790           var issuesOfType = issuesByType[issueType];
68791           if (issuesOfType[0].subtype) {
68792             var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
68793             for (var issueSubtype in issuesBySubtype) {
68794               var issuesOfSubtype = issuesBySubtype[issueSubtype];
68795               tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
68796             }
68797           } else {
68798             tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
68799           }
68800         }
68801       }
68802       var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
68803         return issue.type !== "help_request";
68804       });
68805       addIssueCounts(warnings, "warnings");
68806       var resolvedIssues = context.validator().getResolvedIssues();
68807       addIssueCounts(resolvedIssues, "resolved");
68808       context.changeset = context.changeset.update({ tags });
68809     }
68810     function render(selection2) {
68811       var osm = context.connection();
68812       if (!osm)
68813         return;
68814       var header = selection2.selectAll(".header").data([0]);
68815       var headerTitle = header.enter().append("div").attr("class", "header fillL");
68816       headerTitle.append("div").append("h2").call(_t.append("commit.title"));
68817       headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
68818         dispatch14.call("cancel", this);
68819       }).call(svgIcon("#iD-icon-close"));
68820       var body = selection2.selectAll(".body").data([0]);
68821       body = body.enter().append("div").attr("class", "body").merge(body);
68822       var changesetSection = body.selectAll(".changeset-editor").data([0]);
68823       changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
68824       changesetSection.call(
68825         changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
68826       );
68827       body.call(commitWarnings);
68828       var saveSection = body.selectAll(".save-section").data([0]);
68829       saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
68830       var prose = saveSection.selectAll(".commit-info").data([0]);
68831       if (prose.enter().size()) {
68832         _userDetails2 = null;
68833       }
68834       prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
68835       osm.userDetails(function(err, user) {
68836         if (err)
68837           return;
68838         if (_userDetails2 === user)
68839           return;
68840         _userDetails2 = user;
68841         var userLink = select_default2(document.createElement("div"));
68842         if (user.image_url) {
68843           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
68844         }
68845         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
68846         prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
68847       });
68848       var requestReview = saveSection.selectAll(".request-review").data([0]);
68849       var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
68850       var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
68851       var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
68852       if (!labelEnter.empty()) {
68853         labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
68854       }
68855       labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
68856       labelEnter.append("span").call(_t.append("commit.request_review"));
68857       requestReview = requestReview.merge(requestReviewEnter);
68858       var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
68859       var buttonSection = saveSection.selectAll(".buttons").data([0]);
68860       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
68861       buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
68862       var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
68863       uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
68864       var uploadBlockerTooltipText = getUploadBlockerMessage();
68865       buttonSection = buttonSection.merge(buttonEnter);
68866       buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
68867         dispatch14.call("cancel", this);
68868       });
68869       buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
68870         if (!select_default2(this).classed("disabled")) {
68871           this.blur();
68872           for (var key in context.changeset.tags) {
68873             if (!key)
68874               delete context.changeset.tags[key];
68875           }
68876           context.uploader().save(context.changeset);
68877         }
68878       });
68879       uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
68880       if (uploadBlockerTooltipText) {
68881         buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
68882       }
68883       var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
68884       tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
68885       tagSection.call(
68886         rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68887       );
68888       var changesSection = body.selectAll(".commit-changes-section").data([0]);
68889       changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
68890       changesSection.call(commitChanges.render);
68891       function toggleRequestReview() {
68892         var rr = requestReviewInput.property("checked");
68893         updateChangeset({ review_requested: rr ? "yes" : void 0 });
68894         tagSection.call(
68895           rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68896         );
68897       }
68898     }
68899     function getUploadBlockerMessage() {
68900       var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
68901       if (errors.length) {
68902         return _t.append("commit.outstanding_errors_message", { count: errors.length });
68903       } else {
68904         var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
68905         if (!hasChangesetComment) {
68906           return _t.append("commit.comment_needed_message");
68907         }
68908       }
68909       return null;
68910     }
68911     function changeTags(_2, changed, onInput) {
68912       if (changed.hasOwnProperty("comment")) {
68913         if (changed.comment === void 0) {
68914           changed.comment = "";
68915         }
68916         if (!onInput) {
68917           corePreferences("comment", changed.comment);
68918           corePreferences("commentDate", Date.now());
68919         }
68920       }
68921       if (changed.hasOwnProperty("source")) {
68922         if (changed.source === void 0) {
68923           corePreferences("source", null);
68924         } else if (!onInput) {
68925           corePreferences("source", changed.source);
68926           corePreferences("commentDate", Date.now());
68927         }
68928       }
68929       updateChangeset(changed, onInput);
68930       if (_selection) {
68931         _selection.call(render);
68932       }
68933     }
68934     function findHashtags(tags, commentOnly) {
68935       var detectedHashtags = commentHashtags();
68936       if (detectedHashtags.length) {
68937         corePreferences("hashtags", null);
68938       }
68939       if (!detectedHashtags.length || !commentOnly) {
68940         detectedHashtags = detectedHashtags.concat(hashtagHashtags());
68941       }
68942       var allLowerCase = /* @__PURE__ */ new Set();
68943       return detectedHashtags.filter(function(hashtag) {
68944         var lowerCase = hashtag.toLowerCase();
68945         if (!allLowerCase.has(lowerCase)) {
68946           allLowerCase.add(lowerCase);
68947           return true;
68948         }
68949         return false;
68950       });
68951       function commentHashtags() {
68952         var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
68953         return matches || [];
68954       }
68955       function hashtagHashtags() {
68956         var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
68957           if (s2[0] !== "#") {
68958             s2 = "#" + s2;
68959           }
68960           var matched = s2.match(hashtagRegex);
68961           return matched && matched[0];
68962         }).filter(Boolean);
68963         return matches || [];
68964       }
68965     }
68966     function isReviewRequested(tags) {
68967       var rr = tags.review_requested;
68968       if (rr === void 0)
68969         return false;
68970       rr = rr.trim().toLowerCase();
68971       return !(rr === "" || rr === "no");
68972     }
68973     function updateChangeset(changed, onInput) {
68974       var tags = Object.assign({}, context.changeset.tags);
68975       Object.keys(changed).forEach(function(k2) {
68976         var v2 = changed[k2];
68977         k2 = context.cleanTagKey(k2);
68978         if (readOnlyTags.indexOf(k2) !== -1)
68979           return;
68980         if (v2 === void 0) {
68981           delete tags[k2];
68982         } else if (onInput) {
68983           tags[k2] = v2;
68984         } else {
68985           tags[k2] = context.cleanTagValue(v2);
68986         }
68987       });
68988       if (!onInput) {
68989         var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
68990         var arr = findHashtags(tags, commentOnly);
68991         if (arr.length) {
68992           tags.hashtags = context.cleanTagValue(arr.join(";"));
68993           corePreferences("hashtags", tags.hashtags);
68994         } else {
68995           delete tags.hashtags;
68996           corePreferences("hashtags", null);
68997         }
68998       }
68999       if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
69000         var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
69001         tags.changesets_count = String(changesetsCount);
69002         if (changesetsCount <= 100) {
69003           var s2;
69004           s2 = corePreferences("walkthrough_completed");
69005           if (s2) {
69006             tags["ideditor:walkthrough_completed"] = s2;
69007           }
69008           s2 = corePreferences("walkthrough_progress");
69009           if (s2) {
69010             tags["ideditor:walkthrough_progress"] = s2;
69011           }
69012           s2 = corePreferences("walkthrough_started");
69013           if (s2) {
69014             tags["ideditor:walkthrough_started"] = s2;
69015           }
69016         }
69017       } else {
69018         delete tags.changesets_count;
69019       }
69020       if (!(0, import_fast_deep_equal9.default)(context.changeset.tags, tags)) {
69021         context.changeset = context.changeset.update({ tags });
69022       }
69023     }
69024     commit.reset = function() {
69025       context.changeset = null;
69026     };
69027     return utilRebind(commit, dispatch14, "on");
69028   }
69029
69030   // modules/ui/confirm.js
69031   function uiConfirm(selection2) {
69032     var modalSelection = uiModal(selection2);
69033     modalSelection.select(".modal").classed("modal-alert", true);
69034     var section = modalSelection.select(".content");
69035     section.append("div").attr("class", "modal-section header");
69036     section.append("div").attr("class", "modal-section message-text");
69037     var buttons = section.append("div").attr("class", "modal-section buttons cf");
69038     modalSelection.okButton = function() {
69039       buttons.append("button").attr("class", "button ok-button action").on("click.confirm", function() {
69040         modalSelection.remove();
69041       }).call(_t.append("confirm.okay")).node().focus();
69042       return modalSelection;
69043     };
69044     return modalSelection;
69045   }
69046
69047   // modules/ui/conflicts.js
69048   function uiConflicts(context) {
69049     var dispatch14 = dispatch_default("cancel", "save");
69050     var keybinding = utilKeybinding("conflicts");
69051     var _origChanges;
69052     var _conflictList;
69053     var _shownConflictIndex;
69054     function keybindingOn() {
69055       select_default2(document).call(keybinding.on("\u238B", cancel, true));
69056     }
69057     function keybindingOff() {
69058       select_default2(document).call(keybinding.unbind);
69059     }
69060     function tryAgain() {
69061       keybindingOff();
69062       dispatch14.call("save");
69063     }
69064     function cancel() {
69065       keybindingOff();
69066       dispatch14.call("cancel");
69067     }
69068     function conflicts(selection2) {
69069       keybindingOn();
69070       var headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
69071       headerEnter.append("button").attr("class", "fr").attr("title", _t("icons.close")).on("click", cancel).call(svgIcon("#iD-icon-close"));
69072       headerEnter.append("h2").call(_t.append("save.conflict.header"));
69073       var bodyEnter = selection2.selectAll(".body").data([0]).enter().append("div").attr("class", "body fillL");
69074       var conflictsHelpEnter = bodyEnter.append("div").attr("class", "conflicts-help").call(_t.append("save.conflict.help"));
69075       var changeset = new osmChangeset();
69076       delete changeset.id;
69077       var data = JXON.stringify(changeset.osmChangeJXON(_origChanges));
69078       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
69079       var fileName = "changes.osc";
69080       var linkEnter = conflictsHelpEnter.selectAll(".download-changes").append("a").attr("class", "download-changes");
69081       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
69082       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("save.conflict.download_changes"));
69083       bodyEnter.append("div").attr("class", "conflict-container fillL3").call(showConflict, 0);
69084       bodyEnter.append("div").attr("class", "conflicts-done").attr("opacity", 0).style("display", "none").call(_t.append("save.conflict.done"));
69085       var buttonsEnter = bodyEnter.append("div").attr("class", "buttons col12 joined conflicts-buttons");
69086       buttonsEnter.append("button").attr("disabled", _conflictList.length > 1).attr("class", "action conflicts-button col6").call(_t.append("save.title")).on("click.try_again", tryAgain);
69087       buttonsEnter.append("button").attr("class", "secondary-action conflicts-button col6").call(_t.append("confirm.cancel")).on("click.cancel", cancel);
69088     }
69089     function showConflict(selection2, index) {
69090       index = utilWrap(index, _conflictList.length);
69091       _shownConflictIndex = index;
69092       var parent = select_default2(selection2.node().parentNode);
69093       if (index === _conflictList.length - 1) {
69094         window.setTimeout(function() {
69095           parent.select(".conflicts-button").attr("disabled", null);
69096           parent.select(".conflicts-done").transition().attr("opacity", 1).style("display", "block");
69097         }, 250);
69098       }
69099       var conflict = selection2.selectAll(".conflict").data([_conflictList[index]]);
69100       conflict.exit().remove();
69101       var conflictEnter = conflict.enter().append("div").attr("class", "conflict");
69102       conflictEnter.append("h4").attr("class", "conflict-count").call(_t.append("save.conflict.count", { num: index + 1, total: _conflictList.length }));
69103       conflictEnter.append("a").attr("class", "conflict-description").attr("href", "#").text(function(d2) {
69104         return d2.name;
69105       }).on("click", function(d3_event, d2) {
69106         d3_event.preventDefault();
69107         zoomToEntity(d2.id);
69108       });
69109       var details = conflictEnter.append("div").attr("class", "conflict-detail-container");
69110       details.append("ul").attr("class", "conflict-detail-list").selectAll("li").data(function(d2) {
69111         return d2.details || [];
69112       }).enter().append("li").attr("class", "conflict-detail-item").html(function(d2) {
69113         return d2;
69114       });
69115       details.append("div").attr("class", "conflict-choices").call(addChoices);
69116       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) {
69117         return i3 === 0 && index === 0 || i3 === 1 && index === _conflictList.length - 1 || null;
69118       }).on("click", function(d3_event, d2) {
69119         d3_event.preventDefault();
69120         var container = parent.selectAll(".conflict-container");
69121         var sign2 = d2 === "previous" ? -1 : 1;
69122         container.selectAll(".conflict").remove();
69123         container.call(showConflict, index + sign2);
69124       }).each(function(d2) {
69125         _t.append("save.conflict." + d2)(select_default2(this));
69126       });
69127     }
69128     function addChoices(selection2) {
69129       var choices = selection2.append("ul").attr("class", "layer-list").selectAll("li").data(function(d2) {
69130         return d2.choices || [];
69131       });
69132       var choicesEnter = choices.enter().append("li").attr("class", "layer");
69133       var labelEnter = choicesEnter.append("label");
69134       labelEnter.append("input").attr("type", "radio").attr("name", function(d2) {
69135         return d2.id;
69136       }).on("change", function(d3_event, d2) {
69137         var ul = this.parentNode.parentNode.parentNode;
69138         ul.__data__.chosen = d2.id;
69139         choose(d3_event, ul, d2);
69140       });
69141       labelEnter.append("span").text(function(d2) {
69142         return d2.text;
69143       });
69144       choicesEnter.merge(choices).each(function(d2) {
69145         var ul = this.parentNode;
69146         if (ul.__data__.chosen === d2.id) {
69147           choose(null, ul, d2);
69148         }
69149       });
69150     }
69151     function choose(d3_event, ul, datum2) {
69152       if (d3_event)
69153         d3_event.preventDefault();
69154       select_default2(ul).selectAll("li").classed("active", function(d2) {
69155         return d2 === datum2;
69156       }).selectAll("input").property("checked", function(d2) {
69157         return d2 === datum2;
69158       });
69159       var extent = geoExtent();
69160       var entity;
69161       entity = context.graph().hasEntity(datum2.id);
69162       if (entity)
69163         extent._extend(entity.extent(context.graph()));
69164       datum2.action();
69165       entity = context.graph().hasEntity(datum2.id);
69166       if (entity)
69167         extent._extend(entity.extent(context.graph()));
69168       zoomToEntity(datum2.id, extent);
69169     }
69170     function zoomToEntity(id2, extent) {
69171       context.surface().selectAll(".hover").classed("hover", false);
69172       var entity = context.graph().hasEntity(id2);
69173       if (entity) {
69174         if (extent) {
69175           context.map().trimmedExtent(extent);
69176         } else {
69177           context.map().zoomToEase(entity);
69178         }
69179         context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
69180       }
69181     }
69182     conflicts.conflictList = function(_2) {
69183       if (!arguments.length)
69184         return _conflictList;
69185       _conflictList = _2;
69186       return conflicts;
69187     };
69188     conflicts.origChanges = function(_2) {
69189       if (!arguments.length)
69190         return _origChanges;
69191       _origChanges = _2;
69192       return conflicts;
69193     };
69194     conflicts.shownEntityIds = function() {
69195       if (_conflictList && typeof _shownConflictIndex === "number") {
69196         return [_conflictList[_shownConflictIndex].id];
69197       }
69198       return [];
69199     };
69200     return utilRebind(conflicts, dispatch14, "on");
69201   }
69202
69203   // modules/ui/entity_editor.js
69204   var import_fast_deep_equal10 = __toESM(require_fast_deep_equal());
69205
69206   // modules/ui/sections/entity_issues.js
69207   function uiSectionEntityIssues(context) {
69208     var preference = corePreferences("entity-issues.reference.expanded");
69209     var _expanded = preference === null ? true : preference === "true";
69210     var _entityIDs = [];
69211     var _issues = [];
69212     var _activeIssueID;
69213     var section = uiSection("entity-issues", context).shouldDisplay(function() {
69214       return _issues.length > 0;
69215     }).label(function() {
69216       return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length });
69217     }).disclosureContent(renderDisclosureContent);
69218     context.validator().on("validated.entity_issues", function() {
69219       reloadIssues();
69220       section.reRender();
69221     }).on("focusedIssue.entity_issues", function(issue) {
69222       makeActiveIssue(issue.id);
69223     });
69224     function reloadIssues() {
69225       _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true });
69226     }
69227     function makeActiveIssue(issueID) {
69228       _activeIssueID = issueID;
69229       section.selection().selectAll(".issue-container").classed("active", function(d2) {
69230         return d2.id === _activeIssueID;
69231       });
69232     }
69233     function renderDisclosureContent(selection2) {
69234       selection2.classed("grouped-items-area", true);
69235       _activeIssueID = _issues.length > 0 ? _issues[0].id : null;
69236       var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) {
69237         return d2.key;
69238       });
69239       containers.exit().remove();
69240       var containersEnter = containers.enter().append("div").attr("class", "issue-container");
69241       var itemsEnter = containersEnter.append("div").attr("class", function(d2) {
69242         return "issue severity-" + d2.severity;
69243       }).on("mouseover.highlight", function(d3_event, d2) {
69244         var ids = d2.entityIds.filter(function(e3) {
69245           return _entityIDs.indexOf(e3) === -1;
69246         });
69247         utilHighlightEntities(ids, true, context);
69248       }).on("mouseout.highlight", function(d3_event, d2) {
69249         var ids = d2.entityIds.filter(function(e3) {
69250           return _entityIDs.indexOf(e3) === -1;
69251         });
69252         utilHighlightEntities(ids, false, context);
69253       });
69254       var labelsEnter = itemsEnter.append("div").attr("class", "issue-label");
69255       var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) {
69256         makeActiveIssue(d2.id);
69257         var extent = d2.extent(context.graph());
69258         if (extent) {
69259           var setZoom = Math.max(context.map().zoom(), 19);
69260           context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
69261         }
69262       });
69263       textEnter.each(function(d2) {
69264         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
69265         select_default2(this).call(svgIcon(iconName, "issue-icon"));
69266       });
69267       textEnter.append("span").attr("class", "issue-message");
69268       var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect"));
69269       infoButton.on("click", function(d3_event) {
69270         d3_event.stopPropagation();
69271         d3_event.preventDefault();
69272         this.blur();
69273         var container = select_default2(this.parentNode.parentNode.parentNode);
69274         var info = container.selectAll(".issue-info");
69275         var isExpanded = info.classed("expanded");
69276         _expanded = !isExpanded;
69277         corePreferences("entity-issues.reference.expanded", _expanded);
69278         if (isExpanded) {
69279           info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
69280             info.classed("expanded", false);
69281           });
69282         } else {
69283           info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() {
69284             info.style("max-height", null);
69285           });
69286         }
69287       });
69288       itemsEnter.append("ul").attr("class", "issue-fix-list");
69289       containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) {
69290         if (typeof d2.reference === "function") {
69291           select_default2(this).call(d2.reference);
69292         } else {
69293           select_default2(this).call(_t.append("inspector.no_documentation_key"));
69294         }
69295       });
69296       containers = containers.merge(containersEnter).classed("active", function(d2) {
69297         return d2.id === _activeIssueID;
69298       });
69299       containers.selectAll(".issue-message").text("").each(function(d2) {
69300         return d2.message(context)(select_default2(this));
69301       });
69302       var fixLists = containers.selectAll(".issue-fix-list");
69303       var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) {
69304         return d2.fixes ? d2.fixes(context) : [];
69305       }, function(fix) {
69306         return fix.id;
69307       });
69308       fixes.exit().remove();
69309       var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item");
69310       var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) {
69311         if (select_default2(this).attr("disabled") || !d2.onClick)
69312           return;
69313         if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3)
69314           return;
69315         d2.issue.dateLastRanFix = /* @__PURE__ */ new Date();
69316         utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context);
69317         new Promise(function(resolve, reject) {
69318           d2.onClick(context, resolve, reject);
69319           if (d2.onClick.length <= 1) {
69320             resolve();
69321           }
69322         }).then(function() {
69323           context.validator().validate();
69324         });
69325       }).on("mouseover.highlight", function(d3_event, d2) {
69326         utilHighlightEntities(d2.entityIds, true, context);
69327       }).on("mouseout.highlight", function(d3_event, d2) {
69328         utilHighlightEntities(d2.entityIds, false, context);
69329       });
69330       buttons.each(function(d2) {
69331         var iconName = d2.icon || "iD-icon-wrench";
69332         if (iconName.startsWith("maki")) {
69333           iconName += "-15";
69334         }
69335         select_default2(this).call(svgIcon("#" + iconName, "fix-icon"));
69336       });
69337       buttons.append("span").attr("class", "fix-message").each(function(d2) {
69338         return d2.title(select_default2(this));
69339       });
69340       fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) {
69341         return d2.onClick;
69342       }).attr("disabled", function(d2) {
69343         return d2.onClick ? null : "true";
69344       }).attr("title", function(d2) {
69345         if (d2.disabledReason) {
69346           return d2.disabledReason;
69347         }
69348         return null;
69349       });
69350     }
69351     section.entityIDs = function(val) {
69352       if (!arguments.length)
69353         return _entityIDs;
69354       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
69355         _entityIDs = val;
69356         _activeIssueID = null;
69357         reloadIssues();
69358       }
69359       return section;
69360     };
69361     return section;
69362   }
69363
69364   // modules/ui/preset_icon.js
69365   function uiPresetIcon() {
69366     let _preset;
69367     let _geometry;
69368     function presetIcon(selection2) {
69369       selection2.each(render);
69370     }
69371     function getIcon(p2, geom) {
69372       if (p2.isFallback && p2.isFallback())
69373         return geom === "vertex" ? "" : "iD-icon-" + p2.id;
69374       if (p2.icon)
69375         return p2.icon;
69376       if (geom === "line")
69377         return "iD-other-line";
69378       if (geom === "vertex")
69379         return "temaki-vertex";
69380       return "maki-marker-stroked";
69381     }
69382     function renderPointBorder(container, drawPoint) {
69383       let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []);
69384       pointBorder.exit().remove();
69385       let pointBorderEnter = pointBorder.enter();
69386       const w2 = 40;
69387       const h2 = 40;
69388       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");
69389       pointBorder = pointBorderEnter.merge(pointBorder);
69390     }
69391     function renderCategoryBorder(container, category) {
69392       let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []);
69393       categoryBorder.exit().remove();
69394       let categoryBorderEnter = categoryBorder.enter();
69395       const d2 = 60;
69396       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));
69397       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");
69398       categoryBorder = categoryBorderEnter.merge(categoryBorder);
69399       if (category) {
69400         categoryBorder.selectAll("path").attr("class", "area ".concat(category.id));
69401       }
69402     }
69403     function renderCircleFill(container, drawVertex) {
69404       let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []);
69405       vertexFill.exit().remove();
69406       let vertexFillEnter = vertexFill.enter();
69407       const w2 = 60;
69408       const h2 = 60;
69409       const d2 = 40;
69410       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);
69411       vertexFill = vertexFillEnter.merge(vertexFill);
69412     }
69413     function renderSquareFill(container, drawArea, tagClasses) {
69414       let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []);
69415       fill.exit().remove();
69416       let fillEnter = fill.enter();
69417       const d2 = 60;
69418       const w2 = d2;
69419       const h2 = d2;
69420       const l2 = d2 * 2 / 3;
69421       const c1 = (w2 - l2) / 2;
69422       const c2 = c1 + l2;
69423       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));
69424       ["fill", "stroke"].forEach((klass) => {
69425         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));
69426       });
69427       const rVertex = 2.5;
69428       [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point2) => {
69429         fillEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rVertex);
69430       });
69431       const rMidpoint = 1.25;
69432       [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point2) => {
69433         fillEnter.append("circle").attr("class", "midpoint").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rMidpoint);
69434       });
69435       fill = fillEnter.merge(fill);
69436       fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses));
69437       fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses));
69438     }
69439     function renderLine(container, drawLine, tagClasses) {
69440       let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []);
69441       line.exit().remove();
69442       let lineEnter = line.enter();
69443       const d2 = 60;
69444       const w2 = d2;
69445       const h2 = d2;
69446       const y2 = Math.round(d2 * 0.72);
69447       const l2 = Math.round(d2 * 0.6);
69448       const r2 = 2.5;
69449       const x12 = (w2 - l2) / 2;
69450       const x2 = x12 + l2;
69451       lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69452       ["casing", "stroke"].forEach((klass) => {
69453         lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass));
69454       });
69455       [[x12 - 1, y2], [x2 + 1, y2]].forEach((point2) => {
69456         lineEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69457       });
69458       line = lineEnter.merge(line);
69459       line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses));
69460       line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses));
69461     }
69462     function renderRoute(container, drawRoute, p2) {
69463       let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []);
69464       route.exit().remove();
69465       let routeEnter = route.enter();
69466       const d2 = 60;
69467       const w2 = d2;
69468       const h2 = d2;
69469       const y12 = Math.round(d2 * 0.8);
69470       const y2 = Math.round(d2 * 0.68);
69471       const l2 = Math.round(d2 * 0.6);
69472       const r2 = 2;
69473       const x12 = (w2 - l2) / 2;
69474       const x2 = x12 + l2 / 3;
69475       const x3 = x2 + l2 / 3;
69476       const x4 = x3 + l2 / 3;
69477       routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69478       ["casing", "stroke"].forEach((klass) => {
69479         routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass));
69480         routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass));
69481         routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass));
69482       });
69483       [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point2) => {
69484         routeEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69485       });
69486       route = routeEnter.merge(route);
69487       if (drawRoute) {
69488         let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route;
69489         const segmentPresetIDs = routeSegments[routeType];
69490         for (let i3 in segmentPresetIDs) {
69491           const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]);
69492           const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, "");
69493           route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses));
69494           route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses));
69495         }
69496       }
69497     }
69498     function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) {
69499       const isMaki = picon && /^maki-/.test(picon);
69500       const isTemaki = picon && /^temaki-/.test(picon);
69501       const isFa = picon && /^fa[srb]-/.test(picon);
69502       const isR\u00F6ntgen = picon && /^roentgen-/.test(picon);
69503       const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen);
69504       let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []);
69505       icon2.exit().remove();
69506       icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2);
69507       icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon);
69508       icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses));
69509       icon2.selectAll("use").attr("href", "#" + picon);
69510     }
69511     function renderImageIcon(container, imageURL) {
69512       let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []);
69513       imageIcon.exit().remove();
69514       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);
69515       imageIcon.attr("src", imageURL);
69516     }
69517     const routeSegments = {
69518       bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"],
69519       bus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69520       trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69521       detour: ["highway/tertiary", "highway/residential", "highway/unclassified"],
69522       ferry: ["route/ferry", "route/ferry", "route/ferry"],
69523       foot: ["highway/footway", "highway/footway", "highway/footway"],
69524       hiking: ["highway/path", "highway/path", "highway/path"],
69525       horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"],
69526       light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"],
69527       monorail: ["railway/monorail", "railway/monorail", "railway/monorail"],
69528       mtb: ["highway/path", "highway/track", "highway/bridleway"],
69529       pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"],
69530       piste: ["piste/downhill", "piste/hike", "piste/nordic"],
69531       power: ["power/line", "power/line", "power/line"],
69532       road: ["highway/secondary", "highway/primary", "highway/trunk"],
69533       subway: ["railway/subway", "railway/subway", "railway/subway"],
69534       train: ["railway/rail", "railway/rail", "railway/rail"],
69535       tram: ["railway/tram", "railway/tram", "railway/tram"],
69536       railway: ["railway/rail", "railway/rail", "railway/rail"],
69537       waterway: ["waterway/stream", "waterway/stream", "waterway/stream"]
69538     };
69539     function render() {
69540       let p2 = _preset.apply(this, arguments);
69541       let geom = _geometry ? _geometry.apply(this, arguments) : null;
69542       if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) {
69543         geom = "route";
69544       }
69545       const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
69546       const isFallback = p2.isFallback && p2.isFallback();
69547       const imageURL = showThirdPartyIcons === "true" && p2.imageURL;
69548       const picon = getIcon(p2, geom);
69549       const isCategory = !p2.setTags;
69550       const drawPoint = false;
69551       const drawVertex = picon !== null && geom === "vertex";
69552       const drawLine = picon && geom === "line" && !isFallback && !isCategory;
69553       const drawArea = picon && geom === "area" && !isFallback && !isCategory;
69554       const drawRoute = picon && geom === "route";
69555       const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory;
69556       let tags = !isCategory ? p2.setTags({}, geom) : {};
69557       for (let k2 in tags) {
69558         if (tags[k2] === "*") {
69559           tags[k2] = "yes";
69560         }
69561       }
69562       let tagClasses = svgTagClasses().getClassesString(tags, "");
69563       let selection2 = select_default2(this);
69564       let container = selection2.selectAll(".preset-icon-container").data([0]);
69565       container = container.enter().append("div").attr("class", "preset-icon-container").merge(container);
69566       container.classed("showing-img", !!imageURL).classed("fallback", isFallback);
69567       renderCategoryBorder(container, isCategory && p2);
69568       renderPointBorder(container, drawPoint);
69569       renderCircleFill(container, drawVertex);
69570       renderSquareFill(container, drawArea, tagClasses);
69571       renderLine(container, drawLine, tagClasses);
69572       renderRoute(container, drawRoute, p2);
69573       renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses);
69574       renderImageIcon(container, imageURL);
69575     }
69576     presetIcon.preset = function(val) {
69577       if (!arguments.length)
69578         return _preset;
69579       _preset = utilFunctor(val);
69580       return presetIcon;
69581     };
69582     presetIcon.geometry = function(val) {
69583       if (!arguments.length)
69584         return _geometry;
69585       _geometry = utilFunctor(val);
69586       return presetIcon;
69587     };
69588     return presetIcon;
69589   }
69590
69591   // modules/ui/sections/feature_type.js
69592   function uiSectionFeatureType(context) {
69593     var dispatch14 = dispatch_default("choose");
69594     var _entityIDs = [];
69595     var _presets = [];
69596     var _tagReference;
69597     var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent);
69598     function renderDisclosureContent(selection2) {
69599       selection2.classed("preset-list-item", true);
69600       selection2.classed("mixed-types", _presets.length > 1);
69601       var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap");
69602       var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call(
69603         uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom")
69604       );
69605       presetButton.append("div").attr("class", "preset-icon-container");
69606       presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner");
69607       presetButtonWrap.append("div").attr("class", "accessory-buttons");
69608       var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]);
69609       tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap);
69610       if (_tagReference) {
69611         selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button);
69612         tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body);
69613       }
69614       selection2.selectAll(".preset-reset").on("click", function() {
69615         dispatch14.call("choose", this, _presets);
69616       }).on("pointerdown pointerup mousedown mouseup", function(d3_event) {
69617         d3_event.preventDefault();
69618         d3_event.stopPropagation();
69619       });
69620       var geometries = entityGeometries();
69621       selection2.select(".preset-list-item button").call(
69622         uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point"))
69623       );
69624       var names = _presets.length === 1 ? [
69625         _presets[0].nameLabel(),
69626         _presets[0].subtitleLabel()
69627       ].filter(Boolean) : [_t.append("inspector.multiple_types")];
69628       var label = selection2.select(".label-inner");
69629       var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId);
69630       nameparts.exit().remove();
69631       nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) {
69632         d2(select_default2(this));
69633       });
69634     }
69635     section.entityIDs = function(val) {
69636       if (!arguments.length)
69637         return _entityIDs;
69638       _entityIDs = val;
69639       return section;
69640     };
69641     section.presets = function(val) {
69642       if (!arguments.length)
69643         return _presets;
69644       if (!utilArrayIdentical(val, _presets)) {
69645         _presets = val;
69646         if (_presets.length === 1) {
69647           _tagReference = uiTagReference(_presets[0].reference(), context).showing(false);
69648         }
69649       }
69650       return section;
69651     };
69652     function entityGeometries() {
69653       var counts = {};
69654       for (var i3 in _entityIDs) {
69655         var geometry = context.graph().geometry(_entityIDs[i3]);
69656         if (!counts[geometry])
69657           counts[geometry] = 0;
69658         counts[geometry] += 1;
69659       }
69660       return Object.keys(counts).sort(function(geom1, geom2) {
69661         return counts[geom2] - counts[geom1];
69662       });
69663     }
69664     return utilRebind(section, dispatch14, "on");
69665   }
69666
69667   // modules/ui/sections/preset_fields.js
69668   function uiSectionPresetFields(context) {
69669     var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
69670     var dispatch14 = dispatch_default("change", "revert");
69671     var formFields = uiFormFields(context);
69672     var _state;
69673     var _fieldsArr;
69674     var _presets = [];
69675     var _tags;
69676     var _entityIDs;
69677     function renderDisclosureContent(selection2) {
69678       if (!_fieldsArr) {
69679         var graph = context.graph();
69680         var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
69681           geoms[graph.entity(entityID).geometry(graph)] = true;
69682           return geoms;
69683         }, {}));
69684         const loc = _entityIDs.reduce(function(extent, entityID) {
69685           var entity = context.graph().entity(entityID);
69686           return extent.extend(entity.extent(context.graph()));
69687         }, geoExtent()).center();
69688         var presetsManager = _mainPresetIndex;
69689         var allFields = [];
69690         var allMoreFields = [];
69691         var sharedTotalFields;
69692         _presets.forEach(function(preset) {
69693           var fields = preset.fields(loc);
69694           var moreFields = preset.moreFields(loc);
69695           allFields = utilArrayUnion(allFields, fields);
69696           allMoreFields = utilArrayUnion(allMoreFields, moreFields);
69697           if (!sharedTotalFields) {
69698             sharedTotalFields = utilArrayUnion(fields, moreFields);
69699           } else {
69700             sharedTotalFields = sharedTotalFields.filter(function(field) {
69701               return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
69702             });
69703           }
69704         });
69705         var sharedFields = allFields.filter(function(field) {
69706           return sharedTotalFields.indexOf(field) !== -1;
69707         });
69708         var sharedMoreFields = allMoreFields.filter(function(field) {
69709           return sharedTotalFields.indexOf(field) !== -1;
69710         });
69711         _fieldsArr = [];
69712         sharedFields.forEach(function(field) {
69713           if (field.matchAllGeometry(geometries)) {
69714             _fieldsArr.push(
69715               uiField(context, field, _entityIDs)
69716             );
69717           }
69718         });
69719         var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
69720         if (singularEntity && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
69721           _fieldsArr.push(
69722             uiField(context, presetsManager.field("restrictions"), _entityIDs)
69723           );
69724         }
69725         var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
69726         additionalFields.sort(function(field1, field2) {
69727           return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
69728         });
69729         additionalFields.forEach(function(field) {
69730           if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
69731             _fieldsArr.push(
69732               uiField(context, field, _entityIDs, { show: false })
69733             );
69734           }
69735         });
69736         _fieldsArr.forEach(function(field) {
69737           field.on("change", function(t2, onInput) {
69738             dispatch14.call("change", field, _entityIDs, t2, onInput);
69739           }).on("revert", function(keys2) {
69740             dispatch14.call("revert", field, keys2);
69741           });
69742         });
69743       }
69744       _fieldsArr.forEach(function(field) {
69745         field.state(_state).tags(_tags);
69746       });
69747       selection2.call(
69748         formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
69749       );
69750     }
69751     section.presets = function(val) {
69752       if (!arguments.length)
69753         return _presets;
69754       if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
69755         _presets = val;
69756         _fieldsArr = null;
69757       }
69758       return section;
69759     };
69760     section.state = function(val) {
69761       if (!arguments.length)
69762         return _state;
69763       _state = val;
69764       return section;
69765     };
69766     section.tags = function(val) {
69767       if (!arguments.length)
69768         return _tags;
69769       _tags = val;
69770       return section;
69771     };
69772     section.entityIDs = function(val) {
69773       if (!arguments.length)
69774         return _entityIDs;
69775       if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
69776         _entityIDs = val;
69777         _fieldsArr = null;
69778       }
69779       return section;
69780     };
69781     return utilRebind(section, dispatch14, "on");
69782   }
69783
69784   // modules/ui/sections/raw_member_editor.js
69785   function uiSectionRawMemberEditor(context) {
69786     var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
69787       if (!_entityIDs || _entityIDs.length !== 1)
69788         return false;
69789       var entity = context.hasEntity(_entityIDs[0]);
69790       return entity && entity.type === "relation";
69791     }).label(function() {
69792       var entity = context.hasEntity(_entityIDs[0]);
69793       if (!entity)
69794         return "";
69795       var gt2 = entity.members.length > _maxMembers ? ">" : "";
69796       var count = gt2 + entity.members.slice(0, _maxMembers).length;
69797       return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
69798     }).disclosureContent(renderDisclosureContent);
69799     var taginfo = services.taginfo;
69800     var _entityIDs;
69801     var _maxMembers = 1e3;
69802     function downloadMember(d3_event, d2) {
69803       d3_event.preventDefault();
69804       select_default2(this).classed("loading", true);
69805       context.loadEntity(d2.id, function() {
69806         section.reRender();
69807       });
69808     }
69809     function zoomToMember(d3_event, d2) {
69810       d3_event.preventDefault();
69811       var entity = context.entity(d2.id);
69812       context.map().zoomToEase(entity);
69813       utilHighlightEntities([d2.id], true, context);
69814     }
69815     function selectMember(d3_event, d2) {
69816       d3_event.preventDefault();
69817       utilHighlightEntities([d2.id], false, context);
69818       var entity = context.entity(d2.id);
69819       var mapExtent = context.map().extent();
69820       if (!entity.intersects(mapExtent, context.graph())) {
69821         context.map().zoomToEase(entity);
69822       }
69823       context.enter(modeSelect(context, [d2.id]));
69824     }
69825     function changeRole(d3_event, d2) {
69826       var oldRole = d2.role;
69827       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
69828       if (oldRole !== newRole) {
69829         var member = { id: d2.id, type: d2.type, role: newRole };
69830         context.perform(
69831           actionChangeMember(d2.relation.id, member, d2.index),
69832           _t("operations.change_role.annotation", {
69833             n: 1
69834           })
69835         );
69836         context.validator().validate();
69837       }
69838     }
69839     function deleteMember(d3_event, d2) {
69840       utilHighlightEntities([d2.id], false, context);
69841       context.perform(
69842         actionDeleteMember(d2.relation.id, d2.index),
69843         _t("operations.delete_member.annotation", {
69844           n: 1
69845         })
69846       );
69847       if (!context.hasEntity(d2.relation.id)) {
69848         context.enter(modeBrowse(context));
69849       } else {
69850         context.validator().validate();
69851       }
69852     }
69853     function renderDisclosureContent(selection2) {
69854       var entityID = _entityIDs[0];
69855       var memberships = [];
69856       var entity = context.entity(entityID);
69857       entity.members.slice(0, _maxMembers).forEach(function(member, index) {
69858         memberships.push({
69859           index,
69860           id: member.id,
69861           type: member.type,
69862           role: member.role,
69863           relation: entity,
69864           member: context.hasEntity(member.id),
69865           domId: utilUniqueDomId(entityID + "-member-" + index)
69866         });
69867       });
69868       var list2 = selection2.selectAll(".member-list").data([0]);
69869       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
69870       var items = list2.selectAll("li").data(memberships, function(d2) {
69871         return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
69872       });
69873       items.exit().each(unbind).remove();
69874       var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
69875         return !d2.member;
69876       });
69877       itemsEnter.each(function(d2) {
69878         var item = select_default2(this);
69879         var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
69880         if (d2.member) {
69881           item.on("mouseover", function() {
69882             utilHighlightEntities([d2.id], true, context);
69883           }).on("mouseout", function() {
69884             utilHighlightEntities([d2.id], false, context);
69885           });
69886           var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
69887           labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
69888             var matched = _mainPresetIndex.match(d4.member, context.graph());
69889             return matched && matched.name() || utilDisplayType(d4.member.id);
69890           });
69891           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) {
69892             return utilDisplayName(d4.member);
69893           });
69894           label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
69895           label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
69896         } else {
69897           var labelText = label.append("span").attr("class", "label-text");
69898           labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
69899           labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
69900           label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
69901         }
69902       });
69903       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
69904       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
69905         return d2.domId;
69906       }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
69907       if (taginfo) {
69908         wrapEnter.each(bindTypeahead);
69909       }
69910       items = items.merge(itemsEnter).order();
69911       items.select("input.member-role").property("value", function(d2) {
69912         return d2.role;
69913       }).on("blur", changeRole).on("change", changeRole);
69914       items.select("button.member-delete").on("click", deleteMember);
69915       var dragOrigin, targetIndex;
69916       items.call(
69917         drag_default().on("start", function(d3_event) {
69918           dragOrigin = {
69919             x: d3_event.x,
69920             y: d3_event.y
69921           };
69922           targetIndex = null;
69923         }).on("drag", function(d3_event) {
69924           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
69925           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
69926           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
69927             return;
69928           var index = items.nodes().indexOf(this);
69929           select_default2(this).classed("dragging", true);
69930           targetIndex = null;
69931           selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
69932             var node = select_default2(this).node();
69933             if (index === index2) {
69934               return "translate(" + x2 + "px, " + y2 + "px)";
69935             } else if (index2 > index && d3_event.y > node.offsetTop) {
69936               if (targetIndex === null || index2 > targetIndex) {
69937                 targetIndex = index2;
69938               }
69939               return "translateY(-100%)";
69940             } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
69941               if (targetIndex === null || index2 < targetIndex) {
69942                 targetIndex = index2;
69943               }
69944               return "translateY(100%)";
69945             }
69946             return null;
69947           });
69948         }).on("end", function(d3_event, d2) {
69949           if (!select_default2(this).classed("dragging"))
69950             return;
69951           var index = items.nodes().indexOf(this);
69952           select_default2(this).classed("dragging", false);
69953           selection2.selectAll("li.member-row").style("transform", null);
69954           if (targetIndex !== null) {
69955             context.perform(
69956               actionMoveMember(d2.relation.id, index, targetIndex),
69957               _t("operations.reorder_members.annotation")
69958             );
69959             context.validator().validate();
69960           }
69961         })
69962       );
69963       function bindTypeahead(d2) {
69964         var row = select_default2(this);
69965         var role = row.selectAll("input.member-role");
69966         var origValue = role.property("value");
69967         function sort(value, data) {
69968           var sameletter = [];
69969           var other = [];
69970           for (var i3 = 0; i3 < data.length; i3++) {
69971             if (data[i3].value.substring(0, value.length) === value) {
69972               sameletter.push(data[i3]);
69973             } else {
69974               other.push(data[i3]);
69975             }
69976           }
69977           return sameletter.concat(other);
69978         }
69979         role.call(
69980           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
69981             var geometry;
69982             if (d2.member) {
69983               geometry = context.graph().geometry(d2.member.id);
69984             } else if (d2.type === "relation") {
69985               geometry = "relation";
69986             } else if (d2.type === "way") {
69987               geometry = "line";
69988             } else {
69989               geometry = "point";
69990             }
69991             var rtype = entity.tags.type;
69992             taginfo.roles({
69993               debounce: true,
69994               rtype: rtype || "",
69995               geometry,
69996               query: role2
69997             }, function(err, data) {
69998               if (!err)
69999                 callback(sort(role2, data));
70000             });
70001           }).on("cancel", function() {
70002             role.property("value", origValue);
70003           })
70004         );
70005       }
70006       function unbind() {
70007         var row = select_default2(this);
70008         row.selectAll("input.member-role").call(uiCombobox.off, context);
70009       }
70010     }
70011     section.entityIDs = function(val) {
70012       if (!arguments.length)
70013         return _entityIDs;
70014       _entityIDs = val;
70015       return section;
70016     };
70017     return section;
70018   }
70019
70020   // modules/actions/delete_members.js
70021   function actionDeleteMembers(relationId, memberIndexes) {
70022     return function(graph) {
70023       memberIndexes.sort((a2, b2) => b2 - a2);
70024       for (var i3 in memberIndexes) {
70025         graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
70026       }
70027       return graph;
70028     };
70029   }
70030
70031   // modules/ui/sections/raw_membership_editor.js
70032   function uiSectionRawMembershipEditor(context) {
70033     var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
70034       return _entityIDs && _entityIDs.length;
70035     }).label(function() {
70036       var parents = getSharedParentRelations();
70037       var gt2 = parents.length > _maxMemberships ? ">" : "";
70038       var count = gt2 + parents.slice(0, _maxMemberships).length;
70039       return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
70040     }).disclosureContent(renderDisclosureContent);
70041     var taginfo = services.taginfo;
70042     var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
70043       if (d2.relation)
70044         utilHighlightEntities([d2.relation.id], true, context);
70045     }).itemsMouseLeave(function(d3_event, d2) {
70046       if (d2.relation)
70047         utilHighlightEntities([d2.relation.id], false, context);
70048     });
70049     var _inChange = false;
70050     var _entityIDs = [];
70051     var _showBlank;
70052     var _maxMemberships = 1e3;
70053     function getSharedParentRelations() {
70054       var parents = [];
70055       for (var i3 = 0; i3 < _entityIDs.length; i3++) {
70056         var entity = context.graph().hasEntity(_entityIDs[i3]);
70057         if (!entity)
70058           continue;
70059         if (i3 === 0) {
70060           parents = context.graph().parentRelations(entity);
70061         } else {
70062           parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
70063         }
70064         if (!parents.length)
70065           break;
70066       }
70067       return parents;
70068     }
70069     function getMemberships() {
70070       var memberships = [];
70071       var relations = getSharedParentRelations().slice(0, _maxMemberships);
70072       var isMultiselect = _entityIDs.length > 1;
70073       var i3, relation, membership, index, member, indexedMember;
70074       for (i3 = 0; i3 < relations.length; i3++) {
70075         relation = relations[i3];
70076         membership = {
70077           relation,
70078           members: [],
70079           hash: osmEntity.key(relation)
70080         };
70081         for (index = 0; index < relation.members.length; index++) {
70082           member = relation.members[index];
70083           if (_entityIDs.indexOf(member.id) !== -1) {
70084             indexedMember = Object.assign({}, member, { index });
70085             membership.members.push(indexedMember);
70086             membership.hash += "," + index.toString();
70087             if (!isMultiselect) {
70088               memberships.push(membership);
70089               membership = {
70090                 relation,
70091                 members: [],
70092                 hash: osmEntity.key(relation)
70093               };
70094             }
70095           }
70096         }
70097         if (membership.members.length)
70098           memberships.push(membership);
70099       }
70100       memberships.forEach(function(membership2) {
70101         membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
70102         var roles = [];
70103         membership2.members.forEach(function(member2) {
70104           if (roles.indexOf(member2.role) === -1)
70105             roles.push(member2.role);
70106         });
70107         membership2.role = roles.length === 1 ? roles[0] : roles;
70108       });
70109       return memberships;
70110     }
70111     function selectRelation(d3_event, d2) {
70112       d3_event.preventDefault();
70113       utilHighlightEntities([d2.relation.id], false, context);
70114       context.enter(modeSelect(context, [d2.relation.id]));
70115     }
70116     function zoomToRelation(d3_event, d2) {
70117       d3_event.preventDefault();
70118       var entity = context.entity(d2.relation.id);
70119       context.map().zoomToEase(entity);
70120       utilHighlightEntities([d2.relation.id], true, context);
70121     }
70122     function changeRole(d3_event, d2) {
70123       if (d2 === 0)
70124         return;
70125       if (_inChange)
70126         return;
70127       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
70128       if (!newRole.trim() && typeof d2.role !== "string")
70129         return;
70130       var membersToUpdate = d2.members.filter(function(member) {
70131         return member.role !== newRole;
70132       });
70133       if (membersToUpdate.length) {
70134         _inChange = true;
70135         context.perform(
70136           function actionChangeMemberRoles(graph) {
70137             membersToUpdate.forEach(function(member) {
70138               var newMember = Object.assign({}, member, { role: newRole });
70139               delete newMember.index;
70140               graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
70141             });
70142             return graph;
70143           },
70144           _t("operations.change_role.annotation", {
70145             n: membersToUpdate.length
70146           })
70147         );
70148         context.validator().validate();
70149       }
70150       _inChange = false;
70151     }
70152     function addMembership(d2, role) {
70153       this.blur();
70154       _showBlank = false;
70155       function actionAddMembers(relationId, ids, role2) {
70156         return function(graph) {
70157           for (var i3 in ids) {
70158             var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
70159             graph = actionAddMember(relationId, member)(graph);
70160           }
70161           return graph;
70162         };
70163       }
70164       if (d2.relation) {
70165         context.perform(
70166           actionAddMembers(d2.relation.id, _entityIDs, role),
70167           _t("operations.add_member.annotation", {
70168             n: _entityIDs.length
70169           })
70170         );
70171         context.validator().validate();
70172       } else {
70173         var relation = osmRelation();
70174         context.perform(
70175           actionAddEntity(relation),
70176           actionAddMembers(relation.id, _entityIDs, role),
70177           _t("operations.add.annotation.relation")
70178         );
70179         context.enter(modeSelect(context, [relation.id]).newFeature(true));
70180       }
70181     }
70182     function downloadMembers(d3_event, d2) {
70183       d3_event.preventDefault();
70184       const button = select_default2(this);
70185       button.classed("loading", true);
70186       context.loadEntity(d2.relation.id, function() {
70187         section.reRender();
70188       });
70189     }
70190     function deleteMembership(d3_event, d2) {
70191       this.blur();
70192       if (d2 === 0)
70193         return;
70194       utilHighlightEntities([d2.relation.id], false, context);
70195       var indexes = d2.members.map(function(member) {
70196         return member.index;
70197       });
70198       context.perform(
70199         actionDeleteMembers(d2.relation.id, indexes),
70200         _t("operations.delete_member.annotation", {
70201           n: _entityIDs.length
70202         })
70203       );
70204       context.validator().validate();
70205     }
70206     function fetchNearbyRelations(q2, callback) {
70207       var newRelation = {
70208         relation: null,
70209         value: _t("inspector.new_relation"),
70210         display: _t.append("inspector.new_relation")
70211       };
70212       var entityID = _entityIDs[0];
70213       var result = [];
70214       var graph = context.graph();
70215       function baseDisplayValue(entity) {
70216         var matched = _mainPresetIndex.match(entity, graph);
70217         var presetName = matched && matched.name() || _t("inspector.relation");
70218         var entityName = utilDisplayName(entity) || "";
70219         return presetName + " " + entityName;
70220       }
70221       function baseDisplayLabel(entity) {
70222         var matched = _mainPresetIndex.match(entity, graph);
70223         var presetName = matched && matched.name() || _t("inspector.relation");
70224         var entityName = utilDisplayName(entity) || "";
70225         return (selection2) => {
70226           selection2.append("b").text(presetName + " ");
70227           selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
70228         };
70229       }
70230       var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
70231       if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
70232         result.push({
70233           relation: explicitRelation,
70234           value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
70235           display: baseDisplayLabel(explicitRelation)
70236         });
70237       } else {
70238         context.history().intersects(context.map().extent()).forEach(function(entity) {
70239           if (entity.type !== "relation" || entity.id === entityID)
70240             return;
70241           var value = baseDisplayValue(entity);
70242           if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1)
70243             return;
70244           result.push({
70245             relation: entity,
70246             value,
70247             display: baseDisplayLabel(entity)
70248           });
70249         });
70250         result.sort(function(a2, b2) {
70251           return osmRelation.creationOrder(a2.relation, b2.relation);
70252         });
70253         var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
70254           return v2.length > 1;
70255         });
70256         dupeGroups.forEach(function(group) {
70257           group.forEach(function(obj) {
70258             obj.value += " " + obj.relation.id;
70259           });
70260         });
70261       }
70262       result.forEach(function(obj) {
70263         obj.title = obj.value;
70264       });
70265       result.unshift(newRelation);
70266       callback(result);
70267     }
70268     function renderDisclosureContent(selection2) {
70269       var memberships = getMemberships();
70270       var list2 = selection2.selectAll(".member-list").data([0]);
70271       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
70272       var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
70273         return d2.hash;
70274       });
70275       items.exit().each(unbind).remove();
70276       var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
70277       itemsEnter.on("mouseover", function(d3_event, d2) {
70278         utilHighlightEntities([d2.relation.id], true, context);
70279       }).on("mouseout", function(d3_event, d2) {
70280         utilHighlightEntities([d2.relation.id], false, context);
70281       });
70282       var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
70283         return d2.domId;
70284       });
70285       var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
70286       labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
70287         var matched = _mainPresetIndex.match(d2.relation, context.graph());
70288         return matched && matched.name() || _t.html("inspector.relation");
70289       });
70290       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) {
70291         return utilDisplayName(d2.relation);
70292       });
70293       labelEnter.append("button").attr("class", "members-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMembers);
70294       labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
70295       labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
70296       items = items.merge(itemsEnter);
70297       items.selectAll("button.members-download").classed("hide", (d2) => {
70298         const graph = context.graph();
70299         return d2.relation.members.every((m2) => graph.hasEntity(m2.id));
70300       });
70301       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70302       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
70303         return d2.domId;
70304       }).property("type", "text").property("value", function(d2) {
70305         return typeof d2.role === "string" ? d2.role : "";
70306       }).attr("title", function(d2) {
70307         return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
70308       }).attr("placeholder", function(d2) {
70309         return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
70310       }).classed("mixed", function(d2) {
70311         return Array.isArray(d2.role);
70312       }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
70313       if (taginfo) {
70314         wrapEnter.each(bindTypeahead);
70315       }
70316       var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
70317       newMembership.exit().remove();
70318       var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
70319       var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
70320       newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
70321       newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
70322         list2.selectAll(".member-row-new").remove();
70323       });
70324       var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70325       newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
70326       newMembership = newMembership.merge(newMembershipEnter);
70327       newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
70328         nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity)
70329       );
70330       var addRow = selection2.selectAll(".add-row").data([0]);
70331       var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
70332       var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
70333       addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
70334       addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
70335       addRowEnter.append("div").attr("class", "space-value");
70336       addRowEnter.append("div").attr("class", "space-buttons");
70337       addRow = addRow.merge(addRowEnter);
70338       addRow.select(".add-relation").on("click", function() {
70339         _showBlank = true;
70340         section.reRender();
70341         list2.selectAll(".member-entity-input").node().focus();
70342       });
70343       function acceptEntity(d2) {
70344         if (!d2) {
70345           cancelEntity();
70346           return;
70347         }
70348         if (d2.relation)
70349           utilHighlightEntities([d2.relation.id], false, context);
70350         var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
70351         addMembership(d2, role);
70352       }
70353       function cancelEntity() {
70354         var input = newMembership.selectAll(".member-entity-input");
70355         input.property("value", "");
70356         context.surface().selectAll(".highlighted").classed("highlighted", false);
70357       }
70358       function bindTypeahead(d2) {
70359         var row = select_default2(this);
70360         var role = row.selectAll("input.member-role");
70361         var origValue = role.property("value");
70362         function sort(value, data) {
70363           var sameletter = [];
70364           var other = [];
70365           for (var i3 = 0; i3 < data.length; i3++) {
70366             if (data[i3].value.substring(0, value.length) === value) {
70367               sameletter.push(data[i3]);
70368             } else {
70369               other.push(data[i3]);
70370             }
70371           }
70372           return sameletter.concat(other);
70373         }
70374         role.call(
70375           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
70376             var rtype = d2.relation.tags.type;
70377             taginfo.roles({
70378               debounce: true,
70379               rtype: rtype || "",
70380               geometry: context.graph().geometry(_entityIDs[0]),
70381               query: role2
70382             }, function(err, data) {
70383               if (!err)
70384                 callback(sort(role2, data));
70385             });
70386           }).on("cancel", function() {
70387             role.property("value", origValue);
70388           })
70389         );
70390       }
70391       function unbind() {
70392         var row = select_default2(this);
70393         row.selectAll("input.member-role").call(uiCombobox.off, context);
70394       }
70395     }
70396     section.entityIDs = function(val) {
70397       if (!arguments.length)
70398         return _entityIDs;
70399       _entityIDs = val;
70400       _showBlank = false;
70401       return section;
70402     };
70403     return section;
70404   }
70405
70406   // modules/ui/sections/selection_list.js
70407   function uiSectionSelectionList(context) {
70408     var _selectedIDs = [];
70409     var section = uiSection("selected-features", context).shouldDisplay(function() {
70410       return _selectedIDs.length > 1;
70411     }).label(function() {
70412       return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
70413     }).disclosureContent(renderDisclosureContent);
70414     context.history().on("change.selectionList", function(difference2) {
70415       if (difference2) {
70416         section.reRender();
70417       }
70418     });
70419     section.entityIDs = function(val) {
70420       if (!arguments.length)
70421         return _selectedIDs;
70422       _selectedIDs = val;
70423       return section;
70424     };
70425     function selectEntity(d3_event, entity) {
70426       context.enter(modeSelect(context, [entity.id]));
70427     }
70428     function deselectEntity(d3_event, entity) {
70429       var selectedIDs = _selectedIDs.slice();
70430       var index = selectedIDs.indexOf(entity.id);
70431       if (index > -1) {
70432         selectedIDs.splice(index, 1);
70433         context.enter(modeSelect(context, selectedIDs));
70434       }
70435     }
70436     function renderDisclosureContent(selection2) {
70437       var list2 = selection2.selectAll(".feature-list").data([0]);
70438       list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
70439       var entities = _selectedIDs.map(function(id2) {
70440         return context.hasEntity(id2);
70441       }).filter(Boolean);
70442       var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
70443       items.exit().remove();
70444       var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
70445         select_default2(this).on("mouseover", function() {
70446           utilHighlightEntities([d2.id], true, context);
70447         }).on("mouseout", function() {
70448           utilHighlightEntities([d2.id], false, context);
70449         });
70450       });
70451       var label = enter.append("button").attr("class", "label").on("click", selectEntity);
70452       label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
70453       label.append("span").attr("class", "entity-type");
70454       label.append("span").attr("class", "entity-name");
70455       enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
70456       items = items.merge(enter);
70457       items.selectAll(".entity-geom-icon use").attr("href", function() {
70458         var entity = this.parentNode.parentNode.__data__;
70459         return "#iD-icon-" + entity.geometry(context.graph());
70460       });
70461       items.selectAll(".entity-type").text(function(entity) {
70462         return _mainPresetIndex.match(entity, context.graph()).name();
70463       });
70464       items.selectAll(".entity-name").text(function(d2) {
70465         var entity = context.entity(d2.id);
70466         return utilDisplayName(entity);
70467       });
70468     }
70469     return section;
70470   }
70471
70472   // modules/ui/entity_editor.js
70473   function uiEntityEditor(context) {
70474     var dispatch14 = dispatch_default("choose");
70475     var _state = "select";
70476     var _coalesceChanges = false;
70477     var _modified = false;
70478     var _base;
70479     var _entityIDs;
70480     var _activePresets = [];
70481     var _newFeature;
70482     var _sections;
70483     function entityEditor(selection2) {
70484       var combinedTags = utilCombinedTags(_entityIDs, context.graph());
70485       var header = selection2.selectAll(".header").data([0]);
70486       var headerEnter = header.enter().append("div").attr("class", "header fillL");
70487       var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
70488       headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
70489       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
70490         context.enter(modeBrowse(context));
70491       }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
70492       headerEnter.append("h2");
70493       header = header.merge(headerEnter);
70494       header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
70495       header.selectAll(".preset-reset").on("click", function() {
70496         dispatch14.call("choose", this, _activePresets);
70497       });
70498       var body = selection2.selectAll(".inspector-body").data([0]);
70499       var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
70500       body = body.merge(bodyEnter);
70501       if (!_sections) {
70502         _sections = [
70503           uiSectionSelectionList(context),
70504           uiSectionFeatureType(context).on("choose", function(presets) {
70505             dispatch14.call("choose", this, presets);
70506           }),
70507           uiSectionEntityIssues(context),
70508           uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
70509           uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
70510           uiSectionRawMemberEditor(context),
70511           uiSectionRawMembershipEditor(context)
70512         ];
70513       }
70514       _sections.forEach(function(section) {
70515         if (section.entityIDs) {
70516           section.entityIDs(_entityIDs);
70517         }
70518         if (section.presets) {
70519           section.presets(_activePresets);
70520         }
70521         if (section.tags) {
70522           section.tags(combinedTags);
70523         }
70524         if (section.state) {
70525           section.state(_state);
70526         }
70527         body.call(section.render);
70528       });
70529       context.history().on("change.entity-editor", historyChanged);
70530       function historyChanged(difference2) {
70531         if (selection2.selectAll(".entity-editor").empty())
70532           return;
70533         if (_state === "hide")
70534           return;
70535         var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
70536         if (!significant)
70537           return;
70538         _entityIDs = _entityIDs.filter(context.hasEntity);
70539         if (!_entityIDs.length)
70540           return;
70541         var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
70542         loadActivePresets();
70543         var graph = context.graph();
70544         entityEditor.modified(_base !== graph);
70545         entityEditor(selection2);
70546         if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
70547           context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
70548         }
70549       }
70550     }
70551     function changeTags(entityIDs, changed, onInput) {
70552       var actions = [];
70553       for (var i3 in entityIDs) {
70554         var entityID = entityIDs[i3];
70555         var entity = context.entity(entityID);
70556         var tags = Object.assign({}, entity.tags);
70557         if (typeof changed === "function") {
70558           tags = changed(tags);
70559         } else {
70560           for (var k2 in changed) {
70561             if (!k2)
70562               continue;
70563             var v2 = changed[k2];
70564             if (typeof v2 === "object") {
70565               tags[k2] = tags[v2.oldKey];
70566             } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70567               tags[k2] = v2;
70568             }
70569           }
70570         }
70571         if (!onInput) {
70572           tags = utilCleanTags(tags);
70573         }
70574         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70575           actions.push(actionChangeTags(entityID, tags));
70576         }
70577       }
70578       if (actions.length) {
70579         var combinedAction = function(graph) {
70580           actions.forEach(function(action) {
70581             graph = action(graph);
70582           });
70583           return graph;
70584         };
70585         var annotation = _t("operations.change_tags.annotation");
70586         if (_coalesceChanges) {
70587           context.overwrite(combinedAction, annotation);
70588         } else {
70589           context.perform(combinedAction, annotation);
70590           _coalesceChanges = !!onInput;
70591         }
70592       }
70593       if (!onInput) {
70594         context.validator().validate();
70595       }
70596     }
70597     function revertTags(keys2) {
70598       var actions = [];
70599       for (var i3 in _entityIDs) {
70600         var entityID = _entityIDs[i3];
70601         var original = context.graph().base().entities[entityID];
70602         var changed = {};
70603         for (var j2 in keys2) {
70604           var key = keys2[j2];
70605           changed[key] = original ? original.tags[key] : void 0;
70606         }
70607         var entity = context.entity(entityID);
70608         var tags = Object.assign({}, entity.tags);
70609         for (var k2 in changed) {
70610           if (!k2)
70611             continue;
70612           var v2 = changed[k2];
70613           if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70614             tags[k2] = v2;
70615           }
70616         }
70617         tags = utilCleanTags(tags);
70618         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70619           actions.push(actionChangeTags(entityID, tags));
70620         }
70621       }
70622       if (actions.length) {
70623         var combinedAction = function(graph) {
70624           actions.forEach(function(action) {
70625             graph = action(graph);
70626           });
70627           return graph;
70628         };
70629         var annotation = _t("operations.change_tags.annotation");
70630         if (_coalesceChanges) {
70631           context.overwrite(combinedAction, annotation);
70632         } else {
70633           context.perform(combinedAction, annotation);
70634           _coalesceChanges = false;
70635         }
70636       }
70637       context.validator().validate();
70638     }
70639     entityEditor.modified = function(val) {
70640       if (!arguments.length)
70641         return _modified;
70642       _modified = val;
70643       return entityEditor;
70644     };
70645     entityEditor.state = function(val) {
70646       if (!arguments.length)
70647         return _state;
70648       _state = val;
70649       return entityEditor;
70650     };
70651     entityEditor.entityIDs = function(val) {
70652       if (!arguments.length)
70653         return _entityIDs;
70654       _base = context.graph();
70655       _coalesceChanges = false;
70656       if (val && _entityIDs && utilArrayIdentical(_entityIDs, val))
70657         return entityEditor;
70658       _entityIDs = val;
70659       loadActivePresets(true);
70660       return entityEditor.modified(false);
70661     };
70662     entityEditor.newFeature = function(val) {
70663       if (!arguments.length)
70664         return _newFeature;
70665       _newFeature = val;
70666       return entityEditor;
70667     };
70668     function loadActivePresets(isForNewSelection) {
70669       var graph = context.graph();
70670       var counts = {};
70671       for (var i3 in _entityIDs) {
70672         var entity = graph.hasEntity(_entityIDs[i3]);
70673         if (!entity)
70674           return;
70675         var match = _mainPresetIndex.match(entity, graph);
70676         if (!counts[match.id])
70677           counts[match.id] = 0;
70678         counts[match.id] += 1;
70679       }
70680       var matches = Object.keys(counts).sort(function(p1, p2) {
70681         return counts[p2] - counts[p1];
70682       }).map(function(pID) {
70683         return _mainPresetIndex.item(pID);
70684       });
70685       if (!isForNewSelection) {
70686         var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
70687         if (weakPreset && matches.length === 1 && matches[0].isFallback())
70688           return;
70689       }
70690       entityEditor.presets(matches);
70691     }
70692     entityEditor.presets = function(val) {
70693       if (!arguments.length)
70694         return _activePresets;
70695       if (!utilArrayIdentical(val, _activePresets)) {
70696         _activePresets = val;
70697       }
70698       return entityEditor;
70699     };
70700     return utilRebind(entityEditor, dispatch14, "on");
70701   }
70702
70703   // modules/ui/feature_list.js
70704   var sexagesimal = __toESM(require_sexagesimal());
70705
70706   // modules/modes/draw_area.js
70707   function modeDrawArea(context, wayID, startGraph, button) {
70708     var mode = {
70709       button,
70710       id: "draw-area"
70711     };
70712     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
70713       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
70714     });
70715     mode.wayID = wayID;
70716     mode.enter = function() {
70717       context.install(behavior);
70718     };
70719     mode.exit = function() {
70720       context.uninstall(behavior);
70721     };
70722     mode.selectedIDs = function() {
70723       return [wayID];
70724     };
70725     mode.activeID = function() {
70726       return behavior && behavior.activeID() || [];
70727     };
70728     return mode;
70729   }
70730
70731   // modules/modes/add_area.js
70732   function modeAddArea(context, mode) {
70733     mode.id = "add-area";
70734     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70735     function defaultTags(loc) {
70736       var defaultTags2 = { area: "yes" };
70737       if (mode.preset)
70738         defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
70739       return defaultTags2;
70740     }
70741     function actionClose(wayId) {
70742       return function(graph) {
70743         return graph.replace(graph.entity(wayId).close());
70744       };
70745     }
70746     function start2(loc) {
70747       var startGraph = context.graph();
70748       var node = osmNode({ loc });
70749       var way = osmWay({ tags: defaultTags(loc) });
70750       context.perform(
70751         actionAddEntity(node),
70752         actionAddEntity(way),
70753         actionAddVertex(way.id, node.id),
70754         actionClose(way.id)
70755       );
70756       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70757     }
70758     function startFromWay(loc, edge) {
70759       var startGraph = context.graph();
70760       var node = osmNode({ loc });
70761       var way = osmWay({ tags: defaultTags(loc) });
70762       context.perform(
70763         actionAddEntity(node),
70764         actionAddEntity(way),
70765         actionAddVertex(way.id, node.id),
70766         actionClose(way.id),
70767         actionAddMidpoint({ loc, edge }, node)
70768       );
70769       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70770     }
70771     function startFromNode(node) {
70772       var startGraph = context.graph();
70773       var way = osmWay({ tags: defaultTags(node.loc) });
70774       context.perform(
70775         actionAddEntity(way),
70776         actionAddVertex(way.id, node.id),
70777         actionClose(way.id)
70778       );
70779       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70780     }
70781     mode.enter = function() {
70782       context.install(behavior);
70783     };
70784     mode.exit = function() {
70785       context.uninstall(behavior);
70786     };
70787     return mode;
70788   }
70789
70790   // modules/modes/add_line.js
70791   function modeAddLine(context, mode) {
70792     mode.id = "add-line";
70793     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70794     function defaultTags(loc) {
70795       var defaultTags2 = {};
70796       if (mode.preset)
70797         defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
70798       return defaultTags2;
70799     }
70800     function start2(loc) {
70801       var startGraph = context.graph();
70802       var node = osmNode({ loc });
70803       var way = osmWay({ tags: defaultTags(loc) });
70804       context.perform(
70805         actionAddEntity(node),
70806         actionAddEntity(way),
70807         actionAddVertex(way.id, node.id)
70808       );
70809       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70810     }
70811     function startFromWay(loc, edge) {
70812       var startGraph = context.graph();
70813       var node = osmNode({ loc });
70814       var way = osmWay({ tags: defaultTags(loc) });
70815       context.perform(
70816         actionAddEntity(node),
70817         actionAddEntity(way),
70818         actionAddVertex(way.id, node.id),
70819         actionAddMidpoint({ loc, edge }, node)
70820       );
70821       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70822     }
70823     function startFromNode(node) {
70824       var startGraph = context.graph();
70825       var way = osmWay({ tags: defaultTags(node.loc) });
70826       context.perform(
70827         actionAddEntity(way),
70828         actionAddVertex(way.id, node.id)
70829       );
70830       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70831     }
70832     mode.enter = function() {
70833       context.install(behavior);
70834     };
70835     mode.exit = function() {
70836       context.uninstall(behavior);
70837     };
70838     return mode;
70839   }
70840
70841   // modules/modes/add_point.js
70842   function modeAddPoint(context, mode) {
70843     mode.id = "add-point";
70844     var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
70845     function defaultTags(loc) {
70846       var defaultTags2 = {};
70847       if (mode.preset)
70848         defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
70849       return defaultTags2;
70850     }
70851     function add(loc) {
70852       var node = osmNode({ loc, tags: defaultTags(loc) });
70853       context.perform(
70854         actionAddEntity(node),
70855         _t("operations.add.annotation.point")
70856       );
70857       enterSelectMode(node);
70858     }
70859     function addWay(loc, edge) {
70860       var node = osmNode({ tags: defaultTags(loc) });
70861       context.perform(
70862         actionAddMidpoint({ loc, edge }, node),
70863         _t("operations.add.annotation.vertex")
70864       );
70865       enterSelectMode(node);
70866     }
70867     function enterSelectMode(node) {
70868       context.enter(
70869         modeSelect(context, [node.id]).newFeature(true)
70870       );
70871     }
70872     function addNode(node) {
70873       const _defaultTags = defaultTags(node.loc);
70874       if (Object.keys(_defaultTags).length === 0) {
70875         enterSelectMode(node);
70876         return;
70877       }
70878       var tags = Object.assign({}, node.tags);
70879       for (var key in _defaultTags) {
70880         tags[key] = _defaultTags[key];
70881       }
70882       context.perform(
70883         actionChangeTags(node.id, tags),
70884         _t("operations.add.annotation.point")
70885       );
70886       enterSelectMode(node);
70887     }
70888     function cancel() {
70889       context.enter(modeBrowse(context));
70890     }
70891     mode.enter = function() {
70892       context.install(behavior);
70893     };
70894     mode.exit = function() {
70895       context.uninstall(behavior);
70896     };
70897     return mode;
70898   }
70899
70900   // modules/ui/note_comments.js
70901   function uiNoteComments() {
70902     var _note;
70903     function noteComments(selection2) {
70904       if (_note.isNew())
70905         return;
70906       var comments = selection2.selectAll(".comments-container").data([0]);
70907       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
70908       var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
70909       commentEnter.append("div").attr("class", function(d2) {
70910         return "comment-avatar user-" + d2.uid;
70911       }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
70912       var mainEnter = commentEnter.append("div").attr("class", "comment-main");
70913       var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
70914       metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
70915         var selection3 = select_default2(this);
70916         var osm = services.osm;
70917         if (osm && d2.user) {
70918           selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
70919         }
70920         if (d2.user) {
70921           selection3.text(d2.user);
70922         } else {
70923           selection3.call(_t.append("note.anonymous"));
70924         }
70925       });
70926       metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
70927         return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
70928       });
70929       mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
70930         return d2.html;
70931       }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
70932       comments.call(replaceAvatars);
70933     }
70934     function replaceAvatars(selection2) {
70935       var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
70936       var osm = services.osm;
70937       if (showThirdPartyIcons !== "true" || !osm)
70938         return;
70939       var uids = {};
70940       _note.comments.forEach(function(d2) {
70941         if (d2.uid)
70942           uids[d2.uid] = true;
70943       });
70944       Object.keys(uids).forEach(function(uid) {
70945         osm.loadUser(uid, function(err, user) {
70946           if (!user || !user.image_url)
70947             return;
70948           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);
70949         });
70950       });
70951     }
70952     function localeDateString2(s2) {
70953       if (!s2)
70954         return null;
70955       var options2 = { day: "numeric", month: "short", year: "numeric" };
70956       s2 = s2.replace(/-/g, "/");
70957       var d2 = new Date(s2);
70958       if (isNaN(d2.getTime()))
70959         return null;
70960       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
70961     }
70962     noteComments.note = function(val) {
70963       if (!arguments.length)
70964         return _note;
70965       _note = val;
70966       return noteComments;
70967     };
70968     return noteComments;
70969   }
70970
70971   // modules/ui/note_header.js
70972   function uiNoteHeader() {
70973     var _note;
70974     function noteHeader(selection2) {
70975       var header = selection2.selectAll(".note-header").data(
70976         _note ? [_note] : [],
70977         function(d2) {
70978           return d2.status + d2.id;
70979         }
70980       );
70981       header.exit().remove();
70982       var headerEnter = header.enter().append("div").attr("class", "note-header");
70983       var iconEnter = headerEnter.append("div").attr("class", function(d2) {
70984         return "note-header-icon " + d2.status;
70985       }).classed("new", function(d2) {
70986         return d2.id < 0;
70987       });
70988       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
70989       iconEnter.each(function(d2) {
70990         var statusIcon;
70991         if (d2.id < 0) {
70992           statusIcon = "#iD-icon-plus";
70993         } else if (d2.status === "open") {
70994           statusIcon = "#iD-icon-close";
70995         } else {
70996           statusIcon = "#iD-icon-apply";
70997         }
70998         iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
70999       });
71000       headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
71001         if (_note.isNew()) {
71002           return _t.html("note.new");
71003         }
71004         return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
71005       });
71006     }
71007     noteHeader.note = function(val) {
71008       if (!arguments.length)
71009         return _note;
71010       _note = val;
71011       return noteHeader;
71012     };
71013     return noteHeader;
71014   }
71015
71016   // modules/ui/note_report.js
71017   function uiNoteReport() {
71018     var _note;
71019     function noteReport(selection2) {
71020       var url;
71021       if (services.osm && _note instanceof osmNote && !_note.isNew()) {
71022         url = services.osm.noteReportURL(_note);
71023       }
71024       var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
71025       link3.exit().remove();
71026       var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
71027         return d2;
71028       }).call(svgIcon("#iD-icon-out-link", "inline"));
71029       linkEnter.append("span").call(_t.append("note.report"));
71030     }
71031     noteReport.note = function(val) {
71032       if (!arguments.length)
71033         return _note;
71034       _note = val;
71035       return noteReport;
71036     };
71037     return noteReport;
71038   }
71039
71040   // modules/ui/view_on_osm.js
71041   function uiViewOnOSM(context) {
71042     var _what;
71043     function viewOnOSM(selection2) {
71044       var url;
71045       if (_what instanceof osmEntity) {
71046         url = context.connection().entityURL(_what);
71047       } else if (_what instanceof osmNote) {
71048         url = context.connection().noteURL(_what);
71049       }
71050       var data = !_what || _what.isNew() ? [] : [_what];
71051       var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
71052         return d2.id;
71053       });
71054       link3.exit().remove();
71055       var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
71056       linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
71057     }
71058     viewOnOSM.what = function(_2) {
71059       if (!arguments.length)
71060         return _what;
71061       _what = _2;
71062       return viewOnOSM;
71063     };
71064     return viewOnOSM;
71065   }
71066
71067   // modules/ui/note_editor.js
71068   function uiNoteEditor(context) {
71069     var dispatch14 = dispatch_default("change");
71070     var noteComments = uiNoteComments(context);
71071     var noteHeader = uiNoteHeader();
71072     var _note;
71073     var _newNote;
71074     function noteEditor(selection2) {
71075       var header = selection2.selectAll(".header").data([0]);
71076       var headerEnter = header.enter().append("div").attr("class", "header fillL");
71077       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
71078         context.enter(modeBrowse(context));
71079       }).call(svgIcon("#iD-icon-close"));
71080       headerEnter.append("h2").call(_t.append("note.title"));
71081       var body = selection2.selectAll(".body").data([0]);
71082       body = body.enter().append("div").attr("class", "body").merge(body);
71083       var editor = body.selectAll(".note-editor").data([0]);
71084       editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
71085       var footer = selection2.selectAll(".footer").data([0]);
71086       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
71087       var osm = services.osm;
71088       if (osm) {
71089         osm.on("change.note-save", function() {
71090           selection2.call(noteEditor);
71091         });
71092       }
71093     }
71094     function noteSaveSection(selection2) {
71095       var isSelected = _note && _note.id === context.selectedNoteID();
71096       var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
71097         return d2.status + d2.id;
71098       });
71099       noteSave.exit().remove();
71100       var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
71101       noteSaveEnter.append("h4").attr("class", ".note-save-header").text("").each(function() {
71102         if (_note.isNew()) {
71103           _t.append("note.newDescription")(select_default2(this));
71104         } else {
71105           _t.append("note.newComment")(select_default2(this));
71106         }
71107       });
71108       var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
71109         return d2.newComment;
71110       }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
71111       if (!commentTextarea.empty() && _newNote) {
71112         commentTextarea.node().focus();
71113       }
71114       noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
71115       function keydown(d3_event) {
71116         if (!(d3_event.keyCode === 13 && // ↩ Return
71117         d3_event.metaKey))
71118           return;
71119         var osm = services.osm;
71120         if (!osm)
71121           return;
71122         var hasAuth = osm.authenticated();
71123         if (!hasAuth)
71124           return;
71125         if (!_note.newComment)
71126           return;
71127         d3_event.preventDefault();
71128         select_default2(this).on("keydown.note-input", null);
71129         window.setTimeout(function() {
71130           if (_note.isNew()) {
71131             noteSave.selectAll(".save-button").node().focus();
71132             clickSave(_note);
71133           } else {
71134             noteSave.selectAll(".comment-button").node().focus();
71135             clickComment(_note);
71136           }
71137         }, 10);
71138       }
71139       function changeInput() {
71140         var input = select_default2(this);
71141         var val = input.property("value").trim() || void 0;
71142         _note = _note.update({ newComment: val });
71143         var osm = services.osm;
71144         if (osm) {
71145           osm.replaceNote(_note);
71146         }
71147         noteSave.call(noteSaveButtons);
71148       }
71149     }
71150     function userDetails(selection2) {
71151       var detailSection = selection2.selectAll(".detail-section").data([0]);
71152       detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
71153       var osm = services.osm;
71154       if (!osm)
71155         return;
71156       var hasAuth = osm.authenticated();
71157       var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
71158       authWarning.exit().transition().duration(200).style("opacity", 0).remove();
71159       var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
71160       authEnter.call(svgIcon("#iD-icon-alert", "inline"));
71161       authEnter.append("span").call(_t.append("note.login"));
71162       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) {
71163         d3_event.preventDefault();
71164         osm.authenticate();
71165       });
71166       authEnter.transition().duration(200).style("opacity", 1);
71167       var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
71168       prose.exit().remove();
71169       prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
71170       osm.userDetails(function(err, user) {
71171         if (err)
71172           return;
71173         var userLink = select_default2(document.createElement("div"));
71174         if (user.image_url) {
71175           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
71176         }
71177         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
71178         prose.html(_t.html("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
71179       });
71180     }
71181     function noteSaveButtons(selection2) {
71182       var osm = services.osm;
71183       var hasAuth = osm && osm.authenticated();
71184       var isSelected = _note && _note.id === context.selectedNoteID();
71185       var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
71186         return d2.status + d2.id;
71187       });
71188       buttonSection.exit().remove();
71189       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
71190       if (_note.isNew()) {
71191         buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
71192         buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
71193       } else {
71194         buttonEnter.append("button").attr("class", "button status-button action");
71195         buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
71196       }
71197       buttonSection = buttonSection.merge(buttonEnter);
71198       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
71199       buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
71200       buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).text("").each(function(d2) {
71201         var action = d2.status === "open" ? "close" : "open";
71202         var andComment = d2.newComment ? "_comment" : "";
71203         _t.append("note." + action + andComment)(select_default2(this));
71204       });
71205       buttonSection.select(".status-button").on("click.status", clickStatus);
71206       buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
71207       function isSaveDisabled(d2) {
71208         return hasAuth && d2.status === "open" && d2.newComment ? null : true;
71209       }
71210     }
71211     function clickCancel(d3_event, d2) {
71212       this.blur();
71213       var osm = services.osm;
71214       if (osm) {
71215         osm.removeNote(d2);
71216       }
71217       context.enter(modeBrowse(context));
71218       dispatch14.call("change");
71219     }
71220     function clickSave(d3_event, d2) {
71221       this.blur();
71222       var osm = services.osm;
71223       if (osm) {
71224         osm.postNoteCreate(d2, function(err, note) {
71225           dispatch14.call("change", note);
71226         });
71227       }
71228     }
71229     function clickStatus(d3_event, d2) {
71230       this.blur();
71231       var osm = services.osm;
71232       if (osm) {
71233         var setStatus = d2.status === "open" ? "closed" : "open";
71234         osm.postNoteUpdate(d2, setStatus, function(err, note) {
71235           dispatch14.call("change", note);
71236         });
71237       }
71238     }
71239     function clickComment(d3_event, d2) {
71240       this.blur();
71241       var osm = services.osm;
71242       if (osm) {
71243         osm.postNoteUpdate(d2, d2.status, function(err, note) {
71244           dispatch14.call("change", note);
71245         });
71246       }
71247     }
71248     noteEditor.note = function(val) {
71249       if (!arguments.length)
71250         return _note;
71251       _note = val;
71252       return noteEditor;
71253     };
71254     noteEditor.newNote = function(val) {
71255       if (!arguments.length)
71256         return _newNote;
71257       _newNote = val;
71258       return noteEditor;
71259     };
71260     return utilRebind(noteEditor, dispatch14, "on");
71261   }
71262
71263   // modules/modes/select_note.js
71264   function modeSelectNote(context, selectedNoteID) {
71265     var mode = {
71266       id: "select-note",
71267       button: "browse"
71268     };
71269     var _keybinding = utilKeybinding("select-note");
71270     var _noteEditor = uiNoteEditor(context).on("change", function() {
71271       context.map().pan([0, 0]);
71272       var note = checkSelectedID();
71273       if (!note)
71274         return;
71275       context.ui().sidebar.show(_noteEditor.note(note));
71276     });
71277     var _behaviors = [
71278       behaviorBreathe(context),
71279       behaviorHover(context),
71280       behaviorSelect(context),
71281       behaviorLasso(context),
71282       modeDragNode(context).behavior,
71283       modeDragNote(context).behavior
71284     ];
71285     var _newFeature = false;
71286     function checkSelectedID() {
71287       if (!services.osm)
71288         return;
71289       var note = services.osm.getNote(selectedNoteID);
71290       if (!note) {
71291         context.enter(modeBrowse(context));
71292       }
71293       return note;
71294     }
71295     function selectNote(d3_event, drawn) {
71296       if (!checkSelectedID())
71297         return;
71298       var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
71299       if (selection2.empty()) {
71300         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
71301         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
71302           context.enter(modeBrowse(context));
71303         }
71304       } else {
71305         selection2.classed("selected", true);
71306         context.selectedNoteID(selectedNoteID);
71307       }
71308     }
71309     function esc() {
71310       if (context.container().select(".combobox").size())
71311         return;
71312       context.enter(modeBrowse(context));
71313     }
71314     mode.zoomToSelected = function() {
71315       if (!services.osm)
71316         return;
71317       var note = services.osm.getNote(selectedNoteID);
71318       if (note) {
71319         context.map().centerZoomEase(note.loc, 20);
71320       }
71321     };
71322     mode.newFeature = function(val) {
71323       if (!arguments.length)
71324         return _newFeature;
71325       _newFeature = val;
71326       return mode;
71327     };
71328     mode.enter = function() {
71329       var note = checkSelectedID();
71330       if (!note)
71331         return;
71332       _behaviors.forEach(context.install);
71333       _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
71334       select_default2(document).call(_keybinding);
71335       selectNote();
71336       var sidebar = context.ui().sidebar;
71337       sidebar.show(_noteEditor.note(note).newNote(_newFeature));
71338       sidebar.expand(sidebar.intersects(note.extent()));
71339       context.map().on("drawn.select", selectNote);
71340     };
71341     mode.exit = function() {
71342       _behaviors.forEach(context.uninstall);
71343       select_default2(document).call(_keybinding.unbind);
71344       context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
71345       context.map().on("drawn.select", null);
71346       context.ui().sidebar.hide();
71347       context.selectedNoteID(null);
71348     };
71349     return mode;
71350   }
71351
71352   // modules/modes/add_note.js
71353   function modeAddNote(context) {
71354     var mode = {
71355       id: "add-note",
71356       button: "note",
71357       description: _t.append("modes.add_note.description"),
71358       key: _t("modes.add_note.key")
71359     };
71360     var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
71361     function add(loc) {
71362       var osm = services.osm;
71363       if (!osm)
71364         return;
71365       var note = osmNote({ loc, status: "open", comments: [] });
71366       osm.replaceNote(note);
71367       context.map().pan([0, 0]);
71368       context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
71369     }
71370     function cancel() {
71371       context.enter(modeBrowse(context));
71372     }
71373     mode.enter = function() {
71374       context.install(behavior);
71375     };
71376     mode.exit = function() {
71377       context.uninstall(behavior);
71378     };
71379     return mode;
71380   }
71381
71382   // node_modules/osm-community-index/lib/simplify.js
71383   var import_diacritics2 = __toESM(require_diacritics(), 1);
71384   function simplify(str) {
71385     if (typeof str !== "string")
71386       return "";
71387     return import_diacritics2.default.remove(
71388       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()
71389     );
71390   }
71391
71392   // node_modules/osm-community-index/lib/resolve_strings.js
71393   function resolveStrings(item, defaults, localizerFn) {
71394     let itemStrings = Object.assign({}, item.strings);
71395     let defaultStrings = Object.assign({}, defaults[item.type]);
71396     const anyToken = new RegExp(/(\{\w+\})/, "gi");
71397     if (localizerFn) {
71398       if (itemStrings.community) {
71399         const communityID = simplify(itemStrings.community);
71400         itemStrings.community = localizerFn("_communities.".concat(communityID));
71401       }
71402       ["name", "description", "extendedDescription"].forEach((prop) => {
71403         if (defaultStrings[prop])
71404           defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
71405         if (itemStrings[prop])
71406           itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
71407       });
71408     }
71409     let replacements = {
71410       account: item.account,
71411       community: itemStrings.community,
71412       signupUrl: itemStrings.signupUrl,
71413       url: itemStrings.url
71414     };
71415     if (!replacements.signupUrl) {
71416       replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
71417     }
71418     if (!replacements.url) {
71419       replacements.url = resolve(itemStrings.url || defaultStrings.url);
71420     }
71421     let resolved = {
71422       name: resolve(itemStrings.name || defaultStrings.name),
71423       url: resolve(itemStrings.url || defaultStrings.url),
71424       signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
71425       description: resolve(itemStrings.description || defaultStrings.description),
71426       extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
71427     };
71428     resolved.nameHTML = linkify(resolved.url, resolved.name);
71429     resolved.urlHTML = linkify(resolved.url);
71430     resolved.signupUrlHTML = linkify(resolved.signupUrl);
71431     resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
71432     resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
71433     return resolved;
71434     function resolve(s2, addLinks) {
71435       if (!s2)
71436         return void 0;
71437       let result = s2;
71438       for (let key in replacements) {
71439         const token = "{".concat(key, "}");
71440         const regex = new RegExp(token, "g");
71441         if (regex.test(result)) {
71442           let replacement = replacements[key];
71443           if (!replacement) {
71444             throw new Error("Cannot resolve token: ".concat(token));
71445           } else {
71446             if (addLinks && (key === "signupUrl" || key === "url")) {
71447               replacement = linkify(replacement);
71448             }
71449             result = result.replace(regex, replacement);
71450           }
71451         }
71452       }
71453       const leftovers = result.match(anyToken);
71454       if (leftovers) {
71455         throw new Error("Cannot resolve tokens: ".concat(leftovers));
71456       }
71457       if (addLinks && item.type === "reddit") {
71458         result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
71459       }
71460       return result;
71461     }
71462     function linkify(url, text) {
71463       if (!url)
71464         return void 0;
71465       text = text || url;
71466       return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
71467     }
71468   }
71469
71470   // modules/ui/success.js
71471   var _oci = null;
71472   function uiSuccess(context) {
71473     const MAXEVENTS = 2;
71474     const dispatch14 = dispatch_default("cancel");
71475     let _changeset2;
71476     let _location;
71477     ensureOSMCommunityIndex();
71478     function ensureOSMCommunityIndex() {
71479       const data = _mainFileFetcher;
71480       return Promise.all([
71481         data.get("oci_features"),
71482         data.get("oci_resources"),
71483         data.get("oci_defaults")
71484       ]).then((vals) => {
71485         if (_oci)
71486           return _oci;
71487         if (vals[0] && Array.isArray(vals[0].features)) {
71488           _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
71489         }
71490         let ociResources = Object.values(vals[1].resources);
71491         if (ociResources.length) {
71492           return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
71493             _oci = {
71494               resources: ociResources,
71495               defaults: vals[2].defaults
71496             };
71497             return _oci;
71498           });
71499         } else {
71500           _oci = {
71501             resources: [],
71502             // no resources?
71503             defaults: vals[2].defaults
71504           };
71505           return _oci;
71506         }
71507       });
71508     }
71509     function parseEventDate(when) {
71510       if (!when)
71511         return;
71512       let raw = when.trim();
71513       if (!raw)
71514         return;
71515       if (!/Z$/.test(raw)) {
71516         raw += "Z";
71517       }
71518       const parsed = new Date(raw);
71519       return new Date(parsed.toUTCString().slice(0, 25));
71520     }
71521     function success(selection2) {
71522       let header = selection2.append("div").attr("class", "header fillL");
71523       header.append("h2").call(_t.append("success.just_edited"));
71524       header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
71525       let body = selection2.append("div").attr("class", "body save-success fillL");
71526       let summary = body.append("div").attr("class", "save-summary");
71527       summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
71528       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"));
71529       let osm = context.connection();
71530       if (!osm)
71531         return;
71532       let changesetURL = osm.changesetURL(_changeset2.id);
71533       let table = summary.append("table").attr("class", "summary-table");
71534       let row = table.append("tr").attr("class", "summary-row");
71535       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");
71536       let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
71537       summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
71538       summaryDetail.append("div").html(_t.html("success.changeset_id", {
71539         changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
71540       }));
71541       if (showDonationMessage !== false) {
71542         const donationUrl = "https://supporting.openstreetmap.org/";
71543         let supporting = body.append("div").attr("class", "save-supporting");
71544         supporting.append("h3").call(_t.append("success.supporting.title"));
71545         supporting.append("p").call(_t.append("success.supporting.details"));
71546         table = supporting.append("table").attr("class", "supporting-table");
71547         row = table.append("tr").attr("class", "supporting-row");
71548         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");
71549         let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
71550         supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
71551         supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
71552       }
71553       ensureOSMCommunityIndex().then((oci) => {
71554         const loc = context.map().center();
71555         const validHere = _sharedLocationManager.locationSetsAt(loc);
71556         let communities = [];
71557         oci.resources.forEach((resource) => {
71558           let area = validHere[resource.locationSetID];
71559           if (!area)
71560             return;
71561           const localizer = (stringID) => _t.html("community.".concat(stringID));
71562           resource.resolved = resolveStrings(resource, oci.defaults, localizer);
71563           communities.push({
71564             area,
71565             order: resource.order || 0,
71566             resource
71567           });
71568         });
71569         communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
71570         body.call(showCommunityLinks, communities.map((c2) => c2.resource));
71571       });
71572     }
71573     function showCommunityLinks(selection2, resources) {
71574       let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
71575       communityLinks.append("h3").call(_t.append("success.like_osm"));
71576       let table = communityLinks.append("table").attr("class", "community-table");
71577       let row = table.selectAll(".community-row").data(resources);
71578       let rowEnter = row.enter().append("tr").attr("class", "community-row");
71579       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));
71580       let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
71581       communityDetail.each(showCommunityDetails);
71582       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"));
71583     }
71584     function showCommunityDetails(d2) {
71585       let selection2 = select_default2(this);
71586       let communityID = d2.id;
71587       selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
71588       selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
71589       if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
71590         selection2.append("div").call(
71591           uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
71592         );
71593       }
71594       let nextEvents = (d2.events || []).map((event) => {
71595         event.date = parseEventDate(event.when);
71596         return event;
71597       }).filter((event) => {
71598         const t2 = event.date.getTime();
71599         const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
71600         return !isNaN(t2) && t2 >= now3;
71601       }).sort((a2, b2) => {
71602         return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
71603       }).slice(0, MAXEVENTS);
71604       if (nextEvents.length) {
71605         selection2.append("div").call(
71606           uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
71607         ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
71608       }
71609       function showMore(selection3) {
71610         let more = selection3.selectAll(".community-more").data([0]);
71611         let moreEnter = more.enter().append("div").attr("class", "community-more");
71612         if (d2.resolved.extendedDescriptionHTML) {
71613           moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
71614         }
71615         if (d2.languageCodes && d2.languageCodes.length) {
71616           const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
71617           moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
71618         }
71619       }
71620       function showNextEvents(selection3) {
71621         let events = selection3.append("div").attr("class", "community-events");
71622         let item = events.selectAll(".community-event").data(nextEvents);
71623         let itemEnter = item.enter().append("div").attr("class", "community-event");
71624         itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
71625           let name = d4.name;
71626           if (d4.i18n && d4.id) {
71627             name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
71628           }
71629           return name;
71630         });
71631         itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
71632           let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
71633           if (d4.date.getHours() || d4.date.getMinutes()) {
71634             options2.hour = "numeric";
71635             options2.minute = "numeric";
71636           }
71637           return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
71638         });
71639         itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
71640           let where = d4.where;
71641           if (d4.i18n && d4.id) {
71642             where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
71643           }
71644           return where;
71645         });
71646         itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
71647           let description = d4.description;
71648           if (d4.i18n && d4.id) {
71649             description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
71650           }
71651           return description;
71652         });
71653       }
71654     }
71655     success.changeset = function(val) {
71656       if (!arguments.length)
71657         return _changeset2;
71658       _changeset2 = val;
71659       return success;
71660     };
71661     success.location = function(val) {
71662       if (!arguments.length)
71663         return _location;
71664       _location = val;
71665       return success;
71666     };
71667     return utilRebind(success, dispatch14, "on");
71668   }
71669
71670   // modules/modes/save.js
71671   function modeSave(context) {
71672     var mode = { id: "save" };
71673     var keybinding = utilKeybinding("modeSave");
71674     var commit = uiCommit(context).on("cancel", cancel);
71675     var _conflictsUi;
71676     var _location;
71677     var _success;
71678     var uploader = context.uploader().on("saveStarted.modeSave", function() {
71679       keybindingOff();
71680     }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
71681       cancel();
71682     }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
71683     function cancel() {
71684       context.enter(modeBrowse(context));
71685     }
71686     function showProgress(num, total) {
71687       var modal = context.container().select(".loading-modal .modal-section");
71688       var progress = modal.selectAll(".progress").data([0]);
71689       progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
71690     }
71691     function showConflicts(changeset, conflicts, origChanges) {
71692       var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
71693       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71694       _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
71695         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71696         selection2.remove();
71697         keybindingOn();
71698         uploader.cancelConflictResolution();
71699       }).on("save", function() {
71700         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71701         selection2.remove();
71702         uploader.processResolvedConflicts(changeset);
71703       });
71704       selection2.call(_conflictsUi);
71705     }
71706     function showErrors(errors) {
71707       keybindingOn();
71708       var selection2 = uiConfirm(context.container());
71709       selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
71710       addErrors(selection2, errors);
71711       selection2.okButton();
71712     }
71713     function addErrors(selection2, data) {
71714       var message = selection2.select(".modal-section.message-text");
71715       var items = message.selectAll(".error-container").data(data);
71716       var enter = items.enter().append("div").attr("class", "error-container");
71717       enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
71718         return d2.msg || _t("save.unknown_error_details");
71719       }).on("click", function(d3_event) {
71720         d3_event.preventDefault();
71721         var error = select_default2(this);
71722         var detail = select_default2(this.nextElementSibling);
71723         var exp2 = error.classed("expanded");
71724         detail.style("display", exp2 ? "none" : "block");
71725         error.classed("expanded", !exp2);
71726       });
71727       var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
71728       details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
71729         return d2.details || [];
71730       }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
71731         return d2;
71732       });
71733       items.exit().remove();
71734     }
71735     function showSuccess(changeset) {
71736       commit.reset();
71737       var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
71738         context.ui().sidebar.hide();
71739       });
71740       context.enter(modeBrowse(context).sidebar(ui));
71741     }
71742     function keybindingOn() {
71743       select_default2(document).call(keybinding.on("\u238B", cancel, true));
71744     }
71745     function keybindingOff() {
71746       select_default2(document).call(keybinding.unbind);
71747     }
71748     function prepareForSuccess() {
71749       _success = uiSuccess(context);
71750       _location = null;
71751       if (!services.geocoder)
71752         return;
71753       services.geocoder.reverse(context.map().center(), function(err, result) {
71754         if (err || !result || !result.address)
71755           return;
71756         var addr = result.address;
71757         var place = addr && (addr.town || addr.city || addr.county) || "";
71758         var region = addr && (addr.state || addr.country) || "";
71759         var separator = place && region ? _t("success.thank_you_where.separator") : "";
71760         _location = _t(
71761           "success.thank_you_where.format",
71762           { place, separator, region }
71763         );
71764       });
71765     }
71766     mode.selectedIDs = function() {
71767       return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
71768     };
71769     mode.enter = function() {
71770       context.ui().sidebar.expand();
71771       function done() {
71772         context.ui().sidebar.show(commit);
71773       }
71774       keybindingOn();
71775       context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71776       var osm = context.connection();
71777       if (!osm) {
71778         cancel();
71779         return;
71780       }
71781       if (osm.authenticated()) {
71782         done();
71783       } else {
71784         osm.authenticate(function(err) {
71785           if (err) {
71786             cancel();
71787           } else {
71788             done();
71789           }
71790         });
71791       }
71792     };
71793     mode.exit = function() {
71794       keybindingOff();
71795       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71796       context.ui().sidebar.hide();
71797     };
71798     return mode;
71799   }
71800
71801   // modules/ui/improveOSM_comments.js
71802   function uiImproveOsmComments() {
71803     let _qaItem;
71804     function issueComments(selection2) {
71805       let comments = selection2.selectAll(".comments-container").data([0]);
71806       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
71807       services.improveOSM.getComments(_qaItem).then((d2) => {
71808         if (!d2.comments)
71809           return;
71810         const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment");
71811         commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
71812         const mainEnter = commentEnter.append("div").attr("class", "comment-main");
71813         const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
71814         metadataEnter.append("div").attr("class", "comment-author").each(function(d4) {
71815           const osm = services.osm;
71816           let selection3 = select_default2(this);
71817           if (osm && d4.username) {
71818             selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank");
71819           }
71820           selection3.text((d5) => d5.username);
71821         });
71822         metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) }));
71823         mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text);
71824       }).catch((err) => {
71825         console.log(err);
71826       });
71827     }
71828     function localeDateString2(s2) {
71829       if (!s2)
71830         return null;
71831       const options2 = { day: "numeric", month: "short", year: "numeric" };
71832       const d2 = new Date(s2 * 1e3);
71833       if (isNaN(d2.getTime()))
71834         return null;
71835       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
71836     }
71837     issueComments.issue = function(val) {
71838       if (!arguments.length)
71839         return _qaItem;
71840       _qaItem = val;
71841       return issueComments;
71842     };
71843     return issueComments;
71844   }
71845
71846   // modules/ui/improveOSM_details.js
71847   function uiImproveOsmDetails(context) {
71848     let _qaItem;
71849     function issueDetail(d2) {
71850       if (d2.desc)
71851         return d2.desc;
71852       const issueKey = d2.issueKey;
71853       d2.replacements = d2.replacements || {};
71854       d2.replacements.default = { html: _t.html("inspector.unknown") };
71855       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements);
71856     }
71857     function improveOsmDetails(selection2) {
71858       const details = selection2.selectAll(".error-details").data(
71859         _qaItem ? [_qaItem] : [],
71860         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71861       );
71862       details.exit().remove();
71863       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
71864       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
71865       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
71866       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
71867       let relatedEntities = [];
71868       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
71869         const link3 = select_default2(this);
71870         const isObjectLink = link3.classed("error_object_link");
71871         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
71872         const entity = context.hasEntity(entityID);
71873         relatedEntities.push(entityID);
71874         link3.on("mouseenter", () => {
71875           utilHighlightEntities([entityID], true, context);
71876         }).on("mouseleave", () => {
71877           utilHighlightEntities([entityID], false, context);
71878         }).on("click", (d3_event) => {
71879           d3_event.preventDefault();
71880           utilHighlightEntities([entityID], false, context);
71881           const osmlayer = context.layers().layer("osm");
71882           if (!osmlayer.enabled()) {
71883             osmlayer.enabled(true);
71884           }
71885           context.map().centerZoom(_qaItem.loc, 20);
71886           if (entity) {
71887             context.enter(modeSelect(context, [entityID]));
71888           } else {
71889             context.loadEntity(entityID, (err, result) => {
71890               if (err)
71891                 return;
71892               const entity2 = result.data.find((e3) => e3.id === entityID);
71893               if (entity2)
71894                 context.enter(modeSelect(context, [entityID]));
71895             });
71896           }
71897         });
71898         if (entity) {
71899           let name = utilDisplayName(entity);
71900           if (!name && !isObjectLink) {
71901             const preset = _mainPresetIndex.match(entity, context.graph());
71902             name = preset && !preset.isFallback() && preset.name();
71903           }
71904           if (name) {
71905             this.innerText = name;
71906           }
71907         }
71908       });
71909       context.features().forceVisible(relatedEntities);
71910       context.map().pan([0, 0]);
71911     }
71912     improveOsmDetails.issue = function(val) {
71913       if (!arguments.length)
71914         return _qaItem;
71915       _qaItem = val;
71916       return improveOsmDetails;
71917     };
71918     return improveOsmDetails;
71919   }
71920
71921   // modules/ui/improveOSM_header.js
71922   function uiImproveOsmHeader() {
71923     let _qaItem;
71924     function issueTitle(d2) {
71925       const issueKey = d2.issueKey;
71926       d2.replacements = d2.replacements || {};
71927       d2.replacements.default = { html: _t.html("inspector.unknown") };
71928       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements);
71929     }
71930     function improveOsmHeader(selection2) {
71931       const header = selection2.selectAll(".qa-header").data(
71932         _qaItem ? [_qaItem] : [],
71933         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71934       );
71935       header.exit().remove();
71936       const headerEnter = header.enter().append("div").attr("class", "qa-header");
71937       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));
71938       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");
71939       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 : "");
71940       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
71941     }
71942     improveOsmHeader.issue = function(val) {
71943       if (!arguments.length)
71944         return _qaItem;
71945       _qaItem = val;
71946       return improveOsmHeader;
71947     };
71948     return improveOsmHeader;
71949   }
71950
71951   // modules/ui/improveOSM_editor.js
71952   function uiImproveOsmEditor(context) {
71953     const dispatch14 = dispatch_default("change");
71954     const qaDetails = uiImproveOsmDetails(context);
71955     const qaComments = uiImproveOsmComments(context);
71956     const qaHeader = uiImproveOsmHeader(context);
71957     let _qaItem;
71958     function improveOsmEditor(selection2) {
71959       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
71960       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
71961       headerEnter.append("h2").call(_t.append("QA.improveOSM.title"));
71962       let body = selection2.selectAll(".body").data([0]);
71963       body = body.enter().append("div").attr("class", "body").merge(body);
71964       const editor = body.selectAll(".qa-editor").data([0]);
71965       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);
71966     }
71967     function improveOsmSaveSection(selection2) {
71968       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
71969       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
71970       let saveSection = selection2.selectAll(".qa-save").data(
71971         isShown ? [_qaItem] : [],
71972         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71973       );
71974       saveSection.exit().remove();
71975       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
71976       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment"));
71977       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);
71978       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
71979       function changeInput() {
71980         const input = select_default2(this);
71981         let val = input.property("value").trim();
71982         if (val === "") {
71983           val = void 0;
71984         }
71985         _qaItem = _qaItem.update({ newComment: val });
71986         const qaService = services.improveOSM;
71987         if (qaService) {
71988           qaService.replaceItem(_qaItem);
71989         }
71990         saveSection.call(qaSaveButtons);
71991       }
71992     }
71993     function qaSaveButtons(selection2) {
71994       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
71995       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
71996       buttonSection.exit().remove();
71997       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
71998       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
71999       buttonEnter.append("button").attr("class", "button close-button action");
72000       buttonEnter.append("button").attr("class", "button ignore-button action");
72001       buttonSection = buttonSection.merge(buttonEnter);
72002       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72003         this.blur();
72004         const qaService = services.improveOSM;
72005         if (qaService) {
72006           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72007         }
72008       });
72009       buttonSection.select(".close-button").html((d2) => {
72010         const andComment = d2.newComment ? "_comment" : "";
72011         return _t.html("QA.keepRight.close".concat(andComment));
72012       }).on("click.close", function(d3_event, d2) {
72013         this.blur();
72014         const qaService = services.improveOSM;
72015         if (qaService) {
72016           d2.newStatus = "SOLVED";
72017           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72018         }
72019       });
72020       buttonSection.select(".ignore-button").html((d2) => {
72021         const andComment = d2.newComment ? "_comment" : "";
72022         return _t.html("QA.keepRight.ignore".concat(andComment));
72023       }).on("click.ignore", function(d3_event, d2) {
72024         this.blur();
72025         const qaService = services.improveOSM;
72026         if (qaService) {
72027           d2.newStatus = "INVALID";
72028           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72029         }
72030       });
72031     }
72032     improveOsmEditor.error = function(val) {
72033       if (!arguments.length)
72034         return _qaItem;
72035       _qaItem = val;
72036       return improveOsmEditor;
72037     };
72038     return utilRebind(improveOsmEditor, dispatch14, "on");
72039   }
72040
72041   // modules/ui/keepRight_details.js
72042   function uiKeepRightDetails(context) {
72043     let _qaItem;
72044     function issueDetail(d2) {
72045       const { itemType, parentIssueType } = d2;
72046       const unknown = { html: _t.html("inspector.unknown") };
72047       let replacements = d2.replacements || {};
72048       replacements.default = unknown;
72049       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72050         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
72051       } else {
72052         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
72053       }
72054     }
72055     function keepRightDetails(selection2) {
72056       const details = selection2.selectAll(".error-details").data(
72057         _qaItem ? [_qaItem] : [],
72058         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72059       );
72060       details.exit().remove();
72061       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72062       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
72063       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
72064       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
72065       let relatedEntities = [];
72066       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
72067         const link3 = select_default2(this);
72068         const isObjectLink = link3.classed("error_object_link");
72069         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
72070         const entity = context.hasEntity(entityID);
72071         relatedEntities.push(entityID);
72072         link3.on("mouseenter", () => {
72073           utilHighlightEntities([entityID], true, context);
72074         }).on("mouseleave", () => {
72075           utilHighlightEntities([entityID], false, context);
72076         }).on("click", (d3_event) => {
72077           d3_event.preventDefault();
72078           utilHighlightEntities([entityID], false, context);
72079           const osmlayer = context.layers().layer("osm");
72080           if (!osmlayer.enabled()) {
72081             osmlayer.enabled(true);
72082           }
72083           context.map().centerZoomEase(_qaItem.loc, 20);
72084           if (entity) {
72085             context.enter(modeSelect(context, [entityID]));
72086           } else {
72087             context.loadEntity(entityID, (err, result) => {
72088               if (err)
72089                 return;
72090               const entity2 = result.data.find((e3) => e3.id === entityID);
72091               if (entity2)
72092                 context.enter(modeSelect(context, [entityID]));
72093             });
72094           }
72095         });
72096         if (entity) {
72097           let name = utilDisplayName(entity);
72098           if (!name && !isObjectLink) {
72099             const preset = _mainPresetIndex.match(entity, context.graph());
72100             name = preset && !preset.isFallback() && preset.name();
72101           }
72102           if (name) {
72103             this.innerText = name;
72104           }
72105         }
72106       });
72107       context.features().forceVisible(relatedEntities);
72108       context.map().pan([0, 0]);
72109     }
72110     keepRightDetails.issue = function(val) {
72111       if (!arguments.length)
72112         return _qaItem;
72113       _qaItem = val;
72114       return keepRightDetails;
72115     };
72116     return keepRightDetails;
72117   }
72118
72119   // modules/ui/keepRight_header.js
72120   function uiKeepRightHeader() {
72121     let _qaItem;
72122     function issueTitle(d2) {
72123       const { itemType, parentIssueType } = d2;
72124       const unknown = _t.html("inspector.unknown");
72125       let replacements = d2.replacements || {};
72126       replacements.default = { html: unknown };
72127       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72128         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
72129       } else {
72130         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
72131       }
72132     }
72133     function keepRightHeader(selection2) {
72134       const header = selection2.selectAll(".qa-header").data(
72135         _qaItem ? [_qaItem] : [],
72136         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72137       );
72138       header.exit().remove();
72139       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72140       const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
72141       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"));
72142       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
72143     }
72144     keepRightHeader.issue = function(val) {
72145       if (!arguments.length)
72146         return _qaItem;
72147       _qaItem = val;
72148       return keepRightHeader;
72149     };
72150     return keepRightHeader;
72151   }
72152
72153   // modules/ui/view_on_keepRight.js
72154   function uiViewOnKeepRight() {
72155     let _qaItem;
72156     function viewOnKeepRight(selection2) {
72157       let url;
72158       if (services.keepRight && _qaItem instanceof QAItem) {
72159         url = services.keepRight.issueURL(_qaItem);
72160       }
72161       const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
72162       link3.exit().remove();
72163       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"));
72164       linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
72165     }
72166     viewOnKeepRight.what = function(val) {
72167       if (!arguments.length)
72168         return _qaItem;
72169       _qaItem = val;
72170       return viewOnKeepRight;
72171     };
72172     return viewOnKeepRight;
72173   }
72174
72175   // modules/ui/keepRight_editor.js
72176   function uiKeepRightEditor(context) {
72177     const dispatch14 = dispatch_default("change");
72178     const qaDetails = uiKeepRightDetails(context);
72179     const qaHeader = uiKeepRightHeader(context);
72180     let _qaItem;
72181     function keepRightEditor(selection2) {
72182       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
72183       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72184       headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
72185       let body = selection2.selectAll(".body").data([0]);
72186       body = body.enter().append("div").attr("class", "body").merge(body);
72187       const editor = body.selectAll(".qa-editor").data([0]);
72188       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
72189       const footer = selection2.selectAll(".footer").data([0]);
72190       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
72191     }
72192     function keepRightSaveSection(selection2) {
72193       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72194       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
72195       let saveSection = selection2.selectAll(".qa-save").data(
72196         isShown ? [_qaItem] : [],
72197         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72198       );
72199       saveSection.exit().remove();
72200       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72201       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
72202       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);
72203       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72204       function changeInput() {
72205         const input = select_default2(this);
72206         let val = input.property("value").trim();
72207         if (val === _qaItem.comment) {
72208           val = void 0;
72209         }
72210         _qaItem = _qaItem.update({ newComment: val });
72211         const qaService = services.keepRight;
72212         if (qaService) {
72213           qaService.replaceItem(_qaItem);
72214         }
72215         saveSection.call(qaSaveButtons);
72216       }
72217     }
72218     function qaSaveButtons(selection2) {
72219       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72220       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72221       buttonSection.exit().remove();
72222       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72223       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
72224       buttonEnter.append("button").attr("class", "button close-button action");
72225       buttonEnter.append("button").attr("class", "button ignore-button action");
72226       buttonSection = buttonSection.merge(buttonEnter);
72227       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72228         this.blur();
72229         const qaService = services.keepRight;
72230         if (qaService) {
72231           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72232         }
72233       });
72234       buttonSection.select(".close-button").html((d2) => {
72235         const andComment = d2.newComment ? "_comment" : "";
72236         return _t.html("QA.keepRight.close".concat(andComment));
72237       }).on("click.close", function(d3_event, d2) {
72238         this.blur();
72239         const qaService = services.keepRight;
72240         if (qaService) {
72241           d2.newStatus = "ignore_t";
72242           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72243         }
72244       });
72245       buttonSection.select(".ignore-button").html((d2) => {
72246         const andComment = d2.newComment ? "_comment" : "";
72247         return _t.html("QA.keepRight.ignore".concat(andComment));
72248       }).on("click.ignore", function(d3_event, d2) {
72249         this.blur();
72250         const qaService = services.keepRight;
72251         if (qaService) {
72252           d2.newStatus = "ignore";
72253           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72254         }
72255       });
72256     }
72257     keepRightEditor.error = function(val) {
72258       if (!arguments.length)
72259         return _qaItem;
72260       _qaItem = val;
72261       return keepRightEditor;
72262     };
72263     return utilRebind(keepRightEditor, dispatch14, "on");
72264   }
72265
72266   // modules/ui/osmose_details.js
72267   function uiOsmoseDetails(context) {
72268     let _qaItem;
72269     function issueString(d2, type2) {
72270       if (!d2)
72271         return "";
72272       const s2 = services.osmose.getStrings(d2.itemType);
72273       return type2 in s2 ? s2[type2] : "";
72274     }
72275     function osmoseDetails(selection2) {
72276       const details = selection2.selectAll(".error-details").data(
72277         _qaItem ? [_qaItem] : [],
72278         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72279       );
72280       details.exit().remove();
72281       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72282       if (issueString(_qaItem, "detail")) {
72283         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72284         div.append("h4").call(_t.append("QA.keepRight.detail_description"));
72285         div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72286       }
72287       const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72288       const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72289       if (issueString(_qaItem, "fix")) {
72290         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72291         div.append("h4").call(_t.append("QA.osmose.fix_title"));
72292         div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72293       }
72294       if (issueString(_qaItem, "trap")) {
72295         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72296         div.append("h4").call(_t.append("QA.osmose.trap_title"));
72297         div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72298       }
72299       const thisItem = _qaItem;
72300       services.osmose.loadIssueDetail(_qaItem).then((d2) => {
72301         if (!d2.elems || d2.elems.length === 0)
72302           return;
72303         if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty())
72304           return;
72305         if (d2.detail) {
72306           detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
72307           detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72308         }
72309         elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
72310         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() {
72311           const link3 = select_default2(this);
72312           const entityID = this.textContent;
72313           const entity = context.hasEntity(entityID);
72314           link3.on("mouseenter", () => {
72315             utilHighlightEntities([entityID], true, context);
72316           }).on("mouseleave", () => {
72317             utilHighlightEntities([entityID], false, context);
72318           }).on("click", (d3_event) => {
72319             d3_event.preventDefault();
72320             utilHighlightEntities([entityID], false, context);
72321             const osmlayer = context.layers().layer("osm");
72322             if (!osmlayer.enabled()) {
72323               osmlayer.enabled(true);
72324             }
72325             context.map().centerZoom(d2.loc, 20);
72326             if (entity) {
72327               context.enter(modeSelect(context, [entityID]));
72328             } else {
72329               context.loadEntity(entityID, (err, result) => {
72330                 if (err)
72331                   return;
72332                 const entity2 = result.data.find((e3) => e3.id === entityID);
72333                 if (entity2)
72334                   context.enter(modeSelect(context, [entityID]));
72335               });
72336             }
72337           });
72338           if (entity) {
72339             let name = utilDisplayName(entity);
72340             if (!name) {
72341               const preset = _mainPresetIndex.match(entity, context.graph());
72342               name = preset && !preset.isFallback() && preset.name();
72343             }
72344             if (name) {
72345               this.innerText = name;
72346             }
72347           }
72348         });
72349         context.features().forceVisible(d2.elems);
72350         context.map().pan([0, 0]);
72351       }).catch((err) => {
72352         console.log(err);
72353       });
72354     }
72355     osmoseDetails.issue = function(val) {
72356       if (!arguments.length)
72357         return _qaItem;
72358       _qaItem = val;
72359       return osmoseDetails;
72360     };
72361     return osmoseDetails;
72362   }
72363
72364   // modules/ui/osmose_header.js
72365   function uiOsmoseHeader() {
72366     let _qaItem;
72367     function issueTitle(d2) {
72368       const unknown = _t("inspector.unknown");
72369       if (!d2)
72370         return unknown;
72371       const s2 = services.osmose.getStrings(d2.itemType);
72372       return "title" in s2 ? s2.title : unknown;
72373     }
72374     function osmoseHeader(selection2) {
72375       const header = selection2.selectAll(".qa-header").data(
72376         _qaItem ? [_qaItem] : [],
72377         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72378       );
72379       header.exit().remove();
72380       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72381       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));
72382       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");
72383       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 : "");
72384       headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
72385     }
72386     osmoseHeader.issue = function(val) {
72387       if (!arguments.length)
72388         return _qaItem;
72389       _qaItem = val;
72390       return osmoseHeader;
72391     };
72392     return osmoseHeader;
72393   }
72394
72395   // modules/ui/view_on_osmose.js
72396   function uiViewOnOsmose() {
72397     let _qaItem;
72398     function viewOnOsmose(selection2) {
72399       let url;
72400       if (services.osmose && _qaItem instanceof QAItem) {
72401         url = services.osmose.itemURL(_qaItem);
72402       }
72403       const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
72404       link3.exit().remove();
72405       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"));
72406       linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
72407     }
72408     viewOnOsmose.what = function(val) {
72409       if (!arguments.length)
72410         return _qaItem;
72411       _qaItem = val;
72412       return viewOnOsmose;
72413     };
72414     return viewOnOsmose;
72415   }
72416
72417   // modules/ui/osmose_editor.js
72418   function uiOsmoseEditor(context) {
72419     const dispatch14 = dispatch_default("change");
72420     const qaDetails = uiOsmoseDetails(context);
72421     const qaHeader = uiOsmoseHeader(context);
72422     let _qaItem;
72423     function osmoseEditor(selection2) {
72424       const header = selection2.selectAll(".header").data([0]);
72425       const headerEnter = header.enter().append("div").attr("class", "header fillL");
72426       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72427       headerEnter.append("h2").call(_t.append("QA.osmose.title"));
72428       let body = selection2.selectAll(".body").data([0]);
72429       body = body.enter().append("div").attr("class", "body").merge(body);
72430       let editor = body.selectAll(".qa-editor").data([0]);
72431       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
72432       const footer = selection2.selectAll(".footer").data([0]);
72433       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
72434     }
72435     function osmoseSaveSection(selection2) {
72436       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72437       const isShown = _qaItem && isSelected;
72438       let saveSection = selection2.selectAll(".qa-save").data(
72439         isShown ? [_qaItem] : [],
72440         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72441       );
72442       saveSection.exit().remove();
72443       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72444       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72445     }
72446     function qaSaveButtons(selection2) {
72447       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72448       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72449       buttonSection.exit().remove();
72450       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72451       buttonEnter.append("button").attr("class", "button close-button action");
72452       buttonEnter.append("button").attr("class", "button ignore-button action");
72453       buttonSection = buttonSection.merge(buttonEnter);
72454       buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
72455         this.blur();
72456         const qaService = services.osmose;
72457         if (qaService) {
72458           d2.newStatus = "done";
72459           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72460         }
72461       });
72462       buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
72463         this.blur();
72464         const qaService = services.osmose;
72465         if (qaService) {
72466           d2.newStatus = "false";
72467           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72468         }
72469       });
72470     }
72471     osmoseEditor.error = function(val) {
72472       if (!arguments.length)
72473         return _qaItem;
72474       _qaItem = val;
72475       return osmoseEditor;
72476     };
72477     return utilRebind(osmoseEditor, dispatch14, "on");
72478   }
72479
72480   // modules/modes/select_error.js
72481   function modeSelectError(context, selectedErrorID, selectedErrorService) {
72482     var mode = {
72483       id: "select-error",
72484       button: "browse"
72485     };
72486     var keybinding = utilKeybinding("select-error");
72487     var errorService = services[selectedErrorService];
72488     var errorEditor;
72489     switch (selectedErrorService) {
72490       case "improveOSM":
72491         errorEditor = uiImproveOsmEditor(context).on("change", function() {
72492           context.map().pan([0, 0]);
72493           var error = checkSelectedID();
72494           if (!error)
72495             return;
72496           context.ui().sidebar.show(errorEditor.error(error));
72497         });
72498         break;
72499       case "keepRight":
72500         errorEditor = uiKeepRightEditor(context).on("change", function() {
72501           context.map().pan([0, 0]);
72502           var error = checkSelectedID();
72503           if (!error)
72504             return;
72505           context.ui().sidebar.show(errorEditor.error(error));
72506         });
72507         break;
72508       case "osmose":
72509         errorEditor = uiOsmoseEditor(context).on("change", function() {
72510           context.map().pan([0, 0]);
72511           var error = checkSelectedID();
72512           if (!error)
72513             return;
72514           context.ui().sidebar.show(errorEditor.error(error));
72515         });
72516         break;
72517     }
72518     var behaviors = [
72519       behaviorBreathe(context),
72520       behaviorHover(context),
72521       behaviorSelect(context),
72522       behaviorLasso(context),
72523       modeDragNode(context).behavior,
72524       modeDragNote(context).behavior
72525     ];
72526     function checkSelectedID() {
72527       if (!errorService)
72528         return;
72529       var error = errorService.getError(selectedErrorID);
72530       if (!error) {
72531         context.enter(modeBrowse(context));
72532       }
72533       return error;
72534     }
72535     mode.zoomToSelected = function() {
72536       if (!errorService)
72537         return;
72538       var error = errorService.getError(selectedErrorID);
72539       if (error) {
72540         context.map().centerZoomEase(error.loc, 20);
72541       }
72542     };
72543     mode.enter = function() {
72544       var error = checkSelectedID();
72545       if (!error)
72546         return;
72547       behaviors.forEach(context.install);
72548       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
72549       select_default2(document).call(keybinding);
72550       selectError();
72551       var sidebar = context.ui().sidebar;
72552       sidebar.show(errorEditor.error(error));
72553       context.map().on("drawn.select-error", selectError);
72554       function selectError(d3_event, drawn) {
72555         if (!checkSelectedID())
72556           return;
72557         var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
72558         if (selection2.empty()) {
72559           var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
72560           if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
72561             context.enter(modeBrowse(context));
72562           }
72563         } else {
72564           selection2.classed("selected", true);
72565           context.selectedErrorID(selectedErrorID);
72566         }
72567       }
72568       function esc() {
72569         if (context.container().select(".combobox").size())
72570           return;
72571         context.enter(modeBrowse(context));
72572       }
72573     };
72574     mode.exit = function() {
72575       behaviors.forEach(context.uninstall);
72576       select_default2(document).call(keybinding.unbind);
72577       context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
72578       context.map().on("drawn.select-error", null);
72579       context.ui().sidebar.hide();
72580       context.selectedErrorID(null);
72581       context.features().forceVisible([]);
72582     };
72583     return mode;
72584   }
72585
72586   // modules/ui/feature_list.js
72587   function uiFeatureList(context) {
72588     var _geocodeResults;
72589     function featureList(selection2) {
72590       var header = selection2.append("div").attr("class", "header fillL");
72591       header.append("h2").call(_t.append("inspector.feature_list"));
72592       var searchWrap = selection2.append("div").attr("class", "search-header");
72593       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72594       var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
72595       var listWrap = selection2.append("div").attr("class", "inspector-body");
72596       var list2 = listWrap.append("div").attr("class", "feature-list");
72597       context.on("exit.feature-list", clearSearch);
72598       context.map().on("drawn.feature-list", mapDrawn);
72599       context.keybinding().on(uiCmd("\u2318F"), focusSearch);
72600       function focusSearch(d3_event) {
72601         var mode = context.mode() && context.mode().id;
72602         if (mode !== "browse")
72603           return;
72604         d3_event.preventDefault();
72605         search.node().focus();
72606       }
72607       function keydown(d3_event) {
72608         if (d3_event.keyCode === 27) {
72609           search.node().blur();
72610         }
72611       }
72612       function keypress(d3_event) {
72613         var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
72614         if (d3_event.keyCode === 13 && // ↩ Return
72615         q2.length && items.size()) {
72616           click(d3_event, items.datum());
72617         }
72618       }
72619       function inputevent() {
72620         _geocodeResults = void 0;
72621         drawList();
72622       }
72623       function clearSearch() {
72624         search.property("value", "");
72625         drawList();
72626       }
72627       function mapDrawn(e3) {
72628         if (e3.full) {
72629           drawList();
72630         }
72631       }
72632       function features() {
72633         var result = [];
72634         var graph = context.graph();
72635         var visibleCenter = context.map().extent().center();
72636         var q2 = search.property("value").toLowerCase();
72637         if (!q2)
72638           return result;
72639         var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
72640         if (locationMatch) {
72641           var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
72642           result.push({
72643             id: -1,
72644             geometry: "point",
72645             type: _t("inspector.location"),
72646             name: dmsCoordinatePair([loc[1], loc[0]]),
72647             location: loc
72648           });
72649         }
72650         var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
72651         if (idMatch) {
72652           var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
72653           var elemId = idMatch[2];
72654           result.push({
72655             id: elemType + elemId,
72656             geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
72657             type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
72658             name: elemId
72659           });
72660         }
72661         var allEntities = graph.entities;
72662         var localResults = [];
72663         for (var id2 in allEntities) {
72664           var entity = allEntities[id2];
72665           if (!entity)
72666             continue;
72667           var name = utilDisplayName(entity) || "";
72668           if (name.toLowerCase().indexOf(q2) < 0)
72669             continue;
72670           var matched = _mainPresetIndex.match(entity, graph);
72671           var type2 = matched && matched.name() || utilDisplayType(entity.id);
72672           var extent = entity.extent(graph);
72673           var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
72674           localResults.push({
72675             id: entity.id,
72676             entity,
72677             geometry: entity.geometry(graph),
72678             type: type2,
72679             name,
72680             distance
72681           });
72682           if (localResults.length > 100)
72683             break;
72684         }
72685         localResults = localResults.sort(function byDistance(a2, b2) {
72686           return a2.distance - b2.distance;
72687         });
72688         result = result.concat(localResults);
72689         (_geocodeResults || []).forEach(function(d2) {
72690           if (d2.osm_type && d2.osm_id) {
72691             var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
72692             var tags = {};
72693             tags[d2.class] = d2.type;
72694             var attrs = { id: id3, type: d2.osm_type, tags };
72695             if (d2.osm_type === "way") {
72696               attrs.nodes = ["a", "a"];
72697             }
72698             var tempEntity = osmEntity(attrs);
72699             var tempGraph = coreGraph([tempEntity]);
72700             var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
72701             var type3 = matched2 && matched2.name() || utilDisplayType(id3);
72702             result.push({
72703               id: tempEntity.id,
72704               geometry: tempEntity.geometry(tempGraph),
72705               type: type3,
72706               name: d2.display_name,
72707               extent: new geoExtent(
72708                 [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
72709                 [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
72710               )
72711             });
72712           }
72713         });
72714         if (q2.match(/^[0-9]+$/)) {
72715           result.push({
72716             id: "n" + q2,
72717             geometry: "point",
72718             type: _t("inspector.node"),
72719             name: q2
72720           });
72721           result.push({
72722             id: "w" + q2,
72723             geometry: "line",
72724             type: _t("inspector.way"),
72725             name: q2
72726           });
72727           result.push({
72728             id: "r" + q2,
72729             geometry: "relation",
72730             type: _t("inspector.relation"),
72731             name: q2
72732           });
72733           result.push({
72734             id: "note" + q2,
72735             geometry: "note",
72736             type: _t("note.note"),
72737             name: q2
72738           });
72739         }
72740         return result;
72741       }
72742       function drawList() {
72743         var value = search.property("value");
72744         var results = features();
72745         list2.classed("filtered", value.length);
72746         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"));
72747         resultsIndicator.append("span").attr("class", "entity-name");
72748         list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
72749         if (services.geocoder) {
72750           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"));
72751         }
72752         list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
72753         list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
72754         list2.selectAll(".feature-list-item").data([-1]).remove();
72755         var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
72756           return d2.id;
72757         });
72758         var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
72759         var label = enter.append("div").attr("class", "label");
72760         label.each(function(d2) {
72761           select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
72762         });
72763         label.append("span").attr("class", "entity-type").text(function(d2) {
72764           return d2.type;
72765         });
72766         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) {
72767           return d2.name;
72768         });
72769         enter.style("opacity", 0).transition().style("opacity", 1);
72770         items.order();
72771         items.exit().remove();
72772       }
72773       function mouseover(d3_event, d2) {
72774         if (d2.id === -1)
72775           return;
72776         utilHighlightEntities([d2.id], true, context);
72777       }
72778       function mouseout(d3_event, d2) {
72779         if (d2.id === -1)
72780           return;
72781         utilHighlightEntities([d2.id], false, context);
72782       }
72783       function click(d3_event, d2) {
72784         d3_event.preventDefault();
72785         if (d2.location) {
72786           context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
72787         } else if (d2.entity) {
72788           utilHighlightEntities([d2.id], false, context);
72789           context.enter(modeSelect(context, [d2.entity.id]));
72790           context.map().zoomToEase(d2.entity);
72791         } else if (d2.geometry === "note") {
72792           const noteId = d2.id.replace(/\D/g, "");
72793           context.loadNote(noteId, (err, result) => {
72794             if (err)
72795               return;
72796             const entity = result.data.find((e3) => e3.id === noteId);
72797             if (entity) {
72798               const note = services.osm.getNote(noteId);
72799               context.map().centerZoom(note.loc, 15);
72800               const noteLayer = context.layers().layer("notes");
72801               noteLayer.enabled(true);
72802               context.enter(modeSelectNote(context, noteId));
72803             }
72804           });
72805         } else {
72806           context.zoomToEntity(d2.id);
72807         }
72808       }
72809       function geocoderSearch() {
72810         services.geocoder.search(search.property("value"), function(err, resp) {
72811           _geocodeResults = resp || [];
72812           drawList();
72813         });
72814       }
72815     }
72816     return featureList;
72817   }
72818
72819   // modules/ui/preset_list.js
72820   function uiPresetList(context) {
72821     var dispatch14 = dispatch_default("cancel", "choose");
72822     var _entityIDs;
72823     var _currLoc;
72824     var _currentPresets;
72825     var _autofocus = false;
72826     function presetList(selection2) {
72827       if (!_entityIDs)
72828         return;
72829       var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
72830       selection2.html("");
72831       var messagewrap = selection2.append("div").attr("class", "header fillL");
72832       var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
72833       var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward";
72834       messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
72835         dispatch14.call("cancel", this);
72836       }).call(svgIcon("#iD-icon-".concat(direction)));
72837       function initialKeydown(d3_event) {
72838         if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
72839           d3_event.preventDefault();
72840           d3_event.stopPropagation();
72841           operationDelete(context, _entityIDs)();
72842         } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
72843           d3_event.preventDefault();
72844           d3_event.stopPropagation();
72845           context.undo();
72846         } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
72847           select_default2(this).on("keydown", keydown);
72848           keydown.call(this, d3_event);
72849         }
72850       }
72851       function keydown(d3_event) {
72852         if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
72853         search.node().selectionStart === search.property("value").length) {
72854           d3_event.preventDefault();
72855           d3_event.stopPropagation();
72856           var buttons = list2.selectAll(".preset-list-button");
72857           if (!buttons.empty())
72858             buttons.nodes()[0].focus();
72859         }
72860       }
72861       function keypress(d3_event) {
72862         var value = search.property("value");
72863         if (d3_event.keyCode === 13 && // ↩ Return
72864         value.length) {
72865           list2.selectAll(".preset-list-item:first-child").each(function(d2) {
72866             d2.choose.call(this);
72867           });
72868         }
72869       }
72870       function inputevent() {
72871         var value = search.property("value");
72872         list2.classed("filtered", value.length);
72873         var results, messageText;
72874         if (value.length) {
72875           results = presets.search(value, entityGeometries()[0], _currLoc);
72876           messageText = _t.html("inspector.results", {
72877             n: results.collection.length,
72878             search: value
72879           });
72880         } else {
72881           var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72882           results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
72883           messageText = _t.html("inspector.choose");
72884         }
72885         list2.call(drawList, results);
72886         message.html(messageText);
72887       }
72888       var searchWrap = selection2.append("div").attr("class", "search-header");
72889       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72890       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));
72891       if (_autofocus) {
72892         search.node().focus();
72893         setTimeout(function() {
72894           search.node().focus();
72895         }, 0);
72896       }
72897       var listWrap = selection2.append("div").attr("class", "inspector-body");
72898       var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72899       var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
72900       context.features().on("change.preset-list", updateForFeatureHiddenState);
72901     }
72902     function drawList(list2, presets) {
72903       presets = presets.matchAllGeometry(entityGeometries());
72904       var collection = presets.collection.reduce(function(collection2, preset) {
72905         if (!preset)
72906           return collection2;
72907         if (preset.members) {
72908           if (preset.members.collection.filter(function(preset2) {
72909             return preset2.addable();
72910           }).length > 1) {
72911             collection2.push(CategoryItem(preset));
72912           }
72913         } else if (preset.addable()) {
72914           collection2.push(PresetItem(preset));
72915         }
72916         return collection2;
72917       }, []);
72918       var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
72919         return d2.preset.id;
72920       });
72921       items.order();
72922       items.exit().remove();
72923       items.enter().append("div").attr("class", function(item) {
72924         return "preset-list-item preset-" + item.preset.id.replace("/", "-");
72925       }).classed("current", function(item) {
72926         return _currentPresets.indexOf(item.preset) !== -1;
72927       }).each(function(item) {
72928         select_default2(this).call(item);
72929       }).style("opacity", 0).transition().style("opacity", 1);
72930       updateForFeatureHiddenState();
72931     }
72932     function itemKeydown(d3_event) {
72933       var item = select_default2(this.closest(".preset-list-item"));
72934       var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
72935       if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
72936         d3_event.preventDefault();
72937         d3_event.stopPropagation();
72938         var nextItem = select_default2(item.node().nextElementSibling);
72939         if (nextItem.empty()) {
72940           if (!parentItem.empty()) {
72941             nextItem = select_default2(parentItem.node().nextElementSibling);
72942           }
72943         } else if (select_default2(this).classed("expanded")) {
72944           nextItem = item.select(".subgrid .preset-list-item:first-child");
72945         }
72946         if (!nextItem.empty()) {
72947           nextItem.select(".preset-list-button").node().focus();
72948         }
72949       } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
72950         d3_event.preventDefault();
72951         d3_event.stopPropagation();
72952         var previousItem = select_default2(item.node().previousElementSibling);
72953         if (previousItem.empty()) {
72954           if (!parentItem.empty()) {
72955             previousItem = parentItem;
72956           }
72957         } else if (previousItem.select(".preset-list-button").classed("expanded")) {
72958           previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
72959         }
72960         if (!previousItem.empty()) {
72961           previousItem.select(".preset-list-button").node().focus();
72962         } else {
72963           var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
72964           search.node().focus();
72965         }
72966       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
72967         d3_event.preventDefault();
72968         d3_event.stopPropagation();
72969         if (!parentItem.empty()) {
72970           parentItem.select(".preset-list-button").node().focus();
72971         }
72972       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
72973         d3_event.preventDefault();
72974         d3_event.stopPropagation();
72975         item.datum().choose.call(select_default2(this).node());
72976       }
72977     }
72978     function CategoryItem(preset) {
72979       var box, sublist, shown = false;
72980       function item(selection2) {
72981         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
72982         function click() {
72983           var isExpanded = select_default2(this).classed("expanded");
72984           var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
72985           select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
72986           select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
72987           item.choose();
72988         }
72989         var geometries = entityGeometries();
72990         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) {
72991           if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
72992             d3_event.preventDefault();
72993             d3_event.stopPropagation();
72994             if (!select_default2(this).classed("expanded")) {
72995               click.call(this, d3_event);
72996             }
72997           } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
72998             d3_event.preventDefault();
72999             d3_event.stopPropagation();
73000             if (select_default2(this).classed("expanded")) {
73001               click.call(this, d3_event);
73002             }
73003           } else {
73004             itemKeydown.call(this, d3_event);
73005           }
73006         });
73007         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73008         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");
73009         box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
73010         box.append("div").attr("class", "arrow");
73011         sublist = box.append("div").attr("class", "preset-list fillL3");
73012       }
73013       item.choose = function() {
73014         if (!box || !sublist)
73015           return;
73016         if (shown) {
73017           shown = false;
73018           box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
73019         } else {
73020           shown = true;
73021           var members = preset.members.matchAllGeometry(entityGeometries());
73022           sublist.call(drawList, members);
73023           box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
73024         }
73025       };
73026       item.preset = preset;
73027       return item;
73028     }
73029     function PresetItem(preset) {
73030       function item(selection2) {
73031         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
73032         var geometries = entityGeometries();
73033         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);
73034         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73035         var nameparts = [
73036           preset.nameLabel(),
73037           preset.subtitleLabel()
73038         ].filter(Boolean);
73039         label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
73040           d2(select_default2(this));
73041         });
73042         wrap2.call(item.reference.button);
73043         selection2.call(item.reference.body);
73044       }
73045       item.choose = function() {
73046         if (select_default2(this).classed("disabled"))
73047           return;
73048         if (!context.inIntro()) {
73049           _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
73050         }
73051         context.perform(
73052           function(graph) {
73053             for (var i3 in _entityIDs) {
73054               var entityID = _entityIDs[i3];
73055               var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
73056               graph = actionChangePreset(entityID, oldPreset, preset)(graph);
73057             }
73058             return graph;
73059           },
73060           _t("operations.change_tags.annotation")
73061         );
73062         context.validator().validate();
73063         dispatch14.call("choose", this, preset);
73064       };
73065       item.help = function(d3_event) {
73066         d3_event.stopPropagation();
73067         item.reference.toggle();
73068       };
73069       item.preset = preset;
73070       item.reference = uiTagReference(preset.reference(), context);
73071       return item;
73072     }
73073     function updateForFeatureHiddenState() {
73074       if (!_entityIDs.every(context.hasEntity))
73075         return;
73076       var geometries = entityGeometries();
73077       var button = context.container().selectAll(".preset-list .preset-list-button");
73078       button.call(uiTooltip().destroyAny);
73079       button.each(function(item, index) {
73080         var hiddenPresetFeaturesId;
73081         for (var i3 in geometries) {
73082           hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
73083           if (hiddenPresetFeaturesId)
73084             break;
73085         }
73086         var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
73087         select_default2(this).classed("disabled", isHiddenPreset);
73088         if (isHiddenPreset) {
73089           var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
73090           select_default2(this).call(
73091             uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
73092               features: _t("feature." + hiddenPresetFeaturesId + ".description")
73093             })).placement(index < 2 ? "bottom" : "top")
73094           );
73095         }
73096       });
73097     }
73098     presetList.autofocus = function(val) {
73099       if (!arguments.length)
73100         return _autofocus;
73101       _autofocus = val;
73102       return presetList;
73103     };
73104     presetList.entityIDs = function(val) {
73105       if (!arguments.length)
73106         return _entityIDs;
73107       _entityIDs = val;
73108       _currLoc = null;
73109       if (_entityIDs && _entityIDs.length) {
73110         const extent = _entityIDs.reduce(function(extent2, entityID) {
73111           var entity = context.graph().entity(entityID);
73112           return extent2.extend(entity.extent(context.graph()));
73113         }, geoExtent());
73114         _currLoc = extent.center();
73115         var presets = _entityIDs.map(function(entityID) {
73116           return _mainPresetIndex.match(context.entity(entityID), context.graph());
73117         });
73118         presetList.presets(presets);
73119       }
73120       return presetList;
73121     };
73122     presetList.presets = function(val) {
73123       if (!arguments.length)
73124         return _currentPresets;
73125       _currentPresets = val;
73126       return presetList;
73127     };
73128     function entityGeometries() {
73129       var counts = {};
73130       for (var i3 in _entityIDs) {
73131         var entityID = _entityIDs[i3];
73132         var entity = context.entity(entityID);
73133         var geometry = entity.geometry(context.graph());
73134         if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
73135           geometry = "point";
73136         }
73137         if (!counts[geometry])
73138           counts[geometry] = 0;
73139         counts[geometry] += 1;
73140       }
73141       return Object.keys(counts).sort(function(geom1, geom2) {
73142         return counts[geom2] - counts[geom1];
73143       });
73144     }
73145     return utilRebind(presetList, dispatch14, "on");
73146   }
73147
73148   // modules/ui/inspector.js
73149   function uiInspector(context) {
73150     var presetList = uiPresetList(context);
73151     var entityEditor = uiEntityEditor(context);
73152     var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
73153     var _state = "select";
73154     var _entityIDs;
73155     var _newFeature = false;
73156     function inspector(selection2) {
73157       presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
73158         inspector.setPreset();
73159       });
73160       entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
73161       wrap2 = selection2.selectAll(".panewrap").data([0]);
73162       var enter = wrap2.enter().append("div").attr("class", "panewrap");
73163       enter.append("div").attr("class", "preset-list-pane pane");
73164       enter.append("div").attr("class", "entity-editor-pane pane");
73165       wrap2 = wrap2.merge(enter);
73166       presetPane = wrap2.selectAll(".preset-list-pane");
73167       editorPane = wrap2.selectAll(".entity-editor-pane");
73168       function shouldDefaultToPresetList() {
73169         if (_state !== "select")
73170           return false;
73171         if (_entityIDs.length !== 1)
73172           return false;
73173         var entityID = _entityIDs[0];
73174         var entity = context.hasEntity(entityID);
73175         if (!entity)
73176           return false;
73177         if (entity.hasNonGeometryTags())
73178           return false;
73179         if (_newFeature)
73180           return true;
73181         if (entity.geometry(context.graph()) !== "vertex")
73182           return false;
73183         if (context.graph().parentRelations(entity).length)
73184           return false;
73185         if (context.validator().getEntityIssues(entityID).length)
73186           return false;
73187         if (entity.isHighwayIntersection(context.graph()))
73188           return false;
73189         return true;
73190       }
73191       if (shouldDefaultToPresetList()) {
73192         wrap2.style("right", "-100%");
73193         editorPane.classed("hide", true);
73194         presetPane.classed("hide", false).call(presetList);
73195       } else {
73196         wrap2.style("right", "0%");
73197         presetPane.classed("hide", true);
73198         editorPane.classed("hide", false).call(entityEditor);
73199       }
73200       var footer = selection2.selectAll(".footer").data([0]);
73201       footer = footer.enter().append("div").attr("class", "footer").merge(footer);
73202       footer.call(
73203         uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
73204       );
73205     }
73206     inspector.showList = function(presets) {
73207       presetPane.classed("hide", false);
73208       wrap2.transition().styleTween("right", function() {
73209         return value_default("0%", "-100%");
73210       }).on("end", function() {
73211         editorPane.classed("hide", true);
73212       });
73213       if (presets) {
73214         presetList.presets(presets);
73215       }
73216       presetPane.call(presetList.autofocus(true));
73217     };
73218     inspector.setPreset = function(preset) {
73219       if (preset && preset.id === "type/multipolygon") {
73220         presetPane.call(presetList.autofocus(true));
73221       } else {
73222         editorPane.classed("hide", false);
73223         wrap2.transition().styleTween("right", function() {
73224           return value_default("-100%", "0%");
73225         }).on("end", function() {
73226           presetPane.classed("hide", true);
73227         });
73228         if (preset) {
73229           entityEditor.presets([preset]);
73230         }
73231         editorPane.call(entityEditor);
73232       }
73233     };
73234     inspector.state = function(val) {
73235       if (!arguments.length)
73236         return _state;
73237       _state = val;
73238       entityEditor.state(_state);
73239       context.container().selectAll(".field-help-body").remove();
73240       return inspector;
73241     };
73242     inspector.entityIDs = function(val) {
73243       if (!arguments.length)
73244         return _entityIDs;
73245       _entityIDs = val;
73246       return inspector;
73247     };
73248     inspector.newFeature = function(val) {
73249       if (!arguments.length)
73250         return _newFeature;
73251       _newFeature = val;
73252       return inspector;
73253     };
73254     return inspector;
73255   }
73256
73257   // modules/ui/lasso.js
73258   function uiLasso(context) {
73259     var group, polygon2;
73260     lasso.coordinates = [];
73261     function lasso(selection2) {
73262       context.container().classed("lasso", true);
73263       group = selection2.append("g").attr("class", "lasso hide");
73264       polygon2 = group.append("path").attr("class", "lasso-path");
73265       group.call(uiToggle(true));
73266     }
73267     function draw() {
73268       if (polygon2) {
73269         polygon2.data([lasso.coordinates]).attr("d", function(d2) {
73270           return "M" + d2.join(" L") + " Z";
73271         });
73272       }
73273     }
73274     lasso.extent = function() {
73275       return lasso.coordinates.reduce(function(extent, point2) {
73276         return extent.extend(geoExtent(point2));
73277       }, geoExtent());
73278     };
73279     lasso.p = function(_2) {
73280       if (!arguments.length)
73281         return lasso;
73282       lasso.coordinates.push(_2);
73283       draw();
73284       return lasso;
73285     };
73286     lasso.close = function() {
73287       if (group) {
73288         group.call(uiToggle(false, function() {
73289           select_default2(this).remove();
73290         }));
73291       }
73292       context.container().classed("lasso", false);
73293     };
73294     return lasso;
73295   }
73296
73297   // modules/ui/source_switch.js
73298   function uiSourceSwitch(context) {
73299     var keys2;
73300     function click(d3_event) {
73301       d3_event.preventDefault();
73302       var osm = context.connection();
73303       if (!osm)
73304         return;
73305       if (context.inIntro())
73306         return;
73307       if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes")))
73308         return;
73309       var isLive = select_default2(this).classed("live");
73310       isLive = !isLive;
73311       context.enter(modeBrowse(context));
73312       context.history().clearSaved();
73313       context.flush();
73314       select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
73315       osm.switch(isLive ? keys2[0] : keys2[1]);
73316     }
73317     var sourceSwitch = function(selection2) {
73318       selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
73319     };
73320     sourceSwitch.keys = function(_2) {
73321       if (!arguments.length)
73322         return keys2;
73323       keys2 = _2;
73324       return sourceSwitch;
73325     };
73326     return sourceSwitch;
73327   }
73328
73329   // modules/ui/spinner.js
73330   function uiSpinner(context) {
73331     var osm = context.connection();
73332     return function(selection2) {
73333       var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
73334       if (osm) {
73335         osm.on("loading.spinner", function() {
73336           img.transition().style("opacity", 1);
73337         }).on("loaded.spinner", function() {
73338           img.transition().style("opacity", 0);
73339         });
73340       }
73341     };
73342   }
73343
73344   // modules/ui/sections/privacy.js
73345   function uiSectionPrivacy(context) {
73346     let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
73347     function renderDisclosureContent(selection2) {
73348       selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
73349       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(
73350         uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
73351       );
73352       thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
73353         d3_event.preventDefault();
73354         corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
73355       });
73356       thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
73357       selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
73358       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"));
73359     }
73360     corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
73361     return section;
73362   }
73363
73364   // modules/ui/splash.js
73365   function uiSplash(context) {
73366     return (selection2) => {
73367       if (context.history().hasRestorableChanges())
73368         return;
73369       let updateMessage = "";
73370       const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
73371       let showSplash = !corePreferences("sawSplash");
73372       if (sawPrivacyVersion !== context.privacyVersion) {
73373         updateMessage = _t("splash.privacy_update");
73374         showSplash = true;
73375       }
73376       if (!showSplash)
73377         return;
73378       corePreferences("sawSplash", true);
73379       corePreferences("sawPrivacyVersion", context.privacyVersion);
73380       _mainFileFetcher.get("intro_graph");
73381       let modalSelection = uiModal(selection2);
73382       modalSelection.select(".modal").attr("class", "modal-splash modal");
73383       let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
73384       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
73385       let modalSection = introModal.append("div").attr("class", "modal-section");
73386       modalSection.append("p").html(_t.html("splash.text", {
73387         version: context.version,
73388         website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
73389         github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
73390       }));
73391       modalSection.append("p").html(_t.html("splash.privacy", {
73392         updateMessage,
73393         privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
73394       }));
73395       uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
73396       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
73397       let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
73398         context.container().call(uiIntro(context));
73399         modalSelection.close();
73400       });
73401       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
73402       walkthrough.append("div").call(_t.append("splash.walkthrough"));
73403       let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
73404       startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
73405       startEditing.append("div").call(_t.append("splash.start"));
73406       modalSelection.select("button.close").attr("class", "hide");
73407     };
73408   }
73409
73410   // modules/ui/status.js
73411   function uiStatus(context) {
73412     var osm = context.connection();
73413     return function(selection2) {
73414       if (!osm)
73415         return;
73416       function update(err, apiStatus) {
73417         selection2.html("");
73418         if (err) {
73419           if (apiStatus === "connectionSwitched") {
73420             return;
73421           } else if (apiStatus === "rateLimited") {
73422             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) {
73423               d3_event.preventDefault();
73424               osm.authenticate();
73425             });
73426           } else {
73427             var throttledRetry = throttle_default(function() {
73428               context.loadTiles(context.projection);
73429               osm.reloadApiStatus();
73430             }, 2e3);
73431             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) {
73432               d3_event.preventDefault();
73433               throttledRetry();
73434             });
73435           }
73436         } else if (apiStatus === "readonly") {
73437           selection2.call(_t.append("osm_api_status.message.readonly"));
73438         } else if (apiStatus === "offline") {
73439           selection2.call(_t.append("osm_api_status.message.offline"));
73440         }
73441         selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
73442       }
73443       osm.on("apiStatusChange.uiStatus", update);
73444       context.history().on("storage_error", () => {
73445         selection2.selectAll("span.local-storage-full").remove();
73446         selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
73447         selection2.classed("error", true);
73448       });
73449       window.setInterval(function() {
73450         osm.reloadApiStatus();
73451       }, 9e4);
73452       osm.reloadApiStatus();
73453     };
73454   }
73455
73456   // modules/ui/version.js
73457   var sawVersion = null;
73458   var isNewVersion = false;
73459   var isNewUser = false;
73460   function uiVersion(context) {
73461     var currVersion = context.version;
73462     var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
73463     if (sawVersion === null && matchedVersion !== null) {
73464       if (corePreferences("sawVersion")) {
73465         isNewUser = false;
73466         isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
73467       } else {
73468         isNewUser = true;
73469         isNewVersion = true;
73470       }
73471       corePreferences("sawVersion", currVersion);
73472       sawVersion = currVersion;
73473     }
73474     return function(selection2) {
73475       selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
73476       if (isNewVersion && !isNewUser) {
73477         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(
73478           uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
73479         );
73480       }
73481     };
73482   }
73483
73484   // modules/ui/zoom.js
73485   function uiZoom(context) {
73486     var zooms = [{
73487       id: "zoom-in",
73488       icon: "iD-icon-plus",
73489       title: _t.append("zoom.in"),
73490       action: zoomIn,
73491       disabled: function() {
73492         return !context.map().canZoomIn();
73493       },
73494       disabledTitle: _t.append("zoom.disabled.in"),
73495       key: "+"
73496     }, {
73497       id: "zoom-out",
73498       icon: "iD-icon-minus",
73499       title: _t.append("zoom.out"),
73500       action: zoomOut,
73501       disabled: function() {
73502         return !context.map().canZoomOut();
73503       },
73504       disabledTitle: _t.append("zoom.disabled.out"),
73505       key: "-"
73506     }];
73507     function zoomIn(d3_event) {
73508       if (d3_event.shiftKey)
73509         return;
73510       d3_event.preventDefault();
73511       context.map().zoomIn();
73512     }
73513     function zoomOut(d3_event) {
73514       if (d3_event.shiftKey)
73515         return;
73516       d3_event.preventDefault();
73517       context.map().zoomOut();
73518     }
73519     function zoomInFurther(d3_event) {
73520       if (d3_event.shiftKey)
73521         return;
73522       d3_event.preventDefault();
73523       context.map().zoomInFurther();
73524     }
73525     function zoomOutFurther(d3_event) {
73526       if (d3_event.shiftKey)
73527         return;
73528       d3_event.preventDefault();
73529       context.map().zoomOutFurther();
73530     }
73531     return function(selection2) {
73532       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
73533         if (d2.disabled()) {
73534           return d2.disabledTitle;
73535         }
73536         return d2.title;
73537       }).keys(function(d2) {
73538         return [d2.key];
73539       });
73540       var lastPointerUpType;
73541       var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
73542         return d2.id;
73543       }).on("pointerup.editor", function(d3_event) {
73544         lastPointerUpType = d3_event.pointerType;
73545       }).on("click.editor", function(d3_event, d2) {
73546         if (!d2.disabled()) {
73547           d2.action(d3_event);
73548         } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
73549           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
73550         }
73551         lastPointerUpType = null;
73552       }).call(tooltipBehavior);
73553       buttons.each(function(d2) {
73554         select_default2(this).call(svgIcon("#" + d2.icon, "light"));
73555       });
73556       utilKeybinding.plusKeys.forEach(function(key) {
73557         context.keybinding().on([key], zoomIn);
73558         context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
73559       });
73560       utilKeybinding.minusKeys.forEach(function(key) {
73561         context.keybinding().on([key], zoomOut);
73562         context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
73563       });
73564       function updateButtonStates() {
73565         buttons.classed("disabled", function(d2) {
73566           return d2.disabled();
73567         }).each(function() {
73568           var selection3 = select_default2(this);
73569           if (!selection3.select(".tooltip.in").empty()) {
73570             selection3.call(tooltipBehavior.updateContent);
73571           }
73572         });
73573       }
73574       updateButtonStates();
73575       context.map().on("move.uiZoom", updateButtonStates);
73576     };
73577   }
73578
73579   // modules/ui/sections/raw_tag_editor.js
73580   function uiSectionRawTagEditor(id2, context) {
73581     var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
73582       var count = Object.keys(_tags).filter(function(d2) {
73583         return d2;
73584       }).length;
73585       return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
73586     }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
73587     var taginfo = services.taginfo;
73588     var dispatch14 = dispatch_default("change");
73589     var availableViews = [
73590       { id: "list", icon: "#fas-th-list" },
73591       { id: "text", icon: "#fas-i-cursor" }
73592     ];
73593     let _discardTags = {};
73594     _mainFileFetcher.get("discarded").then((d2) => {
73595       _discardTags = d2;
73596     }).catch(() => {
73597     });
73598     var _tagView = corePreferences("raw-tag-editor-view") || "list";
73599     var _readOnlyTags = [];
73600     var _orderedKeys = [];
73601     var _showBlank = false;
73602     var _pendingChange = null;
73603     var _state;
73604     var _presets;
73605     var _tags;
73606     var _entityIDs;
73607     var _didInteract = false;
73608     function interacted() {
73609       _didInteract = true;
73610     }
73611     function renderDisclosureContent(wrap2) {
73612       _orderedKeys = _orderedKeys.filter(function(key) {
73613         return _tags[key] !== void 0;
73614       });
73615       var all = Object.keys(_tags).sort();
73616       var missingKeys = utilArrayDifference(all, _orderedKeys);
73617       for (var i3 in missingKeys) {
73618         _orderedKeys.push(missingKeys[i3]);
73619       }
73620       var rowData = _orderedKeys.map(function(key, i4) {
73621         return { index: i4, key, value: _tags[key] };
73622       });
73623       if (!rowData.length || _showBlank) {
73624         _showBlank = false;
73625         rowData.push({ index: rowData.length, key: "", value: "" });
73626       }
73627       var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
73628       options2.exit().remove();
73629       var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
73630       var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
73631         return d2.id;
73632       }).enter();
73633       optionEnter.append("button").attr("class", function(d2) {
73634         return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
73635       }).attr("aria-selected", function(d2) {
73636         return _tagView === d2.id;
73637       }).attr("role", "tab").attr("title", function(d2) {
73638         return _t("icons." + d2.id);
73639       }).on("click", function(d3_event, d2) {
73640         _tagView = d2.id;
73641         corePreferences("raw-tag-editor-view", d2.id);
73642         wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
73643           return datum2 === d2;
73644         }).attr("aria-selected", function(datum2) {
73645           return datum2 === d2;
73646         });
73647         wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
73648         wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
73649       }).each(function(d2) {
73650         select_default2(this).call(svgIcon(d2.icon));
73651       });
73652       var textData = rowsToText(rowData);
73653       var textarea = wrap2.selectAll(".tag-text").data([0]);
73654       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);
73655       textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
73656       var list2 = wrap2.selectAll(".tag-list").data([0]);
73657       list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
73658       var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
73659       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);
73660       addRowEnter.append("div").attr("class", "space-value");
73661       addRowEnter.append("div").attr("class", "space-buttons");
73662       var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
73663         return d2.key;
73664       });
73665       items.exit().each(unbind).remove();
73666       var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
73667       var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
73668       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);
73669       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);
73670       innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
73671       items = items.merge(itemsEnter).sort(function(a2, b2) {
73672         return a2.index - b2.index;
73673       });
73674       items.each(function(d2) {
73675         var row = select_default2(this);
73676         var key = row.select("input.key");
73677         var value = row.select("input.value");
73678         if (_entityIDs && taginfo && _state !== "hover") {
73679           bindTypeahead(key, value);
73680         }
73681         var referenceOptions = { key: d2.key };
73682         if (typeof d2.value === "string") {
73683           referenceOptions.value = d2.value;
73684         }
73685         var reference = uiTagReference(referenceOptions, context);
73686         if (_state === "hover") {
73687           reference.showing(false);
73688         }
73689         row.select(".inner-wrap").call(reference.button);
73690         row.call(reference.body);
73691         row.select("button.remove");
73692       });
73693       items.selectAll("input.key").attr("title", function(d2) {
73694         return d2.key;
73695       }).call(utilGetSetValue, function(d2) {
73696         return d2.key;
73697       }).attr("readonly", function(d2) {
73698         return isReadOnly(d2) || null;
73699       });
73700       items.selectAll("input.value").attr("title", function(d2) {
73701         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
73702       }).classed("mixed", function(d2) {
73703         return Array.isArray(d2.value);
73704       }).attr("placeholder", function(d2) {
73705         return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
73706       }).call(utilGetSetValue, function(d2) {
73707         return typeof d2.value === "string" ? d2.value : "";
73708       }).attr("readonly", function(d2) {
73709         return isReadOnly(d2) || null;
73710       });
73711       items.selectAll("button.remove").on(
73712         ("PointerEvent" in window ? "pointer" : "mouse") + "down",
73713         // 'click' fires too late - #5878
73714         (d3_event, d2) => {
73715           if (d3_event.button !== 0)
73716             return;
73717           removeTag(d3_event, d2);
73718         }
73719       );
73720     }
73721     function isReadOnly(d2) {
73722       for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
73723         if (d2.key.match(_readOnlyTags[i3]) !== null) {
73724           return true;
73725         }
73726       }
73727       return false;
73728     }
73729     function setTextareaHeight() {
73730       if (_tagView !== "text")
73731         return;
73732       var selection2 = select_default2(this);
73733       var matches = selection2.node().value.match(/\n/g);
73734       var lineCount = 2 + Number(matches && matches.length);
73735       var lineHeight = 20;
73736       selection2.style("height", lineCount * lineHeight + "px");
73737     }
73738     function stringify3(s2) {
73739       return JSON.stringify(s2).slice(1, -1);
73740     }
73741     function unstringify(s2) {
73742       var leading = "";
73743       var trailing = "";
73744       if (s2.length < 1 || s2.charAt(0) !== '"') {
73745         leading = '"';
73746       }
73747       if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") {
73748         trailing = '"';
73749       }
73750       return JSON.parse(leading + s2 + trailing);
73751     }
73752     function rowsToText(rows) {
73753       var str = rows.filter(function(row) {
73754         return row.key && row.key.trim() !== "";
73755       }).map(function(row) {
73756         var rawVal = row.value;
73757         if (typeof rawVal !== "string")
73758           rawVal = "*";
73759         var val = rawVal ? stringify3(rawVal) : "";
73760         return stringify3(row.key) + "=" + val;
73761       }).join("\n");
73762       if (_state !== "hover" && str.length) {
73763         return str + "\n";
73764       }
73765       return str;
73766     }
73767     function textChanged() {
73768       var newText = this.value.trim();
73769       var newTags = {};
73770       newText.split("\n").forEach(function(row) {
73771         var m2 = row.match(/^\s*([^=]+)=(.*)$/);
73772         if (m2 !== null) {
73773           var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
73774           var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
73775           newTags[k2] = v2;
73776         }
73777       });
73778       var tagDiff = utilTagDiff(_tags, newTags);
73779       if (!tagDiff.length)
73780         return;
73781       _pendingChange = _pendingChange || {};
73782       tagDiff.forEach(function(change) {
73783         if (isReadOnly({ key: change.key }))
73784           return;
73785         if (change.newVal === "*" && typeof change.oldVal !== "string")
73786           return;
73787         if (change.type === "-") {
73788           _pendingChange[change.key] = void 0;
73789         } else if (change.type === "+") {
73790           _pendingChange[change.key] = change.newVal || "";
73791         }
73792       });
73793       if (Object.keys(_pendingChange).length === 0) {
73794         _pendingChange = null;
73795         return;
73796       }
73797       scheduleChange();
73798     }
73799     function pushMore(d3_event) {
73800       if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
73801         addTag();
73802       }
73803     }
73804     function bindTypeahead(key, value) {
73805       if (isReadOnly(key.datum()))
73806         return;
73807       if (Array.isArray(value.datum().value)) {
73808         value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
73809           var keyString = utilGetSetValue(key);
73810           if (!_tags[keyString])
73811             return;
73812           var data = _tags[keyString].map(function(tagValue) {
73813             if (!tagValue) {
73814               return {
73815                 value: " ",
73816                 title: _t("inspector.empty"),
73817                 display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
73818               };
73819             }
73820             return {
73821               value: tagValue,
73822               title: tagValue
73823             };
73824           });
73825           callback(data);
73826         }));
73827         return;
73828       }
73829       var geometry = context.graph().geometry(_entityIDs[0]);
73830       key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
73831         taginfo.keys({
73832           debounce: true,
73833           geometry,
73834           query: value2
73835         }, function(err, data) {
73836           if (!err) {
73837             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()));
73838             callback(sort(value2, filtered));
73839           }
73840         });
73841       }));
73842       value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
73843         taginfo.values({
73844           debounce: true,
73845           key: utilGetSetValue(key),
73846           geometry,
73847           query: value2
73848         }, function(err, data) {
73849           if (!err) {
73850             const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
73851             callback(sort(value2, filtered));
73852           }
73853         });
73854       }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
73855       function sort(value2, data) {
73856         var sameletter = [];
73857         var other = [];
73858         for (var i3 = 0; i3 < data.length; i3++) {
73859           if (data[i3].value.substring(0, value2.length) === value2) {
73860             sameletter.push(data[i3]);
73861           } else {
73862             other.push(data[i3]);
73863           }
73864         }
73865         return sameletter.concat(other);
73866       }
73867     }
73868     function unbind() {
73869       var row = select_default2(this);
73870       row.selectAll("input.key").call(uiCombobox.off, context);
73871       row.selectAll("input.value").call(uiCombobox.off, context);
73872     }
73873     function keyChange(d3_event, d2) {
73874       if (select_default2(this).attr("readonly"))
73875         return;
73876       var kOld = d2.key;
73877       if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0)
73878         return;
73879       var kNew = context.cleanTagKey(this.value.trim());
73880       if (isReadOnly({ key: kNew })) {
73881         this.value = kOld;
73882         return;
73883       }
73884       if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
73885         this.value = kOld;
73886         section.selection().selectAll(".tag-list input.value").each(function(d4) {
73887           if (d4.key === kNew) {
73888             var input = select_default2(this).node();
73889             input.focus();
73890             input.select();
73891           }
73892         });
73893         return;
73894       }
73895       _pendingChange = _pendingChange || {};
73896       if (kOld) {
73897         if (kOld === kNew)
73898           return;
73899         _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
73900         _pendingChange[kOld] = void 0;
73901       } else {
73902         let row = this.parentNode.parentNode;
73903         let inputVal = select_default2(row).selectAll("input.value");
73904         let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
73905         _pendingChange[kNew] = vNew;
73906         utilGetSetValue(inputVal, vNew);
73907       }
73908       var existingKeyIndex = _orderedKeys.indexOf(kOld);
73909       if (existingKeyIndex !== -1)
73910         _orderedKeys[existingKeyIndex] = kNew;
73911       d2.key = kNew;
73912       this.value = kNew;
73913       scheduleChange();
73914     }
73915     function valueChange(d3_event, d2) {
73916       if (isReadOnly(d2))
73917         return;
73918       if (typeof d2.value !== "string" && !this.value)
73919         return;
73920       if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0)
73921         return;
73922       _pendingChange = _pendingChange || {};
73923       _pendingChange[d2.key] = context.cleanTagValue(this.value);
73924       scheduleChange();
73925     }
73926     function removeTag(d3_event, d2) {
73927       if (isReadOnly(d2))
73928         return;
73929       if (d2.key === "") {
73930         _showBlank = false;
73931         section.reRender();
73932       } else {
73933         _orderedKeys = _orderedKeys.filter(function(key) {
73934           return key !== d2.key;
73935         });
73936         _pendingChange = _pendingChange || {};
73937         _pendingChange[d2.key] = void 0;
73938         scheduleChange();
73939       }
73940     }
73941     function addTag() {
73942       window.setTimeout(function() {
73943         _showBlank = true;
73944         section.reRender();
73945         section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
73946       }, 20);
73947     }
73948     function scheduleChange() {
73949       var entityIDs = _entityIDs;
73950       window.setTimeout(function() {
73951         if (!_pendingChange)
73952           return;
73953         dispatch14.call("change", this, entityIDs, _pendingChange);
73954         _pendingChange = null;
73955       }, 10);
73956     }
73957     section.state = function(val) {
73958       if (!arguments.length)
73959         return _state;
73960       if (_state !== val) {
73961         _orderedKeys = [];
73962         _state = val;
73963       }
73964       return section;
73965     };
73966     section.presets = function(val) {
73967       if (!arguments.length)
73968         return _presets;
73969       _presets = val;
73970       if (_presets && _presets.length && _presets[0].isFallback()) {
73971         section.disclosureExpanded(true);
73972       } else if (!_didInteract) {
73973         section.disclosureExpanded(null);
73974       }
73975       return section;
73976     };
73977     section.tags = function(val) {
73978       if (!arguments.length)
73979         return _tags;
73980       _tags = val;
73981       return section;
73982     };
73983     section.entityIDs = function(val) {
73984       if (!arguments.length)
73985         return _entityIDs;
73986       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
73987         _entityIDs = val;
73988         _orderedKeys = [];
73989       }
73990       return section;
73991     };
73992     section.readOnlyTags = function(val) {
73993       if (!arguments.length)
73994         return _readOnlyTags;
73995       _readOnlyTags = val;
73996       return section;
73997     };
73998     return utilRebind(section, dispatch14, "on");
73999   }
74000
74001   // modules/ui/data_editor.js
74002   function uiDataEditor(context) {
74003     var dataHeader = uiDataHeader();
74004     var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
74005     var _datum;
74006     function dataEditor(selection2) {
74007       var header = selection2.selectAll(".header").data([0]);
74008       var headerEnter = header.enter().append("div").attr("class", "header fillL");
74009       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
74010         context.enter(modeBrowse(context));
74011       }).call(svgIcon("#iD-icon-close"));
74012       headerEnter.append("h2").call(_t.append("map_data.title"));
74013       var body = selection2.selectAll(".body").data([0]);
74014       body = body.enter().append("div").attr("class", "body").merge(body);
74015       var editor = body.selectAll(".data-editor").data([0]);
74016       editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
74017       var rte = body.selectAll(".raw-tag-editor").data([0]);
74018       rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
74019         rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
74020       ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
74021     }
74022     dataEditor.datum = function(val) {
74023       if (!arguments.length)
74024         return _datum;
74025       _datum = val;
74026       return this;
74027     };
74028     return dataEditor;
74029   }
74030
74031   // modules/ui/sidebar.js
74032   function uiSidebar(context) {
74033     var inspector = uiInspector(context);
74034     var dataEditor = uiDataEditor(context);
74035     var noteEditor = uiNoteEditor(context);
74036     var improveOsmEditor = uiImproveOsmEditor(context);
74037     var keepRightEditor = uiKeepRightEditor(context);
74038     var osmoseEditor = uiOsmoseEditor(context);
74039     var _current;
74040     var _wasData = false;
74041     var _wasNote = false;
74042     var _wasQaItem = false;
74043     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
74044     function sidebar(selection2) {
74045       var container = context.container();
74046       var minWidth = 240;
74047       var sidebarWidth;
74048       var containerWidth;
74049       var dragOffset;
74050       selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
74051       var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
74052       var downPointerId, lastClientX, containerLocGetter;
74053       function pointerdown(d3_event) {
74054         if (downPointerId)
74055           return;
74056         if ("button" in d3_event && d3_event.button !== 0)
74057           return;
74058         downPointerId = d3_event.pointerId || "mouse";
74059         lastClientX = d3_event.clientX;
74060         containerLocGetter = utilFastMouse(container.node());
74061         dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
74062         sidebarWidth = selection2.node().getBoundingClientRect().width;
74063         containerWidth = container.node().getBoundingClientRect().width;
74064         var widthPct = sidebarWidth / containerWidth * 100;
74065         selection2.style("width", widthPct + "%").style("max-width", "85%");
74066         resizer.classed("dragging", true);
74067         select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
74068           d3_event2.preventDefault();
74069         }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
74070       }
74071       function pointermove(d3_event) {
74072         if (downPointerId !== (d3_event.pointerId || "mouse"))
74073           return;
74074         d3_event.preventDefault();
74075         var dx = d3_event.clientX - lastClientX;
74076         lastClientX = d3_event.clientX;
74077         var isRTL = _mainLocalizer.textDirection() === "rtl";
74078         var scaleX = isRTL ? 0 : 1;
74079         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74080         var x2 = containerLocGetter(d3_event)[0] - dragOffset;
74081         sidebarWidth = isRTL ? containerWidth - x2 : x2;
74082         var isCollapsed = selection2.classed("collapsed");
74083         var shouldCollapse = sidebarWidth < minWidth;
74084         selection2.classed("collapsed", shouldCollapse);
74085         if (shouldCollapse) {
74086           if (!isCollapsed) {
74087             selection2.style(xMarginProperty, "-400px").style("width", "400px");
74088             context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
74089           }
74090         } else {
74091           var widthPct = sidebarWidth / containerWidth * 100;
74092           selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74093           if (isCollapsed) {
74094             context.ui().onResize([-sidebarWidth * scaleX, 0]);
74095           } else {
74096             context.ui().onResize([-dx * scaleX, 0]);
74097           }
74098         }
74099       }
74100       function pointerup(d3_event) {
74101         if (downPointerId !== (d3_event.pointerId || "mouse"))
74102           return;
74103         downPointerId = null;
74104         resizer.classed("dragging", false);
74105         select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
74106       }
74107       var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
74108       var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
74109       var hoverModeSelect = function(targets) {
74110         context.container().selectAll(".feature-list-item button").classed("hover", false);
74111         if (context.selectedIDs().length > 1 && targets && targets.length) {
74112           var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
74113             return targets.indexOf(node) !== -1;
74114           });
74115           if (!elements.empty()) {
74116             elements.classed("hover", true);
74117           }
74118         }
74119       };
74120       sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
74121       function hover(targets) {
74122         var datum2 = targets && targets.length && targets[0];
74123         if (datum2 && datum2.__featurehash__) {
74124           _wasData = true;
74125           sidebar.show(dataEditor.datum(datum2));
74126           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74127         } else if (datum2 instanceof osmNote) {
74128           if (context.mode().id === "drag-note")
74129             return;
74130           _wasNote = true;
74131           var osm = services.osm;
74132           if (osm) {
74133             datum2 = osm.getNote(datum2.id);
74134           }
74135           sidebar.show(noteEditor.note(datum2));
74136           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74137         } else if (datum2 instanceof QAItem) {
74138           _wasQaItem = true;
74139           var errService = services[datum2.service];
74140           if (errService) {
74141             datum2 = errService.getError(datum2.id);
74142           }
74143           var errEditor;
74144           if (datum2.service === "keepRight") {
74145             errEditor = keepRightEditor;
74146           } else if (datum2.service === "osmose") {
74147             errEditor = osmoseEditor;
74148           } else {
74149             errEditor = improveOsmEditor;
74150           }
74151           context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
74152             return d2.id === datum2.id;
74153           });
74154           sidebar.show(errEditor.error(datum2));
74155           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74156         } else if (!_current && datum2 instanceof osmEntity) {
74157           featureListWrap.classed("inspector-hidden", true);
74158           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
74159           if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
74160             inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
74161             inspectorWrap.call(inspector);
74162           }
74163         } else if (!_current) {
74164           featureListWrap.classed("inspector-hidden", false);
74165           inspectorWrap.classed("inspector-hidden", true);
74166           inspector.state("hide");
74167         } else if (_wasData || _wasNote || _wasQaItem) {
74168           _wasNote = false;
74169           _wasData = false;
74170           _wasQaItem = false;
74171           context.container().selectAll(".note").classed("hover", false);
74172           context.container().selectAll(".qaItem").classed("hover", false);
74173           sidebar.hide();
74174         }
74175       }
74176       sidebar.hover = throttle_default(hover, 200);
74177       sidebar.intersects = function(extent) {
74178         var rect = selection2.node().getBoundingClientRect();
74179         return extent.intersects([
74180           context.projection.invert([0, rect.height]),
74181           context.projection.invert([rect.width, 0])
74182         ]);
74183       };
74184       sidebar.select = function(ids, newFeature) {
74185         sidebar.hide();
74186         if (ids && ids.length) {
74187           var entity = ids.length === 1 && context.entity(ids[0]);
74188           if (entity && newFeature && selection2.classed("collapsed")) {
74189             var extent = entity.extent(context.graph());
74190             sidebar.expand(sidebar.intersects(extent));
74191           }
74192           featureListWrap.classed("inspector-hidden", true);
74193           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
74194           inspector.state("select").entityIDs(ids).newFeature(newFeature);
74195           inspectorWrap.call(inspector);
74196         } else {
74197           inspector.state("hide");
74198         }
74199       };
74200       sidebar.showPresetList = function() {
74201         inspector.showList();
74202       };
74203       sidebar.show = function(component, element) {
74204         featureListWrap.classed("inspector-hidden", true);
74205         inspectorWrap.classed("inspector-hidden", true);
74206         if (_current)
74207           _current.remove();
74208         _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
74209       };
74210       sidebar.hide = function() {
74211         featureListWrap.classed("inspector-hidden", false);
74212         inspectorWrap.classed("inspector-hidden", true);
74213         if (_current)
74214           _current.remove();
74215         _current = null;
74216       };
74217       sidebar.expand = function(moveMap) {
74218         if (selection2.classed("collapsed")) {
74219           sidebar.toggle(moveMap);
74220         }
74221       };
74222       sidebar.collapse = function(moveMap) {
74223         if (!selection2.classed("collapsed")) {
74224           sidebar.toggle(moveMap);
74225         }
74226       };
74227       sidebar.toggle = function(moveMap) {
74228         if (context.inIntro())
74229           return;
74230         var isCollapsed = selection2.classed("collapsed");
74231         var isCollapsing = !isCollapsed;
74232         var isRTL = _mainLocalizer.textDirection() === "rtl";
74233         var scaleX = isRTL ? 0 : 1;
74234         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74235         sidebarWidth = selection2.node().getBoundingClientRect().width;
74236         selection2.style("width", sidebarWidth + "px");
74237         var startMargin, endMargin, lastMargin;
74238         if (isCollapsing) {
74239           startMargin = lastMargin = 0;
74240           endMargin = -sidebarWidth;
74241         } else {
74242           startMargin = lastMargin = -sidebarWidth;
74243           endMargin = 0;
74244         }
74245         if (!isCollapsing) {
74246           selection2.classed("collapsed", isCollapsing);
74247         }
74248         selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
74249           var i3 = number_default(startMargin, endMargin);
74250           return function(t2) {
74251             var dx = lastMargin - Math.round(i3(t2));
74252             lastMargin = lastMargin - dx;
74253             context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
74254           };
74255         }).on("end", function() {
74256           if (isCollapsing) {
74257             selection2.classed("collapsed", isCollapsing);
74258           }
74259           if (!isCollapsing) {
74260             var containerWidth2 = container.node().getBoundingClientRect().width;
74261             var widthPct = sidebarWidth / containerWidth2 * 100;
74262             selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74263           }
74264         });
74265       };
74266       resizer.on("dblclick", function(d3_event) {
74267         d3_event.preventDefault();
74268         if (d3_event.sourceEvent) {
74269           d3_event.sourceEvent.preventDefault();
74270         }
74271         sidebar.toggle();
74272       });
74273       context.map().on("crossEditableZoom.sidebar", function(within) {
74274         if (!within && !selection2.select(".inspector-hover").empty()) {
74275           hover([]);
74276         }
74277       });
74278     }
74279     sidebar.showPresetList = function() {
74280     };
74281     sidebar.hover = function() {
74282     };
74283     sidebar.hover.cancel = function() {
74284     };
74285     sidebar.intersects = function() {
74286     };
74287     sidebar.select = function() {
74288     };
74289     sidebar.show = function() {
74290     };
74291     sidebar.hide = function() {
74292     };
74293     sidebar.expand = function() {
74294     };
74295     sidebar.collapse = function() {
74296     };
74297     sidebar.toggle = function() {
74298     };
74299     return sidebar;
74300   }
74301
74302   // modules/ui/tools/modes.js
74303   function uiToolDrawModes(context) {
74304     var tool = {
74305       id: "old_modes",
74306       label: _t.append("toolbar.add_feature")
74307     };
74308     var modes = [
74309       modeAddPoint(context, {
74310         title: _t.append("modes.add_point.title"),
74311         button: "point",
74312         description: _t.append("modes.add_point.description"),
74313         preset: _mainPresetIndex.item("point"),
74314         key: "1"
74315       }),
74316       modeAddLine(context, {
74317         title: _t.append("modes.add_line.title"),
74318         button: "line",
74319         description: _t.append("modes.add_line.description"),
74320         preset: _mainPresetIndex.item("line"),
74321         key: "2"
74322       }),
74323       modeAddArea(context, {
74324         title: _t.append("modes.add_area.title"),
74325         button: "area",
74326         description: _t.append("modes.add_area.description"),
74327         preset: _mainPresetIndex.item("area"),
74328         key: "3"
74329       })
74330     ];
74331     function enabled(_mode) {
74332       return osmEditable();
74333     }
74334     function osmEditable() {
74335       return context.editable();
74336     }
74337     modes.forEach(function(mode) {
74338       context.keybinding().on(mode.key, function() {
74339         if (!enabled(mode))
74340           return;
74341         if (mode.id === context.mode().id) {
74342           context.enter(modeBrowse(context));
74343         } else {
74344           context.enter(mode);
74345         }
74346       });
74347     });
74348     tool.render = function(selection2) {
74349       var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
74350       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74351       context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
74352       context.on("enter.modes", update);
74353       update();
74354       function update() {
74355         var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
74356           return d2.id;
74357         });
74358         buttons.exit().remove();
74359         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74360           return d2.id + " add-button bar-button";
74361         }).on("click.mode-buttons", function(d3_event, d2) {
74362           if (!enabled(d2))
74363             return;
74364           var currMode = context.mode().id;
74365           if (/^draw/.test(currMode))
74366             return;
74367           if (d2.id === currMode) {
74368             context.enter(modeBrowse(context));
74369           } else {
74370             context.enter(d2);
74371           }
74372         }).call(
74373           uiTooltip().placement("bottom").title(function(d2) {
74374             return d2.description;
74375           }).keys(function(d2) {
74376             return [d2.key];
74377           }).scrollContainer(context.container().select(".top-toolbar"))
74378         );
74379         buttonsEnter.each(function(d2) {
74380           select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
74381         });
74382         buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
74383           mode.title(select_default2(this));
74384         });
74385         if (buttons.enter().size() || buttons.exit().size()) {
74386           context.ui().checkOverflow(".top-toolbar", true);
74387         }
74388         buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
74389           return !enabled(d2);
74390         }).classed("disabled", function(d2) {
74391           return !enabled(d2);
74392         }).attr("aria-pressed", function(d2) {
74393           return context.mode() && context.mode().button === d2.button;
74394         }).classed("active", function(d2) {
74395           return context.mode() && context.mode().button === d2.button;
74396         });
74397       }
74398     };
74399     return tool;
74400   }
74401
74402   // modules/ui/tools/notes.js
74403   function uiToolNotes(context) {
74404     var tool = {
74405       id: "notes",
74406       label: _t.append("modes.add_note.label")
74407     };
74408     var mode = modeAddNote(context);
74409     function enabled() {
74410       return notesEnabled() && notesEditable();
74411     }
74412     function notesEnabled() {
74413       var noteLayer = context.layers().layer("notes");
74414       return noteLayer && noteLayer.enabled();
74415     }
74416     function notesEditable() {
74417       var mode2 = context.mode();
74418       return context.map().notesEditable() && mode2 && mode2.id !== "save";
74419     }
74420     context.keybinding().on(mode.key, function() {
74421       if (!enabled())
74422         return;
74423       if (mode.id === context.mode().id) {
74424         context.enter(modeBrowse(context));
74425       } else {
74426         context.enter(mode);
74427       }
74428     });
74429     tool.render = function(selection2) {
74430       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74431       context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
74432       context.on("enter.notes", update);
74433       update();
74434       function update() {
74435         var showNotes = notesEnabled();
74436         var data = showNotes ? [mode] : [];
74437         var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
74438           return d2.id;
74439         });
74440         buttons.exit().remove();
74441         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74442           return d2.id + " add-button bar-button";
74443         }).on("click.notes", function(d3_event, d2) {
74444           if (!enabled())
74445             return;
74446           var currMode = context.mode().id;
74447           if (/^draw/.test(currMode))
74448             return;
74449           if (d2.id === currMode) {
74450             context.enter(modeBrowse(context));
74451           } else {
74452             context.enter(d2);
74453           }
74454         }).call(
74455           uiTooltip().placement("bottom").title(function(d2) {
74456             return d2.description;
74457           }).keys(function(d2) {
74458             return [d2.key];
74459           }).scrollContainer(context.container().select(".top-toolbar"))
74460         );
74461         buttonsEnter.each(function(d2) {
74462           select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
74463         });
74464         if (buttons.enter().size() || buttons.exit().size()) {
74465           context.ui().checkOverflow(".top-toolbar", true);
74466         }
74467         buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
74468           return !enabled();
74469         }).attr("aria-disabled", function() {
74470           return !enabled();
74471         }).classed("active", function(d2) {
74472           return context.mode() && context.mode().button === d2.button;
74473         }).attr("aria-pressed", function(d2) {
74474           return context.mode() && context.mode().button === d2.button;
74475         });
74476       }
74477     };
74478     tool.uninstall = function() {
74479       context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
74480       context.map().on("move.notes", null).on("drawn.notes", null);
74481     };
74482     return tool;
74483   }
74484
74485   // modules/ui/tools/save.js
74486   function uiToolSave(context) {
74487     var tool = {
74488       id: "save",
74489       label: _t.append("save.title")
74490     };
74491     var button = null;
74492     var tooltipBehavior = null;
74493     var history = context.history();
74494     var key = uiCmd("\u2318S");
74495     var _numChanges = 0;
74496     function isSaving() {
74497       var mode = context.mode();
74498       return mode && mode.id === "save";
74499     }
74500     function isDisabled() {
74501       return _numChanges === 0 || isSaving();
74502     }
74503     function save(d3_event) {
74504       d3_event.preventDefault();
74505       if (!context.inIntro() && !isSaving() && history.hasChanges()) {
74506         context.enter(modeSave(context));
74507       }
74508     }
74509     function bgColor(numChanges) {
74510       var step;
74511       if (numChanges === 0) {
74512         return null;
74513       } else if (numChanges <= 50) {
74514         step = numChanges / 50;
74515         return rgb_default("#fff", "#ff8")(step);
74516       } else {
74517         step = Math.min((numChanges - 50) / 50, 1);
74518         return rgb_default("#ff8", "#f88")(step);
74519       }
74520     }
74521     function updateCount() {
74522       var val = history.difference().summary().length;
74523       if (val === _numChanges)
74524         return;
74525       _numChanges = val;
74526       if (tooltipBehavior) {
74527         tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
74528       }
74529       if (button) {
74530         button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
74531         button.select("span.count").text(_numChanges);
74532       }
74533     }
74534     tool.render = function(selection2) {
74535       tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
74536       var lastPointerUpType;
74537       button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
74538         lastPointerUpType = d3_event.pointerType;
74539       }).on("click", function(d3_event) {
74540         save(d3_event);
74541         if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74542           context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
74543         }
74544         lastPointerUpType = null;
74545       }).call(tooltipBehavior);
74546       button.call(svgIcon("#iD-icon-save"));
74547       button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
74548       updateCount();
74549       context.keybinding().on(key, save, true);
74550       context.history().on("change.save", updateCount);
74551       context.on("enter.save", function() {
74552         if (button) {
74553           button.classed("disabled", isDisabled());
74554           if (isSaving()) {
74555             button.call(tooltipBehavior.hide);
74556           }
74557         }
74558       });
74559     };
74560     tool.uninstall = function() {
74561       context.keybinding().off(key, true);
74562       context.history().on("change.save", null);
74563       context.on("enter.save", null);
74564       button = null;
74565       tooltipBehavior = null;
74566     };
74567     return tool;
74568   }
74569
74570   // modules/ui/tools/sidebar_toggle.js
74571   function uiToolSidebarToggle(context) {
74572     var tool = {
74573       id: "sidebar_toggle",
74574       label: _t.append("toolbar.inspect")
74575     };
74576     tool.render = function(selection2) {
74577       selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
74578         context.ui().sidebar.toggle();
74579       }).call(
74580         uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
74581       ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
74582     };
74583     return tool;
74584   }
74585
74586   // modules/ui/tools/undo_redo.js
74587   function uiToolUndoRedo(context) {
74588     var tool = {
74589       id: "undo_redo",
74590       label: _t.append("toolbar.undo_redo")
74591     };
74592     var commands = [{
74593       id: "undo",
74594       cmd: uiCmd("\u2318Z"),
74595       action: function() {
74596         context.undo();
74597       },
74598       annotation: function() {
74599         return context.history().undoAnnotation();
74600       },
74601       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
74602     }, {
74603       id: "redo",
74604       cmd: uiCmd("\u2318\u21E7Z"),
74605       action: function() {
74606         context.redo();
74607       },
74608       annotation: function() {
74609         return context.history().redoAnnotation();
74610       },
74611       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
74612     }];
74613     function editable() {
74614       return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
74615         true
74616         /* ignore min zoom */
74617       );
74618     }
74619     tool.render = function(selection2) {
74620       var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
74621         return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
74622       }).keys(function(d2) {
74623         return [d2.cmd];
74624       }).scrollContainer(context.container().select(".top-toolbar"));
74625       var lastPointerUpType;
74626       var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
74627         return "disabled " + d2.id + "-button bar-button";
74628       }).on("pointerup", function(d3_event) {
74629         lastPointerUpType = d3_event.pointerType;
74630       }).on("click", function(d3_event, d2) {
74631         d3_event.preventDefault();
74632         var annotation = d2.annotation();
74633         if (editable() && annotation) {
74634           d2.action();
74635         }
74636         if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74637           var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
74638           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
74639         }
74640         lastPointerUpType = null;
74641       }).call(tooltipBehavior);
74642       buttons.each(function(d2) {
74643         select_default2(this).call(svgIcon("#" + d2.icon));
74644       });
74645       context.keybinding().on(commands[0].cmd, function(d3_event) {
74646         d3_event.preventDefault();
74647         if (editable())
74648           commands[0].action();
74649       }).on(commands[1].cmd, function(d3_event) {
74650         d3_event.preventDefault();
74651         if (editable())
74652           commands[1].action();
74653       });
74654       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74655       context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
74656       context.history().on("change.undo_redo", function(difference2) {
74657         if (difference2)
74658           update();
74659       });
74660       context.on("enter.undo_redo", update);
74661       function update() {
74662         buttons.classed("disabled", function(d2) {
74663           return !editable() || !d2.annotation();
74664         }).each(function() {
74665           var selection3 = select_default2(this);
74666           if (!selection3.select(".tooltip.in").empty()) {
74667             selection3.call(tooltipBehavior.updateContent);
74668           }
74669         });
74670       }
74671     };
74672     tool.uninstall = function() {
74673       context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
74674       context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
74675       context.history().on("change.undo_redo", null);
74676       context.on("enter.undo_redo", null);
74677     };
74678     return tool;
74679   }
74680
74681   // modules/ui/top_toolbar.js
74682   function uiTopToolbar(context) {
74683     var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
74684     function notesEnabled() {
74685       var noteLayer = context.layers().layer("notes");
74686       return noteLayer && noteLayer.enabled();
74687     }
74688     function topToolbar(bar) {
74689       bar.on("wheel.topToolbar", function(d3_event) {
74690         if (!d3_event.deltaX) {
74691           bar.node().scrollLeft += d3_event.deltaY;
74692         }
74693       });
74694       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74695       context.layers().on("change.topToolbar", debouncedUpdate);
74696       update();
74697       function update() {
74698         var tools = [
74699           sidebarToggle,
74700           "spacer",
74701           modes
74702         ];
74703         tools.push("spacer");
74704         if (notesEnabled()) {
74705           tools = tools.concat([notes, "spacer"]);
74706         }
74707         tools = tools.concat([undoRedo, save]);
74708         var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
74709           return d2.id || d2;
74710         });
74711         toolbarItems.exit().each(function(d2) {
74712           if (d2.uninstall) {
74713             d2.uninstall();
74714           }
74715         }).remove();
74716         var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
74717           var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
74718           if (d2.klass)
74719             classes += " " + d2.klass;
74720           return classes;
74721         });
74722         var actionableItems = itemsEnter.filter(function(d2) {
74723           return d2 !== "spacer";
74724         });
74725         actionableItems.append("div").attr("class", "item-content").each(function(d2) {
74726           select_default2(this).call(d2.render, bar);
74727         });
74728         actionableItems.append("div").attr("class", "item-label").each(function(d2) {
74729           d2.label(select_default2(this));
74730         });
74731       }
74732     }
74733     return topToolbar;
74734   }
74735
74736   // modules/ui/zoom_to_selection.js
74737   function uiZoomToSelection(context) {
74738     function isDisabled() {
74739       var mode = context.mode();
74740       return !mode || !mode.zoomToSelected;
74741     }
74742     var _lastPointerUpType;
74743     function pointerup(d3_event) {
74744       _lastPointerUpType = d3_event.pointerType;
74745     }
74746     function click(d3_event) {
74747       d3_event.preventDefault();
74748       if (isDisabled()) {
74749         if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
74750           context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
74751         }
74752       } else {
74753         var mode = context.mode();
74754         if (mode && mode.zoomToSelected) {
74755           mode.zoomToSelected();
74756         }
74757       }
74758       _lastPointerUpType = null;
74759     }
74760     return function(selection2) {
74761       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
74762         if (isDisabled()) {
74763           return _t.append("inspector.zoom_to.no_selection");
74764         }
74765         return _t.append("inspector.zoom_to.title");
74766       }).keys([_t("inspector.zoom_to.key")]);
74767       var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
74768       function setEnabledState() {
74769         button.classed("disabled", isDisabled());
74770         if (!button.select(".tooltip.in").empty()) {
74771           button.call(tooltipBehavior.updateContent);
74772         }
74773       }
74774       context.on("enter.uiZoomToSelection", setEnabledState);
74775       setEnabledState();
74776     };
74777   }
74778
74779   // modules/ui/pane.js
74780   function uiPane(id2, context) {
74781     var _key;
74782     var _label = "";
74783     var _description = "";
74784     var _iconName = "";
74785     var _sections;
74786     var _paneSelection = select_default2(null);
74787     var _paneTooltip;
74788     var pane = {
74789       id: id2
74790     };
74791     pane.label = function(val) {
74792       if (!arguments.length)
74793         return _label;
74794       _label = val;
74795       return pane;
74796     };
74797     pane.key = function(val) {
74798       if (!arguments.length)
74799         return _key;
74800       _key = val;
74801       return pane;
74802     };
74803     pane.description = function(val) {
74804       if (!arguments.length)
74805         return _description;
74806       _description = val;
74807       return pane;
74808     };
74809     pane.iconName = function(val) {
74810       if (!arguments.length)
74811         return _iconName;
74812       _iconName = val;
74813       return pane;
74814     };
74815     pane.sections = function(val) {
74816       if (!arguments.length)
74817         return _sections;
74818       _sections = val;
74819       return pane;
74820     };
74821     pane.selection = function() {
74822       return _paneSelection;
74823     };
74824     function hidePane() {
74825       context.ui().togglePanes();
74826     }
74827     pane.togglePane = function(d3_event) {
74828       if (d3_event)
74829         d3_event.preventDefault();
74830       _paneTooltip.hide();
74831       context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
74832     };
74833     pane.renderToggleButton = function(selection2) {
74834       if (!_paneTooltip) {
74835         _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
74836       }
74837       selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
74838     };
74839     pane.renderContent = function(selection2) {
74840       if (_sections) {
74841         _sections.forEach(function(section) {
74842           selection2.call(section.render);
74843         });
74844       }
74845     };
74846     pane.renderPane = function(selection2) {
74847       _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
74848       var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
74849       heading2.append("h2").text("").call(_label);
74850       heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
74851       _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
74852       if (_key) {
74853         context.keybinding().on(_key, pane.togglePane);
74854       }
74855     };
74856     return pane;
74857   }
74858
74859   // modules/ui/sections/background_display_options.js
74860   function uiSectionBackgroundDisplayOptions(context) {
74861     var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
74862     var _storedOpacity = corePreferences("background-opacity");
74863     var _minVal = 0;
74864     var _maxVal = 3;
74865     var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
74866     var _options = {
74867       brightness: _storedOpacity !== null ? +_storedOpacity : 1,
74868       contrast: 1,
74869       saturation: 1,
74870       sharpness: 1
74871     };
74872     function clamp3(x2, min3, max3) {
74873       return Math.max(min3, Math.min(x2, max3));
74874     }
74875     function updateValue(d2, val) {
74876       val = clamp3(val, _minVal, _maxVal);
74877       _options[d2] = val;
74878       context.background()[d2](val);
74879       if (d2 === "brightness") {
74880         corePreferences("background-opacity", val);
74881       }
74882       section.reRender();
74883     }
74884     function renderDisclosureContent(selection2) {
74885       var container = selection2.selectAll(".display-options-container").data([0]);
74886       var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
74887       var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
74888         return "display-control display-control-" + d2;
74889       });
74890       slidersEnter.html(function(d2) {
74891         return _t.html("background." + d2);
74892       }).append("span").attr("class", function(d2) {
74893         return "display-option-value display-option-value-" + d2;
74894       });
74895       var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
74896       sildersControlEnter.append("input").attr("class", function(d2) {
74897         return "display-option-input display-option-input-" + d2;
74898       }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
74899         var val = select_default2(this).property("value");
74900         if (!val && d3_event && d3_event.target) {
74901           val = d3_event.target.value;
74902         }
74903         updateValue(d2, val);
74904       });
74905       sildersControlEnter.append("button").attr("title", function(d2) {
74906         return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
74907       }).attr("class", function(d2) {
74908         return "display-option-reset display-option-reset-" + d2;
74909       }).on("click", function(d3_event, d2) {
74910         if (d3_event.button !== 0)
74911           return;
74912         updateValue(d2, 1);
74913       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
74914       containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
74915         d3_event.preventDefault();
74916         for (var i3 = 0; i3 < _sliders.length; i3++) {
74917           updateValue(_sliders[i3], 1);
74918         }
74919       });
74920       container = containerEnter.merge(container);
74921       container.selectAll(".display-option-input").property("value", function(d2) {
74922         return _options[d2];
74923       });
74924       container.selectAll(".display-option-value").text(function(d2) {
74925         return Math.floor(_options[d2] * 100) + "%";
74926       });
74927       container.selectAll(".display-option-reset").classed("disabled", function(d2) {
74928         return _options[d2] === 1;
74929       });
74930       if (containerEnter.size() && _options.brightness !== 1) {
74931         context.background().brightness(_options.brightness);
74932       }
74933     }
74934     return section;
74935   }
74936
74937   // modules/ui/settings/custom_background.js
74938   function uiSettingsCustomBackground() {
74939     var dispatch14 = dispatch_default("change");
74940     function render(selection2) {
74941       var _origSettings = {
74942         template: corePreferences("background-custom-template")
74943       };
74944       var _currSettings = {
74945         template: corePreferences("background-custom-template")
74946       };
74947       var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
74948       var modal = uiConfirm(selection2).okButton();
74949       modal.classed("settings-modal settings-custom-background", true);
74950       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
74951       var textSection = modal.select(".modal-section.message-text");
74952       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, "`");
74953       textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
74954       textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
74955       var buttonSection = modal.select(".modal-section.buttons");
74956       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
74957       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
74958       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
74959       function isSaveDisabled() {
74960         return null;
74961       }
74962       function clickCancel() {
74963         textSection.select(".field-template").property("value", _origSettings.template);
74964         corePreferences("background-custom-template", _origSettings.template);
74965         this.blur();
74966         modal.close();
74967       }
74968       function clickSave() {
74969         _currSettings.template = textSection.select(".field-template").property("value");
74970         corePreferences("background-custom-template", _currSettings.template);
74971         this.blur();
74972         modal.close();
74973         dispatch14.call("change", this, _currSettings);
74974       }
74975     }
74976     return utilRebind(render, dispatch14, "on");
74977   }
74978
74979   // modules/ui/sections/background_list.js
74980   function uiSectionBackgroundList(context) {
74981     var _backgroundList = select_default2(null);
74982     var _customSource = context.background().findSource("custom");
74983     var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
74984     var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
74985     function previousBackgroundID() {
74986       return corePreferences("background-last-used-toggle");
74987     }
74988     function renderDisclosureContent(selection2) {
74989       var container = selection2.selectAll(".layer-background-list").data([0]);
74990       _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
74991       var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
74992       var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
74993         uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
74994       );
74995       minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
74996         d3_event.preventDefault();
74997         uiMapInMap.toggle();
74998       });
74999       minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
75000       var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
75001         uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
75002       );
75003       panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75004         d3_event.preventDefault();
75005         context.ui().info.toggle("background");
75006       });
75007       panelLabelEnter.append("span").call(_t.append("background.panel.description"));
75008       var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
75009         uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
75010       );
75011       locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75012         d3_event.preventDefault();
75013         context.ui().info.toggle("location");
75014       });
75015       locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
75016       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"));
75017       _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
75018         chooseBackground(d2);
75019       }, function(d2) {
75020         return !d2.isHidden() && !d2.overlay;
75021       });
75022     }
75023     function setTooltips(selection2) {
75024       selection2.each(function(d2, i3, nodes) {
75025         var item = select_default2(this).select("label");
75026         var span = item.select("span");
75027         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75028         var hasDescription = d2.hasDescription();
75029         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75030         item.call(uiTooltip().destroyAny);
75031         if (d2.id === previousBackgroundID()) {
75032           item.call(
75033             uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
75034           );
75035         } else if (hasDescription || isOverflowing) {
75036           item.call(
75037             uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
75038           );
75039         }
75040       });
75041     }
75042     function drawListItems(layerList, type2, change, filter2) {
75043       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
75044         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75045       });
75046       var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
75047         return d2.id + "---" + i3;
75048       });
75049       layerLinks.exit().remove();
75050       var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
75051         return d2.id === "custom";
75052       }).classed("best", function(d2) {
75053         return d2.best();
75054       });
75055       var label = enter.append("label");
75056       label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
75057         return d2.id;
75058       }).on("change", change);
75059       label.append("span").each(function(d2) {
75060         d2.label()(select_default2(this));
75061       });
75062       enter.filter(function(d2) {
75063         return d2.id === "custom";
75064       }).append("button").attr("class", "layer-browse").call(
75065         uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75066       ).on("click", function(d3_event) {
75067         d3_event.preventDefault();
75068         editCustom();
75069       }).call(svgIcon("#iD-icon-more"));
75070       enter.filter(function(d2) {
75071         return d2.best();
75072       }).append("div").attr("class", "best").call(
75073         uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75074       ).append("span").text("\u2605");
75075       layerList.call(updateLayerSelections);
75076     }
75077     function updateLayerSelections(selection2) {
75078       function active(d2) {
75079         return context.background().showsLayer(d2);
75080       }
75081       selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
75082         return d2.id === previousBackgroundID();
75083       }).call(setTooltips).selectAll("input").property("checked", active);
75084     }
75085     function chooseBackground(d2) {
75086       if (d2.id === "custom" && !d2.template()) {
75087         return editCustom();
75088       }
75089       var previousBackground = context.background().baseLayerSource();
75090       corePreferences("background-last-used-toggle", previousBackground.id);
75091       corePreferences("background-last-used", d2.id);
75092       context.background().baseLayerSource(d2);
75093     }
75094     function customChanged(d2) {
75095       if (d2 && d2.template) {
75096         _customSource.template(d2.template);
75097         chooseBackground(_customSource);
75098       } else {
75099         _customSource.template("");
75100         chooseBackground(context.background().findSource("none"));
75101       }
75102     }
75103     function editCustom() {
75104       context.container().call(_settingsCustomBackground);
75105     }
75106     context.background().on("change.background_list", function() {
75107       _backgroundList.call(updateLayerSelections);
75108     });
75109     context.map().on(
75110       "move.background_list",
75111       debounce_default(function() {
75112         window.requestIdleCallback(section.reRender);
75113       }, 1e3)
75114     );
75115     return section;
75116   }
75117
75118   // modules/ui/sections/background_offset.js
75119   function uiSectionBackgroundOffset(context) {
75120     var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
75121     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
75122     var _directions = [
75123       ["top", [0, -0.5]],
75124       ["left", [-0.5, 0]],
75125       ["right", [0.5, 0]],
75126       ["bottom", [0, 0.5]]
75127     ];
75128     function updateValue() {
75129       var meters = geoOffsetToMeters(context.background().offset());
75130       var x2 = +meters[0].toFixed(2);
75131       var y2 = +meters[1].toFixed(2);
75132       context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
75133       context.container().selectAll(".nudge-reset").classed("disabled", function() {
75134         return x2 === 0 && y2 === 0;
75135       });
75136     }
75137     function resetOffset() {
75138       context.background().offset([0, 0]);
75139       updateValue();
75140     }
75141     function nudge(d2) {
75142       context.background().nudge(d2, context.map().zoom());
75143       updateValue();
75144     }
75145     function inputOffset() {
75146       var input = select_default2(this);
75147       var d2 = input.node().value;
75148       if (d2 === "")
75149         return resetOffset();
75150       d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
75151         return !isNaN(n3) && n3;
75152       });
75153       if (d2.length !== 2 || !d2[0] || !d2[1]) {
75154         input.classed("error", true);
75155         return;
75156       }
75157       context.background().offset(geoMetersToOffset(d2));
75158       updateValue();
75159     }
75160     function dragOffset(d3_event) {
75161       if (d3_event.button !== 0)
75162         return;
75163       var origin = [d3_event.clientX, d3_event.clientY];
75164       var pointerId = d3_event.pointerId || "mouse";
75165       context.container().append("div").attr("class", "nudge-surface");
75166       select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
75167       if (_pointerPrefix === "pointer") {
75168         select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
75169       }
75170       function pointermove(d3_event2) {
75171         if (pointerId !== (d3_event2.pointerId || "mouse"))
75172           return;
75173         var latest = [d3_event2.clientX, d3_event2.clientY];
75174         var d2 = [
75175           -(origin[0] - latest[0]) / 4,
75176           -(origin[1] - latest[1]) / 4
75177         ];
75178         origin = latest;
75179         nudge(d2);
75180       }
75181       function pointerup(d3_event2) {
75182         if (pointerId !== (d3_event2.pointerId || "mouse"))
75183           return;
75184         if (d3_event2.button !== 0)
75185           return;
75186         context.container().selectAll(".nudge-surface").remove();
75187         select_default2(window).on(".drag-bg-offset", null);
75188       }
75189     }
75190     function renderDisclosureContent(selection2) {
75191       var container = selection2.selectAll(".nudge-container").data([0]);
75192       var containerEnter = container.enter().append("div").attr("class", "nudge-container");
75193       containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
75194       var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
75195       var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
75196       nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
75197       nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
75198         return _t("background.nudge.".concat(d2[0]));
75199       }).attr("class", function(d2) {
75200         return d2[0] + " nudge";
75201       }).on("click", function(d3_event, d2) {
75202         nudge(d2[1]);
75203       });
75204       nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
75205         d3_event.preventDefault();
75206         resetOffset();
75207       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
75208       updateValue();
75209     }
75210     context.background().on("change.backgroundOffset-update", updateValue);
75211     return section;
75212   }
75213
75214   // modules/ui/sections/overlay_list.js
75215   function uiSectionOverlayList(context) {
75216     var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
75217     var _overlayList = select_default2(null);
75218     function setTooltips(selection2) {
75219       selection2.each(function(d2, i3, nodes) {
75220         var item = select_default2(this).select("label");
75221         var span = item.select("span");
75222         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75223         var description = d2.description();
75224         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75225         item.call(uiTooltip().destroyAny);
75226         if (description || isOverflowing) {
75227           item.call(
75228             uiTooltip().placement(placement).title(() => description || d2.name())
75229           );
75230         }
75231       });
75232     }
75233     function updateLayerSelections(selection2) {
75234       function active(d2) {
75235         return context.background().showsLayer(d2);
75236       }
75237       selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
75238     }
75239     function chooseOverlay(d3_event, d2) {
75240       d3_event.preventDefault();
75241       context.background().toggleOverlayLayer(d2);
75242       _overlayList.call(updateLayerSelections);
75243       document.activeElement.blur();
75244     }
75245     function drawListItems(layerList, type2, change, filter2) {
75246       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
75247       var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
75248         return d2.name();
75249       });
75250       layerLinks.exit().remove();
75251       var enter = layerLinks.enter().append("li");
75252       var label = enter.append("label");
75253       label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
75254       label.append("span").each(function(d2) {
75255         d2.label()(select_default2(this));
75256       });
75257       layerList.selectAll("li").sort(sortSources);
75258       layerList.call(updateLayerSelections);
75259       function sortSources(a2, b2) {
75260         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75261       }
75262     }
75263     function renderDisclosureContent(selection2) {
75264       var container = selection2.selectAll(".layer-overlay-list").data([0]);
75265       _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
75266       _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
75267         return !d2.isHidden() && d2.overlay;
75268       });
75269     }
75270     context.map().on(
75271       "move.overlay_list",
75272       debounce_default(function() {
75273         window.requestIdleCallback(section.reRender);
75274       }, 1e3)
75275     );
75276     return section;
75277   }
75278
75279   // modules/ui/panes/background.js
75280   function uiPaneBackground(context) {
75281     var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([
75282       uiSectionBackgroundList(context),
75283       uiSectionOverlayList(context),
75284       uiSectionBackgroundDisplayOptions(context),
75285       uiSectionBackgroundOffset(context)
75286     ]);
75287     return backgroundPane;
75288   }
75289
75290   // modules/ui/panes/help.js
75291   function uiPaneHelp(context) {
75292     var docKeys = [
75293       ["help", [
75294         "welcome",
75295         "open_data_h",
75296         "open_data",
75297         "before_start_h",
75298         "before_start",
75299         "open_source_h",
75300         "open_source",
75301         "open_source_attribution",
75302         "open_source_help"
75303       ]],
75304       ["overview", [
75305         "navigation_h",
75306         "navigation_drag",
75307         "navigation_zoom",
75308         "features_h",
75309         "features",
75310         "nodes_ways"
75311       ]],
75312       ["editing", [
75313         "select_h",
75314         "select_left_click",
75315         "select_right_click",
75316         "select_space",
75317         "multiselect_h",
75318         "multiselect",
75319         "multiselect_shift_click",
75320         "multiselect_lasso",
75321         "undo_redo_h",
75322         "undo_redo",
75323         "save_h",
75324         "save",
75325         "save_validation",
75326         "upload_h",
75327         "upload",
75328         "backups_h",
75329         "backups",
75330         "keyboard_h",
75331         "keyboard"
75332       ]],
75333       ["feature_editor", [
75334         "intro",
75335         "definitions",
75336         "type_h",
75337         "type",
75338         "type_picker",
75339         "fields_h",
75340         "fields_all_fields",
75341         "fields_example",
75342         "fields_add_field",
75343         "tags_h",
75344         "tags_all_tags",
75345         "tags_resources"
75346       ]],
75347       ["points", [
75348         "intro",
75349         "add_point_h",
75350         "add_point",
75351         "add_point_finish",
75352         "move_point_h",
75353         "move_point",
75354         "delete_point_h",
75355         "delete_point",
75356         "delete_point_command"
75357       ]],
75358       ["lines", [
75359         "intro",
75360         "add_line_h",
75361         "add_line",
75362         "add_line_draw",
75363         "add_line_continue",
75364         "add_line_finish",
75365         "modify_line_h",
75366         "modify_line_dragnode",
75367         "modify_line_addnode",
75368         "connect_line_h",
75369         "connect_line",
75370         "connect_line_display",
75371         "connect_line_drag",
75372         "connect_line_tag",
75373         "disconnect_line_h",
75374         "disconnect_line_command",
75375         "move_line_h",
75376         "move_line_command",
75377         "move_line_connected",
75378         "delete_line_h",
75379         "delete_line",
75380         "delete_line_command"
75381       ]],
75382       ["areas", [
75383         "intro",
75384         "point_or_area_h",
75385         "point_or_area",
75386         "add_area_h",
75387         "add_area_command",
75388         "add_area_draw",
75389         "add_area_continue",
75390         "add_area_finish",
75391         "square_area_h",
75392         "square_area_command",
75393         "modify_area_h",
75394         "modify_area_dragnode",
75395         "modify_area_addnode",
75396         "delete_area_h",
75397         "delete_area",
75398         "delete_area_command"
75399       ]],
75400       ["relations", [
75401         "intro",
75402         "edit_relation_h",
75403         "edit_relation",
75404         "edit_relation_add",
75405         "edit_relation_delete",
75406         "maintain_relation_h",
75407         "maintain_relation",
75408         "relation_types_h",
75409         "multipolygon_h",
75410         "multipolygon",
75411         "multipolygon_create",
75412         "multipolygon_merge",
75413         "turn_restriction_h",
75414         "turn_restriction",
75415         "turn_restriction_field",
75416         "turn_restriction_editing",
75417         "route_h",
75418         "route",
75419         "route_add",
75420         "boundary_h",
75421         "boundary",
75422         "boundary_add"
75423       ]],
75424       ["operations", [
75425         "intro",
75426         "intro_2",
75427         "straighten",
75428         "orthogonalize",
75429         "circularize",
75430         "move",
75431         "rotate",
75432         "reflect",
75433         "continue",
75434         "reverse",
75435         "disconnect",
75436         "split",
75437         "extract",
75438         "merge",
75439         "delete",
75440         "downgrade",
75441         "copy_paste"
75442       ]],
75443       ["notes", [
75444         "intro",
75445         "add_note_h",
75446         "add_note",
75447         "place_note",
75448         "move_note",
75449         "update_note_h",
75450         "update_note",
75451         "save_note_h",
75452         "save_note"
75453       ]],
75454       ["imagery", [
75455         "intro",
75456         "sources_h",
75457         "choosing",
75458         "sources",
75459         "offsets_h",
75460         "offset",
75461         "offset_change"
75462       ]],
75463       ["streetlevel", [
75464         "intro",
75465         "using_h",
75466         "using",
75467         "photos",
75468         "viewer"
75469       ]],
75470       ["gps", [
75471         "intro",
75472         "survey",
75473         "using_h",
75474         "using",
75475         "tracing",
75476         "upload"
75477       ]],
75478       ["qa", [
75479         "intro",
75480         "tools_h",
75481         "tools",
75482         "issues_h",
75483         "issues"
75484       ]]
75485     ];
75486     var headings = {
75487       "help.help.open_data_h": 3,
75488       "help.help.before_start_h": 3,
75489       "help.help.open_source_h": 3,
75490       "help.overview.navigation_h": 3,
75491       "help.overview.features_h": 3,
75492       "help.editing.select_h": 3,
75493       "help.editing.multiselect_h": 3,
75494       "help.editing.undo_redo_h": 3,
75495       "help.editing.save_h": 3,
75496       "help.editing.upload_h": 3,
75497       "help.editing.backups_h": 3,
75498       "help.editing.keyboard_h": 3,
75499       "help.feature_editor.type_h": 3,
75500       "help.feature_editor.fields_h": 3,
75501       "help.feature_editor.tags_h": 3,
75502       "help.points.add_point_h": 3,
75503       "help.points.move_point_h": 3,
75504       "help.points.delete_point_h": 3,
75505       "help.lines.add_line_h": 3,
75506       "help.lines.modify_line_h": 3,
75507       "help.lines.connect_line_h": 3,
75508       "help.lines.disconnect_line_h": 3,
75509       "help.lines.move_line_h": 3,
75510       "help.lines.delete_line_h": 3,
75511       "help.areas.point_or_area_h": 3,
75512       "help.areas.add_area_h": 3,
75513       "help.areas.square_area_h": 3,
75514       "help.areas.modify_area_h": 3,
75515       "help.areas.delete_area_h": 3,
75516       "help.relations.edit_relation_h": 3,
75517       "help.relations.maintain_relation_h": 3,
75518       "help.relations.relation_types_h": 2,
75519       "help.relations.multipolygon_h": 3,
75520       "help.relations.turn_restriction_h": 3,
75521       "help.relations.route_h": 3,
75522       "help.relations.boundary_h": 3,
75523       "help.notes.add_note_h": 3,
75524       "help.notes.update_note_h": 3,
75525       "help.notes.save_note_h": 3,
75526       "help.imagery.sources_h": 3,
75527       "help.imagery.offsets_h": 3,
75528       "help.streetlevel.using_h": 3,
75529       "help.gps.using_h": 3,
75530       "help.qa.tools_h": 3,
75531       "help.qa.issues_h": 3
75532     };
75533     var docs = docKeys.map(function(key) {
75534       var helpkey = "help." + key[0];
75535       var helpPaneReplacements = { version: context.version };
75536       var text = key[1].reduce(function(all, part) {
75537         var subkey = helpkey + "." + part;
75538         var depth = headings[subkey];
75539         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
75540         return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n";
75541       }, "");
75542       return {
75543         title: _t.html(helpkey + ".title"),
75544         content: marked(text.trim()).replace(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
75545       };
75546     });
75547     var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help");
75548     helpPane.renderContent = function(content) {
75549       function clickHelp(d2, i3) {
75550         var rtl = _mainLocalizer.textDirection() === "rtl";
75551         content.property("scrollTop", 0);
75552         helpPane.selection().select(".pane-heading h2").html(d2.title);
75553         body.html(d2.content);
75554         body.selectAll("a").attr("target", "_blank");
75555         menuItems.classed("selected", function(m2) {
75556           return m2.title === d2.title;
75557         });
75558         nav.html("");
75559         if (rtl) {
75560           nav.call(drawNext).call(drawPrevious);
75561         } else {
75562           nav.call(drawPrevious).call(drawNext);
75563         }
75564         function drawNext(selection2) {
75565           if (i3 < docs.length - 1) {
75566             var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) {
75567               d3_event.preventDefault();
75568               clickHelp(docs[i3 + 1], i3 + 1);
75569             });
75570             nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
75571           }
75572         }
75573         function drawPrevious(selection2) {
75574           if (i3 > 0) {
75575             var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) {
75576               d3_event.preventDefault();
75577               clickHelp(docs[i3 - 1], i3 - 1);
75578             });
75579             prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title);
75580           }
75581         }
75582       }
75583       function clickWalkthrough(d3_event) {
75584         d3_event.preventDefault();
75585         if (context.inIntro())
75586           return;
75587         context.container().call(uiIntro(context));
75588         context.ui().togglePanes();
75589       }
75590       function clickShortcuts(d3_event) {
75591         d3_event.preventDefault();
75592         context.container().call(context.ui().shortcuts, true);
75593       }
75594       var toc = content.append("ul").attr("class", "toc");
75595       var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) {
75596         return d2.title;
75597       }).on("click", function(d3_event, d2) {
75598         d3_event.preventDefault();
75599         clickHelp(d2, docs.indexOf(d2));
75600       });
75601       var shortcuts = toc.append("li").attr("class", "shortcuts").call(
75602         uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top")
75603       ).append("a").attr("href", "#").on("click", clickShortcuts);
75604       shortcuts.append("div").call(_t.append("shortcuts.title"));
75605       var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough);
75606       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
75607       walkthrough.append("div").call(_t.append("splash.walkthrough"));
75608       var helpContent = content.append("div").attr("class", "left-content");
75609       var body = helpContent.append("div").attr("class", "body");
75610       var nav = helpContent.append("div").attr("class", "nav");
75611       clickHelp(docs[0], 0);
75612     };
75613     return helpPane;
75614   }
75615
75616   // modules/ui/sections/validation_issues.js
75617   function uiSectionValidationIssues(id2, severity, context) {
75618     var _issues = [];
75619     var section = uiSection(id2, context).label(function() {
75620       if (!_issues)
75621         return "";
75622       var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length);
75623       return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText });
75624     }).disclosureContent(renderDisclosureContent).shouldDisplay(function() {
75625       return _issues && _issues.length;
75626     });
75627     function getOptions() {
75628       return {
75629         what: corePreferences("validate-what") || "edited",
75630         where: corePreferences("validate-where") || "all"
75631       };
75632     }
75633     function reloadIssues() {
75634       _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
75635     }
75636     function renderDisclosureContent(selection2) {
75637       var center = context.map().center();
75638       var graph = context.graph();
75639       var issues = _issues.map(function withDistance(issue) {
75640         var extent = issue.extent(graph);
75641         var dist = extent ? geoSphericalDistance(center, extent.center()) : 0;
75642         return Object.assign(issue, { dist });
75643       }).sort(function byDistance(a2, b2) {
75644         return a2.dist - b2.dist;
75645       });
75646       issues = issues.slice(0, 1e3);
75647       selection2.call(drawIssuesList, issues);
75648     }
75649     function drawIssuesList(selection2, issues) {
75650       var list2 = selection2.selectAll(".issues-list").data([0]);
75651       list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2);
75652       var items = list2.selectAll("li").data(issues, function(d2) {
75653         return d2.key;
75654       });
75655       items.exit().remove();
75656       var itemsEnter = items.enter().append("li").attr("class", function(d2) {
75657         return "issue severity-" + d2.severity;
75658       });
75659       var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) {
75660         context.validator().focusIssue(d2);
75661       }).on("mouseover", function(d3_event, d2) {
75662         utilHighlightEntities(d2.entityIds, true, context);
75663       }).on("mouseout", function(d3_event, d2) {
75664         utilHighlightEntities(d2.entityIds, false, context);
75665       });
75666       var textEnter = labelsEnter.append("span").attr("class", "issue-text");
75667       textEnter.append("span").attr("class", "issue-icon").each(function(d2) {
75668         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
75669         select_default2(this).call(svgIcon(iconName));
75670       });
75671       textEnter.append("span").attr("class", "issue-message");
75672       items = items.merge(itemsEnter).order();
75673       items.selectAll(".issue-message").text("").each(function(d2) {
75674         return d2.message(context)(select_default2(this));
75675       });
75676     }
75677     context.validator().on("validated.uiSectionValidationIssues" + id2, function() {
75678       window.requestIdleCallback(function() {
75679         reloadIssues();
75680         section.reRender();
75681       });
75682     });
75683     context.map().on(
75684       "move.uiSectionValidationIssues" + id2,
75685       debounce_default(function() {
75686         window.requestIdleCallback(function() {
75687           if (getOptions().where === "visible") {
75688             reloadIssues();
75689           }
75690           section.reRender();
75691         });
75692       }, 1e3)
75693     );
75694     return section;
75695   }
75696
75697   // modules/ui/sections/validation_options.js
75698   function uiSectionValidationOptions(context) {
75699     var section = uiSection("issues-options", context).content(renderContent);
75700     function renderContent(selection2) {
75701       var container = selection2.selectAll(".issues-options-container").data([0]);
75702       container = container.enter().append("div").attr("class", "issues-options-container").merge(container);
75703       var data = [
75704         { key: "what", values: ["edited", "all"] },
75705         { key: "where", values: ["visible", "all"] }
75706       ];
75707       var options2 = container.selectAll(".issues-option").data(data, function(d2) {
75708         return d2.key;
75709       });
75710       var optionsEnter = options2.enter().append("div").attr("class", function(d2) {
75711         return "issues-option issues-option-" + d2.key;
75712       });
75713       optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) {
75714         return _t.html("issues.options." + d2.key + ".title");
75715       });
75716       var valuesEnter = optionsEnter.selectAll("label").data(function(d2) {
75717         return d2.values.map(function(val) {
75718           return { value: val, key: d2.key };
75719         });
75720       }).enter().append("label");
75721       valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) {
75722         return "issues-option-" + d2.key;
75723       }).attr("value", function(d2) {
75724         return d2.value;
75725       }).property("checked", function(d2) {
75726         return getOptions()[d2.key] === d2.value;
75727       }).on("change", function(d3_event, d2) {
75728         updateOptionValue(d3_event, d2.key, d2.value);
75729       });
75730       valuesEnter.append("span").html(function(d2) {
75731         return _t.html("issues.options." + d2.key + "." + d2.value);
75732       });
75733     }
75734     function getOptions() {
75735       return {
75736         what: corePreferences("validate-what") || "edited",
75737         // 'all', 'edited'
75738         where: corePreferences("validate-where") || "all"
75739         // 'all', 'visible'
75740       };
75741     }
75742     function updateOptionValue(d3_event, d2, val) {
75743       if (!val && d3_event && d3_event.target) {
75744         val = d3_event.target.value;
75745       }
75746       corePreferences("validate-" + d2, val);
75747       context.validator().validate();
75748     }
75749     return section;
75750   }
75751
75752   // modules/ui/sections/validation_rules.js
75753   function uiSectionValidationRules(context) {
75754     var MINSQUARE = 0;
75755     var MAXSQUARE = 20;
75756     var DEFAULTSQUARE = 5;
75757     var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title"));
75758     var _ruleKeys = context.validator().getRuleKeys().filter(function(key) {
75759       return key !== "maprules";
75760     }).sort(function(key1, key2) {
75761       return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1;
75762     });
75763     function renderDisclosureContent(selection2) {
75764       var container = selection2.selectAll(".issues-rulelist-container").data([0]);
75765       var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container");
75766       containerEnter.append("ul").attr("class", "layer-list issue-rules-list");
75767       var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer");
75768       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
75769         d3_event.preventDefault();
75770         context.validator().disableRules(_ruleKeys);
75771       });
75772       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
75773         d3_event.preventDefault();
75774         context.validator().disableRules([]);
75775       });
75776       container = container.merge(containerEnter);
75777       container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled);
75778     }
75779     function drawListItems(selection2, data, type2, name, change, active) {
75780       var items = selection2.selectAll("li").data(data);
75781       items.exit().remove();
75782       var enter = items.enter().append("li");
75783       if (name === "rule") {
75784         enter.call(
75785           uiTooltip().title(function(d2) {
75786             return _t.append("issues." + d2 + ".tip");
75787           }).placement("top")
75788         );
75789       }
75790       var label = enter.append("label");
75791       label.append("input").attr("type", type2).attr("name", name).on("change", change);
75792       label.append("span").html(function(d2) {
75793         var params = {};
75794         if (d2 === "unsquare_way") {
75795           params.val = { html: '<span class="square-degrees"></span>' };
75796         }
75797         return _t.html("issues." + d2 + ".title", params);
75798       });
75799       items = items.merge(enter);
75800       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
75801       var degStr = corePreferences("validate-square-degrees");
75802       if (degStr === null) {
75803         degStr = DEFAULTSQUARE.toString();
75804       }
75805       var span = items.selectAll(".square-degrees");
75806       var input = span.selectAll(".square-degrees-input").data([0]);
75807       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) {
75808         d3_event.preventDefault();
75809         d3_event.stopPropagation();
75810         this.select();
75811       }).on("keyup", function(d3_event) {
75812         if (d3_event.keyCode === 13) {
75813           this.blur();
75814           this.select();
75815         }
75816       }).on("blur", changeSquare).merge(input).property("value", degStr);
75817     }
75818     function changeSquare() {
75819       var input = select_default2(this);
75820       var degStr = utilGetSetValue(input).trim();
75821       var degNum = Number(degStr);
75822       if (!isFinite(degNum)) {
75823         degNum = DEFAULTSQUARE;
75824       } else if (degNum > MAXSQUARE) {
75825         degNum = MAXSQUARE;
75826       } else if (degNum < MINSQUARE) {
75827         degNum = MINSQUARE;
75828       }
75829       degNum = Math.round(degNum * 10) / 10;
75830       degStr = degNum.toString();
75831       input.property("value", degStr);
75832       corePreferences("validate-square-degrees", degStr);
75833       context.validator().revalidateUnsquare();
75834     }
75835     function isRuleEnabled(d2) {
75836       return context.validator().isRuleEnabled(d2);
75837     }
75838     function toggleRule(d3_event, d2) {
75839       context.validator().toggleRule(d2);
75840     }
75841     context.validator().on("validated.uiSectionValidationRules", function() {
75842       window.requestIdleCallback(section.reRender);
75843     });
75844     return section;
75845   }
75846
75847   // modules/ui/sections/validation_status.js
75848   function uiSectionValidationStatus(context) {
75849     var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() {
75850       var issues = context.validator().getIssues(getOptions());
75851       return issues.length === 0;
75852     });
75853     function getOptions() {
75854       return {
75855         what: corePreferences("validate-what") || "edited",
75856         where: corePreferences("validate-where") || "all"
75857       };
75858     }
75859     function renderContent(selection2) {
75860       var box = selection2.selectAll(".box").data([0]);
75861       var boxEnter = box.enter().append("div").attr("class", "box");
75862       boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text"));
75863       var noIssuesMessage = boxEnter.append("span");
75864       noIssuesMessage.append("strong").attr("class", "message");
75865       noIssuesMessage.append("br");
75866       noIssuesMessage.append("span").attr("class", "details");
75867       renderIgnoredIssuesReset(selection2);
75868       setNoIssuesText(selection2);
75869     }
75870     function renderIgnoredIssuesReset(selection2) {
75871       var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" });
75872       var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []);
75873       resetIgnored.exit().remove();
75874       var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer");
75875       resetIgnoredEnter.append("a").attr("href", "#");
75876       resetIgnored = resetIgnored.merge(resetIgnoredEnter);
75877       resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length }));
75878       resetIgnored.on("click", function(d3_event) {
75879         d3_event.preventDefault();
75880         context.validator().resetIgnoredIssues();
75881       });
75882     }
75883     function setNoIssuesText(selection2) {
75884       var opts = getOptions();
75885       function checkForHiddenIssues(cases) {
75886         for (var type2 in cases) {
75887           var hiddenOpts = cases[type2];
75888           var hiddenIssues = context.validator().getIssues(hiddenOpts);
75889           if (hiddenIssues.length) {
75890             selection2.select(".box .details").html("").call(_t.append(
75891               "issues.no_issues.hidden_issues." + type2,
75892               { count: hiddenIssues.length.toString() }
75893             ));
75894             return;
75895           }
75896         }
75897         selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none"));
75898       }
75899       var messageType;
75900       if (opts.what === "edited" && opts.where === "visible") {
75901         messageType = "edits_in_view";
75902         checkForHiddenIssues({
75903           elsewhere: { what: "edited", where: "all" },
75904           everything_else: { what: "all", where: "visible" },
75905           disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" },
75906           everything_else_elsewhere: { what: "all", where: "all" },
75907           disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" },
75908           ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" },
75909           ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" }
75910         });
75911       } else if (opts.what === "edited" && opts.where === "all") {
75912         messageType = "edits";
75913         checkForHiddenIssues({
75914           everything_else: { what: "all", where: "all" },
75915           disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" },
75916           ignored_issues: { what: "edited", where: "all", includeIgnored: "only" }
75917         });
75918       } else if (opts.what === "all" && opts.where === "visible") {
75919         messageType = "everything_in_view";
75920         checkForHiddenIssues({
75921           elsewhere: { what: "all", where: "all" },
75922           disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" },
75923           disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" },
75924           ignored_issues: { what: "all", where: "visible", includeIgnored: "only" },
75925           ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" }
75926         });
75927       } else if (opts.what === "all" && opts.where === "all") {
75928         messageType = "everything";
75929         checkForHiddenIssues({
75930           disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" },
75931           ignored_issues: { what: "all", where: "all", includeIgnored: "only" }
75932         });
75933       }
75934       if (opts.what === "edited" && context.history().difference().summary().length === 0) {
75935         messageType = "no_edits";
75936       }
75937       selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType));
75938     }
75939     context.validator().on("validated.uiSectionValidationStatus", function() {
75940       window.requestIdleCallback(section.reRender);
75941     });
75942     context.map().on(
75943       "move.uiSectionValidationStatus",
75944       debounce_default(function() {
75945         window.requestIdleCallback(section.reRender);
75946       }, 1e3)
75947     );
75948     return section;
75949   }
75950
75951   // modules/ui/panes/issues.js
75952   function uiPaneIssues(context) {
75953     var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([
75954       uiSectionValidationOptions(context),
75955       uiSectionValidationStatus(context),
75956       uiSectionValidationIssues("issues-errors", "error", context),
75957       uiSectionValidationIssues("issues-warnings", "warning", context),
75958       uiSectionValidationRules(context)
75959     ]);
75960     return issuesPane;
75961   }
75962
75963   // modules/ui/settings/custom_data.js
75964   function uiSettingsCustomData(context) {
75965     var dispatch14 = dispatch_default("change");
75966     function render(selection2) {
75967       var dataLayer = context.layers().layer("data");
75968       var _origSettings = {
75969         fileList: dataLayer && dataLayer.fileList() || null,
75970         url: corePreferences("settings-custom-data-url")
75971       };
75972       var _currSettings = {
75973         fileList: dataLayer && dataLayer.fileList() || null
75974         // url: prefs('settings-custom-data-url')
75975       };
75976       var modal = uiConfirm(selection2).okButton();
75977       modal.classed("settings-modal settings-custom-data", true);
75978       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header"));
75979       var textSection = modal.select(".modal-section.message-text");
75980       textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions"));
75981       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) {
75982         var files = d3_event.target.files;
75983         if (files && files.length) {
75984           _currSettings.url = "";
75985           textSection.select(".field-url").property("value", "");
75986           _currSettings.fileList = files;
75987         } else {
75988           _currSettings.fileList = null;
75989         }
75990       });
75991       textSection.append("h4").call(_t.append("settings.custom_data.or"));
75992       textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions"));
75993       textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url);
75994       var buttonSection = modal.select(".modal-section.buttons");
75995       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
75996       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
75997       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
75998       function isSaveDisabled() {
75999         return null;
76000       }
76001       function clickCancel() {
76002         textSection.select(".field-url").property("value", _origSettings.url);
76003         corePreferences("settings-custom-data-url", _origSettings.url);
76004         this.blur();
76005         modal.close();
76006       }
76007       function clickSave() {
76008         _currSettings.url = textSection.select(".field-url").property("value").trim();
76009         if (_currSettings.url) {
76010           _currSettings.fileList = null;
76011         }
76012         if (_currSettings.fileList) {
76013           _currSettings.url = "";
76014         }
76015         corePreferences("settings-custom-data-url", _currSettings.url);
76016         this.blur();
76017         modal.close();
76018         dispatch14.call("change", this, _currSettings);
76019       }
76020     }
76021     return utilRebind(render, dispatch14, "on");
76022   }
76023
76024   // modules/ui/sections/data_layers.js
76025   function uiSectionDataLayers(context) {
76026     var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged);
76027     var layers = context.layers();
76028     var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent);
76029     function renderDisclosureContent(selection2) {
76030       var container = selection2.selectAll(".data-layer-container").data([0]);
76031       container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems);
76032     }
76033     function showsLayer(which) {
76034       var layer = layers.layer(which);
76035       if (layer) {
76036         return layer.enabled();
76037       }
76038       return false;
76039     }
76040     function setLayer(which, enabled) {
76041       var mode = context.mode();
76042       if (mode && /^draw/.test(mode.id))
76043         return;
76044       var layer = layers.layer(which);
76045       if (layer) {
76046         layer.enabled(enabled);
76047         if (!enabled && (which === "osm" || which === "notes")) {
76048           context.enter(modeBrowse(context));
76049         }
76050       }
76051     }
76052     function toggleLayer(which) {
76053       setLayer(which, !showsLayer(which));
76054     }
76055     function drawOsmItems(selection2) {
76056       var osmKeys = ["osm", "notes"];
76057       var osmLayers = layers.all().filter(function(obj) {
76058         return osmKeys.indexOf(obj.id) !== -1;
76059       });
76060       var ul = selection2.selectAll(".layer-list-osm").data([0]);
76061       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul);
76062       var li = ul.selectAll(".list-item").data(osmLayers);
76063       li.exit().remove();
76064       var liEnter = li.enter().append("li").attr("class", function(d2) {
76065         return "list-item list-item-" + d2.id;
76066       });
76067       var labelEnter = liEnter.append("label").each(function(d2) {
76068         if (d2.id === "osm") {
76069           select_default2(this).call(
76070             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom")
76071           );
76072         } else {
76073           select_default2(this).call(
76074             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76075           );
76076         }
76077       });
76078       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76079         toggleLayer(d2.id);
76080       });
76081       labelEnter.append("span").html(function(d2) {
76082         return _t.html("map_data.layers." + d2.id + ".title");
76083       });
76084       li.merge(liEnter).classed("active", function(d2) {
76085         return d2.layer.enabled();
76086       }).selectAll("input").property("checked", function(d2) {
76087         return d2.layer.enabled();
76088       });
76089     }
76090     function drawQAItems(selection2) {
76091       var qaKeys = ["keepRight", "improveOSM", "osmose"];
76092       var qaLayers = layers.all().filter(function(obj) {
76093         return qaKeys.indexOf(obj.id) !== -1;
76094       });
76095       var ul = selection2.selectAll(".layer-list-qa").data([0]);
76096       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul);
76097       var li = ul.selectAll(".list-item").data(qaLayers);
76098       li.exit().remove();
76099       var liEnter = li.enter().append("li").attr("class", function(d2) {
76100         return "list-item list-item-" + d2.id;
76101       });
76102       var labelEnter = liEnter.append("label").each(function(d2) {
76103         select_default2(this).call(
76104           uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76105         );
76106       });
76107       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76108         toggleLayer(d2.id);
76109       });
76110       labelEnter.append("span").each(function(d2) {
76111         _t.append("map_data.layers." + d2.id + ".title")(select_default2(this));
76112       });
76113       li.merge(liEnter).classed("active", function(d2) {
76114         return d2.layer.enabled();
76115       }).selectAll("input").property("checked", function(d2) {
76116         return d2.layer.enabled();
76117       });
76118     }
76119     function drawVectorItems(selection2) {
76120       var dataLayer = layers.layer("data");
76121       var vtData = [
76122         {
76123           name: "Detroit Neighborhoods/Parks",
76124           src: "neighborhoods-parks",
76125           tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.",
76126           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"
76127         },
76128         {
76129           name: "Detroit Composite POIs",
76130           src: "composite-poi",
76131           tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.",
76132           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"
76133         },
76134         {
76135           name: "Detroit All-The-Places POIs",
76136           src: "alltheplaces-poi",
76137           tooltip: "Public domain business location data created by web scrapers.",
76138           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"
76139         }
76140       ];
76141       var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]);
76142       var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center());
76143       var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []);
76144       container.exit().remove();
76145       var containerEnter = container.enter().append("div").attr("class", "vectortile-container");
76146       containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)");
76147       containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile");
76148       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");
76149       container = container.merge(containerEnter);
76150       var ul = container.selectAll(".layer-list-vectortile");
76151       var li = ul.selectAll(".list-item").data(vtData);
76152       li.exit().remove();
76153       var liEnter = li.enter().append("li").attr("class", function(d2) {
76154         return "list-item list-item-" + d2.src;
76155       });
76156       var labelEnter = liEnter.append("label").each(function(d2) {
76157         select_default2(this).call(
76158           uiTooltip().title(d2.tooltip).placement("top")
76159         );
76160       });
76161       labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer);
76162       labelEnter.append("span").text(function(d2) {
76163         return d2.name;
76164       });
76165       li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected);
76166       function isVTLayerSelected(d2) {
76167         return dataLayer && dataLayer.template() === d2.template;
76168       }
76169       function selectVTLayer(d3_event, d2) {
76170         corePreferences("settings-custom-data-url", d2.template);
76171         if (dataLayer) {
76172           dataLayer.template(d2.template, d2.src);
76173           dataLayer.enabled(true);
76174         }
76175       }
76176     }
76177     function drawCustomDataItems(selection2) {
76178       var dataLayer = layers.layer("data");
76179       var hasData = dataLayer && dataLayer.hasData();
76180       var showsData = hasData && dataLayer.enabled();
76181       var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []);
76182       ul.exit().remove();
76183       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data");
76184       var liEnter = ulEnter.append("li").attr("class", "list-item-data");
76185       var labelEnter = liEnter.append("label").call(
76186         uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top")
76187       );
76188       labelEnter.append("input").attr("type", "checkbox").on("change", function() {
76189         toggleLayer("data");
76190       });
76191       labelEnter.append("span").call(_t.append("map_data.layers.custom.title"));
76192       liEnter.append("button").attr("class", "open-data-options").call(
76193         uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76194       ).on("click", function(d3_event) {
76195         d3_event.preventDefault();
76196         editCustom();
76197       }).call(svgIcon("#iD-icon-more"));
76198       liEnter.append("button").attr("class", "zoom-to-data").call(
76199         uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76200       ).on("click", function(d3_event) {
76201         if (select_default2(this).classed("disabled"))
76202           return;
76203         d3_event.preventDefault();
76204         d3_event.stopPropagation();
76205         dataLayer.fitZoom();
76206       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76207       ul = ul.merge(ulEnter);
76208       ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76209       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76210     }
76211     function editCustom() {
76212       context.container().call(settingsCustomData);
76213     }
76214     function customChanged(d2) {
76215       var dataLayer = layers.layer("data");
76216       if (d2 && d2.url) {
76217         dataLayer.url(d2.url);
76218       } else if (d2 && d2.fileList) {
76219         dataLayer.fileList(d2.fileList);
76220       }
76221     }
76222     function drawPanelItems(selection2) {
76223       var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list");
76224       var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call(
76225         uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top")
76226       );
76227       historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76228         d3_event.preventDefault();
76229         context.ui().info.toggle("history");
76230       });
76231       historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title"));
76232       var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call(
76233         uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top")
76234       );
76235       measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76236         d3_event.preventDefault();
76237         context.ui().info.toggle("measurement");
76238       });
76239       measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title"));
76240     }
76241     context.layers().on("change.uiSectionDataLayers", section.reRender);
76242     context.map().on(
76243       "move.uiSectionDataLayers",
76244       debounce_default(function() {
76245         window.requestIdleCallback(section.reRender);
76246       }, 1e3)
76247     );
76248     return section;
76249   }
76250
76251   // modules/ui/sections/map_features.js
76252   function uiSectionMapFeatures(context) {
76253     var _features = context.features().keys();
76254     var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76255     function renderDisclosureContent(selection2) {
76256       var container = selection2.selectAll(".layer-feature-list-container").data([0]);
76257       var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container");
76258       containerEnter.append("ul").attr("class", "layer-list layer-feature-list");
76259       var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer");
76260       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
76261         d3_event.preventDefault();
76262         context.features().disableAll();
76263       });
76264       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
76265         d3_event.preventDefault();
76266         context.features().enableAll();
76267       });
76268       container = container.merge(containerEnter);
76269       container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature);
76270     }
76271     function drawListItems(selection2, data, type2, name, change, active) {
76272       var items = selection2.selectAll("li").data(data);
76273       items.exit().remove();
76274       var enter = items.enter().append("li").call(
76275         uiTooltip().title(function(d2) {
76276           var tip = _t.append(name + "." + d2 + ".tooltip");
76277           if (autoHiddenFeature(d2)) {
76278             var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden");
76279             return (selection3) => {
76280               selection3.call(tip);
76281               selection3.append("div").call(msg);
76282             };
76283           }
76284           return tip;
76285         }).placement("top")
76286       );
76287       var label = enter.append("label");
76288       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76289       label.append("span").html(function(d2) {
76290         return _t.html(name + "." + d2 + ".description");
76291       });
76292       items = items.merge(enter);
76293       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature);
76294     }
76295     function autoHiddenFeature(d2) {
76296       return context.features().autoHidden(d2);
76297     }
76298     function showsFeature(d2) {
76299       return context.features().enabled(d2);
76300     }
76301     function clickFeature(d3_event, d2) {
76302       context.features().toggle(d2);
76303     }
76304     function showsLayer(id2) {
76305       var layer = context.layers().layer(id2);
76306       return layer && layer.enabled();
76307     }
76308     context.features().on("change.map_features", section.reRender);
76309     return section;
76310   }
76311
76312   // modules/ui/sections/map_style_options.js
76313   function uiSectionMapStyleOptions(context) {
76314     var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76315     function renderDisclosureContent(selection2) {
76316       var container = selection2.selectAll(".layer-fill-list").data([0]);
76317       container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill);
76318       var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]);
76319       container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() {
76320         return context.surface().classed("highlight-edited");
76321       });
76322     }
76323     function drawListItems(selection2, data, type2, name, change, active) {
76324       var items = selection2.selectAll("li").data(data);
76325       items.exit().remove();
76326       var enter = items.enter().append("li").call(
76327         uiTooltip().title(function(d2) {
76328           return _t.append(name + "." + d2 + ".tooltip");
76329         }).keys(function(d2) {
76330           var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null;
76331           if (d2 === "highlight_edits")
76332             key = _t("map_data.highlight_edits.key");
76333           return key ? [key] : null;
76334         }).placement("top")
76335       );
76336       var label = enter.append("label");
76337       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76338       label.append("span").html(function(d2) {
76339         return _t.html(name + "." + d2 + ".description");
76340       });
76341       items = items.merge(enter);
76342       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
76343     }
76344     function isActiveFill(d2) {
76345       return context.map().activeAreaFill() === d2;
76346     }
76347     function toggleHighlightEdited(d3_event) {
76348       d3_event.preventDefault();
76349       context.map().toggleHighlightEdited();
76350     }
76351     function setFill(d3_event, d2) {
76352       context.map().activeAreaFill(d2);
76353     }
76354     context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender);
76355     return section;
76356   }
76357
76358   // modules/ui/settings/local_photos.js
76359   function uiSettingsLocalPhotos(context) {
76360     var dispatch14 = dispatch_default("change");
76361     var photoLayer = context.layers().layer("local-photos");
76362     var modal;
76363     function render(selection2) {
76364       modal = uiConfirm(selection2).okButton();
76365       modal.classed("settings-modal settings-local-photos", true);
76366       modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header"));
76367       modal.select(".modal-section.message-text").append("div").classed("local-photos", true);
76368       var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true);
76369       instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions"));
76370       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) {
76371         var files = d3_event.target.files;
76372         if (files && files.length) {
76373           photoList.select("ul").append("li").classed("placeholder", true).append("div");
76374           dispatch14.call("change", this, files);
76375         }
76376         d3_event.target.value = null;
76377       });
76378       instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label"));
76379       const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true);
76380       photoList.append("ul");
76381       updatePhotoList(photoList.select("ul"));
76382       context.layers().on("change", () => updatePhotoList(photoList.select("ul")));
76383     }
76384     function updatePhotoList(container) {
76385       var _a2;
76386       function locationUnavailable(d2) {
76387         return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
76388       }
76389       container.selectAll("li.placeholder").remove();
76390       let selection2 = container.selectAll("li").data((_a2 = photoLayer.getPhotos()) != null ? _a2 : [], (d2) => d2.id);
76391       selection2.exit().remove();
76392       const selectionEnter = selection2.enter().append("li");
76393       selectionEnter.append("span").classed("filename", true);
76394       selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot"));
76395       selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call(
76396         uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left")
76397       );
76398       selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
76399       selection2 = selection2.merge(selectionEnter);
76400       selection2.classed("invalid", locationUnavailable);
76401       selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name);
76402       selection2.select("span.filename").on("click", (d3_event, d2) => {
76403         photoLayer.openPhoto(d3_event, d2, false);
76404       });
76405       selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => {
76406         photoLayer.openPhoto(d3_event, d2, true);
76407       });
76408       selection2.select("button.remove").on("click", (d3_event, d2) => {
76409         photoLayer.removePhoto(d2.id);
76410         updatePhotoList(container);
76411       });
76412     }
76413     return utilRebind(render, dispatch14, "on");
76414   }
76415
76416   // modules/ui/sections/photo_overlays.js
76417   function uiSectionPhotoOverlays(context) {
76418     var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged);
76419     var layers = context.layers();
76420     var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76421     function renderDisclosureContent(selection2) {
76422       var container = selection2.selectAll(".photo-overlay-container").data([0]);
76423       container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
76424     }
76425     function drawPhotoItems(selection2) {
76426       var photoKeys = context.photos().overlayLayerIDs();
76427       var photoLayers = layers.all().filter(function(obj) {
76428         return photoKeys.indexOf(obj.id) !== -1;
76429       });
76430       var data = photoLayers.filter(function(obj) {
76431         if (!obj.layer.supported())
76432           return false;
76433         if (layerEnabled(obj))
76434           return true;
76435         if (typeof obj.layer.validHere === "function") {
76436           return obj.layer.validHere(context.map().extent(), context.map().zoom());
76437         }
76438         return true;
76439       });
76440       function layerSupported(d2) {
76441         return d2.layer && d2.layer.supported();
76442       }
76443       function layerEnabled(d2) {
76444         return layerSupported(d2) && d2.layer.enabled();
76445       }
76446       function layerRendered(d2) {
76447         var _a2, _b, _c;
76448         return (_c = (_b = (_a2 = d2.layer).rendered) == null ? void 0 : _b.call(_a2, context.map().zoom())) != null ? _c : true;
76449       }
76450       var ul = selection2.selectAll(".layer-list-photos").data([0]);
76451       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
76452       var li = ul.selectAll(".list-item-photos").data(data);
76453       li.exit().remove();
76454       var liEnter = li.enter().append("li").attr("class", function(d2) {
76455         var classes = "list-item-photos list-item-" + d2.id;
76456         if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") {
76457           classes += " indented";
76458         }
76459         return classes;
76460       });
76461       var labelEnter = liEnter.append("label").each(function(d2) {
76462         var titleID;
76463         if (d2.id === "mapillary-signs")
76464           titleID = "mapillary.signs.tooltip";
76465         else if (d2.id === "mapillary")
76466           titleID = "mapillary_images.tooltip";
76467         else if (d2.id === "kartaview")
76468           titleID = "kartaview_images.tooltip";
76469         else
76470           titleID = d2.id.replace(/-/g, "_") + ".tooltip";
76471         select_default2(this).call(
76472           uiTooltip().title(() => {
76473             if (!layerRendered(d2)) {
76474               return _t.append("street_side.minzoom_tooltip");
76475             } else {
76476               return _t.append(titleID);
76477             }
76478           }).placement("top")
76479         );
76480       });
76481       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76482         toggleLayer(d2.id);
76483       });
76484       labelEnter.append("span").html(function(d2) {
76485         var id2 = d2.id;
76486         if (id2 === "mapillary-signs")
76487           id2 = "photo_overlays.traffic_signs";
76488         return _t.html(id2.replace(/-/g, "_") + ".title");
76489       });
76490       li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled);
76491     }
76492     function drawPhotoTypeItems(selection2) {
76493       var data = context.photos().allPhotoTypes();
76494       function typeEnabled(d2) {
76495         return context.photos().showsPhotoType(d2);
76496       }
76497       var ul = selection2.selectAll(".layer-list-photo-types").data([0]);
76498       ul.exit().remove();
76499       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul);
76500       var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []);
76501       li.exit().remove();
76502       var liEnter = li.enter().append("li").attr("class", function(d2) {
76503         return "list-item-photo-types list-item-" + d2;
76504       });
76505       var labelEnter = liEnter.append("label").each(function(d2) {
76506         select_default2(this).call(
76507           uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top")
76508         );
76509       });
76510       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76511         context.photos().togglePhotoType(d2);
76512       });
76513       labelEnter.append("span").html(function(d2) {
76514         return _t.html("photo_overlays.photo_type." + d2 + ".title");
76515       });
76516       li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled);
76517     }
76518     function drawDateFilter(selection2) {
76519       var data = context.photos().dateFilters();
76520       function filterEnabled(d2) {
76521         return context.photos().dateFilterValue(d2);
76522       }
76523       var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
76524       ul.exit().remove();
76525       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
76526       var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
76527       li.exit().remove();
76528       var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
76529       var labelEnter = liEnter.append("label").each(function(d2) {
76530         select_default2(this).call(
76531           uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
76532         );
76533       });
76534       labelEnter.append("span").each(function(d2) {
76535         _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
76536       });
76537       labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
76538         utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
76539       }).on("change", function(d3_event, d2) {
76540         var value = utilGetSetValue(select_default2(this)).trim();
76541         context.photos().setDateFilter(d2, value, true);
76542         li.selectAll("input").each(function(d4) {
76543           utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
76544         });
76545       });
76546       li = li.merge(liEnter).classed("active", filterEnabled);
76547     }
76548     function drawUsernameFilter(selection2) {
76549       function filterEnabled() {
76550         return context.photos().usernames();
76551       }
76552       var ul = selection2.selectAll(".layer-list-username-filter").data([0]);
76553       ul.exit().remove();
76554       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul);
76555       var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []);
76556       li.exit().remove();
76557       var liEnter = li.enter().append("li").attr("class", "list-item-username-filter");
76558       var labelEnter = liEnter.append("label").each(function() {
76559         select_default2(this).call(
76560           uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top")
76561         );
76562       });
76563       labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title"));
76564       labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() {
76565         var value = select_default2(this).property("value");
76566         context.photos().setUsernameFilter(value, true);
76567         select_default2(this).property("value", usernameValue);
76568       });
76569       li.merge(liEnter).classed("active", filterEnabled);
76570       function usernameValue() {
76571         var usernames = context.photos().usernames();
76572         if (usernames)
76573           return usernames.join("; ");
76574         return usernames;
76575       }
76576     }
76577     function toggleLayer(which) {
76578       setLayer(which, !showsLayer(which));
76579     }
76580     function showsLayer(which) {
76581       var layer = layers.layer(which);
76582       if (layer) {
76583         return layer.enabled();
76584       }
76585       return false;
76586     }
76587     function setLayer(which, enabled) {
76588       var layer = layers.layer(which);
76589       if (layer) {
76590         layer.enabled(enabled);
76591       }
76592     }
76593     function drawLocalPhotos(selection2) {
76594       var photoLayer = layers.layer("local-photos");
76595       var hasData = photoLayer && photoLayer.hasData();
76596       var showsData = hasData && photoLayer.enabled();
76597       var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []);
76598       ul.exit().remove();
76599       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos");
76600       var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos");
76601       var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip")));
76602       localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() {
76603         toggleLayer("local-photos");
76604       });
76605       localPhotosLabelEnter.call(_t.append("local_photos.header"));
76606       localPhotosEnter.append("button").attr("class", "open-data-options").call(
76607         uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76608       ).on("click", function(d3_event) {
76609         d3_event.preventDefault();
76610         editLocalPhotos();
76611       }).call(svgIcon("#iD-icon-more"));
76612       localPhotosEnter.append("button").attr("class", "zoom-to-data").call(
76613         uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76614       ).on("click", function(d3_event) {
76615         if (select_default2(this).classed("disabled"))
76616           return;
76617         d3_event.preventDefault();
76618         d3_event.stopPropagation();
76619         photoLayer.fitZoom();
76620       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76621       ul = ul.merge(ulEnter);
76622       ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76623       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76624     }
76625     function editLocalPhotos() {
76626       context.container().call(settingsLocalPhotos);
76627     }
76628     function localPhotosChanged(d2) {
76629       var localPhotosLayer = layers.layer("local-photos");
76630       localPhotosLayer.fileList(d2);
76631     }
76632     context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
76633     context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
76634     context.map().on(
76635       "move.photo_overlays",
76636       debounce_default(function() {
76637         window.requestIdleCallback(section.reRender);
76638       }, 1e3)
76639     );
76640     return section;
76641   }
76642
76643   // modules/ui/panes/map_data.js
76644   function uiPaneMapData(context) {
76645     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([
76646       uiSectionDataLayers(context),
76647       uiSectionPhotoOverlays(context),
76648       uiSectionMapStyleOptions(context),
76649       uiSectionMapFeatures(context)
76650     ]);
76651     return mapDataPane;
76652   }
76653
76654   // modules/ui/panes/preferences.js
76655   function uiPanePreferences(context) {
76656     let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([
76657       uiSectionPrivacy(context)
76658     ]);
76659     return preferencesPane;
76660   }
76661
76662   // modules/ui/init.js
76663   function uiInit(context) {
76664     var _initCounter = 0;
76665     var _needWidth = {};
76666     var _lastPointerType;
76667     function render(container) {
76668       container.on("click.ui", function(d3_event) {
76669         if (d3_event.button !== 0)
76670           return;
76671         if (!d3_event.composedPath)
76672           return;
76673         var isOkayTarget = d3_event.composedPath().some(function(node) {
76674           return node.nodeType === 1 && // clicking <input> focuses it and/or changes a value
76675           (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
76676           node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
76677           node.nodeName === "A");
76678         });
76679         if (isOkayTarget)
76680           return;
76681         d3_event.preventDefault();
76682       });
76683       var detected = utilDetect();
76684       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
76685       // but we only need to do this on desktop Safari anyway. – #7694
76686       !detected.isMobileWebKit) {
76687         container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
76688           d3_event.preventDefault();
76689         });
76690       }
76691       if ("PointerEvent" in window) {
76692         select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
76693           var pointerType = d3_event.pointerType || "mouse";
76694           if (_lastPointerType !== pointerType) {
76695             _lastPointerType = pointerType;
76696             container.attr("pointer", pointerType);
76697           }
76698         }, true);
76699       } else {
76700         _lastPointerType = "mouse";
76701         container.attr("pointer", "mouse");
76702       }
76703       container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
76704       container.call(uiFullScreen(context));
76705       var map2 = context.map();
76706       map2.redrawEnable(false);
76707       map2.on("hitMinZoom.ui", function() {
76708         ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
76709       });
76710       container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
76711       container.append("div").attr("class", "sidebar").call(ui.sidebar);
76712       var content = container.append("div").attr("class", "main-content active");
76713       content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
76714       content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
76715       var overMap = content.append("div").attr("class", "over-map");
76716       overMap.append("div").attr("class", "select-trap").text("t");
76717       overMap.call(uiMapInMap(context)).call(uiNotice(context));
76718       overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
76719       var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
76720       var controls = controlsWrap.append("div").attr("class", "map-controls");
76721       controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
76722       controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
76723       controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
76724       controlsWrap.on("wheel.mapControls", function(d3_event) {
76725         if (!d3_event.deltaX) {
76726           controlsWrap.node().scrollTop += d3_event.deltaY;
76727         }
76728       });
76729       var panes = overMap.append("div").attr("class", "map-panes");
76730       var uiPanes = [
76731         uiPaneBackground(context),
76732         uiPaneMapData(context),
76733         uiPaneIssues(context),
76734         uiPanePreferences(context),
76735         uiPaneHelp(context)
76736       ];
76737       uiPanes.forEach(function(pane) {
76738         controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
76739         panes.call(pane.renderPane);
76740       });
76741       ui.info = uiInfo(context);
76742       overMap.call(ui.info);
76743       overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
76744       overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
76745       var about = content.append("div").attr("class", "map-footer");
76746       about.append("div").attr("class", "api-status").call(uiStatus(context));
76747       var footer = about.append("div").attr("class", "map-footer-bar fillD");
76748       footer.append("div").attr("class", "flash-wrap footer-hide");
76749       var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
76750       footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
76751       var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
76752       aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
76753       var apiConnections = context.connection().apiConnections();
76754       if (apiConnections && apiConnections.length > 1) {
76755         aboutList.append("li").attr("class", "source-switch").call(
76756           uiSourceSwitch(context).keys(apiConnections)
76757         );
76758       }
76759       aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
76760       aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
76761       var issueLinks = aboutList.append("li");
76762       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"));
76763       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"));
76764       aboutList.append("li").attr("class", "version").call(uiVersion(context));
76765       if (!context.embed()) {
76766         aboutList.call(uiAccount(context));
76767       }
76768       ui.onResize();
76769       map2.redrawEnable(true);
76770       ui.hash = behaviorHash(context);
76771       ui.hash();
76772       if (!ui.hash.hadLocation) {
76773         map2.centerZoom([0, 0], 2);
76774       }
76775       window.onbeforeunload = function() {
76776         return context.save();
76777       };
76778       window.onunload = function() {
76779         context.history().unlock();
76780       };
76781       select_default2(window).on("resize.editor", function() {
76782         ui.onResize();
76783       });
76784       var panPixels = 80;
76785       context.keybinding().on("\u232B", function(d3_event) {
76786         d3_event.preventDefault();
76787       }).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) {
76788         if (d3_event) {
76789           d3_event.stopImmediatePropagation();
76790           d3_event.preventDefault();
76791         }
76792         var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
76793         if (previousBackground) {
76794           var currentBackground = context.background().baseLayerSource();
76795           corePreferences("background-last-used-toggle", currentBackground.id);
76796           corePreferences("background-last-used", previousBackground.id);
76797           context.background().baseLayerSource(previousBackground);
76798         }
76799       }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
76800         d3_event.preventDefault();
76801         d3_event.stopPropagation();
76802         context.map().toggleWireframe();
76803       }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
76804         d3_event.preventDefault();
76805         d3_event.stopPropagation();
76806         var mode = context.mode();
76807         if (mode && /^draw/.test(mode.id))
76808           return;
76809         var layer = context.layers().layer("osm");
76810         if (layer) {
76811           layer.enabled(!layer.enabled());
76812           if (!layer.enabled()) {
76813             context.enter(modeBrowse(context));
76814           }
76815         }
76816       }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
76817         d3_event.preventDefault();
76818         context.map().toggleHighlightEdited();
76819       });
76820       context.on("enter.editor", function(entered) {
76821         container.classed("mode-" + entered.id, true);
76822       }).on("exit.editor", function(exited) {
76823         container.classed("mode-" + exited.id, false);
76824       });
76825       context.enter(modeBrowse(context));
76826       if (!_initCounter++) {
76827         if (!ui.hash.startWalkthrough) {
76828           context.container().call(uiSplash(context)).call(uiRestore(context));
76829         }
76830         context.container().call(ui.shortcuts);
76831       }
76832       var osm = context.connection();
76833       var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
76834       if (osm && auth) {
76835         osm.on("authLoading.ui", function() {
76836           context.container().call(auth);
76837         }).on("authDone.ui", function() {
76838           auth.close();
76839         });
76840       }
76841       _initCounter++;
76842       if (ui.hash.startWalkthrough) {
76843         ui.hash.startWalkthrough = false;
76844         context.container().call(uiIntro(context));
76845       }
76846       function pan(d2) {
76847         return function(d3_event) {
76848           if (d3_event.shiftKey)
76849             return;
76850           if (context.container().select(".combobox").size())
76851             return;
76852           d3_event.preventDefault();
76853           context.map().pan(d2, 100);
76854         };
76855       }
76856     }
76857     let ui = {};
76858     let _loadPromise;
76859     ui.ensureLoaded = () => {
76860       if (_loadPromise)
76861         return _loadPromise;
76862       return _loadPromise = Promise.all([
76863         // must have strings and presets before loading the UI
76864         _mainLocalizer.ensureLoaded(),
76865         _mainPresetIndex.ensureLoaded()
76866       ]).then(() => {
76867         if (!context.container().empty())
76868           render(context.container());
76869       }).catch((err) => console.error(err));
76870     };
76871     ui.restart = function() {
76872       context.keybinding().clear();
76873       _loadPromise = null;
76874       context.container().selectAll("*").remove();
76875       ui.ensureLoaded();
76876     };
76877     ui.lastPointerType = function() {
76878       return _lastPointerType;
76879     };
76880     ui.svgDefs = svgDefs(context);
76881     ui.flash = uiFlash(context);
76882     ui.sidebar = uiSidebar(context);
76883     ui.photoviewer = uiPhotoviewer(context);
76884     ui.shortcuts = uiShortcuts(context);
76885     ui.onResize = function(withPan) {
76886       var map2 = context.map();
76887       var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
76888       utilGetDimensions(context.container().select(".sidebar"), true);
76889       if (withPan !== void 0) {
76890         map2.redrawEnable(false);
76891         map2.pan(withPan);
76892         map2.redrawEnable(true);
76893       }
76894       map2.dimensions(mapDimensions);
76895       ui.photoviewer.onMapResize();
76896       ui.checkOverflow(".top-toolbar");
76897       ui.checkOverflow(".map-footer-bar");
76898       var resizeWindowEvent = document.createEvent("Event");
76899       resizeWindowEvent.initEvent("resizeWindow", true, true);
76900       document.dispatchEvent(resizeWindowEvent);
76901     };
76902     ui.checkOverflow = function(selector, reset) {
76903       if (reset) {
76904         delete _needWidth[selector];
76905       }
76906       var selection2 = context.container().select(selector);
76907       if (selection2.empty())
76908         return;
76909       var scrollWidth = selection2.property("scrollWidth");
76910       var clientWidth = selection2.property("clientWidth");
76911       var needed = _needWidth[selector] || scrollWidth;
76912       if (scrollWidth > clientWidth) {
76913         selection2.classed("narrow", true);
76914         if (!_needWidth[selector]) {
76915           _needWidth[selector] = scrollWidth;
76916         }
76917       } else if (scrollWidth >= needed) {
76918         selection2.classed("narrow", false);
76919       }
76920     };
76921     ui.togglePanes = function(showPane) {
76922       var hidePanes = context.container().selectAll(".map-pane.shown");
76923       var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
76924       hidePanes.classed("shown", false).classed("hide", true);
76925       context.container().selectAll(".map-pane-control button").classed("active", false);
76926       if (showPane) {
76927         hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
76928         context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
76929         showPane.classed("shown", true).classed("hide", false);
76930         if (hidePanes.empty()) {
76931           showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
76932         } else {
76933           showPane.style(side, "0px");
76934         }
76935       } else {
76936         hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
76937           select_default2(this).classed("shown", false).classed("hide", true);
76938         });
76939       }
76940     };
76941     var _editMenu = uiEditMenu(context);
76942     ui.editMenu = function() {
76943       return _editMenu;
76944     };
76945     ui.showEditMenu = function(anchorPoint, triggerType, operations) {
76946       ui.closeEditMenu();
76947       if (!operations && context.mode().operations)
76948         operations = context.mode().operations();
76949       if (!operations || !operations.length)
76950         return;
76951       if (!context.map().editableDataEnabled())
76952         return;
76953       var surfaceNode = context.surface().node();
76954       if (surfaceNode.focus) {
76955         surfaceNode.focus();
76956       }
76957       operations.forEach(function(operation2) {
76958         if (operation2.point)
76959           operation2.point(anchorPoint);
76960       });
76961       _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
76962       context.map().supersurface.call(_editMenu);
76963     };
76964     ui.closeEditMenu = function() {
76965       context.map().supersurface.select(".edit-menu").remove();
76966     };
76967     var _saveLoading = select_default2(null);
76968     context.uploader().on("saveStarted.ui", function() {
76969       _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
76970       context.container().call(_saveLoading);
76971     }).on("saveEnded.ui", function() {
76972       _saveLoading.close();
76973       _saveLoading = select_default2(null);
76974     });
76975     marked.use({
76976       mangle: false,
76977       headerIds: false
76978     });
76979     return ui;
76980   }
76981
76982   // modules/core/context.js
76983   function coreContext() {
76984     const dispatch14 = dispatch_default("enter", "exit", "change");
76985     let context = utilRebind({}, dispatch14, "on");
76986     let _deferred2 = /* @__PURE__ */ new Set();
76987     context.version = package_default.version;
76988     context.privacyVersion = "20201202";
76989     context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
76990     context.changeset = null;
76991     let _defaultChangesetComment = context.initialHashParams.comment;
76992     let _defaultChangesetSource = context.initialHashParams.source;
76993     let _defaultChangesetHashtags = context.initialHashParams.hashtags;
76994     context.defaultChangesetComment = function(val) {
76995       if (!arguments.length)
76996         return _defaultChangesetComment;
76997       _defaultChangesetComment = val;
76998       return context;
76999     };
77000     context.defaultChangesetSource = function(val) {
77001       if (!arguments.length)
77002         return _defaultChangesetSource;
77003       _defaultChangesetSource = val;
77004       return context;
77005     };
77006     context.defaultChangesetHashtags = function(val) {
77007       if (!arguments.length)
77008         return _defaultChangesetHashtags;
77009       _defaultChangesetHashtags = val;
77010       return context;
77011     };
77012     let _setsDocumentTitle = true;
77013     context.setsDocumentTitle = function(val) {
77014       if (!arguments.length)
77015         return _setsDocumentTitle;
77016       _setsDocumentTitle = val;
77017       return context;
77018     };
77019     let _documentTitleBase = document.title;
77020     context.documentTitleBase = function(val) {
77021       if (!arguments.length)
77022         return _documentTitleBase;
77023       _documentTitleBase = val;
77024       return context;
77025     };
77026     let _ui;
77027     context.ui = () => _ui;
77028     context.lastPointerType = () => _ui.lastPointerType();
77029     let _keybinding = utilKeybinding("context");
77030     context.keybinding = () => _keybinding;
77031     select_default2(document).call(_keybinding);
77032     let _connection = services.osm;
77033     let _history;
77034     let _validator;
77035     let _uploader;
77036     context.connection = () => _connection;
77037     context.history = () => _history;
77038     context.validator = () => _validator;
77039     context.uploader = () => _uploader;
77040     context.preauth = (options2) => {
77041       if (_connection) {
77042         _connection.switch(options2);
77043       }
77044       return context;
77045     };
77046     context.locale = function(locale2) {
77047       if (!arguments.length)
77048         return _mainLocalizer.localeCode();
77049       _mainLocalizer.preferredLocaleCodes(locale2);
77050       return context;
77051     };
77052     function afterLoad(cid, callback) {
77053       return (err, result) => {
77054         if (err) {
77055           if (err.status === 400 || err.status === 401 || err.status === 403) {
77056             if (_connection) {
77057               _connection.logout();
77058             }
77059           }
77060           if (typeof callback === "function") {
77061             callback(err);
77062           }
77063           return;
77064         } else if (_connection && _connection.getConnectionId() !== cid) {
77065           if (typeof callback === "function") {
77066             callback({ message: "Connection Switched", status: -1 });
77067           }
77068           return;
77069         } else {
77070           _history.merge(result.data, result.extent);
77071           if (typeof callback === "function") {
77072             callback(err, result);
77073           }
77074           return;
77075         }
77076       };
77077     }
77078     context.loadTiles = (projection2, callback) => {
77079       const handle = window.requestIdleCallback(() => {
77080         _deferred2.delete(handle);
77081         if (_connection && context.editableDataEnabled()) {
77082           const cid = _connection.getConnectionId();
77083           _connection.loadTiles(projection2, afterLoad(cid, callback));
77084         }
77085       });
77086       _deferred2.add(handle);
77087     };
77088     context.loadTileAtLoc = (loc, callback) => {
77089       const handle = window.requestIdleCallback(() => {
77090         _deferred2.delete(handle);
77091         if (_connection && context.editableDataEnabled()) {
77092           const cid = _connection.getConnectionId();
77093           _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
77094         }
77095       });
77096       _deferred2.add(handle);
77097     };
77098     context.loadEntity = (entityID, callback) => {
77099       if (_connection) {
77100         const cid = _connection.getConnectionId();
77101         _connection.loadEntity(entityID, afterLoad(cid, callback));
77102         _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
77103       }
77104     };
77105     context.loadNote = (entityID, callback) => {
77106       if (_connection) {
77107         const cid = _connection.getConnectionId();
77108         _connection.loadEntityNote(entityID, afterLoad(cid, callback));
77109       }
77110     };
77111     context.zoomToEntity = (entityID, zoomTo) => {
77112       context.loadEntity(entityID, (err, result) => {
77113         if (err)
77114           return;
77115         if (zoomTo !== false) {
77116           const entity = result.data.find((e3) => e3.id === entityID);
77117           if (entity) {
77118             _map.zoomTo(entity);
77119           }
77120         }
77121       });
77122       _map.on("drawn.zoomToEntity", () => {
77123         if (!context.hasEntity(entityID))
77124           return;
77125         _map.on("drawn.zoomToEntity", null);
77126         context.on("enter.zoomToEntity", null);
77127         context.enter(modeSelect(context, [entityID]));
77128       });
77129       context.on("enter.zoomToEntity", () => {
77130         if (_mode.id !== "browse") {
77131           _map.on("drawn.zoomToEntity", null);
77132           context.on("enter.zoomToEntity", null);
77133         }
77134       });
77135     };
77136     let _minEditableZoom = 16;
77137     context.minEditableZoom = function(val) {
77138       if (!arguments.length)
77139         return _minEditableZoom;
77140       _minEditableZoom = val;
77141       if (_connection) {
77142         _connection.tileZoom(val);
77143       }
77144       return context;
77145     };
77146     context.maxCharsForTagKey = () => 255;
77147     context.maxCharsForTagValue = () => 255;
77148     context.maxCharsForRelationRole = () => 255;
77149     context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
77150     context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
77151     context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
77152     let _inIntro = false;
77153     context.inIntro = function(val) {
77154       if (!arguments.length)
77155         return _inIntro;
77156       _inIntro = val;
77157       return context;
77158     };
77159     context.save = () => {
77160       if (_inIntro || context.container().select(".modal").size())
77161         return;
77162       let canSave;
77163       if (_mode && _mode.id === "save") {
77164         canSave = false;
77165         if (services.osm && services.osm.isChangesetInflight()) {
77166           _history.clearSaved();
77167           return;
77168         }
77169       } else {
77170         canSave = context.selectedIDs().every((id2) => {
77171           const entity = context.hasEntity(id2);
77172           return entity && !entity.isDegenerate();
77173         });
77174       }
77175       if (canSave) {
77176         _history.save();
77177       }
77178       if (_history.hasChanges()) {
77179         return _t("save.unsaved_changes");
77180       }
77181     };
77182     context.debouncedSave = debounce_default(context.save, 350);
77183     function withDebouncedSave(fn) {
77184       return function() {
77185         const result = fn.apply(_history, arguments);
77186         context.debouncedSave();
77187         return result;
77188       };
77189     }
77190     context.hasEntity = (id2) => _history.graph().hasEntity(id2);
77191     context.entity = (id2) => _history.graph().entity(id2);
77192     let _mode;
77193     context.mode = () => _mode;
77194     context.enter = (newMode) => {
77195       if (_mode) {
77196         _mode.exit();
77197         dispatch14.call("exit", this, _mode);
77198       }
77199       _mode = newMode;
77200       _mode.enter();
77201       dispatch14.call("enter", this, _mode);
77202     };
77203     context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
77204     context.activeID = () => _mode && _mode.activeID && _mode.activeID();
77205     let _selectedNoteID;
77206     context.selectedNoteID = function(noteID) {
77207       if (!arguments.length)
77208         return _selectedNoteID;
77209       _selectedNoteID = noteID;
77210       return context;
77211     };
77212     let _selectedErrorID;
77213     context.selectedErrorID = function(errorID) {
77214       if (!arguments.length)
77215         return _selectedErrorID;
77216       _selectedErrorID = errorID;
77217       return context;
77218     };
77219     context.install = (behavior) => context.surface().call(behavior);
77220     context.uninstall = (behavior) => context.surface().call(behavior.off);
77221     let _copyGraph;
77222     context.copyGraph = () => _copyGraph;
77223     let _copyIDs = [];
77224     context.copyIDs = function(val) {
77225       if (!arguments.length)
77226         return _copyIDs;
77227       _copyIDs = val;
77228       _copyGraph = _history.graph();
77229       return context;
77230     };
77231     let _copyLonLat;
77232     context.copyLonLat = function(val) {
77233       if (!arguments.length)
77234         return _copyLonLat;
77235       _copyLonLat = val;
77236       return context;
77237     };
77238     let _background;
77239     context.background = () => _background;
77240     let _features;
77241     context.features = () => _features;
77242     context.hasHiddenConnections = (id2) => {
77243       const graph = _history.graph();
77244       const entity = graph.entity(id2);
77245       return _features.hasHiddenConnections(entity, graph);
77246     };
77247     let _photos;
77248     context.photos = () => _photos;
77249     let _map;
77250     context.map = () => _map;
77251     context.layers = () => _map.layers();
77252     context.surface = () => _map.surface;
77253     context.editableDataEnabled = () => _map.editableDataEnabled();
77254     context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
77255     context.editable = () => {
77256       const mode = context.mode();
77257       if (!mode || mode.id === "save")
77258         return false;
77259       return _map.editableDataEnabled();
77260     };
77261     let _debugFlags = {
77262       tile: false,
77263       // tile boundaries
77264       collision: false,
77265       // label collision bounding boxes
77266       imagery: false,
77267       // imagery bounding polygons
77268       target: false,
77269       // touch targets
77270       downloaded: false
77271       // downloaded data from osm
77272     };
77273     context.debugFlags = () => _debugFlags;
77274     context.getDebug = (flag) => flag && _debugFlags[flag];
77275     context.setDebug = function(flag, val) {
77276       if (arguments.length === 1)
77277         val = true;
77278       _debugFlags[flag] = val;
77279       dispatch14.call("change");
77280       return context;
77281     };
77282     let _container = select_default2(null);
77283     context.container = function(val) {
77284       if (!arguments.length)
77285         return _container;
77286       _container = val;
77287       _container.classed("ideditor", true);
77288       return context;
77289     };
77290     context.containerNode = function(val) {
77291       if (!arguments.length)
77292         return context.container().node();
77293       context.container(select_default2(val));
77294       return context;
77295     };
77296     let _embed;
77297     context.embed = function(val) {
77298       if (!arguments.length)
77299         return _embed;
77300       _embed = val;
77301       return context;
77302     };
77303     let _assetPath = "";
77304     context.assetPath = function(val) {
77305       if (!arguments.length)
77306         return _assetPath;
77307       _assetPath = val;
77308       _mainFileFetcher.assetPath(val);
77309       return context;
77310     };
77311     let _assetMap = {};
77312     context.assetMap = function(val) {
77313       if (!arguments.length)
77314         return _assetMap;
77315       _assetMap = val;
77316       _mainFileFetcher.assetMap(val);
77317       return context;
77318     };
77319     context.asset = (val) => {
77320       if (/^http(s)?:\/\//i.test(val))
77321         return val;
77322       const filename = _assetPath + val;
77323       return _assetMap[filename] || filename;
77324     };
77325     context.imagePath = (val) => context.asset("img/".concat(val));
77326     context.reset = context.flush = () => {
77327       context.debouncedSave.cancel();
77328       Array.from(_deferred2).forEach((handle) => {
77329         window.cancelIdleCallback(handle);
77330         _deferred2.delete(handle);
77331       });
77332       Object.values(services).forEach((service) => {
77333         if (service && typeof service.reset === "function") {
77334           service.reset(context);
77335         }
77336       });
77337       context.changeset = null;
77338       _validator.reset();
77339       _features.reset();
77340       _history.reset();
77341       _uploader.reset();
77342       context.container().select(".inspector-wrap *").remove();
77343       return context;
77344     };
77345     context.projection = geoRawMercator();
77346     context.curtainProjection = geoRawMercator();
77347     context.init = () => {
77348       instantiateInternal();
77349       initializeDependents();
77350       return context;
77351       function instantiateInternal() {
77352         _history = coreHistory(context);
77353         context.graph = _history.graph;
77354         context.pauseChangeDispatch = _history.pauseChangeDispatch;
77355         context.resumeChangeDispatch = _history.resumeChangeDispatch;
77356         context.perform = withDebouncedSave(_history.perform);
77357         context.replace = withDebouncedSave(_history.replace);
77358         context.pop = withDebouncedSave(_history.pop);
77359         context.overwrite = withDebouncedSave(_history.overwrite);
77360         context.undo = withDebouncedSave(_history.undo);
77361         context.redo = withDebouncedSave(_history.redo);
77362         _validator = coreValidator(context);
77363         _uploader = coreUploader(context);
77364         _background = rendererBackground(context);
77365         _features = rendererFeatures(context);
77366         _map = rendererMap(context);
77367         _photos = rendererPhotos(context);
77368         _ui = uiInit(context);
77369       }
77370       function initializeDependents() {
77371         if (context.initialHashParams.presets) {
77372           _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
77373         }
77374         if (context.initialHashParams.locale) {
77375           _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
77376         }
77377         _mainLocalizer.ensureLoaded();
77378         _mainPresetIndex.ensureLoaded();
77379         _background.ensureLoaded();
77380         Object.values(services).forEach((service) => {
77381           if (service && typeof service.init === "function") {
77382             service.init();
77383           }
77384         });
77385         _map.init();
77386         _validator.init();
77387         _features.init();
77388         if (services.maprules && context.initialHashParams.maprules) {
77389           json_default(context.initialHashParams.maprules).then((mapcss) => {
77390             services.maprules.init();
77391             mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
77392           }).catch(() => {
77393           });
77394         }
77395         if (!context.container().empty()) {
77396           _ui.ensureLoaded().then(() => {
77397             _background.init();
77398             _photos.init();
77399           });
77400         }
77401       }
77402     };
77403     return context;
77404   }
77405
77406   // modules/services/nominatim.js
77407   var apibase = nominatimApiUrl;
77408   var _inflight = {};
77409   var _nominatimCache;
77410   var nominatim_default = {
77411     init: function() {
77412       _inflight = {};
77413       _nominatimCache = new import_rbush7.default();
77414     },
77415     reset: function() {
77416       Object.values(_inflight).forEach(function(controller) {
77417         controller.abort();
77418       });
77419       _inflight = {};
77420       _nominatimCache = new import_rbush7.default();
77421     },
77422     countryCode: function(location, callback) {
77423       this.reverse(location, function(err, result) {
77424         if (err) {
77425           return callback(err);
77426         } else if (result.address) {
77427           return callback(null, result.address.country_code);
77428         } else {
77429           return callback("Unable to geocode", null);
77430         }
77431       });
77432     },
77433     reverse: function(loc, callback) {
77434       var cached = _nominatimCache.search(
77435         { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
77436       );
77437       if (cached.length > 0) {
77438         if (callback)
77439           callback(null, cached[0].data);
77440         return;
77441       }
77442       var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
77443       var url = apibase + "reverse?" + utilQsString(params);
77444       if (_inflight[url])
77445         return;
77446       var controller = new AbortController();
77447       _inflight[url] = controller;
77448       json_default(url, {
77449         signal: controller.signal,
77450         headers: {
77451           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77452         }
77453       }).then(function(result) {
77454         delete _inflight[url];
77455         if (result && result.error) {
77456           throw new Error(result.error);
77457         }
77458         var extent = geoExtent(loc).padByMeters(200);
77459         _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
77460         if (callback)
77461           callback(null, result);
77462       }).catch(function(err) {
77463         delete _inflight[url];
77464         if (err.name === "AbortError")
77465           return;
77466         if (callback)
77467           callback(err.message);
77468       });
77469     },
77470     search: function(val, callback) {
77471       const params = {
77472         q: val,
77473         limit: 10,
77474         format: "json"
77475       };
77476       var url = apibase + "search?" + utilQsString(params);
77477       if (_inflight[url])
77478         return;
77479       var controller = new AbortController();
77480       _inflight[url] = controller;
77481       json_default(url, {
77482         signal: controller.signal,
77483         headers: {
77484           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77485         }
77486       }).then(function(result) {
77487         delete _inflight[url];
77488         if (result && result.error) {
77489           throw new Error(result.error);
77490         }
77491         if (callback)
77492           callback(null, result);
77493       }).catch(function(err) {
77494         delete _inflight[url];
77495         if (err.name === "AbortError")
77496           return;
77497         if (callback)
77498           callback(err.message);
77499       });
77500     }
77501   };
77502
77503   // node_modules/name-suggestion-index/lib/matcher.js
77504   var import_which_polygon4 = __toESM(require_which_polygon(), 1);
77505
77506   // node_modules/name-suggestion-index/lib/simplify.js
77507   var import_diacritics3 = __toESM(require_diacritics(), 1);
77508   function simplify2(str) {
77509     if (typeof str !== "string")
77510       return "";
77511     return import_diacritics3.default.remove(
77512       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()
77513     );
77514   }
77515
77516   // node_modules/name-suggestion-index/config/matchGroups.json
77517   var matchGroups_default = {
77518     matchGroups: {
77519       adult_gaming_centre: [
77520         "amenity/casino",
77521         "amenity/gambling",
77522         "leisure/adult_gaming_centre"
77523       ],
77524       beauty: [
77525         "shop/beauty",
77526         "shop/hairdresser_supply"
77527       ],
77528       bed: [
77529         "shop/bed",
77530         "shop/furniture"
77531       ],
77532       beverages: [
77533         "shop/alcohol",
77534         "shop/beer",
77535         "shop/beverages",
77536         "shop/kiosk",
77537         "shop/wine"
77538       ],
77539       camping: [
77540         "tourism/camp_site",
77541         "tourism/caravan_site"
77542       ],
77543       car_parts: [
77544         "shop/car_parts",
77545         "shop/car_repair",
77546         "shop/tires",
77547         "shop/tyres"
77548       ],
77549       clinic: [
77550         "amenity/clinic",
77551         "amenity/doctors",
77552         "healthcare/clinic",
77553         "healthcare/laboratory",
77554         "healthcare/physiotherapist",
77555         "healthcare/sample_collection",
77556         "healthcare/dialysis"
77557       ],
77558       convenience: [
77559         "shop/beauty",
77560         "shop/chemist",
77561         "shop/convenience",
77562         "shop/cosmetics",
77563         "shop/grocery",
77564         "shop/kiosk",
77565         "shop/newsagent",
77566         "shop/perfumery"
77567       ],
77568       coworking: [
77569         "amenity/coworking_space",
77570         "office/coworking",
77571         "office/coworking_space"
77572       ],
77573       dentist: [
77574         "amenity/dentist",
77575         "amenity/doctors",
77576         "healthcare/dentist"
77577       ],
77578       electronics: [
77579         "office/telecommunication",
77580         "shop/computer",
77581         "shop/electronics",
77582         "shop/hifi",
77583         "shop/kiosk",
77584         "shop/mobile",
77585         "shop/mobile_phone",
77586         "shop/telecommunication"
77587       ],
77588       fabric: [
77589         "shop/fabric",
77590         "shop/haberdashery",
77591         "shop/sewing"
77592       ],
77593       fashion: [
77594         "shop/accessories",
77595         "shop/bag",
77596         "shop/boutique",
77597         "shop/clothes",
77598         "shop/department_store",
77599         "shop/fashion",
77600         "shop/fashion_accessories",
77601         "shop/sports",
77602         "shop/shoes"
77603       ],
77604       financial: [
77605         "amenity/bank",
77606         "office/accountant",
77607         "office/financial",
77608         "office/financial_advisor",
77609         "office/tax_advisor",
77610         "shop/tax"
77611       ],
77612       fitness: [
77613         "leisure/fitness_centre",
77614         "leisure/fitness_center",
77615         "leisure/sports_centre",
77616         "leisure/sports_center"
77617       ],
77618       food: [
77619         "amenity/bar",
77620         "amenity/cafe",
77621         "amenity/fast_food",
77622         "amenity/ice_cream",
77623         "amenity/pub",
77624         "amenity/restaurant",
77625         "shop/bakery",
77626         "shop/candy",
77627         "shop/chocolate",
77628         "shop/coffee",
77629         "shop/confectionary",
77630         "shop/confectionery",
77631         "shop/food",
77632         "shop/kiosk",
77633         "shop/ice_cream",
77634         "shop/pastry",
77635         "shop/tea"
77636       ],
77637       fuel: [
77638         "amenity/fuel",
77639         "shop/gas",
77640         "shop/convenience;gas",
77641         "shop/gas;convenience"
77642       ],
77643       gift: [
77644         "shop/gift",
77645         "shop/card",
77646         "shop/cards",
77647         "shop/kiosk",
77648         "shop/stationery"
77649       ],
77650       hardware: [
77651         "shop/bathroom_furnishing",
77652         "shop/carpet",
77653         "shop/diy",
77654         "shop/doityourself",
77655         "shop/doors",
77656         "shop/electrical",
77657         "shop/flooring",
77658         "shop/hardware",
77659         "shop/hardware_store",
77660         "shop/power_tools",
77661         "shop/tool_hire",
77662         "shop/tools",
77663         "shop/trade"
77664       ],
77665       health_food: [
77666         "shop/health",
77667         "shop/health_food",
77668         "shop/herbalist",
77669         "shop/nutrition_supplements"
77670       ],
77671       hobby: [
77672         "shop/electronics",
77673         "shop/hobby",
77674         "shop/books",
77675         "shop/games",
77676         "shop/collector",
77677         "shop/toys",
77678         "shop/model",
77679         "shop/video_games",
77680         "shop/anime"
77681       ],
77682       hospital: [
77683         "amenity/doctors",
77684         "amenity/hospital",
77685         "healthcare/hospital"
77686       ],
77687       houseware: [
77688         "shop/houseware",
77689         "shop/interior_decoration"
77690       ],
77691       lifeboat_station: [
77692         "amenity/lifeboat_station",
77693         "emergency/lifeboat_station",
77694         "emergency/marine_rescue"
77695       ],
77696       lodging: [
77697         "tourism/hotel",
77698         "tourism/motel"
77699       ],
77700       money_transfer: [
77701         "amenity/money_transfer",
77702         "shop/money_transfer"
77703       ],
77704       office_supplies: [
77705         "shop/office_supplies",
77706         "shop/stationary",
77707         "shop/stationery"
77708       ],
77709       outdoor: [
77710         "shop/clothes",
77711         "shop/outdoor",
77712         "shop/sports"
77713       ],
77714       parcel_locker: [
77715         "amenity/parcel_locker",
77716         "amenity/vending_machine"
77717       ],
77718       pharmacy: [
77719         "amenity/doctors",
77720         "amenity/pharmacy",
77721         "healthcare/pharmacy"
77722       ],
77723       playground: [
77724         "amenity/theme_park",
77725         "leisure/amusement_arcade",
77726         "leisure/playground"
77727       ],
77728       rental: [
77729         "amenity/bicycle_rental",
77730         "amenity/boat_rental",
77731         "amenity/car_rental",
77732         "amenity/truck_rental",
77733         "amenity/vehicle_rental",
77734         "shop/kiosk",
77735         "shop/rental"
77736       ],
77737       school: [
77738         "amenity/childcare",
77739         "amenity/college",
77740         "amenity/kindergarten",
77741         "amenity/language_school",
77742         "amenity/prep_school",
77743         "amenity/school",
77744         "amenity/university"
77745       ],
77746       storage: [
77747         "shop/storage_units",
77748         "shop/storage_rental"
77749       ],
77750       substation: [
77751         "power/station",
77752         "power/substation",
77753         "power/sub_station"
77754       ],
77755       supermarket: [
77756         "shop/food",
77757         "shop/frozen_food",
77758         "shop/greengrocer",
77759         "shop/grocery",
77760         "shop/supermarket",
77761         "shop/wholesale"
77762       ],
77763       variety_store: [
77764         "shop/variety_store",
77765         "shop/discount",
77766         "shop/convenience"
77767       ],
77768       vending: [
77769         "amenity/vending_machine",
77770         "shop/kiosk",
77771         "shop/vending_machine"
77772       ],
77773       weight_loss: [
77774         "amenity/clinic",
77775         "amenity/doctors",
77776         "amenity/weight_clinic",
77777         "healthcare/counselling",
77778         "leisure/fitness_centre",
77779         "office/therapist",
77780         "shop/beauty",
77781         "shop/diet",
77782         "shop/food",
77783         "shop/health_food",
77784         "shop/herbalist",
77785         "shop/nutrition",
77786         "shop/nutrition_supplements",
77787         "shop/weight_loss"
77788       ],
77789       wholesale: [
77790         "shop/wholesale",
77791         "shop/supermarket",
77792         "shop/department_store"
77793       ]
77794     }
77795   };
77796
77797   // node_modules/name-suggestion-index/config/genericWords.json
77798   var genericWords_default = {
77799     genericWords: [
77800       "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
77801       "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
77802       "^(club|green|out|ware)\\s?house$",
77803       "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
77804       "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
77805       "^(hofladen|librairie|magazine?|maison)$",
77806       "^(mobile home|skate)?\\s?park$",
77807       "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
77808       "^\\?+$",
77809       "^private$",
77810       "^tattoo( studio)?$",
77811       "^windmill$",
77812       "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
77813     ]
77814   };
77815
77816   // node_modules/name-suggestion-index/config/trees.json
77817   var trees_default = {
77818     trees: {
77819       brands: {
77820         emoji: "\u{1F354}",
77821         mainTag: "brand:wikidata",
77822         sourceTags: ["brand", "name"],
77823         nameTags: {
77824           primary: "^(name|name:\\w+)$",
77825           alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
77826         }
77827       },
77828       flags: {
77829         emoji: "\u{1F6A9}",
77830         mainTag: "flag:wikidata",
77831         nameTags: {
77832           primary: "^(flag:name|flag:name:\\w+)$",
77833           alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
77834         }
77835       },
77836       operators: {
77837         emoji: "\u{1F4BC}",
77838         mainTag: "operator:wikidata",
77839         sourceTags: ["operator"],
77840         nameTags: {
77841           primary: "^(name|name:\\w+|operator|operator:\\w+)$",
77842           alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
77843         }
77844       },
77845       transit: {
77846         emoji: "\u{1F687}",
77847         mainTag: "network:wikidata",
77848         sourceTags: ["network"],
77849         nameTags: {
77850           primary: "^network$",
77851           alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
77852         }
77853       }
77854     }
77855   };
77856
77857   // node_modules/name-suggestion-index/lib/matcher.js
77858   var matchGroups = matchGroups_default.matchGroups;
77859   var trees = trees_default.trees;
77860   var Matcher = class {
77861     //
77862     // `constructor`
77863     // initialize the genericWords regexes
77864     constructor() {
77865       this.matchIndex = void 0;
77866       this.genericWords = /* @__PURE__ */ new Map();
77867       (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
77868       this.itemLocation = void 0;
77869       this.locationSets = void 0;
77870       this.locationIndex = void 0;
77871       this.warnings = [];
77872     }
77873     //
77874     // `buildMatchIndex()`
77875     // Call this to prepare the matcher for use
77876     //
77877     // `data` needs to be an Object indexed on a 'tree/key/value' path.
77878     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
77879     // {
77880     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
77881     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
77882     //    …
77883     // }
77884     //
77885     buildMatchIndex(data) {
77886       const that = this;
77887       if (that.matchIndex)
77888         return;
77889       that.matchIndex = /* @__PURE__ */ new Map();
77890       const seenTree = /* @__PURE__ */ new Map();
77891       Object.keys(data).forEach((tkv) => {
77892         const category = data[tkv];
77893         const parts = tkv.split("/", 3);
77894         const t2 = parts[0];
77895         const k2 = parts[1];
77896         const v2 = parts[2];
77897         const thiskv = "".concat(k2, "/").concat(v2);
77898         const tree = trees[t2];
77899         let branch = that.matchIndex.get(thiskv);
77900         if (!branch) {
77901           branch = {
77902             primary: /* @__PURE__ */ new Map(),
77903             alternate: /* @__PURE__ */ new Map(),
77904             excludeGeneric: /* @__PURE__ */ new Map(),
77905             excludeNamed: /* @__PURE__ */ new Map()
77906           };
77907           that.matchIndex.set(thiskv, branch);
77908         }
77909         const properties = category.properties || {};
77910         const exclude = properties.exclude || {};
77911         (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
77912         (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
77913         const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
77914         let items = category.items;
77915         if (!Array.isArray(items) || !items.length)
77916           return;
77917         const primaryName = new RegExp(tree.nameTags.primary, "i");
77918         const alternateName = new RegExp(tree.nameTags.alternate, "i");
77919         const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
77920         const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
77921         const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
77922         const matchGroupKV = /* @__PURE__ */ new Set();
77923         Object.values(matchGroups).forEach((matchGroup) => {
77924           const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
77925           if (!inGroup)
77926             return;
77927           matchGroup.forEach((otherkv) => {
77928             if (otherkv === thiskv)
77929               return;
77930             matchGroupKV.add(otherkv);
77931             const otherk = otherkv.split("/", 2)[0];
77932             genericKV.add("".concat(otherk, "/yes"));
77933           });
77934         });
77935         items.forEach((item) => {
77936           if (!item.id)
77937             return;
77938           if (Array.isArray(item.matchTags) && item.matchTags.length) {
77939             item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && !genericKV.has(matchTag));
77940             if (!item.matchTags.length)
77941               delete item.matchTags;
77942           }
77943           let kvTags = ["".concat(thiskv)].concat(item.matchTags || []);
77944           if (!skipGenericKV) {
77945             kvTags = kvTags.concat(Array.from(genericKV));
77946           }
77947           Object.keys(item.tags).forEach((osmkey) => {
77948             if (notName.test(osmkey))
77949               return;
77950             const osmvalue = item.tags[osmkey];
77951             if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue)))
77952               return;
77953             if (primaryName.test(osmkey)) {
77954               kvTags.forEach((kv) => insertName("primary", t2, kv, simplify2(osmvalue), item.id));
77955             } else if (alternateName.test(osmkey)) {
77956               kvTags.forEach((kv) => insertName("alternate", t2, kv, simplify2(osmvalue), item.id));
77957             }
77958           });
77959           let keepMatchNames = /* @__PURE__ */ new Set();
77960           (item.matchNames || []).forEach((matchName) => {
77961             const nsimple = simplify2(matchName);
77962             kvTags.forEach((kv) => {
77963               const branch2 = that.matchIndex.get(kv);
77964               const primaryLeaf = branch2 && branch2.primary.get(nsimple);
77965               const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
77966               const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
77967               const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
77968               if (!inPrimary && !inAlternate) {
77969                 insertName("alternate", t2, kv, nsimple, item.id);
77970                 keepMatchNames.add(matchName);
77971               }
77972             });
77973           });
77974           if (keepMatchNames.size) {
77975             item.matchNames = Array.from(keepMatchNames);
77976           } else {
77977             delete item.matchNames;
77978           }
77979         });
77980       });
77981       function insertName(which, t2, kv, nsimple, itemID) {
77982         if (!nsimple) {
77983           that.warnings.push("Warning: skipping empty ".concat(which, " name for item ").concat(t2, "/").concat(kv, ": ").concat(itemID));
77984           return;
77985         }
77986         let branch = that.matchIndex.get(kv);
77987         if (!branch) {
77988           branch = {
77989             primary: /* @__PURE__ */ new Map(),
77990             alternate: /* @__PURE__ */ new Map(),
77991             excludeGeneric: /* @__PURE__ */ new Map(),
77992             excludeNamed: /* @__PURE__ */ new Map()
77993           };
77994           that.matchIndex.set(kv, branch);
77995         }
77996         let leaf = branch[which].get(nsimple);
77997         if (!leaf) {
77998           leaf = /* @__PURE__ */ new Set();
77999           branch[which].set(nsimple, leaf);
78000         }
78001         leaf.add(itemID);
78002         if (!/yes$/.test(kv)) {
78003           const kvnsimple = "".concat(kv, "/").concat(nsimple);
78004           const existing = seenTree.get(kvnsimple);
78005           if (existing && existing !== t2) {
78006             const items = Array.from(leaf);
78007             that.warnings.push('Duplicate cache key "'.concat(kvnsimple, '" in trees "').concat(t2, '" and "').concat(existing, '", check items: ').concat(items));
78008             return;
78009           }
78010           seenTree.set(kvnsimple, t2);
78011         }
78012       }
78013       function skipGenericKVMatches(t2, k2, v2) {
78014         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";
78015       }
78016     }
78017     //
78018     // `buildLocationIndex()`
78019     // Call this to prepare a which-polygon location index.
78020     // This *resolves* all the locationSets into GeoJSON, which takes some time.
78021     // You can skip this step if you don't care about matching within a location.
78022     //
78023     // `data` needs to be an Object indexed on a 'tree/key/value' path.
78024     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
78025     // {
78026     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
78027     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
78028     //    …
78029     // }
78030     //
78031     buildLocationIndex(data, loco) {
78032       const that = this;
78033       if (that.locationIndex)
78034         return;
78035       that.itemLocation = /* @__PURE__ */ new Map();
78036       that.locationSets = /* @__PURE__ */ new Map();
78037       Object.keys(data).forEach((tkv) => {
78038         const items = data[tkv].items;
78039         if (!Array.isArray(items) || !items.length)
78040           return;
78041         items.forEach((item) => {
78042           if (that.itemLocation.has(item.id))
78043             return;
78044           let resolved;
78045           try {
78046             resolved = loco.resolveLocationSet(item.locationSet);
78047           } catch (err) {
78048             console.warn("buildLocationIndex: ".concat(err.message));
78049           }
78050           if (!resolved || !resolved.id)
78051             return;
78052           that.itemLocation.set(item.id, resolved.id);
78053           if (that.locationSets.has(resolved.id))
78054             return;
78055           let feature3 = _cloneDeep2(resolved.feature);
78056           feature3.id = resolved.id;
78057           feature3.properties.id = resolved.id;
78058           if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
78059             console.warn("buildLocationIndex: locationSet ".concat(resolved.id, " for ").concat(item.id, " resolves to an empty feature:"));
78060             console.warn(JSON.stringify(feature3));
78061             return;
78062           }
78063           that.locationSets.set(resolved.id, feature3);
78064         });
78065       });
78066       that.locationIndex = (0, import_which_polygon4.default)({ type: "FeatureCollection", features: [...that.locationSets.values()] });
78067       function _cloneDeep2(obj) {
78068         return JSON.parse(JSON.stringify(obj));
78069       }
78070     }
78071     //
78072     // `match()`
78073     // Pass parts and return an Array of matches.
78074     // `k` - key
78075     // `v` - value
78076     // `n` - namelike
78077     // `loc` - optional - [lon,lat] location to search
78078     //
78079     // 1. If the [k,v,n] tuple matches a canonical item…
78080     // Return an Array of match results.
78081     // Each result will include the area in km² that the item is valid.
78082     //
78083     // Order of results:
78084     // Primary ordering will be on the "match" column:
78085     //   "primary" - where the query matches the `name` tag, followed by
78086     //   "alternate" - where the query matches an alternate name tag (e.g. short_name, brand, operator, etc)
78087     // Secondary ordering will be on the "area" column:
78088     //   "area descending" if no location was provided, (worldwide before local)
78089     //   "area ascending" if location was provided (local before worldwide)
78090     //
78091     // [
78092     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78093     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78094     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78095     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78096     //   …
78097     // ]
78098     //
78099     // -or-
78100     //
78101     // 2. If the [k,v,n] tuple matches an exclude pattern…
78102     // Return an Array with a single exclude result, either
78103     //
78104     // [ { match: 'excludeGeneric', pattern: String,  kv: String } ]  // "generic" e.g. "Food Court"
78105     //   or
78106     // [ { match: 'excludeNamed', pattern: String,  kv: String } ]    // "named", e.g. "Kebabai"
78107     //
78108     // About results
78109     //   "generic" - a generic word that is probably not really a name.
78110     //     For these, iD should warn the user "Hey don't put 'food court' in the name tag".
78111     //   "named" - a real name like "Kebabai" that is just common, but not a brand.
78112     //     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.
78113     //
78114     // -or-
78115     //
78116     // 3. If the [k,v,n] tuple matches nothing of any kind, return `null`
78117     //
78118     //
78119     match(k2, v2, n3, loc) {
78120       const that = this;
78121       if (!that.matchIndex) {
78122         throw new Error("match:  matchIndex not built.");
78123       }
78124       let matchLocations;
78125       if (Array.isArray(loc) && that.locationIndex) {
78126         matchLocations = that.locationIndex([loc[0], loc[1], loc[0], loc[1]], true);
78127       }
78128       const nsimple = simplify2(n3);
78129       let seen = /* @__PURE__ */ new Set();
78130       let results = [];
78131       gatherResults("primary");
78132       gatherResults("alternate");
78133       if (results.length)
78134         return results;
78135       gatherResults("exclude");
78136       return results.length ? results : null;
78137       function gatherResults(which) {
78138         const kv = "".concat(k2, "/").concat(v2);
78139         let didMatch = tryMatch(which, kv);
78140         if (didMatch)
78141           return;
78142         for (let mg in matchGroups) {
78143           const matchGroup = matchGroups[mg];
78144           const inGroup = matchGroup.some((otherkv) => otherkv === kv);
78145           if (!inGroup)
78146             continue;
78147           for (let i3 = 0; i3 < matchGroup.length; i3++) {
78148             const otherkv = matchGroup[i3];
78149             if (otherkv === kv)
78150               continue;
78151             didMatch = tryMatch(which, otherkv);
78152             if (didMatch)
78153               return;
78154           }
78155         }
78156         if (which === "exclude") {
78157           const regex = [...that.genericWords.values()].find((regex2) => regex2.test(n3));
78158           if (regex) {
78159             results.push({ match: "excludeGeneric", pattern: String(regex) });
78160             return;
78161           }
78162         }
78163       }
78164       function tryMatch(which, kv) {
78165         const branch = that.matchIndex.get(kv);
78166         if (!branch)
78167           return;
78168         if (which === "exclude") {
78169           let regex = [...branch.excludeNamed.values()].find((regex2) => regex2.test(n3));
78170           if (regex) {
78171             results.push({ match: "excludeNamed", pattern: String(regex), kv });
78172             return;
78173           }
78174           regex = [...branch.excludeGeneric.values()].find((regex2) => regex2.test(n3));
78175           if (regex) {
78176             results.push({ match: "excludeGeneric", pattern: String(regex), kv });
78177             return;
78178           }
78179           return;
78180         }
78181         const leaf = branch[which].get(nsimple);
78182         if (!leaf || !leaf.size)
78183           return;
78184         let hits = Array.from(leaf).map((itemID) => {
78185           let area = Infinity;
78186           if (that.itemLocation && that.locationSets) {
78187             const location = that.locationSets.get(that.itemLocation.get(itemID));
78188             area = location && location.properties.area || Infinity;
78189           }
78190           return { match: which, itemID, area, kv, nsimple };
78191         });
78192         let sortFn = byAreaDescending;
78193         if (matchLocations) {
78194           hits = hits.filter(isValidLocation);
78195           sortFn = byAreaAscending;
78196         }
78197         if (!hits.length)
78198           return;
78199         hits.sort(sortFn).forEach((hit) => {
78200           if (seen.has(hit.itemID))
78201             return;
78202           seen.add(hit.itemID);
78203           results.push(hit);
78204         });
78205         return true;
78206         function isValidLocation(hit) {
78207           if (!that.itemLocation)
78208             return true;
78209           return matchLocations.find((props) => props.id === that.itemLocation.get(hit.itemID));
78210         }
78211         function byAreaAscending(hitA, hitB) {
78212           return hitA.area - hitB.area;
78213         }
78214         function byAreaDescending(hitA, hitB) {
78215           return hitB.area - hitA.area;
78216         }
78217       }
78218     }
78219     //
78220     // `getWarnings()`
78221     // Return any warnings discovered when buiding the index.
78222     // (currently this does nothing)
78223     //
78224     getWarnings() {
78225       return this.warnings;
78226     }
78227   };
78228
78229   // modules/services/nsi.js
78230   var import_vparse2 = __toESM(require_vparse());
78231   var _nsiStatus = "loading";
78232   var _nsi = {};
78233   var buildingPreset = {
78234     "building/commercial": true,
78235     "building/government": true,
78236     "building/hotel": true,
78237     "building/retail": true,
78238     "building/office": true,
78239     "building/supermarket": true,
78240     "building/yes": true
78241   };
78242   var notNames = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
78243   var notBranches = /(coop|express|wireless|factory|outlet)/i;
78244   function setNsiSources() {
78245     const nsiVersion = package_default.dependencies["name-suggestion-index"] || package_default.devDependencies["name-suggestion-index"];
78246     const v2 = (0, import_vparse2.default)(nsiVersion);
78247     const vMinor = "".concat(v2.major, ".").concat(v2.minor);
78248     const cdn = nsiCdnUrl.replace("{version}", vMinor);
78249     const sources = {
78250       "nsi_data": cdn + "dist/nsi.min.json",
78251       "nsi_dissolved": cdn + "dist/dissolved.min.json",
78252       "nsi_features": cdn + "dist/featureCollection.min.json",
78253       "nsi_generics": cdn + "dist/genericWords.min.json",
78254       "nsi_presets": cdn + "dist/presets/nsi-id-presets.min.json",
78255       "nsi_replacements": cdn + "dist/replacements.min.json",
78256       "nsi_trees": cdn + "dist/trees.min.json"
78257     };
78258     let fileMap = _mainFileFetcher.fileMap();
78259     for (const k2 in sources) {
78260       if (!fileMap[k2])
78261         fileMap[k2] = sources[k2];
78262     }
78263   }
78264   function loadNsiPresets() {
78265     return Promise.all([
78266       _mainFileFetcher.get("nsi_presets"),
78267       _mainFileFetcher.get("nsi_features")
78268     ]).then((vals) => {
78269       Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true);
78270       Object.values(vals[0].presets).forEach((preset) => {
78271         if (preset.tags["brand:wikidata"]) {
78272           preset.removeTags = { "brand:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78273         }
78274         if (preset.tags["operator:wikidata"]) {
78275           preset.removeTags = { "operator:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78276         }
78277         if (preset.tags["network:wikidata"]) {
78278           preset.removeTags = { "network:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78279         }
78280       });
78281       _mainPresetIndex.merge({
78282         presets: vals[0].presets,
78283         featureCollection: vals[1]
78284       });
78285     });
78286   }
78287   function loadNsiData() {
78288     return Promise.all([
78289       _mainFileFetcher.get("nsi_data"),
78290       _mainFileFetcher.get("nsi_dissolved"),
78291       _mainFileFetcher.get("nsi_replacements"),
78292       _mainFileFetcher.get("nsi_trees")
78293     ]).then((vals) => {
78294       _nsi = {
78295         data: vals[0].nsi,
78296         // the raw name-suggestion-index data
78297         dissolved: vals[1].dissolved,
78298         // list of dissolved items
78299         replacements: vals[2].replacements,
78300         // trivial old->new qid replacements
78301         trees: vals[3].trees,
78302         // metadata about trees, main tags
78303         kvt: /* @__PURE__ */ new Map(),
78304         // Map (k -> Map (v -> t) )
78305         qids: /* @__PURE__ */ new Map(),
78306         // Map (wd/wp tag values -> qids)
78307         ids: /* @__PURE__ */ new Map()
78308         // Map (id -> NSI item)
78309       };
78310       const matcher = _nsi.matcher = new Matcher();
78311       matcher.buildMatchIndex(_nsi.data);
78312       matcher.itemLocation = /* @__PURE__ */ new Map();
78313       matcher.locationSets = /* @__PURE__ */ new Map();
78314       Object.keys(_nsi.data).forEach((tkv) => {
78315         const items = _nsi.data[tkv].items;
78316         if (!Array.isArray(items) || !items.length)
78317           return;
78318         items.forEach((item) => {
78319           if (matcher.itemLocation.has(item.id))
78320             return;
78321           const locationSetID = _sharedLocationManager.locationSetID(item.locationSet);
78322           matcher.itemLocation.set(item.id, locationSetID);
78323           if (matcher.locationSets.has(locationSetID))
78324             return;
78325           const fakeFeature = { id: locationSetID, properties: { id: locationSetID, area: 1 } };
78326           matcher.locationSets.set(locationSetID, fakeFeature);
78327         });
78328       });
78329       matcher.locationIndex = (bbox2) => {
78330         const validHere = _sharedLocationManager.locationSetsAt([bbox2[0], bbox2[1]]);
78331         const results = [];
78332         for (const [locationSetID, area] of Object.entries(validHere)) {
78333           const fakeFeature = matcher.locationSets.get(locationSetID);
78334           if (fakeFeature) {
78335             fakeFeature.properties.area = area;
78336             results.push(fakeFeature);
78337           }
78338         }
78339         return results;
78340       };
78341       Object.keys(_nsi.data).forEach((tkv) => {
78342         const category = _nsi.data[tkv];
78343         const parts = tkv.split("/", 3);
78344         const t2 = parts[0];
78345         const k2 = parts[1];
78346         const v2 = parts[2];
78347         let vmap = _nsi.kvt.get(k2);
78348         if (!vmap) {
78349           vmap = /* @__PURE__ */ new Map();
78350           _nsi.kvt.set(k2, vmap);
78351         }
78352         vmap.set(v2, t2);
78353         const tree = _nsi.trees[t2];
78354         const mainTag = tree.mainTag;
78355         const items = category.items || [];
78356         items.forEach((item) => {
78357           item.tkv = tkv;
78358           item.mainTag = mainTag;
78359           _nsi.ids.set(item.id, item);
78360           const wd = item.tags[mainTag];
78361           const wp = item.tags[mainTag.replace("wikidata", "wikipedia")];
78362           if (wd)
78363             _nsi.qids.set(wd, wd);
78364           if (wp && wd)
78365             _nsi.qids.set(wp, wd);
78366         });
78367       });
78368     });
78369   }
78370   function gatherKVs(tags) {
78371     let primary = /* @__PURE__ */ new Set();
78372     let alternate = /* @__PURE__ */ new Set();
78373     Object.keys(tags).forEach((osmkey) => {
78374       const osmvalue = tags[osmkey];
78375       if (!osmvalue)
78376         return;
78377       if (osmkey === "route_master")
78378         osmkey = "route";
78379       const vmap = _nsi.kvt.get(osmkey);
78380       if (!vmap)
78381         return;
78382       if (vmap.get(osmvalue)) {
78383         primary.add("".concat(osmkey, "/").concat(osmvalue));
78384       } else if (osmvalue === "yes") {
78385         alternate.add("".concat(osmkey, "/").concat(osmvalue));
78386       }
78387     });
78388     const preset = _mainPresetIndex.matchTags(tags, "area");
78389     if (buildingPreset[preset.id]) {
78390       alternate.add("building/yes");
78391     }
78392     return { primary, alternate };
78393   }
78394   function identifyTree(tags) {
78395     let unknown;
78396     let t2;
78397     Object.keys(tags).forEach((osmkey) => {
78398       if (t2)
78399         return;
78400       const osmvalue = tags[osmkey];
78401       if (!osmvalue)
78402         return;
78403       if (osmkey === "route_master")
78404         osmkey = "route";
78405       const vmap = _nsi.kvt.get(osmkey);
78406       if (!vmap)
78407         return;
78408       if (osmvalue === "yes") {
78409         unknown = "unknown";
78410       } else {
78411         t2 = vmap.get(osmvalue);
78412       }
78413     });
78414     return t2 || unknown || null;
78415   }
78416   function gatherNames(tags) {
78417     const empty2 = { primary: /* @__PURE__ */ new Set(), alternate: /* @__PURE__ */ new Set() };
78418     let primary = /* @__PURE__ */ new Set();
78419     let alternate = /* @__PURE__ */ new Set();
78420     let foundSemi = false;
78421     let testNameFragments = false;
78422     let patterns2;
78423     let t2 = identifyTree(tags);
78424     if (!t2)
78425       return empty2;
78426     if (t2 === "transit") {
78427       patterns2 = {
78428         primary: /^network$/i,
78429         alternate: /^(operator|operator:\w+|network:\w+|\w+_name|\w+_name:\w+)$/i
78430       };
78431     } else if (t2 === "flags") {
78432       patterns2 = {
78433         primary: /^(flag:name|flag:name:\w+)$/i,
78434         alternate: /^(flag|flag:\w+|subject|subject:\w+)$/i
78435         // note: no `country`, we special-case it below
78436       };
78437     } else if (t2 === "brands") {
78438       testNameFragments = true;
78439       patterns2 = {
78440         primary: /^(name|name:\w+)$/i,
78441         alternate: /^(brand|brand:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78442       };
78443     } else if (t2 === "operators") {
78444       testNameFragments = true;
78445       patterns2 = {
78446         primary: /^(name|name:\w+|operator|operator:\w+)$/i,
78447         alternate: /^(brand|brand:\w+|\w+_name|\w+_name:\w+)/i
78448       };
78449     } else {
78450       testNameFragments = true;
78451       patterns2 = {
78452         primary: /^(name|name:\w+)$/i,
78453         alternate: /^(brand|brand:\w+|network|network:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78454       };
78455     }
78456     if (tags.name && testNameFragments) {
78457       const nameParts = tags.name.split(/[\s\-\/,.]/);
78458       for (let split = nameParts.length; split > 0; split--) {
78459         const name = nameParts.slice(0, split).join(" ");
78460         primary.add(name);
78461       }
78462     }
78463     Object.keys(tags).forEach((osmkey) => {
78464       const osmvalue = tags[osmkey];
78465       if (!osmvalue)
78466         return;
78467       if (isNamelike(osmkey, "primary")) {
78468         if (/;/.test(osmvalue)) {
78469           foundSemi = true;
78470         } else {
78471           primary.add(osmvalue);
78472           alternate.delete(osmvalue);
78473         }
78474       } else if (!primary.has(osmvalue) && isNamelike(osmkey, "alternate")) {
78475         if (/;/.test(osmvalue)) {
78476           foundSemi = true;
78477         } else {
78478           alternate.add(osmvalue);
78479         }
78480       }
78481     });
78482     if (tags.man_made === "flagpole" && !primary.size && !alternate.size && !!tags.country) {
78483       const osmvalue = tags.country;
78484       if (/;/.test(osmvalue)) {
78485         foundSemi = true;
78486       } else {
78487         alternate.add(osmvalue);
78488       }
78489     }
78490     if (foundSemi) {
78491       return empty2;
78492     } else {
78493       return { primary, alternate };
78494     }
78495     function isNamelike(osmkey, which) {
78496       if (osmkey === "old_name")
78497         return false;
78498       return patterns2[which].test(osmkey) && !notNames.test(osmkey);
78499     }
78500   }
78501   function gatherTuples(tryKVs, tryNames) {
78502     let tuples = [];
78503     ["primary", "alternate"].forEach((whichName) => {
78504       const arr = Array.from(tryNames[whichName]).sort((a2, b2) => b2.length - a2.length);
78505       arr.forEach((n3) => {
78506         ["primary", "alternate"].forEach((whichKV) => {
78507           tryKVs[whichKV].forEach((kv) => {
78508             const parts = kv.split("/", 2);
78509             const k2 = parts[0];
78510             const v2 = parts[1];
78511             tuples.push({ k: k2, v: v2, n: n3 });
78512           });
78513         });
78514       });
78515     });
78516     return tuples;
78517   }
78518   function _upgradeTags(tags, loc) {
78519     let newTags = Object.assign({}, tags);
78520     let changed = false;
78521     Object.keys(newTags).forEach((osmkey) => {
78522       const matchTag = osmkey.match(/^(\w+:)?wikidata$/);
78523       if (matchTag) {
78524         const prefix = matchTag[1] || "";
78525         const wd = newTags[osmkey];
78526         const replace = _nsi.replacements[wd];
78527         if (replace && replace.wikidata !== void 0) {
78528           changed = true;
78529           if (replace.wikidata) {
78530             newTags[osmkey] = replace.wikidata;
78531           } else {
78532             delete newTags[osmkey];
78533           }
78534         }
78535         if (replace && replace.wikipedia !== void 0) {
78536           changed = true;
78537           const wpkey = "".concat(prefix, "wikipedia");
78538           if (replace.wikipedia) {
78539             newTags[wpkey] = replace.wikipedia;
78540           } else {
78541             delete newTags[wpkey];
78542           }
78543         }
78544       }
78545     });
78546     const isRouteMaster = tags.type === "route_master";
78547     const tryKVs = gatherKVs(tags);
78548     if (!tryKVs.primary.size && !tryKVs.alternate.size) {
78549       return changed ? { newTags, matched: null } : null;
78550     }
78551     const tryNames = gatherNames(tags);
78552     const foundQID = _nsi.qids.get(tags.wikidata) || _nsi.qids.get(tags.wikipedia);
78553     if (foundQID)
78554       tryNames.primary.add(foundQID);
78555     if (!tryNames.primary.size && !tryNames.alternate.size) {
78556       return changed ? { newTags, matched: null } : null;
78557     }
78558     const tuples = gatherTuples(tryKVs, tryNames);
78559     for (let i3 = 0; i3 < tuples.length; i3++) {
78560       const tuple = tuples[i3];
78561       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n, loc);
78562       if (!hits || !hits.length)
78563         continue;
78564       if (hits[0].match !== "primary" && hits[0].match !== "alternate")
78565         break;
78566       let itemID, item;
78567       for (let j2 = 0; j2 < hits.length; j2++) {
78568         const hit = hits[j2];
78569         itemID = hit.itemID;
78570         if (_nsi.dissolved[itemID])
78571           continue;
78572         item = _nsi.ids.get(itemID);
78573         if (!item)
78574           continue;
78575         const mainTag = item.mainTag;
78576         const itemQID = item.tags[mainTag];
78577         const notQID = newTags["not:".concat(mainTag)];
78578         if (
78579           // Exceptions, skip this hit
78580           !itemQID || itemQID === notQID || // No `*:wikidata` or matched a `not:*:wikidata`
78581           newTags.office && !item.tags.office
78582         ) {
78583           item = null;
78584           continue;
78585         } else {
78586           break;
78587         }
78588       }
78589       if (!item)
78590         continue;
78591       item = JSON.parse(JSON.stringify(item));
78592       const tkv = item.tkv;
78593       const parts = tkv.split("/", 3);
78594       const k2 = parts[1];
78595       const v2 = parts[2];
78596       const category = _nsi.data[tkv];
78597       const properties = category.properties || {};
78598       let preserveTags = item.preserveTags || properties.preserveTags || [];
78599       ["building", "emergency", "internet_access", "takeaway"].forEach((osmkey) => {
78600         if (k2 !== osmkey)
78601           preserveTags.push("^".concat(osmkey, "$"));
78602       });
78603       const regexes = preserveTags.map((s2) => new RegExp(s2, "i"));
78604       let keepTags = {};
78605       Object.keys(newTags).forEach((osmkey) => {
78606         if (regexes.some((regex) => regex.test(osmkey))) {
78607           keepTags[osmkey] = newTags[osmkey];
78608         }
78609       });
78610       _nsi.kvt.forEach((vmap, k3) => {
78611         if (newTags[k3] === "yes")
78612           delete newTags[k3];
78613       });
78614       if (foundQID) {
78615         delete newTags.wikipedia;
78616         delete newTags.wikidata;
78617       }
78618       Object.assign(newTags, item.tags, keepTags);
78619       if (isRouteMaster) {
78620         newTags.route_master = newTags.route;
78621         delete newTags.route;
78622       }
78623       const origName = tags.name;
78624       const newName = newTags.name;
78625       if (newName && origName && newName !== origName && !newTags.branch) {
78626         const newNames = gatherNames(newTags);
78627         const newSet = /* @__PURE__ */ new Set([...newNames.primary, ...newNames.alternate]);
78628         const isMoved = newSet.has(origName);
78629         if (!isMoved) {
78630           const nameParts = origName.split(/[\s\-\/,.]/);
78631           for (let split = nameParts.length; split > 0; split--) {
78632             const name = nameParts.slice(0, split).join(" ");
78633             const branch = nameParts.slice(split).join(" ");
78634             const nameHits = _nsi.matcher.match(k2, v2, name, loc);
78635             if (!nameHits || !nameHits.length)
78636               continue;
78637             if (nameHits.some((hit) => hit.itemID === itemID)) {
78638               if (branch) {
78639                 if (notBranches.test(branch)) {
78640                   newTags.name = origName;
78641                 } else {
78642                   const branchHits = _nsi.matcher.match(k2, v2, branch, loc);
78643                   if (branchHits && branchHits.length) {
78644                     if (branchHits[0].match === "primary" || branchHits[0].match === "alternate") {
78645                       return null;
78646                     }
78647                   } else {
78648                     newTags.branch = branch;
78649                   }
78650                 }
78651               }
78652               break;
78653             }
78654           }
78655         }
78656       }
78657       return { newTags, matched: item };
78658     }
78659     return changed ? { newTags, matched: null } : null;
78660   }
78661   function _isGenericName(tags) {
78662     const n3 = tags.name;
78663     if (!n3)
78664       return false;
78665     const tryNames = { primary: /* @__PURE__ */ new Set([n3]), alternate: /* @__PURE__ */ new Set() };
78666     const tryKVs = gatherKVs(tags);
78667     if (!tryKVs.primary.size && !tryKVs.alternate.size)
78668       return false;
78669     const tuples = gatherTuples(tryKVs, tryNames);
78670     for (let i3 = 0; i3 < tuples.length; i3++) {
78671       const tuple = tuples[i3];
78672       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n);
78673       if (hits && hits.length && hits[0].match === "excludeGeneric")
78674         return true;
78675     }
78676     return false;
78677   }
78678   var nsi_default = {
78679     // `init()`
78680     // On init, start preparing the name-suggestion-index
78681     //
78682     init: () => {
78683       setNsiSources();
78684       _mainPresetIndex.ensureLoaded().then(() => loadNsiPresets()).then(() => loadNsiData()).then(() => _nsiStatus = "ok").catch(() => _nsiStatus = "failed");
78685     },
78686     // `reset()`
78687     // Reset is called when user saves data to OSM (does nothing here)
78688     //
78689     reset: () => {
78690     },
78691     // `status()`
78692     // To let other code know how it's going...
78693     //
78694     // Returns
78695     //   `String`: 'loading', 'ok', 'failed'
78696     //
78697     status: () => _nsiStatus,
78698     // `isGenericName()`
78699     // Is the `name` tag generic?
78700     //
78701     // Arguments
78702     //   `tags`: `Object` containing the feature's OSM tags
78703     // Returns
78704     //   `true` if it is generic, `false` if not
78705     //
78706     isGenericName: (tags) => _isGenericName(tags),
78707     // `upgradeTags()`
78708     // Suggest tag upgrades.
78709     // This function will not modify the input tags, it makes a copy.
78710     //
78711     // Arguments
78712     //   `tags`: `Object` containing the feature's OSM tags
78713     //   `loc`: Location where this feature exists, as a [lon, lat]
78714     // Returns
78715     //   `Object` containing the result, or `null` if no changes needed:
78716     //   {
78717     //     'newTags': `Object` - The tags the the feature should have
78718     //     'matched': `Object` - The matched item
78719     //   }
78720     //
78721     upgradeTags: (tags, loc) => _upgradeTags(tags, loc),
78722     // `cache()`
78723     // Direct access to the NSI cache, useful for testing or breaking things
78724     //
78725     // Returns
78726     //   `Object`: the internal NSI cache
78727     //
78728     cache: () => _nsi
78729   };
78730
78731   // modules/services/kartaview.js
78732   var import_rbush8 = __toESM(require_rbush_min());
78733   var apibase2 = "https://kartaview.org";
78734   var maxResults = 1e3;
78735   var tileZoom = 14;
78736   var tiler4 = utilTiler().zoomExtent([tileZoom, tileZoom]).skipNullIsland(true);
78737   var dispatch7 = dispatch_default("loadedImages");
78738   var imgZoom2 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
78739   var _oscCache;
78740   var _oscSelectedImage;
78741   var _loadViewerPromise2;
78742   function abortRequest4(controller) {
78743     controller.abort();
78744   }
78745   function maxPageAtZoom(z2) {
78746     if (z2 < 15)
78747       return 2;
78748     if (z2 === 15)
78749       return 5;
78750     if (z2 === 16)
78751       return 10;
78752     if (z2 === 17)
78753       return 20;
78754     if (z2 === 18)
78755       return 40;
78756     if (z2 > 18)
78757       return 80;
78758   }
78759   function loadTiles2(which, url, projection2) {
78760     var currZoom = Math.floor(geoScaleToZoom(projection2.scale()));
78761     var tiles = tiler4.getTiles(projection2);
78762     var cache = _oscCache[which];
78763     Object.keys(cache.inflight).forEach(function(k2) {
78764       var wanted = tiles.find(function(tile) {
78765         return k2.indexOf(tile.id + ",") === 0;
78766       });
78767       if (!wanted) {
78768         abortRequest4(cache.inflight[k2]);
78769         delete cache.inflight[k2];
78770       }
78771     });
78772     tiles.forEach(function(tile) {
78773       loadNextTilePage(which, currZoom, url, tile);
78774     });
78775   }
78776   function loadNextTilePage(which, currZoom, url, tile) {
78777     var cache = _oscCache[which];
78778     var bbox2 = tile.extent.bbox();
78779     var maxPages = maxPageAtZoom(currZoom);
78780     var nextPage = cache.nextPage[tile.id] || 1;
78781     var params = utilQsString({
78782       ipp: maxResults,
78783       page: nextPage,
78784       // client_id: clientId,
78785       bbTopLeft: [bbox2.maxY, bbox2.minX].join(","),
78786       bbBottomRight: [bbox2.minY, bbox2.maxX].join(",")
78787     }, true);
78788     if (nextPage > maxPages)
78789       return;
78790     var id2 = tile.id + "," + String(nextPage);
78791     if (cache.loaded[id2] || cache.inflight[id2])
78792       return;
78793     var controller = new AbortController();
78794     cache.inflight[id2] = controller;
78795     var options2 = {
78796       method: "POST",
78797       signal: controller.signal,
78798       body: params,
78799       headers: { "Content-Type": "application/x-www-form-urlencoded" }
78800     };
78801     json_default(url, options2).then(function(data) {
78802       cache.loaded[id2] = true;
78803       delete cache.inflight[id2];
78804       if (!data || !data.currentPageItems || !data.currentPageItems.length) {
78805         throw new Error("No Data");
78806       }
78807       var features = data.currentPageItems.map(function(item) {
78808         var loc = [+item.lng, +item.lat];
78809         var d2;
78810         if (which === "images") {
78811           d2 = {
78812             loc,
78813             key: item.id,
78814             ca: +item.heading,
78815             captured_at: item.shot_date || item.date_added,
78816             captured_by: item.username,
78817             imagePath: item.lth_name,
78818             sequence_id: item.sequence_id,
78819             sequence_index: +item.sequence_index
78820           };
78821           var seq = _oscCache.sequences[d2.sequence_id];
78822           if (!seq) {
78823             seq = { rotation: 0, images: [] };
78824             _oscCache.sequences[d2.sequence_id] = seq;
78825           }
78826           seq.images[d2.sequence_index] = d2;
78827           _oscCache.images.forImageKey[d2.key] = d2;
78828         }
78829         return {
78830           minX: loc[0],
78831           minY: loc[1],
78832           maxX: loc[0],
78833           maxY: loc[1],
78834           data: d2
78835         };
78836       });
78837       cache.rtree.load(features);
78838       if (data.currentPageItems.length === maxResults) {
78839         cache.nextPage[tile.id] = nextPage + 1;
78840         loadNextTilePage(which, currZoom, url, tile);
78841       } else {
78842         cache.nextPage[tile.id] = Infinity;
78843       }
78844       if (which === "images") {
78845         dispatch7.call("loadedImages");
78846       }
78847     }).catch(function() {
78848       cache.loaded[id2] = true;
78849       delete cache.inflight[id2];
78850     });
78851   }
78852   function partitionViewport2(projection2) {
78853     var z2 = geoScaleToZoom(projection2.scale());
78854     var z22 = Math.ceil(z2 * 2) / 2 + 2.5;
78855     var tiler9 = utilTiler().zoomExtent([z22, z22]);
78856     return tiler9.getTiles(projection2).map(function(tile) {
78857       return tile.extent;
78858     });
78859   }
78860   function searchLimited2(limit, projection2, rtree) {
78861     limit = limit || 5;
78862     return partitionViewport2(projection2).reduce(function(result, extent) {
78863       var found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
78864         return d2.data;
78865       });
78866       return found.length ? result.concat(found) : result;
78867     }, []);
78868   }
78869   var kartaview_default = {
78870     init: function() {
78871       if (!_oscCache) {
78872         this.reset();
78873       }
78874       this.event = utilRebind(this, dispatch7, "on");
78875     },
78876     reset: function() {
78877       if (_oscCache) {
78878         Object.values(_oscCache.images.inflight).forEach(abortRequest4);
78879       }
78880       _oscCache = {
78881         images: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush8.default(), forImageKey: {} },
78882         sequences: {}
78883       };
78884       _oscSelectedImage = null;
78885     },
78886     images: function(projection2) {
78887       var limit = 5;
78888       return searchLimited2(limit, projection2, _oscCache.images.rtree);
78889     },
78890     sequences: function(projection2) {
78891       var viewport = projection2.clipExtent();
78892       var min3 = [viewport[0][0], viewport[1][1]];
78893       var max3 = [viewport[1][0], viewport[0][1]];
78894       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
78895       var sequenceKeys = {};
78896       _oscCache.images.rtree.search(bbox2).forEach(function(d2) {
78897         sequenceKeys[d2.data.sequence_id] = true;
78898       });
78899       var lineStrings = [];
78900       Object.keys(sequenceKeys).forEach(function(sequenceKey) {
78901         var seq = _oscCache.sequences[sequenceKey];
78902         var images = seq && seq.images;
78903         if (images) {
78904           lineStrings.push({
78905             type: "LineString",
78906             coordinates: images.map(function(d2) {
78907               return d2.loc;
78908             }).filter(Boolean),
78909             properties: {
78910               captured_at: images[0] ? images[0].captured_at : null,
78911               captured_by: images[0] ? images[0].captured_by : null,
78912               key: sequenceKey
78913             }
78914           });
78915         }
78916       });
78917       return lineStrings;
78918     },
78919     cachedImage: function(imageKey) {
78920       return _oscCache.images.forImageKey[imageKey];
78921     },
78922     loadImages: function(projection2) {
78923       var url = apibase2 + "/1.0/list/nearby-photos/";
78924       loadTiles2("images", url, projection2);
78925     },
78926     ensureViewerLoaded: function(context) {
78927       if (_loadViewerPromise2)
78928         return _loadViewerPromise2;
78929       var wrap2 = context.container().select(".photoviewer").selectAll(".kartaview-wrapper").data([0]);
78930       var that = this;
78931       var wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper kartaview-wrapper").classed("hide", true).call(imgZoom2.on("zoom", zoomPan2)).on("dblclick.zoom", null);
78932       wrapEnter.append("div").attr("class", "photo-attribution fillD");
78933       var controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
78934       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
78935       controlsEnter.append("button").on("click.rotate-ccw", rotate(-90)).text("\u293F");
78936       controlsEnter.append("button").on("click.rotate-cw", rotate(90)).text("\u293E");
78937       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
78938       wrapEnter.append("div").attr("class", "kartaview-image-wrap");
78939       context.ui().photoviewer.on("resize.kartaview", function(dimensions) {
78940         imgZoom2.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]);
78941       });
78942       function zoomPan2(d3_event) {
78943         var t2 = d3_event.transform;
78944         context.container().select(".photoviewer .kartaview-image-wrap").call(utilSetTransform, t2.x, t2.y, t2.k);
78945       }
78946       function rotate(deg) {
78947         return function() {
78948           if (!_oscSelectedImage)
78949             return;
78950           var sequenceKey = _oscSelectedImage.sequence_id;
78951           var sequence = _oscCache.sequences[sequenceKey];
78952           if (!sequence)
78953             return;
78954           var r2 = sequence.rotation || 0;
78955           r2 += deg;
78956           if (r2 > 180)
78957             r2 -= 360;
78958           if (r2 < -180)
78959             r2 += 360;
78960           sequence.rotation = r2;
78961           var wrap3 = context.container().select(".photoviewer .kartaview-wrapper");
78962           wrap3.transition().duration(100).call(imgZoom2.transform, identity2);
78963           wrap3.selectAll(".kartaview-image").transition().duration(100).style("transform", "rotate(" + r2 + "deg)");
78964         };
78965       }
78966       function step(stepBy) {
78967         return function() {
78968           if (!_oscSelectedImage)
78969             return;
78970           var sequenceKey = _oscSelectedImage.sequence_id;
78971           var sequence = _oscCache.sequences[sequenceKey];
78972           if (!sequence)
78973             return;
78974           var nextIndex = _oscSelectedImage.sequence_index + stepBy;
78975           var nextImage = sequence.images[nextIndex];
78976           if (!nextImage)
78977             return;
78978           context.map().centerEase(nextImage.loc);
78979           that.selectImage(context, nextImage.key);
78980         };
78981       }
78982       _loadViewerPromise2 = Promise.resolve();
78983       return _loadViewerPromise2;
78984     },
78985     showViewer: function(context) {
78986       var viewer = context.container().select(".photoviewer").classed("hide", false);
78987       var isHidden = viewer.selectAll(".photo-wrapper.kartaview-wrapper.hide").size();
78988       if (isHidden) {
78989         viewer.selectAll(".photo-wrapper:not(.kartaview-wrapper)").classed("hide", true);
78990         viewer.selectAll(".photo-wrapper.kartaview-wrapper").classed("hide", false);
78991       }
78992       return this;
78993     },
78994     hideViewer: function(context) {
78995       _oscSelectedImage = null;
78996       this.updateUrlImage(null);
78997       var viewer = context.container().select(".photoviewer");
78998       if (!viewer.empty())
78999         viewer.datum(null);
79000       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79001       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
79002       return this.setStyles(context, null, true);
79003     },
79004     selectImage: function(context, imageKey) {
79005       var d2 = this.cachedImage(imageKey);
79006       _oscSelectedImage = d2;
79007       this.updateUrlImage(imageKey);
79008       var viewer = context.container().select(".photoviewer");
79009       if (!viewer.empty())
79010         viewer.datum(d2);
79011       this.setStyles(context, null, true);
79012       context.container().selectAll(".icon-sign").classed("currentView", false);
79013       if (!d2)
79014         return this;
79015       var wrap2 = context.container().select(".photoviewer .kartaview-wrapper");
79016       var imageWrap = wrap2.selectAll(".kartaview-image-wrap");
79017       var attribution = wrap2.selectAll(".photo-attribution").text("");
79018       wrap2.transition().duration(100).call(imgZoom2.transform, identity2);
79019       imageWrap.selectAll(".kartaview-image").remove();
79020       if (d2) {
79021         var sequence = _oscCache.sequences[d2.sequence_id];
79022         var r2 = sequence && sequence.rotation || 0;
79023         imageWrap.append("img").attr("class", "kartaview-image").attr("src", apibase2 + "/" + d2.imagePath).style("transform", "rotate(" + r2 + "deg)");
79024         if (d2.captured_by) {
79025           attribution.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://kartaview.org/user/" + encodeURIComponent(d2.captured_by)).text("@" + d2.captured_by);
79026           attribution.append("span").text("|");
79027         }
79028         if (d2.captured_at) {
79029           attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.captured_at));
79030           attribution.append("span").text("|");
79031         }
79032         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");
79033       }
79034       return this;
79035       function localeDateString2(s2) {
79036         if (!s2)
79037           return null;
79038         var options2 = { day: "numeric", month: "short", year: "numeric" };
79039         var d4 = new Date(s2);
79040         if (isNaN(d4.getTime()))
79041           return null;
79042         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
79043       }
79044     },
79045     getSelectedImage: function() {
79046       return _oscSelectedImage;
79047     },
79048     getSequenceKeyForImage: function(d2) {
79049       return d2 && d2.sequence_id;
79050     },
79051     // Updates the currently highlighted sequence and selected bubble.
79052     // Reset is only necessary when interacting with the viewport because
79053     // this implicitly changes the currently selected bubble/sequence
79054     setStyles: function(context, hovered, reset) {
79055       if (reset) {
79056         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79057         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79058       }
79059       var hoveredImageKey = hovered && hovered.key;
79060       var hoveredSequenceKey = this.getSequenceKeyForImage(hovered);
79061       var hoveredSequence = hoveredSequenceKey && _oscCache.sequences[hoveredSequenceKey];
79062       var hoveredImageKeys = hoveredSequence && hoveredSequence.images.map(function(d2) {
79063         return d2.key;
79064       }) || [];
79065       var viewer = context.container().select(".photoviewer");
79066       var selected = viewer.empty() ? void 0 : viewer.datum();
79067       var selectedImageKey = selected && selected.key;
79068       var selectedSequenceKey = this.getSequenceKeyForImage(selected);
79069       var selectedSequence = selectedSequenceKey && _oscCache.sequences[selectedSequenceKey];
79070       var selectedImageKeys = selectedSequence && selectedSequence.images.map(function(d2) {
79071         return d2.key;
79072       }) || [];
79073       var highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79074       context.container().selectAll(".layer-kartaview .viewfield-group").classed("highlighted", function(d2) {
79075         return highlightedImageKeys.indexOf(d2.key) !== -1;
79076       }).classed("hovered", function(d2) {
79077         return d2.key === hoveredImageKey;
79078       }).classed("currentView", function(d2) {
79079         return d2.key === selectedImageKey;
79080       });
79081       context.container().selectAll(".layer-kartaview .sequence").classed("highlighted", function(d2) {
79082         return d2.properties.key === hoveredSequenceKey;
79083       }).classed("currentView", function(d2) {
79084         return d2.properties.key === selectedSequenceKey;
79085       });
79086       context.container().selectAll(".layer-kartaview .viewfield-group .viewfield").attr("d", viewfieldPath);
79087       function viewfieldPath() {
79088         var d2 = this.parentNode.__data__;
79089         if (d2.pano && d2.key !== selectedImageKey) {
79090           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79091         } else {
79092           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79093         }
79094       }
79095       return this;
79096     },
79097     updateUrlImage: function(imageKey) {
79098       if (!window.mocha) {
79099         var hash = utilStringQs(window.location.hash);
79100         if (imageKey) {
79101           hash.photo = "kartaview/" + imageKey;
79102         } else {
79103           delete hash.photo;
79104         }
79105         window.location.replace("#" + utilQsString(hash, true));
79106       }
79107     },
79108     cache: function() {
79109       return _oscCache;
79110     }
79111   };
79112
79113   // modules/services/vegbilder.js
79114   var import_rbush9 = __toESM(require_rbush_min());
79115
79116   // modules/services/pannellum_photo.js
79117   var pannellumViewerCSS = "pannellum/pannellum.css";
79118   var pannellumViewerJS = "pannellum/pannellum.js";
79119   var dispatch8 = dispatch_default("viewerChanged");
79120   var _currScenes = [];
79121   var _pannellumViewer;
79122   var pannellum_photo_default = {
79123     init: async function(context, selection2) {
79124       selection2.append("div").attr("class", "photo-frame pannellum-frame").attr("id", "ideditor-pannellum-viewer").classed("hide", true);
79125       if (!window.pannellum) {
79126         await this.loadPannellum(context);
79127       }
79128       const options2 = {
79129         "default": { firstScene: "" },
79130         scenes: {}
79131       };
79132       _pannellumViewer = window.pannellum.viewer("ideditor-pannellum-viewer", options2);
79133       _pannellumViewer.on("mousedown", () => {
79134         select_default2(window).on("pointermove.pannellum mousemove.pannellum", () => {
79135           dispatch8.call("viewerChanged");
79136         });
79137       }).on("mouseup", () => {
79138         select_default2(window).on("pointermove.pannellum mousemove.pannellum", null);
79139       }).on("animatefinished", () => {
79140         dispatch8.call("viewerChanged");
79141       });
79142       context.ui().photoviewer.on("resize.pannellum", () => {
79143         _pannellumViewer.resize();
79144       });
79145       this.event = utilRebind(this, dispatch8, "on");
79146       return this;
79147     },
79148     loadPannellum: function(context) {
79149       const head = select_default2("head");
79150       return Promise.all([
79151         new Promise((resolve, reject) => {
79152           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);
79153         }),
79154         new Promise((resolve, reject) => {
79155           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);
79156         })
79157       ]);
79158     },
79159     showPhotoFrame: function(context) {
79160       const isHidden = context.selectAll(".photo-frame.pannellum-frame.hide").size();
79161       if (isHidden) {
79162         context.selectAll(".photo-frame:not(.pannellum-frame)").classed("hide", true);
79163         context.selectAll(".photo-frame.pannellum-frame").classed("hide", false);
79164       }
79165       return this;
79166     },
79167     hidePhotoFrame: function(viewerContext) {
79168       viewerContext.select("photo-frame.pannellum-frame").classed("hide", false);
79169       return this;
79170     },
79171     selectPhoto: function(data, keepOrientation) {
79172       const { key } = data;
79173       if (!(key in _currScenes)) {
79174         let newSceneOptions = {
79175           showFullscreenCtrl: false,
79176           autoLoad: false,
79177           compass: true,
79178           yaw: 0,
79179           type: "equirectangular",
79180           preview: data.preview_path,
79181           panorama: data.image_path,
79182           northOffset: data.ca
79183         };
79184         _currScenes.push(key);
79185         _pannellumViewer.addScene(key, newSceneOptions);
79186       }
79187       let yaw = 0;
79188       let pitch = 0;
79189       if (keepOrientation) {
79190         yaw = this.getYaw();
79191         pitch = _pannellumViewer.getPitch();
79192       }
79193       _pannellumViewer.loadScene(key, pitch, yaw);
79194       dispatch8.call("viewerChanged");
79195       if (_currScenes.length > 3) {
79196         const old_key = _currScenes.shift();
79197         _pannellumViewer.removeScene(old_key);
79198       }
79199       return this;
79200     },
79201     getYaw: function() {
79202       return _pannellumViewer.getYaw();
79203     }
79204   };
79205
79206   // modules/services/vegbilder.js
79207   var owsEndpoint = "https://www.vegvesen.no/kart/ogc/vegbilder_1_0/ows?";
79208   var tileZoom2 = 14;
79209   var tiler5 = utilTiler().zoomExtent([tileZoom2, tileZoom2]).skipNullIsland(true);
79210   var dispatch9 = dispatch_default("loadedImages", "viewerChanged");
79211   var directionEnum = Object.freeze({
79212     forward: Symbol(0),
79213     backward: Symbol(1)
79214   });
79215   var _planeFrame;
79216   var _pannellumFrame;
79217   var _currentFrame;
79218   var _loadViewerPromise3;
79219   var _vegbilderCache;
79220   async function fetchAvailableLayers() {
79221     var _a2, _b, _c;
79222     const params = {
79223       service: "WFS",
79224       request: "GetCapabilities",
79225       version: "2.0.0"
79226     };
79227     const urlForRequest = owsEndpoint + utilQsString(params);
79228     const response = await xml_default(urlForRequest);
79229     const xPathSelector = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType/wfs:Name";
79230     const regexMatcher = /^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\d{4})$/;
79231     const NSResolver = response.createNSResolver(response);
79232     const l2 = response.evaluate(
79233       xPathSelector,
79234       response,
79235       NSResolver,
79236       XPathResult.ANY_TYPE
79237     );
79238     let node;
79239     const availableLayers = [];
79240     while ((node = l2.iterateNext()) !== null) {
79241       const match = (_a2 = node.textContent) == null ? void 0 : _a2.match(regexMatcher);
79242       if (match) {
79243         availableLayers.push({
79244           name: match[0],
79245           is_sphere: !!((_b = match.groups) == null ? void 0 : _b.image_type),
79246           year: parseInt((_c = match.groups) == null ? void 0 : _c.year, 10)
79247         });
79248       }
79249     }
79250     return availableLayers;
79251   }
79252   function filterAvailableLayers(photoContex) {
79253     const fromDateString = photoContex.fromDate();
79254     const toDateString = photoContex.toDate();
79255     const fromYear = fromDateString ? new Date(fromDateString).getFullYear() : 2016;
79256     const toYear = toDateString ? new Date(toDateString).getFullYear() : null;
79257     const showsFlat = photoContex.showsFlat();
79258     const showsPano = photoContex.showsPanoramic();
79259     return Array.from(_vegbilderCache.wfslayers.values()).filter(({ layerInfo }) => layerInfo.year >= fromYear && (!toYear || layerInfo.year <= toYear) && (!layerInfo.is_sphere && showsFlat || layerInfo.is_sphere && showsPano));
79260   }
79261   function loadWFSLayers(projection2, margin, wfslayers) {
79262     const tiles = tiler5.margin(margin).getTiles(projection2);
79263     for (const cache of wfslayers) {
79264       loadWFSLayer(projection2, cache, tiles);
79265     }
79266   }
79267   function loadWFSLayer(projection2, cache, tiles) {
79268     for (const [key, controller] of cache.inflight.entries()) {
79269       const wanted = tiles.some((tile) => key === tile.id);
79270       if (!wanted) {
79271         controller.abort();
79272         cache.inflight.delete(key);
79273       }
79274     }
79275     Promise.all(tiles.map(
79276       (tile) => loadTile2(cache, cache.layerInfo.name, tile)
79277     )).then(() => orderSequences(projection2, cache));
79278   }
79279   async function loadTile2(cache, typename, tile) {
79280     const bbox2 = tile.extent.bbox();
79281     const tileid = tile.id;
79282     if (cache.loaded.get(tileid) === true || cache.inflight.has(tileid))
79283       return;
79284     const params = {
79285       service: "WFS",
79286       request: "GetFeature",
79287       version: "2.0.0",
79288       typenames: typename,
79289       bbox: [bbox2.minY, bbox2.minX, bbox2.maxY, bbox2.maxX].join(","),
79290       outputFormat: "json"
79291     };
79292     const controller = new AbortController();
79293     cache.inflight.set(tileid, controller);
79294     const options2 = {
79295       method: "GET",
79296       signal: controller.signal
79297     };
79298     const urlForRequest = owsEndpoint + utilQsString(params);
79299     let featureCollection;
79300     try {
79301       featureCollection = await json_default(urlForRequest, options2);
79302     } catch {
79303       cache.loaded.set(tileid, false);
79304       return;
79305     } finally {
79306       cache.inflight.delete(tileid);
79307     }
79308     cache.loaded.set(tileid, true);
79309     if (featureCollection.features.length === 0) {
79310       return;
79311     }
79312     const features = featureCollection.features.map((feature3) => {
79313       const loc = feature3.geometry.coordinates;
79314       const key = feature3.id;
79315       const properties = feature3.properties;
79316       const {
79317         RETNING: ca,
79318         TIDSPUNKT: captured_at,
79319         URL: image_path,
79320         URLPREVIEW: preview_path,
79321         BILDETYPE: image_type,
79322         METER: metering,
79323         FELTKODE: lane_code
79324       } = properties;
79325       const lane_number = parseInt(lane_code.match(/^[0-9]+/)[0], 10);
79326       const direction = lane_number % 2 === 0 ? directionEnum.backward : directionEnum.forward;
79327       const data = {
79328         loc,
79329         key,
79330         ca,
79331         image_path,
79332         preview_path,
79333         road_reference: roadReference(properties),
79334         metering,
79335         lane_code,
79336         direction,
79337         captured_at: new Date(captured_at),
79338         is_sphere: image_type === "360"
79339       };
79340       cache.points.set(key, data);
79341       return {
79342         minX: loc[0],
79343         minY: loc[1],
79344         maxX: loc[0],
79345         maxY: loc[1],
79346         data
79347       };
79348     });
79349     _vegbilderCache.rtree.load(features);
79350     dispatch9.call("loadedImages");
79351   }
79352   function orderSequences(projection2, cache) {
79353     const { points } = cache;
79354     const grouped = Array.from(points.values()).reduce((grouped2, image) => {
79355       const key = image.road_reference;
79356       if (grouped2.has(key)) {
79357         grouped2.get(key).push(image);
79358       } else {
79359         grouped2.set(key, [image]);
79360       }
79361       return grouped2;
79362     }, /* @__PURE__ */ new Map());
79363     const imageSequences = Array.from(grouped.values()).reduce((imageSequences2, imageGroup) => {
79364       imageGroup.sort((a2, b2) => {
79365         if (a2.captured_at.valueOf() > b2.captured_at.valueOf()) {
79366           return 1;
79367         } else if (a2.captured_at.valueOf() < b2.captured_at.valueOf()) {
79368           return -1;
79369         } else {
79370           const { direction } = a2;
79371           if (direction === directionEnum.forward) {
79372             return a2.metering - b2.metering;
79373           } else {
79374             return b2.metering - a2.metering;
79375           }
79376         }
79377       });
79378       let imageSequence = [imageGroup[0]];
79379       let angle2 = null;
79380       for (const [lastImage, image] of pairs(imageGroup)) {
79381         if (lastImage.ca === null) {
79382           const b2 = projection2(lastImage.loc);
79383           const a2 = projection2(image.loc);
79384           if (!geoVecEqual(a2, b2)) {
79385             angle2 = geoVecAngle(a2, b2);
79386             angle2 *= 180 / Math.PI;
79387             angle2 -= 90;
79388             angle2 = angle2 >= 0 ? angle2 : angle2 + 360;
79389           }
79390           lastImage.ca = angle2;
79391         }
79392         if (image.direction === lastImage.direction && image.captured_at.valueOf() - lastImage.captured_at.valueOf() <= 2e4) {
79393           imageSequence.push(image);
79394         } else {
79395           imageSequences2.push(imageSequence);
79396           imageSequence = [image];
79397         }
79398       }
79399       imageSequences2.push(imageSequence);
79400       return imageSequences2;
79401     }, []);
79402     cache.sequences = imageSequences.map((images) => {
79403       const sequence = {
79404         images,
79405         key: images[0].key,
79406         geometry: {
79407           type: "LineString",
79408           coordinates: images.map((image) => image.loc)
79409         }
79410       };
79411       for (const image of images) {
79412         _vegbilderCache.image2sequence_map.set(image.key, sequence);
79413       }
79414       return sequence;
79415     });
79416   }
79417   function roadReference(properties) {
79418     const {
79419       FYLKENUMMER: county_number,
79420       VEGKATEGORI: road_class,
79421       VEGSTATUS: road_status,
79422       VEGNUMMER: road_number,
79423       STREKNING: section,
79424       DELSTREKNING: subsection,
79425       HP: parcel,
79426       KRYSSDEL: junction_part,
79427       SIDEANLEGGSDEL: services_part,
79428       ANKERPUNKT: anker_point,
79429       AAR: year
79430     } = properties;
79431     let reference;
79432     if (year >= 2020) {
79433       reference = "".concat(road_class).concat(road_status).concat(road_number, " S").concat(section, "D").concat(subsection);
79434       if (junction_part) {
79435         reference = "".concat(reference, " M").concat(anker_point, " KD").concat(junction_part);
79436       } else if (services_part) {
79437         reference = "".concat(reference, " M").concat(anker_point, " SD").concat(services_part);
79438       }
79439     } else {
79440       reference = "".concat(county_number).concat(road_class).concat(road_status).concat(road_number, " HP").concat(parcel);
79441     }
79442     return reference;
79443   }
79444   function localeTimestamp(date) {
79445     const options2 = {
79446       day: "2-digit",
79447       month: "2-digit",
79448       year: "numeric",
79449       hour: "numeric",
79450       minute: "numeric",
79451       second: "numeric"
79452     };
79453     return date.toLocaleString(_mainLocalizer.localeCode(), options2);
79454   }
79455   function partitionViewport3(projection2) {
79456     const zoom = geoScaleToZoom(projection2.scale());
79457     const roundZoom = Math.ceil(zoom * 2) / 2 + 2.5;
79458     const tiler9 = utilTiler().zoomExtent([roundZoom, roundZoom]);
79459     return tiler9.getTiles(projection2).map((tile) => tile.extent);
79460   }
79461   function searchLimited3(limit, projection2, rtree) {
79462     limit != null ? limit : limit = 5;
79463     return partitionViewport3(projection2).reduce((result, extent) => {
79464       const found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
79465       return result.concat(found);
79466     }, []);
79467   }
79468   var vegbilder_default = {
79469     init: function() {
79470       this.event = utilRebind(this, dispatch9, "on");
79471     },
79472     reset: async function() {
79473       if (_vegbilderCache) {
79474         for (const layer of _vegbilderCache.wfslayers.values()) {
79475           for (const controller of layer.inflight.values()) {
79476             controller.abort();
79477           }
79478         }
79479       }
79480       _vegbilderCache = {
79481         wfslayers: /* @__PURE__ */ new Map(),
79482         rtree: new import_rbush9.default(),
79483         image2sequence_map: /* @__PURE__ */ new Map()
79484       };
79485       const availableLayers = await fetchAvailableLayers();
79486       const { wfslayers } = _vegbilderCache;
79487       for (const layerInfo of availableLayers) {
79488         const cache = {
79489           layerInfo,
79490           loaded: /* @__PURE__ */ new Map(),
79491           inflight: /* @__PURE__ */ new Map(),
79492           points: /* @__PURE__ */ new Map(),
79493           sequences: []
79494         };
79495         wfslayers.set(layerInfo.name, cache);
79496       }
79497     },
79498     images: function(projection2) {
79499       const limit = 5;
79500       return searchLimited3(limit, projection2, _vegbilderCache.rtree);
79501     },
79502     sequences: function(projection2) {
79503       const viewport = projection2.clipExtent();
79504       const min3 = [viewport[0][0], viewport[1][1]];
79505       const max3 = [viewport[1][0], viewport[0][1]];
79506       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
79507       const seen = /* @__PURE__ */ new Set();
79508       const line_strings = [];
79509       for (const { data } of _vegbilderCache.rtree.search(bbox2)) {
79510         const sequence = _vegbilderCache.image2sequence_map.get(data.key);
79511         if (!sequence)
79512           continue;
79513         const { key, geometry, images } = sequence;
79514         if (seen.has(key))
79515           continue;
79516         seen.add(key);
79517         const line = {
79518           type: "LineString",
79519           coordinates: geometry.coordinates,
79520           key,
79521           images
79522         };
79523         line_strings.push(line);
79524       }
79525       return line_strings;
79526     },
79527     cachedImage: function(key) {
79528       for (const { points } of _vegbilderCache.wfslayers.values()) {
79529         if (points.has(key))
79530           return points.get(key);
79531       }
79532     },
79533     getSequenceForImage: function(image) {
79534       return _vegbilderCache == null ? void 0 : _vegbilderCache.image2sequence_map.get(image == null ? void 0 : image.key);
79535     },
79536     loadImages: async function(context, margin) {
79537       if (!_vegbilderCache) {
79538         await this.reset();
79539       }
79540       margin != null ? margin : margin = 1;
79541       const wfslayers = filterAvailableLayers(context.photos());
79542       loadWFSLayers(context.projection, margin, wfslayers);
79543     },
79544     photoFrame: function() {
79545       return _currentFrame;
79546     },
79547     ensureViewerLoaded: function(context) {
79548       if (_loadViewerPromise3)
79549         return _loadViewerPromise3;
79550       const step = (stepBy) => () => {
79551         const viewer = context.container().select(".photoviewer");
79552         const selected = viewer.empty() ? void 0 : viewer.datum();
79553         if (!selected)
79554           return;
79555         const sequence = this.getSequenceForImage(selected);
79556         const nextIndex = sequence.images.indexOf(selected) + stepBy;
79557         const nextImage = sequence.images[nextIndex];
79558         if (!nextImage)
79559           return;
79560         context.map().centerEase(nextImage.loc);
79561         this.selectImage(context, nextImage.key, true);
79562       };
79563       const wrap2 = context.container().select(".photoviewer").selectAll(".vegbilder-wrapper").data([0]);
79564       const wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper vegbilder-wrapper").classed("hide", true);
79565       wrapEnter.append("div").attr("class", "photo-attribution fillD");
79566       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
79567       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
79568       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
79569       _loadViewerPromise3 = Promise.all([
79570         pannellum_photo_default.init(context, wrapEnter),
79571         plane_photo_default.init(context, wrapEnter)
79572       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
79573         _pannellumFrame = pannellumPhotoFrame;
79574         _pannellumFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79575         _planeFrame = planePhotoFrame;
79576         _planeFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79577       });
79578       return _loadViewerPromise3;
79579     },
79580     selectImage: function(context, key, keepOrientation) {
79581       const d2 = this.cachedImage(key);
79582       this.updateUrlImage(key);
79583       const viewer = context.container().select(".photoviewer");
79584       if (!viewer.empty()) {
79585         viewer.datum(d2);
79586       }
79587       this.setStyles(context, null, true);
79588       if (!d2)
79589         return this;
79590       const wrap2 = context.container().select(".photoviewer .vegbilder-wrapper");
79591       const attribution = wrap2.selectAll(".photo-attribution").text("");
79592       if (d2.captured_at) {
79593         attribution.append("span").attr("class", "captured_at").text(localeTimestamp(d2.captured_at));
79594       }
79595       attribution.append("a").attr("target", "_blank").attr("href", "https://vegvesen.no").call(_t.append("vegbilder.publisher"));
79596       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"));
79597       _currentFrame = d2.is_sphere ? _pannellumFrame : _planeFrame;
79598       _currentFrame.selectPhoto(d2, keepOrientation).showPhotoFrame(wrap2);
79599       return this;
79600     },
79601     showViewer: function(context) {
79602       const viewer = context.container().select(".photoviewer").classed("hide", false);
79603       const isHidden = viewer.selectAll(".photo-wrapper.vegbilder-wrapper.hide").size();
79604       if (isHidden) {
79605         viewer.selectAll(".photo-wrapper:not(.vegbilder-wrapper)").classed("hide", true);
79606         viewer.selectAll(".photo-wrapper.vegbilder-wrapper").classed("hide", false);
79607       }
79608       return this;
79609     },
79610     hideViewer: function(context) {
79611       this.updateUrlImage(null);
79612       const viewer = context.container().select(".photoviewer");
79613       if (!viewer.empty())
79614         viewer.datum(null);
79615       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79616       context.container().selectAll(".viewfield-group, .sequence").classed("currentView", false);
79617       return this.setStyles(context, null, true);
79618     },
79619     // Updates the currently highlighted sequence and selected bubble.
79620     // Reset is only necessary when interacting with the viewport because
79621     // this implicitly changes the currently selected bubble/sequence
79622     setStyles: function(context, hovered, reset) {
79623       var _a2, _b;
79624       if (reset) {
79625         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79626         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79627       }
79628       const hoveredImageKey = hovered == null ? void 0 : hovered.key;
79629       const hoveredSequence = this.getSequenceForImage(hovered);
79630       const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key;
79631       const hoveredImageKeys = (_a2 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a2 : [];
79632       const viewer = context.container().select(".photoviewer");
79633       const selected = viewer.empty() ? void 0 : viewer.datum();
79634       const selectedImageKey = selected == null ? void 0 : selected.key;
79635       const selectedSequence = this.getSequenceForImage(selected);
79636       const selectedSequenceKey = selectedSequence == null ? void 0 : selectedSequence.key;
79637       const selectedImageKeys = (_b = selectedSequence == null ? void 0 : selectedSequence.images.map((d2) => d2.key)) != null ? _b : [];
79638       const highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79639       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);
79640       context.container().selectAll(".layer-vegbilder .sequence").classed("highlighted", (d2) => d2.key === hoveredSequenceKey).classed("currentView", (d2) => d2.key === selectedSequenceKey);
79641       context.container().selectAll(".layer-vegbilder .viewfield-group .viewfield").attr("d", viewfieldPath);
79642       function viewfieldPath() {
79643         const d2 = this.parentNode.__data__;
79644         if (d2.is_sphere && d2.key !== selectedImageKey) {
79645           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79646         } else {
79647           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79648         }
79649       }
79650       return this;
79651     },
79652     updateUrlImage: function(key) {
79653       if (!window.mocha) {
79654         const hash = utilStringQs(window.location.hash);
79655         if (key) {
79656           hash.photo = "vegbilder/" + key;
79657         } else {
79658           delete hash.photo;
79659         }
79660         window.location.replace("#" + utilQsString(hash, true));
79661       }
79662     },
79663     validHere: function(extent) {
79664       const bbox2 = Object.values(extent.bbox());
79665       return iso1A2Codes(bbox2).includes("NO");
79666     },
79667     cache: function() {
79668       return _vegbilderCache;
79669     }
79670   };
79671
79672   // node_modules/osm-auth/src/osm-auth.mjs
79673   function osmAuth(o2) {
79674     var oauth2 = {};
79675     var _store = null;
79676     try {
79677       _store = window.localStorage;
79678     } catch (e3) {
79679       var _mock = /* @__PURE__ */ new Map();
79680       _store = {
79681         isMocked: true,
79682         hasItem: (k2) => _mock.has(k2),
79683         getItem: (k2) => _mock.get(k2),
79684         setItem: (k2, v2) => _mock.set(k2, v2),
79685         removeItem: (k2) => _mock.delete(k2),
79686         clear: () => _mock.clear()
79687       };
79688     }
79689     function token(k2, v2) {
79690       if (arguments.length === 1)
79691         return _store.getItem(o2.url + k2);
79692       else if (arguments.length === 2)
79693         return _store.setItem(o2.url + k2, v2);
79694     }
79695     oauth2.authenticated = function() {
79696       return !!token("oauth2_access_token");
79697     };
79698     oauth2.logout = function() {
79699       token("oauth2_access_token", "");
79700       token("oauth_token", "");
79701       token("oauth_token_secret", "");
79702       token("oauth_request_token_secret", "");
79703       return oauth2;
79704     };
79705     oauth2.authenticate = function(callback) {
79706       if (oauth2.authenticated()) {
79707         callback(null, oauth2);
79708         return;
79709       }
79710       oauth2.logout();
79711       _preopenPopup(function(error, popup) {
79712         if (error) {
79713           callback(error);
79714         } else {
79715           _generatePkceChallenge(function(pkce) {
79716             _authenticate(pkce, popup, callback);
79717           });
79718         }
79719       });
79720     };
79721     oauth2.authenticateAsync = function() {
79722       if (oauth2.authenticated()) {
79723         return Promise.resolve(oauth2);
79724       }
79725       oauth2.logout();
79726       return new Promise((resolve, reject) => {
79727         var errback = (err, result) => {
79728           if (err) {
79729             reject(err);
79730           } else {
79731             resolve(result);
79732           }
79733         };
79734         _preopenPopup((error, popup) => {
79735           if (error) {
79736             errback(error);
79737           } else {
79738             _generatePkceChallenge((pkce) => _authenticate(pkce, popup, errback));
79739           }
79740         });
79741       });
79742     };
79743     function _preopenPopup(callback) {
79744       if (o2.singlepage) {
79745         callback(null, void 0);
79746         return;
79747       }
79748       var w2 = 550;
79749       var h2 = 610;
79750       var settings = [
79751         ["width", w2],
79752         ["height", h2],
79753         ["left", window.screen.width / 2 - w2 / 2],
79754         ["top", window.screen.height / 2 - h2 / 2]
79755       ].map(function(x2) {
79756         return x2.join("=");
79757       }).join(",");
79758       var popup = window.open("about:blank", "oauth_window", settings);
79759       if (popup) {
79760         callback(null, popup);
79761       } else {
79762         var error = new Error("Popup was blocked");
79763         error.status = "popup-blocked";
79764         callback(error);
79765       }
79766     }
79767     function _authenticate(pkce, popup, callback) {
79768       var state = generateState();
79769       var url = o2.url + "/oauth2/authorize?" + utilQsString2({
79770         client_id: o2.client_id,
79771         redirect_uri: o2.redirect_uri,
79772         response_type: "code",
79773         scope: o2.scope,
79774         state,
79775         code_challenge: pkce.code_challenge,
79776         code_challenge_method: pkce.code_challenge_method
79777       });
79778       if (o2.singlepage) {
79779         if (_store.isMocked) {
79780           var error = new Error("localStorage unavailable, but required in singlepage mode");
79781           error.status = "pkce-localstorage-unavailable";
79782           callback(error);
79783           return;
79784         }
79785         var params = utilStringQs2(window.location.search.slice(1));
79786         if (params.code) {
79787           oauth2.bootstrapToken(params.code, callback);
79788         } else {
79789           token("oauth2_state", state);
79790           token("oauth2_pkce_code_verifier", pkce.code_verifier);
79791           window.location = url;
79792         }
79793       } else {
79794         oauth2.popupWindow = popup;
79795         popup.location = url;
79796       }
79797       window.authComplete = function(url2) {
79798         var params2 = utilStringQs2(url2.split("?")[1]);
79799         if (params2.state !== state) {
79800           error = new Error("Invalid state");
79801           error.status = "invalid-state";
79802           callback(error);
79803           return;
79804         }
79805         _getAccessToken(params2.code, pkce.code_verifier, accessTokenDone);
79806         delete window.authComplete;
79807       };
79808       function accessTokenDone(err, xhr) {
79809         o2.done();
79810         if (err) {
79811           callback(err);
79812           return;
79813         }
79814         var access_token = JSON.parse(xhr.response);
79815         token("oauth2_access_token", access_token.access_token);
79816         callback(null, oauth2);
79817       }
79818     }
79819     function _getAccessToken(auth_code, code_verifier, accessTokenDone) {
79820       var url = o2.url + "/oauth2/token?" + utilQsString2({
79821         client_id: o2.client_id,
79822         redirect_uri: o2.redirect_uri,
79823         grant_type: "authorization_code",
79824         code: auth_code,
79825         code_verifier
79826       });
79827       oauth2.rawxhr("POST", url, null, null, null, accessTokenDone);
79828       o2.loading();
79829     }
79830     oauth2.bringPopupWindowToFront = function() {
79831       var broughtPopupToFront = false;
79832       try {
79833         if (oauth2.popupWindow && !oauth2.popupWindow.closed) {
79834           oauth2.popupWindow.focus();
79835           broughtPopupToFront = true;
79836         }
79837       } catch (err) {
79838       }
79839       return broughtPopupToFront;
79840     };
79841     oauth2.bootstrapToken = function(auth_code, callback) {
79842       var state = token("oauth2_state");
79843       token("oauth2_state", "");
79844       var params = utilStringQs2(window.location.search.slice(1));
79845       if (params.state !== state) {
79846         var error = new Error("Invalid state");
79847         error.status = "invalid-state";
79848         callback(error);
79849         return;
79850       }
79851       var code_verifier = token("oauth2_pkce_code_verifier");
79852       token("oauth2_pkce_code_verifier", "");
79853       _getAccessToken(auth_code, code_verifier, accessTokenDone);
79854       function accessTokenDone(err, xhr) {
79855         o2.done();
79856         if (err) {
79857           callback(err);
79858           return;
79859         }
79860         var access_token = JSON.parse(xhr.response);
79861         token("oauth2_access_token", access_token.access_token);
79862         callback(null, oauth2);
79863       }
79864     };
79865     oauth2.fetch = function(resource, options2) {
79866       if (oauth2.authenticated()) {
79867         return _doFetch();
79868       } else {
79869         if (o2.auto) {
79870           return oauth2.authenticateAsync().then(_doFetch);
79871         } else {
79872           return Promise.reject(new Error("not authenticated"));
79873         }
79874       }
79875       function _doFetch() {
79876         options2 = options2 || {};
79877         if (!options2.headers) {
79878           options2.headers = { "Content-Type": "application/x-www-form-urlencoded" };
79879         }
79880         options2.headers.Authorization = "Bearer " + token("oauth2_access_token");
79881         return fetch(resource, options2);
79882       }
79883     };
79884     oauth2.xhr = function(options2, callback) {
79885       if (oauth2.authenticated()) {
79886         return _doXHR();
79887       } else {
79888         if (o2.auto) {
79889           oauth2.authenticate(_doXHR);
79890           return;
79891         } else {
79892           callback("not authenticated", null);
79893           return;
79894         }
79895       }
79896       function _doXHR() {
79897         var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path;
79898         return oauth2.rawxhr(
79899           options2.method,
79900           url,
79901           token("oauth2_access_token"),
79902           options2.content,
79903           options2.headers,
79904           done
79905         );
79906       }
79907       function done(err, xhr) {
79908         if (err) {
79909           callback(err);
79910         } else if (xhr.responseXML) {
79911           callback(err, xhr.responseXML);
79912         } else {
79913           callback(err, xhr.response);
79914         }
79915       }
79916     };
79917     oauth2.rawxhr = function(method, url, access_token, data, headers, callback) {
79918       headers = headers || { "Content-Type": "application/x-www-form-urlencoded" };
79919       if (access_token) {
79920         headers.Authorization = "Bearer " + access_token;
79921       }
79922       var xhr = new XMLHttpRequest();
79923       xhr.onreadystatechange = function() {
79924         if (4 === xhr.readyState && 0 !== xhr.status) {
79925           if (/^20\d$/.test(xhr.status)) {
79926             callback(null, xhr);
79927           } else {
79928             callback(xhr, null);
79929           }
79930         }
79931       };
79932       xhr.onerror = function(e3) {
79933         callback(e3, null);
79934       };
79935       xhr.open(method, url, true);
79936       for (var h2 in headers)
79937         xhr.setRequestHeader(h2, headers[h2]);
79938       xhr.send(data);
79939       return xhr;
79940     };
79941     oauth2.preauth = function(val) {
79942       if (val && val.access_token) {
79943         token("oauth2_access_token", val.access_token);
79944       }
79945       return oauth2;
79946     };
79947     oauth2.options = function(val) {
79948       if (!arguments.length)
79949         return o2;
79950       o2 = val;
79951       o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org";
79952       o2.url = o2.url || "https://www.openstreetmap.org";
79953       o2.auto = o2.auto || false;
79954       o2.singlepage = o2.singlepage || false;
79955       o2.loading = o2.loading || function() {
79956       };
79957       o2.done = o2.done || function() {
79958       };
79959       return oauth2.preauth(o2);
79960     };
79961     oauth2.options(o2);
79962     return oauth2;
79963   }
79964   function utilQsString2(obj) {
79965     return Object.keys(obj).filter(function(key) {
79966       return obj[key] !== void 0;
79967     }).sort().map(function(key) {
79968       return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
79969     }).join("&");
79970   }
79971   function utilStringQs2(str) {
79972     var i3 = 0;
79973     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
79974       i3++;
79975     str = str.slice(i3);
79976     return str.split("&").reduce(function(obj, pair3) {
79977       var parts = pair3.split("=");
79978       if (parts.length === 2) {
79979         obj[parts[0]] = decodeURIComponent(parts[1]);
79980       }
79981       return obj;
79982     }, {});
79983   }
79984   function supportsWebCryptoAPI() {
79985     return window && window.crypto && window.crypto.getRandomValues && window.crypto.subtle && window.crypto.subtle.digest;
79986   }
79987   function _generatePkceChallenge(callback) {
79988     var code_verifier;
79989     if (supportsWebCryptoAPI()) {
79990       var random = window.crypto.getRandomValues(new Uint8Array(32));
79991       code_verifier = base64(random.buffer);
79992       var verifier = Uint8Array.from(Array.from(code_verifier).map(function(char) {
79993         return char.charCodeAt(0);
79994       }));
79995       window.crypto.subtle.digest("SHA-256", verifier).then(function(hash) {
79996         var code_challenge = base64(hash);
79997         callback({
79998           code_challenge,
79999           code_verifier,
80000           code_challenge_method: "S256"
80001         });
80002       });
80003     } else {
80004       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80005       code_verifier = "";
80006       for (var i3 = 0; i3 < 64; i3++) {
80007         code_verifier += chars[Math.floor(Math.random() * chars.length)];
80008       }
80009       callback({
80010         code_verifier,
80011         code_challenge: code_verifier,
80012         code_challenge_method: "plain"
80013       });
80014     }
80015   }
80016   function generateState() {
80017     var state;
80018     if (supportsWebCryptoAPI()) {
80019       var random = window.crypto.getRandomValues(new Uint8Array(32));
80020       state = base64(random.buffer);
80021     } else {
80022       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80023       state = "";
80024       for (var i3 = 0; i3 < 64; i3++) {
80025         state += chars[Math.floor(Math.random() * chars.length)];
80026       }
80027     }
80028     return state;
80029   }
80030   function base64(buffer) {
80031     return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]/g, "");
80032   }
80033
80034   // modules/services/osm.js
80035   var import_rbush10 = __toESM(require_rbush_min());
80036   var tiler6 = utilTiler();
80037   var dispatch10 = dispatch_default("apiStatusChange", "authLoading", "authDone", "change", "loading", "loaded", "loadedNotes");
80038   var urlroot = osmApiConnections[0].url;
80039   var apiUrlroot = osmApiConnections[0].apiUrl || urlroot;
80040   var redirectPath = window.location.origin + window.location.pathname;
80041   var oauth = osmAuth({
80042     url: urlroot,
80043     apiUrl: apiUrlroot,
80044     client_id: osmApiConnections[0].client_id,
80045     client_secret: osmApiConnections[0].client_secret,
80046     scope: "read_prefs write_prefs write_api read_gpx write_notes",
80047     redirect_uri: redirectPath + "land.html",
80048     loading: authLoading,
80049     done: authDone
80050   });
80051   var _apiConnections = osmApiConnections;
80052   var _imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
80053   var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80054   var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80055   var _userCache = { toLoad: {}, user: {} };
80056   var _cachedApiStatus;
80057   var _changeset = {};
80058   var _deferred = /* @__PURE__ */ new Set();
80059   var _connectionID = 1;
80060   var _tileZoom4 = 16;
80061   var _noteZoom = 12;
80062   var _rateLimitError;
80063   var _userChangesets;
80064   var _userDetails;
80065   var _off;
80066   var _maxWayNodes = 2e3;
80067   function authLoading() {
80068     dispatch10.call("authLoading");
80069   }
80070   function authDone() {
80071     dispatch10.call("authDone");
80072   }
80073   function abortRequest5(controllerOrXHR) {
80074     if (controllerOrXHR) {
80075       controllerOrXHR.abort();
80076     }
80077   }
80078   function hasInflightRequests(cache) {
80079     return Object.keys(cache.inflight).length;
80080   }
80081   function abortUnwantedRequests4(cache, visibleTiles) {
80082     Object.keys(cache.inflight).forEach(function(k2) {
80083       if (cache.toLoad[k2])
80084         return;
80085       if (visibleTiles.find(function(tile) {
80086         return k2 === tile.id;
80087       }))
80088         return;
80089       abortRequest5(cache.inflight[k2]);
80090       delete cache.inflight[k2];
80091     });
80092   }
80093   function getLoc(attrs) {
80094     var lon = attrs.lon && attrs.lon.value;
80095     var lat = attrs.lat && attrs.lat.value;
80096     return [Number(lon), Number(lat)];
80097   }
80098   function getNodes(obj) {
80099     var elems = obj.getElementsByTagName("nd");
80100     var nodes = new Array(elems.length);
80101     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80102       nodes[i3] = "n" + elems[i3].attributes.ref.value;
80103     }
80104     return nodes;
80105   }
80106   function getNodesJSON(obj) {
80107     var elems = obj.nodes;
80108     var nodes = new Array(elems.length);
80109     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80110       nodes[i3] = "n" + elems[i3];
80111     }
80112     return nodes;
80113   }
80114   function getTags(obj) {
80115     var elems = obj.getElementsByTagName("tag");
80116     var tags = {};
80117     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80118       var attrs = elems[i3].attributes;
80119       tags[attrs.k.value] = attrs.v.value;
80120     }
80121     return tags;
80122   }
80123   function getMembers(obj) {
80124     var elems = obj.getElementsByTagName("member");
80125     var members = new Array(elems.length);
80126     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80127       var attrs = elems[i3].attributes;
80128       members[i3] = {
80129         id: attrs.type.value[0] + attrs.ref.value,
80130         type: attrs.type.value,
80131         role: attrs.role.value
80132       };
80133     }
80134     return members;
80135   }
80136   function getMembersJSON(obj) {
80137     var elems = obj.members;
80138     var members = new Array(elems.length);
80139     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80140       var attrs = elems[i3];
80141       members[i3] = {
80142         id: attrs.type[0] + attrs.ref,
80143         type: attrs.type,
80144         role: attrs.role
80145       };
80146     }
80147     return members;
80148   }
80149   function getVisible(attrs) {
80150     return !attrs.visible || attrs.visible.value !== "false";
80151   }
80152   function parseComments(comments) {
80153     var parsedComments = [];
80154     for (var i3 = 0; i3 < comments.length; i3++) {
80155       var comment = comments[i3];
80156       if (comment.nodeName === "comment") {
80157         var childNodes = comment.childNodes;
80158         var parsedComment = {};
80159         for (var j2 = 0; j2 < childNodes.length; j2++) {
80160           var node = childNodes[j2];
80161           var nodeName = node.nodeName;
80162           if (nodeName === "#text")
80163             continue;
80164           parsedComment[nodeName] = node.textContent;
80165           if (nodeName === "uid") {
80166             var uid = node.textContent;
80167             if (uid && !_userCache.user[uid]) {
80168               _userCache.toLoad[uid] = true;
80169             }
80170           }
80171         }
80172         if (parsedComment) {
80173           parsedComments.push(parsedComment);
80174         }
80175       }
80176     }
80177     return parsedComments;
80178   }
80179   function encodeNoteRtree(note) {
80180     return {
80181       minX: note.loc[0],
80182       minY: note.loc[1],
80183       maxX: note.loc[0],
80184       maxY: note.loc[1],
80185       data: note
80186     };
80187   }
80188   var jsonparsers = {
80189     node: function nodeData(obj, uid) {
80190       return new osmNode({
80191         id: uid,
80192         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80193         version: obj.version && obj.version.toString(),
80194         changeset: obj.changeset && obj.changeset.toString(),
80195         timestamp: obj.timestamp,
80196         user: obj.user,
80197         uid: obj.uid && obj.uid.toString(),
80198         loc: [Number(obj.lon), Number(obj.lat)],
80199         tags: obj.tags
80200       });
80201     },
80202     way: function wayData(obj, uid) {
80203       return new osmWay({
80204         id: uid,
80205         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80206         version: obj.version && obj.version.toString(),
80207         changeset: obj.changeset && obj.changeset.toString(),
80208         timestamp: obj.timestamp,
80209         user: obj.user,
80210         uid: obj.uid && obj.uid.toString(),
80211         tags: obj.tags,
80212         nodes: getNodesJSON(obj)
80213       });
80214     },
80215     relation: function relationData(obj, uid) {
80216       return new osmRelation({
80217         id: uid,
80218         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80219         version: obj.version && obj.version.toString(),
80220         changeset: obj.changeset && obj.changeset.toString(),
80221         timestamp: obj.timestamp,
80222         user: obj.user,
80223         uid: obj.uid && obj.uid.toString(),
80224         tags: obj.tags,
80225         members: getMembersJSON(obj)
80226       });
80227     },
80228     user: function parseUser(obj, uid) {
80229       return {
80230         id: uid,
80231         display_name: obj.display_name,
80232         account_created: obj.account_created,
80233         image_url: obj.img && obj.img.href,
80234         changesets_count: obj.changesets && obj.changesets.count && obj.changesets.count.toString() || "0",
80235         active_blocks: obj.blocks && obj.blocks.received && obj.blocks.received.active && obj.blocks.received.active.toString() || "0"
80236       };
80237     }
80238   };
80239   function parseJSON(payload, callback, options2) {
80240     options2 = Object.assign({ skipSeen: true }, options2);
80241     if (!payload) {
80242       return callback({ message: "No JSON", status: -1 });
80243     }
80244     var json = payload;
80245     if (typeof json !== "object")
80246       json = JSON.parse(payload);
80247     if (!json.elements)
80248       return callback({ message: "No JSON", status: -1 });
80249     var children2 = json.elements;
80250     var handle = window.requestIdleCallback(function() {
80251       _deferred.delete(handle);
80252       var results = [];
80253       var result;
80254       for (var i3 = 0; i3 < children2.length; i3++) {
80255         result = parseChild(children2[i3]);
80256         if (result)
80257           results.push(result);
80258       }
80259       callback(null, results);
80260     });
80261     _deferred.add(handle);
80262     function parseChild(child) {
80263       var parser3 = jsonparsers[child.type];
80264       if (!parser3)
80265         return null;
80266       var uid;
80267       uid = osmEntity.id.fromOSM(child.type, child.id);
80268       if (options2.skipSeen) {
80269         if (_tileCache.seen[uid])
80270           return null;
80271         _tileCache.seen[uid] = true;
80272       }
80273       return parser3(child, uid);
80274     }
80275   }
80276   function parseUserJSON(payload, callback, options2) {
80277     options2 = Object.assign({ skipSeen: true }, options2);
80278     if (!payload) {
80279       return callback({ message: "No JSON", status: -1 });
80280     }
80281     var json = payload;
80282     if (typeof json !== "object")
80283       json = JSON.parse(payload);
80284     if (!json.users && !json.user)
80285       return callback({ message: "No JSON", status: -1 });
80286     var objs = json.users || [json];
80287     var handle = window.requestIdleCallback(function() {
80288       _deferred.delete(handle);
80289       var results = [];
80290       var result;
80291       for (var i3 = 0; i3 < objs.length; i3++) {
80292         result = parseObj(objs[i3]);
80293         if (result)
80294           results.push(result);
80295       }
80296       callback(null, results);
80297     });
80298     _deferred.add(handle);
80299     function parseObj(obj) {
80300       var uid = obj.user.id && obj.user.id.toString();
80301       if (options2.skipSeen && _userCache.user[uid]) {
80302         delete _userCache.toLoad[uid];
80303         return null;
80304       }
80305       var user = jsonparsers.user(obj.user, uid);
80306       _userCache.user[uid] = user;
80307       delete _userCache.toLoad[uid];
80308       return user;
80309     }
80310   }
80311   var parsers = {
80312     node: function nodeData2(obj, uid) {
80313       var attrs = obj.attributes;
80314       return new osmNode({
80315         id: uid,
80316         visible: getVisible(attrs),
80317         version: attrs.version.value,
80318         changeset: attrs.changeset && attrs.changeset.value,
80319         timestamp: attrs.timestamp && attrs.timestamp.value,
80320         user: attrs.user && attrs.user.value,
80321         uid: attrs.uid && attrs.uid.value,
80322         loc: getLoc(attrs),
80323         tags: getTags(obj)
80324       });
80325     },
80326     way: function wayData2(obj, uid) {
80327       var attrs = obj.attributes;
80328       return new osmWay({
80329         id: uid,
80330         visible: getVisible(attrs),
80331         version: attrs.version.value,
80332         changeset: attrs.changeset && attrs.changeset.value,
80333         timestamp: attrs.timestamp && attrs.timestamp.value,
80334         user: attrs.user && attrs.user.value,
80335         uid: attrs.uid && attrs.uid.value,
80336         tags: getTags(obj),
80337         nodes: getNodes(obj)
80338       });
80339     },
80340     relation: function relationData2(obj, uid) {
80341       var attrs = obj.attributes;
80342       return new osmRelation({
80343         id: uid,
80344         visible: getVisible(attrs),
80345         version: attrs.version.value,
80346         changeset: attrs.changeset && attrs.changeset.value,
80347         timestamp: attrs.timestamp && attrs.timestamp.value,
80348         user: attrs.user && attrs.user.value,
80349         uid: attrs.uid && attrs.uid.value,
80350         tags: getTags(obj),
80351         members: getMembers(obj)
80352       });
80353     },
80354     note: function parseNote(obj, uid) {
80355       var attrs = obj.attributes;
80356       var childNodes = obj.childNodes;
80357       var props = {};
80358       props.id = uid;
80359       props.loc = getLoc(attrs);
80360       if (!_noteCache.note[uid]) {
80361         let coincident = false;
80362         const epsilon3 = 1e-5;
80363         do {
80364           if (coincident) {
80365             props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]);
80366           }
80367           const bbox2 = geoExtent(props.loc).bbox();
80368           coincident = _noteCache.rtree.search(bbox2).length;
80369         } while (coincident);
80370       } else {
80371         props.loc = _noteCache.note[uid].loc;
80372       }
80373       for (var i3 = 0; i3 < childNodes.length; i3++) {
80374         var node = childNodes[i3];
80375         var nodeName = node.nodeName;
80376         if (nodeName === "#text")
80377           continue;
80378         if (nodeName === "comments") {
80379           props[nodeName] = parseComments(node.childNodes);
80380         } else {
80381           props[nodeName] = node.textContent;
80382         }
80383       }
80384       var note = new osmNote(props);
80385       var item = encodeNoteRtree(note);
80386       _noteCache.note[note.id] = note;
80387       updateRtree4(item, true);
80388       return note;
80389     },
80390     user: function parseUser2(obj, uid) {
80391       var attrs = obj.attributes;
80392       var user = {
80393         id: uid,
80394         display_name: attrs.display_name && attrs.display_name.value,
80395         account_created: attrs.account_created && attrs.account_created.value,
80396         changesets_count: "0",
80397         active_blocks: "0"
80398       };
80399       var img = obj.getElementsByTagName("img");
80400       if (img && img[0] && img[0].getAttribute("href")) {
80401         user.image_url = img[0].getAttribute("href");
80402       }
80403       var changesets = obj.getElementsByTagName("changesets");
80404       if (changesets && changesets[0] && changesets[0].getAttribute("count")) {
80405         user.changesets_count = changesets[0].getAttribute("count");
80406       }
80407       var blocks = obj.getElementsByTagName("blocks");
80408       if (blocks && blocks[0]) {
80409         var received = blocks[0].getElementsByTagName("received");
80410         if (received && received[0] && received[0].getAttribute("active")) {
80411           user.active_blocks = received[0].getAttribute("active");
80412         }
80413       }
80414       _userCache.user[uid] = user;
80415       delete _userCache.toLoad[uid];
80416       return user;
80417     }
80418   };
80419   function parseXML(xml, callback, options2) {
80420     options2 = Object.assign({ skipSeen: true }, options2);
80421     if (!xml || !xml.childNodes) {
80422       return callback({ message: "No XML", status: -1 });
80423     }
80424     var root3 = xml.childNodes[0];
80425     var children2 = root3.childNodes;
80426     var handle = window.requestIdleCallback(function() {
80427       _deferred.delete(handle);
80428       var results = [];
80429       var result;
80430       for (var i3 = 0; i3 < children2.length; i3++) {
80431         result = parseChild(children2[i3]);
80432         if (result)
80433           results.push(result);
80434       }
80435       callback(null, results);
80436     });
80437     _deferred.add(handle);
80438     function parseChild(child) {
80439       var parser3 = parsers[child.nodeName];
80440       if (!parser3)
80441         return null;
80442       var uid;
80443       if (child.nodeName === "user") {
80444         uid = child.attributes.id.value;
80445         if (options2.skipSeen && _userCache.user[uid]) {
80446           delete _userCache.toLoad[uid];
80447           return null;
80448         }
80449       } else if (child.nodeName === "note") {
80450         uid = child.getElementsByTagName("id")[0].textContent;
80451       } else {
80452         uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value);
80453         if (options2.skipSeen) {
80454           if (_tileCache.seen[uid])
80455             return null;
80456           _tileCache.seen[uid] = true;
80457         }
80458       }
80459       return parser3(child, uid);
80460     }
80461   }
80462   function updateRtree4(item, replace) {
80463     _noteCache.rtree.remove(item, function isEql(a2, b2) {
80464       return a2.data.id === b2.data.id;
80465     });
80466     if (replace) {
80467       _noteCache.rtree.insert(item);
80468     }
80469   }
80470   function wrapcb(thisArg, callback, cid) {
80471     return function(err, result) {
80472       if (err) {
80473         if (err.status === 400 || err.status === 401 || err.status === 403) {
80474           thisArg.logout();
80475         }
80476         return callback.call(thisArg, err);
80477       } else if (thisArg.getConnectionId() !== cid) {
80478         return callback.call(thisArg, { message: "Connection Switched", status: -1 });
80479       } else {
80480         return callback.call(thisArg, err, result);
80481       }
80482     };
80483   }
80484   var osm_default = {
80485     init: function() {
80486       utilRebind(this, dispatch10, "on");
80487     },
80488     reset: function() {
80489       Array.from(_deferred).forEach(function(handle) {
80490         window.cancelIdleCallback(handle);
80491         _deferred.delete(handle);
80492       });
80493       _connectionID++;
80494       _userChangesets = void 0;
80495       _userDetails = void 0;
80496       _rateLimitError = void 0;
80497       Object.values(_tileCache.inflight).forEach(abortRequest5);
80498       Object.values(_noteCache.inflight).forEach(abortRequest5);
80499       Object.values(_noteCache.inflightPost).forEach(abortRequest5);
80500       if (_changeset.inflight)
80501         abortRequest5(_changeset.inflight);
80502       _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80503       _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80504       _userCache = { toLoad: {}, user: {} };
80505       _cachedApiStatus = void 0;
80506       _changeset = {};
80507       return this;
80508     },
80509     getConnectionId: function() {
80510       return _connectionID;
80511     },
80512     getUrlRoot: function() {
80513       return urlroot;
80514     },
80515     getApiUrlRoot: function() {
80516       return apiUrlroot;
80517     },
80518     changesetURL: function(changesetID) {
80519       return urlroot + "/changeset/" + changesetID;
80520     },
80521     changesetsURL: function(center, zoom) {
80522       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
80523       return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
80524     },
80525     entityURL: function(entity) {
80526       return urlroot + "/" + entity.type + "/" + entity.osmId();
80527     },
80528     historyURL: function(entity) {
80529       return urlroot + "/" + entity.type + "/" + entity.osmId() + "/history";
80530     },
80531     userURL: function(username) {
80532       return urlroot + "/user/" + encodeURIComponent(username);
80533     },
80534     noteURL: function(note) {
80535       return urlroot + "/note/" + note.id;
80536     },
80537     noteReportURL: function(note) {
80538       return urlroot + "/reports/new?reportable_type=Note&reportable_id=" + note.id;
80539     },
80540     // Generic method to load data from the OSM API
80541     // Can handle either auth or unauth calls.
80542     loadFromAPI: function(path, callback, options2) {
80543       options2 = Object.assign({ skipSeen: true }, options2);
80544       var that = this;
80545       var cid = _connectionID;
80546       function done(err, payload) {
80547         if (that.getConnectionId() !== cid) {
80548           if (callback)
80549             callback({ message: "Connection Switched", status: -1 });
80550           return;
80551         }
80552         var isAuthenticated = that.authenticated();
80553         if (isAuthenticated && err && err.status && (err.status === 400 || err.status === 401 || err.status === 403)) {
80554           that.logout();
80555           that.loadFromAPI(path, callback, options2);
80556         } else {
80557           if (!isAuthenticated && !_rateLimitError && err && err.status && (err.status === 509 || err.status === 429)) {
80558             _rateLimitError = err;
80559             dispatch10.call("change");
80560             that.reloadApiStatus();
80561           } else if (err && _cachedApiStatus === "online" || !err && _cachedApiStatus !== "online") {
80562             that.reloadApiStatus();
80563           }
80564           if (callback) {
80565             if (err) {
80566               return callback(err);
80567             } else {
80568               if (path.indexOf(".json") !== -1) {
80569                 return parseJSON(payload, callback, options2);
80570               } else {
80571                 return parseXML(payload, callback, options2);
80572               }
80573             }
80574           }
80575         }
80576       }
80577       if (this.authenticated()) {
80578         return oauth.xhr({
80579           method: "GET",
80580           path
80581         }, done);
80582       } else {
80583         var url = apiUrlroot + path;
80584         var controller = new AbortController();
80585         var fn;
80586         if (path.indexOf(".json") !== -1) {
80587           fn = json_default;
80588         } else {
80589           fn = xml_default;
80590         }
80591         fn(url, { signal: controller.signal }).then(function(data) {
80592           done(null, data);
80593         }).catch(function(err) {
80594           if (err.name === "AbortError")
80595             return;
80596           var match = err.message.match(/^\d{3}/);
80597           if (match) {
80598             done({ status: +match[0], statusText: err.message });
80599           } else {
80600             done(err.message);
80601           }
80602         });
80603         return controller;
80604       }
80605     },
80606     // Load a single entity by id (ways and relations use the `/full` call to include
80607     // nodes and members). Parent relations are not included, see `loadEntityRelations`.
80608     // GET /api/0.6/node/#id
80609     // GET /api/0.6/[way|relation]/#id/full
80610     loadEntity: function(id2, callback) {
80611       var type2 = osmEntity.id.type(id2);
80612       var osmID = osmEntity.id.toOSM(id2);
80613       var options2 = { skipSeen: false };
80614       this.loadFromAPI(
80615         "/api/0.6/" + type2 + "/" + osmID + (type2 !== "node" ? "/full" : "") + ".json",
80616         function(err, entities) {
80617           if (callback)
80618             callback(err, { data: entities });
80619         },
80620         options2
80621       );
80622     },
80623     // Load a single note by id , XML format
80624     // GET /api/0.6/notes/#id
80625     loadEntityNote: function(id2, callback) {
80626       var options2 = { skipSeen: false };
80627       this.loadFromAPI(
80628         "/api/0.6/notes/" + id2,
80629         function(err, entities) {
80630           if (callback)
80631             callback(err, { data: entities });
80632         },
80633         options2
80634       );
80635     },
80636     // Load a single entity with a specific version
80637     // GET /api/0.6/[node|way|relation]/#id/#version
80638     loadEntityVersion: function(id2, version, callback) {
80639       var type2 = osmEntity.id.type(id2);
80640       var osmID = osmEntity.id.toOSM(id2);
80641       var options2 = { skipSeen: false };
80642       this.loadFromAPI(
80643         "/api/0.6/" + type2 + "/" + osmID + "/" + version + ".json",
80644         function(err, entities) {
80645           if (callback)
80646             callback(err, { data: entities });
80647         },
80648         options2
80649       );
80650     },
80651     // Load the relations of a single entity with the given.
80652     // GET /api/0.6/[node|way|relation]/#id/relations
80653     loadEntityRelations: function(id2, callback) {
80654       var type2 = osmEntity.id.type(id2);
80655       var osmID = osmEntity.id.toOSM(id2);
80656       var options2 = { skipSeen: false };
80657       this.loadFromAPI(
80658         "/api/0.6/" + type2 + "/" + osmID + "/relations.json",
80659         function(err, entities) {
80660           if (callback)
80661             callback(err, { data: entities });
80662         },
80663         options2
80664       );
80665     },
80666     // Load multiple entities in chunks
80667     // (note: callback may be called multiple times)
80668     // Unlike `loadEntity`, child nodes and members are not fetched
80669     // GET /api/0.6/[nodes|ways|relations]?#parameters
80670     loadMultiple: function(ids, callback) {
80671       var that = this;
80672       var groups = utilArrayGroupBy(utilArrayUniq(ids), osmEntity.id.type);
80673       Object.keys(groups).forEach(function(k2) {
80674         var type2 = k2 + "s";
80675         var osmIDs = groups[k2].map(function(id2) {
80676           return osmEntity.id.toOSM(id2);
80677         });
80678         var options2 = { skipSeen: false };
80679         utilArrayChunk(osmIDs, 150).forEach(function(arr) {
80680           that.loadFromAPI(
80681             "/api/0.6/" + type2 + ".json?" + type2 + "=" + arr.join(),
80682             function(err, entities) {
80683               if (callback)
80684                 callback(err, { data: entities });
80685             },
80686             options2
80687           );
80688         });
80689       });
80690     },
80691     // Create, upload, and close a changeset
80692     // PUT /api/0.6/changeset/create
80693     // POST /api/0.6/changeset/#id/upload
80694     // PUT /api/0.6/changeset/#id/close
80695     putChangeset: function(changeset, changes, callback) {
80696       var cid = _connectionID;
80697       if (_changeset.inflight) {
80698         return callback({ message: "Changeset already inflight", status: -2 }, changeset);
80699       } else if (_changeset.open) {
80700         return createdChangeset.call(this, null, _changeset.open);
80701       } else {
80702         var options2 = {
80703           method: "PUT",
80704           path: "/api/0.6/changeset/create",
80705           headers: { "Content-Type": "text/xml" },
80706           content: JXON.stringify(changeset.asJXON())
80707         };
80708         _changeset.inflight = oauth.xhr(
80709           options2,
80710           wrapcb(this, createdChangeset, cid)
80711         );
80712       }
80713       function createdChangeset(err, changesetID) {
80714         _changeset.inflight = null;
80715         if (err) {
80716           return callback(err, changeset);
80717         }
80718         _changeset.open = changesetID;
80719         changeset = changeset.update({ id: changesetID });
80720         var options3 = {
80721           method: "POST",
80722           path: "/api/0.6/changeset/" + changesetID + "/upload",
80723           headers: { "Content-Type": "text/xml" },
80724           content: JXON.stringify(changeset.osmChangeJXON(changes))
80725         };
80726         _changeset.inflight = oauth.xhr(
80727           options3,
80728           wrapcb(this, uploadedChangeset, cid)
80729         );
80730       }
80731       function uploadedChangeset(err) {
80732         _changeset.inflight = null;
80733         if (err)
80734           return callback(err, changeset);
80735         window.setTimeout(function() {
80736           callback(null, changeset);
80737         }, 2500);
80738         _changeset.open = null;
80739         if (this.getConnectionId() === cid) {
80740           oauth.xhr({
80741             method: "PUT",
80742             path: "/api/0.6/changeset/" + changeset.id + "/close",
80743             headers: { "Content-Type": "text/xml" }
80744           }, function() {
80745             return true;
80746           });
80747         }
80748       }
80749     },
80750     // Load multiple users in chunks
80751     // (note: callback may be called multiple times)
80752     // GET /api/0.6/users?users=#id1,#id2,...,#idn
80753     loadUsers: function(uids, callback) {
80754       var toLoad = [];
80755       var cached = [];
80756       utilArrayUniq(uids).forEach(function(uid) {
80757         if (_userCache.user[uid]) {
80758           delete _userCache.toLoad[uid];
80759           cached.push(_userCache.user[uid]);
80760         } else {
80761           toLoad.push(uid);
80762         }
80763       });
80764       if (cached.length || !this.authenticated()) {
80765         callback(void 0, cached);
80766         if (!this.authenticated())
80767           return;
80768       }
80769       utilArrayChunk(toLoad, 150).forEach((function(arr) {
80770         oauth.xhr({
80771           method: "GET",
80772           path: "/api/0.6/users.json?users=" + arr.join()
80773         }, wrapcb(this, done, _connectionID));
80774       }).bind(this));
80775       function done(err, payload) {
80776         if (err)
80777           return callback(err);
80778         var options2 = { skipSeen: true };
80779         return parseUserJSON(payload, function(err2, results) {
80780           if (err2)
80781             return callback(err2);
80782           return callback(void 0, results);
80783         }, options2);
80784       }
80785     },
80786     // Load a given user by id
80787     // GET /api/0.6/user/#id
80788     loadUser: function(uid, callback) {
80789       if (_userCache.user[uid] || !this.authenticated()) {
80790         delete _userCache.toLoad[uid];
80791         return callback(void 0, _userCache.user[uid]);
80792       }
80793       oauth.xhr({
80794         method: "GET",
80795         path: "/api/0.6/user/" + uid + ".json"
80796       }, wrapcb(this, done, _connectionID));
80797       function done(err, payload) {
80798         if (err)
80799           return callback(err);
80800         var options2 = { skipSeen: true };
80801         return parseUserJSON(payload, function(err2, results) {
80802           if (err2)
80803             return callback(err2);
80804           return callback(void 0, results[0]);
80805         }, options2);
80806       }
80807     },
80808     // Load the details of the logged-in user
80809     // GET /api/0.6/user/details
80810     userDetails: function(callback) {
80811       if (_userDetails) {
80812         return callback(void 0, _userDetails);
80813       }
80814       oauth.xhr({
80815         method: "GET",
80816         path: "/api/0.6/user/details.json"
80817       }, wrapcb(this, done, _connectionID));
80818       function done(err, payload) {
80819         if (err)
80820           return callback(err);
80821         var options2 = { skipSeen: false };
80822         return parseUserJSON(payload, function(err2, results) {
80823           if (err2)
80824             return callback(err2);
80825           _userDetails = results[0];
80826           return callback(void 0, _userDetails);
80827         }, options2);
80828       }
80829     },
80830     // Load previous changesets for the logged in user
80831     // GET /api/0.6/changesets?user=#id
80832     userChangesets: function(callback) {
80833       if (_userChangesets) {
80834         return callback(void 0, _userChangesets);
80835       }
80836       this.userDetails(
80837         wrapcb(this, gotDetails, _connectionID)
80838       );
80839       function gotDetails(err, user) {
80840         if (err) {
80841           return callback(err);
80842         }
80843         oauth.xhr({
80844           method: "GET",
80845           path: "/api/0.6/changesets?user=" + user.id
80846         }, wrapcb(this, done, _connectionID));
80847       }
80848       function done(err, xml) {
80849         if (err) {
80850           return callback(err);
80851         }
80852         _userChangesets = Array.prototype.map.call(
80853           xml.getElementsByTagName("changeset"),
80854           function(changeset) {
80855             return { tags: getTags(changeset) };
80856           }
80857         ).filter(function(changeset) {
80858           var comment = changeset.tags.comment;
80859           return comment && comment !== "";
80860         });
80861         return callback(void 0, _userChangesets);
80862       }
80863     },
80864     // Fetch the status of the OSM API
80865     // GET /api/capabilities
80866     status: function(callback) {
80867       var url = apiUrlroot + "/api/capabilities";
80868       var errback = wrapcb(this, done, _connectionID);
80869       xml_default(url).then(function(data) {
80870         errback(null, data);
80871       }).catch(function(err) {
80872         errback(err.message);
80873       });
80874       function done(err, xml) {
80875         if (err) {
80876           return callback(err, null);
80877         }
80878         var elements = xml.getElementsByTagName("blacklist");
80879         var regexes = [];
80880         for (var i3 = 0; i3 < elements.length; i3++) {
80881           var regexString = elements[i3].getAttribute("regex");
80882           if (regexString) {
80883             try {
80884               var regex = new RegExp(regexString);
80885               regexes.push(regex);
80886             } catch {
80887             }
80888           }
80889         }
80890         if (regexes.length) {
80891           _imageryBlocklists = regexes;
80892         }
80893         if (_rateLimitError) {
80894           return callback(_rateLimitError, "rateLimited");
80895         } else {
80896           var waynodes = xml.getElementsByTagName("waynodes");
80897           var maxWayNodes = waynodes.length && parseInt(waynodes[0].getAttribute("maximum"), 10);
80898           if (maxWayNodes && isFinite(maxWayNodes))
80899             _maxWayNodes = maxWayNodes;
80900           var apiStatus = xml.getElementsByTagName("status");
80901           var val = apiStatus[0].getAttribute("api");
80902           return callback(void 0, val);
80903         }
80904       }
80905     },
80906     // Calls `status` and dispatches an `apiStatusChange` event if the returned
80907     // status differs from the cached status.
80908     reloadApiStatus: function() {
80909       if (!this.throttledReloadApiStatus) {
80910         var that = this;
80911         this.throttledReloadApiStatus = throttle_default(function() {
80912           that.status(function(err, status) {
80913             if (status !== _cachedApiStatus) {
80914               _cachedApiStatus = status;
80915               dispatch10.call("apiStatusChange", that, err, status);
80916             }
80917           });
80918         }, 500);
80919       }
80920       this.throttledReloadApiStatus();
80921     },
80922     // Returns the maximum number of nodes a single way can have
80923     maxWayNodes: function() {
80924       return _maxWayNodes;
80925     },
80926     // Load data (entities) from the API in tiles
80927     // GET /api/0.6/map?bbox=
80928     loadTiles: function(projection2, callback) {
80929       if (_off)
80930         return;
80931       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
80932       var hadRequests = hasInflightRequests(_tileCache);
80933       abortUnwantedRequests4(_tileCache, tiles);
80934       if (hadRequests && !hasInflightRequests(_tileCache)) {
80935         dispatch10.call("loaded");
80936       }
80937       tiles.forEach(function(tile) {
80938         this.loadTile(tile, callback);
80939       }, this);
80940     },
80941     // Load a single data tile
80942     // GET /api/0.6/map?bbox=
80943     loadTile: function(tile, callback) {
80944       if (_off)
80945         return;
80946       if (_tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
80947         return;
80948       if (!hasInflightRequests(_tileCache)) {
80949         dispatch10.call("loading");
80950       }
80951       var path = "/api/0.6/map.json?bbox=";
80952       var options2 = { skipSeen: true };
80953       _tileCache.inflight[tile.id] = this.loadFromAPI(
80954         path + tile.extent.toParam(),
80955         tileCallback,
80956         options2
80957       );
80958       function tileCallback(err, parsed) {
80959         delete _tileCache.inflight[tile.id];
80960         if (!err) {
80961           delete _tileCache.toLoad[tile.id];
80962           _tileCache.loaded[tile.id] = true;
80963           var bbox2 = tile.extent.bbox();
80964           bbox2.id = tile.id;
80965           _tileCache.rtree.insert(bbox2);
80966         }
80967         if (callback) {
80968           callback(err, Object.assign({ data: parsed }, tile));
80969         }
80970         if (!hasInflightRequests(_tileCache)) {
80971           dispatch10.call("loaded");
80972         }
80973       }
80974     },
80975     isDataLoaded: function(loc) {
80976       var bbox2 = { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] };
80977       return _tileCache.rtree.collides(bbox2);
80978     },
80979     // load the tile that covers the given `loc`
80980     loadTileAtLoc: function(loc, callback) {
80981       if (Object.keys(_tileCache.toLoad).length > 50)
80982         return;
80983       var k2 = geoZoomToScale(_tileZoom4 + 1);
80984       var offset = geoRawMercator().scale(k2)(loc);
80985       var projection2 = geoRawMercator().transform({ k: k2, x: -offset[0], y: -offset[1] });
80986       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
80987       tiles.forEach(function(tile) {
80988         if (_tileCache.toLoad[tile.id] || _tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
80989           return;
80990         _tileCache.toLoad[tile.id] = true;
80991         this.loadTile(tile, callback);
80992       }, this);
80993     },
80994     // Load notes from the API in tiles
80995     // GET /api/0.6/notes?bbox=
80996     loadNotes: function(projection2, noteOptions) {
80997       noteOptions = Object.assign({ limit: 1e4, closed: 7 }, noteOptions);
80998       if (_off)
80999         return;
81000       var that = this;
81001       var path = "/api/0.6/notes?limit=" + noteOptions.limit + "&closed=" + noteOptions.closed + "&bbox=";
81002       var throttleLoadUsers = throttle_default(function() {
81003         var uids = Object.keys(_userCache.toLoad);
81004         if (!uids.length)
81005           return;
81006         that.loadUsers(uids, function() {
81007         });
81008       }, 750);
81009       var tiles = tiler6.zoomExtent([_noteZoom, _noteZoom]).getTiles(projection2);
81010       abortUnwantedRequests4(_noteCache, tiles);
81011       tiles.forEach(function(tile) {
81012         if (_noteCache.loaded[tile.id] || _noteCache.inflight[tile.id])
81013           return;
81014         var options2 = { skipSeen: false };
81015         _noteCache.inflight[tile.id] = that.loadFromAPI(
81016           path + tile.extent.toParam(),
81017           function(err) {
81018             delete _noteCache.inflight[tile.id];
81019             if (!err) {
81020               _noteCache.loaded[tile.id] = true;
81021             }
81022             throttleLoadUsers();
81023             dispatch10.call("loadedNotes");
81024           },
81025           options2
81026         );
81027       });
81028     },
81029     // Create a note
81030     // POST /api/0.6/notes?params
81031     postNoteCreate: function(note, callback) {
81032       if (!this.authenticated()) {
81033         return callback({ message: "Not Authenticated", status: -3 }, note);
81034       }
81035       if (_noteCache.inflightPost[note.id]) {
81036         return callback({ message: "Note update already inflight", status: -2 }, note);
81037       }
81038       if (!note.loc[0] || !note.loc[1] || !note.newComment)
81039         return;
81040       var comment = note.newComment;
81041       if (note.newCategory && note.newCategory !== "None") {
81042         comment += " #" + note.newCategory;
81043       }
81044       var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment });
81045       _noteCache.inflightPost[note.id] = oauth.xhr({
81046         method: "POST",
81047         path
81048       }, wrapcb(this, done, _connectionID));
81049       function done(err, xml) {
81050         delete _noteCache.inflightPost[note.id];
81051         if (err) {
81052           return callback(err);
81053         }
81054         this.removeNote(note);
81055         var options2 = { skipSeen: false };
81056         return parseXML(xml, function(err2, results) {
81057           if (err2) {
81058             return callback(err2);
81059           } else {
81060             return callback(void 0, results[0]);
81061           }
81062         }, options2);
81063       }
81064     },
81065     // Update a note
81066     // POST /api/0.6/notes/#id/comment?text=comment
81067     // POST /api/0.6/notes/#id/close?text=comment
81068     // POST /api/0.6/notes/#id/reopen?text=comment
81069     postNoteUpdate: function(note, newStatus, callback) {
81070       if (!this.authenticated()) {
81071         return callback({ message: "Not Authenticated", status: -3 }, note);
81072       }
81073       if (_noteCache.inflightPost[note.id]) {
81074         return callback({ message: "Note update already inflight", status: -2 }, note);
81075       }
81076       var action;
81077       if (note.status !== "closed" && newStatus === "closed") {
81078         action = "close";
81079       } else if (note.status !== "open" && newStatus === "open") {
81080         action = "reopen";
81081       } else {
81082         action = "comment";
81083         if (!note.newComment)
81084           return;
81085       }
81086       var path = "/api/0.6/notes/" + note.id + "/" + action;
81087       if (note.newComment) {
81088         path += "?" + utilQsString({ text: note.newComment });
81089       }
81090       _noteCache.inflightPost[note.id] = oauth.xhr({
81091         method: "POST",
81092         path
81093       }, wrapcb(this, done, _connectionID));
81094       function done(err, xml) {
81095         delete _noteCache.inflightPost[note.id];
81096         if (err) {
81097           return callback(err);
81098         }
81099         this.removeNote(note);
81100         if (action === "close") {
81101           _noteCache.closed[note.id] = true;
81102         } else if (action === "reopen") {
81103           delete _noteCache.closed[note.id];
81104         }
81105         var options2 = { skipSeen: false };
81106         return parseXML(xml, function(err2, results) {
81107           if (err2) {
81108             return callback(err2);
81109           } else {
81110             return callback(void 0, results[0]);
81111           }
81112         }, options2);
81113       }
81114     },
81115     /* connection options for source switcher (optional) */
81116     apiConnections: function(val) {
81117       if (!arguments.length)
81118         return _apiConnections;
81119       _apiConnections = val;
81120       return this;
81121     },
81122     switch: function(newOptions) {
81123       urlroot = newOptions.url;
81124       apiUrlroot = newOptions.apiUrl || urlroot;
81125       if (newOptions.url && !newOptions.apiUrl) {
81126         newOptions = {
81127           ...newOptions,
81128           apiUrl: newOptions.url
81129         };
81130       }
81131       const oldOptions = utilObjectOmit(oauth.options(), "access_token");
81132       oauth.options({ ...oldOptions, ...newOptions });
81133       this.reset();
81134       this.userChangesets(function() {
81135       });
81136       dispatch10.call("change");
81137       return this;
81138     },
81139     toggle: function(val) {
81140       _off = !val;
81141       return this;
81142     },
81143     isChangesetInflight: function() {
81144       return !!_changeset.inflight;
81145     },
81146     // get/set cached data
81147     // This is used to save/restore the state when entering/exiting the walkthrough
81148     // Also used for testing purposes.
81149     caches: function(obj) {
81150       function cloneCache(source) {
81151         var target = {};
81152         Object.keys(source).forEach(function(k2) {
81153           if (k2 === "rtree") {
81154             target.rtree = new import_rbush10.default().fromJSON(source.rtree.toJSON());
81155           } else if (k2 === "note") {
81156             target.note = {};
81157             Object.keys(source.note).forEach(function(id2) {
81158               target.note[id2] = osmNote(source.note[id2]);
81159             });
81160           } else {
81161             target[k2] = JSON.parse(JSON.stringify(source[k2]));
81162           }
81163         });
81164         return target;
81165       }
81166       if (!arguments.length) {
81167         return {
81168           tile: cloneCache(_tileCache),
81169           note: cloneCache(_noteCache),
81170           user: cloneCache(_userCache)
81171         };
81172       }
81173       if (obj === "get") {
81174         return {
81175           tile: _tileCache,
81176           note: _noteCache,
81177           user: _userCache
81178         };
81179       }
81180       if (obj.tile) {
81181         _tileCache = obj.tile;
81182         _tileCache.inflight = {};
81183       }
81184       if (obj.note) {
81185         _noteCache = obj.note;
81186         _noteCache.inflight = {};
81187         _noteCache.inflightPost = {};
81188       }
81189       if (obj.user) {
81190         _userCache = obj.user;
81191       }
81192       return this;
81193     },
81194     logout: function() {
81195       _userChangesets = void 0;
81196       _userDetails = void 0;
81197       oauth.logout();
81198       dispatch10.call("change");
81199       return this;
81200     },
81201     authenticated: function() {
81202       return oauth.authenticated();
81203     },
81204     authenticate: function(callback) {
81205       var that = this;
81206       var cid = _connectionID;
81207       _userChangesets = void 0;
81208       _userDetails = void 0;
81209       function done(err, res) {
81210         if (err) {
81211           if (callback)
81212             callback(err);
81213           return;
81214         }
81215         if (that.getConnectionId() !== cid) {
81216           if (callback)
81217             callback({ message: "Connection Switched", status: -1 });
81218           return;
81219         }
81220         _rateLimitError = void 0;
81221         dispatch10.call("change");
81222         if (callback)
81223           callback(err, res);
81224         that.userChangesets(function() {
81225         });
81226       }
81227       oauth.authenticate(done);
81228     },
81229     imageryBlocklists: function() {
81230       return _imageryBlocklists;
81231     },
81232     tileZoom: function(val) {
81233       if (!arguments.length)
81234         return _tileZoom4;
81235       _tileZoom4 = val;
81236       return this;
81237     },
81238     // get all cached notes covering the viewport
81239     notes: function(projection2) {
81240       var viewport = projection2.clipExtent();
81241       var min3 = [viewport[0][0], viewport[1][1]];
81242       var max3 = [viewport[1][0], viewport[0][1]];
81243       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81244       return _noteCache.rtree.search(bbox2).map(function(d2) {
81245         return d2.data;
81246       });
81247     },
81248     // get a single note from the cache
81249     getNote: function(id2) {
81250       return _noteCache.note[id2];
81251     },
81252     // remove a single note from the cache
81253     removeNote: function(note) {
81254       if (!(note instanceof osmNote) || !note.id)
81255         return;
81256       delete _noteCache.note[note.id];
81257       updateRtree4(encodeNoteRtree(note), false);
81258     },
81259     // replace a single note in the cache
81260     replaceNote: function(note) {
81261       if (!(note instanceof osmNote) || !note.id)
81262         return;
81263       _noteCache.note[note.id] = note;
81264       updateRtree4(encodeNoteRtree(note), true);
81265       return note;
81266     },
81267     // Get an array of note IDs closed during this session.
81268     // Used to populate `closed:note` changeset tag
81269     getClosedIDs: function() {
81270       return Object.keys(_noteCache.closed).sort();
81271     }
81272   };
81273
81274   // modules/services/osm_wikibase.js
81275   var apibase3 = "https://wiki.openstreetmap.org/w/api.php";
81276   var _inflight2 = {};
81277   var _wikibaseCache = {};
81278   var _localeIDs = { en: false };
81279   var debouncedRequest = debounce_default(request, 500, { leading: false });
81280   function request(url, callback) {
81281     if (_inflight2[url])
81282       return;
81283     var controller = new AbortController();
81284     _inflight2[url] = controller;
81285     json_default(url, { signal: controller.signal }).then(function(result) {
81286       delete _inflight2[url];
81287       if (callback)
81288         callback(null, result);
81289     }).catch(function(err) {
81290       delete _inflight2[url];
81291       if (err.name === "AbortError")
81292         return;
81293       if (callback)
81294         callback(err.message);
81295     });
81296   }
81297   var osm_wikibase_default = {
81298     init: function() {
81299       _inflight2 = {};
81300       _wikibaseCache = {};
81301       _localeIDs = {};
81302     },
81303     reset: function() {
81304       Object.values(_inflight2).forEach(function(controller) {
81305         controller.abort();
81306       });
81307       _inflight2 = {};
81308     },
81309     /**
81310      * Get the best value for the property, or undefined if not found
81311      * @param entity object from wikibase
81312      * @param property string e.g. 'P4' for image
81313      * @param langCode string e.g. 'fr' for French
81314      */
81315     claimToValue: function(entity, property, langCode) {
81316       if (!entity.claims[property])
81317         return void 0;
81318       var locale2 = _localeIDs[langCode];
81319       var preferredPick, localePick;
81320       entity.claims[property].forEach(function(stmt) {
81321         if (!preferredPick && stmt.rank === "preferred") {
81322           preferredPick = stmt;
81323         }
81324         if (locale2 && stmt.qualifiers && stmt.qualifiers.P26 && stmt.qualifiers.P26[0].datavalue.value.id === locale2) {
81325           localePick = stmt;
81326         }
81327       });
81328       var result = localePick || preferredPick;
81329       if (result) {
81330         var datavalue = result.mainsnak.datavalue;
81331         return datavalue.type === "wikibase-entityid" ? datavalue.value.id : datavalue.value;
81332       } else {
81333         return void 0;
81334       }
81335     },
81336     /**
81337      * Convert monolingual property into a key-value object (language -> value)
81338      * @param entity object from wikibase
81339      * @param property string e.g. 'P31' for monolingual wiki page title
81340      */
81341     monolingualClaimToValueObj: function(entity, property) {
81342       if (!entity || !entity.claims[property])
81343         return void 0;
81344       return entity.claims[property].reduce(function(acc, obj) {
81345         var value = obj.mainsnak.datavalue.value;
81346         acc[value.language] = value.text;
81347         return acc;
81348       }, {});
81349     },
81350     toSitelink: function(key, value) {
81351       var result = value ? "Tag:" + key + "=" + value : "Key:" + key;
81352       return result.replace(/_/g, " ").trim();
81353     },
81354     //
81355     // Pass params object of the form:
81356     // {
81357     //   key: 'string',
81358     //   value: 'string',
81359     //   langCode: 'string'
81360     // }
81361     //
81362     getEntity: function(params, callback) {
81363       var doRequest = params.debounce ? debouncedRequest : request;
81364       var that = this;
81365       var titles = [];
81366       var result = {};
81367       var rtypeSitelink = params.key === "type" && params.value ? ("Relation:" + params.value).replace(/_/g, " ").trim() : false;
81368       var keySitelink = params.key ? this.toSitelink(params.key) : false;
81369       var tagSitelink = params.key && params.value ? this.toSitelink(params.key, params.value) : false;
81370       var localeSitelink;
81371       if (params.langCodes) {
81372         params.langCodes.forEach(function(langCode) {
81373           if (_localeIDs[langCode] === void 0) {
81374             localeSitelink = ("Locale:" + langCode).replace(/_/g, " ").trim();
81375             titles.push(localeSitelink);
81376           }
81377         });
81378       }
81379       if (rtypeSitelink) {
81380         if (_wikibaseCache[rtypeSitelink]) {
81381           result.rtype = _wikibaseCache[rtypeSitelink];
81382         } else {
81383           titles.push(rtypeSitelink);
81384         }
81385       }
81386       if (keySitelink) {
81387         if (_wikibaseCache[keySitelink]) {
81388           result.key = _wikibaseCache[keySitelink];
81389         } else {
81390           titles.push(keySitelink);
81391         }
81392       }
81393       if (tagSitelink) {
81394         if (_wikibaseCache[tagSitelink]) {
81395           result.tag = _wikibaseCache[tagSitelink];
81396         } else {
81397           titles.push(tagSitelink);
81398         }
81399       }
81400       if (!titles.length) {
81401         return callback(null, result);
81402       }
81403       var obj = {
81404         action: "wbgetentities",
81405         sites: "wiki",
81406         titles: titles.join("|"),
81407         languages: params.langCodes.join("|"),
81408         languagefallback: 1,
81409         origin: "*",
81410         format: "json"
81411         // There is an MW Wikibase API bug https://phabricator.wikimedia.org/T212069
81412         // We shouldn't use v1 until it gets fixed, but should switch to it afterwards
81413         // formatversion: 2,
81414       };
81415       var url = apibase3 + "?" + utilQsString(obj);
81416       doRequest(url, function(err, d2) {
81417         if (err) {
81418           callback(err);
81419         } else if (!d2.success || d2.error) {
81420           callback(d2.error.messages.map(function(v2) {
81421             return v2.html["*"];
81422           }).join("<br>"));
81423         } else {
81424           var localeID = false;
81425           Object.values(d2.entities).forEach(function(res) {
81426             if (res.missing !== "") {
81427               var title = res.sitelinks.wiki.title;
81428               if (title === rtypeSitelink) {
81429                 _wikibaseCache[rtypeSitelink] = res;
81430                 result.rtype = res;
81431               } else if (title === keySitelink) {
81432                 _wikibaseCache[keySitelink] = res;
81433                 result.key = res;
81434               } else if (title === tagSitelink) {
81435                 _wikibaseCache[tagSitelink] = res;
81436                 result.tag = res;
81437               } else if (title === localeSitelink) {
81438                 localeID = res.id;
81439               } else {
81440                 console.log("Unexpected title " + title);
81441               }
81442             }
81443           });
81444           if (localeSitelink) {
81445             that.addLocale(params.langCodes[0], localeID);
81446           }
81447           callback(null, result);
81448         }
81449       });
81450     },
81451     //
81452     // Pass params object of the form:
81453     // {
81454     //   key: 'string',     // required
81455     //   value: 'string'    // optional
81456     // }
81457     //
81458     // Get an result object used to display tag documentation
81459     // {
81460     //   title:        'string',
81461     //   description:  'string',
81462     //   editURL:      'string',
81463     //   imageURL:     'string',
81464     //   wiki:         { title: 'string', text: 'string', url: 'string' }
81465     // }
81466     //
81467     getDocs: function(params, callback) {
81468       var that = this;
81469       var langCodes = _mainLocalizer.localeCodes().map(function(code) {
81470         return code.toLowerCase();
81471       });
81472       params.langCodes = langCodes;
81473       this.getEntity(params, function(err, data) {
81474         if (err) {
81475           callback(err);
81476           return;
81477         }
81478         var entity = data.rtype || data.tag || data.key;
81479         if (!entity) {
81480           callback("No entity");
81481           return;
81482         }
81483         var i3;
81484         var description;
81485         for (i3 in langCodes) {
81486           let code2 = langCodes[i3];
81487           if (entity.descriptions[code2] && entity.descriptions[code2].language === code2) {
81488             description = entity.descriptions[code2];
81489             break;
81490           }
81491         }
81492         if (!description && Object.values(entity.descriptions).length)
81493           description = Object.values(entity.descriptions)[0];
81494         var result = {
81495           title: entity.title,
81496           description: description ? description.value : "",
81497           descriptionLocaleCode: description ? description.language : "",
81498           editURL: "https://wiki.openstreetmap.org/wiki/" + entity.title
81499         };
81500         if (entity.claims) {
81501           var imageroot;
81502           var image = that.claimToValue(entity, "P4", langCodes[0]);
81503           if (image) {
81504             imageroot = "https://commons.wikimedia.org/w/index.php";
81505           } else {
81506             image = that.claimToValue(entity, "P28", langCodes[0]);
81507             if (image) {
81508               imageroot = "https://wiki.openstreetmap.org/w/index.php";
81509             }
81510           }
81511           if (imageroot && image) {
81512             result.imageURL = imageroot + "?" + utilQsString({
81513               title: "Special:Redirect/file/" + image,
81514               width: 400
81515             });
81516           }
81517         }
81518         var rtypeWiki = that.monolingualClaimToValueObj(data.rtype, "P31");
81519         var tagWiki = that.monolingualClaimToValueObj(data.tag, "P31");
81520         var keyWiki = that.monolingualClaimToValueObj(data.key, "P31");
81521         var wikis = [rtypeWiki, tagWiki, keyWiki];
81522         for (i3 in wikis) {
81523           var wiki = wikis[i3];
81524           for (var j2 in langCodes) {
81525             var code = langCodes[j2];
81526             var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference";
81527             var info = getWikiInfo(wiki, code, referenceId);
81528             if (info) {
81529               result.wiki = info;
81530               break;
81531             }
81532           }
81533           if (result.wiki)
81534             break;
81535         }
81536         callback(null, result);
81537         function getWikiInfo(wiki2, langCode, tKey) {
81538           if (wiki2 && wiki2[langCode]) {
81539             return {
81540               title: wiki2[langCode],
81541               text: tKey,
81542               url: "https://wiki.openstreetmap.org/wiki/" + wiki2[langCode]
81543             };
81544           }
81545         }
81546       });
81547     },
81548     addLocale: function(langCode, qid) {
81549       _localeIDs[langCode] = qid;
81550     },
81551     apibase: function(val) {
81552       if (!arguments.length)
81553         return apibase3;
81554       apibase3 = val;
81555       return this;
81556     }
81557   };
81558
81559   // modules/services/streetside.js
81560   var import_rbush11 = __toESM(require_rbush_min());
81561   var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}";
81562   var maxResults2 = 500;
81563   var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
81564   var pannellumViewerCSS2 = "pannellum/pannellum.css";
81565   var pannellumViewerJS2 = "pannellum/pannellum.js";
81566   var tileZoom3 = 16.5;
81567   var tiler7 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true);
81568   var dispatch11 = dispatch_default("loadedImages", "viewerChanged");
81569   var minHfov = 10;
81570   var maxHfov = 90;
81571   var defaultHfov = 45;
81572   var _hires = false;
81573   var _resolution = 512;
81574   var _currScene = 0;
81575   var _ssCache;
81576   var _pannellumViewer2;
81577   var _sceneOptions = {
81578     showFullscreenCtrl: false,
81579     autoLoad: true,
81580     compass: true,
81581     yaw: 0,
81582     minHfov,
81583     maxHfov,
81584     hfov: defaultHfov,
81585     type: "cubemap",
81586     cubeMap: []
81587   };
81588   var _loadViewerPromise4;
81589   function abortRequest6(i3) {
81590     i3.abort();
81591   }
81592   function localeTimestamp2(s2) {
81593     if (!s2)
81594       return null;
81595     const options2 = { day: "numeric", month: "short", year: "numeric" };
81596     const d2 = new Date(s2);
81597     if (isNaN(d2.getTime()))
81598       return null;
81599     return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
81600   }
81601   function loadTiles3(which, url, projection2, margin) {
81602     const tiles = tiler7.margin(margin).getTiles(projection2);
81603     const cache = _ssCache[which];
81604     Object.keys(cache.inflight).forEach((k2) => {
81605       const wanted = tiles.find((tile) => k2.indexOf(tile.id + ",") === 0);
81606       if (!wanted) {
81607         abortRequest6(cache.inflight[k2]);
81608         delete cache.inflight[k2];
81609       }
81610     });
81611     tiles.forEach((tile) => loadNextTilePage2(which, url, tile));
81612   }
81613   function loadNextTilePage2(which, url, tile) {
81614     const cache = _ssCache[which];
81615     const nextPage = cache.nextPage[tile.id] || 0;
81616     const id2 = tile.id + "," + String(nextPage);
81617     if (cache.loaded[id2] || cache.inflight[id2])
81618       return;
81619     cache.inflight[id2] = getBubbles(url, tile, (response) => {
81620       cache.loaded[id2] = true;
81621       delete cache.inflight[id2];
81622       if (!response)
81623         return;
81624       if (response.resourceSets[0].resources.length === maxResults2) {
81625         const split = tile.extent.split();
81626         loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] });
81627         loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] });
81628         loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] });
81629         loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] });
81630       }
81631       const features = response.resourceSets[0].resources.map((bubble) => {
81632         const bubbleId = bubble.imageUrl;
81633         if (cache.points[bubbleId])
81634           return null;
81635         const loc = [bubble.lon, bubble.lat];
81636         const d2 = {
81637           loc,
81638           key: bubbleId,
81639           imageUrl: bubble.imageUrl.replace(
81640             "{subdomain}",
81641             bubble.imageUrlSubdomains[0]
81642           ),
81643           ca: bubble.he,
81644           captured_at: bubble.vintageEnd,
81645           captured_by: "microsoft",
81646           pano: true,
81647           sequenceKey: null
81648         };
81649         cache.points[bubbleId] = d2;
81650         return {
81651           minX: loc[0],
81652           minY: loc[1],
81653           maxX: loc[0],
81654           maxY: loc[1],
81655           data: d2
81656         };
81657       }).filter(Boolean);
81658       cache.rtree.load(features);
81659       if (which === "bubbles") {
81660         dispatch11.call("loadedImages");
81661       }
81662     });
81663   }
81664   function getBubbles(url, tile, callback) {
81665     let rect = tile.extent.rectangle();
81666     let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2);
81667     const controller = new AbortController();
81668     fetch(urlForRequest, { signal: controller.signal }).then(function(response) {
81669       if (!response.ok) {
81670         throw new Error(response.status + " " + response.statusText);
81671       }
81672       return response.json();
81673     }).then(function(result) {
81674       if (!result) {
81675         callback(null);
81676       }
81677       return callback(result || []);
81678     }).catch(function(err) {
81679       if (err.name === "AbortError") {
81680       } else {
81681         throw new Error(err);
81682       }
81683     });
81684     return controller;
81685   }
81686   function partitionViewport4(projection2) {
81687     let z2 = geoScaleToZoom(projection2.scale());
81688     let z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81689     let tiler9 = utilTiler().zoomExtent([z22, z22]);
81690     return tiler9.getTiles(projection2).map((tile) => tile.extent);
81691   }
81692   function searchLimited4(limit, projection2, rtree) {
81693     limit = limit || 5;
81694     return partitionViewport4(projection2).reduce((result, extent) => {
81695       let found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
81696       return found.length ? result.concat(found) : result;
81697     }, []);
81698   }
81699   function loadImage2(imgInfo) {
81700     return new Promise((resolve) => {
81701       let img = new Image();
81702       img.onload = () => {
81703         let canvas = document.getElementById("ideditor-canvas" + imgInfo.face);
81704         let ctx = canvas.getContext("2d");
81705         ctx.drawImage(img, imgInfo.x, imgInfo.y);
81706         resolve({ imgInfo, status: "ok" });
81707       };
81708       img.onerror = () => {
81709         resolve({ data: imgInfo, status: "error" });
81710       };
81711       img.setAttribute("crossorigin", "");
81712       img.src = imgInfo.url;
81713     });
81714   }
81715   function loadCanvas(imageGroup) {
81716     return Promise.all(imageGroup.map(loadImage2)).then((data) => {
81717       let canvas = document.getElementById("ideditor-canvas" + data[0].imgInfo.face);
81718       const which = { "01": 0, "02": 1, "03": 2, "10": 3, "11": 4, "12": 5 };
81719       let face = data[0].imgInfo.face;
81720       _sceneOptions.cubeMap[which[face]] = canvas.toDataURL("image/jpeg", 1);
81721       return { status: "loadCanvas for face " + data[0].imgInfo.face + "ok" };
81722     });
81723   }
81724   function loadFaces(faceGroup) {
81725     return Promise.all(faceGroup.map(loadCanvas)).then(() => {
81726       return { status: "loadFaces done" };
81727     });
81728   }
81729   function setupCanvas(selection2, reset) {
81730     if (reset) {
81731       selection2.selectAll("#ideditor-stitcher-canvases").remove();
81732     }
81733     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);
81734   }
81735   function qkToXY(qk) {
81736     let x2 = 0;
81737     let y2 = 0;
81738     let scale = 256;
81739     for (let i3 = qk.length; i3 > 0; i3--) {
81740       const key = qk[i3 - 1];
81741       x2 += +(key === "1" || key === "3") * scale;
81742       y2 += +(key === "2" || key === "3") * scale;
81743       scale *= 2;
81744     }
81745     return [x2, y2];
81746   }
81747   function getQuadKeys() {
81748     let dim = _resolution / 256;
81749     let quadKeys;
81750     if (dim === 16) {
81751       quadKeys = [
81752         "0000",
81753         "0001",
81754         "0010",
81755         "0011",
81756         "0100",
81757         "0101",
81758         "0110",
81759         "0111",
81760         "1000",
81761         "1001",
81762         "1010",
81763         "1011",
81764         "1100",
81765         "1101",
81766         "1110",
81767         "1111",
81768         "0002",
81769         "0003",
81770         "0012",
81771         "0013",
81772         "0102",
81773         "0103",
81774         "0112",
81775         "0113",
81776         "1002",
81777         "1003",
81778         "1012",
81779         "1013",
81780         "1102",
81781         "1103",
81782         "1112",
81783         "1113",
81784         "0020",
81785         "0021",
81786         "0030",
81787         "0031",
81788         "0120",
81789         "0121",
81790         "0130",
81791         "0131",
81792         "1020",
81793         "1021",
81794         "1030",
81795         "1031",
81796         "1120",
81797         "1121",
81798         "1130",
81799         "1131",
81800         "0022",
81801         "0023",
81802         "0032",
81803         "0033",
81804         "0122",
81805         "0123",
81806         "0132",
81807         "0133",
81808         "1022",
81809         "1023",
81810         "1032",
81811         "1033",
81812         "1122",
81813         "1123",
81814         "1132",
81815         "1133",
81816         "0200",
81817         "0201",
81818         "0210",
81819         "0211",
81820         "0300",
81821         "0301",
81822         "0310",
81823         "0311",
81824         "1200",
81825         "1201",
81826         "1210",
81827         "1211",
81828         "1300",
81829         "1301",
81830         "1310",
81831         "1311",
81832         "0202",
81833         "0203",
81834         "0212",
81835         "0213",
81836         "0302",
81837         "0303",
81838         "0312",
81839         "0313",
81840         "1202",
81841         "1203",
81842         "1212",
81843         "1213",
81844         "1302",
81845         "1303",
81846         "1312",
81847         "1313",
81848         "0220",
81849         "0221",
81850         "0230",
81851         "0231",
81852         "0320",
81853         "0321",
81854         "0330",
81855         "0331",
81856         "1220",
81857         "1221",
81858         "1230",
81859         "1231",
81860         "1320",
81861         "1321",
81862         "1330",
81863         "1331",
81864         "0222",
81865         "0223",
81866         "0232",
81867         "0233",
81868         "0322",
81869         "0323",
81870         "0332",
81871         "0333",
81872         "1222",
81873         "1223",
81874         "1232",
81875         "1233",
81876         "1322",
81877         "1323",
81878         "1332",
81879         "1333",
81880         "2000",
81881         "2001",
81882         "2010",
81883         "2011",
81884         "2100",
81885         "2101",
81886         "2110",
81887         "2111",
81888         "3000",
81889         "3001",
81890         "3010",
81891         "3011",
81892         "3100",
81893         "3101",
81894         "3110",
81895         "3111",
81896         "2002",
81897         "2003",
81898         "2012",
81899         "2013",
81900         "2102",
81901         "2103",
81902         "2112",
81903         "2113",
81904         "3002",
81905         "3003",
81906         "3012",
81907         "3013",
81908         "3102",
81909         "3103",
81910         "3112",
81911         "3113",
81912         "2020",
81913         "2021",
81914         "2030",
81915         "2031",
81916         "2120",
81917         "2121",
81918         "2130",
81919         "2131",
81920         "3020",
81921         "3021",
81922         "3030",
81923         "3031",
81924         "3120",
81925         "3121",
81926         "3130",
81927         "3131",
81928         "2022",
81929         "2023",
81930         "2032",
81931         "2033",
81932         "2122",
81933         "2123",
81934         "2132",
81935         "2133",
81936         "3022",
81937         "3023",
81938         "3032",
81939         "3033",
81940         "3122",
81941         "3123",
81942         "3132",
81943         "3133",
81944         "2200",
81945         "2201",
81946         "2210",
81947         "2211",
81948         "2300",
81949         "2301",
81950         "2310",
81951         "2311",
81952         "3200",
81953         "3201",
81954         "3210",
81955         "3211",
81956         "3300",
81957         "3301",
81958         "3310",
81959         "3311",
81960         "2202",
81961         "2203",
81962         "2212",
81963         "2213",
81964         "2302",
81965         "2303",
81966         "2312",
81967         "2313",
81968         "3202",
81969         "3203",
81970         "3212",
81971         "3213",
81972         "3302",
81973         "3303",
81974         "3312",
81975         "3313",
81976         "2220",
81977         "2221",
81978         "2230",
81979         "2231",
81980         "2320",
81981         "2321",
81982         "2330",
81983         "2331",
81984         "3220",
81985         "3221",
81986         "3230",
81987         "3231",
81988         "3320",
81989         "3321",
81990         "3330",
81991         "3331",
81992         "2222",
81993         "2223",
81994         "2232",
81995         "2233",
81996         "2322",
81997         "2323",
81998         "2332",
81999         "2333",
82000         "3222",
82001         "3223",
82002         "3232",
82003         "3233",
82004         "3322",
82005         "3323",
82006         "3332",
82007         "3333"
82008       ];
82009     } else if (dim === 8) {
82010       quadKeys = [
82011         "000",
82012         "001",
82013         "010",
82014         "011",
82015         "100",
82016         "101",
82017         "110",
82018         "111",
82019         "002",
82020         "003",
82021         "012",
82022         "013",
82023         "102",
82024         "103",
82025         "112",
82026         "113",
82027         "020",
82028         "021",
82029         "030",
82030         "031",
82031         "120",
82032         "121",
82033         "130",
82034         "131",
82035         "022",
82036         "023",
82037         "032",
82038         "033",
82039         "122",
82040         "123",
82041         "132",
82042         "133",
82043         "200",
82044         "201",
82045         "210",
82046         "211",
82047         "300",
82048         "301",
82049         "310",
82050         "311",
82051         "202",
82052         "203",
82053         "212",
82054         "213",
82055         "302",
82056         "303",
82057         "312",
82058         "313",
82059         "220",
82060         "221",
82061         "230",
82062         "231",
82063         "320",
82064         "321",
82065         "330",
82066         "331",
82067         "222",
82068         "223",
82069         "232",
82070         "233",
82071         "322",
82072         "323",
82073         "332",
82074         "333"
82075       ];
82076     } else if (dim === 4) {
82077       quadKeys = [
82078         "00",
82079         "01",
82080         "10",
82081         "11",
82082         "02",
82083         "03",
82084         "12",
82085         "13",
82086         "20",
82087         "21",
82088         "30",
82089         "31",
82090         "22",
82091         "23",
82092         "32",
82093         "33"
82094       ];
82095     } else {
82096       quadKeys = [
82097         "0",
82098         "1",
82099         "2",
82100         "3"
82101       ];
82102     }
82103     return quadKeys;
82104   }
82105   var streetside_default = {
82106     /**
82107      * init() initialize streetside.
82108      */
82109     init: function() {
82110       if (!_ssCache) {
82111         this.reset();
82112       }
82113       this.event = utilRebind(this, dispatch11, "on");
82114     },
82115     /**
82116      * reset() reset the cache.
82117      */
82118     reset: function() {
82119       if (_ssCache) {
82120         Object.values(_ssCache.bubbles.inflight).forEach(abortRequest6);
82121       }
82122       _ssCache = {
82123         bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush11.default(), points: {} },
82124         sequences: {}
82125       };
82126     },
82127     /**
82128      * bubbles()
82129      */
82130     bubbles: function(projection2) {
82131       const limit = 5;
82132       return searchLimited4(limit, projection2, _ssCache.bubbles.rtree);
82133     },
82134     cachedImage: function(imageKey) {
82135       return _ssCache.bubbles.points[imageKey];
82136     },
82137     sequences: function(projection2) {
82138       const viewport = projection2.clipExtent();
82139       const min3 = [viewport[0][0], viewport[1][1]];
82140       const max3 = [viewport[1][0], viewport[0][1]];
82141       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
82142       let seen = {};
82143       let results = [];
82144       _ssCache.bubbles.rtree.search(bbox2).forEach((d2) => {
82145         const key = d2.data.sequenceKey;
82146         if (key && !seen[key]) {
82147           seen[key] = true;
82148           results.push(_ssCache.sequences[key].geojson);
82149         }
82150       });
82151       return results;
82152     },
82153     /**
82154      * loadBubbles()
82155      */
82156     loadBubbles: function(projection2, margin) {
82157       if (margin === void 0)
82158         margin = 2;
82159       loadTiles3("bubbles", streetsideApi, projection2, margin);
82160     },
82161     viewer: function() {
82162       return _pannellumViewer2;
82163     },
82164     initViewer: function() {
82165       if (!window.pannellum)
82166         return;
82167       if (_pannellumViewer2)
82168         return;
82169       _currScene += 1;
82170       const sceneID = _currScene.toString();
82171       const options2 = {
82172         "default": { firstScene: sceneID },
82173         scenes: {}
82174       };
82175       options2.scenes[sceneID] = _sceneOptions;
82176       _pannellumViewer2 = window.pannellum.viewer("ideditor-viewer-streetside", options2);
82177     },
82178     ensureViewerLoaded: function(context) {
82179       if (_loadViewerPromise4)
82180         return _loadViewerPromise4;
82181       let wrap2 = context.container().select(".photoviewer").selectAll(".ms-wrapper").data([0]);
82182       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper ms-wrapper").classed("hide", true);
82183       let that = this;
82184       let pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
82185       wrapEnter.append("div").attr("id", "ideditor-viewer-streetside").on(pointerPrefix + "down.streetside", () => {
82186         select_default2(window).on(pointerPrefix + "move.streetside", () => {
82187           dispatch11.call("viewerChanged");
82188         }, true);
82189       }).on(pointerPrefix + "up.streetside pointercancel.streetside", () => {
82190         select_default2(window).on(pointerPrefix + "move.streetside", null);
82191         let t2 = timer((elapsed) => {
82192           dispatch11.call("viewerChanged");
82193           if (elapsed > 2e3) {
82194             t2.stop();
82195           }
82196         });
82197       }).append("div").attr("class", "photo-attribution fillD");
82198       let controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
82199       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
82200       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
82201       wrap2 = wrap2.merge(wrapEnter).call(setupCanvas, true);
82202       context.ui().photoviewer.on("resize.streetside", () => {
82203         if (_pannellumViewer2) {
82204           _pannellumViewer2.resize();
82205         }
82206       });
82207       _loadViewerPromise4 = new Promise((resolve, reject) => {
82208         let loadedCount = 0;
82209         function loaded() {
82210           loadedCount += 1;
82211           if (loadedCount === 2)
82212             resolve();
82213         }
82214         const head = select_default2("head");
82215         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() {
82216           reject();
82217         });
82218         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() {
82219           reject();
82220         });
82221       }).catch(function() {
82222         _loadViewerPromise4 = null;
82223       });
82224       return _loadViewerPromise4;
82225       function step(stepBy) {
82226         return () => {
82227           let viewer = context.container().select(".photoviewer");
82228           let selected = viewer.empty() ? void 0 : viewer.datum();
82229           if (!selected)
82230             return;
82231           let nextID = stepBy === 1 ? selected.ne : selected.pr;
82232           let yaw = _pannellumViewer2.getYaw();
82233           let ca = selected.ca + yaw;
82234           let origin = selected.loc;
82235           const meters = 35;
82236           let p1 = [
82237             origin[0] + geoMetersToLon(meters / 5, origin[1]),
82238             origin[1]
82239           ];
82240           let p2 = [
82241             origin[0] + geoMetersToLon(meters / 2, origin[1]),
82242             origin[1] + geoMetersToLat(meters)
82243           ];
82244           let p3 = [
82245             origin[0] - geoMetersToLon(meters / 2, origin[1]),
82246             origin[1] + geoMetersToLat(meters)
82247           ];
82248           let p4 = [
82249             origin[0] - geoMetersToLon(meters / 5, origin[1]),
82250             origin[1]
82251           ];
82252           let poly = [p1, p2, p3, p4, p1];
82253           let angle2 = (stepBy === 1 ? ca : ca + 180) * (Math.PI / 180);
82254           poly = geoRotate(poly, -angle2, origin);
82255           let extent = poly.reduce((extent2, point2) => {
82256             return extent2.extend(geoExtent(point2));
82257           }, geoExtent());
82258           let minDist = Infinity;
82259           _ssCache.bubbles.rtree.search(extent.bbox()).forEach((d2) => {
82260             if (d2.data.key === selected.key)
82261               return;
82262             if (!geoPointInPolygon(d2.data.loc, poly))
82263               return;
82264             let dist = geoVecLength(d2.data.loc, selected.loc);
82265             let theta = selected.ca - d2.data.ca;
82266             let minTheta = Math.min(Math.abs(theta), 360 - Math.abs(theta));
82267             if (minTheta > 20) {
82268               dist += 5;
82269             }
82270             if (dist < minDist) {
82271               nextID = d2.data.key;
82272               minDist = dist;
82273             }
82274           });
82275           let nextBubble = nextID && that.cachedImage(nextID);
82276           if (!nextBubble)
82277             return;
82278           context.map().centerEase(nextBubble.loc);
82279           that.selectImage(context, nextBubble.key).yaw(yaw).showViewer(context);
82280         };
82281       }
82282     },
82283     yaw: function(yaw) {
82284       if (typeof yaw !== "number")
82285         return yaw;
82286       _sceneOptions.yaw = yaw;
82287       return this;
82288     },
82289     /**
82290      * showViewer()
82291      */
82292     showViewer: function(context) {
82293       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
82294       let isHidden = wrap2.selectAll(".photo-wrapper.ms-wrapper.hide").size();
82295       if (isHidden) {
82296         wrap2.selectAll(".photo-wrapper:not(.ms-wrapper)").classed("hide", true);
82297         wrap2.selectAll(".photo-wrapper.ms-wrapper").classed("hide", false);
82298       }
82299       return this;
82300     },
82301     /**
82302      * hideViewer()
82303      */
82304     hideViewer: function(context) {
82305       let viewer = context.container().select(".photoviewer");
82306       if (!viewer.empty())
82307         viewer.datum(null);
82308       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
82309       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
82310       this.updateUrlImage(null);
82311       return this.setStyles(context, null, true);
82312     },
82313     /**
82314      * selectImage().
82315      */
82316     selectImage: function(context, key) {
82317       let that = this;
82318       let d2 = this.cachedImage(key);
82319       let viewer = context.container().select(".photoviewer");
82320       if (!viewer.empty())
82321         viewer.datum(d2);
82322       this.setStyles(context, null, true);
82323       let wrap2 = context.container().select(".photoviewer .ms-wrapper");
82324       let attribution = wrap2.selectAll(".photo-attribution").html("");
82325       wrap2.selectAll(".pnlm-load-box").style("display", "block");
82326       if (!d2)
82327         return this;
82328       this.updateUrlImage(key);
82329       _sceneOptions.northOffset = d2.ca;
82330       let line1 = attribution.append("div").attr("class", "attribution-row");
82331       const hiresDomId = utilUniqueDomId("streetside-hires");
82332       let label = line1.append("label").attr("for", hiresDomId).attr("class", "streetside-hires");
82333       label.append("input").attr("type", "checkbox").attr("id", hiresDomId).property("checked", _hires).on("click", (d3_event) => {
82334         d3_event.stopPropagation();
82335         _hires = !_hires;
82336         _resolution = _hires ? 1024 : 512;
82337         wrap2.call(setupCanvas, true);
82338         let viewstate = {
82339           yaw: _pannellumViewer2.getYaw(),
82340           pitch: _pannellumViewer2.getPitch(),
82341           hfov: _pannellumViewer2.getHfov()
82342         };
82343         _sceneOptions = Object.assign(_sceneOptions, viewstate);
82344         that.selectImage(context, d2.key).showViewer(context);
82345       });
82346       label.append("span").call(_t.append("streetside.hires"));
82347       let captureInfo = line1.append("div").attr("class", "attribution-capture-info");
82348       if (d2.captured_by) {
82349         const yyyy = (/* @__PURE__ */ new Date()).getFullYear();
82350         captureInfo.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://www.microsoft.com/en-us/maps/streetside").text("\xA9" + yyyy + " Microsoft");
82351         captureInfo.append("span").text("|");
82352       }
82353       if (d2.captured_at) {
82354         captureInfo.append("span").attr("class", "captured_at").text(localeTimestamp2(d2.captured_at));
82355       }
82356       let line2 = attribution.append("div").attr("class", "attribution-row");
82357       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"));
82358       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"));
82359       const faceKeys = ["01", "02", "03", "10", "11", "12"];
82360       let quadKeys = getQuadKeys();
82361       let faces = faceKeys.map((faceKey) => {
82362         return quadKeys.map((quadKey) => {
82363           const xy = qkToXY(quadKey);
82364           return {
82365             face: faceKey,
82366             url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey),
82367             x: xy[0],
82368             y: xy[1]
82369           };
82370         });
82371       });
82372       loadFaces(faces).then(function() {
82373         if (!_pannellumViewer2) {
82374           that.initViewer();
82375         } else {
82376           _currScene += 1;
82377           let sceneID = _currScene.toString();
82378           _pannellumViewer2.addScene(sceneID, _sceneOptions).loadScene(sceneID);
82379           if (_currScene > 2) {
82380             sceneID = (_currScene - 1).toString();
82381             _pannellumViewer2.removeScene(sceneID);
82382           }
82383         }
82384       });
82385       return this;
82386     },
82387     getSequenceKeyForBubble: function(d2) {
82388       return d2 && d2.sequenceKey;
82389     },
82390     // Updates the currently highlighted sequence and selected bubble.
82391     // Reset is only necessary when interacting with the viewport because
82392     // this implicitly changes the currently selected bubble/sequence
82393     setStyles: function(context, hovered, reset) {
82394       if (reset) {
82395         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
82396         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
82397       }
82398       let hoveredBubbleKey = hovered && hovered.key;
82399       let hoveredSequenceKey = this.getSequenceKeyForBubble(hovered);
82400       let hoveredSequence = hoveredSequenceKey && _ssCache.sequences[hoveredSequenceKey];
82401       let hoveredBubbleKeys = hoveredSequence && hoveredSequence.bubbles.map((d2) => d2.key) || [];
82402       let viewer = context.container().select(".photoviewer");
82403       let selected = viewer.empty() ? void 0 : viewer.datum();
82404       let selectedBubbleKey = selected && selected.key;
82405       let selectedSequenceKey = this.getSequenceKeyForBubble(selected);
82406       let selectedSequence = selectedSequenceKey && _ssCache.sequences[selectedSequenceKey];
82407       let selectedBubbleKeys = selectedSequence && selectedSequence.bubbles.map((d2) => d2.key) || [];
82408       let highlightedBubbleKeys = utilArrayUnion(hoveredBubbleKeys, selectedBubbleKeys);
82409       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);
82410       context.container().selectAll(".layer-streetside-images .sequence").classed("highlighted", (d2) => d2.properties.key === hoveredSequenceKey).classed("currentView", (d2) => d2.properties.key === selectedSequenceKey);
82411       context.container().selectAll(".layer-streetside-images .viewfield-group .viewfield").attr("d", viewfieldPath);
82412       function viewfieldPath() {
82413         let d2 = this.parentNode.__data__;
82414         if (d2.pano && d2.key !== selectedBubbleKey) {
82415           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
82416         } else {
82417           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
82418         }
82419       }
82420       return this;
82421     },
82422     updateUrlImage: function(imageKey) {
82423       if (!window.mocha) {
82424         var hash = utilStringQs(window.location.hash);
82425         if (imageKey) {
82426           hash.photo = "streetside/" + imageKey;
82427         } else {
82428           delete hash.photo;
82429         }
82430         window.location.replace("#" + utilQsString(hash, true));
82431       }
82432     },
82433     /**
82434      * cache().
82435      */
82436     cache: function() {
82437       return _ssCache;
82438     }
82439   };
82440
82441   // modules/services/taginfo.js
82442   var apibase4 = taginfoApiUrl;
82443   var _inflight3 = {};
82444   var _popularKeys = {};
82445   var _taginfoCache = {};
82446   var tag_sorts = {
82447     point: "count_nodes",
82448     vertex: "count_nodes",
82449     area: "count_ways",
82450     line: "count_ways"
82451   };
82452   var tag_sort_members = {
82453     point: "count_node_members",
82454     vertex: "count_node_members",
82455     area: "count_way_members",
82456     line: "count_way_members",
82457     relation: "count_relation_members"
82458   };
82459   var tag_filters = {
82460     point: "nodes",
82461     vertex: "nodes",
82462     area: "ways",
82463     line: "ways"
82464   };
82465   var tag_members_fractions = {
82466     point: "count_node_members_fraction",
82467     vertex: "count_node_members_fraction",
82468     area: "count_way_members_fraction",
82469     line: "count_way_members_fraction",
82470     relation: "count_relation_members_fraction"
82471   };
82472   function sets(params, n3, o2) {
82473     if (params.geometry && o2[params.geometry]) {
82474       params[n3] = o2[params.geometry];
82475     }
82476     return params;
82477   }
82478   function setFilter(params) {
82479     return sets(params, "filter", tag_filters);
82480   }
82481   function setSort(params) {
82482     return sets(params, "sortname", tag_sorts);
82483   }
82484   function setSortMembers(params) {
82485     return sets(params, "sortname", tag_sort_members);
82486   }
82487   function clean(params) {
82488     return utilObjectOmit(params, ["geometry", "debounce"]);
82489   }
82490   function filterKeys(type2) {
82491     var count_type = type2 ? "count_" + type2 : "count_all";
82492     return function(d2) {
82493       return Number(d2[count_type]) > 2500 || d2.in_wiki;
82494     };
82495   }
82496   function filterMultikeys(prefix) {
82497     return function(d2) {
82498       var re3 = new RegExp("^" + prefix + "(.*)$", "i");
82499       var matches = d2.key.match(re3) || [];
82500       return matches.length === 2 && matches[1].indexOf(":") === -1;
82501     };
82502   }
82503   function filterValues(allowUpperCase) {
82504     return function(d2) {
82505       if (d2.value.match(/[;,]/) !== null)
82506         return false;
82507       if (!allowUpperCase && d2.value.match(/[A-Z*]/) !== null)
82508         return false;
82509       return d2.count > 100 || d2.in_wiki;
82510     };
82511   }
82512   function filterRoles(geometry) {
82513     return function(d2) {
82514       if (d2.role === "")
82515         return false;
82516       if (d2.role.match(/[A-Z*;,]/) !== null)
82517         return false;
82518       return Number(d2[tag_members_fractions[geometry]]) > 0;
82519     };
82520   }
82521   function valKey(d2) {
82522     return {
82523       value: d2.key,
82524       title: d2.key
82525     };
82526   }
82527   function valKeyDescription(d2) {
82528     var obj = {
82529       value: d2.value,
82530       title: d2.description || d2.value
82531     };
82532     return obj;
82533   }
82534   function roleKey(d2) {
82535     return {
82536       value: d2.role,
82537       title: d2.role
82538     };
82539   }
82540   function sortKeys(a2, b2) {
82541     return a2.key.indexOf(":") === -1 && b2.key.indexOf(":") !== -1 ? -1 : a2.key.indexOf(":") !== -1 && b2.key.indexOf(":") === -1 ? 1 : 0;
82542   }
82543   var debouncedRequest2 = debounce_default(request2, 300, { leading: false });
82544   function request2(url, params, exactMatch, callback, loaded) {
82545     if (_inflight3[url])
82546       return;
82547     if (checkCache(url, params, exactMatch, callback))
82548       return;
82549     var controller = new AbortController();
82550     _inflight3[url] = controller;
82551     json_default(url, { signal: controller.signal }).then(function(result) {
82552       delete _inflight3[url];
82553       if (loaded)
82554         loaded(null, result);
82555     }).catch(function(err) {
82556       delete _inflight3[url];
82557       if (err.name === "AbortError")
82558         return;
82559       if (loaded)
82560         loaded(err.message);
82561     });
82562   }
82563   function checkCache(url, params, exactMatch, callback) {
82564     var rp = params.rp || 25;
82565     var testQuery = params.query || "";
82566     var testUrl = url;
82567     do {
82568       var hit = _taginfoCache[testUrl];
82569       if (hit && (url === testUrl || hit.length < rp)) {
82570         callback(null, hit);
82571         return true;
82572       }
82573       if (exactMatch || !testQuery.length)
82574         return false;
82575       testQuery = testQuery.slice(0, -1);
82576       testUrl = url.replace(/&query=(.*?)&/, "&query=" + testQuery + "&");
82577     } while (testQuery.length >= 0);
82578     return false;
82579   }
82580   var taginfo_default = {
82581     init: function() {
82582       _inflight3 = {};
82583       _taginfoCache = {};
82584       _popularKeys = {
82585         // manually exclude some keys – #5377, #7485
82586         postal_code: true,
82587         full_name: true,
82588         loc_name: true,
82589         reg_name: true,
82590         short_name: true,
82591         sorting_name: true,
82592         artist_name: true,
82593         nat_name: true,
82594         long_name: true,
82595         via: true,
82596         "bridge:name": true
82597       };
82598       var params = {
82599         rp: 100,
82600         sortname: "values_all",
82601         sortorder: "desc",
82602         page: 1,
82603         debounce: false,
82604         lang: _mainLocalizer.languageCode()
82605       };
82606       this.keys(params, function(err, data) {
82607         if (err)
82608           return;
82609         data.forEach(function(d2) {
82610           if (d2.value === "opening_hours")
82611             return;
82612           _popularKeys[d2.value] = true;
82613         });
82614       });
82615     },
82616     reset: function() {
82617       Object.values(_inflight3).forEach(function(controller) {
82618         controller.abort();
82619       });
82620       _inflight3 = {};
82621     },
82622     keys: function(params, callback) {
82623       var doRequest = params.debounce ? debouncedRequest2 : request2;
82624       params = clean(setSort(params));
82625       params = Object.assign({
82626         rp: 10,
82627         sortname: "count_all",
82628         sortorder: "desc",
82629         page: 1,
82630         lang: _mainLocalizer.languageCode()
82631       }, params);
82632       var url = apibase4 + "keys/all?" + utilQsString(params);
82633       doRequest(url, params, false, callback, function(err, d2) {
82634         if (err) {
82635           callback(err);
82636         } else {
82637           var f2 = filterKeys(params.filter);
82638           var result = d2.data.filter(f2).sort(sortKeys).map(valKey);
82639           _taginfoCache[url] = result;
82640           callback(null, result);
82641         }
82642       });
82643     },
82644     multikeys: function(params, callback) {
82645       var doRequest = params.debounce ? debouncedRequest2 : request2;
82646       params = clean(setSort(params));
82647       params = Object.assign({
82648         rp: 25,
82649         sortname: "count_all",
82650         sortorder: "desc",
82651         page: 1,
82652         lang: _mainLocalizer.languageCode()
82653       }, params);
82654       var prefix = params.query;
82655       var url = apibase4 + "keys/all?" + utilQsString(params);
82656       doRequest(url, params, true, callback, function(err, d2) {
82657         if (err) {
82658           callback(err);
82659         } else {
82660           var f2 = filterMultikeys(prefix);
82661           var result = d2.data.filter(f2).map(valKey);
82662           _taginfoCache[url] = result;
82663           callback(null, result);
82664         }
82665       });
82666     },
82667     values: function(params, callback) {
82668       var key = params.key;
82669       if (key && _popularKeys[key]) {
82670         callback(null, []);
82671         return;
82672       }
82673       var doRequest = params.debounce ? debouncedRequest2 : request2;
82674       params = clean(setSort(setFilter(params)));
82675       params = Object.assign({
82676         rp: 25,
82677         sortname: "count_all",
82678         sortorder: "desc",
82679         page: 1,
82680         lang: _mainLocalizer.languageCode()
82681       }, params);
82682       var url = apibase4 + "key/values?" + utilQsString(params);
82683       doRequest(url, params, false, callback, function(err, d2) {
82684         if (err) {
82685           callback(err);
82686         } else {
82687           var allowUpperCase = allowUpperCaseTagValues.test(params.key);
82688           var f2 = filterValues(allowUpperCase);
82689           var result = d2.data.filter(f2).map(valKeyDescription);
82690           _taginfoCache[url] = result;
82691           callback(null, result);
82692         }
82693       });
82694     },
82695     roles: function(params, callback) {
82696       var doRequest = params.debounce ? debouncedRequest2 : request2;
82697       var geometry = params.geometry;
82698       params = clean(setSortMembers(params));
82699       params = Object.assign({
82700         rp: 25,
82701         sortname: "count_all_members",
82702         sortorder: "desc",
82703         page: 1,
82704         lang: _mainLocalizer.languageCode()
82705       }, params);
82706       var url = apibase4 + "relation/roles?" + utilQsString(params);
82707       doRequest(url, params, true, callback, function(err, d2) {
82708         if (err) {
82709           callback(err);
82710         } else {
82711           var f2 = filterRoles(geometry);
82712           var result = d2.data.filter(f2).map(roleKey);
82713           _taginfoCache[url] = result;
82714           callback(null, result);
82715         }
82716       });
82717     },
82718     docs: function(params, callback) {
82719       var doRequest = params.debounce ? debouncedRequest2 : request2;
82720       params = clean(setSort(params));
82721       var path = "key/wiki_pages?";
82722       if (params.value) {
82723         path = "tag/wiki_pages?";
82724       } else if (params.rtype) {
82725         path = "relation/wiki_pages?";
82726       }
82727       var url = apibase4 + path + utilQsString(params);
82728       doRequest(url, params, true, callback, function(err, d2) {
82729         if (err) {
82730           callback(err);
82731         } else {
82732           _taginfoCache[url] = d2.data;
82733           callback(null, d2.data);
82734         }
82735       });
82736     },
82737     apibase: function(_2) {
82738       if (!arguments.length)
82739         return apibase4;
82740       apibase4 = _2;
82741       return this;
82742     }
82743   };
82744
82745   // modules/services/vector_tile.js
82746   var import_fast_deep_equal11 = __toESM(require_fast_deep_equal());
82747   var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify());
82748   var import_polygon_clipping = __toESM(require_polygon_clipping_umd());
82749   var import_pbf2 = __toESM(require_pbf());
82750   var import_vector_tile2 = __toESM(require_vector_tile());
82751   var tiler8 = utilTiler().tileSize(512).margin(1);
82752   var dispatch12 = dispatch_default("loadedData");
82753   var _vtCache;
82754   function abortRequest7(controller) {
82755     controller.abort();
82756   }
82757   function vtToGeoJSON(data, tile, mergeCache) {
82758     var vectorTile = new import_vector_tile2.default.VectorTile(new import_pbf2.default(data));
82759     var layers = Object.keys(vectorTile.layers);
82760     if (!Array.isArray(layers)) {
82761       layers = [layers];
82762     }
82763     var features = [];
82764     layers.forEach(function(layerID) {
82765       var layer = vectorTile.layers[layerID];
82766       if (layer) {
82767         for (var i3 = 0; i3 < layer.length; i3++) {
82768           var feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
82769           var geometry = feature3.geometry;
82770           if (geometry.type === "Polygon") {
82771             geometry.type = "MultiPolygon";
82772             geometry.coordinates = [geometry.coordinates];
82773           }
82774           var isClipped = false;
82775           if (geometry.type === "MultiPolygon") {
82776             var featureClip = bboxClip(feature3, tile.extent.rectangle());
82777             if (!(0, import_fast_deep_equal11.default)(feature3.geometry, featureClip.geometry)) {
82778               isClipped = true;
82779             }
82780             if (!feature3.geometry.coordinates.length)
82781               continue;
82782             if (!feature3.geometry.coordinates[0].length)
82783               continue;
82784           }
82785           var featurehash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3));
82786           var propertyhash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3.properties || {}));
82787           feature3.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, "_");
82788           feature3.__featurehash__ = featurehash;
82789           feature3.__propertyhash__ = propertyhash;
82790           features.push(feature3);
82791           if (isClipped && geometry.type === "MultiPolygon") {
82792             var merged = mergeCache[propertyhash];
82793             if (merged && merged.length) {
82794               var other = merged[0];
82795               var coords = import_polygon_clipping.default.union(
82796                 feature3.geometry.coordinates,
82797                 other.geometry.coordinates
82798               );
82799               if (!coords || !coords.length) {
82800                 continue;
82801               }
82802               merged.push(feature3);
82803               for (var j2 = 0; j2 < merged.length; j2++) {
82804                 merged[j2].geometry.coordinates = coords;
82805                 merged[j2].__featurehash__ = featurehash;
82806               }
82807             } else {
82808               mergeCache[propertyhash] = [feature3];
82809             }
82810           }
82811         }
82812       }
82813     });
82814     return features;
82815   }
82816   function loadTile3(source, tile) {
82817     if (source.loaded[tile.id] || source.inflight[tile.id])
82818       return;
82819     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) {
82820       var subdomains = r2.split(",");
82821       return subdomains[(tile.xyz[0] + tile.xyz[1]) % subdomains.length];
82822     });
82823     var controller = new AbortController();
82824     source.inflight[tile.id] = controller;
82825     fetch(url, { signal: controller.signal }).then(function(response) {
82826       if (!response.ok) {
82827         throw new Error(response.status + " " + response.statusText);
82828       }
82829       source.loaded[tile.id] = [];
82830       delete source.inflight[tile.id];
82831       return response.arrayBuffer();
82832     }).then(function(data) {
82833       if (!data) {
82834         throw new Error("No Data");
82835       }
82836       var z2 = tile.xyz[2];
82837       if (!source.canMerge[z2]) {
82838         source.canMerge[z2] = {};
82839       }
82840       source.loaded[tile.id] = vtToGeoJSON(data, tile, source.canMerge[z2]);
82841       dispatch12.call("loadedData");
82842     }).catch(function() {
82843       source.loaded[tile.id] = [];
82844       delete source.inflight[tile.id];
82845     });
82846   }
82847   var vector_tile_default = {
82848     init: function() {
82849       if (!_vtCache) {
82850         this.reset();
82851       }
82852       this.event = utilRebind(this, dispatch12, "on");
82853     },
82854     reset: function() {
82855       for (var sourceID in _vtCache) {
82856         var source = _vtCache[sourceID];
82857         if (source && source.inflight) {
82858           Object.values(source.inflight).forEach(abortRequest7);
82859         }
82860       }
82861       _vtCache = {};
82862     },
82863     addSource: function(sourceID, template) {
82864       _vtCache[sourceID] = { template, inflight: {}, loaded: {}, canMerge: {} };
82865       return _vtCache[sourceID];
82866     },
82867     data: function(sourceID, projection2) {
82868       var source = _vtCache[sourceID];
82869       if (!source)
82870         return [];
82871       var tiles = tiler8.getTiles(projection2);
82872       var seen = {};
82873       var results = [];
82874       for (var i3 = 0; i3 < tiles.length; i3++) {
82875         var features = source.loaded[tiles[i3].id];
82876         if (!features || !features.length)
82877           continue;
82878         for (var j2 = 0; j2 < features.length; j2++) {
82879           var feature3 = features[j2];
82880           var hash = feature3.__featurehash__;
82881           if (seen[hash])
82882             continue;
82883           seen[hash] = true;
82884           results.push(Object.assign({}, feature3));
82885         }
82886       }
82887       return results;
82888     },
82889     loadTiles: function(sourceID, template, projection2) {
82890       var source = _vtCache[sourceID];
82891       if (!source) {
82892         source = this.addSource(sourceID, template);
82893       }
82894       var tiles = tiler8.getTiles(projection2);
82895       Object.keys(source.inflight).forEach(function(k2) {
82896         var wanted = tiles.find(function(tile) {
82897           return k2 === tile.id;
82898         });
82899         if (!wanted) {
82900           abortRequest7(source.inflight[k2]);
82901           delete source.inflight[k2];
82902         }
82903       });
82904       tiles.forEach(function(tile) {
82905         loadTile3(source, tile);
82906       });
82907     },
82908     cache: function() {
82909       return _vtCache;
82910     }
82911   };
82912
82913   // modules/services/wikidata.js
82914   var apibase5 = "https://www.wikidata.org/w/api.php?";
82915   var _wikidataCache = {};
82916   var wikidata_default = {
82917     init: function() {
82918     },
82919     reset: function() {
82920       _wikidataCache = {};
82921     },
82922     // Search for Wikidata items matching the query
82923     itemsForSearchQuery: function(query, callback, language) {
82924       if (!query) {
82925         if (callback)
82926           callback("No query", {});
82927         return;
82928       }
82929       var lang = this.languagesToQuery()[0];
82930       var url = apibase5 + utilQsString({
82931         action: "wbsearchentities",
82932         format: "json",
82933         formatversion: 2,
82934         search: query,
82935         type: "item",
82936         // the language to search
82937         language: language || lang,
82938         // the language for the label and description in the result
82939         uselang: lang,
82940         limit: 10,
82941         origin: "*"
82942       });
82943       json_default(url).then((result) => {
82944         if (result && result.error) {
82945           if (result.error.code === "badvalue" && result.error.info.includes(lang) && !language && lang.includes("-")) {
82946             this.itemsForSearchQuery(query, callback, lang.split("-")[0]);
82947             return;
82948           } else {
82949             throw new Error(result.error);
82950           }
82951         }
82952         if (callback)
82953           callback(null, result.search || {});
82954       }).catch(function(err) {
82955         if (callback)
82956           callback(err.message, {});
82957       });
82958     },
82959     // Given a Wikipedia language and article title,
82960     // return an array of corresponding Wikidata entities.
82961     itemsByTitle: function(lang, title, callback) {
82962       if (!title) {
82963         if (callback)
82964           callback("No title", {});
82965         return;
82966       }
82967       lang = lang || "en";
82968       var url = apibase5 + utilQsString({
82969         action: "wbgetentities",
82970         format: "json",
82971         formatversion: 2,
82972         sites: lang.replace(/-/g, "_") + "wiki",
82973         titles: title,
82974         languages: "en",
82975         // shrink response by filtering to one language
82976         origin: "*"
82977       });
82978       json_default(url).then(function(result) {
82979         if (result && result.error) {
82980           throw new Error(result.error);
82981         }
82982         if (callback)
82983           callback(null, result.entities || {});
82984       }).catch(function(err) {
82985         if (callback)
82986           callback(err.message, {});
82987       });
82988     },
82989     languagesToQuery: function() {
82990       return _mainLocalizer.localeCodes().map(function(code) {
82991         return code.toLowerCase();
82992       }).filter(function(code) {
82993         return code !== "en-us";
82994       });
82995     },
82996     entityByQID: function(qid, callback) {
82997       if (!qid) {
82998         callback("No qid", {});
82999         return;
83000       }
83001       if (_wikidataCache[qid]) {
83002         if (callback)
83003           callback(null, _wikidataCache[qid]);
83004         return;
83005       }
83006       var langs = this.languagesToQuery();
83007       var url = apibase5 + utilQsString({
83008         action: "wbgetentities",
83009         format: "json",
83010         formatversion: 2,
83011         ids: qid,
83012         props: "labels|descriptions|claims|sitelinks",
83013         sitefilter: langs.map(function(d2) {
83014           return d2 + "wiki";
83015         }).join("|"),
83016         languages: langs.join("|"),
83017         languagefallback: 1,
83018         origin: "*"
83019       });
83020       json_default(url).then(function(result) {
83021         if (result && result.error) {
83022           throw new Error(result.error);
83023         }
83024         if (callback)
83025           callback(null, result.entities[qid] || {});
83026       }).catch(function(err) {
83027         if (callback)
83028           callback(err.message, {});
83029       });
83030     },
83031     // Pass `params` object of the form:
83032     // {
83033     //   qid: 'string'      // brand wikidata  (e.g. 'Q37158')
83034     // }
83035     //
83036     // Get an result object used to display tag documentation
83037     // {
83038     //   title:        'string',
83039     //   description:  'string',
83040     //   editURL:      'string',
83041     //   imageURL:     'string',
83042     //   wiki:         { title: 'string', text: 'string', url: 'string' }
83043     // }
83044     //
83045     getDocs: function(params, callback) {
83046       var langs = this.languagesToQuery();
83047       this.entityByQID(params.qid, function(err, entity) {
83048         if (err || !entity) {
83049           callback(err || "No entity");
83050           return;
83051         }
83052         var i3;
83053         var description;
83054         for (i3 in langs) {
83055           let code = langs[i3];
83056           if (entity.descriptions[code] && entity.descriptions[code].language === code) {
83057             description = entity.descriptions[code];
83058             break;
83059           }
83060         }
83061         if (!description && Object.values(entity.descriptions).length)
83062           description = Object.values(entity.descriptions)[0];
83063         var result = {
83064           title: entity.id,
83065           description: description ? description.value : "",
83066           descriptionLocaleCode: description ? description.language : "",
83067           editURL: "https://www.wikidata.org/wiki/" + entity.id
83068         };
83069         if (entity.claims) {
83070           var imageroot = "https://commons.wikimedia.org/w/index.php";
83071           var props = ["P154", "P18"];
83072           var prop, image;
83073           for (i3 = 0; i3 < props.length; i3++) {
83074             prop = entity.claims[props[i3]];
83075             if (prop && Object.keys(prop).length > 0) {
83076               image = prop[Object.keys(prop)[0]].mainsnak.datavalue.value;
83077               if (image) {
83078                 result.imageURL = imageroot + "?" + utilQsString({
83079                   title: "Special:Redirect/file/" + image,
83080                   width: 400
83081                 });
83082                 break;
83083               }
83084             }
83085           }
83086         }
83087         if (entity.sitelinks) {
83088           var englishLocale = _mainLocalizer.languageCode().toLowerCase() === "en";
83089           for (i3 = 0; i3 < langs.length; i3++) {
83090             var w2 = langs[i3] + "wiki";
83091             if (entity.sitelinks[w2]) {
83092               var title = entity.sitelinks[w2].title;
83093               var tKey = "inspector.wiki_reference";
83094               if (!englishLocale && langs[i3] === "en") {
83095                 tKey = "inspector.wiki_en_reference";
83096               }
83097               result.wiki = {
83098                 title,
83099                 text: tKey,
83100                 url: "https://" + langs[i3] + ".wikipedia.org/wiki/" + title.replace(/ /g, "_")
83101               };
83102               break;
83103             }
83104           }
83105         }
83106         callback(null, result);
83107       });
83108     }
83109   };
83110
83111   // modules/services/wikipedia.js
83112   var endpoint = "https://en.wikipedia.org/w/api.php?";
83113   var wikipedia_default = {
83114     init: function() {
83115     },
83116     reset: function() {
83117     },
83118     search: function(lang, query, callback) {
83119       if (!query) {
83120         if (callback)
83121           callback("No Query", []);
83122         return;
83123       }
83124       lang = lang || "en";
83125       var url = endpoint.replace("en", lang) + utilQsString({
83126         action: "query",
83127         list: "search",
83128         srlimit: "10",
83129         srinfo: "suggestion",
83130         format: "json",
83131         origin: "*",
83132         srsearch: query
83133       });
83134       json_default(url).then(function(result) {
83135         if (result && result.error) {
83136           throw new Error(result.error);
83137         } else if (!result || !result.query || !result.query.search) {
83138           throw new Error("No Results");
83139         }
83140         if (callback) {
83141           var titles = result.query.search.map(function(d2) {
83142             return d2.title;
83143           });
83144           callback(null, titles);
83145         }
83146       }).catch(function(err) {
83147         if (callback)
83148           callback(err, []);
83149       });
83150     },
83151     suggestions: function(lang, query, callback) {
83152       if (!query) {
83153         if (callback)
83154           callback("", []);
83155         return;
83156       }
83157       lang = lang || "en";
83158       var url = endpoint.replace("en", lang) + utilQsString({
83159         action: "opensearch",
83160         namespace: 0,
83161         suggest: "",
83162         format: "json",
83163         origin: "*",
83164         search: query
83165       });
83166       json_default(url).then(function(result) {
83167         if (result && result.error) {
83168           throw new Error(result.error);
83169         } else if (!result || result.length < 2) {
83170           throw new Error("No Results");
83171         }
83172         if (callback)
83173           callback(null, result[1] || []);
83174       }).catch(function(err) {
83175         if (callback)
83176           callback(err.message, []);
83177       });
83178     },
83179     translations: function(lang, title, callback) {
83180       if (!title) {
83181         if (callback)
83182           callback("No Title");
83183         return;
83184       }
83185       var url = endpoint.replace("en", lang) + utilQsString({
83186         action: "query",
83187         prop: "langlinks",
83188         format: "json",
83189         origin: "*",
83190         lllimit: 500,
83191         titles: title
83192       });
83193       json_default(url).then(function(result) {
83194         if (result && result.error) {
83195           throw new Error(result.error);
83196         } else if (!result || !result.query || !result.query.pages) {
83197           throw new Error("No Results");
83198         }
83199         if (callback) {
83200           var list2 = result.query.pages[Object.keys(result.query.pages)[0]];
83201           var translations = {};
83202           if (list2 && list2.langlinks) {
83203             list2.langlinks.forEach(function(d2) {
83204               translations[d2.lang] = d2["*"];
83205             });
83206           }
83207           callback(null, translations);
83208         }
83209       }).catch(function(err) {
83210         if (callback)
83211           callback(err.message);
83212       });
83213     }
83214   };
83215
83216   // modules/services/mapilio.js
83217   var import_pbf3 = __toESM(require_pbf());
83218   var import_rbush12 = __toESM(require_rbush_min());
83219   var import_vector_tile3 = __toESM(require_vector_tile());
83220   var apiUrl2 = "https://end.mapilio.com";
83221   var imageBaseUrl = "https://cdn.mapilio.com/im";
83222   var baseTileUrl2 = "https://geo.mapilio.com/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=mapilio:";
83223   var pointLayer = "map_points";
83224   var lineLayer = "map_roads_line";
83225   var tileStyle = "&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";
83226   var minZoom3 = 14;
83227   var dispatch13 = dispatch_default("loadedImages", "loadedLines");
83228   var imgZoom3 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
83229   var pannellumViewerCSS3 = "pannellum/pannellum.css";
83230   var pannellumViewerJS3 = "pannellum/pannellum.js";
83231   var resolution = 1080;
83232   var _activeImage;
83233   var _cache4;
83234   var _loadViewerPromise5;
83235   var _pannellumViewer3;
83236   var _sceneOptions2 = {
83237     showFullscreenCtrl: false,
83238     autoLoad: true,
83239     yaw: 0,
83240     minHfov: 10,
83241     maxHfov: 90,
83242     hfov: 60
83243   };
83244   var _currScene2 = 0;
83245   function partitionViewport5(projection2) {
83246     const z2 = geoScaleToZoom(projection2.scale());
83247     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
83248     const tiler9 = utilTiler().zoomExtent([z22, z22]);
83249     return tiler9.getTiles(projection2).map(function(tile) {
83250       return tile.extent;
83251     });
83252   }
83253   function searchLimited5(limit, projection2, rtree) {
83254     limit = limit || 5;
83255     return partitionViewport5(projection2).reduce(function(result, extent) {
83256       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
83257         return d2.data;
83258       });
83259       return found.length ? result.concat(found) : result;
83260     }, []);
83261   }
83262   function loadTiles4(which, url, maxZoom2, projection2) {
83263     const tiler9 = utilTiler().zoomExtent([minZoom3, maxZoom2]).skipNullIsland(true);
83264     const tiles = tiler9.getTiles(projection2);
83265     tiles.forEach(function(tile) {
83266       loadTile4(which, url, tile);
83267     });
83268   }
83269   function loadTile4(which, url, tile) {
83270     const cache = _cache4.requests;
83271     const tileId = "".concat(tile.id, "-").concat(which);
83272     if (cache.loaded[tileId] || cache.inflight[tileId])
83273       return;
83274     const controller = new AbortController();
83275     cache.inflight[tileId] = controller;
83276     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
83277     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
83278       if (!response.ok) {
83279         throw new Error(response.status + " " + response.statusText);
83280       }
83281       cache.loaded[tileId] = true;
83282       delete cache.inflight[tileId];
83283       return response.arrayBuffer();
83284     }).then(function(data) {
83285       if (data.byteLength === 0) {
83286         throw new Error("No Data");
83287       }
83288       loadTileDataToCache2(data, tile, which);
83289       if (which === "images") {
83290         dispatch13.call("loadedImages");
83291       } else {
83292         dispatch13.call("loadedLines");
83293       }
83294     }).catch(function(e3) {
83295       if (e3.message === "No Data") {
83296         cache.loaded[tileId] = true;
83297       } else {
83298         console.error(e3);
83299       }
83300     });
83301   }
83302   function loadTileDataToCache2(data, tile) {
83303     const vectorTile = new import_vector_tile3.VectorTile(new import_pbf3.default(data));
83304     let features, cache, layer, i3, feature3, loc, d2;
83305     if (vectorTile.layers.hasOwnProperty(pointLayer)) {
83306       features = [];
83307       cache = _cache4.images;
83308       layer = vectorTile.layers[pointLayer];
83309       for (i3 = 0; i3 < layer.length; i3++) {
83310         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83311         loc = feature3.geometry.coordinates;
83312         let resolutionArr = feature3.properties.resolution.split("x");
83313         let sourceWidth = Math.max(resolutionArr[0], resolutionArr[1]);
83314         let sourceHeight = Math.min(resolutionArr[0], resolutionArr[1]);
83315         let isPano = sourceWidth % sourceHeight === 0;
83316         d2 = {
83317           loc,
83318           capture_time: feature3.properties.capture_time,
83319           id: feature3.properties.id,
83320           sequence_id: feature3.properties.sequence_uuid,
83321           heading: feature3.properties.heading,
83322           resolution: feature3.properties.resolution,
83323           isPano
83324         };
83325         cache.forImageId[d2.id] = d2;
83326         features.push({
83327           minX: loc[0],
83328           minY: loc[1],
83329           maxX: loc[0],
83330           maxY: loc[1],
83331           data: d2
83332         });
83333       }
83334       if (cache.rtree) {
83335         cache.rtree.load(features);
83336       }
83337     }
83338     if (vectorTile.layers.hasOwnProperty(lineLayer)) {
83339       cache = _cache4.sequences;
83340       layer = vectorTile.layers[lineLayer];
83341       for (i3 = 0; i3 < layer.length; i3++) {
83342         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83343         if (cache.lineString[feature3.properties.sequence_uuid]) {
83344           cache.lineString[feature3.properties.sequence_uuid].push(feature3);
83345         } else {
83346           cache.lineString[feature3.properties.sequence_uuid] = [feature3];
83347         }
83348       }
83349     }
83350   }
83351   function getImageData(imageId, sequenceId) {
83352     return fetch(apiUrl2 + "/api/sequence-detail?sequence_uuid=".concat(sequenceId), { method: "GET" }).then(function(response) {
83353       if (!response.ok) {
83354         throw new Error(response.status + " " + response.statusText);
83355       }
83356       return response.json();
83357     }).then(function(data) {
83358       let index = data.data.findIndex((feature3) => feature3.id === imageId);
83359       const { filename, uploaded_hash } = data.data[index];
83360       _sceneOptions2.panorama = imageBaseUrl + "/" + uploaded_hash + "/" + filename + "/" + resolution;
83361     });
83362   }
83363   var mapilio_default = {
83364     // Initialize Mapilio
83365     init: function() {
83366       if (!_cache4) {
83367         this.reset();
83368       }
83369       this.event = utilRebind(this, dispatch13, "on");
83370     },
83371     // Reset cache and state
83372     reset: function() {
83373       if (_cache4) {
83374         Object.values(_cache4.requests.inflight).forEach(function(request3) {
83375           request3.abort();
83376         });
83377       }
83378       _cache4 = {
83379         images: { rtree: new import_rbush12.default(), forImageId: {} },
83380         sequences: { rtree: new import_rbush12.default(), lineString: {} },
83381         requests: { loaded: {}, inflight: {} }
83382       };
83383       _activeImage = null;
83384     },
83385     // Get visible images
83386     images: function(projection2) {
83387       const limit = 5;
83388       return searchLimited5(limit, projection2, _cache4.images.rtree);
83389     },
83390     cachedImage: function(imageKey) {
83391       return _cache4.images.forImageId[imageKey];
83392     },
83393     // Load images in the visible area
83394     loadImages: function(projection2) {
83395       let url = baseTileUrl2 + pointLayer + tileStyle;
83396       loadTiles4("images", url, 14, projection2);
83397     },
83398     // Load line in the visible area
83399     loadLines: function(projection2) {
83400       let url = baseTileUrl2 + lineLayer + tileStyle;
83401       loadTiles4("line", url, 14, projection2);
83402     },
83403     // Get visible sequences
83404     sequences: function(projection2) {
83405       const viewport = projection2.clipExtent();
83406       const min3 = [viewport[0][0], viewport[1][1]];
83407       const max3 = [viewport[1][0], viewport[0][1]];
83408       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
83409       const sequenceIds = {};
83410       let lineStrings = [];
83411       _cache4.images.rtree.search(bbox2).forEach(function(d2) {
83412         if (d2.data.sequence_id) {
83413           sequenceIds[d2.data.sequence_id] = true;
83414         }
83415       });
83416       Object.keys(sequenceIds).forEach(function(sequenceId) {
83417         if (_cache4.sequences.lineString[sequenceId]) {
83418           lineStrings = lineStrings.concat(_cache4.sequences.lineString[sequenceId]);
83419         }
83420       });
83421       return lineStrings;
83422     },
83423     // Set the currently visible image
83424     setActiveImage: function(image) {
83425       if (image) {
83426         _activeImage = {
83427           id: image.id,
83428           sequence_id: image.sequence_id
83429         };
83430       } else {
83431         _activeImage = null;
83432       }
83433     },
83434     // Update the currently highlighted sequence and selected bubble.
83435     setStyles: function(context, hovered) {
83436       const hoveredImageId = hovered && hovered.id;
83437       const hoveredSequenceId = hovered && hovered.sequence_id;
83438       const selectedSequenceId = _activeImage && _activeImage.sequence_id;
83439       const selectedImageId = _activeImage && _activeImage.id;
83440       const markers = context.container().selectAll(".layer-mapilio .viewfield-group");
83441       const sequences = context.container().selectAll(".layer-mapilio .sequence");
83442       markers.classed("highlighted", function(d2) {
83443         return d2.id === hoveredImageId;
83444       }).classed("hovered", function(d2) {
83445         return d2.id === hoveredImageId;
83446       }).classed("currentView", function(d2) {
83447         return d2.id === selectedImageId;
83448       });
83449       sequences.classed("highlighted", function(d2) {
83450         return d2.properties.sequence_uuid === hoveredSequenceId;
83451       }).classed("currentView", function(d2) {
83452         return d2.properties.sequence_uuid === selectedSequenceId;
83453       });
83454       return this;
83455     },
83456     updateUrlImage: function(imageKey) {
83457       if (!window.mocha) {
83458         var hash = utilStringQs(window.location.hash);
83459         if (imageKey) {
83460           hash.photo = "mapilio/" + imageKey;
83461         } else {
83462           delete hash.photo;
83463         }
83464         window.location.replace("#" + utilQsString(hash, true));
83465       }
83466     },
83467     initViewer: function() {
83468       if (!window.pannellum)
83469         return;
83470       if (_pannellumViewer3)
83471         return;
83472       _currScene2 += 1;
83473       const sceneID = _currScene2.toString();
83474       const options2 = {
83475         "default": { firstScene: sceneID },
83476         scenes: {}
83477       };
83478       options2.scenes[sceneID] = _sceneOptions2;
83479       _pannellumViewer3 = window.pannellum.viewer("ideditor-viewer-mapilio-pnlm", options2);
83480     },
83481     selectImage: function(context, id2) {
83482       let that = this;
83483       let d2 = this.cachedImage(id2);
83484       this.setActiveImage(d2);
83485       this.updateUrlImage(d2.id);
83486       let viewer = context.container().select(".photoviewer");
83487       if (!viewer.empty())
83488         viewer.datum(d2);
83489       this.setStyles(context, null);
83490       if (!d2)
83491         return this;
83492       let wrap2 = context.container().select(".photoviewer .mapilio-wrapper");
83493       let attribution = wrap2.selectAll(".photo-attribution").text("");
83494       if (d2.capture_time) {
83495         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
83496         attribution.append("span").text("|");
83497       }
83498       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");
83499       wrap2.transition().duration(100).call(imgZoom3.transform, identity2);
83500       wrap2.selectAll("img").remove();
83501       wrap2.selectAll("button.back").classed("hide", !_cache4.images.forImageId.hasOwnProperty(+id2 - 1));
83502       wrap2.selectAll("button.forward").classed("hide", !_cache4.images.forImageId.hasOwnProperty(+id2 + 1));
83503       getImageData(d2.id, d2.sequence_id).then(function() {
83504         if (d2.isPano) {
83505           if (!_pannellumViewer3) {
83506             that.initViewer();
83507           } else {
83508             _currScene2 += 1;
83509             let sceneID = _currScene2.toString();
83510             _pannellumViewer3.addScene(sceneID, _sceneOptions2).loadScene(sceneID);
83511             if (_currScene2 > 2) {
83512               sceneID = (_currScene2 - 1).toString();
83513               _pannellumViewer3.removeScene(sceneID);
83514             }
83515           }
83516         } else {
83517           that.initOnlyPhoto(context);
83518         }
83519       });
83520       function localeDateString2(s2) {
83521         if (!s2)
83522           return null;
83523         var options2 = { day: "numeric", month: "short", year: "numeric" };
83524         var d4 = new Date(s2);
83525         if (isNaN(d4.getTime()))
83526           return null;
83527         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
83528       }
83529       return this;
83530     },
83531     initOnlyPhoto: function(context) {
83532       if (_pannellumViewer3) {
83533         _pannellumViewer3.destroy();
83534         _pannellumViewer3 = null;
83535       }
83536       let wrap2 = context.container().select("#ideditor-viewer-mapilio-simple");
83537       let imgWrap = wrap2.select("img");
83538       if (!imgWrap.empty()) {
83539         imgWrap.attr("src", _sceneOptions2.panorama);
83540       } else {
83541         wrap2.append("img").attr("src", _sceneOptions2.panorama);
83542       }
83543     },
83544     ensureViewerLoaded: function(context) {
83545       let that = this;
83546       let imgWrap = context.container().select("#ideditor-viewer-mapilio-simple > img");
83547       if (!imgWrap.empty()) {
83548         imgWrap.remove();
83549       }
83550       if (_loadViewerPromise5)
83551         return _loadViewerPromise5;
83552       let wrap2 = context.container().select(".photoviewer").selectAll(".mapilio-wrapper").data([0]);
83553       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null);
83554       wrapEnter.append("div").attr("class", "photo-attribution fillD");
83555       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio");
83556       controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4");
83557       controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA");
83558       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm");
83559       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple");
83560       context.ui().photoviewer.on("resize.mapilio", () => {
83561         if (_pannellumViewer3) {
83562           _pannellumViewer3.resize();
83563         }
83564       });
83565       _loadViewerPromise5 = new Promise((resolve, reject) => {
83566         let loadedCount = 0;
83567         function loaded() {
83568           loadedCount += 1;
83569           if (loadedCount === 2)
83570             resolve();
83571         }
83572         const head = select_default2("head");
83573         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() {
83574           reject();
83575         });
83576         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() {
83577           reject();
83578         });
83579       }).catch(function() {
83580         _loadViewerPromise5 = null;
83581       });
83582       function step(stepBy) {
83583         return function() {
83584           if (!_activeImage)
83585             return;
83586           const imageId = _activeImage.id;
83587           const nextIndex = imageId + stepBy;
83588           if (!nextIndex)
83589             return;
83590           const nextImage = _cache4.images.forImageId[nextIndex];
83591           context.map().centerEase(nextImage.loc);
83592           that.selectImage(context, nextImage.id);
83593         };
83594       }
83595       function zoomPan2(d3_event) {
83596         var t2 = d3_event.transform;
83597         context.container().select(".photoviewer #ideditor-viewer-mapilio-simple").call(utilSetTransform, t2.x, t2.y, t2.k);
83598       }
83599       return _loadViewerPromise5;
83600     },
83601     showViewer: function(context) {
83602       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
83603       let isHidden = wrap2.selectAll(".photo-wrapper.mapilio-wrapper.hide").size();
83604       if (isHidden) {
83605         wrap2.selectAll(".photo-wrapper:not(.mapilio-wrapper)").classed("hide", true);
83606         wrap2.selectAll(".photo-wrapper.mapilio-wrapper").classed("hide", false);
83607       }
83608       return this;
83609     },
83610     /**
83611      * hideViewer()
83612      */
83613     hideViewer: function(context) {
83614       let viewer = context.container().select(".photoviewer");
83615       if (!viewer.empty())
83616         viewer.datum(null);
83617       this.updateUrlImage(null);
83618       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
83619       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
83620       this.setActiveImage();
83621       return this.setStyles(context, null);
83622     },
83623     // Return the current cache
83624     cache: function() {
83625       return _cache4;
83626     }
83627   };
83628
83629   // modules/services/index.js
83630   var services = {
83631     geocoder: nominatim_default,
83632     keepRight: keepRight_default,
83633     improveOSM: improveOSM_default,
83634     osmose: osmose_default,
83635     mapillary: mapillary_default,
83636     nsi: nsi_default,
83637     kartaview: kartaview_default,
83638     vegbilder: vegbilder_default,
83639     osm: osm_default,
83640     osmWikibase: osm_wikibase_default,
83641     maprules: maprules_default,
83642     streetside: streetside_default,
83643     taginfo: taginfo_default,
83644     vectorTile: vector_tile_default,
83645     wikidata: wikidata_default,
83646     wikipedia: wikipedia_default,
83647     mapilio: mapilio_default
83648   };
83649
83650   // modules/modes/drag_note.js
83651   function modeDragNote(context) {
83652     var mode = {
83653       id: "drag-note",
83654       button: "browse"
83655     };
83656     var edit2 = behaviorEdit(context);
83657     var _nudgeInterval;
83658     var _lastLoc;
83659     var _note;
83660     function startNudge(d3_event, nudge) {
83661       if (_nudgeInterval)
83662         window.clearInterval(_nudgeInterval);
83663       _nudgeInterval = window.setInterval(function() {
83664         context.map().pan(nudge);
83665         doMove(d3_event, nudge);
83666       }, 50);
83667     }
83668     function stopNudge() {
83669       if (_nudgeInterval) {
83670         window.clearInterval(_nudgeInterval);
83671         _nudgeInterval = null;
83672       }
83673     }
83674     function origin(note) {
83675       return context.projection(note.loc);
83676     }
83677     function start2(d3_event, note) {
83678       _note = note;
83679       var osm = services.osm;
83680       if (osm) {
83681         _note = osm.getNote(_note.id);
83682       }
83683       context.surface().selectAll(".note-" + _note.id).classed("active", true);
83684       context.perform(actionNoop());
83685       context.enter(mode);
83686       context.selectedNoteID(_note.id);
83687     }
83688     function move(d3_event, entity, point2) {
83689       d3_event.stopPropagation();
83690       _lastLoc = context.projection.invert(point2);
83691       doMove(d3_event);
83692       var nudge = geoViewportEdge(point2, context.map().dimensions());
83693       if (nudge) {
83694         startNudge(d3_event, nudge);
83695       } else {
83696         stopNudge();
83697       }
83698     }
83699     function doMove(d3_event, nudge) {
83700       nudge = nudge || [0, 0];
83701       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
83702       var currMouse = geoVecSubtract(currPoint, nudge);
83703       var loc = context.projection.invert(currMouse);
83704       _note = _note.move(loc);
83705       var osm = services.osm;
83706       if (osm) {
83707         osm.replaceNote(_note);
83708       }
83709       context.replace(actionNoop());
83710     }
83711     function end() {
83712       context.replace(actionNoop());
83713       context.selectedNoteID(_note.id).enter(modeSelectNote(context, _note.id));
83714     }
83715     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);
83716     mode.enter = function() {
83717       context.install(edit2);
83718     };
83719     mode.exit = function() {
83720       context.ui().sidebar.hover.cancel();
83721       context.uninstall(edit2);
83722       context.surface().selectAll(".active").classed("active", false);
83723       stopNudge();
83724     };
83725     mode.behavior = drag;
83726     return mode;
83727   }
83728
83729   // modules/modes/select_data.js
83730   function modeSelectData(context, selectedDatum) {
83731     var mode = {
83732       id: "select-data",
83733       button: "browse"
83734     };
83735     var keybinding = utilKeybinding("select-data");
83736     var dataEditor = uiDataEditor(context);
83737     var behaviors = [
83738       behaviorBreathe(context),
83739       behaviorHover(context),
83740       behaviorSelect(context),
83741       behaviorLasso(context),
83742       modeDragNode(context).behavior,
83743       modeDragNote(context).behavior
83744     ];
83745     function selectData(d3_event, drawn) {
83746       var selection2 = context.surface().selectAll(".layer-mapdata .data" + selectedDatum.__featurehash__);
83747       if (selection2.empty()) {
83748         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
83749         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
83750           context.enter(modeBrowse(context));
83751         }
83752       } else {
83753         selection2.classed("selected", true);
83754       }
83755     }
83756     function esc() {
83757       if (context.container().select(".combobox").size())
83758         return;
83759       context.enter(modeBrowse(context));
83760     }
83761     mode.zoomToSelected = function() {
83762       var extent = geoExtent(bounds_default(selectedDatum));
83763       context.map().centerZoomEase(extent.center(), context.map().trimmedExtentZoom(extent));
83764     };
83765     mode.enter = function() {
83766       behaviors.forEach(context.install);
83767       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
83768       select_default2(document).call(keybinding);
83769       selectData();
83770       var sidebar = context.ui().sidebar;
83771       sidebar.show(dataEditor.datum(selectedDatum));
83772       var extent = geoExtent(bounds_default(selectedDatum));
83773       sidebar.expand(sidebar.intersects(extent));
83774       context.map().on("drawn.select-data", selectData);
83775     };
83776     mode.exit = function() {
83777       behaviors.forEach(context.uninstall);
83778       select_default2(document).call(keybinding.unbind);
83779       context.surface().selectAll(".layer-mapdata .selected").classed("selected hover", false);
83780       context.map().on("drawn.select-data", null);
83781       context.ui().sidebar.hide();
83782     };
83783     return mode;
83784   }
83785
83786   // modules/behavior/select.js
83787   function behaviorSelect(context) {
83788     var _tolerancePx = 4;
83789     var _lastMouseEvent = null;
83790     var _showMenu = false;
83791     var _downPointers = {};
83792     var _longPressTimeout = null;
83793     var _lastInteractionType = null;
83794     var _multiselectionPointerId = null;
83795     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
83796     function keydown(d3_event) {
83797       if (d3_event.keyCode === 32) {
83798         var activeNode = document.activeElement;
83799         if (activeNode && (/* @__PURE__ */ new Set(["INPUT", "TEXTAREA"])).has(activeNode.nodeName))
83800           return;
83801       }
83802       if (d3_event.keyCode === 93 || // context menu key
83803       d3_event.keyCode === 32) {
83804         d3_event.preventDefault();
83805       }
83806       if (d3_event.repeat)
83807         return;
83808       cancelLongPress();
83809       if (d3_event.shiftKey) {
83810         context.surface().classed("behavior-multiselect", true);
83811       }
83812       if (d3_event.keyCode === 32) {
83813         if (!_downPointers.spacebar && _lastMouseEvent) {
83814           cancelLongPress();
83815           _longPressTimeout = window.setTimeout(didLongPress, 500, "spacebar", "spacebar");
83816           _downPointers.spacebar = {
83817             firstEvent: _lastMouseEvent,
83818             lastEvent: _lastMouseEvent
83819           };
83820         }
83821       }
83822     }
83823     function keyup(d3_event) {
83824       cancelLongPress();
83825       if (!d3_event.shiftKey) {
83826         context.surface().classed("behavior-multiselect", false);
83827       }
83828       if (d3_event.keyCode === 93) {
83829         d3_event.preventDefault();
83830         _lastInteractionType = "menukey";
83831         contextmenu(d3_event);
83832       } else if (d3_event.keyCode === 32) {
83833         var pointer = _downPointers.spacebar;
83834         if (pointer) {
83835           delete _downPointers.spacebar;
83836           if (pointer.done)
83837             return;
83838           d3_event.preventDefault();
83839           _lastInteractionType = "spacebar";
83840           click(pointer.firstEvent, pointer.lastEvent, "spacebar");
83841         }
83842       }
83843     }
83844     function pointerdown(d3_event) {
83845       var id2 = (d3_event.pointerId || "mouse").toString();
83846       cancelLongPress();
83847       if (d3_event.buttons && d3_event.buttons !== 1)
83848         return;
83849       context.ui().closeEditMenu();
83850       if (d3_event.pointerType !== "mouse") {
83851         _longPressTimeout = window.setTimeout(didLongPress, 500, id2, "longdown-" + (d3_event.pointerType || "mouse"));
83852       }
83853       _downPointers[id2] = {
83854         firstEvent: d3_event,
83855         lastEvent: d3_event
83856       };
83857     }
83858     function didLongPress(id2, interactionType) {
83859       var pointer = _downPointers[id2];
83860       if (!pointer)
83861         return;
83862       for (var i3 in _downPointers) {
83863         _downPointers[i3].done = true;
83864       }
83865       _longPressTimeout = null;
83866       _lastInteractionType = interactionType;
83867       _showMenu = true;
83868       click(pointer.firstEvent, pointer.lastEvent, id2);
83869     }
83870     function pointermove(d3_event) {
83871       var id2 = (d3_event.pointerId || "mouse").toString();
83872       if (_downPointers[id2]) {
83873         _downPointers[id2].lastEvent = d3_event;
83874       }
83875       if (!d3_event.pointerType || d3_event.pointerType === "mouse") {
83876         _lastMouseEvent = d3_event;
83877         if (_downPointers.spacebar) {
83878           _downPointers.spacebar.lastEvent = d3_event;
83879         }
83880       }
83881     }
83882     function pointerup(d3_event) {
83883       var id2 = (d3_event.pointerId || "mouse").toString();
83884       var pointer = _downPointers[id2];
83885       if (!pointer)
83886         return;
83887       delete _downPointers[id2];
83888       if (_multiselectionPointerId === id2) {
83889         _multiselectionPointerId = null;
83890       }
83891       if (pointer.done)
83892         return;
83893       click(pointer.firstEvent, d3_event, id2);
83894     }
83895     function pointercancel(d3_event) {
83896       var id2 = (d3_event.pointerId || "mouse").toString();
83897       if (!_downPointers[id2])
83898         return;
83899       delete _downPointers[id2];
83900       if (_multiselectionPointerId === id2) {
83901         _multiselectionPointerId = null;
83902       }
83903     }
83904     function contextmenu(d3_event) {
83905       d3_event.preventDefault();
83906       if (!+d3_event.clientX && !+d3_event.clientY) {
83907         if (_lastMouseEvent) {
83908           d3_event = _lastMouseEvent;
83909         } else {
83910           return;
83911         }
83912       } else {
83913         _lastMouseEvent = d3_event;
83914         if (d3_event.pointerType === "touch" || d3_event.pointerType === "pen" || d3_event.mozInputSource && // firefox doesn't give a pointerType on contextmenu events
83915         (d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_TOUCH || d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_PEN)) {
83916           _lastInteractionType = "touch";
83917         } else {
83918           _lastInteractionType = "rightclick";
83919         }
83920       }
83921       _showMenu = true;
83922       click(d3_event, d3_event);
83923     }
83924     function click(firstEvent, lastEvent, pointerId) {
83925       cancelLongPress();
83926       var mapNode = context.container().select(".main-map").node();
83927       var pointGetter = utilFastMouse(mapNode);
83928       var p1 = pointGetter(firstEvent);
83929       var p2 = pointGetter(lastEvent);
83930       var dist = geoVecLength(p1, p2);
83931       if (dist > _tolerancePx || !mapContains(lastEvent)) {
83932         resetProperties();
83933         return;
83934       }
83935       var targetDatum = lastEvent.target.__data__;
83936       var multiselectEntityId;
83937       if (!_multiselectionPointerId) {
83938         var selectPointerInfo = pointerDownOnSelection(pointerId);
83939         if (selectPointerInfo) {
83940           _multiselectionPointerId = selectPointerInfo.pointerId;
83941           multiselectEntityId = !selectPointerInfo.selected && selectPointerInfo.entityId;
83942           _downPointers[selectPointerInfo.pointerId].done = true;
83943         }
83944       }
83945       var isMultiselect = context.mode().id === "select" && // and shift key is down
83946       (lastEvent && lastEvent.shiftKey || // or we're lasso-selecting
83947       context.surface().select(".lasso").node() || // or a pointer is down over a selected feature
83948       _multiselectionPointerId && !multiselectEntityId);
83949       processClick(targetDatum, isMultiselect, p2, multiselectEntityId);
83950       function mapContains(event) {
83951         var rect = mapNode.getBoundingClientRect();
83952         return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
83953       }
83954       function pointerDownOnSelection(skipPointerId) {
83955         var mode = context.mode();
83956         var selectedIDs = mode.id === "select" ? mode.selectedIDs() : [];
83957         for (var pointerId2 in _downPointers) {
83958           if (pointerId2 === "spacebar" || pointerId2 === skipPointerId)
83959             continue;
83960           var pointerInfo = _downPointers[pointerId2];
83961           var p12 = pointGetter(pointerInfo.firstEvent);
83962           var p22 = pointGetter(pointerInfo.lastEvent);
83963           if (geoVecLength(p12, p22) > _tolerancePx)
83964             continue;
83965           var datum2 = pointerInfo.firstEvent.target.__data__;
83966           var entity = datum2 && datum2.properties && datum2.properties.entity || datum2;
83967           if (context.graph().hasEntity(entity.id)) {
83968             return {
83969               pointerId: pointerId2,
83970               entityId: entity.id,
83971               selected: selectedIDs.indexOf(entity.id) !== -1
83972             };
83973           }
83974         }
83975         return null;
83976       }
83977     }
83978     function processClick(datum2, isMultiselect, point2, alsoSelectId) {
83979       var mode = context.mode();
83980       var showMenu = _showMenu;
83981       var interactionType = _lastInteractionType;
83982       var entity = datum2 && datum2.properties && datum2.properties.entity;
83983       if (entity)
83984         datum2 = entity;
83985       if (datum2 && datum2.type === "midpoint") {
83986         datum2 = datum2.parents[0];
83987       }
83988       var newMode;
83989       if (datum2 instanceof osmEntity) {
83990         var selectedIDs = context.selectedIDs();
83991         context.selectedNoteID(null);
83992         context.selectedErrorID(null);
83993         if (!isMultiselect) {
83994           if (!showMenu || selectedIDs.length <= 1 || selectedIDs.indexOf(datum2.id) === -1) {
83995             if (alsoSelectId === datum2.id)
83996               alsoSelectId = null;
83997             selectedIDs = (alsoSelectId ? [alsoSelectId] : []).concat([datum2.id]);
83998             newMode = mode.id === "select" ? mode.selectedIDs(selectedIDs) : modeSelect(context, selectedIDs).selectBehavior(behavior);
83999             context.enter(newMode);
84000           }
84001         } else {
84002           if (selectedIDs.indexOf(datum2.id) !== -1) {
84003             if (!showMenu) {
84004               selectedIDs = selectedIDs.filter(function(id2) {
84005                 return id2 !== datum2.id;
84006               });
84007               newMode = selectedIDs.length ? mode.selectedIDs(selectedIDs) : modeBrowse(context).selectBehavior(behavior);
84008               context.enter(newMode);
84009             }
84010           } else {
84011             selectedIDs = selectedIDs.concat([datum2.id]);
84012             newMode = mode.selectedIDs(selectedIDs);
84013             context.enter(newMode);
84014           }
84015         }
84016       } else if (datum2 && datum2.__featurehash__ && !isMultiselect) {
84017         context.selectedNoteID(null).enter(modeSelectData(context, datum2));
84018       } else if (datum2 instanceof osmNote && !isMultiselect) {
84019         context.selectedNoteID(datum2.id).enter(modeSelectNote(context, datum2.id));
84020       } else if (datum2 instanceof QAItem && !isMultiselect) {
84021         context.selectedErrorID(datum2.id).enter(modeSelectError(context, datum2.id, datum2.service));
84022       } else {
84023         context.selectedNoteID(null);
84024         context.selectedErrorID(null);
84025         if (!isMultiselect && mode.id !== "browse") {
84026           context.enter(modeBrowse(context));
84027         }
84028       }
84029       context.ui().closeEditMenu();
84030       if (showMenu)
84031         context.ui().showEditMenu(point2, interactionType);
84032       resetProperties();
84033     }
84034     function cancelLongPress() {
84035       if (_longPressTimeout)
84036         window.clearTimeout(_longPressTimeout);
84037       _longPressTimeout = null;
84038     }
84039     function resetProperties() {
84040       cancelLongPress();
84041       _showMenu = false;
84042       _lastInteractionType = null;
84043     }
84044     function behavior(selection2) {
84045       resetProperties();
84046       _lastMouseEvent = context.map().lastPointerEvent();
84047       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) {
84048         var e3 = d3_event;
84049         if (+e3.clientX === 0 && +e3.clientY === 0) {
84050           d3_event.preventDefault();
84051         }
84052       });
84053       selection2.on(_pointerPrefix + "down.select", pointerdown).on("contextmenu.select", contextmenu);
84054     }
84055     behavior.off = function(selection2) {
84056       cancelLongPress();
84057       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);
84058       selection2.on(_pointerPrefix + "down.select", null).on("contextmenu.select", null);
84059       context.surface().classed("behavior-multiselect", false);
84060     };
84061     return behavior;
84062   }
84063
84064   // modules/operations/index.js
84065   var operations_exports = {};
84066   __export(operations_exports, {
84067     operationCircularize: () => operationCircularize,
84068     operationContinue: () => operationContinue,
84069     operationCopy: () => operationCopy,
84070     operationDelete: () => operationDelete,
84071     operationDisconnect: () => operationDisconnect,
84072     operationDowngrade: () => operationDowngrade,
84073     operationExtract: () => operationExtract,
84074     operationMerge: () => operationMerge,
84075     operationMove: () => operationMove,
84076     operationOrthogonalize: () => operationOrthogonalize,
84077     operationPaste: () => operationPaste,
84078     operationReflectLong: () => operationReflectLong,
84079     operationReflectShort: () => operationReflectShort,
84080     operationReverse: () => operationReverse,
84081     operationRotate: () => operationRotate,
84082     operationSplit: () => operationSplit,
84083     operationStraighten: () => operationStraighten
84084   });
84085
84086   // modules/operations/continue.js
84087   function operationContinue(context, selectedIDs) {
84088     var _entities = selectedIDs.map(function(id2) {
84089       return context.graph().entity(id2);
84090     });
84091     var _geometries = Object.assign(
84092       { line: [], vertex: [] },
84093       utilArrayGroupBy(_entities, function(entity) {
84094         return entity.geometry(context.graph());
84095       })
84096     );
84097     var _vertex = _geometries.vertex.length && _geometries.vertex[0];
84098     function candidateWays() {
84099       return _vertex ? context.graph().parentWays(_vertex).filter(function(parent) {
84100         return parent.geometry(context.graph()) === "line" && !parent.isClosed() && parent.affix(_vertex.id) && (_geometries.line.length === 0 || _geometries.line[0] === parent);
84101       }) : [];
84102     }
84103     var _candidates = candidateWays();
84104     var operation2 = function() {
84105       var candidate = _candidates[0];
84106       context.enter(
84107         modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true)
84108       );
84109     };
84110     operation2.relatedEntityIds = function() {
84111       return _candidates.length ? [_candidates[0].id] : [];
84112     };
84113     operation2.available = function() {
84114       return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph());
84115     };
84116     operation2.disabled = function() {
84117       if (_candidates.length === 0) {
84118         return "not_eligible";
84119       } else if (_candidates.length > 1) {
84120         return "multiple";
84121       }
84122       return false;
84123     };
84124     operation2.tooltip = function() {
84125       var disable = operation2.disabled();
84126       return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description");
84127     };
84128     operation2.annotation = function() {
84129       return _t("operations.continue.annotation.line");
84130     };
84131     operation2.id = "continue";
84132     operation2.keys = [_t("operations.continue.key")];
84133     operation2.title = _t.append("operations.continue.title");
84134     operation2.behavior = behaviorOperation(context).which(operation2);
84135     return operation2;
84136   }
84137
84138   // modules/operations/copy.js
84139   function operationCopy(context, selectedIDs) {
84140     function getFilteredIdsToCopy() {
84141       return selectedIDs.filter(function(selectedID) {
84142         var entity = context.graph().hasEntity(selectedID);
84143         return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex";
84144       });
84145     }
84146     var operation2 = function() {
84147       var graph = context.graph();
84148       var selected = groupEntities(getFilteredIdsToCopy(), graph);
84149       var canCopy = [];
84150       var skip = {};
84151       var entity;
84152       var i3;
84153       for (i3 = 0; i3 < selected.relation.length; i3++) {
84154         entity = selected.relation[i3];
84155         if (!skip[entity.id] && entity.isComplete(graph)) {
84156           canCopy.push(entity.id);
84157           skip = getDescendants(entity.id, graph, skip);
84158         }
84159       }
84160       for (i3 = 0; i3 < selected.way.length; i3++) {
84161         entity = selected.way[i3];
84162         if (!skip[entity.id]) {
84163           canCopy.push(entity.id);
84164           skip = getDescendants(entity.id, graph, skip);
84165         }
84166       }
84167       for (i3 = 0; i3 < selected.node.length; i3++) {
84168         entity = selected.node[i3];
84169         if (!skip[entity.id]) {
84170           canCopy.push(entity.id);
84171         }
84172       }
84173       context.copyIDs(canCopy);
84174       if (_point && (canCopy.length !== 1 || graph.entity(canCopy[0]).type !== "node")) {
84175         context.copyLonLat(context.projection.invert(_point));
84176       } else {
84177         context.copyLonLat(null);
84178       }
84179     };
84180     function groupEntities(ids, graph) {
84181       var entities = ids.map(function(id2) {
84182         return graph.entity(id2);
84183       });
84184       return Object.assign(
84185         { relation: [], way: [], node: [] },
84186         utilArrayGroupBy(entities, "type")
84187       );
84188     }
84189     function getDescendants(id2, graph, descendants) {
84190       var entity = graph.entity(id2);
84191       var children2;
84192       descendants = descendants || {};
84193       if (entity.type === "relation") {
84194         children2 = entity.members.map(function(m2) {
84195           return m2.id;
84196         });
84197       } else if (entity.type === "way") {
84198         children2 = entity.nodes;
84199       } else {
84200         children2 = [];
84201       }
84202       for (var i3 = 0; i3 < children2.length; i3++) {
84203         if (!descendants[children2[i3]]) {
84204           descendants[children2[i3]] = true;
84205           descendants = getDescendants(children2[i3], graph, descendants);
84206         }
84207       }
84208       return descendants;
84209     }
84210     operation2.available = function() {
84211       return getFilteredIdsToCopy().length > 0;
84212     };
84213     operation2.disabled = function() {
84214       var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph());
84215       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
84216         return "too_large";
84217       }
84218       return false;
84219     };
84220     operation2.availableForKeypress = function() {
84221       var selection2 = window.getSelection && window.getSelection();
84222       return !selection2 || !selection2.toString();
84223     };
84224     operation2.tooltip = function() {
84225       var disable = operation2.disabled();
84226       return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length });
84227     };
84228     operation2.annotation = function() {
84229       return _t("operations.copy.annotation", { n: selectedIDs.length });
84230     };
84231     var _point;
84232     operation2.point = function(val) {
84233       _point = val;
84234       return operation2;
84235     };
84236     operation2.id = "copy";
84237     operation2.keys = [uiCmd("\u2318C")];
84238     operation2.title = _t.append("operations.copy.title");
84239     operation2.behavior = behaviorOperation(context).which(operation2);
84240     return operation2;
84241   }
84242
84243   // modules/operations/disconnect.js
84244   function operationDisconnect(context, selectedIDs) {
84245     var _vertexIDs = [];
84246     var _wayIDs = [];
84247     var _otherIDs = [];
84248     var _actions = [];
84249     selectedIDs.forEach(function(id2) {
84250       var entity = context.entity(id2);
84251       if (entity.type === "way") {
84252         _wayIDs.push(id2);
84253       } else if (entity.geometry(context.graph()) === "vertex") {
84254         _vertexIDs.push(id2);
84255       } else {
84256         _otherIDs.push(id2);
84257       }
84258     });
84259     var _coords, _descriptionID = "", _annotationID = "features";
84260     var _disconnectingVertexIds = [];
84261     var _disconnectingWayIds = [];
84262     if (_vertexIDs.length > 0) {
84263       _disconnectingVertexIds = _vertexIDs;
84264       _vertexIDs.forEach(function(vertexID) {
84265         var action = actionDisconnect(vertexID);
84266         if (_wayIDs.length > 0) {
84267           var waysIDsForVertex = _wayIDs.filter(function(wayID) {
84268             var way = context.entity(wayID);
84269             return way.nodes.indexOf(vertexID) !== -1;
84270           });
84271           action.limitWays(waysIDsForVertex);
84272         }
84273         _actions.push(action);
84274         _disconnectingWayIds = _disconnectingWayIds.concat(context.graph().parentWays(context.graph().entity(vertexID)).map((d2) => d2.id));
84275       });
84276       _disconnectingWayIds = utilArrayUniq(_disconnectingWayIds).filter(function(id2) {
84277         return _wayIDs.indexOf(id2) === -1;
84278       });
84279       _descriptionID += _actions.length === 1 ? "single_point." : "multiple_points.";
84280       if (_wayIDs.length === 1) {
84281         _descriptionID += "single_way." + context.graph().geometry(_wayIDs[0]);
84282       } else {
84283         _descriptionID += _wayIDs.length === 0 ? "no_ways" : "multiple_ways";
84284       }
84285     } else if (_wayIDs.length > 0) {
84286       var ways = _wayIDs.map(function(id2) {
84287         return context.entity(id2);
84288       });
84289       var nodes = utilGetAllNodes(_wayIDs, context.graph());
84290       _coords = nodes.map(function(n3) {
84291         return n3.loc;
84292       });
84293       var sharedActions = [];
84294       var sharedNodes = [];
84295       var unsharedActions = [];
84296       var unsharedNodes = [];
84297       nodes.forEach(function(node) {
84298         var action = actionDisconnect(node.id).limitWays(_wayIDs);
84299         if (action.disabled(context.graph()) !== "not_connected") {
84300           var count = 0;
84301           for (var i3 in ways) {
84302             var way = ways[i3];
84303             if (way.nodes.indexOf(node.id) !== -1) {
84304               count += 1;
84305             }
84306             if (count > 1)
84307               break;
84308           }
84309           if (count > 1) {
84310             sharedActions.push(action);
84311             sharedNodes.push(node);
84312           } else {
84313             unsharedActions.push(action);
84314             unsharedNodes.push(node);
84315           }
84316         }
84317       });
84318       _descriptionID += "no_points.";
84319       _descriptionID += _wayIDs.length === 1 ? "single_way." : "multiple_ways.";
84320       if (sharedActions.length) {
84321         _actions = sharedActions;
84322         _disconnectingVertexIds = sharedNodes.map((node) => node.id);
84323         _descriptionID += "conjoined";
84324         _annotationID = "from_each_other";
84325       } else {
84326         _actions = unsharedActions;
84327         _disconnectingVertexIds = unsharedNodes.map((node) => node.id);
84328         if (_wayIDs.length === 1) {
84329           _descriptionID += context.graph().geometry(_wayIDs[0]);
84330         } else {
84331           _descriptionID += "separate";
84332         }
84333       }
84334     }
84335     var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph());
84336     var operation2 = function() {
84337       context.perform(function(graph) {
84338         return _actions.reduce(function(graph2, action) {
84339           return action(graph2);
84340         }, graph);
84341       }, operation2.annotation());
84342       context.validator().validate();
84343     };
84344     operation2.relatedEntityIds = function() {
84345       if (_vertexIDs.length) {
84346         return _disconnectingWayIds;
84347       }
84348       return _disconnectingVertexIds;
84349     };
84350     operation2.available = function() {
84351       if (_actions.length === 0)
84352         return false;
84353       if (_otherIDs.length !== 0)
84354         return false;
84355       if (_vertexIDs.length !== 0 && _wayIDs.length !== 0 && !_wayIDs.every(function(wayID) {
84356         return _vertexIDs.some(function(vertexID) {
84357           var way = context.entity(wayID);
84358           return way.nodes.indexOf(vertexID) !== -1;
84359         });
84360       }))
84361         return false;
84362       return true;
84363     };
84364     operation2.disabled = function() {
84365       var reason;
84366       for (var actionIndex in _actions) {
84367         reason = _actions[actionIndex].disabled(context.graph());
84368         if (reason)
84369           return reason;
84370       }
84371       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84372         return "too_large." + ((_vertexIDs.length ? _vertexIDs : _wayIDs).length === 1 ? "single" : "multiple");
84373       } else if (_coords && someMissing()) {
84374         return "not_downloaded";
84375       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84376         return "connected_to_hidden";
84377       }
84378       return false;
84379       function someMissing() {
84380         if (context.inIntro())
84381           return false;
84382         var osm = context.connection();
84383         if (osm) {
84384           var missing = _coords.filter(function(loc) {
84385             return !osm.isDataLoaded(loc);
84386           });
84387           if (missing.length) {
84388             missing.forEach(function(loc) {
84389               context.loadTileAtLoc(loc);
84390             });
84391             return true;
84392           }
84393         }
84394         return false;
84395       }
84396     };
84397     operation2.tooltip = function() {
84398       var disable = operation2.disabled();
84399       return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID);
84400     };
84401     operation2.annotation = function() {
84402       return _t("operations.disconnect.annotation." + _annotationID);
84403     };
84404     operation2.id = "disconnect";
84405     operation2.keys = [_t("operations.disconnect.key")];
84406     operation2.title = _t.append("operations.disconnect.title");
84407     operation2.behavior = behaviorOperation(context).which(operation2);
84408     return operation2;
84409   }
84410
84411   // modules/operations/downgrade.js
84412   function operationDowngrade(context, selectedIDs) {
84413     var _affectedFeatureCount = 0;
84414     var _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
84415     var _multi = _affectedFeatureCount === 1 ? "single" : "multiple";
84416     function downgradeTypeForEntityIDs(entityIds) {
84417       var downgradeType;
84418       _affectedFeatureCount = 0;
84419       for (var i3 in entityIds) {
84420         var entityID = entityIds[i3];
84421         var type2 = downgradeTypeForEntityID(entityID);
84422         if (type2) {
84423           _affectedFeatureCount += 1;
84424           if (downgradeType && type2 !== downgradeType) {
84425             if (downgradeType !== "generic" && type2 !== "generic") {
84426               downgradeType = "building_address";
84427             } else {
84428               downgradeType = "generic";
84429             }
84430           } else {
84431             downgradeType = type2;
84432           }
84433         }
84434       }
84435       return downgradeType;
84436     }
84437     function downgradeTypeForEntityID(entityID) {
84438       var graph = context.graph();
84439       var entity = graph.entity(entityID);
84440       var preset = _mainPresetIndex.match(entity, graph);
84441       if (!preset || preset.isFallback())
84442         return null;
84443       if (entity.type === "node" && preset.id !== "address" && Object.keys(entity.tags).some(function(key) {
84444         return key.match(/^addr:.{1,}/);
84445       })) {
84446         return "address";
84447       }
84448       var geometry = entity.geometry(graph);
84449       if (geometry === "area" && entity.tags.building && !preset.tags.building) {
84450         return "building";
84451       }
84452       if (geometry === "vertex" && Object.keys(entity.tags).length) {
84453         return "generic";
84454       }
84455       return null;
84456     }
84457     var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"];
84458     var addressKeysToKeep = ["source"];
84459     var operation2 = function() {
84460       context.perform(function(graph) {
84461         for (var i3 in selectedIDs) {
84462           var entityID = selectedIDs[i3];
84463           var type2 = downgradeTypeForEntityID(entityID);
84464           if (!type2)
84465             continue;
84466           var tags = Object.assign({}, graph.entity(entityID).tags);
84467           for (var key in tags) {
84468             if (type2 === "address" && addressKeysToKeep.indexOf(key) !== -1)
84469               continue;
84470             if (type2 === "building") {
84471               if (buildingKeysToKeep.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
84472                 continue;
84473             }
84474             if (type2 !== "generic") {
84475               if (key.match(/^addr:.{1,}/) || key.match(/^source:.{1,}/))
84476                 continue;
84477             }
84478             delete tags[key];
84479           }
84480           graph = actionChangeTags(entityID, tags)(graph);
84481         }
84482         return graph;
84483       }, operation2.annotation());
84484       context.validator().validate();
84485       context.enter(modeSelect(context, selectedIDs));
84486     };
84487     operation2.available = function() {
84488       return _downgradeType;
84489     };
84490     operation2.disabled = function() {
84491       if (selectedIDs.some(hasWikidataTag)) {
84492         return "has_wikidata_tag";
84493       }
84494       return false;
84495       function hasWikidataTag(id2) {
84496         var entity = context.entity(id2);
84497         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
84498       }
84499     };
84500     operation2.tooltip = function() {
84501       var disable = operation2.disabled();
84502       return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType);
84503     };
84504     operation2.annotation = function() {
84505       var suffix;
84506       if (_downgradeType === "building_address") {
84507         suffix = "generic";
84508       } else {
84509         suffix = _downgradeType;
84510       }
84511       return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount });
84512     };
84513     operation2.id = "downgrade";
84514     operation2.keys = [uiCmd("\u232B")];
84515     operation2.title = _t.append("operations.downgrade.title");
84516     operation2.behavior = behaviorOperation(context).which(operation2);
84517     return operation2;
84518   }
84519
84520   // modules/operations/extract.js
84521   function operationExtract(context, selectedIDs) {
84522     var _amount = selectedIDs.length === 1 ? "single" : "multiple";
84523     var _geometries = utilArrayUniq(selectedIDs.map(function(entityID) {
84524       return context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
84525     }).filter(Boolean));
84526     var _geometryID = _geometries.length === 1 ? _geometries[0] : "feature";
84527     var _extent;
84528     var _actions = selectedIDs.map(function(entityID) {
84529       var graph = context.graph();
84530       var entity = graph.hasEntity(entityID);
84531       if (!entity || !entity.hasInterestingTags())
84532         return null;
84533       if (entity.type === "node" && graph.parentWays(entity).length === 0)
84534         return null;
84535       if (entity.type !== "node") {
84536         var preset = _mainPresetIndex.match(entity, graph);
84537         if (preset.geometry.indexOf("point") === -1)
84538           return null;
84539       }
84540       _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph);
84541       return actionExtract(entityID, context.projection);
84542     }).filter(Boolean);
84543     var operation2 = function() {
84544       var combinedAction = function(graph) {
84545         _actions.forEach(function(action) {
84546           graph = action(graph);
84547         });
84548         return graph;
84549       };
84550       context.perform(combinedAction, operation2.annotation());
84551       var extractedNodeIDs = _actions.map(function(action) {
84552         return action.getExtractedNodeID();
84553       });
84554       context.enter(modeSelect(context, extractedNodeIDs));
84555     };
84556     operation2.available = function() {
84557       return _actions.length && selectedIDs.length === _actions.length;
84558     };
84559     operation2.disabled = function() {
84560       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84561         return "too_large";
84562       } else if (selectedIDs.some(function(entityID) {
84563         return context.graph().geometry(entityID) === "vertex" && context.hasHiddenConnections(entityID);
84564       })) {
84565         return "connected_to_hidden";
84566       }
84567       return false;
84568     };
84569     operation2.tooltip = function() {
84570       var disableReason = operation2.disabled();
84571       if (disableReason) {
84572         return _t.append("operations.extract." + disableReason + "." + _amount);
84573       } else {
84574         return _t.append("operations.extract.description." + _geometryID + "." + _amount);
84575       }
84576     };
84577     operation2.annotation = function() {
84578       return _t("operations.extract.annotation", { n: selectedIDs.length });
84579     };
84580     operation2.id = "extract";
84581     operation2.keys = [_t("operations.extract.key")];
84582     operation2.title = _t.append("operations.extract.title");
84583     operation2.behavior = behaviorOperation(context).which(operation2);
84584     return operation2;
84585   }
84586
84587   // modules/operations/merge.js
84588   function operationMerge(context, selectedIDs) {
84589     var _action = getAction();
84590     function getAction() {
84591       var join = actionJoin(selectedIDs);
84592       if (!join.disabled(context.graph()))
84593         return join;
84594       var merge2 = actionMerge(selectedIDs);
84595       if (!merge2.disabled(context.graph()))
84596         return merge2;
84597       var mergePolygon = actionMergePolygon(selectedIDs);
84598       if (!mergePolygon.disabled(context.graph()))
84599         return mergePolygon;
84600       var mergeNodes = actionMergeNodes(selectedIDs);
84601       if (!mergeNodes.disabled(context.graph()))
84602         return mergeNodes;
84603       if (join.disabled(context.graph()) !== "not_eligible")
84604         return join;
84605       if (merge2.disabled(context.graph()) !== "not_eligible")
84606         return merge2;
84607       if (mergePolygon.disabled(context.graph()) !== "not_eligible")
84608         return mergePolygon;
84609       return mergeNodes;
84610     }
84611     var operation2 = function() {
84612       if (operation2.disabled())
84613         return;
84614       context.perform(_action, operation2.annotation());
84615       context.validator().validate();
84616       var resultIDs = selectedIDs.filter(context.hasEntity);
84617       if (resultIDs.length > 1) {
84618         var interestingIDs = resultIDs.filter(function(id2) {
84619           return context.entity(id2).hasInterestingTags();
84620         });
84621         if (interestingIDs.length)
84622           resultIDs = interestingIDs;
84623       }
84624       context.enter(modeSelect(context, resultIDs));
84625     };
84626     operation2.available = function() {
84627       return selectedIDs.length >= 2;
84628     };
84629     operation2.disabled = function() {
84630       var actionDisabled = _action.disabled(context.graph());
84631       if (actionDisabled)
84632         return actionDisabled;
84633       var osm = context.connection();
84634       if (osm && _action.resultingWayNodesLength && _action.resultingWayNodesLength(context.graph()) > osm.maxWayNodes()) {
84635         return "too_many_vertices";
84636       }
84637       return false;
84638     };
84639     operation2.tooltip = function() {
84640       var disabled = operation2.disabled();
84641       if (disabled) {
84642         if (disabled === "conflicting_relations") {
84643           return _t.append("operations.merge.conflicting_relations");
84644         }
84645         if (disabled === "restriction" || disabled === "connectivity") {
84646           return _t.append(
84647             "operations.merge.damage_relation",
84648             { relation: _mainPresetIndex.item("type/" + disabled).name() }
84649           );
84650         }
84651         return _t.append("operations.merge." + disabled);
84652       }
84653       return _t.append("operations.merge.description");
84654     };
84655     operation2.annotation = function() {
84656       return _t("operations.merge.annotation", { n: selectedIDs.length });
84657     };
84658     operation2.id = "merge";
84659     operation2.keys = [_t("operations.merge.key")];
84660     operation2.title = _t.append("operations.merge.title");
84661     operation2.behavior = behaviorOperation(context).which(operation2);
84662     return operation2;
84663   }
84664
84665   // modules/operations/paste.js
84666   function operationPaste(context) {
84667     var _pastePoint;
84668     var operation2 = function() {
84669       if (!_pastePoint)
84670         return;
84671       var oldIDs = context.copyIDs();
84672       if (!oldIDs.length)
84673         return;
84674       var projection2 = context.projection;
84675       var extent = geoExtent();
84676       var oldGraph = context.copyGraph();
84677       var newIDs = [];
84678       var action = actionCopyEntities(oldIDs, oldGraph);
84679       context.perform(action);
84680       var copies = action.copies();
84681       var originals = /* @__PURE__ */ new Set();
84682       Object.values(copies).forEach(function(entity) {
84683         originals.add(entity.id);
84684       });
84685       for (var id2 in copies) {
84686         var oldEntity = oldGraph.entity(id2);
84687         var newEntity = copies[id2];
84688         extent._extend(oldEntity.extent(oldGraph));
84689         var parents = context.graph().parentWays(newEntity);
84690         var parentCopied = parents.some(function(parent) {
84691           return originals.has(parent.id);
84692         });
84693         if (!parentCopied) {
84694           newIDs.push(newEntity.id);
84695         }
84696       }
84697       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
84698       var delta = geoVecSubtract(_pastePoint, copyPoint);
84699       context.replace(actionMove(newIDs, delta, projection2), operation2.annotation());
84700       context.enter(modeSelect(context, newIDs));
84701     };
84702     operation2.point = function(val) {
84703       _pastePoint = val;
84704       return operation2;
84705     };
84706     operation2.available = function() {
84707       return context.mode().id === "browse";
84708     };
84709     operation2.disabled = function() {
84710       return !context.copyIDs().length;
84711     };
84712     operation2.tooltip = function() {
84713       var oldGraph = context.copyGraph();
84714       var ids = context.copyIDs();
84715       if (!ids.length) {
84716         return _t.append("operations.paste.nothing_copied");
84717       }
84718       return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length });
84719     };
84720     operation2.annotation = function() {
84721       var ids = context.copyIDs();
84722       return _t("operations.paste.annotation", { n: ids.length });
84723     };
84724     operation2.id = "paste";
84725     operation2.keys = [uiCmd("\u2318V")];
84726     operation2.title = _t.append("operations.paste.title");
84727     return operation2;
84728   }
84729
84730   // modules/operations/reverse.js
84731   function operationReverse(context, selectedIDs) {
84732     var operation2 = function() {
84733       context.perform(function combinedReverseAction(graph) {
84734         actions().forEach(function(action) {
84735           graph = action(graph);
84736         });
84737         return graph;
84738       }, operation2.annotation());
84739       context.validator().validate();
84740     };
84741     function actions(situation) {
84742       return selectedIDs.map(function(entityID) {
84743         var entity = context.hasEntity(entityID);
84744         if (!entity)
84745           return null;
84746         if (situation === "toolbar") {
84747           if (entity.type === "way" && (!entity.isOneWay() && !entity.isSided()))
84748             return null;
84749         }
84750         var geometry = entity.geometry(context.graph());
84751         if (entity.type !== "node" && geometry !== "line")
84752           return null;
84753         var action = actionReverse(entityID);
84754         if (action.disabled(context.graph()))
84755           return null;
84756         return action;
84757       }).filter(Boolean);
84758     }
84759     function reverseTypeID() {
84760       var acts = actions();
84761       var nodeActionCount = acts.filter(function(act) {
84762         var entity = context.hasEntity(act.entityID());
84763         return entity && entity.type === "node";
84764       }).length;
84765       if (nodeActionCount === 0)
84766         return "line";
84767       if (nodeActionCount === acts.length)
84768         return "point";
84769       return "feature";
84770     }
84771     operation2.available = function(situation) {
84772       return actions(situation).length > 0;
84773     };
84774     operation2.disabled = function() {
84775       return false;
84776     };
84777     operation2.tooltip = function() {
84778       return _t.append("operations.reverse.description." + reverseTypeID());
84779     };
84780     operation2.annotation = function() {
84781       var acts = actions();
84782       return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length });
84783     };
84784     operation2.id = "reverse";
84785     operation2.keys = [_t("operations.reverse.key")];
84786     operation2.title = _t.append("operations.reverse.title");
84787     operation2.behavior = behaviorOperation(context).which(operation2);
84788     return operation2;
84789   }
84790
84791   // modules/operations/split.js
84792   function operationSplit(context, selectedIDs) {
84793     var _vertexIds = selectedIDs.filter(function(id2) {
84794       return context.graph().geometry(id2) === "vertex";
84795     });
84796     var _selectedWayIds = selectedIDs.filter(function(id2) {
84797       var entity = context.graph().hasEntity(id2);
84798       return entity && entity.type === "way";
84799     });
84800     var _isAvailable = _vertexIds.length > 0 && _vertexIds.length + _selectedWayIds.length === selectedIDs.length;
84801     var _action = actionSplit(_vertexIds);
84802     var _ways = [];
84803     var _geometry = "feature";
84804     var _waysAmount = "single";
84805     var _nodesAmount = _vertexIds.length === 1 ? "single" : "multiple";
84806     if (_isAvailable) {
84807       if (_selectedWayIds.length)
84808         _action.limitWays(_selectedWayIds);
84809       _ways = _action.ways(context.graph());
84810       var geometries = {};
84811       _ways.forEach(function(way) {
84812         geometries[way.geometry(context.graph())] = true;
84813       });
84814       if (Object.keys(geometries).length === 1) {
84815         _geometry = Object.keys(geometries)[0];
84816       }
84817       _waysAmount = _ways.length === 1 ? "single" : "multiple";
84818     }
84819     var operation2 = function() {
84820       var difference2 = context.perform(_action, operation2.annotation());
84821       var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) {
84822         return context.entity(id2).type === "way";
84823       }));
84824       context.enter(modeSelect(context, idsToSelect));
84825     };
84826     operation2.relatedEntityIds = function() {
84827       return _selectedWayIds.length ? [] : _ways.map((way) => way.id);
84828     };
84829     operation2.available = function() {
84830       return _isAvailable;
84831     };
84832     operation2.disabled = function() {
84833       var reason = _action.disabled(context.graph());
84834       if (reason) {
84835         return reason;
84836       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84837         return "connected_to_hidden";
84838       }
84839       return false;
84840     };
84841     operation2.tooltip = function() {
84842       var disable = operation2.disabled();
84843       return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node");
84844     };
84845     operation2.annotation = function() {
84846       return _t("operations.split.annotation." + _geometry, { n: _ways.length });
84847     };
84848     operation2.icon = function() {
84849       if (_waysAmount === "multiple") {
84850         return "#iD-operation-split-multiple";
84851       } else {
84852         return "#iD-operation-split";
84853       }
84854     };
84855     operation2.id = "split";
84856     operation2.keys = [_t("operations.split.key")];
84857     operation2.title = _t.append("operations.split.title");
84858     operation2.behavior = behaviorOperation(context).which(operation2);
84859     return operation2;
84860   }
84861
84862   // modules/operations/straighten.js
84863   function operationStraighten(context, selectedIDs) {
84864     var _wayIDs = selectedIDs.filter(function(id2) {
84865       return id2.charAt(0) === "w";
84866     });
84867     var _nodeIDs = selectedIDs.filter(function(id2) {
84868       return id2.charAt(0) === "n";
84869     });
84870     var _amount = (_wayIDs.length ? _wayIDs : _nodeIDs).length === 1 ? "single" : "multiple";
84871     var _nodes = utilGetAllNodes(selectedIDs, context.graph());
84872     var _coords = _nodes.map(function(n3) {
84873       return n3.loc;
84874     });
84875     var _extent = utilTotalExtent(selectedIDs, context.graph());
84876     var _action = chooseAction();
84877     var _geometry;
84878     function chooseAction() {
84879       if (_wayIDs.length === 0 && _nodeIDs.length > 2) {
84880         _geometry = "point";
84881         return actionStraightenNodes(_nodeIDs, context.projection);
84882       } else if (_wayIDs.length > 0 && (_nodeIDs.length === 0 || _nodeIDs.length === 2)) {
84883         var startNodeIDs = [];
84884         var endNodeIDs = [];
84885         for (var i3 = 0; i3 < selectedIDs.length; i3++) {
84886           var entity = context.entity(selectedIDs[i3]);
84887           if (entity.type === "node") {
84888             continue;
84889           } else if (entity.type !== "way" || entity.isClosed()) {
84890             return null;
84891           }
84892           startNodeIDs.push(entity.first());
84893           endNodeIDs.push(entity.last());
84894         }
84895         startNodeIDs = startNodeIDs.filter(function(n3) {
84896           return startNodeIDs.indexOf(n3) === startNodeIDs.lastIndexOf(n3);
84897         });
84898         endNodeIDs = endNodeIDs.filter(function(n3) {
84899           return endNodeIDs.indexOf(n3) === endNodeIDs.lastIndexOf(n3);
84900         });
84901         if (utilArrayDifference(startNodeIDs, endNodeIDs).length + utilArrayDifference(endNodeIDs, startNodeIDs).length !== 2)
84902           return null;
84903         var wayNodeIDs = utilGetAllNodes(_wayIDs, context.graph()).map(function(node) {
84904           return node.id;
84905         });
84906         if (wayNodeIDs.length <= 2)
84907           return null;
84908         if (_nodeIDs.length === 2 && (wayNodeIDs.indexOf(_nodeIDs[0]) === -1 || wayNodeIDs.indexOf(_nodeIDs[1]) === -1))
84909           return null;
84910         if (_nodeIDs.length) {
84911           _extent = utilTotalExtent(_nodeIDs, context.graph());
84912         }
84913         _geometry = "line";
84914         return actionStraightenWay(selectedIDs, context.projection);
84915       }
84916       return null;
84917     }
84918     function operation2() {
84919       if (!_action)
84920         return;
84921       context.perform(_action, operation2.annotation());
84922       window.setTimeout(function() {
84923         context.validator().validate();
84924       }, 300);
84925     }
84926     operation2.available = function() {
84927       return Boolean(_action);
84928     };
84929     operation2.disabled = function() {
84930       var reason = _action.disabled(context.graph());
84931       if (reason) {
84932         return reason;
84933       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
84934         return "too_large";
84935       } else if (someMissing()) {
84936         return "not_downloaded";
84937       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84938         return "connected_to_hidden";
84939       }
84940       return false;
84941       function someMissing() {
84942         if (context.inIntro())
84943           return false;
84944         var osm = context.connection();
84945         if (osm) {
84946           var missing = _coords.filter(function(loc) {
84947             return !osm.isDataLoaded(loc);
84948           });
84949           if (missing.length) {
84950             missing.forEach(function(loc) {
84951               context.loadTileAtLoc(loc);
84952             });
84953             return true;
84954           }
84955         }
84956         return false;
84957       }
84958     };
84959     operation2.tooltip = function() {
84960       var disable = operation2.disabled();
84961       return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s"));
84962     };
84963     operation2.annotation = function() {
84964       return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length });
84965     };
84966     operation2.id = "straighten";
84967     operation2.keys = [_t("operations.straighten.key")];
84968     operation2.title = _t.append("operations.straighten.title");
84969     operation2.behavior = behaviorOperation(context).which(operation2);
84970     return operation2;
84971   }
84972
84973   // modules/modes/select.js
84974   function modeSelect(context, selectedIDs) {
84975     var mode = {
84976       id: "select",
84977       button: "browse"
84978     };
84979     var keybinding = utilKeybinding("select");
84980     var _breatheBehavior = behaviorBreathe(context);
84981     var _modeDragNode = modeDragNode(context);
84982     var _selectBehavior;
84983     var _behaviors = [];
84984     var _operations = [];
84985     var _newFeature = false;
84986     var _follow = false;
84987     var _focusedParentWayId;
84988     var _focusedVertexIds;
84989     function singular() {
84990       if (selectedIDs && selectedIDs.length === 1) {
84991         return context.hasEntity(selectedIDs[0]);
84992       }
84993     }
84994     function selectedEntities() {
84995       return selectedIDs.map(function(id2) {
84996         return context.hasEntity(id2);
84997       }).filter(Boolean);
84998     }
84999     function checkSelectedIDs() {
85000       var ids = [];
85001       if (Array.isArray(selectedIDs)) {
85002         ids = selectedIDs.filter(function(id2) {
85003           return context.hasEntity(id2);
85004         });
85005       }
85006       if (!ids.length) {
85007         context.enter(modeBrowse(context));
85008         return false;
85009       } else if (selectedIDs.length > 1 && ids.length === 1 || selectedIDs.length === 1 && ids.length > 1) {
85010         context.enter(modeSelect(context, ids));
85011         return false;
85012       }
85013       selectedIDs = ids;
85014       return true;
85015     }
85016     function parentWaysIdsOfSelection(onlyCommonParents) {
85017       var graph = context.graph();
85018       var parents = [];
85019       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85020         var entity = context.hasEntity(selectedIDs[i3]);
85021         if (!entity || entity.geometry(graph) !== "vertex") {
85022           return [];
85023         }
85024         var currParents = graph.parentWays(entity).map(function(w2) {
85025           return w2.id;
85026         });
85027         if (!parents.length) {
85028           parents = currParents;
85029           continue;
85030         }
85031         parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
85032         if (!parents.length) {
85033           return [];
85034         }
85035       }
85036       return parents;
85037     }
85038     function childNodeIdsOfSelection(onlyCommon) {
85039       var graph = context.graph();
85040       var childs = [];
85041       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85042         var entity = context.hasEntity(selectedIDs[i3]);
85043         if (!entity || !["area", "line"].includes(entity.geometry(graph))) {
85044           return [];
85045         }
85046         var currChilds = graph.childNodes(entity).map(function(node) {
85047           return node.id;
85048         });
85049         if (!childs.length) {
85050           childs = currChilds;
85051           continue;
85052         }
85053         childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
85054         if (!childs.length) {
85055           return [];
85056         }
85057       }
85058       return childs;
85059     }
85060     function checkFocusedParent() {
85061       if (_focusedParentWayId) {
85062         var parents = parentWaysIdsOfSelection(true);
85063         if (parents.indexOf(_focusedParentWayId) === -1)
85064           _focusedParentWayId = null;
85065       }
85066     }
85067     function parentWayIdForVertexNavigation() {
85068       var parentIds = parentWaysIdsOfSelection(true);
85069       if (_focusedParentWayId && parentIds.indexOf(_focusedParentWayId) !== -1) {
85070         return _focusedParentWayId;
85071       }
85072       return parentIds.length ? parentIds[0] : null;
85073     }
85074     mode.selectedIDs = function(val) {
85075       if (!arguments.length)
85076         return selectedIDs;
85077       selectedIDs = val;
85078       return mode;
85079     };
85080     mode.zoomToSelected = function() {
85081       context.map().zoomToEase(selectedEntities());
85082     };
85083     mode.newFeature = function(val) {
85084       if (!arguments.length)
85085         return _newFeature;
85086       _newFeature = val;
85087       return mode;
85088     };
85089     mode.selectBehavior = function(val) {
85090       if (!arguments.length)
85091         return _selectBehavior;
85092       _selectBehavior = val;
85093       return mode;
85094     };
85095     mode.follow = function(val) {
85096       if (!arguments.length)
85097         return _follow;
85098       _follow = val;
85099       return mode;
85100     };
85101     function loadOperations() {
85102       _operations.forEach(function(operation2) {
85103         if (operation2.behavior) {
85104           context.uninstall(operation2.behavior);
85105         }
85106       });
85107       _operations = Object.values(operations_exports).map(function(o2) {
85108         return o2(context, selectedIDs);
85109       }).filter(function(o2) {
85110         return o2.id !== "delete" && o2.id !== "downgrade" && o2.id !== "copy";
85111       }).concat([
85112         // group copy/downgrade/delete operation together at the end of the list
85113         operationCopy(context, selectedIDs),
85114         operationDowngrade(context, selectedIDs),
85115         operationDelete(context, selectedIDs)
85116       ]).filter(function(operation2) {
85117         return operation2.available();
85118       });
85119       _operations.forEach(function(operation2) {
85120         if (operation2.behavior) {
85121           context.install(operation2.behavior);
85122         }
85123       });
85124       context.ui().closeEditMenu();
85125     }
85126     mode.operations = function() {
85127       return _operations;
85128     };
85129     mode.enter = function() {
85130       if (!checkSelectedIDs())
85131         return;
85132       context.features().forceVisible(selectedIDs);
85133       _modeDragNode.restoreSelectedIDs(selectedIDs);
85134       loadOperations();
85135       if (!_behaviors.length) {
85136         if (!_selectBehavior)
85137           _selectBehavior = behaviorSelect(context);
85138         _behaviors = [
85139           behaviorPaste(context),
85140           _breatheBehavior,
85141           behaviorHover(context).on("hover", context.ui().sidebar.hoverModeSelect),
85142           _selectBehavior,
85143           behaviorLasso(context),
85144           _modeDragNode.behavior,
85145           modeDragNote(context).behavior
85146         ];
85147       }
85148       _behaviors.forEach(context.install);
85149       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);
85150       select_default2(document).call(keybinding);
85151       context.ui().sidebar.select(selectedIDs, _newFeature);
85152       context.history().on("change.select", function() {
85153         loadOperations();
85154         selectElements();
85155       }).on("undone.select", checkSelectedIDs).on("redone.select", checkSelectedIDs);
85156       context.map().on("drawn.select", selectElements).on("crossEditableZoom.select", function() {
85157         selectElements();
85158         _breatheBehavior.restartIfNeeded(context.surface());
85159       });
85160       context.map().doubleUpHandler().on("doubleUp.modeSelect", didDoubleUp);
85161       selectElements();
85162       if (_follow) {
85163         var extent = geoExtent();
85164         var graph = context.graph();
85165         selectedIDs.forEach(function(id2) {
85166           var entity = context.entity(id2);
85167           extent._extend(entity.extent(graph));
85168         });
85169         var loc = extent.center();
85170         context.map().centerEase(loc);
85171         _follow = false;
85172       }
85173       function nudgeSelection(delta) {
85174         return function() {
85175           if (!context.map().withinEditableZoom())
85176             return;
85177           var moveOp = operationMove(context, selectedIDs);
85178           if (moveOp.disabled()) {
85179             context.ui().flash.duration(4e3).iconName("#iD-operation-" + moveOp.id).iconClass("operation disabled").label(moveOp.tooltip())();
85180           } else {
85181             context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
85182             context.validator().validate();
85183           }
85184         };
85185       }
85186       function scaleSelection(factor) {
85187         return function() {
85188           if (!context.map().withinEditableZoom())
85189             return;
85190           let nodes = utilGetAllNodes(selectedIDs, context.graph());
85191           let isUp = factor > 1;
85192           if (nodes.length <= 1)
85193             return;
85194           let extent2 = utilTotalExtent(selectedIDs, context.graph());
85195           function scalingDisabled() {
85196             if (tooSmall()) {
85197               return "too_small";
85198             } else if (extent2.percentContainedIn(context.map().extent()) < 0.8) {
85199               return "too_large";
85200             } else if (someMissing() || selectedIDs.some(incompleteRelation)) {
85201               return "not_downloaded";
85202             } else if (selectedIDs.some(context.hasHiddenConnections)) {
85203               return "connected_to_hidden";
85204             }
85205             return false;
85206             function tooSmall() {
85207               if (isUp)
85208                 return false;
85209               let dLon = Math.abs(extent2[1][0] - extent2[0][0]);
85210               let dLat = Math.abs(extent2[1][1] - extent2[0][1]);
85211               return dLon < geoMetersToLon(1, extent2[1][1]) && dLat < geoMetersToLat(1);
85212             }
85213             function someMissing() {
85214               if (context.inIntro())
85215                 return false;
85216               let osm = context.connection();
85217               if (osm) {
85218                 let missing = nodes.filter(function(n3) {
85219                   return !osm.isDataLoaded(n3.loc);
85220                 });
85221                 if (missing.length) {
85222                   missing.forEach(function(loc2) {
85223                     context.loadTileAtLoc(loc2);
85224                   });
85225                   return true;
85226                 }
85227               }
85228               return false;
85229             }
85230             function incompleteRelation(id2) {
85231               let entity = context.entity(id2);
85232               return entity.type === "relation" && !entity.isComplete(context.graph());
85233             }
85234           }
85235           const disabled = scalingDisabled();
85236           if (disabled) {
85237             let multi = selectedIDs.length === 1 ? "single" : "multiple";
85238             context.ui().flash.duration(4e3).iconName("#iD-icon-no").iconClass("operation disabled").label(_t.append("operations.scale." + disabled + "." + multi))();
85239           } else {
85240             const pivot = context.projection(extent2.center());
85241             const annotation = _t("operations.scale.annotation." + (isUp ? "up" : "down") + ".feature", { n: selectedIDs.length });
85242             context.perform(actionScale(selectedIDs, pivot, factor, context.projection), annotation);
85243             context.validator().validate();
85244           }
85245         };
85246       }
85247       function didDoubleUp(d3_event, loc2) {
85248         if (!context.map().withinEditableZoom())
85249           return;
85250         var target = select_default2(d3_event.target);
85251         var datum2 = target.datum();
85252         var entity = datum2 && datum2.properties && datum2.properties.entity;
85253         if (!entity)
85254           return;
85255         if (entity instanceof osmWay && target.classed("target")) {
85256           var choice = geoChooseEdge(context.graph().childNodes(entity), loc2, context.projection);
85257           var prev = entity.nodes[choice.index - 1];
85258           var next = entity.nodes[choice.index];
85259           context.perform(
85260             actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
85261             _t("operations.add.annotation.vertex")
85262           );
85263           context.validator().validate();
85264         } else if (entity.type === "midpoint") {
85265           context.perform(
85266             actionAddMidpoint({ loc: entity.loc, edge: entity.edge }, osmNode()),
85267             _t("operations.add.annotation.vertex")
85268           );
85269           context.validator().validate();
85270         }
85271       }
85272       function selectElements() {
85273         if (!checkSelectedIDs())
85274           return;
85275         var surface = context.surface();
85276         surface.selectAll(".selected-member").classed("selected-member", false);
85277         surface.selectAll(".selected").classed("selected", false);
85278         surface.selectAll(".related").classed("related", false);
85279         checkFocusedParent();
85280         if (_focusedParentWayId) {
85281           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85282         }
85283         if (context.map().withinEditableZoom()) {
85284           surface.selectAll(utilDeepMemberSelector(
85285             selectedIDs,
85286             context.graph(),
85287             true
85288             /* skipMultipolgonMembers */
85289           )).classed("selected-member", true);
85290           surface.selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())).classed("selected", true);
85291         }
85292       }
85293       function esc() {
85294         if (context.container().select(".combobox").size())
85295           return;
85296         context.enter(modeBrowse(context));
85297       }
85298       function firstVertex(d3_event) {
85299         d3_event.preventDefault();
85300         var entity = singular();
85301         var parentId = parentWayIdForVertexNavigation();
85302         var way;
85303         if (entity && entity.type === "way") {
85304           way = entity;
85305         } else if (parentId) {
85306           way = context.entity(parentId);
85307         }
85308         _focusedParentWayId = way && way.id;
85309         if (way) {
85310           context.enter(
85311             mode.selectedIDs([way.first()]).follow(true)
85312           );
85313         }
85314       }
85315       function lastVertex(d3_event) {
85316         d3_event.preventDefault();
85317         var entity = singular();
85318         var parentId = parentWayIdForVertexNavigation();
85319         var way;
85320         if (entity && entity.type === "way") {
85321           way = entity;
85322         } else if (parentId) {
85323           way = context.entity(parentId);
85324         }
85325         _focusedParentWayId = way && way.id;
85326         if (way) {
85327           context.enter(
85328             mode.selectedIDs([way.last()]).follow(true)
85329           );
85330         }
85331       }
85332       function previousVertex(d3_event) {
85333         d3_event.preventDefault();
85334         var parentId = parentWayIdForVertexNavigation();
85335         _focusedParentWayId = parentId;
85336         if (!parentId)
85337           return;
85338         var way = context.entity(parentId);
85339         var length2 = way.nodes.length;
85340         var curr = way.nodes.indexOf(selectedIDs[0]);
85341         var index = -1;
85342         if (curr > 0) {
85343           index = curr - 1;
85344         } else if (way.isClosed()) {
85345           index = length2 - 2;
85346         }
85347         if (index !== -1) {
85348           context.enter(
85349             mode.selectedIDs([way.nodes[index]]).follow(true)
85350           );
85351         }
85352       }
85353       function nextVertex(d3_event) {
85354         d3_event.preventDefault();
85355         var parentId = parentWayIdForVertexNavigation();
85356         _focusedParentWayId = parentId;
85357         if (!parentId)
85358           return;
85359         var way = context.entity(parentId);
85360         var length2 = way.nodes.length;
85361         var curr = way.nodes.indexOf(selectedIDs[0]);
85362         var index = -1;
85363         if (curr < length2 - 1) {
85364           index = curr + 1;
85365         } else if (way.isClosed()) {
85366           index = 0;
85367         }
85368         if (index !== -1) {
85369           context.enter(
85370             mode.selectedIDs([way.nodes[index]]).follow(true)
85371           );
85372         }
85373       }
85374       function focusNextParent(d3_event) {
85375         d3_event.preventDefault();
85376         var parents = parentWaysIdsOfSelection(true);
85377         if (!parents || parents.length < 2)
85378           return;
85379         var index = parents.indexOf(_focusedParentWayId);
85380         if (index < 0 || index > parents.length - 2) {
85381           _focusedParentWayId = parents[0];
85382         } else {
85383           _focusedParentWayId = parents[index + 1];
85384         }
85385         var surface = context.surface();
85386         surface.selectAll(".related").classed("related", false);
85387         if (_focusedParentWayId) {
85388           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85389         }
85390       }
85391       function selectParent(d3_event) {
85392         d3_event.preventDefault();
85393         var currentSelectedIds = mode.selectedIDs();
85394         var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
85395         if (!parentIds.length)
85396           return;
85397         context.enter(
85398           mode.selectedIDs(parentIds)
85399         );
85400         _focusedVertexIds = currentSelectedIds;
85401       }
85402       function selectChild(d3_event) {
85403         d3_event.preventDefault();
85404         var currentSelectedIds = mode.selectedIDs();
85405         var childIds = _focusedVertexIds ? _focusedVertexIds.filter((id2) => context.hasEntity(id2)) : childNodeIdsOfSelection(true);
85406         if (!childIds || !childIds.length)
85407           return;
85408         if (currentSelectedIds.length === 1)
85409           _focusedParentWayId = currentSelectedIds[0];
85410         context.enter(
85411           mode.selectedIDs(childIds)
85412         );
85413       }
85414     };
85415     mode.exit = function() {
85416       _newFeature = false;
85417       _focusedVertexIds = null;
85418       _operations.forEach(function(operation2) {
85419         if (operation2.behavior) {
85420           context.uninstall(operation2.behavior);
85421         }
85422       });
85423       _operations = [];
85424       _behaviors.forEach(context.uninstall);
85425       select_default2(document).call(keybinding.unbind);
85426       context.ui().closeEditMenu();
85427       context.history().on("change.select", null).on("undone.select", null).on("redone.select", null);
85428       var surface = context.surface();
85429       surface.selectAll(".selected-member").classed("selected-member", false);
85430       surface.selectAll(".selected").classed("selected", false);
85431       surface.selectAll(".highlighted").classed("highlighted", false);
85432       surface.selectAll(".related").classed("related", false);
85433       context.map().on("drawn.select", null);
85434       context.ui().sidebar.hide();
85435       context.features().forceVisible([]);
85436       var entity = singular();
85437       if (_newFeature && entity && entity.type === "relation" && // no tags
85438       Object.keys(entity.tags).length === 0 && // no parent relations
85439       context.graph().parentRelations(entity).length === 0 && // no members or one member with no role
85440       (entity.members.length === 0 || entity.members.length === 1 && !entity.members[0].role)) {
85441         var deleteAction = actionDeleteRelation(
85442           entity.id,
85443           true
85444           /* don't delete untagged members */
85445         );
85446         context.perform(deleteAction, _t("operations.delete.annotation.relation"));
85447         context.validator().validate();
85448       }
85449     };
85450     return mode;
85451   }
85452
85453   // modules/behavior/lasso.js
85454   function behaviorLasso(context) {
85455     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
85456     var behavior = function(selection2) {
85457       var lasso;
85458       function pointerdown(d3_event) {
85459         var button = 0;
85460         if (d3_event.button === button && d3_event.shiftKey === true) {
85461           lasso = null;
85462           select_default2(window).on(_pointerPrefix + "move.lasso", pointermove).on(_pointerPrefix + "up.lasso", pointerup);
85463           d3_event.stopPropagation();
85464         }
85465       }
85466       function pointermove() {
85467         if (!lasso) {
85468           lasso = uiLasso(context);
85469           context.surface().call(lasso);
85470         }
85471         lasso.p(context.map().mouse());
85472       }
85473       function normalize2(a2, b2) {
85474         return [
85475           [Math.min(a2[0], b2[0]), Math.min(a2[1], b2[1])],
85476           [Math.max(a2[0], b2[0]), Math.max(a2[1], b2[1])]
85477         ];
85478       }
85479       function lassoed() {
85480         if (!lasso)
85481           return [];
85482         var graph = context.graph();
85483         var limitToNodes;
85484         if (context.map().editableDataEnabled(
85485           true
85486           /* skipZoomCheck */
85487         ) && context.map().isInWideSelection()) {
85488           limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
85489         } else if (!context.map().editableDataEnabled()) {
85490           return [];
85491         }
85492         var bounds = lasso.extent().map(context.projection.invert);
85493         var extent = geoExtent(normalize2(bounds[0], bounds[1]));
85494         var intersects = context.history().intersects(extent).filter(function(entity) {
85495           return entity.type === "node" && (!limitToNodes || limitToNodes.has(entity)) && geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) && !context.features().isHidden(entity, graph, entity.geometry(graph));
85496         });
85497         intersects.sort(function(node1, node2) {
85498           var parents1 = graph.parentWays(node1);
85499           var parents2 = graph.parentWays(node2);
85500           if (parents1.length && parents2.length) {
85501             var sharedParents = utilArrayIntersection(parents1, parents2);
85502             if (sharedParents.length) {
85503               var sharedParentNodes = sharedParents[0].nodes;
85504               return sharedParentNodes.indexOf(node1.id) - sharedParentNodes.indexOf(node2.id);
85505             } else {
85506               return Number(parents1[0].id.slice(1)) - Number(parents2[0].id.slice(1));
85507             }
85508           } else if (parents1.length || parents2.length) {
85509             return parents1.length - parents2.length;
85510           }
85511           return node1.loc[0] - node2.loc[0];
85512         });
85513         return intersects.map(function(entity) {
85514           return entity.id;
85515         });
85516       }
85517       function pointerup() {
85518         select_default2(window).on(_pointerPrefix + "move.lasso", null).on(_pointerPrefix + "up.lasso", null);
85519         if (!lasso)
85520           return;
85521         var ids = lassoed();
85522         lasso.close();
85523         if (ids.length) {
85524           context.enter(modeSelect(context, ids));
85525         }
85526       }
85527       selection2.on(_pointerPrefix + "down.lasso", pointerdown);
85528     };
85529     behavior.off = function(selection2) {
85530       selection2.on(_pointerPrefix + "down.lasso", null);
85531     };
85532     return behavior;
85533   }
85534
85535   // modules/modes/browse.js
85536   function modeBrowse(context) {
85537     var mode = {
85538       button: "browse",
85539       id: "browse",
85540       title: _t.append("modes.browse.title"),
85541       description: _t.append("modes.browse.description")
85542     };
85543     var sidebar;
85544     var _selectBehavior;
85545     var _behaviors = [];
85546     mode.selectBehavior = function(val) {
85547       if (!arguments.length)
85548         return _selectBehavior;
85549       _selectBehavior = val;
85550       return mode;
85551     };
85552     mode.enter = function() {
85553       if (!_behaviors.length) {
85554         if (!_selectBehavior)
85555           _selectBehavior = behaviorSelect(context);
85556         _behaviors = [
85557           behaviorPaste(context),
85558           behaviorHover(context).on("hover", context.ui().sidebar.hover),
85559           _selectBehavior,
85560           behaviorLasso(context),
85561           modeDragNode(context).behavior,
85562           modeDragNote(context).behavior
85563         ];
85564       }
85565       _behaviors.forEach(context.install);
85566       if (document.activeElement && document.activeElement.blur) {
85567         document.activeElement.blur();
85568       }
85569       if (sidebar) {
85570         context.ui().sidebar.show(sidebar);
85571       } else {
85572         context.ui().sidebar.select(null);
85573       }
85574     };
85575     mode.exit = function() {
85576       context.ui().sidebar.hover.cancel();
85577       _behaviors.forEach(context.uninstall);
85578       if (sidebar) {
85579         context.ui().sidebar.hide();
85580       }
85581     };
85582     mode.sidebar = function(_2) {
85583       if (!arguments.length)
85584         return sidebar;
85585       sidebar = _2;
85586       return mode;
85587     };
85588     mode.operations = function() {
85589       return [operationPaste(context)];
85590     };
85591     return mode;
85592   }
85593
85594   // modules/behavior/add_way.js
85595   function behaviorAddWay(context) {
85596     var dispatch14 = dispatch_default("start", "startFromWay", "startFromNode");
85597     var draw = behaviorDraw(context);
85598     function behavior(surface) {
85599       draw.on("click", function() {
85600         dispatch14.apply("start", this, arguments);
85601       }).on("clickWay", function() {
85602         dispatch14.apply("startFromWay", this, arguments);
85603       }).on("clickNode", function() {
85604         dispatch14.apply("startFromNode", this, arguments);
85605       }).on("cancel", behavior.cancel).on("finish", behavior.cancel);
85606       context.map().dblclickZoomEnable(false);
85607       surface.call(draw);
85608     }
85609     behavior.off = function(surface) {
85610       surface.call(draw.off);
85611     };
85612     behavior.cancel = function() {
85613       window.setTimeout(function() {
85614         context.map().dblclickZoomEnable(true);
85615       }, 1e3);
85616       context.enter(modeBrowse(context));
85617     };
85618     return utilRebind(behavior, dispatch14, "on");
85619   }
85620
85621   // modules/behavior/hash.js
85622   function behaviorHash(context) {
85623     var _cachedHash = null;
85624     var _latitudeLimit = 90 - 1e-8;
85625     function computedHashParameters() {
85626       var map2 = context.map();
85627       var center = map2.center();
85628       var zoom = map2.zoom();
85629       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
85630       var oldParams = utilObjectOmit(
85631         utilStringQs(window.location.hash),
85632         ["comment", "source", "hashtags", "walkthrough"]
85633       );
85634       var newParams = {};
85635       delete oldParams.id;
85636       var selected = context.selectedIDs().filter(function(id2) {
85637         return context.hasEntity(id2);
85638       });
85639       if (selected.length) {
85640         newParams.id = selected.join(",");
85641       }
85642       newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
85643       return Object.assign(oldParams, newParams);
85644     }
85645     function computedHash() {
85646       return "#" + utilQsString(computedHashParameters(), true);
85647     }
85648     function computedTitle(includeChangeCount) {
85649       var baseTitle = context.documentTitleBase() || "iD";
85650       var contextual;
85651       var changeCount;
85652       var titleID;
85653       var selected = context.selectedIDs().filter(function(id2) {
85654         return context.hasEntity(id2);
85655       });
85656       if (selected.length) {
85657         var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph());
85658         if (selected.length > 1) {
85659           contextual = _t("title.labeled_and_more", {
85660             labeled: firstLabel,
85661             count: selected.length - 1
85662           });
85663         } else {
85664           contextual = firstLabel;
85665         }
85666         titleID = "context";
85667       }
85668       if (includeChangeCount) {
85669         changeCount = context.history().difference().summary().length;
85670         if (changeCount > 0) {
85671           titleID = contextual ? "changes_context" : "changes";
85672         }
85673       }
85674       if (titleID) {
85675         return _t("title.format." + titleID, {
85676           changes: changeCount,
85677           base: baseTitle,
85678           context: contextual
85679         });
85680       }
85681       return baseTitle;
85682     }
85683     function updateTitle(includeChangeCount) {
85684       if (!context.setsDocumentTitle())
85685         return;
85686       var newTitle = computedTitle(includeChangeCount);
85687       if (document.title !== newTitle) {
85688         document.title = newTitle;
85689       }
85690     }
85691     function updateHashIfNeeded() {
85692       if (context.inIntro())
85693         return;
85694       var latestHash = computedHash();
85695       if (_cachedHash !== latestHash) {
85696         _cachedHash = latestHash;
85697         window.history.replaceState(null, computedTitle(
85698           false
85699           /* includeChangeCount */
85700         ), latestHash);
85701         updateTitle(
85702           true
85703           /* includeChangeCount */
85704         );
85705         const q2 = utilStringQs(latestHash);
85706         if (q2.map) {
85707           corePreferences("map-location", q2.map);
85708         }
85709       }
85710     }
85711     var _throttledUpdate = throttle_default(updateHashIfNeeded, 500);
85712     var _throttledUpdateTitle = throttle_default(function() {
85713       updateTitle(
85714         true
85715         /* includeChangeCount */
85716       );
85717     }, 500);
85718     function hashchange() {
85719       if (window.location.hash === _cachedHash)
85720         return;
85721       _cachedHash = window.location.hash;
85722       var q2 = utilStringQs(_cachedHash);
85723       var mapArgs = (q2.map || "").split("/").map(Number);
85724       if (mapArgs.length < 3 || mapArgs.some(isNaN)) {
85725         updateHashIfNeeded();
85726       } else {
85727         if (_cachedHash === computedHash())
85728           return;
85729         var mode = context.mode();
85730         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85731         if (q2.id && mode) {
85732           var ids = q2.id.split(",").filter(function(id2) {
85733             return context.hasEntity(id2);
85734           });
85735           if (ids.length && (mode.id === "browse" || mode.id === "select" && !utilArrayIdentical(mode.selectedIDs(), ids))) {
85736             context.enter(modeSelect(context, ids));
85737             return;
85738           }
85739         }
85740         var center = context.map().center();
85741         var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]);
85742         var maxdist = 500;
85743         if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) {
85744           context.enter(modeBrowse(context));
85745           return;
85746         }
85747       }
85748     }
85749     function behavior() {
85750       context.map().on("move.behaviorHash", _throttledUpdate);
85751       context.history().on("change.behaviorHash", _throttledUpdateTitle);
85752       context.on("enter.behaviorHash", _throttledUpdate);
85753       select_default2(window).on("hashchange.behaviorHash", hashchange);
85754       var q2 = utilStringQs(window.location.hash);
85755       if (q2.id) {
85756         context.zoomToEntity(q2.id.split(",")[0], !q2.map);
85757       }
85758       if (q2.walkthrough === "true") {
85759         behavior.startWalkthrough = true;
85760       }
85761       if (q2.map) {
85762         behavior.hadLocation = true;
85763       } else if (!q2.id && corePreferences("map-location")) {
85764         const mapArgs = corePreferences("map-location").split("/").map(Number);
85765         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85766         updateHashIfNeeded();
85767         behavior.hadLocation = true;
85768       }
85769       hashchange();
85770       updateTitle(false);
85771     }
85772     behavior.off = function() {
85773       _throttledUpdate.cancel();
85774       _throttledUpdateTitle.cancel();
85775       context.map().on("move.behaviorHash", null);
85776       context.on("enter.behaviorHash", null);
85777       select_default2(window).on("hashchange.behaviorHash", null);
85778       window.location.hash = "";
85779     };
85780     return behavior;
85781   }
85782
85783   // node_modules/d3-brush/src/brush.js
85784   var { abs: abs2, max: max2, min: min2 } = Math;
85785   function number1(e3) {
85786     return [+e3[0], +e3[1]];
85787   }
85788   function number22(e3) {
85789     return [number1(e3[0]), number1(e3[1])];
85790   }
85791   var X3 = {
85792     name: "x",
85793     handles: ["w", "e"].map(type),
85794     input: function(x2, e3) {
85795       return x2 == null ? null : [[+x2[0], e3[0][1]], [+x2[1], e3[1][1]]];
85796     },
85797     output: function(xy) {
85798       return xy && [xy[0][0], xy[1][0]];
85799     }
85800   };
85801   var Y3 = {
85802     name: "y",
85803     handles: ["n", "s"].map(type),
85804     input: function(y2, e3) {
85805       return y2 == null ? null : [[e3[0][0], +y2[0]], [e3[1][0], +y2[1]]];
85806     },
85807     output: function(xy) {
85808       return xy && [xy[0][1], xy[1][1]];
85809     }
85810   };
85811   var XY = {
85812     name: "xy",
85813     handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
85814     input: function(xy) {
85815       return xy == null ? null : number22(xy);
85816     },
85817     output: function(xy) {
85818       return xy;
85819     }
85820   };
85821   function type(t2) {
85822     return { type: t2 };
85823   }
85824
85825   // modules/index.js
85826   var debug = false;
85827   var d3 = {
85828     dispatch: dispatch_default,
85829     geoMercator: mercator_default,
85830     geoProjection: projection,
85831     polygonArea: area_default3,
85832     polygonCentroid: centroid_default2,
85833     select: select_default2,
85834     selectAll: selectAll_default2,
85835     timerFlush
85836   };
85837
85838   // modules/id.js
85839   window.requestIdleCallback = window.requestIdleCallback || function(cb) {
85840     var start2 = Date.now();
85841     return window.requestAnimationFrame(function() {
85842       cb({
85843         didTimeout: false,
85844         timeRemaining: function() {
85845           return Math.max(0, 50 - (Date.now() - start2));
85846         }
85847       });
85848     });
85849   };
85850   window.cancelIdleCallback = window.cancelIdleCallback || function(id2) {
85851     window.cancelAnimationFrame(id2);
85852   };
85853   window.iD = modules_exports;
85854 })();
85855 //# sourceMappingURL=iD.js.map