Liferay.Loader.define("@liferay/commerce-product-definitions-web@7.0.115/js/InstanceDetails",["module","exports","require","commerce-frontend-js/components/autocomplete/entry"],(function(e,t,n){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default(e){(function handleCPInstanceOptions({namespace:e}){const t=document.getElementById("".concat(e,"fm"));t.addEventListener("submit",(function saveInstance(){const n=document.getElementById("".concat(e,"cpInstanceOptions")),c=document.getElementById("".concat(e,"optionsContainer"));if(!c)return submitForm(t);const a=c.querySelectorAll("[data-sku-contributor=true]");a&&(n.value=JSON.stringify(Array.from(a).map((e=>({key:e.name||e.querySelector("input:checked").name,value:[e.value?e.value.split("[$SEPARATOR$]")[1]:e.querySelector("input:checked").value.split("[$SEPARATOR$]")[1]]}))))),submitForm(t)}))})(e),function handlePriceOnApplication({namespace:e}){const t=document.getElementById("".concat(e,"priceOnApplication"));if(t){const n=[document.getElementById("".concat(e,"price")),document.getElementById("".concat(e,"cost")),document.getElementById("".concat(e,"promoPrice"))];t.addEventListener("change",(e=>{n.forEach((t=>{t&&(e.target.checked?(t.disabled=!0,t.classList.add("disabled")):(t.disabled=!1,t.classList.remove("disabled")))}))}))}}(e),function handlePublish({WORKFLOW_ACTION_PUBLISH:e,namespace:t}){document.getElementById("".concat(t,"publishButton")).addEventListener("click",(()=>{const n=document.getElementById("".concat(t,"workflowAction"));n&&(n.value=e)}))}(e),function handleReplacements({initialLabel:e,initialValue:t,namespace:n}){const a=document.getElementById("".concat(n,"discontinued")),o=document.getElementById("".concat(n,"discontinuedDate")),d=document.getElementById("".concat(n,"replacementAutocompleteWrapper"));a.addEventListener("change",(e=>{e.target.checked?(o.disabled=!1,o.classList.remove("disabled"),d.classList.remove("d-none")):(o.disabled=!0,o.classList.add("disabled"),d.classList.add("d-none"))})),(0,c.default)("autocomplete","autocomplete-root",{apiUrl:"/o/headless-commerce-admin-catalog/v1.0/skus",initialLabel:e,initialValue:t,inputId:"replacementId",inputName:"".concat(n,"replacementCPInstanceId"),itemsKey:"id",itemsLabel:"sku",showDeleteButton:!0})}(e)};var c=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n("commerce-frontend-js/components/autocomplete/entry"))}));
//# sourceMappingURL=InstanceDetails.js.map