define(["Ti/_/declare","Ti/_/dom","Ti/_/event","Ti/_/style","Ti/_/lang","Ti/_/UI/FontWidget","Ti/UI"],function(t,e,i,n,s,r,u){var a=require.on,o=n.set;return t("Ti._.UI.TextBox",r,{constructor:function(){this._addEventModifier(["click","singletap","blur","change","focus","return"],function(t){t.value=this._getInternalText()})},_initTextBox:function(t){this._field=t;var e=null,n="";this._addStyleableDomNode(this._setFocusNode(t)),a(t,"keydown",this,function(e){return this.editable?void(13===e.keyCode&&(this.suppressReturn&&(i.stop(e),t.blur()),this.fireEvent("return"))):(i.stop(e),!1)}),a(t,"keypress",this,function(){setTimeout(s.hitch(this,function(){this._capitalize()}))}),a(t,"focus",this,function(){this.fireEvent("focus"),e=setInterval(s.hitch(this,function(){var e=t.value;(n.length!==e.length||n!==e)&&(this.fireEvent("change"),n=e)}),200)}),a(t,"blur",this,function(){clearInterval(e),this.fireEvent("blur")}),this.autocorrect=!0},_setInternalText:function(t){this._field.value!==t&&(this._field.value=t,this._capitalize())},_getInternalText:function(){return this._field.value},_updateInternalText:function(){this._setInternalText(this._getInternalText())},_capitalize:function(){var t="off",e=this._field;switch(this.autocapitalization){case u.TEXT_AUTOCAPITALIZATION_ALL:e.value=e.value.toUpperCase();break;case u.TEXT_AUTOCAPITALIZATION_SENTENCES:t="on"}this._field.autocapitalize=t},blur:function(){this._field.blur()},focus:function(){this._field.focus()},hasText:function(){return!!this._field.value},properties:{autocapitalization:{value:u.TEXT_AUTOCAPITALIZATION_SENTENCES,post:"_capitalize"},autocorrect:{post:function(t){this._field.autocorrect=t?"on":"off"}},editable:!0,maxLength:{set:function(t){return t=Math.max(0|t,0),e.attr[t>0?"set":"remove"](this._field,"maxlength",t),t}},returnKeyType:function(){return u.RETURNKEY_DEFAULT},suppressReturn:!0,textAlign:{post:function(t){o(this._field,"textAlign",/(center|right)/.test(t)?t:"left")}},value:{get:function(){return this._getInternalText()},post:"_setInternalText",value:""}}})});