define(["exports","./../emby-apiclient/connectionmanager.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-input/emby-input.js","./../emby-elements/emby-select/emby-select.js","./../emby-elements/emby-scroller/emby-scroller.js","./../emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../dialoghelper/dialoghelper.js","./../layoutmanager.js","./../dom.js","./../common/globalize.js","./../focusmanager.js","./../listview/listview.js"],function(_exports,_connectionmanager,_embyButton,_embyInput,_embySelect,_embyScroller,_embyItemscontainer,_dialoghelper,_layoutmanager,_dom,_globalize,_focusmanager,_listview){function ItemAccessDialog(){}function onAllItemsContainerUpgraded(){this.itemsContainer.resume({refresh:!0}).then(function(){var dlg=this.dlg;_focusmanager.default.autoFocus(dlg,{skipIfNotEnabled:!0})}.bind(this))}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons","formDialogStyle"]),ItemAccessDialog.prototype.getItems=function(query){var options=this.options,options=_connectionmanager.default.getApiClient(options.item);return query=Object.assign({},query),options.getUsersQueryResult(query)},ItemAccessDialog.prototype.getCardOptions=function(items){var fields=["Name"];return fields.push("ProductionYear"),fields.push("ParentName"),{enableDefaultIcon:!0,action:"custom",fields:fields,draggable:!1,multiSelect:!1,contextMenu:!1,hoverPlayButton:!1,imageSize:"small",enableUserDataButtons:!1,mediaInfo:!1}},ItemAccessDialog.prototype.getListOptions=function(items){return{renderer:_listview.default,options:this.getCardOptions(items),virtualScrollLayout:"vertical-list"}},ItemAccessDialog.prototype.show=function(options){var dialogOptions={removeOnClose:!0,scrollY:!1,autoFocus:!1},dialogOptions=(_layoutmanager.default.tv?dialogOptions.size="fullscreen":dialogOptions.size="small",_dialoghelper.default.createDialog(dialogOptions)),html=(dialogOptions.classList.add("formDialog"),""),html=(html=(html=(html=(html=(html+='<div class="formDialogHeader formDialogHeader-clear">')+'<button is="paper-icon-button-light" class="btnCancel hide-mouse-idle-tv" tabindex="-1"><i class="md-icon autortl">&#xE5C4;</i></button>'+'<h2 class="formDialogHeaderTitle">')+_globalize.default.translate("HeaderManageAccess"))+"</h2>"+"</div>")+function(){var html="",scrollerStyle="width:100%;";return _layoutmanager.default.tv&&(scrollerStyle+="max-width:70ch;"),html+'<div class="formDialogContent flex flex-direction-column align-items-center" style="overflow:hidden;">'+('<div is="emby-scroller" data-horizontal="false" data-forcescrollbar="true" data-focusscroll="true" class="flex flex-grow virtualScrollerScrollContainer" style="'+scrollerStyle+'">')+'<div class="scrollSlider dialog-content-centered padded-left padded-right padded-top flex-grow">'+'<div is="emby-itemscontainer" data-virtualscrolllayout="vertical-grid" class="itemsContainer allItemsContainer itemsContainer-defaultCardSize vertical-wrap padded-bottom-page">'+"</div>"+"</div>"+"</div>"+"</div>"}(),dialogOptions.innerHTML=html,this.dlg=dialogOptions,this.options=options,dialogOptions.querySelector(".btnCancel").addEventListener("click",function(){this.result=null,this.closeDialog()}.bind(this)),dialogOptions.querySelector(".allItemsContainer")),options=(html.addEventListener("action-null",function(e){}.bind(this)),html.fetchData=this.getItems.bind(this),html.getListOptions=this.getListOptions.bind(this),this.itemsContainer=html,dialogOptions.addEventListener("opened",function(){var itemsContainer=this.itemsContainer;itemsContainer.resume?onAllItemsContainerUpgraded.call(this):_dom.default.addEventListener(itemsContainer,"upgraded",onAllItemsContainerUpgraded.bind(this),{once:!0})}.bind(this)),function(){return this.result?(this.cleanup(),Promise.resolve()):(this.cleanup(),Promise.reject())}.bind(this));return _dialoghelper.default.open(dialogOptions).then(options,options)},ItemAccessDialog.prototype.closeDialog=function(){var dlg=this.dlg;dlg&&_dialoghelper.default.close(dlg)},ItemAccessDialog.prototype.cleanup=function(){this.listName=null,this.options=null,this.dlg=null,this.itemsContainer=null},_exports.default=ItemAccessDialog});