@tiaohsun/vue-datepicker
Version:
A Vue 3 datepicker with multi-calendar support, styled with Tailwind CSS
1 lines • 187 kB
JavaScript
(function(fe,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","vue","dayjs"],a):(fe=typeof globalThis<"u"?globalThis:fe||self,a(fe.VueDatePicker={},fe.Vue,fe.dayjs))})(this,function(fe,a,ae){"use strict";function Le(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qe={exports:{}},ir=Qe.exports,Zt;function cr(){return Zt||(Zt=1,function(n,e){(function(t,r){n.exports=r()})(ir,function(){var t="minute",r=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g;return function(l,s,i){var u=s.prototype;i.utc=function(f){var y={date:f,utc:!0,args:arguments};return new s(y)},u.utc=function(f){var y=i(this.toDate(),{locale:this.$L,utc:!0});return f?y.add(this.utcOffset(),t):y},u.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var c=u.parse;u.parse=function(f){f.utc&&(this.$u=!0),this.$utils().u(f.$offset)||(this.$offset=f.$offset),c.call(this,f)};var h=u.init;u.init=function(){if(this.$u){var f=this.$d;this.$y=f.getUTCFullYear(),this.$M=f.getUTCMonth(),this.$D=f.getUTCDate(),this.$W=f.getUTCDay(),this.$H=f.getUTCHours(),this.$m=f.getUTCMinutes(),this.$s=f.getUTCSeconds(),this.$ms=f.getUTCMilliseconds()}else h.call(this)};var v=u.utcOffset;u.utcOffset=function(f,y){var d=this.$utils().u;if(d(f))return this.$u?0:d(this.$offset)?v.call(this):this.$offset;if(typeof f=="string"&&(f=function(b){b===void 0&&(b="");var D=b.match(r);if(!D)return null;var m=(""+D[0]).match(o)||["-",0,0],$=m[0],k=60*+m[1]+ +m[2];return k===0?0:$==="+"?k:-k}(f),f===null))return this;var w=Math.abs(f)<=16?60*f:f,S=this;if(y)return S.$offset=w,S.$u=f===0,S;if(f!==0){var p=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(S=this.local().add(w+p,t)).$offset=w,S.$x.$localOffset=p}else S=this.utc();return S};var g=u.format;u.format=function(f){var y=f||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,y)},u.valueOf=function(){var f=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*f},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var T=u.toDate;u.toDate=function(f){return f==="s"&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():T.call(this)};var x=u.diff;u.diff=function(f,y,d){if(f&&this.$u===f.$u)return x.call(this,f,y,d);var w=this.local(),S=i(f).local();return x.call(w,S,y,d)}}})}(Qe)),Qe.exports}var ur=cr();const dr=Le(ur);var Ze={exports:{}},mr=Ze.exports,Gt;function fr(){return Gt||(Gt=1,function(n,e){(function(t,r){n.exports=r()})(mr,function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(o,l,s){var i,u=function(g,T,x){x===void 0&&(x={});var f=new Date(g),y=function(d,w){w===void 0&&(w={});var S=w.timeZoneName||"short",p=d+"|"+S,b=r[p];return b||(b=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:S}),r[p]=b),b}(T,x);return y.formatToParts(f)},c=function(g,T){for(var x=u(g,T),f=[],y=0;y<x.length;y+=1){var d=x[y],w=d.type,S=d.value,p=t[w];p>=0&&(f[p]=parseInt(S,10))}var b=f[3],D=b===24?0:b,m=f[0]+"-"+f[1]+"-"+f[2]+" "+D+":"+f[4]+":"+f[5]+":000",$=+g;return(s.utc(m).valueOf()-($-=$%1e3))/6e4},h=l.prototype;h.tz=function(g,T){g===void 0&&(g=i);var x,f=this.utcOffset(),y=this.toDate(),d=y.toLocaleString("en-US",{timeZone:g}),w=Math.round((y-new Date(d))/1e3/60),S=15*-Math.round(y.getTimezoneOffset()/15)-w;if(!Number(S))x=this.utcOffset(0,T);else if(x=s(d,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(S,!0),T){var p=x.utcOffset();x=x.add(f-p,"minute")}return x.$x.$timezone=g,x},h.offsetName=function(g){var T=this.$x.$timezone||s.tz.guess(),x=u(this.valueOf(),T,{timeZoneName:g}).find(function(f){return f.type.toLowerCase()==="timezonename"});return x&&x.value};var v=h.startOf;h.startOf=function(g,T){if(!this.$x||!this.$x.$timezone)return v.call(this,g,T);var x=s(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return v.call(x,g,T).tz(this.$x.$timezone,!0)},s.tz=function(g,T,x){var f=x&&T,y=x||T||i,d=c(+s(),y);if(typeof g!="string")return s(g).tz(y);var w=function(D,m,$){var k=D-60*m*1e3,O=c(k,$);if(m===O)return[k,m];var H=c(k-=60*(O-m)*1e3,$);return O===H?[k,O]:[D-60*Math.min(O,H)*1e3,Math.max(O,H)]}(s.utc(g,f).valueOf(),d,y),S=w[0],p=w[1],b=s(S).utcOffset(p);return b.$x.$timezone=y,b},s.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},s.tz.setDefault=function(g){i=g}}})}(Ze)),Ze.exports}var hr=fr();const pr=Le(hr);var Ge={exports:{}},gr=Ge.exports,Xt;function yr(){return Xt||(Xt=1,function(n,e){(function(t,r){n.exports=r()})(gr,function(){var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,o=/\d/,l=/\d\d/,s=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,u={},c=function(y){return(y=+y)+(y>68?1900:2e3)},h=function(y){return function(d){this[y]=+d}},v=[/[+-]\d\d:?(\d\d)?|Z/,function(y){(this.zone||(this.zone={})).offset=function(d){if(!d||d==="Z")return 0;var w=d.match(/([+-]|\d\d)/g),S=60*w[1]+(+w[2]||0);return S===0?0:w[0]==="+"?-S:S}(y)}],g=function(y){var d=u[y];return d&&(d.indexOf?d:d.s.concat(d.f))},T=function(y,d){var w,S=u.meridiem;if(S){for(var p=1;p<=24;p+=1)if(y.indexOf(S(p,0,d))>-1){w=p>12;break}}else w=y===(d?"pm":"PM");return w},x={A:[i,function(y){this.afternoon=T(y,!1)}],a:[i,function(y){this.afternoon=T(y,!0)}],Q:[o,function(y){this.month=3*(y-1)+1}],S:[o,function(y){this.milliseconds=100*+y}],SS:[l,function(y){this.milliseconds=10*+y}],SSS:[/\d{3}/,function(y){this.milliseconds=+y}],s:[s,h("seconds")],ss:[s,h("seconds")],m:[s,h("minutes")],mm:[s,h("minutes")],H:[s,h("hours")],h:[s,h("hours")],HH:[s,h("hours")],hh:[s,h("hours")],D:[s,h("day")],DD:[l,h("day")],Do:[i,function(y){var d=u.ordinal,w=y.match(/\d+/);if(this.day=w[0],d)for(var S=1;S<=31;S+=1)d(S).replace(/\[|\]/g,"")===y&&(this.day=S)}],w:[s,h("week")],ww:[l,h("week")],M:[s,h("month")],MM:[l,h("month")],MMM:[i,function(y){var d=g("months"),w=(g("monthsShort")||d.map(function(S){return S.slice(0,3)})).indexOf(y)+1;if(w<1)throw new Error;this.month=w%12||w}],MMMM:[i,function(y){var d=g("months").indexOf(y)+1;if(d<1)throw new Error;this.month=d%12||d}],Y:[/[+-]?\d+/,h("year")],YY:[l,function(y){this.year=c(y)}],YYYY:[/\d{4}/,h("year")],Z:v,ZZ:v};function f(y){var d,w;d=y,w=u&&u.formats;for(var S=(y=d.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(O,H,U){var q=U&&U.toUpperCase();return H||w[U]||t[U]||w[q].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(j,_,V){return _||V.slice(1)})})).match(r),p=S.length,b=0;b<p;b+=1){var D=S[b],m=x[D],$=m&&m[0],k=m&&m[1];S[b]=k?{regex:$,parser:k}:D.replace(/^\[|\]$/g,"")}return function(O){for(var H={},U=0,q=0;U<p;U+=1){var j=S[U];if(typeof j=="string")q+=j.length;else{var _=j.regex,V=j.parser,R=O.slice(q),M=_.exec(R)[0];V.call(H,M),O=O.replace(M,"")}}return function(F){var N=F.afternoon;if(N!==void 0){var K=F.hours;N?K<12&&(F.hours+=12):K===12&&(F.hours=0),delete F.afternoon}}(H),H}}return function(y,d,w){w.p.customParseFormat=!0,y&&y.parseTwoDigitYear&&(c=y.parseTwoDigitYear);var S=d.prototype,p=S.parse;S.parse=function(b){var D=b.date,m=b.utc,$=b.args;this.$u=m;var k=$[1];if(typeof k=="string"){var O=$[2]===!0,H=$[3]===!0,U=O||H,q=$[2];H&&(q=$[2]),u=this.$locale(),!O&&q&&(u=w.Ls[q]),this.$d=function(R,M,F,N){try{if(["x","X"].indexOf(M)>-1)return new Date((M==="X"?1e3:1)*R);var K=f(M)(R),ne=K.year,te=K.month,Y=K.day,C=K.hours,P=K.minutes,Q=K.seconds,W=K.milliseconds,L=K.zone,z=K.week,Z=new Date,le=Y||(ne||te?1:Z.getDate()),se=ne||Z.getFullYear(),me=0;ne&&!te||(me=te>0?te-1:Z.getMonth());var ie,B=C||0,E=P||0,A=Q||0,G=W||0;return L?new Date(Date.UTC(se,me,le,B,E,A,G+60*L.offset*1e3)):F?new Date(Date.UTC(se,me,le,B,E,A,G)):(ie=new Date(se,me,le,B,E,A,G),z&&(ie=N(ie).week(z).toDate()),ie)}catch{return new Date("")}}(D,k,m,w),this.init(),q&&q!==!0&&(this.$L=this.locale(q).$L),U&&D!=this.format(k)&&(this.$d=new Date("")),u={}}else if(k instanceof Array)for(var j=k.length,_=1;_<=j;_+=1){$[1]=k[_-1];var V=w.apply(this,$);if(V.isValid()){this.$d=V.$d,this.$L=V.$L,this.init();break}_===j&&(this.$d=new Date(""))}else p.call(this,b)}}})}(Ge)),Ge.exports}var vr=yr();const ea=Le(vr);var Xe={exports:{}},$r=Xe.exports,ta;function Dr(){return ta||(ta=1,function(n,e){(function(t,r){n.exports=r()})($r,function(){var t="week",r="year";return function(o,l,s){var i=l.prototype;i.week=function(u){if(u===void 0&&(u=null),u!==null)return this.add(7*(u-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var h=s(this).startOf(r).add(1,r).date(c),v=s(this).endOf(t);if(h.isBefore(v))return 1}var g=s(this).startOf(r).date(c).startOf(t).subtract(1,"millisecond"),T=this.diff(g,t,!0);return T<0?s(this).startOf("week").week():Math.ceil(T)},i.weeks=function(u){return u===void 0&&(u=null),this.week(u)}}})}(Xe)),Xe.exports}var kr=Dr();const br=Le(kr);var et={exports:{}},Mr=et.exports,aa;function wr(){return aa||(aa=1,function(n,e){(function(t,r){n.exports=r()})(Mr,function(){return function(t,r,o){var l=r.prototype,s=function(v){return v&&(v.indexOf?v:v.s)},i=function(v,g,T,x,f){var y=v.name?v:v.$locale(),d=s(y[g]),w=s(y[T]),S=d||w.map(function(b){return b.slice(0,x)});if(!f)return S;var p=y.weekStart;return S.map(function(b,D){return S[(D+(p||0))%7]})},u=function(){return o.Ls[o.locale()]},c=function(v,g){return v.formats[g]||function(T){return T.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(x,f,y){return f||y.slice(1)})}(v.formats[g.toUpperCase()])},h=function(){var v=this;return{months:function(g){return g?g.format("MMMM"):i(v,"months")},monthsShort:function(g){return g?g.format("MMM"):i(v,"monthsShort","months",3)},firstDayOfWeek:function(){return v.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):i(v,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):i(v,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):i(v,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return c(v.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};l.localeData=function(){return h.bind(this)()},o.localeData=function(){var v=u();return{firstDayOfWeek:function(){return v.weekStart||0},weekdays:function(){return o.weekdays()},weekdaysShort:function(){return o.weekdaysShort()},weekdaysMin:function(){return o.weekdaysMin()},months:function(){return o.months()},monthsShort:function(){return o.monthsShort()},longDateFormat:function(g){return c(v,g)},meridiem:v.meridiem,ordinal:v.ordinal}},o.months=function(){return i(u(),"months")},o.monthsShort=function(){return i(u(),"monthsShort","months",3)},o.weekdays=function(v){return i(u(),"weekdays",null,null,v)},o.weekdaysShort=function(v){return i(u(),"weekdaysShort","weekdays",3,v)},o.weekdaysMin=function(v){return i(u(),"weekdaysMin","weekdays",2,v)}}})}(et)),et.exports}var Sr=wr();const Tr=Le(Sr);ae.extend(ea);const ra={"en-US":["MM/DD/YYYY","M/D/YYYY"],"en-GB":["DD/MM/YYYY","D/M/YYYY"],"zh-TW":["YYYY-MM-DD","YYYY/MM/DD"],"zh-CN":["YYYY-MM-DD","YYYY/MM/DD"]},na=["YYYY-MM-DD","YYYY/MM/DD","DD/MM/YYYY","MM/DD/YYYY","DD-MM-YYYY","MM-DD-YYYY","YY-MM-DD","YY/MM/DD"];class xr{locale;calendar;preferredFormats;constructor(e="zh-TW",t="gregory"){this.locale=e,this.calendar=t,this.preferredFormats=[...ra[e]||[],...na]}parse(e){if(!e||typeof e!="string")return{success:!1,date:null,format:null,confidence:0};const t=e.trim();try{const r=this.tryParseWithPlugins(t);if(r.success)return r;for(const o of this.preferredFormats){const l=this.tryParseWithFormat(t,o);if(l.success)return{...l,confidence:.9}}return this.fallbackParse(t)}catch(r){return console.warn("日期解析失敗:",r),{success:!1,date:null,format:null,confidence:0}}}tryParseWithPlugins(e){switch(this.calendar){case"roc":const t=new Lt;if(t.canParseInput(e)){const r=t.parseInput(e,this.locale);if(r)return{success:!0,date:r,format:"roc-plugin",confidence:.95,calendarSystem:"roc"}}break}return{success:!1,date:null,format:null,confidence:0}}tryParseWithFormat(e,t){try{const r=ae(e,t,!0);if(r.isValid())return{success:!0,date:{year:r.year(),month:r.month()+1,day:r.date(),hour:r.hour()||0,minute:r.minute()||0,second:r.second()||0},format:t,confidence:1,calendarSystem:"gregory"}}catch{}return{success:!1,date:null,format:null,confidence:0}}fallbackParse(e){try{const t=ae(e);if(t.isValid())return{success:!0,date:{year:t.year(),month:t.month()+1,day:t.date(),hour:t.hour()||0,minute:t.minute()||0,second:t.second()||0},format:"auto-detected",confidence:.6,calendarSystem:"gregory"}}catch{}return{success:!1,date:null,format:null,confidence:0}}setLocale(e){this.locale=e,this.preferredFormats=[...ra[e]||[],...na]}setCalendar(e){this.calendar=e}}const He=new xr;function Er(n,e="zh-TW",t="gregory"){return e!==He.locale&&He.setLocale(e),t!==He.calendar&&He.setCalendar(t),He.parse(n)}function Ce(n,e){return n-e*Math.floor(n/e)}const oa=1721426;function Te(n,e,t,r){e=qe(n,e);let o=e-1,l=-2;return t<=2?l=0:Me(e)&&(l=-1),oa-1+365*o+Math.floor(o/4)-Math.floor(o/100)+Math.floor(o/400)+Math.floor((367*t-362)/12+l+r)}function Me(n){return n%4===0&&(n%100!==0||n%400===0)}function qe(n,e){return n==="BC"?1-e:e}function tt(n){let e="AD";return n<=0&&(e="BC",n=1-n),[e,n]}const Cr={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class ce{fromJulianDay(e){let t=e,r=t-oa,o=Math.floor(r/146097),l=Ce(r,146097),s=Math.floor(l/36524),i=Ce(l,36524),u=Math.floor(i/1461),c=Ce(i,1461),h=Math.floor(c/365),v=o*400+s*100+u*4+h+(s!==4&&h!==4?1:0),[g,T]=tt(v),x=t-Te(g,T,1,1),f=2;t<Te(g,T,3,1)?f=0:Me(T)&&(f=1);let y=Math.floor(((x+f)*12+373)/367),d=t-Te(g,T,y,1)+1;return new ee(g,T,y,d)}toJulianDay(e){return Te(e.era,e.year,e.month,e.day)}getDaysInMonth(e){return Cr[Me(e.year)?"leapyear":"standard"][e.month-1]}getMonthsInYear(e){return 12}getDaysInYear(e){return Me(e.year)?366:365}getYearsInEra(e){return 9999}getEras(){return["BC","AD"]}isInverseEra(e){return e.era==="BC"}balanceDate(e){e.year<=0&&(e.era=e.era==="BC"?"AD":"BC",e.year=1-e.year)}constructor(){this.identifier="gregory"}}const Yr={"001":1,AD:1,AE:6,AF:6,AI:1,AL:1,AM:1,AN:1,AR:1,AT:1,AU:1,AX:1,AZ:1,BA:1,BE:1,BG:1,BH:6,BM:1,BN:1,BY:1,CH:1,CL:1,CM:1,CN:1,CR:1,CY:1,CZ:1,DE:1,DJ:6,DK:1,DZ:6,EC:1,EE:1,EG:6,ES:1,FI:1,FJ:1,FO:1,FR:1,GB:1,GE:1,GF:1,GP:1,GR:1,HR:1,HU:1,IE:1,IQ:6,IR:6,IS:1,IT:1,JO:6,KG:1,KW:6,KZ:1,LB:1,LI:1,LK:1,LT:1,LU:1,LV:1,LY:6,MC:1,MD:1,ME:1,MK:1,MN:1,MQ:1,MV:5,MY:1,NL:1,NO:1,NZ:1,OM:6,PL:1,QA:6,RE:1,RO:1,RS:1,RU:1,SD:6,SE:1,SI:1,SK:1,SM:1,SY:6,TJ:1,TM:1,TR:1,UA:1,UY:1,UZ:1,VA:1,VN:1,XK:1};function Rr(n,e){var t,r,o,l;return(l=(o=(t=n.isEqual)===null||t===void 0?void 0:t.call(n,e))!==null&&o!==void 0?o:(r=e.isEqual)===null||r===void 0?void 0:r.call(e,n))!==null&&l!==void 0?l:n.identifier===e.identifier}function la(n,e,t){let r=n.calendar.toJulianDay(n),o=Pr(e),l=Math.ceil(r+1-o)%7;return l<0&&(l+=7),l}function Vr(n){return ve(Date.now(),n)}function Ir(n){return Hr(Vr(n))}function sa(n,e){return n.calendar.toJulianDay(n)-e.calendar.toJulianDay(e)}function Br(n,e){return ia(n)-ia(e)}function ia(n){return n.hour*36e5+n.minute*6e4+n.second*1e3+n.millisecond}let vt=null;function $t(){return vt==null&&(vt=new Intl.DateTimeFormat().resolvedOptions().timeZone),vt}function Or(n){return n.subtract({days:n.day-1})}const ca=new Map;function Fr(n){if(Intl.Locale){let t=ca.get(n);return t||(t=new Intl.Locale(n).maximize().region,t&&ca.set(n,t)),t}let e=n.split("-")[1];return e==="u"?void 0:e}function Pr(n){let e=Fr(n);return e&&Yr[e]||0}function Nr(n,e,t){let r=n.calendar.getDaysInMonth(n);return Math.ceil((la(Or(n),e)+r)/7)}function Ye(n){n=ue(n,new ce);let e=qe(n.era,n.year);return ua(e,n.month,n.day,n.hour,n.minute,n.second,n.millisecond)}function ua(n,e,t,r,o,l,s){let i=new Date;return i.setUTCHours(r,o,l,s),i.setUTCFullYear(n,e-1,t),i.getTime()}function Dt(n,e){if(e==="UTC")return 0;if(n>0&&e===$t())return new Date(n).getTimezoneOffset()*-6e4;let{year:t,month:r,day:o,hour:l,minute:s,second:i}=ma(n,e);return ua(t,r,o,l,s,i,0)-Math.floor(n/1e3)*1e3}const da=new Map;function ma(n,e){let t=da.get(e);t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),da.set(e,t));let r=t.formatToParts(new Date(n)),o={};for(let l of r)l.type!=="literal"&&(o[l.type]=l.value);return{year:o.era==="BC"||o.era==="B"?-o.year+1:+o.year,month:+o.month,day:+o.day,hour:o.hour==="24"?0:+o.hour,minute:+o.minute,second:+o.second}}const fa=864e5;function Ar(n,e,t,r){return(t===r?[t]:[t,r]).filter(l=>Lr(n,e,l))}function Lr(n,e,t){let r=ma(t,e);return n.year===r.year&&n.month===r.month&&n.day===r.day&&n.hour===r.hour&&n.minute===r.minute&&n.second===r.second}function ye(n,e,t="compatible"){let r=Re(n);if(e==="UTC")return Ye(r);if(e===$t()&&t==="compatible"){r=ue(r,new ce);let u=new Date,c=qe(r.era,r.year);return u.setFullYear(c,r.month-1,r.day),u.setHours(r.hour,r.minute,r.second,r.millisecond),u.getTime()}let o=Ye(r),l=Dt(o-fa,e),s=Dt(o+fa,e),i=Ar(r,e,o-l,o-s);if(i.length===1)return i[0];if(i.length>1)switch(t){case"compatible":case"earlier":return i[0];case"later":return i[i.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(t){case"earlier":return Math.min(o-l,o-s);case"compatible":case"later":return Math.max(o-l,o-s);case"reject":throw new RangeError("No such absolute time found")}}function ha(n,e,t="compatible"){return new Date(ye(n,e,t))}function ve(n,e){let t=Dt(n,e),r=new Date(n+t),o=r.getUTCFullYear(),l=r.getUTCMonth()+1,s=r.getUTCDate(),i=r.getUTCHours(),u=r.getUTCMinutes(),c=r.getUTCSeconds(),h=r.getUTCMilliseconds();return new ze(o<1?"BC":"AD",o<1?-o+1:o,l,s,e,t,i,u,c,h)}function Hr(n){return new ee(n.calendar,n.era,n.year,n.month,n.day)}function Re(n,e){let t=0,r=0,o=0,l=0;if("timeZone"in n)({hour:t,minute:r,second:o,millisecond:l}=n);else if("hour"in n&&!e)return n;return e&&({hour:t,minute:r,second:o,millisecond:l}=e),new Ve(n.calendar,n.era,n.year,n.month,n.day,t,r,o,l)}function ue(n,e){if(Rr(n.calendar,e))return n;let t=e.fromJulianDay(n.calendar.toJulianDay(n)),r=n.copy();return r.calendar=e,r.era=t.era,r.year=t.year,r.month=t.month,r.day=t.day,xe(r),r}function qr(n,e,t){if(n instanceof ze)return n.timeZone===e?n:zr(n,e);let r=ye(n,e,t);return ve(r,e)}function Ur(n){let e=Ye(n)-n.offset;return new Date(e)}function zr(n,e){let t=Ye(n)-n.offset;return ue(ve(t,e),n.calendar)}const Ue=36e5;function at(n,e){let t=n.copy(),r="hour"in t?jr(t,e):0;kt(t,e.years||0),t.calendar.balanceYearMonth&&t.calendar.balanceYearMonth(t,n),t.month+=e.months||0,bt(t),pa(t),t.day+=(e.weeks||0)*7,t.day+=e.days||0,t.day+=r,Wr(t),t.calendar.balanceDate&&t.calendar.balanceDate(t),t.year<1&&(t.year=1,t.month=1,t.day=1);let o=t.calendar.getYearsInEra(t);if(t.year>o){var l,s;let u=(l=(s=t.calendar).isInverseEra)===null||l===void 0?void 0:l.call(s,t);t.year=o,t.month=u?1:t.calendar.getMonthsInYear(t),t.day=u?1:t.calendar.getDaysInMonth(t)}t.month<1&&(t.month=1,t.day=1);let i=t.calendar.getMonthsInYear(t);return t.month>i&&(t.month=i,t.day=t.calendar.getDaysInMonth(t)),t.day=Math.max(1,Math.min(t.calendar.getDaysInMonth(t),t.day)),t}function kt(n,e){var t,r;!((t=(r=n.calendar).isInverseEra)===null||t===void 0)&&t.call(r,n)&&(e=-e),n.year+=e}function bt(n){for(;n.month<1;)kt(n,-1),n.month+=n.calendar.getMonthsInYear(n);let e=0;for(;n.month>(e=n.calendar.getMonthsInYear(n));)n.month-=e,kt(n,1)}function Wr(n){for(;n.day<1;)n.month--,bt(n),n.day+=n.calendar.getDaysInMonth(n);for(;n.day>n.calendar.getDaysInMonth(n);)n.day-=n.calendar.getDaysInMonth(n),n.month++,bt(n)}function pa(n){n.month=Math.max(1,Math.min(n.calendar.getMonthsInYear(n),n.month)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day))}function xe(n){n.calendar.constrainDate&&n.calendar.constrainDate(n),n.year=Math.max(1,Math.min(n.calendar.getYearsInEra(n),n.year)),pa(n)}function ga(n){let e={};for(let t in n)typeof n[t]=="number"&&(e[t]=-n[t]);return e}function ya(n,e){return at(n,ga(e))}function Mt(n,e){let t=n.copy();return e.era!=null&&(t.era=e.era),e.year!=null&&(t.year=e.year),e.month!=null&&(t.month=e.month),e.day!=null&&(t.day=e.day),xe(t),t}function rt(n,e){let t=n.copy();return e.hour!=null&&(t.hour=e.hour),e.minute!=null&&(t.minute=e.minute),e.second!=null&&(t.second=e.second),e.millisecond!=null&&(t.millisecond=e.millisecond),Jr(t),t}function _r(n){n.second+=Math.floor(n.millisecond/1e3),n.millisecond=nt(n.millisecond,1e3),n.minute+=Math.floor(n.second/60),n.second=nt(n.second,60),n.hour+=Math.floor(n.minute/60),n.minute=nt(n.minute,60);let e=Math.floor(n.hour/24);return n.hour=nt(n.hour,24),e}function Jr(n){n.millisecond=Math.max(0,Math.min(n.millisecond,1e3)),n.second=Math.max(0,Math.min(n.second,59)),n.minute=Math.max(0,Math.min(n.minute,59)),n.hour=Math.max(0,Math.min(n.hour,23))}function nt(n,e){let t=n%e;return t<0&&(t+=e),t}function jr(n,e){return n.hour+=e.hours||0,n.minute+=e.minutes||0,n.second+=e.seconds||0,n.millisecond+=e.milliseconds||0,_r(n)}function wt(n,e,t,r){let o=n.copy();switch(e){case"era":{let i=n.calendar.getEras(),u=i.indexOf(n.era);if(u<0)throw new Error("Invalid era: "+n.era);u=$e(u,t,0,i.length-1,r?.round),o.era=i[u],xe(o);break}case"year":var l,s;!((l=(s=o.calendar).isInverseEra)===null||l===void 0)&&l.call(s,o)&&(t=-t),o.year=$e(n.year,t,-1/0,9999,r?.round),o.year===-1/0&&(o.year=1),o.calendar.balanceYearMonth&&o.calendar.balanceYearMonth(o,n);break;case"month":o.month=$e(n.month,t,1,n.calendar.getMonthsInYear(n),r?.round);break;case"day":o.day=$e(n.day,t,1,n.calendar.getDaysInMonth(n),r?.round);break;default:throw new Error("Unsupported field "+e)}return n.calendar.balanceDate&&n.calendar.balanceDate(o),xe(o),o}function va(n,e,t,r){let o=n.copy();switch(e){case"hour":{let l=n.hour,s=0,i=23;if(r?.hourCycle===12){let u=l>=12;s=u?12:0,i=u?23:11}o.hour=$e(l,t,s,i,r?.round);break}case"minute":o.minute=$e(n.minute,t,0,59,r?.round);break;case"second":o.second=$e(n.second,t,0,59,r?.round);break;case"millisecond":o.millisecond=$e(n.millisecond,t,0,999,r?.round);break;default:throw new Error("Unsupported field "+e)}return o}function $e(n,e,t,r,o=!1){if(o){n+=Math.sign(e),n<t&&(n=r);let l=Math.abs(e);e>0?n=Math.ceil(n/l)*l:n=Math.floor(n/l)*l,n>r&&(n=t)}else n+=e,n<t?n=r-(t-n-1):n>r&&(n=t+(n-r-1));return n}function $a(n,e){let t;if(e.years!=null&&e.years!==0||e.months!=null&&e.months!==0||e.weeks!=null&&e.weeks!==0||e.days!=null&&e.days!==0){let o=at(Re(n),{years:e.years,months:e.months,weeks:e.weeks,days:e.days});t=ye(o,n.timeZone)}else t=Ye(n)-n.offset;t+=e.milliseconds||0,t+=(e.seconds||0)*1e3,t+=(e.minutes||0)*6e4,t+=(e.hours||0)*36e5;let r=ve(t,n.timeZone);return ue(r,n.calendar)}function Kr(n,e){return $a(n,ga(e))}function Qr(n,e,t,r){switch(e){case"hour":{let o=0,l=23;if(r?.hourCycle===12){let x=n.hour>=12;o=x?12:0,l=x?23:11}let s=Re(n),i=ue(rt(s,{hour:o}),new ce),u=[ye(i,n.timeZone,"earlier"),ye(i,n.timeZone,"later")].filter(x=>ve(x,n.timeZone).day===i.day)[0],c=ue(rt(s,{hour:l}),new ce),h=[ye(c,n.timeZone,"earlier"),ye(c,n.timeZone,"later")].filter(x=>ve(x,n.timeZone).day===c.day).pop(),v=Ye(n)-n.offset,g=Math.floor(v/Ue),T=v%Ue;return v=$e(g,t,Math.floor(u/Ue),Math.floor(h/Ue),r?.round)*Ue+T,ue(ve(v,n.timeZone),n.calendar)}case"minute":case"second":case"millisecond":return va(n,e,t,r);case"era":case"year":case"month":case"day":{let o=wt(Re(n),e,t,r),l=ye(o,n.timeZone);return ue(ve(l,n.timeZone),n.calendar)}default:throw new Error("Unsupported field "+e)}}function Zr(n,e,t){let r=Re(n),o=rt(Mt(r,e),e);if(o.compare(r)===0)return n;let l=ye(o,n.timeZone,t);return ue(ve(l,n.timeZone),n.calendar)}function Gr(n){return`${String(n.hour).padStart(2,"0")}:${String(n.minute).padStart(2,"0")}:${String(n.second).padStart(2,"0")}${n.millisecond?String(n.millisecond/1e3).slice(1):""}`}function Da(n){let e=ue(n,new ce),t;return e.era==="BC"?t=e.year===1?"0000":"-"+String(Math.abs(1-e.year)).padStart(6,"00"):t=String(e.year).padStart(4,"0"),`${t}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`}function ka(n){return`${Da(n)}T${Gr(n)}`}function Xr(n){let e=Math.sign(n)<0?"-":"+";n=Math.abs(n);let t=Math.floor(n/36e5),r=n%36e5/6e4;return`${e}${String(t).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function en(n){return`${ka(n)}${Xr(n.offset)}[${n.timeZone}]`}function tn(n,e){if(e.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object")}function St(n,e,t){tn(n,e),e.set(n,t)}function Tt(n){let e=typeof n[0]=="object"?n.shift():new ce,t;if(typeof n[0]=="string")t=n.shift();else{let s=e.getEras();t=s[s.length-1]}let r=n.shift(),o=n.shift(),l=n.shift();return[e,t,r,o,l]}var an=new WeakMap;class ee{copy(){return this.era?new ee(this.calendar,this.era,this.year,this.month,this.day):new ee(this.calendar,this.year,this.month,this.day)}add(e){return at(this,e)}subtract(e){return ya(this,e)}set(e){return Mt(this,e)}cycle(e,t,r){return wt(this,e,t,r)}toDate(e){return ha(this,e)}toString(){return Da(this)}compare(e){return sa(this,e)}constructor(...e){St(this,an,{writable:!0,value:void 0});let[t,r,o,l,s]=Tt(e);this.calendar=t,this.era=r,this.year=o,this.month=l,this.day=s,xe(this)}}var rn=new WeakMap;class Ve{copy(){return this.era?new Ve(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new Ve(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(e){return at(this,e)}subtract(e){return ya(this,e)}set(e){return Mt(rt(this,e),e)}cycle(e,t,r){switch(e){case"era":case"year":case"month":case"day":return wt(this,e,t,r);default:return va(this,e,t,r)}}toDate(e,t){return ha(this,e,t)}toString(){return ka(this)}compare(e){let t=sa(this,e);return t===0?Br(this,Re(e)):t}constructor(...e){St(this,rn,{writable:!0,value:void 0});let[t,r,o,l,s]=Tt(e);this.calendar=t,this.era=r,this.year=o,this.month=l,this.day=s,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,xe(this)}}var nn=new WeakMap;class ze{copy(){return this.era?new ze(this.calendar,this.era,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond):new ze(this.calendar,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond)}add(e){return $a(this,e)}subtract(e){return Kr(this,e)}set(e,t){return Zr(this,e,t)}cycle(e,t,r){return Qr(this,e,t,r)}toDate(){return Ur(this)}toString(){return en(this)}toAbsoluteString(){return this.toDate().toISOString()}compare(e){return this.toDate().getTime()-qr(e,this.timeZone).toDate().getTime()}constructor(...e){St(this,nn,{writable:!0,value:void 0});let[t,r,o,l,s]=Tt(e),i=e.shift(),u=e.shift();this.calendar=t,this.era=r,this.year=o,this.month=l,this.day=s,this.timeZone=i,this.offset=u,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,xe(this)}}const Ie=[[1868,9,8],[1912,7,30],[1926,12,25],[1989,1,8],[2019,5,1]],on=[[1912,7,29],[1926,12,24],[1989,1,7],[2019,4,30]],ot=[1867,1911,1925,1988,2018],we=["meiji","taisho","showa","heisei","reiwa"];function ba(n){const e=Ie.findIndex(([t,r,o])=>n.year<t||n.year===t&&n.month<r||n.year===t&&n.month===r&&n.day<o);return e===-1?Ie.length-1:e===0?0:e-1}function xt(n){let e=ot[we.indexOf(n.era)];if(!e)throw new Error("Unknown era: "+n.era);return new ee(n.year+e,n.month,n.day)}class ln extends ce{fromJulianDay(e){let t=super.fromJulianDay(e),r=ba(t);return new ee(this,we[r],t.year-ot[r],t.month,t.day)}toJulianDay(e){return super.toJulianDay(xt(e))}balanceDate(e){let t=xt(e),r=ba(t);we[r]!==e.era&&(e.era=we[r],e.year=t.year-ot[r]),this.constrainDate(e)}constrainDate(e){let t=we.indexOf(e.era),r=on[t];if(r!=null){let[o,l,s]=r,i=o-ot[t];e.year=Math.max(1,Math.min(i,e.year)),e.year===i&&(e.month=Math.min(l,e.month),e.month===l&&(e.day=Math.min(s,e.day)))}if(e.year===1&&t>=0){let[,o,l]=Ie[t];e.month=Math.max(o,e.month),e.month===o&&(e.day=Math.max(l,e.day))}}getEras(){return we}getYearsInEra(e){let t=we.indexOf(e.era),r=Ie[t],o=Ie[t+1];if(o==null)return 9999-r[0]+1;let l=o[0]-r[0];return(e.month<o[1]||e.month===o[1]&&e.day<o[2])&&l++,l}getDaysInMonth(e){return super.getDaysInMonth(xt(e))}getMinimumMonthInYear(e){let t=Ma(e);return t?t[1]:1}getMinimumDayInMonth(e){let t=Ma(e);return t&&e.month===t[1]?t[2]:1}constructor(...e){super(...e),this.identifier="japanese"}}function Ma(n){if(n.year===1){let e=we.indexOf(n.era);return Ie[e]}}const wa=-543;class sn extends ce{fromJulianDay(e){let t=super.fromJulianDay(e),r=qe(t.era,t.year);return new ee(this,r-wa,t.month,t.day)}toJulianDay(e){return super.toJulianDay(Sa(e))}getEras(){return["BE"]}getDaysInMonth(e){return super.getDaysInMonth(Sa(e))}balanceDate(){}constructor(...e){super(...e),this.identifier="buddhist"}}function Sa(n){let[e,t]=tt(n.year+wa);return new ee(e,t,n.month,n.day)}const lt=1911;function Ta(n){return n.era==="minguo"?n.year+lt:1-n.year+lt}function xa(n){let e=n-lt;return e>0?["minguo",e]:["before_minguo",1-e]}class cn extends ce{fromJulianDay(e){let t=super.fromJulianDay(e),r=qe(t.era,t.year),[o,l]=xa(r);return new ee(this,o,l,t.month,t.day)}toJulianDay(e){return super.toJulianDay(Ea(e))}getEras(){return["before_minguo","minguo"]}balanceDate(e){let[t,r]=xa(Ta(e));e.era=t,e.year=r}isInverseEra(e){return e.era==="before_minguo"}getDaysInMonth(e){return super.getDaysInMonth(Ea(e))}getYearsInEra(e){return e.era==="before_minguo"?9999:9999-lt}constructor(...e){super(...e),this.identifier="roc"}}function Ea(n){let[e,t]=tt(Ta(n));return new ee(e,t,n.month,n.day)}const Ca=1948320,Ya=[0,31,62,93,124,155,186,216,246,276,306,336];class un{fromJulianDay(e){let t=e-Ca,r=1+Math.floor((33*t+3)/12053),o=365*(r-1)+Math.floor((8*r+21)/33),l=t-o,s=l<216?Math.floor(l/31):Math.floor((l-6)/30),i=l-Ya[s]+1;return new ee(this,r,s+1,i)}toJulianDay(e){let t=Ca-1+365*(e.year-1)+Math.floor((8*e.year+21)/33);return t+=Ya[e.month-1],t+=e.day,t}getMonthsInYear(){return 12}getDaysInMonth(e){return e.month<=6?31:e.month<=11||Ce(25*e.year+11,33)<8?30:29}getEras(){return["AP"]}getYearsInEra(){return 9377}constructor(){this.identifier="persian"}}const Et=78,Ra=80;class dn extends ce{fromJulianDay(e){let t=super.fromJulianDay(e),r=t.year-Et,o=e-Te(t.era,t.year,1,1),l;o<Ra?(r--,l=Me(t.year-1)?31:30,o+=l+155+90+10):(l=Me(t.year)?31:30,o-=Ra);let s,i;if(o<l)s=1,i=o+1;else{let u=o-l;u<155?(s=Math.floor(u/31)+2,i=u%31+1):(u-=155,s=Math.floor(u/30)+7,i=u%30+1)}return new ee(this,r,s,i)}toJulianDay(e){let t=e.year+Et,[r,o]=tt(t),l,s;return Me(o)?(l=31,s=Te(r,o,3,21)):(l=30,s=Te(r,o,3,22)),e.month===1?s+e.day-1:(s+=l+Math.min(e.month-2,5)*31,e.month>=8&&(s+=(e.month-7)*30),s+=e.day-1,s)}getDaysInMonth(e){return e.month===1&&Me(e.year+Et)||e.month>=2&&e.month<=6?31:30}getYearsInEra(){return 9919}getEras(){return["saka"]}balanceDate(){}constructor(...e){super(...e),this.identifier="indian"}}const st=1948440,Va=1948439,he=1300,Be=1600,mn=460322;function it(n,e,t,r){return r+Math.ceil(29.5*(t-1))+(e-1)*354+Math.floor((3+11*e)/30)+n-1}function Ia(n,e,t){let r=Math.floor((30*(t-e)+10646)/10631),o=Math.min(12,Math.ceil((t-(29+it(e,r,1,1)))/29.5)+1),l=t-it(e,r,o,1)+1;return new ee(n,r,o,l)}function Ba(n){return(14+11*n)%30<11}class Ct{fromJulianDay(e){return Ia(this,st,e)}toJulianDay(e){return it(st,e.year,e.month,e.day)}getDaysInMonth(e){let t=29+e.month%2;return e.month===12&&Ba(e.year)&&t++,t}getMonthsInYear(){return 12}getDaysInYear(e){return Ba(e.year)?355:354}getYearsInEra(){return 9665}getEras(){return["AH"]}constructor(){this.identifier="islamic-civil"}}class fn extends Ct{fromJulianDay(e){return Ia(this,Va,e)}toJulianDay(e){return it(Va,e.year,e.month,e.day)}constructor(...e){super(...e),this.identifier="islamic-tbla"}}const hn="qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=";let Yt,Oe;function ct(n){return mn+Oe[n-he]}function We(n,e){let t=n-he,r=1<<11-(e-1);return(Yt[t]&r)===0?29:30}function Oa(n,e){let t=ct(n);for(let r=1;r<e;r++)t+=We(n,r);return t}function Fa(n){return Oe[n+1-he]-Oe[n-he]}class pn extends Ct{fromJulianDay(e){let t=e-st,r=ct(he),o=ct(Be);if(t<r||t>o)return super.fromJulianDay(e);{let l=he-1,s=1,i=1;for(;i>0;){l++,i=t-ct(l)+1;let u=Fa(l);if(i===u){s=12;break}else if(i<u){let c=We(l,s);for(s=1;i>c;)i-=c,s++,c=We(l,s);break}}return new ee(this,l,s,t-Oa(l,s)+1)}}toJulianDay(e){return e.year<he||e.year>Be?super.toJulianDay(e):st+Oa(e.year,e.month)+(e.day-1)}getDaysInMonth(e){return e.year<he||e.year>Be?super.getDaysInMonth(e):We(e.year,e.month)}getDaysInYear(e){return e.year<he||e.year>Be?super.getDaysInYear(e):Fa(e.year)}constructor(){if(super(),this.identifier="islamic-umalqura",Yt||(Yt=new Uint16Array(Uint8Array.from(atob(hn),e=>e.charCodeAt(0)).buffer)),!Oe){Oe=new Uint32Array(Be-he+1);let e=0;for(let t=he;t<=Be;t++){Oe[t-he]=e;for(let r=1;r<=12;r++)e+=We(t,r)}}}}const Pa=347997,Na=1080,Aa=24*Na,gn=29,yn=12*Na+793,vn=gn*Aa+yn;function Ee(n){return Ce(n*7+1,19)<7}function ut(n){let e=Math.floor((235*n-234)/19),t=12084+13753*e,r=e*29+Math.floor(t/25920);return Ce(3*(r+1),7)<3&&(r+=1),r}function $n(n){let e=ut(n-1),t=ut(n);return ut(n+1)-t===356?2:t-e===382?1:0}function _e(n){return ut(n)+$n(n)}function La(n){return _e(n+1)-_e(n)}function Dn(n){let e=La(n);switch(e>380&&(e-=30),e){case 353:return 0;case 354:return 1;case 355:return 2}}function dt(n,e){if(e>=6&&!Ee(n)&&e++,e===4||e===7||e===9||e===11||e===13)return 29;let t=Dn(n);return e===2?t===2?30:29:e===3?t===0?29:30:e===6?Ee(n)?30:0:30}class kn{fromJulianDay(e){let t=e-Pa,r=t*Aa/vn,o=Math.floor((19*r+234)/235)+1,l=_e(o),s=Math.floor(t-l);for(;s<1;)o--,l=_e(o),s=Math.floor(t-l);let i=1,u=0;for(;u<s;)u+=dt(o,i),i++;i--,u-=dt(o,i);let c=s-u;return new ee(this,o,i,c)}toJulianDay(e){let t=_e(e.year);for(let r=1;r<e.month;r++)t+=dt(e.year,r);return t+e.day+Pa}getDaysInMonth(e){return dt(e.year,e.month)}getMonthsInYear(e){return Ee(e.year)?13:12}getDaysInYear(e){return La(e.year)}getYearsInEra(){return 9999}getEras(){return["AM"]}balanceYearMonth(e,t){t.year!==e.year&&(Ee(t.year)&&!Ee(e.year)&&t.month>6?e.month--:!Ee(t.year)&&Ee(e.year)&&t.month>6&&e.month++)}constructor(){this.identifier="hebrew"}}const Rt=1723856,Ha=1824665,Vt=5500;function mt(n,e,t,r){return n+365*e+Math.floor(e/4)+30*(t-1)+r-1}function It(n,e){let t=Math.floor(4*(e-n)/1461),r=1+Math.floor((e-mt(n,t,1,1))/30),o=e+1-mt(n,t,r,1);return[t,r,o]}function qa(n){return Math.floor(n%4/3)}function Ua(n,e){return e%13!==0?30:qa(n)+5}class Bt{fromJulianDay(e){let[t,r,o]=It(Rt,e),l="AM";return t<=0&&(l="AA",t+=Vt),new ee(this,l,t,r,o)}toJulianDay(e){let t=e.year;return e.era==="AA"&&(t-=Vt),mt(Rt,t,e.month,e.day)}getDaysInMonth(e){return Ua(e.year,e.month)}getMonthsInYear(){return 13}getDaysInYear(e){return 365+qa(e.year)}getYearsInEra(e){return e.era==="AA"?9999:9991}getEras(){return["AA","AM"]}constructor(){this.identifier="ethiopic"}}class bn extends Bt{fromJulianDay(e){let[t,r,o]=It(Rt,e);return t+=Vt,new ee(this,"AA",t,r,o)}getEras(){return["AA"]}getYearsInEra(){return 9999}constructor(...e){super(...e),this.identifier="ethioaa"}}class Mn extends Bt{fromJulianDay(e){let[t,r,o]=It(Ha,e),l="CE";return t<=0&&(l="BCE",t=1-t),new ee(this,l,t,r,o)}toJulianDay(e){let t=e.year;return e.era==="BCE"&&(t=1-t),mt(Ha,t,e.month,e.day)}getDaysInMonth(e){let t=e.year;return e.era==="BCE"&&(t=1-t),Ua(t,e.month)}isInverseEra(e){return e.era==="BCE"}balanceDate(e){e.year<=0&&(e.era=e.era==="BCE"?"CE":"BCE",e.year=1-e.year)}getEras(){return["BCE","CE"]}getYearsInEra(e){return e.era==="BCE"?9999:9715}constructor(...e){super(...e),this.identifier="coptic"}}function wn(n){switch(n){case"buddhist":return new sn;case"ethiopic":return new Bt;case"ethioaa":return new bn;case"coptic":return new Mn;case"hebrew":return new kn;case"indian":return new dn;case"islamic-civil":return new Ct;case"islamic-tbla":return new fn;case"islamic-umalqura":return new pn;case"japanese":return new ln;case"persian":return new un;case"roc":return new cn;case"gregory":default:return new ce}}let Ot=new Map;class ft{format(e){return this.formatter.format(e)}formatToParts(e){return this.formatter.formatToParts(e)}formatRange(e,t){if(typeof this.formatter.formatRange=="function")return this.formatter.formatRange(e,t);if(t<e)throw new RangeError("End date must be >= start date");return`${this.formatter.format(e)} – ${this.formatter.format(t)}`}formatRangeToParts(e,t){if(typeof this.formatter.formatRangeToParts=="function")return this.formatter.formatRangeToParts(e,t);if(t<e)throw new RangeError("End date must be >= start date");let r=this.formatter.formatToParts(e),o=this.formatter.formatToParts(t);return[...r.map(l=>({...l,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...o.map(l=>({...l,source:"endRange"}))]}resolvedOptions(){let e=this.formatter.resolvedOptions();return xn()&&(this.resolvedHourCycle||(this.resolvedHourCycle=En(e.locale,this.options)),e.hourCycle=this.resolvedHourCycle,e.hour12=this.resolvedHourCycle==="h11"||this.resolvedHourCycle==="h12"),e.calendar==="ethiopic-amete-alem"&&(e.calendar="ethioaa"),e}constructor(e,t={}){this.formatter=za(e,t),this.options=t}}const Sn={true:{ja:"h11"},false:{}};function za(n,e={}){if(typeof e.hour12=="boolean"&&Tn()){e={...e};let o=Sn[String(e.hour12)][n.split("-")[0]],l=e.hour12?"h12":"h23";e.hourCycle=o??l,delete e.hour12}let t=n+(e?Object.entries(e).sort((o,l)=>o[0]<l[0]?-1:1).join():"");if(Ot.has(t))return Ot.get(t);let r=new Intl.DateTimeFormat(n,e);return Ot.set(t,r),r}let Ft=null;function Tn(){return Ft==null&&(Ft=new Intl.DateTimeFormat("en-US",{hour:"numeric",hour12:!1}).format(new Date(2020,2,3,0))==="24"),Ft}let Pt=null;function xn(){return Pt==null&&(Pt=new Intl.DateTimeFormat("fr",{hour:"numeric",hour12:!1}).resolvedOptions().hourCycle==="h12"),Pt}function En(n,e){if(!e.timeStyle&&!e.hour)return;n=n.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,""),n+=(n.includes("-u-")?"":"-u")+"-nu-latn";let t=za(n,{...e,timeZone:void 0}),r=parseInt(t.formatToParts(new Date(2020,2,3,0)).find(l=>l.type==="hour").value,10),o=parseInt(t.formatToParts(new Date(2020,2,3,23)).find(l=>l.type==="hour").value,10);if(r===0&&o===23)return"h23";if(r===24&&o===23)return"h24";if(r===0&&o===11)return"h11";if(r===12&&o===11)return"h12";throw new Error("Unexpected hour cycle result")}ae.extend(dr),ae.extend(pr),ae.extend(ea),ae.extend(br),ae.extend(Tr);function Fe(){const n=new Date;return{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}}function Cn(n){try{const e=$t(),t=Ir(e);if(n.calendar.identifier!==t.calendar.identifier){const r=ue(t,n.calendar);return n.compare(r)===0}return n.compare(t)===0}catch(e){return console.error("Error checking if date is today:",e),!1}}function Pe(){const n=new Date;return{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:n.getHours(),minute:n.getMinutes(),second:n.getSeconds()}}function De(n,e,t,r,o,l){const s={year:n,month:e,day:t};return r!==void 0&&(s.hour=r),o!==void 0&&(s.minute=o),l!==void 0&&(s.second=l),s}function oe(n,e="zh-TW",t="gregory"){if(!n)return null;try{if(Bn(n))return n;if(n instanceof Date&&!isNaN(n.getTime()))return{year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:n.getHours(),minute:n.getMinutes(),second:n.getSeconds()};if(typeof n=="string"){const r=Er(n,e,t);return r.success?r.date:null}return null}catch(r){return console.error("Failed to parse date:",r),null}}function de(n,e="YYYY-MM-DD"){if(!n)return null;try{return ae("2000-01-01 00:00:00").year(n.year).month(n.month-1).date(n.day).hour(n.hour||0).minute(n.minute||0).second(n.second||0).format(e)}catch(t){return console.error("Failed to format date:",t),null}}function ht(n,e="iso",t="YYYY-MM-DD",r,o=!1,l="gregory",s="zh-TW",i=!1,u=!0){if(!n)return null;try{switch(e){case"iso":if(o){let c;return u?c=i?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD HH:mm:ss":c=i?"YYYY-MM-DDTHH:mm":"YYYY-MM-DD HH:mm",de(n,c)}else return de(n,"YYYY-MM-DD");case"date":return new Date(n.year,n.month-1,n.day,n.hour||0,n.minute||0,n.second||0);case"object":return n;case"custom":return re.formatOutput(n,t,r,o,l,s);default:return console.warn(`不支援的輸出類型: ${e},回退到 ISO 格式`),de(n,"YYYY-MM-DD")}}catch(c){return console.error("formatOutput 失敗:",c),n}}function pt(n,e){const t=n.year*1e4+n.month*100+n.day,r=e.year*1e4+e.month*100+e.day;return t<r?-1:t>r?1:0}function Nt(n,e){const t=new Date(n.year,n.month-1,n.day);return t.setDate(t.getDate()+e),{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:n.hour,minute:n.minute,second:n.second}}function Wa(n,e){const t=new Date(n.year,n.month-1,n.day).getTime(),r=new Date(e.year,e.month-1,e.day).getTime();return Math.ceil((r-t)/(1e3*60*60*24))}function Yn(){const n=Pe(),e=De(n.year,n.month,1,0,0,0),t=n.month===12?1:n.month+1,r=n.month===12?n.year+1:n.year,o=De(r,t,1),l=Nt(o,-1);return{start:e,end:l}}function Rn(n,e){if(!n||typeof n!="string")return!1;try{const t=_a(n);let r=!0;if(e&&(r=At(e)),!t)return console.warn(`日期格式語義驗證失敗: "${n}"`),!1;if(e&&!r)return console.warn(`時間格式語義驗證失敗: "${e}"`),!1;const o=ae("2000-12-31 23:59:59");let l=!1;try{const c=o.format(n);l=c!==n&&c.length>0}catch(c){console.warn(`日期格式 dayjs 驗證失敗: "${n}"`,c),l=!1}let s=!0;if(e)try{const c=o.format(e);s=c!==e&&c.length>0}catch(c){console.warn(`時間格式 dayjs 驗證失敗: "${e}"`,c),s=!1}let i=!0;if(e)try{const c=`${n} ${e}`,h=o.format(c);i=h!==c&&h.length>0}catch(c){console.warn(`組合格式 dayjs 驗證失敗: "${n} ${e}"`,c),i=!1}return l&&s&&i}catch(t){return console.error("格式驗證時發生錯誤:",t),!1}}function _a(n){const e=["YYYY","YY","MM","M","DD","D"],t=["-","/","."," "];let r=n;t.forEach(g=>{r=r.replace(new RegExp(`\\${g}`,"g")," ")});const o=r.split(/\s+/).filter(Boolean);if(!o.every(g=>e.includes(g)))return!1;const s=o.some(g=>g==="YYYY"||g==="YY"),i=o.some(g=>g==="MM"||g==="M"),u=o.some(g=>g==="DD"||g==="D"),c=o.filter(g=>g==="YYYY"||g==="YY").length,h=o.filter(g=>g==="MM"||g==="M").length,v=o.filter(g=>g==="DD"||g==="D").length;return c>1||h>1||v>1?!1:s&&i&&u}function At(n){if(!n||typeof n!="string")return!1;const e=["HH","H","hh","h","mm","m","ss","s","A","a"],r=n.replace(/[^\w]/g," ").split(/\s+/).filter(Boolean);if(!r.every(h=>e.includes(h)))return!1;const l=r.some(h=>["HH","H"].includes(h)),s=r.some(h=>["hh","h"].includes(h)),i=r.some(h=>["mm","m"].includes(h));if(r.some(h=>["A","a"].includes(h)),!(l||s)||!i||s&&l)return!1;const c=e.reduce((h,v)=>(h[v]=r.filter(g=>g===v).length,h),{});return!Object.values(c).some(h=>h>1)}function Vn(n){return n.replace(/yyyy/g,"YYYY").replace(/yy/g,"YY").replace(/mm/g,"MM").replace(/dd/g,"DD")}function In(n){let e=n;return e=e.replace(/HH/g,"HH").replace(/hh/g,"hh").replace(/MM/g,"mm").replace(/SS/g,"ss").replace(/aa/g,"a").replace(/AA/g,"A"),e}function Bn(n){return!n||typeof n!="object"?!1:typeof n.year=="number"&&typeof n.month=="number"&&typeof n.day=="number"}class Lt{id="roc";yearRange={min:1,max:200};displayName={"zh-TW":"民國曆","zh-CN":"民国历","en-US":"ROC Calendar","ja-JP":"中華民国暦","ko-KR":"중화민국력"};YEAR_OFFSET=1911;parseInput(e,t){if(!e||typeof e!="string")return null;const o=e.trim().replace(/^(民國|民国|ROC\s*)/i,"").trim();if(/[上下]午|時|分|秒|\d{1,2}:\d{2}/.test(o))return this.parseDateTime(o);{if(/\d+年\d+月\d+日/.test(o))return this.parseDatePart(o);const s=o.replace(/[年月日時分秒]/g,""),i=["-","/","."," "];for(const u of i){const c=this.tryParseWithSeparator(s,u);if(c)return c}}return null}parseDateTime(e){const t=e.match(/^(\d+年\d+月\d+日)\s*(.*)$/);if(!t)return null;const[,r,o]=t,l=this.parseDatePart(r);if(!l)return null;const s=this.parseTimePart(o);return s?{...l,...s}:l}parseDatePart(e){const t=e.match(/(\d+)年(\d+)月(\d+)日/);if(!t)return null;const[,r,o,l]=t,s=parseInt(r),i=parseInt(o),u=parseInt(l);return this.validateAndConvertRocDate(s,i,u)}parseTimePart(e){if(!e)return null;const t=e.trim(),r=t.match(/(上午|下午)\s*(\d{1,2})時(\d{2})分(?:(\d{2})秒)?/);if(r){const[,l,s,i,u]=r;let c=parseInt(s);const h=parseInt(i),v=u?parseInt(u):0;return l==="下午"&&c!==12?c+=12:l==="上午"&&c===12&&(c=0),c<0||c>23||h<0||h>59||v<0||v>59?null:{hour:c,minute:h,second:v}}const o=t.match(/(\d{1,2}):(\d{2})(?::(\d{2}))?/);if(o){const[,l,s,i]=o,u=parseInt(l),c=parseInt(s),h=i?parseInt(i):0;return u<0||u>23||c<0||c>59||h<0||h>59?null:{hour:u,minute:c,second:h}}return null}canParseInput(e){return/^(民國|民国|ROC\s*)/i.test(e.trim())}tryParseWithSeparator(e,t){const r=e.split(t).map(i=>i.trim()).filter(Boolean);if(r.length<3)return null;const o=parseInt(r[0]),l=parseInt(r[1]),s=parseInt(r[2]);return this.validateAndConvertRocDate(o,l,s)}validateAndConvertRocDate(e,t,r){if(isNaN(e)||isNaN(t)||isNaN(r)||e<this.yearRange.min||e>this.yearRange.max)return null;const o=e+this.YEAR_OFFSET;if(t<1||t>12||r<1||r>31)return null;const l=`${o}-${t.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}`,s=ae(l,"YYYY-MM-DD",!0);return!s.isValid()||s.year()!==o||s.month()+1!==t||s.date()!==r?null:{year:o,month:t,day:r}}supportsFormat(e){return e.includes("ROC-")||e.includes("民國")}format(e,t,r){if(!this.supportsFormat(t))throw new Error(`RocFormatPlugin 不支援格式: ${t}`);const o=e.hour!==void 0&&e.hour!==null,l=t.split(" "),s=l[0],i=l.slice(1).join(" "),u=this.formatDatePart(e,s,r);if(i&&o){const c=this.detectTimeFormat(i),h=this.formatTimePart(e,i,c);return`${u} ${h}`}return u}detectTimeFormat(e){return!e.includes("A")&&!e.includes("a")&&!e.includes("hh")}formatDatePart(e,t,r){const o=e.year-this.YEAR_OFFSET,l=e.month,s=e.day,i={"ROC-YYYY":`民國${o}年`,"ROC-YYYY-MM-DD":`民國${o}年${l.toString().padStart(2,"0")}月${s.toString().padStart(2,"0")}日`,"ROC-YYYY/MM/DD":`民國${o}/${l.toString().padStart(2,"0")}/${s.toString().padStart(2,"0")}`,"ROC-NUM-YYYY-MM-DD":`${o}-${l.toString().padStart(2,"0")}-${s.toString().padStart(2,"0")}`,"ROC-NUM-YYYY/MM/DD":`${o}/${l.toString().padStart(2,"0")}/${s.toString().padStart(2,"0")}`};if(i[t])return i[t];const u=new Date(e.year,e.month-1,e.day);let c=ae(u).format(t);if(t.includes("YYYY"))c=c.replace(e.year.toString(),o.toString());else if(t.includes("YY")){const h=e.year.toString().slice(-2),v=o.toString().slice(-2);c=c.replace(h,v)}return c}formatTimePart(e,t,r){if(!e)return"";const o=e.hour||0,l=e.minute||0,s=e.second||0,i=this.getFormattedTime(o,l,s,t,r);return i||this.fallbackToDateJs(e,t,r)}getFormattedTime(e,t,r,o,l){if(l){const s={"HH:mm:ss":()=>this.formatBasicTime(e,t,r,!0),"HH:mm":()=>this.formatBasicTime(e,t,0,!1),HH時mm分ss秒:()=>this.formatChineseTime(e,t,r,!0),HH時mm分:()=>this.formatChineseTime(e,t,0,!1)};if(s[o])return s[o]()}else{const s={"hh:mm:ss A":()=>this.format12HourTime(e,t,r,!0,"suffix"),"hh:mm A":()=>this.format12HourTime(e,t,0,!1,"suffix"),"h:mm A":()=>this.format12HourTime(e,t,0,!1,"suffix",!1),"A hh:mm:ss":()=>this.format12HourTime(e,t,r,!0,"prefix"),"A hh:mm":()=>this.format12HourTime(e,t,0,!1,"prefix"),"A HH時mm分ss秒":()=>this.format12HourTime(e,t,r,!0,"chinese"),"A HH時mm分":()=>this.format12HourTime(e,t,0,!1,"chinese")};if(s[o])return s[o]()}return null}formatBasicTime(e,t,r,o){const l=e.toString().padStart(2,"0"),s=t.toString().padStart(2,"0");if(o){const i=r.toString().padStart(2,"0");return`${l}:${s}:${i}`}return`${l}:${s}`}formatChineseTime(e,t,r,o){const l=e.toString().padStart(2,"0"),s=t.toString().padStart(2,"0");if(o){const i=r.toString().padStart(2,"0");return`${l}時${s}分${i}秒`}return`${l}時${s}分`}format12HourTime(e,t,r,o,l,s=!0){const i=e<12?"上午":"下午",u=e===0?12:e>12?e-12:e,c=s?u.toString().padStart(2,"0"):u.toString(),h=t.toString().padStart(2,"0"),v=o?r.toString().padStart(2,"0"):"";switch(l){case"suffix":return o?`${c}:${h}:${v} ${i}`:`${c}:${h} ${i}`;case"prefix":return o?`${i} ${c}:${h}:${v}`:`${i} ${c}:${h}`;case"chinese":return o?`${i} ${c}時${h}分${v}秒`:`${i} ${c}時${h}分`;default:return""}}fallbackToDateJs(e,t,r){const o=new Date(e.year,e.month-1,e.day,e.hour||0,e.minute||0,e.second||0);if(!o||isNaN(o.getTime()))return"";let l=ae(o).format(t);return!r&&(t.includes("A")||t.includes("a"))&&(l=l.replace(/AM/g,"上午").replace(/PM/g,"下午"),l=l.replace(/am/g,"上午").replace(/pm/g,"下午")),l}}class re{static createSafeCalendar(e){try{return wn(e)}catch(t){return console.warn(`無法創建日曆 ${e},回退到西元曆:`,t),new ce}}static safeToCalendar(e,t){try{return ue(e,t)}catch(r){return console.warn("日曆轉換失敗,返回原始日期:",r),e}}static convertToCalendarDateSmart=(e,t)=>e?e.hour!==void 0||e.minute!==void 0||e.second!==void 0?this.convertToCalendarDateTime(e,t):this.convertToCalendarDate(e,t):null;static convertToCalendarDate=(e,t)=>{if(!e||e.year<=0||e.month<=0||e.day<=0||e.month>12||e.day>31)return null;try{if(t==="gregory")return new ee(e.year,e.month,e.day);{const r=this.createSafeCalendar(t),o=new ee(e.year,e.month,e.day);return this.safeToCalendar(o,r)}}catch(r){return console.error("轉換為 CalendarDate 失敗:",r),null}};static convertToCalendarDateTime=(e,t)=>{if(!e)return null;try{if(t==="gregory")return new Ve(e.year,e.month,e.day,e.hour||0,e.minute||0,e.second||0);{const r=this.createSafeCalendar(t),o=new Ve(e.year,e.month,e.day,e.hour||0,e.minute||0,e.second||0);return ue(o,r)}}catch(r){return console.error("轉換為 Cale