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