Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/undo/UndoHistory",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$react","../../../plugins/experience/actions","../../config/constants/undoTypes","../../config/index","../../contexts/StoreContext","../../thunks/multipleUndo","../../utils/getSegmentsExperienceName","./getActionLabel"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const t=(0,u.useDispatch)(),n=(0,u.useSelector)((e=>e)),i=(0,u.useSelector)((e=>e.redoHistory||[])),s=(0,u.useSelector)((e=>e.undoHistory||[])),f=(0,r.useIsMounted)(),[p,g]=(0,l.useState)(!1),[m,y]=(0,l.useState)(!1),b=(e,a,o)=>{e.preventDefault(),y(!0),t((0,d.default)({numberOfActions:a,store:n,type:o})).finally((()=>{f()&&y(!1)}))};return l.default.createElement(l.default.Fragment,null,l.default.createElement(o.default,{active:p,alignmentPosition:o.Align.BottomRight,className:"ml-2",menuElementAttrs:{className:"page-editor__undo-history",containerProps:{className:"cadmin"}},onActiveChange:g,trigger:l.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("history"),"aria-pressed":p,disabled:!s.length&&!i.length,displayType:"secondary",small:!0,symbol:"time",title:Liferay.Language.get("history")})},l.default.createElement(o.default.ItemList,null,l.default.createElement(E,{actions:i,onHistoryItemClick:b,type:c.UNDO_TYPES.redo}),l.default.createElement(E,{actions:s,onHistoryItemClick:b,type:c.UNDO_TYPES.undo}),l.default.createElement(o.default.Divider,null),l.default.createElement(o.default.Item,{disabled:!s.length,onClick:e=>b(e,s.length,c.UNDO_TYPES.undo)},Liferay.Language.get("undo-all")))),m&&l.default.createElement(r.ReactPortal,{className:"cadmin"},l.default.createElement(e,null)))};var a=n("@frontend-taglib-clay$clayui/button"),o=y(n("@frontend-taglib-clay$clayui/drop-down")),r=n("@liferay/frontend-js-react-web"),l=y(n("liferay!frontend-js-react-web$react")),i=n("../../../plugins/experience/actions"),c=n("../../config/constants/undoTypes"),s=n("../../config/index"),u=n("../../contexts/StoreContext"),d=g(n("../../thunks/multipleUndo")),f=g(n("../../utils/getSegmentsExperienceName")),p=g(n("./getActionLabel"));function g(e){return e&&e.__esModule?e:{default:e}}function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function y(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=a?Object.getOwnPropertyDescriptor(e,o):null;r&&(r.get||r.set)?Object.defineProperty(n,o,r):n[o]=e[o]}return n.default=e,t&&t.set(e,n),n}const e=()=>((0,r.useEventListener)("keydown",(e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}),!0,window),l.default.createElement("div",{className:"page-editor__undo-history__overlay",onClickCapture:e=>{e.preventDefault(),e.stopPropagation()}})),E=({actions:e=[],type:t,onHistoryItemClick:n})=>{const a=(0,u.useSelector)((e=>e)),r=e=>t===c.UNDO_TYPES.undo&&0===e,d=t===c.UNDO_TYPES.undo?e:[...e].reverse();return d.map(((e,u)=>l.default.createElement(o.default.Item,{disabled:r(u),key:e.actionId,onClick:e=>{const a=t===c.UNDO_TYPES.undo?u:d.length-u;n(e,a,t)},symbolRight:r(u)?"check":""},(0,p.default)(e,t,{availableSegmentsExperiences:a.availableSegmentsExperiences}),e.type!==i.SELECT_SEGMENTS_EXPERIENCE&&e.segmentsExperienceId!==s.config.defaultSegmentsExperienceId&&!s.config.singleSegmentsExperienceMode&&l.default.createElement("span",null,(0,f.default)(e.segmentsExperienceId,a.availableSegmentsExperiences)))))}}}));
//# sourceMappingURL=UndoHistory.js.map