define(["exports","./../modules/loading/loading.js","./librarytree.js","./../modules/metadataeditor/metadataeditor.js","./../modules/viewmanager/baseview.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/common/globalize.js","./../list/list.js"],function(_exports,_loading,_librarytree,_metadataeditor,_baseview,_embyScroller,_globalize,_list){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!metadatamanager/metadatamanager.css"]);var idPrefix="category_";function refresh(instance,item){_loading.default.show(),instance.destroyCurrentContent(),item?item.Id.startsWith(idPrefix)?function(instance,item){require(["text!list/list.html"]).then(function(responses){var responses=responses[0],responses=(instance.contentElement.classList.remove("padded-top-page"),instance.contentElement.innerHTML=_globalize.default.translateDocument(responses),instance.contentElement.querySelector(".view")),params=(responses.classList.remove("view"),responses.classList.add("flex-grow","editorListView"),{setTitle:!1,defaultView:"datagrid"});switch(item.Id){case idPrefix+"videos":params.mediaTypes="Video";break;case idPrefix+"games":params.mediaTypes="Game";break;case idPrefix+"books":params.mediaTypes="Book";break;case idPrefix+"photos":params.mediaTypes="Photo";break;case idPrefix+"audio":params.mediaTypes="Audio";break;case idPrefix+"missingepisodes":params.type="missingepisodes"}instance.editor=new _list.default(responses,params),instance.editor.onResume({refresh:!0})})}(instance,item):(instance.contentElement.classList.add("padded-top-page"),instance.currentMetadataEditor&&(instance.currentMetadataEditor.destroy(),instance.currentMetadataEditor=null),instance.currentMetadataEditor=new _metadataeditor.default,instance.currentMetadataEditor.embed(instance.contentElement,item.Id,item.ServerId)):(instance.contentElement.innerHTML="",_loading.default.hide())}function MetadataManagerView(view,params){_baseview.default.apply(this,arguments);var libraryTreeElem=view.querySelector(".libraryTree"),instance=(this.libraryTree=new _librarytree.default({view:libraryTreeElem,apiClient:this.getApiClient()}),this);this.contentElement=view.querySelector(".editPageInnerContent"),libraryTreeElem.addEventListener("itemchange",function(event){event=event.detail.item;refresh(instance,event)})}Object.assign(MetadataManagerView.prototype,_baseview.default.prototype),MetadataManagerView.prototype.onResume=function(options){var _this$editor;_baseview.default.prototype.onResume.apply(this,arguments),options.refresh&&(refresh(this,this.libraryTree.getCurrentItem()),this.libraryTree.resume(options)),null!=(_this$editor=this.editor)&&_this$editor.onResume&&this.editor.onResume(options),null!=(_this$editor=this.currentMetadataEditor)&&_this$editor.resume(options)},MetadataManagerView.prototype.onPause=function(){var _this$editor2;_baseview.default.prototype.onResume.apply(this,arguments),null!=(_this$editor2=this.editor)&&_this$editor2.onPause&&this.editor.onPause(),null!=(_this$editor2=this.currentMetadataEditor)&&_this$editor2.pause()},MetadataManagerView.prototype.destroyCurrentContent=function(){var editor=this.editor;editor&&(editor.onPause&&editor.onPause(),editor.destroy&&editor.destroy(),this.editor=null)},MetadataManagerView.prototype.destroy=function(){_baseview.default.prototype.destroy.apply(this,arguments),this.destroyCurrentContent(),this.currentMetadataEditor&&(this.currentMetadataEditor.destroy(),this.currentMetadataEditor=null),this.libraryTree&&(this.libraryTree.destroy(),this.libraryTree=null),this.contentElement=null};_exports.default=MetadataManagerView});