import{t as F,N as w,aG as D,d as O,R as N,D as T,Z as h,aW as g,c as E,v as I,am as R,x as A}from"./index.8f93de0e.js";import{s as G,f as K,p as S,a as m,g as U}from"./utils.52cced7f.js";import{P as W}from"./index.16055f9a.js";const f=new Date().getFullYear(),[Z]=F("date-picker"),_=w({},G,{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 $=O({name:Z,props:_,emits:["confirm","cancel","change","update:modelValue"],setup(t,{emit:r,slots:y}){const n=N(t.modelValue),x=()=>{const e=t.minDate.getFullYear(),a=t.maxDate.getFullYear();return m(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,v=e=>e===t.maxDate.getMonth()+1,c=e=>{const{minDate:a,columnsType:o}=t,s=o.indexOf(e),d=n.value[s];if(d)return+d;switch(e){case"year":return a.getFullYear();case"month":return a.getMonth()+1;case"day":return a.getDate()}},Y=()=>{const e=c("year"),a=l(e)?t.minDate.getMonth()+1:1,o=i(e)?t.maxDate.getMonth()+1:12;return m(a,o,"month",t.formatter,t.filter)},V=()=>{const e=c("year"),a=c("month"),o=l(e)&&M(a)?t.minDate.getDate():1,s=i(e)&&v(a)?t.maxDate.getDate():U(e,a);return m(o,s,"day",t.formatter,t.filter)},u=T(()=>t.columnsType.map(e=>{switch(e){case"year":return x();case"month":return Y();case"day":return V();default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${e}`)}}));h(n,e=>{g(e,t.modelValue)||r("update:modelValue",e)}),h(()=>t.modelValue,e=>{e=K(e,u.value),g(e,n.value)||(n.value=e)},{immediate:!0});const P=(...e)=>r("change",...e),k=(...e)=>r("cancel",...e),C=(...e)=>r("confirm",...e);return()=>E(W,I({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:u.value,onChange:P,onCancel:k,onConfirm:C},R(t,S)),y)}});const z=A($);export{z as D};
