Liferay.Loader.define("style-book-web@2.0.76/js/style-book-editor/UndoHistory",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$react","./constants/undoTypes","./contexts/StyleBookEditorContext"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function UndoHistory(){const e=(0,o.useIsMounted)(),t=(0,u.useMultipleUndo)(),n=(0,u.useRedoHistory)(),l=(0,u.useUndoHistory)(),[c,s]=(0,i.useState)(!1),[f,y]=(0,i.useState)(!1),onHistoryItemClick=(n,a,r)=>{n.preventDefault(),y(!0),t({numberOfActions:a,type:r}).then((()=>{e()&&y(!1)}))};return i.default.createElement(i.default.Fragment,null,i.default.createElement(r.default,{active:c,alignmentPosition:r.Align.BottomRight,className:"ml-2 mr-2",menuElementAttrs:{className:"style-book-editor__undo-history",containerProps:{className:"cadmin"}},onActiveChange:s,trigger:i.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("history"),"aria-pressed":c,disabled:!l.length&&!n.length,displayType:"secondary",size:"sm",symbol:"time",title:Liferay.Language.get("history")})},i.default.createElement(r.default.ItemList,null,i.default.createElement(History,{actions:n,onHistoryItemClick:onHistoryItemClick,type:d.UNDO_TYPES.redo}),i.default.createElement(History,{actions:l,onHistoryItemClick:onHistoryItemClick,type:d.UNDO_TYPES.undo}),i.default.createElement(r.default.Divider,null),i.default.createElement(r.default.Item,{disabled:!l.length,onClick:e=>{onHistoryItemClick(e,l.length,d.UNDO_TYPES.undo)}},Liferay.Language.get("undo-all")))),f&&i.default.createElement(o.ReactPortal,{className:"cadmin"},i.default.createElement(Overlay,null)))};var a=n("@frontend-taglib-clay$clayui/button"),r=_interopRequireWildcard(n("@frontend-taglib-clay$clayui/drop-down")),o=n("@liferay/frontend-js-react-web"),l=n("frontend-js-web"),i=_interopRequireWildcard(n("liferay!frontend-js-react-web$react")),d=n("./constants/undoTypes"),u=n("./contexts/StyleBookEditorContext");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 n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o=a?Object.getOwnPropertyDescriptor(e,r):null;o&&(o.get||o.set)?Object.defineProperty(n,r,o):n[r]=e[r]}return n.default=e,t&&t.set(e,n),n}const Overlay=()=>((0,o.useEventListener)("keydown",(e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}),!0,window),i.default.createElement("div",{className:"style-book-editor__undo-history__overlay",onClickCapture:e=>{e.preventDefault(),e.stopPropagation()}})),History=({actions:e=[],type:t,onHistoryItemClick:n})=>{const isSelectedAction=e=>t===d.UNDO_TYPES.undo&&0===e,a=t===d.UNDO_TYPES.undo?e:[...e].reverse();return a.map(((e,o)=>i.default.createElement(r.default.Item,{disabled:isSelectedAction(o),key:o,onClick:e=>{const r=t===d.UNDO_TYPES.undo?o:a.length-o;n(e,r,t)},symbolRight:isSelectedAction(o)?"check":""},(0,l.sub)(Liferay.Language.get("update-x"),e.label))))}}}));
//# sourceMappingURL=UndoHistory.js.map