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uB,KAAK,0BAC3N,IAAK,IACD,MAAO,GAAG,eAAe,KAAK,eAAe,cAAc,KAAK,KAAO,GAAK,OAAS,UAAU,KAAK,aAAa,iBAAiB,KAAK,MAAQ,KAAK,KAAK,YAAc,WAAa,UAAU,KAAK,KAAK,WAAW,SAAS,EAAG,cAAc,KAAK,sBAAsB,KAAK,gCAAgC,KAAK,wBAAwB,KAAK,2BAA2B,KAAK,YAAc,WAAa,UAAU,KAAK,uBAAuB,KAAK,2BACzb,QACI,MAAO,GAAG,KAAK,IAAI,WAAW,SAAS,EAAG,QAAQ,KAAK,MAAM,WAAW,SAAS,EAAG,OAAO,KAAK,YAAc,IAAM,MAAM,KAAK,KAAK,WAAW,SAAS,EAAG,OAEvK,CAKA,mBAAO,CAAa,GAEhB,IAEI,EAFA,EAAM,gBAAgB,EAAY,EADrB,GAEb,EAAM,gBAAgB,EAFT,GAIjB,OAAI,EAAM,EAAM,KACZ,EAAU,mBAAmB,EALhB,GAMN,KAAK,IAAI,EAAU,EAAG,KAEjC,EAAM,gBAAgB,EARL,GASjB,EAAM,gBAAgB,EAAY,EATjB,GAUb,EAAM,GAAO,IACN,GACX,EAAU,mBAAmB,EAZZ,GAaC,GAAX,GAA2B,GAAX,EAAe,EAAU,GAAK,GACzD","file":"/npm/vietnamese-date@1.1.1/lib/vietnamese-date.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/vietnamese-date@1.1.1/lib/vietnamese-date.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export class VietnameseDateException extends Error {\r\n    constructor(message) {\r\n        super(message);\r\n    }\r\n}\r\nfunction Int(a) {\r\n    return Math.floor(a);\r\n}\r\n/**\r\n * Trả về số ngày tính từ ngày 1 tháng 1 năm 4713 trước công nguyên (theo lịch Julian)\r\n */\r\nfunction JdFromDate(dd, mm, yy) {\r\n    const a = Int((14 - mm) / 12);\r\n    const y = yy + 4800 - a;\r\n    const m = mm + 12 * a - 3;\r\n    let jd = dd + Int((153 * m + 2) / 5) + 365 * y + Int(y / 4) - Int(y / 100) + Int(y / 400) - 32045;\r\n    if (jd < 2299161) {\r\n        jd = dd + Int((153 * m + 2) / 5) + 365 * y + Int(y / 4) - 32083;\r\n    }\r\n    return jd;\r\n}\r\nfunction JdToDate(jd) {\r\n    let b, c;\r\n    if (jd > 2299160) {\r\n        // After 5/10/1582, Gregorian calendar\r\n        const a = jd + 32044;\r\n        b = Int((4 * a + 3) / 146097);\r\n        c = a - Int((b * 146097) / 4);\r\n    }\r\n    else {\r\n        b = 0;\r\n        c = jd + 32082;\r\n    }\r\n    const d = Int((4 * c + 3) / 1461);\r\n    const e = c - Int((1461 * d) / 4);\r\n    const m = Int((5 * e + 2) / 153);\r\n    const day = e - Int((153 * m + 2) / 5) + 1;\r\n    const month = m + 3 - 12 * Int(m / 10);\r\n    const year = b * 100 + d - 4800 + Int(m / 10);\r\n    return new Date(`${year.toString().padStart(4, '0')}-${month.toString().padStart(2, '0')}-${day\r\n        .toString()\r\n        .padStart(2, '0')}T00:00:00+07:00`);\r\n}\r\n/**\r\n * Tính ngày Sóc\r\n */\r\nfunction GetNewMoonDay(k, timeZone) {\r\n    const t = k / 1236.85;\r\n    const t2 = t * t;\r\n    const t3 = t2 * t;\r\n    const dr = Math.PI / 180;\r\n    const jd1 = 2415020.75933 +\r\n        29.53058868 * k +\r\n        0.0001178 * t2 -\r\n        0.000000155 * t3 +\r\n        0.00033 * Math.sin((166.56 + 132.87 * t - 0.009173 * t2) * dr); // Mean new moon\r\n    const m = 359.2242 + 29.10535608 * k - 0.0000333 * t2 - 0.00000347 * t3;\r\n    const mpr = 306.0253 + 385.81691806 * k + 0.0107306 * t2 + 0.00001236 * t3;\r\n    const f = 21.2964 + 390.67050646 * k - 0.0016528 * t2 - 0.00000239 * t3;\r\n    const c1 = (0.1734 - 0.000393 * t) * Math.sin(m * dr) +\r\n        0.0021 * Math.sin(2 * dr * m) -\r\n        0.4068 * Math.sin(mpr * dr) +\r\n        0.0161 * Math.sin(dr * 2 * mpr) -\r\n        0.0004 * Math.sin(dr * 3 * mpr) +\r\n        0.0104 * Math.sin(dr * 2 * f) -\r\n        0.0051 * Math.sin(dr * (m + mpr)) -\r\n        0.0074 * Math.sin(dr * (m - mpr)) +\r\n        0.0004 * Math.sin(dr * (2 * f + m)) -\r\n        0.0004 * Math.sin(dr * (2 * f - m)) -\r\n        0.0006 * Math.sin(dr * (2 * f + mpr)) +\r\n        0.001 * Math.sin(dr * (2 * f - mpr)) +\r\n        0.0005 * Math.sin(dr * (2 * mpr + m));\r\n    const deltaT = t < -11\r\n        ? 0.001 + 0.000839 * t + 0.0002261 * t2 - 0.00000845 * t3 - 0.000000081 * t * t3\r\n        : -0.000278 + 0.000265 * t + 0.000262 * t2;\r\n    const jdNew = jd1 + c1 - deltaT;\r\n    return Int(jdNew + 0.5 + timeZone / 24);\r\n}\r\n/**\r\n * Tính tọa độ mặt trời\r\n */\r\nfunction GetSunLongitude(jdn, timeZone) {\r\n    const t = (jdn - 2451545.5 - timeZone / 24) / 36525;\r\n    const t2 = t * t;\r\n    const dr = Math.PI / 180;\r\n    const m = 357.5291 + 35999.0503 * t - 0.0001559 * t2 - 0.00000048 * t * t2;\r\n    const l0 = 280.46645 + 36000.76983 * t + 0.0003032 * t2;\r\n    const dl = (1.9146 - 0.004817 * t - 0.000014 * t2) * Math.sin(dr * m) +\r\n        (0.019993 - 0.000101 * t) * Math.sin(dr * 2 * m) +\r\n        0.00029 * Math.sin(dr * 3 * m);\r\n    let l = l0 + dl;\r\n    l *= dr;\r\n    l -= Math.PI * 2 * Int(l / (Math.PI * 2)); // Normalize to (0, 2*PI)\r\n    return Int((l / Math.PI) * 6);\r\n}\r\n/**\r\n * Tìm ngày bắt đầu tháng 11 âm lịch\r\n */\r\nfunction GetLunarMonth11(yy, timeZone) {\r\n    const off = JdFromDate(31, 12, yy) - 2415021;\r\n    const k = Int(off / 29.530588853);\r\n    let nm = GetNewMoonDay(k, timeZone);\r\n    const sunLong = GetSunLongitude(nm, timeZone);\r\n    if (sunLong >= 9) {\r\n        nm = GetNewMoonDay(k - 1, timeZone);\r\n    }\r\n    return nm;\r\n}\r\nfunction GetLeapMonthOffset(a11, timeZone) {\r\n    let last;\r\n    const k = Int((a11 - 2415021.076998695) / 29.530588853 + 0.5);\r\n    let i = 1;\r\n    let arc = GetSunLongitude(GetNewMoonDay(k + i, timeZone), timeZone);\r\n    do {\r\n        last = arc;\r\n        i++;\r\n        arc = GetSunLongitude(GetNewMoonDay(k + i, timeZone), timeZone);\r\n    } while (arc != last && i < 14);\r\n    return i - 1;\r\n}\r\nfunction ConvertSolar2Lunar(yy, mm, dd, timeZone = 7.0) {\r\n    const dayNumber = JdFromDate(dd, mm, yy);\r\n    const k = Int((dayNumber - 2415021.076998695) / 29.530588853);\r\n    let monthStart = GetNewMoonDay(k + 1, timeZone);\r\n    if (monthStart > dayNumber) {\r\n        monthStart = GetNewMoonDay(k, timeZone);\r\n    }\r\n    let a11 = GetLunarMonth11(yy, timeZone);\r\n    let b11 = a11;\r\n    let lunarYear;\r\n    if (a11 >= monthStart) {\r\n        lunarYear = yy;\r\n        a11 = GetLunarMonth11(yy - 1, timeZone);\r\n    }\r\n    else {\r\n        lunarYear = yy + 1;\r\n        b11 = GetLunarMonth11(yy + 1, timeZone);\r\n    }\r\n    const lunarDay = dayNumber - monthStart + 1;\r\n    const diff = Int((monthStart - a11) / 29);\r\n    let lunarLeap = 0;\r\n    let lunarMonth = diff + 11;\r\n    if (b11 - a11 > 365) {\r\n        const leapMonthDiff = GetLeapMonthOffset(a11, timeZone);\r\n        if (diff >= leapMonthDiff) {\r\n            lunarMonth = diff + 10;\r\n            if (diff == leapMonthDiff) {\r\n                lunarLeap = 1;\r\n            }\r\n        }\r\n    }\r\n    if (lunarMonth > 12) {\r\n        lunarMonth -= 12;\r\n    }\r\n    if (lunarMonth >= 11 && diff < 4) {\r\n        lunarYear--;\r\n    }\r\n    return [lunarYear, lunarMonth, lunarDay, lunarLeap, dayNumber];\r\n}\r\nfunction ConvertDate2Lunar(date, timeZone = 7.0) {\r\n    return ConvertSolar2Lunar(date.getFullYear(), date.getMonth() + 1, date.getDate(), timeZone);\r\n}\r\nfunction ConvertLunar2Solar(lunarYear, lunarMonth, lunarDay, lunarLeap = false, timeZone = 7.0) {\r\n    let a11, b11;\r\n    if (lunarMonth < 11) {\r\n        a11 = GetLunarMonth11(lunarYear - 1, timeZone);\r\n        b11 = GetLunarMonth11(lunarYear, timeZone);\r\n    }\r\n    else {\r\n        a11 = GetLunarMonth11(lunarYear, timeZone);\r\n        b11 = GetLunarMonth11(lunarYear + 1, timeZone);\r\n    }\r\n    let off = lunarMonth - 11;\r\n    if (off < 0) {\r\n        off += 12;\r\n    }\r\n    if (lunarLeap && b11 - a11 < 365) {\r\n        throw new VietnameseDateException('Invalid leap month');\r\n    }\r\n    if (b11 - a11 > 365 || lunarLeap) {\r\n        const leapOff = GetLeapMonthOffset(a11, timeZone);\r\n        let leapMonth = leapOff - 2;\r\n        if (leapMonth < 0) {\r\n            leapMonth += 12;\r\n        }\r\n        if (lunarLeap && lunarMonth != leapMonth) {\r\n            throw new VietnameseDateException('Invalid leap month');\r\n        }\r\n        // nếu là tháng nhuận hoặc ở sau tháng nhuận thì cộng thêm 1 tháng\r\n        if (lunarLeap || (lunarMonth == 12 && leapOff == 1) || (lunarMonth < 11 && leapOff - 2 < lunarMonth)) {\r\n            off += 1;\r\n        }\r\n    }\r\n    const k = Int(0.5 + (a11 - 2415021.076998695) / 29.530588853);\r\n    const monthStart = GetNewMoonDay(k + off, timeZone);\r\n    const jd = monthStart + lunarDay - 1;\r\n    //return { solarDateTime: JdToDate(jd), juliusDayNumber: jd };\r\n    return jd;\r\n}\r\n// Can\r\nconst CelestialStems = ['Giáp', 'Ất', 'Bính', 'Đinh', 'Mậu', 'Kỷ', 'Canh', 'Tân', 'Nhâm', 'Quý'];\r\n// Chi\r\nconst TerrestrialBranches = [\r\n    'Tý',\r\n    'Sửu',\r\n    'Dần',\r\n    'Mão',\r\n    'Thìn',\r\n    'Tỵ',\r\n    'Ngọ',\r\n    'Mùi',\r\n    'Thân',\r\n    'Dậu',\r\n    'Tuất',\r\n    'Hợi',\r\n];\r\nconst MonthSpeechNames = [\r\n    'Giêng',\r\n    'Hai',\r\n    'Ba',\r\n    'Tư',\r\n    'Năm',\r\n    'Sáu',\r\n    'Bảy',\r\n    'Tám',\r\n    'Chín',\r\n    'Mười',\r\n    'Mười một',\r\n    'Chạp',\r\n];\r\nconst DayOfWeekNames = ['Chủ nhật', 'Thứ hai', 'Thứ ba', 'Thứ tư', 'Thứ năm', 'Thứ sáu', 'Thứ bảy'];\r\n// Giờ hoàng đạo\r\nconst PropitiousHours = [\r\n    [1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0],\r\n    [0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1],\r\n    [1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0],\r\n    [1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0],\r\n    [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1],\r\n    [0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1],\r\n];\r\n// Tiết khí\r\nconst MinorSolarTerms = [\r\n    'Xuân Phân',\r\n    'Thanh Minh',\r\n    'Cốc Vũ',\r\n    'Lập Hạ',\r\n    'Tiểu Mãn',\r\n    'Mang Chủng',\r\n    'Hạ Chí',\r\n    'Tiểu Thử',\r\n    'Đại Thử',\r\n    'Lập Thu',\r\n    'Xử Thử',\r\n    'Bạch Lộ',\r\n    'Thu Phân',\r\n    'Hàn Lộ',\r\n    'Sương Giáng',\r\n    'Lập Đông',\r\n    'Tiểu Tuyết',\r\n    'Đại Tuyết',\r\n    'Đông Chí',\r\n    'Tiểu Hàn',\r\n    'Đại Hàn',\r\n    'Lập Xuân',\r\n    'Vũ Thủy',\r\n    'Kinh Trập',\r\n];\r\n/**\r\n * Vietnamese lunar date - Ngày âm lịch\r\n */\r\nexport default class VietnameseDate {\r\n    constructor(firstParameter, lunarMonth = 1, lunarDay = 1, isLeapMonth = false) {\r\n        if (typeof firstParameter === 'string') {\r\n            firstParameter = new Date(firstParameter);\r\n        }\r\n        const timezoneOffset = new Date().getTimezoneOffset();\r\n        if (firstParameter instanceof Date) {\r\n            this.solarDate = firstParameter;\r\n            this.solarLocalDate = timezoneOffset === -420 ? this.solarDate : new Date(this.solarDate.toLocaleString(\"en-US\", { timeZone: \"Asia/Ho_Chi_Minh\" }));\r\n            const [lunarYear, lunarMonth, lunarDay, isLeapMonth, juliusDayNumber] = ConvertDate2Lunar(this.solarLocalDate);\r\n            this.year = lunarYear;\r\n            this.month = lunarMonth;\r\n            this.day = lunarDay;\r\n            this.isLeapMonth = !!isLeapMonth;\r\n            this.juliusDayNumber = juliusDayNumber;\r\n            return;\r\n        }\r\n        this.year = firstParameter;\r\n        this.month = lunarMonth;\r\n        this.day = lunarDay;\r\n        this.isLeapMonth = isLeapMonth;\r\n        this.juliusDayNumber = ConvertLunar2Solar(this.year, lunarMonth, lunarDay, isLeapMonth);\r\n        this.solarDate = JdToDate(this.juliusDayNumber);\r\n        this.solarLocalDate = timezoneOffset === -420 ? this.solarDate : new Date(this.solarDate.toLocaleString(\"en-US\", { timeZone: \"Asia/Ho_Chi_Minh\" }));\r\n    }\r\n    /**\r\n     * Celestial stem of day - Can của ngày\r\n     */\r\n    get celestialStemOfDay() {\r\n        return CelestialStems[(this.juliusDayNumber + 9) % 10];\r\n    }\r\n    /**\r\n     * Terrestrial branch of day - Chi của ngày\r\n     */\r\n    get terrestrialBranchOfDay() {\r\n        return TerrestrialBranches[(this.juliusDayNumber + 1) % 12];\r\n    }\r\n    /**\r\n     * Celestial stem of month - Can của tháng\r\n     */\r\n    get celestialStemOfMonth() {\r\n        return CelestialStems[(this.year * 12 + this.month + 3) % 10];\r\n    }\r\n    /**\r\n     * Terrestrial branch of month - Chi của tháng\r\n     */\r\n    get terrestrialBranchOfMonth() {\r\n        return TerrestrialBranches[(this.month + 1) % 12];\r\n    }\r\n    /**\r\n     * Celestial stem of year - Can của năm\r\n     */\r\n    get celestialStemOfYear() {\r\n        return CelestialStems[(this.year + 6) % 10];\r\n    }\r\n    /**\r\n     * Terrestrial branch of year - Chi của năm\r\n     */\r\n    get terrestrialBranchOfYear() {\r\n        return TerrestrialBranches[(this.year + 8) % 12];\r\n    }\r\n    /**\r\n     * Propitious hours - Các giờ hoàng đạo\r\n     */\r\n    get propitiousHours() {\r\n        const terrestrialBranchOfDay = (this.juliusDayNumber + 1) % 12;\r\n        const propitiousHours = PropitiousHours[terrestrialBranchOfDay % 6];\r\n        return propitiousHours\r\n            .map((c, i) => (c == 0 ? null : `${TerrestrialBranches[i]} (${(i * 2 + 23) % 24}-${(i * 2 + 1) % 24})`))\r\n            .filter((s) => s !== null)\r\n            .join(', ');\r\n    }\r\n    /**\r\n     * Convert to string - Chuyển đổi thành chuỗi\r\n     * @param formatString Format string - Chuỗi định dạng. Hỗ trợ các giá trị:\r\n     *\r\n     * d: Short format - Dạng ngắn gọn. Eg - Ví dụ: \"07/10/2021\" or - hoặc \"26/04N/2020\"\r\n     *\r\n     * D: Long format - Dạng dài. Eg - Ví dụ: \"Thứ năm, mùng 7 tháng Mười năm 2021\" or - hoặc \"Thứ tư, ngày 26 tháng Tư (nhuận) năm 2020\"\r\n     *\r\n     * m: Numeric month format - Dạng tháng (số). Eg - Ví dụ: \"07/10\" or - hoặc \"26/04N\"\r\n     *\r\n     * M: Alphabet month format - Dạng tháng (chữ). Eg - Ví dụ: \"mùng 7 tháng Mười\" or - hoặc \"26 tháng Tư (nhuận)\"\r\n     *\r\n     * s: Sortable format - Dạng sắp xếp. Eg - Ví dụ: \"2021 / 10 / 07\" or - hoặc \"2020 / 04N/ 26\"\r\n     *\r\n     * L: Celestial stem and Terrestrial branch format - Dạng can chi. Eg - Ví dụ: \"ngày Quý Hợi tháng Kỷ Hợi năm Tân Sửu\" or - hoặc \"ngày Tân Mão tháng Tân Tỵ (nhuận) năm Canh Tý\"\r\n     *\r\n     * F: Full format - Dạng đầy đủ. Eg - Ví dụ: \"Thứ năm, mùng 7 tháng Mười năm 2021 (ngày Quý Hợi tháng Kỷ Hợi năm Tân Sửu)\" or - hoặc \"Thứ tư, ngày 26 tháng Tư (nhuận) năm 2020 (ngày Tân Mão tháng Tân Tỵ (nhuận) năm Canh Tý)\"\r\n     */\r\n    format(formatString = 'd') {\r\n        switch (formatString) {\r\n            case 'D':\r\n                return `${DayOfWeekNames[this.solarLocalDate.getDay()]}, ${this.day <= 10 ? 'mùng' : 'ngày'} ${this.day} tháng ${MonthSpeechNames[this.month - 1]}${this.isLeapMonth ? ' (nhuận)' : ''} năm ${this.year.toString().padStart(4, '0')}`;\r\n            case 'm':\r\n                return `${this.day.toString().padStart(2, '0')}/${this.month.toString().padStart(2, '0')}${this.isLeapMonth ? 'N' : ''}`;\r\n            case 'M':\r\n                return `${this.day <= 10 ? 'mùng' : 'ngày'} ${this.day} tháng ${MonthSpeechNames[this.month - 1]}${this.isLeapMonth ? ' (nhuận)' : ''}`;\r\n            case 's':\r\n                return `${this.year.toString().padStart(4, '0')} / ${this.month.toString().padStart(2, '0')}${this.isLeapMonth ? 'N' : ' '}/ ${this.day.toString().padStart(2, '0')}`;\r\n            case 'L':\r\n                return `ngày ${this.celestialStemOfDay} ${this.terrestrialBranchOfDay} tháng ${this.celestialStemOfMonth} ${this.terrestrialBranchOfMonth}${this.isLeapMonth ? ' (nhuận)' : ''} năm ${this.celestialStemOfYear} ${this.terrestrialBranchOfYear}`;\r\n            case 'F':\r\n                return `${DayOfWeekNames[this.solarLocalDate.getDay()]}, ${this.day <= 10 ? 'mùng' : 'ngày'} ${this.day} tháng ${MonthSpeechNames[this.month - 1]}${this.isLeapMonth ? ' (nhuận)' : ''} năm ${this.year.toString().padStart(4, '0')} (ngày ${this.celestialStemOfDay} ${this.terrestrialBranchOfDay} tháng ${this.celestialStemOfMonth} ${this.terrestrialBranchOfMonth}${this.isLeapMonth ? ' (nhuận)' : ''} năm ${this.celestialStemOfYear} ${this.terrestrialBranchOfYear})`;\r\n            default:\r\n                return `${this.day.toString().padStart(2, '0')}/${this.month.toString().padStart(2, '0')}${this.isLeapMonth ? 'N' : ''}/${this.year.toString().padStart(4, '0')}`;\r\n        }\r\n    }\r\n    /**\r\n     * Return leap month of year, return 0 if year does not have leap month - Trả về tháng nhuận của năm, nếu không phải năm nhuận thì trả về 0.\r\n     * @param lunarYear Lunar year - Năm âm lịch\r\n     */\r\n    static getLeapMonth(lunarYear) {\r\n        const timeZone = 7.0;\r\n        let a11 = GetLunarMonth11(lunarYear - 1, timeZone);\r\n        let b11 = GetLunarMonth11(lunarYear, timeZone);\r\n        let leapOff;\r\n        if (b11 - a11 > 365) {\r\n            leapOff = GetLeapMonthOffset(a11, timeZone);\r\n            return Math.max(leapOff - 2, 0);\r\n        }\r\n        a11 = GetLunarMonth11(lunarYear, timeZone);\r\n        b11 = GetLunarMonth11(lunarYear + 1, timeZone);\r\n        if (b11 - a11 <= 365)\r\n            return 0;\r\n        leapOff = GetLeapMonthOffset(a11, timeZone);\r\n        return leapOff == 1 || leapOff == 2 ? leapOff + 10 : 0;\r\n    }\r\n}\r\n"]}