diff --git a/package/build/vanilla-calendar.min.js b/package/build/vanilla-calendar.min.js index 12421e2b..6007a99c 100644 --- a/package/build/vanilla-calendar.min.js +++ b/package/build/vanilla-calendar.min.js @@ -1,2 +1,2 @@ /*! name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar */ -"use strict";var e=Object.defineProperty,t=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(t,s,l)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,n=(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s);const i=e=>{const t=e.getFullYear();let s=e.getMonth()+1,l=e.getDate();return s=s<10?`0${s}`:s,l=l<10?`0${l}`:l,`${t}-${s}-${l}`},d=e=>{const t=[];return e.forEach((e=>{e.match(/^(\d{4}-\d{2}-\d{2})$/g)?t.push(e):e.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g,((e,s,l)=>{const a=new Date(`${s} 00:00:00`),n=new Date(`${l} 00:00:00`),d=new Date(a.getTime());for(;d<=n;d.setDate(d.getDate()+1))t.push(i(d));return e}))})),t},r=e=>{const t=Number(e);let s=String(t);return 0===t?s="12":13===t?s="01":14===t?s="02":15===t?s="03":16===t?s="04":17===t?s="05":18===t?s="06":19===t?s="07":20===t?s="08":21===t?s="09":22===t?s="10":23===t&&(s="11"),s},c=e=>{var t,s;e.rangeMin=e.settings.range.min,e.rangeMax=e.settings.range.max,e.rangeDisabled=e.settings.range.disabled?d([...e.settings.range.disabled]):[],e.rangeEnabled=e.settings.range.enabled?d([...e.settings.range.enabled]):[],e.selectedDates=e.settings.selected.dates?d([...e.settings.selected.dates]):[],e.selectedHolidays=e.settings.selected.holidays?d([...e.settings.selected.holidays]):[],e.settings.range.disablePast&&!e.settings.range.disableAllDays&&new Date(`${e.settings.range.min} 00:00:00`)+new Date(e)-+new Date(t))),(null==(s=e.rangeEnabled)?void 0:s[0])&&e.settings.range.disableAllDays&&(e.rangeMin=e.rangeEnabled[0],e.rangeMax=e.rangeEnabled[e.rangeEnabled.length-1]);const l=new Date(`${e.rangeMin} 00:00:00`),a=new Date(`${e.rangeMax} 00:00:00`);l.setDate(l.getDate()-1),a.setDate(a.getDate()+1),e.rangeDisabled.push(i(l)),e.rangeDisabled.push(i(a)),null!==e.settings.selected.month&&e.settings.selected.month>=0&&e.settings.selected.month<12?e.selectedMonth=e.settings.selected.month:e.selectedMonth=e.date.today.getMonth(),null!==e.settings.selected.year&&e.settings.selected.year>=0&&e.settings.selected.year<=9999?e.selectedYear=e.settings.selected.year:e.selectedYear=e.date.today.getFullYear(),e.viewYear=e.selectedYear,e.dateMin=e.settings.visibility.disabled?new Date(`${e.date.min} 00:00:00`):new Date(`${e.rangeMin} 00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max} 00:00:00`):new Date(`${e.rangeMax} 00:00:00`);const n=!0===e.settings.selection.time||12===e.settings.selection.time;if(n||24===e.settings.selection.time){if(e.userTime=!1,"string"==typeof e.settings.selected.time){const t=n?/^([0-9]|0[1-9]|1[0-2]):([0-5][0-9])|(AM|PM)/g:/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])/g;e.settings.selected.time.replace(t,((t,s,l,a)=>(s&&l&&(e.userTime=!0,e.selectedHours=s,e.selectedMinutes=l),a&&n?e.selectedKeeping=a:n&&(e.selectedKeeping="AM"),"")))}!e.userTime&&n?(e.selectedHours=r(String(e.date.today.getHours())),e.selectedMinutes=String(e.date.today.getMinutes()),e.selectedKeeping=Number(e.date.today.getHours())>=12?"PM":"AM"):e.userTime||(e.selectedHours=String(e.date.today.getHours()),e.selectedMinutes=String(e.date.today.getMinutes())),e.selectedHours=Number(e.selectedHours)<10?`0${Number(e.selectedHours)}`:`${e.selectedHours}`,e.selectedMinutes=Number(e.selectedMinutes)<10?`0${Number(e.selectedMinutes)}`:`${e.selectedMinutes}`,e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`}else e.settings.selection.time&&(e.settings.selection.time=!1,console.error("The value of the time property can be: false, true, 12 or 24."));"multiple"===e.type&&(1===e.months?(console.warn("The value of the «months» parameter cannot be less than «2», the minimum available value will be initialized."),e.correctMonths=2):e.months>12?(console.warn("The value of the «months» parameter cannot be greater than «12», the maximum available value will be initialized."),e.correctMonths=12):e.correctMonths=e.months)},o=e=>{if(!["default","multiple","year"].includes(e.currentType))return;const t=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowPrev}`),s=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowNext}`);if(!t||!s)return;"default"!==e.currentType&&"multiple"!==e.currentType||(()=>{if(!e.dateMin||!e.dateMax)return;const l=e.selectedMonth===e.dateMin.getMonth(),a=e.selectedMonth===e.dateMax.getMonth(),n=!e.settings.selection.year||e.selectedYear===e.dateMin.getFullYear(),i=!e.settings.selection.year||e.selectedYear===e.dateMax.getFullYear();l&&n||!e.settings.selection.month?t.style.visibility="hidden":t.style.visibility="",a&&i||!e.settings.selection.month?s.style.visibility="hidden":s.style.visibility=""})(),"year"===e.currentType&&e.dateMin&&e.dateMax&&void 0!==e.viewYear&&(e.dateMin.getFullYear()&&e.viewYear-7<=e.dateMin.getFullYear()?t.style.visibility="hidden":t.style.visibility="",e.dateMax.getFullYear()&&e.viewYear+7>=e.dateMax.getFullYear()?s.style.visibility="hidden":s.style.visibility="")},u=(e,t)=>{if(!e)return null;const s=new Date(`${e} 00:00:00`).getDate(),l=new Date(`${e} 00:00:00`).getMonth(),a=new Date(`${e} 00:00:00`).getFullYear(),n=new Date(a,l,s),i=t?n.getDay()||7:n.getDay();n.setDate(n.getDate()+4-i);const d=new Date(n.getFullYear(),0,1);return{year:a,week:Math.ceil(((+n-+d)/864e5+1)/7)}},v=e=>{var t,s;const l=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.days}`),a=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.weekNumbers}`),n=new Date(e.selectedYear,e.selectedMonth,1),d=document.createElement("div"),r=document.createElement("button");d.className=e.CSSClasses.day,r.className=e.CSSClasses.dayBtn,r.type="button",null==(t=e.selectedDates)||t.sort(((e,t)=>+new Date(e)-+new Date(t))),l.forEach(((t,s)=>{const c=new Date(n.setMonth(e.selectedMonth+s)).getMonth(),o=new Date(n.setFullYear(e.selectedYear,e.selectedMonth+s)).getFullYear(),v=new Date(o,c,1),m=new Date(o,c+1,0).getDate();let g=Number(v.getDay());e.settings.iso8601&&(g=Number((0!==v.getDay()?v.getDay():7)-1)),e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&l[s].classList.add(e.CSSClasses.daysSelecting),l[s].innerHTML="";const y=(t,a,n,i,c)=>{var v,m,g,y,h,S,p,b,C;const M=d.cloneNode(!0),D=r.cloneNode(!0);if(c&&D.classList.add(c),D.innerText=t,D.dataset.calendarDay=n,e.settings.visibility.weekNumbers){const t=u(n,e.settings.iso8601);if(!t)return;D.dataset.calendarWeekNumber=`${t.week}`}(null==(v=e.rangeEnabled)?void 0:v[0])&&e.settings.range.disableAllDays&&!(null==(m=e.rangeDisabled)?void 0:m.includes(n))&&(null==(g=e.rangeDisabled)||g.push(n)),(null==(y=e.rangeEnabled)?void 0:y[0])&&(null==(h=e.rangeDisabled)?void 0:h.includes(n))&&(e.rangeDisabled=null==(S=e.rangeDisabled)?void 0:S.filter((t=>{var s;return!(null==(s=e.rangeEnabled)?void 0:s.includes(t))}))),(null==(p=e.settings.range.disableWeekday)?void 0:p.includes(a))&&!(null==(b=e.rangeDisabled)?void 0:b.includes(n))&&(null==(C=e.rangeDisabled)||C.push(n)),((t,s,l,a,n)=>{(e.rangeMin>a||e.rangeMax{t===a&&s.classList.add(e.CSSClasses.dayBtnHoliday)}));let i=e.date.today.getDate(),d=e.date.today.getMonth()+1;i=i<10?`0${i}`:i,d=d<10?`0${d}`:d;const r=`${e.date.today.getFullYear()}-${d}-${i}`;e.settings.visibility.today&&s.dataset.calendarDay===r&&s.classList.add(e.CSSClasses.dayBtnToday),e.selectedDates&&0===e.selectedDates.indexOf(a)?("multiple-ranged"===e.settings.selection.day&&e.selectedDates.length>1?t.classList.add(e.CSSClasses.daySelectedFirst):t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates[0]&&e.selectedDates.indexOf(a)===e.selectedDates.length-1?(t.classList.add(e.CSSClasses.daySelected),"multiple-ranged"===e.settings.selection.day?t.classList.add(e.CSSClasses.daySelectedLast):t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&"multiple-ranged"===e.settings.selection.day?(t.classList.add(e.CSSClasses.daySelectedIntermediate),s.classList.add(e.CSSClasses.dayBtnSelected),s.classList.add(e.CSSClasses.dayBtnIntermediate)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&(t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)),Array.isArray(e.rangeDisabled)&&e.rangeDisabled[0]&&e.rangeDisabled.forEach((t=>{t===a&&(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1)})),!e.settings.selection.month&&n&&(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1),e.settings.selection.year||new Date(`${a} 00:00:00`).getFullYear()===o||(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1)})(M,D,a,n,i),i?e.settings.visibility.daysOutside&&M.append(D):M.append(D),l[s].append(M)};(()=>{let t=new Date(o,c,0).getDate()-g,s=o,l=c;0===c?(l=e.locale.months.length,s=o-1):c<10&&(l=`0${c}`);for(let a=0;a{for(let e=1;e<=m;e++){const t=new Date(o,c,e),s=i(t),l=t.getDay();y(String(e),l,s,!1,null)}})(),(()=>{const t=g+m,s=Math.ceil(t/e.locale.weekday.length),l=e.locale.weekday.length*s-t;let a=o,n=String(c+2);c+1===e.locale.months.length?(n="01",a=o+1):c+2<10&&(n=`0${c+2}`);for(let i=1;i<=l;i++){const t=`${a}-${n}-${i<10?`0${i}`:String(i)}`,s=new Date(o,c,i).getMonth()+1,l=new Date(o,s,i).getDay();y(String(i),l,t,!0,e.CSSClasses.dayBtnNext)}})(),((e,t)=>{e.popups&&Object.keys(e.popups).forEach((s=>{var l;const a=t.querySelector(`[data-calendar-day="${s}"]`);if(a){const t=null==(l=e.popups)?void 0:l[s];(null==t?void 0:t.modifier)&&t.modifier.trim().split(" ").forEach((e=>{a.classList.add(e)})),(null==t?void 0:t.html)&&(a.parentNode.innerHTML+=`
${t.html}
`)}}))})(e,l[s]),((e,t,s,l,a)=>{if(!e.settings.visibility.weekNumbers)return;const n=a.querySelectorAll(`.${e.CSSClasses.day}`);l.innerHTML="";const i=Math.ceil((t+s)/7),d=document.createElement("b");d.className=e.CSSClasses.weekNumbersTitle,d.innerText="#",l.append(d);const r=document.createElement("div");r.className=e.CSSClasses.weekNumbersContent,l.append(r);const c=document.createElement("span");c.className=e.CSSClasses.weekNumber;for(let o=0;o+new Date(e)-+new Date(t)))},m=e=>`\n\t\n`,g=e=>`\n\t\n`,y=e=>`\n\t\n`,h=e=>`\n\t\n`,S=e=>`\n\t
\n`,p=e=>`\n\t
\n`,b=e=>`\n\t
\n`,C=e=>`\n\t
\n`,M=e=>e.settings.visibility.weekNumbers?`\n\t
\n`:"",D=e=>e.settings.selection.time?`\n\t
\n`:"",w=(e,t)=>t.replace(/<#(.*?)\/>/g,((t,s)=>{const l=(e=>{let t=null;switch(e){case"ArrowPrev":t=m;break;case"ArrowNext":t=g;break;case"Month":t=y;break;case"Year":t=h;break;case"Week":t=S;break;case"Days":t=p;break;case"Months":t=b;break;case"Years":t=C;break;case"WeekNumbers":t=M;break;case"ControlTime":t=D}return t})(s.replace(/[\s\n\t]/g,""));return l?l(e):""})).replace(/[\n\t]/g,""),$=e=>{const t=e.HTMLElement;switch(t.classList.add(e.CSSClasses.calendar),e.currentType){case"default":t.classList.add(e.CSSClasses.calendarDefault),t.classList.remove(e.CSSClasses.calendarMonth),t.classList.remove(e.CSSClasses.calendarYear),t.innerHTML=w(e,e.DOMTemplates.default);break;case"multiple":if(!e.correctMonths)break;t.classList.add(e.CSSClasses.calendarMultiple),t.classList.remove(e.CSSClasses.calendarMonth),t.classList.remove(e.CSSClasses.calendarYear),t.innerHTML=((e,t)=>t.replace(/<#Multiple>(.*?)<#\/Multiple>/g,((t,s)=>{let l="";for(let a=0;a{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-month]");if(!t[0]||void 0===e.selectedMonth)return;const s=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((l,a)=>{const n=new Date(s.setMonth(e.selectedMonth+a)).getMonth();t[a].dataset.calendarSelectedMonth=String(n),t[a].innerText=e.locale.months[n],e.settings.selection.month&&"multiple"!==e.currentType?(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.monthDisabled)):(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.monthDisabled))}))},L=e=>{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-year]");if(!t||void 0===e.selectedMonth)return;const s=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((l,a)=>{const n=new Date(s.setFullYear(e.selectedYear,e.selectedMonth+a)).getFullYear();t[a].dataset.calendarSelectedYear=String(n),t[a].innerText=String(n),e.settings.selection.year&&"multiple"!==e.currentType?(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.yearDisabled)):(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.yearDisabled))}))},f=e=>{e.currentType="month",$(e),T(e),L(e);const t=e.HTMLElement.querySelector(`.${e.CSSClasses.months}`);if(void 0===e.selectedMonth||void 0===e.selectedYear||!e.dateMin||!e.dateMax||!t)return;e.settings.selection.month&&t.classList.add(e.CSSClasses.monthsSelecting);const s=document.createElement("button");s.type="button",s.className=e.CSSClasses.monthsMonth;for(let l=0;le.dateMax.getMonth()&&e.selectedYear===e.dateMax.getFullYear()&&(n.classList.add(e.CSSClasses.monthsMonthDisabled),n.tabIndex=-1),n.dataset.calendarMonth=String(l),n.title=`${a}`,n.innerText=`${e.settings.visibility.monthShort?a.substring(0,3):a}`,t.append(n)}},k=(e,t)=>{const s=Number(e);let l=String(s);return"AM"===t?12===s&&(l="00"):"PM"===t&&(1===s?l="13":2===s?l="14":3===s?l="15":4===s?l="16":5===s?l="17":6===s?l="18":7===s?l="19":8===s?l="20":9===s?l="21":10===s?l="22":11===s&&(l="23")),l},H=e=>{const t=e.HTMLElement.querySelector(`.${e.CSSClasses.time}`);if(!t)return;const s=!0===e.settings.selection.time?12:e.settings.selection.time,l="range"===e.settings.selection.controlTime;t.innerHTML=`\n\t
\n\t\t\n\t\t\n\t\t${12===s?`\n\t\t\n\t\t`:""}\n\t
\n\t
\n\t\t\n\t\t\n\t
`,((e,t)=>{const s=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="hours"]`),l=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="minutes"]`),a=e.HTMLElement.querySelector(`.${e.CSSClasses.timeHours} input[name="hours"]`),n=e.HTMLElement.querySelector(`.${e.CSSClasses.timeMinutes} input[name="minutes"]`),i=e.HTMLElement.querySelector(`.${e.CSSClasses.timeKeeping}`),d=(t,s)=>{t.addEventListener("mouseover",(()=>s.classList.add(e.CSSClasses.isFocus)))},c=(t,s)=>{t.addEventListener("mouseout",(()=>s.classList.remove(e.CSSClasses.isFocus)))},o=(t,s,l)=>{"hours"===l?e.selectedHours=`${s}`:"minutes"===l&&(e.selectedMinutes=`${s}`),e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`,e.actions.changeTime&&e.actions.changeTime(t,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,e.HTMLInputElement,e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping)},u=(t,s,l,a)=>{t.addEventListener("input",(t=>{let n=Number(t.target.value);n=n<10?`0${n}`:`${n}`,"hours"===l&&12===a?Number(t.target.value)0?(s.value=n,e.selectedKeeping="AM",i.innerText=e.selectedKeeping,o(t,n,l)):(0===Number(t.target.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),s.value=r(t.target.value),o(t,r(t.target.value),l)):(s.value=n,o(t,n,l))}))},v=(t,s,l,a)=>{s.addEventListener("change",(s=>{const n=s.target;let d=Number(n.value);d=d<10?`0${d}`:`${d}`,"hours"===l&&12===a?n.value&&Number(n.value)<=a&&Number(n.value)>0?(n.value=d,t.value=k(d,e.selectedKeeping),o(s,d,l)):n.value&&Number(n.value)<24&&(Number(n.value)>a||0===Number(n.value))?(0===Number(n.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),n.value=r(n.value),t.value=d,o(s,r(n.value),l)):n.value=e.selectedHours:n.value&&Number(n.value)<=a&&Number(n.value)>=0?(n.value=d,t.value=d,o(s,d,l)):"hours"===l?n.value=e.selectedHours:"minutes"===l&&(n.value=e.selectedMinutes)}))};d(s,a),d(l,n),c(s,a),c(l,n),u(s,a,"hours",24===t?23:12),u(l,n,"minutes",0),v(s,a,"hours",24===t?23:12),v(l,n,"minutes",59),i&&i.addEventListener("click",(t=>{i.innerText.includes("AM")?e.selectedKeeping="PM":e.selectedKeeping="AM",s.value=k(e.selectedHours,e.selectedKeeping),o(t,e.selectedHours,"hours"),i.innerText=e.selectedKeeping}))})(e,s)},E=e=>{if(void 0===e.viewYear||!e.dateMin||!e.dateMax)return;e.currentType="year",$(e),T(e),L(e),o(e);const t=e.HTMLElement.querySelector(`.${e.CSSClasses.years}`);if(!t)return;e.settings.selection.year&&t.classList.add(e.CSSClasses.yearsSelecting);const s=document.createElement("button");s.type="button",s.className=e.CSSClasses.yearsYear;for(let l=e.viewYear-7;le.dateMax.getFullYear()&&(n.classList.add(e.CSSClasses.yearsYearDisabled),n.tabIndex=-1),n.dataset.calendarYear=String(a),n.innerText=`${a}`,t.append(n)}},x=["light","dark","system"];let Y=!1;const _=(e,t)=>{var s;let l=null;for(let a=0;a{e.HTMLElement&&(x.includes(t)?e.HTMLElement.dataset.calendarTheme=t:console.error("Incorrect name of theme in settings.visibility.theme"))},A=(e,t)=>{if(!t)return void N(e,"light");const s=e=>e.matches?"dark":"light";e.HTMLElement.dataset.calendarTheme=s(t),Y||(t.addEventListener("change",(t=>{"system"===e.settings.visibility.theme&&(e.HTMLElement.dataset.calendarTheme=s(t))})),Y=!0)},B=(e,t)=>{if(!e.HTMLElement)return;const s=!!e.settings.visibility.themeDetect&&document.querySelector(e.settings.visibility.themeDetect);if(!s)return void A(e,t);const l=e.settings.visibility.themeDetect.replace(/^.*\[(.+)\]/g,((e,t)=>t)),a=s.hasAttribute(l);if(!l||!a)return void A(e,t);const n=_(s,l);n?(N(e,n),((e,t,s)=>{new MutationObserver((l=>{for(let a=0;a{(e=>{if(!e.HTMLElement)return;let t;"not all"!==window.matchMedia("(prefers-color-scheme)").media&&(t=window.matchMedia("(prefers-color-scheme: dark)")),"system"===e.settings.visibility.theme?B(e,t):N(e,e.settings.visibility.theme)})(e),(e=>{if("define"!==e.settings.lang){e.locale.weekday=[];for(let t=0;t<7;t++){let s=new Date(0,0,t).toLocaleString(e.settings.lang,{weekday:"short"});s=`${s.charAt(0).toUpperCase()}${s.substring(1,s.length)}`,s=s.replace(/\./,""),e.locale.weekday.push(s)}e.locale.months=[];for(let t=0;t<12;t++){let s=new Date(0,t).toLocaleString(e.settings.lang,{month:"long"});s=`${s.charAt(0).toUpperCase()}${s.substring(1,s.length)}`,s=s.replace(/\./,""),e.locale.months.push(s)}}})(e),$(e),T(e),L(e),o(e),H(e),"default"===e.currentType||"multiple"===e.currentType?((e=>{const t=[...e.locale.weekday];if(!t[0])return;const s=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.week}`),l=document.createElement("b");l.className=e.CSSClasses.weekDay,e.settings.iso8601&&t.push(t.shift()),s.forEach((s=>{s.innerHTML="";for(let a=0;a{var t;F&&(e.target.closest(`.${F.CSSClasses.calendar}`)||(null==(t=F.HTMLElement)||t.classList.add(F.CSSClasses.calendarHidden),document.removeEventListener("click",P,{capture:!0})))},O=(e,t)=>{if(void 0===e.selectedMonth||void 0===e.selectedYear)return;const s=e.locale.months.length-1;switch(t){case"prev":0!==e.selectedMonth?e.selectedMonth-=1:e.settings.selection.year&&(e.selectedYear-=1,e.selectedMonth=s);break;case"next":e.selectedMonth!==s?e.selectedMonth+=1:e.settings.selection.year&&(e.selectedYear+=1,e.selectedMonth=0)}T(e),L(e),o(e),v(e)};let K=null;const q=()=>{var e;if(!K)return;const t=null==(e=K.HTMLElement)?void 0:e.querySelectorAll(`.${K.CSSClasses.dayBtnHover}`);t&&t.forEach((e=>e.classList.remove(K.CSSClasses.dayBtnHover)))},W=e=>{var t;if(!K||!K.selectedDates)return;const s=i(e);if(K.rangeDisabled&&K.rangeDisabled.includes(s))return;const l=null==(t=K.HTMLElement)?void 0:t.querySelectorAll(`[data-calendar-day="${s}"]`);null==l||l.forEach((e=>{e.classList.add(K.CSSClasses.dayBtnHover)}))},j=e=>{if(!e.target||!K||!K.selectedDates)return;if(!e.target.closest(`.${K.CSSClasses.days}`))return void q();const t=e.target.dataset.calendarDay;if(!t)return;q();const s=new Date(new Date(`${K.selectedDates[0]} 00:00:00`).getFullYear(),new Date(`${K.selectedDates[0]} 00:00:00`).getMonth(),new Date(`${K.selectedDates[0]} 00:00:00`).getDate()),l=new Date(new Date(`${t} 00:00:00`).getFullYear(),new Date(`${t} 00:00:00`).getMonth(),new Date(`${t} 00:00:00`).getDate());if(l>s)for(let a=s;a<=l;a.setDate(a.getDate()+1))W(a);else for(let a=s;a>=l;a.setDate(a.getDate()-1))W(a)},R=e=>{K&&"Escape"===e.key&&(K.selectedDates=[],K.HTMLElement.removeEventListener("mousemove",j),document.removeEventListener("keydown",R),I(K))},G=e=>{e&&e.selectedDates&&(K=e,e.selectedDates[0]&&e.selectedDates.length<=1?(e.HTMLElement.addEventListener("mousemove",j),document.addEventListener("keydown",R),e.settings.range.disableGaps&&(()=>{var e;if(!K||!(null==(e=K.selectedDates)?void 0:e[0])||!K.rangeDisabled||K.rangeDisabled.length<2)return;const t=new Date(`${K.selectedDates[0]} 00:00:00`);let s=null,l=null;for(let a=0;a=e)){l=e;break}s=e}s&&(s=new Date(s.setDate(s.getDate()+1)),K.rangeMin=i(s)),l&&(l=new Date(l.setDate(l.getDate()-1)),K.rangeMax=i(l))})()):(e.HTMLElement.removeEventListener("mousemove",j),document.removeEventListener("keydown",R),e.settings.range.disableGaps&&K&&(K.rangeMin=K.settings.range.min,K.rangeMax=K.settings.range.max,K.settings.range.disablePast&&new Date(`${K.settings.range.min} 00:00:00`){e.HTMLElement.addEventListener("click",(t=>{const s=t.target,l=s.closest(`.${e.CSSClasses.arrow}`),a=s.closest(`.${e.CSSClasses.arrowPrev}`),n=s.closest(`.${e.CSSClasses.arrowNext}`),d=s.closest(`.${e.CSSClasses.dayBtn}`),r=s.closest(`.${e.CSSClasses.dayBtnPrev}`),c=s.closest(`.${e.CSSClasses.dayBtnNext}`),o=s.closest(`.${e.CSSClasses.weekNumber}`),u=s.closest(`.${e.CSSClasses.year}`),m=s.closest(`.${e.CSSClasses.yearsYear}`),g=s.closest(`.${e.CSSClasses.month}`),y=s.closest(`.${e.CSSClasses.monthsMonth}`);l&&"year"!==e.currentType&&"month"!==e.currentType&&O(e,s.dataset.calendarArrow),l&&e.actions.clickArrow&&e.actions.clickArrow(t,Number(e.selectedYear),Number(e.selectedMonth)),(()=>{if(e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&d){switch(e.settings.selection.day){case"single":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):(e.selectedDates=[],e.selectedDates.push(d.dataset.calendarDay)));break;case"multiple":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):e.selectedDates.push(d.dataset.calendarDay));break;case"multiple-ranged":(()=>{if(e.selectedDates&&d&&d.dataset.calendarDay){if(e.selectedDates.length<=1&&e.selectedDates[0]&&e.selectedDates[0].includes(d.dataset.calendarDay)?e.selectedDates=[]:(e.selectedDates.length>1&&(e.selectedDates=[]),e.selectedDates.push(d.dataset.calendarDay)),e.selectedDates[1]){const t=new Date(new Date(`${e.selectedDates[0]} 00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]} 00:00:00`).getMonth(),new Date(`${e.selectedDates[0]} 00:00:00`).getDate()),s=new Date(new Date(`${e.selectedDates[1]} 00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]} 00:00:00`).getMonth(),new Date(`${e.selectedDates[1]} 00:00:00`).getDate()),l=t=>{if(!e.selectedDates)return;const s=i(t);e.rangeDisabled&&e.rangeDisabled.includes(s)||e.selectedDates.push(s)};if(e.selectedDates=[],s>t)for(let e=t;e<=s;e.setDate(e.getDate()+1))l(e);else for(let e=t;e>=s;e.setDate(e.getDate()-1))l(e)}G(e)}})()}e.actions.clickDay&&e.actions.clickDay(t,e.selectedDates),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,e.HTMLInputElement,e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),r?O(e,"prev"):c?O(e,"next"):v(e)}})(),(()=>{var s;if(!e.settings.visibility.weekNumbers||!o||!e.actions.clickWeekNumber)return;const l=null==(s=e.HTMLElement)?void 0:s.querySelectorAll("[data-calendar-week-number]");if(!l)return;const a=Number(o.innerText),n=Number(o.dataset.calendarYearWeek),i=[...l].filter((e=>Number(e.dataset.calendarWeekNumber)===a));e.actions.clickWeekNumber(t,a,i,n)})(),(()=>{if(e.settings.selection.year&&"multiple"!==e.currentType)if(l&&"year"===e.currentType){if(void 0===e.viewYear)return;n?e.viewYear+=15:a&&(e.viewYear-=15),E(e)}else if("year"!==e.currentType&&u)E(e);else if("year"===e.currentType&&u)e.currentType=e.type,I(e);else if(m){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;e.selectedYear=Number(m.dataset.calendarYear),e.currentType=e.type,e.selectedMonthe.dateMax.getMonth()&&e.selectedYear===e.dateMax.getFullYear()&&(e.selectedMonth=e.dateMax.getMonth()),e.actions.clickYear&&e.actions.clickYear(t,e.selectedYear),I(e)}})(),e.settings.selection.month&&"multiple"!==e.currentType&&("month"!==e.currentType&&g?f(e):"month"===e.currentType&&g?(e.currentType=e.type,I(e)):y&&(e.selectedMonth=Number(y.dataset.calendarMonth),e.currentType=e.type,e.actions.clickMonth&&e.actions.clickMonth(t,e.selectedMonth),I(e)))}))},U=e=>{e.HTMLElement&&((e=>{if(!e.input||!e.HTMLElement||!e.HTMLElement.parentNode)return;e.HTMLInputElement=e.HTMLElement;const t=document.createElement("div"),s=document.createElement("div");t.className=e.CSSClasses.calendarInputWrapper,s.className=`${e.CSSClasses.calendar} ${e.CSSClasses.calendarToInput} ${e.CSSClasses.calendarHidden}`,e.HTMLElement.parentNode.insertBefore(t,e.HTMLInputElement),t.append(e.HTMLInputElement),e.HTMLElement=s,t.append(e.HTMLElement)})(e),c(e),I(e),(e=>{var t;e&&e.input&&(F=e,null==(t=e.HTMLInputElement)||t.addEventListener("click",(()=>{var t;null==(t=e.HTMLElement)||t.classList.remove(e.CSSClasses.calendarHidden),document.addEventListener("click",P,{capture:!0})})))})(e),z(e))},V=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#Multiple>\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Month />\n\t\t\t\t\t\t<#Year />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t<#WeekNumbers />\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Week />\n\t\t\t\t\t\t<#Days />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t<#/Multiple>\n\t
\n\t<#ControlTime />\n`,J=e=>`\n\t
\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t\t<#Months />\n\t\t
\n\t
\n`,Q=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t
\n\t\t\t<#Years />\n\t\t
\n\t
\n`,X={calendar:"vanilla-calendar",calendarDefault:"vanilla-calendar_default",calendarMultiple:"vanilla-calendar_multiple",calendarMonth:"vanilla-calendar_month",calendarYear:"vanilla-calendar_year",calendarHidden:"vanilla-calendar_hidden",calendarToInput:"vanilla-calendar_to-input",calendarInputWrapper:"vanilla-calendar-input-wrapper",controls:"vanilla-calendar-controls",grid:"vanilla-calendar-grid",column:"vanilla-calendar-column",header:"vanilla-calendar-header",headerContent:"vanilla-calendar-header__content",month:"vanilla-calendar-month",monthDisabled:"vanilla-calendar-month_disabled",year:"vanilla-calendar-year",yearDisabled:"vanilla-calendar-year_disabled",arrow:"vanilla-calendar-arrow",arrowPrev:"vanilla-calendar-arrow_prev",arrowNext:"vanilla-calendar-arrow_next",wrapper:"vanilla-calendar-wrapper",content:"vanilla-calendar-content",week:"vanilla-calendar-week",weekDay:"vanilla-calendar-week__day",weekDayWeekend:"vanilla-calendar-week__day_weekend",days:"vanilla-calendar-days",daysSelecting:"vanilla-calendar-days_selecting",months:"vanilla-calendar-months",monthsSelecting:"vanilla-calendar-months_selecting",monthsMonth:"vanilla-calendar-months__month",monthsMonthSelected:"vanilla-calendar-months__month_selected",monthsMonthDisabled:"vanilla-calendar-months__month_disabled",years:"vanilla-calendar-years",yearsSelecting:"vanilla-calendar-years_selecting",yearsYear:"vanilla-calendar-years__year",yearsYearSelected:"vanilla-calendar-years__year_selected",yearsYearDisabled:"vanilla-calendar-years__year_disabled",time:"vanilla-calendar-time",timeContent:"vanilla-calendar-time__content",timeHours:"vanilla-calendar-time__hours",timeMinutes:"vanilla-calendar-time__minutes",timeKeeping:"vanilla-calendar-time__keeping",timeRanges:"vanilla-calendar-time__ranges",timeRange:"vanilla-calendar-time__range",day:"vanilla-calendar-day",daySelected:"vanilla-calendar-day_selected",daySelectedFirst:"vanilla-calendar-day_selected-first",daySelectedLast:"vanilla-calendar-day_selected-last",daySelectedIntermediate:"vanilla-calendar-day_selected-intermediate",dayPopup:"vanilla-calendar-day__popup",dayBtn:"vanilla-calendar-day__btn",dayBtnPrev:"vanilla-calendar-day__btn_prev",dayBtnNext:"vanilla-calendar-day__btn_next",dayBtnToday:"vanilla-calendar-day__btn_today",dayBtnSelected:"vanilla-calendar-day__btn_selected",dayBtnHover:"vanilla-calendar-day__btn_hover",dayBtnDisabled:"vanilla-calendar-day__btn_disabled",dayBtnIntermediate:"vanilla-calendar-day__btn_intermediate",dayBtnWeekend:"vanilla-calendar-day__btn_weekend",dayBtnHoliday:"vanilla-calendar-day__btn_holiday",weekNumbers:"vanilla-calendar-week-numbers",weekNumbersTitle:"vanilla-calendar-week-numbers__title",weekNumbersContent:"vanilla-calendar-week-numbers__content",weekNumber:"vanilla-calendar-week-number",isFocus:"vanilla-calendar-is-focus"};class Z{constructor(e,i){var d,r,o,u,v,m,g,y,h,S,p,b,C,M,D,w,$,T,L,f,k,H,E,x,Y,_,N,A,B,F,P,O,K,q,W,j,R,G,z,Z,ee,te,se,le,ae,ne,ie,de,re,ce,oe,ue,ve,me,ge,ye,he,Se,pe,be,Ce,Me,De,we,$e,Te,Le,fe,ke,He,Ee,xe,Ye,_e,Ne,Ae,Be,Ie,Fe,Pe,Oe,Ke,qe,We,je,Re,Ge,ze,Ue,Ve,Je,Qe,Xe,Ze,et,tt,st,lt,at,nt,it,dt,rt,ct,ot,ut,vt,mt,gt,yt,ht,St,pt,bt,Ct,Mt,Dt,wt,$t,Tt,Lt,ft,kt,Ht,Et;(n(this,"HTMLElement"),n(this,"input"),n(this,"type"),n(this,"months"),n(this,"date"),n(this,"settings"),n(this,"locale"),n(this,"actions"),n(this,"popups"),n(this,"CSSClasses"),n(this,"DOMTemplates"),n(this,"currentType"),n(this,"reset",(()=>{return c(e=this),void I(e);var e})),n(this,"update",(()=>I(this))),n(this,"init",(()=>U(this))),this.HTMLElement="string"==typeof e?document.querySelector(e):e,this.HTMLElement)&&(this.input=null!=(d=null==i?void 0:i.input)&&d,this.type=null!=(r=null==i?void 0:i.type)?r:"default",this.months=null!=(o=null==i?void 0:i.months)?o:2,this.date={min:null!=(v=null==(u=null==i?void 0:i.date)?void 0:u.min)?v:"1970-01-01",max:null!=(g=null==(m=null==i?void 0:i.date)?void 0:m.max)?g:"2470-12-31",today:null!=(h=null==(y=null==i?void 0:i.date)?void 0:y.today)?h:new Date},this.settings={lang:null!=(p=null==(S=null==i?void 0:i.settings)?void 0:S.lang)?p:"en",iso8601:null==(C=null==(b=null==i?void 0:i.settings)?void 0:b.iso8601)||C,range:{min:null!=(w=null==(D=null==(M=null==i?void 0:i.settings)?void 0:M.range)?void 0:D.min)?w:this.date.min,max:null!=(L=null==(T=null==($=null==i?void 0:i.settings)?void 0:$.range)?void 0:T.max)?L:this.date.max,disablePast:null!=(H=null==(k=null==(f=null==i?void 0:i.settings)?void 0:f.range)?void 0:k.disablePast)&&H,disableGaps:null!=(Y=null==(x=null==(E=null==i?void 0:i.settings)?void 0:E.range)?void 0:x.disableGaps)&&Y,disableAllDays:null!=(A=null==(N=null==(_=null==i?void 0:i.settings)?void 0:_.range)?void 0:N.disableAllDays)&&A,disableWeekday:null!=(P=null==(F=null==(B=null==i?void 0:i.settings)?void 0:B.range)?void 0:F.disableWeekday)?P:null,disabled:null!=(q=null==(K=null==(O=null==i?void 0:i.settings)?void 0:O.range)?void 0:K.disabled)?q:null,enabled:null!=(R=null==(j=null==(W=null==i?void 0:i.settings)?void 0:W.range)?void 0:j.enabled)?R:null},selection:{day:null!=(Z=null==(z=null==(G=null==i?void 0:i.settings)?void 0:G.selection)?void 0:z.day)?Z:"single",month:null==(se=null==(te=null==(ee=null==i?void 0:i.settings)?void 0:ee.selection)?void 0:te.month)||se,year:null==(ne=null==(ae=null==(le=null==i?void 0:i.settings)?void 0:le.selection)?void 0:ae.year)||ne,time:null!=(re=null==(de=null==(ie=null==i?void 0:i.settings)?void 0:ie.selection)?void 0:de.time)&&re,controlTime:null!=(ue=null==(oe=null==(ce=null==i?void 0:i.settings)?void 0:ce.selection)?void 0:oe.controlTime)?ue:"all",stepHours:null!=(ge=null==(me=null==(ve=null==i?void 0:i.settings)?void 0:ve.selection)?void 0:me.stepHours)?ge:1,stepMinutes:null!=(Se=null==(he=null==(ye=null==i?void 0:i.settings)?void 0:ye.selection)?void 0:he.stepMinutes)?Se:1},selected:{dates:null!=(Ce=null==(be=null==(pe=null==i?void 0:i.settings)?void 0:pe.selected)?void 0:be.dates)?Ce:null,month:null!=(we=null==(De=null==(Me=null==i?void 0:i.settings)?void 0:Me.selected)?void 0:De.month)?we:null,year:null!=(Le=null==(Te=null==($e=null==i?void 0:i.settings)?void 0:$e.selected)?void 0:Te.year)?Le:null,holidays:null!=(He=null==(ke=null==(fe=null==i?void 0:i.settings)?void 0:fe.selected)?void 0:ke.holidays)?He:null,time:null!=(Ye=null==(xe=null==(Ee=null==i?void 0:i.settings)?void 0:Ee.selected)?void 0:xe.time)?Ye:null},visibility:{theme:null!=(Ae=null==(Ne=null==(_e=null==i?void 0:i.settings)?void 0:_e.visibility)?void 0:Ne.theme)?Ae:"system",themeDetect:null!=(Fe=null==(Ie=null==(Be=null==i?void 0:i.settings)?void 0:Be.visibility)?void 0:Ie.themeDetect)?Fe:"html[data-theme]",monthShort:null==(Ke=null==(Oe=null==(Pe=null==i?void 0:i.settings)?void 0:Pe.visibility)?void 0:Oe.monthShort)||Ke,weekNumbers:null!=(je=null==(We=null==(qe=null==i?void 0:i.settings)?void 0:qe.visibility)?void 0:We.weekNumbers)&&je,weekend:null==(ze=null==(Ge=null==(Re=null==i?void 0:i.settings)?void 0:Re.visibility)?void 0:Ge.weekend)||ze,today:null==(Je=null==(Ve=null==(Ue=null==i?void 0:i.settings)?void 0:Ue.visibility)?void 0:Ve.today)||Je,disabled:null!=(Ze=null==(Xe=null==(Qe=null==i?void 0:i.settings)?void 0:Qe.visibility)?void 0:Xe.disabled)&&Ze,daysOutside:null==(st=null==(tt=null==(et=null==i?void 0:i.settings)?void 0:et.visibility)?void 0:tt.daysOutside)||st}},this.locale={months:null!=(at=null==(lt=null==i?void 0:i.locale)?void 0:lt.months)?at:[],weekday:null!=(it=null==(nt=null==i?void 0:i.locale)?void 0:nt.weekday)?it:[]},this.actions={clickDay:null!=(rt=null==(dt=null==i?void 0:i.actions)?void 0:dt.clickDay)?rt:null,clickWeekNumber:null!=(ot=null==(ct=null==i?void 0:i.actions)?void 0:ct.clickWeekNumber)?ot:null,clickMonth:null!=(vt=null==(ut=null==i?void 0:i.actions)?void 0:ut.clickMonth)?vt:null,clickYear:null!=(gt=null==(mt=null==i?void 0:i.actions)?void 0:mt.clickYear)?gt:null,clickArrow:null!=(ht=null==(yt=null==i?void 0:i.actions)?void 0:yt.clickArrow)?ht:null,changeTime:null!=(pt=null==(St=null==i?void 0:i.actions)?void 0:St.changeTime)?pt:null,changeToInput:null!=(Ct=null==(bt=null==i?void 0:i.actions)?void 0:bt.changeToInput)?Ct:null},this.popups=null!=(Mt=null==i?void 0:i.popups)?Mt:null,this.CSSClasses=(()=>{const e=((e,n)=>{for(var i in n||(n={}))s.call(n,i)&&a(e,i,n[i]);if(t)for(var i of t(n))l.call(n,i)&&a(e,i,n[i]);return e})({},X);return Object.keys(X).forEach((t=>{var s;(null==(s=null==i?void 0:i.CSSClasses)?void 0:s[t])?e[t]=i.CSSClasses[t]:e[t]=X[t]})),e})(),this.DOMTemplates={default:null!=(wt=null==(Dt=null==i?void 0:i.DOMTemplates)?void 0:Dt.default)?wt:(Et=this.CSSClasses,`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#WeekNumbers />\n\t\t
\n\t\t\t<#Week />\n\t\t\t<#Days />\n\t\t
\n\t
\n\t<#ControlTime />\n`),multiple:null!=(Tt=null==($t=null==i?void 0:i.DOMTemplates)?void 0:$t.multiple)?Tt:V(this.CSSClasses),month:null!=(ft=null==(Lt=null==i?void 0:i.DOMTemplates)?void 0:Lt.month)?ft:J(this.CSSClasses),year:null!=(Ht=null==(kt=null==i?void 0:i.DOMTemplates)?void 0:kt.year)?Ht:Q(this.CSSClasses)},this.currentType=this.type)}}"undefined"!=typeof window&&(window.VanillaCalendar=Z),"object"==typeof exports&&"object"==typeof module&&(module.exports=Z); +"use strict";var e=Object.defineProperty,t=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(t,s,l)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,n=(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s);const i=e=>{const t=e.getFullYear();let s=e.getMonth()+1,l=e.getDate();return s=s<10?`0${s}`:s,l=l<10?`0${l}`:l,`${t}-${s}-${l}`},d=e=>{const t=[];return e.forEach((e=>{e.match(/^(\d{4}-\d{2}-\d{2})$/g)?t.push(e):e.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g,((e,s,l)=>{const a=new Date(`${s} 00:00:00`),n=new Date(`${l} 00:00:00`),d=new Date(a.getTime());for(;d<=n;d.setDate(d.getDate()+1))t.push(i(d));return e}))})),t},r=e=>{const t=Number(e);let s=String(t);return 0===t?s="12":13===t?s="01":14===t?s="02":15===t?s="03":16===t?s="04":17===t?s="05":18===t?s="06":19===t?s="07":20===t?s="08":21===t?s="09":22===t?s="10":23===t&&(s="11"),s},c=e=>{var t,s;e.rangeMin=e.settings.range.min,e.rangeMax=e.settings.range.max,e.rangeDisabled=e.settings.range.disabled?d([...e.settings.range.disabled]):[],e.rangeEnabled=e.settings.range.enabled?d([...e.settings.range.enabled]):[],e.selectedDates=e.settings.selected.dates?d([...e.settings.selected.dates]):[],e.selectedHolidays=e.settings.selected.holidays?d([...e.settings.selected.holidays]):[],e.settings.range.disablePast&&!e.settings.range.disableAllDays&&new Date(`${e.settings.range.min} 00:00:00`)+new Date(e)-+new Date(t))),(null==(s=e.rangeEnabled)?void 0:s[0])&&e.settings.range.disableAllDays&&(e.rangeMin=e.rangeEnabled[0],e.rangeMax=e.rangeEnabled[e.rangeEnabled.length-1]);const l=new Date(`${e.rangeMin} 00:00:00`),a=new Date(`${e.rangeMax} 00:00:00`);l.setDate(l.getDate()-1),a.setDate(a.getDate()+1),e.rangeDisabled.push(i(l)),e.rangeDisabled.push(i(a)),null!==e.settings.selected.month&&e.settings.selected.month>=0&&e.settings.selected.month<12?e.selectedMonth=e.settings.selected.month:e.selectedMonth=e.date.today.getMonth(),null!==e.settings.selected.year&&e.settings.selected.year>=0&&e.settings.selected.year<=9999?e.selectedYear=e.settings.selected.year:e.selectedYear=e.date.today.getFullYear(),e.viewYear=e.selectedYear,e.dateMin=e.settings.visibility.disabled?new Date(`${e.date.min} 00:00:00`):new Date(`${e.rangeMin} 00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max} 00:00:00`):new Date(`${e.rangeMax} 00:00:00`);const n=!0===e.settings.selection.time||12===e.settings.selection.time;if(n||24===e.settings.selection.time){if(e.userTime=!1,"string"==typeof e.settings.selected.time){const t=n?/^([0-9]|0[1-9]|1[0-2]):([0-5][0-9])|(AM|PM)/g:/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])/g;e.settings.selected.time.replace(t,((t,s,l,a)=>(s&&l&&(e.userTime=!0,e.selectedHours=s,e.selectedMinutes=l),a&&n?e.selectedKeeping=a:n&&(e.selectedKeeping="AM"),"")))}!e.userTime&&n?(e.selectedHours=r(String(e.date.today.getHours())),e.selectedMinutes=String(e.date.today.getMinutes()),e.selectedKeeping=Number(e.date.today.getHours())>=12?"PM":"AM"):e.userTime||(e.selectedHours=String(e.date.today.getHours()),e.selectedMinutes=String(e.date.today.getMinutes())),e.selectedHours=Number(e.selectedHours)<10?`0${Number(e.selectedHours)}`:`${e.selectedHours}`,e.selectedMinutes=Number(e.selectedMinutes)<10?`0${Number(e.selectedMinutes)}`:`${e.selectedMinutes}`,e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`}else e.settings.selection.time&&(e.settings.selection.time=!1,console.error("The value of the time property can be: false, true, 12 or 24."));"multiple"===e.type&&(1===e.months?(console.warn("The value of the «months» parameter cannot be less than «2», the minimum available value will be initialized."),e.correctMonths=2):e.months>12?(console.warn("The value of the «months» parameter cannot be greater than «12», the maximum available value will be initialized."),e.correctMonths=12):e.correctMonths=e.months)},o=e=>{if(!["default","multiple","year"].includes(e.currentType))return;const t=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowPrev}`),s=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowNext}`);if(!t||!s)return;"default"!==e.currentType&&"multiple"!==e.currentType||(()=>{if(!e.dateMin||!e.dateMax)return;const l=e.selectedMonth===e.dateMin.getMonth(),a=e.selectedMonth===e.dateMax.getMonth(),n=!e.settings.selection.year||e.selectedYear===e.dateMin.getFullYear(),i=!e.settings.selection.year||e.selectedYear===e.dateMax.getFullYear();l&&n||!e.settings.selection.month?t.style.visibility="hidden":t.style.visibility="",a&&i||!e.settings.selection.month?s.style.visibility="hidden":s.style.visibility=""})(),"year"===e.currentType&&e.dateMin&&e.dateMax&&void 0!==e.viewYear&&(e.dateMin.getFullYear()&&e.viewYear-7<=e.dateMin.getFullYear()?t.style.visibility="hidden":t.style.visibility="",e.dateMax.getFullYear()&&e.viewYear+7>=e.dateMax.getFullYear()?s.style.visibility="hidden":s.style.visibility="")},u=(e,t)=>{if(!e)return null;const s=new Date(`${e} 00:00:00`).getDate(),l=new Date(`${e} 00:00:00`).getMonth(),a=new Date(`${e} 00:00:00`).getFullYear(),n=new Date(a,l,s),i=t?n.getDay()||7:n.getDay();n.setDate(n.getDate()+4-i);const d=new Date(n.getFullYear(),0,1);return{year:a,week:Math.ceil(((+n-+d)/864e5+1)/7)}},v=e=>{var t,s;const l=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.days}`),a=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.weekNumbers}`),n=new Date(e.selectedYear,e.selectedMonth,1),d=document.createElement("div"),r=document.createElement("button");d.className=e.CSSClasses.day,r.className=e.CSSClasses.dayBtn,r.type="button",null==(t=e.selectedDates)||t.sort(((e,t)=>+new Date(e)-+new Date(t))),l.forEach(((t,s)=>{const c=new Date(n.setMonth(e.selectedMonth+s)).getMonth(),o=new Date(n.setFullYear(e.selectedYear,e.selectedMonth+s)).getFullYear(),v=new Date(o,c,1),g=new Date(o,c+1,0).getDate();let m=Number(v.getDay());e.settings.iso8601&&(m=Number((0!==v.getDay()?v.getDay():7)-1)),e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&l[s].classList.add(e.CSSClasses.daysSelecting),l[s].innerHTML="";const y=(t,a,n,i,c)=>{var v,g,m,y,h,S,p,b,C;const M=d.cloneNode(!0),D=r.cloneNode(!0);if(c&&D.classList.add(c),D.innerText=t,D.dataset.calendarDay=n,e.settings.visibility.weekNumbers){const t=u(n,e.settings.iso8601);if(!t)return;D.dataset.calendarWeekNumber=`${t.week}`}(null==(v=e.rangeEnabled)?void 0:v[0])&&e.settings.range.disableAllDays&&!(null==(g=e.rangeDisabled)?void 0:g.includes(n))&&(null==(m=e.rangeDisabled)||m.push(n)),(null==(y=e.rangeEnabled)?void 0:y[0])&&(null==(h=e.rangeDisabled)?void 0:h.includes(n))&&(e.rangeDisabled=null==(S=e.rangeDisabled)?void 0:S.filter((t=>{var s;return!(null==(s=e.rangeEnabled)?void 0:s.includes(t))}))),(null==(p=e.settings.range.disableWeekday)?void 0:p.includes(a))&&!(null==(b=e.rangeDisabled)?void 0:b.includes(n))&&(null==(C=e.rangeDisabled)||C.push(n)),((t,s,l,a,n)=>{(e.rangeMin>a||e.rangeMax{t===a&&s.classList.add(e.CSSClasses.dayBtnHoliday)}));let i=e.date.today.getDate(),d=e.date.today.getMonth()+1;i=i<10?`0${i}`:i,d=d<10?`0${d}`:d;const r=`${e.date.today.getFullYear()}-${d}-${i}`;e.settings.visibility.today&&s.dataset.calendarDay===r&&s.classList.add(e.CSSClasses.dayBtnToday),e.selectedDates&&0===e.selectedDates.indexOf(a)?("multiple-ranged"===e.settings.selection.day&&e.selectedDates.length>1?t.classList.add(e.CSSClasses.daySelectedFirst):t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates[0]&&e.selectedDates.indexOf(a)===e.selectedDates.length-1?(t.classList.add(e.CSSClasses.daySelected),"multiple-ranged"===e.settings.selection.day?t.classList.add(e.CSSClasses.daySelectedLast):t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&"multiple-ranged"===e.settings.selection.day?(t.classList.add(e.CSSClasses.daySelectedIntermediate),s.classList.add(e.CSSClasses.dayBtnSelected),s.classList.add(e.CSSClasses.dayBtnIntermediate)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&(t.classList.add(e.CSSClasses.daySelected),s.classList.add(e.CSSClasses.dayBtnSelected)),Array.isArray(e.rangeDisabled)&&e.rangeDisabled[0]&&e.rangeDisabled.forEach((t=>{t===a&&(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1)})),!e.settings.selection.month&&n&&(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1),e.settings.selection.year||new Date(`${a} 00:00:00`).getFullYear()===o||(s.classList.add(e.CSSClasses.dayBtnDisabled),s.tabIndex=-1)})(M,D,a,n,i),i?e.settings.visibility.daysOutside&&M.append(D):M.append(D),l[s].append(M)};(()=>{let t=new Date(o,c,0).getDate()-m,s=o,l=c;0===c?(l=e.locale.months.length,s=o-1):c<10&&(l=`0${c}`);for(let a=0;a{for(let e=1;e<=g;e++){const t=new Date(o,c,e),s=i(t),l=t.getDay();y(String(e),l,s,!1,null)}})(),(()=>{const t=m+g,s=Math.ceil(t/e.locale.weekday.length),l=e.locale.weekday.length*s-t;let a=o,n=String(c+2);c+1===e.locale.months.length?(n="01",a=o+1):c+2<10&&(n=`0${c+2}`);for(let i=1;i<=l;i++){const t=`${a}-${n}-${i<10?`0${i}`:String(i)}`,s=new Date(o,c,i).getMonth()+1,l=new Date(o,s,i).getDay();y(String(i),l,t,!0,e.CSSClasses.dayBtnNext)}})(),((e,t)=>{e.popups&&Object.keys(e.popups).forEach((s=>{var l;const a=t.querySelector(`[data-calendar-day="${s}"]`);if(a){const t=null==(l=e.popups)?void 0:l[s];(null==t?void 0:t.modifier)&&t.modifier.trim().split(" ").forEach((e=>{a.classList.add(e)})),(null==t?void 0:t.html)&&(a.parentNode.innerHTML+=`
${t.html}
`)}}))})(e,l[s]),((e,t,s,l,a)=>{if(!e.settings.visibility.weekNumbers)return;const n=a.querySelectorAll(`.${e.CSSClasses.day}`);l.innerHTML="";const i=Math.ceil((t+s)/7),d=document.createElement("b");d.className=e.CSSClasses.weekNumbersTitle,d.innerText="#",l.append(d);const r=document.createElement("div");r.className=e.CSSClasses.weekNumbersContent,l.append(r);const c=document.createElement("span");c.className=e.CSSClasses.weekNumber;for(let o=0;o+new Date(e)-+new Date(t)))},g=e=>`\n\t\n`,m=e=>`\n\t\n`,y=e=>`\n\t\n`,h=e=>`\n\t\n`,S=e=>`\n\t
\n`,p=e=>`\n\t
\n`,b=e=>`\n\t
\n`,C=e=>`\n\t
\n`,M=e=>e.settings.visibility.weekNumbers?`\n\t
\n`:"",D=e=>e.settings.selection.time?`\n\t
\n`:"",w=(e,t)=>t.replace(/<#(.*?)\/>/g,((t,s)=>{const l=(e=>{let t=null;switch(e){case"ArrowPrev":t=g;break;case"ArrowNext":t=m;break;case"Month":t=y;break;case"Year":t=h;break;case"Week":t=S;break;case"Days":t=p;break;case"Months":t=b;break;case"Years":t=C;break;case"WeekNumbers":t=M;break;case"ControlTime":t=D}return t})(s.replace(/[\s\n\t]/g,""));return l?l(e):""})).replace(/[\n\t]/g,""),$=e=>{const t=e.HTMLElement;switch(t.classList.add(e.CSSClasses.calendar),e.currentType){case"default":t.classList.add(e.CSSClasses.calendarDefault),t.classList.remove(e.CSSClasses.calendarMonth),t.classList.remove(e.CSSClasses.calendarYear),t.innerHTML=w(e,e.DOMTemplates.default);break;case"multiple":if(!e.correctMonths)break;t.classList.add(e.CSSClasses.calendarMultiple),t.classList.remove(e.CSSClasses.calendarMonth),t.classList.remove(e.CSSClasses.calendarYear),t.innerHTML=((e,t)=>t.replace(/<#Multiple>(.*?)<#\/Multiple>/g,((t,s)=>{let l="";for(let a=0;a{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-month]");if(!t[0]||void 0===e.selectedMonth)return;const s=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((l,a)=>{const n=new Date(s.setMonth(e.selectedMonth+a)).getMonth();t[a].dataset.calendarSelectedMonth=String(n),t[a].innerText=e.locale.months[n],e.settings.selection.month&&"multiple"!==e.currentType?(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.monthDisabled)):(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.monthDisabled))}))},L=e=>{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-year]");if(!t||void 0===e.selectedMonth)return;const s=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((l,a)=>{const n=new Date(s.setFullYear(e.selectedYear,e.selectedMonth+a)).getFullYear();t[a].dataset.calendarSelectedYear=String(n),t[a].innerText=String(n),e.settings.selection.year&&"multiple"!==e.currentType?(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.yearDisabled)):(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.yearDisabled))}))},f=e=>{e.currentType="month",$(e),T(e),L(e);const t=e.HTMLElement.querySelector(`.${e.CSSClasses.months}`);if(void 0===e.selectedMonth||void 0===e.selectedYear||!e.dateMin||!e.dateMax||!t)return;e.settings.selection.month&&t.classList.add(e.CSSClasses.monthsSelecting);const s=document.createElement("button");s.type="button",s.className=e.CSSClasses.monthsMonth;for(let l=0;le.dateMax.getMonth()&&e.selectedYear===e.dateMax.getFullYear()&&(n.classList.add(e.CSSClasses.monthsMonthDisabled),n.tabIndex=-1),n.dataset.calendarMonth=String(l),n.title=`${a}`,n.innerText=`${e.settings.visibility.monthShort?a.substring(0,3):a}`,t.append(n)}},k=(e,t)=>{const s=Number(e);let l=String(s);return"AM"===t?12===s&&(l="00"):"PM"===t&&(1===s?l="13":2===s?l="14":3===s?l="15":4===s?l="16":5===s?l="17":6===s?l="18":7===s?l="19":8===s?l="20":9===s?l="21":10===s?l="22":11===s&&(l="23")),l},H=e=>{const t=e.HTMLElement.querySelector(`.${e.CSSClasses.time}`);if(!t)return;const s=!0===e.settings.selection.time?12:e.settings.selection.time,l="range"===e.settings.selection.controlTime;t.innerHTML=`\n\t
\n\t\t\n\t\t\n\t\t${12===s?`\n\t\t\n\t\t`:""}\n\t
\n\t
\n\t\t\n\t\t\n\t
`,((e,t)=>{const s=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="hours"]`),l=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="minutes"]`),a=e.HTMLElement.querySelector(`.${e.CSSClasses.timeHours} input[name="hours"]`),n=e.HTMLElement.querySelector(`.${e.CSSClasses.timeMinutes} input[name="minutes"]`),i=e.HTMLElement.querySelector(`.${e.CSSClasses.timeKeeping}`),d=(t,s)=>{t.addEventListener("mouseover",(()=>s.classList.add(e.CSSClasses.isFocus)))},c=(t,s)=>{t.addEventListener("mouseout",(()=>s.classList.remove(e.CSSClasses.isFocus)))},o=(t,s,l)=>{"hours"===l?e.selectedHours=`${s}`:"minutes"===l&&(e.selectedMinutes=`${s}`),e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`,e.actions.changeTime&&e.actions.changeTime(t,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,e.HTMLInputElement,e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping)},u=(t,s,l,a)=>{t.addEventListener("input",(t=>{let n=Number(t.target.value);n=n<10?`0${n}`:`${n}`,"hours"===l&&12===a?Number(t.target.value)0?(s.value=n,e.selectedKeeping="AM",i.innerText=e.selectedKeeping,o(t,n,l)):(0===Number(t.target.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),s.value=r(t.target.value),o(t,r(t.target.value),l)):(s.value=n,o(t,n,l))}))},v=(t,s,l,a)=>{s.addEventListener("change",(s=>{const n=s.target;let d=Number(n.value);d=d<10?`0${d}`:`${d}`,"hours"===l&&12===a?n.value&&Number(n.value)<=a&&Number(n.value)>0?(n.value=d,t.value=k(d,e.selectedKeeping),o(s,d,l)):n.value&&Number(n.value)<24&&(Number(n.value)>a||0===Number(n.value))?(0===Number(n.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),n.value=r(n.value),t.value=d,o(s,r(n.value),l)):n.value=e.selectedHours:n.value&&Number(n.value)<=a&&Number(n.value)>=0?(n.value=d,t.value=d,o(s,d,l)):"hours"===l?n.value=e.selectedHours:"minutes"===l&&(n.value=e.selectedMinutes)}))};d(s,a),d(l,n),c(s,a),c(l,n),u(s,a,"hours",24===t?23:12),u(l,n,"minutes",0),v(s,a,"hours",24===t?23:12),v(l,n,"minutes",59),i&&i.addEventListener("click",(t=>{i.innerText.includes("AM")?e.selectedKeeping="PM":e.selectedKeeping="AM",s.value=k(e.selectedHours,e.selectedKeeping),o(t,e.selectedHours,"hours"),i.innerText=e.selectedKeeping}))})(e,s)},E=e=>{if(void 0===e.viewYear||!e.dateMin||!e.dateMax)return;e.currentType="year",$(e),T(e),L(e),o(e);const t=e.HTMLElement.querySelector(`.${e.CSSClasses.years}`);if(!t)return;e.settings.selection.year&&t.classList.add(e.CSSClasses.yearsSelecting);const s=document.createElement("button");s.type="button",s.className=e.CSSClasses.yearsYear;for(let l=e.viewYear-7;le.dateMax.getFullYear()&&(n.classList.add(e.CSSClasses.yearsYearDisabled),n.tabIndex=-1),n.dataset.calendarYear=String(a),n.innerText=`${a}`,t.append(n)}},x=["light","dark","system"];let Y=!1;const _=(e,t)=>{var s;let l=null;for(let a=0;a{e.HTMLElement&&(x.includes(t)?e.HTMLElement.dataset.calendarTheme=t:console.error("Incorrect name of theme in settings.visibility.theme"))},A=(e,t)=>{if(!t)return void N(e,"light");const s=e=>e.matches?"dark":"light";e.HTMLElement.dataset.calendarTheme=s(t),Y||(t.addEventListener("change",(t=>{"system"===e.settings.visibility.theme&&(e.HTMLElement.dataset.calendarTheme=s(t))})),Y=!0)},B=(e,t)=>{if(!e.HTMLElement)return;const s=!!e.settings.visibility.themeDetect&&document.querySelector(e.settings.visibility.themeDetect);if(!s)return void A(e,t);const l=e.settings.visibility.themeDetect.replace(/^.*\[(.+)\]/g,((e,t)=>t)),a=s.hasAttribute(l);if(!l||!a)return void A(e,t);const n=_(s,l);n?(N(e,n),((e,t,s)=>{new MutationObserver((l=>{for(let a=0;a{(e=>{if(!e.HTMLElement)return;let t;"not all"!==window.matchMedia("(prefers-color-scheme)").media&&(t=window.matchMedia("(prefers-color-scheme: dark)")),"system"===e.settings.visibility.theme?B(e,t):N(e,e.settings.visibility.theme)})(e),(e=>{if("define"!==e.settings.lang){e.locale.weekday=[];for(let t=0;t<7;t++){let s=new Date(0,0,t).toLocaleString(e.settings.lang,{weekday:"short"});s=`${s.charAt(0).toUpperCase()}${s.substring(1,s.length)}`,s=s.replace(/\./,""),e.locale.weekday.push(s)}e.locale.months=[];for(let t=0;t<12;t++){let s=new Date(0,t).toLocaleString(e.settings.lang,{month:"long"});s=`${s.charAt(0).toUpperCase()}${s.substring(1,s.length)}`,s=s.replace(/\./,""),e.locale.months.push(s)}}})(e),$(e),T(e),L(e),o(e),H(e),"default"===e.currentType||"multiple"===e.currentType?((e=>{const t=[...e.locale.weekday];if(!t[0])return;const s=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.week}`),l=document.createElement("b");l.className=e.CSSClasses.weekDay,e.settings.iso8601&&t.push(t.shift()),s.forEach((s=>{s.innerHTML="";for(let a=0;a{c(e),I(e)};let P=null;const O=e=>{var t;P&&(e.target.closest(`.${P.CSSClasses.calendar}`)||(null==(t=P.HTMLElement)||t.classList.add(P.CSSClasses.calendarHidden),document.removeEventListener("click",O,{capture:!0})))},K=(e,t)=>{if(void 0===e.selectedMonth||void 0===e.selectedYear)return;const s=e.locale.months.length-1;switch(t){case"prev":0!==e.selectedMonth?e.selectedMonth-=1:e.settings.selection.year&&(e.selectedYear-=1,e.selectedMonth=s);break;case"next":e.selectedMonth!==s?e.selectedMonth+=1:e.settings.selection.year&&(e.selectedYear+=1,e.selectedMonth=0)}T(e),L(e),o(e),v(e)};let q=null;const W=()=>{var e;if(!q)return;const t=null==(e=q.HTMLElement)?void 0:e.querySelectorAll(`.${q.CSSClasses.dayBtnHover}`);t&&t.forEach((e=>e.classList.remove(q.CSSClasses.dayBtnHover)))},j=e=>{var t;if(!q||!q.selectedDates)return;const s=i(e);if(q.rangeDisabled&&q.rangeDisabled.includes(s))return;const l=null==(t=q.HTMLElement)?void 0:t.querySelectorAll(`[data-calendar-day="${s}"]`);null==l||l.forEach((e=>{e.classList.add(q.CSSClasses.dayBtnHover)}))},R=e=>{if(!e.target||!q||!q.selectedDates)return;if(!e.target.closest(`.${q.CSSClasses.days}`))return void W();const t=e.target.dataset.calendarDay;if(!t)return;W();const s=new Date(new Date(`${q.selectedDates[0]} 00:00:00`).getFullYear(),new Date(`${q.selectedDates[0]} 00:00:00`).getMonth(),new Date(`${q.selectedDates[0]} 00:00:00`).getDate()),l=new Date(new Date(`${t} 00:00:00`).getFullYear(),new Date(`${t} 00:00:00`).getMonth(),new Date(`${t} 00:00:00`).getDate());if(l>s)for(let a=s;a<=l;a.setDate(a.getDate()+1))j(a);else for(let a=s;a>=l;a.setDate(a.getDate()-1))j(a)},G=e=>{q&&"Escape"===e.key&&(q.selectedDates=[],q.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),I(q))},z=e=>{e&&e.selectedDates&&(q=e,e.selectedDates[0]&&e.selectedDates.length<=1?(e.HTMLElement.addEventListener("mousemove",R),document.addEventListener("keydown",G),e.settings.range.disableGaps&&(()=>{var e;if(!q||!(null==(e=q.selectedDates)?void 0:e[0])||!q.rangeDisabled||q.rangeDisabled.length<2)return;const t=new Date(`${q.selectedDates[0]} 00:00:00`);let s=null,l=null;for(let a=0;a=e)){l=e;break}s=e}s&&(s=new Date(s.setDate(s.getDate()+1)),q.rangeMin=i(s)),l&&(l=new Date(l.setDate(l.getDate()-1)),q.rangeMax=i(l))})()):(e.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),e.settings.range.disableGaps&&q&&(q.rangeMin=q.settings.range.min,q.rangeMax=q.settings.range.max,q.settings.range.disablePast&&new Date(`${q.settings.range.min} 00:00:00`){e.HTMLElement.addEventListener("click",(t=>{const s=t.target,l=s.closest(`.${e.CSSClasses.arrow}`),a=s.closest(`.${e.CSSClasses.arrowPrev}`),n=s.closest(`.${e.CSSClasses.arrowNext}`),d=s.closest(`.${e.CSSClasses.dayBtn}`),r=s.closest(`.${e.CSSClasses.dayBtnPrev}`),c=s.closest(`.${e.CSSClasses.dayBtnNext}`),o=s.closest(`.${e.CSSClasses.weekNumber}`),u=s.closest(`.${e.CSSClasses.year}`),g=s.closest(`.${e.CSSClasses.yearsYear}`),m=s.closest(`.${e.CSSClasses.month}`),y=s.closest(`.${e.CSSClasses.monthsMonth}`);l&&"year"!==e.currentType&&"month"!==e.currentType&&K(e,s.dataset.calendarArrow),l&&e.actions.clickArrow&&e.actions.clickArrow(t,Number(e.selectedYear),Number(e.selectedMonth)),(()=>{if(e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&d){switch(e.settings.selection.day){case"single":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):(e.selectedDates=[],e.selectedDates.push(d.dataset.calendarDay)));break;case"multiple":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):e.selectedDates.push(d.dataset.calendarDay));break;case"multiple-ranged":(()=>{if(e.selectedDates&&d&&d.dataset.calendarDay){if(e.selectedDates.length<=1&&e.selectedDates[0]&&e.selectedDates[0].includes(d.dataset.calendarDay)?e.selectedDates=[]:(e.selectedDates.length>1&&(e.selectedDates=[]),e.selectedDates.push(d.dataset.calendarDay)),e.selectedDates[1]){const t=new Date(new Date(`${e.selectedDates[0]} 00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]} 00:00:00`).getMonth(),new Date(`${e.selectedDates[0]} 00:00:00`).getDate()),s=new Date(new Date(`${e.selectedDates[1]} 00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]} 00:00:00`).getMonth(),new Date(`${e.selectedDates[1]} 00:00:00`).getDate()),l=t=>{if(!e.selectedDates)return;const s=i(t);e.rangeDisabled&&e.rangeDisabled.includes(s)||e.selectedDates.push(s)};if(e.selectedDates=[],s>t)for(let e=t;e<=s;e.setDate(e.getDate()+1))l(e);else for(let e=t;e>=s;e.setDate(e.getDate()-1))l(e)}z(e)}})()}e.actions.clickDay&&e.actions.clickDay(t,e.selectedDates),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,e.HTMLInputElement,e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),r?K(e,"prev"):c?K(e,"next"):v(e)}})(),(()=>{var s;if(!e.settings.visibility.weekNumbers||!o||!e.actions.clickWeekNumber)return;const l=null==(s=e.HTMLElement)?void 0:s.querySelectorAll("[data-calendar-week-number]");if(!l)return;const a=Number(o.innerText),n=Number(o.dataset.calendarYearWeek),i=[...l].filter((e=>Number(e.dataset.calendarWeekNumber)===a));e.actions.clickWeekNumber(t,a,i,n)})(),(()=>{if(e.settings.selection.year&&"multiple"!==e.currentType)if(l&&"year"===e.currentType){if(void 0===e.viewYear)return;n?e.viewYear+=15:a&&(e.viewYear-=15),E(e)}else if("year"!==e.currentType&&u)E(e);else if("year"===e.currentType&&u)e.currentType=e.type,I(e);else if(g){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;e.selectedYear=Number(g.dataset.calendarYear),e.currentType=e.type,e.selectedMonthe.dateMax.getMonth()&&e.selectedYear===e.dateMax.getFullYear()&&(e.selectedMonth=e.dateMax.getMonth()),e.actions.clickYear&&e.actions.clickYear(t,e.selectedYear),I(e)}})(),e.settings.selection.month&&"multiple"!==e.currentType&&("month"!==e.currentType&&m?f(e):"month"===e.currentType&&m?(e.currentType=e.type,I(e)):y&&(e.selectedMonth=Number(y.dataset.calendarMonth),e.currentType=e.type,e.actions.clickMonth&&e.actions.clickMonth(t,e.selectedMonth),I(e)))}))},V=e=>{e.HTMLElement&&((e=>{if(!e.input||!e.HTMLElement||!e.HTMLElement.parentNode)return;e.HTMLInputElement=e.HTMLElement;const t=document.createElement("div"),s=document.createElement("div");t.className=e.CSSClasses.calendarInputWrapper,s.className=`${e.CSSClasses.calendar} ${e.CSSClasses.calendarToInput} ${e.CSSClasses.calendarHidden}`,e.HTMLElement.parentNode.insertBefore(t,e.HTMLInputElement),t.append(e.HTMLInputElement),e.HTMLElement=s,t.append(e.HTMLElement)})(e),F(e),(e=>{var t;e&&e.input&&(P=e,null==(t=e.HTMLInputElement)||t.addEventListener("click",(()=>{var t;null==(t=e.HTMLElement)||t.classList.remove(e.CSSClasses.calendarHidden),document.addEventListener("click",O,{capture:!0})})))})(e),U(e))},J=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#Multiple>\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Month />\n\t\t\t\t\t\t<#Year />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t<#WeekNumbers />\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Week />\n\t\t\t\t\t\t<#Days />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t<#/Multiple>\n\t
\n\t<#ControlTime />\n`,Q=e=>`\n\t
\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t\t<#Months />\n\t\t
\n\t
\n`,X=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t
\n\t\t\t<#Years />\n\t\t
\n\t
\n`,Z={calendar:"vanilla-calendar",calendarDefault:"vanilla-calendar_default",calendarMultiple:"vanilla-calendar_multiple",calendarMonth:"vanilla-calendar_month",calendarYear:"vanilla-calendar_year",calendarHidden:"vanilla-calendar_hidden",calendarToInput:"vanilla-calendar_to-input",calendarInputWrapper:"vanilla-calendar-input-wrapper",controls:"vanilla-calendar-controls",grid:"vanilla-calendar-grid",column:"vanilla-calendar-column",header:"vanilla-calendar-header",headerContent:"vanilla-calendar-header__content",month:"vanilla-calendar-month",monthDisabled:"vanilla-calendar-month_disabled",year:"vanilla-calendar-year",yearDisabled:"vanilla-calendar-year_disabled",arrow:"vanilla-calendar-arrow",arrowPrev:"vanilla-calendar-arrow_prev",arrowNext:"vanilla-calendar-arrow_next",wrapper:"vanilla-calendar-wrapper",content:"vanilla-calendar-content",week:"vanilla-calendar-week",weekDay:"vanilla-calendar-week__day",weekDayWeekend:"vanilla-calendar-week__day_weekend",days:"vanilla-calendar-days",daysSelecting:"vanilla-calendar-days_selecting",months:"vanilla-calendar-months",monthsSelecting:"vanilla-calendar-months_selecting",monthsMonth:"vanilla-calendar-months__month",monthsMonthSelected:"vanilla-calendar-months__month_selected",monthsMonthDisabled:"vanilla-calendar-months__month_disabled",years:"vanilla-calendar-years",yearsSelecting:"vanilla-calendar-years_selecting",yearsYear:"vanilla-calendar-years__year",yearsYearSelected:"vanilla-calendar-years__year_selected",yearsYearDisabled:"vanilla-calendar-years__year_disabled",time:"vanilla-calendar-time",timeContent:"vanilla-calendar-time__content",timeHours:"vanilla-calendar-time__hours",timeMinutes:"vanilla-calendar-time__minutes",timeKeeping:"vanilla-calendar-time__keeping",timeRanges:"vanilla-calendar-time__ranges",timeRange:"vanilla-calendar-time__range",day:"vanilla-calendar-day",daySelected:"vanilla-calendar-day_selected",daySelectedFirst:"vanilla-calendar-day_selected-first",daySelectedLast:"vanilla-calendar-day_selected-last",daySelectedIntermediate:"vanilla-calendar-day_selected-intermediate",dayPopup:"vanilla-calendar-day__popup",dayBtn:"vanilla-calendar-day__btn",dayBtnPrev:"vanilla-calendar-day__btn_prev",dayBtnNext:"vanilla-calendar-day__btn_next",dayBtnToday:"vanilla-calendar-day__btn_today",dayBtnSelected:"vanilla-calendar-day__btn_selected",dayBtnHover:"vanilla-calendar-day__btn_hover",dayBtnDisabled:"vanilla-calendar-day__btn_disabled",dayBtnIntermediate:"vanilla-calendar-day__btn_intermediate",dayBtnWeekend:"vanilla-calendar-day__btn_weekend",dayBtnHoliday:"vanilla-calendar-day__btn_holiday",weekNumbers:"vanilla-calendar-week-numbers",weekNumbersTitle:"vanilla-calendar-week-numbers__title",weekNumbersContent:"vanilla-calendar-week-numbers__content",weekNumber:"vanilla-calendar-week-number",isFocus:"vanilla-calendar-is-focus"};class ee{constructor(e,i){var d,r,o,u,v,g,m,y,h,S,p,b,C,M,D,w,$,T,L,f,k,H,E,x,Y,_,N,A,B,P,O,K,q,W,j,R,G,z,U,ee,te,se,le,ae,ne,ie,de,re,ce,oe,ue,ve,ge,me,ye,he,Se,pe,be,Ce,Me,De,we,$e,Te,Le,fe,ke,He,Ee,xe,Ye,_e,Ne,Ae,Be,Ie,Fe,Pe,Oe,Ke,qe,We,je,Re,Ge,ze,Ue,Ve,Je,Qe,Xe,Ze,et,tt,st,lt,at,nt,it,dt,rt,ct,ot,ut,vt,gt,mt,yt,ht,St,pt,bt,Ct,Mt,Dt,wt,$t,Tt,Lt,ft,kt,Ht,Et,xt;(n(this,"HTMLElement"),n(this,"input"),n(this,"type"),n(this,"months"),n(this,"date"),n(this,"settings"),n(this,"locale"),n(this,"actions"),n(this,"popups"),n(this,"CSSClasses"),n(this,"DOMTemplates"),n(this,"currentType"),n(this,"reset",(()=>F(this))),n(this,"update",(()=>(e=>{var t;let s=null,l=null,a=null;(null==(t=e.settings.selected.dates)?void 0:t[0])||(s=e.settings.selected.dates,e.settings.selected.dates=e.selectedDates),e.settings.selected.month||(l=e.settings.selected.month,e.settings.selected.month=e.selectedMonth),e.settings.selected.year||(a=e.settings.selected.year,e.settings.selected.year=e.selectedYear),c(e),I(e),e.settings.selected.dates=s,e.settings.selected.month=l,e.settings.selected.year=a})(this))),n(this,"init",(()=>V(this))),this.HTMLElement="string"==typeof e?document.querySelector(e):e,this.HTMLElement)&&(this.input=null!=(d=null==i?void 0:i.input)&&d,this.type=null!=(r=null==i?void 0:i.type)?r:"default",this.months=null!=(o=null==i?void 0:i.months)?o:2,this.date={min:null!=(v=null==(u=null==i?void 0:i.date)?void 0:u.min)?v:"1970-01-01",max:null!=(m=null==(g=null==i?void 0:i.date)?void 0:g.max)?m:"2470-12-31",today:null!=(h=null==(y=null==i?void 0:i.date)?void 0:y.today)?h:new Date},this.settings={lang:null!=(p=null==(S=null==i?void 0:i.settings)?void 0:S.lang)?p:"en",iso8601:null==(C=null==(b=null==i?void 0:i.settings)?void 0:b.iso8601)||C,range:{min:null!=(w=null==(D=null==(M=null==i?void 0:i.settings)?void 0:M.range)?void 0:D.min)?w:this.date.min,max:null!=(L=null==(T=null==($=null==i?void 0:i.settings)?void 0:$.range)?void 0:T.max)?L:this.date.max,disablePast:null!=(H=null==(k=null==(f=null==i?void 0:i.settings)?void 0:f.range)?void 0:k.disablePast)&&H,disableGaps:null!=(Y=null==(x=null==(E=null==i?void 0:i.settings)?void 0:E.range)?void 0:x.disableGaps)&&Y,disableAllDays:null!=(A=null==(N=null==(_=null==i?void 0:i.settings)?void 0:_.range)?void 0:N.disableAllDays)&&A,disableWeekday:null!=(O=null==(P=null==(B=null==i?void 0:i.settings)?void 0:B.range)?void 0:P.disableWeekday)?O:null,disabled:null!=(W=null==(q=null==(K=null==i?void 0:i.settings)?void 0:K.range)?void 0:q.disabled)?W:null,enabled:null!=(G=null==(R=null==(j=null==i?void 0:i.settings)?void 0:j.range)?void 0:R.enabled)?G:null},selection:{day:null!=(ee=null==(U=null==(z=null==i?void 0:i.settings)?void 0:z.selection)?void 0:U.day)?ee:"single",month:null==(le=null==(se=null==(te=null==i?void 0:i.settings)?void 0:te.selection)?void 0:se.month)||le,year:null==(ie=null==(ne=null==(ae=null==i?void 0:i.settings)?void 0:ae.selection)?void 0:ne.year)||ie,time:null!=(ce=null==(re=null==(de=null==i?void 0:i.settings)?void 0:de.selection)?void 0:re.time)&&ce,controlTime:null!=(ve=null==(ue=null==(oe=null==i?void 0:i.settings)?void 0:oe.selection)?void 0:ue.controlTime)?ve:"all",stepHours:null!=(ye=null==(me=null==(ge=null==i?void 0:i.settings)?void 0:ge.selection)?void 0:me.stepHours)?ye:1,stepMinutes:null!=(pe=null==(Se=null==(he=null==i?void 0:i.settings)?void 0:he.selection)?void 0:Se.stepMinutes)?pe:1},selected:{dates:null!=(Me=null==(Ce=null==(be=null==i?void 0:i.settings)?void 0:be.selected)?void 0:Ce.dates)?Me:null,month:null!=($e=null==(we=null==(De=null==i?void 0:i.settings)?void 0:De.selected)?void 0:we.month)?$e:null,year:null!=(fe=null==(Le=null==(Te=null==i?void 0:i.settings)?void 0:Te.selected)?void 0:Le.year)?fe:null,holidays:null!=(Ee=null==(He=null==(ke=null==i?void 0:i.settings)?void 0:ke.selected)?void 0:He.holidays)?Ee:null,time:null!=(_e=null==(Ye=null==(xe=null==i?void 0:i.settings)?void 0:xe.selected)?void 0:Ye.time)?_e:null},visibility:{theme:null!=(Be=null==(Ae=null==(Ne=null==i?void 0:i.settings)?void 0:Ne.visibility)?void 0:Ae.theme)?Be:"system",themeDetect:null!=(Pe=null==(Fe=null==(Ie=null==i?void 0:i.settings)?void 0:Ie.visibility)?void 0:Fe.themeDetect)?Pe:"html[data-theme]",monthShort:null==(qe=null==(Ke=null==(Oe=null==i?void 0:i.settings)?void 0:Oe.visibility)?void 0:Ke.monthShort)||qe,weekNumbers:null!=(Re=null==(je=null==(We=null==i?void 0:i.settings)?void 0:We.visibility)?void 0:je.weekNumbers)&&Re,weekend:null==(Ue=null==(ze=null==(Ge=null==i?void 0:i.settings)?void 0:Ge.visibility)?void 0:ze.weekend)||Ue,today:null==(Qe=null==(Je=null==(Ve=null==i?void 0:i.settings)?void 0:Ve.visibility)?void 0:Je.today)||Qe,disabled:null!=(et=null==(Ze=null==(Xe=null==i?void 0:i.settings)?void 0:Xe.visibility)?void 0:Ze.disabled)&&et,daysOutside:null==(lt=null==(st=null==(tt=null==i?void 0:i.settings)?void 0:tt.visibility)?void 0:st.daysOutside)||lt}},this.locale={months:null!=(nt=null==(at=null==i?void 0:i.locale)?void 0:at.months)?nt:[],weekday:null!=(dt=null==(it=null==i?void 0:i.locale)?void 0:it.weekday)?dt:[]},this.actions={clickDay:null!=(ct=null==(rt=null==i?void 0:i.actions)?void 0:rt.clickDay)?ct:null,clickWeekNumber:null!=(ut=null==(ot=null==i?void 0:i.actions)?void 0:ot.clickWeekNumber)?ut:null,clickMonth:null!=(gt=null==(vt=null==i?void 0:i.actions)?void 0:vt.clickMonth)?gt:null,clickYear:null!=(yt=null==(mt=null==i?void 0:i.actions)?void 0:mt.clickYear)?yt:null,clickArrow:null!=(St=null==(ht=null==i?void 0:i.actions)?void 0:ht.clickArrow)?St:null,changeTime:null!=(bt=null==(pt=null==i?void 0:i.actions)?void 0:pt.changeTime)?bt:null,changeToInput:null!=(Mt=null==(Ct=null==i?void 0:i.actions)?void 0:Ct.changeToInput)?Mt:null},this.popups=null!=(Dt=null==i?void 0:i.popups)?Dt:null,this.CSSClasses=(()=>{const e=((e,n)=>{for(var i in n||(n={}))s.call(n,i)&&a(e,i,n[i]);if(t)for(var i of t(n))l.call(n,i)&&a(e,i,n[i]);return e})({},Z);return Object.keys(Z).forEach((t=>{var s;(null==(s=null==i?void 0:i.CSSClasses)?void 0:s[t])?e[t]=i.CSSClasses[t]:e[t]=Z[t]})),e})(),this.DOMTemplates={default:null!=($t=null==(wt=null==i?void 0:i.DOMTemplates)?void 0:wt.default)?$t:(xt=this.CSSClasses,`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#WeekNumbers />\n\t\t
\n\t\t\t<#Week />\n\t\t\t<#Days />\n\t\t
\n\t
\n\t<#ControlTime />\n`),multiple:null!=(Lt=null==(Tt=null==i?void 0:i.DOMTemplates)?void 0:Tt.multiple)?Lt:J(this.CSSClasses),month:null!=(kt=null==(ft=null==i?void 0:i.DOMTemplates)?void 0:ft.month)?kt:Q(this.CSSClasses),year:null!=(Et=null==(Ht=null==i?void 0:i.DOMTemplates)?void 0:Ht.year)?Et:X(this.CSSClasses)},this.currentType=this.type)}}"undefined"!=typeof window&&(window.VanillaCalendar=ee),"object"==typeof exports&&"object"==typeof module&&(module.exports=ee); diff --git a/package/package.json b/package/package.json index 3f9516a0..8eb29d55 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "@uvarov.frontend/vanilla-calendar", - "version": "2.5.7", + "version": "2.5.8", "description": "VanillaCalendar is a pure JavaScript date and time picker that uses TypeScript so it supports any JS framework and library.", "homepage": "https://vanilla-calendar.com", "keywords": [