pakdatakit 1.1.0 → 2.1.1

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.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +909 -666
  3. package/dist/address.cjs +17 -0
  4. package/dist/address.d.cts +36 -0
  5. package/dist/address.d.ts +36 -0
  6. package/dist/address.js +4 -0
  7. package/dist/chunk-3COX5FSL.cjs +1650 -0
  8. package/dist/chunk-432ZYMYV.js +31 -0
  9. package/dist/chunk-43ULDYUP.cjs +235 -0
  10. package/dist/chunk-44YRK7WO.js +231 -0
  11. package/dist/chunk-4EUKCSLW.js +221 -0
  12. package/dist/chunk-4VVFS6FN.cjs +715 -0
  13. package/dist/chunk-6TSKA2PH.js +38 -0
  14. package/dist/chunk-APXP7OK7.cjs +226 -0
  15. package/dist/chunk-AUATLZA5.cjs +168 -0
  16. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  17. package/dist/chunk-CEPNSHIC.js +33 -0
  18. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  19. package/dist/chunk-E47SNBWQ.cjs +224 -0
  20. package/dist/chunk-E7GAK72W.js +20 -0
  21. package/dist/chunk-EEVNLTB4.js +32 -0
  22. package/dist/chunk-ENQ7O7VW.js +32 -0
  23. package/dist/chunk-H6M6L26S.cjs +37 -0
  24. package/dist/chunk-HBOZIITD.js +351 -0
  25. package/dist/chunk-HTCSHHOR.cjs +35 -0
  26. package/dist/chunk-JKE4AMSZ.js +47 -0
  27. package/dist/chunk-JNP27XW2.cjs +22 -0
  28. package/dist/chunk-K6CZFCX6.js +1642 -0
  29. package/dist/chunk-KEHCTYLO.cjs +52 -0
  30. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  31. package/dist/chunk-L2BDDM2W.js +165 -0
  32. package/dist/chunk-L45UXUWX.js +21 -0
  33. package/dist/chunk-LIYNKIKS.js +709 -0
  34. package/dist/chunk-LVHTH4P7.cjs +41 -0
  35. package/dist/chunk-P4CGOJEM.js +16 -0
  36. package/dist/chunk-PHHKIMO2.cjs +35 -0
  37. package/dist/chunk-QQQKISXT.js +223 -0
  38. package/dist/chunk-T3E4B5MJ.js +417 -0
  39. package/dist/chunk-VPBMIYO2.cjs +38 -0
  40. package/dist/chunk-XCXFGTHW.cjs +355 -0
  41. package/dist/chunk-Y6BUGLXU.js +95 -0
  42. package/dist/chunk-YLWZGSFY.cjs +99 -0
  43. package/dist/chunk-YS7MOLK2.cjs +23 -0
  44. package/dist/chunk-Z5JEIQVW.js +102 -0
  45. package/dist/cli.js +78 -2654
  46. package/dist/cnic.cjs +15 -0
  47. package/dist/cnic.d.cts +35 -0
  48. package/dist/cnic.d.ts +35 -0
  49. package/dist/cnic.js +2 -0
  50. package/dist/format.cjs +14 -0
  51. package/dist/format.d.cts +27 -0
  52. package/dist/format.d.ts +27 -0
  53. package/dist/format.js +1 -0
  54. package/dist/geo.cjs +27 -0
  55. package/dist/geo.d.cts +43 -0
  56. package/dist/geo.d.ts +43 -0
  57. package/dist/geo.js +2 -0
  58. package/dist/hijri.cjs +26 -0
  59. package/dist/hijri.d.cts +62 -0
  60. package/dist/hijri.d.ts +62 -0
  61. package/dist/hijri.js +1 -0
  62. package/dist/holidays.cjs +19 -0
  63. package/dist/holidays.d.cts +72 -0
  64. package/dist/holidays.d.ts +72 -0
  65. package/dist/holidays.js +2 -0
  66. package/dist/iban.cjs +15 -0
  67. package/dist/iban.d.cts +21 -0
  68. package/dist/iban.d.ts +21 -0
  69. package/dist/iban.js +2 -0
  70. package/dist/index.cjs +211 -0
  71. package/dist/index.d.cts +16 -0
  72. package/dist/index.d.ts +16 -300
  73. package/dist/index.js +18 -2764
  74. package/dist/networks.cjs +12 -0
  75. package/dist/networks.d.cts +20 -0
  76. package/dist/networks.d.ts +20 -0
  77. package/dist/networks.js +3 -0
  78. package/dist/numbers.cjs +24 -0
  79. package/dist/numbers.d.cts +53 -0
  80. package/dist/numbers.d.ts +53 -0
  81. package/dist/numbers.js +3 -0
  82. package/dist/phone.cjs +29 -0
  83. package/dist/phone.d.cts +56 -0
  84. package/dist/phone.d.ts +56 -0
  85. package/dist/phone.js +4 -0
  86. package/dist/postal.cjs +27 -0
  87. package/dist/postal.d.cts +40 -0
  88. package/dist/postal.d.ts +40 -0
  89. package/dist/postal.js +2 -0
  90. package/dist/raast.cjs +20 -0
  91. package/dist/raast.d.cts +125 -0
  92. package/dist/raast.d.ts +125 -0
  93. package/dist/raast.js +3 -0
  94. package/dist/rules-GxgPiVws.d.cts +7 -0
  95. package/dist/rules-GxgPiVws.d.ts +7 -0
  96. package/dist/tax.cjs +20 -0
  97. package/dist/tax.d.cts +47 -0
  98. package/dist/tax.d.ts +47 -0
  99. package/dist/tax.js +3 -0
  100. package/dist/text.cjs +23 -0
  101. package/dist/text.d.cts +34 -0
  102. package/dist/text.d.ts +34 -0
  103. package/dist/text.js +2 -0
  104. package/dist/valibot.cjs +47 -0
  105. package/dist/valibot.d.cts +22 -0
  106. package/dist/valibot.d.ts +22 -0
  107. package/dist/valibot.js +25 -0
  108. package/dist/whatsapp.cjs +12 -0
  109. package/dist/whatsapp.d.cts +12 -0
  110. package/dist/whatsapp.d.ts +12 -0
  111. package/dist/whatsapp.js +3 -0
  112. package/dist/words.cjs +14 -0
  113. package/dist/words.d.cts +49 -0
  114. package/dist/words.d.ts +49 -0
  115. package/dist/words.js +1 -0
  116. package/dist/yup.cjs +32 -0
  117. package/dist/yup.d.cts +22 -0
  118. package/dist/yup.d.ts +22 -0
  119. package/dist/yup.js +30 -0
  120. package/dist/zod.cjs +27 -0
  121. package/dist/zod.d.cts +22 -0
  122. package/dist/zod.d.ts +22 -0
  123. package/dist/zod.js +25 -0
  124. package/package.json +309 -77
  125. package/dist/cli.d.ts +0 -1
  126. package/dist/cli.js.map +0 -1
  127. package/dist/index.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,2626 +1,15 @@
1
1
  #!/usr/bin/env node
