define(["Ti/_/declare","Ti/_/event","Ti/_/lang","Ti/_/style","Ti/_/UI/Widget","Ti/UI","Ti/Filesystem"],function(t,e,i,r,n,s,o){var h=r.set,a=require.is,d=require.on,u=t(n,{domType:"img",onload:null,onerror:null,constructor:function(){this.domNode.ondragstart=function(){return!1}},_getContentSize:function(){return{width:this.domNode.width,height:this.domNode.height}},_preLayout:function(t,e,i,r){this.domNode.style.width="",this.domNode.style.height="";var n=this.domNode.width/this.domNode.height,o=this.__values__.properties,h=o.width,a=o.height;return i||r?i?r?(o.width=s.SIZE,o.height=s.SIZE):(o.width=e*n,o.height=e):(o.width=t,o.height=t/n):t/e>n?(o.width=e*n,o.height=e):(o.width=t,o.height=t/n),h!==o.width||a!==o.height},_imageRatio:1,properties:{src:{set:function(t){var r,n=this.domNode,s="none",o=i.hitch(this,function(t){e.off(r),this._triggerLayout(),this.onerror&&this.onerror(t)});return t&&(t=t.replace(/^(\/|\.\/)/,""),s="inherit",r=[d(n,"load",this,function(){n.style.width="",n.style.height="";var t=n.width/n.height;isNaN(t)&&(t=0===n.width?1:1/0),this._imageRatio=t,this._triggerLayout(),this.onload&&this.onload()}),d(n,"error",o),d(n,"abort",o)],n.src=require.cache(t)||t),h(n,"display",s),t}}}});return t("Ti.UI.ImageView",n,{_createImage:function(t,e,i){var r=a(t,"String")&&t.match(/^(.+)\:\/\//);switch(r&&~o.protocols.indexOf(r[1])&&(t=o.getFile(t)),t&&t.declaredClass){case"Ti.Filesystem.File":t=t.read();case"Ti.Blob":t=t.toString()}return new u({onload:e,onerror:i,src:t})},_defaultWidth:s.SIZE,_defaultHeight:s.SIZE,_slideshowCount:0,_setSlideshowInterval:function(){var t=this,e=t._images;clearInterval(this._slideshowTimer),this._slideshowTimer=setInterval(function(){var i=!1;return h(e[t._currentIndex].domNode,"display","none"),t.reverse?0===--t._currentIndex&&(t._currentIndex=t.images.length-1,i=!0):++t._currentIndex===t.images.length&&(t._currentIndex=0,i=!0),h(e[t._currentIndex].domNode,"display","inherit"),t.repeatCount&&i&&++t._slideshowCount===t.repeatCount?void t.stop():void t.fireEvent("change",{index:t._currentIndex})},this.duration)},start:function(){this._images&&(this._setState(0,1),this._slideshowCount=0,this._setSlideshowInterval(),this.fireEvent("start"))},stop:function(){var t=this._images;if(t){if(clearInterval(this._slideshowTimer),t.length){var e=0;this.reverse&&(e=t.length-1),this._currentIndex&&h(t[this._currentIndex].domNode,"display","none"),h(t[e].domNode,"display","inherit"),this._currentIndex=e}this._setState(0,0),this.fireEvent("stop")}},pause:function(){this._images&&(clearInterval(this._slideshowTimer),this._setState(1,0),this.fireEvent("pause"))},resume:function(){this._images&&(this._setSlideshowInterval(),this._setState(0,1))},_setState:function(t,e){var i=this.__values__.constants;i.paused=!!t,i.animating=!!e},constants:{animating:!1,paused:!1},properties:{duration:{set:function(t){return Math.max(30,t)},value:200},image:{set:function(t){return this._removeAllChildren(),this._images=void 0,this._add(this._createImage(t,function(){this.fireEvent("load",{state:"image"})},function(t){this.fireEvent("error",t)})),t}},images:{set:function(t){var e=void 0,i=0,r=0;return this._removeAllChildren(),a(t,"Array")&&(e=[],t.forEach(function(n){var s=this._createImage(n,function(){!r&&++i===t.length&&this.fireEvent("load",{state:"image"})},function(t){r||(r=1)&&this.fireEvent("error",t)});h(s.domNode,"display","none"),e.push(s),this._add(s)},this)),this._images=e,t},post:function(){this.stop()}},repeatCount:0,reverse:!1}})});