Liferay.Loader.define("item-selector-taglib@5.2.21/repository_entry_browser/js/ItemSelectorRepositoryEntryBrowser",["module","exports","require","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../item_selector_preview/js/ItemSelectorPreview.es","../../item_selector_uploader/js/SingleFileUploader"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let{closeCaption:t,itemSelectedEventName:r,portletNamespace:c,rootNode:i,uploaderEnabled:s=!0}=e,p=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["closeCaption","itemSelectedEventName","portletNamespace","rootNode","uploaderEnabled"]);const[f,d]=(0,o.useState)(!1),[m,y]=(0,o.useState)(0),v=(0,o.useRef)(),b=(0,o.useCallback)((({returntype:e,value:t})=>{Liferay.Util.getOpener().Liferay.fire(r,{returnType:e,value:t})}),[r]);return(0,o.useEffect)((()=>{const e=[];e.push((0,n.delegate)(document.querySelector(i),"click",".item-preview",(e=>{b(e.delegateTarget.dataset)})));const t=Array.from(document.querySelectorAll("#p_p_id".concat(c," .item-preview-editable"))).map((e=>e.dataset)),r=Array.from(document.querySelectorAll("#p_p_id".concat(c," .icon-view")));return t.length&&t.length===r.length&&(v.current||(v.current=t),r.forEach(((t,r)=>{const n=e=>{e.preventDefault(),e.stopPropagation(),y(r),d(!0)};t.addEventListener("click",n),e.push({dispose:()=>{t.removeEventListener("click",n)}})}))),()=>{e.forEach((({dispose:e})=>e()))}}),[b,c,i]),o.default.createElement(o.default.Fragment,null,s&&o.default.createElement(a.default,u({closeCaption:t,itemSelectedEventName:r},p)),f&&o.default.createElement("div",{className:"item-selector-preview-container"},o.default.createElement(l.default,{currentIndex:m,handleClose:()=>d(!1),handleSelectedItem:b,headerTitle:t,itemSelectedEventName:r,items:v.current})))};var n=r("frontend-js-web"),o=(i(r("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var l=n?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(r,o,l):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),l=i(r("../../item_selector_preview/js/ItemSelectorPreview.es")),a=i(r("../../item_selector_uploader/js/SingleFileUploader"));function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}}}));
//# sourceMappingURL=ItemSelectorRepositoryEntryBrowser.js.map