Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.115/designer/js/definition-builder/diagram-builder/components/sidebar/SidebarHeader",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../DefinitionBuilderContext","../../DiagramBuilderContext","./utils"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function SidebarHeader({backButtonFunction:e=(()=>{}),contentName:t,deleteButtonFunction:a=(()=>{}),showBackButton:u,showDeleteButton:c,title:s}){const{setElements:f}=(0,l.useContext)(i.DefinitionBuilderContext),{selectedItem:y}=(0,l.useContext)(o.DiagramBuilderContext),[m,p]=(0,l.useState)(!1),[g,b]=(0,l.useState)({}),{observer:w}=(0,n.useModal)({onClose:()=>{p(!1)}}),handleKeyDown=e=>{"Backspace"!==e.key&&"Delete"!==e.key||"assignments"===t||document.querySelectorAll(".form-control:focus").length||document.querySelectorAll(".CodeMirror-focused").length||p(!0)};return(0,l.useEffect)((()=>{if(t)return b((0,d.getModalInfo)(t)),window.addEventListener("keydown",handleKeyDown),()=>{window.removeEventListener("keydown",handleKeyDown)}}),[t]),l.default.createElement("div",{className:"sidebar-header"},u&&l.default.createElement(r.ClayButtonWithIcon,{className:"text-secondary",displayType:"unstyled",onClick:e,symbol:"angle-left"}),l.default.createElement("div",{className:"spaced-items"},l.default.createElement("span",{className:"title"},s),c&&l.default.createElement(r.ClayButtonWithIcon,{className:"text-secondary trash-button",disabled:"assignments"===t,displayType:"unstyled",onClick:()=>p(!0),symbol:"trash"})),m&&l.default.createElement(n.default,{center:!0,observer:w,size:"sm"},l.default.createElement(n.default.Header,{className:"text-secondary"},g.title),l.default.createElement(n.default.Body,{className:"text-secondary"},g.message),l.default.createElement(n.default.Footer,{last:l.default.createElement(l.default.Fragment,null,l.default.createElement(r.default,{className:"mr-3",displayType:"secondary",onClick:()=>p(!1)},Liferay.Language.get("cancel")),l.default.createElement(r.default,{displayType:"danger",onClick:a?()=>{a(),p(!1),e()}:()=>{f((e=>e.filter((e=>e.id!==y.id&&e.source!==y.id&&e.target!==y.id)))),p(!1),e()}},Liferay.Language.get("delete")))})))};var r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/button")),n=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/modal")),l=(function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(a("liferay!frontend-js-react-web$react"))),i=a("../../../DefinitionBuilderContext"),o=a("../../DiagramBuilderContext"),d=a("./utils");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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]}return a.default=e,t&&t.set(e,a),a}}}));
//# sourceMappingURL=SidebarHeader.js.map