import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["events","dateTimeView","locale","dropdownForm","dropdownClassName","dropdownRef","currentVisibleDate","onChangeCurrentVisibleDate","multiplicityHours","multiplicityMinutes","multiplicitySeconds","renderAdditionalControls","onDropdownOpen","dropdownOpen","ignoreOutsideClicksRefs","disabled","inputRef"];import addMonths from"date-fns/addMonths";import startOfMonth from"date-fns/startOfMonth";import React,{forwardRef,useEffect,useRef}from"react";import{useClickOutside}from"../../../hooks/useClickOutside/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef";import{setRef}from"../../../utils/setRef";import{DatePickerDropdown}from"../DatePickerDropdown/DatePickerDropdown";import{DatePickerFieldTypeDateTime}from"../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime";import{datePickerPropFormatTypeDateTime,getDropdownZIndex,getMultiplicityTime}from"../helpers";import{datePickerPropDateTimeViewDefault}from"../types";import{useCalendarVisible}from"../useCalendarVisible";import{useCurrentVisibleDate}from"../useCurrentVisibleDate";export var DatePickerTypeDateTime=forwardRef(function(a,b){var c=a.events,d=a.dateTimeView,e=void 0===d?datePickerPropDateTimeViewDefault:d,f=a.locale,g=a.dropdownForm,h=a.dropdownClassName,i=a.dropdownRef,j=a.currentVisibleDate,k=a.onChangeCurrentVisibleDate,l=a.multiplicityHours,m=a.multiplicityMinutes,n=a.multiplicitySeconds,o=a.renderAdditionalControls,p=a.onDropdownOpen,q=a.dropdownOpen,r=a.ignoreOutsideClicksRefs,s=a.disabled,t=a.inputRef,u=_objectWithoutProperties(a,_excluded),v=getMultiplicityTime(u.format||datePickerPropFormatTypeDateTime,l,m,n),w=_slicedToArray(v,3),x=w[0],y=w[1],z=w[2],A=useRef(null),B=useRef(null),C=useRef(null),D=useCalendarVisible({dropdownOpen:q,onDropdownOpen:p,disabled:s,startRef:C}),E=_slicedToArray(D,2),F=E[0],G=E[1],H=useCurrentVisibleDate({currentVisibleDate:j,maxDate:a.maxDate,minDate:a.minDate,value:a.value,startOfUnit:startOfMonth,onChangeCurrentVisibleDate:k,calendarVisible:F}),I=_slicedToArray(H,2),J=I[0],K=I[1];return useEffect(function(){b&&setRef(b,A.current)},[b,A]),useEffect(function(){if(a.value&&"classic"===e&&J){var b=startOfMonth(a.value);return void(b.getTime()!==J.getTime()&&K(b))}if(a.value&&"classic"!==e&&J){var c=startOfMonth(a.value);c.getTime()!==J.getTime()&&c.getTime()!==addMonths(J,1).getTime()&&K(c)}},[a.value]),useClickOutside({isActive:F,ignoreClicksInsideRefs:[A,B].concat(_toConsumableArray(null!==r&&void 0!==r?r:[])),handler:G.off}),React.createElement(React.Fragment,null,React.createElement(DatePickerFieldTypeDateTime,Object.assign({},u,{ref:A,inputRef:useForkRef([C,t]),onClick:G.on,multiplicityHours:x,multiplicitySeconds:z,multiplicityMinutes:y,disabled:s})),React.createElement(DatePickerDropdown,{ref:useForkRef([i,B]),anchorRef:A,isOpen:F,value:a.value||void 0,type:"date-time",view:e,events:c,className:h,locale:f,minDate:a.minDate,maxDate:a.maxDate,currentVisibleDate:J,form:g,onChange:a.onChange,renderAdditionalControls:o,onChangeCurrentVisibleDate:K,multiplicityHours:x,multiplicitySeconds:z,multiplicityMinutes:y,zIndex:getDropdownZIndex(a.style)}))});
//# sourceMappingURL=DatePickerTypeDateTime.js.map