(self.webpackChunk=self.webpackChunk||[]).push([[6372],{86372:function(e,t,o){"use strict";o.r(t),o.d(t,{showEditor:function(){return C}}),o(23938),o(61013),o(63238),o(61418),o(5769);var n,l=o(83094),a=o(1115),i=o(6594),r=o(78695),c=o(6383),s=o(53754),d=(o(78066),o(21865),o(65219),o(30983),o(50447),o(56561),o(16589),o(93462),o(53913)),u=o(38440);function v(e){i.ZP.show();var t=l.ZP.parentWithClass(this,"dialog"),o=t.querySelector("#selectCollectionToAddTo").value,r=d.ZP.getApiClient(n);return o?function(e,t,o){var n=e.getUrl("Collections/".concat(o,"/Items"),{Ids:t.querySelector(".fldSelectedItemIds").value||""});e.ajax({type:"POST",url:n}).then((function(){i.ZP.hide(),t.submitted=!0,a.default.close(t),(0,u.Z)(s.ZP.translate("MessageItemsAdded"))}))}(r,t,o):function(e,t){var o=e.getUrl("Collections",{Name:t.querySelector("#txtNewCollectionName").value,IsLocked:!t.querySelector("#chkEnableInternetMetadata").checked,Ids:t.querySelector(".fldSelectedItemIds").value||""});e.ajax({type:"POST",url:o,dataType:"json"}).then((function(o){i.ZP.hide();var n=o.Id;t.submitted=!0,a.default.close(t),function(e,t){c.appRouter.showItem(t,e.serverId())}(e,n)}))}(r,t),e.preventDefault(),!1}function f(e){e.dispatchEvent(new CustomEvent("change",{}))}function m(e,t,n){Promise.resolve().then(o.bind(o,74227)).then((function(o){var l=n?"on":"off";o.centerFocus[l](e,t)}))}var C=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var o=t.items||{};n=t.serverId;var l={removeOnClose:!0,scrollY:!1};r.Z.tv?l.size="fullscreen":l.size="small";var c=a.default.createDialog(l);c.classList.add("formDialog");var u="";return u+='<div class="formDialogHeader">',u+='<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><span class="material-icons arrow_back"></span></button>',u+='<h3 class="formDialogHeaderTitle">',u+=o.length?s.ZP.translate("HeaderAddToCollection"):s.ZP.translate("NewCollection"),u+="</h3>",u+="</div>",u+=function(){var e="";return e+='<div class="formDialogContent smoothScrollY" style="padding-top:2em;">',e+='<div class="dialogContentInner dialog-content-centered">',e+='<form class="newCollectionForm" style="margin:auto;">',e+="<div>",e+=s.ZP.translate("NewCollectionHelp"),e+="</div>",e+='<div class="fldSelectCollection">',e+="<br/>",e+="<br/>",e+='<div class="selectContainer">',e+='<select is="emby-select" label="'.concat(s.ZP.translate("LabelCollection"),'" id="selectCollectionToAddTo" autofocus></select>'),e+="</div>",e+="</div>",e+='<div class="newCollectionInfo">',e+='<div class="inputContainer">',e+='<input is="emby-input" type="text" id="txtNewCollectionName" required="required" label="'.concat(s.ZP.translate("LabelName"),'" />'),e+='<div class="fieldDescription">'.concat(s.ZP.translate("NewCollectionNameExample"),"</div>"),e+="</div>",e+='<label class="checkboxContainer">',e+='<input is="emby-checkbox" type="checkbox" id="chkEnableInternetMetadata" />',e+="<span>".concat(s.ZP.translate("SearchForCollectionInternetMetadata"),"</span>"),e+="</label>",e+="</div>",e+='<div class="formDialogFooter">',e+='<button is="emby-button" type="submit" class="raised btnSubmit block formDialogFooterItem button-submit">'.concat(s.ZP.translate("ButtonOk"),"</button>"),e+="</div>",e+='<input type="hidden" class="fldSelectedItemIds" />',e+="</form>",(e+="</div>")+"</div>"}(),c.innerHTML=u,function(e,t){if(e.querySelector("#selectCollectionToAddTo").addEventListener("change",(function(){this.value?(e.querySelector(".newCollectionInfo").classList.add("hide"),e.querySelector("#txtNewCollectionName").removeAttribute("required")):(e.querySelector(".newCollectionInfo").classList.remove("hide"),e.querySelector("#txtNewCollectionName").setAttribute("required","required"))})),e.querySelector("form").addEventListener("submit",v),e.querySelector(".fldSelectedItemIds",e).value=t.join(","),t.length)e.querySelector(".fldSelectCollection").classList.remove("hide"),function(e){i.ZP.show();var t=e.querySelector("#selectCollectionToAddTo");e.querySelector(".newCollectionInfo").classList.add("hide");var o=d.ZP.getApiClient(n);o.getItems(o.getCurrentUserId(),{Recursive:!0,IncludeItemTypes:"BoxSet",SortBy:"SortName",EnableTotalRecordCount:!1}).then((function(e){var o="";o+='<option value="">'.concat(s.ZP.translate("OptionNew"),"</option>"),o+=e.Items.map((function(e){return'<option value="'.concat(e.Id,'">').concat(e.Name,"</option>")})),t.innerHTML=o,t.value="",f(t),i.ZP.hide()}))}(e);else{e.querySelector(".fldSelectCollection").classList.add("hide");var o=e.querySelector("#selectCollectionToAddTo");o.innerHTML="",o.value="",f(o)}}(c,o),c.querySelector(".btnCancel").addEventListener("click",(function(){a.default.close(c)})),r.Z.tv&&m(c.querySelector(".formDialogContent"),!1,!0),a.default.open(c).then((function(){return r.Z.tv&&m(c.querySelector(".formDialogContent"),!1,!1),c.submitted?Promise.resolve():Promise.reject()}))};t.default=C}}]);