@desource/phone-mask 0.3.0 → 1.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 (46) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +3 -1
  3. package/dist/country-code-emodji.d.ts +7 -0
  4. package/dist/country-code-emodji.d.ts.map +1 -0
  5. package/dist/data-types.d.ts +2 -0
  6. package/dist/data-types.d.ts.map +1 -0
  7. package/dist/entries.d.ts +81 -0
  8. package/dist/entries.d.ts.map +1 -0
  9. package/dist/esm/entries.js +1 -1
  10. package/dist/esm/formatter.js +1 -0
  11. package/dist/esm/handlers.js +1 -0
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/services/geoip/utils.js +1 -1
  14. package/dist/esm/utils.js +1 -1
  15. package/dist/formatter.d.ts +36 -0
  16. package/dist/formatter.d.ts.map +1 -0
  17. package/dist/handlers.d.ts +63 -0
  18. package/dist/handlers.d.ts.map +1 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/{phone-mask.cjs.js → phone-mask.cjs} +1 -1
  22. package/dist/phone-mask.umd.min.js +1 -1
  23. package/dist/services/geoip/consts.d.ts +5 -0
  24. package/dist/services/geoip/consts.d.ts.map +1 -0
  25. package/dist/services/geoip/index.d.ts +4 -0
  26. package/dist/services/geoip/index.d.ts.map +1 -0
  27. package/dist/services/geoip/types.d.ts +5 -0
  28. package/dist/services/geoip/types.d.ts.map +1 -0
  29. package/dist/services/geoip/utils.d.ts +7 -0
  30. package/dist/services/geoip/utils.d.ts.map +1 -0
  31. package/dist/services/index.d.ts +2 -0
  32. package/dist/services/index.d.ts.map +1 -0
  33. package/dist/types/entries.d.ts.map +1 -1
  34. package/dist/types/formatter.d.ts +36 -0
  35. package/dist/types/formatter.d.ts.map +1 -0
  36. package/dist/types/handlers.d.ts +63 -0
  37. package/dist/types/handlers.d.ts.map +1 -0
  38. package/dist/types/index.d.ts +2 -0
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/services/geoip/utils.d.ts +1 -1
  41. package/dist/types/services/geoip/utils.d.ts.map +1 -1
  42. package/dist/types/utils.d.ts +8 -3
  43. package/dist/types/utils.d.ts.map +1 -1
  44. package/dist/utils.d.ts +27 -0
  45. package/dist/utils.d.ts.map +1 -0
  46. package/package.json +17 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @desource/phone-mask
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Svelte Upgrades:
8
+ - Added attachment `phoneMaskAttachment` for usage in native input (for Svelte 5.29+ versions)
9
+ - Added action `phoneMaskAction` for usage in native input (for Svelte 5.0+ versions)
10
+ - Improved keyboard country selection flow and active-descendant accessibility behavior
11
+ - Refined dropdown/key navigation handling and related focus behavior
12
+ - `usePhoneMask` now exposes `formatter` in the return object
13
+
14
+ - Vue Upgrades:
15
+ - Directive was refactored to align with Svelte action
16
+ - Improved keyboard country selection flow and active-descendant accessibility behavior
17
+ - Refined dropdown/key navigation handling and related focus behavior
18
+ - `usePhoneMask` now exposes `formatter` in the return object
19
+
20
+ - React Upgrades:
21
+ - Improved keyboard country selection flow and active-descendant accessibility behavior
22
+ - Refined dropdown/key navigation handling and related focus behavior
23
+ - `usePhoneMask` now exposes `formatter` in the return object
24
+
25
+ - Core Upgrades:
26
+ - Fixed edge cases in mask variant selection and improved input handler robustness
27
+ - Applied reliability-focused refactors in formatter/handlers and build script generation logic
28
+
29
+ ## 1.0.0
30
+
31
+ ### Major Changes
32
+
33
+ - Core Upgrades:
34
+ - Refactored core architecture for better separation of concerns and reusability
35
+ - Added zero-config browser script support path
36
+ - Improved Intl.DisplayNames caching for performance
37
+ - Fixed various edge cases in formatting and event handling
38
+ - Added comprehensive unit tests for core utilities and handlers
39
+
40
+ - React Upgrades:
41
+ - Major internal refactor to a controlled pattern with consistent hooks
42
+ - Improved React 18/19 compatibility for ref behavior
43
+ - Added and expanded unit/e2e tests for React components and behavior
44
+
45
+ - Vue Upgrades:
46
+ - Refactored to align composable structure and reuse core utilities
47
+ - Fixed directive behavior for external value updates and dropdown close logic
48
+ - Added substantial unit/e2e test coverage for Vue composables and directive
49
+
50
+ - 🚀 Svelte Upgrades:
51
+ - Introduced Svelte version of phone-mask library
52
+
53
+ - Nuxt Upgrades:
54
+ - Added full test foundation with @nuxt/test-utils
55
+ - Added unit tests for module and runtime behavior
56
+ - Added e2e fixtures/tests and shared e2e utilities
57
+
3
58
  ## 0.3.0
4
59
 
5
60
  ### Minor Changes
package/README.md CHANGED
@@ -333,8 +333,10 @@ All exports are tree-shakeable — only import what you use!
333
333
 
334
334
  ## 🔗 Related Packages
335
335
 
336
- - [@desource/phone-mask-vue](../phone-mask-vue) — Vue 3 component + directive
336
+ - [@desource/phone-mask-vue](../phone-mask-vue) — Vue 3 component + composable + directive
337
337
  - [@desource/phone-mask-nuxt](../phone-mask-nuxt) — Nuxt module
338
+ - [@desource/phone-mask-react](../phone-mask-react) — React component + hook
339
+ - [@desource/phone-mask-svelte](../phone-mask-svelte) — Svelte component + composable + action + attachment
338
340
 
339
341
  ## 📄 License