2
- // src/internal/normalize.ts
3
- function stripSeparators(input2) {
4
- return input2.replace(/[\s\-()]/g, "");
5
- }
6
- function normalizeWhitespace(input2) {
7
- return input2.trim().replace(/\s+/g, " ");
8
- }
9
- function normalizeKey(input2) {
10
- return normalizeWhitespace(input2).toLowerCase();
11
- }
12
-
13
- // src/cnic.ts
14
- var CNIC_PATTERN = /^\d{13}$/;
15
- function validateCNIC(cnic) {
16
- const digits = stripSeparators(cnic);
17
- if (digits.length === 0) {
18
- return false;
19
- }
20
- return CNIC_PATTERN.test(digits);
21
- }
22
-
23
- // src/internal/phone-utils.ts
24
- function normalizePhoneDigits(phone) {
25
- let digits = stripSeparators(phone);
26
- if (digits.startsWith("+")) {
27
- digits = digits.slice(1);
28
- }
29
- if (digits.startsWith("00")) {
30
- digits = digits.slice(2);
31
- }
32
- if (digits.startsWith("92")) {
33
- digits = digits.slice(2);
34
- } else if (digits.startsWith("0")) {
35
- digits = digits.slice(1);
36
- }
37
- if (!/^\d+$/.test(digits)) {
38
- return null;
39
- }
40
- if (digits.length !== 10 || !digits.startsWith("3")) {
41
- return null;
42
- }
43
- return `92${digits}`;
44
- }
45
- function getPhonePrefix(phone) {
46
- const digits = normalizePhoneDigits(phone);
47
- if (digits === null) {
48
- return null;
49
- }
50
- const local = digits.slice(2);
51
- return `0${local.slice(0, 3)}`;
52
- }
53
-
54
- // data/networks.json
55
- var networks_default = [
56
- { prefix: "0300", network: "Jazz" },
57
- { prefix: "0301", network: "Jazz" },
58
- { prefix: "0302", network: "Jazz" },
59
- { prefix: "0303", network: "Jazz" },
60
- { prefix: "0304", network: "Jazz" },
61
- { prefix: "0305", network: "Jazz" },
62
- { prefix: "0306", network: "Jazz" },
63
- { prefix: "0307", network: "Jazz" },
64
- { prefix: "0308", network: "Jazz" },
65
- { prefix: "0309", network: "Jazz" },
66
- { prefix: "0320", network: "Jazz" },
67
- { prefix: "0321", network: "Jazz" },
68
- { prefix: "0322", network: "Jazz" },
69
- { prefix: "0323", network: "Jazz" },
70
- { prefix: "0324", network: "Jazz" },
71
- { prefix: "0325", network: "Jazz" },
72
- { prefix: "0326", network: "Jazz" },
73
- { prefix: "0327", network: "Jazz" },
74
- { prefix: "0328", network: "Jazz" },
75
- { prefix: "0310", network: "Zong" },
76
- { prefix: "0311", network: "Zong" },
77
- { prefix: "0312", network: "Zong" },
78
- { prefix: "0313", network: "Zong" },
79
- { prefix: "0314", network: "Zong" },
80
- { prefix: "0315", network: "Zong" },
81
- { prefix: "0316", network: "Zong" },
82
- { prefix: "0317", network: "Zong" },
83
- { prefix: "0318", network: "Zong" },
84
- { prefix: "0319", network: "Zong" },
85
- { prefix: "0370", network: "Zong" },
86
- { prefix: "0371", network: "Zong" },
87
- { prefix: "0330", network: "Ufone" },
88
- { prefix: "0331", network: "Ufone" },
89
- { prefix: "0332", network: "Ufone" },
90
- { prefix: "0333", network: "Ufone" },
91
- { prefix: "0334", network: "Ufone" },
92
- { prefix: "0335", network: "Ufone" },
93
- { prefix: "0336", network: "Ufone" },
94
- { prefix: "0337", network: "Ufone" },
95
- { prefix: "0338", network: "Ufone" },
96
- { prefix: "0339", network: "Ufone" },
97
- { prefix: "0340", network: "Telenor" },
98
- { prefix: "0341", network: "Telenor" },
99
- { prefix: "0342", network: "Telenor" },
100
- { prefix: "0343", network: "Telenor" },
101
- { prefix: "0344", network: "Telenor" },
102
- { prefix: "0345", network: "Telenor" },
103
- { prefix: "0346", network: "Telenor" },
104
- { prefix: "0347", network: "Telenor" },
105
- { prefix: "0348", network: "Telenor" },
106
- { prefix: "0349", network: "Telenor" }
107
- ];
108
-
109
- // src/networks.ts
110
- var PREFIX_MAP = new Map(
111
- networks_default.map((entry) => [
112
- entry.prefix,
113
- entry.network
114
- ])
115
- );
116
- function getNetwork(phone) {
117
- const prefix = getPhonePrefix(phone);
118
- if (prefix === null) {
119
- return "Unknown";
120
- }
121
- return PREFIX_MAP.get(prefix) ?? "Unknown";
122
- }
123
-
124
- // src/phone.ts
125
- var VALID_PHONE_PATTERN = /^\+923\d{9}$/;
126
- function validatePhone(phone) {
127
- const digits = normalizePhoneDigits(phone);
128
- if (digits === null) {
129
- return false;
130
- }
131
- return VALID_PHONE_PATTERN.test(`+${digits}`);
132
- }
133
- function formatPhone(phone) {
134
- const digits = normalizePhoneDigits(phone);
135
- if (digits === null) {
136
- return "";
137
- }
138
- return `+${digits}`;
139
- }
140
- function analyzePhone(phone) {
141
- if (!validatePhone(phone)) {
142
- return {
143
- valid: false,
144
- formatted: null,
145
- network: "Unknown"
146
- };
147
- }
148
- return {
149
- valid: true,
150
- formatted: formatPhone(phone),
151
- network: getNetwork(phone)
152
- };
153
- }
154
-
155
- // data/cities.json
156
- var cities_default = [
157
- {
158
- city: "Faisalabad",
159
- province: "Punjab"
160
- },
161
- {
162
- city: "Gujranwala",
163
- province: "Punjab"
164
- },
165
- {
166
- city: "Hyderabad",
167
- province: "Sindh"
168
- },
169
- {
170
- city: "Islamabad",
171
- province: "Islamabad Capital Territory"
172
- },
173
- {
174
- city: "Karachi",
175
- province: "Sindh"
176
- },
177
- {
178
- city: "Lahore",
179
- province: "Punjab"
180
- },
181
- {
182
- city: "Multan",
183
- province: "Punjab"
184
- },
185
- {
186
- city: "Peshawar",
187
- province: "Khyber Pakhtunkhwa"
188
- },
189
- {
190
- city: "Quetta",
191
- province: "Balochistan"
192
- },
193
- {
194
- city: "Rawalpindi",
195
- province: "Punjab"
196
- },
197
- {
198
- city: "Sialkot",
199
- province: "Punjab"
200
- },
201
- {
202
- city: "Sukkur",
203
- province: "Sindh"
204
- },
205
- {
206
- city: "Ahmadpur East",
207
- province: "Punjab"
208
- },
209
- {
210
- city: "Ali Pur Chattha",
211
- province: "Punjab"
212
- },
213
- {
214
- city: "Aliabad",
215
- province: "Gilgit-Baltistan"
216
- },
217
- {
218
- city: "Alpuri",
219
- province: "Khyber Pakhtunkhwa"
220
- },
221
- {
222
- city: "Arifwala",
223
- province: "Punjab"
224
- },
225
- {
226
- city: "Athmuqam",
227
- province: "Azad Jammu and Kashmir"
228
- },
229
- {
230
- city: "Bagh City",
231
- province: "Azad Jammu and Kashmir"
232
- },
233
- {
234
- city: "Bahrain",
235
- province: "Khyber Pakhtunkhwa"
236
- },
237
- {
238
- city: "Batkhela",
239
- province: "Khyber Pakhtunkhwa"
240
- },
241
- {
242
- city: "Bela",
243
- province: "Balochistan"
244
- },
245
- {
246
- city: "Bhalwal",
247
- province: "Punjab"
248
- },
249
- {
250
- city: "Bhawana",
251
- province: "Punjab"
252
- },
253
- {
254
- city: "Burewala",
255
- province: "Punjab"
256
- },
257
- {
258
- city: "Burewala City",
259
- province: "Punjab"
260
- },
261
- {
262
- city: "Cantt",
263
- province: "Punjab"
264
- },
265
- {
266
- city: "Chak Jhumra",
267
- province: "Punjab"
268
- },
269
- {
270
- city: "Chaman Town",
271
- province: "Balochistan"
272
- },
273
- {
274
- city: "Chhor",
275
- province: "Sindh"
276
- },
277
- {
278
- city: "Chichawatni",
279
- province: "Punjab"
280
- },
281
- {
282
- city: "Chilas",
283
- province: "Gilgit-Baltistan"
284
- },
285
- {
286
- city: "Chishtian",
287
- province: "Punjab"
288
- },
289
- {
290
- city: "Chitral",
291
- province: "Khyber Pakhtunkhwa"
292
- },
293
- {
294
- city: "Chunian",
295
- province: "Punjab"
296
- },
297
- {
298
- city: "Clifton",
299
- province: "Sindh"
300
- },
301
- {
302
- city: "Daggar",
303
- province: "Khyber Pakhtunkhwa"
304
- },
305
- {
306
- city: "Dalbandin",
307
- province: "Balochistan"
308
- },
309
- {
310
- city: "Daska",
311
- province: "Punjab"
312
- },
313
- {
314
- city: "Daska City",
315
- province: "Punjab"
316
- },
317
- {
318
- city: "Defence",
319
- province: "Sindh"
320
- },
321
- {
322
- city: "Depalpur",
323
- province: "Punjab"
324
- },
325
- {
326
- city: "Dera Allah Yar",
327
- province: "Balochistan"
328
- },
329
- {
330
- city: "Dera Murad Jamali",
331
- province: "Balochistan"
332
- },
333
- {
334
- city: "Dhadar",
335
- province: "Balochistan"
336
- },
337
- {
338
- city: "Dina",
339
- province: "Punjab"
340
- },
341
- {
342
- city: "Diplo",
343
- province: "Sindh"
344
- },
345
- {
346
- city: "Dir",
347
- province: "Khyber Pakhtunkhwa"
348
- },
349
- {
350
- city: "Dunyapur",
351
- province: "Punjab"
352
- },
353
- {
354
- city: "Fort Abbas",
355
- province: "Punjab"
356
- },
357
- {
358
- city: "Gaddani",
359
- province: "Balochistan"
360
- },
361
- {
362
- city: "Gahkuch",
363
- province: "Gilgit-Baltistan"
364
- },
365
- {
366
- city: "Gambat",
367
- province: "Sindh"
368
- },
369
- {
370
- city: "Ghalanai",
371
- province: "Khyber Pakhtunkhwa"
372
- },
373
- {
374
- city: "Gojra",
375
- province: "Punjab"
376
- },
377
- {
378
- city: "Gujar Khan",
379
- province: "Punjab"
380
- },
381
- {
382
- city: "Gulberg",
383
- province: "Punjab"
384
- },
385
- {
386
- city: "Gulshan-e-Iqbal",
387
- province: "Sindh"
388
- },
389
- {
390
- city: "Hala",
391
- province: "Sindh"
392
- },
393
- {
394
- city: "Haroonabad",
395
- province: "Punjab"
396
- },
397
- {
398
- city: "Hasilpur",
399
- province: "Punjab"
400
- },
401
- {
402
- city: "Hattian Bala Town",
403
- province: "Azad Jammu and Kashmir"
404
- },
405
- {
406
- city: "Havelian",
407
- province: "Khyber Pakhtunkhwa"
408
- },
409
- {
410
- city: "Hub",
411
- province: "Balochistan"
412
- },
413
- {
414
- city: "Hujra Shah Muqeem",
415
- province: "Punjab"
416
- },
417
- {
418
- city: "Jampur",
419
- province: "Punjab"
420
- },
421
- {
422
- city: "Jaranwala",
423
- province: "Punjab"
424
- },
425
- {
426
- city: "Jaranwala City",
427
- province: "Punjab"
428
- },
429
- {
430
- city: "Jiwani",
431
- province: "Balochistan"
432
- },
433
- {
434
- city: "Kabirwala",
435
- province: "Punjab"
436
- },
437
- {
438
- city: "Kahuta",
439
- province: "Punjab"
440
- },
441
- {
442
- city: "Kalam",
443
- province: "Khyber Pakhtunkhwa"
444
- },
445
- {
446
- city: "Kalat Town",
447
- province: "Balochistan"
448
- },
449
- {
450
- city: "Kalaya",
451
- province: "Khyber Pakhtunkhwa"
452
- },
453
- {
454
- city: "Kallar Kahar",
455
- province: "Punjab"
456
- },
457
- {
458
- city: "Kallar Syedan",
459
- province: "Punjab"
460
- },
461
- {
462
- city: "Kamalia",
463
- province: "Punjab"
464
- },
465
- {
466
- city: "Kamoke",
467
- province: "Punjab"
468
- },
469
- {
470
- city: "Kandhkot",
471
- province: "Sindh"
472
- },
473
- {
474
- city: "Kandiaro",
475
- province: "Sindh"
476
- },
477
- {
478
- city: "Khaar",
479
- province: "Khyber Pakhtunkhwa"
480
- },
481
- {
482
- city: "Khairpur Nathan Shah",
483
- province: "Sindh"
484
- },
485
- {
486
- city: "Khanpur",
487
- province: "Punjab"
488
- },
489
- {
490
- city: "Khaplu",
491
- province: "Gilgit-Baltistan"
492
- },
493
- {
494
- city: "Kharian",
495
- province: "Punjab"
496
- },
497
- {
498
- city: "Khipro",
499
- province: "Sindh"
500
- },
501
- {
502
- city: "Khurrianwala",
503
- province: "Punjab"
504
- },
505
- {
506
- city: "Khuzdar City",
507
- province: "Balochistan"
508
- },
509
- {
510
- city: "Kohlu Town",
511
- province: "Balochistan"
512
- },
513
- {
514
- city: "Kot Abdul Malik",
515
- province: "Punjab"
516
- },
517
- {
518
- city: "Kot Momin",
519
- province: "Punjab"
520
- },
521
- {
522
- city: "Kot Radha Kishan",
523
- province: "Punjab"
524
- },
525
- {
526
- city: "Kotli Loharan",
527
- province: "Punjab"
528
- },
529
- {
530
- city: "Kotri",
531
- province: "Sindh"
532
- },
533
- {
534
- city: "Landhi",
535
- province: "Sindh"
536
- },
537
- {
538
- city: "Landi Kotal",
539
- province: "Khyber Pakhtunkhwa"
540
- },
541
- {
542
- city: "Lawa",
543
- province: "Punjab"
544
- },
545
- {
546
- city: "Liaquatpur",
547
- province: "Punjab"
548
- },
549
- {
550
- city: "Loralai Town",
551
- province: "Balochistan"
552
- },
553
- {
554
- city: "Mailsi",
555
- province: "Punjab"
556
- },
557
- {
558
- city: "Mastung Town",
559
- province: "Balochistan"
560
- },
561
- {
562
- city: "Mehrabpur",
563
- province: "Sindh"
564
- },
565
- {
566
- city: "Mian Channu",
567
- province: "Punjab"
568
- },
569
- {
570
- city: "Mingora",
571
- province: "Khyber Pakhtunkhwa"
572
- },
573
- {
574
- city: "Miranshah",
575
- province: "Khyber Pakhtunkhwa"
576
- },
577
- {
578
- city: "Mithi",
579
- province: "Sindh"
580
- },
581
- {
582
- city: "Model Town",
583
- province: "Punjab"
584
- },
585
- {
586
- city: "Moro",
587
- province: "Sindh"
588
- },
589
- {
590
- city: "Nawabshah",
591
- province: "Sindh"
592
- },
593
- {
594
- city: "Nazimabad",
595
- province: "Sindh"
596
- },
597
- {
598
- city: "Okara City",
599
- province: "Punjab"
600
- },
601
- {
602
- city: "Orangi",
603
- province: "Sindh"
604
- },
605
- {
606
- city: "Ormara",
607
- province: "Balochistan"
608
- },
609
- {
610
- city: "Palandri",
611
- province: "Azad Jammu and Kashmir"
612
- },
613
- {
614
- city: "Parachinar",
615
- province: "Khyber Pakhtunkhwa"
616
- },
617
- {
618
- city: "Pasni",
619
- province: "Balochistan"
620
- },
621
- {
622
- city: "Pasrur",
623
- province: "Punjab"
624
- },
625
- {
626
- city: "Pattoki",
627
- province: "Punjab"
628
- },
629
- {
630
- city: "Phalia",
631
- province: "Punjab"
632
- },
633
- {
634
- city: "Pind Dadan Khan",
635
- province: "Punjab"
636
- },
637
- {
638
- city: "Pir Mahal",
639
- province: "Punjab"
640
- },
641
- {
642
- city: "Pishin Town",
643
- province: "Balochistan"
644
- },
645
- {
646
- city: "Ranipur",
647
- province: "Sindh"
648
- },
649
- {
650
- city: "Ratodero",
651
- province: "Sindh"
652
- },
653
- {
654
- city: "Rawalakot",
655
- province: "Azad Jammu and Kashmir"
656
- },
657
- {
658
- city: "Renala Khurd",
659
- province: "Punjab"
660
- },
661
- {
662
- city: "Renala Khurd City",
663
- province: "Punjab"
664
- },
665
- {
666
- city: "Rojhan",
667
- province: "Punjab"
668
- },
669
- {
670
- city: "Saddar",
671
- province: "Sindh"
672
- },
673
- {
674
- city: "Sadiqabad",
675
- province: "Punjab"
676
- },
677
- {
678
- city: "Sammundri",
679
- province: "Punjab"
680
- },
681
- {
682
- city: "Samundri",
683
- province: "Punjab"
684
- },
685
- {
686
- city: "Sanghar City",
687
- province: "Sindh"
688
- },
689
- {
690
- city: "Sangla Hill",
691
- province: "Punjab"
692
- },
693
- {
694
- city: "Satiana",
695
- province: "Punjab"
696
- },
697
- {
698
- city: "Sehwan",
699
- province: "Sindh"
700
- },
701
- {
702
- city: "Shahdadkot",
703
- province: "Sindh"
704
- },
705
- {
706
- city: "Shahdadpur",
707
- province: "Sindh"
708
- },
709
- {
710
- city: "Shahkot",
711
- province: "Punjab"
712
- },
713
- {
714
- city: "Shahpur",
715
- province: "Punjab"
716
- },
717
- {
718
- city: "Shakargarh",
719
- province: "Punjab"
720
- },
721
- {
722
- city: "Shorkot",
723
- province: "Punjab"
724
- },
725
- {
726
- city: "Sibi Town",
727
- province: "Balochistan"
728
- },
729
- {
730
- city: "Sohawa",
731
- province: "Punjab"
732
- },
733
- {
734
- city: "Sohbatpur Town",
735
- province: "Balochistan"
736
- },
737
- {
738
- city: "Talagang City",
739
- province: "Punjab"
740
- },
741
- {
742
- city: "Tandlianwala",
743
- province: "Punjab"
744
- },
745
- {
746
- city: "Taxila",
747
- province: "Punjab"
748
- },
749
- {
750
- city: "Timergara",
751
- province: "Khyber Pakhtunkhwa"
752
- },
753
- {
754
- city: "Turbat",
755
- province: "Balochistan"
756
- }
757
- ];
2
+ import { normalizeRomanUrdu, formatHijri, toHijri, formatPKR, formatLakh, parseAddress, getCityByPostalCode, getPostalCode, getProvince, getBankFromIBAN, validateIBAN, analyzePhone, validatePhone, validateCNIC } from 'pakdatakit';
758
3
 
