Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ObjectValidation/Conditions",["module","exports","require","@frontend-taglib-clay$clayui/alert","liferay!object-web$codemirror/mode/groovy/groovy","@liferay/object-js-components-web","frontend-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.Conditions=function Conditions({creationLanguageId:t,disabled:a,errors:i,learnResources:u,objectFields:d,objectValidationRuleElements:c,setValues:s,values:f}){var g;const[y,b]=(0,o.useState)(""),p=f.engine,m={content:Liferay.Language.get("use-the-expression-builder-to-define-the-format-of-a-valid-object-entry"),symbol:"question-circle-full"};let L;L="groovy"===p?Liferay.Language.get("insert-a-groovy-script-to-define-your-validation"):"ddm"===p?Liferay.Language.get("add-elements-from-the-sidebar-to-define-your-validation"):"";const v=(0,o.useMemo)((()=>{if(d)return(0,n.filterArrayByQuery)({array:d,query:y,str:"label"})}),[d,y]);return o.default.createElement(o.default.Fragment,null,o.default.createElement(r.default,{className:"lfr-objects__side-panel-content-container",displayType:"info",title:"".concat(Liferay.Language.get("info"),":")},Liferay.Language.get("create-validations-using-expressions")," ",o.default.createElement(l.LearnResourcesContext.Provider,{value:u},o.default.createElement(l.LearnMessage,{className:"alert-link",resource:"object-web",resourceKey:"general"}))),o.default.createElement(n.Card,{title:f.engineLabel,tooltip:"ddm"===p?m:null},o.default.createElement(n.CodeEditor,{error:i.script,mode:p,onChange:(e,t)=>s({lineCount:t,script:e}),placeholder:L,readOnly:a,sidebarElements:c,value:null!==(g=f.script)&&void 0!==g?g:""})),o.default.createElement(n.Card,{title:Liferay.Language.get("error-message")},o.default.createElement(n.InputLocalized,{disabled:a,error:i.errorLabel,label:Liferay.Language.get("message"),onChange:e=>s({errorLabel:e}),placeholder:Liferay.Language.get("add-an-error-message"),required:!0,translations:f.errorLabel}),Liferay.FeatureFlags["LPS-187846"]&&o.default.createElement(o.default.Fragment,null,o.default.createElement(n.RadioField,{defaultValue:f.outputType,inline:!1,label:Liferay.Language.get("output-validation-type"),onChange:e=>{s("fullValidation"!==e?{outputType:e}:{objectValidationRuleSettings:[],outputType:e})},options:e,popover:{alignPosition:"top",content:Liferay.Language.get("map-the-error-message-to-be-displayed-next-to-the-validated-field"),header:Liferay.Language.get("message-location")}}),"partialValidation"===f.outputType&&o.default.createElement(n.AutoComplete,{emptyStateMessage:Liferay.Language.get("no-fields-were-found"),error:i.outputType,items:null!=v?v:[],label:Liferay.Language.get("fields"),onChangeQuery:b,onSelectItem:e=>{s({objectValidationRuleSettings:[{name:"objectFieldExternalReferenceCode",value:e.externalReferenceCode}]})},query:y,required:!0,value:(()=>{var e;if(null===(e=f.objectValidationRuleSettings)||void 0===e?void 0:e.length){const[e]=f.objectValidationRuleSettings,a=d.find((t=>t.externalReferenceCode===e.value));return(0,n.getLocalizableLabel)(t,null==a?void 0:a.label,null==a?void 0:a.name)}return""})()},(({label:e,name:a})=>o.default.createElement("div",{className:"d-flex justify-content-between"},o.default.createElement("div",null,(0,n.getLocalizableLabel)(t,e,a))))))))};var r=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("@frontend-taglib-clay$clayui/alert"));a("liferay!object-web$codemirror/mode/groovy/groovy");var n=a("@liferay/object-js-components-web"),l=a("frontend-js-components-web"),o=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 a={},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(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}const e=[{label:Liferay.Language.get("full-validation-form-summary"),value:"fullValidation"},{label:Liferay.Language.get("partial-validation-inline-field"),value:"partialValidation"}]}}));
//# sourceMappingURL=Conditions.js.map