import{r as i,c as t,h as e,g as r}from"./p-f06dc8f3.js";import{m as s,b as n}from"./p-84ba0a57.js";const o=class{constructor(e){i(this,e),this.onchange=t(this,"onchange",7),this.size="medium",this.max=10,this.min=0,this.editable=!1,this._bounce=1,this.containerClass=()=>s("ibk-number-picker",[this.size]),this.setBounce=()=>{this._bounce="add"==this._action?this.current>=0&&this.current<20?1:this.current>=20&&this.current<999?10:this.current>=100&&this.current<9999?100:1e3:this.current>=0&&this.current<=20?1:this.current>20&&this.current<=1e3?10:this.current>100&&this.current<=1e4?100:1e3},this.changeQuantity=i=>{this._action=i,"add"==this._action?(this.current+=this._bounce,this.current>this.max&&(this.current=this.max)):(this.current-=this._bounce,this.current<this.min&&(this.current=this.min)),this.setBounce(),this._currentFormated=n(this.current),this.onchange.emit({number:this.current,formated:this._currentFormated})},this.typeNumber=i=>{const t=i.target;""==t.value?this.current=this.min:(this.current=parseInt(t.value.replace(/,/,"")),this.current=isNaN(this.current)||""==t.value?0:this.current,this.current<=this.min?this.current=this.min:this.current>=this.max&&(this.current=this.max)),this._currentFormated=n(this.current),this.host.querySelector(".ibk-number-picker__input").value=this._currentFormated,this.setBounce(),this.onchange.emit({number:this.current,formated:this._currentFormated})}}componentWillLoad(){var i;this.current=null!==(i=this.current)&&void 0!==i?i:this.max,this._currentFormated=n(this.current),this.setBounce()}render(){return e("div",{class:this.containerClass()},e("button",{type:"button",class:"ibk-number-picker__button"+(this.current<=this.min?" ibk-number-picker__button--disabled":""),onClick:()=>this.changeQuantity("remove")},e("i",{class:"ibk-number-picker__button-icon icon-xs-minus"})),e("input",{type:"text",class:"ibk-number-picker__input",value:this._currentFormated,readOnly:!this.editable,onInput:this.typeNumber}),e("button",{type:"button",class:"ibk-number-picker__button"+(this.current>=this.max?" ibk-number-picker__button--disabled":""),onClick:()=>this.changeQuantity("add")},e("i",{class:"ibk-number-picker__button-icon icon-xs-plus"})))}get host(){return r(this)}};o.style=".ibk-number-picker{display:inline-flex;align-items:normal;box-sizing:border-box;border:1px solid var(--gray4);border-radius:4px;overflow:hidden}.ibk-number-picker *{box-sizing:border-box}.ibk-number-picker__input{height:46px;appearance:none;-webkit-appearance:none;-moz-appearance:none;background-color:transparent;outline:none;border:solid var(--gray4);border-width:0 1px 0 1px;padding:0 15px;text-align:center;font-family:var(--fontGeometria);font-weight:500;font-size:16px}.ibk-number-picker__input:read-only{cursor:default}.ibk-number-picker__button{width:46px;appearance:none;-webkit-appearance:none;-moz-appearance:none;outline:none;background-color:transparent;border:none;font-size:20px;color:var(--primaryGreen1);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:var(--fast)}.ibk-number-picker__button--disabled{pointer-events:none;background-color:var(--gray5);color:var(--gray3)}.ibk-number-picker__button:hover{background-color:var(--gray5)}.ibk-number-picker__button:active .ibk-number-picker__button-icon{transform:translateY(1px)}.ibk-number-picker--medium .ibk-number-picker__input{width:70px}.ibk-number-picker--large .ibk-number-picker__input{width:140px}.ibk-number-picker--full{width:100%}.ibk-number-picker--full .ibk-number-picker__input{width:100%}";export{o as ibk_number_picker}