From 5a2d6492afe44daa140079c8d3bbe5145f5b648c Mon Sep 17 00:00:00 2001 From: popcornylu Date: Mon, 18 Mar 2024 09:04:08 +0000 Subject: [PATCH] AUTO-COMMIT - build js statics to recce data/ --- recce/data/404.html | 2 +- recce/data/_next/static/chunks/app/page-1b2bb2b388afdc98.js | 1 + recce/data/_next/static/chunks/app/page-f175b9de49fe2892.js | 1 - .../_buildManifest.js | 0 .../_ssgManifest.js | 0 recce/data/index.html | 4 ++-- recce/data/index.txt | 4 ++-- 7 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 recce/data/_next/static/chunks/app/page-1b2bb2b388afdc98.js delete mode 100644 recce/data/_next/static/chunks/app/page-f175b9de49fe2892.js rename recce/data/_next/static/{KuSRJvWbFxUBbU9XQmDGM => lcS0p0b89tL3OsryBWzU2}/_buildManifest.js (100%) rename recce/data/_next/static/{KuSRJvWbFxUBbU9XQmDGM => lcS0p0b89tL3OsryBWzU2}/_ssgManifest.js (100%) diff --git a/recce/data/404.html b/recce/data/404.html index efe5d79f..86535904 100644 --- a/recce/data/404.html +++ b/recce/data/404.html @@ -1 +1 @@ -404: This page could not be found.recce

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.recce

404

This page could not be found.

