// Theme initialization to prevent flash (function() { const savedTheme = localStorage.getItem('theme'); if (savedTheme !== 'light') { document.documentElement.classList.add('dark-theme'); } })(); /* flatpickr v4.6.13,, @license MIT */ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).flatpickr=n()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var n,t=1,a=arguments.length;t",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},i={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var n=e%100;if(n>3&&n<21)return"th";switch(n%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},o=function(e,n){return void 0===n&&(n=2),("000"+e).slice(-1*n)},r=function(e){return!0===e?1:0};function l(e,n){var t;return function(){var a=this,i=arguments;clearTimeout(t),t=setTimeout((function(){return e.apply(a,i)}),n)}}var c=function(e){return e instanceof Array?e:[e]};function s(e,n,t){if(!0===t)return e.classList.add(n);e.classList.remove(n)}function d(e,n,t){var a=window.document.createElement(e);return n=n||"",t=t||"",a.className=n,void 0!==t&&(a.textContent=t),a}function u(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function f(e,n){return n(e)?e:e.parentNode?f(e.parentNode,n):void 0}function m(e,n){var t=d("div","numInputWrapper"),a=d("input","numInput "+e),i=d("span","arrowUp"),o=d("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?a.type="number":(a.type="text",a.pattern="\\d*"),void 0!==n)for(var r in n)a.setAttribute(r,n[r]);return t.appendChild(a),t.appendChild(i),t.appendChild(o),t}function g(e){try{return"function"==typeof e.composedPath?e.composedPath()[0]:e.target}catch(n){return e.target}}var p=function(){},h=function(e,n,t){return t.months[n?"shorthand":"longhand"][e]},v={D:p,F:function(e,n,t){e.setMonth(t.months.longhand.indexOf(n))},G:function(e,n){e.setHours((e.getHours()>=12?12:0)+parseFloat(n))},H:function(e,n){e.setHours(parseFloat(n))},J:function(e,n){e.setDate(parseFloat(n))},K:function(e,n,t){e.setHours(e.getHours()%12+12*r(new RegExp(t.amPM[1],"i").test(n)))},M:function(e,n,t){e.setMonth(t.months.shorthand.indexOf(n))},S:function(e,n){e.setSeconds(parseFloat(n))},U:function(e,n){return new Date(1e3*parseFloat(n))},W:function(e,n,t){var a=parseInt(n),i=new Date(e.getFullYear(),0,2+7*(a-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+t.firstDayOfWeek),i},Y:function(e,n){e.setFullYear(parseFloat(n))},Z:function(e,n){return new Date(n)},d:function(e,n){e.setDate(parseFloat(n))},h:function(e,n){e.setHours((e.getHours()>=12?12:0)+parseFloat(n))},i:function(e,n){e.setMinutes(parseFloat(n))},j:function(e,n){e.setDate(parseFloat(n))},l:p,m:function(e,n){e.setMonth(parseFloat(n)-1)},n:function(e,n){e.setMonth(parseFloat(n)-1)},s:function(e,n){e.setSeconds(parseFloat(n))},u:function(e,n){return new Date(parseFloat(n))},w:p,y:function(e,n){e.setFullYear(2e3+parseFloat(n))}},D={D:"",F:"",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},w={Z:function(e){return e.toISOString()},D:function(e,n,t){return n.weekdays.shorthand[w.w(e,n,t)]},F:function(e,n,t){return h(w.n(e,n,t)-1,!1,n)},G:function(e,n,t){return o(w.h(e,n,t))},H:function(e){return o(e.getHours())},J:function(e,n){return void 0!==n.ordinal?e.getDate()+n.ordinal(e.getDate()):e.getDate()},K:function(e,n){return n.amPM[r(e.getHours()>11)]},M:function(e,n){return h(e.getMonth(),!0,n)},S:function(e){return o(e.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,n,t){return t.getWeek(e)},Y:function(e){return o(e.getFullYear(),4)},d:function(e){return o(e.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(e){return o(e.getMinutes())},j:function(e){return e.getDate()},l:function(e,n){return n.weekdays.longhand[e.getDay()]},m:function(e){return o(e.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},u:function(e){return e.getTime()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},b=function(e){var n=e.config,t=void 0===n?a:n,o=e.l10n,r=void 0===o?i:o,l=e.isMobile,c=void 0!==l&&l;return function(e,n,a){var i=a||r;return void 0===t.formatDate||c?n.split("").map((function(n,a,o){return w[n]&&"\\"!==o[a-1]?w[n](e,i,t):"\\"!==n?n:""})).join(""):t.formatDate(e,n,i)}},C=function(e){var n=e.config,t=void 0===n?a:n,o=e.l10n,r=void 0===o?i:o;return function(e,n,i,o){if(0===e||e){var l,c=o||r,s=e;if(e instanceof Date)l=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)l=new Date(e);else if("string"==typeof e){var d=n||(t||a).dateFormat,u=String(e).trim();if("today"===u)l=new Date,i=!0;else if(t&&t.parseDate)l=t.parseDate(e,d);else if(/Z$/.test(u)||/GMT$/.test(u))l=new Date(e);else{for(var f=void 0,m=[],g=0,p=0,h="";g=0?new Date:new Date(w.config.minDate.getTime()),t=E(w.config);n.setHours(t.hours,t.minutes,t.seconds,n.getMilliseconds()),w.selectedDates=[n],w.latestSelectedDateObj=n}void 0!==e&&"blur"!==e.type&&function(e){e.preventDefault();var n="keydown"===e.type,t=g(e),a=t;void 0!==w.amPM&&t===w.amPM&&(w.amPM.textContent=w.l10n.amPM[r(w.amPM.textContent===w.l10n.amPM[0])]);var i=parseFloat(a.getAttribute("min")),l=parseFloat(a.getAttribute("max")),c=parseFloat(a.getAttribute("step")),s=parseInt(a.value,10),d=e.delta||(n?38===e.which?1:-1:0),u=s+c*d;if(void 0!==a.value&&2===a.value.length){var f=a===w.hourElement,m=a===w.minuteElement;ul&&(u=a===w.hourElement?u-l-r(!w.amPM):i,m&&L(void 0,1,w.hourElement)),w.amPM&&f&&(1===c?u+s===23:Math.abs(u-s)>c)&&(w.amPM.textContent=w.l10n.amPM[r(w.amPM.textContent===w.l10n.amPM[0])]),a.value=o(u)}}(e);var a=w._input.value;O(),ye(),w._input.value!==a&&w._debouncedChange()}function O(){if(void 0!==w.hourElement&&void 0!==w.minuteElement){var e,n,t=(parseInt(w.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(w.minuteElement.value,10)||0)%60,i=void 0!==w.secondElement?(parseInt(w.secondElement.value,10)||0)%60:0;void 0!==w.amPM&&(e=t,n=w.amPM.textContent,t=e%12+12*r(n===w.l10n.amPM[1]));var o=void 0!==w.config.minTime||w.config.minDate&&w.minDateHasTime&&w.latestSelectedDateObj&&0===M(w.latestSelectedDateObj,w.config.minDate,!0),l=void 0!==w.config.maxTime||w.config.maxDate&&w.maxDateHasTime&&w.latestSelectedDateObj&&0===M(w.latestSelectedDateObj,w.config.maxDate,!0);if(void 0!==w.config.maxTime&&void 0!==w.config.minTime&&w.config.minTime>w.config.maxTime){var c=y(w.config.minTime.getHours(),w.config.minTime.getMinutes(),w.config.minTime.getSeconds()),s=y(w.config.maxTime.getHours(),w.config.maxTime.getMinutes(),w.config.maxTime.getSeconds()),d=y(t,a,i);if(d>s&&d=12)]),void 0!==w.secondElement&&(w.secondElement.value=o(t)))}function N(e){var n=g(e),t=parseInt(n.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&ee(t)}function P(e,n,t,a){return n instanceof Array?n.forEach((function(n){return P(e,n,t,a)})):e instanceof Array?e.forEach((function(e){return P(e,n,t,a)})):(e.addEventListener(n,t,a),void w._handlers.push({remove:function(){return e.removeEventListener(n,t,a)}}))}function Y(){De("onChange")}function j(e,n){var t=void 0!==e?w.parseDate(e):w.latestSelectedDateObj||(w.config.minDate&&w.config.minDate>w.now?w.config.minDate:w.config.maxDate&&w.config.maxDate=0&&M(e,w.selectedDates[1])<=0)}(n)&&!be(n)&&o.classList.add("inRange"),w.weekNumbers&&1===w.config.showMonths&&"prevMonthDay"!==e&&a%7==6&&w.weekNumbers.insertAdjacentHTML("beforeend",""+w.config.getWeek(n)+""),De("onDayCreate",o),o}function W(e){e.focus(),"range"===w.config.mode&&oe(e)}function B(e){for(var n=e>0?0:w.config.showMonths-1,t=e>0?w.config.showMonths:-1,a=n;a!=t;a+=e)for(var i=w.daysContainer.children[a],o=e>0?0:i.children.length-1,r=e>0?i.children.length:-1,l=o;l!=r;l+=e){var c=i.children[l];if(-1===c.className.indexOf("hidden")&&ne(c.dateObj))return c}}function J(e,n){var t=k(),a=te(t||document.body),i=void 0!==e?e:a?t:void 0!==w.selectedDateElem&&te(w.selectedDateElem)?w.selectedDateElem:void 0!==w.todayDateElem&&te(w.todayDateElem)?w.todayDateElem:B(n>0?1:-1);void 0===i?w._input.focus():a?function(e,n){for(var t=-1===e.className.indexOf("Month")?e.dateObj.getMonth():w.currentMonth,a=n>0?w.config.showMonths:-1,i=n>0?1:-1,o=t-w.currentMonth;o!=a;o+=i)for(var r=w.daysContainer.children[o],l=t-w.currentMonth===o?e.$i+n:n<0?r.children.length-1:0,c=r.children.length,s=l;s>=0&&s0?c:-1);s+=i){var d=r.children[s];if(-1===d.className.indexOf("hidden")&&ne(d.dateObj)&&Math.abs(e.$i-s)>=Math.abs(n))return W(d)}w.changeMonth(i),J(B(i),0)}(i,n):W(i)}function K(e,n){for(var t=(new Date(e,n,1).getDay()-w.l10n.firstDayOfWeek+7)%7,a=w.utils.getDaysInMonth((n-1+12)%12,e),i=w.utils.getDaysInMonth(n,e),o=window.document.createDocumentFragment(),r=w.config.showMonths>1,l=r?"prevMonthDay hidden":"prevMonthDay",c=r?"nextMonthDay hidden":"nextMonthDay",s=a+1-t,u=0;s<=a;s++,u++)o.appendChild(R("flatpickr-day "+l,new Date(e,n-1,s),0,u));for(s=1;s<=i;s++,u++)o.appendChild(R("flatpickr-day",new Date(e,n,s),0,u));for(var f=i+1;f<=42-t&&(1===w.config.showMonths||u%7!=0);f++,u++)o.appendChild(R("flatpickr-day "+c,new Date(e,n+1,f%i),0,u));var m=d("div","dayContainer");return m.appendChild(o),m}function U(){if(void 0!==w.daysContainer){u(w.daysContainer),w.weekNumbers&&u(w.weekNumbers);for(var e=document.createDocumentFragment(),n=0;n1||"dropdown"!==w.config.monthSelectorType)){var e=function(e){return!(void 0!==w.config.minDate&&w.currentYear===w.config.minDate.getFullYear()&&ew.config.maxDate.getMonth())};w.monthsDropdownContainer.tabIndex=-1,w.monthsDropdownContainer.innerHTML="";for(var n=0;n<12;n++)if(e(n)){var t=d("option","flatpickr-monthDropdown-month");t.value=new Date(w.currentYear,n).getMonth().toString(),t.textContent=h(n,w.config.shorthandCurrentMonth,w.l10n),t.tabIndex=-1,w.currentMonth===n&&(t.selected=!0),w.monthsDropdownContainer.appendChild(t)}}}function $(){var e,n=d("div","flatpickr-month"),t=window.document.createDocumentFragment();w.config.showMonths>1||"static"===w.config.monthSelectorType?e=d("span","cur-month"):(w.monthsDropdownContainer=d("select","flatpickr-monthDropdown-months"),w.monthsDropdownContainer.setAttribute("aria-label",w.l10n.monthAriaLabel),P(w.monthsDropdownContainer,"change",(function(e){var n=g(e),t=parseInt(n.value,10);w.changeMonth(t-w.currentMonth),De("onMonthChange")})),q(),e=w.monthsDropdownContainer);var a=m("cur-year",{tabindex:"-1"}),i=a.getElementsByTagName("input")[0];i.setAttribute("aria-label",w.l10n.yearAriaLabel),w.config.minDate&&i.setAttribute("min",w.config.minDate.getFullYear().toString()),w.config.maxDate&&(i.setAttribute("max",w.config.maxDate.getFullYear().toString()),i.disabled=!!w.config.minDate&&w.config.minDate.getFullYear()===w.config.maxDate.getFullYear());var o=d("div","flatpickr-current-month");return o.appendChild(e),o.appendChild(a),t.appendChild(o),n.appendChild(t),{container:n,yearElement:i,monthElement:e}}function V(){u(w.monthNav),w.monthNav.appendChild(w.prevMonthNav),w.config.showMonths&&(w.yearElements=[],w.monthElements=[]);for(var e=w.config.showMonths;e--;){var n=$();w.yearElements.push(n.yearElement),w.monthElements.push(n.monthElement),w.monthNav.appendChild(n.container)}w.monthNav.appendChild(w.nextMonthNav)}function z(){w.weekdayContainer?u(w.weekdayContainer):w.weekdayContainer=d("div","flatpickr-weekdays");for(var e=w.config.showMonths;e--;){var n=d("div","flatpickr-weekdaycontainer");w.weekdayContainer.appendChild(n)}return G(),w.weekdayContainer}function G(){if(w.weekdayContainer){var e=w.l10n.firstDayOfWeek,t=n(w.l10n.weekdays.shorthand);e>0&&e\n "+t.join("")+"\n \n "}}function Z(e,n){void 0===n&&(n=!0);var t=n?e:e-w.currentMonth;t<0&&!0===w._hidePrevMonthArrow||t>0&&!0===w._hideNextMonthArrow||(w.currentMonth+=t,(w.currentMonth<0||w.currentMonth>11)&&(w.currentYear+=w.currentMonth>11?1:-1,w.currentMonth=(w.currentMonth+12)%12,De("onYearChange"),q()),U(),De("onMonthChange"),Ce())}function Q(e){return w.calendarContainer.contains(e)}function X(e){if(w.isOpen&&!w.config.inline){var n=g(e),t=Q(n),a=!(n===w.input||n===w.altInput||w.element.contains(n)||e.path&&e.path.indexOf&&(~e.path.indexOf(w.input)||~e.path.indexOf(w.altInput)))&&!t&&!Q(e.relatedTarget),i=!w.config.ignoredFocusElements.some((function(e){return e.contains(n)}));a&&i&&(w.config.allowInput&&w.setDate(w._input.value,!1,w.config.altInput?w.config.altFormat:w.config.dateFormat),void 0!==w.timeContainer&&void 0!==w.minuteElement&&void 0!==w.hourElement&&""!==w.input.value&&void 0!==w.input.value&&_(),w.close(),w.config&&"range"===w.config.mode&&1===w.selectedDates.length&&w.clear(!1))}}function ee(e){if(!(!e||w.config.minDate&&ew.config.maxDate.getFullYear())){var n=e,t=w.currentYear!==n;w.currentYear=n||w.currentYear,w.config.maxDate&&w.currentYear===w.config.maxDate.getFullYear()?w.currentMonth=Math.min(w.config.maxDate.getMonth(),w.currentMonth):w.config.minDate&&w.currentYear===w.config.minDate.getFullYear()&&(w.currentMonth=Math.max(w.config.minDate.getMonth(),w.currentMonth)),t&&(w.redraw(),De("onYearChange"),q())}}function ne(e,n){var t;void 0===n&&(n=!0);var a=w.parseDate(e,void 0,n);if(w.config.minDate&&a&&M(a,w.config.minDate,void 0!==n?n:!w.minDateHasTime)<0||w.config.maxDate&&a&&M(a,w.config.maxDate,void 0!==n?n:!w.maxDateHasTime)>0)return!1;if(!w.config.enable&&0===w.config.disable.length)return!0;if(void 0===a)return!1;for(var i=!!w.config.enable,o=null!==(t=w.config.enable)&&void 0!==t?t:w.config.disable,r=0,l=void 0;r=l.from.getTime()&&a.getTime()<=l.to.getTime())return i}return!i}function te(e){return void 0!==w.daysContainer&&(-1===e.className.indexOf("hidden")&&-1===e.className.indexOf("flatpickr-disabled")&&w.daysContainer.contains(e))}function ae(e){var n=e.target===w._input,t=w._input.value.trimEnd()!==Me();!n||!t||e.relatedTarget&&Q(e.relatedTarget)||w.setDate(w._input.value,!0,e.target===w.altInput?w.config.altFormat:w.config.dateFormat)}function ie(e){var n=g(e),t=w.config.wrap?p.contains(n):n===w._input,a=w.config.allowInput,i=w.isOpen&&(!a||!t),o=w.config.inline&&t&&!a;if(13===e.keyCode&&t){if(a)return w.setDate(w._input.value,!0,n===w.altInput?w.config.altFormat:w.config.dateFormat),w.close(),n.blur();w.open()}else if(Q(n)||i||o){var r=!!w.timeContainer&&w.timeContainer.contains(n);switch(e.keyCode){case 13:r?(e.preventDefault(),_(),fe()):me(e);break;case 27:e.preventDefault(),fe();break;case 8:case 46:t&&!w.config.allowInput&&(e.preventDefault(),w.clear());break;case 37:case 39:if(r||t)w.hourElement&&w.hourElement.focus();else{e.preventDefault();var l=k();if(void 0!==w.daysContainer&&(!1===a||l&&te(l))){var c=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),Z(c),J(B(1),0)):J(void 0,c)}}break;case 38:case 40:e.preventDefault();var s=40===e.keyCode?1:-1;w.daysContainer&&void 0!==n.$i||n===w.input||n===w.altInput?e.ctrlKey?(e.stopPropagation(),ee(w.currentYear-s),J(B(1),0)):r||J(void 0,7*s):n===w.currentYearElement?ee(w.currentYear-s):w.config.enableTime&&(!r&&w.hourElement&&w.hourElement.focus(),_(e),w._debouncedChange());break;case 9:if(r){var d=[w.hourElement,w.minuteElement,w.secondElement,w.amPM].concat(w.pluginElements).filter((function(e){return e})),u=d.indexOf(n);if(-1!==u){var f=d[u+(e.shiftKey?-1:1)];e.preventDefault(),(f||w._input).focus()}}else!w.config.noCalendar&&w.daysContainer&&w.daysContainer.contains(n)&&e.shiftKey&&(e.preventDefault(),w._input.focus())}}if(void 0!==w.amPM&&n===w.amPM)switch(e.key){case w.l10n.amPM[0].charAt(0):case w.l10n.amPM[0].charAt(0).toLowerCase():w.amPM.textContent=w.l10n.amPM[0],O(),ye();break;case w.l10n.amPM[1].charAt(0):case w.l10n.amPM[1].charAt(0).toLowerCase():w.amPM.textContent=w.l10n.amPM[1],O(),ye()}(t||Q(n))&&De("onKeyDown",e)}function oe(e,n){if(void 0===n&&(n="flatpickr-day"),1===w.selectedDates.length&&(!e||e.classList.contains(n)&&!e.classList.contains("flatpickr-disabled"))){for(var t=e?e.dateObj.getTime():w.days.firstElementChild.dateObj.getTime(),a=w.parseDate(w.selectedDates[0],void 0,!0).getTime(),i=Math.min(t,w.selectedDates[0].getTime()),o=Math.max(t,w.selectedDates[0].getTime()),r=!1,l=0,c=0,s=i;si&&sl)?l=s:s>a&&(!c||s ."+n)).forEach((function(n){var i,o,s,d=n.dateObj.getTime(),u=l>0&&d0&&d>c;if(u)return n.classList.add("notAllowed"),void["inRange","startRange","endRange"].forEach((function(e){n.classList.remove(e)}));r&&!u||(["startRange","inRange","endRange","notAllowed"].forEach((function(e){n.classList.remove(e)})),void 0!==e&&(e.classList.add(t<=w.selectedDates[0].getTime()?"startRange":"endRange"),at&&d===a&&n.classList.add("endRange"),d>=l&&(0===c||d<=c)&&(o=a,s=t,(i=d)>Math.min(o,s)&&i0||t.getMinutes()>0||t.getSeconds()>0),w.selectedDates&&(w.selectedDates=w.selectedDates.filter((function(e){return ne(e)})),w.selectedDates.length||"min"!==e||F(t),ye()),w.daysContainer&&(ue(),void 0!==t?w.currentYearElement[e]=t.getFullYear().toString():w.currentYearElement.removeAttribute(e),w.currentYearElement.disabled=!!a&&void 0!==t&&a.getFullYear()===t.getFullYear())}}function ce(){return w.config.wrap?p.querySelector("[data-input]"):p}function se(){"object"!=typeof w.config.locale&&void 0===I.l10ns[w.config.locale]&&w.config.errorHandler(new Error("flatpickr: invalid locale "+w.config.locale)),w.l10n=e(e({},I.l10ns.default),"object"==typeof w.config.locale?w.config.locale:"default"!==w.config.locale?I.l10ns[w.config.locale]:void 0),D.D="("+w.l10n.weekdays.shorthand.join("|")+")",D.l="("+w.l10n.weekdays.longhand.join("|")+")",D.M="("+w.l10n.months.shorthand.join("|")+")",D.F="("+w.l10n.months.longhand.join("|")+")",D.K="("+w.l10n.amPM[0]+"|"+w.l10n.amPM[1]+"|"+w.l10n.amPM[0].toLowerCase()+"|"+w.l10n.amPM[1].toLowerCase()+")",void 0===e(e({},v),JSON.parse(JSON.stringify(p.dataset||{}))).time_24hr&&void 0===I.defaultConfig.time_24hr&&(w.config.time_24hr=w.l10n.time_24hr),w.formatDate=b(w),w.parseDate=C({config:w.config,l10n:w.l10n})}function de(e){if("function"!=typeof w.config.position){if(void 0!==w.calendarContainer){De("onPreCalendarPosition");var n=e||w._positionElement,t=Array.prototype.reduce.call(w.calendarContainer.children,(function(e,n){return e+n.offsetHeight}),0),a=w.calendarContainer.offsetWidth,i=w.config.position.split(" "),o=i[0],r=i.length>1?i[1]:null,l=n.getBoundingClientRect(),c=window.innerHeight-l.bottom,d="above"===o||"below"!==o&&ct,u=window.pageYOffset+l.top+(d?-t-2:n.offsetHeight+2);if(s(w.calendarContainer,"arrowTop",!d),s(w.calendarContainer,"arrowBottom",d),!w.config.inline){var f=window.pageXOffset+l.left,m=!1,g=!1;"center"===r?(f-=(a-l.width)/2,m=!0):"right"===r&&(f-=a-l.width,g=!0),s(w.calendarContainer,"arrowLeft",!m&&!g),s(w.calendarContainer,"arrowCenter",m),s(w.calendarContainer,"arrowRight",g);var p=window.document.body.offsetWidth-(window.pageXOffset+l.right),h=f+a>window.document.body.offsetWidth,v=p+a>window.document.body.offsetWidth;if(s(w.calendarContainer,"rightMost",h),!w.config.static)if(w.calendarContainer.style.top=u+"px",h)if(v){var D=function(){for(var e=null,n=0;nw.currentMonth+w.config.showMonths-1)&&"range"!==w.config.mode;if(w.selectedDateElem=t,"single"===w.config.mode)w.selectedDates=[a];else if("multiple"===w.config.mode){var o=be(a);o?w.selectedDates.splice(parseInt(o),1):w.selectedDates.push(a)}else"range"===w.config.mode&&(2===w.selectedDates.length&&w.clear(!1,!1),w.latestSelectedDateObj=a,w.selectedDates.push(a),0!==M(a,w.selectedDates[0],!0)&&w.selectedDates.sort((function(e,n){return e.getTime()-n.getTime()})));if(O(),i){var r=w.currentYear!==a.getFullYear();w.currentYear=a.getFullYear(),w.currentMonth=a.getMonth(),r&&(De("onYearChange"),q()),De("onMonthChange")}if(Ce(),U(),ye(),i||"range"===w.config.mode||1!==w.config.showMonths?void 0!==w.selectedDateElem&&void 0===w.hourElement&&w.selectedDateElem&&w.selectedDateElem.focus():W(t),void 0!==w.hourElement&&void 0!==w.hourElement&&w.hourElement.focus(),w.config.closeOnSelect){var l="single"===w.config.mode&&!w.config.enableTime,c="range"===w.config.mode&&2===w.selectedDates.length&&!w.config.enableTime;(l||c)&&fe()}Y()}}w.parseDate=C({config:w.config,l10n:w.l10n}),w._handlers=[],w.pluginElements=[],w.loadedPlugins=[],w._bind=P,w._setHoursFromDate=F,w._positionCalendar=de,w.changeMonth=Z,w.changeYear=ee,w.clear=function(e,n){void 0===e&&(e=!0);void 0===n&&(n=!0);w.input.value="",void 0!==w.altInput&&(w.altInput.value="");void 0!==w.mobileInput&&(w.mobileInput.value="");w.selectedDates=[],w.latestSelectedDateObj=void 0,!0===n&&(w.currentYear=w._initialDate.getFullYear(),w.currentMonth=w._initialDate.getMonth());if(!0===w.config.enableTime){var t=E(w.config),a=t.hours,i=t.minutes,o=t.seconds;A(a,i,o)}w.redraw(),e&&De("onChange")},w.close=function(){w.isOpen=!1,w.isMobile||(void 0!==w.calendarContainer&&w.calendarContainer.classList.remove("open"),void 0!==w._input&&w._input.classList.remove("active"));De("onClose")},w.onMouseOver=oe,w._createElement=d,w.createDay=R,w.destroy=function(){void 0!==w.config&&De("onDestroy");for(var e=w._handlers.length;e--;)w._handlers[e].remove();if(w._handlers=[],w.mobileInput)w.mobileInput.parentNode&&w.mobileInput.parentNode.removeChild(w.mobileInput),w.mobileInput=void 0;else if(w.calendarContainer&&w.calendarContainer.parentNode)if(w.config.static&&w.calendarContainer.parentNode){var n=w.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else w.calendarContainer.parentNode.removeChild(w.calendarContainer);w.altInput&&(w.input.type="text",w.altInput.parentNode&&w.altInput.parentNode.removeChild(w.altInput),delete w.altInput);w.input&&(w.input.type=w.input._type,w.input.classList.remove("flatpickr-input"),w.input.removeAttribute("readonly"));["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach((function(e){try{delete w[e]}catch(e){}}))},w.isEnabled=ne,w.jumpToDate=j,w.updateValue=ye,w.open=function(e,n){void 0===n&&(n=w._positionElement);if(!0===w.isMobile){if(e){e.preventDefault();var t=g(e);t&&t.blur()}return void 0!==w.mobileInput&&(w.mobileInput.focus(),w.mobileInput.click()),void De("onOpen")}if(w._input.disabled||w.config.inline)return;var a=w.isOpen;w.isOpen=!0,a||(w.calendarContainer.classList.add("open"),w._input.classList.add("active"),De("onOpen"),de(n));!0===w.config.enableTime&&!0===w.config.noCalendar&&(!1!==w.config.allowInput||void 0!==e&&w.timeContainer.contains(e.relatedTarget)||setTimeout((function(){return w.hourElement.select()}),50))},w.redraw=ue,w.set=function(e,n){if(null!==e&&"object"==typeof e)for(var a in Object.assign(w.config,e),e)void 0!==ge[a]&&ge[a].forEach((function(e){return e()}));else w.config[e]=n,void 0!==ge[e]?ge[e].forEach((function(e){return e()})):t.indexOf(e)>-1&&(w.config[e]=c(n));w.redraw(),ye(!0)},w.setDate=function(e,n,t){void 0===n&&(n=!1);void 0===t&&(t=w.config.dateFormat);if(0!==e&&!e||e instanceof Array&&0===e.length)return w.clear(n);pe(e,t),w.latestSelectedDateObj=w.selectedDates[w.selectedDates.length-1],w.redraw(),j(void 0,n),F(),0===w.selectedDates.length&&w.clear(!1);ye(n),n&&De("onChange")},w.toggle=function(e){if(!0===w.isOpen)return w.close();w.open(e)};var ge={locale:[se,G],showMonths:[V,S,z],minDate:[j],maxDate:[j],positionElement:[ve],clickOpens:[function(){!0===w.config.clickOpens?(P(w._input,"focus",w.open),P(w._input,"click",w.open)):(w._input.removeEventListener("focus",w.open),w._input.removeEventListener("click",w.open))}]};function pe(e,n){var t=[];if(e instanceof Array)t=e.map((function(e){return w.parseDate(e,n)}));else if(e instanceof Date||"number"==typeof e)t=[w.parseDate(e,n)];else if("string"==typeof e)switch(w.config.mode){case"single":case"time":t=[w.parseDate(e,n)];break;case"multiple":t=e.split(w.config.conjunction).map((function(e){return w.parseDate(e,n)}));break;case"range":t=e.split(w.l10n.rangeSeparator).map((function(e){return w.parseDate(e,n)}))}else w.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));w.selectedDates=w.config.allowInvalidPreload?t:t.filter((function(e){return e instanceof Date&&ne(e,!1)})),"range"===w.config.mode&&w.selectedDates.sort((function(e,n){return e.getTime()-n.getTime()}))}function he(e){return e.slice().map((function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?w.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:w.parseDate(e.from,void 0),to:w.parseDate(e.to,void 0)}:e})).filter((function(e){return e}))}function ve(){w._positionElement=w.config.positionElement||w._input}function De(e,n){if(void 0!==w.config){var t=w.config[e];if(void 0!==t&&t.length>0)for(var a=0;t[a]&&a1||"static"===w.config.monthSelectorType?w.monthElements[n].textContent=h(t.getMonth(),w.config.shorthandCurrentMonth,w.l10n)+" ":w.monthsDropdownContainer.value=t.getMonth().toString(),e.value=t.getFullYear().toString()})),w._hidePrevMonthArrow=void 0!==w.config.minDate&&(w.currentYear===w.config.minDate.getFullYear()?w.currentMonth<=w.config.minDate.getMonth():w.currentYearw.config.maxDate.getMonth():w.currentYear>w.config.maxDate.getFullYear()))}function Me(e){var n=e||(w.config.altInput?w.config.altFormat:w.config.dateFormat);return w.selectedDates.map((function(e){return w.formatDate(e,n)})).filter((function(e,n,t){return"range"!==w.config.mode||w.config.enableTime||t.indexOf(e)===n})).join("range"!==w.config.mode?w.config.conjunction:w.l10n.rangeSeparator)}function ye(e){void 0===e&&(e=!0),void 0!==w.mobileInput&&w.mobileFormatStr&&(w.mobileInput.value=void 0!==w.latestSelectedDateObj?w.formatDate(w.latestSelectedDateObj,w.mobileFormatStr):""),w.input.value=Me(w.config.dateFormat),void 0!==w.altInput&&(w.altInput.value=Me(w.config.altFormat)),!1!==e&&De("onValueUpdate")}function xe(e){var n=g(e),t=w.prevMonthNav.contains(n),a=w.nextMonthNav.contains(n);t||a?Z(t?-1:1):w.yearElements.indexOf(n)>=0?n.select():n.classList.contains("arrowUp")?w.changeYear(w.currentYear+1):n.classList.contains("arrowDown")&&w.changeYear(w.currentYear-1)}return function(){w.element=w.input=p,w.isOpen=!1,function(){var n=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],i=e(e({},JSON.parse(JSON.stringify(p.dataset||{}))),v),o={};w.config.parseDate=i.parseDate,w.config.formatDate=i.formatDate,Object.defineProperty(w.config,"enable",{get:function(){return w.config._enable},set:function(e){w.config._enable=he(e)}}),Object.defineProperty(w.config,"disable",{get:function(){return w.config._disable},set:function(e){w.config._disable=he(e)}});var r="time"===i.mode;if(!i.dateFormat&&(i.enableTime||r)){var l=I.defaultConfig.dateFormat||a.dateFormat;o.dateFormat=i.noCalendar||r?"H:i"+(i.enableSeconds?":S":""):l+" H:i"+(i.enableSeconds?":S":"")}if(i.altInput&&(i.enableTime||r)&&!i.altFormat){var s=I.defaultConfig.altFormat||a.altFormat;o.altFormat=i.noCalendar||r?"h:i"+(i.enableSeconds?":S K":" K"):s+" h:i"+(i.enableSeconds?":S":"")+" K"}Object.defineProperty(w.config,"minDate",{get:function(){return w.config._minDate},set:le("min")}),Object.defineProperty(w.config,"maxDate",{get:function(){return w.config._maxDate},set:le("max")});var d=function(e){return function(n){w.config["min"===e?"_minTime":"_maxTime"]=w.parseDate(n,"H:i:S")}};Object.defineProperty(w.config,"minTime",{get:function(){return w.config._minTime},set:d("min")}),Object.defineProperty(w.config,"maxTime",{get:function(){return w.config._maxTime},set:d("max")}),"time"===i.mode&&(w.config.noCalendar=!0,w.config.enableTime=!0);Object.assign(w.config,o,i);for(var u=0;u-1?w.config[m]=c(f[m]).map(T).concat(w.config[m]):void 0===i[m]&&(w.config[m]=f[m])}i.altInputClass||(w.config.altInputClass=ce().className+" "+w.config.altInputClass);De("onParseConfig")}(),se(),function(){if(w.input=ce(),!w.input)return void w.config.errorHandler(new Error("Invalid input element specified"));w.input._type=w.input.type,w.input.type="text",w.input.classList.add("flatpickr-input"),w._input=w.input,w.config.altInput&&(w.altInput=d(w.input.nodeName,w.config.altInputClass),w._input=w.altInput,w.altInput.placeholder=w.input.placeholder,w.altInput.disabled=w.input.disabled,w.altInput.required=w.input.required,w.altInput.tabIndex=w.input.tabIndex,w.altInput.type="text",w.input.setAttribute("type","hidden"),!w.config.static&&w.input.parentNode&&w.input.parentNode.insertBefore(w.altInput,w.input.nextSibling));w.config.allowInput||w._input.setAttribute("readonly","readonly");ve()}(),function(){w.selectedDates=[],w.now=w.parseDate(w.config.now)||new Date;var e=w.config.defaultDate||("INPUT"!==w.input.nodeName&&"TEXTAREA"!==w.input.nodeName||!w.input.placeholder||w.input.value!==w.input.placeholder?w.input.value:null);e&&pe(e,w.config.dateFormat);w._initialDate=w.selectedDates.length>0?w.selectedDates[0]:w.config.minDate&&w.config.minDate.getTime()>w.now.getTime()?w.config.minDate:w.config.maxDate&&w.config.maxDate.getTime()0&&(w.latestSelectedDateObj=w.selectedDates[0]);void 0!==w.config.minTime&&(w.config.minTime=w.parseDate(w.config.minTime,"H:i"));void 0!==w.config.maxTime&&(w.config.maxTime=w.parseDate(w.config.maxTime,"H:i"));w.minDateHasTime=!!w.config.minDate&&(w.config.minDate.getHours()>0||w.config.minDate.getMinutes()>0||w.config.minDate.getSeconds()>0),w.maxDateHasTime=!!w.config.maxDate&&(w.config.maxDate.getHours()>0||w.config.maxDate.getMinutes()>0||w.config.maxDate.getSeconds()>0)}(),w.utils={getDaysInMonth:function(e,n){return void 0===e&&(e=w.currentMonth),void 0===n&&(n=w.currentYear),1===e&&(n%4==0&&n%100!=0||n%400==0)?29:w.l10n.daysInMonth[e]}},w.isMobile||function(){var e=window.document.createDocumentFragment();if(w.calendarContainer=d("div","flatpickr-calendar"),w.calendarContainer.tabIndex=-1,!w.config.noCalendar){if(e.appendChild((w.monthNav=d("div","flatpickr-months"),w.yearElements=[],w.monthElements=[],w.prevMonthNav=d("span","flatpickr-prev-month"),w.prevMonthNav.innerHTML=w.config.prevArrow,w.nextMonthNav=d("span","flatpickr-next-month"),w.nextMonthNav.innerHTML=w.config.nextArrow,V(),Object.defineProperty(w,"_hidePrevMonthArrow",{get:function(){return w.__hidePrevMonthArrow},set:function(e){w.__hidePrevMonthArrow!==e&&(s(w.prevMonthNav,"flatpickr-disabled",e),w.__hidePrevMonthArrow=e)}}),Object.defineProperty(w,"_hideNextMonthArrow",{get:function(){return w.__hideNextMonthArrow},set:function(e){w.__hideNextMonthArrow!==e&&(s(w.nextMonthNav,"flatpickr-disabled",e),w.__hideNextMonthArrow=e)}}),w.currentYearElement=w.yearElements[0],Ce(),w.monthNav)),w.innerContainer=d("div","flatpickr-innerContainer"),w.config.weekNumbers){var n=function(){w.calendarContainer.classList.add("hasWeeks");var e=d("div","flatpickr-weekwrapper");e.appendChild(d("span","flatpickr-weekday",w.l10n.weekAbbreviation));var n=d("div","flatpickr-weeks");return e.appendChild(n),{weekWrapper:e,weekNumbers:n}}(),t=n.weekWrapper,a=n.weekNumbers;w.innerContainer.appendChild(t),w.weekNumbers=a,w.weekWrapper=t}w.rContainer=d("div","flatpickr-rContainer"),w.rContainer.appendChild(z()),w.daysContainer||(w.daysContainer=d("div","flatpickr-days"),w.daysContainer.tabIndex=-1),U(),w.rContainer.appendChild(w.daysContainer),w.innerContainer.appendChild(w.rContainer),e.appendChild(w.innerContainer)}w.config.enableTime&&e.appendChild(function(){w.calendarContainer.classList.add("hasTime"),w.config.noCalendar&&w.calendarContainer.classList.add("noCalendar");var e=E(w.config);w.timeContainer=d("div","flatpickr-time"),w.timeContainer.tabIndex=-1;var n=d("span","flatpickr-time-separator",":"),t=m("flatpickr-hour",{"aria-label":w.l10n.hourAriaLabel});w.hourElement=t.getElementsByTagName("input")[0];var a=m("flatpickr-minute",{"aria-label":w.l10n.minuteAriaLabel});w.minuteElement=a.getElementsByTagName("input")[0],w.hourElement.tabIndex=w.minuteElement.tabIndex=-1,w.hourElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getHours():w.config.time_24hr?e.hours:function(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}(e.hours)),w.minuteElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getMinutes():e.minutes),w.hourElement.setAttribute("step",w.config.hourIncrement.toString()),w.minuteElement.setAttribute("step",w.config.minuteIncrement.toString()),w.hourElement.setAttribute("min",w.config.time_24hr?"0":"1"),w.hourElement.setAttribute("max",w.config.time_24hr?"23":"12"),w.hourElement.setAttribute("maxlength","2"),w.minuteElement.setAttribute("min","0"),w.minuteElement.setAttribute("max","59"),w.minuteElement.setAttribute("maxlength","2"),w.timeContainer.appendChild(t),w.timeContainer.appendChild(n),w.timeContainer.appendChild(a),w.config.time_24hr&&w.timeContainer.classList.add("time24hr");if(w.config.enableSeconds){w.timeContainer.classList.add("hasSeconds");var i=m("flatpickr-second");w.secondElement=i.getElementsByTagName("input")[0],w.secondElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getSeconds():e.seconds),w.secondElement.setAttribute("step",w.minuteElement.getAttribute("step")),w.secondElement.setAttribute("min","0"),w.secondElement.setAttribute("max","59"),w.secondElement.setAttribute("maxlength","2"),w.timeContainer.appendChild(d("span","flatpickr-time-separator",":")),w.timeContainer.appendChild(i)}w.config.time_24hr||(w.amPM=d("span","flatpickr-am-pm",w.l10n.amPM[r((w.latestSelectedDateObj?w.hourElement.value:w.config.defaultHour)>11)]),w.amPM.title=w.l10n.toggleTitle,w.amPM.tabIndex=-1,w.timeContainer.appendChild(w.amPM));return w.timeContainer}());s(w.calendarContainer,"rangeMode","range"===w.config.mode),s(w.calendarContainer,"animate",!0===w.config.animate),s(w.calendarContainer,"multiMonth",w.config.showMonths>1),w.calendarContainer.appendChild(e);var i=void 0!==w.config.appendTo&&void 0!==w.config.appendTo.nodeType;if((w.config.inline||w.config.static)&&(w.calendarContainer.classList.add(w.config.inline?"inline":"static"),w.config.inline&&(!i&&w.element.parentNode?w.element.parentNode.insertBefore(w.calendarContainer,w._input.nextSibling):void 0!==w.config.appendTo&&w.config.appendTo.appendChild(w.calendarContainer)),w.config.static)){var l=d("div","flatpickr-wrapper");w.element.parentNode&&w.element.parentNode.insertBefore(l,w.element),l.appendChild(w.element),w.altInput&&l.appendChild(w.altInput),l.appendChild(w.calendarContainer)}w.config.static||w.config.inline||(void 0!==w.config.appendTo?w.config.appendTo:window.document.body).appendChild(w.calendarContainer)}(),function(){w.config.wrap&&["open","close","toggle","clear"].forEach((function(e){Array.prototype.forEach.call(w.element.querySelectorAll("[data-"+e+"]"),(function(n){return P(n,"click",w[e])}))}));if(w.isMobile)return void function(){var e=w.config.enableTime?w.config.noCalendar?"time":"datetime-local":"date";w.mobileInput=d("input",w.input.className+" flatpickr-mobile"),w.mobileInput.tabIndex=1,w.mobileInput.type=e,w.mobileInput.disabled=w.input.disabled,w.mobileInput.required=w.input.required,w.mobileInput.placeholder=w.input.placeholder,w.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",w.selectedDates.length>0&&(w.mobileInput.defaultValue=w.mobileInput.value=w.formatDate(w.selectedDates[0],w.mobileFormatStr));w.config.minDate&&(w.mobileInput.min=w.formatDate(w.config.minDate,"Y-m-d"));w.config.maxDate&&(w.mobileInput.max=w.formatDate(w.config.maxDate,"Y-m-d"));w.input.getAttribute("step")&&(w.mobileInput.step=String(w.input.getAttribute("step")));w.input.type="hidden",void 0!==w.altInput&&(w.altInput.type="hidden");try{w.input.parentNode&&w.input.parentNode.insertBefore(w.mobileInput,w.input.nextSibling)}catch(e){}P(w.mobileInput,"change",(function(e){w.setDate(g(e).value,!1,w.mobileFormatStr),De("onChange"),De("onClose")}))}();var e=l(re,50);w._debouncedChange=l(Y,300),w.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&P(w.daysContainer,"mouseover",(function(e){"range"===w.config.mode&&oe(g(e))}));P(w._input,"keydown",ie),void 0!==w.calendarContainer&&P(w.calendarContainer,"keydown",ie);w.config.inline||w.config.static||P(window,"resize",e);void 0!==window.ontouchstart?P(window.document,"touchstart",X):P(window.document,"mousedown",X);P(window.document,"focus",X,{capture:!0}),!0===w.config.clickOpens&&(P(w._input,"focus",w.open),P(w._input,"click",w.open));void 0!==w.daysContainer&&(P(w.monthNav,"click",xe),P(w.monthNav,["keyup","increment"],N),P(w.daysContainer,"click",me));if(void 0!==w.timeContainer&&void 0!==w.minuteElement&&void 0!==w.hourElement){var n=function(e){return g(e).select()};P(w.timeContainer,["increment"],_),P(w.timeContainer,"blur",_,{capture:!0}),P(w.timeContainer,"click",H),P([w.hourElement,w.minuteElement],["focus","click"],n),void 0!==w.secondElement&&P(w.secondElement,"focus",(function(){return w.secondElement&&w.secondElement.select()})),void 0!==w.amPM&&P(w.amPM,"click",(function(e){_(e)}))}w.config.allowInput&&P(w._input,"blur",ae)}(),(w.selectedDates.length||w.config.noCalendar)&&(w.config.enableTime&&F(w.config.noCalendar?w.latestSelectedDateObj:void 0),ye(!1)),S();var n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!w.isMobile&&n&&de(),De("onReady")}(),w}function T(e,n){for(var t=Array.prototype.slice.call(e).filter((function(e){return e instanceof HTMLElement})),a=[],i=0;i>1&1,n=0;n0;e--)n[e]=n[e]?n[e-1]^_.EXPONENT[v._modN(_.LOG[n[e]]+t)]:n[e-1];n[0]=_.EXPONENT[v._modN(_.LOG[n[0]]+t)]}for(t=0;t<=i;t++)n[t]=_.LOG[n[t]]},_checkBadness:function(){var t,e,i,n,s,r=0,o=this._badness,a=this.buffer,h=this.width;for(s=0;sh*h;)u-=h*h,c++;for(r+=c*v.N4,n=0;n=o-2&&(t=o-2,s>9&&t--);var a=t;if(s>9){for(r[a+2]=0,r[a+3]=0;a--;)e=r[a],r[a+3]|=255&e<<4,r[a+2]=e>>4;r[2]|=255&t<<4,r[1]=t>>4,r[0]=64|t>>12}else{for(r[a+1]=0,r[a+2]=0;a--;)e=r[a],r[a+2]|=255&e<<4,r[a+1]=e>>4;r[1]|=255&t<<4,r[0]=64|t>>4}for(a=t+3-(s<10);a=5&&(i+=v.N1+n[e]-5);for(e=3;et||3*n[e-3]>=4*n[e]||3*n[e+3]>=4*n[e])&&(i+=v.N3);return i},_finish:function(){this._stringBuffer=this.buffer.slice();var t,e,i=0,n=3e4;for(e=0;e<8&&(this._applyMask(e),(t=this._checkBadness())>=1)1&n&&(s[r-1-e+8*r]=1,e<6?s[8+r*e]=1:s[8+r*(e+1)]=1);for(e=0;e<7;e++,n>>=1)1&n&&(s[8+r*(r-7+e)]=1,e?s[6-e+8*r]=1:s[7+8*r]=1)},_interleaveBlocks:function(){var t,e,i=this._dataBlock,n=this._ecc,s=this._eccBlock,r=0,o=this._calculateMaxLength(),a=this._neccBlock1,h=this._neccBlock2,f=this._stringBuffer;for(t=0;t1)for(t=u.BLOCK[n],i=s-7;;){for(e=s-7;e>t-3&&(this._addAlignment(e,i),!(e6)for(t=d.BLOCK[r-7],e=17,i=0;i<6;i++)for(n=0;n<3;n++,e--)1&(e>11?r>>e-12:t>>e)?(s[5-i+o*(2-n+o-11)]=1,s[2-n+o-11+o*(5-i)]=1):(this._setMask(5-i,2-n+o-11),this._setMask(2-n+o-11,5-i))},_isMasked:function(t,e){var i=v._getMaskBit(t,e);return 1===this._mask[i]},_pack:function(){var t,e,i,n=1,s=1,r=this.width,o=r-1,a=r-1,h=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(e=0;ee&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,i+=t},_modN:function(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t},N1:3,N2:3,N3:40,N4:10}),p=v,m=f.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var t=this.element;t.width=t.height=this.qrious.size}}),g=h.extend(function(t,e,i,n){this.name=t,this.modifiable=Boolean(e),this.defaultValue=i,this._valueTransformer=n},{transform:function(t){var e=this._valueTransformer;return"function"==typeof e?e(t,this):t}}),k=h.extend(null,{abs:function(t){return null!=t?Math.abs(t):null},hasOwn:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},noop:function(){},toUpperCase:function(t){return null!=t?t.toUpperCase():null}}),w=h.extend(function(t){this.options={},t.forEach(function(t){this.options[t.name]=t},this)},{exists:function(t){return null!=this.options[t]},get:function(t,e){return w._get(this.options[t],e)},getAll:function(t){var e,i=this.options,n={};for(e in i)k.hasOwn(i,e)&&(n[e]=w._get(i[e],t));return n},init:function(t,e,i){"function"!=typeof i&&(i=k.noop);var n,s;for(n in this.options)k.hasOwn(this.options,n)&&(s=this.options[n],w._set(s,s.defaultValue,e),w._createAccessor(s,e,i));this._setAll(t,e,!0)},set:function(t,e,i){return this._set(t,e,i)},setAll:function(t,e){return this._setAll(t,e)},_set:function(t,e,i,n){var s=this.options[t];if(!s)throw new Error("Invalid option: "+t);if(!s.modifiable&&!n)throw new Error("Option cannot be modified: "+t);return w._set(s,e,i)},_setAll:function(t,e,i){if(!t)return!1;var n,s=!1;for(n in t)k.hasOwn(t,n)&&this._set(n,t[n],e,i)&&(s=!0);return s}},{_createAccessor:function(t,e,i){var n={get:function(){return w._get(t,e)}};t.modifiable&&(n.set=function(n){w._set(t,n,e)&&i(n,t)}),Object.defineProperty(e,t.name,n)},_get:function(t,e){return e["_"+t.name]},_set:function(t,e,i){var n="_"+t.name,s=i[n],r=t.transform(null!=e?e:t.defaultValue);return i[n]=r,r!==s}}),M=w,b=h.extend(function(){this._services={}},{getService:function(t){var e=this._services[t];if(!e)throw new Error("Service is not being managed with name: "+t);return e},setService:function(t,e){if(this._services[t])throw new Error("Service is already managed with name: "+t);e&&(this._services[t]=e)}}),B=new M([new g("background",!0,"white"),new g("backgroundAlpha",!0,1,k.abs),new g("element"),new g("foreground",!0,"black"),new g("foregroundAlpha",!0,1,k.abs),new g("level",!0,"L",k.toUpperCase),new g("mime",!0,"image/png"),new g("padding",!0,null,k.abs),new g("size",!0,100,k.abs),new g("value",!0,"")]),y=new b,O=h.extend(function(t){B.init(t,this,this.update.bind(this));var e=B.get("element",this),i=y.getService("element"),n=e&&i.isCanvas(e)?e:i.createCanvas(),s=e&&i.isImage(e)?e:i.createImage();this._canvasRenderer=new c(this,n,!0),this._imageRenderer=new m(this,s,s===e),this.update()},{get:function(){return B.getAll(this)},set:function(t){B.setAll(t,this)&&this.update()},toDataURL:function(t){return this.canvas.toDataURL(t||this.mime)},update:function(){var t=new p({level:this.level,value:this.value});this._canvasRenderer.render(t),this._imageRenderer.render(t)}},{use:function(t){y.setService(t.getName(),t)}});Object.defineProperties(O.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var A=O,L=h.extend({getName:function(){}}).extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(t){},isImage:function(t){}}).extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(t){return t instanceof HTMLCanvasElement},isImage:function(t){return t instanceof HTMLImageElement}});return A.use(new L),A}); //# sourceMappingURL=qrious.min.js.map // Theme initialization to prevent flash (function() { const savedTheme = localStorage.getItem('theme') || 'light'; if (savedTheme === 'dark') { document.documentElement.setAttribute('data-theme', 'dark'); } else { document.documentElement.removeAttribute('data-theme'); } })(); document.addEventListener('DOMContentLoaded', () => { // Global Theme Toggle Function function initGlobalTheme() { // Target BOTH possible IDs (legacy switcher and new sidebar btn) const toggles = [ document.getElementById('theme-switcher'), document.getElementById('theme-toggle-btn') ]; const updateToggleIcons = (theme) => { toggles.forEach(btn => { if (!btn) return; const icon = btn.querySelector('i'); if (icon) { icon.className = theme === 'dark' ? 'fa-solid fa-sun' : 'fa-solid fa-moon'; } const span = btn.querySelector('span'); if (span) { span.innerText = theme === 'dark' ? 'Light Mode' : 'Dark Mode'; } }); }; // Initial icon state const currentTheme = localStorage.getItem('theme') || 'light'; updateToggleIcons(currentTheme); toggles.forEach(btn => { if (!btn) return; btn.addEventListener('click', (e) => { e.preventDefault(); const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'; if (theme === 'dark') { document.documentElement.setAttribute('data-theme', 'dark'); localStorage.setItem('theme', 'dark'); } else { document.documentElement.removeAttribute('data-theme'); localStorage.setItem('theme', 'light'); } updateToggleIcons(theme); }); }); } initGlobalTheme(); // Background Image Loading - Simple Direct Loading let backgroundImageReady = false; function loadBackgroundImage() { const bgLayer = document.querySelector('.bg-layer'); if (bgLayer) bgLayer.style.backgroundImage = 'url(' + EMBEDDED_BG + ')'; backgroundImageReady = true; } function applyBackgroundImage(base64) { const bgLayer = document.querySelector('.bg-layer'); if (bgLayer) { bgLayer.style.backgroundImage = `url(${base64})`; } } function waitForBackgroundImage(callback, maxWait = 100) { // Reduced wait since pdf-generator handles its own lifecycle setTimeout(() => { callback(); }, maxWait); } // Mobile Menu Logic const mobileToggle = document.getElementById('mobile-toggle'); const sidebar = document.querySelector('.sidebar'); const overlay = document.getElementById('sidebar-overlay'); if (mobileToggle && sidebar && overlay) { const toggleMenu = () => { sidebar.classList.toggle('active'); overlay.classList.toggle('active'); }; mobileToggle.addEventListener('click', toggleMenu); overlay.addEventListener('click', toggleMenu); // Close menu on link click sidebar.querySelectorAll('a').forEach(link => { link.addEventListener('click', toggleMenu); }); } // Initialize background image loading loadBackgroundImage(); // Initialize Premium Date Picker flatpickr(".date-picker", { dateFormat: "d/m/Y", allowInput: true }); // Helper to wrap numbers in a specific class function wrapDigits(text) { return text.replace(/(\d+)/g, '$1'); } // Helper to get value or placeholder and title case it (for English text) function getValOrPlaceholder(inputEl, titleCase = false) { if (!inputEl) return ""; let val = inputEl.value.trim() !== "" ? inputEl.value : (inputEl.placeholder || ""); // Capitalize first letter of each word if requested if (titleCase && val) { val = val.split(' ').map(word => { if (word.length > 0) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); } return word; }).join(' '); } return val; } // Auto-capitalize input fields as the user types (English fields only) const englishInputIds = [ 'in-name-en', 'in-father-en', 'in-house-en', 'in-village-en', 'in-post-en', 'in-district-en', 'in-state-en' ]; englishInputIds.forEach(id => { const el = document.getElementById(id); if (el) { el.addEventListener('input', function(e) { // Save cursor position to restore it after modifying the value const start = this.selectionStart; const end = this.selectionEnd; let val = this.value; // Prevent leading spaces dynamically if (val.startsWith(' ')) { val = val.replace(/^\s+/, ''); } val = val.split(' ').map(word => { if (word.length > 0) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); } return word; }).join(' '); this.value = val; // Restore cursor position this.setSelectionRange(start, end); }); } }); // PIN Code validation - only digits, max 6 characters const pinInput = document.getElementById('in-pin'); if (pinInput) { pinInput.addEventListener('input', function(e) { // Remove any non-digit characters this.value = this.value.replace(/[^0-9]/g, ''); // Limit to 6 characters if (this.value.length > 6) { this.value = this.value.slice(0, 6); } }); pinInput.addEventListener('keypress', function(e) { // Only allow digit keys (0-9) const charCode = e.charCode; if (charCode < 48 || charCode > 57) { e.preventDefault(); return false; } }); } // Simple text updates const textBindings = [ { in: 'in-name-hi', out: 'out-name-hi', titleCase: false }, { in: 'in-name-en', out: 'out-name-en', titleCase: true } ]; textBindings.forEach(binding => { const inputEl = document.getElementById(binding.in); const outputEl = document.getElementById(binding.out); if (inputEl && outputEl) { inputEl.addEventListener('input', (e) => { outputEl.innerText = getValOrPlaceholder(inputEl, binding.titleCase); if (binding.in === 'in-name-en') updateAddress(); // Re-trigger QR and Inrol text }); outputEl.innerText = getValOrPlaceholder(inputEl, binding.titleCase); } }); // Date bindings with prefixes const issueInput = document.getElementById('in-issue-date'); const outIssue = document.getElementById('out-inrol-date'); if (issueInput && outIssue) { issueInput.addEventListener('input', () => { outIssue.innerText = "Aadhaar no. issued: " + getValOrPlaceholder(issueInput); }); outIssue.innerText = "Aadhaar no. issued: " + getValOrPlaceholder(issueInput); } const downloadInput = document.getElementById('in-download-date'); const outDownload = document.getElementById('out-download-date'); const sigDate = document.getElementById('out-signature-date'); function updateDownloadAndSignatureDate() { let val = getValOrPlaceholder(downloadInput); if (outDownload) { outDownload.innerText = "Details as on: " + val; } // Match signature date with download date but keep the time if (sigDate && val) { // Expected val format: DD/MM/YYYY const parts = val.split('/'); if (parts.length === 3) { const formattedDate = `${parts[2]}.${parts[1]}.${parts[0]}`; // YYYY.MM.DD // Keep the current time (or generate a random/fixed time if preferred) const now = new Date(); const timeStr = String(now.getHours()).padStart(2,'0') + ":" + String(now.getMinutes()).padStart(2,'0') + ":" + String(now.getSeconds()).padStart(2,'0'); sigDate.innerText = formattedDate + " " + timeStr; } } } if (downloadInput) { downloadInput.addEventListener('input', updateDownloadAndSignatureDate); updateDownloadAndSignatureDate(); // Initial call } // Gender Radio Buttons logic const genderRadios = document.querySelectorAll('input[name="in-gender"]'); const outGenderHi = document.getElementById('out-gender-hi'); const outGenderEn = document.getElementById('out-gender-en'); function updateGender() { let selected = "M"; // Default genderRadios.forEach(radio => { if (radio.checked) selected = radio.value; }); if (selected === "M") { if(outGenderHi) outGenderHi.innerText = "पुरुष"; if(outGenderEn) outGenderEn.innerText = "MALE"; } else { if(outGenderHi) outGenderHi.innerText = "महिला"; if(outGenderEn) outGenderEn.innerText = "FEMALE"; } } genderRadios.forEach(radio => radio.addEventListener('change', updateGender)); updateGender(); // DOB const dobInput = document.getElementById('in-dob'); const outDob = document.getElementById('out-dob'); if (dobInput && outDob) { dobInput.addEventListener('input', (e) => { outDob.innerText = e.target.value; }); outDob.innerText = dobInput.value; } // Generate Random Enrolment Number function generateRandomEnrolment() { // Format: XXXX/XXXXX/XXXXX (4 digits / 5 digits / 5 digits) const part1 = Math.floor(1000 + Math.random() * 9000); // 1000-9999 const part2 = Math.floor(10000 + Math.random() * 90000); // 10000-99999 const part3 = Math.floor(10000 + Math.random() * 90000); // 10000-99999 return `${part1}/${part2}/${part3}`; } const enrolmentOut = document.getElementById('out-enrolment-no'); if (enrolmentOut) { enrolmentOut.innerText = `नामांकन क्रम/ Enrolment No.: ${generateRandomEnrolment()}`; } // Dynamic Address Compilation const addressInputs = { fatherHi: document.getElementById('in-father-hi'), fatherEn: document.getElementById('in-father-en'), houseHi: document.getElementById('in-house-hi'), houseEn: document.getElementById('in-house-en'), villageHi: document.getElementById('in-village-hi'), villageEn: document.getElementById('in-village-en'), postHi: document.getElementById('in-post-hi'), postEn: document.getElementById('in-post-en'), districtHi: document.getElementById('in-district-hi'), districtEn: document.getElementById('in-district-en'), stateHi: document.getElementById('in-state-hi'), stateEn: document.getElementById('in-state-en'), pin: document.getElementById('in-pin') }; const outAddressHi = document.getElementById('out-address-hi'); const outAddressEn = document.getElementById('out-address-en'); const outInrolText = document.getElementById('out-inroltext'); // QR Code generation function generateQRData(enFullAddress) { const uid = document.getElementById('in-aadhaar') ? document.getElementById('in-aadhaar').value.replace(/\s/g, '') : ""; const name = document.getElementById('in-name-en') ? document.getElementById('in-name-en').value : ""; let gender = "M"; document.querySelectorAll('input[name="in-gender"]').forEach(radio => { if (radio.checked) gender = radio.value; }); // Convert DD/MM/YYYY to YYYY-MM-DD for QR code let dobRaw = document.getElementById('in-dob') ? document.getElementById('in-dob').value : ""; let dob = ""; if (dobRaw && dobRaw.length === 10) { const parts = dobRaw.split('/'); if (parts.length === 3) dob = `${parts[2]}-${parts[1]}-${parts[0]}`; } const co = getValOrPlaceholder(addressInputs.fatherEn); const po = getValOrPlaceholder(addressInputs.postEn); const pc = getValOrPlaceholder(addressInputs.pin); // Clean up the full address for QR (Remove the "Address:
" prefix) let cleanAddress = enFullAddress.replace('Address:
', '').trim(); // Fallback cleanup if any HTML remains cleanAddress = cleanAddress.replace(/<[^>]*>?/gm, ''); // Construct XML string EXACTLY like AadharPrint2 const xmlString = ` `; // Generate QR in a hidden canvas let tempCanvas = document.createElement('canvas'); try { // Using QRious which is much better at handling long raw byte strings new QRious({ element: tempCanvas, value: xmlString, size: 300, level: 'M', // Medium error correction for dense look background: 'white', foreground: 'black' }); // Extract canvas to image setTimeout(() => { let dataUrl = tempCanvas.toDataURL("image/png"); const qr1 = document.getElementById('out-qrcode1'); const qr2 = document.getElementById('out-qrcode2'); if(qr1) qr1.src = dataUrl; if(qr2) qr2.src = dataUrl; }, 100); } catch (error) { // Silently fail if there is an error to avoid console clutter } } function updateAddress() { // Build Hindi Address (No Title Case for Hindi) let hiParts = []; if (getValOrPlaceholder(addressInputs.fatherHi)) hiParts.push(`आत्मज: ${getValOrPlaceholder(addressInputs.fatherHi)}`); if (getValOrPlaceholder(addressInputs.houseHi)) hiParts.push(getValOrPlaceholder(addressInputs.houseHi)); if (getValOrPlaceholder(addressInputs.villageHi)) hiParts.push(getValOrPlaceholder(addressInputs.villageHi)); if (getValOrPlaceholder(addressInputs.postHi)) hiParts.push(getValOrPlaceholder(addressInputs.postHi)); if (getValOrPlaceholder(addressInputs.districtHi)) hiParts.push(getValOrPlaceholder(addressInputs.districtHi)); if (getValOrPlaceholder(addressInputs.stateHi)) hiParts.push(getValOrPlaceholder(addressInputs.stateHi)); let hiFull = hiParts.join(', '); if (getValOrPlaceholder(addressInputs.pin)) hiFull += ` - ${getValOrPlaceholder(addressInputs.pin)}`; if (outAddressHi) outAddressHi.innerHTML = hiFull; // Build English Address (With Title Case for English fields) let enParts = []; if (getValOrPlaceholder(addressInputs.fatherEn, true)) enParts.push(`S/O: ${getValOrPlaceholder(addressInputs.fatherEn, true)}`); if (getValOrPlaceholder(addressInputs.houseEn, true)) enParts.push(getValOrPlaceholder(addressInputs.houseEn, true)); if (getValOrPlaceholder(addressInputs.villageEn, true)) enParts.push(getValOrPlaceholder(addressInputs.villageEn, true)); if (getValOrPlaceholder(addressInputs.postEn, true)) enParts.push(`PO: ${getValOrPlaceholder(addressInputs.postEn, true)}`); if (getValOrPlaceholder(addressInputs.districtEn, true)) enParts.push(`DIST: ${getValOrPlaceholder(addressInputs.districtEn, true)}`); let enFull = enParts.join(', '); if (getValOrPlaceholder(addressInputs.stateEn, true) && getValOrPlaceholder(addressInputs.pin)) { enFull += `,
${getValOrPlaceholder(addressInputs.stateEn, true)} - ${getValOrPlaceholder(addressInputs.pin)}`; } if (outAddressEn) outAddressEn.innerHTML = enFull; let plainEnFull = enParts.join(', ') + `, ${getValOrPlaceholder(addressInputs.stateEn, true)} - ${getValOrPlaceholder(addressInputs.pin)}`; // Build Inrol Text let nameHi = getValOrPlaceholder(document.getElementById('in-name-hi')); let nameEn = getValOrPlaceholder(document.getElementById('in-name-en'), true); if (outInrolText) { outInrolText.innerHTML = ` To
${nameHi}
${nameEn}
S/O: ${getValOrPlaceholder(addressInputs.fatherEn, true)},
${getValOrPlaceholder(addressInputs.villageEn, true)},
VTC: ${getValOrPlaceholder(addressInputs.villageEn, true)},
PO: ${getValOrPlaceholder(addressInputs.postEn, true)},
District: ${getValOrPlaceholder(addressInputs.districtEn, true)},
State: ${getValOrPlaceholder(addressInputs.stateEn, true)},
PIN Code: ${getValOrPlaceholder(addressInputs.pin)} `; } generateQRData(plainEnFull); } Object.values(addressInputs).forEach(input => { if (input) input.addEventListener('input', updateAddress); }); updateAddress(); // Aadhaar Number Formatting const aadhaarInput = document.getElementById('in-aadhaar'); const aadhaarOut1 = document.getElementById('out-aadhaar-1'); const aadhaarOut2 = document.getElementById('out-aadhaar-2'); const aadhaarOut3 = document.getElementById('out-aadhaar-3'); if (aadhaarInput) { aadhaarInput.addEventListener('input', (e) => { let rawValue = e.target.value.replace(/\D/g, ''); if (rawValue.length > 12) rawValue = rawValue.slice(0, 12); let formattedValue = rawValue.replace(/(\d{4})(?=\d)/g, '$1 '); e.target.value = formattedValue; let finalOutput = formattedValue || getValOrPlaceholder(aadhaarInput); if(aadhaarOut1) aadhaarOut1.innerText = finalOutput; if(aadhaarOut2) aadhaarOut2.innerText = finalOutput; if(aadhaarOut3) aadhaarOut3.innerText = finalOutput; updateAddress(); // To update QR Code with new UID }); let initAadhaar = getValOrPlaceholder(aadhaarInput); if(aadhaarOut1) aadhaarOut1.innerText = initAadhaar; if(aadhaarOut2) aadhaarOut2.innerText = initAadhaar; if(aadhaarOut3) aadhaarOut3.innerText = initAadhaar; } // Photo Upload const photoInput = document.getElementById('in-photo'); const photoOut = document.getElementById('out-photo'); const formPhotoPreview = document.getElementById('form-photo-preview'); if (photoInput) { photoInput.addEventListener('change', function(e) { const file = e.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { if (photoOut) photoOut.src = e.target.result; if (formPhotoPreview) formPhotoPreview.src = e.target.result; } reader.readAsDataURL(file); } }); } // Load default photo from base64 file function loadDefaultPhoto() { const photoOut = document.getElementById('out-photo'); const formPhotoPreview = document.getElementById('form-photo-preview'); const dataUrl = 'data:image/jpeg;base64,' + EMBEDDED_PHOTO; if (photoOut) photoOut.src = dataUrl; if (formPhotoPreview) formPhotoPreview.src = dataUrl; } // Load default photo on init loadDefaultPhoto(); // Add error handling for images (CSP compliant - no inline handlers) const placeholderImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; if (formPhotoPreview) { formPhotoPreview.addEventListener('error', function() { this.src = placeholderImage; }); } if (photoOut) { photoOut.addEventListener('error', function() { this.src = placeholderImage; }); } // Pincode logic let pincodeData = {}; fetch('/static/data/pincodes_hindi.json') .then(res => res.json()) .then(data => { pincodeData = data; }) .catch(err => console.error("Error loading pincode data:", err)); document.getElementById("in-pin").addEventListener("input", function() { let pin = this.value.trim(); if (pin.length === 6 && pincodeData[pin]) { let res = pincodeData[pin]; document.getElementById("in-district-en").value = res.d || ""; document.getElementById("in-state-en").value = res.s || ""; if(document.getElementById("in-district-hi")) document.getElementById("in-district-hi").value = res.dh || ""; if(document.getElementById("in-state-hi")) document.getElementById("in-state-hi").value = res.sh || ""; updateAddress(); } }); // Translation logic const inputMappings = [ { en: 'in-name-en', hi: 'in-name-hi' }, { en: 'in-father-en', hi: 'in-father-hi' }, { en: 'in-house-en', hi: 'in-house-hi' }, { en: 'in-village-en', hi: 'in-village-hi' }, { en: 'in-post-en', hi: 'in-post-hi' }, { en: 'in-district-en', hi: 'in-district-hi' }, { en: 'in-state-en', hi: 'in-state-hi' } ]; inputMappings.forEach(mapping => { const enInput = document.getElementById(mapping.en); const hiInput = document.getElementById(mapping.hi); if (enInput && hiInput) { enInput.addEventListener('input', () => { hiInput.value = enInput.value; hiInput.dispatchEvent(new Event('input')); // Force UI refresh immediately }); enInput.addEventListener('blur', () => { const text = enInput.value.trim(); if(text !== "") { const url = `https://inputtools.google.com/request?text=${encodeURIComponent(text)}&itc=hi-t-i0-und&num=1&cp=0&cs=1&ie=utf-8&oe=utf-8&app=demopage`; fetch(url) .then(response => response.json()) .then(data => { if (data[0] === 'SUCCESS' && data[1] && data[1][0] && data[1][0][1] && data[1][0][1][0]) { hiInput.value = data[1][0][1][0]; hiInput.dispatchEvent(new Event('input')); if (mapping.en === 'in-name-en') { const outNameHi = document.getElementById('out-name-hi'); if (outNameHi) outNameHi.innerText = hiInput.value; } } }) .catch(err => console.error("Transliteration Error:", err)); } else { hiInput.value = ""; hiInput.dispatchEvent(new Event('input')); } }); } }); // Popup Logic const popup = document.getElementById('validation-popup'); const popupMessage = document.getElementById('popup-message'); const popupCloseBtn = document.getElementById('popup-close-btn'); function showPopup(message) { if(popup && popupMessage) { popupMessage.innerText = message; // Ensure close button is visible for validation errors const closeBtn = document.getElementById('popup-close-btn'); if (closeBtn) closeBtn.style.display = 'block'; // Reset icon/color to Alert style for validation errors const iconContainer = document.getElementById('popup-icon-container'); const popupTitle = document.getElementById('popup-title'); const popupSvg = document.getElementById('popup-svg'); if (iconContainer) { iconContainer.style.background = '#fff0f0'; iconContainer.style.color = '#ff4757'; iconContainer.style.boxShadow = '0 0 0 10px rgba(255, 71, 87, 0.1)'; } if (popupTitle) popupTitle.innerText = "Action Required"; if (popupSvg) { popupSvg.innerHTML = ''; popupSvg.classList.remove('spinner-animation'); } popup.classList.add('active'); } else { alert(message); } } if(popupCloseBtn && popup) { popupCloseBtn.addEventListener('click', () => { popup.classList.remove('active'); }); } // Print Button & History Save Logic const printBtn = document.getElementById('btn-print-aadhaar'); if (printBtn) { printBtn.addEventListener('click', () => { if (!photoInput || !photoInput.files || photoInput.files.length === 0) { showPopup("Please upload a Photo before printing."); return; } const requiredFields = [ { id: 'in-name-en', name: 'Name (English)' }, { id: 'in-name-hi', name: 'Name (Hindi)' }, { id: 'in-dob', name: 'Date of Birth' }, { id: 'in-aadhaar', name: 'Aadhaar Number' }, { id: 'in-father-en', name: 'Father Name (English)' }, { id: 'in-father-hi', name: 'Father Name (Hindi)' }, { id: 'in-house-en', name: 'House (English)' }, { id: 'in-house-hi', name: 'House (Hindi)' }, { id: 'in-village-en', name: 'Village (English)' }, { id: 'in-village-hi', name: 'Village (Hindi)' }, { id: 'in-post-en', name: 'Post (English)' }, { id: 'in-post-hi', name: 'Post (Hindi)' }, { id: 'in-pin', name: 'PIN Code' }, { id: 'in-district-en', name: 'District (English)' }, { id: 'in-district-hi', name: 'District (Hindi)' }, { id: 'in-state-en', name: 'State (English)' }, { id: 'in-state-hi', name: 'State (Hindi)' }, { id: 'in-issue-date', name: 'Issue Date' }, { id: 'in-download-date', name: 'Download Date' } ]; let formData = {}; for (let i = 0; i < requiredFields.length; i++) { const el = document.getElementById(requiredFields[i].id); if (!el || el.value.trim() === '') { showPopup(`Please fill the "${requiredFields[i].name}" field.`); if(el) el.focus(); return; } formData[requiredFields[i].id] = el.value.trim(); } const aadhaarVal = aadhaarInput ? aadhaarInput.value.replace(/\s/g, '') : ''; if (aadhaarVal.length !== 12) { showPopup("Aadhaar Number must be exactly 12 digits!"); if(aadhaarInput) aadhaarInput.focus(); return; } // Get gender document.querySelectorAll('input[name="in-gender"]').forEach(radio => { if (radio.checked) formData['in-gender'] = radio.value; }); // Save Photo as Base64 if (photoOut && photoOut.src) { formData['photo_base64'] = photoOut.src; } // Save to History saveToHistory(formData); // Directly trigger the high-res PDF generator which shows its own unified popup setTimeout(() => { generateAadhaarPDF(); }, 100); }); } // ========================================== // HISTORY FEATURE LOGIC // ========================================== function saveToHistory(data) { let history = []; try { history = JSON.parse(localStorage.getItem('aadhaarHistory')) || []; } catch (e) { console.error('Failed to parse history:', e); history = []; } // Check for duplicate entry const isDuplicate = history.some(item => { return item['in-aadhaar'] === data['in-aadhaar'] && item['in-dob'] === data['in-dob']; }); if (isDuplicate) { console.log('Duplicate entry found, skipping save'); return; } // Add timestamp and unique ID data.id = Date.now().toString(); data.timestamp = new Date().toLocaleString(); // Push new data to top history.unshift(data); // Circular buffer: Keep only last 20 records (reduced from 50 to prevent QuotaExceeded on mobile) if (history.length > 20) history = history.slice(0, 20); // Robust Save with Quota Management try { localStorage.setItem('aadhaarHistory', JSON.stringify(history)); } catch (e) { if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') { console.warn('Storage quota exceeded, reducing history to 5 items...'); history = history.slice(0, 5); // Aggressively reduce if it fails try { localStorage.setItem('aadhaarHistory', JSON.stringify(history)); } catch (innerError) { console.error('Even reduced history exceeds quota. Clearing storage.'); localStorage.removeItem('aadhaarHistory'); } } else { console.error('LocalStorage save error:', e); } } } const btnShowHistory = document.getElementById('btn-show-history'); const historyModal = document.getElementById('history-modal'); const closeHistoryBtn = document.getElementById('close-history-btn'); const historyList = document.getElementById('history-list'); if (btnShowHistory) { btnShowHistory.addEventListener('click', renderHistory); } if (closeHistoryBtn) { closeHistoryBtn.addEventListener('click', () => { historyModal.classList.remove('active'); }); } function renderHistory() { let history = JSON.parse(localStorage.getItem('aadhaarHistory')) || []; historyList.innerHTML = ''; if (history.length === 0) { historyList.innerHTML = '

