"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const V=require("vue"),T=require("../../_util/BaseMixin.js"),k=require("../../_util/props-util/index.js"),o=require("../../_util/vue-types/index.js"),H=require("./common/Track.js"),M=require("./common/createSlider.js"),l=require("./utils.js"),O=V.defineComponent({compatConfig:{MODE:3},name:"Slider",mixins:[T.default],inheritAttrs:!1,props:{defaultValue:Number,value:Number,disabled:{type:Boolean,default:void 0},autofocus:{type:Boolean,default:void 0},tabindex:o.default.oneOfType([o.default.number,o.default.string]),reverse:{type:Boolean,default:void 0},min:Number,max:Number,ariaLabelForHandle:String,ariaLabelledByForHandle:String,ariaValueTextFormatterForHandle:String,startPoint:Number},emits:["beforeChange","afterChange","change"],data(){const e=this.defaultValue!==void 0?this.defaultValue:this.min,t=this.value!==void 0?this.value:e;return{sValue:this.trimAlignValue(t),dragging:!1}},watch:{value:{handler(e){this.setChangeValue(e)},deep:!0},min(){const{sValue:e}=this;this.setChangeValue(e)},max(){const{sValue:e}=this;this.setChangeValue(e)}},methods:{setChangeValue(e){const t=e!==void 0?e:this.sValue,a=this.trimAlignValue(t,this.$props);a!==this.sValue&&(this.setState({sValue:a}),l.isValueOutOfRange(t,this.$props)&&this.$emit("change",a))},onChange(e){const t=!k.hasProp(this,"value"),a=e.sValue>this.max?{...e,sValue:this.max}:e;t&&this.setState(a);const s=a.sValue;this.$emit("change",s)},onStart(e){this.setState({dragging:!0});const{sValue:t}=this;this.$emit("beforeChange",t);const a=this.calcValueByPos(e);this.startValue=a,this.startPosition=e,a!==t&&(this.prevMovedHandleIndex=0,this.onChange({sValue:a}))},onEnd(e){const{dragging:t}=this;this.removeDocumentEvents(),(t||e)&&this.$emit("afterChange",this.sValue),this.setState({dragging:!1})},onMove(e,t){l.pauseEvent(e);const{sValue:a}=this,s=this.calcValueByPos(t);s!==a&&this.onChange({sValue:s})},onKeyboard(e){const{reverse:t,vertical:a}=this.$props,s=l.getKeyboardValueMutator(e,a,t);if(s){l.pauseEvent(e);const{sValue:i}=this,r=s(i,this.$props),n=this.trimAlignValue(r);if(n===i)return;this.onChange({sValue:n}),this.$emit("afterChange",n),this.onEnd()}},getLowerBound(){const e=this.$props.startPoint||this.$props.min;return this.$data.sValue>e?e:this.$data.sValue},getUpperBound(){return this.$data.sValue<this.$props.startPoint?this.$props.startPoint:this.$data.sValue},trimAlignValue(e,t={}){if(e===null)return null;const a={...this.$props,...t},s=l.ensureValueInRange(e,a);return l.ensureValuePrecision(s,a)},getTrack({prefixCls:e,reverse:t,vertical:a,included:s,minimumTrackStyle:i,mergedTrackStyle:r,length:n,offset:u}){return V.createVNode(H.default,{class:`${e}-track`,vertical:a,included:s,offset:u,reverse:t,length:n,style:{...i,...r}},null)},renderSlider(){const{prefixCls:e,vertical:t,included:a,disabled:s,minimumTrackStyle:i,trackStyle:r,handleStyle:n,tabindex:u,ariaLabelForHandle:m,ariaLabelledByForHandle:p,ariaValueTextFormatterForHandle:v,min:b,max:$,startPoint:d,reverse:h,handle:S,defaultHandle:x}=this,y=S||x,{sValue:c,dragging:C}=this,f=this.calcOffset(c),B=y({class:`${e}-handle`,prefixCls:e,vertical:t,offset:f,value:c,dragging:C,disabled:s,min:b,max:$,reverse:h,index:0,tabindex:u,ariaLabel:m,ariaLabelledBy:p,ariaValueTextFormatter:v,style:n[0]||n,ref:F=>this.saveHandle(0,F),onFocus:this.onFocus,onBlur:this.onBlur}),g=d!==void 0?this.calcOffset(d):0,P=r[0]||r;return{tracks:this.getTrack({prefixCls:e,reverse:h,vertical:t,included:a,offset:g,minimumTrackStyle:i,mergedTrackStyle:P,length:f-g}),handles:B}}}}),q=M.default(O);exports.default=q;
