Liferay.Loader.define("@liferay/commerce-product-asset-categories-web@4.0.37/js/EditAssetCategoryCPDisplayLayout",["module","exports","require","@liferay/frontend-icons-web","frontend-js-web"],(function(e,t,n){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({assetCategory:e,categorySelectorUrl:t,itemSelectorUrl:n,portletNamespace:l,title:o}){const s=document.getElementById("".concat(l,"displayPageItemRemove")),i=document.getElementById("".concat(l,"displayPageNameInput")),d=document.getElementById("".concat(l,"pagesContainerInput")),r=document.getElementById("".concat(l,"chooseDisplayPage"));null==r||r.addEventListener("click",(()=>{(0,c.openSelectionModal)({onSelect:e=>{e&&i&&d&&(d.value=e.id,i.innerHTML=e.name,null==s||s.classList.remove("hide"))},selectEventName:"selectDisplayPage",title:Liferay.Language.get("select-category-display-page"),url:n})})),s&&i&&d&&s.addEventListener("click",(()=>{i.innerHTML=Liferay.Language.get("none"),d.value="",s.classList.add("hide")}));function u(e,t){const n=document.createElement("span");n.classList.add("label","label-dismissible","label-secondary"),n.setAttribute("id",e);const c=document.createElement("span");c.classList.add("label-item","label-item-expand");const l=document.createElement("a");l.setAttribute("href","#"+e),l.innerText=t,c.appendChild(l);const o=document.createElement("span");o.classList.add("label-item","label-item-after");const s=document.createElement("button");s.classList.add("close"),s.setAttribute("aria-label","Close"),s.setAttribute("type","button"),s.addEventListener("click",g);const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("lexicon-icon","lexicon-icon-times"),i.setAttribute("focusable",!1),i.setAttribute("role","presentation");const d=document.createElementNS("http://www.w3.org/2000/svg","use");return d.setAttribute("href","".concat((0,a.getSpritemap)(),"#times")),i.appendChild(d),s.appendChild(i),o.appendChild(s),n.appendChild(c),n.appendChild(o),n}const m=document.getElementById("".concat(l,"categoriesContainer"));function g(e){const t=e.currentTarget;null==m||m.removeChild(t.parentElement.parentElement)}const p=document.getElementById("".concat(l,"classPK")),y=null==e?void 0:e.categoryId;if(y){const e=u("category-".concat(y),o);null==m||m.appendChild(e),p.value=y}const b=document.getElementById("".concat(l,"selectCategories"));null==b||b.addEventListener("click",(()=>{(0,c.openSelectionModal)({buttonAddLabel:Liferay.Language.get("done"),multiple:!0,onSelect:e=>{e&&Object.keys(e).forEach((t=>{const n=e[t];if(n.unchecked&&!m)return;const a=m.children;if(a.length)for(let e=0;e<a.length;e++)m.removeChild(a.item(e));delete e[t];const c=u("category-".concat(n.categoryId),n.value);m.appendChild(c),p.value=n.categoryId}))},selectEventName:"".concat(l,"selectCategory"),title:Liferay.Language.get("select-category-display-page"),url:t})}))};var a=n("@liferay/frontend-icons-web"),c=n("frontend-js-web")}));
//# sourceMappingURL=EditAssetCategoryCPDisplayLayout.js.map