No history found.

'; } else { history.forEach(item => { const div = document.createElement('div'); div.className = 'history-item'; div.innerHTML = `

${item['in-name-en']}

Aadhaar: ${item['in-aadhaar']}

Saved on: ${item.timestamp}

`; historyList.appendChild(div); }); // Attach event listeners after rendering to comply with Extension CSP rules document.querySelectorAll('.btn-print-hist').forEach(btn => { btn.addEventListener('click', function() { loadHistoryItem(this.getAttribute('data-id'), true); }); }); document.querySelectorAll('.btn-delete').forEach(btn => { btn.addEventListener('click', function() { deleteHistoryItem(this.getAttribute('data-id')); }); }); } historyModal.classList.add('active'); } function deleteHistoryItem(id) { let history = JSON.parse(localStorage.getItem('aadhaarHistory')) || []; history = history.filter(item => item.id !== id); localStorage.setItem('aadhaarHistory', JSON.stringify(history)); // Show success toast message showToast('History item deleted successfully'); renderHistory(); // Refresh list } function showToast(message) { // Create toast element if it doesn't exist let toast = document.getElementById('toast-message'); if (!toast) { toast = document.createElement('div'); toast.id = 'toast-message'; toast.style.cssText = ` position: fixed; top: 20px; right: 20px; background: #28a745; color: white; padding: 12px 20px; border-radius: 4px; z-index: 10000; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); opacity: 0; transition: opacity 0.3s ease; `; document.body.appendChild(toast); } toast.textContent = message; toast.style.opacity = '1'; // Hide after 2 seconds setTimeout(() => { toast.style.opacity = '0'; }, 2000); } function showLoadingPopup(message) { // Create loading popup if it doesn't exist or if it's hidden let loadingPopup = document.getElementById('loading-popup'); if (!loadingPopup) { loadingPopup = document.createElement('div'); loadingPopup.id = 'loading-popup'; loadingPopup.innerHTML = `
${message}
`; loadingPopup.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; `; // Add styles for loading content const style = document.createElement('style'); style.textContent = ` .loading-content { background: #2d2d2d; padding: 30px; border-radius: 8px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.3); } .loading-spinner { margin-bottom: 15px; } .loading-text { color: #dad8d8; font-size: 16px; font-weight: 500; } `; document.head.appendChild(style); document.body.appendChild(loadingPopup); } // Reset popup state for reuse loadingPopup.style.display = 'flex'; loadingPopup.style.opacity = '0'; // Update message and show const loadingText = loadingPopup.querySelector('.loading-text'); if (loadingText) { loadingText.textContent = message; } loadingPopup.classList.add('active'); loadingPopup.style.opacity = '1'; // Auto-hide after 2 seconds setTimeout(() => { loadingPopup.style.opacity = '0'; setTimeout(() => { loadingPopup.classList.remove('active'); loadingPopup.style.display = 'none'; // Completely hide }, 300); }, 2000); } function loadHistoryItem(id, autoPrint) { let history = JSON.parse(localStorage.getItem('aadhaarHistory')) || []; let item = history.find(i => i.id === id); if (!item) return; // Populate fields for (const key in item) { if (key === 'id' || key === 'timestamp' || key === 'photo_base64' || key === 'in-gender') continue; const el = document.getElementById(key); if (el) { el.value = item[key]; el.dispatchEvent(new Event('input')); // Trigger updateAddress and other bindings } } // Set Gender if (item['in-gender']) { document.querySelectorAll('input[name="in-gender"]').forEach(radio => { radio.checked = (radio.value === item['in-gender']); radio.dispatchEvent(new Event('change')); }); } // Set Photo if (item['photo_base64']) { const formPreview = document.getElementById('form-photo-preview'); const mainPhoto = document.getElementById('out-photo'); if (formPreview) formPreview.src = item['photo_base64']; if (mainPhoto) mainPhoto.src = item['photo_base64']; // To pass validation, we can't programmatically set a File input, // so if autoPrint is triggered from history, we might need a workaround for validation. } // Force full update updateAddress(); // Close modal historyModal.classList.remove('active'); // Auto print if requested if (autoPrint) { setTimeout(() => { generateAadhaarPDF(); }, 500); } } // Set signature date to today dynamically (Removed, now handled by download date logic) // const sigDate = document.getElementById('out-signature-date'); // if(sigDate) { // const now = new Date(); // sigDate.innerText = now.getFullYear() + "." + String(now.getMonth()+1).padStart(2,'0') + "." + String(now.getDate()).padStart(2,'0') + " " + String(now.getHours()).padStart(2,'0') + ":" + String(now.getMinutes()).padStart(2,'0') + ":" + String(now.getSeconds()).padStart(2,'0'); // } });