"use strict";const e=require("../common/src/instantiationDecorator.js"),s=require("../common/config.js"),t=require("../common/utils.js"),i=require("./props.js"),a=require("../common/utils.wxs.js"),l=require("../../../../common/vendor.js"),n=`${s.prefix}-stepper`,r=e.uniComponent({name:n,options:{styleIsolation:"shared"},controlledProps:[{key:"value",event:"change"}],externalClasses:[`${s.prefix}-class`,`${s.prefix}-class-input`,`${s.prefix}-class-minus`,`${s.prefix}-class-plus`],components:{TIcon:()=>"../icon/icon.js"},props:{...i.props},data:()=>({currentValue:0,classPrefix:n,prefix:s.prefix,tools:a.tools,disablePlus:!1,disableMinus:!1}),watch:{value(e){this.preValue=Number(e),this.updateCurrentValue(this.format(this.preValue))}},mounted(){const{value:e,defaultValue:s,min:i}=this,a=t.coalesce(e,s);this.updateCurrentValue(a?Number(a):i)},methods:{isDisabled(e){const{min:s,max:t,disabled:i}=this,{currentValue:a}=this;return!!i||("minus"===e&&a<=s||"plus"===e&&a>=t)},getLen(e){const s=e.toString();return-1===s.indexOf(".")?0:s.split(".")[1].length},add(e,s){const t=10**Math.max(this.getLen(e),this.getLen(s));return Math.round(e*t+s*t)/t},format(e){const{min:s,max:t,step:i}=this,a=Math.max(this.getLen(i),this.getLen(e));return Math.max(Math.min(t,e,Number.MAX_SAFE_INTEGER),s,Number.MIN_SAFE_INTEGER).toFixed(a)},setValue(e){const s=Number(this.format(e));this.updateCurrentValue(s),this.preValue!==s&&(this.preValue=s,this._trigger("change",{value:s}))},minusValue(){if(this.isDisabled("minus"))return this.$emit("overlimit",{type:"minus"}),!1;const{currentValue:e,step:s}=this;this.setValue(this.add(e,-s))},plusValue(){if(this.isDisabled("plus"))return this.$emit("overlimit",{type:"plus"}),!1;const{currentValue:e,step:s}=this;this.setValue(this.add(e,s))},filterIllegalChar(e){const s=String(e).replace(/[^0-9.]/g,""),t=s.indexOf(".");return this.integer&&-1!==t?s.split(".")[0]:this.integer||-1===t||t===s.lastIndexOf(".")?s:s.split(".",2).join(".")},updateCurrentValue(e){this.currentValue=e},handleFocus(e){const{value:s}=e.detail;this.$emit("focus",{value:s})},handleInput(e){const{value:s}=e.detail;if(""===s)return;const t=this.filterIllegalChar(s),i=this.format(t);this.updateCurrentValue(this.integer?i:t),(this.integer||/\.\d+/.test(t))&&this.setValue(t)},handleBlur(e){const{value:s}=e.detail,t=this.format(s);this.setValue(t),this.$emit("blur",{value:t})}}});if(!Array){l.resolveComponent("t-icon")()}Math;const u=l._export_sfc(r,[["render",function(e,s,t,i,a,n){return{a:l.p({name:"remove"}),b:l.n(e.classPrefix+"__minus "+e.classPrefix+"__minus--"+e.theme+" "+e.classPrefix+"__icon--"+e.size+" "+(e.disabled||e.disableMinus||e.currentValue<=e.min?e.classPrefix+"--"+e.theme+"-disabled":"")+" "+e.tClassMinus),c:"减少"+e.step,d:e.disabled||e.disableMinus||e.currentValue<=e.min,e:l.o(((...s)=>e.minusValue&&e.minusValue(...s))),f:l.s(e.inputWidth?"width:"+e.inputWidth+"px;":""),g:l.n(e.classPrefix+"__input "+e.classPrefix+"__input--"+e.size+" "+e.tClassInput),h:e.disabled||e.disableInput,i:e.integer?"number":"digit",j:e.currentValue,k:l.o(((...s)=>e.handleInput&&e.handleInput(...s))),l:l.o(((...s)=>e.handleFocus&&e.handleFocus(...s))),m:l.o(((...s)=>e.handleBlur&&e.handleBlur(...s))),n:l.n(e.classPrefix+"__input--"+e.theme+" "+(e.disabled||e.disableInput?e.classPrefix+"--"+e.theme+"-disabled":"")),o:l.p({name:"add"}),p:l.n(e.classPrefix+"__plus "+e.classPrefix+"__plus--"+e.theme+" "+e.classPrefix+"__icon--"+e.size+" "+(e.disabled||e.disablePlus||e.currentValue>=e.max?e.classPrefix+"--"+e.theme+"-disabled":"")+" "+e.tClassPlus),q:"增加"+e.step,r:e.disabled||e.disablePlus||e.currentValue>=e.max,s:l.o(((...s)=>e.plusValue&&e.plusValue(...s))),t:l.s(e.tools._style([e.customStyle])),v:l.n(e.classPrefix+" "+e.classPrefix+"--"+e.size+" "+e.tClass)}}],["__scopeId","data-v-843d0139"]]);wx.createComponent(u);
