(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{81159:(e,t,a)=>{Promise.resolve().then(a.bind(a,39158))},39158:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>x});var s=a(57437),r=a(2265),l=a(16463),n=a(92694),i=a(35657),o=a(3274),c=a(37440),d=a(89669);let u=(0,a(78030).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),m=[{key:"created_time",label:"Created"},{key:"last_edited_time",label:"Last Updated"},{key:"model_name",label:"Model"},{key:"prompt_func",label:"Prompter Function"},{key:"response_format",label:"Response Format"}];function h(){let[e,t]=(0,r.useState)([]),[a,h]=(0,r.useState)(!0),[x,f]=(0,r.useState)(null),[g,p]=(0,r.useState)(!0),[y,w]=(0,r.useState)(null),[_,j]=(0,r.useState)(new Set),N=(0,l.useRouter)(),{toast:b}=(0,i.pm)(),[k,v]=(0,r.useState)(null),C=(0,r.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let a=y&&!e?"?lastCreatedTime=".concat(y):"",s=await fetch("/api/runs".concat(a)),r=await s.json();if(404===s.status&&"NO_CACHE_DB"===r.error){v({message:r.message,path:r.path}),p(!1),h(!1);return}if(!s.ok)throw Error("HTTP error! status: ".concat(s.status));if(!Array.isArray(r))throw Error("Data is not in the expected format");if(r.length>0){if(e)t(r),w(r[0].created_time);else if(r.length>0){let e=new Set(r.map(e=>e.run_hash));j(e),t(e=>[...r,...e]),w(r[0].created_time),b({title:"New runs available",description:"".concat(r.length," new runs added")}),setTimeout(()=>{j(new Set)},5e3)}}}catch(e){console.error("Failed to fetch runs:",e),f(e instanceof Error?e.message:"Failed to fetch runs"),b({variant:"destructive",title:"Error",description:"Failed to fetch new runs"})}finally{h(!1)}},[y,b]);return((0,r.useEffect)(()=>{C(!0)},[C]),(0,r.useEffect)(()=>{if(!g)return;let e=setInterval(()=>{C(!1)},5e3);return()=>clearInterval(e)},[g,C]),x)?(0,s.jsxs)("div",{children:["Error: ",x]}):(0,s.jsxs)("div",{className:"min-h-screen bg-background text-foreground overflow-x-hidden",children:[(0,s.jsx)(d.h,{isLoading:a,isPolling:g,onTogglePolling:()=>p(e=>!e),pollingText:"Polling for updates...",loadingText:"Loading runs..."}),(0,s.jsxs)("main",{className:"container mx-auto p-4",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h2",{className:"text-2xl font-semibold text-foreground",children:"Curator Runs History"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"View and analyze your past Bespoke Curator runs"})]}),k?(0,s.jsx)("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 dark:border-yellow-900/50 dark:bg-yellow-900/20 p-4 my-4",children:(0,s.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,s.jsx)(u,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-500 mt-0.5"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-medium text-yellow-600 dark:text-yellow-500",children:"No Cache Database Found"}),(0,s.jsx)("p",{className:"text-sm text-yellow-600 dark:text-yellow-400 mt-1",children:k.message}),(0,s.jsxs)("p",{className:"text-xs text-yellow-500 dark:text-yellow-400 mt-2 font-mono",children:["Expected location: ",k.path]})]})]})}):a?(0,s.jsx)("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)(o.Z,{className:"h-8 w-8 animate-spin"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"Loading runs..."})]})}):0===e.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:(0,s.jsx)("p",{className:"text-muted-foreground",children:"No runs found"})}):(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsx)(n.d,{columns:m,data:e,getRowKey:e=>e.id,getCellContent:(e,t)=>{switch(t){case"created_time":return new Date(e.created_time).toLocaleString();case"last_edited_time":return"-"===e.last_edited_time?"-":new Date(e.last_edited_time).toLocaleString();default:return e[t]}},onRowClick:e=>N.push("/dataset/".concat(e.run_hash,"?batchMode=").concat(e.batch_mode)),truncateConfig:{enabled:!0,maxLength:100},pageSize:10,rowProps:e=>({className:(0,c.cn)(_.has(e.id)&&"bg-success/30 animate-highlight","transition-colors duration-300")})})})]})]})}function x(){return(0,s.jsx)(h,{})}}},e=>{var t=t=>e(e.s=t);e.O(0,[547,883,130,215,744],()=>t(81159)),_N_E=e.O()}]);