define(["exports","./../../dom.js","./../emby-button/emby-button.js"],function(_exports,_dom,_embyButton){function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function setState(button,expanded,animate){var collapseContent=button.parentNode.querySelector(".collapseContent");(collapseContent.expanded=expanded)?function(button,elem,animate){elem.classList.remove("hide"),elem.classList.add("expanded"),elem.style.height="auto",animate&&(animate=elem.offsetHeight+"px",elem.style.height="0",elem.offsetHeight,elem.style.height=animate,setTimeout(function(){elem.classList.contains("expanded")?elem.classList.remove("hide"):elem.classList.add("hide"),elem.style.height="auto"},400)),button.querySelector("i").classList.add("emby-collapse-expandIconExpanded"),button.classList.remove("emby-collapsible-button-collapsed")}(button,collapseContent,!1!==animate):function(button,elem){elem.style.height=elem.offsetHeight+"px",elem.offsetHeight,elem.classList.remove("expanded"),elem.style.height="0",setTimeout(function(){button.classList.add("emby-collapsible-button-collapsed"),elem.classList.contains("expanded")?elem.classList.remove("hide"):elem.classList.add("hide")},400),button.querySelector("i").classList.remove("emby-collapse-expandIconExpanded")}(button,collapseContent)}function onButtonClick(e,animate){var collapseContent=this.parentNode.querySelector(".collapseContent");setState(this,!0!==collapseContent.expanded,animate)}function onInit(){this.hasInit||(this.hasInit=!0)}function onButtonDragEnter(e){this.parentNode.querySelector(".collapseContent").expanded||this.click()}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/emby-elements/emby-collapse/emby-collapse.css"]);var EmbyCollapse=function(_HTMLDivElement){function EmbyCollapse(){babelHelpers.classCallCheck(this,EmbyCollapse),t=this,o=EmbyCollapse,o=babelHelpers.getPrototypeOf(o);var o,e,t=o=babelHelpers.possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],babelHelpers.getPrototypeOf(t).constructor):o.apply(t,e));return onInit.call(t),babelHelpers.possibleConstructorReturn(o,t)}return babelHelpers.inherits(EmbyCollapse,_HTMLDivElement),babelHelpers.createClass(EmbyCollapse,[{key:"expand",value:function(){var button=this.querySelector(".emby-collapsible-button");button&&setState(button,!0,!1)}},{key:"collapse",value:function(){var button=this.querySelector(".emby-collapsible-button");button&&setState(button,!1,!1)}},{key:"connectedCallback",value:function(){onInit.call(this),function(){var collapseContent,headerClass,expandIconClass,buttonClass;this.classList.contains("emby-collapse")||(this.classList.add("emby-collapse"),(collapseContent=this.querySelector(".collapseContent"))&&collapseContent.classList.add("hide"),collapseContent=this.getAttribute("title"),this.title="",headerClass=((this.getAttribute("data-headerclass")||"")+" emby-collapsible-title").trim(),buttonClass=((this.getAttribute("data-buttonclass")||"")+" emby-collapsible-button").trim(),expandIconClass="emby-collapse-expandIcon","rtl"===document.dir&&(expandIconClass+=" emby-collapse-expandIcon-rtl"),expandIconClass=((this.getAttribute("data-iconclass")||"")+" md-icon "+expandIconClass).trim(),this.insertAdjacentHTML("afterbegin",'<button is="emby-button" type="button" on-click="toggleExpand" class="'+buttonClass+'"><h3 class="'+headerClass+'" title="'+collapseContent+'" aria-label="'+collapseContent+'">'+collapseContent+'</h3><i class="'+expandIconClass+'">expand_more</i></button>'),(buttonClass=this.querySelector(".emby-collapsible-button")).addEventListener("click",onButtonClick),"true"===this.getAttribute("data-expanded")?setState(buttonClass,!0,!1):buttonClass.classList.add("emby-collapsible-button-collapsed"),_dom.default.addEventListener(buttonClass,"dragenter",onButtonDragEnter,{passive:!0}))}.call(this)}}])}(babelHelpers.wrapNativeSuper(HTMLDivElement));customElements.define("emby-collapse",EmbyCollapse,{extends:"div"}),_exports.default=EmbyCollapse});