@datarecce/ui 1.54.0 → 1.54.1

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.
Files changed (47) hide show
  1. package/dist/advanced.d.ts +7 -7
  2. package/dist/advanced.js +1 -1
  3. package/dist/{api-DC7Dozi1.d.ts → api-DuJIXF2M.d.ts} +2 -2
  4. package/dist/{api-DC7Dozi1.d.ts.map → api-DuJIXF2M.d.ts.map} +1 -1
  5. package/dist/api-S5ho3Qs3.js.map +1 -1
  6. package/dist/api.d.ts +2 -2
  7. package/dist/components-run.d.ts +2 -2
  8. package/dist/components-run.js +1 -1
  9. package/dist/components.d.ts +6 -6
  10. package/dist/components.js +1 -1
  11. package/dist/contexts.d.ts +3 -3
  12. package/dist/{hooks-CeTKVd72.js → hooks-wWyObPRq.js} +2 -2
  13. package/dist/{hooks-CeTKVd72.js.map → hooks-wWyObPRq.js.map} +1 -1
  14. package/dist/hooks.d.ts +1 -1
  15. package/dist/hooks.js +1 -1
  16. package/dist/{index-Cqok64Sw.d.ts → index-BAZ9ccSn.d.ts} +3 -3
  17. package/dist/{index-Cqok64Sw.d.ts.map → index-BAZ9ccSn.d.ts.map} +1 -1
  18. package/dist/{index-DqNK3h9o.d.ts → index-Bt8tqcVx.d.ts} +4 -4
  19. package/dist/{index-DqNK3h9o.d.ts.map → index-Bt8tqcVx.d.ts.map} +1 -1
  20. package/dist/{index-DjOBN7u1.d.ts → index-CcbJXyWP.d.ts} +3 -3
  21. package/dist/{index-DjOBN7u1.d.ts.map → index-CcbJXyWP.d.ts.map} +1 -1
  22. package/dist/{index-gs16KfoD.d.ts → index-Cf7i3Jjx.d.ts} +2 -2
  23. package/dist/{index-gs16KfoD.d.ts.map → index-Cf7i3Jjx.d.ts.map} +1 -1
  24. package/dist/{index-Da0AhIBC.d.ts → index-DSvEnZsR.d.ts} +5 -5
  25. package/dist/{index-Da0AhIBC.d.ts.map → index-DSvEnZsR.d.ts.map} +1 -1
  26. package/dist/{index-BRyoSMEd.d.ts → index-Dtdfx8GJ.d.ts} +3 -3
  27. package/dist/{index-BRyoSMEd.d.ts.map → index-Dtdfx8GJ.d.ts.map} +1 -1
  28. package/dist/index.d.ts +10 -10
  29. package/dist/index.js +1 -1
  30. package/dist/{instanceInfo-D3d5flul.d.ts → instanceInfo-Bh2vXN8a.d.ts} +3 -3
  31. package/dist/{instanceInfo-D3d5flul.d.ts.map → instanceInfo-Bh2vXN8a.d.ts.map} +1 -1
  32. package/dist/{lineage-Cqlo57P1.d.ts → lineage-BF2rb9ss.d.ts} +7 -7
  33. package/dist/{lineage-Cqlo57P1.d.ts.map → lineage-BF2rb9ss.d.ts.map} +1 -1
  34. package/dist/{primitives-4OaWN3IW.d.ts → primitives-BeItqplR.d.ts} +3 -3
  35. package/dist/{primitives-4OaWN3IW.d.ts.map → primitives-BeItqplR.d.ts.map} +1 -1
  36. package/dist/primitives.d.ts +3 -3
  37. package/dist/primitives.js +1 -1
  38. package/dist/result.js +1 -1
  39. package/dist/{src-DH5i0LSg.js → src-DkPmhj-P.js} +2 -2
  40. package/dist/{src-DH5i0LSg.js.map → src-DkPmhj-P.js.map} +1 -1
  41. package/dist/{types-C7lJDCVr.d.ts → types-Bm0mYEyY.d.ts} +2 -2
  42. package/dist/{types-C7lJDCVr.d.ts.map → types-Bm0mYEyY.d.ts.map} +1 -1
  43. package/dist/{types-D9KPWvGb.d.ts → types-lWiZuchw.d.ts} +2 -2
  44. package/dist/{types-D9KPWvGb.d.ts.map → types-lWiZuchw.d.ts.map} +1 -1
  45. package/dist/types.d.ts +7 -7
  46. package/dist/utils.d.ts +1 -1
  47. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
 
2
- import { a as LineageGraphColumnNode, c as LineageGraphNode, d as NodeAction, f as SelectMode, i as LineageGraph, l as LineageGraphNodes, m as isLineageGraphNode, n as ActionState, o as LineageGraphContextType, p as isLineageGraphColumnNode, r as EnvInfo, s as LineageGraphEdge, t as ActionMode, u as LineageViewContextType } from "./types-C7lJDCVr.js";
3
- import { _ as toReactFlowBasic, a as LineageGraphProvider, c as useRunsAggregated, d as buildLineageGraph, f as getNeighborSet, g as selectUpstream, h as selectDownstream, i as useLineageViewContextSafe, l as COLUMN_HEIGHT, m as layoutWithDagre, n as LineageViewContext, o as LineageGraphProviderProps, p as intersect, r as useLineageViewContext, s as useLineageGraphContext, t as useRecceServerFlag, u as NodeColumnSetMap, v as union } from "./index-Cqok64Sw.js";
4
- import { _ as RecceFeatureMode, a as useIdleTimeoutSafe, b as defaultInstanceInfo, c as useRecceActionContext, g as InstanceInfoType, h as useRecceInstanceContext, i as IdleTimeoutContextType, m as RecceInstanceInfoProvider, n as IdleTimeoutProvider, o as RecceActionProvider, p as useRecceInstanceInfo, r as useIdleTimeout, t as useIdleDetection, v as RecceFeatureToggles, y as defaultFeatureToggles } from "./index-gs16KfoD.js";
2
+ import { a as LineageGraphColumnNode, c as LineageGraphNode, d as NodeAction, f as SelectMode, i as LineageGraph, l as LineageGraphNodes, m as isLineageGraphNode, n as ActionState, o as LineageGraphContextType, p as isLineageGraphColumnNode, r as EnvInfo, s as LineageGraphEdge, t as ActionMode, u as LineageViewContextType } from "./types-Bm0mYEyY.js";
3
+ import { _ as toReactFlowBasic, a as LineageGraphProvider, c as useRunsAggregated, d as buildLineageGraph, f as getNeighborSet, g as selectUpstream, h as selectDownstream, i as useLineageViewContextSafe, l as COLUMN_HEIGHT, m as layoutWithDagre, n as LineageViewContext, o as LineageGraphProviderProps, p as intersect, r as useLineageViewContext, s as useLineageGraphContext, t as useRecceServerFlag, u as NodeColumnSetMap, v as union } from "./index-BAZ9ccSn.js";
4
+ import { _ as RecceFeatureMode, a as useIdleTimeoutSafe, b as defaultInstanceInfo, c as useRecceActionContext, g as InstanceInfoType, h as useRecceInstanceContext, i as IdleTimeoutContextType, m as RecceInstanceInfoProvider, n as IdleTimeoutProvider, o as RecceActionProvider, p as useRecceInstanceInfo, r as useIdleTimeout, t as useIdleDetection, v as RecceFeatureToggles, y as defaultFeatureToggles } from "./index-Cf7i3Jjx.js";
5
5
  import { a as useRouteConfig, c as useApiClient, i as RouteConfigProviderProps, l as useApiConfig, n as RouteConfigContextType, o as useRouteConfigSafe, r as RouteConfigProvider, s as ApiProvider, t as RouteConfig, u as useApiConfigOptional } from "./RouteConfigContext-CRxwjA3a.js";
6
6
  export { type ActionMode, type ActionState, ApiProvider, COLUMN_HEIGHT, type EnvInfo, type IdleTimeoutContextType, IdleTimeoutProvider, type InstanceInfoType, type LineageGraph, type LineageGraphColumnNode, type LineageGraphContextType, type LineageGraphEdge, type LineageGraphNode, type LineageGraphNodes, LineageGraphProvider, type LineageGraphProviderProps, LineageViewContext, type LineageViewContextType, type NodeAction, type NodeColumnSetMap, RecceActionProvider, type RecceFeatureMode, type RecceFeatureToggles, RecceInstanceInfoProvider, type RouteConfig, type RouteConfigContextType, RouteConfigProvider, type RouteConfigProviderProps, type SelectMode, buildLineageGraph, defaultFeatureToggles, defaultInstanceInfo, getNeighborSet, intersect, isLineageGraphColumnNode, isLineageGraphNode, layoutWithDagre, selectDownstream, selectUpstream, toReactFlowBasic, union, useApiClient, useApiConfig, useApiConfigOptional, useIdleDetection, useIdleTimeout, useIdleTimeoutSafe, useLineageGraphContext, useLineageViewContext, useLineageViewContextSafe, useRecceActionContext, useRecceInstanceContext, useRecceInstanceInfo, useRecceServerFlag, useRouteConfig, useRouteConfigSafe, useRunsAggregated };
