define(["browser","appSettings","events"],function(browser,appSettings,events){"use strict";function setLayout(self,layout,selectedLayout){layout===selectedLayout?(self[layout]=!0,document.documentElement.classList.add("layout-"+layout)):(self[layout]=!1,document.documentElement.classList.remove("layout-"+layout))}function LayoutManager(){var self=this;self.setLayout=function(layout,save){layout&&"auto"!==layout?(setLayout(self,"mobile",layout),setLayout(self,"tv",layout),setLayout(self,"desktop",layout),save!==!1&&appSettings.set("layout",layout)):(self.autoLayout(),save!==!1&&appSettings.set("layout","")),events.trigger(self,"modechange")},self.getSavedLayout=function(layout){return appSettings.get("layout")},self.autoLayout=function(){browser.mobile?self.setLayout("mobile",!1):browser.tv||browser.xboxOne?self.setLayout("tv",!1):self.setLayout(self.defaultLayout||"tv",!1)},self.init=function(){var saved=self.getSavedLayout();saved?self.setLayout(saved,!1):self.autoLayout()}}return new LayoutManager});