define(['jquery'],function($){'use strict';$.widget('mage.trimInput',{options:{cache:{}},_create:function(){this.options.cache.input=$(this.element);this._bind();},_bind:function(){if(this.options.cache.input.length){this._on(this.options.cache.input,{'change':this._trimInput,'keyup':this._trimInput,'paste':this._trimInput});}},_trimInput:function(){var caretStart,caretEnd,input;caretStart=this.options.cache.input.get(0).selectionStart;caretEnd=this.options.cache.input.get(0).selectionEnd;input=this._getInputValue().trim();this.options.cache.input.val(input);if(caretStart!==null&&caretEnd!==null){this.options.cache.input.get(0).setSelectionRange(caretStart,caretEnd);}},_getInputValue:function(){return this.options.cache.input.val();}});return $.mage.trimInput;});