import{r as s,c as t,h as i,g as h}from"./p-dfbe004d.js";import{b as e}from"./p-e05449ea.js";import{F as a}from"./p-8617d8eb.js";import{i as n,m as o}from"./p-df8994cd.js";import"./p-8415f806.js";import"./p-fd56940f.js";import"./p-9a7a47e8.js";const r=class{constructor(i){s(this,i),this.scChange=t(this,"scChange",7),this.scInput=t(this,"scInput",7),this.scFocus=t(this,"scFocus",7),this.scBlur=t(this,"scBlur",7),this.size="medium",this.value="",this.pill=!1,this.showLabel=!0,this.help="",this.clearable=!1,this.disabled=!1,this.readonly=!1,this.required=!1,this.invalid=!1}async reportValidity(){return this.input.shadowRoot.querySelector("input").reportValidity()}async triggerFocus(s){return this.input.triggerFocus(s)}async setCustomValidity(s){this.input.setCustomValidity(s)}async triggerBlur(){return this.input.blur()}handleFocusChange(){var s,t,i,h;this.hasFocus?null===(t=null===(s=this.input)||void 0===s?void 0:s.focus)||void 0===t||t.call(s):null===(h=null===(i=this.input)||void 0===i?void 0:i.blur)||void 0===h||h.call(i)}handleChange(){this.updateValue()}handleInput(){this.updateValue(),this.scInput.emit()}updateValue(){if(!this.input.shadowRoot.querySelector("input").checkValidity())return;const s=n(this.currencyCode)?parseFloat(this.input.value):(100*parseFloat(this.input.value)).toFixed(2);this.value=this.input.value?s.toString():""}componentDidLoad(){this.handleFocusChange(),this.formController=new a(this.el).addFormData(),document.addEventListener("wheel",(()=>{this.input.triggerBlur()}))}disconnectedCallback(){var s;null===(s=this.formController)||void 0===s||s.removeFormData()}render(){return i("sc-input",{exportparts:"base, input, form-control, label, help-text, prefix, suffix",size:this.size,label:this.label,showLabel:this.showLabel,help:this.help,ref:s=>this.input=s,type:"number",name:this.name,disabled:this.disabled,readonly:this.readonly,required:this.required,placeholder:this.placeholder,minlength:this.minlength,maxlength:this.maxlength,min:this.min?this.min/100:0,step:.001,max:this.max?this.max/100:null,autofocus:this.autofocus,inputmode:"decimal",onScChange:()=>this.handleChange(),onScInput:()=>this.handleInput(),onScBlur:()=>this.scBlur.emit(),onScFocus:()=>this.scFocus.emit(),value:o(parseFloat(this.value),this.currencyCode).toString()},i("span",{style:{opacity:"0.5"},slot:"prefix"},e(this.currencyCode)),i("span",{slot:"suffix"},i("slot",{name:"suffix"},this.showCode&&(null==this?void 0:this.currencyCode)&&i("span",{style:{opacity:"0.5"}},this.currencyCode.toUpperCase()))))}get el(){return h(this)}static get watchers(){return{hasFocus:["handleFocusChange"]}}};r.style=":host{display:block}";export{r as sc_price_input}