import{i as instance}from"./i18next.js";import{Build}from"@stencil/core/internal/client";Build.isTesting&&instance.init({lng:"cimode"});const maxYear=(new Date).getFullYear()+100,minYear=1900,maxMonths=12,minMonths=1,minDays=1,months=[{label:"January",value:1},{label:"February",value:2},{label:"March",value:3},{label:"April",value:4},{label:"May",value:5},{label:"June",value:6},{label:"July",value:7},{label:"August",value:8},{label:"September",value:9},{label:"October",value:10},{label:"November",value:11},{label:"December",value:12}],twentyNineDays=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29"],thirtyDays=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"],thirtyOneDays=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"],days={1:thirtyOneDays,2:twentyNineDays,3:thirtyOneDays,4:thirtyDays,5:thirtyOneDays,6:thirtyDays,7:thirtyOneDays,8:thirtyOneDays,9:thirtyDays,10:thirtyOneDays,11:thirtyDays,12:thirtyOneDays},internalErrors=["year-range","day-range","month-range","date-error","month-select"];function getMonthErrorKey(e){return e?"month-select":"month-range"}function validate({component:e,year:r,month:a,day:t,monthYearOnly:n,yearTouched:i,monthTouched:o,dayTouched:l,monthSelect:s,monthOptional:d}){if(!r&&!a&&!t)return;const y=daysForSelectedMonth(r,a);e.invalidYear=!1,e.invalidMonth=!1,e.invalidDay=!1;const v=!(n&&d);if(v&&isNaN(a)&&o)return e.invalidMonth=!0,void(e.error=getMonthErrorKey(s));if(!n&&isNaN(t)&&l)return e.invalidDay=!0,void(e.error="day-range");if(isNaN(r)&&i)return e.invalidYear=!0,void(e.error="year-range");if(e.required&&(!r||v&&!a||!n&&!t)){if(v&&o&&!a)return e.invalidMonth=!0,void(e.error="date-error");if(l&&!t&&!n)return e.invalidDay=!0,void(e.error="date-error");if(i&&!r)return e.invalidYear=!0,void(e.error="date-error")}return v&&!a&&o?(e.invalidMonth=!0,void(e.error=getMonthErrorKey(s))):t||n||!l?!r&&i?(e.invalidYear=!0,void(e.error="year-range")):v&&a&&(a<1||a>12)&&o?(e.invalidMonth=!0,void(e.error=getMonthErrorKey(s))):t&&!n&&(t<1||t>y)&&l?(e.invalidDay=!0,void(e.error="day-range")):r&&(r<1900||r>maxYear)&&i?(e.invalidYear=!0,void(e.error="year-range")):!a||!o||l||i?a&&o&&t&&l&&!i?(e.invalidYear=!0,void(e.error="date-error")):void(e.invalidYear||e.invalidMonth||e.invalidDay||e.error&&!internalErrors.includes(e.error)||(e.error=null)):void(n?(e.invalidYear=!0,e.error="date-error"):(e.invalidDay=!0,e.error="date-error")):(e.invalidDay=!0,void(e.error="day-range"))}function getErrorParameters(e,r,a){const t=daysForSelectedMonth(r,a);switch(e){case"month-range":case"month-select":return{start:1,end:12};case"day-range":return{start:1,end:t};case"year-range":return{start:1900,end:maxYear};default:return null}}const daysForSelectedMonth=(e,r)=>{var a;return e&&r?new Date(e,r,0).getDate():(null===(a=days[r])||void 0===a?void 0:a.length)||31},formatDate=(e,r={dateStyle:"full",timeStyle:"short"},a="America/New_York")=>{if(e&&e instanceof Date)return e.toLocaleString("en-US",Object.assign(Object.assign({},r),{timeZone:a}))},isDateAfter=(e,r)=>{if(e&&e instanceof Date&&r&&r instanceof Date)return e.getTime()>r.getTime()},isDateBefore=(e,r)=>{if(e&&e instanceof Date&&r&&r instanceof Date)return e.getTime()<r.getTime()},isDateSameDay=(e,r)=>{if(e&&e instanceof Date&&r&&r instanceof Date)return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDay()===r.getDay()},zeroPadStart=e=>`00${(e||"").toString()}`.slice(-2);export{isDateBefore as a,isDateAfter as b,daysForSelectedMonth as d,formatDate as f,getErrorParameters as g,isDateSameDay as i,months as m,validate as v,zeroPadStart as z};