@jdlien/validator-utils 1.2.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 JD Lien
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- This package is a library of utility functions that can be used for validating and sanitizing
6
- strings and numbers, especially for use in forms. This package is the dependency for the [@jdlien/validator package](https://github.com/jdlien/validator).
5
+ The Validator Utils package is a lightweight (~15KB or ~5KB gzipped) library of utility functions that can validate and sanitize
6
+ dates, times, strings, numbers, and more. This is especially useful in forms. This package is the sole dependency for the [@jdlien/validator package](https://github.com/jdlien/validator).
7
7
 
8
8
  This package was separated from Validator so that it could be used in other projects without
9
9
  pulling in the entire Validator package if you only need some of its validation and parsing functions without the form validation and error message functionality.
@@ -16,17 +16,48 @@ npm install @jdlien/validator-utils
16
16
  # or
17
17
 
18
18
  yarn add @jdlien/validator-utils
19
+
20
+ # or
21
+
22
+ pnpm add @jdlien/validator-utils
19
23
  ```
20
24
 
21
25
  ## Utility Functions
22
26
 
23
27
  Validator includes several utility functions that may be useful in your own code, so they are exported as part of the module.
24
- If you wish to use these, you may import the functions directly from the module as an object that contains all the functions:
28
+ If you're using a bundler:
29
+
30
+ ```javascript
31
+ import { parseDate, formatDateTime } from '@jdlien/validator-utils'
32
+ ```
33
+
34
+ If you're using CommonJS:
35
+
36
+ ```javascript
37
+ const { parseDate, formatDateTime } = require('@jdlien/validator-utils')
38
+ ```
39
+
40
+ If you prefer to access the utilities as a single object:
25
41
 
26
42
  ```javascript
27
- import * as validatorUtils from '@jdlien/validator'
43
+ import * as validatorUtils from '@jdlien/validator-utils'
28
44
  // you could assign the functions you need to more convenient variables
29
- const { dateFormat, formatDateTime } = validatorUtils
45
+ const { parseDate, formatDateTime } = validatorUtils
46
+ ```
47
+
48
+ If you are not using a bundler, you can load a UMD or ESM build directly:
49
+
50
+ ```html
51
+ <!-- UMD (global validatorUtils) -->
52
+ <script src="https://unpkg.com/@jdlien/validator-utils/dist/validator-utils.js"></script>
53
+ <script>
54
+ const { parseDate, formatDateTime } = validatorUtils
55
+ </script>
56
+
57
+ <!-- ESM (module) -->
58
+ <script type="module">
59
+ import { parseDate, formatDateTime } from 'https://unpkg.com/@jdlien/validator-utils/dist/validator-utils.mjs'
60
+ </script>
30
61
  ```
31
62
 
32
63
  Here is a list of the utility functions:
@@ -42,7 +73,8 @@ Here is a list of the utility functions:
42
73
  - **formatDateTime**: Formats a date string or Date object into a string with a specified format.
43
74
  - **parseDateToString**: Parses a date string or Date object into a formatted string with the specified moment.js-style date format.
44
75
  - **isDate**: Determines if a value is a valid date.
45
- - **isDateInRange**: Determines if a date falls within a specified range (either past or future).
76
+ - **isDateInRange**: Determines if a date falls within a specified range. Supports keywords (`past`, `future`, `today`), specific date ranges (`2023-01-01:2023-12-31`), open-ended ranges (`:2025-12-31`, `2020-01-01:`), relative offsets (`-30d:+30d`, `-1y:`, `:+6m`), and date-time bounds (`2024-01-01T12:00:2024-01-01T14:00`).
77
+ - **parseRelativeDate**: Parses a relative date offset (e.g., `-30d`, `+2w`, `30d`, `-6m`, `+1y`) into a Date object.
46
78
  - **isTime**: Determines if a value is a valid time.
47
79
  - **isEmail**: Determines if a value is a valid email address.
48
80
  - **parseNANPTel**: Parses a North American phone number string into a standardized format.
@@ -50,6 +82,8 @@ Here is a list of the utility functions:
50
82
  - **parseInteger**: Parses an integer string into a standardized format.
51
83
  - **isNumber**: Determines if a value is a valid number.
52
84
  - **parseNumber**: Parses a number string into a standardized format.
85
+ - **parseBytes**: Parses a human-readable byte size (e.g., "1.5 MB", "2GiB") into bytes.
86
+ - **formatBytes**: Formats a byte count as a human-readable string (e.g., "1.5 MB", "512 B").
53
87
  - **isInteger**: Determines if a value is a valid integer.
54
88
  - **parseUrl**: Parses a URL string into a standardized format.
55
89
  - **isUrl**: Determines if a value is a valid URL.
@@ -66,14 +100,17 @@ Here is a list of the utility functions:
66
100
  Install dev dependencies:
67
101
 
68
102
  ```bash
69
- npm install
103
+ pnpm install
70
104
  ```
71
105
 
72
- When running Vite, you may get an error like
106
+ Run tests with coverage (100% required for release):
73
107
 
108
+ ```bash
109
+ pnpm coverage
74
110
  ```
75
- Module did not self-register: '...\node_modules\canvas\build\Release\canvas.node'
76
- ```
77
111
 
78
- If that happens, you
79
- need to install the canvas module manually: `bash npm rebuild canvas --update-binary `
112
+ Build the project for testing/release:
113
+
114
+ ```bash
115
+ pnpm build
116
+ ```
@@ -0,0 +1 @@
1
+ export { isFormControl, isType, monthToNumber, yearToFull, parseDate, parseDateTime, parseTime, parseTimeToString, parseDateTimeToString, formatDateTime, momentToFPFormat, parseDateToString, isDate, isDateInRange, parseRelativeDate, isMeridiem, isDateTime, isTime, isEmail, parseNANPTel, isNANPTel, parseInteger, isNumber, parseNumber, isInteger, parseBytes, formatBytes, parseUrl, isUrl, parseZip, isZip, parsePostalCA, isPostalCA, isColor, parseColor, normalizeValidationResult, } from './src/validator-utils';
@@ -1,48 +1,54 @@
1
1
  /**
2
- * Utilities used by the Validator class.
3
- *
4
- * @format
2
+ * Validator Utils - Lightweight validation and parsing utilities
3
+ * Used by the @jdlien/validator package
5
4
  */
6
- type DateParts = {
7
- year: number;
8
- month: number;
9
- day: number;
10
- };
11
- export declare function isFormControl(el: any): boolean;
12
- interface ValidationResult {
13
- valid: boolean;
14
- error?: boolean;
15
- messages: string[];
16
- }
17
- export declare function isType(el: HTMLInputElement | HTMLTextAreaElement, types: string | string[]): boolean;
18
- export declare function momentToFPFormat(format: string): string;
19
- export declare function monthToNumber(str: string | number): number;
20
- export declare function yearToFull(year: number | string): number;
21
- export declare function parseDate(value: string | Date): Date;
22
- export declare function guessDatePart(num: number, knownMeanings?: (string | null)[]): string[];
23
- export declare function guessDateParts(str: string): DateParts;
24
5
  export declare function parseTime(value: string): {
25
6
  hour: number;
26
7
  minute: number;
27
8
  second: number;
28
9
  } | null;
29
- export declare function parseTimeToString(value: string, format?: string): string;
10
+ export declare function isTime(value: string): boolean;
11
+ export declare function isMeridiem(token: string): boolean;
12
+ export declare function yearToFull(y: number | string): number;
13
+ export declare function parseDate(value: string | Date): Date;
30
14
  export declare function parseDateTime(value: string | Date): Date | null;
31
15
  export declare function formatDateTime(date: Date | string, format?: string): string;
32
- export declare function parseDateToString(value: string | Date, format?: string): string;
33
- export declare function parseDateTimeToString(value: string | Date, format?: string): string;
16
+ export declare function momentToFPFormat(format: string): string;
34
17
  export declare function isDate(value: string | Date): boolean;
35
18
  export declare function isDateTime(value: string | Date): boolean;
19
+ export declare function parseDateToString(value: string | Date, format?: string): string;
20
+ export declare function parseDateTimeToString(value: string | Date, format?: string): string;
21
+ export declare function parseTimeToString(value: string, format?: string): string;
22
+ export declare function monthToNumber(str: string | number): number;
23
+ /**
24
+ * Parses a relative date offset like "-30d", "+2w", "30d", "-6m", "+1y"
25
+ * Returns a Date object relative to today, or null if invalid
26
+ */
27
+ export declare function parseRelativeDate(offset: string): Date | null;
36
28
  export declare function isDateInRange(date: Date, range: string): boolean;
37
- export declare function isMeridiem(token: string): boolean;
38
- export declare function isTime(value: string): boolean;
29
+ export declare function isFormControl(el: any): boolean;
30
+ export declare function isType(el: HTMLInputElement | HTMLTextAreaElement, types: string | string[]): boolean;
39
31
  export declare function isEmail(value: string): boolean;
40
32
  export declare function parseNANPTel(value: string): string;
41
33
  export declare function isNANPTel(value: string): boolean;
42
34
  export declare function parseInteger(value: string): string;
43
- export declare function isNumber(value: string): boolean;
44
- export declare function parseNumber(value: string): string;
45
35
  export declare function isInteger(value: string): boolean;
36
+ export declare function parseNumber(value: string): string;
37
+ export declare function isNumber(value: string): boolean;
38
+ /**
39
+ * Parses a human-readable byte size string into bytes.
40
+ * Accepts: 500, 5B, 5K, 5KB, 5KiB, 5Ki, 5M, 5MB, 5MiB, etc.
41
+ * SI units (KB, MB) use powers of 1000; binary units (KiB, MiB) use powers of 1024.
42
+ * Returns NaN for invalid input.
43
+ */
44
+ export declare function parseBytes(value: string): number;
45
+ /**
46
+ * Formats bytes as a human-readable string.
47
+ * @param bytes - The number of bytes
48
+ * @param decimal - If true (default), uses SI units (1000-based). If false, uses binary (1024-based).
49
+ * @returns Formatted string like "1.5 MB" or "512 B"
50
+ */
51
+ export declare function formatBytes(bytes: number, decimal?: boolean): string;
46
52
  export declare function parseUrl(value: string): string;
47
53
  export declare function isUrl(value: string): boolean;
48
54
  export declare function parseZip(value: string): string;
@@ -51,6 +57,11 @@ export declare function parsePostalCA(value: string): string;
51
57
  export declare function isPostalCA(value: string): boolean;
52
58
  export declare function isColor(value: string): boolean;
53
59
  export declare function parseColor(value: string): string;
60
+ interface ValidationResult {
61
+ valid: boolean;
62
+ error?: boolean;
63
+ messages: string[];
64
+ }
54
65
  export declare function normalizeValidationResult(res: boolean | string | {
55
66
  valid: boolean;
56
67
  message?: string;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=/^(?:[a-z+]+:)?\/\//i,C=/^(?:[-a-z+]+:)?\/\//i,R=/^\d{5}(-\d{4})?$/,H=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,_=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,I=/^\d{3}-\d{3}-\d{4}$/,B=/^-?\d*$/,L=/^-?\d*\.?\d*$/;function h(e){let t=e.trim().toLowerCase();if(t==="now"){const u=new Date;return{hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds()}}if(t==="noon")return{hour:12,minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let i=+s[1],a=+(s[2]||0),o=+(s[3]||0);const c=s[4]?.toLowerCase();return c==="p"&&i<12&&(i+=12),c==="a"&&i===12&&(i=0),i>23||a>59||o>59?null:{hour:i,minute:a,second:o}}function P(e){return h(e)!==null}function Z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const z="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",A=new RegExp(`(${z})[a-z]*`,"i");function O(e){return new Date(`1 ${e} 2000`).getMonth()}function M(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function T(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="tomorrow")return new Date(n.setDate(n.getDate()+1));t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let s=0,i=0,a=0;const o=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(o){const p=h(o[1]);if(p&&({hour:s,minute:i,second:a}=p),t=t.replace(o[0],"").trim(),!t||t.length<=2){const g=new Date;return new Date(g.getFullYear(),g.getMonth(),g.getDate(),s,i,a)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),s,i,a);if(/^\d{6}$/.test(t))return new Date(M(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),s,i,a);const c=t.match(A);let u=-1,l=0,r=0;c&&(u=O(c[1]),t=t.replace(c[0]," ").trim());const m=t.match(/'(\d{2})\b/);m&&(l=M(+m[1]),t=t.replace(m[0]," ").trim());const d=t.match(/\d+/g)?.map(Number)||[];if(u>=0)d.length>=2?d[0]>99?(l=d[0],r=d[1]):d[1]>99?(l=d[1],r=d[0]):d[0]>31?(r=d[1],l=M(d[0])):d[1]>31?(r=d[0],l=M(d[1])):(r=d[0],l=l||M(d[1])):d.length===1&&(r=d[0],l=l||new Date().getFullYear());else if(d.length>=3){const[p,g,f]=d;p>31?(l=p,u=g-1,r=f):p>12&&f>12?(r=p,u=g-1,l=f>31?f:M(f)):f>31||f>12?(u=p-1,r=g,l=f>31?f:M(f)):(g>12,u=p-1,r=g,l=M(f))}else d.length===2&&(u=d[0]-1,r=d[1],l=l||new Date().getFullYear());return l&&u>=0&&r&&r>=1&&r<=31?new Date(l>99?l:M(l),u,r,s,i,a):new Date("")}function w(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(c,u,l,r,m)=>`${u}${m?`${l}:${r}:${m}`:`${l}:${r}`}`),/^now$/i.test(t)){const c=new Date;return c.setMilliseconds(0),c}if(/^noon$/i.test(t)){const c=new Date;return new Date(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0)}let n=null,s=t;const i=[/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const c of i){const u=t.match(c);if(u){const l=h(u[0]);if(l){n=l,s=t.replace(u[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const c=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(c){const u=c[2],l=(c[3]||"").replace(/\s+/g,"");let r=u+l;u.length===6&&(r=`${u.slice(0,2)}:${u.slice(2,4)}:${u.slice(4,6)}${l}`);const m=h(r);m&&(n=m,s=c[1])}}if(!n){const c=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(c){const u=c[2]+(c[3]||""),l=h(u);l&&A.test(c[1])&&(n=l,s=c[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const c=new Date;return new Date(c.getFullYear(),c.getMonth(),c.getDate(),n.hour,n.minute,n.second)}const a=T(s);if(isNaN(a.getTime()))return null;const o=n||{hour:0,minute:0,second:0};return new Date(a.getFullYear(),a.getMonth(),a.getDate(),o.hour,o.minute,o.second)}function Y(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=T(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),i=e.getDate(),a=e.getDay(),o=e.getHours(),c=e.getMinutes(),u=e.getSeconds(),l=e.getMilliseconds(),r=(b,$=2)=>String(b).padStart($,"0"),m=o%12||12,d=o<12?"AM":"PM",p=["January","February","March","April","May","June","July","August","September","October","November","December"],g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f={YYYY:n,YY:String(n).slice(-2),MMMM:p[s],MMM:p[s].slice(0,3),MM:r(s+1),M:s+1,DD:r(i),D:i,dddd:g[a],ddd:g[a].slice(0,3),dd:g[a].slice(0,2),d:a,HH:r(o),H:o,hh:r(m),h:m,mm:r(c),m:c,ss:r(u),s:u,SSS:r(l,3),A:d,a:d.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(b,$)=>$??String(f[b]))}const j={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function U(e){return e.replace(K,t=>j[t])}function x(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(T(e).getTime())}function G(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=w(e);return t!==null&&!isNaN(t.getTime())}function V(e,t="YYYY-MMM-DD"){const n=T(e);return isNaN(n.getTime())?"":Y(n,t)}function k(e,t="YYYY-MMM-DD h:mm A"){const n=w(e);return n&&!isNaN(n.getTime())?Y(n,t):""}function J(e,t="h:mm A"){const n=h(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),Y(s,t)}const y={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function W(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const i in y)if(s.startsWith(i))return y[i];throw new Error("Invalid month name: "+e)}function E(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,i]=t,a=parseInt(s)*(n==="-"?-1:1),o=new Date;switch(o.setHours(0,0,0,0),i.toLowerCase()){case"d":o.setDate(o.getDate()+a);break;case"w":o.setDate(o.getDate()+a*7);break;case"m":o.setMonth(o.getMonth()+a);break;case"y":o.setFullYear(o.getFullYear()+a);break}return o}const S=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i,X=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function v(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const r=new Date;return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}const n=r=>{const m=r.trim();if(!m)return{date:null,hasTime:!1,valid:!0};const d=E(m);if(d)return{date:d,hasTime:!1,valid:!0};const p=m.search(X);if(p===-1)return{date:null,hasTime:!1,valid:!1};const g=m.search(S);if(g!==-1&&g<p)return{date:null,hasTime:!1,valid:!1};const f=w(m);return f&&!isNaN(f.getTime())?{date:f,hasTime:S.test(m),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let r=0;r<t.length;r+=1){if(t[r]!==":")continue;const m=n(t.slice(0,r)),d=n(t.slice(r+1));if(m.valid&&d.valid){s={start:m,end:d};break}}if(!s){const r=n(t);return r.valid&&r.date?r.hasTime?e.getTime()===r.date.getTime():e.getFullYear()===r.date.getFullYear()&&e.getMonth()===r.date.getMonth()&&e.getDate()===r.date.getDate():!0}const i=s.start,a=s.end,c=i.hasTime||a.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let u=null;i.date&&(u=i.hasTime?i.date.getTime():new Date(i.date.getFullYear(),i.date.getMonth(),i.date.getDate()).getTime());let l=null;return a.date&&(l=a.hasTime?a.date.getTime():new Date(a.date.getFullYear(),a.date.getMonth(),a.date.getDate(),23,59,59,999).getTime()),!(u!==null&&c<u||l!==null&&c>l)}function q(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Q(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function ee(e){return e.length<=255&&_.test(e)}function te(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function ne(e){return I.test(e)}function re(e){return e.replace(/[^0-9]/g,"")}function se(e){return B.test(e)}function ie(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,i=!1;for(let a=0;a<t.length;a+=1){const o=t[a];if(o==="-"){!i&&n.length===0&&(n+="-",i=!0);continue}if(o==="."){s||(n+=".",s=!0);continue}n+=o}return n}function ae(e){return L.test(e)}const oe={"":1,K:1e3,M:1e6,G:1e9,T:1e12},ce={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function le(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),i=n[2]?.toUpperCase()||"",a=i.includes("I"),o=i.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(a?ce:oe)[o]}function ue(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let i=0,a=e;for(;a>=n&&i<s.length-1;)a/=n,i++;let o=Math.round(a*10)/10;return o>=n&&i<s.length-1&&(o=1,i++),`${o%1===0?o.toFixed(0):o.toFixed(1)} ${s[i]}`}function de(e){return e=e.trim(),F.test(e)?e:"https://"+e}function me(e){return C.test(e)}function fe(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function ge(e){return R.test(e)}function pe(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Me(e){return H.test(e)}function he(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let D=null;const N=new Map;function Te(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);D||(D=document.createElement("canvas"),D.willReadFrequently=!0);const t=D.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function De(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}exports.formatBytes=ue;exports.formatDateTime=Y;exports.isColor=he;exports.isDate=x;exports.isDateInRange=v;exports.isDateTime=G;exports.isEmail=ee;exports.isFormControl=q;exports.isInteger=se;exports.isMeridiem=Z;exports.isNANPTel=ne;exports.isNumber=ae;exports.isPostalCA=Me;exports.isTime=P;exports.isType=Q;exports.isUrl=me;exports.isZip=ge;exports.momentToFPFormat=U;exports.monthToNumber=W;exports.normalizeValidationResult=De;exports.parseBytes=le;exports.parseColor=Te;exports.parseDate=T;exports.parseDateTime=w;exports.parseDateTimeToString=k;exports.parseDateToString=V;exports.parseInteger=re;exports.parseNANPTel=te;exports.parseNumber=ie;exports.parsePostalCA=pe;exports.parseRelativeDate=E;exports.parseTime=h;exports.parseTimeToString=J;exports.parseUrl=de;exports.parseZip=fe;exports.yearToFull=M;
@@ -1 +1 @@
1
- (function(i,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(i=typeof globalThis<"u"?globalThis:i||self,f(i.validatorUtils={}))})(this,function(i){"use strict";function f(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function $(e,n){typeof n=="string"&&(n=[n]);const t=e.dataset.type||"",r=e.type;return!!(n.includes(t)||n.includes(r))}function k(e){return e.replace(/YYYY/g,"Y").replace(/YY/g,"y").replace(/MMMM/g,"F").replace(/MMM/g,"{3}").replace(/MM/g,"{2}").replace(/M/g,"n").replace(/DD/g,"{5}").replace(/D/g,"j").replace(/dddd/g,"l").replace(/ddd/g,"D").replace(/dd/g,"D").replace(/d/g,"w").replace(/HH/g,"{6}").replace(/H/g,"G").replace(/hh/g,"h").replace(/mm/g,"i").replace(/m/g,"i").replace(/ss/g,"S").replace(/s/g,"s").replace(/A/gi,"K").replace(/\{3\}/g,"M").replace(/\{2\}/g,"m").replace(/\{5\}/g,"d").replace(/\{6\}/g,"H")}function M(e){const n=parseInt(e);if(typeof e=="number"||!isNaN(n))return n-1;const t=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(t))return t;const r={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};for(const l in r)if(e.toLowerCase().startsWith(l))return r[l];throw new Error("Invalid month name: "+e)}function w(e){return typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99?e:e<(new Date().getFullYear()+20)%100?e+2e3:e+1900}function m(e){if(e instanceof Date)return e;e=e.trim().toLowerCase();let n=0,t=0,r=0,l=0,s=0,a=0;const d=new RegExp(/\d{1,2}\:\d\d(?:\:\d\ds?)?\s?(?:[a|p]m?)?/gi);if(d.test(e)){const u=e.match(d)[0];e=e.replace(u,"").trim();const g=p(u);if(g!==null&&({hour:l,minute:s,second:a}=g),e.length<=2){const b=new Date;return new Date(b.getFullYear(),b.getMonth(),b.getDate(),l,s,a)}}const c=/(^|\b)(mo|tu|we|th|fr|sa|su|lu|mard|mer|jeu|ve|dom)[\w]*\.?/gi;e=e.replace(c,"").trim();const o=new Date(new Date().setHours(0,0,0,0));if(/(now|today)/.test(e))return o;if(e.includes("tomorrow"))return new Date(o.setDate(o.getDate()+1));e.length===8&&(e=e.replace(/(\d\d\d\d)(\d\d)(\d\d)/,"$1-$2-$3")),e.length===6&&(e=e.replace(/(\d\d)(\d\d)(\d\d)/,w(e.slice(0,2))+"-$2-$3"));try{({year:n,month:t,day:r}=Y(e))}catch{return new Date("")}return new Date(n,t-1,r,l,s,a)}function A(e,n=[null,null,null]){const t=r=>r.filter(l=>!n.includes(l));return e===0||e>31?t(["y"]):e>12?t(["d","y"]):e>=1&&e<=12?t(["m","d","y"]):[]}function Y(e){const n=e.split(/[\s-/:.,]+/).filter(s=>s!=="");if(n.length<3){if(e.match(/\d{4}/)!==null)throw new Error("Invalid Date");n.unshift(String(new Date().getFullYear()))}const t={year:0,month:0,day:0};function r(s,a){s==="year"?t.year=w(a):t[s]=a}let l=0;for(;!(t.year&&t.month&&t.day);){e:for(const s of n){if(l++,/^[a-zA-Zé]+$/.test(s)){t.month||r("month",M(s)+1);continue}if(/^'\d\d$/.test(s)||/^\d{3,5}$/.test(s)){t.year||r("year",parseInt(s.replace(/'/,"")));continue}const a=parseInt(s);if(isNaN(a))throw console.error(`not date because ${s} isNaN`),new Error("Invalid Date");const d=A(a,[t.year?"y":null,t.month?"m":null,t.day?"d":null]);if(d.length==1){if(d[0]==="m"&&!t.month){r("month",a);continue e}if(d[0]==="d"&&!t.day){r("day",a);continue e}if(d[0]==="y"&&!t.year){r("year",a);continue e}}l>3&&(!t.month&&d.includes("m")?r("month",a):!t.day&&d.includes("d")&&r("day",a))}if(l>6)throw new Error("Invalid Date")}if(t.year&&t.month&&t.day)return t;throw new Error("Invalid Date")}function p(e){if(e=e.trim().toLowerCase(),e==="now"){const o=new Date;return{hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds()}}if(e==="noon")return{hour:12,minute:0,second:0};const n=e.match(/(\d{3,4})/);if(n){const o=n[1].length,u=n[1].slice(0,o==3?1:2),g=n[1].slice(-2);e=e.replace(n[1],u+":"+g)}const t=new RegExp(/^(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)\.?m?\.?)?$/i);if(t.test(e)){const o=e.match(t);if(o===null)return null;e=o[1]+":"+(o[2]||"00")+(o[3]||"")}const r=new RegExp(/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)m?)?$/i);if(!r.test(e))return null;const l=e.match(r);if(l===null)return null;const s=parseInt(l[1]),a=parseInt(l[2]),d=l[3]?parseInt(l[3]):0,c=l[4];return isNaN(s)||isNaN(a)||isNaN(d)?null:c==="p"&&s<12?{hour:s+12,minute:a,second:d}:c==="a"&&s===12?{hour:0,minute:a,second:d}:s<0||s>23||a<0||a>59||d<0||d>59?null:{hour:s,minute:a,second:d}}function E(e,n="h:mm A"){const t=p(e);if(t){const r=new Date;return r.setHours(t.hour),r.setMinutes(t.minute),r.setSeconds(t.second),r.setMilliseconds(0),h(r,n)}return""}function D(e){if(e instanceof Date)return e;if(e.trim().length<3)return null;e=e.replace(/(\d)T(\d)/,"$1 $2");let n=e.split(/[\s,]+/).filter(c=>c!==""),t="",r="",l="";n.forEach((c,o)=>{const u=c.match(/^(\d{1,4})([apAP]\.?[mM]?\.?)/);u?r=u[0]:(c.includes(":")||c==="now"||c==="noon")&&(r=c),R(c)&&(l=c,!r&&o>0&&S(n[o-1])&&(r=n[o-1]))}),r?n=n.filter(c=>c!==r&&c!==l):[t,n]=C(n);const s=r?`${r} ${l}`:t?n.join(" "):"",a=p(s)||{hour:0,minute:0,second:0},d=m(t||n.join(" ").trim()||"today");return!d||isNaN(d.getTime())?null:new Date(d.getFullYear(),d.getMonth(),d.getDate(),a.hour,a.minute,a.second)}function C(e){for(let n=3;n>0;n--){const t=e.slice(0,n).join(" ");if(N(t))return[t,e.slice(n)]}return["",e]}function h(e,n="YYYY-MM-DD"){if(e=m(e),isNaN(e.getTime()))return"";const t={y:e.getFullYear(),M:e.getMonth(),D:e.getDate(),W:e.getDay(),H:e.getHours(),m:e.getMinutes(),s:e.getSeconds(),ms:e.getMilliseconds()},r=(o,u=2)=>(o+"").padStart(u,"0"),l=()=>t.H%12||12,s=o=>o<12?"AM":"PM",a=o=>"January|February|March|April|May|June|July|August|September|October|November|December".split("|")[o];function d(o,u=0){const g="Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday".split("|");return u?g[o].slice(0,u):g[o]}const c={YY:String(t.y).slice(-2),YYYY:t.y,M:t.M+1,MM:r(t.M+1),MMMM:a(t.M),MMM:a(t.M).slice(0,3),D:String(t.D),DD:r(t.D),d:String(t.W),dd:d(t.W,2),ddd:d(t.W,3),dddd:d(t.W),H:String(t.H),HH:r(t.H),h:l(),hh:r(l()),A:s(t.H),a:s(t.H).toLowerCase(),m:String(t.m),mm:r(t.m),s:String(t.s),ss:r(t.s),SSS:r(t.ms,3)};return n.replace(/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,(o,u)=>u||c[o])}function x(e,n){const t=m(e);return isNaN(t.getTime())?"":((!n||n.length===0)&&(n="YYYY-MMM-DD"),h(t,n))}function H(e,n){const t=D(e);return t===null||isNaN(t.getTime())?"":((!n||n.length===0)&&(n="YYYY-MMM-DD h:mm A"),h(t,n))}function N(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let n=m(e);return n==null?!1:!isNaN(n.getTime())}function P(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let n=D(e);return n==null?!1:!isNaN(n.getTime())}function I(e,n){return!(n==="past"&&e>new Date||n==="future"&&e.getTime()<new Date().setHours(0,0,0,0))}function R(e){const n=e.toLowerCase().replace(/[.\s]/g,"");return["am","pm","a","p"].includes(n)}function S(e){let n=p(e);return n===null?!1:!isNaN(n.hour)&&!isNaN(n.minute)&&!isNaN(n.second)}function z(e){if(e.length>255||!new RegExp(/^.+@.+\.[a-zA-Z0-9]{2,}$/).test(e))return!1;let t="";return t+="^([a-zA-Z0-9!#$%'*+/=?^_`{|}~-]+",t+="(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*",t+="|",t+='"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*"',t+=")@(",t+="(",t+="(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+",t+="[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?",t+=")",t+=")$",new RegExp(t).test(e)}function Z(e){return e=e.replace(/^[^2-90]+/g,""),e=e.replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4"),e}function F(e){return/^\d\d\d-\d\d\d-\d\d\d\d$/.test(e)}function L(e){return e.replace(/[^0-9]/g,"")}function j(e){return/^\-?\d*\.?\d*$/.test(e)}function q(e){return e.replace(/[^\-0-9.]/g,"").replace(/(^-)|(-)/g,(n,t)=>t?"-":"").replace(/(\..*)\./g,"$1")}function W(e){return/^\-?\d*$/.test(e)}function U(e){return e=e.trim(),new RegExp("^(?:[a-z+]+:)?//","i").test(e)?e:"https://"+e}function J(e){return new RegExp("^(?:[-a-z+]+:)?//","i").test(e)}function V(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6&&(e=e.replace(/-/,"")),e}function G(e){return new RegExp(/^\d{5}(-\d{4})?$/).test(e)}function K(e){return e=e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim(),e}function O(e){return new RegExp(/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/).test(e)}function B(e){return["transparent","currentColor"].includes(e)?!0:typeof e!="string"||!e.trim()?!1:typeof CSS=="object"&&typeof CSS.supports=="function"?CSS.supports("color",e):X(e)}function X(e){const n=new RegExp(/^rgba?\(\s*(\d{1,3}%?,\s*){2}\d{1,3}%?\s*(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),t=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?,\s*\d{1,3}%,\s*\s*\d{1,3}%(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),r=new RegExp(/^rgba?\(\s*(\d{1,3}%?\s+){2}\d{1,3}%?\s*(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),l=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?\s+\d{1,3}%\s+\s*\d{1,3}%(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),s=new RegExp(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);let a="aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";const d=new RegExp(`^(${a})$`,"i");return n.test(e)||t.test(e)||r.test(e)||l.test(e)||s.test(e)||d.test(e)}let y=null;const T=new Map;function _(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(T.has(e))return T.get(e);y===null&&(y=document.createElement("canvas"),y.willReadFrequently=!0);let n=y.getContext("2d");if(!n)throw new Error("Can't get context from colorCanvas");n.fillStyle=e,n.fillRect(0,0,1,1);let t=n.getImageData(0,0,1,1).data,r="#"+("000000"+(t[0]<<16|t[1]<<8|t[2]).toString(16)).slice(-6);return T.set(e,r),r}function Q(e){let n={valid:!1,error:!1,messages:[]};return typeof e=="boolean"?{valid:e,error:!1,messages:[]}:typeof e=="string"?{valid:!1,error:!1,messages:[e]}:(typeof e.valid=="boolean"&&(n.valid=e.valid),typeof e.message=="string"&&(n.messages=[e.message]),typeof e.messages=="string"&&(n.messages=[e.messages]),Array.isArray(e.messages)&&(n.messages=e.messages),e.error===!0&&(n.error=!0),n)}i.formatDateTime=h,i.isColor=B,i.isDate=N,i.isDateInRange=I,i.isDateTime=P,i.isEmail=z,i.isFormControl=f,i.isInteger=W,i.isMeridiem=R,i.isNANPTel=F,i.isNumber=j,i.isPostalCA=O,i.isTime=S,i.isType=$,i.isUrl=J,i.isZip=G,i.momentToFPFormat=k,i.monthToNumber=M,i.normalizeValidationResult=Q,i.parseColor=_,i.parseDate=m,i.parseDateTime=D,i.parseDateTimeToString=H,i.parseDateToString=x,i.parseInteger=L,i.parseNANPTel=Z,i.parseNumber=q,i.parsePostalCA=K,i.parseTime=p,i.parseTimeToString=E,i.parseUrl=U,i.parseZip=V,i.yearToFull=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(a=typeof globalThis<"u"?globalThis:a||self,D(a.validatorUtils={}))})(this,(function(a){"use strict";const D=/^(?:[a-z+]+:)?\/\//i,R=/^(?:[-a-z+]+:)?\/\//i,H=/^\d{5}(-\d{4})?$/,_=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,I=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,B=/^\d{3}-\d{3}-\d{4}$/,L=/^-?\d*$/,P=/^-?\d*\.?\d*$/;function p(e){let t=e.trim().toLowerCase();if(t==="now"){const d=new Date;return{hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds()}}if(t==="noon")return{hour:12,minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let r=+s[1],o=+(s[2]||0),c=+(s[3]||0);const l=s[4]?.toLowerCase();return l==="p"&&r<12&&(r+=12),l==="a"&&r===12&&(r=0),r>23||o>59||c>59?null:{hour:r,minute:o,second:c}}function Z(e){return p(e)!==null}function z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const j="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",A=new RegExp(`(${j})[a-z]*`,"i");function O(e){return new Date(`1 ${e} 2000`).getMonth()}function T(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function w(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="tomorrow")return new Date(n.setDate(n.getDate()+1));t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let s=0,r=0,o=0;const c=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(c){const h=p(c[1]);if(h&&({hour:s,minute:r,second:o}=h),t=t.replace(c[0],"").trim(),!t||t.length<=2){const M=new Date;return new Date(M.getFullYear(),M.getMonth(),M.getDate(),s,r,o)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),s,r,o);if(/^\d{6}$/.test(t))return new Date(T(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),s,r,o);const l=t.match(A);let d=-1,u=0,i=0;l&&(d=O(l[1]),t=t.replace(l[0]," ").trim());const f=t.match(/'(\d{2})\b/);f&&(u=T(+f[1]),t=t.replace(f[0]," ").trim());const m=t.match(/\d+/g)?.map(Number)||[];if(d>=0)m.length>=2?m[0]>99?(u=m[0],i=m[1]):m[1]>99?(u=m[1],i=m[0]):m[0]>31?(i=m[1],u=T(m[0])):m[1]>31?(i=m[0],u=T(m[1])):(i=m[0],u=u||T(m[1])):m.length===1&&(i=m[0],u=u||new Date().getFullYear());else if(m.length>=3){const[h,M,g]=m;h>31?(u=h,d=M-1,i=g):h>12&&g>12?(i=h,d=M-1,u=g>31?g:T(g)):g>31||g>12?(d=h-1,i=M,u=g>31?g:T(g)):(M>12,d=h-1,i=M,u=T(g))}else m.length===2&&(d=m[0]-1,i=m[1],u=u||new Date().getFullYear());return u&&d>=0&&i&&i>=1&&i<=31?new Date(u>99?u:T(u),d,i,s,r,o):new Date("")}function Y(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(l,d,u,i,f)=>`${d}${f?`${u}:${i}:${f}`:`${u}:${i}`}`),/^now$/i.test(t)){const l=new Date;return l.setMilliseconds(0),l}if(/^noon$/i.test(t)){const l=new Date;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),12,0,0)}let n=null,s=t;const r=[/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const l of r){const d=t.match(l);if(d){const u=p(d[0]);if(u){n=u,s=t.replace(d[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const l=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(l){const d=l[2],u=(l[3]||"").replace(/\s+/g,"");let i=d+u;d.length===6&&(i=`${d.slice(0,2)}:${d.slice(2,4)}:${d.slice(4,6)}${u}`);const f=p(i);f&&(n=f,s=l[1])}}if(!n){const l=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(l){const d=l[2]+(l[3]||""),u=p(d);u&&A.test(l[1])&&(n=u,s=l[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const l=new Date;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),n.hour,n.minute,n.second)}const o=w(s);if(isNaN(o.getTime()))return null;const c=n||{hour:0,minute:0,second:0};return new Date(o.getFullYear(),o.getMonth(),o.getDate(),c.hour,c.minute,c.second)}function b(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=w(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),r=e.getDate(),o=e.getDay(),c=e.getHours(),l=e.getMinutes(),d=e.getSeconds(),u=e.getMilliseconds(),i=(y,S=2)=>String(y).padStart(S,"0"),f=c%12||12,m=c<12?"AM":"PM",h=["January","February","March","April","May","June","July","August","September","October","November","December"],M=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={YYYY:n,YY:String(n).slice(-2),MMMM:h[s],MMM:h[s].slice(0,3),MM:i(s+1),M:s+1,DD:i(r),D:r,dddd:M[o],ddd:M[o].slice(0,3),dd:M[o].slice(0,2),d:o,HH:i(c),H:c,hh:i(f),h:f,mm:i(l),m:l,ss:i(d),s:d,SSS:i(u,3),A:m,a:m.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(y,S)=>S??String(g[y]))}const U={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function G(e){return e.replace(K,t=>U[t])}function V(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(w(e).getTime())}function k(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=Y(e);return t!==null&&!isNaN(t.getTime())}function J(e,t="YYYY-MMM-DD"){const n=w(e);return isNaN(n.getTime())?"":b(n,t)}function W(e,t="YYYY-MMM-DD h:mm A"){const n=Y(e);return n&&!isNaN(n.getTime())?b(n,t):""}function v(e,t="h:mm A"){const n=p(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),b(s,t)}const E={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function X(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const r in E)if(s.startsWith(r))return E[r];throw new Error("Invalid month name: "+e)}function F(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,r]=t,o=parseInt(s)*(n==="-"?-1:1),c=new Date;switch(c.setHours(0,0,0,0),r.toLowerCase()){case"d":c.setDate(c.getDate()+o);break;case"w":c.setDate(c.getDate()+o*7);break;case"m":c.setMonth(c.getMonth()+o);break;case"y":c.setFullYear(c.getFullYear()+o);break}return c}const C=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i,q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function Q(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const i=new Date;return e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()}const n=i=>{const f=i.trim();if(!f)return{date:null,hasTime:!1,valid:!0};const m=F(f);if(m)return{date:m,hasTime:!1,valid:!0};const h=f.search(q);if(h===-1)return{date:null,hasTime:!1,valid:!1};const M=f.search(C);if(M!==-1&&M<h)return{date:null,hasTime:!1,valid:!1};const g=Y(f);return g&&!isNaN(g.getTime())?{date:g,hasTime:C.test(f),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let i=0;i<t.length;i+=1){if(t[i]!==":")continue;const f=n(t.slice(0,i)),m=n(t.slice(i+1));if(f.valid&&m.valid){s={start:f,end:m};break}}if(!s){const i=n(t);return i.valid&&i.date?i.hasTime?e.getTime()===i.date.getTime():e.getFullYear()===i.date.getFullYear()&&e.getMonth()===i.date.getMonth()&&e.getDate()===i.date.getDate():!0}const r=s.start,o=s.end,l=r.hasTime||o.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let d=null;r.date&&(d=r.hasTime?r.date.getTime():new Date(r.date.getFullYear(),r.date.getMonth(),r.date.getDate()).getTime());let u=null;return o.date&&(u=o.hasTime?o.date.getTime():new Date(o.date.getFullYear(),o.date.getMonth(),o.date.getDate(),23,59,59,999).getTime()),!(d!==null&&l<d||u!==null&&l>u)}function x(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function ee(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function te(e){return e.length<=255&&I.test(e)}function ne(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function ie(e){return B.test(e)}function se(e){return e.replace(/[^0-9]/g,"")}function re(e){return L.test(e)}function ae(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,r=!1;for(let o=0;o<t.length;o+=1){const c=t[o];if(c==="-"){!r&&n.length===0&&(n+="-",r=!0);continue}if(c==="."){s||(n+=".",s=!0);continue}n+=c}return n}function oe(e){return P.test(e)}const ce={"":1,K:1e3,M:1e6,G:1e9,T:1e12},le={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function ue(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),r=n[2]?.toUpperCase()||"",o=r.includes("I"),c=r.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(o?le:ce)[c]}function de(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let r=0,o=e;for(;o>=n&&r<s.length-1;)o/=n,r++;let c=Math.round(o*10)/10;return c>=n&&r<s.length-1&&(c=1,r++),`${c%1===0?c.toFixed(0):c.toFixed(1)} ${s[r]}`}function me(e){return e=e.trim(),D.test(e)?e:"https://"+e}function fe(e){return R.test(e)}function ge(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function Me(e){return H.test(e)}function he(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Te(e){return _.test(e)}function pe(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let $=null;const N=new Map;function De(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);$||($=document.createElement("canvas"),$.willReadFrequently=!0);const t=$.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function we(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}a.formatBytes=de,a.formatDateTime=b,a.isColor=pe,a.isDate=V,a.isDateInRange=Q,a.isDateTime=k,a.isEmail=te,a.isFormControl=x,a.isInteger=re,a.isMeridiem=z,a.isNANPTel=ie,a.isNumber=oe,a.isPostalCA=Te,a.isTime=Z,a.isType=ee,a.isUrl=fe,a.isZip=Me,a.momentToFPFormat=G,a.monthToNumber=X,a.normalizeValidationResult=we,a.parseBytes=ue,a.parseColor=De,a.parseDate=w,a.parseDateTime=Y,a.parseDateTimeToString=W,a.parseDateToString=J,a.parseInteger=se,a.parseNANPTel=ne,a.parseNumber=ae,a.parsePostalCA=he,a.parseRelativeDate=F,a.parseTime=p,a.parseTimeToString=v,a.parseUrl=me,a.parseZip=ge,a.yearToFull=T,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,430 @@
1
+ const E = /^(?:[a-z+]+:)?\/\//i, F = /^(?:[-a-z+]+:)?\/\//i, H = /^\d{5}(-\d{4})?$/, _ = /^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/, C = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/, R = /^\d{3}-\d{3}-\d{4}$/, I = /^-?\d*$/, B = /^-?\d*\.?\d*$/;
2
+ function h(e) {
3
+ let t = e.trim().toLowerCase();
4
+ if (t === "now") {
5
+ const l = /* @__PURE__ */ new Date();
6
+ return { hour: l.getHours(), minute: l.getMinutes(), second: l.getSeconds() };
7
+ }
8
+ if (t === "noon") return { hour: 12, minute: 0, second: 0 };
9
+ t = t.replace(/\s+/g, "").replace(/\.+$/g, "");
10
+ const s = t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i, "$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);
11
+ if (!s) return null;
12
+ let i = +s[1], a = +(s[2] || 0), o = +(s[3] || 0);
13
+ const c = s[4]?.toLowerCase();
14
+ return c === "p" && i < 12 && (i += 12), c === "a" && i === 12 && (i = 0), i > 23 || a > 59 || o > 59 ? null : { hour: i, minute: a, second: o };
15
+ }
16
+ function U(e) {
17
+ return h(e) !== null;
18
+ }
19
+ function G(e) {
20
+ return /^[ap]\.?m?\.?$/i.test(e.replace(/\s/g, ""));
21
+ }
22
+ const L = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec", A = new RegExp(`(${L})[a-z]*`, "i");
23
+ function P(e) {
24
+ return (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
25
+ }
26
+ function M(e) {
27
+ if (typeof e == "string" && (e = parseInt(e.replace(/\D/g, ""))), e > 99) return e;
28
+ const t = ((/* @__PURE__ */ new Date()).getFullYear() + 20) % 100;
29
+ return e + (e < t ? 2e3 : 1900);
30
+ }
31
+ function T(e) {
32
+ if (e instanceof Date) return e;
33
+ let t = e.trim().toLowerCase();
34
+ const n = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
35
+ if (/^(now|today)$/.test(t)) return n;
36
+ if (t === "tomorrow") return new Date(n.setDate(n.getDate() + 1));
37
+ t = t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi, "").trim();
38
+ let s = 0, i = 0, a = 0;
39
+ const o = t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);
40
+ if (o) {
41
+ const p = h(o[1]);
42
+ if (p && ({ hour: s, minute: i, second: a } = p), t = t.replace(o[0], "").trim(), !t || t.length <= 2) {
43
+ const g = /* @__PURE__ */ new Date();
44
+ return new Date(g.getFullYear(), g.getMonth(), g.getDate(), s, i, a);
45
+ }
46
+ }
47
+ if (/^\d{8}$/.test(t))
48
+ return new Date(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), s, i, a);
49
+ if (/^\d{6}$/.test(t))
50
+ return new Date(M(+t.slice(0, 2)), +t.slice(2, 4) - 1, +t.slice(4, 6), s, i, a);
51
+ const c = t.match(A);
52
+ let l = -1, u = 0, r = 0;
53
+ c && (l = P(c[1]), t = t.replace(c[0], " ").trim());
54
+ const f = t.match(/'(\d{2})\b/);
55
+ f && (u = M(+f[1]), t = t.replace(f[0], " ").trim());
56
+ const d = t.match(/\d+/g)?.map(Number) || [];
57
+ if (l >= 0)
58
+ d.length >= 2 ? d[0] > 99 ? (u = d[0], r = d[1]) : d[1] > 99 ? (u = d[1], r = d[0]) : d[0] > 31 ? (r = d[1], u = M(d[0])) : d[1] > 31 ? (r = d[0], u = M(d[1])) : (r = d[0], u = u || M(d[1])) : d.length === 1 && (r = d[0], u = u || (/* @__PURE__ */ new Date()).getFullYear());
59
+ else if (d.length >= 3) {
60
+ const [p, g, m] = d;
61
+ p > 31 ? (u = p, l = g - 1, r = m) : p > 12 && m > 12 ? (r = p, l = g - 1, u = m > 31 ? m : M(m)) : m > 31 || m > 12 ? (l = p - 1, r = g, u = m > 31 ? m : M(m)) : (g > 12, l = p - 1, r = g, u = M(m));
62
+ } else d.length === 2 && (l = d[0] - 1, r = d[1], u = u || (/* @__PURE__ */ new Date()).getFullYear());
63
+ return u && l >= 0 && r && r >= 1 && r <= 31 ? new Date(u > 99 ? u : M(u), l, r, s, i, a) : /* @__PURE__ */ new Date("");
64
+ }
65
+ function b(e) {
66
+ if (e instanceof Date) return e;
67
+ let t = e.trim();
68
+ if (t.length < 3) return null;
69
+ if (t = t.replace(/(\d)T(\d)/i, "$1 $2"), t = t.replace(
70
+ /(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,
71
+ (c, l, u, r, f) => `${l}${f ? `${u}:${r}:${f}` : `${u}:${r}`}`
72
+ ), /^now$/i.test(t)) {
73
+ const c = /* @__PURE__ */ new Date();
74
+ return c.setMilliseconds(0), c;
75
+ }
76
+ if (/^noon$/i.test(t)) {
77
+ const c = /* @__PURE__ */ new Date();
78
+ return new Date(c.getFullYear(), c.getMonth(), c.getDate(), 12, 0, 0);
79
+ }
80
+ let n = null, s = t;
81
+ const i = [
82
+ /(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,
83
+ // 14:30, 2:30pm, 1:5
84
+ /\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,
85
+ // 2pm, 2p.m., 2 PM, 1P
86
+ /\b(\d{3,4})([ap])m?\b/i
87
+ // 1430pm, 230p, 1200AM
88
+ ];
89
+ for (const c of i) {
90
+ const l = t.match(c);
91
+ if (l) {
92
+ const u = h(l[0]);
93
+ if (u) {
94
+ n = u, s = t.replace(l[0], " ").replace(/[\s.]+$/g, "").replace(/\s+/g, " ").trim();
95
+ break;
96
+ }
97
+ }
98
+ }
99
+ if (!n) {
100
+ const c = s.match(
101
+ /^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i
102
+ );
103
+ if (c) {
104
+ const l = c[2], u = (c[3] || "").replace(/\s+/g, "");
105
+ let r = l + u;
106
+ l.length === 6 && (r = `${l.slice(0, 2)}:${l.slice(2, 4)}:${l.slice(4, 6)}${u}`);
107
+ const f = h(r);
108
+ f && (n = f, s = c[1]);
109
+ }
110
+ }
111
+ if (!n) {
112
+ const c = s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);
113
+ if (c) {
114
+ const l = c[2] + (c[3] || ""), u = h(l);
115
+ u && A.test(c[1]) && (n = u, s = c[1]);
116
+ }
117
+ }
118
+ if (n && (!s || /^,?\s*$/.test(s))) {
119
+ const c = /* @__PURE__ */ new Date();
120
+ return new Date(c.getFullYear(), c.getMonth(), c.getDate(), n.hour, n.minute, n.second);
121
+ }
122
+ const a = T(s);
123
+ if (isNaN(a.getTime())) return null;
124
+ const o = n || { hour: 0, minute: 0, second: 0 };
125
+ return new Date(a.getFullYear(), a.getMonth(), a.getDate(), o.hour, o.minute, o.second);
126
+ }
127
+ function N(e, t = "YYYY-MM-DD") {
128
+ if (typeof e == "string" && (e = T(e)), isNaN(e.getTime())) return "";
129
+ const n = e.getFullYear(), s = e.getMonth(), i = e.getDate(), a = e.getDay(), o = e.getHours(), c = e.getMinutes(), l = e.getSeconds(), u = e.getMilliseconds(), r = (w, Y = 2) => String(w).padStart(Y, "0"), f = o % 12 || 12, d = o < 12 ? "AM" : "PM", p = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], g = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], m = {
130
+ YYYY: n,
131
+ YY: String(n).slice(-2),
132
+ MMMM: p[s],
133
+ MMM: p[s].slice(0, 3),
134
+ MM: r(s + 1),
135
+ M: s + 1,
136
+ DD: r(i),
137
+ D: i,
138
+ dddd: g[a],
139
+ ddd: g[a].slice(0, 3),
140
+ dd: g[a].slice(0, 2),
141
+ d: a,
142
+ HH: r(o),
143
+ H: o,
144
+ hh: r(f),
145
+ h: f,
146
+ mm: r(c),
147
+ m: c,
148
+ ss: r(l),
149
+ s: l,
150
+ SSS: r(u, 3),
151
+ A: d,
152
+ a: d.toLowerCase()
153
+ };
154
+ return t.replace(
155
+ /\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,
156
+ (w, Y) => Y ?? String(m[w])
157
+ );
158
+ }
159
+ const z = {
160
+ YYYY: "Y",
161
+ YY: "y",
162
+ MMMM: "F",
163
+ MMM: "M",
164
+ MM: "m",
165
+ M: "n",
166
+ DD: "d",
167
+ D: "j",
168
+ dddd: "l",
169
+ ddd: "D",
170
+ dd: "D",
171
+ d: "w",
172
+ HH: "H",
173
+ H: "G",
174
+ hh: "h",
175
+ mm: "i",
176
+ m: "i",
177
+ ss: "S",
178
+ s: "s",
179
+ A: "K",
180
+ a: "K"
181
+ }, Z = /YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;
182
+ function k(e) {
183
+ return e.replace(Z, (t) => z[t]);
184
+ }
185
+ function V(e) {
186
+ return typeof e != "string" && !(e instanceof Date) ? !1 : !isNaN(T(e).getTime());
187
+ }
188
+ function J(e) {
189
+ if (typeof e != "string" && !(e instanceof Date)) return !1;
190
+ const t = b(e);
191
+ return t !== null && !isNaN(t.getTime());
192
+ }
193
+ function W(e, t = "YYYY-MMM-DD") {
194
+ const n = T(e);
195
+ return isNaN(n.getTime()) ? "" : N(n, t);
196
+ }
197
+ function X(e, t = "YYYY-MMM-DD h:mm A") {
198
+ const n = b(e);
199
+ return n && !isNaN(n.getTime()) ? N(n, t) : "";
200
+ }
201
+ function q(e, t = "h:mm A") {
202
+ const n = h(e);
203
+ if (!n) return "";
204
+ const s = /* @__PURE__ */ new Date();
205
+ return s.setHours(n.hour, n.minute, n.second, 0), N(s, t);
206
+ }
207
+ const y = {
208
+ ja: 0,
209
+ en: 0,
210
+ fe: 1,
211
+ fé: 1,
212
+ ap: 3,
213
+ ab: 3,
214
+ av: 3,
215
+ mai: 4,
216
+ juin: 5,
217
+ juil: 6,
218
+ au: 7,
219
+ ag: 7,
220
+ ao: 7,
221
+ se: 8,
222
+ o: 9,
223
+ n: 10,
224
+ d: 11
225
+ };
226
+ function v(e) {
227
+ if (typeof e == "number") return e - 1;
228
+ const t = parseInt(e);
229
+ if (!isNaN(t)) return t - 1;
230
+ const n = (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
231
+ if (!isNaN(n)) return n;
232
+ const s = e.toLowerCase();
233
+ for (const i in y) if (s.startsWith(i)) return y[i];
234
+ throw new Error("Invalid month name: " + e);
235
+ }
236
+ function x(e) {
237
+ const t = e.match(/^([+-])?(\d+)([dwmy])$/i);
238
+ if (!t) return null;
239
+ const [, n, s, i] = t, a = parseInt(s) * (n === "-" ? -1 : 1), o = /* @__PURE__ */ new Date();
240
+ switch (o.setHours(0, 0, 0, 0), i.toLowerCase()) {
241
+ case "d":
242
+ o.setDate(o.getDate() + a);
243
+ break;
244
+ case "w":
245
+ o.setDate(o.getDate() + a * 7);
246
+ break;
247
+ case "m":
248
+ o.setMonth(o.getMonth() + a);
249
+ break;
250
+ case "y":
251
+ o.setFullYear(o.getFullYear() + a);
252
+ break;
253
+ }
254
+ return o;
255
+ }
256
+ const S = /(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i, K = /(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;
257
+ function Q(e, t) {
258
+ if (t === "past")
259
+ return e <= /* @__PURE__ */ new Date();
260
+ if (t === "future")
261
+ return e.getTime() >= (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
262
+ if (t === "today") {
263
+ const r = /* @__PURE__ */ new Date();
264
+ return e.getFullYear() === r.getFullYear() && e.getMonth() === r.getMonth() && e.getDate() === r.getDate();
265
+ }
266
+ const n = (r) => {
267
+ const f = r.trim();
268
+ if (!f) return { date: null, hasTime: !1, valid: !0 };
269
+ const d = x(f);
270
+ if (d) return { date: d, hasTime: !1, valid: !0 };
271
+ const p = f.search(K);
272
+ if (p === -1) return { date: null, hasTime: !1, valid: !1 };
273
+ const g = f.search(S);
274
+ if (g !== -1 && g < p) return { date: null, hasTime: !1, valid: !1 };
275
+ const m = b(f);
276
+ return m && !isNaN(m.getTime()) ? { date: m, hasTime: S.test(f), valid: !0 } : { date: null, hasTime: !1, valid: !1 };
277
+ };
278
+ let s = null;
279
+ if (t.includes(":"))
280
+ for (let r = 0; r < t.length; r += 1) {
281
+ if (t[r] !== ":") continue;
282
+ const f = n(t.slice(0, r)), d = n(t.slice(r + 1));
283
+ if (f.valid && d.valid) {
284
+ s = { start: f, end: d };
285
+ break;
286
+ }
287
+ }
288
+ if (!s) {
289
+ const r = n(t);
290
+ return r.valid && r.date ? r.hasTime ? e.getTime() === r.date.getTime() : e.getFullYear() === r.date.getFullYear() && e.getMonth() === r.date.getMonth() && e.getDate() === r.date.getDate() : !0;
291
+ }
292
+ const i = s.start, a = s.end, c = i.hasTime || a.hasTime ? e.getTime() : new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
293
+ let l = null;
294
+ i.date && (l = i.hasTime ? i.date.getTime() : new Date(i.date.getFullYear(), i.date.getMonth(), i.date.getDate()).getTime());
295
+ let u = null;
296
+ return a.date && (u = a.hasTime ? a.date.getTime() : new Date(a.date.getFullYear(), a.date.getMonth(), a.date.getDate(), 23, 59, 59, 999).getTime()), !(l !== null && c < l || u !== null && c > u);
297
+ }
298
+ function ee(e) {
299
+ return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
300
+ }
301
+ function te(e, t) {
302
+ return typeof t == "string" && (t = [t]), t.includes(e.dataset.type || "") || t.includes(e.type);
303
+ }
304
+ function ne(e) {
305
+ return e.length <= 255 && C.test(e);
306
+ }
307
+ function re(e) {
308
+ return e.replace(/^[^2-90]+/g, "").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/, "$1-$2-$3$4");
309
+ }
310
+ function se(e) {
311
+ return R.test(e);
312
+ }
313
+ function ie(e) {
314
+ return e.replace(/[^0-9]/g, "");
315
+ }
316
+ function ae(e) {
317
+ return I.test(e);
318
+ }
319
+ function oe(e) {
320
+ const t = e.replace(/[^\-0-9.]/g, "");
321
+ let n = "", s = !1, i = !1;
322
+ for (let a = 0; a < t.length; a += 1) {
323
+ const o = t[a];
324
+ if (o === "-") {
325
+ !i && n.length === 0 && (n += "-", i = !0);
326
+ continue;
327
+ }
328
+ if (o === ".") {
329
+ s || (n += ".", s = !0);
330
+ continue;
331
+ }
332
+ n += o;
333
+ }
334
+ return n;
335
+ }
336
+ function ce(e) {
337
+ return B.test(e);
338
+ }
339
+ const O = { "": 1, K: 1e3, M: 1e6, G: 1e9, T: 1e12 }, j = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
340
+ function ue(e) {
341
+ const n = e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);
342
+ if (!n) return NaN;
343
+ const s = Number.parseFloat(n[1]), i = n[2]?.toUpperCase() || "", a = i.includes("I"), o = i.replace(/I?B$/i, "").replace(/I$/i, "") || "";
344
+ return s * (a ? j : O)[o];
345
+ }
346
+ function le(e, t = !0) {
347
+ const n = t ? 1e3 : 1024, s = ["B", "KB", "MB", "GB", "TB"];
348
+ if (e < n) return `${e} B`;
349
+ let i = 0, a = e;
350
+ for (; a >= n && i < s.length - 1; )
351
+ a /= n, i++;
352
+ let o = Math.round(a * 10) / 10;
353
+ return o >= n && i < s.length - 1 && (o = 1, i++), `${o % 1 === 0 ? o.toFixed(0) : o.toFixed(1)} ${s[i]}`;
354
+ }
355
+ function de(e) {
356
+ return e = e.trim(), E.test(e) ? e : "https://" + e;
357
+ }
358
+ function fe(e) {
359
+ return F.test(e);
360
+ }
361
+ function me(e) {
362
+ return e = e.replace(/[^0-9]/g, "").replace(/(.{5})(.*)/, "$1-$2").trim(), e.length === 6 ? e.replace(/-/, "") : e;
363
+ }
364
+ function ge(e) {
365
+ return H.test(e);
366
+ }
367
+ function pe(e) {
368
+ return e.toUpperCase().replace(/[^A-Z0-9]/g, "").replace(/(.{3})\s*(.*)/, "$1 $2").trim();
369
+ }
370
+ function Me(e) {
371
+ return _.test(e);
372
+ }
373
+ function he(e) {
374
+ return ["transparent", "currentColor"].includes(e) ? !0 : !e.trim() || typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("color", e);
375
+ }
376
+ let D = null;
377
+ const $ = /* @__PURE__ */ new Map();
378
+ function De(e) {
379
+ if (e = e.trim().toLowerCase(), ["transparent", "currentcolor"].includes(e)) return e;
380
+ if ($.has(e)) return $.get(e);
381
+ D || (D = document.createElement("canvas"), D.willReadFrequently = !0);
382
+ const t = D.getContext("2d");
383
+ t.fillStyle = e, t.fillRect(0, 0, 1, 1);
384
+ const n = t.getImageData(0, 0, 1, 1).data, s = "#" + ("000000" + (n[0] << 16 | n[1] << 8 | n[2]).toString(16)).slice(-6);
385
+ return $.set(e, s), s;
386
+ }
387
+ function Te(e) {
388
+ if (typeof e == "boolean") return { valid: e, error: !1, messages: [] };
389
+ if (typeof e == "string") return { valid: !1, error: !1, messages: [e] };
390
+ const t = { valid: e.valid, error: e.error ?? !1, messages: [] };
391
+ return typeof e.message == "string" ? t.messages = [e.message] : typeof e.messages == "string" ? t.messages = [e.messages] : Array.isArray(e.messages) && (t.messages = e.messages), t;
392
+ }
393
+ export {
394
+ le as formatBytes,
395
+ N as formatDateTime,
396
+ he as isColor,
397
+ V as isDate,
398
+ Q as isDateInRange,
399
+ J as isDateTime,
400
+ ne as isEmail,
401
+ ee as isFormControl,
402
+ ae as isInteger,
403
+ G as isMeridiem,
404
+ se as isNANPTel,
405
+ ce as isNumber,
406
+ Me as isPostalCA,
407
+ U as isTime,
408
+ te as isType,
409
+ fe as isUrl,
410
+ ge as isZip,
411
+ k as momentToFPFormat,
412
+ v as monthToNumber,
413
+ Te as normalizeValidationResult,
414
+ ue as parseBytes,
415
+ De as parseColor,
416
+ T as parseDate,
417
+ b as parseDateTime,
418
+ X as parseDateTimeToString,
419
+ W as parseDateToString,
420
+ ie as parseInteger,
421
+ re as parseNANPTel,
422
+ oe as parseNumber,
423
+ pe as parsePostalCA,
424
+ x as parseRelativeDate,
425
+ h as parseTime,
426
+ q as parseTimeToString,
427
+ de as parseUrl,
428
+ me as parseZip,
429
+ M as yearToFull
430
+ };
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "name": "@jdlien/validator-utils",
3
- "version": "1.2.8",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
- "module": "dist/validator-utils.js",
6
- "main": "dist/validator-utils.js",
7
- "types": "dist/validator-utils.d.ts",
5
+ "main": "dist/validator-utils.cjs",
6
+ "module": "dist/validator-utils.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/validator-utils.mjs",
12
+ "require": "./dist/validator-utils.cjs",
13
+ "default": "./dist/validator-utils.mjs"
14
+ }
15
+ },
8
16
  "files": [
9
17
  "dist"
10
18
  ],
