diff --git a/package.config.ts b/config/assets.config.ts similarity index 69% rename from package.config.ts rename to config/assets.config.ts index 5d438e65..9e255087 100644 --- a/package.config.ts +++ b/config/assets.config.ts @@ -2,7 +2,6 @@ import { resolve } from 'path'; import { defineConfig } from 'vite'; import banner from 'vite-plugin-banner'; -import eslint from 'vite-plugin-eslint'; export default defineConfig({ publicDir: './package/public', @@ -11,12 +10,11 @@ export default defineConfig({ assetsDir: '', outDir: './package/build', cssCodeSplit: true, - minify: 'terser', + minify: true, + emptyOutDir: false, rollupOptions: { output: { inlineDynamicImports: false, - format: 'cjs', - entryFileNames: '[name].min.js', assetFileNames: (assetInfo) => { if (assetInfo.name && ['light.css', 'dark.css'].includes(assetInfo.name)) { return 'themes/[name].min.[ext]'; @@ -25,9 +23,9 @@ export default defineConfig({ }, }, input: { - light: resolve(__dirname, './package/src/styles/themes/light.css'), - dark: resolve(__dirname, './package/src/styles/themes/dark.css'), - 'vanilla-calendar': resolve(__dirname, './package/src/vanilla-calendar.ts'), + light: resolve(__dirname, '../package/src/styles/themes/light.css'), + dark: resolve(__dirname, '../package/src/styles/themes/dark.css'), + 'vanilla-calendar': resolve(__dirname, '../package/src/styles/vanilla-calendar.css'), }, }, }, @@ -36,6 +34,5 @@ export default defineConfig({ outDir: './package/build', content: 'name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar', }), - eslint(), ], }); diff --git a/config/js.config.ts b/config/js.config.ts new file mode 100644 index 00000000..00e60c45 --- /dev/null +++ b/config/js.config.ts @@ -0,0 +1,26 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { resolve } from 'path'; +import { defineConfig } from 'vite'; +import banner from 'vite-plugin-banner'; +import eslint from 'vite-plugin-eslint'; + +export default defineConfig({ + build: { + target: 'ES6', + assetsDir: '', + outDir: './package/build', + minify: 'terser', + lib: { + name: 'VanillaCalendar', + fileName(format, entryName) { return `${entryName}.min${format === 'es' ? '.mjs' : '.js'}`; }, + entry: resolve(__dirname, '../package/src/scripts/vanilla-calendar.ts'), + }, + }, + plugins: [ + banner({ + outDir: './package/build', + content: 'name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar', + }), + eslint(), + ], +}); diff --git a/demo/main.ts b/demo/main.ts index 12fe73ee..b1a3e281 100644 --- a/demo/main.ts +++ b/demo/main.ts @@ -2,8 +2,9 @@ import '@/package/src/styles/vanilla-calendar.css'; import '@/package/src/styles/themes/light.css'; import '@/package/src/styles/themes/dark.css'; -import VanillaCalendar from '@/package/src/scripts/main'; -import { Options } from '@/package/src'; +// import VanillaCalendar from '@/package/build/vanilla-calendar.min'; +import VanillaCalendar from '@/package/src/scripts/vanilla-calendar'; +import IVanillaCalendar, { Options } from '@/package/src'; const config: Options = { settings: { @@ -16,6 +17,6 @@ const config: Options = { document.addEventListener('DOMContentLoaded', () => { // @ts-ignore: VanillaCalendar config - const calendar = new VanillaCalendar('#calendar', config); + const calendar: IVanillaCalendar = new VanillaCalendar('#calendar', config); calendar.init(); }); diff --git a/demo/pages/multiple/main.ts b/demo/pages/multiple/main.ts index 2b9833fe..b5982dc0 100644 --- a/demo/pages/multiple/main.ts +++ b/demo/pages/multiple/main.ts @@ -2,8 +2,9 @@ import '@/package/src/styles/vanilla-calendar.css'; import '@/package/src/styles/themes/light.css'; import '@/package/src/styles/themes/dark.css'; -import VanillaCalendar from '@/package/src/scripts/main'; -import { Options } from '@/package/src'; +// import VanillaCalendar from '@/package/build/vanilla-calendar.min'; +import VanillaCalendar from '@/package/src/scripts/vanilla-calendar'; +import IVanillaCalendar, { Options } from '@/package/src'; const config: Options = { type: 'multiple', @@ -20,6 +21,6 @@ const config: Options = { document.addEventListener('DOMContentLoaded', () => { // @ts-ignore: VanillaCalendar config - const calendar = new VanillaCalendar('#calendar', config); + const calendar: IVanillaCalendar = new VanillaCalendar('#calendar', config); calendar.init(); }); diff --git a/package.json b/package.json index 4de9d2bd..1a5eb6ac 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ ] }, "scripts": { - "package": "tsc && vite build --config package.config.ts", + "package": "tsc && vite build --config config/js.config.ts && vite build --config config/assets.config.ts", "build": "tsc && vite build", "start": "tsc && vite", "lint": "eslint --ext .js,.ts package/src cypress examples", diff --git a/package/build/vanilla-calendar.min.js b/package/build/vanilla-calendar.min.js index 95789f9a..9bab254b 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}T00:00:00`),n=new Date(`${l}T00: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}T00: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}T00:00:00`),a=new Date(`${e.rangeMax}T00: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}T00:00:00`):new Date(`${e.rangeMin}T00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max}T00:00:00`):new Date(`${e.rangeMax}T00: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}T00:00:00`).getDate(),l=new Date(`${e}T00:00:00`).getMonth(),a=new Date(`${e}T00: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}T00: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,""),T=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",T(e),$(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",T(e),$(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.onchange=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),T(e),$(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=>{P&&(e.target.closest(`.${P.CSSClasses.calendar}`)||(document.querySelectorAll(`.${P.CSSClasses.calendar}`).forEach((e=>{e.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)}$(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]}T00:00:00`).getFullYear(),new Date(`${q.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${q.selectedDates[0]}T00:00:00`).getDate()),l=new Date(new Date(`${t}T00:00:00`).getFullYear(),new Date(`${t}T00:00:00`).getMonth(),new Date(`${t}T00: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]}T00: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}T00: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]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[0]}T00:00:00`).getDate()),s=new Date(new Date(`${e.selectedDates[1]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[1]}T00: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,Te,$e,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,Tt,$t,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==($=null==(T=null==i?void 0:i.settings)?void 0:T.range)?void 0:$.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!=(Te=null==(we=null==(De=null==i?void 0:i.settings)?void 0:De.selected)?void 0:we.month)?Te:null,year:null!=(fe=null==(Le=null==($e=null==i?void 0:i.settings)?void 0:$e.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!=(Tt=null==(wt=null==i?void 0:i.DOMTemplates)?void 0:wt.default)?Tt:(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==($t=null==i?void 0:i.DOMTemplates)?void 0:$t.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); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VanillaCalendar=t()}(this,(function(){"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}T00:00:00`),n=new Date(`${l}T00: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}T00: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}T00:00:00`),a=new Date(`${e.rangeMax}T00: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}T00:00:00`):new Date(`${e.rangeMin}T00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max}T00:00:00`):new Date(`${e.rangeMax}T00: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=new Date(e.selectedYear,e.selectedMonth,1),a=new Date(e.selectedYear,e.selectedMonth,1);l.setMonth(l.getMonth()-e.jumpMonths),a.setMonth(a.getMonth()+e.jumpMonths),le.dateMax||!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}T00:00:00`).getDate(),l=new Date(`${e}T00:00:00`).getMonth(),a=new Date(`${e}T00: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}T00: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),e.actions.getDays&&e.actions.getDays(Number(t),n,M,D)};(()=>{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,""),T=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))}))},f=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))}))},L=e=>{e.currentType="month",T(e),$(e),f(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",T(e),$(e),f(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 N=!1;const Y=(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 _(e,"light");const s=e=>e.matches?"dark":"light";e.HTMLElement.dataset.calendarTheme=s(t),N||(t.onchange=t=>{"system"===e.settings.visibility.theme&&(e.HTMLElement.dataset.calendarTheme=s(t))},N=!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=Y(s,l);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):_(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),T(e),$(e),f(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=>{P&&(e.target.closest(`.${P.CSSClasses.calendar}`)||(document.querySelectorAll(`.${P.CSSClasses.calendar}`).forEach((e=>{e.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=new Date(e.selectedYear,e.selectedMonth,1);switch(t){case"prev":s.setMonth(s.getMonth()-e.jumpMonths);break;case"next":s.setMonth(s.getMonth()+e.jumpMonths)}e.selectedMonth=s.getMonth(),e.selectedYear=s.getFullYear(),$(e),f(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]}T00:00:00`).getFullYear(),new Date(`${q.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${q.selectedDates[0]}T00:00:00`).getDate()),l=new Date(new Date(`${t}T00:00:00`).getFullYear(),new Date(`${t}T00:00:00`).getMonth(),new Date(`${t}T00: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]}T00: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}T00: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&&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]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[0]}T00:00:00`).getDate()),s=new Date(new Date(`${e.selectedDates[1]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[1]}T00: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(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?L(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)))}))},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"};return class{constructor(e,i){var d,r,o,u,v,m,g,y,h,S,p,b,C,M,D,w,T,$,f,L,k,H,E,x,N,Y,_,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,me,ge,ye,he,Se,pe,be,Ce,Me,De,we,Te,$e,fe,Le,ke,He,Ee,xe,Ne,Ye,_e,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,Tt,$t,ft,Lt,kt,Ht,Et,xt,Nt,Yt,_t;(n(this,"HTMLElement"),n(this,"input"),n(this,"type"),n(this,"months"),n(this,"jumpMonths"),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.jumpMonths=null!=(u=null==i?void 0:i.jumpMonths)?u:1,this.date={min:null!=(m=null==(v=null==i?void 0:i.date)?void 0:v.min)?m:"1970-01-01",max:null!=(y=null==(g=null==i?void 0:i.date)?void 0:g.max)?y:"2470-12-31",today:null!=(S=null==(h=null==i?void 0:i.date)?void 0:h.today)?S:new Date},this.settings={lang:null!=(b=null==(p=null==i?void 0:i.settings)?void 0:p.lang)?b:"en",iso8601:null==(M=null==(C=null==i?void 0:i.settings)?void 0:C.iso8601)||M,range:{min:null!=(T=null==(w=null==(D=null==i?void 0:i.settings)?void 0:D.range)?void 0:w.min)?T:this.date.min,max:null!=(L=null==(f=null==($=null==i?void 0:i.settings)?void 0:$.range)?void 0:f.max)?L:this.date.max,disablePast:null!=(E=null==(H=null==(k=null==i?void 0:i.settings)?void 0:k.range)?void 0:H.disablePast)&&E,disableGaps:null!=(Y=null==(N=null==(x=null==i?void 0:i.settings)?void 0:x.range)?void 0:N.disableGaps)&&Y,disableAllDays:null!=(B=null==(A=null==(_=null==i?void 0:i.settings)?void 0:_.range)?void 0:A.disableAllDays)&&B,disableWeekday:null!=(K=null==(O=null==(P=null==i?void 0:i.settings)?void 0:P.range)?void 0:O.disableWeekday)?K:null,disabled:null!=(j=null==(W=null==(q=null==i?void 0:i.settings)?void 0:q.range)?void 0:W.disabled)?j:null,enabled:null!=(z=null==(G=null==(R=null==i?void 0:i.settings)?void 0:R.range)?void 0:G.enabled)?z:null},selection:{day:null!=(te=null==(ee=null==(U=null==i?void 0:i.settings)?void 0:U.selection)?void 0:ee.day)?te:"single",month:null==(ae=null==(le=null==(se=null==i?void 0:i.settings)?void 0:se.selection)?void 0:le.month)||ae,year:null==(de=null==(ie=null==(ne=null==i?void 0:i.settings)?void 0:ne.selection)?void 0:ie.year)||de,time:null!=(oe=null==(ce=null==(re=null==i?void 0:i.settings)?void 0:re.selection)?void 0:ce.time)&&oe,controlTime:null!=(me=null==(ve=null==(ue=null==i?void 0:i.settings)?void 0:ue.selection)?void 0:ve.controlTime)?me:"all",stepHours:null!=(he=null==(ye=null==(ge=null==i?void 0:i.settings)?void 0:ge.selection)?void 0:ye.stepHours)?he:1,stepMinutes:null!=(be=null==(pe=null==(Se=null==i?void 0:i.settings)?void 0:Se.selection)?void 0:pe.stepMinutes)?be:1},selected:{dates:null!=(De=null==(Me=null==(Ce=null==i?void 0:i.settings)?void 0:Ce.selected)?void 0:Me.dates)?De:null,month:null!=($e=null==(Te=null==(we=null==i?void 0:i.settings)?void 0:we.selected)?void 0:Te.month)?$e:null,year:null!=(ke=null==(Le=null==(fe=null==i?void 0:i.settings)?void 0:fe.selected)?void 0:Le.year)?ke:null,holidays:null!=(xe=null==(Ee=null==(He=null==i?void 0:i.settings)?void 0:He.selected)?void 0:Ee.holidays)?xe:null,time:null!=(_e=null==(Ye=null==(Ne=null==i?void 0:i.settings)?void 0:Ne.selected)?void 0:Ye.time)?_e:null},visibility:{theme:null!=(Ie=null==(Be=null==(Ae=null==i?void 0:i.settings)?void 0:Ae.visibility)?void 0:Be.theme)?Ie:"system",themeDetect:null!=(Oe=null==(Pe=null==(Fe=null==i?void 0:i.settings)?void 0:Fe.visibility)?void 0:Pe.themeDetect)?Oe:"html[data-theme]",monthShort:null==(We=null==(qe=null==(Ke=null==i?void 0:i.settings)?void 0:Ke.visibility)?void 0:qe.monthShort)||We,weekNumbers:null!=(Ge=null==(Re=null==(je=null==i?void 0:i.settings)?void 0:je.visibility)?void 0:Re.weekNumbers)&&Ge,weekend:null==(Ve=null==(Ue=null==(ze=null==i?void 0:i.settings)?void 0:ze.visibility)?void 0:Ue.weekend)||Ve,today:null==(Xe=null==(Qe=null==(Je=null==i?void 0:i.settings)?void 0:Je.visibility)?void 0:Qe.today)||Xe,disabled:null!=(tt=null==(et=null==(Ze=null==i?void 0:i.settings)?void 0:Ze.visibility)?void 0:et.disabled)&&tt,daysOutside:null==(at=null==(lt=null==(st=null==i?void 0:i.settings)?void 0:st.visibility)?void 0:lt.daysOutside)||at}},this.locale={months:null!=(it=null==(nt=null==i?void 0:i.locale)?void 0:nt.months)?it:[],weekday:null!=(rt=null==(dt=null==i?void 0:i.locale)?void 0:dt.weekday)?rt:[]},this.actions={clickDay:null!=(ot=null==(ct=null==i?void 0:i.actions)?void 0:ct.clickDay)?ot:null,clickWeekNumber:null!=(vt=null==(ut=null==i?void 0:i.actions)?void 0:ut.clickWeekNumber)?vt:null,clickMonth:null!=(gt=null==(mt=null==i?void 0:i.actions)?void 0:mt.clickMonth)?gt:null,clickYear:null!=(ht=null==(yt=null==i?void 0:i.actions)?void 0:yt.clickYear)?ht:null,clickArrow:null!=(pt=null==(St=null==i?void 0:i.actions)?void 0:St.clickArrow)?pt:null,changeTime:null!=(Ct=null==(bt=null==i?void 0:i.actions)?void 0:bt.changeTime)?Ct:null,changeToInput:null!=(Dt=null==(Mt=null==i?void 0:i.actions)?void 0:Mt.changeToInput)?Dt:null,getDays:null!=(Tt=null==(wt=null==i?void 0:i.actions)?void 0:wt.getDays)?Tt:null},this.popups=null!=($t=null==i?void 0:i.popups)?$t: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!=(Lt=null==(ft=null==i?void 0:i.DOMTemplates)?void 0:ft.default)?Lt:(_t=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!=(Ht=null==(kt=null==i?void 0:i.DOMTemplates)?void 0:kt.multiple)?Ht:J(this.CSSClasses),month:null!=(xt=null==(Et=null==i?void 0:i.DOMTemplates)?void 0:Et.month)?xt:Q(this.CSSClasses),year:null!=(Yt=null==(Nt=null==i?void 0:i.DOMTemplates)?void 0:Nt.year)?Yt:X(this.CSSClasses)},this.currentType=this.type)}}})); diff --git a/package/build/vanilla-calendar.min.mjs b/package/build/vanilla-calendar.min.mjs new file mode 100644 index 00000000..6bd094dc --- /dev/null +++ b/package/build/vanilla-calendar.min.mjs @@ -0,0 +1,1654 @@ +/*! name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar */ +var __defProp = Object.defineProperty; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __publicField = (obj, key, value) => { + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + return value; +}; +const generateDate = (date) => { + const year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + month = month < 10 ? `0${month}` : month; + day = day < 10 ? `0${day}` : day; + return `${year}-${month}-${day}`; +}; +const parserDates = (dates) => { + const newDates = []; + dates.forEach((date) => { + if (date.match(/^(\d{4}-\d{2}-\d{2})$/g)) { + newDates.push(date); + } else { + date.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g, (_, d1, d2) => { + const startDate = /* @__PURE__ */ new Date(`${d1}T00:00:00`); + const endDate = /* @__PURE__ */ new Date(`${d2}T00:00:00`); + const currentDate = new Date(startDate.getTime()); + for (currentDate; currentDate <= endDate; currentDate.setDate(currentDate.getDate() + 1)) { + newDates.push(generateDate(currentDate)); + } + return _; + }); + } + }); + return newDates; +}; +const transformTime12 = (hour) => { + const oldHour = Number(hour); + let newHour = String(oldHour); + if (oldHour === 0) { + newHour = "12"; + } else if (oldHour === 13) { + newHour = "01"; + } else if (oldHour === 14) { + newHour = "02"; + } else if (oldHour === 15) { + newHour = "03"; + } else if (oldHour === 16) { + newHour = "04"; + } else if (oldHour === 17) { + newHour = "05"; + } else if (oldHour === 18) { + newHour = "06"; + } else if (oldHour === 19) { + newHour = "07"; + } else if (oldHour === 20) { + newHour = "08"; + } else if (oldHour === 21) { + newHour = "09"; + } else if (oldHour === 22) { + newHour = "10"; + } else if (oldHour === 23) { + newHour = "11"; + } + return newHour; +}; +const setVariablesDates = (self) => { + var _a, _b; + self.rangeMin = self.settings.range.min; + self.rangeMax = self.settings.range.max; + self.rangeDisabled = self.settings.range.disabled ? parserDates([...self.settings.range.disabled]) : []; + self.rangeEnabled = self.settings.range.enabled ? parserDates([...self.settings.range.enabled]) : []; + self.selectedDates = self.settings.selected.dates ? parserDates([...self.settings.selected.dates]) : []; + self.selectedHolidays = self.settings.selected.holidays ? parserDates([...self.settings.selected.holidays]) : []; + if (self.settings.range.disablePast && !self.settings.range.disableAllDays && /* @__PURE__ */ new Date(`${self.settings.range.min}T00:00:00`) < self.date.today) { + self.rangeMin = generateDate(self.date.today); + } + if (self.settings.range.disableAllDays) { + self.rangeMin = generateDate(self.date.today); + self.rangeMax = generateDate(self.date.today); + (_a = self.rangeDisabled) == null ? void 0 : _a.push(generateDate(self.date.today)); + } + if (self.rangeEnabled) + self.rangeEnabled.sort((a, b) => +new Date(a) - +new Date(b)); + if (((_b = self.rangeEnabled) == null ? void 0 : _b[0]) && self.settings.range.disableAllDays) { + self.rangeMin = self.rangeEnabled[0]; + self.rangeMax = self.rangeEnabled[self.rangeEnabled.length - 1]; + } + const firstDay = /* @__PURE__ */ new Date(`${self.rangeMin}T00:00:00`); + const lastDay = /* @__PURE__ */ new Date(`${self.rangeMax}T00:00:00`); + firstDay.setDate(firstDay.getDate() - 1); + lastDay.setDate(lastDay.getDate() + 1); + self.rangeDisabled.push(generateDate(firstDay)); + self.rangeDisabled.push(generateDate(lastDay)); + if (self.settings.selected.month !== null && self.settings.selected.month >= 0 && self.settings.selected.month < 12) { + self.selectedMonth = self.settings.selected.month; + } else { + self.selectedMonth = self.date.today.getMonth(); + } + if (self.settings.selected.year !== null && self.settings.selected.year >= 0 && self.settings.selected.year <= 9999) { + self.selectedYear = self.settings.selected.year; + } else { + self.selectedYear = self.date.today.getFullYear(); + } + self.viewYear = self.selectedYear; + self.dateMin = self.settings.visibility.disabled ? /* @__PURE__ */ new Date(`${self.date.min}T00:00:00`) : /* @__PURE__ */ new Date(`${self.rangeMin}T00:00:00`); + self.dateMax = self.settings.visibility.disabled ? /* @__PURE__ */ new Date(`${self.date.max}T00:00:00`) : /* @__PURE__ */ new Date(`${self.rangeMax}T00:00:00`); + const time12 = self.settings.selection.time === true || self.settings.selection.time === 12; + if (time12 || self.settings.selection.time === 24) { + self.userTime = false; + if (typeof self.settings.selected.time === "string") { + const regExr = time12 ? /^([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; + self.settings.selected.time.replace(regExr, (_, p1, p2, p3) => { + if (p1 && p2) { + self.userTime = true; + self.selectedHours = p1; + self.selectedMinutes = p2; + } + if (p3 && time12) { + self.selectedKeeping = p3; + } else if (time12) { + self.selectedKeeping = "AM"; + } + return ""; + }); + } + if (!self.userTime && time12) { + self.selectedHours = transformTime12(String(self.date.today.getHours())); + self.selectedMinutes = String(self.date.today.getMinutes()); + self.selectedKeeping = Number(self.date.today.getHours()) >= 12 ? "PM" : "AM"; + } else if (!self.userTime) { + self.selectedHours = String(self.date.today.getHours()); + self.selectedMinutes = String(self.date.today.getMinutes()); + } + self.selectedHours = Number(self.selectedHours) < 10 ? `0${Number(self.selectedHours)}` : `${self.selectedHours}`; + self.selectedMinutes = Number(self.selectedMinutes) < 10 ? `0${Number(self.selectedMinutes)}` : `${self.selectedMinutes}`; + self.selectedTime = `${self.selectedHours}:${self.selectedMinutes}${self.selectedKeeping ? ` ${self.selectedKeeping}` : ""}`; + } else if (self.settings.selection.time) { + self.settings.selection.time = false; + console.error("The value of the time property can be: false, true, 12 or 24."); + } + if (self.type !== "multiple") + return; + if (self.months === 1) { + console.warn("The value of the «months» parameter cannot be less than «2», the minimum available value will be initialized."); + self.correctMonths = 2; + } else if (self.months > 12) { + console.warn("The value of the «months» parameter cannot be greater than «12», the maximum available value will be initialized."); + self.correctMonths = 12; + } else { + self.correctMonths = self.months; + } +}; +const controlArrows = (self) => { + if (!["default", "multiple", "year"].includes(self.currentType)) + return; + const arrowPrev = self.HTMLElement.querySelector(`.${self.CSSClasses.arrowPrev}`); + const arrowNext = self.HTMLElement.querySelector(`.${self.CSSClasses.arrowNext}`); + if (!arrowPrev || !arrowNext) + return; + const defaultControl = () => { + if (!self.dateMin || !self.dateMax) + return; + const jumpDateMin = new Date(self.selectedYear, self.selectedMonth, 1); + const jumpDateMax = new Date(self.selectedYear, self.selectedMonth, 1); + jumpDateMin.setMonth(jumpDateMin.getMonth() - self.jumpMonths); + jumpDateMax.setMonth(jumpDateMax.getMonth() + self.jumpMonths); + if (jumpDateMin < self.dateMin || !self.settings.selection.month) { + arrowPrev.style.visibility = "hidden"; + } else { + arrowPrev.style.visibility = ""; + } + if (jumpDateMax > self.dateMax || !self.settings.selection.month) { + arrowNext.style.visibility = "hidden"; + } else { + arrowNext.style.visibility = ""; + } + }; + const yearControl = () => { + if (!self.dateMin || !self.dateMax || self.viewYear === void 0) + return; + if (self.dateMin.getFullYear() && self.viewYear - 7 <= self.dateMin.getFullYear()) { + arrowPrev.style.visibility = "hidden"; + } else { + arrowPrev.style.visibility = ""; + } + if (self.dateMax.getFullYear() && self.viewYear + 7 >= self.dateMax.getFullYear()) { + arrowNext.style.visibility = "hidden"; + } else { + arrowNext.style.visibility = ""; + } + }; + if (self.currentType === "default" || self.currentType === "multiple") + defaultControl(); + if (self.currentType === "year") + yearControl(); +}; +const createPopup = (self, daysEl) => { + if (!self.popups) + return; + Object.keys(self.popups).forEach((date) => { + var _a; + const dayBtnEl = daysEl.querySelector(`[data-calendar-day="${date}"]`); + if (dayBtnEl) { + const dayInfo = (_a = self.popups) == null ? void 0 : _a[date]; + if (dayInfo == null ? void 0 : dayInfo.modifier) + dayInfo.modifier.trim().split(" ").forEach((cl) => { + dayBtnEl.classList.add(cl); + }); + if (dayInfo == null ? void 0 : dayInfo.html) + dayBtnEl.parentNode.innerHTML += `
${dayInfo.html}
`; + } + }); +}; +const getWeekNumber = (date, iso8601) => { + if (!date) + return null; + const day = (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getDate(); + const month = (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getMonth(); + const year = (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getFullYear(); + const currentDate = new Date(year, month, day); + const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay(); + currentDate.setDate(currentDate.getDate() + 4 - dayNum); + const yearStart = new Date(currentDate.getFullYear(), 0, 1); + const weekNumber = Math.ceil(((+currentDate - +yearStart) / 864e5 + 1) / 7); + return { + year, + week: weekNumber + }; +}; +const createWeekNumbers = (self, firstDayWeek, daysSelectedMonth, weekNumbersEl, daysEl) => { + if (!self.settings.visibility.weekNumbers) + return; + const dayEls = daysEl.querySelectorAll(`.${self.CSSClasses.day}`); + weekNumbersEl.innerHTML = ""; + const countWeek = Math.ceil((firstDayWeek + daysSelectedMonth) / 7); + const weekNumbersTitleEl = document.createElement("b"); + weekNumbersTitleEl.className = self.CSSClasses.weekNumbersTitle; + weekNumbersTitleEl.innerText = "#"; + weekNumbersEl.append(weekNumbersTitleEl); + const weekNumbersContentEl = document.createElement("div"); + weekNumbersContentEl.className = self.CSSClasses.weekNumbersContent; + weekNumbersEl.append(weekNumbersContentEl); + const templateWeekNumberEl = document.createElement("span"); + templateWeekNumberEl.className = self.CSSClasses.weekNumber; + for (let i = 0; i < countWeek; i++) { + let dayBtnEl = null; + if (i === 0) { + dayBtnEl = dayEls[6].querySelector(`.${self.CSSClasses.dayBtn}`); + } else { + dayBtnEl = dayEls[i * 7].querySelector(`.${self.CSSClasses.dayBtn}`); + } + const weekNumber = getWeekNumber(dayBtnEl.dataset.calendarDay, self.settings.iso8601); + if (!weekNumber) + return; + const weekNumberEl = templateWeekNumberEl.cloneNode(true); + weekNumberEl.innerText = `${weekNumber.week}`; + weekNumberEl.dataset.calendarYearWeek = `${weekNumber.year}`; + weekNumbersContentEl.append(weekNumberEl); + } +}; +const createDays = (self) => { + var _a, _b; + const daysEls = self.HTMLElement.querySelectorAll(`.${self.CSSClasses.days}`); + const weekNumbersEls = self.HTMLElement.querySelectorAll(`.${self.CSSClasses.weekNumbers}`); + const initDate = new Date(self.selectedYear, self.selectedMonth, 1); + const templateDayEl = document.createElement("div"); + const templateDayBtnEl = document.createElement("button"); + templateDayEl.className = self.CSSClasses.day; + templateDayBtnEl.className = self.CSSClasses.dayBtn; + templateDayBtnEl.type = "button"; + (_a = self.selectedDates) == null ? void 0 : _a.sort((a, b) => +new Date(a) - +new Date(b)); + daysEls.forEach((_, index) => { + const selectedMonth = new Date(initDate.setMonth(self.selectedMonth + index)).getMonth(); + const selectedYear = new Date(initDate.setFullYear(self.selectedYear, self.selectedMonth + index)).getFullYear(); + const firstDay = new Date(selectedYear, selectedMonth, 1); + const daysSelectedMonth = new Date(selectedYear, selectedMonth + 1, 0).getDate(); + let firstDayWeek = Number(firstDay.getDay()); + if (self.settings.iso8601) + firstDayWeek = Number((firstDay.getDay() !== 0 ? firstDay.getDay() : 7) - 1); + if (self.settings.selection.day && ["single", "multiple", "multiple-ranged"].includes(self.settings.selection.day)) { + daysEls[index].classList.add(self.CSSClasses.daysSelecting); + } + daysEls[index].innerHTML = ""; + const setDayModifier = (dayEl, dayBtnEl, dayID, date, otherMonth) => { + if (self.rangeMin > date || self.rangeMax < date) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnDisabled); + dayBtnEl.tabIndex = -1; + } + if (self.settings.visibility.weekend && (dayID === 0 || dayID === 6)) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnWeekend); + } + if (Array.isArray(self.selectedHolidays)) { + self.selectedHolidays.forEach((holiday) => { + if (holiday === date) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnHoliday); + } + }); + } + let thisToday = self.date.today.getDate(); + let thisMonth = self.date.today.getMonth() + 1; + thisToday = thisToday < 10 ? `0${thisToday}` : thisToday; + thisMonth = thisMonth < 10 ? `0${thisMonth}` : thisMonth; + const thisDay = `${self.date.today.getFullYear()}-${thisMonth}-${thisToday}`; + if (self.settings.visibility.today && dayBtnEl.dataset.calendarDay === thisDay) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnToday); + } + if (self.selectedDates && self.selectedDates.indexOf(date) === 0) { + if (self.settings.selection.day === "multiple-ranged" && self.selectedDates.length > 1) { + dayEl.classList.add(self.CSSClasses.daySelectedFirst); + } else { + dayEl.classList.add(self.CSSClasses.daySelected); + } + dayBtnEl.classList.add(self.CSSClasses.dayBtnSelected); + } else if (self.selectedDates && self.selectedDates[0] && self.selectedDates.indexOf(date) === self.selectedDates.length - 1) { + dayEl.classList.add(self.CSSClasses.daySelected); + if (self.settings.selection.day === "multiple-ranged") { + dayEl.classList.add(self.CSSClasses.daySelectedLast); + } else { + dayEl.classList.add(self.CSSClasses.daySelected); + } + dayBtnEl.classList.add(self.CSSClasses.dayBtnSelected); + } else if (self.selectedDates && self.selectedDates.indexOf(date) > 0 && self.settings.selection.day === "multiple-ranged") { + dayEl.classList.add(self.CSSClasses.daySelectedIntermediate); + dayBtnEl.classList.add(self.CSSClasses.dayBtnSelected); + dayBtnEl.classList.add(self.CSSClasses.dayBtnIntermediate); + } else if (self.selectedDates && self.selectedDates.indexOf(date) > 0) { + dayEl.classList.add(self.CSSClasses.daySelected); + dayBtnEl.classList.add(self.CSSClasses.dayBtnSelected); + } + if (Array.isArray(self.rangeDisabled) && self.rangeDisabled[0]) { + self.rangeDisabled.forEach((dateDisabled) => { + if (dateDisabled === date) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnDisabled); + dayBtnEl.tabIndex = -1; + } + }); + } + if (!self.settings.selection.month && otherMonth) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnDisabled); + dayBtnEl.tabIndex = -1; + } + if (!self.settings.selection.year && (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getFullYear() !== selectedYear) { + dayBtnEl.classList.add(self.CSSClasses.dayBtnDisabled); + dayBtnEl.tabIndex = -1; + } + }; + const createDay = (dayText, dayID, date, otherMonth, modifier) => { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i; + const dayEl = templateDayEl.cloneNode(true); + const dayBtnEl = templateDayBtnEl.cloneNode(true); + if (modifier) + dayBtnEl.classList.add(modifier); + dayBtnEl.innerText = dayText; + dayBtnEl.dataset.calendarDay = date; + if (self.settings.visibility.weekNumbers) { + const weekNumber = getWeekNumber(date, self.settings.iso8601); + if (!weekNumber) + return; + dayBtnEl.dataset.calendarWeekNumber = `${weekNumber.week}`; + } + if (((_a2 = self.rangeEnabled) == null ? void 0 : _a2[0]) && self.settings.range.disableAllDays && !((_b2 = self.rangeDisabled) == null ? void 0 : _b2.includes(date))) { + (_c = self.rangeDisabled) == null ? void 0 : _c.push(date); + } + if (((_d = self.rangeEnabled) == null ? void 0 : _d[0]) && ((_e = self.rangeDisabled) == null ? void 0 : _e.includes(date))) { + self.rangeDisabled = (_f = self.rangeDisabled) == null ? void 0 : _f.filter((d) => { + var _a3; + return !((_a3 = self.rangeEnabled) == null ? void 0 : _a3.includes(d)); + }); + } + if (((_g = self.settings.range.disableWeekday) == null ? void 0 : _g.includes(dayID)) && !((_h = self.rangeDisabled) == null ? void 0 : _h.includes(date))) { + (_i = self.rangeDisabled) == null ? void 0 : _i.push(date); + } + setDayModifier(dayEl, dayBtnEl, dayID, date, otherMonth); + if (otherMonth) { + if (self.settings.visibility.daysOutside) + dayEl.append(dayBtnEl); + } else { + dayEl.append(dayBtnEl); + } + daysEls[index].append(dayEl); + if (self.actions.getDays) + self.actions.getDays(Number(dayText), date, dayEl, dayBtnEl); + }; + const prevMonth = () => { + const prevMonthDays = new Date(selectedYear, selectedMonth, 0).getDate(); + let day = prevMonthDays - firstDayWeek; + let year = selectedYear; + let month = selectedMonth; + if (selectedMonth === 0) { + month = self.locale.months.length; + year = selectedYear - 1; + } else if (selectedMonth < 10) { + month = `0${selectedMonth}`; + } + for (let i = 0; i < firstDayWeek; i++) { + day += 1; + const date = `${year}-${month}-${day}`; + const dayIDCurrent = new Date(selectedYear, selectedMonth, day - 1); + const prevMonthID = dayIDCurrent.getMonth() - 1; + const dayID = new Date(selectedYear, prevMonthID, day).getDay(); + createDay(String(day), dayID, date, true, self.CSSClasses.dayBtnPrev); + } + }; + const currentMonth = () => { + for (let i = 1; i <= daysSelectedMonth; i++) { + const day = new Date(selectedYear, selectedMonth, i); + const date = generateDate(day); + const dayID = day.getDay(); + createDay(String(i), dayID, date, false, null); + } + }; + const nextMonth = () => { + const total = firstDayWeek + daysSelectedMonth; + const rows = Math.ceil(total / self.locale.weekday.length); + const nextDays = self.locale.weekday.length * rows - total; + let year = selectedYear; + let month = String(selectedMonth + 2); + if (selectedMonth + 1 === self.locale.months.length) { + month = "01"; + year = selectedYear + 1; + } else if (selectedMonth + 2 < 10) { + month = `0${selectedMonth + 2}`; + } + for (let i = 1; i <= nextDays; i++) { + const day = i < 10 ? `0${i}` : String(i); + const date = `${year}-${month}-${day}`; + const dayIDCurrent = new Date(selectedYear, selectedMonth, i); + const nextMonthID = dayIDCurrent.getMonth() + 1; + const dayID = new Date(selectedYear, nextMonthID, i).getDay(); + createDay(String(i), dayID, date, true, self.CSSClasses.dayBtnNext); + } + }; + prevMonth(); + currentMonth(); + nextMonth(); + createPopup(self, daysEls[index]); + createWeekNumbers(self, firstDayWeek, daysSelectedMonth, weekNumbersEls[index], daysEls[index]); + }); + (_b = self.rangeDisabled) == null ? void 0 : _b.sort((a, b) => +new Date(a) - +new Date(b)); +}; +const ArrowPrev = (self) => ` + +`; +const ArrowNext = (self) => ` + +`; +const Month = (self) => ` + +`; +const Year = (self) => ` + +`; +const Week = (self) => ` +
+`; +const Days = (self) => ` +
+`; +const Months = (self) => ` +
+`; +const Years = (self) => ` +
+`; +const WeekNumbers = (self) => self.settings.visibility.weekNumbers ? ` +
+` : ""; +const ControlTime = (self) => self.settings.selection.time ? ` +
+` : ""; +const getComponent = (pattern) => { + let FC = null; + switch (pattern) { + case "ArrowPrev": + FC = ArrowPrev; + break; + case "ArrowNext": + FC = ArrowNext; + break; + case "Month": + FC = Month; + break; + case "Year": + FC = Year; + break; + case "Week": + FC = Week; + break; + case "Days": + FC = Days; + break; + case "Months": + FC = Months; + break; + case "Years": + FC = Years; + break; + case "WeekNumbers": + FC = WeekNumbers; + break; + case "ControlTime": + FC = ControlTime; + break; + } + return FC; +}; +const DOMParser = (self, template) => template.replace(/<#(.*?)\/>/g, (_, p1) => { + const component = getComponent(p1.replace(/[\s\n\t]/g, "")); + return component ? component(self) : ""; +}).replace(/[\n\t]/g, ""); +const MultipleParser = (self, template) => template.replace(/<#Multiple>(.*?)<#\/Multiple>/g, (_, p1) => { + let content = ""; + for (let i = 0; i < self.correctMonths; i++) { + content += p1; + } + return content; +}).replace(/[\n\t]/g, ""); +const createDOM = (self) => { + const calendarElement = self.HTMLElement; + calendarElement.classList.add(self.CSSClasses.calendar); + switch (self.currentType) { + case "default": + calendarElement.classList.add(self.CSSClasses.calendarDefault); + calendarElement.classList.remove(self.CSSClasses.calendarMonth); + calendarElement.classList.remove(self.CSSClasses.calendarYear); + calendarElement.innerHTML = DOMParser(self, self.DOMTemplates.default); + break; + case "multiple": + if (!self.correctMonths) + break; + calendarElement.classList.add(self.CSSClasses.calendarMultiple); + calendarElement.classList.remove(self.CSSClasses.calendarMonth); + calendarElement.classList.remove(self.CSSClasses.calendarYear); + calendarElement.innerHTML = MultipleParser(self, DOMParser(self, self.DOMTemplates.multiple)); + break; + case "month": + calendarElement.classList.remove(self.CSSClasses.calendarDefault); + calendarElement.classList.add(self.CSSClasses.calendarMonth); + calendarElement.classList.remove(self.CSSClasses.calendarYear); + calendarElement.innerHTML = DOMParser(self, self.DOMTemplates.month); + break; + case "year": + calendarElement.classList.remove(self.CSSClasses.calendarDefault); + calendarElement.classList.remove(self.CSSClasses.calendarMonth); + calendarElement.classList.add(self.CSSClasses.calendarYear); + calendarElement.innerHTML = DOMParser(self, self.DOMTemplates.year); + break; + } +}; +const showMonth = (self) => { + const months = self.HTMLElement.querySelectorAll("[data-calendar-selected-month]"); + if (!months[0] || self.selectedMonth === void 0) + return; + const initDate = new Date(self.selectedYear, self.selectedMonth, 1); + months.forEach((_, index) => { + const selectedMonth = new Date(initDate.setMonth(self.selectedMonth + index)).getMonth(); + months[index].dataset.calendarSelectedMonth = String(selectedMonth); + months[index].innerText = self.locale.months[selectedMonth]; + if (!self.settings.selection.month || self.currentType === "multiple") { + months[index].tabIndex = -1; + months[index].classList.add(self.CSSClasses.monthDisabled); + } else { + months[index].tabIndex = 0; + months[index].classList.remove(self.CSSClasses.monthDisabled); + } + }); +}; +const showYear = (self) => { + const years = self.HTMLElement.querySelectorAll("[data-calendar-selected-year]"); + if (!years || self.selectedMonth === void 0) + return; + const initDate = new Date(self.selectedYear, self.selectedMonth, 1); + years.forEach((_, index) => { + const selectedYear = new Date(initDate.setFullYear(self.selectedYear, self.selectedMonth + index)).getFullYear(); + years[index].dataset.calendarSelectedYear = String(selectedYear); + years[index].innerText = String(selectedYear); + if (!self.settings.selection.year || self.currentType === "multiple") { + years[index].tabIndex = -1; + years[index].classList.add(self.CSSClasses.yearDisabled); + } else { + years[index].tabIndex = 0; + years[index].classList.remove(self.CSSClasses.yearDisabled); + } + }); +}; +const createMonths = (self) => { + self.currentType = "month"; + createDOM(self); + showMonth(self); + showYear(self); + const monthsEl = self.HTMLElement.querySelector(`.${self.CSSClasses.months}`); + if (self.selectedMonth === void 0 || self.selectedYear === void 0 || !self.dateMin || !self.dateMax || !monthsEl) + return; + if (self.settings.selection.month) + monthsEl.classList.add(self.CSSClasses.monthsSelecting); + const templateMonthEl = document.createElement("button"); + templateMonthEl.type = "button"; + templateMonthEl.className = self.CSSClasses.monthsMonth; + for (let i = 0; i < self.locale.months.length; i++) { + const month = self.locale.months[i]; + const monthEl = templateMonthEl.cloneNode(true); + if (i === self.selectedMonth) { + monthEl.classList.add(self.CSSClasses.monthsMonthSelected); + } + if (i < self.dateMin.getMonth() && self.selectedYear === self.dateMin.getFullYear()) { + monthEl.classList.add(self.CSSClasses.monthsMonthDisabled); + monthEl.tabIndex = -1; + } + if (i > self.dateMax.getMonth() && self.selectedYear === self.dateMax.getFullYear()) { + monthEl.classList.add(self.CSSClasses.monthsMonthDisabled); + monthEl.tabIndex = -1; + } + monthEl.dataset.calendarMonth = String(i); + monthEl.title = `${month}`; + monthEl.innerText = `${self.settings.visibility.monthShort ? month.substring(0, 3) : month}`; + monthsEl.append(monthEl); + } +}; +const transformTime24 = (hour, keeping) => { + const oldHour = Number(hour); + let newHour = String(oldHour); + if (keeping === "AM") { + if (oldHour === 12) { + newHour = "00"; + } + } else if (keeping === "PM") { + if (oldHour === 1) { + newHour = "13"; + } else if (oldHour === 2) { + newHour = "14"; + } else if (oldHour === 3) { + newHour = "15"; + } else if (oldHour === 4) { + newHour = "16"; + } else if (oldHour === 5) { + newHour = "17"; + } else if (oldHour === 6) { + newHour = "18"; + } else if (oldHour === 7) { + newHour = "19"; + } else if (oldHour === 8) { + newHour = "20"; + } else if (oldHour === 9) { + newHour = "21"; + } else if (oldHour === 10) { + newHour = "22"; + } else if (oldHour === 11) { + newHour = "23"; + } + } + return newHour; +}; +const controlTime = (self, keepingTime) => { + const rangeHours = self.HTMLElement.querySelector(`.${self.CSSClasses.timeRange} input[name="hours"]`); + const rangeMinutes = self.HTMLElement.querySelector(`.${self.CSSClasses.timeRange} input[name="minutes"]`); + const inputHours = self.HTMLElement.querySelector(`.${self.CSSClasses.timeHours} input[name="hours"]`); + const inputMinutes = self.HTMLElement.querySelector(`.${self.CSSClasses.timeMinutes} input[name="minutes"]`); + const btnKeepingTime = self.HTMLElement.querySelector(`.${self.CSSClasses.timeKeeping}`); + const mouseoverRange = (range, input) => { + range.addEventListener("mouseover", () => input.classList.add(self.CSSClasses.isFocus)); + }; + const mouseoutRange = (range, input) => { + range.addEventListener("mouseout", () => input.classList.remove(self.CSSClasses.isFocus)); + }; + const setTime = (e, value, type) => { + if (type === "hours") { + self.selectedHours = `${value}`; + } else if (type === "minutes") { + self.selectedMinutes = `${value}`; + } + self.selectedTime = `${self.selectedHours}:${self.selectedMinutes}${self.selectedKeeping ? ` ${self.selectedKeeping}` : ""}`; + if (self.actions.changeTime) { + self.actions.changeTime(e, self.selectedTime, self.selectedHours, self.selectedMinutes, self.selectedKeeping); + } + if (self.input && self.HTMLInputElement && self.actions.changeToInput) { + self.actions.changeToInput(e, self.HTMLInputElement, self.selectedDates, self.selectedTime, self.selectedHours, self.selectedMinutes, self.selectedKeeping); + } + }; + const changeRange = (range, input, type, max) => { + range.addEventListener("input", (e) => { + let value = Number(e.target.value); + value = value < 10 ? `0${value}` : `${value}`; + if (type === "hours" && max === 12) { + if (Number(e.target.value) < max && Number(e.target.value) > 0) { + input.value = value; + self.selectedKeeping = "AM"; + btnKeepingTime.innerText = self.selectedKeeping; + setTime(e, value, type); + } else { + if (Number(e.target.value) === 0) { + self.selectedKeeping = "AM"; + btnKeepingTime.innerText = "AM"; + } else { + self.selectedKeeping = "PM"; + btnKeepingTime.innerText = "PM"; + } + input.value = transformTime12(e.target.value); + setTime(e, transformTime12(e.target.value), type); + } + } else { + input.value = value; + setTime(e, value, type); + } + }); + }; + const changeInput = (range, input, type, max) => { + input.addEventListener("change", (e) => { + const changeInputEl = e.target; + let value = Number(changeInputEl.value); + value = value < 10 ? `0${value}` : `${value}`; + if (type === "hours" && max === 12) { + if (changeInputEl.value && Number(changeInputEl.value) <= max && Number(changeInputEl.value) > 0) { + changeInputEl.value = value; + range.value = transformTime24(value, self.selectedKeeping); + setTime(e, value, type); + } else if (changeInputEl.value && Number(changeInputEl.value) < 24 && (Number(changeInputEl.value) > max || Number(changeInputEl.value) === 0)) { + if (Number(changeInputEl.value) === 0) { + self.selectedKeeping = "AM"; + btnKeepingTime.innerText = "AM"; + } else { + self.selectedKeeping = "PM"; + btnKeepingTime.innerText = "PM"; + } + changeInputEl.value = transformTime12(changeInputEl.value); + range.value = value; + setTime(e, transformTime12(changeInputEl.value), type); + } else { + changeInputEl.value = self.selectedHours; + } + } else if (changeInputEl.value && Number(changeInputEl.value) <= max && Number(changeInputEl.value) >= 0) { + changeInputEl.value = value; + range.value = value; + setTime(e, value, type); + } else if (type === "hours") { + changeInputEl.value = self.selectedHours; + } else if (type === "minutes") { + changeInputEl.value = self.selectedMinutes; + } + }); + }; + mouseoverRange(rangeHours, inputHours); + mouseoverRange(rangeMinutes, inputMinutes); + mouseoutRange(rangeHours, inputHours); + mouseoutRange(rangeMinutes, inputMinutes); + changeRange(rangeHours, inputHours, "hours", keepingTime === 24 ? 23 : 12); + changeRange(rangeMinutes, inputMinutes, "minutes", 0); + changeInput(rangeHours, inputHours, "hours", keepingTime === 24 ? 23 : 12); + changeInput(rangeMinutes, inputMinutes, "minutes", 59); + if (!btnKeepingTime) + return; + btnKeepingTime.addEventListener("click", (e) => { + if (btnKeepingTime.innerText.includes("AM")) { + self.selectedKeeping = "PM"; + } else { + self.selectedKeeping = "AM"; + } + rangeHours.value = transformTime24(self.selectedHours, self.selectedKeeping); + setTime(e, self.selectedHours, "hours"); + btnKeepingTime.innerText = self.selectedKeeping; + }); +}; +const createTime = (self) => { + const timeEl = self.HTMLElement.querySelector(`.${self.CSSClasses.time}`); + if (!timeEl) + return; + const keepingTime = self.settings.selection.time === true ? 12 : self.settings.selection.time; + const range = self.settings.selection.controlTime === "range"; + timeEl.innerHTML = ` +
+ + + ${keepingTime === 12 ? ` + + ` : ""} +
+
+ + +
`; + controlTime(self, keepingTime); +}; +const createWeek = (self) => { + const weekday = [...self.locale.weekday]; + if (!weekday[0]) + return; + const weekEls = self.HTMLElement.querySelectorAll(`.${self.CSSClasses.week}`); + const templateWeekDayEl = document.createElement("b"); + templateWeekDayEl.className = self.CSSClasses.weekDay; + if (self.settings.iso8601) + weekday.push(weekday.shift()); + weekEls.forEach((weekEl) => { + weekEl.innerHTML = ""; + for (let i = 0; i < weekday.length; i++) { + const weekDayName = weekday[i]; + const weekDayEl = templateWeekDayEl.cloneNode(true); + if (self.settings.visibility.weekend && self.settings.iso8601) { + if (i === 5 || i === 6) { + weekDayEl.classList.add(self.CSSClasses.weekDayWeekend); + } + } else if (self.settings.visibility.weekend && !self.settings.iso8601) { + if (i === 0 || i === 6) { + weekDayEl.classList.add(self.CSSClasses.weekDayWeekend); + } + } + weekDayEl.innerText = `${weekDayName}`; + weekEl.append(weekDayEl); + } + }); +}; +const createYears = (self) => { + if (self.viewYear === void 0 || !self.dateMin || !self.dateMax) + return; + self.currentType = "year"; + createDOM(self); + showMonth(self); + showYear(self); + controlArrows(self); + const yearsEl = self.HTMLElement.querySelector(`.${self.CSSClasses.years}`); + if (!yearsEl) + return; + if (self.settings.selection.year) + yearsEl.classList.add(self.CSSClasses.yearsSelecting); + const templateYearEl = document.createElement("button"); + templateYearEl.type = "button"; + templateYearEl.className = self.CSSClasses.yearsYear; + for (let i = self.viewYear - 7; i < self.viewYear + 8; i++) { + const year = i; + const yearEl = templateYearEl.cloneNode(true); + if (year === self.selectedYear) { + yearEl.classList.add(self.CSSClasses.yearsYearSelected); + } + if (year < self.dateMin.getFullYear()) { + yearEl.classList.add(self.CSSClasses.yearsYearDisabled); + yearEl.tabIndex = -1; + } + if (year > self.dateMax.getFullYear()) { + yearEl.classList.add(self.CSSClasses.yearsYearDisabled); + yearEl.tabIndex = -1; + } + yearEl.dataset.calendarYear = String(year); + yearEl.innerText = `${year}`; + yearsEl.append(yearEl); + } +}; +const getLocale = (self) => { + if (self.settings.lang === "define") + return; + self.locale.weekday = []; + for (let i = 0; i < 7; i++) { + let weekday = new Date(0, 0, i).toLocaleString(self.settings.lang, { weekday: "short" }); + weekday = `${weekday.charAt(0).toUpperCase()}${weekday.substring(1, weekday.length)}`; + weekday = weekday.replace(/\./, ""); + self.locale.weekday.push(weekday); + } + self.locale.months = []; + for (let i = 0; i < 12; i++) { + let month = new Date(0, i).toLocaleString(self.settings.lang, { month: "long" }); + month = `${month.charAt(0).toUpperCase()}${month.substring(1, month.length)}`; + month = month.replace(/\./, ""); + self.locale.months.push(month); + } +}; +const themes = ["light", "dark", "system"]; +let haveListener = false; +const getActiveTheme = (htmlEl, attr) => { + var _a; + let activeTheme = null; + for (let i = 0; i < themes.length; i++) { + const theme = themes[i]; + if (theme === "system") + return; + if ((_a = htmlEl.getAttribute(attr)) == null ? void 0 : _a.includes(themes[i])) { + activeTheme = themes[i]; + break; + } + } + return activeTheme; +}; +const set = (self, theme) => { + if (!self.HTMLElement) + return; + if (themes.includes(theme)) { + self.HTMLElement.dataset.calendarTheme = theme; + return; + } + console.error("Incorrect name of theme in settings.visibility.theme"); +}; +const get = (self, supportDarkTheme) => { + if (!supportDarkTheme) { + set(self, "light"); + return; + } + const theme = (e) => e.matches ? "dark" : "light"; + self.HTMLElement.dataset.calendarTheme = theme(supportDarkTheme); + if (!haveListener) { + supportDarkTheme.onchange = (e) => { + if (self.settings.visibility.theme !== "system") + return; + self.HTMLElement.dataset.calendarTheme = theme(e); + }; + haveListener = true; + } +}; +const track = (self, htmlEl, attr) => { + const changes = (mutationsList) => { + for (let i = 0; i < mutationsList.length; i++) { + const record = mutationsList[i]; + if (record.attributeName === attr) { + const activeTheme = getActiveTheme(htmlEl, attr); + if (activeTheme) + set(self, activeTheme); + break; + } + } + }; + const observer = new MutationObserver(changes); + observer.observe(htmlEl, { + attributes: true + }); +}; +const detect = (self, supportDarkTheme) => { + if (!self.HTMLElement) + return; + const detectedThemeEl = self.settings.visibility.themeDetect ? document.querySelector(self.settings.visibility.themeDetect) : false; + if (!detectedThemeEl) { + get(self, supportDarkTheme); + return; + } + const attr = self.settings.visibility.themeDetect.replace(/^.*\[(.+)\]/g, (_, p1) => p1); + const strValues = detectedThemeEl.hasAttribute(attr); + if (!attr || !strValues) { + get(self, supportDarkTheme); + return; + } + const activeTheme = getActiveTheme(detectedThemeEl, attr); + if (activeTheme) { + set(self, activeTheme); + track(self, detectedThemeEl, attr); + } else { + get(self, supportDarkTheme); + } +}; +const setTheme = (self) => { + if (!self.HTMLElement) + return; + let supportDarkTheme; + if (window.matchMedia("(prefers-color-scheme)").media !== "not all") { + supportDarkTheme = window.matchMedia("(prefers-color-scheme: dark)"); + } + if (self.settings.visibility.theme === "system") { + detect(self, supportDarkTheme); + } else { + set(self, self.settings.visibility.theme); + } +}; +const mainMethod = (self) => { + setTheme(self); + getLocale(self); + createDOM(self); + showMonth(self); + showYear(self); + controlArrows(self); + createTime(self); + if (self.currentType === "default" || self.currentType === "multiple") { + createWeek(self); + createDays(self); + } else if (self.currentType === "month") { + createMonths(self); + } else if (self.currentType === "year") { + createYears(self); + } +}; +const resetCalendar = (self) => { + setVariablesDates(self); + mainMethod(self); +}; +const updateCalendar = (self) => { + var _a; + let tempSelectedDates = null; + let tempSelectedMonth = null; + let tempSelectedYear = null; + if (!((_a = self.settings.selected.dates) == null ? void 0 : _a[0])) { + tempSelectedDates = self.settings.selected.dates; + self.settings.selected.dates = self.selectedDates; + } + if (!self.settings.selected.month) { + tempSelectedMonth = self.settings.selected.month; + self.settings.selected.month = self.selectedMonth; + } + if (!self.settings.selected.year) { + tempSelectedYear = self.settings.selected.year; + self.settings.selected.year = self.selectedYear; + } + setVariablesDates(self); + mainMethod(self); + self.settings.selected.dates = tempSelectedDates; + self.settings.selected.month = tempSelectedMonth; + self.settings.selected.year = tempSelectedYear; +}; +let currentSelf$1 = null; +const documentClickEvent = (e) => { + if (!currentSelf$1) + return; + if (e.target.closest(`.${currentSelf$1.CSSClasses.calendar}`)) + return; + document.querySelectorAll(`.${currentSelf$1.CSSClasses.calendar}`).forEach((calendar) => { + calendar.classList.add(currentSelf$1.CSSClasses.calendarHidden); + }); + document.removeEventListener("click", documentClickEvent, { capture: true }); +}; +const handlerInput = (self) => { + var _a; + if (!self || !self.input) + return; + currentSelf$1 = self; + (_a = self.HTMLInputElement) == null ? void 0 : _a.addEventListener("click", () => { + var _a2; + (_a2 = self.HTMLElement) == null ? void 0 : _a2.classList.remove(self.CSSClasses.calendarHidden); + document.addEventListener("click", documentClickEvent, { capture: true }); + }); +}; +const changeMonth = (self, route) => { + if (self.selectedMonth === void 0 || self.selectedYear === void 0) + return; + const jumpDate = new Date(self.selectedYear, self.selectedMonth, 1); + switch (route) { + case "prev": + jumpDate.setMonth(jumpDate.getMonth() - self.jumpMonths); + break; + case "next": + jumpDate.setMonth(jumpDate.getMonth() + self.jumpMonths); + break; + } + self.selectedMonth = jumpDate.getMonth(); + self.selectedYear = jumpDate.getFullYear(); + showMonth(self); + showYear(self); + controlArrows(self); + createDays(self); +}; +let currentSelf = null; +const removeHover = () => { + var _a; + if (!currentSelf) + return; + const daysEl = (_a = currentSelf.HTMLElement) == null ? void 0 : _a.querySelectorAll(`.${currentSelf.CSSClasses.dayBtnHover}`); + if (daysEl) + daysEl.forEach((d) => d.classList.remove(currentSelf.CSSClasses.dayBtnHover)); +}; +const addHover = (day) => { + var _a; + if (!currentSelf || !currentSelf.selectedDates) + return; + const date = generateDate(day); + if (currentSelf.rangeDisabled && currentSelf.rangeDisabled.includes(date)) + return; + const dayEls = (_a = currentSelf.HTMLElement) == null ? void 0 : _a.querySelectorAll(`[data-calendar-day="${date}"]`); + dayEls == null ? void 0 : dayEls.forEach((dayEl) => { + dayEl.classList.add(currentSelf.CSSClasses.dayBtnHover); + }); +}; +const hoverDaysEvent = (e) => { + if (!e.target || !currentSelf || !currentSelf.selectedDates) + return; + if (!e.target.closest(`.${currentSelf.CSSClasses.days}`)) { + removeHover(); + return; + } + const date = e.target.dataset.calendarDay; + if (!date) + return; + removeHover(); + const startDate = new Date( + (/* @__PURE__ */ new Date(`${currentSelf.selectedDates[0]}T00:00:00`)).getFullYear(), + (/* @__PURE__ */ new Date(`${currentSelf.selectedDates[0]}T00:00:00`)).getMonth(), + (/* @__PURE__ */ new Date(`${currentSelf.selectedDates[0]}T00:00:00`)).getDate() + ); + const endDate = new Date( + (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getFullYear(), + (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getMonth(), + (/* @__PURE__ */ new Date(`${date}T00:00:00`)).getDate() + ); + if (endDate > startDate) { + for (let i = startDate; i <= endDate; i.setDate(i.getDate() + 1)) { + addHover(i); + } + } else { + for (let i = startDate; i >= endDate; i.setDate(i.getDate() - 1)) { + addHover(i); + } + } +}; +const cancelSelectionDays = (e) => { + if (!currentSelf || e.key !== "Escape") + return; + currentSelf.selectedDates = []; + currentSelf.HTMLElement.removeEventListener("mousemove", hoverDaysEvent); + document.removeEventListener("keydown", cancelSelectionDays); + mainMethod(currentSelf); +}; +const setDisabledDates = () => { + var _a; + if (!currentSelf || !((_a = currentSelf.selectedDates) == null ? void 0 : _a[0]) || !currentSelf.rangeDisabled || currentSelf.rangeDisabled.length < 2) + return; + const selectedDate = /* @__PURE__ */ new Date(`${currentSelf.selectedDates[0]}T00:00:00`); + let startDate = null; + let endDate = null; + for (let index = 0; index < currentSelf.rangeDisabled.length; index++) { + const disabledDate = /* @__PURE__ */ new Date(`${currentSelf.rangeDisabled[index]}T00:00:00`); + if (selectedDate >= disabledDate) { + startDate = disabledDate; + } else { + endDate = disabledDate; + break; + } + } + if (startDate) { + startDate = new Date(startDate.setDate(startDate.getDate() + 1)); + currentSelf.rangeMin = generateDate(startDate); + } + if (endDate) { + endDate = new Date(endDate.setDate(endDate.getDate() - 1)); + currentSelf.rangeMax = generateDate(endDate); + } +}; +const resetDisabledDates = () => { + if (!currentSelf) + return; + currentSelf.rangeMin = currentSelf.settings.range.min; + currentSelf.rangeMax = currentSelf.settings.range.max; + if (currentSelf.settings.range.disablePast && /* @__PURE__ */ new Date(`${currentSelf.settings.range.min}T00:00:00`) < currentSelf.date.today) { + currentSelf.rangeMin = generateDate(currentSelf.date.today); + } +}; +const handlerMultipleRanged = (self) => { + if (!self || !self.selectedDates) + return; + currentSelf = self; + if (self.selectedDates[0] && self.selectedDates.length <= 1) { + self.HTMLElement.addEventListener("mousemove", hoverDaysEvent); + document.addEventListener("keydown", cancelSelectionDays); + if (self.settings.range.disableGaps) + setDisabledDates(); + } else { + self.HTMLElement.removeEventListener("mousemove", hoverDaysEvent); + document.removeEventListener("keydown", cancelSelectionDays); + if (self.settings.range.disableGaps) + resetDisabledDates(); + } +}; +const clickCalendar = (self) => { + self.HTMLElement.addEventListener("click", (e) => { + const element = e.target; + const arrowEl = element.closest(`.${self.CSSClasses.arrow}`); + const arrowPrevEl = element.closest(`.${self.CSSClasses.arrowPrev}`); + const arrowNextEl = element.closest(`.${self.CSSClasses.arrowNext}`); + const dayBtnEl = element.closest(`.${self.CSSClasses.dayBtn}`); + const dayBtnPrevEl = element.closest(`.${self.CSSClasses.dayBtnPrev}`); + const dayBtnNextEl = element.closest(`.${self.CSSClasses.dayBtnNext}`); + const weekNumberEl = element.closest(`.${self.CSSClasses.weekNumber}`); + const yearHeaderEl = element.closest(`.${self.CSSClasses.year}`); + const yearItemEl = element.closest(`.${self.CSSClasses.yearsYear}`); + const monthHeaderEl = element.closest(`.${self.CSSClasses.month}`); + const monthItemEl = element.closest(`.${self.CSSClasses.monthsMonth}`); + const clickArrowMonth = () => { + if (arrowEl && self.currentType !== "year" && self.currentType !== "month") { + changeMonth(self, element.dataset.calendarArrow); + } + if (arrowEl) { + if (self.actions.clickArrow) + self.actions.clickArrow(e, Number(self.selectedYear), Number(self.selectedMonth)); + } + }; + const clickDaySingle = () => { + if (!self.selectedDates || !dayBtnEl || !dayBtnEl.dataset.calendarDay) + return; + if (dayBtnEl.classList.contains(self.CSSClasses.dayBtnSelected)) { + self.selectedDates.splice(self.selectedDates.indexOf(dayBtnEl.dataset.calendarDay), 1); + } else { + self.selectedDates = []; + self.selectedDates.push(dayBtnEl.dataset.calendarDay); + } + }; + const clickDayMultiple = () => { + if (!self.selectedDates || !dayBtnEl || !dayBtnEl.dataset.calendarDay) + return; + if (dayBtnEl.classList.contains(self.CSSClasses.dayBtnSelected)) { + self.selectedDates.splice(self.selectedDates.indexOf(dayBtnEl.dataset.calendarDay), 1); + } else { + self.selectedDates.push(dayBtnEl.dataset.calendarDay); + } + }; + const clickDayMultipleRanged = () => { + if (!self.selectedDates || !dayBtnEl || !dayBtnEl.dataset.calendarDay) + return; + if (self.selectedDates.length <= 1 && self.selectedDates[0] && self.selectedDates[0].includes(dayBtnEl.dataset.calendarDay)) { + self.selectedDates = []; + } else { + if (self.selectedDates.length > 1) + self.selectedDates = []; + self.selectedDates.push(dayBtnEl.dataset.calendarDay); + } + if (self.selectedDates[1]) { + const startDate = new Date( + (/* @__PURE__ */ new Date(`${self.selectedDates[0]}T00:00:00`)).getFullYear(), + (/* @__PURE__ */ new Date(`${self.selectedDates[0]}T00:00:00`)).getMonth(), + (/* @__PURE__ */ new Date(`${self.selectedDates[0]}T00:00:00`)).getDate() + ); + const endDate = new Date( + (/* @__PURE__ */ new Date(`${self.selectedDates[1]}T00:00:00`)).getFullYear(), + (/* @__PURE__ */ new Date(`${self.selectedDates[1]}T00:00:00`)).getMonth(), + (/* @__PURE__ */ new Date(`${self.selectedDates[1]}T00:00:00`)).getDate() + ); + const addSelectedDate = (day) => { + if (!self.selectedDates) + return; + const date = generateDate(day); + if (self.rangeDisabled && self.rangeDisabled.includes(date)) + return; + self.selectedDates.push(date); + }; + self.selectedDates = []; + if (endDate > startDate) { + for (let i = startDate; i <= endDate; i.setDate(i.getDate() + 1)) { + addSelectedDate(i); + } + } else { + for (let i = startDate; i >= endDate; i.setDate(i.getDate() - 1)) { + addSelectedDate(i); + } + } + } + handlerMultipleRanged(self); + }; + const clickDay = () => { + if (self.settings.selection.day && ["single", "multiple", "multiple-ranged"].includes(self.settings.selection.day) && dayBtnEl) { + switch (self.settings.selection.day) { + case "single": + clickDaySingle(); + break; + case "multiple": + clickDayMultiple(); + break; + case "multiple-ranged": + clickDayMultipleRanged(); + break; + } + if (self.actions.clickDay) + self.actions.clickDay(e, self.selectedDates); + if (self.input && self.HTMLInputElement && self.actions.changeToInput) { + self.actions.changeToInput(e, self.HTMLInputElement, self.selectedDates, self.selectedTime, self.selectedHours, self.selectedMinutes, self.selectedKeeping); + } + if (dayBtnPrevEl) { + changeMonth(self, "prev"); + } else if (dayBtnNextEl) { + changeMonth(self, "next"); + } else { + createDays(self); + } + } + }; + const clickWeekNumber = () => { + var _a; + if (!self.settings.visibility.weekNumbers || !weekNumberEl || !self.actions.clickWeekNumber) + return; + const daysToWeeks = (_a = self.HTMLElement) == null ? void 0 : _a.querySelectorAll("[data-calendar-week-number]"); + if (!daysToWeeks) + return; + const weekNumberValue = Number(weekNumberEl.innerText); + const yearWeek = Number(weekNumberEl.dataset.calendarYearWeek); + const daysOfThisWeek = [...daysToWeeks].filter((day) => Number(day.dataset.calendarWeekNumber) === weekNumberValue); + self.actions.clickWeekNumber(e, weekNumberValue, daysOfThisWeek, yearWeek); + }; + const clickYear = () => { + if (!self.settings.selection.year || self.currentType === "multiple") + return; + if (arrowEl && self.currentType === "year") { + if (self.viewYear === void 0) + return; + if (arrowNextEl) { + self.viewYear += 15; + } else if (arrowPrevEl) { + self.viewYear -= 15; + } + createYears(self); + } else if (self.currentType !== "year" && yearHeaderEl) { + createYears(self); + } else if (self.currentType === "year" && yearHeaderEl) { + self.currentType = self.type; + mainMethod(self); + } else if (yearItemEl) { + if (self.selectedMonth === void 0 || !self.dateMin || !self.dateMax) + return; + self.selectedYear = Number(yearItemEl.dataset.calendarYear); + self.currentType = self.type; + if (self.selectedMonth < self.dateMin.getMonth() && self.selectedYear === self.dateMin.getFullYear()) { + self.selectedMonth = self.dateMin.getMonth(); + } + if (self.selectedMonth > self.dateMax.getMonth() && self.selectedYear === self.dateMax.getFullYear()) { + self.selectedMonth = self.dateMax.getMonth(); + } + if (self.actions.clickYear) + self.actions.clickYear(e, self.selectedYear); + mainMethod(self); + } + }; + const clickMonth = () => { + if (!self.settings.selection.month || self.currentType === "multiple") + return; + if (self.currentType !== "month" && monthHeaderEl) { + createMonths(self); + } else if (self.currentType === "month" && monthHeaderEl) { + self.currentType = self.type; + mainMethod(self); + } else if (monthItemEl) { + self.selectedMonth = Number(monthItemEl.dataset.calendarMonth); + self.currentType = self.type; + if (self.actions.clickMonth) + self.actions.clickMonth(e, self.selectedMonth); + mainMethod(self); + } + }; + clickArrowMonth(); + clickDay(); + clickWeekNumber(); + clickYear(); + clickMonth(); + }); +}; +const createCalendarToInput = (self) => { + if (!self.input || !self.HTMLElement || !self.HTMLElement.parentNode) + return; + self.HTMLInputElement = self.HTMLElement; + const wrapper = document.createElement("div"); + const calendar = document.createElement("div"); + wrapper.className = self.CSSClasses.calendarInputWrapper; + calendar.className = `${self.CSSClasses.calendar} ${self.CSSClasses.calendarToInput} ${self.CSSClasses.calendarHidden}`; + self.HTMLElement.parentNode.insertBefore(wrapper, self.HTMLInputElement); + wrapper.append(self.HTMLInputElement); + self.HTMLElement = calendar; + wrapper.append(self.HTMLElement); +}; +const initCalendar = (self) => { + if (!self.HTMLElement) + return; + createCalendarToInput(self); + resetCalendar(self); + handlerInput(self); + clickCalendar(self); +}; +const DOMDefault = (styles) => ` +
+ <#ArrowPrev /> +
+ <#Month /> + <#Year /> +
+ <#ArrowNext /> +
+
+ <#WeekNumbers /> +
+ <#Week /> + <#Days /> +
+
+ <#ControlTime /> +`; +const DOMMultiple = (styles) => ` +
+ <#ArrowPrev /> + <#ArrowNext /> +
+
+ <#Multiple> +
+
+
+ <#Month /> + <#Year /> +
+
+
+ <#WeekNumbers /> +
+ <#Week /> + <#Days /> +
+
+
+ <#/Multiple> +
+ <#ControlTime /> +`; +const DOMMonths = (styles) => ` +
+
+ <#Month /> + <#Year /> +
+
+
+
+ <#Months /> +
+
+`; +const DOMYears = (styles) => ` +
+ <#ArrowPrev /> +
+ <#Month /> + <#Year /> +
+ <#ArrowNext /> +
+
+
+ <#Years /> +
+
+`; +const classes = { + 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 VanillaCalendar { + constructor(selector, option) { + __publicField(this, "HTMLElement"); + __publicField(this, "input"); + __publicField(this, "type"); + __publicField(this, "months"); + __publicField(this, "jumpMonths"); + __publicField(this, "date"); + __publicField(this, "settings"); + __publicField(this, "locale"); + __publicField(this, "actions"); + __publicField(this, "popups"); + __publicField(this, "CSSClasses"); + __publicField(this, "DOMTemplates"); + __publicField(this, "currentType"); + __publicField(this, "reset", () => resetCalendar(this)); + __publicField(this, "update", () => updateCalendar(this)); + __publicField(this, "init", () => initCalendar(this)); + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb; + this.HTMLElement = typeof selector === "string" ? document.querySelector(selector) : selector; + if (!this.HTMLElement) + return; + this.input = (_a = option == null ? void 0 : option.input) != null ? _a : false; + this.type = (_b = option == null ? void 0 : option.type) != null ? _b : "default"; + this.months = (_c = option == null ? void 0 : option.months) != null ? _c : 2; + this.jumpMonths = (_d = option == null ? void 0 : option.jumpMonths) != null ? _d : 1; + this.date = { + min: (_f = (_e = option == null ? void 0 : option.date) == null ? void 0 : _e.min) != null ? _f : "1970-01-01", + max: (_h = (_g = option == null ? void 0 : option.date) == null ? void 0 : _g.max) != null ? _h : "2470-12-31", + today: (_j = (_i = option == null ? void 0 : option.date) == null ? void 0 : _i.today) != null ? _j : /* @__PURE__ */ new Date() + }; + this.settings = { + lang: (_l = (_k = option == null ? void 0 : option.settings) == null ? void 0 : _k.lang) != null ? _l : "en", + iso8601: (_n = (_m = option == null ? void 0 : option.settings) == null ? void 0 : _m.iso8601) != null ? _n : true, + range: { + min: (_q = (_p = (_o = option == null ? void 0 : option.settings) == null ? void 0 : _o.range) == null ? void 0 : _p.min) != null ? _q : this.date.min, + max: (_t = (_s = (_r = option == null ? void 0 : option.settings) == null ? void 0 : _r.range) == null ? void 0 : _s.max) != null ? _t : this.date.max, + disablePast: (_w = (_v = (_u = option == null ? void 0 : option.settings) == null ? void 0 : _u.range) == null ? void 0 : _v.disablePast) != null ? _w : false, + disableGaps: (_z = (_y = (_x = option == null ? void 0 : option.settings) == null ? void 0 : _x.range) == null ? void 0 : _y.disableGaps) != null ? _z : false, + disableAllDays: (_C = (_B = (_A = option == null ? void 0 : option.settings) == null ? void 0 : _A.range) == null ? void 0 : _B.disableAllDays) != null ? _C : false, + disableWeekday: (_F = (_E = (_D = option == null ? void 0 : option.settings) == null ? void 0 : _D.range) == null ? void 0 : _E.disableWeekday) != null ? _F : null, + disabled: (_I = (_H = (_G = option == null ? void 0 : option.settings) == null ? void 0 : _G.range) == null ? void 0 : _H.disabled) != null ? _I : null, + enabled: (_L = (_K = (_J = option == null ? void 0 : option.settings) == null ? void 0 : _J.range) == null ? void 0 : _K.enabled) != null ? _L : null + }, + selection: { + day: (_O = (_N = (_M = option == null ? void 0 : option.settings) == null ? void 0 : _M.selection) == null ? void 0 : _N.day) != null ? _O : "single", + month: (_R = (_Q = (_P = option == null ? void 0 : option.settings) == null ? void 0 : _P.selection) == null ? void 0 : _Q.month) != null ? _R : true, + year: (_U = (_T = (_S = option == null ? void 0 : option.settings) == null ? void 0 : _S.selection) == null ? void 0 : _T.year) != null ? _U : true, + time: (_X = (_W = (_V = option == null ? void 0 : option.settings) == null ? void 0 : _V.selection) == null ? void 0 : _W.time) != null ? _X : false, + controlTime: (__ = (_Z = (_Y = option == null ? void 0 : option.settings) == null ? void 0 : _Y.selection) == null ? void 0 : _Z.controlTime) != null ? __ : "all", + stepHours: (_ba = (_aa = (_$ = option == null ? void 0 : option.settings) == null ? void 0 : _$.selection) == null ? void 0 : _aa.stepHours) != null ? _ba : 1, + stepMinutes: (_ea = (_da = (_ca = option == null ? void 0 : option.settings) == null ? void 0 : _ca.selection) == null ? void 0 : _da.stepMinutes) != null ? _ea : 1 + }, + selected: { + dates: (_ha = (_ga = (_fa = option == null ? void 0 : option.settings) == null ? void 0 : _fa.selected) == null ? void 0 : _ga.dates) != null ? _ha : null, + month: (_ka = (_ja = (_ia = option == null ? void 0 : option.settings) == null ? void 0 : _ia.selected) == null ? void 0 : _ja.month) != null ? _ka : null, + year: (_na = (_ma = (_la = option == null ? void 0 : option.settings) == null ? void 0 : _la.selected) == null ? void 0 : _ma.year) != null ? _na : null, + holidays: (_qa = (_pa = (_oa = option == null ? void 0 : option.settings) == null ? void 0 : _oa.selected) == null ? void 0 : _pa.holidays) != null ? _qa : null, + time: (_ta = (_sa = (_ra = option == null ? void 0 : option.settings) == null ? void 0 : _ra.selected) == null ? void 0 : _sa.time) != null ? _ta : null + }, + visibility: { + theme: (_wa = (_va = (_ua = option == null ? void 0 : option.settings) == null ? void 0 : _ua.visibility) == null ? void 0 : _va.theme) != null ? _wa : "system", + themeDetect: (_za = (_ya = (_xa = option == null ? void 0 : option.settings) == null ? void 0 : _xa.visibility) == null ? void 0 : _ya.themeDetect) != null ? _za : "html[data-theme]", + monthShort: (_Ca = (_Ba = (_Aa = option == null ? void 0 : option.settings) == null ? void 0 : _Aa.visibility) == null ? void 0 : _Ba.monthShort) != null ? _Ca : true, + weekNumbers: (_Fa = (_Ea = (_Da = option == null ? void 0 : option.settings) == null ? void 0 : _Da.visibility) == null ? void 0 : _Ea.weekNumbers) != null ? _Fa : false, + weekend: (_Ia = (_Ha = (_Ga = option == null ? void 0 : option.settings) == null ? void 0 : _Ga.visibility) == null ? void 0 : _Ha.weekend) != null ? _Ia : true, + today: (_La = (_Ka = (_Ja = option == null ? void 0 : option.settings) == null ? void 0 : _Ja.visibility) == null ? void 0 : _Ka.today) != null ? _La : true, + disabled: (_Oa = (_Na = (_Ma = option == null ? void 0 : option.settings) == null ? void 0 : _Ma.visibility) == null ? void 0 : _Na.disabled) != null ? _Oa : false, + daysOutside: (_Ra = (_Qa = (_Pa = option == null ? void 0 : option.settings) == null ? void 0 : _Pa.visibility) == null ? void 0 : _Qa.daysOutside) != null ? _Ra : true + } + }; + this.locale = { + months: (_Ta = (_Sa = option == null ? void 0 : option.locale) == null ? void 0 : _Sa.months) != null ? _Ta : [], + weekday: (_Va = (_Ua = option == null ? void 0 : option.locale) == null ? void 0 : _Ua.weekday) != null ? _Va : [] + }; + this.actions = { + clickDay: (_Xa = (_Wa = option == null ? void 0 : option.actions) == null ? void 0 : _Wa.clickDay) != null ? _Xa : null, + clickWeekNumber: (_Za = (_Ya = option == null ? void 0 : option.actions) == null ? void 0 : _Ya.clickWeekNumber) != null ? _Za : null, + clickMonth: (_$a = (__a = option == null ? void 0 : option.actions) == null ? void 0 : __a.clickMonth) != null ? _$a : null, + clickYear: (_bb = (_ab = option == null ? void 0 : option.actions) == null ? void 0 : _ab.clickYear) != null ? _bb : null, + clickArrow: (_db = (_cb = option == null ? void 0 : option.actions) == null ? void 0 : _cb.clickArrow) != null ? _db : null, + changeTime: (_fb = (_eb = option == null ? void 0 : option.actions) == null ? void 0 : _eb.changeTime) != null ? _fb : null, + changeToInput: (_hb = (_gb = option == null ? void 0 : option.actions) == null ? void 0 : _gb.changeToInput) != null ? _hb : null, + getDays: (_jb = (_ib = option == null ? void 0 : option.actions) == null ? void 0 : _ib.getDays) != null ? _jb : null + }; + this.popups = (_kb = option == null ? void 0 : option.popups) != null ? _kb : null; + this.CSSClasses = (() => { + const classesObj = __spreadValues({}, classes); + Object.keys(classes).forEach((className) => { + var _a2; + if ((_a2 = option == null ? void 0 : option.CSSClasses) == null ? void 0 : _a2[className]) { + classesObj[className] = option.CSSClasses[className]; + } else { + classesObj[className] = classes[className]; + } + }); + return classesObj; + })(); + this.DOMTemplates = { + default: (_mb = (_lb = option == null ? void 0 : option.DOMTemplates) == null ? void 0 : _lb.default) != null ? _mb : DOMDefault(this.CSSClasses), + multiple: (_ob = (_nb = option == null ? void 0 : option.DOMTemplates) == null ? void 0 : _nb.multiple) != null ? _ob : DOMMultiple(this.CSSClasses), + month: (_qb = (_pb = option == null ? void 0 : option.DOMTemplates) == null ? void 0 : _pb.month) != null ? _qb : DOMMonths(this.CSSClasses), + year: (_sb = (_rb = option == null ? void 0 : option.DOMTemplates) == null ? void 0 : _rb.year) != null ? _sb : DOMYears(this.CSSClasses) + }; + this.currentType = this.type; + } +} +export { + VanillaCalendar as default +}; diff --git a/package/package.json b/package/package.json index 0a9fff2e..9843d044 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "@uvarov.frontend/vanilla-calendar", - "version": "2.6.1", + "version": "2.6.2", "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": [ @@ -32,8 +32,9 @@ }, "license": "MIT", "main": "./build/vanilla-calendar.min.js", + "module": "./build/vanilla-calendar.min.mjs", + "source": "./src/scripts/vanilla-calendar.ts", "style": "./build/vanilla-calendar.min.css", - "source": "./src/scripts/main.ts", "types": "./src/index.d.ts", "devDependencies": {}, "dependencies": {} diff --git a/package/src/scripts/main.ts b/package/src/scripts/vanilla-calendar.ts similarity index 100% rename from package/src/scripts/main.ts rename to package/src/scripts/vanilla-calendar.ts diff --git a/package/src/vanilla-calendar.ts b/package/src/vanilla-calendar.ts deleted file mode 100644 index 969abe8c..00000000 --- a/package/src/vanilla-calendar.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable import/no-import-module-exports */ -import VanillaCalendar from './scripts/main'; -import './styles/vanilla-calendar.css'; - -if (typeof window !== 'undefined') { - (window as { VanillaCalendar?: object }).VanillaCalendar = VanillaCalendar; -} -if (typeof exports === 'object' && typeof module === 'object') { - module.exports = VanillaCalendar; -}