@datarecce/ui 1.44.0-nightly.20260413 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import{$ as e,A as t,D as n,G as r,J as i,K as a,M as o,N as s,O as c,R as l,W as u,X as d,_t as f,a as p,c as m,d as h,et as g,gt as _,h as v,it as y,j as b,k as x,l as S,lt as C,m as w,mt as ee,n as T,nt as E,o as D,p as O,s as te,u as ne,w as re,x as ie}from"./api-E1dkaTi_.js";import{c as k,f as A}from"./keepAlive-DbC0X4zr.js";import{r as ae,t as j}from"./fetchClient-BVyYwVMf.js";import{C as oe,O as se,T as ce,_ as M,a as le,b as N,d as ue,f as de,g as P,h as fe,j as pe,k as me,l as he,m as ge,o as _e,p as ve,s as ye,u as be,v as xe,w as Se,y as Ce}from"./utils-SEuNIttT.js";import{i as we,n as F}from"./colors-BbPSDR1X.js";import{$t as Te,A as Ee,Bt as De,Cn as I,Dn as Oe,E as ke,En as Ae,Ft as je,Gt as Me,Ht as Ne,In as Pe,It as Fe,L as Ie,Ln as Le,Lt as Re,M as ze,Nn as L,Nt as R,O as Be,On as Ve,Pn as He,Qt as Ue,Rt as We,S as z,Sn as Ge,T as Ke,Tn as qe,Ut as Je,V as B,Vt as Ye,Wt as Xe,Xt as Ze,Yt as Qe,Zt as $e,_n as et,_t as tt,an as nt,bn as rt,bt as it,c as at,d as ot,dt as st,en as ct,f as lt,in as ut,j as dt,k as ft,ln as pt,lt as mt,m as ht,n as gt,o as _t,on as vt,p as yt,pt as bt,r as xt,rn as St,s as Ct,sn as wt,t as Tt,tn as Et,tt as Dt,un as Ot,ut as kt,v as At,vn as jt,w as Mt,wn as Nt,xn as Pt,yn as Ft,yt as It}from"./AuthModal-CGfEiCOR.js";import{Ft as Lt,Pt as Rt,Q as zt,a as Bt,ct as Vt,dt as Ht,i as Ut,m as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./utils-Crcz1Rb5.js";import{fetchGitHubAvatar as Xt,fetchUser as Zt}from"./lib/api/user.js";import{PUBLIC_CLOUD_WEB_URL as Qt,RECCE_SUPPORT_CALENDAR_URL as $t}from"./lib/const.js";import{EXPLORE_ACTION as en,EXPLORE_FORM_EVENT as tn,EXPLORE_SOURCE as nn,trackColumnLevelLineage as rn,trackCopyToClipboard as an,trackEnvironmentConfig as on,trackExploreAction as sn,trackExploreActionForm as cn,trackHistoryAction as ln,trackInit as un,trackLineageSelection as dn,trackLineageViewRender as fn,trackMultiNodesAction as pn,trackNavigation as mn,trackPreviewChange as hn,trackPreviewChangeFeedback as gn,trackShareState as _n,trackSingleEnvironment as vn,trackStateAction as yn}from"./lib/api/track.js";import{t as bn}from"./constants-D-hOGDbU.js";import{QueryClient as xn,QueryClientProvider as Sn,useMutation as Cn,useQuery as wn,useQueryClient as Tn}from"@tanstack/react-query";import{Suspense as En,createContext as Dn,forwardRef as On,memo as kn,useCallback as V,useContext as An,useEffect as jn,useImperativeHandle as Mn,useLayoutEffect as Nn,useMemo as H,useRef as Pn,useState as U}from"react";import{Fragment as W,jsx as G,jsxs as K}from"react/jsx-runtime";import q from"@mui/material/Box";import J from"@mui/material/Button";import Fn from"@mui/material/Dialog";import In from"@mui/material/DialogActions";import Ln from"@mui/material/DialogContent";import Rn from"@mui/material/DialogTitle";import zn from"@mui/material/Link";import Y from"@mui/material/Stack";import X from"@mui/material/Typography";import{LuExternalLink as Bn,LuSave as Vn}from"react-icons/lu";import{alpha as Hn,useTheme as Un}from"@mui/material/styles";import{useTheme as Wn}from"next-themes";import Z from"@mui/material/IconButton";import Gn from"next/link";import{IoBookmarksOutline as Kn,IoClose as qn,IoSync as Jn,IoWarning as Yn}from"react-icons/io5";import Xn from"@mui/material/Divider";import Zn from"@mui/material/CircularProgress";import Q from"@mui/material/Tooltip";import{FaCloud as Qn,FaExpandArrowsAlt as $n,FaGithub as er,FaQuestionCircle as tr,FaRegDotCircle as nr,FaSlack as rr,FaUser as ir}from"react-icons/fa";import{PiBookmarkSimple as ar,PiCaretDown as or,PiChatText as sr,PiCheckCircle as cr,PiCircle as lr,PiCopy as ur,PiExport as dr,PiInfo as fr,PiInfoFill as pr,PiMoon as mr,PiNotePencil as hr,PiPencil as gr,PiPencilSimple as _r,PiPlusCircle as vr,PiRepeat as yr,PiSun as br,PiTrashFill as xr,PiTrashSimple as Sr,PiX as Cr}from"react-icons/pi";import wr from"@mui/material/Chip";import{Background as Tr,BackgroundVariant as Er,BaseEdge as Dr,ControlButton as Or,Controls as kr,MiniMap as Ar,Panel as jr,Position as Mr,ReactFlow as Nr,ReactFlowProvider as Pr,getBezierPath as Fr,getNodesBounds as Ir,useEdgesState as Lr,useNodesState as Rr,useReactFlow as zr,useStore as Br}from"@xyflow/react";import Vr from"file-saver";import Hr from"@mui/material/Checkbox";import Ur from"@mui/material/FormControlLabel";import{useCopyToClipboard as Wr,useInterval as Gr}from"usehooks-ts";import Kr from"@mui/material/Alert";import qr from"@mui/material/Menu";import Jr from"@mui/material/MenuItem";import{isEmpty as Yr}from"lodash";import{VscCircleLarge as Xr,VscFeedback as Zr,VscGitPullRequest as Qr,VscHistory as $r,VscKebabVertical as ei}from"react-icons/vsc";import ti from"@mui/material/ListSubheader";import ni from"@mui/material/TextField";import{format as ri,formatDistanceToNow as ii,parseISO as ai}from"date-fns";import oi from"@mui/material/Tab";import si from"@mui/material/Tabs";import ci from"@mui/material/List";import li from"@mui/material/ListItem";import"@xyflow/react/dist/style.css";import{Box as ui,Typography as di}from"@mui/material";import fi from"@mui/material/Avatar";import pi from"@mui/material/Popover";import{usePathname as mi,useRouter as hi,useSearchParams as gi}from"next/navigation";import{TbChecklist as _i,TbCloudUpload as vi,TbEdit as yi}from"react-icons/tb";import bi from"@mui/material/ListItemIcon";import xi from"@mui/material/ListItemText";import{FiArrowRight as Si,FiCopy as Ci,FiInfo as wi,FiPackage as Ti}from"react-icons/fi";import Ei from"@mui/material/Switch";import{RiArrowDownSFill as Di,RiArrowUpSFill as Oi,RiMindMap as ki,RiSwapLine as Ai,RiTerminalBoxLine as ji}from"react-icons/ri";import{FaBookmark as Mi,FaFileImport as Ni}from"react-icons/fa6";import{BiArrowFromBottom as Pi,BiArrowToBottom as Fi}from"react-icons/bi";import Ii from"@dagrejs/dagre";import Li from"@mui/material/Skeleton";import{AiOutlineExperiment as Ri}from"react-icons/ai";import zi from"@mui/material/Radio";import Bi from"@mui/material/RadioGroup";import Vi from"@mui/material/Table";import Hi from"@mui/material/TableBody";import $ from"@mui/material/TableCell";import Ui from"@mui/material/TableContainer";import Wi from"@mui/material/TableHead";import Gi from"@mui/material/TableRow";import Ki from"@mui/material/Badge";import qi from"@mui/material/Grid";import{stripIndents as Ji}from"common-tags";import{IoMdCodeWorking as Yi}from"react-icons/io";import{DragDropContext as Xi,Draggable as Zi,Droppable as Qi}from"@hello-pangea/dnd";import $i from"@mui/material/Card";import ea from"@mui/material/CardContent";import ta from"@mui/material/CardHeader";const na=Dn(null);na.displayName=`RecceRoutingContext`;function ra(){return An(na)||{basePath:``,buildPath:e=>e,pathname:``,navigate:e=>{typeof window<`u`&&(window.location.href=e)}}}function ia(){let{pathname:e,navigate:t}=ra();return[e,t]}function aa({children:e,config:t}){let n=t?.basePath??``,r=t?.pathname??``,i=t?.onNavigate,a=V(e=>n?`${n}${e.startsWith(`/`)?e:`/${e}`}`:e,[n]),o=V((e,t)=>{i?i(e,t):typeof window<`u`&&(t?.replace?(window.history.replaceState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))):window.location.href=e)},[i]),s=H(()=>({basePath:n,buildPath:a,pathname:r,navigate:o}),[n,a,r,o]);return G(na.Provider,{value:s,children:e})}const oa=e=>new xn({defaultOptions:{queries:{staleTime:e?.staleTime??1e3*60,gcTime:e?.gcTime??1e3*60*5,retry:1,refetchOnWindowFocus:!1}}});function sa({children:e,api:t,theme:n=`system`,routing:r,queryClient:i,runActions:a,lineage:o,checks:s,query:c,features:l={}}){let u=i?.staleTime,d=i?.gcTime,f=H(()=>oa({staleTime:u,gcTime:d}),[u,d]),{enableInstance:p=!0,enableIdleTimeout:m=!0,enableLineage:h=!0,enableRunActions:g=!0,enableChecks:_=!0,enableQuery:v=!0}=l,y=e;return y=G(aa,{config:r,children:y}),y=G(Lt,{defaultMode:n,children:y}),y=G(k,{config:t,children:y}),y=G(Sn,{client:f,children:y}),v&&(y=G(He,{sql:c?.sql,isExecuting:c?.isExecuting,error:c?.error,baseResult:c?.baseResult,currentResult:c?.currentResult,onSqlChange:c?.onSqlChange,onExecute:c?.onExecute,onCancel:c?.onCancel,children:y})),_&&(y=G(Pe,{checks:s?.checks,isLoading:s?.isLoading,error:s?.error,selectedCheckId:s?.selectedCheckId,onSelectCheck:s?.onSelectCheck,onCreateCheck:s?.onCreateCheck,onUpdateCheck:s?.onUpdateCheck,onDeleteCheck:s?.onDeleteCheck,onReorderChecks:s?.onReorderChecks,refetchChecks:s?.refetchChecks,children:y})),g&&(y=G(se,{onRunAction:a?.onRunAction,onShowRunId:a?.onShowRunId,initialRunId:a?.initialRunId,initialHistoryOpen:a?.initialHistoryOpen,children:y})),h&&(y=G(P,{lineageGraph:o?.lineageGraph,envInfo:o?.envInfo,reviewMode:o?.reviewMode,cloudMode:o?.cloudMode,fileMode:o?.fileMode,fileName:o?.fileName,isDemoSite:o?.isDemoSite,isCodespace:o?.isCodespace,isLoading:o?.isLoading,error:o?.error,supportTasks:o?.supportTasks,onRefetchLineageGraph:o?.onRefetchLineageGraph,runsAggregated:o?.runsAggregated,onRefetchRunsAggregated:o?.onRefetchRunsAggregated,children:y})),m&&(y=G(Ce,{children:y})),p&&(y=G(oe,{children:y})),y}function ca({actionState:e,onCancel:t,onClose:n}){let r=()=>e.mode===`per_node`?`${e.completed} / ${e.total}`:e.currentRun?.progress?.percentage?`${e.currentRun.progress.percentage*100}%`:e.status===`completed`?`100%`:`0%`,i=e.status===`running`||e.status===`canceling`;return G(q,{sx:{bgcolor:`background.paper`,borderRadius:1,boxShadow:6},children:K(Y,{direction:`row`,divider:G(Xn,{orientation:`vertical`,flexItem:!0}),spacing:2,sx:{p:`5px 15px`,mt:2},children:[K(q,{sx:{fontSize:`10pt`},children:[`Progress: `,r(),` `,e.status===`canceled`?` (canceled)`:``]}),i?G(J,{size:`small`,variant:`outlined`,onClick:t,disabled:e.status===`canceling`,children:e.status===`canceling`?`Canceling`:`Cancel`}):G(Y,{direction:`row`,children:G(J,{size:`small`,variant:`outlined`,onClick:n,children:`Close`})})]})})}const la=({lineageGraph:e,cllInput:t,onCenterNode:n})=>{let r={cursor:`pointer`,fontFamily:`monospace`,bgcolor:Rt()?`grey.700`:`grey.100`,px:.5,borderRadius:.5};if(!e)return G(W,{});if(!t)return G(W,{children:`Default View`});if(t.node_id===void 0)return G(X,{component:`span`,children:`Impact Radius for All Changed Models`});let i=t.node_id in e.nodes?e.nodes[t.node_id].data.name:t.node_id;if(!t.column){let e=t.node_id;return K(W,{children:[G(X,{component:`span`,sx:{mr:`5px`},children:`Impact Radius for`}),G(q,{component:`code`,onClick:()=>{n(e)},sx:r,children:i})]})}let a=`${t.node_id}_${t.column}`;return K(W,{children:[K(X,{component:`span`,sx:{mr:`5px`},children:[`Column Lineage for`,` `]}),K(q,{component:`code`,onClick:()=>{n(a)},sx:r,children:[i,`.`,t.column]})]})},ua=({action:e,interactive:t,viewOptions:n,lineageGraph:r,singleEnvMode:i=!1,changeAnalysisAvailable:a=!0,onShowCll:o,onResetCll:s,onCenterNode:c,setChangeAnalysisMode:l,newCllExperience:u=!1,changeAnalysisMode:d=!1})=>{let f=n.column_level_lineage,p=!r?.catalogMetadata.current,m=u&&d,h=f&&!(u&&!f.column);return K(Y,{direction:`row`,spacing:`5px`,children:[!i&&!m&&G(q,{sx:{borderRadius:1,boxShadow:3},children:G(Q,{enterDelay:50,title:a?p?`Please provide catalog.json to enable Impact Radius`:``:`Requires warehouse connection`,placement:`top`,children:G(`span`,{children:G(J,{size:`small`,variant:`outlined`,color:`neutral`,sx:{whiteSpace:`nowrap`,display:`inline-flex`,bgcolor:`background.paper`},disabled:!t||p||!a||e.isPending,startIcon:G(nr,{}),onClick:()=>{l?.(!0),o({no_upstream:!0,change_analysis:!0})},children:`Impact Radius`})})})}),h&&K(Y,{direction:`row`,alignItems:`center`,sx:{borderRadius:1,boxShadow:3,border:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`,fontSize:`0.8rem`,p:`0 0.625rem`},children:[G(la,{lineageGraph:r,cllInput:f,onCenterNode:c}),e.isError&&G(Q,{title:`Error: ${e.error.message}`,placement:`bottom`,children:G(X,{component:`span`,sx:{color:`error.main`,ml:`2px`,display:`inline-flex`,alignItems:`center`},children:G(q,{component:fr,sx:{color:`error.main`,fontSize:`14px`}})})}),e.isPending?G(Zn,{size:12,sx:{ml:`2px`}}):G(Z,{size:`small`,sx:{ml:`2px`},"aria-label":`Reset Column Level Lineage`,onClick:()=>{s()},children:G(Cr,{size:`10px`})})]})]})};function da({onClose:e}){let{cancel:t,actionState:n}=fe();return G(ca,{actionState:n,onCancel:t,onClose:e})}const fa=({action:e})=>{let{showColumnLevelLineage:t,resetColumnLevelLineage:n,interactive:r,viewOptions:i,centerNode:a,setChangeAnalysisMode:o,newCllExperience:s,changeAnalysisMode:c}=fe(),{data:l}=be(),u=l?.single_env_onboarding??!1,{lineageGraph:d,isActionAvailable:f}=M();return G(ua,{action:e,interactive:r,viewOptions:i,lineageGraph:d,singleEnvMode:u,changeAnalysisAvailable:f(`change_analysis`),onShowCll:t,onResetCll:()=>n(),onCenterNode:a,setChangeAnalysisMode:o,newCllExperience:s,changeAnalysisMode:c})};function pa(e){let{id:t,data:n}=e,{id:r}=n.node,{column:i,type:a,transformationType:o,changeStatus:s,isImpacted:c}=n,l=Br(e=>e.transform[2]>.3),{isDark:u}=gt(),{viewOptions:d,showContextMenu:f,isNodeHighlighted:p,isNodeShowingChangeAnalysis:m,newCllExperience:h}=fe(),g=d.column_level_lineage?.node_id,_=i===d.column_level_lineage?.column&&r===g,v=p(t),y=m(r);return G(et,{id:t,data:{column:i,type:a,nodeId:r,transformationType:o,changeStatus:s,isHighlighted:v,isFocused:_,isImpacted:c},showContent:l,showChangeAnalysis:y,isDark:u,newCllExperience:h,onContextMenu:(t,n)=>{f(t,e)}})}const ma=kn(pa);ma.displayName=`GraphColumnNode`;function ha(e){let{source:t,target:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,style:l={},markerEnd:u,data:d,isEdgeHighlighted:f}=e,p={...l};d?.changeStatus&&(p.stroke=I(d.changeStatus).hexColor,p.strokeDasharray=`5`),!f||f(t,n)||(p.filter=qe);let[m]=Fr({sourceX:r,sourceY:i,sourcePosition:s,targetX:a,targetY:o,targetPosition:c});return G(W,{children:G(Dr,{path:m,markerEnd:u,style:{...p,...l}})})}const ga=kn(ha);ga.displayName=`GraphEdge`;function _a(e){let{isEdgeHighlighted:t}=fe();return G(ga,{...e,isEdgeHighlighted:t})}const va=()=>G(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:G(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z`})}),ya=()=>G(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:G(`path`,{d:`M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z`})});function ba({skipReason:e}){return G(wr,{size:`small`,label:K(Y,{direction:`row`,sx:{fontSize:`10pt`,color:`grey.500`,alignItems:`center`,gap:`3px`},children:[G(q,{children:`Skipped`}),e&&G(Q,{title:e,children:G(q,{component:`span`,sx:{display:`flex`},children:G(va,{})})})]}),sx:{bgcolor:`grey.100`}})}function xa({errorMessage:e}){return K(Y,{direction:`row`,sx:{fontSize:`10pt`,color:`gray`,alignItems:`center`},children:[G(q,{children:`Error`}),e&&G(Q,{title:e,children:G(q,{component:`span`,sx:{display:`flex`},children:G(ya,{})})})]})}function Sa({result:e}){let{mismatchedColumns:t}=e,n=t>0;return G(wr,{size:`small`,sx:{bgcolor:n?`error.light`:`success.light`},label:G(Y,{direction:`row`,sx:{fontSize:`10pt`,color:n?`error.main`:`success.main`,alignItems:`center`,gap:`3px`},children:n?`${t} columns mismatched`:`All columns match`})})}function Ca({result:e}){let{base:t,current:n}=e,r=t===null?`N/A`:t.toLocaleString(),i=n===null?`N/A`:n.toLocaleString(),a=``,o=`grey.500`;return t!==null&&n!==null&&(n>t?(a=`↑`,o=`success.main`):n<t?(a=`↓`,o=`error.main`):a=`=`),G(wr,{size:`small`,sx:{bgcolor:`grey.100`},label:K(Y,{direction:`row`,sx:{fontSize:`10pt`,alignItems:`center`,gap:`3px`},children:[G(q,{children:r}),G(q,{children:`→`}),G(q,{children:i}),a&&G(q,{component:`span`,sx:{color:o,ml:.5},children:a})]})})}function wa({status:e,skipReason:t,errorMessage:n,progress:r,valueDiffResult:i,rowCountDiffResult:a,runId:o,"data-testid":s}){return e===`pending`?G(Zn,{size:16,"data-testid":s,"data-status":`pending`}):e===`skipped`?G(q,{"data-testid":s,"data-status":`skipped`,children:G(ba,{skipReason:t})}):e===`running`?r?.percentage===void 0?G(Zn,{size:16,"data-testid":s,"data-status":`running`}):G(Zn,{variant:`determinate`,value:r.percentage*100,size:16,"data-testid":s,"data-status":`running`}):e===`error`?G(q,{"data-testid":s,"data-status":`error`,children:G(xa,{errorMessage:n})}):i?G(q,{"data-testid":s,"data-status":`success`,children:G(Sa,{result:i})}):a?G(q,{"data-testid":s,"data-status":`success`,children:G(Ca,{result:a})}):G(q,{"data-testid":s,"data-status":`success`,children:o||`Complete`})}const Ta=kn(wa);Ta.displayName=`ActionTag`;const Ea={success:`#059669`,failure:`#ef4444`,error:`#ef4444`,warning:`#f59e0b`},Da={success:`PASSED`,failure:`FAILED`,error:`ERROR`,warning:`WARNING`};function Oa(e){return Ea[e]??`#6b7280`}function ka(e){return Da[e]??e.toUpperCase()}function Aa({run:e,index:t,onClick:n}){let r=Oa(e.status),i=ka(e.status),a=ii(new Date(e.run_at),{addSuffix:!0}),o=!!n;return K(ui,{component:o?`button`:`div`,type:o?`button`:void 0,onClick:o?()=>n?.(e.run_id):void 0,"aria-label":o?`View run #${t} — ${i}`:void 0,sx:{p:1,border:`none`,borderLeft:`3px solid ${r}`,borderRadius:1,bgcolor:`action.hover`,cursor:o?`pointer`:`default`,"&:hover":o?{bgcolor:`action.selected`}:{},textAlign:`left`,width:`100%`,font:`inherit`,color:`inherit`},children:[K(di,{variant:`body2`,sx:{fontWeight:600,fontSize:`0.75rem`},children:[`Run #`,t,` — `,i,e.triggered_by===`recce_ai`&&G(di,{component:`span`,sx:{ml:.75,fontSize:`0.65rem`,fontWeight:500,color:`#7c3aed`},children:`by AI`})]}),e.summary&&G(di,{variant:`body2`,sx:{color:`text.secondary`,fontSize:`0.7rem`,mt:.25},children:e.summary}),G(di,{variant:`body2`,sx:{color:`text.secondary`,fontSize:`0.65rem`,mt:.25},children:a})]})}function ja({event:e}){let t=l(e),n={create:vr,comment:sr,approve:cr,unapprove:lr,edit:hr,preset:ar},r={create:`primary.main`,comment:`grey.500`,approve:`success.main`,unapprove:`grey.400`,edit:`warning.main`,preset:`secondary.main`},i=n[t],a=r[t];return G(q,{component:i,sx:{color:a,fontSize:16}})}function Ma({event:e}){let{actor:t}=e,{avatarUrl:n}=Ye({userId:t.user_id}),r=(t.fullname||t.login||`User`).charAt(0).toUpperCase();return G(fi,{src:n||void 0,sx:{width:24,height:24,fontSize:`0.75rem`},children:r})}function Na({event:e}){let{actor:t}=e,n=t.fullname||t.login||`Someone`,r=ii(new Date(e.created_at),{addSuffix:!0}),i=``;switch(e.event_type){case`check_created`:i=`created this check`;break;case`approval_change`:i=e.new_value===`true`?`approved this check`:`unapproved this check`;break;case`description_change`:i=`updated the description`;break;case`name_change`:i=`renamed this check`;break;case`preset_applied`:i=`applied a preset`;break;default:i=`made a change`}return K(q,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[G(q,{sx:{pt:`2px`},children:G(ja,{event:e})}),G(q,{sx:{flex:1},children:K(Y,{direction:`row`,spacing:.5,flexWrap:`wrap`,alignItems:`center`,children:[G(Ma,{event:e}),G(X,{variant:`body2`,fontWeight:`500`,children:n}),G(X,{variant:`body2`,color:`text.secondary`,children:i}),G(X,{variant:`caption`,color:`text.disabled`,children:r})]})})]})}function Pa({event:e,currentUserId:t,onEdit:n,onDelete:r}){let i=Rt(),[a,o]=U(!1),[s,c]=U(e.content||``),[l,u]=U(!1),[d,f]=U(!1),[p,m]=U(null),h=!!p,{actor:g}=e,_=g.fullname||g.login||`Someone`,v=ii(new Date(e.created_at),{addSuffix:!0}),y=t&&String(g.user_id)===String(t),b=()=>{c(e.content||``),o(!0)},x=()=>{c(e.content||``),o(!1)},S=async()=>{let t=s.trim();if(!t||t===e.content){x();return}if(n){u(!0);try{await n(e.id,t),o(!1)}finally{u(!1)}}},C=e=>{e.key===`Escape`?x():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())},w=e=>{m(e.currentTarget)},ee=()=>{m(null)},T=async()=>{if(r){f(!0);try{await r(e.id),ee()}finally{f(!1)}}};return e.is_deleted?K(q,{sx:{display:`flex`,gap:1,alignItems:`center`,py:1},children:[G(q,{sx:{pt:`2px`,display:`flex`,alignItems:`center`},children:G(ja,{event:e})}),G(q,{sx:{display:`flex`,flex:1,alignItems:`center`},children:G(X,{variant:`body2`,color:`text.disabled`,fontStyle:`italic`,children:`Comment deleted`})})]}):K(q,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[G(q,{sx:{pt:`2px`},children:G(ja,{event:e})}),K(q,{sx:{flex:1},children:[K(Y,{direction:`row`,spacing:.5,sx:{mb:.5},flexWrap:`wrap`,alignItems:`center`,children:[G(Ma,{event:e}),K(X,{variant:`body2`,fontWeight:`500`,children:[_,y&&K(X,{component:`span`,variant:`body2`,color:`text.secondary`,children:[` `,`(Author)`]})]}),G(X,{variant:`caption`,color:`text.disabled`,children:v}),e.is_edited&&G(X,{variant:`caption`,color:`text.disabled`,children:`(edited)`})]}),a?K(q,{children:[G(ni,{value:s,onChange:e=>c(e.target.value),onKeyDown:C,size:`small`,multiline:!0,minRows:3,fullWidth:!0,disabled:l,autoFocus:!0,sx:{"& .MuiOutlinedInput-root":{bgcolor:`background.paper`,"&:focus-within":{borderColor:`primary.main`}}}}),K(Y,{direction:`row`,spacing:1,sx:{mt:1},justifyContent:`flex-end`,children:[G(J,{size:`small`,variant:`text`,onClick:x,disabled:l,children:`Cancel`}),G(J,{size:`small`,variant:`contained`,onClick:S,disabled:!s.trim()||l,children:l?`Saving...`:`Save`})]})]}):K(q,{sx:{bgcolor:i?`grey.800`:`grey.50`,borderRadius:1,p:1,border:`1px solid`,borderColor:i?`grey.700`:`grey.200`,position:`relative`,"&:hover .comment-actions":{opacity:1}},children:[G(bt,{content:e.content||``,fontSize:`sm`}),y&&(n||r)&&K(Y,{className:`comment-actions`,direction:`row`,spacing:0,sx:{position:`absolute`,top:4,right:4,opacity:0,transition:`opacity 0.2s`},children:[n&&G(Q,{title:`Edit comment`,children:G(Z,{"aria-label":`Edit comment`,size:`small`,onClick:b,children:G(_r,{})})}),r&&K(W,{children:[G(Q,{title:`Delete comment`,children:G(Z,{"aria-label":`Delete comment`,size:`small`,color:`error`,onClick:w,children:G(Sr,{})})}),G(pi,{open:h,anchorEl:p,onClose:ee,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},children:K(q,{sx:{p:2},children:[G(X,{variant:`body2`,sx:{mb:2},children:`Delete this comment?`}),K(Y,{direction:`row`,spacing:1,justifyContent:`flex-end`,children:[G(J,{size:`small`,variant:`text`,onClick:ee,disabled:d,children:`Cancel`}),G(J,{size:`small`,variant:`contained`,color:`error`,onClick:T,disabled:d,children:d?`Deleting...`:`Delete`})]})]})})]})]})]})]})]})}function Fa({event:e,currentUserId:t,onEdit:n,onDelete:r}){return e.event_type===`comment`?G(Pa,{event:e,currentUserId:t,onEdit:n,onDelete:r}):G(Na,{event:e})}function Ia(e,t){let n=e?.toLowerCase();return n===`finished`?t?`error`:`success`:n===`failed`?`error`:e??`unknown`}function La(e,t){let n=[];for(let t of e)n.push({kind:`event`,event:t,at:t.created_at});if(t){let e=[...t].sort((e,t)=>new Date(e.run_at).getTime()-new Date(t.run_at).getTime());for(let t=0;t<e.length;t++)n.push({kind:`run`,run:e[t],index:t+1,at:e[t].run_at})}return n.sort((e,t)=>new Date(t.at).getTime()-new Date(e.at).getTime()),n}function Ra({checkId:e}){let t=Rt(),{apiClient:n,authToken:r}=Ne(),{events:i,isLoading:a,error:o,createComment:s,isCreatingComment:c,updateComment:l,deleteComment:u}=ot(e),{data:f}=wn({queryKey:A.user(),queryFn:()=>Zt(n),retry:!1}),{data:p}=wn({queryKey:[`check-runs`,e],queryFn:async()=>(await d(n)).filter(t=>t.check_id===e).map(e=>({run_id:e.run_id,run_at:e.run_at,status:Ia(e.status,e.error),summary:e.error||void 0,triggered_by:e.triggered_by})),enabled:!!r,staleTime:3e4}),m=H(()=>La(i,p),[i,p]),h=e=>{s(e)},g=async(e,t)=>{await l({eventId:e,content:t})},_=async e=>{await u(e)};return a?G(q,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(Zn,{size:20})}):o?G(q,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(X,{sx:{fontSize:`0.875rem`,color:`error.main`},children:`Failed to load timeline`})}):K(Y,{sx:{height:`100%`,alignItems:`stretch`,borderLeft:`1px solid`,borderColor:t?`grey.700`:`grey.200`},spacing:0,children:[G(q,{sx:{px:3,py:2,borderBottom:`1px solid`,borderColor:t?`grey.700`:`grey.200`},children:G(X,{variant:`subtitle2`,sx:{fontWeight:500},children:`Activity`})}),G(q,{sx:{flex:1,overflowY:`auto`,px:3,py:2},children:m.length===0?G(X,{sx:{fontSize:`0.875rem`,color:`grey.500`},children:`No activity yet`}):G(Y,{sx:{alignItems:`stretch`},spacing:0,children:m.map((e,n)=>K(q,{children:[e.kind===`event`?G(Fa,{event:e.event,currentUserId:f?.id,onEdit:g,onDelete:_}):G(Aa,{run:e.run,index:e.index}),n<m.length-1&&G(Xn,{sx:{borderColor:t?`grey.700`:`grey.100`}})]},e.kind===`event`?e.event.id:e.run.run_id))})}),G(q,{sx:{px:3,py:3,borderTop:`1px solid`,borderColor:t?`grey.700`:`grey.200`,bgcolor:t?`grey.900`:`grey.50`},children:G(De,{onSubmit:h,isSubmitting:c})})]})}function za({color:e}){return G(q,{component:`span`,sx:{display:`inline-block`,width:`10px`,height:`10px`,bgcolor:e,mr:1,borderRadius:`4px`}})}const Ba=({defaultPrimaryKeys:e,onPrimaryKeysChange:t,...n})=>{let{lineageGraph:r,isActionAvailable:i}=M(),a=H(()=>{if(!r)return[];let e=new Set;for(let t in r.nodes){let n=r.nodes[t],i={...n.data.data.base?.columns??{},...n.data.data.current?.columns??{}};Object.entries(i).forEach(([t,n])=>{n?.unique&&e.add(t)})}return Array.from(e).sort()},[r]);return G(q,{sx:{display:`flex`},...n,children:K(Y,{spacing:0,sx:{m:`0 0.5rem`},children:[K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(X,{component:`label`,sx:{fontSize:`0.625rem`,color:`text.secondary`},children:`Diff with Primary Key(s) (suggested)`}),G(Q,{title:`Provide a primary key to perform query diff in data warehouse and only return changed rows.`,placement:`bottom-end`,children:G(q,{component:`span`,sx:{display:`flex`,color:`grey.600`,cursor:`help`},children:G(fr,{fontSize:`0.75rem`})})})]}),G(Ot,{className:`no-track-pii-safe`,unitName:`key`,defaultValues:e,suggestionList:a,onValuesChange:t,size:`2xs`,width:`240px`,placeholder:`Select or type to add keys`,disabled:!i(`query_diff_with_primary_key`)})]})})};function Va({supportCalendarUrl:e=`https://cal.com/team/recce/chat`}){let{data:t}=ce();return G(`div`,{className:`flex flex-1 h-full min-h-0 m-2 p-4 bg-blue-50 rounded-lg shadow-md justify-center`,children:K(`div`,{className:`w-4/5 flex flex-col overflow-y-auto gap-6 px-8 pb-8`,children:[K(Y,{alignItems:`center`,spacing:2,children:[G(q,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:G(q,{component:ji,sx:{fontSize:28,color:`iochmara.500`}})}),G(X,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),K(X,{sx:{fontSize:`1rem`,textAlign:`center`},children:[`Query functions disabled without a`,` `,G(X,{component:`span`,sx:{fontWeight:`bold`},children:`data warehouse connection`})]})]}),G(Y,{sx:{width:`50%`,mt:3,mx:`auto`},children:G(J,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{window.open(Yt(t,e),`_blank`)},children:`Connect to Data Warehouse`})})]})})}const Ha=()=>{let{isCustomQueries:e,setCustomQueries:t,sqlQuery:n,setBaseSqlQuery:r}=z();return K(q,{children:[K(Y,{direction:`row`,spacing:.5,alignItems:`center`,fontSize:`0.75rem`,children:[G(X,{variant:`body2`,sx:{fontSize:`0.75rem`},children:`Custom Queries`}),G(Q,{title:`Custom queries allow you to use two SQL queries to compare results between current and base environments.`,children:G(q,{component:`span`,sx:{display:`flex`,color:`grey.600`},children:G(pr,{fontSize:`1rem`})})})]}),G(Ei,{size:`small`,checked:e,onChange:()=>{!e&&r&&r(n),t(!e)},color:`primary`})]})},Ua=()=>{let{sqlQuery:e,baseSqlQuery:t,setSqlQuery:n,setBaseSqlQuery:i,primaryKeys:o,setPrimaryKeys:s,isCustomQueries:c}=z(),{lineageGraph:l,envInfo:d}=M(),{featureToggles:f,singleEnv:p}=Se(),m=e;d?.adapterType===`sqlmesh`&&e===`select * from {{ ref("mymodel") }}`&&(m=`select * from db.mymodel`),f.mode===`read only`&&(m=`--- Would like to do query here? Book a demo with us at ${$t}\n${m}`);let{showRunId:h}=me(),{apiClient:_}=Ne(),{mutate:v,isPending:y}=Cn({mutationFn:async e=>{function n(e){switch(e){case`query`:return u;case`query_base`:return r;case`query_diff`:return a;default:throw Error(`Unknown query type: ${e}`)}}let i=e===`query_base`?t??``:m,s=n(e),l={sql_template:i},d={nowait:!0};e===`query_diff`&&(l.primary_keys=o,c&&(l.base_sql_template=t));let{run_id:f}=await s(l,d,_);return h(f),await g(f,void 0,_)}}),b=H(()=>{let e={};if(!l)return`N/A`;for(let t in l.nodes){let n=l.nodes[t].data.data.current?.schema;n&&(e[n]=(e[n]||0)+1)}return Object.keys(e).reduce((t,n)=>e[n]>(e[t]||0)?n:t,`N/A`)},[l]);return p||f.mode===`metadata only`?K(q,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[K(q,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`},children:[G(ls,{}),G(q,{sx:{flexGrow:1}}),p?G(Q,{title:`Please configure the base environment before running the diff`,placement:`left`,children:G(`span`,{children:G(J,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})}):G($s,{display:f.mode===`metadata only`,children:G(J,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})]}),G(ft,{value:m,onChange:n,onRun:()=>{v(`query`)},labels:[`base (production)`,`current (${b})`],SetupGuide:f.mode===`metadata only`?G(Va,{}):G(is,{})})]}):K(q,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[K(q,{sx:{display:`flex`,justifyContent:`right`,alignItems:`flex-end`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`,flex:`0 0 54px`},children:[G(ls,{}),G(Ha,{}),G(q,{sx:{flexGrow:1}}),G(Ba,{defaultPrimaryKeys:o,onPrimaryKeysChange:s}),G(J,{variant:`contained`,onClick:()=>{v(`query_diff`)},disabled:y||f.disableDatabaseQuery,size:`small`,children:`Run Diff`})]}),G(q,{sx:{width:`100%`,flex:1,overflowY:`auto`},children:c?G(ft,{value:m,baseValue:t,onChange:n,onChangeBase:i,onRun:()=>{v(`query`)},onRunBase:()=>{v(`query_base`)},onRunDiff:()=>{v(`query_diff`)}}):G(Ee,{value:m,onChange:n,onRun:()=>{v(`query`)},onRunDiff:()=>{v(`query_diff`)}})})]})};function Wa({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} Rows`,i=e.curr===null?`N/A`:`${e.curr} Rows`,a,o;t===null&&n===null?(a=`Failed to load`,o=`default`):t===null||n===null?(a=`${r} -> ${i}`,o=t===null?`success`:`error`):t===n?(a=`=`,o=`default`):(a=`${Wt(t,n)} Rows`,o=t<n?`success`:`error`);let s=B(`row_count_diff`).icon;return G(wr,{size:`small`,color:o,icon:s?G(s,{}):void 0,label:a,sx:{height:20,fontSize:`0.7rem`}})}function Ga({id:e,inverted:t}){let{lineageGraph:n,runsAggregated:r}=M(),{text:i,isDark:a}=gt(),o=r?.[e],s=n?.nodes[e];if(!o&&!s)return null;let c;if(s?.data.data.base&&s.data.data.current){let e=s.data.data.base.columns,t=s.data.data.current.columns;c=Gt(e,t)}let l;if(o?.row_count_diff){let e=o.row_count_diff.result;l=e.curr!==e.base}let u=t?i.inverted:I(`modified`).color,d=t?i.secondary:a?`grey.700`:`grey.100`,f=B(`schema_diff`).icon;return K(q,{sx:{display:`flex`,flex:1,alignItems:`center`},children:[c!==void 0&&G(Q,{title:`Schema (${c?`changed`:`no change`})`,enterDelay:500,children:G(q,{sx:{height:16},children:f&&G(q,{component:f,sx:{color:c?u:d}})})}),G(q,{sx:{flexGrow:1}}),o?.row_count_diff&&l!==void 0&&G(Q,{title:`Row count (${l?`changed`:`=`})`,enterDelay:500,children:G(q,{children:G(Wa,{rowCount:o.row_count_diff.result})})})]})}function Ka({nodeId:e,nodeName:t}){let{getNodeAction:n}=fe(),r=n(e);if(!r)return null;let{status:i,skipReason:a,run:o}=r;if(i===`pending`)return G(Ta,{status:`pending`});if(i===`skipped`)return G(Ta,{status:`skipped`,skipReason:a});if(!o)return G(Ta,{status:`pending`});let{error:s,run_id:c,progress:l}=o;if(i===`running`)return G(Ta,{status:`running`,progress:{percentage:l?.percentage}});if(s)return G(Ta,{status:`error`,errorMessage:s});if(o.type===`value_diff`&&o.result){let e=o.result,t=0,n=e.data.data.length;for(let n of e.data.data)n[2]<1&&t++;return G(Ta,{status:`success`,valueDiffResult:{mismatchedColumns:t,totalColumns:n}})}if(C(o)&&o.result){let e=o.result[t];if(e)return G(Wa,{rowCount:e})}if(o.type===`row_count`&&o.result){let e=o.result[t];if(e?.curr!==void 0&&e.curr!==null)return G(wr,{size:`small`,label:`${e.curr.toLocaleString()} Rows`,sx:{height:20,fontSize:`0.7rem`}})}return G(Ta,{status:`success`,runId:c})}function qa(e){let{data:t}=e,{id:n,resourceType:r,changeStatus:i,name:a}=t,o=Br(e=>e.transform[2]>.3),{isDark:s}=gt(),{interactive:c,selectNode:l,selectMode:u,focusedNode:d,getNodeAction:f,getNodeColumnSet:p,isNodeHighlighted:m,isNodeSelected:h,isNodeShowingChangeAnalysis:g,showContextMenu:_,viewOptions:v,cll:y,impactedNodeIds:b,newCllExperience:x,showColumnLevelLineage:S,setChangeAnalysisMode:C}=fe(),{isActionAvailable:w}=M(),ee=x?b.has(n):!1,T=y?.current.nodes[n]?.change_category,E=m(n),D=h(n),O=v.column_level_lineage?.node_id===n&&v.column_level_lineage.column===void 0,te=d?.id===n||O,ne=g(n),re=p(t.id),ie=u===`action_result`?f(t.id):void 0,k=i,A=u,ae=u===`action_result`&&ie?G(Ka,{nodeId:n,nodeName:a}):void 0,j=u!==`action_result`&&t.resourceType===`model`?G(Ga,{id:t.id,inverted:u===`selecting`&&D}):void 0;return G(vt,{id:n,data:{label:a,changeStatus:k,resourceType:r,materialized:t.data?.current?.config?.materialized??t.data?.base?.config?.materialized},newCllExperience:x,isImpacted:ee,interactive:c,selectMode:A,isNodeSelected:D,isFocused:te,isHighlighted:E,showContent:o,actionTag:ae,showChangeAnalysis:ne,changeCategory:T,runsAggregatedTag:j,hasParents:Object.keys(t.parents).length>0,hasChildren:Object.keys(t.children).length>0,columnCount:re.size,columnHeight:24,isDark:s,onSelect:e=>{l(e)},onContextMenu:(t,n)=>{_(t,e)},onShowImpactRadius:i===`modified`&&w(`change_analysis`)?e=>{C(!0),S({node_id:e,change_analysis:!0,no_upstream:!0})}:void 0})}const Ja=kn(qa);Ja.displayName=`GraphNode`;const Ya={lineageGraphNode:Ja,lineageGraphColumnNode:ma},Xa={lineageGraphEdge:_a},Za=[],Qa=e=>e.data.changeStatus?I(e.data.changeStatus).hexColor:F.neutral[400],$a={ROW_COUNT:`row_count`,ROW_COUNT_DIFF:`row_count_diff`,PROFILE:`profile`,PROFILE_DIFF:`profile_diff`,VALUE_DIFF:`value_diff`,HISTOGRAM_DIFF:`histogram_diff`,TOP_K_DIFF:`top_k_diff`},eo={LINEAGE_VIEW_CONTEXT_MENU:`lineage_view_context_menu`},to={SELECT_PARENT_NODES:`select_parent_nodes`,SELECT_CHILD_NODES:`select_child_nodes`,SELECT_ALL_UPSTREAM:`select_all_upstream`,SELECT_ALL_DOWNSTREAM:`select_all_downstream`},no=({menuItems:e,open:t,onClose:n,x:r,y:i,featureToggles:a,DisabledItemWrapper:o})=>{let s=o??(({children:e})=>G(W,{children:e})),c=a?.mode===`metadata only`;return G(qr,{open:t,onClose:n,anchorReference:`anchorPosition`,anchorPosition:{top:i,left:r},slotProps:{paper:{sx:{fontSize:`0.85rem`,width:`250px`}}},children:e.length===0?G(Jr,{disabled:!0,children:`No action available`},`no action`):e.map(({isSeparator:e,label:t,isDisabled:r,action:i,itemIcon:a})=>{if(e)return G(Xn,{},t);let l=K(Jr,{disabled:r,onClick:()=>{i&&i(),n()},children:[a,` `,t]},t);return r&&o?G(s,{display:c,children:l},t):l})})},ro=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>{let d=[],{runAction:f,onNavigate:p,onTrack:m,findByRunType:h,setSqlQuery:g,setPrimaryKeys:_,getPrimaryKey:v,DisabledItemWrapper:y}=a,{selectMode:b,cll:x,showColumnLevelLineage:S,setChangeAnalysisMode:C,selectParentNodes:w,selectChildNodes:ee,getNodeColumnSet:T}=o,E=c.single_env_onboarding??!1,D=s.disableDatabaseQuery??!1;if(!i?.data)return G(W,{});let O=i.data,te=O.resourceType,ne=T?Array.from(T(i.id)):[],re={source:`lineage_model_node`},ie=O.changeStatus,k=v?.(O.name);if(ie===`modified`&&d.push({label:`Show Impact Radius`,itemIcon:G(nr,{}),isDisabled:l||!u(`change_analysis`),action:()=>{C?.(!0),S?.({node_id:i.id,change_analysis:!0,no_upstream:!0})}}),!b&&te&&[`model`,`seed`,`snapshot`].includes(te)){d.length>0&&d.push({label:`select group one`,isSeparator:!0});let e=h?.(E?`query`:`query_diff`),t=Kt(Object.keys(O.data.base?.columns??{}),Object.keys(O.data.current?.columns??{})),n=`select * from {{ ref("${O.name}") }}`;if(t.length&&(n=`select \n ${t.join(`
3
+ `)}\nfrom {{ ref("${O.name}") }}`),e&&d.push({label:`Query`,itemIcon:G(q,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{g?.(n),u(`query_diff_with_primary_key`)&&_?.(k===void 0?void 0:[k]),p?.(`/query`)}}),ne.length>0&&e)if(x!==void 0){let t=new Set;k&&t.add(k),ne.forEach(e=>{t.add(e)}),d.push({label:`Query Related Columns`,itemIcon:G(q,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{let e=`select \n ${Array.from(t).join(`,
4
+ `)}\nfrom {{ ref("${O.name}") }}`;g?.(e),u(`query_diff_with_primary_key`)&&_?.(k===void 0?void 0:[k]),p?.(`/query`)}})}else{let t=Object.entries(O.change?.columns??{}).filter(([,e])=>e===`modified`).map(([e])=>e);if(t.length>0){let n=new Set;k&&n.add(k),t.forEach(e=>{n.add(e)}),d.push({label:`Query Modified Columns`,itemIcon:G(q,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{let e=`select \n ${Array.from(n).join(`,
5
+ `)}\nfrom {{ ref("${O.name}") }}`;g?.(e),u(`query_diff_with_primary_key`)&&_?.(k===void 0?void 0:[k]),p?.(`/query`)}})}}let r=E?`row_count`:`row_count_diff`,a=h?.(r);a&&d.push({label:a.title,itemIcon:G(q,{component:a.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{m?.(`explore_action`,{action:E?$a.ROW_COUNT:$a.ROW_COUNT_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(r,{node_names:[O.name]},{showForm:!1,trackProps:re})}});let o=E?`profile`:`profile_diff`,s=h?.(o);if(s&&d.push({label:s.title,itemIcon:G(q,{component:s.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{let e=T?Array.from(T(i.id)):[];m?.(`explore_action`,{action:E?$a.PROFILE:$a.PROFILE_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(o,{model:O.name,columns:e},{showForm:!0,trackProps:re})}}),!E){let e=h?.(`value_diff`);e&&d.push({label:e.title,itemIcon:G(q,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:D,action:()=>{let e=T?Array.from(T(i.id)):[];m?.(`explore_action`,{action:$a.VALUE_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(`value_diff`,{model:O.name,columns:e},{showForm:!0,trackProps:re})}})}}return E||(d.length>0&&d.push({label:`select group two`,isSeparator:!0}),d.push({label:`Select Parent Nodes`,itemIcon:G(Pi,{}),action:()=>{m?.(`lineage_selection`,{action:to.SELECT_PARENT_NODES}),w?.(i.id,1)}}),d.push({label:`Select Child Nodes`,itemIcon:G(Fi,{}),action:()=>{m?.(`lineage_selection`,{action:to.SELECT_CHILD_NODES}),ee?.(i.id,1)}}),d.push({label:`Select All Upstream Nodes`,itemIcon:G(Pi,{}),action:()=>{m?.(`lineage_selection`,{action:to.SELECT_ALL_UPSTREAM}),w?.(i.id)}}),d.push({label:`Select All Downstream Nodes`,itemIcon:G(Fi,{}),action:()=>{m?.(`lineage_selection`,{action:to.SELECT_ALL_DOWNSTREAM}),ee?.(i.id)}})),G(no,{x:n,y:r,menuItems:d,open:e,onClose:t,featureToggles:s,DisabledItemWrapper:y})},io=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},featureToggles:o={},serverFlags:s={},isActionAvailable:c=()=>!0})=>{let l=[],{runAction:u,onTrack:d,findByRunType:f,supportsHistogramDiff:p,DisabledItemWrapper:m}=a,h=s.single_env_onboarding??!1,g=o.disableDatabaseQuery??!1;if(i?.data===void 0)return G(W,{});let _=i.data,v=_.node,y=_.column,b=_.type,x={source:`lineage_column_node`},S=()=>{d?.(`explore_action`,{action:$a.PROFILE_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`profile_diff`,{model:v.name,columns:[y]},{showForm:!1,trackProps:x})},C=()=>{d?.(`explore_action`,{action:$a.HISTOGRAM_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`histogram_diff`,{model:v.name,column_name:y,column_type:b},{showForm:!1,trackProps:x})},w=()=>{d?.(`explore_action`,{action:$a.TOP_K_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`top_k_diff`,{model:v.name,column_name:y,k:50},{showForm:!1,trackProps:x})},ee=()=>{d?.(`explore_action`,{action:$a.VALUE_DIFF,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`value_diff`,{model:v.name,columns:[y]},{showForm:!0,trackProps:x})},T=v.data.base?.columns?.[y]===void 0||v.data.current?.columns?.[y]===void 0,E=f?.(h?`profile`:`profile_diff`);if(E&&l.push({label:E.title,itemIcon:G(q,{component:E.icon,sx:{display:`inline-flex`}}),action:S,isDisabled:T||!c(`profile_diff`)||g}),!h){let e=f?.(`histogram_diff`);if(e){let t=p?.(b)??!0;l.push({label:e.title,itemIcon:G(q,{component:e.icon,sx:{display:`inline-flex`}}),action:C,isDisabled:T||!t||g})}let t=f?.(`top_k_diff`);t&&l.push({label:t.title,itemIcon:G(q,{component:t.icon,sx:{display:`inline-flex`}}),action:w,isDisabled:T||g});let n=f?.(`value_diff`);n&&l.push({label:n.title,itemIcon:G(q,{component:n.icon,sx:{display:`inline-flex`}}),action:ee,isDisabled:T||g})}return G(no,{x:n,y:r,menuItems:l,open:e,onClose:t,featureToggles:o,DisabledItemWrapper:m})},ao=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>s.disableViewActionDropdown?G(no,{menuItems:[],open:e,onClose:t,x:n,y:r,featureToggles:s,DisabledItemWrapper:a.DisabledItemWrapper}):i&&de(i)?G(ro,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,viewOptions:o,featureToggles:s,serverFlags:c,noCatalogCurrent:l,isActionAvailable:u}):i&&ue(i)?G(io,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,featureToggles:s,serverFlags:c,isActionAvailable:u}):null,oo=()=>{let[e,t]=U(!1),n=()=>t(!0),r=()=>t(!1),[i,a]=U({x:0,y:0}),[o,s]=U();return{props:{x:i.x,y:i.y,node:o,isOpen:e,onClose:r},showContextMenu:(e,t,r)=>{a({x:e,y:t}),s(r),n()},closeContextMenu:()=>{a({x:0,y:0}),s(void 0),r()}}},so=()=>{let{isDark:e}=gt(),{successToast:t,failToast:n}=Vt();return yt({renderLibrary:`html-to-image`,imageType:`png`,shadowEffect:!0,backgroundColor:e?F.neutral[900]:F.neutral[50],ignoreElements:e=>{try{return e.classList.contains(lt)}catch{return e.className?e.className.includes(lt):!1}},onSuccess:()=>{t(`Copied the Lineage View as an image to clipboard`)},onError:e=>{console.error(`Error taking screenshot`,e),n(`Failed to copy image to clipboard`,e)}})},co=()=>{let e=hi(),{basePath:t}=pe();return V(n=>{n.check_id&&e.push(`${t}/checks/?id=${n.check_id}`)},[e.push,t])};function lo(){let[e,t]=U(()=>new Set),[n,r]=U(()=>new Set);return{impactedNodeIds:e,impactedColumnIds:n,publish:V(e=>{t(e.nodeIds),r(e.columnIds)},[])}}const uo=(e,t)=>{let n=Pn({width:0,height:0});jn(()=>{let r=e.current,i=new ResizeObserver(e=>{for(let r of e){let e=r.contentRect.width,i=r.contentRect.height;(Math.abs(i-n.current.height)>10||Math.abs(e-n.current.width)>10)&&n.current.height>0&&i>0&&n.current.width>0&&e>0&&t(),n.current={width:e,height:i}}});return r&&i.observe(r),()=>{r&&i.unobserve(r)}},[t,e])},fo=()=>V((e,t,n,r,i)=>{let a=e.filter(de),o=Object.groupBy(a,e=>e.data.changeStatus??`unchanged`),s=Object.fromEntries(Object.entries(o).map(([e,t])=>[`nodes_${e}`,t?.length??0])),c={node_count:a.length,view_mode:t,impact_radius_enabled:n,right_sidebar_open:i,...s};r&&(c.cll_column_active=!0),fn(c)},[]),po={row_count:en.ROW_COUNT,row_count_diff:en.ROW_COUNT_DIFF,value_diff:en.VALUE_DIFF},mo=e=>{let t=po[e.action];t&&sn({action:t,source:nn.LINEAGE_VIEW_TOP_BAR,node_count:e.node_count})},ho=(e,t)=>Ke(e,{...t,onTrackAction:mo,trackingSource:nn.LINEAGE_VIEW_TOP_BAR});function go(){return Mt({onConfirm:()=>cn({action:en.VALUE_DIFF,event:tn.EXECUTE}),onCancel:()=>cn({action:en.VALUE_DIFF,event:tn.CANCEL})})}function _o({notification:e,type:t}){let n=D.lineageNotificationDismissed,[r,i]=U(()=>sessionStorage.getItem(n)!==`true`);if(e===null||!r)return null;let a={info:`iochmara.light`,success:`success.light`,warning:`warning.light`,error:`error.light`}[t];return K(q,{sx:{width:`100%`,display:`flex`,flexDirection:`row`,p:`5px 10px`,gap:`5px`,alignItems:`flex-start`,borderRadius:1,boxShadow:4,border:`1px solid`,borderColor:`neutral.light`,bgcolor:a},children:[e,G(q,{sx:{flex:1}}),G(Z,{size:`small`,onClick:()=>{sessionStorage.setItem(n,`true`),i(!1)},children:G(qn,{})})]})}function vo(e,t,n,r){let{parent_map:i,child_map:a,columns:o}=e.current,s=new Map,c=new Set;function l(e,t){if(c.has(e))return;c.add(e);let n=o[e];if(n){let t=e.slice(0,-(n.name.length+1)),i=s.get(t)??[];i.push({column:n.name,isImpacted:r.has(e),transformationType:n.transformation_type,changeStatus:n.change_status}),s.set(t,i)}let i=t[e]??[];for(let e of i)l(e,t)}let u=`${t}_${n}`,d=o[u];if(d){let e=u.slice(0,-(d.name.length+1));s.set(e,[{column:d.name,isImpacted:r.has(u),transformationType:d.transformation_type,changeStatus:d.change_status}])}c.add(u);for(let e of i[u]??[])l(e,i);for(let e of a[u]??[])l(e,a);return s}function yo(e){let{columns:t,parent_map:n}=e.current,r=new Map;function i(e){let a=r.get(e);if(a===`pending`)return!1;if(a!==void 0)return a;if(r.set(e,`pending`),t[e]?.change_status)return r.set(e,!0),!0;let o=n[e]??[];for(let t of o)if(i(t))return r.set(e,!0),!0;return r.set(e,!1),!1}let a=new Set;for(let e of Object.keys(t))i(e)&&a.add(e);return a}function bo(e,t,n,r){if(n)return!0;if(!t)return!1;if(t.current.nodes[e]?.impacted)return!0;let i=r,a=`${e}_`;for(let e of i)if(e.startsWith(a))return!0;return!1}const xo=e=>{let{runAction:t}=me(),{setSqlQuery:n,setPrimaryKeys:r}=z(),i=hi(),{primaryKey:a}=_t(e),{basePath:o}=pe();return{runAction:(e,n,r)=>{t(e,n,r)},onNavigate:e=>{i.push(`${o}${e}`)},onTrack:(e,t)=>{e===`explore_action`?sn({action:t.action,source:eo.LINEAGE_VIEW_CONTEXT_MENU,node_count:t.node_count}):e===`lineage_selection`&&dn({action:t.action})},supportsHistogramDiff:pt,findByRunType:e=>{let t=B(e);return t?{title:t.title,icon:t.icon}:void 0},setSqlQuery:n,setPrimaryKeys:r,getPrimaryKey:()=>a,DisabledItemWrapper:$s}},So=({isOpen:e,onClose:t,x:n,y:r,node:i})=>{let{selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s,selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d}=fe(),{featureToggles:f}=Se(),{isActionAvailable:p,lineageGraph:m}=M(),{data:h}=be(),g=!m?.catalogMetadata.current;return G(ao,{x:n,y:r,node:i,isOpen:e,onClose:t,deps:xo(i?.type===`lineageGraphNode`?i.data?.name:i?.type===`lineageGraphColumnNode`?i.data?.node?.name:void 0),viewOptions:{selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d,selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s},featureToggles:{disableDatabaseQuery:f.disableDatabaseQuery,disableViewActionDropdown:f.disableViewActionDropdown,mode:f.mode??void 0},serverFlags:{single_env_onboarding:h?.single_env_onboarding},noCatalogCurrent:g,isActionAvailable:p})},Co=oo;function wo(e,t){let n=[],r=[],{selectedNodes:i,cll:a,existingPositions:o,newCllExperience:s,columnAncestry:c}=t??{},l={};function u(e){return e===`base`?0:e===`current`?2:1}function d(e,t){let n=u(e.data?.from),r=u(t.data?.from);return n<r?-1:n>r?1:0}let f=i===void 0?void 0:new Set(i),p=Object.values(e.nodes).sort(d);for(let e of p){if(f&&!f.has(e.id))continue;let t=new Set,i=0;if(a&&!s){let o=a.current?.parent_map[e.id]??new Set;for(let t of o){let n=t,i=e.id;r.push({id:`m2c_${n}_${i}`,source:n,target:i,style:{zIndex:9999}})}for(let o of Object.keys(e.data.data.current?.columns??{})){let s=`${e.id}_${o}`,c=a.current,l=c?.columns[s],u=c?.parent_map[s]??new Set;if(l!=null){n.push({id:s,position:{x:10,y:70+i*24},parentId:e.id,extent:`parent`,draggable:!1,className:`no-track-pii-safe`,data:{node:e.data,column:l.name,type:l.type,transformationType:l.transformation_type,changeStatus:l.change_status},style:{zIndex:9999},type:`lineageGraphColumnNode`,targetPosition:Mr.Left,sourcePosition:Mr.Right});for(let e of u){let t=e,n=s;r.push({id:`${t}_${n}`,source:t,target:n,style:{zIndex:9999}})}i++,t.add(l.name)}}}l[e.id]=t;let c=60;i>0&&(c+=20+i*24);let u=o?.get(e.id);n.unshift({id:e.id,position:u??{x:0,y:0},width:300,height:c,className:`no-track-pii-safe`,data:{...e.data},type:`lineageGraphNode`,targetPosition:Mr.Left,sourcePosition:Mr.Right,style:{width:300,height:c}})}let m=Object.values(e.edges).sort(d);for(let e of m)f&&(!f.has(e.source)||!f.has(e.target))||r.push({id:e.id,type:`lineageGraphEdge`,source:e.source,target:e.target,data:{...e.data}});return s&&c&&a&&To(n,r,c,a,f),n.some(e=>e.type===`lineageGraphNode`&&!o?.has(e.id))&&Eo(n,r),[n,r,l]}function To(e,t,n,r,i){let a=new Set,o=new Map;for(let[t,s]of n)if(!(i&&!i.has(t))){for(let n=0;n<s.length;n++){let i=s[n],c=`${t}_${i.column}`;a.add(c),o.set(c,{modelId:t,isImpacted:i.isImpacted});let l=r.current.columns[c];e.push({id:c,position:{x:10,y:64+n*24},parentId:t,draggable:!1,className:`no-track-pii-safe`,data:{node:{id:t},column:i.column,type:l?.type,transformationType:i.transformationType,changeStatus:i.changeStatus,isHighlighted:!0,isFocused:!1,isImpacted:i.isImpacted},style:{zIndex:9999},type:`lineageGraphColumnNode`,targetPosition:Mr.Left,sourcePosition:Mr.Right})}if(s.length>0){let n=e.find(e=>e.id===t&&e.type===`lineageGraphNode`);n&&(n.height=80+s.length*24)}}for(let e of a){let n=r.current.parent_map[e]??[];for(let r of n)if(a.has(r)){let n=o.get(r)?.isImpacted??!1;t.push({id:`ancestry_${r}_${e}`,source:r,target:e,style:{zIndex:9999,strokeWidth:2,stroke:n?Ge.impacted:Ge.unchanged}})}}}const Eo=(e,t,n=`LR`)=>{le(Ii,e,t,n)};function Do(){return K(q,{sx:{display:`flex`,gap:2,px:1,py:.5,fontSize:`0.75rem`,color:`text.secondary`},children:[K(`span`,{children:[G(`span`,{className:`schema-change-badge schema-change-badge-added`,children:`+`}),` `,`added`]}),K(`span`,{children:[G(`span`,{className:`schema-change-badge schema-change-badge-removed`,children:`-`}),` `,`removed`]}),K(`span`,{children:[G(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`}),` `,`changed`]})]})}function Oo({current:e,showMenu:t=!0},n){let r=ge(),[i,a]=U(null),[o,s]=U(new Map),{columns:c,rows:l}=H(()=>Dt({type:`schema_single`,columns:e?.columns},{node:e,cllRunningMap:o,showMenu:t}),[e,o,t]),{lineageGraph:u,isActionAvailable:d}=M(),f=d(`change_analysis`),p=!u?.catalogMetadata.current,m;p&&(m="catalog.json not found. Run `recce debug` to troubleshoot.");let h=e&&e.columns===void 0,g;h&&(g=`Node schema not found in catalog.json. Please regenerate your catalog.json to update.`);let _=async t=>{if(!f)return;rn({action:`view`,source:`schema_column`}),s(e=>new Map(e).set(t,!0));let n=e?.id;n&&await r?.showColumnLevelLineage({node_id:n,column:t}),s(e=>new Map(e).set(t,!1))},v=V(t=>`${e?.id}-${t.data.name}`,[e?.id]),y=r?.viewOptions.column_level_lineage,b=y?`${y.node_id}-${y.column}`:null;jn(()=>{if(i&&(i.deselectAll(),b)){let e=i.getRowNode(b);e&&e.setSelected(!0)}},[i,b]);let x=V(e=>{a(e.api)},[]);return K(q,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[m?G(Kr,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:m}):g?G(Kr,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:g}):G(W,{}),l.length>0&&G(it,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`10pt`,borderWidth:1},columns:c,rows:l,renderers:{noRowsFallback:G(It,{})},ref:n,getRowId:v,getRowClass:e=>r!==void 0&&f?`row-normal row-selectable`:`row-normal`,onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&await _(t.name)},onGridReady:x,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}function ko({base:e,current:t,showMenu:n=!0,columnChanges:r,onViewCode:i},a){let o=ge(),{data:s}=be(),c=s?.new_cll_experience??!1,[l,u]=U(null),[d,f]=U(new Map),p=H(()=>{if(!c)return;let e=o?.impactedColumnIds;return e?.size?e:void 0},[c,o?.impactedColumnIds]),{columns:m,rows:h}=H(()=>{let a=t?.resource_type??e?.resource_type,o=a&&[`model`,`seed`,`snapshot`,`source`].includes(a)?t??e:void 0,s=t?.id??e?.id;return Dt({type:`schema_diff`,base:e?.columns,current:t?.columns},{node:o,cllRunningMap:d,showMenu:n,columnChanges:r,onViewCode:i,impactedColumns:p,nodeId:s})},[e,t,d,n,r,i,p]),{lineageGraph:g,isActionAvailable:_}=M(),v=_(`change_analysis`),y=!g?.catalogMetadata.base,b=!g?.catalogMetadata.current,x;y&&b?x="catalog.json not found on both environments. Run `recce debug` to troubleshoot.":y?x="catalog.json not found on base environment. Run `recce debug` to troubleshoot.":b&&(x="catalog.json not found on current environment. Run `recce debug` to troubleshoot.");let S=e&&e.columns===void 0,C=t&&t.columns===void 0,w;S&&C?w=`Node schema not found in catalog.json on both environments. Please regenerate your catalog.json to update.`:C?w=`Node schema not found in catalog.json on current environment. Please regenerate your catalog.json to update.`:S&&(w=`Node schema not found in catalog.json on base environment. Please regenerate your catalog.json to update.`);let ee=async n=>{if(!v)return;rn({action:`view`,source:`schema_column`}),f(e=>new Map(e).set(n,!0));let r=t?.id??e?.id;r&&await o?.showColumnLevelLineage({node_id:r,column:n}),f(e=>new Map(e).set(n,!1))},T=V(n=>`${t?.id??e?.id}-${n.data.name}`,[t?.id,e?.id]),E=o?.viewOptions.column_level_lineage,D=E?`${E.node_id}-${E.column}`:null;jn(()=>{if(l&&(l.deselectAll(),D)){let e=l.getRowNode(D);e&&e.setSelected(!0)}},[l,D]);let O=V(e=>{u(e.api)},[]);return K(q,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[x?G(Kr,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:x}):w?G(Kr,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:w}):G(W,{}),G(Do,{}),h.length>0&&G(it,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`0.8rem`,borderWidth:1},columns:m,rows:h,rowHeight:35,renderers:{noRowsFallback:G(It,{})},className:`rdg-light no-track-pii-safe${c?` cll-experience`:``}`,ref:a,getRowId:T,getRowClass:e=>{let t=e.data;if(!t)return`row-normal`;let n;if(t.baseIndex===void 0)n=`row-added`;else if(t.currentIndex===void 0)return`row-removed`;else n=t.baseType!==t.currentType||t.reordered===!0||t.definitionChanged===!0?`row-changed`:t.isImpacted?`row-impacted`:`row-normal`;return o!==void 0&&v&&(n+=` row-selectable`),n},onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&(t.baseIndex!==void 0&&t.currentIndex===void 0||await ee(t.name))},onGridReady:O,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}const Ao=On(ko),jo=On(Oo),Mo=({node:e,isSingleEnv:t,CodeEditor:n,DiffEditor:r,isDark:i=!1})=>{let[a,o]=U(!1),[s,c]=U(!1);if(e.data.resourceType!==`model`&&e.data.resourceType!==`snapshot`)return`Not available`;let l=e.data.data.base?.raw_code,u=e.data.data.current?.raw_code,d=e.data.data.base?.name??e.data.data.current?.name??``;return K(q,{className:`no-track-pii-safe`,sx:{position:`relative`,height:`100%`},onMouseEnter:()=>{c(!0)},onMouseLeave:()=>{c(!1)},children:[t?G(n,{language:`sql`,value:l??``,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):G(r,{original:l??``,modified:u??``,language:`sql`,readOnly:!0,lineNumbers:!0,sideBySide:!1,theme:i?`dark`:`light`,height:`100%`}),G(Z,{onClick:()=>o(!0),size:`medium`,"aria-label":`Expand`,sx:{position:`absolute`,top:`5px`,right:`20px`,opacity:s?.5:.1,transition:`opacity 0.3s ease-in-out`},children:G($n,{})}),K(Fn,{open:a,onClose:()=>o(!1),maxWidth:`sm`,fullWidth:!0,slotProps:{paper:{sx:{height:`75%`,overflowY:`auto`}}},children:[K(Rn,{sx:{display:`flex`,alignItems:`center`},children:[t?K(W,{children:[G(`code`,{children:d}),`\xA0Model Code`]}):K(W,{children:[G(`code`,{children:d}),`\xA0Model Code Diff`]}),G(q,{sx:{flex:1}}),G(Z,{size:`small`,onClick:()=>o(!1),children:G(qn,{})})]}),G(Ln,{children:t?G(n,{language:`sql`,value:l??``,fontSize:16,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):G(r,{original:l??``,modified:u??``,language:`sql`,theme:i?`dark`:`light`,className:`text-base`})})]})]})},No=({node:e})=>{let{data:t,isLoading:n}=be(),r=Rt();return n?G(W,{}):G(Mo,{node:e,isSingleEnv:t?.single_env_onboarding??!1,CodeEditor:Me,DiffEditor:tt,isDark:r})};function Po({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} rows`,i=e.curr===null?`N/A`:`${e.curr} rows`;return t===null&&n===null?G(W,{children:` Failed to load`}):t===null||n===null?K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(X,{variant:`body2`,component:`span`,children:r}),G(Si,{}),G(X,{variant:`body2`,component:`span`,children:i})]}):t===n?K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(X,{variant:`body2`,component:`span`,children:i}),G(q,{component:`span`,sx:{color:`grey.500`,display:`flex`},children:G(Ai,{})}),G(X,{variant:`body2`,component:`span`,sx:{color:`grey.500`},children:`No Change`})]}):t<n?K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(X,{variant:`body2`,component:`span`,children:i}),G(q,{component:`span`,sx:{color:`success.main`,display:`flex`},children:G(Oi,{})}),G(X,{variant:`body2`,component:`span`,sx:{color:`success.main`},children:Wt(t,n)})]}):K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(X,{variant:`body2`,component:`span`,children:i}),G(q,{component:`span`,sx:{color:`error.main`,display:`flex`},children:G(Di,{})}),G(X,{variant:`body2`,component:`span`,sx:{color:`error.main`},children:Wt(t,n)})]})}function Fo({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Rt(),{featureToggles:a}=Se(),{runsAggregated:o}=M(),s=o?.[t.id]?.row_count_diff.result,c=B(`row_count_diff`).icon,l=e??s,u=l;return G(Q,{title:l?`${l.base??`N/A`} -> ${l.curr??`N/A`} rows`:``,children:G($s,{display:a.mode===`metadata only`,children:K(q,{component:`span`,sx:{...ut(i),gap:.5},children:[G(c,{}),u!=null||r?r?G(Li,{width:30,height:16}):u==null?G(X,{variant:`caption`,children:`row count`}):G(Po,{rowCount:u}):G(X,{variant:`caption`,children:`row count`}),n&&G(Z,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:a.disableDatabaseQuery,sx:{p:0,ml:.5},children:G(yr,{size:12})})]})})})}function Io({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Rt(),{runsAggregated:a}=M(),o=a?.[t.id]?.row_count.result,s=B(`row_count`).icon,c,l=e??o;return l&&(c=`${l.curr??`N/A`} rows`),K(q,{component:`span`,sx:ut(i),children:[G(q,{component:`span`,sx:nt,children:G(s,{})}),l||r?r?G(Li,{width:30,height:16}):G(X,{variant:`caption`,children:c}):G(X,{variant:`caption`,children:`row count`}),n&&G(Z,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:t.data.from===`base`,sx:{p:0,ml:.5},children:G(yr,{size:12})})]})}function Lo({children:e,value:t,index:n}){return t===n?G(W,{children:e}):null}const Ro=()=>G(`span`,{}),zo=({children:e})=>G(W,{children:e}),Bo=()=>!0;function Vo(e,t,n){return e?bn.add_or_remove:n(t)?``:`This action is not supported yet.`}function Ho({node:e,actionCallbacks:t,runTypeIcons:n,isActionAvailable:r}){let i=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,a=n?.query??Ro,o=n?.row_count??Ro,s=n?.profile??Ro;return K(Y,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,children:[G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(a,{fontSize:`small`}),onClick:t?.onQueryClick,sx:{textTransform:`none`},children:`Query`}),G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(o,{fontSize:`small`}),onClick:t?.onRowCountClick,sx:{textTransform:`none`},children:`Row Count`}),G(Q,{title:Vo(i,`profile`,r),placement:`top`,children:G(`span`,{children:G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(s,{fontSize:`small`}),onClick:t?.onProfileClick,disabled:i,sx:{textTransform:`none`},children:`Profile`})})})]})}function Uo({actionCallbacks:e,runTypeIcons:t,featureToggles:n,ConnectionPopoverWrapper:r}){let i=n?.mode===`metadata only`,a=t?.schema_diff??Ro,o=t?.sandbox??Ro;return K(Y,{direction:`row`,alignItems:`center`,sx:{mr:1},flexWrap:`wrap`,gap:1,children:[G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(a,{fontSize:`small`}),onClick:e?.onAddSchemaDiffClick,sx:{textTransform:`none`},children:`Add schema diff to checklist`}),G(r,{display:i,children:G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(o,{fontSize:`small`}),onClick:e?.onSandboxClick,disabled:n?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Sandbox`})})]})}function Wo({node:e,actionCallbacks:t,runTypeIcons:n,featureToggles:r,isActionAvailable:i,ConnectionPopoverWrapper:a}){let o=r?.mode===`metadata only`,s=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,c=n?.query_diff??Ro,l=n?.row_count_diff??Ro,u=n?.profile_diff??Ro,d=n?.value_diff??Ro,f=n?.top_k_diff??Ro,p=n?.histogram_diff??Ro,m=(e,t)=>o?G(a,{display:!0,children:e}):G(Q,{title:Vo(s,t,i),placement:`top`,children:G(`span`,{children:e})});return K(Y,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:2,children:[G(X,{variant:`caption`,fontWeight:`bold`,children:`Diff`}),K(Y,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,width:`93%`,children:[G(a,{display:o,children:G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(l,{fontSize:`small`}),onClick:t?.onRowCountDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Row Count`})}),m(G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(u,{fontSize:`small`}),onClick:t?.onProfileDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Profile`}),`profile_diff`),m(G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(d,{fontSize:`small`}),onClick:t?.onValueDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Value`}),`value_diff`),m(G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(f,{fontSize:`small`}),onClick:t?.onTopKDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Top-K`}),`top_k_diff`),m(G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(p,{fontSize:`small`}),onClick:t?.onHistogramDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Histogram`}),`histogram_diff`),G(a,{display:o,children:G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(c,{fontSize:`small`}),onClick:t?.onQueryDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Query`})})]})]})}function Go({node:e,onCloseNode:t,isSingleEnv:n,featureToggles:r,SchemaView:i,SingleEnvSchemaView:a,NodeSqlView:o,RowCountDiffTag:s,RowCountTag:c,ResourceTypeTag:l,NotificationComponent:u,ConnectionPopoverWrapper:d=zo,SandboxDialog:f,runTypeIcons:p,actionCallbacks:m,isActionAvailable:h=Bo}){let g=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`,[_,v]=U(!1),[y,b]=U(!0),[x,S]=U(0),{base:C,current:w}=e.data.data,ee=!n&&Gt(C?.columns,w?.columns)===!0,T=!n&&C?.raw_code!=null&&w?.raw_code!=null&&C.raw_code!==w.raw_code,E=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`snapshot`,D={...m,onSandboxClick:()=>{m?.onSandboxClick?.(),v(!0)}};return K(q,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[K(Y,{direction:`row`,alignItems:`center`,children:[G(q,{sx:{flex:`0 1 20%`,p:2},children:G(X,{variant:`subtitle1`,fontWeight:600,className:`no-track-pii-safe`,children:e.data.name})}),G(q,{sx:{flexGrow:1}}),!n&&E&&G(Uo,{node:e,actionCallbacks:D,runTypeIcons:p,featureToggles:r,ConnectionPopoverWrapper:d}),G(q,{sx:{flex:`0 1 1%`},children:G(Z,{size:`small`,onClick:t,children:G(qn,{})})})]}),G(q,{sx:{color:`text.secondary`,pl:2},children:K(Y,{direction:`row`,spacing:1,children:[l&&G(l,{node:e}),E&&(n?c&&G(c,{node:e,onRefresh:m?.onRowCountClick}):s&&G(s,{node:e,onRefresh:m?.onRowCountDiffClick}))]})}),E&&G(q,{sx:{pl:2,py:1},children:n?G(Ho,{node:e,actionCallbacks:m,runTypeIcons:p,isActionAvailable:h}):G(Wo,{node:e,actionCallbacks:D,runTypeIcons:p,featureToggles:r,isActionAvailable:h,ConnectionPopoverWrapper:d})}),g&&K(q,{sx:{overflow:`auto`,display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[n&&y&&u&&G(q,{sx:{p:1.5},children:G(u,{onClose:()=>b(!1),children:G(X,{variant:`body2`,children:`Enable the Recce Checklist and start adding checks for better data validation and review.`})})}),K(si,{value:x,onChange:(e,t)=>S(t),sx:{borderBottom:1,borderColor:`divider`},children:[G(oi,{label:K(q,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Columns`,ee&&G(q,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})}),G(oi,{label:K(q,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Code`,T&&G(q,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})})]}),K(q,{sx:{overflow:`auto`,height:`calc(100% - 48px)`},children:[G(Lo,{value:x,index:0,children:G(q,{sx:{overflowY:`auto`,height:`100%`},children:n?a&&G(a,{current:e.data.data.current}):i&&G(i,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,onViewCode:()=>S(1)})})}),G(Lo,{value:x,index:1,children:G(q,{sx:{height:`100%`},children:o&&G(o,{node:e})})})]})]}),f&&G(f,{isOpen:_,onClose:()=>v(!1),current:e.data.data.current})]})}function Ko(e){return ri(ai(e),`yyyy-MM-dd'T'HH:mm:ss`)}function qo({current:e,primaryKeys:t,onPrimaryKeysChange:n,onRunResultOpen:r,runQuery:i,isPending:a,QueryForm:o}){return K(Y,{direction:`row`,justifyContent:`flex-end`,alignItems:`center`,sx:{p:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderBottomColor:`divider`,flex:`0 0 54px`},children:[K(q,{children:[K(X,{variant:`h6`,component:`h2`,sx:{display:`flex`,alignItems:`center`,gap:`5px`},children:[G(q,{component:Ri,sx:{fontSize:`1.2em`}}),`Sandbox`]}),K(X,{sx:{fontSize:`0.75rem`,color:`grey.500`},children:[`Compare the run results based on the modified SQL code of model`,` `,G(`b`,{children:e?.name})]})]}),G(q,{sx:{flexGrow:1}}),G(o,{defaultPrimaryKeys:t,onPrimaryKeysChange:n}),G(Q,{title:`Run diff to see the changes`,children:G(J,{size:`small`,sx:{mt:`16px`,fontSize:`14px`},onClick:()=>{r(),i()},color:`iochmara`,variant:`contained`,disabled:a,children:a?`Running...`:`Run Diff`})})]})}function Jo({currentModelID:e,height:t=`32px`,flex:n=`0 0 auto`,isDark:r=!1}){let{lineageGraph:i,envInfo:a}=M(),o=`0 16px`,s=ii(Ko(a?.dbt?.current?.generated_at??``),{addSuffix:!0}),c=`N/A`;if(i?.nodes[e]){let t=i.nodes[e];t.data.data.current?.schema&&(c=t.data.data.current.schema)}return K(Y,{direction:`row`,sx:{gap:0,height:t,flex:n,fontSize:`14px`,alignItems:`center`,m:0,bgcolor:Hn(r?F.neutral[700]:F.neutral[100],.5)},children:[G(Y,{sx:{width:`50%`},children:K(X,{sx:{fontWeight:`bold`,margin:o},children:[`ORIGINAL (Schema: `,c,`, Last Updated: `,s,`)`]})}),G(Y,{sx:{width:`50%`},children:G(X,{sx:{fontWeight:`bold`,margin:o},children:`SANDBOX EDITOR`})})]})}function Yo({current:e,onChange:t,isDark:n,DiffEditor:r}){return G(r,{original:e?.raw_code??``,modified:e?.raw_code??``,language:`sql`,readOnly:!1,lineNumbers:!0,sideBySide:!0,theme:n?`dark`:`light`,height:`100%`,onModifiedChange:t})}function Xo({isOpen:e,onClose:t,current:n,DiffEditor:r,QueryForm:i,RunResultPane:a,isDark:o=!1,primaryKeys:s=[],onPrimaryKeysChange:c,isPending:l=!1,onRunQuery:u,onRunResultOpen:d,onModifiedCodeChange:f,onShowFeedback:p,tracking:m,logoUrl:h=`/logo/recce-logo-white.png`,brandName:g=`RECCE`}){let[_,v]=U(!1),y=e=>{f?.(e)},b=()=>{v(!0),d?.()},x=()=>{u?.()},S=()=>{t(),v(!1),m?.onPreviewChange?.({action:`close`,node:n?.name})},C=e=>{c?.(e)};return K(Fn,{open:e,onClose:S,maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:`100%`,height:`100%`,maxWidth:`100%`,maxHeight:`100%`,m:0}}},children:[K(q,{sx:{height:`40px`,bgcolor:`cyan.600`,px:0,py:2,display:`flex`,alignItems:`center`},children:[K(Y,{direction:`row`,alignItems:`center`,sx:{height:`100%`,gap:`10px`},children:[G(q,{component:`img`,sx:{width:`20px`,height:`20px`,ml:`18px`},src:h,alt:`logo`}),G(X,{variant:`h6`,component:`h1`,sx:{fontFamily:`"Montserrat", sans-serif`,fontSize:`1.125rem`,color:`common.white`},children:g}),G(wr,{label:`Experiment`,size:`small`,variant:`outlined`,sx:{fontSize:`0.875rem`,color:`common.white`,borderColor:`rgba(255,255,255,0.5)`}})]}),G(Z,{"aria-label":`close`,onClick:S,sx:{position:`absolute`,right:8,top:4,color:`common.white`},children:G(qn,{})})]}),G(Ln,{sx:{p:0},children:K(kt,{sizes:_?[50,50]:[100,0],minSize:0,gutterSize:5,className:_?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`,height:`100%`},children:[K(Y,{sx:{height:`100%`,m:0,p:0},children:[G(qo,{current:n,primaryKeys:s,onPrimaryKeysChange:C,onRunResultOpen:b,runQuery:x,isPending:l,QueryForm:i}),G(Jo,{height:`32px`,flex:`0 0 auto`,currentModelID:n?.id??``,isDark:o}),G(Yo,{current:n,onChange:y,isDark:o,DiffEditor:r})]}),_?G(a,{onClose:()=>v(!1),disableAddToChecklist:!0}):G(q,{})]})}),G(q,{sx:{position:`fixed`,bottom:16,right:16,opacity:.5},children:G(Q,{title:`Give us feedback`,children:G(Z,{"aria-label":`feedback`,size:`medium`,onClick:()=>{p?.()},children:G(Zr,{})})})})]})}function Zo({isOpen:e,onClose:t,current:n}){let[r,i]=U(n?.raw_code??``),[o,s]=U(e),{showRunId:c,clearRunResult:l}=me(),{primaryKeys:u,setPrimaryKeys:d}=z(),{data:f,isLoading:m}=be(),{apiClient:h}=Ne(),_=Rt();e!==o&&(s(e),e&&i(n?.raw_code??``));let{mutate:v,isPending:y}=Cn({mutationFn:async()=>{let e=r,{run_id:t}=await a({current_model:n?.name??``,primary_keys:u,sql_template:e},{nowait:!0},h);return c(t),await g(t,void 0,h)},onSuccess(e){e.error?hn({action:`run`,node:n?.name,status:`failure`}):(hn({action:`run`,node:n?.name,status:`success`}),setTimeout(()=>{b()},1e3),!m&&f?.single_env_onboarding&&setTimeout(()=>{S()},2e3))}}),{feedbackToast:b,closeToast:x}=at({feedbackId:p.previewChangeFeedbackID,description:`Enjoy preview change?`,onFeedbackSubmit:e=>{switch(e){case`like`:gn({feedback:`like`,node:n?.name});break;case`dislike`:gn({feedback:`dislike`,node:n?.name});break;case`link`:gn({feedback:`form`,node:n?.name});break;default:console.log(`Not support feedback type`)}},externalLink:`https://docs.google.com/forms/d/e/1FAIpQLSd7Lei7Ijwo7MinWaI0K6rzZi_21gV1BKetmiNEX254kDziDA/viewform?usp=header`,externalLinkText:`Give us feedback`}),{guideToast:S,closeGuideToast:C}=Ct({guideId:p.prepareEnvGuideID,description:`Want to compare data changes with production data?`,externalLink:`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,externalLinkText:`Learn how.`,onExternalLinkClick:()=>{vn({action:`external_link`,from:`preview_changes`,node:n?.name})}});return G(Xo,{isOpen:e,onClose:()=>{t(),l(),x(),C()},current:n,DiffEditor:tt,QueryForm:Ba,RunResultPane:Be,isDark:_,primaryKeys:u??[],onPrimaryKeysChange:d,isPending:y,onRunQuery:v,onModifiedCodeChange:i,onShowFeedback:()=>b(!0),tracking:{onPreviewChange:hn}})}const Qo=({node:e})=>{let t=e.data.data.current?.config?.materialized??e.data.data.base?.config?.materialized;return G(St,{resourceType:e.data.resourceType,materialized:t})};function $o({onClose:e}){return G(ze,{onClose:e,align:`flex-start`,children:K(X,{variant:`body2`,children:[`Enable the Recce Checklist and start adding checks for better data validation and review.`,G(`br`,{}),G(dt,{})]})})}function es({node:e,onCloseNode:t}){let n=hi(),{runAction:r}=me(),{isActionAvailable:i,envInfo:a}=M(),{singleEnv:o,featureToggles:s}=Se(),{setSqlQuery:c,setPrimaryKeys:l}=z(),{primaryKey:u}=_t(e.data.name),{apiClient:d}=Ne(),{basePath:f}=pe(),p=H(()=>({query:B(`query`).icon,row_count:B(`row_count`).icon,row_count_diff:B(`row_count_diff`).icon,profile:B(`profile`).icon,profile_diff:B(`profile_diff`).icon,query_diff:B(`query_diff`).icon,value_diff:B(`value_diff`).icon,top_k_diff:B(`top_k_diff`).icon,histogram_diff:B(`histogram_diff`).icon,schema_diff:B(`schema_diff`).icon,sandbox:B(`sandbox`).icon}),[]),m=Kt(Object.keys(e.data.data.base?.columns??{}),Object.keys(e.data.data.current?.columns??{})),h=H(()=>m.length?`select \n ${m.join(`
6
+ `)}\nfrom {{ ref("${e.data.name}") }}`:`select * from {{ ref("${e.data.name}") }}`,[m,e.data.name]),g=H(()=>({onQueryClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),n.push(`${f}/query`)},onRowCountClick:()=>{sn({action:en.ROW_COUNT,source:nn.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onRowCountDiffClick:()=>{sn({action:en.ROW_COUNT_DIFF,source:nn.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count_diff`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onProfileClick:()=>{sn({action:en.PROFILE,source:nn.NODE_SIDEBAR_SINGLE_ENV,node_count:1}),r(`profile`,{model:e.data.name},{showForm:!0,showLast:!1})},onProfileDiffClick:()=>{sn({action:en.PROFILE_DIFF,source:nn.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`profile_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onQueryDiffClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),n.push(`${f}/query`)},onValueDiffClick:()=>{sn({action:en.VALUE_DIFF,source:nn.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`value_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onTopKDiffClick:()=>{sn({action:en.TOP_K_DIFF,source:nn.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`top_k_diff`,{model:e.data.name,column_name:``,k:50},{showForm:!0})},onHistogramDiffClick:()=>{sn({action:en.HISTOGRAM_DIFF,source:nn.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`histogram_diff`,{model:e.data.name,column_name:``,column_type:``},{showForm:!0})},onAddSchemaDiffClick:async()=>{let t=await v({node_id:e.id},d);n.push(`${f}/checks/?id=${t.check_id}`)},onSandboxClick:()=>{i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),hn({action:`explore`,node:e.data.name})}}),[e,h,a,c,r,i,l,u,d,n.push,f]);return G(Go,{node:e,onCloseNode:t,isSingleEnv:o??!1,featureToggles:s,SchemaView:Ao,SingleEnvSchemaView:jo,NodeSqlView:No,ResourceTypeTag:Qo,RowCountDiffTag:Fo,RowCountTag:Io,NotificationComponent:$o,ConnectionPopoverWrapper:$s,SandboxDialog:Zo,runTypeIcons:p,actionCallbacks:g,isActionAvailable:i})}function ts(e,t){let n={...e};for(let[e,r]of Object.entries(t.current.nodes)){if(!r.change_status)continue;let t=null;if(r.columns){let e={},n=!1;for(let t of Object.values(r.columns))t.change_status&&(e[t.name]=t.change_status,n=!0);n&&(t=e)}n[e]={change_status:r.change_status,change:r.change_category?{category:r.change_category,columns:t}:null}}return n}function ns({featureToggles:e,settingsUrl:t}){return e.mode===`metadata only`?G(q,{sx:{display:`flex`,alignItems:`center`,width:`100%`,px:1,py:.25,bgcolor:`cyan.50`},children:K(Y,{direction:`row`,alignItems:`center`,sx:{flex:1,fontSize:`0.875rem`,color:`cyan.600`},spacing:1,children:[G(q,{component:fr}),G(X,{sx:{fontSize:`inherit`,color:`inherit`},children:`Query functions disabled without a data warehouse connection.`}),G(J,{sx:{bgcolor:`iochmara.400`},size:`small`,variant:`contained`,onClick:()=>{window.open(t,`_blank`)},children:`Connect to Data Warehouse`})]})}):null}function rs(e){let{featureToggles:t}=Se(),{data:n}=ce();return G(ns,{featureToggles:e.featureToggles??t,settingsUrl:e.settingsUrl??Yt(n,$t)})}function is({docsUrl:e=`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,onStartClick:t}={}){return G(Y,{sx:{flex:1,height:`100%`,minHeight:0,m:1,p:2,bgcolor:`iochmara.50`,borderRadius:2,boxShadow:2,justifyContent:`center`},children:K(Y,{sx:{width:`80%`,overflowY:`auto`,gap:3,px:4,pb:4},alignSelf:`center`,children:[K(Y,{alignItems:`center`,spacing:2,children:[G(q,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:G(q,{component:ji,sx:{fontSize:28,color:`iochmara.500`}})}),G(X,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),K(X,{sx:{textAlign:`center`},children:[`Recce is currently running in`,` `,G(X,{component:`span`,sx:{fontWeight:`bold`},children:`limited functionality mode`}),` `,`so you can run queries but`,` `,G(X,{component:`span`,sx:{fontWeight:`bold`},children:`can't diff the results yet!`})]})]}),K(Y,{spacing:1,children:[G(X,{children:`To unlock the full power of Recce, set up a base environment of dbt artifacts for comparison.`}),G(X,{children:`Once configured, you'll be able to:`}),K(ci,{sx:{listStyleType:`disc`,pl:2},children:[G(li,{sx:{display:`list-item`,p:0},children:G(X,{children:`Run statistical data diffs`})}),G(li,{sx:{display:`list-item`,p:0},children:G(X,{children:`Run query diffs`})}),G(li,{sx:{display:`list-item`,p:0},children:G(X,{children:`Save checks to your Recce Checklist`})}),G(li,{sx:{display:`list-item`,p:0},children:G(X,{children:`...and more!`})})]}),G(X,{children:`Take the next step toward better data impact assessment.`})]}),G(Y,{sx:{width:`100%`,mt:3},children:G(J,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{t?t():window.open(e,`_blank`)},children:`Start Now`})})]})})}function as({docsUrl:e=`https://docs.reccehq.com/configure-diff/`}={}){return K(Y,{direction:`row`,spacing:`10px`,alignItems:`flex-start`,children:[G(q,{component:ki,sx:{color:`iochmara.main`,fontSize:20}}),K(Y,{spacing:`5px`,children:[K(X,{sx:{fontWeight:700},children:[`Single Environment Mode`,` `,G(X,{component:`span`,sx:{color:`error.main`,fontWeight:600},children:`Limited Functionality`})]}),G(X,{sx:{fontSize:`0.875rem`},children:`Single Environment Mode allows you to explore your dbt project but won't show data comparisons between environments.`}),G(X,{sx:{fontSize:`0.875rem`},children:`To set up full environment comparison:`}),K(ci,{sx:{pl:2},children:[G(li,{sx:{p:0,display:`list-item`},children:G(X,{sx:{fontSize:`0.875rem`},children:"Run `recce debug` for setup assistance"})}),G(li,{sx:{p:0,display:`list-item`},children:K(X,{sx:{fontSize:`0.875rem`},children:[`Visit`,` `,G(zn,{sx:{color:`primary.main`,fontWeight:500},target:`_blank`,href:e,children:`docs`}),` `,`for configuration details`]})})]})]})]})}function os(){return G(q,{sx:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(Zn,{size:48})})}function ss({error:e,onRetry:t}){return G(q,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:K(Y,{alignItems:`center`,spacing:1,children:[G(q,{children:`Failed to load lineage data. This could be because the server has been terminated or there is a network error.`}),K(q,{children:[`[Reason: `,e,`]`]}),G(J,{color:`iochmara`,variant:`contained`,onClick:()=>{t&&t()},children:`Retry`})]})})}function cs({viewOptions:e,onViewOptionsChanged:t}){return G(q,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:K(Y,{alignItems:`center`,spacing:1,children:[G(W,{children:`No change detected`}),G(J,{color:`iochmara`,variant:`contained`,onClick:async()=>{await t({...e,view_mode:`all`})},children:`Show all nodes`})]})})}function ls(){let{isHistoryOpen:e,showHistory:t}=me();if(!e)return K(q,{children:[G(q,{sx:{fontSize:`8pt`},children:`History`}),G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G($r,{}),onClick:()=>{ln({name:e?`hide`:`show`}),t()},children:`Show`})]})}const us=e=>({fontSize:`8pt`,bgcolor:e?`grey.700`:`grey.100`,px:.5,borderRadius:1}),ds=()=>{let e=us(Rt());return K(Y,{alignItems:`flex-start`,spacing:0,children:[G(X,{fontSize:`10pt`,color:`text.secondary`,pb:1,children:`Select nodes by dbt node selector syntax`}),K(X,{fontSize:`8pt`,children:[G(q,{component:`code`,sx:e,children:`model_name`}),` `,`Select a node`]}),K(X,{fontSize:`8pt`,children:[G(q,{component:`code`,sx:e,children:`model_name+`}),` `,`Select downstream nodes`]}),K(X,{fontSize:`8pt`,children:[G(q,{component:`code`,sx:e,children:`+model_name`}),` `,`Select upstream nodes`]}),K(X,{fontSize:`8pt`,children:[G(q,{component:`code`,sx:e,children:`model*`}),` `,`Select by wildcard`]})]})},fs=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>{let[r,i]=U(null),a=!!r,o=t.view_mode??`changed_models`,s=o===`changed_models`?`Changed Models`:`All`,c=e=>{i(e.currentTarget)},l=()=>{i(null)},u=e=>{n({...t,view_mode:e}),l()},d=Nt(`model`).icon;return K(W,{children:[G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:c,disabled:e,startIcon:d&&G(d,{}),endIcon:G(or,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:s}),K(qr,{anchorEl:r,open:a,onClose:l,children:[G(ti,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`mode`}),K(Bi,{value:o,children:[G(Jr,{onClick:()=>u(`changed_models`),children:G(Ur,{value:`changed_models`,control:G(zi,{size:`small`,sx:{py:0}}),label:`Changed Models`,sx:{m:0}})}),G(Jr,{onClick:()=>u(`all`),children:G(Ur,{value:`all`,control:G(zi,{size:`small`,sx:{py:0}}),label:`All`,sx:{m:0}})})]})]})]})},ps=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,lineageGraph:r})=>{let[i,a]=U(null),o=!!i,s=new Set,c=Object.values(r?.nodes??{});for(let e of c)e.data.packageName&&s.add(e.data.packageName);let l=r?.manifestMetadata.current?.project_name,u=t.packages?new Set(t.packages):l?new Set([l]):s,d=u.size===s.size,f=u.size===0,p=u.size===1?Array.from(u)[0]:d?`All Packages`:f?`No Package`:`${u.size} Packages`,m=e=>{a(e.currentTarget)},h=()=>{a(null)},g=()=>{n(d?{...t,packages:[]}:{...t,packages:Array.from(s)})},_=e=>{let r=new Set(u);r.has(e)?r.delete(e):r.add(e),n({...t,packages:Array.from(r)})};return K(W,{children:[G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:m,disabled:e,startIcon:G(Ti,{}),endIcon:G(or,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:p}),K(qr,{anchorEl:i,open:o,onClose:h,children:[G(ti,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Select Packages`}),K(Jr,{onClick:g,children:[G(Hr,{checked:d,indeterminate:!d&&!f,size:`small`,sx:{py:0}}),G(xi,{children:`Select All`})]}),G(Xn,{}),Array.from(s).map(e=>K(Jr,{onClick:()=>_(e),children:[G(Hr,{checked:u.has(e),size:`small`,sx:{py:0}}),G(xi,{className:`no-track-pii-safe`,children:e})]},e))]})]})},ms=({value:e,onChange:t,isDisabled:n,tooltipComponent:r,showTooltip:i=!0})=>{let[a,o]=U(e),s=Pn(null);return jn(()=>{s.current&&(s.current.value=e)},[e]),G(Q,{title:i?r:``,placement:`bottom-start`,slotProps:{tooltip:{sx:{width:`18.75rem`,p:2,boxShadow:3,border:1,borderRadius:1,color:`text.primary`,bgcolor:`background.paper`}}},children:G(ni,{inputRef:s,size:`small`,placeholder:`with selectors`,disabled:n,value:a,onChange:e=>{o(e.target.value)},onKeyUp:n=>{n.key===`Enter`?t(a):n.key===`Escape`&&(n.preventDefault(),o(e),s.current&&s.current.blur())},onBlur:()=>{o(e)},sx:{"& .MuiInputBase-root":{width:`18.75rem`,height:24,fontSize:`0.75rem`},"& .MuiInputBase-input":{py:.5,px:1}}})})},hs=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,showTooltip:r})=>G(ms,{isDisabled:e,value:t.select??``,onChange:e=>{n({...t,select:e||void 0})},tooltipComponent:G(ds,{}),showTooltip:r}),gs=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>G(ms,{isDisabled:e,value:t.exclude??``,onChange:e=>{n({...t,exclude:e||void 0})}}),_s=({label:e,children:t,style:n})=>K(q,{style:n,sx:{maxWidth:300},children:[G(X,{fontSize:`8pt`,children:(e??``).trim()||G(W,{children:`\xA0`})}),t]}),vs=({children:e})=>G(W,{children:e}),ys=({viewOptions:e,onViewOptionsChanged:t,lineageGraph:n,featureToggles:r,serverFlags:i,focusedNode:a,selectedNodes:o,onDeselect:s,onRunRowCount:c,onRunRowCountDiff:l,onRunValueDiff:u,onAddLineageDiffCheck:d,onAddSchemaDiffCheck:f,runTypeIcons:p,historyToggleSlot:m,SetupConnectionPopoverSlot:h=vs})=>{let g=i?.single_env_onboarding,[_,v]=U(null),y=!!_,b=o.length>0,x=b,S=e=>{v(e.currentTarget)},C=()=>{v(null)},w=p.rowCountDiff,ee=p.valueDiff,T=p.lineageDiff,E=p.schemaDiff;return G(Y,{direction:`row`,alignItems:`center`,borderBottom:1,borderColor:`neutral.light`,sx:{width:`100%`,p:`4pt 8pt`,gap:`0.5rem`},children:K(Y,{direction:`row`,alignItems:`center`,sx:{flex:1,gap:`0.5rem`},children:[m,G(_s,{label:`Mode`,style:{flexShrink:1},children:G(fs,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),G(_s,{label:`Package`,style:{flexShrink:1},children:G(ps,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,lineageGraph:n})}),G(_s,{label:`Select`,style:{flexShrink:1},children:G(hs,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,showTooltip:g})}),G(_s,{label:`Exclude`,style:{flexShrink:1},children:G(gs,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),G(q,{sx:{flexGrow:1}}),b&&K(W,{children:[G(_s,{label:``,style:{flexShrink:0},children:G(X,{fontSize:`9pt`,color:`text.secondary`,children:o.length>1?`${o.length} nodes selected`:`${o.length} node selected`})}),G(_s,{label:``,children:G(J,{variant:`outlined`,color:`neutral`,size:`xsmall`,onClick:()=>{s()},sx:{textTransform:`none`,fontSize:`9pt`},children:`Deselect`})}),g&&G(_s,{label:`Explore`,children:K(q,{sx:{display:`inline-flex`},children:[G(J,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:S,endIcon:G(or,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),G(qr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:K(Jr,{disabled:r.disableDatabaseQuery,onClick:async()=>{await c?.(),C()},children:[G(bi,{children:G(w,{fontSize:`small`})}),G(xi,{children:`Row Count`})]})})]})})]}),!g&&G(_s,{label:`Explore`,children:K(q,{sx:{display:`inline-flex`},children:[G(J,{size:`xsmall`,color:`neutral`,variant:`outlined`,disabled:r.disableViewActionDropdown,onClick:S,endIcon:G(or,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),K(qr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:[G(ti,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Diff`}),G(h,{display:r.mode===`metadata only`,children:K(Jr,{disabled:r.disableDatabaseQuery,onClick:async()=>{await l?.(),C()},children:[G(bi,{children:G(w,{fontSize:`small`})}),G(xi,{children:`Row Count Diff`})]})}),G(h,{display:r.mode===`metadata only`,children:K(Jr,{disabled:r.disableDatabaseQuery,onClick:async()=>{await u?.(),C()},children:[G(bi,{children:G(ee,{fontSize:`small`})}),G(xi,{children:`Value Diff`})]})}),(!r.disableUpdateChecklist||r.checklistPermissionDenied)&&[G(Xn,{},`checklist-divider`),G(ti,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Add to Checklist`},`checklist-header`),G(Q,{title:r.checklistPermissionDenied?`You don't have permission to add checks`:``,placement:`left`,children:G(`span`,{children:K(Jr,{disabled:r.checklistPermissionDenied,onClick:()=>{r.checklistPermissionDenied||(d?.(e.view_mode),C())},children:[G(bi,{children:G(T,{fontSize:`small`})}),G(xi,{children:`Lineage Diff`})]})})},`add-lineage-diff`),G(Q,{title:r.checklistPermissionDenied?`You don't have permission to add checks`:``,placement:`left`,children:G(`span`,{children:K(Jr,{disabled:r.checklistPermissionDenied,onClick:()=>{r.checklistPermissionDenied||(f?.(),C())},children:[G(bi,{children:G(E,{fontSize:`small`})}),G(xi,{children:`Schema Diff`})]})})},`add-schema-diff`)]]})]})})]})})},bs=({display:e,children:t})=>G($s,{display:e,children:t}),xs=()=>{let{deselect:e,focusedNode:t,selectedNodes:n,viewOptions:r,onViewOptionsChanged:i,runRowCount:a,runRowCountDiff:o,runValueDiff:s,addLineageDiffCheck:c,addSchemaDiffCheck:l}=fe(),{lineageGraph:u}=M(),{featureToggles:d}=Se(),{data:f}=be();return G(ys,{viewOptions:r,onViewOptionsChanged:i,lineageGraph:u,featureToggles:d,serverFlags:f,focusedNode:t,selectedNodes:n,onDeselect:e,onRunRowCount:a,onRunRowCountDiff:o,onRunValueDiff:s,onAddLineageDiffCheck:c,onAddSchemaDiffCheck:l,runTypeIcons:{rowCountDiff:B(`row_count_diff`).icon,valueDiff:B(`value_diff`).icon,lineageDiff:B(`lineage_diff`).icon,schemaDiff:B(`schema_diff`).icon},historyToggleSlot:G(ls,{}),SetupConnectionPopoverSlot:bs})};function Ss(e,t){let n=yo(t),r=new Set;for(let i of Object.keys(e.nodes)){let a=e.nodes[i];bo(i,t,a.data.changeStatus,n)&&r.add(i)}return{nodeIds:r,columnIds:n}}function Cs(e,t,n,r){return e&&t&&n?.node_id&&n?.column?vo(t,n.node_id,n.column,r??new Set):void 0}async function ws(e,t,n,r,i){let a={...e,change_analysis:e.change_analysis??t},o=await n.mutateAsync(a);return a.change_analysis&&o&&(r.current={pending:!0,cllData:o},i.setQueryData(A.lineage(),e=>e&&{...e,lineage:{...e.lineage,diff:ts(e.lineage.diff,o)}})),o}function Ts({interactive:e=!1,...t},n){let{isDark:r}=gt(),{apiClient:i}=Ne(),a=Tn(),o=zr(),s=Pn(null),{copyToClipboard:c,ImageDownloadModal:l,ref:u}=so(),[d,p,m]=Rr(Za),[h,g,b]=Lr([]),{lineageGraph:x,refetchLineageGraph:S,isLoading:C,error:T,refetchRunsAggregated:D}=M(),{featureToggles:O,singleEnv:te}=Se(),{data:ne}=be(),k=ne?.new_cll_experience??!1,{runId:ae,showRunId:oe,closeRunResult:se,runAction:ce,isRunResultOpen:le}=me(),{run:N}=xt(ae),[P,fe]=U({...t.viewOptions}),pe=fo(),ge=Pn([]).current,[xe,Ce]=U(void 0),[we,Te]=U(!1),Ee=Pn(!1);Ee.current=we;let De=Cn({mutationFn:e=>re(e,i)}),I=Pn({pending:!1}),[ke,je]=U({}),Me=V(e=>d.filter(de).find(t=>t.data.name===e),[d]);Mn(n,()=>({copyToClipboard:c}));let Pe=H(()=>!!(x&&x.modifiedSet.length>0),[x]),Fe=P.view_mode??`changed_models`,Ie=H(()=>d.filter(e=>e.type===`lineageGraphNode`).map(e=>e.id),[d]),Le=H(()=>x?Ie.map(e=>x.nodes[e]):[],[x,Ie]),[Re,ze]=U(),L=Re?x?.nodes[Re]:void 0,[R,Be]=U(),[He,Ue]=U(new Set),We=H(()=>x?Array.from(He).map(e=>x.nodes[e]):[],[x,He]),z=ho(We.length>0?We:Le,{onActionStarted:()=>{Be(`action_result`)},onActionNodeUpdated:e=>{p(t=>t.map(t=>t.id===e.id?{...t}:t))},onActionCompleted:()=>{}}),Ge=V(()=>{let e=new Map,t=o.getNodes();for(let n of t)!n.parentId&&n.position&&e.set(n.id,{x:n.position.x,y:n.position.y});return e},[o]),Ke=H(()=>{if(!x)return new Set;let e=new Set;if(xe){for(let[t,n]of Object.entries(xe.current.nodes))n.impacted!==!1&&e.add(t);for(let t of Object.keys(xe.current.columns))e.add(t)}else if(R===`action_result`){let t=Object.keys(z.actionState.actions);e=new Set(t)}else e=L?he(ye(x,[L.id]),_e(x,[L.id])):Pe?_e(x,x.modifiedSet):new Set(Ie);return new Set(e)},[x,xe,R,L,Pe,z.actionState.actions,Ie]),qe=Co(),Je=()=>{qe.closeContextMenu()},B=Pn(!1),{impactedNodeIds:Ye,impactedColumnIds:Xe,publish:Ze}=lo();Nn(()=>{(async()=>{let e;if(!x)return;if(P.node_ids)e=P.node_ids;else{let n=x.manifestMetadata.current?.project_name,r={view_mode:P.view_mode??(Pe?`changed_models`:`all`),packages:n?[n]:void 0,...t.viewOptions};try{e=(await w({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}catch{r.view_mode=`all`,e=(await w({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}fe(r)}let n=P.column_level_lineage,r=!1;ne?.impact_at_startup&&!B.current&&!n&&(B.current=!0,r=!0,Ee.current=!0,Te(!0),n={change_analysis:!0,no_upstream:!0},fe(e=>({...e,column_level_lineage:n})));let o;if(n)if(I.current.pending)o=I.current.cllData,I.current={pending:!1};else try{o=await ws(n,Ee.current,De,I,a)}catch(e){if(r&&(Ee.current=!1,Te(!1),fe(e=>({...e,column_level_lineage:void 0})),n=void 0),e instanceof j){Ht.create({title:`Column Level Lineage error`,description:e.data?.detail??e.message,type:`error`,closable:!0});return}}else I.current={pending:!1};let s=k&&o?Ss(x,o):void 0,[c,l,u]=await wo(x,{selectedNodes:e,cll:o,newCllExperience:k,columnAncestry:Cs(k,o,n,s?.columnIds)});p(c),g(l),je(u),Ce(o),s&&n?.change_analysis&&!n?.column&&Ze(s),pe(c,P.view_mode??`changed_models`,Ee.current,!!n?.column,!!Re||!!N)})()},[x,ne?.impact_at_startup]);let Qe=()=>{ze(void 0)},$e=async e=>{let t=d.find(t=>t.id===e);if(t){if(t.parentId){let e=t.parentId;t=d.find(t=>t.id===e)??t}if(t.measured!=null){let{width:e,height:n}=t.measured;if(e&&n){let r=t.position.x+e/2,i=t.position.y+n/2,a=o.getZoom();await o.setCenter(r,i,{zoom:a,duration:200})}}}},et=co();uo(s,async()=>{R!==`selecting`&&(Re?await $e(Re):await o.fitView({nodes:d,duration:200,padding:Oe,minZoom:Ve,maxZoom:1}))});let tt=async(e,t=!1)=>{let n=P.column_level_lineage;!e&&!k&&Te(!1);let r=n!==void 0;await ot({...P,column_level_lineage:e},!1,r),t||ge.push(n),e?.node_id?ze(e.node_id):e||ze(void 0)},nt=async e=>{if(e){if(ge.length===0)return;let e=ge.pop();e?await tt(e,!0):await tt(void 0,!0)}else k&&we?await tt({change_analysis:!0,no_upstream:!0},!0):await tt(void 0,!0)},rt=(e,t)=>{R||tt({node_id:t.data.node.id,column:t.data.column})},it=(t,n)=>{if(e&&x){if(ue(n)){rt(t,n);return}if(Je(),!R)ze(n.id);else if(R===`action_result`){let e=z.actionState.actions[n.id];e.run?.run_id&&oe(e.run.run_id),ze(n.id)}else{let e=new Set(He);He.has(n.id)?e.delete(n.id):e.add(n.id),Ue(e),e.size===0&&Be(void 0)}}},at=async e=>{let{viewOptions:t=P}=e,{fitView:n,preservePositions:r=!1}=e,s;if(!x)return;if(P.select!==t.select||P.exclude!==t.exclude||P.packages!==t.packages||P.view_mode!==t.view_mode){try{let e=await w({select:t.select,exclude:t.exclude,packages:t.packages,view_mode:t.view_mode},i);t={...t,column_level_lineage:void 0},s=e.nodes}catch(e){e instanceof j&&Ht.create({title:`Select node error`,description:e.data?.detail??e.message,type:`error`,closable:!0});return}ze(void 0)}else s=d.map(e=>e.id);let c;if(t.column_level_lineage)try{c=await ws(t.column_level_lineage,we,De,I,a)}catch(e){if(e instanceof j){Ht.create({title:`Column Level Lineage error`,description:e.data?.detail??e.message,type:`error`,closable:!0});return}}else k||Te(!1);let l;(r||k)&&(l=Ge());let u=t.column_level_lineage,m=k&&c?Ss(x,c):void 0,[h,v,b]=await wo(x,{selectedNodes:s,cll:c,existingPositions:l,newCllExperience:k,columnAncestry:Cs(k,c,u,m?.columnIds)});p(h),g(v),je(b),Ce(c),m&&!u?.column&&Ze(m),pe(h,t.view_mode??`changed_models`,we,!!t.column_level_lineage?.column,!!Re||!!N),N&&(ee(N)||y(N)||E(N)||f(N)||_(N))&&N.params?.model&&!Me(N.params.model)&&se(),n&&(await new Promise(e=>setTimeout(e,1)),o.fitView({nodes:h,duration:200,padding:Oe,minZoom:Ve,maxZoom:1}))},ot=async(e,t=!0,n=!1)=>{fe(e),await at({viewOptions:e,fitView:t,preservePositions:n})},st=go();jn(()=>{let t=N?.type;if(e&&le&&!(!t||[`query_diff`,`query`,`row_count`,`row_count_diff`].includes(t))&&!R){let e;(ee(N)||y(N)||E(N)||f(N)||_(N))&&(e=N.params?.model);let t=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window});if(e){let n=Me(e);n?de(n)&&L!==n.data.data&&it(t,n):ot({...P,view_mode:`all`})}else Qe()}},[N,P,le,R,Me,L,e]);let ct=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Be(`selecting`),z.reset(),P.column_level_lineage&&ot({...P,column_level_lineage:void 0})),Ue(he(He,ye(x,[e],t))))},ut=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Be(`selecting`),z.reset(),P.column_level_lineage&&ot({...P,column_level_lineage:void 0})),Ue(he(He,_e(x,[e],t))))},dt=(t,n)=>{if(!e||R===`action_result`)return;t.preventDefault();let r=u.current,i=r.getBoundingClientRect(),a=t.clientX-i.left,o=t.clientY-i.top+r.offsetTop;qe.showContextMenu(a,o,n)},ft=e=>{if(!R){if(!x)return;Ue(new Set([e])),Be(`selecting`),ze(void 0),z.reset()}else if(R===`selecting`){let t=new Set(He);He.has(e)?t.delete(e):t.add(e),Ue(t),t.size===0&&Be(void 0)}},pt=()=>{Be(void 0),Ue(new Set),ze(void 0),se(),D?.()},ht={interactive:e,nodes:d,focusedNode:L,selectedNodes:We,viewOptions:P,showContextMenu:dt,onViewOptionsChanged:ot,selectMode:R,selectNode:ft,selectParentNodes:ct,selectChildNodes:ut,deselect:pt,impactedNodeIds:Ye,impactedColumnIds:Xe,isNodeHighlighted:e=>Ke.has(e),isNodeSelected:e=>He.has(e),isEdgeHighlighted:(e,t)=>xe?e in xe.current.parent_map?t in xe.current.parent_map[e]:!1:Ke.has(e)&&Ke.has(t),isNodeShowingChangeAnalysis:e=>{if(!x||!we)return!1;let t=e in x.nodes?x.nodes[e]:void 0,n=P.column_level_lineage;return n?.node_id&&!n.column?n.node_id===e&&!!t?.data.changeStatus:!!t?.data.changeStatus},changeAnalysisMode:we,newCllExperience:k,setChangeAnalysisMode:Te,getNodeAction:e=>z.actionState.actions[e],getNodeColumnSet:e=>e in ke?new Set(ke[e]):new Set,runRowCount:async()=>{R===`selecting`?(await z.runRowCount(),pn({type:`row_count`,selected:`multi`})):L?(ce(`row_count`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),pn({type:`row_count`,selected:`single`})):(ce(`row_count`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),pn({type:`row_count`,selected:`none`}))},runRowCountDiff:async()=>{R===`selecting`?(await z.runRowCountDiff(),pn({type:`row_count_diff`,selected:`multi`})):L?(ce(`row_count_diff`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),pn({type:`row_count_diff`,selected:`single`})):(ce(`row_count_diff`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),pn({type:`row_count_diff`,selected:`none`}))},runValueDiff:async()=>{if(L)ce(`value_diff`,{model:L.data.name},{showForm:!0,showLast:!1}),pn({type:`value_diff`,selected:`single`});else{let e=R===`selecting`?We.length:Ie.length;await st.confirm(e)&&(await z.runValueDiff(),pn({type:`value_diff`,selected:R===`selecting`?`multi`:`none`}))}},addLineageDiffCheck:async()=>{let e=await ie(P,i),t;t=R===`selecting`?`multi`:L?`single`:`none`,pn({type:`lineage_diff`,selected:t}),e&&(await a.invalidateQueries({queryKey:A.checks()}),et(e))},addSchemaDiffCheck:async()=>{let e;R===`selecting`?We.length>0&&(e=await z.addSchemaDiffCheck(),pt(),pn({type:`schema_diff`,selected:`multi`})):L?(e=await v({node_id:L.id},i),pn({type:`schema_diff`,selected:`single`})):(e=await v({select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode},i),pn({type:`schema_diff`,selected:`none`})),e&&(await a.invalidateQueries({queryKey:A.checks()}),et(e))},cancel:z.cancel,actionState:z.actionState,centerNode:$e,cll:xe,showColumnLevelLineage:tt,resetColumnLevelLineage:nt};return C?G(os,{}):T?G(ss,{error:T,onRetry:S}):!x||d==Za?G(W,{}):Fe===`changed_models`&&!x.modifiedSet.length?G(cs,{viewOptions:P,onViewOptionsChanged:ot}):K(ve.Provider,{value:ht,children:[K(mt,{sizes:L?[70,30]:[100,0],minSize:0,gutterSize:5,className:L?void 0:`split-gutter-hidden`,style:{height:`100%`,width:`100%`},children:[K(Y,{ref:s,divider:G(Xn,{sx:{borderColor:`grey.200`}}),spacing:0,sx:{contain:`strict`,position:`relative`},children:[e&&K(W,{children:[G(xs,{}),O.mode===`metadata only`&&G(rs,{})]}),K(Nr,{proOptions:{hideAttribution:!0},nodeTypes:Ya,edgeTypes:Xa,nodes:d,edges:h,onNodesChange:m,onEdgesChange:b,onNodeClick:it,onNodeContextMenu:dt,onClick:Je,onInit:async()=>{if(Pe){let e=d.filter(e=>de(e)&&e.data.changeStatus!==void 0),t=e.length>0?e:d;await o.fitView({nodes:t,duration:200,padding:Oe,minZoom:Ve,maxZoom:1})}else{let e=Ir(d,{});await o.setCenter(e.x+e.width/2,e.y+e.height/2,{zoom:1})}},maxZoom:1,minZoom:Ae,nodesDraggable:e,ref:u,colorMode:r?`dark`:`light`,children:[G(Tr,{id:`lineage-bg`,variant:Er.Dots,color:r?F.neutral[700]:F.neutral[300],gap:20,size:2}),G(kr,{showInteractive:!1,position:`top-right`,className:lt,style:{backgroundColor:r?F.neutral[700]:void 0,borderColor:r?F.neutral[600]:void 0},children:G(Or,{title:`copy image`,onClick:async()=>{await c(),an({type:Fe,from:`lineage_view`})},style:{backgroundColor:r?F.neutral[700]:void 0,color:r?F.neutral[200]:void 0},children:G(q,{component:Ci})})}),G(l,{}),G(jr,{position:`bottom-left`,children:K(Y,{spacing:`5px`,children:[Pe&&G(wt,{variant:`changeStatus`,newCllExperience:k}),P.column_level_lineage&&G(wt,{variant:`transformation`})]})}),G(jr,{position:`top-center`,children:G(_o,{notification:te?G(as,{}):null,type:`info`})}),G(jr,{position:`top-left`,children:K(Y,{spacing:`5px`,children:[G(fa,{action:De}),d.length==0&&G(X,{sx:{fontSize:`1.25rem`,color:`grey`,opacity:.5},children:`No nodes`})]})}),G(Ar,{nodeColor:Qa,nodeStrokeWidth:3,zoomable:!0,pannable:!0,bgColor:r?F.neutral[800]:void 0,maskColor:r?`${F.neutral[900]}99`:`${F.neutral[100]}99`}),R===`action_result`&&G(jr,{position:`bottom-center`,className:`ignore-screenshot`,children:G(da,{onClose:()=>{pt()}})})]}),G(So,{...qe.props})]}),L?G(q,{sx:{borderLeft:`solid 1px`,borderColor:`divider`,height:`100%`},children:G(es,{node:L,onCloseNode:Qe})}):G(q,{})]}),st.AlertDialog]})}const Es=On(Ts);function Ds(){return G(Pr,{children:G(Es,{interactive:!0})})}function Os(){let{apiClient:e}=Ne(),{data:t,isLoading:n,error:r}=wn({queryKey:A.user(),queryFn:()=>Zt(e),retry:!1}),{data:i}=wn({queryKey:[`github-avatar`,t?.id],queryFn:()=>t?Xt(t.id):Promise.resolve(null),enabled:!!t?.id&&t.login_type===`github`,retry:!1,staleTime:300*1e3}),[a,o]=U(null),s=!!a,c=e=>{o(e.currentTarget)},l=()=>{o(null)},u=!n&&!r&&t;return K(W,{children:[n?G(q,{onClick:c,sx:{width:32,height:32,borderRadius:`50%`,bgcolor:`background.paper`,color:`primary.main`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`},children:G(Zn,{size:16})}):G(fi,{onClick:c,src:i||void 0,sx:{width:28,height:28,cursor:`pointer`,outline:`1px solid white`,fontSize:`0.875rem`},children:(e=>e?e.charAt(0).toUpperCase():`U`)(t?.login)}),K(qr,{anchorEl:a,open:s,onClose:l,slotProps:{paper:{sx:{bgcolor:`background.paper`,borderColor:`divider`,boxShadow:3,minWidth:180}}},children:[K(q,{sx:{px:2,py:1.5},children:[n&&K(q,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[G(X,{variant:`body2`,color:`text.primary`,children:`Loading...`}),G(Zn,{size:16})]}),r&&G(X,{variant:`caption`,color:`error`,children:`Failed to load user information`}),u&&K(W,{children:[G(X,{variant:`body2`,fontWeight:`600`,color:`text.primary`,children:t.login}),t.email&&G(X,{variant:`caption`,color:`text.secondary`,children:t.email})]})]}),G(Xn,{}),K(Jr,{onClick:()=>{window.open(Qt,`_blank`),l()},children:[G(bi,{children:G(Qn,{})}),G(xi,{children:`Recce Cloud`})]}),K(Jr,{onClick:()=>{window.open($t,`_blank`),l()},children:[G(bi,{children:G(ir,{})}),G(xi,{children:`Get live support`})]})]})]})}const ks=()=>{let{setTheme:e,resolvedTheme:t}=Wn(),[n,r]=U(!1);jn(()=>{r(!0)},[]);let i=()=>{e(t===`dark`?`light`:`dark`)};if(!n)return G(Z,{size:`small`,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},disabled:!0,children:G(br,{style:{width:18,height:18}})});let a=t===`dark`;return G(Q,{title:a?`Switch to light mode`:`Switch to dark mode`,children:G(Z,{size:`small`,onClick:i,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},"aria-label":a?`Switch to light mode`:`Switch to dark mode`,children:G(a?br:mr,{style:{width:18,height:18}})})})};function As(e,t,n,r){let i=e?.git,a=e?.pullRequest,o=e?.dbt?.base,s=e?.dbt?.current,c={review_mode:t||!1,adapter_type:e?.adapterType||null,has_git_info:!Yr(i),has_pr_info:!Yr(a)};return e?.adapterType===`dbt`&&(c.base={schema_count:n.size,dbt_version:o?.dbt_version||null,timestamp:o?.generated_at||null},c.current={schema_count:r.size,dbt_version:s?.dbt_version||null,timestamp:s?.generated_at||null},c.schemas_match=n.size===r.size&&Array.from(n).every(e=>r.has(e))),e?.adapterType===`sqlmesh`&&(c.base={has_env:!!e.sqlmesh?.base_env},c.current={has_env:!!e.sqlmesh?.current_env}),c}function js(e){return Object.values(e).every(e=>e===null)?[G(q,{sx:{ml:`10px`},children:`No information`},`no info`)]:Object.entries(e).filter(([e,t])=>e!==`url`&&t!=null).map(([e,t])=>K(`li`,{style:{marginLeft:`10px`},children:[e,`: `,t]},e))}function Ms(){let{envInfo:e,reviewMode:t,lineageGraph:n}=M(),[r,i]=U(!1),a=e?.git,o=e?.pullRequest,s={...a,...o},c=e?.dbt?.base,l=e?.dbt?.current,u=c?.generated_at?Bt(c.generated_at):``,d=l?.generated_at?Bt(l.generated_at):``,f=``,p=``;c&&(f=c.generated_at?Ut(c.generated_at):``),l&&(p=l.generated_at?Ut(l.generated_at):``);let[m,h]=Jt(n),g=Pn(!1);jn(()=>{!g.current&&e&&(g.current=!0,on(As(e,t,m,h)))},[e,t,m,h]);let _=()=>i(!0),v=()=>i(!1);return K(W,{children:[G(Q,{title:`Environment Info`,placement:`bottom-end`,children:K(q,{sx:{display:`flex`,alignItems:`center`,cursor:`pointer`,"&:hover":{color:`text.primary`}},onClick:_,children:[K(Y,{direction:`column`,sx:{display:{xs:`none`,lg:`flex`},fontSize:`0.875rem`},children:[K(q,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[G(X,{component:`span`,noWrap:!0,sx:{color:`warning.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(m).join(`, `)}),K(X,{component:`span`,noWrap:!0,children:[`(`,f,`)`]})]}),K(q,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[G(X,{component:`span`,noWrap:!0,sx:{color:`primary.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(h).join(`, `)}),K(X,{component:`span`,noWrap:!0,children:[`(`,p,`)`]})]})]}),G(Z,{size:`small`,"aria-label":`Environment Info`,children:G(q,{component:fr,sx:{fontSize:16,verticalAlign:`middle`}})})]})}),K(Fn,{open:r,onClose:v,maxWidth:`sm`,fullWidth:!0,children:[K(Rn,{sx:{display:`flex`,alignItems:`center`},children:[`Environment Information`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:v,children:G(qn,{})})]}),G(Ln,{children:K(Y,{direction:`column`,spacing:1,children:[t?K(Y,{direction:`column`,spacing:.5,children:[G(X,{variant:`h6`,sx:{fontSize:`1rem`},children:`Review Information`}),K(`ul`,{style:{margin:0,paddingLeft:`20px`},children:[s.url&&K(`li`,{style:{marginLeft:`10px`},children:[`url:`,` `,K(zn,{href:s.url,target:`_blank`,sx:{color:`primary.main`},children:[s.url,` `,G(Bn,{})]})]}),!Yr(s)&&js(s)]})]}):K(Y,{direction:`column`,spacing:.5,children:[G(X,{variant:`h6`,sx:{fontSize:`1rem`},children:`Dev Information`}),G(`ul`,{style:{margin:0,paddingLeft:`20px`},children:a&&js(a)})]}),G(Xn,{}),e?.adapterType===`dbt`&&K(Y,{direction:`column`,spacing:.5,children:[G(X,{variant:`h6`,sx:{fontSize:`1rem`},children:`DBT`}),G(Ui,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:K(Vi,{size:`small`,stickyHeader:!0,children:[G(Wi,{children:K(Gi,{children:[G($,{}),G($,{children:`base`}),G($,{children:`current`})]})}),K(Hi,{children:[K(Gi,{children:[G($,{children:`schema`}),G($,{className:`no-track-pii-safe`,children:Array.from(m).map(e=>G(Q,{title:e,placement:`bottom`,children:G(`div`,{className:`max-w-72 truncate`,children:e})},e))}),G($,{className:`no-track-pii-safe`,children:Array.from(h).map(e=>G(Q,{title:e,placement:`bottom`,children:G(`div`,{className:`max-w-72 truncate`,children:e})},e))})]}),K(Gi,{children:[G($,{children:`version`}),G($,{children:c?.dbt_version}),G($,{children:l?.dbt_version})]}),K(Gi,{children:[G($,{children:`timestamp`}),G($,{children:u}),G($,{children:d})]})]})]})})]}),e?.adapterType===`sqlmesh`&&K(Y,{direction:`column`,spacing:.5,children:[G(X,{variant:`h6`,sx:{fontSize:`1rem`},children:`SQLMesh`}),G(Ui,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:K(Vi,{stickyHeader:!0,children:[G(Wi,{children:K(Gi,{children:[G($,{}),G($,{children:`base`}),G($,{children:`current`})]})}),G(Hi,{children:K(Gi,{children:[G($,{children:`Environment`}),G($,{className:`no-track-pii-safe`,children:e.sqlmesh?.base_env}),G($,{className:`no-track-pii-safe`,children:e.sqlmesh?.current_env})]})})]})})]})]})}),G(In,{children:G(J,{color:`iochmara`,onClick:v,children:`Close`})})]})]})}const Ns=()=>({toastSuccess:e=>{Ht.create({description:e,type:`success`,duration:5e3,closable:!0})},toastError:(e,t)=>{let n=e;t!=null&&(n=ae(t)?`${e}. ${String(t.data?.detail)}`:`${e}. ${t}`),Ht.create({description:n,type:`error`,duration:5e3,closable:!0})}}),Ps=e=>{jn(()=>{let t=e=>{e.preventDefault()};return e&&window.addEventListener(`beforeunload`,t),()=>{e&&window.removeEventListener(`beforeunload`,t)}},[e])},Fs=()=>{let{featureToggles:e}=Se(),{fileName:t,cloudMode:n,isDemoSite:r,envInfo:i}=M(),{apiClient:a}=Ne(),[o,c]=U(!1),[l,u]=U(!1),d=!t&&!n&&!r,{data:f}=s(d),m=f!=null&&f.filter(e=>!e.is_preset).length>0;Ps(d&&m);let[{newFileName:g,errorMessage:_,modified:v,overwriteWithMethod:y,bypass:b},x]=U({newFileName:t??`recce_state.json`,bypass:!1}),S=Pn(null),{toastSuccess:C,toastError:w}=Ns(),ee=Tn(),T=()=>{x({newFileName:t??`recce_state.json`,modified:!t,bypass:!1}),c(!0)},E=()=>c(!1),D=()=>u(!1),O=async(e,t)=>{if(!g)return;let n=localStorage.getItem(p.bypassSaveOverwrite)===`true`;try{e===`save`?await h({filename:g,overwrite:t??n},a):await ne({filename:g,overwrite:t??n},a),C(e===`save`?`Save file successfully`:`Rename file successfully`),await ee.invalidateQueries({queryKey:A.lineage()}),b&&localStorage.setItem(p.bypassSaveOverwrite,`true`)}catch(t){if(ae(t)&&t.status===409){x(t=>({...t,overwriteWithMethod:e})),u(!0);return}w(e===`save`?`Save file failed`:`Rename file failed`,t)}finally{E()}},te=()=>{D(),c(!0),x(e=>({...e,overwriteWithMethod:void 0}))};if(n||r)return G(W,{});let re=`New Instance`+(m?` (unsaved)`:``),ie;if(e.disableSaveToFile&&t){let e=i?.stateMetadata?.generated_at,n=e?R(new Date(e)):null;ie=n?`${t} (${n})`:null}return K(W,{children:[K(Y,{direction:`row`,alignItems:`center`,justifyContent:`center`,children:[G(q,{sx:{fontWeight:600},children:ie??t??re}),!e.disableSaveToFile&&G(Q,{title:t?`Change Filename`:`Save`,enterDelay:1e3,children:G(Z,{onClick:T,"aria-label":t?`Change Filename`:`Save`,size:`small`,children:G(q,{component:t?gr:Vn,sx:{fontSize:16,verticalAlign:`middle`}})})})]}),K(Fn,{open:o,onClose:E,children:[K(Rn,{sx:{display:`flex`,alignItems:`center`},children:[t?`Change Filename`:`Save File`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:E,children:G(qn,{})})]}),G(Ln,{onKeyDown:e=>{e.stopPropagation()},children:G(ni,{inputRef:S,value:g,label:`File name`,placeholder:`Enter filename`,error:!!_,helperText:_,fullWidth:!0,size:`small`,sx:{mt:1},onChange:e=>{let n=e.target.value,r;n?n.endsWith(`.json`)?/^[a-zA-Z0-9 _-]+\.json$/.test(n)?t&&n===t&&(r=`Filename is the same as the current one.`):r=`Invalid filename. Only alphanumeric, space, _ and - are allowed.`:r=`Filename must end with .json.`:r=`Filename cannot be empty.`,x(e=>({...e,modified:!0,newFileName:n,errorMessage:r}))},onKeyDown:e=>{if(e.key===`Enter`){if(_)return;O(t?`rename`:`save`)}else e.key===`Escape`&&E()}})}),K(In,{sx:{gap:`5px`},children:[G(J,{size:`small`,color:t?`inherit`:`iochmara`,variant:`contained`,onClick:async()=>{await O(`save`)},disabled:!g||!!_||!v,children:t?`Save as New File`:`Confirm`}),t&&G(J,{size:`small`,color:`iochmara`,variant:`contained`,onClick:async()=>{await O(`rename`)},disabled:!g||!!_||!v,children:`Rename`})]})]}),K(Fn,{open:l,onClose:D,children:[K(Rn,{sx:{display:`flex`,alignItems:`center`},children:[`Overwrite File?`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:D,children:G(qn,{})})]}),K(Ln,{sx:{borderTop:`solid 1px`,borderBottom:`solid 1px`,borderColor:`divider`},onKeyDown:e=>{e.stopPropagation()},children:[G(X,{sx:{fontSize:`12pt`},children:y===`save`?`Saving a file with this name will overwrite the existing file. Are you sure you wish to continue?`:`Renaming the file with this name will overwrite the existing file. Are you sure you wish to continue?`}),G(Ur,{control:G(Hr,{size:`small`,checked:b,onChange:e=>{x(t=>({...t,bypass:e.target.checked}))}}),label:G(X,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),K(In,{sx:{gap:`5px`},children:[G(J,{variant:`outlined`,onClick:te,size:`small`,children:`Back`}),G(J,{size:`small`,color:`iochmara`,variant:`contained`,onClick:()=>{y&&(O(y,!0),D())},children:`Overwrite`})]})]})]})};function Is(){let{featureToggles:e}=Se(),{apiClient:t}=Ne(),n=async()=>{try{let e=await te(t),n=JSON.stringify(e,null,2);Vr(new Blob([n],{type:`application/json`}),`recce-state-${ri(new Date,`yyyy-MM-dd-HH-mm-ss`)}.json`)}catch(e){console.error(`Export failed`,e),Ht.create({title:`Export failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}};return G(Q,{title:`Export`,children:G(Z,{size:`small`,"aria-label":`Export state`,onClick:async()=>{await n(),yn({name:`export`})},disabled:e.disableExportStateFile,children:G(q,{component:dr,sx:{verticalAlign:`middle`,width:`16px`,height:`16px`}})})})}const Ls=[`Processing...`,`Still processing, please wait...`,`Almost there, thanks for your patience...`];function Rs(){let{successToast:e,failToast:t}=Vt(),[,n]=Wr(),{authed:r}=Se(),{shareUrl:i,isLoading:a,error:o,handleShareClick:s}=At(),[c,l]=U(!1),[u,d]=U(0),[f,p]=U(a);a!==f&&(p(a),a&&d(0)),Gr(()=>{d(e=>Math.min(e+1,Ls.length-1))},a?3e4:null),jn(()=>{o&&t(`Failed to share state`,o)},[o,t]);let m=async()=>{try{await n(String(i)),e(`Copied the link to clipboard`)}catch(e){t(`Failed to copy the link`,e)}};return r?K(Y,{direction:`row`,sx:{flex:1,alignItems:`center`,gap:`5px`},children:[G(J,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:G(vi,{}),endIcon:i?G(q,{component:cr,sx:{color:`success.main`}}):void 0,onClick:async()=>{await s(),_n({name:`create`})},disabled:a,children:a?`Sharing...`:`Share`}),a&&G(X,{sx:{fontSize:14,color:`grey.500`},children:Ls[u]}),G(Y,{direction:`row`,spacing:.5,alignItems:`center`,children:i&&K(W,{children:[G(q,{sx:{overflowX:`auto`,whiteSpace:`nowrap`,maxWidth:`350px`},children:G(X,{sx:{fontSize:14},children:i})}),G(Z,{size:`small`,"aria-label":`Copy the share URL`,onClick:async()=>{await m(),_n({name:`copy`})},children:G(ur,{})})]})})]}):K(Y,{direction:`row`,sx:{flex:1,alignItems:`center`},children:[G(J,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:()=>{l(!0)},startIcon:G(vi,{}),children:`Share`}),c&&G(Tt,{parentOpen:c,handleParentClose:l,ignoreCookie:!0,variant:`enable-share`})]})}function zs(e){return/^\/checks\/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/.test(e)}function Bs(){return G(Q,{title:`Syncing`,children:G(q,{sx:{mx:`10px`},children:G(Zn,{size:20})})})}function Vs(){let[e,t]=U(!1),n=Tn(),{apiClient:r}=Ne(),i=hi(),a=mi(),{basePath:o}=pe(),[s,c]=U(!1),[l,u]=U(``),{data:d}=ce(),f=()=>c(!1),p=V(async e=>{if(c(!1),t(!0),(await O(e,r)).status===`conflict`){c(!0),t(!1);return}for(;await S(r);)await new Promise(e=>setTimeout(e,1e3));Ht.create({description:`Sync Completed`,type:`success`,duration:5e3,closable:!0}),t(!1),u(``),await n.invalidateQueries({queryKey:A.lineage()}),await n.invalidateQueries({queryKey:A.checks()}),await n.invalidateQueries({queryKey:A.runs()}),zs(a)&&i.push(`${o}/checks`)},[n,a,r,i.push,o]);return e?G(Bs,{}):K(W,{children:[G(Q,{title:`Sync with Cloud`,children:G(Z,{size:`small`,"aria-label":`Sync state`,onClick:()=>p(d?.session_id?{method:`merge`}:{}),children:G(q,{component:Jn,sx:{fontSize:16,verticalAlign:`middle`}})})}),K(Fn,{open:s,onClose:f,children:[K(Rn,{sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Sync with Cloud`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:f,children:G(qn,{})})]}),K(Ln,{children:[G(X,{children:`New changes have been detected in the cloud. Please choose a method to sync your state`}),G(q,{sx:{mt:`5px`},children:G(Bi,{value:l,onChange:e=>{u(e.target.value)},children:K(Y,{direction:`column`,children:[G(Ur,{value:`merge`,control:G(zi,{}),label:K(Y,{direction:`row`,alignItems:`center`,children:[`Merge`,G(Q,{title:`This will merge the local and remote states.`,children:G(q,{component:fr,sx:{ml:2,cursor:`pointer`}})})]})}),G(Ur,{value:`overwrite`,control:G(zi,{}),label:K(Y,{direction:`row`,alignItems:`center`,children:[`Overwrite`,G(Q,{title:`This will overwrite the remote state file with the local state.`,children:G(q,{component:fr,sx:{ml:2,cursor:`pointer`}})})]})}),G(Ur,{value:`revert`,control:G(zi,{}),label:K(Y,{direction:`row`,alignItems:`center`,children:[`Revert`,G(Q,{title:`This will discard local changes and revert to the cloud state.`,children:G(q,{component:fr,sx:{ml:2,cursor:`pointer`}})})]})})]})})})]}),K(In,{children:[G(J,{onClick:f,sx:{mr:1},children:`Cancel`}),G(J,{color:`iochmara`,variant:`contained`,onClick:()=>p({method:l||void 0}),disabled:!l,children:`Sync`})]})]})]})}const Hs=[{path:`/lineage`,name:`Lineage`},{path:`/query`,name:`Query`},{path:`/checks`,name:`Checklist`}];function Us({queryKey:e,fetchCallback:t,selectCallback:n}){let{data:r,isLoading:i,error:a}=wn({queryKey:e,queryFn:t,select:n});return i||a||r===0?G(W,{}):G(q,{bgcolor:`brand.main`,display:`flex`,justifyContent:`center`,alignItems:`center`,p:1,borderRadius:`100%`,color:`white`,fontWeight:700,fontSize:`0.75rem`,children:G(`span`,{children:r})})}function Ws(){let{apiClient:e}=Ne();return G(Us,{queryKey:A.checks(),fetchCallback:()=>x(e),selectCallback:e=>e.filter(e=>!e.is_checked).length})}const Gs=()=>{let e=mi(),{isDemoSite:t,isLoading:n,cloudMode:r}=M(),{featureToggles:i}=Se(),{data:a,isLoading:o}=be(),s=Pn(null);return jn(()=>{s.current&&s.current!==e&&mn({from:s.current,to:e}),s.current=e},[e]),G(q,{sx:{borderBottom:`1px solid lightgray`,px:`12px`},children:K(q,{sx:{display:`grid`,gridTemplateColumns:`1fr auto 1fr`,width:`100%`,alignItems:`center`},children:[G(si,{value:H(()=>e.startsWith(`/checks`)?`/checks`:e.startsWith(`/query`)?`/query`:e.startsWith(`/runs`)?`/runs`:`/lineage`,[e]),sx:{borderBottom:`none`,minHeight:`auto`},children:Hs.map(({path:e,name:t})=>t===`Query`&&a?.single_env_onboarding?null:t===`Checklist`&&Ws?G(oi,{value:e,disabled:n||o,sx:{p:0},label:G(q,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:K(Gn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`,display:`flex`,gap:3,alignItems:`center`},children:[t,` `,G(Ws,{})]})})},e):G(oi,{value:e,disabled:n||o,sx:{p:0},label:G(q,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:G(Gn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`},children:t})})},e))}),K(q,{sx:{display:`flex`,alignItems:`center`,gap:`12px`,justifyContent:`center`},children:[!n&&!t&&G(Fs,{}),!n&&!t&&!a?.single_env_onboarding&&!i.disableShare&&G(Rs,{})]}),!n&&K(q,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,mr:`8px`},children:[G(Ms,{}),r&&G(Vs,{}),G(Is,{})]})]})})};function Ks(){let{remainingSeconds:e,isEnabled:t}=N();return!t||e===null||e>60?null:K(Ki,{color:`warning`,variant:`standard`,sx:{display:`flex`,alignItems:`center`,gap:1,fontSize:`0.75rem`,mr:2},children:[G(q,{component:Yn,sx:{display:`inline-flex`}}),`Idle timeout: `,qt(e,`compact`)]})}const qs=()=>{let{version:e,latestVersion:t}=T(),n=H(()=>RegExp(`^\\d+\\.\\d+\\.\\d+$`),[]);return jn(()=>{if(n.test(e)&&e!==t){let e=`recce-update-toast-shown`;if(sessionStorage.getItem(e))return;setTimeout(()=>{Ht.create({id:`recce-update-available`,title:`Update available`,description:K(`span`,{children:[`A new version of Recce (v`,t,`) is available.`,G(`br`,{}),`Please run`,` `,G(q,{component:`code`,sx:{bgcolor:`grey.200`,px:.5,py:.25,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},children:`pip install --upgrade recce`}),` `,`to update Recce.`,G(`br`,{}),G(zn,{sx:{color:`primary.main`,fontWeight:`bold`,"&:hover":{textDecoration:`underline`}},href:`https://github.com/DataRecce/recce/releases/tag/v${t}`,target:`_blank`,children:`Click here to view the detail of latest release`})]}),duration:60*1e3,closable:!0}),sessionStorage.setItem(e,`true`)},0)}},[e,t,n]),n.test(e)?G(zn,{href:`https://github.com/DataRecce/recce/releases/tag/v${e}`,sx:{"&:hover":{textDecoration:`none`},fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},target:`_blank`,children:e}):G(X,{component:`span`,sx:{fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},children:e})};function Js({icon:e,href:t,sx:n,...r}){let i=Un();return G(zn,{sx:{height:`20px`,color:`common.white`,...n},href:t,target:`_blank`,...r,children:G(e,{style:{color:i.palette.common.white,width:20,height:20}})})}const Ys=()=>{let{reviewMode:e,isDemoSite:t,envInfo:n,cloudMode:r}=M(),{featureToggles:i,authed:a}=Se(),{url:o,id:s}=n?.pullRequest??{},c=o?o.split(`/`).pop():null,l=r||a?Qt:`https://reccehq.com/`,[u,d]=U(!1);return K(q,{sx:{display:`flex`,gap:`10px`,minHeight:`40px`,alignItems:`center`,bgcolor:F.brand[400]},children:[G(zn,{href:l,target:`_blank`,sx:{"&:hover":{textDecoration:`none`}},children:K(q,{sx:{display:`flex`,gap:`10px`,alignItems:`center`},children:[G(q,{component:`img`,sx:{width:20,height:20,ml:`18px`},src:`/logo/recce-logo-white.png`,alt:`recce-logo-white`}),G(X,{variant:`h4`,sx:{fontFamily:`"Montserrat", sans-serif`,color:`common.white`,fontSize:`1.25rem`},children:`RECCE`})]})}),G(ks,{}),G(qs,{}),(i.mode??e)&&G(Ki,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:i.mode??`review mode`}),r&&s&&G(Ki,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:K(Y,{direction:`row`,spacing:1,alignItems:`center`,children:[G(q,{children:`cloud mode`}),G(q,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:K(zn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[G(Qr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),G(X,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${String(s)}`})]})})]})}),t&&o&&c&&G(Ki,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:K(Y,{direction:`row`,spacing:1,alignItems:`center`,children:[G(q,{children:`demo mode`}),G(q,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:K(zn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[G(Qr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),G(X,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${c}`})]})})]})}),G(q,{sx:{flex:1}}),(t||i.mode===`read only`)&&K(W,{children:[G(Js,{icon:er,href:`https://github.com/DataRecce/recce`}),G(Js,{icon:rr,href:`https://getdbt.slack.com/archives/C05C28V7CPP`}),G(Js,{sx:{mr:2},icon:tr,href:`https://docs.reccehq.com`})]}),!t&&i.mode!==`read only`&&K(W,{children:[G(Ks,{}),a||r?G(q,{sx:{mr:2},children:G(Os,{})}):K(W,{children:[G(q,{component:`button`,sx:{color:`common.white`,fontSize:`0.875rem`,fontWeight:600,bgcolor:`brand.700`,borderRadius:1,px:3,py:1,mr:2,cursor:`pointer`,border:`none`},onClick:()=>{d(!0)},children:`Connect to Cloud`}),u&&G(Tt,{parentOpen:u,handleParentClose:d,ignoreCookie:!0,variant:`user-profile`})]})]})]})};function Xs(){return G(q,{sx:{display:`flex`,height:`100%`,alignItems:`center`,justifyContent:`center`,contain:`size`},children:G(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:G(Zn,{size:48})})})}function Zs({children:e,lineage:t}){let n=mi(),{isDemoSite:r,isLoading:i,isCodespace:a}=M(),{featureToggles:o}=Se(),s=n.replace(/\/$/,``)||`/`,c=s===`/lineage`||s===`/`;return jn(()=>{un()},[]),K(q,{sx:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:[G(Ys,{}),G(Gs,{}),G(Qs,{isLineageRoute:c,lineage:t,children:e}),!i&&!r&&!a&&o.mode===null&&G(Tt,{})]})}function Qs({children:e,lineage:t,isLineageRoute:n,disableInternalHistory:r=!1}){let{isRunResultOpen:i,isHistoryOpen:a,closeRunResult:o}=me(),{basePath:s}=pe(),{data:c}=be(),l=mi(),u=Rt(),d=i&&!l.startsWith(`${s}/checks`),f=r?!1:a&&!l.startsWith(`${s}/checks`);return K(mt,{sizes:f?[20,80]:[0,100],minSize:0,gutterSize:5,className:f?void 0:`split-gutter-hidden`,style:{height:`100%`},children:[G(q,{style:{contain:`size`},suppressHydrationWarning:!0,children:f&&G(Ie,{})}),K(kt,{sizes:d?[50,50]:[100,0],minSize:0,gutterSize:5,className:d?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`},children:[G(En,{fallback:G(Xs,{}),children:K(q,{sx:{p:0,contain:`content`,height:`100%`,position:`relative`},suppressHydrationWarning:!0,children:[G(q,{sx:{display:n?`block`:`none`,height:`100%`,position:n?`relative`:`absolute`,inset:0},children:t}),!n&&e]})}),G(q,{sx:{height:`100%`,bgcolor:u?`grey.900`:`grey.50`},suppressHydrationWarning:!0,children:d?G(Be,{onClose:o,isSingleEnvironment:!!c?.single_env_onboarding}):null})]})]})}function $s({children:e,display:t}){let[n,r]=U(!1),i=Pn(null),a=Pn(null),o=V(()=>{i.current&&=(clearTimeout(i.current),null),r(!0)},[]),s=V(()=>{i.current=setTimeout(()=>{r(!1)},100)},[]);return t?K(W,{children:[G(q,{ref:a,onMouseEnter:o,onMouseLeave:s,sx:{display:`contents`},children:e}),K(pi,{open:n,anchorEl:a.current,onClose:()=>r(!1),anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},disableAutoFocus:!0,disableEnforceFocus:!0,sx:{pointerEvents:`none`},slotProps:{paper:{onMouseEnter:o,onMouseLeave:s,sx:{bgcolor:`grey.600`,color:`white`,p:1.5,pointerEvents:`auto`}}},children:[`Connect to a data warehouse to unlock Diff.`,` `,G(zn,{href:$t,target:`_blank`,sx:{color:`white`,textDecoration:`underline`},children:`Learn more`}),`.`]})]}):e}function ec({checksOnly:e=!0}){let t=Rt(),{featureToggles:n}=Se(),r=Tn(),{apiClient:i}=Ne(),a=Pn(null),o=Pn(null),[s,c]=U(null),[l,u]=U(!1),d=hi(),f=mi(),{basePath:p}=pe(),[,h]=xe(),g=V(async()=>{if(s){try{let{runs:t,checks:n}=await m(s,e,i);h?.(),await r.invalidateQueries({queryKey:A.checks()}),await r.invalidateQueries({queryKey:A.runs()}),f.includes(`/checks`)&&d.push(`${p}/checks`);let a=e?`${n} checks imported successfully`:`${t} runs and ${n} checks imported successfully`;Ht.create({description:a,type:`info`,duration:5e3,closable:!0})}catch(e){console.error(`Import failed`,e),Ht.create({title:`Import failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}u(!1)}},[r,s,f,h,e,i,d.push,p]),_=()=>{a.current&&a.current.click()},v=e=>{e.target.files?.length===1&&(c(e.target.files[0]),u(!0)),a.current&&(a.current.value=``)},y=()=>u(!1),b=e?`checks`:`runs and checks`,{isDemoSite:x}=M();return K(W,{children:[G(Q,{title:`Import Checklist from State File`+(x?` (Disabled in the demo site)`:``),children:G(Z,{sx:{pt:`6px`,color:t?`grey.300`:`grey.600`,"&:hover":{color:t?`grey.100`:`grey.800`},fontSize:20},"aria-label":`Import state`,onClick:()=>{_(),yn({name:`import`})},disabled:n.disableImportStateFile||x,children:G(Ni,{})})}),G(`input`,{type:`file`,style:{display:`none`},ref:a,onChange:v}),K(Fn,{open:l,onClose:y,maxWidth:`sm`,fullWidth:!0,"aria-labelledby":`import-dialog-title`,children:[K(Rn,{id:`import-dialog-title`,sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Import state`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:y,children:G(qn,{})})]}),G(Ln,{children:K(Y,{direction:`column`,spacing:1,sx:{px:`5px`,borderRadius:1},children:[K(Y,{direction:`row`,alignItems:`center`,spacing:.5,children:[G(q,{component:fr,sx:{color:`error.main`}}),G(X,{component:`span`,sx:{fontWeight:500,color:`error.main`},children:`Caution!`})]}),K(X,{children:[`The current `,b,` will be`,` `,G(X,{component:`span`,sx:{fontWeight:600},children:`merged`}),` `,`with the imported state`]})]})}),K(In,{children:[G(J,{ref:o,onClick:y,children:`Cancel`}),G(J,{color:`iochmara`,variant:`contained`,onClick:g,sx:{ml:`5px`},children:`Import`})]})]})]})}function tc({check:e},t){return G(q,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:G(Pr,{children:G(Es,{viewOptions:{...e.params,...e.view_options},interactive:!1,ref:t})})})}const nc=On(tc),rc=({node:e,selected:t,onSelect:n,schemaChanged:r,isDark:i})=>{let{icon:a}=Nt(e.data.resourceType),{base:o,current:s}=e.data.data,c,l;return r?(c=B(`schema_diff`).icon,l=I(`modified`).color):!o&&s?(c=I(`added`).icon,l=I(`added`).color):o&&!s&&(c=I(`removed`).icon,l=I(`removed`).color),G(li,{disablePadding:!0,children:K(q,{sx:{display:`flex`,width:`100%`,fontSize:`10pt`,p:`5px 8px`,cursor:`pointer`,"&:hover":{bgcolor:i?`grey.700`:`grey.200`},bgcolor:t?i?`grey.800`:`grey.100`:`inherit`,alignItems:`center`,gap:`5px`},onClick:()=>{n(e.id)},children:[a&&G(q,{component:a}),G(q,{sx:{flex:1,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`},children:e.data.name}),c&&l&&G(q,{component:c,sx:{color:l}})]})})};function ic({check:e},t){let n=Rt(),{apiClient:r}=Ne(),{lineageGraph:i}=M(),a=e.params,{isLoading:o,error:s,data:c}=wn({queryKey:[...A.check(e.check_id),`select`],queryFn:async()=>w({select:a.select,exclude:a.exclude,packages:a.packages,view_mode:a.view_mode},r),refetchOnMount:!0,enabled:!a.node_id}),[l,u]=H(()=>{let e=[],t=[],n=[],r=[];if(a.node_id){let t=a.node_id instanceof Array?a.node_id:[a.node_id];for(let n of t){let t=i?.nodes[n];t&&e.push(t)}}else for(let t of c?.nodes??[]){let n=i?.nodes[t];n&&e.push(n)}let o=e.filter(e=>e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`);for(let e of o)Gt(e.data.data.base?.columns,e.data.data.current?.columns)?t.push(e.id):!e.data.data.base&&e.data.data.current?n.push(e.id):e.data.data.base&&!e.data.data.current&&r.push(e.id);function s(e){return t.includes(e.id)?3:n.includes(e.id)?2:r.includes(e.id)?1:0}return o.sort((e,t)=>{let n=s(e),r=s(t);return n===r?e.data.name.localeCompare(t.data.name):r-n}),[o,t]},[a.node_id,c?.nodes,i]),[d,f]=U(0);if(o)return G(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`Loading...`});if(s)return K(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},className:`no-track-pii-safe`,children:[`Error: `,s.message]});if(l.length==0)return G(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`No nodes matched`});if(d<l.length){let e=l[d];return K(mt,{sizes:[80,20],minSize:30,style:{height:`100%`},children:[G(Ao,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,enableScreenshot:!0,showMenu:!1,ref:t}),G(ci,{sx:{overflow:`auto`,bgcolor:`background.paper`,listStyle:`none`},children:l.map((e,t)=>G(rc,{node:e,schemaChanged:u.includes(e.id),selected:t===d,isDark:n,onSelect:()=>{f(t)}},e.id))})]})}return G(W,{})}const ac=On(ic);function oc({checkId:r,refreshCheckList:a}){let s=Un(),l=Rt(),{apiClient:u}=Ne(),{featureToggles:d,sessionId:f}=Se(),{setLatestSelectedCheckId:p}=L(),{cloudMode:m}=M(),h=Tn(),g=hi(),{basePath:_}=pe(),{setSqlQuery:v,setBaseSqlQuery:y,setCustomQueries:b,setPrimaryKeys:x}=z(),{successToast:S,failToast:C}=Vt(),[w,ee]=U(),[T]=U(),[E,D]=U(!1),[O,te]=U(!1),[ne,re]=U(null),ie=!!ne,{isLoading:k,error:ae,data:j}=wn({queryKey:A.check(r),queryFn:async()=>c(r,u),refetchOnMount:!0}),oe=w??j?.last_run?.run_id,{run:se,error:ce}=xt(oe),le=w?!se||se.status===`Running`:se?.status===`Running`,N=j?.type?B(j.type):void 0,ue;N&&(ue=N.RunResultView);let de=j?.is_preset??!1,P=Pn(null),{mutate:fe}=Cn({mutationFn:e=>o(r,e,u),onSuccess:async()=>{await h.invalidateQueries({queryKey:A.check(r)}),await h.invalidateQueries({queryKey:A.checks()})}}),{mutate:me}=Cn({mutationFn:()=>n(r,u),onSuccess:async()=>{p(``),await h.invalidateQueries({queryKey:A.checks()}),g.push(`${_}/checks`)}}),{mutate:he,isPending:ge}=Cn({mutationFn:async()=>{if(!j)throw Error(`Check not found`);return await t(r,u)},onSuccess:async()=>{S(`Check marked as preset successfully`),await h.invalidateQueries({queryKey:A.check(r)})},onError:e=>{C(`Failed to mark check as preset`,e)}}),_e=V(async()=>{j?.type&&(ee((await e(r,{nowait:!0},u)).run_id),await h.invalidateQueries({queryKey:A.check(r)}),a&&a())},[j,r,h,a,u]),ve=V(async()=>{if(D(!0),oe)return await i(oe,u)},[oe,u]),ye=async()=>{if(!j)return;let e=sc(j);if(!window.isSecureContext){C(`Failed to copy the check to clipboard`,Error(`Copy to clipboard is available only in secure contexts (HTTPS)`));return}try{await navigator.clipboard.writeText(e),S(`Copied the check to the clipboard`)}catch(e){C(`Failed to copy the check to clipboard`,e)}},be=V(()=>{let e=j?.is_checked;fe({is_checked:!e}),e||Ht.create({title:`Marked as approved`,type:`success`,duration:2e3})},[j?.is_checked,fe]),xe=e=>{fe({view_options:e})},Ce=e=>{fe({description:e})},we=e=>{re(e.currentTarget)},F=()=>{re(null)},De=V(()=>{if(!j)return;let e=j.params;v(e?.sql_template||``),`base_sql_template`in e&&e.base_sql_template?(y(e.base_sql_template),b(!0)):(y(``),b(!1)),`primary_keys`in e&&e.primary_keys?x(e.primary_keys):x(void 0),g.push(`${_}/query`)},[j,g,_,v,y,b,x]),[I,Oe]=U(`result`),{ref:Ae,onCopyToClipboard:je,onMouseEnter:Me,onMouseLeave:Pe}=ht(),Fe=Xe({name:j?.name??``,description:j?.description??``,type:j?.type??``,params:j?.params,viewOptions:j?.view_options});if(k)return G(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:`Loading`});if(ae)return K(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:[`Error: `,G(`span`,{className:`no-track-pii-safe`,children:ae.message})]});if(!j)return G(kt,{minSize:100,sizes:[30,70],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:G(q,{style:{contain:`strict`},sx:{display:`flex`,flexDirection:`column`},children:G(q,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40},children:G(Et,{name:`Check not found`,disabled:!0})})})});let Ie=se?.run_at?ii(new Date(se.run_at),{addSuffix:!0}):null,Le=N?.icon;return K(qi,{spacing:0,container:!0,sx:{height:`100%`,width:`100%`},children:[G(qi,{size:{xs:12,md:m?9:12},sx:{height:`100%`},children:K(kt,{minSize:100,sizes:[40,60],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:[G(q,{sx:{height:`100%`,contain:`strict`,display:`flex`,flexDirection:`row`},children:K(q,{sx:{flex:1,height:`100%`,display:`flex`,flexDirection:`column`,overflow:`hidden`,minWidth:0},children:[K(q,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40,borderBottom:`2px solid`,borderColor:l?`grey.700`:`grey.300`},children:[Le&&G(q,{component:Le,sx:{fontSize:20,mr:1,flexShrink:0}}),G(Et,{name:j.name,onNameChange:e=>{fe({name:e})}}),G(q,{sx:{flexGrow:1}}),K(Y,{direction:`row`,spacing:2,sx:{mr:`10px`},children:[de&&G(Q,{title:`This is a preset check`,children:G(q,{display:`flex`,alignItems:`center`,justifyContent:`center`,children:G(Mi,{size:`1rem`,color:s.palette.iochmara.dark})})}),j?.actor_type&&!j.is_preset&&Te[j.actor_type]&&G(wr,{label:Te[j.actor_type].label,size:`small`,sx:{height:20,fontSize:`0.65rem`,fontWeight:500,backgroundColor:Te[j.actor_type].bg,color:Te[j.actor_type].color,flexShrink:0,"& .MuiChip-label":{px:.75}}}),G(Z,{size:`small`,onClick:we,children:G(ei,{})}),K(qr,{anchorEl:ne,open:ie,onClose:F,children:[f&&K(Jr,{onClick:()=>{he(),F()},disabled:ge||de,children:[G(bi,{children:G(Kn,{})}),G(xi,{children:`Mark as Preset Check`})]}),K(Jr,{onClick:()=>{te(!0),F()},children:[G(bi,{children:G(Yi,{})}),G(xi,{children:`Get Preset Check Template`})]}),K(Jr,{onClick:()=>{ye(),F()},children:[G(bi,{children:G(ur,{})}),G(xi,{children:`Copy Markdown`})]}),G(Xn,{}),K(Jr,{onClick:()=>{me(),F()},disabled:d.disableUpdateChecklist,sx:{color:`error.main`},children:[G(bi,{sx:{color:`error.main`},children:G(xr,{})}),G(xi,{children:`Delete`})]})]}),G(Q,{title:We({type:j.type,hasResult:!!se?.result,hasError:!!se?.error})?`Run the check first`:j.is_checked?`Remove approval`:`Mark as approved`,placement:`bottom-end`,children:G(J,{size:`small`,color:j.is_checked?`success`:`neutral`,variant:j.is_checked?`contained`:`outlined`,onClick:()=>{be()},disabled:We({type:j.type,hasResult:!!se?.result,hasError:!!se?.error})||d.disableUpdateChecklist,startIcon:j.is_checked?G(cr,{}):G(Xr,{style:{color:l?s.palette.grey[600]:s.palette.grey[400]}}),sx:{flex:`0 0 auto`,textTransform:`none`},children:j.is_checked?`Approved`:`Pending`})})]})]}),G(q,{sx:{flex:1,p:`8px 16px`,minHeight:100},children:G(Ue,{value:j.description,onChange:Ce,disabled:d.disableUpdateChecklist},j.check_id)})]})}),G(q,{style:{contain:`strict`},children:K(q,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[K(q,{sx:{display:`flex`,alignItems:`center`,borderBottom:1,borderColor:`divider`,height:50},children:[K(si,{value:I,onChange:(e,t)=>Oe(t),children:[G(oi,{label:`Result`,value:`result`,sx:{fontSize:`0.75rem`,textTransform:`none`}}),(j.type===`query`||j.type===`query_diff`)&&G(oi,{label:`Query`,value:`query`,sx:{fontSize:`0.75rem`,textTransform:`none`}})]}),Ie&&G(X,{variant:`caption`,color:`text.secondary`,sx:{ml:1,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0,display:`flex`,alignItems:`center`},children:Ie}),G(q,{sx:{flexGrow:1}}),K(Y,{direction:`row`,spacing:1,sx:{mr:`10px`},children:[(j.type===`query`||j.type===`query_base`||j.type===`query_diff`)&&G(Q,{title:`Open in Query tab`,children:G(J,{variant:`outlined`,color:`neutral`,size:`small`,onClick:De,disabled:d.disableDatabaseQuery,startIcon:G(yi,{}),sx:{textTransform:`none`},children:`Open Query`})}),ue&&G(Q,{title:`Rerun`,children:G(J,{variant:`outlined`,color:`neutral`,size:`small`,onClick:()=>_e(),disabled:d.disableDatabaseQuery||le,startIcon:G(yr,{}),sx:{textTransform:`none`},children:le?`Running...`:`Rerun`})}),G(J,{variant:`outlined`,color:`neutral`,disabled:We({type:j.type,hasResult:!!se?.result,hasError:!!se?.error})||I!==`result`,onMouseEnter:Me,onMouseLeave:Pe,size:`small`,onClick:async()=>{j.type===`lineage_diff`?P.current?.copyToClipboard():await je(),an({type:j.type,from:`check`})},startIcon:G(ur,{}),sx:{textTransform:`none`},children:`Copy to Clipboard`})]})]}),K(q,{sx:{flex:1,contain:`strict`},children:[I===`result`&&K(q,{sx:{width:`100%`,height:`100%`},children:[ue&&(j.last_run||oe?G(ke,{ref:Ae,isRunning:le,isAborting:E,run:oe?se:j.last_run,error:ce,progress:T,RunResultView:ue,viewOptions:j.view_options,onViewOptionsChanged:xe,onCancel:ve,onExecuteRun:_e}):G(q,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:l?`grey.900`:`grey.50`,height:`100%`},children:K(Y,{spacing:2,alignItems:`center`,children:[G(q,{children:`This action is part of the initial preset and has not been performed yet. Once performed, the result will be shown here.`}),G($s,{display:d.mode===`metadata only`,children:G(J,{onClick:_e,variant:`contained`,size:`small`,disabled:d.disableDatabaseQuery,children:`Run Query`})})]})})),j.type===`schema_diff`&&G(ac,{check:j,ref:Ae},j.check_id),j.type===`lineage_diff`&&G(nc,{check:j,ref:P},j.check_id)]}),I===`query`&&(j.type===`query`||j.type===`query_diff`||j.type===`query_base`)&&G(q,{sx:{height:`100%`,width:`100%`},children:j.params.base_sql_template?G(ft,{value:j.params.sql_template||``,baseValue:j.params.base_sql_template??``,options:{readOnly:!0}}):G(Ee,{value:j.params.sql_template||``,options:{readOnly:!0}})})]})]})}),K(Fn,{open:O,onClose:()=>te(!1),maxWidth:`md`,fullWidth:!0,children:[G(Rn,{children:`Preset Check Template`}),K(Ln,{children:[K(X,{variant:`subtitle2`,fontWeight:`bold`,sx:{mb:2},children:[`Please`,` `,G(X,{component:`span`,sx:{cursor:`pointer`,"&:hover":{textDecoration:`underline`},color:`primary.main`},onClick:async()=>{await navigator.clipboard.writeText(Fe),S(`Copied the template to the clipboard`)},children:`copy`}),` `,`the following template and paste it into the`,` `,G(q,{component:`span`,sx:{px:.5,bgcolor:`error.light`,borderRadius:.5},children:`recce.yml`}),` `,`file.`]}),G(Je,{yamlTemplate:Fe})]}),G(In,{children:G(Z,{size:`small`,onClick:()=>te(!1),sx:{position:`absolute`,top:8,right:8},children:G(qn,{})})})]})]})}),m&&G(qi,{size:3,sx:{height:`100%`,overflow:`hidden`,flexShrink:0,display:{xs:`none`,md:`block`}},children:G(Ra,{checkId:r})})]})}function sc(e){return Ji`
7
+ <details><summary>${Fe({name:e.name,isChecked:e.is_checked})}</summary>
8
+
9
+ ${cc(e)}
10
+
11
+ </details>`}function cc(e){let t=je({description:e.description});if(e.type===`query`||e.type===`query_diff`){let n=e.params;return`${t}\n\n${Re({sql:n&&`sql_template`in n?n.sql_template:``})}`}return t}const lc=()=>{let e=Tn(),t=hi(),{apiClient:n}=Ne(),{basePath:r}=pe(),{mutate:i,isPending:a}=Cn({mutationFn:()=>v({select:`state:modified`},n),onSuccess:async n=>{await e.invalidateQueries({queryKey:A.checks()}),t.push(`${r}/checks/?id=${n.check_id}`)}});return G(Ze,{title:`No checks yet`,description:`Checks help you validate data quality and catch issues.`,icon:G(_i,{size:48}),actionText:`Create Schema Diff Check`,onAction:()=>{i()},isLoading:a,helperText:`The schema checks compare modified models between environments to detect changes, additions, or removals.`})},uc=({check:e,selected:t,onSelect:n,onApprovalChange:r})=>{let{featureToggles:i}=Se(),a=e.last_run?.run_id,{run:o}=xt(a),s=We({type:e.type,hasResult:!!o?.result,hasError:!!o?.error}),c=s||i.disableUpdateChecklist;return G(ct,{check:{id:e.check_id,name:e.name,type:e.type,isApproved:e.is_checked,runStatus:(()=>{if(o){if(o.error)return`error`;if(o.result)return`success`}})(),isPreset:e.is_preset,isOutdated:e.is_outdated,lastRunAt:e.last_run?.run_at,actorType:e.actor_type},isSelected:t,onClick:n,onApprovalChange:r,disableApproval:c,disabledApprovalTooltip:s?`Run the check first`:void 0})},dc=({checks:e,selectedItem:t,onCheckSelected:n,onChecksReordered:r})=>{let[i,a]=U(!1),[s,c]=U(!1),[l,u]=U(null),d=Tn(),{apiClient:f}=Ne(),{mutate:p}=Cn({mutationFn:({checkId:e,isChecked:t})=>o(e,{is_checked:t},f),onSuccess:async(e,{checkId:t})=>{await d.invalidateQueries({queryKey:A.check(t)}),await d.invalidateQueries({queryKey:A.checks()})}}),m=e=>{e.destination&&r(e.source.index,e.destination.index)},h=()=>c(!0),g=()=>{c(!1),u(null)},_=()=>{Ht.create({title:`Marked as approved`,type:`success`,duration:2e3})},v=(e,t)=>{t?localStorage.getItem(`bypassMarkAsApprovedWarning`)===`true`?(p({checkId:e,isChecked:!0}),_()):(u(e),h()):p({checkId:e,isChecked:!1})};return K(W,{children:[G(Xi,{onDragEnd:m,children:G(Qi,{droppableId:`checklist`,children:r=>K(Y,{...r.droppableProps,ref:r.innerRef,className:`no-track-pii-safe`,sx:{width:`100%`,flex:1,overflow:`auto`},spacing:0,children:[e.map((e,r)=>G(Zi,{draggableId:e.check_id,index:r,children:(r,i)=>{let a=r.draggableProps.style;if(i.isDragging&&a&&`left`in a){let e={x:0,y:80};a={...a,left:a.left-e.x,top:a.top-e.y}}return G(q,{ref:r.innerRef,...r.draggableProps,...r.dragHandleProps,style:a,sx:{width:`100%`},borderBottom:`1px solid`,borderColor:`divider`,children:G(uc,{check:e,selected:e.check_id===t,onSelect:n,onApprovalChange:v},e.check_id)})}},e.check_id)),r.placeholder]})})}),K(Fn,{open:s,onClose:g,maxWidth:`xs`,fullWidth:!0,children:[K(Rn,{sx:{display:`flex`,alignItems:`center`},children:[`Mark as Approved?`,G(q,{sx:{flexGrow:1}}),G(Z,{size:`small`,onClick:g,children:G(qn,{})})]}),G(Xn,{}),K(Ln,{sx:{fontSize:`0.875rem`},children:[G(X,{children:`Please ensure you have reviewed the contents of this check before marking it as approved.`}),G(Ur,{control:G(Hr,{checked:i,onChange:e=>{a(e.target.checked)},size:`small`}),label:G(X,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),G(Xn,{}),K(In,{sx:{gap:0},children:[G(J,{variant:`outlined`,size:`small`,onClick:g,children:`Cancel`}),G(J,{color:`iochmara`,variant:`contained`,size:`small`,onClick:()=>{l&&(p({checkId:l,isChecked:!0}),i&&localStorage.setItem(`bypassMarkAsApprovedWarning`,`true`),_(),g(),u(null))},children:`Mark as approved`})]})]})]})},fc=()=>{let e=Un().palette.mode===`dark`?`grey.700`:`grey.300`,t=hi(),n=gi().get(`id`),{latestSelectedCheckId:r,setLatestSelectedCheckId:i}=L(),a=Tn(),{apiClient:o}=Ne(),{basePath:s}=pe(),c=n;jn(()=>{c&&i(c)},[c,i]);let{isLoading:l,error:u,data:d,status:f,refetch:p}=wn({queryKey:A.checks(),queryFn:()=>x(o),refetchOnMount:!0}),m=V(e=>{t.push(`${s}/checks/?id=${e}`)},[t.push,s]),[h,g]=U(d??[]),[_,v]=U(d);d!==_&&(v(d),g(d??[]));let{mutate:y}=Cn({mutationFn:e=>b(e,o),onSuccess:async()=>{await a.invalidateQueries({queryKey:A.checks()})}}),S=V((e,t)=>{let n=[...h],[r]=n.splice(e,1);n.splice(t,0,r),y({source:e,destination:t}),g(n)},[h,y]),C=H(()=>!!(c&&d?.some(e=>e.check_id===c)),[c,d]);return jn(()=>{f!==`success`||d.length===0||C||(r&&d.some(e=>e.check_id===r)?t.replace(`${s}/checks/?id=${r}`):t.replace(`${s}/checks/?id=${d[0].check_id}`))},[f,C,d,r,t.replace,s]),l?null:u?K(q,{children:[`Error: `,G(`span`,{className:`no-track-pii-safe`,children:u.message})]}):d?.length?K(mt,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[G(q,{sx:{height:`100%`},style:{contain:`size`},children:K(Y,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[G(q,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:G(ec,{checksOnly:!0})}),G(Xn,{}),G(dc,{checks:h,selectedItem:c,onCheckSelected:m,onChecksReordered:S})]})}),G(q,{sx:{height:`100%`},children:C&&c&&G(oc,{checkId:c,refreshCheckList:p},c)})]}):K(mt,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[G(q,{sx:{borderRight:`1px solid`,borderRightColor:e,height:`100%`},style:{contain:`size`},children:K(Y,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[G(q,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:G(ec,{checksOnly:!0})}),G(Xn,{}),G(q,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(q,{sx:{textAlign:`center`,color:`grey.500`},children:`No checks`})})]})}),G(q,{children:G(q,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(lc,{})})})]})},pc=()=>K(mt,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[G(q,{sx:{borderRight:`1px solid`,borderRightColor:Un().palette.mode===`dark`?`grey.700`:`grey.300`,height:`100%`},style:{contain:`size`},children:G(q,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(Zn,{size:20})})}),G(q,{children:G(q,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:G(Zn,{size:20})})})]}),mc={added:[`Model Added`,`Added resource`],removed:[`Model Removed`,`Removed resource`],modified:[`Model Modified`,`Modified resource`],col_added:[`Column Added`,`Added column`],col_removed:[`Column Removed`,`Removed column`],col_changed:[`Column Modified`,`Modified column`],folder_changed:[`Modified`,`Modified folder`]};function hc(e){let t=String(we(`colors.green.solid`)),n=String(we(`colors.red.solid`)),r=String(we(`colors.amber.emphasized`));return e===`added`?{color:t,icon:jt}:e===`removed`?{color:n,icon:Pt}:e===`modified`?{color:r,icon:rt}:e===`col_added`?{color:t,icon:jt}:e===`col_removed`?{color:n,icon:Pt}:e===`col_changed`?{color:r,icon:rt}:e===`folder_changed`?{color:r,icon:Ft}:{color:`inherit`,icon:void 0}}function gc(e,t){let n=0,r=0,i=0;return!e&&!t?{adds:n,removes:r,modifies:i}:(t&&Object.keys(t.columns??{}).forEach(t=>{e?.columns?.[t]||n++}),e&&Object.keys(e.columns??{}).forEach(e=>{t?.columns?.[e]||r++}),t&&e&&Object.keys(t.columns??{}).forEach(n=>{e.columns&&t.columns?.[n]&&e.columns[n]&&e.columns[n].type!==t.columns[n].type&&i++}),{adds:n,removes:r,modifies:i})}function _c(e){let t=e.modifiedSet,n=0,r=0,i=0,a=0,o=0,s=0;return t.forEach(t=>{e.nodes[t].data.changeStatus===`added`?n++:e.nodes[t].data.changeStatus===`removed`?r++:e.nodes[t].data.changeStatus===`modified`&&i++;let c=e.nodes[t].data.data.base,l=e.nodes[t].data.data.current,u=gc(c,l);a+=u.adds,o+=u.removes,s+=u.modifies}),{adds:n,removes:r,modifies:i,col_added:a,col_removed:o,col_changed:s}}function vc({name:e,value:t,tip:n}){return K(Y,{alignItems:`stretch`,children:[K(X,{sx:{fontSize:`0.875rem`,color:`grey.600`},children:[e,n&&G(Q,{title:n,children:G(q,{sx:{display:`inline-block`},children:G(q,{component:wi,sx:{mx:`2px`,fontSize:12,verticalAlign:`middle`}})})})]}),t]})}function yc({changeStatus:e,value:t}){let[n]=e?mc[e]:[``],{icon:r,color:i}=hc(e);return K(Y,{alignItems:`stretch`,children:[K(Y,{direction:`row`,alignItems:`center`,sx:{fontSize:`0.875rem`,color:`grey.600`},children:[r&&G(q,{component:r,sx:{mr:`5px`,color:i,fontSize:`1rem`}}),n]}),G(X,{sx:{fontSize:`0.875rem`},children:t})]})}function bc({lineageGraph:e}){let{adds:t,removes:n,modifies:r,col_added:i,col_removed:a,col_changed:o}=_c(e);return K(qi,{container:!0,sx:{mb:`10px`,borderTop:`1px solid`,borderColor:`divider`,p:`2.5vw`},children:[G(qi,{size:6,sx:{borderColor:`divider`},children:G(vc,{name:`Code Changes`,value:K(qi,{container:!0,sx:{width:`100%`},children:[G(qi,{size:4,children:G(yc,{changeStatus:`added`,value:t})}),G(qi,{size:4,children:G(yc,{changeStatus:`removed`,value:n})}),G(qi,{size:4,children:G(yc,{changeStatus:`modified`,value:r})})]})})}),G(qi,{size:6,sx:{borderLeft:`1px solid`,borderLeftColor:`divider`,pl:`12px`},children:G(vc,{name:`Column Changes`,value:K(qi,{container:!0,sx:{width:`100%`},children:[G(qi,{size:4,children:G(yc,{changeStatus:`col_added`,value:i})}),G(qi,{size:4,children:G(yc,{changeStatus:`col_removed`,value:a})}),G(qi,{size:4,children:G(yc,{changeStatus:`col_changed`,value:o})})]})})})]})}function xc({node:e,...t}){return K($i,{sx:{maxWidth:500},children:[G(ta,{title:G(X,{sx:{fontSize:18,fontWeight:`bold`},children:t.title}),subheader:K(Y,{direction:`row`,spacing:`8px`,sx:{p:`16px`},children:[G(St,{resourceType:e.data.resourceType,materialized:e.data.data.current?.config?.materialized??e.data.data.base?.config?.materialized}),e.data.resourceType===`model`&&G(Fo,{node:e})]})}),G(ea,{children:G(q,{sx:{display:`flex`},children:G(Ao,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns})})})]})}function Sc(e){let t=[],n=e.nodes;return e.modifiedSet.forEach(e=>{let r=n[e],i=zt(Object.keys(r.data.data.base?.columns??{}),Object.keys(r.data.data.current?.columns??{}));!Object.values(i).every(e=>e===void 0)&&r.data.data.base&&r.data.data.current&&t.push(r)}),t}function Cc({lineageGraph:e}){let[t,n]=U([]);return jn(()=>{n(Sc(e))},[e]),K(W,{children:[G(q,{sx:{width:`100%`,pb:`10px`,mb:`20px`,mt:`20px`},children:G(X,{variant:`h5`,sx:{fontSize:24},children:`Schema Summary`})}),G(q,{sx:{width:`100%`,pb:`10px`,mb:`20px`},children:t.length===0?G(X,{sx:{fontSize:18,color:`grey.600`},children:`No schema changes detected.`}):G(q,{sx:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(400px, 1fr))`,gap:`2vw`,p:`2.5vw`,width:`100%`,bgcolor:`lightgray`},children:t.map(e=>G(xc,{title:e.data.name,node:e},e.id))})})]})}function wc({checks:e,isLoading:t,error:n,selectedCheckId:r,onCheckSelect:i,onApprovalChange:a,onAction:o,onReorder:s,onDescriptionChange:c,onNameChange:l,onCreateCheck:u,getCheckTabs:d,getPrimaryActions:f,getSecondaryActions:p,disableApproval:m=!1,disabledApprovalTooltip:h,height:g=`100%`,listPaneSize:_=30,minListSize:v=200,maxListSize:y=500,listTitle:b,className:x}){let S=Le(),C=e??S.checks,w=t===void 0?S.isLoading:t,ee=n??S.error,T=r??S.selectedCheckId,E=i??S.onSelectCheck,D=H(()=>C.map(e=>({id:e.check_id,name:e.name,type:e.type,description:e.description,isApproved:e.is_checked})),[C]),O=H(()=>C.find(e=>e.check_id===T),[C,T]),te=V(e=>{E?.(e)},[E]),ne=V((e,t)=>{o?.(e,t)},[o]),re=V(e=>{T&&c?.(T,e)},[T,c]),ie=V(e=>{T&&l?.(T,e)},[T,l]);if(w)return G(q,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(Zn,{})});if(ee)return G(q,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(X,{color:`error`,children:ee})});if(C.length===0)return G(q,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(Ze,{title:`No checks yet`,description:`Create your first check to start validating your data.`,actionText:`Create Check`,onAction:u})});let k=O?d?.(O):void 0,A=O?f?.(O):void 0,ae=O?p?.(O):void 0;return G(q,{className:x,sx:{width:`100%`,height:g},children:K(st,{direction:`horizontal`,sizes:[_,100-_],minSizes:[v,200],maxSizes:[y,1/0],children:[G(q,{sx:{height:`100%`,overflow:`auto`},children:G(Qe,{checks:D,selectedId:T,onCheckSelect:te,onApprovalChange:a,onReorder:s,disableApproval:m,disabledApprovalTooltip:h,title:b})}),G(q,{sx:{height:`100%`,overflow:`auto`},children:O?G($e,{checkId:O.check_id,name:O.name,type:O.type,description:O.description,isApproved:O.is_checked,tabs:k,primaryActions:A,secondaryActions:ae,onAction:ne,onDescriptionChange:re,onNameChange:ie}):G(q,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(X,{color:`text.secondary`,children:`Select a check from the list to view details`})})})]})})}const Tc=kn(wc);Tc.displayName=`ChecksView`;const Ec=`0.2.0`;export{Va as A,jo as C,yo as D,bo as E,ra as F,za as M,sa as N,_o as O,ia as P,Ao as S,wo as T,Ms as _,_c as a,Go as b,mc as c,dc as d,lc as f,Ks as g,Zs as h,bc as i,Ba as j,Ua as k,pc as l,Qs as m,Tc as n,gc as o,oc as p,Cc as r,hc as s,Ec as t,fc as u,Ds as v,Eo as w,Do as x,ls as y};
12
+ //# sourceMappingURL=src-0UNempLN.js.map