bs-ad-calendar-react 1.3.1 → 1.3.2
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/dist/bs-ad-calendar.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as g, jsxs as S, Fragment as pe } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
2
|
+
import { useMemo as vt, useState as B, useEffect as Yt, useRef as Ft } from "react";
|
|
3
3
|
const Q = [1943, 4, 14], Lt = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], be = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], W = [[[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365]];
|
|
4
4
|
let Rt = class extends Error {
|
|
5
5
|
constructor(t) {
|
|
6
6
|
super(t), this.name = "DateOutOfRangeError";
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
-
const _t = () => Q[0] + 1, jt = () => Q[0] + W.length - 1, Pt = () => 2e3, Wt = () => 2e3 + W.length - 1, yt = (e) => e % 400 === 0 || e % 4 === 0 && e % 100 !== 0, kt = (e) => yt(e) ? be : Lt, Se = (e, t, n) => !(e < _t() || e > jt() || t < 1 || t > 12 || n < 1 || n > kt(e)[t - 1]),
|
|
9
|
+
const _t = () => Q[0] + 1, jt = () => Q[0] + W.length - 1, Pt = () => 2e3, Wt = () => 2e3 + W.length - 1, yt = (e) => e % 400 === 0 || e % 4 === 0 && e % 100 !== 0, kt = (e) => yt(e) ? be : Lt, Se = (e, t, n) => !(e < _t() || e > jt() || t < 1 || t > 12 || n < 1 || n > kt(e)[t - 1]), xt = (e, t, n) => {
|
|
10
10
|
let a = e * 365 + n;
|
|
11
11
|
for (let s = 0; s < t - 1; s++) a += Lt[s];
|
|
12
12
|
return t <= 2 && (e -= 1), a += Math.floor(e / 4) - Math.floor(e / 100) + Math.floor(e / 400), a;
|
|
@@ -14,7 +14,7 @@ const _t = () => Q[0] + 1, jt = () => Q[0] + W.length - 1, Pt = () => 2e3, Wt =
|
|
|
14
14
|
function Ee(e, t, n) {
|
|
15
15
|
const a = t + 1;
|
|
16
16
|
if (!Se(e, a, n)) throw new Rt("Date out of range");
|
|
17
|
-
let s = 2e3, r = 1, o = 1, u = Math.abs(
|
|
17
|
+
let s = 2e3, r = 1, o = 1, u = Math.abs(xt(e, a, n) - xt(...Q)), i = 0;
|
|
18
18
|
for (; u >= W[i][1]; ) u -= W[i][1], s += 1, i += 1;
|
|
19
19
|
let h = 0;
|
|
20
20
|
for (; u >= W[i][0][h]; ) u -= W[i][0][h], r += 1, h += 1;
|
|
@@ -30,23 +30,23 @@ const we = (e, t, n) => !(e < Pt() || e > Wt() || t < 1 || t > 12 || n < 1 || n
|
|
|
30
30
|
const a = t + 1;
|
|
31
31
|
if (!we(e, a, n)) throw new Rt("Date out of range");
|
|
32
32
|
let [s, r, o] = [Q[0], 1, 1];
|
|
33
|
-
const u = kt(s).slice(0, Q[1] - 1).reduce((
|
|
33
|
+
const u = kt(s).slice(0, Q[1] - 1).reduce((f, d) => f + d, 0) + Q[2] - 1;
|
|
34
34
|
let i = Math.abs(Ye(e, a, n) + u);
|
|
35
35
|
for (; i >= 366 && yt(s) || i >= 365 && !yt(s); ) i -= yt(s) ? 366 : 365, s += 1;
|
|
36
36
|
const h = kt(s);
|
|
37
37
|
let c = 0;
|
|
38
38
|
for (; i >= h[c]; ) i -= h[c], r += 1, c += 1;
|
|
39
39
|
return o += i, [s, r - 1, o];
|
|
40
|
-
}, J = { enMinYear: _t, enMaxYear: jt, npMinYear: Pt, npMaxYear: Wt, englishToNepali: Ee, nepaliToEnglish: ke }, Ut = "en", L = "ne", Jt = 207e5, Vt = 198e5, Ce = 5049018e5, Ae = new Date(1986, 0, 1, 0, 15), Mt = ["Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"], Ct = ["Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha"], Kt = ["बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र"],
|
|
41
|
-
const t = e.getTime(), n = t < Ce ? Vt : Jt, a = new Date(t + n), s = a.getUTCFullYear(), r = a.getUTCMonth(), o = a.getUTCDate(), u = a.getUTCHours(), i = a.getUTCMinutes(), h = a.getUTCSeconds(), c = a.getUTCMilliseconds(),
|
|
42
|
-
return { year: s, month0: r, day: o, hour: u, minute: i, second: h, ms: c, weekDay:
|
|
43
|
-
},
|
|
40
|
+
}, J = { enMinYear: _t, enMaxYear: jt, npMinYear: Pt, npMaxYear: Wt, englishToNepali: Ee, nepaliToEnglish: ke }, Ut = "en", L = "ne", Jt = 207e5, Vt = 198e5, Ce = 5049018e5, Ae = new Date(1986, 0, 1, 0, 15), Mt = ["Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"], Ct = ["Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha"], Kt = ["बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र"], $e = ["बै", "जे", "अ", "श्रा", "भा", "आ", "का", "मं", "पौ", "मा", "फा", "चै"], At = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], $t = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], ve = ["जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"], Fe = ["जन", "फेब", "मार", "अप्रि", "मे", "जुन", "जुला", "अग", "सेप", "अक्टो", "नोभे", "डिसे"], Gt = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], tt = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], pt = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], zt = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], qt = ["आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"], xe = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DD?|ddd?d?|do?|YYYY|YY|y{2,4}|yo?|a|A|hh?|HH?|mm?|ss?|SSS|x|X|.)/g, Ne = (e) => {
|
|
41
|
+
const t = e.getTime(), n = t < Ce ? Vt : Jt, a = new Date(t + n), s = a.getUTCFullYear(), r = a.getUTCMonth(), o = a.getUTCDate(), u = a.getUTCHours(), i = a.getUTCMinutes(), h = a.getUTCSeconds(), c = a.getUTCMilliseconds(), f = a.getUTCDay();
|
|
42
|
+
return { year: s, month0: r, day: o, hour: u, minute: i, second: h, ms: c, weekDay: f };
|
|
43
|
+
}, Nt = (e, t, n, a, s, r, o) => {
|
|
44
44
|
const u = new Date(e, t, n, a, s, r, o);
|
|
45
45
|
let i = u < Ae ? Vt : Jt;
|
|
46
46
|
const h = -1 * u.getTimezoneOffset() * 60 * 1e3;
|
|
47
47
|
return new Date(u.getTime() - i + h);
|
|
48
48
|
}, bt = (e) => {
|
|
49
|
-
const t = e.match(
|
|
49
|
+
const t = e.match(xe);
|
|
50
50
|
return t ? t.map((n) => n.startsWith("[") && n.endsWith("]") ? n.slice(1, -1) : n) : [];
|
|
51
51
|
}, P = (e) => {
|
|
52
52
|
if (e.length === 0) return new RegExp("");
|
|
@@ -54,23 +54,23 @@ const we = (e, t, n) => !(e < Pt() || e > Wt() || t < 1 || t > 12 || n < 1 || n
|
|
|
54
54
|
if (t = t.sort((a, s) => s.length - a.length), t[0] === "") return new RegExp("");
|
|
55
55
|
const n = `(${t.join("|")})`;
|
|
56
56
|
return new RegExp(n);
|
|
57
|
-
},
|
|
57
|
+
}, x = (e) => e.toString().padStart(2, "0"), Xt = (e) => e.toString().padStart(3, "0"), He = (e) => e.split("").map((t) => Gt[t.charCodeAt(0) - 48]).join(""), b = (e, t) => {
|
|
58
58
|
const n = typeof e == "string" ? e : String(e);
|
|
59
|
-
return t !== L ? n :
|
|
60
|
-
},
|
|
59
|
+
return t !== L ? n : He(n);
|
|
60
|
+
}, Oe = (e, t) => b(e.getYear(), t).substring(2), Te = (e, t) => b(e.getYear(), t), Be = (e, t) => b(e.getEnglishYear(), t).substring(2), Ie = (e, t) => b(e.getEnglishYear(), t), Le = (e, t) => b(e.getMonth() + 1, t), Re = (e, t) => b(x(e.getMonth() + 1), t), _e = (e, t) => t === L ? $e[e.getMonth()] : Ct[e.getMonth()], je = (e, t) => t === L ? Kt[e.getMonth()] : Mt[e.getMonth()], Pe = (e, t) => b(e.getEnglishMonth() + 1, t), We = (e, t) => b(x(e.getEnglishMonth() + 1), t), Ue = (e, t) => t === L ? Fe[e.getEnglishMonth()] : $t[e.getEnglishMonth()], Je = (e, t) => t === L ? ve[e.getEnglishMonth()] : At[e.getEnglishMonth()], Ve = (e, t) => b(e.getDate(), t), Ke = (e, t) => b(x(e.getDate()), t), Ge = (e, t) => b(e.getEnglishDate(), t), ze = (e, t) => b(x(e.getEnglishDate()), t), Zt = (e, t) => b(e.getDay(), t), Dt = (e, t) => t === L ? zt[e.getDay()] : tt[e.getDay()], Qt = (e, t) => t === L ? qt[e.getDay()] : pt[e.getDay()], te = (e, t) => b(e.getHours(), t), ee = (e, t) => b(x(e.getHours()), t), ne = (e, t) => {
|
|
61
61
|
const n = e.getHours(), a = n > 12 ? n - 12 : n;
|
|
62
62
|
return b(a, t);
|
|
63
63
|
}, se = (e, t) => {
|
|
64
64
|
const n = e.getHours(), a = n > 12 ? n - 12 : n;
|
|
65
|
-
return b(
|
|
66
|
-
}, ae = (e, t) => b(e.getMinutes(), t), re = (e, t) => b(
|
|
67
|
-
const a = bt(t), s = (r) => r in
|
|
65
|
+
return b(x(a), t);
|
|
66
|
+
}, ae = (e, t) => b(e.getMinutes(), t), re = (e, t) => b(x(e.getMinutes()), t), oe = (e, t) => b(e.getSeconds(), t), ie = (e, t) => b(x(e.getSeconds()), t), ue = (e, t) => b(Xt(e.getMilliseconds()), t), ce = (e, t) => t === L ? e.getHours() >= 12 ? "पिम" : "एम" : e.getHours() >= 12 ? "PM" : "AM", he = (e, t) => t === L ? e.getHours() >= 12 ? "पिम" : "एम" : e.getHours() >= 12 ? "pm" : "am", Ht = { YY: Oe, YYYY: Te, M: Le, MM: Re, MMM: _e, MMMM: je, D: Ve, DD: Ke, d: Zt, dd: Dt, ddd: Dt, dddd: Qt, H: te, HH: ee, h: ne, hh: se, m: ae, mm: re, s: oe, ss: ie, SSS: ue, A: ce, a: he }, le = (e, t, n) => {
|
|
67
|
+
const a = bt(t), s = (r) => r in Ht ? Ht[r](e, n) : r;
|
|
68
68
|
return a.map(s).join("");
|
|
69
69
|
}, qe = (e, t) => le(e, t, Ut), Xe = (e, t) => le(e, t, L), Ze = (e) => {
|
|
70
|
-
const t =
|
|
70
|
+
const t = x(e.getYear()), n = x(e.getMonth() + 1), a = x(e.getDate()), s = x(e.getHours()), r = x(e.getMinutes()), o = x(e.getSeconds()), u = e.getMilliseconds(), i = u === 0 ? "" : `.${Xt(u)}`;
|
|
71
71
|
return `${t}-${n}-${a} ${s}:${r}:${o}${i}`;
|
|
72
|
-
},
|
|
73
|
-
const a = bt(t), s = (r) => r in
|
|
72
|
+
}, Ot = { YY: Be, YYYY: Ie, M: Pe, MM: We, MMM: Ue, MMMM: Je, D: Ge, DD: ze, d: Zt, dd: Dt, ddd: Dt, dddd: Qt, H: te, HH: ee, h: ne, hh: se, m: ae, mm: re, s: oe, ss: ie, SSS: ue, A: ce, a: he }, de = (e, t, n) => {
|
|
73
|
+
const a = bt(t), s = (r) => r in Ot ? Ot[r](e, n) : r;
|
|
74
74
|
return a.map(s).join("");
|
|
75
75
|
}, Qe = (e, t) => de(e, t, Ut), t3 = (e, t) => de(e, t, L);
|
|
76
76
|
function e3(e) {
|
|
@@ -95,15 +95,15 @@ function s3(e) {
|
|
|
95
95
|
const [t, n] = e.split(" ", 2), [a, s, r] = e3(t), [o, u, i, h] = n3(n);
|
|
96
96
|
return [a, s, r, o, u, i, h];
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const Tt = { YY: /(\d\d)/, YYYY: /(\d\d\d\d)/, M: /(1[0-2]|0[1-9]|[1-9])/, MM: /(1[0-2]|0[1-9]|[1-9])/, D: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, DD: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, H: /(2[0-3]|[0-1]\d|\d)/, HH: /(2[0-3]|[0-1]\d|\d)/, hh: /(1[0-2]|0[1-9]|[1-9])/, mm: /([0-5]\d|\d)/, ss: /([0-5]\d|\d)/, SSS: /(\d\d\d)/, A: /(AM|PM)/, a: /(am|pm)/, MMMM: P(Mt), MMM: P(Ct), dddd: P(pt), ddd: P(tt), dd: P(tt), d: /([0-6])/ };
|
|
99
99
|
function a3(e) {
|
|
100
100
|
const t = [], n = [];
|
|
101
|
-
for (const s of e) s in
|
|
101
|
+
for (const s of e) s in Tt ? (t.push(s), n.push(Tt[s].source)) : n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
102
102
|
const a = n.join("");
|
|
103
103
|
return { dateTokens: t, regex: new RegExp(`^${a}$`) };
|
|
104
104
|
}
|
|
105
105
|
function r3(e, t) {
|
|
106
|
-
let [n, a, s, r, o, u, i, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1,
|
|
106
|
+
let [n, a, s, r, o, u, i, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1, f = !1;
|
|
107
107
|
for (let d = 0; d < e.length; d++) {
|
|
108
108
|
const k = e[d], m = parseInt(t[d + 1]);
|
|
109
109
|
switch (k) {
|
|
@@ -133,7 +133,7 @@ function r3(e, t) {
|
|
|
133
133
|
break;
|
|
134
134
|
case "hh":
|
|
135
135
|
case "h":
|
|
136
|
-
o = m,
|
|
136
|
+
o = m, f = !0;
|
|
137
137
|
break;
|
|
138
138
|
case "mm":
|
|
139
139
|
case "m":
|
|
@@ -151,15 +151,15 @@ function r3(e, t) {
|
|
|
151
151
|
c = t[d + 1].toLowerCase() === "pm";
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
return
|
|
154
|
+
return f && (r = o + (c ? 12 : 0)), { year: n, month0: a - 1, day: s, hour: r, minute: u, second: i, ms: h };
|
|
155
155
|
}
|
|
156
156
|
function ge(e, t) {
|
|
157
157
|
const n = bt(t), { dateTokens: a, regex: s } = a3(n), r = RegExp(s).exec(e);
|
|
158
158
|
if (!r) throw new Error("Invalid date format");
|
|
159
|
-
const { year: o, month0: u, day: i, hour: h, minute: c, second:
|
|
160
|
-
return [o, u, i, h, c,
|
|
159
|
+
const { year: o, month0: u, day: i, hour: h, minute: c, second: f, ms: d } = r3(a, r);
|
|
160
|
+
return [o, u, i, h, c, f, d];
|
|
161
161
|
}
|
|
162
|
-
const Bt = { YY: /(\d\d)/, YYYY: /(\d\d\d\d)/, M: /(1[0-2]|0[1-9]|[1-9])/, MM: /(1[0-2]|0[1-9]|[1-9])/, D: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, DD: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, H: /(2[0-3]|[0-1]\d|\d)/, HH: /(2[0-3]|[0-1]\d|\d)/, hh: /(1[0-2]|0[1-9]|[1-9])/, mm: /([0-5]\d|\d)/, ss: /([0-5]\d|\d)/, SSS: /(\d\d\d)/, A: /(AM|PM)/, a: /(am|pm)/, MMMM: P(At), MMM: P(
|
|
162
|
+
const Bt = { YY: /(\d\d)/, YYYY: /(\d\d\d\d)/, M: /(1[0-2]|0[1-9]|[1-9])/, MM: /(1[0-2]|0[1-9]|[1-9])/, D: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, DD: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, H: /(2[0-3]|[0-1]\d|\d)/, HH: /(2[0-3]|[0-1]\d|\d)/, hh: /(1[0-2]|0[1-9]|[1-9])/, mm: /([0-5]\d|\d)/, ss: /([0-5]\d|\d)/, SSS: /(\d\d\d)/, A: /(AM|PM)/, a: /(am|pm)/, MMMM: P(At), MMM: P($t), dddd: P(pt), ddd: P(tt), dd: P(tt), d: /([0-6])/ };
|
|
163
163
|
function o3(e) {
|
|
164
164
|
const t = [], n = [];
|
|
165
165
|
for (const s of e) s in Bt ? (t.push(s), n.push(Bt[s].source)) : n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
@@ -167,7 +167,7 @@ function o3(e) {
|
|
|
167
167
|
return { dateTokens: t, regex: new RegExp(`^${a}$`) };
|
|
168
168
|
}
|
|
169
169
|
function i3(e, t) {
|
|
170
|
-
let [n, a, s, r, o, u, i, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1,
|
|
170
|
+
let [n, a, s, r, o, u, i, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1, f = !1;
|
|
171
171
|
for (let d = 0; d < e.length; d++) {
|
|
172
172
|
const k = e[d], m = parseInt(t[d + 1]);
|
|
173
173
|
switch (k) {
|
|
@@ -185,7 +185,7 @@ function i3(e, t) {
|
|
|
185
185
|
a = At.indexOf(t[d + 1]) + 1;
|
|
186
186
|
break;
|
|
187
187
|
case "MMM":
|
|
188
|
-
a =
|
|
188
|
+
a = $t.indexOf(t[d + 1]) + 1;
|
|
189
189
|
break;
|
|
190
190
|
case "DD":
|
|
191
191
|
case "D":
|
|
@@ -197,7 +197,7 @@ function i3(e, t) {
|
|
|
197
197
|
break;
|
|
198
198
|
case "hh":
|
|
199
199
|
case "h":
|
|
200
|
-
o = m,
|
|
200
|
+
o = m, f = !0;
|
|
201
201
|
break;
|
|
202
202
|
case "mm":
|
|
203
203
|
case "m":
|
|
@@ -215,13 +215,13 @@ function i3(e, t) {
|
|
|
215
215
|
c = t[d + 1].toLowerCase() === "pm";
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
return
|
|
218
|
+
return f && (r = o + (c ? 12 : 0)), { year: n, month0: a - 1, day: s, hour: r, minute: u, second: i, ms: h };
|
|
219
219
|
}
|
|
220
220
|
function u3(e, t) {
|
|
221
221
|
const n = bt(t), { dateTokens: a, regex: s } = o3(n), r = RegExp(s).exec(e);
|
|
222
222
|
if (!r) throw new Error("Invalid date format");
|
|
223
|
-
const { year: o, month0: u, day: i, hour: h, minute: c, second:
|
|
224
|
-
return [o, u, i, h, c,
|
|
223
|
+
const { year: o, month0: u, day: i, hour: h, minute: c, second: f, ms: d } = i3(a, r);
|
|
224
|
+
return [o, u, i, h, c, f, d];
|
|
225
225
|
}
|
|
226
226
|
function c3(e) {
|
|
227
227
|
const t = { एम: "AM", पिम: "PM" };
|
|
@@ -246,7 +246,7 @@ const l3 = (e) => {
|
|
|
246
246
|
if (e < 0 || e > 59) throw new St("Second should be in the range 0-59");
|
|
247
247
|
}, m3 = (e) => {
|
|
248
248
|
if (e < 0 || e > 999) throw new St("Millisecond should be in the range 0-999");
|
|
249
|
-
},
|
|
249
|
+
}, f3 = (e, t, n, a) => {
|
|
250
250
|
l3(e), d3(t), g3(n), m3(a);
|
|
251
251
|
};
|
|
252
252
|
class Y {
|
|
@@ -295,10 +295,10 @@ class Y {
|
|
|
295
295
|
}
|
|
296
296
|
_setDateObject(t, n = !0) {
|
|
297
297
|
this.timestamp = t;
|
|
298
|
-
const { year: a, month0: s, day: r, hour: o, minute: u, weekDay: i } =
|
|
298
|
+
const { year: a, month0: s, day: r, hour: o, minute: u, weekDay: i } = Ne(t);
|
|
299
299
|
if (this.yearEn = a, this.monthEn = s, this.dayEn = r, this.hour = o, this.minute = u, this.weekDay = i, n) {
|
|
300
|
-
const [h, c,
|
|
301
|
-
this.year = h, this.month = c, this.day =
|
|
300
|
+
const [h, c, f] = J.englishToNepali(a, s, r);
|
|
301
|
+
this.year = h, this.month = c, this.day = f;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
getDateObject() {
|
|
@@ -365,9 +365,9 @@ class Y {
|
|
|
365
365
|
this._setDateObject(new Date(t));
|
|
366
366
|
}
|
|
367
367
|
set(t, n, a, s, r, o, u) {
|
|
368
|
-
|
|
368
|
+
f3(s, r, o, u);
|
|
369
369
|
const [i, h, c] = J.nepaliToEnglish(t, n, a);
|
|
370
|
-
this.year = t, this.month = n, this.day = a, this._setDateObject(
|
|
370
|
+
this.year = t, this.month = n, this.day = a, this._setDateObject(Nt(i, h, c, s, r, o, u), !1);
|
|
371
371
|
}
|
|
372
372
|
setDateObject(t) {
|
|
373
373
|
this._setDateObject(t, !0);
|
|
@@ -388,7 +388,7 @@ class Y {
|
|
|
388
388
|
return t3(this, t);
|
|
389
389
|
}
|
|
390
390
|
static fromEnglishDate(t, n, a, s = 0, r = 0, o = 0, u = 0) {
|
|
391
|
-
const i =
|
|
391
|
+
const i = Nt(t, n, a, s, r, o, u);
|
|
392
392
|
return new Y(i);
|
|
393
393
|
}
|
|
394
394
|
static parseNepaliFormat(t, n) {
|
|
@@ -450,7 +450,7 @@ const y3 = [
|
|
|
450
450
|
"Magh",
|
|
451
451
|
"Falgun",
|
|
452
452
|
"Chaitra"
|
|
453
|
-
],
|
|
453
|
+
], D3 = [
|
|
454
454
|
"January",
|
|
455
455
|
"February",
|
|
456
456
|
"March",
|
|
@@ -463,7 +463,7 @@ const y3 = [
|
|
|
463
463
|
"October",
|
|
464
464
|
"November",
|
|
465
465
|
"December"
|
|
466
|
-
], M3 = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], p3 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], b3 = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"],
|
|
466
|
+
], M3 = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], p3 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], b3 = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], N3 = {
|
|
467
467
|
light: {
|
|
468
468
|
primary: "#3b82f6",
|
|
469
469
|
background: "#ffffff",
|
|
@@ -484,7 +484,7 @@ const y3 = [
|
|
|
484
484
|
today: "#1e40af",
|
|
485
485
|
disabled: "#6b7280"
|
|
486
486
|
}
|
|
487
|
-
}, V = (e) => e.toString().split("").map((t) => b3[parseInt(t)]).join(""),
|
|
487
|
+
}, V = (e) => e.toString().split("").map((t) => b3[parseInt(t)]).join(""), fe = (e, t, n) => {
|
|
488
488
|
if (e === "BS")
|
|
489
489
|
try {
|
|
490
490
|
const a = n === 11 ? new Y(t + 1, 0, 1) : new Y(t, n + 1, 1);
|
|
@@ -501,7 +501,7 @@ const y3 = [
|
|
|
501
501
|
return 0;
|
|
502
502
|
}
|
|
503
503
|
return new Date(t, n, 1).getDay();
|
|
504
|
-
},
|
|
504
|
+
}, H = (e) => {
|
|
505
505
|
const t = /* @__PURE__ */ new Date();
|
|
506
506
|
if (e === "BS")
|
|
507
507
|
try {
|
|
@@ -514,21 +514,13 @@ const y3 = [
|
|
|
514
514
|
}, wt = (e, t, n, a, s) => {
|
|
515
515
|
if (e === "BS")
|
|
516
516
|
try {
|
|
517
|
-
const r = new Y(t, n, a), u =
|
|
518
|
-
r.getEnglishYear(),
|
|
519
|
-
r.getEnglishMonth(),
|
|
520
|
-
r.getEnglishDate()
|
|
521
|
-
).toISOString().split("T")[0];
|
|
517
|
+
const r = new Y(t, n, a), o = r.getEnglishYear(), u = r.getEnglishMonth(), i = r.getEnglishDate(), h = `${o}-${String(u + 1).padStart(2, "0")}-${String(i).padStart(2, "0")}`;
|
|
522
518
|
return {
|
|
523
519
|
bs: `${t}-${String(n + 1).padStart(2, "0")}-${String(a).padStart(2, "0")}`,
|
|
524
|
-
ad:
|
|
520
|
+
ad: h,
|
|
525
521
|
formatted: {
|
|
526
522
|
bs: `${s[n]} ${a}, ${t}`,
|
|
527
|
-
ad: new Date(
|
|
528
|
-
r.getEnglishYear(),
|
|
529
|
-
r.getEnglishMonth(),
|
|
530
|
-
r.getEnglishDate()
|
|
531
|
-
).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
523
|
+
ad: new Date(o, u, i).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
532
524
|
}
|
|
533
525
|
};
|
|
534
526
|
} catch {
|
|
@@ -543,14 +535,14 @@ const y3 = [
|
|
|
543
535
|
};
|
|
544
536
|
}
|
|
545
537
|
else {
|
|
546
|
-
const r =
|
|
538
|
+
const r = `${t}-${String(n + 1).padStart(2, "0")}-${String(a).padStart(2, "0")}`, o = new Date(t, n, a);
|
|
547
539
|
try {
|
|
548
540
|
const u = Y.fromEnglishDate(t, n, a), i = `${u.getYear()}-${String(u.getMonth() + 1).padStart(2, "0")}-${String(u.getDate()).padStart(2, "0")}`;
|
|
549
541
|
return {
|
|
550
|
-
ad:
|
|
542
|
+
ad: r,
|
|
551
543
|
bs: i,
|
|
552
544
|
formatted: {
|
|
553
|
-
ad:
|
|
545
|
+
ad: o.toLocaleDateString("en-US", {
|
|
554
546
|
year: "numeric",
|
|
555
547
|
month: "long",
|
|
556
548
|
day: "numeric"
|
|
@@ -560,20 +552,20 @@ const y3 = [
|
|
|
560
552
|
};
|
|
561
553
|
} catch {
|
|
562
554
|
return {
|
|
563
|
-
ad:
|
|
564
|
-
bs:
|
|
555
|
+
ad: r,
|
|
556
|
+
bs: r,
|
|
565
557
|
formatted: {
|
|
566
|
-
ad:
|
|
558
|
+
ad: o.toLocaleDateString("en-US", {
|
|
567
559
|
year: "numeric",
|
|
568
560
|
month: "long",
|
|
569
561
|
day: "numeric"
|
|
570
562
|
}),
|
|
571
|
-
bs:
|
|
563
|
+
bs: o.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
572
564
|
}
|
|
573
565
|
};
|
|
574
566
|
}
|
|
575
567
|
}
|
|
576
|
-
},
|
|
568
|
+
}, H3 = (e, t, n) => {
|
|
577
569
|
const a = new Date(e.year, e.month, e.day).getTime(), s = new Date(t.year, t.month, t.day).getTime(), r = new Date(n.year, n.month, n.day).getTime();
|
|
578
570
|
return a >= s && a <= r;
|
|
579
571
|
}, It = (e) => {
|
|
@@ -602,13 +594,13 @@ const y3 = [
|
|
|
602
594
|
}
|
|
603
595
|
return !1;
|
|
604
596
|
}, E3 = (e = "AD") => {
|
|
605
|
-
const t =
|
|
597
|
+
const t = vt(() => H(e), [e]), [n, a] = B(t.year), [s, r] = B(t.month), [o, u] = B(null), [i, h] = B(null), [c, f] = B(null);
|
|
606
598
|
Yt(() => {
|
|
607
599
|
a(t.year), r(t.month);
|
|
608
600
|
}, [t.year, t.month]);
|
|
609
|
-
const d =
|
|
610
|
-
const E =
|
|
611
|
-
for (let C = 0; C <
|
|
601
|
+
const d = vt(() => {
|
|
602
|
+
const E = fe(e, n, s), $ = S3(e, n, s), p = [];
|
|
603
|
+
for (let C = 0; C < $; C++)
|
|
612
604
|
p.push(null);
|
|
613
605
|
for (let C = 1; C <= E; C++)
|
|
614
606
|
p.push(C);
|
|
@@ -628,7 +620,7 @@ const y3 = [
|
|
|
628
620
|
setCurrentMonth: r,
|
|
629
621
|
setSelectedDate: u,
|
|
630
622
|
setRangeStart: h,
|
|
631
|
-
setRangeEnd:
|
|
623
|
+
setRangeEnd: f,
|
|
632
624
|
navigateMonth: (E) => {
|
|
633
625
|
let p = s + E, C = n;
|
|
634
626
|
for (; p > 11; )
|
|
@@ -639,11 +631,11 @@ const y3 = [
|
|
|
639
631
|
},
|
|
640
632
|
// Helpers
|
|
641
633
|
isToday: (E) => n === t.year && s === t.month && E === t.day,
|
|
642
|
-
isSelected: (E,
|
|
634
|
+
isSelected: (E, $ = "single") => $ === "range" ? !!(i && i.year === n && i.month === s && i.day === E) || !!(c && c.year === n && c.month === s && c.day === E) : !!(o && o.year === n && o.month === s && o.day === E),
|
|
643
635
|
isInRange: (E) => {
|
|
644
636
|
if (!i || !c) return !1;
|
|
645
|
-
const
|
|
646
|
-
return
|
|
637
|
+
const $ = new Date(n, s, E).getTime(), p = new Date(i.year, i.month, i.day).getTime(), C = new Date(c.year, c.month, c.day).getTime();
|
|
638
|
+
return $ >= p && $ <= C;
|
|
647
639
|
}
|
|
648
640
|
};
|
|
649
641
|
}, Z = (e, t, n) => {
|
|
@@ -676,7 +668,7 @@ const y3 = [
|
|
|
676
668
|
a -= 1, s += 12;
|
|
677
669
|
for (; s >= 12; )
|
|
678
670
|
a += 1, s -= 12;
|
|
679
|
-
const r =
|
|
671
|
+
const r = fe("BS", a, s), o = Math.min(e.day, r);
|
|
680
672
|
return { year: a, month: s, day: o };
|
|
681
673
|
} catch {
|
|
682
674
|
return e;
|
|
@@ -697,7 +689,7 @@ const y3 = [
|
|
|
697
689
|
const n = new Date(e.year, e.month, e.day), a = n.getDay();
|
|
698
690
|
return n.setDate(n.getDate() - a), { year: n.getFullYear(), month: n.getMonth(), day: n.getDate() };
|
|
699
691
|
}
|
|
700
|
-
},
|
|
692
|
+
}, O3 = {
|
|
701
693
|
TODAY: "today",
|
|
702
694
|
YESTERDAY: "yesterday",
|
|
703
695
|
THIS_WEEK: "thisWeek",
|
|
@@ -716,7 +708,7 @@ const y3 = [
|
|
|
716
708
|
key: "today",
|
|
717
709
|
label: "Today",
|
|
718
710
|
getValue: (s) => {
|
|
719
|
-
const r =
|
|
711
|
+
const r = H(s);
|
|
720
712
|
return { start: r, end: r };
|
|
721
713
|
}
|
|
722
714
|
},
|
|
@@ -724,7 +716,7 @@ const y3 = [
|
|
|
724
716
|
key: "yesterday",
|
|
725
717
|
label: "Yesterday",
|
|
726
718
|
getValue: (s) => {
|
|
727
|
-
const r =
|
|
719
|
+
const r = H(s), o = Z(r, -1, s);
|
|
728
720
|
return { start: o, end: o };
|
|
729
721
|
}
|
|
730
722
|
},
|
|
@@ -732,7 +724,7 @@ const y3 = [
|
|
|
732
724
|
key: "thisWeek",
|
|
733
725
|
label: "This Week",
|
|
734
726
|
getValue: (s) => {
|
|
735
|
-
const r =
|
|
727
|
+
const r = H(s);
|
|
736
728
|
return { start: w3(r, s), end: r };
|
|
737
729
|
}
|
|
738
730
|
},
|
|
@@ -740,7 +732,7 @@ const y3 = [
|
|
|
740
732
|
key: "last7days",
|
|
741
733
|
label: "Last 7 Days",
|
|
742
734
|
getValue: (s) => {
|
|
743
|
-
const r =
|
|
735
|
+
const r = H(s);
|
|
744
736
|
return { start: Z(r, -6, s), end: r };
|
|
745
737
|
}
|
|
746
738
|
},
|
|
@@ -748,7 +740,7 @@ const y3 = [
|
|
|
748
740
|
key: "last30days",
|
|
749
741
|
label: "Last 30 Days",
|
|
750
742
|
getValue: (s) => {
|
|
751
|
-
const r =
|
|
743
|
+
const r = H(s);
|
|
752
744
|
return { start: Z(r, -29, s), end: r };
|
|
753
745
|
}
|
|
754
746
|
},
|
|
@@ -756,7 +748,7 @@ const y3 = [
|
|
|
756
748
|
key: "thisMonth",
|
|
757
749
|
label: "This Month",
|
|
758
750
|
getValue: (s) => {
|
|
759
|
-
const r =
|
|
751
|
+
const r = H(s);
|
|
760
752
|
return { start: z(r), end: r };
|
|
761
753
|
}
|
|
762
754
|
},
|
|
@@ -764,7 +756,7 @@ const y3 = [
|
|
|
764
756
|
key: "lastMonth",
|
|
765
757
|
label: "Last Month",
|
|
766
758
|
getValue: (s) => {
|
|
767
|
-
const r =
|
|
759
|
+
const r = H(s), o = Z(z(r), -1, s);
|
|
768
760
|
return { start: z(o), end: o };
|
|
769
761
|
}
|
|
770
762
|
},
|
|
@@ -772,7 +764,7 @@ const y3 = [
|
|
|
772
764
|
key: "last3months",
|
|
773
765
|
label: "Last 3 Months",
|
|
774
766
|
getValue: (s) => {
|
|
775
|
-
const r =
|
|
767
|
+
const r = H(s), o = dt(r, -2, s);
|
|
776
768
|
return { start: z(o), end: r };
|
|
777
769
|
}
|
|
778
770
|
},
|
|
@@ -780,7 +772,7 @@ const y3 = [
|
|
|
780
772
|
key: "last6months",
|
|
781
773
|
label: "Last 6 Months",
|
|
782
774
|
getValue: (s) => {
|
|
783
|
-
const r =
|
|
775
|
+
const r = H(s), o = dt(r, -5, s);
|
|
784
776
|
return { start: z(o), end: r };
|
|
785
777
|
}
|
|
786
778
|
},
|
|
@@ -788,7 +780,7 @@ const y3 = [
|
|
|
788
780
|
key: "last180days",
|
|
789
781
|
label: "Last 180 Days",
|
|
790
782
|
getValue: (s) => {
|
|
791
|
-
const r =
|
|
783
|
+
const r = H(s);
|
|
792
784
|
return { start: Z(r, -179, s), end: r };
|
|
793
785
|
}
|
|
794
786
|
},
|
|
@@ -796,7 +788,7 @@ const y3 = [
|
|
|
796
788
|
key: "last9months",
|
|
797
789
|
label: "Last 9 Months",
|
|
798
790
|
getValue: (s) => {
|
|
799
|
-
const r =
|
|
791
|
+
const r = H(s), o = dt(r, -8, s);
|
|
800
792
|
return { start: z(o), end: r };
|
|
801
793
|
}
|
|
802
794
|
},
|
|
@@ -804,7 +796,7 @@ const y3 = [
|
|
|
804
796
|
key: "lastYear",
|
|
805
797
|
label: "Last Year",
|
|
806
798
|
getValue: (s) => {
|
|
807
|
-
const r =
|
|
799
|
+
const r = H(s), o = dt(r, -11, s);
|
|
808
800
|
return { start: z(o), end: r };
|
|
809
801
|
}
|
|
810
802
|
}
|
|
@@ -821,7 +813,7 @@ const y3 = [
|
|
|
821
813
|
convertToNepaliNumber: u = (h) => h.toString(),
|
|
822
814
|
calendarType: i
|
|
823
815
|
}) => {
|
|
824
|
-
const [h, c] = B(Math.floor(e / 12) * 12),
|
|
816
|
+
const [h, c] = B(Math.floor(e / 12) * 12), f = i === "BS" ? 2e3 : 1944, d = i === "BS" ? 2100 : 2043;
|
|
825
817
|
return /* @__PURE__ */ g("div", { className: "bsac-picker-overlay", onClick: r, children: /* @__PURE__ */ S("div", { className: "bsac-picker-content", onClick: (k) => k.stopPropagation(), children: [
|
|
826
818
|
/* @__PURE__ */ S("div", { className: "bsac-picker-header", children: [
|
|
827
819
|
/* @__PURE__ */ g("h3", { children: "Select Month & Year" }),
|
|
@@ -832,7 +824,7 @@ const y3 = [
|
|
|
832
824
|
/* @__PURE__ */ S("div", { className: "bsac-picker-section-header", children: [
|
|
833
825
|
/* @__PURE__ */ g("label", { children: "Year" }),
|
|
834
826
|
/* @__PURE__ */ S("div", { className: "bsac-year-nav", children: [
|
|
835
|
-
/* @__PURE__ */ g("button", { onClick: () => c(Math.max(
|
|
827
|
+
/* @__PURE__ */ g("button", { onClick: () => c(Math.max(f, h - 12)), disabled: h <= f, children: "«" }),
|
|
836
828
|
/* @__PURE__ */ S("span", { children: [
|
|
837
829
|
o ? u(h) : h,
|
|
838
830
|
" – ",
|
|
@@ -882,11 +874,11 @@ const y3 = [
|
|
|
882
874
|
convertToNepaliNumber: i,
|
|
883
875
|
calendarType: h
|
|
884
876
|
}) => {
|
|
885
|
-
const [c,
|
|
877
|
+
const [c, f] = B(!1);
|
|
886
878
|
return /* @__PURE__ */ S("div", { className: "bsac-header", children: [
|
|
887
879
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(-12), disabled: o, "aria-label": "Previous year", children: "«" }),
|
|
888
880
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(-1), disabled: o, "aria-label": "Previous month", children: "‹" }),
|
|
889
|
-
/* @__PURE__ */ S("button", { className: "bsac-month-year-btn", onClick: () =>
|
|
881
|
+
/* @__PURE__ */ S("button", { className: "bsac-month-year-btn", onClick: () => f(!0), disabled: o, children: [
|
|
890
882
|
n[e],
|
|
891
883
|
" ",
|
|
892
884
|
u ? i(t) : t
|
|
@@ -901,7 +893,7 @@ const y3 = [
|
|
|
901
893
|
months: n,
|
|
902
894
|
onYearChange: s,
|
|
903
895
|
onMonthChange: r,
|
|
904
|
-
onClose: () =>
|
|
896
|
+
onClose: () => f(!1),
|
|
905
897
|
showNepaliNumbers: u,
|
|
906
898
|
convertToNepaliNumber: i,
|
|
907
899
|
calendarType: h
|
|
@@ -921,22 +913,22 @@ const y3 = [
|
|
|
921
913
|
convertToNepaliNumber: h
|
|
922
914
|
}) => /* @__PURE__ */ S("div", { className: "bsac-grid", children: [
|
|
923
915
|
t.map((c) => /* @__PURE__ */ g("div", { className: "bsac-day-header", children: c }, c)),
|
|
924
|
-
e.map((c,
|
|
925
|
-
const d = c ? o?.(c) || u : !1, k = c ? a(c) : !1, m = c ? s(c) : !1, A = c ? r(c) : !1,
|
|
916
|
+
e.map((c, f) => {
|
|
917
|
+
const d = c ? o?.(c) || u : !1, k = c ? a(c) : !1, m = c ? s(c) : !1, A = c ? r(c) : !1, O = [
|
|
926
918
|
"bsac-day",
|
|
927
919
|
c ? d ? "bsac-day-disabled" : k ? "bsac-day-selected" : m ? "bsac-day-in-range" : A ? "bsac-day-today" : "" : "bsac-day-empty"
|
|
928
920
|
].filter(Boolean).join(" ");
|
|
929
921
|
return /* @__PURE__ */ g(
|
|
930
922
|
"div",
|
|
931
923
|
{
|
|
932
|
-
className:
|
|
924
|
+
className: O,
|
|
933
925
|
onClick: () => c && !d && n(c),
|
|
934
926
|
children: c ? i ? h(c) : c : ""
|
|
935
927
|
},
|
|
936
|
-
|
|
928
|
+
f
|
|
937
929
|
);
|
|
938
930
|
})
|
|
939
|
-
] }),
|
|
931
|
+
] }), ft = ({
|
|
940
932
|
presets: e,
|
|
941
933
|
calendarType: t,
|
|
942
934
|
onPresetSelect: n,
|
|
@@ -968,14 +960,14 @@ const y3 = [
|
|
|
968
960
|
mode: i = "single",
|
|
969
961
|
onRangeSelect: h,
|
|
970
962
|
showRangePresets: c = !1,
|
|
971
|
-
rangePresetsPosition:
|
|
963
|
+
rangePresetsPosition: f = "top",
|
|
972
964
|
predefinedRanges: d,
|
|
973
965
|
presetKeys: k,
|
|
974
966
|
presetLabels: m,
|
|
975
967
|
onPresetSelect: A,
|
|
976
|
-
renderPresets:
|
|
968
|
+
renderPresets: O,
|
|
977
969
|
showNepaliMonths: E = !1,
|
|
978
|
-
showNepaliDays:
|
|
970
|
+
showNepaliDays: $ = !1,
|
|
979
971
|
showNepaliNumbers: p = !1,
|
|
980
972
|
theme: C = "light",
|
|
981
973
|
colors: nt,
|
|
@@ -983,42 +975,42 @@ const y3 = [
|
|
|
983
975
|
maxDate: K
|
|
984
976
|
}) => {
|
|
985
977
|
const {
|
|
986
|
-
currentYear:
|
|
987
|
-
currentMonth:
|
|
978
|
+
currentYear: T,
|
|
979
|
+
currentMonth: N,
|
|
988
980
|
rangeStart: U,
|
|
989
981
|
rangeEnd: y,
|
|
990
982
|
calendarDays: w,
|
|
991
983
|
setSelectedDate: R,
|
|
992
984
|
setRangeStart: M,
|
|
993
|
-
setRangeEnd:
|
|
985
|
+
setRangeEnd: v,
|
|
994
986
|
setCurrentYear: _,
|
|
995
987
|
setCurrentMonth: j,
|
|
996
|
-
navigateMonth:
|
|
988
|
+
navigateMonth: F,
|
|
997
989
|
isToday: st,
|
|
998
990
|
isSelected: at,
|
|
999
991
|
isInRange: rt
|
|
1000
|
-
} = E3(e), [ot, Et] = B(), it = d || Y3(k, m), ut = (l,
|
|
992
|
+
} = E3(e), [ot, Et] = B(), it = d || Y3(k, m), ut = (l, D) => ({
|
|
1001
993
|
start: wt(e, l.year, l.month, l.day, G),
|
|
1002
|
-
end: wt(e,
|
|
1003
|
-
}), G = e === "BS" && E ? y3 : e === "BS" ? me :
|
|
1004
|
-
|
|
1005
|
-
}, ye = (l,
|
|
1006
|
-
M(l),
|
|
994
|
+
end: wt(e, D.year, D.month, D.day, G)
|
|
995
|
+
}), G = e === "BS" && E ? y3 : e === "BS" ? me : D3, ct = e === "BS" && $ ? M3 : p3, ht = (l, D) => {
|
|
996
|
+
D.start && D.end && (M(D.start), v(D.end), _(D.start.year), j(D.start.month), Et(l.key), A?.(l, D), h?.(ut(D.start, D.end)));
|
|
997
|
+
}, ye = (l, D) => {
|
|
998
|
+
M(l), v(D), Et(void 0), h?.(ut(l, D));
|
|
1007
999
|
}, lt = (l) => {
|
|
1008
1000
|
if (r) return;
|
|
1009
|
-
const
|
|
1010
|
-
if (et(
|
|
1001
|
+
const D = { year: T, month: N, day: l };
|
|
1002
|
+
if (et(D, I, K)) return;
|
|
1011
1003
|
if (i === "range") {
|
|
1012
1004
|
if (Et(void 0), !U || U && y)
|
|
1013
|
-
M(
|
|
1005
|
+
M(D), v(null);
|
|
1014
1006
|
else {
|
|
1015
1007
|
const X = new Date(U.year, U.month, U.day).getTime();
|
|
1016
|
-
new Date(
|
|
1008
|
+
new Date(D.year, D.month, D.day).getTime() < X ? (M(D), v(U), h?.(ut(D, U))) : (v(D), h?.(ut(U, D)));
|
|
1017
1009
|
}
|
|
1018
1010
|
return;
|
|
1019
1011
|
}
|
|
1020
|
-
R(
|
|
1021
|
-
const q = wt(e,
|
|
1012
|
+
R(D);
|
|
1013
|
+
const q = wt(e, T, N, l, G);
|
|
1022
1014
|
if (u?.(q), n) {
|
|
1023
1015
|
let X;
|
|
1024
1016
|
switch (o) {
|
|
@@ -1034,26 +1026,26 @@ const y3 = [
|
|
|
1034
1026
|
}
|
|
1035
1027
|
n(X);
|
|
1036
1028
|
}
|
|
1037
|
-
},
|
|
1029
|
+
}, De = (l) => {
|
|
1038
1030
|
if (!r) {
|
|
1039
1031
|
switch (l.key) {
|
|
1040
1032
|
case "ArrowLeft":
|
|
1041
|
-
|
|
1033
|
+
F(-1);
|
|
1042
1034
|
break;
|
|
1043
1035
|
case "ArrowRight":
|
|
1044
|
-
|
|
1036
|
+
F(1);
|
|
1045
1037
|
break;
|
|
1046
1038
|
case "ArrowUp":
|
|
1047
|
-
|
|
1039
|
+
F(-12);
|
|
1048
1040
|
break;
|
|
1049
1041
|
case "ArrowDown":
|
|
1050
|
-
|
|
1042
|
+
F(12);
|
|
1051
1043
|
break;
|
|
1052
1044
|
case "PageUp":
|
|
1053
|
-
l.shiftKey ?
|
|
1045
|
+
l.shiftKey ? F(-12) : F(-1);
|
|
1054
1046
|
break;
|
|
1055
1047
|
case "PageDown":
|
|
1056
|
-
l.shiftKey ?
|
|
1048
|
+
l.shiftKey ? F(12) : F(1);
|
|
1057
1049
|
break;
|
|
1058
1050
|
default:
|
|
1059
1051
|
return;
|
|
@@ -1062,7 +1054,7 @@ const y3 = [
|
|
|
1062
1054
|
}
|
|
1063
1055
|
}, Me = {
|
|
1064
1056
|
...nt ? Object.entries(nt).reduce(
|
|
1065
|
-
(l, [
|
|
1057
|
+
(l, [D, q]) => (l[`--calendar-${D}`] = q, l),
|
|
1066
1058
|
{}
|
|
1067
1059
|
) : {}
|
|
1068
1060
|
};
|
|
@@ -1072,21 +1064,21 @@ const y3 = [
|
|
|
1072
1064
|
className: `bsac-calendar ${a}`,
|
|
1073
1065
|
style: Me,
|
|
1074
1066
|
"data-theme": C,
|
|
1075
|
-
onKeyDown:
|
|
1067
|
+
onKeyDown: De,
|
|
1076
1068
|
tabIndex: 0,
|
|
1077
1069
|
role: "application",
|
|
1078
1070
|
"aria-label": "Calendar",
|
|
1079
1071
|
children: [
|
|
1080
|
-
i === "range" &&
|
|
1081
|
-
/* @__PURE__ */ g("div", { children:
|
|
1072
|
+
i === "range" && O && /* @__PURE__ */ S("div", { style: { display: "flex", gap: "16px" }, children: [
|
|
1073
|
+
/* @__PURE__ */ g("div", { children: O({ onRangeChange: ye }) }),
|
|
1082
1074
|
/* @__PURE__ */ S("div", { style: { flex: 1 }, children: [
|
|
1083
1075
|
/* @__PURE__ */ g(
|
|
1084
1076
|
gt,
|
|
1085
1077
|
{
|
|
1086
|
-
currentMonth:
|
|
1087
|
-
currentYear:
|
|
1078
|
+
currentMonth: N,
|
|
1079
|
+
currentYear: T,
|
|
1088
1080
|
months: G,
|
|
1089
|
-
onNavigateMonth:
|
|
1081
|
+
onNavigateMonth: F,
|
|
1090
1082
|
onYearChange: _,
|
|
1091
1083
|
onMonthChange: j,
|
|
1092
1084
|
disabled: r,
|
|
@@ -1104,7 +1096,7 @@ const y3 = [
|
|
|
1104
1096
|
isSelected: (l) => at(l, i),
|
|
1105
1097
|
isInRange: rt,
|
|
1106
1098
|
isToday: (l) => s && st(l),
|
|
1107
|
-
isDisabled: (l) => et({ year:
|
|
1099
|
+
isDisabled: (l) => et({ year: T, month: N, day: l }, I, K),
|
|
1108
1100
|
disabled: r,
|
|
1109
1101
|
showNepaliNumbers: p,
|
|
1110
1102
|
convertToNepaliNumber: V
|
|
@@ -1112,9 +1104,9 @@ const y3 = [
|
|
|
1112
1104
|
)
|
|
1113
1105
|
] })
|
|
1114
1106
|
] }),
|
|
1115
|
-
i === "range" && c &&
|
|
1107
|
+
i === "range" && c && f === "left" && !O && /* @__PURE__ */ S("div", { style: { display: "flex", gap: "16px", flexWrap: "nowrap" }, children: [
|
|
1116
1108
|
/* @__PURE__ */ g(
|
|
1117
|
-
|
|
1109
|
+
ft,
|
|
1118
1110
|
{
|
|
1119
1111
|
presets: it,
|
|
1120
1112
|
calendarType: e,
|
|
@@ -1127,10 +1119,10 @@ const y3 = [
|
|
|
1127
1119
|
/* @__PURE__ */ g(
|
|
1128
1120
|
gt,
|
|
1129
1121
|
{
|
|
1130
|
-
currentMonth:
|
|
1131
|
-
currentYear:
|
|
1122
|
+
currentMonth: N,
|
|
1123
|
+
currentYear: T,
|
|
1132
1124
|
months: G,
|
|
1133
|
-
onNavigateMonth:
|
|
1125
|
+
onNavigateMonth: F,
|
|
1134
1126
|
onYearChange: _,
|
|
1135
1127
|
onMonthChange: j,
|
|
1136
1128
|
disabled: r,
|
|
@@ -1148,7 +1140,7 @@ const y3 = [
|
|
|
1148
1140
|
isSelected: (l) => at(l, i),
|
|
1149
1141
|
isInRange: rt,
|
|
1150
1142
|
isToday: (l) => s && st(l),
|
|
1151
|
-
isDisabled: (l) => et({ year:
|
|
1143
|
+
isDisabled: (l) => et({ year: T, month: N, day: l }, I, K),
|
|
1152
1144
|
disabled: r,
|
|
1153
1145
|
showNepaliNumbers: p,
|
|
1154
1146
|
convertToNepaliNumber: V
|
|
@@ -1156,15 +1148,15 @@ const y3 = [
|
|
|
1156
1148
|
)
|
|
1157
1149
|
] })
|
|
1158
1150
|
] }),
|
|
1159
|
-
i === "range" && c &&
|
|
1151
|
+
i === "range" && c && f === "right" && !O && /* @__PURE__ */ S("div", { style: { display: "flex", gap: "16px", flexWrap: "nowrap" }, children: [
|
|
1160
1152
|
/* @__PURE__ */ S("div", { children: [
|
|
1161
1153
|
/* @__PURE__ */ g(
|
|
1162
1154
|
gt,
|
|
1163
1155
|
{
|
|
1164
|
-
currentMonth:
|
|
1165
|
-
currentYear:
|
|
1156
|
+
currentMonth: N,
|
|
1157
|
+
currentYear: T,
|
|
1166
1158
|
months: G,
|
|
1167
|
-
onNavigateMonth:
|
|
1159
|
+
onNavigateMonth: F,
|
|
1168
1160
|
onYearChange: _,
|
|
1169
1161
|
onMonthChange: j,
|
|
1170
1162
|
disabled: r,
|
|
@@ -1182,7 +1174,7 @@ const y3 = [
|
|
|
1182
1174
|
isSelected: (l) => at(l, i),
|
|
1183
1175
|
isInRange: rt,
|
|
1184
1176
|
isToday: (l) => s && st(l),
|
|
1185
|
-
isDisabled: (l) => et({ year:
|
|
1177
|
+
isDisabled: (l) => et({ year: T, month: N, day: l }, I, K),
|
|
1186
1178
|
disabled: r,
|
|
1187
1179
|
showNepaliNumbers: p,
|
|
1188
1180
|
convertToNepaliNumber: V
|
|
@@ -1190,7 +1182,7 @@ const y3 = [
|
|
|
1190
1182
|
)
|
|
1191
1183
|
] }),
|
|
1192
1184
|
/* @__PURE__ */ g(
|
|
1193
|
-
|
|
1185
|
+
ft,
|
|
1194
1186
|
{
|
|
1195
1187
|
presets: it,
|
|
1196
1188
|
calendarType: e,
|
|
@@ -1200,9 +1192,9 @@ const y3 = [
|
|
|
1200
1192
|
}
|
|
1201
1193
|
)
|
|
1202
1194
|
] }),
|
|
1203
|
-
(!i || i === "single" || !c && !
|
|
1204
|
-
i === "range" && c &&
|
|
1205
|
-
|
|
1195
|
+
(!i || i === "single" || !c && !O || f === "top" || f === "bottom") && /* @__PURE__ */ S(pe, { children: [
|
|
1196
|
+
i === "range" && c && f === "top" && /* @__PURE__ */ g(
|
|
1197
|
+
ft,
|
|
1206
1198
|
{
|
|
1207
1199
|
presets: it,
|
|
1208
1200
|
calendarType: e,
|
|
@@ -1214,10 +1206,10 @@ const y3 = [
|
|
|
1214
1206
|
/* @__PURE__ */ g(
|
|
1215
1207
|
gt,
|
|
1216
1208
|
{
|
|
1217
|
-
currentMonth:
|
|
1218
|
-
currentYear:
|
|
1209
|
+
currentMonth: N,
|
|
1210
|
+
currentYear: T,
|
|
1219
1211
|
months: G,
|
|
1220
|
-
onNavigateMonth:
|
|
1212
|
+
onNavigateMonth: F,
|
|
1221
1213
|
onYearChange: _,
|
|
1222
1214
|
onMonthChange: j,
|
|
1223
1215
|
disabled: r,
|
|
@@ -1235,14 +1227,14 @@ const y3 = [
|
|
|
1235
1227
|
isSelected: (l) => at(l, i),
|
|
1236
1228
|
isInRange: rt,
|
|
1237
1229
|
isToday: (l) => s && st(l),
|
|
1238
|
-
isDisabled: (l) => et({ year:
|
|
1230
|
+
isDisabled: (l) => et({ year: T, month: N, day: l }, I, K),
|
|
1239
1231
|
disabled: r,
|
|
1240
1232
|
showNepaliNumbers: p,
|
|
1241
1233
|
convertToNepaliNumber: V
|
|
1242
1234
|
}
|
|
1243
1235
|
),
|
|
1244
|
-
i === "range" && c &&
|
|
1245
|
-
|
|
1236
|
+
i === "range" && c && f === "bottom" && /* @__PURE__ */ g(
|
|
1237
|
+
ft,
|
|
1246
1238
|
{
|
|
1247
1239
|
presets: it,
|
|
1248
1240
|
calendarType: e,
|
|
@@ -1255,7 +1247,7 @@ const y3 = [
|
|
|
1255
1247
|
]
|
|
1256
1248
|
}
|
|
1257
1249
|
);
|
|
1258
|
-
},
|
|
1250
|
+
}, T3 = ({
|
|
1259
1251
|
placeholder: e = "Select date",
|
|
1260
1252
|
format: t = "YYYY-MM-DD",
|
|
1261
1253
|
defaultValue: n,
|
|
@@ -1267,9 +1259,9 @@ const y3 = [
|
|
|
1267
1259
|
icon: i,
|
|
1268
1260
|
showIcon: h = !0,
|
|
1269
1261
|
calendarType: c = "AD",
|
|
1270
|
-
...
|
|
1262
|
+
...f
|
|
1271
1263
|
}) => {
|
|
1272
|
-
const [d, k] = B(!1), [m, A] = B(null), [
|
|
1264
|
+
const [d, k] = B(!1), [m, A] = B(null), [O, E] = B(() => {
|
|
1273
1265
|
if (!n) return "";
|
|
1274
1266
|
if (c === "BS")
|
|
1275
1267
|
try {
|
|
@@ -1279,70 +1271,71 @@ const y3 = [
|
|
|
1279
1271
|
return n;
|
|
1280
1272
|
}
|
|
1281
1273
|
return n;
|
|
1282
|
-
}),
|
|
1283
|
-
if (
|
|
1284
|
-
const y =
|
|
1274
|
+
}), $ = Ft(null), p = Ft(null), [C, nt] = B({ visibility: "hidden" }), I = () => {
|
|
1275
|
+
if (!$.current) return;
|
|
1276
|
+
const y = $.current.getBoundingClientRect(), w = p.current?.offsetHeight || 360, R = p.current?.offsetWidth || 280, M = window.innerHeight - y.bottom, v = window.innerWidth - y.left, _ = M >= w + 8 ? y.bottom + 8 : Math.max(8, y.top - w - 8), j = v >= R ? y.left : Math.max(8, y.right - R);
|
|
1285
1277
|
nt({ top: _, left: j, visibility: "visible" });
|
|
1286
1278
|
};
|
|
1287
1279
|
Yt(() => (d && (requestAnimationFrame(I), window.addEventListener("scroll", I, !0), window.addEventListener("resize", I)), () => {
|
|
1288
1280
|
window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I);
|
|
1289
1281
|
}), [d]), Yt(() => {
|
|
1290
1282
|
const y = (w) => {
|
|
1291
|
-
|
|
1283
|
+
$.current && !$.current.contains(w.target) && k(!1);
|
|
1292
1284
|
};
|
|
1293
1285
|
return d && document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y);
|
|
1294
1286
|
}, [d]);
|
|
1295
1287
|
const K = (y) => {
|
|
1296
1288
|
A(y), E(c === "BS" ? y.bs : y.ad), k(!1), a?.(y);
|
|
1297
|
-
},
|
|
1289
|
+
}, T = (y) => {
|
|
1298
1290
|
const w = y.target.value;
|
|
1299
1291
|
if (w === "") {
|
|
1300
1292
|
E("");
|
|
1301
1293
|
return;
|
|
1302
1294
|
}
|
|
1303
|
-
if ((y.target.selectionStart || 0) === w.length && w.length >
|
|
1295
|
+
if ((y.target.selectionStart || 0) === w.length && w.length > O.length) {
|
|
1304
1296
|
const M = w.replace(/[^0-9]/g, "");
|
|
1305
|
-
let
|
|
1306
|
-
M.length > 4 && M.length <= 6 ?
|
|
1297
|
+
let v = M;
|
|
1298
|
+
M.length > 4 && M.length <= 6 ? v = M.slice(0, 4) + "-" + M.slice(4) : M.length > 6 && (v = M.slice(0, 4) + "-" + M.slice(4, 6) + "-" + M.slice(6, 8)), E(v);
|
|
1307
1299
|
} else {
|
|
1308
1300
|
const M = w.replace(/[^0-9-]/g, "");
|
|
1309
1301
|
M.length <= 10 && E(M);
|
|
1310
1302
|
}
|
|
1311
|
-
},
|
|
1312
|
-
const y =
|
|
1303
|
+
}, N = () => {
|
|
1304
|
+
const y = O.trim();
|
|
1313
1305
|
if (!y) {
|
|
1314
1306
|
A(null);
|
|
1315
1307
|
return;
|
|
1316
1308
|
}
|
|
1317
1309
|
const w = y.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
1318
1310
|
if (w) {
|
|
1319
|
-
const [, R, M,
|
|
1311
|
+
const [, R, M, v] = w, _ = parseInt(M), j = parseInt(v);
|
|
1320
1312
|
if (_ < 1 || _ > 12 || j < 1 || j > 32) {
|
|
1321
1313
|
E(m ? c === "BS" ? m.bs : m.ad : "");
|
|
1322
1314
|
return;
|
|
1323
1315
|
}
|
|
1324
|
-
const
|
|
1325
|
-
bs: c === "BS" ? `${R}-${M}-${
|
|
1326
|
-
ad: c === "AD" ? `${R}-${M}-${
|
|
1316
|
+
const F = {
|
|
1317
|
+
bs: c === "BS" ? `${R}-${M}-${v}` : "",
|
|
1318
|
+
ad: c === "AD" ? `${R}-${M}-${v}` : "",
|
|
1327
1319
|
formatted: {
|
|
1328
1320
|
bs: c === "BS" ? y : "",
|
|
1329
1321
|
ad: c === "AD" ? y : ""
|
|
1330
1322
|
}
|
|
1331
1323
|
};
|
|
1332
|
-
A(
|
|
1324
|
+
if (A(F), m === null) return;
|
|
1325
|
+
a?.(F);
|
|
1333
1326
|
} else y.length < 10 && E(m ? c === "BS" ? m.bs : m.ad : "");
|
|
1334
1327
|
};
|
|
1335
|
-
return /* @__PURE__ */ S("div", { className: "bsac-datepicker", ref:
|
|
1328
|
+
return /* @__PURE__ */ S("div", { className: "bsac-datepicker", ref: $, style: o, children: [
|
|
1336
1329
|
/* @__PURE__ */ g(
|
|
1337
1330
|
"input",
|
|
1338
1331
|
{
|
|
1339
1332
|
type: "text",
|
|
1340
|
-
value:
|
|
1333
|
+
value: O,
|
|
1341
1334
|
placeholder: e,
|
|
1342
|
-
onChange:
|
|
1343
|
-
onBlur:
|
|
1335
|
+
onChange: T,
|
|
1336
|
+
onBlur: N,
|
|
1344
1337
|
onKeyDown: (y) => {
|
|
1345
|
-
y.key === "Enter" ? (
|
|
1338
|
+
y.key === "Enter" ? (N(), k(!1)) : y.key === "Escape" && k(!1);
|
|
1346
1339
|
},
|
|
1347
1340
|
className: `bsac-input ${s}`,
|
|
1348
1341
|
style: u,
|
|
@@ -1368,27 +1361,27 @@ const y3 = [
|
|
|
1368
1361
|
] })
|
|
1369
1362
|
}
|
|
1370
1363
|
),
|
|
1371
|
-
d && /* @__PURE__ */ g("div", { ref: p, className: `bsac-popup ${r}`, style: C, children: /* @__PURE__ */ g(C3, { calendarType: c, onDateSelect: K, ...
|
|
1364
|
+
d && /* @__PURE__ */ g("div", { ref: p, className: `bsac-popup ${r}`, style: C, children: /* @__PURE__ */ g(C3, { calendarType: c, onDateSelect: K, ...f }) })
|
|
1372
1365
|
] });
|
|
1373
1366
|
};
|
|
1374
1367
|
export {
|
|
1375
1368
|
C3 as Calendar,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1369
|
+
T3 as CalendarInput,
|
|
1370
|
+
N3 as DEFAULT_COLORS,
|
|
1371
|
+
T3 as DatePicker,
|
|
1379
1372
|
p3 as ENGLISH_DAYS,
|
|
1380
|
-
|
|
1373
|
+
D3 as ENGLISH_MONTHS_AD,
|
|
1381
1374
|
me as ENGLISH_MONTHS_BS,
|
|
1382
1375
|
M3 as NEPALI_DAYS,
|
|
1383
1376
|
b3 as NEPALI_DIGITS,
|
|
1384
1377
|
y3 as NEPALI_MONTHS,
|
|
1385
|
-
|
|
1378
|
+
O3 as PRESET_KEYS,
|
|
1386
1379
|
V as convertToNepaliNumber,
|
|
1387
1380
|
wt as createDateOutput,
|
|
1388
1381
|
Y3 as createPredefinedRanges,
|
|
1389
|
-
|
|
1382
|
+
fe as getDaysInMonth,
|
|
1390
1383
|
S3 as getFirstDayOfMonth,
|
|
1391
|
-
|
|
1392
|
-
|
|
1384
|
+
H as getTodayDate,
|
|
1385
|
+
H3 as isDateInRange,
|
|
1393
1386
|
E3 as useCalendar
|
|
1394
1387
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(S,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],h):(S=typeof globalThis<"u"?globalThis:S||self,h(S.BSADCalendar={},S.ReactJSXRuntime,S.React))})(this,(function(S,h,k){"use strict";const X=[1943,4,14],Ft=[31,28,31,30,31,30,31,31,30,31,30,31],we=[31,29,31,30,31,30,31,31,30,31,30,31],_=[[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,32,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,32,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,31,29,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365]];let Nt=class extends Error{constructor(t){super(t),this.name="DateOutOfRangeError"}};const Tt=()=>X[0]+1,Ot=()=>X[0]+_.length-1,Ht=()=>2e3,It=()=>2e3+_.length-1,nt=e=>e%400===0||e%4===0&&e%100!==0,wt=e=>nt(e)?we:Ft,Ye=(e,t,n)=>!(e<Tt()||e>Ot()||t<1||t>12||n<1||n>wt(e)[t-1]),Bt=(e,t,n)=>{let a=e*365+n;for(let s=0;s<t-1;s++)a+=Ft[s];return t<=2&&(e-=1),a+=Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400),a};function ke(e,t,n){const a=t+1;if(!Ye(e,a,n))throw new Nt("Date out of range");let s=2e3,r=1,o=1,u=Math.abs(Bt(e,a,n)-Bt(...X)),i=0;for(;u>=_[i][1];)u-=_[i][1],s+=1,i+=1;let l=0;for(;u>=_[i][0][l];)u-=_[i][0][l],r+=1,l+=1;return o+=u,[s,r-1,o]}const Ce=(e,t,n)=>!(e<Ht()||e>It()||t<1||t>12||n<1||n>_[e-2e3][0][t-1]),Ae=(e,t,n)=>{let a=n-1;const s=e-2e3;for(let r=0;r<t-1;r++)a+=_[s][0][r];for(let r=0;r<s;r++)a+=_[r][1];return a},ve=(e,t,n)=>{const a=t+1;if(!Ce(e,a,n))throw new Nt("Date out of range");let[s,r,o]=[X[0],1,1];const u=wt(s).slice(0,X[1]-1).reduce((f,g)=>f+g,0)+X[2]-1;let i=Math.abs(Ae(e,a,n)+u);for(;i>=366&&nt(s)||i>=365&&!nt(s);)i-=nt(s)?366:365,s+=1;const l=wt(s);let c=0;for(;i>=l[c];)i-=l[c],r+=1,c+=1;return o+=i,[s,r-1,o]},V={enMinYear:Tt,enMaxYear:Ot,npMinYear:Ht,npMaxYear:It,englishToNepali:ke,nepaliToEnglish:ve},Lt="en",L="ne",xt=207e5,_t=198e5,$e=5049018e5,Fe=new Date(1986,0,1,0,15),st=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],Yt=["Bai","Jes","Asa","Shr","Bhd","Asw","Kar","Man","Pou","Mag","Fal","Cha"],jt=["बैशाख","जेठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुण","चैत्र"],Ne=["बै","जे","अ","श्रा","भा","आ","का","मं","पौ","मा","फा","चै"],kt=["January","February","March","April","May","June","July","August","September","October","November","December"],Ct=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Te=["जनवरी","फेब्रुअरी","मार्च","अप्रिल","मे","जुन","जुलाई","अगस्ट","सेप्टेम्बर","अक्टोबर","नोभेम्बर","डिसेम्बर"],Oe=["जन","फेब","मार","अप्रि","मे","जुन","जुला","अग","सेप","अक्टो","नोभे","डिसे"],Pt=["०","१","२","३","४","५","६","७","८","९"],Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],at=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Wt=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],Ut=["आइतबार","सोमबार","मंगलबार","बुधबार","बिहिबार","शुक्रबार","शनिबार"],He=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DD?|ddd?d?|do?|YYYY|YY|y{2,4}|yo?|a|A|hh?|HH?|mm?|ss?|SSS|x|X|.)/g,Ie=e=>{const t=e.getTime(),n=t<$e?_t:xt,a=new Date(t+n),s=a.getUTCFullYear(),r=a.getUTCMonth(),o=a.getUTCDate(),u=a.getUTCHours(),i=a.getUTCMinutes(),l=a.getUTCSeconds(),c=a.getUTCMilliseconds(),f=a.getUTCDay();return{year:s,month0:r,day:o,hour:u,minute:i,second:l,ms:c,weekDay:f}},Jt=(e,t,n,a,s,r,o)=>{const u=new Date(e,t,n,a,s,r,o);let i=u<Fe?_t:xt;const l=-1*u.getTimezoneOffset()*60*1e3;return new Date(u.getTime()-i+l)},rt=e=>{const t=e.match(He);return t?t.map(n=>n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n):[]},j=e=>{if(e.length===0)return new RegExp("");let t=[...e];if(t=t.sort((a,s)=>s.length-a.length),t[0]==="")return new RegExp("");const n=`(${t.join("|")})`;return new RegExp(n)},T=e=>e.toString().padStart(2,"0"),Vt=e=>e.toString().padStart(3,"0"),Be=e=>e.split("").map(t=>Pt[t.charCodeAt(0)-48]).join(""),b=(e,t)=>{const n=typeof e=="string"?e:String(e);return t!==L?n:Be(n)},Le=(e,t)=>b(e.getYear(),t).substring(2),xe=(e,t)=>b(e.getYear(),t),_e=(e,t)=>b(e.getEnglishYear(),t).substring(2),je=(e,t)=>b(e.getEnglishYear(),t),Pe=(e,t)=>b(e.getMonth()+1,t),We=(e,t)=>b(T(e.getMonth()+1),t),Ue=(e,t)=>t===L?Ne[e.getMonth()]:Yt[e.getMonth()],Je=(e,t)=>t===L?jt[e.getMonth()]:st[e.getMonth()],Ve=(e,t)=>b(e.getEnglishMonth()+1,t),Ke=(e,t)=>b(T(e.getEnglishMonth()+1),t),Ge=(e,t)=>t===L?Oe[e.getEnglishMonth()]:Ct[e.getEnglishMonth()],ze=(e,t)=>t===L?Te[e.getEnglishMonth()]:kt[e.getEnglishMonth()],qe=(e,t)=>b(e.getDate(),t),Xe=(e,t)=>b(T(e.getDate()),t),Ze=(e,t)=>b(e.getEnglishDate(),t),Qe=(e,t)=>b(T(e.getEnglishDate()),t),Kt=(e,t)=>b(e.getDay(),t),ot=(e,t)=>t===L?Wt[e.getDay()]:Z[e.getDay()],Gt=(e,t)=>t===L?Ut[e.getDay()]:at[e.getDay()],zt=(e,t)=>b(e.getHours(),t),qt=(e,t)=>b(T(e.getHours()),t),Xt=(e,t)=>{const n=e.getHours(),a=n>12?n-12:n;return b(a,t)},Zt=(e,t)=>{const n=e.getHours(),a=n>12?n-12:n;return b(T(a),t)},Qt=(e,t)=>b(e.getMinutes(),t),Rt=(e,t)=>b(T(e.getMinutes()),t),te=(e,t)=>b(e.getSeconds(),t),ee=(e,t)=>b(T(e.getSeconds()),t),ne=(e,t)=>b(Vt(e.getMilliseconds()),t),se=(e,t)=>t===L?e.getHours()>=12?"पिम":"एम":e.getHours()>=12?"PM":"AM",ae=(e,t)=>t===L?e.getHours()>=12?"पिम":"एम":e.getHours()>=12?"pm":"am",re={YY:Le,YYYY:xe,M:Pe,MM:We,MMM:Ue,MMMM:Je,D:qe,DD:Xe,d:Kt,dd:ot,ddd:ot,dddd:Gt,H:zt,HH:qt,h:Xt,hh:Zt,m:Qt,mm:Rt,s:te,ss:ee,SSS:ne,A:se,a:ae},oe=(e,t,n)=>{const a=rt(t),s=r=>r in re?re[r](e,n):r;return a.map(s).join("")},Re=(e,t)=>oe(e,t,Lt),t3=(e,t)=>oe(e,t,L),e3=e=>{const t=T(e.getYear()),n=T(e.getMonth()+1),a=T(e.getDate()),s=T(e.getHours()),r=T(e.getMinutes()),o=T(e.getSeconds()),u=e.getMilliseconds(),i=u===0?"":`.${Vt(u)}`;return`${t}-${n}-${a} ${s}:${r}:${o}${i}`},ie={YY:_e,YYYY:je,M:Ve,MM:Ke,MMM:Ge,MMMM:ze,D:Ze,DD:Qe,d:Kt,dd:ot,ddd:ot,dddd:Gt,H:zt,HH:qt,h:Xt,hh:Zt,m:Qt,mm:Rt,s:te,ss:ee,SSS:ne,A:se,a:ae},ue=(e,t,n)=>{const a=rt(t),s=r=>r in ie?ie[r](e,n):r;return a.map(s).join("")},n3=(e,t)=>ue(e,t,Lt),s3=(e,t)=>ue(e,t,L);function a3(e){const t=e.split(/[-./]/,3),[n,a=1,s=1]=t.map(r=>{const o=parseInt(r,10);if(Number.isNaN(o))throw new Error("Invalid date");return o});return[n,a-1,s]}function r3(e){if(!e)return[0,0,0,0];const[t,n="0"]=e.split(".",2),a=t.split(":",3),[s,r=0,o=0]=a.map(i=>{const l=parseInt(i,10);if(Number.isNaN(l))throw new Error("Invalid time");return l});let u=parseInt(n,10);return Number.isNaN(u)&&(u=0),[s,r,o,u]}function o3(e){const[t,n]=e.split(" ",2),[a,s,r]=a3(t),[o,u,i,l]=r3(n);return[a,s,r,o,u,i,l]}const ce={YY:/(\d\d)/,YYYY:/(\d\d\d\d)/,M:/(1[0-2]|0[1-9]|[1-9])/,MM:/(1[0-2]|0[1-9]|[1-9])/,D:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,DD:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,H:/(2[0-3]|[0-1]\d|\d)/,HH:/(2[0-3]|[0-1]\d|\d)/,hh:/(1[0-2]|0[1-9]|[1-9])/,mm:/([0-5]\d|\d)/,ss:/([0-5]\d|\d)/,SSS:/(\d\d\d)/,A:/(AM|PM)/,a:/(am|pm)/,MMMM:j(st),MMM:j(Yt),dddd:j(at),ddd:j(Z),dd:j(Z),d:/([0-6])/};function i3(e){const t=[],n=[];for(const s of e)s in ce?(t.push(s),n.push(ce[s].source)):n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));const a=n.join("");return{dateTokens:t,regex:new RegExp(`^${a}$`)}}function u3(e,t){let[n,a,s,r,o,u,i,l]=[0,1,1,0,0,0,0,0],c=!1,f=!1;for(let g=0;g<e.length;g++){const C=e[g],m=parseInt(t[g+1]);switch(C){case"YYYY":n=m;break;case"YY":n=2e3+parseInt(t[g]);break;case"MM":case"M":a=m;break;case"MMMM":a=st.indexOf(t[g+1])+1;break;case"MMM":a=Yt.indexOf(t[g+1])+1;break;case"DD":case"D":s=m;break;case"HH":case"H":r=m;break;case"hh":case"h":o=m,f=!0;break;case"mm":case"m":u=m;break;case"ss":case"s":i=m;break;case"SSS":l=m;break;case"A":case"a":c=t[g+1].toLowerCase()==="pm"}}return f&&(r=o+(c?12:0)),{year:n,month0:a-1,day:s,hour:r,minute:u,second:i,ms:l}}function he(e,t){const n=rt(t),{dateTokens:a,regex:s}=i3(n),r=RegExp(s).exec(e);if(!r)throw new Error("Invalid date format");const{year:o,month0:u,day:i,hour:l,minute:c,second:f,ms:g}=u3(a,r);return[o,u,i,l,c,f,g]}const le={YY:/(\d\d)/,YYYY:/(\d\d\d\d)/,M:/(1[0-2]|0[1-9]|[1-9])/,MM:/(1[0-2]|0[1-9]|[1-9])/,D:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,DD:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,H:/(2[0-3]|[0-1]\d|\d)/,HH:/(2[0-3]|[0-1]\d|\d)/,hh:/(1[0-2]|0[1-9]|[1-9])/,mm:/([0-5]\d|\d)/,ss:/([0-5]\d|\d)/,SSS:/(\d\d\d)/,A:/(AM|PM)/,a:/(am|pm)/,MMMM:j(kt),MMM:j(Ct),dddd:j(at),ddd:j(Z),dd:j(Z),d:/([0-6])/};function c3(e){const t=[],n=[];for(const s of e)s in le?(t.push(s),n.push(le[s].source)):n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));const a=n.join("");return{dateTokens:t,regex:new RegExp(`^${a}$`)}}function h3(e,t){let[n,a,s,r,o,u,i,l]=[0,1,1,0,0,0,0,0],c=!1,f=!1;for(let g=0;g<e.length;g++){const C=e[g],m=parseInt(t[g+1]);switch(C){case"YYYY":n=m;break;case"YY":n=2e3+parseInt(t[g]);break;case"MM":case"M":a=m;break;case"MMMM":a=kt.indexOf(t[g+1])+1;break;case"MMM":a=Ct.indexOf(t[g+1])+1;break;case"DD":case"D":s=m;break;case"HH":case"H":r=m;break;case"hh":case"h":o=m,f=!0;break;case"mm":case"m":u=m;break;case"ss":case"s":i=m;break;case"SSS":l=m;break;case"A":case"a":c=t[g+1].toLowerCase()==="pm"}}return f&&(r=o+(c?12:0)),{year:n,month0:a-1,day:s,hour:r,minute:u,second:i,ms:l}}function l3(e,t){const n=rt(t),{dateTokens:a,regex:s}=c3(n),r=RegExp(s).exec(e);if(!r)throw new Error("Invalid date format");const{year:o,month0:u,day:i,hour:l,minute:c,second:f,ms:g}=h3(a,r);return[o,u,i,l,c,f,g]}function d3(e){const t={एम:"AM",पिम:"PM"};jt.forEach((a,s)=>t[a]=st[s]),Ut.forEach((a,s)=>t[a]=at[s]),Wt.forEach((a,s)=>t[a]=Z[s]),Pt.forEach((a,s)=>t[a]=String(s));const n=new RegExp(Object.keys(t).join("|"),"g");return e.replace(n,a=>t[a])}function g3(e,t){const n=d3(e);return he(n,t)}class it extends Error{constructor(t){super(t),this.name="ValidationError"}}const m3=e=>{if(e<0||e>23)throw new it("Hour should be in the range 0-23")},f3=e=>{if(e<0||e>59)throw new it("Minute should be in the range 0-59")},D3=e=>{if(e<0||e>59)throw new it("Second should be in the range 0-59")},y3=e=>{if(e<0||e>999)throw new it("Millisecond should be in the range 0-999")},M3=(e,t,n,a)=>{m3(e),f3(t),D3(n),y3(a)};class E{timestamp;year;yearEn;month;monthEn;day;dayEn;hour;minute;weekDay;constructor(...t){if(t.length===0)this.initFromCurrentDate();else if(t.length===1&&t[0]instanceof Date)this.initFromEnglishDate(t[0]);else if(t.length===1&&t[0]instanceof E)this.initFromNepaliDate(t[0]);else if(t.length===1&&typeof t[0]=="string")this.parseFromString(t[0]);else if(t.length===1&&typeof t[0]=="number")this.initFromTimestamp(t[0]);else if(t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string")this.parseFromStringWithFormat(t[0],t[1]);else if(t.length>=2&&t.length<=8&&t.every(n=>typeof n=="number"))this.initFromComponents(t);else throw new Error("Invalid date argument")}initFromCurrentDate(){this._setDateObject(new Date)}initFromEnglishDate(t){this._setDateObject(t)}initFromNepaliDate(t){this.set(t.year,t.month,t.day,t.hour,t.minute,t.getSeconds(),t.getMilliseconds())}parseFromString(t){const n=o3(t);this.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}initFromTimestamp(t){this._setDateObject(new Date(t))}parseFromStringWithFormat(t,n){const a=he(t,n);this.set(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}initFromComponents(t){this.set(t[0],t[1],t[2]??1,t[3]??0,t[4]??0,t[5]??0,t[6]??0)}_setDateObject(t,n=!0){this.timestamp=t;const{year:a,month0:s,day:r,hour:o,minute:u,weekDay:i}=Ie(t);if(this.yearEn=a,this.monthEn=s,this.dayEn=r,this.hour=o,this.minute=u,this.weekDay=i,n){const[l,c,f]=V.englishToNepali(a,s,r);this.year=l,this.month=c,this.day=f}}getDateObject(){return this.timestamp}getYear(){return this.year}getEnglishYear(){return this.yearEn}getMonth(){return this.month}getEnglishMonth(){return this.monthEn}getDate(){return this.day}getEnglishDate(){return this.dayEn}getDay(){return this.weekDay}getHours(){return this.hour}getMinutes(){return this.minute}getSeconds(){return this.timestamp.getSeconds()}getMilliseconds(){return this.timestamp.getMilliseconds()}getTime(){return this.timestamp.getTime()}setYear(t){this.set(t,this.month,this.day,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setMonth(t){this.set(this.year,t,this.day,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setDate(t){this.set(this.year,this.month,t,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setHours(t){this.set(this.year,this.month,this.day,t,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setMinutes(t){this.set(this.year,this.month,this.day,this.hour,t,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setSeconds(t){this.set(this.year,this.month,this.day,this.hour,this.minute,t,this.timestamp.getMilliseconds())}setMilliseconds(t){this.set(this.year,this.month,this.day,this.hour,this.minute,this.timestamp.getSeconds(),t)}setTime(t){this._setDateObject(new Date(t))}set(t,n,a,s,r,o,u){M3(s,r,o,u);const[i,l,c]=V.nepaliToEnglish(t,n,a);this.year=t,this.month=n,this.day=a,this._setDateObject(Jt(i,l,c,s,r,o,u),!1)}setDateObject(t){this._setDateObject(t,!0)}format(t){return Re(this,t)}formatNepali(t){return t3(this,t)}toString(){return e3(this)}formatEnglishDate(t){return n3(this,t)}formatEnglishDateInNepali(t){return s3(this,t)}static fromEnglishDate(t,n,a,s=0,r=0,o=0,u=0){const i=Jt(t,n,a,s,r,o,u);return new E(i)}static parseNepaliFormat(t,n){const[a,s,r,o,u,i,l]=g3(t,n);return new E(a,s,r,o,u,i,l)}static parseEnglishDate(t,n){const[a,s,r,o,u,i,l]=l3(t,n);return E.fromEnglishDate(a,s,r,o,u,i,l)}static getDaysOfMonth(t,n){if(t<V.npMinYear()||t>V.npMaxYear())throw new Error("Year out of range");if(n<0||n>11)throw new Error("Month out of range");return _[t-V.npMinYear()][0][n]}static minSupportedDate(){return E.fromEnglishDate(V.enMinYear(),0,1).getDateObject()}static maxSupportedDate(){return E.fromEnglishDate(V.enMaxYear(),11,31).getDateObject()}static minSupportedNepaliDate(){return new E(V.npMinYear(),0,1)}static maxSupportedNepaliDate(){const t=V.npMaxYear();return new E(t,11,this.getDaysOfMonth(t,11))}static minimum(){return console.warn("`NepaliDate.minimum()` is deprecated and will be removed in a future version. Please use `NepaliDate.minSupportedDate()` instead."),this.minSupportedDate()}static maximum(){return console.warn("`NepaliDate.maximum()` is deprecated and will be removed in a future version. Please use `NepaliDate.maxSupportedDate()` instead."),this.maxSupportedDate()}}const de=["बैशाख","जेठ","आषाढ","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुन","चैत्र"],At=["Baishakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],me=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],fe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],De=["०","१","२","३","४","५","६","७","८","९"],S3={light:{primary:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",hover:"#f3f4f6",selected:"#3b82f6",today:"#dbeafe",disabled:"#d1d5db"},dark:{primary:"#60a5fa",background:"#1f2937",text:"#f9fafb",border:"#374151",hover:"#374151",selected:"#3b82f6",today:"#1e40af",disabled:"#6b7280"}},K=e=>e.toString().split("").map(t=>De[parseInt(t)]).join(""),vt=(e,t,n)=>{if(e==="BS")try{const a=n===11?new E(t+1,0,1):new E(t,n+1,1);return new E(a.getTime()-1440*60*1e3).getDate()}catch{return 30}return new Date(t,n+1,0).getDate()},ye=(e,t,n)=>{if(e==="BS")try{return new E(t,n,1).getDay()||0}catch{return 0}return new Date(t,n,1).getDay()},O=e=>{const t=new Date;if(e==="BS")try{const n=E.fromEnglishDate(t.getFullYear(),t.getMonth(),t.getDate());return{year:n.getYear(),month:n.getMonth(),day:n.getDate()}}catch{return{year:2081,month:0,day:1}}return{year:t.getFullYear(),month:t.getMonth(),day:t.getDate()}},ut=(e,t,n,a,s)=>{if(e==="BS")try{const r=new E(t,n,a),u=new Date(r.getEnglishYear(),r.getEnglishMonth(),r.getEnglishDate()).toISOString().split("T")[0];return{bs:`${t}-${String(n+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`,ad:u,formatted:{bs:`${s[n]} ${a}, ${t}`,ad:new Date(r.getEnglishYear(),r.getEnglishMonth(),r.getEnglishDate()).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}}}catch{const r=`${t}-${String(n+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`;return{bs:r,ad:r,formatted:{bs:`${s[n]} ${a}, ${t}`,ad:`${s[n]} ${a}, ${t}`}}}else{const r=new Date(t,n,a),o=r.toISOString().split("T")[0];try{const u=E.fromEnglishDate(t,n,a),i=`${u.getYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`;return{ad:o,bs:i,formatted:{ad:r.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),bs:`${At[u.getMonth()]} ${u.getDate()}, ${u.getYear()}`}}}catch{return{ad:o,bs:o,formatted:{ad:r.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),bs:r.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}}}}},p3=(e,t,n)=>{const a=new Date(e.year,e.month,e.day).getTime(),s=new Date(t.year,t.month,t.day).getTime(),r=new Date(n.year,n.month,n.day).getTime();return a>=s&&a<=r},Me=e=>{try{const[t,n,a]=e.split("-").map(Number);return!t||!n||!a?null:{year:t,month:n-1,day:a}}catch{return null}},et=(e,t,n)=>{if(!t&&!n)return!1;const a=new Date(e.year,e.month,e.day).getTime();if(t){const s=Me(t);if(s){const r=new Date(s.year,s.month,s.day).getTime();if(a<r)return!0}}if(n){const s=Me(n);if(s){const r=new Date(s.year,s.month,s.day).getTime();if(a>r)return!0}}return!1},Se=(e="AD")=>{const t=k.useMemo(()=>O(e),[e]),[n,a]=k.useState(t.year),[s,r]=k.useState(t.month),[o,u]=k.useState(null),[i,l]=k.useState(null),[c,f]=k.useState(null);k.useEffect(()=>{a(t.year),r(t.month)},[t.year,t.month]);const g=k.useMemo(()=>{const w=vt(e,n,s),$=ye(e,n,s),p=[];for(let A=0;A<$;A++)p.push(null);for(let A=1;A<=w;A++)p.push(A);return p},[n,s,e]);return{currentYear:n,currentMonth:s,selectedDate:o,rangeStart:i,rangeEnd:c,today:t,calendarDays:g,setCurrentYear:a,setCurrentMonth:r,setSelectedDate:u,setRangeStart:l,setRangeEnd:f,navigateMonth:w=>{let p=s+w,A=n;for(;p>11;)p-=12,A+=1;for(;p<0;)p+=12,A-=1;r(p),a(A)},isToday:w=>n===t.year&&s===t.month&&w===t.day,isSelected:(w,$="single")=>$==="range"?!!(i&&i.year===n&&i.month===s&&i.day===w)||!!(c&&c.year===n&&c.month===s&&c.day===w):!!(o&&o.year===n&&o.month===s&&o.day===w),isInRange:w=>{if(!i||!c)return!1;const $=new Date(n,s,w).getTime(),p=new Date(i.year,i.month,i.day).getTime(),A=new Date(c.year,c.month,c.day).getTime();return $>=p&&$<=A}}},Q=(e,t,n)=>{if(n==="BS")try{const a=new E(e.year,e.month,e.day),s=new Date(a.getEnglishYear(),a.getEnglishMonth(),a.getEnglishDate());s.setDate(s.getDate()+t);const r=E.fromEnglishDate(s.getFullYear(),s.getMonth(),s.getDate());return{year:r.getYear(),month:r.getMonth(),day:r.getDate()}}catch{return e}else{const a=new Date(e.year,e.month,e.day);return a.setDate(a.getDate()+t),{year:a.getFullYear(),month:a.getMonth(),day:a.getDate()}}},ct=(e,t,n)=>{if(n==="BS")try{let a=e.year,s=e.month+t;for(;s<0;)a-=1,s+=12;for(;s>=12;)a+=1,s-=12;const r=vt("BS",a,s),o=Math.min(e.day,r);return{year:a,month:s,day:o}}catch{return e}else{const a=new Date(e.year,e.month,e.day);return a.setMonth(a.getMonth()+t),{year:a.getFullYear(),month:a.getMonth(),day:a.getDate()}}},G=e=>({year:e.year,month:e.month,day:1}),b3=(e,t)=>{if(t==="BS")try{const a=new E(e.year,e.month,e.day).getDay();return Q(e,-a,"BS")}catch{return e}else{const n=new Date(e.year,e.month,e.day),a=n.getDay();return n.setDate(n.getDate()-a),{year:n.getFullYear(),month:n.getMonth(),day:n.getDate()}}},E3={TODAY:"today",YESTERDAY:"yesterday",THIS_WEEK:"thisWeek",LAST_7_DAYS:"last7days",LAST_30_DAYS:"last30days",THIS_MONTH:"thisMonth",LAST_MONTH:"lastMonth",LAST_3_MONTHS:"last3months",LAST_6_MONTHS:"last6months",LAST_180_DAYS:"last180days",LAST_9_MONTHS:"last9months",LAST_YEAR:"lastYear"},pe=(e,t)=>{const n=[{key:"today",label:"Today",getValue:s=>{const r=O(s);return{start:r,end:r}}},{key:"yesterday",label:"Yesterday",getValue:s=>{const r=O(s),o=Q(r,-1,s);return{start:o,end:o}}},{key:"thisWeek",label:"This Week",getValue:s=>{const r=O(s);return{start:b3(r,s),end:r}}},{key:"last7days",label:"Last 7 Days",getValue:s=>{const r=O(s);return{start:Q(r,-6,s),end:r}}},{key:"last30days",label:"Last 30 Days",getValue:s=>{const r=O(s);return{start:Q(r,-29,s),end:r}}},{key:"thisMonth",label:"This Month",getValue:s=>{const r=O(s);return{start:G(r),end:r}}},{key:"lastMonth",label:"Last Month",getValue:s=>{const r=O(s),o=Q(G(r),-1,s);return{start:G(o),end:o}}},{key:"last3months",label:"Last 3 Months",getValue:s=>{const r=O(s),o=ct(r,-2,s);return{start:G(o),end:r}}},{key:"last6months",label:"Last 6 Months",getValue:s=>{const r=O(s),o=ct(r,-5,s);return{start:G(o),end:r}}},{key:"last180days",label:"Last 180 Days",getValue:s=>{const r=O(s);return{start:Q(r,-179,s),end:r}}},{key:"last9months",label:"Last 9 Months",getValue:s=>{const r=O(s),o=ct(r,-8,s);return{start:G(o),end:r}}},{key:"lastYear",label:"Last Year",getValue:s=>{const r=O(s),o=ct(r,-11,s);return{start:G(o),end:r}}}],a=e?n.filter(s=>e.includes(s.key)):n;return t?a.map(s=>({...s,label:t[s.key]||s.label})):a},w3=({currentYear:e,currentMonth:t,months:n,onYearChange:a,onMonthChange:s,onClose:r,showNepaliNumbers:o=!1,convertToNepaliNumber:u=l=>l.toString(),calendarType:i})=>{const[l,c]=k.useState(Math.floor(e/12)*12),f=i==="BS"?2e3:1944,g=i==="BS"?2100:2043;return h.jsx("div",{className:"bsac-picker-overlay",onClick:r,children:h.jsxs("div",{className:"bsac-picker-content",onClick:C=>C.stopPropagation(),children:[h.jsxs("div",{className:"bsac-picker-header",children:[h.jsx("h3",{children:"Select Month & Year"}),h.jsx("button",{className:"bsac-close-btn",onClick:r,children:"×"})]}),h.jsxs("div",{className:"bsac-picker-body",children:[h.jsxs("div",{className:"bsac-picker-section",children:[h.jsxs("div",{className:"bsac-picker-section-header",children:[h.jsx("label",{children:"Year"}),h.jsxs("div",{className:"bsac-year-nav",children:[h.jsx("button",{onClick:()=>c(Math.max(f,l-12)),disabled:l<=f,children:"«"}),h.jsxs("span",{children:[o?u(l):l," – ",o?u(l+11):l+11]}),h.jsx("button",{onClick:()=>c(Math.min(g-11,l+12)),disabled:l+11>=g,children:"»"})]})]}),h.jsx("div",{className:"bsac-year-grid",children:Array.from({length:12},(C,m)=>{const v=l+m;return v>g?null:h.jsx("button",{onClick:()=>a(v),className:v===e?"bsac-selected":"",children:o?u(v):v},v)})})]}),h.jsxs("div",{className:"bsac-picker-section",children:[h.jsx("label",{children:"Month"}),h.jsx("div",{className:"bsac-month-grid",children:n.map((C,m)=>h.jsx("button",{onClick:()=>{s(m),r()},className:m===t?"bsac-selected":"",children:C},m))})]})]})]})})},ht=({currentMonth:e,currentYear:t,months:n,onNavigateMonth:a,onYearChange:s,onMonthChange:r,disabled:o=!1,showNepaliNumbers:u=!1,convertToNepaliNumber:i,calendarType:l})=>{const[c,f]=k.useState(!1);return h.jsxs("div",{className:"bsac-header",children:[h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(-12),disabled:o,"aria-label":"Previous year",children:"«"}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(-1),disabled:o,"aria-label":"Previous month",children:"‹"}),h.jsxs("button",{className:"bsac-month-year-btn",onClick:()=>f(!0),disabled:o,children:[n[e]," ",u?i(t):t]}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(1),disabled:o,"aria-label":"Next month",children:"›"}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(12),disabled:o,"aria-label":"Next year",children:"»"}),c&&h.jsx(w3,{currentYear:t,currentMonth:e,months:n,onYearChange:s,onMonthChange:r,onClose:()=>f(!1),showNepaliNumbers:u,convertToNepaliNumber:i,calendarType:l})]})},lt=({calendarDays:e,days:t,onDateSelect:n,isSelected:a,isInRange:s,isToday:r,isDisabled:o,disabled:u=!1,showNepaliNumbers:i=!1,convertToNepaliNumber:l})=>h.jsxs("div",{className:"bsac-grid",children:[t.map(c=>h.jsx("div",{className:"bsac-day-header",children:c},c)),e.map((c,f)=>{const g=c?o?.(c)||u:!1,C=c?a(c):!1,m=c?s(c):!1,v=c?r(c):!1,I=["bsac-day",c?g?"bsac-day-disabled":C?"bsac-day-selected":m?"bsac-day-in-range":v?"bsac-day-today":"":"bsac-day-empty"].filter(Boolean).join(" ");return h.jsx("div",{className:I,onClick:()=>c&&!g&&n(c),children:c?i?l(c):c:""},f)})]}),dt=({presets:e,calendarType:t,onPresetSelect:n,activePreset:a,position:s="top"})=>{const r=o=>{const u=o.getValue(t);n(o,u)};return h.jsx("div",{className:`bsac-presets bsac-presets--${s}`,children:e.map(o=>h.jsx("button",{onClick:()=>r(o),className:`bsac-preset-btn${a===o.key?" bsac-preset-btn--active":""}`,children:o.label},o.key))})},be=({calendarType:e="AD",value:t,onChange:n,className:a="",showToday:s=!0,disabled:r=!1,outputFormat:o="both",onDateSelect:u,mode:i="single",onRangeSelect:l,showRangePresets:c=!1,rangePresetsPosition:f="top",predefinedRanges:g,presetKeys:C,presetLabels:m,onPresetSelect:v,renderPresets:I,showNepaliMonths:w=!1,showNepaliDays:$=!1,showNepaliNumbers:p=!1,theme:A="light",colors:gt,minDate:x,maxDate:z})=>{const{currentYear:B,currentMonth:H,rangeStart:P,rangeEnd:D,calendarDays:Y,setSelectedDate:W,setRangeStart:M,setRangeEnd:F,setCurrentYear:U,setCurrentMonth:J,navigateMonth:N,isToday:mt,isSelected:ft,isInRange:Dt}=Se(e),[yt,$t]=k.useState(),Mt=g||pe(C,m),St=(d,y)=>({start:ut(e,d.year,d.month,d.day,q),end:ut(e,y.year,y.month,y.day,q)}),q=e==="BS"&&w?de:e==="BS"?At:ge,pt=e==="BS"&&$?me:fe,bt=(d,y)=>{y.start&&y.end&&(M(y.start),F(y.end),U(y.start.year),J(y.start.month),$t(d.key),v?.(d,y),l?.(St(y.start,y.end)))},Y3=(d,y)=>{M(d),F(y),$t(void 0),l?.(St(d,y))},Et=d=>{if(r)return;const y={year:B,month:H,day:d};if(et(y,x,z))return;if(i==="range"){if($t(void 0),!P||P&&D)M(y),F(null);else{const tt=new Date(P.year,P.month,P.day).getTime();new Date(y.year,y.month,y.day).getTime()<tt?(M(y),F(P),l?.(St(y,P))):(F(y),l?.(St(P,y)))}return}W(y);const R=ut(e,B,H,d,q);if(u?.(R),n){let tt;switch(o){case"iso":tt=R.ad;break;case"object":tt=JSON.stringify(R);break;default:tt=JSON.stringify(R);break}n(tt)}},k3=d=>{if(!r){switch(d.key){case"ArrowLeft":N(-1);break;case"ArrowRight":N(1);break;case"ArrowUp":N(-12);break;case"ArrowDown":N(12);break;case"PageUp":d.shiftKey?N(-12):N(-1);break;case"PageDown":d.shiftKey?N(12):N(1);break;default:return}d.preventDefault()}},C3={...gt?Object.entries(gt).reduce((d,[y,R])=>(d[`--calendar-${y}`]=R,d),{}):{}};return h.jsxs("div",{className:`bsac-calendar ${a}`,style:C3,"data-theme":A,onKeyDown:k3,tabIndex:0,role:"application","aria-label":"Calendar",children:[i==="range"&&I&&h.jsxs("div",{style:{display:"flex",gap:"16px"},children:[h.jsx("div",{children:I({onRangeChange:Y3})}),h.jsxs("div",{style:{flex:1},children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]})]}),i==="range"&&c&&f==="left"&&!I&&h.jsxs("div",{style:{display:"flex",gap:"16px",flexWrap:"nowrap"},children:[h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"left"}),h.jsxs("div",{children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]})]}),i==="range"&&c&&f==="right"&&!I&&h.jsxs("div",{style:{display:"flex",gap:"16px",flexWrap:"nowrap"},children:[h.jsxs("div",{children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]}),h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"right"})]}),(!i||i==="single"||!c&&!I||f==="top"||f==="bottom")&&h.jsxs(h.Fragment,{children:[i==="range"&&c&&f==="top"&&h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"top"}),h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K}),i==="range"&&c&&f==="bottom"&&h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"bottom"})]})]})},Ee=({placeholder:e="Select date",format:t="YYYY-MM-DD",defaultValue:n,onDateSelect:a,inputClassName:s="",popupClassName:r="",style:o,inputStyle:u,icon:i,showIcon:l=!0,calendarType:c="AD",...f})=>{const[g,C]=k.useState(!1),[m,v]=k.useState(null),[I,w]=k.useState(()=>{if(!n)return"";if(c==="BS")try{const[D,Y,W]=n.split("-").map(Number),M=E.fromEnglishDate(D,Y-1,W);return`${M.getYear()}-${String(M.getMonth()+1).padStart(2,"0")}-${String(M.getDate()).padStart(2,"0")}`}catch{return n}return n}),$=k.useRef(null),p=k.useRef(null),[A,gt]=k.useState({visibility:"hidden"}),x=()=>{if(!$.current)return;const D=$.current.getBoundingClientRect(),Y=p.current?.offsetHeight||360,W=p.current?.offsetWidth||280,M=window.innerHeight-D.bottom,F=window.innerWidth-D.left,U=M>=Y+8?D.bottom+8:Math.max(8,D.top-Y-8),J=F>=W?D.left:Math.max(8,D.right-W);gt({top:U,left:J,visibility:"visible"})};k.useEffect(()=>(g&&(requestAnimationFrame(x),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x)),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}),[g]),k.useEffect(()=>{const D=Y=>{$.current&&!$.current.contains(Y.target)&&C(!1)};return g&&document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[g]);const z=D=>{v(D),w(c==="BS"?D.bs:D.ad),C(!1),a?.(D)},B=D=>{const Y=D.target.value;if(Y===""){w("");return}if((D.target.selectionStart||0)===Y.length&&Y.length>I.length){const M=Y.replace(/[^0-9]/g,"");let F=M;M.length>4&&M.length<=6?F=M.slice(0,4)+"-"+M.slice(4):M.length>6&&(F=M.slice(0,4)+"-"+M.slice(4,6)+"-"+M.slice(6,8)),w(F)}else{const M=Y.replace(/[^0-9-]/g,"");M.length<=10&&w(M)}},H=()=>{const D=I.trim();if(!D){v(null);return}const Y=D.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(Y){const[,W,M,F]=Y,U=parseInt(M),J=parseInt(F);if(U<1||U>12||J<1||J>32){w(m?c==="BS"?m.bs:m.ad:"");return}const N={bs:c==="BS"?`${W}-${M}-${F}`:"",ad:c==="AD"?`${W}-${M}-${F}`:"",formatted:{bs:c==="BS"?D:"",ad:c==="AD"?D:""}};v(N),a?.(N)}else D.length<10&&w(m?c==="BS"?m.bs:m.ad:"")},P=D=>{D.key==="Enter"?(H(),C(!1)):D.key==="Escape"&&C(!1)};return h.jsxs("div",{className:"bsac-datepicker",ref:$,style:o,children:[h.jsx("input",{type:"text",value:I,placeholder:e,onChange:B,onBlur:H,onKeyDown:P,className:`bsac-input ${s}`,style:u,"aria-label":"Date picker input","aria-haspopup":"dialog","aria-expanded":g,maxLength:10}),h.jsx("button",{type:"button",className:"bsac-icon-btn",onClick:()=>C(!g),"aria-label":"Toggle calendar",style:{display:l?"flex":"none"},children:i||h.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),h.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),h.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),g&&h.jsx("div",{ref:p,className:`bsac-popup ${r}`,style:A,children:h.jsx(be,{calendarType:c,onDateSelect:z,...f})})]})};S.Calendar=be,S.CalendarInput=Ee,S.DEFAULT_COLORS=S3,S.DatePicker=Ee,S.ENGLISH_DAYS=fe,S.ENGLISH_MONTHS_AD=ge,S.ENGLISH_MONTHS_BS=At,S.NEPALI_DAYS=me,S.NEPALI_DIGITS=De,S.NEPALI_MONTHS=de,S.PRESET_KEYS=E3,S.convertToNepaliNumber=K,S.createDateOutput=ut,S.createPredefinedRanges=pe,S.getDaysInMonth=vt,S.getFirstDayOfMonth=ye,S.getTodayDate=O,S.isDateInRange=p3,S.useCalendar=Se,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(S,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],h):(S=typeof globalThis<"u"?globalThis:S||self,h(S.BSADCalendar={},S.ReactJSXRuntime,S.React))})(this,(function(S,h,k){"use strict";const X=[1943,4,14],Ft=[31,28,31,30,31,30,31,31,30,31,30,31],we=[31,29,31,30,31,30,31,31,30,31,30,31],_=[[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,32,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,32,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,31,29,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,31,32,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,30],365],[[31,32,31,32,31,30,30,30,29,30,29,31],366],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[30,32,31,32,31,30,30,30,29,30,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,29,31],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365],[[31,32,31,32,31,30,30,30,29,29,30,31],366],[[31,31,31,32,31,31,29,30,30,29,30,30],365],[[31,31,32,31,31,31,30,29,30,29,30,30],365],[[31,31,32,32,31,30,30,29,30,29,30,30],365]];let Nt=class extends Error{constructor(t){super(t),this.name="DateOutOfRangeError"}};const Tt=()=>X[0]+1,Ot=()=>X[0]+_.length-1,Ht=()=>2e3,It=()=>2e3+_.length-1,nt=e=>e%400===0||e%4===0&&e%100!==0,wt=e=>nt(e)?we:Ft,Ye=(e,t,n)=>!(e<Tt()||e>Ot()||t<1||t>12||n<1||n>wt(e)[t-1]),Bt=(e,t,n)=>{let a=e*365+n;for(let s=0;s<t-1;s++)a+=Ft[s];return t<=2&&(e-=1),a+=Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400),a};function ke(e,t,n){const a=t+1;if(!Ye(e,a,n))throw new Nt("Date out of range");let s=2e3,r=1,o=1,u=Math.abs(Bt(e,a,n)-Bt(...X)),i=0;for(;u>=_[i][1];)u-=_[i][1],s+=1,i+=1;let l=0;for(;u>=_[i][0][l];)u-=_[i][0][l],r+=1,l+=1;return o+=u,[s,r-1,o]}const Ce=(e,t,n)=>!(e<Ht()||e>It()||t<1||t>12||n<1||n>_[e-2e3][0][t-1]),Ae=(e,t,n)=>{let a=n-1;const s=e-2e3;for(let r=0;r<t-1;r++)a+=_[s][0][r];for(let r=0;r<s;r++)a+=_[r][1];return a},ve=(e,t,n)=>{const a=t+1;if(!Ce(e,a,n))throw new Nt("Date out of range");let[s,r,o]=[X[0],1,1];const u=wt(s).slice(0,X[1]-1).reduce((f,g)=>f+g,0)+X[2]-1;let i=Math.abs(Ae(e,a,n)+u);for(;i>=366&&nt(s)||i>=365&&!nt(s);)i-=nt(s)?366:365,s+=1;const l=wt(s);let c=0;for(;i>=l[c];)i-=l[c],r+=1,c+=1;return o+=i,[s,r-1,o]},V={enMinYear:Tt,enMaxYear:Ot,npMinYear:Ht,npMaxYear:It,englishToNepali:ke,nepaliToEnglish:ve},Lt="en",L="ne",xt=207e5,_t=198e5,$e=5049018e5,Fe=new Date(1986,0,1,0,15),st=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],Yt=["Bai","Jes","Asa","Shr","Bhd","Asw","Kar","Man","Pou","Mag","Fal","Cha"],jt=["बैशाख","जेठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुण","चैत्र"],Ne=["बै","जे","अ","श्रा","भा","आ","का","मं","पौ","मा","फा","चै"],kt=["January","February","March","April","May","June","July","August","September","October","November","December"],Ct=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Te=["जनवरी","फेब्रुअरी","मार्च","अप्रिल","मे","जुन","जुलाई","अगस्ट","सेप्टेम्बर","अक्टोबर","नोभेम्बर","डिसेम्बर"],Oe=["जन","फेब","मार","अप्रि","मे","जुन","जुला","अग","सेप","अक्टो","नोभे","डिसे"],Pt=["०","१","२","३","४","५","६","७","८","९"],Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],at=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Wt=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],Ut=["आइतबार","सोमबार","मंगलबार","बुधबार","बिहिबार","शुक्रबार","शनिबार"],He=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DD?|ddd?d?|do?|YYYY|YY|y{2,4}|yo?|a|A|hh?|HH?|mm?|ss?|SSS|x|X|.)/g,Ie=e=>{const t=e.getTime(),n=t<$e?_t:xt,a=new Date(t+n),s=a.getUTCFullYear(),r=a.getUTCMonth(),o=a.getUTCDate(),u=a.getUTCHours(),i=a.getUTCMinutes(),l=a.getUTCSeconds(),c=a.getUTCMilliseconds(),f=a.getUTCDay();return{year:s,month0:r,day:o,hour:u,minute:i,second:l,ms:c,weekDay:f}},Jt=(e,t,n,a,s,r,o)=>{const u=new Date(e,t,n,a,s,r,o);let i=u<Fe?_t:xt;const l=-1*u.getTimezoneOffset()*60*1e3;return new Date(u.getTime()-i+l)},rt=e=>{const t=e.match(He);return t?t.map(n=>n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n):[]},j=e=>{if(e.length===0)return new RegExp("");let t=[...e];if(t=t.sort((a,s)=>s.length-a.length),t[0]==="")return new RegExp("");const n=`(${t.join("|")})`;return new RegExp(n)},T=e=>e.toString().padStart(2,"0"),Vt=e=>e.toString().padStart(3,"0"),Be=e=>e.split("").map(t=>Pt[t.charCodeAt(0)-48]).join(""),b=(e,t)=>{const n=typeof e=="string"?e:String(e);return t!==L?n:Be(n)},Le=(e,t)=>b(e.getYear(),t).substring(2),xe=(e,t)=>b(e.getYear(),t),_e=(e,t)=>b(e.getEnglishYear(),t).substring(2),je=(e,t)=>b(e.getEnglishYear(),t),Pe=(e,t)=>b(e.getMonth()+1,t),We=(e,t)=>b(T(e.getMonth()+1),t),Ue=(e,t)=>t===L?Ne[e.getMonth()]:Yt[e.getMonth()],Je=(e,t)=>t===L?jt[e.getMonth()]:st[e.getMonth()],Ve=(e,t)=>b(e.getEnglishMonth()+1,t),Ke=(e,t)=>b(T(e.getEnglishMonth()+1),t),Ge=(e,t)=>t===L?Oe[e.getEnglishMonth()]:Ct[e.getEnglishMonth()],ze=(e,t)=>t===L?Te[e.getEnglishMonth()]:kt[e.getEnglishMonth()],qe=(e,t)=>b(e.getDate(),t),Xe=(e,t)=>b(T(e.getDate()),t),Ze=(e,t)=>b(e.getEnglishDate(),t),Qe=(e,t)=>b(T(e.getEnglishDate()),t),Kt=(e,t)=>b(e.getDay(),t),ot=(e,t)=>t===L?Wt[e.getDay()]:Z[e.getDay()],Gt=(e,t)=>t===L?Ut[e.getDay()]:at[e.getDay()],zt=(e,t)=>b(e.getHours(),t),qt=(e,t)=>b(T(e.getHours()),t),Xt=(e,t)=>{const n=e.getHours(),a=n>12?n-12:n;return b(a,t)},Zt=(e,t)=>{const n=e.getHours(),a=n>12?n-12:n;return b(T(a),t)},Qt=(e,t)=>b(e.getMinutes(),t),Rt=(e,t)=>b(T(e.getMinutes()),t),te=(e,t)=>b(e.getSeconds(),t),ee=(e,t)=>b(T(e.getSeconds()),t),ne=(e,t)=>b(Vt(e.getMilliseconds()),t),se=(e,t)=>t===L?e.getHours()>=12?"पिम":"एम":e.getHours()>=12?"PM":"AM",ae=(e,t)=>t===L?e.getHours()>=12?"पिम":"एम":e.getHours()>=12?"pm":"am",re={YY:Le,YYYY:xe,M:Pe,MM:We,MMM:Ue,MMMM:Je,D:qe,DD:Xe,d:Kt,dd:ot,ddd:ot,dddd:Gt,H:zt,HH:qt,h:Xt,hh:Zt,m:Qt,mm:Rt,s:te,ss:ee,SSS:ne,A:se,a:ae},oe=(e,t,n)=>{const a=rt(t),s=r=>r in re?re[r](e,n):r;return a.map(s).join("")},Re=(e,t)=>oe(e,t,Lt),t3=(e,t)=>oe(e,t,L),e3=e=>{const t=T(e.getYear()),n=T(e.getMonth()+1),a=T(e.getDate()),s=T(e.getHours()),r=T(e.getMinutes()),o=T(e.getSeconds()),u=e.getMilliseconds(),i=u===0?"":`.${Vt(u)}`;return`${t}-${n}-${a} ${s}:${r}:${o}${i}`},ie={YY:_e,YYYY:je,M:Ve,MM:Ke,MMM:Ge,MMMM:ze,D:Ze,DD:Qe,d:Kt,dd:ot,ddd:ot,dddd:Gt,H:zt,HH:qt,h:Xt,hh:Zt,m:Qt,mm:Rt,s:te,ss:ee,SSS:ne,A:se,a:ae},ue=(e,t,n)=>{const a=rt(t),s=r=>r in ie?ie[r](e,n):r;return a.map(s).join("")},n3=(e,t)=>ue(e,t,Lt),s3=(e,t)=>ue(e,t,L);function a3(e){const t=e.split(/[-./]/,3),[n,a=1,s=1]=t.map(r=>{const o=parseInt(r,10);if(Number.isNaN(o))throw new Error("Invalid date");return o});return[n,a-1,s]}function r3(e){if(!e)return[0,0,0,0];const[t,n="0"]=e.split(".",2),a=t.split(":",3),[s,r=0,o=0]=a.map(i=>{const l=parseInt(i,10);if(Number.isNaN(l))throw new Error("Invalid time");return l});let u=parseInt(n,10);return Number.isNaN(u)&&(u=0),[s,r,o,u]}function o3(e){const[t,n]=e.split(" ",2),[a,s,r]=a3(t),[o,u,i,l]=r3(n);return[a,s,r,o,u,i,l]}const ce={YY:/(\d\d)/,YYYY:/(\d\d\d\d)/,M:/(1[0-2]|0[1-9]|[1-9])/,MM:/(1[0-2]|0[1-9]|[1-9])/,D:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,DD:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,H:/(2[0-3]|[0-1]\d|\d)/,HH:/(2[0-3]|[0-1]\d|\d)/,hh:/(1[0-2]|0[1-9]|[1-9])/,mm:/([0-5]\d|\d)/,ss:/([0-5]\d|\d)/,SSS:/(\d\d\d)/,A:/(AM|PM)/,a:/(am|pm)/,MMMM:j(st),MMM:j(Yt),dddd:j(at),ddd:j(Z),dd:j(Z),d:/([0-6])/};function i3(e){const t=[],n=[];for(const s of e)s in ce?(t.push(s),n.push(ce[s].source)):n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));const a=n.join("");return{dateTokens:t,regex:new RegExp(`^${a}$`)}}function u3(e,t){let[n,a,s,r,o,u,i,l]=[0,1,1,0,0,0,0,0],c=!1,f=!1;for(let g=0;g<e.length;g++){const C=e[g],m=parseInt(t[g+1]);switch(C){case"YYYY":n=m;break;case"YY":n=2e3+parseInt(t[g]);break;case"MM":case"M":a=m;break;case"MMMM":a=st.indexOf(t[g+1])+1;break;case"MMM":a=Yt.indexOf(t[g+1])+1;break;case"DD":case"D":s=m;break;case"HH":case"H":r=m;break;case"hh":case"h":o=m,f=!0;break;case"mm":case"m":u=m;break;case"ss":case"s":i=m;break;case"SSS":l=m;break;case"A":case"a":c=t[g+1].toLowerCase()==="pm"}}return f&&(r=o+(c?12:0)),{year:n,month0:a-1,day:s,hour:r,minute:u,second:i,ms:l}}function he(e,t){const n=rt(t),{dateTokens:a,regex:s}=i3(n),r=RegExp(s).exec(e);if(!r)throw new Error("Invalid date format");const{year:o,month0:u,day:i,hour:l,minute:c,second:f,ms:g}=u3(a,r);return[o,u,i,l,c,f,g]}const le={YY:/(\d\d)/,YYYY:/(\d\d\d\d)/,M:/(1[0-2]|0[1-9]|[1-9])/,MM:/(1[0-2]|0[1-9]|[1-9])/,D:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,DD:/(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/,H:/(2[0-3]|[0-1]\d|\d)/,HH:/(2[0-3]|[0-1]\d|\d)/,hh:/(1[0-2]|0[1-9]|[1-9])/,mm:/([0-5]\d|\d)/,ss:/([0-5]\d|\d)/,SSS:/(\d\d\d)/,A:/(AM|PM)/,a:/(am|pm)/,MMMM:j(kt),MMM:j(Ct),dddd:j(at),ddd:j(Z),dd:j(Z),d:/([0-6])/};function c3(e){const t=[],n=[];for(const s of e)s in le?(t.push(s),n.push(le[s].source)):n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));const a=n.join("");return{dateTokens:t,regex:new RegExp(`^${a}$`)}}function h3(e,t){let[n,a,s,r,o,u,i,l]=[0,1,1,0,0,0,0,0],c=!1,f=!1;for(let g=0;g<e.length;g++){const C=e[g],m=parseInt(t[g+1]);switch(C){case"YYYY":n=m;break;case"YY":n=2e3+parseInt(t[g]);break;case"MM":case"M":a=m;break;case"MMMM":a=kt.indexOf(t[g+1])+1;break;case"MMM":a=Ct.indexOf(t[g+1])+1;break;case"DD":case"D":s=m;break;case"HH":case"H":r=m;break;case"hh":case"h":o=m,f=!0;break;case"mm":case"m":u=m;break;case"ss":case"s":i=m;break;case"SSS":l=m;break;case"A":case"a":c=t[g+1].toLowerCase()==="pm"}}return f&&(r=o+(c?12:0)),{year:n,month0:a-1,day:s,hour:r,minute:u,second:i,ms:l}}function l3(e,t){const n=rt(t),{dateTokens:a,regex:s}=c3(n),r=RegExp(s).exec(e);if(!r)throw new Error("Invalid date format");const{year:o,month0:u,day:i,hour:l,minute:c,second:f,ms:g}=h3(a,r);return[o,u,i,l,c,f,g]}function d3(e){const t={एम:"AM",पिम:"PM"};jt.forEach((a,s)=>t[a]=st[s]),Ut.forEach((a,s)=>t[a]=at[s]),Wt.forEach((a,s)=>t[a]=Z[s]),Pt.forEach((a,s)=>t[a]=String(s));const n=new RegExp(Object.keys(t).join("|"),"g");return e.replace(n,a=>t[a])}function g3(e,t){const n=d3(e);return he(n,t)}class it extends Error{constructor(t){super(t),this.name="ValidationError"}}const m3=e=>{if(e<0||e>23)throw new it("Hour should be in the range 0-23")},f3=e=>{if(e<0||e>59)throw new it("Minute should be in the range 0-59")},D3=e=>{if(e<0||e>59)throw new it("Second should be in the range 0-59")},y3=e=>{if(e<0||e>999)throw new it("Millisecond should be in the range 0-999")},M3=(e,t,n,a)=>{m3(e),f3(t),D3(n),y3(a)};class E{timestamp;year;yearEn;month;monthEn;day;dayEn;hour;minute;weekDay;constructor(...t){if(t.length===0)this.initFromCurrentDate();else if(t.length===1&&t[0]instanceof Date)this.initFromEnglishDate(t[0]);else if(t.length===1&&t[0]instanceof E)this.initFromNepaliDate(t[0]);else if(t.length===1&&typeof t[0]=="string")this.parseFromString(t[0]);else if(t.length===1&&typeof t[0]=="number")this.initFromTimestamp(t[0]);else if(t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string")this.parseFromStringWithFormat(t[0],t[1]);else if(t.length>=2&&t.length<=8&&t.every(n=>typeof n=="number"))this.initFromComponents(t);else throw new Error("Invalid date argument")}initFromCurrentDate(){this._setDateObject(new Date)}initFromEnglishDate(t){this._setDateObject(t)}initFromNepaliDate(t){this.set(t.year,t.month,t.day,t.hour,t.minute,t.getSeconds(),t.getMilliseconds())}parseFromString(t){const n=o3(t);this.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}initFromTimestamp(t){this._setDateObject(new Date(t))}parseFromStringWithFormat(t,n){const a=he(t,n);this.set(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}initFromComponents(t){this.set(t[0],t[1],t[2]??1,t[3]??0,t[4]??0,t[5]??0,t[6]??0)}_setDateObject(t,n=!0){this.timestamp=t;const{year:a,month0:s,day:r,hour:o,minute:u,weekDay:i}=Ie(t);if(this.yearEn=a,this.monthEn=s,this.dayEn=r,this.hour=o,this.minute=u,this.weekDay=i,n){const[l,c,f]=V.englishToNepali(a,s,r);this.year=l,this.month=c,this.day=f}}getDateObject(){return this.timestamp}getYear(){return this.year}getEnglishYear(){return this.yearEn}getMonth(){return this.month}getEnglishMonth(){return this.monthEn}getDate(){return this.day}getEnglishDate(){return this.dayEn}getDay(){return this.weekDay}getHours(){return this.hour}getMinutes(){return this.minute}getSeconds(){return this.timestamp.getSeconds()}getMilliseconds(){return this.timestamp.getMilliseconds()}getTime(){return this.timestamp.getTime()}setYear(t){this.set(t,this.month,this.day,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setMonth(t){this.set(this.year,t,this.day,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setDate(t){this.set(this.year,this.month,t,this.hour,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setHours(t){this.set(this.year,this.month,this.day,t,this.minute,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setMinutes(t){this.set(this.year,this.month,this.day,this.hour,t,this.timestamp.getSeconds(),this.timestamp.getMilliseconds())}setSeconds(t){this.set(this.year,this.month,this.day,this.hour,this.minute,t,this.timestamp.getMilliseconds())}setMilliseconds(t){this.set(this.year,this.month,this.day,this.hour,this.minute,this.timestamp.getSeconds(),t)}setTime(t){this._setDateObject(new Date(t))}set(t,n,a,s,r,o,u){M3(s,r,o,u);const[i,l,c]=V.nepaliToEnglish(t,n,a);this.year=t,this.month=n,this.day=a,this._setDateObject(Jt(i,l,c,s,r,o,u),!1)}setDateObject(t){this._setDateObject(t,!0)}format(t){return Re(this,t)}formatNepali(t){return t3(this,t)}toString(){return e3(this)}formatEnglishDate(t){return n3(this,t)}formatEnglishDateInNepali(t){return s3(this,t)}static fromEnglishDate(t,n,a,s=0,r=0,o=0,u=0){const i=Jt(t,n,a,s,r,o,u);return new E(i)}static parseNepaliFormat(t,n){const[a,s,r,o,u,i,l]=g3(t,n);return new E(a,s,r,o,u,i,l)}static parseEnglishDate(t,n){const[a,s,r,o,u,i,l]=l3(t,n);return E.fromEnglishDate(a,s,r,o,u,i,l)}static getDaysOfMonth(t,n){if(t<V.npMinYear()||t>V.npMaxYear())throw new Error("Year out of range");if(n<0||n>11)throw new Error("Month out of range");return _[t-V.npMinYear()][0][n]}static minSupportedDate(){return E.fromEnglishDate(V.enMinYear(),0,1).getDateObject()}static maxSupportedDate(){return E.fromEnglishDate(V.enMaxYear(),11,31).getDateObject()}static minSupportedNepaliDate(){return new E(V.npMinYear(),0,1)}static maxSupportedNepaliDate(){const t=V.npMaxYear();return new E(t,11,this.getDaysOfMonth(t,11))}static minimum(){return console.warn("`NepaliDate.minimum()` is deprecated and will be removed in a future version. Please use `NepaliDate.minSupportedDate()` instead."),this.minSupportedDate()}static maximum(){return console.warn("`NepaliDate.maximum()` is deprecated and will be removed in a future version. Please use `NepaliDate.maxSupportedDate()` instead."),this.maxSupportedDate()}}const de=["बैशाख","जेठ","आषाढ","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुन","चैत्र"],At=["Baishakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],me=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],fe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],De=["०","१","२","३","४","५","६","७","८","९"],S3={light:{primary:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",hover:"#f3f4f6",selected:"#3b82f6",today:"#dbeafe",disabled:"#d1d5db"},dark:{primary:"#60a5fa",background:"#1f2937",text:"#f9fafb",border:"#374151",hover:"#374151",selected:"#3b82f6",today:"#1e40af",disabled:"#6b7280"}},K=e=>e.toString().split("").map(t=>De[parseInt(t)]).join(""),vt=(e,t,n)=>{if(e==="BS")try{const a=n===11?new E(t+1,0,1):new E(t,n+1,1);return new E(a.getTime()-1440*60*1e3).getDate()}catch{return 30}return new Date(t,n+1,0).getDate()},ye=(e,t,n)=>{if(e==="BS")try{return new E(t,n,1).getDay()||0}catch{return 0}return new Date(t,n,1).getDay()},O=e=>{const t=new Date;if(e==="BS")try{const n=E.fromEnglishDate(t.getFullYear(),t.getMonth(),t.getDate());return{year:n.getYear(),month:n.getMonth(),day:n.getDate()}}catch{return{year:2081,month:0,day:1}}return{year:t.getFullYear(),month:t.getMonth(),day:t.getDate()}},ut=(e,t,n,a,s)=>{if(e==="BS")try{const r=new E(t,n,a),o=r.getEnglishYear(),u=r.getEnglishMonth(),i=r.getEnglishDate(),l=`${o}-${String(u+1).padStart(2,"0")}-${String(i).padStart(2,"0")}`;return{bs:`${t}-${String(n+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`,ad:l,formatted:{bs:`${s[n]} ${a}, ${t}`,ad:new Date(o,u,i).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}}}catch{const r=`${t}-${String(n+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`;return{bs:r,ad:r,formatted:{bs:`${s[n]} ${a}, ${t}`,ad:`${s[n]} ${a}, ${t}`}}}else{const r=`${t}-${String(n+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`,o=new Date(t,n,a);try{const u=E.fromEnglishDate(t,n,a),i=`${u.getYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`;return{ad:r,bs:i,formatted:{ad:o.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),bs:`${At[u.getMonth()]} ${u.getDate()}, ${u.getYear()}`}}}catch{return{ad:r,bs:r,formatted:{ad:o.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),bs:o.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}}}}},p3=(e,t,n)=>{const a=new Date(e.year,e.month,e.day).getTime(),s=new Date(t.year,t.month,t.day).getTime(),r=new Date(n.year,n.month,n.day).getTime();return a>=s&&a<=r},Me=e=>{try{const[t,n,a]=e.split("-").map(Number);return!t||!n||!a?null:{year:t,month:n-1,day:a}}catch{return null}},et=(e,t,n)=>{if(!t&&!n)return!1;const a=new Date(e.year,e.month,e.day).getTime();if(t){const s=Me(t);if(s){const r=new Date(s.year,s.month,s.day).getTime();if(a<r)return!0}}if(n){const s=Me(n);if(s){const r=new Date(s.year,s.month,s.day).getTime();if(a>r)return!0}}return!1},Se=(e="AD")=>{const t=k.useMemo(()=>O(e),[e]),[n,a]=k.useState(t.year),[s,r]=k.useState(t.month),[o,u]=k.useState(null),[i,l]=k.useState(null),[c,f]=k.useState(null);k.useEffect(()=>{a(t.year),r(t.month)},[t.year,t.month]);const g=k.useMemo(()=>{const w=vt(e,n,s),$=ye(e,n,s),p=[];for(let A=0;A<$;A++)p.push(null);for(let A=1;A<=w;A++)p.push(A);return p},[n,s,e]);return{currentYear:n,currentMonth:s,selectedDate:o,rangeStart:i,rangeEnd:c,today:t,calendarDays:g,setCurrentYear:a,setCurrentMonth:r,setSelectedDate:u,setRangeStart:l,setRangeEnd:f,navigateMonth:w=>{let p=s+w,A=n;for(;p>11;)p-=12,A+=1;for(;p<0;)p+=12,A-=1;r(p),a(A)},isToday:w=>n===t.year&&s===t.month&&w===t.day,isSelected:(w,$="single")=>$==="range"?!!(i&&i.year===n&&i.month===s&&i.day===w)||!!(c&&c.year===n&&c.month===s&&c.day===w):!!(o&&o.year===n&&o.month===s&&o.day===w),isInRange:w=>{if(!i||!c)return!1;const $=new Date(n,s,w).getTime(),p=new Date(i.year,i.month,i.day).getTime(),A=new Date(c.year,c.month,c.day).getTime();return $>=p&&$<=A}}},Q=(e,t,n)=>{if(n==="BS")try{const a=new E(e.year,e.month,e.day),s=new Date(a.getEnglishYear(),a.getEnglishMonth(),a.getEnglishDate());s.setDate(s.getDate()+t);const r=E.fromEnglishDate(s.getFullYear(),s.getMonth(),s.getDate());return{year:r.getYear(),month:r.getMonth(),day:r.getDate()}}catch{return e}else{const a=new Date(e.year,e.month,e.day);return a.setDate(a.getDate()+t),{year:a.getFullYear(),month:a.getMonth(),day:a.getDate()}}},ct=(e,t,n)=>{if(n==="BS")try{let a=e.year,s=e.month+t;for(;s<0;)a-=1,s+=12;for(;s>=12;)a+=1,s-=12;const r=vt("BS",a,s),o=Math.min(e.day,r);return{year:a,month:s,day:o}}catch{return e}else{const a=new Date(e.year,e.month,e.day);return a.setMonth(a.getMonth()+t),{year:a.getFullYear(),month:a.getMonth(),day:a.getDate()}}},G=e=>({year:e.year,month:e.month,day:1}),b3=(e,t)=>{if(t==="BS")try{const a=new E(e.year,e.month,e.day).getDay();return Q(e,-a,"BS")}catch{return e}else{const n=new Date(e.year,e.month,e.day),a=n.getDay();return n.setDate(n.getDate()-a),{year:n.getFullYear(),month:n.getMonth(),day:n.getDate()}}},E3={TODAY:"today",YESTERDAY:"yesterday",THIS_WEEK:"thisWeek",LAST_7_DAYS:"last7days",LAST_30_DAYS:"last30days",THIS_MONTH:"thisMonth",LAST_MONTH:"lastMonth",LAST_3_MONTHS:"last3months",LAST_6_MONTHS:"last6months",LAST_180_DAYS:"last180days",LAST_9_MONTHS:"last9months",LAST_YEAR:"lastYear"},pe=(e,t)=>{const n=[{key:"today",label:"Today",getValue:s=>{const r=O(s);return{start:r,end:r}}},{key:"yesterday",label:"Yesterday",getValue:s=>{const r=O(s),o=Q(r,-1,s);return{start:o,end:o}}},{key:"thisWeek",label:"This Week",getValue:s=>{const r=O(s);return{start:b3(r,s),end:r}}},{key:"last7days",label:"Last 7 Days",getValue:s=>{const r=O(s);return{start:Q(r,-6,s),end:r}}},{key:"last30days",label:"Last 30 Days",getValue:s=>{const r=O(s);return{start:Q(r,-29,s),end:r}}},{key:"thisMonth",label:"This Month",getValue:s=>{const r=O(s);return{start:G(r),end:r}}},{key:"lastMonth",label:"Last Month",getValue:s=>{const r=O(s),o=Q(G(r),-1,s);return{start:G(o),end:o}}},{key:"last3months",label:"Last 3 Months",getValue:s=>{const r=O(s),o=ct(r,-2,s);return{start:G(o),end:r}}},{key:"last6months",label:"Last 6 Months",getValue:s=>{const r=O(s),o=ct(r,-5,s);return{start:G(o),end:r}}},{key:"last180days",label:"Last 180 Days",getValue:s=>{const r=O(s);return{start:Q(r,-179,s),end:r}}},{key:"last9months",label:"Last 9 Months",getValue:s=>{const r=O(s),o=ct(r,-8,s);return{start:G(o),end:r}}},{key:"lastYear",label:"Last Year",getValue:s=>{const r=O(s),o=ct(r,-11,s);return{start:G(o),end:r}}}],a=e?n.filter(s=>e.includes(s.key)):n;return t?a.map(s=>({...s,label:t[s.key]||s.label})):a},w3=({currentYear:e,currentMonth:t,months:n,onYearChange:a,onMonthChange:s,onClose:r,showNepaliNumbers:o=!1,convertToNepaliNumber:u=l=>l.toString(),calendarType:i})=>{const[l,c]=k.useState(Math.floor(e/12)*12),f=i==="BS"?2e3:1944,g=i==="BS"?2100:2043;return h.jsx("div",{className:"bsac-picker-overlay",onClick:r,children:h.jsxs("div",{className:"bsac-picker-content",onClick:C=>C.stopPropagation(),children:[h.jsxs("div",{className:"bsac-picker-header",children:[h.jsx("h3",{children:"Select Month & Year"}),h.jsx("button",{className:"bsac-close-btn",onClick:r,children:"×"})]}),h.jsxs("div",{className:"bsac-picker-body",children:[h.jsxs("div",{className:"bsac-picker-section",children:[h.jsxs("div",{className:"bsac-picker-section-header",children:[h.jsx("label",{children:"Year"}),h.jsxs("div",{className:"bsac-year-nav",children:[h.jsx("button",{onClick:()=>c(Math.max(f,l-12)),disabled:l<=f,children:"«"}),h.jsxs("span",{children:[o?u(l):l," – ",o?u(l+11):l+11]}),h.jsx("button",{onClick:()=>c(Math.min(g-11,l+12)),disabled:l+11>=g,children:"»"})]})]}),h.jsx("div",{className:"bsac-year-grid",children:Array.from({length:12},(C,m)=>{const v=l+m;return v>g?null:h.jsx("button",{onClick:()=>a(v),className:v===e?"bsac-selected":"",children:o?u(v):v},v)})})]}),h.jsxs("div",{className:"bsac-picker-section",children:[h.jsx("label",{children:"Month"}),h.jsx("div",{className:"bsac-month-grid",children:n.map((C,m)=>h.jsx("button",{onClick:()=>{s(m),r()},className:m===t?"bsac-selected":"",children:C},m))})]})]})]})})},ht=({currentMonth:e,currentYear:t,months:n,onNavigateMonth:a,onYearChange:s,onMonthChange:r,disabled:o=!1,showNepaliNumbers:u=!1,convertToNepaliNumber:i,calendarType:l})=>{const[c,f]=k.useState(!1);return h.jsxs("div",{className:"bsac-header",children:[h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(-12),disabled:o,"aria-label":"Previous year",children:"«"}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(-1),disabled:o,"aria-label":"Previous month",children:"‹"}),h.jsxs("button",{className:"bsac-month-year-btn",onClick:()=>f(!0),disabled:o,children:[n[e]," ",u?i(t):t]}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(1),disabled:o,"aria-label":"Next month",children:"›"}),h.jsx("button",{className:"bsac-nav-btn",onClick:()=>a(12),disabled:o,"aria-label":"Next year",children:"»"}),c&&h.jsx(w3,{currentYear:t,currentMonth:e,months:n,onYearChange:s,onMonthChange:r,onClose:()=>f(!1),showNepaliNumbers:u,convertToNepaliNumber:i,calendarType:l})]})},lt=({calendarDays:e,days:t,onDateSelect:n,isSelected:a,isInRange:s,isToday:r,isDisabled:o,disabled:u=!1,showNepaliNumbers:i=!1,convertToNepaliNumber:l})=>h.jsxs("div",{className:"bsac-grid",children:[t.map(c=>h.jsx("div",{className:"bsac-day-header",children:c},c)),e.map((c,f)=>{const g=c?o?.(c)||u:!1,C=c?a(c):!1,m=c?s(c):!1,v=c?r(c):!1,I=["bsac-day",c?g?"bsac-day-disabled":C?"bsac-day-selected":m?"bsac-day-in-range":v?"bsac-day-today":"":"bsac-day-empty"].filter(Boolean).join(" ");return h.jsx("div",{className:I,onClick:()=>c&&!g&&n(c),children:c?i?l(c):c:""},f)})]}),dt=({presets:e,calendarType:t,onPresetSelect:n,activePreset:a,position:s="top"})=>{const r=o=>{const u=o.getValue(t);n(o,u)};return h.jsx("div",{className:`bsac-presets bsac-presets--${s}`,children:e.map(o=>h.jsx("button",{onClick:()=>r(o),className:`bsac-preset-btn${a===o.key?" bsac-preset-btn--active":""}`,children:o.label},o.key))})},be=({calendarType:e="AD",value:t,onChange:n,className:a="",showToday:s=!0,disabled:r=!1,outputFormat:o="both",onDateSelect:u,mode:i="single",onRangeSelect:l,showRangePresets:c=!1,rangePresetsPosition:f="top",predefinedRanges:g,presetKeys:C,presetLabels:m,onPresetSelect:v,renderPresets:I,showNepaliMonths:w=!1,showNepaliDays:$=!1,showNepaliNumbers:p=!1,theme:A="light",colors:gt,minDate:x,maxDate:z})=>{const{currentYear:B,currentMonth:H,rangeStart:P,rangeEnd:D,calendarDays:Y,setSelectedDate:W,setRangeStart:M,setRangeEnd:F,setCurrentYear:U,setCurrentMonth:J,navigateMonth:N,isToday:mt,isSelected:ft,isInRange:Dt}=Se(e),[yt,$t]=k.useState(),Mt=g||pe(C,m),St=(d,y)=>({start:ut(e,d.year,d.month,d.day,q),end:ut(e,y.year,y.month,y.day,q)}),q=e==="BS"&&w?de:e==="BS"?At:ge,pt=e==="BS"&&$?me:fe,bt=(d,y)=>{y.start&&y.end&&(M(y.start),F(y.end),U(y.start.year),J(y.start.month),$t(d.key),v?.(d,y),l?.(St(y.start,y.end)))},Y3=(d,y)=>{M(d),F(y),$t(void 0),l?.(St(d,y))},Et=d=>{if(r)return;const y={year:B,month:H,day:d};if(et(y,x,z))return;if(i==="range"){if($t(void 0),!P||P&&D)M(y),F(null);else{const tt=new Date(P.year,P.month,P.day).getTime();new Date(y.year,y.month,y.day).getTime()<tt?(M(y),F(P),l?.(St(y,P))):(F(y),l?.(St(P,y)))}return}W(y);const R=ut(e,B,H,d,q);if(u?.(R),n){let tt;switch(o){case"iso":tt=R.ad;break;case"object":tt=JSON.stringify(R);break;default:tt=JSON.stringify(R);break}n(tt)}},k3=d=>{if(!r){switch(d.key){case"ArrowLeft":N(-1);break;case"ArrowRight":N(1);break;case"ArrowUp":N(-12);break;case"ArrowDown":N(12);break;case"PageUp":d.shiftKey?N(-12):N(-1);break;case"PageDown":d.shiftKey?N(12):N(1);break;default:return}d.preventDefault()}},C3={...gt?Object.entries(gt).reduce((d,[y,R])=>(d[`--calendar-${y}`]=R,d),{}):{}};return h.jsxs("div",{className:`bsac-calendar ${a}`,style:C3,"data-theme":A,onKeyDown:k3,tabIndex:0,role:"application","aria-label":"Calendar",children:[i==="range"&&I&&h.jsxs("div",{style:{display:"flex",gap:"16px"},children:[h.jsx("div",{children:I({onRangeChange:Y3})}),h.jsxs("div",{style:{flex:1},children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]})]}),i==="range"&&c&&f==="left"&&!I&&h.jsxs("div",{style:{display:"flex",gap:"16px",flexWrap:"nowrap"},children:[h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"left"}),h.jsxs("div",{children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]})]}),i==="range"&&c&&f==="right"&&!I&&h.jsxs("div",{style:{display:"flex",gap:"16px",flexWrap:"nowrap"},children:[h.jsxs("div",{children:[h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K})]}),h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"right"})]}),(!i||i==="single"||!c&&!I||f==="top"||f==="bottom")&&h.jsxs(h.Fragment,{children:[i==="range"&&c&&f==="top"&&h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"top"}),h.jsx(ht,{currentMonth:H,currentYear:B,months:q,onNavigateMonth:N,onYearChange:U,onMonthChange:J,disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K,calendarType:e}),h.jsx(lt,{calendarDays:Y,days:pt,onDateSelect:Et,isSelected:d=>ft(d,i),isInRange:Dt,isToday:d=>s&&mt(d),isDisabled:d=>et({year:B,month:H,day:d},x,z),disabled:r,showNepaliNumbers:p,convertToNepaliNumber:K}),i==="range"&&c&&f==="bottom"&&h.jsx(dt,{presets:Mt,calendarType:e,onPresetSelect:bt,activePreset:yt,position:"bottom"})]})]})},Ee=({placeholder:e="Select date",format:t="YYYY-MM-DD",defaultValue:n,onDateSelect:a,inputClassName:s="",popupClassName:r="",style:o,inputStyle:u,icon:i,showIcon:l=!0,calendarType:c="AD",...f})=>{const[g,C]=k.useState(!1),[m,v]=k.useState(null),[I,w]=k.useState(()=>{if(!n)return"";if(c==="BS")try{const[D,Y,W]=n.split("-").map(Number),M=E.fromEnglishDate(D,Y-1,W);return`${M.getYear()}-${String(M.getMonth()+1).padStart(2,"0")}-${String(M.getDate()).padStart(2,"0")}`}catch{return n}return n}),$=k.useRef(null),p=k.useRef(null),[A,gt]=k.useState({visibility:"hidden"}),x=()=>{if(!$.current)return;const D=$.current.getBoundingClientRect(),Y=p.current?.offsetHeight||360,W=p.current?.offsetWidth||280,M=window.innerHeight-D.bottom,F=window.innerWidth-D.left,U=M>=Y+8?D.bottom+8:Math.max(8,D.top-Y-8),J=F>=W?D.left:Math.max(8,D.right-W);gt({top:U,left:J,visibility:"visible"})};k.useEffect(()=>(g&&(requestAnimationFrame(x),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x)),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}),[g]),k.useEffect(()=>{const D=Y=>{$.current&&!$.current.contains(Y.target)&&C(!1)};return g&&document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[g]);const z=D=>{v(D),w(c==="BS"?D.bs:D.ad),C(!1),a?.(D)},B=D=>{const Y=D.target.value;if(Y===""){w("");return}if((D.target.selectionStart||0)===Y.length&&Y.length>I.length){const M=Y.replace(/[^0-9]/g,"");let F=M;M.length>4&&M.length<=6?F=M.slice(0,4)+"-"+M.slice(4):M.length>6&&(F=M.slice(0,4)+"-"+M.slice(4,6)+"-"+M.slice(6,8)),w(F)}else{const M=Y.replace(/[^0-9-]/g,"");M.length<=10&&w(M)}},H=()=>{const D=I.trim();if(!D){v(null);return}const Y=D.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(Y){const[,W,M,F]=Y,U=parseInt(M),J=parseInt(F);if(U<1||U>12||J<1||J>32){w(m?c==="BS"?m.bs:m.ad:"");return}const N={bs:c==="BS"?`${W}-${M}-${F}`:"",ad:c==="AD"?`${W}-${M}-${F}`:"",formatted:{bs:c==="BS"?D:"",ad:c==="AD"?D:""}};if(v(N),m===null)return;a?.(N)}else D.length<10&&w(m?c==="BS"?m.bs:m.ad:"")},P=D=>{D.key==="Enter"?(H(),C(!1)):D.key==="Escape"&&C(!1)};return h.jsxs("div",{className:"bsac-datepicker",ref:$,style:o,children:[h.jsx("input",{type:"text",value:I,placeholder:e,onChange:B,onBlur:H,onKeyDown:P,className:`bsac-input ${s}`,style:u,"aria-label":"Date picker input","aria-haspopup":"dialog","aria-expanded":g,maxLength:10}),h.jsx("button",{type:"button",className:"bsac-icon-btn",onClick:()=>C(!g),"aria-label":"Toggle calendar",style:{display:l?"flex":"none"},children:i||h.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),h.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),h.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})}),g&&h.jsx("div",{ref:p,className:`bsac-popup ${r}`,style:A,children:h.jsx(be,{calendarType:c,onDateSelect:z,...f})})]})};S.Calendar=be,S.CalendarInput=Ee,S.DEFAULT_COLORS=S3,S.DatePicker=Ee,S.ENGLISH_DAYS=fe,S.ENGLISH_MONTHS_AD=ge,S.ENGLISH_MONTHS_BS=At,S.NEPALI_DAYS=me,S.NEPALI_DIGITS=De,S.NEPALI_MONTHS=de,S.PRESET_KEYS=E3,S.convertToNepaliNumber=K,S.createDateOutput=ut,S.createPredefinedRanges=pe,S.getDaysInMonth=vt,S.getFirstDayOfMonth=ye,S.getTodayDate=O,S.isDateInRange=p3,S.useCalendar=Se,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { DateOutput } from '../types';
|
|
3
2
|
interface CustomizationTabProps {
|
|
4
|
-
outputAD: string;
|
|
5
|
-
onADSelect: (date: DateOutput) => void;
|
|
6
3
|
copied: string | null;
|
|
7
4
|
onCopyCode: (code: string, id: string) => void;
|
|
8
|
-
renderOutput: (output: string) => React.ReactNode;
|
|
9
5
|
}
|
|
10
6
|
declare const CustomizationTab: React.FC<CustomizationTabProps>;
|
|
11
7
|
export default CustomizationTab;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bs-ad-calendar-react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern React calendar component for seamless conversion between Bikram Sambat (BS) and Gregorian (AD) calendars. Supports date picker, range selection, Nepali localization, and dark theme.",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "./dist/bs-ad-calendar.
|
|
7
|
+
"main": "./dist/bs-ad-calendar.umd.cjs",
|
|
8
8
|
"module": "./dist/bs-ad-calendar.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|