@code-plate/iran-cities 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/MIGRATION.fa.md +277 -0
- package/MIGRATION.md +272 -0
- package/NOTICE.md +38 -0
- package/README.fa.md +528 -201
- package/README.md +524 -201
- package/dist/boundaries.cjs +9218 -0
- package/dist/boundaries.cjs.map +1 -0
- package/dist/boundaries.d.cts +30 -0
- package/dist/boundaries.d.mts +30 -0
- package/dist/boundaries.mjs +9215 -0
- package/dist/boundaries.mjs.map +1 -0
- package/dist/changes-B-wz9-Gy.cjs +841 -0
- package/dist/changes-B-wz9-Gy.cjs.map +1 -0
- package/dist/changes-CMVZbfZO.d.mts +8 -0
- package/dist/changes-DLZkHBwZ.mjs +800 -0
- package/dist/changes-DLZkHBwZ.mjs.map +1 -0
- package/dist/changes-DnnwRAKl.d.cts +8 -0
- package/dist/components-B7060em0.mjs +240 -0
- package/dist/components-B7060em0.mjs.map +1 -0
- package/dist/components-BuMUB7XT.d.cts +47 -0
- package/dist/components-DZz72pd1.d.mts +47 -0
- package/dist/components-grWmOsaV.cjs +247 -0
- package/dist/components-grWmOsaV.cjs.map +1 -0
- package/dist/components.css +251 -0
- package/dist/data/cities.csv +1253 -0
- package/dist/data/cities.json +23305 -0
- package/dist/data/iran-cities.sql +1487 -0
- package/dist/data/iran-provinces.geojson +1 -0
- package/dist/data/provinces.csv +32 -0
- package/dist/data/provinces.json +460 -0
- package/dist/hooks-C6kjWLIE.mjs +134 -0
- package/dist/hooks-C6kjWLIE.mjs.map +1 -0
- package/dist/hooks-K7pTMF2R.cjs +139 -0
- package/dist/hooks-K7pTMF2R.cjs.map +1 -0
- package/dist/index.cjs +30 -7550
- package/dist/index.d.cts +25 -0
- package/dist/index.d.mts +25 -25
- package/dist/index.mjs +3 -7507
- package/dist/lite-CtNPRhU-.mjs +1926 -0
- package/dist/lite-CtNPRhU-.mjs.map +1 -0
- package/dist/lite-CutarzAc.cjs +2051 -0
- package/dist/lite-CutarzAc.cjs.map +1 -0
- package/dist/lite-react-1HVWJOWt.cjs +55 -0
- package/dist/lite-react-1HVWJOWt.cjs.map +1 -0
- package/dist/lite-react-Ds-DNmEi.mjs +20 -0
- package/dist/lite-react-Ds-DNmEi.mjs.map +1 -0
- package/dist/lite-react-components.cjs +12 -0
- package/dist/lite-react-components.cjs.map +1 -0
- package/dist/lite-react-components.d.cts +5 -0
- package/dist/lite-react-components.d.mts +5 -0
- package/dist/lite-react-components.mjs +11 -0
- package/dist/lite-react-components.mjs.map +1 -0
- package/dist/lite-react.cjs +8 -0
- package/dist/lite-react.d.cts +7 -0
- package/dist/lite-react.d.mts +7 -0
- package/dist/lite-react.mjs +2 -0
- package/dist/lite.cjs +28 -0
- package/dist/lite.d.cts +23 -0
- package/dist/lite.d.mts +23 -0
- package/dist/lite.mjs +3 -0
- package/dist/react-BKmJ476x.mjs +20 -0
- package/dist/react-BKmJ476x.mjs.map +1 -0
- package/dist/react-BZV3TkXB.cjs +55 -0
- package/dist/react-BZV3TkXB.cjs.map +1 -0
- package/dist/react-components.cjs +12 -0
- package/dist/react-components.cjs.map +1 -0
- package/dist/react-components.d.cts +5 -0
- package/dist/react-components.d.mts +5 -0
- package/dist/react-components.mjs +11 -0
- package/dist/react-components.mjs.map +1 -0
- package/dist/react.cjs +8 -7553
- package/dist/react.d.cts +7 -0
- package/dist/react.d.mts +7 -30
- package/dist/react.mjs +2 -7524
- package/dist/rolldown-runtime-78lK1XfQ.cjs +42 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/src-DRaUVbc4.mjs +4302 -0
- package/dist/src-DRaUVbc4.mjs.map +1 -0
- package/dist/src-mqZTwJfQ.cjs +4439 -0
- package/dist/src-mqZTwJfQ.cjs.map +1 -0
- package/dist/types/boundaries.d.ts +30 -0
- package/dist/types/changes.d.ts +4 -0
- package/dist/types/components.d.ts +47 -0
- package/dist/types/core.d.ts +25 -0
- package/dist/types/geo.d.ts +2 -0
- package/dist/types/hooks.d.ts +2 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/keyboard.d.ts +3 -0
- package/dist/types/lite-react-components.d.ts +5 -0
- package/dist/types/lite-react.d.ts +7 -0
- package/dist/types/lite.d.ts +26 -0
- package/dist/types/normalize.d.ts +1 -0
- package/dist/types/packed.d.ts +16 -0
- package/dist/types/react-components.d.ts +5 -0
- package/dist/types/react.d.ts +7 -0
- package/dist/types/types.d.ts +149 -0
- package/dist/types/valibot.d.ts +23 -0
- package/dist/types/validation-shared.d.ts +11 -0
- package/dist/types/zod.d.ts +23 -0
- package/dist/types-Ds_b0yHP.d.cts +150 -0
- package/dist/types-Ds_b0yHP.d.mts +150 -0
- package/dist/valibot.cjs +47 -0
- package/dist/valibot.cjs.map +1 -0
- package/dist/valibot.d.cts +21 -0
- package/dist/valibot.d.mts +21 -0
- package/dist/valibot.mjs +38 -0
- package/dist/valibot.mjs.map +1 -0
- package/dist/validation-shared-BFilTuY1.cjs +58 -0
- package/dist/validation-shared-BFilTuY1.cjs.map +1 -0
- package/dist/validation-shared-C7l2cv4e.d.cts +8 -0
- package/dist/validation-shared-CJjGRx8p.d.mts +7 -0
- package/dist/validation-shared-mh_saZne.mjs +29 -0
- package/dist/validation-shared-mh_saZne.mjs.map +1 -0
- package/dist/zod.cjs +49 -0
- package/dist/zod.cjs.map +1 -0
- package/dist/zod.d.cts +21 -0
- package/dist/zod.d.mts +21 -0
- package/dist/zod.mjs +42 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +177 -29
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.mjs.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.d.ts +0 -30
- package/dist/react.mjs.map +0 -1
- package/dist/types-DzSw8Uw2.d.mts +0 -52
- package/dist/types-DzSw8Uw2.d.ts +0 -52
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
// src/keyboard.ts
|
|
2
|
+
const LATIN_TO_PERSIAN = {
|
|
3
|
+
q: "ض",
|
|
4
|
+
w: "ص",
|
|
5
|
+
e: "ث",
|
|
6
|
+
r: "ق",
|
|
7
|
+
t: "ف",
|
|
8
|
+
y: "غ",
|
|
9
|
+
u: "ع",
|
|
10
|
+
i: "ه",
|
|
11
|
+
o: "خ",
|
|
12
|
+
p: "ح",
|
|
13
|
+
"[": "ج",
|
|
14
|
+
"]": "چ",
|
|
15
|
+
a: "ش",
|
|
16
|
+
s: "س",
|
|
17
|
+
d: "ی",
|
|
18
|
+
f: "ب",
|
|
19
|
+
g: "ل",
|
|
20
|
+
h: "ا",
|
|
21
|
+
j: "ت",
|
|
22
|
+
k: "ن",
|
|
23
|
+
l: "م",
|
|
24
|
+
";": "ک",
|
|
25
|
+
"'": "گ",
|
|
26
|
+
z: "ظ",
|
|
27
|
+
x: "ط",
|
|
28
|
+
c: "ز",
|
|
29
|
+
v: "ر",
|
|
30
|
+
b: "ذ",
|
|
31
|
+
n: "د",
|
|
32
|
+
m: "پ",
|
|
33
|
+
",": "و",
|
|
34
|
+
"\\": "پ",
|
|
35
|
+
"`": "پ",
|
|
36
|
+
C: "ژ",
|
|
37
|
+
H: "آ"
|
|
38
|
+
};
|
|
39
|
+
const PERSIAN_TO_LATIN = (() => {
|
|
40
|
+
const map = {};
|
|
41
|
+
for (const [latin, persian] of Object.entries(LATIN_TO_PERSIAN)) if (!(persian in map)) map[persian] = latin.toLowerCase();
|
|
42
|
+
map["ي"] = "d";
|
|
43
|
+
map["ك"] = ";";
|
|
44
|
+
map["ئ"] = "m";
|
|
45
|
+
return map;
|
|
46
|
+
})();
|
|
47
|
+
const HAS_LATIN_LETTER = /[a-z]/i;
|
|
48
|
+
const HAS_PERSIAN_LETTER = /[-ۿ]/;
|
|
49
|
+
function convertKeyboardLayout(text, to) {
|
|
50
|
+
const input = typeof text === "string" ? text : "";
|
|
51
|
+
let out = "";
|
|
52
|
+
for (const ch of input) if (to === "fa") {
|
|
53
|
+
var _ref, _LATIN_TO_PERSIAN$ch;
|
|
54
|
+
out += (_ref = (_LATIN_TO_PERSIAN$ch = LATIN_TO_PERSIAN[ch]) !== null && _LATIN_TO_PERSIAN$ch !== void 0 ? _LATIN_TO_PERSIAN$ch : LATIN_TO_PERSIAN[ch.toLowerCase()]) !== null && _ref !== void 0 ? _ref : ch;
|
|
55
|
+
} else {
|
|
56
|
+
var _PERSIAN_TO_LATIN$ch;
|
|
57
|
+
out += (_PERSIAN_TO_LATIN$ch = PERSIAN_TO_LATIN[ch]) !== null && _PERSIAN_TO_LATIN$ch !== void 0 ? _PERSIAN_TO_LATIN$ch : ch;
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
function guessKeyboardTarget(text) {
|
|
62
|
+
if (typeof text !== "string") return void 0;
|
|
63
|
+
const latin = HAS_LATIN_LETTER.test(text);
|
|
64
|
+
const persian = HAS_PERSIAN_LETTER.test(text);
|
|
65
|
+
if (latin && !persian) return "fa";
|
|
66
|
+
if (persian && !latin) return "en";
|
|
67
|
+
}
|
|
68
|
+
// src/normalize.ts
|
|
69
|
+
const CHAR_MAP = {
|
|
70
|
+
"ي": "ی",
|
|
71
|
+
"ى": "ی",
|
|
72
|
+
"ئ": "ی",
|
|
73
|
+
"ك": "ک",
|
|
74
|
+
"ة": "ه",
|
|
75
|
+
"ۀ": "ه",
|
|
76
|
+
"ؤ": "و",
|
|
77
|
+
"أ": "ا",
|
|
78
|
+
"إ": "ا",
|
|
79
|
+
"آ": "ا",
|
|
80
|
+
"ٱ": "ا"
|
|
81
|
+
};
|
|
82
|
+
function normalize(input) {
|
|
83
|
+
return input.trim().toLowerCase().replace(/[۰-۹]/g, (d) => String(d.charCodeAt(0) - 1776)).replace(/[٠-٩]/g, (d) => String(d.charCodeAt(0) - 1632)).replace(/[ً-ٰٟـ]/g, "").replace(/[يىئكةۀؤأإآٱ]/g, (ch) => {
|
|
84
|
+
var _CHAR_MAP$ch;
|
|
85
|
+
return (_CHAR_MAP$ch = CHAR_MAP[ch]) !== null && _CHAR_MAP$ch !== void 0 ? _CHAR_MAP$ch : ch;
|
|
86
|
+
}).replace(/[\s\-_'’`]+/g, "");
|
|
87
|
+
}
|
|
88
|
+
// src/core.ts
|
|
89
|
+
const LATIN = /[a-z]/;
|
|
90
|
+
const LOWERCASE_WORDS = /* @__PURE__ */ new Set([
|
|
91
|
+
"va",
|
|
92
|
+
"and",
|
|
93
|
+
"o"
|
|
94
|
+
]);
|
|
95
|
+
function displayNameFromSlug(slug) {
|
|
96
|
+
const parts = slug.split("-").filter(Boolean);
|
|
97
|
+
let out = "";
|
|
98
|
+
for (const part of parts) {
|
|
99
|
+
if ((part === "e" || part === "ye") && out) {
|
|
100
|
+
out += `-${part}`;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const word = LOWERCASE_WORDS.has(part) && out ? part : part.charAt(0).toUpperCase() + part.slice(1);
|
|
104
|
+
out += out ? ` ${word}` : word;
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
function toText(value) {
|
|
109
|
+
if (typeof value === "string") return value;
|
|
110
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
function isPresent(value) {
|
|
114
|
+
return value !== void 0 && value !== null && toText(value).trim() !== "";
|
|
115
|
+
}
|
|
116
|
+
function boundedLevenshtein(a, b, max) {
|
|
117
|
+
if (a === b) return 0;
|
|
118
|
+
if (Math.abs(a.length - b.length) > max) return max + 1;
|
|
119
|
+
if (a.length === 0) return b.length;
|
|
120
|
+
if (b.length === 0) return a.length;
|
|
121
|
+
let prev = [];
|
|
122
|
+
for (let j = 0; j <= b.length; j++) prev.push(j);
|
|
123
|
+
for (let i = 1; i <= a.length; i++) {
|
|
124
|
+
const curr = [i];
|
|
125
|
+
let rowMin = i;
|
|
126
|
+
for (let j = 1; j <= b.length; j++) {
|
|
127
|
+
const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
|
|
128
|
+
const value = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
129
|
+
curr.push(value);
|
|
130
|
+
if (value < rowMin) rowMin = value;
|
|
131
|
+
}
|
|
132
|
+
if (rowMin > max) return max + 1;
|
|
133
|
+
prev = curr;
|
|
134
|
+
}
|
|
135
|
+
return prev[b.length];
|
|
136
|
+
}
|
|
137
|
+
function matchScore(query, target, fuzzy, maxDistance) {
|
|
138
|
+
if (!target) return 1e400;
|
|
139
|
+
if (target === query) return 0;
|
|
140
|
+
if (target.startsWith(query)) return 1;
|
|
141
|
+
if (target.includes(query)) return 2;
|
|
142
|
+
if (!fuzzy) return 1e400;
|
|
143
|
+
let best = 1e400;
|
|
144
|
+
const full = boundedLevenshtein(query, target, maxDistance);
|
|
145
|
+
if (full <= maxDistance) best = 3 + full;
|
|
146
|
+
if (query.length >= 3 && target.length > query.length) for (const len of [
|
|
147
|
+
query.length - 1,
|
|
148
|
+
query.length,
|
|
149
|
+
query.length + 1
|
|
150
|
+
]) {
|
|
151
|
+
if (len < 1 || len >= target.length) continue;
|
|
152
|
+
const prefix = boundedLevenshtein(query, target.slice(0, len), maxDistance);
|
|
153
|
+
if (prefix <= maxDistance) best = Math.min(best, 3.5 + prefix);
|
|
154
|
+
}
|
|
155
|
+
return best;
|
|
156
|
+
}
|
|
157
|
+
function deepFreeze(value) {
|
|
158
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
159
|
+
Object.freeze(value);
|
|
160
|
+
for (const key of Object.keys(value)) deepFreeze(value[key]);
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
164
|
+
function createCollator() {
|
|
165
|
+
try {
|
|
166
|
+
return new Intl.Collator("fa").compare;
|
|
167
|
+
} catch {
|
|
168
|
+
return (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function pickPreferred(list, primaryIds) {
|
|
172
|
+
var _ref, _list$find;
|
|
173
|
+
return (_ref = (_list$find = list.find((c) => c.isCapital)) !== null && _list$find !== void 0 ? _list$find : list.find((c) => primaryIds.has(c.id))) !== null && _ref !== void 0 ? _ref : list.reduce((a, b) => b.id < a.id ? b : a);
|
|
174
|
+
}
|
|
175
|
+
function pushTo(map, key, value) {
|
|
176
|
+
const list = map.get(key);
|
|
177
|
+
if (!list) map.set(key, [value]);
|
|
178
|
+
else if (!list.includes(value)) list.push(value);
|
|
179
|
+
}
|
|
180
|
+
function cityKeys(city) {
|
|
181
|
+
const keys = [{
|
|
182
|
+
value: normalize(city.en),
|
|
183
|
+
locale: "en"
|
|
184
|
+
}, {
|
|
185
|
+
value: normalize(city.fa),
|
|
186
|
+
locale: "fa"
|
|
187
|
+
}];
|
|
188
|
+
for (const alias of city.aliases) keys.push({
|
|
189
|
+
value: normalize(alias),
|
|
190
|
+
locale: LATIN.test(alias.toLowerCase()) ? "en" : "fa"
|
|
191
|
+
});
|
|
192
|
+
return keys;
|
|
193
|
+
}
|
|
194
|
+
function createApi(rawData) {
|
|
195
|
+
const compare = createCollator();
|
|
196
|
+
const primaryIds = /* @__PURE__ */ new Set();
|
|
197
|
+
const legacySlugs = [];
|
|
198
|
+
const provinces = rawData.map((p) => {
|
|
199
|
+
const provinceEn = p["province-en"];
|
|
200
|
+
return {
|
|
201
|
+
id: p["province-id"],
|
|
202
|
+
en: provinceEn,
|
|
203
|
+
fa: p["province-fa"],
|
|
204
|
+
nameEn: p["name-en"],
|
|
205
|
+
phoneCode: p["phone-code"],
|
|
206
|
+
capitalId: p["capital-city-id"],
|
|
207
|
+
neighborIds: [...p.neighbors],
|
|
208
|
+
cities: p.cities.map((c) => {
|
|
209
|
+
var _c$legacySlugs, _c$nameEn;
|
|
210
|
+
if (c.primary) primaryIds.add(c["city-id"]);
|
|
211
|
+
for (const slug of (_c$legacySlugs = c["legacy-slugs"]) !== null && _c$legacySlugs !== void 0 ? _c$legacySlugs : []) legacySlugs.push([slug, c["city-id"]]);
|
|
212
|
+
const city = {
|
|
213
|
+
id: c["city-id"],
|
|
214
|
+
isCapital: c["city-id"] === p["capital-city-id"],
|
|
215
|
+
en: c["city-en"],
|
|
216
|
+
fa: c["city-fa"],
|
|
217
|
+
nameEn: (_c$nameEn = c["name-en"]) !== null && _c$nameEn !== void 0 ? _c$nameEn : displayNameFromSlug(c["city-en"]),
|
|
218
|
+
slug: `${provinceEn}/${c["city-en"]}`,
|
|
219
|
+
aliases: c.aliases ? [...c.aliases] : []
|
|
220
|
+
};
|
|
221
|
+
if (typeof c.lat === "number" && typeof c.lng === "number") {
|
|
222
|
+
var _c$coordConfidence;
|
|
223
|
+
city.coordinates = {
|
|
224
|
+
lat: c.lat,
|
|
225
|
+
lng: c.lng,
|
|
226
|
+
confidence: (_c$coordConfidence = c["coord-confidence"]) !== null && _c$coordConfidence !== void 0 ? _c$coordConfidence : "high"
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return city;
|
|
230
|
+
})
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
const flatCities = [];
|
|
234
|
+
const cityBySlug = /* @__PURE__ */ new Map();
|
|
235
|
+
const cityById = /* @__PURE__ */ new Map();
|
|
236
|
+
const provinceById = /* @__PURE__ */ new Map();
|
|
237
|
+
const provinceByPhoneCode = /* @__PURE__ */ new Map();
|
|
238
|
+
const provinceByNormKey = /* @__PURE__ */ new Map();
|
|
239
|
+
const citiesByNormKey = /* @__PURE__ */ new Map();
|
|
240
|
+
const searchableCities = [];
|
|
241
|
+
const searchableProvinces = [];
|
|
242
|
+
for (const p of provinces) {
|
|
243
|
+
provinceById.set(p.id, p);
|
|
244
|
+
provinceByPhoneCode.set(p.phoneCode, p);
|
|
245
|
+
const pKeys = [{
|
|
246
|
+
value: normalize(p.en),
|
|
247
|
+
locale: "en"
|
|
248
|
+
}, {
|
|
249
|
+
value: normalize(p.fa),
|
|
250
|
+
locale: "fa"
|
|
251
|
+
}];
|
|
252
|
+
for (const k of pKeys) if (!provinceByNormKey.has(k.value)) provinceByNormKey.set(k.value, p);
|
|
253
|
+
searchableProvinces.push({
|
|
254
|
+
item: p,
|
|
255
|
+
keys: pKeys,
|
|
256
|
+
isCapital: false,
|
|
257
|
+
rank: 0
|
|
258
|
+
});
|
|
259
|
+
for (const c of p.cities) {
|
|
260
|
+
const flat = {
|
|
261
|
+
...c,
|
|
262
|
+
provinceId: p.id,
|
|
263
|
+
provinceEn: p.en,
|
|
264
|
+
provinceFa: p.fa,
|
|
265
|
+
provinceNameEn: p.nameEn,
|
|
266
|
+
phoneCode: p.phoneCode
|
|
267
|
+
};
|
|
268
|
+
flatCities.push(flat);
|
|
269
|
+
cityBySlug.set(flat.slug, flat);
|
|
270
|
+
cityById.set(flat.id, flat);
|
|
271
|
+
const keys = cityKeys(flat);
|
|
272
|
+
for (const k of keys) pushTo(citiesByNormKey, k.value, flat);
|
|
273
|
+
searchableCities.push({
|
|
274
|
+
item: flat,
|
|
275
|
+
keys,
|
|
276
|
+
isCapital: flat.isCapital,
|
|
277
|
+
rank: 0
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (const [slug, id] of legacySlugs) {
|
|
282
|
+
const flat = cityById.get(id);
|
|
283
|
+
if (flat && !cityBySlug.has(slug)) cityBySlug.set(slug, flat);
|
|
284
|
+
}
|
|
285
|
+
const cityByNormKey = /* @__PURE__ */ new Map();
|
|
286
|
+
for (const [key, list] of citiesByNormKey) {
|
|
287
|
+
list.sort((a, b) => a.id - b.id);
|
|
288
|
+
cityByNormKey.set(key, pickPreferred(list, primaryIds));
|
|
289
|
+
}
|
|
290
|
+
[...searchableCities].sort((a, b) => compare(a.item.fa, b.item.fa) || a.item.id - b.item.id).forEach((entry, index) => {
|
|
291
|
+
entry.rank = index;
|
|
292
|
+
});
|
|
293
|
+
[...searchableProvinces].sort((a, b) => compare(a.item.fa, b.item.fa) || a.item.id - b.item.id).forEach((entry, index) => {
|
|
294
|
+
entry.rank = index;
|
|
295
|
+
});
|
|
296
|
+
const capitals = provinces.map((p) => cityById.get(p.capitalId));
|
|
297
|
+
const stats = {
|
|
298
|
+
provinceCount: provinces.length,
|
|
299
|
+
cityCount: flatCities.length
|
|
300
|
+
};
|
|
301
|
+
deepFreeze(provinces);
|
|
302
|
+
deepFreeze(flatCities);
|
|
303
|
+
deepFreeze(capitals);
|
|
304
|
+
deepFreeze(stats);
|
|
305
|
+
for (const list of citiesByNormKey.values()) Object.freeze(list);
|
|
306
|
+
const emptyCities = Object.freeze([]);
|
|
307
|
+
const emptyCityList = Object.freeze([]);
|
|
308
|
+
function rankedSearch(pool, query, options) {
|
|
309
|
+
const opts = options !== null && options !== void 0 ? options : {};
|
|
310
|
+
const text = toText(query);
|
|
311
|
+
const q = normalize(text);
|
|
312
|
+
const target = opts.keyboardFix === false || !q ? void 0 : guessKeyboardTarget(text);
|
|
313
|
+
const converted = target ? normalize(convertKeyboardLayout(text, target)) : "";
|
|
314
|
+
if (!converted || converted === q) return rankedSearchOnce(pool, q, opts);
|
|
315
|
+
const convertedOptions = {
|
|
316
|
+
...opts,
|
|
317
|
+
locale: target,
|
|
318
|
+
emptyQuery: "none"
|
|
319
|
+
};
|
|
320
|
+
if (rankedSearchOnce(pool, q, {
|
|
321
|
+
...opts,
|
|
322
|
+
fuzzy: false,
|
|
323
|
+
limit: 1
|
|
324
|
+
}).length > 0) return rankedSearchOnce(pool, q, opts);
|
|
325
|
+
if (rankedSearchOnce(pool, converted, {
|
|
326
|
+
...convertedOptions,
|
|
327
|
+
fuzzy: false,
|
|
328
|
+
limit: 1
|
|
329
|
+
}).length > 0) return rankedSearchOnce(pool, converted, convertedOptions);
|
|
330
|
+
const fuzzyResults = rankedSearchOnce(pool, q, opts);
|
|
331
|
+
return fuzzyResults.length > 0 ? fuzzyResults : rankedSearchOnce(pool, converted, convertedOptions);
|
|
332
|
+
}
|
|
333
|
+
function rankedSearchOnce(pool, q, opts) {
|
|
334
|
+
var _opts$locale, _opts$fuzzy;
|
|
335
|
+
const limit = typeof opts.limit === "number" && opts.limit > 0 ? Math.floor(opts.limit) : void 0;
|
|
336
|
+
if (!q) {
|
|
337
|
+
if (opts.emptyQuery === "none") return [];
|
|
338
|
+
const all = pool.map((e) => e.item);
|
|
339
|
+
return limit ? all.slice(0, limit) : all;
|
|
340
|
+
}
|
|
341
|
+
const locale = (_opts$locale = opts.locale) !== null && _opts$locale !== void 0 ? _opts$locale : "both";
|
|
342
|
+
const fuzzy = (_opts$fuzzy = opts.fuzzy) !== null && _opts$fuzzy !== void 0 ? _opts$fuzzy : false;
|
|
343
|
+
const requested = typeof opts.maxDistance === "number" && opts.maxDistance >= 0 ? Math.floor(opts.maxDistance) : 2;
|
|
344
|
+
const maxDistance = Math.min(requested, Math.floor(q.length / 3));
|
|
345
|
+
const scored = [];
|
|
346
|
+
for (const entry of pool) {
|
|
347
|
+
let score = 1e400;
|
|
348
|
+
for (const key of entry.keys) {
|
|
349
|
+
if (locale !== "both" && key.locale !== locale) continue;
|
|
350
|
+
score = Math.min(score, matchScore(q, key.value, fuzzy, maxDistance));
|
|
351
|
+
if (score === 0) break;
|
|
352
|
+
}
|
|
353
|
+
if (score !== 1e400) scored.push({
|
|
354
|
+
entry,
|
|
355
|
+
score
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
scored.sort((a, b) => a.score - b.score || Number(b.entry.isCapital) - Number(a.entry.isCapital) || a.entry.rank - b.entry.rank);
|
|
359
|
+
const results = scored.map((s) => s.entry.item);
|
|
360
|
+
return limit ? results.slice(0, limit) : results;
|
|
361
|
+
}
|
|
362
|
+
function asId(query) {
|
|
363
|
+
if (typeof query === "number") return Number.isInteger(query) ? query : void 0;
|
|
364
|
+
const t = normalize(toText(query));
|
|
365
|
+
return /^\d+$/.test(t) ? Number(t) : void 0;
|
|
366
|
+
}
|
|
367
|
+
function cityMatches(city, key) {
|
|
368
|
+
return normalize(city.en) === key || normalize(city.fa) === key || city.aliases.some((a) => normalize(a) === key);
|
|
369
|
+
}
|
|
370
|
+
function getProvinces() {
|
|
371
|
+
return provinces;
|
|
372
|
+
}
|
|
373
|
+
function getProvincesList() {
|
|
374
|
+
return provinces.map((p) => ({
|
|
375
|
+
id: p.id,
|
|
376
|
+
en: p.en,
|
|
377
|
+
fa: p.fa,
|
|
378
|
+
nameEn: p.nameEn,
|
|
379
|
+
phoneCode: p.phoneCode,
|
|
380
|
+
capitalId: p.capitalId
|
|
381
|
+
}));
|
|
382
|
+
}
|
|
383
|
+
function getProvinceById(id) {
|
|
384
|
+
return provinceById.get(Number(id));
|
|
385
|
+
}
|
|
386
|
+
function getProvince(query) {
|
|
387
|
+
if (!isPresent(query)) return void 0;
|
|
388
|
+
const id = asId(query);
|
|
389
|
+
if (id !== void 0) return provinceById.get(id);
|
|
390
|
+
return provinceByNormKey.get(normalize(toText(query)));
|
|
391
|
+
}
|
|
392
|
+
function getCities(provinceQuery) {
|
|
393
|
+
var _getProvince$cities, _getProvince;
|
|
394
|
+
return (_getProvince$cities = (_getProvince = getProvince(provinceQuery)) === null || _getProvince === void 0 ? void 0 : _getProvince.cities) !== null && _getProvince$cities !== void 0 ? _getProvince$cities : emptyCityList;
|
|
395
|
+
}
|
|
396
|
+
function getAllCities() {
|
|
397
|
+
return flatCities;
|
|
398
|
+
}
|
|
399
|
+
function getCityById(id) {
|
|
400
|
+
return cityById.get(Number(id));
|
|
401
|
+
}
|
|
402
|
+
function getCityBySlug(slug) {
|
|
403
|
+
return cityBySlug.get(toText(slug).trim());
|
|
404
|
+
}
|
|
405
|
+
function getCity(cityQuery, provinceQuery) {
|
|
406
|
+
if (!isPresent(cityQuery)) return void 0;
|
|
407
|
+
const cityId = asId(cityQuery);
|
|
408
|
+
if (isPresent(provinceQuery)) {
|
|
409
|
+
const province = getProvince(provinceQuery);
|
|
410
|
+
if (!province) return void 0;
|
|
411
|
+
const key = cityId === void 0 ? normalize(toText(cityQuery)) : "";
|
|
412
|
+
const city = province.cities.find((c) => cityId !== void 0 ? c.id === cityId : cityMatches(c, key));
|
|
413
|
+
return city ? cityById.get(city.id) : void 0;
|
|
414
|
+
}
|
|
415
|
+
if (cityId !== void 0) return cityById.get(cityId);
|
|
416
|
+
return cityByNormKey.get(normalize(toText(cityQuery)));
|
|
417
|
+
}
|
|
418
|
+
function getCitiesByName(cityQuery) {
|
|
419
|
+
const key = normalize(toText(cityQuery));
|
|
420
|
+
return key && citiesByNormKey.get(key) || emptyCities;
|
|
421
|
+
}
|
|
422
|
+
function isAmbiguousCityName(cityQuery) {
|
|
423
|
+
return getCitiesByName(cityQuery).length > 1;
|
|
424
|
+
}
|
|
425
|
+
function getProvinceOfCity(cityQuery) {
|
|
426
|
+
const city = getCity(cityQuery);
|
|
427
|
+
return city ? provinceById.get(city.provinceId) : void 0;
|
|
428
|
+
}
|
|
429
|
+
function getCapital(provinceQuery) {
|
|
430
|
+
const p = getProvince(provinceQuery);
|
|
431
|
+
return p ? cityById.get(p.capitalId) : void 0;
|
|
432
|
+
}
|
|
433
|
+
function getCapitals() {
|
|
434
|
+
return capitals.slice();
|
|
435
|
+
}
|
|
436
|
+
function getProvinceByPhoneCode(code) {
|
|
437
|
+
let digits = normalize(toText(code)).replace(/^\+/, "").replace(/^0+/, "");
|
|
438
|
+
if (digits.length > 2 && digits.startsWith("98")) digits = digits.slice(2).replace(/^0+/, "");
|
|
439
|
+
if (!/^\d+$/.test(digits)) return void 0;
|
|
440
|
+
return provinceByPhoneCode.get(`0${digits}`);
|
|
441
|
+
}
|
|
442
|
+
function searchProvinces(query, options) {
|
|
443
|
+
return rankedSearch(searchableProvinces, query, options);
|
|
444
|
+
}
|
|
445
|
+
function searchCities(query, options) {
|
|
446
|
+
return rankedSearch(searchableCities, query, options);
|
|
447
|
+
}
|
|
448
|
+
function getNeighborProvinces(provinceQuery) {
|
|
449
|
+
const province = getProvince(provinceQuery);
|
|
450
|
+
if (!province) return [];
|
|
451
|
+
return province.neighborIds.map((id) => provinceById.get(id));
|
|
452
|
+
}
|
|
453
|
+
function areNeighborProvinces(a, b) {
|
|
454
|
+
const first = getProvince(a);
|
|
455
|
+
const second = getProvince(b);
|
|
456
|
+
return !!first && !!second && first.neighborIds.includes(second.id);
|
|
457
|
+
}
|
|
458
|
+
function getStats() {
|
|
459
|
+
return stats;
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
getProvinces,
|
|
463
|
+
getProvincesList,
|
|
464
|
+
getProvinceById,
|
|
465
|
+
getProvince,
|
|
466
|
+
getCities,
|
|
467
|
+
getAllCities,
|
|
468
|
+
getCityById,
|
|
469
|
+
getCityBySlug,
|
|
470
|
+
getCity,
|
|
471
|
+
getCitiesByName,
|
|
472
|
+
isAmbiguousCityName,
|
|
473
|
+
getProvinceOfCity,
|
|
474
|
+
getCapital,
|
|
475
|
+
getCapitals,
|
|
476
|
+
getProvinceByPhoneCode,
|
|
477
|
+
searchProvinces,
|
|
478
|
+
searchCities,
|
|
479
|
+
getNeighborProvinces,
|
|
480
|
+
areNeighborProvinces,
|
|
481
|
+
getStats
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
// src/packed.ts
|
|
485
|
+
const SCALE = 1e7;
|
|
486
|
+
const CONFIDENCE = {
|
|
487
|
+
"1": "high",
|
|
488
|
+
"2": "medium",
|
|
489
|
+
"3": "low"
|
|
490
|
+
};
|
|
491
|
+
function unpack(packed) {
|
|
492
|
+
if (packed.format !== 1) throw new Error(`Unsupported data format ${packed.format}`);
|
|
493
|
+
const en = packed.en.split("|");
|
|
494
|
+
const fa = packed.fa.split("|");
|
|
495
|
+
const extras = /* @__PURE__ */ new Map();
|
|
496
|
+
for (const extra of packed.extras) extras.set(extra[0], extra);
|
|
497
|
+
let id = 0;
|
|
498
|
+
let lat = 0;
|
|
499
|
+
let lng = 0;
|
|
500
|
+
let coordIndex = 0;
|
|
501
|
+
let cityIndex = 0;
|
|
502
|
+
return packed.provinces.map(([provinceId, provinceEn, provinceFa, phoneCode, capitalId, nameEn, neighbors, count]) => {
|
|
503
|
+
const cities = [];
|
|
504
|
+
for (let n = 0; n < count; n++, cityIndex++) {
|
|
505
|
+
var _packed$confidence;
|
|
506
|
+
id += packed.ids[cityIndex];
|
|
507
|
+
const city = {
|
|
508
|
+
"city-id": id,
|
|
509
|
+
"city-en": en[cityIndex],
|
|
510
|
+
"city-fa": fa[cityIndex]
|
|
511
|
+
};
|
|
512
|
+
const code = (_packed$confidence = packed.confidence) === null || _packed$confidence === void 0 ? void 0 : _packed$confidence.charAt(cityIndex);
|
|
513
|
+
if (code && code !== "0" && packed.lat && packed.lng) {
|
|
514
|
+
lat += packed.lat[coordIndex];
|
|
515
|
+
lng += packed.lng[coordIndex];
|
|
516
|
+
coordIndex++;
|
|
517
|
+
city.lat = lat / SCALE;
|
|
518
|
+
city.lng = lng / SCALE;
|
|
519
|
+
const confidence = CONFIDENCE[code];
|
|
520
|
+
if (confidence && confidence !== "high") city["coord-confidence"] = confidence;
|
|
521
|
+
}
|
|
522
|
+
const extra = extras.get(cityIndex);
|
|
523
|
+
if (extra) {
|
|
524
|
+
if (extra[1]) city["name-en"] = extra[1];
|
|
525
|
+
if (extra[2]) city.aliases = extra[2];
|
|
526
|
+
if (extra[3]) city.primary = true;
|
|
527
|
+
if (extra[4]) city["legacy-slugs"] = extra[4];
|
|
528
|
+
}
|
|
529
|
+
cities.push(city);
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
"province-id": provinceId,
|
|
533
|
+
"province-en": provinceEn,
|
|
534
|
+
"province-fa": provinceFa,
|
|
535
|
+
"phone-code": phoneCode,
|
|
536
|
+
"capital-city-id": capitalId,
|
|
537
|
+
"name-en": nameEn,
|
|
538
|
+
neighbors,
|
|
539
|
+
cities
|
|
540
|
+
};
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
// src/changes.ts
|
|
544
|
+
const DATA_VERSION = "2.0.0";
|
|
545
|
+
const DATA_CHANGES = Object.freeze([
|
|
546
|
+
Object.freeze({
|
|
547
|
+
version: "1.2.0",
|
|
548
|
+
type: "removed",
|
|
549
|
+
provinceId: 20,
|
|
550
|
+
before: Object.freeze({ fa: "گلوگاه" }),
|
|
551
|
+
note: "Duplicate entry of Galugah in Mazandaran removed; the remaining entry keeps the city."
|
|
552
|
+
}),
|
|
553
|
+
Object.freeze({
|
|
554
|
+
version: "1.2.0",
|
|
555
|
+
type: "renamed",
|
|
556
|
+
cityId: 402,
|
|
557
|
+
before: Object.freeze({
|
|
558
|
+
en: "sowme'eh-sara",
|
|
559
|
+
slug: "gilan/sowme'eh-sara"
|
|
560
|
+
}),
|
|
561
|
+
after: Object.freeze({
|
|
562
|
+
en: "sowmeeh-sara",
|
|
563
|
+
fa: "صومعه سرا",
|
|
564
|
+
slug: "gilan/sowmeeh-sara"
|
|
565
|
+
}),
|
|
566
|
+
note: "English id normalized to kebab-case; the old id still resolves."
|
|
567
|
+
}),
|
|
568
|
+
Object.freeze({
|
|
569
|
+
version: "1.2.0",
|
|
570
|
+
type: "renamed",
|
|
571
|
+
cityId: 672,
|
|
572
|
+
before: Object.freeze({
|
|
573
|
+
en: "هلشی",
|
|
574
|
+
slug: "kermanshah/هلشی"
|
|
575
|
+
}),
|
|
576
|
+
after: Object.freeze({
|
|
577
|
+
en: "halashi",
|
|
578
|
+
fa: "هلشی",
|
|
579
|
+
slug: "kermanshah/halashi"
|
|
580
|
+
}),
|
|
581
|
+
note: "English id was a Persian string; the old id still resolves."
|
|
582
|
+
}),
|
|
583
|
+
Object.freeze({
|
|
584
|
+
version: "2.0.0",
|
|
585
|
+
type: "spelling",
|
|
586
|
+
cityId: 145,
|
|
587
|
+
before: Object.freeze({ fa: "كليبر" }),
|
|
588
|
+
after: Object.freeze({ fa: "کلیبر" }),
|
|
589
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
590
|
+
}),
|
|
591
|
+
Object.freeze({
|
|
592
|
+
version: "2.0.0",
|
|
593
|
+
type: "spelling",
|
|
594
|
+
cityId: 147,
|
|
595
|
+
before: Object.freeze({ fa: "صوفيان" }),
|
|
596
|
+
after: Object.freeze({ fa: "صوفیان" }),
|
|
597
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
598
|
+
}),
|
|
599
|
+
Object.freeze({
|
|
600
|
+
version: "2.0.0",
|
|
601
|
+
type: "spelling",
|
|
602
|
+
cityId: 152,
|
|
603
|
+
before: Object.freeze({ fa: "كلوانق" }),
|
|
604
|
+
after: Object.freeze({ fa: "کلوانق" }),
|
|
605
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
606
|
+
}),
|
|
607
|
+
Object.freeze({
|
|
608
|
+
version: "2.0.0",
|
|
609
|
+
type: "spelling",
|
|
610
|
+
cityId: 418,
|
|
611
|
+
before: Object.freeze({ fa: "لوندويل" }),
|
|
612
|
+
after: Object.freeze({ fa: "لوندویل" }),
|
|
613
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
614
|
+
}),
|
|
615
|
+
Object.freeze({
|
|
616
|
+
version: "2.0.0",
|
|
617
|
+
type: "spelling",
|
|
618
|
+
cityId: 438,
|
|
619
|
+
before: Object.freeze({ fa: "ليسار" }),
|
|
620
|
+
after: Object.freeze({ fa: "لیسار" }),
|
|
621
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
622
|
+
}),
|
|
623
|
+
Object.freeze({
|
|
624
|
+
version: "2.0.0",
|
|
625
|
+
type: "spelling",
|
|
626
|
+
cityId: 487,
|
|
627
|
+
before: Object.freeze({ fa: "مريانج" }),
|
|
628
|
+
after: Object.freeze({ fa: "مریانج" }),
|
|
629
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
630
|
+
}),
|
|
631
|
+
Object.freeze({
|
|
632
|
+
version: "2.0.0",
|
|
633
|
+
type: "spelling",
|
|
634
|
+
cityId: 529,
|
|
635
|
+
before: Object.freeze({ fa: "تازيان پايين" }),
|
|
636
|
+
after: Object.freeze({ fa: "تازیان پایین" }),
|
|
637
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
638
|
+
}),
|
|
639
|
+
Object.freeze({
|
|
640
|
+
version: "2.0.0",
|
|
641
|
+
type: "spelling",
|
|
642
|
+
cityId: 545,
|
|
643
|
+
before: Object.freeze({ fa: "كوخرد" }),
|
|
644
|
+
after: Object.freeze({ fa: "کوخرد" }),
|
|
645
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
646
|
+
}),
|
|
647
|
+
Object.freeze({
|
|
648
|
+
version: "2.0.0",
|
|
649
|
+
type: "spelling",
|
|
650
|
+
cityId: 551,
|
|
651
|
+
before: Object.freeze({ fa: "اركواز" }),
|
|
652
|
+
after: Object.freeze({ fa: "ارکواز" }),
|
|
653
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
654
|
+
}),
|
|
655
|
+
Object.freeze({
|
|
656
|
+
version: "2.0.0",
|
|
657
|
+
type: "spelling",
|
|
658
|
+
cityId: 564,
|
|
659
|
+
before: Object.freeze({ fa: "موسيان" }),
|
|
660
|
+
after: Object.freeze({ fa: "موسیان" }),
|
|
661
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
662
|
+
}),
|
|
663
|
+
Object.freeze({
|
|
664
|
+
version: "2.0.0",
|
|
665
|
+
type: "spelling",
|
|
666
|
+
cityId: 714,
|
|
667
|
+
before: Object.freeze({ fa: "چويبده" }),
|
|
668
|
+
after: Object.freeze({ fa: "چویبده" }),
|
|
669
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
670
|
+
}),
|
|
671
|
+
Object.freeze({
|
|
672
|
+
version: "2.0.0",
|
|
673
|
+
type: "spelling",
|
|
674
|
+
cityId: 716,
|
|
675
|
+
before: Object.freeze({ fa: "صيدون" }),
|
|
676
|
+
after: Object.freeze({ fa: "صیدون" }),
|
|
677
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
678
|
+
}),
|
|
679
|
+
Object.freeze({
|
|
680
|
+
version: "2.0.0",
|
|
681
|
+
type: "spelling",
|
|
682
|
+
cityId: 749,
|
|
683
|
+
before: Object.freeze({ fa: "گلگير" }),
|
|
684
|
+
after: Object.freeze({ fa: "گلگیر" }),
|
|
685
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
686
|
+
}),
|
|
687
|
+
Object.freeze({
|
|
688
|
+
version: "2.0.0",
|
|
689
|
+
type: "spelling",
|
|
690
|
+
cityId: 910,
|
|
691
|
+
before: Object.freeze({ fa: "پايين هولار" }),
|
|
692
|
+
after: Object.freeze({ fa: "پایین هولار" }),
|
|
693
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
694
|
+
}),
|
|
695
|
+
Object.freeze({
|
|
696
|
+
version: "2.0.0",
|
|
697
|
+
type: "spelling",
|
|
698
|
+
cityId: 947,
|
|
699
|
+
before: Object.freeze({ fa: "اسفرورين" }),
|
|
700
|
+
after: Object.freeze({ fa: "اسفرورین" }),
|
|
701
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
702
|
+
}),
|
|
703
|
+
Object.freeze({
|
|
704
|
+
version: "2.0.0",
|
|
705
|
+
type: "spelling",
|
|
706
|
+
cityId: 1025,
|
|
707
|
+
before: Object.freeze({ fa: "كدكن" }),
|
|
708
|
+
after: Object.freeze({ fa: "کدکن" }),
|
|
709
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
710
|
+
}),
|
|
711
|
+
Object.freeze({
|
|
712
|
+
version: "2.0.0",
|
|
713
|
+
type: "spelling",
|
|
714
|
+
cityId: 1077,
|
|
715
|
+
before: Object.freeze({ fa: "گلمورتي" }),
|
|
716
|
+
after: Object.freeze({ fa: "گلمورتی" }),
|
|
717
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
718
|
+
}),
|
|
719
|
+
Object.freeze({
|
|
720
|
+
version: "2.0.0",
|
|
721
|
+
type: "spelling",
|
|
722
|
+
cityId: 1107,
|
|
723
|
+
before: Object.freeze({ fa: "آيسک" }),
|
|
724
|
+
after: Object.freeze({ fa: "آیسک" }),
|
|
725
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
726
|
+
}),
|
|
727
|
+
Object.freeze({
|
|
728
|
+
version: "2.0.0",
|
|
729
|
+
type: "spelling",
|
|
730
|
+
cityId: 1114,
|
|
731
|
+
before: Object.freeze({ fa: "طبس مسينا" }),
|
|
732
|
+
after: Object.freeze({ fa: "طبس مسینا" }),
|
|
733
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
734
|
+
}),
|
|
735
|
+
Object.freeze({
|
|
736
|
+
version: "2.0.0",
|
|
737
|
+
type: "spelling",
|
|
738
|
+
cityId: 1199,
|
|
739
|
+
before: Object.freeze({ fa: "ايواوغلی" }),
|
|
740
|
+
after: Object.freeze({ fa: "ایواوغلی" }),
|
|
741
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
742
|
+
}),
|
|
743
|
+
Object.freeze({
|
|
744
|
+
version: "2.0.0",
|
|
745
|
+
type: "spelling",
|
|
746
|
+
cityId: 1209,
|
|
747
|
+
before: Object.freeze({ fa: "خليفان" }),
|
|
748
|
+
after: Object.freeze({ fa: "خلیفان" }),
|
|
749
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
750
|
+
}),
|
|
751
|
+
Object.freeze({
|
|
752
|
+
version: "2.0.0",
|
|
753
|
+
type: "spelling",
|
|
754
|
+
cityId: 1225,
|
|
755
|
+
before: Object.freeze({ fa: "بفروييه" }),
|
|
756
|
+
after: Object.freeze({ fa: "بفروییه" }),
|
|
757
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
758
|
+
}),
|
|
759
|
+
Object.freeze({
|
|
760
|
+
version: "2.0.0",
|
|
761
|
+
type: "spelling",
|
|
762
|
+
cityId: 1235,
|
|
763
|
+
before: Object.freeze({ fa: "قيدار" }),
|
|
764
|
+
after: Object.freeze({ fa: "قیدار" }),
|
|
765
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
766
|
+
}),
|
|
767
|
+
Object.freeze({
|
|
768
|
+
version: "2.0.0",
|
|
769
|
+
type: "spelling",
|
|
770
|
+
cityId: 1236,
|
|
771
|
+
before: Object.freeze({ fa: "هيدج" }),
|
|
772
|
+
after: Object.freeze({ fa: "هیدج" }),
|
|
773
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
774
|
+
}),
|
|
775
|
+
Object.freeze({
|
|
776
|
+
version: "2.0.0",
|
|
777
|
+
type: "spelling",
|
|
778
|
+
cityId: 1237,
|
|
779
|
+
before: Object.freeze({ fa: "صائين قلعه" }),
|
|
780
|
+
after: Object.freeze({ fa: "صائین قلعه" }),
|
|
781
|
+
note: "Arabic letters replaced with Persian ی/ک."
|
|
782
|
+
})
|
|
783
|
+
]);
|
|
784
|
+
function compareVersions(a, b) {
|
|
785
|
+
const pa = a.split(".").map(Number);
|
|
786
|
+
const pb = b.split(".").map(Number);
|
|
787
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
788
|
+
var _pa$i, _pb$i;
|
|
789
|
+
const diff = ((_pa$i = pa[i]) !== null && _pa$i !== void 0 ? _pa$i : 0) - ((_pb$i = pb[i]) !== null && _pb$i !== void 0 ? _pb$i : 0);
|
|
790
|
+
if (diff !== 0) return diff;
|
|
791
|
+
}
|
|
792
|
+
return 0;
|
|
793
|
+
}
|
|
794
|
+
function getDataChanges(sinceVersion) {
|
|
795
|
+
if (!sinceVersion) return DATA_CHANGES.slice();
|
|
796
|
+
return DATA_CHANGES.filter((change) => compareVersions(change.version, sinceVersion) > 0);
|
|
797
|
+
}
|
|
798
|
+
Object.defineProperty(exports, "DATA_CHANGES", {
|
|
799
|
+
enumerable: true,
|
|
800
|
+
get: function() {
|
|
801
|
+
return DATA_CHANGES;
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
Object.defineProperty(exports, "DATA_VERSION", {
|
|
805
|
+
enumerable: true,
|
|
806
|
+
get: function() {
|
|
807
|
+
return DATA_VERSION;
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
Object.defineProperty(exports, "convertKeyboardLayout", {
|
|
811
|
+
enumerable: true,
|
|
812
|
+
get: function() {
|
|
813
|
+
return convertKeyboardLayout;
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
Object.defineProperty(exports, "createApi", {
|
|
817
|
+
enumerable: true,
|
|
818
|
+
get: function() {
|
|
819
|
+
return createApi;
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
Object.defineProperty(exports, "getDataChanges", {
|
|
823
|
+
enumerable: true,
|
|
824
|
+
get: function() {
|
|
825
|
+
return getDataChanges;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
Object.defineProperty(exports, "normalize", {
|
|
829
|
+
enumerable: true,
|
|
830
|
+
get: function() {
|
|
831
|
+
return normalize;
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
Object.defineProperty(exports, "unpack", {
|
|
835
|
+
enumerable: true,
|
|
836
|
+
get: function() {
|
|
837
|
+
return unpack;
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
//# sourceMappingURL=changes-B-wz9-Gy.cjs.map
|