\ No newline at end of file diff --git a/recce/data/_next/static/chunks/app/page-1b2bb2b388afdc98.js b/recce/data/_next/static/chunks/app/page-1b2bb2b388afdc98.js new file mode 100644 index 00000000..c16c8dd7 --- /dev/null +++ b/recce/data/_next/static/chunks/app/page-1b2bb2b388afdc98.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{99178:function(e,n,t){Promise.resolve().then(t.bind(t,76625))},76625:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Home}});var r=t(757),i=t(27869);function getNeighborSet(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,r=new Set,i={},dfs=(e,t)=>{if(t<0||void 0!==i[e]&&i[e]>=t)return;i[e]=t;let l=n(e);for(let e of l)dfs(e,t-1);r.add(e)};for(let n of e)dfs(n,t);return r}function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{r.add(e)})}),r}function buildLineageGraph(e,n){let t={},r={},buildNode=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,r]of Object.entries(e.parent_map)){t[n]=buildNode(n,"base");let r=e.nodes&&e.nodes[n];r&&(t[n].data.base=r,t[n].name=null==r?void 0:r.name,t[n].resourceType=null==r?void 0:r.resource_type,t[n].packageName=null==r?void 0:r.package_name)}for(let[e,r]of Object.entries(n.parent_map)){t[e]?t[e].from="both":t[e]=buildNode(e,"current");let r=n.nodes&&n.nodes[e];r&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==r?void 0:r.name,t[e].resourceType=null==r?void 0:r.resource_type,t[e].packageName=null==r?void 0:r.package_name)}for(let[n,i]of Object.entries(e.parent_map))for(let e of i){let i=t[n],l=t[e],o="".concat(e,"_").concat(n);r[o]={id:o,from:"base",parent:l,child:i};let a=r[o];i.parents[e]=a,l.children[n]=a}for(let[e,i]of Object.entries(n.parent_map))for(let n of i){let i=t[e],l=t[n],o="".concat(n,"_").concat(e);r[o]?r[o].from="both":r[o]={id:o,from:"current",parent:l,child:i};let a=r[o];i.parents[n]=a,l.children[e]=a}let i=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",i.push(n.id);else if("current"===n.from)n.changeStatus="added",i.push(n.id);else{var l,o,a,s,c,d;let e=null==n?void 0:null===(a=n.data)||void 0===a?void 0:null===(o=a.base)||void 0===o?void 0:null===(l=o.checksum)||void 0===l?void 0:l.checksum,t=null==n?void 0:null===(d=n.data)||void 0===d?void 0:null===(c=d.current)||void 0===c?void 0:null===(s=c.checksum)||void 0===s?void 0:s.checksum;e&&t&&e!==t&&(n.changeStatus="modified",i.push(n.id))}for(let[e,n]of Object.entries(r))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{nodes:t,edges:r,modifiedSet:i,catalogExistence:{base:!!e.catalog_metadata,current:!!n.catalog_metadata}}}function selectUpstream(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].parents),t)}function selectDownstream(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children),t)}function toReactflow(e,n){let t=[],r=[],l=new Set;for(let n of e)t.push({id:n.id,position:{x:0,y:0},data:n,type:"customNode",targetPosition:i.Ly.Left,sourcePosition:i.Ly.Right}),l.add(n.id);for(let e of n)l.has(e.parent.id)&&l.has(e.child.id)&&r.push({id:e.id,type:"customEdge",source:e.parent.id,target:e.child.id,data:e});return[t,r]}function highlightNodes(e,n,t){let r=new Set(e),i=new Set(t.filter(e=>r.has(e.source)&&r.has(e.target)).map(e=>e.id)),l=n.map(e=>({...e,data:{...e.data,isHighlighted:r.has(e.id)}})),o=t.map(e=>({...e,data:{...e.data,isHighlighted:i.has(e.id)}}));return[l,o]}function selectSingleNode(e,n){let t=n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:t}}});return t}function selectNode(e,n){let t=n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:n.data.isSelected!==t}}});return t}function selectNodes(e,n){let t=n.map(n=>{let t=e.includes(n.id);return{...n,data:{...n.data,isSelected:n.data.isSelected||t}}});return t}function cleanUpNodes(e,n){let t=e.map(e=>({...e,data:{...e.data,isSelected:!1,isActionMode:n,action:void 0}}));return t}var l=t(10126),o=t(83172),a=t(55528),s=t(29330),c=t(46543),d=t(76920),u=t(39668),h=t(83179),m=t(62648),x=t(43093),f=t(40312),p=t(36700),g=t(10287),y=t(48950),v=t(27726),j=t(26187),C=t(23704),b=t(33710),k=t(93864),w=t.n(k);t(94570);var _=t(90593),S=t(11180),R=t(63240),D=t(54057);let N=S.Nbv,T=S.sFB,E=S.UGs;function getIconForChangeStatus(e){return"added"===e?{color:"#1dce00",icon:N}:"removed"===e?{color:"#ff4444",icon:T}:"modified"===e?{color:"#ffa502",icon:E}:{color:"inherit",icon:void 0}}function getIconForResourceType(e){return"model"===e?{color:"#c0eafd",icon:R.Fn3}:"metric"===e?{color:"#ffe6ee",icon:D._MV}:"source"===e?{color:"#a6dda6",icon:R.i1q}:"exposure"===e?{color:"#ffe6ee",icon:D.n8P}:"semantic_model"===e?{color:"#fb8caf",icon:D.R1C}:"seed"===e?{color:"#a6dda6",icon:R.tWi}:{color:"inherit",icon:void 0}}t(88727);var I=t(85036),L=t(49294),F=t(46016),z=t(19920),A=t(19103),M=t(95913),O=t(89042),P=t(10929),V=t(12218);let B=V.env.NEXT_PUBLIC_API_URL?V.env.NEXT_PUBLIC_API_URL:window.location.origin;var q=t(27471);let H=P.default.create({baseURL:B}),K=new q.S;async function submitRun(e,n,t){let r=await H.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait}),i=r.data;return i}async function waitRun(e,n){let t=await H.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}}),r=t.data;return r}async function cancelRun(e){return await H.post("/api/runs/".concat(e,"/cancel"))}async function submitRunFromCheck(e,n){let t=await H.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait}),r=t.data;return r}async function searchRuns(e,n,t){let r=await H.post("/api/runs/search",{type:e,params:n,limit:t});return r.data}async function aggregateRuns(){let e=await H.post("/api/runs/aggregate",{});return e.data}async function submitRowCountDiff(e,n){return await submitRun("row_count_diff",e,n)}async function queryModelRowCount(e){let{result:n}=await queryRowCount([e]);return n[e]}async function queryRowCount(e){if(0===e.length)throw Error("No model names provided");let{run_id:n}=await submitRowCountDiff({node_names:e},{nowait:!0}),t=await waitRun(n);return{runId:n,result:t.result}}let W={rowCount:e=>["row_count",e],lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],run:e=>["runs",e],runsAggregated:()=>["runs_aggregated"]};var U=t(44903),G=t(62516),Q=t(35537),J=t(99691);async function getLineage(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=await H.get("/api/lineage?base=".concat(e));return n.data}async function getLineageWithError(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let n=await getLineage(e);return{data:n}}catch(e){if(!(e instanceof J.d7))return{error:null==e?void 0:e.message};{var n,t;let r=null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(n=t.data)||void 0===n?void 0:n.detail;if(r)return{error:r};return{error:null==e?void 0:e.message}}}}async function getLineageDiff(){let[e,n]=await Promise.all([getLineageWithError(!0),getLineageWithError(!1)]);return{base:e.data,current:n.data,base_error:e.error,current_error:n.error}}var Z=t(15550),X=t(21123),Y=t.n(X);let $=(0,v.createContext)({});function LineageWatcher(e){let{refetch:n}=e,t=(0,Z.p)(),[i,l]=(0,v.useState)(),o=(0,Q.NL)();return(0,v.useEffect)(()=>{function httpUrlToWebSocketUrl(e){return e.replace(/(http)(s)?\:\/\//,"ws$2://")}let e=new WebSocket("".concat(httpUrlToWebSocketUrl(B),"/api/ws"));return l(e),e.onopen=()=>{e.send("ping")},e.onmessage=e=>{if("pong"!==e.data)try{let n=JSON.parse(e.data);if("refresh"===n.command){let{eventType:e,srcPath:r}=n.event,[i,l]=r.split("/").slice(-2),a=Y().parse(l).name;t({description:"Detected ".concat(i," ").concat(a," ").concat(e),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),o.invalidateQueries({queryKey:W.lineage()})}}catch(e){console.error(e)}},()=>{e&&e.close()}},[t,o]),(0,r.jsx)(r.Fragment,{})}function LineageGraphContextProvider(e){let{children:n}=e,{data:t,isLoading:i,error:l,refetch:o}=(0,U.a)({queryKey:W.lineage(),queryFn:getLineageDiff}),{data:a,refetch:s}=(0,U.a)({queryKey:W.runsAggregated(),queryFn:aggregateRuns}),c=(0,v.useMemo)(()=>{if(t)return buildLineageGraph(t.base,t.current)},[t]),d=(null==l?void 0:l.message)||(null==t?void 0:t.current_error)||(null==t?void 0:t.base_error);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(LineageWatcher,{refetch:o}),(0,r.jsx)($.Provider,{value:{lineageGraph:c,metadata:null==t?void 0:t.current.metadata,isDemoSite:!!(null==t?void 0:t.current.metadata.pr_url),error:d,isLoading:i,runsAggregated:a,refetchRunsAggregated:()=>{s()}},children:n})]})}let useLineageGraphContext=()=>(0,v.useContext)($),useRunsAggregated=()=>{let{runsAggregated:e,refetchRunsAggregated:n}=useLineageGraphContext();return[e,n]};function deltaPercentageString(e,n){if(e=.1?t.toFixed(1):" <0.1 ","%")}if(!(e>n))return"0 %";{let t=(e-n)/e*100;return"-".concat(t>=.1?t.toFixed(1):" <0.1 ","%")}}var ee=t(79935);function ResourceTypeTag(e){let{node:n}=e,{icon:t}=getIconForResourceType(n.resourceType);return(0,r.jsx)(o.u,{hasArrow:!0,label:"Type of resource",children:(0,r.jsxs)(z.Vp,{children:[(0,r.jsx)(z.AD,{as:t}),(0,r.jsx)(z.Sn,{children:n.resourceType})]})})}function _RowCountByRate(e){let{rowCount:n}=e,t=n.base,i=n.curr,l=null===n.base?"N/A":"".concat(n.base," rows"),o=null===n.curr?"N/A":"".concat(n.curr," rows");return null===t&&null===i?(0,r.jsx)(r.Fragment,{children:" Failed to load"}):null===t||null===i?(0,r.jsxs)(m.U,{children:[(0,r.jsx)(x.x,{children:l}),(0,r.jsx)(s.J,{as:O.Rgz}),(0,r.jsx)(x.x,{children:o})]}):t===i?(0,r.jsxs)(m.U,{children:[(0,r.jsx)(x.x,{children:o}),(0,r.jsx)(s.J,{as:G.lxc,color:"gray.500"}),(0,r.jsx)(x.x,{color:"gray.500",children:"No Change"})]}):tqueryModelRowCount(a.name),enabled:!1,initialData:l}),f=h||l||u;if(f){let e=(null==f?void 0:f.base)===null?"N/A":null==f?void 0:f.base,n=(null==f?void 0:f.curr)===null?"N/A":null==f?void 0:f.curr;i="".concat(e," -> ").concat(n," rows")}return(0,r.jsx)(o.u,{label:i,children:(0,r.jsxs)(z.Vp,{children:[(0,r.jsx)(z.AD,{as:O.SwK}),(0,r.jsx)(z.Sn,{children:f||x?(0,r.jsx)(A.N,{isLoaded:!x,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:f?(0,r.jsx)(_RowCountByRate,{rowCount:f}):"row count"}):(0,r.jsx)(r.Fragment,{children:"row count"})}),s&&(0,r.jsx)(z.bq,{as:M.h,isLoading:x,"aria-label":"Query Row Count",icon:(0,r.jsx)(ee.n,{}),size:"xs",onClick:async()=>{await m(),null==d||d()}})]})})}let ActionTag=e=>{let{node:n,action:t}=e,{status:i,skipReason:s,run:c}=t;if("pending"===i)return(0,r.jsx)(F.D,{size:"20px",value:0});if("skipped"===i)return(0,r.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,r.jsx)(l.xu,{children:"Skipped"}),s&&(0,r.jsx)(o.u,{label:s,children:(0,r.jsx)(I.s,{})})]});if(!c)return(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px"});let{error:d,result:u,run_id:h,progress:m}=c;if("running"===i)return(null==m?void 0:m.percentage)===void 0?(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px"}):(0,r.jsx)(F.D,{size:"20px",value:(null==m?void 0:m.percentage)*100});if(d)return(0,r.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,r.jsx)(l.xu,{children:"Error"}),s&&(0,r.jsx)(o.u,{label:d,children:(0,r.jsx)(L.a,{})})]});if("value_diff"===c.type){let e=0;for(let n of u.data.data)n[2]<1&&e++;return(0,r.jsx)(z.Vp,{children:(0,r.jsx)(z.Sn,{children:(0,r.jsx)(a.k,{fontSize:"10pt",color:e>0?"red":"green",alignItems:"center",gap:"3px",children:e>0?"".concat(e," columns mismatched"):"All columns match"})})})}if("row_count_diff"===c.type){let e=c.result;return(0,r.jsx)(RowCountTag,{rowCount:e[n.name],node:n,isInteractive:!1})}return(0,r.jsx)(r.Fragment,{children:h})},NodeRunsAggregated=e=>{let n,{id:t}=e,{runsAggregated:i}=useLineageGraphContext(),c=null==i?void 0:i[t];if(!c)return(0,r.jsx)(r.Fragment,{});if(c.row_count_diff){let e=c.row_count_diff;n=e.result.curr!==e.result.base}return(0,r.jsx)(a.k,{children:void 0!==n&&(0,r.jsx)(o.u,{label:"Row count (".concat(n?"changed":"no change",")"),openDelay:500,children:(0,r.jsx)(l.xu,{height:"16px",children:(0,r.jsx)(s.J,{as:O.SwK,color:n?getIconForChangeStatus("modified").color:getIconForChangeStatus().color})})})})};function GraphNode(e){var n,t;let c,{data:d}=e,{isHighlighted:u,isSelected:h,resourceType:x,changeStatus:f}=d,p=(0,i.oR)(e=>e.transform[2]>.3),{icon:g}=getIconForResourceType(x),y="gray.400",v="solid";f&&(c=getIconForChangeStatus(f).icon,y=getIconForChangeStatus(f).color);let j=y,C=d.isSelected?"rgba(3, 102, 214, 0.5) 5px 5px 10px 3px":"unset",b=null==d?void 0:d.name;return(0,r.jsx)(o.u,{label:"model"===x?b:"".concat(b," (").concat(x,")"),placement:"top",children:(0,r.jsxs)(a.k,{width:"300px",_hover:{backgroundColor:p?"gray.100":y},borderColor:j,borderWidth:1,borderStyle:v,backgroundColor:p?"white":y,borderRadius:3,boxShadow:C,transition:"box-shadow 0.2s ease-in-out",padding:0,className:!0===u?"node-highlight":!0===h?"node-highlight":!1===u?"node-unhighlight":void 0,children:[(0,r.jsx)(a.k,{backgroundColor:y,padding:2,borderRightWidth:1,borderColor:j,borderStyle:v,alignItems:"top",visibility:p?"inherit":"hidden",children:(0,r.jsx)(s.J,{as:g})}),(0,r.jsxs)(a.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",children:[(0,r.jsxs)(a.k,{width:"100%",textAlign:"left",flex:"1",p:1,alignItems:"center",visibility:p?"inherit":"hidden",children:[(0,r.jsx)(l.xu,{flex:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:b}),c&&(0,r.jsx)(a.k,{children:(0,r.jsx)(s.J,{color:y,as:c,flex:"0 0 20px"})})]}),(0,r.jsx)(a.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:p?"inherit":"hidden",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(_.L,{}),d.isActionMode?d.action?(0,r.jsx)(ActionTag,{node:d,action:d.action}):(0,r.jsx)(r.Fragment,{}):"model"===d.resourceType?(0,r.jsx)(NodeRunsAggregated,{id:d.id}):(0,r.jsx)(r.Fragment,{})]})})]}),Object.keys(null!==(n=null==d?void 0:d.parents)&&void 0!==n?n:{}).length>0&&(0,r.jsx)(i.HH,{type:"target",position:i.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==d?void 0:d.children)&&void 0!==t?t:{}).length>0&&(0,r.jsx)(i.HH,{type:"source",position:i.Ly.Right,isConnectable:!1})]})})}function GraphEdge(e){let{sourceX:n,sourceY:t,targetX:l,targetY:o,sourcePosition:a,targetPosition:s,style:c={},markerEnd:d,data:u}=e,h={...c};(null==u?void 0:u.changeStatus)&&(h.stroke=getIconForChangeStatus(null==u?void 0:u.changeStatus).color,h.strokeDasharray="5"),(null==u?void 0:u.isHighlighted)===!1&&(h.filter="opacity(0.2) grayscale(50%)");let[m]=(0,i.OQ)({sourceX:n,sourceY:t,sourcePosition:a,targetX:l,targetY:o,targetPosition:s});return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(i.u5,{path:m,markerEnd:d,style:{...h,...c}})})}var en=t(67907),et=t(17714),er=t(74796),ei=t(79315),el=t(7752),eo=t(94410),ea=t(23330),es=t(58909),ec=t(29985),ed=t(42524),eu=t(2593),eh=t(55344),em=t(1726),ex=t(83622),ef=t(21801),ep=t(29731),eg=t(18974);function mergeKeys(e,n){let t=[...e],r=[...n],i=[];for(;t.length>0&&r.length>0;)if(i.includes(t[0]))t.shift();else if(i.includes(r[0]))r.shift();else if(t[0]===r[0])i.push(t[0]),t.shift(),r.shift();else if(r.includes(t[0])){let e=r.indexOf(t[0]);for(let n=0;n{i.includes(e)||i.push(e)}),r.forEach(e=>{i.includes(e)||i.push(e)}),i}function mergeKeysWithStatus(e,n){let t=mergeKeys(e,n),r={};for(let i of t)e.includes(i)?n.includes(i)?r[i]=void 0:r[i]="removed":r[i]="added";let i={};e.forEach((e,n)=>{i[e]=n});let l=-1;for(let e of t){let n=i[e];void 0!==n&&(n>l?l=n:r[e]="reordered")}return r}function mergeColumns(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={},r=mergeKeysWithStatus(Object.keys(e),Object.keys(n));return Object.entries(r).forEach(e=>{let[n,r]=e;t[n]={name:n,reordered:"reordered"===r}}),Object.entries(e).map((e,n)=>{let[r,i]=e;t[r].baseIndex=n+1,t[r].baseType=i.type}),Object.entries(n).map((e,n)=>{let[r,i]=e;t[r].currentIndex=n+1,t[r].currentType=i.type}),t}function toDataGrid(e){function columnIndexCellClass(e){return void 0===e.baseIndex?"column-index-added":void 0===e.currentIndex?"column-index-removed":!0===e.reordered?"column-index-reordered":"column-index-normal"}function columnNameCellClass(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":!0===e.reordered?"column-body-reordered":"column-body-normal"}function columnTypeCellClass(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":e.baseType!==e.currentType?"column-body-type-changed":!0===e.reordered?"column-body-reordered":"column-body-normal"}let n=Object.values(e);return{columns:[{key:"baseIndex",name:"",resizable:!0,minWidth:35,cellClass:columnIndexCellClass},{key:"currentIndex",name:"",resizable:!0,minWidth:35,cellClass:columnIndexCellClass},{key:"name",name:"Name",resizable:!0,cellClass:columnNameCellClass},{key:"baseType",name:"Base Type",resizable:!0,cellClass:columnTypeCellClass},{key:"currentType",name:"Current Type",resizable:!0,cellClass:columnTypeCellClass}],rows:n}}t(75165),t(91702);var ey=t(93683),ev=t(7873),ej=t(52116),eC=t(47367),eb=t(17072),ek=t(84680),ew=t(55201),e_=t.n(ew);function useClipBoardToast(){let e=(0,Z.p)();return{successToast:function(n){e({description:n,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})},failToast:function(n,t){e({title:n,description:"".concat(t),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}}}var eS=t(16062),eR=t(68686),eD=t.n(eR);let eN="ignore-screenshot";function useToBlob(e){let{imageType:n="png",backgroundColor:t=null,boardEffect:r=!0,shadowEffect:i=!1,borderStyle:l="solid 1px #ccc",borderRadius:o="10px",onSuccess:a,onError:s,ignoreElements:c}=e,[d,u]=(0,v.useState)("idle"),h=(0,v.useRef)(null),toImage=async()=>{if(!h.current){console.error("No node to use for screenshot"),u("error"),s&&s(Error("No node to use for screenshot"));return}let e=h.current.element||h.current,d=e.style.overflow,m=e.style.border,x=e.style.borderRadius,f=e.style.backgroundColor;function resetStyles(){e.style.overflow=d,e.style.border=m,e.style.borderRadius=x,e.style.backgroundColor=f}try{var p;e.style.overflow="hidden",e.style.border=r?l:"",e.style.borderRadius=r?o:"",e.style.backgroundColor=t||"";let d=document.createElement("style");document.head.appendChild(d),null===(p=d.sheet)||void 0===p||p.insertRule("body > div:last-child img { display: inline-block; }"),u("loading");let h=await e_()(e,{logging:!1,backgroundColor:null,ignoreElements:c});d.remove();let m=i?document.createElement("canvas"):h;if(i){m.width=h.width+80,m.height=h.height+80;let e=m.getContext("2d");if(e)e.shadowColor="rgba(0, 0, 0, 0.5)",e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(h,40,40);else{console.error("Error getting canvas context"),u("error"),s&&s(Error("Error getting canvas context to add shadow effect"));return}}m.toBlob(async e=>{u("success"),a&&e&&await a(e)},"image/".concat(n))}catch(e){console.error("Error converting to image",e),u("error"),s&&s(e);return}finally{resetStyles()}};return{status:d,isLoading:"loading"===d,isErrored:"error"===d,isSuccess:"success"===d,toImage,ref:h}}async function copyBlobToClipboard(e){if(!e)throw Error("No blob to copy to clipboard");try{await navigator.clipboard.write([new ClipboardItem({[e.type]:e})])}catch(e){throw console.error("Error copying to clipboard",e),e}}function useCopyToClipboardButton(e){let{successToast:n,failToast:t}=useClipBoardToast(),{isLoading:i,toImage:l,ref:o}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:async r=>{try{await copyBlobToClipboard(r),n("Copied the query result as an image to clipboard")}catch(i){let n=i.message;"ClipboardItem is not defined"===n&&(null==e?void 0:e.onClipboardNotDefined)?e.onClipboardNotDefined(r):t("Failed to copy image to clipboard",i)}},onError:e=>{console.error("Error taking screenshot",e),t("Failed to copy image to clipboard",e)}});function CopyToClipboardButton(e){let{imageType:n="png",...t}=e;return(0,r.jsx)(h.z,{size:"sm",leftIcon:(0,r.jsx)(eC.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:i,onMouseEnter:()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow="rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px",e.style.transition="box-shadow 0.5s ease-in-out"}},onMouseLeave:()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow=""}},onClick:async()=>{if(o.current){await l();let e=o.current.element||o.current;e.style.boxShadow=""}},children:"Copy to Clipboard"})}return{ref:o,CopyToClipboardButton}}function useImageBoardModal(){let{isOpen:e,onOpen:n,onClose:t}=(0,et.q)(),[i,l]=(0,v.useState)();return{onOpen:n,setImgBlob:l,ImageBoardModal:function(){let[n,l]=(0,v.useState)();return(0,v.useEffect)(()=>{if(!i)return;let e=new FileReader;e.readAsDataURL(i),e.onloadend=e=>{var n,t;(null===(n=e.target)||void 0===n?void 0:n.result)&&(null===(t=e.target)||void 0===t?void 0:t.result)!==null&&l(e.target.result)}},[l]),(0,r.jsxs)(el.u_,{size:"3xl",isOpen:e,onClose:t,children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{children:[(0,r.jsx)(es.x,{children:"Screenshot Preview"}),(0,r.jsx)(ec.o,{}),(0,r.jsxs)(ed.f,{children:[(0,r.jsxs)(a.k,{px:"10px",gap:"10px",direction:"column",children:[(0,r.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,r.jsx)(I.s,{color:"red.600"}),(0,r.jsx)(x.x,{fontWeight:"500",display:"inline",children:"Copy to the Clipboard"})," ","is not supported in the current browser"]}),(0,r.jsx)(x.x,{children:"Please download it directly"})]}),(0,r.jsx)(eb.E,{src:n,alt:"screenshot"})]}),(0,r.jsxs)(ek.m,{children:[(0,r.jsx)(h.z,{mr:3,onClick:t,children:"Close"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>{if(!i)return;let e=new Date,n="recce-screenshot-".concat((0,eS.ZP)(e,"yyyy-MM-dd-HH-mm-ss"),".png");eD()(i,n),t()},children:"Download"})]})]})]})}}}function ScreenshotDataGrid(e){let{enableScreenshot:n=!0,...t}=e,{onOpen:i,setImgBlob:l,ImageBoardModal:o}=useImageBoardModal(),a=(0,v.useCallback)(e=>{l(e),i()},[l,i]),{ref:s,CopyToClipboardButton:c}=useCopyToClipboardButton({onClipboardNotDefined:a});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.ZP,{ref:s,...t}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{imageType:"png"}),(0,r.jsx)(o,{})]})]})}function EmptyRowsRenderer(){return(0,r.jsx)(a.k,{h:"35px",alignItems:"center",justifyContent:"center",bg:"gray.100",style:{textAlign:"center",gridColumn:"1/-1"},children:(0,r.jsx)(x.x,{fontWeight:"600",children:" No rows"})})}function SchemaView(e){let n,t,{base:i,current:l,enableScreenshot:o=!1}=e,{columns:s,rows:c}=(0,v.useMemo)(()=>toDataGrid(mergeColumns(null==i?void 0:i.columns,null==l?void 0:l.columns)),[i,l]),{lineageGraph:d}=useLineageGraphContext(),u=(null==d?void 0:d.catalogExistence.base)===!1,h=(null==d?void 0:d.catalogExistence.current)===!1;u&&h?n="catalog.json is missing on both current and base environments.":u?n="catalog.json is missing on base environment.":h&&(n="catalog.json is missing on current environment.");let m=i&&void 0===i.columns,x=l&&void 0===l.columns;return m&&x?t="Schema information is missing on both current and base environments.":m?t="Schema information is missing on base environment.":x&&(t="Schema information is missing on current environment."),(0,r.jsxs)(a.k,{direction:"column",children:[n?(0,r.jsxs)(ey.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,r.jsx)(ev.z,{}),n]}):t?(0,r.jsxs)(ey.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,r.jsx)(ev.z,{}),t]}):(0,r.jsx)(r.Fragment,{}),c.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:s,rows:c,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},className:"rdg-light",enableScreenshot:o})})]})}let eT='select * from {{ ref("mymodel") }}',eE=(0,v.createContext)({sqlQuery:eT,setSqlQuery:()=>{}});function RecceQueryContextProvider(e){let{children:n}=e,[t,i]=v.useState(eT);return(0,r.jsx)(eE.Provider,{value:{setSqlQuery:i,sqlQuery:t},children:n})}let useRecceQueryContext=()=>(0,v.useContext)(eE),eI=(0,v.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function RowCountStateContextProvider(e){let{children:n}=e,[t,i]=v.useState([]);return(0,r.jsx)(eI.Provider,{value:{isNodesFetching:t,setIsNodesFetching:i},children:n})}var eL=t(29357);function SqlDiffView(e){let{base:n,current:t}=e;return(0,r.jsx)(eL.SV,{height:"500px",language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==t?void 0:t.raw_code,options:{readOnly:!0,fontSize:14,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same"}})}var eF=t(32865);async function createSimpleCheck(){let e=await H.post("/api/checks",{type:"simple"}),n=e.data;return n}async function createLineageDiffCheck(e,n){let t=await H.post("/api/checks",{type:"lineage_diff",params:{view_mode:e,node_ids:n}}),r=t.data;return r}async function createCheckByNodeSchema(e){let n=await H.post("/api/checks",{type:"schema_diff",params:{node_id:e}}),t=n.data;return t}async function createCheckByRun(e,n){let t=await H.post("/api/checks",{run_id:e,view_options:n}),r=t.data;return r}async function listChecks(){let e=await H.get("/api/checks");return e.data}async function getCheck(e){let n=await H.get("/api/checks/".concat(e));return n.data}async function updateCheck(e,n){let t=await H.patch("/api/checks/".concat(e),n);return t.data}async function deleteCheck(e){let n=await H.delete("/api/checks/".concat(e));return n.data}async function reorderChecks(e){return await H.post("/api/checks/reorder",e)}async function exportChecks(){let e=await H.post("/api/checks/export");return e.data}async function loadChecks(e){let n=new FormData;n.append("file",e);let t=await H.post("/api/checks/load",n);return t.data}var ez=t(78448),eA=t(93573);function ColumnNameCell(e){let{params:n,column:t,containerRef:i}=e,{runAction:o}=useRecceActionContext(),handleValueDiffDetail=(e,t)=>{let r={...n,...e};o("value_diff_detail",r,t)};return(0,r.jsxs)(a.k,{children:[(0,r.jsx)(l.xu,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,r.jsx)(_.L,{}),(0,r.jsx)(p.v,{children:e=>{let{isOpen:n}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eg.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:M.h,icon:(0,r.jsx)(s.J,{as:S.D_A}),variant:"unstyled",size:"sm"}),(0,r.jsx)(ez.h,{containerRef:i,children:(0,r.jsx)(g.q,{lineHeight:"20px",children:(0,r.jsxs)(eA.k,{title:"Action",as:l.xu,fontSize:"8pt",children:[(0,r.jsx)(y.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({},{showForm:!0}),children:"Show mismatched values..."}),(0,r.jsxs)(y.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({columns:[t]},{showForm:!1}),children:["Show mismatched values for '",t,"'"]})]})})})]})}})]})}function ValueDiffResultView(e){let{run:n}=e,t=n.result,i=n.params,cellClass=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},o=(0,v.useRef)(),c=[{key:"__is_pk__",name:"",maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,r.jsx)(d.M,{height:"100%",children:n[0]===i.primary_key&&(0,r.jsx)(s.J,{as:S.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,r.jsx)(ColumnNameCell,{column:n[t.key],params:i,containerRef:o})},cellClass:"cell-show-context-menu"},{key:"1",name:"Matched",resizable:!0,cellClass},{key:"2",name:"Matched %",resizable:!0,renderCell:e=>{let{column:n,row:t}=e,i=t[n.key];return(0,r.jsx)(l.xu,{textAlign:"end",children:void 0!=i&&null!==i?"".concat((100*i).toFixed(2)," %"):"N/A"})},cellClass}];return(0,r.jsxs)(a.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",ref:o,children:[(0,r.jsxs)(l.xu,{px:"16px",children:["Model: ",i.model,", ",t.summary.total," total (",t.summary.total-t.summary.added-t.summary.removed," ","common, ",t.summary.added," added, ",t.summary.removed," removed)"]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:c,rows:t.data.data,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})}var eM=t(41171),eO=t(53930),eP=t(25535),eV=t(51348),eB=t(11546),eq=t(83978),eH=t.n(eq);function extractColumns(e){function getColumns(e){return e&&e.columns?Object.values(e.columns):[]}let n=getColumns(e.data.base),t=getColumns(e.data.current),r=[];return n.forEach(e=>{r.some(n=>n.name===e.name)||r.push(e)}),t.forEach(e=>{r.some(n=>n.name===e.name)||r.push(e)}),r}function extractColumnNames(e){function getNames(e){return e&&e.columns?Object.values(e.columns).map(e=>e.name):[]}let n=getNames(e.data.base),t=getNames(e.data.current),r=[];return n.forEach(e=>{r.includes(e)||r.push(e)}),t.forEach(e=>{r.includes(e)||r.push(e)}),r}function ValueDiffForm(e){var n;let{params:t,onParamsChanged:i,setIsReadyToExecute:l}=e,{lineageGraph:o}=useLineageGraphContext(),[a,s]=(0,v.useState)(!t.columns||0===t.columns.length),c=null==t?void 0:t.model,d=null==t?void 0:t.primary_key,h=eH().find(null==o?void 0:o.nodes,{name:null==t?void 0:t.model}),m=null==h?void 0:null===(n=h.data.current)||void 0===n?void 0:n.primary_key;(0,v.useEffect)(()=>{!d&&m&&i({...t,primary_key:m})},[d,m,t,i]),(0,v.useEffect)(()=>{l(!!d&&!!c)},[d,c,l]);let x=h?extractColumnNames(h):[];return(0,r.jsxs)(u.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Model"}),(0,r.jsx)(eP.I,{isReadOnly:!0,value:null==t?void 0:t.model})]}),(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Primary key"}),(0,r.jsx)(eB.Z,{placeholder:"Select primary key",value:d?{label:d,value:d}:void 0,options:(x||[]).map(e=>({label:e,value:e})),onChange:e=>{s(!0),i({...t,primary_key:(null==e?void 0:e.value)||"",columns:void 0})}})]}),(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Columns"}),(0,r.jsx)(eV.X,{marginBottom:"10px",isChecked:a,onChange:e=>{s(e.target.checked),i({...t,columns:void 0})},children:"All columns"}),!a&&(0,r.jsx)(eB.Z,{isMulti:!0,closeMenuOnSelect:!1,options:(x||[]).map(e=>({label:e,value:e})),value:(t.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{i({...t,columns:(e||[]).map(e=>e.value)})}})]})]})}function _getColumnMap(e,n){let t={},r=mergeKeysWithStatus(e.columns.map(e=>e.name),n.columns.map(e=>e.name));return Object.entries(r).map(r=>{let[i,l]=r;t[i]={status:l,baseColumnIndex:e.columns.findIndex(e=>e.name===i),currentColumnIndex:n.columns.findIndex(e=>e.name===i)}}),t}function _getPrimaryKeyIndexes(e,n){let t=[];for(let r of n){let n=e.findIndex(e=>e.name===r);if(n<0)throw Error("Column ".concat(r," not found"));t.push(n)}return t}function _getPrimaryKeyValue(e,n,t){let r={};if(0===n.length)return JSON.stringify({_index:t._index});for(let i of n){let n=e[i];r[n.name]=t[i]}return JSON.stringify(r)}function DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:i,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,r.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&i&&(0,r.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?S.ven:S.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);i&&i(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];i&&i(e)}}),!h&&o&&(0,r.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?S.$kI:S.oJP,onClick:m?()=>{let e=u.filter(e=>e!==n);o&&o(e)}:()=>{let e=[...u,n];o&&o(e)}})]})}t(7866);let defaultRenderCell=e=>{let{row:n,column:t}=e,i=n[t.key];return(0,r.jsx)(r.Fragment,{children:"boolean"==typeof i?i.toString():i})};function toDataDiffGrid(e,n,t){let i=e||{columns:[],data:[]},l=n||{columns:[],data:[]},o=(null==t?void 0:t.primaryKeys)||[],a=(null==t?void 0:t.pinnedColumns)||[],s=(null==t?void 0:t.changedOnly)||!1,c=[],d=_getColumnMap(i,l),u={},h={},m=!1,x=!1;if(0===o.length)i.data.forEach((e,n)=>{e._index=n+1,u[JSON.stringify({_index:n+1})]=e}),l.data.forEach((e,n)=>{e._index=n+1,h[JSON.stringify({_index:n+1})]=e});else{let e=_getPrimaryKeyIndexes(i.columns,o);i.data.forEach((n,t)=>{let r=_getPrimaryKeyValue(i.columns,e,n);r in u&&(m=!0),u[r]=n}),e=_getPrimaryKeyIndexes(l.columns,o),l.data.forEach((n,t)=>{let r=_getPrimaryKeyValue(l.columns,e,n);r in h&&(x=!0),h[r]=n})}let f=mergeKeysWithStatus(Object.keys(u),Object.keys(h)),p=Object.entries(f).map(e=>{let[n,t]=e,r=u[n],a=h[n],s=JSON.parse(n);if(r&&i.columns.forEach((e,n)=>{o.includes(e.name)||(s["base__".concat(e.name)]=r[n])}),a&&l.columns.forEach((e,n)=>{o.includes(e.name)||(s["current__".concat(e.name)]=a[n])}),r){if(a)for(let[e,n]of Object.entries(d))"index"===e||o.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eH().isEqual(r[n.baseColumnIndex],a[n.currentColumnIndex])||(s.status="modified",n.status="modified");else s.status="removed"}else s.status="added";return s});s&&(p=p.filter(e=>"added"===e.status||"removed"===e.status||"modified"===e.status));let toColumn=(e,n)=>{let i="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let r=t.status;if("removed"===r)return"diff-cell-removed";if("added"===r)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eH().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:i,name:(0,r.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:defaultRenderCell,size:"auto"}]}};return 0===o.length?c.push({key:"_index",name:"",cellClass:"index-column"}):o.forEach(e=>{let n=d[e].status||"";c.push({key:"".concat(e),name:(0,r.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),a.forEach(e=>{let n=d[e].status||"";"index"===e||o.includes(e)||c.push(toColumn(e,n))}),Object.entries(d).forEach(e=>{let[n,t]=e,r=t.status||"";"index"===n||o.includes(n)||a.includes(n)||s&&"added"!==r&&"removed"!==r&&"modified"!==r||c.push(toColumn(n,r))}),{columns:c,rows:p,invalidPKeyBase:m,invalidPKeyCurrent:x}}function ProfileDiffResultView(e){var n;let{run:t,viewOptions:i,onViewOptionsChanged:l}=e,o=t.result;t.params;let a=(0,v.useMemo)(()=>(null==i?void 0:i.pinned_columns)||[],[i]),s=((null==o?void 0:null===(n=o.current)||void 0===n?void 0:n.columns)||[]).find(e=>"column_name"===e.name.toLowerCase()),c=(null==s?void 0:s.name)||"column_name",u=(0,v.useMemo)(()=>toDataDiffGrid(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[c],pinnedColumns:a,onPinnedColumnsChange:e=>{l&&l({...i,pinned_columns:e})}}),[o,c,a,i,l]);return 0===u.columns.length?(0,r.jsx)(d.M,{height:"100%",children:"No data"}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})}var eK=t(70556);let RunView=e=>{var n,t;let{isPending:i,isAborting:o,progress:s,error:c,run:m,onCancel:x,viewOptions:f,onViewOptionsChanged:p,RunResultView:g,children:y}=e;if(y&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!y&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");let v=(null==c?void 0:null===(t=c.response)||void 0===t?void 0:null===(n=t.data)||void 0===n?void 0:n.detail)||(null==m?void 0:m.error);if(v)return(0,r.jsxs)(ey.b,{status:"error",children:[(0,r.jsx)(ev.z,{}),"Error: ",v]});if(i){let e=(null==s?void 0:s.message)?null==s?void 0:s.message:"Loading...";return(0,r.jsx)(d.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,r.jsxs)(u.g,{children:[(0,r.jsxs)(a.k,{alignItems:"center",children:[(null==s?void 0:s.percentage)===void 0||(null==s?void 0:s.percentage)===null?(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,r.jsx)(F.D,{size:"20px",value:100*s.percentage,mr:"8px"}),o?(0,r.jsx)(r.Fragment,{children:"Aborting..."}):(0,r.jsx)(r.Fragment,{children:e})]}),!o&&(0,r.jsx)(h.z,{onClick:x,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}return m?(0,r.jsxs)(l.xu,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(0,r.jsx)(g,{run:m,viewOptions:f,onViewOptionsChanged:p}),y&&y({run:m,viewOptions:f,onViewOptionsChanged:p})]}):(0,r.jsx)(d.M,{bg:"rgb(249,249,249)",height:"100%",children:"No data"})};var eW=t(48689);let RunModal=e=>{let{isOpen:n,onClose:t,type:i,title:o,params:s,initialRun:c,RunForm:d,RunResultView:u}=e,[,m]=(0,eF.TH)(),[x,f]=(0,v.useState)(),[p,g]=(0,v.useState)(s),[y,j]=(0,v.useState)(!1),[C,b]=(0,v.useState)(!1),[k,w]=(0,v.useState)(),[_,S]=(0,v.useState)(),[R,D]=(0,v.useState)(c),submitRunFn=async()=>{let{run_id:e}=await submitRun(i,p,{nowait:!0});for(f(e);;){let n=await waitRun(e,2);if(w(n.progress),n.result||n.error)return j(!1),w(void 0),n}},{data:N,mutate:T,reset:E,error:I,isPending:L}=(0,eK.D)({mutationFn:submitRunFn});(0,v.useEffect)(()=>{n&&void 0===d&&void 0===R&&T()},[n]);let F=(0,Q.NL)(),z=(0,v.useCallback)(async()=>{if(j(!0),x)return await cancelRun(x)},[x]),A=(0,v.useCallback)(()=>{T()},[T]),M=(0,v.useCallback)(()=>{T(),D(void 0)},[T]),handleReset=()=>{j(!1),g(s),w(void 0),D(void 0),E()},O=(0,v.useCallback)(async()=>{let e=R?R.run_id:null==N?void 0:N.run_id;if(void 0===e)return;let n=await createCheckByRun(e,_);F.invalidateQueries({queryKey:W.checks()}),m("/checks/".concat(n.check_id))},[null==N?void 0:N.run_id,R,m,F,_]),handleClose=async()=>{t(),L&&x&&await cancelRun(x),handleReset()},P=!!(null==R?void 0:R.result)||!!(null==N?void 0:N.result),V=(null==R?void 0:R.run_at)?(0,eW.Z)(new Date(R.run_at),{addSuffix:!0}):null;return(0,r.jsxs)(el.u_,{isOpen:n,onClose:handleClose,size:"6xl",scrollBehavior:"inside",children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{overflowY:"auto",height:"75%",children:[(0,r.jsxs)(es.x,{children:[o,!N&&!L&&V&&(0,r.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:V})]}),(0,r.jsx)(ec.o,{}),(0,r.jsx)(ed.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:L||N||I||R?(0,r.jsx)(RunView,{isPending:L,isAborting:y,run:R||N,error:I,progress:k,onCancel:z,viewOptions:_,onViewOptionsChanged:S,RunResultView:u}):(0,r.jsx)(l.xu,{style:{contain:"layout"},children:d&&(0,r.jsx)(d,{params:p,onParamsChanged:g,setIsReadyToExecute:b})})}),(0,r.jsx)(ek.m,{children:(0,r.jsxs)(a.k,{gap:"10px",children:[P&&d&&(0,r.jsx)(h.z,{colorScheme:"blue",onClick:handleReset,children:"Reset"}),P&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(h.z,{colorScheme:"blue",onClick:O,children:"Add to checklist"})}),L&&(0,r.jsx)(h.z,{onClick:z,isDisabled:y,colorScheme:"blue",children:"Cancel"}),!P&&!L&&(0,r.jsx)(h.z,{isDisabled:L||!C,colorScheme:"blue",onClick:A,children:"Execute"}),P&&!d&&(0,r.jsx)(h.z,{colorScheme:"blue",onClick:M,children:"Rerun"})]})})]})]})};var eU=t(99986);function valuediff_getColumnMap(e){let n={};return e.columns.map((e,t)=>{n[e.name]={index:t}}),n}function valuediff_getPrimaryKeyIndexes(e,n){let t=[];for(let r of n){let n=e.findIndex(e=>e.name===r);if(n<0)throw Error("Column ".concat(r," not found"));t.push(n)}return t}function valuediff_getPrimaryKeyValue(e,n,t){let r={};if(0===n.length)return JSON.stringify({_index:t._index});for(let i of n){let n=e[i];r[n.name]=t[i]}return JSON.stringify(r)}function valuediff_DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:i,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,r.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&o&&(0,r.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?S.$kI:S.oJP,onClick:m?()=>{let e=u.filter(e=>e!==n);o&&o(e)}:()=>{let e=[...u,n];o&&o(e)}})]})}let valuediff_defaultRenderCell=e=>{let{row:n,column:t}=e,i=n[t.key];return(0,r.jsx)(r.Fragment,{children:"boolean"==typeof i?i.toString():i})};function toValueDiffGrid(e,n,t){let i=(null==t?void 0:t.pinnedColumns)||[],l=(null==t?void 0:t.changedOnly)||!1,o=[],a=valuediff_getColumnMap(e),s={},c={};if(0===n.length)throw Error("Primary keys are required");let d=valuediff_getPrimaryKeyIndexes(e.columns,n),u=(a.in_a||a.IN_A).index,h=(a.in_b||a.IN_B).index;e.data.forEach((n,t)=>{let r=valuediff_getPrimaryKeyValue(e.columns,d,n);n[u]&&(s[r]=n),n[h]&&(c[r]=n)});let m=mergeKeysWithStatus(Object.keys(s),Object.keys(c)),x=Object.entries(m).map(t=>{let[r,i]=t,l=s[r],o=c[r],d=JSON.parse(r);if(l&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["base__".concat(e.name)]=l[t])}),o&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["current__".concat(e.name)]=o[t])}),l){if(o)for(let[e,t]of Object.entries(a))!("index"===e||n.includes(e))&&(eH().isEqual(l[t.index],o[t.index])||(d.status="modified",t.status="modified"));else d.status="removed"}else d.status="added";return d});l&&(x=x.filter(e=>"added"===e.status||"removed"===e.status||"modified"===e.status));let toColumn=(e,n)=>{let i="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let r=t.status;if("removed"===r)return"diff-cell-removed";if("added"===r)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eH().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:i,name:(0,r.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"}]}};return n.forEach(e=>{let n=a[e].status||"";o.push({key:"".concat(e),name:(0,r.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),i.forEach(e=>{let t=a[e].status||"";n.includes(e)||o.push(toColumn(e,t))}),Object.entries(a).forEach(e=>{let[t,r]=e,a=r.status||"";"in_a"===t||"in_b"===t||n.includes(t)||i.includes(t)||l&&"added"!==a&&"removed"!==a&&"modified"!==a||o.push(toColumn(t,a))}),{columns:o,rows:x}}let ValueDiffDetailResultView=e=>{var n,t;let{run:i,onAddToChecklist:s,viewOptions:c,onViewOptionsChanged:u}=e,h=(0,v.useMemo)(()=>(null==c?void 0:c.changed_only)||!1,[c]),m=(0,v.useMemo)(()=>(null==c?void 0:c.pinned_columns)||[],[c]),x=(0,v.useMemo)(()=>{var e,n;if(!i.result)return{columns:[],rows:[]};let t=(null==i?void 0:null===(e=i.params)||void 0===e?void 0:e.primary_key)?[null==i?void 0:null===(n=i.params)||void 0===n?void 0:n.primary_key]:[];return toValueDiffGrid(null==i?void 0:i.result,t,{changedOnly:h,pinnedColumns:m,onPinnedColumnsChange:e=>{u&&u({...c,pinned_columns:e})}})},[i,c,h,m,u]);if(0===x.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});if(h&&0===x.rows.length)return(0,r.jsx)(d.M,{height:"100%",children:"No change"});let f=(null===(n=i.result)||void 0===n?void 0:n.limit)||0,p=f>0&&(null==i?void 0:null===(t=i.result)||void 0===t?void 0:t.more)?"Warning: Displayed results are limited to ".concat(f.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:p?"orange.100":"inherit",children:[p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",(0,r.jsx)(l.xu,{children:p})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),(0,r.jsx)(eV.X,{isChecked:null==c?void 0:c.changed_only,onChange:()=>{let e=!(null==c?void 0:c.changed_only);u&&u({...c,changed_only:e})},children:"Changed only"}),s&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>s(i)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:x.columns,rows:x.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};var eG=t(34030);function formatNumber(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US",t=arguments.length>2?arguments[2]:void 0;return"number"!=typeof e?e:new Intl.NumberFormat(n,t).format(e)}function formatters_formatIntervalMinMax(e){let n=e>0&&e<=.001,t=e<1&&e>=.999,formatter=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e;return formatNumber(n,"en-US",{style:"percent",minimumFractionDigits:1})};if(n){let e=formatter(.001);return"<".concat(e)}if(t){let e=formatter(.999);return">".concat(e)}return formatter()}function formatters_formatAsAbbreviatedNumber(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,r=n>=1e6,i=n>=1e9,l=n>=1e15;if(l||n>=1e12)return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:l?0:2}).format(e/1e12).replace("L","T");if(i||r||n>=1e3){let n={base:i?1e9:r?1e6:1e3,unit:i?"B":r?"M":"K"};return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:1}).format(e/n.base).replace("L",n.unit)}return n>=1?new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:t?3:2,notation:t||0===n?"standard":"scientific"}).format(e)}}var eQ=t(17180),eJ=t(85670),eZ=t(84021);let eX="#63B3ED",eY="#F6AD55",e$="".concat(eX,"A5"),e0="".concat(eY,"A5");function SquareIcon(e){let{color:n}=e;return(0,r.jsx)(l.xu,{display:"inline-block",w:"10px",h:"10px",bgColor:n,mr:"2",borderRadius:"sm"})}let e1="#63B3ED";function prepareSummaryList(e,n){let t=n?10:e.counts.length,r=e.counts.slice(0,t),i=e.valids-r.reduce((e,n)=>e+n,0),l=e.values.slice(0,t);return l.concat([i]).map((n,t)=>{let l=t===r.length,o=l?i:r[t];return{isLastItemOthers:l,label:l?"(others)":String(n)||"(empty)",count:o,displayCount:formatters_formatAsAbbreviatedNumber(o),displayRatio:formatters_formatIntervalMinMax(o/e.valids)||"N/A"}})}function TopKChartTooltip(e){let{base:n,current:t,children:i}=e;return(0,r.jsx)(o.u,{label:(0,r.jsxs)(l.xu,{children:[(0,r.jsxs)(x.x,{children:[(0,r.jsx)(SquareIcon,{color:eX}),"Current: ",t.count," (",t.displayRatio,")"]}),(0,r.jsxs)(x.x,{children:[(0,r.jsx)(SquareIcon,{color:eY}),"Base: ",n.count," (",n.displayRatio,")"]})]}),placement:"auto",hasArrow:!0,children:i})}function TopKSummaryBarChart(e){let{topKDiff:n,isDisplayTopTen:t}=e,i=prepareSummaryList(n.current,t),o=prepareSummaryList(n.base,t);return(0,r.jsxs)(l.xu,{w:"100%",px:20,py:4,children:[(0,r.jsxs)(a.k,{alignItems:"center",direction:"row",children:[(0,r.jsx)(_.L,{}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:eY})," Base"]}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:eX})," Current"]}),(0,r.jsx)(_.L,{})]}),i.map((e,t)=>{let i=o[t];return e.isLastItemOthers&&0===e.count&&0===i.count?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(v.Fragment,{children:[(0,r.jsx)(TopKChartTooltip,{base:i,current:e,children:(0,r.jsxs)(a.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:4,children:[(0,r.jsx)(x.x,{noOfLines:1,width:"10em",fontSize:"sm",color:e.isLastItemOthers||0===e.label.length?"gray.400":"inherit",children:e.label}),(0,r.jsxs)(a.k,{width:"70%",direction:"column",children:[(0,r.jsxs)(a.k,{height:"1em",children:[(0,r.jsx)(CategoricalBarChart,{topkCount:e.count,topkLabel:e.label,valids:n.current.valids,color:eX}),(0,r.jsx)(x.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:e.displayCount}),(0,r.jsx)(x.x,{color:"gray.400",fontSize:"sm",width:"4em",children:e.displayRatio})]}),(0,r.jsxs)(a.k,{height:"1em",children:[(0,r.jsx)(CategoricalBarChart,{topkCount:i.count,topkLabel:i.label,valids:n.base.valids,color:eY}),(0,r.jsx)(x.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:i.displayCount}),(0,r.jsx)(x.x,{color:"gray.400",fontSize:"sm",width:"4em",children:i.displayRatio})]})]})]})}),(0,r.jsx)(eQ.i,{})]},t)})]})}function CategoricalBarChart(e){let{topkCount:n,topkLabel:t,valids:i,animation:l=!1,color:o=e1}=e;eJ.kL.register(eJ.uw,eJ.ZL,eJ.f$);let a=getCatBarChartOptions(n,i,{animation:l}),s=getCatBarChartData({topkCount:n,topkLabel:t,color:o});return(0,r.jsx)(eZ.$Q,{data:s,options:a,plugins:[]})}function getCatBarChartOptions(e,n){let{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{responsive:!0,maintainAspectRatio:!1,indexAxis:"y",scales:{x:{display:!1,max:n,grid:{display:!1}},y:{display:!1}},plugins:{tooltip:{enabled:!1}},...t}}function getCatBarChartData(e){let{topkLabel:n,topkCount:t,color:r=e1}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:r,hoverBackgroundColor:r,borderWidth:0,borderColor:r,barPercentage:1,categoryPercentage:.6}]}}let ScreenshotBox=e=>{let{backgroundColor:n="white",blockSize:t,children:i,...o}=e,{onOpen:a,setImgBlob:s,ImageBoardModal:c}=useImageBoardModal(),d=(0,v.useCallback)(e=>{s(e),a()},[s,a]),{ref:u,CopyToClipboardButton:h}=useCopyToClipboardButton({backgroundColor:n,onClipboardNotDefined:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.xu,{ref:u,...o,overflow:"auto",children:(0,r.jsx)(l.xu,{backgroundColor:n,height:"100%",blockSize:t,children:i})}),(0,r.jsx)(h,{imageType:"png"}),(0,r.jsx)(c,{})]})};function TopKDiffResultView(e){let{run:n}=e,[t,i]=(0,v.useState)(!0),l=n.result,o=n.params,s=l.base,c=l.current;return(0,r.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,r.jsxs)(ScreenshotBox,{blockSize:"auto",children:[(0,r.jsxs)(ei.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",children:["Model ",o.model,".",o.column_name]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(TopKSummaryBarChart,{topKDiff:l,valids:c.valids||0,isDisplayTopTen:t}),(0,r.jsx)(_.L,{})]})]}),(0,r.jsx)(_.L,{}),(s.values.length>10||c.values.length>10)&&(0,r.jsx)(a.k,{p:5,justify:"start",children:(0,r.jsx)(eG.r,{onClick:()=>i(e=>!e),textColor:"blue.500",children:t?"View More Items":"View Only Top-10"})})]})}var e2=t(68665);function TopKDiffForm(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:i}=e,{lineageGraph:o}=useLineageGraphContext(),a=eH().find(null==o?void 0:o.nodes,{name:null==n?void 0:n.model}),s=a?extractColumnNames(a):[];return(0,v.useEffect)(()=>{i(!!n.column_name)},[n,i]),(0,r.jsx)(l.xu,{m:"16px",children:(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Pick a column to show top-k"}),(0,r.jsx)(e2.P,{placeholder:"Select column",value:null==n?void 0:n.column_name,onChange:e=>{let r=e.target.value;t({...n,column_name:r})},children:s.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})})}function HistogramChart(e){let{data:n,hideAxis:t=!1,animation:i=!1}=e;eJ.kL.register(eJ.ZL,eJ.RM,eJ.f$,eJ.uw,eJ.u);let l=getHistogramChartOptions(n,t,{animation:i}),o=getHistogramChartData(n);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a.k,{alignItems:"center",direction:"row",children:[(0,r.jsx)(_.L,{}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:e0})," Base"]}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:e$})," Current"]}),(0,r.jsx)(_.L,{})]}),(0,r.jsx)(eZ.kL,{type:"bar",options:l,data:o,plugins:[]})]})}function getHistogramChartDataset(e,n,t,r,i){let{counts:l=[]}=i,o="datetime"===e?l.map((e,t)=>({x:n[t],y:e})):l;return{label:t,data:o,backgroundColor:r,borderColor:r,hoverBackgroundColor:r,borderWidth:0,categoryPercentage:1,barPercentage:1,xAxisID:"x"}}function getHistogramChartData(e){let{datasets:n,type:t,binEdges:r}=e,[i,l]=n,o=getHistogramChartDataset(t,r,"Current",e$,l),a=getHistogramChartDataset(t,r,"Base",e0,i),s=r.map((e,n)=>formatDisplayedBinItem(r,n)).slice(0,-1);return{labels:s,datasets:[o,a]}}function getHistogramChartOptions(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasets:r,type:i,samples:l=0,binEdges:o}=e,[a,s]=r,c="datetime"===i;return{responsive:!0,maintainAspectRatio:!1,plugins:{tooltip:{mode:"index",intersect:!1,callbacks:{title(e){let[{dataIndex:n,datasetIndex:t}]=e,r=formatDisplayedBinItem(o,n);return"".concat(c?"Date Range":"string"===i?"Text Length":"Value Range","\n").concat(r)},label(e){let{datasetIndex:n,dataIndex:t,dataset:{label:r}}=e,i=0===n?s.counts:a.counts,o=formatters_formatIntervalMinMax(i[t]/l),c=i[t];return"".concat(r,": ").concat(c," (").concat(o,")")}}}},scales:getScales(e,n),...t}}function getScales(e){let{datasets:n,min:t=0,max:r=0,type:i,binEdges:l}=e,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],[a,s]=n,c=Math.max(...s.counts,...a.counts),d=l.map((e,n)=>formatDisplayedBinItem(l,n)).slice(0,-1);return{x:"datetime"===i?{display:!o,type:"timeseries",min:t,max:r,adapters:{date:{}},time:{minUnit:"day"},grid:{display:!1},ticks:{minRotation:30,maxRotation:30,maxTicksLimit:8}}:{display:!o,type:"category",grid:{display:!1},ticks:{callback:(e,n)=>d[n]},stacked:!0},y:{display:!o,type:"linear",max:c,border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return formatters_formatAsAbbreviatedNumber(e)}},beginAtZero:!0}}}function formatDisplayedBinItem(e,n){let t=e[n],r=e[n+1],i=formatters_formatAsAbbreviatedNumber(t),l=formatters_formatAsAbbreviatedNumber(r),o="".concat(i," - ").concat(l);return o}function HistogramDiffResultView(e){var n,t,i,o,s,c;let{run:d}=e,u=d.params,h=null===(n=d.result)||void 0===n?void 0:n.base,x=null===(t=d.result)||void 0===t?void 0:t.current,f=null===(i=d.result)||void 0===i?void 0:i.min,p=null===(o=d.result)||void 0===o?void 0:o.max,g=null===(s=d.result)||void 0===s?void 0:s.bin_edges;return h&&x?(0,r.jsx)(a.k,{direction:"column",height:"500px",children:(0,r.jsxs)(ScreenshotBox,{height:"100%",children:[(0,r.jsxs)(ei.X,{as:"h1",size:"md",paddingTop:"4",textAlign:"center",children:["Model ",u.model,".",u.column_name]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(l.xu,{w:"80%",h:"300px",m:"4",children:(0,r.jsx)(HistogramChart,{data:{type:(null===(c=d.params)||void 0===c?void 0:c.column_type)||"",datasets:[x,h],min:f,max:p,samples:h.total,binEdges:g}})}),(0,r.jsx)(_.L,{})]})]})}):(0,r.jsx)("div",{children:"Loading..."})}function isStringDataType(e){return["CHAR","VARCHAR","TINYTEXT","TEXT","MEDIUMTEXT","LONGTEXT","NCHAR","NVARCHAR","VARCHAR2","NVARCHAR2","CLOB","NCLOB","VARCHAR(MAX)","XML","JSON","BOOLEAN","TINYINT(1)","BIT","NUMBER(1)","BOOL"].includes(e.toUpperCase())}function isDateTimeType(e){return["DATE","DATETIME","TIMESTAMP","TIME","YEAR","DATETIME2","SMALLDATETIME","DATETIMEOFFSET","INTERVAL","TIMESTAMPTZ","TIMETZ","TIMESTAMP WITH TIME ZONE","TIMESTAMP WITH LOCAL TIME ZONE","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP_TZ"].includes(e.toUpperCase())}function HistogramDiffForm(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:i}=e,{lineageGraph:o}=useLineageGraphContext(),a=eH().find(null==o?void 0:o.nodes,{name:null==n?void 0:n.model}),s=a?extractColumns(a).filter(e=>!isStringDataType(e.type)&&!isDateTimeType(e.type)):[];return(0,r.jsx)(l.xu,{m:"16px",children:(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Pick a column to show Histogram Diff"}),(0,r.jsx)(e2.P,{placeholder:"Select column",value:null==n?void 0:n.column_name,onChange:e=>{var r;let l=e.target.value;i(!!l);let o=(null===(r=s.find(e=>e.name===l))||void 0===r?void 0:r.type)||"";t({...n,column_name:l,column_type:o})},children:s.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}let e5=(0,v.createContext)({runAction:()=>{}}),e6={profile_diff:{title:"Profile Diff",RunResultView:ProfileDiffResultView},value_diff:{title:"Value Diff",RunResultView:ValueDiffResultView,RunForm:ValueDiffForm},value_diff_detail:{title:"Value Diff Detail",RunResultView:ValueDiffDetailResultView,RunForm:ValueDiffForm},top_k_diff:{title:"Top-K Diff",RunResultView:TopKDiffResultView,RunForm:TopKDiffForm},histogram_diff:{title:"Histogram Diff",RunResultView:HistogramDiffResultView,RunForm:HistogramDiffForm}},useCloseModalEffect=e=>{let[n]=(0,eF.TH)();(0,v.useEffect)(()=>{e()},[e,n])};function RecceActionContextProvider(e){var n;let{children:t}=e,[i,l]=(0,v.useState)(),{isOpen:o,onOpen:a,onClose:s}=(0,et.q)(),c=(0,v.useCallback)(async(e,n,t)=>{let r;let i=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await searchRuns(e,n,1);1===t.length&&(r=t[0])}l({session:i,type:e,params:n,lastRun:r,options:t}),a()},[l,a]);return useCloseModalEffect(s),(0,r.jsxs)(e5.Provider,{value:{runAction:c},children:[i&&e6[i.type]&&(0,r.jsx)(RunModal,{isOpen:o,onClose:s,title:e6[i.type].title,type:i.type,params:i.params,initialRun:i.lastRun,RunResultView:e6[i.type].RunResultView,RunForm:(null===(n=i.options)||void 0===n?void 0:n.showForm)?e6[i.type].RunForm:void 0},i.session),t]})}let useRecceActionContext=()=>(0,v.useContext)(e5);function NodeView(e){let{node:n,onCloseNode:t}=e,[,i]=(0,eF.TH)(),{setSqlQuery:o}=useRecceQueryContext(),s="model"===n.resourceType||"seed"===n.resourceType||"source"===n.resourceType,{isOpen:c,onOpen:d,onClose:u}=(0,et.q)(),{runAction:x}=useRecceActionContext(),f=(0,v.useCallback)(async()=>{let e=n.id,t=await createCheckByNodeSchema(e);i("/checks/".concat(t.check_id))},[n,i]);return(0,r.jsxs)(er.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,r.jsxs)(m.U,{children:[(0,r.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,r.jsx)(ei.X,{size:"sm",children:n.name})}),(0,r.jsx)(_.L,{}),"modified"===n.changeStatus&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(h.z,{onClick:d,leftIcon:(0,r.jsx)(R.tvD,{}),colorScheme:"orange",variant:"solid",children:"Diff"}),(0,r.jsxs)(el.u_,{isOpen:c,onClose:u,size:"6xl",children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{overflowY:"auto",height:"75%",children:[(0,r.jsx)(es.x,{children:"Model Raw Code Diff"}),(0,r.jsx)(ec.o,{}),(0,r.jsx)(ed.f,{children:(0,r.jsx)(SqlDiffView,{base:n.data.base,current:n.data.current})})]})]})]}),(0,r.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,r.jsx)(eu.P,{onClick:t})})]}),(0,r.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,r.jsx)(RowCountTag,{node:n,isInteractive:!0})]})}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(eh.m,{overflow:"auto",as:a.k,children:[(0,r.jsx)(em.t,{children:(0,r.jsx)(ex.O,{children:"Columns"})}),(0,r.jsx)(ef.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,r.jsx)(ep.x,{p:0,overflowY:"auto",height:"100%",children:(0,r.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]}),(0,r.jsxs)(m.U,{p:"16px",children:[(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{as:h.z,size:"sm",colorScheme:"blue",children:"Add check"}),(0,r.jsx)(g.q,{children:(0,r.jsx)(y.s,{onClick:f,children:"Schema Check"})})]}),(0,r.jsx)(_.L,{}),"model"===n.resourceType&&(0,r.jsxs)(r.Fragment,{children:["added"!==n.changeStatus&&"removed"!==n.changeStatus&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{as:h.z,size:"sm",colorScheme:"blue",children:"Advanced Diffs"}),(0,r.jsxs)(g.q,{children:[(0,r.jsx)(y.s,{onClick:()=>{x("profile_diff",{model:n.name},{showForm:!1,showLast:!0})},children:"Profile Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("value_diff",{model:n.name},{showForm:!0,showLast:!0})},children:"Value Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("top_k_diff",{model:n.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("histogram_diff",{model:n.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})]})]})}),(0,r.jsx)(h.z,{colorScheme:"blue",size:"sm",onClick:()=>{o('select * from {{ ref("'.concat(n.name,'") }}')),i("/query")},children:"Query"})]})]})]})]})}var e3=t(45438),e4=t(72491),e9=t(52246),e8=t(25807),e7=t(80294),ne=t(15012);function AddSchemaChangesCheckButton(e){let{nodes:n,onFinish:t}=e,[,i]=(0,eF.TH)();return(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===n.length,onClick:async()=>{let e;1===n.length?e=await createCheckByNodeSchema(n[0].id):await Promise.all(n.map(async e=>{await createCheckByNodeSchema(e.id)})),t(),e?i("/checks/".concat(e.check_id)):i("/checks")},children:[(0,r.jsx)(s.J,{as:e7.Edg}),"Add schema check"]})}function AddLineageDiffCheckButton(e){let{viewMode:n,nodes:t,onFinish:i,withIcon:l}=e,[,o]=(0,eF.TH)();return(0,r.jsxs)(h.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:0===t.length,onClick:async()=>{let e=t.map(e=>e.id),r=await createLineageDiffCheck(n,e);i(),r?o("/checks/".concat(r.check_id)):o("/checks")},children:[l&&(0,r.jsx)(s.J,{as:ne.Ks7}),"Add lineage diff check"]})}function NodeSelector(e){var n,t,i,o;let{viewMode:a,nodes:c,onClose:d,onActionStarted:u,onActionNodeUpdated:x,onActionCompleted:f}=e,[p,g]=(0,v.useState)({mode:"per_node",status:"pending",completed:0,total:0}),y=(0,Q.NL)(),[,j]=(0,eF.TH)(),submitRunForNodes=async(e,n,t)=>{let r="multi_nodes";p.mode=r,u(),p.status="running";let i=[];for(let e of c){let t=n(e);t?(e.action={mode:r,status:"skipped",skipReason:t},x(e)):(e.action={mode:r,status:"pending"},i.push(e))}let l=t(i);try{let{run_id:n}=await submitRun(e,l,{nowait:!0});for(p.currentRun={run_id:n},p.total=1;;){let e=await waitRun(n,2);p.currentRun=e;let t=e.error?"failure":e.result?"success":"running";for(let n of i)n.action={mode:r,status:t,run:e},x(n);if(e.error||e.result)break}}catch(e){}if(p.completed=1,"canceling"===p.status){p.status="canceled",f();return}p.status="completed",f()},submitRunsPerNodes=async(e,n)=>{let t="per_node";for(let e of(p.mode=t,u(),p.status="running",c))e.action={mode:t,status:"pending"},x(e);for(let r of(p.completed=0,p.total=c.length,c)){let{params:i,skipReason:l}=n(r);if(l)r.action={mode:t,status:"skipped",skipReason:l},x(r);else try{let{run_id:n}=await submitRun(e,i,{nowait:!0});for(p.currentRun={run_id:n},r.action={mode:t,status:"running"},x(r);;){let e=await waitRun(n,2);p.currentRun=e;let i=e.error?"failure":e.result?"success":"running";if(r.action={mode:t,status:i,run:e},x(r),e.error||e.result)break}}catch(e){}finally{p.currentRun=void 0}if(p.completed++,"canceling"===p.status){p.status="canceled",f();return}}p.status="completed",f()},handleRowCountDiffClick=async()=>{let e=[];for(let n of c)"model"!==n.resourceType?(n.action={mode:"multi_nodes",status:"skipped",skipReason:"Not a model"},x(n)):e.push(n.name);submitRunForNodes("row_count_diff",e=>{if("model"!==e.resourceType)return"Not a model"},e=>{let n={node_names:e.map(e=>e.name)};return n})},handleValueDiffClick=async()=>{submitRunsPerNodes("value_diff",e=>{var n,t;let r=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;if(!r)return{skipReason:"No primary key found. The first unique column is used as primary key."};let i={model:e.name,primary_key:r};return{params:i}})},handleCancel=async()=>{var e;p.status="canceling",(null===(e=p.currentRun)||void 0===e?void 0:e.run_id)&&cancelRun(p.currentRun.run_id)},C=(0,v.useCallback)(async()=>{var e;let n=null===(e=p.currentRun)||void 0===e?void 0:e.run_id;if(!n)return;let t=await createCheckByRun(n);y.invalidateQueries({queryKey:W.checks()}),j("/checks/".concat(t.check_id))},[null===(n=p.currentRun)||void 0===n?void 0:n.run_id,j,y]);return(0,e4.z)(()=>{"running"===p.status&&handleCancel()}),(0,r.jsxs)(l.xu,{bg:"white",rounded:"md",shadow:"dark-lg",children:["pending"===p.status&&(0,r.jsxs)(m.U,{p:"5px 15px",mt:"4",divider:(0,r.jsx)(e9.c,{borderColor:"gray.200"}),spacing:4,children:[(0,r.jsxs)(e8.h,{size:"xs",isAttached:!0,variant:"outline",rounded:"xs",onClick:d,children:[(0,r.jsxs)(h.z,{children:[c.length," selected"]}),(0,r.jsx)(M.h,{"aria-label":"Exit select Mode",icon:(0,r.jsx)(e3.D,{})})]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(AddSchemaChangesCheckButton,{nodes:c,onFinish:d}),(0,r.jsx)(AddLineageDiffCheckButton,{viewMode:a,nodes:c,onFinish:d,withIcon:!0})]}),(0,r.jsxs)(m.U,{children:[(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleRowCountDiffClick,children:[(0,r.jsx)(s.J,{as:O.SwK}),"Row count diff"]}),(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleValueDiffClick,children:[(0,r.jsx)(s.J,{as:ne.pRi}),"Value diff"]})]})]}),"pending"!==p.status&&(0,r.jsxs)(m.U,{p:"5px 15px",mt:"4",divider:(0,r.jsx)(e9.c,{borderColor:"gray.200"}),spacing:4,children:[(0,r.jsxs)(l.xu,{fontSize:"10pt",children:["Progress: ","per_node"===p.mode?"".concat(p.completed," / ").concat(p.total):(null===(o=p.currentRun)||void 0===o?void 0:null===(i=o.progress)||void 0===i?void 0:i.percentage)?"".concat(100*p.currentRun.progress.percentage,"%"):"completed"===p.status?"100%":"0%"," ","canceled"===p.status?" (canceled)":""]}),"running"===p.status||"canceling"===p.status?(0,r.jsx)(h.z,{size:"xs",variant:"outline",onClick:handleCancel,isLoading:"canceling"===p.status,loadingText:"Canceling",children:"Cancel"}):(0,r.jsxs)(m.U,{children:["multi_nodes"===p.mode&&(null===(t=p.currentRun)||void 0===t?void 0:t.result)&&(0,r.jsx)(h.z,{display:"none",size:"xs",variant:"outline",onClick:C,children:"Add to checklist"}),(0,r.jsx)(h.z,{size:"xs",variant:"outline",onClick:d,children:"Close"})]})]})]})}function RowCountDiffResultView(e){let{run:n}=e;function columnCellClass(e){if(e.base===e.current);else if(e.basee.current||"N/A"===e.current)return"column-body-removed";return"column-body-normal"}let t=n.result||{},i=Object.keys(n.result||{}).map(e=>{let n=t[e],r=(null==n?void 0:n.base)||null,i=(null==n?void 0:n.curr)||null,l="No Change";return null!==r&&null!==i?l=r!==i?deltaPercentageString(r,i):"No Change":r===i?l="N/A":null===r?l="Added":null===i&&(l="Removed"),{name:e,base:null===r?"N/A":Number(r),current:null===i?"N/A":Number(i),delta:l}});return(0,r.jsx)(a.k,{direction:"column",children:Object.keys(t).length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:[{key:"name",name:"Name",cellClass:columnCellClass},{key:"base",name:"Base Rows",cellClass:columnCellClass},{key:"current",name:"Current Rows",cellClass:columnCellClass},{key:"delta",name:"Delta",cellClass:columnCellClass}],rows:i,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},className:"rdg-light",enableScreenshot:!0})})})}function NodeRunView(e){var n,t,i,o,s,c,d,u,x;let{node:f,onCloseNode:p}=e,g=null===(n=f.action)||void 0===n?void 0:n.run,[,y]=(0,eF.TH)(),j=(0,Q.NL)(),[C,b]=(0,v.useState)(),k=(0,v.useCallback)(async()=>{if(!(null==g?void 0:g.run_id))return;let e=await createCheckByRun(g.run_id,C);j.invalidateQueries({queryKey:W.checks()}),y("/checks/".concat(e.check_id))},[null==g?void 0:g.run_id,y,j,C]),w=(null===(i=f.action)||void 0===i?void 0:null===(t=i.run)||void 0===t?void 0:t.type)==="value_diff"?ValueDiffResultView:(null===(s=f.action)||void 0===s?void 0:null===(o=s.run)||void 0===o?void 0:o.type)==="row_count_diff"?RowCountDiffResultView:null;return(0,r.jsxs)(er.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,r.jsxs)(m.U,{children:[(0,r.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,r.jsx)(ei.X,{size:"sm",children:f.name})}),(0,r.jsx)(_.L,{}),(0,r.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,r.jsx)(eu.P,{onClick:p})})]}),(0,r.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(ResourceTypeTag,{node:f}),(null==g?void 0:g.type)==="row_count_diff"&&(null===(c=g.result)||void 0===c?void 0:c[f.name])&&(0,r.jsx)(RowCountTag,{rowCount:g.result[f.name],node:f})]})}),(0,r.jsxs)(eh.m,{overflow:"auto",as:a.k,children:[(0,r.jsx)(em.t,{children:(0,r.jsx)(ex.O,{children:"Run"})}),(0,r.jsx)(ef.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,r.jsx)(ep.x,{p:0,overflowY:"auto",height:"100%",children:w?(0,r.jsx)(RunView,{run:null===(d=f.action)||void 0===d?void 0:d.run,viewOptions:C,onViewOptionsChanged:b,RunResultView:w}):(0,r.jsx)(l.xu,{p:"20px 10px",children:"No run result"})})})]}),(0,r.jsxs)(m.U,{p:"16px",children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(h.z,{size:"sm",colorScheme:"blue",isDisabled:!(null===(x=f.action)||void 0===x?void 0:null===(u=x.run)||void 0===u?void 0:u.result),onClick:k,children:"Add to checklist"})]})]})}let layout=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",r=new(w()).graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:t}),e.forEach(e=>{r.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{r.setEdge(e.source,e.target)}),w().layout(r),e.forEach(e=>{let n=r.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})},nn={customNode:GraphNode},nt={customEdge:GraphEdge},nodeColor=e=>{var n,t;return(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.changeStatus)?getIconForChangeStatus(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.changeStatus).color:"lightgray"},nr={all:"All",changed_models:"Changed Models"};function ChangeStatusLegend(){return(0,r.jsx)(l.xu,{bg:"white",padding:"12px",borderWidth:"1px",borderColor:"gray.200",fontSize:"sm",children:Object.entries({added:["Added","Added resource"],removed:["Removed","Removed resource"],modified:["Modified","Modified resource"]}).map(e=>{let[n,[t,i]]=e,{icon:l,color:c}=getIconForChangeStatus(n);return(0,r.jsx)(o.u,{label:i,children:(0,r.jsxs)(a.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,r.jsx)(s.J,{color:c,as:l})," ",t]})},n)})})}function _LineageView(e){let{...n}=e,{fitView:t,setCenter:o,getZoom:k}=(0,i._K)(),{successToast:w,failToast:_}=useClipBoardToast(),{onOpen:S,setImgBlob:R,ImageBoardModal:D}=useImageBoardModal(),{toImage:N,ref:T}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(eN))},onSuccess:async e=>{try{await copyBlobToClipboard(e),w("Copied the Lineage View as an image to clipboard")}catch(n){"ClipboardItem is not defined"===n.message?(R(e),S()):_("Failed to copy image to clipboard",n)}},onError:e=>{console.error("Error taking screenshot",e),_("Failed to copy image to clipboard",e)}}),[E,I,L]=(0,i.Rr)([]),[F,z,A]=(0,i.ll)([]),{lineageGraph:M,isLoading:P,error:V,refetchRunsAggregated:B}=useLineageGraphContext(),q=null==M?void 0:M.modifiedSet,[H,K]=(0,v.useState)("detail"),[W,U]=(0,v.useState)(),[G,Q]=(0,v.useState)(!1),[J,Z]=(0,v.useState)(n.viewMode||"changed_models"),[X,Y]=(0,v.useState)(!1),[$,ee]=(0,v.useState)({x:0,y:0});(0,v.useEffect)(()=>{if(!M)return;let e=Object.values(M.nodes),t=Object.values(M.edges);if("changed_models"===J){let n=selectUpstream(M,M.modifiedSet,1),t=selectDownstream(M,M.modifiedSet),r=union(n,t);e=e.filter(e=>r.has(e.id))}if("function"==typeof n.filterNodes){let t=n.filterNodes?n.filterNodes:()=>!0;e=e.filter(e=>t(e.id,e))}let[r,i]=toReactflow(e,t),l=selectDownstream(M,M.modifiedSet),[o,a]=highlightNodes(Array.from(l),r,i);layout(o,a),I(o),z(a)},[I,z,J,M,n.filterNodes]);let centerNode=e=>{if(e.width&&e.height){let n=e.position.x+e.width/2,t=e.position.y+e.height/2,r=k();o(n,t,{zoom:r,duration:200})}},et=(0,v.useCallback)(e=>{I(n=>{let t=n.map(n=>n.id===e.id?{...n,data:e}:n);return t})},[I]);if(P)return(0,r.jsx)(a.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,r.jsx)(c.$,{size:"xl"})});let closeContextMenu=()=>{Y(!1),ee({x:0,y:0})};return V?(0,r.jsxs)(r.Fragment,{children:["Fail to load lineage data: ",V]}):"changed_models"===J&&(void 0===q||(null==q?void 0:q.length)===0)?(0,r.jsx)(d.M,{h:"100%",children:(0,r.jsxs)(u.g,{children:[(0,r.jsx)(r.Fragment,{children:"No change detected"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>{Z("all")},children:"Show all nodes"})]})}):(0,r.jsxs)(a.k,{width:"100%",height:"100%",children:[(0,r.jsx)(l.xu,{flex:"1 0 0px",children:(0,r.jsxs)(i.x$,{nodeTypes:nn,edgeTypes:nt,nodes:E,edges:F,onNodesChange:L,onEdgesChange:A,onNodeClick:(e,t)=>{!1!==n.interactive&&(closeContextMenu(),"detail"===H?(U(t.data),G||(Q(!0),centerNode(t)),I(selectSingleNode(t.id,E))):"action_result"===H?(U(t.data),G||(Q(!0),centerNode(t)),I(selectSingleNode(t.id,E))):I(selectNode(t.id,E)))},onNodeMouseEnter:(e,n)=>{if(!M)return;let t=union(selectUpstream(M,[n.id]),selectDownstream(M,[n.id])),[r,i]=highlightNodes(Array.from(t),E,F);I(r),z(i)},onNodeMouseLeave:(e,n)=>{if(!M)return;let t=selectDownstream(M,M.modifiedSet),[r,i]=highlightNodes(Array.from(t),E,F);I(r),z(i)},onNodeContextMenu:(e,n)=>{"action"===H&&(e.preventDefault(),ee({x:e.clientX,y:e.clientY,selectedNode:n}),Y(!0))},onClick:closeContextMenu,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:n.interactive,ref:T,children:[(0,r.jsx)(j.A,{color:"#ccc"}),(0,r.jsxs)(C.Z,{showInteractive:!1,position:"top-right",className:eN,children:[n.interactive&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(C.B,{title:"switch mode",onClick:()=>{Z("all"===J?"changed_models":"all");let e=cleanUpNodes(E);I(e)},children:(0,r.jsx)(s.J,{as:O.Bw1})})}),(0,r.jsx)(C.B,{title:"copy image",onClick:()=>{N()},children:(0,r.jsx)(s.J,{as:O.C3L})})]}),(0,r.jsx)(D,{}),(0,r.jsx)(i.s_,{position:"bottom-left",children:(0,r.jsxs)(m.U,{children:[(0,r.jsx)(ChangeStatusLegend,{}),n.interactive&&(0,r.jsxs)(l.xu,{p:2,flex:"0 1 160px",fontSize:"14px",className:eN,children:[(0,r.jsx)(x.x,{color:"gray",mb:"2px",children:"Actions"}),(0,r.jsxs)(u.g,{spacing:1,align:"baseline",children:[(0,r.jsx)(h.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:"detail"!==H,onClick:()=>{let e="detail"===H?"action":"detail";U(void 0),Q(!1);let n=cleanUpNodes(E,"action"===e);I(n),K(e)},children:"Select Models"}),(0,r.jsx)(AddLineageDiffCheckButton,{viewMode:J,nodes:E.map(e=>e.data),onFinish:()=>K("detail")})]})]})]})}),(0,r.jsx)(i.s_,{position:"top-left",children:(0,r.jsx)(x.x,{fontSize:"xl",color:"grey",opacity:.5,children:nr[J]})}),(0,r.jsx)(i.s_,{position:"bottom-center",className:eN,children:(0,r.jsx)(f.R,{in:"detail"!==H,unmountOnExit:!0,style:{zIndex:10},children:(0,r.jsx)(NodeSelector,{viewMode:J,nodes:E.map(e=>e.data).filter(e=>e.isSelected),onClose:()=>{K("detail");let e=cleanUpNodes(E);U(void 0),Q(!1),I(e),null==B||B()},onActionStarted:()=>{K("action_result")},onActionNodeUpdated:et,onActionCompleted:()=>{}})})}),(0,r.jsx)(b.a,{nodeColor:nodeColor,nodeStrokeWidth:3})]})}),"detail"===H&&W&&(0,r.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,r.jsx)(NodeView,{node:W,onCloseNode:()=>{U(void 0),Q(!1),I(cleanUpNodes(E))}})}),"action_result"===H&&W&&(0,r.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,r.jsx)(NodeRunView,{node:W,onCloseNode:()=>{U(void 0),Q(!1)}})}),X&&(0,r.jsx)(p.v,{isOpen:!0,onClose:closeContextMenu,children:(0,r.jsxs)(g.q,{style:{position:"absolute",left:"".concat($.x,"px"),top:"".concat($.y,"px")},children:[(0,r.jsx)(y.s,{icon:(0,r.jsx)(en.Cv2,{}),onClick:()=>{let e=$.selectedNode;if("action"!==H||void 0===e||void 0===M)return;let n=e.id,t=selectUpstream(M,[n]),r=selectNodes([...t],E);I(r)},children:"Select parent nodes"}),(0,r.jsx)(y.s,{icon:(0,r.jsx)(en.IMj,{}),onClick:()=>{let e=$.selectedNode;if("action"!==H||void 0===e||void 0===M)return;let n=e.id,t=selectDownstream(M,[n]),r=selectNodes([...t],E);I(r)},children:"Select child nodes"})]})})]})}function LineageView(e){let{...n}=e;return void 0===n.interactive&&(n.interactive=!0),void 0===n.viewMode&&(n.viewMode="changed_models"),(0,r.jsx)(i.tV,{children:(0,r.jsx)(_LineageView,{...n})})}var ni=t(16761),nl=t(98786);function RecceContextProvider(e){let{children:n}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(RecceQueryContextProvider,{children:(0,r.jsx)(LineageGraphContextProvider,{children:(0,r.jsx)(RowCountStateContextProvider,{children:(0,r.jsx)(RecceActionContextProvider,{children:n})})})})})}function useVersionNumber(){let[e,n]=(0,v.useState)("");return(0,v.useEffect)(()=>{(async function(){try{let e=await H.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}var no=t(45489),na=t(69005),ns=t(14800),nc=t(2600),nd=t(68677),nu=t(83358),nh=t(44525),nm=t(93197),nx=t(234),nf=t(96094),np=t(36334);function CheckBreadcrumb(e){let{name:n,setName:t}=e,[i,o]=(0,v.useState)(!1),[a,s]=(0,v.useState)(n),c=(0,v.useRef)(null),d=(0,v.useCallback)(()=>{t(a),o(!1)},[t,o,a]);return(0,v.useEffect)(()=>{let handleClickOutside=e=>{c.current&&!c.current.contains(e.target)&&d()};return i&&document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[i,c,d]),(0,r.jsxs)(nx.a,{flex:"0 1",fontSize:"12pt",fontWeight:"500",separator:(0,r.jsx)(np.X,{color:"gray.500"}),children:[(0,r.jsx)(nf.g,{children:(0,r.jsx)(l.xu,{children:"Checklist"})}),(0,r.jsx)(nf.g,{flex:"0 1",cursor:"pointer",children:i?(0,r.jsx)(eP.I,{ref:c,value:a,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Enter"===e.key?(t(a),o(!1)):"Escape"===e.key&&(s(n),o(!1))},size:"sm",w:"auto",minW:"200px",maxW:"600px"}):(0,r.jsx)(l.xu,{onClick:()=>{s(n),o(!0)},textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n})})]})}function SchemaDiffView(e){let{check:n}=e,{lineageGraph:t}=useLineageGraphContext(),i=n.params,l=i.node_id,o=l?null==t?void 0:t.nodes[l]:void 0;return o?(0,r.jsx)(SchemaView,{base:o.data.base,current:o.data.current,enableScreenshot:!0}):(0,r.jsx)(r.Fragment,{})}var ng=t(33695);function CheckDescription(e){let{value:n,onChange:t}=e,[i,l]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),c=(0,v.useRef)(null);return((0,v.useEffect)(()=>{if(i&&c.current){let e=c.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[i]),i)?(0,r.jsxs)(a.k,{direction:"column",align:"flex-end",children:[(0,r.jsx)(ng.g,{h:"200px",value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&l(!1)},ref:c}),(0,r.jsxs)(a.k,{gap:"12px",alignItems:"flex-end",children:[(0,r.jsx)(eG.r,{onClick:()=>{setTimeout(()=>{l(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,r.jsx)(h.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:()=>{t&&(t(o),l(!1))},children:"Update"})]})]}):(0,r.jsx)(x.x,{maxHeight:"400px",overflow:"auto",fontSize:"11pt",onClick:()=>{s(n||""),l(!0)},whiteSpace:"pre-line",color:n?"inherit":"lightgray",children:n||"Add description here"})}var ny=t(48742);function _templateObject(){let e=(0,no._)(["\n **SQL**\n ```sql\n ","\n ```\n "],["\n **SQL**\n \\`\\`\\`sql\n ","\n \\`\\`\\`\n "]);return _templateObject=function(){return e},e}function buildTitle(e){return"".concat(e.is_checked?"✅ ":"").concat(e.name)}function buildDescription(e){return e.description?e.description:"_(no description)_"}function buildQuery(e){var n;return(0,ny.Pn)(_templateObject(),null===(n=e.params)||void 0===n?void 0:n.sql_template)}var query_SqlEditor=e=>{let{value:n,onChange:t,onRun:i,onRunDiff:l,options:o={},...a}=e;return(0,r.jsx)(eL.ZP,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{i&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,i),l&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyMod.Shift|n.KeyCode.Enter,l)},options:{tabSize:2,fontSize:16,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"indent",...o}})};function DataFrameColumnHeader(e){let{name:n,pinnedColumns:t=[],onPinnedColumnsChange:i=()=>{}}=e,o=t.includes(n);return(0,r.jsxs)(a.k,{className:"grid-header",alignItems:"center",children:[(0,r.jsx)(l.xu,{flex:1,children:n}),(0,r.jsx)(s.J,{className:o?"unpin-icon":"pin-icon",display:o?"block":"none",cursor:"pointer",as:o?S.$kI:S.oJP,onClick:o?()=>{let e=t.filter(e=>e!==n);i(e)}:()=>{let e=[...t,n];i(e)}})]})}function QueryResultView_toDataGrid(e,n){let t=[],i=n.pinnedColumns||[],toColumn=(e,t)=>({key:String(e),name:(0,r.jsx)(DataFrameColumnHeader,{name:t,...n}),width:"auto",renderCell:defaultRenderCell});return t.push({key:"_index",name:"",width:10,cellClass:"index-column"}),i.forEach(n=>{let r=eH().findIndex(e.columns,e=>e.name===n);r<0||t.push(toColumn(r,n))}),e.columns.forEach((e,n)=>{i.includes(e.name)||t.push(toColumn(n,e.name))}),e.data.forEach((e,n)=>{e._index=n+1}),{columns:t,rows:e.data}}let QueryResultView=e=>{let{run:n,viewOptions:t,onViewOptionsChanged:i,onAddToChecklist:s}=e,c=(0,v.useMemo)(()=>(null==t?void 0:t.pinned_columns)||[],[t]),u=null==n?void 0:n.result,h=(0,v.useMemo)(()=>u?QueryResultView_toDataGrid(u,{pinnedColumns:c,onPinnedColumnsChange:e=>{i&&i({...t,pinned_columns:e})}}):{rows:[],columns:[]},[u,c,t,i]);if(0===h.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});let m=(null==u?void 0:u.limit)||0,x=m>0&&(null==u?void 0:u.more)?"Warning: Displayed results are limited to ".concat(m.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(s||x)&&(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:x?"orange.100":"inherit",children:[x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.a,{color:"orange.600",alignSelf:"center"})," ",(0,r.jsx)(l.xu,{children:x})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),s&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>s(n)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},QueryDiffResultView=e=>{var n,t,i,s,c,h;let{run:m,onAddToChecklist:x,viewOptions:f,onViewOptionsChanged:p}=e,g=(0,v.useMemo)(()=>(null==f?void 0:f.primary_keys)||[],[f]),y=(0,v.useMemo)(()=>(null==f?void 0:f.changed_only)||!1,[f]),j=(0,v.useMemo)(()=>(null==f?void 0:f.pinned_columns)||[],[f]),C=(0,v.useMemo)(()=>{var e,n;return toDataDiffGrid(null==m?void 0:null===(e=m.result)||void 0===e?void 0:e.base,null==m?void 0:null===(n=m.result)||void 0===n?void 0:n.current,{changedOnly:y,primaryKeys:g,onPrimaryKeyChange:e=>{p&&p({...f,primary_keys:e})},pinnedColumns:j,onPinnedColumnsChange:e=>{p&&p({...f,pinned_columns:e})}})},[m,f,y,g,j,p]),b=(0,v.useMemo)(()=>{let e=g.join(", ");return C.invalidPKeyBase&&C.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):C.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):C.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[C.invalidPKeyBase,C.invalidPKeyCurrent,g]);if(0===C.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});if(y&&0===C.rows.length)return(0,r.jsx)(d.M,{height:"100%",children:"No change"});let k=(null===(t=m.result)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.limit)||0,w=k>0&&((null==m?void 0:null===(s=m.result)||void 0===s?void 0:null===(i=s.current)||void 0===i?void 0:i.more)||(null==m?void 0:null===(h=m.result)||void 0===h?void 0:null===(c=h.base)||void 0===c?void 0:c.more))?"Warning: Displayed results are limited to ".concat(k.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:w||b?"orange.100":"inherit",children:[(0,r.jsxs)(u.g,{alignItems:"flex-start",spacing:0,children:[b&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",b]}),w&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",w]})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),(0,r.jsx)(eV.X,{isChecked:null==f?void 0:f.changed_only,onChange:()=>{let e=!(null==f?void 0:f.changed_only);p&&p({...f,changed_only:e})},children:"Changed only"}),x&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>x(m)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:C.columns,rows:C.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};function LineageDiffView(e){var n;let{check:t}=e,i=(null===(n=t.params)||void 0===n?void 0:n.view_mode)||"";return(0,r.jsx)(a.k,{direction:"column",height:"100%",children:(0,r.jsx)(LineageView,{viewMode:i,interactive:!1,filterNodes:e=>{var n,r;return null===(r=t.params)||void 0===r?void 0:null===(n=r.node_ids)||void 0===n?void 0:n.includes(e)}})})}function CheckDetail_templateObject(){let e=(0,no._)(["\n
","\n\n ","\n\n
"]);return CheckDetail_templateObject=function(){return e},e}let nv={query:QueryResultView,query_diff:QueryDiffResultView,value_diff:ValueDiffResultView,value_diff_detail:ValueDiffDetailResultView,profile_diff:ProfileDiffResultView,row_count_diff:RowCountDiffResultView,top_k_diff:TopKDiffResultView,histogram_diff:HistogramDiffResultView},useCancelOnUnmount=e=>{let{runId:n,isPending:t,setAborting:r}=e;(0,v.useEffect)(()=>()=>{r(!1),n&&t&&cancelRun(n)},[t,n,r])},CheckDetail=e=>{var n;let{checkId:t}=e,i=(0,Q.NL)(),[,c]=(0,eF.TH)(),{successToast:u,failToast:m}=useClipBoardToast(),[x,f]=(0,v.useState)(),[j,C]=(0,v.useState)(),[b,k]=(0,v.useState)(!1),{isLoading:w,error:R,refetch:D,data:N}=(0,U.a)({queryKey:W.check(t),queryFn:async()=>getCheck(t),refetchOnMount:!1,staleTime:3e5}),T=N&&(null==N?void 0:N.type)in nv?nv[null==N?void 0:N.type]:void 0,{mutate:E}=(0,eK.D)({mutationFn:e=>updateCheck(t,e),onSuccess:()=>{i.invalidateQueries({queryKey:W.check(t)}),i.invalidateQueries({queryKey:W.checks()})}}),{mutate:I}=(0,eK.D)({mutationFn:()=>deleteCheck(t),onSuccess:()=>{i.invalidateQueries({queryKey:W.checks()}),c("/checks")}}),submitRunFn=async()=>{let e=null==N?void 0:N.type;if(!e)return;let{run_id:n}=await submitRunFromCheck(t,{nowait:!0});for(f(n);;){let e=await waitRun(n,2);if(C(e.progress),e.result||e.error)return k(!1),C(void 0),e}},{data:L,mutate:F,error:z,isIdle:A,isPending:O}=(0,eK.D)({mutationFn:submitRunFn,onSuccess:e=>{D()}}),handleRerun=async()=>{F()},P=(0,v.useCallback)(async()=>{if(k(!0),x)return await cancelRun(x)},[x]);useCancelOnUnmount({runId:x,isPending:O,setAborting:k});let handleCopy=async()=>{if(!N)return;let e=buildMarkdown(N);if(!navigator.clipboard){m("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),u("Copied the check to the clipboard")}catch(e){m("Failed to copy the check to clipboard",e)}},V=(0,v.useCallback)(()=>{let e=null==N?void 0:N.is_checked;E({is_checked:!e})},[null==N?void 0:N.is_checked,E]);if(w)return(0,r.jsx)(d.M,{h:"100%",children:"Loading"});if(R)return(0,r.jsxs)(d.M,{h:"100%",children:["Error: ",R.message]});let B=A?null==N?void 0:N.last_run:L,q=(null==B?void 0:B.run_at)?(0,eW.Z)(new Date(B.run_at),{addSuffix:!0}):null;return(0,r.jsxs)(a.k,{height:"100%",width:"100%",maxHeight:"100%",direction:"column",children:[(0,r.jsxs)(a.k,{p:"0px 16px",alignItems:"center",children:[(0,r.jsx)(CheckBreadcrumb,{name:(null==N?void 0:N.name)||"",setName:e=>{E({name:e})}}),(0,r.jsx)(_.L,{}),(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{isRound:!0,as:M.h,icon:(0,r.jsx)(s.J,{as:S.D_A}),variant:"ghost"}),(0,r.jsx)(g.q,{children:(0,r.jsx)(y.s,{icon:(0,r.jsx)(nh.p,{}),onClick:()=>I(),children:"Delete"})})]}),q&&(0,r.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:q}),N&&(null==N?void 0:N.type)in nv&&(0,r.jsx)(o.u,{label:"Rerun",children:(0,r.jsx)(M.h,{isRound:!0,isLoading:O,variant:"ghost","aria-label":"Rerun",icon:(0,r.jsx)(ee.n,{}),onClick:()=>handleRerun()})}),(0,r.jsx)(o.u,{label:"Copy markdown",children:(0,r.jsx)(M.h,{isRound:!0,variant:"ghost","aria-label":"Copy markdown",icon:(0,r.jsx)(eC.T,{}),onClick:()=>handleCopy()})}),(0,r.jsx)(o.u,{label:(null==N?void 0:N.is_checked)?"Mark as unchecked":"Mark as checked",children:(0,r.jsx)(h.z,{size:"sm",colorScheme:(null==N?void 0:N.is_checked)?"green":"gray",leftIcon:(0,r.jsx)(nm.r,{}),onClick:()=>V(),children:(null==N?void 0:N.is_checked)?"Checked":"Unchecked"})})]}),(0,r.jsx)(l.xu,{p:"8px 16px",minHeight:"100px",children:(0,r.jsx)(CheckDescription,{value:null==N?void 0:N.description,onChange:e=>{E({description:e})}},null==N?void 0:N.check_id)}),((null==N?void 0:N.type)==="query"||(null==N?void 0:N.type)==="query_diff")&&(0,r.jsx)(na.U,{defaultIndex:[],allowToggle:!0,children:(0,r.jsxs)(ns.Q,{children:[(0,r.jsxs)(nc.K,{children:["query",(0,r.jsx)(nd.X,{})]}),(0,r.jsx)(nu.H,{children:(0,r.jsx)(l.xu,{height:"400px",width:"100%",border:"lightgray 1px solid ",children:(0,r.jsx)(query_SqlEditor,{value:(null===(n=null==N?void 0:N.params)||void 0===n?void 0:n.sql_template)||"",options:{readOnly:!0}})})})]})}),(0,r.jsxs)(l.xu,{style:{contain:"size"},flex:"1 1 0%",children:[T&&(0,r.jsx)(RunView,{isPending:O,isAborting:b,run:B,error:z,progress:j,RunResultView:T,viewOptions:null==N?void 0:N.view_options,onViewOptionsChanged:e=>{E({view_options:e})},onCancel:P}),N&&"schema_diff"===N.type&&(0,r.jsx)(SchemaDiffView,{check:N}),N&&"lineage_diff"===N.type&&(0,r.jsx)(LineageDiffView,{check:N})]})]})};function buildMarkdown(e){return(0,ny.Pn)(CheckDetail_templateObject(),buildTitle(e),buildBody(e))}function buildBody(e){return"query"===e.type||"query_diff"===e.type?"".concat(buildDescription(e),"\n\n").concat(buildQuery(e)):buildDescription(e)}var nj=t(79648),nC=t(38505);let ChecklistItem=e=>{let{check:n,selected:t,onSelect:i}=e,o=(0,Q.NL)(),c=n.check_id,{mutate:d}=(0,eK.D)({mutationFn:e=>updateCheck(c,e),onSuccess:()=>{o.invalidateQueries({queryKey:W.check(c)}),o.invalidateQueries({queryKey:W.checks()})}}),u=(e=>{switch(e){case"schema_diff":return ne.uhn;case"query":case"query_diff":return ne.r2i;case"value_diff":return ne.pRi;case"profile_diff":return ne.KA6;case"row_count_diff":return O.SwK;case"lineage_diff":return ne.Ks7;case"top_k_diff":return nj.Pkc;case"histogram_diff":return ne.dku;default:return ne.WzH}})(n.type);return(0,r.jsxs)(a.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"gray.200"},bg:t?"gray.100":"inherit",onClick:()=>i(n.check_id),alignItems:"center",gap:"5px",children:[(0,r.jsx)(s.J,{as:u}),(0,r.jsx)(l.xu,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n.name}),n.is_checked&&(0,r.jsx)(s.J,{color:"green",as:R.FJM})]})},CheckList=e=>{let{checks:n,selectedItem:t,onCheckSelected:i,onChecksReordered:l}=e;return(0,r.jsx)(nC.Z5,{onDragEnd:e=>{e.destination&&l(e.source.index,e.destination.index)},children:(0,r.jsx)(nC.bK,{droppableId:"checklist",children:e=>(0,r.jsxs)(u.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",children:[n.map((e,n)=>(0,r.jsx)(nC._l,{draggableId:e.check_id,index:n,children:n=>(0,r.jsx)(a.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,r.jsx)(ChecklistItem,{check:e,selected:e.check_id===t,onSelect:i},e.check_id)})},e.check_id)),e.placeholder]})})})};var nb=t(73672),nk=t(83561);function CheckListInitLoader(){let e=(0,Z.p)(),n=(0,Q.NL)(),t=(0,v.useRef)(null),[i,l]=(0,v.useState)(null),[,o]=useRunsAggregated(),a=(0,v.useCallback)(async()=>{if(i)try{let{checks:t}=await loadChecks(i);o(),n.invalidateQueries({queryKey:W.checks()}),e({description:"".concat(t," checks loaded successfully"),status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(n){console.error("Load failed",n),e({title:"Load failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}},[n,e,i,o]);return(0,v.useEffect)(()=>{i&&a()},[i,a]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.z,{onClick:()=>{t.current&&t.current.click()},children:"Load a checklist"}),(0,r.jsx)("input",{type:"file",style:{display:"none"},ref:t,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&l(e.target.files[0])}})]})}function CheckListLoader(){let e=(0,Z.p)(),n=(0,Q.NL)(),t=(0,v.useRef)(null),i=(0,v.useRef)(null),[l,c]=(0,v.useState)(null),{isOpen:d,onOpen:u,onClose:m}=(0,et.q)(),[,f]=(0,eF.TH)(),[,p]=useRunsAggregated(),g=(0,v.useCallback)(async()=>{if(l){try{let{checks:t}=await loadChecks(l);p(),await n.invalidateQueries({queryKey:W.checks()}),f("/checks"),e({description:"".concat(t," checks loaded successfully"),status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(n){console.error("Load failed",n),e({title:"Load failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}m()}},[n,l,e,m,f,p]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.u,{label:"Load checklist",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Load checks",mr:"10px",onClick:()=>{t.current&&t.current.click()},icon:(0,r.jsx)(s.J,{pt:"10px",as:nk._mA,boxSize:"2em"})})}),(0,r.jsx)("input",{type:"file",style:{display:"none"},ref:t,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&(c(e.target.files[0]),u())}}),(0,r.jsx)(nb.a,{isOpen:d,leastDestructiveRef:i,onClose:m,size:"lg",children:(0,r.jsx)(eo.Z,{children:(0,r.jsxs)(nb._,{children:[(0,r.jsx)(es.x,{fontSize:"lg",fontWeight:"bold",children:"Load checklist"}),(0,r.jsx)(ed.f,{children:(0,r.jsxs)(a.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,r.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,r.jsx)(I.s,{color:"red.600"}),(0,r.jsx)(x.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,r.jsx)(a.k,{children:(0,r.jsxs)(x.x,{children:["The checklist will be"," ",(0,r.jsx)(x.x,{as:"span",fontWeight:"600",children:"overwritten"})," ","by the loaded checklist"]})})]})}),(0,r.jsxs)(ek.m,{children:[(0,r.jsx)(h.z,{ref:i,onClick:m,children:"Cancel"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:g,ml:"5px",children:"Load"})]})]})})})]})}var nw=t(472);function CheckListExporter(){let e=(0,Z.p)(),handleExport=async()=>{try{let e=await exportChecks(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),r=new Date,i="recce-state-".concat((0,eS.ZP)(r,"yyyy-MM-dd-HH-mm-ss"),".json");eD()(t,i)}catch(n){console.error("Export failed",n),e({title:"Export failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}};return(0,r.jsx)(o.u,{label:"Export checklist",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Export checks",onClick:handleExport,icon:(0,r.jsx)(nw._,{})})})}function CheckPage_templateObject(){let e=(0,no._)(["\n
","\n\n ","\n\n
"]);return CheckPage_templateObject=function(){return e},e}let CheckPage=()=>{let{isDemoSite:e}=useLineageGraphContext(),[,n]=(0,eF.TH)(),[,t]=(0,eF.yj)("/checks/:checkId"),i=(0,Q.NL)(),{successToast:s,failToast:c}=useClipBoardToast(),x=null==t?void 0:t.checkId,{isLoading:f,error:p,data:g,status:y}=(0,U.a)({queryKey:W.checks(),queryFn:listChecks,refetchOnMount:!0}),j=(0,v.useCallback)(e=>{n("/checks/".concat(e))},[n]),[C,b]=(0,v.useState)(g||[]),{mutate:k}=(0,eK.D)({mutationFn:e=>reorderChecks(e),onSuccess:()=>{i.invalidateQueries({queryKey:W.checks()})}}),w=(0,v.useCallback)((e,n)=>{let t=[...C],[r]=t.splice(e,1);t.splice(n,0,r),k({source:e,destination:n}),b(t)},[C,b,k]),_=(0,v.useCallback)(async()=>{let e=await createSimpleCheck();i.invalidateQueries({queryKey:W.checks()}),j(e.check_id)},[i,j]);return((0,v.useEffect)(()=>{"success"===y&&(!x&&g.length>0&&n("/checks/".concat(g[0].check_id)),b(g))},[y,x,g,b,n]),f)?(0,r.jsx)(r.Fragment,{children:"Loading"}):p?(0,r.jsxs)(r.Fragment,{children:["Error: ",p.message]}):(null==g?void 0:g.length)?(0,r.jsxs)(a.k,{height:"100%",children:[(0,r.jsx)(l.xu,{flex:"0 0 400px",borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,r.jsxs)(u.g,{spacing:0,align:"flex-end",h:"100%",children:[(0,r.jsxs)(m.U,{gap:"0px",children:[(0,r.jsx)(o.u,{label:"Create a simple check",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Create a simple check",onClick:_,icon:(0,r.jsx)(eU.d,{})})}),(0,r.jsx)(o.u,{label:"Copy checklist to the clipboard",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Copy checklist to the clipboard",onClick:async()=>{let e=CheckPage_buildMarkdown(g);if(!navigator.clipboard){c("Failed to copy checklist to clipboard",Error("Copy to clipboard is available only in secure contexts (HTTPS)"));return}try{await navigator.clipboard.writeText(e),s("Copied ".concat(g.length," checks to the clipboard"))}catch(e){c("Failed to copy checklist to clipboard",e)}},icon:(0,r.jsx)(eC.T,{})})}),!e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(CheckListExporter,{}),(0,r.jsx)(CheckListLoader,{})]})]}),(0,r.jsx)(eQ.i,{mb:"8px"}),(0,r.jsx)(CheckList,{checks:C,selectedItem:x,onCheckSelected:j,onChecksReordered:w})]})}),(0,r.jsx)(l.xu,{flex:"1",height:"100%",width:"calc(100% - 400px)",children:(0,r.jsx)(eF.rs,{children:(0,r.jsx)(eF.AW,{path:"/checks/:checkId",children:e=>(0,r.jsx)(CheckDetail,{checkId:e.checkId},e.checkId)})})})]}):(0,r.jsx)(d.M,{h:"100%",children:(0,r.jsxs)(u.g,{children:[(0,r.jsx)(l.xu,{children:"No checks"}),(0,r.jsxs)(a.k,{gap:"5",children:[(0,r.jsx)(h.z,{colorScheme:"blue",onClick:_,children:"Create a simple check"}),!e&&(0,r.jsx)(CheckListInitLoader,{})]})]})})};function CheckPage_buildMarkdown(e){let n=e.map(e=>(0,ny.Pn)(CheckPage_templateObject(),buildTitle(e),buildDescription(e)));return n.join("\n\n")}async function submitQuery(e,n){return await submitRun("query",e,n)}async function submitQueryDiff(e,n){return await submitRun("query_diff",e,n)}let QueryPage=()=>{let{sqlQuery:e,setSqlQuery:n}=useRecceQueryContext(),[t,i]=(0,v.useState)(),[o,s]=(0,v.useState)(),[c,d]=(0,v.useState)({}),u=(0,Q.NL)(),[,m]=(0,eF.TH)(),queryFn=async n=>{i(n);let{run_id:t}="query"===n?await submitQuery({sql_template:e},{nowait:!0}):await submitQueryDiff({sql_template:e},{nowait:!0});return s(t),await waitRun(t)},{data:x,mutate:f,error:p,isPending:g}=(0,eK.D)({mutationFn:queryFn,onSuccess:e=>{d({})}}),y=(0,v.useCallback)(async()=>{if(o)return await cancelRun(o)},[o]),j=(0,v.useCallback)(async e=>{if(!(null==e?void 0:e.run_id))return;let n=await createCheckByRun(e.run_id,c);u.invalidateQueries({queryKey:W.checks()}),m("/checks/".concat(n.check_id))},[m,c,u]);return!g&&(null==x?void 0:x.run_id)&&(null==x||x.error),(0,r.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,r.jsxs)(a.k,{justifyContent:"right",padding:"5px",gap:"5px",children:[(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>f("query_diff"),isDisabled:g,size:"sm",children:"Run Diff"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>f("query"),isDisabled:g,size:"sm",children:"Run"})]}),(0,r.jsx)(l.xu,{flex:"1",border:"1px solid #CBD5E0",height:"200px",width:"100%",children:(0,r.jsx)(query_SqlEditor,{value:e,onChange:n,onRun:()=>f("query"),onRunDiff:()=>f("query_diff")})}),(0,r.jsx)(a.k,{height:"50vh",direction:"column",children:"query"===t?(0,r.jsx)(RunView,{run:x,error:p,isPending:g,onCancel:y,children:e=>(0,r.jsx)(QueryResultView,{...e,onAddToChecklist:j})},o):(0,r.jsx)(RunView,{isPending:g,run:x,error:p,viewOptions:c,onViewOptionsChanged:d,onCancel:y,children:e=>(0,r.jsx)(QueryDiffResultView,{...e,onAddToChecklist:j})},o)})]})};var n_=t(72952);let hashNavigate=e=>(0,n_.c4)("#!"+e),useHashLocation=()=>{let e=(0,n_.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr");return[e,hashNavigate]};var nS=t(82017),nR=t(41546);let RunPage=e=>{let{runId:n}=e,{isPending:t,error:i,data:l}=(0,U.a)({queryKey:W.run(n),queryFn:async()=>waitRun(n)});return(0,r.jsx)(RunView,{isPending:t,error:i,run:l,RunResultView:ValueDiffResultView})};var nD=t(26954);let Fallback=e=>{let{error:n,resetError:t}=e;return(0,r.jsx)(d.M,{height:"100%",backgroundColor:"gray.50",children:(0,r.jsxs)(a.k,{p:4,direction:"column",justifyContent:"flex-start",backgroundColor:"white",border:"solid lightgray 1px",minHeight:"200px",children:[(0,r.jsx)(ei.X,{width:"800px",size:"md",children:"You have encountered an error"}),(0,r.jsx)(l.xu,{flex:"1",fontSize:"10pt",children:n.toString()}),(0,r.jsx)(h.z,{justifySelf:"center",alignSelf:"center",mt:"20px",colorScheme:"blue",size:"sm",onClick:()=>{t()},children:"Reset"})]})})},ErrorBoundary=e=>{let{children:n}=e;return(0,r.jsx)(nD.SV,{fallback:Fallback,children:n})};var nN=t(12218);function getCookie(e){var n=document.cookie.match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n.pop():""}let RouteAlwaysMount=e=>{let{children:n,path:t}=e,[i]=(0,eF.yj)(t);return(0,r.jsx)(l.xu,{display:i?"block":"none",height:"100%",children:n})};function TopBar(){let{metadata:e}=useLineageGraphContext(),n=null==e?void 0:e.pr_url;return n&&null!==n?(0,r.jsxs)(a.k,{gap:"5px",minHeight:"35px",alignItems:"center",justifyContent:"center",bg:"orange.300",children:[(0,r.jsx)(I.s,{color:"orange.600"}),(0,r.jsxs)(x.x,{children:["Please check"," ",(0,r.jsx)(eG.r,{textDecoration:"underline",fontWeight:"600",href:n,isExternal:!0,children:"this Pull Request"})," ","comment for context about this Recce instance"]})]}):(0,r.jsx)(r.Fragment,{})}function NavBar(){let[e,n]=(0,eF.TH)(),t=useVersionNumber(),i=[["Lineage","/lineage"],["Query","/query"],["Checklist","/checks"]],o=eH().findIndex(i,n=>{let[,t]=n;return e.startsWith(t)});return(0,r.jsx)(eh.m,{index:o,children:(0,r.jsxs)(em.t,{children:[i.map(e=>{let[t,i]=e;return(0,r.jsx)(ex.O,{onClick:()=>{n(i)},children:t},t)}),(0,r.jsx)(l.xu,{position:"absolute",right:"0",top:"0",p:"2",color:"gray.500",children:t})]})})}function Home(){(0,v.useLayoutEffect)(()=>{let e=getCookie("recce_user_id");if(e&&nN.env.AMPLITUDE_API_KEY)try{nl.S1(nN.env.AMPLITUDE_API_KEY,e,{defaultTracking:!0})}catch(e){console.error(e)}},[]);let e=(0,nS.Z)({components:{MuiTooltip:{styleOverrides:{tooltip:{zIndex:1500}}}}});return(0,r.jsx)(nR.Z,{theme:e,children:(0,r.jsx)(ni.x,{children:(0,r.jsx)(Q.aH,{client:K,children:(0,r.jsx)(eF.F0,{hook:useHashLocation,children:(0,r.jsx)(RecceContextProvider,{children:(0,r.jsxs)(a.k,{direction:"column",height:"100vh",children:[(0,r.jsx)(TopBar,{}),(0,r.jsx)(NavBar,{}),(0,r.jsx)(ErrorBoundary,{children:(0,r.jsxs)(l.xu,{p:0,overflow:"auto",flex:"1",style:{contain:"size"},children:[(0,r.jsx)(RouteAlwaysMount,{path:"/lineage",children:(0,r.jsx)(LineageView,{})}),(0,r.jsxs)(eF.rs,{children:[(0,r.jsx)(eF.AW,{path:"/query",children:(0,r.jsx)(QueryPage,{})}),(0,r.jsx)(eF.AW,{path:"/checks/:slug*",children:(0,r.jsx)(CheckPage,{})}),(0,r.jsx)(eF.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,r.jsx)(RunPage,{runId:n})}}),(0,r.jsx)(eF.AW,{path:"/ssr",children:(0,r.jsx)(r.Fragment,{children:"Loading"})}),(0,r.jsx)(eF.AW,{children:(0,r.jsx)(eF.l_,{to:"/lineage"})})]})]})})]})})})})})})}},88727:function(){},7866:function(){},75165:function(){}},function(e){e.O(0,[634,145,170,521,462,531,498,685,182,710,971,495,599,512,405,297,62,744],function(){return e(e.s=99178)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/recce/data/_next/static/chunks/app/page-f175b9de49fe2892.js b/recce/data/_next/static/chunks/app/page-f175b9de49fe2892.js deleted file mode 100644 index 3468ec7c..00000000 --- a/recce/data/_next/static/chunks/app/page-f175b9de49fe2892.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{99178:function(e,n,t){Promise.resolve().then(t.bind(t,76625))},76625:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Home}});var r=t(757),i=t(27869);function getNeighborSet(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,r=new Set,i={},dfs=(e,t)=>{if(t<0||void 0!==i[e]&&i[e]>=t)return;i[e]=t;let l=n(e);for(let e of l)dfs(e,t-1);r.add(e)};for(let n of e)dfs(n,t);return r}function buildDefaultLineageGraphSets(e,n){function buildAllLineageGraph(e,n){let t={},r={},buildNode=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,r]of Object.entries(e.parent_map)){t[n]=buildNode(n,"base");let r=e.nodes&&e.nodes[n];r&&(t[n].data.base=r,t[n].name=null==r?void 0:r.name,t[n].resourceType=null==r?void 0:r.resource_type,t[n].packageName=null==r?void 0:r.package_name)}for(let[e,r]of Object.entries(n.parent_map)){t[e]?t[e].from="both":t[e]=buildNode(e,"current");let r=n.nodes&&n.nodes[e];r&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==r?void 0:r.name,t[e].resourceType=null==r?void 0:r.resource_type,t[e].packageName=null==r?void 0:r.package_name)}for(let[n,i]of Object.entries(e.parent_map))for(let e of i){let i=t[n],l=t[e],o="".concat(e,"_").concat(n);r[o]={id:o,from:"base",parent:l,child:i};let a=r[o];i.parents[e]=a,l.children[n]=a}for(let[e,i]of Object.entries(n.parent_map))for(let n of i){let i=t[e],l=t[n],o="".concat(n,"_").concat(e);r[o]?r[o].from="both":r[o]={id:o,from:"current",parent:l,child:i};let a=r[o];i.parents[n]=a,l.children[e]=a}return{edges:r,nodes:t}}function buildChangedOnlyLineageGraph(e,n){let t={},r={};function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{r.add(e)})}),r}let i=selectDownstream(e,n),l=selectUpstream(e,n,1),o=union(i,l);return Object.entries(e.nodes).forEach(e=>{let[n,r]=e;o.has(n)&&(t[n]=r)}),Object.entries(e.edges).forEach(e=>{let[n,t]=e;o.has(t.parent.id)&&o.has(t.child.id)&&(r[n]=t)}),{nodes:t,edges:r}}let{nodes:t,edges:r}=buildAllLineageGraph(e,n),i=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",i.push(n.id);else if("current"===n.from)n.changeStatus="added",i.push(n.id);else{var l,o,a,s,c,d;let e=null==n?void 0:null===(a=n.data)||void 0===a?void 0:null===(o=a.base)||void 0===o?void 0:null===(l=o.checksum)||void 0===l?void 0:l.checksum,t=null==n?void 0:null===(d=n.data)||void 0===d?void 0:null===(c=d.current)||void 0===c?void 0:null===(s=c.checksum)||void 0===s?void 0:s.checksum;e&&t&&e!==t&&(n.changeStatus="modified",i.push(n.id))}for(let[e,n]of Object.entries(r))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{all:{nodes:t,edges:r},changed:buildChangedOnlyLineageGraph({nodes:t,edges:r},i),modifiedSet:i,catalogExistence:{base:!!e.catalog_metadata,current:!!n.catalog_metadata}}}function selectUpstream(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].parents),t)}function selectDownstream(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children),t)}function toReactflow(e,n){let t=[],r=[];for(let[n,r]of Object.entries(e.nodes))t.push({id:r.id,position:{x:0,y:0},data:r,type:"customNode",targetPosition:i.Ly.Left,sourcePosition:i.Ly.Right});for(let[n,t]of Object.entries(e.edges))r.push({id:t.id,type:"customEdge",source:t.parent.id,target:t.child.id,data:t});return highlightPath(e,n,t,r,null)}function highlightPath(e,n,t,r,i){function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{r.add(e)})}),r}let l=null!==i?union(selectUpstream(e,[i]),selectDownstream(e,[i])):getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children)),o=new Set(r.filter(e=>l.has(e.source)&&l.has(e.target)).map(e=>e.id)),a=t.map(e=>({...e,data:{...e.data,isHighlighted:l.has(e.id)}})),s=r.map(e=>({...e,data:{...e.data,isHighlighted:o.has(e.id)}}));return[a,s]}function selectSingleNode(e,n){let t=n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:t}}});return t}function selectNode(e,n){let t=n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:n.data.isSelected!==t}}});return t}function selectNodes(e,n){let t=n.map(n=>{let t=e.includes(n.id);return{...n,data:{...n.data,isSelected:n.data.isSelected||t}}});return t}function cleanUpNodes(e,n){let t=e.map(e=>({...e,data:{...e.data,isSelected:!1,isActionMode:n,action:void 0}}));return t}var l=t(10126),o=t(83172),a=t(55528),s=t(29330),c=t(46543),d=t(76920),u=t(39668),h=t(83179),m=t(62648),x=t(43093),f=t(40312),p=t(36700),g=t(10287),y=t(48950),v=t(27726),j=t(26187),C=t(23704),b=t(33710),k=t(93864),w=t.n(k);t(94570);var _=t(90593),S=t(11180),R=t(63240),D=t(54057);let N=S.Nbv,E=S.sFB,T=S.UGs;function getIconForChangeStatus(e){return"added"===e?{color:"#1dce00",icon:N}:"removed"===e?{color:"#ff4444",icon:E}:"modified"===e?{color:"#ffa502",icon:T}:{color:"inherit",icon:void 0}}function getIconForResourceType(e){return"model"===e?{color:"#c0eafd",icon:R.Fn3}:"metric"===e?{color:"#ffe6ee",icon:D._MV}:"source"===e?{color:"#a6dda6",icon:R.i1q}:"exposure"===e?{color:"#ffe6ee",icon:D.n8P}:"semantic_model"===e?{color:"#fb8caf",icon:D.R1C}:"seed"===e?{color:"#a6dda6",icon:R.tWi}:{color:"inherit",icon:void 0}}t(88727);var I=t(85036),L=t(49294),F=t(46016),z=t(19920),A=t(19103),M=t(95913),O=t(89042),P=t(10929),V=t(12218);let B=V.env.NEXT_PUBLIC_API_URL?V.env.NEXT_PUBLIC_API_URL:window.location.origin;var q=t(27471);let H=P.default.create({baseURL:B}),K=new q.S;async function submitRun(e,n,t){let r=await H.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait}),i=r.data;return i}async function waitRun(e,n){let t=await H.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}}),r=t.data;return r}async function cancelRun(e){return await H.post("/api/runs/".concat(e,"/cancel"))}async function submitRunFromCheck(e,n){let t=await H.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait}),r=t.data;return r}async function searchRuns(e,n,t){let r=await H.post("/api/runs/search",{type:e,params:n,limit:t});return r.data}async function aggregateRuns(){let e=await H.post("/api/runs/aggregate",{});return e.data}async function submitRowCountDiff(e,n){return await submitRun("row_count_diff",e,n)}async function queryModelRowCount(e){let{result:n}=await queryRowCount([e]);return n[e]}async function queryRowCount(e){if(0===e.length)throw Error("No model names provided");let{run_id:n}=await submitRowCountDiff({node_names:e},{nowait:!0}),t=await waitRun(n);return{runId:n,result:t.result}}let W={rowCount:e=>["row_count",e],lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],run:e=>["runs",e],runsAggregated:()=>["runs_aggregated"]};var U=t(44903),G=t(62516),Q=t(35537),J=t(99691);async function getLineage(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=await H.get("/api/lineage?base=".concat(e));return n.data}async function getLineageWithError(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let n=await getLineage(e);return{data:n}}catch(e){if(!(e instanceof J.d7))return{error:null==e?void 0:e.message};{var n,t;let r=null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(n=t.data)||void 0===n?void 0:n.detail;if(r)return{error:r};return{error:null==e?void 0:e.message}}}}async function getLineageDiff(){let[e,n]=await Promise.all([getLineageWithError(!0),getLineageWithError(!1)]);return{base:e.data,current:n.data,base_error:e.error,current_error:n.error}}var Z=t(15550),X=t(21123),Y=t.n(X);let $=(0,v.createContext)({});function LineageWatcher(e){let{refetch:n}=e,t=(0,Z.p)(),[i,l]=(0,v.useState)(),o=(0,Q.NL)();return(0,v.useEffect)(()=>{function httpUrlToWebSocketUrl(e){return e.replace(/(http)(s)?\:\/\//,"ws$2://")}let e=new WebSocket("".concat(httpUrlToWebSocketUrl(B),"/api/ws"));return l(e),e.onopen=()=>{e.send("ping")},e.onmessage=e=>{if("pong"!==e.data)try{let n=JSON.parse(e.data);if("refresh"===n.command){let{eventType:e,srcPath:r}=n.event,[i,l]=r.split("/").slice(-2),a=Y().parse(l).name;t({description:"Detected ".concat(i," ").concat(a," ").concat(e),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),o.invalidateQueries({queryKey:W.lineage()})}}catch(e){console.error(e)}},()=>{e&&e.close()}},[t,o]),(0,r.jsx)(r.Fragment,{})}function LineageGraphsContextProvider(e){let{children:n}=e,{data:t,isLoading:i,error:l,refetch:o}=(0,U.a)({queryKey:W.lineage(),queryFn:getLineageDiff}),{data:a,refetch:s}=(0,U.a)({queryKey:W.runsAggregated(),queryFn:aggregateRuns}),c=(0,v.useMemo)(()=>{if(t)return buildDefaultLineageGraphSets(t.base,t.current)},[t]),d=(null==l?void 0:l.message)||(null==t?void 0:t.current_error)||(null==t?void 0:t.base_error);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(LineageWatcher,{refetch:o}),(0,r.jsx)($.Provider,{value:{lineageGraphSets:c,metadata:null==t?void 0:t.current.metadata,isDemoSite:!!(null==t?void 0:t.current.metadata.pr_url),error:d,isLoading:i,runsAggregated:a,refetchRunsAggregated:()=>{s()}},children:n})]})}let useLineageGraphsContext=()=>(0,v.useContext)($),useRunsAggregated=()=>{let{runsAggregated:e,refetchRunsAggregated:n}=useLineageGraphsContext();return[e,n]};function deltaPercentageString(e,n){if(e=.1?t.toFixed(1):" <0.1 ","%")}if(!(e>n))return"0 %";{let t=(e-n)/e*100;return"-".concat(t>=.1?t.toFixed(1):" <0.1 ","%")}}var ee=t(79935);function ResourceTypeTag(e){let{node:n}=e,{icon:t}=getIconForResourceType(n.resourceType);return(0,r.jsx)(o.u,{hasArrow:!0,label:"Type of resource",children:(0,r.jsxs)(z.Vp,{children:[(0,r.jsx)(z.AD,{as:t}),(0,r.jsx)(z.Sn,{children:n.resourceType})]})})}function _RowCountByRate(e){let{rowCount:n}=e,t=n.base,i=n.curr,l=null===n.base?"N/A":"".concat(n.base," rows"),o=null===n.curr?"N/A":"".concat(n.curr," rows");return null===t&&null===i?(0,r.jsx)(r.Fragment,{children:" Failed to load"}):null===t||null===i?(0,r.jsxs)(m.U,{children:[(0,r.jsx)(x.x,{children:l}),(0,r.jsx)(s.J,{as:O.Rgz}),(0,r.jsx)(x.x,{children:o})]}):t===i?(0,r.jsxs)(m.U,{children:[(0,r.jsx)(x.x,{children:o}),(0,r.jsx)(s.J,{as:G.lxc,color:"gray.500"}),(0,r.jsx)(x.x,{color:"gray.500",children:"No Change"})]}):tqueryModelRowCount(a.name),enabled:!1,initialData:l}),f=h||l||u;if(f){let e=(null==f?void 0:f.base)===null?"N/A":null==f?void 0:f.base,n=(null==f?void 0:f.curr)===null?"N/A":null==f?void 0:f.curr;i="".concat(e," -> ").concat(n," rows")}return(0,r.jsx)(o.u,{label:i,children:(0,r.jsxs)(z.Vp,{children:[(0,r.jsx)(z.AD,{as:O.SwK}),(0,r.jsx)(z.Sn,{children:f||x?(0,r.jsx)(A.N,{isLoaded:!x,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:f?(0,r.jsx)(_RowCountByRate,{rowCount:f}):"row count"}):(0,r.jsx)(r.Fragment,{children:"row count"})}),s&&(0,r.jsx)(z.bq,{as:M.h,isLoading:x,"aria-label":"Query Row Count",icon:(0,r.jsx)(ee.n,{}),size:"xs",onClick:async()=>{await m(),null==d||d()}})]})})}let ActionTag=e=>{let{node:n,action:t}=e,{status:i,skipReason:s,run:c}=t;if("pending"===i)return(0,r.jsx)(F.D,{size:"20px",value:0});if("skipped"===i)return(0,r.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,r.jsx)(l.xu,{children:"Skipped"}),s&&(0,r.jsx)(o.u,{label:s,children:(0,r.jsx)(I.s,{})})]});if(!c)return(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px"});let{error:d,result:u,run_id:h,progress:m}=c;if("running"===i)return(null==m?void 0:m.percentage)===void 0?(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px"}):(0,r.jsx)(F.D,{size:"20px",value:(null==m?void 0:m.percentage)*100});if(d)return(0,r.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,r.jsx)(l.xu,{children:"Error"}),s&&(0,r.jsx)(o.u,{label:d,children:(0,r.jsx)(L.a,{})})]});if("value_diff"===c.type){let e=0;for(let n of u.data.data)n[2]<1&&e++;return(0,r.jsx)(z.Vp,{children:(0,r.jsx)(z.Sn,{children:(0,r.jsx)(a.k,{fontSize:"10pt",color:e>0?"red":"green",alignItems:"center",gap:"3px",children:e>0?"".concat(e," columns mismatched"):"All columns match"})})})}if("row_count_diff"===c.type){let e=c.result;return(0,r.jsx)(RowCountTag,{rowCount:e[n.name],node:n,isInteractive:!1})}return(0,r.jsx)(r.Fragment,{children:h})},NodeRunsAggregated=e=>{let n,{id:t}=e,{runsAggregated:i}=useLineageGraphsContext(),c=null==i?void 0:i[t];if(!c)return(0,r.jsx)(r.Fragment,{});if(c.row_count_diff){let e=c.row_count_diff;n=e.result.curr!==e.result.base}return(0,r.jsx)(a.k,{children:void 0!==n&&(0,r.jsx)(o.u,{label:"Row count (".concat(n?"changed":"no change",")"),openDelay:500,children:(0,r.jsx)(l.xu,{height:"16px",children:(0,r.jsx)(s.J,{as:O.SwK,color:n?getIconForChangeStatus("modified").color:getIconForChangeStatus().color})})})})};function GraphNode(e){var n,t;let c,{data:d}=e,{isHighlighted:u,isSelected:h,resourceType:x,changeStatus:f}=d,p=(0,i.oR)(e=>e.transform[2]>.3),{icon:g}=getIconForResourceType(x),y="gray.400",v="solid";f&&(c=getIconForChangeStatus(f).icon,y=getIconForChangeStatus(f).color);let j=y,C=d.isSelected?"rgba(3, 102, 214, 0.5) 5px 5px 10px 3px":"unset",b=null==d?void 0:d.name;return(0,r.jsx)(o.u,{label:"model"===x?b:"".concat(b," (").concat(x,")"),placement:"top",children:(0,r.jsxs)(a.k,{width:"300px",_hover:{backgroundColor:p?"gray.100":y},borderColor:j,borderWidth:1,borderStyle:v,backgroundColor:p?"white":y,borderRadius:3,boxShadow:C,transition:"box-shadow 0.2s ease-in-out",padding:0,className:!0===u?"node-highlight":!0===h?"node-highlight":!1===u?"node-unhighlight":void 0,children:[(0,r.jsx)(a.k,{backgroundColor:y,padding:2,borderRightWidth:1,borderColor:j,borderStyle:v,alignItems:"top",visibility:p?"inherit":"hidden",children:(0,r.jsx)(s.J,{as:g})}),(0,r.jsxs)(a.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",children:[(0,r.jsxs)(a.k,{width:"100%",textAlign:"left",flex:"1",p:1,alignItems:"center",visibility:p?"inherit":"hidden",children:[(0,r.jsx)(l.xu,{flex:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:b}),c&&(0,r.jsx)(a.k,{children:(0,r.jsx)(s.J,{color:y,as:c,flex:"0 0 20px"})})]}),(0,r.jsx)(a.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:p?"inherit":"hidden",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(_.L,{}),d.isActionMode?d.action?(0,r.jsx)(ActionTag,{node:d,action:d.action}):(0,r.jsx)(r.Fragment,{}):"model"===d.resourceType?(0,r.jsx)(NodeRunsAggregated,{id:d.id}):(0,r.jsx)(r.Fragment,{})]})})]}),Object.keys(null!==(n=null==d?void 0:d.parents)&&void 0!==n?n:{}).length>0&&(0,r.jsx)(i.HH,{type:"target",position:i.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==d?void 0:d.children)&&void 0!==t?t:{}).length>0&&(0,r.jsx)(i.HH,{type:"source",position:i.Ly.Right,isConnectable:!1})]})})}function GraphEdge(e){let{sourceX:n,sourceY:t,targetX:l,targetY:o,sourcePosition:a,targetPosition:s,style:c={},markerEnd:d,data:u}=e,h={...c};(null==u?void 0:u.changeStatus)&&(h.stroke=getIconForChangeStatus(null==u?void 0:u.changeStatus).color,h.strokeDasharray="5"),(null==u?void 0:u.isHighlighted)===!1&&(h.filter="opacity(0.2) grayscale(50%)");let[m]=(0,i.OQ)({sourceX:n,sourceY:t,sourcePosition:a,targetX:l,targetY:o,targetPosition:s});return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(i.u5,{path:m,markerEnd:d,style:{...h,...c}})})}var en=t(67907),et=t(17714),er=t(74796),ei=t(79315),el=t(7752),eo=t(94410),ea=t(23330),es=t(58909),ec=t(29985),ed=t(42524),eu=t(2593),eh=t(55344),em=t(1726),ex=t(83622),ef=t(21801),ep=t(29731),eg=t(18974);function mergeKeys(e,n){let t=[...e],r=[...n],i=[];for(;t.length>0&&r.length>0;)if(i.includes(t[0]))t.shift();else if(i.includes(r[0]))r.shift();else if(t[0]===r[0])i.push(t[0]),t.shift(),r.shift();else if(r.includes(t[0])){let e=r.indexOf(t[0]);for(let n=0;n{i.includes(e)||i.push(e)}),r.forEach(e=>{i.includes(e)||i.push(e)}),i}function mergeKeysWithStatus(e,n){let t=mergeKeys(e,n),r={};for(let i of t)e.includes(i)?n.includes(i)?r[i]=void 0:r[i]="removed":r[i]="added";let i={};e.forEach((e,n)=>{i[e]=n});let l=-1;for(let e of t){let n=i[e];void 0!==n&&(n>l?l=n:r[e]="reordered")}return r}function mergeColumns(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={},r=mergeKeysWithStatus(Object.keys(e),Object.keys(n));return Object.entries(r).forEach(e=>{let[n,r]=e;t[n]={name:n,reordered:"reordered"===r}}),Object.entries(e).map((e,n)=>{let[r,i]=e;t[r].baseIndex=n+1,t[r].baseType=i.type}),Object.entries(n).map((e,n)=>{let[r,i]=e;t[r].currentIndex=n+1,t[r].currentType=i.type}),t}function toDataGrid(e){function columnIndexCellClass(e){return void 0===e.baseIndex?"column-index-added":void 0===e.currentIndex?"column-index-removed":!0===e.reordered?"column-index-reordered":"column-index-normal"}function columnNameCellClass(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":!0===e.reordered?"column-body-reordered":"column-body-normal"}function columnTypeCellClass(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":e.baseType!==e.currentType?"column-body-type-changed":!0===e.reordered?"column-body-reordered":"column-body-normal"}let n=Object.values(e);return{columns:[{key:"baseIndex",name:"",resizable:!0,minWidth:35,cellClass:columnIndexCellClass},{key:"currentIndex",name:"",resizable:!0,minWidth:35,cellClass:columnIndexCellClass},{key:"name",name:"Name",resizable:!0,cellClass:columnNameCellClass},{key:"baseType",name:"Base Type",resizable:!0,cellClass:columnTypeCellClass},{key:"currentType",name:"Current Type",resizable:!0,cellClass:columnTypeCellClass}],rows:n}}t(75165),t(91702);var ey=t(93683),ev=t(7873),ej=t(52116),eC=t(47367),eb=t(17072),ek=t(84680),ew=t(55201),e_=t.n(ew);function useClipBoardToast(){let e=(0,Z.p)();return{successToast:function(n){e({description:n,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})},failToast:function(n,t){e({title:n,description:"".concat(t),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}}}var eS=t(16062),eR=t(68686),eD=t.n(eR);let eN="ignore-screenshot";function useToBlob(e){let{imageType:n="png",backgroundColor:t=null,boardEffect:r=!0,shadowEffect:i=!1,borderStyle:l="solid 1px #ccc",borderRadius:o="10px",onSuccess:a,onError:s,ignoreElements:c}=e,[d,u]=(0,v.useState)("idle"),h=(0,v.useRef)(null),toImage=async()=>{if(!h.current){console.error("No node to use for screenshot"),u("error"),s&&s(Error("No node to use for screenshot"));return}let e=h.current.element||h.current,d=e.style.overflow,m=e.style.border,x=e.style.borderRadius,f=e.style.backgroundColor;function resetStyles(){e.style.overflow=d,e.style.border=m,e.style.borderRadius=x,e.style.backgroundColor=f}try{var p;e.style.overflow="hidden",e.style.border=r?l:"",e.style.borderRadius=r?o:"",e.style.backgroundColor=t||"";let d=document.createElement("style");document.head.appendChild(d),null===(p=d.sheet)||void 0===p||p.insertRule("body > div:last-child img { display: inline-block; }"),u("loading");let h=await e_()(e,{logging:!1,backgroundColor:null,ignoreElements:c});d.remove();let m=i?document.createElement("canvas"):h;if(i){m.width=h.width+80,m.height=h.height+80;let e=m.getContext("2d");if(e)e.shadowColor="rgba(0, 0, 0, 0.5)",e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(h,40,40);else{console.error("Error getting canvas context"),u("error"),s&&s(Error("Error getting canvas context to add shadow effect"));return}}m.toBlob(async e=>{u("success"),a&&e&&await a(e)},"image/".concat(n))}catch(e){console.error("Error converting to image",e),u("error"),s&&s(e);return}finally{resetStyles()}};return{status:d,isLoading:"loading"===d,isErrored:"error"===d,isSuccess:"success"===d,toImage,ref:h}}async function copyBlobToClipboard(e){if(!e)throw Error("No blob to copy to clipboard");try{await navigator.clipboard.write([new ClipboardItem({[e.type]:e})])}catch(e){throw console.error("Error copying to clipboard",e),e}}function useCopyToClipboardButton(e){let{successToast:n,failToast:t}=useClipBoardToast(),{isLoading:i,toImage:l,ref:o}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:async r=>{try{await copyBlobToClipboard(r),n("Copied the query result as an image to clipboard")}catch(i){let n=i.message;"ClipboardItem is not defined"===n&&(null==e?void 0:e.onClipboardNotDefined)?e.onClipboardNotDefined(r):t("Failed to copy image to clipboard",i)}},onError:e=>{console.error("Error taking screenshot",e),t("Failed to copy image to clipboard",e)}});function CopyToClipboardButton(e){let{imageType:n="png",...t}=e;return(0,r.jsx)(h.z,{size:"sm",leftIcon:(0,r.jsx)(eC.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:i,onMouseEnter:()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow="rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px",e.style.transition="box-shadow 0.5s ease-in-out"}},onMouseLeave:()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow=""}},onClick:async()=>{if(o.current){await l();let e=o.current.element||o.current;e.style.boxShadow=""}},children:"Copy to Clipboard"})}return{ref:o,CopyToClipboardButton}}function useImageBoardModal(){let{isOpen:e,onOpen:n,onClose:t}=(0,et.q)(),[i,l]=(0,v.useState)();return{onOpen:n,setImgBlob:l,ImageBoardModal:function(){let[n,l]=(0,v.useState)();return(0,v.useEffect)(()=>{if(!i)return;let e=new FileReader;e.readAsDataURL(i),e.onloadend=e=>{var n,t;(null===(n=e.target)||void 0===n?void 0:n.result)&&(null===(t=e.target)||void 0===t?void 0:t.result)!==null&&l(e.target.result)}},[l]),(0,r.jsxs)(el.u_,{size:"3xl",isOpen:e,onClose:t,children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{children:[(0,r.jsx)(es.x,{children:"Screenshot Preview"}),(0,r.jsx)(ec.o,{}),(0,r.jsxs)(ed.f,{children:[(0,r.jsxs)(a.k,{px:"10px",gap:"10px",direction:"column",children:[(0,r.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,r.jsx)(I.s,{color:"red.600"}),(0,r.jsx)(x.x,{fontWeight:"500",display:"inline",children:"Copy to the Clipboard"})," ","is not supported in the current browser"]}),(0,r.jsx)(x.x,{children:"Please download it directly"})]}),(0,r.jsx)(eb.E,{src:n,alt:"screenshot"})]}),(0,r.jsxs)(ek.m,{children:[(0,r.jsx)(h.z,{mr:3,onClick:t,children:"Close"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>{if(!i)return;let e=new Date,n="recce-screenshot-".concat((0,eS.ZP)(e,"yyyy-MM-dd-HH-mm-ss"),".png");eD()(i,n),t()},children:"Download"})]})]})]})}}}function ScreenshotDataGrid(e){let{enableScreenshot:n=!0,...t}=e,{onOpen:i,setImgBlob:l,ImageBoardModal:o}=useImageBoardModal(),a=(0,v.useCallback)(e=>{l(e),i()},[l,i]),{ref:s,CopyToClipboardButton:c}=useCopyToClipboardButton({onClipboardNotDefined:a});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.ZP,{ref:s,...t}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{imageType:"png"}),(0,r.jsx)(o,{})]})]})}function EmptyRowsRenderer(){return(0,r.jsx)(a.k,{h:"35px",alignItems:"center",justifyContent:"center",bg:"gray.100",style:{textAlign:"center",gridColumn:"1/-1"},children:(0,r.jsx)(x.x,{fontWeight:"600",children:" No rows"})})}function SchemaView(e){let n,t,{base:i,current:l,enableScreenshot:o=!1}=e,{columns:s,rows:c}=(0,v.useMemo)(()=>toDataGrid(mergeColumns(null==i?void 0:i.columns,null==l?void 0:l.columns)),[i,l]),{lineageGraphSets:d}=useLineageGraphsContext(),u=(null==d?void 0:d.catalogExistence.base)===!1,h=(null==d?void 0:d.catalogExistence.current)===!1;u&&h?n="catalog.json is missing on both current and base environments.":u?n="catalog.json is missing on base environment.":h&&(n="catalog.json is missing on current environment.");let m=i&&void 0===i.columns,x=l&&void 0===l.columns;return m&&x?t="Schema information is missing on both current and base environments.":m?t="Schema information is missing on base environment.":x&&(t="Schema information is missing on current environment."),(0,r.jsxs)(a.k,{direction:"column",children:[n?(0,r.jsxs)(ey.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,r.jsx)(ev.z,{}),n]}):t?(0,r.jsxs)(ey.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,r.jsx)(ev.z,{}),t]}):(0,r.jsx)(r.Fragment,{}),c.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:s,rows:c,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},className:"rdg-light",enableScreenshot:o})})]})}let eE='select * from {{ ref("mymodel") }}',eT=(0,v.createContext)({sqlQuery:eE,setSqlQuery:()=>{}});function RecceQueryContextProvider(e){let{children:n}=e,[t,i]=v.useState(eE);return(0,r.jsx)(eT.Provider,{value:{setSqlQuery:i,sqlQuery:t},children:n})}let useRecceQueryContext=()=>(0,v.useContext)(eT),eI=(0,v.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function RowCountStateContextProvider(e){let{children:n}=e,[t,i]=v.useState([]);return(0,r.jsx)(eI.Provider,{value:{isNodesFetching:t,setIsNodesFetching:i},children:n})}var eL=t(29357);function SqlDiffView(e){let{base:n,current:t}=e;return(0,r.jsx)(eL.SV,{height:"500px",language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==t?void 0:t.raw_code,options:{readOnly:!0,fontSize:14,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same"}})}var eF=t(32865);async function createSimpleCheck(){let e=await H.post("/api/checks",{type:"simple"}),n=e.data;return n}async function createLineageDiffCheck(e,n){let t=await H.post("/api/checks",{type:"lineage_diff",params:{view_mode:e,node_ids:n}}),r=t.data;return r}async function createCheckByNodeSchema(e){let n=await H.post("/api/checks",{type:"schema_diff",params:{node_id:e}}),t=n.data;return t}async function createCheckByRun(e,n){let t=await H.post("/api/checks",{run_id:e,view_options:n}),r=t.data;return r}async function listChecks(){let e=await H.get("/api/checks");return e.data}async function getCheck(e){let n=await H.get("/api/checks/".concat(e));return n.data}async function updateCheck(e,n){let t=await H.patch("/api/checks/".concat(e),n);return t.data}async function deleteCheck(e){let n=await H.delete("/api/checks/".concat(e));return n.data}async function reorderChecks(e){return await H.post("/api/checks/reorder",e)}async function exportChecks(){let e=await H.post("/api/checks/export");return e.data}async function loadChecks(e){let n=new FormData;n.append("file",e);let t=await H.post("/api/checks/load",n);return t.data}var ez=t(78448),eA=t(93573);function ColumnNameCell(e){let{params:n,column:t,containerRef:i}=e,{runAction:o}=useRecceActionContext(),handleValueDiffDetail=(e,t)=>{let r={...n,...e};o("value_diff_detail",r,t)};return(0,r.jsxs)(a.k,{children:[(0,r.jsx)(l.xu,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,r.jsx)(_.L,{}),(0,r.jsx)(p.v,{children:e=>{let{isOpen:n}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eg.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:M.h,icon:(0,r.jsx)(s.J,{as:S.D_A}),variant:"unstyled",size:"sm"}),(0,r.jsx)(ez.h,{containerRef:i,children:(0,r.jsx)(g.q,{lineHeight:"20px",children:(0,r.jsxs)(eA.k,{title:"Action",as:l.xu,fontSize:"8pt",children:[(0,r.jsx)(y.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({},{showForm:!0}),children:"Show mismatched values..."}),(0,r.jsxs)(y.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({columns:[t]},{showForm:!1}),children:["Show mismatched values for '",t,"'"]})]})})})]})}})]})}function ValueDiffResultView(e){let{run:n}=e,t=n.result,i=n.params,cellClass=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},o=(0,v.useRef)(),c=[{key:"__is_pk__",name:"",maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,r.jsx)(d.M,{height:"100%",children:n[0]===i.primary_key&&(0,r.jsx)(s.J,{as:S.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,r.jsx)(ColumnNameCell,{column:n[t.key],params:i,containerRef:o})},cellClass:"cell-show-context-menu"},{key:"1",name:"Matched",resizable:!0,cellClass},{key:"2",name:"Matched %",resizable:!0,renderCell:e=>{let{column:n,row:t}=e,i=t[n.key];return(0,r.jsx)(l.xu,{textAlign:"end",children:void 0!=i&&null!==i?"".concat((100*i).toFixed(2)," %"):"N/A"})},cellClass}];return(0,r.jsxs)(a.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",ref:o,children:[(0,r.jsxs)(l.xu,{px:"16px",children:["Model: ",i.model,", ",t.summary.total," total (",t.summary.total-t.summary.added-t.summary.removed," ","common, ",t.summary.added," added, ",t.summary.removed," removed)"]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:c,rows:t.data.data,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})}var eM=t(41171),eO=t(53930),eP=t(25535),eV=t(51348),eB=t(11546),eq=t(83978),eH=t.n(eq);function extractColumns(e){function getColumns(e){return e&&e.columns?Object.values(e.columns):[]}let n=getColumns(e.data.base),t=getColumns(e.data.current),r=[];return n.forEach(e=>{r.some(n=>n.name===e.name)||r.push(e)}),t.forEach(e=>{r.some(n=>n.name===e.name)||r.push(e)}),r}function extractColumnNames(e){function getNames(e){return e&&e.columns?Object.values(e.columns).map(e=>e.name):[]}let n=getNames(e.data.base),t=getNames(e.data.current),r=[];return n.forEach(e=>{r.includes(e)||r.push(e)}),t.forEach(e=>{r.includes(e)||r.push(e)}),r}function ValueDiffForm(e){var n,t;let{params:i,onParamsChanged:l,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),[s,c]=(0,v.useState)(!i.columns||0===i.columns.length),d=null==i?void 0:i.model,h=null==i?void 0:i.primary_key,m=eH().find(null===(n=a.lineageGraphSets)||void 0===n?void 0:n.all.nodes,{name:null==i?void 0:i.model}),x=null==m?void 0:null===(t=m.data.current)||void 0===t?void 0:t.primary_key;(0,v.useEffect)(()=>{!h&&x&&l({...i,primary_key:x})},[h,x,i,l]),(0,v.useEffect)(()=>{o(!!h&&!!d)},[h,d,o]);let f=m?extractColumnNames(m):[];return(0,r.jsxs)(u.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Model"}),(0,r.jsx)(eP.I,{isReadOnly:!0,value:null==i?void 0:i.model})]}),(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Primary key"}),(0,r.jsx)(eB.Z,{placeholder:"Select primary key",value:h?{label:h,value:h}:void 0,options:(f||[]).map(e=>({label:e,value:e})),onChange:e=>{c(!0),l({...i,primary_key:(null==e?void 0:e.value)||"",columns:void 0})}})]}),(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Columns"}),(0,r.jsx)(eV.X,{marginBottom:"10px",isChecked:s,onChange:e=>{c(e.target.checked),l({...i,columns:void 0})},children:"All columns"}),!s&&(0,r.jsx)(eB.Z,{isMulti:!0,closeMenuOnSelect:!1,options:(f||[]).map(e=>({label:e,value:e})),value:(i.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{l({...i,columns:(e||[]).map(e=>e.value)})}})]})]})}function _getColumnMap(e,n){let t={},r=mergeKeysWithStatus(e.columns.map(e=>e.name),n.columns.map(e=>e.name));return Object.entries(r).map(r=>{let[i,l]=r;t[i]={status:l,baseColumnIndex:e.columns.findIndex(e=>e.name===i),currentColumnIndex:n.columns.findIndex(e=>e.name===i)}}),t}function _getPrimaryKeyIndexes(e,n){let t=[];for(let r of n){let n=e.findIndex(e=>e.name===r);if(n<0)throw Error("Column ".concat(r," not found"));t.push(n)}return t}function _getPrimaryKeyValue(e,n,t){let r={};if(0===n.length)return JSON.stringify({_index:t._index});for(let i of n){let n=e[i];r[n.name]=t[i]}return JSON.stringify(r)}function DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:i,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,r.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&i&&(0,r.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?S.ven:S.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);i&&i(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];i&&i(e)}}),!h&&o&&(0,r.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?S.$kI:S.oJP,onClick:m?()=>{let e=u.filter(e=>e!==n);o&&o(e)}:()=>{let e=[...u,n];o&&o(e)}})]})}t(7866);let defaultRenderCell=e=>{let{row:n,column:t}=e,i=n[t.key];return(0,r.jsx)(r.Fragment,{children:"boolean"==typeof i?i.toString():i})};function toDataDiffGrid(e,n,t){let i=e||{columns:[],data:[]},l=n||{columns:[],data:[]},o=(null==t?void 0:t.primaryKeys)||[],a=(null==t?void 0:t.pinnedColumns)||[],s=(null==t?void 0:t.changedOnly)||!1,c=[],d=_getColumnMap(i,l),u={},h={},m=!1,x=!1;if(0===o.length)i.data.forEach((e,n)=>{e._index=n+1,u[JSON.stringify({_index:n+1})]=e}),l.data.forEach((e,n)=>{e._index=n+1,h[JSON.stringify({_index:n+1})]=e});else{let e=_getPrimaryKeyIndexes(i.columns,o);i.data.forEach((n,t)=>{let r=_getPrimaryKeyValue(i.columns,e,n);r in u&&(m=!0),u[r]=n}),e=_getPrimaryKeyIndexes(l.columns,o),l.data.forEach((n,t)=>{let r=_getPrimaryKeyValue(l.columns,e,n);r in h&&(x=!0),h[r]=n})}let f=mergeKeysWithStatus(Object.keys(u),Object.keys(h)),p=Object.entries(f).map(e=>{let[n,t]=e,r=u[n],a=h[n],s=JSON.parse(n);if(r&&i.columns.forEach((e,n)=>{o.includes(e.name)||(s["base__".concat(e.name)]=r[n])}),a&&l.columns.forEach((e,n)=>{o.includes(e.name)||(s["current__".concat(e.name)]=a[n])}),r){if(a)for(let[e,n]of Object.entries(d))"index"===e||o.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eH().isEqual(r[n.baseColumnIndex],a[n.currentColumnIndex])||(s.status="modified",n.status="modified");else s.status="removed"}else s.status="added";return s});s&&(p=p.filter(e=>"added"===e.status||"removed"===e.status||"modified"===e.status));let toColumn=(e,n)=>{let i="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let r=t.status;if("removed"===r)return"diff-cell-removed";if("added"===r)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eH().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:i,name:(0,r.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:defaultRenderCell,size:"auto"}]}};return 0===o.length?c.push({key:"_index",name:"",cellClass:"index-column"}):o.forEach(e=>{let n=d[e].status||"";c.push({key:"".concat(e),name:(0,r.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),a.forEach(e=>{let n=d[e].status||"";"index"===e||o.includes(e)||c.push(toColumn(e,n))}),Object.entries(d).forEach(e=>{let[n,t]=e,r=t.status||"";"index"===n||o.includes(n)||a.includes(n)||s&&"added"!==r&&"removed"!==r&&"modified"!==r||c.push(toColumn(n,r))}),{columns:c,rows:p,invalidPKeyBase:m,invalidPKeyCurrent:x}}function ProfileDiffResultView(e){var n;let{run:t,viewOptions:i,onViewOptionsChanged:l}=e,o=t.result;t.params;let a=(0,v.useMemo)(()=>(null==i?void 0:i.pinned_columns)||[],[i]),s=((null==o?void 0:null===(n=o.current)||void 0===n?void 0:n.columns)||[]).find(e=>"column_name"===e.name.toLowerCase()),c=(null==s?void 0:s.name)||"column_name",u=(0,v.useMemo)(()=>toDataDiffGrid(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[c],pinnedColumns:a,onPinnedColumnsChange:e=>{l&&l({...i,pinned_columns:e})}}),[o,c,a,i,l]);return 0===u.columns.length?(0,r.jsx)(d.M,{height:"100%",children:"No data"}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})}var eK=t(70556);let RunView=e=>{var n,t;let{isPending:i,isAborting:o,progress:s,error:c,run:m,onCancel:x,viewOptions:f,onViewOptionsChanged:p,RunResultView:g,children:y}=e;if(y&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!y&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");let v=(null==c?void 0:null===(t=c.response)||void 0===t?void 0:null===(n=t.data)||void 0===n?void 0:n.detail)||(null==m?void 0:m.error);if(v)return(0,r.jsxs)(ey.b,{status:"error",children:[(0,r.jsx)(ev.z,{}),"Error: ",v]});if(i){let e=(null==s?void 0:s.message)?null==s?void 0:s.message:"Loading...";return(0,r.jsx)(d.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,r.jsxs)(u.g,{children:[(0,r.jsxs)(a.k,{alignItems:"center",children:[(null==s?void 0:s.percentage)===void 0||(null==s?void 0:s.percentage)===null?(0,r.jsx)(F.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,r.jsx)(F.D,{size:"20px",value:100*s.percentage,mr:"8px"}),o?(0,r.jsx)(r.Fragment,{children:"Aborting..."}):(0,r.jsx)(r.Fragment,{children:e})]}),!o&&(0,r.jsx)(h.z,{onClick:x,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}return m?(0,r.jsxs)(l.xu,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(0,r.jsx)(g,{run:m,viewOptions:f,onViewOptionsChanged:p}),y&&y({run:m,viewOptions:f,onViewOptionsChanged:p})]}):(0,r.jsx)(d.M,{bg:"rgb(249,249,249)",height:"100%",children:"No data"})};var eW=t(48689);let RunModal=e=>{let{isOpen:n,onClose:t,type:i,title:o,params:s,initialRun:c,RunForm:d,RunResultView:u}=e,[,m]=(0,eF.TH)(),[x,f]=(0,v.useState)(),[p,g]=(0,v.useState)(s),[y,j]=(0,v.useState)(!1),[C,b]=(0,v.useState)(!1),[k,w]=(0,v.useState)(),[_,S]=(0,v.useState)(),[R,D]=(0,v.useState)(c),submitRunFn=async()=>{let{run_id:e}=await submitRun(i,p,{nowait:!0});for(f(e);;){let n=await waitRun(e,2);if(w(n.progress),n.result||n.error)return j(!1),w(void 0),n}},{data:N,mutate:E,reset:T,error:I,isPending:L}=(0,eK.D)({mutationFn:submitRunFn});(0,v.useEffect)(()=>{n&&void 0===d&&void 0===R&&E()},[n]);let F=(0,Q.NL)(),z=(0,v.useCallback)(async()=>{if(j(!0),x)return await cancelRun(x)},[x]),A=(0,v.useCallback)(()=>{E()},[E]),M=(0,v.useCallback)(()=>{E(),D(void 0)},[E]),handleReset=()=>{j(!1),g(s),w(void 0),D(void 0),T()},O=(0,v.useCallback)(async()=>{let e=R?R.run_id:null==N?void 0:N.run_id;if(void 0===e)return;let n=await createCheckByRun(e,_);F.invalidateQueries({queryKey:W.checks()}),m("/checks/".concat(n.check_id))},[null==N?void 0:N.run_id,R,m,F,_]),handleClose=async()=>{t(),L&&x&&await cancelRun(x),handleReset()},P=!!(null==R?void 0:R.result)||!!(null==N?void 0:N.result),V=(null==R?void 0:R.run_at)?(0,eW.Z)(new Date(R.run_at),{addSuffix:!0}):null;return(0,r.jsxs)(el.u_,{isOpen:n,onClose:handleClose,size:"6xl",scrollBehavior:"inside",children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{overflowY:"auto",height:"75%",children:[(0,r.jsxs)(es.x,{children:[o,!N&&!L&&V&&(0,r.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:V})]}),(0,r.jsx)(ec.o,{}),(0,r.jsx)(ed.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:L||N||I||R?(0,r.jsx)(RunView,{isPending:L,isAborting:y,run:R||N,error:I,progress:k,onCancel:z,viewOptions:_,onViewOptionsChanged:S,RunResultView:u}):(0,r.jsx)(l.xu,{style:{contain:"layout"},children:d&&(0,r.jsx)(d,{params:p,onParamsChanged:g,setIsReadyToExecute:b})})}),(0,r.jsx)(ek.m,{children:(0,r.jsxs)(a.k,{gap:"10px",children:[P&&d&&(0,r.jsx)(h.z,{colorScheme:"blue",onClick:handleReset,children:"Reset"}),P&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(h.z,{colorScheme:"blue",onClick:O,children:"Add to checklist"})}),L&&(0,r.jsx)(h.z,{onClick:z,isDisabled:y,colorScheme:"blue",children:"Cancel"}),!P&&!L&&(0,r.jsx)(h.z,{isDisabled:L||!C,colorScheme:"blue",onClick:A,children:"Execute"}),P&&!d&&(0,r.jsx)(h.z,{colorScheme:"blue",onClick:M,children:"Rerun"})]})})]})]})};var eU=t(99986);function valuediff_getColumnMap(e){let n={};return e.columns.map((e,t)=>{n[e.name]={index:t}}),n}function valuediff_getPrimaryKeyIndexes(e,n){let t=[];for(let r of n){let n=e.findIndex(e=>e.name===r);if(n<0)throw Error("Column ".concat(r," not found"));t.push(n)}return t}function valuediff_getPrimaryKeyValue(e,n,t){let r={};if(0===n.length)return JSON.stringify({_index:t._index});for(let i of n){let n=e[i];r[n.name]=t[i]}return JSON.stringify(r)}function valuediff_DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:i,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,r.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&o&&(0,r.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?S.$kI:S.oJP,onClick:m?()=>{let e=u.filter(e=>e!==n);o&&o(e)}:()=>{let e=[...u,n];o&&o(e)}})]})}let valuediff_defaultRenderCell=e=>{let{row:n,column:t}=e,i=n[t.key];return(0,r.jsx)(r.Fragment,{children:"boolean"==typeof i?i.toString():i})};function toValueDiffGrid(e,n,t){let i=(null==t?void 0:t.pinnedColumns)||[],l=(null==t?void 0:t.changedOnly)||!1,o=[],a=valuediff_getColumnMap(e),s={},c={};if(0===n.length)throw Error("Primary keys are required");let d=valuediff_getPrimaryKeyIndexes(e.columns,n),u=(a.in_a||a.IN_A).index,h=(a.in_b||a.IN_B).index;e.data.forEach((n,t)=>{let r=valuediff_getPrimaryKeyValue(e.columns,d,n);n[u]&&(s[r]=n),n[h]&&(c[r]=n)});let m=mergeKeysWithStatus(Object.keys(s),Object.keys(c)),x=Object.entries(m).map(t=>{let[r,i]=t,l=s[r],o=c[r],d=JSON.parse(r);if(l&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["base__".concat(e.name)]=l[t])}),o&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["current__".concat(e.name)]=o[t])}),l){if(o)for(let[e,t]of Object.entries(a))!("index"===e||n.includes(e))&&(eH().isEqual(l[t.index],o[t.index])||(d.status="modified",t.status="modified"));else d.status="removed"}else d.status="added";return d});l&&(x=x.filter(e=>"added"===e.status||"removed"===e.status||"modified"===e.status));let toColumn=(e,n)=>{let i="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let r=t.status;if("removed"===r)return"diff-cell-removed";if("added"===r)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eH().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:i,name:(0,r.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ej.Ug,headerCellClass:i,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"}]}};return n.forEach(e=>{let n=a[e].status||"";o.push({key:"".concat(e),name:(0,r.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),i.forEach(e=>{let t=a[e].status||"";n.includes(e)||o.push(toColumn(e,t))}),Object.entries(a).forEach(e=>{let[t,r]=e,a=r.status||"";"in_a"===t||"in_b"===t||n.includes(t)||i.includes(t)||l&&"added"!==a&&"removed"!==a&&"modified"!==a||o.push(toColumn(t,a))}),{columns:o,rows:x}}let ValueDiffDetailResultView=e=>{var n,t;let{run:i,onAddToChecklist:s,viewOptions:c,onViewOptionsChanged:u}=e,h=(0,v.useMemo)(()=>(null==c?void 0:c.changed_only)||!1,[c]),m=(0,v.useMemo)(()=>(null==c?void 0:c.pinned_columns)||[],[c]),x=(0,v.useMemo)(()=>{var e,n;if(!i.result)return{columns:[],rows:[]};let t=(null==i?void 0:null===(e=i.params)||void 0===e?void 0:e.primary_key)?[null==i?void 0:null===(n=i.params)||void 0===n?void 0:n.primary_key]:[];return toValueDiffGrid(null==i?void 0:i.result,t,{changedOnly:h,pinnedColumns:m,onPinnedColumnsChange:e=>{u&&u({...c,pinned_columns:e})}})},[i,c,h,m,u]);if(0===x.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});if(h&&0===x.rows.length)return(0,r.jsx)(d.M,{height:"100%",children:"No change"});let f=(null===(n=i.result)||void 0===n?void 0:n.limit)||0,p=f>0&&(null==i?void 0:null===(t=i.result)||void 0===t?void 0:t.more)?"Warning: Displayed results are limited to ".concat(f.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:p?"orange.100":"inherit",children:[p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",(0,r.jsx)(l.xu,{children:p})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),(0,r.jsx)(eV.X,{isChecked:null==c?void 0:c.changed_only,onChange:()=>{let e=!(null==c?void 0:c.changed_only);u&&u({...c,changed_only:e})},children:"Changed only"}),s&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>s(i)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:x.columns,rows:x.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};var eG=t(34030);function formatNumber(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US",t=arguments.length>2?arguments[2]:void 0;return"number"!=typeof e?e:new Intl.NumberFormat(n,t).format(e)}function formatters_formatIntervalMinMax(e){let n=e>0&&e<=.001,t=e<1&&e>=.999,formatter=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e;return formatNumber(n,"en-US",{style:"percent",minimumFractionDigits:1})};if(n){let e=formatter(.001);return"<".concat(e)}if(t){let e=formatter(.999);return">".concat(e)}return formatter()}function formatters_formatAsAbbreviatedNumber(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,r=n>=1e6,i=n>=1e9,l=n>=1e15;if(l||n>=1e12)return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:l?0:2}).format(e/1e12).replace("L","T");if(i||r||n>=1e3){let n={base:i?1e9:r?1e6:1e3,unit:i?"B":r?"M":"K"};return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:1}).format(e/n.base).replace("L",n.unit)}return n>=1?new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:t?3:2,notation:t||0===n?"standard":"scientific"}).format(e)}}var eQ=t(17180),eJ=t(85670),eZ=t(84021);let eX="#63B3ED",eY="#F6AD55",e$="".concat(eX,"A5"),e0="".concat(eY,"A5");function SquareIcon(e){let{color:n}=e;return(0,r.jsx)(l.xu,{display:"inline-block",w:"10px",h:"10px",bgColor:n,mr:"2",borderRadius:"sm"})}let e1="#63B3ED";function prepareSummaryList(e,n){let t=n?10:e.counts.length,r=e.counts.slice(0,t),i=e.valids-r.reduce((e,n)=>e+n,0),l=e.values.slice(0,t);return l.concat([i]).map((n,t)=>{let l=t===r.length,o=l?i:r[t];return{isLastItemOthers:l,label:l?"(others)":String(n)||"(empty)",count:o,displayCount:formatters_formatAsAbbreviatedNumber(o),displayRatio:formatters_formatIntervalMinMax(o/e.valids)||"N/A"}})}function TopKChartTooltip(e){let{base:n,current:t,children:i}=e;return(0,r.jsx)(o.u,{label:(0,r.jsxs)(l.xu,{children:[(0,r.jsxs)(x.x,{children:[(0,r.jsx)(SquareIcon,{color:eX}),"Current: ",t.count," (",t.displayRatio,")"]}),(0,r.jsxs)(x.x,{children:[(0,r.jsx)(SquareIcon,{color:eY}),"Base: ",n.count," (",n.displayRatio,")"]})]}),placement:"auto",hasArrow:!0,children:i})}function TopKSummaryBarChart(e){let{topKDiff:n,isDisplayTopTen:t}=e,i=prepareSummaryList(n.current,t),o=prepareSummaryList(n.base,t);return(0,r.jsxs)(l.xu,{w:"100%",px:20,py:4,children:[(0,r.jsxs)(a.k,{alignItems:"center",direction:"row",children:[(0,r.jsx)(_.L,{}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:eY})," Base"]}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:eX})," Current"]}),(0,r.jsx)(_.L,{})]}),i.map((e,t)=>{let i=o[t];return e.isLastItemOthers&&0===e.count&&0===i.count?(0,r.jsx)(r.Fragment,{}):(0,r.jsxs)(v.Fragment,{children:[(0,r.jsx)(TopKChartTooltip,{base:i,current:e,children:(0,r.jsxs)(a.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:4,children:[(0,r.jsx)(x.x,{noOfLines:1,width:"10em",fontSize:"sm",color:e.isLastItemOthers||0===e.label.length?"gray.400":"inherit",children:e.label}),(0,r.jsxs)(a.k,{width:"70%",direction:"column",children:[(0,r.jsxs)(a.k,{height:"1em",children:[(0,r.jsx)(CategoricalBarChart,{topkCount:e.count,topkLabel:e.label,valids:n.current.valids,color:eX}),(0,r.jsx)(x.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:e.displayCount}),(0,r.jsx)(x.x,{color:"gray.400",fontSize:"sm",width:"4em",children:e.displayRatio})]}),(0,r.jsxs)(a.k,{height:"1em",children:[(0,r.jsx)(CategoricalBarChart,{topkCount:i.count,topkLabel:i.label,valids:n.base.valids,color:eY}),(0,r.jsx)(x.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:i.displayCount}),(0,r.jsx)(x.x,{color:"gray.400",fontSize:"sm",width:"4em",children:i.displayRatio})]})]})]})}),(0,r.jsx)(eQ.i,{})]},t)})]})}function CategoricalBarChart(e){let{topkCount:n,topkLabel:t,valids:i,animation:l=!1,color:o=e1}=e;eJ.kL.register(eJ.uw,eJ.ZL,eJ.f$);let a=getCatBarChartOptions(n,i,{animation:l}),s=getCatBarChartData({topkCount:n,topkLabel:t,color:o});return(0,r.jsx)(eZ.$Q,{data:s,options:a,plugins:[]})}function getCatBarChartOptions(e,n){let{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{responsive:!0,maintainAspectRatio:!1,indexAxis:"y",scales:{x:{display:!1,max:n,grid:{display:!1}},y:{display:!1}},plugins:{tooltip:{enabled:!1}},...t}}function getCatBarChartData(e){let{topkLabel:n,topkCount:t,color:r=e1}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:r,hoverBackgroundColor:r,borderWidth:0,borderColor:r,barPercentage:1,categoryPercentage:.6}]}}let ScreenshotBox=e=>{let{backgroundColor:n="white",blockSize:t,children:i,...o}=e,{onOpen:a,setImgBlob:s,ImageBoardModal:c}=useImageBoardModal(),d=(0,v.useCallback)(e=>{s(e),a()},[s,a]),{ref:u,CopyToClipboardButton:h}=useCopyToClipboardButton({backgroundColor:n,onClipboardNotDefined:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.xu,{ref:u,...o,overflow:"auto",children:(0,r.jsx)(l.xu,{backgroundColor:n,height:"100%",blockSize:t,children:i})}),(0,r.jsx)(h,{imageType:"png"}),(0,r.jsx)(c,{})]})};function TopKDiffResultView(e){let{run:n}=e,[t,i]=(0,v.useState)(!0),l=n.result,o=n.params,s=l.base,c=l.current;return(0,r.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,r.jsxs)(ScreenshotBox,{blockSize:"auto",children:[(0,r.jsxs)(ei.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",children:["Model ",o.model,".",o.column_name]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(TopKSummaryBarChart,{topKDiff:l,valids:c.valids||0,isDisplayTopTen:t}),(0,r.jsx)(_.L,{})]})]}),(0,r.jsx)(_.L,{}),(s.values.length>10||c.values.length>10)&&(0,r.jsx)(a.k,{p:5,justify:"start",children:(0,r.jsx)(eG.r,{onClick:()=>i(e=>!e),textColor:"blue.500",children:t?"View More Items":"View Only Top-10"})})]})}var e2=t(68665);function TopKDiffForm(e){var n;let{params:t,onParamsChanged:i,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eH().find(null===(n=a.lineageGraphSets)||void 0===n?void 0:n.all.nodes,{name:null==t?void 0:t.model}),c=s?extractColumnNames(s):[];return(0,v.useEffect)(()=>{o(!!t.column_name)},[t,o]),(0,r.jsx)(l.xu,{m:"16px",children:(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Pick a column to show top-k"}),(0,r.jsx)(e2.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{let n=e.target.value;i({...t,column_name:n})},children:c.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})})}function HistogramChart(e){let{data:n,hideAxis:t=!1,animation:i=!1}=e;eJ.kL.register(eJ.ZL,eJ.RM,eJ.f$,eJ.uw,eJ.u);let l=getHistogramChartOptions(n,t,{animation:i}),o=getHistogramChartData(n);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a.k,{alignItems:"center",direction:"row",children:[(0,r.jsx)(_.L,{}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:e0})," Base"]}),(0,r.jsxs)(x.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,r.jsx)(SquareIcon,{color:e$})," Current"]}),(0,r.jsx)(_.L,{})]}),(0,r.jsx)(eZ.kL,{type:"bar",options:l,data:o,plugins:[]})]})}function getHistogramChartDataset(e,n,t,r,i){let{counts:l=[]}=i,o="datetime"===e?l.map((e,t)=>({x:n[t],y:e})):l;return{label:t,data:o,backgroundColor:r,borderColor:r,hoverBackgroundColor:r,borderWidth:0,categoryPercentage:1,barPercentage:1,xAxisID:"x"}}function getHistogramChartData(e){let{datasets:n,type:t,binEdges:r}=e,[i,l]=n,o=getHistogramChartDataset(t,r,"Current",e$,l),a=getHistogramChartDataset(t,r,"Base",e0,i),s=r.map((e,n)=>formatDisplayedBinItem(r,n)).slice(0,-1);return{labels:s,datasets:[o,a]}}function getHistogramChartOptions(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasets:r,type:i,samples:l=0,binEdges:o}=e,[a,s]=r,c="datetime"===i;return{responsive:!0,maintainAspectRatio:!1,plugins:{tooltip:{mode:"index",intersect:!1,callbacks:{title(e){let[{dataIndex:n,datasetIndex:t}]=e,r=formatDisplayedBinItem(o,n);return"".concat(c?"Date Range":"string"===i?"Text Length":"Value Range","\n").concat(r)},label(e){let{datasetIndex:n,dataIndex:t,dataset:{label:r}}=e,i=0===n?s.counts:a.counts,o=formatters_formatIntervalMinMax(i[t]/l),c=i[t];return"".concat(r,": ").concat(c," (").concat(o,")")}}}},scales:getScales(e,n),...t}}function getScales(e){let{datasets:n,min:t=0,max:r=0,type:i,binEdges:l}=e,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],[a,s]=n,c=Math.max(...s.counts,...a.counts),d=l.map((e,n)=>formatDisplayedBinItem(l,n)).slice(0,-1);return{x:"datetime"===i?{display:!o,type:"timeseries",min:t,max:r,adapters:{date:{}},time:{minUnit:"day"},grid:{display:!1},ticks:{minRotation:30,maxRotation:30,maxTicksLimit:8}}:{display:!o,type:"category",grid:{display:!1},ticks:{callback:(e,n)=>d[n]},stacked:!0},y:{display:!o,type:"linear",max:c,border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return formatters_formatAsAbbreviatedNumber(e)}},beginAtZero:!0}}}function formatDisplayedBinItem(e,n){let t=e[n],r=e[n+1],i=formatters_formatAsAbbreviatedNumber(t),l=formatters_formatAsAbbreviatedNumber(r),o="".concat(i," - ").concat(l);return o}function HistogramDiffResultView(e){var n,t,i,o,s,c;let{run:d}=e,u=d.params,h=null===(n=d.result)||void 0===n?void 0:n.base,x=null===(t=d.result)||void 0===t?void 0:t.current,f=null===(i=d.result)||void 0===i?void 0:i.min,p=null===(o=d.result)||void 0===o?void 0:o.max,g=null===(s=d.result)||void 0===s?void 0:s.bin_edges;return h&&x?(0,r.jsx)(a.k,{direction:"column",height:"500px",children:(0,r.jsxs)(ScreenshotBox,{height:"100%",children:[(0,r.jsxs)(ei.X,{as:"h1",size:"md",paddingTop:"4",textAlign:"center",children:["Model ",u.model,".",u.column_name]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(l.xu,{w:"80%",h:"300px",m:"4",children:(0,r.jsx)(HistogramChart,{data:{type:(null===(c=d.params)||void 0===c?void 0:c.column_type)||"",datasets:[x,h],min:f,max:p,samples:h.total,binEdges:g}})}),(0,r.jsx)(_.L,{})]})]})}):(0,r.jsx)("div",{children:"Loading..."})}function isStringDataType(e){return["CHAR","VARCHAR","TINYTEXT","TEXT","MEDIUMTEXT","LONGTEXT","NCHAR","NVARCHAR","VARCHAR2","NVARCHAR2","CLOB","NCLOB","VARCHAR(MAX)","XML","JSON","BOOLEAN","TINYINT(1)","BIT","NUMBER(1)","BOOL"].includes(e.toUpperCase())}function isDateTimeType(e){return["DATE","DATETIME","TIMESTAMP","TIME","YEAR","DATETIME2","SMALLDATETIME","DATETIMEOFFSET","INTERVAL","TIMESTAMPTZ","TIMETZ","TIMESTAMP WITH TIME ZONE","TIMESTAMP WITH LOCAL TIME ZONE","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP_TZ"].includes(e.toUpperCase())}function HistogramDiffForm(e){var n;let{params:t,onParamsChanged:i,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eH().find(null===(n=a.lineageGraphSets)||void 0===n?void 0:n.all.nodes,{name:null==t?void 0:t.model}),c=s?extractColumns(s).filter(e=>!isStringDataType(e.type)&&!isDateTimeType(e.type)):[];return(0,r.jsx)(l.xu,{m:"16px",children:(0,r.jsxs)(eM.NI,{children:[(0,r.jsx)(eO.l,{children:"Pick a column to show Histogram Diff"}),(0,r.jsx)(e2.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{var n;let r=e.target.value;o(!!r);let l=(null===(n=c.find(e=>e.name===r))||void 0===n?void 0:n.type)||"";i({...t,column_name:r,column_type:l})},children:c.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}let e5=(0,v.createContext)({runAction:()=>{}}),e6={profile_diff:{title:"Profile Diff",RunResultView:ProfileDiffResultView},value_diff:{title:"Value Diff",RunResultView:ValueDiffResultView,RunForm:ValueDiffForm},value_diff_detail:{title:"Value Diff Detail",RunResultView:ValueDiffDetailResultView,RunForm:ValueDiffForm},top_k_diff:{title:"Top-K Diff",RunResultView:TopKDiffResultView,RunForm:TopKDiffForm},histogram_diff:{title:"Histogram Diff",RunResultView:HistogramDiffResultView,RunForm:HistogramDiffForm}},useCloseModalEffect=e=>{let[n]=(0,eF.TH)();(0,v.useEffect)(()=>{e()},[e,n])};function RecceActionContextProvider(e){var n;let{children:t}=e,[i,l]=(0,v.useState)(),{isOpen:o,onOpen:a,onClose:s}=(0,et.q)(),c=(0,v.useCallback)(async(e,n,t)=>{let r;let i=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await searchRuns(e,n,1);1===t.length&&(r=t[0])}l({session:i,type:e,params:n,lastRun:r,options:t}),a()},[l,a]);return useCloseModalEffect(s),(0,r.jsxs)(e5.Provider,{value:{runAction:c},children:[i&&e6[i.type]&&(0,r.jsx)(RunModal,{isOpen:o,onClose:s,title:e6[i.type].title,type:i.type,params:i.params,initialRun:i.lastRun,RunResultView:e6[i.type].RunResultView,RunForm:(null===(n=i.options)||void 0===n?void 0:n.showForm)?e6[i.type].RunForm:void 0},i.session),t]})}let useRecceActionContext=()=>(0,v.useContext)(e5);function NodeView(e){let{node:n,onCloseNode:t}=e,[,i]=(0,eF.TH)(),{setSqlQuery:o}=useRecceQueryContext(),s="model"===n.resourceType||"seed"===n.resourceType||"source"===n.resourceType,{isOpen:c,onOpen:d,onClose:u}=(0,et.q)(),{runAction:x}=useRecceActionContext(),f=(0,v.useCallback)(async()=>{let e=n.id,t=await createCheckByNodeSchema(e);i("/checks/".concat(t.check_id))},[n,i]);return(0,r.jsxs)(er.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,r.jsxs)(m.U,{children:[(0,r.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,r.jsx)(ei.X,{size:"sm",children:n.name})}),(0,r.jsx)(_.L,{}),"modified"===n.changeStatus&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(h.z,{onClick:d,leftIcon:(0,r.jsx)(R.tvD,{}),colorScheme:"orange",variant:"solid",children:"Diff"}),(0,r.jsxs)(el.u_,{isOpen:c,onClose:u,size:"6xl",children:[(0,r.jsx)(eo.Z,{}),(0,r.jsxs)(ea.h,{overflowY:"auto",height:"75%",children:[(0,r.jsx)(es.x,{children:"Model Raw Code Diff"}),(0,r.jsx)(ec.o,{}),(0,r.jsx)(ed.f,{children:(0,r.jsx)(SqlDiffView,{base:n.data.base,current:n.data.current})})]})]})]}),(0,r.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,r.jsx)(eu.P,{onClick:t})})]}),(0,r.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,r.jsx)(RowCountTag,{node:n,isInteractive:!0})]})}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(eh.m,{overflow:"auto",as:a.k,children:[(0,r.jsx)(em.t,{children:(0,r.jsx)(ex.O,{children:"Columns"})}),(0,r.jsx)(ef.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,r.jsx)(ep.x,{p:0,overflowY:"auto",height:"100%",children:(0,r.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]}),(0,r.jsxs)(m.U,{p:"16px",children:[(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{as:h.z,size:"sm",colorScheme:"blue",children:"Add check"}),(0,r.jsx)(g.q,{children:(0,r.jsx)(y.s,{onClick:f,children:"Schema Check"})})]}),(0,r.jsx)(_.L,{}),"model"===n.resourceType&&(0,r.jsxs)(r.Fragment,{children:["added"!==n.changeStatus&&"removed"!==n.changeStatus&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{as:h.z,size:"sm",colorScheme:"blue",children:"Advanced Diffs"}),(0,r.jsxs)(g.q,{children:[(0,r.jsx)(y.s,{onClick:()=>{x("profile_diff",{model:n.name},{showForm:!1,showLast:!0})},children:"Profile Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("value_diff",{model:n.name},{showForm:!0,showLast:!0})},children:"Value Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("top_k_diff",{model:n.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"}),(0,r.jsx)(y.s,{onClick:()=>{x("histogram_diff",{model:n.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})]})]})}),(0,r.jsx)(h.z,{colorScheme:"blue",size:"sm",onClick:()=>{o('select * from {{ ref("'.concat(n.name,'") }}')),i("/query")},children:"Query"})]})]})]})]})}var e3=t(45438),e4=t(72491),e9=t(52246),e8=t(25807),e7=t(80294),ne=t(15012);function AddSchemaChangesCheckButton(e){let{nodes:n,onFinish:t}=e,[,i]=(0,eF.TH)();return(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===n.length,onClick:async()=>{let e;1===n.length?e=await createCheckByNodeSchema(n[0].id):await Promise.all(n.map(async e=>{await createCheckByNodeSchema(e.id)})),t(),e?i("/checks/".concat(e.check_id)):i("/checks")},children:[(0,r.jsx)(s.J,{as:e7.Edg}),"Add schema check"]})}function AddLineageDiffCheckButton(e){let{viewMode:n,nodes:t,onFinish:i,withIcon:l}=e,[,o]=(0,eF.TH)();return(0,r.jsxs)(h.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:0===t.length,onClick:async()=>{let e=t.map(e=>e.id),r=await createLineageDiffCheck(n,e);i(),r?o("/checks/".concat(r.check_id)):o("/checks")},children:[l&&(0,r.jsx)(s.J,{as:ne.Ks7}),"Add lineage diff check"]})}function NodeSelector(e){var n,t,i,o;let{viewMode:a,nodes:c,onClose:d,onActionStarted:u,onActionNodeUpdated:x,onActionCompleted:f}=e,[p,g]=(0,v.useState)({mode:"per_node",status:"pending",completed:0,total:0}),y=(0,Q.NL)(),[,j]=(0,eF.TH)(),submitRunForNodes=async(e,n,t)=>{let r="multi_nodes";p.mode=r,u(),p.status="running";let i=[];for(let e of c){let t=n(e);t?(e.action={mode:r,status:"skipped",skipReason:t},x(e)):(e.action={mode:r,status:"pending"},i.push(e))}let l=t(i);try{let{run_id:n}=await submitRun(e,l,{nowait:!0});for(p.currentRun={run_id:n},p.total=1;;){let e=await waitRun(n,2);p.currentRun=e;let t=e.error?"failure":e.result?"success":"running";for(let n of i)n.action={mode:r,status:t,run:e},x(n);if(e.error||e.result)break}}catch(e){}if(p.completed=1,"canceling"===p.status){p.status="canceled",f();return}p.status="completed",f()},submitRunsPerNodes=async(e,n)=>{let t="per_node";for(let e of(p.mode=t,u(),p.status="running",c))e.action={mode:t,status:"pending"},x(e);for(let r of(p.completed=0,p.total=c.length,c)){let{params:i,skipReason:l}=n(r);if(l)r.action={mode:t,status:"skipped",skipReason:l},x(r);else try{let{run_id:n}=await submitRun(e,i,{nowait:!0});for(p.currentRun={run_id:n},r.action={mode:t,status:"running"},x(r);;){let e=await waitRun(n,2);p.currentRun=e;let i=e.error?"failure":e.result?"success":"running";if(r.action={mode:t,status:i,run:e},x(r),e.error||e.result)break}}catch(e){}finally{p.currentRun=void 0}if(p.completed++,"canceling"===p.status){p.status="canceled",f();return}}p.status="completed",f()},handleRowCountDiffClick=async()=>{let e=[];for(let n of c)"model"!==n.resourceType?(n.action={mode:"multi_nodes",status:"skipped",skipReason:"Not a model"},x(n)):e.push(n.name);submitRunForNodes("row_count_diff",e=>{if("model"!==e.resourceType)return"Not a model"},e=>{let n={node_names:e.map(e=>e.name)};return n})},handleValueDiffClick=async()=>{submitRunsPerNodes("value_diff",e=>{var n,t;let r=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;if(!r)return{skipReason:"No primary key found. The first unique column is used as primary key."};let i={model:e.name,primary_key:r};return{params:i}})},handleCancel=async()=>{var e;p.status="canceling",(null===(e=p.currentRun)||void 0===e?void 0:e.run_id)&&cancelRun(p.currentRun.run_id)},C=(0,v.useCallback)(async()=>{var e;let n=null===(e=p.currentRun)||void 0===e?void 0:e.run_id;if(!n)return;let t=await createCheckByRun(n);y.invalidateQueries({queryKey:W.checks()}),j("/checks/".concat(t.check_id))},[null===(n=p.currentRun)||void 0===n?void 0:n.run_id,j,y]);return(0,e4.z)(()=>{"running"===p.status&&handleCancel()}),(0,r.jsxs)(l.xu,{bg:"white",rounded:"md",shadow:"dark-lg",children:["pending"===p.status&&(0,r.jsxs)(m.U,{p:"5px 15px",mt:"4",divider:(0,r.jsx)(e9.c,{borderColor:"gray.200"}),spacing:4,children:[(0,r.jsxs)(e8.h,{size:"xs",isAttached:!0,variant:"outline",rounded:"xs",onClick:d,children:[(0,r.jsxs)(h.z,{children:[c.length," selected"]}),(0,r.jsx)(M.h,{"aria-label":"Exit select Mode",icon:(0,r.jsx)(e3.D,{})})]}),(0,r.jsxs)(m.U,{children:[(0,r.jsx)(AddSchemaChangesCheckButton,{nodes:c,onFinish:d}),(0,r.jsx)(AddLineageDiffCheckButton,{viewMode:a,nodes:c,onFinish:d,withIcon:!0})]}),(0,r.jsxs)(m.U,{children:[(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleRowCountDiffClick,children:[(0,r.jsx)(s.J,{as:O.SwK}),"Row count diff"]}),(0,r.jsxs)(h.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleValueDiffClick,children:[(0,r.jsx)(s.J,{as:ne.pRi}),"Value diff"]})]})]}),"pending"!==p.status&&(0,r.jsxs)(m.U,{p:"5px 15px",mt:"4",divider:(0,r.jsx)(e9.c,{borderColor:"gray.200"}),spacing:4,children:[(0,r.jsxs)(l.xu,{fontSize:"10pt",children:["Progress: ","per_node"===p.mode?"".concat(p.completed," / ").concat(p.total):(null===(o=p.currentRun)||void 0===o?void 0:null===(i=o.progress)||void 0===i?void 0:i.percentage)?"".concat(100*p.currentRun.progress.percentage,"%"):"completed"===p.status?"100%":"0%"," ","canceled"===p.status?" (canceled)":""]}),"running"===p.status||"canceling"===p.status?(0,r.jsx)(h.z,{size:"xs",variant:"outline",onClick:handleCancel,isLoading:"canceling"===p.status,loadingText:"Canceling",children:"Cancel"}):(0,r.jsxs)(m.U,{children:["multi_nodes"===p.mode&&(null===(t=p.currentRun)||void 0===t?void 0:t.result)&&(0,r.jsx)(h.z,{display:"none",size:"xs",variant:"outline",onClick:C,children:"Add to checklist"}),(0,r.jsx)(h.z,{size:"xs",variant:"outline",onClick:d,children:"Close"})]})]})]})}function RowCountDiffResultView(e){let{run:n}=e;function columnCellClass(e){if(e.base===e.current);else if(e.basee.current||"N/A"===e.current)return"column-body-removed";return"column-body-normal"}let t=n.result||{},i=Object.keys(n.result||{}).map(e=>{let n=t[e],r=(null==n?void 0:n.base)||null,i=(null==n?void 0:n.curr)||null,l="No Change";return null!==r&&null!==i?l=r!==i?deltaPercentageString(r,i):"No Change":r===i?l="N/A":null===r?l="Added":null===i&&(l="Removed"),{name:e,base:null===r?"N/A":Number(r),current:null===i?"N/A":Number(i),delta:l}});return(0,r.jsx)(a.k,{direction:"column",children:Object.keys(t).length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:[{key:"name",name:"Name",cellClass:columnCellClass},{key:"base",name:"Base Rows",cellClass:columnCellClass},{key:"current",name:"Current Rows",cellClass:columnCellClass},{key:"delta",name:"Delta",cellClass:columnCellClass}],rows:i,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},className:"rdg-light",enableScreenshot:!0})})})}function NodeRunView(e){var n,t,i,o,s,c,d,u,x;let{node:f,onCloseNode:p}=e,g=null===(n=f.action)||void 0===n?void 0:n.run,[,y]=(0,eF.TH)(),j=(0,Q.NL)(),[C,b]=(0,v.useState)(),k=(0,v.useCallback)(async()=>{if(!(null==g?void 0:g.run_id))return;let e=await createCheckByRun(g.run_id,C);j.invalidateQueries({queryKey:W.checks()}),y("/checks/".concat(e.check_id))},[null==g?void 0:g.run_id,y,j,C]),w=(null===(i=f.action)||void 0===i?void 0:null===(t=i.run)||void 0===t?void 0:t.type)==="value_diff"?ValueDiffResultView:(null===(s=f.action)||void 0===s?void 0:null===(o=s.run)||void 0===o?void 0:o.type)==="row_count_diff"?RowCountDiffResultView:null;return(0,r.jsxs)(er.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,r.jsxs)(m.U,{children:[(0,r.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,r.jsx)(ei.X,{size:"sm",children:f.name})}),(0,r.jsx)(_.L,{}),(0,r.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,r.jsx)(eu.P,{onClick:p})})]}),(0,r.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,r.jsxs)(m.U,{spacing:"8px",children:[(0,r.jsx)(ResourceTypeTag,{node:f}),(null==g?void 0:g.type)==="row_count_diff"&&(null===(c=g.result)||void 0===c?void 0:c[f.name])&&(0,r.jsx)(RowCountTag,{rowCount:g.result[f.name],node:f})]})}),(0,r.jsxs)(eh.m,{overflow:"auto",as:a.k,children:[(0,r.jsx)(em.t,{children:(0,r.jsx)(ex.O,{children:"Run"})}),(0,r.jsx)(ef.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,r.jsx)(ep.x,{p:0,overflowY:"auto",height:"100%",children:w?(0,r.jsx)(RunView,{run:null===(d=f.action)||void 0===d?void 0:d.run,viewOptions:C,onViewOptionsChanged:b,RunResultView:w}):(0,r.jsx)(l.xu,{p:"20px 10px",children:"No run result"})})})]}),(0,r.jsxs)(m.U,{p:"16px",children:[(0,r.jsx)(_.L,{}),(0,r.jsx)(h.z,{size:"sm",colorScheme:"blue",isDisabled:!(null===(x=f.action)||void 0===x?void 0:null===(u=x.run)||void 0===u?void 0:u.result),onClick:k,children:"Add to checklist"})]})]})}let layout=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",r=new(w()).graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:t}),e.forEach(e=>{r.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{r.setEdge(e.source,e.target)}),w().layout(r),e.forEach(e=>{let n=r.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})},nn={customNode:GraphNode},nt={customEdge:GraphEdge},nodeColor=e=>{var n,t;return(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.changeStatus)?getIconForChangeStatus(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.changeStatus).color:"lightgray"},nr={all:"All",changed_models:"Changed Models"};function ChangeStatusLegend(){return(0,r.jsx)(l.xu,{bg:"white",padding:"12px",borderWidth:"1px",borderColor:"gray.200",fontSize:"sm",children:Object.entries({added:["Added","Added resource"],removed:["Removed","Removed resource"],modified:["Modified","Modified resource"]}).map(e=>{let[n,[t,i]]=e,{icon:l,color:c}=getIconForChangeStatus(n);return(0,r.jsx)(o.u,{label:i,children:(0,r.jsxs)(a.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,r.jsx)(s.J,{color:c,as:l})," ",t]})},n)})})}function _LineageView(e){let{...n}=e,{fitView:t,setCenter:o,getZoom:k}=(0,i._K)(),{successToast:w,failToast:_}=useClipBoardToast(),{onOpen:S,setImgBlob:R,ImageBoardModal:D}=useImageBoardModal(),{toImage:N,ref:E}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(eN))},onSuccess:async e=>{try{await copyBlobToClipboard(e),w("Copied the Lineage View as an image to clipboard")}catch(n){"ClipboardItem is not defined"===n.message?(R(e),S()):_("Failed to copy image to clipboard",n)}},onError:e=>{console.error("Error taking screenshot",e),_("Failed to copy image to clipboard",e)}}),[T,I,L]=(0,i.Rr)([]),[F,z,A]=(0,i.ll)([]),[M,P]=(0,v.useState)(),[V,B]=(0,v.useState)(),{lineageGraphSets:q,isLoading:H,error:K,refetchRunsAggregated:W}=useLineageGraphsContext(),[U,G]=(0,v.useState)("detail"),[Q,J]=(0,v.useState)(),[Z,X]=(0,v.useState)(!1),[Y,$]=(0,v.useState)(n.viewMode||"changed_models"),[ee,et]=(0,v.useState)(!1),[er,ei]=(0,v.useState)({x:0,y:0});(0,v.useEffect)(()=>{if(!q)return;let e="changed_models"===Y?{...q.changed}:{...q.all},t=q.modifiedSet;if("function"==typeof n.filterNodes){let t=n.filterNodes?n.filterNodes:()=>!0;e.nodes=Object.fromEntries(Object.entries(e.nodes).filter(e=>{let[n,r]=e;return t(n,r)}))}let[r,i]=toReactflow(e,q.modifiedSet);layout(r,i),P(e),B(t),I(r),z(i)},[I,z,Y,q,n.filterNodes]);let centerNode=e=>{if(e.width&&e.height){let n=e.position.x+e.width/2,t=e.position.y+e.height/2,r=k();o(n,t,{zoom:r,duration:200})}},el=(0,v.useCallback)(e=>{I(n=>{let t=n.map(n=>n.id===e.id?{...n,data:e}:n);return t})},[I]);if(H)return(0,r.jsx)(a.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,r.jsx)(c.$,{size:"xl"})});let closeContextMenu=()=>{et(!1),ei({x:0,y:0})};return K?(0,r.jsxs)(r.Fragment,{children:["Fail to load lineage data: ",K]}):"changed_models"===Y&&(void 0===V||(null==V?void 0:V.length)===0)?(0,r.jsx)(d.M,{h:"100%",children:(0,r.jsxs)(u.g,{children:[(0,r.jsx)(r.Fragment,{children:"No change detected"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>{$("all")},children:"Show all nodes"})]})}):(0,r.jsxs)(a.k,{width:"100%",height:"100%",children:[(0,r.jsx)(l.xu,{flex:"1 0 0px",children:(0,r.jsxs)(i.x$,{nodeTypes:nn,edgeTypes:nt,nodes:T,edges:F,onNodesChange:L,onEdgesChange:A,onNodeClick:(e,t)=>{!1!==n.interactive&&(closeContextMenu(),"detail"===U?(J(t.data),Z||(X(!0),centerNode(t)),I(selectSingleNode(t.id,T))):"action_result"===U?(J(t.data),Z||(X(!0),centerNode(t)),I(selectSingleNode(t.id,T))):I(selectNode(t.id,T)))},onNodeMouseEnter:(e,n)=>{if(M&&void 0!==V){let[e,t]=highlightPath(M,V,T,F,n.id);I(e),z(t)}},onNodeMouseLeave:(e,n)=>{if(M&&void 0!==V){let[e,n]=highlightPath(M,V,T,F,null);I(e),z(n)}},onNodeContextMenu:(e,n)=>{"action"===U&&(e.preventDefault(),ei({x:e.clientX,y:e.clientY,selectedNode:n}),et(!0))},onClick:closeContextMenu,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:n.interactive,ref:E,children:[(0,r.jsx)(j.A,{color:"#ccc"}),(0,r.jsxs)(C.Z,{showInteractive:!1,position:"top-right",className:eN,children:[n.interactive&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(C.B,{title:"switch mode",onClick:()=>{$("all"===Y?"changed_models":"all");let e=cleanUpNodes(T);I(e)},children:(0,r.jsx)(s.J,{as:O.Bw1})})}),(0,r.jsx)(C.B,{title:"copy image",onClick:()=>{N()},children:(0,r.jsx)(s.J,{as:O.C3L})})]}),(0,r.jsx)(D,{}),(0,r.jsx)(i.s_,{position:"bottom-left",children:(0,r.jsxs)(m.U,{children:[(0,r.jsx)(ChangeStatusLegend,{}),n.interactive&&(0,r.jsxs)(l.xu,{p:2,flex:"0 1 160px",fontSize:"14px",className:eN,children:[(0,r.jsx)(x.x,{color:"gray",mb:"2px",children:"Actions"}),(0,r.jsxs)(u.g,{spacing:1,align:"baseline",children:[(0,r.jsx)(h.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:"detail"!==U,onClick:()=>{let e="detail"===U?"action":"detail";J(void 0),X(!1);let n=cleanUpNodes(T,"action"===e);I(n),G(e)},children:"Select Models"}),(0,r.jsx)(AddLineageDiffCheckButton,{viewMode:Y,nodes:T.map(e=>e.data),onFinish:()=>G("detail")})]})]})]})}),(0,r.jsx)(i.s_,{position:"top-left",children:(0,r.jsx)(x.x,{fontSize:"xl",color:"grey",opacity:.5,children:nr[Y]})}),(0,r.jsx)(i.s_,{position:"bottom-center",className:eN,children:(0,r.jsx)(f.R,{in:"detail"!==U,unmountOnExit:!0,style:{zIndex:10},children:(0,r.jsx)(NodeSelector,{viewMode:Y,nodes:T.map(e=>e.data).filter(e=>e.isSelected),onClose:()=>{G("detail");let e=cleanUpNodes(T);J(void 0),X(!1),I(e),null==W||W()},onActionStarted:()=>{G("action_result")},onActionNodeUpdated:el,onActionCompleted:()=>{}})})}),(0,r.jsx)(b.a,{nodeColor:nodeColor,nodeStrokeWidth:3})]})}),"detail"===U&&Q&&(0,r.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,r.jsx)(NodeView,{node:Q,onCloseNode:()=>{J(void 0),X(!1),I(cleanUpNodes(T))}})}),"action_result"===U&&Q&&(0,r.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,r.jsx)(NodeRunView,{node:Q,onCloseNode:()=>{J(void 0),X(!1)}})}),ee&&(0,r.jsx)(p.v,{isOpen:!0,onClose:closeContextMenu,children:(0,r.jsxs)(g.q,{style:{position:"absolute",left:"".concat(er.x,"px"),top:"".concat(er.y,"px")},children:[(0,r.jsx)(y.s,{icon:(0,r.jsx)(en.Cv2,{}),onClick:()=>{let e=er.selectedNode;if("action"!==U||void 0===e||void 0===M)return;let n=e.id,t=selectUpstream(M,[n]),r=selectNodes([...t],T);I(r)},children:"Select parent nodes"}),(0,r.jsx)(y.s,{icon:(0,r.jsx)(en.IMj,{}),onClick:()=>{let e=er.selectedNode;if("action"!==U||void 0===e||void 0===M)return;let n=e.id,t=selectDownstream(M,[n]),r=selectNodes([...t],T);I(r)},children:"Select child nodes"})]})})]})}function LineageView(e){let{...n}=e;return void 0===n.interactive&&(n.interactive=!0),void 0===n.viewMode&&(n.viewMode="changed_models"),(0,r.jsx)(i.tV,{children:(0,r.jsx)(_LineageView,{...n})})}var ni=t(16761),nl=t(98786);function RecceContextProvider(e){let{children:n}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(RecceQueryContextProvider,{children:(0,r.jsx)(LineageGraphsContextProvider,{children:(0,r.jsx)(RowCountStateContextProvider,{children:(0,r.jsx)(RecceActionContextProvider,{children:n})})})})})}function useVersionNumber(){let[e,n]=(0,v.useState)("");return(0,v.useEffect)(()=>{(async function(){try{let e=await H.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}var no=t(45489),na=t(69005),ns=t(14800),nc=t(2600),nd=t(68677),nu=t(83358),nh=t(44525),nm=t(93197),nx=t(234),nf=t(96094),np=t(36334);function CheckBreadcrumb(e){let{name:n,setName:t}=e,[i,o]=(0,v.useState)(!1),[a,s]=(0,v.useState)(n),c=(0,v.useRef)(null),d=(0,v.useCallback)(()=>{t(a),o(!1)},[t,o,a]);return(0,v.useEffect)(()=>{let handleClickOutside=e=>{c.current&&!c.current.contains(e.target)&&d()};return i&&document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[i,c,d]),(0,r.jsxs)(nx.a,{flex:"0 1",fontSize:"12pt",fontWeight:"500",separator:(0,r.jsx)(np.X,{color:"gray.500"}),children:[(0,r.jsx)(nf.g,{children:(0,r.jsx)(l.xu,{children:"Checklist"})}),(0,r.jsx)(nf.g,{flex:"0 1",cursor:"pointer",children:i?(0,r.jsx)(eP.I,{ref:c,value:a,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Enter"===e.key?(t(a),o(!1)):"Escape"===e.key&&(s(n),o(!1))},size:"sm",w:"auto",minW:"200px",maxW:"600px"}):(0,r.jsx)(l.xu,{onClick:()=>{s(n),o(!0)},textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n})})]})}function SchemaDiffView(e){let{check:n}=e,{lineageGraphSets:t}=useLineageGraphsContext(),i=n.params,l=i.node_id,o=l?null==t?void 0:t.all.nodes[l]:void 0;return o?(0,r.jsx)(SchemaView,{base:o.data.base,current:o.data.current,enableScreenshot:!0}):(0,r.jsx)(r.Fragment,{})}var ng=t(33695);function CheckDescription(e){let{value:n,onChange:t}=e,[i,l]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),c=(0,v.useRef)(null);return((0,v.useEffect)(()=>{if(i&&c.current){let e=c.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[i]),i)?(0,r.jsxs)(a.k,{direction:"column",align:"flex-end",children:[(0,r.jsx)(ng.g,{h:"200px",value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&l(!1)},ref:c}),(0,r.jsxs)(a.k,{gap:"12px",alignItems:"flex-end",children:[(0,r.jsx)(eG.r,{onClick:()=>{setTimeout(()=>{l(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,r.jsx)(h.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:()=>{t&&(t(o),l(!1))},children:"Update"})]})]}):(0,r.jsx)(x.x,{maxHeight:"400px",overflow:"auto",fontSize:"11pt",onClick:()=>{s(n||""),l(!0)},whiteSpace:"pre-line",color:n?"inherit":"lightgray",children:n||"Add description here"})}var ny=t(48742);function _templateObject(){let e=(0,no._)(["\n **SQL**\n ```sql\n ","\n ```\n "],["\n **SQL**\n \\`\\`\\`sql\n ","\n \\`\\`\\`\n "]);return _templateObject=function(){return e},e}function buildTitle(e){return"".concat(e.is_checked?"✅ ":"").concat(e.name)}function buildDescription(e){return e.description?e.description:"_(no description)_"}function buildQuery(e){var n;return(0,ny.Pn)(_templateObject(),null===(n=e.params)||void 0===n?void 0:n.sql_template)}var query_SqlEditor=e=>{let{value:n,onChange:t,onRun:i,onRunDiff:l,options:o={},...a}=e;return(0,r.jsx)(eL.ZP,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{i&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,i),l&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyMod.Shift|n.KeyCode.Enter,l)},options:{tabSize:2,fontSize:16,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"indent",...o}})};function DataFrameColumnHeader(e){let{name:n,pinnedColumns:t=[],onPinnedColumnsChange:i=()=>{}}=e,o=t.includes(n);return(0,r.jsxs)(a.k,{className:"grid-header",alignItems:"center",children:[(0,r.jsx)(l.xu,{flex:1,children:n}),(0,r.jsx)(s.J,{className:o?"unpin-icon":"pin-icon",display:o?"block":"none",cursor:"pointer",as:o?S.$kI:S.oJP,onClick:o?()=>{let e=t.filter(e=>e!==n);i(e)}:()=>{let e=[...t,n];i(e)}})]})}function QueryResultView_toDataGrid(e,n){let t=[],i=n.pinnedColumns||[],toColumn=(e,t)=>({key:String(e),name:(0,r.jsx)(DataFrameColumnHeader,{name:t,...n}),width:"auto",renderCell:defaultRenderCell});return t.push({key:"_index",name:"",width:10,cellClass:"index-column"}),i.forEach(n=>{let r=eH().findIndex(e.columns,e=>e.name===n);r<0||t.push(toColumn(r,n))}),e.columns.forEach((e,n)=>{i.includes(e.name)||t.push(toColumn(n,e.name))}),e.data.forEach((e,n)=>{e._index=n+1}),{columns:t,rows:e.data}}let QueryResultView=e=>{let{run:n,viewOptions:t,onViewOptionsChanged:i,onAddToChecklist:s}=e,c=(0,v.useMemo)(()=>(null==t?void 0:t.pinned_columns)||[],[t]),u=null==n?void 0:n.result,h=(0,v.useMemo)(()=>u?QueryResultView_toDataGrid(u,{pinnedColumns:c,onPinnedColumnsChange:e=>{i&&i({...t,pinned_columns:e})}}):{rows:[],columns:[]},[u,c,t,i]);if(0===h.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});let m=(null==u?void 0:u.limit)||0,x=m>0&&(null==u?void 0:u.more)?"Warning: Displayed results are limited to ".concat(m.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(s||x)&&(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:x?"orange.100":"inherit",children:[x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.a,{color:"orange.600",alignSelf:"center"})," ",(0,r.jsx)(l.xu,{children:x})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),s&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>s(n)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},QueryDiffResultView=e=>{var n,t,i,s,c,h;let{run:m,onAddToChecklist:x,viewOptions:f,onViewOptionsChanged:p}=e,g=(0,v.useMemo)(()=>(null==f?void 0:f.primary_keys)||[],[f]),y=(0,v.useMemo)(()=>(null==f?void 0:f.changed_only)||!1,[f]),j=(0,v.useMemo)(()=>(null==f?void 0:f.pinned_columns)||[],[f]),C=(0,v.useMemo)(()=>{var e,n;return toDataDiffGrid(null==m?void 0:null===(e=m.result)||void 0===e?void 0:e.base,null==m?void 0:null===(n=m.result)||void 0===n?void 0:n.current,{changedOnly:y,primaryKeys:g,onPrimaryKeyChange:e=>{p&&p({...f,primary_keys:e})},pinnedColumns:j,onPinnedColumnsChange:e=>{p&&p({...f,pinned_columns:e})}})},[m,f,y,g,j,p]),b=(0,v.useMemo)(()=>{let e=g.join(", ");return C.invalidPKeyBase&&C.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):C.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):C.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[C.invalidPKeyBase,C.invalidPKeyCurrent,g]);if(0===C.columns.length)return(0,r.jsx)(d.M,{height:"100%",children:"No data"});if(y&&0===C.rows.length)return(0,r.jsx)(d.M,{height:"100%",children:"No change"});let k=(null===(t=m.result)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.limit)||0,w=k>0&&((null==m?void 0:null===(s=m.result)||void 0===s?void 0:null===(i=s.current)||void 0===i?void 0:i.more)||(null==m?void 0:null===(h=m.result)||void 0===h?void 0:null===(c=h.base)||void 0===c?void 0:c.more))?"Warning: Displayed results are limited to ".concat(k.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,r.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,r.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:w||b?"orange.100":"inherit",children:[(0,r.jsxs)(u.g,{alignItems:"flex-start",spacing:0,children:[b&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",b]}),w&&(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(L.a,{color:"orange.600"})," ",w]})]}),(0,r.jsx)(_.L,{minHeight:"32px"}),(0,r.jsx)(eV.X,{isChecked:null==f?void 0:f.changed_only,onChange:()=>{let e=!(null==f?void 0:f.changed_only);p&&p({...f,changed_only:e})},children:"Changed only"}),x&&(0,r.jsx)(o.u,{label:"Add to Checklist",children:(0,r.jsx)(M.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,r.jsx)(eU.d,{}),onClick:()=>x(m)})})]}),(0,r.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:C.columns,rows:C.rows,renderers:{noRowsFallback:(0,r.jsx)(EmptyRowsRenderer,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};function LineageDiffView(e){var n;let{check:t}=e,i=(null===(n=t.params)||void 0===n?void 0:n.view_mode)||"";return(0,r.jsx)(a.k,{direction:"column",height:"100%",children:(0,r.jsx)(LineageView,{viewMode:i,interactive:!1,filterNodes:e=>{var n,r;return null===(r=t.params)||void 0===r?void 0:null===(n=r.node_ids)||void 0===n?void 0:n.includes(e)}})})}function CheckDetail_templateObject(){let e=(0,no._)(["\n
","\n\n ","\n\n
"]);return CheckDetail_templateObject=function(){return e},e}let nv={query:QueryResultView,query_diff:QueryDiffResultView,value_diff:ValueDiffResultView,value_diff_detail:ValueDiffDetailResultView,profile_diff:ProfileDiffResultView,row_count_diff:RowCountDiffResultView,top_k_diff:TopKDiffResultView,histogram_diff:HistogramDiffResultView},useCancelOnUnmount=e=>{let{runId:n,isPending:t,setAborting:r}=e;(0,v.useEffect)(()=>()=>{r(!1),n&&t&&cancelRun(n)},[t,n,r])},CheckDetail=e=>{var n;let{checkId:t}=e,i=(0,Q.NL)(),[,c]=(0,eF.TH)(),{successToast:u,failToast:m}=useClipBoardToast(),[x,f]=(0,v.useState)(),[j,C]=(0,v.useState)(),[b,k]=(0,v.useState)(!1),{isLoading:w,error:R,refetch:D,data:N}=(0,U.a)({queryKey:W.check(t),queryFn:async()=>getCheck(t),refetchOnMount:!1,staleTime:3e5}),E=N&&(null==N?void 0:N.type)in nv?nv[null==N?void 0:N.type]:void 0,{mutate:T}=(0,eK.D)({mutationFn:e=>updateCheck(t,e),onSuccess:()=>{i.invalidateQueries({queryKey:W.check(t)}),i.invalidateQueries({queryKey:W.checks()})}}),{mutate:I}=(0,eK.D)({mutationFn:()=>deleteCheck(t),onSuccess:()=>{i.invalidateQueries({queryKey:W.checks()}),c("/checks")}}),submitRunFn=async()=>{let e=null==N?void 0:N.type;if(!e)return;let{run_id:n}=await submitRunFromCheck(t,{nowait:!0});for(f(n);;){let e=await waitRun(n,2);if(C(e.progress),e.result||e.error)return k(!1),C(void 0),e}},{data:L,mutate:F,error:z,isIdle:A,isPending:O}=(0,eK.D)({mutationFn:submitRunFn,onSuccess:e=>{D()}}),handleRerun=async()=>{F()},P=(0,v.useCallback)(async()=>{if(k(!0),x)return await cancelRun(x)},[x]);useCancelOnUnmount({runId:x,isPending:O,setAborting:k});let handleCopy=async()=>{if(!N)return;let e=buildMarkdown(N);if(!navigator.clipboard){m("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),u("Copied the check to the clipboard")}catch(e){m("Failed to copy the check to clipboard",e)}},V=(0,v.useCallback)(()=>{let e=null==N?void 0:N.is_checked;T({is_checked:!e})},[null==N?void 0:N.is_checked,T]);if(w)return(0,r.jsx)(d.M,{h:"100%",children:"Loading"});if(R)return(0,r.jsxs)(d.M,{h:"100%",children:["Error: ",R.message]});let B=A?null==N?void 0:N.last_run:L,q=(null==B?void 0:B.run_at)?(0,eW.Z)(new Date(B.run_at),{addSuffix:!0}):null;return(0,r.jsxs)(a.k,{height:"100%",width:"100%",maxHeight:"100%",direction:"column",children:[(0,r.jsxs)(a.k,{p:"0px 16px",alignItems:"center",children:[(0,r.jsx)(CheckBreadcrumb,{name:(null==N?void 0:N.name)||"",setName:e=>{T({name:e})}}),(0,r.jsx)(_.L,{}),(0,r.jsxs)(p.v,{children:[(0,r.jsx)(eg.j,{isRound:!0,as:M.h,icon:(0,r.jsx)(s.J,{as:S.D_A}),variant:"ghost"}),(0,r.jsx)(g.q,{children:(0,r.jsx)(y.s,{icon:(0,r.jsx)(nh.p,{}),onClick:()=>I(),children:"Delete"})})]}),q&&(0,r.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:q}),N&&(null==N?void 0:N.type)in nv&&(0,r.jsx)(o.u,{label:"Rerun",children:(0,r.jsx)(M.h,{isRound:!0,isLoading:O,variant:"ghost","aria-label":"Rerun",icon:(0,r.jsx)(ee.n,{}),onClick:()=>handleRerun()})}),(0,r.jsx)(o.u,{label:"Copy markdown",children:(0,r.jsx)(M.h,{isRound:!0,variant:"ghost","aria-label":"Copy markdown",icon:(0,r.jsx)(eC.T,{}),onClick:()=>handleCopy()})}),(0,r.jsx)(o.u,{label:(null==N?void 0:N.is_checked)?"Mark as unchecked":"Mark as checked",children:(0,r.jsx)(h.z,{size:"sm",colorScheme:(null==N?void 0:N.is_checked)?"green":"gray",leftIcon:(0,r.jsx)(nm.r,{}),onClick:()=>V(),children:(null==N?void 0:N.is_checked)?"Checked":"Unchecked"})})]}),(0,r.jsx)(l.xu,{p:"8px 16px",minHeight:"100px",children:(0,r.jsx)(CheckDescription,{value:null==N?void 0:N.description,onChange:e=>{T({description:e})}},null==N?void 0:N.check_id)}),((null==N?void 0:N.type)==="query"||(null==N?void 0:N.type)==="query_diff")&&(0,r.jsx)(na.U,{defaultIndex:[],allowToggle:!0,children:(0,r.jsxs)(ns.Q,{children:[(0,r.jsxs)(nc.K,{children:["query",(0,r.jsx)(nd.X,{})]}),(0,r.jsx)(nu.H,{children:(0,r.jsx)(l.xu,{height:"400px",width:"100%",border:"lightgray 1px solid ",children:(0,r.jsx)(query_SqlEditor,{value:(null===(n=null==N?void 0:N.params)||void 0===n?void 0:n.sql_template)||"",options:{readOnly:!0}})})})]})}),(0,r.jsxs)(l.xu,{style:{contain:"size"},flex:"1 1 0%",children:[E&&(0,r.jsx)(RunView,{isPending:O,isAborting:b,run:B,error:z,progress:j,RunResultView:E,viewOptions:null==N?void 0:N.view_options,onViewOptionsChanged:e=>{T({view_options:e})},onCancel:P}),N&&"schema_diff"===N.type&&(0,r.jsx)(SchemaDiffView,{check:N}),N&&"lineage_diff"===N.type&&(0,r.jsx)(LineageDiffView,{check:N})]})]})};function buildMarkdown(e){return(0,ny.Pn)(CheckDetail_templateObject(),buildTitle(e),buildBody(e))}function buildBody(e){return"query"===e.type||"query_diff"===e.type?"".concat(buildDescription(e),"\n\n").concat(buildQuery(e)):buildDescription(e)}var nj=t(79648),nC=t(38505);let ChecklistItem=e=>{let{check:n,selected:t,onSelect:i}=e,o=(0,Q.NL)(),c=n.check_id,{mutate:d}=(0,eK.D)({mutationFn:e=>updateCheck(c,e),onSuccess:()=>{o.invalidateQueries({queryKey:W.check(c)}),o.invalidateQueries({queryKey:W.checks()})}}),u=(e=>{switch(e){case"schema_diff":return ne.uhn;case"query":case"query_diff":return ne.r2i;case"value_diff":return ne.pRi;case"profile_diff":return ne.KA6;case"row_count_diff":return O.SwK;case"lineage_diff":return ne.Ks7;case"top_k_diff":return nj.Pkc;case"histogram_diff":return ne.dku;default:return ne.WzH}})(n.type);return(0,r.jsxs)(a.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"gray.200"},bg:t?"gray.100":"inherit",onClick:()=>i(n.check_id),alignItems:"center",gap:"5px",children:[(0,r.jsx)(s.J,{as:u}),(0,r.jsx)(l.xu,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n.name}),n.is_checked&&(0,r.jsx)(s.J,{color:"green",as:R.FJM})]})},CheckList=e=>{let{checks:n,selectedItem:t,onCheckSelected:i,onChecksReordered:l}=e;return(0,r.jsx)(nC.Z5,{onDragEnd:e=>{e.destination&&l(e.source.index,e.destination.index)},children:(0,r.jsx)(nC.bK,{droppableId:"checklist",children:e=>(0,r.jsxs)(u.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",children:[n.map((e,n)=>(0,r.jsx)(nC._l,{draggableId:e.check_id,index:n,children:n=>(0,r.jsx)(a.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,r.jsx)(ChecklistItem,{check:e,selected:e.check_id===t,onSelect:i},e.check_id)})},e.check_id)),e.placeholder]})})})};var nb=t(73672),nk=t(83561);function CheckListInitLoader(){let e=(0,Z.p)(),n=(0,Q.NL)(),t=(0,v.useRef)(null),[i,l]=(0,v.useState)(null),[,o]=useRunsAggregated(),a=(0,v.useCallback)(async()=>{if(i)try{let{checks:t}=await loadChecks(i);o(),n.invalidateQueries({queryKey:W.checks()}),e({description:"".concat(t," checks loaded successfully"),status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(n){console.error("Load failed",n),e({title:"Load failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}},[n,e,i,o]);return(0,v.useEffect)(()=>{i&&a()},[i,a]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.z,{onClick:()=>{t.current&&t.current.click()},children:"Load a checklist"}),(0,r.jsx)("input",{type:"file",style:{display:"none"},ref:t,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&l(e.target.files[0])}})]})}function CheckListLoader(){let e=(0,Z.p)(),n=(0,Q.NL)(),t=(0,v.useRef)(null),i=(0,v.useRef)(null),[l,c]=(0,v.useState)(null),{isOpen:d,onOpen:u,onClose:m}=(0,et.q)(),[,f]=(0,eF.TH)(),[,p]=useRunsAggregated(),g=(0,v.useCallback)(async()=>{if(l){try{let{checks:t}=await loadChecks(l);p(),await n.invalidateQueries({queryKey:W.checks()}),f("/checks"),e({description:"".concat(t," checks loaded successfully"),status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(n){console.error("Load failed",n),e({title:"Load failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}m()}},[n,l,e,m,f,p]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.u,{label:"Load checklist",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Load checks",mr:"10px",onClick:()=>{t.current&&t.current.click()},icon:(0,r.jsx)(s.J,{pt:"10px",as:nk._mA,boxSize:"2em"})})}),(0,r.jsx)("input",{type:"file",style:{display:"none"},ref:t,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&(c(e.target.files[0]),u())}}),(0,r.jsx)(nb.a,{isOpen:d,leastDestructiveRef:i,onClose:m,size:"lg",children:(0,r.jsx)(eo.Z,{children:(0,r.jsxs)(nb._,{children:[(0,r.jsx)(es.x,{fontSize:"lg",fontWeight:"bold",children:"Load checklist"}),(0,r.jsx)(ed.f,{children:(0,r.jsxs)(a.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,r.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,r.jsx)(I.s,{color:"red.600"}),(0,r.jsx)(x.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,r.jsx)(a.k,{children:(0,r.jsxs)(x.x,{children:["The checklist will be"," ",(0,r.jsx)(x.x,{as:"span",fontWeight:"600",children:"overwritten"})," ","by the loaded checklist"]})})]})}),(0,r.jsxs)(ek.m,{children:[(0,r.jsx)(h.z,{ref:i,onClick:m,children:"Cancel"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:g,ml:"5px",children:"Load"})]})]})})})]})}var nw=t(472);function CheckListExporter(){let e=(0,Z.p)(),handleExport=async()=>{try{let e=await exportChecks(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),r=new Date,i="recce-state-".concat((0,eS.ZP)(r,"yyyy-MM-dd-HH-mm-ss"),".json");eD()(t,i)}catch(n){console.error("Export failed",n),e({title:"Export failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}};return(0,r.jsx)(o.u,{label:"Export checklist",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Export checks",onClick:handleExport,icon:(0,r.jsx)(nw._,{})})})}function CheckPage_templateObject(){let e=(0,no._)(["\n
","\n\n ","\n\n
"]);return CheckPage_templateObject=function(){return e},e}let CheckPage=()=>{let{isDemoSite:e}=useLineageGraphsContext(),[,n]=(0,eF.TH)(),[,t]=(0,eF.yj)("/checks/:checkId"),i=(0,Q.NL)(),{successToast:s,failToast:c}=useClipBoardToast(),x=null==t?void 0:t.checkId,{isLoading:f,error:p,data:g,status:y}=(0,U.a)({queryKey:W.checks(),queryFn:listChecks,refetchOnMount:!0}),j=(0,v.useCallback)(e=>{n("/checks/".concat(e))},[n]),[C,b]=(0,v.useState)(g||[]),{mutate:k}=(0,eK.D)({mutationFn:e=>reorderChecks(e),onSuccess:()=>{i.invalidateQueries({queryKey:W.checks()})}}),w=(0,v.useCallback)((e,n)=>{let t=[...C],[r]=t.splice(e,1);t.splice(n,0,r),k({source:e,destination:n}),b(t)},[C,b,k]),_=(0,v.useCallback)(async()=>{let e=await createSimpleCheck();i.invalidateQueries({queryKey:W.checks()}),j(e.check_id)},[i,j]);return((0,v.useEffect)(()=>{"success"===y&&(!x&&g.length>0&&n("/checks/".concat(g[0].check_id)),b(g))},[y,x,g,b,n]),f)?(0,r.jsx)(r.Fragment,{children:"Loading"}):p?(0,r.jsxs)(r.Fragment,{children:["Error: ",p.message]}):(null==g?void 0:g.length)?(0,r.jsxs)(a.k,{height:"100%",children:[(0,r.jsx)(l.xu,{flex:"0 0 400px",borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,r.jsxs)(u.g,{spacing:0,align:"flex-end",h:"100%",children:[(0,r.jsxs)(m.U,{gap:"0px",children:[(0,r.jsx)(o.u,{label:"Create a simple check",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Create a simple check",onClick:_,icon:(0,r.jsx)(eU.d,{})})}),(0,r.jsx)(o.u,{label:"Copy checklist to the clipboard",children:(0,r.jsx)(M.h,{variant:"unstyled","aria-label":"Copy checklist to the clipboard",onClick:async()=>{let e=CheckPage_buildMarkdown(g);if(!navigator.clipboard){c("Failed to copy checklist to clipboard",Error("Copy to clipboard is available only in secure contexts (HTTPS)"));return}try{await navigator.clipboard.writeText(e),s("Copied ".concat(g.length," checks to the clipboard"))}catch(e){c("Failed to copy checklist to clipboard",e)}},icon:(0,r.jsx)(eC.T,{})})}),!e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(CheckListExporter,{}),(0,r.jsx)(CheckListLoader,{})]})]}),(0,r.jsx)(eQ.i,{mb:"8px"}),(0,r.jsx)(CheckList,{checks:C,selectedItem:x,onCheckSelected:j,onChecksReordered:w})]})}),(0,r.jsx)(l.xu,{flex:"1",height:"100%",width:"calc(100% - 400px)",children:(0,r.jsx)(eF.rs,{children:(0,r.jsx)(eF.AW,{path:"/checks/:checkId",children:e=>(0,r.jsx)(CheckDetail,{checkId:e.checkId},e.checkId)})})})]}):(0,r.jsx)(d.M,{h:"100%",children:(0,r.jsxs)(u.g,{children:[(0,r.jsx)(l.xu,{children:"No checks"}),(0,r.jsxs)(a.k,{gap:"5",children:[(0,r.jsx)(h.z,{colorScheme:"blue",onClick:_,children:"Create a simple check"}),!e&&(0,r.jsx)(CheckListInitLoader,{})]})]})})};function CheckPage_buildMarkdown(e){let n=e.map(e=>(0,ny.Pn)(CheckPage_templateObject(),buildTitle(e),buildDescription(e)));return n.join("\n\n")}async function submitQuery(e,n){return await submitRun("query",e,n)}async function submitQueryDiff(e,n){return await submitRun("query_diff",e,n)}let QueryPage=()=>{let{sqlQuery:e,setSqlQuery:n}=useRecceQueryContext(),[t,i]=(0,v.useState)(),[o,s]=(0,v.useState)(),[c,d]=(0,v.useState)({}),u=(0,Q.NL)(),[,m]=(0,eF.TH)(),queryFn=async n=>{i(n);let{run_id:t}="query"===n?await submitQuery({sql_template:e},{nowait:!0}):await submitQueryDiff({sql_template:e},{nowait:!0});return s(t),await waitRun(t)},{data:x,mutate:f,error:p,isPending:g}=(0,eK.D)({mutationFn:queryFn,onSuccess:e=>{d({})}}),y=(0,v.useCallback)(async()=>{if(o)return await cancelRun(o)},[o]),j=(0,v.useCallback)(async e=>{if(!(null==e?void 0:e.run_id))return;let n=await createCheckByRun(e.run_id,c);u.invalidateQueries({queryKey:W.checks()}),m("/checks/".concat(n.check_id))},[m,c,u]);return!g&&(null==x?void 0:x.run_id)&&(null==x||x.error),(0,r.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,r.jsxs)(a.k,{justifyContent:"right",padding:"5px",gap:"5px",children:[(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>f("query_diff"),isDisabled:g,size:"sm",children:"Run Diff"}),(0,r.jsx)(h.z,{colorScheme:"blue",onClick:()=>f("query"),isDisabled:g,size:"sm",children:"Run"})]}),(0,r.jsx)(l.xu,{flex:"1",border:"1px solid #CBD5E0",height:"200px",width:"100%",children:(0,r.jsx)(query_SqlEditor,{value:e,onChange:n,onRun:()=>f("query"),onRunDiff:()=>f("query_diff")})}),(0,r.jsx)(a.k,{height:"50vh",direction:"column",children:"query"===t?(0,r.jsx)(RunView,{run:x,error:p,isPending:g,onCancel:y,children:e=>(0,r.jsx)(QueryResultView,{...e,onAddToChecklist:j})},o):(0,r.jsx)(RunView,{isPending:g,run:x,error:p,viewOptions:c,onViewOptionsChanged:d,onCancel:y,children:e=>(0,r.jsx)(QueryDiffResultView,{...e,onAddToChecklist:j})},o)})]})};var n_=t(72952);let hashNavigate=e=>(0,n_.c4)("#!"+e),useHashLocation=()=>{let e=(0,n_.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr");return[e,hashNavigate]};var nS=t(82017),nR=t(41546);let RunPage=e=>{let{runId:n}=e,{isPending:t,error:i,data:l}=(0,U.a)({queryKey:W.run(n),queryFn:async()=>waitRun(n)});return(0,r.jsx)(RunView,{isPending:t,error:i,run:l,RunResultView:ValueDiffResultView})};var nD=t(26954);let Fallback=e=>{let{error:n,resetError:t}=e;return(0,r.jsx)(d.M,{height:"100%",backgroundColor:"gray.50",children:(0,r.jsxs)(a.k,{p:4,direction:"column",justifyContent:"flex-start",backgroundColor:"white",border:"solid lightgray 1px",minHeight:"200px",children:[(0,r.jsx)(ei.X,{width:"800px",size:"md",children:"You have encountered an error"}),(0,r.jsx)(l.xu,{flex:"1",fontSize:"10pt",children:n.toString()}),(0,r.jsx)(h.z,{justifySelf:"center",alignSelf:"center",mt:"20px",colorScheme:"blue",size:"sm",onClick:()=>{t()},children:"Reset"})]})})},ErrorBoundary=e=>{let{children:n}=e;return(0,r.jsx)(nD.SV,{fallback:Fallback,children:n})};var nN=t(12218);function getCookie(e){var n=document.cookie.match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n.pop():""}let RouteAlwaysMount=e=>{let{children:n,path:t}=e,[i]=(0,eF.yj)(t);return(0,r.jsx)(l.xu,{display:i?"block":"none",height:"100%",children:n})};function TopBar(){let{metadata:e}=useLineageGraphsContext(),n=null==e?void 0:e.pr_url;return n&&null!==n?(0,r.jsxs)(a.k,{gap:"5px",minHeight:"35px",alignItems:"center",justifyContent:"center",bg:"orange.300",children:[(0,r.jsx)(I.s,{color:"orange.600"}),(0,r.jsxs)(x.x,{children:["Please check"," ",(0,r.jsx)(eG.r,{textDecoration:"underline",fontWeight:"600",href:n,isExternal:!0,children:"this Pull Request"})," ","comment for context about this Recce instance"]})]}):(0,r.jsx)(r.Fragment,{})}function NavBar(){let[e,n]=(0,eF.TH)(),t=useVersionNumber(),i=[["Lineage","/lineage"],["Query","/query"],["Checklist","/checks"]],o=eH().findIndex(i,n=>{let[,t]=n;return e.startsWith(t)});return(0,r.jsx)(eh.m,{index:o,children:(0,r.jsxs)(em.t,{children:[i.map(e=>{let[t,i]=e;return(0,r.jsx)(ex.O,{onClick:()=>{n(i)},children:t},t)}),(0,r.jsx)(l.xu,{position:"absolute",right:"0",top:"0",p:"2",color:"gray.500",children:t})]})})}function Home(){(0,v.useLayoutEffect)(()=>{let e=getCookie("recce_user_id");if(e&&nN.env.AMPLITUDE_API_KEY)try{nl.S1(nN.env.AMPLITUDE_API_KEY,e,{defaultTracking:!0})}catch(e){console.error(e)}},[]);let e=(0,nS.Z)({components:{MuiTooltip:{styleOverrides:{tooltip:{zIndex:1500}}}}});return(0,r.jsx)(nR.Z,{theme:e,children:(0,r.jsx)(ni.x,{children:(0,r.jsx)(Q.aH,{client:K,children:(0,r.jsx)(eF.F0,{hook:useHashLocation,children:(0,r.jsx)(RecceContextProvider,{children:(0,r.jsxs)(a.k,{direction:"column",height:"100vh",children:[(0,r.jsx)(TopBar,{}),(0,r.jsx)(NavBar,{}),(0,r.jsx)(ErrorBoundary,{children:(0,r.jsxs)(l.xu,{p:0,overflow:"auto",flex:"1",style:{contain:"size"},children:[(0,r.jsx)(RouteAlwaysMount,{path:"/lineage",children:(0,r.jsx)(LineageView,{})}),(0,r.jsxs)(eF.rs,{children:[(0,r.jsx)(eF.AW,{path:"/query",children:(0,r.jsx)(QueryPage,{})}),(0,r.jsx)(eF.AW,{path:"/checks/:slug*",children:(0,r.jsx)(CheckPage,{})}),(0,r.jsx)(eF.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,r.jsx)(RunPage,{runId:n})}}),(0,r.jsx)(eF.AW,{path:"/ssr",children:(0,r.jsx)(r.Fragment,{children:"Loading"})}),(0,r.jsx)(eF.AW,{children:(0,r.jsx)(eF.l_,{to:"/lineage"})})]})]})})]})})})})})})}},88727:function(){},7866:function(){},75165:function(){}},function(e){e.O(0,[634,145,170,521,462,531,498,685,182,710,971,495,599,512,405,297,62,744],function(){return e(e.s=99178)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/recce/data/_next/static/KuSRJvWbFxUBbU9XQmDGM/_buildManifest.js b/recce/data/_next/static/lcS0p0b89tL3OsryBWzU2/_buildManifest.js similarity index 100% rename from recce/data/_next/static/KuSRJvWbFxUBbU9XQmDGM/_buildManifest.js rename to recce/data/_next/static/lcS0p0b89tL3OsryBWzU2/_buildManifest.js diff --git a/recce/data/_next/static/KuSRJvWbFxUBbU9XQmDGM/_ssgManifest.js b/recce/data/_next/static/lcS0p0b89tL3OsryBWzU2/_ssgManifest.js similarity index 100% rename from recce/data/_next/static/KuSRJvWbFxUBbU9XQmDGM/_ssgManifest.js rename to recce/data/_next/static/lcS0p0b89tL3OsryBWzU2/_ssgManifest.js diff --git a/recce/data/index.html b/recce/data/index.html index 08548f35..b0119dd4 100644 --- a/recce/data/index.html +++ b/recce/data/index.html @@ -1,4 +1,4 @@ -recce
Loading...
Loading
\ No newline at end of file + ){outline:none;box-shadow:none;}select::-ms-expand{display:none;}:root,:host{--chakra-vh:100vh;}@supports (height: -webkit-fill-available){:root,:host{--chakra-vh:-webkit-fill-available;}}@supports (height: -moz-fill-available){:root,:host{--chakra-vh:-moz-fill-available;}}@supports (height: 100dvh){:root,:host{--chakra-vh:100dvh;}}
Loading...
Loading
\ No newline at end of file diff --git a/recce/data/index.txt b/recce/data/index.txt index 57e0e17f..096ce08e 100644 --- a/recce/data/index.txt +++ b/recce/data/index.txt @@ -1,9 +1,9 @@ -0:["KuSRJvWbFxUBbU9XQmDGM",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L1",[null,"$L2"]]]] +0:["lcS0p0b89tL3OsryBWzU2",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L1",[null,"$L2"]]]] 3:HL["/_next/static/css/6d0611c21a82d0bb.css","style",{"crossOrigin":""}] 4:I[44813,[],""] 5:I[82593,[],""] 7:I[32658,[],""] -8:I[76625,["634","static/chunks/7c9ab469-732af37965d79ccf.js","145","static/chunks/fb2d5402-0ccc92fc728c2993.js","170","static/chunks/526a6206-7ccbd30e159c1652.js","521","static/chunks/607285b2-dadd48144d45dbcf.js","462","static/chunks/f6be744d-5973a409ea097354.js","531","static/chunks/f78b7092-70a7bf0d3a99067a.js","498","static/chunks/6af6e714-6003aba9c53d2dcd.js","685","static/chunks/030e0bea-59754f62ad2a287c.js","182","static/chunks/5e9a126f-da62af62011c0643.js","710","static/chunks/2d02f0f7-ed3b4e4daa7c5d22.js","971","static/chunks/49348413-7aacf235ca16afb9.js","495","static/chunks/6dc81886-a3fa8efdc3652e8f.js","599","static/chunks/c132bf7d-fca1bc3c8aa231eb.js","512","static/chunks/4b89641d-a80e6024cd2468dc.js","405","static/chunks/405-8f1ba692a3f04532.js","931","static/chunks/app/page-f175b9de49fe2892.js"],""] +8:I[76625,["634","static/chunks/7c9ab469-732af37965d79ccf.js","145","static/chunks/fb2d5402-0ccc92fc728c2993.js","170","static/chunks/526a6206-7ccbd30e159c1652.js","521","static/chunks/607285b2-dadd48144d45dbcf.js","462","static/chunks/f6be744d-5973a409ea097354.js","531","static/chunks/f78b7092-70a7bf0d3a99067a.js","498","static/chunks/6af6e714-6003aba9c53d2dcd.js","685","static/chunks/030e0bea-59754f62ad2a287c.js","182","static/chunks/5e9a126f-da62af62011c0643.js","710","static/chunks/2d02f0f7-ed3b4e4daa7c5d22.js","971","static/chunks/49348413-7aacf235ca16afb9.js","495","static/chunks/6dc81886-a3fa8efdc3652e8f.js","599","static/chunks/c132bf7d-fca1bc3c8aa231eb.js","512","static/chunks/4b89641d-a80e6024cd2468dc.js","405","static/chunks/405-8f1ba692a3f04532.js","931","static/chunks/app/page-1b2bb2b388afdc98.js"],""] 1:[null,["$","html",null,{"lang":"en","children":["$","body",null,{"suppressHydrationWarning":true,"children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":["$L6",["$","$L7",null,{"propsForComponent":{"params":{}},"Component":"$8","isStaticGeneration":true}],null],"segment":"__PAGE__"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/6d0611c21a82d0bb.css","precedence":"next","crossOrigin":""}]]}]}]}],null] 2:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"recce"}],["$","meta","3",{"name":"description","content":"Recce: a dbt tool"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}]] 6:null