var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,a){function u(t){try{o(r.next(t))}catch(t){a(t)}}function s(t){try{o(r["throw"](t))}catch(t){a(t)}}function o(t){t.done?n(t.value):i(t.value).then(u,s)}o((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,u;return u={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(t){return function(e){return o([t,e])}}function o(u){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(a=u[0]&2?i["return"]:u[0]?i["throw"]||((a=i["return"])&&a.call(i),0):i.next)&&!(a=a.call(i,u[1])).done)return a;if(i=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:n.label++;return{value:u[1],done:false};case 5:n.label++;i=u[1];u=[0];continue;case 7:u=n.ops.pop();n.trys.pop();continue;default:if(!(a=n.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){n.label=u[1];break}if(u[0]===6&&n.label<a[1]){n.label=a[1];a=u;break}if(a&&n.label<a[2]){n.label=a[2];n.ops.push(u);break}if(a[2])n.ops.pop();n.trys.pop();continue}u=e.call(t,n)}catch(t){u=[6,t];i=0}finally{r=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-e3f64949.js";var balInputCss="@-webkit-keyframes spinAround{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes spinAround{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.sc-bal-input-h{display:block}";var Input=function(){function t(t){var e=this;registerInstance(this,t);this.balInput=createEvent(this,"balInput",7);this.balBlur=createEvent(this,"balBlur",7);this.balClick=createEvent(this,"balClick",7);this.balKeyPress=createEvent(this,"balKeyPress",7);this.balFocus=createEvent(this,"balFocus",7);this.inputId="bal-in-"+InputIds++;this.name=this.inputId;this.type="text";this.placeholder="";this.balTabindex=0;this.maxLength=undefined;this.minLength=undefined;this.inverted=false;this.readonly=false;this.disabled=false;this.clickable=false;this.autoComplete=false;this.numberKeyboard=false;this.onlyNumbers=false;this.value="";this.onInput=function(t){var n;var r=t.target&&((n=t.target)===null||n===void 0?void 0:n.value);if(e.onlyNumbers){r=e.filterNumbers(r)}if(e.value!==r){e.value=r;e.balInput.emit(e.value)}else{e.updateInputValue()}}}t.prototype.valueChanged=function(){this.updateInputValue()};t.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.inputEl.focus();return[2]}))}))};t.prototype.render=function(){var t=this;return h(Host,null,h("input",{class:{input:true,"is-inverted":this.inverted,clickable:this.clickable},autoComplete:this.autoComplete?"on":"off",id:this.inputId,type:this.type,placeholder:this.placeholder,name:this.name,value:this.value,tabindex:this.balTabindex,disabled:this.disabled,readonly:this.readonly,pattern:this.numberKeyboard?"[0-9]*":"",maxLength:this.maxLength,minLength:this.minLength,onInput:function(e){return t.onInput(e)},onBlur:function(e){return t.balBlur.emit(e)},onClick:function(e){return t.balClick.emit(e)},onKeyPress:function(e){return t.balKeyPress.emit(e)},onFocus:function(e){return t.balFocus.emit(e)},ref:function(e){return t.inputEl=e}}))};t.prototype.updateInputValue=function(){if(this.inputEl.value!==this.value){this.inputEl.value=this.value}};t.prototype.filterNumbers=function(t){if(t&&typeof t==="string"){t=t.replace(/[^\d]/g,"")}return t};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{value:["valueChanged"]}},enumerable:false,configurable:true});return t}();var InputIds=0;Input.style=balInputCss;export{Input as bal_input};