759
- // data/districts.json
760
- var districts_default = [
761
- {
762
- district: "Abbottabad",
763
- province: "Khyber Pakhtunkhwa"
764
- },
765
- {
766
- district: "Astore",
767
- province: "Gilgit-Baltistan"
768
- },
769
- {
770
- district: "Astore",
771
- province: "Gilgit-Baltistan"
772
- },
773
- {
774
- district: "Attock",
775
- province: "Punjab"
776
- },
777
- {
778
- district: "Awaran",
779
- province: "Balochistan"
780
- },
781
- {
782
- district: "Badin",
783
- province: "Sindh"
784
- },
785
- {
786
- district: "Bagh",
787
- province: "Azad Jammu and Kashmir"
788
- },
789
- {
790
- district: "Bahawalnagar",
791
- province: "Punjab"
792
- },
793
- {
794
- district: "Bahawalpur",
795
- province: "Punjab"
796
- },
797
- {
798
- district: "Bajaur",
799
- province: "Khyber Pakhtunkhwa"
800
- },
801
- {
802
- district: "Bannu",
803
- province: "Khyber Pakhtunkhwa"
804
- },
805
- {
806
- district: "Barkhan",
807
- province: "Balochistan"
808
- },
809
- {
810
- district: "Batagram",
811
- province: "Khyber Pakhtunkhwa"
812
- },
813
- {
814
- district: "Bhakkar",
815
- province: "Punjab"
816
- },
817
- {
818
- district: "Bhimber",
819
- province: "Azad Jammu and Kashmir"
820
- },
821
- {
822
- district: "Buner",
823
- province: "Khyber Pakhtunkhwa"
824
- },
825
- {
826
- district: "Chagai",
827
- province: "Balochistan"
828
- },
829
- {
830
- district: "Chakwal",
831
- province: "Punjab"
832
- },
833
- {
834
- district: "Chaman",
835
- province: "Balochistan"
836
- },
837
- {
838
- district: "Charsadda",
839
- province: "Khyber Pakhtunkhwa"
840
- },
841
- {
842
- district: "Chiniot",
843
- province: "Punjab"
844
- },
845
- {
846
- district: "Dadu",
847
- province: "Sindh"
848
- },
849
- {
850
- district: "Darel",
851
- province: "Gilgit-Baltistan"
852
- },
853
- {
854
- district: "Dera Bugti",
855
- province: "Balochistan"
856
- },
857
- {
858
- district: "Dera Ghazi Khan",
859
- province: "Punjab"
860
- },
861
- {
862
- district: "Dera Ismail Khan",
863
- province: "Khyber Pakhtunkhwa"
864
- },
865
- {
866
- district: "Diamer",
867
- province: "Gilgit-Baltistan"
868
- },
869
- {
870
- district: "Duki",
871
- province: "Balochistan"
872
- },
873
- {
874
- district: "Faisalabad",
875
- province: "Punjab"
876
- },
877
- {
878
- district: "Ghanche",
879
- province: "Gilgit-Baltistan"
880
- },
881
- {
882
- district: "Ghanche",
883
- province: "Gilgit-Baltistan"
884
- },
885
- {
886
- district: "Ghizer",
887
- province: "Gilgit-Baltistan"
888
- },
889
- {
890
- district: "Ghizer",
891
- province: "Gilgit-Baltistan"
892
- },
893
- {
894
- district: "Ghotki",
895
- province: "Sindh"
896
- },
897
- {
898
- district: "Gilgit",
899
- province: "Gilgit-Baltistan"
900
- },
901
- {
902
- district: "Gujranwala",
903
- province: "Punjab"
904
- },
905
- {
906
- district: "Gujrat",
907
- province: "Punjab"
908
- },
909
- {
910
- district: "Gupis-Yasin",
911
- province: "Gilgit-Baltistan"
912
- },
913
- {
914
- district: "Gwadar",
915
- province: "Balochistan"
916
- },
917
- {
918
- district: "Hafizabad",
919
- province: "Punjab"
920
- },
921
- {
922
- district: "Hangu",
923
- province: "Khyber Pakhtunkhwa"
924
- },
925
- {
926
- district: "Haripur",
927
- province: "Khyber Pakhtunkhwa"
928
- },
929
- {
930
- district: "Harnai",
931
- province: "Balochistan"
932
- },
933
- {
934
- district: "Hatian Bala",
935
- province: "Azad Jammu and Kashmir"
936
- },
937
- {
938
- district: "Haveli",
939
- province: "Azad Jammu and Kashmir"
940
- },
941
- {
942
- district: "Hunza",
943
- province: "Gilgit-Baltistan"
944
- },
945
- {
946
- district: "Hunza",
947
- province: "Gilgit-Baltistan"
948
- },
949
- {
950
- district: "Hyderabad",
951
- province: "Sindh"
952
- },
953
- {
954
- district: "Islamabad",
955
- province: "Islamabad Capital Territory"
956
- },
957
- {
958
- district: "Jacobabad",
959
- province: "Sindh"
960
- },
961
- {
962
- district: "Jaffarabad",
963
- province: "Balochistan"
964
- },
965
- {
966
- district: "Jamshoro",
967
- province: "Sindh"
968
- },
969
- {
970
- district: "Jhal Magsi",
971
- province: "Balochistan"
972
- },
973
- {
974
- district: "Jhang",
975
- province: "Punjab"
976
- },
977
- {
978
- district: "Jhelum",
979
- province: "Punjab"
980
- },
981
- {
982
- district: "Kachhi",
983
- province: "Balochistan"
984
- },
985
- {
986
- district: "Kalat",
987
- province: "Balochistan"
988
- },
989
- {
990
- district: "Karachi Central",
991
- province: "Sindh"
992
- },
993
- {
994
- district: "Karachi East",
995
- province: "Sindh"
996
- },
997
- {
998
- district: "Karachi South",
999
- province: "Sindh"
1000
- },
1001
- {
1002
- district: "Karachi West",
1003
- province: "Sindh"
1004
- },
1005
- {
1006
- district: "Karak",
1007
- province: "Khyber Pakhtunkhwa"
1008
- },
1009
- {
1010
- district: "Kashmore",
1011
- province: "Sindh"
1012
- },
1013
- {
1014
- district: "Kasur",
1015
- province: "Punjab"
1016
- },
1017
- {
1018
- district: "Keamari",
1019
- province: "Sindh"
1020
- },
1021
- {
1022
- district: "Kech",
1023
- province: "Balochistan"
1024
- },
1025
- {
1026
- district: "Khairpur",
1027
- province: "Sindh"
1028
- },
1029
- {
1030
- district: "Khanewal",
1031
- province: "Punjab"
1032
- },
1033
- {
1034
- district: "Kharan",
1035
- province: "Balochistan"
1036
- },
1037
- {
1038
- district: "Kharmang",
1039
- province: "Gilgit-Baltistan"
1040
- },
1041
- {
1042
- district: "Kharmang",
1043
- province: "Gilgit-Baltistan"
1044
- },
1045
- {
1046
- district: "Khushab",
1047
- province: "Punjab"
1048
- },
1049
- {
1050
- district: "Khuzdar",
1051
- province: "Balochistan"
1052
- },
1053
- {
1054
- district: "Khyber",
1055
- province: "Khyber Pakhtunkhwa"
1056
- },
1057
- {
1058
- district: "Killa Abdullah",
1059
- province: "Balochistan"
1060
- },
1061
- {
1062
- district: "Killa Saifullah",
1063
- province: "Balochistan"
1064
- },
1065
- {
1066
- district: "Kohat",
1067
- province: "Khyber Pakhtunkhwa"
1068
- },
1069
- {
1070
- district: "Kohlu",
1071
- province: "Balochistan"
1072
- },
1073
- {
1074
- district: "Kolai-Palas",
1075
- province: "Khyber Pakhtunkhwa"
1076
- },
1077
- {
1078
- district: "Korangi",
1079
- province: "Sindh"
1080
- },
1081
- {
1082
- district: "Kot Addu",
1083
- province: "Punjab"
1084
- },
1085
- {
1086
- district: "Kotli",
1087
- province: "Azad Jammu and Kashmir"
1088
- },
1089
- {
1090
- district: "Kurram",
1091
- province: "Khyber Pakhtunkhwa"
1092
- },
1093
- {
1094
- district: "Lahore",
1095
- province: "Punjab"
1096
- },
1097
- {
1098
- district: "Lakki Marwat",
1099
- province: "Khyber Pakhtunkhwa"
1100
- },
1101
- {
1102
- district: "Larkana",
1103
- province: "Sindh"
1104
- },
1105
- {
1106
- district: "Lasbela",
1107
- province: "Balochistan"
1108
- },
1109
- {
1110
- district: "Layyah",
1111
- province: "Punjab"
1112
- },
1113
- {
1114
- district: "Lodhran",
1115
- province: "Punjab"
1116
- },
1117
- {
1118
- district: "Loralai",
1119
- province: "Balochistan"
1120
- },
1121
- {
1122
- district: "Lower Chitral",
1123
- province: "Khyber Pakhtunkhwa"
1124
- },
1125
- {
1126
- district: "Lower Dir",
1127
- province: "Khyber Pakhtunkhwa"
1128
- },
1129
- {
1130
- district: "Lower Kohistan",
1131
- province: "Khyber Pakhtunkhwa"
1132
- },
1133
- {
1134
- district: "Malakand",
1135
- province: "Khyber Pakhtunkhwa"
1136
- },
1137
- {
1138
- district: "Malir",
1139
- province: "Sindh"
1140
- },
1141
- {
1142
- district: "Mandi Bahauddin",
1143
- province: "Punjab"
1144
- },
1145
- {
1146
- district: "Mansehra",
1147
- province: "Khyber Pakhtunkhwa"
1148
- },
1149
- {
1150
- district: "Mardan",
1151
- province: "Khyber Pakhtunkhwa"
1152
- },
1153
- {
1154
- district: "Mastung",
1155
- province: "Balochistan"
1156
- },
1157
- {
1158
- district: "Matiari",
1159
- province: "Sindh"
1160
- },
1161
- {
1162
- district: "Mianwali",
1163
- province: "Punjab"
1164
- },
1165
- {
1166
- district: "Mirpur",
1167
- province: "Azad Jammu and Kashmir"
1168
- },
1169
- {
1170
- district: "Mirpur Khas",
1171
- province: "Sindh"
1172
- },
1173
- {
1174
- district: "Mohmand",
1175
- province: "Khyber Pakhtunkhwa"
1176
- },
1177
- {
1178
- district: "Multan",
1179
- province: "Punjab"
1180
- },
1181
- {
1182
- district: "Murree",
1183
- province: "Punjab"
1184
- },
1185
- {
1186
- district: "Musakhel",
1187
- province: "Balochistan"
1188
- },
1189
- {
1190
- district: "Muzaffarabad",
1191
- province: "Azad Jammu and Kashmir"
1192
- },
1193
- {
1194
- district: "Muzaffargarh",
1195
- province: "Punjab"
1196
- },
1197
- {
1198
- district: "Nagar",
1199
- province: "Gilgit-Baltistan"
1200
- },
1201
- {
1202
- district: "Nagar",
1203
- province: "Gilgit-Baltistan"
1204
- },
1205
- {
1206
- district: "Nankana Sahib",
1207
- province: "Punjab"
1208
- },
1209
- {
1210
- district: "Narowal",
1211
- province: "Punjab"
1212
- },
1213
- {
1214
- district: "Nasirabad",
1215
- province: "Balochistan"
1216
- },
1217
- {
1218
- district: "Naushahro Feroze",
1219
- province: "Sindh"
1220
- },
1221
- {
1222
- district: "Neelam",
1223
- province: "Azad Jammu and Kashmir"
1224
- },
1225
- {
1226
- district: "North Waziristan",
1227
- province: "Khyber Pakhtunkhwa"
1228
- },
1229
- {
1230
- district: "Nowshera",
1231
- province: "Khyber Pakhtunkhwa"
1232
- },
1233
- {
1234
- district: "Nushki",
1235
- province: "Balochistan"
1236
- },
1237
- {
1238
- district: "Okara",
1239
- province: "Punjab"
1240
- },
1241
- {
1242
- district: "Orakzai",
1243
- province: "Khyber Pakhtunkhwa"
1244
- },
1245
- {
1246
- district: "Pakpattan",
1247
- province: "Punjab"
1248
- },
1249
- {
1250
- district: "Panjgur",
1251
- province: "Balochistan"
1252
- },
1253
- {
1254
- district: "Peshawar",
1255
- province: "Khyber Pakhtunkhwa"
1256
- },
1257
- {
1258
- district: "Pishin",
1259
- province: "Balochistan"
1260
- },
1261
- {
1262
- district: "Poonch",
1263
- province: "Azad Jammu and Kashmir"
1264
- },
1265
- {
1266
- district: "Qambar Shahdadkot",
1267
- province: "Sindh"
1268
- },
1269
- {
1270
- district: "Quetta",
1271
- province: "Balochistan"
1272
- },
1273
- {
1274
- district: "Rahim Yar Khan",
1275
- province: "Punjab"
1276
- },
1277
- {
1278
- district: "Rajanpur",
1279
- province: "Punjab"
1280
- },
1281
- {
1282
- district: "Rawalpindi",
1283
- province: "Punjab"
1284
- },
1285
- {
1286
- district: "Rondu",
1287
- province: "Gilgit-Baltistan"
1288
- },
1289
- {
1290
- district: "Sahiwal",
1291
- province: "Punjab"
1292
- },
1293
- {
1294
- district: "Sanghar",
1295
- province: "Sindh"
1296
- },
1297
- {
1298
- district: "Sargodha",
1299
- province: "Punjab"
1300
- },
1301
- {
1302
- district: "Shaheed Benazir Abad",
1303
- province: "Sindh"
1304
- },
1305
- {
1306
- district: "Shangla",
1307
- province: "Khyber Pakhtunkhwa"
1308
- },
1309
- {
1310
- district: "Sheerani",
1311
- province: "Balochistan"
1312
- },
1313
- {
1314
- district: "Sheikhupura",
1315
- province: "Punjab"
1316
- },
1317
- {
1318
- district: "Shigar",
1319
- province: "Gilgit-Baltistan"
1320
- },
1321
- {
1322
- district: "Shigar",
1323
- province: "Gilgit-Baltistan"
1324
- },
1325
- {
1326
- district: "Shikarpur",
1327
- province: "Sindh"
1328
- },
1329
- {
1330
- district: "Sialkot",
1331
- province: "Punjab"
1332
- },
1333
- {
1334
- district: "Sibi",
1335
- province: "Balochistan"
1336
- },
1337
- {
1338
- district: "Skardu",
1339
- province: "Gilgit-Baltistan"
1340
- },
1341
- {
1342
- district: "Sohbatpur",
1343
- province: "Balochistan"
1344
- },
1345
- {
1346
- district: "South Waziristan",
1347
- province: "Khyber Pakhtunkhwa"
1348
- },
1349
- {
1350
- district: "Sudhnuti",
1351
- province: "Azad Jammu and Kashmir"
1352
- },
1353
- {
1354
- district: "Sujawal",
1355
- province: "Sindh"
1356
- },
1357
- {
1358
- district: "Sukkur",
1359
- province: "Sindh"
1360
- },
1361
- {
1362
- district: "Surab",
1363
- province: "Balochistan"
1364
- },
1365
- {
1366
- district: "Swabi",
1367
- province: "Khyber Pakhtunkhwa"
1368
- },
1369
- {
1370
- district: "Swat",
1371
- province: "Khyber Pakhtunkhwa"
1372
- },
1373
- {
1374
- district: "Talagang",
1375
- province: "Punjab"
1376
- },
1377
- {
1378
- district: "Tando Allahyar",
1379
- province: "Sindh"
1380
- },
1381
- {
1382
- district: "Tando Muhammad Khan",
1383
- province: "Sindh"
1384
- },
1385
- {
1386
- district: "Tangir",
1387
- province: "Gilgit-Baltistan"
1388
- },
1389
- {
1390
- district: "Tank",
1391
- province: "Khyber Pakhtunkhwa"
1392
- },
1393
- {
1394
- district: "Tharparkar",
1395
- province: "Sindh"
1396
- },
1397
- {
1398
- district: "Thatta",
1399
- province: "Sindh"
1400
- },
1401
- {
1402
- district: "Toba Tek Singh",
1403
- province: "Punjab"
1404
- },
1405
- {
1406
- district: "Tor Ghar",
1407
- province: "Khyber Pakhtunkhwa"
1408
- },
1409
- {
1410
- district: "Umerkot",
1411
- province: "Sindh"
1412
- },
1413
- {
1414
- district: "Upper Chitral",
1415
- province: "Khyber Pakhtunkhwa"
1416
- },
1417
- {
1418
- district: "Upper Dir",
1419
- province: "Khyber Pakhtunkhwa"
1420
- },
1421
- {
1422
- district: "Upper Kohistan",
1423
- province: "Khyber Pakhtunkhwa"
1424
- },
1425
- {
1426
- district: "Vehari",
1427
- province: "Punjab"
1428
- },
1429
- {
1430
- district: "Washuk",
1431
- province: "Balochistan"
1432
- },
1433
- {
1434
- district: "Wazirabad",
1435
- province: "Punjab"
1436
- },
1437
- {
1438
- district: "Zhob",
1439
- province: "Balochistan"
1440
- },
1441
- {
1442
- district: "Ziarat",
1443
- province: "Balochistan"
1444
- }
1445
- ];
1446
-
1447
- // src/geo.ts
1448
- var CITIES = cities_default;
1449
- var DISTRICTS = districts_default;
1450
- var CITY_LOOKUP = new Map(
1451
- CITIES.map((entry) => [normalizeKey(entry.city), entry.province])
1452
- );
1453
- var DISTRICT_LOOKUP = new Map(
1454
- DISTRICTS.map((entry) => [normalizeKey(entry.district), entry.province])
1455
- );
1456
- function getProvince(city) {
1457
- const key = normalizeKey(city);
1458
- if (key.length === 0) {
1459
- return null;
1460
- }
1461
- return CITY_LOOKUP.get(key) ?? null;
1462
- }
1463
- function getDistrictProvince(district) {
1464
- const key = normalizeKey(district);
1465
- if (key.length === 0) {
1466
- return null;
1467
- }
1468
- return DISTRICT_LOOKUP.get(key) ?? null;
1469
- }
1470
-
1471
- // src/format.ts
1472
- var LAKH = 1e5;
1473
- var CRORE = 1e7;
1474
- var pkrFormatter = new Intl.NumberFormat("en-PK", {
1475
- maximumFractionDigits: 0
1476
- });
1477
- function formatPKR(amount) {
1478
- const safeAmount = Number.isFinite(amount) && amount > 0 ? amount : 0;
1479
- return `Rs. ${pkrFormatter.format(safeAmount)}`;
1480
- }
1481
- function formatScaled(value, unit) {
1482
- const rounded = Math.round(value * 100) / 100;
1483
- const formatted = Number.isInteger(rounded) ? String(rounded) : String(rounded);
1484
- return `${formatted} ${unit}`;
1485
- }
1486
- function formatLakh(amount) {
1487
- const safeAmount = Number.isFinite(amount) && amount > 0 ? amount : 0;
1488
- if (safeAmount >= CRORE) {
1489
- return formatScaled(safeAmount / CRORE, "Crore");
1490
- }
1491
- if (safeAmount >= LAKH) {
1492
- return formatScaled(safeAmount / LAKH, "Lakh");
1493
- }
1494
- return formatPKR(safeAmount);
1495
- }
1496
-
1497
- // data/banks.json
1498
- var banks_default = [
1499
- {
1500
- code: "ABPA",
1501
- name: "Allied Bank Limited"
1502
- },
1503
- {
1504
- code: "AIIN",
1505
- name: "Al Baraka Bank (Pakistan) Limited"
1506
- },
1507
- {
1508
- code: "ALFH",
1509
- name: "Bank Alfalah Limited"
1510
- },
1511
- {
1512
- code: "APNA",
1513
- name: "Apna Microfinance Bank"
1514
- },
1515
- {
1516
- code: "ASCM",
1517
- name: "Askari Bank Limited"
1518
- },
1519
- {
1520
- code: "BAHL",
1521
- name: "Bank Al Habib Limited"
1522
- },
1523
- {
1524
- code: "BARC",
1525
- name: "Barclays Bank PLC"
1526
- },
1527
- {
1528
- code: "BIPL",
1529
- name: "Bank of Islamabad Limited"
1530
- },
1531
- {
1532
- code: "BKIP",
1533
- name: "BankIslami Pakistan Limited"
1534
- },
1535
- {
1536
- code: "BPUN",
1537
- name: "The Bank of Punjab"
1538
- },
1539
- {
1540
- code: "CITI",
1541
- name: "Citibank N.A. Pakistan"
1542
- },
1543
- {
1544
- code: "DEUT",
1545
- name: "Deutsche Bank AG"
1546
- },
1547
- {
1548
- code: "DUIB",
1549
- name: "Dubai Islamic Bank Pakistan Limited"
1550
- },
1551
- {
1552
- code: "FAYS",
1553
- name: "Faysal Bank Limited"
1554
- },
1555
- {
1556
- code: "FINC",
1557
- name: "FINCA Microfinance Bank"
1558
- },
1559
- {
1560
- code: "FMFB",
1561
- name: "First MicroFinance Bank"
1562
- },
1563
- {
1564
- code: "FWOM",
1565
- name: "First Women Bank Limited"
1566
- },
1567
- {
1568
- code: "HABB",
1569
- name: "Habib Bank Limited"
1570
- },
1571
- {
1572
- code: "ICBK",
1573
- name: "Industrial and Commercial Bank of China"
1574
- },
1575
- {
1576
- code: "JCMA",
1577
- name: "Mobilink Microfinance Bank (JazzCash)"
1578
- },
1579
- {
1580
- code: "JSBL",
1581
- name: "JS Bank Limited"
1582
- },
1583
- {
1584
- code: "KHYB",
1585
- name: "The Bank of Khyber"
1586
- },
1587
- {
1588
- code: "KMBL",
1589
- name: "Khushhali Microfinance Bank"
1590
- },
1591
- {
1592
- code: "MCBL",
1593
- name: "MCB Bank Limited"
1594
- },
1595
- {
1596
- code: "MCIB",
1597
- name: "MCB Islamic Bank Limited"
1598
- },
1599
- {
1600
- code: "MEZN",
1601
- name: "Meezan Bank Limited"
1602
- },
1603
- {
1604
- code: "MPBL",
1605
- name: "Habib Metropolitan Bank Limited"
1606
- },
1607
- {
1608
- code: "MSHQ",
1609
- name: "Mashreq Bank Pakistan"
1610
- },
1611
- {
1612
- code: "MUCB",
1613
- name: "MCB Bank Limited"
1614
- },
1615
- {
1616
- code: "NBPA",
1617
- name: "National Bank of Pakistan"
1618
- },
1619
- {
1620
- code: "NBPB",
1621
- name: "National Bank of Pakistan"
1622
- },
1623
- {
1624
- code: "NIBP",
1625
- name: "NIB Bank Limited"
1626
- },
1627
- {
1628
- code: "NRSP",
1629
- name: "NRSP Microfinance Bank"
1630
- },
1631
- {
1632
- code: "PAKB",
1633
- name: "Pak Oman Microfinance Bank"
1634
- },
1635
- {
1636
- code: "SAMB",
1637
- name: "Samba Bank Limited"
1638
- },
1639
- {
1640
- code: "SAUD",
1641
- name: "Saudi Pak Industrial Investment Bank"
1642
- },
1643
- {
1644
- code: "SBPP",
1645
- name: "State Bank of Pakistan"
1646
- },
1647
- {
1648
- code: "SCBL",
1649
- name: "Standard Chartered Bank (Pakistan) Limited"
1650
- },
1651
- {
1652
- code: "SILK",
1653
- name: "Silkbank Limited"
1654
- },
1655
- {
1656
- code: "SIND",
1657
- name: "Sindh Bank Limited"
1658
- },
1659
- {
1660
- code: "SMEP",
1661
- name: "Summit Bank Limited"
1662
- },
1663
- {
1664
- code: "SONE",
1665
- name: "Soneri Bank Limited"
1666
- },
1667
- {
1668
- code: "TAMW",
1669
- name: "Tameer Microfinance Bank"
1670
- },
1671
- {
1672
- code: "TMFB",
1673
- name: "Telenor Microfinance Bank (Easypaisa)"
1674
- },
1675
- {
1676
- code: "UMBL",
1677
- name: "U Microfinance Bank"
1678
- },
1679
- {
1680
- code: "UNIL",
1681
- name: "United Bank Limited"
1682
- }
1683
- ];
1684
-
1685
- // src/iban.ts
1686
- var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
1687
- var PK_IBAN_LENGTH = 24;
1688
- var BANK_MAP = /* @__PURE__ */ new Map();
1689
- for (const entry of banks_default) {
1690
- BANK_MAP.set(entry.code, entry.name);
1691
- }
1692
- var BANK_ALIASES = {
1693
- NBPB: "NBPA",
1694
- MCBL: "MUCB"
1695
- };
1696
- function expandIbanChars(value) {
1697
- return value.replace(/[A-Z]/g, (char) => (char.charCodeAt(0) - 55).toString());
1698
- }
1699
- function mod97(numericIban) {
1700
- let remainder = 0;
1701
- for (const digit of numericIban) {
1702
- remainder = (remainder * 10 + Number(digit)) % 97;
1703
- }
1704
- return remainder;
1705
- }
1706
- function normalizeIBAN(iban) {
1707
- return stripSeparators(iban).toUpperCase();
1708
- }
1709
- function validateIBAN(iban) {
1710
- const normalized = normalizeIBAN(iban);
1711
- if (normalized.length !== PK_IBAN_LENGTH) {
1712
- return false;
1713
- }
1714
- if (!PK_IBAN_PATTERN.test(normalized)) {
1715
- return false;
1716
- }
1717
- const rearranged = normalized.slice(4) + normalized.slice(0, 4);
1718
- const expanded = expandIbanChars(rearranged);
1719
- return mod97(expanded) === 1;
1720
- }
1721
- function getBankFromIBAN(iban) {
1722
- if (!validateIBAN(iban)) {
1723
- return null;
1724
- }
1725
- const normalized = normalizeIBAN(iban);
1726
- const bankCode = normalized.slice(4, 8);
1727
- const resolvedCode = BANK_ALIASES[bankCode] ?? bankCode;
1728
- return BANK_MAP.get(resolvedCode) ?? BANK_MAP.get(bankCode) ?? null;
1729
- }
1730
-
1731
- // data/postal-codes.json
1732
- var postal_codes_default = [
1733
- {
1734
- city: "Islamabad",
1735
- postalCode: "44000",
1736
- area: "Islamabad GPO",
1737
- primary: true
1738
- },
1739
- {
1740
- city: "Rawalpindi",
1741
- postalCode: "46000",
1742
- area: "Rawalpindi GPO",
1743
- primary: true
1744
- },
1745
- {
1746
- city: "Rawalpindi",
1747
- postalCode: "46300",
1748
- area: "Satellite Town"
1749
- },
1750
- {
1751
- city: "Murree",
1752
- postalCode: "47150",
1753
- area: "Murree GPO",
1754
- primary: true
1755
- },
1756
- {
1757
- city: "Taxila",
1758
- postalCode: "47040",
1759
- area: "Taxila GPO",
1760
- primary: true
1761
- },
1762
- {
1763
- city: "Lahore",
1764
- postalCode: "54000",
1765
- area: "Lahore GPO",
1766
- primary: true
1767
- },
1768
- {
1769
- city: "Lahore",
1770
- postalCode: "54660",
1771
- area: "Gulberg"
1772
- },
1773
- {
1774
- city: "Lahore",
1775
- postalCode: "54700",
1776
- area: "Model Town"
1777
- },
1778
- {
1779
- city: "Lahore",
1780
- postalCode: "54810",
1781
- area: "Lahore Cantt"
1782
- },
1783
- {
1784
- city: "Lahore",
1785
- postalCode: "54570",
1786
- area: "Iqbal Town"
1787
- },
1788
- {
1789
- city: "Faisalabad",
1790
- postalCode: "38000",
1791
- area: "Faisalabad GPO",
1792
- primary: true
1793
- },
1794
- {
1795
- city: "Multan",
1796
- postalCode: "60000",
1797
- area: "Multan GPO",
1798
- primary: true
1799
- },
1800
- {
1801
- city: "Gujranwala",
1802
- postalCode: "52250",
1803
- area: "Gujranwala GPO",
1804
- primary: true
1805
- },
1806
- {
1807
- city: "Sialkot",
1808
- postalCode: "51310",
1809
- area: "Sialkot GPO",
1810
- primary: true
1811
- },
1812
- {
1813
- city: "Sargodha",
1814
- postalCode: "40100",
1815
- area: "Sargodha GPO",
1816
- primary: true
1817
- },
1818
- {
1819
- city: "Bahawalpur",
1820
- postalCode: "63100",
1821
- area: "Bahawalpur GPO",
1822
- primary: true
1823
- },
1824
- {
1825
- city: "Sheikhupura",
1826
- postalCode: "39350",
1827
- area: "Sheikhupura GPO",
1828
- primary: true
1829
- },
1830
- {
1831
- city: "Gujrat",
1832
- postalCode: "50700",
1833
- area: "Gujrat GPO",
1834
- primary: true
1835
- },
1836
- {
1837
- city: "Jhang",
1838
- postalCode: "35200",
1839
- area: "Jhang GPO",
1840
- primary: true
1841
- },
1842
- {
1843
- city: "Sahiwal",
1844
- postalCode: "57000",
1845
- area: "Sahiwal GPO",
1846
- primary: true
1847
- },
1848
- {
1849
- city: "Okara",
1850
- postalCode: "56300",
1851
- area: "Okara GPO",
1852
- primary: true
1853
- },
1854
- {
1855
- city: "Kasur",
1856
- postalCode: "55050",
1857
- area: "Kasur GPO",
1858
- primary: true
1859
- },
1860
- {
1861
- city: "Dera Ghazi Khan",
1862
- postalCode: "32200",
1863
- area: "DG Khan GPO",
1864
- primary: true
1865
- },
1866
- {
1867
- city: "Muzaffargarh",
1868
- postalCode: "34200",
1869
- area: "Muzaffargarh GPO",
1870
- primary: true
1871
- },
1872
- {
1873
- city: "Rahim Yar Khan",
1874
- postalCode: "64200",
1875
- area: "RY Khan GPO",
1876
- primary: true
1877
- },
1878
- {
1879
- city: "Bahawalnagar",
1880
- postalCode: "62300",
1881
- area: "Bahawalnagar GPO",
1882
- primary: true
1883
- },
1884
- {
1885
- city: "Khanewal",
1886
- postalCode: "58150",
1887
- area: "Khanewal GPO",
1888
- primary: true
1889
- },
1890
- {
1891
- city: "Vehari",
1892
- postalCode: "61100",
1893
- area: "Vehari GPO",
1894
- primary: true
1895
- },
1896
- {
1897
- city: "Pakpattan",
1898
- postalCode: "57400",
1899
- area: "Pakpattan GPO",
1900
- primary: true
1901
- },
1902
- {
1903
- city: "Chiniot",
1904
- postalCode: "35400",
1905
- area: "Chiniot GPO",
1906
- primary: true
1907
- },
1908
- {
1909
- city: "Hafizabad",
1910
- postalCode: "52110",
1911
- area: "Hafizabad GPO",
1912
- primary: true
1913
- },
1914
- {
1915
- city: "Mandi Bahauddin",
1916
- postalCode: "50400",
1917
- area: "Mandi Bahauddin GPO",
1918
- primary: true
1919
- },
1920
- {
1921
- city: "Jhelum",
1922
- postalCode: "49600",
1923
- area: "Jhelum GPO",
1924
- primary: true
1925
- },
1926
- {
1927
- city: "Attock",
1928
- postalCode: "43600",
1929
- area: "Attock GPO",
1930
- primary: true
1931
- },
1932
- {
1933
- city: "Chakwal",
1934
- postalCode: "48800",
1935
- area: "Chakwal GPO",
1936
- primary: true
1937
- },
1938
- {
1939
- city: "Mianwali",
1940
- postalCode: "42200",
1941
- area: "Mianwali GPO",
1942
- primary: true
1943
- },
1944
- {
1945
- city: "Bhakkar",
1946
- postalCode: "30000",
1947
- area: "Bhakkar GPO",
1948
- primary: true
1949
- },
1950
- {
1951
- city: "Khushab",
1952
- postalCode: "41000",
1953
- area: "Khushab GPO",
1954
- primary: true
1955
- },
1956
- {
1957
- city: "Narowal",
1958
- postalCode: "51600",
1959
- area: "Narowal GPO",
1960
- primary: true
1961
- },
1962
- {
1963
- city: "Nankana Sahib",
1964
- postalCode: "39100",
1965
- area: "Nankana Sahib GPO",
1966
- primary: true
1967
- },
1968
- {
1969
- city: "Toba Tek Singh",
1970
- postalCode: "36050",
1971
- area: "TTS GPO",
1972
- primary: true
1973
- },
1974
- {
1975
- city: "Lodhran",
1976
- postalCode: "59320",
1977
- area: "Lodhran GPO",
1978
- primary: true
1979
- },
1980
- {
1981
- city: "Layyah",
1982
- postalCode: "31200",
1983
- area: "Layyah GPO",
1984
- primary: true
1985
- },
1986
- {
1987
- city: "Rajanpur",
1988
- postalCode: "33500",
1989
- area: "Rajanpur GPO",
1990
- primary: true
1991
- },
1992
- {
1993
- city: "Wazirabad",
1994
- postalCode: "52000",
1995
- area: "Wazirabad GPO",
1996
- primary: true
1997
- },
1998
- {
1999
- city: "Talagang",
2000
- postalCode: "48100",
2001
- area: "Talagang GPO",
2002
- primary: true
2003
- },
2004
- {
2005
- city: "Kot Addu",
2006
- postalCode: "34050",
2007
- area: "Kot Addu GPO",
2008
- primary: true
2009
- },
2010
- {
2011
- city: "Karachi",
2012
- postalCode: "74200",
2013
- area: "Karachi GPO",
2014
- primary: true
2015
- },
2016
- {
2017
- city: "Karachi",
2018
- postalCode: "74000",
2019
- area: "Karachi City GPO"
2020
- },
2021
- {
2022
- city: "Karachi",
2023
- postalCode: "74400",
2024
- area: "Karachi Saddar GPO"
2025
- },
2026
- {
2027
- city: "Karachi",
2028
- postalCode: "74800",
2029
- area: "New Town GPO"
2030
- },
2031
- {
2032
- city: "Karachi",
2033
- postalCode: "74700",
2034
- area: "Al-Hydri GPO"
2035
- },
2036
- {
2037
- city: "Karachi",
2038
- postalCode: "75500",
2039
- area: "Defence"
2040
- },
2041
- {
2042
- city: "Karachi",
2043
- postalCode: "75600",
2044
- area: "Clifton"
2045
- },
2046
- {
2047
- city: "Karachi",
2048
- postalCode: "75300",
2049
- area: "Gulshan-e-Iqbal"
2050
- },
2051
- {
2052
- city: "Karachi",
2053
- postalCode: "74600",
2054
- area: "Nazimabad"
2055
- },
2056
- {
2057
- city: "Karachi",
2058
- postalCode: "74900",
2059
- area: "Korangi"
2060
- },
2061
- {
2062
- city: "Karachi",
2063
- postalCode: "75950",
2064
- area: "Federal B Area"
2065
- },
2066
- {
2067
- city: "Hyderabad",
2068
- postalCode: "71000",
2069
- area: "Hyderabad GPO",
2070
- primary: true
2071
- },
2072
- {
2073
- city: "Sukkur",
2074
- postalCode: "65200",
2075
- area: "Sukkur GPO",
2076
- primary: true
2077
- },
2078
- {
2079
- city: "Larkana",
2080
- postalCode: "77150",
2081
- area: "Larkana GPO",
2082
- primary: true
2083
- },
2084
- {
2085
- city: "Nawabshah",
2086
- postalCode: "67450",
2087
- area: "Nawabshah GPO",
2088
- primary: true
2089
- },
2090
- {
2091
- city: "Mirpur Khas",
2092
- postalCode: "69000",
2093
- area: "Mirpur Khas GPO",
2094
- primary: true
2095
- },
2096
- {
2097
- city: "Jacobabad",
2098
- postalCode: "79000",
2099
- area: "Jacobabad GPO",
2100
- primary: true
2101
- },
2102
- {
2103
- city: "Shikarpur",
2104
- postalCode: "78100",
2105
- area: "Shikarpur GPO",
2106
- primary: true
2107
- },
2108
- {
2109
- city: "Dadu",
2110
- postalCode: "76200",
2111
- area: "Dadu GPO",
2112
- primary: true
2113
- },
2114
- {
2115
- city: "Badin",
2116
- postalCode: "72220",
2117
- area: "Badin GPO",
2118
- primary: true
2119
- },
2120
- {
2121
- city: "Thatta",
2122
- postalCode: "73020",
2123
- area: "Thatta GPO",
2124
- primary: true
2125
- },
2126
- {
2127
- city: "Sanghar",
2128
- postalCode: "68100",
2129
- area: "Sanghar GPO",
2130
- primary: true
2131
- },
2132
- {
2133
- city: "Umerkot",
2134
- postalCode: "69100",
2135
- area: "Umerkot GPO",
2136
- primary: true
2137
- },
2138
- {
2139
- city: "Tharparkar",
2140
- postalCode: "69230",
2141
- area: "Mithi GPO",
2142
- primary: true
2143
- },
2144
- {
2145
- city: "Jamshoro",
2146
- postalCode: "76080",
2147
- area: "Jamshoro GPO",
2148
- primary: true
2149
- },
2150
- {
2151
- city: "Matiari",
2152
- postalCode: "70100",
2153
- area: "Matiari GPO",
2154
- primary: true
2155
- },
2156
- {
2157
- city: "Khairpur",
2158
- postalCode: "66020",
2159
- area: "Khairpur GPO",
2160
- primary: true
2161
- },
2162
- {
2163
- city: "Ghotki",
2164
- postalCode: "65110",
2165
- area: "Ghotki GPO",
2166
- primary: true
2167
- },
2168
- {
2169
- city: "Kashmore",
2170
- postalCode: "79200",
2171
- area: "Kashmore GPO",
2172
- primary: true
2173
- },
2174
- {
2175
- city: "Sujawal",
2176
- postalCode: "73220",
2177
- area: "Sujawal GPO",
2178
- primary: true
2179
- },
2180
- {
2181
- city: "Peshawar",
2182
- postalCode: "25000",
2183
- area: "Peshawar GPO",
2184
- primary: true
2185
- },
2186
- {
2187
- city: "Mardan",
2188
- postalCode: "23200",
2189
- area: "Mardan GPO",
2190
- primary: true
2191
- },
2192
- {
2193
- city: "Abbottabad",
2194
- postalCode: "22010",
2195
- area: "Abbottabad GPO",
2196
- primary: true
2197
- },
2198
- {
2199
- city: "Kohat",
2200
- postalCode: "26000",
2201
- area: "Kohat GPO",
2202
- primary: true
2203
- },
2204
- {
2205
- city: "Bannu",
2206
- postalCode: "28100",
2207
- area: "Bannu GPO",
2208
- primary: true
2209
- },
2210
- {
2211
- city: "Swat",
2212
- postalCode: "19200",
2213
- area: "Mingora GPO",
2214
- primary: true
2215
- },
2216
- {
2217
- city: "Mansehra",
2218
- postalCode: "21300",
2219
- area: "Mansehra GPO",
2220
- primary: true
2221
- },
2222
- {
2223
- city: "Dera Ismail Khan",
2224
- postalCode: "29120",
2225
- area: "DI Khan GPO",
2226
- primary: true
2227
- },
2228
- {
2229
- city: "Nowshera",
2230
- postalCode: "24100",
2231
- area: "Nowshera GPO",
2232
- primary: true
2233
- },
2234
- {
2235
- city: "Swabi",
2236
- postalCode: "23430",
2237
- area: "Swabi GPO",
2238
- primary: true
2239
- },
2240
- {
2241
- city: "Charsadda",
2242
- postalCode: "24420",
2243
- area: "Charsadda GPO",
2244
- primary: true
2245
- },
2246
- {
2247
- city: "Haripur",
2248
- postalCode: "22620",
2249
- area: "Haripur GPO",
2250
- primary: true
2251
- },
2252
- {
2253
- city: "Hangu",
2254
- postalCode: "26190",
2255
- area: "Hangu GPO",
2256
- primary: true
2257
- },
2258
- {
2259
- city: "Karak",
2260
- postalCode: "27200",
2261
- area: "Karak GPO",
2262
- primary: true
2263
- },
2264
- {
2265
- city: "Tank",
2266
- postalCode: "29430",
2267
- area: "Tank GPO",
2268
- primary: true
2269
- },
2270
- {
2271
- city: "Lakki Marwat",
2272
- postalCode: "28420",
2273
- area: "Lakki Marwat GPO",
2274
- primary: true
2275
- },
2276
- {
2277
- city: "Quetta",
2278
- postalCode: "87300",
2279
- area: "Quetta GPO",
2280
- primary: true
2281
- },
2282
- {
2283
- city: "Gwadar",
2284
- postalCode: "91200",
2285
- area: "Gwadar GPO",
2286
- primary: true
2287
- },
2288
- {
2289
- city: "Turbat",
2290
- postalCode: "92600",
2291
- area: "Turbat GPO",
2292
- primary: true
2293
- },
2294
- {
2295
- city: "Khuzdar",
2296
- postalCode: "89100",
2297
- area: "Khuzdar GPO",
2298
- primary: true
2299
- },
2300
- {
2301
- city: "Sibi",
2302
- postalCode: "82000",
2303
- area: "Sibi GPO",
2304
- primary: true
2305
- },
2306
- {
2307
- city: "Loralai",
2308
- postalCode: "84800",
2309
- area: "Loralai GPO",
2310
- primary: true
2311
- },
2312
- {
2313
- city: "Zhob",
2314
- postalCode: "85200",
2315
- area: "Zhob GPO",
2316
- primary: true
2317
- },
2318
- {
2319
- city: "Chaman",
2320
- postalCode: "86000",
2321
- area: "Chaman GPO",
2322
- primary: true
2323
- },
2324
- {
2325
- city: "Hub",
2326
- postalCode: "90250",
2327
- area: "Hub GPO",
2328
- primary: true
2329
- },
2330
- {
2331
- city: "Muzaffarabad",
2332
- postalCode: "13100",
2333
- area: "Muzaffarabad GPO",
2334
- primary: true
2335
- },
2336
- {
2337
- city: "Mirpur",
2338
- postalCode: "10250",
2339
- area: "Mirpur GPO",
2340
- primary: true
2341
- },
2342
- {
2343
- city: "Kotli",
2344
- postalCode: "11100",
2345
- area: "Kotli GPO",
2346
- primary: true
2347
- },
2348
- {
2349
- city: "Rawalakot",
2350
- postalCode: "12350",
2351
- area: "Rawalakot GPO",
2352
- primary: true
2353
- },
2354
- {
2355
- city: "Bagh",
2356
- postalCode: "12500",
2357
- area: "Bagh GPO",
2358
- primary: true
2359
- },
2360
- {
2361
- city: "Gilgit",
2362
- postalCode: "15700",
2363
- area: "Gilgit GPO",
2364
- primary: true
2365
- },
2366
- {
2367
- city: "Skardu",
2368
- postalCode: "16100",
2369
- area: "Skardu GPO",
2370
- primary: true
2371
- }
2372
- ];
2373
-
2374
- // src/postal.ts
2375
- var POSTAL_ENTRIES = postal_codes_default;
2376
- var POSTAL_BY_CODE = new Map(
2377
- POSTAL_ENTRIES.map((entry) => [entry.postalCode, entry.city])
2378
- );
2379
- var POSTAL_BY_CITY = /* @__PURE__ */ new Map();
2380
- for (const entry of POSTAL_ENTRIES) {
2381
- const key = normalizeKey(entry.city);
2382
- const existing = POSTAL_BY_CITY.get(key);
2383
- if (existing === void 0 || entry.primary === true) {
2384
- POSTAL_BY_CITY.set(key, entry.postalCode);
2385
- }
2386
- }
2387
- function getCityByPostalCode(postalCode) {
2388
- const code = stripPostalCode(postalCode);
2389
- if (code.length === 0) {
2390
- return null;
2391
- }
2392
- return POSTAL_BY_CODE.get(code) ?? null;
2393
- }
2394
- function getPostalCode(city) {
2395
- const key = normalizeKey(city);
2396
- if (key.length === 0) {
2397
- return null;
2398
- }
2399
- return POSTAL_BY_CITY.get(key) ?? null;
2400
- }
2401
- function stripPostalCode(postalCode) {
2402
- return postalCode.trim().replace(/\s+/g, "");
2403
- }
2404
-
2405
- // src/address.ts
2406
- var CITY_NAMES = cities_default.map((entry) => entry.city).sort((a, b) => b.length - a.length);
2407
- var DISTRICT_NAMES = districts_default.map((entry) => entry.district).sort((a, b) => b.length - a.length);
2408
- var PROVINCES = [
2409
- "Islamabad Capital Territory",
2410
- "Azad Jammu and Kashmir",
2411
- "Gilgit-Baltistan",
2412
- "Khyber Pakhtunkhwa",
2413
- "Balochistan",
2414
- "Punjab",
2415
- "Sindh"
2416
- ];
2417
- function parseAddress(address) {
2418
- const raw = normalizeWhitespace(address);
2419
- if (raw.length === 0) {
2420
- return emptyParsedAddress(raw);
2421
- }
2422
- let working = raw;
2423
- let postalCode = null;
2424
- const postalMatch = working.match(/\b(\d{5})\b/);
2425
- if (postalMatch?.[1]) {
2426
- postalCode = postalMatch[1];
2427
- working = working.replace(postalMatch[0], " ").trim();
2428
- }
2429
- const segments = working.split(",").map((part) => normalizeWhitespace(part)).filter((part) => part.length > 0);
2430
- const consumed = /* @__PURE__ */ new Set();
2431
- let province = null;
2432
- let city = null;
2433
- let district = null;
2434
- for (let i = segments.length - 1; i >= 0; i -= 1) {
2435
- const segment = segments[i];
2436
- if (segment === void 0 || consumed.has(i)) {
2437
- continue;
2438
- }
2439
- if (province === null) {
2440
- const matchedProvince = matchFromList(segment, PROVINCES);
2441
- if (matchedProvince) {
2442
- province = matchedProvince;
2443
- consumed.add(i);
2444
- continue;
2445
- }
2446
- }
2447
- if (city === null) {
2448
- const matchedCity = matchFromList(segment, CITY_NAMES);
2449
- if (matchedCity) {
2450
- city = matchedCity;
2451
- consumed.add(i);
2452
- continue;
2453
- }
2454
- }
2455
- if (district === null) {
2456
- const matchedDistrict = matchFromList(segment, DISTRICT_NAMES);
2457
- if (matchedDistrict) {
2458
- district = matchedDistrict;
2459
- if (city === null) {
2460
- city = matchedDistrict;
2461
- }
2462
- consumed.add(i);
2463
- }
2464
- }
2465
- }
2466
- if (postalCode !== null && city === null) {
2467
- city = getCityByPostalCode(postalCode);
2468
- }
2469
- if (city !== null && province === null) {
2470
- province = getProvince(city) ?? getDistrictProvince(city);
2471
- }
2472
- if (district !== null && province === null) {
2473
- province = getDistrictProvince(district);
2474
- }
2475
- const remaining = segments.filter((_, index) => !consumed.has(index));
2476
- const street = remaining.length > 0 ? remaining[0] ?? null : null;
2477
- const area = remaining.length > 1 ? remaining.slice(1).join(", ") : null;
2478
- return {
2479
- raw,
2480
- street,
2481
- area,
2482
- city,
2483
- district,
2484
- province,
2485
- postalCode
2486
- };
2487
- }
2488
- function emptyParsedAddress(raw) {
2489
- return {
2490
- raw,
2491
- street: null,
2492
- area: null,
2493
- city: null,
2494
- district: null,
2495
- province: null,
2496
- postalCode: null
2497
- };
2498
- }
2499
- function matchFromList(segment, options) {
2500
- const key = normalizeKey(segment);
2501
- for (const option of options) {
2502
- if (normalizeKey(option) === key) {
2503
- return option;
2504
- }
2505
- }
2506
- return null;
2507
- }
2508
-
2509
- // src/text.ts
2510
- var URDU_DIGITS = ["\u06F0", "\u06F1", "\u06F2", "\u06F3", "\u06F4", "\u06F5", "\u06F6", "\u06F7", "\u06F8", "\u06F9"];
2511
- var ENGLISH_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
2512
- var ARABIC_INDIC_DIGITS = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
2513
- var ROMAN_URDU_REPLACEMENTS = [
2514
- [/\bkia\b/gi, "kya"],
2515
- [/\bker\b/gi, "kar"],
2516
- [/\bkr\b/gi, "kar"],
2517
- [/\bhai\b/gi, "hai"],
2518
- [/\bhy\b/gi, "hai"],
2519
- [/\bmujhe\b/gi, "mujhe"],
2520
- [/\bmujhay\b/gi, "mujhe"],
2521
- [/\bap\b/gi, "aap"],
2522
- [/\btum\b/gi, "tum"],
2523
- [/\bshukria\b/gi, "shukriya"],
2524
- [/\bmein\b/gi, "main"],
2525
- [/\bmen\b/gi, "main"],
2526
- [/\bnahi\b/gi, "nahi"],
2527
- [/\bnhi\b/gi, "nahi"],
2528
- [/\bassalamu alaikum\b/gi, "assalamualaikum"],
2529
- [/\bassalam o alaikum\b/gi, "assalamualaikum"],
2530
- [/\bkhuda hafiz\b/gi, "khuda hafiz"],
2531
- [/\ballah hafiz\b/gi, "allah hafiz"]
2532
- ];
2533
- function normalizeText(text) {
2534
- return normalizeWhitespace(text.normalize("NFC"));
2535
- }
2536
- function normalizeRomanUrdu(text) {
2537
- let result = normalizeText(toEnglishDigits(text));
2538
- for (const [pattern, replacement] of ROMAN_URDU_REPLACEMENTS) {
2539
- result = result.replace(pattern, replacement);
2540
- }
2541
- return result;
2542
- }
2543
- function toEnglishDigits(text) {
2544
- let result = text;
2545
- for (let i = 0; i < URDU_DIGITS.length; i += 1) {
2546
- const urdu = URDU_DIGITS[i];
2547
- const english = ENGLISH_DIGITS[i];
2548
- if (urdu !== void 0 && english !== void 0) {
2549
- result = result.replaceAll(urdu, english);
2550
- }
2551
- }
2552
- for (let i = 0; i < ARABIC_INDIC_DIGITS.length; i += 1) {
2553
- const arabic = ARABIC_INDIC_DIGITS[i];
2554
- const english = ENGLISH_DIGITS[i];
2555
- if (arabic !== void 0 && english !== void 0) {
2556
- result = result.replaceAll(arabic, english);
2557
- }
2558
- }
2559
- return result;
2560
- }
2561
-
2562
- // src/hijri.ts
2563
- var HIJRI_MONTHS = [
2564
- "Muharram",
2565
- "Safar",
2566
- "Rabi al-Awwal",
2567
- "Rabi al-Thani",
2568
- "Jumada al-Awwal",
2569
- "Jumada al-Thani",
2570
- "Rajab",
2571
- "Shaaban",
2572
- "Ramadan",
2573
- "Shawwal",
2574
- "Dhu al-Qadah",
2575
- "Dhu al-Hijjah"
2576
- ];
2577
- function toHijri(date) {
2578
- const jd = gregorianToJulianDay(
2579
- date.getFullYear(),
2580
- date.getMonth() + 1,
2581
- date.getDate()
2582
- );
2583
- return julianDayToHijri(jd);
2584
- }
2585
- function formatHijri(date) {
2586
- const hijri = toHijri(date);
2587
- const monthName = getHijriMonthName(hijri.month);
2588
- return `${hijri.day} ${monthName} ${hijri.year}`;
2589
- }
2590
- function getHijriMonthName(month) {
2591
- if (month < 1 || month > 12) {
2592
- return "";
2593
- }
2594
- return HIJRI_MONTHS[month - 1] ?? "";
2595
- }
2596
- function gregorianToJulianDay(year, month, day) {
2597
- let y = year;
2598
- let m = month;
2599
- if (m <= 2) {
2600
- y -= 1;
2601
- m += 12;
2602
- }
2603
- const A = Math.floor(y / 100);
2604
- const B = 2 - A + Math.floor(A / 4);
2605
- return Math.floor(365.25 * (y + 4716)) + Math.floor(30.6001 * (m + 1)) + day + B - 1524.5;
2606
- }
2607
- function julianDayToHijri(jd) {
2608
- const l = Math.floor(jd - 1948440 + 10632);
2609
- const n = Math.floor((l - 1) / 10631);
2610
- const l2 = l - 10631 * n + 354;
2611
- const j = Math.floor((10985 - l2) / 5316) * Math.floor(50 * l2 / 17719) + Math.floor(l2 / 5670) * Math.floor(43 * l2 / 15238);
2612
- const l3 = l2 - Math.floor((30 - j) / 15) * Math.floor(17719 * j / 50) - Math.floor(j / 16) * Math.floor(15238 * j / 43) + 29;
2613
- const month = Math.floor(24 * l3 / 709);
2614
- const day = l3 - Math.floor(709 * month / 24);
2615
- const year = 30 * n + j - 30;
2616
- return { year, month, day };
2617
- }
2618
-
2619
- // src/cli.ts
4
+ // package.json
5
+ var version = "2.1.1";
6
+ var EXIT_OK = 0;
7
+ var EXIT_NEGATIVE = 1;
8
+ var EXIT_USAGE = 2;
2620
9
  var [, , command, ...args] = process.argv;
