"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/helpers/objectWithoutProperties"),o=require("react"),r=require("clsx"),i=require("@prom-ui/core/Button"),a=require("@prom-ui/core/Icon"),u=require("@prom-ui/core/Overlay"),c=require("@prom-ui/core/Tooltip"),l=require("@prom-ui/core/useMedia");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var m=d(e),b=d(t),p=d(n),f=s(o),_=d(r),h={buttonContent:"k6I7C",buttonIcon:"AMl7D",buttonText:"_1HzQ4",list:"O4D4q",listItem:"LNQ-G","buttonContentColor_red-900":"A2TgC"},x=["children","items","onOpen","onClose","isRenderPortal","placement"],C=function(e){var t=e.children,n=e.items,o=e.onOpen,r=e.onClose,d=e.isRenderPortal,s=void 0===d||d,C=e.placement,q=void 0===C?"bottom-end":C,y=p.default(e,x),v=f.useState(!1),O=b.default(v,2),g=O[0],E=O[1],j=l.useMedia({minWidth:"medium"}),k=function(){o&&o(),E(!0)},P=function(){r&&r(),E(!1)},w=f.createElement("ul",{className:h.list,"data-qaid":y["data-qaid"]||"context_menu","data-testid":y["data-testid"]||"context_menu"},n.map((function(e,t){var n=e.icon,o=e.onClick,r=e.isCloseOnClick,u=void 0===r||r,c=e.color,l=e.children;return f.createElement("li",{key:t,className:h.listItem,"data-qaid":"context_menu_item","data-testid":"context_menu_item"},f.createElement(i.Button,{type:"button","button-theme":"white","button-width":"1-1","button-round":"none","button-padding":"xs m","button-blackhole":["border-none","awesome-content"],"button-weight":"normal","data-qaid":"context_menu_button","data-testid":"context_menu_button",onClick:function(e){u&&P(),o&&o(e)}},f.createElement("div",{className:_.default(h.buttonContent,m.default({},h["buttonContentColor_".concat(c)],Boolean(c)))},!!n&&f.createElement(a.Icon,{className:h.buttonIcon,"icon-as":n,style:{width:24,height:24},"data-qaid":"context_menu_button_icon","data-testid":"context_menu_button_icon"}),f.createElement("div",{className:h.buttonText,"data-qaid":"context_menu_button_text","data-testid":"context_menu_button_text"},l))))})));return j?f.createElement(c.Tooltip,{isRenderPortal:s,trigger:"click",placement:q,isShowArrow:!1,content:w,isVisible:g,padding:"0",onVisibleChange:function(e){g?e||P():e&&k()}},t):f.createElement(f.Fragment,null,f.cloneElement(t,{onClick:k}),f.createElement(u.Overlay,{isRenderPortal:s,isOpen:g,onClose:P,header:null,padding:"0"},w))};C.displayName="ContextMenu",exports.ContextMenu=C,require("./style.production.css");
