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","currentVisibleDate","onChangeCurrentVisibleDate","multiplicityHours","multiplicityMinutes","multiplicitySeconds","renderAdditionalControls","onDropdownOpen","dropdownOpen","ignoreOutsideClicksRefs"];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{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.currentVisibleDate,j=a.onChangeCurrentVisibleDate,k=a.multiplicityHours,l=a.multiplicityMinutes,m=a.multiplicitySeconds,n=a.renderAdditionalControls,o=a.onDropdownOpen,p=a.dropdownOpen,q=a.ignoreOutsideClicksRefs,r=_objectWithoutProperties(a,_excluded),s=getMultiplicityTime(r.format||datePickerPropFormatTypeDateTime,k,l,m),t=_slicedToArray(s,3),u=t[0],v=t[1],w=t[2],x=useRef(null),y=useRef(null),z=useRef(null),A=useCalendarVisible({dropdownOpen:p,onDropdownOpen:o,startRef:z}),B=_slicedToArray(A,2),C=B[0],D=B[1],E=useCurrentVisibleDate({currentVisibleDate:i,maxDate:a.maxDate,minDate:a.minDate,value:a.value,startOfUnit:startOfMonth,onChangeCurrentVisibleDate:j,calendarVisible:C}),F=_slicedToArray(E,2),G=F[0],H=F[1];return useEffect(function(){b&&setRef(b,x.current)},[b,x]),useEffect(function(){if(a.value&&"classic"===e&&G){var b=startOfMonth(a.value);return void(b.getTime()!==G.getTime()&&H(b))}if(a.value&&"classic"!==e&&G){var c=startOfMonth(a.value);c.getTime()!==G.getTime()&&c.getTime()!==addMonths(G,1).getTime()&&H(c)}},[a.value]),useClickOutside({isActive:C,ignoreClicksInsideRefs:[x,y].concat(_toConsumableArray(null!==q&&void 0!==q?q:[])),handler:D.off}),React.createElement(React.Fragment,null,React.createElement(DatePickerFieldTypeDateTime,Object.assign({},r,{ref:x,inputRef:z,onClick:D.on,multiplicityHours:u,multiplicitySeconds:w,multiplicityMinutes:v})),React.createElement(DatePickerDropdown,{ref:y,anchorRef:x,isOpen:C,value:a.value||void 0,type:"date-time",view:e,events:c,className:h,locale:f,minDate:a.minDate,maxDate:a.maxDate,currentVisibleDate:G,form:g,onChange:a.onChange,renderAdditionalControls:n,onChangeCurrentVisibleDate:H,multiplicityHours:u,multiplicitySeconds:w,multiplicityMinutes:v,zIndex:getDropdownZIndex(a.style)}))});
//# sourceMappingURL=DatePickerTypeDateTime.js.map