@perses-dev/logs-table-plugin 0.3.0-rc.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";(self.chunk_LogsTable=self.chunk_LogsTable||[]).push([["7764"],{8604(e,t,n){n.r(t),n.d(t,{LogsTable:()=>es});var l=n(62540),o=n(74628),a=n(88091),r=n(70451),s=n(56599);let i=e=>{let{message:t="No logs to display"}=e,n=(0,s.A)();return(0,l.jsx)(o.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"200px"},children:(0,l.jsx)(a.A,{variant:"body2",sx:{color:n.palette.text.secondary,fontSize:"14px"},children:t})})};var c=n(47095),d=n(91823),p=n(12138),u=n(7013),x=n(7800),m=n(74649),h=n(57072),f=n(35432),g=n(19848),y=n(80242),b=n(91264);let j=new y.v;j.use_classes=!0;let w=RegExp("\x1b\\[[0-9;]*m");function S(e){if(!w.test(e))return null;let t=j.ansi_to_html(e);return b.A.sanitize(t,{ALLOWED_TAGS:["span"],ALLOWED_ATTR:["class","style"]})}let v=RegExp("\x1b\\[[0-9;]*m","g");function A(e){return e.replace(v,"")}function C(e){var t,n;let l,o=("number"==typeof(t=e.timestamp)?new Date(1e3*t):(n=t,new Date(/^\d+$/.test(n)?1e3*parseInt(n):Date.parse(n)))).toISOString(),a=0===(l=Object.entries(e.labels||{})).length?"":l.map(e=>{let[t,n]=e;return`${t}="${n}"`}).join(" "),r=A(e.line);return a?`${o} ${a} ${r}`:`${o} ${r}`}function k(e){return A(e.line)}function E(e){return e.map(C).join("\n")}var z=n(65211),T=n(30145),L=n(63079),O=n(33213),I=n(14045),D=n(39098),R=n(3908),M=n(87275),W=n(11061),F=n(77241),$=n(50172),P=n(12309);let _={critical:["critical","emerg","fatal","alert","crit"],error:["error","err","eror"],debug:["debug","dbug"],info:["info","inf","information","notice"],trace:["trace"],warning:["warn","warning"],unknown:["unknown"],other:[""]};var N=n(91394),V=n(5139),B=n(3399),J=n(59238),U=n(45271);let H=e=>{let{value:t}=e,n=(0,r.useMemo)(()=>S(t),[t]);return n?(0,l.jsx)("span",{dangerouslySetInnerHTML:{__html:n}}):(0,l.jsx)(l.Fragment,{children:t})},K=e=>{let{log:t}=e,n=(0,s.A)();return(0,l.jsx)(N.A,{size:"small",sx:{border:`1px solid ${n.palette.divider}`,"& .MuiTableCell-root":{border:"none",padding:"6px 8px",fontSize:"12px"}},children:(0,l.jsx)(V.A,{children:Object.entries(t).map(e=>{let[t,o]=e;return(0,l.jsxs)(B.A,{sx:{"&:hover":{backgroundColor:(0,J.X4)(n.palette.action.hover,.04)}},children:[(0,l.jsx)(U.A,{sx:{color:n.palette.text.secondary,fontWeight:500,width:"33%"},children:t}),(0,l.jsx)(U.A,{sx:{color:n.palette.text.primary,wordBreak:"break-word",width:"67%"},children:null!=o&&""!==o?(0,l.jsx)(H,{value:o}):"--"})]},t)})})})},G=e=>{let{timestamp:t}=e,n="number"==typeof t?new Date(1e3*t):new Date(/^\d+$/.test(t)?1e3*parseInt(t):Date.parse(t));return(0,l.jsx)("time",{style:{fontSize:"12px",whiteSpace:"nowrap",minWidth:"max-content"},dateTime:n.toISOString(),children:n.toISOString()})};var Q=n(77308);let X=(0,Q.A)(o.A,{shouldForwardProp:e=>"severityColor"!==e})(e=>{let{severityColor:t}=e;return{borderLeft:`4px solid ${t}`,transition:"all 0.2s ease",marginBottom:"4px",fontFamily:'"DejaVu Sans Mono", monospace',userSelect:"text"}}),Y=(0,Q.A)(o.A,{shouldForwardProp:e=>"isExpandable"!==e&&"isHighlighted"!==e&&"isSelected"!==e&&"hasRowActions"!==e})(e=>{let{theme:t,isExpandable:n,isHighlighted:l,isSelected:o,hasRowActions:a}=e;return{display:"grid",gridTemplateColumns:n?`16px minmax(160px, max-content) 1fr ${a?"min-content":""}`:`minmax(160px, max-content) 1fr ${a?"min-content":""}`,alignItems:"flex-start",padding:"4px 8px",cursor:"default",gap:"12px",backgroundColor:l?t.palette.action.hover:o?t.palette.action.selected:"transparent","&:hover":{backgroundColor:o?t.palette.action.focus:t.palette.action.hover}}}),q=(0,Q.A)(c.A,{shouldForwardProp:e=>"isExpanded"!==e})(e=>{let{theme:t,isExpanded:n}=e;return{padding:0,width:"16px",height:"16px",color:t.palette.text.secondary,transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"}}),Z=(0,Q.A)(a.A,{shouldForwardProp:e=>"allowWrap"!==e})(e=>{let{allowWrap:t}=e;return{fontSize:"12px",flex:1,lineHeight:1.4,textAlign:"left",...t?{wordBreak:"break-word",whiteSpace:"pre-wrap",overflow:"visible",textOverflow:"unset"}:{wordBreak:"normal",whiteSpace:"nowrap"}}}),ee=(0,r.memo)(e=>{let{log:t,isExpanded:n,index:a,onToggle:i,isExpandable:d=!0,showTime:p=!1,allowWrap:u=!1,isSelected:x=!1,onSelect:m,itemActionButtons:h}=e,f=(0,s.A)(),g=(e=>{let t=(0,s.A)();if(!e)return t.palette.text.secondary;switch((e=>{var t,n;let l=null==(n=e.labels)||null==(t=n.level)?void 0:t.toLowerCase();if(l){for(let[e,t]of Object.entries(_))if(t.some(e=>e&&l.includes(e)))return e}return"unknown"})(e)){case"critical":return t.palette.error.dark;case"error":return t.palette.error.main;case"warning":return t.palette.warning.main;case"info":return t.palette.info.main;case"debug":return t.palette.primary.main;case"trace":return t.palette.grey[500];default:return t.palette.text.secondary}})(t),y=(0,r.useMemo)(()=>t?S(t.line):null,[t]),[b,j]=(0,r.useState)(!1),[w,v]=(0,r.useState)(null),[A,E]=(0,r.useState)(!1),N=(0,r.useRef)(null),V=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{V.current&&window.clearTimeout(V.current)},[]);let B=(0,r.useCallback)(e=>{d&&(e.stopPropagation(),i(a))},[d,i,a]),J=(0,r.useCallback)(e=>{m&&m(a,e)},[m,a]),U=(0,r.useCallback)(e=>{e.stopPropagation(),v(e.currentTarget)},[]),H=(0,r.useCallback)(()=>{v(null),j(!1)},[]),Q=(0,r.useCallback)(async e=>{let n;if(t){switch(e){case"message":n=k(t);break;case"json":n=JSON.stringify(t,null,2);break;default:n=C(t)}await navigator.clipboard.writeText(n),E(!0),H(),V.current&&window.clearTimeout(V.current),V.current=window.setTimeout(()=>{E(!1)},1500)}},[t,H]);if(!t)return null;let ee=h&&h.length>0;return(0,l.jsxs)(X,{severityColor:g,ref:N,onMouseEnter:()=>j(!0),onMouseLeave:()=>{w||j(!1)},"data-log-index":a,"data-testid":`log-row-container-${a}`,children:[(0,l.jsxs)(Y,{onMouseDown:J,isExpandable:d,isHighlighted:!!w,hasRowActions:ee,isSelected:x,children:[d&&(0,l.jsx)(o.A,{onClick:B,sx:{display:"flex",alignItems:"center",width:"16px",justifyContent:"center",cursor:"pointer"},children:(0,l.jsx)(q,{size:"small",isExpanded:n,children:(0,l.jsx)(W.default,{sx:{fontSize:"12px"}})})}),(0,l.jsx)(G,{timestamp:t.timestamp}),(0,l.jsxs)(o.A,{sx:{display:"flex",gap:"10px",marginLeft:"36px",alignItems:"center"},children:[y?(0,l.jsx)(Z,{variant:"body2",allowWrap:u,dangerouslySetInnerHTML:{__html:y}}):(0,l.jsx)(Z,{variant:"body2",allowWrap:u,children:t.line}),(0,l.jsx)(z.A,{title:A?"Copied!":"Copy options",children:(0,l.jsx)(c.A,{size:"small",onClick:U,"aria-label":"Copy log options",sx:{padding:"4px",marginLeft:"auto",color:A?f.palette.success.main:f.palette.text.secondary,opacity:b||w||A?1:0,pointerEvents:b||w||A?"auto":"none",transition:"opacity 0.08s ease, color 0.2s ease","&:hover":{color:A?f.palette.success.main:f.palette.primary.main,backgroundColor:f.palette.action.hover},borderRadius:"4px",display:"flex",gap:"2px"},children:A?(0,l.jsx)(R.default,{sx:{fontSize:"14px"}}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)($.default,{sx:{fontSize:"14px"}}),(0,l.jsx)(M.default,{sx:{fontSize:"12px"}})]})})}),ee&&(0,l.jsx)(o.A,{sx:{display:"flex",gap:"4px",alignItems:"center",opacity:b||w?1:0,pointerEvents:b||w?"auto":"none",transition:"opacity 0.08s ease"},children:h}),(0,l.jsxs)(T.A,{anchorEl:w,open:!!w,onClose:H,onClick:e=>e.stopPropagation(),"aria-label":"Copy format options",anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:.5,minWidth:180,boxShadow:f.shadows[3]}}},children:[(0,l.jsxs)(L.A,{onClick:()=>Q("full"),sx:{py:1,"&:hover":{backgroundColor:f.palette.action.hover}},children:[(0,l.jsx)(O.A,{children:(0,l.jsx)($.default,{fontSize:"small"})}),(0,l.jsx)(I.A,{primary:"Copy log",secondary:"Timestamp + labels + message",slotProps:{primary:{fontSize:"14px"},secondary:{fontSize:"11px"}}})]}),(0,l.jsxs)(L.A,{onClick:()=>Q("message"),sx:{py:1,"&:hover":{backgroundColor:f.palette.action.hover}},children:[(0,l.jsx)(O.A,{children:(0,l.jsx)(P.default,{fontSize:"small"})}),(0,l.jsx)(I.A,{primary:"Copy message",secondary:"Message text only",slotProps:{primary:{fontSize:"14px"},secondary:{fontSize:"11px"}}})]}),(0,l.jsxs)(L.A,{onClick:()=>Q("json"),sx:{py:1,"&:hover":{backgroundColor:f.palette.action.hover}},children:[(0,l.jsx)(O.A,{children:(0,l.jsx)(F.default,{fontSize:"small"})}),(0,l.jsx)(I.A,{primary:"Copy as JSON",secondary:"Full log entry",slotProps:{primary:{fontSize:"14px"},secondary:{fontSize:"11px"}}})]})]})]})]}),(0,l.jsx)(D.A,{in:n,timeout:200,children:(0,l.jsx)(o.A,{sx:{padding:"8px"},children:(0,l.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:p?"8px minmax(160px, max-content) 1fr":"1fr",gap:"12px"},children:[p&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.A,{}),(0,l.jsx)(o.A,{})]}),(0,l.jsx)(o.A,{children:(0,l.jsx)(K,{log:t.labels})})]})})})]})});ee.displayName="LogRow";let et="PERSES_LOGSTABLE_HINTS_DISMISSED",en=(0,f.formatForDisplay)("Mod"),el=e=>{var t;let{logs:n,spec:a,expandedRows:i,onToggleExpand:y}=e,b=(0,s.A)(),[j,w]=(0,r.useState)(new Set),[S,v]=(0,r.useState)(null),A=(0,r.useRef)(j),[C,z]=(0,r.useState)(null),[T,L]=(0,r.useState)("full"),[O,I]=(0,r.useState)(0),D=(0,r.useRef)(null),[R,M]=(0,r.useState)(()=>{try{return"true"===localStorage.getItem(et)}catch{return!1}}),W=(null==(t=a.selection)?void 0:t.enabled)??!1,{setSelection:F,clearSelection:$}=(0,h.useSelection)(),P=(0,g.useAllVariableValues)(),_=a.actions?a.actions:void 0,N=(null==_?void 0:_.enabled)&&_.displayWithItem?_.actionsList:[],{getItemActionButtons:V,confirmDialog:B}=(0,f.useSelectionItemActions)({actions:N,variableState:P});(0,r.useEffect)(()=>{A.current=j},[j]),(0,r.useEffect)(()=>{W&&(0===j.size?$():F(Array.from(j).map(e=>{let t=n[e];return t?{id:e,item:t}:null}).filter(e=>null!==e)))},[j,n,W,F,$]);let J=(0,r.useCallback)(()=>{M(!0);try{localStorage.setItem(et,"true")}catch{}},[]),U=(0,r.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"full",t=arguments.length>1?arguments[1]:void 0;z({x:window.innerWidth-32,y:window.innerHeight-32}),L(e),I(t),D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{z(null)},5e3)},[]),H=(0,r.useCallback)(()=>{D.current&&window.clearTimeout(D.current),z(null)},[]),K=(0,r.useCallback)(async e=>{let t,l=Array.from(A.current).sort((e,t)=>e-t).map(e=>n[e]).filter(e=>void 0!==e);t="message"===e?l.map(k).join("\n"):"json"===e?JSON.stringify(l,null,2):E(l),await navigator.clipboard.writeText(t),U(e,l.length)},[n,U]),G=(0,r.useCallback)((e,t)=>{var n,l;if(t.shiftKey)if(t.preventDefault(),null==(n=window.getSelection())||n.removeAllRanges(),null!==S){let t=Math.min(S,e),n=Math.max(S,e),l=new Set;for(let e=t;e<=n;e++)l.add(e);w(l)}else w(new Set([e])),v(e);else if(t.ctrlKey||t.metaKey){t.preventDefault(),null==(l=window.getSelection())||l.removeAllRanges();let n=new Set(j);n.has(e)?n.delete(e):n.add(e),w(n),v(e)}else v(e)},[j,S]);return(0,r.useEffect)(()=>{let e=async e=>{if((e.metaKey||e.ctrlKey)&&"a"===e.key&&(e.preventDefault(),w(new Set(n.map((e,t)=>t))),n.length>0&&v(n.length-1)),(e.metaKey||e.ctrlKey)&&"c"===e.key){let t=window.getSelection(),l=t&&t.rangeCount>0&&t.toString().length>0;if(A.current.size>0&&!l){e.preventDefault();let t=Array.from(A.current).sort((e,t)=>e-t).map(e=>n[e]).filter(e=>void 0!==e),l=E(t);await navigator.clipboard.writeText(l),U("full",t.length)}}"Escape"===e.key&&j.size>0&&(w(new Set),v(null))};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[n,j,U]),(0,r.useEffect)(()=>()=>{D.current&&window.clearTimeout(D.current)},[]),(0,l.jsxs)(l.Fragment,{children:[B,(0,l.jsxs)(o.A,{sx:{height:"100%",backgroundColor:b.palette.background.default,overflow:"hidden",boxShadow:b.shadows[1],display:"flex",flexDirection:"column"},onCopy:e=>{let t=window.getSelection();if(t&&t.rangeCount>0&&t.toString().length>0)return;let l=A.current;if(l.size>0){e.preventDefault();let t=E(Array.from(l).sort((e,t)=>e-t).map(e=>n[e]).filter(e=>void 0!==e));e.clipboardData.setData("text/plain",t)}},children:[!R&&(0,l.jsxs)(o.A,{sx:{px:2,py:.75,fontSize:"12px",color:b.palette.text.secondary,backgroundColor:b.palette.background.paper,borderBottom:`1px solid ${b.palette.divider}`,display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[(0,l.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:2,flex:1},children:[(0,l.jsxs)(o.A,{component:"span",sx:{opacity:.8},children:[en,"+Click to select"]}),(0,l.jsx)(o.A,{component:"span",sx:{opacity:.6},children:"•"}),(0,l.jsx)(o.A,{component:"span",sx:{opacity:.8},children:"Shift+Click for range"}),(0,l.jsx)(o.A,{component:"span",sx:{opacity:.6},children:"•"}),(0,l.jsxs)(o.A,{component:"span",sx:{opacity:.8},children:[en,"+C to copy"]}),(0,l.jsx)(o.A,{component:"span",sx:{opacity:.6},children:"•"}),(0,l.jsx)(o.A,{component:"span",sx:{opacity:.8},children:"Esc to clear"})]}),(0,l.jsx)(c.A,{size:"small",onClick:J,sx:{opacity:.6,"&:hover":{opacity:1},padding:.5},"aria-label":"Dismiss hints",children:(0,l.jsx)(x.default,{sx:{fontSize:"16px"}})})]}),(0,l.jsx)(m.aY,{style:{height:"100%",flexGrow:1},initialItemCount:a.showAll?n.length:void 0,totalCount:n.length,itemContent:e=>{let t=n[e];if(!t)return null;let o=(null==N?void 0:N.length)?V({id:e,data:t}):[];return(0,l.jsx)(ee,{isExpandable:a.enableDetails,log:t,index:e,isExpanded:i.has(e),onToggle:y,allowWrap:a.allowWrap,showTime:a.showTime,isSelected:j.has(e),onSelect:G,itemActionButtons:o})}}),(0,l.jsx)(d.Ay,{open:!!C,anchorReference:"anchorPosition",anchorPosition:C?{top:C.y,left:C.x}:void 0,onClose:H,disableScrollLock:!0,disableAutoFocus:!0,disableRestoreFocus:!0,disableEnforceFocus:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},slotProps:{paper:{sx:{px:2,py:1.5,boxShadow:b.shadows[8],borderRadius:2,pointerEvents:"auto"}}},sx:{pointerEvents:"none"},children:(0,l.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,l.jsxs)(o.A,{sx:{fontSize:"14px",color:b.palette.text.primary,fontWeight:500,display:"flex",alignItems:"center",gap:.5},children:["✓ Copied ",O," ",1===O?"log":"logs"," as"," ",(0,l.jsx)(o.A,{component:"span",sx:{color:b.palette.primary.main,minWidth:"60px",display:"inline-block"},children:"full"===T?"Full":"message"===T?"Message":"JSON"})]}),(0,l.jsxs)(p.A,{size:"small",variant:"outlined",children:[(0,l.jsx)(u.A,{onClick:()=>K("full"),sx:{fontSize:"12px",textTransform:"none",minWidth:"52px",fontWeight:"full"===T?600:400,bgcolor:"full"===T?b.palette.action.selected:"transparent"},children:"Full"}),(0,l.jsx)(u.A,{onClick:()=>K("message"),sx:{fontSize:"12px",textTransform:"none",minWidth:"74px",fontWeight:"message"===T?600:400,bgcolor:"message"===T?b.palette.action.selected:"transparent"},children:"Message"}),(0,l.jsx)(u.A,{onClick:()=>K("json"),sx:{fontSize:"12px",textTransform:"none",minWidth:"52px",fontWeight:"json"===T?600:400,bgcolor:"json"===T?b.palette.action.selected:"transparent"},children:"JSON"})]})]})})]})]})},eo=e=>{let{logs:t,spec:n}=e,{expandedRows:o,toggleExpand:a}=(()=>{let[e,t]=(0,r.useState)(new Set);return{expandedRows:e,toggleExpand:(0,r.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),clearExpanded:(0,r.useCallback)(()=>{t(new Set)},[])}})();return t.length?(0,l.jsx)(el,{logs:t,spec:n,expandedRows:o,onToggleExpand:a}):(0,l.jsx)(i,{})};var ea=n(52643),er=n(54042);let es={PanelComponent:function(e){let{queryResults:t,spec:n}=e,r=t.flatMap(e=>{var t;return(null==e||null==(t=e.data.logs)?void 0:t.entries)??[]}).sort((e,t)=>t.timestamp-e.timestamp);return r.length?(0,l.jsx)(eo,{logs:r,spec:n}):(0,l.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,l.jsx)(a.A,{children:"No logs to display"})})},panelOptionsEditorComponents:[{label:"Settings",content:function(e){let{onChange:t,value:n}=e;return(0,l.jsxs)(h.OptionsEditorGrid,{children:[(0,l.jsx)(h.OptionsEditorColumn,{children:(0,l.jsx)(g.LegendOptionsEditor,{value:n.legend,onChange:e=>{t({...n,legend:e})}})}),(0,l.jsx)(h.OptionsEditorColumn,{children:(0,l.jsx)(h.ThresholdsEditor,{hideDefault:!0,thresholds:n.thresholds,onChange:e=>{t({...n,thresholds:e})}})})]})}},{label:"Item Actions",content:function(e){let{value:t,onChange:n}=e;return(0,l.jsx)(g.ItemSelectionActionsEditor,{actionOptions:t.actions,onChangeActions:function(e){n({...t,actions:e})},selectionOptions:t.selection,onChangeSelection:function(e){n({...t,selection:e})}})}}],supportedQueryTypes:["LogQuery"],createInitialOptions:()=>({showTime:!0,allowWrap:!0,enableDetails:!0}),actions:[{component:e=>{let{queryResults:t,definition:n}=e,o=(0,r.useMemo)(()=>t.flatMap(e=>{var t,n;return(null==(n=e.data)||null==(t=n.logs)?void 0:t.entries)??[]}),[t]),a=!o.length,s=(0,r.useCallback)(()=>{if(!a)try{var e,t;let l=JSON.stringify(o,null,2),a=new Blob([l],{type:"application/json"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r;let i=(null==n||null==(t=n.spec)||null==(e=t.display)?void 0:e.name)||"Logs Table Data",c=(0,g.sanitizeFilename)(i);s.download=`${c}_data.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)}catch(e){console.error("Logs table export failed:",e)}},[n,o,a]);return(0,l.jsx)(h.InfoTooltip,{description:a?"No data to export":"Export as JSON",children:(0,l.jsx)(c.A,{disabled:a,size:"small",onClick:s,"aria-label":"Export Logs Table Data as JSON",children:(0,l.jsx)(er.default,{fontSize:"inherit"})})})},location:"header"},{component:e=>{let{queryResults:t,definition:n}=e,o=(0,r.useMemo)(()=>t.flatMap(e=>{var t,n;return(null==(n=e.data)||null==(t=n.logs)?void 0:t.entries)??[]}),[t]),a=!o.length,s=(0,r.useCallback)(()=>{if(!a)try{var e,t;let l,a=(l=function(e){let t=new Set;for(let n of e)for(let e of Object.keys(n.labels))t.add(e);return Array.from(t).sort()}(o),[["timestamp","body",...l].map(g.escapeCsvValue).join(","),...o.map(e=>{let t=(0,g.escapeCsvValue)((0,g.formatTimestampISO)(e.timestamp)),n=(0,g.escapeCsvValue)(A(e.line));return[t,n,...l.map(t=>(0,g.escapeCsvValue)(e.labels[t]??""))].join(",")})].join("\n")+"\n"),r=new Blob([a],{type:"text/csv;charset=utf-8"}),s=URL.createObjectURL(r),i=document.createElement("a");i.href=s;let c=(null==n||null==(t=n.spec)||null==(e=t.display)?void 0:e.name)||"Logs Table Data",d=(0,g.sanitizeFilename)(c);i.download=`${d}_data.csv`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s)}catch(e){console.error("Logs table CSV export failed:",e)}},[n,o,a]);return(0,l.jsx)(h.InfoTooltip,{description:a?"No data to export":"Export as CSV",children:(0,l.jsx)(c.A,{disabled:a,size:"small",onClick:s,"aria-label":"Export Logs Table Data as CSV",children:(0,l.jsx)(ea.default,{fontSize:"inherit"})})})},location:"header"}]}}}]);