pakdatakit 1.1.0 → 2.1.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.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +907 -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-422X6FEZ.cjs +220 -0
  9. package/dist/chunk-432ZYMYV.js +31 -0
  10. package/dist/chunk-4VVFS6FN.cjs +715 -0
  11. package/dist/chunk-6TSKA2PH.js +38 -0
  12. package/dist/chunk-APXP7OK7.cjs +226 -0
  13. package/dist/chunk-AUATLZA5.cjs +168 -0
  14. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  15. package/dist/chunk-CEPNSHIC.js +33 -0
  16. package/dist/chunk-CQKK3S7A.js +217 -0
  17. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  18. package/dist/chunk-EEVNLTB4.js +32 -0
  19. package/dist/chunk-ENQ7O7VW.js +32 -0
  20. package/dist/chunk-H4DVWUYH.js +231 -0
  21. package/dist/chunk-H6M6L26S.cjs +37 -0
  22. package/dist/chunk-HBOZIITD.js +351 -0
  23. package/dist/chunk-HTCSHHOR.cjs +35 -0
  24. package/dist/chunk-JKE4AMSZ.js +47 -0
  25. package/dist/chunk-K6CZFCX6.js +1642 -0
  26. package/dist/chunk-KEHCTYLO.cjs +52 -0
  27. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  28. package/dist/chunk-L2BDDM2W.js +165 -0
  29. package/dist/chunk-L45UXUWX.js +21 -0
  30. package/dist/chunk-LIYNKIKS.js +709 -0
  31. package/dist/chunk-LVHTH4P7.cjs +41 -0
  32. package/dist/chunk-OVUR47QH.cjs +22 -0
  33. package/dist/chunk-P4CGOJEM.js +16 -0
  34. package/dist/chunk-PHHKIMO2.cjs +35 -0
  35. package/dist/chunk-QQQKISXT.js +223 -0
  36. package/dist/chunk-T3E4B5MJ.js +417 -0
  37. package/dist/chunk-VPBMIYO2.cjs +38 -0
  38. package/dist/chunk-WPKV5JT3.cjs +235 -0
  39. package/dist/chunk-XCXFGTHW.cjs +355 -0
  40. package/dist/chunk-XT4ZNXRC.js +20 -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 +119 -0
  92. package/dist/raast.d.ts +119 -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
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
4
+
5
+ // src/text.ts
6
+ var URDU_DIGITS = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
7
+ var ROMAN_URDU_REPLACEMENTS = [
8
+ [/\bkia\b/gi, "kya"],
9
+ [/\bker\b/gi, "kar"],
10
+ [/\bkr\b/gi, "kar"],
11
+ [/\bhy\b/gi, "hai"],
12
+ [/\bmujhay\b/gi, "mujhe"],
13
+ [/\bap\b/gi, "aap"],
14
+ [/\bshukria\b/gi, "shukriya"],
15
+ [/\bnhi\b/gi, "nahi"],
16
+ [/\bassalamu alaikum\b/gi, "assalamualaikum"],
17
+ [/\bassalam o alaikum\b/gi, "assalamualaikum"]
18
+ ];
19
+ function normalizeText(text) {
20
+ return chunkVPBMIYO2_cjs.normalizeWhitespace(text.normalize("NFC"));
21
+ }
22
+ function normalizeRomanUrdu(text) {
23
+ let result = normalizeText(toEnglishDigits(text));
24
+ for (const [pattern, replacement] of ROMAN_URDU_REPLACEMENTS) {
25
+ result = result.replace(pattern, (match) => matchCase(match, replacement));
26
+ }
27
+ return result;
28
+ }
29
+ function toUrduDigits(text) {
30
+ return chunkVPBMIYO2_cjs.toAsciiDigits(text).replace(
31
+ /\d/g,
32
+ (digit) => URDU_DIGITS[Number(digit)]
33
+ );
34
+ }
35
+ function toEnglishDigits(text) {
36
+ return chunkVPBMIYO2_cjs.toAsciiDigits(text);
37
+ }
38
+ function matchCase(original, replacement) {
39
+ if (original.length > 1 && original === original.toUpperCase()) {
40
+ return original;
41
+ }
42
+ const first = original[0];
43
+ if (first !== first.toLowerCase()) {
44
+ return replacement[0]?.toUpperCase() + replacement.slice(1);
45
+ }
46
+ return replacement;
47
+ }
48
+
49
+ exports.normalizeRomanUrdu = normalizeRomanUrdu;
50
+ exports.normalizeText = normalizeText;
51
+ exports.toEnglishDigits = toEnglishDigits;
52
+ exports.toUrduDigits = toUrduDigits;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
4
+
5
+ // src/whatsapp.ts
6
+ function createWhatsAppLink(phone, message) {
7
+ const digits = chunkYLWZGSFY_cjs.normalizePhoneDigits(phone);
8
+ if (digits === null) {
9
+ return null;
10
+ }
11
+ const baseUrl = `https://wa.me/${digits}`;
12
+ if (message === void 0 || message.length === 0) {
13
+ return baseUrl;
14
+ }
15
+ return `${baseUrl}?text=${encodeURIComponent(message)}`;
16
+ }
17
+
18
+ exports.createWhatsAppLink = createWhatsAppLink;
@@ -0,0 +1,165 @@
1
+ import { getCityByPostalCode } from './chunk-LIYNKIKS.js';
2
+ import { cities_default, districts_default, getProvince, getDistrictProvince } from './chunk-K6CZFCX6.js';
3
+ import { lazy, normalizeWhitespace, normalizeKey } from './chunk-ENQ7O7VW.js';
4
+
5
+ // src/address.ts
6
+ function byLengthDesc(a, b) {
7
+ return b.length - a.length;
8
+ }
9
+ var cityNames = lazy(
10
+ () => cities_default.map((entry) => entry.city).sort(byLengthDesc)
11
+ );
12
+ var districtNames = lazy(
13
+ () => districts_default.map((entry) => entry.district).sort(byLengthDesc)
14
+ );
15
+ var PROVINCES = [
16
+ "Islamabad Capital Territory",
17
+ "Azad Jammu and Kashmir",
18
+ "Gilgit-Baltistan",
19
+ "Khyber Pakhtunkhwa",
20
+ "Balochistan",
21
+ "Punjab",
22
+ "Sindh"
23
+ ];
24
+ var NON_POSTAL_PREFIX = /(?:\b(?:p\.?\s*o\.?\s*box|box|house|h\.?\s*no\.?|plot|street|st\.?|flat|shop|office|suite|no\.?)|#)\s*$/i;
25
+ function parseAddress(address) {
26
+ const raw = normalizeWhitespace(address);
27
+ if (raw.length === 0) {
28
+ return emptyParsedAddress(raw);
29
+ }
30
+ const warnings = [];
31
+ let working = raw;
32
+ const postalMatch = findPostalCode(working);
33
+ const postalCode = postalMatch?.code ?? null;
34
+ if (postalMatch) {
35
+ working = working.slice(0, postalMatch.index) + " " + working.slice(postalMatch.index + postalMatch.code.length);
36
+ }
37
+ const segments = working.split(",").map((part) => normalizeWhitespace(part)).filter((part) => part.length > 0);
38
+ let province = null;
39
+ let city = null;
40
+ let district = null;
41
+ for (let i = segments.length - 1; i >= 0; i -= 1) {
42
+ const segment = segments[i];
43
+ const matchedProvince = province === null ? matchExact(segment, PROVINCES) : null;
44
+ if (matchedProvince) {
45
+ province = matchedProvince;
46
+ segments[i] = "";
47
+ continue;
48
+ }
49
+ const matchedCity = city === null ? matchExact(segment, cityNames()) : null;
50
+ if (matchedCity) {
51
+ city = matchedCity;
52
+ segments[i] = "";
53
+ continue;
54
+ }
55
+ const matchedDistrict = district === null ? matchExact(segment, districtNames()) : null;
56
+ if (matchedDistrict) {
57
+ district = matchedDistrict;
58
+ segments[i] = "";
59
+ }
60
+ }
61
+ for (let i = segments.length - 1; i >= 0; i -= 1) {
62
+ if (province === null) {
63
+ const found = matchTrailing(segments[i], PROVINCES);
64
+ if (found) {
65
+ province = found.match;
66
+ segments[i] = found.rest;
67
+ }
68
+ }
69
+ if (city === null) {
70
+ const found = matchTrailing(segments[i], cityNames());
71
+ if (found) {
72
+ city = found.match;
73
+ segments[i] = found.rest;
74
+ }
75
+ }
76
+ }
77
+ if (city === null && district !== null) {
78
+ city = district;
79
+ }
80
+ if (postalCode !== null && city === null) {
81
+ city = getCityByPostalCode(postalCode);
82
+ }
83
+ const inferredProvince = city !== null ? getProvince(city) ?? getDistrictProvince(city) : district !== null ? getDistrictProvince(district) : null;
84
+ if (province === null) {
85
+ province = inferredProvince;
86
+ } else if (inferredProvince !== null && inferredProvince !== province) {
87
+ warnings.push(
88
+ `${city ?? district} is in ${inferredProvince}, but the address says ${province}`
89
+ );
90
+ }
91
+ const remaining = segments.filter((part) => part.length > 0);
92
+ const street = remaining[0] ?? null;
93
+ const area = remaining.length > 1 ? remaining.slice(1).join(", ") : null;
94
+ return {
95
+ raw,
96
+ street,
97
+ area,
98
+ city,
99
+ district,
100
+ province,
101
+ postalCode,
102
+ warnings
103
+ };
104
+ }
105
+ function formatAddress(parts) {
106
+ const segments = [
107
+ parts.street,
108
+ parts.area,
109
+ parts.city ?? parts.district,
110
+ parts.province
111
+ ].filter(
112
+ (part) => typeof part === "string" && part.length > 0
113
+ );
114
+ let formatted = segments.join(", ");
115
+ if (parts.postalCode) {
116
+ formatted = formatted.length > 0 ? `${formatted} ${parts.postalCode}` : parts.postalCode;
117
+ }
118
+ return formatted.length > 0 ? formatted : parts.raw ?? "";
119
+ }
120
+ function emptyParsedAddress(raw) {
121
+ return {
122
+ raw,
123
+ street: null,
124
+ area: null,
125
+ city: null,
126
+ district: null,
127
+ province: null,
128
+ postalCode: null,
129
+ warnings: []
130
+ };
131
+ }
132
+ function findPostalCode(text) {
133
+ let result = null;
134
+ for (const match of text.matchAll(/(?<![\w#/-])([1-9]\d{4})(?![\w/-])/g)) {
135
+ const before = text.slice(0, match.index);
136
+ if (!NON_POSTAL_PREFIX.test(before)) {
137
+ result = { code: match[1], index: match.index };
138
+ }
139
+ }
140
+ return result;
141
+ }
142
+ function matchExact(segment, options) {
143
+ const key = normalizeKey(segment);
144
+ if (key.length === 0) {
145
+ return null;
146
+ }
147
+ return options.find((option) => normalizeKey(option) === key) ?? null;
148
+ }
149
+ function matchTrailing(segment, options) {
150
+ const key = normalizeKey(segment);
151
+ for (const option of options) {
152
+ const optionKey = normalizeKey(option);
153
+ if (key.endsWith(` ${optionKey}`)) {
154
+ return {
155
+ match: option,
156
+ rest: normalizeWhitespace(
157
+ segment.slice(0, segment.length - option.length)
158
+ )
159
+ };
160
+ }
161
+ }
162
+ return null;
163
+ }
164
+
165
+ export { formatAddress, parseAddress };
@@ -0,0 +1,21 @@
1
+ import { networks_default, getPhonePrefix } from './chunk-Y6BUGLXU.js';
2
+ import { lazy } from './chunk-ENQ7O7VW.js';
3
+
4
+ // src/networks.ts
5
+ var prefixMap = lazy(
6
+ () => new Map(
7
+ networks_default.map((entry) => [
8
+ entry.prefix,
9
+ entry.network
10
+ ])
11
+ )
12
+ );
13
+ function getNetwork(phone) {
14
+ const prefix = getPhonePrefix(phone);
15
+ if (prefix === null) {
16
+ return "Unknown";
17
+ }
18
+ return prefixMap().get(prefix) ?? "Unknown";
19
+ }
20
+
21
+ export { getNetwork };