import{FormItemInputContext as e}from"../form/FormItemContext.mjs";import t from"../select/index.mjs";import n from"../radio/Group.mjs";import r from"../radio/RadioButton.mjs";import{createVNode as i,defineComponent as a,ref as o}from"vue";var s=10,c=20;function l(e){let{fullscreen:n,validRange:r,generateConfig:a,locale:o,prefixCls:l,value:u,onChange:d,divRef:f}=e,p=a.getYear(u||a.getNow()),m=p-s,h=m+c;r&&(m=a.getYear(r[0]),h=a.getYear(r[1])+1);let g=o&&o.year===`年`?`年`:``,_=[];for(let e=m;e<h;e++)_.push({label:`${e}${g}`,value:e});return i(t,{size:n?void 0:`small`,options:_,value:p,class:`${l}-year-select`,onChange:e=>{let t=a.setYear(u,e);if(r){let[e,n]=r,i=a.getYear(t),o=a.getMonth(t);i===a.getYear(n)&&o>a.getMonth(n)&&(t=a.setMonth(t,a.getMonth(n))),i===a.getYear(e)&&o<a.getMonth(e)&&(t=a.setMonth(t,a.getMonth(e)))}d(t)},getPopupContainer:()=>f.value},null)}l.inheritAttrs=!1;function u(e){let{prefixCls:n,fullscreen:r,validRange:a,value:o,generateConfig:s,locale:c,onChange:l,divRef:u}=e,d=s.getMonth(o||s.getNow()),f=0,p=11;if(a){let[e,t]=a,n=s.getYear(o);s.getYear(t)===n&&(p=s.getMonth(t)),s.getYear(e)===n&&(f=s.getMonth(e))}let m=c.shortMonths||s.locale.getShortMonths(c.locale),h=[];for(let e=f;e<=p;e+=1)h.push({label:m[e],value:e});return i(t,{size:r?void 0:`small`,class:`${n}-month-select`,value:d,options:h,onChange:e=>{l(s.setMonth(o,e))},getPopupContainer:()=>u.value},null)}u.inheritAttrs=!1;function d(e){let{prefixCls:t,locale:a,mode:o,fullscreen:s,onModeChange:c}=e;return i(n,{onChange:({target:{value:e}})=>{c(e)},value:o,size:s?void 0:`small`,class:`${t}-mode-switch`},{default:()=>[i(r,{value:`month`},{default:()=>[a.month]}),i(r,{value:`year`},{default:()=>[a.year]})]})}d.inheritAttrs=!1;var f=a({name:`CalendarHeader`,inheritAttrs:!1,props:[`mode`,`prefixCls`,`value`,`validRange`,`generateConfig`,`locale`,`mode`,`fullscreen`],setup(t,{attrs:n}){let r=o(null),a=e.useInject();return e.useProvide(a,{isFormItemInput:!1}),()=>{let e={...t,...n},{prefixCls:a,fullscreen:o,mode:s,onChange:c,onModeChange:f}=e,p={...e,fullscreen:o,divRef:r};return i(`div`,{class:`${a}-header`,ref:r},[i(l,{...p,onChange:e=>{c(e,`year`)}},null),s===`month`&&i(u,{...p,onChange:e=>{c(e,`month`)}},null),i(d,{...p,onModeChange:f},null)])}}});export{f as default};