@itzsa/nepali-datepicker 0.3.1

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/index.js ADDED
@@ -0,0 +1,2217 @@
1
+ 'use strict';
2
+
3
+ var React6 = require('react');
4
+ var reactDom = require('react-dom');
5
+ var clsx = require('clsx');
6
+ var tailwindMerge = require('tailwind-merge');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
28
+
29
+ // src/calendar-data.ts
30
+ var BS_MONTH_DAYS = {
31
+ 2e3: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
32
+ 2001: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
33
+ 2002: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
34
+ 2003: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
35
+ 2004: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
36
+ 2005: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
37
+ 2006: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
38
+ 2007: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
39
+ 2008: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
40
+ 2009: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
41
+ 2010: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
42
+ 2011: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
43
+ 2012: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
44
+ 2013: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
45
+ 2014: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
46
+ 2015: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
47
+ 2016: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
48
+ 2017: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
49
+ 2018: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
50
+ 2019: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
51
+ 2020: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
52
+ 2021: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
53
+ 2022: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
54
+ 2023: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
55
+ 2024: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
56
+ 2025: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
57
+ 2026: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
58
+ 2027: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
59
+ 2028: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
60
+ 2029: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
61
+ 2030: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
62
+ 2031: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
63
+ 2032: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
64
+ 2033: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
65
+ 2034: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
66
+ 2035: [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
67
+ 2036: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
68
+ 2037: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
69
+ 2038: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
70
+ 2039: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
71
+ 2040: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
72
+ 2041: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
73
+ 2042: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
74
+ 2043: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
75
+ 2044: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
76
+ 2045: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
77
+ 2046: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
78
+ 2047: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
79
+ 2048: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
80
+ 2049: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
81
+ 2050: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
82
+ 2051: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
83
+ 2052: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
84
+ 2053: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
85
+ 2054: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
86
+ 2055: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
87
+ 2056: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
88
+ 2057: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
89
+ 2058: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
90
+ 2059: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
91
+ 2060: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
92
+ 2061: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
93
+ 2062: [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
94
+ 2063: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
95
+ 2064: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
96
+ 2065: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
97
+ 2066: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
98
+ 2067: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
99
+ 2068: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
100
+ 2069: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
101
+ 2070: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
102
+ 2071: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
103
+ 2072: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
104
+ 2073: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
105
+ 2074: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
106
+ 2075: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
107
+ 2076: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
108
+ 2077: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
109
+ 2078: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
110
+ 2079: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
111
+ 2080: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
112
+ 2081: [31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
113
+ 2082: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
114
+ 2083: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
115
+ 2084: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
116
+ 2085: [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
117
+ 2086: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
118
+ 2087: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
119
+ 2088: [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
120
+ 2089: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
121
+ 2090: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
122
+ 2091: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
123
+ 2092: [30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
124
+ 2093: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
125
+ 2094: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
126
+ 2095: [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30],
127
+ 2096: [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
128
+ 2097: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
129
+ 2098: [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 30, 31],
130
+ 2099: [31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30],
131
+ 2100: [31, 32, 31, 32, 30, 31, 30, 29, 30, 29, 30, 30]
132
+ };
133
+ var BS_MIN_YEAR = 2e3;
134
+ var BS_MAX_YEAR = 2100;
135
+ var BS_EPOCH_AD = { year: 1943, month: 4, day: 14 };
136
+
137
+ // src/convert.ts
138
+ var MS_PER_DAY = 864e5;
139
+ function assertYear(year) {
140
+ if (!Number.isInteger(year) || year < BS_MIN_YEAR || year > BS_MAX_YEAR) {
141
+ throw new RangeError(
142
+ `BS year must be an integer between ${BS_MIN_YEAR} and ${BS_MAX_YEAR} (got ${year})`
143
+ );
144
+ }
145
+ }
146
+ function assertMonth(month) {
147
+ if (!Number.isInteger(month) || month < 1 || month > 12) {
148
+ throw new RangeError(`Month must be an integer 1\u201312 (got ${month})`);
149
+ }
150
+ }
151
+ function getDaysInBsMonth(year, month) {
152
+ assertYear(year);
153
+ assertMonth(month);
154
+ return BS_MONTH_DAYS[year][month - 1];
155
+ }
156
+ function getDaysInBsYear(year) {
157
+ assertYear(year);
158
+ return BS_MONTH_DAYS[year].reduce((sum, d) => sum + d, 0);
159
+ }
160
+ function isValidBsDate(year, month, day) {
161
+ if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
162
+ return false;
163
+ }
164
+ if (year < BS_MIN_YEAR || year > BS_MAX_YEAR) return false;
165
+ if (month < 1 || month > 12) return false;
166
+ if (day < 1) return false;
167
+ const max = BS_MONTH_DAYS[year]?.[month - 1];
168
+ if (max == null) return false;
169
+ return day <= max;
170
+ }
171
+ function assertBsDate(year, month, day) {
172
+ if (!isValidBsDate(year, month, day)) {
173
+ throw new RangeError(`Invalid BS date ${year}-${month}-${day}`);
174
+ }
175
+ }
176
+ function daysFromBsEpoch(year, month, day) {
177
+ assertBsDate(year, month, day);
178
+ let days = 0;
179
+ for (let y = BS_MIN_YEAR; y < year; y++) {
180
+ days += getDaysInBsYear(y);
181
+ }
182
+ for (let m = 1; m < month; m++) {
183
+ days += getDaysInBsMonth(year, m);
184
+ }
185
+ return days + (day - 1);
186
+ }
187
+ function utcCivilParts(ms) {
188
+ const d = new Date(ms);
189
+ return {
190
+ year: d.getUTCFullYear(),
191
+ month: d.getUTCMonth() + 1,
192
+ day: d.getUTCDate()
193
+ };
194
+ }
195
+ function utcMsFromParts(parts) {
196
+ return Date.UTC(parts.year, parts.month - 1, parts.day);
197
+ }
198
+ function bsToAd(year, month, day) {
199
+ const offset = daysFromBsEpoch(year, month, day);
200
+ const epochMs = utcMsFromParts(BS_EPOCH_AD);
201
+ return utcCivilParts(epochMs + offset * MS_PER_DAY);
202
+ }
203
+ function adToBs(year, month, day) {
204
+ if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
205
+ throw new RangeError("AD year/month/day must be integers");
206
+ }
207
+ if (month < 1 || month > 12 || day < 1 || day > 31) {
208
+ throw new RangeError(`Invalid AD date ${year}-${month}-${day}`);
209
+ }
210
+ const epochMs = utcMsFromParts(BS_EPOCH_AD);
211
+ const targetMs = Date.UTC(year, month - 1, day);
212
+ let remaining = Math.round((targetMs - epochMs) / MS_PER_DAY);
213
+ if (remaining < 0) {
214
+ throw new RangeError(
215
+ `AD date ${year}-${month}-${day} is before supported BS range`
216
+ );
217
+ }
218
+ let bsYear = BS_MIN_YEAR;
219
+ while (bsYear <= BS_MAX_YEAR) {
220
+ const yearDays = getDaysInBsYear(bsYear);
221
+ if (remaining < yearDays) break;
222
+ remaining -= yearDays;
223
+ bsYear += 1;
224
+ }
225
+ if (bsYear > BS_MAX_YEAR) {
226
+ throw new RangeError(
227
+ `AD date ${year}-${month}-${day} is after supported BS range`
228
+ );
229
+ }
230
+ let bsMonth = 1;
231
+ while (bsMonth <= 12) {
232
+ const monthDays = getDaysInBsMonth(bsYear, bsMonth);
233
+ if (remaining < monthDays) break;
234
+ remaining -= monthDays;
235
+ bsMonth += 1;
236
+ }
237
+ return { year: bsYear, month: bsMonth, day: remaining + 1 };
238
+ }
239
+ function todayBs() {
240
+ const now = /* @__PURE__ */ new Date();
241
+ return adToBs(now.getFullYear(), now.getMonth() + 1, now.getDate());
242
+ }
243
+ function todayBsDateTime() {
244
+ const now = /* @__PURE__ */ new Date();
245
+ const date = adToBs(now.getFullYear(), now.getMonth() + 1, now.getDate());
246
+ return {
247
+ ...date,
248
+ hour: now.getHours(),
249
+ minute: now.getMinutes(),
250
+ second: now.getSeconds()
251
+ };
252
+ }
253
+ function getBsWeekday(year, month, day) {
254
+ const ad = bsToAd(year, month, day);
255
+ return new Date(Date.UTC(ad.year, ad.month - 1, ad.day)).getUTCDay();
256
+ }
257
+ function compareDateParts(a, b) {
258
+ if (a.year !== b.year) return a.year < b.year ? -1 : 1;
259
+ if (a.month !== b.month) return a.month < b.month ? -1 : 1;
260
+ if (a.day !== b.day) return a.day < b.day ? -1 : 1;
261
+ return 0;
262
+ }
263
+ function clampBsDate(parts, min, max) {
264
+ let next = parts;
265
+ if (min && compareDateParts(next, min) < 0) next = min;
266
+ if (max && compareDateParts(next, max) > 0) next = max;
267
+ return next;
268
+ }
269
+ function addBsMonths(year, month, delta) {
270
+ const idx = year * 12 + (month - 1) + delta;
271
+ const y = Math.floor(idx / 12);
272
+ const m = idx % 12 + 1;
273
+ if (y < BS_MIN_YEAR || y > BS_MAX_YEAR) {
274
+ throw new RangeError("Month navigation out of supported BS range");
275
+ }
276
+ return { year: y, month: m };
277
+ }
278
+ function diffBsDays(a, b) {
279
+ const adA = bsToAd(a.year, a.month, a.day);
280
+ const adB = bsToAd(b.year, b.month, b.day);
281
+ return Math.round(
282
+ (utcMsFromParts(adB) - utcMsFromParts(adA)) / MS_PER_DAY
283
+ );
284
+ }
285
+ function addBsDays(parts, delta) {
286
+ const ad = bsToAd(parts.year, parts.month, parts.day);
287
+ const next = utcCivilParts(utcMsFromParts(ad) + delta * MS_PER_DAY);
288
+ return adToBs(next.year, next.month, next.day);
289
+ }
290
+
291
+ // src/datetime.ts
292
+ function pad2(n) {
293
+ return n < 10 ? `0${n}` : String(n);
294
+ }
295
+ function isValidTime(hour, minute, second = 0) {
296
+ return Number.isInteger(hour) && Number.isInteger(minute) && Number.isInteger(second) && hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59 && second >= 0 && second <= 59;
297
+ }
298
+ function parseDateTimeString(value) {
299
+ const trimmed = value.trim().replace(/\//g, "-");
300
+ const m = /^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}):(\d{1,2})(?::(\d{1,2}))?)?$/.exec(
301
+ trimmed
302
+ );
303
+ if (!m) return null;
304
+ const year = Number(m[1]);
305
+ const month = Number(m[2]);
306
+ const day = Number(m[3]);
307
+ const hour = m[4] != null ? Number(m[4]) : 0;
308
+ const minute = m[5] != null ? Number(m[5]) : 0;
309
+ const second = m[6] != null ? Number(m[6]) : 0;
310
+ if (!isValidBsDate(year, month, day)) return null;
311
+ if (!isValidTime(hour, minute, second)) return null;
312
+ return { year, month, day, hour, minute, second };
313
+ }
314
+ function toDateTimeString(parts, opts) {
315
+ const base = `${parts.year}-${pad2(parts.month)}-${pad2(parts.day)} ${pad2(parts.hour)}:${pad2(parts.minute)}`;
316
+ if (opts?.withSeconds) {
317
+ return `${base}:${pad2(parts.second ?? 0)}`;
318
+ }
319
+ return base;
320
+ }
321
+ function dateTimeToDateParts(dt) {
322
+ return { year: dt.year, month: dt.month, day: dt.day };
323
+ }
324
+ function compareDateTimeParts(a, b) {
325
+ if (a.year !== b.year) return a.year < b.year ? -1 : 1;
326
+ if (a.month !== b.month) return a.month < b.month ? -1 : 1;
327
+ if (a.day !== b.day) return a.day < b.day ? -1 : 1;
328
+ if (a.hour !== b.hour) return a.hour < b.hour ? -1 : 1;
329
+ if (a.minute !== b.minute) return a.minute < b.minute ? -1 : 1;
330
+ const as = a.second ?? 0;
331
+ const bs = b.second ?? 0;
332
+ if (as !== bs) return as < bs ? -1 : 1;
333
+ return 0;
334
+ }
335
+ function clampDateTime(parts, min, max) {
336
+ let next = parts;
337
+ if (min && compareDateTimeParts(next, min) < 0) next = { ...min };
338
+ if (max && compareDateTimeParts(next, max) > 0) next = { ...max };
339
+ return next;
340
+ }
341
+ function parseDateTimeBound(value, edge) {
342
+ if (!value) return null;
343
+ const full = parseDateTimeString(value);
344
+ if (full) {
345
+ const hasTime = /[T ]\d/.test(value.trim());
346
+ if (!hasTime) {
347
+ return edge === "min" ? { ...full, hour: 0, minute: 0, second: 0 } : { ...full, hour: 23, minute: 59, second: 59 };
348
+ }
349
+ return full;
350
+ }
351
+ return null;
352
+ }
353
+ function isCompleteBsDateTime(value, opts) {
354
+ const dt = parseDateTimeString(value);
355
+ if (!dt) return false;
356
+ const hasTime = /[T ]\d{1,2}:\d{1,2}/.test(value.trim());
357
+ if (!hasTime) return false;
358
+ if (opts?.requireSeconds) {
359
+ return /:\d{1,2}:\d{1,2}/.test(value.trim());
360
+ }
361
+ return true;
362
+ }
363
+ function snapMinute(minute, step) {
364
+ const s = Math.max(1, Math.min(30, Math.floor(step)));
365
+ return Math.floor(minute / s) * s;
366
+ }
367
+
368
+ // src/locale.ts
369
+ var NEPALI_MONTH_NAMES_EN = [
370
+ "Baisakh",
371
+ "Jestha",
372
+ "Ashar",
373
+ "Shrawan",
374
+ "Bhadra",
375
+ "Ashwin",
376
+ "Kartik",
377
+ "Mangsir",
378
+ "Poush",
379
+ "Magh",
380
+ "Falgun",
381
+ "Chaitra"
382
+ ];
383
+ var NEPALI_MONTH_NAMES_NE = [
384
+ "\u092C\u0948\u0936\u093E\u0916",
385
+ "\u091C\u0947\u0920",
386
+ "\u0905\u0938\u093E\u0930",
387
+ "\u0938\u093E\u0909\u0928",
388
+ "\u092D\u0926\u094C",
389
+ "\u0905\u0938\u094B\u091C",
390
+ "\u0915\u093E\u0930\u094D\u0924\u093F\u0915",
391
+ "\u092E\u0902\u0938\u093F\u0930",
392
+ "\u092A\u0941\u0937",
393
+ "\u092E\u093E\u0918",
394
+ "\u092B\u093E\u0932\u094D\u0917\u0941\u0928",
395
+ "\u091A\u0948\u0924"
396
+ ];
397
+ var WEEKDAY_NAMES_EN = [
398
+ "Sun",
399
+ "Mon",
400
+ "Tue",
401
+ "Wed",
402
+ "Thu",
403
+ "Fri",
404
+ "Sat"
405
+ ];
406
+ var WEEKDAY_NAMES_NE = [
407
+ "\u0906\u0907\u0924",
408
+ "\u0938\u094B\u092E",
409
+ "\u092E\u0902\u0917\u0932",
410
+ "\u092C\u0941\u0927",
411
+ "\u092C\u093F\u0939\u0940",
412
+ "\u0936\u0941\u0915\u094D\u0930",
413
+ "\u0936\u0928\u093F"
414
+ ];
415
+ var DIGITS_NE = ["\u0966", "\u0967", "\u0968", "\u0969", "\u096A", "\u096B", "\u096C", "\u096D", "\u096E", "\u096F"];
416
+ function getMonthName(month, locale = "en") {
417
+ const idx = month - 1;
418
+ if (idx < 0 || idx > 11) return String(month);
419
+ return locale === "ne" ? NEPALI_MONTH_NAMES_NE[idx] : NEPALI_MONTH_NAMES_EN[idx];
420
+ }
421
+ function getWeekdayNames(locale = "en") {
422
+ return locale === "ne" ? WEEKDAY_NAMES_NE : WEEKDAY_NAMES_EN;
423
+ }
424
+ function localizeDigits(value, locale) {
425
+ const s = String(value);
426
+ if (locale !== "ne") return s;
427
+ return s.replace(/\d/g, (d) => DIGITS_NE[Number(d)]);
428
+ }
429
+
430
+ // src/format.ts
431
+ function pad22(n) {
432
+ return n < 10 ? `0${n}` : String(n);
433
+ }
434
+ var BS_DATE_COMPLETE = /^\d{4}[-/]\d{2}[-/]\d{2}$/;
435
+ function parseDateString(value) {
436
+ const trimmed = value.trim().replace(/\//g, "-");
437
+ const m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(trimmed);
438
+ if (!m) return null;
439
+ const year = Number(m[1]);
440
+ const month = Number(m[2]);
441
+ const day = Number(m[3]);
442
+ if (!isValidBsDate(year, month, day)) return null;
443
+ return { year, month, day };
444
+ }
445
+ function formatTypedBsDate(raw) {
446
+ const digits = raw.replace(/\D/g, "").slice(0, 8);
447
+ if (digits.length <= 4) return digits;
448
+ if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
449
+ return `${digits.slice(0, 4)}-${digits.slice(4, 6)}-${digits.slice(6)}`;
450
+ }
451
+ function isCompleteBsDate(value) {
452
+ const normalized = value.trim().replace(/\//g, "-");
453
+ if (!BS_DATE_COMPLETE.test(normalized)) return false;
454
+ return parseDateString(normalized) != null;
455
+ }
456
+ function toDateString(parts) {
457
+ return `${parts.year}-${pad22(parts.month)}-${pad22(parts.day)}`;
458
+ }
459
+ function formatDateParts(parts, pattern = "YYYY-MM-DD", locale = "en") {
460
+ const y = String(parts.year);
461
+ const m = pad22(parts.month);
462
+ const d = pad22(parts.day);
463
+ let out;
464
+ switch (pattern) {
465
+ case "YYYY/MM/DD":
466
+ out = `${y}/${m}/${d}`;
467
+ break;
468
+ case "DD-MM-YYYY":
469
+ out = `${d}-${m}-${y}`;
470
+ break;
471
+ case "DD/MM/YYYY":
472
+ out = `${d}/${m}/${y}`;
473
+ break;
474
+ default:
475
+ out = `${y}-${m}-${d}`;
476
+ }
477
+ return localizeDigits(out, locale);
478
+ }
479
+ function formatBsLabel(parts, locale = "en") {
480
+ const day = localizeDigits(parts.day, locale);
481
+ const month = getMonthName(parts.month, locale);
482
+ const year = localizeDigits(parts.year, locale);
483
+ return `${day} ${month} ${year}`;
484
+ }
485
+ function formatBsDateTimeLabel(parts, locale = "en", opts) {
486
+ const date = formatBsLabel(parts, locale);
487
+ const h = localizeDigits(pad22(parts.hour), locale);
488
+ const m = localizeDigits(pad22(parts.minute), locale);
489
+ if (opts?.withSeconds) {
490
+ const s = localizeDigits(pad22(parts.second ?? 0), locale);
491
+ return `${date}, ${h}:${m}:${s}`;
492
+ }
493
+ return `${date}, ${h}:${m}`;
494
+ }
495
+
496
+ // src/validate.ts
497
+ function assertBsYear(year) {
498
+ if (typeof year !== "number" || !Number.isInteger(year)) {
499
+ throw new TypeError("bsYear must be an integer");
500
+ }
501
+ if (year < BS_MIN_YEAR || year > BS_MAX_YEAR) {
502
+ throw new RangeError(
503
+ `bsYear must be between ${BS_MIN_YEAR} and ${BS_MAX_YEAR} (got ${year})`
504
+ );
505
+ }
506
+ }
507
+ function assertBsMonth(month) {
508
+ if (typeof month !== "number" || !Number.isInteger(month)) {
509
+ throw new TypeError("bsMonth must be an integer");
510
+ }
511
+ if (month < 1 || month > 12) {
512
+ throw new RangeError(`bsMonth must be 1\u201312 (got ${month})`);
513
+ }
514
+ }
515
+ function assertBsDay(day) {
516
+ if (typeof day !== "number" || !Number.isInteger(day)) {
517
+ throw new TypeError("bsDay must be an integer");
518
+ }
519
+ if (day < 1 || day > 32) {
520
+ throw new RangeError(`bsDay must be 1\u201332 (got ${day})`);
521
+ }
522
+ }
523
+ function validateBsDate(year, month, day) {
524
+ if (year == null || month == null || day == null) {
525
+ return {
526
+ ok: false,
527
+ code: "required",
528
+ message: "year, month, and day are required"
529
+ };
530
+ }
531
+ if (typeof year !== "number" || typeof month !== "number" || typeof day !== "number" || !Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
532
+ return {
533
+ ok: false,
534
+ code: "type",
535
+ message: "year, month, and day must be integers"
536
+ };
537
+ }
538
+ if (year < BS_MIN_YEAR || year > BS_MAX_YEAR) {
539
+ return {
540
+ ok: false,
541
+ code: "year_range",
542
+ message: `year must be ${BS_MIN_YEAR}\u2013${BS_MAX_YEAR}`
543
+ };
544
+ }
545
+ if (month < 1 || month > 12) {
546
+ return {
547
+ ok: false,
548
+ code: "month_range",
549
+ message: "month must be 1\u201312"
550
+ };
551
+ }
552
+ if (day < 1 || day > 32) {
553
+ return {
554
+ ok: false,
555
+ code: "day_range",
556
+ message: "day must be 1\u201332"
557
+ };
558
+ }
559
+ if (!isValidBsDate(year, month, day)) {
560
+ return {
561
+ ok: false,
562
+ code: "invalid_date",
563
+ message: `invalid BS date ${year}-${month}-${day}`
564
+ };
565
+ }
566
+ return { ok: true };
567
+ }
568
+ function validateBsDateParts(parts) {
569
+ return validateBsDate(parts.year, parts.month, parts.day);
570
+ }
571
+ function assertValidBsDate(year, month, day) {
572
+ const result = validateBsDate(year, month, day);
573
+ if (!result.ok) {
574
+ if (result.code === "type" || result.code === "required") {
575
+ throw new TypeError(result.message);
576
+ }
577
+ throw new RangeError(result.message);
578
+ }
579
+ }
580
+ function cn(...inputs) {
581
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
582
+ }
583
+ function mergeRefs(...refs) {
584
+ return (value) => {
585
+ for (const ref of refs) {
586
+ if (!ref) continue;
587
+ if (typeof ref === "function") {
588
+ ref(value);
589
+ } else {
590
+ ref.current = value;
591
+ }
592
+ }
593
+ };
594
+ }
595
+ function CalendarIcon({ className }) {
596
+ return /* @__PURE__ */ jsxRuntime.jsxs(
597
+ "svg",
598
+ {
599
+ className,
600
+ width: "16",
601
+ height: "16",
602
+ viewBox: "0 0 24 24",
603
+ fill: "none",
604
+ stroke: "currentColor",
605
+ strokeWidth: "2",
606
+ strokeLinecap: "round",
607
+ strokeLinejoin: "round",
608
+ "aria-hidden": true,
609
+ children: [
610
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
611
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 2v4M8 2v4M3 10h18" })
612
+ ]
613
+ }
614
+ );
615
+ }
616
+ function Chevron({
617
+ dir,
618
+ className
619
+ }) {
620
+ return /* @__PURE__ */ jsxRuntime.jsx(
621
+ "svg",
622
+ {
623
+ className,
624
+ width: "16",
625
+ height: "16",
626
+ viewBox: "0 0 24 24",
627
+ fill: "none",
628
+ stroke: "currentColor",
629
+ strokeWidth: "2",
630
+ strokeLinecap: "round",
631
+ strokeLinejoin: "round",
632
+ "aria-hidden": true,
633
+ children: dir === "left" ? /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 18l-6-6 6-6" }) : dir === "right" ? /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 18l6-6-6-6" }) : /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 9l6 6 6-6" })
634
+ }
635
+ );
636
+ }
637
+ function usePortalReady() {
638
+ const [ready, setReady] = React6__namespace.useState(false);
639
+ React6__namespace.useEffect(() => {
640
+ setReady(true);
641
+ }, []);
642
+ return ready;
643
+ }
644
+ function useFloatingPopover(open, anchorRef, opts) {
645
+ const minWidth = opts?.minWidth ?? 280;
646
+ const estimatedHeight = opts?.estimatedHeight ?? 340;
647
+ const [pos, setPos] = React6__namespace.useState({
648
+ top: 0,
649
+ left: 0,
650
+ width: minWidth
651
+ });
652
+ const updatePosition = React6__namespace.useCallback(() => {
653
+ const el = anchorRef.current;
654
+ if (!el) return;
655
+ const rect = el.getBoundingClientRect();
656
+ const width = Math.max(minWidth, rect.width);
657
+ let left = rect.left;
658
+ if (left + width > window.innerWidth - 8) {
659
+ left = Math.max(8, window.innerWidth - width - 8);
660
+ }
661
+ const below = rect.bottom + 6;
662
+ const top = below + estimatedHeight > window.innerHeight && rect.top > estimatedHeight ? rect.top - estimatedHeight - 6 : below;
663
+ setPos({ top, left, width });
664
+ }, [anchorRef, minWidth, estimatedHeight]);
665
+ React6__namespace.useEffect(() => {
666
+ if (!open) return;
667
+ updatePosition();
668
+ const onScroll = () => updatePosition();
669
+ const onResize = () => updatePosition();
670
+ window.addEventListener("scroll", onScroll, true);
671
+ window.addEventListener("resize", onResize);
672
+ return () => {
673
+ window.removeEventListener("scroll", onScroll, true);
674
+ window.removeEventListener("resize", onResize);
675
+ };
676
+ }, [open, updatePosition]);
677
+ return { pos, updatePosition };
678
+ }
679
+ function useDismissOnOutside(open, onClose, refs) {
680
+ const refsRef = React6__namespace.useRef(refs);
681
+ refsRef.current = refs;
682
+ React6__namespace.useEffect(() => {
683
+ if (!open) return;
684
+ const onKey = (e) => {
685
+ if (e.key === "Escape") onClose();
686
+ };
687
+ const onPointer = (e) => {
688
+ const t = e.target;
689
+ for (const ref of refsRef.current) {
690
+ if (ref.current?.contains(t)) return;
691
+ }
692
+ onClose();
693
+ };
694
+ document.addEventListener("keydown", onKey);
695
+ document.addEventListener("mousedown", onPointer);
696
+ return () => {
697
+ document.removeEventListener("keydown", onKey);
698
+ document.removeEventListener("mousedown", onPointer);
699
+ };
700
+ }, [open, onClose]);
701
+ }
702
+ function CalendarMonth({
703
+ year,
704
+ month,
705
+ locale,
706
+ isDisabledDay,
707
+ getModifiers,
708
+ onDayClick,
709
+ onDayHover,
710
+ showHeader = true,
711
+ onPrevMonth,
712
+ onNextMonth,
713
+ canPrevMonth = true,
714
+ canNextMonth = true,
715
+ onMonthTitleClick,
716
+ onYearTitleClick
717
+ }) {
718
+ const weekdays = getWeekdayNames(locale);
719
+ const daysInMonth = getDaysInBsMonth(year, month);
720
+ const startWeekday = getBsWeekday(year, month, 1);
721
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-month", children: [
722
+ showHeader ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-header", children: [
723
+ onPrevMonth ? /* @__PURE__ */ jsxRuntime.jsx(
724
+ "button",
725
+ {
726
+ type: "button",
727
+ className: "itzsa-ndp-nav-btn",
728
+ disabled: !canPrevMonth,
729
+ "aria-label": "Previous month",
730
+ onClick: onPrevMonth,
731
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "left" })
732
+ }
733
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-nav-spacer" }),
734
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-header-title", children: [
735
+ onMonthTitleClick ? /* @__PURE__ */ jsxRuntime.jsx(
736
+ "button",
737
+ {
738
+ type: "button",
739
+ className: "itzsa-ndp-title-btn",
740
+ onClick: onMonthTitleClick,
741
+ children: getMonthName(month, locale)
742
+ }
743
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-title-static", children: getMonthName(month, locale) }),
744
+ onYearTitleClick ? /* @__PURE__ */ jsxRuntime.jsx(
745
+ "button",
746
+ {
747
+ type: "button",
748
+ className: "itzsa-ndp-title-btn",
749
+ onClick: onYearTitleClick,
750
+ children: localizeDigits(year, locale)
751
+ }
752
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-title-static", children: localizeDigits(year, locale) })
753
+ ] }),
754
+ onNextMonth ? /* @__PURE__ */ jsxRuntime.jsx(
755
+ "button",
756
+ {
757
+ type: "button",
758
+ className: "itzsa-ndp-nav-btn",
759
+ disabled: !canNextMonth,
760
+ "aria-label": "Next month",
761
+ onClick: onNextMonth,
762
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "right" })
763
+ }
764
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-nav-spacer" })
765
+ ] }) : null,
766
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "itzsa-ndp-weekdays", children: weekdays.map((w) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-weekday", children: w }, w)) }),
767
+ /* @__PURE__ */ jsxRuntime.jsxs(
768
+ "div",
769
+ {
770
+ className: "itzsa-ndp-days",
771
+ role: "grid",
772
+ onMouseLeave: () => onDayHover?.(null),
773
+ children: [
774
+ Array.from({ length: startWeekday }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-day is-empty" }, `e-${i}`)),
775
+ Array.from({ length: daysInMonth }, (_, i) => {
776
+ const day = i + 1;
777
+ const parts = { year, month, day };
778
+ const disabledDay = isDisabledDay(parts);
779
+ const mod = getModifiers(parts);
780
+ return /* @__PURE__ */ jsxRuntime.jsx(
781
+ "button",
782
+ {
783
+ type: "button",
784
+ role: "gridcell",
785
+ disabled: disabledDay || mod.disabled,
786
+ "aria-selected": mod.selected || mod.rangeStart || mod.rangeEnd,
787
+ className: cn(
788
+ "itzsa-ndp-day",
789
+ mod.selected && "is-selected",
790
+ mod.today && "is-today",
791
+ (disabledDay || mod.disabled) && "is-disabled",
792
+ mod.rangeStart && "is-range-start",
793
+ mod.rangeEnd && "is-range-end",
794
+ mod.inRange && "is-in-range",
795
+ mod.rangePreview && "is-range-preview"
796
+ ),
797
+ onClick: () => onDayClick(parts),
798
+ onMouseEnter: () => onDayHover?.(parts),
799
+ children: localizeDigits(day, locale)
800
+ },
801
+ day
802
+ );
803
+ })
804
+ ]
805
+ }
806
+ )
807
+ ] });
808
+ }
809
+ function SingleCalendarPanel({
810
+ locale,
811
+ view,
812
+ onViewChange,
813
+ selected,
814
+ today,
815
+ minYear = BS_MIN_YEAR,
816
+ maxYear = BS_MAX_YEAR,
817
+ isDisabledDay,
818
+ onDayClick,
819
+ onToday,
820
+ onClear,
821
+ showClear = false
822
+ }) {
823
+ const [mode, setMode] = React6__namespace.useState("days");
824
+ const yearStart = Math.floor(view.year / 12) * 12;
825
+ const years = Array.from({ length: 12 }, (_, i) => yearStart + i).filter(
826
+ (y) => y >= minYear && y <= maxYear
827
+ );
828
+ const canPrevMonth = (() => {
829
+ try {
830
+ return addBsMonths(view.year, view.month, -1).year >= minYear;
831
+ } catch {
832
+ return false;
833
+ }
834
+ })();
835
+ const canNextMonth = (() => {
836
+ try {
837
+ return addBsMonths(view.year, view.month, 1).year <= maxYear;
838
+ } catch {
839
+ return false;
840
+ }
841
+ })();
842
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-panel", children: [
843
+ mode === "days" ? /* @__PURE__ */ jsxRuntime.jsx(
844
+ CalendarMonth,
845
+ {
846
+ year: view.year,
847
+ month: view.month,
848
+ locale,
849
+ isDisabledDay,
850
+ getModifiers: (parts) => ({
851
+ selected: selected != null && compareDateParts(selected, parts) === 0,
852
+ today: compareDateParts(today, parts) === 0
853
+ }),
854
+ onDayClick,
855
+ canPrevMonth,
856
+ canNextMonth,
857
+ onPrevMonth: () => {
858
+ try {
859
+ onViewChange(addBsMonths(view.year, view.month, -1));
860
+ } catch {
861
+ }
862
+ },
863
+ onNextMonth: () => {
864
+ try {
865
+ onViewChange(addBsMonths(view.year, view.month, 1));
866
+ } catch {
867
+ }
868
+ },
869
+ onMonthTitleClick: () => setMode("months"),
870
+ onYearTitleClick: () => setMode("years")
871
+ }
872
+ ) : null,
873
+ mode === "months" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
874
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-header", children: [
875
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-nav-spacer" }),
876
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "itzsa-ndp-header-title", children: /* @__PURE__ */ jsxRuntime.jsx(
877
+ "button",
878
+ {
879
+ type: "button",
880
+ className: "itzsa-ndp-title-btn",
881
+ onClick: () => setMode("years"),
882
+ children: localizeDigits(view.year, locale)
883
+ }
884
+ ) }),
885
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "itzsa-ndp-nav-spacer" })
886
+ ] }),
887
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "itzsa-ndp-grid-months", children: Array.from({ length: 12 }, (_, i) => {
888
+ const month = i + 1;
889
+ return /* @__PURE__ */ jsxRuntime.jsx(
890
+ "button",
891
+ {
892
+ type: "button",
893
+ className: cn(
894
+ "itzsa-ndp-chip",
895
+ view.month === month && "is-active"
896
+ ),
897
+ onClick: () => {
898
+ onViewChange({ year: view.year, month });
899
+ setMode("days");
900
+ },
901
+ children: getMonthName(month, locale)
902
+ },
903
+ month
904
+ );
905
+ }) })
906
+ ] }) : null,
907
+ mode === "years" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-grid-years", children: [
908
+ /* @__PURE__ */ jsxRuntime.jsx(
909
+ "button",
910
+ {
911
+ type: "button",
912
+ className: "itzsa-ndp-nav-btn itzsa-ndp-year-shift",
913
+ disabled: yearStart - 12 < minYear,
914
+ "aria-label": "Previous years",
915
+ onClick: () => onViewChange({
916
+ ...view,
917
+ year: Math.max(minYear, yearStart - 12)
918
+ }),
919
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "left" })
920
+ }
921
+ ),
922
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "itzsa-ndp-year-list", children: years.map((y) => /* @__PURE__ */ jsxRuntime.jsx(
923
+ "button",
924
+ {
925
+ type: "button",
926
+ className: cn("itzsa-ndp-chip", view.year === y && "is-active"),
927
+ onClick: () => {
928
+ onViewChange({ ...view, year: y });
929
+ setMode("months");
930
+ },
931
+ children: localizeDigits(y, locale)
932
+ },
933
+ y
934
+ )) }),
935
+ /* @__PURE__ */ jsxRuntime.jsx(
936
+ "button",
937
+ {
938
+ type: "button",
939
+ className: "itzsa-ndp-nav-btn itzsa-ndp-year-shift",
940
+ disabled: yearStart + 12 > maxYear,
941
+ "aria-label": "Next years",
942
+ onClick: () => onViewChange({
943
+ ...view,
944
+ year: Math.min(maxYear, yearStart + 12)
945
+ }),
946
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "right" })
947
+ }
948
+ )
949
+ ] }) : null,
950
+ (onToday || onClear) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-footer", children: [
951
+ onToday ? /* @__PURE__ */ jsxRuntime.jsx(
952
+ "button",
953
+ {
954
+ type: "button",
955
+ className: "itzsa-ndp-footer-btn",
956
+ disabled: isDisabledDay(today),
957
+ onClick: onToday,
958
+ children: locale === "ne" ? "\u0906\u091C" : "Today"
959
+ }
960
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
961
+ showClear && onClear ? /* @__PURE__ */ jsxRuntime.jsx(
962
+ "button",
963
+ {
964
+ type: "button",
965
+ className: "itzsa-ndp-footer-btn",
966
+ onClick: onClear,
967
+ children: locale === "ne" ? "\u0916\u093E\u0932\u0940" : "Clear"
968
+ }
969
+ ) : null
970
+ ] })
971
+ ] });
972
+ }
973
+ function createIsDisabledDay(opts) {
974
+ return (parts) => {
975
+ if (parts.year < opts.minYear || parts.year > opts.maxYear) return true;
976
+ if (opts.minParts && compareDateParts(parts, opts.minParts) < 0) return true;
977
+ if (opts.maxParts && compareDateParts(parts, opts.maxParts) > 0) return true;
978
+ return false;
979
+ };
980
+ }
981
+
982
+ // src/styling.ts
983
+ var VAR_MAP = {
984
+ accent: "--ndp-accent",
985
+ accentForeground: "--ndp-accent-fg",
986
+ background: "--ndp-bg",
987
+ foreground: "--ndp-fg",
988
+ muted: "--ndp-muted",
989
+ border: "--ndp-border",
990
+ surface: "--ndp-surface",
991
+ radius: "--ndp-radius",
992
+ font: "--ndp-font"
993
+ };
994
+ function mergePickerStyle(vars, style) {
995
+ if (!vars && !style) return style;
996
+ const next = { ...style };
997
+ if (vars) {
998
+ for (const key of Object.keys(vars)) {
999
+ const value = vars[key];
1000
+ if (value == null || value === "") continue;
1001
+ next[VAR_MAP[key]] = value;
1002
+ }
1003
+ }
1004
+ return next;
1005
+ }
1006
+ function parseBound(value) {
1007
+ if (!value) return null;
1008
+ return parseDateString(value);
1009
+ }
1010
+ var NepaliDatePicker = React6__namespace.forwardRef(function NepaliDatePicker2({
1011
+ value: valueProp,
1012
+ defaultValue = "",
1013
+ onChange,
1014
+ onSelect,
1015
+ locale = "ne",
1016
+ valueLocale,
1017
+ minDate,
1018
+ maxDate,
1019
+ minYear = BS_MIN_YEAR,
1020
+ maxYear = BS_MAX_YEAR,
1021
+ closeOnSelect = true,
1022
+ todayIfEmpty = true,
1023
+ placeholder,
1024
+ disabled = false,
1025
+ readOnly = false,
1026
+ id,
1027
+ name,
1028
+ required,
1029
+ className,
1030
+ inputClassName,
1031
+ popoverClassName,
1032
+ classNames,
1033
+ vars,
1034
+ style,
1035
+ popoverStyle,
1036
+ "aria-label": ariaLabel,
1037
+ "aria-labelledby": ariaLabelledBy
1038
+ }, forwardedRef) {
1039
+ const displayLocale = valueLocale ?? locale;
1040
+ const rootStyle = mergePickerStyle(vars, style);
1041
+ const panelStyle = mergePickerStyle(vars, popoverStyle);
1042
+ const isControlled = valueProp !== void 0;
1043
+ const [uncontrolled, setUncontrolled] = React6__namespace.useState(defaultValue);
1044
+ const value = isControlled ? valueProp ?? "" : uncontrolled;
1045
+ const minParts = React6__namespace.useMemo(() => parseBound(minDate), [minDate]);
1046
+ const maxParts = React6__namespace.useMemo(() => parseBound(maxDate), [maxDate]);
1047
+ const selected = React6__namespace.useMemo(() => parseDateString(value), [value]);
1048
+ const today = React6__namespace.useMemo(() => todayBs(), []);
1049
+ const initialView = React6__namespace.useMemo(() => {
1050
+ if (selected) return selected;
1051
+ if (todayIfEmpty) return clampBsDate(today, minParts, maxParts);
1052
+ return {
1053
+ year: Math.min(Math.max(2080, minYear), maxYear),
1054
+ month: 1,
1055
+ day: 1
1056
+ };
1057
+ }, [selected, todayIfEmpty, today, minParts, maxParts, minYear, maxYear]);
1058
+ const [open, setOpen] = React6__namespace.useState(false);
1059
+ const [view, setView] = React6__namespace.useState({
1060
+ year: initialView.year,
1061
+ month: initialView.month
1062
+ });
1063
+ const rootRef = React6__namespace.useRef(null);
1064
+ const inputRef = React6__namespace.useRef(null);
1065
+ const popoverRef = React6__namespace.useRef(null);
1066
+ const portalReady = usePortalReady();
1067
+ const { pos } = useFloatingPopover(open, rootRef, {
1068
+ minWidth: 288,
1069
+ estimatedHeight: 360
1070
+ });
1071
+ React6__namespace.useImperativeHandle(
1072
+ forwardedRef,
1073
+ () => inputRef.current
1074
+ );
1075
+ React6__namespace.useEffect(() => {
1076
+ if (!open) return;
1077
+ const next = selected ?? (todayIfEmpty ? today : initialView);
1078
+ setView({ year: next.year, month: next.month });
1079
+ }, [open]);
1080
+ const close = React6__namespace.useCallback(() => setOpen(false), []);
1081
+ useDismissOnOutside(open, close, [rootRef, popoverRef]);
1082
+ const setValue = React6__namespace.useCallback(
1083
+ (next) => {
1084
+ if (!isControlled) setUncontrolled(next);
1085
+ onChange?.(next);
1086
+ },
1087
+ [isControlled, onChange]
1088
+ );
1089
+ const isDisabledDay = React6__namespace.useMemo(
1090
+ () => createIsDisabledDay({ minYear, maxYear, minParts, maxParts }),
1091
+ [minYear, maxYear, minParts, maxParts]
1092
+ );
1093
+ const pickParts = (parts) => {
1094
+ if (isDisabledDay(parts)) return;
1095
+ const str = toDateString(parts);
1096
+ setValue(str);
1097
+ onSelect?.(str);
1098
+ if (closeOnSelect) setOpen(false);
1099
+ };
1100
+ const displayValue = selected ? formatBsLabel(selected, displayLocale) : "";
1101
+ const popover = open && portalReady ? reactDom.createPortal(
1102
+ /* @__PURE__ */ jsxRuntime.jsx(
1103
+ "div",
1104
+ {
1105
+ ref: popoverRef,
1106
+ className: cn(
1107
+ "itzsa-ndp-popover",
1108
+ popoverClassName,
1109
+ classNames?.popover
1110
+ ),
1111
+ "data-locale": locale,
1112
+ style: {
1113
+ position: "fixed",
1114
+ top: pos.top,
1115
+ left: pos.left,
1116
+ width: pos.width,
1117
+ zIndex: 50,
1118
+ ...panelStyle
1119
+ },
1120
+ role: "dialog",
1121
+ "aria-modal": "false",
1122
+ "aria-label": "Nepali calendar",
1123
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1124
+ SingleCalendarPanel,
1125
+ {
1126
+ locale,
1127
+ view,
1128
+ onViewChange: setView,
1129
+ selected,
1130
+ today,
1131
+ minYear,
1132
+ maxYear,
1133
+ isDisabledDay,
1134
+ onDayClick: pickParts,
1135
+ showClear: Boolean(value),
1136
+ onToday: () => {
1137
+ const clamped = clampBsDate(today, minParts, maxParts);
1138
+ setView({ year: clamped.year, month: clamped.month });
1139
+ pickParts(clamped);
1140
+ },
1141
+ onClear: () => {
1142
+ setValue("");
1143
+ onSelect?.("");
1144
+ }
1145
+ }
1146
+ )
1147
+ }
1148
+ ),
1149
+ document.body
1150
+ ) : null;
1151
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1152
+ "div",
1153
+ {
1154
+ ref: rootRef,
1155
+ className: cn("itzsa-ndp", className, classNames?.root),
1156
+ style: rootStyle,
1157
+ "data-locale": locale,
1158
+ "data-disabled": disabled ? "" : void 0,
1159
+ "data-open": open ? "" : void 0,
1160
+ children: [
1161
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("itzsa-ndp-field", classNames?.field), children: [
1162
+ /* @__PURE__ */ jsxRuntime.jsx(
1163
+ "input",
1164
+ {
1165
+ ref: inputRef,
1166
+ id,
1167
+ name,
1168
+ required,
1169
+ disabled,
1170
+ readOnly: true,
1171
+ placeholder: placeholder ?? (displayLocale === "ne" ? "\u092E\u093F\u0924\u093F \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : "Select date"),
1172
+ value: displayValue,
1173
+ "aria-label": ariaLabel,
1174
+ "aria-labelledby": ariaLabelledBy,
1175
+ "aria-expanded": open,
1176
+ "aria-haspopup": "dialog",
1177
+ className: cn("itzsa-ndp-input", inputClassName, classNames?.input),
1178
+ onClick: () => {
1179
+ if (!disabled && !readOnly) setOpen(true);
1180
+ },
1181
+ onFocus: () => {
1182
+ if (!disabled && !readOnly) setOpen(true);
1183
+ },
1184
+ onKeyDown: (e) => {
1185
+ if (disabled || readOnly) return;
1186
+ if (e.key === "Enter" || e.key === " ") {
1187
+ e.preventDefault();
1188
+ setOpen((o) => !o);
1189
+ }
1190
+ }
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ jsxRuntime.jsx(
1194
+ "button",
1195
+ {
1196
+ type: "button",
1197
+ className: cn("itzsa-ndp-trigger", classNames?.trigger),
1198
+ tabIndex: -1,
1199
+ disabled: disabled || readOnly,
1200
+ "aria-label": "Open calendar",
1201
+ onClick: () => {
1202
+ if (!disabled && !readOnly) setOpen((o) => !o);
1203
+ },
1204
+ children: /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {})
1205
+ }
1206
+ )
1207
+ ] }),
1208
+ popover
1209
+ ]
1210
+ }
1211
+ );
1212
+ });
1213
+ function parseBound2(value) {
1214
+ if (!value) return null;
1215
+ return parseDateString(value);
1216
+ }
1217
+ var EditableNepaliDatePicker = React6__namespace.forwardRef(function EditableNepaliDatePicker2({
1218
+ value: valueProp,
1219
+ defaultValue = "",
1220
+ onChange,
1221
+ onSelect,
1222
+ locale = "en",
1223
+ minDate,
1224
+ maxDate,
1225
+ minYear = BS_MIN_YEAR,
1226
+ maxYear = BS_MAX_YEAR,
1227
+ closeOnSelect = true,
1228
+ placeholder = "YYYY-MM-DD",
1229
+ disabled = false,
1230
+ readOnly = false,
1231
+ id,
1232
+ name,
1233
+ required,
1234
+ className,
1235
+ inputClassName,
1236
+ popoverClassName,
1237
+ classNames,
1238
+ vars,
1239
+ style,
1240
+ popoverStyle,
1241
+ "aria-label": ariaLabel,
1242
+ "aria-labelledby": ariaLabelledBy
1243
+ }, forwardedRef) {
1244
+ const isControlled = valueProp !== void 0;
1245
+ const rootStyle = mergePickerStyle(vars, style);
1246
+ const panelStyle = mergePickerStyle(vars, popoverStyle);
1247
+ const [uncontrolled, setUncontrolled] = React6__namespace.useState(defaultValue);
1248
+ const value = isControlled ? valueProp ?? "" : uncontrolled;
1249
+ const [localValue, setLocalValue] = React6__namespace.useState(value);
1250
+ const cursorPosRef = React6__namespace.useRef(null);
1251
+ React6__namespace.useEffect(() => {
1252
+ setLocalValue(value);
1253
+ }, [value]);
1254
+ const minParts = React6__namespace.useMemo(() => parseBound2(minDate), [minDate]);
1255
+ const maxParts = React6__namespace.useMemo(() => parseBound2(maxDate), [maxDate]);
1256
+ const selected = React6__namespace.useMemo(
1257
+ () => parseDateString(localValue.replace(/\//g, "-")),
1258
+ [localValue]
1259
+ );
1260
+ const today = React6__namespace.useMemo(() => todayBs(), []);
1261
+ const [open, setOpen] = React6__namespace.useState(false);
1262
+ const [view, setView] = React6__namespace.useState(() => {
1263
+ const t = todayBs();
1264
+ return { year: t.year, month: t.month };
1265
+ });
1266
+ const rootRef = React6__namespace.useRef(null);
1267
+ const inputRef = React6__namespace.useRef(null);
1268
+ const popoverRef = React6__namespace.useRef(null);
1269
+ const portalReady = usePortalReady();
1270
+ const { pos } = useFloatingPopover(open, rootRef, {
1271
+ minWidth: 288,
1272
+ estimatedHeight: 360
1273
+ });
1274
+ React6__namespace.useLayoutEffect(() => {
1275
+ if (cursorPosRef.current !== null && inputRef.current) {
1276
+ inputRef.current.setSelectionRange(
1277
+ cursorPosRef.current,
1278
+ cursorPosRef.current
1279
+ );
1280
+ cursorPosRef.current = null;
1281
+ }
1282
+ });
1283
+ React6__namespace.useEffect(() => {
1284
+ if (!open) return;
1285
+ const next = selected ?? clampBsDate(today, minParts, maxParts);
1286
+ setView({ year: next.year, month: next.month });
1287
+ }, [open]);
1288
+ const close = React6__namespace.useCallback(() => setOpen(false), []);
1289
+ useDismissOnOutside(open, close, [rootRef, popoverRef]);
1290
+ const commit = React6__namespace.useCallback(
1291
+ (next) => {
1292
+ setLocalValue(next);
1293
+ if (!isControlled) setUncontrolled(next);
1294
+ onChange?.(next);
1295
+ },
1296
+ [isControlled, onChange]
1297
+ );
1298
+ const isDisabledDay = React6__namespace.useMemo(
1299
+ () => createIsDisabledDay({ minYear, maxYear, minParts, maxParts }),
1300
+ [minYear, maxYear, minParts, maxParts]
1301
+ );
1302
+ const handleType = (e) => {
1303
+ const input = e.target;
1304
+ const selStart = input.selectionStart ?? 0;
1305
+ const raw = input.value;
1306
+ const formatted = formatTypedBsDate(raw);
1307
+ const digitsBeforeCursor = raw.slice(0, selStart).replace(/\D/g, "").length;
1308
+ let newPos = digitsBeforeCursor;
1309
+ if (digitsBeforeCursor > 4) newPos += 1;
1310
+ if (digitsBeforeCursor > 6) newPos += 1;
1311
+ cursorPosRef.current = Math.min(newPos, formatted.length);
1312
+ commit(formatted);
1313
+ };
1314
+ const pickParts = (parts) => {
1315
+ if (isDisabledDay(parts)) return;
1316
+ const str = toDateString(parts);
1317
+ commit(str);
1318
+ onSelect?.(str);
1319
+ if (closeOnSelect) setOpen(false);
1320
+ };
1321
+ const popover = open && portalReady ? reactDom.createPortal(
1322
+ /* @__PURE__ */ jsxRuntime.jsx(
1323
+ "div",
1324
+ {
1325
+ ref: popoverRef,
1326
+ className: cn(
1327
+ "itzsa-ndp-popover",
1328
+ popoverClassName,
1329
+ classNames?.popover
1330
+ ),
1331
+ "data-locale": locale,
1332
+ style: {
1333
+ position: "fixed",
1334
+ top: pos.top,
1335
+ left: pos.left,
1336
+ width: pos.width,
1337
+ zIndex: 50,
1338
+ ...panelStyle
1339
+ },
1340
+ role: "dialog",
1341
+ "aria-modal": "false",
1342
+ "aria-label": "Nepali calendar",
1343
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1344
+ SingleCalendarPanel,
1345
+ {
1346
+ locale,
1347
+ view,
1348
+ onViewChange: setView,
1349
+ selected,
1350
+ today,
1351
+ minYear,
1352
+ maxYear,
1353
+ isDisabledDay,
1354
+ onDayClick: pickParts,
1355
+ showClear: Boolean(localValue),
1356
+ onToday: () => {
1357
+ const clamped = clampBsDate(today, minParts, maxParts);
1358
+ setView({ year: clamped.year, month: clamped.month });
1359
+ pickParts(clamped);
1360
+ },
1361
+ onClear: () => {
1362
+ commit("");
1363
+ onSelect?.("");
1364
+ }
1365
+ }
1366
+ )
1367
+ }
1368
+ ),
1369
+ document.body
1370
+ ) : null;
1371
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1372
+ "div",
1373
+ {
1374
+ ref: rootRef,
1375
+ className: cn(
1376
+ "itzsa-ndp itzsa-ndp-editable",
1377
+ className,
1378
+ classNames?.root
1379
+ ),
1380
+ style: rootStyle,
1381
+ "data-locale": locale,
1382
+ "data-disabled": disabled ? "" : void 0,
1383
+ "data-open": open ? "" : void 0,
1384
+ children: [
1385
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("itzsa-ndp-field", classNames?.field), children: [
1386
+ /* @__PURE__ */ jsxRuntime.jsx(
1387
+ "input",
1388
+ {
1389
+ ref: mergeRefs(forwardedRef, inputRef),
1390
+ id,
1391
+ name,
1392
+ required,
1393
+ disabled,
1394
+ readOnly,
1395
+ inputMode: "numeric",
1396
+ autoComplete: "off",
1397
+ spellCheck: false,
1398
+ placeholder,
1399
+ value: localValue,
1400
+ "aria-label": ariaLabel,
1401
+ "aria-labelledby": ariaLabelledBy,
1402
+ "aria-expanded": open,
1403
+ "aria-haspopup": "dialog",
1404
+ className: cn(
1405
+ "itzsa-ndp-input itzsa-ndp-input-editable",
1406
+ inputClassName,
1407
+ classNames?.input
1408
+ ),
1409
+ onChange: readOnly ? void 0 : handleType,
1410
+ onKeyDown: (e) => {
1411
+ if (disabled || readOnly) return;
1412
+ if (e.key === "ArrowDown" && (e.altKey || e.metaKey)) {
1413
+ e.preventDefault();
1414
+ setOpen(true);
1415
+ }
1416
+ }
1417
+ }
1418
+ ),
1419
+ /* @__PURE__ */ jsxRuntime.jsx(
1420
+ "button",
1421
+ {
1422
+ type: "button",
1423
+ className: cn("itzsa-ndp-trigger", classNames?.trigger),
1424
+ tabIndex: -1,
1425
+ disabled: disabled || readOnly,
1426
+ "aria-label": "Open calendar",
1427
+ onClick: () => {
1428
+ if (!disabled && !readOnly) setOpen((o) => !o);
1429
+ },
1430
+ children: /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {})
1431
+ }
1432
+ )
1433
+ ] }),
1434
+ popover
1435
+ ]
1436
+ }
1437
+ );
1438
+ });
1439
+ function parseBound3(value) {
1440
+ if (!value) return null;
1441
+ return parseDateString(value);
1442
+ }
1443
+ function orderedRange(a, b) {
1444
+ return compareDateParts(a, b) <= 0 ? { from: a, to: b } : { from: b, to: a };
1445
+ }
1446
+ function inInclusiveRange(day, from, to) {
1447
+ return compareDateParts(day, from) >= 0 && compareDateParts(day, to) <= 0;
1448
+ }
1449
+ function NepaliDateRangePicker({
1450
+ value: valueProp,
1451
+ defaultValue = {},
1452
+ onChange,
1453
+ locale = "ne",
1454
+ valueLocale,
1455
+ minDate,
1456
+ maxDate,
1457
+ minYear = BS_MIN_YEAR,
1458
+ maxYear = BS_MAX_YEAR,
1459
+ numberOfMonths = 2,
1460
+ closeOnSelect = true,
1461
+ placeholder,
1462
+ disabled = false,
1463
+ className,
1464
+ triggerClassName,
1465
+ popoverClassName,
1466
+ classNames,
1467
+ vars,
1468
+ style,
1469
+ popoverStyle,
1470
+ id,
1471
+ "aria-label": ariaLabel
1472
+ }) {
1473
+ const displayLocale = valueLocale ?? locale;
1474
+ const rootStyle = mergePickerStyle(vars, style);
1475
+ const panelStyle = mergePickerStyle(vars, popoverStyle);
1476
+ const isControlled = valueProp !== void 0;
1477
+ const [uncontrolled, setUncontrolled] = React6__namespace.useState(defaultValue);
1478
+ const value = isControlled ? valueProp ?? {} : uncontrolled;
1479
+ const minParts = React6__namespace.useMemo(() => parseBound3(minDate), [minDate]);
1480
+ const maxParts = React6__namespace.useMemo(() => parseBound3(maxDate), [maxDate]);
1481
+ const fromParts = React6__namespace.useMemo(
1482
+ () => value.from ? parseDateString(value.from) : null,
1483
+ [value.from]
1484
+ );
1485
+ const toParts = React6__namespace.useMemo(
1486
+ () => value.to ? parseDateString(value.to) : null,
1487
+ [value.to]
1488
+ );
1489
+ const today = React6__namespace.useMemo(() => todayBs(), []);
1490
+ const [open, setOpen] = React6__namespace.useState(false);
1491
+ const [hover, setHover] = React6__namespace.useState(null);
1492
+ const [anchor, setAnchor] = React6__namespace.useState(null);
1493
+ const [leftView, setLeftView] = React6__namespace.useState(() => {
1494
+ const t = todayBs();
1495
+ return { year: t.year, month: t.month };
1496
+ });
1497
+ const rightView = React6__namespace.useMemo(() => {
1498
+ try {
1499
+ return addBsMonths(leftView.year, leftView.month, 1);
1500
+ } catch {
1501
+ return leftView;
1502
+ }
1503
+ }, [leftView]);
1504
+ const rootRef = React6__namespace.useRef(null);
1505
+ const popoverRef = React6__namespace.useRef(null);
1506
+ const portalReady = usePortalReady();
1507
+ const dual = numberOfMonths === 2;
1508
+ const { pos } = useFloatingPopover(open, rootRef, {
1509
+ minWidth: dual ? 560 : 288,
1510
+ estimatedHeight: 380
1511
+ });
1512
+ React6__namespace.useEffect(() => {
1513
+ if (!open) return;
1514
+ const base = fromParts ?? clampBsDate(today, minParts, maxParts);
1515
+ setLeftView({ year: base.year, month: base.month });
1516
+ setAnchor(fromParts && !toParts ? fromParts : null);
1517
+ setHover(null);
1518
+ }, [open]);
1519
+ const close = React6__namespace.useCallback(() => setOpen(false), []);
1520
+ useDismissOnOutside(open, close, [rootRef, popoverRef]);
1521
+ const commit = React6__namespace.useCallback(
1522
+ (next) => {
1523
+ if (!isControlled) setUncontrolled(next);
1524
+ onChange?.(next);
1525
+ },
1526
+ [isControlled, onChange]
1527
+ );
1528
+ const isDisabledDay = React6__namespace.useMemo(
1529
+ () => createIsDisabledDay({ minYear, maxYear, minParts, maxParts }),
1530
+ [minYear, maxYear, minParts, maxParts]
1531
+ );
1532
+ const previewTo = anchor && hover ? orderedRange(anchor, hover) : null;
1533
+ const getModifiers = (parts) => {
1534
+ const start = fromParts;
1535
+ const end = toParts;
1536
+ const preview = !end && previewTo ? previewTo : null;
1537
+ const solidInRange = start && end ? inInclusiveRange(parts, start, end) && compareDateParts(parts, start) !== 0 && compareDateParts(parts, end) !== 0 : false;
1538
+ const previewInRange = preview != null && inInclusiveRange(parts, preview.from, preview.to) && compareDateParts(parts, preview.from) !== 0 && compareDateParts(parts, preview.to) !== 0;
1539
+ return {
1540
+ today: compareDateParts(today, parts) === 0,
1541
+ rangeStart: Boolean(
1542
+ start && compareDateParts(parts, start) === 0 || preview && compareDateParts(parts, preview.from) === 0
1543
+ ),
1544
+ rangeEnd: Boolean(
1545
+ end && compareDateParts(parts, end) === 0 || preview && compareDateParts(parts, preview.to) === 0 && compareDateParts(preview.from, preview.to) !== 0
1546
+ ),
1547
+ inRange: Boolean(solidInRange || previewInRange),
1548
+ rangePreview: Boolean(previewInRange),
1549
+ selected: Boolean(
1550
+ start && compareDateParts(parts, start) === 0 || end && compareDateParts(parts, end) === 0
1551
+ )
1552
+ };
1553
+ };
1554
+ const onDayClick = (parts) => {
1555
+ if (isDisabledDay(parts)) return;
1556
+ if (!anchor) {
1557
+ setAnchor(parts);
1558
+ commit({ from: toDateString(parts), to: void 0 });
1559
+ return;
1560
+ }
1561
+ const { from, to } = orderedRange(anchor, parts);
1562
+ commit({ from: toDateString(from), to: toDateString(to) });
1563
+ setAnchor(null);
1564
+ setHover(null);
1565
+ if (closeOnSelect) setOpen(false);
1566
+ };
1567
+ const shiftLeft = (delta) => {
1568
+ try {
1569
+ setLeftView(addBsMonths(leftView.year, leftView.month, delta));
1570
+ } catch {
1571
+ }
1572
+ };
1573
+ const canPrev = (() => {
1574
+ try {
1575
+ return addBsMonths(leftView.year, leftView.month, -1).year >= minYear;
1576
+ } catch {
1577
+ return false;
1578
+ }
1579
+ })();
1580
+ const canNext = (() => {
1581
+ try {
1582
+ const step = dual ? 1 : 1;
1583
+ const next = addBsMonths(
1584
+ dual ? rightView.year : leftView.year,
1585
+ dual ? rightView.month : leftView.month,
1586
+ step
1587
+ );
1588
+ return next.year <= maxYear;
1589
+ } catch {
1590
+ return false;
1591
+ }
1592
+ })();
1593
+ const nights = fromParts && toParts ? Math.max(0, diffBsDays(fromParts, toParts)) : null;
1594
+ const label = (() => {
1595
+ if (fromParts && toParts) {
1596
+ return `${formatBsLabel(fromParts, displayLocale)} \u2013 ${formatBsLabel(toParts, displayLocale)}`;
1597
+ }
1598
+ if (fromParts) {
1599
+ return `${formatBsLabel(fromParts, displayLocale)} \u2013 \u2026`;
1600
+ }
1601
+ return placeholder ?? (displayLocale === "ne" ? "\u092E\u093F\u0924\u093F \u0926\u093E\u092F\u0930\u093E \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : "Pick a date range");
1602
+ })();
1603
+ const popover = open && portalReady ? reactDom.createPortal(
1604
+ /* @__PURE__ */ jsxRuntime.jsxs(
1605
+ "div",
1606
+ {
1607
+ ref: popoverRef,
1608
+ className: cn(
1609
+ "itzsa-ndp-popover itzsa-ndp-popover-range",
1610
+ dual && "is-dual",
1611
+ popoverClassName,
1612
+ classNames?.popover
1613
+ ),
1614
+ "data-locale": locale,
1615
+ style: {
1616
+ position: "fixed",
1617
+ top: pos.top,
1618
+ left: pos.left,
1619
+ width: Math.max(pos.width, dual ? 560 : 288),
1620
+ zIndex: 50,
1621
+ ...panelStyle
1622
+ },
1623
+ role: "dialog",
1624
+ "aria-modal": "false",
1625
+ "aria-label": "Nepali date range",
1626
+ children: [
1627
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-range-toolbar", children: [
1628
+ /* @__PURE__ */ jsxRuntime.jsx(
1629
+ "button",
1630
+ {
1631
+ type: "button",
1632
+ className: "itzsa-ndp-nav-btn",
1633
+ disabled: !canPrev,
1634
+ "aria-label": "Previous month",
1635
+ onClick: () => shiftLeft(-1),
1636
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "left" })
1637
+ }
1638
+ ),
1639
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "itzsa-ndp-range-hint", children: locale === "ne" ? anchor || fromParts && !toParts ? "\u0905\u0928\u094D\u0924\u093F\u092E \u092E\u093F\u0924\u093F \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : "\u0938\u0941\u0930\u0941 \u092E\u093F\u0924\u093F \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : anchor || fromParts && !toParts ? "Select end date" : "Select start date" }),
1640
+ /* @__PURE__ */ jsxRuntime.jsx(
1641
+ "button",
1642
+ {
1643
+ type: "button",
1644
+ className: "itzsa-ndp-nav-btn",
1645
+ disabled: !canNext,
1646
+ "aria-label": "Next month",
1647
+ onClick: () => shiftLeft(1),
1648
+ children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "right" })
1649
+ }
1650
+ )
1651
+ ] }),
1652
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("itzsa-ndp-range-months", dual && "is-dual", classNames?.rangeMonths), children: [
1653
+ /* @__PURE__ */ jsxRuntime.jsx(
1654
+ CalendarMonth,
1655
+ {
1656
+ year: leftView.year,
1657
+ month: leftView.month,
1658
+ locale,
1659
+ isDisabledDay,
1660
+ getModifiers,
1661
+ onDayClick,
1662
+ onDayHover: setHover,
1663
+ showHeader: true,
1664
+ onPrevMonth: void 0,
1665
+ onNextMonth: void 0
1666
+ }
1667
+ ),
1668
+ dual ? /* @__PURE__ */ jsxRuntime.jsx(
1669
+ CalendarMonth,
1670
+ {
1671
+ year: rightView.year,
1672
+ month: rightView.month,
1673
+ locale,
1674
+ isDisabledDay,
1675
+ getModifiers,
1676
+ onDayClick,
1677
+ onDayHover: setHover,
1678
+ showHeader: true
1679
+ }
1680
+ ) : null
1681
+ ] }),
1682
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-footer itzsa-ndp-range-footer", children: [
1683
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "itzsa-ndp-range-meta", children: nights != null ? locale === "ne" ? `${nights} \u0926\u093F\u0928` : `${nights} day${nights === 1 ? "" : "s"}` : locale === "ne" ? "\u0926\u093E\u092F\u0930\u093E \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : "Select a range" }),
1684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-range-actions", children: [
1685
+ /* @__PURE__ */ jsxRuntime.jsx(
1686
+ "button",
1687
+ {
1688
+ type: "button",
1689
+ className: "itzsa-ndp-footer-btn",
1690
+ onClick: () => {
1691
+ commit({});
1692
+ setAnchor(null);
1693
+ setHover(null);
1694
+ },
1695
+ children: locale === "ne" ? "\u0916\u093E\u0932\u0940" : "Clear"
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ jsxRuntime.jsx(
1699
+ "button",
1700
+ {
1701
+ type: "button",
1702
+ className: "itzsa-ndp-footer-btn is-primary",
1703
+ disabled: !fromParts || !toParts,
1704
+ onClick: () => setOpen(false),
1705
+ children: locale === "ne" ? "\u0920\u093F\u0915 \u091B" : "Done"
1706
+ }
1707
+ )
1708
+ ] })
1709
+ ] })
1710
+ ]
1711
+ }
1712
+ ),
1713
+ document.body
1714
+ ) : null;
1715
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1716
+ "div",
1717
+ {
1718
+ ref: rootRef,
1719
+ className: cn("itzsa-ndp itzsa-ndp-range", className, classNames?.root),
1720
+ style: rootStyle,
1721
+ "data-locale": locale,
1722
+ "data-disabled": disabled ? "" : void 0,
1723
+ "data-open": open ? "" : void 0,
1724
+ children: [
1725
+ /* @__PURE__ */ jsxRuntime.jsxs(
1726
+ "button",
1727
+ {
1728
+ type: "button",
1729
+ id,
1730
+ disabled,
1731
+ "aria-label": ariaLabel,
1732
+ "aria-expanded": open,
1733
+ "aria-haspopup": "dialog",
1734
+ className: cn(
1735
+ "itzsa-ndp-range-trigger",
1736
+ triggerClassName,
1737
+ classNames?.rangeTrigger
1738
+ ),
1739
+ onClick: () => {
1740
+ if (!disabled) setOpen((o) => !o);
1741
+ },
1742
+ children: [
1743
+ /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, { className: "itzsa-ndp-range-trigger-icon" }),
1744
+ /* @__PURE__ */ jsxRuntime.jsx(
1745
+ "span",
1746
+ {
1747
+ className: cn(
1748
+ "itzsa-ndp-range-trigger-label",
1749
+ !(fromParts || toParts) && "is-placeholder",
1750
+ classNames?.rangeLabel
1751
+ ),
1752
+ children: label
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "down", className: "itzsa-ndp-range-trigger-chevron" })
1756
+ ]
1757
+ }
1758
+ ),
1759
+ popover
1760
+ ]
1761
+ }
1762
+ );
1763
+ }
1764
+ function TimeColumn({
1765
+ label,
1766
+ values,
1767
+ selected,
1768
+ locale,
1769
+ disabledValues,
1770
+ onPick
1771
+ }) {
1772
+ const listRef = React6__namespace.useRef(null);
1773
+ React6__namespace.useEffect(() => {
1774
+ const root = listRef.current;
1775
+ if (!root) return;
1776
+ const el = root.querySelector("[data-selected]");
1777
+ el?.scrollIntoView({ block: "center" });
1778
+ }, [selected]);
1779
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-time-col", children: [
1780
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "itzsa-ndp-time-col-label", children: label }),
1781
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: listRef, className: "itzsa-ndp-time-list", role: "listbox", children: values.map((n) => {
1782
+ const disabled = disabledValues?.has(n) ?? false;
1783
+ const isSel = n === selected;
1784
+ return /* @__PURE__ */ jsxRuntime.jsx(
1785
+ "button",
1786
+ {
1787
+ type: "button",
1788
+ role: "option",
1789
+ "aria-selected": isSel,
1790
+ "data-selected": isSel ? "" : void 0,
1791
+ disabled,
1792
+ className: cn(
1793
+ "itzsa-ndp-time-item",
1794
+ isSel && "is-selected",
1795
+ disabled && "is-disabled"
1796
+ ),
1797
+ onClick: () => onPick(n),
1798
+ children: localizeDigits(pad23(n), locale)
1799
+ },
1800
+ n
1801
+ );
1802
+ }) })
1803
+ ] });
1804
+ }
1805
+ function pad23(n) {
1806
+ return n < 10 ? `0${n}` : String(n);
1807
+ }
1808
+ var NepaliDateTimePicker = React6__namespace.forwardRef(function NepaliDateTimePicker2({
1809
+ value: valueProp,
1810
+ defaultValue = "",
1811
+ onChange,
1812
+ onSelect,
1813
+ locale = "ne",
1814
+ valueLocale,
1815
+ minDateTime,
1816
+ minDate,
1817
+ maxDateTime,
1818
+ maxDate,
1819
+ minYear = BS_MIN_YEAR,
1820
+ maxYear = BS_MAX_YEAR,
1821
+ minuteStep = 5,
1822
+ withSeconds = false,
1823
+ closeOnSelect = true,
1824
+ todayIfEmpty = true,
1825
+ placeholder,
1826
+ disabled = false,
1827
+ readOnly = false,
1828
+ id,
1829
+ name,
1830
+ required,
1831
+ className,
1832
+ inputClassName,
1833
+ popoverClassName,
1834
+ classNames,
1835
+ vars,
1836
+ style,
1837
+ popoverStyle,
1838
+ "aria-label": ariaLabel,
1839
+ "aria-labelledby": ariaLabelledBy
1840
+ }, forwardedRef) {
1841
+ const displayLocale = valueLocale ?? locale;
1842
+ const rootStyle = mergePickerStyle(vars, style);
1843
+ const panelStyle = mergePickerStyle(vars, popoverStyle);
1844
+ const isControlled = valueProp !== void 0;
1845
+ const [uncontrolled, setUncontrolled] = React6__namespace.useState(defaultValue);
1846
+ const value = isControlled ? valueProp ?? "" : uncontrolled;
1847
+ const minBound = React6__namespace.useMemo(
1848
+ () => parseDateTimeBound(minDateTime ?? minDate, "min"),
1849
+ [minDateTime, minDate]
1850
+ );
1851
+ const maxBound = React6__namespace.useMemo(
1852
+ () => parseDateTimeBound(maxDateTime ?? maxDate, "max"),
1853
+ [maxDateTime, maxDate]
1854
+ );
1855
+ const selected = React6__namespace.useMemo(() => parseDateTimeString(value), [value]);
1856
+ const todayDate = React6__namespace.useMemo(() => todayBs(), []);
1857
+ const nowDt = React6__namespace.useMemo(() => todayBsDateTime(), []);
1858
+ const [open, setOpen] = React6__namespace.useState(false);
1859
+ const [draft, setDraft] = React6__namespace.useState(
1860
+ () => clampDateTime(
1861
+ selected ?? (todayIfEmpty ? nowDt : { ...nowDt, hour: 0, minute: 0, second: 0 }),
1862
+ minBound,
1863
+ maxBound
1864
+ )
1865
+ );
1866
+ const [view, setView] = React6__namespace.useState({
1867
+ year: draft.year,
1868
+ month: draft.month
1869
+ });
1870
+ const rootRef = React6__namespace.useRef(null);
1871
+ const inputRef = React6__namespace.useRef(null);
1872
+ const popoverRef = React6__namespace.useRef(null);
1873
+ const portalReady = usePortalReady();
1874
+ const { pos } = useFloatingPopover(open, rootRef, {
1875
+ minWidth: 320,
1876
+ estimatedHeight: 420
1877
+ });
1878
+ React6__namespace.useImperativeHandle(
1879
+ forwardedRef,
1880
+ () => inputRef.current
1881
+ );
1882
+ React6__namespace.useEffect(() => {
1883
+ if (!open) return;
1884
+ const base = selected ?? (todayIfEmpty ? nowDt : { year: 2080, month: 1, day: 1, hour: 0, minute: 0, second: 0 });
1885
+ const next = clampDateTime(
1886
+ {
1887
+ ...base,
1888
+ minute: snapMinute(base.minute, minuteStep),
1889
+ second: withSeconds ? base.second ?? 0 : 0
1890
+ },
1891
+ minBound,
1892
+ maxBound
1893
+ );
1894
+ setDraft(next);
1895
+ setView({ year: next.year, month: next.month });
1896
+ }, [open]);
1897
+ const close = React6__namespace.useCallback(() => setOpen(false), []);
1898
+ useDismissOnOutside(open, close, [rootRef, popoverRef]);
1899
+ const commit = React6__namespace.useCallback(
1900
+ (parts) => {
1901
+ const clamped = clampDateTime(parts, minBound, maxBound);
1902
+ const str = toDateTimeString(clamped, { withSeconds });
1903
+ if (!isControlled) setUncontrolled(str);
1904
+ onChange?.(str);
1905
+ onSelect?.(str);
1906
+ if (closeOnSelect) setOpen(false);
1907
+ },
1908
+ [minBound, maxBound, withSeconds, isControlled, onChange, onSelect, closeOnSelect]
1909
+ );
1910
+ const minParts = minBound ? dateTimeToDateParts(minBound) : null;
1911
+ const maxParts = maxBound ? dateTimeToDateParts(maxBound) : null;
1912
+ const isDisabledDay = React6__namespace.useMemo(
1913
+ () => createIsDisabledDay({ minYear, maxYear, minParts, maxParts }),
1914
+ [minYear, maxYear, minParts, maxParts]
1915
+ );
1916
+ const setDraftClamped = (next) => {
1917
+ setDraft(clampDateTime(next, minBound, maxBound));
1918
+ };
1919
+ const onDayClick = (parts) => {
1920
+ if (isDisabledDay(parts)) return;
1921
+ setDraftClamped({
1922
+ ...parts,
1923
+ hour: draft.hour,
1924
+ minute: draft.minute,
1925
+ second: draft.second ?? 0
1926
+ });
1927
+ };
1928
+ const hours = Array.from({ length: 24 }, (_, i) => i);
1929
+ const minutes = Array.from(
1930
+ { length: Math.floor(60 / Math.max(1, minuteStep)) },
1931
+ (_, i) => i * Math.max(1, minuteStep)
1932
+ );
1933
+ const seconds = Array.from({ length: 60 }, (_, i) => i);
1934
+ const disabledHours = React6__namespace.useMemo(() => {
1935
+ const set = /* @__PURE__ */ new Set();
1936
+ for (const h of hours) {
1937
+ const probe = {
1938
+ ...draft,
1939
+ hour: h,
1940
+ minute: 0,
1941
+ second: 0
1942
+ };
1943
+ const hi = {
1944
+ ...draft,
1945
+ hour: h,
1946
+ minute: 59,
1947
+ second: 59
1948
+ };
1949
+ if (minBound && compareDateTimeParts(hi, minBound) < 0) set.add(h);
1950
+ if (maxBound && compareDateTimeParts(probe, maxBound) > 0) set.add(h);
1951
+ }
1952
+ return set;
1953
+ }, [draft, minBound, maxBound, hours]);
1954
+ const disabledMinutes = React6__namespace.useMemo(() => {
1955
+ const set = /* @__PURE__ */ new Set();
1956
+ for (const m of minutes) {
1957
+ const probe = {
1958
+ ...draft,
1959
+ minute: m,
1960
+ second: 0
1961
+ };
1962
+ const hi = {
1963
+ ...draft,
1964
+ minute: m,
1965
+ second: 59
1966
+ };
1967
+ if (minBound && compareDateTimeParts(hi, minBound) < 0) set.add(m);
1968
+ if (maxBound && compareDateTimeParts(probe, maxBound) > 0) set.add(m);
1969
+ }
1970
+ return set;
1971
+ }, [draft, minBound, maxBound, minutes]);
1972
+ const displayValue = selected ? formatBsDateTimeLabel(selected, displayLocale, { withSeconds }) : "";
1973
+ const popover = open && portalReady ? reactDom.createPortal(
1974
+ /* @__PURE__ */ jsxRuntime.jsxs(
1975
+ "div",
1976
+ {
1977
+ ref: popoverRef,
1978
+ className: cn(
1979
+ "itzsa-ndp-popover itzsa-ndp-popover-datetime",
1980
+ popoverClassName,
1981
+ classNames?.popover
1982
+ ),
1983
+ "data-locale": locale,
1984
+ style: {
1985
+ position: "fixed",
1986
+ top: pos.top,
1987
+ left: pos.left,
1988
+ width: Math.max(pos.width, 320),
1989
+ zIndex: 50,
1990
+ ...panelStyle
1991
+ },
1992
+ role: "dialog",
1993
+ "aria-modal": "false",
1994
+ "aria-label": "Nepali date and time",
1995
+ children: [
1996
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-datetime-layout", children: [
1997
+ /* @__PURE__ */ jsxRuntime.jsx(
1998
+ SingleCalendarPanel,
1999
+ {
2000
+ locale,
2001
+ view,
2002
+ onViewChange: setView,
2003
+ selected: dateTimeToDateParts(draft),
2004
+ today: todayDate,
2005
+ minYear,
2006
+ maxYear,
2007
+ isDisabledDay,
2008
+ onDayClick
2009
+ }
2010
+ ),
2011
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-time-panel", children: [
2012
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "itzsa-ndp-time-heading", children: locale === "ne" ? "\u0938\u092E\u092F" : "Time" }),
2013
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-time-cols", children: [
2014
+ /* @__PURE__ */ jsxRuntime.jsx(
2015
+ TimeColumn,
2016
+ {
2017
+ label: locale === "ne" ? "\u0918\u0923\u094D\u091F\u093E" : "Hour",
2018
+ values: hours,
2019
+ selected: draft.hour,
2020
+ locale,
2021
+ disabledValues: disabledHours,
2022
+ onPick: (hour) => setDraftClamped({ ...draft, hour })
2023
+ }
2024
+ ),
2025
+ /* @__PURE__ */ jsxRuntime.jsx(
2026
+ TimeColumn,
2027
+ {
2028
+ label: locale === "ne" ? "\u092E\u093F\u0928\u0947\u091F" : "Min",
2029
+ values: minutes,
2030
+ selected: snapMinute(draft.minute, minuteStep),
2031
+ locale,
2032
+ disabledValues: disabledMinutes,
2033
+ onPick: (minute) => setDraftClamped({ ...draft, minute })
2034
+ }
2035
+ ),
2036
+ withSeconds ? /* @__PURE__ */ jsxRuntime.jsx(
2037
+ TimeColumn,
2038
+ {
2039
+ label: locale === "ne" ? "\u0938\u0947\u0915\u0947\u0928\u094D\u0921" : "Sec",
2040
+ values: seconds,
2041
+ selected: draft.second ?? 0,
2042
+ locale,
2043
+ onPick: (second) => setDraftClamped({ ...draft, second })
2044
+ }
2045
+ ) : null
2046
+ ] })
2047
+ ] })
2048
+ ] }),
2049
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("itzsa-ndp-footer", classNames?.footer), children: [
2050
+ /* @__PURE__ */ jsxRuntime.jsx(
2051
+ "button",
2052
+ {
2053
+ type: "button",
2054
+ className: "itzsa-ndp-footer-btn",
2055
+ onClick: () => {
2056
+ const now = todayBsDateTime();
2057
+ const t = clampDateTime(
2058
+ {
2059
+ ...now,
2060
+ minute: snapMinute(now.minute, minuteStep),
2061
+ second: withSeconds ? now.second : 0
2062
+ },
2063
+ minBound,
2064
+ maxBound
2065
+ );
2066
+ setDraft(t);
2067
+ setView({ year: t.year, month: t.month });
2068
+ },
2069
+ children: locale === "ne" ? "\u0905\u0939\u093F\u0932\u0947" : "Now"
2070
+ }
2071
+ ),
2072
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "itzsa-ndp-range-actions", children: [
2073
+ value ? /* @__PURE__ */ jsxRuntime.jsx(
2074
+ "button",
2075
+ {
2076
+ type: "button",
2077
+ className: "itzsa-ndp-footer-btn",
2078
+ onClick: () => {
2079
+ if (!isControlled) setUncontrolled("");
2080
+ onChange?.("");
2081
+ onSelect?.("");
2082
+ },
2083
+ children: locale === "ne" ? "\u0916\u093E\u0932\u0940" : "Clear"
2084
+ }
2085
+ ) : null,
2086
+ /* @__PURE__ */ jsxRuntime.jsx(
2087
+ "button",
2088
+ {
2089
+ type: "button",
2090
+ className: "itzsa-ndp-footer-btn is-primary",
2091
+ onClick: () => commit(draft),
2092
+ children: locale === "ne" ? "\u0920\u093F\u0915 \u091B" : "Confirm"
2093
+ }
2094
+ )
2095
+ ] })
2096
+ ] })
2097
+ ]
2098
+ }
2099
+ ),
2100
+ document.body
2101
+ ) : null;
2102
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2103
+ "div",
2104
+ {
2105
+ ref: rootRef,
2106
+ className: cn("itzsa-ndp itzsa-ndp-datetime", className, classNames?.root),
2107
+ style: rootStyle,
2108
+ "data-locale": locale,
2109
+ "data-disabled": disabled ? "" : void 0,
2110
+ "data-open": open ? "" : void 0,
2111
+ children: [
2112
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("itzsa-ndp-field", classNames?.field), children: [
2113
+ /* @__PURE__ */ jsxRuntime.jsx(
2114
+ "input",
2115
+ {
2116
+ ref: inputRef,
2117
+ id,
2118
+ name,
2119
+ required,
2120
+ disabled,
2121
+ readOnly: true,
2122
+ placeholder: placeholder ?? (displayLocale === "ne" ? "\u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F \u091B\u093E\u0928\u094D\u0928\u0941\u0939\u094B\u0938\u094D" : "Select date & time"),
2123
+ value: displayValue,
2124
+ "aria-label": ariaLabel,
2125
+ "aria-labelledby": ariaLabelledBy,
2126
+ "aria-expanded": open,
2127
+ "aria-haspopup": "dialog",
2128
+ className: cn("itzsa-ndp-input", inputClassName, classNames?.input),
2129
+ onClick: () => {
2130
+ if (!disabled && !readOnly) setOpen(true);
2131
+ },
2132
+ onFocus: () => {
2133
+ if (!disabled && !readOnly) setOpen(true);
2134
+ },
2135
+ onKeyDown: (e) => {
2136
+ if (disabled || readOnly) return;
2137
+ if (e.key === "Enter" || e.key === " ") {
2138
+ e.preventDefault();
2139
+ setOpen((o) => !o);
2140
+ }
2141
+ }
2142
+ }
2143
+ ),
2144
+ /* @__PURE__ */ jsxRuntime.jsx(
2145
+ "button",
2146
+ {
2147
+ type: "button",
2148
+ className: cn("itzsa-ndp-trigger", classNames?.trigger),
2149
+ tabIndex: -1,
2150
+ disabled: disabled || readOnly,
2151
+ "aria-label": "Open date and time picker",
2152
+ onClick: () => {
2153
+ if (!disabled && !readOnly) setOpen((o) => !o);
2154
+ },
2155
+ children: /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {})
2156
+ }
2157
+ )
2158
+ ] }),
2159
+ popover
2160
+ ]
2161
+ }
2162
+ );
2163
+ });
2164
+
2165
+ exports.BS_EPOCH_AD = BS_EPOCH_AD;
2166
+ exports.BS_MAX_YEAR = BS_MAX_YEAR;
2167
+ exports.BS_MIN_YEAR = BS_MIN_YEAR;
2168
+ exports.BS_MONTH_DAYS = BS_MONTH_DAYS;
2169
+ exports.EditableNepaliDatePicker = EditableNepaliDatePicker;
2170
+ exports.NEPALI_MONTH_NAMES_EN = NEPALI_MONTH_NAMES_EN;
2171
+ exports.NEPALI_MONTH_NAMES_NE = NEPALI_MONTH_NAMES_NE;
2172
+ exports.NepaliDatePicker = NepaliDatePicker;
2173
+ exports.NepaliDateRangePicker = NepaliDateRangePicker;
2174
+ exports.NepaliDateTimePicker = NepaliDateTimePicker;
2175
+ exports.WEEKDAY_NAMES_EN = WEEKDAY_NAMES_EN;
2176
+ exports.WEEKDAY_NAMES_NE = WEEKDAY_NAMES_NE;
2177
+ exports.adToBs = adToBs;
2178
+ exports.addBsDays = addBsDays;
2179
+ exports.addBsMonths = addBsMonths;
2180
+ exports.assertBsDay = assertBsDay;
2181
+ exports.assertBsMonth = assertBsMonth;
2182
+ exports.assertBsYear = assertBsYear;
2183
+ exports.assertValidBsDate = assertValidBsDate;
2184
+ exports.bsToAd = bsToAd;
2185
+ exports.clampBsDate = clampBsDate;
2186
+ exports.clampDateTime = clampDateTime;
2187
+ exports.cn = cn;
2188
+ exports.compareDateParts = compareDateParts;
2189
+ exports.compareDateTimeParts = compareDateTimeParts;
2190
+ exports.dateTimeToDateParts = dateTimeToDateParts;
2191
+ exports.diffBsDays = diffBsDays;
2192
+ exports.formatBsDateTimeLabel = formatBsDateTimeLabel;
2193
+ exports.formatBsLabel = formatBsLabel;
2194
+ exports.formatDateParts = formatDateParts;
2195
+ exports.formatTypedBsDate = formatTypedBsDate;
2196
+ exports.getBsWeekday = getBsWeekday;
2197
+ exports.getDaysInBsMonth = getDaysInBsMonth;
2198
+ exports.getDaysInBsYear = getDaysInBsYear;
2199
+ exports.getMonthName = getMonthName;
2200
+ exports.getWeekdayNames = getWeekdayNames;
2201
+ exports.isCompleteBsDate = isCompleteBsDate;
2202
+ exports.isCompleteBsDateTime = isCompleteBsDateTime;
2203
+ exports.isValidBsDate = isValidBsDate;
2204
+ exports.localizeDigits = localizeDigits;
2205
+ exports.mergeRefs = mergeRefs;
2206
+ exports.parseDateString = parseDateString;
2207
+ exports.parseDateTimeBound = parseDateTimeBound;
2208
+ exports.parseDateTimeString = parseDateTimeString;
2209
+ exports.snapMinute = snapMinute;
2210
+ exports.toDateString = toDateString;
2211
+ exports.toDateTimeString = toDateTimeString;
2212
+ exports.todayBs = todayBs;
2213
+ exports.todayBsDateTime = todayBsDateTime;
2214
+ exports.validateBsDate = validateBsDate;
2215
+ exports.validateBsDateParts = validateBsDateParts;
2216
+ //# sourceMappingURL=index.js.map
2217
+ //# sourceMappingURL=index.js.map