@wernfried/daterangepicker 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var DateRangePicker=(function(C,h){"use strict";class L{#e=null;#t=null;constructor(s,e,n){if(typeof s=="string"&&document.querySelectorAll(s).length>1)throw new RangeError("Option 'element' must match to one element only");this.parentEl="body",this.element=s instanceof HTMLElement?s:document.querySelector(s),this.isInputText=this.element instanceof HTMLInputElement&&this.element.type==="text",this.button=null,this.showOnClick=!0,this.#e=h.DateTime.now().startOf("day"),this.#t=h.DateTime.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initialMonth=h.DateTime.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=h.DateTime.now().minus({year:100}).year,this.maxYear=h.DateTime.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!this.isInputText,this.timePicker=!1;const a=new Intl.DateTimeFormat(h.DateTime.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=h.Duration.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element?.classList.contains("pull-right")?"left":"right",this.drops=this.element?.classList.contains("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:h.DateTime.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:h.Info.weekdays("short"),monthNames:h.Info.months("long"),firstDay:h.Info.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=null,this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let r={};const i=Array.from(this.element.attributes).filter(t=>t.name.startsWith("data-"));for(let t of i){const c=t.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(c)||Object.keys(e).includes(c))continue;let m=h.DateTime.fromISO(t.value);const v=["startDate","endDate","minDate","maxDate","initialMonth"].includes(c);r[c]=m.isValid&&v?m:JSON.parse(t.value)}if(e={...r,...e},["string","object"].includes(typeof e.button)){let t=e.button;typeof t=="string"&&document.querySelectorAll(t).length===1&&(t=document.querySelector(t)),t instanceof HTMLButtonElement?this.button=t:console.error("Option 'button' cannot resolved to a HTMLButtonElement")}if(typeof e.singleDatePicker=="boolean"&&(this.singleDatePicker=e.singleDatePicker),!this.singleDatePicker&&typeof e.singleMonthView=="boolean"?this.singleMonthView=e.singleMonthView:this.singleMonthView=!1,e.externalStyle!==null){const t=window.getComputedStyle(document.body);t&&typeof t[Symbol.iterator]=="function"&&[...t].some(c=>c.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?I(e.template):e.template;else{let t=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>',this.singleMonthView?'<tr class="calendar-time end-time"></tr>':"","</tfoot>","</table>","</div>"];t.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",this.singleMonthView?"":'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),t.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?t.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):t.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),t.push("</div></div>"),e.template=t.join(""),this.container=I(e.template)}if(this.parentEl=document.querySelector(typeof e.parentEl=="string"?e.parentEl:this.parentEl),this.parentEl.appendChild(this.container),typeof e.timePicker=="boolean"&&(this.timePicker=e.timePicker),this.timePicker&&(this.locale.format=h.DateTime.DATETIME_SHORT),typeof e.locale=="object"){for(let t of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[t]=="string"&&(this.locale[t]=e.locale[t]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof e.locale.format)&&(this.locale.format=e.locale.format),Array.isArray(e.locale.daysOfWeek)&&(e.locale.daysOfWeek.some(t=>typeof t!="string")?console.error("Option 'locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(t=>typeof t!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=e.locale.monthNames.slice()),typeof e.locale.firstDay=="number"&&(this.locale.firstDay=e.locale.firstDay),typeof e.locale.customRangeLabel=="string"){var o=document.createElement("textarea");o.innerHTML=e.locale.customRangeLabel;var d=o.value;this.locale.customRangeLabel=d}["string","object","function"].includes(typeof e.locale.durationFormat)&&e.locale.durationFormat!=null&&(this.locale.durationFormat=e.locale.durationFormat)}this.container.classList.add(this.locale.direction);for(let t of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel","showOnClick"])typeof e[t]=="boolean"&&(this[t]=e[t]);for(let t of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[t]=="string"?this[t]=e[t]:["weekendClasses","weekendDayClasses","todayClasses"].includes(t)&&e[t]===null&&(this[t]=e[t]);for(let t of["minYear","maxYear"])typeof e[t]=="number"&&(this[t]=e[t]);for(let t of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[t]=="function"?this[t]=e[t]:this[t]=function(){return!1};if(!this.singleDatePicker){for(let t of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[t])&&(h.Duration.isDuration(e[t])&&e[t].isValid?this[t]=e[t]:h.Duration.fromISO(e[t]).isValid?this[t]=h.Duration.fromISO(e[t]):typeof e[t]=="number"&&h.Duration.fromObject({seconds:e[t]}).isValid?this[t]=h.Duration.fromObject({seconds:e[t]}):e[t]===null?this[t]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&(this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'")))}if(this.timePicker){if(["string","object","number"].includes(typeof e.timePickerStepSize)){let t;h.Duration.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?t=e.timePickerStepSize:h.Duration.fromISO(e.timePickerStepSize).isValid?t=h.Duration.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&h.Duration.fromObject({seconds:e.timePickerStepSize}).isValid?t=h.Duration.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),t=this.timePickerStepSize);var l=[];for(let c of["minutes","seconds"])l.push(...[1,2,3,4,5,6,10,12,15,20,30].map(m=>h.Duration.fromObject({[c]:m})));l.push(...[1,2,3,4,6].map(c=>h.Duration.fromObject({hours:c}))),this.timePicker24Hour&&l.push(...[8,12].map(c=>h.Duration.fromObject({hours:c}))),l.some(c=>t.rescale().equals(c))?this.timePickerStepSize=t.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(t.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<h.Duration.fromObject({hours:1}),showSeconds:this.timePickerStepSize<h.Duration.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=h.Duration.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=h.Duration.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let t of["startDate","endDate","minDate","maxDate","initialMonth"])if(!(t==="endDate"&&this.singleDatePicker)){if(typeof e[t]=="object")h.DateTime.isDateTime(e[t])&&e[t].isValid?this[t]=e[t]:e[t]instanceof Date?this[t]=h.DateTime.fromJSDate(e[t]):e[t]===null?this[t]=null:console.error(`Option '${t}' must be a luxon.DateTime or Date or string`);else if(typeof e[t]=="string"){const c=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(h.DateTime.fromISO(e[t]).isValid)this[t]=h.DateTime.fromISO(e[t]);else if(h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale}).isValid)this[t]=h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale});else{const m=h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale}).invalidExplanation;console.error(`Option '${t}' is not a valid string: ${m}`)}}}if(this.isInputText&&this.element.value!=""){const t=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const c=h.DateTime.fromFormat(this.element.value,t,{locale:h.DateTime.now().locale});c.isValid?this.#e=c:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${c.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const c=this.element.value.split(this.locale.separator);if(c.length===2){const m=h.DateTime.fromFormat(c[0],t,{locale:h.DateTime.now().locale}),v=h.DateTime.fromFormat(c[1],t,{locale:h.DateTime.now().locale});m.isValid&&v.isValid?(this.#e=m,this.#t=v):console.error(`Value in <input> is not a valid string: ${m.invalidExplanation} - ${v.invalidExplanation}`)}else console.error(`Value "${this.element.value}" in <input> is not a valid string`)}}if(this.singleDatePicker?this.#t=this.#e:this.#t<this.#e&&console.error(`Option 'endDate' ${this.#t} must not be earlier than 'startDate' ${this.#e}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#e&&(this.#e=this.#e.startOf("day")),this.#t&&(this.#t=this.#t.endOf("day"))),!this.#e&&this.initialMonth)this.#t=null,this.timePicker&&console.error("Option 'initialMonth' works only with 'timePicker: false'");else{const t=this.validateInput(null,!1);if(t!=null){let c=t.startDate;if(c.length>0)if(c.some(m=>m.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${c.find(m=>m.reason.startsWith("isInvalid")).reason}`);else{const m=c.filter(v=>v.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${m}`),this.#e=m}if(!this.singleDatePicker&&(c=t.endDate.filter(m=>m.new!=null),c.length>0))if(c.some(m=>m.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${c.find(m=>m.reason.startsWith("isInvalid")).reason}`);else{const m=c.filter(v=>v.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${m}`),this.#t=m}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const t=document.querySelector(e.altInput);this.altInput=t instanceof HTMLInputElement&&t.type==="text"?t:null}else e.altInput instanceof HTMLElement&&(this.altInput=e.altInput instanceof HTMLInputElement&&e.altInput.type==="text"?e.altInput:null);else if(!this.singleDatePicker&&Array.isArray(e.altInput)&&e.altInput.length===2){this.altInput=[];for(let t of e.altInput){const c=typeof t=="string"?document.querySelector(t):t;c instanceof HTMLInputElement&&c.type==="text"&&this.altInput.push(c)}this.altInput.length!==2&&(this.altInput=null)}else e.altInput!=null&&console.warn(`Option 'altInput' ${JSON.stringify(e.altInput)} is not valid`);if(e.altInput&&["function","string"].includes(typeof e.altFormat)&&(this.altFormat=e.altFormat),typeof e.opens=="string"&&(["left","right","center"].includes(e.opens)?this.opens=e.opens:console.error("Option 'opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'drops' must be 'up', 'down' or 'auto'")),Array.isArray(e.buttonClasses)?this.buttonClasses=e.buttonClasses.join(" "):typeof e.buttonClasses=="string"&&(this.buttonClasses=e.buttonClasses),typeof e.onOutsideClick=="string"&&(["cancel","apply"].includes(e.onOutsideClick)?this.onOutsideClick=e.onOutsideClick:console.error("Option 'onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let t=this.locale.firstDay;for(;t>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),t--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let t in e.ranges){let c,m;if(["string","object"].includes(typeof e.ranges[t][0])&&(h.DateTime.isDateTime(e.ranges[t][0])&&e.ranges[t][0].isValid?c=e.ranges[t][0]:e.ranges[t][0]instanceof Date?c=h.DateTime.fromJSDate(e.ranges[t][0]):typeof e.ranges[t][0]=="string"&&h.DateTime.fromISO(e.ranges[t][0]).isValid?c=h.DateTime.fromISO(e.ranges[t][0]):console.error(`Option ranges['${t}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[t][1])&&(h.DateTime.isDateTime(e.ranges[t][1])&&e.ranges[t][1].isValid?m=e.ranges[t][1]:e.ranges[t][1]instanceof Date?m=h.DateTime.fromJSDate(e.ranges[t][1]):typeof e.ranges[t][1]=="string"&&h.DateTime.fromISO(e.ranges[t][1]).isValid?m=h.DateTime.fromISO(e.ranges[t][1]):console.error(`Option ranges['${t}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(c==null||m==null)){var o=document.createElement("textarea");o.innerHTML=t,this.ranges[o.value]=[c,m]}}var f="<ul>";for(let t in this.ranges)f+=`<li data-range-key="${t}">${t}</li>`;this.showCustomRangeLabel&&(f+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),f+="</ul>",this.container.querySelector(".ranges").prepend(I(f)),this.container.classList.add("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(t=>{t.style.display="none"}),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.classList.add("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.classList.add("single"),this.container.querySelector(".drp-calendar.left").classList.add("single"),this.container.querySelector(".drp-calendar.left").style.display="",this.container.querySelector(".drp-calendar.right").style.display="none",!this.timePicker&&this.autoApply&&this.container.classList.add("auto-apply")),(this.singleDatePicker||!Object.keys(this.ranges).length||this.alwaysShowCalendars)&&this.container.classList.add("show-calendar"),this.container.classList.add(`opens${this.opens}`),this.container.querySelectorAll(".applyBtn, .cancelBtn").forEach(t=>{t.classList.add(...this.buttonClasses.split(" "))}),this.applyButtonClasses.length&&this.container.querySelector(".applyBtn").classList.add(...this.applyButtonClasses.split(" ")),this.cancelButtonClasses.length&&this.container.querySelector(".cancelBtn").classList.add(...this.cancelButtonClasses.split(" ")),this.container.querySelector(".applyBtn").innerHTML=this.locale.applyLabel,this.container.querySelector(".cancelBtn").innerHTML=this.locale.cancelLabel,this.addListener(".drp-calendar","click",".prev",this.clickPrev.bind(this)),this.addListener(".drp-calendar","click",".next",this.clickNext.bind(this)),this.addListener(".drp-calendar","mousedown","td.available",this.clickDate.bind(this)),this.addListener(".drp-calendar","mouseenter","td.available",this.hoverDate.bind(this)),this.addListener(".drp-calendar","change","select.yearselect,select.monthselect",this.monthOrYearChanged.bind(this)),this.addListener(".drp-calendar","change","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.addListener(".ranges","click","li",this.clickRange.bind(this)),this.addListener(".ranges","mouseenter","li",this.hoverRange.bind(this)),this.addListener(".ranges","mouseleave","li",this.leaveRange.bind(this)),this.addListener(".drp-buttons","click","button.applyBtn",this.clickApply.bind(this)),this.addListener(".drp-buttons","click","button.cancelBtn",this.clickCancel.bind(this)),this.showOnClick&&(this.element.matches("input")||this.element.matches("button")?(this.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a),this.element.addEventListener("keyup",this.#h),this.element.addEventListener("keydown",this.#o)):(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n))),this.button&&this.button.addEventListener("click",this.#a),this.updateElement()}get startDate(){return this.timePicker?this.#e:this.#e?.startOf("day")??null}get endDate(){return this.singleDatePicker?null:(this.timePicker?this.#t:this.#t?.endOf("day"))??null}set startDate(s){this.#e=s}set endDate(s){this.#t=s}#i={onViolate:{type:"violate",param:(s,e)=>({...s,cancelable:!0})},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker"},onBeforeRenderCalendar:{type:"beforeRenderCalendar"},onShow:{type:"show"},onBeforeHide:{type:"beforeHide",param:{cancelable:!0}},onHide:{type:"hide"},onShowCalendar:{type:"showCalendar"},onHideCalendar:{type:"hideCalendar"},onOutsideClick:{type:"outsideClick",param:{cancelable:!0}},onDateChange:{type:"dateChange",param:s=>s},onTimeChange:{type:"timeChange",param:s=>s},onApply:{type:"apply"},onCancel:{type:"cancel"},onInputChange:{type:"inputChange"},onMonthViewChange:{type:"monthViewChange",param:(s,e)=>({left:this.leftCalendar.month.startOf("month"),right:this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month.startOf("month")})}};get events(){return this.#i}#s=this.outsideClick.bind(this);#r=this.move.bind(this);#l=s=>{const e=s.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(s)};#a=this.show.bind(this);#h=this.elementChanged.bind(this);#o=this.keydown.bind(this);#n=this.toggle.bind(this);setStartDate(s,e=!0){if(!this.singleDatePicker)return this.setRange(s,this.#t,e);const n=this.#e;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#e.hasSame(a,"month");return this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),e&&this.updateView(i),r}setEndDate(s,e=!0){return this.singleDatePicker?null:this.setRange(this.#e,s,e)}setRange(s,e,n=!0){if(this.singleDatePicker)return;this.#t||(this.#t=this.#e);const a=[this.#e,this.#t];let r=[this.parseDate(s),this.parseDate(e)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const o=!this.#e.hasSame(r[0],"month")||!this.#t.hasSame(r[1],"month");return this.#e=r[0],this.#t=r[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),n&&this.updateView(o),i}parseDate(s){if(typeof s=="object"){if(h.DateTime.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return h.DateTime.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const e=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(h.DateTime.fromISO(s).isValid)return h.DateTime.fromISO(s);if(h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale}).isValid)return h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale});{const n=h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}formatDate(s,e=this.locale.format){if(s===null)return null;if(typeof e=="object")return s.toLocaleString(e);if(h.Settings.defaultLocale===null){const n=h.DateTime.now().locale;return s.toFormat(e,{locale:n})}else return s.toFormat(e)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#e);this.singleDatePicker||(s+=this.locale.separator,this.#t&&(s+=this.formatDate(this.#t))),this.container.querySelector(".drp-selected").innerHTML=s}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#t){this.container.querySelector(".drp-duration-label").innerHTML="";return}if(typeof this.locale.durationFormat=="function")this.container.querySelector(".drp-duration-label").innerHTML=this.locale.durationFormat(this.#e,this.#t);else{let s=this.#t.plus({milliseconds:1}).diff(this.#e).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.querySelector(".drp-duration-label").innerHTML=s.toHuman(this.locale.durationFormat):this.container.querySelector(".drp-duration-label").innerHTML=s.toFormat(this.locale.durationFormat)}}}validateInput(s,e=!1){let n=s==null?this.#e:s[0],a=s==null?this.#t:s[1];if(n==null)return null;let r={startDate:[]},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const l=this.timePickerStepSize.as("seconds");n=h.DateTime.fromSeconds(l*Math.round(n.toSeconds()/l)),i.new=n,i.new.equals(i.old)||r.startDate.push(i)}else n=n.startOf("day");const o=this.timePicker?this.timePickerStepSize.as("seconds"):h.Duration.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/o)*o}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/o)*o}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.push(i));let d=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&d.push("minute"),this.timePickerOpts.showSeconds&&d.push("second"),this.timePicker24Hour||d.push("ampm")),this.isInvalidDate(n)&&r.startDate.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let l of d)this.isInvalidTime(n,l,"start")&&r.startDate.push({old:n,reason:"isInvalidTime",unit:l});if(this.singleDatePicker){if(r.startDate.length==0)return null;if(e){let l={startDate:n};const f=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:l});return f.defaultPrevented&&(r.newDate=f.newDate),r}else return r}if(a==null)return null;if(r.endDate=[],i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const l=this.timePickerStepSize.as("seconds");a=h.DateTime.fromSeconds(l*Math.round(a.toSeconds()/l)),i.new=a,i.new.equals(i.old)||r.endDate.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/o)*o}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/o)*o}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i)),this.maxSpan){const l=n.plus(this.maxSpan);a>l&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(l.diff(a).as("seconds")/o)*o}),a>l&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i))}if(this.minSpan){const l=n.plus(this.minSpan);a<l&&(i={old:a,reason:"minSpan"},this.defaultSpan?a=n.plus({seconds:Math.trunc(this.defaultSpan.as("seconds")/o)*o}):a=n.plus({seconds:Math.trunc(this.minSpan.as("seconds")/o)*o}),a<l&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i))}if(this.isInvalidDate(a)&&r.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let l of d)this.isInvalidTime(a,l,"end")&&r.endDate.push({old:a,reason:"isInvalidTime",unit:l});if(r.startDate.length==0&&r.endDate.length==0)return null;if(e){let l={startDate:n,endDate:a};const f=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:l});return f.defaultPrevented&&(r.newDate=f.newDate),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.container.querySelectorAll(".calendar-time.end-time select").forEach(e=>{e.disabled=!this.#t}),this.container.querySelectorAll(".calendar-time.end-time select").forEach(e=>{e.classList.toggle("disabled",!this.#t)})),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#t){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month"))&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#e.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#t.hasSame(this.#e,"month")?this.rightCalendar.month=this.#t.startOf("month"):this.rightCalendar.month=this.#e.startOf("month").plus({month:1}))}else!this.#e&&this.initialMonth?(this.leftCalendar.month=this.initialMonth,this.singleMonthView||(this.rightCalendar.month=this.initialMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#e,"month")&&!this.rightCalendar.month.hasSame(this.#e,"month")&&(this.leftCalendar.month=this.#e.startOf("month"),this.rightCalendar.month=this.#e.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var e,n,a;this.#t?(e=parseInt(this.container.querySelector(".start-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10)))):(e=parseInt(this.container.querySelector(".end-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:e,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:e,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChange),this.container.querySelectorAll(".ranges li").forEach(r=>{r.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#e&&this.initialMonth&&(i.month=this.initialMonth.startOf("month"));const e=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=e,i.lastDay=n;for(var o=0;o<6;o++)i[o]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,S=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&S++,i[S][y%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var d=s==="left"?this.minDate:this.#e,l=this.maxDate,f="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+="<th></th>"),(!d||d<i.firstDay)&&(!this.linkedCalendars||s==="left")?f+='<th class="prev available"><span></span></th>':f+="<th></th>";var t=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const y=(l&&l.year)??this.maxYear,S=(d&&d.year)??this.minYear;let E=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var c=`${E}<select class="monthselect">`,m=1;m<=12;m++)c+=`<option value="${m}"${m===i.firstDay.month?" selected":""}`,(d&&i.firstDay.set({month:m})<d.startOf("month")||l&&i.firstDay.set({month:m})>l.endOf("month"))&&(c+=" disabled"),c+=`>${this.locale.monthNames[m-1]}</option>`;c+="</select>",this.externalStyle==="bulma"&&(c+="</div>"),E=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var v=`${E}<select class="yearselect">`,g=S;g<=y;g++)v+=`<option value="${g}"${g===i.firstDay.year?" selected":""}>${g}</option>`;v+="</select>",this.externalStyle==="bulma"&&(v+="</div>"),t=c+v}f+='<th colspan="5" class="month">'+t+"</th>",(!l||l>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?f+='<th class="next available"><span></span></th>':f+="<th></th>",f+="</tr>",f+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[y,S]of this.locale.daysOfWeek.entries())f+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&h.Info.getWeekendWeekdays().includes(y+1)&&(f+=` class="${this.weekendDayClasses}"`),f+=`>${S}</th>`;if(f+="</tr>",this.container.querySelector(`.drp-calendar.${s} .calendar-table thead`).innerHTML=f,f="",this.#t==null&&this.maxSpan){var D=this.#e.plus(this.maxSpan).endOf("day");(!l||D<l)&&(l=D)}var k;this.#t==null&&this.minSpan&&(k=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){f+="<tr>",this.showISOWeekNumbers?f+=`<td class="week">${i[y][0].weekNumber}</td>`:this.showWeekNumbers&&(f+=`<td class="week">${i[y][0].localWeekNumber}</td>`);for(let S=0;S<7;S++){var p=[];this.todayClasses&&this.todayClasses.length&&i[y][S].hasSame(h.DateTime.now(),"day")&&p.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&h.Info.getWeekendWeekdays().includes(i[y][S].weekday)&&p.push(this.weekendClasses),i[y][S].month!=i[1][1].month&&p.push("off","ends"),this.minDate&&i[y][S].startOf("day")<this.minDate.startOf("day")&&p.push("off","disabled"),l&&i[y][S].startOf("day")>l.startOf("day")&&p.push("off","disabled"),k&&i[y][S].startOf("day")>this.#e.startOf("day")&&i[y][S].startOf("day")<k.startOf("day")&&p.push("off","disabled"),this.isInvalidDate(i[y][S])&&p.push("off","disabled"),this.#e!=null&&i[y][S].hasSame(this.#e,"day")&&p.push("active","start-date"),this.#t!=null&&i[y][S].hasSame(this.#t,"day")&&p.push("active","end-date"),this.#t!=null&&i[y][S]>this.#e&&i[y][S]<this.#t&&p.push("in-range");var w=this.isCustomDate(i[y][S]);w!==!1&&(typeof w=="string"?p.push(w):p.push(...w)),p.includes("disabled")||p.push("available"),f+=`<td class="${p.join(" ")}" data-title="r${y}c${S}">${i[y][S].day}</td>`}f+="</tr>"}this.container.querySelector(`.drp-calendar.${s} .calendar-table tbody`).innerHTML=f}renderTimePicker(s){if(s==="end"&&!this.#t)return;var e,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(r=this.#e.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#e.plus(this.minSpan)),s==="start")e=this.#e,a=this.minDate;else if(s==="end"){e=this.#t,a=this.#e;let g=this.container.querySelector(".drp-calendar .calendar-time.end-time");g.innerHTML!=""&&(e=e.set({hour:isNaN(e.hour)?g.querySelector(".hourselect option:selected").value:e.hour,minute:isNaN(e.minute)?g.querySelector(".minuteselect option:selected").value:e.minute,second:isNaN(e.second)?g.querySelector(".secondselect option:selected").value:e.second})),e<this.#e&&(e=this.#e),r&&e>r&&(e=r)}let o=[],d=[];i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const l=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=l==="AM"?1:13);for(var t=f;t<=f+23;t+=this.timePickerOpts.hourStep){let g=e.set({hour:t%24}),D=!1;if(a&&g.set({minute:59})<a&&(D=!0),r&&g.set({minute:0})>r&&(D=!0),n&&g.endOf("hour")<n&&(D=!0),!D&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(D=!0),this.timePicker24Hour)!D&&t==e.hour?i+=`<option value="${t}" selected>${t}</option>`:D?i+=`<option value="${t}" disabled class="disabled">${t}</option>`:i+=`<option value="${t}">${t}</option>`;else{const k=h.DateTime.fromFormat(`${t%24}`,"H").toFormat("h"),p=h.DateTime.fromFormat(`${t%24}`,"H").toFormat("a",{locale:"en-US"});l==p?!D&&t==e.hour?i+=`<option ampm="${p}" value="${t%24}" selected>${k}</option>`:D?i+=`<option ampm="${p}" value="${t%24}" disabled class="disabled">${k}</option>`:i+=`<option ampm="${p}" value="${t%24}">${k}</option>`:i+=`<option ampm="${p}" hidden="hidden" value="${t%24}">${k}</option>`}o.push(D)}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var t=0;t<60;t+=this.timePickerOpts.minuteStep){var c=t<10?"0"+t:t;let D=e.set({minute:t}),k=!1;o.every(p=>p)&&(k=!0),a&&D.set({second:59})<a&&(k=!0),r&&D.set({second:0})>r&&(k=!0),n&&D.endOf("minute")<n&&(k=!0),!k&&this.isInvalidTime(D,this.singleDatePicker?null:s,"minute")&&(k=!0),e.minute==t&&!k?i+=`<option value="${t}" selected>${c}</option>`:k?i+=`<option value="${t}" disabled class="disabled">${c}</option>`:i+=`<option value="${t}">${c}</option>`,d.push(k)}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var t=0;t<60;t+=this.timePickerOpts.secondStep){var c=t<10?"0"+t:t;let k=e.set({second:t}),p=!1;d.every(w=>w)&&(p=!0),a&&k<a&&(p=!0),r&&k>r&&(p=!0),n&&k<n&&(p=!0),!p&&this.isInvalidTime(k,this.singleDatePicker?null:s,"second")&&(p=!0),e.second==t&&!p?i+=`<option value="${t}" selected>${c}</option>`:p?i+=`<option value="${t}" disabled class="disabled">${c}</option>`:i+=`<option value="${t}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var m="",v="";let g=!1;o.every(D=>D)&&(g=!0),a&&e.startOf("day")<a&&(g=!0),r&&e.endOf("day")>r&&(g=!0),n&&e.startOf("day")<n&&(g=!0),g?(m=' disabled class="disabled "',v=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:s,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?v=' disabled class="disabled"':m=' disabled class="disabled"'),i+=`<option value="AM"${m}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${h.Info.meridiems()[0]}</option><option value="PM"${v}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${h.Info.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${s}-time`).innerHTML=i}setApplyBtnState(){const s=this.singleDatePicker||this.#t&&this.#e<=this.#t;this.container.querySelector("button.applyBtn").disabled=!s}move(){let s={top:0,left:0},e,n,a=this.drops,r=window.innerWidth;switch(this.parentEl.matches("body")||(s={top:b(this.parentEl).top-this.parentEl.scrollTop(),left:b(this.parentEl).left-this.parentEl.scrollLeft()},r=this.parentEl[0].clientWidth+b(this.parentEl).left),this.drops){case"auto":e=b(this.element).top+O(this.element)-s.top,e+O(this.container)>=this.parentEl.scrollHeight&&(e=b(this.element).top-O(this.container)-s.top,a="up");break;case"up":e=b(this.element).top-O(this.container)-s.top;break;case"down":e=b(this.element).top+O(this.element)-s.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[o,d]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[o]=typeof d=="number"&&d>0?`${d}px`:d;const i=T(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const o=r-b(this.element).left-T(this.element);if(i+o>window.innerWidth)for(const[d,l]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:e,right:o,left:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;case"center":if(n=b(this.element).left-s.left+T(this.element)/2-i/2,n<0)for(const[d,l]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else if(n+i>window.innerWidth)for(const[d,l]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:e,left:n,right:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;case"right":if(n=b(this.element).left-s.left,n+i>window.innerWidth)for(const[d,l]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:`${e}px`,left:n,right:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;default:console.error(`Option opens '${this.opens}' not defined`);break}}show(){this.isShowing||(document.addEventListener("mousedown",this.#s),document.addEventListener("touchend",this.#s),document.addEventListener("click",this.#l),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#r),this.oldStartDate=this.#e,this.oldEndDate=this.#t,this.updateView(!1),this.container.style.display="block",this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){!this.isShowing||(this.#t||(this.#e=this.oldStartDate,this.#t=this.oldEndDate),typeof this.callback=="function"&&(this.#e&&!this.#e.equals(this.oldStartDate??h.DateTime)||this.#t&&!this.singleDatePicker&&!this.#t.equals(this.oldEndDate??h.DateTime))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented)||(document.removeEventListener("mousedown",this.#s),document.removeEventListener("touchend",this.#s),document.removeEventListener("focusin",this.#s),document.removeEventListener("click",this.#l),window.removeEventListener("resize",this.#r),this.container.style.display="none",this.triggerEvent(this.#i.onHide),this.isShowing=!1)}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.classList.add("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.classList.remove("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){const e=s.target;function n(r,i){if(i==null)return null;let o=r;for(;o;){if(o==i)return o;o=o.parentElement}return null}s.type==="focusin"||n(e,this.element)||n(e,this.container)||n(e,this.button)||e.closest(".calendar-table")||this.triggerEvent(this.#i.onOutsideClick).defaultPrevented||(this.onOutsideClick==="cancel"&&(this.#e=this.oldStartDate,this.#t=this.oldEndDate),this.hide())}clickPrev(s){s.target.closest(".drp-calendar").classList.contains("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!s.target.classList.contains("available"))return;let e=s.target.dataset.title;const n=e.substring(1,2),a=e.substring(3,4);var i=s.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const o=this.leftCalendar,d=this.rightCalendar,l=this.#e,f=this.initialMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(t=>{if(t.classList.contains("week"))return;const c=t.dataset.title,m=c.substring(1,2),v=c.substring(3,4),D=t.closest(".drp-calendar").classList.contains("left")?o.calendar[m][v]:d.calendar[m][v];!l&&f?t.classList.remove("in-range"):t.classList.toggle("in-range",D>l&&D<i||D.hasSame(i,"day"))})}hoverRange(s){const e=s.target.dataset.rangeKey,n=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],r=this.leftCalendar,i=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(o=>{if(o.classList.contains("week"))return;const d=o.dataset.ttitle,l=d.substring(1,2),f=d.substring(3,4),c=o.closest(".drp-calendar").classList.contains("left")?r.calendar[l][f]:i.calendar[l][f];o.classList.toggle("start-hover",c.hasSame(a[0],"day")),o.classList.toggle("start-date",c.hasSame(n[0],"day")),o.classList.toggle("end-hover",c.hasSame(a[1],"day")),o.classList.toggle("end-date",n[1]!=null&&c.hasSame(n[1],"day")),o.classList.toggle("range-hover",c.startOf("day")>=a[0].startOf("day")&&c.startOf("day")<=a[1].startOf("day")),o.classList.toggle("in-range",c.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&c.startOf("day")<=n[1].startOf("day"))})}leaveRange(){this.container.querySelectorAll(".drp-calendar tbody td").forEach(s=>{s.classList.contains("week")||(s.classList.remove("start-hover"),s.classList.remove("end-hover"),s.classList.remove("range-hover"))})}clickRange(s){let e=s.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{let n=this.ranges[e];const a=!this.#e.hasSame(n[0],"month")||!this.#t.hasSame(n[1],"month");this.#e=n[0],this.#t=n[1],this.timePicker||(this.#e.startOf("day"),this.#t.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented&&this.updateView(a),this.clickApply()}}clickDate(s){if(!s.target.classList.contains("available"))return;let e=s.target.dataset.title,n=e.substring(1,2),a=e.substring(3,4),i=s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a],o;if(this.#t||!this.#e||i<this.#e.startOf("day")){if(this.timePicker){let d=parseInt(this.container.querySelector(".start-time .hourselect").value,10);isNaN(d)&&(d=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10));let l=0;this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10)));let f=0;this.timePickerOpts.showSeconds&&(f=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(f)&&(f=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10))),i=i.set({hour:d,minute:l,second:f})}else i=i.startOf("day");this.#t=null,this.#e=i,o="start"}else if(!this.#t&&i<this.#e)this.#t=this.#e,o="end";else{if(this.timePicker){let d=parseInt(this.container.querySelector(".end-time .hourselect").value,10);isNaN(d)&&(d=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10));let l=0;this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10)));let f=0;this.timePickerOpts.showSeconds&&(f=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(f)&&(f=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10))),i=i.set({hour:d,minute:l,second:f})}else i=i.endOf("day");this.#t=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),o="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),o=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:o})}calculateChosenLabel(){if(Object.keys(this.ranges).length===0)return;let s=!0,e=this.timePicker?"hour":"day";this.timePicker&&(this.timePickerOpts.showMinutes?e="minute":this.timePickerOpts.showSeconds&&(e="second"));for(const[n,[a,r]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(r.startOf(e))){s=!1;const i=this.container.querySelector(`.ranges li[data-range-key="${n}"]`);this.chosenLabel=n,i.classList.add("active");break}if(s){if(this.showCustomRangeLabel){const n=this.container.querySelector(".ranges li:last-child");this.chosenLabel=n.dataset.rangeKey,n.classList.add("active")}else this.chosenLabel=null;this.showCalendars()}}timeChanged(s){const e=s.target.closest(".calendar-time"),n=e.classList.contains("start-time")?"start":"end";var a=parseInt(e.querySelector(".hourselect").value,10);if(isNaN(a)&&(a=parseInt(e.querySelector(".hourselect option:last-child").value,10)),!this.timePicker24Hour){const o=e.querySelector(".ampmselect").value;if(o==null&&e.querySelector(".ampmselect option:last-child").value,o!=h.DateTime.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(l=>{l.hidden=!l.hidden});const d=h.DateTime.fromFormat(`${a}`,"H").toFormat("h");a=h.DateTime.fromFormat(`${d}${o}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(e.querySelector(".minuteselect").value,10),isNaN(r)&&(r=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(e.querySelector(".secondselect").value,10),isNaN(i)&&(i=parseInt(e.querySelector(".secondselect option:last-child").value,10))),n==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&(this.defaultSpan&&this.#t<this.#e.plus(this.minSpan)?this.#t=this.#e.plus(this.defaultSpan):this.minSpan&&this.#t<this.#e.plus(this.minSpan)?this.#t=this.#e.plus(this.minSpan):this.#t<this.#e&&(this.#t=this.#e))):this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i}),this.#t<this.#e&&(this.#t=this.#e.plus(this.minSpan??h.Duration.fromObject({})))),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,{side:this.singleDatePicker?null:n})}monthOrYearChanged(s){const e=s.target.closest(".drp-calendar").classList.contains("left"),n=e?"left":"right",a=this.container.querySelector(`.drp-calendar.${n}`);let r=parseInt(a.querySelector(".monthselect").value,10),i=a.querySelector(".yearselect").value,o=!1;e||(i<this.#e.year||i==this.#e.year&&r<this.#e.month)&&(r=this.#e.month,i=this.#e.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),e?(o=!h.DateTime.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(o=!h.DateTime.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(o)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#e=this.oldStartDate,this.#t=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.isInputText||!this.element.value.length)return;const s=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=h.DateTime.fromFormat(this.element.value,s,{locale:h.DateTime.now().locale});const r=this.#e;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#e.hasSame(a,"month"),this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else if(!this.singleDatePicker&&e.length===2){const a=[0,1].map(o=>h.DateTime.fromFormat(e[o],s,{locale:h.DateTime.now().locale})),r=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#e.hasSame(a[0],"month")||!this.#t.hasSame(a[1],"month"),this.#e=a[0],this.#t=a[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(s){[9,11].includes(s.keyCode)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#e==null&&this.initialMonth))if(this.isInputText){let s=this.formatDate(this.#e);this.singleDatePicker||(s+=this.locale.separator,this.#t&&(s+=this.formatDate(this.#t))),this.updateAltInput(),s!==this.element.value&&(this.element.value=s,this.element.dispatchEvent(new Event("change",{bubbles:!0})))}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const e=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});if((this.singleDatePicker?this.altInput:this.altInput[0]).value=e,!this.singleDatePicker&&this.#t){const n=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});this.altInput[1].value=n}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);if((this.singleDatePicker?this.altInput:this.altInput[0]).value=s,!this.singleDatePicker&&this.#t){const e=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);this.altInput[1].value=e}}}remove(){this.element.removeEventListener("click",this.#a),this.element.removeEventListener("focus",this.#a),this.element.removeEventListener("keyup",this.#h),this.element.removeEventListener("keydown",this.#o),this.element.removeEventListener("click",this.#n),this.element.removeEventListener("keydown",this.#n),this.container.remove()}triggerEvent(s,...e){if(e.length===0){const n=new $(this,s);return this.element.dispatchEvent(n),n}else{const n=new $(this,s,...e);return this.element.dispatchEvent(n),n}}addListener(s,e,n,a){this.container.querySelectorAll(s).forEach(r=>{r.addEventListener(e,function(i){const o=i.target.closest(n);o&&r.contains(o)&&a.call(o,i)})})}}function I(u){const s=document.createElement("template");return s.innerHTML=u.trim(),s.content.firstElementChild}class $ extends Event{#e;constructor(s,e,n={}){let a={};e.param&&(a=typeof e.param=="function"?e.param():e.param),a={...a,...n},super(e.type,a),this.#e=s;for(const[r,i]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(r)||(this[r]=i)}get picker(){return this.#e}}function b(u){const s=u.getBoundingClientRect();return{top:s.top+window.scrollY,left:s.left+window.scrollX}}function T(u,s=!1){if(!s)return u.offsetWidth;const e=getComputedStyle(u);return u.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function O(u,s=!1){if(!s)return u.offsetHeight;const e=getComputedStyle(u);return u.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function P(u,s,e){return typeof u=="string"?P(document.querySelectorAll(u),s,e):(u instanceof HTMLElement&&(u=[u]),(u instanceof NodeList||u instanceof HTMLCollection)&&(u=Array.from(u)),u==null?new L(null,s||{},e):(u.forEach(n=>{n._daterangepicker&&typeof n._daterangepicker.remove=="function"&&n._daterangepicker.remove(),n._daterangepicker=new L(n,s||{},e)}),u.length===1?u[0]:u))}function q(u){return typeof u=="string"&&(u=document.querySelector(u)),u instanceof HTMLElement?u._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(u,s){return this.each(function(){P(this,u,s)})});function M(u){u?.fn&&(u.fn.daterangepicker=function(s,e){return this.each(function(){P(this,s,e)})})}return Object.defineProperty(window,"jQuery",{configurable:!0,set(u){this._jQuery=u,M(u)},get(){return this._jQuery}}),C.DateRangePicker=L,C.daterangepicker=P,C.getDateRangePicker=q,C})({},luxon);
1
+ var DateRangePicker=(function(C,h){"use strict";class L{#e=null;#t=null;constructor(s,e,n){if(typeof s=="string"&&document.querySelectorAll(s).length>1)throw new RangeError("Option 'element' must match to one element only");this.parentEl="body",this.element=s instanceof HTMLElement?s:document.querySelector(s),this.isInputText=this.element instanceof HTMLInputElement&&this.element.type==="text",this.button=null,this.showOnClick=!0,this.#e=h.DateTime.now().startOf("day"),this.#t=h.DateTime.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initialMonth=h.DateTime.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=h.DateTime.now().minus({year:100}).year,this.maxYear=h.DateTime.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!this.isInputText,this.timePicker=!1;const a=new Intl.DateTimeFormat(h.DateTime.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=h.Duration.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element?.classList.contains("pull-right")?"left":"right",this.drops=this.element?.classList.contains("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:h.DateTime.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:h.Info.weekdays("short"),monthNames:h.Info.months("long"),firstDay:h.Info.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=null,this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let r={};const i=Array.from(this.element.attributes).filter(t=>t.name.startsWith("data-"));for(let t of i){const c=t.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(c)||Object.keys(e).includes(c))continue;let m=h.DateTime.fromISO(t.value);const v=["startDate","endDate","minDate","maxDate","initialMonth"].includes(c);r[c]=m.isValid&&v?m:JSON.parse(t.value)}if(e={...r,...e},["string","object"].includes(typeof e.button)){let t=e.button;typeof t=="string"&&document.querySelectorAll(t).length===1&&(t=document.querySelector(t)),t instanceof HTMLButtonElement?this.button=t:console.error("Option 'button' cannot resolved to a HTMLButtonElement")}if(typeof e.singleDatePicker=="boolean"&&(this.singleDatePicker=e.singleDatePicker),!this.singleDatePicker&&typeof e.singleMonthView=="boolean"?this.singleMonthView=e.singleMonthView:this.singleMonthView=!1,e.externalStyle!==null){const t=window.getComputedStyle(document.body);t&&typeof t[Symbol.iterator]=="function"&&[...t].some(c=>c.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?I(e.template):e.template;else{let t=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>',this.singleMonthView?'<tr class="calendar-time end-time"></tr>':"","</tfoot>","</table>","</div>"];t.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",this.singleMonthView?"":'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),t.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?t.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):t.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),t.push("</div></div>"),e.template=t.join(""),this.container=I(e.template)}if(this.parentEl=document.querySelector(typeof e.parentEl=="string"?e.parentEl:this.parentEl),this.parentEl.appendChild(this.container),typeof e.timePicker=="boolean"&&(this.timePicker=e.timePicker),this.timePicker&&(this.locale.format=h.DateTime.DATETIME_SHORT),typeof e.locale=="object"){for(let t of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[t]=="string"&&(this.locale[t]=e.locale[t]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof e.locale.format)&&(this.locale.format=e.locale.format),Array.isArray(e.locale.daysOfWeek)&&(e.locale.daysOfWeek.some(t=>typeof t!="string")?console.error("Option 'locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(t=>typeof t!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=e.locale.monthNames.slice()),typeof e.locale.firstDay=="number"&&(this.locale.firstDay=e.locale.firstDay),typeof e.locale.customRangeLabel=="string"){var o=document.createElement("textarea");o.innerHTML=e.locale.customRangeLabel;var d=o.value;this.locale.customRangeLabel=d}["string","object","function"].includes(typeof e.locale.durationFormat)&&e.locale.durationFormat!=null&&(this.locale.durationFormat=e.locale.durationFormat)}this.container.classList.add(this.locale.direction);for(let t of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel","showOnClick"])typeof e[t]=="boolean"&&(this[t]=e[t]);for(let t of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[t]=="string"?this[t]=e[t]:["weekendClasses","weekendDayClasses","todayClasses"].includes(t)&&e[t]===null&&(this[t]=e[t]);for(let t of["minYear","maxYear"])typeof e[t]=="number"&&(this[t]=e[t]);for(let t of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[t]=="function"?this[t]=e[t]:this[t]=function(){return!1};if(!this.singleDatePicker){for(let t of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[t])&&(h.Duration.isDuration(e[t])&&e[t].isValid?this[t]=e[t]:h.Duration.fromISO(e[t]).isValid?this[t]=h.Duration.fromISO(e[t]):typeof e[t]=="number"&&h.Duration.fromObject({seconds:e[t]}).isValid?this[t]=h.Duration.fromObject({seconds:e[t]}):e[t]===null?this[t]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&(this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'")))}if(this.timePicker){if(["string","object","number"].includes(typeof e.timePickerStepSize)){let t;h.Duration.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?t=e.timePickerStepSize:h.Duration.fromISO(e.timePickerStepSize).isValid?t=h.Duration.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&h.Duration.fromObject({seconds:e.timePickerStepSize}).isValid?t=h.Duration.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),t=this.timePickerStepSize);var l=[];for(let c of["minutes","seconds"])l.push(...[1,2,3,4,5,6,10,12,15,20,30].map(m=>h.Duration.fromObject({[c]:m})));l.push(...[1,2,3,4,6].map(c=>h.Duration.fromObject({hours:c}))),this.timePicker24Hour&&l.push(...[8,12].map(c=>h.Duration.fromObject({hours:c}))),l.some(c=>t.rescale().equals(c))?this.timePickerStepSize=t.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(t.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<h.Duration.fromObject({hours:1}),showSeconds:this.timePickerStepSize<h.Duration.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=h.Duration.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=h.Duration.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let t of["startDate","endDate","minDate","maxDate","initialMonth"])if(!(t==="endDate"&&this.singleDatePicker)){if(typeof e[t]=="object")h.DateTime.isDateTime(e[t])&&e[t].isValid?this[t]=e[t]:e[t]instanceof Date?this[t]=h.DateTime.fromJSDate(e[t]):e[t]===null?this[t]=null:console.error(`Option '${t}' must be a luxon.DateTime or Date or string`);else if(typeof e[t]=="string"){const c=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(h.DateTime.fromISO(e[t]).isValid)this[t]=h.DateTime.fromISO(e[t]);else if(h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale}).isValid)this[t]=h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale});else{const m=h.DateTime.fromFormat(e[t],c,{locale:h.DateTime.now().locale}).invalidExplanation;console.error(`Option '${t}' is not a valid string: ${m}`)}}}if(this.isInputText&&this.element.value!=""){const t=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const c=h.DateTime.fromFormat(this.element.value,t,{locale:h.DateTime.now().locale});c.isValid?this.#e=c:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${c.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const c=this.element.value.split(this.locale.separator);if(c.length===2){const m=h.DateTime.fromFormat(c[0],t,{locale:h.DateTime.now().locale}),v=h.DateTime.fromFormat(c[1],t,{locale:h.DateTime.now().locale});m.isValid&&v.isValid?(this.#e=m,this.#t=v):console.error(`Value in <input> is not a valid string: ${m.invalidExplanation} - ${v.invalidExplanation}`)}else console.error(`Value "${this.element.value}" in <input> is not a valid string`)}}if(this.singleDatePicker?this.#t=this.#e:this.#t<this.#e&&console.error(`Option 'endDate' ${this.#t} must not be earlier than 'startDate' ${this.#e}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#e&&(this.#e=this.#e.startOf("day")),this.#t&&(this.#t=this.#t.endOf("day"))),!this.#e&&this.initialMonth)this.#t=null,this.timePicker&&console.error("Option 'initialMonth' works only with 'timePicker: false'");else{const t=this.validateInput(null,!1);if(t!=null){let c=t.startDate;if(c.length>0)if(c.some(m=>m.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${c.find(m=>m.reason.startsWith("isInvalid")).reason}`);else{const m=c.filter(v=>v.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${m}`),this.#e=m}if(!this.singleDatePicker&&(c=t.endDate.filter(m=>m.new!=null),c.length>0))if(c.some(m=>m.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${c.find(m=>m.reason.startsWith("isInvalid")).reason}`);else{const m=c.filter(v=>v.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${m}`),this.#t=m}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const t=document.querySelector(e.altInput);this.altInput=t instanceof HTMLInputElement&&t.type==="text"?t:null}else e.altInput instanceof HTMLElement&&(this.altInput=e.altInput instanceof HTMLInputElement&&e.altInput.type==="text"?e.altInput:null);else if(!this.singleDatePicker&&Array.isArray(e.altInput)&&e.altInput.length===2){this.altInput=[];for(let t of e.altInput){const c=typeof t=="string"?document.querySelector(t):t;c instanceof HTMLInputElement&&c.type==="text"&&this.altInput.push(c)}this.altInput.length!==2&&(this.altInput=null)}else e.altInput!=null&&console.warn(`Option 'altInput' ${JSON.stringify(e.altInput)} is not valid`);if(e.altInput&&["function","string"].includes(typeof e.altFormat)&&(this.altFormat=e.altFormat),typeof e.opens=="string"&&(["left","right","center"].includes(e.opens)?this.opens=e.opens:console.error("Option 'opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'drops' must be 'up', 'down' or 'auto'")),Array.isArray(e.buttonClasses)?this.buttonClasses=e.buttonClasses.join(" "):typeof e.buttonClasses=="string"&&(this.buttonClasses=e.buttonClasses),typeof e.onOutsideClick=="string"&&(["cancel","apply"].includes(e.onOutsideClick)?this.onOutsideClick=e.onOutsideClick:console.error("Option 'onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let t=this.locale.firstDay;for(;t>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),t--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let t in e.ranges){let c,m;if(["string","object"].includes(typeof e.ranges[t][0])&&(h.DateTime.isDateTime(e.ranges[t][0])&&e.ranges[t][0].isValid?c=e.ranges[t][0]:e.ranges[t][0]instanceof Date?c=h.DateTime.fromJSDate(e.ranges[t][0]):typeof e.ranges[t][0]=="string"&&h.DateTime.fromISO(e.ranges[t][0]).isValid?c=h.DateTime.fromISO(e.ranges[t][0]):console.error(`Option ranges['${t}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[t][1])&&(h.DateTime.isDateTime(e.ranges[t][1])&&e.ranges[t][1].isValid?m=e.ranges[t][1]:e.ranges[t][1]instanceof Date?m=h.DateTime.fromJSDate(e.ranges[t][1]):typeof e.ranges[t][1]=="string"&&h.DateTime.fromISO(e.ranges[t][1]).isValid?m=h.DateTime.fromISO(e.ranges[t][1]):console.error(`Option ranges['${t}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(c==null||m==null)){var o=document.createElement("textarea");o.innerHTML=t,this.ranges[o.value]=[c,m]}}var f="<ul>";for(let t in this.ranges)f+=`<li data-range-key="${t}">${t}</li>`;this.showCustomRangeLabel&&(f+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),f+="</ul>",this.container.querySelector(".ranges").prepend(I(f)),this.container.classList.add("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(t=>{t.style.display="none"}),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.classList.add("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.classList.add("single"),this.container.querySelector(".drp-calendar.left").classList.add("single"),this.container.querySelector(".drp-calendar.left").style.display="",this.container.querySelector(".drp-calendar.right").style.display="none",!this.timePicker&&this.autoApply&&this.container.classList.add("auto-apply")),(this.singleDatePicker||!Object.keys(this.ranges).length||this.alwaysShowCalendars)&&this.container.classList.add("show-calendar"),this.container.classList.add(`opens${this.opens}`),this.container.querySelectorAll(".applyBtn, .cancelBtn").forEach(t=>{t.classList.add(...this.buttonClasses.split(" "))}),this.applyButtonClasses.length&&this.container.querySelector(".applyBtn").classList.add(...this.applyButtonClasses.split(" ")),this.cancelButtonClasses.length&&this.container.querySelector(".cancelBtn").classList.add(...this.cancelButtonClasses.split(" ")),this.container.querySelector(".applyBtn").innerHTML=this.locale.applyLabel,this.container.querySelector(".cancelBtn").innerHTML=this.locale.cancelLabel,this.addListener(".drp-calendar","click",".prev",this.clickPrev.bind(this)),this.addListener(".drp-calendar","click",".next",this.clickNext.bind(this)),this.addListener(".drp-calendar","mousedown","td.available",this.clickDate.bind(this)),this.addListener(".drp-calendar","mouseenter","td.available",this.hoverDate.bind(this)),this.addListener(".drp-calendar","change","select.yearselect,select.monthselect",this.monthOrYearChanged.bind(this)),this.addListener(".drp-calendar","change","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.addListener(".ranges","click","li",this.clickRange.bind(this)),this.addListener(".ranges","mouseenter","li",this.hoverRange.bind(this)),this.addListener(".ranges","mouseleave","li",this.leaveRange.bind(this)),this.addListener(".drp-buttons","click","button.applyBtn",this.clickApply.bind(this)),this.addListener(".drp-buttons","click","button.cancelBtn",this.clickCancel.bind(this)),this.element.matches("input")||this.element.matches("button")?(this.showOnClick&&(this.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a)),this.element.addEventListener("keyup",this.#h),this.element.addEventListener("keydown",this.#o)):this.showOnClick&&(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n)),this.button&&this.button.addEventListener("click",this.#a),this.updateElement()}get startDate(){return this.timePicker?this.#e:this.#e?.startOf("day")??null}get endDate(){return this.singleDatePicker?null:(this.timePicker?this.#t:this.#t?.endOf("day"))??null}set startDate(s){this.#e=s}set endDate(s){this.#t=s}#i={onViolate:{type:"violate",param:(s,e)=>({...s,cancelable:!0})},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker"},onBeforeRenderCalendar:{type:"beforeRenderCalendar"},onShow:{type:"show"},onBeforeHide:{type:"beforeHide",param:{cancelable:!0}},onHide:{type:"hide"},onShowCalendar:{type:"showCalendar"},onHideCalendar:{type:"hideCalendar"},onOutsideClick:{type:"outsideClick",param:{cancelable:!0}},onDateChange:{type:"dateChange",param:s=>s},onTimeChange:{type:"timeChange",param:s=>s},onApply:{type:"apply"},onCancel:{type:"cancel"},onInputChange:{type:"inputChange"},onMonthViewChange:{type:"monthViewChange",param:(s,e)=>({left:this.leftCalendar.month.startOf("month"),right:this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month.startOf("month")})}};get events(){return this.#i}#s=this.outsideClick.bind(this);#r=this.move.bind(this);#l=s=>{const e=s.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(s)};#a=this.show.bind(this);#h=this.elementChanged.bind(this);#o=this.keydown.bind(this);#n=this.toggle.bind(this);setStartDate(s,e=!0){if(!this.singleDatePicker)return this.setRange(s,this.#t,e);const n=this.#e;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#e.hasSame(a,"month");return this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),e&&this.updateView(i),r}setEndDate(s,e=!0){return this.singleDatePicker?null:this.setRange(this.#e,s,e)}setRange(s,e,n=!0){if(this.singleDatePicker)return;this.#t||(this.#t=this.#e);const a=[this.#e,this.#t];let r=[this.parseDate(s),this.parseDate(e)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const o=!this.#e.hasSame(r[0],"month")||!this.#t.hasSame(r[1],"month");return this.#e=r[0],this.#t=r[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),n&&this.updateView(o),i}parseDate(s){if(typeof s=="object"){if(h.DateTime.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return h.DateTime.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const e=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format);if(h.DateTime.fromISO(s).isValid)return h.DateTime.fromISO(s);if(h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale}).isValid)return h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale});{const n=h.DateTime.fromFormat(s,e,{locale:h.DateTime.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}formatDate(s,e=this.locale.format){if(s===null)return null;if(typeof e=="object")return s.toLocaleString(e);if(h.Settings.defaultLocale===null){const n=h.DateTime.now().locale;return s.toFormat(e,{locale:n})}else return s.toFormat(e)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#e);this.singleDatePicker||(s+=this.locale.separator,this.#t&&(s+=this.formatDate(this.#t))),this.container.querySelector(".drp-selected").innerHTML=s}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#t){this.container.querySelector(".drp-duration-label").innerHTML="";return}if(typeof this.locale.durationFormat=="function")this.container.querySelector(".drp-duration-label").innerHTML=this.locale.durationFormat(this.#e,this.#t);else{let s=this.#t.plus({milliseconds:1}).diff(this.#e).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.querySelector(".drp-duration-label").innerHTML=s.toHuman(this.locale.durationFormat):this.container.querySelector(".drp-duration-label").innerHTML=s.toFormat(this.locale.durationFormat)}}}validateInput(s,e=!1){let n=s==null?this.#e:s[0],a=s==null?this.#t:s[1];if(n==null)return null;let r={startDate:[]},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const l=this.timePickerStepSize.as("seconds");n=h.DateTime.fromSeconds(l*Math.round(n.toSeconds()/l)),i.new=n,i.new.equals(i.old)||r.startDate.push(i)}else n=n.startOf("day");const o=this.timePicker?this.timePickerStepSize.as("seconds"):h.Duration.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/o)*o}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/o)*o}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.push(i));let d=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&d.push("minute"),this.timePickerOpts.showSeconds&&d.push("second"),this.timePicker24Hour||d.push("ampm")),this.isInvalidDate(n)&&r.startDate.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let l of d)this.isInvalidTime(n,l,"start")&&r.startDate.push({old:n,reason:"isInvalidTime",unit:l});if(this.singleDatePicker){if(r.startDate.length==0)return null;if(e){let l={startDate:n};const f=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:l});return f.defaultPrevented&&(r.newDate=f.newDate),r}else return r}if(a==null)return null;if(r.endDate=[],i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const l=this.timePickerStepSize.as("seconds");a=h.DateTime.fromSeconds(l*Math.round(a.toSeconds()/l)),i.new=a,i.new.equals(i.old)||r.endDate.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/o)*o}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/o)*o}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i)),this.maxSpan){const l=n.plus(this.maxSpan);a>l&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(l.diff(a).as("seconds")/o)*o}),a>l&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i))}if(this.minSpan){const l=n.plus(this.minSpan);a<l&&(i={old:a,reason:"minSpan"},this.defaultSpan?a=n.plus({seconds:Math.trunc(this.defaultSpan.as("seconds")/o)*o}):a=n.plus({seconds:Math.trunc(this.minSpan.as("seconds")/o)*o}),a<l&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.push(i))}if(this.isInvalidDate(a)&&r.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let l of d)this.isInvalidTime(a,l,"end")&&r.endDate.push({old:a,reason:"isInvalidTime",unit:l});if(r.startDate.length==0&&r.endDate.length==0)return null;if(e){let l={startDate:n,endDate:a};const f=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:l});return f.defaultPrevented&&(r.newDate=f.newDate),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.container.querySelectorAll(".calendar-time.end-time select").forEach(e=>{e.disabled=!this.#t}),this.container.querySelectorAll(".calendar-time.end-time select").forEach(e=>{e.classList.toggle("disabled",!this.#t)})),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#t){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month"))&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#e.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#t.hasSame(this.#e,"month")?this.rightCalendar.month=this.#t.startOf("month"):this.rightCalendar.month=this.#e.startOf("month").plus({month:1}))}else!this.#e&&this.initialMonth?(this.leftCalendar.month=this.initialMonth,this.singleMonthView||(this.rightCalendar.month=this.initialMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#e,"month")&&!this.rightCalendar.month.hasSame(this.#e,"month")&&(this.leftCalendar.month=this.#e.startOf("month"),this.rightCalendar.month=this.#e.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var e,n,a;this.#t?(e=parseInt(this.container.querySelector(".start-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10)))):(e=parseInt(this.container.querySelector(".end-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:e,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:e,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChange),this.container.querySelectorAll(".ranges li").forEach(r=>{r.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#e&&this.initialMonth&&(i.month=this.initialMonth.startOf("month"));const e=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=e,i.lastDay=n;for(var o=0;o<6;o++)i[o]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,S=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&S++,i[S][y%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var d=s==="left"?this.minDate:this.#e,l=this.maxDate,f="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+="<th></th>"),(!d||d<i.firstDay)&&(!this.linkedCalendars||s==="left")?f+='<th class="prev available"><span></span></th>':f+="<th></th>";var t=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const y=(l&&l.year)??this.maxYear,S=(d&&d.year)??this.minYear;let E=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var c=`${E}<select class="monthselect">`,m=1;m<=12;m++)c+=`<option value="${m}"${m===i.firstDay.month?" selected":""}`,(d&&i.firstDay.set({month:m})<d.startOf("month")||l&&i.firstDay.set({month:m})>l.endOf("month"))&&(c+=" disabled"),c+=`>${this.locale.monthNames[m-1]}</option>`;c+="</select>",this.externalStyle==="bulma"&&(c+="</div>"),E=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var v=`${E}<select class="yearselect">`,g=S;g<=y;g++)v+=`<option value="${g}"${g===i.firstDay.year?" selected":""}>${g}</option>`;v+="</select>",this.externalStyle==="bulma"&&(v+="</div>"),t=c+v}f+='<th colspan="5" class="month">'+t+"</th>",(!l||l>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?f+='<th class="next available"><span></span></th>':f+="<th></th>",f+="</tr>",f+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[y,S]of this.locale.daysOfWeek.entries())f+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&h.Info.getWeekendWeekdays().includes(y+1)&&(f+=` class="${this.weekendDayClasses}"`),f+=`>${S}</th>`;if(f+="</tr>",this.container.querySelector(`.drp-calendar.${s} .calendar-table thead`).innerHTML=f,f="",this.#t==null&&this.maxSpan){var D=this.#e.plus(this.maxSpan).endOf("day");(!l||D<l)&&(l=D)}var k;this.#t==null&&this.minSpan&&(k=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){f+="<tr>",this.showISOWeekNumbers?f+=`<td class="week">${i[y][0].weekNumber}</td>`:this.showWeekNumbers&&(f+=`<td class="week">${i[y][0].localWeekNumber}</td>`);for(let S=0;S<7;S++){var p=[];this.todayClasses&&this.todayClasses.length&&i[y][S].hasSame(h.DateTime.now(),"day")&&p.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&h.Info.getWeekendWeekdays().includes(i[y][S].weekday)&&p.push(this.weekendClasses),i[y][S].month!=i[1][1].month&&p.push("off","ends"),this.minDate&&i[y][S].startOf("day")<this.minDate.startOf("day")&&p.push("off","disabled"),l&&i[y][S].startOf("day")>l.startOf("day")&&p.push("off","disabled"),k&&i[y][S].startOf("day")>this.#e.startOf("day")&&i[y][S].startOf("day")<k.startOf("day")&&p.push("off","disabled"),this.isInvalidDate(i[y][S])&&p.push("off","disabled"),this.#e!=null&&i[y][S].hasSame(this.#e,"day")&&p.push("active","start-date"),this.#t!=null&&i[y][S].hasSame(this.#t,"day")&&p.push("active","end-date"),this.#t!=null&&i[y][S]>this.#e&&i[y][S]<this.#t&&p.push("in-range");var w=this.isCustomDate(i[y][S]);w!==!1&&(typeof w=="string"?p.push(w):p.push(...w)),p.includes("disabled")||p.push("available"),f+=`<td class="${p.join(" ")}" data-title="r${y}c${S}">${i[y][S].day}</td>`}f+="</tr>"}this.container.querySelector(`.drp-calendar.${s} .calendar-table tbody`).innerHTML=f}renderTimePicker(s){if(s==="end"&&!this.#t)return;var e,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(r=this.#e.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#e.plus(this.minSpan)),s==="start")e=this.#e,a=this.minDate;else if(s==="end"){e=this.#t,a=this.#e;let g=this.container.querySelector(".drp-calendar .calendar-time.end-time");g.innerHTML!=""&&(e=e.set({hour:isNaN(e.hour)?g.querySelector(".hourselect option:selected").value:e.hour,minute:isNaN(e.minute)?g.querySelector(".minuteselect option:selected").value:e.minute,second:isNaN(e.second)?g.querySelector(".secondselect option:selected").value:e.second})),e<this.#e&&(e=this.#e),r&&e>r&&(e=r)}let o=[],d=[];i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const l=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=l==="AM"?1:13);for(var t=f;t<=f+23;t+=this.timePickerOpts.hourStep){let g=e.set({hour:t%24}),D=!1;if(a&&g.set({minute:59})<a&&(D=!0),r&&g.set({minute:0})>r&&(D=!0),n&&g.endOf("hour")<n&&(D=!0),!D&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(D=!0),this.timePicker24Hour)!D&&t==e.hour?i+=`<option value="${t}" selected>${t}</option>`:D?i+=`<option value="${t}" disabled class="disabled">${t}</option>`:i+=`<option value="${t}">${t}</option>`;else{const k=h.DateTime.fromFormat(`${t%24}`,"H").toFormat("h"),p=h.DateTime.fromFormat(`${t%24}`,"H").toFormat("a",{locale:"en-US"});l==p?!D&&t==e.hour?i+=`<option ampm="${p}" value="${t%24}" selected>${k}</option>`:D?i+=`<option ampm="${p}" value="${t%24}" disabled class="disabled">${k}</option>`:i+=`<option ampm="${p}" value="${t%24}">${k}</option>`:i+=`<option ampm="${p}" hidden="hidden" value="${t%24}">${k}</option>`}o.push(D)}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var t=0;t<60;t+=this.timePickerOpts.minuteStep){var c=t<10?"0"+t:t;let D=e.set({minute:t}),k=!1;o.every(p=>p)&&(k=!0),a&&D.set({second:59})<a&&(k=!0),r&&D.set({second:0})>r&&(k=!0),n&&D.endOf("minute")<n&&(k=!0),!k&&this.isInvalidTime(D,this.singleDatePicker?null:s,"minute")&&(k=!0),e.minute==t&&!k?i+=`<option value="${t}" selected>${c}</option>`:k?i+=`<option value="${t}" disabled class="disabled">${c}</option>`:i+=`<option value="${t}">${c}</option>`,d.push(k)}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var t=0;t<60;t+=this.timePickerOpts.secondStep){var c=t<10?"0"+t:t;let k=e.set({second:t}),p=!1;d.every(w=>w)&&(p=!0),a&&k<a&&(p=!0),r&&k>r&&(p=!0),n&&k<n&&(p=!0),!p&&this.isInvalidTime(k,this.singleDatePicker?null:s,"second")&&(p=!0),e.second==t&&!p?i+=`<option value="${t}" selected>${c}</option>`:p?i+=`<option value="${t}" disabled class="disabled">${c}</option>`:i+=`<option value="${t}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var m="",v="";let g=!1;o.every(D=>D)&&(g=!0),a&&e.startOf("day")<a&&(g=!0),r&&e.endOf("day")>r&&(g=!0),n&&e.startOf("day")<n&&(g=!0),g?(m=' disabled class="disabled "',v=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:s,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?v=' disabled class="disabled"':m=' disabled class="disabled"'),i+=`<option value="AM"${m}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${h.Info.meridiems()[0]}</option><option value="PM"${v}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${h.Info.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${s}-time`).innerHTML=i}setApplyBtnState(){const s=this.singleDatePicker||this.#t&&this.#e<=this.#t;this.container.querySelector("button.applyBtn").disabled=!s}move(){let s={top:0,left:0},e,n,a=this.drops,r=window.innerWidth;switch(this.parentEl.matches("body")||(s={top:b(this.parentEl).top-this.parentEl.scrollTop(),left:b(this.parentEl).left-this.parentEl.scrollLeft()},r=this.parentEl[0].clientWidth+b(this.parentEl).left),this.drops){case"auto":e=b(this.element).top+O(this.element)-s.top,e+O(this.container)>=this.parentEl.scrollHeight&&(e=b(this.element).top-O(this.container)-s.top,a="up");break;case"up":e=b(this.element).top-O(this.container)-s.top;break;case"down":e=b(this.element).top+O(this.element)-s.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[o,d]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[o]=typeof d=="number"&&d>0?`${d}px`:d;const i=T(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const o=r-b(this.element).left-T(this.element);if(i+o>window.innerWidth)for(const[d,l]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:e,right:o,left:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;case"center":if(n=b(this.element).left-s.left+T(this.element)/2-i/2,n<0)for(const[d,l]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else if(n+i>window.innerWidth)for(const[d,l]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:e,left:n,right:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;case"right":if(n=b(this.element).left-s.left,n+i>window.innerWidth)for(const[d,l]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;else for(const[d,l]of Object.entries({top:`${e}px`,left:n,right:"auto"}))this.container.style[d]=typeof l=="number"&&l>0?`${l}px`:l;break;default:console.error(`Option opens '${this.opens}' not defined`);break}}show(){this.isShowing||(document.addEventListener("mousedown",this.#s),document.addEventListener("touchend",this.#s),document.addEventListener("click",this.#l),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#r),this.oldStartDate=this.#e,this.oldEndDate=this.#t,this.updateView(!1),this.container.style.display="block",this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){!this.isShowing||(this.#t||(this.#e=this.oldStartDate,this.#t=this.oldEndDate),typeof this.callback=="function"&&(this.#e&&!this.#e.equals(this.oldStartDate??h.DateTime)||this.#t&&!this.singleDatePicker&&!this.#t.equals(this.oldEndDate??h.DateTime))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented)||(document.removeEventListener("mousedown",this.#s),document.removeEventListener("touchend",this.#s),document.removeEventListener("focusin",this.#s),document.removeEventListener("click",this.#l),window.removeEventListener("resize",this.#r),this.container.style.display="none",this.triggerEvent(this.#i.onHide),this.isShowing=!1)}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.classList.add("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.classList.remove("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){const e=s.target;function n(r,i){if(i==null)return null;let o=r;for(;o;){if(o==i)return o;o=o.parentElement}return null}s.type==="focusin"||n(e,this.element)||n(e,this.container)||n(e,this.button)||e.closest(".calendar-table")||this.triggerEvent(this.#i.onOutsideClick).defaultPrevented||(this.onOutsideClick==="cancel"&&(this.#e=this.oldStartDate,this.#t=this.oldEndDate),this.hide())}clickPrev(s){s.target.closest(".drp-calendar").classList.contains("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!s.target.classList.contains("available"))return;let e=s.target.dataset.title;const n=e.substring(1,2),a=e.substring(3,4);var i=s.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const o=this.leftCalendar,d=this.rightCalendar,l=this.#e,f=this.initialMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(t=>{if(t.classList.contains("week"))return;const c=t.dataset.title,m=c.substring(1,2),v=c.substring(3,4),D=t.closest(".drp-calendar").classList.contains("left")?o.calendar[m][v]:d.calendar[m][v];!l&&f?t.classList.remove("in-range"):t.classList.toggle("in-range",D>l&&D<i||D.hasSame(i,"day"))})}hoverRange(s){const e=s.target.dataset.rangeKey,n=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],r=this.leftCalendar,i=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(o=>{if(o.classList.contains("week"))return;const d=o.dataset.ttitle,l=d.substring(1,2),f=d.substring(3,4),c=o.closest(".drp-calendar").classList.contains("left")?r.calendar[l][f]:i.calendar[l][f];o.classList.toggle("start-hover",c.hasSame(a[0],"day")),o.classList.toggle("start-date",c.hasSame(n[0],"day")),o.classList.toggle("end-hover",c.hasSame(a[1],"day")),o.classList.toggle("end-date",n[1]!=null&&c.hasSame(n[1],"day")),o.classList.toggle("range-hover",c.startOf("day")>=a[0].startOf("day")&&c.startOf("day")<=a[1].startOf("day")),o.classList.toggle("in-range",c.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&c.startOf("day")<=n[1].startOf("day"))})}leaveRange(){this.container.querySelectorAll(".drp-calendar tbody td").forEach(s=>{s.classList.contains("week")||(s.classList.remove("start-hover"),s.classList.remove("end-hover"),s.classList.remove("range-hover"))})}clickRange(s){let e=s.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{let n=this.ranges[e];const a=!this.#e.hasSame(n[0],"month")||!this.#t.hasSame(n[1],"month");this.#e=n[0],this.#t=n[1],this.timePicker||(this.#e.startOf("day"),this.#t.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented&&this.updateView(a),this.clickApply()}}clickDate(s){if(!s.target.classList.contains("available"))return;let e=s.target.dataset.title,n=e.substring(1,2),a=e.substring(3,4),i=s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a],o;if(this.#t||!this.#e||i<this.#e.startOf("day")){if(this.timePicker){let d=parseInt(this.container.querySelector(".start-time .hourselect").value,10);isNaN(d)&&(d=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10));let l=0;this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10)));let f=0;this.timePickerOpts.showSeconds&&(f=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(f)&&(f=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10))),i=i.set({hour:d,minute:l,second:f})}else i=i.startOf("day");this.#t=null,this.#e=i,o="start"}else if(!this.#t&&i<this.#e)this.#t=this.#e,o="end";else{if(this.timePicker){let d=parseInt(this.container.querySelector(".end-time .hourselect").value,10);isNaN(d)&&(d=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10));let l=0;this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10)));let f=0;this.timePickerOpts.showSeconds&&(f=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(f)&&(f=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10))),i=i.set({hour:d,minute:l,second:f})}else i=i.endOf("day");this.#t=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),o="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),o=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:o})}calculateChosenLabel(){if(Object.keys(this.ranges).length===0)return;let s=!0,e=this.timePicker?"hour":"day";this.timePicker&&(this.timePickerOpts.showMinutes?e="minute":this.timePickerOpts.showSeconds&&(e="second"));for(const[n,[a,r]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(r.startOf(e))){s=!1;const i=this.container.querySelector(`.ranges li[data-range-key="${n}"]`);this.chosenLabel=n,i.classList.add("active");break}if(s){if(this.showCustomRangeLabel){const n=this.container.querySelector(".ranges li:last-child");this.chosenLabel=n.dataset.rangeKey,n.classList.add("active")}else this.chosenLabel=null;this.showCalendars()}}timeChanged(s){const e=s.target.closest(".calendar-time"),n=e.classList.contains("start-time")?"start":"end";var a=parseInt(e.querySelector(".hourselect").value,10);if(isNaN(a)&&(a=parseInt(e.querySelector(".hourselect option:last-child").value,10)),!this.timePicker24Hour){const o=e.querySelector(".ampmselect").value;if(o==null&&e.querySelector(".ampmselect option:last-child").value,o!=h.DateTime.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(l=>{l.hidden=!l.hidden});const d=h.DateTime.fromFormat(`${a}`,"H").toFormat("h");a=h.DateTime.fromFormat(`${d}${o}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(e.querySelector(".minuteselect").value,10),isNaN(r)&&(r=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(e.querySelector(".secondselect").value,10),isNaN(i)&&(i=parseInt(e.querySelector(".secondselect option:last-child").value,10))),n==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&(this.defaultSpan&&this.#t<this.#e.plus(this.minSpan)?this.#t=this.#e.plus(this.defaultSpan):this.minSpan&&this.#t<this.#e.plus(this.minSpan)?this.#t=this.#e.plus(this.minSpan):this.#t<this.#e&&(this.#t=this.#e))):this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i}),this.#t<this.#e&&(this.#t=this.#e.plus(this.minSpan??h.Duration.fromObject({})))),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,{side:this.singleDatePicker?null:n})}monthOrYearChanged(s){const e=s.target.closest(".drp-calendar").classList.contains("left"),n=e?"left":"right",a=this.container.querySelector(`.drp-calendar.${n}`);let r=parseInt(a.querySelector(".monthselect").value,10),i=a.querySelector(".yearselect").value,o=!1;e||(i<this.#e.year||i==this.#e.year&&r<this.#e.month)&&(r=this.#e.month,i=this.#e.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),e?(o=!h.DateTime.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(o=!h.DateTime.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(o)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#e=this.oldStartDate,this.#t=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.isInputText||!this.element.value.length)return;const s=typeof this.locale.format=="string"?this.locale.format:h.DateTime.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=h.DateTime.fromFormat(this.element.value,s,{locale:h.DateTime.now().locale});const r=this.#e;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#e.hasSame(a,"month"),this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else if(!this.singleDatePicker&&e.length===2){const a=[0,1].map(o=>h.DateTime.fromFormat(e[o],s,{locale:h.DateTime.now().locale})),r=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#e.hasSame(a[0],"month")||!this.#t.hasSame(a[1],"month"),this.#e=a[0],this.#t=a[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(s){[9,11].includes(s.keyCode)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#e==null&&this.initialMonth))if(this.isInputText){let s=this.formatDate(this.#e);this.singleDatePicker||(s+=this.locale.separator,this.#t&&(s+=this.formatDate(this.#t))),this.updateAltInput(),s!==this.element.value&&(this.element.value=s,this.element.dispatchEvent(new Event("change",{bubbles:!0})))}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const e=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});if((this.singleDatePicker?this.altInput:this.altInput[0]).value=e,!this.singleDatePicker&&this.#t){const n=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});this.altInput[1].value=n}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);if((this.singleDatePicker?this.altInput:this.altInput[0]).value=s,!this.singleDatePicker&&this.#t){const e=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);this.altInput[1].value=e}}}remove(){this.element.removeEventListener("click",this.#a),this.element.removeEventListener("focus",this.#a),this.element.removeEventListener("keyup",this.#h),this.element.removeEventListener("keydown",this.#o),this.element.removeEventListener("click",this.#n),this.element.removeEventListener("keydown",this.#n),this.container.remove()}triggerEvent(s,...e){if(e.length===0){const n=new $(this,s);return this.element.dispatchEvent(n),n}else{const n=new $(this,s,...e);return this.element.dispatchEvent(n),n}}addListener(s,e,n,a){this.container.querySelectorAll(s).forEach(r=>{r.addEventListener(e,function(i){const o=i.target.closest(n);o&&r.contains(o)&&a.call(o,i)})})}}function I(u){const s=document.createElement("template");return s.innerHTML=u.trim(),s.content.firstElementChild}class $ extends Event{#e;constructor(s,e,n={}){let a={};e.param&&(a=typeof e.param=="function"?e.param():e.param),a={...a,...n},super(e.type,a),this.#e=s;for(const[r,i]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(r)||(this[r]=i)}get picker(){return this.#e}}function b(u){const s=u.getBoundingClientRect();return{top:s.top+window.scrollY,left:s.left+window.scrollX}}function T(u,s=!1){if(!s)return u.offsetWidth;const e=getComputedStyle(u);return u.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function O(u,s=!1){if(!s)return u.offsetHeight;const e=getComputedStyle(u);return u.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function P(u,s,e){return typeof u=="string"?P(document.querySelectorAll(u),s,e):(u instanceof HTMLElement&&(u=[u]),(u instanceof NodeList||u instanceof HTMLCollection)&&(u=Array.from(u)),u==null?new L(null,s||{},e):(u.forEach(n=>{n._daterangepicker&&typeof n._daterangepicker.remove=="function"&&n._daterangepicker.remove(),n._daterangepicker=new L(n,s||{},e)}),u.length===1?u[0]:u))}function q(u){return typeof u=="string"&&(u=document.querySelector(u)),u instanceof HTMLElement?u._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(u,s){return this.each(function(){P(this,u,s)})});function M(u){u?.fn&&(u.fn.daterangepicker=function(s,e){return this.each(function(){P(this,s,e)})})}return Object.defineProperty(window,"jQuery",{configurable:!0,set(u){this._jQuery=u,M(u)},get(){return this._jQuery}}),C.DateRangePicker=L,C.daterangepicker=P,C.getDateRangePicker=q,C})({},luxon);
2
2
  //# sourceMappingURL=daterangepicker.min.js.map