import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{memo as a}from"react";import o from"moment";import{isEqual as i,template as n}from"lodash";import{makeStyles as l}from"@material-ui/core";import s from"@material-ui/icons/ArrowForward";import{Tooltip as p}from"../../Tooltip/Tooltip.js";import"../../Tooltip/ScrollableTooltip.js";import{getDeductsFromScoreClass as c,isResolved as m,getDeductsFromScoreValue as d}from"../utils.js";import{ALERT_STATES as h,BADGE_ICON_STATUSES as f}from"../constants.js";import{UniversalLink as g}from"../../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import{useDQUnvalidatedContentStyles as u}from"../styles.js";import{MIXPANEL_ACTION_TYPES as x}from"../../../constants/mixpanel.js";var y=l((function(e){return{errorIcon:{width:20,height:18},title:{maxWidth:198,padding:"0 0 8px",fontSize:16,lineHeight:"22px",color:e.palette.primary.text1,display:"flex",alignItems:"center"},emptyMessage:{padding:"0",fontSize:16,lineHeight:"22px",color:e.palette.primary.contrastText},alertTime:{fontSize:14,color:e.palette.primary.text6,"& span":{color:e.palette.primary.text1}},alertMessage:{width:"100%",height:40,margin:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box","-webkit-line-clamp":2,"-webkit-box-orient":"vertical",whiteSpace:"pre-wrap",fontSize:14,lineHeight:"20px",color:e.palette.primary.text1},alertMessageFull:{marginBottom:8,fontSize:14,lineHeight:"20px",color:e.palette.primary.text1,whiteSpace:"pre-wrap"},alertInfo:{display:"flex",alignItems:"center",flexWrap:"wrap",marginBottom:8,fontSize:14,textTransform:"capitalize","& span":{color:e.palette.primary.text6,marginRight:8},"& .error":{color:e.palette.error.main},"& .warning":{color:"#ffa500"}},resolvedInfo:{display:"flex",alignItems:"center",marginBottom:8,color:e.palette.primary.text6,fontSize:14},infoIcon:{color:e.palette.info.main,marginRight:8,fontSize:16},popover:{marginLeft:77,width:270,padding:12,display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:e.palette.background.b9,border:"1px solid ".concat(e.palette.primary.text9),boxShadow:"0px 3px 10px rgba(0, 0, 0, 0.4)",borderRadius:4,zIndex:500,"& .MuiTooltip-tooltip":{backgroundColor:e.palette.background.b10,fontWeight:400,lineHeight:"20px",margin:0}},message:{whiteSpace:"pre-wrap"},note:{marginBottom:4},ok:{color:"#F99500 !important"},good:{color:"".concat(e.palette.warning.light," !important")}}})),v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"MMM D YYYY, hh:mm A";return e?o.unix(e).format(t):null},w=function(e){return o.unix(e).format("DD MMM HH:mm (Z)")},S=function(t){var r=t.children,a=y(),o=n(r)({timestampFormatter:w}).split("**").map((function(t,r){return r%2==1?e("b",{children:t}):t}));return e("span",{className:a.message,children:o})},b=a((function(a){var o,i=a.alert,n=a.alertIcon,l=a.children,w=a.linkToDQPage,b=y(),N=u({}),I=Math.max(i.statusUpdatedAt,i.lastCheckedAt),M=v(I);return e(p,{interactive:!0,children:l,PopperProps:{className:b.popover},placement:"right",title:t(r,{children:[i.emptyMessage&&e("div",{className:b.emptyMessage,children:i.statusUpdatedAt?v(i.statusUpdatedAt):i.emptyMessage}),!i.emptyMessage&&t(r,{children:[t("div",{className:b.title,children:[i.name,e(p,{isFullScreen:!1,title:"Go to Data Quality page",children:e("div",{children:e(g,{className:N.link,href:w,onClick:function(){var e,t;null===(e=(t=window)[Symbol.for("logToMixpanel")])||void 0===e||e.call(t,x.REDIRECT.ASSET_DASHBOARD,{referer:"DQ Badge"})},children:e(s,{className:N.linkIcon})})})})]}),t("span",{className:b.alertInfo,children:[e("span",{children:"Category:"})," ",i.category]}),t("span",{className:b.alertInfo,children:[e("span",{children:"Status:"})," ",i.status]}),t("span",{className:b.alertInfo,children:[e("span",{children:"Error Type:"}),e("div",{className:b.errorIcon,children:n}),e("span",{className:i.state===h.issue?f.warning:f.error,children:i.state})]}),t("span",{className:b.alertInfo,children:[e("span",{children:"Score Deduction:"}),e("span",{className:c(b,i.deductsFromScore,m(i.status)),children:d(i.deductsFromScore,m(i.status))})]}),t("div",{className:b.alertMessageFull,children:[i.isThrottled&&e("b",{children:"[Throttled]: "}),e(S,{children:i.message})]}),t("span",{className:b.alertInfo,children:[e("span",{className:b.note,children:"Note:"})," ",null!==(o=i.note)&&void 0!==o&&o.length?i.note:"—"]}),t("span",{className:b.alertTime,children:["Updated at: ",e("span",{children:M})]})]})]})})}),(function(e,t){return i(e.alert,t.alert)}));export{b as DQAlertsTooltip};
//# sourceMappingURL=DQAlertsTooltip.js.map
