import{A as e,D as t,I as n,_ as r,et as i,pt as a,vt as o}from"./vue.runtime.esm-bundler-gHHLlCcd.js";import{C as s,D as c,Dt as l,Mt as ee,S as u,Tt as d,a as f,dt as p,en as m,i as h,it as te,lt as g,m as _,nt as ne,pt as v,tn as y,w as b}from"./_plugin-vue_export-helper-BgFcNt9i.js";import{n as x,o as re,p as S,t as C}from"./Input-CzZwXnLY.js";import{i as w}from"./Tooltip-AUgbrayK.js";var T=t({name:`Remove`,render(){return e(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`},e(`line`,{x1:`400`,y1:`256`,x2:`112`,y2:`256`,style:`
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 32px;
      `}))}});function E(e){let{textColorDisabled:t}=e;return{iconColorDisabled:t}}var D=s({name:`InputNumber`,common:_,peers:{Button:f,Input:x},self:E}),ie=m([y(`input-number-suffix`,`
 display: inline-block;
 margin-right: 10px;
 `),y(`input-number-prefix`,`
 display: inline-block;
 margin-left: 10px;
 `)]);function ae(e){return e==null||typeof e==`string`&&e.trim()===``?null:Number(e)}function O(e){return e.includes(`.`)&&(/^(-)?\d+.*(\.|0)$/.test(e)||/^-?\d*$/.test(e))||e===`-`||e===`-0`}function k(e){return e==null?!0:!Number.isNaN(e)}function A(e,t){return typeof e==`number`?t===void 0?String(e):e.toFixed(t):``}function j(e){if(e===null)return null;if(typeof e==`number`)return e;{let t=Number(e);return Number.isNaN(t)?null:t}}var M=800,N=100,P=t({name:`InputNumber`,props:Object.assign(Object.assign({},b.props),{autofocus:Boolean,loading:{type:Boolean,default:void 0},placeholder:String,defaultValue:{type:Number,default:null},value:Number,step:{type:[Number,String],default:1},min:[Number,String],max:[Number,String],size:String,disabled:{type:Boolean,default:void 0},validator:Function,bordered:{type:Boolean,default:void 0},showButton:{type:Boolean,default:!0},buttonPlacement:{type:String,default:`right`},inputProps:Object,readonly:Boolean,clearable:Boolean,keyboard:{type:Object,default:{}},updateValueOnInput:{type:Boolean,default:!0},round:{type:Boolean,default:void 0},parse:Function,format:Function,precision:Number,status:String,"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],onFocus:[Function,Array],onBlur:[Function,Array],onClear:[Function,Array],onChange:[Function,Array]}),slots:Object,setup(e){let{mergedBorderedRef:t,mergedClsPrefixRef:s,mergedRtlRef:u,mergedComponentPropsRef:f}=te(e),p=b(`InputNumber`,`-input-number`,ie,D,e,s),{localeRef:m}=re(`InputNumber`),h=ne(e,{mergedSize:t=>{let{size:n}=e;if(n)return n;let{mergedSize:r}=t||{};return r?.value?r.value:f?.value?.InputNumber?.size||`medium`}}),{mergedSizeRef:g,mergedDisabledRef:_,mergedStatusRef:y}=h,x=a(null),C=a(null),w=a(null),T=a(e.defaultValue),E=S(o(e,`value`),T),P=a(``),F=e=>{let t=String(e).split(`.`)[1];return t?t.length:0},oe=t=>{let n=[e.min,e.max,e.step,t].map(e=>e===void 0?0:F(e));return Math.max(...n)},se=d(()=>{let{placeholder:t}=e;return t===void 0?m.value.placeholder:t}),I=d(()=>{let t=j(e.step);return t===null||t===0?1:Math.abs(t)}),L=d(()=>{let t=j(e.min);return t===null?null:t}),R=d(()=>{let t=j(e.max);return t===null?null:t}),z=()=>{let{value:t}=E;if(k(t)){let{format:n,precision:r}=e;n?P.value=n(t):t===null||r===void 0||F(t)>r?P.value=A(t,void 0):P.value=A(t,r)}else P.value=String(t)};z();let B=t=>{let{value:n}=E;if(t===n){z();return}let{"onUpdate:value":r,onUpdateValue:i,onChange:a}=e,{nTriggerFormInput:o,nTriggerFormChange:s}=h;a&&v(a,t),i&&v(i,t),r&&v(r,t),T.value=t,o(),s()},V=({offset:t,doUpdateIfValid:n,fixPrecision:r,isInputing:i})=>{let{value:a}=P;if(i&&O(a))return!1;let o=(e.parse||ae)(a);if(o===null)return n&&B(null),null;if(k(o)){let a=F(o),{precision:s}=e;if(s!==void 0&&s<a&&!r)return!1;let c=Number.parseFloat((o+t).toFixed(s??oe(o)));if(k(c)){let{value:t}=R,{value:r}=L;if(t!==null&&c>t){if(!n||i)return!1;c=t}if(r!==null&&c<r){if(!n||i)return!1;c=r}return e.validator&&!e.validator(c)?!1:(n&&B(c),c)}}return!1},ce=d(()=>V({offset:0,doUpdateIfValid:!1,isInputing:!1,fixPrecision:!1})===!1),H=d(()=>{let{value:t}=E;if(e.validator&&t===null)return!1;let{value:n}=I;return V({offset:-n,doUpdateIfValid:!1,isInputing:!1,fixPrecision:!1})!==!1}),U=d(()=>{let{value:t}=E;if(e.validator&&t===null)return!1;let{value:n}=I;return V({offset:+n,doUpdateIfValid:!1,isInputing:!1,fixPrecision:!1})!==!1});function W(t){let{onFocus:n}=e,{nTriggerFormFocus:r}=h;n&&v(n,t),r()}function le(t){if(t.target===x.value?.wrapperElRef)return;let r=V({offset:0,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0});if(r!==!1){let e=x.value?.inputElRef;e&&(e.value=String(r||``)),E.value===r&&z()}else z();let{onBlur:i}=e,{nTriggerFormBlur:a}=h;i&&v(i,t),a(),n(()=>{z()})}function ue(t){let{onClear:n}=e;n&&v(n,t)}function G(){let{value:t}=U;if(!t){$();return}let{value:n}=E;if(n===null)e.validator||B(q());else{let{value:e}=I;V({offset:e,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0})}}function K(){let{value:t}=H;if(!t){Z();return}let{value:n}=E;if(n===null)e.validator||B(q());else{let{value:e}=I;V({offset:-e,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0})}}let de=W,fe=le;function q(){if(e.validator)return null;let{value:t}=L,{value:n}=R;return t===null?n===null?0:Math.min(0,n):Math.max(0,t)}function pe(e){ue(e),B(null)}function me(e){var t;w.value?.$el.contains(e.target)&&e.preventDefault(),C.value?.$el.contains(e.target)&&e.preventDefault(),(t=x.value)==null||t.activate()}let J=null,Y=null,X=null;function Z(){X&&=(window.clearTimeout(X),null),J&&=(window.clearInterval(J),null)}let Q=null;function $(){Q&&=(window.clearTimeout(Q),null),Y&&=(window.clearInterval(Y),null)}function he(){Z(),X=window.setTimeout(()=>{J=window.setInterval(()=>{K()},N)},M),l(`mouseup`,document,Z,{once:!0})}function ge(){$(),Q=window.setTimeout(()=>{Y=window.setInterval(()=>{G()},N)},M),l(`mouseup`,document,$,{once:!0})}let _e=()=>{Y||G()},ve=()=>{J||K()};function ye(t){var n;if(t.key===`Enter`){if(t.target===x.value?.wrapperElRef)return;V({offset:0,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0})!==!1&&((n=x.value)==null||n.deactivate())}else if(t.key===`ArrowUp`){if(!U.value||e.keyboard.ArrowUp===!1)return;t.preventDefault(),V({offset:0,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0})!==!1&&G()}else if(t.key===`ArrowDown`){if(!H.value||e.keyboard.ArrowDown===!1)return;t.preventDefault(),V({offset:0,doUpdateIfValid:!0,isInputing:!1,fixPrecision:!0})!==!1&&K()}}function be(t){P.value=t,e.updateValueOnInput&&!e.format&&!e.parse&&e.precision===void 0&&V({offset:0,doUpdateIfValid:!0,isInputing:!0,fixPrecision:!1})}i(E,()=>{z()});let xe={focus:()=>x.value?.focus(),blur:()=>x.value?.blur(),select:()=>x.value?.select()},Se=c(`InputNumber`,u,s);return Object.assign(Object.assign({},xe),{rtlEnabled:Se,inputInstRef:x,minusButtonInstRef:C,addButtonInstRef:w,mergedClsPrefix:s,mergedBordered:t,uncontrolledValue:T,mergedValue:E,mergedPlaceholder:se,displayedValueInvalid:ce,mergedSize:g,mergedDisabled:_,displayedValue:P,addable:U,minusable:H,mergedStatus:y,handleFocus:de,handleBlur:fe,handleClear:pe,handleMouseDown:me,handleAddClick:_e,handleMinusClick:ve,handleAddMousedown:ge,handleMinusMousedown:he,handleKeyDown:ye,handleUpdateDisplayedValue:be,mergedTheme:p,inputThemeOverrides:{paddingSmall:`0 8px 0 10px`,paddingMedium:`0 8px 0 12px`,paddingLarge:`0 8px 0 14px`},buttonThemeOverrides:r(()=>{let{self:{iconColorDisabled:e}}=p.value,[t,n,r,i]=ee(e);return{textColorTextDisabled:`rgb(${t}, ${n}, ${r})`,opacityDisabled:`${i}`}})})},render(){let{mergedClsPrefix:t,$slots:n}=this,r=()=>e(h,{text:!0,disabled:!this.minusable||this.mergedDisabled||this.readonly,focusable:!1,theme:this.mergedTheme.peers.Button,themeOverrides:this.mergedTheme.peerOverrides.Button,builtinThemeOverrides:this.buttonThemeOverrides,onClick:this.handleMinusClick,onMousedown:this.handleMinusMousedown,ref:`minusButtonInstRef`},{icon:()=>g(n[`minus-icon`],()=>[e(u,{clsPrefix:t},{default:()=>e(T,null)})])}),i=()=>e(h,{text:!0,disabled:!this.addable||this.mergedDisabled||this.readonly,focusable:!1,theme:this.mergedTheme.peers.Button,themeOverrides:this.mergedTheme.peerOverrides.Button,builtinThemeOverrides:this.buttonThemeOverrides,onClick:this.handleAddClick,onMousedown:this.handleAddMousedown,ref:`addButtonInstRef`},{icon:()=>g(n[`add-icon`],()=>[e(u,{clsPrefix:t},{default:()=>e(w,null)})])});return e(`div`,{class:[`${t}-input-number`,this.rtlEnabled&&`${t}-input-number--rtl`]},e(C,{ref:`inputInstRef`,autofocus:this.autofocus,status:this.mergedStatus,bordered:this.mergedBordered,loading:this.loading,value:this.displayedValue,onUpdateValue:this.handleUpdateDisplayedValue,theme:this.mergedTheme.peers.Input,themeOverrides:this.mergedTheme.peerOverrides.Input,builtinThemeOverrides:this.inputThemeOverrides,size:this.mergedSize,placeholder:this.mergedPlaceholder,disabled:this.mergedDisabled,readonly:this.readonly,round:this.round,textDecoration:this.displayedValueInvalid?`line-through`:void 0,onFocus:this.handleFocus,onBlur:this.handleBlur,onKeydown:this.handleKeyDown,onMousedown:this.handleMouseDown,onClear:this.handleClear,clearable:this.clearable,inputProps:this.inputProps,internalLoadingBeforeSuffix:!0},{prefix:()=>this.showButton&&this.buttonPlacement===`both`?[r(),p(n.prefix,n=>n?e(`span`,{class:`${t}-input-number-prefix`},n):null)]:n.prefix?.call(n),suffix:()=>this.showButton?[p(n.suffix,n=>n?e(`span`,{class:`${t}-input-number-suffix`},n):null),this.buttonPlacement===`right`?r():null,i()]:n.suffix?.call(n)}))}});export{P as t};