2621
10
  var input = args.join(" ").trim();
2622
11
  function printUsage() {
2623
- console.log(`pakdatakit \u2014 Pakistani developer utilities
12
+ console.log(`pakdatakit ${version} \u2014 Pakistani developer utilities
2624
13
 
2625
14
  Usage:
2626
15
  pakdatakit <command> [input]
@@ -2637,69 +26,104 @@ Commands:
2637
26
  parse-address <address> Parse a Pakistani address
2638
27
  format-pkr <amount> Format PKR amount
2639
28
  format-lakh <amount> Format in Lakh/Crore
2640
- hijri [iso-date] Convert date to Hijri (default: today)
29
+ hijri [yyyy-mm-dd] Convert date to Hijri (default: today)
2641
30
  normalize-urdu <text> Normalize Roman Urdu text
2642
- help Show this help message
31
+ help, --help Show this help message
32
+ --version Show the version
33
+
34
+ Exit status is 0 when the input is valid or found, 1 when it is invalid or
35
+ not found, and 2 for usage errors.
2643
36
  `);
2644
37
  }
38
+ function usageError(message) {
39
+ console.error(`Error: ${message}`);
40
+ return EXIT_USAGE;
41
+ }
42
+ function printBoolean(result) {
43
+ console.log(result);
44
+ return result ? EXIT_OK : EXIT_NEGATIVE;
45
+ }
46
+ function printLookup(result) {
47
+ console.log(result ?? "Not found");
48
+ return result === null ? EXIT_NEGATIVE : EXIT_OK;
49
+ }
50
+ function parseAmount(value) {
51
+ const amount = Number(value.replace(/,/g, ""));
52
+ return value.length > 0 && Number.isFinite(amount) ? amount : null;
53
+ }
54
+ function parseLocalDate(value) {
55
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
56
+ if (!match) {
57
+ return null;
58
+ }
59
+ const [year, month, day] = match.slice(1).map(Number);
60
+ const date = new Date(year, month - 1, day);
61
+ return date.getMonth() === month - 1 ? date : null;
62
+ }
2645
63
  function run() {
2646
- if (!command || command === "help" || command === "--help") {
64
+ if (!command || command === "help" || command === "--help" || command === "-h") {
2647
65
  printUsage();
2648
- return;
66
+ return EXIT_OK;
67
+ }
68
+ if (command === "--version" || command === "-v") {
69
+ console.log(version);
70
+ return EXIT_OK;
2649
71
  }
2650
72
  if (input.length === 0 && command !== "hijri") {
2651
- console.error(`Error: missing input for "${command}"`);
2652
- process.exit(1);
73
+ return usageError(`missing input for "${command}"`);
2653
74
  }
2654
75
  switch (command) {
2655
76
  case "validate-cnic":
2656
- console.log(validateCNIC(input));
2657
- break;
77
+ return printBoolean(validateCNIC(input));
2658
78
  case "validate-phone":
2659
- console.log(validatePhone(input));
2660
- break;
2661
- case "analyze-phone":
2662
- console.log(JSON.stringify(analyzePhone(input), null, 2));
2663
- break;
79
+ return printBoolean(validatePhone(input));
80
+ case "analyze-phone": {
81
+ const analysis = analyzePhone(input);
82
+ console.log(JSON.stringify(analysis, null, 2));
83
+ return analysis.valid ? EXIT_OK : EXIT_NEGATIVE;
84
+ }
2664
85
  case "validate-iban":
2665
- console.log(validateIBAN(input));
2666
- break;
86
+ return printBoolean(validateIBAN(input));
2667
87
  case "bank-from-iban":
2668
- console.log(getBankFromIBAN(input) ?? "Unknown");
2669
- break;
88
+ return printLookup(getBankFromIBAN(input));
2670
89
  case "province":
2671
- console.log(getProvince(input) ?? "Not found");
2672
- break;
90
+ return printLookup(getProvince(input));
2673
91
  case "postal-code":
2674
- console.log(getPostalCode(input) ?? "Not found");
2675
- break;
92
+ return printLookup(getPostalCode(input));
2676
93
  case "city-from-postal":
2677
- console.log(getCityByPostalCode(input) ?? "Not found");
2678
- break;
94
+ return printLookup(getCityByPostalCode(input));
2679
95
  case "parse-address":
2680
96
  console.log(JSON.stringify(parseAddress(input), null, 2));
2681
- break;
97
+ return EXIT_OK;
2682
98
  case "format-pkr":
2683
- console.log(formatPKR(Number(input)));
2684
- break;
2685
- case "format-lakh":
2686
- console.log(formatLakh(Number(input)));
2687
- break;
99
+ case "format-lakh": {
100
+ const amount = parseAmount(input);
101
+ if (amount === null) {
102
+ return usageError(`"${input}" is not a number`);
103
+ }
104
+ console.log(
105
+ command === "format-pkr" ? formatPKR(amount) : formatLakh(amount)
106
+ );
107
+ return EXIT_OK;
108
+ }
2688
109
  case "hijri": {
2689
- const date = input.length > 0 ? new Date(input) : /* @__PURE__ */ new Date();
110
+ const date = input.length > 0 ? parseLocalDate(input) : /* @__PURE__ */ new Date();
111
+ if (date === null) {
112
+ return usageError(
113
+ `"${input}" is not a valid date (expected yyyy-mm-dd)`
114
+ );
115
+ }
2690
116
  console.log(formatHijri(date));
2691
117
  console.log(JSON.stringify(toHijri(date), null, 2));
2692
- break;
118
+ return EXIT_OK;
2693
119
  }
2694
120
  case "normalize-urdu":
2695
121
  console.log(normalizeRomanUrdu(input));
2696
- break;
122
+ return EXIT_OK;
2697
123
  default:
2698
124
  console.error(`Unknown command: ${command}`);
2699
125
  printUsage();
2700
- process.exit(1);
126
+ return EXIT_USAGE;
2701
127
  }
2702
128
  }
2703
- run();
2704
- //# sourceMappingURL=cli.js.map
2705
- //# sourceMappingURL=cli.js.map
129
+ process.exitCode = run();