pakdatakit 2.5.1 → 2.7.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/DATA.md +83 -7
- package/README.md +94 -31
- package/dist/{chunk-LQHM3ADX.js → chunk-33JPVN33.js} +11 -6
- package/dist/{chunk-XCFZKCV2.cjs → chunk-36K225SE.cjs} +14 -9
- package/dist/{chunk-CEPNSHIC.js → chunk-3OCMTNQ7.js} +1 -1
- package/dist/{chunk-YDUXIENX.cjs → chunk-4YLSPXBZ.cjs} +2 -2
- package/dist/{chunk-2OBKPYJZ.cjs → chunk-6AIN4FKB.cjs} +12 -4
- package/dist/chunk-7NTUEHQV.cjs +69 -0
- package/dist/{chunk-KRYHLYN2.js → chunk-BATPA7GN.js} +12 -4
- package/dist/chunk-CKCOK6X4.js +64 -0
- package/dist/{chunk-7DY26QPN.js → chunk-CRYCAMWC.js} +1 -1
- package/dist/{chunk-TVL6RDAU.cjs → chunk-EGF4CINK.cjs} +2 -2
- package/dist/{chunk-XVEG53NN.cjs → chunk-GOGEMCGG.cjs} +84 -0
- package/dist/chunk-NDW52ZK3.js +85 -0
- package/dist/chunk-NLSIAPZG.cjs +90 -0
- package/dist/{chunk-IDTRFOQW.js → chunk-OYQJQE5R.js} +10 -5
- package/dist/{chunk-5RGX4DWF.js → chunk-SGGQ6XB2.js} +46 -14
- package/dist/{chunk-UYFTXD4P.js → chunk-T6K46DGW.js} +1 -1
- package/dist/{chunk-AUQFA7EE.cjs → chunk-VSIVT5RT.cjs} +11 -6
- package/dist/{chunk-H6M6L26S.cjs → chunk-VZIBHQC7.cjs} +2 -2
- package/dist/{chunk-EA3SIHYT.js → chunk-WYNM5ZWY.js} +84 -1
- package/dist/{chunk-5DDHO5Z7.cjs → chunk-XWGSREI5.cjs} +46 -14
- package/dist/class-validator.cjs +18 -9
- package/dist/class-validator.d.cts +12 -3
- package/dist/class-validator.d.ts +12 -3
- package/dist/class-validator.js +17 -9
- package/dist/cli.js +1 -1
- package/dist/cnic.cjs +11 -3
- package/dist/cnic.d.cts +80 -3
- package/dist/cnic.d.ts +80 -3
- package/dist/cnic.js +1 -1
- package/dist/format.cjs +11 -3
- package/dist/format.d.cts +57 -1
- package/dist/format.d.ts +57 -1
- package/dist/format.js +1 -1
- package/dist/incometax.cjs +6 -6
- package/dist/incometax.d.cts +51 -7
- package/dist/incometax.d.ts +51 -7
- package/dist/incometax.js +1 -1
- package/dist/index.cjs +67 -47
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +10 -10
- package/dist/input.cjs +8 -8
- package/dist/input.js +2 -2
- package/dist/joi.cjs +10 -8
- package/dist/joi.d.cts +2 -1
- package/dist/joi.d.ts +2 -1
- package/dist/joi.js +9 -7
- package/dist/numbers.cjs +5 -5
- package/dist/numbers.d.cts +28 -5
- package/dist/numbers.d.ts +28 -5
- package/dist/numbers.js +1 -1
- package/dist/quality.cjs +5 -5
- package/dist/quality.js +2 -2
- package/dist/raast.cjs +5 -5
- package/dist/raast.d.cts +17 -6
- package/dist/raast.d.ts +17 -6
- package/dist/raast.js +1 -1
- package/dist/{rules-GxgPiVws.d.cts → rules-GEELAOfb.d.cts} +5 -0
- package/dist/{rules-GxgPiVws.d.ts → rules-GEELAOfb.d.ts} +5 -0
- package/dist/superstruct.cjs +10 -8
- package/dist/superstruct.d.cts +2 -1
- package/dist/superstruct.d.ts +2 -1
- package/dist/superstruct.js +9 -7
- package/dist/tax.cjs +5 -5
- package/dist/tax.d.cts +8 -2
- package/dist/tax.d.ts +8 -2
- package/dist/tax.js +2 -2
- package/dist/text.cjs +13 -9
- package/dist/text.d.cts +40 -4
- package/dist/text.d.ts +40 -4
- package/dist/text.js +1 -1
- package/dist/valibot.cjs +16 -8
- package/dist/valibot.d.cts +2 -1
- package/dist/valibot.d.ts +2 -1
- package/dist/valibot.js +15 -7
- package/dist/words.d.cts +4 -1
- package/dist/words.d.ts +4 -1
- package/dist/yup.cjs +10 -8
- package/dist/yup.d.cts +2 -1
- package/dist/yup.d.ts +2 -1
- package/dist/yup.js +9 -7
- package/dist/zod.cjs +12 -8
- package/dist/zod.d.cts +2 -1
- package/dist/zod.d.ts +2 -1
- package/dist/zod.js +11 -7
- package/package.json +2 -2
- package/dist/chunk-6TSKA2PH.js +0 -38
- package/dist/chunk-EEVNLTB4.js +0 -32
- package/dist/chunk-HTCSHHOR.cjs +0 -35
- package/dist/chunk-LVHTH4P7.cjs +0 -41
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { toAsciiDigits } from './chunk-ENQ7O7VW.js';
|
|
2
|
+
|
|
3
|
+
// src/cnic.ts
|
|
4
|
+
var CNIC_PATTERN = /^[1-8]\d{4}([-‐‑‒–—. ]?)\d{7}\1\d$/;
|
|
5
|
+
function validateCNIC(cnic) {
|
|
6
|
+
return CNIC_PATTERN.test(toAsciiDigits(cnic.trim()));
|
|
7
|
+
}
|
|
8
|
+
var CNIC_PROVINCES = {
|
|
9
|
+
"1": "Khyber Pakhtunkhwa",
|
|
10
|
+
"2": "Khyber Pakhtunkhwa",
|
|
11
|
+
"3": "Punjab",
|
|
12
|
+
"4": "Sindh",
|
|
13
|
+
"5": "Balochistan",
|
|
14
|
+
"6": "Islamabad Capital Territory",
|
|
15
|
+
"7": "Gilgit-Baltistan",
|
|
16
|
+
"8": "Azad Jammu and Kashmir"
|
|
17
|
+
};
|
|
18
|
+
function getCNICInfo(cnic) {
|
|
19
|
+
if (!validateCNIC(cnic)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const digits = toAsciiDigits(cnic).replace(/\D/g, "");
|
|
23
|
+
const lastDigit = Number(digits[12]);
|
|
24
|
+
return {
|
|
25
|
+
digits,
|
|
26
|
+
formatted: `${digits.slice(0, 5)}-${digits.slice(5, 12)}-${digits[12]}`,
|
|
27
|
+
province: CNIC_PROVINCES[digits[0]],
|
|
28
|
+
gender: lastDigit % 2 === 1 ? "male" : "female"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var ANY_DIGIT = /[0-9\u06F0-\u06F9\u0660-\u0669]/.source;
|
|
32
|
+
var CNIC_SEPARATOR = /[-\u2010\u2011\u2012\u2013\u2014. ]/.source;
|
|
33
|
+
var CNIC_IN_TEXT = new RegExp(
|
|
34
|
+
`(?<!${ANY_DIGIT})` + /[1-8\u06F1-\u06F8\u0661-\u0668]/.source + `${ANY_DIGIT}{4}${CNIC_SEPARATOR}?${ANY_DIGIT}{7}${CNIC_SEPARATOR}?${ANY_DIGIT}(?!${ANY_DIGIT})`,
|
|
35
|
+
"g"
|
|
36
|
+
);
|
|
37
|
+
function findCNICs(text) {
|
|
38
|
+
if (typeof text !== "string") return [];
|
|
39
|
+
return [...text.matchAll(CNIC_IN_TEXT)].map((match) => {
|
|
40
|
+
const raw = match[0];
|
|
41
|
+
const digits = toAsciiDigits(raw).replace(/\D/g, "");
|
|
42
|
+
const start = match.index;
|
|
43
|
+
return {
|
|
44
|
+
raw,
|
|
45
|
+
digits,
|
|
46
|
+
formatted: `${digits.slice(0, 5)}-${digits.slice(5, 12)}-${digits[12]}`,
|
|
47
|
+
start,
|
|
48
|
+
end: start + raw.length
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function maskCNICs(text, options = {}) {
|
|
53
|
+
if (typeof text !== "string") return { text: "", count: 0 };
|
|
54
|
+
const mask = typeof options.mask === "string" ? options.mask : "X";
|
|
55
|
+
const digit = new RegExp(ANY_DIGIT, "g");
|
|
56
|
+
let count = 0;
|
|
57
|
+
const masked = text.replace(CNIC_IN_TEXT, (raw) => {
|
|
58
|
+
count += 1;
|
|
59
|
+
return raw.replace(digit, () => mask);
|
|
60
|
+
});
|
|
61
|
+
return { text: masked, count };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { findCNICs, getCNICInfo, maskCNICs, validateCNIC };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validateIBAN } from './chunk-IBZPJS4H.js';
|
|
2
2
|
import { isAllocatedPrefix } from './chunk-P7LVE2TF.js';
|
|
3
|
-
import { validateCNIC } from './chunk-
|
|
3
|
+
import { validateCNIC } from './chunk-CKCOK6X4.js';
|
|
4
4
|
import { toAsciiDigits } from './chunk-ENQ7O7VW.js';
|
|
5
5
|
|
|
6
6
|
// src/input.ts
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkDHOP7LQX_cjs = require('./chunk-DHOP7LQX.cjs');
|
|
4
4
|
var chunkYTLE5K7G_cjs = require('./chunk-YTLE5K7G.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk7NTUEHQV_cjs = require('./chunk-7NTUEHQV.cjs');
|
|
6
6
|
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
7
7
|
|
|
8
8
|
// src/input.ts
|
|
@@ -19,7 +19,7 @@ function checkCNICInput(value) {
|
|
|
19
19
|
if (!/^\d+$/.test(text) || text.length > 13) return "invalid";
|
|
20
20
|
if (!/^[1-8]/.test(text)) return "invalid";
|
|
21
21
|
if (text.length < 13) return "incomplete";
|
|
22
|
-
return
|
|
22
|
+
return chunk7NTUEHQV_cjs.validateCNIC(text) ? "valid" : "invalid";
|
|
23
23
|
}
|
|
24
24
|
function splitPhone(value) {
|
|
25
25
|
const text = chunkVPBMIYO2_cjs.toAsciiDigits(value).replace(SEPARATORS, "");
|
|
@@ -311,11 +311,95 @@ function wrapBidi(text, direction = "auto") {
|
|
|
311
311
|
const open = direction === "rtl" ? "\u2067" : direction === "ltr" ? "\u2066" : "\u2068";
|
|
312
312
|
return `${open}${text}\u2069`;
|
|
313
313
|
}
|
|
314
|
+
var KEY_DIGRAPHS = {
|
|
315
|
+
kh: "kh",
|
|
316
|
+
gh: "g",
|
|
317
|
+
sh: "sh",
|
|
318
|
+
ch: "ch",
|
|
319
|
+
ph: "f",
|
|
320
|
+
th: "t",
|
|
321
|
+
dh: "d",
|
|
322
|
+
bh: "b",
|
|
323
|
+
jh: "j",
|
|
324
|
+
zh: "z",
|
|
325
|
+
ck: "k"
|
|
326
|
+
};
|
|
327
|
+
var KEY_LETTERS = {
|
|
328
|
+
c: "k",
|
|
329
|
+
q: "k",
|
|
330
|
+
v: "w",
|
|
331
|
+
x: "ks"
|
|
332
|
+
};
|
|
333
|
+
var PLAIN_VOWELS = "aeiou";
|
|
334
|
+
function vowelClass(letter) {
|
|
335
|
+
if (letter === "a" || letter === "e") return "a";
|
|
336
|
+
if (letter === "i" || letter === "y") return "i";
|
|
337
|
+
return "u";
|
|
338
|
+
}
|
|
339
|
+
function firstVowelClass(run, wordStart) {
|
|
340
|
+
if (run.startsWith("ee")) return "i";
|
|
341
|
+
if (wordStart && run.startsWith("e")) return "i";
|
|
342
|
+
if (/^[ao][uw]/.test(run)) return "u";
|
|
343
|
+
if (/^(a[iye]|e[iy])/.test(run)) return "e";
|
|
344
|
+
return vowelClass(run[0]);
|
|
345
|
+
}
|
|
346
|
+
function wordKey(word) {
|
|
347
|
+
let letters = "";
|
|
348
|
+
for (let i = 0; i < word.length; ) {
|
|
349
|
+
const pair = KEY_DIGRAPHS[word.slice(i, i + 2)];
|
|
350
|
+
if (pair !== void 0) {
|
|
351
|
+
letters += pair;
|
|
352
|
+
i += 2;
|
|
353
|
+
} else {
|
|
354
|
+
const letter = word[i];
|
|
355
|
+
letters += KEY_LETTERS[letter] ?? letter;
|
|
356
|
+
i += 1;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
letters = letters.replace(/([^e])\1+/g, "$1");
|
|
360
|
+
const vowel = [];
|
|
361
|
+
for (let i = 0; i < letters.length; i += 1) {
|
|
362
|
+
const letter = letters[i];
|
|
363
|
+
vowel.push(
|
|
364
|
+
PLAIN_VOWELS.includes(letter) || letter === "y" && i > 0 || letter === "w" && i > 0 && vowel[i - 1] === true && !PLAIN_VOWELS.includes(letters[i + 1] ?? "")
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
const last = letters.length - 1;
|
|
368
|
+
if (last > 0 && letters[last] === "h" && vowel[last - 1] === true) {
|
|
369
|
+
letters = letters.slice(0, last);
|
|
370
|
+
vowel.pop();
|
|
371
|
+
}
|
|
372
|
+
let key = "";
|
|
373
|
+
let firstVowelDone = false;
|
|
374
|
+
for (let i = 0; i < letters.length; ) {
|
|
375
|
+
if (!vowel[i]) {
|
|
376
|
+
key += letters[i];
|
|
377
|
+
i += 1;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
let end = i;
|
|
381
|
+
while (end < letters.length && vowel[end]) end += 1;
|
|
382
|
+
const run = letters.slice(i, end);
|
|
383
|
+
if (!firstVowelDone) {
|
|
384
|
+
key += firstVowelClass(run, i === 0);
|
|
385
|
+
firstVowelDone = true;
|
|
386
|
+
} else if (end === letters.length) {
|
|
387
|
+
key += run.endsWith("ee") ? "i" : vowelClass(run[run.length - 1]);
|
|
388
|
+
}
|
|
389
|
+
i = end;
|
|
390
|
+
}
|
|
391
|
+
return key;
|
|
392
|
+
}
|
|
393
|
+
function romanUrduKey(text) {
|
|
394
|
+
if (typeof text !== "string") return "";
|
|
395
|
+
return text.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").split(/[^a-z]+/).filter((word) => word !== "").map(wordKey).join(" ");
|
|
396
|
+
}
|
|
314
397
|
|
|
315
398
|
exports.compareUrdu = compareUrdu;
|
|
316
399
|
exports.isRTL = isRTL;
|
|
317
400
|
exports.normalizeRomanUrdu = normalizeRomanUrdu;
|
|
318
401
|
exports.normalizeText = normalizeText;
|
|
402
|
+
exports.romanUrduKey = romanUrduKey;
|
|
319
403
|
exports.slugify = slugify;
|
|
320
404
|
exports.toEnglishDigits = toEnglishDigits;
|
|
321
405
|
exports.toUrduDigits = toUrduDigits;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/format.ts
|
|
2
|
+
var LAKH = 1e5;
|
|
3
|
+
var CRORE = 1e7;
|
|
4
|
+
var pkrFormatter = new Intl.NumberFormat("en-PK", {
|
|
5
|
+
maximumFractionDigits: 0
|
|
6
|
+
});
|
|
7
|
+
function assertFinite(amount) {
|
|
8
|
+
if (typeof amount !== "number" || !Number.isFinite(amount)) {
|
|
9
|
+
throw new RangeError(
|
|
10
|
+
`Amount must be a finite number, received ${String(amount)}`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function roundTo2(value) {
|
|
15
|
+
return Math.round(value * 100) / 100;
|
|
16
|
+
}
|
|
17
|
+
function formatPKR(amount) {
|
|
18
|
+
assertFinite(amount);
|
|
19
|
+
const rounded = Math.round(Math.abs(amount));
|
|
20
|
+
const sign = amount < 0 && rounded !== 0 ? "-" : "";
|
|
21
|
+
return `${sign}Rs. ${pkrFormatter.format(rounded)}`;
|
|
22
|
+
}
|
|
23
|
+
function formatLakh(amount) {
|
|
24
|
+
assertFinite(amount);
|
|
25
|
+
const sign = amount < 0 ? "-" : "";
|
|
26
|
+
const absolute = Math.abs(amount);
|
|
27
|
+
const crores = roundTo2(absolute / CRORE);
|
|
28
|
+
if (crores >= 1) {
|
|
29
|
+
return `${sign}${crores} Crore`;
|
|
30
|
+
}
|
|
31
|
+
const lakhs = roundTo2(absolute / LAKH);
|
|
32
|
+
if (lakhs >= 1) {
|
|
33
|
+
return `${sign}${lakhs} Lakh`;
|
|
34
|
+
}
|
|
35
|
+
return formatPKR(amount);
|
|
36
|
+
}
|
|
37
|
+
var SPACE = /[ \t\n\r\u00A0\u202F]/.source;
|
|
38
|
+
var TRIM = new RegExp(`^${SPACE}+|${SPACE}+$`, "g");
|
|
39
|
+
var CURRENCY = /(rs\.?|pkr|\u20A8)/.source;
|
|
40
|
+
var NUMBER = /(\d{1,3}(?:,\d{3})+|\d{1,2}(?:,\d{2})+,\d{3}|\d+)?(?:\.(\d*))?/.source;
|
|
41
|
+
var THOUSAND = /k|thousands?|hazar|\u06C1\u0632\u0627\u0631/.source;
|
|
42
|
+
var LAKH_UNIT = /lakhs?|lacs?|\u0644\u0627\u06A9\u06BE/.source;
|
|
43
|
+
var CRORE_UNIT = /crores?|cr|\u06A9\u0631\u0648\u0691/.source;
|
|
44
|
+
var AMOUNT = new RegExp(
|
|
45
|
+
`^(?:${CURRENCY}${SPACE}*)?${NUMBER}(?:${SPACE}*(${THOUSAND}|${LAKH_UNIT}|${CRORE_UNIT}))?(?:${SPACE}*${CURRENCY})?(?:${SPACE}*(\\/-))?$`
|
|
46
|
+
);
|
|
47
|
+
function unitExponent(unit) {
|
|
48
|
+
if (unit === void 0) return 0;
|
|
49
|
+
if (new RegExp(`^(?:${THOUSAND})$`).test(unit)) return 3;
|
|
50
|
+
if (new RegExp(`^(?:${LAKH_UNIT})$`).test(unit)) return 5;
|
|
51
|
+
return 7;
|
|
52
|
+
}
|
|
53
|
+
var MAX_PAISA = 5000000000000000n;
|
|
54
|
+
function parseAmount(input) {
|
|
55
|
+
if (typeof input !== "string") return null;
|
|
56
|
+
const raw = input.replace(TRIM, "");
|
|
57
|
+
const text = raw.replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 1776)).replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 1632)).replace(/\u066B/g, ".").replace(/\u066C/g, ",").replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
58
|
+
const match = AMOUNT.exec(text);
|
|
59
|
+
if (!match) return null;
|
|
60
|
+
const [, before, whole = "", fraction, unit, after] = match;
|
|
61
|
+
if (before !== void 0 && after !== void 0) return null;
|
|
62
|
+
if (whole === "" && (fraction === void 0 || fraction === "")) return null;
|
|
63
|
+
const digits = whole.replace(/,/g, "") + (fraction ?? "");
|
|
64
|
+
const point = whole.replace(/,/g, "").length + unitExponent(unit);
|
|
65
|
+
const padded = digits.padEnd(point + 3, "0");
|
|
66
|
+
const rupees = padded.slice(0, point) || "0";
|
|
67
|
+
const paisa = padded.slice(point, point + 2);
|
|
68
|
+
let cents = BigInt(rupees + paisa);
|
|
69
|
+
if (padded.charCodeAt(point + 2) >= 53) cents += 1n;
|
|
70
|
+
if (cents > MAX_PAISA) return null;
|
|
71
|
+
return { value: Number(cents) / 100, raw };
|
|
72
|
+
}
|
|
73
|
+
function formatAmountInput(input) {
|
|
74
|
+
const parsed = parseAmount(input);
|
|
75
|
+
if (parsed === null) return null;
|
|
76
|
+
const cents = Math.round(parsed.value * 100);
|
|
77
|
+
const rupees = String(Math.floor(cents / 100)).replace(
|
|
78
|
+
/\B(?=(\d{3})+(?!\d))/g,
|
|
79
|
+
","
|
|
80
|
+
);
|
|
81
|
+
const paisa = cents % 100;
|
|
82
|
+
return `Rs. ${rupees}${paisa ? `.${String(paisa).padStart(2, "0")}` : ""}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { formatAmountInput, formatLakh, formatPKR, parseAmount };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/format.ts
|
|
4
|
+
var LAKH = 1e5;
|
|
5
|
+
var CRORE = 1e7;
|
|
6
|
+
var pkrFormatter = new Intl.NumberFormat("en-PK", {
|
|
7
|
+
maximumFractionDigits: 0
|
|
8
|
+
});
|
|
9
|
+
function assertFinite(amount) {
|
|
10
|
+
if (typeof amount !== "number" || !Number.isFinite(amount)) {
|
|
11
|
+
throw new RangeError(
|
|
12
|
+
`Amount must be a finite number, received ${String(amount)}`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function roundTo2(value) {
|
|
17
|
+
return Math.round(value * 100) / 100;
|
|
18
|
+
}
|
|
19
|
+
function formatPKR(amount) {
|
|
20
|
+
assertFinite(amount);
|
|
21
|
+
const rounded = Math.round(Math.abs(amount));
|
|
22
|
+
const sign = amount < 0 && rounded !== 0 ? "-" : "";
|
|
23
|
+
return `${sign}Rs. ${pkrFormatter.format(rounded)}`;
|
|
24
|
+
}
|
|
25
|
+
function formatLakh(amount) {
|
|
26
|
+
assertFinite(amount);
|
|
27
|
+
const sign = amount < 0 ? "-" : "";
|
|
28
|
+
const absolute = Math.abs(amount);
|
|
29
|
+
const crores = roundTo2(absolute / CRORE);
|
|
30
|
+
if (crores >= 1) {
|
|
31
|
+
return `${sign}${crores} Crore`;
|
|
32
|
+
}
|
|
33
|
+
const lakhs = roundTo2(absolute / LAKH);
|
|
34
|
+
if (lakhs >= 1) {
|
|
35
|
+
return `${sign}${lakhs} Lakh`;
|
|
36
|
+
}
|
|
37
|
+
return formatPKR(amount);
|
|
38
|
+
}
|
|
39
|
+
var SPACE = /[ \t\n\r\u00A0\u202F]/.source;
|
|
40
|
+
var TRIM = new RegExp(`^${SPACE}+|${SPACE}+$`, "g");
|
|
41
|
+
var CURRENCY = /(rs\.?|pkr|\u20A8)/.source;
|
|
42
|
+
var NUMBER = /(\d{1,3}(?:,\d{3})+|\d{1,2}(?:,\d{2})+,\d{3}|\d+)?(?:\.(\d*))?/.source;
|
|
43
|
+
var THOUSAND = /k|thousands?|hazar|\u06C1\u0632\u0627\u0631/.source;
|
|
44
|
+
var LAKH_UNIT = /lakhs?|lacs?|\u0644\u0627\u06A9\u06BE/.source;
|
|
45
|
+
var CRORE_UNIT = /crores?|cr|\u06A9\u0631\u0648\u0691/.source;
|
|
46
|
+
var AMOUNT = new RegExp(
|
|
47
|
+
`^(?:${CURRENCY}${SPACE}*)?${NUMBER}(?:${SPACE}*(${THOUSAND}|${LAKH_UNIT}|${CRORE_UNIT}))?(?:${SPACE}*${CURRENCY})?(?:${SPACE}*(\\/-))?$`
|
|
48
|
+
);
|
|
49
|
+
function unitExponent(unit) {
|
|
50
|
+
if (unit === void 0) return 0;
|
|
51
|
+
if (new RegExp(`^(?:${THOUSAND})$`).test(unit)) return 3;
|
|
52
|
+
if (new RegExp(`^(?:${LAKH_UNIT})$`).test(unit)) return 5;
|
|
53
|
+
return 7;
|
|
54
|
+
}
|
|
55
|
+
var MAX_PAISA = 5000000000000000n;
|
|
56
|
+
function parseAmount(input) {
|
|
57
|
+
if (typeof input !== "string") return null;
|
|
58
|
+
const raw = input.replace(TRIM, "");
|
|
59
|
+
const text = raw.replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 1776)).replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 1632)).replace(/\u066B/g, ".").replace(/\u066C/g, ",").replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
60
|
+
const match = AMOUNT.exec(text);
|
|
61
|
+
if (!match) return null;
|
|
62
|
+
const [, before, whole = "", fraction, unit, after] = match;
|
|
63
|
+
if (before !== void 0 && after !== void 0) return null;
|
|
64
|
+
if (whole === "" && (fraction === void 0 || fraction === "")) return null;
|
|
65
|
+
const digits = whole.replace(/,/g, "") + (fraction ?? "");
|
|
66
|
+
const point = whole.replace(/,/g, "").length + unitExponent(unit);
|
|
67
|
+
const padded = digits.padEnd(point + 3, "0");
|
|
68
|
+
const rupees = padded.slice(0, point) || "0";
|
|
69
|
+
const paisa = padded.slice(point, point + 2);
|
|
70
|
+
let cents = BigInt(rupees + paisa);
|
|
71
|
+
if (padded.charCodeAt(point + 2) >= 53) cents += 1n;
|
|
72
|
+
if (cents > MAX_PAISA) return null;
|
|
73
|
+
return { value: Number(cents) / 100, raw };
|
|
74
|
+
}
|
|
75
|
+
function formatAmountInput(input) {
|
|
76
|
+
const parsed = parseAmount(input);
|
|
77
|
+
if (parsed === null) return null;
|
|
78
|
+
const cents = Math.round(parsed.value * 100);
|
|
79
|
+
const rupees = String(Math.floor(cents / 100)).replace(
|
|
80
|
+
/\B(?=(\d{3})+(?!\d))/g,
|
|
81
|
+
","
|
|
82
|
+
);
|
|
83
|
+
const paisa = cents % 100;
|
|
84
|
+
return `Rs. ${rupees}${paisa ? `.${String(paisa).padStart(2, "0")}` : ""}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports.formatAmountInput = formatAmountInput;
|
|
88
|
+
exports.formatLakh = formatLakh;
|
|
89
|
+
exports.formatPKR = formatPKR;
|
|
90
|
+
exports.parseAmount = parseAmount;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { validatePhone } from './chunk-S274QFFB.js';
|
|
2
|
-
import { phoneRiskSignals } from './chunk-
|
|
3
|
-
import { validateSTRN, validateNTN } from './chunk-
|
|
2
|
+
import { phoneRiskSignals } from './chunk-T6K46DGW.js';
|
|
3
|
+
import { validateSTRN, validateNTN } from './chunk-3OCMTNQ7.js';
|
|
4
4
|
import { validateVehiclePlate } from './chunk-RZQJAZKC.js';
|
|
5
5
|
import { validateIBAN } from './chunk-IBZPJS4H.js';
|
|
6
|
-
import { validateLandline } from './chunk-
|
|
6
|
+
import { validateLandline } from './chunk-33JPVN33.js';
|
|
7
7
|
import { validatePassport } from './chunk-E6HSKRAE.js';
|
|
8
|
-
import { validateCNIC } from './chunk-
|
|
8
|
+
import { validateCNIC } from './chunk-CKCOK6X4.js';
|
|
9
|
+
import { parseAmount } from './chunk-NDW52ZK3.js';
|
|
9
10
|
|
|
10
11
|
// src/adapters/rules.ts
|
|
11
12
|
var RULES = {
|
|
@@ -15,7 +16,7 @@ var RULES = {
|
|
|
15
16
|
ntn: { test: validateNTN, message: "Invalid NTN" },
|
|
16
17
|
strn: { test: validateSTRN, message: "Invalid STRN" },
|
|
17
18
|
landline: {
|
|
18
|
-
test: validateLandline,
|
|
19
|
+
test: (value, options) => validateLandline(value, { services: options.services === true }),
|
|
19
20
|
message: "Invalid Pakistani landline number"
|
|
20
21
|
},
|
|
21
22
|
passport: {
|
|
@@ -29,6 +30,10 @@ var RULES = {
|
|
|
29
30
|
codPhone: {
|
|
30
31
|
test: (value) => phoneRiskSignals(value).length === 0,
|
|
31
32
|
message: "Enter a mobile number a courier can call"
|
|
33
|
+
},
|
|
34
|
+
amount: {
|
|
35
|
+
test: (value) => parseAmount(value) !== null,
|
|
36
|
+
message: "Enter an amount in rupees, like 150,000 or 1.5 lakh"
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
|
|
@@ -81,7 +81,8 @@ var income_tax_slabs_default = [
|
|
|
81
81
|
fixed: 2142e4,
|
|
82
82
|
rate: 35
|
|
83
83
|
}
|
|
84
|
-
]
|
|
84
|
+
],
|
|
85
|
+
surcharge: null
|
|
85
86
|
},
|
|
86
87
|
{
|
|
87
88
|
taxYear: 2021,
|
|
@@ -162,7 +163,8 @@ var income_tax_slabs_default = [
|
|
|
162
163
|
fixed: 2142e4,
|
|
163
164
|
rate: 35
|
|
164
165
|
}
|
|
165
|
-
]
|
|
166
|
+
],
|
|
167
|
+
surcharge: null
|
|
166
168
|
},
|
|
167
169
|
{
|
|
168
170
|
taxYear: 2022,
|
|
@@ -243,7 +245,8 @@ var income_tax_slabs_default = [
|
|
|
243
245
|
fixed: 2142e4,
|
|
244
246
|
rate: 35
|
|
245
247
|
}
|
|
246
|
-
]
|
|
248
|
+
],
|
|
249
|
+
surcharge: null
|
|
247
250
|
},
|
|
248
251
|
{
|
|
249
252
|
taxYear: 2023,
|
|
@@ -294,7 +297,8 @@ var income_tax_slabs_default = [
|
|
|
294
297
|
fixed: 2955e3,
|
|
295
298
|
rate: 35
|
|
296
299
|
}
|
|
297
|
-
]
|
|
300
|
+
],
|
|
301
|
+
surcharge: null
|
|
298
302
|
},
|
|
299
303
|
{
|
|
300
304
|
taxYear: 2024,
|
|
@@ -339,7 +343,8 @@ var income_tax_slabs_default = [
|
|
|
339
343
|
fixed: 1095e3,
|
|
340
344
|
rate: 35
|
|
341
345
|
}
|
|
342
|
-
]
|
|
346
|
+
],
|
|
347
|
+
surcharge: null
|
|
343
348
|
},
|
|
344
349
|
{
|
|
345
350
|
taxYear: 2025,
|
|
@@ -384,7 +389,13 @@ var income_tax_slabs_default = [
|
|
|
384
389
|
fixed: 7e5,
|
|
385
390
|
rate: 35
|
|
386
391
|
}
|
|
387
|
-
]
|
|
392
|
+
],
|
|
393
|
+
surcharge: {
|
|
394
|
+
rate: 10,
|
|
395
|
+
over: 1e7,
|
|
396
|
+
law: "Income Tax Ordinance 2001, s. 4AB, inserted by the Finance Act 2024, s. 8(2): 10% of the tax under Division I where taxable income exceeds Rs 10 million",
|
|
397
|
+
source: "https://download1.fbr.gov.pk/Docs/2024630146346801FinanceAct-2024.pdf"
|
|
398
|
+
}
|
|
388
399
|
},
|
|
389
400
|
{
|
|
390
401
|
taxYear: 2026,
|
|
@@ -429,7 +440,13 @@ var income_tax_slabs_default = [
|
|
|
429
440
|
fixed: 616e3,
|
|
430
441
|
rate: 35
|
|
431
442
|
}
|
|
432
|
-
]
|
|
443
|
+
],
|
|
444
|
+
surcharge: {
|
|
445
|
+
rate: 9,
|
|
446
|
+
over: 1e7,
|
|
447
|
+
law: "Income Tax Ordinance 2001, s. 4AB, proviso added by the Finance Act 2025: 9% for an individual with income under the head Salary, where taxable income exceeds Rs 10 million",
|
|
448
|
+
source: "https://download1.fbr.gov.pk/Docs/2025881983148210Income-Tax-Ordinance,-2001-Amended-upto-31.07.2025.pdf"
|
|
449
|
+
}
|
|
433
450
|
},
|
|
434
451
|
{
|
|
435
452
|
taxYear: 2027,
|
|
@@ -486,7 +503,13 @@ var income_tax_slabs_default = [
|
|
|
486
503
|
fixed: 1424e3,
|
|
487
504
|
rate: 35
|
|
488
505
|
}
|
|
489
|
-
]
|
|
506
|
+
],
|
|
507
|
+
surcharge: {
|
|
508
|
+
rate: 0,
|
|
509
|
+
over: 1e7,
|
|
510
|
+
law: "Income Tax Ordinance 2001, s. 4AB, proviso substituted by the Finance Act 2026, s. 5(2)(b): no surcharge for an individual with income under the head Salary",
|
|
511
|
+
source: "https://download1.fbr.gov.pk/Docs/20266291261044366FinanceAct2026.pdf"
|
|
512
|
+
}
|
|
490
513
|
}
|
|
491
514
|
];
|
|
492
515
|
|
|
@@ -517,7 +540,8 @@ function findYear(options) {
|
|
|
517
540
|
}
|
|
518
541
|
var copyYear = (year) => ({
|
|
519
542
|
...year,
|
|
520
|
-
slabs: year.slabs.map((slab) => ({ ...slab }))
|
|
543
|
+
slabs: year.slabs.map((slab) => ({ ...slab })),
|
|
544
|
+
surcharge: year.surcharge === null ? null : { ...year.surcharge }
|
|
521
545
|
});
|
|
522
546
|
function getSalaryTaxSlabs(taxYear) {
|
|
523
547
|
const year = findYear(taxYear === void 0 ? void 0 : { taxYear });
|
|
@@ -526,7 +550,7 @@ function getSalaryTaxSlabs(taxYear) {
|
|
|
526
550
|
function getSalaryTaxYears() {
|
|
527
551
|
return YEARS.map((y) => y.taxYear);
|
|
528
552
|
}
|
|
529
|
-
function compute(incomePaisa, year) {
|
|
553
|
+
function compute(incomePaisa, year, includeSurcharge) {
|
|
530
554
|
const slabs = year.slabs;
|
|
531
555
|
let slab = slabs[0];
|
|
532
556
|
for (const candidate of slabs) {
|
|
@@ -535,10 +559,18 @@ function compute(incomePaisa, year) {
|
|
|
535
559
|
const rateBp = Math.round(slab.rate * 100);
|
|
536
560
|
const above = BigInt(incomePaisa - slab.over * 100);
|
|
537
561
|
const taxPaisa = incomePaisa > slab.over * 100 ? slab.fixed * 100 + divideHalfUp(above * BigInt(rateBp), 10000n) : slab.fixed * 100;
|
|
562
|
+
const surcharge = year.surcharge;
|
|
563
|
+
const surchargePaisa = includeSurcharge && surcharge !== null && surcharge.rate > 0 && incomePaisa > surcharge.over * 100 ? divideHalfUp(
|
|
564
|
+
BigInt(taxPaisa) * BigInt(Math.round(surcharge.rate * 100)),
|
|
565
|
+
10000n
|
|
566
|
+
) : 0;
|
|
567
|
+
const totalPaisa = taxPaisa + surchargePaisa;
|
|
538
568
|
return {
|
|
539
569
|
tax: fromPaisa(taxPaisa),
|
|
540
|
-
|
|
541
|
-
|
|
570
|
+
surcharge: fromPaisa(surchargePaisa),
|
|
571
|
+
total: fromPaisa(totalPaisa),
|
|
572
|
+
monthly: fromPaisa(divideHalfUp(BigInt(totalPaisa), 12n)),
|
|
573
|
+
effectiveRate: incomePaisa === 0 ? 0 : divideHalfUp(BigInt(totalPaisa) * 10000n, BigInt(incomePaisa)) / 100,
|
|
542
574
|
slab: { ...slab },
|
|
543
575
|
taxYear: year.taxYear
|
|
544
576
|
};
|
|
@@ -547,13 +579,13 @@ function calculateSalaryTax(annualIncome, options) {
|
|
|
547
579
|
const paisa = toUnits(annualIncome, 2);
|
|
548
580
|
if (paisa === null) return null;
|
|
549
581
|
const year = findYear(options);
|
|
550
|
-
return year ? compute(paisa, year) : null;
|
|
582
|
+
return year ? compute(paisa, year, options?.includeSurcharge === true) : null;
|
|
551
583
|
}
|
|
552
584
|
function calculateMonthlySalaryTax(monthlySalary, options) {
|
|
553
585
|
const paisa = toUnits(monthlySalary, 2);
|
|
554
586
|
if (paisa === null) return null;
|
|
555
587
|
const year = findYear(options);
|
|
556
|
-
return year ? compute(paisa * 12, year) : null;
|
|
588
|
+
return year ? compute(paisa * 12, year, options?.includeSurcharge === true) : null;
|
|
557
589
|
}
|
|
558
590
|
|
|
559
591
|
export { calculateMonthlySalaryTax, calculateSalaryTax, getSalaryTaxSlabs, getSalaryTaxYears, getTaxYear };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { analyzeNumber } from './chunk-
|
|
1
|
+
import { analyzeNumber } from './chunk-33JPVN33.js';
|
|
2
2
|
import { parseAddress } from './chunk-B7DOQ5QF.js';
|
|
3
3
|
import { getPostOffice } from './chunk-33QMFE2Z.js';
|
|
4
4
|
import { normalizeWhitespace, toAsciiDigits } from './chunk-ENQ7O7VW.js';
|
|
@@ -471,9 +471,8 @@ var area_codes_default = [
|
|
|
471
471
|
var FIXED_LINE = /^(?:(?:(?:21|42)[2-9]|58[126])\d{7}|(?:2[25]|4[0146-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]\d{6,7}|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8]))[2-9]\d{5,6})$/;
|
|
472
472
|
var UAN = /^((?:2(?:[125]|3[2358]|4[2-4]|9[2-8])|4(?:[0-246-9]|5[3479])|5(?:[1-35-7]|4[2-467])|6(?:0[468]|[1-8])|7(?:[14]|2[236])|8(?:[16]|2[2-689]|3[23578]|4[3478]|5[2356])|9(?:1|22|3[27-9]|4[2-6]|6[3569]|9[2-7])))111(\d{6})$/;
|
|
473
473
|
var UAN_WITHOUT_AREA_CODE = /^111(\d{6})$/;
|
|
474
|
-
var TOLL_FREE = /^800(\d{5}
|
|
474
|
+
var TOLL_FREE = /^800(\d{5})$/;
|
|
475
475
|
var PREMIUM = /^900(\d{5})$/;
|
|
476
|
-
var PERSONAL = /^122(\d{6})$/;
|
|
477
476
|
var areaCodes = /* @__PURE__ */ chunkVPBMIYO2_cjs.lazy(() => area_codes_default);
|
|
478
477
|
var areaCodeMap = /* @__PURE__ */ chunkVPBMIYO2_cjs.lazy(
|
|
479
478
|
() => new Map(areaCodes().map((entry) => [entry.code, entry.cities]))
|
|
@@ -545,8 +544,6 @@ function analyzeNumber(phone) {
|
|
|
545
544
|
if (tollFree) return service("toll-free", "800", tollFree[1]);
|
|
546
545
|
const premium = PREMIUM.exec(national);
|
|
547
546
|
if (premium) return service("premium", "900", premium[1]);
|
|
548
|
-
const personal = PERSONAL.exec(national);
|
|
549
|
-
if (personal) return service("personal", "122", personal[1]);
|
|
550
547
|
const uan = UAN.exec(national);
|
|
551
548
|
if (uan) {
|
|
552
549
|
const code = uan[1];
|
|
@@ -573,8 +570,16 @@ function analyzeNumber(phone) {
|
|
|
573
570
|
function getNumberType(phone) {
|
|
574
571
|
return analyzeNumber(phone)?.type ?? null;
|
|
575
572
|
}
|
|
576
|
-
|
|
577
|
-
|
|
573
|
+
var SERVICE_TYPES = /* @__PURE__ */ new Set([
|
|
574
|
+
"uan",
|
|
575
|
+
"toll-free",
|
|
576
|
+
"premium"
|
|
577
|
+
]);
|
|
578
|
+
function validateLandline(phone, options = {}) {
|
|
579
|
+
if (typeof phone !== "string") return false;
|
|
580
|
+
const type = getNumberType(phone);
|
|
581
|
+
if (type === "landline") return true;
|
|
582
|
+
return options.services === true && type !== null && SERVICE_TYPES.has(type);
|
|
578
583
|
}
|
|
579
584
|
function getAreaCode(city) {
|
|
580
585
|
const key = chunkVPBMIYO2_cjs.normalizeKey(city);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7NTUEHQV_cjs = require('./chunk-7NTUEHQV.cjs');
|
|
4
4
|
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
5
5
|
|
|
6
6
|
// src/tax.ts
|
|
7
7
|
function analyzeNTN(ntn) {
|
|
8
8
|
const trimmed = chunkVPBMIYO2_cjs.toAsciiDigits(ntn.trim());
|
|
9
|
-
if (
|
|
9
|
+
if (chunk7NTUEHQV_cjs.validateCNIC(trimmed)) {
|
|
10
10
|
const digits = chunkVPBMIYO2_cjs.stripSeparators(trimmed);
|
|
11
11
|
return {
|
|
12
12
|
type: "individual",
|