dynamic-html-helpers 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var M=ke();function ke(){let[e,r,n,t]=["2-digit","numeric","long","short"],a={fixed:{MM:{month:n},M:{month:t},m:{month:r},mm:{month:e},yyyy:{year:r},yy:{year:e},WD:{weekday:n},wd:{weekday:t},d:{day:r},dd:{day:e},h:{hour:r},hh:{hour:e},mi:{minute:r},mmi:{minute:e},s:{second:r},ss:{second:e},ms:{fractionalSecondDigits:3},tz:{timeZoneName:"shortOffset"},dl:{locale:"default"},h12:{hour12:!1},yn:{yearName:""},ry:{relatedYear:!0},msp:{fractionalSecond:!0}},dynamic:{tzn:l=>({timeZoneName:l.slice(4)}),hrc:l=>({hourCycle:`h${l.slice(4)}`}),ds:l=>({dateStyle:l.slice(3)}),ts:l=>({timeStyle:l.slice(3)}),tz:l=>({timeZone:l.slice(3)}),e:l=>({era:l.slice(2)}),l:l=>({locale:l.slice(2)})}},o={...a,retrieveDyn(l){let y=l?.slice(0,l.indexOf(":"));return a.dynamic[y]&&a.dynamic[y](l)},get re(){return new RegExp(`\\b(${Object.keys(a.fixed).join("|")})\\b`,"g")}},s=(l="dtf",y=0)=>{let h=` ${l.replace(/(?<=\{)(.+?)(?=})/g,d=>`[${y++}]`).replace(/[{}]/g,"").trim()} `,D=l.match(/(?<=\{)(.+?)(?=})/g)||[];return{get texts(){return D},formatString(d){h=d},set formatStr(d){h=d},get formatStr(){return h},get units(){return h.match(o.re)||[]},finalize(d="",Z="",b="",$=""){return h.replace(/~([\d+]?)/g,"$1").replace(/dtf/,d).replace(/era/,b).replace(/dp\b|~dp\b/,Z).replace(/yn\b/,$).replace(/\[(\d+?)]/g,(w,Fe)=>D[Fe].trim()).trim()}}},u=l=>l.replace(/\s+/g,""),c=(...l)=>l?.reduce((y,h)=>({...y,...o.retrieveDyn(h)||o.fixed[h]}),o.fixed.dl),i=(l,y,h)=>{let D=c(...u(h).split(",")),d=Intl.DateTimeFormat(D.locale,D).format(l);return y.finalize(d)},m=(l,y,h,D)=>l.toLocaleString(y,{timeZone:h,month:D?t:n}),T=(l,y,h)=>{let D=c(...y.units.concat(u(h).split(",")).flat()),d={...o.fixed},Z=($,w)=>D[$]==="numeric"&&w.startsWith("0")?w.slice(1):w,b=Intl.DateTimeFormat(D.locale,D).formatToParts(l).reduce(($,w)=>w.type==="literal"&&/[ ,/-]/.test(w.value)?$:{...$,[w.type]:Z(w.type,w.value)},{});return d.ms=D.fractionalSecondDigits?d.msp:d.ms,d.yyyy=b.relatedYear?d.ry:d.yyyy,y.formatStr=y.formatStr.replace(o.re,$=>/^(M|MM)$/.test($)?m(l,D.locale,D.timeZone,/^M$/.test($)):b[Object.keys(d[$]).shift()]||$),y.finalize(void 0,b.dayPeriod,b.era,b.yearName)};return(l,y,h="l:default")=>/ds:|ts:/.test(h)?i(l,s(void 0),h):T(l,s(y||void 0),h)}var le=Ce;function Ce(){let e=(t,a)=>{let o=isNaN(new Date(t)),s=isNaN(new Date(a));if(s){let[u,c,i]=Array(3).fill("end date not valid");return{error:!0,message:u,full:c,clean:i}}if(o){let[u,c,i]=Array(3).fill("start date not valid");return{error:!0,message:u,full:c,clean:i}}if(o&&!s){let[u,c,i]=Array(3).fill("start- and/or end date are not valid");return{error:!0,message:u,full:c,clean:i}}return{error:!1}},r=n();return function({start:t,end:a,diffs:o={}}={}){let s=e(t,a),u=a>t?"+":"-";if(s.error)return s;let c=Math.abs(t-a),i=new Date(c),m=i.getUTCFullYear()-1970,T=i.getUTCMonth(),l=i.getUTCDate()-1,y=l%7,h=Math.floor(l/7),D=i.getUTCHours(),d=i.getUTCMinutes(),Z=i.getUTCSeconds(),b=i.getUTCMilliseconds(),$=Math.floor(c/864e5);o={...o,fromUTC:t,toUTC:a,sign:"",years:m,months:T,days:l,hours:D,minutes:d,seconds:Z,milliseconds:b,diffInDays:$},o.full=r({values:o,full:!0}),o.clean=r({values:o}),o.equalDates=o.clean==="Dates are equal";let w=D+d+Z>0?"T":"";return o.clean!=="Dates are equal"&&(o.sign=u,o.jsPeriod=`${u}P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${h>0?`${h}W`:""}${y>0?`${y}D`:""}${w}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${Z>0?`${Z}S`:""}`,o.ISOPeriod=`P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${l>0?`${l}D`:""}${w}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${Z>0?`${Z}S`:""}`),o};function n(){let t=(...i)=>m=>i.reduce((T,l)=>l(T),m),a=(i,m)=>i===1?m.slice(0,-1):m;return t(({values:i,full:m})=>[Object.entries(i).filter(([T])=>/^(years|month|days|hours|minutes|seconds)/i.test(T)),m],([i,m])=>m?i:i.filter(([,T])=>m?+T:T>0),i=>i.reduce((m,[T,l])=>[...m,`${l} ${a(l,T)}`],[]),i=>i.length<1?"Dates are equal":`${i.slice(0,-1).join(", ")}${i.length>1?" and ":""}${i.slice(-1).shift()}`)}}var ie=Ae;function Ae(){let e=Object.entries({year:"FullYear",month:"Month",date:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds",millisecond:"Milliseconds"}).reduce((t,[a,o])=>({...t,[a]:o,[`${a}s`]:o}),{}),r=!1,n=function(...t){let a=t.length===1;return r=t[0].trim().startsWith("subtract,"),r&&(t=a?t[0].trim().replace(/^subtract,/i,"").split(",").map(o=>o.trim()):t.filter(o=>!o.startsWith("subtract"))),a&&!r&&(t=t[0].split(",").map(o=>o.trim())),t.map(function(o){if(!o)return!1;let s=o.toLowerCase().split(/ {1,}/);return s.length<2?!1:s.map(u=>{u=`${u}`.trim().replace(/[^a-z0-9-+]/g,"");let c=parseInt(u,10);return Number.isNaN(c)?u:r?-c:+c})}).filter(o=>o)};return function(t,...a){if(a.length<1)return t;let o=n(...a);return o.length&&o.forEach(([s,u])=>{u=u,u=e[u],s&&u&&t[`set${u}`](t[`get${u}`]()+s)}),t}}var ge=le(),ye=Ye(),N=ie(),We=["sun","mon","tue","wed","thu","fri","sat"],he=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function q(e,r=!1){let n=e.month+1,t=e.month;if(e.month+=r?-1:1,!r&&e.month>=n)for(;e.month>n;)e.dateNr-=1;if(r&&e.month===t)for(;e.month>=t;)e.dateNr-=1;return e}function H(e,...r){return N(e,...r),e}function De(e,r=!1){let n=Q(e.clone,{sunday:r}),t=[n];return{weekStart:n.format("WD","l:en-GB"),inputDate:e,dates:t.concat([...Array(6)].map((a,o)=>n.clone.addDays(o+1)))}}function W(e,{start:r,end:n,future:t,past:a,include:o={start:!1,end:!1}}={}){let s=e.clone.UTC;return r=r?.value||r?.constructor===Date?f(r?.value||r).UTC:f.now.UTC,n=n&&n?.value||n?.constructor===Date?f(n?.value||n).UTC:f.now.UTC,s.milliseconds=0,r.milliseconds=0,n.milliseconds=0,t?r>n:a?r<n:(o.start?+s>=+r:+s>+r)&&(o.end?+s<=+n:+s<+n)}function _(e,{zoneTime:r=!1,formatStr:n,moreOptions:t}={}){return t=r?e.localeInfo.formatOptions+(t?`,${t}`:""):g.formatOptions+(t?`,${t}`:""),r?(e.localeInfo||(e.localeInfo=g),M(e,n,t)):Ue(e,n,t)}function Ue(e,r,n){let t=e.clone.relocate(g);return n=(n||"").startsWith("+")?`${t.localeInfo.formatOptions},${n.slice(1)}`:n||t.localeInfo.formatOptions,M(t,r,n)}function Te(e,r){let n=ge({start:e,end:r||e});return parseInt(`${n.sign}${n.diffInDays}`)}function G(e,r=!1){let{locale:n,timeZone:t}=r?e.localeInfo:g,a=se(n,t),o=e.format("MM|WD",a).split("|");return{locale:n,timeZone:t,monthName:o[0],dayName:o[1],dayNames:ae(n),monthNames:Y(n)}}function B(e,r=!1){let[n,t,a,o]=U(e,r),u={values4Timezone:r?g.timeZone:e.timeZone,hours:n,minutes:t,seconds:a,milliseconds:o};return Object.freeze(u)}function U(e,r=!1){let t=`l:en-CA,${r?`tz:${g.timeZone}`:`tz:${e.timeZone}`},hrc:23,ts:medium`;return e.format("",t).split(/:/).map(Number).concat(e.getMilliseconds())}function J(e,r){let n=r?`tz:${g.timeZone}`:`,tz:${e.timeZone}`,[t,a,o]=e.format("yyyy-mm-dd",n).split(/-/).map(Number);a-=1;let s=r?g.timeZone:e.timeZone;return Object.freeze({values4Timezone:s,year:t,month:a,date:o})}function K(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate()];let n=e.format("yyyy-m-d",e.localeInfo.formatOptions).split(/-/).map(Number);return n[1]-=1,n}function Le(e){let r=new Intl.Locale(e.locale),n=r.weekInfo?r.weekInfo.firstDay:r.getWeekInfo?r.getWeekInfo().firstDay:1;return n=n===7?0:n,he[n]}function Q(e,{sunday:r=!1}={}){let n=r?"sunday":Le(e);return x(e,{day:n,preserveTodayWhenEqual:!0})}function xe(e,r){let n=e.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000",t=r.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000";return n=A(n.slice(0,3)+":"+n.slice(-2),!0),t=A(t.slice(0,3)+":"+t.slice(-2),!0),[-n[0]+t[0],-n[1]+t[1]].map(a=>n[0]<0?-a:a)}function R({start:e,end:r}={}){r||(r=e.clone),r?.clone||(r=f(r,{timeZone:e.timeZone})),e=f(fe(e,e.timeZone),{timeZone:e.timeZone}),r=f(fe(r,r.timeZone),{timeZone:r.timeZone});let n=ge({start:e,end:r,diffs:{timeZoneStart:e.timeZone,timeZoneEnd:r.timeZone}}),t=xe(r,e),a=n.sign.startsWith("-")?"ahead of":"behind",[o,s]=t.map(i=>Math.abs(i)),[u,c]=[`${o} ${C(o,"hour")}`,`${s} ${C(s,"minute")}`];return n.timeZonesOffsetDifference=n.sign.length<1||o+s===0?`Offsets of ${e.timeZone} and ${r.timeZone} are equal`:`${e.timeZone} is ${u}${s>0?` and ${c}`:""} ${a} ${r.timeZone}`,n}function X(e,r){r=String(r).toLowerCase()==="utc"||r.timeZone==="UTC"?e.clone.relocate({timeZone:"UTC"}):f(e.value,{timeZone:r.timeZone||g.timeZone});let t=R({start:e.clone,end:r}),o=`${t.sign}${ce(t.hours)}:${ce(t.minutes)}`;return{fromTZ:e.timeZone,toTZ:r.timeZone,offset:o,offsetText:`${r.timeZone} ${je(o)} ${e.timeZone}`}}function ce(e,r=2){return`${e}`.padStart(r,"0")}function C(e,r){return`${r}${e>1||e===0?"s":""}`}function je(e){if(/00:00/.test(e))return"no time diffence to";let r=e.slice(1).split(":").map(Number),[n,t]=r,a=C(n,"hour"),o=C(t,"minute"),s=e.startsWith("+");return t>0?`${n} ${a} and ${t} ${o} ${s?"ahead of":"behind"}`:`${n} ${a} ${s?"ahead of":"behind"}`}function me(e,r,n){return e.clone.format(r,n||e.localeInfo.formatOptions)}function pe(e,{withFormat:r,withFormatOptions:n,local:t=!1}={}){if(r)return t?me(e,r,$D.localeInformation.formatOptions):me(e,r,n);let a=e.clone.relocate({locale:"en"}),o=t?g.formatOptions:a.localeInfo.formatOptions,u=`wd M dd yyyy hh:mmi:ss ${a.format("tz",o+",tzn:longOffset").replace(":","")} (tz)`;return a.format(u,o+",tzn:long, hrc:23")}function ee(e,r=!1){let n=Intl.DateTimeFormat("en",{timeZone:r?e.timeZone:g.timeZone,weekday:"short"});return ye(n.format(e))}function $e(e){let r=g,n=e.localeInfo,t=e.clone.relocate({locale:r.locale,timeZone:r.timeZone}),a=e.offsetFrom(t),o=t.offsetFrom(e),s=r,u=n,c=e.format("hh:mmi:ss dp",`hrc:12,tz:${e.timeZone}`),i=t.format("hh:mmi:ss dp",`hrc:12,tz:${t.timeZone}`),m={note:"'user' are values for your locale/timeZone, 'remote' (if applicable) idem for the instance",locales:{user:{locale:s.locale,timeZone:s.timeZone}},dateTime:{user:{...e.dateTime,monthName:t.monthName,weekdayNr:t.day,weekdayName:t.dayName,dayPeriodTime:i,hasDST:t.hasDST,DSTActive:t.DSTActive,offsetFromRemote:a.offset,string:t.toString()}},offset:{fromUTC:e.UTC.offsetFrom(e).offsetText}};return n.timeZone!==r.timeZone&&(m.locales.remote={locale:u.locale,timeZone:u.timeZone},m.dateTime.remote={...e.zoneDateTime,monthName:e.zoneNames.monthName,weekdayNr:ee(e,!0),weekdayName:e.zoneNames.dayName,dayPeriodTime:c,hasDST:e.hasDST,DSTActive:e.DSTActive,offsetFromUser:o.offset,string:e.toString()},m.offset.fromUserTime=o.offsetText),m}function O(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];let n=e.format("yyyy-m-d-hh-mmi-ss",`${e.localeInfo.formatOptions},hrc23:true`).split(/-/).map(Number).concat(e.getMilliseconds());return n[1]-=1,n}function te(e){return new Date(e.year,e.month+1,0,0,0,0).getDate()}function L(e,r){r=p({locale:r||e.localeInfo.locale}).locale;let n=e.clone.relocate({locale:r});return n.date={date:1},[n].concat([...Array(te(n)-1)].map((t,a)=>n.clone.add(`${a+1} days`)))}function x(e,{day:r,next:n=!1,preserveTodayWhenEqual:t=!1}={}){r=r?.toLowerCase()||"-";let a=ye(r);if(a<0)return console.error(`[TickTock instance].next/previous invalid day value ${r}`),e.clone;let o=n?1:-1,s=f(new Date(...e.dateTimeValues),e.localeInfo);return t&&a===s.day?s:Pe(s.addDays(n?1:-1),a,o)}function Pe(e,r,n){function t(a){switch(!0){case a.day===r:return a;default:return t(a.add(`${n} days`))}}return t(e)}function F(e,{dateOnly:r=!1,timeOnly:n=!1}={}){let{locale:t,timeZone:a}=e.localeInfo;return r?new Date(e).toLocaleDateString(t,{timeZone:a}):n?new Date(e).toLocaleTimeString(t,{timeZone:a}):new Date(e).toLocaleString(t,{timeZone:a})}function fe(e,r){let n={timeZone:r,hourCycle:"h23"};return new Date(new Date(e).toLocaleString("en",n))}function v(e,{year:r,month:n,date:t}={}){return S(r)&&e.setFullYear(parseInt(r)),S(t)&&e.setDate(parseInt(t)),S(n)&&e.setMonth(parseInt(n)),e}function I(e,{hours:r,minutes:n,seconds:t,milliseconds:a}={}){return S(r)&&e.setHours(parseInt(r)),S(n)&&e.setMinutes(parseInt(n)),S(t)&&e.setSeconds(parseInt(t)),S(a)&&e.setMilliseconds(parseInt(a)),e}function we(e){return e?.constructor===Date||e?.value}function re(e,r){return we(r)?f(r?.value||r,e.localeInfo):f.from(...e.dateTimeValues).relocate(e.localeInfo)}function Ye(){return function(e){e=`${e}`.toLowerCase();let r=We.indexOf(e);return r<0?he.indexOf(e):r}}function A(e){let r=e.slice(1).split(/[-:]/).map(Number),n=e.startsWith("-");return r=r.map(t=>n?-t:t),r}function Se(e){return e.time={hours:0,minutes:0,seconds:0,milliseconds:0},e}function de(e,r){return Intl.DateTimeFormat("en-CA",{timeZone:r,timeZoneName:"long"}).format(e).split(/,/)[1].trim()}function j(e,r){r=r||e?.timeZone||g.timeZone,e=e?.value?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r});let n=e.year||e.getFullYear(),t=de(new Date(n,0,1),r),a=de(new Date(n,5,1),r);return t!==a}function P(e,r){return r=r||e?.timeZone||g.timeZone,e=e?.hasDST?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r}),e.hasDST?!/standard/i.test(e.toString()):!1}function Ze(e,{locale:r,timeZone:n,l:t,tz:a}={}){return e.localeInfo=p({locale:t||r||e.l||e.locale,timeZone:a||n||e.tz||e.timeZone}),e}function be(e,r){return we(r)&&(e=f(r.value||r,r.localeInfo||e.localeInfo)),e}function k(e,r){let n=oe(new Date(e,11,r||31));return n===1?k(e,(r||31)-1):n}function ne(e,r){let n=e.month;switch(!0){case n<3:return r?1:"First";case n<6:return r?2:"Second";case n<9:return r?3:"Third";case n<12:return r?4:"Fourth";default:return"unknown"}}function oe(e){let r=new Date(e),n=(r.getDay()+6)%7;r.setDate(r.getDate()-n+3);let t=r.valueOf();return r.setMonth(0,1),r.getDay()!==4&&r.setMonth(0,1+(4-r.getDay()+7)%7),1+Math.ceil((t-r)/6048e5)}var E=Ee;function Ee({localeInfo:e,customMethods:r,dateValue:n}={}){let t,a={add(...o){return H(t,...o)},between({start:o,end:s,include:u}={}){return W(t,{start:o,end:s,include:u})},cloneWith(o){return re(t,o)},daysUntil(o){return Te(t,o)},differenceTo(o){return R({start:t,end:o})},differenceUntil(o){return t.differenceTo(o).clean},firstWeekday({sunday:o=!1,midnight:s=!1}={}){return Q(t,{sunday:o,midnight:s})},format(o,s){return _(t,{formatStr:o,moreOptions:s})},fullMonth(o){return L(t,o)},fullWeek(o=!1){return De(t,!!o)},isFuture(o){return W(t,{start:t,end:o,future:!0})},isPast(o){return W(t,{start:t,end:o,past:!0})},next(o,s){return x(t,{day:o,next:!0,preserveTodayWhenEqual:!!s})},offsetFrom(o){return X(t,o)},previous(o,s){return x(t,{day:o,next:!1,preserveTodayWhenEqual:!!s})},relocate({locale:o,timeZone:s,l:u,tz:c}={}){return Ze(t,{locale:o,timeZone:s,l:u,tz:c})},revalue(o){return t=be(t,o),t},setDateValues({year:o,month:s,date:u}={}){return v(t,{year:o,month:s,date:u})},setTimeValues({hours:o,minutes:s,seconds:u,milliseconds:c}={}){return I(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},subtract(...o){return H(t,"subtract,"+o.join(","))},toArray(o=!1){return O(t,o)},toString({template:o,formatOptions:s,local:u}={}){return pe(t,{withFormat:o,withFormatOptions:s,local:u})},values(o=!1){return o?t.dateTime:t.zoneDateTime},zoneFormat(o,s){return _(t,{zoneTime:!0,formatStr:o,moreOptions:s})},set date({year:o,month:s,date:u}){v(t,{year:o,month:s,date:u})},set dateNr(o){v(t,{date:o})},set hours(o){I(t,{hours:o})},set localeInfo({locale:o,timeZone:s,l:u,tz:c}){e=z({locale:o,timeZone:s,l:u,tz:c})},set milliseconds(o){I(t,{milliseconds:`${o}`})},set minutes(o){I(t,{minutes:o})},set month(o){v(t,{month:o})},set seconds(o){I(t,{seconds:o})},set time({hours:o,minutes:s,seconds:u,milliseconds:c}){I(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},set year(o){v(t,{year:o})},get age(){return t.differenceTo(new Date).years},get ageFull(){return t.differenceTo(new Date).clean},get clone(){return re(t)},get date(){return J(t,!0)},get dateNr(){return t.date.date},get dateTime(){return{...t.date,...t.time}},get dateTimeValues(){return O(t,!0)},get dateValues(){return K(t,!0)},get day(){return t.getDay()},get dayName(){return t.names.dayName},get daysThisMonth(){return te(t)},get DSTActive(){return P(t)},get hasDST(){return j(t)},get hours(){return t.time.hours},get info(){return $e(t)},get isLeapYear(){return new Date(t.getFullYear(),2,0).getDate()===29},get ISO(){return t.toISOString()},get local(){return F(t)},get localDate(){return F(t,{dateOnly:!0})},get locale(){return(e||z()).locale},get localeInfo(){return e},get localeString(){return F(t)},get localTime(){return F(t,{timeOnly:!0})},get milliseconds(){return t.getMilliseconds()},get minutes(){return t.time.minutes},get month(){return t.date.month},get monthName(){return t.names.monthName},get names(){return G(t)},get quarter(){return ne(t)},get quarterNr(){return ne(t,!0)},get removeTime(){return Se(t)},get seconds(){return t.time.seconds},get time(){return B(t,!0)},get timeValues(){return U(t,!0)},get timeZone(){return(e||z()).timeZone},get unixEpochTimestamp(){return Math.floor(+t/1e3)},get userLocaleInfo(){return g},get UTC(){return t.clone.relocate({locale:t.locale,timeZone:"UTC"})},get UTCOffset(){return X(t,"UTC")},get value(){return new Date(t)},get weeknr(){return oe(t)},get weeksInYear(){return k(t.year,31)},get year(){return t.date.year},get zoneDate(){return J(t,!1)},get zoneDateNr(){return t.zoneDate.date},get zoneDateTime(){return{...t.zoneDate,...t.zoneTime}},get zoneDateTimeValues(){return O(t,!1)},get zoneDateValues(){return K(t,!1)},get zoneDay(){return ee(t,!0)},get zoneDayname(){return t.zoneNames.dayName},get zoneHours(){return t.zoneTime.hours},get zoneMinutes(){return t.zoneTime.minutes},get zoneMonth(){return t.zoneDate.month},get zoneMonthname(){return t.zoneNames.monthName},get zoneNames(){return G(t,!0)},get zoneSeconds(){return t.zoneTime.seconds},get zoneTime(){return B(t)},get zoneTimeValues(){return U(t)},get zoneYear(){return t.zoneDate.year},get zoneValues(){return t.zoneDateTime},get zoneArray(){return O(t,!1)}};return!e&&!n?a:(a.localeInfo=e||z(),t=new Proxy(n,Ve(a)),Object.entries(Object.getOwnPropertyDescriptors(ue(t,r))).forEach(([o,s])=>Object.defineProperty(a,o,s)),Object.freeze(t))}function Ve(e){return{get(r,n){return n!=="toString"&&n in r?r[n].bind(r):Reflect.get(e,n)},set(r,n,t){return n in e&&Reflect.set(e,n,t)}}}var g=Me(Intl.DateTimeFormat().resolvedOptions()),qe=Object.getOwnPropertyNames(Date.prototype).filter(e=>e.startsWith("set")).reduce((e,r)=>[...e,{native:r,syn:"change"+r.slice(3)}],[]);function ae(e="en-GB"){return e=p({locale:e}).locale,{long:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"long"})),short:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"short"}))}}function Y(e="en"){return e=p({locale:e}).locale,{long:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"long"})),short:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"short"}))}}function He({year:e,locale:r}={}){e=S(e)?parseInt(e):new Date().getFullYear();let n={year:e,calendar:{}},t=Y().long.map(a=>a.toLowerCase());for(let a=0;a<12;a+=1){let o=f.from(e,a,1);n.calendar[t[a]]=L(o,r)}return n}function _e({year:e,monthNr:r,locale:n="en-CA"}={}){e=S(r)&&parseInt(e)||-1,r=S(r)&&parseInt(r)||new Date().getFullYear();let t=r>=1&&r<=12;return n=p({locale:n}).locale,r=t?r-1:void 0,t?f.from(e,r,1).relocate({locale:n}).fullMonth(n):"MonthNr should be a specific number (1 = january - 12 = december)"}function Me(e){let r=se(e.locale,e.timeZone),n=new Intl.Locale(e.locale);return e.weekInfo=n.getWeekInfo?n.getWeekInfo():null,Object.defineProperty(e,"formatOptions",{value:r,enumerable:!1})}function se(e,r){return[`${e&&!(Array.isArray(e)&&e.length<1)?`l:${e}`:""}`,`${r?`tz:${r}`:""}`].filter(n=>n).join(",")}function p({locale:e,timeZone:r,l:n,tz:t}={}){return r=r||t,e=e||n,e=Ie({trial:function(){return Intl.DateTimeFormat(e,{timeZone:g.timeZone}).resolvedOptions().locale},onError:function(){return console.warn(`Intl locale "${e}" best fit impossible, using "${g.locale}"`),g.locale}}),r=Ie({trial:function(){return Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions().timeZone},onError:function(){return console.warn(`timeZone "${r}" not valid. Using "${g.timeZone}"`),g.timeZone}}),Me(Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions())}function z({locale:e,timeZone:r,l:n,tz:t}={}){return p({locale:e,timeZone:r,l:n,tz:t},!0)}function Ne(e){return!Number.isNaN(+e)&&e?.constructor===Date?e:new Date}function ve(e){let r=new Date;switch(!0){case(typeof e=="string"||typeof e=="number"):return Ne(new Date(e));case(Array.isArray(e)&&e.map(Number).length===e.length):return e.length===1?new Date(e[0],0,1):new Date(...e);case e?.constructor===Date:return Ne(e);default:return r}}function Ie({trial:e,onError:r=()=>{}}={}){if(e?.constructor===Function)try{return e()}catch(n){return r?.constructor===Function?r(n):void 0}}function Ge({timeZoneDate:e,timeZoneID:r,userTimeZoneID:n}={}){let t={timeZone:p({timeZone:r}).timeZone},a={timeZone:p({timeZone:n||""}).timeZone},o=f(e,t),s=f(e,a),u=s.differenceTo(o),c=o.offsetFrom(s).offset,[i,m]=A(c,!0),T=s.clone.add(`${i} hours, ${m} minutes`),y=u.equalDates?"No difference":`Time offset ${c}: ${a.timeZone} is ${u.clean} ${i<0?"behind":"ahead of"} ${t.timeZone}`;return{remoteTimezone:t.timeZone,userTimezone:a.timeZone,timeDifference:y,result:{[t.timeZone.replace(/\//,"_")]:f(e).toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"}),[a.timeZone.replace(/\//,"_")]:T.toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"})}}}function S(e){return!Number.isNaN(parseInt(e))}function V(e,r,n){return e?.constructor===Number?N(r,`${e} ${n}`):r}function Be(e){let r={addYears(n=1){return V(n,e,"years")},addMonths(n=1){return V(n,e,"months")},addWeeks(n=1){return n=n?.constructor===Number?n*7:1,V(n,e,"days")},addDays(n=1){return V(n,e,"days")},get nextYear(){return N(e,"1 year")},get nextWeek(){return N(e,"7 days")},get previousWeek(){return N(e,"-7 days")},get previousYear(){return N(e,"-1 year")},get nextMonth(){return q(e)},get previousMonth(){return q(e,!0)},get tomorrow(){return N(e,"1 day")},get yesterday(){return N(e,"-1 day")}};for(let n of qe)r[n.syn]=function(...t){return e[n.native](...t),e};return r}function ue(e,r){let n=Be(e);for(let[t,a]of Object.entries(r||{})){let o=a.enumerable,s=a.isGetter?{get(){return a.method(e)},enumerable:o}:{value(...u){return a.method(e,...u)},enumerable:o};Object.defineProperty(n,t,s)}return n}function ze(e,r){return Object.defineProperties(e,{now:{get(){return e(new Date)}},localeInformation:{get(){return p()}},localWeekdaynames:{value(n){return ae(n)}},localMonthnames:{value(n){return Y(n)}},daysInMonth:{value(n,t=!1){return n=S(n)?parseInt(n):0,n>=1&&n<=12?new Date(t?2e3:2005,n,0).getDate():`${n} should be a Number between (1 (january) - 12 (december))`}},yearCalendar:{value:He},monthCalendar:{value:_e},from:{value(...n){return e(n)}},fromUxTS:{value(n,t){n=S(n)?parseInt(n)*1e3:void 0;let a=n?new Date(n):new Date;return f(a,t||g)}},hasDST:{value({date:n,timeZone:t}={}){return j(n,t)}},DSTActive:{value({date:n,timeZone:t}={}){return P(n,t)}},values:{value({date:n,timeZone:t}={}){n=n||n?.value||new Date;let a=M(n,"yyyy-m-d-h-mi-s",p({timeZone:t}).formatOptions.concat(",hrc:23")).split("-").map(Number).concat(n.getMilliseconds());return a[1]-=1,a}},format:{value({date:n,template:t,timeZone:a,locale:o,opts:s}={}){n=n||n?.value||new Date,t=t?.constructor===String?t:"yyyy/mm/dd hh:mmi:ss dp";let u=p({timeZone:a,locale:o}).formatOptions;return u+=s?`,${s}`:"",M(n,t,u)}},addCustom:{value({name:n,method:t,enumerable:a=!1,isGetter:o=!1}={}){n?.constructor===String&&t?.constructor===Function&&t.length>0&&(r[n]={method:t,enumerable:a,isGetter:o})}},validateLocaleInformation:{value:p},timeAcrossZones:{value:Ge},weeksInYear:{value(n){return k(n,31)}},keys:{get(){let n=Object.fromEntries(Object.entries(r).filter(([a,o])=>o.enumerable===!0));return[...Object.keys(E()),...Object.keys(ue()),...Object.keys(n)].sort((a,o)=>a.localeCompare(o))}}}),e}var Oe={},f=ze(Je,Oe);function Je(e,r){if(e?.localeInfo)return e.clone;let n=e?.locale||e?.timeZone||e?.tz||e?.l;return E({localeInfo:p(n?e:r),dateValue:new Date(n?Date.now():ve(e)),customMethods:Oe})}export{f as default};
1
+ var M=ke();function ke(){let[e,r,n,t]=["2-digit","numeric","long","short"],a={fixed:{MM:{month:n},M:{month:t},m:{month:r},mm:{month:e},yyyy:{year:r},yy:{year:e},WD:{weekday:n},wd:{weekday:t},d:{day:r},dd:{day:e},h:{hour:r},hh:{hour:e},mi:{minute:r},mmi:{minute:e},s:{second:r},ss:{second:e},ms:{fractionalSecondDigits:3},tz:{timeZoneName:"shortOffset"},dl:{locale:"default"},h12:{hour12:!1},yn:{yearName:""},ry:{relatedYear:!0},msp:{fractionalSecond:!0}},dynamic:{tzn:l=>({timeZoneName:l.slice(4)}),hrc:l=>({hourCycle:`h${l.slice(4)}`}),ds:l=>({dateStyle:l.slice(3)}),ts:l=>({timeStyle:l.slice(3)}),tz:l=>({timeZone:l.slice(3)}),e:l=>({era:l.slice(2)}),l:l=>({locale:l.slice(2)})}},o={...a,retrieveDyn(l){let y=l?.slice(0,l.indexOf(":"));return a.dynamic[y]&&a.dynamic[y](l)},get re(){return new RegExp(`\\b(${Object.keys(a.fixed).join("|")})\\b`,"g")}},s=(l="dtf",y=0)=>{let h=` ${l.replace(/(?<=\{)(.+?)(?=})/g,d=>`[${y++}]`).replace(/[{}]/g,"").trim()} `,D=l.match(/(?<=\{)(.+?)(?=})/g)||[];return{get texts(){return D},formatString(d){h=d},set formatStr(d){h=d},get formatStr(){return h},get units(){return h.match(o.re)||[]},finalize(d="",Z="",b="",$=""){return h.replace(/~([\d+]?)/g,"$1").replace(/dtf/,d).replace(/era/,b).replace(/dp\b|~dp\b/,Z).replace(/yn\b/,$).replace(/\[(\d+?)]/g,(w,Fe)=>D[Fe].trim()).trim()}}},u=l=>l.replace(/\s+/g,""),c=(...l)=>l?.reduce((y,h)=>({...y,...o.retrieveDyn(h)||o.fixed[h]}),o.fixed.dl),i=(l,y,h)=>{let D=c(...u(h).split(",")),d=Intl.DateTimeFormat(D.locale,D).format(l);return y.finalize(d)},m=(l,y,h,D)=>l.toLocaleString(y,{timeZone:h,month:D?t:n}),T=(l,y,h)=>{let D=c(...y.units.concat(u(h).split(",")).flat()),d={...o.fixed},Z=($,w)=>D[$]==="numeric"&&w.startsWith("0")?w.slice(1):w,b=Intl.DateTimeFormat(D.locale,D).formatToParts(l).reduce(($,w)=>w.type==="literal"&&/[ ,/-]/.test(w.value)?$:{...$,[w.type]:Z(w.type,w.value)},{});return d.ms=D.fractionalSecondDigits?d.msp:d.ms,d.yyyy=b.relatedYear?d.ry:d.yyyy,y.formatStr=y.formatStr.replace(o.re,$=>/^(M|MM)$/.test($)?m(l,D.locale,D.timeZone,/^M$/.test($)):b[Object.keys(d[$]).shift()]||$),y.finalize(void 0,b.dayPeriod,b.era,b.yearName)};return(l,y,h="l:default")=>/ds:|ts:/.test(h)?i(l,s(void 0),h):T(l,s(y||void 0),h)}var le=Ce;function Ce(){let e=(t,a)=>{let o=isNaN(new Date(t)),s=isNaN(new Date(a));if(s){let[u,c,i]=Array(3).fill("end date not valid");return{error:!0,message:u,full:c,clean:i}}if(o){let[u,c,i]=Array(3).fill("start date not valid");return{error:!0,message:u,full:c,clean:i}}if(o&&!s){let[u,c,i]=Array(3).fill("start- and/or end date are not valid");return{error:!0,message:u,full:c,clean:i}}return{error:!1}},r=n();return function({start:t,end:a,diffs:o={}}={}){let s=e(t,a),u=a>t?"+":"-";if(s.error)return s;let c=Math.abs(t-a),i=new Date(c),m=i.getUTCFullYear()-1970,T=i.getUTCMonth(),l=i.getUTCDate()-1,y=l%7,h=Math.floor(l/7),D=i.getUTCHours(),d=i.getUTCMinutes(),Z=i.getUTCSeconds(),b=i.getUTCMilliseconds(),$=Math.floor(c/864e5);o={...o,fromUTC:t,toUTC:a,sign:"",years:m,months:T,days:l,hours:D,minutes:d,seconds:Z,milliseconds:b,diffInDays:$},o.full=r({values:o,full:!0}),o.clean=r({values:o}),o.equalDates=o.clean==="Dates are equal";let w=D+d+Z>0?"T":"";return o.clean!=="Dates are equal"&&(o.sign=u,o.jsPeriod=`${u}P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${h>0?`${h}W`:""}${y>0?`${y}D`:""}${w}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${Z>0?`${Z}S`:""}`,o.ISOPeriod=`P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${l>0?`${l}D`:""}${w}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${Z>0?`${Z}S`:""}`),o};function n(){let t=(...i)=>m=>i.reduce((T,l)=>l(T),m),a=(i,m)=>i===1?m.slice(0,-1):m;return t(({values:i,full:m})=>[Object.entries(i).filter(([T])=>/^(years|month|days|hours|minutes|seconds)/i.test(T)),m],([i,m])=>m?i:i.filter(([,T])=>m?+T:T>0),i=>i.reduce((m,[T,l])=>[...m,`${l} ${a(l,T)}`],[]),i=>i.length<1?"Dates are equal":`${i.slice(0,-1).join(", ")}${i.length>1?" and ":""}${i.slice(-1).shift()}`)}}var ie=Ae;function Ae(){let e=Object.entries({year:"FullYear",month:"Month",date:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds",millisecond:"Milliseconds"}).reduce((t,[a,o])=>({...t,[a]:o,[`${a}s`]:o}),{}),r=!1,n=function(...t){let a=t.length===1;return r=t[0].trim().startsWith("subtract,"),r&&(t=a?t[0].trim().replace(/^subtract,/i,"").split(",").map(o=>o.trim()):t.filter(o=>!o.startsWith("subtract"))),a&&!r&&(t=t[0].split(",").map(o=>o.trim())),t.map(function(o){if(!o)return!1;let s=o.toLowerCase().split(/ {1,}/);return s.length<2?!1:s.map(u=>{u=`${u}`.trim().replace(/[^a-z0-9-+]/g,"");let c=parseInt(u,10);return Number.isNaN(c)?u:r?-c:+c})}).filter(o=>o)};return function(t,...a){if(a.length<1)return t;let o=n(...a);return o.length&&o.forEach(([s,u])=>{u=u,u=e[u],s&&u&&t[`set${u}`](t[`get${u}`]()+s)}),t}}var ge=le(),ye=Ye(),N=ie(),We=["sun","mon","tue","wed","thu","fri","sat"],he=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function q(e,r=!1){let n=e.month+1,t=e.month;if(e.month+=r?-1:1,!r&&e.month>=n)for(;e.month>n;)e.dateNr-=1;if(r&&e.month===t)for(;e.month>=t;)e.dateNr-=1;return e}function H(e,...r){return N(e,...r),e}function De(e,r=!1){let n=Q(e.clone,{sunday:r}),t=[n];return{weekStart:n.format("WD","l:en-GB"),inputDate:e,dates:t.concat([...Array(6)].map((a,o)=>n.clone.addDays(o+1)))}}function W(e,{start:r,end:n,future:t,past:a,include:o={start:!1,end:!1}}={}){let s=e.clone.UTC;return r=r?.value||r?.constructor===Date?f(r?.value||r).UTC:f.now.UTC,n=n&&n?.value||n?.constructor===Date?f(n?.value||n).UTC:f.now.UTC,s.milliseconds=0,r.milliseconds=0,n.milliseconds=0,t?r>n:a?r<n:(o.start?+s>=+r:+s>+r)&&(o.end?+s<=+n:+s<+n)}function _(e,{zoneTime:r=!1,formatStr:n,moreOptions:t}={}){return t=r?e.localeInfo.formatOptions+(t?`,${t}`:""):g.formatOptions+(t?`,${t}`:""),r?(e.localeInfo||(e.localeInfo=g),M(e,n,t)):Ue(e,n,t)}function Ue(e,r,n){let t=e.clone.relocate(g);return n=(n||"").startsWith("+")?`${t.localeInfo.formatOptions},${n.slice(1)}`:n||t.localeInfo.formatOptions,M(t,r,n)}function Te(e,r){let n=ge({start:e,end:r||e});return parseInt(`${n.sign}${n.diffInDays}`)}function G(e,r=!1){let{locale:n,timeZone:t}=r?e.localeInfo:g,a=se(n,t),o=e.format("MM|WD",a).split("|");return{locale:n,timeZone:t,monthName:o[0],dayName:o[1],dayNames:ae(n),monthNames:Y(n)}}function B(e,r=!1){let[n,t,a,o]=U(e,r),u={values4Timezone:r?g.timeZone:e.timeZone,hours:n,minutes:t,seconds:a,milliseconds:o};return Object.freeze(u)}function U(e,r=!1){let t=`l:en-CA,${r?`tz:${g.timeZone}`:`tz:${e.timeZone}`},hrc:23,ts:medium`;return e.format("",t).split(/:/).map(Number).concat(e.getMilliseconds())}function J(e,r){let n=r?`tz:${g.timeZone}`:`,tz:${e.timeZone}`,[t,a,o]=e.format("yyyy-mm-dd",n).split(/-/).map(Number);a-=1;let s=r?g.timeZone:e.timeZone;return Object.freeze({values4Timezone:s,year:t,month:a,date:o})}function K(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate()];let n=e.format("yyyy-m-d",e.localeInfo.formatOptions).split(/-/).map(Number);return n[1]-=1,n}function Le(e){let r=new Intl.Locale(e.locale),n=r.weekInfo?r.weekInfo.firstDay:r.getWeekInfo?r.getWeekInfo().firstDay:1;return n=n===7?0:n,he[n]}function Q(e,{sunday:r=!1}={}){let n=r?"sunday":Le(e);return x(e,{day:n,preserveTodayWhenEqual:!0})}function xe(e,r){let n=e.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000",t=r.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000";return n=A(n.slice(0,3)+":"+n.slice(-2),!0),t=A(t.slice(0,3)+":"+t.slice(-2),!0),[-n[0]+t[0],-n[1]+t[1]].map(a=>n[0]<0?-a:a)}function R({start:e,end:r}={}){r||(r=e.clone),r?.clone||(r=f(r,{timeZone:e.timeZone})),e=f(fe(e,e.timeZone),{timeZone:e.timeZone}),r=f(fe(r,r.timeZone),{timeZone:r.timeZone});let n=ge({start:e,end:r,diffs:{timeZoneStart:e.timeZone,timeZoneEnd:r.timeZone}}),t=xe(r,e),a=n.sign.startsWith("-")?"ahead of":"behind",[o,s]=t.map(i=>Math.abs(i)),[u,c]=[`${o} ${C(o,"hour")}`,`${s} ${C(s,"minute")}`];return n.timeZonesOffsetDifference=n.sign.length<1||o+s===0?`Offsets of ${e.timeZone} and ${r.timeZone} are equal`:`${e.timeZone} is ${u}${s>0?` and ${c}`:""} ${a} ${r.timeZone}`,n}function X(e,r){r=String(r).toLowerCase()==="utc"||r.timeZone==="UTC"?e.clone.relocate({timeZone:"UTC"}):f(e.value,{timeZone:r.timeZone||g.timeZone});let t=R({start:e.clone,end:r}),o=`${t.sign}${ce(t.hours)}:${ce(t.minutes)}`;return{fromTZ:e.timeZone,toTZ:r.timeZone,offset:o,offsetText:`${r.timeZone} ${je(o)} ${e.timeZone}`}}function ce(e,r=2){return`${e}`.padStart(r,"0")}function C(e,r){return`${r}${e>1||e===0?"s":""}`}function je(e){if(/00:00/.test(e))return"no time diffence to";let r=e.slice(1).split(":").map(Number),[n,t]=r,a=C(n,"hour"),o=C(t,"minute"),s=e.startsWith("+");return t>0?`${n} ${a} and ${t} ${o} ${s?"ahead of":"behind"}`:`${n} ${a} ${s?"ahead of":"behind"}`}function me(e,r,n){return e.clone.format(r,n||e.localeInfo.formatOptions)}function pe(e,{withFormat:r,withFormatOptions:n,local:t=!1}={}){if(r)return t?me(e,r,$D.localeInformation.formatOptions):me(e,r,n);let a=e.clone.relocate({locale:"en"}),o=t?g.formatOptions:a.localeInfo.formatOptions,u=`wd M dd yyyy hh:mmi:ss ${a.format("tz",o+",tzn:longOffset").replace(":","")} (tz)`;return a.format(u,o+",tzn:long, hrc:23")}function ee(e,r=!1){let n=Intl.DateTimeFormat("en",{timeZone:r?e.timeZone:g.timeZone,weekday:"short"});return ye(n.format(e))}function $e(e){let r=g,n=e.localeInfo,t=e.clone.relocate({locale:r.locale,timeZone:r.timeZone}),a=e.offsetFrom(t),o=t.offsetFrom(e),s=r,u=n,c=e.format("hh:mmi:ss dp",`hrc:12,tz:${e.timeZone}`),i=t.format("hh:mmi:ss dp",`hrc:12,tz:${t.timeZone}`),m={note:"'user' are values for your locale/timeZone, 'remote' (if applicable) idem for the instance",locales:{user:{locale:s.locale,timeZone:s.timeZone}},dateTime:{user:{...e.dateTime,monthName:t.monthName,weekdayNr:t.day,weekdayName:t.dayName,dayPeriodTime:i,hasDST:t.hasDST,DSTActive:t.DSTActive,offsetFromRemote:a.offset,string:t.toString()}},offset:{fromUTC:e.UTC.offsetFrom(e).offsetText}};return n.timeZone!==r.timeZone&&(m.locales.remote={locale:u.locale,timeZone:u.timeZone},m.dateTime.remote={...e.zoneDateTime,monthName:e.zoneNames.monthName,weekdayNr:ee(e,!0),weekdayName:e.zoneNames.dayName,dayPeriodTime:c,hasDST:e.hasDST,DSTActive:e.DSTActive,offsetFromUser:o.offset,string:e.toString()},m.offset.fromUserTime=o.offsetText),m}function O(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];let n=e.format("yyyy-m-d-hh-mmi-ss",`${e.localeInfo.formatOptions},hrc23:true`).split(/-/).map(Number).concat(e.getMilliseconds());return n[1]-=1,n}function te(e){return new Date(e.year,e.month+1,0,0,0,0).getDate()}function L(e,r){r=p({locale:r||e.localeInfo.locale}).locale;let n=e.clone.relocate({locale:r});return n.date={date:1},[n].concat([...Array(te(n)-1)].map((t,a)=>n.clone.add(`${a+1} days`)))}function x(e,{day:r,next:n=!1,preserveTodayWhenEqual:t=!1}={}){r=r?.toLowerCase()||"-";let a=ye(r);if(a<0)return console.error(`[TickTock instance].next/previous invalid day value ${r}`),e.clone;let o=n?1:-1,s=f(new Date(...e.dateTimeValues),e.localeInfo);return t&&a===s.day?s:Pe(s.addDays(n?1:-1),a,o)}function Pe(e,r,n){function t(a){return!0===(a.day===r)?a:t(a.add(`${n} days`))}return t(e)}function F(e,{dateOnly:r=!1,timeOnly:n=!1}={}){let{locale:t,timeZone:a}=e.localeInfo;return r?new Date(e).toLocaleDateString(t,{timeZone:a}):n?new Date(e).toLocaleTimeString(t,{timeZone:a}):new Date(e).toLocaleString(t,{timeZone:a})}function fe(e,r){let n={timeZone:r,hourCycle:"h23"};return new Date(new Date(e).toLocaleString("en",n))}function v(e,{year:r,month:n,date:t}={}){return S(r)&&e.setFullYear(parseInt(r)),S(t)&&e.setDate(parseInt(t)),S(n)&&e.setMonth(parseInt(n)),e}function I(e,{hours:r,minutes:n,seconds:t,milliseconds:a}={}){return S(r)&&e.setHours(parseInt(r)),S(n)&&e.setMinutes(parseInt(n)),S(t)&&e.setSeconds(parseInt(t)),S(a)&&e.setMilliseconds(parseInt(a)),e}function we(e){return e?.constructor===Date||e?.value}function re(e,r){return we(r)?f(r?.value||r,e.localeInfo):f.from(...e.dateTimeValues).relocate(e.localeInfo)}function Ye(){return function(e){e=`${e}`.toLowerCase();let r=We.indexOf(e);return r<0?he.indexOf(e):r}}function A(e){let r=e.slice(1).split(/[-:]/).map(Number),n=e.startsWith("-");return r=r.map(t=>n?-t:t),r}function Se(e){return e.time={hours:0,minutes:0,seconds:0,milliseconds:0},e}function de(e,r){return Intl.DateTimeFormat("en-CA",{timeZone:r,timeZoneName:"long"}).format(e).split(/,/)[1].trim()}function j(e,r){r=r||e?.timeZone||g.timeZone,e=e?.value?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r});let n=e.year||e.getFullYear(),t=de(new Date(n,0,1),r),a=de(new Date(n,5,1),r);return t!==a}function P(e,r){return r=r||e?.timeZone||g.timeZone,e=e?.hasDST?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r}),e.hasDST?!/standard/i.test(e.toString()):!1}function Ze(e,{locale:r,timeZone:n,l:t,tz:a}={}){return e.localeInfo=p({locale:t||r||e.l||e.locale,timeZone:a||n||e.tz||e.timeZone}),e}function be(e,r){return we(r)&&(e=f(r.value||r,r.localeInfo||e.localeInfo)),e}function k(e,r){let n=oe(new Date(e,11,r||31));return n===1?k(e,(r||31)-1):n}function ne(e,r){let n=e.month;switch(!0){case n<3:return r?1:"First";case n<6:return r?2:"Second";case n<9:return r?3:"Third";case n<12:return r?4:"Fourth";default:return"unknown"}}function oe(e){let r=new Date(e),n=(r.getDay()+6)%7;r.setDate(r.getDate()-n+3);let t=r.valueOf();return r.setMonth(0,1),r.getDay()!==4&&r.setMonth(0,1+(4-r.getDay()+7)%7),1+Math.ceil((t-r)/6048e5)}var E=Ee;function Ee({localeInfo:e,customMethods:r,dateValue:n}={}){let t,a={add(...o){return H(t,...o)},between({start:o,end:s,include:u}={}){return W(t,{start:o,end:s,include:u})},cloneWith(o){return re(t,o)},daysUntil(o){return Te(t,o)},differenceTo(o){return R({start:t,end:o})},differenceUntil(o){return t.differenceTo(o).clean},firstWeekday({sunday:o=!1,midnight:s=!1}={}){return Q(t,{sunday:o,midnight:s})},format(o,s){return _(t,{formatStr:o,moreOptions:s})},fullMonth(o){return L(t,o)},fullWeek(o=!1){return De(t,!!o)},isFuture(o){return W(t,{start:t,end:o,future:!0})},isPast(o){return W(t,{start:t,end:o,past:!0})},next(o,s){return x(t,{day:o,next:!0,preserveTodayWhenEqual:!!s})},offsetFrom(o){return X(t,o)},previous(o,s){return x(t,{day:o,next:!1,preserveTodayWhenEqual:!!s})},relocate({locale:o,timeZone:s,l:u,tz:c}={}){return Ze(t,{locale:o,timeZone:s,l:u,tz:c})},revalue(o){return t=be(t,o),t},setDateValues({year:o,month:s,date:u}={}){return v(t,{year:o,month:s,date:u})},setTimeValues({hours:o,minutes:s,seconds:u,milliseconds:c}={}){return I(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},subtract(...o){return H(t,"subtract,"+o.join(","))},toArray(o=!1){return O(t,o)},toString({template:o,formatOptions:s,local:u}={}){return pe(t,{withFormat:o,withFormatOptions:s,local:u})},values(o=!1){return o?t.dateTime:t.zoneDateTime},zoneFormat(o,s){return _(t,{zoneTime:!0,formatStr:o,moreOptions:s})},set date({year:o,month:s,date:u}){v(t,{year:o,month:s,date:u})},set dateNr(o){v(t,{date:o})},set hours(o){I(t,{hours:o})},set localeInfo({locale:o,timeZone:s,l:u,tz:c}){e=z({locale:o,timeZone:s,l:u,tz:c})},set milliseconds(o){I(t,{milliseconds:`${o}`})},set minutes(o){I(t,{minutes:o})},set month(o){v(t,{month:o})},set seconds(o){I(t,{seconds:o})},set time({hours:o,minutes:s,seconds:u,milliseconds:c}){I(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},set year(o){v(t,{year:o})},get age(){return t.differenceTo(new Date).years},get ageFull(){return t.differenceTo(new Date).clean},get clone(){return re(t)},get date(){return J(t,!0)},get dateNr(){return t.date.date},get dateTime(){return{...t.date,...t.time}},get dateTimeValues(){return O(t,!0)},get dateValues(){return K(t,!0)},get day(){return t.getDay()},get dayName(){return t.names.dayName},get daysThisMonth(){return te(t)},get DSTActive(){return P(t)},get hasDST(){return j(t)},get hours(){return t.time.hours},get info(){return $e(t)},get isLeapYear(){return new Date(t.getFullYear(),2,0).getDate()===29},get ISO(){return t.toISOString()},get local(){return F(t)},get localDate(){return F(t,{dateOnly:!0})},get locale(){return(e||z()).locale},get localeInfo(){return e},get localeString(){return F(t)},get localTime(){return F(t,{timeOnly:!0})},get milliseconds(){return t.getMilliseconds()},get minutes(){return t.time.minutes},get month(){return t.date.month},get monthName(){return t.names.monthName},get names(){return G(t)},get quarter(){return ne(t)},get quarterNr(){return ne(t,!0)},get removeTime(){return Se(t)},get seconds(){return t.time.seconds},get time(){return B(t,!0)},get timeValues(){return U(t,!0)},get timeZone(){return(e||z()).timeZone},get unixEpochTimestamp(){return Math.floor(+t/1e3)},get userLocaleInfo(){return g},get UTC(){return t.clone.relocate({locale:t.locale,timeZone:"UTC"})},get UTCOffset(){return X(t,"UTC")},get value(){return new Date(t)},get weeknr(){return oe(t)},get weeksInYear(){return k(t.year,31)},get year(){return t.date.year},get zoneDate(){return J(t,!1)},get zoneDateNr(){return t.zoneDate.date},get zoneDateTime(){return{...t.zoneDate,...t.zoneTime}},get zoneDateTimeValues(){return O(t,!1)},get zoneDateValues(){return K(t,!1)},get zoneDay(){return ee(t,!0)},get zoneDayname(){return t.zoneNames.dayName},get zoneHours(){return t.zoneTime.hours},get zoneMinutes(){return t.zoneTime.minutes},get zoneMonth(){return t.zoneDate.month},get zoneMonthname(){return t.zoneNames.monthName},get zoneNames(){return G(t,!0)},get zoneSeconds(){return t.zoneTime.seconds},get zoneTime(){return B(t)},get zoneTimeValues(){return U(t)},get zoneYear(){return t.zoneDate.year},get zoneValues(){return t.zoneDateTime},get zoneArray(){return O(t,!1)}};return!e&&!n?a:(a.localeInfo=e||z(),t=new Proxy(n,Ve(a)),Object.entries(Object.getOwnPropertyDescriptors(ue(t,r))).forEach(([o,s])=>Object.defineProperty(a,o,s)),Object.freeze(t))}function Ve(e){return{get(r,n){return n!=="toString"&&n in r?r[n].bind(r):Reflect.get(e,n)},set(r,n,t){return n in e&&Reflect.set(e,n,t)}}}var g=Me(Intl.DateTimeFormat().resolvedOptions()),qe=Object.getOwnPropertyNames(Date.prototype).filter(e=>e.startsWith("set")).reduce((e,r)=>[...e,{native:r,syn:"change"+r.slice(3)}],[]);function ae(e="en-GB"){return e=p({locale:e}).locale,{long:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"long"})),short:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"short"}))}}function Y(e="en"){return e=p({locale:e}).locale,{long:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"long"})),short:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"short"}))}}function He({year:e,locale:r}={}){e=S(e)?parseInt(e):new Date().getFullYear();let n={year:e,calendar:{}},t=Y().long.map(a=>a.toLowerCase());for(let a=0;a<12;a+=1){let o=f.from(e,a,1);n.calendar[t[a]]=L(o,r)}return n}function _e({year:e,monthNr:r,locale:n="en-CA"}={}){e=S(r)&&parseInt(e)||-1,r=S(r)&&parseInt(r)||new Date().getFullYear();let t=r>=1&&r<=12;return n=p({locale:n}).locale,r=t?r-1:void 0,t?f.from(e,r,1).relocate({locale:n}).fullMonth(n):"MonthNr should be a specific number (1 = january - 12 = december)"}function Me(e){let r=se(e.locale,e.timeZone),n=new Intl.Locale(e.locale);return e.weekInfo=n.getWeekInfo?n.getWeekInfo():null,Object.defineProperty(e,"formatOptions",{value:r,enumerable:!1})}function se(e,r){return[`${e&&!(Array.isArray(e)&&e.length<1)?`l:${e}`:""}`,`${r?`tz:${r}`:""}`].filter(n=>n).join(",")}function p({locale:e,timeZone:r,l:n,tz:t}={}){return r=r||t,e=e||n,e=Ie({trial:function(){return Intl.DateTimeFormat(e,{timeZone:g.timeZone}).resolvedOptions().locale},onError:function(){return console.warn(`Intl locale "${e}" best fit impossible, using "${g.locale}"`),g.locale}}),r=Ie({trial:function(){return Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions().timeZone},onError:function(){return console.warn(`timeZone "${r}" not valid. Using "${g.timeZone}"`),g.timeZone}}),Me(Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions())}function z({locale:e,timeZone:r,l:n,tz:t}={}){return p({locale:e,timeZone:r,l:n,tz:t},!0)}function Ne(e){return!Number.isNaN(+e)&&e?.constructor===Date?e:new Date}function ve(e){let r=new Date;switch(!0){case(typeof e=="string"||typeof e=="number"):return Ne(new Date(e));case(Array.isArray(e)&&e.map(Number).length===e.length):return e.length===1?new Date(e[0],0,1):new Date(...e);case e?.constructor===Date:return Ne(e);default:return r}}function Ie({trial:e,onError:r=()=>{}}={}){if(e?.constructor===Function)try{return e()}catch(n){return r?.constructor===Function?r(n):void 0}}function Ge({timeZoneDate:e,timeZoneID:r,userTimeZoneID:n}={}){let t={timeZone:p({timeZone:r}).timeZone},a={timeZone:p({timeZone:n||""}).timeZone},o=f(e,t),s=f(e,a),u=s.differenceTo(o),c=o.offsetFrom(s).offset,[i,m]=A(c,!0),T=s.clone.add(`${i} hours, ${m} minutes`),y=u.equalDates?"No difference":`Time offset ${c}: ${a.timeZone} is ${u.clean} ${i<0?"behind":"ahead of"} ${t.timeZone}`;return{remoteTimezone:t.timeZone,userTimezone:a.timeZone,timeDifference:y,result:{[t.timeZone.replace(/\//,"_")]:f(e).toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"}),[a.timeZone.replace(/\//,"_")]:T.toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"})}}}function S(e){return!Number.isNaN(parseInt(e))}function V(e,r,n){return e?.constructor===Number?N(r,`${e} ${n}`):r}function Be(e){let r={addYears(n=1){return V(n,e,"years")},addMonths(n=1){return V(n,e,"months")},addWeeks(n=1){return n=n?.constructor===Number?n*7:1,V(n,e,"days")},addDays(n=1){return V(n,e,"days")},get nextYear(){return N(e,"1 year")},get nextWeek(){return N(e,"7 days")},get previousWeek(){return N(e,"-7 days")},get previousYear(){return N(e,"-1 year")},get nextMonth(){return q(e)},get previousMonth(){return q(e,!0)},get tomorrow(){return N(e,"1 day")},get yesterday(){return N(e,"-1 day")}};for(let n of qe)r[n.syn]=function(...t){return e[n.native](...t),e};return r}function ue(e,r){let n=Be(e);for(let[t,a]of Object.entries(r||{})){let o=a.enumerable,s=a.isGetter?{get(){return a.method(e)},enumerable:o}:{value(...u){return a.method(e,...u)},enumerable:o};Object.defineProperty(n,t,s)}return n}function ze(e,r){return Object.defineProperties(e,{now:{get(){return e(new Date)}},localeInformation:{get(){return p()}},localWeekdaynames:{value(n){return ae(n)}},localMonthnames:{value(n){return Y(n)}},daysInMonth:{value(n,t=!1){return n=S(n)?parseInt(n):0,n>=1&&n<=12?new Date(t?2e3:2005,n,0).getDate():`${n} should be a Number between (1 (january) - 12 (december))`}},yearCalendar:{value:He},monthCalendar:{value:_e},from:{value(...n){return e(n)}},fromUxTS:{value(n,t){n=S(n)?parseInt(n)*1e3:void 0;let a=n?new Date(n):new Date;return f(a,t||g)}},hasDST:{value({date:n,timeZone:t}={}){return j(n,t)}},DSTActive:{value({date:n,timeZone:t}={}){return P(n,t)}},values:{value({date:n,timeZone:t}={}){n=n||n?.value||new Date;let a=M(n,"yyyy-m-d-h-mi-s",p({timeZone:t}).formatOptions.concat(",hrc:23")).split("-").map(Number).concat(n.getMilliseconds());return a[1]-=1,a}},format:{value({date:n,template:t,timeZone:a,locale:o,opts:s}={}){n=n||n?.value||new Date,t=t?.constructor===String?t:"yyyy/mm/dd hh:mmi:ss dp";let u=p({timeZone:a,locale:o}).formatOptions;return u+=s?`,${s}`:"",M(n,t,u)}},addCustom:{value({name:n,method:t,enumerable:a=!1,isGetter:o=!1}={}){n?.constructor===String&&t?.constructor===Function&&t.length>0&&(r[n]={method:t,enumerable:a,isGetter:o})}},validateLocaleInformation:{value:p},timeAcrossZones:{value:Ge},weeksInYear:{value(n){return k(n,31)}},keys:{get(){let n=Object.fromEntries(Object.entries(r).filter(([a,o])=>o.enumerable===!0));return[...Object.keys(E()),...Object.keys(ue()),...Object.keys(n)].sort((a,o)=>a.localeCompare(o))}}}),e}var Oe={},f=ze(Je,Oe);function Je(e,r){if(e?.localeInfo)return e.clone;let n=e?.locale||e?.timeZone||e?.tz||e?.l;return E({localeInfo:p(n?e:r),dateValue:new Date(n?Date.now():ve(e)),customMethods:Oe})}export{f as default};
package/index.js CHANGED
@@ -59,5 +59,5 @@ function tryJSON(content, formatted) {
59
59
  }
60
60
 
61
61
  function setDefaultStyling() {
62
- $.editCssRules(`li::marker{vertical-align:top;}`,`code{color:green;background-color:#eee;padding:2px;font-family:monospace;}`,`code.codeblock{display:block;padding:6px;border:1px solid #999;margin:0.5rem 0;background-color:#eee;white-space:pre-wrap;}`,`h3{marginTop:1.5rem;}`,`.thickBorder{border:5px solid green;borderWidth:5px;padding:0.5rem;display:inline-block;}`,`a.ExternalLink{text-decoration:none;color:rgb(0,0,238);background-color:#EEE;padding:3px;font-weight:bold;}`,`.cmmt{color:#888;}`,`.hidden{display:none;}`,`.attention{color:red; font-size:1.2em; font-weight:bold;}`,`#log2screen li{listStyle:'\\2713';paddingLeft:6px;margin:0.5rem 0 0 -1.2rem;font-family:monospace}`,`#log2screen li.head{list-style-type:none;font-weight:bold;margin-top:0.8rem;margin-bottom:-0.2rem;font-family:revert;}`,`.err{fontStyle:italic; color:red; }`,`a{text-decoration:none; font-weight:bold;}`,`a:hover{text-decoration:underline;}`,`a[target]:before,a.internalLink:before,a.externalLink:before{color:rgba(0,0,238,0.7);font-size:1.1rem;padding-right:2px;vertical-align:baseline;}`,`a[target="_blank"]:before,a.externalLink:before{content:'\\2197';}`,`a[data-top]:before,a.internalLink:before,a[target="_top"]:before{content:'\\21BA';}`);
62
+ $.editCssRules(`:root{--grey-default:rgba(112,92,92,0.9);--code-color:#555;}`,`li::marker{vertical-align:top;}`,`code:not(.hljs,.codeblock){background-color:rgb(227, 230, 232);color:var(--code-color);padding:1px 2px;display:inline-block;margin:1px 0px;border-radius:4px;font-style:normal;font-weight:normal;}`,`code.codeblock{display:block;padding:6px;border:1px solid #999;margin:0.5rem 0;background-color:#eee;white-space:pre-wrap;}`,`h3{marginTop:1.5rem;}`,`.thickBorder{border:5px solid green;borderWidth:5px;padding:0.5rem;display:inline-block;}`,`a.ExternalLink{text-decoration:none;color:rgb(0,0,238);background-color:#EEE;padding:3px;font-weight:bold;}`,`.cmmt{color:#888;}`,`.hidden{display:none;}`,`.attention{color:red; font-size:1.2em; font-weight:bold;}`,`#log2screen li{listStyle:'\\2713';paddingLeft:6px;margin:0.5rem 0 0 -1.2rem;font-family:monospace}`,`#log2screen li.head{list-style-type:none;font-weight:bold;margin-top:0.8rem;margin-bottom:-0.2rem;font-family:revert;}`,`.err{fontStyle:italic; color:red; }`,`a{text-decoration:none; font-weight:bold;}`,`a:hover{text-decoration:underline;}`,`a[target]:before,a.internalLink:before,a.externalLink:before{color:rgba(0,0,238,0.7);font-size:1.1rem;padding-right:2px;vertical-align:baseline;}`,`a[target="_blank"]:before,a.externalLink:before{content:'\\2197';}`,`a[data-top]:before,a.internalLink:before,a[target="_top"]:before{content:'\\21BA';}`);
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamic-html-helpers",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Helpers for ES/JS/HTML projects",
5
5
  "keywords": [
6
6
  "es20xx",