Liferay.Loader.define("frontend-js-web@5.0.33/liferay/ItemSelectorDialog.es",["module","exports","require","frontend-js-metal-web$metal-component","frontend-js-metal-web$metal-state","./util/toggle_disabled"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=s(n("frontend-js-metal-web$metal-component")),l=n("frontend-js-metal-web$metal-state"),o=s(n("./util/toggle_disabled"));function s(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class e extends i.default{close(){Liferay.Util.getWindow(this.eventName).hide()}open(){this._currentItem=null,this._selectedItem=null;const e=this.eventName,t=this._getDialogConfig();Liferay.Util.selectEntity({dialog:a(a({},t),{on:{click:e=>{e.domEvent.preventDefault()},visibleChange:e=>{e.newVal||(this.selectedItem=this._selectedItem,this.emit("selectedItemChange",{selectedItem:this.selectedItem})),this.emit("visibleChange",{visible:e.newVal})}}}),eventName:e,id:e,stack:!this.zIndex,title:this.title,uri:this.url},this._onItemSelected.bind(this))}_getDialogConfig(){const e={constrain:!0,cssClass:this.dialogClasses,destroyOnHide:!0,modal:!0,zIndex:this.zIndex};if(!this.singleSelect){const t=[{cssClass:"btn-secondary close-modal",id:"cancelButton",label:this.buttonCancelLabel,on:{click:()=>{this.close()}}},{cssClass:"btn-primary",disabled:!0,id:"addButton",label:this.buttonAddLabel,on:{click:()=>{this._selectedItem=this._currentItem,this.close()}}}];e["toolbars.footer"]=t}return e}_onItemSelected(e){const t=e.data;if(this.singleSelect)this._selectedItem=t,this.close();else{const e=Liferay.Util.getWindow(this.eventName).getToolbar("footer").get("boundingBox").one("#addButton");(0,o.default)(e,!t)}this._currentItem=t}}e.STATE={buttonAddLabel:l.Config.string().value(Liferay.Language.get("add")),buttonCancelLabel:l.Config.string().value(Liferay.Language.get("cancel")),dialogClasses:l.Config.string(),eventName:l.Config.string().required(),selectedItem:l.Config.oneOfType([l.Config.object(),l.Config.arrayOf(l.Config.object())]),singleSelect:l.Config.bool().value(!1),title:l.Config.string().value(Liferay.Language.get("select-file")),url:l.Config.string().required(),zIndex:l.Config.number()};var d=e;t.default=d}}));
//# sourceMappingURL=ItemSelectorDialog.es.js.map