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