define(["exports","./../dialoghelper/dialoghelper.js","./../layoutmanager.js","./../common/globalize.js","./../emby-elements/emby-input/emby-input.js","./../emby-elements/emby-select/emby-select.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-button/paper-icon-button-light.js","./../emby-elements/emby-scroller/emby-scroller.js","./../emby-elements/emby-dialogclosebutton/emby-dialogclosebutton.js"],function(_exports,_dialoghelper,_layoutmanager,_globalize,_embyInput,_embySelect,_embyButton,_paperIconButtonLight,_embyScroller,_embyDialogclosebutton){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["formDialogStyle"]);_exports.default={show:function(person){return require(["text!modules/metadataeditor/personeditor.template.html"]).then(function(responses){var responses=responses[0],dialogOptions={removeOnClose:!0,scrollY:!1},dlg=(_layoutmanager.default.tv?dialogOptions.size="fullscreen":dialogOptions.size="medium-tall",_dialoghelper.default.createDialog(dialogOptions)),dialogOptions=(dlg.classList.add("formDialog"),""),submitted=!1;return dialogOptions+=_globalize.default.translateDocument(responses,"sharedcomponents"),dlg.innerHTML=dialogOptions,person.Name?dlg.querySelector(".formDialogHeaderTitle").innerHTML=_globalize.default.translate("Edit"):dlg.querySelector(".formDialogHeaderTitle").innerHTML=_globalize.default.translate("Add"),dlg.querySelector(".txtPersonName",dlg).value=person.Name||"",dlg.querySelector(".selectPersonType",dlg).value=person.Type||"",dlg.querySelector(".txtPersonRole",dlg).value=person.Role||"",dlg.querySelector(".selectPersonType").addEventListener("change",function(e){"Actor"===this.value?dlg.querySelector(".fldRole").classList.remove("hide"):dlg.querySelector(".fldRole").classList.add("hide")}),dlg.querySelector("form").addEventListener("submit",function(e){return submitted=!0,person.Name=dlg.querySelector(".txtPersonName",dlg).value,person.Type=dlg.querySelector(".selectPersonType",dlg).value,person.Role=dlg.querySelector(".txtPersonRole",dlg).value||null,_dialoghelper.default.close(dlg),e.preventDefault(),!1}),dlg.querySelector(".selectPersonType").dispatchEvent(new CustomEvent("change",{bubbles:!0})),_dialoghelper.default.open(dlg).then(function(){return submitted?Promise.resolve(person):Promise.reject()})})}}});