var J=Object.create;var M=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var P=(e,t,u,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of X(t))!Z.call(e,n)&&n!==u&&M(e,n,{get:()=>t[n],enumerable:!(o=Q(t,n))||o.enumerable});return e};var ee=(e,t,u)=>(u=e!=null?J(Y(e)):{},P(t||!e||!e.__esModule?M(u,"default",{value:e,enumerable:!0}):u,e));var V=_((oe,h)=>{(function(){"use strict";var e={}.hasOwnProperty;function t(){for(var n="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(n=o(n,u(a)))}return n}function u(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var i="";for(var a in n)e.call(n,a)&&n[a]&&(i=o(i,a));return i}function o(n,i){return i?n?n+" "+i:n+i:n}typeof h<"u"&&h.exports?(t.default=t,h.exports=t):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return t}):window.classNames=t})()});var m=ee(V());import l,{useLayoutEffect as C,useRef as re,useState as D}from"react";import{useEffect as te,useRef as ne}from"react";function x(e){let t=ne(null);return te(()=>{e&&(typeof e=="function"?e(t.current):e.current=t.current)},[t,e]),t}function T(e){if(e===void 0||isNaN(e))return"";if(e.toString().includes("e")){let[u,o]=e.toString().split("e"),n=u.split(".")[1]?.length||0,i=Number(o);return i<0?e.toFixed(-i+n):e.toLocaleString("fullwide",{useGrouping:!1})}return e.toString()}function R(e){if(e===void 0||isNaN(e))return"";let[t,u]=T(e).split("."),o=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return u?`${o}.${u}`:o}function g(e){if(!e)return NaN;let t=new RegExp("[^-+0-9.]","g"),u=e.replace(t,"");return parseFloat(u)}var pe=l.forwardRef(function({value:t,label:u,clearable:o=!0,errorMessage:n,step:i=1,min:a=0,max:d,commas:H,prefix:w,onValueChange:O,onEnter:A,...s},B){let f=x(B),E=re(null),[S,K]=D(L(t)),[W,I]=D(!1),p=H?R:T;C(()=>{E.current&&f.current&&(f.current.style.paddingLeft=`calc(10px + ${E.current.offsetWidth}px)`)},[w]),C(()=>{typeof t=="number"&&f.current&&(f.current.value=p(t))},[t]);function L(r){return r!==""&&r!==void 0}function F(r){return!!(/^-0?$/.test(r)||/[^.]\.{1}0*$/.test(r))}function $(r){return typeof a=="number"&&r<a?r=a:typeof d=="number"&&d<r&&(r=d),r}function j(r){if(F(r.currentTarget.value))return;let c=p(g(r.currentTarget.value));f.current&&(f.current.value=c),s.onChange?.(r),O?.(g(c)),K(L(r.target.value))}function k(r){s.onFocus?.(r),I(!0)}function U(r){if(s.onBlur?.(r),I(!1),F(r.currentTarget.value))return;let c=$(g(r.currentTarget.value));y(p(c))}function G(r){s.onKeyDown?.(r);let c=g(r.currentTarget.value);r.key==="Enter"&&A?.(c);let b=r.shiftKey?i*10:i;if(r.key==="ArrowDown"){let N=(c||0)-b,v=Math.max(a,N);y(p(v)),r.preventDefault()}if(r.key==="ArrowUp"){let N=(c||0)+b,v=d===void 0?N:Math.min(N,d);y(p(v)),r.preventDefault()}}function q(){y("")}function y(r){if(!f.current)return;Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(f.current,r);let b=new Event("input",{bubbles:!0});f.current.dispatchEvent(b)}let z=o&&S&&!s.disabled&&!s.readOnly;return l.createElement("div",{className:(0,m.default)("leaf-input-container","leaf-number-input",{filled:S,focused:W,error:!!n,disabled:s.disabled})},l.createElement("div",{className:"leaf-label-area"},u&&l.createElement("label",{className:"leaf-label"},u)),l.createElement("div",{className:(0,m.default)("leaf-input-area")},w&&l.createElement("span",{className:(0,m.default)("leaf-prefix","leaf-label"),ref:E},w),l.createElement("input",{...s,className:(0,m.default)("leaf-input",{clearable:o},s.className),type:"text",ref:f,onChange:j,onFocus:k,onBlur:U,onKeyDown:G,style:s.style}),z&&l.createElement("button",{type:"button",className:"leaf-clear-button",onClick:q,tabIndex:-1})),l.createElement("div",{className:"leaf-extra-area"},n&&l.createElement("p",{className:(0,m.default)("leaf-error-message","leaf-desc")},n)))});export{pe as default};
/*! Bundled license information:

classnames/index.js:
  (*!
  	Copyright (c) 2018 Jed Watson.
  	Licensed under the MIT License (MIT), see
  	http://jedwatson.github.io/classnames
  *)
*/
