Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.128/Validation/ValidationDate",["module","exports","require","@frontend-taglib-clay$clayui/form","data-engine-js-components-web","liferay!frontend-js-react-web$react","./DDMSelect","./StartEndDate","./ValidationDate.scss","./validationReducer"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=function ValidationDate({dispatch:e,errorMessage:a,localizationMode:t,localizedValue:s,name:u,onBlur:c,parameter:f,parentFieldName:p,readOnly:g,selectedValidation:y,transformSelectedValidation:E,validations:v,visible:_}){const b=getFromParameter(f,"startsFrom",s),L=getFromParameter(f,"endsOn",s),D=m[y.name],handleChangeParameters=(a,t)=>{const r={};"startsFrom"===a?(r.startsFrom=t,r.endsOn=L):"endsOn"===a&&(r.endsOn=t,r.startsFrom=b),e({payload:{parameter:r},type:d.EVENT_TYPES.SET_PARAMETER})},O=u+"_errorMessage",{formBuilder:h}=(0,n.useFormState)(),F=(0,l.useMemo)((()=>{const e=[];return new n.PagesVisitor(h.pages).mapFields(((a,t,r,n,...l)=>{a.repeatable||"date"!==a.type||a.fieldName===p||l.some((({repeatable:e})=>e))||e.push({checked:!1,label:a.label,name:a.fieldName,value:a.fieldName})}),!0,!0),e}),[h.pages,p]);return l.default.createElement(l.default.Fragment,null,l.default.createElement("div",{className:"ddm-form-field-type__validation-date-accepted-date"},l.default.createElement(o.default,{className:"lfr-ddm__validation-date-select",disabled:g||t,label:Liferay.Language.get("accepted-date"),name:"selectedValidation",onChange:({target:{value:a}})=>{e({payload:{selectedValidation:E(a)},type:d.EVENT_TYPES.CHANGE_SELECTED_VALIDATION})},options:v,value:y.name})),D.map((({label:e,name:a,options:r},n)=>{const{parameters:o,title:d,tooltip:s}="startsFrom"===a?{parameters:b,title:Liferay.Language.get("start-date"),tooltip:Liferay.Language.get("starts-from-tooltip")}:{parameters:L,title:Liferay.Language.get("end-date"),tooltip:Liferay.Language.get("ends-on-tooltip")};return l.default.createElement(l.default.Fragment,{key:n},D.length>1&&l.default.createElement(l.default.Fragment,null,l.default.createElement("label",null,d.toUpperCase()),l.default.createElement("hr",{className:"separator"})),l.default.createElement(i.default,{dateFieldOptions:F,eventType:a,label:e,name:u,onChange:handleChangeParameters,options:r,parameters:o,readOnly:t||g,tooltip:s,visible:_}))})),l.default.createElement("label",{className:"lfr-ddm__validation-date-error-message",htmlFor:O},Liferay.Language.get("error-message"),l.default.createElement(r.ClayInput,{id:O,name:O,onBlur:c,onChange:a=>{e({payload:{errorMessage:a.target.value},type:d.EVENT_TYPES.CHANGE_ERROR_MESSAGE})},placeholder:Liferay.Language.get("this-field-is-invalid"),type:"text",value:s(a)})))};var r=t("@frontend-taglib-clay$clayui/form"),n=t("data-engine-js-components-web"),l=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=_getRequireWildcardCache();if(a&&a.has(e))return a.get(e);var t={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(t,n,l):t[n]=e[n]}t.default=e,a&&a.set(e,t);return t}(t("liferay!frontend-js-react-web$react")),o=_interopRequireDefault(t("./DDMSelect")),i=_interopRequireDefault(t("./StartEndDate"));t("./ValidationDate.scss");var d=t("./validationReducer");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}const e=Liferay.Language.get("custom-date"),s=Liferay.Language.get("ends-on"),u=Liferay.Language.get("response-date"),c=Liferay.Language.get("starts-from"),f={checked:!1,label:u,name:"responseDate",value:"responseDate"},getDateOptionsByType=(a,t)=>({label:a,name:t,options:[f,{checked:!1,label:e,name:"customDate",value:"customDate"}]});function getFromParameter(e,a,t){var r,n;let l=null!==(r=t(e))&&void 0!==r?r:e;if(l&&"string"==typeof l)try{l=JSON.parse(l)}catch(e){}return null===(n=l)||void 0===n?void 0:n[a]}const m={dateRange:[getDateOptionsByType(c,"startsFrom"),getDateOptionsByType(s,"endsOn")],futureDates:[getDateOptionsByType(c,"startsFrom")],pastDates:[getDateOptionsByType(s,"endsOn")]}}}));
//# sourceMappingURL=ValidationDate.js.map