import{r as t,c as s,h as i,H as h,g as e}from"./p-78e3ebb9.js";const n=class{constructor(i){t(this,i);this.onChange=s(this,"change",7);this.onChanging=s(this,"changing",7);this.handleTouchStart=t=>{if(this.touching||this.disabled)return;this.touching=true;this.touchId=t.targetTouches[0].identifier;this.totalWidth=this.sliderInsRef.clientWidth||1;this.ogX=t.targetTouches[0].pageX;this.ogPercent=this.percent};this.handleTouchMove=t=>{const{disabled:s,touching:i,touchId:h,totalWidth:e,max:n,min:o,ogX:a,ogPercent:r}=this;if(!i||s)return;if(t.targetTouches[0].identifier!==h)return;t.preventDefault();const l=t.targetTouches[0].pageX;const c=l-a;let u=c/e*100+r;u=this.handleValueUpdate(u,0,100);const d=o+u*.01*(n-o);this.updateByStep(d);this.onChanging.emit({detail:t.detail,value:this.value})};this.handleTouchEnd=t=>{const{disabled:s,touching:i}=this;if(!i||s)return;if(this.percent!==this.ogPercent){this.onChange.emit({detail:t.detail,value:this.value})}this.touching=false;this.touchId=null;this.ogX=0;this.ogPercent=0};this.handleValueUpdate=(t,s=this.min,i=this.max)=>{t=isNaN(t)?0:t;return Math.max(s,Math.min(t,i))};this.min=0;this.max=100;this.step=1;this.disabled=false;this.value=0;this.activeColor="#1aad19";this.backgroundColor="#e9e9e9";this.blockSize=28;this.blockColor="#ffffff";this.showValue=false;this.name="";this.totalWidth=1;this.touching=false;this.ogX=0;this.touchId=null;this.percent=0;this.ogPercent=undefined;this.isWillLoadCalled=false}function(t){if(!this.isWillLoadCalled)return;const{max:s,min:i}=this;if(t!==null){const h=this.handleValueUpdate(t,i,s);this.updateByStep(h)}}componentDidLoad(){this.handler.addEventListener("touchstart",this.handleTouchStart);this.handler.addEventListener("touchmove",this.handleTouchMove);this.handler.addEventListener("touchend",this.handleTouchEnd)}componentWillLoad(){this.isWillLoadCalled=true;const{value:t,max:s,min:i}=this;const h=this.handleValueUpdate(t,i,s);this.updateByStep(h)}updateByStep(t){const{max:s,min:i,step:h}=this;const e=Math.floor((s-i)/h);for(let s=0;s<=e;s++){const n=i+h*s;const o=s===e?null:i+h*(s+1);if(t===n)break;if(!o&&t>n){t=n}if(o&&t>n&&t<o){if(t-n<h/2){t=n}else{t=o}break}}const n=(t-i)/(s-i)*100;this.value=t;this.percent=n}render(){const{showValue:t,backgroundColor:s,activeColor:e,blockColor:n,name:o,percent:a,value:r}=this;let l=this.blockSize;const c={backgroundColor:s};const u=a>100?100:a;const d={width:`${u}%`,backgroundColor:e};if(l<12){l=12}if(l>28){l=28}const f={left:`${u}%`,width:`${l}px`,height:`${l}px`,backgroundColor:n,marginTop:`-${Math.floor(l/2)}px`,marginLeft:`-${Math.floor(l/2)}px`};return i(h,{class:"weui-slider-box"},i("div",{class:"weui-slider"},i("div",{class:"weui-slider__inner",style:c,ref:t=>this.sliderInsRef=t},i("div",{style:d,class:"weui-slider__track"}),i("div",{class:"weui-slider__handler",ref:t=>{if(t)this.handler=t},style:f}),i("input",{type:"hidden",name:o,value:r}))),t&&i("div",{class:"weui-slider-box__value"},r))}get el(){return e(this)}static get watchers(){return{value:["function"]}}};export{n as taro_slider_core};
//# sourceMappingURL=p-93ccd68a.entry.js.map