import{r as t,c as i,h as e,H as n,g as s}from"./p-40eb06b7.js";const a=class{constructor(e){t(this,e),this.onSubInputEvent=i(this,"sub",7),this.onSumInputEvent=i(this,"sum",7),this.onValidateInputEvent=i(this,"validated",7),e.$hostElement$["s-ei"]?this.internals=e.$hostElement$["s-ei"]:(this.internals=e.$hostElement$.attachInternals(),e.$hostElement$["s-ei"]=this.internals),this.name=void 0,this.min=0,this.max=void 0,this.value=1,this.validate=void 0,this.required=void 0,this.number=void 0,this.isValid=!0}onValueChange(t){this.number="number"==typeof t?t:parseInt(t),this.value=this.number,this.internals.setFormValue(this.number.toString())}async checkValidity(){return this.onValidate(),this.isValid}componentWillLoad(){this.number=this.value,this.internals.setFormValue(this.number.toString())}onBlurInput(){setTimeout((()=>this.onValidate()),50)}onValidate(){if(!this.validate)return;let t=null;["input","select","textarea"].forEach((i=>{null===t&&(t=this.el.querySelector(i))})),this.isValid=!(null==t?void 0:t.validity)||t.validity.valid,this.onValidateInputEvent.emit(t)}handleChange(t){this.value=t.target.value,this.internals.setFormValue(t.target.value)}onPlusClick(){!Number.isNaN(this.number)&&this.number+1>this.max||(this.number++,this.onSumInputEvent.emit(this.number))}onMinusClick(){!Number.isNaN(this.number)&&this.number-1<this.min||(this.number--,this.onSubInputEvent.emit(this.number))}render(){return e(n,{key:"12a40bf5c746f9603fe8f8bbfc47ba7ba9e26c1c",class:{invalid:!this.isValid,required:this.required},"data-for":this.name},e("x-chip",{key:"ed016d64dcd4409399a766d85387f3904dd1c522",hoverable:!0},e("x-button",{key:"70ca16d8fec733d1eeb3c7bd8391fe8edd2ccbce",icon:"plus",onClick:this.onPlusClick.bind(this)}),e("input",{key:"82a8d36ef94c1e293941900a259ad36fe636d112",type:"number",value:this.number,min:this.min,max:this.max,required:this.required,inputMode:"numeric",onInput:this.handleChange.bind(this)}),e("x-button",{key:"684a19401494ce73255ce8dc940e607e14e9208e",icon:"minus",onClick:this.onMinusClick.bind(this)})))}static get formAssociated(){return!0}get el(){return s(this)}static get watchers(){return{value:["onValueChange"]}}};a.style="x-quantity x-chip x-button button{background-color:transparent !important}x-quantity input{width:2rem;-webkit-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-weight:bold;text-align:center;display:inline-block;position:relative;margin:0 0.25rem;border:none;background:transparent;outline:none;-moz-appearance:textfield;border-radius:0.25rem}x-quantity input::-webkit-outer-spin-button,x-quantity input::-webkit-inner-spin-button{-webkit-appearance:none}.is-dark-mode x-quantity input{color:var(--color-text-light, #FEFEFE)}";export{a as x_quantity}