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