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