const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.es-BQHZMhDS.js","assets/main-DtyiNRRn.js"])))=>i.map(i=>d[i]);
import{_ as D,I as _,ay as p,aF as b,aG as w,r as g,o as a,b as c,a as f,q as n,w as S,p as B,F as k,u,v as h,n as F,ab as T,J as v}from"./main-DtyiNRRn.js";import{_ as I}from"./dateMixin.vue_vue_type_script_lang-DOBw9JOo.js";const L=T(()=>v(()=>import("./index.es-BQHZMhDS.js"),__vite__mapDeps([0,1]))),x={name:"DatepickerFi",components:{IconFi:_,LabelFi:p,VueDatePicker:L},mixins:[I,b,w],props:{value:{type:[String,Object],default:null},label:{type:String,default:""},name:{type:String,default:""},infoText:{type:String,default:""},infoIcon:{type:String,default:""},successText:{type:String,default:""},errorMsg:{type:String,default:""},errorIcon:{type:String,default:""},minDate:{type:String,default:""},maxDate:{type:String,default:""},validateDate:{type:Boolean,default:!1},error:{type:Boolean,default:!1},dateSuccess:{type:Boolean,default:!1},dateReset:{type:Boolean,default:!1},range:{type:Boolean,default:!1},large:{type:Boolean,default:!1},clearable:{type:Boolean,default:!0},checkForInvalidDate:{type:Boolean,default:!1},light:{type:Boolean,default:!1},initialViewYear:{type:Boolean,default:!1},disableTodaysDate:{type:Boolean,default:!1},isFlexiblePicker:{type:Boolean,default:!1},isBirthdayPicker:{type:Boolean,default:!1},required:{type:Boolean,default:!1},allowedDates:{type:Function,default:null},disabled:{type:Boolean,default:!1},darkLabel:{type:Boolean,default:!1}},emits:["input"],data(){return{initDate:null,isOpen:!1,dateTimeStringAppendix:"T00:00:00+0000",allowedYearsFromNow:1,allowedYearsInPast:20,allowedMinYearForBirthdays:1900,dateFormat:null,isMounted:!1}},computed:{todayTime(){const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0).getTime()},lang(){const t=[],i=[],e=[],m=[],o={weekday:"long"},s={weekday:"short"};for(let r=0;r<7;r++){const d=new Date(0,0,r);t.push(d.toLocaleDateString(this.$fischer.siteLanguage(),o)),i.push(d.toLocaleDateString(this.$fischer.siteLanguage(),s))}const y={month:"long"},l={month:"short"};for(let r=1;r<=12;r++){const d=new Date(0,r,0);e.push(d.toLocaleDateString(this.$fischer.siteLanguage(),y)),m.push(d.toLocaleDateString(this.$fischer.siteLanguage(),l))}return{formatLocale:{weekdays:t,weekdaysShort:i,weekdaysMin:i,months:e,monthsShort:m,firstDayOfWeek:1}}},date:{get(){return this.momentLoaded?this.value:null},set(t){if(this.checkForInvalidDate&&(t==null?void 0:t.toLowerCase())==="invalid date"){this.date=this.initDate;return}this.$emit("input",t)}},parsedDate(){return this.date?this.date.start&&this.date.end?[this.parseDateIsoShort(new Date(this.date.start)),this.parseDateIsoShort(new Date(this.date.end))]:this.parseDateIsoShort(new Date(this.date)):null},momentFormat(){return{stringify:t=>this.formatDate(t),parse:t=>this.parseDate(t)}}},watch:{momentLoaded:{immediate:!0,handler(t){t&&(this.dateFormat=this.getDateFormat())}}},mounted(){this.isMounted=!0},created(){this.initDate=`${this.value}${this.dateTimeStringAppendix}`},methods:{disabledDates(t){return!(this.allowedDates?this.allowedDates:this.getAllowedDates)(t)},setFormattedValue(t){Array.isArray(t)?this.date={start:this.formatDateIsoShort(t[0]),end:this.formatDateIsoShort(t[1])}:this.date=this.formatDateIsoShort(t)},getAllowedDates(t){const e=new Date(t).getTime();return this.minDate&&e<new Date(this.minDate).getTime()||this.maxDate&&e>new Date(this.maxDate).getTime()?!1:this.isFlexiblePicker?!0:this.isBirthdayPicker?e<this.todayTime:this.disableTodaysDate?e>=this.todayTime+24*60*60*1e3:e>=this.todayTime}}},O={key:0,class:"datepicker-fi__field"},M={class:"datepicker-fi__icon","data-test":"open-datepicker"},P={key:1,class:"datepicker-fi__error-text"},V={key:2,class:"datepicker-fi__info-text"},A={key:3,class:"datepicker-fi__info-text"};function E(t,i,e,m,o,s){const y=g("label-fi"),l=g("icon-fi"),r=g("vue-date-picker");return a(),c("div",{class:F({"datepicker-fi":!0,"datepicker-fi--disabled":e.disabled,"datepicker-fi--active":!!s.date,"datepicker-fi--error":e.error||t.isError,"datepicker-fi--large":e.large,"datepicker-fi--range":e.range,"datepicker-fi--open":o.isOpen,"datepicker-fi--light":e.light,"datepicker-fi--dark-label":e.darkLabel})},[t.momentLoaded?(a(),c("div",O,[e.label?(a(),f(y,{key:0,class:"datepicker-fi__label",label:e.label,mandatory:e.required},null,8,["label","mandatory"])):n("",!0),o.isMounted&&t.momentLoaded?(a(),f(r,{key:1,ref:"datePicker",value:s.parsedDate,lang:s.lang,range:e.range,"append-to-body":!1,formatter:s.momentFormat,"default-panel":e.initialViewYear?"year":null,"disabled-date":s.disabledDates,disabled:e.disabled,separator:" - ",placeholder:"","title-format":o.dateFormat,clearable:e.clearable,onOpen:i[0]||(i[0]=d=>o.isOpen=!0),onClose:i[1]||(i[1]=d=>o.isOpen=!1),"onUpdate:value":s.setFormattedValue},{"icon-calendar":S(()=>[B("div",M,[e.validateDate&&e.dateSuccess?(a(),f(l,{key:0,icon:"check",class:"datepicker-fi__icon--success"})):n("",!0),!e.validateDate||!e.clearable?(a(),f(l,{key:1,icon:"calendar"})):n("",!0)])]),_:1},8,["value","lang","range","formatter","default-panel","disabled-date","disabled","title-format","clearable","onUpdate:value"])):n("",!0)])):n("",!0),t.isError?(a(),c("div",P,[e.errorIcon?(a(),f(l,{key:0,icon:e.errorIcon,class:"datepicker-fi__error-icon"},null,8,["icon"])):n("",!0),e.errorMsg?(a(),c(k,{key:1},[u(h(e.errorMsg),1)],64)):(a(),c(k,{key:2},[u(h(t.errorText),1)],64))])):n("",!0),!t.isError&&e.infoText?(a(),c("div",V,[e.infoIcon?(a(),f(l,{key:0,icon:e.infoIcon,class:"datepicker-fi__info-icon"},null,8,["icon"])):n("",!0),u(" "+h(e.infoText),1)])):n("",!0),e.validateDate&&e.dateSuccess&&e.successText&&!e.dateReset?(a(),c("div",A,[e.infoIcon?(a(),f(l,{key:0,icon:e.infoIcon,class:"datepicker-fi__info-icon"},null,8,["icon"])):n("",!0),u(" "+h(e.successText),1)])):n("",!0)],2)}const N=D(x,[["render",E],["__scopeId","data-v-7a7f9146"]]);export{N as default};