@erdoai/ui 0.1.49 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ ${n.map(([a,s])=>{let i=s.theme?.[o]||s.color;return i?` --color-${a}: ${i};`:n
4
4
  `)}
5
5
  }
6
6
  `).join(`
7
- `)}}):null},on=Dt.Tooltip;function an({active:t,payload:e,className:n,indicator:o="dot",hideLabel:r=false,hideIndicator:a=false,label:s,labelFormatter:i,labelClassName:c,formatter:l,color:u,nameKey:p,labelKey:d}){let{config:m}=zn(),f=ut.useMemo(()=>{if(r||!e?.length)return null;let[h]=e,k=`${d||h?.dataKey||h?.name||"value"}`,y=rn(m,h,k),b=!d&&typeof s=="string"?m[s]?.label||s:y?.label;return i?jsx("div",{className:q("font-medium",c),children:i(b,e)}):b?jsx("div",{className:q("font-medium",c),children:b}):null},[s,i,e,r,c,m,d]);if(!t||!e?.length)return null;let g=e.length===1&&o!=="dot";return jsxs("div",{className:q("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",n),children:[g?null:f,jsx("div",{className:"grid gap-1.5",children:e.map((h,k)=>{let y=`${p||h.name||h.dataKey||"value"}`,b=rn(m,h,y),N=u||h.payload.fill||h.color;return jsx("div",{className:q("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",o==="dot"&&"items-center"),children:l&&h?.value!==void 0&&h.name?l(h.value,h.name,h,k,h.payload):jsxs(Fragment,{children:[b?.icon?jsx(b.icon,{}):!a&&jsx("div",{className:q("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":o==="dot","w-1":o==="line","w-0 border-[1.5px] border-dashed bg-transparent":o==="dashed","my-0.5":g&&o==="dashed"}),style:{"--color-bg":N,"--color-border":N}}),jsxs("div",{className:q("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[jsxs("div",{className:"grid gap-1.5",children:[g?f:null,jsx("span",{className:"text-muted-foreground",children:b?.label||h.name})]}),h.value&&jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:h.value.toLocaleString()})]})]})},h.dataKey)})})]})}var sn=Dt.Legend;function ln({className:t,hideIcon:e=false,payload:n,verticalAlign:o="bottom",nameKey:r}){let{config:a}=zn();return n?.length?jsx("div",{className:q("flex items-center justify-center gap-4",o==="top"?"pb-3":"pt-3",t),children:n.map(s=>{let i=`${r||s.dataKey||"value"}`,c=rn(a,s,i);return jsxs("div",{className:q("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),children:[c?.icon&&!e?jsx(c.icon,{}):jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:s.color}}),c?.label]},s.value)})}):null}function rn(t,e,n){if(typeof e!="object"||e===null)return;let o="payload"in e&&typeof e.payload=="object"&&e.payload!==null?e.payload:void 0,r=n;return n in e&&typeof e[n]=="string"?r=e[n]:o&&n in o&&typeof o[n]=="string"&&(r=o[n]),r in t?t[r]:t[n]}function tt(t,e,n){if(t==null)return "";if(n==="date"){let o=Zn(t);if(o&&e)try{let r=e;e==="%Y%m%d"?r="%Y-%m-%d":e==="%d%m%Y"?r="%d-%m-%Y":e==="%m%d%Y"&&(r="%m-%d-%Y");let a=r.match(/%./g)||[],s="aAbBcdejHILmMpSUwWxXyYZ%";return a.some(l=>{let u=l.charAt(1);return !s.includes(u)})||a.length===0?(console.warn(`Invalid date format directives in: ${e}. Using default format.`),o.toISOString().split("T")[0]):utcFormat(r)(o)}catch(r){return console.warn(`Invalid date format: ${e}. Error: ${r}. Falling back to default.`),o.toISOString().split("T")[0]}if(o){let r=o.toISOString();return r.endsWith("T00:00:00.000Z")?r.split("T")[0]:o.toISOString().replace("T"," ").replace(".000Z"," UTC")}return String(t)}if(n==="number"){let o=typeof t=="string"?parseFloat(t.replace(/,/g,"")):t;if(isNaN(o))return String(t);let r=e;if(e&&(r=e.replace(/(\.\d+)f%/,"$1%")),!r)return Math.abs(o)>=1e3?format(",.0f")(o):Math.abs(o)>=100?format(".1f")(o):Math.abs(o)>=10?format(".2f")(o):Math.abs(o)>=1?format(".3f")(o):format(".3g")(o);if(r.includes("%"))return o>=0&&o<=1?format(r)(o):format(r)(o/100);try{return format(r)(o)}catch(a){return console.warn(`Error formatting number with format '${r}': ${a}. Falling back to default.`),Math.abs(o)>=1e3?format(",.0f")(o):Math.abs(o)>=1?format(".2f")(o):format(".3g")(o)}}return String(t)}function Zn(t){if(!t)return null;if(t instanceof Date)return isValid(t)?t:null;if(typeof t=="number"){let n=new Date(t);return isValid(n)?n:null}if(typeof t=="string"){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=new Date(t+"T00:00:00.000Z");if(isValid(r))return r}let o=["yyyy-MM-dd","yyyyMMdd","yyyy-MM-dd'T'HH:mm:ss","yyyyMMddHHmmss","MM/dd/yyyy","dd/MM/yyyy"];for(let r of o){let a=parse(t,r,new Date);if(isValid(a))return a}}let e=new Date(t);return isValid(e)?e:null}function ye({onZoomChange:t}={}){let[e,n]=useState({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false}),[o,r]=useState({x:[null,null],y:[null,null]}),a=useCallback(u=>{!u?.xValue||!u?.yValue||n(p=>({...p,refAreaLeft:u.xValue,refAreaTop:u.yValue,zooming:true}));},[]),s=useCallback(u=>{!u?.xValue||!u?.yValue||!e.zooming||n(p=>({...p,refAreaRight:u.xValue,refAreaBottom:u.yValue}));},[e.zooming]),i=useCallback(()=>{if(!e.refAreaLeft||!e.refAreaRight||!e.refAreaTop||!e.refAreaBottom){n({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false});return}let[u,p]=[Math.min(e.refAreaLeft,e.refAreaRight),Math.max(e.refAreaLeft,e.refAreaRight)],[d,m]=[Math.min(e.refAreaTop,e.refAreaBottom),Math.max(e.refAreaTop,e.refAreaBottom)],f={x:[u,p],y:[d,m]};r(f),t?.(f),n({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false});},[e,t]),c=useCallback(()=>{let u={x:[null,null],y:[null,null]};r(u),t?.(u);},[t]),l=useMemo(()=>({onZoomStart:a,onZoomMove:s,onZoomEnd:i,onResetZoom:c}),[a,s,i,c]);return {zoomState:e,customDomain:o,handlers:l}}function Xn(t){let e={max:null,min:null};if(t.maxValue)if(t.type==="number"){let n=parseFloat(t.maxValue);isNaN(n)?console.warn(`Error parsing max value ${t.maxValue}. Falling back to default.`):e.max=n;}else t.type==="date"?typeof t.maxValue=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.maxValue)?e.max=new Date(t.maxValue+"T00:00:00.000Z").getTime():e.max=new Date(t.maxValue).getTime():e.max=t.maxValue;if(t.minValue)if(t.type==="number"){let n=parseFloat(t.minValue);isNaN(n)?console.warn(`Error parsing min value ${t.minValue}. Falling back to default.`):e.min=n;}else t.type==="date"?typeof t.minValue=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.minValue)?e.min=new Date(t.minValue+"T00:00:00.000Z").getTime():e.min=new Date(t.minValue).getTime():e.min=t.minValue;return e}function Tt(t,e,n){return tt(t,e,n)}function vo({title:t,subtitle:e,data:n,displayConfig:o,dataConfig:r,ChartComponent:a,PointComponent:s,disableAnimation:i,onZoomChange:c,stacked:l,enableDownload:u=true,onDownloadSuccess:p,onDownloadError:d,className:m,chartContainerClassName:f,downloadButtonClassName:g,resetZoomButtonClassName:h}){let{zoomState:k,customDomain:y,handlers:b}=ye({onZoomChange:c}),N=useCallback(x=>{let w=`${(t||"chart").toLowerCase().replace(/\s+/g,"-")}.png`,R=document.createElement("a");R.download=w,R.href=x,R.click(),p?.(w);},[t,p]),v=useCallback(x=>{console.error("Error converting chart to image:",x),d?.(x);},[d]),[{isLoading:D},I,B]=useToPng({onSuccess:N,onError:v}),yt=useCallback(async()=>{I();},[I]),z=useMemo(()=>Xn(r.xAxis),[r.xAxis]),F=useMemo(()=>r.yAxes.map(x=>Xn(x)),[r.yAxes]),ht=useMemo(()=>n?r.chartType==="histogram"?n.map(x=>({[r.xAxis.key]:(x.binStart+x.binEnd)/2,frequency:x.frequency,binStart:x.binStart,binEnd:x.binEnd})):r.xAxis.type==="number"?n.filter(x=>!isNaN(x[r.xAxis.key])):r.xAxis.type==="date"?n.filter(x=>!isNaN(x[r.xAxis.key])):n:[],[n,r.xAxis.key,r.chartType,r.xAxis.type]),V=useCallback((x,w)=>{if(!x?.length)return {min:null,max:null};let R=x.map(J=>Number(J[w])).filter(J=>!isNaN(J));return {min:Math.min(...R),max:Math.max(...R)}},[]),me=useMemo(()=>({x:y.x[0]!==null&&y.x[1]!==null?[y.x[0],y.x[1]]:(()=>{if(z.min!==null&&z.max!==null)return [z.min,z.max];let x=V(ht,r.xAxis.key);return [x.min??"auto",x.max??"auto"]})(),y:r.yAxes.map((x,w)=>{if(y.y[0]!==null&&y.y[1]!==null)return [y.y[0],y.y[1]];let J=r.series.filter(A=>(A.axisIndex||0)===w).reduce((A,it)=>{let O=V(ht,it.key);return {min:A.min===null?O.min:O.min===null?A.min:Math.min(A.min,O.min),max:A.max===null?O.max:O.max===null?A.max:Math.max(A.max,O.max)}},{min:null,max:null});if(x.type==="number"&&x.maxValue){let A=parseFloat(x.maxValue);if(J.max===null||A<=J.max*1.5)return [F[w].min??J.min??"auto",F[w].max??J.max??"auto"]}return [F[w].min??J.min??"auto",F[w].max??J.max??"auto"]})}),[y.x,y.y,z,F,r.series,r.yAxes,r.xAxis.key,ht,V]),Xt=useCallback((x,w,R)=>{if(R.dataKey===r.xAxis.key)return Tt(x,r.xAxis.format,r.xAxis.type);let A=r.series.find(it=>it.key===R.dataKey)?.name||String(w).replace(/^dataset_\d+_/,"");if(r.chartType==="histogram"){let it=R.payload;if(it.binStart!==void 0){let O=Tt(it.binStart,r.xAxis.format,r.xAxis.type),te=Tt(it.binEnd,r.xAxis.format,r.xAxis.type);return `Count: ${x} (${O} - ${te})`}}return `${A}: ${x}`},[r.xAxis,r.series,r.chartType]),[fe,C]=useState(false);useEffect(()=>{let x=setTimeout(()=>{C(true);},1700);return ()=>clearTimeout(x)},[]);let S=useCallback((x,w)=>{if(w&&w.length>0){let R=w[0].payload[r.xAxis.key],J=Tt(R,r.xAxis.format,r.xAxis.type);return jsxs("div",{className:"flex flex-col",children:[jsx("span",{children:r.xAxis.label}),jsx("span",{className:"font-mono tabular-nums",children:J})]})}return x},[r.xAxis.key,r.xAxis.format,r.xAxis.type,r.xAxis.label]),P=useCallback(x=>jsx(an,{...x,formatter:Xt,labelFormatter:S}),[Xt,S]),W=useCallback(x=>jsx(ln,{...x}),[]),K=useMemo(()=>!!(i||(n?.length||0)>100||fe),[i,n?.length,fe]);return jsxs("div",{className:m||"w-full items-center mt-0 flex flex-col gap-0",children:[(t||u)&&jsxs("div",{className:"w-full items-center mb-2 relative",children:[t&&jsx("h2",{className:"text-center text-base pt-0 mt-0 mb-2",children:t}),u&&jsx("button",{onClick:yt,disabled:D,className:g||"text-sm text-gray-500 hover:text-gray-700 disabled:opacity-50 h-8 absolute right-0 top-[-5px] px-2 py-1 border rounded hover:bg-gray-50",title:"Download chart as PNG",children:jsx(Download,{className:"w-4 h-4"})})]}),e&&jsx("p",{className:"text-center text-sm text-muted-foreground mb-2",children:e}),jsx(ee,{ref:B,config:o,className:f||"w-full border border-border/50 p-4 rounded-md",debounceResize:true,children:jsxs(a,{accessibilityLayer:true,data:ht,isAnimationActive:!K,onMouseDown:b.onZoomStart,onMouseMove:b.onZoomMove,onMouseUp:b.onZoomEnd,onDoubleClick:b.onResetZoom,style:{userSelect:"none",cursor:"crosshair"},children:[jsx(CartesianGrid,{vertical:false}),jsx(XAxis,{dataKey:r.xAxis.key,domain:me.x,type:r.xAxis.type==="date"||!r.xAxis.type?"number":r.xAxis.type,tickFormatter:x=>Tt(x,r.xAxis.format,r.xAxis.type),tickLine:false,tickMargin:10,height:50,axisLine:false,allowDataOverflow:true,children:jsx(Label,{value:r.xAxis.label,position:"bottom",offset:-10,style:{textAnchor:"middle"}})}),r.yAxes.map((x,w)=>jsx(YAxis,{yAxisId:w,orientation:w===0?"left":"right",domain:l?void 0:me.y[w],type:x.type==="date"||!x.type?"number":x.type,tickFormatter:R=>Tt(R,x.format,x.type),allowDataOverflow:true,children:jsx(Label,{value:x.label,position:w===0?"insideLeft":"insideRight",angle:-90,style:{textAnchor:"middle"}})},`y-axis-${x.key}`)),jsx(on,{content:P}),jsx(sn,{content:W,verticalAlign:"top"}),r.series.map(x=>jsx(s,{dataKey:x.key,yAxisId:x.axisIndex||0,fill:x.color||"blue",stroke:x.color||"blue",dot:{fill:x.color||"blue",stroke:x.color||"blue"},radius:4,name:x.name,isAnimationActive:!K,animationDuration:1500,animationBegin:0,stackId:r.chartType==="bar"&&l?"stack":void 0},`${x.key}-${l?"stacked":"unstacked"}`)),k.refAreaLeft&&k.refAreaRight&&k.refAreaTop&&k.refAreaBottom&&jsx(ReferenceArea,{x1:k.refAreaLeft,x2:k.refAreaRight,y1:k.refAreaTop,y2:k.refAreaBottom,strokeOpacity:.2,stroke:"currentColor",fill:"currentColor",fillOpacity:.02,style:{pointerEvents:"none"}})]})}),y.x[0]!==null&&jsx("button",{onClick:b.onResetZoom,className:h||"text-sm text-gray-500 hover:text-gray-700 mt-2 px-3 py-1 border rounded hover:bg-gray-50",children:"Reset Zoom"})]})}function et(t){return jsx(xt,{fallback:jsx("div",{className:t.errorClassName||"text-red-500",children:"Failed to load chart"}),children:jsx(vo,{...t})})}function kt(t){return jsx(et,{...t,ChartComponent:BarChart,PointComponent:Bar})}function Bt(t){return jsx(et,{...t,ChartComponent:LineChart,PointComponent:Line})}var Ao=(t,e,n)=>{let o=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,a=parseInt(t.slice(5,7),16)/255,s=Math.max(o,r,a),i=Math.min(o,r,a),c,l,u=(s+i)/2;if(s===i)c=l=0;else {let g=s-i;switch(l=u>.5?g/(2-s-i):g/(s+i),s){case o:c=(r-a)/g+(r<a?6:0);break;case r:c=(a-o)/g+2;break;case a:c=(o-r)/g+4;break;default:c=0;}c/=6;}let p=e/n,d=c*360+(p*40-20),m=Math.min(100,l*100+p*25),f=Math.max(35,Math.min(65,u*100-p*20));return `hsl(${d}, ${m}%, ${f}%)`};function Oo({title:t,subtitle:e,data:n,displayConfig:o,dataConfig:r,className:a,chartContainerClassName:s}){let i=r.series[0]?.color||"blue",c=r.yAxes[0]?.format,l=r.yAxes[0]?.type||"number",u=useMemo(()=>n.reduce((p,d)=>(r.series.forEach(m=>{let f=m.key,g=String(d[r.xAxis.key]||"Unknown"),h=parseFloat(d[f]||"0");isNaN(h)||p.push({name:g,value:h,seriesId:f,displayName:g});}),p),[]).sort((p,d)=>d.value-p.value),[n,r.series,r.xAxis.key]);return jsxs("div",{className:a||"items-center",children:[jsx("h2",{className:"text-center text-base mb-2",children:t}),e&&jsx("p",{className:"text-center text-sm text-muted-foreground mb-2",children:e}),jsx(ee,{config:o,className:s||"w-full border border-border/50 rounded-md",children:jsxs(PieChart,{width:400,height:400,children:[jsx(Pie,{data:u,dataKey:"value",nameKey:"displayName",cx:"50%",cy:"50%",outerRadius:150,label:p=>`${p.displayName}: ${tt(p.value,c,l)}`,children:u.map((p,d)=>jsx(Cell,{fill:d===0?i:Ao(i,d,u.length)},`cell-${p.name}`))}),jsx(Tooltip,{formatter:(p,d)=>[tt(p,c,l),d]}),jsx(Legend,{})]})})]})}function Pt(t){return jsx(xt,{fallback:jsx("div",{className:"text-red-500",children:"Failed to load chart"}),children:jsx(Oo,{...t})})}function Rt(t){return jsx(et,{...t,ChartComponent:ScatterChart,PointComponent:Scatter})}var Go=t=>{let{cx:e,cy:n,payload:o,xAxis:r,yAxis:a}=t,s=o.value||o.z||0,c=`hsl(${240-Math.min(1,Math.max(0,s/100))*240}, 70%, 50%)`,l=r.scale.bandwidth?r.scale.bandwidth():20,u=a.scale.bandwidth?a.scale.bandwidth():20;return jsx("rect",{x:e-l/2,y:n-u/2,width:l,height:u,fill:c,fillOpacity:.8,stroke:"#fff",strokeWidth:1})},Fo=t=>jsx(Scatter,{...t,shape:Go});function At(t){return jsx(et,{...t,ChartComponent:ScatterChart,PointComponent:Fo})}async function rr(t,e,n,o,r){if(t.dataFetcher)return t.dataFetcher.fetchDatasetContents(e,n,o,r);let a=new URLSearchParams({limit:"1000"});o&&a.set("query",o),r&&a.set("resource_key",r);let s=`${t.baseUrl}/datasets/${encodeURIComponent(e)}/query?${a.toString()}`,i={"Content-Type":"application/json"},c=t.token||t.authToken;c&&(i.Authorization=`Bearer ${c}`);let l=await fetch(s,{headers:i});if(!l.ok)throw new Error(`Failed to fetch dataset contents: ${l.statusText}`);let u=await l.json();return !u.Columns||!u.Rows||u.Columns.length===0?[]:u.Rows.map(p=>{let d={};return u.Columns.forEach((m,f)=>{d[m]=p[f];}),d})}function xe(t,e,n,o){let r=It(),[a,s]=useState(void 0),[i,c]=useState(false),[l,u]=useState(null),[p,d]=useState(0),m=!!t&&!!e,f=useDeepCompareMemo(()=>r,[r]);return useEffect(()=>{if(!m){s(void 0),c(false),u(null);return}let h=false;return c(true),u(null),rr(f,t,e,n,o).then(k=>{h||(s(k),c(false));}).catch(k=>{h||(u(k instanceof Error?k:new Error(String(k))),c(false));}),()=>{h=true;}},[f,t,e,n,o,m,p]),{data:a,isLoading:i,error:l,refetch:()=>d(h=>h+1)}}function ke(t,e,n,o){let r=j(),[a,s]=useState(new Map),[i,c]=useState(0),l=t.join(","),u=n?JSON.stringify(n):"",p=o?JSON.stringify(o):"",d=useDeepCompareMemo(()=>r,[r]);return useEffect(()=>{if(!d||!e||t.length===0){s(new Map);return}let m=false,f=new Map;return t.forEach(g=>{f.set(g,{data:void 0,isLoading:true,error:null,refetch:()=>c(h=>h+1)});}),s(f),t.forEach(g=>{let h=n?.[g],k=o?.[g];rr(d,g,e,h,k).then(y=>{m||s(b=>{let N=new Map(b);return N.set(g,{data:y,isLoading:false,error:null,refetch:()=>c(v=>v+1)}),N});}).catch(y=>{m||s(b=>{let N=new Map(b);return N.set(g,{data:void 0,isLoading:false,error:y instanceof Error?y:new Error(String(y)),refetch:()=>c(v=>v+1)}),N});});}),()=>{m=true;}},[d,l,u,p,e,i]),t.map(m=>a.get(m)||{data:void 0,isLoading:!(!d||!e),error:null,refetch:()=>c(f=>f+1)})}function or(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`).replace(/^_/,"")}function Vt(t,e){if(!t.length)return e;let n=t[0];if(n[e]!==void 0)return e;let o=e.toLowerCase();if(n[o]!==void 0)return o;let r=or(e);if(n[r]!==void 0)return r;let a=e.toLowerCase().replace(/_/g,"");return Object.keys(n).find(i=>i.toLowerCase().replace(/_/g,"")===a)||e}function Zo(){return ["yyyy-MM-dd","yyyyMMdd","yyyy-MM-dd'T'HH:mm:ss","yyyyMMddHHmmss"]}function Qo(t){if(!t)return null;if(typeof t=="string"){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=new Date(t+"T00:00:00.000Z");if(isValid(r))return r.getTime()}let o=Zo();for(let r of o){let a=parse(t,r,new Date);if(isValid(a))return a.getTime()}}let e=new Date(t);return isValid(e)?e.getTime():null}function ve(t,e,n,o){let r=e==="index"&&t[e]===void 0?o:t[e];return n==="date"?Qo(r):n==="number"?parseFloat(r):r}function Yo(t,e,n){if(t===e.key)return e.type||"category";let o=n.find(r=>r.key===t);return o?o.type||"number":"category"}function oe(t,e,n,o){return !o||o.length===0?t:[...t].sort((r,a)=>{for(let s of o){let i=Yo(s.key,e,n),c=ve(r,s.key,i,r.index),l=ve(a,s.key,i,a.index);if(c===l)continue;let u=typeof c=="number"&&typeof l=="number"?c-l:c instanceof Date&&l instanceof Date?c.getTime()-l.getTime():String(c).localeCompare(String(l));return s.direction==="asc"?u:-u}return 0})}function ar(t,e){let n=Math.ceil(t.length/e),o=[t[0]];for(let r=n;r<t.length-1;r+=n)o.push(t[r]);return o[o.length-1]!==t[t.length-1]&&o.push(t[t.length-1]),o}function Xo(t,e,n,o,r,a,s){let i=t.reduce((u,p)=>{let d=p[e];return u[d]||(u[d]=[]),u[d].push(p),u},{}),c=Object.entries(i);if(c.length>o){let u=Math.ceil(c.length/o),p=c.reduce((d,[m,f],g)=>{let h=Math.floor(g/u);return d[h]||(d[h]={key:m,items:[]}),d[h].items.push(...f),d},[]).map(({key:d,items:m})=>({[e]:d,...n.reduce((f,g)=>{let h=m.map(k=>parseFloat(k[g.key])).filter(k=>!isNaN(k));return f[g.key]=h.length?h.reduce((k,y)=>k+y,0)/h.length:null,f},{})}));return s&&s.length>0?oe(p,r,a,s):p}let l=c.map(([u,p])=>{let d=n.reduce((f,g)=>{let h=p.map(k=>parseFloat(k[g.key])).filter(k=>!isNaN(k));return f[g.key]=h.length?h.reduce((k,y)=>k+y,0)/h.length:null,f},{}),m=Object.values(d).filter(f=>f!==null).reduce((f,g)=>f+g,0);return {[e]:u,...d,index:m}});return s&&s.length>0?oe(l,r,a,s):l}function ta(t,e,n,o){let r=t.map(l=>parseFloat(l[e])).filter(l=>!isNaN(l)),a=Math.min(...r),i=(Math.max(...r)-a)/o,c=Array.from({length:o},(l,u)=>({binStart:a+u*i,binEnd:a+(u+1)*i,count:0,seriesValues:n.reduce((p,d)=>(p[d.key]=[],p),{})}));return t.forEach(l=>{let u=parseFloat(l[e]);if(isNaN(u))return;let p=Math.min(Math.floor((u-a)/i),o-1);c[p].count++,n.forEach(d=>{let m=parseFloat(l[d.key]);isNaN(m)||c[p].seriesValues[d.key].push(m);});}),c.map(l=>({[e]:(l.binStart+l.binEnd)/2,...n.reduce((u,p)=>{let d=l.seriesValues[p.key];return u[p.key]=d.length?d.reduce((m,f)=>m+f,0)/d.length:null,u},{}),count:l.count,index:n.reduce((u,p)=>{let d=l.seriesValues[p.key],m=d.length?d.reduce((f,g)=>f+g,0)/d.length:0;return u+m},0)})).filter(l=>n.some(u=>l[u.key]!==null))}function sr(t,e,n,o,r){let a=t.map((m,f)=>{let g=ve(m,e,r.type||"number",f);return typeof g=="number"?g:parseFloat(g)}).filter(m=>!isNaN(m)),s=Math.min(...a),l=(Math.max(...a)-s)/o,u=Array.from({length:o},(m,f)=>({binStart:Number((s+f*l).toFixed(2)),binEnd:Number((s+(f+1)*l).toFixed(2)),frequency:0,[e]:Number((s+(f+.5)*l).toFixed(2))}));a.forEach(m=>{let f=Math.min(Math.floor((m-s)/l),o-1);u[f].frequency++;});let p=u.filter(m=>m.frequency>0);return (u.length-p.length)/u.length*100>30?sr(t,e,n,Math.floor(o/2),r):p}function ea(t,e,n,o){return !e||e.length===0?t:t.filter(r=>e.every(a=>{let s=a.key;n&&a.key.toLowerCase()===n.toLowerCase()?s=n:o&&a.key.toLowerCase()===o.toLowerCase()&&(s=o);let i=r[s],c=Array.isArray(a.value)?a.value:[a.value];switch(a.operator){case "equals":return c.some(l=>String(i)===String(l));case "not_equals":return c.every(l=>String(i)!==String(l));case "greater_than":return parseFloat(String(i))>parseFloat(String(c[0]));case "less_than":return parseFloat(String(i))<parseFloat(String(c[0]));case "contains":return String(i).toLowerCase().includes(String(c[0]).toLowerCase());case "between":if(c.length===2){let l=parseFloat(String(i)),u=parseFloat(String(c[0])),p=parseFloat(String(c[1]));return l>=u&&l<=p}return true;default:return true}}))}var Ce=ut__default.memo(function({chartType:e,title:n,invocationId:o,datasetSlugs:r,xAxis:a,yAxes:s,series:i,dataReduction:c={strategy:"none",target_points:1e3},stacked:l,sort:u,onScrollUpdate:p,enableDownload:d=true,className:m,chartContainerClassName:f}){let g=useMemo(()=>{let C={};return i.forEach(S=>{S.sqlQuery&&!C[S.datasetSlug]&&(C[S.datasetSlug]=S.sqlQuery);}),Object.keys(C).length>0?C:void 0},[i]),h=useMemo(()=>{let C={};return i.forEach(S=>{S.resourceKey&&!C[S.datasetSlug]&&(C[S.datasetSlug]=S.resourceKey);}),Object.keys(C).length>0?C:void 0},[i]),k=ke(r,o,g,h),y=k.some(C=>C.isLoading),b=k.map(C=>C.data),N=useDeepCompareMemo(()=>b.map(C=>C||[]),[b]),{resolvedXAxisKey:v,resolvedSeriesKeys:D}=useMemo(()=>{let C=N.find(S=>S.length>0)||[];return {resolvedXAxisKey:Vt(C,a.key),resolvedSeriesKeys:i.map(S=>({...S,resolvedKey:Vt(C,S.key)}))}},[N,a.key,i]),I=useMemo(()=>{let C=N.reduce((P,W,K)=>(i.filter(w=>w.datasetSlug===r[K]).forEach(w=>{let R=D.find(A=>A.datasetSlug===w.datasetSlug&&A.key===w.key)?.resolvedKey||w.key;(w.filters?ea(W,w.filters,R,v):W).forEach((A,it)=>{let O=ve(A,v,a.type||"category",it);if(O==null||a.type==="number"&&isNaN(O))return;let te=a.type==="number"||a.type==="date"||typeof O=="object"?O.toString():String(O);P.has(te)||P.set(te,{[a.key]:O});let Xr=`dataset_${r.findIndex(eo=>eo===w.datasetSlug)}_series_${i.indexOf(w)}_${w.key}`,to=A[R];P.get(te)[Xr]=to;});}),P),new Map),S=Array.from(C.values());return u&&u.length>0?S:S.sort((P,W)=>{if(a.type==="date")return P[a.key]-W[a.key];let K=parseFloat(P[a.key]),x=parseFloat(W[a.key]);return isNaN(K)||isNaN(x)?String(P[a.key]).localeCompare(String(W[a.key])):K-x})},[N,i,r,D,v,a,u]),B=useMemo(()=>i.map((C,S)=>{let P=r.findIndex(W=>W===C.datasetSlug);return {...C,key:`dataset_${P}_series_${S}_${C.key}`}}),[i,r]),yt=useMemo(()=>({[a.key]:{label:a.label,format:a.format,type:a.type},...B.reduce((C,S)=>(C[S.key]={label:S.name,color:S.color},C),{}),...e==="histogram"?{frequency:{label:s[0]?.label||"Frequency",color:B[0]?.color||"#2563eb"}}:{}}),[a,B,e,s]),z=useMemo(()=>!a.key||!B.length?null:{chartType:e,xAxis:a,yAxes:e==="histogram"?s.map(C=>({...C,key:"frequency",minValue:C.minValue||"0"})):s,series:e==="histogram"?[{key:"frequency",name:s[0]?.label||"Frequency",color:i[0]?.color||"#2563eb"}]:B},[a,s,i,B,e]),F=null;switch(e){case "bar":F=kt;break;case "line":F=Bt;break;case "pie":F=Pt;break;case "scatter":F=Rt;break;case "histogram":F=kt;break;case "heatmap":F=At;break}let ht=useRef(false);useEffect(()=>{ht.current||!p||!y&&yt&&z&&I.length&&(p(),setTimeout(()=>p(),250),ht.current=true);},[p,y,yt,z,I.length]);let[V,me]=useState({x:[null,null],y:[null,null]}),{processedData:Xt,dataReductionInfo:fe}=useMemo(()=>{if(y||!I.length)return {processedData:[],dataReductionInfo:null};if(e==="histogram"){let K=c.target_points||20;return {processedData:sr(I,v,B,K,a),dataReductionInfo:null}}let C=I;if((V.x[0]!==null||V.y[0]!==null)&&(C=I.filter(K=>{if(V.x[0]!==null&&V.x[1]!==null){let x=parseFloat(K[a.key]);if(isNaN(x)||x<V.x[0]||x>V.x[1])return false}if(V.y[0]!==null&&V.y[1]!==null)for(let x of B){let w=parseFloat(K[x.key]);if(!isNaN(w)&&(w<V.y[0]||w>V.y[1]))return false}return true})),C.length<=c.target_points&&(!u||u.length===0))return {processedData:C,dataReductionInfo:null};let S,P="";switch(c.strategy){case "sample":S=ar(C,c.target_points),P="sampled",u&&u.length>0&&(S=oe(S,a,s,u));break;case "aggregate":S=Xo(C,v,B,c.target_points,a,s,u),P="aggregated";break;case "bin":S=ta(C,v,B,c.target_points),P="binning",u&&u.length>0&&(S=oe(S,a,s,u));break;default:C.length<1e3?S=C:(S=ar(C,c.target_points),P="sampled"),u&&u.length>0&&(S=oe(S,a,s,u));}let W=null;return C.length!==S.length&&(W=`${P} ${C.length.toLocaleString()} \u2192 ${S.length.toLocaleString()} points`),{processedData:S,dataReductionInfo:W}},[I,c,e,y,V.x,V.y,B,u,a,s,v]);return F?y?jsx("div",{children:"Loading..."}):I.length?z?jsx(F,{data:Xt,displayConfig:yt,stacked:l,dataConfig:z,title:n,subtitle:fe||void 0,disableAnimation:Xt.length>100,onZoomChange:me,enableDownload:d,className:m,chartContainerClassName:f}):jsx("div",{children:"Invalid chart configuration"}):jsx("div",{children:"Unable to display chart - no data available"}):(console.error("No chart component found"),null)},(t,e)=>Jo(t,e));function _e({title:t,invocationId:e,datasetSlug:n,sqlQuery:o,resourceKey:r,columns:a,maxRows:s=100,className:i,tableWrapperClassName:c,headerClassName:l,loadingClassName:u,emptyClassName:p,onScrollUpdate:d}){let{data:m,isLoading:f}=xe(n,e,o,r),g=useMemo(()=>a?m?.length?a.map(y=>{let b=Vt(m,y.key);return {key:y.key,name:y.name,resolvedKey:b,format:y.format,value_type:y.value_type}}):[]:m?.length?Object.keys(m[0]).map(y=>({key:y,name:y,resolvedKey:y,format:void 0,value_type:void 0})):[],[a,m]),h=useMemo(()=>!m||m.length===0?[]:s?m.slice(0,s):m,[m,s]),k=useRef(false);return useEffect(()=>{k.current||!d||!f&&m?.length&&(d(),setTimeout(()=>d(),250),k.current=true);},[d,f,m?.length]),f?jsx("div",{className:u||"text-gray-500",children:"Loading..."}):m?.length?g.length===0?jsx("div",{className:p||"text-gray-500",children:"No columns defined"}):jsxs("div",{className:i||"w-full",children:[t&&jsx("h3",{className:"text-lg font-medium mb-3",children:t}),jsx("div",{className:c||"relative w-full overflow-x-auto rounded-lg border border-border/50",children:jsxs("table",{className:"w-full caption-bottom text-sm",children:[jsx("thead",{className:"[&_tr]:border-b",children:jsx("tr",{className:l||"border-b transition-colors",children:g.map(y=>jsx("th",{className:"h-10 px-3 text-left align-middle font-medium text-muted-foreground",children:y.name},y.key))})}),jsx("tbody",{className:"[&_tr:last-child]:border-0",children:h.map((y,b)=>jsx("tr",{className:"border-b transition-colors hover:bg-muted/50",children:g.map(N=>jsx("td",{className:"p-3 align-middle text-foreground",children:tt(y[N.resolvedKey],N.format,N.value_type)},N.key))},b))})]})}),m.length>s&&jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Showing ",s," of ",m.length," rows"]})]}):jsx("div",{className:p||"text-gray-500",children:"No data"})}function pn(t){if(!t.content)return null;if(typeof t.content=="object")return t.content;if(typeof t.content=="string")try{return JSON.parse(t.content)}catch{return null}return null}function lr(t){let e=t.content_type;if(e==="tool_result")return "result";if(e==="tool_invocation")return "invocation";let n=pn(t);return n&&"action_type"in n&&"name"in n&&"input"in n&&n.action_type!=="bot.invoke"?"result"in n?"result":"invocation":null}function cr(t){return pn(t)?.id}function ur(t){let e=pn(t);if(!e?.action_type)return null;let o=e.input?.query;return `${e.action_type}:${o||""}`}function Se(t){let e=t.filter(r=>lr(r)==="result"),n=new Set(e.map(r=>cr(r)).filter(Boolean)),o=new Set(e.map(r=>ur(r)).filter(Boolean));return t.filter(r=>{if(lr(r)==="invocation"){let a=cr(r),s=ur(r);if(a&&n.has(a)||s&&o.has(s))return false}return true})}function we({output:t,ContentComponent:e}){let n=j(),o=e??n?.ContentComponent,r=t?.contents,a=useMemo(()=>r?Se(r.filter(s=>s.user_visibility==="visible")):[],[r]);return !t||!t.output||!a.length?null:jsx("div",{children:a.map(s=>o?jsx(o,{content:s},s.id):jsx("div",{className:"text-sm",children:typeof s.content=="string"?s.content:JSON.stringify(s.content)},s.id))},t.output.id)}function dr(t){return t!==null&&typeof t=="object"&&"Valid"in t&&"String"in t}function T(t){if(typeof t=="string")return t;if(dr(t))return t.Valid?t.String:void 0}function aa(t,e){return T(t)??e}var pr={v:"5.10.2",fr:60,ip:0,op:180,w:144,h:144,nm:"system-solid-719-spinner-circle",ddd:0,assets:[{id:"comp_6",nm:"loop-snake-alt",fr:60,layers:[{ddd:0,ind:1,ty:0,nm:"mask-2",td:1,refId:"comp_7",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[72,72,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:144,h:144,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"circle 2",tt:2,tp:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[-30.652,0],[0,30.652],[30.652,0],[0,-30.652]],o:[[30.652,0],[0,-30.652],[-30.652,0],[0,30.652]],v:[[0,55.5],[55.5,0],[0,-55.5],[-55.5,0]],c:true},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.071,.075,.192,1],ix:3,x:`var $bm_rt;
7
+ `)}}):null},on=Dt.Tooltip;function an({active:t,payload:e,className:n,indicator:o="dot",hideLabel:r=false,hideIndicator:a=false,label:s,labelFormatter:i,labelClassName:c,formatter:l,color:u,nameKey:p,labelKey:d}){let{config:m}=zn(),f=ut.useMemo(()=>{if(r||!e?.length)return null;let[y]=e,x=`${d||y?.dataKey||y?.name||"value"}`,h=rn(m,y,x),b=!d&&typeof s=="string"?m[s]?.label||s:h?.label;return i?jsx("div",{className:q("font-medium",c),children:i(b,e)}):b?jsx("div",{className:q("font-medium",c),children:b}):null},[s,i,e,r,c,m,d]);if(!t||!e?.length)return null;let g=e.length===1&&o!=="dot";return jsxs("div",{className:q("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",n),children:[g?null:f,jsx("div",{className:"grid gap-1.5",children:e.map((y,x)=>{let h=`${p||y.name||y.dataKey||"value"}`,b=rn(m,y,h),N=u||y.payload.fill||y.color;return jsx("div",{className:q("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",o==="dot"&&"items-center"),children:l&&y?.value!==void 0&&y.name?l(y.value,y.name,y,x,y.payload):jsxs(Fragment,{children:[b?.icon?jsx(b.icon,{}):!a&&jsx("div",{className:q("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":o==="dot","w-1":o==="line","w-0 border-[1.5px] border-dashed bg-transparent":o==="dashed","my-0.5":g&&o==="dashed"}),style:{"--color-bg":N,"--color-border":N}}),jsxs("div",{className:q("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[jsxs("div",{className:"grid gap-1.5",children:[g?f:null,jsx("span",{className:"text-muted-foreground",children:b?.label||y.name})]}),y.value&&jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:y.value.toLocaleString()})]})]})},y.dataKey)})})]})}var sn=Dt.Legend;function ln({className:t,hideIcon:e=false,payload:n,verticalAlign:o="bottom",nameKey:r}){let{config:a}=zn();return n?.length?jsx("div",{className:q("flex items-center justify-center gap-4",o==="top"?"pb-3":"pt-3",t),children:n.map(s=>{let i=`${r||s.dataKey||"value"}`,c=rn(a,s,i);return jsxs("div",{className:q("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),children:[c?.icon&&!e?jsx(c.icon,{}):jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:s.color}}),c?.label]},s.value)})}):null}function rn(t,e,n){if(typeof e!="object"||e===null)return;let o="payload"in e&&typeof e.payload=="object"&&e.payload!==null?e.payload:void 0,r=n;return n in e&&typeof e[n]=="string"?r=e[n]:o&&n in o&&typeof o[n]=="string"&&(r=o[n]),r in t?t[r]:t[n]}function tt(t,e,n){if(t==null)return "";if(n==="date"){let o=Zn(t);if(o&&e)try{let r=e;e==="%Y%m%d"?r="%Y-%m-%d":e==="%d%m%Y"?r="%d-%m-%Y":e==="%m%d%Y"&&(r="%m-%d-%Y");let a=r.match(/%./g)||[],s="aAbBcdejHILmMpSUwWxXyYZ%";return a.some(l=>{let u=l.charAt(1);return !s.includes(u)})||a.length===0?(console.warn(`Invalid date format directives in: ${e}. Using default format.`),o.toISOString().split("T")[0]):utcFormat(r)(o)}catch(r){return console.warn(`Invalid date format: ${e}. Error: ${r}. Falling back to default.`),o.toISOString().split("T")[0]}if(o){let r=o.toISOString();return r.endsWith("T00:00:00.000Z")?r.split("T")[0]:o.toISOString().replace("T"," ").replace(".000Z"," UTC")}return String(t)}if(n==="number"){let o=typeof t=="string"?parseFloat(t.replace(/,/g,"")):t;if(isNaN(o))return String(t);let r=e;if(e&&(r=e.replace(/(\.\d+)f%/,"$1%")),!r)return Math.abs(o)>=1e3?format(",.0f")(o):Math.abs(o)>=100?format(".1f")(o):Math.abs(o)>=10?format(".2f")(o):Math.abs(o)>=1?format(".3f")(o):format(".3g")(o);if(r.includes("%"))return o>=0&&o<=1?format(r)(o):format(r)(o/100);try{return format(r)(o)}catch(a){return console.warn(`Error formatting number with format '${r}': ${a}. Falling back to default.`),Math.abs(o)>=1e3?format(",.0f")(o):Math.abs(o)>=1?format(".2f")(o):format(".3g")(o)}}return String(t)}function Zn(t){if(!t)return null;if(t instanceof Date)return isValid(t)?t:null;if(typeof t=="number"){let n=new Date(t);return isValid(n)?n:null}if(typeof t=="string"){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=new Date(t+"T00:00:00.000Z");if(isValid(r))return r}let o=["yyyy-MM-dd","yyyyMMdd","yyyy-MM-dd'T'HH:mm:ss","yyyyMMddHHmmss","MM/dd/yyyy","dd/MM/yyyy"];for(let r of o){let a=parse(t,r,new Date);if(isValid(a))return a}}let e=new Date(t);return isValid(e)?e:null}function ye({onZoomChange:t}={}){let[e,n]=useState({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false}),[o,r]=useState({x:[null,null],y:[null,null]}),a=useCallback(u=>{!u?.xValue||!u?.yValue||n(p=>({...p,refAreaLeft:u.xValue,refAreaTop:u.yValue,zooming:true}));},[]),s=useCallback(u=>{!u?.xValue||!u?.yValue||!e.zooming||n(p=>({...p,refAreaRight:u.xValue,refAreaBottom:u.yValue}));},[e.zooming]),i=useCallback(()=>{if(!e.refAreaLeft||!e.refAreaRight||!e.refAreaTop||!e.refAreaBottom){n({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false});return}let[u,p]=[Math.min(e.refAreaLeft,e.refAreaRight),Math.max(e.refAreaLeft,e.refAreaRight)],[d,m]=[Math.min(e.refAreaTop,e.refAreaBottom),Math.max(e.refAreaTop,e.refAreaBottom)],f={x:[u,p],y:[d,m]};r(f),t?.(f),n({refAreaLeft:null,refAreaRight:null,refAreaTop:null,refAreaBottom:null,zooming:false});},[e,t]),c=useCallback(()=>{let u={x:[null,null],y:[null,null]};r(u),t?.(u);},[t]),l=useMemo(()=>({onZoomStart:a,onZoomMove:s,onZoomEnd:i,onResetZoom:c}),[a,s,i,c]);return {zoomState:e,customDomain:o,handlers:l}}function Xn(t){let e={max:null,min:null};if(t.maxValue)if(t.type==="number"){let n=parseFloat(t.maxValue);isNaN(n)?console.warn(`Error parsing max value ${t.maxValue}. Falling back to default.`):e.max=n;}else t.type==="date"?typeof t.maxValue=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.maxValue)?e.max=new Date(t.maxValue+"T00:00:00.000Z").getTime():e.max=new Date(t.maxValue).getTime():e.max=t.maxValue;if(t.minValue)if(t.type==="number"){let n=parseFloat(t.minValue);isNaN(n)?console.warn(`Error parsing min value ${t.minValue}. Falling back to default.`):e.min=n;}else t.type==="date"?typeof t.minValue=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.minValue)?e.min=new Date(t.minValue+"T00:00:00.000Z").getTime():e.min=new Date(t.minValue).getTime():e.min=t.minValue;return e}function Tt(t,e,n){return tt(t,e,n)}function vo({title:t,subtitle:e,data:n,displayConfig:o,dataConfig:r,ChartComponent:a,PointComponent:s,disableAnimation:i,onZoomChange:c,stacked:l,enableDownload:u=true,onDownloadSuccess:p,onDownloadError:d,className:m,chartContainerClassName:f,downloadButtonClassName:g,resetZoomButtonClassName:y}){let{zoomState:x,customDomain:h,handlers:b}=ye({onZoomChange:c}),N=useCallback(k=>{let w=`${(t||"chart").toLowerCase().replace(/\s+/g,"-")}.png`,R=document.createElement("a");R.download=w,R.href=k,R.click(),p?.(w);},[t,p]),v=useCallback(k=>{console.error("Error converting chart to image:",k),d?.(k);},[d]),[{isLoading:D},I,B]=useToPng({onSuccess:N,onError:v}),yt=useCallback(async()=>{I();},[I]),z=useMemo(()=>Xn(r.xAxis),[r.xAxis]),F=useMemo(()=>r.yAxes.map(k=>Xn(k)),[r.yAxes]),ht=useMemo(()=>n?r.chartType==="histogram"?n.map(k=>({[r.xAxis.key]:(k.binStart+k.binEnd)/2,frequency:k.frequency,binStart:k.binStart,binEnd:k.binEnd})):r.xAxis.type==="number"?n.filter(k=>!isNaN(k[r.xAxis.key])):r.xAxis.type==="date"?n.filter(k=>!isNaN(k[r.xAxis.key])):n:[],[n,r.xAxis.key,r.chartType,r.xAxis.type]),V=useCallback((k,w)=>{if(!k?.length)return {min:null,max:null};let R=k.map(J=>Number(J[w])).filter(J=>!isNaN(J));return {min:Math.min(...R),max:Math.max(...R)}},[]),me=useMemo(()=>({x:h.x[0]!==null&&h.x[1]!==null?[h.x[0],h.x[1]]:(()=>{if(z.min!==null&&z.max!==null)return [z.min,z.max];let k=V(ht,r.xAxis.key);return [k.min??"auto",k.max??"auto"]})(),y:r.yAxes.map((k,w)=>{if(h.y[0]!==null&&h.y[1]!==null)return [h.y[0],h.y[1]];let J=r.series.filter(A=>(A.axisIndex||0)===w).reduce((A,it)=>{let O=V(ht,it.key);return {min:A.min===null?O.min:O.min===null?A.min:Math.min(A.min,O.min),max:A.max===null?O.max:O.max===null?A.max:Math.max(A.max,O.max)}},{min:null,max:null});if(k.type==="number"&&k.maxValue){let A=parseFloat(k.maxValue);if(J.max===null||A<=J.max*1.5)return [F[w].min??J.min??"auto",F[w].max??J.max??"auto"]}return [F[w].min??J.min??"auto",F[w].max??J.max??"auto"]})}),[h.x,h.y,z,F,r.series,r.yAxes,r.xAxis.key,ht,V]),Xt=useCallback((k,w,R)=>{if(R.dataKey===r.xAxis.key)return Tt(k,r.xAxis.format,r.xAxis.type);let A=r.series.find(it=>it.key===R.dataKey)?.name||String(w).replace(/^dataset_\d+_/,"");if(r.chartType==="histogram"){let it=R.payload;if(it.binStart!==void 0){let O=Tt(it.binStart,r.xAxis.format,r.xAxis.type),te=Tt(it.binEnd,r.xAxis.format,r.xAxis.type);return `Count: ${k} (${O} - ${te})`}}return `${A}: ${k}`},[r.xAxis,r.series,r.chartType]),[fe,C]=useState(false);useEffect(()=>{let k=setTimeout(()=>{C(true);},1700);return ()=>clearTimeout(k)},[]);let S=useCallback((k,w)=>{if(w&&w.length>0){let R=w[0].payload[r.xAxis.key],J=Tt(R,r.xAxis.format,r.xAxis.type);return jsxs("div",{className:"flex flex-col",children:[jsx("span",{children:r.xAxis.label}),jsx("span",{className:"font-mono tabular-nums",children:J})]})}return k},[r.xAxis.key,r.xAxis.format,r.xAxis.type,r.xAxis.label]),P=useCallback(k=>jsx(an,{...k,formatter:Xt,labelFormatter:S}),[Xt,S]),W=useCallback(k=>jsx(ln,{...k}),[]),K=useMemo(()=>!!(i||(n?.length||0)>100||fe),[i,n?.length,fe]);return jsxs("div",{className:m||"w-full items-center mt-0 flex flex-col gap-0",children:[(t||u)&&jsxs("div",{className:"w-full items-center mb-2 relative",children:[t&&jsx("h2",{className:"text-center text-base pt-0 mt-0 mb-2",children:t}),u&&jsx("button",{onClick:yt,disabled:D,className:g||"text-sm text-gray-500 hover:text-gray-700 disabled:opacity-50 h-8 absolute right-0 top-[-5px] px-2 py-1 border rounded hover:bg-gray-50",title:"Download chart as PNG",children:jsx(Download,{className:"w-4 h-4"})})]}),e&&jsx("p",{className:"text-center text-sm text-muted-foreground mb-2",children:e}),jsx(ee,{ref:B,config:o,className:f||"w-full border border-border/50 p-4 rounded-md",debounceResize:true,children:jsxs(a,{accessibilityLayer:true,data:ht,isAnimationActive:!K,onMouseDown:b.onZoomStart,onMouseMove:b.onZoomMove,onMouseUp:b.onZoomEnd,onDoubleClick:b.onResetZoom,style:{userSelect:"none",cursor:"crosshair"},children:[jsx(CartesianGrid,{vertical:false}),jsx(XAxis,{dataKey:r.xAxis.key,domain:me.x,type:r.xAxis.type==="date"||!r.xAxis.type?"number":r.xAxis.type,tickFormatter:k=>Tt(k,r.xAxis.format,r.xAxis.type),tickLine:false,tickMargin:10,height:50,axisLine:false,allowDataOverflow:true,children:jsx(Label,{value:r.xAxis.label,position:"bottom",offset:-10,style:{textAnchor:"middle"}})}),r.yAxes.map((k,w)=>jsx(YAxis,{yAxisId:w,orientation:w===0?"left":"right",domain:l?void 0:me.y[w],type:k.type==="date"||!k.type?"number":k.type,tickFormatter:R=>Tt(R,k.format,k.type),allowDataOverflow:true,children:jsx(Label,{value:k.label,position:w===0?"insideLeft":"insideRight",angle:-90,style:{textAnchor:"middle"}})},`y-axis-${k.key}`)),jsx(on,{content:P}),jsx(sn,{content:W,verticalAlign:"top"}),r.series.map(k=>jsx(s,{dataKey:k.key,yAxisId:k.axisIndex||0,fill:k.color||"blue",stroke:k.color||"blue",dot:{fill:k.color||"blue",stroke:k.color||"blue"},radius:4,name:k.name,isAnimationActive:!K,animationDuration:1500,animationBegin:0,stackId:r.chartType==="bar"&&l?"stack":void 0},`${k.key}-${l?"stacked":"unstacked"}`)),x.refAreaLeft&&x.refAreaRight&&x.refAreaTop&&x.refAreaBottom&&jsx(ReferenceArea,{x1:x.refAreaLeft,x2:x.refAreaRight,y1:x.refAreaTop,y2:x.refAreaBottom,strokeOpacity:.2,stroke:"currentColor",fill:"currentColor",fillOpacity:.02,style:{pointerEvents:"none"}})]})}),h.x[0]!==null&&jsx("button",{onClick:b.onResetZoom,className:y||"text-sm text-gray-500 hover:text-gray-700 mt-2 px-3 py-1 border rounded hover:bg-gray-50",children:"Reset Zoom"})]})}function et(t){return jsx(xt,{fallback:jsx("div",{className:t.errorClassName||"text-red-500",children:"Failed to load chart"}),children:jsx(vo,{...t})})}function kt(t){return jsx(et,{...t,ChartComponent:BarChart,PointComponent:Bar})}function Bt(t){return jsx(et,{...t,ChartComponent:LineChart,PointComponent:Line})}var Ao=(t,e,n)=>{let o=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,a=parseInt(t.slice(5,7),16)/255,s=Math.max(o,r,a),i=Math.min(o,r,a),c,l,u=(s+i)/2;if(s===i)c=l=0;else {let g=s-i;switch(l=u>.5?g/(2-s-i):g/(s+i),s){case o:c=(r-a)/g+(r<a?6:0);break;case r:c=(a-o)/g+2;break;case a:c=(o-r)/g+4;break;default:c=0;}c/=6;}let p=e/n,d=c*360+(p*40-20),m=Math.min(100,l*100+p*25),f=Math.max(35,Math.min(65,u*100-p*20));return `hsl(${d}, ${m}%, ${f}%)`};function Oo({title:t,subtitle:e,data:n,displayConfig:o,dataConfig:r,className:a,chartContainerClassName:s}){let i=r.series[0]?.color||"blue",c=r.yAxes[0]?.format,l=r.yAxes[0]?.type||"number",u=useMemo(()=>n.reduce((p,d)=>(r.series.forEach(m=>{let f=m.key,g=String(d[r.xAxis.key]||"Unknown"),y=parseFloat(d[f]||"0");isNaN(y)||p.push({name:g,value:y,seriesId:f,displayName:g});}),p),[]).sort((p,d)=>d.value-p.value),[n,r.series,r.xAxis.key]);return jsxs("div",{className:a||"items-center",children:[jsx("h2",{className:"text-center text-base mb-2",children:t}),e&&jsx("p",{className:"text-center text-sm text-muted-foreground mb-2",children:e}),jsx(ee,{config:o,className:s||"w-full border border-border/50 rounded-md",children:jsxs(PieChart,{width:400,height:400,children:[jsx(Pie,{data:u,dataKey:"value",nameKey:"displayName",cx:"50%",cy:"50%",outerRadius:150,label:p=>`${p.displayName}: ${tt(p.value,c,l)}`,children:u.map((p,d)=>jsx(Cell,{fill:d===0?i:Ao(i,d,u.length)},`cell-${p.name}`))}),jsx(Tooltip,{formatter:(p,d)=>[tt(p,c,l),d]}),jsx(Legend,{})]})})]})}function Pt(t){return jsx(xt,{fallback:jsx("div",{className:"text-red-500",children:"Failed to load chart"}),children:jsx(Oo,{...t})})}function Rt(t){return jsx(et,{...t,ChartComponent:ScatterChart,PointComponent:Scatter})}var Go=t=>{let{cx:e,cy:n,payload:o,xAxis:r,yAxis:a}=t,s=o.value||o.z||0,c=`hsl(${240-Math.min(1,Math.max(0,s/100))*240}, 70%, 50%)`,l=r.scale.bandwidth?r.scale.bandwidth():20,u=a.scale.bandwidth?a.scale.bandwidth():20;return jsx("rect",{x:e-l/2,y:n-u/2,width:l,height:u,fill:c,fillOpacity:.8,stroke:"#fff",strokeWidth:1})},Fo=t=>jsx(Scatter,{...t,shape:Go});function At(t){return jsx(et,{...t,ChartComponent:ScatterChart,PointComponent:Fo})}async function rr(t,e,n,o,r){if(t.dataFetcher)return t.dataFetcher.fetchDatasetContents(e,n,o,r);let a=new URLSearchParams({limit:"1000"});o&&a.set("query",o),r&&a.set("resource_key",r);let s=`${t.baseUrl}/datasets/${encodeURIComponent(e)}/query?${a.toString()}`,i={"Content-Type":"application/json"},c=t.token||t.authToken;c&&(i.Authorization=`Bearer ${c}`);let l=await fetch(s,{headers:i});if(!l.ok)throw new Error(`Failed to fetch dataset contents: ${l.statusText}`);let u=await l.json();return !u.Columns||!u.Rows||u.Columns.length===0?[]:u.Rows.map(p=>{let d={};return u.Columns.forEach((m,f)=>{d[m]=p[f];}),d})}function xe(t,e,n,o){let r=It(),[a,s]=useState(void 0),[i,c]=useState(false),[l,u]=useState(null),[p,d]=useState(0),m=!!t&&!!e,f=useDeepCompareMemo(()=>r,[r]);return useEffect(()=>{if(!m){s(void 0),c(false),u(null);return}let y=false;return c(true),u(null),rr(f,t,e,n,o).then(x=>{y||(s(x),c(false));}).catch(x=>{y||(u(x instanceof Error?x:new Error(String(x))),c(false));}),()=>{y=true;}},[f,t,e,n,o,m,p]),{data:a,isLoading:i,error:l,refetch:()=>d(y=>y+1)}}function ke(t,e,n,o){let r=j(),[a,s]=useState(new Map),[i,c]=useState(0),l=t.join(","),u=n?JSON.stringify(n):"",p=o?JSON.stringify(o):"",d=useDeepCompareMemo(()=>r,[r]);return useEffect(()=>{if(!d||!e||t.length===0){s(new Map);return}let m=false,f=new Map;return t.forEach(g=>{f.set(g,{data:void 0,isLoading:true,error:null,refetch:()=>c(y=>y+1)});}),s(f),t.forEach(g=>{let y=n?.[g],x=o?.[g];rr(d,g,e,y,x).then(h=>{m||s(b=>{let N=new Map(b);return N.set(g,{data:h,isLoading:false,error:null,refetch:()=>c(v=>v+1)}),N});}).catch(h=>{m||s(b=>{let N=new Map(b);return N.set(g,{data:void 0,isLoading:false,error:h instanceof Error?h:new Error(String(h)),refetch:()=>c(v=>v+1)}),N});});}),()=>{m=true;}},[d,l,u,p,e,i]),t.map(m=>a.get(m)||{data:void 0,isLoading:!(!d||!e),error:null,refetch:()=>c(f=>f+1)})}function or(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`).replace(/^_/,"")}function Vt(t,e){if(!t.length)return e;let n=t[0];if(n[e]!==void 0)return e;let o=e.toLowerCase();if(n[o]!==void 0)return o;let r=or(e);if(n[r]!==void 0)return r;let a=e.toLowerCase().replace(/_/g,"");return Object.keys(n).find(i=>i.toLowerCase().replace(/_/g,"")===a)||e}function Zo(){return ["yyyy-MM-dd","yyyyMMdd","yyyy-MM-dd'T'HH:mm:ss","yyyyMMddHHmmss"]}function Qo(t){if(!t)return null;if(typeof t=="string"){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=new Date(t+"T00:00:00.000Z");if(isValid(r))return r.getTime()}let o=Zo();for(let r of o){let a=parse(t,r,new Date);if(isValid(a))return a.getTime()}}let e=new Date(t);return isValid(e)?e.getTime():null}function ve(t,e,n,o){let r=e==="index"&&t[e]===void 0?o:t[e];return n==="date"?Qo(r):n==="number"?parseFloat(r):r}function Yo(t,e,n){if(t===e.key)return e.type||"category";let o=n.find(r=>r.key===t);return o?o.type||"number":"category"}function oe(t,e,n,o){return !o||o.length===0?t:[...t].sort((r,a)=>{for(let s of o){let i=Yo(s.key,e,n),c=ve(r,s.key,i,r.index),l=ve(a,s.key,i,a.index);if(c===l)continue;let u=typeof c=="number"&&typeof l=="number"?c-l:c instanceof Date&&l instanceof Date?c.getTime()-l.getTime():String(c).localeCompare(String(l));return s.direction==="asc"?u:-u}return 0})}function ar(t,e){let n=Math.ceil(t.length/e),o=[t[0]];for(let r=n;r<t.length-1;r+=n)o.push(t[r]);return o[o.length-1]!==t[t.length-1]&&o.push(t[t.length-1]),o}function Xo(t,e,n,o,r,a,s){let i=t.reduce((u,p)=>{let d=p[e];return u[d]||(u[d]=[]),u[d].push(p),u},{}),c=Object.entries(i);if(c.length>o){let u=Math.ceil(c.length/o),p=c.reduce((d,[m,f],g)=>{let y=Math.floor(g/u);return d[y]||(d[y]={key:m,items:[]}),d[y].items.push(...f),d},[]).map(({key:d,items:m})=>({[e]:d,...n.reduce((f,g)=>{let y=m.map(x=>parseFloat(x[g.key])).filter(x=>!isNaN(x));return f[g.key]=y.length?y.reduce((x,h)=>x+h,0)/y.length:null,f},{})}));return s&&s.length>0?oe(p,r,a,s):p}let l=c.map(([u,p])=>{let d=n.reduce((f,g)=>{let y=p.map(x=>parseFloat(x[g.key])).filter(x=>!isNaN(x));return f[g.key]=y.length?y.reduce((x,h)=>x+h,0)/y.length:null,f},{}),m=Object.values(d).filter(f=>f!==null).reduce((f,g)=>f+g,0);return {[e]:u,...d,index:m}});return s&&s.length>0?oe(l,r,a,s):l}function ta(t,e,n,o){let r=t.map(l=>parseFloat(l[e])).filter(l=>!isNaN(l)),a=Math.min(...r),i=(Math.max(...r)-a)/o,c=Array.from({length:o},(l,u)=>({binStart:a+u*i,binEnd:a+(u+1)*i,count:0,seriesValues:n.reduce((p,d)=>(p[d.key]=[],p),{})}));return t.forEach(l=>{let u=parseFloat(l[e]);if(isNaN(u))return;let p=Math.min(Math.floor((u-a)/i),o-1);c[p].count++,n.forEach(d=>{let m=parseFloat(l[d.key]);isNaN(m)||c[p].seriesValues[d.key].push(m);});}),c.map(l=>({[e]:(l.binStart+l.binEnd)/2,...n.reduce((u,p)=>{let d=l.seriesValues[p.key];return u[p.key]=d.length?d.reduce((m,f)=>m+f,0)/d.length:null,u},{}),count:l.count,index:n.reduce((u,p)=>{let d=l.seriesValues[p.key],m=d.length?d.reduce((f,g)=>f+g,0)/d.length:0;return u+m},0)})).filter(l=>n.some(u=>l[u.key]!==null))}function sr(t,e,n,o,r){let a=t.map((m,f)=>{let g=ve(m,e,r.type||"number",f);return typeof g=="number"?g:parseFloat(g)}).filter(m=>!isNaN(m)),s=Math.min(...a),l=(Math.max(...a)-s)/o,u=Array.from({length:o},(m,f)=>({binStart:Number((s+f*l).toFixed(2)),binEnd:Number((s+(f+1)*l).toFixed(2)),frequency:0,[e]:Number((s+(f+.5)*l).toFixed(2))}));a.forEach(m=>{let f=Math.min(Math.floor((m-s)/l),o-1);u[f].frequency++;});let p=u.filter(m=>m.frequency>0);return (u.length-p.length)/u.length*100>30?sr(t,e,n,Math.floor(o/2),r):p}function ea(t,e,n,o){return !e||e.length===0?t:t.filter(r=>e.every(a=>{let s=a.key;n&&a.key.toLowerCase()===n.toLowerCase()?s=n:o&&a.key.toLowerCase()===o.toLowerCase()&&(s=o);let i=r[s],c=Array.isArray(a.value)?a.value:[a.value];switch(a.operator){case "equals":return c.some(l=>String(i)===String(l));case "not_equals":return c.every(l=>String(i)!==String(l));case "greater_than":return parseFloat(String(i))>parseFloat(String(c[0]));case "less_than":return parseFloat(String(i))<parseFloat(String(c[0]));case "contains":return String(i).toLowerCase().includes(String(c[0]).toLowerCase());case "between":if(c.length===2){let l=parseFloat(String(i)),u=parseFloat(String(c[0])),p=parseFloat(String(c[1]));return l>=u&&l<=p}return true;default:return true}}))}var Ce=ut__default.memo(function({chartType:e,title:n,invocationId:o,datasetSlugs:r,xAxis:a,yAxes:s,series:i,dataReduction:c={strategy:"none",target_points:1e3},stacked:l,sort:u,onScrollUpdate:p,enableDownload:d=true,className:m,chartContainerClassName:f}){let g=useMemo(()=>{let C={};return i.forEach(S=>{S.sqlQuery&&!C[S.datasetSlug]&&(C[S.datasetSlug]=S.sqlQuery);}),Object.keys(C).length>0?C:void 0},[i]),y=useMemo(()=>{let C={};return i.forEach(S=>{S.resourceKey&&!C[S.datasetSlug]&&(C[S.datasetSlug]=S.resourceKey);}),Object.keys(C).length>0?C:void 0},[i]),x=ke(r,o,g,y),h=x.some(C=>C.isLoading),b=x.map(C=>C.data),N=useDeepCompareMemo(()=>b.map(C=>C||[]),[b]),{resolvedXAxisKey:v,resolvedSeriesKeys:D}=useMemo(()=>{let C=N.find(S=>S.length>0)||[];return {resolvedXAxisKey:Vt(C,a.key),resolvedSeriesKeys:i.map(S=>({...S,resolvedKey:Vt(C,S.key)}))}},[N,a.key,i]),I=useMemo(()=>{let C=N.reduce((P,W,K)=>(i.filter(w=>w.datasetSlug===r[K]).forEach(w=>{let R=D.find(A=>A.datasetSlug===w.datasetSlug&&A.key===w.key)?.resolvedKey||w.key;(w.filters?ea(W,w.filters,R,v):W).forEach((A,it)=>{let O=ve(A,v,a.type||"category",it);if(O==null||a.type==="number"&&isNaN(O))return;let te=a.type==="number"||a.type==="date"||typeof O=="object"?O.toString():String(O);P.has(te)||P.set(te,{[a.key]:O});let Xr=`dataset_${r.findIndex(eo=>eo===w.datasetSlug)}_series_${i.indexOf(w)}_${w.key}`,to=A[R];P.get(te)[Xr]=to;});}),P),new Map),S=Array.from(C.values());return u&&u.length>0?S:S.sort((P,W)=>{if(a.type==="date")return P[a.key]-W[a.key];let K=parseFloat(P[a.key]),k=parseFloat(W[a.key]);return isNaN(K)||isNaN(k)?String(P[a.key]).localeCompare(String(W[a.key])):K-k})},[N,i,r,D,v,a,u]),B=useMemo(()=>i.map((C,S)=>{let P=r.findIndex(W=>W===C.datasetSlug);return {...C,key:`dataset_${P}_series_${S}_${C.key}`}}),[i,r]),yt=useMemo(()=>({[a.key]:{label:a.label,format:a.format,type:a.type},...B.reduce((C,S)=>(C[S.key]={label:S.name,color:S.color},C),{}),...e==="histogram"?{frequency:{label:s[0]?.label||"Frequency",color:B[0]?.color||"#2563eb"}}:{}}),[a,B,e,s]),z=useMemo(()=>!a.key||!B.length?null:{chartType:e,xAxis:a,yAxes:e==="histogram"?s.map(C=>({...C,key:"frequency",minValue:C.minValue||"0"})):s,series:e==="histogram"?[{key:"frequency",name:s[0]?.label||"Frequency",color:i[0]?.color||"#2563eb"}]:B},[a,s,i,B,e]),F=null;switch(e){case "bar":F=kt;break;case "line":F=Bt;break;case "pie":F=Pt;break;case "scatter":F=Rt;break;case "histogram":F=kt;break;case "heatmap":F=At;break}let ht=useRef(false);useEffect(()=>{ht.current||!p||!h&&yt&&z&&I.length&&(p(),setTimeout(()=>p(),250),ht.current=true);},[p,h,yt,z,I.length]);let[V,me]=useState({x:[null,null],y:[null,null]}),{processedData:Xt,dataReductionInfo:fe}=useMemo(()=>{if(h||!I.length)return {processedData:[],dataReductionInfo:null};if(e==="histogram"){let K=c.target_points||20;return {processedData:sr(I,v,B,K,a),dataReductionInfo:null}}let C=I;if((V.x[0]!==null||V.y[0]!==null)&&(C=I.filter(K=>{if(V.x[0]!==null&&V.x[1]!==null){let k=parseFloat(K[a.key]);if(isNaN(k)||k<V.x[0]||k>V.x[1])return false}if(V.y[0]!==null&&V.y[1]!==null)for(let k of B){let w=parseFloat(K[k.key]);if(!isNaN(w)&&(w<V.y[0]||w>V.y[1]))return false}return true})),C.length<=c.target_points&&(!u||u.length===0))return {processedData:C,dataReductionInfo:null};let S,P="";switch(c.strategy){case "sample":S=ar(C,c.target_points),P="sampled",u&&u.length>0&&(S=oe(S,a,s,u));break;case "aggregate":S=Xo(C,v,B,c.target_points,a,s,u),P="aggregated";break;case "bin":S=ta(C,v,B,c.target_points),P="binning",u&&u.length>0&&(S=oe(S,a,s,u));break;default:C.length<1e3?S=C:(S=ar(C,c.target_points),P="sampled"),u&&u.length>0&&(S=oe(S,a,s,u));}let W=null;return C.length!==S.length&&(W=`${P} ${C.length.toLocaleString()} \u2192 ${S.length.toLocaleString()} points`),{processedData:S,dataReductionInfo:W}},[I,c,e,h,V.x,V.y,B,u,a,s,v]);return F?h?jsx("div",{children:"Loading..."}):I.length?z?jsx(F,{data:Xt,displayConfig:yt,stacked:l,dataConfig:z,title:n,subtitle:fe||void 0,disableAnimation:Xt.length>100,onZoomChange:me,enableDownload:d,className:m,chartContainerClassName:f}):jsx("div",{children:"Invalid chart configuration"}):jsx("div",{children:"Unable to display chart - no data available"}):(console.error("No chart component found"),null)},(t,e)=>Jo(t,e));function _e({title:t,invocationId:e,datasetSlug:n,sqlQuery:o,resourceKey:r,columns:a,maxRows:s=100,className:i,tableWrapperClassName:c,headerClassName:l,loadingClassName:u,emptyClassName:p,onScrollUpdate:d}){let{data:m,isLoading:f}=xe(n,e,o,r),g=useMemo(()=>a?m?.length?a.map(h=>{let b=Vt(m,h.key);return {key:h.key,name:h.name,resolvedKey:b,format:h.format,value_type:h.value_type}}):[]:m?.length?Object.keys(m[0]).map(h=>({key:h,name:h,resolvedKey:h,format:void 0,value_type:void 0})):[],[a,m]),y=useMemo(()=>!m||m.length===0?[]:s?m.slice(0,s):m,[m,s]),x=useRef(false);return useEffect(()=>{x.current||!d||!f&&m?.length&&(d(),setTimeout(()=>d(),250),x.current=true);},[d,f,m?.length]),f?jsx("div",{className:u||"text-gray-500",children:"Loading..."}):m?.length?g.length===0?jsx("div",{className:p||"text-gray-500",children:"No columns defined"}):jsxs("div",{className:i||"w-full",children:[t&&jsx("h3",{className:"text-lg font-medium mb-3",children:t}),jsx("div",{className:c||"relative w-full overflow-x-auto rounded-lg border border-border/50",children:jsxs("table",{className:"w-full caption-bottom text-sm",children:[jsx("thead",{className:"[&_tr]:border-b",children:jsx("tr",{className:l||"border-b transition-colors",children:g.map(h=>jsx("th",{className:"h-10 px-3 text-left align-middle font-medium text-muted-foreground",children:h.name},h.key))})}),jsx("tbody",{className:"[&_tr:last-child]:border-0",children:y.map((h,b)=>jsx("tr",{className:"border-b transition-colors hover:bg-muted/50",children:g.map(N=>jsx("td",{className:"p-3 align-middle text-foreground",children:tt(h[N.resolvedKey],N.format,N.value_type)},N.key))},b))})]})}),m.length>s&&jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Showing ",s," of ",m.length," rows"]})]}):jsx("div",{className:p||"text-gray-500",children:"No data"})}function pn(t){if(!t.content)return null;if(typeof t.content=="object")return t.content;if(typeof t.content=="string")try{return JSON.parse(t.content)}catch{return null}return null}function lr(t){let e=t.content_type;if(e==="tool_result")return "result";if(e==="tool_invocation")return "invocation";let n=pn(t);return n&&"action_type"in n&&"name"in n&&"input"in n&&n.action_type!=="bot.invoke"?"result"in n?"result":"invocation":null}function cr(t){return pn(t)?.id}function ur(t){let e=pn(t);if(!e?.action_type)return null;let o=e.input?.query;return `${e.action_type}:${o||""}`}function Se(t){let e=t.filter(r=>lr(r)==="result"),n=new Set(e.map(r=>cr(r)).filter(Boolean)),o=new Set(e.map(r=>ur(r)).filter(Boolean));return t.filter(r=>{if(lr(r)==="invocation"){let a=cr(r),s=ur(r);if(a&&n.has(a)||s&&o.has(s))return false}return true})}function we({output:t,ContentComponent:e}){let n=j(),o=e??n?.ContentComponent,r=t?.contents,a=useMemo(()=>r?Se(r.filter(s=>s.user_visibility==="visible")):[],[r]);return !t||!t.output||!a.length?null:jsx("div",{children:a.map(s=>o?jsx(o,{content:s},s.id):jsx("div",{className:"text-sm",children:typeof s.content=="string"?s.content:JSON.stringify(s.content)},s.id))},t.output.id)}function dr(t){return t!==null&&typeof t=="object"&&"Valid"in t&&"String"in t}function T(t){if(typeof t=="string")return t;if(dr(t))return t.Valid?t.String:void 0}function aa(t,e){return T(t)??e}var pr={v:"5.10.2",fr:60,ip:0,op:180,w:144,h:144,nm:"system-solid-719-spinner-circle",ddd:0,assets:[{id:"comp_6",nm:"loop-snake-alt",fr:60,layers:[{ddd:0,ind:1,ty:0,nm:"mask-2",td:1,refId:"comp_7",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[72,72,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:144,h:144,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"circle 2",tt:2,tp:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[-30.652,0],[0,30.652],[30.652,0],[0,-30.652]],o:[[30.652,0],[0,-30.652],[-30.652,0],[0,30.652]],v:[[0,55.5],[55.5,0],[0,-55.5],[-55.5,0]],c:true},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.071,.075,.192,1],ix:3,x:`var $bm_rt;
8
8
  $bm_rt = comp('system-solid-719-spinner-circle').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:4},w:{a:0,k:9,ix:5},lc:2,lj:1,ml:4,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"fl",c:{a:0,k:[.071,.075,.192,1],ix:4,x:`var $bm_rt;
9
9
  $bm_rt = comp('system-solid-719-spinner-circle').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:5},r:1,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Fill",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"circle",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:300,st:0,ct:1,bm:0}]},{id:"comp_7",nm:"mask-2",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1108",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:1,k:[{i:{x:[.833],y:[.833]},o:{x:[.167],y:[.167]},t:0,s:[0]},{t:180,s:[-360]}],ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{d:1,ty:"el",s:{a:0,k:[111,111],ix:2},p:{a:0,k:[0,0],ix:3},nm:"Ellipse Path 1",mn:"ADBE Vector Shape - Ellipse",hd:false},{ty:"tm",s:{a:1,k:[{i:{x:[.33],y:[1]},o:{x:[.335],y:[0]},t:90,s:[99.9]},{t:157,s:[0]}],ix:1},e:{a:1,k:[{i:{x:[.33],y:[1]},o:{x:[.33],y:[0]},t:111,s:[100]},{t:180,s:[.1]}],ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:90,op:991,st:90,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:2,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{d:1,ty:"el",s:{a:0,k:[111,111],ix:2},p:{a:0,k:[0,0],ix:3},nm:"Ellipse Path 1",mn:"ADBE Vector Shape - Ellipse",hd:false},{ty:"tm",s:{a:1,k:[{i:{x:[.33],y:[1]},o:{x:[.335],y:[0]},t:0,s:[99.9]},{t:67,s:[0]}],ix:1},e:{a:1,k:[{i:{x:[.33],y:[1]},o:{x:[.33],y:[0]},t:21,s:[100]},{t:90,s:[.1]}],ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:90,st:0,ct:1,bm:0}]},{id:"comp_9",nm:"mask-1",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1107",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:1,k:[{i:{x:[.584],y:[.217]},o:{x:[.247],y:[0]},t:0,s:[0]},{i:{x:[.647],y:[.59]},o:{x:[.314],y:[.277]},t:9,s:[18.902]},{i:{x:[.649],y:[.675]},o:{x:[.315],y:[.302]},t:13,s:[36.82]},{i:{x:[.693],y:[1]},o:{x:[.208],y:[.228]},t:18,s:[63.991]},{t:240,s:[1080]}],ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:.833,y:.833},o:{x:.26,y:0},t:168,s:[{i:[[-30.652,0],[-4.25,4.25],[30.652,0],[5.125,5.125]],o:[[30.652,0],[-4.25,4.25],[-30.652,0],[6,6.5]],v:[[0,55],[45,32.75],[0,55.5],[-45.25,32.5]],c:true}]},{i:{x:.833,y:.833},o:{x:.167,y:.167},t:186,s:[{i:[[-43.5,0],[4.456,-17.326],[30.652,0],[2.907,16.173]],o:[[38.5,0],[-2.411,15.677],[-30.652,0],[-5.064,-20.184]],v:[[0,39.201],[49.544,18.576],[0,55.5],[-49.686,18.434]],c:true}]},{i:{x:.05,y:1},o:{x:.167,y:.167},t:196,s:[{i:[[-50,0],[0,-29.209],[30.652,0],[1.285,24.253]],o:[[50.75,0],[-1.065,24.034],[-30.652,0],[0,-29.896]],v:[[0,14.948],[52.868,8.209],[0,55.5],[-52.931,8.146]],c:true}]},{t:240,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:168,op:350,st:120,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:2,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{d:1,ty:"el",s:{a:0,k:[111,111],ix:2},p:{a:0,k:[0,0],ix:3},nm:"Ellipse Path 1",mn:"ADBE Vector Shape - Ellipse",hd:false},{ty:"tm",s:{a:1,k:[{i:{x:[.334],y:[1]},o:{x:[.333],y:[0]},t:0,s:[0]},{t:48,s:[35]}],ix:1},e:{a:1,k:[{i:{x:[.334],y:[1]},o:{x:[.333],y:[0]},t:0,s:[100]},{t:48,s:[65]}],ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:168,st:0,ct:1,bm:0}]},{id:"comp_11",nm:"mask-3",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1109",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:.833,y:.833},o:{x:.26,y:0},t:48,s:[{i:[[-30.652,0],[-4.25,4.25],[30.652,0],[5.125,5.125]],o:[[30.652,0],[-4.25,4.25],[-30.652,0],[6,6.5]],v:[[0,55],[45,32.75],[0,55.5],[-45.25,32.5]],c:true}]},{i:{x:.833,y:.833},o:{x:.167,y:.167},t:66,s:[{i:[[-43.5,0],[4.456,-17.326],[30.652,0],[2.907,16.173]],o:[[38.5,0],[-2.411,15.677],[-30.652,0],[-5.064,-20.184]],v:[[0,39.201],[49.544,18.576],[0,55.5],[-49.686,18.434]],c:true}]},{i:{x:.05,y:1},o:{x:.167,y:.167},t:76,s:[{i:[[-50,0],[0,-29.209],[30.652,0],[1.285,24.253]],o:[[50.75,0],[-1.065,24.034],[-30.652,0],[0,-29.896]],v:[[0,14.948],[52.868,8.209],[0,55.5],[-52.931,8.146]],c:true}]},{t:120,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:48,op:523,st:0,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{d:1,ty:"el",s:{a:0,k:[111,111],ix:2},p:{a:0,k:[0,0],ix:3},nm:"Ellipse Path 1",mn:"ADBE Vector Shape - Ellipse",hd:false},{ty:"tm",s:{a:1,k:[{i:{x:[.334],y:[1]},o:{x:[.333],y:[0]},t:0,s:[0]},{t:48,s:[35]}],ix:1},e:{a:1,k:[{i:{x:[.334],y:[1]},o:{x:[.333],y:[0]},t:0,s:[100]},{t:48,s:[65]}],ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:49,st:0,ct:1,bm:0}]},{id:"comp_14",nm:"mask-4",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1110",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:1,k:[{i:{x:[.667],y:[1]},o:{x:[.167],y:[.167]},t:0,s:[0]},{t:90,s:[100]}],ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:.833,y:.833},o:{x:.167,y:.167},t:0,s:[{i:[[-0.276,0],[0,-0.276],[.276,0],[0,.276]],o:[[.276,0],[0,.276],[-0.276,0],[0,-0.276]],v:[[0,-0.5],[.5,0],[0,.5],[-0.5,0]],c:true}]},{t:120,s:[{i:[[-30.154,0],[0,-30.154],[30.154,0],[0,30.154]],o:[[30.154,0],[0,30.154],[-30.154,0],[0,-30.154]],v:[[0,-54.598],[54.598,0],[0,54.598],[-54.598,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:0,k:0,ix:1},e:{a:0,k:100,ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:1800,st:0,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:1,k:[{i:{x:[.161],y:[1]},o:{x:[.167],y:[.167]},t:0,s:[100]},{t:60,s:[0]}],ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:.161,y:1},o:{x:.167,y:.167},t:0,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}]},{t:60,s:[{i:[[-37.003,0],[0,-37.003],[37.003,0],[0,37.003]],o:[[37.003,0],[0,37.003],[-37.003,0],[0,-37.003]],v:[[0,-67],[67,0],[0,67],[-67,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:0,k:0,ix:1},e:{a:0,k:100,ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:1800,st:0,ct:1,bm:0}]},{id:"comp_16",nm:"mask-5",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1111",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:0,y:.66},o:{x:.124,y:.088},t:20,s:[{i:[[-0.276,0],[0,-0.276],[.276,0],[0,.276]],o:[[.276,0],[0,.276],[-0.276,0],[0,-0.276]],v:[[0,-0.5],[.5,0],[0,.5],[-0.5,0]],c:true}]},{t:60,s:[{i:[[-30.154,0],[0,-30.154],[30.154,0],[0,30.154]],o:[[30.154,0],[0,30.154],[-30.154,0],[0,-30.154]],v:[[0,-54.598],[54.598,0],[0,54.598],[-54.598,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:0,k:0,ix:1},e:{a:0,k:100,ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:20,op:1800,st:0,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:1,k:[{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:0,s:[100]},{t:60,s:[0]}],ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:.507,y:1},o:{x:.095,y:.321},t:0,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}]},{t:60,s:[{i:[[-37.003,0],[0,-37.003],[37.003,0],[0,37.003]],o:[[37.003,0],[0,37.003],[-37.003,0],[0,-37.003]],v:[[0,-67],[67,0],[0,67],[-67,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:0,k:0,ix:1},e:{a:0,k:100,ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:1800,st:0,ct:1,bm:0}]},{id:"comp_19",nm:"mask-6",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"Null 1112",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[78.6,78.6,100],ix:6,l:2}},ao:0,ip:0,op:1800,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:"mask",parent:3,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[.514,-0.84,0],ix:2,l:2},a:{a:0,k:[.514,-6.24,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[0,0],[-12.745,-9.902],[-2.377,-1.327],[-8.708,-0.155],[-4.427,1.116],[-5.211,16.683],[-0.162,4.273],[.683,3.57],[16.218,4.737],[3.846,.074],[4.596,-1.531],[-0.017,-17.15],[-13.185,-6.083],[-3.505,-0.454],[-6.139,3.186],[-3.046,5.293],[-0.309,4.673],[.703,2.893],[4.329,3.821],[5.306,.603],[4.422,-2.403],[2.136,-3.916],[-0.144,-3.846],[-3.333,-3.451],[-1.877,-0.92],[-3.188,.401],[-1.893,5.145],[.978,2.596],[2.775,.798],[1.781,-2.308],[-1.419,-1.448]],o:[[.965,16.115],[2.149,1.67],[7.626,4.259],[4.598,.082],[16.65,-4.196],[1.275,-4.083],[.138,-3.624],[-3.192,-16.68],[-3.724,-1.088],[-4.887,-0.094],[-16.161,5.384],[.287,14.428],[3.249,1.499],[6.853,.887],[5.491,-2.85],[2.336,-4.06],[.198,-3.003],[-1.376,-5.661],[-4.129,-3.645],[-5.084,-0.578],[-3.952,2.148],[-1.841,3.376],[.182,4.869],[1.49,1.543],[3.02,1.48],[5.353,-0.673],[1.032,-2.804],[-1.139,-3.025],[-2.704,-0.778],[-1.14,1.477],[0,0]],v:[[-55.765,-4.143],[-34.151,37.195],[-27.316,41.629],[-2.358,48.14],[11.243,46.45],[46.671,12.649],[48.717,.071],[47.804,-10.664],[15.642,-45.824],[4.204,-47.466],[-10.148,-45.15],[-37.914,-6.587],[-16.262,27.132],[-6.024,29.983],[13.888,26.321],[26.864,13.719],[30.785,.393],[29.933,-8.55],[21.059,-23.045],[6.42,-29.442],[-8.246,-26.497],[-17.475,-17.167],[-20.027,-5.992],[-14.434,7.02],[-9.293,10.7],[.313,12.253],[12.328,2.889],[12.294,-5.579],[5.835,-11.66],[-1.807,-9.436],[-1.903,-4.143]],c:false},ix:2},nm:"Path 3",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:0,k:0,ix:1},e:{a:1,k:[{i:{x:[.667],y:[1]},o:{x:[.167],y:[.167]},t:39,s:[0]},{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:97.559,s:[100]},{i:{x:[.667],y:[1]},o:{x:[.298],y:[0]},t:117.559,s:[100]},{i:{x:[.802],y:[1]},o:{x:[.333],y:[0]},t:193.559,s:[45.895]},{t:228,s:[0]}],ix:2},o:{a:0,k:0,ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:1,ml:4,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 33",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:194,st:0,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:"mask",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:1,k:[{i:{x:[.652],y:[.354]},o:{x:[.443],y:[.213]},t:0,s:[0]},{i:{x:[.526],y:[.666]},o:{x:[.231],y:[.231]},t:118,s:[-473.927]},{t:240,s:[-1384.503]}],ix:10},p:{a:0,k:[0,0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{t:118.559,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}],h:1},{i:{x:.29,y:1},o:{x:.333,y:0},t:194,s:[{i:[[-26.752,3.759],[0,-30.652],[30.646,-1.513],[0,30.652]],o:[[21.768,-3.059],[0,30.652],[-30.615,1.511],[0,-12.422]],v:[[-2.911,-43.444],[49.68,1.935],[-0.898,54.175],[-55.863,-2.206]],c:true}]},{t:240,s:[{i:[[-30.652,0],[0,-30.652],[30.652,0],[0,30.652]],o:[[30.652,0],[0,30.652],[-30.652,0],[0,-30.652]],v:[[0,-55.5],[55.5,0],[0,55.5],[-55.5,0]],c:true}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"tm",s:{a:1,k:[{t:0,s:[1.1],h:1},{i:{x:[.728],y:[1]},o:{x:[.28],y:[-0.325]},t:39,s:[0]},{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:194,s:[0]},{t:240,s:[1.1]}],ix:1},e:{a:1,k:[{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:0,s:[73.3]},{t:73.559,s:[0],h:1},{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:194,s:[82.8]},{t:240,s:[73.3]}],ix:2},o:{a:1,k:[{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:0,s:[91]},{t:39,s:[-89],h:1},{i:{x:[.833],y:[.833]},o:{x:[.333],y:[0]},t:194,s:[-382]},{t:240,s:[-319]}],ix:3},m:1,ix:2,nm:"Trim Paths 1",mn:"ADBE Vector Filter - Trim",hd:false},{ty:"st",c:{a:0,k:[.070588238537,.074509806931,.192156866193,1],ix:3},o:{a:0,k:100,ix:4},w:{a:0,k:11.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Ellipse 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:595,st:0,ct:1,bm:0}]}],layers:[{ddd:0,ind:1,ty:3,nm:"control",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,ef:[{ty:5,nm:"primary",np:3,mn:"ADBE Color Control",ix:1,en:1,ef:[{ty:2,nm:"Color",mn:"ADBE Color Control-0001",ix:1,v:{a:0,k:[.071,.075,.192],ix:1}}]}],ip:0,op:1751,st:0,bm:0},{ddd:0,ind:8,ty:0,nm:"loop-snake-alt",refId:"comp_6",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[72,72,0],ix:2,l:2},a:{a:0,k:[72,72,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:144,h:144,ip:0,op:190,st:0,bm:0}],markers:[{tm:0,cm:"default:loop-snake-alt",dr:180}]};var mr={v:"5.12.1",fr:60,ip:0,op:59,w:500,h:500,nm:"system-solid-31-check",ddd:0,assets:[{id:"comp_1",nm:"hover-check",fr:60,layers:[{ddd:0,ind:1,ty:4,nm:".primary.design",cl:"primary design",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250,250,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[2083,2083,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[.26,0],[.2,.19],[0,0],[-0.39,.39],[-0.39,-0.39],[0,0],[0,0],[-0.39,-0.39],[.39,-0.39],[0,0]],o:[[-0.26,0],[0,0],[-0.39,-0.39],[.39,-0.39],[0,0],[0,0],[.39,-0.39],[.39,.39],[0,0],[-0.2,.19]],v:[[-1.34,4],[-2.05,3.71],[-4.55,1.2],[-4.55,-0.21],[-3.14,-0.21],[-1.34,1.59],[3.47,-3.21],[4.88,-3.21],[4.88,-1.8],[-0.63,3.71]],c:true},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ind:1,ty:"sh",ix:2,ks:{a:0,k:{i:[[5.41,0],[0,0],[-0.13,-5.51],[-5.41,0],[0,0],[.13,5.51]],o:[[0,0],[-5.51,.14],[.13,5.43],[0,0],[5.51,-0.14],[-0.13,-5.43]],v:[[0,-10],[-0.24,-10],[-10,.24],[0,10],[.24,10],[10,-0.24]],c:true},ix:2},nm:"Path 2",mn:"ADBE Vector Shape - Group",hd:false},{ty:"fl",c:{a:0,k:[.071,.075,.192,1],ix:4,x:`var $bm_rt;
10
10
  $bm_rt = comp('system-solid-31-check').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:5},r:1,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Fill",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:3,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:60,op:305,st:60,ct:1,bm:0},{ddd:0,ind:2,ty:4,nm:".primary.design",cl:"primary design",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250,250,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[2083,2083,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[.26,0],[.2,.19],[0,0],[-0.39,.39],[-0.39,-0.39],[0,0],[0,0],[-0.39,-0.39],[.39,-0.39],[0,0]],o:[[-0.26,0],[0,0],[-0.39,-0.39],[.39,-0.39],[0,0],[0,0],[.39,-0.39],[.39,.39],[0,0],[-0.2,.19]],v:[[-1.34,4],[-2.05,3.71],[-4.55,1.2],[-4.55,-0.21],[-3.14,-0.21],[-1.34,1.59],[3.47,-3.21],[4.88,-3.21],[4.88,-1.8],[-0.63,3.71]],c:true},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ind:1,ty:"sh",ix:2,ks:{a:0,k:{i:[[5.41,0],[0,0],[-0.13,-5.51],[-5.41,0],[0,0],[.13,5.51]],o:[[0,0],[-5.51,.14],[.13,5.43],[0,0],[5.51,-0.14],[-0.13,-5.43]],v:[[0,-10],[-0.24,-10],[-10,.24],[0,10],[.24,10],[10,-0.24]],c:true},ix:2},nm:"Path 2",mn:"ADBE Vector Shape - Group",hd:false},{ty:"fl",c:{a:0,k:[.071,.075,.192,1],ix:4,x:`var $bm_rt;
@@ -20,7 +20,7 @@ $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Col
20
20
  $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:4},w:{a:0,k:52,ix:5},lc:2,lj:1,ml:10,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:3,op:54,st:0,ct:1,bm:0},{ddd:0,ind:5,ty:4,nm:".primary.design",cl:"primary design",parent:3,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[50.004,10.799,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,41.667],[0,-41.667]],c:false},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.071,.075,.192,1],ix:3,x:`var $bm_rt;
21
21
  $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:4},w:{a:0,k:42,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,-14.5],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:3,op:54,st:0,ct:1,bm:0},{ddd:0,ind:6,ty:0,nm:"mask-1",td:1,refId:"comp_3",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250,250,0],ix:2,l:2},a:{a:0,k:[250,250,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:500,h:500,ip:1,op:54,st:1,bm:0},{ddd:0,ind:7,ty:4,nm:".primary.design",cl:"primary design",tt:2,tp:6,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250.004,239.584,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[0,0],[0,0],[0,0]],o:[[0,0],[0,0],[0,0]],v:[[-192.709,182.293],[0,-182.293],[192.709,182.293]],c:true},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[.071,.075,.192,1],ix:3,x:`var $bm_rt;
