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