1if(!customElements.get("price-range")){class PriceRange extends HTMLElement{constructor(){super(),this.selectors={inputMin:".cc-price-range__input--min",inputMax:".cc-price-range__input--max",control:".cc-price-range__control",controlMin:".cc-price-range__control--min",controlMax:".cc-price-range__control--max",bar:".cc-price-range__bar",activeBar:".cc-price-range__bar-active"},this.controls={min:{barControl:this.querySelector(this.selectors.controlMin),input:this.querySelector(this.selectors.inputMin)},max:{barControl:this.querySelector(this.selectors.controlMax),input:this.querySelector(this.selectors.inputMax)}},this.controls.min.value=parseInt(this.controls.min.input.value===""?this.controls.min.input.placeholder:this.controls.min.input.value,10),this.controls.max.value=parseInt(this.controls.max.input.value===""?this.controls.max.input.placeholder:this.controls.max.input.value,10),this.valueMin=this.controls.min.input.min,this.valueMax=this.controls.max.input.max,this.valueRange=this.valueMax-this.valueMin,[this.controls.min,this.controls.max].forEach(item=>{item.barControl.setAttribute("aria-valuemin",this.valueMin),item.barControl.setAttribute("aria-valuemax",this.valueMax),item.barControl.setAttribute("tabindex",0)}),this.controls.min.barControl.setAttribute("role","slider"),this.controls.min.barControl.setAttribute("aria-valuenow",this.controls.min.value),this.controls.max.barControl.setAttribute("role","slider"),this.controls.max.barControl.setAttribute("aria-valuenow",this.controls.max.value),this.bar=this.querySelector(this.selectors.bar),this.activeBar=this.querySelector(this.selectors.activeBar),this.inDrag=!1,this.rtl=document.querySelector("html[dir=rtl]"),this.bindEvents(),this.render()}getPxToValueRatio(){const r=this.bar.clientWidth/(this.valueMax-this.valueMin);return this.rtl?-r:r}getPcToValueRatio(){return 100/(this.valueMax-this.valueMin)}setActiveControlValue(valueIn){let value=valueIn;Number.isNaN(parseInt(value,10))||(this.activeControl===this.controls.min?(value===""&&(value=this.valueMin),value=Math.min(value,this.controls.max.value-1),value=Math.max(this.valueMin,value)):(value===""&&(value=this.valueMax),value=Math.max(value,this.controls.min.value+1),value=Math.min(this.valueMax,value)),this.activeControl.value=Math.round(value),this.activeControl.input.value!==this.activeControl.value&&(this.activeControl.value===this.activeControl.input.placeholder?this.activeControl.input.value="":this.activeControl.input.value=this.activeControl.value,this.activeControl.input.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!1,detail:{sender:"theme:component:price_range"}}))),this.activeControl.barControl.setAttribute("aria-valuenow",this.activeControl.value))}render(){this.drawControl(this.controls.min),this.drawControl(this.controls.max),this.drawActiveBar()}drawControl(control){const x=`${(control.value-this.valueMin)*this.getPcToValueRatio()}%`;this.rtl?control.barControl.style.right=x:control.barControl.style.left=x}drawActiveBar(){const s=`${(this.controls.min.value-this.valueMin)*this.getPcToValueRatio()}%`,e=`${(this.valueMax-this.controls.max.value)*this.getPcToValueRatio()}%`;this.rtl?(this.activeBar.style.left=e,this.activeBar.style.right=s):(this.activeBar.style.left=s,this.activeBar.style.right=e)}handleControlTouchStart(e){e.preventDefault(),this.startDrag(e.target,e.touches[0].clientX),this.boundControlTouchMoveEvent=this.handleControlTouchMove.bind(this),this.boundControlTouchEndEvent=this.handleControlTouchEnd.bind(this),window.addEventListener("touchmove",this.boundControlTouchMoveEvent,{passive:!0}),window.addEventListener("touchend",this.boundControlTouchEndEvent)}handleControlTouchMove(e){this.moveDrag(e.touches[0].clientX)}handleControlTouchEnd(e){e.preventDefault(),window.removeEventListener("touchmove",this.boundControlTouchMoveEvent),window.removeEventListener("touchend",this.boundControlTouchEndEvent),this.stopDrag(
1)}handleControlMouseDown(e){e.preventDefault(),this.startDrag(e.target,e.clientX),this.boundControlMouseMoveEvent=this.handleControlMouseMove.bind(this),this.boundControlMouseUpEvent=this.handleControlMouseUp.bind(this),window.addEventListener("mousemove",this.boundControlMouseMoveEvent),window.addEventListener("mouseup",this.boundControlMouseUpEvent)}handleControlMouseMove(e){this.moveDrag(e.clientX)}handleControlMouseUp(e){e.preventDefault(),window.removeEventListener("mousemove",this.boundControlMouseMoveEvent),window.removeEventListener("mouseup",this.boundControlMouseUpEvent),this.stopDrag()}startDrag(target,startX){this.controls.min.barControl===target?this.activeControl=this.controls.min:this.activeControl=this.controls.max,this.dragStartX=startX,this.dragStartValue=this.activeControl.value,this.inDrag=!0}moveDrag(moveX){if(this.inDrag){const value=this.dragStartValue+(moveX-this.dragStartX)/this.getPxToValueRatio();this.setActiveControlValue(value),this.render()}}stopDrag(){this.inDrag=!1}handleControlKeyDown(evt){evt.key==="ArrowRight"?(this.adjustControlFromKeypress(evt.target,10),evt.preventDefault()):evt.key==="ArrowLeft"?(this.adjustControlFromKeypress(evt.target,-10),evt.preventDefault()):evt.key==="Home"?(this.adjustControlFromKeypress(evt.target,!1,"min"),evt.preventDefault()):evt.key==="End"&&(this.adjustControlFromKeypress(evt.target,!1,"max"),evt.preventDefault())}adjustControlFromKeypress(control,pxAmount,minMax){this.controls.min.barControl===control?this.activeControl=this.controls.min:this.activeControl=this.controls.max,minMax?minMax==="min"?this.setActiveControlValue(this.activeControl.input.min):this.setActiveControlValue(this.activeControl.input.max):this.setActiveControlValue(this.activeControl.value+pxAmount/this.getPxToValueRatio()),this.render()}handleInputChange(e){e.target.value=e.target.value.replace(/\D/g,""),(!e.detail||e.detail.sender!=="theme:component:price_range")&&(this.controls.min.input===e.target?this.activeControl=this.controls.min:this.activeControl=this.controls.max,this.setActiveControlValue(e.target.value),this.render())}static handleInputKeyup(e){setTimeout(()=>{e.target.value=e.target.value.replace(/\D/g,"")},10)}bindEvents(){[this.controls.min,this.controls.max].forEach(item=>{item.barControl.addEventListener("touchstart",this.handleControlTouchStart.bind(this),{passive:!1}),item.barControl.addEventListener("mousedown",this.handleControlMouseDown.bind(this)),item.barControl.addEventListener("keydown",this.handleControlKeyDown.bind(this)),item.input.addEventListener("change",this.handleInputChange.bind(this)),item.input.addEventListener("keyup",PriceRange.handleInputKeyup)})}}customElements.define("price-range",PriceRange)} 2//# sourceMappingURL=/cdn/shop/t/80/assets/price-range.js.map?v=57919097508744252771776343343
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.