19
+ "unpkg": "dist/validator-utils.js",
20
+ "jsdelivr": "dist/validator-utils.js",
11
21
  "description": "Validation and sanitization functions used by @jdlien/Validator.",
12
- "scripts": {
13
- "dev": "vite",
14
- "build": "vite build && tsc --emitDeclarationOnly",
15
- "preview": "vite preview",
16
- "test": "vitest",
17
- "coverage": "vitest --coverage"
18
- },
19
22
  "repository": {
20
23
  "type": "git",
21
24
  "url": "git+https://github.com/jdlien/validator-utils.git"
@@ -25,7 +28,7 @@
25
28
  },
26
29
  "keywords": [
27
30
  "validation",
28
- "utilties",
31
+ "utilities",
29
32
  "sanitization",
30
33
  "date",
31
34
  "time",
@@ -38,15 +41,26 @@
38
41
  },
39
42
  "homepage": "https://github.com/jdlien/validator-utils#readme",
40
43
  "devDependencies": {
41
- "@types/jsdom": "^21.1.0",
42
- "@vitest/coverage-v8": "^3.1.1",
43
- "canvas": "^3.0.0",
44
- "jsdom": "^26.1.0",
44
+ "@types/jsdom": "^27.0.0",
45
+ "@vitest/coverage-v8": "^4.0.18",
46
+ "canvas": "^3.2.1",
47
+ "jsdom": "^27.4.0",
45
48
  "jsdom-global": "^3.0.2",
46
- "prettier": "^3.0.1",
47
- "typescript": "^5.1.6",
48
- "vite": "^6.3.1",
49
- "vitest": "^3.1.1"
49
+ "prettier": "^3.8.1",
50
+ "typescript": "^5.9.3",
51
+ "vite": "^7.3.1",
52
+ "vitest": "^4.0.18"
50
53
  },
51
- "sideEffects": false
52
- }
54
+ "sideEffects": false,
55
+ "scripts": {
56
+ "dev": "vite",
57
+ "build:lib": "pnpm build:lib:esm && pnpm build:lib:compat && tsc --emitDeclarationOnly",
58
+ "build:lib:esm": "vite build",
59
+ "build:lib:compat": "vite build --mode compat",
60
+ "build": "pnpm build:lib",
61
+ "size:wire": "node scripts/measure-wire-size.mjs",
62
+ "preview": "vite preview",
63
+ "test": "vitest",
64
+ "coverage": "vitest --coverage"
65
+ }
66
+ }