@wernfried/daterangepicker 5.2.12 → 5.2.13

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
- import{DateTime as c,Duration as D,Info as O,Settings as M}from"luxon";class x{#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.#e=c.now().startOf("day"),this.#t=c.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initialMonth=c.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=c.now().minus({year:100}).year,this.maxYear=c.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(c.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=D.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:c.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:O.weekdays("short"),monthNames:O.months("long"),firstDay:O.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=null,this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let l={};const t=Array.from(this.element.attributes).filter(i=>i.name.startsWith("data-"));for(let i of t){const o=i.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(o)||Object.keys(e).includes(o))continue;let u=c.fromISO(i.value);const b=["startDate","endDate","minDate","maxDate","initialMonth"].includes(o);l[o]=u.isValid&&b?u:JSON.parse(i.value)}if(e={...l,...e},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 i=window.getComputedStyle(document.body);i&&typeof i[Symbol.iterator]=="function"&&[...i].some(o=>o.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?E(e.template):e.template;else{let i=['<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>"];i.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>"),i.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?i.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):i.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),i.push("</div></div>"),e.template=i.join(""),this.container=E(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=c.DATETIME_SHORT),typeof e.locale=="object"){for(let i of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[i]=="string"&&(this.locale[i]=e.locale[i]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'options.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(i=>typeof i!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(i=>typeof i!="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 h=document.createElement("textarea");h.innerHTML=e.locale.customRangeLabel;var d=h.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 i of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof e[i]=="boolean"&&(this[i]=e[i]);for(let i of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[i]=="string"?this[i]=e[i]:["weekendClasses","weekendDayClasses","todayClasses"].includes(i)&&e[i]===null&&(this[i]=e[i]);for(let i of["minYear","maxYear"])typeof e[i]=="number"&&(this[i]=e[i]);for(let i of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[i]=="function"?this[i]=e[i]:this[i]=function(){return!1};if(!this.singleDatePicker){for(let i of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[i])&&(D.isDuration(e[i])&&e[i].isValid?this[i]=e[i]:D.fromISO(e[i]).isValid?this[i]=D.fromISO(e[i]):typeof e[i]=="number"&&D.fromObject({seconds:e[i]}).isValid?this[i]=D.fromObject({seconds:e[i]}):e[i]===null?this[i]=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.defaultSpan&&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 i;D.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?i=e.timePickerStepSize:D.fromISO(e.timePickerStepSize).isValid?i=D.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&D.fromObject({seconds:e.timePickerStepSize}).isValid?i=D.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),i=this.timePickerStepSize);var r=[];for(let o of["minutes","seconds"])r.push(...[1,2,3,4,5,6,10,12,15,20,30].map(u=>D.fromObject({[o]:u})));r.push(...[1,2,3,4,6].map(o=>D.fromObject({hours:o}))),this.timePicker24Hour&&r.push(...[8,12].map(o=>D.fromObject({hours:o}))),r.some(o=>i.rescale().equals(o))?this.timePickerStepSize=i.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(i.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<D.fromObject({hours:1}),showSeconds:this.timePickerStepSize<D.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=D.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=D.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let i of["startDate","endDate","minDate","maxDate","initialMonth"])if(!(i==="endDate"&&this.singleDatePicker)){if(typeof e[i]=="object")c.isDateTime(e[i])&&e[i].isValid?this[i]=e[i]:e[i]instanceof Date?this[i]=c.fromJSDate(e[i]):e[i]===null?this[i]=null:console.error(`Option '${i}' must be a luxon.DateTime or Date or string`);else if(typeof e[i]=="string"){const o=typeof this.locale.format=="string"?this.locale.format:c.parseFormatForOpts(this.locale.format);if(c.fromISO(e[i]).isValid)this[i]=c.fromISO(e[i]);else if(c.fromFormat(e[i],o,{locale:c.now().locale}).isValid)this[i]=c.fromFormat(e[i],o,{locale:c.now().locale});else{const u=c.fromFormat(e[i],o,{locale:c.now().locale}).invalidExplanation;console.error(`Option '${i}' is not a valid string: ${u}`)}}}if(this.isInputText&&this.element.value!=""){const i=typeof this.locale.format=="string"?this.locale.format:c.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const o=c.fromFormat(this.element.value,i,{locale:c.now().locale});o.isValid?this.#e=o:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${o.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const o=this.element.value.split(this.locale.separator);if(o.length===2){const u=c.fromFormat(o[0],i,{locale:c.now().locale}),b=c.fromFormat(o[1],i,{locale:c.now().locale});u.isValid&&b.isValid?(this.#e=u,this.#t=b):console.error(`Value in <input> is not a valid string: ${u.invalidExplanation} - ${b.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 i=this.validateInput(null,!1);if(i!=null){let o=i.startDate;if(o.length>0)if(o.some(u=>u.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${o.find(u=>u.reason.startsWith("isInvalid")).reason}`);else{const u=o.filter(b=>b.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${u}`),this.#e=u}if(!this.singleDatePicker&&(o=i.endDate.filter(u=>u.new!=null),o.length>0))if(o.some(u=>u.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${o.find(u=>u.reason.startsWith("isInvalid")).reason}`);else{const u=o.filter(b=>b.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${u}`),this.#t=u}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const i=document.querySelector(e.altInput);this.altInput=i instanceof HTMLInputElement&&i.type==="text"?i: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 i of e.altInput){const o=typeof i=="string"?document.querySelector(i):i;o instanceof HTMLInputElement&&o.type==="text"&&this.altInput.push(o)}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 'options.opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'options.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 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let i=this.locale.firstDay;for(;i>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),i--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let i in e.ranges){let o,u;if(["string","object"].includes(typeof e.ranges[i][0])&&(c.isDateTime(e.ranges[i][0])&&e.ranges[i][0].isValid?o=e.ranges[i][0]:e.ranges[i][0]instanceof Date?o=c.fromJSDate(e.ranges[i][0]):typeof e.ranges[i][0]=="string"&&c.fromISO(e.ranges[i][0]).isValid?o=c.fromISO(e.ranges[i][0]):console.error(`Option ranges['${i}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[i][1])&&(c.isDateTime(e.ranges[i][1])&&e.ranges[i][1].isValid?u=e.ranges[i][1]:e.ranges[i][1]instanceof Date?u=c.fromJSDate(e.ranges[i][1]):typeof e.ranges[i][1]=="string"&&c.fromISO(e.ranges[i][1]).isValid?u=c.fromISO(e.ranges[i][1]):console.error(`Option ranges['${i}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(o==null||u==null)){var h=document.createElement("textarea");h.innerHTML=i,this.ranges[h.value]=[o,u]}}var f="<ul>";for(let i in this.ranges)f+=`<li data-range-key="${i}">${i}</li>`;this.showCustomRangeLabel&&(f+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),f+="</ul>",this.container.querySelector(".ranges").prepend(E(f)),this.container.classList.add("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(i=>{i.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(i=>{i.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.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a),this.element.addEventListener("keyup",this.#o),this.element.addEventListener("keydown",this.#h)):(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n)),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);#l=this.move.bind(this);#r=s=>{const e=s.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(s)};#a=this.show.bind(this);#o=this.elementChanged.bind(this);#h=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 l=this.validateInput([a,null],!0);if(l!=null)if(l.newDate!=null)a=l.newDate.startDate;else return l;const t=!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(t),l}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 l=[this.parseDate(s),this.parseDate(e)];if(a[0].equals(l[0])&&a[1].equals(l[1])||l[0]>l[1])return;const t=this.validateInput([l[0],l[1]],!0);if(t!=null)if(t.newDate!=null)l[0]=t.newDate.startDate,l[1]=t.newDate.endDate;else return t;const h=!this.#e.hasSame(l[0],"month")||!this.#t.hasSame(l[1],"month");return this.#e=l[0],this.#t=l[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),n&&this.updateView(h),t}parseDate(s){if(typeof s=="object"){if(c.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return c.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:c.parseFormatForOpts(this.locale.format);if(c.fromISO(s).isValid)return c.fromISO(s);if(c.fromFormat(s,e,{locale:c.now().locale}).isValid)return c.fromFormat(s,e,{locale:c.now().locale});{const n=c.fromFormat(s,e,{locale:c.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(M.defaultLocale===null){const n=c.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 l={startDate:[]},t={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const r=this.timePickerStepSize.as("seconds");n=c.fromSeconds(r*Math.round(n.toSeconds()/r)),t.new=n,t.new.equals(t.old)||l.startDate.push(t)}else n=n.startOf("day");const h=this.timePicker?this.timePickerStepSize.as("seconds"):D.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(t={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/h)*h}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=n,t.new.equals(t.old)||l.startDate.push(t)):this.maxDate&&n>this.maxDate&&(t={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/h)*h}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=n,t.new.equals(t.old)||l.startDate.push(t));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)&&l.startDate.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let r of d)this.isInvalidTime(n,r,"start")&&l.startDate.push({old:n,reason:"isInvalidTime",unit:r});if(this.singleDatePicker){if(l.startDate.length==0)return null;if(e){let r={startDate:n};const f=this.triggerEvent(this.#i.onViolate,{violation:l,newDate:r});return f.defaultPrevented&&(l.newDate=f.newDate),l}else return l}if(a==null)return null;if(l.endDate=[],t={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const r=this.timePickerStepSize.as("seconds");a=c.fromSeconds(r*Math.round(a.toSeconds()/r)),t.new=a,t.new.equals(t.old)||l.endDate.push(t)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(t={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/h)*h}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t)):this.minDate&&a<this.minDate&&(t={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/h)*h}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t)),this.maxSpan){const r=n.plus(this.maxSpan);a>r&&(t={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(r.diff(a).as("seconds")/h)*h}),a>r&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t))}if(this.minSpan){const r=n.plus(this.defaultSpan??this.minSpan);a<r&&(t={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(r.diff(a).as("seconds")/h)*h}),a<r&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t))}if(this.isInvalidDate(a)&&l.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let r of d)this.isInvalidTime(a,r,"end")&&l.endDate.push({old:a,reason:"isInvalidTime",unit:r});if(l.startDate.length==0&&l.endDate.length==0)return null;if(e){let r={startDate:n,endDate:a};const f=this.triggerEvent(this.#i.onViolate,{violation:l,newDate:r});return f.defaultPrevented&&(l.newDate=f.newDate),l}else return l}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.container.querySelectorAll(".calendar-time.end-time select").disabled=!this.#t,this.container.querySelectorAll(".calendar-time.end-time select").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(l=>{l.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var t=s==="left"?this.leftCalendar:this.rightCalendar;t.month==null&&!this.#e&&this.initialMonth&&(t.month=this.initialMonth.startOf("month"));const e=t.month.startOf("month"),n=t.month.endOf("month").startOf("day");var a=t.month.startOf("month").minus({day:1});const l={hour:t.month.hour,minute:t.month.minute,second:t.month.second};var t=[];t.firstDay=e,t.lastDay=n;for(var h=0;h<6;h++)t[h]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,k=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&k++,t[k][y%7]=a.set(l);s==="left"?this.leftCalendar.calendar=t:this.rightCalendar.calendar=t;var d=s==="left"?this.minDate:this.#e,r=this.maxDate,f="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+="<th></th>"),(!d||d<t.firstDay)&&(!this.linkedCalendars||s==="left")?f+='<th class="prev available"><span></span></th>':f+="<th></th>";var i=`${this.locale.monthNames[t.firstDay.month-1]} ${t.firstDay.year}`;if(this.showDropdowns){const y=(r&&r.year)??this.maxYear,k=(d&&d.year)??this.minYear;let I=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var o=`${I}<select class="monthselect">`,u=1;u<=12;u++)o+=`<option value="${u}"${u===t.firstDay.month?" selected":""}`,(d&&t.firstDay.set({month:u})<d.startOf("month")||r&&t.firstDay.set({month:u})>r.endOf("month"))&&(o+=" disabled"),o+=`>${this.locale.monthNames[u-1]}</option>`;o+="</select>",this.externalStyle==="bulma"&&(o+="</div>"),I=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var b=`${I}<select class="yearselect">`,g=k;g<=y;g++)b+=`<option value="${g}"${g===t.firstDay.year?" selected":""}>${g}</option>`;b+="</select>",this.externalStyle==="bulma"&&(b+="</div>"),i=o+b}f+='<th colspan="5" class="month">'+i+"</th>",(!r||r>t.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,k]of this.locale.daysOfWeek.entries())f+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&O.getWeekendWeekdays().includes(y+1)&&(f+=` class="${this.weekendDayClasses}"`),f+=`>${k}</th>`;if(f+="</tr>",this.container.querySelector(`.drp-calendar.${s} .calendar-table thead`).innerHTML=f,f="",this.#t==null&&this.maxSpan){var S=this.#e.plus(this.maxSpan).endOf("day");(!r||S<r)&&(r=S)}var v;this.#t==null&&this.minSpan&&(v=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){f+="<tr>",this.showISOWeekNumbers?f+=`<td class="week">${t[y][0].weekNumber}</td>`:this.showWeekNumbers&&(f+=`<td class="week">${t[y][0].localWeekNumber}</td>`);for(let k=0;k<7;k++){var p=[];this.todayClasses&&this.todayClasses.length&&t[y][k].hasSame(c.now(),"day")&&p.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&O.getWeekendWeekdays().includes(t[y][k].weekday)&&p.push(this.weekendClasses),t[y][k].month!=t[1][1].month&&p.push("off","ends"),this.minDate&&t[y][k].startOf("day")<this.minDate.startOf("day")&&p.push("off","disabled"),r&&t[y][k].startOf("day")>r.startOf("day")&&p.push("off","disabled"),v&&t[y][k].startOf("day")>this.#e.startOf("day")&&t[y][k].startOf("day")<v.startOf("day")&&p.push("off","disabled"),this.isInvalidDate(t[y][k])&&p.push("off","disabled"),this.#e!=null&&t[y][k].hasSame(this.#e,"day")&&p.push("active","start-date"),this.#t!=null&&t[y][k].hasSame(this.#t,"day")&&p.push("active","end-date"),this.#t!=null&&t[y][k]>this.#e&&t[y][k]<this.#t&&p.push("in-range");var C=this.isCustomDate(t[y][k]);C!==!1&&(typeof C=="string"?p.push(C):p.push(...C)),p.includes("disabled")||p.push("available"),f+=`<td class="${p.join(" ")}" data-title="r${y}c${k}">${t[y][k].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,l=this.maxDate;let t="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(t+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(l=this.#e.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#e.plus(this.defaultSpan??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),l&&e>l&&(e=l)}let h=[],d=[];t+='<th colspan="7">',this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="hourselect">';const r=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=r==="AM"?1:13);for(var i=f;i<=f+23;i+=this.timePickerOpts.hourStep){let g=e.set({hour:i%24}),S=!1;if(a&&g.set({minute:59})<a&&(S=!0),l&&g.set({minute:0})>l&&(S=!0),n&&g.endOf("hour")<n&&(S=!0),!S&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(S=!0),this.timePicker24Hour)!S&&i==e.hour?t+=`<option value="${i}" selected>${i}</option>`:S?t+=`<option value="${i}" disabled class="disabled">${i}</option>`:t+=`<option value="${i}">${i}</option>`;else{const v=c.fromFormat(`${i%24}`,"H").toFormat("h"),p=c.fromFormat(`${i%24}`,"H").toFormat("a",{locale:"en-US"});r==p?!S&&i==e.hour?t+=`<option ampm="${p}" value="${i%24}" selected>${v}</option>`:S?t+=`<option ampm="${p}" value="${i%24}" disabled class="disabled">${v}</option>`:t+=`<option ampm="${p}" value="${i%24}">${v}</option>`:t+=`<option ampm="${p}" hidden="hidden" value="${i%24}">${v}</option>`}h.push(S)}if(t+="</select>",this.externalStyle==="bulma"&&(t+="</div>"),this.timePickerOpts.showMinutes){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="minuteselect">';for(var i=0;i<60;i+=this.timePickerOpts.minuteStep){var o=i<10?"0"+i:i;let S=e.set({minute:i}),v=!1;h.every(p=>p)&&(v=!0),a&&S.set({second:59})<a&&(v=!0),l&&S.set({second:0})>l&&(v=!0),n&&S.endOf("minute")<n&&(v=!0),!v&&this.isInvalidTime(S,this.singleDatePicker?null:s,"minute")&&(v=!0),e.minute==i&&!v?t+=`<option value="${i}" selected>${o}</option>`:v?t+=`<option value="${i}" disabled class="disabled">${o}</option>`:t+=`<option value="${i}">${o}</option>`,d.push(v)}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(this.timePickerOpts.showSeconds){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="secondselect">';for(var i=0;i<60;i+=this.timePickerOpts.secondStep){var o=i<10?"0"+i:i;let v=e.set({second:i}),p=!1;d.every(C=>C)&&(p=!0),a&&v<a&&(p=!0),l&&v>l&&(p=!0),n&&v<n&&(p=!0),!p&&this.isInvalidTime(v,this.singleDatePicker?null:s,"second")&&(p=!0),e.second==i&&!p?t+=`<option value="${i}" selected>${o}</option>`:p?t+=`<option value="${i}" disabled class="disabled">${o}</option>`:t+=`<option value="${i}">${o}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="ampmselect">';var u="",b="";let g=!1;h.every(S=>S)&&(g=!0),a&&e.startOf("day")<a&&(g=!0),l&&e.endOf("day")>l&&(g=!0),n&&e.startOf("day")<n&&(g=!0),g?(u=' disabled class="disabled "',b=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:s,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?b=' disabled class="disabled"':u=' disabled class="disabled"'),t+=`<option value="AM"${u}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(t+=" selected"),t+=`>${O.meridiems()[0]}</option><option value="PM"${b}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(t+=" selected"),t+=`>${O.meridiems()[1]}</option>`,t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}t+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${s}-time`).innerHTML=t}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,l=window.innerWidth;switch(this.parentEl.matches("body")||(s={top:w(this.parentEl).top-this.parentEl.scrollTop(),left:w(this.parentEl).left-this.parentEl.scrollLeft()},l=this.parentEl[0].clientWidth+w(this.parentEl).left),this.drops){case"auto":e=w(this.element).top+P(this.element)-s.top,e+P(this.container)>=this.parentEl.scrollHeight&&(e=w(this.element).top-P(this.container)-s.top,a="up");break;case"up":e=w(this.element).top-P(this.container)-s.top;break;case"down":e=w(this.element).top+P(this.element)-s.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[h,d]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[h]=typeof d=="number"&&d>0?`${d}px`:d;const t=$(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const h=l-w(this.element).left-$(this.element);if(t+h>window.innerWidth)for(const[d,r]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:e,right:h,left:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;break;case"center":if(n=w(this.element).left-s.left+$(this.element)/2-t/2,n<0)for(const[d,r]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else if(n+t>window.innerWidth)for(const[d,r]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:e,left:n,right:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;break;case"right":if(n=w(this.element).left-s.left,n+t>window.innerWidth)for(const[d,r]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:`${e}px`,left:n,right:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;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.#r),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#l),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??c)||this.#t&&!this.singleDatePicker&&!this.#t.equals(this.oldEndDate??c))&&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.#r),window.removeEventListener("resize",this.#l),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(l,t){let h=l.parentElement;for(;h;){if(h==t)return h;h=h.parentElement}return null}s.type==="focusin"||n(e,this.element)||n(e,this.container)||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 t=s.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const h=this.leftCalendar,d=this.rightCalendar,r=this.#e,f=this.initialMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(i=>{if(i.classList.contains("week"))return;const o=i.dataset.title,u=o.substring(1,2),b=o.substring(3,4),S=i.closest(".drp-calendar").classList.contains("left")?h.calendar[u][b]:d.calendar[u][b];!r&&f?i.classList.remove("in-range"):i.classList.toggle("in-range",S>r&&S<t||S.hasSame(t,"day"))})}hoverRange(s){const e=s.target.dataset.rangeKey,n=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],l=this.leftCalendar,t=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(h=>{if(h.classList.contains("week"))return;const d=h.dataset.ttitle,r=d.substring(1,2),f=d.substring(3,4),o=h.closest(".drp-calendar").classList.contains("left")?l.calendar[r][f]:t.calendar[r][f];h.classList.toggle("start-hover",o.hasSame(a[0],"day")),h.classList.toggle("start-date",o.hasSame(n[0],"day")),h.classList.toggle("end-hover",o.hasSame(a[1],"day")),h.classList.toggle("end-date",n[1]!=null&&o.hasSame(n[1],"day")),h.classList.toggle("range-hover",o.startOf("day")>=a[0].startOf("day")&&o.startOf("day")<=a[1].startOf("day")),h.classList.toggle("in-range",o.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&o.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),t=s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a],h;if(this.#t||!this.#e||t<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 r=0;this.timePickerOpts.showMinutes&&(r=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(r)&&(r=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))),t=t.set({hour:d,minute:r,second:f})}else t=t.startOf("day");this.#t=null,this.#e=t,h="start"}else if(!this.#t&&t<this.#e)this.#t=this.#e,h="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 r=0;this.timePickerOpts.showMinutes&&(r=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(r)&&(r=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))),t=t.set({hour:d,minute:r,second:f})}else t=t.endOf("day");this.#t=t,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),h="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),h=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:h})}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,l]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(l.startOf(e))){s=!1;const t=this.container.querySelector(`.ranges li[data-range-key="${n}"]`);this.chosenLabel=n,t.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 h=e.querySelector(".ampmselect").value;if(h==null&&e.querySelector(".ampmselect option:last-child").value,h!=c.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(r=>{r.hidden=!r.hidden});const d=c.fromFormat(`${a}`,"H").toFormat("h");a=c.fromFormat(`${d}${h}`,"ha",{locale:"en-US"}).hour}}var l=0;this.timePickerOpts.showMinutes&&(l=parseInt(e.querySelector(".minuteselect").value,10),isNaN(l)&&(l=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var t=0;this.timePickerOpts.showSeconds&&(t=parseInt(e.querySelector(".secondselect").value,10),isNaN(t)&&(t=parseInt(e.querySelector(".secondselect option:last-child").value,10))),n==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:l,second:t})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&this.#t<this.#e&&(this.#t=this.#e)):this.#t&&(this.#t=this.#t.set({hour:a,minute:l,second:t})),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 l=parseInt(a.querySelector(".monthselect").value,10),t=a.querySelector(".yearselect").value,h=!1;e||(t<this.#e.year||t==this.#e.year&&l<this.#e.month)&&(l=this.#e.month,t=this.#e.year),this.minDate&&(t<this.minDate.year||t==this.minDate.year&&l<this.minDate.month)&&(l=this.minDate.month,t=this.minDate.year),this.maxDate&&(t>this.maxDate.year||t==this.maxDate.year&&l>this.maxDate.month)&&(l=this.maxDate.month,t=this.maxDate.year),e?(h=!c.fromObject({year:t,month:l}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:t,month:l}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(h=!c.fromObject({year:t,month:l}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:t,month:l}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(h)}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:c.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=c.fromFormat(this.element.value,s,{locale:c.now().locale});const l=this.#e;if(!a.isValid||l.equals(a))return;const t=this.validateInput([a,null],!0);if(t!=null)if(t.newDate!=null)a=t.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(h=>c.fromFormat(e[h],s,{locale:c.now().locale})),l=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||l[0].equals(a[0])&&l[1].equals(a[1])||a[0]>a[1])return;const t=this.validateInput([a[0],a[1]],!0);if(t!=null)if(t.newDate!=null)a[0]=t.newDate.startDate,a[1]=t.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.#o),this.element.removeEventListener("keydown",this.#h),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 q(this,s);return this.element.dispatchEvent(n),n}else{const n=new q(this,s,...e);return this.element.dispatchEvent(n),n}}addListener(s,e,n,a){this.container.querySelectorAll(s).forEach(l=>{l.addEventListener(e,function(t){const h=t.target.closest(n);h&&l.contains(h)&&a.call(h,t)})})}}function E(m){const s=document.createElement("template");return s.innerHTML=m.trim(),s.content.firstElementChild}class q 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[l,t]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(l)||(this[l]=t)}get picker(){return this.#e}}function w(m){const s=m.getBoundingClientRect();return{top:s.top+window.scrollY,left:s.left+window.scrollX}}function $(m,s=!1){if(!s)return m.offsetWidth;const e=getComputedStyle(m);return m.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function P(m,s=!1){if(!s)return m.offsetHeight;const e=getComputedStyle(m);return m.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function L(m,s,e){return typeof m=="string"?L(document.querySelectorAll(m),s,e):(m instanceof HTMLElement&&(m=[m]),(m instanceof NodeList||m instanceof HTMLCollection)&&(m=Array.from(m)),m==null?new x(null,s||{},e):(m.forEach(n=>{n._daterangepicker&&typeof n._daterangepicker.remove=="function"&&n._daterangepicker.remove(),n._daterangepicker=new x(n,s||{},e)}),m.length===1?m[0]:m))}function T(m){return typeof m=="string"&&(m=document.querySelector(m)),m instanceof HTMLElement?m._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(m,s){return this.each(function(){L(this,m,s)})});function N(m){m?.fn&&(m.fn.daterangepicker=function(s,e){return this.each(function(){L(this,s,e)})})}Object.defineProperty(window,"jQuery",{configurable:!0,set(m){this._jQuery=m,N(m)},get(){return this._jQuery}});export{x as DateRangePicker,L as daterangepicker,T as getDateRangePicker};
1
+ import{DateTime as c,Duration as D,Info as O,Settings as M}from"luxon";class x{#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.#e=c.now().startOf("day"),this.#t=c.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initialMonth=c.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=c.now().minus({year:100}).year,this.maxYear=c.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(c.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=D.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:c.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:O.weekdays("short"),monthNames:O.months("long"),firstDay:O.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=null,this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let l={};const t=Array.from(this.element.attributes).filter(i=>i.name.startsWith("data-"));for(let i of t){const o=i.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(o)||Object.keys(e).includes(o))continue;let u=c.fromISO(i.value);const b=["startDate","endDate","minDate","maxDate","initialMonth"].includes(o);l[o]=u.isValid&&b?u:JSON.parse(i.value)}if(e={...l,...e},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 i=window.getComputedStyle(document.body);i&&typeof i[Symbol.iterator]=="function"&&[...i].some(o=>o.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?E(e.template):e.template;else{let i=['<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>"];i.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>"),i.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?i.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):i.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),i.push("</div></div>"),e.template=i.join(""),this.container=E(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=c.DATETIME_SHORT),typeof e.locale=="object"){for(let i of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[i]=="string"&&(this.locale[i]=e.locale[i]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'options.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(i=>typeof i!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(i=>typeof i!="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 h=document.createElement("textarea");h.innerHTML=e.locale.customRangeLabel;var d=h.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 i of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof e[i]=="boolean"&&(this[i]=e[i]);for(let i of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[i]=="string"?this[i]=e[i]:["weekendClasses","weekendDayClasses","todayClasses"].includes(i)&&e[i]===null&&(this[i]=e[i]);for(let i of["minYear","maxYear"])typeof e[i]=="number"&&(this[i]=e[i]);for(let i of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[i]=="function"?this[i]=e[i]:this[i]=function(){return!1};if(!this.singleDatePicker){for(let i of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[i])&&(D.isDuration(e[i])&&e[i].isValid?this[i]=e[i]:D.fromISO(e[i]).isValid?this[i]=D.fromISO(e[i]):typeof e[i]=="number"&&D.fromObject({seconds:e[i]}).isValid?this[i]=D.fromObject({seconds:e[i]}):e[i]===null?this[i]=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.defaultSpan&&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 i;D.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?i=e.timePickerStepSize:D.fromISO(e.timePickerStepSize).isValid?i=D.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&D.fromObject({seconds:e.timePickerStepSize}).isValid?i=D.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),i=this.timePickerStepSize);var r=[];for(let o of["minutes","seconds"])r.push(...[1,2,3,4,5,6,10,12,15,20,30].map(u=>D.fromObject({[o]:u})));r.push(...[1,2,3,4,6].map(o=>D.fromObject({hours:o}))),this.timePicker24Hour&&r.push(...[8,12].map(o=>D.fromObject({hours:o}))),r.some(o=>i.rescale().equals(o))?this.timePickerStepSize=i.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(i.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<D.fromObject({hours:1}),showSeconds:this.timePickerStepSize<D.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=D.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=D.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let i of["startDate","endDate","minDate","maxDate","initialMonth"])if(!(i==="endDate"&&this.singleDatePicker)){if(typeof e[i]=="object")c.isDateTime(e[i])&&e[i].isValid?this[i]=e[i]:e[i]instanceof Date?this[i]=c.fromJSDate(e[i]):e[i]===null?this[i]=null:console.error(`Option '${i}' must be a luxon.DateTime or Date or string`);else if(typeof e[i]=="string"){const o=typeof this.locale.format=="string"?this.locale.format:c.parseFormatForOpts(this.locale.format);if(c.fromISO(e[i]).isValid)this[i]=c.fromISO(e[i]);else if(c.fromFormat(e[i],o,{locale:c.now().locale}).isValid)this[i]=c.fromFormat(e[i],o,{locale:c.now().locale});else{const u=c.fromFormat(e[i],o,{locale:c.now().locale}).invalidExplanation;console.error(`Option '${i}' is not a valid string: ${u}`)}}}if(this.isInputText&&this.element.value!=""){const i=typeof this.locale.format=="string"?this.locale.format:c.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const o=c.fromFormat(this.element.value,i,{locale:c.now().locale});o.isValid?this.#e=o:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${o.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const o=this.element.value.split(this.locale.separator);if(o.length===2){const u=c.fromFormat(o[0],i,{locale:c.now().locale}),b=c.fromFormat(o[1],i,{locale:c.now().locale});u.isValid&&b.isValid?(this.#e=u,this.#t=b):console.error(`Value in <input> is not a valid string: ${u.invalidExplanation} - ${b.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 i=this.validateInput(null,!1);if(i!=null){let o=i.startDate;if(o.length>0)if(o.some(u=>u.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${o.find(u=>u.reason.startsWith("isInvalid")).reason}`);else{const u=o.filter(b=>b.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${u}`),this.#e=u}if(!this.singleDatePicker&&(o=i.endDate.filter(u=>u.new!=null),o.length>0))if(o.some(u=>u.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${o.find(u=>u.reason.startsWith("isInvalid")).reason}`);else{const u=o.filter(b=>b.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${u}`),this.#t=u}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const i=document.querySelector(e.altInput);this.altInput=i instanceof HTMLInputElement&&i.type==="text"?i: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 i of e.altInput){const o=typeof i=="string"?document.querySelector(i):i;o instanceof HTMLInputElement&&o.type==="text"&&this.altInput.push(o)}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 'options.opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'options.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 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let i=this.locale.firstDay;for(;i>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),i--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let i in e.ranges){let o,u;if(["string","object"].includes(typeof e.ranges[i][0])&&(c.isDateTime(e.ranges[i][0])&&e.ranges[i][0].isValid?o=e.ranges[i][0]:e.ranges[i][0]instanceof Date?o=c.fromJSDate(e.ranges[i][0]):typeof e.ranges[i][0]=="string"&&c.fromISO(e.ranges[i][0]).isValid?o=c.fromISO(e.ranges[i][0]):console.error(`Option ranges['${i}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[i][1])&&(c.isDateTime(e.ranges[i][1])&&e.ranges[i][1].isValid?u=e.ranges[i][1]:e.ranges[i][1]instanceof Date?u=c.fromJSDate(e.ranges[i][1]):typeof e.ranges[i][1]=="string"&&c.fromISO(e.ranges[i][1]).isValid?u=c.fromISO(e.ranges[i][1]):console.error(`Option ranges['${i}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(o==null||u==null)){var h=document.createElement("textarea");h.innerHTML=i,this.ranges[h.value]=[o,u]}}var f="<ul>";for(let i in this.ranges)f+=`<li data-range-key="${i}">${i}</li>`;this.showCustomRangeLabel&&(f+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),f+="</ul>",this.container.querySelector(".ranges").prepend(E(f)),this.container.classList.add("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(i=>{i.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(i=>{i.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.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a),this.element.addEventListener("keyup",this.#o),this.element.addEventListener("keydown",this.#h)):(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n)),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);#l=this.move.bind(this);#r=s=>{const e=s.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(s)};#a=this.show.bind(this);#o=this.elementChanged.bind(this);#h=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 l=this.validateInput([a,null],!0);if(l!=null)if(l.newDate!=null)a=l.newDate.startDate;else return l;const t=!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(t),l}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 l=[this.parseDate(s),this.parseDate(e)];if(a[0].equals(l[0])&&a[1].equals(l[1])||l[0]>l[1])return;const t=this.validateInput([l[0],l[1]],!0);if(t!=null)if(t.newDate!=null)l[0]=t.newDate.startDate,l[1]=t.newDate.endDate;else return t;const h=!this.#e.hasSame(l[0],"month")||!this.#t.hasSame(l[1],"month");return this.#e=l[0],this.#t=l[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),n&&this.updateView(h),t}parseDate(s){if(typeof s=="object"){if(c.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return c.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:c.parseFormatForOpts(this.locale.format);if(c.fromISO(s).isValid)return c.fromISO(s);if(c.fromFormat(s,e,{locale:c.now().locale}).isValid)return c.fromFormat(s,e,{locale:c.now().locale});{const n=c.fromFormat(s,e,{locale:c.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(M.defaultLocale===null){const n=c.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 l={startDate:[]},t={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const r=this.timePickerStepSize.as("seconds");n=c.fromSeconds(r*Math.round(n.toSeconds()/r)),t.new=n,t.new.equals(t.old)||l.startDate.push(t)}else n=n.startOf("day");const h=this.timePicker?this.timePickerStepSize.as("seconds"):D.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(t={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/h)*h}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=n,t.new.equals(t.old)||l.startDate.push(t)):this.maxDate&&n>this.maxDate&&(t={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/h)*h}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=n,t.new.equals(t.old)||l.startDate.push(t));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)&&l.startDate.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let r of d)this.isInvalidTime(n,r,"start")&&l.startDate.push({old:n,reason:"isInvalidTime",unit:r});if(this.singleDatePicker){if(l.startDate.length==0)return null;if(e){let r={startDate:n};const f=this.triggerEvent(this.#i.onViolate,{violation:l,newDate:r});return f.defaultPrevented&&(l.newDate=f.newDate),l}else return l}if(a==null)return null;if(l.endDate=[],t={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const r=this.timePickerStepSize.as("seconds");a=c.fromSeconds(r*Math.round(a.toSeconds()/r)),t.new=a,t.new.equals(t.old)||l.endDate.push(t)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(t={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/h)*h}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t)):this.minDate&&a<this.minDate&&(t={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/h)*h}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t)),this.maxSpan){const r=n.plus(this.maxSpan);a>r&&(t={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(r.diff(a).as("seconds")/h)*h}),a>r&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t))}if(this.minSpan){const r=n.plus(this.defaultSpan??this.minSpan);a<r&&(t={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(r.diff(a).as("seconds")/h)*h}),a<r&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||l.endDate.push(t))}if(this.isInvalidDate(a)&&l.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let r of d)this.isInvalidTime(a,r,"end")&&l.endDate.push({old:a,reason:"isInvalidTime",unit:r});if(l.startDate.length==0&&l.endDate.length==0)return null;if(e){let r={startDate:n,endDate:a};const f=this.triggerEvent(this.#i.onViolate,{violation:l,newDate:r});return f.defaultPrevented&&(l.newDate=f.newDate),l}else return l}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(l=>{l.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var t=s==="left"?this.leftCalendar:this.rightCalendar;t.month==null&&!this.#e&&this.initialMonth&&(t.month=this.initialMonth.startOf("month"));const e=t.month.startOf("month"),n=t.month.endOf("month").startOf("day");var a=t.month.startOf("month").minus({day:1});const l={hour:t.month.hour,minute:t.month.minute,second:t.month.second};var t=[];t.firstDay=e,t.lastDay=n;for(var h=0;h<6;h++)t[h]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,k=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&k++,t[k][y%7]=a.set(l);s==="left"?this.leftCalendar.calendar=t:this.rightCalendar.calendar=t;var d=s==="left"?this.minDate:this.#e,r=this.maxDate,f="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(f+="<th></th>"),(!d||d<t.firstDay)&&(!this.linkedCalendars||s==="left")?f+='<th class="prev available"><span></span></th>':f+="<th></th>";var i=`${this.locale.monthNames[t.firstDay.month-1]} ${t.firstDay.year}`;if(this.showDropdowns){const y=(r&&r.year)??this.maxYear,k=(d&&d.year)??this.minYear;let I=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var o=`${I}<select class="monthselect">`,u=1;u<=12;u++)o+=`<option value="${u}"${u===t.firstDay.month?" selected":""}`,(d&&t.firstDay.set({month:u})<d.startOf("month")||r&&t.firstDay.set({month:u})>r.endOf("month"))&&(o+=" disabled"),o+=`>${this.locale.monthNames[u-1]}</option>`;o+="</select>",this.externalStyle==="bulma"&&(o+="</div>"),I=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var b=`${I}<select class="yearselect">`,g=k;g<=y;g++)b+=`<option value="${g}"${g===t.firstDay.year?" selected":""}>${g}</option>`;b+="</select>",this.externalStyle==="bulma"&&(b+="</div>"),i=o+b}f+='<th colspan="5" class="month">'+i+"</th>",(!r||r>t.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,k]of this.locale.daysOfWeek.entries())f+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&O.getWeekendWeekdays().includes(y+1)&&(f+=` class="${this.weekendDayClasses}"`),f+=`>${k}</th>`;if(f+="</tr>",this.container.querySelector(`.drp-calendar.${s} .calendar-table thead`).innerHTML=f,f="",this.#t==null&&this.maxSpan){var S=this.#e.plus(this.maxSpan).endOf("day");(!r||S<r)&&(r=S)}var v;this.#t==null&&this.minSpan&&(v=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){f+="<tr>",this.showISOWeekNumbers?f+=`<td class="week">${t[y][0].weekNumber}</td>`:this.showWeekNumbers&&(f+=`<td class="week">${t[y][0].localWeekNumber}</td>`);for(let k=0;k<7;k++){var p=[];this.todayClasses&&this.todayClasses.length&&t[y][k].hasSame(c.now(),"day")&&p.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&O.getWeekendWeekdays().includes(t[y][k].weekday)&&p.push(this.weekendClasses),t[y][k].month!=t[1][1].month&&p.push("off","ends"),this.minDate&&t[y][k].startOf("day")<this.minDate.startOf("day")&&p.push("off","disabled"),r&&t[y][k].startOf("day")>r.startOf("day")&&p.push("off","disabled"),v&&t[y][k].startOf("day")>this.#e.startOf("day")&&t[y][k].startOf("day")<v.startOf("day")&&p.push("off","disabled"),this.isInvalidDate(t[y][k])&&p.push("off","disabled"),this.#e!=null&&t[y][k].hasSame(this.#e,"day")&&p.push("active","start-date"),this.#t!=null&&t[y][k].hasSame(this.#t,"day")&&p.push("active","end-date"),this.#t!=null&&t[y][k]>this.#e&&t[y][k]<this.#t&&p.push("in-range");var C=this.isCustomDate(t[y][k]);C!==!1&&(typeof C=="string"?p.push(C):p.push(...C)),p.includes("disabled")||p.push("available"),f+=`<td class="${p.join(" ")}" data-title="r${y}c${k}">${t[y][k].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,l=this.maxDate;let t="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(t+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(l=this.#e.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#e.plus(this.defaultSpan??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),l&&e>l&&(e=l)}let h=[],d=[];t+='<th colspan="7">',this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="hourselect">';const r=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=r==="AM"?1:13);for(var i=f;i<=f+23;i+=this.timePickerOpts.hourStep){let g=e.set({hour:i%24}),S=!1;if(a&&g.set({minute:59})<a&&(S=!0),l&&g.set({minute:0})>l&&(S=!0),n&&g.endOf("hour")<n&&(S=!0),!S&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(S=!0),this.timePicker24Hour)!S&&i==e.hour?t+=`<option value="${i}" selected>${i}</option>`:S?t+=`<option value="${i}" disabled class="disabled">${i}</option>`:t+=`<option value="${i}">${i}</option>`;else{const v=c.fromFormat(`${i%24}`,"H").toFormat("h"),p=c.fromFormat(`${i%24}`,"H").toFormat("a",{locale:"en-US"});r==p?!S&&i==e.hour?t+=`<option ampm="${p}" value="${i%24}" selected>${v}</option>`:S?t+=`<option ampm="${p}" value="${i%24}" disabled class="disabled">${v}</option>`:t+=`<option ampm="${p}" value="${i%24}">${v}</option>`:t+=`<option ampm="${p}" hidden="hidden" value="${i%24}">${v}</option>`}h.push(S)}if(t+="</select>",this.externalStyle==="bulma"&&(t+="</div>"),this.timePickerOpts.showMinutes){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="minuteselect">';for(var i=0;i<60;i+=this.timePickerOpts.minuteStep){var o=i<10?"0"+i:i;let S=e.set({minute:i}),v=!1;h.every(p=>p)&&(v=!0),a&&S.set({second:59})<a&&(v=!0),l&&S.set({second:0})>l&&(v=!0),n&&S.endOf("minute")<n&&(v=!0),!v&&this.isInvalidTime(S,this.singleDatePicker?null:s,"minute")&&(v=!0),e.minute==i&&!v?t+=`<option value="${i}" selected>${o}</option>`:v?t+=`<option value="${i}" disabled class="disabled">${o}</option>`:t+=`<option value="${i}">${o}</option>`,d.push(v)}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(this.timePickerOpts.showSeconds){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="secondselect">';for(var i=0;i<60;i+=this.timePickerOpts.secondStep){var o=i<10?"0"+i:i;let v=e.set({second:i}),p=!1;d.every(C=>C)&&(p=!0),a&&v<a&&(p=!0),l&&v>l&&(p=!0),n&&v<n&&(p=!0),!p&&this.isInvalidTime(v,this.singleDatePicker?null:s,"second")&&(p=!0),e.second==i&&!p?t+=`<option value="${i}" selected>${o}</option>`:p?t+=`<option value="${i}" disabled class="disabled">${o}</option>`:t+=`<option value="${i}">${o}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="ampmselect">';var u="",b="";let g=!1;h.every(S=>S)&&(g=!0),a&&e.startOf("day")<a&&(g=!0),l&&e.endOf("day")>l&&(g=!0),n&&e.startOf("day")<n&&(g=!0),g?(u=' disabled class="disabled "',b=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:s,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?b=' disabled class="disabled"':u=' disabled class="disabled"'),t+=`<option value="AM"${u}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(t+=" selected"),t+=`>${O.meridiems()[0]}</option><option value="PM"${b}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(t+=" selected"),t+=`>${O.meridiems()[1]}</option>`,t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}t+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${s}-time`).innerHTML=t}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,l=window.innerWidth;switch(this.parentEl.matches("body")||(s={top:w(this.parentEl).top-this.parentEl.scrollTop(),left:w(this.parentEl).left-this.parentEl.scrollLeft()},l=this.parentEl[0].clientWidth+w(this.parentEl).left),this.drops){case"auto":e=w(this.element).top+P(this.element)-s.top,e+P(this.container)>=this.parentEl.scrollHeight&&(e=w(this.element).top-P(this.container)-s.top,a="up");break;case"up":e=w(this.element).top-P(this.container)-s.top;break;case"down":e=w(this.element).top+P(this.element)-s.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[h,d]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[h]=typeof d=="number"&&d>0?`${d}px`:d;const t=$(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const h=l-w(this.element).left-$(this.element);if(t+h>window.innerWidth)for(const[d,r]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:e,right:h,left:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;break;case"center":if(n=w(this.element).left-s.left+$(this.element)/2-t/2,n<0)for(const[d,r]of Object.entries({top:e,right:"auto",left:9}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else if(n+t>window.innerWidth)for(const[d,r]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:e,left:n,right:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;break;case"right":if(n=w(this.element).left-s.left,n+t>window.innerWidth)for(const[d,r]of Object.entries({top:e,left:"auto",right:0}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;else for(const[d,r]of Object.entries({top:`${e}px`,left:n,right:"auto"}))this.container.style[d]=typeof r=="number"&&r>0?`${r}px`:r;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.#r),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#l),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??c)||this.#t&&!this.singleDatePicker&&!this.#t.equals(this.oldEndDate??c))&&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.#r),window.removeEventListener("resize",this.#l),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(l,t){let h=l.parentElement;for(;h;){if(h==t)return h;h=h.parentElement}return null}s.type==="focusin"||n(e,this.element)||n(e,this.container)||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 t=s.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const h=this.leftCalendar,d=this.rightCalendar,r=this.#e,f=this.initialMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(i=>{if(i.classList.contains("week"))return;const o=i.dataset.title,u=o.substring(1,2),b=o.substring(3,4),S=i.closest(".drp-calendar").classList.contains("left")?h.calendar[u][b]:d.calendar[u][b];!r&&f?i.classList.remove("in-range"):i.classList.toggle("in-range",S>r&&S<t||S.hasSame(t,"day"))})}hoverRange(s){const e=s.target.dataset.rangeKey,n=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],l=this.leftCalendar,t=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(h=>{if(h.classList.contains("week"))return;const d=h.dataset.ttitle,r=d.substring(1,2),f=d.substring(3,4),o=h.closest(".drp-calendar").classList.contains("left")?l.calendar[r][f]:t.calendar[r][f];h.classList.toggle("start-hover",o.hasSame(a[0],"day")),h.classList.toggle("start-date",o.hasSame(n[0],"day")),h.classList.toggle("end-hover",o.hasSame(a[1],"day")),h.classList.toggle("end-date",n[1]!=null&&o.hasSame(n[1],"day")),h.classList.toggle("range-hover",o.startOf("day")>=a[0].startOf("day")&&o.startOf("day")<=a[1].startOf("day")),h.classList.toggle("in-range",o.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&o.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),t=s.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a],h;if(this.#t||!this.#e||t<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 r=0;this.timePickerOpts.showMinutes&&(r=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(r)&&(r=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))),t=t.set({hour:d,minute:r,second:f})}else t=t.startOf("day");this.#t=null,this.#e=t,h="start"}else if(!this.#t&&t<this.#e)this.#t=this.#e,h="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 r=0;this.timePickerOpts.showMinutes&&(r=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(r)&&(r=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))),t=t.set({hour:d,minute:r,second:f})}else t=t.endOf("day");this.#t=t,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),h="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),h=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:h})}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,l]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(l.startOf(e))){s=!1;const t=this.container.querySelector(`.ranges li[data-range-key="${n}"]`);this.chosenLabel=n,t.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 h=e.querySelector(".ampmselect").value;if(h==null&&e.querySelector(".ampmselect option:last-child").value,h!=c.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(r=>{r.hidden=!r.hidden});const d=c.fromFormat(`${a}`,"H").toFormat("h");a=c.fromFormat(`${d}${h}`,"ha",{locale:"en-US"}).hour}}var l=0;this.timePickerOpts.showMinutes&&(l=parseInt(e.querySelector(".minuteselect").value,10),isNaN(l)&&(l=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var t=0;this.timePickerOpts.showSeconds&&(t=parseInt(e.querySelector(".secondselect").value,10),isNaN(t)&&(t=parseInt(e.querySelector(".secondselect option:last-child").value,10))),n==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:l,second:t})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&this.#t<this.#e&&(this.#t=this.#e)):this.#t&&(this.#t=this.#t.set({hour:a,minute:l,second:t})),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 l=parseInt(a.querySelector(".monthselect").value,10),t=a.querySelector(".yearselect").value,h=!1;e||(t<this.#e.year||t==this.#e.year&&l<this.#e.month)&&(l=this.#e.month,t=this.#e.year),this.minDate&&(t<this.minDate.year||t==this.minDate.year&&l<this.minDate.month)&&(l=this.minDate.month,t=this.minDate.year),this.maxDate&&(t>this.maxDate.year||t==this.maxDate.year&&l>this.maxDate.month)&&(l=this.maxDate.month,t=this.maxDate.year),e?(h=!c.fromObject({year:t,month:l}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:t,month:l}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(h=!c.fromObject({year:t,month:l}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:t,month:l}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(h)}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:c.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=c.fromFormat(this.element.value,s,{locale:c.now().locale});const l=this.#e;if(!a.isValid||l.equals(a))return;const t=this.validateInput([a,null],!0);if(t!=null)if(t.newDate!=null)a=t.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(h=>c.fromFormat(e[h],s,{locale:c.now().locale})),l=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||l[0].equals(a[0])&&l[1].equals(a[1])||a[0]>a[1])return;const t=this.validateInput([a[0],a[1]],!0);if(t!=null)if(t.newDate!=null)a[0]=t.newDate.startDate,a[1]=t.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.#o),this.element.removeEventListener("keydown",this.#h),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 q(this,s);return this.element.dispatchEvent(n),n}else{const n=new q(this,s,...e);return this.element.dispatchEvent(n),n}}addListener(s,e,n,a){this.container.querySelectorAll(s).forEach(l=>{l.addEventListener(e,function(t){const h=t.target.closest(n);h&&l.contains(h)&&a.call(h,t)})})}}function E(m){const s=document.createElement("template");return s.innerHTML=m.trim(),s.content.firstElementChild}class q 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[l,t]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(l)||(this[l]=t)}get picker(){return this.#e}}function w(m){const s=m.getBoundingClientRect();return{top:s.top+window.scrollY,left:s.left+window.scrollX}}function $(m,s=!1){if(!s)return m.offsetWidth;const e=getComputedStyle(m);return m.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function P(m,s=!1){if(!s)return m.offsetHeight;const e=getComputedStyle(m);return m.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function L(m,s,e){return typeof m=="string"?L(document.querySelectorAll(m),s,e):(m instanceof HTMLElement&&(m=[m]),(m instanceof NodeList||m instanceof HTMLCollection)&&(m=Array.from(m)),m==null?new x(null,s||{},e):(m.forEach(n=>{n._daterangepicker&&typeof n._daterangepicker.remove=="function"&&n._daterangepicker.remove(),n._daterangepicker=new x(n,s||{},e)}),m.length===1?m[0]:m))}function T(m){return typeof m=="string"&&(m=document.querySelector(m)),m instanceof HTMLElement?m._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(m,s){return this.each(function(){L(this,m,s)})});function N(m){m?.fn&&(m.fn.daterangepicker=function(s,e){return this.each(function(){L(this,s,e)})})}Object.defineProperty(window,"jQuery",{configurable:!0,set(m){this._jQuery=m,N(m)},get(){return this._jQuery}});export{x as DateRangePicker,L as daterangepicker,T as getDateRangePicker};
2
2
  //# sourceMappingURL=daterangepicker.min.js.map