import{ref as i,computed as h,watchEffect as g}from"vue";import{getClosingViewDate as S,isSameMonth as E,isSameYear as N,isSameDecade as R}from"../utils/dateUtil.mjs";import{getValue as c,updateValues as w}from"../utils/miscUtil.mjs";function q(u,o,l,n){const e=S(u,l,n,1);function t(a){return a(u,o)?"same":a(e,o)?"closing":"far"}switch(l){case"year":return t((a,r)=>R(n,a,r));case"quarter":case"month":return t((a,r)=>N(n,a,r));default:return t((a,r)=>E(n,a,r))}}function y(u,o,l,n){const e=c(u,0),t=c(u,1);if(o===0)return e;if(e&&t)switch(q(e,t,l,n)){case"same":return e;case"closing":return e;default:return S(t,l,n,-1)}return e}function b({values:u,picker:o,defaultDates:l,generateConfig:n}){const e=i([c(l,0),c(l,1)]),t=i(null),a=h(()=>c(u.value,0)),r=h(()=>c(u.value,1)),m=s=>e.value[s]?e.value[s]:c(t.value,s)||y(u.value,s,o.value,n.value)||a.value||r.value||n.value.getNow(),D=i(null),V=i(null);g(()=>{D.value=m(0),V.value=m(1)});function p(s,f){if(s){let v=w(t.value,s,f);e.value=w(e.value,null,f)||[null,null];const d=(f+1)%2;c(u.value,d)||(v=w(v,s,d)),t.value=v}else(a.value||r.value)&&(t.value=null)}return[D,V,p]}export{b as default};
