"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../_util/KeyCode.js");function w(t,n){try{return Object.keys(n).some(e=>t.target===n[e].ref)}catch{return!1}}function m(t,{min:n,max:e}){return t<n||t>e}function b(t){return t.touches.length>1||t.type.toLowerCase()==="touchend"&&t.touches.length>0}function c(t,{marks:n,step:e,min:i,max:r}){const s=Object.keys(n).map(Number.parseFloat);if(e!==null){const o=10**l(e),f=Math.floor((r*o-i*o)/(e*o)),g=Math.min((t-i)/e,f),h=Math.round(g)*e+i;s.push(h)}const u=s.map(o=>Math.abs(t-o));return s[u.indexOf(Math.min(...u))]}function l(t){const n=t.toString();let e=0;return n.includes(".")&&(e=n.length-n.indexOf(".")-1),e}function P(t,n){let e=1;return window.visualViewport&&(e=+(window.visualViewport.width/document.body.getBoundingClientRect().width).toFixed(2)),(t?n.clientY:n.pageX)/e}function y(t,n){let e=1;return window.visualViewport&&(e=+(window.visualViewport.width/document.body.getBoundingClientRect().width).toFixed(2)),(t?n.touches[0].clientY:n.touches[0].pageX)/e}function O(t,n){const e=n.getBoundingClientRect();return t?e.top+e.height*.5:window.scrollX+e.left+e.width*.5}function k(t,{max:n,min:e}){return t<=e?e:t>=n?n:t}function V(t,n){const{step:e}=n,i=isFinite(c(t,n))?c(t,n):0;return e===null?i:Number.parseFloat(i.toFixed(l(e)))}function p(t){t.stopPropagation(),t.preventDefault()}function d(t,n,e){const i={increase:(u,o)=>u+o,decrease:(u,o)=>u-o},r=i[t](Object.keys(e.marks).indexOf(JSON.stringify(n)),1),s=Object.keys(e.marks)[r];return e.step?i[t](n,e.step):Object.keys(e.marks).length&&e.marks[s]?e.marks[s]:n}function E(t,n,e){const i="increase",r="decrease";let s=i;switch(t.keyCode){case a.default.UP:s=n&&e?r:i;break;case a.default.RIGHT:s=!n&&e?r:i;break;case a.default.DOWN:s=n&&e?i:r;break;case a.default.LEFT:s=!n&&e?i:r;break;case a.default.END:return(u,o)=>o.max;case a.default.HOME:return(u,o)=>o.min;case a.default.PAGE_UP:return(u,o)=>u+o.step*2;case a.default.PAGE_DOWN:return(u,o)=>u-o.step*2;default:return}return(u,o)=>d(s,u,o)}exports.calculateNextValue=d;exports.ensureValueInRange=k;exports.ensureValuePrecision=V;exports.getClosestPoint=c;exports.getHandleCenterPosition=O;exports.getKeyboardValueMutator=E;exports.getMousePosition=P;exports.getPrecision=l;exports.getTouchPosition=y;exports.isEventFromHandle=w;exports.isNotTouchEvent=b;exports.isValueOutOfRange=m;exports.pauseEvent=p;
