define(["Marionette","base/BaseCtrl","./views/CarouselView","events/EventManager"],function(a,b,c,d){var e=a.Controller.extend({initialize:function(a){b.applyMixin.call(this),this.ctrls={},this.views={},this.eventManager=new d(this),this.region=a.region,this.settingsModel=a.settingsModel,this.lessonsModel=a.lessonsModel,this.eventManager.bindKeyboardEvents(),this.eventManager.addKeyVisible(this.cid),_.bindAll(this,"onLessonsModelIndexChanged","_onKeyLeft","_onKeyRight"),this._bindEvents()},_bindEvents:function(){this.eventManager.bind(CtrlEvents.LessonsModel.indexChanged,this.onLessonsModelIndexChanged,this),this.eventManager.bind("key:left",this._onKeyLeft,this),this.eventManager.bind("key:right",this._onKeyRight,this)},_unbindEvents:function(){this.eventManager&&this.eventManager.unbindAll(),this.eventManager&&this.eventManager.unbindKeyboardEvents()},_onKeyLeft:function(a){a.cid===this.cid&&this.lessonsModel.prevLesson()},_onKeyRight:function(a){a.cid===this.cid&&this.lessonsModel.nextLesson()},onLessonsModelIndexChanged:function(){if(this.views.carouselView){var a=!0;this.views.carouselView.showPanelIndexRequest(this.lessonsModel.getLessonIndex(),a)}},show:function(){this.views.carouselView=new c({lessonsModel:this.lessonsModel,settingsModel:this.settingsModel}),this.views.carouselView.on("request:hitMe",this.onClickHitMe,this),this.views.carouselView.on("request:language",this.onClickLanguage,this),this.region.show(this.views.carouselView)},onClickHitMe:function(a){this.lessonsModel.hitMe(a)},onClickLanguage:function(a){window.dictionary.setLearningLanguage(a),this.views.carouselView.render()},getCurrentPanelElement:function(){return this.views.carouselView?this.views.carouselView.getCurrentPanelElement():null}});return _.extend(e.prototype,b),e});