"use strict";define(["app","Controller","../../../../../components/Overlay/Views/OverlayView","../../../../../components/Confirmation/Controllers/ConfirmationController","../Views/BlockedClinicPopupView","utils"],function(e,g,c,b,d,a){var f=g.extend({callback:null,origClinicExceptions:null,clinics:null,initialize:function(h){g.prototype.initialize.apply(this,arguments);_.extend(this,h);this.overlayView=new c({framework:e.instance().FrontendFramework(),css:{display:"none","background-color":"rgba(27,27,27,0.9)","z-index":"100"}});this.confirmationController=new b();this.blockedClinicPopupView=new d({parent:this.overlayView});},open:function(h,i){this.callback=i;this.origClinicExceptions=h.clinicExceptions;this.clinics=h.clinics;this.view=this.blockedClinicPopupView.render(h);this.listenTo(this.view,"view:setinfoForsave",_.bind(this.setinfoForsave,this));this.listenTo(this.view,"view:confirm",_.bind(function(j){this.confirmationController.open({parent:this.view,header:j.header,message:j.message},_.bind(function(k){if(k===true){if(j.action==="cancel"){this.blockedClinicPopupView.cancelConfirmed();}if(j.action==="save"){this.blockedClinicPopupView.saveConfirmed();}}},this));},this));},close:function(){this.overlayView.close();},setinfoForsave:function(i){if(this.callback){var j=a.getSupportedLanguages();var h=[];_.each(i.blockedClIds,_.bind(function(k){var m=$.grep(this.clinics,function(n){return n.Id.toString()===k.toString();});var l=m.length?m[0].Description:"";_.each(j,_.bind(function(q){var o=[];if(this.origClinicExceptions){o=_.filter(this.origClinicExceptions,function(r){return r.ClinicId.toString()===k.toString()&&r.LangCd===q;});}var p=o.length?o[0].Message:a.getDefaultExceptionMessage(q);var n={clinicId:k.toString(),clinicDesc:l,LangCd:q,excpMessage:p};h.push(n);},this));},this));this.callback.apply(this,[h]);}}});return f;});