import{defineProperty as e,slicedToArray as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import a,{useMemo as r,useState as n,useRef as o,useEffect as i,useCallback as d,createContext as s}from"react";import l from"classnames";import{InternalModifier as c,DayPicker as u}from"react-day-picker";import m from"./DatePicker.module.scss.js";import f from"./DatePickerHeader.js";import{AddToRangeMiddle as k,AddToRangeStart as v,RemoveFromRange as D,HoveredDayExists as g,AddToRangeEnd as y,HalfRangeSelected as P,addToRange as b,addToRangeModifiers as p}from"./utils.js";import{RangeDayContent as h}from"./RangeDayContent.js";import{SingleDayContent as C}from"./SingleDayContent.js";import{DayContentHoverProvider as S,DayContentHoverContext as R}from"./DateContentHoverContext.js";var A,N={hours:9,minutes:0},E=(e(e(e(e(e(e(e(e(e(e(A={},c.Outside,m.datePickerDayOutside),c.Selected,m.datePickerDaySelected),c.Today,m.datePickerDayToday),c.Disabled,m.datePickerDayDisabled),c.RangeStart,m.datePickerDayRangeStart),c.RangeEnd,m.datePickerDayRangeEnd),c.RangeMiddle,m.datePickerDayRangeMiddle),k,m.datePickerAddToRangeMiddle),v,m.datePickerAddToRangeStart),y,m.datePickerAddToRangeEnd),e(e(e(A,D,m.datePickerRemoveFromRange),g,m.datePickerHoveredDayExists),P,m.datePickerHalfRangeSelected)),j=s({}),w=function(){return a.createElement(j.Consumer,null,(function(e){return a.createElement(f,Object.assign({},e))}))},H=function(s){var f=s.className,k=s.dayClassName,v=s.selectedDayClassName,D=s.id,g=s["data-testid"],y=s.mode,P=void 0===y?"single":y,A=s.date,H=s.endDate,L=s.onDateChange,M=s.firstDayOfWeek,O=void 0===M?0:M,x=s.showWeekNumber,T=s.isDateDisabled,B=s.locale,W=s.nextButtonAriaLabel,_=void 0===W?"Next":W,q=s.prevButtonAriaLabel,F=void 0===q?"Previous":q,Y=s.monthSelectionAriaLabel,z=void 0===Y?"Month":Y,G=s.yearSelectionAriaLabel,I=void 0===G?"Year":G,J=s.dropdownsClassName,K=s.intent,Q=void 0===K?"to":K,U=s.dialogContainerSelector,V=r((function(){return"single"===P?A:{from:A,to:H}}),[A,H,P]),X=n(A||new Date),Z=t(X,2),$=Z[0],ee=Z[1],te=o(),ae=o(),re=o(!1);i((function(){var e=+ae.current!=+H,t=!re.current;+te.current!=+A?t&&A&&ee(A):e&&t&&H&&ee(H),te.current=A,ae.current=H,re.current=!1}),[A,H]);var ne=d((function(e,t){if(re.current=!0,"range"===P){var a=b(t,V,Q);L({date:null==a?void 0:a.from,endDate:null==a?void 0:a.to})}else{var r=e,n=A?{hours:A.getHours(),minutes:A.getMinutes()}:N;r.setHours(n.hours,n.minutes),L(r)}}),[A,Q,P,L,V]),oe=r((function(){return{setDisplayMonth:ee,locale:B,nextButtonAriaLabel:_,prevButtonAriaLabel:F,monthSelectionAriaLabel:z,yearSelectionAriaLabel:I,dropdownsClassName:J,dialogContainerSelector:U}}),[B,z,_,ee,F,I,J,U]),ie=r((function(){return Object.assign(Object.assign({},E),e({},c.Selected,l(E[c.Selected],v)))}),[v]),de=r((function(){return{months:m.datePickerMonths,head:m.datePickerHead,table:m.datePickerTable,tbody:m.datePickerBody,day:l(m.datePickerDay,k)}}),[k]);return a.createElement("div",{id:D,className:l(m.datePicker,e({},m.withWeekNumber,x),f),"data-testid":g,"data-vibe":"DatePicker"},a.createElement(S,null,a.createElement(j.Provider,{value:oe},a.createElement(R.Consumer,null,(function(e){var t=p(e.hover,V,Q);return a.createElement(u,{fixedWeeks:!0,showOutsideDays:!0,showWeekNumber:x,mode:P,required:!0,weekStartsOn:O,disabled:T,selected:V,onSelect:ne,month:$,onMonthChange:ee,components:{Caption:w,DayContent:"single"===P?C:h},classNames:de,modifiers:t,modifiersClassNames:ie,locale:B})})))))};export{N as DEFAULT_TIME,H as default};
//# sourceMappingURL=DatePicker.js.map
