"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../_util/KeyCode.js"),c=require("../../_util/raf.js"),w=require("../../vc-util/Dom/isVisible.js"),o=new Map;function Y(e,t){let r;function n(){w.default(e)?t():r=c.default(()=>{n()})}return n(),()=>{c.default.cancel(r)}}function m(e,t,r){if(o.get(e)&&c.default.cancel(o.get(e)),r<=0){o.set(e,c.default(()=>{e.scrollTop=t}));return}const a=(t-e.scrollTop)/r*10;o.set(e,c.default(()=>{e.scrollTop+=a,e.scrollTop!==t&&m(e,t,r-10)}))}function M(e,{onLeftRight:t,onCtrlLeftRight:r,onUpDown:n,onPageUpDown:a,onEnter:d}){const{which:k,ctrlKey:l,metaKey:f}=e;switch(k){case u.default.LEFT:if(l||f){if(r)return r(-1),!0}else if(t)return t(-1),!0;break;case u.default.RIGHT:if(l||f){if(r)return r(1),!0}else if(t)return t(1),!0;break;case u.default.UP:if(n)return n(-1),!0;break;case u.default.DOWN:if(n)return n(1),!0;break;case u.default.PAGE_UP:if(a)return a(-1),!0;break;case u.default.PAGE_DOWN:if(a)return a(1),!0;break;case u.default.ENTER:if(d)return d(),!0;break}return!1}function g(e,t,r,n){let a=e;if(!a)switch(t){case"time":a=n?"hh:mm:ss a":"HH:mm:ss";break;case"week":a="gggg-wo";break;case"month":a="YYYY-MM";break;case"quarter":a="YYYY-[Q]Q";break;case"year":a="YYYY";break;default:a=r?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD"}return a}function b(e,t,r){const n=e==="time"?8:10,a=typeof t=="function"?t(r.getNow()).length:t.length;return Math.max(n,a)+2}let s=null;const i=new Set;function y(e){return!s&&typeof window<"u"&&window.addEventListener&&(s=t=>{[...i].forEach(r=>{r(t)})},window.addEventListener("mousedown",s)),i.add(e),()=>{i.delete(e),i.size===0&&(window.removeEventListener("mousedown",s),s=null)}}function E(e){const t=e.target;return e.composed&&t.shadowRoot&&e.composedPath?.()[0]||t}const h=e=>e==="month"||e==="date"?"year":e,T=e=>e==="date"?"month":e,p=e=>e==="month"||e==="date"?"quarter":e,v=e=>e==="date"?"week":e,N={year:h,month:T,quarter:p,week:v,time:null,date:null};function F(e,t){return e.some(r=>r&&r.contains(t))}exports.PickerModeMap=N;exports.addGlobalMousedownEvent=y;exports.createKeydownHandler=M;exports.elementsContains=F;exports.getDefaultFormat=g;exports.getInputSize=b;exports.getTargetFromEvent=E;exports.scrollTo=m;exports.waitElementReady=Y;
