define(["exports","./../../layoutmanager.js","./../../input/keyboard.js"],function(_exports,_layoutmanager,_keyboard){function onKeyDown(e){if("Enter"===_keyboard.default.normalizeKeyFromEvent(e))return e.preventDefault(),this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),!1}function onFocus(){var _this$closest;null!=(_this$closest=this.closest(".emby-toggle-label"))&&_this$closest.classList.add("emby-toggle-label-focus")}function onBlur(){var _this$closest2;null!=(_this$closest2=this.closest(".emby-toggle-label"))&&_this$closest2.classList.remove("emby-toggle-label-focus")}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/emby-elements/emby-toggle/emby-toggle.css"]);var EmbyToggle=function(_HTMLInputElement){babelHelpers.inherits(EmbyToggle,_HTMLInputElement);var _super=_createSuper(EmbyToggle);function EmbyToggle(){var _this;babelHelpers.classCallCheck(this,EmbyToggle),_this=_super.call(this);return babelHelpers.possibleConstructorReturn(_this,_this)}return babelHelpers.createClass(EmbyToggle,[{key:"connectedCallback",value:function(){!function(){this.setAttribute("role","switch"),this.classList.add("emby-toggle");var labelElement=this.parentNode,labelTextElement=(_layoutmanager.default.tv?(this.classList.add("emby-toggle-tv"),labelElement.classList.add("emby-toggle-label-tv")):this.classList.add("emby-toggle-focusring"),labelElement.classList.add("emby-toggle-label"),labelElement.querySelector(".toggleLabel"));labelTextElement||((labelTextElement=document.createElement("span")).innerHTML=this.getAttribute("label")||"",labelElement.appendChild(labelTextElement)),labelTextElement.classList.add("toggleLabel"),_layoutmanager.default.tv&&labelTextElement.classList.add("toggleLabel-tv"),(labelTextElement=labelElement.querySelector(".toggleSwitch"))||((labelTextElement=document.createElement("div")).classList.add("toggleSwitch"),labelElement.appendChild(labelTextElement)),this.addEventListener("keydown",onKeyDown),this.removeEventListener("focus",onFocus),this.addEventListener("focus",onFocus),this.removeEventListener("blur",onBlur),this.addEventListener("blur",onBlur)}.call(this)}},{key:"disconnectedCallback",value:function(){!function(){this.removeEventListener("keydown",onKeyDown)}.call(this)}}]),EmbyToggle}(babelHelpers.wrapNativeSuper(HTMLInputElement));customElements.define("emby-toggle",EmbyToggle,{extends:"input"}),_exports.default=EmbyToggle});