Liferay.Loader.define("commerce-product-options-web@4.0.34/js/add_cp_option",["module","exports","require","commerce-frontend-js/ServiceProvider/index","commerce-frontend-js/utilities/modals/index","commerce-frontend-js/utilities/slugify","frontend-js-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({defaultLanguageId:e,editOptionURL:t,namespace:n,windowState:d}){const u=document.getElementById(n+"fm"),c=u.querySelector("#"+n+"key"),l=u.querySelector("#"+n+"name");l.addEventListener("input",(0,a.debounce)((()=>{c.value=(0,i.default)(l.value)}),200));const f=r.default.AdminCatalogAPI("v1");Liferay.provide(window,n+"apiSubmit",(()=>{o.isSubmitting();const r={fieldType:"",key:"",name:{}};r.fieldType=document.getElementById(n+"DDMFormFieldTypeName").value,r.key=c.value,r.name[e]=l.value,f.createOption(r).then((e=>{const n=new Liferay.PortletURL.createURL(t);n.setParameter("p_p_state",d),n.setParameter("cpOptionId",e.id),o.closeAndRedirect(n)})).catch(o.onSubmitFail)}),["liferay-portlet-url"])};var r=u(n("commerce-frontend-js/ServiceProvider/index")),o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=r?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n("commerce-frontend-js/utilities/modals/index")),i=u(n("commerce-frontend-js/utilities/slugify")),a=n("frontend-js-web");function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function u(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=add_cp_option.js.map