Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.108/Validation/CustomDate",["module","exports","require","liferay!frontend-js-react-web$react","./CustomDate.scss","./DDMQuantity","./DDMSelect","./SelectDateType"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));a("./CustomDate.scss");var r=i(a("./DDMQuantity")),l=i(a("./DDMSelect")),u=i(a("./SelectDateType"));function i(e){return e&&e.__esModule?e:{default:e}}function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function c(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function d(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?c(Object(a),!0).forEach((function(t){f(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):c(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function f(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const e="plus",y="minus",p="customDate",g=[{label:Liferay.Language.get("plus"),value:e},{label:Liferay.Language.get("minus"),value:y}],m=[{label:Liferay.Language.get("days"),value:"days"},{label:Liferay.Language.get("months"),value:"months"},{label:Liferay.Language.get("years"),value:"years"}];var s=({dateFieldOptions:t,eventType:a,onChange:i,options:o,parameters:c,readOnly:f})=>{const[s,b]=(0,n.useState)(c);function O(e){Object.entries(e).some((([e,t])=>s[e]!==t))&&(b((t=>d(d({},t),e))),i(e))}return(0,n.useEffect)((()=>{b(c)}),[c]),n.default.createElement(n.default.Fragment,null,n.default.createElement(u.default,{dateFieldName:s.dateFieldName,dateFieldOptions:t,label:Liferay.Language.get("date"),onChange:(e,t)=>O({date:e,dateFieldName:t}),options:o.filter((({name:e})=>e!==p)),type:s.date}),n.default.createElement("div",{className:"lfr-ddm__custom-date"},n.default.createElement(l.default,{className:"lfr_ddm__custom-date-select",disabled:f,label:Liferay.Language.get("operation"),name:"selectedOperation_".concat(a),onChange:({target:{value:t}})=>{if(t!==(s.quantity<0?y:e)){const e=-1*s.quantity;O({dateFieldName:s.dateFieldName,quantity:e})}},options:g,value:s.quantity<0?y:e}),n.default.createElement(r.default,{label:Liferay.Language.get("quantity"),name:"inputedQuantity_".concat(a),onQuantityChange:e=>{O({dateFieldName:s.dateFieldName,quantity:s.quantity<0?-1*e:e})},readOnly:f,value:Math.abs(s.quantity)}),n.default.createElement(l.default,{className:"lfr_ddm__custom-date-select",disabled:f,label:Liferay.Language.get("unit"),name:"selectedUnit_".concat(a),onChange:({target:{value:e}})=>O({dateFieldName:s.dateFieldName,unit:e}),options:m,value:s.unit})))};t.default=s}}));
//# sourceMappingURL=CustomDate.js.map