340
342
 
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert country code to corresponding flag emoji
3
+ * @param {string} cc - country code string
4
+ * @returns {string} flag emoji
5
+ */
6
+ export declare const countryCodeEmoji: (cc: string) => string;
7
+ //# sourceMappingURL=country-code-emodji.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country-code-emodji.d.ts","sourceRoot":"","sources":["../src/country-code-emodji.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,MAU7C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type CountryKey = 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
2
+ //# sourceMappingURL=data-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { CountryKey } from './data-types';
2
+ interface MaskBase {
3
+ id: CountryKey;
4
+ mask: string | Array<string>;
5
+ }
6
+ interface Mask extends MaskBase {
7
+ code: string;
8
+ }
9
+ interface MaskWithFlag extends Mask {
10
+ flag: string;
11
+ }
12
+ interface MaskFull extends MaskWithFlag {
13
+ name: string;
14
+ }
15
+ type MaskBaseMap = Record<CountryKey, string | Array<string>>;
16
+ type MaskMap = Record<CountryKey, Omit<Mask, 'id'>>;
17
+ type MaskWithFlagMap = Record<CountryKey, Omit<MaskWithFlag, 'id'>>;
18
+ type MaskFullMap = Record<CountryKey, Omit<MaskFull, 'id'>>;
19
+ /**
20
+ * Base masks (including country code) map
21
+ * @example
22
+ * MasksBaseMap.US // "+1 ###-###-####"
23
+ */
24
+ export declare const MasksBaseMap: MaskBaseMap;
25
+ /** Base masks (including country code) array
26
+ * @example
27
+ * MasksBase[0] // { id: 'US', mask: "+1 ###-###-####" }
28
+ */
29
+ export declare const MasksBase: MaskBase[];
30
+ /**
31
+ * Masks map with country code as separate property
32
+ * @example
33
+ * MasksMap.US // { code: "+1", mask: "###-###-####" }
34
+ */
35
+ export declare const MasksMap: MaskMap;
36
+ /**
37
+ * Masks array with country code as separate property
38
+ * @example
39
+ * Masks[0] // { id: 'US', code: "+1", mask: "###-###-####" }
40
+ */
41
+ export declare const Masks: Mask[];
42
+ /**
43
+ * Masks map with flag emoji
44
+ * @example
45
+ * MasksWithFlagMap.US // { code: "+1", mask: "###-###-####", flag: "🇺🇸" }
46
+ */
47
+ export declare const MasksWithFlagMap: MaskWithFlagMap;
48
+ /**
49
+ * Masks array with flag emoji
50
+ * @example
51
+ * MasksWithFlag[0] // { id: 'US', code: "+1", mask: "###-###-####", flag: "🇺🇸" }
52
+ */
53
+ export declare const MasksWithFlag: MaskWithFlag[];
54
+ /**
55
+ * Full masks map with name and flag emoji. Name is localized based on provided language.
56
+ * @example
57
+ * MasksFullMap.US // { code: "+1", mask: "###-###-####", name: "United States", flag: "🇺🇸" }
58
+ */
59
+ export declare const MasksFullMap: (lang: string) => MaskFullMap;
60
+ /**
61
+ * Full masks array with name and flag emoji. Name is localized based on provided language.
62
+ * @example
63
+ * MasksFull[0] // { id: 'US', code: "+1", mask: "###-###-####", name: "United States", flag: "🇺🇸" }
64
+ */
65
+ export declare const MasksFull: (lang: string) => MaskFull[];
66
+ /**
67
+ * Full masks map with name and flag emoji in English
68
+ * @example
69
+ * MasksFullMapEn.US // { code: "+1", mask: "###-###-####", name: "United States", flag: "🇺🇸" }
70
+ */
71
+ export declare const MasksFullMapEn: MaskFullMap;
72
+ /**
73
+ * Full masks array with name and flag emoji in English
74
+ * @example
75
+ * MasksFullEn[0] // { id: 'US', code: "+1", mask: "###-###-####", name: "United States", flag: "🇺🇸" }
76
+ */
77
+ export declare const MasksFullEn: MaskFull[];
78
+ /** Get flag emoji by country ISO code */
79
+ export declare const getFlagEmoji: (cc: string) => string;
80
+ export type { CountryKey, MaskBaseMap, MaskBase, MaskMap, Mask, MaskWithFlagMap, MaskWithFlag, MaskFullMap, MaskFull };
81
+ //# sourceMappingURL=entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,QAAQ;IAChB,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;CAC9B;AACD,UAAU,IAAK,SAAQ,QAAQ;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,YAAa,SAAQ,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,QAAS,SAAQ,YAAY;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,KAAK,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,KAAK,eAAe,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACpE,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AA4C5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAAkB,CAAC;AAC9C;;;GAGG;AACH,eAAO,MAAM,SAAS,YAA4D,CAAC;AACnF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAIJ,CAAC;AAClB;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAGhB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iBAIJ,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,aAAa,gBAGxB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,gBAQxC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,eAYrC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAA6B,CAAC;AACzD;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAA0B,CAAC;AACnD,yCAAyC;AACzC,eAAO,MAAM,YAAY,wBAAmB,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
@@ -1 +1 @@
1
- import e from"./data.min.js";import{countryCodeEmoji as n}from"./country-code-emodji.js";const t=Object.entries(e),divideMask=e=>e.split(/ (.*)/s);function getCodeAndMask(e){let n="",t="";if(Array.isArray(e)){const o=[];for(const t of e){const[e,s]=divideMask(t);n||(n=e),o.push(s)}t=o}else{const[o,s]=divideMask(e);n=o,t=s}return[n,t]}const o=e,s=t.map(([e,n])=>({id:e,mask:n})),a=t.reduce((e,[n,t])=>{const[o,s]=getCodeAndMask(t);return e[n]={code:o,mask:s},e},{}),r=t.map(([e,n])=>{const[t,o]=getCodeAndMask(n);return{id:e,code:t,mask:o}}),d=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o);return e[t]={code:s,mask:a,flag:n(t)},e},{}),c=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,flag:n(e)}}),MasksFullMap=e=>{const o=new Intl.DisplayNames([e],{type:"region"});return t.reduce((e,[t,s])=>{const[a,r]=getCodeAndMask(s),d=o.of(t)??"";return e[t]={code:a,mask:r,name:d,flag:n(t)},e},{})},MasksFull=e=>{const o=new Intl.DisplayNames([e],{type:"region"});return t.map(([e,t])=>{const[s,a]=getCodeAndMask(t);return{id:e,code:s,mask:a,name:o.of(e)??"",flag:n(e)}})},m=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o),r=new Intl.DisplayNames(["en"],{type:"region"});return e[t]={code:s,mask:a,name:r.of(t)??"",flag:n(t)},e},{}),i=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,name:new Intl.DisplayNames(["en"],{type:"region"}).of(e)??"",flag:n(e)}}),g=n;export{r as Masks,s as MasksBase,o as MasksBaseMap,MasksFull,i as MasksFullEn,MasksFullMap,m as MasksFullMapEn,a as MasksMap,c as MasksWithFlag,d as MasksWithFlagMap,g as getFlagEmoji};
1
+ import e from"./data.min.js";import{countryCodeEmoji as t}from"./country-code-emodji.js";const o="en",n=new Map,getDisplayNames=e=>{const t=e.toLowerCase(),s=n.get(t);if(s)return s;const r=new Intl.DisplayNames([e],{type:"region"});if(n.size>=10)for(const e of n.keys())if(e!==o){n.delete(e);break}return n.set(t,r),r},s=Object.entries(e),divideMask=e=>e.split(/ (.*)/s);function getCodeAndMask(e){let t="",o="";if(Array.isArray(e)){const n=[];for(const o of e){const[e,s]=divideMask(o);t||(t=e),n.push(s)}o=n}else{const[n,s]=divideMask(e);t=n,o=s}return[t,o]}const r=e,a=s.map(([e,t])=>({id:e,mask:t})),d=s.reduce((e,[t,o])=>{const[n,s]=getCodeAndMask(o);return e[t]={code:n,mask:s},e},{}),c=s.map(([e,t])=>{const[o,n]=getCodeAndMask(t);return{id:e,code:o,mask:n}}),m=s.reduce((e,[o,n])=>{const[s,r]=getCodeAndMask(n);return e[o]={code:s,mask:r,flag:t(o)},e},{}),i=s.map(([e,o])=>{const[n,s]=getCodeAndMask(o);return{id:e,code:n,mask:s,flag:t(e)}}),MasksFullMap=e=>{const o=getDisplayNames(e);return s.reduce((e,[n,s])=>{const[r,a]=getCodeAndMask(s),d=o.of(n)??"";return e[n]={code:r,mask:a,name:d,flag:t(n)},e},{})},MasksFull=e=>{const o=getDisplayNames(e);return s.map(([e,n])=>{const[s,r]=getCodeAndMask(n);return{id:e,code:s,mask:r,name:o.of(e)??"",flag:t(e)}})},f=MasksFullMap(o),u=MasksFull(o),k=t;export{c as Masks,a as MasksBase,r as MasksBaseMap,MasksFull,u as MasksFullEn,MasksFullMap,f as MasksFullMapEn,d as MasksMap,i as MasksWithFlag,m as MasksWithFlagMap,k as getFlagEmoji};
@@ -0,0 +1 @@
1
+ import{countPlaceholders as t,removeCountryCodePrefix as e,formatDigitsWithMap as n,toArray as r,pickMaskVariant as a}from"./utils.js";function createPhoneFormatter(o){const i=r(o.mask),l=i.map(n=>t(e(n))),s=Math.max(...l),getMask=t=>{const n=a(i,t);return e(n)};return{formatDisplay:t=>{const e=getMask(t.length);return n(e,t).display},getMaxDigits:()=>s,getPlaceholder:()=>getMask(0),getCaretPosition:t=>{const e=Math.max(0,t);if(0===e)return 0;const r=getMask(e),{display:a}=n(r,"0".repeat(e));return a.length},getDigitRange:(t,e,r)=>{const a=getMask(t.length),{map:o}=n(a,t);let i=1/0,l=-1/0;for(let t=e;t<r&&t<o.length;t++){const e=o[t];void 0!==e&&e>=0&&(i=Math.min(i,e),l=Math.max(l,e))}return i===1/0?null:[i,l+1]},isComplete:t=>l.includes(t.length)}}export{createPhoneFormatter};
@@ -0,0 +1 @@
1
+ const e=[" ","-","(",")"],t=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],n=/[^\d\s\-()]/;function removeDigitsRange(e,t,n){return{newDigits:e.slice(0,t)+e.slice(n),caretDigitIndex:t}}function removeSelectedDigits(e,t,n,i){if(n===i)return;const r=t.getDigitRange(e,n,i);if(!r)return;const[s,g]=r;return removeDigitsRange(e,s,g)}function extractDigits(e,t){const n=e.replace(/\D/g,"");return t?n.slice(0,t):n}function getSelection(e){return e?[e.selectionStart??0,e.selectionEnd??0]:[0,0]}function setCaret(e,t){if(e)try{e.setSelectionRange(t,t)}catch{}}function processBeforeInput(e){if(!e.target)return;const t=e.target,i=e.data;"insertText"===e.inputType&&i&&(n.test(i)||" "===i&&t.value.endsWith(" "))&&e.preventDefault()}function processInput(e,t){if(!e.target)return;const n=e.target,{formatter:i}=t,r=i.getMaxDigits(),s=extractDigits(n.value,r);return{newDigits:s,caretDigitIndex:s.length}}function processKeydown(n,i){if(!n.target)return;const r=n.target,{digits:s,formatter:g}=i;if(function shouldIgnoreKeydown(e){return e.ctrlKey||e.metaKey||e.altKey||t.includes(e.key)}(n))return;const[o,c]=getSelection(r),a=r.value;return"Backspace"===n.key?(n.preventDefault(),removeSelectedDigits(s,g,o,c)??function removePreviousDigit(t,n,i,r){if(r<=0)return;let s=r-1;for(;s>=0&&e.includes(i[s]);)s--;if(s<0)return;const g=n.getDigitRange(t,s,s+1);if(!g)return;const[o]=g;return removeDigitsRange(t,o,o+1)}(s,g,a,o)):"Delete"===n.key?(n.preventDefault(),removeSelectedDigits(s,g,o,c)??function removeNextDigit(e,t,n,i){if(i>=n.length)return;const r=t.getDigitRange(e,i,n.length);if(!r)return;const[s]=r;return removeDigitsRange(e,s,s+1)}(s,g,a,o)):void(/^\d$/.test(n.key)?s.length>=g.getMaxDigits()&&n.preventDefault():1===n.key.length&&n.preventDefault())}function processPaste(e,t){if(!e.target)return;e.preventDefault();const n=e.target,{digits:i,formatter:r}=t,s=e.clipboardData?.getData("text")||"",g=r.getMaxDigits(),o=extractDigits(s,g);if(0===o.length)return;const[c,a]=getSelection(n);if(c!==a){const e=r.getDigitRange(i,c,a);if(e){const[t,n]=e;return{newDigits:extractDigits(i.slice(0,t)+o+i.slice(n),g),caretDigitIndex:t+o.length}}}const u=r.getDigitRange(i,0,c),l=u?u[1]:0;return{newDigits:extractDigits(i.slice(0,l)+o+i.slice(l),g),caretDigitIndex:l+o.length}}export{e as DELIMITERS,n as INVALID_PATTERN,t as NAVIGATION_KEYS,extractDigits,getSelection,processBeforeInput,processInput,processKeydown,processPaste,setCaret};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{Masks as s,MasksBase as o,MasksBaseMap as r,MasksFull as i,MasksFullEn as e,MasksFullMap as t,MasksFullMapEn as m,MasksMap as p,MasksWithFlag as f,MasksWithFlagMap as j,getFlagEmoji as c}from"./entries.js";import{countPlaceholders as g,formatDigitsWithMap as l,getCountry as n,getMasksFullMapByLocale as u,getNavigatorLang as v,pickMaskVariant as x,removeCountryCodePrefix as a,toArray as b}from"./utils.js";import{CACHE_EXPIRY_MS as d,CACHE_KEY as h,GEO_IP_API_URL as k,GEO_IP_TIMEOUT_MS as q}from"./services/geoip/consts.js";import{detectByGeoIp as w,detectCountryFromGeoIP as y}from"./services/geoip/utils.js";export{d as CACHE_EXPIRY_MS,h as CACHE_KEY,k as GEO_IP_API_URL,q as GEO_IP_TIMEOUT_MS,s as Masks,o as MasksBase,r as MasksBaseMap,i as MasksFull,e as MasksFullEn,t as MasksFullMap,m as MasksFullMapEn,p as MasksMap,f as MasksWithFlag,j as MasksWithFlagMap,g as countPlaceholders,w as detectByGeoIp,y as detectCountryFromGeoIP,l as formatDigitsWithMap,n as getCountry,c as getFlagEmoji,u as getMasksFullMapByLocale,v as getNavigatorLang,x as pickMaskVariant,a as removeCountryCodePrefix,b as toArray};
1
+ import{Masks as r,MasksBase as o,MasksBaseMap as s,MasksFull as i,MasksFullEn as m,MasksFullMap as t,MasksFullMapEn as e,MasksMap as p,MasksWithFlag as f,MasksWithFlagMap as j,getFlagEmoji as c}from"./entries.js";import{countPlaceholders as l,detectCountryFromLocale as n,filterCountries as a,formatDigitsWithMap as g,getCountry as u,getNavigatorLang as v,hasCountry as d,parseCountryCode as h,pickMaskVariant as x,removeCountryCodePrefix as b,toArray as k}from"./utils.js";import{DELIMITERS as q,INVALID_PATTERN as w,NAVIGATION_KEYS as y,extractDigits as z,getSelection as A,processBeforeInput as B,processInput as C,processKeydown as D,processPaste as E,setCaret as F}from"./handlers.js";import{createPhoneFormatter as G}from"./formatter.js";import{CACHE_EXPIRY_MS as H,CACHE_KEY as I,GEO_IP_API_URL as J,GEO_IP_TIMEOUT_MS as K}from"./services/geoip/consts.js";import{detectByGeoIp as L,detectCountryFromGeoIP as M}from"./services/geoip/utils.js";export{H as CACHE_EXPIRY_MS,I as CACHE_KEY,q as DELIMITERS,J as GEO_IP_API_URL,K as GEO_IP_TIMEOUT_MS,w as INVALID_PATTERN,r as Masks,o as MasksBase,s as MasksBaseMap,i as MasksFull,m as MasksFullEn,t as MasksFullMap,e as MasksFullMapEn,p as MasksMap,f as MasksWithFlag,j as MasksWithFlagMap,y as NAVIGATION_KEYS,l as countPlaceholders,G as createPhoneFormatter,L as detectByGeoIp,M as detectCountryFromGeoIP,n as detectCountryFromLocale,z as extractDigits,a as filterCountries,g as formatDigitsWithMap,u as getCountry,c as getFlagEmoji,v as getNavigatorLang,A as getSelection,d as hasCountry,h as parseCountryCode,x as pickMaskVariant,B as processBeforeInput,C as processInput,D as processKeydown,E as processPaste,b as removeCountryCodePrefix,F as setCaret,k as toArray};
@@ -1 +1 @@
1
- import{GEO_IP_API_URL as t,GEO_IP_TIMEOUT_MS as o,CACHE_KEY as e,CACHE_EXPIRY_MS as r}from"./consts.js";async function detectCountryFromGeoIP(e=t,r=o){const c=new AbortController,n=setTimeout(()=>c.abort(),r);try{const t=await fetch(e,{signal:c.signal,headers:{Accept:"application/json"}});if(clearTimeout(n),!t.ok)return null;const o=await t.json();return(o.country||o.country_code||o.countryCode||o.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(n),null}}async function detectByGeoIp(t){try{const o=localStorage.getItem(e);if(o){const c=JSON.parse(o),n=Date.now()-c.ts>r;if(!n&&c.country_code&&t(c.country_code))return c.country_code.toUpperCase();n&&localStorage.removeItem(e)}}catch{}const o=await detectCountryFromGeoIP();if(o&&t(o)){try{localStorage.setItem(e,JSON.stringify({country_code:o,ts:Date.now()}))}catch{}return o}return null}export{detectByGeoIp,detectCountryFromGeoIP};
1
+ import{parseCountryCode as t}from"../../utils.js";import{GEO_IP_API_URL as o,GEO_IP_TIMEOUT_MS as e,CACHE_KEY as r,CACHE_EXPIRY_MS as n}from"./consts.js";async function detectCountryFromGeoIP(t=o,r=e){const n=new AbortController,c=setTimeout(()=>n.abort(),r);try{const o=await fetch(t,{signal:n.signal,headers:{Accept:"application/json"}});if(clearTimeout(c),!o.ok)return null;const e=await o.json();return(e.country||e.country_code||e.countryCode||e.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(c),null}}async function detectByGeoIp(){try{const o=localStorage.getItem(r);if(o){const e=JSON.parse(o),c=Date.now()-e.ts>n,a=t(e.country_code);if(a&&!c)return a;localStorage.removeItem(r)}}catch{}const o=await detectCountryFromGeoIP(),e=t(o);if(e){try{const t=JSON.stringify({country_code:e,ts:Date.now()});localStorage.setItem(r,t)}catch{}return e}return null}export{detectByGeoIp,detectCountryFromGeoIP};
package/dist/esm/utils.js CHANGED
@@ -1 +1 @@
1
- import{MasksFullMapEn as t,MasksFullMap as n}from"./entries.js";function getNavigatorLang(){return"undefined"!=typeof navigator&&navigator.language||"en"}function getMasksFullMapByLocale(e){return e.toLowerCase().startsWith("en")?t:n(e)}function getCountry(t,n){const e=getMasksFullMapByLocale(n),r=t.toUpperCase();return r in e?{id:r,...e[r]}:{id:"US",...e.US}}function toArray(t){return Array.isArray(t)?t:[t]}function countPlaceholders(t){return(t.match(/#/g)||[]).length}function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")}function pickMaskVariant(t,n){if(1===t.length)return t[0];const e=t.map(t=>({mask:t,count:countPlaceholders(t)})),r=e.filter(t=>t.count>=n).sort((t,n)=>t.count-n.count);if(r.length>0)return r[0].mask;const o=e.sort((t,n)=>n.count-t.count)[0];return o?o.mask:t[0]}function formatDigitsWithMap(t,n){let e="";const r=[];let o=0;const a=n.length,i=t.length;for(let u=0;u<i;u++){const i=t[u];if("#"===i){if(!(o<a))break;e+=n[o],r.push(o),o++}else{const n=-1!==t.indexOf("#",u+1)&&o<a;(e.length>0||n)&&(e+=i,r.push(-1))}}return{display:e,map:r}}export{countPlaceholders,formatDigitsWithMap,getCountry,getMasksFullMapByLocale,getNavigatorLang,pickMaskVariant,removeCountryCodePrefix,toArray};
1
+ import{MasksFullMap as t,MasksFullMapEn as r}from"./entries.js";function getNavigatorLang(){return globalThis.navigator?.language||"en"}function detectCountryFromLocale(){try{const t=getNavigatorLang();try{const r=new Intl.Locale(t);if(r.region)return r.region.toUpperCase()}catch{}const r=t.split(/[-_]/);if(r.length>1)return r[1]?.toUpperCase()||null}catch{}return null}function hasCountry(t){const e=r;return t.toUpperCase()in e}function getCountry(r,e){const n=t(e),o=r.toUpperCase();return o in n?{id:o,...n[o]}:{id:"US",...n.US}}function parseCountryCode(t,r){return t&&hasCountry(t)?t.toUpperCase():r||""}function toArray(t){return Array.isArray(t)?t:[t]}function countPlaceholders(t){return(t.match(/#/g)||[]).length}function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")}function pickMaskVariant(t,r){if(!t.length)return"";if(1===t.length)return t[0];const e=t.map(t=>({mask:t,count:countPlaceholders(t)})),n=e.filter(t=>t.count>=r).sort((t,r)=>t.count-r.count);if(n.length>0)return n[0].mask;const o=e.sort((t,r)=>r.count-t.count)[0];return o?o.mask:t[0]}function formatDigitsWithMap(t,r){let e="";const n=[];let o=0;const a=r.length,s=t.length;for(let c=0;c<s;c++){const s=t[c];if("#"===s){if(!(o<a))break;e+=r[o],n.push(o),o++}else{const r=-1!==t.indexOf("#",c+1)&&o<a;(e.length>0||r)&&(e+=s,n.push(-1))}}return{display:e,map:n}}function filterCountries(t,r){const e=r.trim().toUpperCase();if(!e)return t;const n=e.replace(/\D/g,""),o=n.length>0;return t.map(t=>{const r=t.name.toUpperCase(),a=t.id.toUpperCase(),s=t.code.toUpperCase(),c=t.code.replace(/\D/g,"");let i=0;return r.startsWith(e)?i=1e3:r.includes(e)&&(i=500),s.startsWith(e)?i+=100:s.includes(e)&&(i+=50),a===e?i+=200:a.startsWith(e)&&(i+=150),o&&c.startsWith(n)?i+=80:o&&c.includes(n)&&(i+=40),{country:t,score:i}}).filter(t=>t.score>0).sort((t,r)=>r.score===t.score?t.country.name.localeCompare(r.country.name):r.score-t.score).map(t=>t.country)}export{countPlaceholders,detectCountryFromLocale,filterCountries,formatDigitsWithMap,getCountry,getNavigatorLang,hasCountry,parseCountryCode,pickMaskVariant,removeCountryCodePrefix,toArray};
@@ -0,0 +1,36 @@
1
+ import type { MaskFull } from './entries';
2
+ /**
3
+ * Formatter interface for digit range and caret calculations
4
+ */
5
+ export interface FormatterHelpers {
6
+ /**
7
+ * Format digits into display string with mask delimiters
8
+ */
9
+ formatDisplay: (digits: string) => string;
10
+ /**
11
+ * Get maximum number of digits for the current country
12
+ */
13
+ getMaxDigits: () => number;
14
+ /**
15
+ * Get placeholder string for the input
16
+ */
17
+ getPlaceholder: () => string;
18
+ /**
19
+ * Get caret position in display string for given digit index
20
+ */
21
+ getCaretPosition: (digitIndex: number) => number;
22
+ /**
23
+ * Get digit range [start, end) for selection range in display string
24
+ * Returns null if no digits are selected
25
+ */
26
+ getDigitRange: (digits: string, selStart: number, selEnd: number) => [number, number] | null;
27
+ /**
28
+ * Check if the current number of digits is a valid complete phone number
29
+ */
30
+ isComplete: (digits: string) => boolean;
31
+ }
32
+ /**
33
+ * Create a phone formatter for a given country
34
+ */
35
+ export declare function createPhoneFormatter(country: MaskFull): FormatterHelpers;
36
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAE1C;;OAEG;IACH,YAAY,EAAE,MAAM,MAAM,CAAC;IAE3B;;OAEG;IACH,cAAc,EAAE,MAAM,MAAM,CAAC;IAE7B;;OAEG;IACH,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAEjD;;;OAGG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE7F;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CACzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,CAuDxE"}
@@ -0,0 +1,63 @@
1
+ import type { FormatterHelpers } from './formatter';
2
+ export declare const DELIMITERS: string[];
3
+ export declare const NAVIGATION_KEYS: string[];
4
+ export declare const INVALID_PATTERN: RegExp;
5
+ /** Result of processInput */
6
+ interface InputResult {
7
+ newDigits: string;
8
+ caretDigitIndex: number;
9
+ }
10
+ /** Result of processKeydown */
11
+ interface KeydownResult {
12
+ newDigits: string;
13
+ caretDigitIndex: number;
14
+ }
15
+ /** Result of processPaste */
16
+ interface PasteResult {
17
+ newDigits: string;
18
+ caretDigitIndex: number;
19
+ }
20
+ /** Parameters for processInput */
21
+ interface ProcessInputParams {
22
+ formatter: FormatterHelpers;
23
+ }
24
+ /** Parameters for processKeydown */
25
+ interface ProcessKeydownParams {
26
+ digits: string;
27
+ formatter: FormatterHelpers;
28
+ }
29
+ /** Parameters for processPaste */
30
+ interface ProcessPasteParams {
31
+ digits: string;
32
+ formatter: FormatterHelpers;
33
+ }
34
+ /**
35
+ * Extract digits from a string, optionally limiting to maxLength
36
+ */
37
+ export declare function extractDigits(value: string, maxLength?: number): string;
38
+ /**
39
+ * Get current selection range from input element
40
+ */
41
+ export declare function getSelection(el: HTMLInputElement | null): [number, number];
42
+ /**
43
+ * Set caret position in input element
44
+ */
45
+ export declare function setCaret(el: HTMLInputElement | null, position: number): void;
46
+ /**
47
+ * Process beforeinput event - determine if input should be blocked
48
+ */
49
+ export declare function processBeforeInput(e: InputEvent): void;
50
+ /**
51
+ * Process input event - extract digits and calculate caret position
52
+ */
53
+ export declare function processInput(e: Event, params: ProcessInputParams): InputResult | undefined;
54
+ /**
55
+ * Process keydown event - handle backspace, delete, digits, etc.
56
+ */
57
+ export declare function processKeydown(e: KeyboardEvent, params: ProcessKeydownParams): KeydownResult | undefined;
58
+ /**
59
+ * Process paste event - extract digits and insert at correct position
60
+ */
61
+ export declare function processPaste(e: ClipboardEvent, params: ProcessPasteParams): PasteResult | undefined;
62
+ export {};
63
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,UAAU,UAAuB,CAAC;AAC/C,eAAO,MAAM,eAAe,UAA4E,CAAC;AACzG,eAAO,MAAM,eAAe,QAAgB,CAAC;AAE7C,6BAA6B;AAC7B,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,+BAA+B;AAC/B,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,6BAA6B;AAC7B,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,kCAAkC;AAClC,UAAU,kBAAkB;IAC1B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,oCAAoC;AACpC,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,kCAAkC;AAClC,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAoED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAYtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAc1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,oBAAoB,GAAG,aAAa,GAAG,SAAS,CA2CxG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAkDnG"}
@@ -0,0 +1,6 @@
1
+ export * from './entries';
2
+ export * from './services';
3
+ export * from './utils';
4
+ export * from './handlers';
5
+ export * from './formatter';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const data={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},CC_REGEX=/^[a-z]{2}$/i,countryCodeEmoji=t=>{if(!CC_REGEX.test(t)){const e=typeof t;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===e?t:e}' instead.`)}const e=[...t.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)},dataEntries=Object.entries(data),divideMask=t=>t.split(/ (.*)/s);function getCodeAndMask(t){let e="",o="";if(Array.isArray(t)){const a=[];for(const o of t){const[t,s]=divideMask(o);e||(e=t),a.push(s)}o=a}else{const[a,s]=divideMask(t);e=a,o=s}return[e,o]}const MasksBaseMap=data,MasksBase=dataEntries.map(([t,e])=>({id:t,mask:e})),MasksMap=dataEntries.reduce((t,[e,o])=>{const[a,s]=getCodeAndMask(o);return t[e]={code:a,mask:s},t},{}),Masks=dataEntries.map(([t,e])=>{const[o,a]=getCodeAndMask(e);return{id:t,code:o,mask:a}}),MasksWithFlagMap=dataEntries.reduce((t,[e,o])=>{const[a,s]=getCodeAndMask(o);return t[e]={code:a,mask:s,flag:countryCodeEmoji(e)},t},{}),MasksWithFlag=dataEntries.map(([t,e])=>{const[o,a]=getCodeAndMask(e);return{id:t,code:o,mask:a,flag:countryCodeEmoji(t)}}),MasksFullMap=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return dataEntries.reduce((t,[o,a])=>{const[s,n]=getCodeAndMask(a),r=e.of(o)??"";return t[o]={code:s,mask:n,name:r,flag:countryCodeEmoji(o)},t},{})},MasksFullMapEn=dataEntries.reduce((t,[e,o])=>{const[a,s]=getCodeAndMask(o),n=new Intl.DisplayNames(["en"],{type:"region"});return t[e]={code:a,mask:s,name:n.of(e)??"",flag:countryCodeEmoji(e)},t},{}),MasksFullEn=dataEntries.map(([t,e])=>{const[o,a]=getCodeAndMask(e);return{id:t,code:o,mask:a,name:new Intl.DisplayNames(["en"],{type:"region"}).of(t)??"",flag:countryCodeEmoji(t)}}),getFlagEmoji=countryCodeEmoji,CACHE_KEY="@desource/phone-mask:geo";async function detectCountryFromGeoIP(t="https://ipapi.co/json/",e=1500){const o=new AbortController,a=setTimeout(()=>o.abort(),e);try{const e=await fetch(t,{signal:o.signal,headers:{Accept:"application/json"}});if(clearTimeout(a),!e.ok)return null;const s=await e.json();return(s.country||s.country_code||s.countryCode||s.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(a),null}}function getMasksFullMapByLocale(t){return t.toLowerCase().startsWith("en")?MasksFullMapEn:MasksFullMap(t)}function countPlaceholders(t){return(t.match(/#/g)||[]).length}exports.CACHE_EXPIRY_MS=864e5,exports.CACHE_KEY=CACHE_KEY,exports.GEO_IP_API_URL="https://ipapi.co/json/",exports.GEO_IP_TIMEOUT_MS=1500,exports.Masks=Masks,exports.MasksBase=MasksBase,exports.MasksBaseMap=MasksBaseMap,exports.MasksFull=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return dataEntries.map(([t,o])=>{const[a,s]=getCodeAndMask(o);return{id:t,code:a,mask:s,name:e.of(t)??"",flag:countryCodeEmoji(t)}})},exports.MasksFullEn=MasksFullEn,exports.MasksFullMap=MasksFullMap,exports.MasksFullMapEn=MasksFullMapEn,exports.MasksMap=MasksMap,exports.MasksWithFlag=MasksWithFlag,exports.MasksWithFlagMap=MasksWithFlagMap,exports.countPlaceholders=countPlaceholders,exports.detectByGeoIp=async function detectByGeoIp(t){try{const e=localStorage.getItem(CACHE_KEY);if(e){const o=JSON.parse(e),a=Date.now()-o.ts>864e5;if(!a&&o.country_code&&t(o.country_code))return o.country_code.toUpperCase();a&&localStorage.removeItem(CACHE_KEY)}}catch{}const e=await detectCountryFromGeoIP();if(e&&t(e)){try{localStorage.setItem(CACHE_KEY,JSON.stringify({country_code:e,ts:Date.now()}))}catch{}return e}return null},exports.detectCountryFromGeoIP=detectCountryFromGeoIP,exports.formatDigitsWithMap=function formatDigitsWithMap(t,e){let o="";const a=[];let s=0;const n=e.length,r=t.length;for(let c=0;c<r;c++){const r=t[c];if("#"===r){if(!(s<n))break;o+=e[s],a.push(s),s++}else{const e=-1!==t.indexOf("#",c+1)&&s<n;(o.length>0||e)&&(o+=r,a.push(-1))}}return{display:o,map:a}},exports.getCountry=function getCountry(t,e){const o=getMasksFullMapByLocale(e),a=t.toUpperCase();return a in o?{id:a,...o[a]}:{id:"US",...o.US}},exports.getFlagEmoji=getFlagEmoji,exports.getMasksFullMapByLocale=getMasksFullMapByLocale,exports.getNavigatorLang=function getNavigatorLang(){return"undefined"!=typeof navigator&&navigator.language||"en"},exports.pickMaskVariant=function pickMaskVariant(t,e){if(1===t.length)return t[0];const o=t.map(t=>({mask:t,count:countPlaceholders(t)})),a=o.filter(t=>t.count>=e).sort((t,e)=>t.count-e.count);if(a.length>0)return a[0].mask;const s=o.sort((t,e)=>e.count-t.count)[0];return s?s.mask:t[0]},exports.removeCountryCodePrefix=function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")},exports.toArray=function toArray(t){return Array.isArray(t)?t:[t]};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const data={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},CC_REGEX=/^[a-z]{2}$/i,countryCodeEmoji=t=>{if(!CC_REGEX.test(t)){const e=typeof t;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===e?t:e}' instead.`)}const e=[...t.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)},dnCache=new Map,getDisplayNames=t=>{const e=t.toLowerCase(),r=dnCache.get(e);if(r)return r;const n=new Intl.DisplayNames([t],{type:"region"});if(dnCache.size>=10)for(const t of dnCache.keys())if("en"!==t){dnCache.delete(t);break}return dnCache.set(e,n),n},dataEntries=Object.entries(data),divideMask=t=>t.split(/ (.*)/s);function getCodeAndMask(t){let e="",r="";if(Array.isArray(t)){const n=[];for(const r of t){const[t,o]=divideMask(r);e||(e=t),n.push(o)}r=n}else{const[n,o]=divideMask(t);e=n,r=o}return[e,r]}const MasksBaseMap=data,MasksBase=dataEntries.map(([t,e])=>({id:t,mask:e})),MasksMap=dataEntries.reduce((t,[e,r])=>{const[n,o]=getCodeAndMask(r);return t[e]={code:n,mask:o},t},{}),Masks=dataEntries.map(([t,e])=>{const[r,n]=getCodeAndMask(e);return{id:t,code:r,mask:n}}),MasksWithFlagMap=dataEntries.reduce((t,[e,r])=>{const[n,o]=getCodeAndMask(r);return t[e]={code:n,mask:o,flag:countryCodeEmoji(e)},t},{}),MasksWithFlag=dataEntries.map(([t,e])=>{const[r,n]=getCodeAndMask(e);return{id:t,code:r,mask:n,flag:countryCodeEmoji(t)}}),MasksFullMap=t=>{const e=getDisplayNames(t);return dataEntries.reduce((t,[r,n])=>{const[o,s]=getCodeAndMask(n),a=e.of(r)??"";return t[r]={code:o,mask:s,name:a,flag:countryCodeEmoji(r)},t},{})},MasksFull=t=>{const e=getDisplayNames(t);return dataEntries.map(([t,r])=>{const[n,o]=getCodeAndMask(r);return{id:t,code:n,mask:o,name:e.of(t)??"",flag:countryCodeEmoji(t)}})},MasksFullMapEn=MasksFullMap("en"),MasksFullEn=MasksFull("en"),getFlagEmoji=countryCodeEmoji,CACHE_KEY="@desource/phone-mask:geo";function getNavigatorLang(){return globalThis.navigator?.language||"en"}function hasCountry(t){const e=MasksFullMapEn;return t.toUpperCase()in e}function parseCountryCode(t,e){return t&&hasCountry(t)?t.toUpperCase():e||""}function toArray(t){return Array.isArray(t)?t:[t]}function countPlaceholders(t){return(t.match(/#/g)||[]).length}function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")}function pickMaskVariant(t,e){if(!t.length)return"";if(1===t.length)return t[0];const r=t.map(t=>({mask:t,count:countPlaceholders(t)})),n=r.filter(t=>t.count>=e).sort((t,e)=>t.count-e.count);if(n.length>0)return n[0].mask;const o=r.sort((t,e)=>e.count-t.count)[0];return o?o.mask:t[0]}function formatDigitsWithMap(t,e){let r="";const n=[];let o=0;const s=e.length,a=t.length;for(let i=0;i<a;i++){const a=t[i];if("#"===a){if(!(o<s))break;r+=e[o],n.push(o),o++}else{const e=-1!==t.indexOf("#",i+1)&&o<s;(r.length>0||e)&&(r+=a,n.push(-1))}}return{display:r,map:n}}async function detectCountryFromGeoIP(t="https://ipapi.co/json/",e=1500){const r=new AbortController,n=setTimeout(()=>r.abort(),e);try{const e=await fetch(t,{signal:r.signal,headers:{Accept:"application/json"}});if(clearTimeout(n),!e.ok)return null;const o=await e.json();return(o.country||o.country_code||o.countryCode||o.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(n),null}}const DELIMITERS=[" ","-","(",")"],NAVIGATION_KEYS=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],INVALID_PATTERN=/[^\d\s\-()]/;function removeDigitsRange(t,e,r){return{newDigits:t.slice(0,e)+t.slice(r),caretDigitIndex:e}}function removeSelectedDigits(t,e,r,n){if(r===n)return;const o=e.getDigitRange(t,r,n);if(!o)return;const[s,a]=o;return removeDigitsRange(t,s,a)}function extractDigits(t,e){const r=t.replace(/\D/g,"");return e?r.slice(0,e):r}function getSelection(t){return t?[t.selectionStart??0,t.selectionEnd??0]:[0,0]}exports.CACHE_EXPIRY_MS=864e5,exports.CACHE_KEY=CACHE_KEY,exports.DELIMITERS=DELIMITERS,exports.GEO_IP_API_URL="https://ipapi.co/json/",exports.GEO_IP_TIMEOUT_MS=1500,exports.INVALID_PATTERN=INVALID_PATTERN,exports.Masks=Masks,exports.MasksBase=MasksBase,exports.MasksBaseMap=MasksBaseMap,exports.MasksFull=MasksFull,exports.MasksFullEn=MasksFullEn,exports.MasksFullMap=MasksFullMap,exports.MasksFullMapEn=MasksFullMapEn,exports.MasksMap=MasksMap,exports.MasksWithFlag=MasksWithFlag,exports.MasksWithFlagMap=MasksWithFlagMap,exports.NAVIGATION_KEYS=NAVIGATION_KEYS,exports.countPlaceholders=countPlaceholders,exports.createPhoneFormatter=function createPhoneFormatter(t){const e=toArray(t.mask),r=e.map(t=>countPlaceholders(removeCountryCodePrefix(t))),n=Math.max(...r),getMask=t=>removeCountryCodePrefix(pickMaskVariant(e,t));return{formatDisplay:t=>formatDigitsWithMap(getMask(t.length),t).display,getMaxDigits:()=>n,getPlaceholder:()=>getMask(0),getCaretPosition:t=>{const e=Math.max(0,t);if(0===e)return 0;const r=getMask(e),{display:n}=formatDigitsWithMap(r,"0".repeat(e));return n.length},getDigitRange:(t,e,r)=>{const n=getMask(t.length),{map:o}=formatDigitsWithMap(n,t);let s=1/0,a=-1/0;for(let t=e;t<r&&t<o.length;t++){const e=o[t];void 0!==e&&e>=0&&(s=Math.min(s,e),a=Math.max(a,e))}return s===1/0?null:[s,a+1]},isComplete:t=>r.includes(t.length)}},exports.detectByGeoIp=async function detectByGeoIp(){try{const t=localStorage.getItem(CACHE_KEY);if(t){const e=JSON.parse(t),r=Date.now()-e.ts>864e5,n=parseCountryCode(e.country_code);if(n&&!r)return n;localStorage.removeItem(CACHE_KEY)}}catch{}const t=parseCountryCode(await detectCountryFromGeoIP());if(t){try{const e=JSON.stringify({country_code:t,ts:Date.now()});localStorage.setItem(CACHE_KEY,e)}catch{}return t}return null},exports.detectCountryFromGeoIP=detectCountryFromGeoIP,exports.detectCountryFromLocale=function detectCountryFromLocale(){try{const t=getNavigatorLang();try{const e=new Intl.Locale(t);if(e.region)return e.region.toUpperCase()}catch{}const e=t.split(/[-_]/);if(e.length>1)return e[1]?.toUpperCase()||null}catch{}return null},exports.extractDigits=extractDigits,exports.filterCountries=function filterCountries(t,e){const r=e.trim().toUpperCase();if(!r)return t;const n=r.replace(/\D/g,""),o=n.length>0;return t.map(t=>{const e=t.name.toUpperCase(),s=t.id.toUpperCase(),a=t.code.toUpperCase(),i=t.code.replace(/\D/g,"");let c=0;return e.startsWith(r)?c=1e3:e.includes(r)&&(c=500),a.startsWith(r)?c+=100:a.includes(r)&&(c+=50),s===r?c+=200:s.startsWith(r)&&(c+=150),o&&i.startsWith(n)?c+=80:o&&i.includes(n)&&(c+=40),{country:t,score:c}}).filter(t=>t.score>0).sort((t,e)=>e.score===t.score?t.country.name.localeCompare(e.country.name):e.score-t.score).map(t=>t.country)},exports.formatDigitsWithMap=formatDigitsWithMap,exports.getCountry=function getCountry(t,e){const r=MasksFullMap(e),n=t.toUpperCase();return n in r?{id:n,...r[n]}:{id:"US",...r.US}},exports.getFlagEmoji=getFlagEmoji,exports.getNavigatorLang=getNavigatorLang,exports.getSelection=getSelection,exports.hasCountry=hasCountry,exports.parseCountryCode=parseCountryCode,exports.pickMaskVariant=pickMaskVariant,exports.processBeforeInput=function processBeforeInput(t){if(!t.target)return;const e=t.target,r=t.data;"insertText"===t.inputType&&r&&(INVALID_PATTERN.test(r)||" "===r&&e.value.endsWith(" "))&&t.preventDefault()},exports.processInput=function processInput(t,e){if(!t.target)return;const r=t.target,{formatter:n}=e,o=n.getMaxDigits(),s=extractDigits(r.value,o);return{newDigits:s,caretDigitIndex:s.length}},exports.processKeydown=function processKeydown(t,e){if(!t.target)return;const r=t.target,{digits:n,formatter:o}=e;if(function shouldIgnoreKeydown(t){return t.ctrlKey||t.metaKey||t.altKey||NAVIGATION_KEYS.includes(t.key)}(t))return;const[s,a]=getSelection(r),i=r.value;return"Backspace"===t.key?(t.preventDefault(),removeSelectedDigits(n,o,s,a)??function removePreviousDigit(t,e,r,n){if(n<=0)return;let o=n-1;for(;o>=0&&DELIMITERS.includes(r[o]);)o--;if(o<0)return;const s=e.getDigitRange(t,o,o+1);if(!s)return;const[a]=s;return removeDigitsRange(t,a,a+1)}(n,o,i,s)):"Delete"===t.key?(t.preventDefault(),removeSelectedDigits(n,o,s,a)??function removeNextDigit(t,e,r,n){if(n>=r.length)return;const o=e.getDigitRange(t,n,r.length);if(!o)return;const[s]=o;return removeDigitsRange(t,s,s+1)}(n,o,i,s)):void(/^\d$/.test(t.key)?n.length>=o.getMaxDigits()&&t.preventDefault():1===t.key.length&&t.preventDefault())},exports.processPaste=function processPaste(t,e){if(!t.target)return;t.preventDefault();const r=t.target,{digits:n,formatter:o}=e,s=t.clipboardData?.getData("text")||"",a=o.getMaxDigits(),i=extractDigits(s,a);if(0===i.length)return;const[c,u]=getSelection(r);if(c!==u){const t=o.getDigitRange(n,c,u);if(t){const[e,r]=t;return{newDigits:extractDigits(n.slice(0,e)+i+n.slice(r),a),caretDigitIndex:e+i.length}}}const l=o.getDigitRange(n,0,c),g=l?l[1]:0;return{newDigits:extractDigits(n.slice(0,g)+i+n.slice(g),a),caretDigitIndex:g+i.length}},exports.removeCountryCodePrefix=removeCountryCodePrefix,exports.setCaret=function setCaret(t,e){if(t)try{t.setSelectionRange(e,e)}catch{}},exports.toArray=toArray;
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phoneMask={})}(this,function(t){"use strict";const e={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},n=/^[a-z]{2}$/i,o=t=>{if(!n.test(t)){const e=typeof t;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===e?t:e}' instead.`)}const e=[...t.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)},r=Object.entries(e),a=t=>t.split(/ (.*)/s);function s(t){let e="",n="";if(Array.isArray(t)){const o=[];for(const n of t){const[t,r]=a(n);e||(e=t),o.push(r)}n=o}else{const[o,r]=a(t);e=o,n=r}return[e,n]}const c=e,i=r.map(([t,e])=>({id:t,mask:e})),u=r.reduce((t,[e,n])=>{const[o,r]=s(n);return t[e]={code:o,mask:r},t},{}),l=r.map(([t,e])=>{const[n,o]=s(e);return{id:t,code:n,mask:o}}),M=r.reduce((t,[e,n])=>{const[r,a]=s(n);return t[e]={code:r,mask:a,flag:o(e)},t},{}),p=r.map(([t,e])=>{const[n,r]=s(e);return{id:t,code:n,mask:r,flag:o(t)}}),f=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return r.reduce((t,[n,r])=>{const[a,c]=s(r),i=e.of(n)??"";return t[n]={code:a,mask:c,name:i,flag:o(n)},t},{})},d=r.reduce((t,[e,n])=>{const[r,a]=s(n),c=new Intl.DisplayNames(["en"],{type:"region"});return t[e]={code:r,mask:a,name:c.of(e)??"",flag:o(e)},t},{}),g=r.map(([t,e])=>{const[n,r]=s(e);return{id:t,code:n,mask:r,name:new Intl.DisplayNames(["en"],{type:"region"}).of(t)??"",flag:o(t)}}),m=o,S="https://ipapi.co/json/",C="@desource/phone-mask:geo",y=864e5;async function A(t=S,e=1500){const n=new AbortController,o=setTimeout(()=>n.abort(),e);try{const e=await fetch(t,{signal:n.signal,headers:{Accept:"application/json"}});if(clearTimeout(o),!e.ok)return null;const r=await e.json();return(r.country||r.country_code||r.countryCode||r.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(o),null}}function T(t){return t.toLowerCase().startsWith("en")?d:f(t)}function G(t){return(t.match(/#/g)||[]).length}t.CACHE_EXPIRY_MS=y,t.CACHE_KEY=C,t.GEO_IP_API_URL=S,t.GEO_IP_TIMEOUT_MS=1500,t.Masks=l,t.MasksBase=i,t.MasksBaseMap=c,t.MasksFull=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return r.map(([t,n])=>{const[r,a]=s(n);return{id:t,code:r,mask:a,name:e.of(t)??"",flag:o(t)}})},t.MasksFullEn=g,t.MasksFullMap=f,t.MasksFullMapEn=d,t.MasksMap=u,t.MasksWithFlag=p,t.MasksWithFlagMap=M,t.countPlaceholders=G,t.detectByGeoIp=async function(t){try{const e=localStorage.getItem(C);if(e){const n=JSON.parse(e),o=Date.now()-n.ts>y;if(!o&&n.country_code&&t(n.country_code))return n.country_code.toUpperCase();o&&localStorage.removeItem(C)}}catch{}const e=await A();if(e&&t(e)){try{localStorage.setItem(C,JSON.stringify({country_code:e,ts:Date.now()}))}catch{}return e}return null},t.detectCountryFromGeoIP=A,t.formatDigitsWithMap=function(t,e){let n="";const o=[];let r=0;const a=e.length,s=t.length;for(let c=0;c<s;c++){const s=t[c];if("#"===s){if(!(r<a))break;n+=e[r],o.push(r),r++}else{const e=-1!==t.indexOf("#",c+1)&&r<a;(n.length>0||e)&&(n+=s,o.push(-1))}}return{display:n,map:o}},t.getCountry=function(t,e){const n=T(e),o=t.toUpperCase();return o in n?{id:o,...n[o]}:{id:"US",...n.US}},t.getFlagEmoji=m,t.getMasksFullMapByLocale=T,t.getNavigatorLang=function(){return"undefined"!=typeof navigator&&navigator.language||"en"},t.pickMaskVariant=function(t,e){if(1===t.length)return t[0];const n=t.map(t=>({mask:t,count:G(t)})),o=n.filter(t=>t.count>=e).sort((t,e)=>t.count-e.count);if(o.length>0)return o[0].mask;const r=n.sort((t,e)=>e.count-t.count)[0];return r?r.mask:t[0]},t.removeCountryCodePrefix=function(t){return t.replace(/^\+\d+\s?/,"")},t.toArray=function(t){return Array.isArray(t)?t:[t]},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phoneMask={})}(this,function(t){"use strict";const e={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},n=/^[a-z]{2}$/i,r=t=>{if(!n.test(t)){const e=typeof t;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===e?t:e}' instead.`)}const e=[...t.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)},o="en",s=new Map,a=t=>{const e=t.toLowerCase(),n=s.get(e);if(n)return n;const r=new Intl.DisplayNames([t],{type:"region"});if(s.size>=10)for(const t of s.keys())if(t!==o){s.delete(t);break}return s.set(e,r),r},i=Object.entries(e),c=t=>t.split(/ (.*)/s);function u(t){let e="",n="";if(Array.isArray(t)){const r=[];for(const n of t){const[t,o]=c(n);e||(e=t),r.push(o)}n=r}else{const[r,o]=c(t);e=r,n=o}return[e,n]}const l=e,g=i.map(([t,e])=>({id:t,mask:e})),f=i.reduce((t,[e,n])=>{const[r,o]=u(n);return t[e]={code:r,mask:o},t},{}),p=i.map(([t,e])=>{const[n,r]=u(e);return{id:t,code:n,mask:r}}),d=i.reduce((t,[e,n])=>{const[o,s]=u(n);return t[e]={code:o,mask:s,flag:r(e)},t},{}),M=i.map(([t,e])=>{const[n,o]=u(e);return{id:t,code:n,mask:o,flag:r(t)}}),m=t=>{const e=a(t);return i.reduce((t,[n,o])=>{const[s,a]=u(o),i=e.of(n)??"";return t[n]={code:s,mask:a,name:i,flag:r(n)},t},{})},h=t=>{const e=a(t);return i.map(([t,n])=>{const[o,s]=u(n);return{id:t,code:o,mask:s,name:e.of(t)??"",flag:r(t)}})},C=m(o),y=h(o),D=r,S="https://ipapi.co/json/",A="@desource/phone-mask:geo",I=864e5;function T(){return globalThis.navigator?.language||"en"}function E(t){const e=C;return t.toUpperCase()in e}function G(t,e){return t&&E(t)?t.toUpperCase():e||""}function k(t){return Array.isArray(t)?t:[t]}function P(t){return(t.match(/#/g)||[]).length}function R(t){return t.replace(/^\+\d+\s?/,"")}function N(t,e){if(!t.length)return"";if(1===t.length)return t[0];const n=t.map(t=>({mask:t,count:P(t)})),r=n.filter(t=>t.count>=e).sort((t,e)=>t.count-e.count);if(r.length>0)return r[0].mask;const o=n.sort((t,e)=>e.count-t.count)[0];return o?o.mask:t[0]}function U(t,e){let n="";const r=[];let o=0;const s=e.length,a=t.length;for(let i=0;i<a;i++){const a=t[i];if("#"===a){if(!(o<s))break;n+=e[o],r.push(o),o++}else{const e=-1!==t.indexOf("#",i+1)&&o<s;(n.length>0||e)&&(n+=a,r.push(-1))}}return{display:n,map:r}}async function B(t=S,e=1500){const n=new AbortController,r=setTimeout(()=>n.abort(),e);try{const e=await fetch(t,{signal:n.signal,headers:{Accept:"application/json"}});if(clearTimeout(r),!e.ok)return null;const o=await e.json();return(o.country||o.country_code||o.countryCode||o.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(r),null}}const L=[" ","-","(",")"],K=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],F=/[^\d\s\-()]/;function O(t,e,n){return{newDigits:t.slice(0,e)+t.slice(n),caretDigitIndex:e}}function w(t,e,n,r){if(n===r)return;const o=e.getDigitRange(t,n,r);if(!o)return;const[s,a]=o;return O(t,s,a)}function W(t,e){const n=t.replace(/\D/g,"");return e?n.slice(0,e):n}function x(t){return t?[t.selectionStart??0,t.selectionEnd??0]:[0,0]}t.CACHE_EXPIRY_MS=I,t.CACHE_KEY=A,t.DELIMITERS=L,t.GEO_IP_API_URL=S,t.GEO_IP_TIMEOUT_MS=1500,t.INVALID_PATTERN=F,t.Masks=p,t.MasksBase=g,t.MasksBaseMap=l,t.MasksFull=h,t.MasksFullEn=y,t.MasksFullMap=m,t.MasksFullMapEn=C,t.MasksMap=f,t.MasksWithFlag=M,t.MasksWithFlagMap=d,t.NAVIGATION_KEYS=K,t.countPlaceholders=P,t.createPhoneFormatter=function(t){const e=k(t.mask),n=e.map(t=>P(R(t))),r=Math.max(...n),o=t=>R(N(e,t));return{formatDisplay:t=>U(o(t.length),t).display,getMaxDigits:()=>r,getPlaceholder:()=>o(0),getCaretPosition:t=>{const e=Math.max(0,t);if(0===e)return 0;const n=o(e),{display:r}=U(n,"0".repeat(e));return r.length},getDigitRange:(t,e,n)=>{const r=o(t.length),{map:s}=U(r,t);let a=1/0,i=-1/0;for(let t=e;t<n&&t<s.length;t++){const e=s[t];void 0!==e&&e>=0&&(a=Math.min(a,e),i=Math.max(i,e))}return a===1/0?null:[a,i+1]},isComplete:t=>n.includes(t.length)}},t.detectByGeoIp=async function(){try{const t=localStorage.getItem(A);if(t){const e=JSON.parse(t),n=Date.now()-e.ts>I,r=G(e.country_code);if(r&&!n)return r;localStorage.removeItem(A)}}catch{}const t=G(await B());if(t){try{const e=JSON.stringify({country_code:t,ts:Date.now()});localStorage.setItem(A,e)}catch{}return t}return null},t.detectCountryFromGeoIP=B,t.detectCountryFromLocale=function(){try{const t=T();try{const e=new Intl.Locale(t);if(e.region)return e.region.toUpperCase()}catch{}const e=t.split(/[-_]/);if(e.length>1)return e[1]?.toUpperCase()||null}catch{}return null},t.extractDigits=W,t.filterCountries=function(t,e){const n=e.trim().toUpperCase();if(!n)return t;const r=n.replace(/\D/g,""),o=r.length>0;return t.map(t=>{const e=t.name.toUpperCase(),s=t.id.toUpperCase(),a=t.code.toUpperCase(),i=t.code.replace(/\D/g,"");let c=0;return e.startsWith(n)?c=1e3:e.includes(n)&&(c=500),a.startsWith(n)?c+=100:a.includes(n)&&(c+=50),s===n?c+=200:s.startsWith(n)&&(c+=150),o&&i.startsWith(r)?c+=80:o&&i.includes(r)&&(c+=40),{country:t,score:c}}).filter(t=>t.score>0).sort((t,e)=>e.score===t.score?t.country.name.localeCompare(e.country.name):e.score-t.score).map(t=>t.country)},t.formatDigitsWithMap=U,t.getCountry=function(t,e){const n=m(e),r=t.toUpperCase();return r in n?{id:r,...n[r]}:{id:"US",...n.US}},t.getFlagEmoji=D,t.getNavigatorLang=T,t.getSelection=x,t.hasCountry=E,t.parseCountryCode=G,t.pickMaskVariant=N,t.processBeforeInput=function(t){if(!t.target)return;const e=t.target,n=t.data;"insertText"===t.inputType&&n&&(F.test(n)||" "===n&&e.value.endsWith(" "))&&t.preventDefault()},t.processInput=function(t,e){if(!t.target)return;const n=t.target,{formatter:r}=e,o=r.getMaxDigits(),s=W(n.value,o);return{newDigits:s,caretDigitIndex:s.length}},t.processKeydown=function(t,e){if(!t.target)return;const n=t.target,{digits:r,formatter:o}=e;if(function(t){return t.ctrlKey||t.metaKey||t.altKey||K.includes(t.key)}(t))return;const[s,a]=x(n),i=n.value;return"Backspace"===t.key?(t.preventDefault(),w(r,o,s,a)??function(t,e,n,r){if(r<=0)return;let o=r-1;for(;o>=0&&L.includes(n[o]);)o--;if(o<0)return;const s=e.getDigitRange(t,o,o+1);if(!s)return;const[a]=s;return O(t,a,a+1)}(r,o,i,s)):"Delete"===t.key?(t.preventDefault(),w(r,o,s,a)??function(t,e,n,r){if(r>=n.length)return;const o=e.getDigitRange(t,r,n.length);if(!o)return;const[s]=o;return O(t,s,s+1)}(r,o,i,s)):void(/^\d$/.test(t.key)?r.length>=o.getMaxDigits()&&t.preventDefault():1===t.key.length&&t.preventDefault())},t.processPaste=function(t,e){if(!t.target)return;t.preventDefault();const n=t.target,{digits:r,formatter:o}=e,s=t.clipboardData?.getData("text")||"",a=o.getMaxDigits(),i=W(s,a);if(0===i.length)return;const[c,u]=x(n);if(c!==u){const t=o.getDigitRange(r,c,u);if(t){const[e,n]=t;return{newDigits:W(r.slice(0,e)+i+r.slice(n),a),caretDigitIndex:e+i.length}}}const l=o.getDigitRange(r,0,c),g=l?l[1]:0;return{newDigits:W(r.slice(0,g)+i+r.slice(g),a),caretDigitIndex:g+i.length}},t.removeCountryCodePrefix=R,t.setCaret=function(t,e){if(t)try{t.setSelectionRange(e,e)}catch{}},t.toArray=k,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,5 @@
1
+ export declare const GEO_IP_API_URL = "https://ipapi.co/json/";
2
+ export declare const GEO_IP_TIMEOUT_MS = 1500;
3
+ export declare const CACHE_KEY = "@desource/phone-mask:geo";
4
+ export declare const CACHE_EXPIRY_MS: number;
5
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/services/geoip/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,2BAA2B,CAAC;AACvD,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC,eAAO,MAAM,SAAS,6BAA6B,CAAC;AACpD,eAAO,MAAM,eAAe,QAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './consts';
2
+ export * from './utils';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/geoip/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface MaskGeoCache {
2
+ country_code: string;
3
+ ts: number;
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/geoip/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACZ"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Detect country from GeoIP service.
3
+ * Attempts to fetch country code from external API with timeout
4
+ */
5
+ export declare function detectCountryFromGeoIP(url?: string, timeout?: number): Promise<string | null>;
6
+ export declare function detectByGeoIp(): Promise<string | null>;
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/geoip/utils.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,SAAiB,EACpB,OAAO,SAAoB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwBxB;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoC5D"}
@@ -0,0 +1,2 @@
1
+ export * from './geoip';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,QAAQ;IAChB,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;CAC9B;AACD,UAAU,IAAK,SAAQ,QAAQ;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,YAAa,SAAQ,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,QAAS,SAAQ,YAAY;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,KAAK,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,KAAK,eAAe,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACpE,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AAsB5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAAkB,CAAC;AAC9C;;;GAGG;AACH,eAAO,MAAM,SAAS,YAA4D,CAAC;AACnF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAIJ,CAAC;AAClB;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAGhB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iBAIJ,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,aAAa,gBAGxB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,gBAQxC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,eAYrC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAKN,CAAC;AACtB;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAUtB,CAAC;AACH,yCAAyC;AACzC,eAAO,MAAM,YAAY,wBAAmB,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,QAAQ;IAChB,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;CAC9B;AACD,UAAU,IAAK,SAAQ,QAAQ;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,YAAa,SAAQ,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,QAAS,SAAQ,YAAY;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,KAAK,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,KAAK,eAAe,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACpE,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AA4C5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAAkB,CAAC;AAC9C;;;GAGG;AACH,eAAO,MAAM,SAAS,YAA4D,CAAC;AACnF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAIJ,CAAC;AAClB;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAGhB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iBAIJ,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,aAAa,gBAGxB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,gBAQxC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,eAYrC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAA6B,CAAC;AACzD;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAA0B,CAAC;AACnD,yCAAyC;AACzC,eAAO,MAAM,YAAY,wBAAmB,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { MaskFull } from './entries';
2
+ /**
3
+ * Formatter interface for digit range and caret calculations
4
+ */
5
+ export interface FormatterHelpers {
6
+ /**
7
+ * Format digits into display string with mask delimiters
8
+ */
9
+ formatDisplay: (digits: string) => string;
10
+ /**
11
+ * Get maximum number of digits for the current country
12
+ */
13
+ getMaxDigits: () => number;
14
+ /**
15
+ * Get placeholder string for the input
16
+ */
17
+ getPlaceholder: () => string;
18
+ /**
19
+ * Get caret position in display string for given digit index
20
+ */
21
+ getCaretPosition: (digitIndex: number) => number;
22
+ /**
23
+ * Get digit range [start, end) for selection range in display string
24
+ * Returns null if no digits are selected
25
+ */
26
+ getDigitRange: (digits: string, selStart: number, selEnd: number) => [number, number] | null;
27
+ /**
28
+ * Check if the current number of digits is a valid complete phone number
29
+ */
30
+ isComplete: (digits: string) => boolean;
31
+ }
32
+ /**
33
+ * Create a phone formatter for a given country
34
+ */
35
+ export declare function createPhoneFormatter(country: MaskFull): FormatterHelpers;
36
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAE1C;;OAEG;IACH,YAAY,EAAE,MAAM,MAAM,CAAC;IAE3B;;OAEG;IACH,cAAc,EAAE,MAAM,MAAM,CAAC;IAE7B;;OAEG;IACH,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAEjD;;;OAGG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE7F;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CACzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,CAuDxE"}
@@ -0,0 +1,63 @@
1
+ import { FormatterHelpers } from './formatter';
2
+ export declare const DELIMITERS: string[];
3
+ export declare const NAVIGATION_KEYS: string[];
4
+ export declare const INVALID_PATTERN: RegExp;
5
+ /** Result of processInput */
6
+ interface InputResult {
7
+ newDigits: string;
8
+ caretDigitIndex: number;
9
+ }
10
+ /** Result of processKeydown */
11
+ interface KeydownResult {
12
+ newDigits: string;
13
+ caretDigitIndex: number;
14
+ }
15
+ /** Result of processPaste */
16
+ interface PasteResult {
17
+ newDigits: string;
18
+ caretDigitIndex: number;
19
+ }
20
+ /** Parameters for processInput */
21
+ interface ProcessInputParams {
22
+ formatter: FormatterHelpers;
23
+ }
24
+ /** Parameters for processKeydown */
25
+ interface ProcessKeydownParams {
26
+ digits: string;
27
+ formatter: FormatterHelpers;
28
+ }
29
+ /** Parameters for processPaste */
30
+ interface ProcessPasteParams {
31
+ digits: string;
32
+ formatter: FormatterHelpers;
33
+ }
34
+ /**
35
+ * Extract digits from a string, optionally limiting to maxLength
36
+ */
37
+ export declare function extractDigits(value: string, maxLength?: number): string;
38
+ /**
39
+ * Get current selection range from input element
40
+ */
41
+ export declare function getSelection(el: HTMLInputElement | null): [number, number];
42
+ /**
43
+ * Set caret position in input element
44
+ */
45
+ export declare function setCaret(el: HTMLInputElement | null, position: number): void;
46
+ /**
47
+ * Process beforeinput event - determine if input should be blocked
48
+ */
49
+ export declare function processBeforeInput(e: InputEvent): void;
50
+ /**
51
+ * Process input event - extract digits and calculate caret position
52
+ */
53
+ export declare function processInput(e: Event, params: ProcessInputParams): InputResult | undefined;
54
+ /**
55
+ * Process keydown event - handle backspace, delete, digits, etc.
56
+ */
57
+ export declare function processKeydown(e: KeyboardEvent, params: ProcessKeydownParams): KeydownResult | undefined;
58
+ /**
59
+ * Process paste event - extract digits and insert at correct position
60
+ */
61
+ export declare function processPaste(e: ClipboardEvent, params: ProcessPasteParams): PasteResult | undefined;
62
+ export {};
63
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,UAAU,UAAuB,CAAC;AAC/C,eAAO,MAAM,eAAe,UAA4E,CAAC;AACzG,eAAO,MAAM,eAAe,QAAgB,CAAC;AAE7C,6BAA6B;AAC7B,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,+BAA+B;AAC/B,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,6BAA6B;AAC7B,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,kCAAkC;AAClC,UAAU,kBAAkB;IAC1B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,oCAAoC;AACpC,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,kCAAkC;AAClC,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAoED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAYtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAc1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,oBAAoB,GAAG,aAAa,GAAG,SAAS,CA2CxG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAkDnG"}
@@ -1,4 +1,6 @@
1
1
  export * from './entries';
2
2
  export * from './services';
3
3
  export * from './utils';
4
+ export * from './handlers';
5
+ export * from './formatter';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -3,5 +3,5 @@
3
3
  * Attempts to fetch country code from external API with timeout
4
4
  */
5
5
  export declare function detectCountryFromGeoIP(url?: string, timeout?: number): Promise<string | null>;
6
- export declare function detectByGeoIp(hasCountry: (code: string) => boolean): Promise<string | null>;
6
+ export declare function detectByGeoIp(): Promise<string | null>;
7
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/services/geoip/utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,SAAiB,EACpB,OAAO,SAAoB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwBxB;AAED,wBAAsB,aAAa,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgCjG"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/services/geoip/utils.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,SAAiB,EACpB,OAAO,SAAoB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwBxB;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoC5D"}
@@ -1,14 +1,17 @@
1
- import { MaskFull, MaskFullMap } from './entries';
1
+ import { MaskFull } from './entries';
2
2
  export type FormatResult = {
3
3
  display: string;
4
4
  map: number[];
5
5
  };
6
6
  /** Get navigator language with fallback to 'en' */
7
7
  export declare function getNavigatorLang(): string;
8
- /** Get full mask map for a given locale */
9
- export declare function getMasksFullMapByLocale(locale: string): MaskFullMap;
8
+ /** Detect country from browser locale */
9
+ export declare function detectCountryFromLocale(): string | null;
10
+ /** Check if a country exists in the full mask map */
11
+ export declare function hasCountry(code: string): boolean;
10
12
  /** Get country data by ISO code and locale with fallback to US */
11
13
  export declare function getCountry(code: string, locale: string): MaskFull;
14
+ export declare function parseCountryCode(code?: string | null, fallback?: string): string;
12
15
  /** Ensure mask is an array of strings */
13
16
  export declare function toArray<T>(mask: T | T[]): T[];
14
17
  /** Count number of placeholders (#) in a mask string */
@@ -19,4 +22,6 @@ export declare function removeCountryCodePrefix(maskStr: string): string;
19
22
  export declare function pickMaskVariant(variants: string[], typedDigitsCount: number): string;
20
23
  /** Formatting with mapping for efficient position tracking */
21
24
  export declare function formatDigitsWithMap(maskTemplate: string, digitStr: string): FormatResult;
25
+ /** Filter and rank countries by a search query */
26
+ export declare function filterCountries(countries: MaskFull[], search: string): MaskFull[];
22
27
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,2CAA2C;AAC3C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAKnE;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CASjE;AAED,yCAAyC;AACzC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAgBpF;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAgCxF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,yCAAyC;AACzC,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAkBvD;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhD;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CASjE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED,yCAAyC;AACzC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAiBpF;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAgCxF;AAED,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAiCjF"}
@@ -0,0 +1,27 @@
1
+ import type { MaskFull } from './entries';
2
+ export type FormatResult = {
3
+ display: string;
4
+ map: number[];
5
+ };
6
+ /** Get navigator language with fallback to 'en' */
7
+ export declare function getNavigatorLang(): string;
8
+ /** Detect country from browser locale */
9
+ export declare function detectCountryFromLocale(): string | null;
10
+ /** Check if a country exists in the full mask map */
11
+ export declare function hasCountry(code: string): boolean;
12
+ /** Get country data by ISO code and locale with fallback to US */
13
+ export declare function getCountry(code: string, locale: string): MaskFull;
14
+ export declare function parseCountryCode(code?: string | null, fallback?: string): string;
15
+ /** Ensure mask is an array of strings */
16
+ export declare function toArray<T>(mask: T | T[]): T[];
17
+ /** Count number of placeholders (#) in a mask string */
18
+ export declare function countPlaceholders(maskStr: string): number;
19
+ /** Remove country code prefix (e.g., +1 ) from a mask string */
20
+ export declare function removeCountryCodePrefix(maskStr: string): string;
21
+ /** Pick the most suitable mask variant based on typed digits count */
22
+ export declare function pickMaskVariant(variants: string[], typedDigitsCount: number): string;
23
+ /** Formatting with mapping for efficient position tracking */
24
+ export declare function formatDigitsWithMap(maskTemplate: string, digitStr: string): FormatResult;
25
+ /** Filter and rank countries by a search query */
26
+ export declare function filterCountries(countries: MaskFull[], search: string): MaskFull[];
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,yCAAyC;AACzC,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAkBvD;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhD;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CASjE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED,yCAAyC;AACzC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAiBpF;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAgCxF;AAED,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAiCjF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desource/phone-mask",
3
- "version": "0.3.0",
3
+ "version": "1.1.0",
4
4
  "description": "⚡ Ultra-lightweight international phone number formatter & validator with auto-sync to Google libphonenumber. Framework-agnostic core library.",
5
5
  "keywords": [
6
6
  "phone",
@@ -32,9 +32,13 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "main": "dist/phone-mask.cjs.js",
35
+ "type": "module",
36
+ "main": "dist/phone-mask.cjs",
36
37
  "module": "dist/esm/index.js",
37
38
  "types": "dist/types/index.d.ts",
39
+ "unpkg": "dist/phone-mask.umd.min.js",
40
+ "jsdelivr": "dist/phone-mask.umd.min.js",
41
+ "browser": "dist/phone-mask.umd.min.js",
38
42
  "files": [
39
43
  "dist",
40
44
  "CHANGELOG.md",
@@ -45,20 +49,26 @@
45
49
  ".": {
46
50
  "types": "./dist/types/index.d.ts",
47
51
  "import": "./dist/esm/index.js",
48
- "require": "./dist/phone-mask.cjs.js"
49
- }
52
+ "require": "./dist/phone-mask.cjs",
53
+ "default": "./dist/esm/index.js"
54
+ },
55
+ "./package.json": "./package.json"
50
56
  },
51
57
  "devDependencies": {
52
- "@rollup/plugin-terser": "^0.4.4",
58
+ "@rollup/plugin-terser": "^1.0.0",
53
59
  "google-libphonenumber": "^3.2.44",
54
60
  "vite-plugin-dts": "^4.5.4"
55
61
  },
56
62
  "scripts": {
57
- "clean": "rimraf dist",
58
- "build": "vite build",
63
+ "clean": "rimraf dist coverage tsconfig.tsbuildinfo",
64
+ "build": "pnpm clean && pnpm build:internal",
65
+ "build:internal": "pnpm build:lib && pnpm build:types",
66
+ "build:lib": "vite build",
59
67
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
60
68
  "dev": "vite",
61
69
  "typecheck": "tsc -p tsconfig.json --noEmit",
70
+ "test:unit": "vitest run --config vitest.config.ts",
71
+ "test:unit:coverage": "vitest run --config vitest.config.ts --coverage.enabled --coverage.provider=v8 --coverage.reporter=lcov --coverage.reportsDirectory=coverage",
62
72
  "gen": "pnpm add -D google-libphonenumber@latest && node scripts/gen.js"
63
73
  }
64
74
  }