import{Component}from"@theme/component";import{QuantitySelectorUpdateEvent}from"@theme/events";class QuantitySelectorComponent extends Component{increaseQuantity(event){event.target instanceof HTMLElement&&(event.preventDefault(),this.refs.quantityInput.stepUp(),this.#onQuantityChange())}decreaseQuantity(event){event.target instanceof HTMLElement&&(event.preventDefault(),this.refs.quantityInput.stepDown(),this.#onQuantityChange())}selectInputValue(event){const{quantityInput}=this.refs;!(event.target instanceof HTMLInputElement)||document.activeElement!==quantityInput||quantityInput.select()}setQuantity(event){event.target instanceof HTMLElement&&(event.preventDefault(),event.target instanceof HTMLInputElement&&(this.refs.quantityInput.value=event.target.value),this.#onQuantityChange())}#onQuantityChange(){const{quantityInput}=this.refs;this.#checkQuantityRules();const newValue=parseInt(quantityInput.value);quantityInput.dispatchEvent(new QuantitySelectorUpdateEvent(newValue,Number(quantityInput.dataset.cartLine)))}#checkQuantityRules=()=>{const{quantityInput}=this.refs,{min,max,value:newValue}=quantityInput;newValuemax&&max&&(quantityInput.value=max)};get quantityInput(){if(!this.refs.quantityInput)throw new Error('Missing inside ');return this.refs.quantityInput}}customElements.get("quantity-selector-component")||customElements.define("quantity-selector-component",QuantitySelectorComponent); //# sourceMappingURL=/cdn/shop/t/47/assets/component-quantity-selector.js.map?v=56330027151833116691757451905