function smartHomeController(n,t,i,r,u,f,e,o,s){function c(){var t=[],n={};return n={text:"Download iOS App",target:"_blank",href:"https://itunes.apple.com/us/app/midco-smarthome/id992471602?mt=8",img:"account-img",src:"/Content/images/myAccount/icons/myAccount_Icons_cloudBW.png"},t.push(n),n={text:"Download Android App",target:"_blank",href:"https://play.google.com/store/apps/details?id=com.midco.smarthome&hl=en",img:"account-img",src:"/Content/images/myAccount/icons/myAccount_Icons_cloudBW.png"},t.push(n),t}var h=this;h.data={cleversafeBucketName:"app_smarthome",cleversafeFilePath:"SmartHome_Checklist",loading:!0,smartHomeObject:{accountId:"",activationCode:"",active:!1,businessPhone:null,contact:[],creator:"",emailAddress:"",emergencyContact:[],firstName:"",group:[],homePhone:"",internal:!1,mobilePhone:null,premise:{},primaryLanguage:null,product:"",property:[],readyForRMA:!1,source:"",specialInstruction:null,status:"",suspended:!1,user:[],errorMessage:null},comporiumEquipment:{},equipmentTypes:{camera:[],thermostat:[],lighting:[],doorLock:[],genericDevice:[],peripheral:[],sensor:[],cpe:[]},isSHAcctNull:!1,isSHWorkOrderOpen:!1,comporiumAcctUpdated:!1,comporiumAcctError:!1,isUpgradeable:!1,user:null,location:null,equipment:[],smartHomeMatrix:"0",installChecklistForm:null,helpfulLinks:[],hitError:!1,noChecklistFound:!1,serverError:!1,supportTopics:[],supportTopicPage:"HomeSecuritySupportLinks"};h.fetchChecklistFile=!1;h.init=function(){var n={};h.data.smartHomeMatrix=parseInt(t.myServices.matrix.smartHomeLevel);t.myServices&&(t.myServices.smartHome=h.data.smartHomeObject,n=t.myServices.smartHome,n.accountNumber=t.accountNumber);t.myServices||f.getAccountServices(t.accountNumber).then(function(n){t.myServices=n.data});t.smartHome&&(h.data.smartHomeObject=t.smartHome,h.data.equipmentTypes=t.smartHomeEquipmentTypes,h.completeLoad());t.smartHome||o.getAccountFromComporium(t.accountNumber).then(function(n){if(h.data.smartHomeObject=n.data,t.myServices.smartHome=h.data.smartHomeObject,angular.equals(n.data,{})||n.data===null||n.data===undefined){h.data.isSHAcctNull=!0;$("#smartHomeDocsDiv").attr("class","helpful-Links hidden");h.completeLoad();return}t.smartHome=h.data.smartHomeObject;h.completeLoad()},function(){h.data.loading=!1;h.data.serverError=!0});t.newSmartHomeInstalls||s.getWorkOrdersByFilterAsync(t.accountNumber,"").then(function(n){var t,i;if(n.data!==null&&n.data!==undefined&&n.length>0)for(t=0;t<n.length;t++)for(i=0;i<n[t].changes.length;i++)n[t].changes[i].workOrderChange==="SmartHome"&&(h.data.isSHWorkOrderOpen=!0)},function(){})};h.completeLoad=function(){parseInt(h.data.smartHomeMatrix)<4&&(h.data.isUpgradeable=!0);h.data.helpfulLinks=c();h.data.loading=!1;h.data.supportTopics=[{href:"/support/home-security/app-support/",target:"_self",text:"How to manage my system using my smartphone",title:"How to manage my system using my smartphone"},{href:"/support/home-security/alarms-and-armed-states/",target:"_self",text:"How to arm and disarm my system",title:"How to arm and disarm my system"},{href:"/support/home-security/rules-and-scenes/",target:"_self",text:"How to set rules and scenes",title:"How to set rules and scenes"},{href:"/support/home-security/equipment-support/security-cameras/",target:"_self",text:"How to manage my security cameras",title:"How to manage my security cameras"},{href:"/support/home-security/equipment-support/sensors-and-detectors/",target:"_self",text:"How to manage my sensors and detectors",title:"How to manage my sensors and detectors"},{href:"/support/home-security/manage-passcodes/",target:"_self",text:"How to manage my passcodes",title:"How to manage my passcodes"}];h.data.supportDataLoaded=!0};h.getChecklistPdf=function(n){n&&n.preventDefault();var i="";o.getcheckliststatus(t.accountNumber).then(function(n){if(n.data!==null&&n.data!==undefined)if(n.data.fileName!==null&&n.data.fileName!==""){i=n.data.fileName;var u=i;r.open("/api/smartHome/getchecklistfiles?accountNumber="+t.accountNumber+"&bucketName="+h.data.cleversafeBucketName+"&fileName="+u+"&filePath="+h.data.cleversafeFilePath);h.completeLoad();h.data.loading=!1}else h.data.loading=!1,window.location.href="/MyAccount/HomeSecurity/SmartHomeChecklist/";else return},function(){})}}function shChecklistFormController(n,t,i,r,u){function e(n){for(var i,u=window.location.search.substring(1),r=u.split("&"),t=0;t<r.length;t++)if(i=r[t].split("="),i[0]==n)return i[1];return!1}var f=this;f.data={accountNumber:null,accountNumberProvided:!1,customerFirstName:"",customerLastName:"",formReviewed:!1,loading:!0,items:{one:!1},customerSignature:null,customerDate:null,defaultEntryTime:null,defaultExitTime:null,htmlError:!1,isChecklistProcessing:!1,submissionError:!1,submissionIncomplete:!1,submissionSuccess:!1};f.item1="checkbox1";f.init=function(){f.data.accountNumber=e("accountnumber");f.data.accountNumber!=!1?f.data.accountNumberProvided=!0:f.data.accountNumber="";f.data.loading=!1};f.checkboxChanged=function(){};f.saveChecklistForm=function(){var r,s;if(f.data.isChecklistProcessing=!0,r=_.filter(f.data.items,function(n){return n==!1}),r.length>0){f.data.formReviewed=!1;f.data.submissionIncomplete=!0;return}if(f.data.accountNumber==""){f.data.formReviewed=!1;f.data.submissionIncomplete=!0;return}if(f.data.customerFirstName==""){f.data.formReviewed=!1;f.data.submissionIncomplete=!0;return}if(f.data.customerLastName==""){f.data.formReviewed=!1;f.data.submissionIncomplete=!0;return}f.data.submissionIncomplete=!1;f.data.formReviewed=!0;var n=new Date,h=String(n.getFullYear()),c=String(n.getDate()),t=n.getMonth()+1;t=String(t);var e=h+t+c,o={accountNumber:f.data.accountNumber,customerFirstName:f.data.customerFirstName,customerLastName:f.data.customerLastName,bucketName:"app_smarthome",fileName:f.data.accountNumber+"-"+e+".pdf",filePath:"SmartHome_Checklist",checklistReviewed:f.data.formReviewed},i=$("#SHChecklistInnerDiv").html();if(i===null||i===undefined){f.data.htmlError=!0;return}s={accountNumber:f.data.accountNumber,bucketName:"app_smarthome",fileAsBase64:"",fileAsString:i,fileName:o.accountNumber+"-"+e+".pdf",filePath:"SmartHome_Checklist/",firstName:f.data.customerFirstName,lastName:f.data.customerLastName,formReviewed:f.data.formReviewed};u.savechecklistform(o).then(function(n){n.data?u.putchecklistfile(s).then(function(){f.data.isChecklistProcessing=!1;f.data.submissionSuccess=!0;f.data.submissionError=!1},function(){f.data.isChecklistProcessing=!1;f.data.submissionError=!0;f.data.submissionSuccess=!1}):(f.data.isChecklistProcessing=!1,f.data.submissionError=!0,f.data.submissionSuccess=!1)},function(){f.data.isChecklistProcessing=!1;f.data.submissionError=!0;f.data.submissionSuccess=!1})}}angular.module("midcoComm").controller("quizModalController",["$http","$scope","api","smartHomeService","close","selectedPackageOnGetStarted","selectedEquipmentOnGetStarted","questions",function(n,t,i,r,u,f,e,o){function s(){f=null;e=null}function h(n){window.console&&console.log(n)}t.close=u;t.getStartedFormSubmitted=!1;t.sendingForm=!1;t.submitGetStartedFormClick=function(n){t.sendingForm=!0;r.submitGetStartedForm(n,f,e,o).then(function(){t.getStartedFormSubmitted=!0;$("html, body").animate({scrollTop:0},"slow")},h);s()}}]);angular.module("midcoComm").controller("questionnaireController",["smartHomeService",function(n){function f(i){t.loadingBundles=!0;n.getRecommendedBundles(i).then(h,e)}function o(){r=null;u=null}function s(r){r==="Premier Package"&&(t.hideEquipmentResults=!0,t.showTouchScreenQuestion=!0,i&&(t.recommended.touchScreenSelection=i,t.hideEquipmentResults=!1,i==="purchase"?n.setEquipmentToSelected(t.recommended.equipmentBundles[0].equipment,"SHTOUCH",!0):i==="lease"&&n.removeEquipmentFromList(t.recommended.equipmentBundles[0].equipment,"SHTOUCH")))}function h(i){var r,u;if(t.loadingBundles=!1,o(),t.recommended=i.data,t.hideEquipmentResults=!1,t.showTouchScreenQuestion=!1,i.data.equipmentBundles&&i.data.equipmentBundles.length>1)for(t.recommendedViewUrl="/Scripts/app/views/smartHome/recommendedBundles.html",t.allBundlesShown=!0,r=0;r<t.recommended.equipmentBundles.length;r++)t.recommended.equipmentBundles[r].visible||(t.allBundlesShown=!1),u=n.calculateTotalOfSelectedEquipment(t.recommended.equipmentBundles[r].equipment),t.recommended.equipmentBundles[r].selectedCost=u,t.recommended.equipmentBundles[r].totalUpfrontCost=u;else s(i.data.packageName),t.recommendedViewUrl="/Scripts/app/views/smartHome/recommendedPackage.html",t.recommended.equipmentBundles[0].selectedCost=n.calculateTotalOfSelectedEquipment(t.recommended.equipmentBundles[0].equipment),t.recommended.equipmentBundles[0].totalUpfrontCost=n.calculateTotalUpFrontCost(t.recommended.equipmentBundles[0].equipment,t.recommended.equipmentAllowance),t.allEquipmentShown=!1}function c(n){t.questions=n.data}function e(n){window.console&&console.log(n)}var t=this,r,u,i;t.getStartedFormSubmitted=!1;t.getStartedFormUrl="/Scripts/app/views/smartHome/getStartedForm.html";t.questionnaireViewUrl="/Scripts/app/views/smartHome/questionnaire.html";t.noImageAvailableUrl="../../Content/images/no-image-available.png";t.loadingBundles=!1;n.getQuestionnaireQuestions().then(c,e);t.selectGetStarted=function(i,f){t.getStartedFormSubmitted=!1;r=i;u=f;n.showModal(r,u,t.questions)};t.lifestyleOptionSelected=function(t){var i=n.validateBothQuestionsAreAnswered(t);i&&f(t)};t.securityInterestSelected=function(t,i){n.unselectOtherRadioButtonsOnChange(t.securityInterestQuestions,i);var r=n.validateBothQuestionsAreAnswered(t);r&&f(t)};t.touchscreenOptionChange=function(r){r==="lease"?n.removeEquipmentFromList(t.recommended.equipmentBundles[0].equipment,"SHTOUCH"):r==="purchase"&&n.setEquipmentToSelected(t.recommended.equipmentBundles[0].equipment,"SHTOUCH",!0);t.recommended.equipmentBundles[0].selectedCost=n.calculateTotalOfSelectedEquipment(t.recommended.equipmentBundles[0].equipment);t.recommended.equipmentBundles[0].totalUpfrontCost=n.calculateTotalUpFrontCost(t.recommended.equipmentBundles[0].equipment,t.recommended.equipmentAllowance);t.hideEquipmentResults=!1;i=r};t.selectedEquipmentChanged=function(t,i){t.selectedCost=n.calculateTotalOfSelectedEquipment(t.equipment);t.totalUpfrontCost=n.calculateTotalUpFrontCost(t.equipment,i)};t.showAllBundleOptions=function(n){for(var i=0;i<n.length;i++)n[i].visible=!0;t.allBundlesShown=!0};t.showAllEquipmentOptions=function(n){for(var i=0;i<n.length;i++)n[i].hidden||(n[i].visible=!0);t.allEquipmentShown=!0}}]).directive("errSrc",function(){return{link:function(n,t,i){t.bind("error",function(){i.src!=i.errSrc&&i.$set("src",i.errSrc)})}}});angular.module("midcoComm").controller("serviceAvailabilityController",["smartHomeService","$timeout",function(n,t){function f(){var t=n.getServiceableResultsFromCookie();t&&(i.serviceZipCode=t.zipCode&&parseInt(t.zipCode)||i.serviceZipCode,i.isServiceable=t.serviceable,i.serviceabilityChecked=!0)}function e(n){var t=n.keyCode||n.which;return t===13?(r(),!1):!0}function o(){r()}function r(){i.serviceabilityChecked=!1;n.checkIfZipCodeIsServiceable(i.serviceZipCode).then(s.bind(i),u.bind(i))}function s(n){n.data||u("No results");i.franchise=n.data.franchise;i.isServiceable=n.data.serviceable;i.zipCode=n.data.zipCode&&parseInt(n.data.zipCode);t(function(){i.serviceabilityChecked=!0},1e3)}function u(n){i.errors=n;i.isServiceable=!1;i.serviceabilityChecked=!0}var i=this;i.serviceZipCode=57103;i.franchise=101353;i.isServiceable=!1;i.serviceabilityChecked=!1;i.submitZipCode=o;i.keyPress=e;f()}]);angular.module("midcoComm").factory("smartHomeService",["$http","$q","$cookieStore","api","ModalService",function(n,t,i,r,u){function s(n){for(var i=0,t=0;t<n.length;t++)n[t].selected&&(i+=n[t].cost);return i}function h(n,t){for(var i=0,r=0;r<n.length;r++)n[r].selected&&(i+=n[r].cost);return i-=t,i>0?i:0}function c(t){return f.zipCode=t,n.get(r.smartHome.checkServiceableByZip+t).then(function(n){return f.franchise=n.data.franchise,f.serviceable=n.data.serviceable,i.put(e,f),n})}function l(){return n.get(r.smartHome.getQuestions)}function a(t){var u=d(t),i=o(),f=i&&i.franchise?i.franchise:101353;return n.post(r.smartHome.getRecommendedService,{franchise:f,answers:u})}function o(){return i.get(e)}function v(n,t){for(var i=0;i<n.length;i++)n[i].codeDetail===t&&(n[i].hidden=!0,n[i].selected=!1,n[i].visible=!1);return n}function y(n,t,i){for(var r=0;r<n.length;r++)n[r].codeDetail===t&&(n[r].selected=!0,n[r].required=i,n[r].visible=!0,n[r].hidden=!1);return n}function p(n,t,i){u.showModal({templateUrl:"/Scripts/app/views/smartHome/getStartedForm.html",controller:"quizModalController",inputs:{selectedPackageOnGetStarted:n,selectedEquipmentOnGetStarted:t,questions:i}})}function w(t,i,u,f){var e={name:t.name,address:t.address,city:t.city,zipCode:t.zipCode,emailAddress:t.emailAddress,phoneNumber:t.phoneNumber,preferredMethodOfContact:t.methodOfContact,bestTimeToCall:t.bestTimeToCall,otherComments:t.otherComments,packageName:i.packageName,selectedBundle:u,touchScreenSelection:i.touchScreenSelection,lifestyleAnswers:g(f),securityAnswer:nt(f),selectedCost:u.selectedCost,quotedUpFrontCost:u.totalUpfrontCost};return n.post(r.smartHome.postGetStartedForm,e)}function b(n,t){for(var i=0;i<n.length;i++)n[i].selected=n[i]==t}function k(n){for(var t,r=[],u=[],i=0;i<n.lifestyleOptions.length;i++)n.lifestyleOptions[i].selected&&r.push(n.lifestyleOptions[i]);for(t=0;t<n.securityInterestQuestions.length;t++)n.securityInterestQuestions[t].selected&&u.push(n.securityInterestQuestions[t]);return r.length>0&&u.length>0}function d(n){for(var t,r=[],i=0;i<n.lifestyleOptions.length;i++)n.lifestyleOptions[i].selected&&r.push(n.lifestyleOptions[i].value);for(t=0;t<n.securityInterestQuestions.length;t++)n.securityInterestQuestions[t].selected&&r.push(n.securityInterestQuestions[t].value);return r}function g(n){for(var i=[],t=0;t<n.lifestyleOptions.length;t++)n.lifestyleOptions[t].selected&&i.push(n.lifestyleOptions[t].value);return i}function nt(n){for(var t=0;t<n.securityInterestQuestions.length;t++)if(n.securityInterestQuestions[t].selected)return n.securityInterestQuestions[t].value}function tt(i){var u=t.defer();return n.get(r.smartHome.getAccountFromComporium+i).then(function(n){u.resolve(n)},function(n){u.reject(n)}),u.promise}function it(i){var u=t.defer();return n.get(r.smartHome.getEquipmentFromComporium+i).then(function(n){u.resolve(n.data)},function(n){u.reject(n)}),u.promise}function rt(i,u,f){var e=t.defer();return n.get(r.smartHome.getChecklistForm+"?fileName="+i+"&bucketName="+u+"&filePath="+f).then(function(n){e.resolve(n.data)},function(n){e.reject(n)}),e.promise}function ut(i,r,u){var f=t.defer();return n.get("/api/smartHome/getchecklistfiles?accountNumber="+i+"&bucketName="+r+"&filePath="+u).then(function(n){f.resolve(n)},function(n){f.reject(n)}),f.promise}function ft(i){var r=t.defer();return n.post("/api/smartHome/savechecklistform",i).then(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise}function et(i){var r=t.defer();return n.put("/api/smartHome/putchecklistfile",i).then(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise}function ot(i){var r=t.defer();return n.get("/api/smarthome/getcheckliststatus?accountNumber="+i).then(function(n){r.resolve(n)},function(n){r.reject(n)}),r.promise}var e="smarthomequiz.search",f={};return{calculateTotalOfSelectedEquipment:s,calculateTotalUpFrontCost:h,checkIfZipCodeIsServiceable:c,getQuestionnaireQuestions:l,getRecommendedBundles:a,getServiceableResultsFromCookie:o,removeEquipmentFromList:v,showModal:p,setEquipmentToSelected:y,submitGetStartedForm:w,unselectOtherRadioButtonsOnChange:b,validateBothQuestionsAreAnswered:k,getAccountFromComporium:tt,getEquipmentFromComporium:it,getChecklistForm:rt,getChecklistFiles:ut,savechecklistform:ft,getcheckliststatus:ot,putchecklistfile:et}}]);angular.module("midcoComm").controller("smartHomeController",smartHomeController);smartHomeController.$inject=["$scope","$localStorage","$http","$window","$location","servicesService","siteService","smartHomeService","workOrderService"];angular.module("midcoComm").controller("shChecklistFormController",shChecklistFormController);shChecklistFormController.$inject=["$localStorage","$http","$window","$scope","smartHomeService","siteService"]