@@ -3,5 +3,5 @@ import{$ as e,C as t,G as n,K as r,L as i,O as a,R as o,S as s,X as c,Z as l,at
3
3
  \`\`\`sql
4
4
  ${e}
5
5
  \`\`\``}const rs=`recce:canceledRuns`,is=`recce:canceledRuns:changed`;function as(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(rs);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function os(e){if(!(typeof window>`u`))try{window.localStorage.setItem(rs,JSON.stringify(e))}catch{}}function ss(){let[e,t]=V(()=>as());return R(()=>{if(typeof window>`u`)return;let e=e=>{if(e.key===rs){if(e.newValue==null){t(as());return}try{let n=JSON.parse(e.newValue);if(!Array.isArray(n)){t([]);return}t(n.filter(e=>typeof e==`string`))}catch{t(as())}}},n=()=>t(as());return window.addEventListener(`storage`,e),window.addEventListener(is,n),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(is,n)}},[]),{has:L(t=>e.includes(t),[e]),add:L(e=>{let n=as();if(n.includes(e)){t(n);return}let r=[...n,e],i=r.length>200?r.slice(r.length-200):r;if(os(i),t(i),typeof window<`u`)try{window.dispatchEvent(new Event(is))}catch{}},[])}}function cs(e){return e.status?e.status:e.result?`Finished`:e.error?`Failed`:`Finished`}function ls(e){switch(e){case`Running`:return{color:`blue`,label:`Running`};case`Finished`:return{color:`green`,label:`Finished`};case`Failed`:return{color:`red`,label:`Failed`};case`Cancelled`:return{color:`grey`,label:`Cancelled`};default:return{color:`green`,label:`Finished`}}}function us({status:e,showSpinner:t=!0,size:n=`small`,className:r}){let{color:i,label:a}=ls(e);return W(G,{className:r,sx:{display:`inline-flex`,alignItems:`center`,gap:.5},children:[e===`Running`&&t&&U(pn,{size:n===`small`?12:16,color:`primary`}),U(J,{component:`span`,sx:{fontWeight:500,fontSize:n===`small`?`0.75rem`:`0.875rem`,color:`${i}.500`},children:a})]})}const ds=I(us);ds.displayName=`RunStatusBadge`;function fs(e){if(e==null)return null;let t=new Date,n=new Date;return n.setDate(t.getDate()-1),t.toDateString()===e.toDateString()?`Today`:n.toDateString()===e.toDateString()?`Yesterday`:e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function ps(e){if(e==null)return null;let t=new Date,n=new Date;n.setDate(t.getDate()-1);let r=e.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1});return t.toDateString()===e.toDateString()?`Today, ${r}`:n.toDateString()===e.toDateString()?`Yesterday, ${r}`:`${e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}, ${r}`}function ms({status:e,runAt:t,className:n}){let r=t?ps(typeof t==`string`?new Date(t):t):null;return W(G,{className:n,sx:{display:`flex`,alignItems:`center`,gap:.5,fontSize:`0.75rem`,color:`text.secondary`},children:[U(ds,{status:e,size:`small`}),r&&W(H,{children:[U(J,{component:`span`,sx:{fontSize:`inherit`},children:`•`}),U(J,{component:`span`,sx:{fontSize:`inherit`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r})]})]})}const hs=I(ms);hs.displayName=`RunStatusWithDate`;function gs({run:e,className:t}){return U(hs,{status:cs(e),runAt:e.run_at,className:t})}const _s=I(gs);_s.displayName=`RunStatusAndDate`;function vs({run:e,isSelected:t=!1,icon:n,onClick:r,onAddToChecklist:i,onGoToCheck:a,addToChecklistIcon:o,goToCheckIcon:s,hideAddToChecklist:c=!1,disableAddToChecklist:l=!1,className:u}){let d=P(),f=ss().has(e.id)?`Cancelled`:e.status,p=e.checkId!=null,m=!c&&!p&&(i||l);return W(G,{className:u,onClick:()=>r?.(e.id),sx:e=>({display:`flex`,flexDirection:`column`,width:`100%`,p:`8px 16px`,cursor:`pointer`,borderBottom:1,borderColor:`divider`,borderLeft:`4px solid`,borderLeftColor:t?`warning.main`:`transparent`,bgcolor:t?d?`warning.dark`:`warning.light`:`transparent`,"&:hover":{bgcolor:t?d?`warning.dark`:`warning.light`:e.palette.action.hover}}),children:[W(G,{sx:{display:`flex`,alignItems:`center`,gap:1.5},children:[n&&U(G,{sx:{fontSize:16,color:`text.secondary`,flexShrink:0},children:n}),U(J,{sx:{flex:1,fontSize:`0.875rem`,fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:e.name?`text.primary`:`text.secondary`},children:e.name?.trim()||`<no name>`}),p&&a&&U(X,{title:`Go to Check`,children:U(Y,{size:`small`,onClick:t=>{t.stopPropagation(),e.checkId&&a(e.checkId)},sx:{p:.5},children:s||U(G,{component:`span`,sx:{fontSize:14,color:`success.main`},children:`✓`})})}),m&&U(X,{title:l?`You don't have permission to add checks`:`Add to Checklist`,children:U(`span`,{children:U(Y,{size:`small`,disabled:l,onClick:t=>{t.stopPropagation(),i?.(e.id)},sx:{p:.5},children:o||U(G,{component:`span`,sx:{fontSize:14},children:`○`})})})})]}),U(hs,{status:f,runAt:e.runAt})]})}const ys=I(vs);ys.displayName=`RunListItem`;const bs=I(function({date:e}){return U(G,{sx:{width:`100%`,p:`8px 16px`,borderBottom:1,borderColor:`divider`,color:`text.secondary`,fontSize:`0.75rem`,fontWeight:500,bgcolor:`action.hover`},children:e})});function xs({runs:e,selectedId:t,isLoading:n=!1,onRunSelect:r,onAddToChecklist:i,onGoToCheck:a,getRunIcon:o,hideAddToChecklist:s=!1,disableAddToChecklist:c=!1,title:l=`Runs`,headerActions:u,emptyMessage:d=`No runs`,loadingMessage:f=`Loading...`,groupByDate:p=!1,addToChecklistIcon:m,goToCheckIcon:h,className:g}){return W(G,{className:g,sx:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`},children:[W(q,{direction:`row`,sx:{alignItems:`center`,flex:`0 0 auto`,px:2,py:1.5,borderBottom:1,borderColor:`divider`},children:[U(J,{variant:`h6`,children:l}),U(G,{sx:{flex:1}}),u]}),U(G,{sx:{flex:1,overflow:`auto`},children:n?U(G,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,color:`text.secondary`},children:f}):(()=>{if(e.length===0)return U(G,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,color:`text.secondary`,p:4},children:d});let n=null;return e.map(e=>{let l=e.runAt?fs(new Date(e.runAt)):null,u=p&&l&&n!==l;return n=l,W(G,{children:[u&&U(bs,{date:l}),U(ys,{run:e,isSelected:e.id===t,icon:o?.(e.type),onClick:r,onAddToChecklist:i,onGoToCheck:a,hideAddToChecklist:s,disableAddToChecklist:c,addToChecklistIcon:m,goToCheckIcon:h})]},e.id)})})()})]})}const Ss=I(xs);Ss.displayName=`RunList`;function Cs({status:e,progress:t,message:n,errorMessage:r,variant:i=`spinner`,showStatus:a=!0,icon:o,className:s}){let c=e===`Running`,l=e===`Failed`,u=t!==void 0&&t>=0;return W(G,{className:s,sx:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:2,p:3,textAlign:`center`},children:[o?U(G,{sx:{fontSize:40,color:`text.secondary`},children:o}):c&&W(H,{children:[i===`spinner`&&U(pn,{size:40,color:`primary`}),i===`circular`&&U(pn,{size:60,variant:u?`determinate`:`indeterminate`,value:t,color:`primary`})]}),c&&i===`linear`&&W(G,{sx:{width:`100%`,maxWidth:300},children:[U(Vn,{variant:u?`determinate`:`indeterminate`,value:t,sx:{height:8,borderRadius:4}}),u&&W(J,{variant:`caption`,sx:{color:`text.secondary`,mt:.5,display:`block`},children:[Math.round(t),`%`]})]}),a&&U(ds,{status:e,size:`medium`}),n&&!l&&U(J,{variant:`body2`,sx:{color:`text.secondary`},children:n}),l&&r&&U(G,{sx:{p:2,bgcolor:`error.light`,borderRadius:1,maxWidth:400},children:U(J,{variant:`body2`,sx:{color:`error.contrastText`},children:r})})]})}const ws=I(Cs);ws.displayName=`RunProgress`;function Ts({visible:e=!0,opacity:t=.8,...n}){return e?U(G,{sx:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:`rgba(255, 255, 255, ${t})`,zIndex:10,".dark &":{bgcolor:`rgba(0, 0, 0, ${t})`}},children:U(ws,{...n})}):null}const Es=I(Ts);Es.displayName=`RunProgressOverlay`;function Ds({warnings:e,children:t,className:n}){let r=P(),i=e&&e.length>0;return W(G,{className:n,sx:{display:`flex`,borderBottom:`1px solid`,borderColor:`divider`,justifyContent:`flex-end`,gap:`5px`,alignItems:`center`,px:`10px`,bgcolor:i?r?N.amber[900]:N.amber[100]:`inherit`,color:i?r?N.amber[200]:N.amber[800]:`inherit`},children:[U(G,{sx:{display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:0},children:e?.map((e,t)=>W(G,{children:[U(on,{color:r?N.amber[400]:N.amber[600],style:{verticalAlign:`middle`,marginRight:4}}),e]},e))}),U(G,{sx:{flex:1,minHeight:`32px`}}),t]})}const Os=I(Ds);Os.displayName=`RunToolbar`,Wn.register(Hn,qn,Kn,Un,Jn,Gn,Yn);function ks(e,t){let n=e[t],r=e[t+1];return`${Ne(n)} - ${Ne(r)}`}function As({title:e,dataType:t=`numeric`,samples:n=0,min:r=0,max:i=0,binEdges:a,baseData:o,currentData:s,animate:c=!1,hideAxis:l=!1,theme:u=`light`,height:d=300,className:f}){let p=u===`dark`,m=ge(p),h=M(p),g=t===`datetime`,_=z(()=>{let e=a.slice(0,-1).map((e,t)=>ks(a,t)),t=(e,t,n)=>{let r=e.counts??[];return{label:t,data:g?r.map((e,t)=>[a[t],e]):r,backgroundColor:n,borderColor:n,hoverBackgroundColor:n,borderWidth:0,categoryPercentage:1,barPercentage:1,xAxisID:`x`}};return{labels:e,datasets:[t(s,s.label??`Current`,h.currentWithAlpha),t(o,o.label??`Base`,h.baseWithAlpha)]}},[a,o,s,h,g]),v=z(()=>{let u=Math.max(...s.counts,...o.counts),d=a.slice(0,-1).map((e,t)=>ks(a,t)),f=g?`Date Range`:t===`string`?`Text Length`:`Value Range`;return{responsive:!0,maintainAspectRatio:!1,animation:c?void 0:!1,plugins:{legend:{reverse:!0,labels:{color:m.textColor}},title:{display:!0,text:e,font:{size:20},color:m.textColor},tooltip:{mode:`index`,intersect:!1,backgroundColor:m.tooltipBackgroundColor,titleColor:m.tooltipTextColor,bodyColor:m.tooltipTextColor,borderColor:m.borderColor,borderWidth:1,callbacks:{title([{dataIndex:e}]){return`${f}\n${ks(a,e)}`},label({datasetIndex:e,dataIndex:t,dataset:r}){let i=(e===0?s.counts:o.counts)[t],a=n>0?Ve(i/n):``;return`${r.label}: ${i}${a?` (${a})`:``}`}}}},scales:{x:g?{display:!l,type:`timeseries`,min:r,max:i,adapters:{date:{}},time:{minUnit:`day`},grid:{display:!1},ticks:{minRotation:30,maxRotation:30,maxTicksLimit:8,color:m.textColor}}:{display:!l,type:`category`,grid:{display:!1},ticks:{callback(e,t){return d[t]},color:m.textColor},stacked:!0},y:{display:!l,type:`linear`,max:u,border:{dash:[2,2],color:m.borderColor},grid:{color:m.gridColor},ticks:{maxTicksLimit:8,color:m.textColor,callback(e){return Ne(e)}},beginAtZero:!0}}}},[e,t,g,n,r,i,a,o,s,l,c,m]);return U(`div`,{className:f,style:{height:d},children:U(Zn,{type:`bar`,options:v,data:_})})}const js=I(As);js.displayName=`HistogramChart`;function Ms({reason:e,adapterType:t,className:n}){let r=e??`This warehouse doesn't expose native HLL / approx-percentile / approx-top-k aggregates, so paired column distributions aren't available here.`;return W(Qn,{severity:`info`,variant:`outlined`,className:n,sx:{fontSize:`0.75rem`,py:.5,px:1,"& .MuiAlert-message":{py:.5}},role:`status`,"aria-live":`polite`,"data-testid":`profile-distribution-unsupported-banner`,children:[U($n,{sx:{fontSize:`0.75rem`,fontWeight:600,mb:.25},children:t?`Paired distributions unavailable on ${t}`:`Paired distributions unavailable on this adapter`}),r]})}Dt.registerModules([Et]);function Ns({emptyMessage:e}){return U(G,{sx:{display:`flex`,height:`35px`,alignItems:`center`,justifyContent:`center`,bgcolor:`grey.100`,textAlign:`center`,gridColumn:`1/-1`},children:U(J,{sx:{fontWeight:600},children:e??`No rows`})})}function Ps({style:e,className:t,columnDefs:n,rowData:r,columns:i,rows:a,getRowId:o,rowHeight:s=32,headerHeight:c=36,defaultColDef:l,defaultColumnOptions:u,renderers:d,rowClassName:f,containerClassName:p,...m},h){let g=B(null),_=B(null);pt(h,()=>({get api(){return _.current},get element(){return g.current}}),[]);let v=P(),y=z(()=>v?he:me,[v]),b=n??i,x=r??a,S=l??u,C=z(()=>({resizable:!0,suppressMovable:!0,...S}),[S]),w=z(()=>{if(d?.noRowsFallback)return()=>d.noRowsFallback},[d?.noRowsFallback]),T=z(()=>o||(e=>{let t=e.data;return t?.__rowKey===void 0?t?._index===void 0?t?.rowIndex===void 0?String(Math.random()):String(t.rowIndex):String(t._index):String(t.__rowKey)}),[o]),E=z(()=>b?`grid-${b.filter(e=>`field`in e&&e.pinned===`left`).map(e=>e.field).sort().join(`,`)}`:`grid`,[b]);return U(G,{ref:g,className:[t,p].filter(Boolean).join(` `)||void 0,sx:{flex:1,minHeight:0,width:`100%`,overflow:`hidden`,"& .ag-root-wrapper":{border:`none`,height:`100%`},"& .ag-header":{borderBottom:`1px solid var(--ag-border-color)`},"& .ag-row":{borderBottom:`1px solid var(--ag-border-color)`},"& .ag-cell":{borderRight:`1px solid var(--ag-border-color)`},"& .ag-header-cell":{borderRight:`1px solid var(--ag-border-color)`},"& .diff-cell-added":{backgroundColor:v?`#1a4d1a !important`:`#cefece !important`,color:`var(--mui-palette-text-primary)`},"& .diff-cell-removed":{backgroundColor:v?`#5c1f1f !important`:`#ffc5c5 !important`,color:`var(--mui-palette-text-primary)`},"& .diff-cell-modified":{backgroundColor:v?`#713F12 !important`:`#FEF3C7 !important`,color:`var(--mui-palette-text-primary)`},"& .diff-header-added":{backgroundColor:`#15803d !important`,color:`white`},"& .diff-header-removed":{backgroundColor:`#f43f5e !important`,color:`white`},"& .diff-header-modified":{backgroundColor:`#f59e0b !important`,color:`white`},"& .index-column":{color:`var(--mui-palette-text-secondary)`,textAlign:`right`},"& .ag-pinned-left-cols-container .ag-cell":{backgroundColor:v?`#2d2d2d`:`#f5f5f5`}},children:U(er,{theme:y,columnDefs:b,rowData:x,getRowId:T,rowHeight:s,headerHeight:c,defaultColDef:C,suppressCellFocus:!0,suppressRowHoverHighlight:!1,animateRows:!1,enableCellTextSelection:!0,ensureDomOrder:!0,rowClass:f,noRowsOverlayComponent:w,onGridReady:e=>{_.current=e.api},...m},E)})}const Fs=ut(Ps);Wn.register(Un,Hn,Kn,Gn,Yn);function Is(e,t){let n=Math.min(t,e.counts.length),r=e.counts.slice(0,n),i=r.reduce((e,t)=>e+t,0),a=e.valids-i,o=r.map((t,n)=>{let r=e.values[n],i,a=!1;return r==null?(i=`(null)`,a=!0):typeof r==`string`&&r.length===0?(i=`(empty)`,a=!0):i=String(r),{label:i,count:t,isSpecial:a}});return a>0&&o.push({label:`(others)`,count:a,isSpecial:!0}),o}function Ls({count:e,total:t,color:n,theme:r=`light`,height:i=16}){let a=r===`dark`,o=ge(a),s=M(a),c=n??s.current,l=z(()=>({labels:[``],datasets:[{indexAxis:`y`,data:[e],backgroundColor:c,hoverBackgroundColor:c,borderWidth:0,borderColor:c,barPercentage:1,categoryPercentage:.6}]}),[e,c]),u=z(()=>({responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{display:!1,max:t,grid:{display:!1},ticks:{color:o.textColor}},y:{display:!1,ticks:{color:o.textColor}}},plugins:{tooltip:{enabled:!1}},animation:!1}),[t,o]);return U(`div`,{style:{height:i,width:`100%`},children:U(Xn,{data:l,options:u})})}const Rs=I(Ls);Rs.displayName=`SingleBarChart`;function zs({data:e,maxItems:t=10,theme:n=`light`,className:r}){let i=M(n===`dark`);return U(G,{className:r,sx:{width:`100%`},children:z(()=>Is(e,t),[e,t]).map(t=>W(ct,{children:[W(G,{sx:{display:`flex`,alignItems:`center`,width:`100%`,"&:hover":{bgcolor:`action.hover`},px:1.5},children:[U(X,{title:t.label,placement:`top-start`,children:U(J,{sx:{width:`14em`,fontSize:`0.875rem`,color:t.isSpecial?`grey.400`:`inherit`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t.label})}),U(G,{sx:{display:`flex`,height:`2em`,width:`10em`},children:U(Rs,{count:t.count,total:e.valids,color:i.current,theme:n})}),U(X,{title:String(t.count),placement:`top-start`,children:U(J,{sx:{ml:2.5,mr:1,fontSize:`0.875rem`,width:`4em`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:Ne(t.count)})}),U(J,{sx:{color:`grey.400`,fontSize:`0.875rem`,width:`4em`},children:Ve(t.count/e.valids)})]}),U(Sn,{})]},t.label))})}const Bs=I(zs);Bs.displayName=`TopKSummaryList`;function Vs({baseData:e,currentData:t,maxItems:n=10,showComparison:r=!1,theme:i=`light`,title:a,className:o}){let s=i===`dark`,c=M(s),l=ge(s),u=z(()=>Is(t,n),[t,n]),d=z(()=>e?Is(e,n):[],[e,n]),f=r&&e&&d.length>0,p=t.valids||1,m=e?.valids||1,h=z(()=>u.map((e,t)=>({current:e,base:f?d[t]??null:null})).filter(({current:e,base:t})=>!(e.label===`(others)`&&e.count===0&&(!t||t.count===0))),[u,d,f]),g=z(()=>{let e=h.map(({current:e})=>e.label),t=[{label:`Current`,data:h.map(({current:e})=>e.count/p),backgroundColor:c.current,hoverBackgroundColor:c.current,borderWidth:0,borderRadius:3,barPercentage:f?.9:1,categoryPercentage:f?.75:.6}];return f&&t.push({label:`Base`,data:h.map(({base:e})=>(e?.count??0)/m),backgroundColor:c.base,hoverBackgroundColor:c.base,borderWidth:0,borderRadius:3,barPercentage:.9,categoryPercentage:.75}),{labels:e,datasets:t}},[h,c,f,p,m]),_=z(()=>({responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,layout:{padding:{right:80}},scales:{x:{display:!1,grid:{display:!1}},y:{grid:{display:!1},ticks:{padding:8,color:e=>h[e.index]?.current.isSpecial?`#9ca3af`:l.textColor}}},plugins:{legend:{display:!!f,position:`top`,align:`center`,reverse:!0,labels:{boxWidth:32,boxHeight:12,borderRadius:3,useBorderRadius:!0,color:l.textColor}},tooltip:{mode:`index`,callbacks:{label:e=>{let t=e.parsed.x??0,n=e.dataset.label===`Base`?m:p,r=Math.round(t*n);return`${e.dataset.label}: ${Ne(r)} (${Ve(t)})`}}}},animation:!1}),[h,l,f,m,p]),v={id:`barLabels`,afterDatasetsDraw(e){let{ctx:t}=e;t.save(),t.font=`11px system-ui, sans-serif`,t.textBaseline=`middle`;let n=ge(s);for(let r=0;r<e.data.datasets.length;r++){let i=e.data.datasets[r],a=i.label===`Base`?m:p,o=e.getDatasetMeta(r);for(let e=0;e<o.data.length;e++){let{x:r,y:s,base:c}=o.data[e],l=i.data[e]??0;if(l===0)continue;let u=Math.round(l*a),d=r-c,f=Ne(u),p=Ve(l)??``,m=t.measureText(f).width;m+8<d?(t.fillStyle=n.barLabelColor,t.textAlign=`left`,t.fillText(f,c+4,s),t.fillStyle=n.secondaryTextColor,t.textAlign=`left`,t.fillText(p,r+4,s)):(t.fillStyle=n.textColor,t.textAlign=`left`,t.fillText(f,r+4,s),t.fillStyle=n.secondaryTextColor,t.fillText(p,r+4+m+4,s))}}t.restore()}},y=h.length*(f?46:32)+(f?30:0);return W(G,{className:o,sx:{width:`100%`,px:2,py:2},children:[a&&U(J,{variant:`subtitle1`,sx:{fontWeight:500,mb:1},children:a}),U(`div`,{style:{height:Math.max(y,50)},children:U(Xn,{data:g,options:_,plugins:[v]})})]})}const Hs=I(Vs);Hs.displayName=`TopKBarChart`;function Us(e){switch(e){case`sql`:return kn();case`yaml`:return An();default:return null}}function Ws(e){return[Nn.theme({"&":{backgroundColor:e?`#1e1e1e`:`#ffffff`,color:e?`#d4d4d4`:`#1f2937`},".cm-content":{caretColor:e?`#d4d4d4`:`#1f2937`,fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,fontSize:`13px`},".cm-gutters":{backgroundColor:e?`#252526`:`#f5f5f5`,color:e?`#858585`:`#6b7280`,border:`none`},".cm-activeLineGutter":{backgroundColor:e?`#2a2d2e`:`#e5e7eb`},".cm-activeLine":{backgroundColor:e?`#2a2d2e40`:`#f3f4f640`},".cm-changedLine":{backgroundColor:e?`#3d3d0050`:`#fff3c550`},".cm-changedText":{backgroundColor:e?`#5c5c0080`:`#fef08a80`},".cm-deletedChunk":{backgroundColor:e?`#5c1f1f50`:`#ffc5c550`},".cm-insertedChunk":{backgroundColor:e?`#1a4d1a50`:`#cefece50`}},{dark:e})]}function Gs({original:e,modified:t,language:n=`text`,readOnly:r=!0,lineNumbers:i=!0,sideBySide:a=!0,height:o=`400px`,theme:s=`light`,onModifiedChange:c,className:l}){let u=B(null),d=B(null),f=s===`dark`;return R(()=>{if(!u.current)return;d.current&&=(d.current instanceof tr,d.current.destroy(),null);let o=[...Ws(f)];i&&o.push(Fn());let s=Us(n);if(s&&o.push(s),r&&o.push(jn.readOnly.of(!0)),c&&!r&&o.push(Nn.updateListener.of(e=>{e.docChanged&&c(e.state.doc.toString())})),a)d.current=new tr({a:{doc:e,extensions:[...o]},b:{doc:t,extensions:[...o]},parent:u.current,orientation:`a-b`,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}});else{let n=[...o,nr({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})];d.current=new Nn({state:jn.create({doc:t,extensions:n}),parent:u.current})}return()=>{d.current&&=(d.current instanceof tr,d.current.destroy(),null)}},[e,t,n,r,i,a,f,c]),U(G,{ref:u,className:l,sx:{height:o,width:`100%`,overflow:`auto`,border:`1px solid`,borderColor:f?`grey.700`:`grey.300`,borderRadius:1,"& .cm-editor":{height:`100%`},"& .cm-scroller":{overflow:`auto`},"& .cm-merge-view":{height:`100%`},"& .cm-merge-view > div":{height:`100%`}}})}const Ks=I(Gs);Ks.displayName=`DiffEditor`;const qs=e=>{let{defaultValues:t,suggestionList:n,onValuesChange:r,className:i}=e,[a,o]=V(t??[]),[s,c]=V(``),[l,u]=V(!1),[d,f]=V(null),p=B(null),m=!!d,h=t=>t.length>1?`${t.length} ${e.unitName}s selected`:t.length===1?t[0]:``,g=e=>{f(e.currentTarget),setTimeout(()=>p.current?.focus(),100)},_=()=>{f(null),u(!1)},v=e=>{a.includes(e)||(c(``),o([...a,e]),r([...a,e]))},y=()=>{c(``),o([]),r([])},b=e=>{o(a.filter(t=>t!==e)),r(a.filter(t=>t!==e))},x=s.toLowerCase(),S=n?.filter(e=>x===``||e.toLowerCase().includes(x)).filter(e=>!a.includes(e))??[],C=()=>{switch(e.size){case`2xs`:return`0.625rem`;case`xs`:return`0.75rem`;case`sm`:return`0.875rem`;default:return`0.875rem`}};return W(G,{sx:{display:`flex`,alignItems:`center`,width:e.width},className:i,children:[W(K,{variant:`outlined`,color:`neutral`,size:`small`,onClick:g,disabled:e.disabled,sx:{width:`100%`,height:(()=>{switch(e.size){case`2xs`:return 24;case`xs`:return 28;case`sm`:return 32;default:return 36}})(),justifyContent:`space-between`,textTransform:`none`,fontSize:C(),fontWeight:`normal`,px:1},children:[U(J,{component:`span`,sx:{fontSize:C(),color:a.length>0?`text.primary`:`text.secondary`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:h(a)||e.placeholder||``}),a.length>0&&U(J,{component:`span`,onClick:e=>{e.stopPropagation(),y()},sx:{fontSize:C(),color:`primary.main`,cursor:`pointer`,ml:1,"&:hover":{textDecoration:`underline`}},children:`Clear`})]}),W(ln,{anchorEl:d,open:m,onClose:_,slotProps:{paper:{sx:{width:e.width,fontSize:C()}}},children:[U(G,{sx:{px:.5,py:.5},children:W(G,{sx:{border:`1px solid`,borderColor:`divider`,borderRadius:1,p:.5,display:`flex`,flexWrap:`wrap`,gap:.5,alignItems:`center`},className:`no-track-pii-safe`,children:[a.map(e=>U(At,{label:e,size:`small`,onDelete:()=>b(e),sx:{height:22,fontSize:C()}},e)),U(ir,{inputRef:p,placeholder:`Filter or add custom keys`,value:s,onChange:e=>{c(e.target.value),u(!0)},onKeyDown:e=>{e.key!==`Escape`&&e.stopPropagation();let t=e.target,n=t.value.trim().replace(`,`,``);switch(e.key){case`,`:case`Enter`:e.preventDefault(),n&&(v(n),c(``));break;case`Backspace`:t.value===``&&a.length>0&&(o(a.slice(0,-1)),r(a.slice(0,-1)));break;default:break}},onBlur:()=>{p.current&&l&&p.current.focus()},sx:{flex:1,minWidth:120,fontSize:C(),"& input":{p:.5}}})]})}),U(Sn,{}),s!==``&&!n?.includes(s)&&W(Z,{onClick:()=>{v(s),u(!1)},sx:{fontSize:C()},children:[`Add '`,s,`' to the list`]}),S.slice(0,10).map((e,t)=>U(Z,{onClick:()=>{v(e)},sx:{fontSize:C()},children:e},ar.uniqueId(`option-${t}`))),S.length>10&&U(X,{title:`Please use filter to find more items`,placement:`top`,children:W(G,{sx:{px:1.5,py:.5,color:`text.secondary`,fontSize:`8pt`},children:[`and `,S.length-10,` more items...`]})})]})]})};function Js({title:e,description:t,icon:n,actionLabel:r,onAction:i,secondaryActionLabel:a,onSecondaryAction:o,theme:s=`light`,paddingY:c=8,className:l,children:u}){let d=s===`dark`;return W(G,{className:l,sx:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,textAlign:`center`,py:c,px:4,height:`100%`,minHeight:200},children:[n&&U(G,{sx:{mb:2,color:d?`grey.500`:`grey.400`,"& svg":{width:48,height:48}},children:n}),U(J,{variant:`h6`,sx:{fontWeight:500,color:d?`grey.300`:`grey.700`,mb:+!!t},children:e}),t&&U(J,{variant:`body2`,sx:{color:d?`grey.400`:`grey.500`,maxWidth:400,mb:r||a?3:0},children:t}),(r||a)&&W(G,{sx:{display:`flex`,gap:2,mt:1},children:[r&&i&&U(K,{variant:`contained`,onClick:i,size:`small`,children:r}),a&&o&&U(K,{variant:`outlined`,onClick:o,size:`small`,children:a})]}),u&&U(G,{sx:{mt:3},children:u})]})}const Ys=I(Js);Ys.displayName=`EmptyState`;function Xs(e,t=60){if(e.length<=t)return e;try{let n=new URL(e),r=n.hostname,i=n.pathname+n.search+n.hash;if(r.length>=t-3)return r.substring(0,t-3)+`...`;let a=t-r.length-3;return i.length>a?`${r}${i.substring(0,a)}...`:e}catch{return e.substring(0,t-3)+`...`}}function Zs({isOpen:e,url:t,onConfirm:n,onCancel:r}){let i=B(null);return W(mt,{open:e,onClose:r,maxWidth:`sm`,fullWidth:!0,"aria-labelledby":`external-link-dialog-title`,children:[W(_t,{id:`external-link-dialog-title`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[U(G,{component:on,sx:{color:`amber.500`,fontSize:20}}),`External Link`]}),U(Y,{"aria-label":`close`,onClick:r,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),W(gt,{children:[U(J,{sx:{mb:1.5},children:`This link will take you to an external website outside of Recce. Are you sure you want to continue?`}),U(G,{sx:{bgcolor:`grey.50`,p:1,borderRadius:1,border:`1px solid`,borderColor:`grey.200`},children:U(G,{component:`code`,sx:{fontSize:`0.875rem`,wordBreak:`break-all`,whiteSpace:`pre-wrap`,bgcolor:`transparent`,fontFamily:`monospace`},children:Xs(t,100)})})]}),W(ht,{sx:{gap:1},children:[U(K,{ref:i,variant:`outlined`,onClick:r,children:`Cancel`}),U(K,{color:`iochmara`,variant:`contained`,onClick:n,children:`Open Link`})]})]})}function Qs(e,t){if(!e||e.startsWith(`/`)||e.startsWith(`#`)||e.startsWith(`?`))return!1;try{let n=new URL(e,window.location.origin);return!t.some(e=>n.hostname===e||n.hostname.endsWith(`.${e}`))}catch{return!1}}function $s({href:e,children:t,internalDomains:n}){let[r,i]=V(!1),[a,o]=V(null),s=t=>{e&&Qs(e,n)&&(t.preventDefault(),o(e),i(!0))},c=()=>{a&&window.open(a,`_blank`,`noopener,noreferrer`),i(!1),o(null)},l=()=>{i(!1),o(null)},u=e?Qs(e,n):!1;return W(H,{children:[W(vt,{href:e,onClick:s,sx:{color:`primary.main`,textDecoration:`underline`,"&:hover":{color:`iochmara.600`}},target:`_blank`,rel:u?`noopener noreferrer`:void 0,children:[t,u&&` ↗`]}),U(Zs,{isOpen:r,url:a||``,onConfirm:c,onCancel:l})]})}function ec({className:e,children:t,isDark:n=!1}){let r=/language-(\w+)/.exec(e||``),i=r?r[1]:void 0,a=String(t).replace(/\n$/,``);return!r&&!String(t).includes(`
6
- `)?U(G,{component:`code`,sx:{bgcolor:n?`grey.800`:`grey.100`,color:n?`grey.200`:`inherit`,px:1,py:.5,borderRadius:.5,fontSize:`0.9em`,fontFamily:`monospace`},children:t}):U(G,{sx:{my:2,borderRadius:1,overflow:`hidden`,fontSize:`0.875rem`},children:U(sr,{style:cr,language:i,PreTag:`div`,customStyle:{margin:0,borderRadius:`6px`,fontSize:`0.85em`},children:a})})}function tc({content:e,fontSize:t=`0.875rem`,internalDomains:n=[]}){let r=P(),i=[window.location.hostname,`reccehq.com`,`datarecce.io`,`localhost`,...n];return U(G,{className:`markdown-content`,children:U(or,{remarkPlugins:[lr],components:{a:({href:e,children:t})=>U($s,{href:e,internalDomains:i,children:t}),code:e=>U(ec,{...e,isDark:r}),p:({children:e})=>U(J,{component:`p`,sx:{fontSize:t,mb:2,"&:last-child":{mb:0}},children:e}),h1:({children:e})=>U(J,{sx:{fontSize:`1.25rem`,fontWeight:`bold`,mb:2,mt:3},children:e}),h2:({children:e})=>U(J,{sx:{fontSize:`1.125rem`,fontWeight:`bold`,mb:2,mt:3},children:e}),h3:({children:e})=>U(J,{sx:{fontSize:`1rem`,fontWeight:600,mb:2,mt:2},children:e}),ul:({children:e})=>U(G,{component:`ul`,sx:{pl:4,mb:2,listStyleType:`disc`},children:e}),ol:({children:e})=>U(G,{component:`ol`,sx:{pl:4,mb:2,listStyleType:`decimal`},children:e}),li:({children:e})=>U(G,{component:`li`,sx:{fontSize:t,mb:1},children:e}),blockquote:({children:e})=>U(G,{sx:{borderLeft:`3px solid`,borderLeftColor:r?`grey.600`:`grey.300`,pl:3,py:1,my:2,color:r?`grey.400`:`grey.600`,fontStyle:`italic`},children:e}),table:({children:e})=>U(G,{sx:{overflowX:`auto`,my:2},children:U(G,{component:`table`,sx:{width:`100%`,fontSize:t,border:`1px solid`,borderColor:r?`grey.700`:`grey.200`,borderRadius:1},children:e})}),thead:({children:e})=>U(G,{component:`thead`,sx:{bgcolor:r?`grey.800`:`grey.50`},children:e}),tbody:({children:e})=>U(G,{component:`tbody`,children:e}),tr:({children:e})=>U(G,{component:`tr`,sx:{borderBottom:`1px solid`,borderColor:r?`grey.700`:`grey.200`},children:e}),th:({children:e})=>U(G,{component:`th`,sx:{px:2,py:1,fontWeight:600,textAlign:`left`},children:e}),td:({children:e})=>U(G,{component:`td`,sx:{px:2,py:1},children:e}),hr:()=>U(G,{component:`hr`,sx:{my:3,borderColor:r?`grey.700`:`grey.200`}}),strong:({children:e})=>U(J,{component:`strong`,sx:{fontWeight:600},children:e}),em:({children:e})=>U(J,{component:`em`,sx:{fontStyle:`italic`},children:e}),del:({children:e})=>U(J,{component:`del`,sx:{textDecoration:`line-through`,color:`grey.500`},children:e})},children:e})})}const nc=ut(function({backgroundColor:e=`white`,blockSize:t,children:n,...r},i){return U(G,{ref:i,...r,sx:{overflowY:`auto`,overflowX:`hidden`,...r.sx},children:U(G,{sx:{backgroundColor:e,height:`100%`,blockSize:t},children:n})})});function rc({children:e,direction:t=`horizontal`,sizes:n,minSizes:r=0,maxSizes:i,gutterSize:a=5,snapOffset:o=30,dragInterval:s=1,onDragEnd:c,onDrag:l,theme:u,style:d,className:f}){let p=P(),m=u?u===`dark`:p,h={display:`flex`,flexDirection:t===`horizontal`?`row`:`column`,height:`100%`,width:`100%`,...d};return U(G,{className:f,sx:{height:`100%`,width:`100%`,"& .gutter":{backgroundColor:`divider`,backgroundRepeat:`no-repeat`,backgroundPosition:`50%`,transition:`background-color 0.15s ease`,"&:hover":{backgroundColor:m?`grey.600`:`grey.300`}},"& .gutter.gutter-horizontal":{cursor:`col-resize`},"& .gutter.gutter-vertical":{cursor:`row-resize`}},children:U(ur,{style:h,direction:t,sizes:n,minSize:r,maxSize:i,gutterSize:a,snapOffset:o,dragInterval:s,onDragEnd:c,onDrag:l,children:e})})}const ic=I(rc);ic.displayName=`SplitPane`;function ac(e){let{style:t,children:n,gutterSize:r=5,minSize:i,maxSize:a,sizes:o,snapOffset:s,dragInterval:c,onDragEnd:l,onDrag:u,className:d}=e;return U(ic,{direction:`horizontal`,gutterSize:r,minSizes:i,maxSizes:a,sizes:o,snapOffset:typeof s==`number`?s:void 0,dragInterval:c,onDragEnd:l,onDrag:u,style:t,className:d,children:n})}function oc(e){let{style:t,children:n,gutterSize:r=5,minSize:i,maxSize:a,sizes:o,snapOffset:s,dragInterval:c,onDragEnd:l,onDrag:u,className:d}=e;return U(ic,{direction:`vertical`,gutterSize:r,minSizes:i,maxSizes:a,sizes:o,snapOffset:typeof s==`number`?s:void 0,dragInterval:c,onDragEnd:l,onDrag:u,style:t,className:d,children:n})}const sc={mode:`multiRow`,checkboxes:!0,headerCheckbox:!0,enableClickSelection:!1};function cc({warning:e,isDark:t}){return W(G,{sx:{display:`flex`,alignItems:`center`,gap:.5,fontSize:`0.75rem`},children:[U(on,{color:t?dr[400]:dr[600]}),U(G,{children:e})]})}function lc({toolbar:e,warnings:t,warningStyle:n=`alert`,isDark:r}){return!e&&(!t||t.length===0)?null:W(G,{sx:{display:`flex`,alignItems:`center`,gap:1,px:1,py:.5,borderBottom:1,borderColor:`divider`,bgcolor:n===`amber`&&t&&t.length>0?r?dr[900]:dr[100]:r?`grey.900`:`grey.50`,color:n===`amber`&&t&&t.length>0?r?dr[200]:dr[800]:void 0},children:[n===`amber`?t?.map(e=>U(cc,{warning:e,isDark:r},e)):t?.map(e=>U(Qn,{severity:`warning`,sx:{py:0,fontSize:`0.75rem`},children:e},e)),U(G,{sx:{flex:1}}),e]})}function $(e){let{displayName:t,typeGuard:n,expectedRunType:r,screenshotWrapper:i,transformData:a,emptyState:o=`No data`,conditionalEmptyState:s,enableRowSelection:c}=e;function l({run:e,viewOptions:t,onViewOptionsChanged:l,onAddToChecklist:u},d){let f=P();if(!n(e))throw Error(`Run type must be ${r}`);let p=z(()=>a(e,{viewOptions:t,onViewOptionsChanged:l,onAddToChecklist:u,isDark:f}),[e,t,l,u,f]),m=s?.(e,t);return m==null?p?.renderNull?null:!p||p.isEmpty?p?.toolbar||p?.warnings&&p.warnings.length>0?W(G,{sx:{display:`flex`,flexDirection:`column`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:[U(lc,{toolbar:p?.toolbar,warnings:p?.warnings,warningStyle:p?.warningStyle,isDark:f}),U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,flex:1},children:p?.emptyMessage??o})]}):U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:o}):i===`grid`?W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[p.header,U(lc,{toolbar:p.toolbar,warnings:p.warnings,warningStyle:p.warningStyle,isDark:f}),U(Fs,{ref:d,style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`0.875rem`,borderWidth:1},columns:p.columns??[],rows:p.rows??[],renderers:{noRowsFallback:U(Ns,{emptyMessage:p.noRowsMessage})},defaultColumnOptions:p.defaultColumnOptions,rowSelection:c?sc:void 0}),p.footer]}):W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[p.header,U(lc,{toolbar:p.toolbar,warnings:p.warnings,warningStyle:p.warningStyle,isDark:f}),U(nc,{ref:d,backgroundColor:f?`#1f2937`:`white`,sx:{height:`100%`},children:p.content}),p.footer]}):U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:m})}return l.displayName=t,ut(l)}const uc=`0.1.0`;function dc(e){return u(e)}const fc=$({displayName:`HistogramDiffResultView`,typeGuard:dc,expectedRunType:`histogram_diff`,screenshotWrapper:`box`,conditionalEmptyState:e=>{let t=e.result?.base,n=e.result?.current;return!t||!n?U(`div`,{children:`Loading...`}):null},transformData:(e,{isDark:t})=>{let n=e.params,r=e.result?.base,i=e.result?.current,a=e.result?.min,o=e.result?.max,s=e.result?.bin_edges??[];if(!r||!i)return{isEmpty:!0};let c=e.params?.column_type??`numeric`,l=c===`datetime`?`datetime`:c===`string`?`string`:`numeric`;return{content:W(G,{sx:{display:`flex`,flexDirection:`row`},children:[U(G,{sx:{flex:1}}),U(G,{sx:{width:`80%`,height:`35vh`,m:4},children:U(js,{title:`Model ${n.model}.${n.column_name}`,dataType:l,baseData:{counts:r.counts},currentData:{counts:i.counts},min:a,max:o,samples:r.total,binEdges:s,theme:t?`dark`:`light`})}),U(G,{sx:{flex:1}})]})}}});function pc(e,t){if(e.baseIndex===void 0&&e.currentIndex!==void 0)return`added`;if(e.baseIndex!==void 0&&e.currentIndex===void 0)return`removed`;let n=e.baseType!==e.currentType,r=e.definitionChanged===!0||e.reordered===!0;return n&&!r&&t&&e.changeUnknown!==!0?`impacted`:n||r?`changed`:e.changeUnknown===!0?`unknown`:t?`impacted`:`unchanged`}function mc({model:e,row:t,singleEnv:n,cllRunning:r,showMenu:i=!0,onViewCode:a,isImpacted:o}){let s=ue(),{isActionAvailable:c}=pe(),{runAction:l}=j(),{featureToggles:u}=ae(),{name:d,baseType:f,currentType:p,baseIndex:m,currentIndex:h,definitionChanged:g}=t,_=p??f??t.type,v=!(m===void 0&&h!==void 0)&&!(m!==void 0&&h===void 0)&&f!==p,y=n?`unchanged`:pc(t,o),b=y===`added`?`added`:y===`removed`?`removed`:y===`unknown`?`definition_unknown`:(y===`changed`||y===`impacted`)&&v?`type_changed`:y===`changed`&&g?`definition_changed`:`unchanged`,[x,S]=V(null),C=!!x,w=e=>{e.stopPropagation(),S(e.currentTarget)},T=()=>{S(null)},E=()=>{l(`profile_diff`,{model:e.name,columns:[d]},{showForm:!1,trackProps:{action:`profile_diff`,source:`schema_column_menu`,node_count:1}})},ee=()=>{l(`histogram_diff`,{model:e.name,column_name:d,column_type:_},{showForm:!1,trackProps:{action:`histogram_diff`,source:`schema_column_menu`,node_count:1}})},D=()=>{l(`top_k_diff`,{model:e.name,column_name:d,k:50},{showForm:!1,trackProps:{action:`top_k_diff`,source:`schema_column_menu`,node_count:1}})},O=()=>{l(`value_diff`,{model:e.name,columns:[d]},{showForm:!0,trackProps:{action:`value_diff`,source:`schema_column_menu`,node_count:1}})},k=!f||!p;return U(X,{title:oi({name:d,status:b,baseType:f,currentType:p,cllAvailable:!(s===void 0||!c(`change_analysis`)||m!==void 0&&h===void 0),impacted:y===`impacted`}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`3px`},children:[y===`changed`&&(g?U(X,{title:`Definition changed — click to view code`,placement:`top`,onMouseOver:e=>e.stopPropagation(),children:a?U(`button`,{type:`button`,className:`schema-change-badge schema-change-badge-changed schema-change-badge-clickable`,onClick:e=>{e.stopPropagation(),a()},children:`~`}):U(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`})}):U(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`})),y===`added`&&U(`span`,{className:`schema-change-badge schema-change-badge-added`,children:`+`}),y===`removed`&&U(`span`,{className:`schema-change-badge schema-change-badge-removed`,children:`-`}),y===`impacted`&&U(`span`,{className:`schema-change-badge schema-change-badge-impacted`,children:`!`}),y===`unknown`&&U(X,{title:`Change status unknown — analyzer couldn't resolve column dependencies`,placement:`top`,onMouseOver:e=>e.stopPropagation(),children:U(`span`,{className:`schema-change-badge schema-change-badge-unknown`,children:`?`})}),U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:d}),v?W(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:`0.125rem`,ml:`0.25rem`,fontSize:`1.6rem`,lineHeight:1},children:[f&&U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,textDecoration:`line-through`,opacity:.6},children:U(ci,{type:f,disableTooltip:!0})}),U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,fontSize:`0.7em`,opacity:.5},children:`→`}),p&&U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`},children:U(ci,{type:p,disableTooltip:!0})})]}):_&&U(G,{component:`span`,sx:{ml:`0.25rem`,fontSize:`1.6rem`},children:U(ci,{type:_,disableTooltip:!0})}),U(G,{sx:{flex:1}}),r&&U(pn,{size:12,color:`inherit`}),i&&!n&&e.resource_type!==`source`&&W(H,{children:[U(Y,{"aria-label":`Column options`,className:`row-context-menu`,size:`small`,disabled:u.disableDatabaseQuery,onClick:w,children:U(dn,{})}),W(ln,{anchorEl:x,open:C,onClose:T,slotProps:{list:{sx:{lineHeight:`20px`}}},children:[U(mn,{sx:{m:0,p:`4px 12px`,lineHeight:`20px`},children:`Diff`}),U(Z,{onClick:()=>{E(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Profile Diff`}),U(Z,{onClick:()=>{ee(),T()},disabled:k||(_?!Ra(_):!0),sx:{fontSize:`0.85rem`},children:`Histogram Diff`}),U(Z,{onClick:()=>{D(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Top-k Diff`}),U(Z,{onClick:()=>{O(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Value Diff`})]})]})]})})}function hc(e,t,n,r){return i=>{let a=i.data;return a?U(mc,{model:e,row:a,cllRunning:t?.get(a.name)??!1,showMenu:n,onViewCode:r,isImpacted:a.isImpacted}):null}}function gc(e,t,n){return r=>{let i=r.data;return i?U(mc,{model:e,row:i,cllRunning:t?.get(i.name)??!1,singleEnv:!0,showMenu:n}):null}}function _c(e){let t=e.scopedColumns?new Set(e.scopedColumns):void 0;return n=>{let r=n.data;if(!r)return null;let i=e.payloads[r.name],a=!t||t.has(r.name);return U(Pa,{payload:i,columnType:r.currentType??r.baseType,baseTotal:e.baseTotal,currentTotal:e.currentTotal,isLoading:e.isLoading&&!i&&a,hasError:e.hasError&&a,notProfiled:!a})}}function vc(e){if(!e.data)return null;let{baseIndex:t,currentIndex:n,reordered:r}=e.data;return r&&t!==void 0&&n!==void 0&&t!==n?W(`span`,{children:[U(`span`,{className:`schema-index-old`,children:t}),U(`span`,{className:`schema-index-new`,children:n})]}):U(`span`,{children:n===void 0?t??`-`:n??`-`})}function yc(e={},t={}){let n={},r=Me(Object.keys(e),Object.keys(t));Object.entries(r).forEach(([e,t])=>{n[e]={name:e,reordered:t===`reordered`,__status:void 0}});let i=0;return Object.entries(e).forEach(([e,t])=>{t!=null&&(n[e].baseIndex=i+=1,n[e].baseType=t.type)}),i=0,Object.entries(t).forEach(([e,t])=>{t!=null&&(n[e].currentIndex=i+=1,n[e].currentType=t.type)}),n}function bc(e,t={}){let{node:n,cllRunningMap:r,showMenu:i,columnChanges:a,onViewCode:o,impactedColumns:s,nodeId:c,distribution:l}=t,u=[{field:`index`,headerName:``,resizable:!0,minWidth:35,width:35,cellRenderer:vc,cellClass:`schema-column schema-column-index`},{field:`name`,headerName:`Name`,resizable:!0,flex:1,minWidth:180,cellRenderer:n?hc(n,r,i,o):void 0,cellClass:`schema-column`,valueGetter:e=>{let t=e.data;return t?`${t.name}|${t.definitionChanged??!1}|${t.isImpacted??!1}|${t.changeUnknown??!1}`:``}}];l&&u.push({colId:`distribution`,headerName:`Distribution`,resizable:!0,sortable:!1,minWidth:150,width:160,cellRenderer:_c(l),cellClass:`schema-column schema-column-profile-distribution`});let d=Object.values(e);if(a)for(let e of d){let t=e.baseIndex===void 0,n=e.currentIndex===void 0,r=!t&&!n&&e.baseType!==e.currentType,i=a[e.name];i===`modified`&&!t&&!n&&!r&&!e.reordered?e.definitionChanged=!0:i===`unknown`&&!t&&!n&&!r&&!e.reordered&&(e.changeUnknown=!0)}if(c&&s)for(let e of d)Ee(c,e.name,s)&&(e.isImpacted=!0);return{columns:u,rows:d}}function xc(e={},t={}){let{node:n,cllRunningMap:r,showMenu:i}=t,a=Object.entries(e).filter(([e,t])=>t!=null).map(([e,t],n)=>({name:e,index:n+1,type:t.type,__status:void 0}));return{columns:[{field:`index`,headerName:``,resizable:!0,minWidth:35,width:35,cellClass:`schema-column schema-column-index`},{field:`name`,headerName:`Name`,resizable:!0,flex:1,minWidth:180,cellRenderer:n?gc(n,r,i):void 0,cellClass:`schema-column`}],rows:a}}function Sc({columnName:e,primaryKeys:t}){return U(G,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`},children:t.includes(e)&&U(fn,{})})}function Cc({params:e,column:t}){let{runAction:n}=j(),{featureToggles:r}=ae(),[i,a]=V(null),o=!!i,s=e=>{a(e.currentTarget)},c=()=>{a(null)},l=(t,r)=>{n(`value_diff_detail`,{...e,...t},r)};return W(G,{sx:{display:`flex`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t}),U(G,{sx:{flex:1}}),U(Y,{"aria-label":`Column options`,className:`row-context-menu`,size:`small`,disabled:r.disableDatabaseQuery,onClick:s,children:U(Jt,{})}),W(ln,{anchorEl:i,open:o,onClose:c,slotProps:{list:{sx:{lineHeight:`20px`}}},children:[U(mn,{sx:{fontSize:`8pt`,lineHeight:`20px`},children:`Action`}),U(Z,{onClick:()=>{l({},{showForm:!0}),c()},sx:{fontSize:`10pt`},children:`Show mismatched values...`}),W(Z,{onClick:()=>{l({columns:[t]},{showForm:!1}),c()},sx:{fontSize:`10pt`},children:[`Show mismatched values for '`,t,`'`]})]})]})}function wc({value:e}){let t=`N/A`;return e!=null&&(t=e>.9999&&e<1?`~99.99 %`:e<1e-4&&e>0?`~0.01 %`:`${(e*100).toFixed(2)} %`),U(G,{sx:{textAlign:`right`},children:t})}function Tc(e){return t=>{let n=t.data;return n?U(Sc,{columnName:String(n[0]),primaryKeys:e}):null}}function Ec(e){return t=>{let n=t.data,r=t.colDef?.field??``;return n?U(Cc,{column:String(n[r]),params:e}):null}}function Dc(e){let t=e.data,n=e.colDef?.field??``;return t?U(wc,{value:t[n]}):null}const Oc=[{key:`0`,name:`Column`,type:`text`},{key:`1`,name:`Matched`,type:`number`},{key:`2`,name:`Matched %`,type:`number`}];function kc(e){let t=e.data;if(!t)return;let n=t[2];return n!=null&&n<1?`diff-cell-modified`:void 0}function Ac(e,t){let n=e==null,r=t==null;return n&&r?0:n?1:r?-1:e-t}const jc={PRIMARY_KEY_INDICATOR:`__is_pk__`,COLUMN_NAME:`0`,MATCHED_COUNT:`1`,MATCHED_PERCENT:`2`};function Mc(e,t){return[{field:jc.PRIMARY_KEY_INDICATOR,headerName:``,width:30,maxWidth:30,sortable:!1,cellRenderer:Tc(e)},{field:jc.COLUMN_NAME,headerName:`Column`,resizable:!0,cellRenderer:Ec(t),cellClass:`cell-show-context-menu`},{field:jc.MATCHED_COUNT,headerName:`Matched`,resizable:!0,cellClass:kc},{field:jc.MATCHED_PERCENT,headerName:`Matched %`,resizable:!0,sort:`asc`,comparator:Ac,cellRenderer:Dc,cellClass:kc}]}function Nc(e,t){let{params:n}=t,r=Array.isArray(n.primary_key)?n.primary_key:[n.primary_key],i={...e.data,columns:Oc};return{columns:Mc(r,n),rows:We(i)}}function Pc(e){if(p(e)||y(e))return e.result?{kind:`query`,result:e.result}:null;if(w(e))return e.result?e.result.diff&&e.params?.primary_keys?{kind:`query_diff_joined`,result:e.result,primaryKeys:e.params.primary_keys}:{kind:`query_diff_separate`,result:e.result}:null;if(ee(e))return!e.result||!e.params?null:{kind:`value_diff`,result:e.result,params:e.params};if(T(e)){if(!e.result||!e.params?.primary_key)return null;let t=e.params.primary_key,n=Array.isArray(t)?t:[t];return{kind:`value_diff_detail`,result:e.result,primaryKeys:n}}return f(e)?e.result?.current?{kind:`profile`,result:e.result}:null:S(e)?e.result?{kind:`profile_diff`,result:e.result}:null:b(e)?e.result?{kind:`row_count`,result:e.result}:null:g(e)&&e.result?{kind:`row_count_diff`,result:e.result}:null}function Fc(e){let t=e.data;if(!t)return null;let n=e.colDef?.field??``,r=String(ze(t,n)??e.value??``),i=String(ze(t,`data_type`)??``)||void 0;return U(X,{title:oi({name:r,currentType:i}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`6px`,overflow:`hidden`,height:`100%`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&U(G,{component:`span`,sx:{fontSize:`1.6rem`},children:U(ci,{type:i,disableTooltip:!0})})]})})}function Ic(e){let t=e.data;if(!t)return null;let n=e.colDef?.field??``,r=String(ze(t,n)??e.value??``),i=ze(t,`base__data_type`),a=i==null?void 0:String(i),o=ze(t,`current__data_type`),s=o==null?void 0:String(o),c=a!=null&&s!=null&&a!==s,l=s??a;return U(X,{title:oi({name:r,baseType:a,currentType:s}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`6px`,overflow:`hidden`,height:`100%`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),c?W(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:`0.125rem`,fontSize:`1.6rem`},children:[U(G,{component:`span`,sx:{textDecoration:`line-through`,opacity:.6},children:U(ci,{type:a,disableTooltip:!0})}),U(G,{component:`span`,sx:{fontSize:`0.7em`,opacity:.5},children:`→`}),U(ci,{type:s,disableTooltip:!0})]}):l&&U(G,{component:`span`,sx:{fontSize:`1.6rem`},children:U(ci,{type:l,disableTooltip:!0})})]})})}function Lc(e){if(!e)return!1;let t=e.toLowerCase();return t===`data_type`||t===`base__data_type`||t===`current__data_type`}function Rc(e){let t=e.rows.length>0&&Object.hasOwn(e.rows[0],`base__data_type`),n=e.columns.filter(e=>{if(`children`in e&&e.children){let t=e.children.filter(e=>!Lc(e.field));return t.length===0?!1:(e.children=t,!0)}return!Lc(e.field)}).map(e=>{if(`children`in e&&e.children)return{...e,children:e.children.map(e=>{let t=e;return t.field?.toLowerCase()===`column_name`?{...t,cellRenderer:Fc}:e})};let n=e;return n.field?.toLowerCase()===`column_name`?{...n,cellRenderer:t?Ic:Fc}:e});return{...e,columns:n}}function zc(e){return e.current?.columns.find(e=>e.name.toLowerCase()===`column_name`)?.name??`column_name`}function Bc(e,t={}){let n=Pc(e);if(!n)return null;switch(n.kind){case`query`:return De(n.result,{primaryKeys:t.primaryKeys,pinnedColumns:t.pinnedColumns,columnsRenderMode:t.columnsRenderMode,onPrimaryKeyChange:t.onPrimaryKeyChange,onPinnedColumnsChange:t.onPinnedColumnsChange,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged});case`query_diff_separate`:return qe(n.result.base,n.result.current,t);case`query_diff_joined`:return n.result.diff?Ke(n.result.diff,n.primaryKeys,{changedOnly:t.changedOnly,pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,baseTitle:t.baseTitle,currentTitle:t.currentTitle,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}):null;case`value_diff`:return Nc(n.result,{params:n.params});case`value_diff_detail`:return Ke(n.result,n.primaryKeys,{changedOnly:t.changedOnly,pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged});case`profile`:{if(!n.result.current)return null;let e=zc(n.result);return Rc(De(n.result.current,{primaryKeys:[e],pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}))}case`profile_diff`:{let e=zc(n.result);return Rc(qe(n.result.base,n.result.current,{primaryKeys:[e],pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}))}case`row_count`:return je(n.result);case`row_count_diff`:return Ge(n.result);default:return null}}function Vc(e,t){switch(e.type){case`single`:return De(e.dataframe,t??{});case`dual`:return qe(e.base,e.current,t??{});case`joined`:return Ke(e.dataframe,e.primaryKeys,t??{});case`schema_diff`:{let n=t??{};return bc(yc(e.base,e.current),n)}case`schema_single`:return xc(e.columns,t??{})}}function Hc({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let[r,i]=V(!e.columns||e.columns.length===0),a=e.model,{columns:o,isLoading:s,error:c}=Mu(e.model);R(()=>{n(!!a)},[a,n]);let l=o.map(e=>e.name);return s?U(G,{children:`Loading...`}):l.length===0||c?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):W(q,{spacing:5,sx:{m:`8px 24px`,pb:`200px`},children:[W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Model`}),U(yn,{fullWidth:!0,size:`small`,value:e.model,slotProps:{input:{readOnly:!0}}})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Columns`}),U(zt,{control:U(Rt,{checked:r,onChange:n=>{i(n.target.checked),t({...e,columns:void 0})},size:`small`}),label:`All columns`,sx:{mb:`10px`}}),!r&&U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:l,value:e.columns??[],onChange:(n,r)=>{t({...e,columns:r.length===0?void 0:r})},renderInput:t=>U(yn,{...t,placeholder:(e.columns??[]).length===0?`Select columns`:``,className:`no-track-pii-safe`})})]})]})}const Uc=e=>typeof e==`object`&&!!e&&`type`in e&&S(e),Wc=$({displayName:`ProfileResultView`,typeGuard:e=>typeof e==`object`&&!!e&&`type`in e&&f(e),expectedRunType:`profile`,screenshotWrapper:`grid`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=Bc(e,{pinnedColumns:t?.pinned_columns??[],onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},columnsRenderMode:{distinct_proportion:`percent`,not_null_proportion:`percent`,...t?.columnsRenderMode},onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})}})??{columns:[],rows:[]};return{columns:r.columns,rows:r.rows,isEmpty:r.columns.length===0}}}),Gc=$({displayName:`ProfileDiffResultView`,typeGuard:Uc,expectedRunType:`profile_diff`,screenshotWrapper:`grid`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=t?.pinned_columns??[],i=t?.display_mode??`inline`,a=Bc(e,{pinnedColumns:r,onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},displayMode:i,columnsRenderMode:{distinct_proportion:`percent`,not_null_proportion:`percent`,...t?.columnsRenderMode},onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})}})??{columns:[],rows:[]},o=U(Os,{children:U(ua,{displayMode:i,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}})});return{columns:a.columns,rows:a.rows,header:o,isEmpty:a.columns.length===0}}});function Kc(e){return w(e)}const qc=$({displayName:`QueryDiffResultView`,typeGuard:Kc,expectedRunType:`query_diff`,screenshotWrapper:`grid`,enableRowSelection:!0,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=e.result&&`diff`in e.result&&e.result.diff!=null,i,a;e.params&&e.params.current_model&&(i=`Original`,a=`Editor`);let o=t?.changed_only??!1,s=t?.pinned_columns??[],c=t?.display_mode??`inline`,l=t?.columnsRenderMode??{},u=r?[]:t?.primary_keys??[],d=e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},f=r?void 0:e=>{n&&n({...t,primary_keys:e})},p=e=>{n&&n({...t,pinned_columns:e})},m;if(r&&e.result?.diff){let t=e.params?.primary_keys??[];m=Ke(e.result.diff,t,{changedOnly:o,pinnedColumns:s,onPinnedColumnsChange:p,columnsRenderMode:l,onColumnsRenderModeChanged:d,baseTitle:i,currentTitle:a,displayMode:c})}else m=qe(e.result?.base,e.result?.current,{changedOnly:o,pinnedColumns:s,onPinnedColumnsChange:p,columnsRenderMode:l,onColumnsRenderModeChanged:d,baseTitle:i,currentTitle:a,displayMode:c,primaryKeys:u,onPrimaryKeyChange:f});let h=[];if(!r&&u.length>0){let e=u.join(`, `);m.invalidPKeyBase&&m.invalidPKeyCurrent?h.push(`Warning: The primary key '${e}' is not unique in the base and current environments`):m.invalidPKeyBase?h.push(`Warning: The primary key '${e}' is not unique in the base environment`):m.invalidPKeyCurrent&&h.push(`Warning: The primary key '${e}' is not unique in the current environment`)}let g=r?e.result?.diff?.limit??0:e.result?.current?.limit??0,_=r?e.result?.diff?.more:e.result?.current?.more||e.result?.base?.more;if(g>0&&_&&h.push(`Warning: Displayed results are limited to ${g.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`),m.columns.length===0)return{isEmpty:!0};let v=W(H,{children:[U(ua,{displayMode:c,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}}),U(ca,{changedOnly:t?.changed_only,onChange:()=>{let e=!t?.changed_only;n&&n({...t,changed_only:e})}})]});return r&&o&&m.rows.length===0?{isEmpty:!0,emptyMessage:`No change`,toolbar:v,warnings:h.length>0?h:void 0}:{columns:m.columns,rows:m.rows,warnings:h.length>0?h:void 0,toolbar:v,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},noRowsMessage:`No mismatched rows`}}});function Jc(e){return p(e)||y(e)}const Yc=$({displayName:`QueryResultView`,typeGuard:Jc,expectedRunType:`query`,screenshotWrapper:`grid`,enableRowSelection:!0,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n,onAddToChecklist:r})=>{let i=t?.pinned_columns??[],a=t?.columnsRenderMode??{},o=e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},s=e=>{n&&n({...t,pinned_columns:e})};if(!e.result)return{isEmpty:!0};let c=De(e.result,{pinnedColumns:i,onPinnedColumnsChange:s,columnsRenderMode:a,onColumnsRenderModeChanged:o});if(c.columns.length===0)return{isEmpty:!0};let l=e.result,u=l?l.limit??0:0,d=[];u>0&&l?.more&&d.push(`Warning: Displayed results are limited to ${u.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`);let f=r?U(K,{sx:{my:`5px`},size:`small`,color:`iochmara`,variant:`contained`,onClick:()=>{r(e)},children:`Add to Checklist`}):void 0;return{columns:c.columns,rows:c.rows,warnings:d.length>0?d:void 0,warningStyle:`amber`,toolbar:f,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35}}}});function Xc(e){return b(e)}function Zc(e){return g(e)}function Qc(e){if(!e.result)return null;let t=je(e.result);return{columns:t.columns,rows:t.rows,isEmpty:t.rows.length===0}}function $c(e){if(!e.result)return null;let t=Ge(e.result);return{columns:t.columns,rows:t.rows,isEmpty:t.rows.length===0}}const el=$({displayName:`RowCountResultView`,typeGuard:Xc,expectedRunType:`row_count`,screenshotWrapper:`grid`,transformData:Qc,emptyState:`No nodes matched`}),tl=$({displayName:`RowCountDiffResultView`,typeGuard:Zc,expectedRunType:`row_count_diff`,screenshotWrapper:`grid`,transformData:$c,emptyState:`No nodes matched`});function nl({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let{columns:r,isLoading:i,error:a}=Mu(e.model),o=r.map(e=>e.name);return R(()=>{n(!!e.column_name)},[e,n]),i?U(G,{children:`Loading...`}):o.length===0||a?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):U(G,{sx:{m:`16px`},children:W(hn,{fullWidth:!0,children:[U(gn,{sx:{mb:1},children:`Pick a column to show top-k`}),W(_n,{value:e.column_name,onChange:n=>{let r=n.target.value;t({...e,column_name:r})},children:[U(`option`,{value:``,children:`Select column`}),o.map(e=>U(`option`,{value:e,className:`no-track-pii-safe`,children:e},e))]})]})})}function rl(e){return _(e)}function il({model:e,columnName:t}){return W(J,{variant:`h5`,sx:{pt:4,textAlign:`center`,color:P()?`grey.200`:`grey.600`},children:[`Model `,e,`.`,t]})}function al({showAll:e,onToggle:t}){return U(G,{sx:{display:`flex`,p:5,justifyContent:`start`},children:U(vt,{component:`button`,onClick:t,sx:{color:`iochmara.main`,cursor:`pointer`},children:e?`View Only Top-10`:`View More Items`})})}function ol(e,{viewOptions:t,onViewOptionsChanged:n,isDark:r}){let i=e.result,a=e.params;if(!i)return{isEmpty:!0};let o=i.base,s=i.current,c=t?.show_all??!1,l=!c,u=o.values.length>10||s.values.length>10?U(al,{showAll:c,onToggle:()=>{n&&n({...t,show_all:!c})}}):void 0;return{content:W(H,{children:[U(il,{model:a.model,columnName:a.column_name}),W(q,{direction:`row`,sx:{alignItems:`center`},children:[U(G,{sx:{flex:1}}),U(Hs,{baseData:o,currentData:s,showComparison:!0,maxItems:l?10:void 0,theme:r?`dark`:`light`}),U(G,{sx:{flex:1}})]})]}),footer:u}}const sl=$({displayName:`TopKDiffResultView`,typeGuard:rl,expectedRunType:`top_k_diff`,screenshotWrapper:`box`,emptyState:`No data`,transformData:ol});function cl(e){return T(e)}const ll=$({displayName:`ValueDiffDetailResultView`,typeGuard:cl,expectedRunType:`value_diff_detail`,screenshotWrapper:`grid`,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=t?.changed_only??!1,i=t?.pinned_columns??[],a=t?.display_mode??`inline`,o=t?.columnsRenderMode??{},s=e.params?.primary_key;if(!s||!e.result)return{isEmpty:!0};let c=Array.isArray(s)?s:[s],l=Ke(e.result,c,{changedOnly:r,pinnedColumns:i,onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},columnsRenderMode:o,onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},displayMode:a});if(l.columns.length===0)return{isEmpty:!0};let u=e.result?.limit??0,d=[];u>0&&e.result?.more&&d.push(`Warning: Displayed results are limited to ${u.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`);let f=W(H,{children:[U(ua,{displayMode:a,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}}),U(ca,{changedOnly:t?.changed_only,onChange:()=>{let e=!t?.changed_only;n&&n({...t,changed_only:e})}})]});return r&&l.rows.length===0?{isEmpty:!0,emptyMessage:`No change`,toolbar:f,warnings:d.length>0?d:void 0,warningStyle:`amber`}:{columns:l.columns,rows:l.rows,warnings:d.length>0?d:void 0,warningStyle:`amber`,toolbar:f,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},noRowsMessage:`No mismatched rows`}}});function ul({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let[r,i]=V(!e.columns||e.columns.length===0),a=e.model,o=e.primary_key,{columns:s,primaryKey:c,isLoading:l,error:u}=Mu(e.model);R(()=>{!o&&c&&t({...e,primary_key:c})},[o,c,e,t]),R(()=>{n(!!(o&&a))},[o,a,n]);let d=s.map(e=>e.name),f=Array.isArray(o)?o:o?[o]:void 0;return l?U(G,{children:`Loading...`}):d.length===0||u?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):W(q,{spacing:5,sx:{m:`8px 24px`,pb:`200px`},children:[W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Model`}),U(yn,{fullWidth:!0,size:`small`,value:e.model,slotProps:{input:{readOnly:!0}}})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Primary key`}),U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:d,value:(f??[]).filter(e=>e!==void 0),onChange:(n,r)=>{t({...e,primary_key:r.length===1?r[0]:r})},renderInput:e=>U(yn,{...e,placeholder:(f??[]).length===0?`Select primary key`:``,className:`no-track-pii-safe`})})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Columns`}),U(zt,{control:U(Rt,{checked:r,onChange:n=>{i(n.target.checked),t({...e,columns:void 0})},size:`small`}),label:`All columns`,sx:{mb:`10px`}}),!r&&U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:d,value:e.columns??[],onChange:(n,r)=>{t({...e,columns:r.length===0?void 0:r})},renderInput:t=>U(yn,{...t,placeholder:(e.columns??[]).length===0?`Select columns`:``,className:`no-track-pii-safe`})})]})]})}function dl(e){return ee(e)}function fl({params:e,summary:t}){let n=t.total-t.added-t.removed;return W(G,{sx:{px:`16px`,pt:`5px`,pb:`5px`},children:[`Model: `,e.model,`, `,t.total,` total (`,n,` common,`,` `,t.added,` added, `,t.removed,` removed)`]})}function pl(e){if(!e.result||!e.params)return{renderNull:!0};let t=Nc(e.result,{params:e.params});return t?{columns:t.columns,rows:t.rows,isEmpty:!1,header:U(fl,{params:e.params,summary:e.result.summary})}:{renderNull:!0}}const ml=$({displayName:`ValueDiffResultView`,typeGuard:dl,expectedRunType:`value_diff`,screenshotWrapper:`grid`,transformData:pl}),hl={lineage_diff:{title:`Lineage Diff`,icon:yr},schema_diff:{title:`Schema Diff`,icon:_r},query:{title:`Query`,icon:Cr,RunResultView:Yc},query_base:{title:`Query Base`,icon:Cr,RunResultView:Yc},query_diff:{title:`Query Diff`,icon:Cr,RunResultView:qc},row_count:{title:`Row Count`,icon:gr,RunResultView:el},row_count_diff:{title:`Row Count Diff`,icon:gr,RunResultView:tl},profile:{title:`Profile`,icon:Sr,RunResultView:Wc,RunForm:Hc},profile_diff:{title:`Profile Diff`,icon:Sr,RunResultView:Gc,RunForm:Hc},value_diff:{title:`Value Diff`,icon:vr,RunResultView:ml,RunForm:ul},value_diff_detail:{title:`Value Diff Detail`,icon:vr,RunResultView:ll,RunForm:ul},top_k_diff:{title:`Top-K Diff`,icon:yt,RunResultView:sl,RunForm:nl},histogram_diff:{title:`Histogram Diff`,icon:br,RunResultView:fc,RunForm:za},simple:{title:`Simple`,icon:xr}};function gl(e){return hl[e]}const _l=hl;function vl(e){let t={...hl};for(let[n,r]of Object.entries(e))r&&n in t&&(t[n]={...t[n],...r});return t}function yl(e){return t=>e[t]}function bl(e){return{id:e.run_id,name:e.name,type:e.type,status:e.status??`Finished`,runAt:e.run_at,checkId:e.check_id}}function xl(){let{closeHistory:t,showRunId:n,runId:r}=j(),{featureToggles:i}=ae(),{apiClient:o}=Ql(),s=pr(),c=st(),{basePath:l}=oe(),{data:u,isLoading:d}=ot({queryKey:O.runs(),queryFn:async()=>await e(o),retry:!1}),f=z(()=>(u??[]).map(bl),[u]),p=L(e=>{Qe({name:`click_run`}),n(e,!1)},[n]),m=L(async e=>{Qe({name:`add_to_checklist`});let t=await a(e,void 0,o);await c.invalidateQueries({queryKey:O.checks()}),s.push(`${l}/checks/?id=${t.check_id}`)},[o,c,s.push,l]),h=L(e=>{Qe({name:`go_to_check`}),s.push(`${l}/checks/?id=${e}`)},[s.push,l]),g=L(()=>{Qe({name:`hide`}),t()},[t]),_=L(e=>{let t=gl(e)?.icon;return t?U(t,{}):null},[]),v=U(Y,{"aria-label":`Close History`,onClick:g,children:U(sn,{})});return U(Ss,{runs:f,selectedId:r,isLoading:d,onRunSelect:p,onAddToChecklist:m,onGoToCheck:h,getRunIcon:_,hideAddToChecklist:i.disableUpdateChecklist&&!i.checklistPermissionDenied,disableAddToChecklist:i.checklistPermissionDenied,title:`History`,headerActions:v,emptyMessage:`No runs`,loadingMessage:`Loading...`,groupByDate:!0,addToChecklistIcon:U(hr,{}),goToCheckIcon:U(mr,{color:`green`})})}const Sl=({size:e=16})=>W(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[U(`circle`,{cx:`12`,cy:`12`,r:`10`}),U(`path`,{d:`M12 16v-4`}),U(`path`,{d:`M12 8h.01`})]});function Cl({isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,RunForm:o,onCancel:s,onExecuteClick:c,documentationUrl:l,InfoIcon:u=Sl}){let[d,f]=V(a??{}),[p,m]=V(null),[h,g]=V(!1),_=B(!1),v=()=>{_.current||s?.(),_.current=!1,t()};return W(mt,{open:e,onClose:v,maxWidth:`sm`,fullWidth:!0,scroll:`paper`,slotProps:{paper:{sx:{height:`75%`,minHeight:`400px`}}},children:[W(_t,{sx:{display:`flex`,alignItems:`center`},children:[i,` `,l&&W(H,{children:[U(Y,{size:`small`,"aria-label":`Click this button to learn more about the SQL behind`,onMouseEnter:e=>m(e.currentTarget),onMouseLeave:()=>m(null),onClick:()=>window.open(l,`_blank`),children:U(G,{component:u,sx:{fontSize:`16px`}})}),U(Bn,{open:!!p,anchorEl:p,onClose:()=>m(null),anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},disableRestoreFocus:!0,sx:{pointerEvents:`none`},slotProps:{paper:{sx:{bgcolor:`black`,color:`white`,p:1}}},children:W(J,{sx:{fontSize:`0.875rem`},children:[`Click`,` `,U(vt,{href:l,target:`_blank`,sx:{textDecoration:`underline`,color:`white`,"&:hover":{color:`iochmara.300`}},children:`here`}),` `,`to learn more about the SQL behind`]})})]})]}),U(Y,{"aria-label":`close`,onClick:v,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),U(gt,{sx:{p:0,overflow:`auto`,borderTop:`1px solid`,borderBottom:`1px solid`,borderColor:`divider`},children:U(G,{sx:{contain:`layout`},children:o&&U(o,{params:d,onParamsChanged:f,setIsReadyToExecute:g})})}),U(ht,{children:U(q,{direction:`row`,spacing:`10px`,children:U(K,{disabled:!h,color:`iochmara`,variant:`contained`,onClick:()=>{_.current=!0,c?.(),n(r,d)},children:`Execute`})})})]})}const wl=e=>({value_diff:`https://docs.reccehq.com/features/lineage/#value-diff`,profile_diff:`https://docs.reccehq.com/features/lineage/#profile-diff`,histogram_diff:`https://docs.reccehq.com/features/lineage/#histogram-diff`,top_k_diff:`https://docs.reccehq.com/features/lineage/#top-k-diff`})[e]||null;function Tl({isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,initialRun:o,RunForm:s}){return U(Cl,{isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,initialRun:o,RunForm:s,onCancel:()=>{Ye(r)&&Ze({action:r,event:Je.CANCEL})},onExecuteClick:()=>{Ye(r)&&Ze({action:r,event:Je.EXECUTE})},documentationUrl:wl(r),InfoIcon:Zt})}const El=ut(function({isRunning:e,runId:t,progress:n,error:r,run:i,onCancel:a,viewOptions:o,onViewOptionsChanged:s,RunResultView:c,children:l,ErrorBoundary:u,errorBoundaryFallback:d},f){let p=P(),m=ss(),h=r?.response?.data?.detail??i?.error,g=i?.run_id??t,_=g!=null&&m.has(g),v=i?.status===`Cancelled`||_;if(h)return W(Qn,{severity:`error`,sx:p?{bgcolor:`error.dark`,color:`common.white`,"& .MuiAlert-icon":{color:`common.white`}}:void 0,children:[`Error: `,U(`span`,{className:`no-track-pii-safe`,children:h})]});if(v)return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,p:`1rem`,height:`100%`,bgcolor:p?`grey.900`:`grey.50`},children:U(q,{spacing:1,sx:{alignItems:`center`},children:U(J,{children:`Cancelled`})})});if((e||i?.status===`Running`)&&!_){let e=`Loading...`;n?.message?e=n.message:i?.progress?.message&&(e=i.progress.message);let t=n?.percentage==null?void 0:n.percentage*100;return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,p:`1rem`,height:`100%`,bgcolor:p?`grey.900`:`grey.50`},children:W(q,{spacing:2,sx:{alignItems:`center`},children:[W(q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[t==null?U(pn,{size:32}):W(G,{sx:{position:`relative`,display:`inline-flex`},children:[U(pn,{variant:`determinate`,value:t,size:32}),U(G,{sx:{top:0,left:0,bottom:0,right:0,position:`absolute`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:U(J,{variant:`caption`,component:`div`,sx:{fontSize:`0.6rem`},children:`${Math.round(t)}%`})})]}),U(J,{className:`no-track-pii-safe`,children:e})]}),U(K,{variant:`contained`,onClick:a,size:`small`,children:`Cancel`})]})})}if(!i)return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:p?`grey.900`:`grey.50`,height:`100%`},children:U(pn,{size:32})});if(l&&c)throw Error(`RunView requires either a children or a RunResultView prop, but not both.`);if(!l&&!c)throw Error(`RunView requires at least one of children or RunResultView prop.`);return U(G,{sx:{height:`100%`,contain:`layout`,overflow:`auto`,bgcolor:p?`grey.900`:`grey.50`},className:`no-track-pii-safe`,children:(()=>{let e=c&&(i.error??i.result)?U(c,{ref:f,run:i,viewOptions:o,onViewOptionsChanged:s}):null,t=l?.({run:i,viewOptions:o,onViewOptionsChanged:s});return u&&e?W(H,{children:[U(u,{fallback:d,children:e}),t]}):W(H,{children:[e,t]})})()})});El.displayName=`RunView`;const Dl=I(({type:e,params:t})=>{let n=P();return U(Ro,{value:Dn.stringify({type:e,params:t},null,2),language:`yaml`,readOnly:!0,lineNumbers:!1,wordWrap:!0,fontSize:14,height:`100%`,theme:n?`dark`:`light`,className:`no-track-pii-safe`})});Dl.displayName=`ParamView`;function Ol(e,t){return t!=null&&t>0?`${e} (${ye(t)})`:e}const kl=I(({open:e,rowCount:t,onContinue:n,onCancel:r})=>W(mt,{open:e,onClose:r,children:[U(_t,{children:`Large Export Warning`}),U(gt,{children:W(Tr,{children:[`You are about to download `,U(`strong`,{children:ye(t)}),`. This may take a while and produce a large file. Are you sure you want to continue?`]})}),W(ht,{children:[U(K,{onClick:r,children:`Cancel`}),U(K,{onClick:n,variant:`contained`,children:`Continue`})]})]}));kl.displayName=`LargeExportWarningDialog`;const Al=I(({disableExport:e,onCopyAsImage:t,onMouseEnter:n,onMouseLeave:r,csvExport:i,label:a=`Export`})=>{let[o,s]=V(null),c=!!o,[l,u]=V(!1),[d,f]=V(null),p=i?.totalRowCount??0,m=p>1e5,h=e=>{s(e.currentTarget)},g=()=>{s(null)},_=e=>{m?(f(()=>e),u(!0)):(e(),g())};return W(H,{children:[U(K,{size:`small`,variant:`outlined`,color:`neutral`,onClick:h,endIcon:U(Vt,{}),sx:{textTransform:`none`},children:a}),W(ln,{anchorEl:o,open:c,onClose:g,children:[W(Z,{onClick:async()=>{await t(),g()},onMouseEnter:n,onMouseLeave:r,disabled:e,children:[U(Er,{children:U(Xt,{})}),U(Dr,{children:`Copy as Image`})]}),W(Z,{onClick:async()=>{await i?.copyAsTSV?.(),g()},disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Kt,{})}),U(Dr,{children:`Copy as Text`})]}),W(Z,{onClick:async()=>{await i?.copyAsCSV(),g()},disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(rn,{})}),U(Dr,{children:`Copy as CSV`})]}),i?.copySelectedRows&&W(Z,{onClick:async()=>{await i.copySelectedRows?.(),g()},disabled:e,children:[U(Er,{children:U(nn,{})}),U(Dr,{children:`Copy Selected Rows`})]}),W(Z,{onClick:()=>_(()=>i?.downloadAsCSV()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as CSV`,i?.totalRowCount)})]}),W(Z,{onClick:()=>_(()=>i?.downloadAsTSV?.()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as TSV`,i?.totalRowCount)})]}),i?.downloadAsExcel&&W(Z,{onClick:()=>_(()=>i?.downloadAsExcel?.()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as Excel`,i?.totalRowCount)})]})]}),U(kl,{open:l,rowCount:p,onContinue:()=>{u(!1),d?.(),f(null),g()},onCancel:()=>{u(!1),f(null)}})]})});Al.displayName=`DefaultExportMenu`;const jl=I(({runId:e,run:t,disableUpdateChecklist:n,checklistPermissionDenied:r,hasError:i,onGoToCheck:a,onAddToChecklist:o})=>{let s=ss();if(e&&s.has(e))return null;let c=t?.check_id,l=!e||!t?.result||i;return n&&!r?null:c?U(K,{disabled:l,size:`small`,variant:`contained`,onClick:()=>a?.(c),startIcon:U(Ut,{}),sx:{textTransform:`none`},children:`Go to Check`}):U(X,{title:r?`You don't have permission to add checks`:``,children:U(`span`,{children:U(K,{disabled:l||r,size:`small`,variant:`contained`,onClick:o,startIcon:U(Ut,{}),sx:{textTransform:`none`},children:`Add to Checklist`})})})});jl.displayName=`DefaultAddToCheckButton`;const Ml=I(({run:e})=>{let t=ss(),n=e.run_id&&t.has(e.run_id)?`Cancelled`:e.status||(e.result?`Finished`:e.error?`Failed`:`unknown`),r=e=>{switch(e.toLowerCase()){case`finished`:return`success.main`;case`failed`:return`error.main`;case`running`:return`primary.main`;default:return`text.secondary`}},i=e.run_at?xn(new Date(e.run_at),{addSuffix:!0}):`Unknown time`;return W(J,{variant:`body2`,sx:{color:`text.secondary`},children:[U(G,{component:`span`,sx:{fontWeight:600,color:r(n)},children:n}),`・`,i]})});Ml.displayName=`RunStatusAndDateDisplay`;function Nl({runId:e,run:t,isRunning:n,error:r,viewOptions:i,onViewOptionsChanged:a,isSingleEnvironment:o,disableDatabaseQuery:s,disableShare:c,disableUpdateChecklist:l,checklistPermissionDenied:u,onClose:d,onCancel:f,onRerun:p,onCopyAsImage:m,onCopyMouseEnter:h,onCopyMouseLeave:g,csvExport:_,onTrackCopyToClipboard:v,onGoToCheck:y,onAddToChecklist:b,SingleEnvironmentNotification:x,SqlEditorComponent:S,DualSqlEditorComponent:C,RunResultView:w,resultViewRef:T,children:E}){let ee=P(),D=ss(),O=e?D.has(e):!1,[k,te]=V(`result`),[ne,re]=V(!0),ie=t?.type===`query`||t?.type===`query_diff`||t?.type===`query_base`,ae=!e||!t?.result||!!r||k!==`result`||O,oe=L(async()=>{await m?.(),v&&v(t?.type??`unknown`,`run`)},[m,v,t?.type]),se=t?.type===`query_diff`,ce=t?.params;return W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,bgcolor:ee?`grey.900`:`grey.50`},children:[o&&ne&&x&&U(x,{runType:t?.type,onClose:()=>re(!1)}),W(G,{sx:{display:`flex`,alignItems:`center`,borderBottom:1,borderColor:`divider`,mb:`1px`},children:[W(wn,{value:k,onChange:(e,t)=>te(t),children:[U(Cn,{label:`Result`,value:`result`}),U(Cn,{label:`Params`,value:`params`}),ie&&U(Cn,{label:`Query`,value:`query`})]}),U(G,{sx:{flexGrow:1}}),W(q,{direction:`row`,spacing:1,sx:{alignItems:`center`,overflow:`hidden`,pr:1},children:[t&&U(Ml,{run:t}),U(K,{variant:`outlined`,color:`neutral`,disabled:!e||n||s,size:`small`,onClick:p,startIcon:U(tn,{}),sx:{textTransform:`none`},children:`Rerun`}),U(Al,{run:t,disableExport:ae,onCopyAsImage:oe,onMouseEnter:h,onMouseLeave:g,csvExport:_,label:c?`Export`:`Share`}),U(jl,{runId:e,run:t,disableUpdateChecklist:l,checklistPermissionDenied:u,hasError:!!r,onGoToCheck:y,onAddToChecklist:b}),U(Y,{size:`small`,onClick:d,children:U(kt,{})})]})]}),k===`result`&&(w||E)&&U(El,{ref:T,runId:e,isRunning:n,error:r,run:t,onCancel:f,viewOptions:i,onViewOptionsChanged:a,RunResultView:w,children:E}),k===`params`&&t&&U(Dl,{type:t.type,params:t.params}),k===`query`&&t&&ie&&ce?.sql_template&&U(H,{children:se&&C?U(C,{value:ce.sql_template,baseValue:ce.base_sql_template,readOnly:!0}):S?U(S,{value:ce.sql_template,readOnly:!0}):U(Ro,{value:ce.sql_template,language:`sql`,readOnly:!0,theme:`dark`,height:`100%`})})]})}const Pl=I(Nl);Pl.displayName=`RunResultPane`;function Fl(e){let t=e.getSelectedNodes();if(t.length===0)return null;let n=e.getAllDisplayedColumns().filter(e=>e.getColId()!==`ag-Grid-SelectionColumn`);return n.length===0?null:Le(n.map(e=>{let t=e.getColDef();return String(t.headerName??t.field??e.getColId())}),t.map(t=>n.map(n=>e.getCellValue({rowNode:t,colKey:n,useFormatter:!0})??``)))}const Il=e=>W(G,{sx:{display:`flex`,flex:1,minHeight:`48px`,m:`4px`,px:`16px`,py:`12px`,bgcolor:`primary.50`,border:`1px solid`,borderRadius:`4px`,borderColor:`primary.400`,alignItems:e.align??`center`,gap:`12px`},children:[U(G,{component:Or,sx:{width:`20px`,height:`20px`,color:`primary.900`}}),e.children,U(G,{sx:{flexGrow:1}}),U(Y,{size:`small`,onClick:e.onClose,children:U(kt,{})})]}),Ll=()=>W(vt,{href:`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,target:`_blank`,sx:{color:`primary.main`,fontWeight:`bold`,textDecoration:`underline`,display:`inline-flex`,alignItems:`center`,gap:.5},children:[`Learn how `,U(bt,{})]});function Rl({value:e,onChange:t,onRun:n,onRunBase:r,onRunDiff:i,label:a,CustomEditor:o,options:s={},manifestData:c,schemas:l,...u}){let{featureToggles:d}=ae(),f=P(),p=e=>{t&&t(e)},m=``;c&&(m=c.generated_at?Be(c.generated_at):``);let h=z(()=>{let e=[];return n&&e.push({key:`Mod-Enter`,run:()=>(n(),!0)}),r&&e.push({key:`Alt-Enter`,run:()=>(r(),!0)}),i&&e.push({key:`Mod-Shift-Enter`,run:()=>(i(),!0)}),e},[n,r,i]);return W(H,{children:[(a??n??r)&&W(q,{direction:`row`,sx:{bgcolor:Ct(f?N.neutral[600]:N.neutral[200],.7),height:`40px`,minHeight:`40px`,fontSize:`14px`,alignItems:`center`,m:0,p:`0px 16px`,flex:`0 0 40px`},children:[U(J,{component:`strong`,sx:{fontWeight:`bold`},className:`no-track-pii-safe`,children:a?a.toUpperCase():``}),c&&W(`span`,{className:`ml-1`,children:[`(`,l&&W(`span`,{className:`no-track-pii-safe`,children:[l,`, `]}),U(`span`,{children:m}),`)`]}),U(G,{sx:{flexGrow:1}}),(n??r)&&U(K,{size:`xsmall`,variant:`outlined`,onClick:n??r,sx:{bgcolor:`background.paper`,p:`6px 12px`},disabled:d.disableDatabaseQuery,startIcon:U(kr,{}),children:`Run Query`})]}),o??U(Ro,{value:e,onChange:p,language:`sql`,readOnly:s.readOnly??!1,lineNumbers:s.lineNumbers!==`off`,wordWrap:s.wordWrap!==`off`,fontSize:s.fontSize??16,keyBindings:h,theme:f?`dark`:`light`,className:`no-track-pii-safe max-h-dvh h-full`})]})}function zl({value:e,baseValue:t,onChange:n,onChangeBase:r,onRun:i,onRunBase:a,onRunDiff:o,options:s={},labels:c,SetupGuide:l,...u}){let d=c?c[0]:`Base`,f=c?c[1]:`Current`,{envInfo:p,lineageGraph:m}=pe(),h,g;p?.dbt?.base&&p.dbt.current&&(h=p.dbt.base,g=p.dbt.current);let[_,v]=Re(m);return U(H,{children:W(q,{direction:`row`,sx:{height:`100%`,gap:0},children:[U(q,{sx:{height:`100%`,width:`50%`,gap:0,borderRight:`1px solid`,borderRightColor:`divider`},children:U(Rl,{label:d,value:t??``,onChange:r,onRunBase:a,options:s,CustomEditor:l,manifestData:h??void 0,schemas:Array.from(_).join(`, `),...u})}),U(q,{sx:{height:`100%`,width:`50%`,gap:0},children:U(Rl,{label:f,value:e,onChange:n,onRun:i,options:s,manifestData:g??void 0,schemas:Array.from(v).join(`, `),...u})})]})})}const Bl=({runType:e,onClose:t})=>{switch(e){case`row_count`:return U(Il,{onClose:t,children:W(J,{children:[`Enable row count diffing, and other Recce features, by configuring a base dbt environment to compare against. `,U(Ll,{})]})});case`profile`:return U(Il,{onClose:t,children:W(J,{children:[`Enable data-profile diffing, and other Recce features, by configuring a base dbt environment to compare against.`,` `,U(Ll,{})]})});default:return null}},Vl=({value:e,readOnly:t})=>U(Rl,{value:e,options:{readOnly:t}}),Hl=({value:e,baseValue:t,readOnly:n})=>U(zl,{value:e,baseValue:t,options:{readOnly:n}}),Ul=({runId:e,onClose:t,isSingleEnvironment:n})=>{let{featureToggles:r}=ae(),{runAction:i}=j(),{error:o,run:s,onCancel:c,isRunning:l}=Nu(e),[u,f]=V(),p=st(),m=pr(),{apiClient:h}=Ql(),{basePath:g}=oe(),_;s&&d(s.type)&&(_=gl(s.type).RunResultView);let{ref:v,onCopyToClipboard:y,onMouseEnter:b,onMouseLeave:x}=xu(),S=Du({run:s,runId:e,viewOptions:u}),C=!!s?.type&&[`query`,`query_base`,`query_diff`].includes(s.type),w=L(async()=>{let e=v.current?.api;if(!e)return;let t=Fl(e);if(!t){F.create({title:`No rows selected`,description:`Select rows with the checkboxes, then copy.`,type:`info`,duration:3e3});return}try{await Ce(t),F.create({title:`Copied to clipboard`,description:`Selected rows copied — paste into any spreadsheet`,type:`success`,duration:2e3}),Xe({type:s?.type??`unknown`,from:`run-selection`})}catch(e){console.error(`Failed to copy selected rows:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[v,s?.type]),T=L(()=>{s&&i(s.type,s.params)},[s,i]),E=L(async()=>{await y(),Xe({type:s?.type??`unknown`,from:`run`})},[y,s?.type]),ee=L(e=>{m.push(`${g}/checks/?id=${e}`)},[m.push,g]),D=L(async()=>{if(e)try{let t=await a(e,u,h);await p.invalidateQueries({queryKey:O.checks()}),m.push(`${g}/checks/?id=${t.check_id}`)}catch(e){re(e)&&e.status===403?F.error({title:`Permission denied`,description:`You don't have permission to add checks. Contact your org admin for access.`}):F.error({title:`Failed to create check`,description:e instanceof Error?e.message:`An unexpected error occurred`})}},[e,u,h,p,m.push,g]);return U(Pl,{runId:e,run:s,isRunning:l,error:o,viewOptions:u,onViewOptionsChanged:f,isSingleEnvironment:n,disableDatabaseQuery:r.disableDatabaseQuery,disableShare:r.disableShare,disableUpdateChecklist:r.disableUpdateChecklist,checklistPermissionDenied:r.checklistPermissionDenied,onClose:t,onCancel:c,onRerun:T,onCopyAsImage:E,onCopyMouseEnter:b,onCopyMouseLeave:x,csvExport:{...S,copySelectedRows:C?w:void 0},onGoToCheck:ee,onAddToChecklist:D,SingleEnvironmentNotification:Bl,SqlEditorComponent:Vl,DualSqlEditorComponent:Hl,RunResultView:_,resultViewRef:v})},Wl=({onClose:e,isSingleEnvironment:t})=>{let{runId:n}=j();return U(Ul,{runId:n,onClose:e,isSingleEnvironment:t})};function Gl({error:e,resetError:t}){let{background:n,text:r}=Pu();return U(G,{sx:{height:`100%`,bgcolor:n.subtle,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(G,{sx:{p:4,display:`flex`,flexDirection:`column`,justifyContent:`flex-start`,bgcolor:`background.paper`,border:`solid 1px`,borderColor:`divider`,minHeight:`200px`},children:[U(J,{variant:`h6`,sx:{width:`800px`},children:`You have encountered an error`}),U(G,{sx:{flex:1,fontSize:`10pt`,color:r.secondary},children:String(e)}),U(K,{sx:{justifySelf:`center`,alignSelf:`center`,mt:`20px`},color:`iochmara`,variant:`contained`,size:`small`,onClick:t,children:`Reset`})]})})}const Kl=e=>U(Gl,{error:e.error,resetError:e.resetError}),ql=({children:e,fallback:t=Kl})=>U(Ar,{fallback:t,children:e}),Jl=ut(function(e,t){return U(El,{...e,ErrorBoundary:ql,errorBoundaryFallback:nt,ref:t})});Jl.displayName=`RunViewOss`;const Yl={mode:`per_node`,status:`pending`,completed:0,total:0,actions:{}},Xl=(e,t)=>{let{onActionStarted:n,onActionNodeUpdated:r,onActionCompleted:i,onTrackAction:a,trackingSource:o=`lineage_view_top_bar`}=t,c=k(),u=B({...Yl}).current,d=ss(),{showRunId:f}=j(),p=async(t,a,o)=>{u.mode=`multi_nodes`,u.actions={};let s=u.mode,l=u.actions;n(),u.status=`running`;let d=[];for(let t of e){let e=a(t);e?(l[t.id]={mode:s,status:`skipped`,skipReason:e},r(t)):(l[t.id]={mode:s,status:`pending`},d.push(t))}let p=o(d);try{let{run_id:e}=await C(t,p,{nowait:!0},c);for(f(e),u.currentRun={run_id:e},u.total=1;;){let t=await x(e,2,c);u.currentRun=t;let n=t.error?`failure`:t.result?`success`:`running`;for(let e of d)l[e.id]={mode:s,status:n,run:t},r(e);if(t.error||t.result)break}}catch{}if(u.completed=1,u.status===`canceling`){u.status=`canceled`,i();return}u.status=`completed`,i()},m=async(t,a)=>{u.mode=`per_node`,u.actions={};let o=u.mode,s=u.actions;n(),u.status=`running`;for(let t of e)s[t.id]={mode:o,status:`pending`},r(t);u.completed=0,u.total=e.length;for(let n of e){let{params:e,skipReason:l}=a(n);if(l)s[n.id]={mode:o,status:`skipped`,skipReason:l},r(n);else try{let{run_id:i}=await C(t,e,{nowait:!0},c);for(u.currentRun={run_id:i},s[n.id]={mode:o,status:`running`},r(n);;){let e=await x(i,2,c);u.currentRun=e;let t=e.error?`failure`:e.result?`success`:`running`;if(s[n.id]={mode:o,status:t,run:e},r(n),e.error||e.result)break}}catch{}finally{u.currentRun=void 0}if(u.completed++,u.status===`canceling`){u.status=`canceled`,i();return}}u.status=`completed`,i()};return{actionState:u,runRowCount:async()=>{a?.({action:`row_count`,source:o,node_count:e.length});for(let t of e)t.data.resourceType!==`model`&&(u.actions[t.id]={mode:`multi_nodes`,status:`skipped`,skipReason:`Not a model`},r(t));await p(`row_count`,e=>{if(e.data.resourceType!==`model`)return`Not a model`},e=>({node_names:e.map(e=>e.data.name)}))},runRowCountDiff:async()=>{a?.({action:`row_count_diff`,source:o,node_count:e.length});for(let t of e)t.data.resourceType!==`model`&&(u.actions[t.id]={mode:`multi_nodes`,status:`skipped`,skipReason:`Not a model`},r(t));await p(`row_count_diff`,e=>{if(e.data.resourceType!==`model`)return`Not a model`},e=>({node_names:e.map(e=>e.data.name)}))},runValueDiff:async()=>{a?.({action:`value_diff`,source:o,node_count:e.length}),await m(`value_diff`,e=>({skipReason:`No primary key found. The first unique column is used as primary key.`}))},addLineageDiffCheck:async()=>await s({node_ids:e.map(e=>e.id)},c),addSchemaDiffCheck:async()=>{let t;return t=e.length===1?await v({node_id:e[0].id},c):await v({node_id:e.map(e=>e.id)},c),t},cancel:()=>{u.status=`canceling`;let e=u.currentRun?.run_id;return e&&(d.add(e),l(e,c)),Promise.resolve()},reset:()=>{Object.assign(u,Yl)}}},Zl={apiPrefix:``,authToken:void 0,baseUrl:void 0,apiClient:ne({baseURL:et??``})};function Ql(){return D()??Zl}function $l({connect:e,idleSeconds:t}){return W(H,{children:[U(_t,{children:`Server Disconnected`}),U(gt,{children:t!=null&&t>0?W(J,{children:[`The server has been idle for `,He(t),` and was automatically stopped. Please restart the Recce server to continue.`]}):U(J,{children:`The server connection has been lost. Please restart the Recce server and try again.`})}),U(ht,{children:U(K,{color:`iochmara`,variant:`contained`,onClick:()=>{e()},children:`Retry`})})]})}function eu({shareUrl:e,mode:t,supportCalendarUrl:n,LinkComponent:r}){let i={"read only":{title:`Share Instance Expired`,body:`This Share Instance has expired. Please restart the share instance.`,action:`Restart`,link:e},"metadata only":{title:`Preview Instance Expired`,body:`This Preview Instance has expired. To browse more, please book a meeting with us.`,action:`Contact us`,link:n}}[t],a=U(K,{color:`iochmara`,variant:`contained`,children:i.action});return W(H,{children:[U(_t,{children:i.title}),U(gt,{children:U(J,{children:i.body})}),U(ht,{children:t===`read only`?U(r||`a`,{href:i.link,children:a}):U(K,{color:`iochmara`,variant:`contained`,onClick:()=>window.open(i.link,`_blank`),children:i.action})})]})}function tu(e){let{apiClient:t}=Ql();return ot({queryKey:O.lineage(),queryFn:()=>E(t),...e})}function nu({enabled:e=!0,baseUrl:t,apiPrefix:n}={}){let[r,i]=V(void 0),a=B({ws:void 0,status:`pending`,artifactsUpdatedToastId:void 0}),[o,s]=V(e?`pending`:`connected`),[c,l]=V(void 0);R(()=>{a.current.status=o},[o]),R(()=>{a.current.artifactsUpdatedToastId=r},[r]);let u=st(),d=L(()=>{u.invalidateQueries({queryKey:O.lineage()}),u.invalidateQueries({queryKey:O.checks()}),u.invalidateQueries({queryKey:O.runs()})},[u]),f=L(()=>{function e(e){return e.replace(/(http)(s)?:\/\//,`ws$2://`)}let r=t??et,o=n?`${n}/ws`:`/api/ws`,c=new WebSocket(`${e(r)}${o}`);a.current.ws=c,c.onopen=()=>{c.send(`ping`)},c.onmessage=e=>{if(e.data===`pong`){a.current.status===`disconnected`&&d(),s(`connected`);return}try{let t=JSON.parse(e.data);if(`type`in t&&t.type===`metadata_updated`){d();return}let n=t;if(n.command===`refresh`){let{eventType:e,srcPath:t}=n.event,[r,o]=t.split(`/`).slice(-2),s=o.replace(/\.[^/.]+$/,``),c=`${r}-${s}-${e}`;a.current.artifactsUpdatedToastId??i(F.create({id:c,description:`Detected ${r} ${s} ${e}`,type:`info`,duration:5e3,closable:!0})),d()}else if(n.command===`relaunch`)l(`relaunch`);else{let{id:e,title:t,description:r,status:a,duration:o}=n.event;i(F.create({id:e||`broadcast`,title:t,description:r,type:a??`info`,duration:o??5e3,closable:!0}))}}catch(e){console.error(e)}},c.onerror=e=>{console.error(`An error occurred during Handling WebSockets`,e)},c.onclose=()=>{s(e=>e===`connected`?`disconnected`:e),a.current.ws=void 0}},[d,t,n]);return R(()=>{if(!e)return;let t=a.current;return f(),()=>{t.ws&&t.ws.close()}},[f,e]),{connectionStatus:o,connect:f,envStatus:c}}function ru({children:e}){let{idleTimeout:t,remainingSeconds:n,isEnabled:r,setDisconnected:i,resetConnection:a}=se(),{apiClient:o,apiPrefix:s,baseUrl:l}=Ql(),u=tu(),d=ot({queryKey:O.runsAggregated(),queryFn:()=>c(o)}),f=z(()=>{let e=u.data?.lineage;if(e?.nodes)return de(e)},[u.data]),p=u.error?.message,{state_metadata:m,lineage:h,sqlmesh:g,demo:_,codespace:v,review_mode:y,cloud_mode:b,file_mode:x,filename:S,adapter_type:C,git:w,pull_request:T,support_tasks:E}=u.data??{demo:!1},ee={stateMetadata:m,adapterType:C,git:w,pullRequest:T,dbt:{base:h?.metadata?.base?.manifest_metadata,current:h?.metadata?.current?.manifest_metadata},sqlmesh:g},{connectionStatus:D,connect:k,envStatus:ne}=nu({enabled:!0,baseUrl:l,apiPrefix:s});R(()=>{D===`disconnected`?i():D===`connected`&&a()},[D,i,a]);let{data:re,isLoading:ie}=le(),{featureToggles:oe,shareUrl:ce}=ae(),[A,ue]=V(!1),[j,pe]=V(!1),me=st(),M=!ie&&ne===`relaunch`&&re?.single_env_onboarding===!0&&re.show_relaunch_hint;M!==j&&(pe(M),ue(M)),R(()=>{M&&A&&$e({action:`target_base_added`})},[M,A]);let he=()=>{ue(!1),te(o),me.invalidateQueries({queryKey:O.flag()})},ge=L(()=>{d.refetch()},[d]),_e=L(()=>{d.refetch()},[d]);return W(H,{children:[U(fe,{lineageGraph:f,envInfo:ee,reviewMode:y,cloudMode:b,fileMode:x,fileName:S,isDemoSite:_??!1,isCodespace:v,isLoading:u.isLoading,error:p,supportTasks:E,onRefetchLineageGraph:ge,runsAggregated:d.data,onRefetchRunsAggregated:_e,children:e}),U(mt,{open:D===`disconnected`,onClose:()=>void 0,children:ce&&oe.mode!==null?U(eu,{shareUrl:ce,mode:oe.mode,supportCalendarUrl:tt,LinkComponent:({href:e,children:t})=>U(Ot,{href:e,passHref:!0,children:t})}):U($l,{connect:k,idleSeconds:r&&t!==null&&n!==null&&n<=5?t-Math.max(0,n):void 0})}),re?.single_env_onboarding&&W(mt,{open:A,onClose:he,children:[U(_t,{children:`Target-base Added`}),U(Y,{"aria-label":`close`,onClick:he,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),U(gt,{children:U(J,{children:`Please restart the Recce server.`})}),U(ht,{children:U(K,{color:`iochmara`,variant:`contained`,onClick:he,children:`Got it!`})})]})]})}const iu=`select * from {{ ref("mymodel") }}`;function au({children:e}){let[t,n]=V(iu),[r,i]=V(iu),[a,o]=V(!1),[s,c]=V();return U(Lr,{sql:t,sqlQuery:t,setSqlQuery:n,primaryKeys:s,setPrimaryKeys:c,isCustomQueries:a,setCustomQueries:o,baseSqlQuery:r,setBaseSqlQuery:i,children:e})}const ou=e=>{},su=e=>{},cu=e=>{},lu=e=>{};function uu(){let e=Rr();return{sqlQuery:e.sqlQuery??`select * from {{ ref("mymodel") }}`,setSqlQuery:e.setSqlQuery??ou,primaryKeys:e.primaryKeys,setPrimaryKeys:e.setPrimaryKeys??su,isCustomQueries:e.isCustomQueries??!1,setCustomQueries:e.setCustomQueries??cu,baseSqlQuery:e.baseSqlQuery??`select * from {{ ref("mymodel") }}`,setBaseSqlQuery:e.setBaseSqlQuery??lu}}function du(e){R(()=>{e()},[e,fr()])}function fu({children:e}){let{apiClient:t}=Ql(),[n,r]=V(),[i,a]=V(!1),o=L(()=>a(!0),[]),s=L(()=>a(!1),[]),c=pr(),l=fr(),u=st(),{basePath:d}=oe(),f=B(null);du(s);let p=L(async(e,t)=>{t!==!1&&await u.invalidateQueries({queryKey:O.runs()})},[u]),h=L(async(e,n,i)=>{try{let a=new Date().getTime().toString(),s,p=i;if(p?.showLast){let r=await m(e,n,1,t);r.length===1&&(s=r[0])}let h=gl(e);if(!h)throw Error(`Run type ${e} does not have a result view`);let g=h.RunResultView,{title:_,RunForm:v}=h;if(g===void 0)throw Error(`Run type ${e} does not have a result view`);if(v===void 0||!i?.showForm){let{run_id:r}=await C(e,n,{nowait:!0,trackProps:p?.trackProps},t);await u.invalidateQueries({queryKey:O.runs()}),f.current&&f.current(r);let i=`${d}/lineage`;l.startsWith(`${i}/`)&&l!==i&&c.push(i);return}r({session:a,title:_,type:e,params:n,lastRun:s,options:p,RunForm:v}),o();return}catch(e){F.create({title:`Failed to submit a run`,description:e instanceof Error?e.message:void 0,type:`error`,duration:5e3,closable:!0});return}},[o,u,t,l,c,d]),g=L(async(e,r)=>{try{s();let{run_id:i}=await C(e,r,{nowait:!0,trackProps:n?.options?.trackProps},t);f.current&&f.current(i)}catch(e){F.create({title:`Failed to submit a run`,description:e instanceof Error?e.message:void 0,type:`error`,duration:5e3,closable:!0})}},[s,n?.options?.trackProps,t]);return W(ie,{onRunAction:h,onShowRunId:p,children:[U(pu,{showRunIdRef:f,children:e}),n&&U(Tl,{isOpen:i,onClose:s,onExecute:g,title:n.title,type:n.type,params:n.params,initialRun:n.lastRun,RunForm:n.options?.showForm&&n.RunForm?n.RunForm:void 0},n.session)]})}function pu({children:e,showRunIdRef:t}){let{showRunId:n}=j();return R(()=>(t.current=n,()=>{t.current=null}),[n,t]),U(H,{children:e})}const mu=lt(void 0);function hu({children:e}){let[t,n]=V(),[r,i]=V(!1),[a,o]=V(),{apiClient:s}=Ql();return U(mu.Provider,{value:{shareUrl:t,isLoading:r,error:a,handleShareClick:async()=>{i(!0),o(void 0),n(void 0);try{let e=await h(s);if(e.status!==`success`){o(e.message);return}n(e.share_url)}catch(e){o(e.message)}finally{i(!1)}}},children:e})}const gu=()=>{let e=dt(mu);if(!e)throw Error(`useRecceShareStateContext must be used within a RecceShareStateContextProvider`);return e};function _u({children:e}){return U(ce,{children:U(hu,{children:U(au,{children:U(ru,{children:U(fu,{children:U(zr,{children:e})})})})})})}const vu=e=>`element`in e?e.element:e,yu=`ignore-screenshot`;function bu({imageType:e=`png`,backgroundColor:t=null,boardEffect:n=!0,shadowEffect:r=!1,borderStyle:i=`solid 1px ${N.neutral[300]}`,borderRadius:a=`10px`,onSuccess:o,onError:s,ignoreElements:c}){let[l,u]=V(`idle`),d=B(null),{onOpen:f,setImgBlob:p,ImageDownloadModal:m}=Su(),h=async()=>{if(!d.current)throw console.error(`No node to use for screenshot`),Error(`No node to use for screenshot`);let e=vu(d.current);if(!e)throw console.error(`Could not get HTMLElement from ref`),Error(`Could not get HTMLElement from ref`);let o=e.style.overflow,s=e.style.border,l=e.style.borderRadius,f=e.style.backgroundColor,p=e.style.height;function m(){let t=e;t&&(t.style.overflow=o,t.style.border=s,t.style.borderRadius=l,t.style.backgroundColor=f,t.style.height=p)}let h=document.createElement(`style`);document.head.appendChild(h),h.sheet?.insertRule(`body > div:last-child img { display: inline-block; }`);try{e.style.overflow=`hidden`,e.style.border=n?i:``,e.style.borderRadius=n?a:``,e.style.backgroundColor=t??N.neutral[100],e.style.height=`${String(e.offsetHeight)}px`;let o=c?e=>!c(e):void 0;u(`loading`);let s=await jr.toCanvas(e,{filter:o,filterMode:`remove`,backgroundColor:t??N.neutral[100]}),l=r?document.createElement(`canvas`):s;if(r){l.width=s.width+80,l.height=s.height+80;let e=l.getContext(`2d`);if(e)e.shadowColor=`rgba(0, 0, 0, 0.5)`,e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(s,40,40);else throw console.error(`Error getting canvas context`),Error(`Error getting canvas context to add shadow effect`)}return await(await fetch(l.toDataURL())).blob()}catch(e){throw console.error(`Error converting to image`,e),e}finally{h.remove(),m()}};return{status:l,isLoading:l===`loading`,isErrored:l===`error`,isSuccess:l===`success`,copyToClipboard:async()=>{try{await navigator.clipboard.write([new ClipboardItem({[`image/${e}`]:h()})]),u(`success`),o&&o()}catch(e){e.message===`ClipboardItem is not defined`?(p(await h()),f(),u(`success`)):(u(`error`),console.error(`Error copying to clipboard`,e),s&&s(e))}},ImageDownloadModal:m,ref:d}}function xu(e){let{successToast:t,failToast:n}=Ue(),{isLoading:r,copyToClipboard:i,ImageDownloadModal:a,ref:o}=bu({imageType:`png`,shadowEffect:!0,backgroundColor:e?.backgroundColor??N.neutral[100],onSuccess:()=>{t(`Copied the query result as an image to clipboard`)},onError:e=>{console.error(`Error taking screenshot`,e),n(`Failed to copy image to clipboard`,e)}}),s=L(()=>{if(o.current){let e=vu(o.current);e&&(e.style.boxShadow=`rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px`,e.style.transition=`box-shadow 0.5s ease-in-out`)}},[o]),c=L(()=>{if(o.current){let e=vu(o.current);e&&(e.style.boxShadow=``)}},[o]),l=L(async()=>{if(o.current){await i();let e=vu(o.current);e&&(e.style.boxShadow=``)}else n(`Failed to copy image to clipboard`,`No content to copy`)},[o,i,n]);function u({imageType:e=`png`,...t}){return W(H,{children:[U(K,{size:`small`,sx:{position:`absolute`,bottom:16,right:16},disabled:r,onMouseEnter:s,onMouseLeave:c,onClick:l,startIcon:U(qt,{}),...t,children:`Copy to Clipboard`}),U(a,{})]})}return{ref:o,CopyToClipboardButton:u,onMouseEnter:s,onMouseLeave:c,onCopyToClipboard:l}}function Su(){let[e,t]=V(!1),[n,r]=V(),i=()=>t(!0),a=()=>t(!1);function o(){let[t,r]=V();return R(()=>{if(!n)return;let e=new FileReader;e.readAsDataURL(n),e.onloadend=e=>{e.target?.result!=null&&r(e.target.result)}},[]),W(mt,{open:e,onClose:a,maxWidth:`sm`,fullWidth:!0,children:[U(_t,{children:`Screenshot Preview`}),U(Y,{"aria-label":`close`,onClick:a,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),W(gt,{children:[W(q,{sx:{px:`10px`,gap:`10px`},children:[W(q,{direction:`row`,spacing:`5px`,sx:{alignItems:`center`},children:[U(G,{component:Zt,sx:{color:`error.main`}}),U(J,{sx:{fontWeight:500,display:`inline`},children:`Copy to the Clipboard`}),` `,`is not supported in the current browser`]}),U(J,{children:`Please download it directly`})]}),U(G,{component:`img`,src:t,alt:`screenshot`,sx:{maxWidth:`100%`}})]}),W(ht,{children:[U(K,{sx:{mr:1.5},onClick:a,children:`Close`}),U(K,{color:`iochmara`,variant:`contained`,onClick:()=>{n&&(Lt(n,`recce-screenshot-${bn(new Date,`yyyy-MM-dd-HH-mm-ss`)}.png`),a())},children:`Download`})]})]})}return{onOpen:i,setImgBlob:r,ImageDownloadModal:o}}function Cu({userId:e,enabled:t=!0}){let{apiClient:n}=Ql(),r=e?.toString(),{data:i,isLoading:a}=ot({queryKey:O.user(),queryFn:()=>it(n),enabled:t&&!!r,retry:!1,staleTime:300*1e3}),o=!!(i&&r&&i.id===r)&&i?.login_type===`github`,s=!!(t&&o&&r),{data:c,isLoading:l}=ot({queryKey:[`github-avatar`,r],queryFn:()=>r?rt(r):Promise.resolve(null),enabled:s,retry:!1,staleTime:300*1e3});return{avatarUrl:typeof c==`string`?c:null,isLoading:a||s&&l,isGitHubUser:!!o}}function wu(e,t={}){let{enabled:a=!0}=t,s=st(),{apiClient:c}=Ql(),{data:l,isLoading:u,error:d,refetch:f}=ot({queryKey:O.checkEvents(e),queryFn:()=>n(e,c),enabled:a,refetchInterval:1e4,refetchIntervalInBackground:!1}),p=at({mutationFn:t=>i(e,t,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}}),m=at({mutationFn:({eventId:t,content:n})=>r(e,t,n,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}}),h=at({mutationFn:t=>o(e,t,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}});return{events:l??[],isLoading:u,error:d,refetch:f,createComment:p.mutate,isCreatingComment:p.isPending,createCommentError:p.error,updateComment:m.mutateAsync,isUpdatingComment:m.isPending,updateCommentError:m.error,deleteComment:h.mutateAsync,isDeletingComment:h.isPending,deleteCommentError:h.error}}const Tu={TOAST_ID:`lifetime-countdown`,WARNING_THRESHOLD:60,UPDATE_INTERVAL:1e3,MESSAGE:e=>`The server will be closed in ${e} seconds.`,STYLE:{fontFamily:`monospace`}};function Eu(e){let t=F,[n,r]=V(null),i=B(void 0),a=L(()=>{if(!e)return 0;let t=new Date,n=Math.floor((e.getTime()-t.getTime())/1e3);return Math.max(0,n)},[e]),o=L(()=>{n!=null&&(t.remove(n),r(null))},[n]),s=L(()=>{if(n==null)return;let e=a();if(e<=0){o();return}t.update(n,{description:Tu.MESSAGE(e)})},[n,a,o]),c=L(()=>{if(!e)return;o();let n=a();n<=0||(r(t.create({id:Tu.TOAST_ID,description:Tu.MESSAGE(n)})),i.current=setInterval(s,Tu.UPDATE_INTERVAL))},[e,a,s,o]),l=a();rr(c,e?Math.max(0,l-Tu.WARNING_THRESHOLD)*1e3:null),R(()=>o,[o])}function Du({run:e,runId:t,viewOptions:n}){let r=z(()=>!e?.type||!e?.result?!1:Ie(e.type),[e?.type,e?.result]),i=z(()=>{if(!e?.result)return null;let t=e.result;if(`total_row_count`in t&&typeof t.total_row_count==`number`)return t.total_row_count;let n=t.base,r=t.current,i=typeof n?.total_row_count==`number`?n.total_row_count:null,a=typeof r?.total_row_count==`number`?r.total_row_count:null;return i!==null&&a!==null?Math.max(i,a):i??a},[e?.result]),a=L(()=>{if(!e?.type||!e?.result)return null;let t={displayMode:n?.display_mode,primaryKeys:e?.params?.primary_keys};return ve(e.type,e.result,t)},[e?.type,e?.result,e?.params,n]),o=L(()=>{let e=a();return e?we(e.columns,e.rows):null},[a]),s=L(()=>{let e=a();return e?Le(e.columns,e.rows):null},[a]),c=L(e=>{if(!t)return;let n=document.createElement(`a`);n.href=`/api/runs/${t}/export?format=${e}`,document.body.appendChild(n),n.click(),document.body.removeChild(n)},[t]),l=L(async()=>{let e=o();if(!e){F.create({title:`Export failed`,description:`Unable to extract data for CSV export`,type:`error`,duration:3e3});return}try{await Ce(e),F.create({title:`Copied to clipboard`,description:`CSV data copied successfully`,type:`success`,duration:2e3})}catch(e){console.error(`Failed to copy CSV to clipboard:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[o]),u=z(()=>e?.type===`query_diff`&&!!e?.params?.primary_keys,[e?.type,e?.params]),d=L(()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`csv`);return}let n=o();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for CSV export`,type:`error`,duration:3e3});return}try{let t=Oe(e?.type??``,e?.params);Te(n,t),F.create({title:`Downloaded`,description:t,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download CSV file:`,e),F.create({title:`Download failed`,description:`Failed to download CSV file`,type:`error`,duration:3e3})}},[t,e,u,o,c]),f=L(async()=>{let e=s();if(!e){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{await Ce(e),F.create({title:`Copied to clipboard`,description:`Text data copied — paste into any spreadsheet`,type:`success`,duration:2e3})}catch(e){console.error(`Failed to copy TSV to clipboard:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[s]),p=L(()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`tsv`);return}let n=s();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{let t=Oe(e?.type??``,e?.params).replace(/\.csv$/,`.tsv`);xe(n,t),F.create({title:`Downloaded`,description:t,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download TSV file:`,e),F.create({title:`Download failed`,description:`Failed to download TSV file`,type:`error`,duration:3e3})}},[t,e,u,s,c]);return{canExportCSV:r,totalRowCount:i,copyAsCSV:l,copyAsTSV:f,downloadAsCSV:d,downloadAsExcel:L(async()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`xlsx`);return}let n=a();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{let t=await Se(n.columns,n.rows),r=Oe(e?.type??``,e?.params).replace(/\.csv$/,`.xlsx`);be(t,r),F.create({title:`Downloaded`,description:r,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download Excel file:`,e),F.create({title:`Download failed`,description:`Failed to download Excel file`,type:`error`,duration:3e3})}},[t,e,u,a,c]),downloadAsTSV:p}}function Ou({description:e,onLike:t,onDislike:n,onClickLink:r,externalLink:i,externalLinkText:a}){return W(G,{sx:{display:`flex`,gap:4,justifyContent:`center`,alignContent:`center`,alignItems:`center`},children:[e,U(Y,{"aria-label":`thumbs up`,onClick:t,sx:{width:`32px`,height:`32px`},children:U(G,{component:`img`,src:`/imgs/feedback/thumbs-up.png`,alt:`like`})}),U(Y,{"aria-label":`thumbs down`,onClick:n,sx:{width:`32px`,height:`32px`},children:U(G,{component:`img`,src:`/imgs/feedback/thumbs-down.png`,alt:`dislike`})}),i&&a&&W(vt,{href:i,target:`_blank`,onClick:r,sx:{textDecoration:`underline`},children:[a,` `,U(bt,{})]})]})}function ku(e){let{feedbackId:t,description:n,onFeedbackSubmit:r,externalLink:i,externalLinkText:a}=e,[o,s]=V(void 0);function c(e=!1){let c=localStorage.getItem(t);o??(c===`true`&&!e||s(F.create({id:t,duration:void 0,type:`success`,description:U(q,{direction:`row`,children:U(Ou,{description:n,onLike:()=>{r(`like`),F.dismiss(t),localStorage.setItem(t,`true`)},onDislike:()=>{r(`dislike`),F.dismiss(t),localStorage.setItem(t,`true`)},externalLink:i,externalLinkText:a,onClickLink:()=>{r(`link`)}})})})))}return{feedbackToast:c,closeToast:()=>{o&&F.dismiss(o)}}}function Au(e){let[t,n]=V(void 0),{guideId:r,description:i,externalLinkText:a,onExternalLinkClick:o}=e;function s(){t??n(F.create({id:r,duration:3e3,type:`success`,description:i,action:{label:a??`link`,onClick:()=>{o&&o()}}}))}return{guideToast:s,closeGuideToast:()=>{t&&F.dismiss(t)}}}function ju(e,t){let n=[];return e.forEach(e=>{n.some(t=>t.name===e.name)||n.push(e)}),t.forEach(e=>{n.some(t=>t.name===e.name)||n.push(e)}),n}function Mu(e,n){let{lineageGraph:r}=pe(),i=D(),a=n??i?.apiClient,o=ar.find(r?.nodes,{data:{name:e}}),s=!!a&&!!o?.id,{data:c,isLoading:l,error:u}=ot({queryKey:[`modelDetail`,o?.id],queryFn:()=>{if(!o?.id||!a)throw Error(`useModelColumns: missing node id or api client`);return t(o.id,a)},enabled:s,staleTime:300*1e3}),{columns:d,primaryKey:f}=z(()=>{let e=c?.model;return!e?.base.columns||!e.current.columns?{columns:[],primaryKey:e?.current.primary_key}:{columns:ju(Object.values(e.base.columns),Object.values(e.current.columns)),primaryKey:e.current.primary_key}},[c]);return{columns:d,primaryKey:f,isLoading:s?l:!1,error:u?u instanceof Error?u:Error(String(u)):null}}const Nu=e=>{let{apiClient:t}=Ql(),n=st(),r=ss(),[i,a]=V(!!e),[,o]=A(),s=B(null);R(()=>{e&&(a(!0),s.current=null)},[e]);let c=e?r.has(e):!1,u=i&&!c,{error:f,data:p}=ot({queryKey:O.run(e??``),queryFn:async()=>await x(e??``,u?2:0,t),enabled:!!e&&!c,refetchInterval:u?50:!1,retry:!1});R(()=>{if(!p)return;let e=p.status?.toLowerCase();f||p.result||p.error||e&&e!==`running`?s.current!==p.run_id&&(s.current=p.run_id,a(!1)):e===`running`&&!c&&(s.current=null,a(!0))},[p,f,c]),R(()=>{(f||p?.result||p?.error)&&(p?.type===`row_count_diff`||p?.type===`row_count`)&&o?.()},[p,f,o]);let m=r.add,h=L(()=>e?(n.setQueryData(O.run(e),e=>e&&{...e,status:`Cancelled`}),m(e),a(!1),s.current=e,l(e,t),Promise.resolve()):Promise.resolve(),[e,t,n,m]),g;return p&&d(p.type)&&(g=gl(p.type).RunResultView),{run:p,isRunning:i,error:f,onCancel:h,RunResultView:g}};function Pu(){let e=wt(),t=ke(),n=P(),[r,i]=V(!1);R(()=>{i(!0)},[]);let a=r?t?t.resolvedMode===`dark`:n:!1;return{isDark:a,theme:e,background:{default:a?N.neutral[900]:N.white,paper:a?N.neutral[800]:N.white,subtle:a?N.neutral[800]:N.neutral[50],emphasized:a?N.neutral[700]:N.neutral[100]},text:{primary:a?N.neutral[50]:N.neutral[900],secondary:a?N.neutral[400]:N.neutral[600],disabled:a?N.neutral[500]:N.neutral[400],inverted:a?N.neutral[900]:N.neutral[50]},border:{light:a?N.neutral[700]:N.neutral[200],default:a?N.neutral[600]:N.neutral[300],strong:a?N.neutral[500]:N.neutral[400]},status:{added:{bg:a?N.green[900]:N.green[100],text:a?N.neutral[50]:N.neutral[900]},removed:{bg:a?N.red[950]:N.red[200],text:a?N.neutral[50]:N.neutral[900]},modified:{bg:a?N.yellow[900]:N.amber[100],text:a?N.neutral[50]:N.neutral[900]}},interactive:{hover:a?N.neutral[700]:N.neutral[100],active:a?N.neutral[600]:N.neutral[200],focus:N.iochmara[500]}}}export{Wc as $,_o as $t,Rl as A,Pi as An,_s as At,_l as B,Vr as Bn,Qo as Bt,tu as C,mi as Cn,Ms as Ct,ql as D,Wi as Dn,Es as Dt,Jl as E,Ui as En,ws as Et,Tl as F,li as Fn,cs as Ft,ll as G,Mr as Gn,Io as Gt,hl as H,Rr as Hn,Vo as Ht,Cl as I,ci as In,es as It,tl as J,Ao as Jt,sl as K,Po as Kt,xl as L,oi as Ln,$o as Lt,Il as M,fi as Mn,hs as Mt,Pl as N,ui as Nn,fs as Nt,Wl as O,Gi as On,Ss as Ot,El as P,di as Pn,ps as Pt,Gc as Q,bo as Qt,yl as R,Ur as Rn,ns as Rt,ru as S,hi as Sn,Fs as St,Xl as T,Q as Tn,Os as Tt,ml as U,Pr as Un,zo as Ut,gl as V,Lr as Vn,Uo as Vt,ul as W,Fr as Wn,Ro as Wt,Yc as X,Oo as Xt,el as Y,Eo as Yt,qc as Z,So as Zt,gu as _,Qi as _n,Ys as _t,Au as a,Xa as an,mc as at,iu as b,pi as bn,Hs as bt,Eu as c,za as cn,uc as ct,yu as d,xa as dn,oc as dt,fo as en,Hc as et,bu as f,_a as fn,ic as ft,hu as g,sa as gn,Xs as gt,_u as h,ca as hn,Zs as ht,Mu as i,to as in,xc as it,Ll as j,Ni as jn,ds as jt,zl as k,ji as kn,ys as kt,wu as l,Ra as ln,$ as lt,Su as m,la as mn,tc as mt,Nu as n,uo as nn,yc as nt,ku as o,Ya as on,pc as ot,xu as p,ua as pn,nc as pt,nl as q,Mo as qt,ju as r,ao as rn,bc as rt,Du as s,qa as sn,fc as st,Pu as t,po as tn,Vc as tt,Cu as u,Pa as un,ac as ut,fu as v,$i as vn,qs as vt,Ql as w,Li as wn,js as wt,uu as x,gi as xn,Ns as xt,au as y,aa as yn,Ks as yt,vl as z,zr as zn,ts as zt};
7
- //# sourceMappingURL=hooks-CeTKVd72.js.map
6
+ `)?U(G,{component:`code`,sx:{bgcolor:n?`grey.800`:`grey.100`,color:n?`grey.200`:`inherit`,px:1,py:.5,borderRadius:.5,fontSize:`0.9em`,fontFamily:`monospace`},children:t}):U(G,{sx:{my:2,borderRadius:1,overflow:`hidden`,fontSize:`0.875rem`},children:U(sr,{style:cr,language:i,PreTag:`div`,customStyle:{margin:0,borderRadius:`6px`,fontSize:`0.85em`},children:a})})}function tc({content:e,fontSize:t=`0.875rem`,internalDomains:n=[]}){let r=P(),i=[window.location.hostname,`reccehq.com`,`datarecce.io`,`localhost`,...n];return U(G,{className:`markdown-content`,children:U(or,{remarkPlugins:[lr],components:{a:({href:e,children:t})=>U($s,{href:e,internalDomains:i,children:t}),code:e=>U(ec,{...e,isDark:r}),p:({children:e})=>U(J,{component:`p`,sx:{fontSize:t,mb:2,"&:last-child":{mb:0}},children:e}),h1:({children:e})=>U(J,{sx:{fontSize:`1.25rem`,fontWeight:`bold`,mb:2,mt:3},children:e}),h2:({children:e})=>U(J,{sx:{fontSize:`1.125rem`,fontWeight:`bold`,mb:2,mt:3},children:e}),h3:({children:e})=>U(J,{sx:{fontSize:`1rem`,fontWeight:600,mb:2,mt:2},children:e}),ul:({children:e})=>U(G,{component:`ul`,sx:{pl:4,mb:2,listStyleType:`disc`},children:e}),ol:({children:e})=>U(G,{component:`ol`,sx:{pl:4,mb:2,listStyleType:`decimal`},children:e}),li:({children:e})=>U(G,{component:`li`,sx:{fontSize:t,mb:1},children:e}),blockquote:({children:e})=>U(G,{sx:{borderLeft:`3px solid`,borderLeftColor:r?`grey.600`:`grey.300`,pl:3,py:1,my:2,color:r?`grey.400`:`grey.600`,fontStyle:`italic`},children:e}),table:({children:e})=>U(G,{sx:{overflowX:`auto`,my:2},children:U(G,{component:`table`,sx:{width:`100%`,fontSize:t,border:`1px solid`,borderColor:r?`grey.700`:`grey.200`,borderRadius:1},children:e})}),thead:({children:e})=>U(G,{component:`thead`,sx:{bgcolor:r?`grey.800`:`grey.50`},children:e}),tbody:({children:e})=>U(G,{component:`tbody`,children:e}),tr:({children:e})=>U(G,{component:`tr`,sx:{borderBottom:`1px solid`,borderColor:r?`grey.700`:`grey.200`},children:e}),th:({children:e})=>U(G,{component:`th`,sx:{px:2,py:1,fontWeight:600,textAlign:`left`},children:e}),td:({children:e})=>U(G,{component:`td`,sx:{px:2,py:1},children:e}),hr:()=>U(G,{component:`hr`,sx:{my:3,borderColor:r?`grey.700`:`grey.200`}}),strong:({children:e})=>U(J,{component:`strong`,sx:{fontWeight:600},children:e}),em:({children:e})=>U(J,{component:`em`,sx:{fontStyle:`italic`},children:e}),del:({children:e})=>U(J,{component:`del`,sx:{textDecoration:`line-through`,color:`grey.500`},children:e})},children:e})})}const nc=ut(function({backgroundColor:e=`white`,blockSize:t,children:n,...r},i){return U(G,{ref:i,...r,sx:{overflowY:`auto`,overflowX:`hidden`,...r.sx},children:U(G,{sx:{backgroundColor:e,height:`100%`,blockSize:t},children:n})})});function rc({children:e,direction:t=`horizontal`,sizes:n,minSizes:r=0,maxSizes:i,gutterSize:a=5,snapOffset:o=30,dragInterval:s=1,onDragEnd:c,onDrag:l,theme:u,style:d,className:f}){let p=P(),m=u?u===`dark`:p,h={display:`flex`,flexDirection:t===`horizontal`?`row`:`column`,height:`100%`,width:`100%`,...d};return U(G,{className:f,sx:{height:`100%`,width:`100%`,"& .gutter":{backgroundColor:`divider`,backgroundRepeat:`no-repeat`,backgroundPosition:`50%`,transition:`background-color 0.15s ease`,"&:hover":{backgroundColor:m?`grey.600`:`grey.300`}},"& .gutter.gutter-horizontal":{cursor:`col-resize`},"& .gutter.gutter-vertical":{cursor:`row-resize`}},children:U(ur,{style:h,direction:t,sizes:n,minSize:r,maxSize:i,gutterSize:a,snapOffset:o,dragInterval:s,onDragEnd:c,onDrag:l,children:e})})}const ic=I(rc);ic.displayName=`SplitPane`;function ac(e){let{style:t,children:n,gutterSize:r=5,minSize:i,maxSize:a,sizes:o,snapOffset:s,dragInterval:c,onDragEnd:l,onDrag:u,className:d}=e;return U(ic,{direction:`horizontal`,gutterSize:r,minSizes:i,maxSizes:a,sizes:o,snapOffset:typeof s==`number`?s:void 0,dragInterval:c,onDragEnd:l,onDrag:u,style:t,className:d,children:n})}function oc(e){let{style:t,children:n,gutterSize:r=5,minSize:i,maxSize:a,sizes:o,snapOffset:s,dragInterval:c,onDragEnd:l,onDrag:u,className:d}=e;return U(ic,{direction:`vertical`,gutterSize:r,minSizes:i,maxSizes:a,sizes:o,snapOffset:typeof s==`number`?s:void 0,dragInterval:c,onDragEnd:l,onDrag:u,style:t,className:d,children:n})}const sc={mode:`multiRow`,checkboxes:!0,headerCheckbox:!0,enableClickSelection:!1};function cc({warning:e,isDark:t}){return W(G,{sx:{display:`flex`,alignItems:`center`,gap:.5,fontSize:`0.75rem`},children:[U(on,{color:t?dr[400]:dr[600]}),U(G,{children:e})]})}function lc({toolbar:e,warnings:t,warningStyle:n=`alert`,isDark:r}){return!e&&(!t||t.length===0)?null:W(G,{sx:{display:`flex`,alignItems:`center`,gap:1,px:1,py:.5,borderBottom:1,borderColor:`divider`,bgcolor:n===`amber`&&t&&t.length>0?r?dr[900]:dr[100]:r?`grey.900`:`grey.50`,color:n===`amber`&&t&&t.length>0?r?dr[200]:dr[800]:void 0},children:[n===`amber`?t?.map(e=>U(cc,{warning:e,isDark:r},e)):t?.map(e=>U(Qn,{severity:`warning`,sx:{py:0,fontSize:`0.75rem`},children:e},e)),U(G,{sx:{flex:1}}),e]})}function $(e){let{displayName:t,typeGuard:n,expectedRunType:r,screenshotWrapper:i,transformData:a,emptyState:o=`No data`,conditionalEmptyState:s,enableRowSelection:c}=e;function l({run:e,viewOptions:t,onViewOptionsChanged:l,onAddToChecklist:u},d){let f=P();if(!n(e))throw Error(`Run type must be ${r}`);let p=z(()=>a(e,{viewOptions:t,onViewOptionsChanged:l,onAddToChecklist:u,isDark:f}),[e,t,l,u,f]),m=s?.(e,t);return m==null?p?.renderNull?null:!p||p.isEmpty?p?.toolbar||p?.warnings&&p.warnings.length>0?W(G,{sx:{display:`flex`,flexDirection:`column`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:[U(lc,{toolbar:p?.toolbar,warnings:p?.warnings,warningStyle:p?.warningStyle,isDark:f}),U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,flex:1},children:p?.emptyMessage??o})]}):U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:o}):i===`grid`?W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[p.header,U(lc,{toolbar:p.toolbar,warnings:p.warnings,warningStyle:p.warningStyle,isDark:f}),U(Fs,{ref:d,style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`0.875rem`,borderWidth:1},columns:p.columns??[],rows:p.rows??[],renderers:{noRowsFallback:U(Ns,{emptyMessage:p.noRowsMessage})},defaultColumnOptions:p.defaultColumnOptions,rowSelection:c?sc:void 0}),p.footer]}):W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[p.header,U(lc,{toolbar:p.toolbar,warnings:p.warnings,warningStyle:p.warningStyle,isDark:f}),U(nc,{ref:d,backgroundColor:f?`#1f2937`:`white`,sx:{height:`100%`},children:p.content}),p.footer]}):U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:f?`grey.900`:`grey.50`,height:`100%`},children:m})}return l.displayName=t,ut(l)}const uc=`0.1.0`;function dc(e){return u(e)}const fc=$({displayName:`HistogramDiffResultView`,typeGuard:dc,expectedRunType:`histogram_diff`,screenshotWrapper:`box`,conditionalEmptyState:e=>{let t=e.result?.base,n=e.result?.current;return!t||!n?U(`div`,{children:`Loading...`}):null},transformData:(e,{isDark:t})=>{let n=e.params,r=e.result?.base,i=e.result?.current,a=e.result?.min,o=e.result?.max,s=e.result?.bin_edges??[];if(!r||!i)return{isEmpty:!0};let c=e.params?.column_type??`numeric`,l=c===`datetime`?`datetime`:c===`string`?`string`:`numeric`;return{content:W(G,{sx:{display:`flex`,flexDirection:`row`},children:[U(G,{sx:{flex:1}}),U(G,{sx:{width:`80%`,height:`35vh`,m:4},children:U(js,{title:`Model ${n.model}.${n.column_name}`,dataType:l,baseData:{counts:r.counts},currentData:{counts:i.counts},min:a,max:o,samples:r.total,binEdges:s,theme:t?`dark`:`light`})}),U(G,{sx:{flex:1}})]})}}});function pc(e,t){if(e.baseIndex===void 0&&e.currentIndex!==void 0)return`added`;if(e.baseIndex!==void 0&&e.currentIndex===void 0)return`removed`;let n=e.baseType!==e.currentType,r=e.definitionChanged===!0||e.reordered===!0;return n&&!r&&t&&e.changeUnknown!==!0?`impacted`:n||r?`changed`:e.changeUnknown===!0?`unknown`:t?`impacted`:`unchanged`}function mc({model:e,row:t,singleEnv:n,cllRunning:r,showMenu:i=!0,onViewCode:a,isImpacted:o}){let s=ue(),{isActionAvailable:c}=pe(),{runAction:l}=j(),{featureToggles:u}=ae(),{name:d,baseType:f,currentType:p,baseIndex:m,currentIndex:h,definitionChanged:g}=t,_=p??f??t.type,v=!(m===void 0&&h!==void 0)&&!(m!==void 0&&h===void 0)&&f!==p,y=n?`unchanged`:pc(t,o),b=y===`added`?`added`:y===`removed`?`removed`:y===`unknown`?`definition_unknown`:(y===`changed`||y===`impacted`)&&v?`type_changed`:y===`changed`&&g?`definition_changed`:`unchanged`,[x,S]=V(null),C=!!x,w=e=>{e.stopPropagation(),S(e.currentTarget)},T=()=>{S(null)},E=()=>{l(`profile_diff`,{model:e.name,columns:[d]},{showForm:!1,trackProps:{action:`profile_diff`,source:`schema_column_menu`,node_count:1}})},ee=()=>{l(`histogram_diff`,{model:e.name,column_name:d,column_type:_},{showForm:!1,trackProps:{action:`histogram_diff`,source:`schema_column_menu`,node_count:1}})},D=()=>{l(`top_k_diff`,{model:e.name,column_name:d,k:50},{showForm:!1,trackProps:{action:`top_k_diff`,source:`schema_column_menu`,node_count:1}})},O=()=>{l(`value_diff`,{model:e.name,columns:[d]},{showForm:!0,trackProps:{action:`value_diff`,source:`schema_column_menu`,node_count:1}})},k=!f||!p;return U(X,{title:oi({name:d,status:b,baseType:f,currentType:p,cllAvailable:!(s===void 0||!c(`change_analysis`)||m!==void 0&&h===void 0),impacted:y===`impacted`}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`3px`},children:[y===`changed`&&(g?U(X,{title:`Definition changed — click to view code`,placement:`top`,onMouseOver:e=>e.stopPropagation(),children:a?U(`button`,{type:`button`,className:`schema-change-badge schema-change-badge-changed schema-change-badge-clickable`,onClick:e=>{e.stopPropagation(),a()},children:`~`}):U(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`})}):U(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`})),y===`added`&&U(`span`,{className:`schema-change-badge schema-change-badge-added`,children:`+`}),y===`removed`&&U(`span`,{className:`schema-change-badge schema-change-badge-removed`,children:`-`}),y===`impacted`&&U(`span`,{className:`schema-change-badge schema-change-badge-impacted`,children:`!`}),y===`unknown`&&U(X,{title:`Change status unknown — analyzer couldn't resolve column dependencies`,placement:`top`,onMouseOver:e=>e.stopPropagation(),children:U(`span`,{className:`schema-change-badge schema-change-badge-unknown`,children:`?`})}),U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:d}),v?W(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:`0.125rem`,ml:`0.25rem`,fontSize:`1.6rem`,lineHeight:1},children:[f&&U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,textDecoration:`line-through`,opacity:.6},children:U(ci,{type:f,disableTooltip:!0})}),U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,fontSize:`0.7em`,opacity:.5},children:`→`}),p&&U(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`},children:U(ci,{type:p,disableTooltip:!0})})]}):_&&U(G,{component:`span`,sx:{ml:`0.25rem`,fontSize:`1.6rem`},children:U(ci,{type:_,disableTooltip:!0})}),U(G,{sx:{flex:1}}),r&&U(pn,{size:12,color:`inherit`}),i&&!n&&e.resource_type!==`source`&&W(H,{children:[U(Y,{"aria-label":`Column options`,className:`row-context-menu`,size:`small`,disabled:u.disableDatabaseQuery,onClick:w,children:U(dn,{})}),W(ln,{anchorEl:x,open:C,onClose:T,slotProps:{list:{sx:{lineHeight:`20px`}}},children:[U(mn,{sx:{m:0,p:`4px 12px`,lineHeight:`20px`},children:`Diff`}),U(Z,{onClick:()=>{E(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Profile Diff`}),U(Z,{onClick:()=>{ee(),T()},disabled:k||(_?!Ra(_):!0),sx:{fontSize:`0.85rem`},children:`Histogram Diff`}),U(Z,{onClick:()=>{D(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Top-k Diff`}),U(Z,{onClick:()=>{O(),T()},disabled:k,sx:{fontSize:`0.85rem`},children:`Value Diff`})]})]})]})})}function hc(e,t,n,r){return i=>{let a=i.data;return a?U(mc,{model:e,row:a,cllRunning:t?.get(a.name)??!1,showMenu:n,onViewCode:r,isImpacted:a.isImpacted}):null}}function gc(e,t,n){return r=>{let i=r.data;return i?U(mc,{model:e,row:i,cllRunning:t?.get(i.name)??!1,singleEnv:!0,showMenu:n}):null}}function _c(e){let t=e.scopedColumns?new Set(e.scopedColumns):void 0;return n=>{let r=n.data;if(!r)return null;let i=e.payloads[r.name],a=!t||t.has(r.name);return U(Pa,{payload:i,columnType:r.currentType??r.baseType,baseTotal:e.baseTotal,currentTotal:e.currentTotal,isLoading:e.isLoading&&!i&&a,hasError:e.hasError&&a,notProfiled:!a})}}function vc(e){if(!e.data)return null;let{baseIndex:t,currentIndex:n,reordered:r}=e.data;return r&&t!==void 0&&n!==void 0&&t!==n?W(`span`,{children:[U(`span`,{className:`schema-index-old`,children:t}),U(`span`,{className:`schema-index-new`,children:n})]}):U(`span`,{children:n===void 0?t??`-`:n??`-`})}function yc(e={},t={}){let n={},r=Me(Object.keys(e),Object.keys(t));Object.entries(r).forEach(([e,t])=>{n[e]={name:e,reordered:t===`reordered`,__status:void 0}});let i=0;return Object.entries(e).forEach(([e,t])=>{t!=null&&(n[e].baseIndex=i+=1,n[e].baseType=t.type)}),i=0,Object.entries(t).forEach(([e,t])=>{t!=null&&(n[e].currentIndex=i+=1,n[e].currentType=t.type)}),n}function bc(e,t={}){let{node:n,cllRunningMap:r,showMenu:i,columnChanges:a,onViewCode:o,impactedColumns:s,nodeId:c,distribution:l}=t,u=[{field:`index`,headerName:``,resizable:!0,minWidth:35,width:35,cellRenderer:vc,cellClass:`schema-column schema-column-index`},{field:`name`,headerName:`Name`,resizable:!0,flex:1,minWidth:180,cellRenderer:n?hc(n,r,i,o):void 0,cellClass:`schema-column`,valueGetter:e=>{let t=e.data;return t?`${t.name}|${t.definitionChanged??!1}|${t.isImpacted??!1}|${t.changeUnknown??!1}`:``}}];l&&u.push({colId:`distribution`,headerName:`Distribution`,resizable:!0,sortable:!1,minWidth:150,width:160,cellRenderer:_c(l),cellClass:`schema-column schema-column-profile-distribution`});let d=Object.values(e);if(a)for(let e of d){let t=e.baseIndex===void 0,n=e.currentIndex===void 0,r=!t&&!n&&e.baseType!==e.currentType,i=a[e.name];i===`modified`&&!t&&!n&&!r&&!e.reordered?e.definitionChanged=!0:i===`unknown`&&!t&&!n&&!r&&!e.reordered&&(e.changeUnknown=!0)}if(c&&s)for(let e of d)Ee(c,e.name,s)&&(e.isImpacted=!0);return{columns:u,rows:d}}function xc(e={},t={}){let{node:n,cllRunningMap:r,showMenu:i}=t,a=Object.entries(e).filter(([e,t])=>t!=null).map(([e,t],n)=>({name:e,index:n+1,type:t.type,__status:void 0}));return{columns:[{field:`index`,headerName:``,resizable:!0,minWidth:35,width:35,cellClass:`schema-column schema-column-index`},{field:`name`,headerName:`Name`,resizable:!0,flex:1,minWidth:180,cellRenderer:n?gc(n,r,i):void 0,cellClass:`schema-column`}],rows:a}}function Sc({columnName:e,primaryKeys:t}){return U(G,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`},children:t.includes(e)&&U(fn,{})})}function Cc({params:e,column:t}){let{runAction:n}=j(),{featureToggles:r}=ae(),[i,a]=V(null),o=!!i,s=e=>{a(e.currentTarget)},c=()=>{a(null)},l=(t,r)=>{n(`value_diff_detail`,{...e,...t},r)};return W(G,{sx:{display:`flex`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t}),U(G,{sx:{flex:1}}),U(Y,{"aria-label":`Column options`,className:`row-context-menu`,size:`small`,disabled:r.disableDatabaseQuery,onClick:s,children:U(Jt,{})}),W(ln,{anchorEl:i,open:o,onClose:c,slotProps:{list:{sx:{lineHeight:`20px`}}},children:[U(mn,{sx:{fontSize:`8pt`,lineHeight:`20px`},children:`Action`}),U(Z,{onClick:()=>{l({},{showForm:!0}),c()},sx:{fontSize:`10pt`},children:`Show mismatched values...`}),W(Z,{onClick:()=>{l({columns:[t]},{showForm:!1}),c()},sx:{fontSize:`10pt`},children:[`Show mismatched values for '`,t,`'`]})]})]})}function wc({value:e}){let t=`N/A`;return e!=null&&(t=e>.9999&&e<1?`~99.99 %`:e<1e-4&&e>0?`~0.01 %`:`${(e*100).toFixed(2)} %`),U(G,{sx:{textAlign:`right`},children:t})}function Tc(e){return t=>{let n=t.data;return n?U(Sc,{columnName:String(n[0]),primaryKeys:e}):null}}function Ec(e){return t=>{let n=t.data,r=t.colDef?.field??``;return n?U(Cc,{column:String(n[r]),params:e}):null}}function Dc(e){let t=e.data,n=e.colDef?.field??``;return t?U(wc,{value:t[n]}):null}const Oc=[{key:`0`,name:`Column`,type:`text`},{key:`1`,name:`Matched`,type:`number`},{key:`2`,name:`Matched %`,type:`number`}];function kc(e){let t=e.data;if(!t)return;let n=t[2];return n!=null&&n<1?`diff-cell-modified`:void 0}function Ac(e,t){let n=e==null,r=t==null;return n&&r?0:n?1:r?-1:e-t}const jc={PRIMARY_KEY_INDICATOR:`__is_pk__`,COLUMN_NAME:`0`,MATCHED_COUNT:`1`,MATCHED_PERCENT:`2`};function Mc(e,t){return[{field:jc.PRIMARY_KEY_INDICATOR,headerName:``,width:30,maxWidth:30,sortable:!1,cellRenderer:Tc(e)},{field:jc.COLUMN_NAME,headerName:`Column`,resizable:!0,cellRenderer:Ec(t),cellClass:`cell-show-context-menu`},{field:jc.MATCHED_COUNT,headerName:`Matched`,resizable:!0,cellClass:kc},{field:jc.MATCHED_PERCENT,headerName:`Matched %`,resizable:!0,sort:`asc`,comparator:Ac,cellRenderer:Dc,cellClass:kc}]}function Nc(e,t){let{params:n}=t,r=Array.isArray(n.primary_key)?n.primary_key:[n.primary_key],i={...e.data,columns:Oc};return{columns:Mc(r,n),rows:We(i)}}function Pc(e){if(p(e)||y(e))return e.result?{kind:`query`,result:e.result}:null;if(w(e))return e.result?e.result.diff&&e.params?.primary_keys?{kind:`query_diff_joined`,result:e.result,primaryKeys:e.params.primary_keys}:{kind:`query_diff_separate`,result:e.result}:null;if(ee(e))return!e.result||!e.params?null:{kind:`value_diff`,result:e.result,params:e.params};if(T(e)){if(!e.result||!e.params?.primary_key)return null;let t=e.params.primary_key,n=Array.isArray(t)?t:[t];return{kind:`value_diff_detail`,result:e.result,primaryKeys:n}}return f(e)?e.result?.current?{kind:`profile`,result:e.result}:null:S(e)?e.result?{kind:`profile_diff`,result:e.result}:null:b(e)?e.result?{kind:`row_count`,result:e.result}:null:g(e)&&e.result?{kind:`row_count_diff`,result:e.result}:null}function Fc(e){let t=e.data;if(!t)return null;let n=e.colDef?.field??``,r=String(ze(t,n)??e.value??``),i=String(ze(t,`data_type`)??``)||void 0;return U(X,{title:oi({name:r,currentType:i}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`6px`,overflow:`hidden`,height:`100%`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&U(G,{component:`span`,sx:{fontSize:`1.6rem`},children:U(ci,{type:i,disableTooltip:!0})})]})})}function Ic(e){let t=e.data;if(!t)return null;let n=e.colDef?.field??``,r=String(ze(t,n)??e.value??``),i=ze(t,`base__data_type`),a=i==null?void 0:String(i),o=ze(t,`current__data_type`),s=o==null?void 0:String(o),c=a!=null&&s!=null&&a!==s,l=s??a;return U(X,{title:oi({name:r,baseType:a,currentType:s}),placement:`top`,children:W(G,{sx:{display:`flex`,alignItems:`center`,gap:`6px`,overflow:`hidden`,height:`100%`},children:[U(G,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),c?W(G,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:`0.125rem`,fontSize:`1.6rem`},children:[U(G,{component:`span`,sx:{textDecoration:`line-through`,opacity:.6},children:U(ci,{type:a,disableTooltip:!0})}),U(G,{component:`span`,sx:{fontSize:`0.7em`,opacity:.5},children:`→`}),U(ci,{type:s,disableTooltip:!0})]}):l&&U(G,{component:`span`,sx:{fontSize:`1.6rem`},children:U(ci,{type:l,disableTooltip:!0})})]})})}function Lc(e){if(!e)return!1;let t=e.toLowerCase();return t===`data_type`||t===`base__data_type`||t===`current__data_type`}function Rc(e){let t=e.rows.length>0&&Object.hasOwn(e.rows[0],`base__data_type`),n=e.columns.filter(e=>{if(`children`in e&&e.children){let t=e.children.filter(e=>!Lc(e.field));return t.length===0?!1:(e.children=t,!0)}return!Lc(e.field)}).map(e=>{if(`children`in e&&e.children)return{...e,children:e.children.map(e=>{let t=e;return t.field?.toLowerCase()===`column_name`?{...t,cellRenderer:Fc}:e})};let n=e;return n.field?.toLowerCase()===`column_name`?{...n,cellRenderer:t?Ic:Fc}:e});return{...e,columns:n}}function zc(e){return e.current?.columns.find(e=>e.name.toLowerCase()===`column_name`)?.name??`column_name`}function Bc(e,t={}){let n=Pc(e);if(!n)return null;switch(n.kind){case`query`:return De(n.result,{primaryKeys:t.primaryKeys,pinnedColumns:t.pinnedColumns,columnsRenderMode:t.columnsRenderMode,onPrimaryKeyChange:t.onPrimaryKeyChange,onPinnedColumnsChange:t.onPinnedColumnsChange,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged});case`query_diff_separate`:return qe(n.result.base,n.result.current,t);case`query_diff_joined`:return n.result.diff?Ke(n.result.diff,n.primaryKeys,{changedOnly:t.changedOnly,pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,baseTitle:t.baseTitle,currentTitle:t.currentTitle,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}):null;case`value_diff`:return Nc(n.result,{params:n.params});case`value_diff_detail`:return Ke(n.result,n.primaryKeys,{changedOnly:t.changedOnly,pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged});case`profile`:{if(!n.result.current)return null;let e=zc(n.result);return Rc(De(n.result.current,{primaryKeys:[e],pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}))}case`profile_diff`:{let e=zc(n.result);return Rc(qe(n.result.base,n.result.current,{primaryKeys:[e],pinnedColumns:t.pinnedColumns,onPinnedColumnsChange:t.onPinnedColumnsChange,displayMode:t.displayMode,columnsRenderMode:t.columnsRenderMode,onColumnsRenderModeChanged:t.onColumnsRenderModeChanged}))}case`row_count`:return je(n.result);case`row_count_diff`:return Ge(n.result);default:return null}}function Vc(e,t){switch(e.type){case`single`:return De(e.dataframe,t??{});case`dual`:return qe(e.base,e.current,t??{});case`joined`:return Ke(e.dataframe,e.primaryKeys,t??{});case`schema_diff`:{let n=t??{};return bc(yc(e.base,e.current),n)}case`schema_single`:return xc(e.columns,t??{})}}function Hc({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let[r,i]=V(!e.columns||e.columns.length===0),a=e.model,{columns:o,isLoading:s,error:c}=Mu(e.model);R(()=>{n(!!a)},[a,n]);let l=o.map(e=>e.name);return s?U(G,{children:`Loading...`}):l.length===0||c?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):W(q,{spacing:5,sx:{m:`8px 24px`,pb:`200px`},children:[W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Model`}),U(yn,{fullWidth:!0,size:`small`,value:e.model,slotProps:{input:{readOnly:!0}}})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Columns`}),U(zt,{control:U(Rt,{checked:r,onChange:n=>{i(n.target.checked),t({...e,columns:void 0})},size:`small`}),label:`All columns`,sx:{mb:`10px`}}),!r&&U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:l,value:e.columns??[],onChange:(n,r)=>{t({...e,columns:r.length===0?void 0:r})},renderInput:t=>U(yn,{...t,placeholder:(e.columns??[]).length===0?`Select columns`:``,className:`no-track-pii-safe`})})]})]})}const Uc=e=>typeof e==`object`&&!!e&&`type`in e&&S(e),Wc=$({displayName:`ProfileResultView`,typeGuard:e=>typeof e==`object`&&!!e&&`type`in e&&f(e),expectedRunType:`profile`,screenshotWrapper:`grid`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=Bc(e,{pinnedColumns:t?.pinned_columns??[],onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},columnsRenderMode:{distinct_proportion:`percent`,not_null_proportion:`percent`,...t?.columnsRenderMode},onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})}})??{columns:[],rows:[]};return{columns:r.columns,rows:r.rows,isEmpty:r.columns.length===0}}}),Gc=$({displayName:`ProfileDiffResultView`,typeGuard:Uc,expectedRunType:`profile_diff`,screenshotWrapper:`grid`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=t?.pinned_columns??[],i=t?.display_mode??`inline`,a=Bc(e,{pinnedColumns:r,onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},displayMode:i,columnsRenderMode:{distinct_proportion:`percent`,not_null_proportion:`percent`,...t?.columnsRenderMode},onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})}})??{columns:[],rows:[]},o=U(Os,{children:U(ua,{displayMode:i,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}})});return{columns:a.columns,rows:a.rows,header:o,isEmpty:a.columns.length===0}}});function Kc(e){return w(e)}const qc=$({displayName:`QueryDiffResultView`,typeGuard:Kc,expectedRunType:`query_diff`,screenshotWrapper:`grid`,enableRowSelection:!0,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=e.result&&`diff`in e.result&&e.result.diff!=null,i,a;e.params&&e.params.current_model&&(i=`Original`,a=`Editor`);let o=t?.changed_only??!1,s=t?.pinned_columns??[],c=t?.display_mode??`inline`,l=t?.columnsRenderMode??{},u=r?[]:t?.primary_keys??[],d=e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},f=r?void 0:e=>{n&&n({...t,primary_keys:e})},p=e=>{n&&n({...t,pinned_columns:e})},m;if(r&&e.result?.diff){let t=e.params?.primary_keys??[];m=Ke(e.result.diff,t,{changedOnly:o,pinnedColumns:s,onPinnedColumnsChange:p,columnsRenderMode:l,onColumnsRenderModeChanged:d,baseTitle:i,currentTitle:a,displayMode:c})}else m=qe(e.result?.base,e.result?.current,{changedOnly:o,pinnedColumns:s,onPinnedColumnsChange:p,columnsRenderMode:l,onColumnsRenderModeChanged:d,baseTitle:i,currentTitle:a,displayMode:c,primaryKeys:u,onPrimaryKeyChange:f});let h=[];if(!r&&u.length>0){let e=u.join(`, `);m.invalidPKeyBase&&m.invalidPKeyCurrent?h.push(`Warning: The primary key '${e}' is not unique in the base and current environments`):m.invalidPKeyBase?h.push(`Warning: The primary key '${e}' is not unique in the base environment`):m.invalidPKeyCurrent&&h.push(`Warning: The primary key '${e}' is not unique in the current environment`)}let g=r?e.result?.diff?.limit??0:e.result?.current?.limit??0,_=r?e.result?.diff?.more:e.result?.current?.more||e.result?.base?.more;if(g>0&&_&&h.push(`Warning: Displayed results are limited to ${g.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`),m.columns.length===0)return{isEmpty:!0};let v=W(H,{children:[U(ua,{displayMode:c,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}}),U(ca,{changedOnly:t?.changed_only,onChange:()=>{let e=!t?.changed_only;n&&n({...t,changed_only:e})}})]});return r&&o&&m.rows.length===0?{isEmpty:!0,emptyMessage:`No change`,toolbar:v,warnings:h.length>0?h:void 0}:{columns:m.columns,rows:m.rows,warnings:h.length>0?h:void 0,toolbar:v,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},noRowsMessage:`No mismatched rows`}}});function Jc(e){return p(e)||y(e)}const Yc=$({displayName:`QueryResultView`,typeGuard:Jc,expectedRunType:`query`,screenshotWrapper:`grid`,enableRowSelection:!0,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n,onAddToChecklist:r})=>{let i=t?.pinned_columns??[],a=t?.columnsRenderMode??{},o=e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},s=e=>{n&&n({...t,pinned_columns:e})};if(!e.result)return{isEmpty:!0};let c=De(e.result,{pinnedColumns:i,onPinnedColumnsChange:s,columnsRenderMode:a,onColumnsRenderModeChanged:o});if(c.columns.length===0)return{isEmpty:!0};let l=e.result,u=l?l.limit??0:0,d=[];u>0&&l?.more&&d.push(`Warning: Displayed results are limited to ${u.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`);let f=r?U(K,{sx:{my:`5px`},size:`small`,color:`iochmara`,variant:`contained`,onClick:()=>{r(e)},children:`Add to Checklist`}):void 0;return{columns:c.columns,rows:c.rows,warnings:d.length>0?d:void 0,warningStyle:`amber`,toolbar:f,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35}}}});function Xc(e){return b(e)}function Zc(e){return g(e)}function Qc(e){if(!e.result)return null;let t=je(e.result);return{columns:t.columns,rows:t.rows,isEmpty:t.rows.length===0}}function $c(e){if(!e.result)return null;let t=Ge(e.result);return{columns:t.columns,rows:t.rows,isEmpty:t.rows.length===0}}const el=$({displayName:`RowCountResultView`,typeGuard:Xc,expectedRunType:`row_count`,screenshotWrapper:`grid`,transformData:Qc,emptyState:`No nodes matched`}),tl=$({displayName:`RowCountDiffResultView`,typeGuard:Zc,expectedRunType:`row_count_diff`,screenshotWrapper:`grid`,transformData:$c,emptyState:`No nodes matched`});function nl({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let{columns:r,isLoading:i,error:a}=Mu(e.model),o=r.map(e=>e.name);return R(()=>{n(!!e.column_name)},[e,n]),i?U(G,{children:`Loading...`}):o.length===0||a?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):U(G,{sx:{m:`16px`},children:W(hn,{fullWidth:!0,children:[U(gn,{sx:{mb:1},children:`Pick a column to show top-k`}),W(_n,{value:e.column_name,onChange:n=>{let r=n.target.value;t({...e,column_name:r})},children:[U(`option`,{value:``,children:`Select column`}),o.map(e=>U(`option`,{value:e,className:`no-track-pii-safe`,children:e},e))]})]})})}function rl(e){return _(e)}function il({model:e,columnName:t}){return W(J,{variant:`h5`,sx:{pt:4,textAlign:`center`,color:P()?`grey.200`:`grey.600`},children:[`Model `,e,`.`,t]})}function al({showAll:e,onToggle:t}){return U(G,{sx:{display:`flex`,p:5,justifyContent:`start`},children:U(vt,{component:`button`,onClick:t,sx:{color:`iochmara.main`,cursor:`pointer`},children:e?`View Only Top-10`:`View More Items`})})}function ol(e,{viewOptions:t,onViewOptionsChanged:n,isDark:r}){let i=e.result,a=e.params;if(!i)return{isEmpty:!0};let o=i.base,s=i.current,c=t?.show_all??!1,l=!c,u=o.values.length>10||s.values.length>10?U(al,{showAll:c,onToggle:()=>{n&&n({...t,show_all:!c})}}):void 0;return{content:W(H,{children:[U(il,{model:a.model,columnName:a.column_name}),W(q,{direction:`row`,sx:{alignItems:`center`},children:[U(G,{sx:{flex:1}}),U(Hs,{baseData:o,currentData:s,showComparison:!0,maxItems:l?10:void 0,theme:r?`dark`:`light`}),U(G,{sx:{flex:1}})]})]}),footer:u}}const sl=$({displayName:`TopKDiffResultView`,typeGuard:rl,expectedRunType:`top_k_diff`,screenshotWrapper:`box`,emptyState:`No data`,transformData:ol});function cl(e){return T(e)}const ll=$({displayName:`ValueDiffDetailResultView`,typeGuard:cl,expectedRunType:`value_diff_detail`,screenshotWrapper:`grid`,emptyState:`No data`,transformData:(e,{viewOptions:t,onViewOptionsChanged:n})=>{let r=t?.changed_only??!1,i=t?.pinned_columns??[],a=t?.display_mode??`inline`,o=t?.columnsRenderMode??{},s=e.params?.primary_key;if(!s||!e.result)return{isEmpty:!0};let c=Array.isArray(s)?s:[s],l=Ke(e.result,c,{changedOnly:r,pinnedColumns:i,onPinnedColumnsChange:e=>{n&&n({...t,pinned_columns:e})},columnsRenderMode:o,onColumnsRenderModeChanged:e=>{let r={...t?.columnsRenderMode??{},...e};n&&n({...t,columnsRenderMode:r})},displayMode:a});if(l.columns.length===0)return{isEmpty:!0};let u=e.result?.limit??0,d=[];u>0&&e.result?.more&&d.push(`Warning: Displayed results are limited to ${u.toLocaleString()} records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set.`);let f=W(H,{children:[U(ua,{displayMode:a,onDisplayModeChanged:e=>{n&&n({...t,display_mode:e})}}),U(ca,{changedOnly:t?.changed_only,onChange:()=>{let e=!t?.changed_only;n&&n({...t,changed_only:e})}})]});return r&&l.rows.length===0?{isEmpty:!0,emptyMessage:`No change`,toolbar:f,warnings:d.length>0?d:void 0,warningStyle:`amber`}:{columns:l.columns,rows:l.rows,warnings:d.length>0?d:void 0,warningStyle:`amber`,toolbar:f,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},noRowsMessage:`No mismatched rows`}}});function ul({params:e,onParamsChanged:t,setIsReadyToExecute:n}){let[r,i]=V(!e.columns||e.columns.length===0),a=e.model,o=e.primary_key,{columns:s,primaryKey:c,isLoading:l,error:u}=Mu(e.model);R(()=>{!o&&c&&t({...e,primary_key:c})},[o,c,e,t]),R(()=>{n(!!(o&&a))},[o,a,n]);let d=s.map(e=>e.name),f=Array.isArray(o)?o:o?[o]:void 0;return l?U(G,{children:`Loading...`}):d.length===0||u?U(G,{children:`Error: Please provide the 'catalog.json' to list column candidates`}):W(q,{spacing:5,sx:{m:`8px 24px`,pb:`200px`},children:[W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Model`}),U(yn,{fullWidth:!0,size:`small`,value:e.model,slotProps:{input:{readOnly:!0}}})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Primary key`}),U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:d,value:(f??[]).filter(e=>e!==void 0),onChange:(n,r)=>{t({...e,primary_key:r.length===1?r[0]:r})},renderInput:e=>U(yn,{...e,placeholder:(f??[]).length===0?`Select primary key`:``,className:`no-track-pii-safe`})})]}),W(G,{children:[U(J,{variant:`body2`,sx:{mb:1},children:`Columns`}),U(zt,{control:U(Rt,{checked:r,onChange:n=>{i(n.target.checked),t({...e,columns:void 0})},size:`small`}),label:`All columns`,sx:{mb:`10px`}}),!r&&U(wr,{multiple:!0,size:`small`,disableCloseOnSelect:!0,options:d,value:e.columns??[],onChange:(n,r)=>{t({...e,columns:r.length===0?void 0:r})},renderInput:t=>U(yn,{...t,placeholder:(e.columns??[]).length===0?`Select columns`:``,className:`no-track-pii-safe`})})]})]})}function dl(e){return ee(e)}function fl({params:e,summary:t}){let n=t.total-t.added-t.removed;return W(G,{sx:{px:`16px`,pt:`5px`,pb:`5px`},children:[`Model: `,e.model,`, `,t.total,` total (`,n,` common,`,` `,t.added,` added, `,t.removed,` removed)`]})}function pl(e){if(!e.result||!e.params)return{renderNull:!0};let t=Nc(e.result,{params:e.params});return t?{columns:t.columns,rows:t.rows,isEmpty:!1,header:U(fl,{params:e.params,summary:e.result.summary})}:{renderNull:!0}}const ml=$({displayName:`ValueDiffResultView`,typeGuard:dl,expectedRunType:`value_diff`,screenshotWrapper:`grid`,transformData:pl}),hl={lineage_diff:{title:`Lineage Diff`,icon:yr},schema_diff:{title:`Schema Diff`,icon:_r},query:{title:`Query`,icon:Cr,RunResultView:Yc},query_base:{title:`Query Base`,icon:Cr,RunResultView:Yc},query_diff:{title:`Query Diff`,icon:Cr,RunResultView:qc},row_count:{title:`Row Count`,icon:gr,RunResultView:el},row_count_diff:{title:`Row Count Diff`,icon:gr,RunResultView:tl},profile:{title:`Profile`,icon:Sr,RunResultView:Wc,RunForm:Hc},profile_diff:{title:`Profile Diff`,icon:Sr,RunResultView:Gc,RunForm:Hc},value_diff:{title:`Value Diff`,icon:vr,RunResultView:ml,RunForm:ul},value_diff_detail:{title:`Value Diff Detail`,icon:vr,RunResultView:ll,RunForm:ul},top_k_diff:{title:`Top-K Diff`,icon:yt,RunResultView:sl,RunForm:nl},histogram_diff:{title:`Histogram Diff`,icon:br,RunResultView:fc,RunForm:za},simple:{title:`Simple`,icon:xr}};function gl(e){return hl[e]}const _l=hl;function vl(e){let t={...hl};for(let[n,r]of Object.entries(e))r&&n in t&&(t[n]={...t[n],...r});return t}function yl(e){return t=>e[t]}function bl(e){return{id:e.run_id,name:e.name,type:e.type,status:e.status??`Finished`,runAt:e.run_at,checkId:e.check_id}}function xl(){let{closeHistory:t,showRunId:n,runId:r}=j(),{featureToggles:i}=ae(),{apiClient:o}=Ql(),s=pr(),c=st(),{basePath:l}=oe(),{data:u,isLoading:d}=ot({queryKey:O.runs(),queryFn:async()=>await e(o),retry:!1}),f=z(()=>(u??[]).map(bl),[u]),p=L(e=>{Qe({name:`click_run`}),n(e,!1)},[n]),m=L(async e=>{Qe({name:`add_to_checklist`});let t=await a(e,void 0,o);await c.invalidateQueries({queryKey:O.checks()}),s.push(`${l}/checks/?id=${t.check_id}`)},[o,c,s.push,l]),h=L(e=>{Qe({name:`go_to_check`}),s.push(`${l}/checks/?id=${e}`)},[s.push,l]),g=L(()=>{Qe({name:`hide`}),t()},[t]),_=L(e=>{let t=gl(e)?.icon;return t?U(t,{}):null},[]),v=U(Y,{"aria-label":`Close History`,onClick:g,children:U(sn,{})});return U(Ss,{runs:f,selectedId:r,isLoading:d,onRunSelect:p,onAddToChecklist:m,onGoToCheck:h,getRunIcon:_,hideAddToChecklist:i.disableUpdateChecklist&&!i.checklistPermissionDenied,disableAddToChecklist:i.checklistPermissionDenied,title:`History`,headerActions:v,emptyMessage:`No runs`,loadingMessage:`Loading...`,groupByDate:!0,addToChecklistIcon:U(hr,{}),goToCheckIcon:U(mr,{color:`green`})})}const Sl=({size:e=16})=>W(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[U(`circle`,{cx:`12`,cy:`12`,r:`10`}),U(`path`,{d:`M12 16v-4`}),U(`path`,{d:`M12 8h.01`})]});function Cl({isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,RunForm:o,onCancel:s,onExecuteClick:c,documentationUrl:l,InfoIcon:u=Sl}){let[d,f]=V(a??{}),[p,m]=V(null),[h,g]=V(!1),_=B(!1),v=()=>{_.current||s?.(),_.current=!1,t()};return W(mt,{open:e,onClose:v,maxWidth:`sm`,fullWidth:!0,scroll:`paper`,slotProps:{paper:{sx:{height:`75%`,minHeight:`400px`}}},children:[W(_t,{sx:{display:`flex`,alignItems:`center`},children:[i,` `,l&&W(H,{children:[U(Y,{size:`small`,"aria-label":`Click this button to learn more about the SQL behind`,onMouseEnter:e=>m(e.currentTarget),onMouseLeave:()=>m(null),onClick:()=>window.open(l,`_blank`),children:U(G,{component:u,sx:{fontSize:`16px`}})}),U(Bn,{open:!!p,anchorEl:p,onClose:()=>m(null),anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},disableRestoreFocus:!0,sx:{pointerEvents:`none`},slotProps:{paper:{sx:{bgcolor:`black`,color:`white`,p:1}}},children:W(J,{sx:{fontSize:`0.875rem`},children:[`Click`,` `,U(vt,{href:l,target:`_blank`,sx:{textDecoration:`underline`,color:`white`,"&:hover":{color:`iochmara.300`}},children:`here`}),` `,`to learn more about the SQL behind`]})})]})]}),U(Y,{"aria-label":`close`,onClick:v,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),U(gt,{sx:{p:0,overflow:`auto`,borderTop:`1px solid`,borderBottom:`1px solid`,borderColor:`divider`},children:U(G,{sx:{contain:`layout`},children:o&&U(o,{params:d,onParamsChanged:f,setIsReadyToExecute:g})})}),U(ht,{children:U(q,{direction:`row`,spacing:`10px`,children:U(K,{disabled:!h,color:`iochmara`,variant:`contained`,onClick:()=>{_.current=!0,c?.(),n(r,d)},children:`Execute`})})})]})}const wl=e=>({value_diff:`https://docs.reccehq.com/features/lineage/#value-diff`,profile_diff:`https://docs.reccehq.com/features/lineage/#profile-diff`,histogram_diff:`https://docs.reccehq.com/features/lineage/#histogram-diff`,top_k_diff:`https://docs.reccehq.com/features/lineage/#top-k-diff`})[e]||null;function Tl({isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,initialRun:o,RunForm:s}){return U(Cl,{isOpen:e,onClose:t,onExecute:n,type:r,title:i,params:a,initialRun:o,RunForm:s,onCancel:()=>{Ye(r)&&Ze({action:r,event:Je.CANCEL})},onExecuteClick:()=>{Ye(r)&&Ze({action:r,event:Je.EXECUTE})},documentationUrl:wl(r),InfoIcon:Zt})}const El=ut(function({isRunning:e,runId:t,progress:n,error:r,run:i,onCancel:a,viewOptions:o,onViewOptionsChanged:s,RunResultView:c,children:l,ErrorBoundary:u,errorBoundaryFallback:d},f){let p=P(),m=ss(),h=r?.response?.data?.detail??i?.error,g=i?.run_id??t,_=g!=null&&m.has(g),v=i?.status===`Cancelled`||_;if(h)return W(Qn,{severity:`error`,sx:p?{bgcolor:`error.dark`,color:`common.white`,"& .MuiAlert-icon":{color:`common.white`}}:void 0,children:[`Error: `,U(`span`,{className:`no-track-pii-safe`,children:h})]});if(v)return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,p:`1rem`,height:`100%`,bgcolor:p?`grey.900`:`grey.50`},children:U(q,{spacing:1,sx:{alignItems:`center`},children:U(J,{children:`Cancelled`})})});if((e||i?.status===`Running`)&&!_){let e=`Loading...`;n?.message?e=n.message:i?.progress?.message&&(e=i.progress.message);let t=n?.percentage==null?void 0:n.percentage*100;return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,p:`1rem`,height:`100%`,bgcolor:p?`grey.900`:`grey.50`},children:W(q,{spacing:2,sx:{alignItems:`center`},children:[W(q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[t==null?U(pn,{size:32}):W(G,{sx:{position:`relative`,display:`inline-flex`},children:[U(pn,{variant:`determinate`,value:t,size:32}),U(G,{sx:{top:0,left:0,bottom:0,right:0,position:`absolute`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:U(J,{variant:`caption`,component:`div`,sx:{fontSize:`0.6rem`},children:`${Math.round(t)}%`})})]}),U(J,{className:`no-track-pii-safe`,children:e})]}),U(K,{variant:`contained`,onClick:a,size:`small`,children:`Cancel`})]})})}if(!i)return U(G,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:p?`grey.900`:`grey.50`,height:`100%`},children:U(pn,{size:32})});if(l&&c)throw Error(`RunView requires either a children or a RunResultView prop, but not both.`);if(!l&&!c)throw Error(`RunView requires at least one of children or RunResultView prop.`);return U(G,{sx:{height:`100%`,contain:`layout`,overflow:`auto`,bgcolor:p?`grey.900`:`grey.50`},className:`no-track-pii-safe`,children:(()=>{let e=c&&(i.error??i.result)?U(c,{ref:f,run:i,viewOptions:o,onViewOptionsChanged:s}):null,t=l?.({run:i,viewOptions:o,onViewOptionsChanged:s});return u&&e?W(H,{children:[U(u,{fallback:d,children:e}),t]}):W(H,{children:[e,t]})})()})});El.displayName=`RunView`;const Dl=I(({type:e,params:t})=>{let n=P();return U(Ro,{value:Dn.stringify({type:e,params:t},null,2),language:`yaml`,readOnly:!0,lineNumbers:!1,wordWrap:!0,fontSize:14,height:`100%`,theme:n?`dark`:`light`,className:`no-track-pii-safe`})});Dl.displayName=`ParamView`;function Ol(e,t){return t!=null&&t>0?`${e} (${ye(t)})`:e}const kl=I(({open:e,rowCount:t,onContinue:n,onCancel:r})=>W(mt,{open:e,onClose:r,children:[U(_t,{children:`Large Export Warning`}),U(gt,{children:W(Tr,{children:[`You are about to download `,U(`strong`,{children:ye(t)}),`. This may take a while and produce a large file. Are you sure you want to continue?`]})}),W(ht,{children:[U(K,{onClick:r,children:`Cancel`}),U(K,{onClick:n,variant:`contained`,children:`Continue`})]})]}));kl.displayName=`LargeExportWarningDialog`;const Al=I(({disableExport:e,onCopyAsImage:t,onMouseEnter:n,onMouseLeave:r,csvExport:i,label:a=`Export`})=>{let[o,s]=V(null),c=!!o,[l,u]=V(!1),[d,f]=V(null),p=i?.totalRowCount??0,m=p>1e5,h=e=>{s(e.currentTarget)},g=()=>{s(null)},_=e=>{m?(f(()=>e),u(!0)):(e(),g())};return W(H,{children:[U(K,{size:`small`,variant:`outlined`,color:`neutral`,onClick:h,endIcon:U(Vt,{}),sx:{textTransform:`none`},children:a}),W(ln,{anchorEl:o,open:c,onClose:g,children:[W(Z,{onClick:async()=>{await t(),g()},onMouseEnter:n,onMouseLeave:r,disabled:e,children:[U(Er,{children:U(Xt,{})}),U(Dr,{children:`Copy as Image`})]}),W(Z,{onClick:async()=>{await i?.copyAsTSV?.(),g()},disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Kt,{})}),U(Dr,{children:`Copy as Text`})]}),W(Z,{onClick:async()=>{await i?.copyAsCSV(),g()},disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(rn,{})}),U(Dr,{children:`Copy as CSV`})]}),i?.copySelectedRows&&W(Z,{onClick:async()=>{await i.copySelectedRows?.(),g()},disabled:e,children:[U(Er,{children:U(nn,{})}),U(Dr,{children:`Copy Selected Rows`})]}),W(Z,{onClick:()=>_(()=>i?.downloadAsCSV()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as CSV`,i?.totalRowCount)})]}),W(Z,{onClick:()=>_(()=>i?.downloadAsTSV?.()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as TSV`,i?.totalRowCount)})]}),i?.downloadAsExcel&&W(Z,{onClick:()=>_(()=>i?.downloadAsExcel?.()),disabled:e||!i?.canExportCSV,children:[U(Er,{children:U(Yt,{})}),U(Dr,{children:Ol(`Download as Excel`,i?.totalRowCount)})]})]}),U(kl,{open:l,rowCount:p,onContinue:()=>{u(!1),d?.(),f(null),g()},onCancel:()=>{u(!1),f(null)}})]})});Al.displayName=`DefaultExportMenu`;const jl=I(({runId:e,run:t,disableUpdateChecklist:n,checklistPermissionDenied:r,hasError:i,onGoToCheck:a,onAddToChecklist:o})=>{let s=ss();if(e&&s.has(e))return null;let c=t?.check_id,l=!e||!t?.result||i;return n&&!r?null:c?U(K,{disabled:l,size:`small`,variant:`contained`,onClick:()=>a?.(c),startIcon:U(Ut,{}),sx:{textTransform:`none`},children:`Go to Check`}):U(X,{title:r?`You don't have permission to add checks`:``,children:U(`span`,{children:U(K,{disabled:l||r,size:`small`,variant:`contained`,onClick:o,startIcon:U(Ut,{}),sx:{textTransform:`none`},children:`Add to Checklist`})})})});jl.displayName=`DefaultAddToCheckButton`;const Ml=I(({run:e})=>{let t=ss(),n=e.run_id&&t.has(e.run_id)?`Cancelled`:e.status||(e.result?`Finished`:e.error?`Failed`:`unknown`),r=e=>{switch(e.toLowerCase()){case`finished`:return`success.main`;case`failed`:return`error.main`;case`running`:return`primary.main`;default:return`text.secondary`}},i=e.run_at?xn(new Date(e.run_at),{addSuffix:!0}):`Unknown time`;return W(J,{variant:`body2`,sx:{color:`text.secondary`},children:[U(G,{component:`span`,sx:{fontWeight:600,color:r(n)},children:n}),`・`,i]})});Ml.displayName=`RunStatusAndDateDisplay`;function Nl({runId:e,run:t,isRunning:n,error:r,viewOptions:i,onViewOptionsChanged:a,isSingleEnvironment:o,disableDatabaseQuery:s,disableShare:c,disableUpdateChecklist:l,checklistPermissionDenied:u,onClose:d,onCancel:f,onRerun:p,onCopyAsImage:m,onCopyMouseEnter:h,onCopyMouseLeave:g,csvExport:_,onTrackCopyToClipboard:v,onGoToCheck:y,onAddToChecklist:b,SingleEnvironmentNotification:x,SqlEditorComponent:S,DualSqlEditorComponent:C,RunResultView:w,resultViewRef:T,children:E}){let ee=P(),D=ss(),O=e?D.has(e):!1,[k,te]=V(`result`),[ne,re]=V(!0),ie=t?.type===`query`||t?.type===`query_diff`||t?.type===`query_base`,ae=!e||!t?.result||!!r||k!==`result`||O,oe=L(async()=>{await m?.(),v&&v(t?.type??`unknown`,`run`)},[m,v,t?.type]),se=t?.type===`query_diff`,ce=t?.params;return W(G,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,bgcolor:ee?`grey.900`:`grey.50`},children:[o&&ne&&x&&U(x,{runType:t?.type,onClose:()=>re(!1)}),W(G,{sx:{display:`flex`,alignItems:`center`,borderBottom:1,borderColor:`divider`,mb:`1px`},children:[W(wn,{value:k,onChange:(e,t)=>te(t),children:[U(Cn,{label:`Result`,value:`result`}),U(Cn,{label:`Params`,value:`params`}),ie&&U(Cn,{label:`Query`,value:`query`})]}),U(G,{sx:{flexGrow:1}}),W(q,{direction:`row`,spacing:1,sx:{alignItems:`center`,overflow:`hidden`,pr:1},children:[t&&U(Ml,{run:t}),U(K,{variant:`outlined`,color:`neutral`,disabled:!e||n||s,size:`small`,onClick:p,startIcon:U(tn,{}),sx:{textTransform:`none`},children:`Rerun`}),U(Al,{run:t,disableExport:ae,onCopyAsImage:oe,onMouseEnter:h,onMouseLeave:g,csvExport:_,label:c?`Export`:`Share`}),U(jl,{runId:e,run:t,disableUpdateChecklist:l,checklistPermissionDenied:u,hasError:!!r,onGoToCheck:y,onAddToChecklist:b}),U(Y,{size:`small`,onClick:d,children:U(kt,{})})]})]}),k===`result`&&(w||E)&&U(El,{ref:T,runId:e,isRunning:n,error:r,run:t,onCancel:f,viewOptions:i,onViewOptionsChanged:a,RunResultView:w,children:E}),k===`params`&&t&&U(Dl,{type:t.type,params:t.params}),k===`query`&&t&&ie&&ce?.sql_template&&U(H,{children:se&&C?U(C,{value:ce.sql_template,baseValue:ce.base_sql_template,readOnly:!0}):S?U(S,{value:ce.sql_template,readOnly:!0}):U(Ro,{value:ce.sql_template,language:`sql`,readOnly:!0,theme:`dark`,height:`100%`})})]})}const Pl=I(Nl);Pl.displayName=`RunResultPane`;function Fl(e){let t=e.getSelectedNodes();if(t.length===0)return null;let n=e.getAllDisplayedColumns().filter(e=>e.getColId()!==`ag-Grid-SelectionColumn`);return n.length===0?null:Le(n.map(e=>{let t=e.getColDef();return String(t.headerName??t.field??e.getColId())}),t.map(t=>n.map(n=>e.getCellValue({rowNode:t,colKey:n,useFormatter:!0})??``)))}const Il=e=>W(G,{sx:{display:`flex`,flex:1,minHeight:`48px`,m:`4px`,px:`16px`,py:`12px`,bgcolor:`primary.50`,border:`1px solid`,borderRadius:`4px`,borderColor:`primary.400`,alignItems:e.align??`center`,gap:`12px`},children:[U(G,{component:Or,sx:{width:`20px`,height:`20px`,color:`primary.900`}}),e.children,U(G,{sx:{flexGrow:1}}),U(Y,{size:`small`,onClick:e.onClose,children:U(kt,{})})]}),Ll=()=>W(vt,{href:`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,target:`_blank`,sx:{color:`primary.main`,fontWeight:`bold`,textDecoration:`underline`,display:`inline-flex`,alignItems:`center`,gap:.5},children:[`Learn how `,U(bt,{})]});function Rl({value:e,onChange:t,onRun:n,onRunBase:r,onRunDiff:i,label:a,CustomEditor:o,options:s={},manifestData:c,schemas:l,...u}){let{featureToggles:d}=ae(),f=P(),p=e=>{t&&t(e)},m=``;c&&(m=c.generated_at?Be(c.generated_at):``);let h=z(()=>{let e=[];return n&&e.push({key:`Mod-Enter`,run:()=>(n(),!0)}),r&&e.push({key:`Alt-Enter`,run:()=>(r(),!0)}),i&&e.push({key:`Mod-Shift-Enter`,run:()=>(i(),!0)}),e},[n,r,i]);return W(H,{children:[(a??n??r)&&W(q,{direction:`row`,sx:{bgcolor:Ct(f?N.neutral[600]:N.neutral[200],.7),height:`40px`,minHeight:`40px`,fontSize:`14px`,alignItems:`center`,m:0,p:`0px 16px`,flex:`0 0 40px`},children:[U(J,{component:`strong`,sx:{fontWeight:`bold`},className:`no-track-pii-safe`,children:a?a.toUpperCase():``}),c&&W(`span`,{className:`ml-1`,children:[`(`,l&&W(`span`,{className:`no-track-pii-safe`,children:[l,`, `]}),U(`span`,{children:m}),`)`]}),U(G,{sx:{flexGrow:1}}),(n??r)&&U(K,{size:`xsmall`,variant:`outlined`,onClick:n??r,sx:{bgcolor:`background.paper`,p:`6px 12px`},disabled:d.disableDatabaseQuery,startIcon:U(kr,{}),children:`Run Query`})]}),o??U(Ro,{value:e,onChange:p,language:`sql`,readOnly:s.readOnly??!1,lineNumbers:s.lineNumbers!==`off`,wordWrap:s.wordWrap!==`off`,fontSize:s.fontSize??16,keyBindings:h,theme:f?`dark`:`light`,className:`no-track-pii-safe max-h-dvh h-full`})]})}function zl({value:e,baseValue:t,onChange:n,onChangeBase:r,onRun:i,onRunBase:a,onRunDiff:o,options:s={},labels:c,SetupGuide:l,...u}){let d=c?c[0]:`Base`,f=c?c[1]:`Current`,{envInfo:p,lineageGraph:m}=pe(),h,g;p?.dbt?.base&&p.dbt.current&&(h=p.dbt.base,g=p.dbt.current);let[_,v]=Re(m);return U(H,{children:W(q,{direction:`row`,sx:{height:`100%`,gap:0},children:[U(q,{sx:{height:`100%`,width:`50%`,gap:0,borderRight:`1px solid`,borderRightColor:`divider`},children:U(Rl,{label:d,value:t??``,onChange:r,onRunBase:a,options:s,CustomEditor:l,manifestData:h??void 0,schemas:Array.from(_).join(`, `),...u})}),U(q,{sx:{height:`100%`,width:`50%`,gap:0},children:U(Rl,{label:f,value:e,onChange:n,onRun:i,options:s,manifestData:g??void 0,schemas:Array.from(v).join(`, `),...u})})]})})}const Bl=({runType:e,onClose:t})=>{switch(e){case`row_count`:return U(Il,{onClose:t,children:W(J,{children:[`Enable row count diffing, and other Recce features, by configuring a base dbt environment to compare against. `,U(Ll,{})]})});case`profile`:return U(Il,{onClose:t,children:W(J,{children:[`Enable data-profile diffing, and other Recce features, by configuring a base dbt environment to compare against.`,` `,U(Ll,{})]})});default:return null}},Vl=({value:e,readOnly:t})=>U(Rl,{value:e,options:{readOnly:t}}),Hl=({value:e,baseValue:t,readOnly:n})=>U(zl,{value:e,baseValue:t,options:{readOnly:n}}),Ul=({runId:e,onClose:t,isSingleEnvironment:n})=>{let{featureToggles:r}=ae(),{runAction:i}=j(),{error:o,run:s,onCancel:c,isRunning:l}=Nu(e),[u,f]=V(),p=st(),m=pr(),{apiClient:h}=Ql(),{basePath:g}=oe(),_;s&&d(s.type)&&(_=gl(s.type).RunResultView);let{ref:v,onCopyToClipboard:y,onMouseEnter:b,onMouseLeave:x}=xu(),S=Du({run:s,runId:e,viewOptions:u}),C=!!s?.type&&[`query`,`query_base`,`query_diff`].includes(s.type),w=L(async()=>{let e=v.current?.api;if(!e)return;let t=Fl(e);if(!t){F.create({title:`No rows selected`,description:`Select rows with the checkboxes, then copy.`,type:`info`,duration:3e3});return}try{await Ce(t),F.create({title:`Copied to clipboard`,description:`Selected rows copied — paste into any spreadsheet`,type:`success`,duration:2e3}),Xe({type:s?.type??`unknown`,from:`run-selection`})}catch(e){console.error(`Failed to copy selected rows:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[v,s?.type]),T=L(()=>{s&&i(s.type,s.params)},[s,i]),E=L(async()=>{await y(),Xe({type:s?.type??`unknown`,from:`run`})},[y,s?.type]),ee=L(e=>{m.push(`${g}/checks/?id=${e}`)},[m.push,g]),D=L(async()=>{if(e)try{let t=await a(e,u,h);await p.invalidateQueries({queryKey:O.checks()}),m.push(`${g}/checks/?id=${t.check_id}`)}catch(e){re(e)&&e.status===403?F.error({title:`Permission denied`,description:`You don't have permission to add checks. Contact your org admin for access.`}):F.error({title:`Failed to create check`,description:e instanceof Error?e.message:`An unexpected error occurred`})}},[e,u,h,p,m.push,g]);return U(Pl,{runId:e,run:s,isRunning:l,error:o,viewOptions:u,onViewOptionsChanged:f,isSingleEnvironment:n,disableDatabaseQuery:r.disableDatabaseQuery,disableShare:r.disableShare,disableUpdateChecklist:r.disableUpdateChecklist,checklistPermissionDenied:r.checklistPermissionDenied,onClose:t,onCancel:c,onRerun:T,onCopyAsImage:E,onCopyMouseEnter:b,onCopyMouseLeave:x,csvExport:{...S,copySelectedRows:C?w:void 0},onGoToCheck:ee,onAddToChecklist:D,SingleEnvironmentNotification:Bl,SqlEditorComponent:Vl,DualSqlEditorComponent:Hl,RunResultView:_,resultViewRef:v})},Wl=({onClose:e,isSingleEnvironment:t})=>{let{runId:n}=j();return U(Ul,{runId:n,onClose:e,isSingleEnvironment:t})};function Gl({error:e,resetError:t}){let{background:n,text:r}=Pu();return U(G,{sx:{height:`100%`,bgcolor:n.subtle,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(G,{sx:{p:4,display:`flex`,flexDirection:`column`,justifyContent:`flex-start`,bgcolor:`background.paper`,border:`solid 1px`,borderColor:`divider`,minHeight:`200px`},children:[U(J,{variant:`h6`,sx:{width:`800px`},children:`You have encountered an error`}),U(G,{sx:{flex:1,fontSize:`10pt`,color:r.secondary},children:String(e)}),U(K,{sx:{justifySelf:`center`,alignSelf:`center`,mt:`20px`},color:`iochmara`,variant:`contained`,size:`small`,onClick:t,children:`Reset`})]})})}const Kl=e=>U(Gl,{error:e.error,resetError:e.resetError}),ql=({children:e,fallback:t=Kl})=>U(Ar,{fallback:t,children:e}),Jl=ut(function(e,t){return U(El,{...e,ErrorBoundary:ql,errorBoundaryFallback:nt,ref:t})});Jl.displayName=`RunViewOss`;const Yl={mode:`per_node`,status:`pending`,completed:0,total:0,actions:{}},Xl=(e,t)=>{let{onActionStarted:n,onActionNodeUpdated:r,onActionCompleted:i,onTrackAction:a,trackingSource:o=`lineage_view_top_bar`}=t,c=k(),u=B({...Yl}).current,d=ss(),{showRunId:f}=j(),p=async(t,a,o)=>{u.mode=`multi_nodes`,u.actions={};let s=u.mode,l=u.actions;n(),u.status=`running`;let d=[];for(let t of e){let e=a(t);e?(l[t.id]={mode:s,status:`skipped`,skipReason:e},r(t)):(l[t.id]={mode:s,status:`pending`},d.push(t))}let p=o(d);try{let{run_id:e}=await C(t,p,{nowait:!0},c);for(f(e),u.currentRun={run_id:e},u.total=1;;){let t=await x(e,2,c);u.currentRun=t;let n=t.error?`failure`:t.result?`success`:`running`;for(let e of d)l[e.id]={mode:s,status:n,run:t},r(e);if(t.error||t.result)break}}catch{}if(u.completed=1,u.status===`canceling`){u.status=`canceled`,i();return}u.status=`completed`,i()},m=async(t,a)=>{u.mode=`per_node`,u.actions={};let o=u.mode,s=u.actions;n(),u.status=`running`;for(let t of e)s[t.id]={mode:o,status:`pending`},r(t);u.completed=0,u.total=e.length;for(let n of e){let{params:e,skipReason:l}=a(n);if(l)s[n.id]={mode:o,status:`skipped`,skipReason:l},r(n);else try{let{run_id:i}=await C(t,e,{nowait:!0},c);for(u.currentRun={run_id:i},s[n.id]={mode:o,status:`running`},r(n);;){let e=await x(i,2,c);u.currentRun=e;let t=e.error?`failure`:e.result?`success`:`running`;if(s[n.id]={mode:o,status:t,run:e},r(n),e.error||e.result)break}}catch{}finally{u.currentRun=void 0}if(u.completed++,u.status===`canceling`){u.status=`canceled`,i();return}}u.status=`completed`,i()};return{actionState:u,runRowCount:async()=>{a?.({action:`row_count`,source:o,node_count:e.length});for(let t of e)t.data.resourceType!==`model`&&(u.actions[t.id]={mode:`multi_nodes`,status:`skipped`,skipReason:`Not a model`},r(t));await p(`row_count`,e=>{if(e.data.resourceType!==`model`)return`Not a model`},e=>({node_names:e.map(e=>e.data.name)}))},runRowCountDiff:async()=>{a?.({action:`row_count_diff`,source:o,node_count:e.length});for(let t of e)t.data.resourceType!==`model`&&(u.actions[t.id]={mode:`multi_nodes`,status:`skipped`,skipReason:`Not a model`},r(t));await p(`row_count_diff`,e=>{if(e.data.resourceType!==`model`)return`Not a model`},e=>({node_names:e.map(e=>e.data.name)}))},runValueDiff:async()=>{a?.({action:`value_diff`,source:o,node_count:e.length}),await m(`value_diff`,e=>({skipReason:`No primary key found. The first unique column is used as primary key.`}))},addLineageDiffCheck:async()=>await s({node_ids:e.map(e=>e.id)},c),addSchemaDiffCheck:async()=>{let t;return t=e.length===1?await v({node_id:e[0].id},c):await v({node_id:e.map(e=>e.id)},c),t},cancel:()=>{u.status=`canceling`;let e=u.currentRun?.run_id;return e&&(d.add(e),l(e,c)),Promise.resolve()},reset:()=>{Object.assign(u,Yl)}}},Zl={apiPrefix:``,authToken:void 0,baseUrl:void 0,apiClient:ne({baseURL:et??``})};function Ql(){return D()??Zl}function $l({connect:e,idleSeconds:t}){return W(H,{children:[U(_t,{children:`Server Disconnected`}),U(gt,{children:t!=null&&t>0?W(J,{children:[`The server has been idle for `,He(t),` and was automatically stopped. Please restart the Recce server to continue.`]}):U(J,{children:`The server connection has been lost. Please restart the Recce server and try again.`})}),U(ht,{children:U(K,{color:`iochmara`,variant:`contained`,onClick:()=>{e()},children:`Retry`})})]})}function eu({shareUrl:e,mode:t,supportCalendarUrl:n,LinkComponent:r}){let i={"read only":{title:`Share Instance Expired`,body:`This Share Instance has expired. Please restart the share instance.`,action:`Restart`,link:e},"metadata only":{title:`Preview Instance Expired`,body:`This Preview Instance has expired. To browse more, please book a meeting with us.`,action:`Contact us`,link:n}}[t],a=U(K,{color:`iochmara`,variant:`contained`,children:i.action});return W(H,{children:[U(_t,{children:i.title}),U(gt,{children:U(J,{children:i.body})}),U(ht,{children:t===`read only`?U(r||`a`,{href:i.link,children:a}):U(K,{color:`iochmara`,variant:`contained`,onClick:()=>window.open(i.link,`_blank`),children:i.action})})]})}function tu(e){let{apiClient:t}=Ql();return ot({queryKey:O.lineage(),queryFn:()=>E(t),...e})}function nu({enabled:e=!0,baseUrl:t,apiPrefix:n}={}){let[r,i]=V(void 0),a=B({ws:void 0,status:`pending`,artifactsUpdatedToastId:void 0}),[o,s]=V(e?`pending`:`connected`),[c,l]=V(void 0);R(()=>{a.current.status=o},[o]),R(()=>{a.current.artifactsUpdatedToastId=r},[r]);let u=st(),d=L(()=>{u.invalidateQueries({queryKey:O.lineage()}),u.invalidateQueries({queryKey:O.checks()}),u.invalidateQueries({queryKey:O.runs()})},[u]),f=L(()=>{function e(e){return e.replace(/(http)(s)?:\/\//,`ws$2://`)}let r=t??et,o=n?`${n}/ws`:`/api/ws`,c=new WebSocket(`${e(r)}${o}`);a.current.ws=c,c.onopen=()=>{c.send(`ping`)},c.onmessage=e=>{if(e.data===`pong`){a.current.status===`disconnected`&&d(),s(`connected`);return}try{let t=JSON.parse(e.data);if(`type`in t&&t.type===`metadata_updated`){d();return}let n=t;if(n.command===`refresh`){let{eventType:e,srcPath:t}=n.event,[r,o]=t.split(`/`).slice(-2),s=o.replace(/\.[^/.]+$/,``),c=`${r}-${s}-${e}`;a.current.artifactsUpdatedToastId??i(F.create({id:c,description:`Detected ${r} ${s} ${e}`,type:`info`,duration:5e3,closable:!0})),d()}else if(n.command===`relaunch`)l(`relaunch`);else{let{id:e,title:t,description:r,status:a,duration:o}=n.event;i(F.create({id:e||`broadcast`,title:t,description:r,type:a??`info`,duration:o??5e3,closable:!0}))}}catch(e){console.error(e)}},c.onerror=e=>{console.error(`An error occurred during Handling WebSockets`,e)},c.onclose=()=>{s(e=>e===`connected`?`disconnected`:e),a.current.ws=void 0}},[d,t,n]);return R(()=>{if(!e)return;let t=a.current;return f(),()=>{t.ws&&t.ws.close()}},[f,e]),{connectionStatus:o,connect:f,envStatus:c}}function ru({children:e}){let{idleTimeout:t,remainingSeconds:n,isEnabled:r,setDisconnected:i,resetConnection:a}=se(),{apiClient:o,apiPrefix:s,baseUrl:l}=Ql(),u=tu(),d=ot({queryKey:O.runsAggregated(),queryFn:()=>c(o)}),f=z(()=>{let e=u.data?.lineage;if(e?.nodes)return de(e)},[u.data]),p=u.error?.message,{state_metadata:m,lineage:h,sqlmesh:g,demo:_,codespace:v,review_mode:y,cloud_mode:b,file_mode:x,filename:S,adapter_type:C,git:w,pull_request:T,support_tasks:E}=u.data??{demo:!1},ee={stateMetadata:m,adapterType:C,git:w,pullRequest:T,dbt:{base:h?.metadata?.base?.manifest_metadata,current:h?.metadata?.current?.manifest_metadata},sqlmesh:g},{connectionStatus:D,connect:k,envStatus:ne}=nu({enabled:!0,baseUrl:l,apiPrefix:s});R(()=>{D===`disconnected`?i():D===`connected`&&a()},[D,i,a]);let{data:re,isLoading:ie}=le(),{featureToggles:oe,shareUrl:ce}=ae(),[A,ue]=V(!1),[j,pe]=V(!1),me=st(),M=!ie&&ne===`relaunch`&&re?.single_env_onboarding===!0&&re.show_relaunch_hint;M!==j&&(pe(M),ue(M)),R(()=>{M&&A&&$e({action:`target_base_added`})},[M,A]);let he=()=>{ue(!1),te(o),me.invalidateQueries({queryKey:O.flag()})},ge=L(()=>{d.refetch()},[d]),_e=L(()=>{d.refetch()},[d]);return W(H,{children:[U(fe,{lineageGraph:f,envInfo:ee,reviewMode:y,cloudMode:b,fileMode:x,fileName:S,isDemoSite:_??!1,isCodespace:v,isLoading:u.isLoading,error:p,supportTasks:E,onRefetchLineageGraph:ge,runsAggregated:d.data,onRefetchRunsAggregated:_e,children:e}),U(mt,{open:D===`disconnected`,onClose:()=>void 0,children:ce&&oe.mode!==null?U(eu,{shareUrl:ce,mode:oe.mode,supportCalendarUrl:tt,LinkComponent:({href:e,children:t})=>U(Ot,{href:e,passHref:!0,children:t})}):U($l,{connect:k,idleSeconds:r&&t!==null&&n!==null&&n<=5?t-Math.max(0,n):void 0})}),re?.single_env_onboarding&&W(mt,{open:A,onClose:he,children:[U(_t,{children:`Target-base Added`}),U(Y,{"aria-label":`close`,onClick:he,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),U(gt,{children:U(J,{children:`Please restart the Recce server.`})}),U(ht,{children:U(K,{color:`iochmara`,variant:`contained`,onClick:he,children:`Got it!`})})]})]})}const iu=`select * from {{ ref("mymodel") }}`;function au({children:e}){let[t,n]=V(iu),[r,i]=V(iu),[a,o]=V(!1),[s,c]=V();return U(Lr,{sql:t,sqlQuery:t,setSqlQuery:n,primaryKeys:s,setPrimaryKeys:c,isCustomQueries:a,setCustomQueries:o,baseSqlQuery:r,setBaseSqlQuery:i,children:e})}const ou=e=>{},su=e=>{},cu=e=>{},lu=e=>{};function uu(){let e=Rr();return{sqlQuery:e.sqlQuery??`select * from {{ ref("mymodel") }}`,setSqlQuery:e.setSqlQuery??ou,primaryKeys:e.primaryKeys,setPrimaryKeys:e.setPrimaryKeys??su,isCustomQueries:e.isCustomQueries??!1,setCustomQueries:e.setCustomQueries??cu,baseSqlQuery:e.baseSqlQuery??`select * from {{ ref("mymodel") }}`,setBaseSqlQuery:e.setBaseSqlQuery??lu}}function du(e){R(()=>{e()},[e,fr()])}function fu({children:e}){let{apiClient:t}=Ql(),[n,r]=V(),[i,a]=V(!1),o=L(()=>a(!0),[]),s=L(()=>a(!1),[]),c=pr(),l=fr(),u=st(),{basePath:d}=oe(),f=B(null);du(s);let p=L(async(e,t)=>{t!==!1&&await u.invalidateQueries({queryKey:O.runs()})},[u]),h=L(async(e,n,i)=>{try{let a=new Date().getTime().toString(),s,p=i;if(p?.showLast){let r=await m(e,n,1,t);r.length===1&&(s=r[0])}let h=gl(e);if(!h)throw Error(`Run type ${e} does not have a result view`);let g=h.RunResultView,{title:_,RunForm:v}=h;if(g===void 0)throw Error(`Run type ${e} does not have a result view`);if(v===void 0||!i?.showForm){let{run_id:r}=await C(e,n,{nowait:!0,trackProps:p?.trackProps},t);await u.invalidateQueries({queryKey:O.runs()}),f.current&&f.current(r);let i=`${d}/lineage`;l.startsWith(`${i}/`)&&l!==i&&c.push(i);return}r({session:a,title:_,type:e,params:n,lastRun:s,options:p,RunForm:v}),o();return}catch(e){F.create({title:`Failed to submit a run`,description:e instanceof Error?e.message:void 0,type:`error`,duration:5e3,closable:!0});return}},[o,u,t,l,c,d]),g=L(async(e,r)=>{try{s();let{run_id:i}=await C(e,r,{nowait:!0,trackProps:n?.options?.trackProps},t);f.current&&f.current(i)}catch(e){F.create({title:`Failed to submit a run`,description:e instanceof Error?e.message:void 0,type:`error`,duration:5e3,closable:!0})}},[s,n?.options?.trackProps,t]);return W(ie,{onRunAction:h,onShowRunId:p,children:[U(pu,{showRunIdRef:f,children:e}),n&&U(Tl,{isOpen:i,onClose:s,onExecute:g,title:n.title,type:n.type,params:n.params,initialRun:n.lastRun,RunForm:n.options?.showForm&&n.RunForm?n.RunForm:void 0},n.session)]})}function pu({children:e,showRunIdRef:t}){let{showRunId:n}=j();return R(()=>(t.current=n,()=>{t.current=null}),[n,t]),U(H,{children:e})}const mu=lt(void 0);function hu({children:e}){let[t,n]=V(),[r,i]=V(!1),[a,o]=V(),{apiClient:s}=Ql();return U(mu.Provider,{value:{shareUrl:t,isLoading:r,error:a,handleShareClick:async()=>{i(!0),o(void 0),n(void 0);try{let e=await h(s);if(e.status!==`success`){o(e.message);return}n(e.share_url)}catch(e){o(e.message)}finally{i(!1)}}},children:e})}const gu=()=>{let e=dt(mu);if(!e)throw Error(`useRecceShareStateContext must be used within a RecceShareStateContextProvider`);return e};function _u({children:e}){return U(ce,{children:U(hu,{children:U(au,{children:U(ru,{children:U(fu,{children:U(zr,{children:e})})})})})})}const vu=e=>`element`in e?e.element:e,yu=`ignore-screenshot`;function bu({imageType:e=`png`,backgroundColor:t=null,boardEffect:n=!0,shadowEffect:r=!1,borderStyle:i=`solid 1px ${N.neutral[300]}`,borderRadius:a=`10px`,onSuccess:o,onError:s,ignoreElements:c}){let[l,u]=V(`idle`),d=B(null),{onOpen:f,setImgBlob:p,ImageDownloadModal:m}=Su(),h=async()=>{if(!d.current)throw console.error(`No node to use for screenshot`),Error(`No node to use for screenshot`);let e=vu(d.current);if(!e)throw console.error(`Could not get HTMLElement from ref`),Error(`Could not get HTMLElement from ref`);let o=e.style.overflow,s=e.style.border,l=e.style.borderRadius,f=e.style.backgroundColor,p=e.style.height;function m(){let t=e;t&&(t.style.overflow=o,t.style.border=s,t.style.borderRadius=l,t.style.backgroundColor=f,t.style.height=p)}let h=document.createElement(`style`);document.head.appendChild(h),h.sheet?.insertRule(`body > div:last-child img { display: inline-block; }`);try{e.style.overflow=`hidden`,e.style.border=n?i:``,e.style.borderRadius=n?a:``,e.style.backgroundColor=t??N.neutral[100],e.style.height=`${String(e.offsetHeight)}px`;let o=c?e=>!c(e):void 0;u(`loading`);let s=await jr.toCanvas(e,{filter:o,filterMode:`remove`,backgroundColor:t??N.neutral[100]}),l=r?document.createElement(`canvas`):s;if(r){l.width=s.width+80,l.height=s.height+80;let e=l.getContext(`2d`);if(e)e.shadowColor=`rgba(0, 0, 0, 0.5)`,e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(s,40,40);else throw console.error(`Error getting canvas context`),Error(`Error getting canvas context to add shadow effect`)}return await(await fetch(l.toDataURL())).blob()}catch(e){throw console.error(`Error converting to image`,e),e}finally{h.remove(),m()}};return{status:l,isLoading:l===`loading`,isErrored:l===`error`,isSuccess:l===`success`,copyToClipboard:async()=>{try{await navigator.clipboard.write([new ClipboardItem({[`image/${e}`]:h()})]),u(`success`),o&&o()}catch(e){e.message===`ClipboardItem is not defined`?(p(await h()),f(),u(`success`)):(u(`error`),console.error(`Error copying to clipboard`,e),s&&s(e))}},ImageDownloadModal:m,ref:d}}function xu(e){let{successToast:t,failToast:n}=Ue(),{isLoading:r,copyToClipboard:i,ImageDownloadModal:a,ref:o}=bu({imageType:`png`,shadowEffect:!0,backgroundColor:e?.backgroundColor??N.neutral[100],onSuccess:()=>{t(`Copied the query result as an image to clipboard`)},onError:e=>{console.error(`Error taking screenshot`,e),n(`Failed to copy image to clipboard`,e)}}),s=L(()=>{if(o.current){let e=vu(o.current);e&&(e.style.boxShadow=`rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px`,e.style.transition=`box-shadow 0.5s ease-in-out`)}},[o]),c=L(()=>{if(o.current){let e=vu(o.current);e&&(e.style.boxShadow=``)}},[o]),l=L(async()=>{if(o.current){await i();let e=vu(o.current);e&&(e.style.boxShadow=``)}else n(`Failed to copy image to clipboard`,`No content to copy`)},[o,i,n]);function u({imageType:e=`png`,...t}){return W(H,{children:[U(K,{size:`small`,sx:{position:`absolute`,bottom:16,right:16},disabled:r,onMouseEnter:s,onMouseLeave:c,onClick:l,startIcon:U(qt,{}),...t,children:`Copy to Clipboard`}),U(a,{})]})}return{ref:o,CopyToClipboardButton:u,onMouseEnter:s,onMouseLeave:c,onCopyToClipboard:l}}function Su(){let[e,t]=V(!1),[n,r]=V(),i=()=>t(!0),a=()=>t(!1);function o(){let[t,r]=V();return R(()=>{if(!n)return;let e=new FileReader;e.readAsDataURL(n),e.onloadend=e=>{e.target?.result!=null&&r(e.target.result)}},[]),W(mt,{open:e,onClose:a,maxWidth:`sm`,fullWidth:!0,children:[U(_t,{children:`Screenshot Preview`}),U(Y,{"aria-label":`close`,onClick:a,sx:{position:`absolute`,right:8,top:8,color:`grey.500`},children:U(kt,{})}),W(gt,{children:[W(q,{sx:{px:`10px`,gap:`10px`},children:[W(q,{direction:`row`,spacing:`5px`,sx:{alignItems:`center`},children:[U(G,{component:Zt,sx:{color:`error.main`}}),U(J,{sx:{fontWeight:500,display:`inline`},children:`Copy to the Clipboard`}),` `,`is not supported in the current browser`]}),U(J,{children:`Please download it directly`})]}),U(G,{component:`img`,src:t,alt:`screenshot`,sx:{maxWidth:`100%`}})]}),W(ht,{children:[U(K,{sx:{mr:1.5},onClick:a,children:`Close`}),U(K,{color:`iochmara`,variant:`contained`,onClick:()=>{n&&(Lt(n,`recce-screenshot-${bn(new Date,`yyyy-MM-dd-HH-mm-ss`)}.png`),a())},children:`Download`})]})]})}return{onOpen:i,setImgBlob:r,ImageDownloadModal:o}}function Cu({userId:e,enabled:t=!0}){let{apiClient:n}=Ql(),r=e?.toString(),{data:i,isLoading:a}=ot({queryKey:O.user(),queryFn:()=>it(n),enabled:t&&!!r,retry:!1,staleTime:300*1e3}),o=!!(i&&r&&i.id===r)&&i?.login_type===`github`,s=!!(t&&o&&r),{data:c,isLoading:l}=ot({queryKey:[`github-avatar`,r],queryFn:()=>r?rt(r):Promise.resolve(null),enabled:s,retry:!1,staleTime:300*1e3});return{avatarUrl:typeof c==`string`?c:null,isLoading:a||s&&l,isGitHubUser:!!o}}function wu(e,t={}){let{enabled:a=!0}=t,s=st(),{apiClient:c}=Ql(),{data:l,isLoading:u,error:d,refetch:f}=ot({queryKey:O.checkEvents(e),queryFn:()=>n(e,c),enabled:a,refetchInterval:1e4,refetchIntervalInBackground:!1}),p=at({mutationFn:t=>i(e,t,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}}),m=at({mutationFn:({eventId:t,content:n})=>r(e,t,n,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}}),h=at({mutationFn:t=>o(e,t,c),onSuccess:async()=>{await s.invalidateQueries({queryKey:O.checkEvents(e)})}});return{events:l??[],isLoading:u,error:d,refetch:f,createComment:p.mutate,isCreatingComment:p.isPending,createCommentError:p.error,updateComment:m.mutateAsync,isUpdatingComment:m.isPending,updateCommentError:m.error,deleteComment:h.mutateAsync,isDeletingComment:h.isPending,deleteCommentError:h.error}}const Tu={TOAST_ID:`lifetime-countdown`,WARNING_THRESHOLD:60,UPDATE_INTERVAL:1e3,MESSAGE:e=>`The server will be closed in ${e} seconds.`,STYLE:{fontFamily:`monospace`}};function Eu(e){let t=F,[n,r]=V(null),i=B(void 0),a=L(()=>{if(!e)return 0;let t=new Date,n=Math.floor((e.getTime()-t.getTime())/1e3);return Math.max(0,n)},[e]),o=L(()=>{n!=null&&(t.remove(n),r(null))},[n]),s=L(()=>{if(n==null)return;let e=a();if(e<=0){o();return}t.update(n,{description:Tu.MESSAGE(e)})},[n,a,o]),c=L(()=>{if(!e)return;o();let n=a();n<=0||(r(t.create({id:Tu.TOAST_ID,description:Tu.MESSAGE(n)})),i.current=setInterval(s,Tu.UPDATE_INTERVAL))},[e,a,s,o]),l=a();rr(c,e?Math.max(0,l-Tu.WARNING_THRESHOLD)*1e3:null),R(()=>o,[o])}function Du({run:e,runId:t,viewOptions:n}){let r=z(()=>!e?.type||!e?.result?!1:Ie(e.type),[e?.type,e?.result]),i=z(()=>{if(!e?.result)return null;let t=e.result;if(`total_row_count`in t&&typeof t.total_row_count==`number`)return t.total_row_count;let n=t.base,r=t.current,i=typeof n?.total_row_count==`number`?n.total_row_count:null,a=typeof r?.total_row_count==`number`?r.total_row_count:null;return i!==null&&a!==null?Math.max(i,a):i??a},[e?.result]),a=L(()=>{if(!e?.type||!e?.result)return null;let t={displayMode:n?.display_mode,primaryKeys:e?.params?.primary_keys};return ve(e.type,e.result,t)},[e?.type,e?.result,e?.params,n]),o=L(()=>{let e=a();return e?we(e.columns,e.rows):null},[a]),s=L(()=>{let e=a();return e?Le(e.columns,e.rows):null},[a]),c=L(e=>{if(!t)return;let n=document.createElement(`a`);n.href=`/api/runs/${t}/export?format=${e}`,document.body.appendChild(n),n.click(),document.body.removeChild(n)},[t]),l=L(async()=>{let e=o();if(!e){F.create({title:`Export failed`,description:`Unable to extract data for CSV export`,type:`error`,duration:3e3});return}try{await Ce(e),F.create({title:`Copied to clipboard`,description:`CSV data copied successfully`,type:`success`,duration:2e3})}catch(e){console.error(`Failed to copy CSV to clipboard:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[o]),u=z(()=>e?.type===`query_diff`&&!!e?.params?.primary_keys,[e?.type,e?.params]),d=L(()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`csv`);return}let n=o();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for CSV export`,type:`error`,duration:3e3});return}try{let t=Oe(e?.type??``,e?.params);Te(n,t),F.create({title:`Downloaded`,description:t,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download CSV file:`,e),F.create({title:`Download failed`,description:`Failed to download CSV file`,type:`error`,duration:3e3})}},[t,e,u,o,c]),f=L(async()=>{let e=s();if(!e){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{await Ce(e),F.create({title:`Copied to clipboard`,description:`Text data copied — paste into any spreadsheet`,type:`success`,duration:2e3})}catch(e){console.error(`Failed to copy TSV to clipboard:`,e),F.create({title:`Copy failed`,description:`Failed to copy to clipboard`,type:`error`,duration:3e3})}},[s]),p=L(()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`tsv`);return}let n=s();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{let t=Oe(e?.type??``,e?.params).replace(/\.csv$/,`.tsv`);xe(n,t),F.create({title:`Downloaded`,description:t,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download TSV file:`,e),F.create({title:`Download failed`,description:`Failed to download TSV file`,type:`error`,duration:3e3})}},[t,e,u,s,c]);return{canExportCSV:r,totalRowCount:i,copyAsCSV:l,copyAsTSV:f,downloadAsCSV:d,downloadAsExcel:L(async()=>{if(t&&!u&&[`query`,`query_base`,`query_diff`].includes(e?.type??``)){c(`xlsx`);return}let n=a();if(!n){F.create({title:`Export failed`,description:`Unable to extract data for export`,type:`error`,duration:3e3});return}try{let t=await Se(n.columns,n.rows),r=Oe(e?.type??``,e?.params).replace(/\.csv$/,`.xlsx`);be(t,r),F.create({title:`Downloaded`,description:r,type:`success`,duration:3e3})}catch(e){console.error(`Failed to download Excel file:`,e),F.create({title:`Download failed`,description:`Failed to download Excel file`,type:`error`,duration:3e3})}},[t,e,u,a,c]),downloadAsTSV:p}}function Ou({description:e,onLike:t,onDislike:n,onClickLink:r,externalLink:i,externalLinkText:a}){return W(G,{sx:{display:`flex`,gap:4,justifyContent:`center`,alignContent:`center`,alignItems:`center`},children:[e,U(Y,{"aria-label":`thumbs up`,onClick:t,sx:{width:`32px`,height:`32px`},children:U(G,{component:`img`,src:`/imgs/feedback/thumbs-up.png`,alt:`like`})}),U(Y,{"aria-label":`thumbs down`,onClick:n,sx:{width:`32px`,height:`32px`},children:U(G,{component:`img`,src:`/imgs/feedback/thumbs-down.png`,alt:`dislike`})}),i&&a&&W(vt,{href:i,target:`_blank`,onClick:r,sx:{textDecoration:`underline`},children:[a,` `,U(bt,{})]})]})}function ku(e){let{feedbackId:t,description:n,onFeedbackSubmit:r,externalLink:i,externalLinkText:a}=e,[o,s]=V(void 0);function c(e=!1){let c=localStorage.getItem(t);o??(c===`true`&&!e||s(F.create({id:t,duration:void 0,type:`success`,description:U(q,{direction:`row`,children:U(Ou,{description:n,onLike:()=>{r(`like`),F.dismiss(t),localStorage.setItem(t,`true`)},onDislike:()=>{r(`dislike`),F.dismiss(t),localStorage.setItem(t,`true`)},externalLink:i,externalLinkText:a,onClickLink:()=>{r(`link`)}})})})))}return{feedbackToast:c,closeToast:()=>{o&&F.dismiss(o)}}}function Au(e){let[t,n]=V(void 0),{guideId:r,description:i,externalLinkText:a,onExternalLinkClick:o}=e;function s(){t??n(F.create({id:r,duration:3e3,type:`success`,description:i,action:{label:a??`link`,onClick:()=>{o&&o()}}}))}return{guideToast:s,closeGuideToast:()=>{t&&F.dismiss(t)}}}function ju(e,t){let n=[];return e.forEach(e=>{n.some(t=>t.name===e.name)||n.push(e)}),t.forEach(e=>{n.some(t=>t.name===e.name)||n.push(e)}),n}function Mu(e,n){let{lineageGraph:r}=pe(),i=D(),a=n??i?.apiClient,o=ar.find(r?.nodes,{data:{name:e}}),s=!!a&&!!o?.id,{data:c,isLoading:l,error:u}=ot({queryKey:[`modelDetail`,o?.id],queryFn:()=>{if(!o?.id||!a)throw Error(`useModelColumns: missing node id or api client`);return t(o.id,a)},enabled:s,staleTime:300*1e3}),{columns:d,primaryKey:f}=z(()=>{let e=c?.model;return{columns:ju(e?.base?.columns?Object.values(e.base.columns):[],e?.current?.columns?Object.values(e.current.columns):[]),primaryKey:e?.current?.primary_key??e?.base?.primary_key}},[c]);return{columns:d,primaryKey:f,isLoading:s?l:!1,error:u?u instanceof Error?u:Error(String(u)):null}}const Nu=e=>{let{apiClient:t}=Ql(),n=st(),r=ss(),[i,a]=V(!!e),[,o]=A(),s=B(null);R(()=>{e&&(a(!0),s.current=null)},[e]);let c=e?r.has(e):!1,u=i&&!c,{error:f,data:p}=ot({queryKey:O.run(e??``),queryFn:async()=>await x(e??``,u?2:0,t),enabled:!!e&&!c,refetchInterval:u?50:!1,retry:!1});R(()=>{if(!p)return;let e=p.status?.toLowerCase();f||p.result||p.error||e&&e!==`running`?s.current!==p.run_id&&(s.current=p.run_id,a(!1)):e===`running`&&!c&&(s.current=null,a(!0))},[p,f,c]),R(()=>{(f||p?.result||p?.error)&&(p?.type===`row_count_diff`||p?.type===`row_count`)&&o?.()},[p,f,o]);let m=r.add,h=L(()=>e?(n.setQueryData(O.run(e),e=>e&&{...e,status:`Cancelled`}),m(e),a(!1),s.current=e,l(e,t),Promise.resolve()):Promise.resolve(),[e,t,n,m]),g;return p&&d(p.type)&&(g=gl(p.type).RunResultView),{run:p,isRunning:i,error:f,onCancel:h,RunResultView:g}};function Pu(){let e=wt(),t=ke(),n=P(),[r,i]=V(!1);R(()=>{i(!0)},[]);let a=r?t?t.resolvedMode===`dark`:n:!1;return{isDark:a,theme:e,background:{default:a?N.neutral[900]:N.white,paper:a?N.neutral[800]:N.white,subtle:a?N.neutral[800]:N.neutral[50],emphasized:a?N.neutral[700]:N.neutral[100]},text:{primary:a?N.neutral[50]:N.neutral[900],secondary:a?N.neutral[400]:N.neutral[600],disabled:a?N.neutral[500]:N.neutral[400],inverted:a?N.neutral[900]:N.neutral[50]},border:{light:a?N.neutral[700]:N.neutral[200],default:a?N.neutral[600]:N.neutral[300],strong:a?N.neutral[500]:N.neutral[400]},status:{added:{bg:a?N.green[900]:N.green[100],text:a?N.neutral[50]:N.neutral[900]},removed:{bg:a?N.red[950]:N.red[200],text:a?N.neutral[50]:N.neutral[900]},modified:{bg:a?N.yellow[900]:N.amber[100],text:a?N.neutral[50]:N.neutral[900]}},interactive:{hover:a?N.neutral[700]:N.neutral[100],active:a?N.neutral[600]:N.neutral[200],focus:N.iochmara[500]}}}export{Wc as $,_o as $t,Rl as A,Pi as An,_s as At,_l as B,Vr as Bn,Qo as Bt,tu as C,mi as Cn,Ms as Ct,ql as D,Wi as Dn,Es as Dt,Jl as E,Ui as En,ws as Et,Tl as F,li as Fn,cs as Ft,ll as G,Mr as Gn,Io as Gt,hl as H,Rr as Hn,Vo as Ht,Cl as I,ci as In,es as It,tl as J,Ao as Jt,sl as K,Po as Kt,xl as L,oi as Ln,$o as Lt,Il as M,fi as Mn,hs as Mt,Pl as N,ui as Nn,fs as Nt,Wl as O,Gi as On,Ss as Ot,El as P,di as Pn,ps as Pt,Gc as Q,bo as Qt,yl as R,Ur as Rn,ns as Rt,ru as S,hi as Sn,Fs as St,Xl as T,Q as Tn,Os as Tt,ml as U,Pr as Un,zo as Ut,gl as V,Lr as Vn,Uo as Vt,ul as W,Fr as Wn,Ro as Wt,Yc as X,Oo as Xt,el as Y,Eo as Yt,qc as Z,So as Zt,gu as _,Qi as _n,Ys as _t,Au as a,Xa as an,mc as at,iu as b,pi as bn,Hs as bt,Eu as c,za as cn,uc as ct,yu as d,xa as dn,oc as dt,fo as en,Hc as et,bu as f,_a as fn,ic as ft,hu as g,sa as gn,Xs as gt,_u as h,ca as hn,Zs as ht,Mu as i,to as in,xc as it,Ll as j,Ni as jn,ds as jt,zl as k,ji as kn,ys as kt,wu as l,Ra as ln,$ as lt,Su as m,la as mn,tc as mt,Nu as n,uo as nn,yc as nt,ku as o,Ya as on,pc as ot,xu as p,ua as pn,nc as pt,nl as q,Mo as qt,ju as r,ao as rn,bc as rt,Du as s,qa as sn,fc as st,Pu as t,po as tn,Vc as tt,Cu as u,Pa as un,ac as ut,fu as v,$i as vn,qs as vt,Ql as w,Li as wn,js as wt,uu as x,gi as xn,Ns as xt,au as y,aa as yn,Ks as yt,vl as z,zr as zn,ts as zt};
7
+ //# sourceMappingURL=hooks-wWyObPRq.js.map