import{s as F,f as O,p as w,a as s,g as N}from"./utils.3d9f83cd.js";import{P as T}from"./index.53518914.js";import{t as E,N as I,aG as D,d as R,R as A,y as G,Z as g,aW as h,c as K,E as S,am as U,D as W}from"./index.1c621181.js";const f=new Date().getFullYear(),[Z]=E("date-picker"),_=I({},F,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(f-10,0,1),validator:D},maxDate:{type:Date,default:()=>new Date(f+10,11,31),validator:D}});var b=R({name:Z,props:_,emits:["confirm","cancel","change","update:modelValue"],setup(t,{emit:r,slots:y}){const n=A(t.modelValue),x=()=>{const e=t.minDate.getFullYear(),a=t.maxDate.getFullYear();return s(e,a,"year",t.formatter,t.filter)},l=e=>e===t.minDate.getFullYear(),i=e=>e===t.maxDate.getFullYear(),M=e=>e===t.minDate.getMonth()+1,Y=e=>e===t.maxDate.getMonth()+1,c=e=>{const{minDate:a,columnsType:o}=t,m=o.indexOf(e),d=n.value[m];if(d)return+d;switch(e){case"year":return a.getFullYear();case"month":return a.getMonth()+1;case"day":return a.getDate()}},v=()=>{const e=c("year"),a=l(e)?t.minDate.getMonth()+1:1,o=i(e)?t.maxDate.getMonth()+1:12;return s(a,o,"month",t.formatter,t.filter)},V=()=>{const e=c("year"),a=c("month"),o=l(e)&&M(a)?t.minDate.getDate():1,m=i(e)&&Y(a)?t.maxDate.getDate():N(e,a);return s(o,m,"day",t.formatter,t.filter)},u=G(()=>t.columnsType.map(e=>{switch(e){case"year":return x();case"month":return v();case"day":return V();default:return[]}}));g(n,e=>{h(e,t.modelValue)||r("update:modelValue",e)}),g(()=>t.modelValue,e=>{e=O(e,u.value),h(e,n.value)||(n.value=e)},{immediate:!0});const C=(...e)=>r("change",...e),P=(...e)=>r("cancel",...e),k=(...e)=>r("confirm",...e);return()=>K(T,S({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:u.value,onChange:C,onCancel:P,onConfirm:k},U(t,w)),y)}});const B=W(b);export{B as D};