Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.108/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({dispatch:e,errorMessage:a,localizationMode:t,localizedValue:d,name:u,onBlur:f,parameter:m,parentFieldName:p,readOnly:g,selectedValidation:y,transformSelectedValidation:v,validations:b,visible:L}){const O=c(m,"startsFrom",d),_=c(m,"endsOn",d),D=E[y.name],h=(a,t)=>{const r={};"startsFrom"===a?(r.startsFrom=t,r.endsOn=_):"endsOn"===a&&(r.endsOn=t,r.startsFrom=O),e({payload:{parameter:r},type:s.EVENT_TYPES.SET_PARAMETER})},F=u+"_errorMessage",{formBuilder:N}=(0,n.useFormState)(),M=(0,l.useMemo)((()=>{const e=[];return new n.PagesVisitor(N.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}),[N.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:v(a)},type:s.EVENT_TYPES.CHANGE_SELECTED_VALIDATION})},options:b,value:y.name})),D.map((({label:e,name:a,options:r},n)=>{const{parameters:o,title:s,tooltip:d}="startsFrom"===a?{parameters:O,title:Liferay.Language.get("start-date"),tooltip:Liferay.Language.get("starts-from-tooltip")}:{parameters:_,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,s.toUpperCase()),l.default.createElement("hr",{className:"separator"})),l.default.createElement(i.default,{dateFieldOptions:M,eventType:a,label:e,name:u,onChange:h,options:r,parameters:o,readOnly:t||g,tooltip:d,visible:L}))})),l.default.createElement("label",{className:"lfr-ddm__validation-date-error-message",htmlFor:F},Liferay.Language.get("error-message"),l.default.createElement(r.ClayInput,{id:F,name:F,onBlur:f,onChange:a=>{e({payload:{errorMessage:a.target.value},type:s.EVENT_TYPES.CHANGE_ERROR_MESSAGE})},placeholder:Liferay.Language.get("this-field-is-invalid"),type:"text",value:d(a)})))};var r=t("@frontend-taglib-clay$clayui/form"),n=t("data-engine-js-components-web"),l=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=u();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=d(t("./DDMSelect")),i=d(t("./StartEndDate"));t("./ValidationDate.scss");var s=t("./validationReducer");function d(e){return e&&e.__esModule?e:{default:e}}function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}const e=Liferay.Language.get("custom-date"),f=Liferay.Language.get("ends-on"),m=Liferay.Language.get("response-date"),p=Liferay.Language.get("starts-from"),g={checked:!1,label:m,name:"responseDate",value:"responseDate"},y=(a,t)=>({label:a,name:t,options:[g,{checked:!1,label:e,name:"customDate",value:"customDate"}]});function c(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 E={dateRange:[y(p,"startsFrom"),y(f,"endsOn")],futureDates:[y(p,"startsFrom")],pastDates:[y(f,"endsOn")]}}}));
//# sourceMappingURL=ValidationDate.js.map