import e from"../../../_util/classNames.mjs";import t from"../../../_util/KeyCode.mjs";import n from"../../hooks/useMergeProps.mjs";import{setDateTime as r}from"../../utils/timeUtil.mjs";import{tuple as i}from"../../utils/miscUtil.mjs";import a from"../DatePanel/index.mjs";import o from"../TimePanel/index.mjs";import{createVNode as s,ref as c}from"vue";var l=i(`date`,`time`);function u(i){let u=n(i),{prefixCls:d,operationRef:f,generateConfig:p,value:m,defaultValue:h,disabledTime:g,showTime:_,onSelect:v}=u,y=`${d}-datetime-panel`,b=c(null),x=c({}),S=c({}),C=typeof _==`object`?{..._}:{};function w(e){return l[l.indexOf(b.value)+e]||null}let T=e=>{S.value.onBlur&&S.value.onBlur(e),b.value=null};f.value={onKeydown:e=>{if(e.which===t.TAB){let t=w(e.shiftKey?-1:1);return b.value=t,t&&e.preventDefault(),!0}if(b.value){let t=b.value===`date`?x:S;return t.value&&t.value.onKeydown&&t.value.onKeydown(e),!0}return[t.LEFT,t.RIGHT,t.UP,t.DOWN].includes(e.which)?(b.value=`date`,!0):!1},onBlur:T,onClose:T};let E=(e,t)=>{let n=e;t===`date`&&!m&&C.defaultValue?(n=p.setHour(n,p.getHour(C.defaultValue)),n=p.setMinute(n,p.getMinute(C.defaultValue)),n=p.setSecond(n,p.getSecond(C.defaultValue))):t===`time`&&!m&&h&&(n=p.setYear(n,p.getYear(h)),n=p.setMonth(n,p.getMonth(h)),n=p.setDate(n,p.getDate(h))),v&&v(n,`mouse`)},D=g?g(m||null):{};return s(`div`,{class:e(y,{[`${y}-active`]:b.value})},[s(a,{...u,operationRef:x,active:b.value===`date`,onSelect:e=>{E(r(p,e,!m&&typeof _==`object`?_.defaultValue:null),`date`)}},null),s(o,{...u,format:void 0,...C,...D,disabledTime:null,defaultValue:void 0,operationRef:S,active:b.value===`time`,onSelect:e=>{E(e,`time`)}},null)])}u.displayName=`DatetimePanel`,u.inheritAttrs=!1;export{u as default};