Liferay.Loader.define("data-engine-taglib@3.3.53/data_layout_builder/js/components/rules/RuleItem",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/label","@frontend-taglib-clay$clayui/panel","liferay!frontend-js-react-web$classnames","data-engine-js-components-web","frontend-js-web","liferay!frontend-js-react-web$react","../../utils/dataDefinition.es","../../utils/lang.es","../drop-down/DropDown.es"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=function RuleItem({loc:a,onDeleteRule:t,onEditRule:r,rule:y}){const{actions:p,conditions:m,logicalOperator:L,name:b}=y,{dataDefinition:w}=(0,o.useFormState)({schema:["dataDefinition"]}),D=(0,f.getLocalizedValue)(w.defaultLanguageId,b),E=[{action:()=>r(a),name:Liferay.Language.get("edit")},{action:()=>{(0,u.openConfirmModal)({message:Liferay.Language.get("are-you-sure-you-want-to-delete-this"),onConfirm:e=>{e&&t(a)}})},name:Liferay.Language.get("delete")}];return d.default.createElement("div",{className:"rule-list__panel"},d.default.createElement(i.default,{className:"collapsable-panel panel-unstyled",collapsable:!0,collapseClassNames:"panel-body",displayTitle:D,displayType:"secondary"},d.default.createElement(l.default,{displayType:"unstyled",onClick:()=>r(a)},d.default.createElement(Text,{capitalize:!0},Liferay.Language.get("if")),m.map((({operands:e,operator:a},t)=>{const[l,i]=e,r=null==i?void 0:i.value;return d.default.createElement(d.default.Fragment,{key:t},d.default.createElement(Text,{lowercase:!0},Liferay.Language.get("field")),d.default.createElement(n.default,{displayType:"success"},(0,s.getFieldLabel)(w,l.value)),d.default.createElement(n.default,{displayType:"secondary"},g[a]||a),r&&d.default.createElement(n.default,{displayType:"info"},(()=>{if((0,s.getDataDefinitionField)(w,r))return(0,s.getFieldLabel)(w,r);const e=(0,s.getDataDefinitionField)(w,l.value);if(e){var a;return(0,s.getOptionLabel)(null===(a=e.customProperties)||void 0===a?void 0:a.options,r,w.defaultLanguageId)||r}return r})()),t+1!==m.length&&d.default.createElement(n.default,{displayType:"warning"},L))})),p.map((({action:a,expression:t,target:l},i)=>d.default.createElement(d.default.Fragment,{key:i},d.default.createElement(Text,{lowercase:!0},e[a]||a),t&&d.default.createElement(d.default.Fragment,null,d.default.createElement(n.default,{displayType:"secondary"},(e=>((0,s.forEachDataDefinitionField)(w,(({name:a})=>{e=e.replace(new RegExp("\\[".concat(a,"\\]"),"g"),(0,s.getFieldLabel)(w,a))})),e))(t)),d.default.createElement(Text,{lowercase:!0},Liferay.Language.get("into"))),d.default.createElement(n.default,{displayType:"success"},(0,s.getFieldLabel)(w,l)),i+1!==p.length&&d.default.createElement(n.default,{displayType:"warning"},Liferay.Language.get("and"))))))),d.default.createElement(c.default,{actions:E,className:"rule-list__options"}))};var l=_interopRequireDefault(t("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/label")),i=_interopRequireDefault(t("@frontend-taglib-clay$clayui/panel")),r=_interopRequireDefault(t("liferay!frontend-js-react-web$classnames")),o=t("data-engine-js-components-web"),u=t("frontend-js-web"),d=_interopRequireDefault(t("liferay!frontend-js-react-web$react")),s=t("../../utils/dataDefinition.es"),f=t("../../utils/lang.es"),c=_interopRequireDefault(t("../drop-down/DropDown.es"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={autofill:Liferay.Language.get("autofill"),calculate:Liferay.Language.get("calculate"),enable:Liferay.Language.get("enable"),require:Liferay.Language.get("require"),show:Liferay.Language.get("show")},g={"belongs-to":Liferay.Language.get("belongs-to"),contains:Liferay.Language.get("contains"),"does-not-contain":Liferay.Language.get("does-not-contain"),"equals-to":Liferay.Language.get("equals-to"),"is-empty":Liferay.Language.get("is-empty"),"not-equals-to":Liferay.Language.get("not-equals-to"),"not-is-empty":Liferay.Language.get("not-is-empty")},Text=({capitalize:e=!1,children:a="",lowercase:t=!1})=>d.default.createElement("span",{className:(0,r.default)("pr-1",{"text-capitalize":e,"text-lowercase":t})},a)}}));
//# sourceMappingURL=RuleItem.js.map