angular.module("mystrom.settings",[]).factory("settingsService",["$q","stateService","$rootScope",function(e,t,i){var s=function(){var e,t=window.innerWidth,i=document.getElementsByTagName("link")[2],s=i.sheet?i.sheet:i.styleSheet;e=768>t?.09*(t-2)/2:992>t?.09*(t-3)/3:1200>t?.09*(t-4)/4:.09*(t-6)/6,s.insertRule("h2 {font-size: "+e+"px !important;}",s.cssRules.length),s.insertRule("h1 {font-size: "+2.75*e+"px !important;}",s.cssRules.length)},n=function(){return e(function(e,t){cordova.exec(e,t,"mystrom","backToMain",[])})},g=function(t){return e(function(e,i){cordova.exec(e,i,"mystrom","getLocalizables",t)})},o=function(t){return console.log("Analytics: ",t),e(function(e,i){cordova.exec(e,i,"mystrom","setAnalytics",[t])})},a=function(){return e(function(e,t){cordova.exec(e,t,"mystrom","loadingCompleted",[])})},r=function(){return e(function(e,s){try{cordova.exec(function(s){console.log("Open settings for: %s",s),""!==s&&(i.$broadcast("clear_active_tiles"),window.cordova&&o("Settings"),ionic.Platform.isIPad()?($ionicHistory.clearCache(),$timeout(function(){t.goState("ipad-settings.scheduler",{tile:s},!0)},500)):t.goState("tile-settings",{tile:s},!0)),e(s)},s,"mystrom","getDeviceId",[])}catch(n){e("")}})};return{setHeaderSize:s,goBack:n,getLocalizables:g,setAnalytics:o,loadingCompleted:a,getSettingsId:r}}]).factory("api",["$http","loginService",function(e,t){var i=function(i,s){var n=t.getAuthData();return s=s||{},s.params=s.params||{},s.headers=s.headers||{},s.headers["Auth-Token"]=s.params.authToken||n.authToken,e.get(i,s).then(function(e){return e})},s=function(i,s,n){var g=t.getAuthData();return n=n||{},n.params=n.params||{},n.headers=n.headers||{},n.headers["Auth-Token"]=n.params.authToken||g.authToken,e.post(i,s,n).then(function(e){return e})},n="https://mystrom.ch/api/";return{get:i,post:s,baseURL:n}}]).factory("loadingService",["$translate","$ionicLoading","$ionicPopup",function(e,t,i){var s,n,g=function(i){e("Please_wait_").then(function(e){s=t.show({template:'<div style="min-width: 100px;">'+e+"</div><br><ion-spinner></ion-spinner>",animation:"fade-in",showBackdrop:i||!1,maxWidth:200,showDelay:0})})},o=function(){t.hide(),e(["ConnectionError","CheckConnection","OK"]).then(function(e){_.isUndefined(n)&&(n=i.alert({title:e.ConnectionError+"<br><br>"+e.CheckConnection,cssClass:"custom-popup",okText:e.OK}).then(function(){n=void 0}))})},a=function(){t.hide()};return{showLoading:g,hideLoading:a,showError:o}}]).factory("filesService",function(){var e=["img/settings/alarms.svg","img/settings/devicesettings.svg","img/settings/graphs.svg","img/settings/help.svg","img/settings/powersavers.svg","img/settings/scheduler.svg","img/settings/vacation.svg","img/tiles/add.svg","img/tiles/buy.svg","img/tiles/camera-security.svg","img/tiles/charging.svg","img/tiles/coffee-machine.svg","img/tiles/cooking-device.svg","img/tiles/energy-bulb.svg","img/tiles/fridge.svg","img/tiles/game-console.svg","img/tiles/heater-aircon.svg","img/tiles/lamp-bulb.svg","img/tiles/mystromsettings.svg","img/tiles/new-adapter.svg","img/tiles/pc-mac.svg","img/tiles/printer.svg","img/tiles/radio.svg","img/tiles/set-top-box.svg","img/tiles/stereo.svg","img/tiles/switch-adapter.svg","img/tiles/telefone.svg","img/tiles/tv.svg","img/tiles/washing-machine.svg","img/tiles/water-pump.svg","img/tiles/xmas-tree.svg","img/6oclock.svg","img/alert.svg","img/cockpit.svg","img/continue.svg","img/exclamation.svg","img/graph.svg","img/ionic.png","img/midnight.svg","img/new.svg","img/noon.svg","img/scan.svg","img/settings_small.svg","img/new-firmware.svg","img/process.svg","img/downloading.svg","img/sprite.svg","img/starxxx.png","img/starxxx2x.png","img/success.svg","img/switch-2s.svg","img/switch-led.svg","img/trash.svg"];return{files:e}});