22
22
  $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:4},w:{a:0,k:31.3,ix:5},lc:2,lj:2,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Stroke",hd:false,cl:"primary"},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false},{ty:"fl",c:{a:0,k:[.071,.075,.192,1],ix:4,x:`var $bm_rt;
23
- $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:5},r:1,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Fill",hd:false,cl:"primary"}],ip:1,op:54,st:0,ct:1,bm:0}]},{id:"comp_3",nm:"mask-1",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"NULL 2",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:1,k:[{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:11,s:[0]},{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:17.25,s:[-30]},{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:23.5,s:[30]},{i:{x:[.16],y:[1]},o:{x:[.333],y:[0]},t:31,s:[-30]},{t:46,s:[0]}],ix:10},p:{a:0,k:[250,284,0],ix:2,l:2},a:{a:0,k:[50,50,0],ix:1,l:2},s:{a:1,k:[{i:{x:[0,0,.2],y:[1,1,1]},o:{x:[.333,.333,.333],y:[0,0,0]},t:0,s:[100,100,100]},{i:{x:[.3,.3,.3],y:[1,1,1]},o:{x:[1,1,.8],y:[0,0,0]},t:16,s:[180,180,100]},{i:{x:[.3,.3,.3],y:[1,1,1]},o:{x:[.7,.7,.7],y:[0,0,0]},t:35,s:[180,180,100]},{t:58,s:[100,100,100]}],ix:6,l:2}},ao:0,ip:0,op:53,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:".primary.design",cl:"primary design",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[50.005,120.173,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,0],[0,0]],c:false},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[1,1,1,1],ix:3},o:{a:0,k:100,ix:4},w:{a:1,k:[{i:{x:[0],y:[1]},o:{x:[.333],y:[0]},t:0,s:[52]},{i:{x:[0],y:[1]},o:{x:[1],y:[0]},t:10,s:[150]},{i:{x:[.833],y:[.833]},o:{x:[1],y:[0]},t:29,s:[150]},{t:53,s:[52]}],ix:5},lc:2,lj:1,ml:10,bm:0,nm:"Stroke 1",mn:"ADBE Vector Graphic - Stroke",hd:false},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:53,st:-1,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:".primary.design",cl:"primary design",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[50.004,10.799,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:0,y:1},o:{x:.333,y:0},t:0,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,41.667],[0,-41.667]],c:false}]},{i:{x:0,y:1},o:{x:1,y:0},t:10,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[.004,142.667],[0,-41.667]],c:false}]},{i:{x:.833,y:.833},o:{x:1,y:0},t:29,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[.004,142.667],[0,-41.667]],c:false}]},{t:53,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,41.667],[0,-41.667]],c:false}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[1,1,1,1],ix:3},o:{a:0,k:100,ix:4},w:{a:1,k:[{i:{x:[0],y:[1]},o:{x:[.333],y:[0]},t:0,s:[42]},{i:{x:[0],y:[1]},o:{x:[1],y:[0]},t:10,s:[150]},{i:{x:[.833],y:[.833]},o:{x:[1],y:[0]},t:29,s:[150]},{t:53,s:[42]}],ix:5},lc:2,lj:2,bm:0,nm:"Stroke 1",mn:"ADBE Vector Graphic - Stroke",hd:false},{ty:"tr",p:{a:0,k:[0,-14.5],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:53,st:-1,ct:1,bm:0}]}],layers:[{ddd:0,ind:1,ty:3,nm:"control",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,ef:[{ty:5,nm:"primary",np:3,mn:"ADBE Color Control",ix:1,en:1,ef:[{ty:2,nm:"Color",mn:"ADBE Color Control-0001",ix:1,v:{a:0,k:[.071,.075,.192],ix:1}}]}],ip:0,op:131,st:0,bm:0},{ddd:0,ind:3,ty:0,nm:"hover-warning",refId:"comp_2",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250,250,0],ix:2,l:2},a:{a:0,k:[250,250,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:500,h:500,ip:0,op:70,st:0,bm:0}],markers:[{tm:0,cm:"default:hover-warning",dr:60}],props:{}};var yr=null,Ne=null,gn=new Set;function da(){return Ne||(typeof window>"u"?Promise.resolve():(Ne=import('@lordicon/react').then(t=>{yr=t.Player,gn.forEach(e=>e());}),Ne))}typeof window<"u"&&da();function pa(t){return gn.add(t),()=>gn.delete(t)}function ma(){return yr}function fa(){return null}function ga(){let[t,e]=useState("#000000");return useEffect(()=>{if(typeof window>"u")return;let n=()=>{let r=document.documentElement.classList.contains("dark");e(r?"#ffffff":"#000000");};n();let o=new MutationObserver(r=>{r.forEach(a=>{a.attributeName==="class"&&n();});});return o.observe(document.documentElement,{attributes:true}),()=>o.disconnect()},[]),t}function vt({status:t,color:e,size:n=16,className:o}){let r=useRef(null),a=useRef(null),s=useRef(null),i=useSyncExternalStore(pa,ma,fa),c=ga(),l=e||c;return useEffect(()=>{i&&(t==="loading"?r.current?.playFromBeginning?.():t==="finished"?(r.current?.pause?.(),a.current?.playFromBeginning?.()):t==="failed"&&(r.current?.pause?.(),s.current?.playFromBeginning?.()));},[t,i]),i?jsxs("div",{className:o,style:{width:n,height:n,position:"relative"},children:[jsx("div",{style:{position:"absolute",opacity:t==="loading"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:r,size:n,icon:pr,colorize:l,onComplete:()=>r.current?.playFromBeginning?.()})}),jsx("div",{style:{position:"absolute",opacity:t==="finished"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:a,size:n,icon:mr,colorize:l})}),jsx("div",{style:{position:"absolute",opacity:t==="failed"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:s,size:n,icon:fr,colorize:l})})]}):jsx("div",{className:o,style:{width:n,height:n}})}function ae(t,e){return t==="json"||e==="json"||e==="ui_generation"}var hr=(c=>(c.Pending="pending",c.Running="running",c.Success="success",c.Error="error",c.RequiresInfo="requires info",c.GoToStep="go to step",c.Skipped="skipped",c.Break="break",c))(hr||{}),yn=(a=>(a.Initializing="initializing",a.Running="running",a.ProcessingDatasets="processing datasets",a.Completed="completed",a.Failed="failed",a))(yn||{});var xr={Finished:"step finished",Failed:"step error"};function Ie({step:t}){let e=T(t.action_type)||"step",n=t.currentStatus;if(!n)return null;let o="loading";n.status===xr.Finished||n.status==="completed"?o="finished":(n.status===xr.Failed||n.status==="failed")&&(o="failed");let r,a=T(n.message);return a?r=a:o==="finished"?r=T(t.finished_message)||`Finished ${e}`:o==="failed"?r=`Failed: ${e}`:r=T(t.running_message)||`Running ${e}...`,jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[jsx(vt,{status:o}),r]})}function Ee({step:t,ContentComponent:e}){if(T(t.user_output_visibility)!=="visible")return null;let n=T(t.action_type);return jsxs(Fragment,{children:[n!=="bot.invoke"&&n!=="invoke_bot"&&jsx(Ie,{step:t}),jsx(Mt,{eventsByID:t.eventsByID,ContentComponent:e})]})}function De({event:t,ContentComponent:e}){let n=j(),o=e??n?.ContentComponent;if(!t)return null;switch(t.type){case "output":return t.Output?jsx(we,{output:t.Output,ContentComponent:o}):null;case "step":return t.Step?jsx(Ee,{step:t.Step,ContentComponent:o}):null;default:return null}}function Mt({eventsByID:t,ContentComponent:e}){return jsx(Fragment,{children:Object.values(t).map(n=>jsx(De,{event:n,ContentComponent:e},n.id))})}function se({content:t,className:e}){return t?.length?jsx("div",{className:e||"prose dark:prose-invert max-w-4xl w-full leading-normal",children:jsx("p",{style:{whiteSpace:"pre-wrap"},children:t})}):null}function Ca(t){let e=[],n=t;for(;n.length>0;){let o=n.indexOf("{"),r=n.indexOf("["),a=-1,s=true;if(o>=0&&(r<0||o<r)?(a=o,s=true):r>=0&&(a=r,s=false),a<0){n.trim()&&e.push({type:"text",content:n});break}if(a>0){let d=n.slice(0,a);d.trim()&&e.push({type:"text",content:d});}let i=0,c=a,l=s?"{":"[",u=s?"}":"]";for(let d=a;d<n.length;d++)if(n[d]===l&&i++,n[d]===u&&i--,i===0){c=d+1;break}let p=n.slice(a,c);try{let d=JSON.parse(p);e.push({type:"json",content:d});}catch{e.push({type:"text",content:p});}n=n.slice(c);}return e}function _a(t){switch(t){case "muted":return "text-gray-500";case "error":return "text-red-500";case "warning":return "text-yellow-600";case "success":return "text-green-600";default:return ""}}function mt({content:t,className:e}){let n=useMemo(()=>t==null?"":typeof t=="string"?t:JSON.stringify(t,null,2),[t]),o=useMemo(()=>Ca(n),[n]);return n?.length?jsx("div",{className:e||"prose dark:prose-invert leading-normal",children:o.map((r,a)=>{if(r.type==="json"){let s=r.content;return s.message&&typeof s.message=="string"?jsx("p",{className:_a(s.style),children:s.message},a):jsx("pre",{className:"bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto text-sm",children:JSON.stringify(s,null,2)},a)}return jsx("p",{children:r.content},a)})}):null}function Pe({config:t,data:e,className:n,errorClassName:o,emptyClassName:r}){let a=useMemo(()=>!t?.chart_type||!t?.chart_title||!t?.series?.length||!t?.y_axes?.length?null:{chartType:t.chart_type,title:t.chart_title,xAxis:{label:t.x_axis.axis_label,key:t.x_axis.key,maxValue:t.x_axis.max_value,minValue:t.x_axis.min_value,type:t.x_axis.value_type,format:t.x_axis.format},yAxes:t.y_axes.map(l=>({label:l.axis_label,key:l.key,maxValue:l.max_value,minValue:l.min_value,type:l.value_type,format:l.format})),series:t.series.map(l=>({key:l.key,name:l.series_name,color:l.color,axisIndex:l.axis_index,filters:l.filters})),dataReduction:t.data_reduction,stacked:t.stacked,sort:t.sort},[t]);if(!a)return jsx("div",{className:o||"text-red-500",children:"Invalid chart configuration"});if(!e||e.length===0)return jsx("div",{className:r||"text-gray-500",children:"No data available for chart"});let s=null;switch(a.chartType){case "bar":case "histogram":s=kt;break;case "line":s=Bt;break;case "pie":s=Pt;break;case "scatter":s=Rt;break;case "heatmap":s=At;break}if(!s)return jsxs("div",{className:o||"text-red-500",children:["Unsupported chart type: ",a.chartType]});let i={[a.xAxis.key]:{label:a.xAxis.label,format:a.xAxis.format,type:a.xAxis.type},...a.series.reduce((l,u)=>(l[u.key]={label:u.name,color:u.color},l),{})},c={chartType:a.chartType,xAxis:a.xAxis,yAxes:a.yAxes,series:a.series};return jsx("div",{className:n||"w-full max-w-3xl",children:jsx(s,{title:a.title,data:e,displayConfig:i,dataConfig:c,stacked:a.stacked,disableAnimation:e.length>100})})}function Re({title:t,columns:e,data:n,className:o,maxRows:r=100}){let a=useMemo(()=>!n||n.length===0?[]:r?n.slice(0,r):n,[n,r]);return !e||e.length===0?jsx("div",{className:"text-gray-500",children:"No columns defined"}):!n||n.length===0?jsx("div",{className:"text-gray-500",children:"No data available"}):jsxs("div",{className:o||"w-full",children:[t&&jsx("h3",{className:"text-lg font-medium mb-3",children:t}),jsx("div",{className:"relative w-full overflow-x-auto rounded-lg border border-border",children:jsxs("table",{className:"w-full caption-bottom text-sm",children:[jsx("thead",{className:"[&_tr]:border-b",children:jsx("tr",{className:"border-b transition-colors bg-muted/50",children:e.map(s=>jsx("th",{className:"h-10 px-3 text-left align-middle font-medium text-muted-foreground",children:s.column_name},s.key))})}),jsx("tbody",{className:"[&_tr:last-child]:border-0",children:a.map((s,i)=>jsx("tr",{className:"border-b transition-colors hover:bg-muted/50",children:e.map(c=>jsx("td",{className:"p-3 align-middle text-foreground",children:tt(s[c.key],c.format,c.value_type)},c.key))},i))})]})}),n.length>r&&jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Showing ",r," of ",n.length," rows"]})]})}function Da(){return t=>{let e=[];visit(t,"code",(n,o,r)=>{let a=n;(!a.value||a.value.trim()==="")&&r&&typeof o=="number"&&e.push({parent:r,index:o});}),visit(t,"text",(n,o,r)=>{let s=n.value?.trim();s&&/^```[a-zA-Z]*$/.test(s)&&r&&typeof o=="number"&&e.push({parent:r,index:o});}),e.sort((n,o)=>o.index-n.index).forEach(({parent:n,index:o})=>{n.children.splice(o,1);});}}function M({content:t,className:e}){return t?.length?jsx("div",{className:q("prose dark:prose-invert leading-tight",e),children:jsx(Ia,{remarkPlugins:[Ea,Da],children:t})}):null}async function Ra(t,e,n,o,r){let a=new URLSearchParams({ThreadID:n}),s=`${t}/datasets/${encodeURIComponent(e)}?${a}`,i={};o?i.Authorization=`Bearer ${o}`:r&&(i["X-Erdo-Token"]=r);let c=await fetch(s,{headers:i});if(!c.ok)return null;let l=await c.json();return {id:l.id,name:T(l.name)||"dataset"}}async function Aa(t,e,n,o){let r=`${t}/datasets/${encodeURIComponent(e)}/download`,a={};n?a.Authorization=`Bearer ${n}`:o&&(a["X-Erdo-Token"]=o);let s=await fetch(r,{headers:a});if(!s.ok)throw new Error(`Download failed: ${s.statusText}`);return s.blob()}function Oa(t,e){let n=window.URL.createObjectURL(t),o=document.createElement("a");o.style.display="none",o.href=n,o.download=e,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o);}function $t({slug:t,invocationId:e,threadId:n,className:o}){let r=j(),[a,s]=useState(false),[i,c]=useState(null),[l,u]=useState(true),p=n||r?.threadId;useEffect(()=>{if(!t||!p){u(false);return}let m=false;async function f(){try{let g=null;r?.dataFetcher?.getDatasetDetails?g=await r.dataFetcher.getDatasetDetails(t,p):r?.baseUrl&&(g=await Ra(r.baseUrl,t,p,r.authToken,r.token)),m||c(g);}catch(g){console.error("Failed to fetch dataset details:",g);}finally{m||u(false);}}return f(),()=>{m=true;}},[t,p,r]);let d=useCallback(async m=>{if(m.preventDefault(),!(!i?.id||a)){s(true);try{let f;if(r?.dataFetcher?.downloadDataset)f=await r.dataFetcher.downloadDataset(i.id);else if(r?.baseUrl)f=await Aa(r.baseUrl,i.id,r.authToken,r.token);else throw new Error("No download method available");let g=`${i.name||"dataset"}.csv`;Oa(f,g);}catch(f){console.error("Download failed:",f);}finally{s(false);}}},[i,a,r]);return l||!i?.id?null:jsxs("a",{href:"#",onClick:d,className:`inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors ${o||""}`,children:[jsx(Download,{className:"h-4 w-4"}),a?"Downloading...":"Download",jsx("span",{className:"font-medium",children:i.name||"dataset"})]})}function bn({node:t,invocationId:e,warningClassName:n}){let o=t.content;if(!o)return null;let r=o.series||[],a=[...new Set(r.map(s=>s.dataset_slug).filter(s=>!!s))];return e?jsxs("div",{className:"my-4",children:[jsx(Ce,{chartType:o.chart_type,title:o.chart_title,invocationId:e,datasetSlugs:a,xAxis:{label:o.x_axis.axis_label,key:o.x_axis.key,type:o.x_axis.value_type,format:o.x_axis.format,maxValue:o.x_axis.max_value,minValue:o.x_axis.min_value},yAxes:o.y_axes.map(s=>({label:s.axis_label,key:s.key,type:s.value_type,format:s.format,maxValue:s.max_value,minValue:s.min_value})),series:r.filter(s=>!!s.dataset_slug).map(s=>({name:s.series_name,key:s.key,color:s.color,datasetSlug:s.dataset_slug,sqlQuery:s.sql_query,resourceKey:s.resource_key,axisIndex:s.axis_index,filters:s.filters?.map(i=>({key:i.key,operator:i.operator,value:i.value}))})),dataReduction:o.data_reduction?{strategy:o.data_reduction.strategy,target_points:o.data_reduction.target_points}:void 0,stacked:o.stacked,sort:o.sort?.map(s=>({key:s.key,direction:s.direction}))}),a.length>0&&jsx("div",{className:"flex gap-4 mt-2",children:a.map(s=>jsx($t,{slug:s,invocationId:e},s))})]}):jsx("div",{className:n||"my-4 p-4 border border-yellow-200 bg-yellow-50 dark:border-yellow-800 dark:bg-yellow-900/20 rounded text-sm text-yellow-700 dark:text-yellow-300",children:"Chart cannot be displayed: missing invocation ID for data fetching"})}function vn({node:t,className:e,invocationId:n,warningClassName:o}){let r=t.content;if(!r)return null;let a=r.dataset_slug;return !n||!a?jsxs("div",{className:o||"my-4 p-4 border border-yellow-200 bg-yellow-50 dark:border-yellow-800 dark:bg-yellow-900/20 rounded text-sm text-yellow-700 dark:text-yellow-300",children:["Table cannot be displayed: missing ",n?"dataset slug":"invocation ID"," for data fetching"]}):jsxs("div",{className:"my-4",children:[jsx(_e,{title:r.table_title,invocationId:n,datasetSlug:a,sqlQuery:r.sql_query,resourceKey:r.resource_key,columns:r.columns?.map(s=>({name:s.column_name,key:s.key,format:s.format,value_type:s.value_type})),className:e}),jsx("div",{className:"mt-2",children:jsx($t,{slug:a,invocationId:n})})]})}function Cn({node:t,className:e}){let n=t.content;return jsx("div",{className:"my-2",children:jsx(M,{content:n?.text||"",className:e})})}function _n({node:t,className:e,invocationId:n}){let r=t.content?.dataset_slug;return r?jsx("div",{className:"my-2",children:jsx($t,{slug:r,invocationId:n,className:e})}):null}function Sn({node:t,onSuggestionClick:e,suggestionButtonClassName:n}){let r=t.content?.suggestions||[];return r.length?jsx("div",{className:"flex flex-col gap-2 my-4",children:r.map((a,s)=>jsx("button",{onClick:e?()=>e(a):void 0,disabled:!e,className:n||"text-left px-3 py-2 bg-gray-100 dark:bg-gray-800 rounded hover:bg-gray-200 dark:hover:bg-gray-700 text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:a},s))}):null}var wn={Chart:bn,Table:vn,TextMarkdown:Cn,DownloadButton:_n,Suggestions:Sn};function Lt({nodes:t,className:e,invocationId:n,onSuggestionClick:o,customNodeComponents:r,warningClassName:a,suggestionButtonClassName:s}){if(!t||!Array.isArray(t))return null;let i={...wn,...r};return jsx(Fragment,{children:t.map((c,l)=>{let u=c;if(!u?._type)return null;let p=i[u._type];return p?jsx(p,{node:u,index:l,className:e,invocationId:n,onSuggestionClick:o,warningClassName:a,suggestionButtonClassName:s},`${u._type}-${l}`):null})})}function Ae({item:t,className:e}){let[n,o]=useState(false),r=t.content_type==="redacted_thinking",a="";typeof t.content=="string"?a=t.content:t.content&&typeof t.content=="object"&&(r?a=t.content.data||"Some of Claude's internal reasoning has been automatically encrypted for safety reasons. This doesn't affect the quality of responses.":a=t.content.thinking||"");let s=r?"border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-700":"border-gray-200 bg-gray-50 dark:bg-gray-800 dark:border-gray-700",i=r?"hover:bg-amber-100 dark:hover:bg-amber-800/30":"hover:bg-gray-100 dark:hover:bg-gray-700",c=r?"text-amber-700 dark:text-amber-300":"text-gray-600 dark:text-gray-400",l=r?"text-amber-800 dark:text-amber-200 italic":"text-gray-700 dark:text-gray-300",u=r?"border-amber-200 dark:border-amber-700":"border-gray-200 dark:border-gray-700";return jsxs("div",{className:`my-2 border rounded-lg ${s} ${e||""}`,children:[jsxs("button",{onClick:()=>o(!n),className:`w-full px-3 py-2 flex items-center gap-2 text-left transition-colors rounded-lg ${i}`,children:[n?jsx(ChevronDown,{className:"h-4 w-4 text-gray-500"}):jsx(ChevronRight,{className:"h-4 w-4 text-gray-500"}),jsx("span",{className:`text-sm font-medium ${c}`,children:r?"Encrypted Thinking...":"Thinking..."}),!n&&jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 ml-auto",children:"Click to expand"})]}),n&&jsx("div",{className:`px-3 pb-3 border-t ${u}`,children:jsx("div",{className:`mt-2 text-sm whitespace-pre-wrap ${l}`,children:a})})]})}function Er(t){try{return JSON.parse(t)}catch{return t}}function Ga(t){if(!t)return "";try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return ""}}function Nn({log:t}){let e=typeof t.message=="string"?Er(t.message):t.message,n=Ga(t.timestamp),o="text-xs font-mono py-0.5 px-1.5 rounded flex items-start",r="";switch(t.level){case "error":o+=" bg-red-50/50 dark:bg-red-950/30 text-red-600 dark:text-red-400 border-l-2 border-red-400 dark:border-red-600",r="text-red-500 dark:text-red-400";break;case "requires_info":o+=" bg-yellow-50/50 dark:bg-yellow-950/30 text-yellow-600 dark:text-yellow-400 border-l-2 border-yellow-400 dark:border-yellow-600",r="text-yellow-500 dark:text-yellow-400";break;default:o+=" bg-blue-50/40 dark:bg-blue-900/20 text-blue-500/90 dark:text-blue-300/80 border-l-2 border-blue-300 dark:border-blue-600/50",r="text-blue-400 dark:text-blue-400/70";}return jsx("div",{className:"my-0.5",children:jsx("div",{className:o,children:jsxs("div",{className:"flex items-start gap-2",children:[n&&jsx("span",{className:"text-[10px] opacity-60 whitespace-nowrap w-16 flex-shrink-0 pt-0.5",children:n}),t.level==="error"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z",clipRule:"evenodd"})})}),t.level==="requires_info"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})})}),t.level==="info"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})})}),jsx("div",{className:"flex-1 break-words whitespace-pre-wrap",children:String(e)})]})})})}function Oe({item:t,className:e}){let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=Er(n),r={level:o.level||"info",message:o.message||n,timestamp:o.timestamp};return jsx("div",{className:e,children:jsx(Nn,{log:r})})}function Ve({item:t,className:e}){let n=t.content;return n?.results?.length?jsx("div",{className:`max-w-2xl ${e||""}`,children:jsx("div",{className:"space-y-1",children:n.results.map(o=>jsx("div",{className:"group hover:shadow-sm transition-shadow rounded-sm py-2 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900",children:jsx("div",{className:"px-4",children:jsx("div",{className:"flex items-start justify-between gap-2",children:jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 font-medium text-xs leading-tight truncate text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 hover:underline",children:[jsx("span",{children:o.title}),jsxs("span",{className:"text-xs text-gray-500/60 dark:text-gray-400/60 flex-shrink-0",children:["(",new URL(o.url).hostname,")"]})]}),jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate leading-tight mt-0.5",children:o.description})]})})})},o.url))})}):null}function Me({item:t,className:e}){let n=t.content;return n?.content?.length?jsxs("div",{className:`max-w-4xl border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-900 ${e||""}`,children:[jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:jsxs("div",{className:"flex items-start justify-between",children:[jsxs("div",{className:"space-y-2",children:[jsxs("h3",{className:"flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[jsx(Globe,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"}),n.title||"Parsed Website Content"]}),n.description&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:n.description})]}),n.url&&jsxs("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-500 dark:hover:text-blue-300 transition-colors font-medium",children:[jsx(ExternalLink,{className:"h-3 w-3"}),"Visit"]})]})}),jsx("div",{className:"p-4",children:jsx(M,{content:n.content,className:"prose dark:prose-invert max-w-none leading-relaxed prose-sm"})})]}):null}var ts=Prism;function Ft({language:t,value:e,defaultOpen:n=false,title:o="View code",closeTitle:r="Hide code",className:a,theme:s="auto"}){let[i,c]=useState(n),[l,u]=useState(false),p=useRef(null);useEffect(()=>{if(!i){let y=p.current;y&&(y.scrollTop=y.scrollHeight);}},[i,e]);let d=useMemo(()=>s!=="auto"?s:typeof window>"u"?"light":document.documentElement.classList.contains("dark")||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[s]),m=useMemo(()=>d==="dark"?oneDark:oneLight,[d]),f=async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3);}catch{let y=document.createElement("textarea");y.value=e,document.body.appendChild(y),y.select(),document.execCommand("copy"),document.body.removeChild(y),u(true),setTimeout(()=>u(false),2e3);}},g=useMemo(()=>({margin:0,width:"100%",background:"transparent",padding:"1rem 0.5rem",fontSize:"0.825rem",maxWidth:"100vw",overflow:"auto"}),[]),h=useMemo(()=>({userSelect:"none",minWidth:"2.5em",paddingRight:"1em",color:"rgb(161 161 170)",opacity:"0.5"}),[]),k=useMemo(()=>({style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre",wordBreak:"break-word"}}),[]);return jsx(qt.Root,{open:i,onOpenChange:c,className:a,children:jsxs("div",{className:"relative w-full font-sans rounded-lg overflow-hidden border border-zinc-200 dark:border-zinc-800",children:[jsxs("div",{className:"flex items-center justify-between w-full px-4 py-1.5 bg-white/80 dark:bg-zinc-800/80 text-zinc-600 dark:text-zinc-100 backdrop-blur-sm border-b border-zinc-200 dark:border-zinc-800",children:[jsx("span",{className:"text-xs font-medium lowercase text-zinc-400 dark:text-zinc-500",children:t}),jsx("button",{onClick:f,className:"h-6 w-6 flex items-center justify-center rounded-md hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",children:l?jsx(Check,{className:"h-3 w-3 text-green-500"}):jsx(Copy,{className:"h-3 w-3 text-zinc-400 dark:text-zinc-500"})})]}),jsxs("div",{ref:p,className:`${i?"max-h-96":"max-h-[200px]"} overflow-auto relative`,children:[jsx("div",{className:"bg-zinc-50/50 dark:bg-zinc-950/70",children:jsx(ts,{language:t,style:m,PreTag:"div",showLineNumbers:true,wrapLines:false,wrapLongLines:false,startingLineNumber:1,className:"not-prose",customStyle:g,lineNumberStyle:h,codeTagProps:k,children:e})}),!i&&jsx("div",{className:"absolute bottom-0 inset-x-0 h-24 pointer-events-none bg-gradient-to-t from-zinc-50 dark:from-zinc-950 to-transparent",style:{marginBottom:"1.5rem"}})]}),jsx(qt.Trigger,{className:"absolute bottom-0 inset-x-0 flex items-center gap-2 text-sm text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300 p-2 justify-start bg-zinc-50/80 dark:bg-zinc-950/80 backdrop-blur-sm border-t border-zinc-200 dark:border-zinc-800 cursor-pointer",children:i?jsxs(Fragment,{children:[jsx(ChevronUp,{className:"h-4 w-4"}),r]}):jsxs(Fragment,{children:[jsx(ChevronDown,{className:"h-4 w-4"}),o]})})]})})}var Jt=Symbol("parsing"),ft=class{result;stack;key;state;stringBuffer;numberBuffer;quoteBuffer;escapeNext;unicode;isInTripleQuotes;constructor(){this.result=void 0,this.stack=[],this.key=void 0,this.state="START",this.stringBuffer="",this.numberBuffer="",this.quoteBuffer="",this.escapeNext=false,this.unicode="",this.isInTripleQuotes=false;}reset(){this.result=void 0,this.stack=[],this.key=void 0,this.state="START",this.stringBuffer="",this.numberBuffer="",this.quoteBuffer="",this.escapeNext=false,this.unicode="",this.isInTripleQuotes=false;}parse(e){return this.reset(),this.add(e)}add(e){for(let n=0;n<e.length;n++){let o=e[n];this.processChar(o);}return this.result}processChar(e){switch(this.state){case "START":this.handleStartState(e);break;case "IN_OBJECT":this.handleObjectState(e);break;case "IN_ARRAY":this.handleArrayState(e);break;case "IN_OBJECT_KEY":this.handleObjectKeyState(e);break;case "AFTER_KEY":this.handleAfterKeyState(e);break;case "IN_OBJECT_VALUE":this.handleObjectValueState(e);break;case "IN_STRING":this.handleStringState(e);break;case "IN_NUMBER":this.handleNumberState(e);break;case "IN_TRUE":this.handleLiteralState(e,"true");break;case "IN_FALSE":this.handleLiteralState(e,"false");break;case "IN_NULL":this.handleLiteralState(e,"null");break;case "IN_UNICODE":this.handleUnicodeState(e);break}}handleStartState(e){if(e==="{")this.startObject();else if(e==="[")this.startArray();else if(!this.isWhitespace(e))throw this.error("must start with { or [","start")}error(e,n){return new Error(`Invalid JSON in ${n}: ${e}`)}handleObjectState(e){if(e==="}")this.endObject();else if(e==='"')this.state="IN_OBJECT_KEY",this.stringBuffer="",this.key=void 0,this.quoteBuffer="";else if(e===",")this.key=void 0;else if(!this.isWhitespace(e))throw this.error(`Invalid character in object: ${e}`,"object")}handleArrayState(e){e==="]"?this.endArray():e===","||this.isWhitespace(e)||this.startValue(e);}handleObjectKeyState(e){e==='"'?(this.state="AFTER_KEY",this.key=this.stringBuffer,this.stringBuffer=""):(this.stringBuffer+=e,this.updateValueInParent(this.stringBuffer));}handleAfterKeyState(e){e===":"?this.state="IN_OBJECT_VALUE":this.isWhitespace(e)||this.isWhitespace(e)||(this.key=this.key+e);}handleObjectValueState(e){this.isWhitespace(e)||this.startValue(e);}handleStringState(e){if(this.escapeNext)this.handleEscapeChar(e);else if(e==="\\")this.escapeNext=true;else if(e==='"'){if(this.quoteBuffer+='"',this.stringBuffer===""&&this.quoteBuffer==='""')this.quoteBuffer="",this.isInTripleQuotes=true;else if(this.stringBuffer&&this.quoteBuffer==='"""'){this.quoteBuffer="",this.isInTripleQuotes=false,this.stringBuffer=this.stringBuffer.replace(/^\n+/,"").replace(/\n+$/,"").trim(),this.endString();return}}else {if(this.quoteBuffer){if(this.quoteBuffer==='"'&&!this.isInTripleQuotes){this.quoteBuffer="",this.endString(),this.processChar(e);return}else if(this.quoteBuffer==='"""'&&this.isInTripleQuotes){this.quoteBuffer="",this.isInTripleQuotes=false,this.endString(),this.processChar(e);return}this.stringBuffer+=this.quoteBuffer,this.quoteBuffer="";}this.stringBuffer+=e,this.updateValueInParent(this.stringBuffer);}}handleNumberState(e){e.match(/[0-9.eE+-]/)?(this.numberBuffer+=e,this.updateValueInParent(parseFloat(this.numberBuffer))):(this.endNumber(),this.processChar(e));}handleLiteralState(e,n){let o=n[this.stringBuffer.length];if(e===o)this.stringBuffer+=e,this.stringBuffer===n?this.endLiteral(n):this.updateValueInParent(this.stringBuffer);else throw this.error(`Invalid literal: expected ${n}`,"literal")}handleUnicodeState(e){if(this.unicode+=e,this.unicode.length===4){let n=parseInt(this.unicode,16);this.stringBuffer+=String.fromCharCode(n),this.unicode="",this.state="IN_STRING";}}handleEscapeChar(e){switch(e){case '"':case "\\":case "/":this.stringBuffer+=e;break;case "b":this.stringBuffer+="\b";break;case "f":this.stringBuffer+="\f";break;case "n":this.stringBuffer+=`
23
+ $bm_rt = comp('system-solid-56-warning').layer('control').effect('primary')('Color');`},o:{a:0,k:100,ix:5},r:1,bm:0,nm:".primary",mn:"ADBE Vector Graphic - Fill",hd:false,cl:"primary"}],ip:1,op:54,st:0,ct:1,bm:0}]},{id:"comp_3",nm:"mask-1",fr:60,layers:[{ddd:0,ind:1,ty:3,nm:"NULL 2",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:1,k:[{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:11,s:[0]},{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:17.25,s:[-30]},{i:{x:[.667],y:[1]},o:{x:[.333],y:[0]},t:23.5,s:[30]},{i:{x:[.16],y:[1]},o:{x:[.333],y:[0]},t:31,s:[-30]},{t:46,s:[0]}],ix:10},p:{a:0,k:[250,284,0],ix:2,l:2},a:{a:0,k:[50,50,0],ix:1,l:2},s:{a:1,k:[{i:{x:[0,0,.2],y:[1,1,1]},o:{x:[.333,.333,.333],y:[0,0,0]},t:0,s:[100,100,100]},{i:{x:[.3,.3,.3],y:[1,1,1]},o:{x:[1,1,.8],y:[0,0,0]},t:16,s:[180,180,100]},{i:{x:[.3,.3,.3],y:[1,1,1]},o:{x:[.7,.7,.7],y:[0,0,0]},t:35,s:[180,180,100]},{t:58,s:[100,100,100]}],ix:6,l:2}},ao:0,ip:0,op:53,st:0,bm:0},{ddd:0,ind:2,ty:4,nm:".primary.design",cl:"primary design",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[50.005,120.173,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:0,k:{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,0],[0,0]],c:false},ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[1,1,1,1],ix:3},o:{a:0,k:100,ix:4},w:{a:1,k:[{i:{x:[0],y:[1]},o:{x:[.333],y:[0]},t:0,s:[52]},{i:{x:[0],y:[1]},o:{x:[1],y:[0]},t:10,s:[150]},{i:{x:[.833],y:[.833]},o:{x:[1],y:[0]},t:29,s:[150]},{t:53,s:[52]}],ix:5},lc:2,lj:1,ml:10,bm:0,nm:"Stroke 1",mn:"ADBE Vector Graphic - Stroke",hd:false},{ty:"tr",p:{a:0,k:[0,0],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:53,st:-1,ct:1,bm:0},{ddd:0,ind:3,ty:4,nm:".primary.design",cl:"primary design",parent:1,sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[50.004,10.799,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,shapes:[{ty:"gr",it:[{ind:0,ty:"sh",ix:1,ks:{a:1,k:[{i:{x:0,y:1},o:{x:.333,y:0},t:0,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,41.667],[0,-41.667]],c:false}]},{i:{x:0,y:1},o:{x:1,y:0},t:10,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[.004,142.667],[0,-41.667]],c:false}]},{i:{x:.833,y:.833},o:{x:1,y:0},t:29,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[.004,142.667],[0,-41.667]],c:false}]},{t:53,s:[{i:[[0,0],[0,0]],o:[[0,0],[0,0]],v:[[0,41.667],[0,-41.667]],c:false}]}],ix:2},nm:"Path 1",mn:"ADBE Vector Shape - Group",hd:false},{ty:"st",c:{a:0,k:[1,1,1,1],ix:3},o:{a:0,k:100,ix:4},w:{a:1,k:[{i:{x:[0],y:[1]},o:{x:[.333],y:[0]},t:0,s:[42]},{i:{x:[0],y:[1]},o:{x:[1],y:[0]},t:10,s:[150]},{i:{x:[.833],y:[.833]},o:{x:[1],y:[0]},t:29,s:[150]},{t:53,s:[42]}],ix:5},lc:2,lj:2,bm:0,nm:"Stroke 1",mn:"ADBE Vector Graphic - Stroke",hd:false},{ty:"tr",p:{a:0,k:[0,-14.5],ix:2},a:{a:0,k:[0,0],ix:1},s:{a:0,k:[100,100],ix:3},r:{a:0,k:0,ix:6},o:{a:0,k:100,ix:7},sk:{a:0,k:0,ix:4},sa:{a:0,k:0,ix:5},nm:"Transform"}],nm:"Group 1",np:2,cix:2,bm:0,ix:1,mn:"ADBE Vector Group",hd:false}],ip:0,op:53,st:-1,ct:1,bm:0}]}],layers:[{ddd:0,ind:1,ty:3,nm:"control",sr:1,ks:{o:{a:0,k:0,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[0,0],ix:2,l:2},a:{a:0,k:[0,0,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,ef:[{ty:5,nm:"primary",np:3,mn:"ADBE Color Control",ix:1,en:1,ef:[{ty:2,nm:"Color",mn:"ADBE Color Control-0001",ix:1,v:{a:0,k:[.071,.075,.192],ix:1}}]}],ip:0,op:131,st:0,bm:0},{ddd:0,ind:3,ty:0,nm:"hover-warning",refId:"comp_2",sr:1,ks:{o:{a:0,k:100,ix:11},r:{a:0,k:0,ix:10},p:{a:0,k:[250,250,0],ix:2,l:2},a:{a:0,k:[250,250,0],ix:1,l:2},s:{a:0,k:[100,100,100],ix:6,l:2}},ao:0,w:500,h:500,ip:0,op:70,st:0,bm:0}],markers:[{tm:0,cm:"default:hover-warning",dr:60}],props:{}};var yr=null,Ne=null,gn=new Set;function da(){return Ne||(typeof window>"u"?Promise.resolve():(Ne=import('@lordicon/react').then(t=>{yr=t.Player,gn.forEach(e=>e());}),Ne))}typeof window<"u"&&da();function pa(t){return gn.add(t),()=>gn.delete(t)}function ma(){return yr}function fa(){return null}function ga(){let[t,e]=useState("#000000");return useEffect(()=>{if(typeof window>"u")return;let n=()=>{let r=document.documentElement.classList.contains("dark");e(r?"#ffffff":"#000000");};n();let o=new MutationObserver(r=>{r.forEach(a=>{a.attributeName==="class"&&n();});});return o.observe(document.documentElement,{attributes:true}),()=>o.disconnect()},[]),t}function vt({status:t,color:e,size:n=16,className:o}){let r=useRef(null),a=useRef(null),s=useRef(null),i=useSyncExternalStore(pa,ma,fa),c=ga(),l=e||c;return useEffect(()=>{i&&(t==="loading"?r.current?.playFromBeginning?.():t==="finished"?(r.current?.pause?.(),a.current?.playFromBeginning?.()):t==="failed"&&(r.current?.pause?.(),s.current?.playFromBeginning?.()));},[t,i]),i?jsxs("div",{className:o,style:{width:n,height:n,position:"relative"},children:[jsx("div",{style:{position:"absolute",opacity:t==="loading"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:r,size:n,icon:pr,colorize:l,onComplete:()=>r.current?.playFromBeginning?.()})}),jsx("div",{style:{position:"absolute",opacity:t==="finished"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:a,size:n,icon:mr,colorize:l})}),jsx("div",{style:{position:"absolute",opacity:t==="failed"?1:0,transition:"opacity 0.3s ease-in-out"},children:jsx(i,{ref:s,size:n,icon:fr,colorize:l})})]}):jsx("div",{className:o,style:{width:n,height:n}})}function ae(t,e){return t==="json"||e==="json"||e==="ui_generation"}var hr=(c=>(c.Pending="pending",c.Running="running",c.Success="success",c.Error="error",c.RequiresInfo="requires info",c.GoToStep="go to step",c.Skipped="skipped",c.Break="break",c))(hr||{}),yn=(a=>(a.Initializing="initializing",a.Running="running",a.ProcessingDatasets="processing datasets",a.Completed="completed",a.Failed="failed",a))(yn||{});var xr={Finished:"step finished",Failed:"step error"};function Ie({step:t}){let e=T(t.action_type)||"step",n=t.currentStatus;if(!n)return null;let o="loading";n.status===xr.Finished||n.status==="completed"?o="finished":(n.status===xr.Failed||n.status==="failed")&&(o="failed");let r,a=T(n.message);return a?r=a:o==="finished"?r=T(t.finished_message)||`Finished ${e}`:o==="failed"?r=`Failed: ${e}`:r=T(t.running_message)||`Running ${e}...`,jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[jsx(vt,{status:o}),r]})}function Ee({step:t,ContentComponent:e}){if(T(t.user_output_visibility)!=="visible")return null;let n=T(t.action_type);return jsxs(Fragment,{children:[n!=="bot.invoke"&&n!=="invoke_bot"&&jsx(Ie,{step:t}),jsx(Mt,{eventsByID:t.eventsByID,ContentComponent:e})]})}function De({event:t,ContentComponent:e}){let n=j(),o=e??n?.ContentComponent;if(!t)return null;switch(t.type){case "output":return t.Output?jsx(we,{output:t.Output,ContentComponent:o}):null;case "step":return t.Step?jsx(Ee,{step:t.Step,ContentComponent:o}):null;default:return null}}function Mt({eventsByID:t,ContentComponent:e}){return jsx(Fragment,{children:Object.values(t).map(n=>jsx(De,{event:n,ContentComponent:e},n.id))})}function se({content:t,className:e}){return t?.length?jsx("div",{className:e||"prose dark:prose-invert max-w-4xl w-full leading-normal",children:jsx("p",{style:{whiteSpace:"pre-wrap"},children:t})}):null}function Ca(t){let e=[],n=t;for(;n.length>0;){let o=n.indexOf("{"),r=n.indexOf("["),a=-1,s=true;if(o>=0&&(r<0||o<r)?(a=o,s=true):r>=0&&(a=r,s=false),a<0){n.trim()&&e.push({type:"text",content:n});break}if(a>0){let d=n.slice(0,a);d.trim()&&e.push({type:"text",content:d});}let i=0,c=a,l=s?"{":"[",u=s?"}":"]";for(let d=a;d<n.length;d++)if(n[d]===l&&i++,n[d]===u&&i--,i===0){c=d+1;break}let p=n.slice(a,c);try{let d=JSON.parse(p);e.push({type:"json",content:d});}catch{e.push({type:"text",content:p});}n=n.slice(c);}return e}function _a(t){switch(t){case "muted":return "text-gray-500";case "error":return "text-red-500";case "warning":return "text-yellow-600";case "success":return "text-green-600";default:return ""}}function mt({content:t,className:e}){let n=useMemo(()=>t==null?"":typeof t=="string"?t:JSON.stringify(t,null,2),[t]),o=useMemo(()=>Ca(n),[n]);return n?.length?jsx("div",{className:e||"prose dark:prose-invert leading-normal",children:o.map((r,a)=>{if(r.type==="json"){let s=r.content;return s.message&&typeof s.message=="string"?jsx("p",{className:_a(s.style),children:s.message},a):jsx("pre",{className:"bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto text-sm",children:JSON.stringify(s,null,2)},a)}return jsx("p",{children:r.content},a)})}):null}function Pe({config:t,data:e,className:n,errorClassName:o,emptyClassName:r}){let a=useMemo(()=>!t?.chart_type||!t?.chart_title||!t?.series?.length||!t?.y_axes?.length?null:{chartType:t.chart_type,title:t.chart_title,xAxis:{label:t.x_axis.axis_label,key:t.x_axis.key,maxValue:t.x_axis.max_value,minValue:t.x_axis.min_value,type:t.x_axis.value_type,format:t.x_axis.format},yAxes:t.y_axes.map(l=>({label:l.axis_label,key:l.key,maxValue:l.max_value,minValue:l.min_value,type:l.value_type,format:l.format})),series:t.series.map(l=>({key:l.key,name:l.series_name,color:l.color,axisIndex:l.axis_index,filters:l.filters})),dataReduction:t.data_reduction,stacked:t.stacked,sort:t.sort},[t]);if(!a)return jsx("div",{className:o||"text-red-500",children:"Invalid chart configuration"});if(!e||e.length===0)return jsx("div",{className:r||"text-gray-500",children:"No data available for chart"});let s=null;switch(a.chartType){case "bar":case "histogram":s=kt;break;case "line":s=Bt;break;case "pie":s=Pt;break;case "scatter":s=Rt;break;case "heatmap":s=At;break}if(!s)return jsxs("div",{className:o||"text-red-500",children:["Unsupported chart type: ",a.chartType]});let i={[a.xAxis.key]:{label:a.xAxis.label,format:a.xAxis.format,type:a.xAxis.type},...a.series.reduce((l,u)=>(l[u.key]={label:u.name,color:u.color},l),{})},c={chartType:a.chartType,xAxis:a.xAxis,yAxes:a.yAxes,series:a.series};return jsx("div",{className:n||"w-full max-w-3xl",children:jsx(s,{title:a.title,data:e,displayConfig:i,dataConfig:c,stacked:a.stacked,disableAnimation:e.length>100})})}function Re({title:t,columns:e,data:n,className:o,maxRows:r=100}){let a=useMemo(()=>!n||n.length===0?[]:r?n.slice(0,r):n,[n,r]);return !e||e.length===0?jsx("div",{className:"text-gray-500",children:"No columns defined"}):!n||n.length===0?jsx("div",{className:"text-gray-500",children:"No data available"}):jsxs("div",{className:o||"w-full",children:[t&&jsx("h3",{className:"text-lg font-medium mb-3",children:t}),jsx("div",{className:"relative w-full overflow-x-auto rounded-lg border border-border",children:jsxs("table",{className:"w-full caption-bottom text-sm",children:[jsx("thead",{className:"[&_tr]:border-b",children:jsx("tr",{className:"border-b transition-colors bg-muted/50",children:e.map(s=>jsx("th",{className:"h-10 px-3 text-left align-middle font-medium text-muted-foreground",children:s.column_name},s.key))})}),jsx("tbody",{className:"[&_tr:last-child]:border-0",children:a.map((s,i)=>jsx("tr",{className:"border-b transition-colors hover:bg-muted/50",children:e.map(c=>jsx("td",{className:"p-3 align-middle text-foreground",children:tt(s[c.key],c.format,c.value_type)},c.key))},i))})]})}),n.length>r&&jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Showing ",r," of ",n.length," rows"]})]})}function Da(){return t=>{let e=[];visit(t,"code",(n,o,r)=>{let a=n;(!a.value||a.value.trim()==="")&&r&&typeof o=="number"&&e.push({parent:r,index:o});}),visit(t,"text",(n,o,r)=>{let s=n.value?.trim();s&&/^```[a-zA-Z]*$/.test(s)&&r&&typeof o=="number"&&e.push({parent:r,index:o});}),e.sort((n,o)=>o.index-n.index).forEach(({parent:n,index:o})=>{n.children.splice(o,1);});}}function M({content:t,className:e}){return t?.length?jsx("div",{className:q("prose dark:prose-invert leading-tight",e),children:jsx(Ia,{remarkPlugins:[Ea,Da],children:t})}):null}async function Ra(t,e,n,o,r){let a=new URLSearchParams({ThreadID:n}),s=`${t}/datasets/${encodeURIComponent(e)}?${a}`,i={};o?i.Authorization=`Bearer ${o}`:r&&(i["X-Erdo-Token"]=r);let c=await fetch(s,{headers:i});if(!c.ok)return null;let l=await c.json();return {id:l.id,name:T(l.name)||"dataset"}}async function Aa(t,e,n,o,r,a,s){let i=`${t}/datasets/${encodeURIComponent(e)}/download`,c={"Content-Type":"application/json"};a?c.Authorization=`Bearer ${a}`:s&&(c["X-Erdo-Token"]=s);let l=await fetch(i,{method:"POST",headers:c,body:JSON.stringify({thread_id:n||"",query:o||"",resource_key:r||""})});if(!l.ok)throw new Error(`Download failed: ${l.statusText}`);return l.blob()}function Oa(t,e){let n=window.URL.createObjectURL(t),o=document.createElement("a");o.style.display="none",o.href=n,o.download=e,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o);}function $t({slug:t,invocationId:e,threadId:n,sqlQuery:o,resourceKey:r,className:a}){let s=j(),[i,c]=useState(false),[l,u]=useState(null),[p,d]=useState(true),m=n||s?.threadId;useEffect(()=>{if(!t||!m){d(false);return}let g=false;async function y(){try{let x=null;s?.dataFetcher?.getDatasetDetails?x=await s.dataFetcher.getDatasetDetails(t,m):s?.baseUrl&&(x=await Ra(s.baseUrl,t,m,s.authToken,s.token)),g||u(x);}catch(x){console.error("Failed to fetch dataset details:",x);}finally{g||d(false);}}return y(),()=>{g=true;}},[t,m,s]);let f=useCallback(async g=>{if(g.preventDefault(),!(!l?.id||i)){c(true);try{let y;if(s?.dataFetcher?.downloadDataset)y=await s.dataFetcher.downloadDataset(l.id,o,r);else if(s?.baseUrl)y=await Aa(s.baseUrl,l.id,m,o,r,s.authToken,s.token);else throw new Error("No download method available");let x=`${l.name||"dataset"}.csv`;Oa(y,x);}catch(y){console.error("Download failed:",y);}finally{c(false);}}},[l,i,s,m,o,r]);return p||!l?.id?null:jsxs("a",{href:"#",onClick:f,className:`inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors ${a||""}`,children:[jsx(Download,{className:"h-4 w-4"}),i?"Downloading...":"Download",jsx("span",{className:"font-medium",children:l.name||"dataset"})]})}function bn({node:t,invocationId:e,warningClassName:n}){let o=t.content;if(!o)return null;let r=o.series||[],a=[...new Set(r.map(s=>s.dataset_slug).filter(s=>!!s))];return e?jsxs("div",{className:"my-4",children:[jsx(Ce,{chartType:o.chart_type,title:o.chart_title,invocationId:e,datasetSlugs:a,xAxis:{label:o.x_axis.axis_label,key:o.x_axis.key,type:o.x_axis.value_type,format:o.x_axis.format,maxValue:o.x_axis.max_value,minValue:o.x_axis.min_value},yAxes:o.y_axes.map(s=>({label:s.axis_label,key:s.key,type:s.value_type,format:s.format,maxValue:s.max_value,minValue:s.min_value})),series:r.filter(s=>!!s.dataset_slug).map(s=>({name:s.series_name,key:s.key,color:s.color,datasetSlug:s.dataset_slug,sqlQuery:s.sql_query,resourceKey:s.resource_key,axisIndex:s.axis_index,filters:s.filters?.map(i=>({key:i.key,operator:i.operator,value:i.value}))})),dataReduction:o.data_reduction?{strategy:o.data_reduction.strategy,target_points:o.data_reduction.target_points}:void 0,stacked:o.stacked,sort:o.sort?.map(s=>({key:s.key,direction:s.direction}))}),a.length>0&&jsx("div",{className:"flex gap-4 mt-2",children:a.map(s=>jsx($t,{slug:s,invocationId:e},s))})]}):jsx("div",{className:n||"my-4 p-4 border border-yellow-200 bg-yellow-50 dark:border-yellow-800 dark:bg-yellow-900/20 rounded text-sm text-yellow-700 dark:text-yellow-300",children:"Chart cannot be displayed: missing invocation ID for data fetching"})}function vn({node:t,className:e,invocationId:n,warningClassName:o}){let r=t.content;if(!r)return null;let a=r.dataset_slug;return !n||!a?jsxs("div",{className:o||"my-4 p-4 border border-yellow-200 bg-yellow-50 dark:border-yellow-800 dark:bg-yellow-900/20 rounded text-sm text-yellow-700 dark:text-yellow-300",children:["Table cannot be displayed: missing ",n?"dataset slug":"invocation ID"," for data fetching"]}):jsxs("div",{className:"my-4",children:[jsx(_e,{title:r.table_title,invocationId:n,datasetSlug:a,sqlQuery:r.sql_query,resourceKey:r.resource_key,columns:r.columns?.map(s=>({name:s.column_name,key:s.key,format:s.format,value_type:s.value_type})),className:e}),jsx("div",{className:"mt-2",children:jsx($t,{slug:a,invocationId:n})})]})}function Cn({node:t,className:e}){let n=t.content;return jsx("div",{className:"my-2",children:jsx(M,{content:n?.text||"",className:e})})}function _n({node:t,className:e,invocationId:n}){let r=t.content?.dataset_slug;return r?jsx("div",{className:"my-2",children:jsx($t,{slug:r,invocationId:n,className:e})}):null}function Sn({node:t,onSuggestionClick:e,suggestionButtonClassName:n}){let r=t.content?.suggestions||[];return r.length?jsx("div",{className:"flex flex-col gap-2 my-4",children:r.map((a,s)=>jsx("button",{onClick:e?()=>e(a):void 0,disabled:!e,className:n||"text-left px-3 py-2 bg-gray-100 dark:bg-gray-800 rounded hover:bg-gray-200 dark:hover:bg-gray-700 text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:a},s))}):null}var wn={Chart:bn,Table:vn,TextMarkdown:Cn,DownloadButton:_n,Suggestions:Sn};function Lt({nodes:t,className:e,invocationId:n,onSuggestionClick:o,customNodeComponents:r,warningClassName:a,suggestionButtonClassName:s}){if(!t||!Array.isArray(t))return null;let i={...wn,...r};return jsx(Fragment,{children:t.map((c,l)=>{let u=c;if(!u?._type)return null;let p=i[u._type];return p?jsx(p,{node:u,index:l,className:e,invocationId:n,onSuggestionClick:o,warningClassName:a,suggestionButtonClassName:s},`${u._type}-${l}`):null})})}function Ae({item:t,className:e}){let[n,o]=useState(false),r=t.content_type==="redacted_thinking",a="";typeof t.content=="string"?a=t.content:t.content&&typeof t.content=="object"&&(r?a=t.content.data||"Some of Claude's internal reasoning has been automatically encrypted for safety reasons. This doesn't affect the quality of responses.":a=t.content.thinking||"");let s=r?"border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-700":"border-gray-200 bg-gray-50 dark:bg-gray-800 dark:border-gray-700",i=r?"hover:bg-amber-100 dark:hover:bg-amber-800/30":"hover:bg-gray-100 dark:hover:bg-gray-700",c=r?"text-amber-700 dark:text-amber-300":"text-gray-600 dark:text-gray-400",l=r?"text-amber-800 dark:text-amber-200 italic":"text-gray-700 dark:text-gray-300",u=r?"border-amber-200 dark:border-amber-700":"border-gray-200 dark:border-gray-700";return jsxs("div",{className:`my-2 border rounded-lg ${s} ${e||""}`,children:[jsxs("button",{onClick:()=>o(!n),className:`w-full px-3 py-2 flex items-center gap-2 text-left transition-colors rounded-lg ${i}`,children:[n?jsx(ChevronDown,{className:"h-4 w-4 text-gray-500"}):jsx(ChevronRight,{className:"h-4 w-4 text-gray-500"}),jsx("span",{className:`text-sm font-medium ${c}`,children:r?"Encrypted Thinking...":"Thinking..."}),!n&&jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 ml-auto",children:"Click to expand"})]}),n&&jsx("div",{className:`px-3 pb-3 border-t ${u}`,children:jsx("div",{className:`mt-2 text-sm whitespace-pre-wrap ${l}`,children:a})})]})}function Er(t){try{return JSON.parse(t)}catch{return t}}function Ga(t){if(!t)return "";try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return ""}}function Nn({log:t}){let e=typeof t.message=="string"?Er(t.message):t.message,n=Ga(t.timestamp),o="text-xs font-mono py-0.5 px-1.5 rounded flex items-start",r="";switch(t.level){case "error":o+=" bg-red-50/50 dark:bg-red-950/30 text-red-600 dark:text-red-400 border-l-2 border-red-400 dark:border-red-600",r="text-red-500 dark:text-red-400";break;case "requires_info":o+=" bg-yellow-50/50 dark:bg-yellow-950/30 text-yellow-600 dark:text-yellow-400 border-l-2 border-yellow-400 dark:border-yellow-600",r="text-yellow-500 dark:text-yellow-400";break;default:o+=" bg-blue-50/40 dark:bg-blue-900/20 text-blue-500/90 dark:text-blue-300/80 border-l-2 border-blue-300 dark:border-blue-600/50",r="text-blue-400 dark:text-blue-400/70";}return jsx("div",{className:"my-0.5",children:jsx("div",{className:o,children:jsxs("div",{className:"flex items-start gap-2",children:[n&&jsx("span",{className:"text-[10px] opacity-60 whitespace-nowrap w-16 flex-shrink-0 pt-0.5",children:n}),t.level==="error"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z",clipRule:"evenodd"})})}),t.level==="requires_info"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})})}),t.level==="info"&&jsx("span",{className:"inline-block mr-1 flex-shrink-0",children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-3 w-3 ${r}`,viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})})}),jsx("div",{className:"flex-1 break-words whitespace-pre-wrap",children:String(e)})]})})})}function Oe({item:t,className:e}){let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=Er(n),r={level:o.level||"info",message:o.message||n,timestamp:o.timestamp};return jsx("div",{className:e,children:jsx(Nn,{log:r})})}function Ve({item:t,className:e}){let n=t.content;return n?.results?.length?jsx("div",{className:`max-w-2xl ${e||""}`,children:jsx("div",{className:"space-y-1",children:n.results.map(o=>jsx("div",{className:"group hover:shadow-sm transition-shadow rounded-sm py-2 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900",children:jsx("div",{className:"px-4",children:jsx("div",{className:"flex items-start justify-between gap-2",children:jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 font-medium text-xs leading-tight truncate text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 hover:underline",children:[jsx("span",{children:o.title}),jsxs("span",{className:"text-xs text-gray-500/60 dark:text-gray-400/60 flex-shrink-0",children:["(",new URL(o.url).hostname,")"]})]}),jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate leading-tight mt-0.5",children:o.description})]})})})},o.url))})}):null}function Me({item:t,className:e}){let n=t.content;return n?.content?.length?jsxs("div",{className:`max-w-4xl border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-900 ${e||""}`,children:[jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:jsxs("div",{className:"flex items-start justify-between",children:[jsxs("div",{className:"space-y-2",children:[jsxs("h3",{className:"flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[jsx(Globe,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"}),n.title||"Parsed Website Content"]}),n.description&&jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:n.description})]}),n.url&&jsxs("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-500 dark:hover:text-blue-300 transition-colors font-medium",children:[jsx(ExternalLink,{className:"h-3 w-3"}),"Visit"]})]})}),jsx("div",{className:"p-4",children:jsx(M,{content:n.content,className:"prose dark:prose-invert max-w-none leading-relaxed prose-sm"})})]}):null}var ts=Prism;function Ft({language:t,value:e,defaultOpen:n=false,title:o="View code",closeTitle:r="Hide code",className:a,theme:s="auto"}){let[i,c]=useState(n),[l,u]=useState(false),p=useRef(null);useEffect(()=>{if(!i){let h=p.current;h&&(h.scrollTop=h.scrollHeight);}},[i,e]);let d=useMemo(()=>s!=="auto"?s:typeof window>"u"?"light":document.documentElement.classList.contains("dark")||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[s]),m=useMemo(()=>d==="dark"?oneDark:oneLight,[d]),f=async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3);}catch{let h=document.createElement("textarea");h.value=e,document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h),u(true),setTimeout(()=>u(false),2e3);}},g=useMemo(()=>({margin:0,width:"100%",background:"transparent",padding:"1rem 0.5rem",fontSize:"0.825rem",maxWidth:"100vw",overflow:"auto"}),[]),y=useMemo(()=>({userSelect:"none",minWidth:"2.5em",paddingRight:"1em",color:"rgb(161 161 170)",opacity:"0.5"}),[]),x=useMemo(()=>({style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre",wordBreak:"break-word"}}),[]);return jsx(qt.Root,{open:i,onOpenChange:c,className:a,children:jsxs("div",{className:"relative w-full font-sans rounded-lg overflow-hidden border border-zinc-200 dark:border-zinc-800",children:[jsxs("div",{className:"flex items-center justify-between w-full px-4 py-1.5 bg-white/80 dark:bg-zinc-800/80 text-zinc-600 dark:text-zinc-100 backdrop-blur-sm border-b border-zinc-200 dark:border-zinc-800",children:[jsx("span",{className:"text-xs font-medium lowercase text-zinc-400 dark:text-zinc-500",children:t}),jsx("button",{onClick:f,className:"h-6 w-6 flex items-center justify-center rounded-md hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",children:l?jsx(Check,{className:"h-3 w-3 text-green-500"}):jsx(Copy,{className:"h-3 w-3 text-zinc-400 dark:text-zinc-500"})})]}),jsxs("div",{ref:p,className:`${i?"max-h-96":"max-h-[200px]"} overflow-auto relative`,children:[jsx("div",{className:"bg-zinc-50/50 dark:bg-zinc-950/70",children:jsx(ts,{language:t,style:m,PreTag:"div",showLineNumbers:true,wrapLines:false,wrapLongLines:false,startingLineNumber:1,className:"not-prose",customStyle:g,lineNumberStyle:y,codeTagProps:x,children:e})}),!i&&jsx("div",{className:"absolute bottom-0 inset-x-0 h-24 pointer-events-none bg-gradient-to-t from-zinc-50 dark:from-zinc-950 to-transparent",style:{marginBottom:"1.5rem"}})]}),jsx(qt.Trigger,{className:"absolute bottom-0 inset-x-0 flex items-center gap-2 text-sm text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300 p-2 justify-start bg-zinc-50/80 dark:bg-zinc-950/80 backdrop-blur-sm border-t border-zinc-200 dark:border-zinc-800 cursor-pointer",children:i?jsxs(Fragment,{children:[jsx(ChevronUp,{className:"h-4 w-4"}),r]}):jsxs(Fragment,{children:[jsx(ChevronDown,{className:"h-4 w-4"}),o]})})]})})}var Jt=Symbol("parsing"),ft=class{result;stack;key;state;stringBuffer;numberBuffer;quoteBuffer;escapeNext;unicode;isInTripleQuotes;constructor(){this.result=void 0,this.stack=[],this.key=void 0,this.state="START",this.stringBuffer="",this.numberBuffer="",this.quoteBuffer="",this.escapeNext=false,this.unicode="",this.isInTripleQuotes=false;}reset(){this.result=void 0,this.stack=[],this.key=void 0,this.state="START",this.stringBuffer="",this.numberBuffer="",this.quoteBuffer="",this.escapeNext=false,this.unicode="",this.isInTripleQuotes=false;}parse(e){return this.reset(),this.add(e)}add(e){for(let n=0;n<e.length;n++){let o=e[n];this.processChar(o);}return this.result}processChar(e){switch(this.state){case "START":this.handleStartState(e);break;case "IN_OBJECT":this.handleObjectState(e);break;case "IN_ARRAY":this.handleArrayState(e);break;case "IN_OBJECT_KEY":this.handleObjectKeyState(e);break;case "AFTER_KEY":this.handleAfterKeyState(e);break;case "IN_OBJECT_VALUE":this.handleObjectValueState(e);break;case "IN_STRING":this.handleStringState(e);break;case "IN_NUMBER":this.handleNumberState(e);break;case "IN_TRUE":this.handleLiteralState(e,"true");break;case "IN_FALSE":this.handleLiteralState(e,"false");break;case "IN_NULL":this.handleLiteralState(e,"null");break;case "IN_UNICODE":this.handleUnicodeState(e);break}}handleStartState(e){if(e==="{")this.startObject();else if(e==="[")this.startArray();else if(!this.isWhitespace(e))throw this.error("must start with { or [","start")}error(e,n){return new Error(`Invalid JSON in ${n}: ${e}`)}handleObjectState(e){if(e==="}")this.endObject();else if(e==='"')this.state="IN_OBJECT_KEY",this.stringBuffer="",this.key=void 0,this.quoteBuffer="";else if(e===",")this.key=void 0;else if(!this.isWhitespace(e))throw this.error(`Invalid character in object: ${e}`,"object")}handleArrayState(e){e==="]"?this.endArray():e===","||this.isWhitespace(e)||this.startValue(e);}handleObjectKeyState(e){e==='"'?(this.state="AFTER_KEY",this.key=this.stringBuffer,this.stringBuffer=""):(this.stringBuffer+=e,this.updateValueInParent(this.stringBuffer));}handleAfterKeyState(e){e===":"?this.state="IN_OBJECT_VALUE":this.isWhitespace(e)||this.isWhitespace(e)||(this.key=this.key+e);}handleObjectValueState(e){this.isWhitespace(e)||this.startValue(e);}handleStringState(e){if(this.escapeNext)this.handleEscapeChar(e);else if(e==="\\")this.escapeNext=true;else if(e==='"'){if(this.quoteBuffer+='"',this.stringBuffer===""&&this.quoteBuffer==='""')this.quoteBuffer="",this.isInTripleQuotes=true;else if(this.stringBuffer&&this.quoteBuffer==='"""'){this.quoteBuffer="",this.isInTripleQuotes=false,this.stringBuffer=this.stringBuffer.replace(/^\n+/,"").replace(/\n+$/,"").trim(),this.endString();return}}else {if(this.quoteBuffer){if(this.quoteBuffer==='"'&&!this.isInTripleQuotes){this.quoteBuffer="",this.endString(),this.processChar(e);return}else if(this.quoteBuffer==='"""'&&this.isInTripleQuotes){this.quoteBuffer="",this.isInTripleQuotes=false,this.endString(),this.processChar(e);return}this.stringBuffer+=this.quoteBuffer,this.quoteBuffer="";}this.stringBuffer+=e,this.updateValueInParent(this.stringBuffer);}}handleNumberState(e){e.match(/[0-9.eE+-]/)?(this.numberBuffer+=e,this.updateValueInParent(parseFloat(this.numberBuffer))):(this.endNumber(),this.processChar(e));}handleLiteralState(e,n){let o=n[this.stringBuffer.length];if(e===o)this.stringBuffer+=e,this.stringBuffer===n?this.endLiteral(n):this.updateValueInParent(this.stringBuffer);else throw this.error(`Invalid literal: expected ${n}`,"literal")}handleUnicodeState(e){if(this.unicode+=e,this.unicode.length===4){let n=parseInt(this.unicode,16);this.stringBuffer+=String.fromCharCode(n),this.unicode="",this.state="IN_STRING";}}handleEscapeChar(e){switch(e){case '"':case "\\":case "/":this.stringBuffer+=e;break;case "b":this.stringBuffer+="\b";break;case "f":this.stringBuffer+="\f";break;case "n":this.stringBuffer+=`
24
24
  `;break;case "r":this.stringBuffer+="\r";break;case "t":this.stringBuffer+=" ";break;case "u":this.unicode="",this.state="IN_UNICODE";break;case "`":this.stringBuffer+="`";break;default:throw this.error("Invalid escape character","string")}this.escapeNext=false;}startObject(){let e={[Jt]:true};this.addValueToParent(e),this.stack.push({value:e,key:this.key}),this.key=void 0,this.state="IN_OBJECT";}endObject(){let{value:e,key:n,index:o}=this.stack.pop();if(delete e[Jt],this.stack.length===0)this.state="END",this.result={...e};else {let{value:r}=this.stack[this.stack.length-1];if(Array.isArray(r))o!==void 0?r[o]={...e}:r[r.length-1]={...e};else if(n!==void 0)r[n]={...e};else throw this.error("Key is undefined","object");this.state=this.getParentState();}}startArray(){let e=[];e[Jt]=true,this.addValueToParent(e),this.stack.push({value:e,key:this.key,index:0}),this.key=void 0,this.state="IN_ARRAY";}endArray(){let{value:e,key:n,index:o}=this.stack.pop();if(delete e[Jt],this.stack.length===0)if(this.state="END",Array.isArray(e))this.result=[...e];else throw this.error("Expected array at root level","array");else {let{value:r}=this.stack[this.stack.length-1];Array.isArray(r)?o!==void 0?r[o]=Array.isArray(e)?[...e]:e:r[r.length-1]=Array.isArray(e)?[...e]:e:n!==void 0&&(r[n]=Array.isArray(e)?[...e]:e),this.state=this.getParentState();}}startValue(e){if(e==='"')this.state="IN_STRING",this.stringBuffer="",this.quoteBuffer="",this.addValueToParent("");else if(e.match(/[0-9-]/))this.state="IN_NUMBER",this.numberBuffer=e,this.addValueToParent(parseFloat(e));else if(e==="t")this.state="IN_TRUE",this.stringBuffer="t",this.addValueToParent("t");else if(e==="f")this.state="IN_FALSE",this.stringBuffer="f",this.addValueToParent("f");else if(e==="n")this.state="IN_NULL",this.stringBuffer="n",this.addValueToParent("n");else if(e==="{")this.startObject();else if(e==="[")this.startArray();else throw this.error(`Invalid value start: ${e}`,"value")}endString(){let e=this.stringBuffer;this.stringBuffer="",this.updateValueInParent(e),this.state=this.getParentState();}endNumber(){let e=parseFloat(this.numberBuffer);this.updateValueInParent(e),this.numberBuffer="",this.state=this.getParentState();}endLiteral(e){let n;switch(e){case "true":n=true;break;case "false":n=false;break;case "null":n=null;break;default:throw this.error("Invalid literal","literal")}this.updateValueInParent(n),this.stringBuffer="",this.state=this.getParentState();}addValueToParent(e){if(this.stack.length===0)this.result=e;else {let n=this.stack[this.stack.length-1],{value:o}=n;if(Array.isArray(o))o.push(e),n.index!==void 0&&n.index++;else if(this.state==="IN_OBJECT_KEY")this.key=e,o[this.key]="";else {if(this.key===void 0)throw this.error("Key is undefined","object");o[this.key]=e;}}}updateValueInParent(e){if(this.stack.length===0)this.result=e;else {let n=this.stack[this.stack.length-1],{value:o}=n;if(Array.isArray(o))n.index!==void 0?o[n.index-1]=e:o[o.length-1]=e;else if(this.key!==void 0)o[this.key]=e;else if(this.state!=="IN_OBJECT_KEY")throw this.error("Key is undefined","object")}}isWhitespace(e){return e===" "||e===" "||e===`
25
25
  `||e==="\r"}getParentState(){return this.stack.length===0?"END":Array.isArray(this.stack[this.stack.length-1].value)?"IN_ARRAY":"IN_OBJECT"}};function es(t){let e=t.trim();try{return JSON.parse(e)}catch{try{return new ft().parse(e)}catch(o){return console.log("parseCompleteJson failed, content:",e),console.error("parseCompleteJson error:",o),null}}}function Le(t){return t===" "||t===`
26
- `||t===" "||t==="\r"}function ns(t,e){if(e>=t.length-1)return "";for(let n=e+1;n<t.length;n++)if(!Le(t[n]))return t[n];return ""}function ot(t){if(typeof t!="string")return t;let e=[],n=/```json\s*\n/g,o=n.test(t);if(n.lastIndex=0,o){let r=0,a;for(;(a=n.exec(t))!==null;){let i=t.substring(r,a.index).trim();i&&e.push({content:i,type:"text"});let c=a.index+a[0].length,l=[],u=c;for(;;){let m=t.indexOf("```",u);if(m===-1)break;l.push(m),u=m+3;}let p=null,d=t.length;for(let m of l){let f=t.substring(c,m);try{p=JSON.parse(f),d=m+3;break}catch{try{let g=new ft,h=g.parse(f);if(h&&g.state==="END"){p=h,d=m+3;break}}catch{}}}if(p)e.push({content:p,type:"json"});else {let m=t.substring(a.index,d);e.push({content:m,type:"text"});}r=d,n.lastIndex=d;}let s=t.substring(r).trim();s&&e.push({content:s,type:"text"});}else {let r="",a=null,s=false,i=0;for(let c=0;c<t.length;c++){let l=t[c],u=ns(t,c);if(!s&&(l==="{"&&u==='"'||l==="["&&u==="{")&&(r.trim()&&e.push({content:r.trim(),type:"text"}),s=true,a=new ft,r=""),s){let p;try{p=a.add(l);}catch(d){if(console.log("parseMixedJson: currentChunk",r),console.log("parseMixedJson: currentResult",a?.result),console.warn("parseMixedJson: JSON parse error",d),i++,i>3){s=false,a=null,i=0,r+=l;continue}continue}r+=l,a.state==="END"&&(e.push({content:p,type:"json"}),s=false,a=null,r="");}else r+=l;}r.trim()&&e.push({content:r.trim(),type:"text"});}return e}function rs(t){return t&&typeof t=="object"&&!t[Jt]}function En(t){return t&&typeof t=="object"&&t[Jt]===true}function Ue({item:t,className:e}){if(!t.content)return null;let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=t.parsedJson;if(!o)try{o=ot(n);}catch(c){console.error("Failed to parse SQL content:",c),o=[{content:n||"",type:"text"}];}let r=Array.isArray(o)?o.find(c=>c.type==="json"):o?.[0];if(!r)return jsxs("div",{className:`text-destructive text-sm ${e||""}`,children:[jsx("div",{className:"font-medium",children:"Error"}),jsx("div",{children:n})]});let{thinking:a,sql_query:s,error:i}=r?.content||{};return i?jsxs("div",{className:`text-destructive text-sm ${e||""}`,children:[jsx("div",{className:"font-medium",children:"Error"}),jsx("div",{children:i})]}):s?jsxs("div",{className:`text-foreground whitespace-pre-wrap leading-normal ${e||""}`,children:[a&&jsx("div",{className:"mb-2",children:jsx(M,{content:a,className:"text-sm max-w-none"})}),s&&jsx("div",{className:"mb-2",children:jsx(Ft,{language:"sql",value:s,defaultOpen:false})})]}):null}function jt({children:t,defaultOpen:e=false,wrapperType:n="standard",compact:o=false,className:r}){let[a,s]=useState(e),[i,c]=useState(false),l=useRef(null);useEffect(()=>{let d=l.current;d&&(a||(d.scrollTop=d.scrollHeight),c(d.scrollHeight>d.clientHeight));},[a,t]);let u={standard:"bg-muted/30 border-border",info:"bg-info/10 border-info/30",warning:"bg-warning/10 border-warning/30"},p={standard:"text-muted-foreground hover:text-foreground",info:"text-info hover:text-info/80",warning:"text-warning hover:text-warning/80"};return jsx("div",{className:`relative text-sm ${o?"":"mb-2"} ${r||""}`,children:jsx(qt.Root,{open:a,onOpenChange:s,className:`border rounded-sm ${u[n]}`,children:jsxs("div",{ref:l,className:`overflow-y-auto ${a?"":"max-h-[200px]"}`,children:[i&&jsx(qt.Trigger,{className:`sticky top-0 text-center text-xs py-1 transition-opacity w-full cursor-pointer ${p[n]}`,children:a?"Less \u2193":"More \u2191"}),jsx("div",{className:`${o?"px-2 py-1":"p-2"} m-0 overflow-x-auto break-words whitespace-pre-wrap`,children:t})]})})})}function Tn(t){return new Date(t).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Fe({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-muted-foreground/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-foreground/80",children:t})]})}function Wt({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-info/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-info/90",children:t})]})}function Je({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-warning/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-warning/90",children:t})]})}function We({item:t,className:e}){if(!t.content)return null;let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=t.parsedJson;if(!o)try{o=ot(n);}catch(u){console.error("Failed to parse codegen content:",u),o=[{content:n||"",type:"text"}];}let r=Array.isArray(o)?o.find(u=>u.type==="json"):o?.[0],{step_by_step:a,thinking:s,code:i,warnings:c,error:l}=r?.content||{};return l?jsx(jt,{wrapperType:"info",className:e,children:jsx(Wt,{children:l})}):!a&&!i?null:jsxs("div",{className:`text-foreground whitespace-pre-wrap leading-normal ${e||""}`,children:[a&&jsx(M,{content:a,className:"text-sm max-w-none"}),s&&jsx("div",{className:"mb-2",children:jsx(M,{content:s,className:"text-sm max-w-none"})}),i&&jsx("div",{className:"mb-2",children:jsx(Ft,{language:"python",value:i,defaultOpen:false})}),c&&jsxs("div",{className:"text-sm text-warning",children:[jsx("div",{className:"font-medium",children:"Warnings"}),jsx(M,{content:c,className:"text-sm max-w-none"})]})]})}function qe({item:t,className:e}){let n=t.parsedJson;if(!n?.length)return null;let o=n.map(i=>i.message?.trim()?{level:i.level,message:i.message,timestamp:i.timestamp,index:i.index}:null).filter(i=>i!==null);if(o.sort((i,c)=>i.index-c.index),o.length===0)return null;let r=o.some(i=>i.level==="error"),a=o.some(i=>i.level==="warning"),s=r?"info":a?"warning":"standard";return jsx("div",{className:`text-foreground leading-normal ${e||""}`,children:jsx(jt,{wrapperType:s,compact:true,children:o.map((i,c)=>jsx(ss,{output:i},`${i.level}-${c}`))})})}function ss({output:t}){switch(t.level){case "output":return jsx(Fe,{timestamp:t.timestamp,children:t.message});case "error":return jsx(Wt,{timestamp:t.timestamp,children:t.message});case "warning":return jsx(Je,{timestamp:t.timestamp,children:t.message});default:return jsx("div",{className:"text-muted-foreground",children:t.message})}}var us={"websearch.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched web for "${n}"`:`Failed to search web for "${n}"`:`Searching web for "${n}"...`:"Web search"}},"webparser.parse":{icon:Globe,getLabel:(t,e)=>{let n=t?.url;return n?e?e==="success"?`Read ${n}`:`Failed to read ${n}`:`Reading ${n}...`:"Parse site"}},"siteparser.parse":{icon:Globe,getLabel:(t,e)=>{let n=t?.url;return n?e?e==="success"?`Read ${n}`:`Failed to read ${n}`:`Reading ${n}...`:"Parse site"}},"resource_definitions.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched resources for "${n}"`:`Failed to search resources for "${n}"`:`Searching resources for "${n}"...`:"Search resources"}},"memory.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched memories for "${n}"`:`Failed to search memories for "${n}"`:`Searching memories for "${n}"...`:"Search memories"}}};function Ar(t){return t&&us[t]||null}function ds(t){if(!t?.result||t.status==="error")return false;let e=t.result;if(typeof e=="string"){let n=e.trim();return n!==""&&n!=="{}"&&n!=="[]"}if(Array.isArray(e))return e.length>0;if(typeof e=="object"&&e!==null){let n=Object.keys(e);return n.length===0?false:n.some(o=>{let r=e[o];return r==null?false:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"?Object.keys(r).length>0:true})}return true}function ps({actionType:t}){let n=Ar(t)?.icon||Wrench;return jsx(n,{className:"h-4 w-4"})}function ms({actionType:t,input:e,name:n,result:o,invocation:r}){if(o?.finished_message)return jsx("span",{children:o.finished_message});if(o?.running_message)return jsx("span",{children:o.running_message});if(!o&&r?.running_message)return jsx("span",{children:r.running_message});let a=Ar(t);if(a)return jsx("span",{children:a.getLabel(e,o?.status)});let s=o?`Completed ${n}`:`Running ${n}...`;return jsx("span",{children:s})}function Ht({toolGroup:t,ContentComponent:e,className:n,fallbackClassName:o}){let[r,a]=useState(false),s=j(),i=e??s?.ContentComponent,c=t.invocation,l=t.result,u=ds(l),p=c?.action_type||l?.action_type,d=c?.input||l?.input,m=c?.name||l?.name,f=l?.status==="error"?"text-gray-500/80 dark:text-gray-400/80":"text-gray-500 dark:text-gray-400";return jsxs(qt.Root,{open:r,onOpenChange:a,className:`relative w-full max-w-4xl space-y-2 leading-normal ${n||""}`,children:[jsxs(qt.Trigger,{className:`flex items-center gap-2 text-sm transition-colors w-full ${f} ${u?"hover:text-gray-900 dark:hover:text-gray-100 cursor-pointer":"cursor-default"}`,disabled:!u,children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(ps,{actionType:p}),jsx(ms,{actionType:p,input:d,name:m,result:l,invocation:c})]}),u&&jsx(ChevronDown,{className:`h-4 w-4 transition-transform duration-200 ${r?"rotate-180":""}`})]}),u&&l&&jsx(qt.Content,{children:jsx("div",{className:"pl-6 mt-2",children:i?jsx(i,{content:{content:l.result,content_type:l.ui_content_type||"text",ui_content_type:l.ui_content_type||"text"}}):jsx("pre",{className:o||"text-sm bg-gray-100 dark:bg-gray-800 p-2 rounded overflow-x-auto",children:JSON.stringify(l.result,null,2)})})})]})}var wt={Success:"success",Error:"error",RequiresInfo:"requires info"};function hs(t){return t?t===wt.Success?"finished":t===wt.Error||t===wt.RequiresInfo?"failed":"loading":"loading"}function Mr(t){return t?t!==wt.Success&&t!==wt.Error&&t!==wt.RequiresInfo:true}function xs(t,e){let n=e||"agent",o=T(t?.message);return o||(t?.status===wt.Success?`Finished ${n}`:`Running ${n}...`)}function He({content:t,botInvocation:e,isLoading:n=false,defaultOpen:o,adminLinkHref:r,adminLinkText:a="Open in Agent Designer",showAdminLink:s=false,onAdminClick:i,onExpand:c,EventsComponent:l,ContentComponent:u,className:p}){let d=()=>o!==void 0?o:e?.currentStatus?Mr(e.currentStatus.status):false,[m,f]=useState(d),[g,h]=useState(false),k=useRef(null);if(useEffect(()=>{if(e?.currentStatus){let I=e.currentStatus.status;if(k.current!==I&&(k.current=I,!g)){let B=Mr(I);B&&!m?f(true):!B&&m&&f(false);}}},[e,g,m]),useEffect(()=>{m&&e&&c&&c(t.invocation_id,t.bot_id,t.bot_name);},[m,e,c,t]),n&&!e)return jsxs("div",{className:`flex items-center gap-2 text-sm text-muted-foreground ${p||""}`,children:[jsx(vt,{status:"loading"}),jsxs("span",{children:["Loading ",t.bot_name,"..."]})]});if(!e)return null;let y=hs(e.currentStatus?.status),b=xs(e.currentStatus,t.bot_name),N=I=>{f(I),h(true);},v=I=>{i&&(I.preventDefault(),i(t.invocation_id,t.bot_id));},D=e.eventsByID&&Object.keys(e.eventsByID).length>0;return jsxs(qt.Root,{open:m,onOpenChange:N,className:`relative w-full max-w-4xl space-y-2 leading-normal bot-invocation-content ${p||""}`,children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs(qt.Trigger,{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[jsx(vt,{status:y}),b]}),jsx(ChevronDown,{className:`h-4 w-4 transition-transform duration-200 ${m?"transform rotate-180":""}`})]}),s&&(r||i)&&jsxs("a",{href:r||"#",onClick:i?v:void 0,target:r?"_blank":void 0,rel:r?"noopener noreferrer":void 0,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a,jsx(ArrowUpRight,{className:"h-3.5 w-3.5"})]})]}),jsx(qt.Content,{children:jsx("div",{className:"space-y-2 max-w-3xl",children:D?l?jsx(l,{eventsByID:e.eventsByID,defaultOpen:m}):jsx(Mt,{eventsByID:e.eventsByID,ContentComponent:u}):jsx("span",{className:"text-sm text-muted-foreground",children:"No events to display"})})})]})}function Rn({content:t,isSearching:e=false,className:n}){let o=[];if(Array.isArray(t))o=t;else if(typeof t=="object"&&t!==null&&"q"in t)o=t.q;else if(typeof t=="string")try{let a=JSON.parse(t);Array.isArray(a)?o=a:a.q&&Array.isArray(a.q)&&(o=a.q);}catch{o=[t];}let r=o.filter(a=>a&&a.trim()!=="");return r.length===0?null:jsx("div",{className:`flex flex-wrap gap-2 ${n||""}`,children:r.map(a=>jsxs("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg text-sm bg-muted/50 text-foreground border border-border/30",children:[e?jsx(Loader2,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0 animate-spin"}):jsx(Search,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0"}),jsx("span",{className:"line-clamp-1",children:a})]},a))})}function An({content:t,isSearching:e=false,className:n}){let o=[];if(Array.isArray(t))o=t;else if(typeof t=="object"&&t!==null&&"integration_queries"in t)o=t.integration_queries;else if(typeof t=="string")try{let a=JSON.parse(t);Array.isArray(a)?o=a:a.integration_queries&&Array.isArray(a.integration_queries)&&(o=a.integration_queries);}catch{return null}let r=o.filter(a=>a&&a.query&&a.query.trim()!=="");return r.length===0?null:jsx("div",{className:`flex flex-wrap gap-2 ${n||""}`,children:r.map(a=>jsxs("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg text-sm bg-muted/50 text-foreground border border-border/30",children:[e?jsx(Loader2,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0 animate-spin"}):jsx(Search,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0"}),jsx("span",{className:"line-clamp-1",children:a.query})]},`${a.integration_config_id}-${a.resource_id}-${a.query}`))})}var Bs=120;function Ps(t,e){return !t||t.length<=e?t:t.slice(0,e).trimEnd()+"..."}function Rs(t){switch(t){case "snippet":return Code;case "learning":return Brain;case "error":return AlertCircle;case "limitation":return AlertCircle;case "optimization":return Zap;default:return Lightbulb}}function As(t){switch(t){case "snippet":return "Snippet";case "learning":return "Learning";case "error":return "Error";case "limitation":return "Limitation";case "optimization":return "Optimization";default:return t}}function Os({memory:t}){let[e,n]=useState(false),o=Rs(t.type),r=As(t.type),a=t.type==="snippet",s=Ps(t.description||"",Bs),i=t.content&&t.content.trim()!=="",c=a&&i;return jsxs(qt.Root,{open:e,onOpenChange:n,className:"border border-border/50 rounded-lg overflow-hidden",children:[jsxs(qt.Trigger,{className:`w-full text-left p-3 flex items-start gap-3 ${c?"hover:bg-muted/50 cursor-pointer":"cursor-default"}`,disabled:!c,children:[jsx("div",{className:"flex-shrink-0 mt-0.5",children:jsx(o,{className:"h-4 w-4 text-muted-foreground"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:r}),t.tags&&t.tags.length>0&&jsxs("div",{className:"flex gap-1 flex-wrap",children:[t.tags.slice(0,3).map((l,u)=>jsx("span",{className:"text-xs px-1.5 py-0.5 bg-muted rounded text-muted-foreground",children:l},u)),t.tags.length>3&&jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.tags.length-3]})]})]}),jsx("p",{className:"text-sm text-foreground",children:a?s:t.description||t.content})]}),c&&jsx(ChevronDown,{className:`h-4 w-4 text-muted-foreground flex-shrink-0 transition-transform duration-200 ${e?"rotate-180":""}`})]}),c&&jsx(qt.Content,{children:jsx("div",{className:"border-t border-border/50 bg-muted/30",children:jsx("pre",{className:"p-3 text-sm overflow-x-auto whitespace-pre-wrap break-words font-mono",children:t.content})})})]})}function Ze({content:t,className:e}){let n=Array.isArray(t)?t:t?.memories;return !n||n.length===0?jsx("p",{className:"text-sm text-muted-foreground",children:"No memories found."}):jsx("div",{className:`space-y-2 ${e||""}`,children:n.map(o=>jsx(Os,{memory:o},o.id))})}function On(){return jsxs("span",{className:"inline-flex gap-1 text-muted-foreground",children:[jsx("span",{className:"animate-bounce",style:{animationDelay:"0ms"},children:"\u25CF"}),jsx("span",{className:"animate-bounce",style:{animationDelay:"150ms"},children:"\u25CF"}),jsx("span",{className:"animate-bounce",style:{animationDelay:"300ms"},children:"\u25CF"})]})}function Vn(){return jsx("div",{className:"flex items-center justify-center py-8",children:jsx(Loader2,{className:"animate-spin text-muted-foreground",size:24})})}function $s(t){if(t.content_type==="bot_invocation"||t.content_type==="bot_invocation_result"||t.content&&typeof t.content=="object"&&t.content.action_type==="bot.invoke")return null;if(t.content_type==="tool_invocation")return "tool_invocation";if(t.content_type==="tool_result")return "tool_result";if(!t.content||typeof t.content!="object")return null;let e=t.content;return "action_type"in e&&"name"in e&&"input"in e&&e.action_type!=="bot.invoke"?"result"in e?"tool_result":"tool_invocation":null}function ue({content:t,className:e,components:n}){let r=j()?.onSuggestionClick,a=useMemo(()=>l=>jsx(ue,{...l,components:n}),[n]);if(t.content&&typeof t.content=="object"&&t.content.action_type==="bot.invoke")return null;let s=$s(t),i;s?i=s:(i=T(t.ui_content_type)||t.content_type,i!=="ui_generation"&&typeof t.content=="string"&&(t.content.includes('{"children":')||t.content.includes('"children":'))&&(i="ui_generation"));let c=n?.[i];if(c)return jsx(c,{content:t,className:e});switch(i){case "text":return jsx(se,{content:Ur(t),className:e});case "markdown":return jsx(M,{content:Ur(t),className:e});case "thinking":case "redacted_thinking":return jsx(Ae,{item:t,className:e});case "json":return jsx(mt,{content:t.content,className:e});case "codegen_json":return jsx(We,{item:t,className:e});case "sql_generation":return jsx(Ue,{item:t,className:e});case "codeexec_output":return jsx(qe,{item:t,className:e});case "log":return jsx(Oe,{item:t,className:e});case "websearch":case "websearch_output":case "web_search":return jsx(Ve,{item:t,className:e});case "search_queries":return jsx(Rn,{content:t.content,className:e});case "integration_queries":return jsx(An,{content:t.content,className:e});case "memory":return jsx(Ze,{content:t.content,className:e});case "webparse":case "webparse_output":case "web_parse":return jsx(Me,{item:t,className:e});case "tool_group":return jsx(Ht,{toolGroup:t.content,ContentComponent:a,className:e});case "bot_invocation":{let l=t.content,u=t.botInvocation;return jsx(He,{content:l,botInvocation:u,ContentComponent:a,className:e})}case "chart":case "ui_generation":{let l=t.invocation_id||t.created_by_invocation_id;if(t.chartConfig&&t.chartData)return jsx(Pe,{config:t.chartConfig,data:t.chartData,className:e});let u=t.parsedJson;if(u&&Array.isArray(u)&&u.length>0)return jsx(Fragment,{children:u.map((d,m)=>{if(d.type==="text"){let f=d.content;return jsx(M,{content:f,className:e},`${m}-${f.length}`)}else if(d.type==="json"){let f=d.content;return En(f)?f?.children?.some(k=>k?._type==="TextMarkdown")?jsx(On,{},m):jsx(Vn,{},m):f?.children&&Array.isArray(f.children)?jsx(ut__default.Fragment,{children:jsx(Lt,{nodes:f.children,className:e,invocationId:l,onSuggestionClick:r})},`${m}-${f.children.length}`):jsx(mt,{content:f,className:e},`${m}-json`)}return null})});let p=typeof t.content=="string"?t.content:null;if(p){let d=ot(p);if(Array.isArray(d))return jsx(Fragment,{children:d.map((m,f)=>{if(m.type==="text"){let g=m.content;return jsx(M,{content:g,className:e},`${f}-${g.length}`)}else if(m.type==="json"){let g=m.content;return g?.children&&Array.isArray(g.children)?jsx(ut__default.Fragment,{children:jsx(Lt,{nodes:g.children,className:e,invocationId:l,onSuggestionClick:r})},`${f}-${g.children.length}`):jsx(mt,{content:g,className:e},`${f}-json`)}return null})})}if(typeof t.content=="object"&&t.content!==null){let d=t.content;if(d?.children&&Array.isArray(d.children))return jsx(Lt,{nodes:d.children,className:e,invocationId:l,onSuggestionClick:r})}return jsx(mt,{content:t.content,className:e})}case "table":return t.tableColumns&&t.tableData?jsx(Re,{columns:t.tableColumns,data:t.tableData,className:e}):jsx(mt,{content:t.content,className:e});case "bot_invocation_result":case "security_check_json":return null;case "tool_invocation":{let l=t.content,u={invocation:{invocation_id:l.id||"",action:l.action_type||"",params:l.input||{},id:l.id||"",name:l.name||"",input:l.input||{},description:l.description,action_type:l.action_type,running_message:l.running_message}};return jsx(Ht,{toolGroup:u,ContentComponent:a,className:e})}case "tool_result":{let l=t.content,u={invocation:{invocation_id:l.id||"",action:l.action_type||"",params:l.input||{}},result:{invocation_id:l.id||"",result:l.result}},p={...u,invocation:{...u.invocation,id:l.id||"",name:l.name||"",input:l.input||{},action_type:l.action_type,description:l.description},result:{...u.result,id:l.id||"",name:l.name||"",input:l.input||{},result:l.result,status:l.status||"success",action_type:l.action_type,description:l.description,ui_content_type:l.ui_content_type,running_message:l.running_status,finished_message:l.finished_status}};return jsx(Ht,{toolGroup:p,ContentComponent:a,className:e})}default:return typeof t.content=="string"?jsx(se,{content:t.content,className:e}):null}}function Ur(t){return typeof t.content=="string"?t.content:""}function Us({result:t,isStreaming:e,className:n,components:o,streamingText:r}){let a=t?Fr(t):[];return r&&a.length===0?jsxs("div",{className:n?`erdo-ui ${n}`:"erdo-ui space-y-4",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"animate-pulse w-2 h-2 bg-blue-500 rounded-full"}),jsx("span",{className:"text-sm text-gray-500",children:"Streaming response..."})]}),jsx("div",{className:"border rounded-lg p-4 whitespace-pre-wrap",children:r})]}):a.length===0&&!e?null:jsxs("div",{className:n?`erdo-ui ${n}`:"erdo-ui space-y-4",children:[a.map((s,i)=>jsx("div",{children:jsx(ue,{content:s,components:o})},s.id||i)),e&&a.length===0&&!r&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"animate-pulse w-2 h-2 bg-blue-500 rounded-full"}),jsx("span",{className:"text-sm text-gray-500",children:"Processing..."})]})]})}function Fr(t){let e=[],n=new Set;if(t.events)for(let o of t.events){let r=o.metadata,a=o.payload;if(r?.user_visibility==="visible"&&a?.status==="success"&&a?.output){let s=a.output;if(s.content&&Array.isArray(s.content))for(let i=0;i<s.content.length;i++){let c=s.content[i],l=c.id||`event-result-${i}`;if(n.has(l))continue;n.add(l);let u=r?.ui_content_type;if(!u&&typeof c.content=="string")try{JSON.parse(c.content)?.children&&(u="ui_generation");}catch{(c.content.includes('{"children":')||c.content.includes('{ "children":'))&&(u="ui_generation");}e.push({id:l,content_type:c.content_type||"text",ui_content_type:u,content:c.content,data:c.data,chartConfig:c.chartConfig,chartData:c.chartData,tableColumns:c.tableColumns,tableData:c.tableData});}}}if(e.length===0&&t.result?.output?.content){let o=t.result.output.content;if(Array.isArray(o))for(let r=0;r<o.length;r++){let a=o[r],s=a.id||`result-${r}`;if(n.has(s))continue;n.add(s);let i=a.ui_content_type;if(!i&&typeof a.content=="string")try{JSON.parse(a.content)?.children&&(i="ui_generation");}catch{(a.content.includes('{"children":')||a.content.includes('{ "children":'))&&(i="ui_generation");}e.push({...a,id:s,ui_content_type:i});}}return e}function $(t){if(!t)throw new Error("Entity is null");if(!("_type"in t))throw new Error(`Entity ${JSON.stringify(t)} is missing _type`);return t._type}function Gs(t){return t.contents.length===0?null:t.contents[t.contents.length-1]||null}function qr(t){return t.contents.length===0?null:t.contents[0]||null}function Ln(t,e){let n=$(t);switch(n){case "message":return t;case "step":let o=t;if(e){let s=o.eventsByID[e]?.Message;return s||Kr({},"",e)}let a=Object.keys(o.eventsByID).reverse();for(let s of a){let i=o.eventsByID[s];if(i&&i.Message)return i.Message}throw new Error("Unable to find message for step");default:throw new Error(`Unable to have messages on entity type ${n}`)}}function Fs(t,e){switch($(t)){case "message_content":return t;case "output_content":return t;case "message":return Qt(t,e);case "output":return Yt(t,e);case "step":let o=Xe(t,e);return o?Yt(o,e):null;default:return null}}function Qt(t,e){let n=$(t);switch(n){case "message_content":return t;case "message":let o=Ln(t);if(!o)throw new Error("Unable to find message to add content to");return e?o.contentsByID[e]:Gs(o);default:throw new Error(`Unable to have message content on entity type ${n}`)}}function Yt(t,e){let n=$(t);switch(n){case "output_content":return t;case "output":let o=t;return e?o.contentsByID[e]||null:o.contents.length<=0?null:o.contents[o.contents.length-1]||null;case "step":let a=Xe(t,e);return a?Yt(a):null;case "invocation":if(!e)return null;let s=t.eventsByID[e];return !s||!s.Output?null:Yt(s.Output);default:throw new Error(`Unable to have output content on entity type ${n}`)}}function Un(t,e){let n=$(t),o=null;switch(n){case "invocation":return t;case "message_content":if(o=t.botInvocation||null,!o)throw new Error("Unable to find bot invocation for message content");if(e&&o.bot_invocation.id!==e)throw new Error("Unable to find bot invocation for message content - mismatched ID");return o;case "message":if(o=qr(t)?.botInvocation||null,!o)throw new Error("Unable to find bot invocation for message");if(e&&o.bot_invocation.id!==e)throw new Error("Unable to find bot invocation for message - mismatched ID");return o;case "output_content":return t.botInvocation||null;default:throw new Error(`Unable to have bot invocation on entity type ${n}`)}}function Xe(t,e){let n=$(t);switch(n){case "output":return t;case "step":let o=t;if(e){let i=o.eventsByID[e]?.Output;if(!i)throw new Error("Unable to find output with id "+e);return i}let a=Object.keys(o.eventsByID).reverse();for(let i of a){let c=o.eventsByID[i];if(c&&c.Output)return c.Output}throw new Error("Unable to find output for step");case "invocation":if(!e)throw new Error("Unable to find output for invocation without ID");return t.eventsByID[e]?.Output||null;default:throw new Error(`Unable to have step outputs on entity type ${n}`)}}function Hr(t,e){let n=$(t);switch(n){case "result_handler":return t;case "step":if(!e)throw new Error("Unable to have result handlers on step without ID");let o=t.eventsByID[e];if(!o||!o.type||o.type!=="result_handler"||!o.ResultHandler)throw new Error(`Unable to find result handler with id ${e} on step ${t.id}`);return o.ResultHandler;default:throw new Error(`Unable to have result handlers on entity type ${n}`)}}function zr(t,e){let n=$(t),o=null;switch(n){case "step":if(t.id===e||!e)return t;throw new Error("Unable to find step on step with id "+e);case "invocation":if(!e)throw new Error("Unable to have steps on bot invocation without ID");o=t;let r=o.eventsByID[e];if(!r)throw new Error("Unable to find step on invocation with id "+e);if(!r.Step)throw new Error("Unable to find step on invocation with id "+e);return r.Step;case "result_handler":if(!e)throw new Error("Unable to have steps on result handler without ID");let s=t.eventsByID[e];if(!s)throw new Error("Unable to find step on result handler with id "+e);if(!s.Step)throw new Error("Unable to find step on result handler with id "+e);return s.Step;default:throw new Error(`Unable to have steps on entity type ${n}`)}}var Mn=class extends Error{};function Js(t,e,n){let o=null,r=e[0],a=e[1];n[r]=a;try{switch(r){case "message":o=Ln(t,a);break;case "content":o=Qt(t,a);break;case "step":o=zr(t,a);break;case "output":o=Xe(t,a);break;case "output_content":o=Yt(t,a);break;case "invocation":o=Un(t,a);break;case "result_handler":o=Hr(t,a);break}}catch(s){throw console.error("error finding next entity"),console.log("path",e),console.log("currentEntity",t),s}if(!o)throw console.log("path",e),console.log("currentEntity",t),console.log("nextEntity",o),new Mn(`Unable to find next entity for path ${e.join("/")}`);return o}function Kr(t,e,n,o){let r=t.payload;return {_type:"message",message:{id:n,thread_id:e,author_id:r.author_id||"app",author_entity_type:r.author_entity_type||"app",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),role:r.role||"assistant",avatar:"/teams/erdo.svg"},state:"in_progress",contents:[],contentsByID:{},contentIDToIdx:{}}}function js(t,e){return {_type:"message_content",id:t.metadata.message_content_id,message_id:e.message,content_type:t.metadata.content_type,created_by_invocation_id:t.metadata.invocation_id,invocation_id:t.metadata.invocation_id,state:"in_progress",user_visibility:t.metadata.user_visibility??"visible",bot_visibility:t.metadata.bot_visibility??"visible",content:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:t.metadata?.ui_content_type?{String:t.metadata.ui_content_type,Valid:true}:{String:"",Valid:false}}}function Ws(t,e){let n=t.metadata?.ui_content_type,o=typeof t.payload=="string"?t.payload:t.payload.content||t.payload,r=null;if(ae(t.metadata.content_type,n))try{r=ot(o);}catch(a){console.error("Failed to parse message content as JSON:",a),r=[{content:o,type:"text"}];}return {_type:"message_content",id:t.metadata.message_content_id,message_id:e.message,content:o,content_type:t.metadata.content_type,created_by_invocation_id:t.metadata.invocation_id,invocation_id:t.metadata.invocation_id,state:"completed",user_visibility:t.metadata.visibility||"visible",bot_visibility:"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:n?{String:n,Valid:true}:{String:"",Valid:false},parsedJson:r}}function qs(t,e,n){let o=t.payload;return {_type:"step",id:e,invocation_id:n.invocation||"",step_id:o.step_id||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),current_status_id:"",path:{String:"",Valid:false},action_type:{String:o.action_type,Valid:true},key:{String:o.key,Valid:true},bot_id:o.bot_id,result_handler_id:"",step_order:{Int32:o.step_order,Valid:true},output_content_type:{String:o.content_type,Valid:true},execution_mode:{String:o.execution_mode,Valid:true},output_behaviour:{String:o.output_behaviour,Valid:true},user_output_visibility:{String:t.metadata.visibility||"visible",Valid:true},output_channels:o.output_channels||[],running_message:{String:o.running_message||"",Valid:!!o.running_message},finished_message:{String:o.finished_message||"",Valid:!!o.finished_message},depends_on:[],eventsByID:{},currentStatus:null}}function Hs(t,e,n){let o=t.payload;return {_type:"result_handler",id:e,invocation_id:t.metadata.invocation_id||"",result_handler_id:o.result_handler_id||e,step_invocation_id:o.step_invocation_id||"",type:o.type||"",if_conditions:o.if_conditions||{},created_at:new Date().toISOString(),updated_at:new Date().toISOString(),output_content_type:o.output_content_type||"",result_handler_order:o.result_handler_order||0,eventsByID:{}}}function zs(t,e,n){return {_type:"output",id:e,step_id:n.step_id,output:{id:e,invocation_id:t.metadata?.invocation_id,path:t.metadata.path,created_at:new Date().toISOString(),updated_at:new Date().toISOString()},state:"in_progress",contents:[],contentsByID:{},contentIDToIdx:{}}}function Jr(t,e,n,o=null){return {_type:"output_content",id:e,output_id:n.output,content:"",content_type:t.metadata.content_type,state:"in_progress",invocation_id:t.metadata.invocation_id,user_visibility:o??t.metadata.user_visibility??"visible",bot_visibility:t.metadata.bot_visibility??"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:t.metadata.ui_content_type?{String:t.metadata.ui_content_type,Valid:true}:{String:"",Valid:false},output:null}}function jr(t,e,n,o=null){let r=null,a=t.metadata?.ui_content_type;if(ae(t.metadata.content_type,a))try{r=ot(t.payload);}catch(s){console.error("Failed to parse step output content as JSON:",s),r=[{content:t.payload,type:"text"}];}return {_type:"output_content",id:e,output_id:n.output,content:t.payload,content_type:t.metadata.content_type,state:"completed",invocation_id:t.metadata.invocation_id,parsedJson:r,user_visibility:o||t.metadata.visibility||"visible",bot_visibility:"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:a?{String:a,Valid:true}:{String:"",Valid:false},output:null}}function Ks(t,e,n){return {_type:"invocation",bot_invocation:{id:t.payload.invocation_id,bot_id:t.payload.bot_id,bot_name:t.payload.bot_name,created_by_user_id:t.payload.created_by_user_id,current_state_id:"",parent_invocation_id:"",branch_init_state_id:"",current_status_id:"",organization_id:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()},eventsByID:{},currentStatus:null,current_status:null,step_invocations:[],step_invocation_states:[],resources:[],outputs:[],statuses:[]}}function de(t,e){let n=t.payload;return {_type:"status",id:new Date().toISOString(),status:n.status,message:{String:n.message,Valid:true},Details:n}}function Zr(t){return {id:t.id,type:"step",created_at:t.created_at,_type:"invocation_event",Output:null,Message:null,Status:null,ResultHandler:null,Step:t}}function Gn(t){return {id:t.output.id,type:"output",created_at:t.output.created_at,_type:"invocation_event",Output:t,Message:null,Status:null,ResultHandler:null,Step:null}}function Fn(t){return {id:t.id,type:"status",created_at:t.created_at,_type:"invocation_event",Status:t,Output:null,Message:null,ResultHandler:null,Step:null}}function Zs(t){return {id:t.message.id,type:"message",created_at:t.message.created_at,_type:"invocation_event",Output:null,Message:t,Status:null,ResultHandler:null,Step:null}}function Qs(t){return {id:t.id,type:"result_handler",created_at:t.created_at,_type:"invocation_event",Output:null,Message:null,Status:null,ResultHandler:t,Step:null}}var Ys=new Set(["=","("]);function Xs(t){if(!t||t.length===0)return true;let e=t[t.length-1];return !Ys.has(e)}function Jn(t,e){if(t.content||(t.content=""),t.user_visibility!=="visible"||!ae(t.content_type,t.ui_content_type.String))return t.content+=e,{...t};if(t.parsedJson||(t.parsedJson=[]),typeof e=="object")return t.content+=JSON.stringify(e),t.parsedJson=[...t.parsedJson,e],{...t};t._jsonParser||(t._isInJson=false),t._charBuffer||(t._charBuffer="");for(let n of e){if(t.content+=n,!t._isInJson&&n==="{"){let o=t.content.slice(0,-1);if(Xs(o)){t._charBuffer="{";continue}}if(t._charBuffer&&Le(n)){t._charBuffer+=n;continue}if(!t._isInJson&&t._charBuffer?.match(/^\s*{\s*$/)&&n==='"'){t._isInJson=true,t._jsonParser=new ft;let r={content:t._jsonParser.add("{"),type:"json"};t._currentContent?.content?t._currentContent.content.match(/^\s*{$/)?(t._currentContent=r,t.parsedJson=[...t.parsedJson.slice(0,-1),r]):(t._currentContent.content=t._currentContent.content.replace(/{$/,""),t._currentContent=r,t.parsedJson=[...t.parsedJson,r]):(t._currentContent=r,t.parsedJson=[...t.parsedJson,r]);}if(t._isInJson)try{let o=t._jsonParser.add(n);t._currentContent.content=o,t._jsonParser.state==="END"&&(t._isInJson=!1,t._currentContent=void 0);}catch(o){if(console.log("handleIncrementalMixedJsonParsing: content chunk",e),console.log("handleIncrementalMixedJsonParsing: accumulated content",t.content),console.warn("handleIncrementalMixedJsonParsing: JSON parse error, recovering as text",o),t._isInJson=false,t._jsonParser=void 0,t.parsedJson&&t.parsedJson.length>0){let r=t.parsedJson[t.parsedJson.length-1];if(r.type==="json"){let a=t.content.lastIndexOf("{"),s=t.content.slice(a);r.type="text",r.content=s,t._currentContent=r;}}continue}else t._currentContent||(t._currentContent={content:t._charBuffer||"",type:"text"},t.parsedJson=[...t.parsedJson,t._currentContent]),t._currentContent.content+=t._charBuffer+n;t._charBuffer="";}return {...t}}function ti(t,e){return Jn(t,e)}function Wr(t,e){return Jn(t,e)}function $n(t,e){let n=$(t);switch(n){case "message":return st(t,e);case "message_content":return Ye(t,e);case "step":return ni(t,e);case "output":return ri(t,e);case "output_content":return oi(t,e);case "invocation":return pe(t,e);case "result_handler":return ai(t,e);default:throw new Error(`Unable to add update entity for entity type ${n}`)}}function ei(t,e){for(let n of e)t=$n(t,n);return t}function st(t,e){let n=Ln(t);if(!n)throw new Error("Unable to find message to add content to");let o=$(e),r=null;switch(o){case "message_content":if(r=e,!n.contentsByID[r.id])n.contentIDToIdx={...n.contentIDToIdx,[r.id]:n.contents.length},n.contents=[...n.contents,r];else {let i=n.contentIDToIdx[r.id];n.contents=[...n.contents.slice(0,i),r,...n.contents.slice(i+1)];}return n.contentsByID={...n.contentsByID,[r.id]:r},{...n};case "invocation":let a=e;if(n.contents.length===0)throw new Error("Unable to find message content to add invocation to");return r=Ye(n.contents[0],a),st(n,r);case "step":if(n.contents.length===0)throw new Error("Unable to find message content to add content to");if(r=n.contents[0],!r)throw new Error("Unable to find message content to add content to");let s=Un(r);if(!s)throw new Error("Unable to find bot invocation to add content to");return r.botInvocation=pe(s,e),st(n,r);case "status":if(n.contents.length>0){let i=n.contents[0];if(i?.botInvocation){let c=Ye(i,e);return st(n,c)}}return {...n};default:throw new Error(`Unable to add update message child for child type ${o}`)}}function Ye(t,e){let n=Qt(t);if(!n)throw new Error("Unable to find message content to add content to");let o=$(e);switch(o){case "invocation":return n.botInvocation=e,{...n};case "step":let r=n.botInvocation;if(!r)throw new Error("Unable to find bot invocation to add content to");return n.botInvocation=pe(r,e),{...n};case "status":return n.botInvocation&&(n.botInvocation=pe(n.botInvocation,e)),{...n};default:throw new Error(`Unable to add update message content child for child type ${o}`)}}function ni(t,e){let n=zr(t);if(!n)throw new Error("Unable to find bot invocation to add step to");let o=$(e),r=null;switch(o){case "output":let a=e;return r=Gn(a),n.eventsByID={...n.eventsByID,[a.output.id]:r},{...n};case "message":let s=e;return r=Zs(s),n.eventsByID={...n.eventsByID,[s.message.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID={...n.eventsByID,[i.id]:r},{...n};case "result_handler":let c=e;return r=Qs(c),n.eventsByID={...n.eventsByID,[c.id]:r},{...n};default:throw new Error(`Unable to add update step for entity type ${o}`)}}function ri(t,e){let n=Xe(t);if(!n)throw new Error("Unable to find step output to add content to");let o=$(e);switch(o){case "output_content":let r=e;if(!n.contentsByID[r.id])n.contentIDToIdx={...n.contentIDToIdx,[r.id]:n.contents.length},n.contents=[...n.contents,r];else {let a=n.contentIDToIdx[r.id];n.contents=[...n.contents.slice(0,a),r,...n.contents.slice(a+1)];}return n.contentsByID={...n.contentsByID,[r.id]:r},{...n};default:throw new Error(`Unable to add update output for entity type ${o}`)}}function oi(t,e){let n=Yt(t);if(!n)throw new Error("Unable to find step output content to add content to");let o=$(e);switch(o){case "invocation":return n.botInvocation=e,{...n};case "step":let r=n.botInvocation;if(!r)throw new Error("Unable to find bot invocation to add content to");return n.botInvocation=pe(r,e),{...n};default:throw new Error(`Unable to add update step output content for entity type ${o}`)}}function pe(t,e){let n=Un(t);if(!n)throw new Error("Unable to find bot invocation to add content to");let o=$(e),r;switch(o){case "step":let a=e;return r=Zr(a),n.eventsByID={...n.eventsByID,[a.id]:r},{...n};case "output":let s=e;return r=Gn(s),n.eventsByID={...n.eventsByID,[s.output.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID={...n.eventsByID,[i.id]:r},n.currentStatus=i,{...n};default:throw new Error(`Unable to add update invocation for entity type ${o}`)}}function ai(t,e){let n=Hr(t);if(!n)throw new Error("Unable to find result handler to add content to");let o=$(e),r=null;switch(o){case "step":let a=e;return r=Zr(a),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[a.id]:r},{...n};case "output":let s=e;return r=Gn(s),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[s.output.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[i.id]:r},{...n};default:throw new Error(`Unable to add update to result handler for entity type ${o}`)}}function si(t){return t==="bot started"||t==="bot resumed"||t==="message created"||t==="create message content"||t==="message content result"||t==="step started"||t==="result handler started"||t==="state created"||t==="step output created"||t==="create step output content"||t==="step output content result"||t==="log"}function tn(t,e,n,o,r,a=null,s=[],i={}){if(!a&&Object.keys(r).length>0){let p,d;if(n.length>=2&&n[0]==="message"?(d=n[1],p=r[d],p||(p=Object.values(r)[0],d=Object.keys(r)[0])):(p=Object.values(r)[Object.values(r).length-1],d=Object.keys(r)[Object.keys(r).length-1]),i.message=d,n.length<=2&&t==="message finished")return null;if(n[0]!=="content"&&Object.keys(p.contentsByID).length>0&&e.metadata.message_content_id){let m=e.metadata.message_content_id,f=p.contentsByID[m];f&&(a=f);}a?s=[p]:a=p;}if(n.length<=2&&si(t)){let p=n[1],d=[],m,f,g,h,k;switch(t){case "bot started":case "bot resumed":if(!a)throw new Error("Unable to find message to add content to");let y=Ks(e);if(a._type==="message_content"){if(f=a,!f.id)throw new Error("Unable to find message content id");if(g=r[f.message_id],!g)throw new Error("Unable to find message to add content to");if(h=Qt(g,f.id),!h)throw new Error("Unable to find message content to add content to");let D=Ye(h,y);r[f.message_id]={...st(g,D)};}d.push(y);break;case "message created":return r[p]=Kr(e,o,p),null;case "create message content":if(!a)throw new Error("Unable to find message to add content to");if(k=js(e,i),a._type==="output"){m=a,d.push(Jr(e,p,i,"hidden"));let D=e.payload.message_id;if(D||(D=s[0].message.id),g=r[D],!g)throw new Error("Unable to find message to add content to")}else if(a._type==="message_content"){if(m=a,g=r[m.message_id],!g)throw new Error("Unable to find message to add content to")}else {if(a._type!=="message")throw new Error(`Incorrect path? Cannot add content to non-message entity: ${a._type}`);if(m=a,g=r[m.message.id],!g)throw new Error("Unable to find message to add content to");d.push(k);}r[g.message.id]={...st(g,k)};break;case "message content result":if(!a)throw new Error("Unable to find message to add content to");let b=null;if(a._type==="output"){d.push(jr(e,p,i,"hidden"));let D=e.payload.message_id||i.message;if(D?b=s.find(I=>I.message.id===D):b=s[0],g=r[D],!g)throw new Error("Unable to find message to add content to")}else if(a._type==="message_content"){if(b=s[0],g=r[b.message.id],!g)throw new Error("Unable to find message to add content to")}else {if(a._type!=="message")throw new Error(`Incorrect path? Cannot add content to non-message entity: ${a._type}`);if(b=a,g=r[b.message.id],!g)throw new Error("Unable to find message to add content to")}let N=e.metadata.message_content_id;if(!N)throw new Error("Unable to find message content id");let v=Qt(b,N);if(v){v.state="completed";let D=typeof e.payload=="string"?e.payload:e.payload.content||e.payload;v.content=D,r[g.message.id]={...st(g,v)},(a._type==="message"||a._type==="message_content")&&d.push(v);}else v=Ws(e,i),r[g.message.id]={...st(g,v)},(a._type==="message"||a._type==="message_content")&&d.push(v);break;case "step started":d.push(qs(e,p,i));break;case "result handler started":d.push(Hs(e,p));break;case "step output created":d.push(zs(e,p,a));break;case "create step output content":d.push(Jr(e,p,i));break;case "step output content result":d.push(jr(e,p,i));break;case "log":return null;default:throw new Error(`Unable to handle create event type ${t}`)}return d.length?!a||a._type==="message_content"&&d.length===1&&d[0]._type==="message_content"?d[0]:ei(a,d):null}if(!a)throw new Error("No first message has been created, so cannot handle amend events");if(n.length<=1){let p=null;try{p=Fs(a);}catch{}switch(t){case "message content delta":if(!p)throw new Error("Unable to find message content");let d=null,m=null,f=null;if(a._type==="output_content"){d=Wr(a,e.payload);let y=e.metadata.message_content_id;if(!y)throw new Error("Unable to find message content id from entity ids");let b=i.message;if(f=s.find(N=>N.message.id===b),!f)throw new Error("Unable to find message to add content to");m=Qt(f,y);}else {if(m=p,f=s[s.length-1],!f)throw new Error("Unable to find message to add content to");if(f._type!=="message")throw new Error("Unable to find message to add content to - not a message")}if(!m)throw new Error("Unable to find message content");let g=r[f.message.id];if(!g)throw new Error("Unable to find message to add content to");let h=ti(m,e.payload);return r[g.message.id]={...st(g,h)},a._type==="message_content"&&(d=h),d;case "step output content delta":return Wr(p,e.payload);case "status":if(a._type==="step"&&(a.currentStatus=de(e)),a._type==="invocation"&&(a.currentStatus=de(e)),a._type==="message_content"){let k=a;if(k.botInvocation)return k.botInvocation.currentStatus=de(e),{...k}}if(a._type==="message"){let k=a,y=qr(k);if(y?.botInvocation)return y.botInvocation.currentStatus=de(e),st(k,y)}return $n(a,de(e));case "result":return null;case "message finished":return null;case "step output finished":return null;case "step result":return null;case "error":return null;case "dataset created":return null;case "log":return null;default:throw new Error(`Unable to handle event type ${t}`)}}let c=n.slice(2),l=Js(a,n,i),u=tn(t,e,c,o,r,l,[...s,a],i);return u?$n(a,{...u}):a}function li(t){return t.split("/").filter(Boolean)}function Yr(t={}){let e=It(),[n,o]=useState(null),[r,a]=useState(false),[s,i]=useState(null),[c,l]=useState([]),u=useRef(null),p=useRef(t.threadId);t.threadId!==p.current&&(p.current=t.threadId);let d=useCallback(()=>{u.current&&(u.current.abort(),u.current=null);},[]),m=useCallback(h=>{o(h),p.current=h.id;},[]),f=useCallback(async h=>{if(!e.client)throw new Error("ErdoClient not configured in provider. Pass a client to ErdoProvider config to use useThread.");if(!e.client.sendMessage)throw new Error("ErdoClient does not support sendMessage. Make sure you are using @erdoai/server client.");if(!e.client.createThread)throw new Error("ErdoClient does not support createThread. Make sure you are using @erdoai/server client.");d(),u.current=new AbortController,a(true),i(null),l([]);let k={};try{let y=p.current;if(!y){let v=await e.client.createThread();o(v),p.current=v.id,y=v.id;}for await(let v of e.client.sendMessage(y,{content:h,botKey:t.botKey})){if(u.current?.signal.aborted)break;t.onEvent?.(v);let D=v.type||"",I=v.metadata||{},B=li(I.path||""),yt={payload:v.payload,metadata:{path:I.path||"",...I}};try{tn(D,yt,B,y,k);}catch(z){console.error("Error handling SSE event:",z,D);}l(Object.values(k));}let b=Object.values(k);l(b);let N=b.flatMap(v=>v.contents||[]).filter(v=>v.user_visibility==="visible").map(v=>({id:v.id,content_type:v.content_type,ui_content_type:T(v.ui_content_type),content:v.content,parsedJson:v.parsedJson,botInvocation:v.botInvocation}));t.onFinish?.(N);}catch(y){let b=y instanceof Error?y:new Error(String(y));throw i(b),t.onError?.(b),b}finally{a(false),u.current=null;}},[e.client,t,d]),g=useMemo(()=>{let h=c.flatMap(b=>b.contents||[]).filter(b=>b.user_visibility==="visible");return Se(h).map(b=>({id:b.id,content_type:b.content_type,ui_content_type:T(b.ui_content_type),content:b.content,parsedJson:b.parsedJson,botInvocation:b.botInvocation}))},[c]);return {thread:n,isStreaming:r,error:s,activeMessages:c,streamingContents:g,sendMessage:f,cancel:d,setThread:m}}export{kt as BarChart,He as BotInvocationContent,et as Chart,ee as ChartContainer,Pe as ChartContent,sn as ChartLegend,ln as ChartLegendContent,bn as ChartNode,Kn as ChartStyle,on as ChartTooltip,an as ChartTooltipContent,qe as CodeexecContent,We as CodegenContent,Ft as CollapsibleCodeBlock,ue as Content,Ce as DatasetChart,$t as DatasetDownload,_e as DatasetTable,_n as DownloadButtonNode,qn as ErdoProvider,Us as ErdoUI,xt as ErrorBoundary,yn as ExecutionStatus,jt as ExpandableOutputContent,At as HeatmapChart,De as InvocationEvent,Mt as InvocationEvents,hr as InvocationStatus,ft as JSONStreamParser,mt as JsonContent,Bt as LineChart,Vn as Loader,Nn as Log,Oe as LogContent,M as MarkdownContent,Ze as MemoryContent,we as Output,Pt as PieChart,Rt as ScatterChart,Ue as SqlContent,vt as StatusSpinner,Wt as StderrText,Fe as StdoutText,Je as StdwarnText,Ee as StepInvocation,Ie as StepInvocationStatus,Sn as SuggestionsNode,Re as TableContent,vn as TableNode,se as TextContent,Cn as TextMarkdownNode,Ae as ThinkingContent,Ht as ToolGroupContent,Lt as UIGenerationNodes,Me as WebParseContent,Ve as WebSearchContent,On as WritingLoader,q as cn,Fr as extractContentItems,tt as formatValue,Jn as handleIncrementalMixedJsonParsing,tn as handleSSEEvent,ae as isJsonLike,dr as isNullString,rs as isParsingComplete,En as isParsingInProgress,Le as isWhitespaceChar,wn as nodeComponents,es as parseCompleteJson,ot as parseMixedJson,Zn as parseToDate,Vt as resolveKeyFromData,or as toSnakeCase,T as unwrapNullString,aa as unwrapNullStringOr,ye as useChartZoom,xe as useDatasetContents,It as useErdoConfig,j as useErdoConfigOptional,ke as useMultipleDatasetContents,Yr as useThread};
26
+ `||t===" "||t==="\r"}function ns(t,e){if(e>=t.length-1)return "";for(let n=e+1;n<t.length;n++)if(!Le(t[n]))return t[n];return ""}function ot(t){if(typeof t!="string")return t;let e=[],n=/```json\s*\n/g,o=n.test(t);if(n.lastIndex=0,o){let r=0,a;for(;(a=n.exec(t))!==null;){let i=t.substring(r,a.index).trim();i&&e.push({content:i,type:"text"});let c=a.index+a[0].length,l=[],u=c;for(;;){let m=t.indexOf("```",u);if(m===-1)break;l.push(m),u=m+3;}let p=null,d=t.length;for(let m of l){let f=t.substring(c,m);try{p=JSON.parse(f),d=m+3;break}catch{try{let g=new ft,y=g.parse(f);if(y&&g.state==="END"){p=y,d=m+3;break}}catch{}}}if(p)e.push({content:p,type:"json"});else {let m=t.substring(a.index,d);e.push({content:m,type:"text"});}r=d,n.lastIndex=d;}let s=t.substring(r).trim();s&&e.push({content:s,type:"text"});}else {let r="",a=null,s=false,i=0;for(let c=0;c<t.length;c++){let l=t[c],u=ns(t,c);if(!s&&(l==="{"&&u==='"'||l==="["&&u==="{")&&(r.trim()&&e.push({content:r.trim(),type:"text"}),s=true,a=new ft,r=""),s){let p;try{p=a.add(l);}catch(d){if(console.log("parseMixedJson: currentChunk",r),console.log("parseMixedJson: currentResult",a?.result),console.warn("parseMixedJson: JSON parse error",d),i++,i>3){s=false,a=null,i=0,r+=l;continue}continue}r+=l,a.state==="END"&&(e.push({content:p,type:"json"}),s=false,a=null,r="");}else r+=l;}r.trim()&&e.push({content:r.trim(),type:"text"});}return e}function rs(t){return t&&typeof t=="object"&&!t[Jt]}function En(t){return t&&typeof t=="object"&&t[Jt]===true}function Ue({item:t,className:e}){if(!t.content)return null;let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=t.parsedJson;if(!o)try{o=ot(n);}catch(c){console.error("Failed to parse SQL content:",c),o=[{content:n||"",type:"text"}];}let r=Array.isArray(o)?o.find(c=>c.type==="json"):o?.[0];if(!r)return jsxs("div",{className:`text-destructive text-sm ${e||""}`,children:[jsx("div",{className:"font-medium",children:"Error"}),jsx("div",{children:n})]});let{thinking:a,sql_query:s,error:i}=r?.content||{};return i?jsxs("div",{className:`text-destructive text-sm ${e||""}`,children:[jsx("div",{className:"font-medium",children:"Error"}),jsx("div",{children:i})]}):s?jsxs("div",{className:`text-foreground whitespace-pre-wrap leading-normal ${e||""}`,children:[a&&jsx("div",{className:"mb-2",children:jsx(M,{content:a,className:"text-sm max-w-none"})}),s&&jsx("div",{className:"mb-2",children:jsx(Ft,{language:"sql",value:s,defaultOpen:false})})]}):null}function jt({children:t,defaultOpen:e=false,wrapperType:n="standard",compact:o=false,className:r}){let[a,s]=useState(e),[i,c]=useState(false),l=useRef(null);useEffect(()=>{let d=l.current;d&&(a||(d.scrollTop=d.scrollHeight),c(d.scrollHeight>d.clientHeight));},[a,t]);let u={standard:"bg-muted/30 border-border",info:"bg-info/10 border-info/30",warning:"bg-warning/10 border-warning/30"},p={standard:"text-muted-foreground hover:text-foreground",info:"text-info hover:text-info/80",warning:"text-warning hover:text-warning/80"};return jsx("div",{className:`relative text-sm ${o?"":"mb-2"} ${r||""}`,children:jsx(qt.Root,{open:a,onOpenChange:s,className:`border rounded-sm ${u[n]}`,children:jsxs("div",{ref:l,className:`overflow-y-auto ${a?"":"max-h-[200px]"}`,children:[i&&jsx(qt.Trigger,{className:`sticky top-0 text-center text-xs py-1 transition-opacity w-full cursor-pointer ${p[n]}`,children:a?"Less \u2193":"More \u2191"}),jsx("div",{className:`${o?"px-2 py-1":"p-2"} m-0 overflow-x-auto break-words whitespace-pre-wrap`,children:t})]})})})}function Tn(t){return new Date(t).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Fe({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-muted-foreground/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-foreground/80",children:t})]})}function Wt({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-info/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-info/90",children:t})]})}function Je({children:t,timestamp:e}){return jsxs("div",{className:"flex",children:[e&&jsx("span",{className:"text-warning/60 mr-2 select-none",children:Tn(e)}),jsx("span",{className:"text-warning/90",children:t})]})}function We({item:t,className:e}){if(!t.content)return null;let n=typeof t.content=="string"?t.content:JSON.stringify(t.content),o=t.parsedJson;if(!o)try{o=ot(n);}catch(u){console.error("Failed to parse codegen content:",u),o=[{content:n||"",type:"text"}];}let r=Array.isArray(o)?o.find(u=>u.type==="json"):o?.[0],{step_by_step:a,thinking:s,code:i,warnings:c,error:l}=r?.content||{};return l?jsx(jt,{wrapperType:"info",className:e,children:jsx(Wt,{children:l})}):!a&&!i?null:jsxs("div",{className:`text-foreground whitespace-pre-wrap leading-normal ${e||""}`,children:[a&&jsx(M,{content:a,className:"text-sm max-w-none"}),s&&jsx("div",{className:"mb-2",children:jsx(M,{content:s,className:"text-sm max-w-none"})}),i&&jsx("div",{className:"mb-2",children:jsx(Ft,{language:"python",value:i,defaultOpen:false})}),c&&jsxs("div",{className:"text-sm text-warning",children:[jsx("div",{className:"font-medium",children:"Warnings"}),jsx(M,{content:c,className:"text-sm max-w-none"})]})]})}function qe({item:t,className:e}){let n=t.parsedJson;if(!n?.length)return null;let o=n.map(i=>i.message?.trim()?{level:i.level,message:i.message,timestamp:i.timestamp,index:i.index}:null).filter(i=>i!==null);if(o.sort((i,c)=>i.index-c.index),o.length===0)return null;let r=o.some(i=>i.level==="error"),a=o.some(i=>i.level==="warning"),s=r?"info":a?"warning":"standard";return jsx("div",{className:`text-foreground leading-normal ${e||""}`,children:jsx(jt,{wrapperType:s,compact:true,children:o.map((i,c)=>jsx(ss,{output:i},`${i.level}-${c}`))})})}function ss({output:t}){switch(t.level){case "output":return jsx(Fe,{timestamp:t.timestamp,children:t.message});case "error":return jsx(Wt,{timestamp:t.timestamp,children:t.message});case "warning":return jsx(Je,{timestamp:t.timestamp,children:t.message});default:return jsx("div",{className:"text-muted-foreground",children:t.message})}}var us={"websearch.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched web for "${n}"`:`Failed to search web for "${n}"`:`Searching web for "${n}"...`:"Web search"}},"webparser.parse":{icon:Globe,getLabel:(t,e)=>{let n=t?.url;return n?e?e==="success"?`Read ${n}`:`Failed to read ${n}`:`Reading ${n}...`:"Parse site"}},"siteparser.parse":{icon:Globe,getLabel:(t,e)=>{let n=t?.url;return n?e?e==="success"?`Read ${n}`:`Failed to read ${n}`:`Reading ${n}...`:"Parse site"}},"resource_definitions.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched resources for "${n}"`:`Failed to search resources for "${n}"`:`Searching resources for "${n}"...`:"Search resources"}},"memory.search":{icon:Search,getLabel:(t,e)=>{let n=t?.query;return n?e?e==="success"?`Searched memories for "${n}"`:`Failed to search memories for "${n}"`:`Searching memories for "${n}"...`:"Search memories"}}};function Ar(t){return t&&us[t]||null}function ds(t){if(!t?.result||t.status==="error")return false;let e=t.result;if(typeof e=="string"){let n=e.trim();return n!==""&&n!=="{}"&&n!=="[]"}if(Array.isArray(e))return e.length>0;if(typeof e=="object"&&e!==null){let n=Object.keys(e);return n.length===0?false:n.some(o=>{let r=e[o];return r==null?false:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"?Object.keys(r).length>0:true})}return true}function ps({actionType:t}){let n=Ar(t)?.icon||Wrench;return jsx(n,{className:"h-4 w-4"})}function ms({actionType:t,input:e,name:n,result:o,invocation:r}){if(o?.finished_message)return jsx("span",{children:o.finished_message});if(o?.running_message)return jsx("span",{children:o.running_message});if(!o&&r?.running_message)return jsx("span",{children:r.running_message});let a=Ar(t);if(a)return jsx("span",{children:a.getLabel(e,o?.status)});let s=o?`Completed ${n}`:`Running ${n}...`;return jsx("span",{children:s})}function Ht({toolGroup:t,ContentComponent:e,className:n,fallbackClassName:o}){let[r,a]=useState(false),s=j(),i=e??s?.ContentComponent,c=t.invocation,l=t.result,u=ds(l),p=c?.action_type||l?.action_type,d=c?.input||l?.input,m=c?.name||l?.name,f=l?.status==="error"?"text-gray-500/80 dark:text-gray-400/80":"text-gray-500 dark:text-gray-400";return jsxs(qt.Root,{open:r,onOpenChange:a,className:`relative w-full max-w-4xl space-y-2 leading-normal ${n||""}`,children:[jsxs(qt.Trigger,{className:`flex items-center gap-2 text-sm transition-colors w-full ${f} ${u?"hover:text-gray-900 dark:hover:text-gray-100 cursor-pointer":"cursor-default"}`,disabled:!u,children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(ps,{actionType:p}),jsx(ms,{actionType:p,input:d,name:m,result:l,invocation:c})]}),u&&jsx(ChevronDown,{className:`h-4 w-4 transition-transform duration-200 ${r?"rotate-180":""}`})]}),u&&l&&jsx(qt.Content,{children:jsx("div",{className:"pl-6 mt-2",children:i?jsx(i,{content:{content:l.result,content_type:l.ui_content_type||"text",ui_content_type:l.ui_content_type||"text"}}):jsx("pre",{className:o||"text-sm bg-gray-100 dark:bg-gray-800 p-2 rounded overflow-x-auto",children:JSON.stringify(l.result,null,2)})})})]})}var wt={Success:"success",Error:"error",RequiresInfo:"requires info"};function hs(t){return t?t===wt.Success?"finished":t===wt.Error||t===wt.RequiresInfo?"failed":"loading":"loading"}function Mr(t){return t?t!==wt.Success&&t!==wt.Error&&t!==wt.RequiresInfo:true}function xs(t,e){let n=e||"agent",o=T(t?.message);return o||(t?.status===wt.Success?`Finished ${n}`:`Running ${n}...`)}function He({content:t,botInvocation:e,isLoading:n=false,defaultOpen:o,adminLinkHref:r,adminLinkText:a="Open in Agent Designer",showAdminLink:s=false,onAdminClick:i,onExpand:c,EventsComponent:l,ContentComponent:u,className:p}){let d=()=>o!==void 0?o:e?.currentStatus?Mr(e.currentStatus.status):false,[m,f]=useState(d),[g,y]=useState(false),x=useRef(null);if(useEffect(()=>{if(e?.currentStatus){let I=e.currentStatus.status;if(x.current!==I&&(x.current=I,!g)){let B=Mr(I);B&&!m?f(true):!B&&m&&f(false);}}},[e,g,m]),useEffect(()=>{m&&e&&c&&c(t.invocation_id,t.bot_id,t.bot_name);},[m,e,c,t]),n&&!e)return jsxs("div",{className:`flex items-center gap-2 text-sm text-muted-foreground ${p||""}`,children:[jsx(vt,{status:"loading"}),jsxs("span",{children:["Loading ",t.bot_name,"..."]})]});if(!e)return null;let h=hs(e.currentStatus?.status),b=xs(e.currentStatus,t.bot_name),N=I=>{f(I),y(true);},v=I=>{i&&(I.preventDefault(),i(t.invocation_id,t.bot_id));},D=e.eventsByID&&Object.keys(e.eventsByID).length>0;return jsxs(qt.Root,{open:m,onOpenChange:N,className:`relative w-full max-w-4xl space-y-2 leading-normal bot-invocation-content ${p||""}`,children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs(qt.Trigger,{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[jsx(vt,{status:h}),b]}),jsx(ChevronDown,{className:`h-4 w-4 transition-transform duration-200 ${m?"transform rotate-180":""}`})]}),s&&(r||i)&&jsxs("a",{href:r||"#",onClick:i?v:void 0,target:r?"_blank":void 0,rel:r?"noopener noreferrer":void 0,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a,jsx(ArrowUpRight,{className:"h-3.5 w-3.5"})]})]}),jsx(qt.Content,{children:jsx("div",{className:"space-y-2 max-w-3xl",children:D?l?jsx(l,{eventsByID:e.eventsByID,defaultOpen:m}):jsx(Mt,{eventsByID:e.eventsByID,ContentComponent:u}):jsx("span",{className:"text-sm text-muted-foreground",children:"No events to display"})})})]})}function Rn({content:t,isSearching:e=false,className:n}){let o=[];if(Array.isArray(t))o=t;else if(typeof t=="object"&&t!==null&&"q"in t)o=t.q;else if(typeof t=="string")try{let a=JSON.parse(t);Array.isArray(a)?o=a:a.q&&Array.isArray(a.q)&&(o=a.q);}catch{o=[t];}let r=o.filter(a=>a&&a.trim()!=="");return r.length===0?null:jsx("div",{className:`flex flex-wrap gap-2 ${n||""}`,children:r.map(a=>jsxs("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg text-sm bg-muted/50 text-foreground border border-border/30",children:[e?jsx(Loader2,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0 animate-spin"}):jsx(Search,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0"}),jsx("span",{className:"line-clamp-1",children:a})]},a))})}function An({content:t,isSearching:e=false,className:n}){let o=[];if(Array.isArray(t))o=t;else if(typeof t=="object"&&t!==null&&"integration_queries"in t)o=t.integration_queries;else if(typeof t=="string")try{let a=JSON.parse(t);Array.isArray(a)?o=a:a.integration_queries&&Array.isArray(a.integration_queries)&&(o=a.integration_queries);}catch{return null}let r=o.filter(a=>a&&a.query&&a.query.trim()!=="");return r.length===0?null:jsx("div",{className:`flex flex-wrap gap-2 ${n||""}`,children:r.map(a=>jsxs("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg text-sm bg-muted/50 text-foreground border border-border/30",children:[e?jsx(Loader2,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0 animate-spin"}):jsx(Search,{className:"h-3 w-3 mr-2 text-muted-foreground flex-shrink-0"}),jsx("span",{className:"line-clamp-1",children:a.query})]},`${a.integration_config_id}-${a.resource_id}-${a.query}`))})}var Bs=120;function Ps(t,e){return !t||t.length<=e?t:t.slice(0,e).trimEnd()+"..."}function Rs(t){switch(t){case "snippet":return Code;case "learning":return Brain;case "error":return AlertCircle;case "limitation":return AlertCircle;case "optimization":return Zap;default:return Lightbulb}}function As(t){switch(t){case "snippet":return "Snippet";case "learning":return "Learning";case "error":return "Error";case "limitation":return "Limitation";case "optimization":return "Optimization";default:return t}}function Os({memory:t}){let[e,n]=useState(false),o=Rs(t.type),r=As(t.type),a=t.type==="snippet",s=Ps(t.description||"",Bs),i=t.content&&t.content.trim()!=="",c=a&&i;return jsxs(qt.Root,{open:e,onOpenChange:n,className:"border border-border/50 rounded-lg overflow-hidden",children:[jsxs(qt.Trigger,{className:`w-full text-left p-3 flex items-start gap-3 ${c?"hover:bg-muted/50 cursor-pointer":"cursor-default"}`,disabled:!c,children:[jsx("div",{className:"flex-shrink-0 mt-0.5",children:jsx(o,{className:"h-4 w-4 text-muted-foreground"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-1",children:[jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:r}),t.tags&&t.tags.length>0&&jsxs("div",{className:"flex gap-1 flex-wrap",children:[t.tags.slice(0,3).map((l,u)=>jsx("span",{className:"text-xs px-1.5 py-0.5 bg-muted rounded text-muted-foreground",children:l},u)),t.tags.length>3&&jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.tags.length-3]})]})]}),jsx("p",{className:"text-sm text-foreground",children:a?s:t.description||t.content})]}),c&&jsx(ChevronDown,{className:`h-4 w-4 text-muted-foreground flex-shrink-0 transition-transform duration-200 ${e?"rotate-180":""}`})]}),c&&jsx(qt.Content,{children:jsx("div",{className:"border-t border-border/50 bg-muted/30",children:jsx("pre",{className:"p-3 text-sm overflow-x-auto whitespace-pre-wrap break-words font-mono",children:t.content})})})]})}function Ze({content:t,className:e}){let n=Array.isArray(t)?t:t?.memories;return !n||n.length===0?jsx("p",{className:"text-sm text-muted-foreground",children:"No memories found."}):jsx("div",{className:`space-y-2 ${e||""}`,children:n.map(o=>jsx(Os,{memory:o},o.id))})}function On(){return jsxs("span",{className:"inline-flex gap-1 text-muted-foreground",children:[jsx("span",{className:"animate-bounce",style:{animationDelay:"0ms"},children:"\u25CF"}),jsx("span",{className:"animate-bounce",style:{animationDelay:"150ms"},children:"\u25CF"}),jsx("span",{className:"animate-bounce",style:{animationDelay:"300ms"},children:"\u25CF"})]})}function Vn(){return jsx("div",{className:"flex items-center justify-center py-8",children:jsx(Loader2,{className:"animate-spin text-muted-foreground",size:24})})}function $s(t){if(t.content_type==="bot_invocation"||t.content_type==="bot_invocation_result"||t.content&&typeof t.content=="object"&&t.content.action_type==="bot.invoke")return null;if(t.content_type==="tool_invocation")return "tool_invocation";if(t.content_type==="tool_result")return "tool_result";if(!t.content||typeof t.content!="object")return null;let e=t.content;return "action_type"in e&&"name"in e&&"input"in e&&e.action_type!=="bot.invoke"?"result"in e?"tool_result":"tool_invocation":null}function ue({content:t,className:e,components:n}){let r=j()?.onSuggestionClick,a=useMemo(()=>l=>jsx(ue,{...l,components:n}),[n]);if(t.content&&typeof t.content=="object"&&t.content.action_type==="bot.invoke")return null;let s=$s(t),i;s?i=s:(i=T(t.ui_content_type)||t.content_type,i!=="ui_generation"&&typeof t.content=="string"&&(t.content.includes('{"children":')||t.content.includes('"children":'))&&(i="ui_generation"));let c=n?.[i];if(c)return jsx(c,{content:t,className:e});switch(i){case "text":return jsx(se,{content:Ur(t),className:e});case "markdown":return jsx(M,{content:Ur(t),className:e});case "thinking":case "redacted_thinking":return jsx(Ae,{item:t,className:e});case "json":return jsx(mt,{content:t.content,className:e});case "codegen_json":return jsx(We,{item:t,className:e});case "sql_generation":return jsx(Ue,{item:t,className:e});case "codeexec_output":return jsx(qe,{item:t,className:e});case "log":return jsx(Oe,{item:t,className:e});case "websearch":case "websearch_output":case "web_search":return jsx(Ve,{item:t,className:e});case "search_queries":return jsx(Rn,{content:t.content,className:e});case "integration_queries":return jsx(An,{content:t.content,className:e});case "memory":return jsx(Ze,{content:t.content,className:e});case "webparse":case "webparse_output":case "web_parse":return jsx(Me,{item:t,className:e});case "tool_group":return jsx(Ht,{toolGroup:t.content,ContentComponent:a,className:e});case "bot_invocation":{let l=t.content,u=t.botInvocation;return jsx(He,{content:l,botInvocation:u,ContentComponent:a,className:e})}case "chart":case "ui_generation":{let l=t.invocation_id||t.created_by_invocation_id;if(t.chartConfig&&t.chartData)return jsx(Pe,{config:t.chartConfig,data:t.chartData,className:e});let u=t.parsedJson;if(u&&Array.isArray(u)&&u.length>0)return jsx(Fragment,{children:u.map((d,m)=>{if(d.type==="text"){let f=d.content;return jsx(M,{content:f,className:e},`${m}-${f.length}`)}else if(d.type==="json"){let f=d.content;return En(f)?f?.children?.some(x=>x?._type==="TextMarkdown")?jsx(On,{},m):jsx(Vn,{},m):f?.children&&Array.isArray(f.children)?jsx(ut__default.Fragment,{children:jsx(Lt,{nodes:f.children,className:e,invocationId:l,onSuggestionClick:r})},`${m}-${f.children.length}`):jsx(mt,{content:f,className:e},`${m}-json`)}return null})});let p=typeof t.content=="string"?t.content:null;if(p){let d=ot(p);if(Array.isArray(d))return jsx(Fragment,{children:d.map((m,f)=>{if(m.type==="text"){let g=m.content;return jsx(M,{content:g,className:e},`${f}-${g.length}`)}else if(m.type==="json"){let g=m.content;return g?.children&&Array.isArray(g.children)?jsx(ut__default.Fragment,{children:jsx(Lt,{nodes:g.children,className:e,invocationId:l,onSuggestionClick:r})},`${f}-${g.children.length}`):jsx(mt,{content:g,className:e},`${f}-json`)}return null})})}if(typeof t.content=="object"&&t.content!==null){let d=t.content;if(d?.children&&Array.isArray(d.children))return jsx(Lt,{nodes:d.children,className:e,invocationId:l,onSuggestionClick:r})}return jsx(mt,{content:t.content,className:e})}case "table":return t.tableColumns&&t.tableData?jsx(Re,{columns:t.tableColumns,data:t.tableData,className:e}):jsx(mt,{content:t.content,className:e});case "bot_invocation_result":case "security_check_json":return null;case "tool_invocation":{let l=t.content,u={invocation:{invocation_id:l.id||"",action:l.action_type||"",params:l.input||{},id:l.id||"",name:l.name||"",input:l.input||{},description:l.description,action_type:l.action_type,running_message:l.running_message}};return jsx(Ht,{toolGroup:u,ContentComponent:a,className:e})}case "tool_result":{let l=t.content,u={invocation:{invocation_id:l.id||"",action:l.action_type||"",params:l.input||{}},result:{invocation_id:l.id||"",result:l.result}},p={...u,invocation:{...u.invocation,id:l.id||"",name:l.name||"",input:l.input||{},action_type:l.action_type,description:l.description},result:{...u.result,id:l.id||"",name:l.name||"",input:l.input||{},result:l.result,status:l.status||"success",action_type:l.action_type,description:l.description,ui_content_type:l.ui_content_type,running_message:l.running_status,finished_message:l.finished_status}};return jsx(Ht,{toolGroup:p,ContentComponent:a,className:e})}default:return typeof t.content=="string"?jsx(se,{content:t.content,className:e}):null}}function Ur(t){return typeof t.content=="string"?t.content:""}function Us({result:t,isStreaming:e,className:n,components:o,streamingText:r}){let a=t?Fr(t):[];return r&&a.length===0?jsxs("div",{className:n?`erdo-ui ${n}`:"erdo-ui space-y-4",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"animate-pulse w-2 h-2 bg-blue-500 rounded-full"}),jsx("span",{className:"text-sm text-gray-500",children:"Streaming response..."})]}),jsx("div",{className:"border rounded-lg p-4 whitespace-pre-wrap",children:r})]}):a.length===0&&!e?null:jsxs("div",{className:n?`erdo-ui ${n}`:"erdo-ui space-y-4",children:[a.map((s,i)=>jsx("div",{children:jsx(ue,{content:s,components:o})},s.id||i)),e&&a.length===0&&!r&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"animate-pulse w-2 h-2 bg-blue-500 rounded-full"}),jsx("span",{className:"text-sm text-gray-500",children:"Processing..."})]})]})}function Fr(t){let e=[],n=new Set;if(t.events)for(let o of t.events){let r=o.metadata,a=o.payload;if(r?.user_visibility==="visible"&&a?.status==="success"&&a?.output){let s=a.output;if(s.content&&Array.isArray(s.content))for(let i=0;i<s.content.length;i++){let c=s.content[i],l=c.id||`event-result-${i}`;if(n.has(l))continue;n.add(l);let u=r?.ui_content_type;if(!u&&typeof c.content=="string")try{JSON.parse(c.content)?.children&&(u="ui_generation");}catch{(c.content.includes('{"children":')||c.content.includes('{ "children":'))&&(u="ui_generation");}e.push({id:l,content_type:c.content_type||"text",ui_content_type:u,content:c.content,data:c.data,chartConfig:c.chartConfig,chartData:c.chartData,tableColumns:c.tableColumns,tableData:c.tableData});}}}if(e.length===0&&t.result?.output?.content){let o=t.result.output.content;if(Array.isArray(o))for(let r=0;r<o.length;r++){let a=o[r],s=a.id||`result-${r}`;if(n.has(s))continue;n.add(s);let i=a.ui_content_type;if(!i&&typeof a.content=="string")try{JSON.parse(a.content)?.children&&(i="ui_generation");}catch{(a.content.includes('{"children":')||a.content.includes('{ "children":'))&&(i="ui_generation");}e.push({...a,id:s,ui_content_type:i});}}return e}function $(t){if(!t)throw new Error("Entity is null");if(!("_type"in t))throw new Error(`Entity ${JSON.stringify(t)} is missing _type`);return t._type}function Gs(t){return t.contents.length===0?null:t.contents[t.contents.length-1]||null}function qr(t){return t.contents.length===0?null:t.contents[0]||null}function Ln(t,e){let n=$(t);switch(n){case "message":return t;case "step":let o=t;if(e){let s=o.eventsByID[e]?.Message;return s||Kr({},"",e)}let a=Object.keys(o.eventsByID).reverse();for(let s of a){let i=o.eventsByID[s];if(i&&i.Message)return i.Message}throw new Error("Unable to find message for step");default:throw new Error(`Unable to have messages on entity type ${n}`)}}function Fs(t,e){switch($(t)){case "message_content":return t;case "output_content":return t;case "message":return Qt(t,e);case "output":return Yt(t,e);case "step":let o=Xe(t,e);return o?Yt(o,e):null;default:return null}}function Qt(t,e){let n=$(t);switch(n){case "message_content":return t;case "message":let o=Ln(t);if(!o)throw new Error("Unable to find message to add content to");return e?o.contentsByID[e]:Gs(o);default:throw new Error(`Unable to have message content on entity type ${n}`)}}function Yt(t,e){let n=$(t);switch(n){case "output_content":return t;case "output":let o=t;return e?o.contentsByID[e]||null:o.contents.length<=0?null:o.contents[o.contents.length-1]||null;case "step":let a=Xe(t,e);return a?Yt(a):null;case "invocation":if(!e)return null;let s=t.eventsByID[e];return !s||!s.Output?null:Yt(s.Output);default:throw new Error(`Unable to have output content on entity type ${n}`)}}function Un(t,e){let n=$(t),o=null;switch(n){case "invocation":return t;case "message_content":if(o=t.botInvocation||null,!o)throw new Error("Unable to find bot invocation for message content");if(e&&o.bot_invocation.id!==e)throw new Error("Unable to find bot invocation for message content - mismatched ID");return o;case "message":if(o=qr(t)?.botInvocation||null,!o)throw new Error("Unable to find bot invocation for message");if(e&&o.bot_invocation.id!==e)throw new Error("Unable to find bot invocation for message - mismatched ID");return o;case "output_content":return t.botInvocation||null;default:throw new Error(`Unable to have bot invocation on entity type ${n}`)}}function Xe(t,e){let n=$(t);switch(n){case "output":return t;case "step":let o=t;if(e){let i=o.eventsByID[e]?.Output;if(!i)throw new Error("Unable to find output with id "+e);return i}let a=Object.keys(o.eventsByID).reverse();for(let i of a){let c=o.eventsByID[i];if(c&&c.Output)return c.Output}throw new Error("Unable to find output for step");case "invocation":if(!e)throw new Error("Unable to find output for invocation without ID");return t.eventsByID[e]?.Output||null;default:throw new Error(`Unable to have step outputs on entity type ${n}`)}}function Hr(t,e){let n=$(t);switch(n){case "result_handler":return t;case "step":if(!e)throw new Error("Unable to have result handlers on step without ID");let o=t.eventsByID[e];if(!o||!o.type||o.type!=="result_handler"||!o.ResultHandler)throw new Error(`Unable to find result handler with id ${e} on step ${t.id}`);return o.ResultHandler;default:throw new Error(`Unable to have result handlers on entity type ${n}`)}}function zr(t,e){let n=$(t),o=null;switch(n){case "step":if(t.id===e||!e)return t;throw new Error("Unable to find step on step with id "+e);case "invocation":if(!e)throw new Error("Unable to have steps on bot invocation without ID");o=t;let r=o.eventsByID[e];if(!r)throw new Error("Unable to find step on invocation with id "+e);if(!r.Step)throw new Error("Unable to find step on invocation with id "+e);return r.Step;case "result_handler":if(!e)throw new Error("Unable to have steps on result handler without ID");let s=t.eventsByID[e];if(!s)throw new Error("Unable to find step on result handler with id "+e);if(!s.Step)throw new Error("Unable to find step on result handler with id "+e);return s.Step;default:throw new Error(`Unable to have steps on entity type ${n}`)}}var Mn=class extends Error{};function Js(t,e,n){let o=null,r=e[0],a=e[1];n[r]=a;try{switch(r){case "message":o=Ln(t,a);break;case "content":o=Qt(t,a);break;case "step":o=zr(t,a);break;case "output":o=Xe(t,a);break;case "output_content":o=Yt(t,a);break;case "invocation":o=Un(t,a);break;case "result_handler":o=Hr(t,a);break}}catch(s){throw console.error("error finding next entity"),console.log("path",e),console.log("currentEntity",t),s}if(!o)throw console.log("path",e),console.log("currentEntity",t),console.log("nextEntity",o),new Mn(`Unable to find next entity for path ${e.join("/")}`);return o}function Kr(t,e,n,o){let r=t.payload;return {_type:"message",message:{id:n,thread_id:e,author_id:r.author_id||"app",author_entity_type:r.author_entity_type||"app",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),role:r.role||"assistant",avatar:"/teams/erdo.svg"},state:"in_progress",contents:[],contentsByID:{},contentIDToIdx:{}}}function js(t,e){return {_type:"message_content",id:t.metadata.message_content_id,message_id:e.message,content_type:t.metadata.content_type,created_by_invocation_id:t.metadata.invocation_id,invocation_id:t.metadata.invocation_id,state:"in_progress",user_visibility:t.metadata.user_visibility??"visible",bot_visibility:t.metadata.bot_visibility??"visible",content:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:t.metadata?.ui_content_type?{String:t.metadata.ui_content_type,Valid:true}:{String:"",Valid:false}}}function Ws(t,e){let n=t.metadata?.ui_content_type,o=typeof t.payload=="string"?t.payload:t.payload.content||t.payload,r=null;if(ae(t.metadata.content_type,n))try{r=ot(o);}catch(a){console.error("Failed to parse message content as JSON:",a),r=[{content:o,type:"text"}];}return {_type:"message_content",id:t.metadata.message_content_id,message_id:e.message,content:o,content_type:t.metadata.content_type,created_by_invocation_id:t.metadata.invocation_id,invocation_id:t.metadata.invocation_id,state:"completed",user_visibility:t.metadata.visibility||"visible",bot_visibility:"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:n?{String:n,Valid:true}:{String:"",Valid:false},parsedJson:r}}function qs(t,e,n){let o=t.payload;return {_type:"step",id:e,invocation_id:n.invocation||"",step_id:o.step_id||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),current_status_id:"",path:{String:"",Valid:false},action_type:{String:o.action_type,Valid:true},key:{String:o.key,Valid:true},bot_id:o.bot_id,result_handler_id:"",step_order:{Int32:o.step_order,Valid:true},output_content_type:{String:o.content_type,Valid:true},execution_mode:{String:o.execution_mode,Valid:true},output_behaviour:{String:o.output_behaviour,Valid:true},user_output_visibility:{String:t.metadata.visibility||"visible",Valid:true},output_channels:o.output_channels||[],running_message:{String:o.running_message||"",Valid:!!o.running_message},finished_message:{String:o.finished_message||"",Valid:!!o.finished_message},depends_on:[],eventsByID:{},currentStatus:null}}function Hs(t,e,n){let o=t.payload;return {_type:"result_handler",id:e,invocation_id:t.metadata.invocation_id||"",result_handler_id:o.result_handler_id||e,step_invocation_id:o.step_invocation_id||"",type:o.type||"",if_conditions:o.if_conditions||{},created_at:new Date().toISOString(),updated_at:new Date().toISOString(),output_content_type:o.output_content_type||"",result_handler_order:o.result_handler_order||0,eventsByID:{}}}function zs(t,e,n){return {_type:"output",id:e,step_id:n.step_id,output:{id:e,invocation_id:t.metadata?.invocation_id,path:t.metadata.path,created_at:new Date().toISOString(),updated_at:new Date().toISOString()},state:"in_progress",contents:[],contentsByID:{},contentIDToIdx:{}}}function Jr(t,e,n,o=null){return {_type:"output_content",id:e,output_id:n.output,content:"",content_type:t.metadata.content_type,state:"in_progress",invocation_id:t.metadata.invocation_id,user_visibility:o??t.metadata.user_visibility??"visible",bot_visibility:t.metadata.bot_visibility??"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:t.metadata.ui_content_type?{String:t.metadata.ui_content_type,Valid:true}:{String:"",Valid:false},output:null}}function jr(t,e,n,o=null){let r=null,a=t.metadata?.ui_content_type;if(ae(t.metadata.content_type,a))try{r=ot(t.payload);}catch(s){console.error("Failed to parse step output content as JSON:",s),r=[{content:t.payload,type:"text"}];}return {_type:"output_content",id:e,output_id:n.output,content:t.payload,content_type:t.metadata.content_type,state:"completed",invocation_id:t.metadata.invocation_id,parsedJson:r,user_visibility:o||t.metadata.visibility||"visible",bot_visibility:"visible",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),content_params:{RawMessage:null,Valid:false},history_content_type:t.metadata?.history_content_type?{String:t.metadata.history_content_type,Valid:true}:{String:"",Valid:false},ui_content_type:a?{String:a,Valid:true}:{String:"",Valid:false},output:null}}function Ks(t,e,n){return {_type:"invocation",bot_invocation:{id:t.payload.invocation_id,bot_id:t.payload.bot_id,bot_name:t.payload.bot_name,created_by_user_id:t.payload.created_by_user_id,current_state_id:"",parent_invocation_id:"",branch_init_state_id:"",current_status_id:"",organization_id:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()},eventsByID:{},currentStatus:null,current_status:null,step_invocations:[],step_invocation_states:[],resources:[],outputs:[],statuses:[]}}function de(t,e){let n=t.payload;return {_type:"status",id:new Date().toISOString(),status:n.status,message:{String:n.message,Valid:true},Details:n}}function Zr(t){return {id:t.id,type:"step",created_at:t.created_at,_type:"invocation_event",Output:null,Message:null,Status:null,ResultHandler:null,Step:t}}function Gn(t){return {id:t.output.id,type:"output",created_at:t.output.created_at,_type:"invocation_event",Output:t,Message:null,Status:null,ResultHandler:null,Step:null}}function Fn(t){return {id:t.id,type:"status",created_at:t.created_at,_type:"invocation_event",Status:t,Output:null,Message:null,ResultHandler:null,Step:null}}function Zs(t){return {id:t.message.id,type:"message",created_at:t.message.created_at,_type:"invocation_event",Output:null,Message:t,Status:null,ResultHandler:null,Step:null}}function Qs(t){return {id:t.id,type:"result_handler",created_at:t.created_at,_type:"invocation_event",Output:null,Message:null,Status:null,ResultHandler:t,Step:null}}var Ys=new Set(["=","("]);function Xs(t){if(!t||t.length===0)return true;let e=t[t.length-1];return !Ys.has(e)}function Jn(t,e){if(t.content||(t.content=""),t.user_visibility!=="visible"||!ae(t.content_type,t.ui_content_type.String))return t.content+=e,{...t};if(t.parsedJson||(t.parsedJson=[]),typeof e=="object")return t.content+=JSON.stringify(e),t.parsedJson=[...t.parsedJson,e],{...t};t._jsonParser||(t._isInJson=false),t._charBuffer||(t._charBuffer="");for(let n of e){if(t.content+=n,!t._isInJson&&n==="{"){let o=t.content.slice(0,-1);if(Xs(o)){t._charBuffer="{";continue}}if(t._charBuffer&&Le(n)){t._charBuffer+=n;continue}if(!t._isInJson&&t._charBuffer?.match(/^\s*{\s*$/)&&n==='"'){t._isInJson=true,t._jsonParser=new ft;let r={content:t._jsonParser.add("{"),type:"json"};t._currentContent?.content?t._currentContent.content.match(/^\s*{$/)?(t._currentContent=r,t.parsedJson=[...t.parsedJson.slice(0,-1),r]):(t._currentContent.content=t._currentContent.content.replace(/{$/,""),t._currentContent=r,t.parsedJson=[...t.parsedJson,r]):(t._currentContent=r,t.parsedJson=[...t.parsedJson,r]);}if(t._isInJson)try{let o=t._jsonParser.add(n);t._currentContent.content=o,t._jsonParser.state==="END"&&(t._isInJson=!1,t._currentContent=void 0);}catch(o){if(console.log("handleIncrementalMixedJsonParsing: content chunk",e),console.log("handleIncrementalMixedJsonParsing: accumulated content",t.content),console.warn("handleIncrementalMixedJsonParsing: JSON parse error, recovering as text",o),t._isInJson=false,t._jsonParser=void 0,t.parsedJson&&t.parsedJson.length>0){let r=t.parsedJson[t.parsedJson.length-1];if(r.type==="json"){let a=t.content.lastIndexOf("{"),s=t.content.slice(a);r.type="text",r.content=s,t._currentContent=r;}}continue}else t._currentContent||(t._currentContent={content:t._charBuffer||"",type:"text"},t.parsedJson=[...t.parsedJson,t._currentContent]),t._currentContent.content+=t._charBuffer+n;t._charBuffer="";}return {...t}}function ti(t,e){return Jn(t,e)}function Wr(t,e){return Jn(t,e)}function $n(t,e){let n=$(t);switch(n){case "message":return st(t,e);case "message_content":return Ye(t,e);case "step":return ni(t,e);case "output":return ri(t,e);case "output_content":return oi(t,e);case "invocation":return pe(t,e);case "result_handler":return ai(t,e);default:throw new Error(`Unable to add update entity for entity type ${n}`)}}function ei(t,e){for(let n of e)t=$n(t,n);return t}function st(t,e){let n=Ln(t);if(!n)throw new Error("Unable to find message to add content to");let o=$(e),r=null;switch(o){case "message_content":if(r=e,!n.contentsByID[r.id])n.contentIDToIdx={...n.contentIDToIdx,[r.id]:n.contents.length},n.contents=[...n.contents,r];else {let i=n.contentIDToIdx[r.id];n.contents=[...n.contents.slice(0,i),r,...n.contents.slice(i+1)];}return n.contentsByID={...n.contentsByID,[r.id]:r},{...n};case "invocation":let a=e;if(n.contents.length===0)throw new Error("Unable to find message content to add invocation to");return r=Ye(n.contents[0],a),st(n,r);case "step":if(n.contents.length===0)throw new Error("Unable to find message content to add content to");if(r=n.contents[0],!r)throw new Error("Unable to find message content to add content to");let s=Un(r);if(!s)throw new Error("Unable to find bot invocation to add content to");return r.botInvocation=pe(s,e),st(n,r);case "status":if(n.contents.length>0){let i=n.contents[0];if(i?.botInvocation){let c=Ye(i,e);return st(n,c)}}return {...n};default:throw new Error(`Unable to add update message child for child type ${o}`)}}function Ye(t,e){let n=Qt(t);if(!n)throw new Error("Unable to find message content to add content to");let o=$(e);switch(o){case "invocation":return n.botInvocation=e,{...n};case "step":let r=n.botInvocation;if(!r)throw new Error("Unable to find bot invocation to add content to");return n.botInvocation=pe(r,e),{...n};case "status":return n.botInvocation&&(n.botInvocation=pe(n.botInvocation,e)),{...n};default:throw new Error(`Unable to add update message content child for child type ${o}`)}}function ni(t,e){let n=zr(t);if(!n)throw new Error("Unable to find bot invocation to add step to");let o=$(e),r=null;switch(o){case "output":let a=e;return r=Gn(a),n.eventsByID={...n.eventsByID,[a.output.id]:r},{...n};case "message":let s=e;return r=Zs(s),n.eventsByID={...n.eventsByID,[s.message.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID={...n.eventsByID,[i.id]:r},{...n};case "result_handler":let c=e;return r=Qs(c),n.eventsByID={...n.eventsByID,[c.id]:r},{...n};default:throw new Error(`Unable to add update step for entity type ${o}`)}}function ri(t,e){let n=Xe(t);if(!n)throw new Error("Unable to find step output to add content to");let o=$(e);switch(o){case "output_content":let r=e;if(!n.contentsByID[r.id])n.contentIDToIdx={...n.contentIDToIdx,[r.id]:n.contents.length},n.contents=[...n.contents,r];else {let a=n.contentIDToIdx[r.id];n.contents=[...n.contents.slice(0,a),r,...n.contents.slice(a+1)];}return n.contentsByID={...n.contentsByID,[r.id]:r},{...n};default:throw new Error(`Unable to add update output for entity type ${o}`)}}function oi(t,e){let n=Yt(t);if(!n)throw new Error("Unable to find step output content to add content to");let o=$(e);switch(o){case "invocation":return n.botInvocation=e,{...n};case "step":let r=n.botInvocation;if(!r)throw new Error("Unable to find bot invocation to add content to");return n.botInvocation=pe(r,e),{...n};default:throw new Error(`Unable to add update step output content for entity type ${o}`)}}function pe(t,e){let n=Un(t);if(!n)throw new Error("Unable to find bot invocation to add content to");let o=$(e),r;switch(o){case "step":let a=e;return r=Zr(a),n.eventsByID={...n.eventsByID,[a.id]:r},{...n};case "output":let s=e;return r=Gn(s),n.eventsByID={...n.eventsByID,[s.output.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID={...n.eventsByID,[i.id]:r},n.currentStatus=i,{...n};default:throw new Error(`Unable to add update invocation for entity type ${o}`)}}function ai(t,e){let n=Hr(t);if(!n)throw new Error("Unable to find result handler to add content to");let o=$(e),r=null;switch(o){case "step":let a=e;return r=Zr(a),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[a.id]:r},{...n};case "output":let s=e;return r=Gn(s),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[s.output.id]:r},{...n};case "status":let i=e;return r=Fn(i),n.eventsByID||(n.eventsByID={}),n.eventsByID={...n.eventsByID,[i.id]:r},{...n};default:throw new Error(`Unable to add update to result handler for entity type ${o}`)}}function si(t){return t==="bot started"||t==="bot resumed"||t==="message created"||t==="create message content"||t==="message content result"||t==="step started"||t==="result handler started"||t==="state created"||t==="step output created"||t==="create step output content"||t==="step output content result"||t==="log"}function tn(t,e,n,o,r,a=null,s=[],i={}){if(!a&&Object.keys(r).length>0){let p,d;if(n.length>=2&&n[0]==="message"?(d=n[1],p=r[d],p||(p=Object.values(r)[0],d=Object.keys(r)[0])):(p=Object.values(r)[Object.values(r).length-1],d=Object.keys(r)[Object.keys(r).length-1]),i.message=d,n.length<=2&&t==="message finished")return null;if(n[0]!=="content"&&Object.keys(p.contentsByID).length>0&&e.metadata.message_content_id){let m=e.metadata.message_content_id,f=p.contentsByID[m];f&&(a=f);}a?s=[p]:a=p;}if(n.length<=2&&si(t)){let p=n[1],d=[],m,f,g,y,x;switch(t){case "bot started":case "bot resumed":if(!a)throw new Error("Unable to find message to add content to");let h=Ks(e);if(a._type==="message_content"){if(f=a,!f.id)throw new Error("Unable to find message content id");if(g=r[f.message_id],!g)throw new Error("Unable to find message to add content to");if(y=Qt(g,f.id),!y)throw new Error("Unable to find message content to add content to");let D=Ye(y,h);r[f.message_id]={...st(g,D)};}d.push(h);break;case "message created":return r[p]=Kr(e,o,p),null;case "create message content":if(!a)throw new Error("Unable to find message to add content to");if(x=js(e,i),a._type==="output"){m=a,d.push(Jr(e,p,i,"hidden"));let D=e.payload.message_id;if(D||(D=s[0].message.id),g=r[D],!g)throw new Error("Unable to find message to add content to")}else if(a._type==="message_content"){if(m=a,g=r[m.message_id],!g)throw new Error("Unable to find message to add content to")}else {if(a._type!=="message")throw new Error(`Incorrect path? Cannot add content to non-message entity: ${a._type}`);if(m=a,g=r[m.message.id],!g)throw new Error("Unable to find message to add content to");d.push(x);}r[g.message.id]={...st(g,x)};break;case "message content result":if(!a)throw new Error("Unable to find message to add content to");let b=null;if(a._type==="output"){d.push(jr(e,p,i,"hidden"));let D=e.payload.message_id||i.message;if(D?b=s.find(I=>I.message.id===D):b=s[0],g=r[D],!g)throw new Error("Unable to find message to add content to")}else if(a._type==="message_content"){if(b=s[0],g=r[b.message.id],!g)throw new Error("Unable to find message to add content to")}else {if(a._type!=="message")throw new Error(`Incorrect path? Cannot add content to non-message entity: ${a._type}`);if(b=a,g=r[b.message.id],!g)throw new Error("Unable to find message to add content to")}let N=e.metadata.message_content_id;if(!N)throw new Error("Unable to find message content id");let v=Qt(b,N);if(v){v.state="completed";let D=typeof e.payload=="string"?e.payload:e.payload.content||e.payload;v.content=D,r[g.message.id]={...st(g,v)},(a._type==="message"||a._type==="message_content")&&d.push(v);}else v=Ws(e,i),r[g.message.id]={...st(g,v)},(a._type==="message"||a._type==="message_content")&&d.push(v);break;case "step started":d.push(qs(e,p,i));break;case "result handler started":d.push(Hs(e,p));break;case "step output created":d.push(zs(e,p,a));break;case "create step output content":d.push(Jr(e,p,i));break;case "step output content result":d.push(jr(e,p,i));break;case "log":return null;default:throw new Error(`Unable to handle create event type ${t}`)}return d.length?!a||a._type==="message_content"&&d.length===1&&d[0]._type==="message_content"?d[0]:ei(a,d):null}if(!a)throw new Error("No first message has been created, so cannot handle amend events");if(n.length<=1){let p=null;try{p=Fs(a);}catch{}switch(t){case "message content delta":if(!p)throw new Error("Unable to find message content");let d=null,m=null,f=null;if(a._type==="output_content"){d=Wr(a,e.payload);let h=e.metadata.message_content_id;if(!h)throw new Error("Unable to find message content id from entity ids");let b=i.message;if(f=s.find(N=>N.message.id===b),!f)throw new Error("Unable to find message to add content to");m=Qt(f,h);}else {if(m=p,f=s[s.length-1],!f)throw new Error("Unable to find message to add content to");if(f._type!=="message")throw new Error("Unable to find message to add content to - not a message")}if(!m)throw new Error("Unable to find message content");let g=r[f.message.id];if(!g)throw new Error("Unable to find message to add content to");let y=ti(m,e.payload);return r[g.message.id]={...st(g,y)},a._type==="message_content"&&(d=y),d;case "step output content delta":return Wr(p,e.payload);case "status":if(a._type==="step"&&(a.currentStatus=de(e)),a._type==="invocation"&&(a.currentStatus=de(e)),a._type==="message_content"){let x=a;if(x.botInvocation)return x.botInvocation.currentStatus=de(e),{...x}}if(a._type==="message"){let x=a,h=qr(x);if(h?.botInvocation)return h.botInvocation.currentStatus=de(e),st(x,h)}return $n(a,de(e));case "result":return null;case "message finished":return null;case "step output finished":return null;case "step result":return null;case "error":return null;case "dataset created":return null;case "log":return null;default:throw new Error(`Unable to handle event type ${t}`)}}let c=n.slice(2),l=Js(a,n,i),u=tn(t,e,c,o,r,l,[...s,a],i);return u?$n(a,{...u}):a}function li(t){return t.split("/").filter(Boolean)}function Yr(t={}){let e=It(),[n,o]=useState(null),[r,a]=useState(false),[s,i]=useState(null),[c,l]=useState([]),u=useRef(null),p=useRef(t.threadId);t.threadId!==p.current&&(p.current=t.threadId);let d=useCallback(()=>{u.current&&(u.current.abort(),u.current=null);},[]),m=useCallback(y=>{o(y),p.current=y.id;},[]),f=useCallback(async y=>{if(!e.client)throw new Error("ErdoClient not configured in provider. Pass a client to ErdoProvider config to use useThread.");if(!e.client.sendMessage)throw new Error("ErdoClient does not support sendMessage. Make sure you are using @erdoai/server client.");if(!e.client.createThread)throw new Error("ErdoClient does not support createThread. Make sure you are using @erdoai/server client.");d(),u.current=new AbortController,a(true),i(null),l([]);let x={};try{let h=p.current;if(!h){let v=await e.client.createThread();o(v),p.current=v.id,h=v.id;}for await(let v of e.client.sendMessage(h,{content:y,botKey:t.botKey})){if(u.current?.signal.aborted)break;t.onEvent?.(v);let D=v.type||"",I=v.metadata||{},B=li(I.path||""),yt={payload:v.payload,metadata:{path:I.path||"",...I}};try{tn(D,yt,B,h,x);}catch(z){console.error("Error handling SSE event:",z,D);}l(Object.values(x));}let b=Object.values(x);l(b);let N=b.flatMap(v=>v.contents||[]).filter(v=>v.user_visibility==="visible").map(v=>({id:v.id,content_type:v.content_type,ui_content_type:T(v.ui_content_type),content:v.content,parsedJson:v.parsedJson,botInvocation:v.botInvocation}));t.onFinish?.(N);}catch(h){let b=h instanceof Error?h:new Error(String(h));throw i(b),t.onError?.(b),b}finally{a(false),u.current=null;}},[e.client,t,d]),g=useMemo(()=>{let y=c.flatMap(b=>b.contents||[]).filter(b=>b.user_visibility==="visible");return Se(y).map(b=>({id:b.id,content_type:b.content_type,ui_content_type:T(b.ui_content_type),content:b.content,parsedJson:b.parsedJson,botInvocation:b.botInvocation}))},[c]);return {thread:n,isStreaming:r,error:s,activeMessages:c,streamingContents:g,sendMessage:f,cancel:d,setThread:m}}export{kt as BarChart,He as BotInvocationContent,et as Chart,ee as ChartContainer,Pe as ChartContent,sn as ChartLegend,ln as ChartLegendContent,bn as ChartNode,Kn as ChartStyle,on as ChartTooltip,an as ChartTooltipContent,qe as CodeexecContent,We as CodegenContent,Ft as CollapsibleCodeBlock,ue as Content,Ce as DatasetChart,$t as DatasetDownload,_e as DatasetTable,_n as DownloadButtonNode,qn as ErdoProvider,Us as ErdoUI,xt as ErrorBoundary,yn as ExecutionStatus,jt as ExpandableOutputContent,At as HeatmapChart,De as InvocationEvent,Mt as InvocationEvents,hr as InvocationStatus,ft as JSONStreamParser,mt as JsonContent,Bt as LineChart,Vn as Loader,Nn as Log,Oe as LogContent,M as MarkdownContent,Ze as MemoryContent,we as Output,Pt as PieChart,Rt as ScatterChart,Ue as SqlContent,vt as StatusSpinner,Wt as StderrText,Fe as StdoutText,Je as StdwarnText,Ee as StepInvocation,Ie as StepInvocationStatus,Sn as SuggestionsNode,Re as TableContent,vn as TableNode,se as TextContent,Cn as TextMarkdownNode,Ae as ThinkingContent,Ht as ToolGroupContent,Lt as UIGenerationNodes,Me as WebParseContent,Ve as WebSearchContent,On as WritingLoader,q as cn,Fr as extractContentItems,tt as formatValue,Jn as handleIncrementalMixedJsonParsing,tn as handleSSEEvent,ae as isJsonLike,dr as isNullString,rs as isParsingComplete,En as isParsingInProgress,Le as isWhitespaceChar,wn as nodeComponents,es as parseCompleteJson,ot as parseMixedJson,Zn as parseToDate,Vt as resolveKeyFromData,or as toSnakeCase,T as unwrapNullString,aa as unwrapNullStringOr,ye as useChartZoom,xe as useDatasetContents,It as useErdoConfig,j as useErdoConfigOptional,ke as useMultipleDatasetContents,Yr as useThread};