Your IP : 216.73.217.79


Current Path : /var/www/v3.cesa.co.za/public/bundles/sonataform/
Upload File :
Current File : /var/www/v3.cesa.co.za/public/bundles/sonataform/639.js

(self.webpackChunksonata_project_form_extensions=self.webpackChunksonata_project_form_extensions||[]).push([[639],{255:function(t,e){!function(t){"use strict";const e={type:"icons",time:"fas fa-clock",date:"fas fa-calendar",up:"fas fa-arrow-up",down:"fas fa-arrow-down",previous:"fas fa-chevron-left",next:"fas fa-chevron-right",today:"fas fa-calendar-check",clear:"fas fa-trash",close:"fas fa-times"},s=(t,s,i)=>{i.DefaultOptions.display.icons=e};t.faFiveIcons=e,t.load=s,Object.defineProperty(t,"__esModule",{value:!0})}(e)},969:function(t,e,s){"use strict";s.d(e,{U_:function(){return J},Xq:function(){return Z},g$:function(){return a}});class i extends Error{}const o="tempus-dominus";class a{}a.NAME=o,a.dataKey="td",a.events=new class{constructor(){this.key=".td",this.change=`change${this.key}`,this.update=`update${this.key}`,this.error=`error${this.key}`,this.show=`show${this.key}`,this.hide=`hide${this.key}`,this.blur=`blur${this.key}`,this.focus=`focus${this.key}`,this.keyup=`keyup${this.key}`,this.keydown=`keydown${this.key}`}},a.css=new class{constructor(){this.widget=`${o}-widget`,this.calendarHeader="calendar-header",this.switch="picker-switch",this.toolbar="toolbar",this.noHighlight="no-highlight",this.sideBySide="timepicker-sbs",this.previous="previous",this.next="next",this.disabled="disabled",this.old="old",this.new="new",this.active="active",this.dateContainer="date-container",this.decadesContainer=`${this.dateContainer}-decades`,this.decade="decade",this.yearsContainer=`${this.dateContainer}-years`,this.year="year",this.monthsContainer=`${this.dateContainer}-months`,this.month="month",this.daysContainer=`${this.dateContainer}-days`,this.day="day",this.calendarWeeks="cw",this.dayOfTheWeek="dow",this.today="today",this.weekend="weekend",this.rangeIn="range-in",this.rangeStart="range-start",this.rangeEnd="range-end",this.timeContainer="time-container",this.separator="separator",this.clockContainer=`${this.timeContainer}-clock`,this.hourContainer=`${this.timeContainer}-hour`,this.minuteContainer=`${this.timeContainer}-minute`,this.secondContainer=`${this.timeContainer}-second`,this.hour="hour",this.minute="minute",this.second="second",this.toggleMeridiem="toggleMeridiem",this.show="show",this.collapsing="td-collapsing",this.collapse="td-collapse",this.inline="inline",this.lightTheme="light",this.darkTheme="dark",this.isDarkPreferredQuery="(prefers-color-scheme: dark)"}},a.errorMessages=new class{constructor(){this.base="TD:",this.failedToSetInvalidDate="Failed to set invalid date",this.failedToParseInput="Failed parse input field"}unexpectedOption(t){const e=new i(`${this.base} Unexpected option: ${t} does not match a known option.`);throw e.code=1,e}unexpectedOptions(t){const e=new i(`${this.base}: ${t.join(", ")}`);throw e.code=1,e}unexpectedOptionValue(t,e,s){const o=new i(`${this.base} Unexpected option value: ${t} does not accept a value of "${e}". Valid values are: ${s.join(", ")}`);throw o.code=2,o}typeMismatch(t,e,s){const o=new i(`${this.base} Mismatch types: ${t} has a type of ${e} instead of the required ${s}`);throw o.code=3,o}numbersOutOfRange(t,e,s){const o=new i(`${this.base} ${t} expected an array of number between ${e} and ${s}.`);throw o.code=4,o}failedToParseDate(t,e,s=!1){const o=new i(`${this.base} Could not correctly parse "${e}" to a date for ${t}.`);if(o.code=5,!s)throw o;console.warn(o)}mustProvideElement(){const t=new i(`${this.base} No element was provided.`);throw t.code=6,t}subscribeMismatch(){const t=new i(`${this.base} The subscribed events does not match the number of callbacks`);throw t.code=7,t}conflictingConfiguration(t){const e=new i(`${this.base} A configuration value conflicts with another rule. ${t}`);throw e.code=8,e}customDateFormatError(t){const e=new i(`${this.base} Custom Date Format: ${t}`);throw e.code=9,e}dateString(){console.warn(`${this.base} Using a string for date options is not recommended unless you specify an ISO string or use the customDateFormat plugin.`)}deprecatedWarning(t,e){console.warn(`${this.base} Warning ${t} is deprecated and will be removed in a future version. ${e}`)}throwError(t){const e=new i(`${this.base} ${t}`);throw e.code=9,e}};var n,r={...{dateFormats:{LTS:"h:mm:ss T",LT:"h:mm T",L:"MM/dd/yyyy",LL:"MMMM d, yyyy",LLL:"MMMM d, yyyy h:mm T",LLLL:"dddd, MMMM d, yyyy h:mm T"},format:"L LT",locale:"default",hourCycle:void 0,ordinal:t=>{const e=["th","st","nd","rd"],s=t%100;return`[${t}${e[(s-20)%10]||e[s]||e[0]}]`}}};!function(t){t.seconds="seconds",t.minutes="minutes",t.hours="hours",t.date="date",t.month="month",t.year="year"}(n||(n={}));const d={month:"2-digit",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"},c=t=>{switch(t){case"date":return{dateStyle:"short"};case"month":return{month:"numeric",year:"numeric"};case"year":return{year:"numeric"}}},l=t=>{if(!t)return"h12";const e={hour:"2-digit",minute:"2-digit",numberingSystem:"latn"},s=(new h).setLocalization({locale:t});s.hours=0;const i=s.parts(void 0,e).hour;if("12"===i)return"h12";if("24"===i)return"h24";s.hours=23;const o=s.parts(void 0,e).hour;return"00"===i&&"11"===o?"h11":"00"===i&&"23"===o?"h23":void console.warn(`couldn't determine hour cycle for ${t}. start: ${i}. end: ${o}`)};class h extends Date{constructor(){super(...arguments),this.localization=r,this.nonLeapLadder=[0,31,59,90,120,151,181,212,243,273,304,334],this.leapLadder=[0,31,60,91,121,152,182,213,244,274,305,335],this.dateTimeRegex=/(\[[^[\]]*])|y{1,4}|M{1,4}|d{1,4}|H{1,2}|h{1,2}|t|T|m{1,2}|s{1,2}|f{3}/g,this.formattingTokens=/(\[[^[\]]*])|([-_:/.,()\s]+)|(T|t|yyyy|yy?|MM?M?M?|Do|dd?|hh?|HH?|mm?|ss?)/g,this.match2=/\d\d/,this.match3=/\d{3}/,this.match4=/\d{4}/,this.match1to2=/\d\d?/,this.matchSigned=/[+-]?\d+/,this.matchOffset=/[+-]\d\d:?(\d\d)?|Z/,this.matchWord=/[^\d_:/,\-()\s]+/,this.zoneExpressions=[this.matchOffset,(t,e)=>{t.offset=this.offsetFromString(e)}],this.expressions={t:{pattern:void 0,parser:(t,e)=>{t.afternoon=this.meridiemMatch(e)}},T:{pattern:void 0,parser:(t,e)=>{t.afternoon=this.meridiemMatch(e)}},fff:{pattern:this.match3,parser:(t,e)=>{t.milliseconds=+e}},s:{pattern:this.match1to2,parser:this.addInput("seconds")},ss:{pattern:this.match1to2,parser:this.addInput("seconds")},m:{pattern:this.match1to2,parser:this.addInput("minutes")},mm:{pattern:this.match1to2,parser:this.addInput("minutes")},H:{pattern:this.match1to2,parser:this.addInput("hours")},h:{pattern:this.match1to2,parser:this.addInput("hours")},HH:{pattern:this.match1to2,parser:this.addInput("hours")},hh:{pattern:this.match1to2,parser:this.addInput("hours")},d:{pattern:this.match1to2,parser:this.addInput("day")},dd:{pattern:this.match2,parser:this.addInput("day")},Do:{pattern:this.matchWord,parser:(t,e)=>{if(t.day=+(e.match(/\d+/)[0]||1),this.localization.ordinal)for(let s=1;s<=31;s+=1)this.localization.ordinal(s).replace(/[[\]]/g,"")===e&&(t.day=s)}},M:{pattern:this.match1to2,parser:this.addInput("month")},MM:{pattern:this.match2,parser:this.addInput("month")},MMM:{pattern:this.matchWord,parser:(t,e)=>{const s=this.getAllMonths(),i=(this.getAllMonths("short")||s.map((t=>t.slice(0,3)))).indexOf(e)+1;if(i<1)throw new Error;t.month=i%12||i}},MMMM:{pattern:this.matchWord,parser:(t,e)=>{const s=this.getAllMonths().indexOf(e)+1;if(s<1)throw new Error;t.month=s%12||s}},y:{pattern:this.matchSigned,parser:this.addInput("year")},yy:{pattern:this.match2,parser:(t,e)=>{t.year=this.parseTwoDigitYear(+e)}},yyyy:{pattern:this.match4,parser:this.addInput("year")}}}setLocale(t){return this.localization||(this.localization=r,this.localization.locale=t),this}setLocalization(t){return this.localization=t,this}static convert(t,e="default",s=void 0){if(!t)throw new Error("A date is required");return s||((s=r).locale=e),new h(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()).setLocalization(s)}get clone(){return new h(this.year,this.month,this.date,this.hours,this.minutes,this.seconds,this.getMilliseconds()).setLocalization(this.localization)}static isValid(t){return void 0!==t&&"null"!==JSON.stringify(t)&&t.constructor.name===h.name}startOf(t,e=0){if(void 0===this[t])throw new Error(`Unit '${t}' is not valid`);switch(t){case"seconds":this.setMilliseconds(0);break;case"minutes":this.setSeconds(0,0);break;case"hours":this.setMinutes(0,0,0);break;case"date":this.setHours(0,0,0,0);break;case"weekDay":{if(this.startOf(n.date),this.weekDay===e)break;const t=(this.weekDay-e+7)%7;this.manipulate(-1*t,n.date);break}case"month":this.startOf(n.date),this.setDate(1);break;case"year":this.startOf(n.date),this.setMonth(0,1)}return this}endOf(t,e=0){if(void 0===this[t])throw new Error(`Unit '${t}' is not valid`);switch(t){case"seconds":this.setMilliseconds(999);break;case"minutes":this.setSeconds(59,999);break;case"hours":this.setMinutes(59,59,999);break;case"date":this.setHours(23,59,59,999);break;case"weekDay":{this.endOf(n.date);const t=6+e;if(this.weekDay===t)break;this.manipulate(t-this.weekDay,n.date);break}case"month":this.endOf(n.date),this.manipulate(1,n.month),this.setDate(0);break;case"year":this.endOf(n.date),this.setMonth(11,31)}return this}manipulate(t,e){if(void 0===this[e])throw new Error(`Unit '${e}' is not valid`);return this[e]+=t,this}isBefore(t,e){if(!h.isValid(t))return!1;if(!e)return this.valueOf()<t.valueOf();if(void 0===this[e])throw new Error(`Unit '${e}' is not valid`);return this.clone.startOf(e).valueOf()<t.clone.startOf(e).valueOf()}isAfter(t,e){if(!h.isValid(t))return!1;if(!e)return this.valueOf()>t.valueOf();if(void 0===this[e])throw new Error(`Unit '${e}' is not valid`);return this.clone.startOf(e).valueOf()>t.clone.startOf(e).valueOf()}isSame(t,e){if(!h.isValid(t))return!1;if(!e)return this.valueOf()===t.valueOf();if(void 0===this[e])throw new Error(`Unit '${e}' is not valid`);return t=h.convert(t),this.clone.startOf(e).valueOf()===t.startOf(e).valueOf()}isBetween(t,e,s,i="()"){if(!h.isValid(t)||!h.isValid(e))return!1;if(s&&void 0===this[s])throw new Error(`Unit '${s}' is not valid`);const o="("===i[0],a=")"===i[1],n=o?this.isAfter(t,s):!this.isBefore(t,s),r=a?this.isBefore(e,s):!this.isAfter(e,s);return n&&r}parts(t=this.localization.locale,e={dateStyle:"full",timeStyle:"long"}){const s={};return new Intl.DateTimeFormat(t,e).formatToParts(this).filter((t=>"literal"!==t.type)).forEach((t=>s[t.type]=t.value)),s}get seconds(){return this.getSeconds()}set seconds(t){this.setSeconds(t)}get secondsFormatted(){return this.parts(void 0,d).second}get minutes(){return this.getMinutes()}set minutes(t){this.setMinutes(t)}get minutesFormatted(){return this.parts(void 0,d).minute}get hours(){return this.getHours()}set hours(t){this.setHours(t)}getHoursFormatted(t="h12"){return this.parts(void 0,{...d,hourCycle:t}).hour}meridiem(t=this.localization.locale){return new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0}).formatToParts(this).find((t=>"dayPeriod"===t.type))?.value}get date(){return this.getDate()}set date(t){this.setDate(t)}get dateFormatted(){return this.parts(void 0,d).day}get weekDay(){return this.getDay()}get month(){return this.getMonth()}set month(t){const e=new Date(this.year,t+1);e.setDate(0);const s=e.getDate();this.date>s&&(this.date=s),this.setMonth(t)}get monthFormatted(){return this.parts(void 0,d).month}get year(){return this.getFullYear()}set year(t){this.setFullYear(t)}get week(){const t=this.computeOrdinal(),e=this.getUTCDay();let s=Math.floor((t-e+10)/7);return s<1?s=this.weeksInWeekYear():s>this.weeksInWeekYear()&&(s=1),s}weeksInWeekYear(){const t=(this.year+Math.floor(this.year/4)-Math.floor(this.year/100)+Math.floor(this.year/400))%7,e=this.year-1,s=(e+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400))%7;return 4===t||3===s?53:52}get isLeapYear(){return this.year%4==0&&(this.year%100!=0||this.year%400==0)}computeOrdinal(){return this.date+(this.isLeapYear?this.leapLadder:this.nonLeapLadder)[this.month]}getAllMonths(t="long"){const e=new Intl.DateTimeFormat(this.localization.locale,{month:t}).format;return[...Array(12).keys()].map((t=>e(new Date(2021,t))))}replaceTokens(t,e){return t.replace(/(\[[^[\]]*])|(LTS?|l{1,4}|L{1,4})/g,((t,s,i)=>{const o=i&&i.toUpperCase();return s||e[o]||r.dateFormats[o]}))}parseTwoDigitYear(t){return t+(t>68?1900:2e3)}offsetFromString(t){if(!t)return 0;if("Z"===t)return 0;const[e,s,i]=t.match(/([+-]|\d\d)/g),o=60*+s+(+i||0);return 0===o?0:"+"===e?-o:o}zoneInformation(t,e){let s=t.parts(this.localization.locale,{timeZoneName:"longOffset"}).timeZoneName.replace("GMT","").replace(":","");const i=s.includes("-");return s=s.replace("-",""),"z"===e?s=s.substring(1,2):"zz"===e&&(s=s.substring(0,2)),`${i?"-":""}${s}`}addInput(t){return(e,s)=>{e[t]=+s}}getLocaleAfternoon(){return new Intl.DateTimeFormat(this.localization.locale,{hour:"numeric",hour12:!0}).formatToParts(new Date(2022,3,4,13)).find((t=>"dayPeriod"===t.type))?.value?.replace(/\s+/g," ")}meridiemMatch(t){return t.toLowerCase()===this.getLocaleAfternoon().toLowerCase()}correctHours(t){const{afternoon:e}=t;if(void 0!==e){const{hours:s}=t;e?s<12&&(t.hours+=12):12===s&&(t.hours=0),delete t.afternoon}}makeParser(t){const e=(t=this.replaceTokens(t,this.localization.dateFormats)).match(this.formattingTokens),{length:s}=e,i=[];for(let t=0;t<s;t+=1){const s=e[t],o=this.expressions[s];i[t]=o?.parser?o:s.replace(/^\[[^[\]]*]$/g,"")}return t=>{const e={hours:0,minutes:0,seconds:0,milliseconds:0};for(let o=0,a=0;o<s;o+=1){const s=i[o];if("string"==typeof s)a+=s.length;else{const i=t.slice(a);let o=i;if(s.pattern){o=s.pattern.exec(i)[0]}s.parser.call(this,e,o),t=t.replace(o,"")}}return this.correctHours(e),e}}static fromString(t,e){e?.format||a.errorMessages.customDateFormatError("No format was provided");try{const s=new h;if(s.setLocalization(e),["x","X"].indexOf(e.format)>-1)return new h(("X"===e.format?1e3:1)*+t);t=t.replace(/\s+/g," ");const i=s.makeParser(e.format),{year:o,month:a,day:n,hours:r,minutes:d,seconds:c,milliseconds:l,zone:p}=i(t),u=n||(o||a?1:s.getDate()),m=o||s.getFullYear();let y=0;return o&&!a||(y=a>0?a-1:s.getMonth()),p?new h(Date.UTC(m,y,u,r,d,c,l+60*p.offset*1e3)):new h(m,y,u,r,d,c,l)}catch(s){a.errorMessages.customDateFormatError(`Unable to parse provided input: ${t}, format: ${e.format}`)}}format(t,e=this.localization.locale){if(t&&"object"==typeof t)return new Intl.DateTimeFormat(e,t).format(this);const s=this.replaceTokens(t||this.localization.format||`${r.dateFormats.L}, ${r.dateFormats.LT}`,this.localization.dateFormats),i=t=>new Intl.DateTimeFormat(this.localization.locale,t).format(this);this.localization.hourCycle||(this.localization.hourCycle=l(this.localization.locale));const o=this.localization.hourCycle.startsWith("h1")?"h24":this.localization.hourCycle,a=this.localization.hourCycle.startsWith("h2")?"h12":this.localization.hourCycle,n={y:this.year,yy:i({year:"2-digit"}),yyyy:this.year,M:i({month:"numeric"}),MM:this.monthFormatted,MMM:this.getAllMonths("short")[this.getMonth()],MMMM:this.getAllMonths()[this.getMonth()],d:this.date,dd:this.dateFormatted,ddd:i({weekday:"short"}),dddd:i({weekday:"long"}),H:this.getHours(),HH:this.getHoursFormatted(o),h:this.hours>12?this.hours-12:this.hours,hh:this.getHoursFormatted(a),t:this.meridiem(),T:this.meridiem().toUpperCase(),m:this.minutes,mm:this.minutesFormatted,s:this.seconds,ss:this.secondsFormatted,fff:this.getMilliseconds()};return s.replace(this.dateTimeRegex,((t,e)=>e||n[t])).replace(/\[/g,"").replace(/]/g,"")}}class p{constructor(){this.cache=new Map}locate(t){const e=this.cache.get(t);if(e)return e;const s=new t;return this.cache.set(t,s),s}}let u;const m=[{name:"calendar",className:a.css.daysContainer,unit:n.month,step:1},{name:"months",className:a.css.monthsContainer,unit:n.year,step:1},{name:"years",className:a.css.yearsContainer,unit:n.year,step:10},{name:"decades",className:a.css.decadesContainer,unit:n.year,step:100}];class y{constructor(){this._currentCalendarViewMode=0,this._viewDate=new h,this.minimumCalendarViewMode=0,this.currentView="calendar"}get currentCalendarViewMode(){return this._currentCalendarViewMode}set currentCalendarViewMode(t){this._currentCalendarViewMode=t,this.currentView=m[t].name}get viewDate(){return this._viewDate}set viewDate(t){this._viewDate=t,this.options&&(this.options.viewDate=t)}refreshCurrentView(){this.currentView=m[this.currentCalendarViewMode].name}get isTwelveHour(){return["h12","h11"].includes(this.options.localization.hourCycle)}}class g{constructor(){this.optionsStore=u.locate(y)}isValid(t,e){if(!this._enabledDisabledDatesIsValid(e,t))return!1;if(e!==n.month&&e!==n.year&&this.optionsStore.options.restrictions.daysOfWeekDisabled?.length>0&&-1!==this.optionsStore.options.restrictions.daysOfWeekDisabled.indexOf(t.weekDay))return!1;if(!this._minMaxIsValid(e,t))return!1;if(e===n.hours||e===n.minutes||e===n.seconds){if(!this._enabledDisabledHoursIsValid(t))return!1;if(0!==this.optionsStore.options.restrictions.disabledTimeIntervals?.filter((e=>t.isBetween(e.from,e.to))).length)return!1}return!0}_enabledDisabledDatesIsValid(t,e){return t!==n.date||!(this.optionsStore.options.restrictions.disabledDates.length>0&&this._isInDisabledDates(e))&&!(this.optionsStore.options.restrictions.enabledDates.length>0&&!this._isInEnabledDates(e))}_isInDisabledDates(t){return!(!this.optionsStore.options.restrictions.disabledDates||0===this.optionsStore.options.restrictions.disabledDates.length)&&!!this.optionsStore.options.restrictions.disabledDates.find((e=>e.isSame(t,n.date)))}_isInEnabledDates(t){return!this.optionsStore.options.restrictions.enabledDates||0===this.optionsStore.options.restrictions.enabledDates.length||!!this.optionsStore.options.restrictions.enabledDates.find((e=>e.isSame(t,n.date)))}_minMaxIsValid(t,e){return(!this.optionsStore.options.restrictions.minDate||!e.isBefore(this.optionsStore.options.restrictions.minDate,t))&&(!this.optionsStore.options.restrictions.maxDate||!e.isAfter(this.optionsStore.options.restrictions.maxDate,t))}_enabledDisabledHoursIsValid(t){return!(this.optionsStore.options.restrictions.disabledHours.length>0&&this._isInDisabledHours(t))&&!(this.optionsStore.options.restrictions.enabledHours.length>0&&!this._isInEnabledHours(t))}_isInDisabledHours(t){if(!this.optionsStore.options.restrictions.disabledHours||0===this.optionsStore.options.restrictions.disabledHours.length)return!1;const e=t.hours;return this.optionsStore.options.restrictions.disabledHours.includes(e)}_isInEnabledHours(t){if(!this.optionsStore.options.restrictions.enabledHours||0===this.optionsStore.options.restrictions.enabledHours.length)return!0;const e=t.hours;return this.optionsStore.options.restrictions.enabledHours.includes(e)}dateRangeIsValid(t,e,s){if(!this.optionsStore.options.dateRange)return!0;if(2!==t.length&&1!==e)return!0;const i=t[0].clone;if(i.isSame(s,n.date))return!0;for(i.manipulate(1,n.date);!i.isSame(s,n.date);){if(!this.isValid(i,n.date))return!1;i.manipulate(1,n.date)}return!0}}class v{constructor(){this.subscribers=[]}subscribe(t){return this.subscribers.push(t),this.unsubscribe.bind(this,this.subscribers.length-1)}unsubscribe(t){this.subscribers.splice(t,1)}emit(t){this.subscribers.forEach((e=>{e(t)}))}destroy(){this.subscribers=null,this.subscribers=[]}}class f{constructor(){this.triggerEvent=new v,this.viewUpdate=new v,this.updateDisplay=new v,this.action=new v,this.updateViewDate=new v}destroy(){this.triggerEvent.destroy(),this.viewUpdate.destroy(),this.updateDisplay.destroy(),this.action.destroy(),this.updateViewDate.destroy()}}const S={clear:"Clear selection",close:"Close the picker",dateFormats:r.dateFormats,dayViewHeaderFormat:{month:"long",year:"2-digit"},decrementHour:"Decrement Hour",decrementMinute:"Decrement Minute",decrementSecond:"Decrement Second",format:r.format,hourCycle:r.hourCycle,incrementHour:"Increment Hour",incrementMinute:"Increment Minute",incrementSecond:"Increment Second",locale:r.locale,maxWeekdayLength:0,nextCentury:"Next Century",nextDecade:"Next Decade",nextMonth:"Next Month",nextYear:"Next Year",ordinal:r.ordinal,pickHour:"Pick Hour",pickMinute:"Pick Minute",pickSecond:"Pick Second",previousCentury:"Previous Century",previousDecade:"Previous Decade",previousMonth:"Previous Month",previousYear:"Previous Year",selectDate:"Select Date",selectDecade:"Select Decade",selectMonth:"Select Month",selectTime:"Select Time",selectYear:"Select Year",startOfTheWeek:0,today:"Go to today",toggleMeridiem:"Toggle Meridiem"},w={allowInputToggle:!1,container:void 0,dateRange:!1,debug:!1,defaultDate:void 0,display:{icons:{type:"icons",time:"fa-solid fa-clock",date:"fa-solid fa-calendar",up:"fa-solid fa-arrow-up",down:"fa-solid fa-arrow-down",previous:"fa-solid fa-chevron-left",next:"fa-solid fa-chevron-right",today:"fa-solid fa-calendar-check",clear:"fa-solid fa-trash",close:"fa-solid fa-xmark"},sideBySide:!1,calendarWeeks:!1,viewMode:"calendar",toolbarPlacement:"bottom",keepOpen:!1,buttons:{today:!1,clear:!1,close:!1},components:{calendar:!0,date:!0,month:!0,year:!0,decades:!0,clock:!0,hours:!0,minutes:!0,seconds:!1,useTwentyfourHour:void 0},inline:!1,theme:"auto",placement:"bottom"},keepInvalid:!1,localization:S,meta:{},multipleDates:!1,multipleDatesSeparator:"; ",promptTimeOnDateChange:!1,promptTimeOnDateChangeTransitionDelay:200,restrictions:{minDate:void 0,maxDate:void 0,disabledDates:[],enabledDates:[],daysOfWeekDisabled:[],disabledTimeIntervals:[],disabledHours:[],enabledHours:[]},stepping:1,useCurrent:!0,viewDate:new h};function b(t,e){if(!t)return null;if(t.constructor.name===h.name)return t;if(t.constructor.name===Date.name)return h.convert(t);if("string"==typeof t){const s=h.fromString(t,e);return"null"===JSON.stringify(s)?null:s}return null}function D(t,e,s){"string"==typeof t&&"input"!==e&&a.errorMessages.dateString();const i=b(t,s);return i||a.errorMessages.failedToParseDate(e,t,"input"===e),i}function _(t,e,s,i=r){Array.isArray(e)||a.errorMessages.typeMismatch(t,s,"array of DateTime or Date");for(let s=0;s<e.length;s++){const o=D(e[s],t,i);o.setLocalization(i),e[s]=o}}function k(t,e,s){Array.isArray(e)&&!e.some((t=>"number"!=typeof t))||a.errorMessages.typeMismatch(t,s,"array of numbers")}function C(t){return({value:e,providedType:s,localization:i})=>{const o=D(e,t,i);if(void 0!==o)return o.setLocalization(i),o}}function M(t){const e=C(t);return t=>void 0===t.value?t.value:e(t)}function E(t,e,s){return({value:i,providedType:o})=>void 0===i?[]:(k(t,i,o),i.some((t=>t<e||t>s))&&a.errorMessages.numbersOutOfRange(t,e,s),i)}function L(t){return E(t,0,23)}function T(t){return({value:e,providedType:s,localization:i})=>void 0===e?[]:(_(t,e,s,i),e)}function A(t){return({value:e,path:s})=>(t.includes(e)||a.errorMessages.unexpectedOptionValue(s.substring(1),e,t),e)}const V=Object.freeze({defaultDate:C("defaultDate"),viewDate:C("viewDate"),minDate:M("restrictions.minDate"),maxDate:M("restrictions.maxDate"),disabledHours:L("restrictions.disabledHours"),enabledHours:L("restrictions.enabledHours"),disabledDates:T("restrictions.disabledDates"),enabledDates:T("restrictions.enabledDates"),daysOfWeekDisabled:E("restrictions.daysOfWeekDisabled",0,6),disabledTimeIntervals:({key:t,value:e,providedType:s,localization:i})=>{if(void 0===e)return[];Array.isArray(e)||a.errorMessages.typeMismatch(t,s,"array of { from: DateTime|Date, to: DateTime|Date }");const o=e;for(let e=0;e<o.length;e++)Object.keys(o[e]).forEach((s=>{const a=`${t}[${e}].${s}`,n=D(o[e][s],a,i);n.setLocalization(i),o[e][s]=n}));return o},toolbarPlacement:A(["top","bottom","default"]),type:A(["icons","sprites"]),viewMode:A(["clock","calendar","months","years","decades"]),theme:A(["light","dark","auto"]),placement:A(["top","bottom"]),meta:({value:t})=>t,dayViewHeaderFormat:({value:t})=>t,container:({value:t,path:e})=>(t&&!(t instanceof HTMLElement||t instanceof Element||t?.appendChild)&&a.errorMessages.typeMismatch(e.substring(1),typeof t,"HTMLElement"),t),useTwentyfourHour:({value:t,path:e,providedType:s,defaultType:i})=>{if(a.errorMessages.deprecatedWarning("useTwentyfourHour",'Please use "options.localization.hourCycle" instead'),void 0===t||"boolean"===s)return t;a.errorMessages.typeMismatch(e,s,i)},hourCycle:A(["h11","h12","h23","h24"])}),$=({value:t,defaultType:e,providedType:s,path:i})=>{switch(e){case"boolean":return"true"===t||!0===t;case"number":return+t;case"string":return t.toString();case"object":return{};case"function":return t;default:a.errorMessages.typeMismatch(i,s,e)}};function O(t){return(V[t.key]||$)(t)}class H{static deepCopy(t){const e={};return Object.keys(t).forEach((s=>{const i=t[s];i instanceof h?e[s]=i.clone:i instanceof Date?e[s]=new Date(i.valueOf()):(e[s]=i,"object"!=typeof i||i instanceof HTMLElement||i instanceof Element||Array.isArray(i)||(e[s]=H.deepCopy(i)))})),e}static objectPath(t,e){return"."===t.charAt(0)&&(t=t.slice(1)),t?t.split(".").reduce(((t,e)=>H.isValue(t)||H.isValue(t[e])?t[e]:void 0),e):e}static spread(t,e,s,i=""){const o=H.objectPath(i,w),n=Object.keys(t).filter((t=>!Object.keys(o).includes(t)));if(n.length>0){const t=H.getFlattenDefaultOptions(),e=n.map((e=>{let s=`"${i}.${e}" in not a known option.`;const o=t.find((t=>t.includes(e)));return o&&(s+=` Did you mean "${o}"?`),s}));a.errorMessages.unexpectedOptions(e)}Object.keys(t).filter((t=>"__proto__"!==t&&"constructor"!==t)).forEach((a=>{"."===(i+=`.${a}`).charAt(0)&&(i=i.slice(1));const n=o[a],r=typeof t[a],d=typeof n,c=t[a];if(null==c)return e[a]=c,void(i=i.substring(0,i.lastIndexOf(`.${a}`)));"object"!=typeof n||Array.isArray(t[a])||n instanceof Date||H.ignoreProperties.includes(a)?e[a]=H.processKey(a,c,r,d,i,s):H.spread(t[a],e[a],s,i),i=i.substring(0,i.lastIndexOf(`.${a}`))}))}static processKey(t,e,s,i,o,a){return O({key:t,value:e,providedType:s,defaultType:i,path:o,localization:a})}static _mergeOptions(t,e){const s=H.deepCopy(e),i="default"!==e.localization?.locale?e.localization:t?.localization||w.localization;return H.spread(t,s,i,""),s}static _dataToOptions(t,e){const s=JSON.parse(JSON.stringify(t.dataset));if(s?.tdTargetInput&&delete s.tdTargetInput,s?.tdTargetToggle&&delete s.tdTargetToggle,!s||0===Object.keys(s).length||s.constructor!==DOMStringMap)return e;const i={},o=t=>{const e={};return Object.keys(t).forEach((t=>{e[t.toLowerCase()]=t})),e},n=this.normalizeObject(o),r=o(e);return Object.keys(s).filter((t=>t.startsWith(a.dataKey))).map((t=>t.substring(2))).forEach((t=>{let o=r[t.toLowerCase()];if(t.includes("_")){const a=t.split("_");o=r[a[0].toLowerCase()],void 0!==o&&e[o].constructor===Object&&(i[o]=n(a,1,e[o],s[`td${t}`]))}else void 0!==o&&(i[o]=s[`td${t}`])})),this._mergeOptions(i,e)}static normalizeObject(t){const e=(s,i,o,a)=>{const n=t(o)[s[i].toLowerCase()],r={};return void 0===n||(o[n].constructor===Object?(i++,r[n]=e(s,i,o[n],a)):r[n]=a),r};return e}static _dateTypeCheck(t,e){return b(t,e)}static _typeCheckDateArray(t,e,s,i){return _(t,e,s,i)}static _typeCheckNumberArray(t,e,s){return k(t,e,s)}static dateConversion(t,e,s){return D(t,e,s)}static getFlattenDefaultOptions(){if(this._flattenDefaults)return this._flattenDefaults;const t=(e,s=[])=>Array.isArray(e)?[]:Object(e)===e?Object.entries(e).flatMap((([e,i])=>t(i,[...s,e]))):s.join(".");return this._flattenDefaults=t(w),this._flattenDefaults}static _validateConflicts(t){!t.display.sideBySide||t.display.components.clock&&(t.display.components.hours||t.display.components.minutes||t.display.components.seconds)||a.errorMessages.conflictingConfiguration("Cannot use side by side mode without the clock components"),t.restrictions.minDate&&t.restrictions.maxDate&&(t.restrictions.minDate.isAfter(t.restrictions.maxDate)&&a.errorMessages.conflictingConfiguration("minDate is after maxDate"),t.restrictions.maxDate.isBefore(t.restrictions.minDate)&&a.errorMessages.conflictingConfiguration("maxDate is before minDate")),t.multipleDates&&t.dateRange&&a.errorMessages.conflictingConfiguration('Cannot uss option "multipleDates" with "dateRange"')}}H.ignoreProperties=["meta","dayViewHeaderFormat","container","dateForms","ordinal"],H.isValue=t=>null!=t;class z{constructor(){this._dates=[],this.optionsStore=u.locate(y),this.validation=u.locate(g),this._eventEmitters=u.locate(f)}get picked(){return[...this._dates]}get lastPicked(){return this._dates[this.lastPickedIndex]?.clone}get lastPickedIndex(){return 0===this._dates.length?0:this._dates.length-1}formatInput(t){return t?(t.localization=this.optionsStore.options.localization,t.format()):""}parseInput(t){return H.dateConversion(t,"input",this.optionsStore.options.localization)}setFromInput(t,e){if(!t)return void this.setValue(void 0,e);const s=this.parseInput(t);s&&(s.setLocalization(this.optionsStore.options.localization),this.setValue(s,e))}add(t){this._dates.push(t)}isPicked(t,e){if(!h.isValid(t))return!1;if(!e)return void 0!==this._dates.find((e=>e.isSame(t)));const s=c(e),i=t.format(s);return void 0!==this._dates.map((t=>t.format(s))).find((t=>t===i))}pickedIndex(t,e){if(!h.isValid(t))return-1;if(!e)return this._dates.map((t=>t.valueOf())).indexOf(t.valueOf());const s=c(e),i=t.format(s);return this._dates.map((t=>t.format(s))).indexOf(i)}clear(){this.optionsStore.unset=!0,this._eventEmitters.triggerEvent.emit({type:a.events.change,date:void 0,oldDate:this.lastPicked,isClear:!0,isValid:!0}),this._dates=[],this.optionsStore.input&&(this.optionsStore.input.value=""),this._eventEmitters.updateDisplay.emit("all")}static getStartEndYear(t,e){const s=t/10,i=Math.floor(e/t)*t;return[i,i+9*s,Math.floor(e/s)*s]}updateInput(t){if(!this.optionsStore.input)return;let e=this.formatInput(t);(this.optionsStore.options.multipleDates||this.optionsStore.options.dateRange)&&(e=this._dates.map((t=>this.formatInput(t))).join(this.optionsStore.options.multipleDatesSeparator)),this.optionsStore.input.value!=e&&(this.optionsStore.input.value=e)}setValue(t,e){const s=void 0===e,i=!t&&s;let o=this.optionsStore.unset?null:this._dates[e]?.clone;if(!o&&!this.optionsStore.unset&&s&&i&&(o=this.lastPicked),t&&o?.isSame(t))return void this.updateInput(t);if(!t)return void this._setValueNull(i,e,o);e=e||0,t=t.clone,1!==this.optionsStore.options.stepping&&(t.minutes=Math.round(t.minutes/this.optionsStore.options.stepping)*this.optionsStore.options.stepping,t.startOf(n.minutes));const r=s=>{this._dates[e]=t,this._eventEmitters.updateViewDate.emit(t.clone),this.updateInput(t),this.optionsStore.unset=!1,this._eventEmitters.updateDisplay.emit("all"),this._eventEmitters.triggerEvent.emit({type:a.events.change,date:t,oldDate:o,isClear:i,isValid:s})};this.validation.isValid(t)&&this.validation.dateRangeIsValid(this.picked,e,t)?r(!0):(this.optionsStore.options.keepInvalid&&r(!1),this._eventEmitters.triggerEvent.emit({type:a.events.error,reason:a.errorMessages.failedToSetInvalidDate,date:t,oldDate:o}))}_setValueNull(t,e,s){!this.optionsStore.options.multipleDates||1===this._dates.length||t?(this.optionsStore.unset=!0,this._dates=[]):this._dates.splice(e,1),this.updateInput(),this._eventEmitters.triggerEvent.emit({type:a.events.change,date:void 0,oldDate:s,isClear:t,isValid:!0}),this._eventEmitters.updateDisplay.emit("all")}}var x;!function(t){t.next="next",t.previous="previous",t.changeCalendarView="changeCalendarView",t.selectMonth="selectMonth",t.selectYear="selectYear",t.selectDecade="selectDecade",t.selectDay="selectDay",t.selectHour="selectHour",t.selectMinute="selectMinute",t.selectSecond="selectSecond",t.incrementHours="incrementHours",t.incrementMinutes="incrementMinutes",t.incrementSeconds="incrementSeconds",t.decrementHours="decrementHours",t.decrementMinutes="decrementMinutes",t.decrementSeconds="decrementSeconds",t.toggleMeridiem="toggleMeridiem",t.togglePicker="togglePicker",t.showClock="showClock",t.showHours="showHours",t.showMinutes="showMinutes",t.showSeconds="showSeconds",t.clear="clear",t.close="close",t.today="today"}(x||(x={}));var I=x;class P{constructor(){this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");if(t.classList.add(a.css.daysContainer),t.append(...this._daysOfTheWeek()),this.optionsStore.options.display.calendarWeeks){const e=document.createElement("div");e.classList.add(a.css.calendarWeeks,a.css.noHighlight),t.appendChild(e)}const{rangeHoverEvent:e,rangeHoverOutEvent:s}=this.handleMouseEvents(t);for(let i=0;i<42;i++){if(0!==i&&i%7==0&&this.optionsStore.options.display.calendarWeeks){const e=document.createElement("div");e.classList.add(a.css.calendarWeeks,a.css.noHighlight),t.appendChild(e)}const o=document.createElement("div");o.setAttribute("data-action",I.selectDay),t.appendChild(o),matchMedia("(hover: hover)").matches&&this.optionsStore.options.dateRange&&(o.addEventListener("mouseover",e),o.addEventListener("mouseout",s))}return t}_update(t,e){const s=t.getElementsByClassName(a.css.daysContainer)[0];this._updateCalendarView(s);const i=this.optionsStore.viewDate.clone.startOf(n.month).startOf("weekDay",this.optionsStore.options.localization.startOfTheWeek).manipulate(12,n.hours);this._handleCalendarWeeks(s,i.clone),s.querySelectorAll(`[data-action="${I.selectDay}"]`).forEach((t=>{const s=[];s.push(a.css.day),i.isBefore(this.optionsStore.viewDate,n.month)&&s.push(a.css.old),i.isAfter(this.optionsStore.viewDate,n.month)&&s.push(a.css.new),this.optionsStore.unset||this.optionsStore.options.dateRange||!this.dates.isPicked(i,n.date)||s.push(a.css.active),this.validation.isValid(i,n.date)||s.push(a.css.disabled),i.isSame(new h,n.date)&&s.push(a.css.today),0!==i.weekDay&&6!==i.weekDay||s.push(a.css.weekend),this._handleDateRange(i,s),e(n.date,i,s,t),t.classList.remove(...t.classList),t.classList.add(...s),t.setAttribute("data-value",this._dateToDataValue(i)),t.setAttribute("data-day",`${i.date}`),t.innerText=i.parts(void 0,{day:"numeric"}).day,i.manipulate(1,n.date)}))}_dateToDataValue(t){return h.isValid(t)?`${t.year}-${t.monthFormatted}-${t.dateFormatted}`:""}_handleDateRange(t,e){const s=this.dates.picked[0],i=this.dates.picked[1];this.optionsStore.options.dateRange&&(t.isBetween(s,i,n.date)&&e.push(a.css.rangeIn),t.isSame(s,n.date)&&e.push(a.css.rangeStart),t.isSame(i,n.date)&&e.push(a.css.rangeEnd))}handleMouseEvents(t){return{rangeHoverEvent:e=>{const s=e?.currentTarget;if(1!==this.dates.picked.length||s.classList.contains(a.css.disabled))return;const i=[...t.querySelectorAll(".day")],o=s.getAttribute("data-value"),r=h.fromString(o,{format:"yyyy-MM-dd"}),d=i.findIndex((t=>t.getAttribute("data-value")===o)),c=this.dates.picked[0],l=this.dates.picked[1],p=this._dateToDataValue(c),u=i.findIndex((t=>t.getAttribute("data-value")===p)),m=i[u];let y;r.isSame(c,n.date)||s.classList.remove(a.css.rangeStart),r.isSame(l,n.date)||s.classList.remove(a.css.rangeEnd),r.isBefore(c)?(s.classList.add(a.css.rangeStart),m?.classList.remove(a.css.rangeStart),m?.classList.add(a.css.rangeEnd),y=(t,e)=>e>d&&e<u):(s.classList.add(a.css.rangeEnd),m?.classList.remove(a.css.rangeEnd),m?.classList.add(a.css.rangeStart),y=(t,e)=>e<d&&e>u),i.filter(y).forEach((t=>{t.classList.add(a.css.rangeIn)}))},rangeHoverOutEvent:e=>{const s=[...t.querySelectorAll(".day")];if(1===this.dates.picked.length&&s.forEach((t=>t.classList.remove(a.css.rangeIn))),1!==this.dates.picked.length)return;const i=e?.currentTarget,o=new h(i.getAttribute("data-value"));o.isSame(this.dates.picked[0],n.date)||i.classList.remove(a.css.rangeStart),o.isSame(this.dates.picked[1],n.date)||i.classList.remove(a.css.rangeEnd)}}}_updateCalendarView(t){if("calendar"!==this.optionsStore.currentView)return;const[e,s,i]=t.parentElement.getElementsByClassName(a.css.calendarHeader)[0].getElementsByTagName("div");s.setAttribute(a.css.daysContainer,this.optionsStore.viewDate.format(this.optionsStore.options.localization.dayViewHeaderFormat)),this.optionsStore.options.display.components.month?s.classList.remove(a.css.disabled):s.classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(-1,n.month),n.month)?e.classList.remove(a.css.disabled):e.classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(1,n.month),n.month)?i.classList.remove(a.css.disabled):i.classList.add(a.css.disabled)}_daysOfTheWeek(){const t=this.optionsStore.viewDate.clone.startOf("weekDay",this.optionsStore.options.localization.startOfTheWeek).startOf(n.date),e=[];if(document.createElement("div"),this.optionsStore.options.display.calendarWeeks){const t=document.createElement("div");t.classList.add(a.css.calendarWeeks,a.css.noHighlight),t.innerText="#",e.push(t)}for(let s=0;s<7;s++){const s=document.createElement("div");s.classList.add(a.css.dayOfTheWeek,a.css.noHighlight);let i=t.format({weekday:"short"});this.optionsStore.options.localization.maxWeekdayLength>0&&(i=i.substring(0,this.optionsStore.options.localization.maxWeekdayLength)),s.innerText=i,t.manipulate(1,n.date),e.push(s)}return e}_handleCalendarWeeks(t,e){[...t.querySelectorAll(`.${a.css.calendarWeeks}`)].filter((t=>"#"!==t.innerText)).forEach((t=>{t.innerText=`${e.week}`,e.manipulate(7,n.date)}))}}class N{constructor(){this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.monthsContainer);for(let e=0;e<12;e++){const e=document.createElement("div");e.setAttribute("data-action",I.selectMonth),t.appendChild(e)}return t}_update(t,e){const s=t.getElementsByClassName(a.css.monthsContainer)[0];if("months"===this.optionsStore.currentView){const[t,e,i]=s.parentElement.getElementsByClassName(a.css.calendarHeader)[0].getElementsByTagName("div");e.setAttribute(a.css.monthsContainer,this.optionsStore.viewDate.format({year:"numeric"})),this.optionsStore.options.display.components.year?e.classList.remove(a.css.disabled):e.classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(-1,n.year),n.year)?t.classList.remove(a.css.disabled):t.classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(1,n.year),n.year)?i.classList.remove(a.css.disabled):i.classList.add(a.css.disabled)}const i=this.optionsStore.viewDate.clone.startOf(n.year);s.querySelectorAll(`[data-action="${I.selectMonth}"]`).forEach(((t,s)=>{const o=[];o.push(a.css.month),!this.optionsStore.unset&&this.dates.isPicked(i,n.month)&&o.push(a.css.active),this.validation.isValid(i,n.month)||o.push(a.css.disabled),e(n.month,i,o,t),t.classList.remove(...t.classList),t.classList.add(...o),t.setAttribute("data-value",`${s}`),t.innerText=`${i.format({month:"short"})}`,i.manipulate(1,n.month)}))}}class F{constructor(){this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.yearsContainer);for(let e=0;e<12;e++){const e=document.createElement("div");e.setAttribute("data-action",I.selectYear),t.appendChild(e)}return t}_update(t,e){this._startYear=this.optionsStore.viewDate.clone.manipulate(-1,n.year),this._endYear=this.optionsStore.viewDate.clone.manipulate(10,n.year);const s=t.getElementsByClassName(a.css.yearsContainer)[0];if("years"===this.optionsStore.currentView){const[t,e,i]=s.parentElement.getElementsByClassName(a.css.calendarHeader)[0].getElementsByTagName("div");e.setAttribute(a.css.yearsContainer,`${this._startYear.format({year:"numeric"})}-${this._endYear.format({year:"numeric"})}`),this.optionsStore.options.display.components.decades?e.classList.remove(a.css.disabled):e.classList.add(a.css.disabled),this.validation.isValid(this._startYear,n.year)?t.classList.remove(a.css.disabled):t.classList.add(a.css.disabled),this.validation.isValid(this._endYear,n.year)?i.classList.remove(a.css.disabled):i.classList.add(a.css.disabled)}const i=this.optionsStore.viewDate.clone.startOf(n.year).manipulate(-1,n.year);s.querySelectorAll(`[data-action="${I.selectYear}"]`).forEach((t=>{const s=[];s.push(a.css.year),!this.optionsStore.unset&&this.dates.isPicked(i,n.year)&&s.push(a.css.active),this.validation.isValid(i,n.year)||s.push(a.css.disabled),e(n.year,i,s,t),t.classList.remove(...t.classList),t.classList.add(...s),t.setAttribute("data-value",`${i.year}`),t.innerText=i.format({year:"numeric"}),i.manipulate(1,n.year)}))}}class B{constructor(){this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.decadesContainer);for(let e=0;e<12;e++){const e=document.createElement("div");e.setAttribute("data-action",I.selectDecade),t.appendChild(e)}return t}_update(t,e){const[s,i]=z.getStartEndYear(100,this.optionsStore.viewDate.year);this._startDecade=this.optionsStore.viewDate.clone.startOf(n.year),this._startDecade.year=s,this._endDecade=this.optionsStore.viewDate.clone.startOf(n.year),this._endDecade.year=i;const o=t.getElementsByClassName(a.css.decadesContainer)[0],[r,d,c]=o.parentElement.getElementsByClassName(a.css.calendarHeader)[0].getElementsByTagName("div");"decades"===this.optionsStore.currentView&&(d.setAttribute(a.css.decadesContainer,`${this._startDecade.format({year:"numeric"})}-${this._endDecade.format({year:"numeric"})}`),this.validation.isValid(this._startDecade,n.year)?r.classList.remove(a.css.disabled):r.classList.add(a.css.disabled),this.validation.isValid(this._endDecade,n.year)?c.classList.remove(a.css.disabled):c.classList.add(a.css.disabled));const l=this.dates.picked.map((t=>t.year));o.querySelectorAll(`[data-action="${I.selectDecade}"]`).forEach(((t,s)=>{if(0===s)return t.classList.add(a.css.old),this._startDecade.year-10<0?(t.textContent=" ",r.classList.add(a.css.disabled),t.classList.add(a.css.disabled),void t.setAttribute("data-value","")):(t.innerText=this._startDecade.clone.manipulate(-10,n.year).format({year:"numeric"}),void t.setAttribute("data-value",`${this._startDecade.year}`));const i=[];i.push(a.css.decade);const o=this._startDecade.year,d=this._startDecade.year+9;!this.optionsStore.unset&&l.filter((t=>t>=o&&t<=d)).length>0&&i.push(a.css.active),e("decade",this._startDecade,i,t),t.classList.remove(...t.classList),t.classList.add(...i),t.setAttribute("data-value",`${this._startDecade.year}`),t.innerText=`${this._startDecade.format({year:"numeric"})}`,this._startDecade.manipulate(10,n.year)}))}}class W{constructor(){this._gridColumns="",this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g)}getPicker(t){const e=document.createElement("div");return e.classList.add(a.css.clockContainer),e.append(...this._grid(t)),e}_update(t){const e=t.getElementsByClassName(a.css.clockContainer)[0];let s=this.dates.lastPicked?.clone;if(!s&&this.optionsStore.options.useCurrent&&(s=this.optionsStore.viewDate.clone),e.querySelectorAll(".disabled").forEach((t=>t.classList.remove(a.css.disabled))),this.optionsStore.options.display.components.hours&&(this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(1,n.hours),n.hours)||e.querySelector(`[data-action=${I.incrementHours}]`).classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(-1,n.hours),n.hours)||e.querySelector(`[data-action=${I.decrementHours}]`).classList.add(a.css.disabled),e.querySelector(`[data-time-component=${n.hours}]`).innerText=s?s.getHoursFormatted(this.optionsStore.options.localization.hourCycle):"--"),this.optionsStore.options.display.components.minutes&&(this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(1,n.minutes),n.minutes)||e.querySelector(`[data-action=${I.incrementMinutes}]`).classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(-1,n.minutes),n.minutes)||e.querySelector(`[data-action=${I.decrementMinutes}]`).classList.add(a.css.disabled),e.querySelector(`[data-time-component=${n.minutes}]`).innerText=s?s.minutesFormatted:"--"),this.optionsStore.options.display.components.seconds&&(this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(1,n.seconds),n.seconds)||e.querySelector(`[data-action=${I.incrementSeconds}]`).classList.add(a.css.disabled),this.validation.isValid(this.optionsStore.viewDate.clone.manipulate(-1,n.seconds),n.seconds)||e.querySelector(`[data-action=${I.decrementSeconds}]`).classList.add(a.css.disabled),e.querySelector(`[data-time-component=${n.seconds}]`).innerText=s?s.secondsFormatted:"--"),this.optionsStore.isTwelveHour){const t=e.querySelector(`[data-action=${I.toggleMeridiem}]`),i=(s||this.optionsStore.viewDate).clone;t.innerText=i.meridiem(),this.validation.isValid(i.manipulate(i.hours>=12?-12:12,n.hours))?t.classList.remove(a.css.disabled):t.classList.add(a.css.disabled)}e.style.gridTemplateAreas=`"${this._gridColumns}"`}_grid(t){this._gridColumns="";const e=[],s=[],i=[],o=document.createElement("div"),r=t(this.optionsStore.options.display.icons.up),d=t(this.optionsStore.options.display.icons.down);o.classList.add(a.css.separator,a.css.noHighlight);const c=o.cloneNode(!0);c.innerHTML=":";const l=(t=!1)=>t?c.cloneNode(!0):o.cloneNode(!0);if(this.optionsStore.options.display.components.hours){let t=document.createElement("div");t.setAttribute("title",this.optionsStore.options.localization.incrementHour),t.setAttribute("data-action",I.incrementHours),t.appendChild(r.cloneNode(!0)),e.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.pickHour),t.setAttribute("data-action",I.showHours),t.setAttribute("data-time-component",n.hours),s.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.decrementHour),t.setAttribute("data-action",I.decrementHours),t.appendChild(d.cloneNode(!0)),i.push(t),this._gridColumns+="a"}if(this.optionsStore.options.display.components.minutes){this._gridColumns+=" a",this.optionsStore.options.display.components.hours&&(e.push(l()),s.push(l(!0)),i.push(l()),this._gridColumns+=" a");let t=document.createElement("div");t.setAttribute("title",this.optionsStore.options.localization.incrementMinute),t.setAttribute("data-action",I.incrementMinutes),t.appendChild(r.cloneNode(!0)),e.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.pickMinute),t.setAttribute("data-action",I.showMinutes),t.setAttribute("data-time-component",n.minutes),s.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.decrementMinute),t.setAttribute("data-action",I.decrementMinutes),t.appendChild(d.cloneNode(!0)),i.push(t)}if(this.optionsStore.options.display.components.seconds){this._gridColumns+=" a",this.optionsStore.options.display.components.minutes&&(e.push(l()),s.push(l(!0)),i.push(l()),this._gridColumns+=" a");let t=document.createElement("div");t.setAttribute("title",this.optionsStore.options.localization.incrementSecond),t.setAttribute("data-action",I.incrementSeconds),t.appendChild(r.cloneNode(!0)),e.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.pickSecond),t.setAttribute("data-action",I.showSeconds),t.setAttribute("data-time-component",n.seconds),s.push(t),t=document.createElement("div"),t.setAttribute("title",this.optionsStore.options.localization.decrementSecond),t.setAttribute("data-action",I.decrementSeconds),t.appendChild(d.cloneNode(!0)),i.push(t)}if(this.optionsStore.isTwelveHour){this._gridColumns+=" a";let t=l();e.push(t);const o=document.createElement("button");o.setAttribute("type","button"),o.setAttribute("title",this.optionsStore.options.localization.toggleMeridiem),o.setAttribute("data-action",I.toggleMeridiem),o.setAttribute("tabindex","-1"),a.css.toggleMeridiem.includes(",")?o.classList.add(...a.css.toggleMeridiem.split(",")):o.classList.add(a.css.toggleMeridiem),t=document.createElement("div"),t.classList.add(a.css.noHighlight),t.appendChild(o),s.push(t),t=l(),i.push(t)}return this._gridColumns=this._gridColumns.trim(),[...e,...s,...i]}}class q{constructor(){this.optionsStore=u.locate(y),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.hourContainer);for(let e=0;e<(this.optionsStore.isTwelveHour?12:24);e++){const e=document.createElement("div");e.setAttribute("data-action",I.selectHour),t.appendChild(e)}return t}_update(t,e){const s=t.getElementsByClassName(a.css.hourContainer)[0],i=this.optionsStore.viewDate.clone.startOf(n.date);s.querySelectorAll(`[data-action="${I.selectHour}"]`).forEach((t=>{const s=[];s.push(a.css.hour),this.validation.isValid(i,n.hours)||s.push(a.css.disabled),e(n.hours,i,s,t),t.classList.remove(...t.classList),t.classList.add(...s),t.setAttribute("data-value",`${i.hours}`),t.innerText=i.getHoursFormatted(this.optionsStore.options.localization.hourCycle),i.manipulate(1,n.hours)}))}}class Y{constructor(){this.optionsStore=u.locate(y),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.minuteContainer);const e=1===this.optionsStore.options.stepping?5:this.optionsStore.options.stepping;for(let s=0;s<60/e;s++){const e=document.createElement("div");e.setAttribute("data-action",I.selectMinute),t.appendChild(e)}return t}_update(t,e){const s=t.getElementsByClassName(a.css.minuteContainer)[0],i=this.optionsStore.viewDate.clone.startOf(n.hours),o=1===this.optionsStore.options.stepping?5:this.optionsStore.options.stepping;s.querySelectorAll(`[data-action="${I.selectMinute}"]`).forEach((t=>{const s=[];s.push(a.css.minute),this.validation.isValid(i,n.minutes)||s.push(a.css.disabled),e(n.minutes,i,s,t),t.classList.remove(...t.classList),t.classList.add(...s),t.setAttribute("data-value",`${i.minutes}`),t.innerText=i.minutesFormatted,i.manipulate(o,n.minutes)}))}}class j{constructor(){this.optionsStore=u.locate(y),this.validation=u.locate(g)}getPicker(){const t=document.createElement("div");t.classList.add(a.css.secondContainer);for(let e=0;e<12;e++){const e=document.createElement("div");e.setAttribute("data-action",I.selectSecond),t.appendChild(e)}return t}_update(t,e){const s=t.getElementsByClassName(a.css.secondContainer)[0],i=this.optionsStore.viewDate.clone.startOf(n.minutes);s.querySelectorAll(`[data-action="${I.selectSecond}"]`).forEach((t=>{const s=[];s.push(a.css.second),this.validation.isValid(i,n.seconds)||s.push(a.css.disabled),e(n.seconds,i,s,t),t.classList.remove(...t.classList),t.classList.add(...s),t.setAttribute("data-value",`${i.seconds}`),t.innerText=i.secondsFormatted,i.manipulate(5,n.seconds)}))}}class U{static toggle(t){t.classList.contains(a.css.show)?this.hide(t):this.show(t)}static showImmediately(t){t.classList.remove(a.css.collapsing),t.classList.add(a.css.collapse,a.css.show),t.style.height=""}static show(t){if(t.classList.contains(a.css.collapsing)||t.classList.contains(a.css.show))return;t.style.height="0",t.classList.remove(a.css.collapse),t.classList.add(a.css.collapsing),setTimeout((()=>{U.showImmediately(t)}),this.getTransitionDurationFromElement(t)),t.style.height=`${t.scrollHeight}px`}static hideImmediately(t){t&&(t.classList.remove(a.css.collapsing,a.css.show),t.classList.add(a.css.collapse))}static hide(t){if(t.classList.contains(a.css.collapsing)||!t.classList.contains(a.css.show))return;t.style.height=`${t.getBoundingClientRect().height}px`;t.offsetHeight,t.classList.remove(a.css.collapse,a.css.show),t.classList.add(a.css.collapsing),t.style.height="",setTimeout((()=>{U.hideImmediately(t)}),this.getTransitionDurationFromElement(t))}}U.getTransitionDurationFromElement=t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:s}=window.getComputedStyle(t);const i=Number.parseFloat(e),o=Number.parseFloat(s);return i||o?(e=e.split(",")[0],s=s.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(s))):0};class R{constructor(){this._isVisible=!1,this._documentClickEvent=t=>{this.optionsStore.options.debug||window.debug||!this._isVisible||t.composedPath().includes(this.widget)||t.composedPath()?.includes(this.optionsStore.element)||this.hide()},this._actionsClickEvent=t=>{this._eventEmitters.action.emit({e:t})},this.optionsStore=u.locate(y),this.validation=u.locate(g),this.dates=u.locate(z),this.dateDisplay=u.locate(P),this.monthDisplay=u.locate(N),this.yearDisplay=u.locate(F),this.decadeDisplay=u.locate(B),this.timeDisplay=u.locate(W),this.hourDisplay=u.locate(q),this.minuteDisplay=u.locate(Y),this.secondDisplay=u.locate(j),this._eventEmitters=u.locate(f),this._widget=void 0,this._eventEmitters.updateDisplay.subscribe((t=>{this._update(t)}))}get widget(){return this._widget}get dateContainer(){return this.widget?.querySelector(`div.${a.css.dateContainer}`)}get timeContainer(){return this.widget?.querySelector(`div.${a.css.timeContainer}`)}get isVisible(){return this._isVisible}_update(t){if(this.widget)switch(t){case n.seconds:this.secondDisplay._update(this.widget,this.paint);break;case n.minutes:this.minuteDisplay._update(this.widget,this.paint);break;case n.hours:this.hourDisplay._update(this.widget,this.paint);break;case n.date:this.dateDisplay._update(this.widget,this.paint);break;case n.month:this.monthDisplay._update(this.widget,this.paint);break;case n.year:this.yearDisplay._update(this.widget,this.paint);break;case"decade":this.decadeDisplay._update(this.widget,this.paint);break;case"clock":if(!this._hasTime)break;this.timeDisplay._update(this.widget),this._update(n.hours),this._update(n.minutes),this._update(n.seconds);break;case"calendar":this._update(n.date),this._update(n.year),this._update(n.month),this.decadeDisplay._update(this.widget,this.paint),this._updateCalendarHeader();break;case"all":this._hasTime&&this._update("clock"),this._hasDate&&this._update("calendar")}}paint(t,e,s,i){}show(){if(null==this.widget){if(this._showSetDefaultIfNeeded(),this._buildWidget(),this._updateTheme(),this._showSetupViewMode(),this.optionsStore.options.display.inline)this.optionsStore.element.appendChild(this.widget);else{const t=this.optionsStore.options?.container||document.body,e=this.optionsStore.options?.display?.placement||"bottom";t.appendChild(this.widget),this.createPopup(this.optionsStore.element,this.widget,{modifiers:[{name:"eventListeners",enabled:!0}],placement:"rtl"===document.documentElement.dir?`${e}-end`:`${e}-start`}).then()}"clock"==this.optionsStore.options.display.viewMode&&this._eventEmitters.action.emit({e:null,action:I.showClock}),this.widget.querySelectorAll("[data-action]").forEach((t=>t.addEventListener("click",this._actionsClickEvent))),this._hasTime&&this.optionsStore.options.display.sideBySide&&(this.timeDisplay._update(this.widget),this.widget.getElementsByClassName(a.css.clockContainer)[0].style.display="grid")}this.widget.classList.add(a.css.show),this.optionsStore.options.display.inline||(this.updatePopup(),document.addEventListener("click",this._documentClickEvent)),this._eventEmitters.triggerEvent.emit({type:a.events.show}),this._isVisible=!0}_showSetupViewMode(){const t=this._hasTime&&!this._hasDate;t?(this.optionsStore.currentView="clock",this._eventEmitters.action.emit({e:null,action:I.showClock})):this.optionsStore.currentCalendarViewMode||(this.optionsStore.currentCalendarViewMode=this.optionsStore.minimumCalendarViewMode),t||"clock"===this.optionsStore.options.display.viewMode||(this._hasTime&&(this.optionsStore.options.display.sideBySide?U.show(this.timeContainer):U.hideImmediately(this.timeContainer)),U.show(this.dateContainer)),this._hasDate&&this._showMode()}_showSetDefaultIfNeeded(){if(0==this.dates.picked.length){if(this.optionsStore.options.useCurrent&&!this.optionsStore.options.defaultDate){const t=(new h).setLocalization(this.optionsStore.options.localization);if(!this.optionsStore.options.keepInvalid){let e=0,s=1;for(this.optionsStore.options.restrictions.maxDate?.isBefore(t)&&(s=-1);!this.validation.isValid(t)&&e>31;)t.manipulate(s,n.date),e++}this.dates.setValue(t)}this.optionsStore.options.defaultDate&&this.dates.setValue(this.optionsStore.options.defaultDate)}}async createPopup(t,e,i){let o;if(window?.Popper)o=window?.Popper?.createPopper;else{const{createPopper:t}=await s.e(200).then(s.bind(s,200));o=t}o&&(this._popperInstance=o(t,e,i))}updatePopup(){this._popperInstance?.update()}_showMode(t){if(!this.widget)return;if(t){const e=Math.max(this.optionsStore.minimumCalendarViewMode,Math.min(3,this.optionsStore.currentCalendarViewMode+t));if(this.optionsStore.currentCalendarViewMode==e)return;this.optionsStore.currentCalendarViewMode=e}this.widget.querySelectorAll(`.${a.css.dateContainer} > div:not(.${a.css.calendarHeader}), .${a.css.timeContainer} > div:not(.${a.css.clockContainer})`).forEach((t=>t.style.display="none"));const e=m[this.optionsStore.currentCalendarViewMode],s=this.widget.querySelector(`.${e.className}`);switch(e.className){case a.css.decadesContainer:this.decadeDisplay._update(this.widget,this.paint);break;case a.css.yearsContainer:this.yearDisplay._update(this.widget,this.paint);break;case a.css.monthsContainer:this.monthDisplay._update(this.widget,this.paint);break;case a.css.daysContainer:this.dateDisplay._update(this.widget,this.paint)}s.style.display="grid",this.optionsStore.options.display.sideBySide&&(this.widget.querySelectorAll(`.${a.css.clockContainer}`)[0].style.display="grid"),this._updateCalendarHeader(),this._eventEmitters.viewUpdate.emit()}_updateTheme(t){if(this.widget){if(t){if(this.optionsStore.options.display.theme===t)return;this.optionsStore.options.display.theme=t}this.widget.classList.remove("light","dark"),this.widget.classList.add(this._getThemeClass()),"auto"===this.optionsStore.options.display.theme?window.matchMedia(a.css.isDarkPreferredQuery).addEventListener("change",(()=>this._updateTheme())):window.matchMedia(a.css.isDarkPreferredQuery).removeEventListener("change",(()=>this._updateTheme()))}}_getThemeClass(){const t=this.optionsStore.options.display.theme||"auto",e=window.matchMedia&&window.matchMedia(a.css.isDarkPreferredQuery).matches;switch(t){case"light":return a.css.lightTheme;case"dark":return a.css.darkTheme;case"auto":return e?a.css.darkTheme:a.css.lightTheme}}_updateCalendarHeader(){if(!this._hasDate)return;const t=[...this.widget.querySelector(`.${a.css.dateContainer} div[style*="display: grid"]`).classList].find((t=>t.startsWith(a.css.dateContainer))),[e,s,i]=this.widget.getElementsByClassName(a.css.calendarHeader)[0].getElementsByTagName("div");switch(t){case a.css.decadesContainer:e.setAttribute("title",this.optionsStore.options.localization.previousCentury),s.setAttribute("title",""),i.setAttribute("title",this.optionsStore.options.localization.nextCentury);break;case a.css.yearsContainer:e.setAttribute("title",this.optionsStore.options.localization.previousDecade),s.setAttribute("title",this.optionsStore.options.localization.selectDecade),i.setAttribute("title",this.optionsStore.options.localization.nextDecade);break;case a.css.monthsContainer:e.setAttribute("title",this.optionsStore.options.localization.previousYear),s.setAttribute("title",this.optionsStore.options.localization.selectYear),i.setAttribute("title",this.optionsStore.options.localization.nextYear);break;case a.css.daysContainer:e.setAttribute("title",this.optionsStore.options.localization.previousMonth),s.setAttribute("title",this.optionsStore.options.localization.selectMonth),i.setAttribute("title",this.optionsStore.options.localization.nextMonth),s.setAttribute(t,this.optionsStore.viewDate.format(this.optionsStore.options.localization.dayViewHeaderFormat))}s.innerText=s.getAttribute(t)}hide(){this.widget&&this._isVisible&&(this.widget.classList.remove(a.css.show),this._isVisible&&(this._eventEmitters.triggerEvent.emit({type:a.events.hide,date:this.optionsStore.unset?null:this.dates.lastPicked?.clone}),this._isVisible=!1),document.removeEventListener("click",this._documentClickEvent))}toggle(){return this._isVisible?this.hide():this.show()}_dispose(){document.removeEventListener("click",this._documentClickEvent),this.widget&&(this.widget.querySelectorAll("[data-action]").forEach((t=>t.removeEventListener("click",this._actionsClickEvent))),this.widget.parentNode.removeChild(this.widget),this._widget=void 0)}_buildWidget(){const t=document.createElement("div");t.classList.add(a.css.widget);const e=document.createElement("div");e.classList.add(a.css.dateContainer),e.append(this.getHeadTemplate(),this.decadeDisplay.getPicker(),this.yearDisplay.getPicker(),this.monthDisplay.getPicker(),this.dateDisplay.getPicker());const s=document.createElement("div");s.classList.add(a.css.timeContainer),s.appendChild(this.timeDisplay.getPicker(this._iconTag.bind(this))),s.appendChild(this.hourDisplay.getPicker()),s.appendChild(this.minuteDisplay.getPicker()),s.appendChild(this.secondDisplay.getPicker());const i=document.createElement("div");if(i.classList.add(a.css.toolbar),i.append(...this.getToolbarElements()),this.optionsStore.options.display.inline&&t.classList.add(a.css.inline),this.optionsStore.options.display.calendarWeeks&&t.classList.add("calendarWeeks"),this.optionsStore.options.display.sideBySide&&this._hasDateAndTime)return void this._buildWidgetSideBySide(t,e,s,i);"top"===this.optionsStore.options.display.toolbarPlacement&&t.appendChild(i);const o=(e,s,i,o)=>{e&&(s&&(i.classList.add(a.css.collapse),o&&i.classList.add(a.css.show)),t.appendChild(i))};o(this._hasDate,this._hasTime,e,"clock"!==this.optionsStore.options.display.viewMode),o(this._hasTime,this._hasDate,s,"clock"===this.optionsStore.options.display.viewMode),"bottom"===this.optionsStore.options.display.toolbarPlacement&&t.appendChild(i);const n=document.createElement("div");n.classList.add("arrow"),n.setAttribute("data-popper-arrow",""),t.appendChild(n),this._widget=t}_buildWidgetSideBySide(t,e,s,i){t.classList.add(a.css.sideBySide),"top"===this.optionsStore.options.display.toolbarPlacement&&t.appendChild(i);const o=document.createElement("div");o.classList.add("td-row"),e.classList.add("td-half"),s.classList.add("td-half"),o.appendChild(e),o.appendChild(s),t.appendChild(o),"bottom"===this.optionsStore.options.display.toolbarPlacement&&t.appendChild(i),this._widget=t}get _hasTime(){return this.optionsStore.options.display.components.clock&&(this.optionsStore.options.display.components.hours||this.optionsStore.options.display.components.minutes||this.optionsStore.options.display.components.seconds)}get _hasDate(){return this.optionsStore.options.display.components.calendar&&(this.optionsStore.options.display.components.year||this.optionsStore.options.display.components.month||this.optionsStore.options.display.components.date)}get _hasDateAndTime(){return this._hasDate&&this._hasTime}getToolbarElements(){const t=[];if(this.optionsStore.options.display.buttons.today){const e=document.createElement("div");e.setAttribute("data-action",I.today),e.setAttribute("title",this.optionsStore.options.localization.today),e.appendChild(this._iconTag(this.optionsStore.options.display.icons.today)),t.push(e)}if(!this.optionsStore.options.display.sideBySide&&this._hasDate&&this._hasTime){let e,s;"clock"===this.optionsStore.options.display.viewMode?(e=this.optionsStore.options.localization.selectDate,s=this.optionsStore.options.display.icons.date):(e=this.optionsStore.options.localization.selectTime,s=this.optionsStore.options.display.icons.time);const i=document.createElement("div");i.setAttribute("data-action",I.togglePicker),i.setAttribute("title",e),i.appendChild(this._iconTag(s)),t.push(i)}if(this.optionsStore.options.display.buttons.clear){const e=document.createElement("div");e.setAttribute("data-action",I.clear),e.setAttribute("title",this.optionsStore.options.localization.clear),e.appendChild(this._iconTag(this.optionsStore.options.display.icons.clear)),t.push(e)}if(this.optionsStore.options.display.buttons.close){const e=document.createElement("div");e.setAttribute("data-action",I.close),e.setAttribute("title",this.optionsStore.options.localization.close),e.appendChild(this._iconTag(this.optionsStore.options.display.icons.close)),t.push(e)}return t}getHeadTemplate(){const t=document.createElement("div");t.classList.add(a.css.calendarHeader);const e=document.createElement("div");e.classList.add(a.css.previous),e.setAttribute("data-action",I.previous),e.appendChild(this._iconTag(this.optionsStore.options.display.icons.previous));const s=document.createElement("div");s.classList.add(a.css.switch),s.setAttribute("data-action",I.changeCalendarView);const i=document.createElement("div");return i.classList.add(a.css.next),i.setAttribute("data-action",I.next),i.appendChild(this._iconTag(this.optionsStore.options.display.icons.next)),t.append(e,s,i),t}_iconTag(t){if("sprites"===this.optionsStore.options.display.icons.type){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),s=document.createElementNS("http://www.w3.org/2000/svg","use");return s.setAttribute("xlink:href",t),s.setAttribute("href",t),e.appendChild(s),e}const e=document.createElement("i");return e.classList.add(...t.split(" ")),e}_rebuild(){const t=this._isVisible;this._dispose(),t&&this.show()}refreshCurrentView(){switch(this._isVisible||this._dispose(),this.optionsStore.currentView){case"clock":this._update("clock");break;case"calendar":this._update(n.date);break;case"months":this._update(n.month);break;case"years":this._update(n.year);break;case"decades":this._update("decade")}}}class Q{constructor(){this.optionsStore=u.locate(y),this.dates=u.locate(z),this.validation=u.locate(g),this.display=u.locate(R),this._eventEmitters=u.locate(f),this._eventEmitters.action.subscribe((t=>{this.do(t.e,t.action)}))}do(t,e){const s=t?.currentTarget;if(s?.classList?.contains(a.css.disabled))return;e=e||s?.dataset?.action;const i=(this.dates.lastPicked||this.optionsStore.viewDate).clone;switch(e){case I.next:case I.previous:this.handleNextPrevious(e);break;case I.changeCalendarView:this.display._showMode(1),this.display._updateCalendarHeader();break;case I.selectMonth:case I.selectYear:case I.selectDecade:this.handleSelectCalendarMode(e,s);break;case I.selectDay:this.handleSelectDay(s);break;case I.selectHour:{let e=+s.dataset.value;i.hours>=12&&this.optionsStore.isTwelveHour&&(e+=12),i.hours=e,this.dates.setValue(i,this.dates.lastPickedIndex),this.hideOrClock(t);break}case I.selectMinute:i.minutes=+s.dataset.value,this.dates.setValue(i,this.dates.lastPickedIndex),this.hideOrClock(t);break;case I.selectSecond:i.seconds=+s.dataset.value,this.dates.setValue(i,this.dates.lastPickedIndex),this.hideOrClock(t);break;case I.incrementHours:this.manipulateAndSet(i,n.hours);break;case I.incrementMinutes:this.manipulateAndSet(i,n.minutes,this.optionsStore.options.stepping);break;case I.incrementSeconds:this.manipulateAndSet(i,n.seconds);break;case I.decrementHours:this.manipulateAndSet(i,n.hours,-1);break;case I.decrementMinutes:this.manipulateAndSet(i,n.minutes,-1*this.optionsStore.options.stepping);break;case I.decrementSeconds:this.manipulateAndSet(i,n.seconds,-1);break;case I.toggleMeridiem:this.manipulateAndSet(i,n.hours,this.dates.lastPicked.hours>=12?-12:12);break;case I.togglePicker:this.handleToggle(s);break;case I.showClock:case I.showHours:case I.showMinutes:case I.showSeconds:this.optionsStore.options.display.sideBySide||"clock"===this.optionsStore.currentView||(U.hideImmediately(this.display.dateContainer),U.showImmediately(this.display.timeContainer)),this.handleShowClockContainers(e);break;case I.clear:this.dates.setValue(null),this.display._updateCalendarHeader();break;case I.close:this.display.hide();break;case I.today:{const t=(new h).setLocalization(this.optionsStore.options.localization);this._eventEmitters.updateViewDate.emit(t),this.validation.isValid(t,n.date)&&this.dates.setValue(t,this.dates.lastPickedIndex);break}}}handleShowClockContainers(t){if(!this.display._hasTime)return void a.errorMessages.throwError("Cannot show clock containers when time is disabled.");this.optionsStore.currentView="clock",this.display.widget.querySelectorAll(`.${a.css.timeContainer} > div`).forEach((t=>t.style.display="none"));let e="";switch(t){case I.showClock:e=a.css.clockContainer,this.display._update("clock");break;case I.showHours:e=a.css.hourContainer,this.display._update(n.hours);break;case I.showMinutes:e=a.css.minuteContainer,this.display._update(n.minutes);break;case I.showSeconds:e=a.css.secondContainer,this.display._update(n.seconds)}this.display.widget.getElementsByClassName(e)[0].style.display="grid"}handleNextPrevious(t){const{unit:e,step:s}=m[this.optionsStore.currentCalendarViewMode];t===I.next?this.optionsStore.viewDate.manipulate(s,e):this.optionsStore.viewDate.manipulate(-1*s,e),this._eventEmitters.viewUpdate.emit(),this.display._showMode()}hideOrClock(t){this.optionsStore.isTwelveHour||this.optionsStore.options.display.components.minutes||this.optionsStore.options.display.keepOpen||this.optionsStore.options.display.inline?this.do(t,I.showClock):this.display.hide()}manipulateAndSet(t,e,s=1){const i=t.manipulate(s,e);this.validation.isValid(i,e)&&this.dates.setValue(i,this.dates.lastPickedIndex)}handleSelectCalendarMode(t,e){const s=+e.dataset.value;switch(t){case I.selectMonth:this.optionsStore.viewDate.month=s;break;case I.selectYear:case I.selectDecade:this.optionsStore.viewDate.year=s}this.optionsStore.currentCalendarViewMode===this.optionsStore.minimumCalendarViewMode?(this.dates.setValue(this.optionsStore.viewDate,this.dates.lastPickedIndex),this.optionsStore.options.display.inline||this.display.hide()):this.display._showMode(-1)}handleToggle(t){t.getAttribute("title")===this.optionsStore.options.localization.selectDate?(t.setAttribute("title",this.optionsStore.options.localization.selectTime),t.innerHTML=this.display._iconTag(this.optionsStore.options.display.icons.time).outerHTML,this.display._updateCalendarHeader(),this.optionsStore.refreshCurrentView()):(t.setAttribute("title",this.optionsStore.options.localization.selectDate),t.innerHTML=this.display._iconTag(this.optionsStore.options.display.icons.date).outerHTML,this.display._hasTime&&(this.handleShowClockContainers(I.showClock),this.display._update("clock"))),this.display.widget.querySelectorAll(`.${a.css.dateContainer}, .${a.css.timeContainer}`).forEach((t=>U.toggle(t))),this._eventEmitters.viewUpdate.emit()}handleSelectDay(t){const e=this.optionsStore.viewDate.clone;t.classList.contains(a.css.old)&&e.manipulate(-1,n.month),t.classList.contains(a.css.new)&&e.manipulate(1,n.month),e.date=+t.dataset.day,this.optionsStore.options.dateRange?this.handleDateRange(e):this.optionsStore.options.multipleDates?this.handleMultiDate(e):this.dates.setValue(e,this.dates.lastPickedIndex),this.display._hasTime||this.optionsStore.options.display.keepOpen||this.optionsStore.options.display.inline||this.optionsStore.options.multipleDates||this.optionsStore.options.dateRange||this.display.hide()}handleMultiDate(t){let e=this.dates.pickedIndex(t,n.date);console.log(e),-1!==e?this.dates.setValue(null,e):(e=this.dates.lastPickedIndex+1,0===this.dates.picked.length&&(e=0),this.dates.setValue(t,e))}handleDateRange(t){switch(this.dates.picked.length){case 2:this.dates.clear();break;case 1:{const e=this.dates.picked[0];if(t.getTime()===e.getTime()){this.dates.clear();break}return t.isBefore(e)?(this.dates.setValue(t,0),void this.dates.setValue(e,1)):void this.dates.setValue(t,1)}}this.dates.setValue(t,0)}}class J{constructor(t,e={}){this._subscribers={},this._isDisabled=!1,this._inputChangeEvent=t=>{const e=t?.detail;if(e)return;const s=()=>{this.dates.lastPicked&&(this.optionsStore.viewDate=this.dates.lastPicked.clone)},i=this.optionsStore.input.value;if(this.optionsStore.options.multipleDates||this.optionsStore.options.dateRange)try{const t=i.split(this.optionsStore.options.multipleDatesSeparator);for(let e=0;e<t.length;e++)this.dates.setFromInput(t[e],e);s()}catch{console.warn("TD: Something went wrong trying to set the multipleDates values from the input field.")}else this.dates.setFromInput(i,0),s()},this._toggleClickEvent=()=>{this.optionsStore.element?.disabled||this.optionsStore.input?.disabled||"INPUT"===this._toggle.nodeName&&"text"===this._toggle?.type&&this.optionsStore.options.allowInputToggle||this.toggle()},this._openClickEvent=()=>{this.optionsStore.element?.disabled||this.optionsStore.input?.disabled||this.display.isVisible||this.show()},u=new p,this._eventEmitters=u.locate(f),this.optionsStore=u.locate(y),this.display=u.locate(R),this.dates=u.locate(z),this.actions=u.locate(Q),t||a.errorMessages.mustProvideElement(),this.optionsStore.element=t,this._initializeOptions(e,w,!0),this.optionsStore.viewDate.setLocalization(this.optionsStore.options.localization),this.optionsStore.unset=!0,this._initializeInput(),this._initializeToggle(),this.optionsStore.options.display.inline&&this.display.show(),this._eventEmitters.triggerEvent.subscribe((t=>{this._triggerEvent(t)})),this._eventEmitters.viewUpdate.subscribe((()=>{this._viewUpdate()})),this._eventEmitters.updateViewDate.subscribe((t=>{this.viewDate=t}))}get viewDate(){return this.optionsStore.viewDate}set viewDate(t){this.optionsStore.viewDate=t,this.optionsStore.viewDate.setLocalization(this.optionsStore.options.localization),this.display._update("clock"===this.optionsStore.currentView?"clock":"calendar")}updateOptions(t,e=!1){e?this._initializeOptions(t,w):this._initializeOptions(t,this.optionsStore.options),this.optionsStore.viewDate.setLocalization(this.optionsStore.options.localization),this.display.refreshCurrentView()}toggle(){this._isDisabled||this.display.toggle()}show(){this._isDisabled||this.display.show()}hide(){this.display.hide()}disable(){this._isDisabled=!0,this.optionsStore.input?.setAttribute("disabled","disabled"),this.display.hide()}enable(){this._isDisabled=!1,this.optionsStore.input?.removeAttribute("disabled")}clear(){this.optionsStore.input.value="",this.dates.clear()}subscribe(t,e){let s;"string"==typeof t&&(t=[t]),s=Array.isArray(e)?e:[e],t.length!==s.length&&a.errorMessages.subscribeMismatch();const i=[];for(let e=0;e<t.length;e++){const o=t[e];if(Array.isArray(this._subscribers[o])||(this._subscribers[o]=[]),this._subscribers[o].push(s[e]),i.push({unsubscribe:this._unsubscribe.bind(this,o,this._subscribers[o].length-1)}),1===t.length)return i[0]}return i}dispose(){this.display.hide(),this.display._dispose(),this._eventEmitters.destroy(),this.optionsStore.input?.removeEventListener("change",this._inputChangeEvent),this.optionsStore.options.allowInputToggle&&(this.optionsStore.input?.removeEventListener("click",this._openClickEvent),this.optionsStore.input?.removeEventListener("focus",this._openClickEvent)),this._toggle?.removeEventListener("click",this._toggleClickEvent),this._subscribers={}}locale(t){const e=K[t];e&&this.updateOptions({localization:e})}_triggerEvent(t){t.viewMode=this.optionsStore.currentView;const e=t.type===a.events.change;if(e){const{date:e,oldDate:s,isClear:i}=t;if(e&&s&&e.isSame(s)||!i&&!e&&!s)return;this._handleAfterChangeEvent(t),this.optionsStore.input?.dispatchEvent(new CustomEvent("change",{detail:t}))}if(this.optionsStore.element.dispatchEvent(new CustomEvent(t.type,{detail:t})),window.jQuery){const s=window.jQuery;e&&this.optionsStore.input?s(this.optionsStore.input).trigger(t):s(this.optionsStore.element).trigger(t)}this._publish(t)}_publish(t){Array.isArray(this._subscribers[t.type])&&this._subscribers[t.type].forEach((e=>{e(t)}))}_viewUpdate(){this._triggerEvent({type:a.events.update,viewDate:this.optionsStore.viewDate.clone})}_unsubscribe(t,e){this._subscribers[t].splice(e,1)}_initializeOptions(t,e,s=!1){let i=H.deepCopy(t);i=H._mergeOptions(i,e),s&&(i=H._dataToOptions(this.optionsStore.element,i)),H._validateConflicts(i),i.viewDate=i.viewDate.setLocalization(i.localization),this.optionsStore.viewDate.isSame(i.viewDate)||(this.optionsStore.viewDate=i.viewDate),i.display.components.year&&(this.optionsStore.minimumCalendarViewMode=2),i.display.components.month&&(this.optionsStore.minimumCalendarViewMode=1),i.display.components.date&&(this.optionsStore.minimumCalendarViewMode=0),this.optionsStore.currentCalendarViewMode=Math.max(this.optionsStore.minimumCalendarViewMode,this.optionsStore.currentCalendarViewMode),m[this.optionsStore.currentCalendarViewMode].name!==i.display.viewMode&&(this.optionsStore.currentCalendarViewMode=Math.max(m.findIndex((t=>t.name===i.display.viewMode)),this.optionsStore.minimumCalendarViewMode)),this.display?.isVisible&&this.display._update("all"),i.display.components.useTwentyfourHour&&void 0===i.localization.hourCycle?i.localization.hourCycle="h24":void 0===i.localization.hourCycle&&(i.localization.hourCycle=l(i.localization.locale)),this.optionsStore.options=i,i.restrictions.maxDate&&this.viewDate.isAfter(i.restrictions.maxDate)&&(this.viewDate=i.restrictions.maxDate),i.restrictions.minDate&&this.viewDate.isBefore(i.restrictions.minDate)&&(this.viewDate=i.restrictions.minDate)}_initializeInput(){if("INPUT"==this.optionsStore.element.tagName)this.optionsStore.input=this.optionsStore.element;else{const t=this.optionsStore.element.dataset.tdTargetInput;this.optionsStore.input=null==t||"nearest"==t?this.optionsStore.element.querySelector("input"):this.optionsStore.element.querySelector(t)}this.optionsStore.input&&(!this.optionsStore.input.value&&this.optionsStore.options.defaultDate&&(this.optionsStore.input.value=this.dates.formatInput(this.optionsStore.options.defaultDate)),this.optionsStore.input.addEventListener("change",this._inputChangeEvent),this.optionsStore.options.allowInputToggle&&(this.optionsStore.input.addEventListener("click",this._openClickEvent),this.optionsStore.input.addEventListener("focus",this._openClickEvent)),this.optionsStore.input.value&&this._inputChangeEvent())}_initializeToggle(){if(this.optionsStore.options.display.inline)return;let t=this.optionsStore.element.dataset.tdTargetToggle;"nearest"==t&&(t='[data-td-toggle="datetimepicker"]'),this._toggle=null==t?this.optionsStore.element:this.optionsStore.element.querySelector(t),this._toggle.addEventListener("click",this._toggleClickEvent)}_handleAfterChangeEvent(t){!this.optionsStore.options.promptTimeOnDateChange||this.optionsStore.options.multipleDates||this.optionsStore.options.display.inline||this.optionsStore.options.display.sideBySide||!this.display._hasTime||this.display.widget?.getElementsByClassName(a.css.show)[0].classList.contains(a.css.timeContainer)||!t.oldDate&&this.optionsStore.options.useCurrent||t.oldDate&&t.date?.isSame(t.oldDate)||(clearTimeout(this._currentPromptTimeTimeout),this._currentPromptTimeTimeout=setTimeout((()=>{this.display.widget&&this._eventEmitters.action.emit({e:{currentTarget:this.display.widget.querySelector('[data-action="togglePicker"]')},action:I.togglePicker})}),this.optionsStore.options.promptTimeOnDateChangeTransitionDelay))}}const K={},Z=t=>{K[t.name]||(K[t.name]=t.localization)}}}]);