define(["exports","./../../input/keyboard.js"],function(_exports,_keyboard){function onKeyDown(e){var key=_keyboard.default.normalizeKeyFromEvent(e);if("Enter"===key)return e.preventDefault(),e.repeat?void 0:(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","css!!tv|modules/emby-elements/emby-toggle/emby-toggle_nontv.css","css!tv|modules/emby-elements/emby-toggle/emby-toggle_tv.css"]);var EmbyToggle=function(_HTMLInputElement){function EmbyToggle(){var _this;_this=_HTMLInputElement.call(this)||this;return babelHelpers.possibleConstructorReturn(_this,_this)}return babelHelpers.inherits(EmbyToggle,_HTMLInputElement),babelHelpers.createClass(EmbyToggle,[{key:"connectedCallback",value:function(){!function(){this.setAttribute("role","switch"),this.classList.add("emby-toggle");var labelElement=this.parentNode,labelTextElement=(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"),this.classList.contains("toggle-inline")||labelTextElement.classList.add("flex-grow"),(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)}}])}(babelHelpers.wrapNativeSuper(HTMLInputElement));customElements.define("emby-toggle",EmbyToggle,{extends:"input"}),_exports.default=EmbyToggle});