const e=require("../_util/classNames.js"),t=require("./locale/en_US.js"),n=require("../locale/LocaleReceiver.js"),r=require("../config-provider/hooks/useConfigInject.js"),i=require("../_util/hooks/useMergedState.js"),a=require("../vc-picker/PickerPanel.js"),o=require("./Header.js"),s=require("./style/index.js");let c=require("vue");function l(l){function u(e,t){return e&&t&&l.getYear(e)===l.getYear(t)}function d(e,t){return u(e,t)&&l.getMonth(e)===l.getMonth(t)}function f(e,t){return d(e,t)&&l.getDate(e)===l.getDate(t)}let p=(0,c.defineComponent)({name:`ACalendar`,inheritAttrs:!1,props:{prefixCls:String,locale:{type:Object,default:void 0},validRange:{type:Array,default:void 0},disabledDate:{type:Function,default:void 0},dateFullCellRender:{type:Function,default:void 0},dateCellRender:{type:Function,default:void 0},monthFullCellRender:{type:Function,default:void 0},monthCellRender:{type:Function,default:void 0},headerRender:{type:Function,default:void 0},value:{type:[Object,String],default:void 0},defaultValue:{type:[Object,String],default:void 0},mode:{type:String,default:void 0},fullscreen:{type:Boolean,default:void 0},onChange:{type:Function,default:void 0},"onUpdate:value":{type:Function,default:void 0},onPanelChange:{type:Function,default:void 0},onSelect:{type:Function,default:void 0},valueFormat:{type:String,default:void 0}},slots:Object,setup(p,{emit:m,slots:h,attrs:g}){let _=p,{prefixCls:v,direction:y}=r.default(`picker`,_),[b,x]=s.default(v),S=(0,c.computed)(()=>`${v.value}-calendar`),C=e=>_.valueFormat?l.toString(e,_.valueFormat):e,w=(0,c.computed)(()=>_.value?_.valueFormat?l.toDate(_.value,_.valueFormat):_.value:_.value===``?void 0:_.value),[T,E]=i.default(()=>w.value||l.getNow(),{defaultValue:(0,c.computed)(()=>_.defaultValue?_.valueFormat?l.toDate(_.defaultValue,_.valueFormat):_.defaultValue:_.defaultValue===``?void 0:_.defaultValue).value,value:w}),[D,O]=i.default(`month`,{value:(0,c.toRef)(_,`mode`)}),k=(0,c.computed)(()=>D.value===`year`?`month`:`date`),A=(0,c.computed)(()=>e=>(_.validRange?l.isAfter(_.validRange[0],e)||l.isAfter(e,_.validRange[1]):!1)||!!_.disabledDate?.(e)),j=(e,t)=>{m(`panelChange`,C(e),t)},M=e=>{if(E(e),!f(e,T.value)){(k.value===`date`&&!d(e,T.value)||k.value===`month`&&!u(e,T.value))&&j(e,D.value);let t=C(e);m(`update:value`,t),m(`change`,t)}},N=e=>{O(e),j(T.value,e)},P=(e,t)=>{M(e),m(`select`,C(e),{source:t})},[F]=n.useLocaleReceiver(`Calendar`,(0,c.computed)(()=>{let{locale:e}=_,n={...t.default,...e};return n.lang={...n.lang,...(e||{}).lang},n}));return()=>{let t=l.getNow(),{dateFullCellRender:n=h?.dateFullCellRender,dateCellRender:r=h?.dateCellRender,monthFullCellRender:i=h?.monthFullCellRender,monthCellRender:s=h?.monthCellRender,headerRender:u=h?.headerRender,fullscreen:p=!0,validRange:m}=_,C=({current:i})=>n?n({current:i}):(0,c.createVNode)(`div`,{class:e.default(`${v.value}-cell-inner`,`${S.value}-date`,{[`${S.value}-date-today`]:f(t,i)})},[(0,c.createVNode)(`div`,{class:`${S.value}-date-value`},[String(l.getDate(i)).padStart(2,`0`)]),(0,c.createVNode)(`div`,{class:`${S.value}-date-content`},[r&&r({current:i})])]),w=({current:n},r)=>{if(i)return i({current:n});let a=r.shortMonths||l.locale.getShortMonths(r.locale);return(0,c.createVNode)(`div`,{class:e.default(`${v.value}-cell-inner`,`${S.value}-date`,{[`${S.value}-date-today`]:d(t,n)})},[(0,c.createVNode)(`div`,{class:`${S.value}-date-value`},[a[l.getMonth(n)]]),(0,c.createVNode)(`div`,{class:`${S.value}-date-content`},[s&&s({current:n})])])};return b((0,c.createVNode)(`div`,{...g,class:e.default(S.value,{[`${S.value}-full`]:p,[`${S.value}-mini`]:!p,[`${S.value}-rtl`]:y.value===`rtl`},g.class,x.value)},[u?u({value:T.value,type:D.value,onChange:e=>{P(e,`customize`)},onTypeChange:N}):(0,c.createVNode)(o.default,{prefixCls:S.value,value:T.value,generateConfig:l,mode:D.value,fullscreen:p,locale:F.value.lang,validRange:m,onChange:P,onModeChange:N},null),(0,c.createVNode)(a.default,{value:T.value,prefixCls:v.value,locale:F.value.lang,generateConfig:l,dateRender:C,monthCellRender:e=>w(e,F.value.lang),onSelect:e=>{P(e,k.value)},mode:k.value,picker:k.value,disabledDate:A.value,hideHeader:!0},null)]))}}});return p.install=function(e){return e.component(p.name,p),e},p}exports.default=l;