angular.module("mystrom.adapter.controllers",["ionic"]).controller("AdapterController",["$scope","$rootScope","tileService","$ionicHistory","$state","stateService","settingsService",function(t,o,e,i,n,a,d){t.isAndroid=ionic.Platform.isAndroid(),t.isIPad=ionic.Platform.isIPad(),t.proceed=function(){e.activeTile={name:"",deviceTypeId:"mgcSLEtmj6kDNvb2"},ionic.Platform.isIPad()?a.goState("index.tiles",{},!1):a.goState("tiles",{},!0)},t.scan=function(t){window.cordova&&void 0===t?d.setAnalytics("AddUndetectedSwitchAlreadyConnected"):window.cordova&&"again"===t?d.setAnalytics("AddUndetectedSwitchSearchAgain"):window.cordova&&"finish"===t&&(a.setWizardCompleted(!0),d.setAnalytics("AddSwitchFinishWizard")),ionic.Platform.isIPad()?a.goState("index.adapter-scan",{},!1):a.goState("adapter-scan",{},!0)},t.goBack=function(){var o=i.backView();return t.isIPad&&(_.isNull(o)||"index.adapter-scan"!==o.stateName)?(a.modal.hide(),void a.goState("index",{},!1)):void i.goBack()},t.goToMainIndex=function(){a.modal.hide(),a.goState("index",{},!1)},t.goToMain=function(t){window.cordova&&"cancel"===t&&d.setAnalytics("AddUndetectedSwitchCancle"),a.modal.hide(),i.nextViewOptions({historyRoot:!0}),i.clearCache(),a.goState("index",{},!1),i.clearHistory()},t.goToCancel=function(){ionic.Platform.isIPad()?a.goState("index.adapter-cancel-add",{},!1):a.goState("adapter-cancel-add",{},!0)},t.goToConnect=function(){ionic.Platform.isIPad()&&a.goState("index",{},!1)},t.goToFound=function(){ionic.Platform.isIPad()&&a.goState("index.adapter-found",{},!1)},t.goToPlugIn=function(){window.cordova&&d.setAnalytics("AddSwitchNotConnected"),ionic.Platform.isIPad()?a.goState("index.adapter-plug-in",{},!1):a.goState("adapter-plug-in",{},!0)},t.goToStarxxx=function(){ionic.Platform.isIPad()?a.goState("index.adapter-starxxx",{},!1):a.goState("adapter-starxxx",{},!0)},t.goToSwitch2s=function(){ionic.Platform.isIPad()?a.goState("index.adapter-switch-2s",{},!1):a.goState("adapter-switch-2s",{},!0)},t.goToSettingsInfo=function(){ionic.Platform.isIPad()?a.goState("index.adapter-settings-info",{},!1):a.goState("adapter-settings-info",{},!0)}}]).controller("ScanController",["$rootScope","$scope","$timeout","$state","adapterService","tileService","stateService","$ionicHistory","settingsService","$translate",function(t,o,e,i,n,a,d,c,r,s){o.isAndroid=ionic.Platform.isAndroid();var l,g;o.$on("$ionicView.enter",function(){window.cordova?(console.log("Scanning"),l=o.$on("new_devices",function(t,o){if(t.preventDefault(),o.length>0)if(s("New").then(function(t){a.generateAddTiles(o,t)}),n.activationCode=o[0],ionic.Platform.isIPad())d.goState("index.adapter-found",{},!1);else{var i=ionic.Platform.isAndroid()?2e3:0;e(function(){d.goState("adapter-found",{},!0)},i)}else window.cordova&&d.getWizardCompleted()&&r.setAnalytics("AddSwitchFinishWizardSwitchNotFound"),ionic.Platform.isIPad()?d.goState("index.adapter-not-found",{},!1):d.goState("adapter-not-found",{},!0)}),n.startDeviceDiscovery(),g=e(function(){l(),window.cordova&&d.getWizardCompleted()&&r.setAnalytics("AddSwitchFinishWizardSwitchNotFound"),ionic.Platform.isIPad()?d.goState("index.adapter-not-found",{},!1):d.goState("adapter-not-found",{},!0)},15e3)):g=e(function(){n.activationCode="D8V4-YK3M-LVVC",s("New").then(function(t){a.generateAddTiles([n.activationCode],t)}),d.goState("adapter-found",{},!0)},1e3)}),o.$on("$ionicView.beforeLeave",function(){void 0!==l&&l(),e.cancel(g),window.cordova&&n.endDeviceDiscovery()}),o.goBack=function(){void 0!==l&&l(),e.cancel(g),c.goBack()}}]);