const e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t=["January","February","March","April","May","June","July","August","September","October","November","December"];function pad(e){return`0${e}`.slice(-2)}export function strftime(r,n){const a=r.getDay(),u=r.getDate(),c=r.getMonth(),o=r.getFullYear(),i=r.getHours(),s=r.getMinutes(),l=r.getSeconds();return n.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(n){let m;switch(n[1]){case"%":return"%";case"a":return e[a].slice(0,3);case"A":return e[a];case"b":return t[c].slice(0,3);case"B":return t[c];case"c":return r.toString();case"d":return pad(u);case"e":return String(u);case"H":return pad(i);case"I":return pad(strftime(r,"%l"));case"l":return String(0===i||12===i?12:(i+12)%12);case"m":return pad(c+1);case"M":return pad(s);case"p":return i>11?"PM":"AM";case"P":return i>11?"pm":"am";case"S":return pad(l);case"w":return String(a);case"y":return pad(o%100);case"Y":return String(o);case"Z":return m=r.toString().match(/\((\w+)\)$/),m?m[1]:"";case"z":return m=r.toString().match(/\w([+-]\d\d\d\d) /),m?m[1]:""}return""}))}export function makeFormatter(e){let t;return function(){if(t)return t;if("Intl"in window)try{return t=new Intl.DateTimeFormat(void 0,e),t}catch(e){if(!(e instanceof RangeError))throw e}}}let r=null;const n=makeFormatter({day:"numeric",month:"short"});export function isDayFirst(){if(null!==r)return r;const e=n();if(e){const t=e.format(new Date(0));return r=!!t.match(/^\d/),r}return!1}let a=null;const u=makeFormatter({day:"numeric",month:"short",year:"numeric"});export function isYearSeparator(){if(null!==a)return a;const e=u();if(e){const t=e.format(new Date(0));return a=!!t.match(/\d,/),a}return!0}export function isThisYear(e){return(new Date).getUTCFullYear()===e.getUTCFullYear()}export function makeRelativeFormat(e,t){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(e,t)}catch(e){if(!(e instanceof RangeError))throw e}}export function localeFromElement(e){const t=e.closest("[lang]");return t instanceof HTMLElement&&t.lang?t.lang:"default"}