define(["exports","./browser.js","./../bower_components/emby-apiclient/events.js"],function(_exports,_browser,_events){var currentLayout;function setLayout(instance,layout,selectedLayout){layout===selectedLayout?(instance[layout]=!0,"tv"===layout&&document.documentElement.classList.add("layout-"+layout)):(instance[layout]=!1,"tv"===layout&&document.documentElement.classList.remove("layout-"+layout))}function LayoutManager(){}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_browser=babelHelpers.interopRequireDefault(_browser),_events=babelHelpers.interopRequireDefault(_events),LayoutManager.prototype.setLayout=function(layout,save){var changed;layout&&"auto"!==layout?(setLayout(this,"mobile",layout),setLayout(this,"tv",layout),setLayout(this,"desktop",layout),!1!==save&&this.appSettings.set("layout",layout),changed=currentLayout!==layout,currentLayout=layout,changed&&_events.default.trigger(this,"modechange")):(this.autoLayout(),!1!==save&&this.appSettings.set("layout",""))},LayoutManager.prototype.getSavedLayout=function(layout){return this.appSettings.get("layout")},LayoutManager.prototype.autoLayout=function(){this.setLayout(this.getDefaultLayout(),!1)},LayoutManager.prototype.getDefaultLayout=function(){if(this.getPlatformDefaultLayout){var result=this.getPlatformDefaultLayout();if(result)return result}return _browser.default.xboxOne||_browser.default.ps4||_browser.default.chromecast||_browser.default.netcast||_browser.default.operaTv?"tv":function(){var terms=["mobi","ipad","iphone","ipod","silk","kindle fire","opera mini"],lower=navigator.userAgent.toLowerCase();if(!lower.includes("android tv"))for(var i=0,length=terms.length;i<length;i++)if(lower.includes(terms[i]))return 1}()?"mobile":_browser.default.tv?"tv":function(){try{if(window.matchMedia("(pointer: coarse)").matches)return 1;if(window.matchMedia("(pointer: fine)").matches)return;if(window.matchMedia("(pointer: none)").matches)return}catch(err){console.log("error using window.matchMedia")}return"ontouchstart"in document.documentElement}()?"mobile":(navigator.userAgent||"").toLowerCase().includes("electron")||window.location.href.toString().toLowerCase().includes("tv.emby")?"tv":"desktop"},LayoutManager.prototype.init=function(appSettings){this.appSettings=appSettings;var saved=this.getSavedLayout();saved?this.setLayout(saved,!1):this.autoLayout()};var _default=new LayoutManager;_exports.default=_default});