\ 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-cadda951f70a213c.js b/recce/data/_next/static/chunks/app/page-7319610f7c824b99.js
similarity index 90%
rename from recce/data/_next/static/chunks/app/page-cadda951f70a213c.js
rename to recce/data/_next/static/chunks/app/page-7319610f7c824b99.js
index 77e531f1..f1e8d2ff 100644
--- a/recce/data/_next/static/chunks/app/page-cadda951f70a213c.js
+++ b/recce/data/_next/static/chunks/app/page-7319610f7c824b99.js
@@ -1 +1 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{99178:function(e,n,t){Promise.resolve().then(t.bind(t,69797))},69797:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Home}});var i=t(757),r=t(27869);function getNeighborSet(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=new Set,r={},dfs=(e,t)=>{if(t<0||void 0!==r[e]&&r[e]>=t)return;r[e]=t;let l=n(e);for(let e of l)dfs(e,t-1);i.add(e)};for(let n of e)dfs(n,t);return i}function buildDefaultLineageGraphSets(e,n){function buildAllLineageGraph(e,n){let t={},i={},buildNode=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,i]of Object.entries(e.parent_map)){t[n]=buildNode(n,"base");let i=e.nodes&&e.nodes[n];i&&(t[n].data.base=i,t[n].name=null==i?void 0:i.name,t[n].resourceType=null==i?void 0:i.resource_type,t[n].packageName=null==i?void 0:i.package_name)}for(let[e,i]of Object.entries(n.parent_map)){t[e]?t[e].from="both":t[e]=buildNode(e,"current");let i=n.nodes&&n.nodes[e];i&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==i?void 0:i.name,t[e].resourceType=null==i?void 0:i.resource_type,t[e].packageName=null==i?void 0:i.package_name)}for(let[n,r]of Object.entries(e.parent_map))for(let e of r){let r=t[n],l=t[e],o="".concat(e,"_").concat(n);i[o]={id:o,from:"base",parent:l,child:r};let a=i[o];r.parents[e]=a,l.children[n]=a}for(let[e,r]of Object.entries(n.parent_map))for(let n of r){let r=t[e],l=t[n],o="".concat(n,"_").concat(e);i[o]?i[o].from="both":i[o]={id:o,from:"current",parent:l,child:r};let a=i[o];r.parents[n]=a,l.children[e]=a}return{edges:i,nodes:t}}function buildChangedOnlyLineageGraph(e,n){let t={},i={};function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}let r=selectDownstream(e,n),l=selectUpstream(e,n,1),o=union(r,l);return Object.entries(e.nodes).forEach(e=>{let[n,i]=e;o.has(n)&&(t[n]=i)}),Object.entries(e.edges).forEach(e=>{let[n,t]=e;o.has(t.parent.id)&&o.has(t.child.id)&&(i[n]=t)}),{nodes:t,edges:i}}let{nodes:t,edges:i}=buildAllLineageGraph(e,n),r=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",r.push(n.id);else if("current"===n.from)n.changeStatus="added",r.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",r.push(n.id))}for(let[e,n]of Object.entries(i))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{all:{nodes:t,edges:i},changed:buildChangedOnlyLineageGraph({nodes:t,edges:i},r),modifiedSet:r,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=[],i=[];for(let[n,i]of Object.entries(e.nodes))t.push({id:i.id,position:{x:0,y:0},data:i,type:"customNode",targetPosition:r.Ly.Left,sourcePosition:r.Ly.Right});for(let[n,t]of Object.entries(e.edges))i.push({id:t.id,type:"customEdge",source:t.parent.id,target:t.child.id,data:t});return highlightPath(e,n,t,i,null)}function highlightPath(e,n,t,i,r){function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}let l=null!==r?union(selectUpstream(e,[r]),selectDownstream(e,[r])):getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children)),o=new Set(i.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=i.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 cleanUpSelectedNodes(e){let n=e.map(e=>({...e,data:{...e.data,isSelected:!1,action:void 0}}));return n}var l=t(10126),o=t(83172),a=t(55528),s=t(29330),c=t(17714),d=t(46543),u=t(76920),h=t(39668),m=t(83179),x=t(62648),f=t(43093),p=t(40312),g=t(7752),v=t(94410),j=t(23330),y=t(29985),C=t(42524),b=t(36700),k=t(10287),w=t(48950),S=t(27726),_=t(26187),R=t(23704),D=t(33710),T=t(93864),N=t.n(T);t(94570);var E=t(90593),L=t(11180),I=t(63240),M=t(54057);let z=L.Nbv,F=L.sFB,O=L.UGs,IconChanged=e=>(0,i.jsxs)("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 16 16",height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 11 a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"}),(0,i.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:""})]});function getIconForChangeStatus(e){return"added"===e?{color:"#1dce00",icon:z}:"removed"===e?{color:"#ff4444",icon:F}:"modified"===e?{color:"#ffa502",icon:O}:{color:"inherit",icon:void 0}}function getIconForResourceType(e){return"model"===e?{color:"#c0eafd",icon:I.Fn3}:"metric"===e?{color:"#ffe6ee",icon:M._MV}:"source"===e?{color:"#a6dda6",icon:I.i1q}:"exposure"===e?{color:"#ffe6ee",icon:M.n8P}:"semantic_model"===e?{color:"#fb8caf",icon:M.R1C}:"seed"===e?{color:"#a6dda6",icon:I.tWi}:{color:"inherit",icon:void 0}}t(88727);var A=t(19920),V=t(19103),P=t(95913),B=t(89042),q=t(80294),H=t(35537),K=t(10929),W=t(12218);let U=W.env.NEXT_PUBLIC_API_URL?W.env.NEXT_PUBLIC_API_URL:window.location.origin;var G=t(27471);let Q=K.default.create({baseURL:U}),J=new G.S;async function submitRun(e,n,t){let i=await Q.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait}),r=i.data;return r}async function waitRun(e,n){let t=await Q.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}}),i=t.data;return i}async function cancelRun(e){return await Q.post("/api/runs/".concat(e,"/cancel"))}async function submitRunFromCheck(e,n){let t=await Q.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait}),i=t.data;return i}async function searchRuns(e,n,t){let i=await Q.post("/api/runs/search",{type:e,params:n,limit:t});return i.data}async function submitRowCountDiff(e,n){return await submitRun("row_count_diff",e,n)}let Z={allRowCount:()=>["row_count"],rowCount:e=>["row_count",e],lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],run:e=>["runs",e]},X='select * from {{ ref("mymodel") }}',Y=(0,S.createContext)({sqlQuery:X,setSqlQuery:()=>{}});function RecceQueryContextProvider(e){let{children:n}=e,[t,r]=S.useState(X);return(0,i.jsx)(Y.Provider,{value:{setSqlQuery:r,sqlQuery:t},children:n})}let useRecceQueryContext=()=>(0,S.useContext)(Y),$=(0,S.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function RowCountStateContextProvider(e){let{children:n}=e,[t,r]=S.useState([]);return(0,i.jsx)($.Provider,{value:{isNodesFetching:t,setIsNodesFetching:r},children:n})}let useRowCountStateContext=()=>(0,S.useContext)($);async function models_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}}function models_useRowCountQueries(e){let[n,t]=(0,S.useState)(!1),i=(0,H.NL)(),{setIsNodesFetching:r}=useRowCountStateContext(),l=i.getQueriesData({queryKey:Z.allRowCount()}).filter(n=>{let[t,i]=n,[r,l]=t;return e.includes(l)}).map(e=>{let[n,t]=e,[i,r]=n;return{modelName:r,data:t}}),o=[];return e.forEach(e=>{let{data:n}=l.find(n=>n.modelName===e)||{data:void 0,modelName:e};void 0===n&&o.push(e)}),{isLoading:n,fetchFn:async function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=n&&n.skipCache?e:o;t(!0),r(l);let{runId:a,result:s}=await queryRowCount(l);return Object.keys(s).forEach(e=>{let n=s[e];i.setQueryData(Z.rowCount(e),{base:n.base,curr:n.curr})}),t(!1),r([]),a}}}var ee=t(44903),en=t(62516);function RowCountByCompare(e){let{rowCount:n}=e,t=null===n.base?-1:n.base,r=null===n.curr?-1:n.curr,l=null===t?"N/A":t,o=null===r?"N/A":r;return t===r?(0,i.jsx)(x.U,{children:(0,i.jsxs)(f.x,{children:[l," == ",o," rows"]})}):tt?(0,i.jsxs)(x.U,{children:[(0,i.jsx)(f.x,{children:l}),(0,i.jsx)(s.J,{as:B.ZBs,color:"red.500"}),(0,i.jsxs)(f.x,{children:[o," row"]})]}):void 0}function RowCountWiteRate(e){let{rowCount:n}=e,t=null===n.base?-1:n.base,r=null===n.curr?-1:n.curr;return t<=0||r<=0?(0,i.jsx)(RowCountByCompare,{rowCount:n}):t===r?(0,i.jsxs)(x.U,{children:[(0,i.jsxs)(f.x,{children:[r," rows"]}),(0,i.jsx)(s.J,{as:en.lxc,color:"gray.500"}),(0,i.jsx)(f.x,{color:"gray.500",children:"No Change"})]}):tmodels_queryModelRowCount(n.name),enabled:"model"===n.resourceType&&t}),m=h||l.includes(n.name),x=a||l.includes(n.name);function ProcessedRowCountTag(e){let{isLoading:n,rowCount:t}=e;return(0,i.jsx)(A.Sn,{children:(0,i.jsx)(V.N,{isLoaded:!n,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:(0,i.jsx)(ModelRowCount,{rowCount:t})})})}function UnprocessedRowCountTag(e){let{isInteractive:n,invokeFunction:t}=e;return n?(0,i.jsx)(P.h,{"aria-label":"Query Row Count",icon:(0,i.jsx)(q.j3i,{}),size:"xs",onClick:()=>{t()}}):(0,i.jsx)(s.J,{as:q.ebq})}if(!1===r&&!1===u&&!1===m)return null;let f="Query the number of row";if(m)f="Querying the number of row";else if(u){let e=(null==c?void 0:c.base)===null?"N/A":null==c?void 0:c.base,n=(null==c?void 0:c.curr)===null?"N/A":null==c?void 0:c.curr;f="".concat(e," -> ").concat(n," rows")}return(0,i.jsx)(o.u,{hasArrow:!0,label:f,openDelay:500,closeDelay:200,children:(0,i.jsxs)(A.Vp,{children:[(0,i.jsx)(A.AD,{as:B.SwK}),u||m?(0,i.jsx)(ProcessedRowCountTag,{isLoading:x,rowCount:c}):(0,i.jsx)(UnprocessedRowCountTag,{isInteractive:r,invokeFunction:d})]})})}var et=t(85036),ei=t(49294),er=t(46016);let ActionTag=e=>{let{node:n,action:t}=e,{status:r,skipReason:s,run:c}=t;if("pending"===r)return(0,i.jsx)(er.D,{size:"20px",value:0});if("skipped"===r)return(0,i.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.xu,{children:"Skipped"}),s&&(0,i.jsx)(o.u,{label:s,children:(0,i.jsx)(et.s,{})})]});if(!c)return(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px"});let{error:d,result:u,run_id:h,progress:m}=c;if("running"===r)return(null==m?void 0:m.percentage)===void 0?(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px"}):(0,i.jsx)(er.D,{size:"20px",value:(null==m?void 0:m.percentage)*100});if(d)return(0,i.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.xu,{children:"Error"}),s&&(0,i.jsx)(o.u,{label:d,children:(0,i.jsx)(ei.a,{})})]});if("value_diff"===c.type){let e=0;for(let n of u.data.data)n[2]<1&&e++;return(0,i.jsx)(A.Vp,{children:(0,i.jsx)(A.Sn,{children:(0,i.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,i.jsx)(A.Vp,{children:(0,i.jsx)(A.Sn,{children:(0,i.jsx)(ModelRowCount,{rowCount:e[n.name]})})})}return(0,i.jsx)(i.Fragment,{children:h})};function GraphNode(e){var n,t;let c,{data:d}=e,{isHighlighted:u,isSelected:h,resourceType:m,changeStatus:f}=d,p=(0,r.oR)(e=>e.transform[2]>.3),{icon:g}=getIconForResourceType(m),v="gray.400",j="solid";f&&(c=getIconForChangeStatus(f).icon,v=getIconForChangeStatus(f).color);let y=v,C=d.isSelected?"rgba(3, 102, 214, 0.5) 5px 5px 10px 3px":"unset",b=null==d?void 0:d.name;return(0,i.jsx)(o.u,{label:"model"===m?b:"".concat(b," (").concat(m,")"),placement:"top",children:(0,i.jsxs)(a.k,{width:"300px",_hover:{backgroundColor:p?"gray.100":v},borderColor:y,borderWidth:1,borderStyle:j,backgroundColor:p?"white":v,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,i.jsx)(a.k,{backgroundColor:v,padding:2,borderRightWidth:1,borderColor:y,borderStyle:j,alignItems:"top",visibility:p?"inherit":"hidden",children:(0,i.jsx)(s.J,{as:g})}),(0,i.jsxs)(a.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",children:[(0,i.jsxs)(a.k,{width:"100%",textAlign:"left",flex:"1",p:1,alignItems:"center",visibility:p?"inherit":"hidden",children:[(0,i.jsx)(l.xu,{flex:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:b}),c&&(0,i.jsx)(a.k,{children:(0,i.jsx)(s.J,{color:v,as:c,flex:"0 0 20px"})})]}),(0,i.jsx)(a.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:p?"inherit":"hidden",children:(0,i.jsxs)(x.U,{spacing:"8px",children:[(0,i.jsx)(E.L,{}),d.action?(0,i.jsx)(ActionTag,{node:d,action:d.action}):"model"===d.resourceType?(0,i.jsx)(RowCountTag,{node:d,isInteractive:!1}):(0,i.jsx)(i.Fragment,{})]})})]}),Object.keys(null!==(n=null==d?void 0:d.parents)&&void 0!==n?n:{}).length>0&&(0,i.jsx)(r.HH,{type:"target",position:r.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==d?void 0:d.children)&&void 0!==t?t:{}).length>0&&(0,i.jsx)(r.HH,{type:"source",position:r.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,r.OQ)({sourceX:n,sourceY:t,sourcePosition:a,targetX:l,targetY:o,targetPosition:s});return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(r.u5,{path:m,markerEnd:d,style:{...h,...c}})})}var el=t(67907),eo=t(74796),ea=t(79315),es=t(58909),ec=t(2593),ed=t(55344),eu=t(1726),eh=t(83622),em=t(21801),ex=t(29731),ef=t(18974);function mergeKeys(e,n){let t=[...e],i=[...n],r=[];for(;t.length>0&&i.length>0;)if(r.includes(t[0]))t.shift();else if(r.includes(i[0]))i.shift();else if(t[0]===i[0])r.push(t[0]),t.shift(),i.shift();else if(i.includes(t[0])){let e=i.indexOf(t[0]);for(let n=0;n{r.includes(e)||r.push(e)}),i.forEach(e=>{r.includes(e)||r.push(e)}),r}function mergeKeysWithStatus(e,n){let t=mergeKeys(e,n),i={};for(let r of t)e.includes(r)?n.includes(r)?i[r]=void 0:i[r]="removed":i[r]="added";let r={};e.forEach((e,n)=>{r[e]=n});let l=-1;for(let e of t){let n=r[e];void 0!==n&&(n>l?l=n:i[e]="reordered")}return i}function mergeColumns(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={},i=mergeKeysWithStatus(Object.keys(e),Object.keys(n));return Object.entries(i).forEach(e=>{let[n,i]=e;t[n]={name:n,reordered:"reordered"===i}}),Object.entries(e).map((e,n)=>{let[i,r]=e;t[i].baseIndex=n+1,t[i].baseType=r.type}),Object.entries(n).map((e,n)=>{let[i,r]=e;t[i].currentIndex=n+1,t[i].currentType=r.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 ep=t(93683),eg=t(7873),ev=t(52116),ej=t(47367),ey=t(55201),eC=t.n(ey),eb=t(15550);function useClipBoardToast(){let e=(0,eb.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})}}}let ek="ignore-screenshot";function useToBlob(e){let{imageType:n="png",backgroundColor:t=null,boardEffect:i=!0,shadowEffect:r=!1,borderStyle:l="solid 1px #ccc",borderRadius:o="10px",onSuccess:a,onError:s,ignoreElements:c}=e,[d,u]=(0,S.useState)("idle"),h=(0,S.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=i?l:"",e.style.borderRadius=i?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 eC()(e,{logging:!1,backgroundColor:null,ignoreElements:c});d.remove();let m=r?document.createElement("canvas"):h;if(r){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:r,toImage:l,ref:o}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:async e=>{try{await copyBlobToClipboard(e),n("Copied the query result as an image to clipboard")}catch(e){t("Failed to copy image to clipboard",e)}},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,i.jsx)(m.z,{size:"sm",leftIcon:(0,i.jsx)(ej.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:r,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()=>{o.current&&await l()},children:"Copy to Clipboard"})}return{ref:o,CopyToClipboardButton}}function ScreenshotDataGrid(e){let{enableScreenshot:n=!0,...t}=e,{ref:r,CopyToClipboardButton:l}=useCopyToClipboardButton();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ev.ZP,{ref:r,...t}),n&&(0,i.jsx)(l,{imageType:"png"})]})}var ew=t(99691);async function getLineage(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=await Q.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 ew.d7))return{error:null==e?void 0:e.message};{var n,t;let i=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(i)return{error:i};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 eS=t(21123),e_=t.n(eS);let eR=(0,S.createContext)({});function LineageWatcher(e){let{refetch:n}=e,t=(0,eb.p)(),[r,l]=(0,S.useState)(),o=(0,H.NL)();return(0,S.useEffect)(()=>{function httpUrlToWebSocketUrl(e){return e.replace(/(http)(s)?\:\/\//,"ws$2://")}let e=new WebSocket("".concat(httpUrlToWebSocketUrl(U),"/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:i}=n.event,[r,l]=i.split("/").slice(-2),a=e_().parse(l).name;t({description:"Detected ".concat(r," ").concat(a," ").concat(e),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),o.invalidateQueries({queryKey:Z.lineage()})}}catch(e){console.error(e)}},()=>{e&&e.close()}},[t,o]),(0,i.jsx)(i.Fragment,{})}function LineageGraphsContextProvider(e){let{children:n}=e,{data:t,isLoading:r,error:l,refetch:o}=(0,ee.a)({queryKey:Z.lineage(),queryFn:getLineageDiff}),a=(0,S.useMemo)(()=>{if(t)return buildDefaultLineageGraphSets(t.base,t.current)},[t]),s=(null==l?void 0:l.message)||(null==t?void 0:t.current_error)||(null==t?void 0:t.base_error);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(LineageWatcher,{refetch:o}),(0,i.jsx)(eR.Provider,{value:{lineageGraphSets:a,metadata:null==t?void 0:t.current.metadata,isDemoSite:!!(null==t?void 0:t.current.metadata.pr_url),error:s,isLoading:r},children:n})]})}let useLineageGraphsContext=()=>(0,S.useContext)(eR);function SchemaView(e){let n,t,{base:r,current:l,enableScreenshot:o=!1}=e,{columns:s,rows:c}=(0,S.useMemo)(()=>toDataGrid(mergeColumns(null==r?void 0:r.columns,null==l?void 0:l.columns)),[r,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=r&&void 0===r.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,i.jsxs)(a.k,{direction:"column",children:[n?(0,i.jsxs)(ep.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(eg.z,{}),n]}):t?(0,i.jsxs)(ep.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(eg.z,{}),t]}):(0,i.jsx)(i.Fragment,{}),c.length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:s,rows:c,className:"rdg-light",enableScreenshot:o})})]})}var eD=t(29357);function SqlDiffView(e){let{base:n,current:t}=e;return(0,i.jsx)(eD.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 eT=t(32865);async function createSimpleCheck(){let e=await Q.post("/api/checks",{type:"simple"}),n=e.data;return n}async function createLineageDiffCheck(e,n){let t=await Q.post("/api/checks",{type:"lineage_diff",params:{view_mode:e,node_ids:n}}),i=t.data;return i}async function createCheckByNodeSchema(e){let n=await Q.post("/api/checks",{type:"schema_diff",params:{node_id:e}}),t=n.data;return t}async function checks_createCheckByRun(e,n){let t=await Q.post("/api/checks",{run_id:e,view_options:n}),i=t.data;return i}async function listChecks(){let e=await Q.get("/api/checks");return e.data}async function getCheck(e){let n=await Q.get("/api/checks/".concat(e));return n.data}async function updateCheck(e,n){let t=await Q.patch("/api/checks/".concat(e),n);return t.data}async function deleteCheck(e){let n=await Q.delete("/api/checks/".concat(e));return n.data}async function reorderChecks(e){return await Q.post("/api/checks/reorder",e)}async function exportChecks(){let e=await Q.post("/api/checks/export");return e.data}async function loadChecks(e){let n=new FormData;n.append("file",e);let t=await Q.post("/api/checks/load",n);return t.data}var eN=t(78448),eE=t(93573);function ColumnNameCell(e){let{params:n,column:t,containerRef:r}=e,{runAction:o}=useRecceActionContext(),handleValueDiffDetail=(e,t)=>{let i={...n,...e};o("value_diff_detail",i,t)};return(0,i.jsxs)(a.k,{children:[(0,i.jsx)(l.xu,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(E.L,{}),(0,i.jsx)(b.v,{children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ef.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:P.h,icon:(0,i.jsx)(s.J,{as:L.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(eN.h,{containerRef:r,children:(0,i.jsx)(k.q,{lineHeight:"20px",children:(0,i.jsxs)(eE.k,{title:"Action",as:l.xu,fontSize:"8pt",children:[(0,i.jsx)(w.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({},{showForm:!0}),children:"Show mismatched values..."}),(0,i.jsxs)(w.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,r=n.params,cellClass=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},o=(0,S.useRef)(),c=[{key:"__is_pk__",name:"",maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,i.jsx)(u.M,{height:"100%",children:n[0]===r.primary_key&&(0,i.jsx)(s.J,{as:L.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,i.jsx)(ColumnNameCell,{column:n[t.key],params:r,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,r=t[n.key];return(0,i.jsx)(l.xu,{textAlign:"end",children:void 0!=r&&null!==r?"".concat((100*r).toFixed(2)," %"):"N/A"})},cellClass}];return(0,i.jsxs)(a.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",ref:o,children:[(0,i.jsxs)(l.xu,{px:"16px",children:["Model: ",r.model,", ",t.summary.total," total (",t.summary.total-t.summary.added-t.summary.removed," ","common, ",t.summary.added," added, ",t.summary.removed," removed)"]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:c,rows:t.data.data,defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})}var eL=t(41171),eI=t(53930),eM=t(25535),ez=t(51348),eF=t(11546),eO=t(83978),eA=t.n(eO);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),i=[];return n.forEach(e=>{i.some(n=>n.name===e.name)||i.push(e)}),t.forEach(e=>{i.some(n=>n.name===e.name)||i.push(e)}),i}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),i=[];return n.forEach(e=>{i.includes(e)||i.push(e)}),t.forEach(e=>{i.includes(e)||i.push(e)}),i}function ValueDiffForm(e){var n,t;let{params:r,onParamsChanged:l,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),[s,c]=(0,S.useState)(!r.columns||0===r.columns.length),d=null==r?void 0:r.model,u=eA().find(null===(n=a.lineageGraphSets)||void 0===n?void 0:n.all.nodes,{name:null==r?void 0:r.model}),m=(null==r?void 0:r.primary_key)||(null==u?void 0:null===(t=u.data.current)||void 0===t?void 0:t.primary_key);(0,S.useEffect)(()=>{o(!!m&&!!d)},[m,d,o]);let x=u?extractColumnNames(u):[];return(0,i.jsxs)(h.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Model"}),(0,i.jsx)(eM.I,{isReadOnly:!0,value:null==r?void 0:r.model})]}),(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Primary key"}),(0,i.jsx)(eF.Z,{placeholder:"Select primary key",value:m?{label:m,value:m}:void 0,options:(x||[]).map(e=>({label:e,value:e})),onChange:e=>{c(!0),l({...r,primary_key:(null==e?void 0:e.value)||"",columns:void 0})}})]}),(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Columns"}),(0,i.jsx)(ez.X,{marginBottom:"10px",isChecked:s,onChange:e=>{c(e.target.checked),l({...r,columns:void 0})},children:"All columns"}),!s&&(0,i.jsx)(eF.Z,{isMulti:!0,closeMenuOnSelect:!1,options:(x||[]).map(e=>({label:e,value:e})),value:(r.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{l({...r,columns:(e||[]).map(e=>e.value)})}})]})]})}function _getColumnMap(e,n){let t={},i=mergeKeysWithStatus(e.columns.map(e=>e.name),n.columns.map(e=>e.name));return Object.entries(i).map(i=>{let[r,l]=i;t[r]={status:l,baseColumnIndex:e.columns.findIndex(e=>e.name===r),currentColumnIndex:n.columns.findIndex(e=>e.name===r)}}),t}function _getPrimaryKeyIndexes(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function _getPrimaryKeyValue(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let r of n){let n=e[r];i[n.name]=t[r]}return JSON.stringify(i)}function DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&r&&(0,i.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?L.ven:L.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);r&&r(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];r&&r(e)}}),!h&&o&&(0,i.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?L.$kI:L.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,r=n[t.key];return(0,i.jsx)(i.Fragment,{children:"boolean"==typeof r?r.toString():r})};function toDataDiffGrid(e,n,t){let r=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(r,l),u={},h={},m=!1,x=!1;if(0===o.length)r.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(r.columns,o);r.data.forEach((n,t)=>{let i=_getPrimaryKeyValue(r.columns,e,n);i in u&&(m=!0),u[i]=n}),e=_getPrimaryKeyIndexes(l.columns,o),l.data.forEach((n,t)=>{let i=_getPrimaryKeyValue(l.columns,e,n);i in h&&(x=!0),h[i]=n})}let f=mergeKeysWithStatus(Object.keys(u),Object.keys(h)),p=Object.entries(f).map(e=>{let[n,t]=e,i=u[n],a=h[n],s=JSON.parse(n);if(i&&r.columns.forEach((e,n)=>{o.includes(e.name)||(s["base__".concat(e.name)]=i[n])}),a&&l.columns.forEach((e,n)=>{o.includes(e.name)||(s["current__".concat(e.name)]=a[n])}),i){if(a)for(let[e,n]of Object.entries(d))"index"===e||o.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eA().isEqual(i[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 r="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let i=t.status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eA().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:r,name:(0,i.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ev.Ug,headerCellClass:r,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,i.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,i=t.status||"";"index"===n||o.includes(n)||a.includes(n)||s&&"added"!==i&&"removed"!==i&&"modified"!==i||c.push(toColumn(n,i))}),{columns:c,rows:p,invalidPKeyBase:m,invalidPKeyCurrent:x}}function ProfileDiffResultView(e){var n;let{run:t,viewOptions:r,onViewOptionsChanged:l}=e,o=t.result;t.params;let a=(0,S.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),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",d=(0,S.useMemo)(()=>toDataDiffGrid(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[c],pinnedColumns:a,onPinnedColumnsChange:e=>{l&&l({...r,pinned_columns:e})}}),[o,c,a,r,l]);return 0===d.columns.length?(0,i.jsx)(u.M,{height:"100%",children:"No data"}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:d.columns,rows:d.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})}var eV=t(84680),eP=t(70556);let RunView=e=>{var n,t;let{isPending:r,isAborting:o,progress:s,error:c,run:d,onCancel:x,viewOptions:f,onViewOptionsChanged:p,RunResultView:g,children:v}=e;if(v&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!v&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");let j=(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==d?void 0:d.error);if(j)return(0,i.jsxs)(ep.b,{status:"error",children:[(0,i.jsx)(eg.z,{}),"Error: ",j]});if(r){let e=(null==s?void 0:s.message)?null==s?void 0:s.message:"Loading...";return(0,i.jsx)(u.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,i.jsxs)(h.g,{children:[(0,i.jsxs)(a.k,{alignItems:"center",children:[(null==s?void 0:s.percentage)===void 0||(null==s?void 0:s.percentage)===null?(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,i.jsx)(er.D,{size:"20px",value:100*s.percentage,mr:"8px"}),o?(0,i.jsx)(i.Fragment,{children:"Aborting..."}):(0,i.jsx)(i.Fragment,{children:e})]}),!o&&(0,i.jsx)(m.z,{onClick:x,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}return d?(0,i.jsxs)(l.xu,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(0,i.jsx)(g,{run:d,viewOptions:f,onViewOptionsChanged:p}),v&&v({run:d,viewOptions:f,onViewOptionsChanged:p})]}):(0,i.jsx)(u.M,{bg:"rgb(249,249,249)",height:"100%",children:"No data"})};var eB=t(48689);let RunModal=e=>{let{isOpen:n,onClose:t,type:r,title:o,params:s,initialRun:c,RunForm:d,RunResultView:u}=e,[,h]=(0,eT.TH)(),[x,f]=(0,S.useState)(),[p,b]=(0,S.useState)(s),[k,w]=(0,S.useState)(!1),[_,R]=(0,S.useState)(!1),[D,T]=(0,S.useState)(),[N,E]=(0,S.useState)(),[L,I]=(0,S.useState)(c),submitRunFn=async()=>{let{run_id:e}=await submitRun(r,p,{nowait:!0});for(f(e);;){let n=await waitRun(e,2);if(T(n.progress),n.result||n.error)return w(!1),T(void 0),n}},{data:M,mutate:z,reset:F,error:O,isPending:A}=(0,eP.D)({mutationFn:submitRunFn});(0,S.useEffect)(()=>{n&&void 0===d&&void 0===L&&z()},[n]);let V=(0,H.NL)(),P=(0,S.useCallback)(async()=>{if(w(!0),x)return await cancelRun(x)},[x]),B=(0,S.useCallback)(()=>{z()},[z]),q=(0,S.useCallback)(()=>{z(),I(void 0)},[z]),handleReset=()=>{w(!1),b(s),T(void 0),I(void 0),F()},K=(0,S.useCallback)(async()=>{let e=L?L.run_id:null==M?void 0:M.run_id;if(void 0===e)return;let n=await checks_createCheckByRun(e,N);V.invalidateQueries({queryKey:Z.checks()}),h("/checks/".concat(n.check_id))},[null==M?void 0:M.run_id,L,h,V,N]),handleClose=async()=>{t(),A&&x&&await cancelRun(x),handleReset()},W=!!(null==L?void 0:L.result)||!!(null==M?void 0:M.result),U=(null==L?void 0:L.run_at)?(0,eB.Z)(new Date(L.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(g.u_,{isOpen:n,onClose:handleClose,size:"6xl",scrollBehavior:"inside",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"75%",children:[(0,i.jsxs)(es.x,{children:[o,!M&&!A&&U&&(0,i.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:U})]}),(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:A||M||O||L?(0,i.jsx)(RunView,{isPending:A,isAborting:k,run:L||M,error:O,progress:D,onCancel:P,viewOptions:N,onViewOptionsChanged:E,RunResultView:u}):(0,i.jsx)(l.xu,{style:{contain:"layout"},children:d&&(0,i.jsx)(d,{params:p,onParamsChanged:b,setIsReadyToExecute:R})})}),(0,i.jsx)(eV.m,{children:(0,i.jsxs)(a.k,{gap:"10px",children:[W&&d&&(0,i.jsx)(m.z,{colorScheme:"blue",onClick:handleReset,children:"Reset"}),W&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(m.z,{colorScheme:"blue",onClick:K,children:"Add to checklist"})}),A&&(0,i.jsx)(m.z,{onClick:P,isDisabled:k,colorScheme:"blue",children:"Cancel"}),!W&&!A&&(0,i.jsx)(m.z,{isDisabled:A||!_,colorScheme:"blue",onClick:B,children:"Execute"}),W&&!d&&(0,i.jsx)(m.z,{colorScheme:"blue",onClick:q,children:"Rerun"})]})})]})]})};var eq=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 i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function valuediff_getPrimaryKeyValue(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let r of n){let n=e[r];i[n.name]=t[r]}return JSON.stringify(i)}function valuediff_DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&o&&(0,i.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?L.$kI:L.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,r=n[t.key];return(0,i.jsx)(i.Fragment,{children:"boolean"==typeof r?r.toString():r})};function toValueDiffGrid(e,n,t){let r=(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 i=valuediff_getPrimaryKeyValue(e.columns,d,n);n[u]&&(s[i]=n),n[h]&&(c[i]=n)});let m=mergeKeysWithStatus(Object.keys(s),Object.keys(c)),x=Object.entries(m).map(t=>{let[i,r]=t,l=s[i],o=c[i],d=JSON.parse(i);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))&&(eA().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 r="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let i=t.status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eA().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:r,name:(0,i.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"}]}};return n.forEach(e=>{let n=a[e].status||"";o.push({key:"".concat(e),name:(0,i.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),r.forEach(e=>{let t=a[e].status||"";n.includes(e)||o.push(toColumn(e,t))}),Object.entries(a).forEach(e=>{let[t,i]=e,a=i.status||"";"in_a"===t||"in_b"===t||n.includes(t)||r.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:r,onAddToChecklist:s,viewOptions:c,onViewOptionsChanged:d}=e,h=(0,S.useMemo)(()=>(null==c?void 0:c.changed_only)||!1,[c]),m=(0,S.useMemo)(()=>(null==c?void 0:c.pinned_columns)||[],[c]),x=(0,S.useMemo)(()=>{var e,n;if(!r.result)return{columns:[],rows:[]};let t=(null==r?void 0:null===(e=r.params)||void 0===e?void 0:e.primary_key)?[null==r?void 0:null===(n=r.params)||void 0===n?void 0:n.primary_key]:[];return toValueDiffGrid(null==r?void 0:r.result,t,{changedOnly:h,pinnedColumns:m,onPinnedColumnsChange:e=>{d&&d({...c,pinned_columns:e})}})},[r,c,h,m,d]);if(0===x.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});if(h&&0===x.rows.length)return(0,i.jsx)(u.M,{height:"100%",children:"No change"});let f=(null===(n=r.result)||void 0===n?void 0:n.limit)||0,p=f>0&&(null==r?void 0:null===(t=r.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,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:p?"orange.100":"inherit",children:[p&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",(0,i.jsx)(l.xu,{children:p})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),(0,i.jsx)(ez.X,{isChecked:null==c?void 0:c.changed_only,onChange:()=>{let e=!(null==c?void 0:c.changed_only);d&&d({...c,changed_only:e})},children:"Changed only"}),s&&(0,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>s(r)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:x.columns,rows:x.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};var eH=t(17180),eK=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 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 formatAsAbbreviatedNumber(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,i=n>=1e6,r=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(r||i||n>=1e3){let n={base:r?1e9:i?1e6:1e3,unit:r?"B":i?"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 eW=t(85670),eU=t(84021);function TopKSummaryList(e){let{topk:n,valids:t,isDisplayTopTen:r}=e,s=r?10:n.counts.length,c=n.counts.slice(0,s),d=t-c.reduce((e,n)=>e+n,0);return(0,i.jsx)(l.xu,{w:"100%",children:c.concat([d]).map((e,r)=>{let l=r===c.length,s=l?d:e,u=String(n.values[r]),h=l?"(others)":u||"(empty)",m=formatAsAbbreviatedNumber(s),x=formatIntervalMinMax(s/t);return(0,i.jsx)(S.Fragment,{children:!l||l&&s>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:3,children:[(0,i.jsx)(o.u,{label:h,placement:"start",children:(0,i.jsx)(f.x,{noOfLines:1,width:"14em",fontSize:"sm",color:l||0===u.length?"gray.400":"inherit",children:h})}),(0,i.jsx)(a.k,{height:"2em",width:"10em",children:(0,i.jsx)(CategoricalBarChart,{topkCount:s,topkLabel:h,valids:t})}),(0,i.jsx)(o.u,{label:m,placement:"start",children:(0,i.jsx)(f.x,{ml:5,mr:2,fontSize:"sm",width:"4em",noOfLines:1,children:m})}),(0,i.jsx)(o.u,{label:x,placement:"start",children:(0,i.jsx)(f.x,{color:"gray.400",fontSize:"sm",width:"4em",children:x})})]}),(0,i.jsx)(eH.i,{})]}):(0,i.jsx)(i.Fragment,{})},r)})})}function CategoricalBarChart(e){let{topkCount:n,topkLabel:t,valids:r,animation:l=!1}=e;eW.kL.register(eW.uw,eW.ZL,eW.f$);let o=getCatBarChartOptions(n,r,{animation:l}),a=getCatBarChartData({topkCount:n,topkLabel:t});return(0,i.jsx)(eU.$Q,{data:a,options:o,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}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:"#63B3ED",hoverBackgroundColor:"#002a53",borderWidth:1,borderColor:"#002a53",barPercentage:1,categoryPercentage:.6}]}}let ScreenshotBox=e=>{let{backgroundColor:n="white",blockSize:t,children:r,...o}=e,{ref:a,CopyToClipboardButton:s}=useCopyToClipboardButton({backgroundColor:n});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.xu,{ref:a,...o,overflow:"auto",children:(0,i.jsx)(l.xu,{backgroundColor:n,height:"100%",blockSize:t,children:r})}),(0,i.jsx)(s,{imageType:"png"})]})};function TopKDiffResultView(e){let{run:n}=e,[t,r]=(0,S.useState)(!0),o=n.result,s=n.params,c=o.base,d=o.current;return(0,i.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(ScreenshotBox,{blockSize:"auto",children:[(0,i.jsxs)(ea.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",children:["Model ",s.model,".",s.column_name]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(E.L,{}),(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Base"}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(TopKSummaryList,{topk:c,valids:c.valids||0,isDisplayTopTen:t})]}),(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Current"}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(TopKSummaryList,{topk:d,valids:d.valids||0,isDisplayTopTen:t})]}),(0,i.jsx)(E.L,{})]})]}),(0,i.jsx)(E.L,{}),(c.values.length>10||d.values.length>10)&&(0,i.jsx)(a.k,{p:5,justify:"start",children:(0,i.jsx)(eK.r,{onClick:()=>r(e=>!e),textColor:"blue.500",children:t?"View More Items":"View Only Top-10"})})]})}var eG=t(68665);function TopKDiffForm(e){var n;let{params:t,onParamsChanged:r,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eA().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,S.useEffect)(()=>{o(!!t.column_name)},[t,o]),(0,i.jsx)(l.xu,{m:"16px",children:(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Pick a column to show top-k"}),(0,i.jsx)(eG.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{let n=e.target.value;r({...t,column_name:n})},children:c.map(e=>(0,i.jsx)("option",{value:e,children:e},e))})]})})}function HistogramChart(e){let{data:n,hideAxis:t=!1,animation:r=!1}=e;eW.kL.register(eW.ZL,eW.RM,eW.f$,eW.uw,eW.u);let l=getHistogramChartOptions(n,t,{animation:r}),o=getHistogramChartData(n);return(0,i.jsx)(eU.kL,{type:"bar",options:l,data:o,plugins:[]})}function getHistogramChartData(e){let{histogram:n,type:t,binEdges:i}=e,{counts:r=[]}=n||{},l="datetime"===t?r.map((e,n)=>({x:i[n],y:e})):r,o=i.map((e,n)=>formatDisplayedBinItem(i,n)).slice(0,-1);return{labels:o,datasets:[{label:"counts",data:l,backgroundColor:"#63B3ED",borderColor:"#4299E1",hoverBackgroundColor:"#002A53",borderWidth:1,categoryPercentage:1,barPercentage:1,xAxisID:"x"}]}}function getHistogramChartOptions(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{histogram:i,type:r,samples:l=0,binEdges:o}=e,{counts:a=[]}=i||{},s="datetime"===r;return{responsive:!0,maintainAspectRatio:!1,plugins:{tooltip:{mode:"index",position:"nearest",intersect:!1,callbacks:{title(e){let[{dataIndex:n}]=e,t=formatDisplayedBinItem(o,n),i=formatIntervalMinMax(a[n]/l);return"".concat(s?"Date Range":"string"===r?"Text Length":"Value Range","\n").concat(t,"\n(").concat(i,")")}}}},scales:getScales(e,n),...t}}function getScales(e){let{histogram:n,min:t=0,max:i=0,type:r,binEdges:l}=e,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{counts:a=[]}=n||{},s=l.map((e,n)=>formatDisplayedBinItem(l,n)).slice(0,-1);return{x:"datetime"===r?{display:!o,type:"timeseries",min:t,max:i,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)=>s[n]}},y:{display:!o,type:"linear",max:Math.max(...a),border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return formatAsAbbreviatedNumber(e)}}}}}function formatDisplayedBinItem(e,n){let t=e[n],i=e[n+1],r=formatAsAbbreviatedNumber(t),l=formatAsAbbreviatedNumber(i),o="".concat(r," - ").concat(l);return o}function HistogramDiffResultView(e){var n,t,r,o,s,c,d;let{run:u}=e,h=u.params,m=null===(n=u.result)||void 0===n?void 0:n.base,f=null===(t=u.result)||void 0===t?void 0:t.current,p=null===(r=u.result)||void 0===r?void 0:r.min,g=null===(o=u.result)||void 0===o?void 0:o.max,v=null===(s=u.result)||void 0===s?void 0:s.bin_edges;return m&&f?(0,i.jsx)(a.k,{direction:"column",height:"500px",children:(0,i.jsxs)(ScreenshotBox,{height:"100%",children:[(0,i.jsxs)(ea.X,{as:"h1",size:"md",paddingTop:"4",textAlign:"center",children:["Model ",h.model,".",h.column_name]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(E.L,{}),(0,i.jsxs)(l.xu,{w:"40%",h:"300px",m:"4",children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Base"}),(0,i.jsx)(HistogramChart,{data:{type:(null===(c=u.params)||void 0===c?void 0:c.column_type)||"",histogram:m,min:p,max:g,samples:m.total,binEdges:v}})]}),(0,i.jsxs)(l.xu,{w:"40%",h:"300px",m:"4",children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Current"}),(0,i.jsx)(HistogramChart,{data:{type:(null===(d=u.params)||void 0===d?void 0:d.column_type)||"",histogram:f,min:p,max:g,samples:f.total,binEdges:v}})]}),(0,i.jsx)(E.L,{})]})]})}):(0,i.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:r,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eA().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,i.jsx)(l.xu,{m:"16px",children:(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Pick a column to show Histogram Diff"}),(0,i.jsx)(eG.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{var n;let i=e.target.value;o(!!i);let l=(null===(n=c.find(e=>e.name===i))||void 0===n?void 0:n.type)||"";r({...t,column_name:i,column_type:l})},children:c.map(e=>(0,i.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}let eQ=(0,S.createContext)({runAction:()=>{}}),eJ={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,eT.TH)();(0,S.useEffect)(()=>{e()},[e,n])};function RecceActionContextProvider(e){var n;let{children:t}=e,[r,l]=(0,S.useState)(),{isOpen:o,onOpen:a,onClose:s}=(0,c.q)(),d=(0,S.useCallback)(async(e,n,t)=>{let i;let r=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await searchRuns(e,n,1);1===t.length&&(i=t[0])}l({session:r,type:e,params:n,lastRun:i,options:t}),a()},[l,a]);return useCloseModalEffect(s),(0,i.jsxs)(eQ.Provider,{value:{runAction:d},children:[r&&eJ[r.type]&&(0,i.jsx)(RunModal,{isOpen:o,onClose:s,title:eJ[r.type].title,type:r.type,params:r.params,initialRun:r.lastRun,RunResultView:eJ[r.type].RunResultView,RunForm:(null===(n=r.options)||void 0===n?void 0:n.showForm)?eJ[r.type].RunForm:void 0},r.session),t]})}let useRecceActionContext=()=>(0,S.useContext)(eQ);function NodeView(e){let{node:n,onCloseNode:t}=e,[,r]=(0,eT.TH)(),{setSqlQuery:o}=useRecceQueryContext(),{fetchFn:s}=models_useRowCountQueries([n.name]),d="model"===n.resourceType||"seed"===n.resourceType||"source"===n.resourceType,{isOpen:u,onOpen:h,onClose:f}=(0,c.q)(),{runAction:p}=useRecceActionContext(),_=(0,S.useCallback)(async()=>{let e=n.id,t=await createCheckByNodeSchema(e);r("/checks/".concat(t.check_id))},[n,r]),R=(0,S.useCallback)(async()=>{let e=await s({skipCache:!0}),n=await checks_createCheckByRun(e);r("/checks/".concat(n.check_id))},[r,s]);return(0,i.jsxs)(eo.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(x.U,{children:[(0,i.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(ea.X,{size:"sm",children:n.name})}),(0,i.jsx)(E.L,{}),"modified"===n.changeStatus&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(m.z,{onClick:h,leftIcon:(0,i.jsx)(I.tvD,{}),colorScheme:"orange",variant:"solid",children:"Diff"}),(0,i.jsxs)(g.u_,{isOpen:u,onClose:f,size:"6xl",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(es.x,{children:"Model Raw Code Diff"}),(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{children:(0,i.jsx)(SqlDiffView,{base:n.data.base,current:n.data.current})})]})]})]}),(0,i.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,i.jsx)(ec.P,{onClick:t})})]}),(0,i.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,i.jsxs)(x.U,{spacing:"8px",children:[(0,i.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,i.jsx)(RowCountTag,{node:n})]})}),d&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(ed.m,{overflow:"auto",as:a.k,children:[(0,i.jsx)(eu.t,{children:(0,i.jsx)(eh.O,{children:"Columns"})}),(0,i.jsx)(em.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(ex.x,{p:0,overflowY:"auto",height:"100%",children:(0,i.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]}),(0,i.jsxs)(x.U,{p:"16px",children:[(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{as:m.z,size:"sm",colorScheme:"blue",children:"Add check"}),(0,i.jsxs)(k.q,{children:[(0,i.jsx)(w.s,{onClick:_,children:"Schema Check"}),(0,i.jsx)(w.s,{onClick:R,children:"Row Count Check"})]})]}),(0,i.jsx)(E.L,{}),"model"===n.resourceType&&(0,i.jsxs)(i.Fragment,{children:["added"!==n.changeStatus&&"removed"!==n.changeStatus&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{as:m.z,size:"sm",colorScheme:"blue",children:"Advanced Diffs"}),(0,i.jsxs)(k.q,{children:[(0,i.jsx)(w.s,{onClick:()=>{p("profile_diff",{model:n.name},{showForm:!1,showLast:!0})},children:"Profile Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("value_diff",{model:n.name},{showForm:!0,showLast:!0})},children:"Value Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("top_k_diff",{model:n.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("histogram_diff",{model:n.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})]})]})}),(0,i.jsx)(m.z,{colorScheme:"blue",size:"sm",onClick:()=>{o('select * from {{ ref("'.concat(n.name,'") }}')),r("/query")},children:"Query"})]})]})]})]})}let eZ={added:["Model Added","Added resource"],removed:["Model Removed","Removed resource"],modified:["Model Modified","Modified resource"],col_added:["Column Added","Added column"],col_removed:["Column Removed","Removed column"],col_changed:["Column Modified","Modified column"],folder_changed:["Modified","Modified folder"]};function ChangeSummary_getIconForChangeStatus(e){if("added"===e)return{color:"#1dce00",icon:z};if("removed"===e)return{color:"#ff067e",icon:F};if("modified"===e)return{color:"#ffa502",icon:O};if("col_added"===e)return{color:"#1dce00",icon:z};if("col_removed"===e)return{color:"#ff067e",icon:F};if("col_changed"===e)return{color:"#ffa502",icon:O};if("folder_changed"===e)return{color:"#ffa502",icon:IconChanged};return{color:"inherit",icon:void 0}}function SummaryText(e){let{name:n,value:t,tip:r}=e;return(0,i.jsxs)(h.g,{alignItems:"stretch",children:[(0,i.jsxs)(f.x,{fontSize:"sm",color:"gray",children:[n,r&&(0,i.jsx)(o.u,{label:r,children:(0,i.jsx)(l.xu,{display:"inline-block",children:(0,i.jsx)(s.J,{mx:"2px",as:B.H33,boxSize:3})})})]}),t]})}function ChangeStatusCountLabel(e){let{changeStatus:n,value:t}=e,[r]=n?eZ[n]:[""],{icon:l,color:o}=ChangeSummary_getIconForChangeStatus(n);return(0,i.jsxs)(h.g,{alignItems:"stretch",children:[(0,i.jsxs)(a.k,{alignItems:"center",fontSize:"sm",color:"gray",children:[(0,i.jsx)(s.J,{mr:"5px",as:l,color:o}),r]}),(0,i.jsx)(f.x,{fontSize:"sm",children:t})]})}function calculateColumnChange(e,n){let t=0,i=0,r=0;return(e||n)&&(n&&Object.keys(n.columns||{}).forEach(n=>{(!e||!e.columns||!e.columns[n])&&t++}),e&&Object.keys(e.columns||{}).forEach(e=>{(!n||!n.columns||!n.columns[e])&&i++}),n&&e&&Object.keys(n.columns||{}).forEach(t=>{e.columns&&n.columns&&e.columns[t]&&e.columns[t].type!==n.columns[t].type&&r++})),{adds:t,removes:i,modifies:r}}function calculateChangeSummary(e,n){let t=0,i=0,r=0,l=0,o=0,a=0;return n.forEach(n=>{"added"===e.nodes[n].changeStatus?t++:"removed"===e.nodes[n].changeStatus?i++:"modified"===e.nodes[n].changeStatus&&r++;let s=e.nodes[n].data.base,c=e.nodes[n].data.current,d=calculateColumnChange(s,c);l+=d.adds,o+=d.removes,a+=d.modifies}),{adds:t,removes:i,modifies:r,col_added:l,col_removed:o,col_changed:a}}function ChangeSummary(e){let{lineageGraphSets:n}=e,{adds:t,removes:r,modifies:o,col_added:a,col_removed:s,col_changed:c}=calculateChangeSummary(n.all,n.modifiedSet);return(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr",mb:"10px",borderTop:"1px solid lightgray",padding:"2.5vw",children:[(0,i.jsx)(l.xu,{borderColor:"lightgray",children:(0,i.jsx)(SummaryText,{name:"Code Changes",value:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr 1fr",width:"100%",children:[(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"added",value:t}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"removed",value:r}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"modified",value:o})]})})})}),(0,i.jsx)(l.xu,{borderLeft:"1px",paddingLeft:"12px",borderColor:"lightgray",children:(0,i.jsx)(SummaryText,{name:"Column Changes",value:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr 1fr",width:"100%",children:[(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_added",value:a}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_removed",value:s}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_changed",value:c})]})})})})]})}var eX=t(76353),eY=t(53248),e$=t(9763),e0=t(95853);function SchemaDiffCard(e){let{node:n,...t}=e;return(0,i.jsxs)(eX.Z,{maxWidth:"500px",children:[(0,i.jsxs)(eY.O,{children:[(0,i.jsx)(ea.X,{fontSize:18,children:t.title}),(0,i.jsxs)(x.U,{spacing:"8px",p:"16px",children:[(0,i.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,i.jsx)(RowCountTag,{node:n,isAutoFetching:!0})]})]}),(0,i.jsx)(e$.e,{children:(0,i.jsx)(a.k,{children:(0,i.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]})}function listChangedNodes(e){let n=[],t=e.all.nodes;return e.modifiedSet.forEach(e=>{var i,r;let l=t[e],o=mergeKeysWithStatus(Object.keys((null===(i=l.data.base)||void 0===i?void 0:i.columns)||{}),Object.keys((null===(r=l.data.current)||void 0===r?void 0:r.columns)||{})),a=!Object.values(o).every(e=>void 0===e);a&&l.data.base&&l.data.current&&n.push(l)}),n}function SchemaSummary(e){let{lineageGraphSets:n}=e,[t,r]=(0,S.useState)([]);return(0,S.useEffect)(()=>{r(listChangedNodes(n))},[n]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",marginTop:"20px",children:(0,i.jsx)(ea.X,{fontSize:24,children:"Schema Summary"})}),(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",children:0===t.length?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(f.x,{fontSize:18,color:"gray",children:"No schema changes detected."})}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(e0.M,{minChildWidth:"400px",spacing:"2vw",padding:"2.5vw",width:"100%",backgroundColor:"lightgray",children:t.map(e=>(0,i.jsx)(SchemaDiffCard,{title:e.name,node:e},e.id))})})})]})}function SummaryView(){let{lineageGraphSets:e}=useLineageGraphsContext();return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(a.k,{direction:"column",w:"100%",minHeight:"650px",children:[(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",children:(0,i.jsx)(ea.X,{fontSize:24,children:"Change Summary"})}),e&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ChangeSummary,{lineageGraphSets:e}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(SchemaSummary,{lineageGraphSets:e})]})]})})}var e1=t(45438),e2=t(72491),e5=t(52246),e3=t(25807),e6=t(15012);function AddSchemaChangesCheckButton(e){let{nodes:n,onFinish:t}=e,[,r]=(0,eT.TH)();return(0,i.jsxs)(m.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?r("/checks/".concat(e.check_id)):r("/checks")},children:[(0,i.jsx)(s.J,{as:q.Edg}),"Add schema check"]})}function AddLineageDiffCheckButton(e){let{viewMode:n,nodes:t,onFinish:r,withIcon:l}=e,[,o]=(0,eT.TH)();return(0,i.jsxs)(m.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:0===t.length,onClick:async()=>{let e=t.map(e=>e.id),i=await createLineageDiffCheck(n,e);r(),i?o("/checks/".concat(i.check_id)):o("/checks")},children:[l&&(0,i.jsx)(s.J,{as:e6.Ks7}),"Add lineage diff check"]})}function NodeSelector(e){var n,t,r,o;let{viewMode:a,nodes:c,onClose:d,onActionStarted:u,onActionNodeUpdated:h,onActionCompleted:f}=e,[p,g]=(0,S.useState)({mode:"per_node",status:"pending",completed:0,total:0}),v=(0,H.NL)(),[,j]=(0,eT.TH)(),submitRunForNodes=async(e,n,t)=>{let i="multi_nodes";p.mode=i,u(),p.status="running";let r=[];for(let e of c){let t=n(e);t?(e.action={mode:i,status:"skipped",skipReason:t},h(e)):(e.action={mode:i,status:"pending"},r.push(e))}let l=t(r);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 r)n.action={mode:i,status:t,run:e},h(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"},h(e);for(let i of(p.completed=0,p.total=c.length,c)){let{params:r,skipReason:l}=n(i);if(l)i.action={mode:t,status:"skipped",skipReason:l},h(i);else try{let{run_id:n}=await submitRun(e,r,{nowait:!0});for(p.currentRun={run_id:n},i.action={mode:t,status:"running"},h(i);;){let e=await waitRun(n,2);p.currentRun=e;let r=e.error?"failure":e.result?"success":"running";if(i.action={mode:t,status:r,run:e},h(i),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"},h(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 i=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;if(!i)return{skipReason:"No primary key found. The first unique column is used as primary key."};let r={model:e.name,primary_key:i};return{params:r}})},handleCancel=async()=>{var e;p.status="canceling",(null===(e=p.currentRun)||void 0===e?void 0:e.run_id)&&cancelRun(p.currentRun.run_id)},y=(0,S.useCallback)(async()=>{var e;let n=null===(e=p.currentRun)||void 0===e?void 0:e.run_id;if(!n)return;let t=await checks_createCheckByRun(n);v.invalidateQueries({queryKey:Z.checks()}),j("/checks/".concat(t.check_id))},[null===(n=p.currentRun)||void 0===n?void 0:n.run_id,j,v]);return(0,e2.z)(()=>{"running"===p.status&&handleCancel()}),(0,i.jsxs)(l.xu,{bg:"white",rounded:"md",shadow:"dark-lg",children:["pending"===p.status&&(0,i.jsxs)(x.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(e5.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.jsxs)(e3.h,{size:"xs",isAttached:!0,variant:"outline",rounded:"xs",onClick:d,children:[(0,i.jsxs)(m.z,{children:[c.length," selected"]}),(0,i.jsx)(P.h,{"aria-label":"Exit select Mode",icon:(0,i.jsx)(e1.D,{})})]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(AddSchemaChangesCheckButton,{nodes:c,onFinish:d}),(0,i.jsx)(AddLineageDiffCheckButton,{viewMode:a,nodes:c,onFinish:d,withIcon:!0})]}),(0,i.jsxs)(x.U,{children:[(0,i.jsxs)(m.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleRowCountDiffClick,children:[(0,i.jsx)(s.J,{as:B.SwK}),"Row count diff"]}),(0,i.jsxs)(m.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleValueDiffClick,children:[(0,i.jsx)(s.J,{as:e6.pRi}),"Value diff"]})]})]}),"pending"!==p.status&&(0,i.jsxs)(x.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(e5.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.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===(r=o.progress)||void 0===r?void 0:r.percentage)?"".concat(100*p.currentRun.progress.percentage,"%"):"completed"===p.status?"100%":"0%"," ","canceled"===p.status?" (canceled)":""]}),"running"===p.status||"canceling"===p.status?(0,i.jsx)(m.z,{size:"xs",variant:"outline",onClick:handleCancel,isLoading:"canceling"===p.status,loadingText:"Canceling",children:"Cancel"}):(0,i.jsxs)(x.U,{children:["multi_nodes"===p.mode&&(null===(t=p.currentRun)||void 0===t?void 0:t.result)&&(0,i.jsx)(m.z,{display:"none",size:"xs",variant:"outline",onClick:y,children:"Add to checklist"}),(0,i.jsx)(m.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||{},r=Object.keys(n.result||{}).map(e=>{let n=t[e],i=(null==n?void 0:n.base)||null,r=(null==n?void 0:n.curr)||null,l="No Change";return null!==i&&null!==r?l=ir?"- ".concat(Math.round((i-r)/i*100),"%"):"No Change":i===r?l="N/A":null===i?l="Added":null===r&&(l="Removed"),{name:e,base:null===i?"N/A":Number(i),current:null===r?"N/A":Number(r),delta:l}});return(0,i.jsx)(a.k,{direction:"column",children:Object.keys(t).length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.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:r,className:"rdg-light",enableScreenshot:!0})})})}function NodeRunView(e){var n,t,r,o,s,c,d,u;let{node:h,onCloseNode:f}=e,p=null===(n=h.action)||void 0===n?void 0:n.run,[,g]=(0,eT.TH)(),v=(0,H.NL)(),[j,y]=(0,S.useState)(),C=(0,S.useCallback)(async()=>{if(!(null==p?void 0:p.run_id))return;let e=await checks_createCheckByRun(p.run_id,j);v.invalidateQueries({queryKey:Z.checks()}),g("/checks/".concat(e.check_id))},[null==p?void 0:p.run_id,g,v,j]),b=(null===(r=h.action)||void 0===r?void 0:null===(t=r.run)||void 0===t?void 0:t.type)==="value_diff"?ValueDiffResultView:(null===(s=h.action)||void 0===s?void 0:null===(o=s.run)||void 0===o?void 0:o.type)==="row_count_diff"?RowCountDiffResultView:null;return(0,i.jsxs)(eo.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(x.U,{children:[(0,i.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(ea.X,{size:"sm",children:h.name})}),(0,i.jsx)(E.L,{}),(0,i.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,i.jsx)(ec.P,{onClick:f})})]}),(0,i.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,i.jsx)(x.U,{spacing:"8px",children:(0,i.jsx)(ResourceTypeTag,{node:h})})}),(0,i.jsxs)(ed.m,{overflow:"auto",as:a.k,children:[(0,i.jsx)(eu.t,{children:(0,i.jsx)(eh.O,{children:"Run"})}),(0,i.jsx)(em.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(ex.x,{p:0,overflowY:"auto",height:"100%",children:b?(0,i.jsx)(RunView,{run:null===(c=h.action)||void 0===c?void 0:c.run,viewOptions:j,onViewOptionsChanged:y,RunResultView:b}):(0,i.jsx)(l.xu,{p:"20px 10px",children:"No run result"})})})]}),(0,i.jsxs)(x.U,{p:"16px",children:[(0,i.jsx)(E.L,{}),(0,i.jsx)(m.z,{size:"sm",colorScheme:"blue",isDisabled:!(null===(u=h.action)||void 0===u?void 0:null===(d=u.run)||void 0===d?void 0:d.result),onClick:C,children:"Add to checklist"})]})]})}let layout=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",i=new(N()).graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:t}),e.forEach(e=>{i.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{i.setEdge(e.source,e.target)}),N().layout(i),e.forEach(e=>{let n=i.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})},e4={customNode:GraphNode},e9={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"},e8={all:"All",changed_models:"Changed Models"};function ChangeStatusLegend(){return(0,i.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,r]]=e,{icon:l,color:c}=getIconForChangeStatus(n);return(0,i.jsx)(o.u,{label:r,children:(0,i.jsxs)(a.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,i.jsx)(s.J,{color:c,as:l})," ",t]})},n)})})}function _LineageView(e){let{...n}=e,{fitView:t,setCenter:o,getZoom:T}=(0,r._K)(),{successToast:N,failToast:E}=useClipBoardToast(),{toImage:L,ref:I}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(ek))},onSuccess:async e=>{try{await copyBlobToClipboard(e),N("Copied the Lineage View as an image to clipboard")}catch(e){E("Failed to copy image to clipboard",e)}},onError:e=>{console.error("Error taking screenshot",e),E("Failed to copy image to clipboard",e)}}),[M,z,F]=(0,r.Rr)([]),[O,A,V]=(0,r.ll)([]),[P,q]=(0,S.useState)(),[H,K]=(0,S.useState)(),{lineageGraphSets:W,isLoading:U,error:G}=useLineageGraphsContext(),{isOpen:Q,onOpen:J,onClose:Z}=(0,c.q)(),[X,Y]=(0,S.useState)("detail"),[$,ee]=(0,S.useState)(),[en,et]=(0,S.useState)(!1),[ei,er]=(0,S.useState)(n.viewMode||"changed_models"),[eo,ea]=(0,S.useState)(!1),[es,ec]=(0,S.useState)({x:0,y:0});(0,S.useEffect)(()=>{if(!W)return;let e="changed_models"===ei?{...W.changed}:{...W.all},t=W.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,i]=e;return t(n,i)}))}let[i,r]=toReactflow(e,W.modifiedSet);layout(i,r),q(e),K(t),z(i),A(r)},[z,A,ei,W,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,i=T();o(n,t,{zoom:i,duration:200})}},ed=(0,S.useCallback)(e=>{z(n=>{let t=n.map(n=>n.id===e.id?{...n,data:e}:n);return t})},[z]);if(U)return(0,i.jsx)(a.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,i.jsx)(d.$,{size:"xl"})});let closeContextMenu=()=>{ea(!1),ec({x:0,y:0})};return G?(0,i.jsxs)(i.Fragment,{children:["Fail to load lineage data: ",G]}):"changed_models"===ei&&(void 0===H||(null==H?void 0:H.length)===0)?(0,i.jsx)(u.M,{h:"100%",children:(0,i.jsxs)(h.g,{children:[(0,i.jsx)(i.Fragment,{children:"No change detected"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>{er("all")},children:"Show all nodes"})]})}):(0,i.jsxs)(a.k,{width:"100%",height:"100%",children:[(0,i.jsx)(l.xu,{flex:"1 0 0px",children:(0,i.jsxs)(r.x$,{nodeTypes:e4,edgeTypes:e9,nodes:M,edges:O,onNodesChange:F,onEdgesChange:V,onNodeClick:(e,t)=>{!1!==n.interactive&&(closeContextMenu(),"detail"===X?(ee(t.data),en||et(!0),z(selectSingleNode(t.id,M)),centerNode(t)):"action_result"===X?(ee(t.data),en||et(!0),z(selectSingleNode(t.id,M)),centerNode(t)):z(selectNode(t.id,M)))},onNodeMouseEnter:(e,n)=>{if(P&&void 0!==H){let[e,t]=highlightPath(P,H,M,O,n.id);z(e),A(t)}},onNodeMouseLeave:(e,n)=>{if(P&&void 0!==H){let[e,n]=highlightPath(P,H,M,O,null);z(e),A(n)}},onNodeContextMenu:(e,n)=>{"action"===X&&(e.preventDefault(),ec({x:e.clientX,y:e.clientY,selectedNode:n}),ea(!0))},onClick:closeContextMenu,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:n.interactive,ref:I,children:[(0,i.jsx)(_.A,{color:"#ccc"}),(0,i.jsxs)(R.Z,{showInteractive:!1,position:"top-right",className:ek,children:[n.interactive&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(R.B,{title:"switch mode",onClick:()=>{er("all"===ei?"changed_models":"all");let e=cleanUpSelectedNodes(M);z(e)},children:(0,i.jsx)(s.J,{as:B.Bw1})}),(0,i.jsx)(R.B,{title:"summary",onClick:J,children:(0,i.jsx)(s.J,{as:B.SnF})})]}),(0,i.jsx)(R.B,{title:"copy image",onClick:()=>{L()},children:(0,i.jsx)(s.J,{as:B.C3L})})]}),(0,i.jsx)(r.s_,{position:"bottom-left",children:(0,i.jsxs)(x.U,{children:[(0,i.jsx)(ChangeStatusLegend,{}),n.interactive&&(0,i.jsxs)(l.xu,{p:2,flex:"0 1 160px",fontSize:"14px",className:ek,children:[(0,i.jsx)(f.x,{color:"gray",mb:"2px",children:"Actions"}),(0,i.jsxs)(h.g,{spacing:1,align:"baseline",children:[(0,i.jsx)(m.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:"detail"!==X,onClick:()=>{ee(void 0),et(!1);let e=cleanUpSelectedNodes(M);z(e),Y("detail"===X?"action":"detail")},children:"Select Models"}),(0,i.jsx)(AddLineageDiffCheckButton,{viewMode:ei,nodes:M.map(e=>e.data),onFinish:()=>Y("detail")})]})]})]})}),(0,i.jsx)(r.s_,{position:"top-left",children:(0,i.jsx)(f.x,{fontSize:"xl",color:"grey",opacity:.5,children:e8[ei]})}),(0,i.jsx)(r.s_,{position:"bottom-center",className:ek,children:(0,i.jsx)(p.R,{in:"detail"!==X,unmountOnExit:!0,style:{zIndex:10},children:(0,i.jsx)(NodeSelector,{viewMode:ei,nodes:M.map(e=>e.data).filter(e=>e.isSelected),onClose:()=>{Y("detail");let e=cleanUpSelectedNodes(M);ee(void 0),et(!1),z(e)},onActionStarted:()=>{Y("action_result")},onActionNodeUpdated:ed,onActionCompleted:()=>{}})})}),(0,i.jsx)(D.a,{nodeColor:nodeColor,nodeStrokeWidth:3})]})}),(0,i.jsxs)(g.u_,{isOpen:Q,onClose:Z,size:"6xl",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"80%",children:[(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{children:(0,i.jsx)(SummaryView,{})})]})]}),"detail"===X&&$&&(0,i.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(NodeView,{node:$,onCloseNode:()=>{ee(void 0),et(!1),z(cleanUpSelectedNodes(M))}})}),"action_result"===X&&$&&(0,i.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(NodeRunView,{node:$,onCloseNode:()=>{ee(void 0),et(!1)}})}),eo&&(0,i.jsx)(b.v,{isOpen:!0,onClose:closeContextMenu,children:(0,i.jsxs)(k.q,{style:{position:"absolute",left:"".concat(es.x,"px"),top:"".concat(es.y,"px")},children:[(0,i.jsx)(w.s,{icon:(0,i.jsx)(el.Cv2,{}),onClick:()=>{let e=es.selectedNode;if("action"!==X||void 0===e||void 0===P)return;let n=e.id,t=selectUpstream(P,[n]),i=selectNodes([...t],M);z(i)},children:"Select parent nodes"}),(0,i.jsx)(w.s,{icon:(0,i.jsx)(el.IMj,{}),onClick:()=>{let e=es.selectedNode;if("action"!==X||void 0===e||void 0===P)return;let n=e.id,t=selectDownstream(P,[n]),i=selectNodes([...t],M);z(i)},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,i.jsx)(r.tV,{children:(0,i.jsx)(_LineageView,{...n})})}var e7=t(12844),ne=t(98786);function RecceContextProvider(e){let{children:n}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(RecceQueryContextProvider,{children:(0,i.jsx)(LineageGraphsContextProvider,{children:(0,i.jsx)(RowCountStateContextProvider,{children:(0,i.jsx)(RecceActionContextProvider,{children:n})})})})})}function useVersionNumber(){let[e,n]=(0,S.useState)("");return(0,S.useEffect)(()=>{(async function(){try{let e=await Q.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}var nn=t(45489),nt=t(69005),ni=t(14800),nr=t(2600),nl=t(68677),no=t(83358),na=t(44525),ns=t(79935),nc=t(93197),nd=t(234),nu=t(96094),nh=t(36334);function CheckBreadcrumb(e){let{name:n,setName:t}=e,[r,o]=(0,S.useState)(!1),[a,s]=(0,S.useState)(n),c=(0,S.useRef)(null),d=(0,S.useCallback)(()=>{t(a),o(!1)},[t,o,a]);return(0,S.useEffect)(()=>{let handleClickOutside=e=>{c.current&&!c.current.contains(e.target)&&d()};return r&&document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[r,c,d]),(0,i.jsxs)(nd.a,{flex:"0 1",fontSize:"12pt",fontWeight:"500",separator:(0,i.jsx)(nh.X,{color:"gray.500"}),children:[(0,i.jsx)(nu.g,{children:(0,i.jsx)(l.xu,{children:"Checklist"})}),(0,i.jsx)(nu.g,{flex:"0 1",cursor:"pointer",children:r?(0,i.jsx)(eM.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,i.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(),r=n.params,l=r.node_id,o=l?null==t?void 0:t.all.nodes[l]:void 0;return o?(0,i.jsx)(SchemaView,{base:o.data.base,current:o.data.current,enableScreenshot:!0}):(0,i.jsx)(i.Fragment,{})}var nm=t(33695);function CheckDescription(e){let{value:n,onChange:t}=e,[r,l]=(0,S.useState)(!1),[o,s]=(0,S.useState)(),c=(0,S.useRef)(null);return((0,S.useEffect)(()=>{if(r&&c.current){let e=c.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[r]),r)?(0,i.jsxs)(a.k,{direction:"column",align:"flex-end",children:[(0,i.jsx)(nm.g,{h:"200px",value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&l(!1)},ref:c}),(0,i.jsxs)(a.k,{gap:"12px",alignItems:"flex-end",children:[(0,i.jsx)(eK.r,{onClick:()=>{setTimeout(()=>{l(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,i.jsx)(m.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:()=>{t&&(t(o),l(!1))},children:"Update"})]})]}):(0,i.jsx)(f.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 nx=t(48742);function _templateObject(){let e=(0,nn._)(["\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,nx.Pn)(_templateObject(),null===(n=e.params)||void 0===n?void 0:n.sql_template)}var query_SqlEditor=e=>{let{value:n,onChange:t,onRun:r,onRunDiff:l,options:o={},...a}=e;return(0,i.jsx)(eD.ZP,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{r&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,r),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:r=()=>{}}=e,o=t.includes(n);return(0,i.jsxs)(a.k,{className:"grid-header",alignItems:"center",children:[(0,i.jsx)(l.xu,{flex:1,children:n}),(0,i.jsx)(s.J,{className:o?"unpin-icon":"pin-icon",display:o?"block":"none",cursor:"pointer",as:o?L.$kI:L.oJP,onClick:o?()=>{let e=t.filter(e=>e!==n);r(e)}:()=>{let e=[...t,n];r(e)}})]})}function QueryResultView_toDataGrid(e,n){let t=[],r=n.pinnedColumns||[],toColumn=(e,t)=>({key:String(e),name:(0,i.jsx)(DataFrameColumnHeader,{name:t,...n}),width:"auto",renderCell:defaultRenderCell});return t.push({key:"_index",name:"",width:10,cellClass:"index-column"}),r.forEach(n=>{let i=eA().findIndex(e.columns,e=>e.name===n);i<0||t.push(toColumn(i,n))}),e.columns.forEach((e,n)=>{r.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:r,onAddToChecklist:s}=e,c=(0,S.useMemo)(()=>(null==t?void 0:t.pinned_columns)||[],[t]),d=null==n?void 0:n.result,h=(0,S.useMemo)(()=>d?QueryResultView_toDataGrid(d,{pinnedColumns:c,onPinnedColumnsChange:e=>{r&&r({...t,pinned_columns:e})}}):{rows:[],columns:[]},[d,c,t,r]);if(0===h.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});let m=(null==d?void 0:d.limit)||0,x=m>0&&(null==d?void 0:d.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,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(s||x)&&(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:x?"orange.100":"inherit",children:[x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ei.a,{color:"orange.600",alignSelf:"center"})," ",(0,i.jsx)(l.xu,{children:x})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),s&&(0,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>s(n)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},QueryDiffResultView=e=>{var n,t,r,s,c,d;let{run:m,onAddToChecklist:x,viewOptions:f,onViewOptionsChanged:p}=e,g=(0,S.useMemo)(()=>(null==f?void 0:f.primary_keys)||[],[f]),v=(0,S.useMemo)(()=>(null==f?void 0:f.changed_only)||!1,[f]),j=(0,S.useMemo)(()=>(null==f?void 0:f.pinned_columns)||[],[f]),y=(0,S.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:v,primaryKeys:g,onPrimaryKeyChange:e=>{p&&p({...f,primary_keys:e})},pinnedColumns:j,onPinnedColumnsChange:e=>{p&&p({...f,pinned_columns:e})}})},[m,f,v,g,j,p]),C=(0,S.useMemo)(()=>{let e=g.join(", ");return y.invalidPKeyBase&&y.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):y.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):y.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[y.invalidPKeyBase,y.invalidPKeyCurrent,g]);if(0===y.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});if(v&&0===y.rows.length)return(0,i.jsx)(u.M,{height:"100%",children:"No change"});let b=(null===(t=m.result)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.limit)||0,k=b>0&&((null==m?void 0:null===(s=m.result)||void 0===s?void 0:null===(r=s.current)||void 0===r?void 0:r.more)||(null==m?void 0:null===(d=m.result)||void 0===d?void 0:null===(c=d.base)||void 0===c?void 0:c.more))?"Warning: Displayed results are limited to ".concat(b.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:k||C?"orange.100":"inherit",children:[(0,i.jsxs)(h.g,{alignItems:"flex-start",spacing:0,children:[C&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",C]}),k&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",k]})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),(0,i.jsx)(ez.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,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>x(m)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:y.columns,rows:y.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};function LineageDiffView(e){var n;let{check:t}=e,r=(null===(n=t.params)||void 0===n?void 0:n.view_mode)||"";return(0,i.jsx)(a.k,{direction:"column",height:"100%",children:(0,i.jsx)(LineageView,{viewMode:r,interactive:!1,filterNodes:e=>{var n,i;return null===(i=t.params)||void 0===i?void 0:null===(n=i.node_ids)||void 0===n?void 0:n.includes(e)}})})}function CheckDetail_templateObject(){let e=(0,nn._)(["\n ","\n\n ","\n\n "]);return CheckDetail_templateObject=function(){return e},e}let nf={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:i}=e;(0,S.useEffect)(()=>()=>{i(!1),n&&t&&cancelRun(n)},[t,n,i])},CheckDetail=e=>{var n;let{checkId:t}=e,r=(0,H.NL)(),[,c]=(0,eT.TH)(),{successToast:d,failToast:h}=useClipBoardToast(),[x,f]=(0,S.useState)(),[p,g]=(0,S.useState)(),[v,j]=(0,S.useState)(!1),{isLoading:y,error:C,refetch:_,data:R}=(0,ee.a)({queryKey:Z.check(t),queryFn:async()=>getCheck(t),refetchOnMount:!1,staleTime:3e5}),D=R&&(null==R?void 0:R.type)in nf?nf[null==R?void 0:R.type]:void 0,{mutate:T}=(0,eP.D)({mutationFn:e=>updateCheck(t,e),onSuccess:()=>{r.invalidateQueries({queryKey:Z.check(t)}),r.invalidateQueries({queryKey:Z.checks()})}}),{mutate:N}=(0,eP.D)({mutationFn:()=>deleteCheck(t),onSuccess:()=>{r.invalidateQueries({queryKey:Z.checks()}),c("/checks")}}),submitRunFn=async()=>{let e=null==R?void 0:R.type;if(!e)return;let{run_id:n}=await submitRunFromCheck(t,{nowait:!0});for(f(n);;){let e=await waitRun(n,2);if(g(e.progress),e.result||e.error)return j(!1),g(void 0),e}},{data:I,mutate:M,error:z,isIdle:F,isPending:O}=(0,eP.D)({mutationFn:submitRunFn,onSuccess:e=>{_()}}),handleRerun=async()=>{M()},A=(0,S.useCallback)(async()=>{if(j(!0),x)return await cancelRun(x)},[x]);useCancelOnUnmount({runId:x,isPending:O,setAborting:j});let handleCopy=async()=>{if(!R)return;let e=buildMarkdown(R);if(!navigator.clipboard){h("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),d("Copied the check to the clipboard")}catch(e){h("Failed to copy the check to clipboard",e)}},V=(0,S.useCallback)(()=>{let e=null==R?void 0:R.is_checked;T({is_checked:!e})},[null==R?void 0:R.is_checked,T]);if(y)return(0,i.jsx)(u.M,{h:"100%",children:"Loading"});if(C)return(0,i.jsxs)(u.M,{h:"100%",children:["Error: ",C.message]});let B=F?null==R?void 0:R.last_run:I,q=(null==B?void 0:B.run_at)?(0,eB.Z)(new Date(B.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(a.k,{height:"100%",width:"100%",maxHeight:"100%",direction:"column",children:[(0,i.jsxs)(a.k,{p:"0px 16px",alignItems:"center",children:[(0,i.jsx)(CheckBreadcrumb,{name:(null==R?void 0:R.name)||"",setName:e=>{T({name:e})}}),(0,i.jsx)(E.L,{}),(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{isRound:!0,as:P.h,icon:(0,i.jsx)(s.J,{as:L.D_A}),variant:"ghost"}),(0,i.jsx)(k.q,{children:(0,i.jsx)(w.s,{icon:(0,i.jsx)(na.p,{}),onClick:()=>N(),children:"Delete"})})]}),q&&(0,i.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:q}),R&&(null==R?void 0:R.type)in nf&&(0,i.jsx)(o.u,{label:"Rerun",children:(0,i.jsx)(P.h,{isRound:!0,isLoading:O,variant:"ghost","aria-label":"Rerun",icon:(0,i.jsx)(ns.n,{}),onClick:()=>handleRerun()})}),(0,i.jsx)(o.u,{label:"Copy markdown",children:(0,i.jsx)(P.h,{isRound:!0,variant:"ghost","aria-label":"Copy markdown",icon:(0,i.jsx)(ej.T,{}),onClick:()=>handleCopy()})}),(0,i.jsx)(o.u,{label:(null==R?void 0:R.is_checked)?"Mark as unchecked":"Mark as checked",children:(0,i.jsx)(m.z,{size:"sm",colorScheme:(null==R?void 0:R.is_checked)?"green":"gray",leftIcon:(0,i.jsx)(nc.r,{}),onClick:()=>V(),children:(null==R?void 0:R.is_checked)?"Checked":"Unchecked"})})]}),(0,i.jsx)(l.xu,{p:"8px 16px",minHeight:"100px",children:(0,i.jsx)(CheckDescription,{value:null==R?void 0:R.description,onChange:e=>{T({description:e})}},null==R?void 0:R.check_id)}),((null==R?void 0:R.type)==="query"||(null==R?void 0:R.type)==="query_diff")&&(0,i.jsx)(nt.U,{defaultIndex:[],allowToggle:!0,children:(0,i.jsxs)(ni.Q,{children:[(0,i.jsxs)(nr.K,{children:["query",(0,i.jsx)(nl.X,{})]}),(0,i.jsx)(no.H,{children:(0,i.jsx)(l.xu,{height:"400px",width:"100%",border:"lightgray 1px solid ",children:(0,i.jsx)(query_SqlEditor,{value:(null===(n=null==R?void 0:R.params)||void 0===n?void 0:n.sql_template)||"",options:{readOnly:!0}})})})]})}),(0,i.jsxs)(l.xu,{style:{contain:"size"},flex:"1 1 0%",children:[D&&(0,i.jsx)(RunView,{isPending:O,isAborting:v,run:B,error:z,progress:p,RunResultView:D,viewOptions:null==R?void 0:R.view_options,onViewOptionsChanged:e=>{T({view_options:e})},onCancel:A}),R&&"schema_diff"===R.type&&(0,i.jsx)(SchemaDiffView,{check:R}),R&&"lineage_diff"===R.type&&(0,i.jsx)(LineageDiffView,{check:R})]})]})};function buildMarkdown(e){return(0,nx.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 np=t(79648),ng=t(38505);let ChecklistItem=e=>{let{check:n,selected:t,onSelect:r}=e,o=(0,H.NL)(),c=n.check_id,{mutate:d}=(0,eP.D)({mutationFn:e=>updateCheck(c,e),onSuccess:()=>{o.invalidateQueries({queryKey:Z.check(c)}),o.invalidateQueries({queryKey:Z.checks()})}}),u=(e=>{switch(e){case"schema_diff":return e6.uhn;case"query":case"query_diff":return e6.r2i;case"value_diff":return e6.pRi;case"profile_diff":return e6.KA6;case"row_count_diff":return B.SwK;case"lineage_diff":return e6.Ks7;case"top_k_diff":return np.Pkc;case"histogram_diff":return e6.dku;default:return e6.WzH}})(n.type);return(0,i.jsxs)(a.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"gray.200"},bg:t?"gray.100":"inherit",onClick:()=>r(n.check_id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:u}),(0,i.jsx)(l.xu,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n.name}),n.is_checked&&(0,i.jsx)(s.J,{color:"green",as:I.FJM})]})},CheckList=e=>{let{checks:n,selectedItem:t,onCheckSelected:r,onChecksReordered:l}=e;return(0,i.jsx)(ng.Z5,{onDragEnd:e=>{e.destination&&l(e.source.index,e.destination.index)},children:(0,i.jsx)(ng.bK,{droppableId:"checklist",children:e=>(0,i.jsxs)(h.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",children:[n.map((e,n)=>(0,i.jsx)(ng._l,{draggableId:e.check_id,index:n,children:n=>(0,i.jsx)(a.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,i.jsx)(ChecklistItem,{check:e,selected:e.check_id===t,onSelect:r},e.check_id)})},e.check_id)),e.placeholder]})})})};var nv=t(73672),nj=t(83561);function CheckListInitLoader(){let e=(0,eb.p)(),n=(0,H.NL)(),t=(0,S.useRef)(null),[r,l]=(0,S.useState)(null),o=(0,S.useCallback)(async()=>{if(r)try{let{checks:t}=await loadChecks(r);n.invalidateQueries({queryKey:Z.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,r]);return(0,S.useEffect)(()=>{r&&o()},[r,o]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(m.z,{onClick:()=>{t.current&&t.current.click()},children:"Load a checklist"}),(0,i.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,eb.p)(),n=(0,H.NL)(),t=(0,S.useRef)(null),r=(0,S.useRef)(null),[l,d]=(0,S.useState)(null),{isOpen:u,onOpen:h,onClose:x}=(0,c.q)(),p=(0,S.useCallback)(async()=>{if(l){try{let{checks:t}=await loadChecks(l);n.invalidateQueries({queryKey:Z.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})}x()}},[n,l,e,x]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o.u,{label:"Load checklist",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Load checks",mr:"10px",onClick:()=>{t.current&&t.current.click()},icon:(0,i.jsx)(s.J,{pt:"10px",as:nj._mA,boxSize:"2em"})})}),(0,i.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&&(d(e.target.files[0]),h())}}),(0,i.jsx)(nv.a,{isOpen:u,leastDestructiveRef:r,onClose:x,size:"lg",children:(0,i.jsx)(v.Z,{children:(0,i.jsxs)(nv._,{children:[(0,i.jsx)(es.x,{fontSize:"lg",fontWeight:"bold",children:"Load checklist"}),(0,i.jsx)(C.f,{children:(0,i.jsxs)(a.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,i.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(et.s,{color:"red.600"}),(0,i.jsx)(f.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,i.jsx)(a.k,{children:(0,i.jsxs)(f.x,{children:["The checklist will be"," ",(0,i.jsx)(f.x,{as:"span",fontWeight:"600",children:"overwritten"})," ","by the loaded checklist"]})})]})}),(0,i.jsxs)(eV.m,{children:[(0,i.jsx)(m.z,{ref:r,onClick:x,children:"Cancel"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:p,ml:"5px",children:"Load"})]})]})})})]})}var ny=t(472),nC=t(16062),nb=t(68686),nk=t.n(nb);function CheckListExporter(){let e=(0,eb.p)(),handleExport=async()=>{try{let e=await exportChecks(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),i=new Date,r="recce-state-".concat((0,nC.ZP)(i,"yyyy-MM-dd-HH-mm-ss"),".json");nk()(t,r)}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,i.jsx)(o.u,{label:"Export checklist",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Export checks",onClick:handleExport,icon:(0,i.jsx)(ny._,{})})})}function CheckPage_templateObject(){let e=(0,nn._)(["\n ","\n\n ","\n\n "]);return CheckPage_templateObject=function(){return e},e}let CheckPage=()=>{let{isDemoSite:e}=useLineageGraphsContext(),[,n]=(0,eT.TH)(),[,t]=(0,eT.yj)("/checks/:checkId"),r=(0,H.NL)(),{successToast:s,failToast:c}=useClipBoardToast(),d=null==t?void 0:t.checkId,{isLoading:f,error:p,data:g,status:v}=(0,ee.a)({queryKey:Z.checks(),queryFn:listChecks,refetchOnMount:!0}),j=(0,S.useCallback)(e=>{n("/checks/".concat(e))},[n]),[y,C]=(0,S.useState)(g||[]),{mutate:b}=(0,eP.D)({mutationFn:e=>reorderChecks(e),onSuccess:()=>{r.invalidateQueries({queryKey:Z.checks()})}}),k=(0,S.useCallback)((e,n)=>{let t=[...y],[i]=t.splice(e,1);t.splice(n,0,i),b({source:e,destination:n}),C(t)},[y,C,b]),w=(0,S.useCallback)(async()=>{let e=await createSimpleCheck();r.invalidateQueries({queryKey:Z.checks()}),j(e.check_id)},[r,j]);return((0,S.useEffect)(()=>{"success"===v&&(!d&&g.length>0&&n("/checks/".concat(g[0].check_id)),C(g))},[v,d,g,C,n]),f)?(0,i.jsx)(i.Fragment,{children:"Loading"}):p?(0,i.jsxs)(i.Fragment,{children:["Error: ",p.message]}):(null==g?void 0:g.length)?(0,i.jsxs)(a.k,{height:"100%",children:[(0,i.jsx)(l.xu,{flex:"0 0 400px",borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,i.jsxs)(h.g,{spacing:0,align:"flex-end",h:"100%",children:[(0,i.jsxs)(x.U,{gap:"0px",children:[(0,i.jsx)(o.u,{label:"Create a simple check",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Create a simple check",onClick:w,icon:(0,i.jsx)(eq.d,{})})}),(0,i.jsx)(o.u,{label:"Copy checklist to the clipboard",children:(0,i.jsx)(P.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,i.jsx)(ej.T,{})})}),!e&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(CheckListExporter,{}),(0,i.jsx)(CheckListLoader,{})]})]}),(0,i.jsx)(eH.i,{mb:"8px"}),(0,i.jsx)(CheckList,{checks:y,selectedItem:d,onCheckSelected:j,onChecksReordered:k})]})}),(0,i.jsx)(l.xu,{flex:"1",height:"100%",width:"calc(100% - 400px)",children:(0,i.jsx)(eT.rs,{children:(0,i.jsx)(eT.AW,{path:"/checks/:checkId",children:e=>(0,i.jsx)(CheckDetail,{checkId:e.checkId},e.checkId)})})})]}):(0,i.jsx)(u.M,{h:"100%",children:(0,i.jsxs)(h.g,{children:[(0,i.jsx)(l.xu,{children:"No checks"}),(0,i.jsxs)(a.k,{gap:"5",children:[(0,i.jsx)(m.z,{colorScheme:"blue",onClick:w,children:"Create a simple check"}),!e&&(0,i.jsx)(CheckListInitLoader,{})]})]})})};function CheckPage_buildMarkdown(e){let n=e.map(e=>(0,nx.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,r]=(0,S.useState)(),[o,s]=(0,S.useState)(),[c,d]=(0,S.useState)({}),u=(0,H.NL)(),[,h]=(0,eT.TH)(),queryFn=async n=>{r(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,eP.D)({mutationFn:queryFn,onSuccess:e=>{d({})}}),v=(0,S.useCallback)(async()=>{if(o)return await cancelRun(o)},[o]),j=(0,S.useCallback)(async e=>{if(!(null==e?void 0:e.run_id))return;let n=await checks_createCheckByRun(e.run_id,c);u.invalidateQueries({queryKey:Z.checks()}),h("/checks/".concat(n.check_id))},[h,c,u]);return!g&&(null==x?void 0:x.run_id)&&(null==x||x.error),(0,i.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(a.k,{justifyContent:"right",padding:"5px",gap:"5px",children:[(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>f("query_diff"),isDisabled:g,size:"sm",children:"Run Diff"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>f("query"),isDisabled:g,size:"sm",children:"Run"})]}),(0,i.jsx)(l.xu,{flex:"1",border:"1px solid #CBD5E0",height:"200px",width:"100%",children:(0,i.jsx)(query_SqlEditor,{value:e,onChange:n,onRun:()=>f("query"),onRunDiff:()=>f("query_diff")})}),(0,i.jsx)(a.k,{height:"50vh",direction:"column",children:"query"===t?(0,i.jsx)(RunView,{run:x,error:p,isPending:g,onCancel:v,children:e=>(0,i.jsx)(QueryResultView,{...e,onAddToChecklist:j})},o):(0,i.jsx)(RunView,{isPending:g,run:x,error:p,viewOptions:c,onViewOptionsChanged:d,onCancel:v,children:e=>(0,i.jsx)(QueryDiffResultView,{...e,onAddToChecklist:j})},o)})]})};var nw=t(72952);let hashNavigate=e=>(0,nw.c4)("#!"+e),useHashLocation=()=>{let e=(0,nw.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr");return[e,hashNavigate]};var nS=t(82017),n_=t(41546);let RunPage=e=>{let{runId:n}=e,{isPending:t,error:r,data:l}=(0,ee.a)({queryKey:Z.run(n),queryFn:async()=>waitRun(n)});return(0,i.jsx)(RunView,{isPending:t,error:r,run:l,RunResultView:ValueDiffResultView})};var nR=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,[r]=(0,eT.yj)(t);return(0,i.jsx)(l.xu,{display:r?"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,i.jsxs)(a.k,{gap:"5px",minHeight:"35px",alignItems:"center",justifyContent:"center",bg:"orange.300",children:[(0,i.jsx)(et.s,{color:"orange.600"}),(0,i.jsxs)(f.x,{children:["Please check"," ",(0,i.jsx)(eK.r,{textDecoration:"underline",fontWeight:"600",href:n,isExternal:!0,children:"this Pull Request"})," ","comment for context about this Recce instance"]})]}):(0,i.jsx)(i.Fragment,{})}function NavBar(){let[e,n]=(0,eT.TH)(),t=useVersionNumber(),r=[["Lineage","/lineage"],["Query","/query"],["Checklist","/checks"]],o=eA().findIndex(r,n=>{let[,t]=n;return e.startsWith(t)});return(0,i.jsx)(ed.m,{index:o,children:(0,i.jsxs)(eu.t,{children:[r.map(e=>{let[t,r]=e;return(0,i.jsx)(eh.O,{onClick:()=>{n(r)},children:t},t)}),(0,i.jsx)(l.xu,{position:"absolute",right:"0",top:"0",p:"2",color:"gray.500",children:t})]})})}function Home(){(0,S.useLayoutEffect)(()=>{let e=getCookie("recce_user_id");if(e&&nR.env.AMPLITUDE_API_KEY)try{ne.S1(nR.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,i.jsx)(n_.Z,{theme:e,children:(0,i.jsx)(e7.x,{children:(0,i.jsx)(H.aH,{client:J,children:(0,i.jsx)(eT.F0,{hook:useHashLocation,children:(0,i.jsx)(RecceContextProvider,{children:(0,i.jsxs)(a.k,{direction:"column",height:"100vh",children:[(0,i.jsx)(TopBar,{}),(0,i.jsx)(NavBar,{}),(0,i.jsxs)(l.xu,{p:0,overflow:"auto",flex:"1",style:{contain:"size"},children:[(0,i.jsx)(RouteAlwaysMount,{path:"/lineage",children:(0,i.jsx)(LineageView,{})}),(0,i.jsxs)(eT.rs,{children:[(0,i.jsx)(eT.AW,{path:"/query",children:(0,i.jsx)(QueryPage,{})}),(0,i.jsx)(eT.AW,{path:"/checks/:slug*",children:(0,i.jsx)(CheckPage,{})}),(0,i.jsx)(eT.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,i.jsx)(RunPage,{runId:n})}}),(0,i.jsx)(eT.AW,{path:"/ssr",children:(0,i.jsx)(i.Fragment,{children:"Loading"})}),(0,i.jsx)(eT.AW,{children:(0,i.jsx)(eT.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,103,297,62,744],function(){return e(e.s=99178)}),_N_E=e.O()}]);
\ No newline at end of file
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{99178:function(e,n,t){Promise.resolve().then(t.bind(t,69797))},69797:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Home}});var i=t(757),r=t(27869);function getNeighborSet(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=new Set,r={},dfs=(e,t)=>{if(t<0||void 0!==r[e]&&r[e]>=t)return;r[e]=t;let l=n(e);for(let e of l)dfs(e,t-1);i.add(e)};for(let n of e)dfs(n,t);return i}function buildDefaultLineageGraphSets(e,n){function buildAllLineageGraph(e,n){let t={},i={},buildNode=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,i]of Object.entries(e.parent_map)){t[n]=buildNode(n,"base");let i=e.nodes&&e.nodes[n];i&&(t[n].data.base=i,t[n].name=null==i?void 0:i.name,t[n].resourceType=null==i?void 0:i.resource_type,t[n].packageName=null==i?void 0:i.package_name)}for(let[e,i]of Object.entries(n.parent_map)){t[e]?t[e].from="both":t[e]=buildNode(e,"current");let i=n.nodes&&n.nodes[e];i&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==i?void 0:i.name,t[e].resourceType=null==i?void 0:i.resource_type,t[e].packageName=null==i?void 0:i.package_name)}for(let[n,r]of Object.entries(e.parent_map))for(let e of r){let r=t[n],l=t[e],o="".concat(e,"_").concat(n);i[o]={id:o,from:"base",parent:l,child:r};let a=i[o];r.parents[e]=a,l.children[n]=a}for(let[e,r]of Object.entries(n.parent_map))for(let n of r){let r=t[e],l=t[n],o="".concat(n,"_").concat(e);i[o]?i[o].from="both":i[o]={id:o,from:"current",parent:l,child:r};let a=i[o];r.parents[n]=a,l.children[e]=a}return{edges:i,nodes:t}}function buildChangedOnlyLineageGraph(e,n){let t={},i={};function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}let r=selectDownstream(e,n),l=selectUpstream(e,n,1),o=union(r,l);return Object.entries(e.nodes).forEach(e=>{let[n,i]=e;o.has(n)&&(t[n]=i)}),Object.entries(e.edges).forEach(e=>{let[n,t]=e;o.has(t.parent.id)&&o.has(t.child.id)&&(i[n]=t)}),{nodes:t,edges:i}}let{nodes:t,edges:i}=buildAllLineageGraph(e,n),r=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",r.push(n.id);else if("current"===n.from)n.changeStatus="added",r.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",r.push(n.id))}for(let[e,n]of Object.entries(i))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{all:{nodes:t,edges:i},changed:buildChangedOnlyLineageGraph({nodes:t,edges:i},r),modifiedSet:r,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=[],i=[];for(let[n,i]of Object.entries(e.nodes))t.push({id:i.id,position:{x:0,y:0},data:i,type:"customNode",targetPosition:r.Ly.Left,sourcePosition:r.Ly.Right});for(let[n,t]of Object.entries(e.edges))i.push({id:t.id,type:"customEdge",source:t.parent.id,target:t.child.id,data:t});return highlightPath(e,n,t,i,null)}function highlightPath(e,n,t,i,r){function union(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}let l=null!==r?union(selectUpstream(e,[r]),selectDownstream(e,[r])):getNeighborSet(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children)),o=new Set(i.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=i.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 cleanUpSelectedNodes(e){let n=e.map(e=>({...e,data:{...e.data,isSelected:!1,action:void 0}}));return n}var l=t(10126),o=t(83172),a=t(55528),s=t(29330),c=t(17714),d=t(46543),u=t(76920),h=t(39668),m=t(83179),x=t(62648),f=t(43093),p=t(40312),g=t(7752),v=t(94410),j=t(23330),y=t(29985),C=t(42524),b=t(36700),k=t(10287),w=t(48950),S=t(27726),_=t(26187),R=t(23704),D=t(33710),T=t(93864),N=t.n(T);t(94570);var E=t(90593),L=t(11180),I=t(63240),M=t(54057);let z=L.Nbv,F=L.sFB,O=L.UGs,IconChanged=e=>(0,i.jsxs)("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 16 16",height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 11 a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"}),(0,i.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:""})]});function getIconForChangeStatus(e){return"added"===e?{color:"#1dce00",icon:z}:"removed"===e?{color:"#ff4444",icon:F}:"modified"===e?{color:"#ffa502",icon:O}:{color:"inherit",icon:void 0}}function getIconForResourceType(e){return"model"===e?{color:"#c0eafd",icon:I.Fn3}:"metric"===e?{color:"#ffe6ee",icon:M._MV}:"source"===e?{color:"#a6dda6",icon:I.i1q}:"exposure"===e?{color:"#ffe6ee",icon:M.n8P}:"semantic_model"===e?{color:"#fb8caf",icon:M.R1C}:"seed"===e?{color:"#a6dda6",icon:I.tWi}:{color:"inherit",icon:void 0}}t(88727);var A=t(19920),V=t(19103),P=t(95913),B=t(89042),q=t(80294),H=t(35537),K=t(10929),W=t(12218);let U=W.env.NEXT_PUBLIC_API_URL?W.env.NEXT_PUBLIC_API_URL:window.location.origin;var G=t(27471);let Q=K.default.create({baseURL:U}),J=new G.S;async function submitRun(e,n,t){let i=await Q.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait}),r=i.data;return r}async function waitRun(e,n){let t=await Q.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}}),i=t.data;return i}async function cancelRun(e){return await Q.post("/api/runs/".concat(e,"/cancel"))}async function submitRunFromCheck(e,n){let t=await Q.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait}),i=t.data;return i}async function searchRuns(e,n,t){let i=await Q.post("/api/runs/search",{type:e,params:n,limit:t});return i.data}async function submitRowCountDiff(e,n){return await submitRun("row_count_diff",e,n)}let Z={allRowCount:()=>["row_count"],rowCount:e=>["row_count",e],lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],run:e=>["runs",e]},X='select * from {{ ref("mymodel") }}',Y=(0,S.createContext)({sqlQuery:X,setSqlQuery:()=>{}});function RecceQueryContextProvider(e){let{children:n}=e,[t,r]=S.useState(X);return(0,i.jsx)(Y.Provider,{value:{setSqlQuery:r,sqlQuery:t},children:n})}let useRecceQueryContext=()=>(0,S.useContext)(Y),$=(0,S.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function RowCountStateContextProvider(e){let{children:n}=e,[t,r]=S.useState([]);return(0,i.jsx)($.Provider,{value:{isNodesFetching:t,setIsNodesFetching:r},children:n})}let useRowCountStateContext=()=>(0,S.useContext)($);async function models_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}}function models_useRowCountQueries(e){let[n,t]=(0,S.useState)(!1),i=(0,H.NL)(),{setIsNodesFetching:r}=useRowCountStateContext(),l=i.getQueriesData({queryKey:Z.allRowCount()}).filter(n=>{let[t,i]=n,[r,l]=t;return e.includes(l)}).map(e=>{let[n,t]=e,[i,r]=n;return{modelName:r,data:t}}),o=[];return e.forEach(e=>{let{data:n}=l.find(n=>n.modelName===e)||{data:void 0,modelName:e};void 0===n&&o.push(e)}),{isLoading:n,fetchFn:async function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=n&&n.skipCache?e:o;t(!0),r(l);let{runId:a,result:s}=await queryRowCount(l);return Object.keys(s).forEach(e=>{let n=s[e];i.setQueryData(Z.rowCount(e),{base:n.base,curr:n.curr})}),t(!1),r([]),a}}}var ee=t(44903),en=t(62516);function RowCountByCompare(e){let{rowCount:n}=e,t=null===n.base?-1:n.base,r=null===n.curr?-1:n.curr,l=null===t?"N/A":t,o=null===r?"N/A":r;return t===r?(0,i.jsx)(x.U,{children:(0,i.jsxs)(f.x,{children:[l," == ",o," rows"]})}):tt?(0,i.jsxs)(x.U,{children:[(0,i.jsx)(f.x,{children:l}),(0,i.jsx)(s.J,{as:B.ZBs,color:"red.500"}),(0,i.jsxs)(f.x,{children:[o," row"]})]}):void 0}function RowCountWiteRate(e){let{rowCount:n}=e,t=null===n.base?-1:n.base,r=null===n.curr?-1:n.curr;return t<=0||r<=0?(0,i.jsx)(RowCountByCompare,{rowCount:n}):t===r?(0,i.jsxs)(x.U,{children:[(0,i.jsxs)(f.x,{children:[r," rows"]}),(0,i.jsx)(s.J,{as:en.lxc,color:"gray.500"}),(0,i.jsx)(f.x,{color:"gray.500",children:"No Change"})]}):tmodels_queryModelRowCount(n.name),enabled:"model"===n.resourceType&&t}),m=h||l.includes(n.name),x=a||l.includes(n.name);function ProcessedRowCountTag(e){let{isLoading:n,rowCount:t}=e;return(0,i.jsx)(A.Sn,{children:(0,i.jsx)(V.N,{isLoaded:!n,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:(0,i.jsx)(ModelRowCount,{rowCount:t})})})}function UnprocessedRowCountTag(e){let{isInteractive:n,invokeFunction:t}=e;return n?(0,i.jsx)(P.h,{"aria-label":"Query Row Count",icon:(0,i.jsx)(q.j3i,{}),size:"xs",onClick:()=>{t()}}):(0,i.jsx)(s.J,{as:q.ebq})}if(!1===r&&!1===u&&!1===m)return null;let f="Query the number of row";if(m)f="Querying the number of row";else if(u){let e=(null==c?void 0:c.base)===null?"N/A":null==c?void 0:c.base,n=(null==c?void 0:c.curr)===null?"N/A":null==c?void 0:c.curr;f="".concat(e," -> ").concat(n," rows")}return(0,i.jsx)(o.u,{hasArrow:!0,label:f,openDelay:500,closeDelay:200,children:(0,i.jsxs)(A.Vp,{children:[(0,i.jsx)(A.AD,{as:B.SwK}),u||m?(0,i.jsx)(ProcessedRowCountTag,{isLoading:x,rowCount:c}):(0,i.jsx)(UnprocessedRowCountTag,{isInteractive:r,invokeFunction:d})]})})}var et=t(85036),ei=t(49294),er=t(46016);let ActionTag=e=>{let{node:n,action:t}=e,{status:r,skipReason:s,run:c}=t;if("pending"===r)return(0,i.jsx)(er.D,{size:"20px",value:0});if("skipped"===r)return(0,i.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.xu,{children:"Skipped"}),s&&(0,i.jsx)(o.u,{label:s,children:(0,i.jsx)(et.s,{})})]});if(!c)return(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px"});let{error:d,result:u,run_id:h,progress:m}=c;if("running"===r)return(null==m?void 0:m.percentage)===void 0?(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px"}):(0,i.jsx)(er.D,{size:"20px",value:(null==m?void 0:m.percentage)*100});if(d)return(0,i.jsxs)(a.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.xu,{children:"Error"}),s&&(0,i.jsx)(o.u,{label:d,children:(0,i.jsx)(ei.a,{})})]});if("value_diff"===c.type){let e=0;for(let n of u.data.data)n[2]<1&&e++;return(0,i.jsx)(A.Vp,{children:(0,i.jsx)(A.Sn,{children:(0,i.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,i.jsx)(A.Vp,{children:(0,i.jsx)(A.Sn,{children:(0,i.jsx)(ModelRowCount,{rowCount:e[n.name]})})})}return(0,i.jsx)(i.Fragment,{children:h})};function GraphNode(e){var n,t;let c,{data:d}=e,{isHighlighted:u,isSelected:h,resourceType:m,changeStatus:f}=d,p=(0,r.oR)(e=>e.transform[2]>.3),{icon:g}=getIconForResourceType(m),v="gray.400",j="solid";f&&(c=getIconForChangeStatus(f).icon,v=getIconForChangeStatus(f).color);let y=v,C=d.isSelected?"rgba(3, 102, 214, 0.5) 5px 5px 10px 3px":"unset",b=null==d?void 0:d.name;return(0,i.jsx)(o.u,{label:"model"===m?b:"".concat(b," (").concat(m,")"),placement:"top",children:(0,i.jsxs)(a.k,{width:"300px",_hover:{backgroundColor:p?"gray.100":v},borderColor:y,borderWidth:1,borderStyle:j,backgroundColor:p?"white":v,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,i.jsx)(a.k,{backgroundColor:v,padding:2,borderRightWidth:1,borderColor:y,borderStyle:j,alignItems:"top",visibility:p?"inherit":"hidden",children:(0,i.jsx)(s.J,{as:g})}),(0,i.jsxs)(a.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",children:[(0,i.jsxs)(a.k,{width:"100%",textAlign:"left",flex:"1",p:1,alignItems:"center",visibility:p?"inherit":"hidden",children:[(0,i.jsx)(l.xu,{flex:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:b}),c&&(0,i.jsx)(a.k,{children:(0,i.jsx)(s.J,{color:v,as:c,flex:"0 0 20px"})})]}),(0,i.jsx)(a.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:p?"inherit":"hidden",children:(0,i.jsxs)(x.U,{spacing:"8px",children:[(0,i.jsx)(E.L,{}),d.action?(0,i.jsx)(ActionTag,{node:d,action:d.action}):"model"===d.resourceType?(0,i.jsx)(RowCountTag,{node:d,isInteractive:!1}):(0,i.jsx)(i.Fragment,{})]})})]}),Object.keys(null!==(n=null==d?void 0:d.parents)&&void 0!==n?n:{}).length>0&&(0,i.jsx)(r.HH,{type:"target",position:r.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==d?void 0:d.children)&&void 0!==t?t:{}).length>0&&(0,i.jsx)(r.HH,{type:"source",position:r.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,r.OQ)({sourceX:n,sourceY:t,sourcePosition:a,targetX:l,targetY:o,targetPosition:s});return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(r.u5,{path:m,markerEnd:d,style:{...h,...c}})})}var el=t(67907),eo=t(74796),ea=t(79315),es=t(58909),ec=t(2593),ed=t(55344),eu=t(1726),eh=t(83622),em=t(21801),ex=t(29731),ef=t(18974);function mergeKeys(e,n){let t=[...e],i=[...n],r=[];for(;t.length>0&&i.length>0;)if(r.includes(t[0]))t.shift();else if(r.includes(i[0]))i.shift();else if(t[0]===i[0])r.push(t[0]),t.shift(),i.shift();else if(i.includes(t[0])){let e=i.indexOf(t[0]);for(let n=0;n{r.includes(e)||r.push(e)}),i.forEach(e=>{r.includes(e)||r.push(e)}),r}function mergeKeysWithStatus(e,n){let t=mergeKeys(e,n),i={};for(let r of t)e.includes(r)?n.includes(r)?i[r]=void 0:i[r]="removed":i[r]="added";let r={};e.forEach((e,n)=>{r[e]=n});let l=-1;for(let e of t){let n=r[e];void 0!==n&&(n>l?l=n:i[e]="reordered")}return i}function mergeColumns(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={},i=mergeKeysWithStatus(Object.keys(e),Object.keys(n));return Object.entries(i).forEach(e=>{let[n,i]=e;t[n]={name:n,reordered:"reordered"===i}}),Object.entries(e).map((e,n)=>{let[i,r]=e;t[i].baseIndex=n+1,t[i].baseType=r.type}),Object.entries(n).map((e,n)=>{let[i,r]=e;t[i].currentIndex=n+1,t[i].currentType=r.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 ep=t(93683),eg=t(7873),ev=t(52116),ej=t(47367),ey=t(55201),eC=t.n(ey),eb=t(15550);function useClipBoardToast(){let e=(0,eb.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})}}}let ek="ignore-screenshot";function useToBlob(e){let{imageType:n="png",backgroundColor:t=null,boardEffect:i=!0,shadowEffect:r=!1,borderStyle:l="solid 1px #ccc",borderRadius:o="10px",onSuccess:a,onError:s,ignoreElements:c}=e,[d,u]=(0,S.useState)("idle"),h=(0,S.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=i?l:"",e.style.borderRadius=i?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 eC()(e,{logging:!1,backgroundColor:null,ignoreElements:c});d.remove();let m=r?document.createElement("canvas"):h;if(r){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:r,toImage:l,ref:o}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:async e=>{try{await copyBlobToClipboard(e),n("Copied the query result as an image to clipboard")}catch(e){t("Failed to copy image to clipboard",e)}},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,i.jsx)(m.z,{size:"sm",leftIcon:(0,i.jsx)(ej.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:r,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()=>{o.current&&await l()},children:"Copy to Clipboard"})}return{ref:o,CopyToClipboardButton}}function ScreenshotDataGrid(e){let{enableScreenshot:n=!0,...t}=e,{ref:r,CopyToClipboardButton:l}=useCopyToClipboardButton();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ev.ZP,{ref:r,...t}),n&&(0,i.jsx)(l,{imageType:"png"})]})}var ew=t(99691);async function getLineage(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=await Q.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 ew.d7))return{error:null==e?void 0:e.message};{var n,t;let i=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(i)return{error:i};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 eS=t(21123),e_=t.n(eS);let eR=(0,S.createContext)({});function LineageWatcher(e){let{refetch:n}=e,t=(0,eb.p)(),[r,l]=(0,S.useState)(),o=(0,H.NL)();return(0,S.useEffect)(()=>{function httpUrlToWebSocketUrl(e){return e.replace(/(http)(s)?\:\/\//,"ws$2://")}let e=new WebSocket("".concat(httpUrlToWebSocketUrl(U),"/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:i}=n.event,[r,l]=i.split("/").slice(-2),a=e_().parse(l).name;t({description:"Detected ".concat(r," ").concat(a," ").concat(e),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),o.invalidateQueries({queryKey:Z.lineage()})}}catch(e){console.error(e)}},()=>{e&&e.close()}},[t,o]),(0,i.jsx)(i.Fragment,{})}function LineageGraphsContextProvider(e){let{children:n}=e,{data:t,isLoading:r,error:l,refetch:o}=(0,ee.a)({queryKey:Z.lineage(),queryFn:getLineageDiff}),a=(0,S.useMemo)(()=>{if(t)return buildDefaultLineageGraphSets(t.base,t.current)},[t]),s=(null==l?void 0:l.message)||(null==t?void 0:t.current_error)||(null==t?void 0:t.base_error);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(LineageWatcher,{refetch:o}),(0,i.jsx)(eR.Provider,{value:{lineageGraphSets:a,metadata:null==t?void 0:t.current.metadata,isDemoSite:!!(null==t?void 0:t.current.metadata.pr_url),error:s,isLoading:r},children:n})]})}let useLineageGraphsContext=()=>(0,S.useContext)(eR);function SchemaView(e){let n,t,{base:r,current:l,enableScreenshot:o=!1}=e,{columns:s,rows:c}=(0,S.useMemo)(()=>toDataGrid(mergeColumns(null==r?void 0:r.columns,null==l?void 0:l.columns)),[r,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=r&&void 0===r.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,i.jsxs)(a.k,{direction:"column",children:[n?(0,i.jsxs)(ep.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(eg.z,{}),n]}):t?(0,i.jsxs)(ep.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(eg.z,{}),t]}):(0,i.jsx)(i.Fragment,{}),c.length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:s,rows:c,className:"rdg-light",enableScreenshot:o})})]})}var eD=t(29357);function SqlDiffView(e){let{base:n,current:t}=e;return(0,i.jsx)(eD.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 eT=t(32865);async function createSimpleCheck(){let e=await Q.post("/api/checks",{type:"simple"}),n=e.data;return n}async function createLineageDiffCheck(e,n){let t=await Q.post("/api/checks",{type:"lineage_diff",params:{view_mode:e,node_ids:n}}),i=t.data;return i}async function createCheckByNodeSchema(e){let n=await Q.post("/api/checks",{type:"schema_diff",params:{node_id:e}}),t=n.data;return t}async function checks_createCheckByRun(e,n){let t=await Q.post("/api/checks",{run_id:e,view_options:n}),i=t.data;return i}async function listChecks(){let e=await Q.get("/api/checks");return e.data}async function getCheck(e){let n=await Q.get("/api/checks/".concat(e));return n.data}async function updateCheck(e,n){let t=await Q.patch("/api/checks/".concat(e),n);return t.data}async function deleteCheck(e){let n=await Q.delete("/api/checks/".concat(e));return n.data}async function reorderChecks(e){return await Q.post("/api/checks/reorder",e)}async function exportChecks(){let e=await Q.post("/api/checks/export");return e.data}async function loadChecks(e){let n=new FormData;n.append("file",e);let t=await Q.post("/api/checks/load",n);return t.data}var eN=t(78448),eE=t(93573);function ColumnNameCell(e){let{params:n,column:t,containerRef:r}=e,{runAction:o}=useRecceActionContext(),handleValueDiffDetail=(e,t)=>{let i={...n,...e};o("value_diff_detail",i,t)};return(0,i.jsxs)(a.k,{children:[(0,i.jsx)(l.xu,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(E.L,{}),(0,i.jsx)(b.v,{children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ef.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:P.h,icon:(0,i.jsx)(s.J,{as:L.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(eN.h,{containerRef:r,children:(0,i.jsx)(k.q,{lineHeight:"20px",children:(0,i.jsxs)(eE.k,{title:"Action",as:l.xu,fontSize:"8pt",children:[(0,i.jsx)(w.s,{fontSize:"10pt",onClick:()=>handleValueDiffDetail({},{showForm:!0}),children:"Show mismatched values..."}),(0,i.jsxs)(w.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,r=n.params,cellClass=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},o=(0,S.useRef)(),c=[{key:"__is_pk__",name:"",maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,i.jsx)(u.M,{height:"100%",children:n[0]===r.primary_key&&(0,i.jsx)(s.J,{as:L.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,i.jsx)(ColumnNameCell,{column:n[t.key],params:r,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,r=t[n.key];return(0,i.jsx)(l.xu,{textAlign:"end",children:void 0!=r&&null!==r?"".concat((100*r).toFixed(2)," %"):"N/A"})},cellClass}];return(0,i.jsxs)(a.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",ref:o,children:[(0,i.jsxs)(l.xu,{px:"16px",children:["Model: ",r.model,", ",t.summary.total," total (",t.summary.total-t.summary.added-t.summary.removed," ","common, ",t.summary.added," added, ",t.summary.removed," removed)"]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:c,rows:t.data.data,defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})}var eL=t(41171),eI=t(53930),eM=t(25535),ez=t(51348),eF=t(11546),eO=t(83978),eA=t.n(eO);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),i=[];return n.forEach(e=>{i.some(n=>n.name===e.name)||i.push(e)}),t.forEach(e=>{i.some(n=>n.name===e.name)||i.push(e)}),i}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),i=[];return n.forEach(e=>{i.includes(e)||i.push(e)}),t.forEach(e=>{i.includes(e)||i.push(e)}),i}function ValueDiffForm(e){var n,t;let{params:r,onParamsChanged:l,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),[s,c]=(0,S.useState)(!r.columns||0===r.columns.length),d=null==r?void 0:r.model,u=eA().find(null===(n=a.lineageGraphSets)||void 0===n?void 0:n.all.nodes,{name:null==r?void 0:r.model}),m=(null==r?void 0:r.primary_key)||(null==u?void 0:null===(t=u.data.current)||void 0===t?void 0:t.primary_key);(0,S.useEffect)(()=>{o(!!m&&!!d)},[m,d,o]);let x=u?extractColumnNames(u):[];return(0,i.jsxs)(h.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Model"}),(0,i.jsx)(eM.I,{isReadOnly:!0,value:null==r?void 0:r.model})]}),(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Primary key"}),(0,i.jsx)(eF.Z,{placeholder:"Select primary key",value:m?{label:m,value:m}:void 0,options:(x||[]).map(e=>({label:e,value:e})),onChange:e=>{c(!0),l({...r,primary_key:(null==e?void 0:e.value)||"",columns:void 0})}})]}),(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Columns"}),(0,i.jsx)(ez.X,{marginBottom:"10px",isChecked:s,onChange:e=>{c(e.target.checked),l({...r,columns:void 0})},children:"All columns"}),!s&&(0,i.jsx)(eF.Z,{isMulti:!0,closeMenuOnSelect:!1,options:(x||[]).map(e=>({label:e,value:e})),value:(r.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{l({...r,columns:(e||[]).map(e=>e.value)})}})]})]})}function _getColumnMap(e,n){let t={},i=mergeKeysWithStatus(e.columns.map(e=>e.name),n.columns.map(e=>e.name));return Object.entries(i).map(i=>{let[r,l]=i;t[r]={status:l,baseColumnIndex:e.columns.findIndex(e=>e.name===r),currentColumnIndex:n.columns.findIndex(e=>e.name===r)}}),t}function _getPrimaryKeyIndexes(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function _getPrimaryKeyValue(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let r of n){let n=e[r];i[n.name]=t[r]}return JSON.stringify(i)}function DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&r&&(0,i.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?L.ven:L.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);r&&r(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];r&&r(e)}}),!h&&o&&(0,i.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?L.$kI:L.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,r=n[t.key];return(0,i.jsx)(i.Fragment,{children:"boolean"==typeof r?r.toString():r})};function toDataDiffGrid(e,n,t){let r=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(r,l),u={},h={},m=!1,x=!1;if(0===o.length)r.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(r.columns,o);r.data.forEach((n,t)=>{let i=_getPrimaryKeyValue(r.columns,e,n);i in u&&(m=!0),u[i]=n}),e=_getPrimaryKeyIndexes(l.columns,o),l.data.forEach((n,t)=>{let i=_getPrimaryKeyValue(l.columns,e,n);i in h&&(x=!0),h[i]=n})}let f=mergeKeysWithStatus(Object.keys(u),Object.keys(h)),p=Object.entries(f).map(e=>{let[n,t]=e,i=u[n],a=h[n],s=JSON.parse(n);if(i&&r.columns.forEach((e,n)=>{o.includes(e.name)||(s["base__".concat(e.name)]=i[n])}),a&&l.columns.forEach((e,n)=>{o.includes(e.name)||(s["current__".concat(e.name)]=a[n])}),i){if(a)for(let[e,n]of Object.entries(d))"index"===e||o.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eA().isEqual(i[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 r="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let i=t.status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eA().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:r,name:(0,i.jsx)(DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ev.Ug,headerCellClass:r,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,i.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,i=t.status||"";"index"===n||o.includes(n)||a.includes(n)||s&&"added"!==i&&"removed"!==i&&"modified"!==i||c.push(toColumn(n,i))}),{columns:c,rows:p,invalidPKeyBase:m,invalidPKeyCurrent:x}}function ProfileDiffResultView(e){var n;let{run:t,viewOptions:r,onViewOptionsChanged:l}=e,o=t.result;t.params;let a=(0,S.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),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",d=(0,S.useMemo)(()=>toDataDiffGrid(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[c],pinnedColumns:a,onPinnedColumnsChange:e=>{l&&l({...r,pinned_columns:e})}}),[o,c,a,r,l]);return 0===d.columns.length?(0,i.jsx)(u.M,{height:"100%",children:"No data"}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:d.columns,rows:d.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})}var eV=t(84680),eP=t(70556);let RunView=e=>{var n,t;let{isPending:r,isAborting:o,progress:s,error:c,run:d,onCancel:x,viewOptions:f,onViewOptionsChanged:p,RunResultView:g,children:v}=e;if(v&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!v&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");let j=(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==d?void 0:d.error);if(j)return(0,i.jsxs)(ep.b,{status:"error",children:[(0,i.jsx)(eg.z,{}),"Error: ",j]});if(r){let e=(null==s?void 0:s.message)?null==s?void 0:s.message:"Loading...";return(0,i.jsx)(u.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,i.jsxs)(h.g,{children:[(0,i.jsxs)(a.k,{alignItems:"center",children:[(null==s?void 0:s.percentage)===void 0||(null==s?void 0:s.percentage)===null?(0,i.jsx)(er.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,i.jsx)(er.D,{size:"20px",value:100*s.percentage,mr:"8px"}),o?(0,i.jsx)(i.Fragment,{children:"Aborting..."}):(0,i.jsx)(i.Fragment,{children:e})]}),!o&&(0,i.jsx)(m.z,{onClick:x,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}return d?(0,i.jsxs)(l.xu,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(0,i.jsx)(g,{run:d,viewOptions:f,onViewOptionsChanged:p}),v&&v({run:d,viewOptions:f,onViewOptionsChanged:p})]}):(0,i.jsx)(u.M,{bg:"rgb(249,249,249)",height:"100%",children:"No data"})};var eB=t(48689);let RunModal=e=>{let{isOpen:n,onClose:t,type:r,title:o,params:s,initialRun:c,RunForm:d,RunResultView:u}=e,[,h]=(0,eT.TH)(),[x,f]=(0,S.useState)(),[p,b]=(0,S.useState)(s),[k,w]=(0,S.useState)(!1),[_,R]=(0,S.useState)(!1),[D,T]=(0,S.useState)(),[N,E]=(0,S.useState)(),[L,I]=(0,S.useState)(c),submitRunFn=async()=>{let{run_id:e}=await submitRun(r,p,{nowait:!0});for(f(e);;){let n=await waitRun(e,2);if(T(n.progress),n.result||n.error)return w(!1),T(void 0),n}},{data:M,mutate:z,reset:F,error:O,isPending:A}=(0,eP.D)({mutationFn:submitRunFn});(0,S.useEffect)(()=>{n&&void 0===d&&void 0===L&&z()},[n]);let V=(0,H.NL)(),P=(0,S.useCallback)(async()=>{if(w(!0),x)return await cancelRun(x)},[x]),B=(0,S.useCallback)(()=>{z()},[z]),q=(0,S.useCallback)(()=>{z(),I(void 0)},[z]),handleReset=()=>{w(!1),b(s),T(void 0),I(void 0),F()},K=(0,S.useCallback)(async()=>{let e=L?L.run_id:null==M?void 0:M.run_id;if(void 0===e)return;let n=await checks_createCheckByRun(e,N);V.invalidateQueries({queryKey:Z.checks()}),h("/checks/".concat(n.check_id))},[null==M?void 0:M.run_id,L,h,V,N]),handleClose=async()=>{t(),A&&x&&await cancelRun(x),handleReset()},W=!!(null==L?void 0:L.result)||!!(null==M?void 0:M.result),U=(null==L?void 0:L.run_at)?(0,eB.Z)(new Date(L.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(g.u_,{isOpen:n,onClose:handleClose,size:"6xl",scrollBehavior:"inside",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"75%",children:[(0,i.jsxs)(es.x,{children:[o,!M&&!A&&U&&(0,i.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:U})]}),(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:A||M||O||L?(0,i.jsx)(RunView,{isPending:A,isAborting:k,run:L||M,error:O,progress:D,onCancel:P,viewOptions:N,onViewOptionsChanged:E,RunResultView:u}):(0,i.jsx)(l.xu,{style:{contain:"layout"},children:d&&(0,i.jsx)(d,{params:p,onParamsChanged:b,setIsReadyToExecute:R})})}),(0,i.jsx)(eV.m,{children:(0,i.jsxs)(a.k,{gap:"10px",children:[W&&d&&(0,i.jsx)(m.z,{colorScheme:"blue",onClick:handleReset,children:"Reset"}),W&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(m.z,{colorScheme:"blue",onClick:K,children:"Add to checklist"})}),A&&(0,i.jsx)(m.z,{onClick:P,isDisabled:k,colorScheme:"blue",children:"Cancel"}),!W&&!A&&(0,i.jsx)(m.z,{isDisabled:A||!_,colorScheme:"blue",onClick:B,children:"Execute"}),W&&!d&&(0,i.jsx)(m.z,{colorScheme:"blue",onClick:q,children:"Rerun"})]})})]})]})};var eq=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 i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function valuediff_getPrimaryKeyValue(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let r of n){let n=e[r];i[n.name]=t[r]}return JSON.stringify(i)}function valuediff_DataFrameColumnGroupHeader(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:o,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),m=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(a.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.xu,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&o&&(0,i.jsx)(s.J,{className:m?"unpin-icon":"pin-icon",display:m?"block":"none",cursor:"pointer",as:m?L.$kI:L.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,r=n[t.key];return(0,i.jsx)(i.Fragment,{children:"boolean"==typeof r?r.toString():r})};function toValueDiffGrid(e,n,t){let r=(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 i=valuediff_getPrimaryKeyValue(e.columns,d,n);n[u]&&(s[i]=n),n[h]&&(c[i]=n)});let m=mergeKeysWithStatus(Object.keys(s),Object.keys(c)),x=Object.entries(m).map(t=>{let[i,r]=t,l=s[i],o=c[i],d=JSON.parse(i);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))&&(eA().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 r="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,cellClass=t=>{let i=t.status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eA().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:r,name:(0,i.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:ev.Ug,headerCellClass:r,cellClass,renderCell:valuediff_defaultRenderCell,size:"auto"}]}};return n.forEach(e=>{let n=a[e].status||"";o.push({key:"".concat(e),name:(0,i.jsx)(valuediff_DataFrameColumnGroupHeader,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.status)return"diff-header-".concat(e.status)}})}),r.forEach(e=>{let t=a[e].status||"";n.includes(e)||o.push(toColumn(e,t))}),Object.entries(a).forEach(e=>{let[t,i]=e,a=i.status||"";"in_a"===t||"in_b"===t||n.includes(t)||r.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:r,onAddToChecklist:s,viewOptions:c,onViewOptionsChanged:d}=e,h=(0,S.useMemo)(()=>(null==c?void 0:c.changed_only)||!1,[c]),m=(0,S.useMemo)(()=>(null==c?void 0:c.pinned_columns)||[],[c]),x=(0,S.useMemo)(()=>{var e,n;if(!r.result)return{columns:[],rows:[]};let t=(null==r?void 0:null===(e=r.params)||void 0===e?void 0:e.primary_key)?[null==r?void 0:null===(n=r.params)||void 0===n?void 0:n.primary_key]:[];return toValueDiffGrid(null==r?void 0:r.result,t,{changedOnly:h,pinnedColumns:m,onPinnedColumnsChange:e=>{d&&d({...c,pinned_columns:e})}})},[r,c,h,m,d]);if(0===x.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});if(h&&0===x.rows.length)return(0,i.jsx)(u.M,{height:"100%",children:"No change"});let f=(null===(n=r.result)||void 0===n?void 0:n.limit)||0,p=f>0&&(null==r?void 0:null===(t=r.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,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:p?"orange.100":"inherit",children:[p&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",(0,i.jsx)(l.xu,{children:p})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),(0,i.jsx)(ez.X,{isChecked:null==c?void 0:c.changed_only,onChange:()=>{let e=!(null==c?void 0:c.changed_only);d&&d({...c,changed_only:e})},children:"Changed only"}),s&&(0,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>s(r)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:x.columns,rows:x.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};var eH=t(17180),eK=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 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 formatAsAbbreviatedNumber(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,i=n>=1e6,r=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(r||i||n>=1e3){let n={base:r?1e9:i?1e6:1e3,unit:r?"B":i?"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 eW=t(85670),eU=t(84021);function TopKSummaryList(e){let{topk:n,valids:t,isDisplayTopTen:r}=e,s=r?10:n.counts.length,c=n.counts.slice(0,s),d=t-c.reduce((e,n)=>e+n,0);return(0,i.jsx)(l.xu,{w:"100%",children:c.concat([d]).map((e,r)=>{let l=r===c.length,s=l?d:e,u=String(n.values[r]),h=l?"(others)":u||"(empty)",m=formatAsAbbreviatedNumber(s),x=formatIntervalMinMax(s/t);return(0,i.jsx)(S.Fragment,{children:!l||l&&s>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:3,children:[(0,i.jsx)(o.u,{label:h,placement:"start",children:(0,i.jsx)(f.x,{noOfLines:1,width:"14em",fontSize:"sm",color:l||0===u.length?"gray.400":"inherit",children:h})}),(0,i.jsx)(a.k,{height:"2em",width:"10em",children:(0,i.jsx)(CategoricalBarChart,{topkCount:s,topkLabel:h,valids:t})}),(0,i.jsx)(o.u,{label:m,placement:"start",children:(0,i.jsx)(f.x,{ml:5,mr:2,fontSize:"sm",width:"4em",noOfLines:1,children:m})}),(0,i.jsx)(o.u,{label:x,placement:"start",children:(0,i.jsx)(f.x,{color:"gray.400",fontSize:"sm",width:"4em",children:x})})]}),(0,i.jsx)(eH.i,{})]}):(0,i.jsx)(i.Fragment,{})},r)})})}function CategoricalBarChart(e){let{topkCount:n,topkLabel:t,valids:r,animation:l=!1}=e;eW.kL.register(eW.uw,eW.ZL,eW.f$);let o=getCatBarChartOptions(n,r,{animation:l}),a=getCatBarChartData({topkCount:n,topkLabel:t});return(0,i.jsx)(eU.$Q,{data:a,options:o,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}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:"#63B3ED",hoverBackgroundColor:"#002a53",borderWidth:1,borderColor:"#002a53",barPercentage:1,categoryPercentage:.6}]}}let ScreenshotBox=e=>{let{backgroundColor:n="white",blockSize:t,children:r,...o}=e,{ref:a,CopyToClipboardButton:s}=useCopyToClipboardButton({backgroundColor:n});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.xu,{ref:a,...o,overflow:"auto",children:(0,i.jsx)(l.xu,{backgroundColor:n,height:"100%",blockSize:t,children:r})}),(0,i.jsx)(s,{imageType:"png"})]})};function TopKDiffResultView(e){let{run:n}=e,[t,r]=(0,S.useState)(!0),o=n.result,s=n.params,c=o.base,d=o.current;return(0,i.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(ScreenshotBox,{blockSize:"auto",children:[(0,i.jsxs)(ea.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",children:["Model ",s.model,".",s.column_name]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(E.L,{}),(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Base"}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(TopKSummaryList,{topk:c,valids:c.valids||0,isDisplayTopTen:t})]}),(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Current"}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(TopKSummaryList,{topk:d,valids:d.valids||0,isDisplayTopTen:t})]}),(0,i.jsx)(E.L,{})]})]}),(0,i.jsx)(E.L,{}),(c.values.length>10||d.values.length>10)&&(0,i.jsx)(a.k,{p:5,justify:"start",children:(0,i.jsx)(eK.r,{onClick:()=>r(e=>!e),textColor:"blue.500",children:t?"View More Items":"View Only Top-10"})})]})}var eG=t(68665);function TopKDiffForm(e){var n;let{params:t,onParamsChanged:r,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eA().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,S.useEffect)(()=>{o(!!t.column_name)},[t,o]),(0,i.jsx)(l.xu,{m:"16px",children:(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Pick a column to show top-k"}),(0,i.jsx)(eG.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{let n=e.target.value;r({...t,column_name:n})},children:c.map(e=>(0,i.jsx)("option",{value:e,children:e},e))})]})})}function HistogramChart(e){let{data:n,hideAxis:t=!1,animation:r=!1}=e;eW.kL.register(eW.ZL,eW.RM,eW.f$,eW.uw,eW.u);let l=getHistogramChartOptions(n,t,{animation:r}),o=getHistogramChartData(n);return(0,i.jsx)(eU.kL,{type:"bar",options:l,data:o,plugins:[]})}function getHistogramChartData(e){let{histogram:n,type:t,binEdges:i}=e,{counts:r=[]}=n||{},l="datetime"===t?r.map((e,n)=>({x:i[n],y:e})):r,o=i.map((e,n)=>formatDisplayedBinItem(i,n)).slice(0,-1);return{labels:o,datasets:[{label:"counts",data:l,backgroundColor:"#63B3ED",borderColor:"#4299E1",hoverBackgroundColor:"#002A53",borderWidth:1,categoryPercentage:1,barPercentage:1,xAxisID:"x"}]}}function getHistogramChartOptions(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{histogram:i,type:r,samples:l=0,binEdges:o}=e,{counts:a=[]}=i||{},s="datetime"===r;return{responsive:!0,maintainAspectRatio:!1,plugins:{tooltip:{mode:"index",position:"nearest",intersect:!1,callbacks:{title(e){let[{dataIndex:n}]=e,t=formatDisplayedBinItem(o,n),i=formatIntervalMinMax(a[n]/l);return"".concat(s?"Date Range":"string"===r?"Text Length":"Value Range","\n").concat(t,"\n(").concat(i,")")}}}},scales:getScales(e,n),...t}}function getScales(e){let{histogram:n,min:t=0,max:i=0,type:r,binEdges:l}=e,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{counts:a=[]}=n||{},s=l.map((e,n)=>formatDisplayedBinItem(l,n)).slice(0,-1);return{x:"datetime"===r?{display:!o,type:"timeseries",min:t,max:i,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)=>s[n]}},y:{display:!o,type:"linear",max:Math.max(...a),border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return formatAsAbbreviatedNumber(e)}}}}}function formatDisplayedBinItem(e,n){let t=e[n],i=e[n+1],r=formatAsAbbreviatedNumber(t),l=formatAsAbbreviatedNumber(i),o="".concat(r," - ").concat(l);return o}function HistogramDiffResultView(e){var n,t,r,o,s,c,d;let{run:u}=e,h=u.params,m=null===(n=u.result)||void 0===n?void 0:n.base,f=null===(t=u.result)||void 0===t?void 0:t.current,p=null===(r=u.result)||void 0===r?void 0:r.min,g=null===(o=u.result)||void 0===o?void 0:o.max,v=null===(s=u.result)||void 0===s?void 0:s.bin_edges;return m&&f?(0,i.jsx)(a.k,{direction:"column",height:"500px",children:(0,i.jsxs)(ScreenshotBox,{height:"100%",children:[(0,i.jsxs)(ea.X,{as:"h1",size:"md",paddingTop:"4",textAlign:"center",children:["Model ",h.model,".",h.column_name]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(E.L,{}),(0,i.jsxs)(l.xu,{w:"40%",h:"300px",m:"4",children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Base"}),(0,i.jsx)(HistogramChart,{data:{type:(null===(c=u.params)||void 0===c?void 0:c.column_type)||"",histogram:m,min:p,max:g,samples:m.total,binEdges:v}})]}),(0,i.jsxs)(l.xu,{w:"40%",h:"300px",m:"4",children:[(0,i.jsx)(ea.X,{as:"h3",size:"sm",m:"2",color:"gray",children:"Current"}),(0,i.jsx)(HistogramChart,{data:{type:(null===(d=u.params)||void 0===d?void 0:d.column_type)||"",histogram:f,min:p,max:g,samples:f.total,binEdges:v}})]}),(0,i.jsx)(E.L,{})]})]})}):(0,i.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:r,setIsReadyToExecute:o}=e,a=useLineageGraphsContext(),s=eA().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,i.jsx)(l.xu,{m:"16px",children:(0,i.jsxs)(eL.NI,{children:[(0,i.jsx)(eI.l,{children:"Pick a column to show Histogram Diff"}),(0,i.jsx)(eG.P,{placeholder:"Select column",value:null==t?void 0:t.column_name,onChange:e=>{var n;let i=e.target.value;o(!!i);let l=(null===(n=c.find(e=>e.name===i))||void 0===n?void 0:n.type)||"";r({...t,column_name:i,column_type:l})},children:c.map(e=>(0,i.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}let eQ=(0,S.createContext)({runAction:()=>{}}),eJ={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,eT.TH)();(0,S.useEffect)(()=>{e()},[e,n])};function RecceActionContextProvider(e){var n;let{children:t}=e,[r,l]=(0,S.useState)(),{isOpen:o,onOpen:a,onClose:s}=(0,c.q)(),d=(0,S.useCallback)(async(e,n,t)=>{let i;let r=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await searchRuns(e,n,1);1===t.length&&(i=t[0])}l({session:r,type:e,params:n,lastRun:i,options:t}),a()},[l,a]);return useCloseModalEffect(s),(0,i.jsxs)(eQ.Provider,{value:{runAction:d},children:[r&&eJ[r.type]&&(0,i.jsx)(RunModal,{isOpen:o,onClose:s,title:eJ[r.type].title,type:r.type,params:r.params,initialRun:r.lastRun,RunResultView:eJ[r.type].RunResultView,RunForm:(null===(n=r.options)||void 0===n?void 0:n.showForm)?eJ[r.type].RunForm:void 0},r.session),t]})}let useRecceActionContext=()=>(0,S.useContext)(eQ);function NodeView(e){let{node:n,onCloseNode:t}=e,[,r]=(0,eT.TH)(),{setSqlQuery:o}=useRecceQueryContext(),{fetchFn:s}=models_useRowCountQueries([n.name]),d="model"===n.resourceType||"seed"===n.resourceType||"source"===n.resourceType,{isOpen:u,onOpen:h,onClose:f}=(0,c.q)(),{runAction:p}=useRecceActionContext(),_=(0,S.useCallback)(async()=>{let e=n.id,t=await createCheckByNodeSchema(e);r("/checks/".concat(t.check_id))},[n,r]),R=(0,S.useCallback)(async()=>{let e=await s({skipCache:!0}),n=await checks_createCheckByRun(e);r("/checks/".concat(n.check_id))},[r,s]);return(0,i.jsxs)(eo.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(x.U,{children:[(0,i.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(ea.X,{size:"sm",children:n.name})}),(0,i.jsx)(E.L,{}),"modified"===n.changeStatus&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(m.z,{onClick:h,leftIcon:(0,i.jsx)(I.tvD,{}),colorScheme:"orange",variant:"solid",children:"Diff"}),(0,i.jsxs)(g.u_,{isOpen:u,onClose:f,size:"6xl",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(es.x,{children:"Model Raw Code Diff"}),(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{children:(0,i.jsx)(SqlDiffView,{base:n.data.base,current:n.data.current})})]})]})]}),(0,i.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,i.jsx)(ec.P,{onClick:t})})]}),(0,i.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,i.jsxs)(x.U,{spacing:"8px",children:[(0,i.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,i.jsx)(RowCountTag,{node:n})]})}),d&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(ed.m,{overflow:"auto",as:a.k,children:[(0,i.jsx)(eu.t,{children:(0,i.jsx)(eh.O,{children:"Columns"})}),(0,i.jsx)(em.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(ex.x,{p:0,overflowY:"auto",height:"100%",children:(0,i.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]}),(0,i.jsxs)(x.U,{p:"16px",children:[(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{as:m.z,size:"sm",colorScheme:"blue",children:"Add check"}),(0,i.jsxs)(k.q,{children:[(0,i.jsx)(w.s,{onClick:_,children:"Schema Check"}),(0,i.jsx)(w.s,{onClick:R,children:"Row Count Check"})]})]}),(0,i.jsx)(E.L,{}),"model"===n.resourceType&&(0,i.jsxs)(i.Fragment,{children:["added"!==n.changeStatus&&"removed"!==n.changeStatus&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{as:m.z,size:"sm",colorScheme:"blue",children:"Advanced Diffs"}),(0,i.jsxs)(k.q,{children:[(0,i.jsx)(w.s,{onClick:()=>{p("profile_diff",{model:n.name},{showForm:!1,showLast:!0})},children:"Profile Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("value_diff",{model:n.name},{showForm:!0,showLast:!0})},children:"Value Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("top_k_diff",{model:n.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"}),(0,i.jsx)(w.s,{onClick:()=>{p("histogram_diff",{model:n.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})]})]})}),(0,i.jsx)(m.z,{colorScheme:"blue",size:"sm",onClick:()=>{o('select * from {{ ref("'.concat(n.name,'") }}')),r("/query")},children:"Query"})]})]})]})]})}let eZ={added:["Model Added","Added resource"],removed:["Model Removed","Removed resource"],modified:["Model Modified","Modified resource"],col_added:["Column Added","Added column"],col_removed:["Column Removed","Removed column"],col_changed:["Column Modified","Modified column"],folder_changed:["Modified","Modified folder"]};function ChangeSummary_getIconForChangeStatus(e){if("added"===e)return{color:"#1dce00",icon:z};if("removed"===e)return{color:"#ff067e",icon:F};if("modified"===e)return{color:"#ffa502",icon:O};if("col_added"===e)return{color:"#1dce00",icon:z};if("col_removed"===e)return{color:"#ff067e",icon:F};if("col_changed"===e)return{color:"#ffa502",icon:O};if("folder_changed"===e)return{color:"#ffa502",icon:IconChanged};return{color:"inherit",icon:void 0}}function SummaryText(e){let{name:n,value:t,tip:r}=e;return(0,i.jsxs)(h.g,{alignItems:"stretch",children:[(0,i.jsxs)(f.x,{fontSize:"sm",color:"gray",children:[n,r&&(0,i.jsx)(o.u,{label:r,children:(0,i.jsx)(l.xu,{display:"inline-block",children:(0,i.jsx)(s.J,{mx:"2px",as:B.H33,boxSize:3})})})]}),t]})}function ChangeStatusCountLabel(e){let{changeStatus:n,value:t}=e,[r]=n?eZ[n]:[""],{icon:l,color:o}=ChangeSummary_getIconForChangeStatus(n);return(0,i.jsxs)(h.g,{alignItems:"stretch",children:[(0,i.jsxs)(a.k,{alignItems:"center",fontSize:"sm",color:"gray",children:[(0,i.jsx)(s.J,{mr:"5px",as:l,color:o}),r]}),(0,i.jsx)(f.x,{fontSize:"sm",children:t})]})}function calculateColumnChange(e,n){let t=0,i=0,r=0;return(e||n)&&(n&&Object.keys(n.columns||{}).forEach(n=>{(!e||!e.columns||!e.columns[n])&&t++}),e&&Object.keys(e.columns||{}).forEach(e=>{(!n||!n.columns||!n.columns[e])&&i++}),n&&e&&Object.keys(n.columns||{}).forEach(t=>{e.columns&&n.columns&&e.columns[t]&&e.columns[t].type!==n.columns[t].type&&r++})),{adds:t,removes:i,modifies:r}}function calculateChangeSummary(e,n){let t=0,i=0,r=0,l=0,o=0,a=0;return n.forEach(n=>{"added"===e.nodes[n].changeStatus?t++:"removed"===e.nodes[n].changeStatus?i++:"modified"===e.nodes[n].changeStatus&&r++;let s=e.nodes[n].data.base,c=e.nodes[n].data.current,d=calculateColumnChange(s,c);l+=d.adds,o+=d.removes,a+=d.modifies}),{adds:t,removes:i,modifies:r,col_added:l,col_removed:o,col_changed:a}}function ChangeSummary(e){let{lineageGraphSets:n}=e,{adds:t,removes:r,modifies:o,col_added:a,col_removed:s,col_changed:c}=calculateChangeSummary(n.all,n.modifiedSet);return(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr",mb:"10px",borderTop:"1px solid lightgray",padding:"2.5vw",children:[(0,i.jsx)(l.xu,{borderColor:"lightgray",children:(0,i.jsx)(SummaryText,{name:"Code Changes",value:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr 1fr",width:"100%",children:[(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"added",value:t}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"removed",value:r}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"modified",value:o})]})})})}),(0,i.jsx)(l.xu,{borderLeft:"1px",paddingLeft:"12px",borderColor:"lightgray",children:(0,i.jsx)(SummaryText,{name:"Column Changes",value:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(eo.r,{templateColumns:"1fr 1fr 1fr",width:"100%",children:[(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_added",value:a}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_removed",value:s}),(0,i.jsx)(ChangeStatusCountLabel,{changeStatus:"col_changed",value:c})]})})})})]})}var eX=t(76353),eY=t(53248),e$=t(9763),e0=t(95853);function SchemaDiffCard(e){let{node:n,...t}=e;return(0,i.jsxs)(eX.Z,{maxWidth:"500px",children:[(0,i.jsxs)(eY.O,{children:[(0,i.jsx)(ea.X,{fontSize:18,children:t.title}),(0,i.jsxs)(x.U,{spacing:"8px",p:"16px",children:[(0,i.jsx)(ResourceTypeTag,{node:n}),"model"===n.resourceType&&(0,i.jsx)(RowCountTag,{node:n,isAutoFetching:!0})]})]}),(0,i.jsx)(e$.e,{children:(0,i.jsx)(a.k,{children:(0,i.jsx)(SchemaView,{base:n.data.base,current:n.data.current})})})]})}function listChangedNodes(e){let n=[],t=e.all.nodes;return e.modifiedSet.forEach(e=>{var i,r;let l=t[e],o=mergeKeysWithStatus(Object.keys((null===(i=l.data.base)||void 0===i?void 0:i.columns)||{}),Object.keys((null===(r=l.data.current)||void 0===r?void 0:r.columns)||{})),a=!Object.values(o).every(e=>void 0===e);a&&l.data.base&&l.data.current&&n.push(l)}),n}function SchemaSummary(e){let{lineageGraphSets:n}=e,[t,r]=(0,S.useState)([]);return(0,S.useEffect)(()=>{r(listChangedNodes(n))},[n]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",marginTop:"20px",children:(0,i.jsx)(ea.X,{fontSize:24,children:"Schema Summary"})}),(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",children:0===t.length?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(f.x,{fontSize:18,color:"gray",children:"No schema changes detected."})}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(e0.M,{minChildWidth:"400px",spacing:"2vw",padding:"2.5vw",width:"100%",backgroundColor:"lightgray",children:t.map(e=>(0,i.jsx)(SchemaDiffCard,{title:e.name,node:e},e.id))})})})]})}function SummaryView(){let{lineageGraphSets:e}=useLineageGraphsContext();return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(a.k,{direction:"column",w:"100%",minHeight:"650px",children:[(0,i.jsx)(a.k,{w:"100%",paddingBottom:"10px",marginBottom:"20px",children:(0,i.jsx)(ea.X,{fontSize:24,children:"Change Summary"})}),e&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ChangeSummary,{lineageGraphSets:e}),(0,i.jsx)(eH.i,{}),(0,i.jsx)(SchemaSummary,{lineageGraphSets:e})]})]})})}var e1=t(45438),e2=t(72491),e5=t(52246),e3=t(25807),e6=t(15012);function AddSchemaChangesCheckButton(e){let{nodes:n,onFinish:t}=e,[,r]=(0,eT.TH)();return(0,i.jsxs)(m.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?r("/checks/".concat(e.check_id)):r("/checks")},children:[(0,i.jsx)(s.J,{as:q.Edg}),"Add schema check"]})}function AddLineageDiffCheckButton(e){let{viewMode:n,nodes:t,onFinish:r,withIcon:l}=e,[,o]=(0,eT.TH)();return(0,i.jsxs)(m.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:0===t.length,onClick:async()=>{let e=t.map(e=>e.id),i=await createLineageDiffCheck(n,e);r(),i?o("/checks/".concat(i.check_id)):o("/checks")},children:[l&&(0,i.jsx)(s.J,{as:e6.Ks7}),"Add lineage diff check"]})}function NodeSelector(e){var n,t,r,o;let{viewMode:a,nodes:c,onClose:d,onActionStarted:u,onActionNodeUpdated:h,onActionCompleted:f}=e,[p,g]=(0,S.useState)({mode:"per_node",status:"pending",completed:0,total:0}),v=(0,H.NL)(),[,j]=(0,eT.TH)(),submitRunForNodes=async(e,n,t)=>{let i="multi_nodes";p.mode=i,u(),p.status="running";let r=[];for(let e of c){let t=n(e);t?(e.action={mode:i,status:"skipped",skipReason:t},h(e)):(e.action={mode:i,status:"pending"},r.push(e))}let l=t(r);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 r)n.action={mode:i,status:t,run:e},h(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"},h(e);for(let i of(p.completed=0,p.total=c.length,c)){let{params:r,skipReason:l}=n(i);if(l)i.action={mode:t,status:"skipped",skipReason:l},h(i);else try{let{run_id:n}=await submitRun(e,r,{nowait:!0});for(p.currentRun={run_id:n},i.action={mode:t,status:"running"},h(i);;){let e=await waitRun(n,2);p.currentRun=e;let r=e.error?"failure":e.result?"success":"running";if(i.action={mode:t,status:r,run:e},h(i),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"},h(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 i=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;if(!i)return{skipReason:"No primary key found. The first unique column is used as primary key."};let r={model:e.name,primary_key:i};return{params:r}})},handleCancel=async()=>{var e;p.status="canceling",(null===(e=p.currentRun)||void 0===e?void 0:e.run_id)&&cancelRun(p.currentRun.run_id)},y=(0,S.useCallback)(async()=>{var e;let n=null===(e=p.currentRun)||void 0===e?void 0:e.run_id;if(!n)return;let t=await checks_createCheckByRun(n);v.invalidateQueries({queryKey:Z.checks()}),j("/checks/".concat(t.check_id))},[null===(n=p.currentRun)||void 0===n?void 0:n.run_id,j,v]);return(0,e2.z)(()=>{"running"===p.status&&handleCancel()}),(0,i.jsxs)(l.xu,{bg:"white",rounded:"md",shadow:"dark-lg",children:["pending"===p.status&&(0,i.jsxs)(x.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(e5.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.jsxs)(e3.h,{size:"xs",isAttached:!0,variant:"outline",rounded:"xs",onClick:d,children:[(0,i.jsxs)(m.z,{children:[c.length," selected"]}),(0,i.jsx)(P.h,{"aria-label":"Exit select Mode",icon:(0,i.jsx)(e1.D,{})})]}),(0,i.jsxs)(x.U,{children:[(0,i.jsx)(AddSchemaChangesCheckButton,{nodes:c,onFinish:d}),(0,i.jsx)(AddLineageDiffCheckButton,{viewMode:a,nodes:c,onFinish:d,withIcon:!0})]}),(0,i.jsxs)(x.U,{children:[(0,i.jsxs)(m.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleRowCountDiffClick,children:[(0,i.jsx)(s.J,{as:B.SwK}),"Row count diff"]}),(0,i.jsxs)(m.z,{size:"xs",variant:"outline",isDisabled:0===c.length,onClick:handleValueDiffClick,children:[(0,i.jsx)(s.J,{as:e6.pRi}),"Value diff"]})]})]}),"pending"!==p.status&&(0,i.jsxs)(x.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(e5.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.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===(r=o.progress)||void 0===r?void 0:r.percentage)?"".concat(100*p.currentRun.progress.percentage,"%"):"completed"===p.status?"100%":"0%"," ","canceled"===p.status?" (canceled)":""]}),"running"===p.status||"canceling"===p.status?(0,i.jsx)(m.z,{size:"xs",variant:"outline",onClick:handleCancel,isLoading:"canceling"===p.status,loadingText:"Canceling",children:"Cancel"}):(0,i.jsxs)(x.U,{children:["multi_nodes"===p.mode&&(null===(t=p.currentRun)||void 0===t?void 0:t.result)&&(0,i.jsx)(m.z,{display:"none",size:"xs",variant:"outline",onClick:y,children:"Add to checklist"}),(0,i.jsx)(m.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||{},r=Object.keys(n.result||{}).map(e=>{let n=t[e],i=(null==n?void 0:n.base)||null,r=(null==n?void 0:n.curr)||null,l="No Change";return null!==i&&null!==r?l=ir?"- ".concat(Math.round((i-r)/i*100),"%"):"No Change":i===r?l="N/A":null===i?l="Added":null===r&&(l="Removed"),{name:e,base:null===i?"N/A":Number(i),current:null===r?"N/A":Number(r),delta:l}});return(0,i.jsx)(a.k,{direction:"column",children:Object.keys(t).length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.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:r,className:"rdg-light",enableScreenshot:!0})})})}function NodeRunView(e){var n,t,r,o,s,c,d,u;let{node:h,onCloseNode:f}=e,p=null===(n=h.action)||void 0===n?void 0:n.run,[,g]=(0,eT.TH)(),v=(0,H.NL)(),[j,y]=(0,S.useState)(),C=(0,S.useCallback)(async()=>{if(!(null==p?void 0:p.run_id))return;let e=await checks_createCheckByRun(p.run_id,j);v.invalidateQueries({queryKey:Z.checks()}),g("/checks/".concat(e.check_id))},[null==p?void 0:p.run_id,g,v,j]),b=(null===(r=h.action)||void 0===r?void 0:null===(t=r.run)||void 0===t?void 0:t.type)==="value_diff"?ValueDiffResultView:(null===(s=h.action)||void 0===s?void 0:null===(o=s.run)||void 0===o?void 0:o.type)==="row_count_diff"?RowCountDiffResultView:null;return(0,i.jsxs)(eo.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(x.U,{children:[(0,i.jsx)(l.xu,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(ea.X,{size:"sm",children:h.name})}),(0,i.jsx)(E.L,{}),(0,i.jsx)(l.xu,{flex:"0 1 1%",p:"16px",children:(0,i.jsx)(ec.P,{onClick:f})})]}),(0,i.jsx)(l.xu,{color:"gray",paddingLeft:"16px",children:(0,i.jsx)(x.U,{spacing:"8px",children:(0,i.jsx)(ResourceTypeTag,{node:h})})}),(0,i.jsxs)(ed.m,{overflow:"auto",as:a.k,children:[(0,i.jsx)(eu.t,{children:(0,i.jsx)(eh.O,{children:"Run"})}),(0,i.jsx)(em.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(ex.x,{p:0,overflowY:"auto",height:"100%",children:b?(0,i.jsx)(RunView,{run:null===(c=h.action)||void 0===c?void 0:c.run,viewOptions:j,onViewOptionsChanged:y,RunResultView:b}):(0,i.jsx)(l.xu,{p:"20px 10px",children:"No run result"})})})]}),(0,i.jsxs)(x.U,{p:"16px",children:[(0,i.jsx)(E.L,{}),(0,i.jsx)(m.z,{size:"sm",colorScheme:"blue",isDisabled:!(null===(u=h.action)||void 0===u?void 0:null===(d=u.run)||void 0===d?void 0:d.result),onClick:C,children:"Add to checklist"})]})]})}let layout=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",i=new(N()).graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:t}),e.forEach(e=>{i.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{i.setEdge(e.source,e.target)}),N().layout(i),e.forEach(e=>{let n=i.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})},e4={customNode:GraphNode},e9={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"},e8={all:"All",changed_models:"Changed Models"};function ChangeStatusLegend(){return(0,i.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,r]]=e,{icon:l,color:c}=getIconForChangeStatus(n);return(0,i.jsx)(o.u,{label:r,children:(0,i.jsxs)(a.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,i.jsx)(s.J,{color:c,as:l})," ",t]})},n)})})}function _LineageView(e){let{...n}=e,{fitView:t,setCenter:o,getZoom:T}=(0,r._K)(),{successToast:N,failToast:E}=useClipBoardToast(),{toImage:L,ref:I}=useToBlob({imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(ek))},onSuccess:async e=>{try{await copyBlobToClipboard(e),N("Copied the Lineage View as an image to clipboard")}catch(e){E("Failed to copy image to clipboard",e)}},onError:e=>{console.error("Error taking screenshot",e),E("Failed to copy image to clipboard",e)}}),[M,z,F]=(0,r.Rr)([]),[O,A,V]=(0,r.ll)([]),[P,q]=(0,S.useState)(),[H,K]=(0,S.useState)(),{lineageGraphSets:W,isLoading:U,error:G}=useLineageGraphsContext(),{isOpen:Q,onOpen:J,onClose:Z}=(0,c.q)(),[X,Y]=(0,S.useState)("detail"),[$,ee]=(0,S.useState)(),[en,et]=(0,S.useState)(!1),[ei,er]=(0,S.useState)(n.viewMode||"changed_models"),[eo,ea]=(0,S.useState)(!1),[es,ec]=(0,S.useState)({x:0,y:0});(0,S.useEffect)(()=>{if(!W)return;let e="changed_models"===ei?{...W.changed}:{...W.all},t=W.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,i]=e;return t(n,i)}))}let[i,r]=toReactflow(e,W.modifiedSet);layout(i,r),q(e),K(t),z(i),A(r)},[z,A,ei,W,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,i=T();o(n,t,{zoom:i,duration:200})}},ed=(0,S.useCallback)(e=>{z(n=>{let t=n.map(n=>n.id===e.id?{...n,data:e}:n);return t})},[z]);if(U)return(0,i.jsx)(a.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,i.jsx)(d.$,{size:"xl"})});let closeContextMenu=()=>{ea(!1),ec({x:0,y:0})};return G?(0,i.jsxs)(i.Fragment,{children:["Fail to load lineage data: ",G]}):"changed_models"===ei&&(void 0===H||(null==H?void 0:H.length)===0)?(0,i.jsx)(u.M,{h:"100%",children:(0,i.jsxs)(h.g,{children:[(0,i.jsx)(i.Fragment,{children:"No change detected"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>{er("all")},children:"Show all nodes"})]})}):(0,i.jsxs)(a.k,{width:"100%",height:"100%",children:[(0,i.jsx)(l.xu,{flex:"1 0 0px",children:(0,i.jsxs)(r.x$,{nodeTypes:e4,edgeTypes:e9,nodes:M,edges:O,onNodesChange:F,onEdgesChange:V,onNodeClick:(e,t)=>{!1!==n.interactive&&(closeContextMenu(),"detail"===X?(ee(t.data),en||et(!0),z(selectSingleNode(t.id,M)),centerNode(t)):"action_result"===X?(ee(t.data),en||et(!0),z(selectSingleNode(t.id,M)),centerNode(t)):z(selectNode(t.id,M)))},onNodeMouseEnter:(e,n)=>{if(P&&void 0!==H){let[e,t]=highlightPath(P,H,M,O,n.id);z(e),A(t)}},onNodeMouseLeave:(e,n)=>{if(P&&void 0!==H){let[e,n]=highlightPath(P,H,M,O,null);z(e),A(n)}},onNodeContextMenu:(e,n)=>{"action"===X&&(e.preventDefault(),ec({x:e.clientX,y:e.clientY,selectedNode:n}),ea(!0))},onClick:closeContextMenu,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:n.interactive,ref:I,children:[(0,i.jsx)(_.A,{color:"#ccc"}),(0,i.jsxs)(R.Z,{showInteractive:!1,position:"top-right",className:ek,children:[n.interactive&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(R.B,{title:"switch mode",onClick:()=>{er("all"===ei?"changed_models":"all");let e=cleanUpSelectedNodes(M);z(e)},children:(0,i.jsx)(s.J,{as:B.Bw1})}),(0,i.jsx)(R.B,{title:"summary",onClick:J,children:(0,i.jsx)(s.J,{as:B.SnF})})]}),(0,i.jsx)(R.B,{title:"copy image",onClick:()=>{L()},children:(0,i.jsx)(s.J,{as:B.C3L})})]}),(0,i.jsx)(r.s_,{position:"bottom-left",children:(0,i.jsxs)(x.U,{children:[(0,i.jsx)(ChangeStatusLegend,{}),n.interactive&&(0,i.jsxs)(l.xu,{p:2,flex:"0 1 160px",fontSize:"14px",className:ek,children:[(0,i.jsx)(f.x,{color:"gray",mb:"2px",children:"Actions"}),(0,i.jsxs)(h.g,{spacing:1,align:"baseline",children:[(0,i.jsx)(m.z,{size:"xs",variant:"outline",backgroundColor:"white",isDisabled:"detail"!==X,onClick:()=>{ee(void 0),et(!1);let e=cleanUpSelectedNodes(M);z(e),Y("detail"===X?"action":"detail")},children:"Select Models"}),(0,i.jsx)(AddLineageDiffCheckButton,{viewMode:ei,nodes:M.map(e=>e.data),onFinish:()=>Y("detail")})]})]})]})}),(0,i.jsx)(r.s_,{position:"top-left",children:(0,i.jsx)(f.x,{fontSize:"xl",color:"grey",opacity:.5,children:e8[ei]})}),(0,i.jsx)(r.s_,{position:"bottom-center",className:ek,children:(0,i.jsx)(p.R,{in:"detail"!==X,unmountOnExit:!0,style:{zIndex:10},children:(0,i.jsx)(NodeSelector,{viewMode:ei,nodes:M.map(e=>e.data).filter(e=>e.isSelected),onClose:()=>{Y("detail");let e=cleanUpSelectedNodes(M);ee(void 0),et(!1),z(e)},onActionStarted:()=>{Y("action_result")},onActionNodeUpdated:ed,onActionCompleted:()=>{}})})}),(0,i.jsx)(D.a,{nodeColor:nodeColor,nodeStrokeWidth:3})]})}),(0,i.jsxs)(g.u_,{isOpen:Q,onClose:Z,size:"6xl",children:[(0,i.jsx)(v.Z,{}),(0,i.jsxs)(j.h,{overflowY:"auto",height:"80%",children:[(0,i.jsx)(y.o,{}),(0,i.jsx)(C.f,{children:(0,i.jsx)(SummaryView,{})})]})]}),"detail"===X&&$&&(0,i.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(NodeView,{node:$,onCloseNode:()=>{ee(void 0),et(!1),z(cleanUpSelectedNodes(M))}})}),"action_result"===X&&$&&(0,i.jsx)(l.xu,{flex:"0 0 500px",borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(NodeRunView,{node:$,onCloseNode:()=>{ee(void 0),et(!1)}})}),eo&&(0,i.jsx)(b.v,{isOpen:!0,onClose:closeContextMenu,children:(0,i.jsxs)(k.q,{style:{position:"absolute",left:"".concat(es.x,"px"),top:"".concat(es.y,"px")},children:[(0,i.jsx)(w.s,{icon:(0,i.jsx)(el.Cv2,{}),onClick:()=>{let e=es.selectedNode;if("action"!==X||void 0===e||void 0===P)return;let n=e.id,t=selectUpstream(P,[n]),i=selectNodes([...t],M);z(i)},children:"Select parent nodes"}),(0,i.jsx)(w.s,{icon:(0,i.jsx)(el.IMj,{}),onClick:()=>{let e=es.selectedNode;if("action"!==X||void 0===e||void 0===P)return;let n=e.id,t=selectDownstream(P,[n]),i=selectNodes([...t],M);z(i)},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,i.jsx)(r.tV,{children:(0,i.jsx)(_LineageView,{...n})})}var e7=t(12844),ne=t(98786);function RecceContextProvider(e){let{children:n}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(RecceQueryContextProvider,{children:(0,i.jsx)(LineageGraphsContextProvider,{children:(0,i.jsx)(RowCountStateContextProvider,{children:(0,i.jsx)(RecceActionContextProvider,{children:n})})})})})}function useVersionNumber(){let[e,n]=(0,S.useState)("");return(0,S.useEffect)(()=>{(async function(){try{let e=await Q.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}var nn=t(45489),nt=t(69005),ni=t(14800),nr=t(2600),nl=t(68677),no=t(83358),na=t(44525),ns=t(79935),nc=t(93197),nd=t(234),nu=t(96094),nh=t(36334);function CheckBreadcrumb(e){let{name:n,setName:t}=e,[r,o]=(0,S.useState)(!1),[a,s]=(0,S.useState)(n),c=(0,S.useRef)(null),d=(0,S.useCallback)(()=>{t(a),o(!1)},[t,o,a]);return(0,S.useEffect)(()=>{let handleClickOutside=e=>{c.current&&!c.current.contains(e.target)&&d()};return r&&document.addEventListener("mousedown",handleClickOutside),()=>{document.removeEventListener("mousedown",handleClickOutside)}},[r,c,d]),(0,i.jsxs)(nd.a,{flex:"0 1",fontSize:"12pt",fontWeight:"500",separator:(0,i.jsx)(nh.X,{color:"gray.500"}),children:[(0,i.jsx)(nu.g,{children:(0,i.jsx)(l.xu,{children:"Checklist"})}),(0,i.jsx)(nu.g,{flex:"0 1",cursor:"pointer",children:r?(0,i.jsx)(eM.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,i.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(),r=n.params,l=r.node_id,o=l?null==t?void 0:t.all.nodes[l]:void 0;return o?(0,i.jsx)(SchemaView,{base:o.data.base,current:o.data.current,enableScreenshot:!0}):(0,i.jsx)(i.Fragment,{})}var nm=t(33695);function CheckDescription(e){let{value:n,onChange:t}=e,[r,l]=(0,S.useState)(!1),[o,s]=(0,S.useState)(),c=(0,S.useRef)(null);return((0,S.useEffect)(()=>{if(r&&c.current){let e=c.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[r]),r)?(0,i.jsxs)(a.k,{direction:"column",align:"flex-end",children:[(0,i.jsx)(nm.g,{h:"200px",value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&l(!1)},ref:c}),(0,i.jsxs)(a.k,{gap:"12px",alignItems:"flex-end",children:[(0,i.jsx)(eK.r,{onClick:()=>{setTimeout(()=>{l(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,i.jsx)(m.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:()=>{t&&(t(o),l(!1))},children:"Update"})]})]}):(0,i.jsx)(f.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 nx=t(48742);function _templateObject(){let e=(0,nn._)(["\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,nx.Pn)(_templateObject(),null===(n=e.params)||void 0===n?void 0:n.sql_template)}var query_SqlEditor=e=>{let{value:n,onChange:t,onRun:r,onRunDiff:l,options:o={},...a}=e;return(0,i.jsx)(eD.ZP,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{r&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,r),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:r=()=>{}}=e,o=t.includes(n);return(0,i.jsxs)(a.k,{className:"grid-header",alignItems:"center",children:[(0,i.jsx)(l.xu,{flex:1,children:n}),(0,i.jsx)(s.J,{className:o?"unpin-icon":"pin-icon",display:o?"block":"none",cursor:"pointer",as:o?L.$kI:L.oJP,onClick:o?()=>{let e=t.filter(e=>e!==n);r(e)}:()=>{let e=[...t,n];r(e)}})]})}function QueryResultView_toDataGrid(e,n){let t=[],r=n.pinnedColumns||[],toColumn=(e,t)=>({key:String(e),name:(0,i.jsx)(DataFrameColumnHeader,{name:t,...n}),width:"auto",renderCell:defaultRenderCell});return t.push({key:"_index",name:"",width:10,cellClass:"index-column"}),r.forEach(n=>{let i=eA().findIndex(e.columns,e=>e.name===n);i<0||t.push(toColumn(i,n))}),e.columns.forEach((e,n)=>{r.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:r,onAddToChecklist:s}=e,c=(0,S.useMemo)(()=>(null==t?void 0:t.pinned_columns)||[],[t]),d=null==n?void 0:n.result,h=(0,S.useMemo)(()=>d?QueryResultView_toDataGrid(d,{pinnedColumns:c,onPinnedColumnsChange:e=>{r&&r({...t,pinned_columns:e})}}):{rows:[],columns:[]},[d,c,t,r]);if(0===h.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});let m=(null==d?void 0:d.limit)||0,x=m>0&&(null==d?void 0:d.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,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(s||x)&&(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:x?"orange.100":"inherit",children:[x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ei.a,{color:"orange.600",alignSelf:"center"})," ",(0,i.jsx)(l.xu,{children:x})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),s&&(0,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>s(n)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},QueryDiffResultView=e=>{var n,t,r,s,c,d;let{run:m,onAddToChecklist:x,viewOptions:f,onViewOptionsChanged:p}=e,g=(0,S.useMemo)(()=>(null==f?void 0:f.primary_keys)||[],[f]),v=(0,S.useMemo)(()=>(null==f?void 0:f.changed_only)||!1,[f]),j=(0,S.useMemo)(()=>(null==f?void 0:f.pinned_columns)||[],[f]),y=(0,S.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:v,primaryKeys:g,onPrimaryKeyChange:e=>{p&&p({...f,primary_keys:e})},pinnedColumns:j,onPinnedColumnsChange:e=>{p&&p({...f,pinned_columns:e})}})},[m,f,v,g,j,p]),C=(0,S.useMemo)(()=>{let e=g.join(", ");return y.invalidPKeyBase&&y.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):y.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):y.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[y.invalidPKeyBase,y.invalidPKeyCurrent,g]);if(0===y.columns.length)return(0,i.jsx)(u.M,{height:"100%",children:"No data"});if(v&&0===y.rows.length)return(0,i.jsx)(u.M,{height:"100%",children:"No change"});let b=(null===(t=m.result)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.limit)||0,k=b>0&&((null==m?void 0:null===(s=m.result)||void 0===s?void 0:null===(r=s.current)||void 0===r?void 0:r.more)||(null==m?void 0:null===(d=m.result)||void 0===d?void 0:null===(c=d.base)||void 0===c?void 0:c.more))?"Warning: Displayed results are limited to ".concat(b.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null;return(0,i.jsxs)(a.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsxs)(a.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:k||C?"orange.100":"inherit",children:[(0,i.jsxs)(h.g,{alignItems:"flex-start",spacing:0,children:[C&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",C]}),k&&(0,i.jsxs)(l.xu,{children:[(0,i.jsx)(ei.a,{color:"orange.600"})," ",k]})]}),(0,i.jsx)(E.L,{minHeight:"32px"}),(0,i.jsx)(ez.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,i.jsx)(o.u,{label:"Add to Checklist",children:(0,i.jsx)(P.h,{variant:"unstyled",size:"sm","aria-label":"Add",icon:(0,i.jsx)(eq.d,{}),onClick:()=>x(m)})})]}),(0,i.jsx)(ScreenshotDataGrid,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:y.columns,rows:y.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})};function LineageDiffView(e){var n;let{check:t}=e,r=(null===(n=t.params)||void 0===n?void 0:n.view_mode)||"";return(0,i.jsx)(a.k,{direction:"column",height:"100%",children:(0,i.jsx)(LineageView,{viewMode:r,interactive:!1,filterNodes:e=>{var n,i;return null===(i=t.params)||void 0===i?void 0:null===(n=i.node_ids)||void 0===n?void 0:n.includes(e)}})})}function CheckDetail_templateObject(){let e=(0,nn._)(["\n ","\n\n ","\n\n "]);return CheckDetail_templateObject=function(){return e},e}let nf={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:i}=e;(0,S.useEffect)(()=>()=>{i(!1),n&&t&&cancelRun(n)},[t,n,i])},CheckDetail=e=>{var n;let{checkId:t}=e,r=(0,H.NL)(),[,c]=(0,eT.TH)(),{successToast:d,failToast:h}=useClipBoardToast(),[x,f]=(0,S.useState)(),[p,g]=(0,S.useState)(),[v,j]=(0,S.useState)(!1),{isLoading:y,error:C,refetch:_,data:R}=(0,ee.a)({queryKey:Z.check(t),queryFn:async()=>getCheck(t),refetchOnMount:!1,staleTime:3e5}),D=R&&(null==R?void 0:R.type)in nf?nf[null==R?void 0:R.type]:void 0,{mutate:T}=(0,eP.D)({mutationFn:e=>updateCheck(t,e),onSuccess:()=>{r.invalidateQueries({queryKey:Z.check(t)}),r.invalidateQueries({queryKey:Z.checks()})}}),{mutate:N}=(0,eP.D)({mutationFn:()=>deleteCheck(t),onSuccess:()=>{r.invalidateQueries({queryKey:Z.checks()}),c("/checks")}}),submitRunFn=async()=>{let e=null==R?void 0:R.type;if(!e)return;let{run_id:n}=await submitRunFromCheck(t,{nowait:!0});for(f(n);;){let e=await waitRun(n,2);if(g(e.progress),e.result||e.error)return j(!1),g(void 0),e}},{data:I,mutate:M,error:z,isIdle:F,isPending:O}=(0,eP.D)({mutationFn:submitRunFn,onSuccess:e=>{_()}}),handleRerun=async()=>{M()},A=(0,S.useCallback)(async()=>{if(j(!0),x)return await cancelRun(x)},[x]);useCancelOnUnmount({runId:x,isPending:O,setAborting:j});let handleCopy=async()=>{if(!R)return;let e=buildMarkdown(R);if(!navigator.clipboard){h("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),d("Copied the check to the clipboard")}catch(e){h("Failed to copy the check to clipboard",e)}},V=(0,S.useCallback)(()=>{let e=null==R?void 0:R.is_checked;T({is_checked:!e})},[null==R?void 0:R.is_checked,T]);if(y)return(0,i.jsx)(u.M,{h:"100%",children:"Loading"});if(C)return(0,i.jsxs)(u.M,{h:"100%",children:["Error: ",C.message]});let B=F?null==R?void 0:R.last_run:I,q=(null==B?void 0:B.run_at)?(0,eB.Z)(new Date(B.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(a.k,{height:"100%",width:"100%",maxHeight:"100%",direction:"column",children:[(0,i.jsxs)(a.k,{p:"0px 16px",alignItems:"center",children:[(0,i.jsx)(CheckBreadcrumb,{name:(null==R?void 0:R.name)||"",setName:e=>{T({name:e})}}),(0,i.jsx)(E.L,{}),(0,i.jsxs)(b.v,{children:[(0,i.jsx)(ef.j,{isRound:!0,as:P.h,icon:(0,i.jsx)(s.J,{as:L.D_A}),variant:"ghost"}),(0,i.jsx)(k.q,{children:(0,i.jsx)(w.s,{icon:(0,i.jsx)(na.p,{}),onClick:()=>N(),children:"Delete"})})]}),q&&(0,i.jsx)(l.xu,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:q}),R&&(null==R?void 0:R.type)in nf&&(0,i.jsx)(o.u,{label:"Rerun",children:(0,i.jsx)(P.h,{isRound:!0,isLoading:O,variant:"ghost","aria-label":"Rerun",icon:(0,i.jsx)(ns.n,{}),onClick:()=>handleRerun()})}),(0,i.jsx)(o.u,{label:"Copy markdown",children:(0,i.jsx)(P.h,{isRound:!0,variant:"ghost","aria-label":"Copy markdown",icon:(0,i.jsx)(ej.T,{}),onClick:()=>handleCopy()})}),(0,i.jsx)(o.u,{label:(null==R?void 0:R.is_checked)?"Mark as unchecked":"Mark as checked",children:(0,i.jsx)(m.z,{size:"sm",colorScheme:(null==R?void 0:R.is_checked)?"green":"gray",leftIcon:(0,i.jsx)(nc.r,{}),onClick:()=>V(),children:(null==R?void 0:R.is_checked)?"Checked":"Unchecked"})})]}),(0,i.jsx)(l.xu,{p:"8px 16px",minHeight:"100px",children:(0,i.jsx)(CheckDescription,{value:null==R?void 0:R.description,onChange:e=>{T({description:e})}},null==R?void 0:R.check_id)}),((null==R?void 0:R.type)==="query"||(null==R?void 0:R.type)==="query_diff")&&(0,i.jsx)(nt.U,{defaultIndex:[],allowToggle:!0,children:(0,i.jsxs)(ni.Q,{children:[(0,i.jsxs)(nr.K,{children:["query",(0,i.jsx)(nl.X,{})]}),(0,i.jsx)(no.H,{children:(0,i.jsx)(l.xu,{height:"400px",width:"100%",border:"lightgray 1px solid ",children:(0,i.jsx)(query_SqlEditor,{value:(null===(n=null==R?void 0:R.params)||void 0===n?void 0:n.sql_template)||"",options:{readOnly:!0}})})})]})}),(0,i.jsxs)(l.xu,{style:{contain:"size"},flex:"1 1 0%",children:[D&&(0,i.jsx)(RunView,{isPending:O,isAborting:v,run:B,error:z,progress:p,RunResultView:D,viewOptions:null==R?void 0:R.view_options,onViewOptionsChanged:e=>{T({view_options:e})},onCancel:A}),R&&"schema_diff"===R.type&&(0,i.jsx)(SchemaDiffView,{check:R}),R&&"lineage_diff"===R.type&&(0,i.jsx)(LineageDiffView,{check:R})]})]})};function buildMarkdown(e){return(0,nx.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 np=t(79648),ng=t(38505);let ChecklistItem=e=>{let{check:n,selected:t,onSelect:r}=e,o=(0,H.NL)(),c=n.check_id,{mutate:d}=(0,eP.D)({mutationFn:e=>updateCheck(c,e),onSuccess:()=>{o.invalidateQueries({queryKey:Z.check(c)}),o.invalidateQueries({queryKey:Z.checks()})}}),u=(e=>{switch(e){case"schema_diff":return e6.uhn;case"query":case"query_diff":return e6.r2i;case"value_diff":return e6.pRi;case"profile_diff":return e6.KA6;case"row_count_diff":return B.SwK;case"lineage_diff":return e6.Ks7;case"top_k_diff":return np.Pkc;case"histogram_diff":return e6.dku;default:return e6.WzH}})(n.type);return(0,i.jsxs)(a.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"gray.200"},bg:t?"gray.100":"inherit",onClick:()=>r(n.check_id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:u}),(0,i.jsx)(l.xu,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n.name}),n.is_checked&&(0,i.jsx)(s.J,{color:"green",as:I.FJM})]})},CheckList=e=>{let{checks:n,selectedItem:t,onCheckSelected:r,onChecksReordered:l}=e;return(0,i.jsx)(ng.Z5,{onDragEnd:e=>{e.destination&&l(e.source.index,e.destination.index)},children:(0,i.jsx)(ng.bK,{droppableId:"checklist",children:e=>(0,i.jsxs)(h.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",children:[n.map((e,n)=>(0,i.jsx)(ng._l,{draggableId:e.check_id,index:n,children:n=>(0,i.jsx)(a.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,i.jsx)(ChecklistItem,{check:e,selected:e.check_id===t,onSelect:r},e.check_id)})},e.check_id)),e.placeholder]})})})};var nv=t(73672),nj=t(83561);function CheckListInitLoader(){let e=(0,eb.p)(),n=(0,H.NL)(),t=(0,S.useRef)(null),[r,l]=(0,S.useState)(null),o=(0,S.useCallback)(async()=>{if(r)try{let{checks:t}=await loadChecks(r);n.invalidateQueries({queryKey:Z.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,r]);return(0,S.useEffect)(()=>{r&&o()},[r,o]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(m.z,{onClick:()=>{t.current&&t.current.click()},children:"Load a checklist"}),(0,i.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,eb.p)(),n=(0,H.NL)(),t=(0,S.useRef)(null),r=(0,S.useRef)(null),[l,d]=(0,S.useState)(null),{isOpen:u,onOpen:h,onClose:x}=(0,c.q)(),[,p]=(0,eT.TH)(),g=(0,S.useCallback)(async()=>{if(l){try{let{checks:t}=await loadChecks(l);await n.invalidateQueries({queryKey:Z.checks()}),p("/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})}x()}},[n,l,e,x,p]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o.u,{label:"Load checklist",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Load checks",mr:"10px",onClick:()=>{t.current&&t.current.click()},icon:(0,i.jsx)(s.J,{pt:"10px",as:nj._mA,boxSize:"2em"})})}),(0,i.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&&(d(e.target.files[0]),h())}}),(0,i.jsx)(nv.a,{isOpen:u,leastDestructiveRef:r,onClose:x,size:"lg",children:(0,i.jsx)(v.Z,{children:(0,i.jsxs)(nv._,{children:[(0,i.jsx)(es.x,{fontSize:"lg",fontWeight:"bold",children:"Load checklist"}),(0,i.jsx)(C.f,{children:(0,i.jsxs)(a.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,i.jsxs)(a.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(et.s,{color:"red.600"}),(0,i.jsx)(f.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,i.jsx)(a.k,{children:(0,i.jsxs)(f.x,{children:["The checklist will be"," ",(0,i.jsx)(f.x,{as:"span",fontWeight:"600",children:"overwritten"})," ","by the loaded checklist"]})})]})}),(0,i.jsxs)(eV.m,{children:[(0,i.jsx)(m.z,{ref:r,onClick:x,children:"Cancel"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:g,ml:"5px",children:"Load"})]})]})})})]})}var ny=t(472),nC=t(16062),nb=t(68686),nk=t.n(nb);function CheckListExporter(){let e=(0,eb.p)(),handleExport=async()=>{try{let e=await exportChecks(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),i=new Date,r="recce-state-".concat((0,nC.ZP)(i,"yyyy-MM-dd-HH-mm-ss"),".json");nk()(t,r)}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,i.jsx)(o.u,{label:"Export checklist",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Export checks",onClick:handleExport,icon:(0,i.jsx)(ny._,{})})})}function CheckPage_templateObject(){let e=(0,nn._)(["\n ","\n\n ","\n\n "]);return CheckPage_templateObject=function(){return e},e}let CheckPage=()=>{let{isDemoSite:e}=useLineageGraphsContext(),[,n]=(0,eT.TH)(),[,t]=(0,eT.yj)("/checks/:checkId"),r=(0,H.NL)(),{successToast:s,failToast:c}=useClipBoardToast(),d=null==t?void 0:t.checkId,{isLoading:f,error:p,data:g,status:v}=(0,ee.a)({queryKey:Z.checks(),queryFn:listChecks,refetchOnMount:!0}),j=(0,S.useCallback)(e=>{n("/checks/".concat(e))},[n]),[y,C]=(0,S.useState)(g||[]),{mutate:b}=(0,eP.D)({mutationFn:e=>reorderChecks(e),onSuccess:()=>{r.invalidateQueries({queryKey:Z.checks()})}}),k=(0,S.useCallback)((e,n)=>{let t=[...y],[i]=t.splice(e,1);t.splice(n,0,i),b({source:e,destination:n}),C(t)},[y,C,b]),w=(0,S.useCallback)(async()=>{let e=await createSimpleCheck();r.invalidateQueries({queryKey:Z.checks()}),j(e.check_id)},[r,j]);return((0,S.useEffect)(()=>{"success"===v&&(!d&&g.length>0&&n("/checks/".concat(g[0].check_id)),C(g))},[v,d,g,C,n]),f)?(0,i.jsx)(i.Fragment,{children:"Loading"}):p?(0,i.jsxs)(i.Fragment,{children:["Error: ",p.message]}):(null==g?void 0:g.length)?(0,i.jsxs)(a.k,{height:"100%",children:[(0,i.jsx)(l.xu,{flex:"0 0 400px",borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,i.jsxs)(h.g,{spacing:0,align:"flex-end",h:"100%",children:[(0,i.jsxs)(x.U,{gap:"0px",children:[(0,i.jsx)(o.u,{label:"Create a simple check",children:(0,i.jsx)(P.h,{variant:"unstyled","aria-label":"Create a simple check",onClick:w,icon:(0,i.jsx)(eq.d,{})})}),(0,i.jsx)(o.u,{label:"Copy checklist to the clipboard",children:(0,i.jsx)(P.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,i.jsx)(ej.T,{})})}),!e&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(CheckListExporter,{}),(0,i.jsx)(CheckListLoader,{})]})]}),(0,i.jsx)(eH.i,{mb:"8px"}),(0,i.jsx)(CheckList,{checks:y,selectedItem:d,onCheckSelected:j,onChecksReordered:k})]})}),(0,i.jsx)(l.xu,{flex:"1",height:"100%",width:"calc(100% - 400px)",children:(0,i.jsx)(eT.rs,{children:(0,i.jsx)(eT.AW,{path:"/checks/:checkId",children:e=>(0,i.jsx)(CheckDetail,{checkId:e.checkId},e.checkId)})})})]}):(0,i.jsx)(u.M,{h:"100%",children:(0,i.jsxs)(h.g,{children:[(0,i.jsx)(l.xu,{children:"No checks"}),(0,i.jsxs)(a.k,{gap:"5",children:[(0,i.jsx)(m.z,{colorScheme:"blue",onClick:w,children:"Create a simple check"}),!e&&(0,i.jsx)(CheckListInitLoader,{})]})]})})};function CheckPage_buildMarkdown(e){let n=e.map(e=>(0,nx.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,r]=(0,S.useState)(),[o,s]=(0,S.useState)(),[c,d]=(0,S.useState)({}),u=(0,H.NL)(),[,h]=(0,eT.TH)(),queryFn=async n=>{r(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,eP.D)({mutationFn:queryFn,onSuccess:e=>{d({})}}),v=(0,S.useCallback)(async()=>{if(o)return await cancelRun(o)},[o]),j=(0,S.useCallback)(async e=>{if(!(null==e?void 0:e.run_id))return;let n=await checks_createCheckByRun(e.run_id,c);u.invalidateQueries({queryKey:Z.checks()}),h("/checks/".concat(n.check_id))},[h,c,u]);return!g&&(null==x?void 0:x.run_id)&&(null==x||x.error),(0,i.jsxs)(a.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(a.k,{justifyContent:"right",padding:"5px",gap:"5px",children:[(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>f("query_diff"),isDisabled:g,size:"sm",children:"Run Diff"}),(0,i.jsx)(m.z,{colorScheme:"blue",onClick:()=>f("query"),isDisabled:g,size:"sm",children:"Run"})]}),(0,i.jsx)(l.xu,{flex:"1",border:"1px solid #CBD5E0",height:"200px",width:"100%",children:(0,i.jsx)(query_SqlEditor,{value:e,onChange:n,onRun:()=>f("query"),onRunDiff:()=>f("query_diff")})}),(0,i.jsx)(a.k,{height:"50vh",direction:"column",children:"query"===t?(0,i.jsx)(RunView,{run:x,error:p,isPending:g,onCancel:v,children:e=>(0,i.jsx)(QueryResultView,{...e,onAddToChecklist:j})},o):(0,i.jsx)(RunView,{isPending:g,run:x,error:p,viewOptions:c,onViewOptionsChanged:d,onCancel:v,children:e=>(0,i.jsx)(QueryDiffResultView,{...e,onAddToChecklist:j})},o)})]})};var nw=t(72952);let hashNavigate=e=>(0,nw.c4)("#!"+e),useHashLocation=()=>{let e=(0,nw.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr");return[e,hashNavigate]};var nS=t(82017),n_=t(41546);let RunPage=e=>{let{runId:n}=e,{isPending:t,error:r,data:l}=(0,ee.a)({queryKey:Z.run(n),queryFn:async()=>waitRun(n)});return(0,i.jsx)(RunView,{isPending:t,error:r,run:l,RunResultView:ValueDiffResultView})};var nR=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,[r]=(0,eT.yj)(t);return(0,i.jsx)(l.xu,{display:r?"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,i.jsxs)(a.k,{gap:"5px",minHeight:"35px",alignItems:"center",justifyContent:"center",bg:"orange.300",children:[(0,i.jsx)(et.s,{color:"orange.600"}),(0,i.jsxs)(f.x,{children:["Please check"," ",(0,i.jsx)(eK.r,{textDecoration:"underline",fontWeight:"600",href:n,isExternal:!0,children:"this Pull Request"})," ","comment for context about this Recce instance"]})]}):(0,i.jsx)(i.Fragment,{})}function NavBar(){let[e,n]=(0,eT.TH)(),t=useVersionNumber(),r=[["Lineage","/lineage"],["Query","/query"],["Checklist","/checks"]],o=eA().findIndex(r,n=>{let[,t]=n;return e.startsWith(t)});return(0,i.jsx)(ed.m,{index:o,children:(0,i.jsxs)(eu.t,{children:[r.map(e=>{let[t,r]=e;return(0,i.jsx)(eh.O,{onClick:()=>{n(r)},children:t},t)}),(0,i.jsx)(l.xu,{position:"absolute",right:"0",top:"0",p:"2",color:"gray.500",children:t})]})})}function Home(){(0,S.useLayoutEffect)(()=>{let e=getCookie("recce_user_id");if(e&&nR.env.AMPLITUDE_API_KEY)try{ne.S1(nR.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,i.jsx)(n_.Z,{theme:e,children:(0,i.jsx)(e7.x,{children:(0,i.jsx)(H.aH,{client:J,children:(0,i.jsx)(eT.F0,{hook:useHashLocation,children:(0,i.jsx)(RecceContextProvider,{children:(0,i.jsxs)(a.k,{direction:"column",height:"100vh",children:[(0,i.jsx)(TopBar,{}),(0,i.jsx)(NavBar,{}),(0,i.jsxs)(l.xu,{p:0,overflow:"auto",flex:"1",style:{contain:"size"},children:[(0,i.jsx)(RouteAlwaysMount,{path:"/lineage",children:(0,i.jsx)(LineageView,{})}),(0,i.jsxs)(eT.rs,{children:[(0,i.jsx)(eT.AW,{path:"/query",children:(0,i.jsx)(QueryPage,{})}),(0,i.jsx)(eT.AW,{path:"/checks/:slug*",children:(0,i.jsx)(CheckPage,{})}),(0,i.jsx)(eT.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,i.jsx)(RunPage,{runId:n})}}),(0,i.jsx)(eT.AW,{path:"/ssr",children:(0,i.jsx)(i.Fragment,{children:"Loading"})}),(0,i.jsx)(eT.AW,{children:(0,i.jsx)(eT.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,103,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/W8VlPJJ-9OfeCU3fVV69c/_buildManifest.js b/recce/data/_next/static/rbbNCX1OWJ9HIgCf8P_E0/_buildManifest.js
similarity index 100%
rename from recce/data/_next/static/W8VlPJJ-9OfeCU3fVV69c/_buildManifest.js
rename to recce/data/_next/static/rbbNCX1OWJ9HIgCf8P_E0/_buildManifest.js
diff --git a/recce/data/_next/static/W8VlPJJ-9OfeCU3fVV69c/_ssgManifest.js b/recce/data/_next/static/rbbNCX1OWJ9HIgCf8P_E0/_ssgManifest.js
similarity index 100%
rename from recce/data/_next/static/W8VlPJJ-9OfeCU3fVV69c/_ssgManifest.js
rename to recce/data/_next/static/rbbNCX1OWJ9HIgCf8P_E0/_ssgManifest.js
diff --git a/recce/data/index.html b/recce/data/index.html
index a79f1ebd..61a49bd9 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;}}