Liferay.Loader.define("@liferay/notification-web@1.0.35/js/components/ContentContainer/FreeMarkerTemplateEditor",["module","exports","require","@liferay/object-js-components-web","frontend-js-web","liferay!frontend-js-react-web$react","../../util/constants"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.FreeMarkerTemplateEditor=function FreeMarkerTemplateEditor({baseResourceURL:e,objectDefinitions:t,selectedLocale:r,setSelectedLocale:c,setValues:l,values:u}){const[s,d]=(0,o.useState)(""),[f,p]=(0,o.useState)(),[b,y]=(0,o.useState)([]),m=(0,o.useMemo)((()=>{const e=t.filter((e=>{const{label:t}=e.status;return e.system?"Address"!==e.name&&"User"!==e.name&&"AccountEntry"!==e.name&&"CommercePricingClass"!==e.name:"approved"===t}));return(0,n.filterArrayByQuery)({array:e,query:s,str:"label"})}),[t,s]);return o.default.createElement(n.CodeEditorLocalized,{CustomSidebarContent:o.default.createElement(n.AutoComplete,{emptyStateMessage:Liferay.Language.get("no-entities-were-found"),items:null!=m?m:[],label:Liferay.Language.get("entity"),onChangeQuery:d,onSelectItem:t=>{p(t),(async t=>{const r=await(0,a.fetch)((0,a.createResourceURL)(e,{objectDefinitionId:t,p_p_resource_id:"/notification_templates/notification_template_ftl_elements"}).toString());y(await r.json())})(t.id)},query:s,value:null==f?void 0:f.label[i.defaultLanguageId]},(({label:e,name:t})=>{var r;return o.default.createElement("div",{className:"d-flex justify-content-between"},o.default.createElement("div",null,null!==(r=e[i.defaultLanguageId])&&void 0!==r?r:t))})),mode:"freemarker",onSelectedLocaleChange:({label:e})=>{c(e)},onTranslationsChange:e=>{l(_objectSpread(_objectSpread({},u),{},{body:e}))},placeholder:"<#--".concat(Liferay.Language.get("add-elements-from-the-sidebar-to-define-your-template"),"--\x3e"),selectedLocale:r,sidebarElements:b,translations:u.body})};var n=r("@liferay/object-js-components-web"),a=r("frontend-js-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 r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),i=r("../../util/constants");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=FreeMarkerTemplateEditor.js.map