@standardagents/builder 0.11.0-next.730b472 → 0.11.0-next.80cee2e

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.
@@ -1,4 +1,4 @@
1
- import{d as re,i as Zt,c as W,t as Io,r as f,w as pe,o as Te,a as Ne,p as Lo,m as Ie,b as l,e as o,f as e,n as lt,g as Ke,h as Ce,u as We,j as Q,k as T,l as Y,q as H,F as he,s as ye,v as M,x as Me,y as ce,z as ot,A as Ze,B as C,R as Vt,C as Ve,T as vt,D as Ge,E as Pe,G as De,H as Eo,I as Ue,L as Kt,J as $t,K as Gt,M as Je,N as Xt,X as Ao,O as dt,P as ht,Q as Po,S as jo,U as xt,V as Mt,W as Oo,Y as It,Z as Uo,_ as Ro,$ as Lt,a0 as Do,a1 as Bo,a2 as No,a3 as Fo,a4 as qo,a5 as Yt,a6 as zo,a7 as Qt,a8 as Ho,a9 as Wo,aa as yt,ab as qe,ac as Xe,ad as Jo,ae as Zo,af as eo,ag as to,ah as Ko,ai as Go,aj as Xo,ak as Yo,al as Qo}from"./vue.js";import{f as ea}from"./vendor.js";import{W as ta,a as oa,e as Et}from"./monaco.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const i of u.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(a){if(a.ep)return;a.ep=!0;const u=n(a);fetch(a.href,u)}})();var oo=class{endpoint;token;constructor(t){this.endpoint=t.replace(/\/$/,""),this.token=typeof localStorage<"u"?localStorage.getItem("agentbuilder_auth_token"):null}getEndpoint(){return this.endpoint}async createThread(t){const s=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`Failed to create thread: ${s.statusText}`);return s.json()}async getThread(t){const s=await fetch(`${this.endpoint}/threads/${t}`,{method:"GET",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to get thread: ${s.statusText}`);return s.json()}async getMessages(t,s={}){const n=new URLSearchParams;s.limit!==void 0&&n.set("limit",String(s.limit)),s.offset!==void 0&&n.set("offset",String(s.offset)),s.depth!==void 0&&n.set("depth",String(s.depth)),s.includeSilent!==void 0&&n.set("includeSilent",String(s.includeSilent));const r=n.toString(),a=`${this.endpoint}/threads/${t}/messages${r?`?${r}`:""}`,u=await fetch(a,{method:"GET",headers:this.getHeaders()});if(!u.ok)throw new Error(`Failed to get messages: ${u.statusText}`);return(await u.json()).messages||[]}async sendMessage(t,s){const n=await fetch(`${this.endpoint}/threads/${t}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Failed to send message: ${n.statusText}`);return n.json()}async stopExecution(t){const s=await fetch(`${this.endpoint}/threads/${t}/stop`,{method:"POST",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to stop execution: ${s.statusText}`);await s.json()}async deleteMessage(t,s){const n=await fetch(`${this.endpoint}/threads/${t}/messages/${s}`,{method:"DELETE",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to delete message: ${n.statusText}`);return n.json()}async uploadFile(t,s,n){const r=encodeURIComponent(s.name),a=`${this.endpoint}/threads/${t}/fs/${r}`;if(n?.thumbnail){const i=await this.fileToBase64(s),p=await fetch(a,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:i,mimeType:s.type,thumbnail:n.thumbnail,metadata:{width:n.width,height:n.height}})});if(!p.ok)throw new Error(`Failed to upload file: ${p.statusText}`);return p.json()}const u=await fetch(a,{method:"POST",headers:{...this.getHeaders(),"Content-Type":s.type},body:s});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const u=r.result.split(",")[1];s(u)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}getFileUrl(t,s){const r=(s.startsWith("/")?s.slice(1):s).split("/").map(a=>encodeURIComponent(a)).join("/");return`${this.endpoint}/threads/${t}/fs/${r}`}getThumbnailUrl(t,s){return`${this.getFileUrl(t,s)}?thumbnail=true`}async listFiles(t){const s=await fetch(`${this.endpoint}/threads/${t}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to list files: ${s.statusText}`);return(await s.json()).files||[]}connectMessageWebSocket(t,s={},n={}){const r=new URLSearchParams;this.token&&r.set("token",this.token),n.includeSilent!==void 0&&r.set("includeSilent",String(n.includeSilent)),n.depth!==void 0&&r.set("depth",String(n.depth));const a=this.endpoint.startsWith("https")?"wss":"ws",i=`${this.endpoint.replace(/^https?/,a)}/threads/${t}/stream?${r.toString()}`,p=new WebSocket(i);return p.onopen=()=>{s.onOpen?.()},p.onmessage=m=>{try{if(typeof m.data=="string"&&m.data==="pong")return;const x=JSON.parse(m.data);switch(x.type){case"message_data":s.onMessage?.(x);break;case"message_chunk":s.onChunk?.(x);break;case"event":s.onEvent?.(x);break;case"error":s.onError?.(x);break}}catch(x){console.error("Failed to parse WebSocket message:",x)}},p.onerror=m=>{console.error("WebSocket error:",m),s.onError?.({type:"error",error:"WebSocket connection error"})},p.onclose=m=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${m.code}, reason: ${m.reason||"none"}, wasClean: ${m.wasClean}`),s.onClose?.()},p}connectLogWebSocket(t,s={}){const n=new URLSearchParams;this.token&&n.set("token",this.token);const r=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,r)}/threads/${t}?${n.toString()}`,i=new WebSocket(u);return i.onopen=()=>{s.onOpen?.()},i.onmessage=p=>{try{if(typeof p.data=="string"&&p.data==="pong")return;const m=JSON.parse(p.data);switch(m.type){case"log_data":s.onLog?.(m);break;case"custom":s.onCustom?.(m);break;case"stopped_by_user":s.onStopped?.(m);break}}catch(m){console.error("Failed to parse WebSocket message:",m)}},i.onerror=p=>{console.error("WebSocket error:",p)},i.onclose=()=>{s.onClose?.()},i}getHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}},aa=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(t,s,n={},r={}){this.client=t,this.threadId=s,this.callbacks=n,this.options={depth:r.depth??0,includeSilent:r.includeSilent??!1,heartbeatInterval:r.heartbeatInterval??3e4,maxReconnectDelay:r.maxReconnectDelay??3e4}}getStatus(){return this.status}getThreadId(){return this.threadId}connect(){this.ws&&this.ws.readyState!==WebSocket.CLOSED||(this.shouldReconnect=!0,this.isReconnecting=!1,this.setStatus("connecting"),this.ws=this.client.connectMessageWebSocket(this.threadId,{onOpen:()=>{this.setStatus("connected"),this.reconnectAttempts=0,this.isReconnecting=!1,this.startHeartbeat()},onMessage:t=>{this.callbacks.onMessage?.(t)},onChunk:t=>{this.callbacks.onChunk?.(t)},onEvent:t=>{this.callbacks.onEvent?.(t)},onError:t=>{this.callbacks.onError?.(t)},onClose:()=>{this.clearTimers(),this.scheduleReconnect()}},{depth:this.options.depth,includeSilent:this.options.includeSilent}))}disconnect(){this.shouldReconnect=!1,this.clearTimers(),this.ws&&(this.ws.close(),this.ws=null),this.reconnectAttempts=0,this.isReconnecting=!1,this.setStatus("disconnected")}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}updateOptions(t){this.options={...this.options,...t}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.onStatusChange?.(t))}startHeartbeat(){this.clearHeartbeat(),this.heartbeatInterval=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("ping")},this.options.heartbeatInterval)}clearHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}clearTimers(){this.clearHeartbeat(),this.clearReconnectTimeout()}scheduleReconnect(){if(!this.shouldReconnect||this.isReconnecting){this.setStatus("disconnected");return}this.isReconnecting=!0,this.setStatus("reconnecting");const t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.options.maxReconnectDelay);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.shouldReconnect&&this.connect()},t)}};function At(t){return t.toLowerCase().startsWith("image/")}var Pt=256;function la(t){return new Promise((s,n)=>{const r=new Image,a=URL.createObjectURL(t);r.onload=()=>{URL.revokeObjectURL(a),s(r)},r.onerror=()=>{URL.revokeObjectURL(a),n(new Error("Failed to load image"))},r.src=a})}function sa(t){const{width:s,height:n}=t,r=s/n;let a,u;r>1?(a=Math.min(Pt,s),u=Math.floor(a/r)):(u=Math.min(Pt,n),a=Math.floor(u*r));const i=document.createElement("canvas");i.width=a,i.height=u;const p=i.getContext("2d");if(!p)throw new Error("Failed to get canvas context");return p.drawImage(t,0,0,a,u),i.toDataURL("image/webp",.8).split(",")[1]}async function na(t){const s=await la(t);return{thumbnail:sa(s),width:s.width,height:s.height}}function ra(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ia(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}var da=class{createPendingFile(t){return{id:ra(),name:t.name,mimeType:t.type,size:t.size,isImage:At(t.type),localPreviewUrl:null,status:"uploading"}}queueFiles(t){return Array.from(t).map(s=>({pending:this.createPendingFile(s),file:s}))}async executeUpload(t,s,n,r,a,u={}){const{generateThumbnail:i=!0,generatePreview:p=!0}=u,m=At(s.type);m&&p&&ia(s).then(x=>a({localPreviewUrl:x})).catch(x=>console.error("Failed to generate preview:",x));try{let x;if(m&&i)try{const v=await na(s);x={thumbnail:v.thumbnail,width:v.width,height:v.height}}catch(v){console.warn("Failed to generate thumbnail:",v)}const d=await r.uploadFile(t,s,x);return a({id:d.id,status:"ready",path:d.path,width:d.width,height:d.height}),d}catch(x){throw a({status:"error",error:x instanceof Error?x.message:"Failed to upload file"}),x}}async executeUploads(t,s,n,r,a={}){const u=s.map(({pending:i,file:p})=>this.executeUpload(t,p,i.id,n,m=>r(i.id,m),a).catch(m=>m instanceof Error?m:new Error(String(m))));return Promise.all(u)}};function ua(t){if(t.length===0)return[];const s=[];let n=0;for(;n<t.length;){const r=t[n];if(r.role==="assistant"&&r.tool_calls){let a;try{a=JSON.parse(r.tool_calls)}catch{s.push(r),n++;continue}const u=[],i=[];let p=r.reasoning_content||null,m="completed";const x=r.id,d=r.created_at,v=r.depth;r.status==="pending"?m="pending":r.status==="failed"&&(m="failed"),r.content&&i.push(r.content);for(const b of a)u.push({id:b.id||r.id,type:"tool_call",name:b.function?.name,content:b.function?.arguments||null,status:null,tool_call_id:b.id});let c=n+1;for(;c<t.length;){const b=t[c];if(b.role==="tool"){const V=b.tool_status||"pending";u.push({id:b.id,type:"tool_result",name:b.name||void 0,content:b.content,status:V,tool_call_id:b.tool_call_id||void 0}),c++}else if(b.role==="assistant"&&b.tool_calls){let V;try{V=JSON.parse(b.tool_calls)}catch{break}b.status==="pending"?m="pending":b.status==="failed"&&m!=="pending"&&(m="failed"),b.content&&i.push(b.content),!p&&b.reasoning_content&&(p=b.reasoning_content);for(const P of V)u.push({id:P.id||b.id,type:"tool_call",name:P.function?.name,content:P.function?.arguments||null,status:null,tool_call_id:P.id});c++}else break}const k=new Set(u.filter(b=>b.type==="tool_call").map(b=>b.tool_call_id)),g=u.filter(b=>b.type==="tool_result"&&b.tool_call_id&&!k.has(b.tool_call_id));for(const b of g){const V=u.indexOf(b),P=b.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",U={id:`synthetic-${b.tool_call_id}`,type:"tool_call",name:P,content:null,status:b.status,tool_call_id:b.tool_call_id};u.splice(V,0,U)}for(const b of u)if(b.type==="tool_call"&&b.tool_call_id&&b.status===null){const V=u.find(P=>P.type==="tool_result"&&P.tool_call_id===b.tool_call_id);V?b.status=V.status:b.status="pending"}const h=i.length>0?i.join(""):null,w={id:x,type:"workblock",content:h,reasoning_content:p,workItems:u,status:m,created_at:d,depth:v};s.push(w),n=c}else s.push(r),n++}return s}var ao=Symbol("StandardAgents"),lo=Symbol("Thread"),ca={install(t,s){if(!s?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const r={client:new oo(s.endpoint),endpoint:s.endpoint};t.provide(ao,r)}};function pa(){const t=Zt(ao);if(!t)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return t}var jt=new da;function ma(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const u=r.result.split(",")[1];s(u)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}function va(t,s={}){const{preload:n=!0,live:r=!0,useWorkblocks:a=!1,depth:u=0,includeSilent:i=!1,endpoint:p}=s,m=W(()=>Io(t)),x=pa(),d=p?new oo(p):x.client,v={preload:n,live:r,useWorkblocks:a,depth:u,includeSilent:i},c=f([]),k=f("disconnected"),g=f(n),h=f(null),w=f([]),b=f([]),V=f([]),P=W(()=>{const I=new Set(b.value.map(ae=>ae.path));return[...w.value.filter(ae=>!ae.path||!I.has(ae.path)),...b.value]}),U=new Map;let q=null;const K=W(()=>a?ua(c.value):c.value);async function R(){g.value=!0,h.value=null;try{const I=await d.getMessages(m.value,{depth:u,includeSilent:i});c.value=I}catch(I){h.value=I instanceof Error?I:new Error(String(I))}finally{g.value=!1}}async function j(){try{const I=await d.listFiles(m.value);b.value=I.filter(ee=>!ee.isDirectory).map(ee=>({id:ee.path,name:ee.name,path:ee.path,mimeType:ee.mimeType,size:ee.size,isImage:ee.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(I){console.error("Failed to load files:",I)}}function Z(I){if(I.file.isDirectory)return;const ee={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ae=b.value.findIndex(me=>me.path===I.path);ae>=0?b.value[ae]=ee:b.value=[...b.value,ee]}function N(I){if(I.file.isDirectory)return;const ee={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ae=b.value.findIndex(me=>me.path===I.path);ae>=0?b.value[ae]=ee:b.value=[...b.value,ee]}function F(I){b.value=b.value.filter(ee=>ee.path!==I.path)}function B(){r&&(q=new aa(d,m.value,{onStatusChange:I=>{k.value=I},onMessage:I=>{if(I.type==="message_data"){const ee=c.value.findIndex(ae=>ae.id===I.data.id);ee>=0?c.value[ee]=I.data:c.value=[...c.value,I.data]}},onChunk:I=>{const ee=c.value.findIndex(ae=>ae.id===I.message_id);if(ee>=0){const ae=c.value[ee];c.value[ee]={...ae,content:(ae.content||"")+I.chunk}}},onEvent:I=>{I.eventType==="file_created"?Z(I.data):I.eventType==="file_updated"?N(I.data):I.eventType==="file_deleted"&&F(I.data);const ee=U.get(I.eventType);ee&&ee.forEach(ae=>{try{ae(I.data)}catch(me){console.error(`Error in event listener for "${I.eventType}":`,me)}})},onError:I=>{h.value=I instanceof Error?I:new Error(String(I))}},{depth:u,includeSilent:i}),q.connect())}async function y(I){const ee=`optimistic-${crypto.randomUUID()}`,ae=V.value.map(fe=>({id:fe.id,type:"file",path:"",name:fe.name,mimeType:fe.mimeType,size:fe.size,width:fe.width,height:fe.height,localPreviewUrl:fe.previewUrl||void 0})),me={id:ee,role:I.role,content:I.content,attachments:ae.length>0?JSON.stringify(ae):null,created_at:Date.now()*1e3,status:"pending"};c.value=[...c.value,me];const $e=[...V.value];V.value=[];try{const fe=await Promise.all($e.map(async we=>({name:we.name,mimeType:we.mimeType,data:await ma(we.file),width:we.width,height:we.height}))),ke=await d.sendMessage(m.value,{...I,attachments:fe.length>0?fe:void 0});return c.value=c.value.filter(we=>we.id!==ee),$e.forEach(we=>{we.previewUrl&&URL.revokeObjectURL(we.previewUrl)}),ke}catch(fe){throw V.value=$e,c.value=c.value.filter(ke=>ke.id!==ee),h.value=fe instanceof Error?fe:new Error(String(fe)),fe}}async function $(){try{await d.stopExecution(m.value)}catch(I){throw h.value=I instanceof Error?I:new Error(String(I)),I}}async function E(I){const ee=[...c.value];c.value=c.value.filter(ae=>ae.id!==I);try{await d.deleteMessage(m.value,I)}catch(ae){throw c.value=ee,h.value=ae instanceof Error?ae:new Error(String(ae)),ae}}function _(I){const ee=jt.queueFiles(I);w.value=[...w.value,...ee.map(ae=>ae.pending)];for(const{pending:ae,file:me}of ee)jt.executeUpload(m.value,me,ae.id,d,$e=>{w.value=w.value.map(fe=>fe.id===ae.id?{...fe,...$e}:fe)}).catch(()=>{})}function S(I){w.value=w.value.filter(ee=>ee.id!==I)}function L(I){return I.path?d.getFileUrl(m.value,I.path):""}function J(I){return I.path?d.getThumbnailUrl(m.value,I.path):""}function X(I){return I.isImage?I.localPreviewUrl?I.localPreviewUrl:I.path?J(I):null:null}function G(I){const ae=(I instanceof FileList?Array.from(I):Array.isArray(I)?I:[I]).map(me=>{const $e=me.type.startsWith("image/");return{id:crypto.randomUUID(),file:me,name:me.name,mimeType:me.type,size:me.size,isImage:$e,previewUrl:$e?URL.createObjectURL(me):null}});V.value=[...V.value,...ae]}function D(I){const ee=V.value.find(ae=>ae.id===I);ee?.previewUrl&&URL.revokeObjectURL(ee.previewUrl),V.value=V.value.filter(ae=>ae.id!==I)}function O(){V.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)}),V.value=[]}function A(I,ee){return U.has(I)||U.set(I,new Set),U.get(I).add(ee),()=>{const ae=U.get(I);ae&&(ae.delete(ee),ae.size===0&&U.delete(I))}}function de(){q?.disconnect(),q=null,k.value="disconnected"}return pe(m,(I,ee)=>{I!==ee&&(de(),c.value=[],h.value=null,w.value=[],b.value=[],V.value.forEach(ae=>{ae.previewUrl&&URL.revokeObjectURL(ae.previewUrl)}),V.value=[],n&&R(),j(),B())}),Te(()=>{n&&R(),j(),B()}),Ne(()=>{q?.disconnect(),U.clear(),V.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)})}),{threadId:m,options:v,messages:c,workblocks:K,status:k,connectionStatus:k,isLoading:g,loading:g,error:h,sendMessage:y,stopExecution:$,deleteMessage:E,onEvent:A,subscribeToEvent:A,files:P,addFiles:_,removeFile:S,getFileUrl:L,getThumbnailUrl:J,getPreviewUrl:X,attachments:V,addAttachment:G,removeAttachment:D,clearAttachments:O}}var ha=re({name:"ThreadProvider",props:{threadId:{type:String,required:!0},preload:{type:Boolean,default:void 0},live:{type:Boolean,default:void 0},useWorkblocks:{type:Boolean,default:void 0},depth:{type:Number,default:void 0},includeSilent:{type:Boolean,default:void 0},endpoint:{type:String,default:void 0}},setup(t,{slots:s}){const n={};t.preload!==void 0&&(n.preload=t.preload),t.live!==void 0&&(n.live=t.live),t.useWorkblocks!==void 0&&(n.useWorkblocks=t.useWorkblocks),t.depth!==void 0&&(n.depth=t.depth),t.includeSilent!==void 0&&(n.includeSilent=t.includeSilent),t.endpoint!==void 0&&(n.endpoint=t.endpoint);const r=va(()=>t.threadId,n);return Lo(lo,r),()=>s.default?.()}});function so(){const t=Zt(lo);if(!t)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return t}const fa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ga(t,s){return o(),l("svg",fa,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 8V4H8"}),e("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const Ot=Ie({name:"lucide-bot",render:ga}),ba={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xa(t,s){return o(),l("svg",ba,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const Ut=Ie({name:"lucide-message-square",render:xa}),ya={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ka(t,s){return o(),l("svg",ya,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),e("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),e("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const wa=Ie({name:"lucide-cpu",render:ka}),_a={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $a(t,s){return o(),l("svg",_a,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Ca=Ie({name:"lucide-server",render:$a}),Sa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ta(t,s){return o(),l("svg",Sa,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Va=Ie({name:"lucide-wrench",render:Ta}),Ma={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ia(t,s){return o(),l("svg",Ma,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const La=Ie({name:"lucide-settings",render:Ia}),Ea={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Aa(t,s){return o(),l("svg",Ea,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Pa=Ie({name:"lucide-chevron-left",render:Aa}),ja={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Oa(t,s){return o(),l("svg",ja,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"4"}),e("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const Ua=Ie({name:"lucide-sun",render:Oa}),Ra={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Da(t,s){return o(),l("svg",Ra,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const Ba=Ie({name:"lucide-moon",render:Da}),Na={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fa(t,s){return o(),l("svg",Na,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const qa=Ie({name:"lucide-activity",render:Fa}),za={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ha(t,s){return o(),l("svg",za,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const Wa=Ie({name:"lucide-function-square",render:Ha}),Ja={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Za(t,s){return o(),l("svg",Ja,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const Ka=Ie({name:"lucide-log-out",render:Za}),Ga={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Xa(t,s){return o(),l("svg",Ga,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),e("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const Ya=Ie({name:"lucide-users",render:Xa}),Qa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function el(t,s){return o(),l("svg",Qa,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),e("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const tl=Ie({name:"lucide-key",render:el}),ol={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function al(t,s){return o(),l("svg",ol,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 7v14m-9-3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4a4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3a3 3 0 0 0-3-3z"},null,-1)])])}const ll=Ie({name:"lucide-book-open",render:al}),sl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nl(t,s){return o(),l("svg",sl,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null,-1)])])}const rl=Ie({name:"lucide-external-link",render:nl}),no="agentbuilder-accent-theme",ro=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],kt=f("purple");let Rt=!1;function io(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function il(t){try{localStorage.setItem(no,t)}catch{}}function dl(){try{const t=localStorage.getItem(no);if(t&&ro.includes(t))return t}catch{}return"purple"}function uo(){if(Rt)return;Rt=!0;const t=dl();kt.value=t,io(t)}function ul(){uo();function t(s){kt.value=s,io(s),il(s)}return{theme:kt,themes:ro,setTheme:t}}const Ye=re({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const s=t,n=f(),r=f(),a=f(),u=f(0),i=(d,v,c,k,g,h)=>{d.beginPath(),d.moveTo(v+h,c),d.lineTo(v+k-h,c),d.quadraticCurveTo(v+k,c,v+k,c+h),d.lineTo(v+k,c+g-h),d.quadraticCurveTo(v+k,c+g,v+k-h,c+g),d.lineTo(v+h,c+g),d.quadraticCurveTo(v,c+g,v,c+g-h),d.lineTo(v,c+h),d.quadraticCurveTo(v,c,v+h,c),d.closePath()},p=async()=>{if(await Ce(),!n.value||!r.value||!a.value)return;const d=n.value.getContext("2d");if(!d)return;const v=a.value.getBoundingClientRect(),c=a.value.firstElementChild;if(c){const w=getComputedStyle(c);u.value=parseFloat(w.borderRadius)||0}const k=v.width+s.offsetX+4,g=v.height+s.offsetY+4;n.value.width=k,n.value.height=g,n.value.style.width=`${k}px`,n.value.style.height=`${g}px`,d.clearRect(0,0,n.value.width,n.value.height);const h=document.documentElement.classList.contains("dark");if(d.fillStyle=h?"#6b7280":"black",d.globalAlpha=s.intensity,d.save(),i(d,s.offsetX,s.offsetY,v.width,v.height,u.value),d.clip(),s.pattern==="crosshatch"){const w=h?4:3;d.lineWidth=1,d.strokeStyle=h?"#6b7280":"black";for(let b=-v.height;b<v.width;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY),d.lineTo(s.offsetX+b+v.height,s.offsetY+v.height),d.stroke();for(let b=0;b<v.width+v.height;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY+v.height),d.lineTo(s.offsetX+b-v.height,s.offsetY),d.stroke()}else if(s.pattern==="dots"){const b=h?3:2,V=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let P=0;P<v.width;P+=b)for(let U=0;U<v.height;U+=b){const q=Math.floor(P/b)%4,K=Math.floor(U/b)%4;V[K][q]/16<s.intensity&&d.fillRect(s.offsetX+P,s.offsetY+U,1,1)}}else if(s.pattern==="diagonal"){const w=h?5:4;d.lineWidth=1,d.strokeStyle=h?"#6b7280":"black";for(let b=-v.height;b<v.width;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY),d.lineTo(s.offsetX+b+v.height,s.offsetY+v.height),d.stroke()}d.restore()};let m=null,x=null;return Te(()=>{m=new ResizeObserver(()=>{p()}),a.value&&m.observe(a.value),p(),x=new MutationObserver(()=>{p()}),x.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Ne(()=>{a.value&&m&&m.unobserve(a.value),x&&x.disconnect()}),pe(()=>[s.offsetX,s.offsetY,s.intensity,s.pattern],()=>{p()}),(d,v)=>(o(),l("div",{ref_key:"container",ref:r,class:"relative",style:lt({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:n,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:a,class:"relative"},[Ke(d.$slots,"default")],512)],4))}}),co="/agents/assets/img/agent-builder-logo-light.svg",po="/agents/assets/img/agent-builder-logo-dark.svg",cl="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(31,41,55);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(31,41,55);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",pl="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(249,250,251);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(249,250,251);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function ml(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function at(){return ml().mountPoint}function le(t){const s=at(),n=t.startsWith("/")?t:`/${t}`;return s==="/"?n:`${s}${n}`}const vl=["src"],hl=["src"],fl={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},gl={class:"flex flex-col gap-1 px-2"},bl={key:0},xl=["onClick","title"],yl={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},kl={key:0,class:"ml-4 space-y-0.5"},wl=["onClick"],_l={class:"whitespace-nowrap overflow-hidden text-ellipsis"},$l=["onClick","title"],Cl={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Sl={class:"flex flex-col gap-1 px-2"},Tl=["title"],Vl={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Ml={class:"relative settings-menu-container"},Il={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Ll={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg py-2 min-w-[200px]"},El={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Al=["title"],Pl={class:"relative z-10 flex items-center justify-center w-8 h-full"},jl={class:"relative z-10 flex items-center justify-center w-8 h-full"},Ol={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Ul={class:"grid grid-cols-5 gap-3"},Rl=["onClick","title"],Dl={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Bl={key:0,class:"text-sm overflow-hidden whitespace-nowrap max-w-0 group-hover:max-w-[60px] group-hover:ml-2 transition-all duration-200"},Nl=re({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:s}){function n(F){if(F.startsWith("/src/")||F.startsWith("data:"))return F;const B=at();return B==="/"?F.replace("/agents/","/"):F.replace("/agents/",`${B}/`)}const r=n(co),a=n(po),u=n(cl),i=n(pl),p=t,m=We(),x=ot(),d=W(()=>m.name);function v(F){const B=m.path;return B===F.path||B.startsWith(F.path+"/")}const c=W(()=>p.isDark?a:r),k=W(()=>p.isDark?i:u),g=[{id:"threads",label:"Threads",icon:qa,path:"/threads"},{id:"agents",label:"Agents",icon:Ot,path:"/agents"},{id:"prompts",label:"Prompts",icon:Ut,path:"/prompts"},{id:"tools",label:"Tools",icon:Va,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Wa,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Ut,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:Ot,path:"/tools#agents"}]},{id:"models",label:"Models",icon:wa,path:"/models"},{id:"providers",label:"Providers",icon:Ca,path:"/providers"}],h=F=>{x.push(F)},w=F=>{x.push(F),V.value=!1},b=W(()=>typeof d.value=="string"&&(d.value==="tools"||d.value.startsWith("tools-"))),V=f(!1),{theme:P,themes:U,setTheme:q}=ul(),K={amber:"bg-amber-500",lime:"bg-lime-500",emerald:"bg-emerald-500",sky:"bg-sky-500",blue:"bg-blue-500",indigo:"bg-indigo-500",purple:"bg-purple-500",fuchsia:"bg-fuchsia-500",pink:"bg-pink-500",white:"bg-neutral-400 dark:bg-neutral-500"},R=W(()=>d.value==="users"||d.value==="api-keys"),j=()=>{V.value=!V.value},Z=()=>{localStorage.removeItem("auth_token"),x.push("/login")},N=F=>{const B=F.target;V.value&&!B.closest(".settings-menu-container")&&(V.value=!1)};return Te(()=>{document.addEventListener("click",N)}),Ne(()=>{document.removeEventListener("click",N)}),(F,B)=>(o(),l("aside",{class:Q(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:Q(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?T("",!0):(o(),l("img",{key:0,src:c.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,vl)),e("button",{onClick:B[0]||(B[0]=y=>F.$emit("toggle-sidebar")),class:Q(`p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors ${t.isCollapsed?"m-auto":"border border-black/20 dark:border-white/20 opacity-50 hover:opacity-100"}`),"aria-label":"Toggle sidebar"},[t.isCollapsed?(o(),l("img",{key:1,src:k.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,hl)):(o(),Y(H(Pa),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",fl,[e("div",gl,[(o(),l(he,null,ye(g,y=>(o(),l(he,{key:y.id},[y.hasSubnav?(o(),l("div",bl,[e("button",{onClick:$=>h(y.path),class:Q(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",b.value?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),Y(Ze(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?T("",!0):(o(),l("span",yl,C(y.label),1))],10,xl),!t.isCollapsed&&y.subnav?(o(),l("div",kl,[(o(!0),l(he,null,ye(y.subnav,$=>(o(),l("button",{key:$.id,onClick:E=>h($.path),class:Q(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",d.value===$.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(o(),Y(Ze($.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",_l,C($.label),1)],10,wl))),128))])):T("",!0)])):(o(),l("button",{key:1,onClick:$=>h(y.path),class:Q(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",v(y)?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),Y(Ze(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?T("",!0):(o(),l("span",Cl,C(y.label),1))],10,$l))],64))),64))]),e("div",Sl,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:Q(["flex items-center gap-3 px-3 py-2 rounded text-sm transition-all","hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?"Documentation":void 0},[M(H(ll),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?T("",!0):(o(),l("span",Vl," Docs ")),t.isCollapsed?T("",!0):(o(),Y(H(rl),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Tl),e("div",{class:Q(["flex items-center gap-1 pt-2 mt-1 border-t border-black/10 dark:border-white/10",t.isCollapsed?"flex-col":"justify-between"])},[e("div",Ml,[e("button",{onClick:Me(j,["stop"]),class:Q(["p-2 rounded transition-colors flex items-center",V.value||R.value?"bg-black/10 dark:bg-white/10 text-black dark:text-white":"hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white"]),title:"Settings"},[M(H(La),{class:"w-5 h-5 flex-shrink-0"})],2),V.value?(o(),l("div",Il,[M(Ye,{"offset-x":6,"offset-y":6,intensity:.4},{default:ce(()=>[e("div",Ll,[e("div",El,[B[4]||(B[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:B[1]||(B[1]=Me(y=>F.$emit("toggle-theme"),["stop"])),class:"relative flex items-center h-7 rounded-full bg-neutral-200 dark:bg-neutral-800 hover:bg-neutral-300 dark:hover:bg-neutral-700 transition-colors",title:t.isDark?"Switch to light mode":"Switch to dark mode"},[e("span",{class:Q(["absolute top-0.5 h-6 w-8 rounded-full bg-white dark:bg-black shadow-sm transition-transform duration-200",t.isDark?"translate-x-[calc(100%-2px)]":"translate-x-0.5"])},null,2),e("span",Pl,[M(H(Ua),{class:Q(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",jl,[M(H(Ba),{class:Q(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Al)]),e("div",Ol,[B[5]||(B[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Ul,[(o(!0),l(he,null,ye(H(U),y=>(o(),l("button",{key:y,onClick:Me($=>H(q)(y),["stop"]),class:Q(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[K[y],H(P)===y?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:y.charAt(0).toUpperCase()+y.slice(1)},[H(P)===y?(o(),l("span",Dl)):T("",!0)],10,Rl))),128))])]),e("button",{onClick:B[2]||(B[2]=y=>w("/settings/users")),class:Q(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[M(H(Ya),{class:"w-4 h-4 flex-shrink-0"}),B[6]||(B[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:B[3]||(B[3]=y=>w("/settings/api-keys")),class:Q(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[M(H(tl),{class:"w-4 h-4 flex-shrink-0"}),B[7]||(B[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])]),_:1})])):T("",!0)]),e("button",{onClick:Z,class:"group p-2 rounded hover:bg-red-500/10 transition-colors text-neutral-600 dark:text-neutral-400 hover:text-red-600 dark:hover:text-red-400 flex items-center",title:"Logout"},[M(H(Ka),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?T("",!0):(o(),l("span",Bl,"Logout"))])],2)])])],2))}}),Fl={class:"warning-banner-container"},ql={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},zl={class:"flex items-center gap-2"},Hl=["onClick"],Wl=re({__name:"WarningBanner",setup(t){const s=f([]),n=f(new Set),r=async()=>{if(localStorage.getItem("auth_token"))try{const m=await fetch(le("/api/diagnostics"));if(m.ok){const x=await m.json();s.value=x.warnings||[]}}catch{}},a=p=>{const m=`${p.type}:${p.details?.name||p.message}`;n.value.add(m)},u=p=>{const m=`${p.type}:${p.details?.name||p.message}`;return!n.value.has(m)},i=p=>{if(p.type==="duplicate_tool_name"){const m=p.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${p.details?.name}" (defined as both ${m}). This may cause unexpected behavior.`}return p.message};return Te(()=>{r()}),(p,m)=>(o(),l("div",Fl,[(o(!0),l(he,null,ye(s.value,x=>(o(),l(he,{key:`${x.type}:${x.details?.name}`},[u(x)?(o(),l("div",ql,[e("div",zl,[m[0]||(m[0]=e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),e("span",null,C(i(x)),1)]),e("button",{onClick:d=>a(x),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...m[1]||(m[1]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,Hl)])):T("",!0)],64))),128))]))}}),Jl={key:2,class:"flex-1 overflow-auto my-3 mr-4 border border-neutral-300 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 flex flex-col"},Zl={class:"flex-1 overflow-auto"},Kl=re({__name:"App",setup(t){uo();const s=We(),n=f(!1),r=f(!1),a=W(()=>s.name!=="login"),u=()=>{n.value=!n.value},i=()=>{r.value=!r.value,r.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Te(()=>{const p=localStorage.getItem("theme");(p==="dark"||!p&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(r.value=!0,document.documentElement.classList.add("dark"))}),(p,m)=>(o(),l("div",{class:Q(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":r.value}])},[a.value?(o(),Y(Nl,{key:0,"is-collapsed":n.value,"is-dark":r.value,onToggleSidebar:u,onToggleTheme:i},null,8,["is-collapsed","is-dark"])):T("",!0),a.value?(o(),l("main",Jl,[M(Wl),e("div",Zl,[M(H(Vt))])])):(o(),Y(H(Vt),{key:1}))],2))}}),Qe=(t,s)=>{const n=t.__vccOpts||t;for(const[r,a]of s)n[r]=a;return n},Gl=Qe(Kl,[["__scopeId","data-v-2125e5d3"]]),Xl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yl(t,s){return o(),l("svg",Xl,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const Ql=Ie({name:"lucide-trash-2",render:Yl}),es={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ts(t,s){return o(),l("svg",es,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const os=Ie({name:"lucide-edit",render:ts}),as={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ls(t,s){return o(),l("svg",as,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const wt=Ie({name:"lucide-eye",render:ls}),ss={class:"w-full"},ns={class:"border border-black dark:border-neutral-300 rounded overflow-hidden"},rs={class:"overflow-x-auto"},is={class:"w-full"},ds={class:"border-b border-black dark:border-neutral-300"},us={key:0,class:"px-4 py-3 text-right font-medium text-sm"},cs={key:0},ps=["colspan"],ms={key:1},vs=["colspan"],hs=["innerHTML"],fs={key:0,class:"px-4 py-3 text-right"},gs={class:"inline-flex gap-1"},bs=["onClick","title"],He=re({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1}},setup(t){const s=u=>{switch(u){case"edit":return os;case"delete":return Ql;case"view":return wt;default:return null}},n=(u,i)=>{const p=u[i.key];return i.formatter?i.formatter(p):p??"-"},r=u=>{switch(u){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},a=(u,i)=>{if(u.confirm){const p=u.confirmMessage||`Are you sure you want to ${u.label.toLowerCase()}?`;confirm(p)&&u.handler(i)}else u.handler(i)};return(u,i)=>(o(),l("div",ss,[e("div",ns,[e("div",rs,[e("table",is,[e("thead",ds,[e("tr",null,[(o(!0),l(he,null,ye(t.columns,p=>(o(),l("th",{key:p.key,class:Q(["px-4 py-3 font-medium text-sm",r(p.align),p.width||""])},C(p.label),3))),128)),t.actions&&t.actions.length>0?(o(),l("th",us," Actions ")):T("",!0)])]),e("tbody",null,[t.loading?(o(),l("tr",cs,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},[...i[0]||(i[0]=[e("div",{class:"inline-flex items-center gap-2"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),Ve(" Loading... ")],-1)])],8,ps)])):t.data.length===0?(o(),l("tr",ms,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},C(t.emptyMessage),9,vs)])):(o(!0),l(he,{key:2},ye(t.data,(p,m)=>(o(),l("tr",{key:m,class:"border-t border-neutral-200 dark:border-neutral-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(o(!0),l(he,null,ye(t.columns,x=>(o(),l("td",{key:x.key,class:Q(["px-4 py-3 text-sm",r(x.align)])},[Ke(u.$slots,`cell-${x.key}`,{value:p[x.key],row:p,column:x},()=>[x.html?(o(),l("span",{key:0,innerHTML:n(p,x)},null,8,hs)):(o(),l(he,{key:1},[Ve(C(n(p,x)),1)],64))])],2))),128)),t.actions&&t.actions.length>0?(o(),l("td",fs,[e("div",gs,[(o(!0),l(he,null,ye(t.actions,(x,d)=>(o(),l("button",{key:d,onClick:v=>a(x,p),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:x.label},[(o(),Y(Ze(s(x.icon)),{class:"w-4 h-4"}))],8,bs))),128))])])):T("",!0)]))),128))])])])])]))}}),xs=re({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(t,{expose:s,emit:n}){const r=n,a=f([]),u=f(!1),i=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:d=>d==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:d=>d||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:d=>d||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:d=>r("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await x(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],m=async()=>{u.value=!0;try{const d=await fetch(le("/api/agents"));if(d.ok){const v=await d.json();a.value=v.agents||[]}}catch(d){console.error("Error fetching agents:",d)}finally{u.value=!1}},x=async d=>{try{const v=await fetch(le(`/api/agents/${d.id}`),{method:"DELETE"});if(v.ok)await m();else{const c=await v.json();alert(c.error||"Failed to delete agent")}}catch(v){console.error("Error deleting agent:",v),alert("Failed to delete agent")}};return Te(()=>{m()}),s({refresh:m}),(d,v)=>(o(),l("div",null,[M(He,{columns:i,data:a.value,actions:p,loading:u.value,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])]))}}),ys={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ks(t,s){return o(),l("svg",ys,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const mo=Ie({name:"lucide-x",render:ks}),ws={key:0,class:"w-full max-w-md"},_s={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},$s={class:"text-xl font-bold text-red-600"},Cs={class:"p-6"},Ss={class:"text-neutral-700 dark:text-neutral-300 mb-6"},Ts={class:"flex justify-end gap-3"},vo=re({__name:"ConfirmDialog",props:{modelValue:{type:Boolean},title:{default:"Confirm Action"},message:{default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{default:"Continue"},cancelText:{default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(t,{emit:s}){const n=t,r=s,a=()=>{r("update:modelValue",!1)},u=()=>{r("confirm"),a()},i=()=>{r("cancel"),a()},p=m=>{m.key==="Escape"&&n.modelValue&&i()};return pe(()=>n.modelValue,m=>{m?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")}),(m,x)=>(o(),Y(vt,{to:"body"},[M(Ge,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:i},[M(Ge,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ce(()=>[t.modelValue?(o(),l("div",ws,[M(Ye,{"offset-x":12,"offset-y":12,intensity:.4},{default:ce(()=>[e("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:x[0]||(x[0]=Me(()=>{},["stop"]))},[e("div",_s,[e("h2",$s,C(t.title),1),e("button",{onClick:i,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[M(H(mo),{class:"w-5 h-5 text-red-600"})])]),e("div",Cs,[e("p",Ss,C(t.message),1),e("div",Ts,[e("button",{onClick:i,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors"},C(t.cancelText),1),e("button",{onClick:u,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},C(t.confirmText),1)])])])]),_:1})])):T("",!0)]),_:1})])):T("",!0)]),_:1})]))}}),Vs={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-neutral-300 flex-shrink-0"},Ms={class:"text-xl font-bold"},Is={class:"overflow-y-auto flex-1"},Ls={class:"p-6"},Es={key:0,class:"p-6 border-t-2 border-black dark:border-neutral-300 flex-shrink-0"},Be=re({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0}},emits:["update:modelValue","close"],setup(t,{emit:s}){const n=t,r=s,a=f(),u=f(!1),i=f(new Map),p=()=>a.value&&(a.value.querySelector("input")||a.value.querySelector("textarea")||a.value.querySelector("select")||a.value.querySelector("[contenteditable]")||a.value.querySelector(".monaco-editor")),m=()=>{if(!a.value)return;a.value.querySelectorAll(".monaco-editor-container").forEach(U=>{const q=U.__monacoEditor;if(q&&typeof q.getValue=="function"){const K=q.getValue();i.value.set(U,K)}})},x=()=>{if(!a.value)return!1;const P=a.value.querySelectorAll(".monaco-editor-container");for(const U of P){const q=U.__monacoEditor;if(q&&typeof q.getValue=="function"){const K=q.getValue(),R=i.value.get(U);if(R===void 0||(q.getRawOptions?.()||{}).readOnly===!0)continue;if(K!==R)return!0}}return!1},d=()=>{if(n.hasChanges!==void 0)return n.hasChanges;if(!a.value)return!1;if(x())return!0;const P=a.value.querySelectorAll("form");for(const q of P){const R=q.querySelectorAll("input, textarea, select");for(const j of R){const Z=j;if(Z.type==="checkbox"||Z.type==="radio"){const N=Z;if(N.checked!==N.defaultChecked)return!0}else if(Z.tagName==="SELECT"){const N=Z;if(N.value!==N.defaultValue)return!0}else if(Z.value!==Z.defaultValue)return!0}}const U=a.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const q of U){const K=q;if(K.type==="checkbox"||K.type==="radio"){const R=K;if(R.checked!==R.defaultChecked)return!0}else if(K.tagName==="SELECT"){const R=K;if(R.value!==R.defaultValue)return!0}else if(K.value!==K.defaultValue)return!0}return!1},v=()=>{p()&&d()?u.value=!0:c()},c=()=>{r("update:modelValue",!1),r("close")},k=()=>{u.value=!1,c()},g=()=>{u.value=!1},h=P=>{P.key==="Escape"&&n.modelValue&&(p()||c())};pe(()=>n.modelValue,async P=>{P?(document.addEventListener("keydown",h),document.body.style.overflow="hidden",await Ce(),setTimeout(()=>{m()},100)):(document.removeEventListener("keydown",h),document.body.style.overflow="",i.value.clear())});const w=f(!1),b=P=>{w.value=P.target===P.currentTarget},V=P=>{P.target===P.currentTarget&&w.value&&(p()||c()),w.value=!1};return(P,U)=>(o(),Y(vt,{to:"body"},[M(Ge,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:b,onClick:V},[M(Ge,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:Q(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[M(Ye,{"offset-x":12,"offset-y":12,intensity:.4},{default:ce(()=>[e("div",{ref_key:"modalRef",ref:a,class:Q(["bg-white dark:bg-black border-2 border-black dark:border-neutral-300 flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Vs,[e("h2",Ms,C(t.title),1),e("button",{onClick:v,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[M(H(mo),{class:"w-5 h-5"})])]),e("div",Is,[e("div",Ls,[Ke(P.$slots,"default")])]),P.$slots.footer?(o(),l("div",Es,[Ke(P.$slots,"footer")])):T("",!0)],2)]),_:3})],2)):T("",!0)]),_:3})],32)):T("",!0)]),_:3}),M(vo,{modelValue:u.value,"onUpdate:modelValue":U[0]||(U[0]=q=>u.value=q),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:k,onCancel:g},null,8,["modelValue"])]))}}),As={class:"space-y-1.5"},Ps={key:0,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},js={key:0,class:"text-red-500"},Os=["type","value","placeholder","disabled"],Us={key:1,class:"text-xs text-red-500 dark:text-red-400"},Ee=re({__name:"TextInput",props:{modelValue:{},label:{},placeholder:{},type:{default:"text"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","click"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(null),i=W(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors placeholder:text-neutral-400 dark:placeholder:text-neutral-500",r.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",r.disabled?"opacity-50 cursor-not-allowed":""]),p=d=>{const v=d.target;a("update:modelValue",v.value)},m=d=>{a("focus",d)},x=d=>{a("click",d)};return s({inputRef:u}),(d,v)=>(o(),l("div",As,[t.label?(o(),l("label",Ps,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",js,"*")):T("",!0)])):T("",!0),e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:Q(i.value),onInput:p,onFocus:m,onClick:x},null,42,Os),t.error?(o(),l("p",Us,C(t.error),1)):T("",!0)]))}}),Rs={class:"space-y-1"},Ds={key:0,class:"block text-sm font-medium"},Bs={key:0,class:"text-red-500"},Ns=["value","placeholder","disabled","rows"],Fs={key:1,class:"text-xs text-red-500 dark:text-red-400"},ho=re({__name:"TextareaInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{default:4}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50 cursor-not-allowed":""]),u=i=>{const p=i.target;r("update:modelValue",p.value)};return(i,p)=>(o(),l("div",Rs,[t.label?(o(),l("label",Ds,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",Bs,"*")):T("",!0)])):T("",!0),e("textarea",{value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,class:Q(a.value),onInput:u},null,42,Ns),t.error?(o(),l("p",Fs,C(t.error),1)):T("",!0)]))}}),qs={key:0,class:"block text-sm font-medium mb-2"},zs={key:0,class:"text-red-500"},Hs=["disabled","aria-expanded"],Ws={class:"flex items-center justify-between gap-1"},Js={key:0,class:"flex items-center gap-2 text-neutral-400 flex-1 min-w-0"},Zs={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},Ks=["src","alt"],Gs={class:"block truncate"},Xs={key:2,class:"block truncate text-neutral-400 flex-1 min-w-0"},Ys={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},Qs={class:"p-2 border-b border-neutral-200 dark:border-neutral-700"},en=["placeholder"],tn={class:"max-h-60 overflow-y-auto"},on={key:0,class:"px-4 py-3 text-sm text-neutral-500 dark:text-neutral-400"},an=["onClick","onMouseenter"],ln={class:"flex-shrink-0 w-5 h-5 mt-0.5"},sn=["src","alt"],nn={key:1,class:"w-full h-full bg-neutral-200 dark:bg-neutral-700 rounded"},rn={class:"flex-1 min-w-0"},dn={class:"text-sm font-medium text-black dark:text-white"},un={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},cn={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"},_e=re({__name:"SelectInput",props:{modelValue:{},options:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},label:{},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},error:{},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=f(!1),u=f(""),i=f(),p=f(),m=f(),x=f(),d=f(-1),v=W(()=>n.options.find(j=>j.value===n.modelValue)),c=W(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",n.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-neutral-300 focus:ring-black dark:focus:ring-white"]),k=W(()=>{if(!u.value)return n.options;const j=u.value.toLowerCase();return n.options.filter(Z=>Z.label.toLowerCase().includes(j)||Z.value.toLowerCase().includes(j)||Z.description&&Z.description.toLowerCase().includes(j))});pe(k,()=>{d.value=-1});const g=()=>{n.disabled||(a.value?b():(a.value=!0,u.value="",d.value=-1,Ce(()=>{if(x.value&&(x.value.setAttribute("popover","auto"),x.value.addEventListener("toggle",R),"showPopover"in x.value))try{x.value.showPopover()}catch{}V(),setTimeout(()=>i.value?.focus(),0)})))},h=j=>{r("update:modelValue",j.value),b(),u.value="",d.value=-1},w=j=>{j.stopPropagation(),r("update:modelValue","")},b=()=>{if(x.value){if("hidePopover"in x.value)try{x.value.hidePopover()}catch{}x.value.removeEventListener("toggle",R)}a.value=!1,d.value=-1},V=()=>{if(!m.value||!x.value)return;const j=m.value.getBoundingClientRect();x.value.offsetWidth||j.width,x.value.style.position="fixed",x.value.style.top=`${j.bottom+8}px`,x.value.style.left=`${j.left}px`,x.value.style.width=`${j.width}px`,x.value.style.margin="0"},P=j=>{p.value&&!p.value.contains(j.target)&&x.value&&!x.value.contains(j.target)&&b()},U=j=>{j.key==="Escape"&&a.value&&(b(),m.value?.focus())},q=j=>{if(!a.value)return;const Z=k.value;if(Z.length!==0)switch(j.key){case"ArrowDown":j.preventDefault(),d.value=d.value<Z.length-1?d.value+1:0,K();break;case"ArrowUp":j.preventDefault(),d.value=d.value>0?d.value-1:Z.length-1,K();break;case"Enter":j.preventDefault(),d.value>=0&&d.value<Z.length&&h(Z[d.value]);break}},K=()=>{Ce(()=>{const j=x.value?.querySelector(".highlighted-option");j&&j.scrollIntoView({block:"nearest",behavior:"smooth"})})},R=j=>{j.target===x.value&&(a.value=j.newState==="open",a.value&&V())};return Te(()=>{document.addEventListener("click",P),document.addEventListener("keydown",U);const j=()=>{a.value&&V()};window.addEventListener("resize",j),window.addEventListener("scroll",j,!0)}),Ne(()=>{document.removeEventListener("click",P),document.removeEventListener("keydown",U),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}),(j,Z)=>(o(),l("div",{ref_key:"dropdownRef",ref:p,class:"relative"},[t.label?(o(),l("label",qs,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",zs,"*")):T("",!0)])):T("",!0),e("button",{ref_key:"buttonRef",ref:m,type:"button",onClick:g,disabled:t.disabled,"aria-expanded":a.value,"aria-haspopup":!0,class:Q(c.value)},[e("div",Ws,[t.loading?(o(),l("span",Js,[...Z[1]||(Z[1]=[e("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),Ve(" Loading... ",-1)])])):v.value?(o(),l("span",Zs,[v.value.icon?(o(),l("img",{key:0,src:v.value.icon,alt:v.value.label,class:"w-5 h-5 flex-shrink-0"},null,8,Ks)):T("",!0),e("span",Gs,C(v.value.label),1)])):(o(),l("span",Xs,C(t.placeholder),1)),v.value&&!t.disabled?(o(),l("button",{key:3,type:"button",onClick:w,class:"flex-shrink-0 p-0.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":"Clear selection"},[...Z[2]||(Z[2]=[e("svg",{class:"h-4 w-4 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):T("",!0),Z[3]||(Z[3]=e("svg",{class:"h-5 w-5 text-neutral-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,Hs),a.value?(o(),l("div",{key:1,ref_key:"popoverRef",ref:x,class:"dropdown-popover"},[M(Ye,{"offset-x":4,"offset-y":4,intensity:.3},{default:ce(()=>[e("div",Ys,[e("div",Qs,[Pe(e("input",{ref_key:"searchInput",ref:i,"onUpdate:modelValue":Z[0]||(Z[0]=N=>u.value=N),type:"text",placeholder:t.searchPlaceholder,onKeydown:q,class:"w-full px-3 py-1.5 text-sm border border-neutral-300 dark:border-neutral-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-neutral-400 dark:placeholder:text-neutral-500"},null,40,en),[[De,u.value]])]),e("div",tn,[k.value.length===0?(o(),l("div",on," No options found ")):T("",!0),(o(!0),l(he,null,ye(k.value,(N,F)=>(o(),l("button",{key:N.value,type:"button",onClick:B=>h(N),onMouseenter:B=>d.value=F,class:Q(["w-full px-4 py-2 text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none flex items-start gap-3",{"bg-neutral-50 dark:bg-neutral-900":N.value===t.modelValue,"bg-neutral-100 dark:bg-neutral-800 highlighted-option":F===d.value}])},[e("div",ln,[N.icon?(o(),l("img",{key:0,src:N.icon,alt:N.label,class:"w-full h-full"},null,8,sn)):(o(),l("div",nn))]),e("div",rn,[e("div",dn,C(N.label),1),N.description?(o(),l("div",un,C(N.description),1)):T("",!0)])],42,an))),128))])])]),_:1})],512)):T("",!0),t.error?(o(),l("p",cn,C(t.error),1)):T("",!0)],512))}}),pn={class:"flex items-start"},mn=["for"],vn=["id","checked","disabled"],hn={class:"flex items-center h-5"},fn={class:"flex-1"},gn={key:0,class:"text-red-500"},bn={key:1,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},xn={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},je=re({__name:"CheckboxInput",props:{modelValue:{type:Boolean,default:!1},label:{},helpText:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=Eo(),u=W(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50":"hover:scale-110",n.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",n.modelValue?"before:block":"before:hidden"]),i=p=>{if(!n.disabled){const m=p.target;r("update:modelValue",m.checked)}};return(p,m)=>(o(),l("div",pn,[e("label",{for:H(a),class:Q(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:H(a),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:i,class:"absolute left-[-9999px]"},null,40,vn),e("div",hn,[e("span",{class:Q(u.value)},null,2)]),e("div",fn,[t.label?(o(),l("span",{key:0,class:Q(["block text-sm font-medium",{"opacity-50":t.disabled}])},[Ve(C(t.label)+" ",1),t.required?(o(),l("span",gn,"*")):T("",!0)],2)):T("",!0),t.helpText?(o(),l("p",bn,C(t.helpText),1)):T("",!0),t.error?(o(),l("p",xn,C(t.error),1)):T("",!0)])],10,mn)]))}}),yn={key:0,class:"min-h-[400px] flex items-center justify-center"},kn={key:1,class:"space-y-6 pr-2 pb-4"},wn={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg"},_n={class:"text-sm text-red-800 dark:text-red-200"},$n={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Cn={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Sn={key:1},Tn={key:2},Vn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Mn={key:3},In={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ln={class:"grid grid-cols-2 gap-6"},En={class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},An={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Pn={class:"space-y-3"},jn={class:"flex items-start"},On={key:0,class:"ml-8 mt-2 space-y-2"},Un={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Rn={key:1},Dn={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},Bn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Nn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Fn={class:"space-y-4 p-4 bg-neutral-100 dark:bg-neutral-800 rounded-lg"},qn={class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"},zn={key:0,class:"flex flex-col items-center justify-center py-8"},Hn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Wn={class:"space-y-3"},Jn={class:"flex items-start"},Zn={key:0,class:"ml-8 mt-2 space-y-2"},Kn={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Gn={key:1},Xn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Yn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Qn={class:"flex justify-between"},er=["disabled"],tr=re({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>n.mode==="edit"),u=f(!1),i=f(""),p=f(""),m=f(""),x=f(null),d=f(""),v=f("dual_ai"),c=f(!1),k=f(""),g=f(""),h=f(null),w=f(""),b=f(""),V=f(""),P=f(""),U=f(!0),q=f(!1),K=f(""),R=f(""),j=f(""),Z=f(""),N=f(!1),F=f(null),B=f(""),y=f(""),$=f(""),E=f(""),_=f(""),S=f(""),L=f(!0),J=f(!1),X=f(""),G=f(""),D=f(""),O=f(""),A=f(null),de=f(""),I=f(""),ee=f(""),{data:ae,execute:me}=Ue(le("/api/prompts"),{immediate:!1}).json(),{data:$e,execute:fe}=Ue(le("/api/tools?schema=true"),{immediate:!1}).json(),ke=f(null),we=f(!1),Ae=f(null),oe=f(!1),ie=f(!1),ne=W(()=>{if(!ae.value)return[{value:"",label:"Select a prompt..."}];const ue=ae.value?.prompts||[];return[{value:"",label:"None"},...ue.map(z=>({value:z.id,label:z.name}))]}),be=ue=>$e.value?$e.value[ue]:null,xe=W(()=>!ke.value||!ke.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...ke.value.tools.map(ue=>{const z=typeof ue=="string"?ue:ue.name;return{value:z,label:z}})]),Le=W(()=>!Ae.value||!Ae.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ae.value.tools.map(ue=>{const z=typeof ue=="string"?ue:ue.name;return{value:z,label:z}})]),ve=W(()=>{if(!K.value)return[];const ue=be(K.value);return!ue||!ue.schema||!ue.schema.properties?[]:Object.keys(ue.schema.properties).map(z=>({value:z,label:z}))}),se=W(()=>{if(!X.value)return[];const ue=be(X.value);return!ue||!ue.schema||!ue.schema.properties?[]:Object.keys(ue.schema.properties).map(z=>({value:z,label:z}))}),ge=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Oe=W({get(){return p.value},set(ue){const z=x.value?.inputRef,te=z?.selectionStart??ue.length;let Fe=ue.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Fe.endsWith("_agent")||(Fe=Fe+"_agent"),p.value=Fe,z){z.value=Fe;const Re=Math.min(te,Fe.length-6);z.setSelectionRange(Re,Re)}}}),st=async()=>{await Ce();const ue=x.value?.inputRef;if(ue&&p.value.endsWith("_agent")){const z=p.value.length-6;ue.setSelectionRange(z,z)}},wo=ue=>!ue||ue==="_agent"?(m.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(ue)?(m.value="",!0):(m.value="Name must start with a letter",!1),nt=()=>{p.value="",i.value="",m.value="",d.value="",v.value="dual_ai",c.value=!1,k.value="",g.value="",h.value=null,w.value="",V.value="",P.value="",U.value=!0,q.value=!1,K.value="",R.value="",j.value="",Z.value="",N.value=!1,F.value=null,B.value="",y.value="",$.value="",ke.value=null,_.value="",S.value="",L.value=!0,J.value=!1,X.value="",G.value="",D.value="",O.value="",A.value=null,de.value="",I.value="",ee.value="",Ae.value=null},_o=async()=>{if(n.editAgent?.id){u.value=!0,ie.value=!0;try{const ue=await fetch(le(`/api/agents/${n.editAgent.id}`));if(ue.ok){const z=await ue.json(),te=z.agent||z;p.value=te.name||"",i.value=te.name||"",d.value=te.title||"",v.value=te.type||"dual_ai",c.value=te.expose_as_tool||!1,k.value=te.tool_description||"",h.value=te.max_session_turns;const Fe=te.side_a_stop_tool||"",Re=te.side_a_stop_tool_response_property||"",So=te.side_b_stop_tool||"",To=te.side_b_stop_tool_response_property||"",Vo=te.side_a_end_conversation_tool||"",Mo=te.side_b_end_conversation_tool||"";b.value=te.side_a_label||"",E.value=te.side_b_label||"",V.value=te.side_a_agent_prompt||"",_.value=te.side_b_agent_prompt||"",U.value=!!te.side_a_stop_on_response,q.value=!!te.side_a_stop_tool,N.value=!!te.side_a_manual_stop_condition,F.value=te.side_a_max_turns,L.value=!!te.side_b_stop_on_response,J.value=!!te.side_b_stop_tool,A.value=te.side_b_max_turns,await Ce(),K.value=Fe,j.value=Re,X.value=So,D.value=To,y.value=Vo,I.value=Mo}}catch(ue){console.error("Error loading agent data:",ue)}finally{u.value=!1,ie.value=!1}}},$o=async()=>{m.value="",w.value="",P.value="",R.value="",Z.value="",B.value="",$.value="",S.value="",G.value="",O.value="",de.value="",ee.value="";let ue=!1;wo(p.value)||(ue=!0);const z=p.value;v.value==="dual_ai"&&h.value!==null&&h.value!==void 0&&h.value<=0&&(w.value="Max session turns must be a positive number",ue=!0),V.value||(P.value="Please select an agent prompt",ue=!0);const te=U.value||K.value,Fe=v.value==="ai_human"&&N.value;if(!te&&!Fe&&(P.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",ue=!0),K.value&&!j.value&&(Z.value="Response property required when using stop tool",ue=!0),F.value!==null&&F.value<=0&&(B.value="Max turns must be a positive number",ue=!0),v.value==="dual_ai"&&!y.value&&!I.value&&($.value="At least one side must have an end conversation tool",ee.value="At least one side must have an end conversation tool",ue=!0),v.value==="dual_ai"&&(_.value||(S.value="Please select an agent prompt",ue=!0),X.value&&!D.value&&(O.value="Response property required when using stop tool",ue=!0),A.value!==null&&A.value<=0&&(de.value="Max turns must be a positive number",ue=!0)),ue)return;const Re={name:z,title:d.value||null,type:v.value,expose_as_tool:c.value,tool_description:c.value?k.value:null,max_session_turns:v.value==="dual_ai"?h.value:null,side_a_label:b.value||null,side_a_agent_prompt:V.value,side_a_stop_on_response:U.value,side_a_stop_tool:K.value||null,side_a_stop_tool_response_property:j.value||null,side_a_manual_stop_condition:N.value,side_a_max_turns:F.value,side_a_end_conversation_tool:y.value||null};v.value==="dual_ai"&&(Re.side_b_label=E.value||null,Re.side_b_agent_prompt=_.value,Re.side_b_stop_on_response=L.value,Re.side_b_stop_tool=X.value||null,Re.side_b_stop_tool_response_property=D.value||null,Re.side_b_max_turns=A.value,Re.side_b_end_conversation_tool=I.value||null),a.value&&n.editAgent?.id&&(Re.id=n.editAgent.id),r("save",Re)},Co=()=>{nt(),r("update:modelValue",!1)};return pe(V,async ue=>{if(ie.value||(K.value="",j.value=""),!ue){ke.value=null;return}we.value=!0;try{const z=await fetch(le(`/api/prompts/${ue}`));z.ok&&(ke.value=await z.json())}catch(z){console.error("Error fetching Side A prompt:",z)}finally{we.value=!1}}),pe(_,async ue=>{if(ie.value||(X.value="",D.value=""),!ue){Ae.value=null;return}oe.value=!0;try{const z=await fetch(le(`/api/prompts/${ue}`));z.ok&&(Ae.value=await z.json())}catch(z){console.error("Error fetching Side B prompt:",z)}finally{oe.value=!1}}),pe(q,ue=>{ue||(K.value="",j.value="")}),pe(J,ue=>{ue||(X.value="",D.value="")}),pe(()=>n.modelValue,async ue=>{ue?(await Promise.all([me(),fe()]),a.value?(nt(),await _o()):nt()):nt()}),(ue,z)=>(o(),Y(Be,{"model-value":t.modelValue,"onUpdate:modelValue":z[23]||(z[23]=te=>ue.$emit("update:modelValue",te)),title:a.value?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:ce(()=>[e("div",Qn,[e("button",{onClick:Co,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:$o,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:u.value},C(a.value?"Update Agent":"Create Agent"),9,er)])]),default:ce(()=>[u.value?(o(),l("div",yn,[...z[24]||(z[24]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(o(),l("div",kn,[t.apiError?(o(),l("div",wn,[e("p",_n,C(t.apiError),1)])):T("",!0),e("div",null,[M(Ee,{ref_key:"nameInputRef",ref:x,modelValue:Oe.value,"onUpdate:modelValue":z[0]||(z[0]=te=>Oe.value=te),label:"Agent Name",error:m.value,required:"",disabled:a.value,onFocus:st,onClick:st},null,8,["modelValue","error","disabled"]),!m.value&&!a.value?(o(),l("p",$n," Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ")):T("",!0),a.value?(o(),l("p",Cn," Agent names cannot be changed after creation (used as foreign key for threads) ")):T("",!0)]),e("div",null,[M(Ee,{modelValue:d.value,"onUpdate:modelValue":z[1]||(z[1]=te=>d.value=te),label:"Display Title (Optional)"},null,8,["modelValue"]),z[25]||(z[25]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Human-readable title shown in the UI (e.g., Research Assistant). If not set, the name will be used. ",-1))]),e("div",null,[M(_e,{modelValue:v.value,"onUpdate:modelValue":z[2]||(z[2]=te=>v.value=te),label:"Agent Type",options:ge},null,8,["modelValue"]),z[26]||(z[26]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),v.value==="dual_ai"?(o(),l("div",Sn,[M(je,{modelValue:c.value,"onUpdate:modelValue":z[3]||(z[3]=te=>c.value=te),label:"Expose as Tool"},null,8,["modelValue"]),z[27]||(z[27]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):T("",!0),c.value&&v.value==="dual_ai"?(o(),l("div",Tn,[M(ho,{modelValue:k.value,"onUpdate:modelValue":z[4]||(z[4]=te=>k.value=te),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:g.value,rows:3},null,8,["modelValue","error"]),g.value?T("",!0):(o(),l("p",Vn," This description helps other agents understand when to use this agent "))])):T("",!0),v.value==="dual_ai"?(o(),l("div",Mn,[M(Ee,{"model-value":h.value?.toString()||"","onUpdate:modelValue":z[5]||(z[5]=te=>h.value=te?parseInt(te):null),label:"Max Session Turns",type:"number",error:w.value,placeholder:"Unlimited"},null,8,["model-value","error"]),w.value?T("",!0):(o(),l("p",In," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):T("",!0),e("div",Ln,[e("div",En,[z[34]||(z[34]=e("h4",{class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"}," Side A (AI) ",-1)),e("div",null,[M(Ee,{modelValue:b.value,"onUpdate:modelValue":z[6]||(z[6]=te=>b.value=te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),z[28]||(z[28]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e("div",null,[M(_e,{modelValue:V.value,"onUpdate:modelValue":z[7]||(z[7]=te=>V.value=te),label:"Agent Prompt",options:ne.value,error:P.value,required:""},null,8,["modelValue","options","error"]),P.value?T("",!0):(o(),l("p",An," The prompt that defines this agent's behavior "))]),e("div",Pn,[z[31]||(z[31]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),z[32]||(z[32]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",jn,[M(je,{modelValue:U.value,"onUpdate:modelValue":z[8]||(z[8]=te=>U.value=te),label:"Stop when agent returns content"},null,8,["modelValue"])]),z[33]||(z[33]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[M(je,{modelValue:q.value,"onUpdate:modelValue":z[9]||(z[9]=te=>q.value=te),label:"Stop on specific tool call"},null,8,["modelValue"]),q.value?(o(),l("div",On,[M(_e,{modelValue:K.value,"onUpdate:modelValue":z[10]||(z[10]=te=>K.value=te),label:"Stop Tool",options:xe.value,error:R.value,placeholder:"Select a tool...",disabled:we.value||!V.value},null,8,["modelValue","options","error","disabled"]),R.value?T("",!0):(o(),l("p",Un," Agent stops when this tool is called ")),K.value?(o(),l("div",Rn,[M(_e,{modelValue:j.value,"onUpdate:modelValue":z[11]||(z[11]=te=>j.value=te),label:"Response Property",options:ve.value,error:Z.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),z[29]||(z[29]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):T("",!0)])):T("",!0)]),v.value==="ai_human"&&!U.value&&!q.value?(o(),l("div",Dn,[M(je,{modelValue:N.value,"onUpdate:modelValue":z[12]||(z[12]=te=>N.value=te),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),z[30]||(z[30]=e("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):T("",!0)]),e("div",null,[M(Ee,{"model-value":F.value?.toString()||"","onUpdate:modelValue":z[13]||(z[13]=te=>F.value=te?parseInt(te):null),label:"Max Turns",type:"number",error:B.value,placeholder:"Unlimited"},null,8,["model-value","error"]),B.value?T("",!0):(o(),l("p",Bn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[M(_e,{modelValue:y.value,"onUpdate:modelValue":z[14]||(z[14]=te=>y.value=te),label:"End Conversation Tool",options:xe.value,error:$.value,placeholder:"Select a tool...",disabled:we.value||!V.value},null,8,["modelValue","options","error","disabled"]),$.value?T("",!0):(o(),l("p",Nn," Tool that ends the entire conversation when called "))])]),e("div",Fn,[e("h4",qn," Side B ("+C(v.value==="ai_human"?"Human":"AI")+") ",1),e("div",null,[M(Ee,{modelValue:E.value,"onUpdate:modelValue":z[15]||(z[15]=te=>E.value=te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),z[35]||(z[35]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),v.value==="ai_human"?(o(),l("div",zn,[...z[36]||(z[36]=[e("svg",{class:"w-20 h-20 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),e("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(o(),l(he,{key:1},[e("div",null,[M(_e,{modelValue:_.value,"onUpdate:modelValue":z[16]||(z[16]=te=>_.value=te),label:"Agent Prompt",options:ne.value,error:S.value,required:""},null,8,["modelValue","options","error"]),S.value?T("",!0):(o(),l("p",Hn," The prompt that defines this agent's behavior "))]),e("div",Wn,[z[38]||(z[38]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),z[39]||(z[39]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",Jn,[M(je,{modelValue:L.value,"onUpdate:modelValue":z[17]||(z[17]=te=>L.value=te),label:"Stop when agent returns content"},null,8,["modelValue"])]),z[40]||(z[40]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[M(je,{modelValue:J.value,"onUpdate:modelValue":z[18]||(z[18]=te=>J.value=te),label:"Stop on specific tool call"},null,8,["modelValue"]),J.value?(o(),l("div",Zn,[M(_e,{modelValue:X.value,"onUpdate:modelValue":z[19]||(z[19]=te=>X.value=te),label:"Stop Tool",options:Le.value,error:G.value,placeholder:"Select a tool...",disabled:oe.value||!_.value},null,8,["modelValue","options","error","disabled"]),G.value?T("",!0):(o(),l("p",Kn," Agent stops when this tool is called ")),X.value?(o(),l("div",Gn,[M(_e,{modelValue:D.value,"onUpdate:modelValue":z[20]||(z[20]=te=>D.value=te),label:"Response Property",options:se.value,error:O.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),z[37]||(z[37]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):T("",!0)])):T("",!0)])]),e("div",null,[M(Ee,{"model-value":A.value?.toString()||"","onUpdate:modelValue":z[21]||(z[21]=te=>A.value=te?parseInt(te):null),label:"Max Turns",type:"number",error:de.value,placeholder:"Unlimited"},null,8,["model-value","error"]),de.value?T("",!0):(o(),l("p",Xn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[M(_e,{modelValue:I.value,"onUpdate:modelValue":z[22]||(z[22]=te=>I.value=te),label:"End Conversation Tool",options:Le.value,error:ee.value,placeholder:"Select a tool...",disabled:oe.value||!_.value},null,8,["modelValue","options","error","disabled"]),ee.value?T("",!0):(o(),l("p",Yn," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"]))}}),or={},ar={class:"p-8 w-full max-w-7xl mx-auto"};function lr(t,s){return o(),l("div",ar,[Ke(t.$slots,"default")])}const et=Qe(or,[["render",lr]]),sr=re({__name:"AgentsView",setup(t){const s=ot(),n=We(),r=f(!1),a=f("add"),u=f(null),i=f(null),p=f(null);pe(()=>n.query.refresh,()=>{n.query.refresh&&(i.value?.refresh(),s.replace({path:"/agents",query:{}}))});const m=()=>{a.value="add",u.value=null,p.value=null,r.value=!0},x=v=>{a.value="edit",u.value=v,p.value=null,r.value=!0},d=async v=>{p.value=null;try{const c=a.value==="edit"&&u.value?.id,{originalName:k,...g}=v,h=le(c?`/api/agents/${u.value.id}`:"/api/agents"),b=await fetch(h,{method:c?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(b.ok)i.value?.refresh(),r.value=!1,u.value=null;else{const V=await b.json();p.value=V.error||`Failed to ${c?"update":"create"} agent`}}catch(c){console.error(`Error ${a.value==="edit"?"updating":"creating"} agent:`,c),p.value=`Failed to ${a.value==="edit"?"update":"create"} agent`}};return(v,c)=>(o(),Y(et,null,{default:ce(()=>[e("div",{class:"flex justify-between items-center mb-6"},[c[1]||(c[1]=e("h1",{class:"text-3xl font-bold"},"Agents",-1)),e("button",{onClick:m,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),c[2]||(c[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Configure and manage your AI agents. ",-1)),M(xs,{ref_key:"dataTableRef",ref:i,onAdd:m,onEdit:x},null,512),M(tr,{modelValue:r.value,"onUpdate:modelValue":c[0]||(c[0]=k=>r.value=k),mode:a.value,editAgent:u.value,apiError:p.value,onSave:d},null,8,["modelValue","mode","editAgent","apiError"])]),_:1}))}});function nr(t){const{limit:s=50,offset:n=0,agentId:r=null,userId:a=null,autoFetch:u=!0}={},i=W(()=>{const w=new URLSearchParams,b=typeof s=="number"?s:s.value,V=typeof n=="number"?n:n.value,P=typeof r=="string"?r:r?.value,U=typeof a=="string"?a:a?.value;return w.append("limit",b.toString()),w.append("offset",V.toString()),P&&w.append("agent_id",P),U&&w.append("user_id",U),le(`/api/threads?${w.toString()}`)}),{data:p,error:m,isFetching:x,isFinished:d,execute:v,abort:c}=Ue(i,{immediate:u}).get().json(),k=W(()=>p.value?.threads||[]),g=W(()=>p.value?.total||0),h=W(()=>p.value?.hasMore||!1);return{threads:k,total:g,hasMore:h,error:m,isFetching:x,isFinished:d,refetch:v,abort:c}}function Ct(t){const s=W(()=>!!(typeof t=="string"?t:t?.value)),n=W(()=>{const d=typeof t=="string"?t:t?.value;return le(d?`/api/threads/${d}`:"/api/threads/placeholder")}),{data:r,error:a,isFetching:u,isFinished:i,execute:p,abort:m}=Ue(n,{immediate:!1}).get().json();return pe(s,d=>{d&&p()},{immediate:!0}),{thread:W(()=>r.value?{id:r.value.thread.id,agent_id:r.value.thread.agent_id,user_id:r.value.thread.user_id,tags:r.value.thread.tags||[],created_at:r.value.thread.created_at,agent:r.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:r.value.stats}:null),error:a,isFetching:u,isFinished:i,refetch:p,abort:m}}function rr(t){const{autoConnect:s=!0,onEvent:n}=t||{},r=f(null),a=f(!1),u=f(null),i=()=>{r.value&&r.value.close();const m=window.location.protocol==="https:"?"wss:":"ws:",x=window.location.host;let d=`${m}//${x}${le("/api/events")}`;const v=localStorage.getItem("auth_token");v&&(d+=`?token=${encodeURIComponent(v)}`);try{r.value=new WebSocket(d),r.value.onopen=()=>{a.value=!0,u.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},r.value.onmessage=c=>{try{const k=JSON.parse(c.data);console.log("[AgentBuilderEvents] Received event:",k.type),n&&n(k)}catch(k){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",k)}},r.value.onerror=c=>{u.value="WebSocket connection error",a.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",c)},r.value.onclose=()=>{a.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(c){u.value=c.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",c)}},p=()=>{r.value&&(r.value.close(),r.value=null,a.value=!1)};return s&&i(),Ne(()=>{p()}),{wsConnected:a,wsError:u,connect:i,disconnect:p}}const ir={class:"inline-flex items-center justify-center"},Se=re({__name:"Loader",props:{size:{default:"md"}},setup(t){const s=t,n=W(()=>{switch(s.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}});return(r,a)=>(o(),l("div",ir,[e("div",{class:Q([n.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}});function dr(t){const n=Date.now()*1e3-t,r=Math.floor(n/1e6);if(r<60)return r===1?"1 second ago":`${r} seconds ago`;const a=Math.floor(r/60);if(a<60)return a===1?"1 minute ago":`${a} minutes ago`;const u=Math.floor(a/60);if(u<24)return u===1?"1 hour ago":`${u} hours ago`;const i=Math.floor(u/24);if(i<30)return i===1?"1 day ago":`${i} days ago`;const p=Math.floor(i/30);if(p<12)return p===1?"1 month ago":`${p} months ago`;const m=Math.floor(p/12);return m===1?"1 year ago":`${m} years ago`}function ur(t){const s=f("");let n=null;const r=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,a=()=>{const u=r();s.value=dr(u);const p=Date.now()*1e3-u,m=Math.floor(p/1e6);n!==null&&(clearInterval(n),n=null),m<60?n=setInterval(a,1e3):m<3600?n=setInterval(a,6e4):m<86400&&(n=setInterval(a,6e5))};return a(),Ne(()=>{n!==null&&clearInterval(n)}),s}const ct=re({__name:"TimeAgo",props:{timestamp:{}},setup(t){const s=t,n=ur(()=>s.timestamp);return(r,a)=>(o(),l("span",null,C(H(n)),1))}}),cr={class:"relative inline-flex items-center"},pr={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},mr={key:1,class:"inline-block w-2 h-2 rounded-full bg-red-500 dark:bg-red-400"},vr={key:2,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},hr={key:0},fr={key:1},gr={key:2},St=re({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const s=f(!1),n=f(null);return(r,a)=>(o(),l("div",cr,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:a[0]||(a[0]=u=>s.value=!0),onMouseleave:a[1]||(a[1]=u=>s.value=!1)},[t.connected?(o(),l("span",pr)):t.error?(o(),l("span",mr)):(o(),l("span",vr))],32),M(Ge,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[s.value?(o(),l("div",{key:0,ref_key:"popoverRef",ref:n,class:Q(["absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs rounded shadow-lg whitespace-nowrap z-50 border",{"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800 text-green-700 dark:text-green-300":t.connected,"bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800 text-red-700 dark:text-red-300":!t.connected&&t.error,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected&&!t.error}])},[t.connected?(o(),l("span",hr,"Live - Connected")):t.error?(o(),l("span",fr,"Connection Error")):(o(),l("span",gr,"Offline"))],2)):T("",!0)]),_:1})]))}}),br={class:"flex flex-col flex-1 min-h-0"},xr={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},yr={class:"flex items-center justify-between"},kr={class:"flex items-center gap-2"},wr={class:"flex items-center gap-2"},_r={class:"flex-1 overflow-y-auto text-xs min-h-0"},$r={key:0,class:"p-2 flex justify-center"},Cr={key:1,class:"p-2 text-red-600 dark:text-red-400"},Sr={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12 text-base"},Tr={key:3},Vr=["id","onClick"],Mr={class:"flex items-center gap-2 mb-1"},Ir={class:"font-medium truncate flex-1 min-w-0"},Lr={class:"flex-shrink-0 text-neutral-500 dark:text-neutral-400"},Er={key:0,class:"flex flex-wrap gap-1"},Ar=re({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:s,emit:n}){const r=n;f("");const{threads:a,isFetching:u,isFinished:i,error:p,refetch:m}=nr(),x=f([]),d=f(new Set),v=W(()=>{const b=a.value.filter(U=>!d.value.has(U.id)),V=new Set(b.map(U=>U.id));return[...x.value.filter(U=>!V.has(U.id)&&!d.value.has(U.id)),...b].sort((U,q)=>q.created_at-U.created_at)}),c=async b=>{if(b.type==="thread_created"){const V={id:b.thread.id,agent_id:b.thread.agent_name,user_id:b.thread.user_id,tags:b.thread.tags||[],created_at:b.thread.created_at,agent:{name:b.thread.agent_name,title:void 0,type:"ai_human"}};x.value.unshift(V)}else b.type==="thread_deleted"&&(d.value.add(b.threadId),x.value=x.value.filter(V=>V.id!==b.threadId))},{wsConnected:k,wsError:g}=rr({onEvent:c});pe(a,()=>{x.value=[]});const h=f(!1);pe(()=>({threads:a.value,finished:i.value}),({threads:b,finished:V})=>{V&&!h.value&&(h.value=!0,r("threadsLoaded",b[0]?.id??null))},{immediate:!0}),s({refetch:m});const w=b=>{r("selectThread",b)};return(b,V)=>(o(),l("div",br,[e("div",xr,[e("div",yr,[e("div",kr,[M(H(Kt),{size:18,class:"shrink-0"}),V[2]||(V[2]=e("h2",{class:"text-base font-bold"},"Threads",-1)),M(St,{connected:H(k),error:H(g)},null,8,["connected","error"])]),e("div",wr,[e("button",{onClick:V[0]||(V[0]=P=>r("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),e("button",{onClick:V[1]||(V[1]=P=>r("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[M(H($t),{size:20})])])])]),e("div",_r,[H(u)?(o(),l("div",$r,[M(Se)])):H(p)?(o(),l("div",Cr," Error: "+C(H(p)),1)):v.value.length===0?(o(),l("div",Sr," No threads found ")):(o(),l("div",Tr,[(o(!0),l(he,null,ye(v.value,P=>(o(),l("button",{key:P.id,id:`thread-${P.id}`,class:Q(["w-full text-left px-2 py-2 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:ring-2 hover:ring-inset hover:ring-accent-400 dark:hover:ring-accent-400",{"bg-accent-100 dark:bg-accent-900 dark:text-white ring-2 ring-inset ring-accent-400 dark:ring-accent-400":t.selectedThreadId===P.id}]),onClick:U=>w(P.id)},[e("div",Mr,[e("span",Ir,C(P.agent.title||P.agent.name),1),e("span",Lr,[M(ct,{timestamp:P.created_at*1e6},null,8,["timestamp"])])]),P.tags.length>0?(o(),l("div",Er,[(o(!0),l(he,null,ye(P.tags,U=>(o(),l("span",{key:U,class:Q(["inline-block px-1.5 py-0.5 rounded text-[10px]",t.selectedThreadId===P.id?"bg-accent-400 dark:bg-accent-950 text-accent-950 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"])},C(U),3))),128))])):T("",!0)],10,Vr))),128))]))])]))}});function Pr(t,s={}){const n=f(null),r=f(!1),a=f(null);let u=null;try{u=so()}catch{}const i=u?.messages??f([]),p=W(()=>u?.status.value==="connected"),m=f(null);u?.loading??f(!1);const x=W(()=>i.value.some(_=>_.status==="pending")),d=f(!1),v=f(0),c=f(!1);function k(_){if(!n.value?.agent)return null;const S=n.value.agent,L=_==="assistant"?"A":"B";return L==="A"&&S.side_a_label?S.side_a_label:L==="B"&&S.side_b_label?S.side_b_label:null}function g(_,S){return _==="system"||S==="system"?!1:_!==S}function h(_){if(_){if(Array.isArray(_))return _.length>0?_:void 0;try{const S=JSON.parse(_);return Array.isArray(S)&&S.length>0?S:void 0}catch(S){console.error("Failed to parse attachments:",S);return}}}const w=W(()=>{const _=[],S=i.value.filter(X=>(X.depth??0)===0),L=new Map;for(let X=0;X<S.length;X++){const G=S[X],D=G.role;if(D==="tool"){const me=G.tool_call_id;if(me&&L.has(me)){const $e=L.get(me),fe=_[$e],ke=fe.items.find(we=>we.type==="tool_call"&&we.tool_call_id===me);if(ke){ke.response=G.content||"",ke.response_log_id=G.log_id;const we=(G.content||"").toLowerCase(),Ae=we.length,oe=we.includes("failed")||we.includes("error"),ie=Ae<500;oe&&ie?ke.response_status="failed":ke.response_status="success"}fe.updated_at=G.created_at,L.delete(me)}continue}const O=k(D==="tool"?"assistant":D),A=_[_.length-1],de=A?.role;A&&g(D,de)&&A.type==="work"&&!A.isComplete&&(A.isComplete=!0);let I=null;if(G.tool_calls)if(typeof G.tool_calls=="string")try{I=JSON.parse(G.tool_calls)}catch(me){console.error("Failed to parse tool_calls:",me)}else Array.isArray(G.tool_calls)&&(I=G.tool_calls);const ee=I&&I.length>0,ae=A?.type==="work"&&A.role===D&&!A.isComplete;if(ee){let me,$e;ae?(me=A,$e=_.length-1):(me={type:"work",id:G.id,role:D,items:[],created_at:G.created_at,updated_at:G.created_at,isComplete:!1,sideLabel:O,isExpanded:!1,request_sent_at:G.request_sent_at,response_completed_at:G.response_completed_at,status:G.status||"completed"},_.push(me),$e=_.length-1),G.reasoning_content&&me.items.push({id:`${G.id}-reasoning`,type:"reasoning",content:G.reasoning_content,created_at:G.created_at,log_id:G.log_id}),G.content&&me.items.push({id:`${G.id}-content`,type:"content",content:G.content,created_at:G.created_at,log_id:G.log_id}),I.forEach(fe=>{me.items.push({id:fe.id,type:"tool_call",content:fe.function.name,created_at:G.created_at,tool_name:fe.function.name,tool_call_id:fe.id,tool_arguments:fe.function.arguments,log_id:G.log_id,response:null,response_status:"pending",response_log_id:null}),L.set(fe.id,$e)}),me.updated_at=G.created_at,G.response_completed_at&&(me.response_completed_at=G.response_completed_at),G.status&&G.status!=="completed"?me.status=G.status:G.status==="completed"&&me.status==="pending"&&(me.status="completed")}else ae&&G.status!=="pending"&&(A.isComplete=!0),(G.content||D==="system"||G.status==="pending"||G.attachments)&&_.push({type:"text",id:G.id,role:D,content:G.content||"",attachments:h(G.attachments),created_at:G.created_at,log_id:G.log_id,sideLabel:O,isOptimistic:G.isOptimistic,status:G.status})}const J=_[_.length-1];return J?.type==="work"&&!J.isComplete&&(J.isComplete=!0),_});async function b(){if(!t.value){n.value=null;return}try{const _=await fetch(le(`/api/threads/${t.value}`));_.ok&&(n.value=await _.json())}catch(_){console.error("Error fetching thread info:",_)}}async function V(_){if(t.value){if(u?.deleteMessage){await u.deleteMessage(_);return}try{if(!(await fetch(le(`/api/threads/${t.value}/messages/${_}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(S){throw S}}}async function P(_,S){if(t.value)try{if(!(await fetch(le(`/api/threads/${t.value}/messages/${_}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S})})).ok)throw new Error("Failed to update message")}catch(L){throw L}}pe(t,async _=>{_?(r.value=!0,await b(),r.value=!1):n.value=null},{immediate:!0});const U=u?.sendMessage,q=u?.stopExecution,K=u?.attachments??f([]),R=u?.addAttachment??(()=>{}),j=u?.removeAttachment??(()=>{}),Z=u?.clearAttachments??(()=>{});function N(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function F(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function B(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function y(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function $(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function E(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:w,threadInfo:n,isFetching:r,isLoadingMore:c,error:a,wsConnected:p,wsError:m,isExecuting:x,hasMore:d,totalMessages:v,sendMessage:U,stopThread:q,attachments:K,addAttachment:R,removeAttachment:j,clearAttachments:Z,deleteMessageById:V,updateMessageContent:P,refetch:E,loadMoreMessages:N,connectWebSocket:F,disconnectWebSocket:B,addOptimisticMessage:y,removeOptimisticMessage:$}}const jr={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},Or={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},Ur=["src","alt"],Rr={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center p-1"},Dr={key:0,class:"text-white text-[10px] mb-1"},Br={class:"text-white text-[10px] truncate w-full text-center"},Nr={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},Fr=re({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(t,{emit:s}){const n=t,r=s,a=f(!0),u=f(!1),i=W(()=>n.attachment.mimeType.startsWith("image/")),p=W(()=>!!n.attachment.thumbnailBase64),m=W(()=>{if(!n.threadId||!n.attachment.path)return"";const g=n.attachment.path.startsWith("/")?n.attachment.path.slice(1):n.attachment.path;return le(`/api/threads/${n.threadId}/fs/${g}`)}),x=W(()=>i.value?n.attachment.thumbnailBase64?`data:image/webp;base64,${n.attachment.thumbnailBase64}`:m.value:"");function d(){a.value=!1,u.value=!1}function v(){a.value=!1,u.value=!0}function c(){r("remove",n.attachment.id)}function k(){m.value&&window.open(m.value,"_blank")}return(g,h)=>(o(),l("div",{class:Q(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-20 h-20":i.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!i.value,"cursor-pointer":i.value&&m.value}]),onClick:h[0]||(h[0]=w=>i.value&&m.value?k():void 0)},[i.value?(o(),l(he,{key:0},[a.value&&!u.value&&!p.value?(o(),l("div",jr,[...h[1]||(h[1]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):T("",!0),u.value&&!p.value?(o(),l("div",Or,[M(H(Gt),{size:24})])):T("",!0),Pe(e("img",{src:x.value||m.value,alt:t.attachment.name,class:"w-full h-full object-cover",onLoad:d,onError:v},null,40,Ur),[[Je,!a.value&&!u.value||p.value]]),e("div",Rr,[m.value?(o(),l("span",Dr,"Click to view")):T("",!0),e("span",Br,C(t.attachment.name),1)])],64)):(o(),l(he,{key:1},[M(H(Xt),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),e("span",Nr,C(t.attachment.name),1)],64)),t.showRemove?(o(),l("button",{key:2,onClick:Me(c,["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"},[M(H(Ao),{size:10})])):T("",!0)],2))}}),qr=["onMouseenter","onMouseleave","onClick"],zr=["onClick"],Hr={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"3",stroke:"currentColor",class:"w-3 h-3 text-white"},Wr={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2.5",stroke:"currentColor",class:"w-3 h-3 text-white"},Jr={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},Zr={key:0,class:"flex flex-wrap gap-2 mb-2"},Kr=["contenteditable","onInput"],Gr={key:2,class:"flex gap-1 items-center min-h-[1.5rem]"},Xr={key:0,class:"opacity-50"},Yr={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},Qr=["onClick","onMouseenter"],ei={key:0,class:"space-y-1"},ti={class:"flex items-start gap-2"},oi={class:"flex-1 min-w-0"},ai={key:0,class:"truncate opacity-80"},li={key:1,class:"italic opacity-60"},si={class:"flex items-center gap-2 pl-5 opacity-60"},ni={class:"text-[10px]"},ri={class:"text-[10px]"},ii={key:1,class:"space-y-2"},di={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},ui={class:"text-[10px] italic"},ci={class:"text-[10px] ml-auto"},pi={key:0,class:"space-y-1"},mi=["onClick","onMouseenter"],vi={class:"font-mono text-[11px] flex-shrink-0"},hi={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},fi={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},gi={key:0,class:"pl-4 space-y-2 text-[10px]"},bi={key:0},xi={class:"w-full border-collapse"},yi={class:"py-0.5 pr-2 opacity-65 align-top"},ki={class:"py-0.5 opacity-85 break-all"},wi={key:1},_i=["onClick","onMouseenter"],$i={class:"whitespace-pre-wrap break-all"},Ci={key:1,class:"text-[10px]"},Si=["onClick"],Ti={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},Vi={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},Mi=re({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:s,emit:n}){const r=t,a=n;function u(D){const O=r.selectedForDelete?.has(D)??!1;a("selectionChange",D,!O)}function i(D,O){const de=D.target.innerText;a("messageEdit",O,de)}function p(D){return r.editedMessages?.has(D)??!1}const m=f(new Map);function x(D,O){O?m.value.set(D,O):m.value.delete(D)}function d(D){const O=r.messages.findIndex(A=>A.log_id===D);if(O<=0)return-1;for(let A=O-1;A>=0;A--){const de=r.messages[A];if(de.role==="user")return A;if(de.role==="assistant"&&de.log_id)break}return-1}function v(D){for(let O=0;O<r.messages.length;O++){const A=r.messages[O];if(A.log_id===D||A.type==="work"&&A.items&&A.items.some(ee=>ee.log_id===D||ee.response_log_id===D))return O}return-1}function c(D,O){const de=v(D);if(de===-1)return!1;const I=m.value.get(de);if(!I)return!1;const ee=r.messages[de];let ae=null;if(ee.role==="assistant"&&ee.log_id){const fe=d(ee.log_id);ae=fe!==-1?m.value.get(fe):null}const me=O.getBoundingClientRect(),$e=I.getBoundingClientRect();if($e.top<me.top){const we=(ae||I).getBoundingClientRect().top-me.top-10;O.scrollBy({top:we,behavior:"smooth"})}else if($e.bottom>me.bottom){const fe=$e.bottom-me.bottom+10;O.scrollBy({top:fe,behavior:"smooth"})}else if(ae){const fe=ae.getBoundingClientRect();if(fe.top<me.top){const ke=fe.top-me.top-10;O.scrollBy({top:ke,behavior:"smooth"})}}return!0}function k(D){for(const O of r.messages){if(O.type!=="work")continue;if(O.items.some(I=>I.log_id===D||I.response_log_id===D))return!0}return!1}s({scrollToLogId:c,hasWorkblockForLogId:k});function g(D){const O=r.messages[D];if(O.log_id)return O.log_id;if(O.role==="user")for(let A=D+1;A<r.messages.length;A++){const de=r.messages[A];if(de.log_id)return de.log_id;if(de.role==="user")break}return null}function h(D,O){return O?g(D)===O:!1}function w(D){const O=g(D);O&&a("messageHover",O)}function b(D){g(D)&&a("messageHover",null)}function V(D){const O=r.messages[D],A=g(D);A&&a("messageClick",O.id,A)}const P=f(new Set),U=f(new Set),q=f(new Set);function K(D){P.value.has(D)?P.value.delete(D):P.value.add(D)}function R(D){U.value.has(D)?U.value.delete(D):U.value.add(D)}function j(D){q.value.has(D)?q.value.delete(D):q.value.add(D)}function Z(D){if(!D)return{};try{return JSON.parse(D)}catch{return{raw:D}}}function N(D){if(!D)return null;const O=Z(D),A=Object.keys(O);if(A.length===0)return null;const de=O[A[0]];return typeof de=="string"?de:JSON.stringify(de)}function F(D){return new Date(D/1e3).toLocaleTimeString()}function B(D){const O=Math.round(D/1e6);if(O<1)return"< 1s";if(O<60)return`${O}s`;const A=Math.floor(O/60),de=O%60;return`${A}m ${de}s`}function y(D){if(D.status==="pending")return"...";if(!D.isComplete)return"Working...";let O;return D.request_sent_at&&D.response_completed_at?O=D.response_completed_at-D.request_sent_at:O=D.updated_at-D.created_at,`Worked for ${B(O)}`}function $(D){const O=D.filter(A=>A.type==="content");if(O.length===0){const A=D.filter(de=>de.type==="reasoning");return A.length>0?A[A.length-1].content:null}return O[O.length-1].content}function E(D){const A=D.trim().split(`
1
+ import{d as re,i as Zt,c as W,t as Io,r as f,w as pe,o as Te,a as Ne,p as Lo,m as Ie,b as l,e as o,f as e,n as lt,g as Ke,h as Ce,u as We,j as Q,k as T,l as Y,q as H,F as he,s as ye,v as M,x as Me,y as ce,z as ot,A as Ze,B as C,R as Vt,C as Ve,T as vt,D as Ge,E as Pe,G as De,H as Eo,I as Ue,L as Kt,J as $t,K as Gt,M as Je,N as Xt,X as Ao,O as dt,P as ht,Q as Po,S as jo,U as xt,V as Mt,W as Oo,Y as It,Z as Uo,_ as Ro,$ as Lt,a0 as Do,a1 as Bo,a2 as No,a3 as Fo,a4 as qo,a5 as Yt,a6 as zo,a7 as Qt,a8 as Ho,a9 as Wo,aa as yt,ab as qe,ac as Xe,ad as Jo,ae as Zo,af as eo,ag as to,ah as Ko,ai as Go,aj as Xo,ak as Yo,al as Qo}from"./vue.js";import{f as ea}from"./vendor.js";import{W as ta,a as oa,e as Et}from"./monaco.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const i of u.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(a){if(a.ep)return;a.ep=!0;const u=n(a);fetch(a.href,u)}})();var oo=class{endpoint;token;constructor(t){this.endpoint=t.replace(/\/$/,""),this.token=typeof localStorage<"u"?localStorage.getItem("agentbuilder_auth_token"):null}getEndpoint(){return this.endpoint}async createThread(t){const s=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`Failed to create thread: ${s.statusText}`);return s.json()}async getThread(t){const s=await fetch(`${this.endpoint}/threads/${t}`,{method:"GET",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to get thread: ${s.statusText}`);return s.json()}async getMessages(t,s={}){const n=new URLSearchParams;s.limit!==void 0&&n.set("limit",String(s.limit)),s.offset!==void 0&&n.set("offset",String(s.offset)),s.depth!==void 0&&n.set("depth",String(s.depth)),s.includeSilent!==void 0&&n.set("includeSilent",String(s.includeSilent));const r=n.toString(),a=`${this.endpoint}/threads/${t}/messages${r?`?${r}`:""}`,u=await fetch(a,{method:"GET",headers:this.getHeaders()});if(!u.ok)throw new Error(`Failed to get messages: ${u.statusText}`);return(await u.json()).messages||[]}async sendMessage(t,s){const n=await fetch(`${this.endpoint}/threads/${t}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Failed to send message: ${n.statusText}`);return n.json()}async stopExecution(t){const s=await fetch(`${this.endpoint}/threads/${t}/stop`,{method:"POST",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to stop execution: ${s.statusText}`);await s.json()}async deleteMessage(t,s){const n=await fetch(`${this.endpoint}/threads/${t}/messages/${s}`,{method:"DELETE",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to delete message: ${n.statusText}`);return n.json()}async uploadFile(t,s,n){const r=encodeURIComponent(s.name),a=`${this.endpoint}/threads/${t}/fs/${r}`;if(n?.thumbnail){const i=await this.fileToBase64(s),p=await fetch(a,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:i,mimeType:s.type,thumbnail:n.thumbnail,metadata:{width:n.width,height:n.height}})});if(!p.ok)throw new Error(`Failed to upload file: ${p.statusText}`);return p.json()}const u=await fetch(a,{method:"POST",headers:{...this.getHeaders(),"Content-Type":s.type},body:s});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const u=r.result.split(",")[1];s(u)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}getFileUrl(t,s){const r=(s.startsWith("/")?s.slice(1):s).split("/").map(a=>encodeURIComponent(a)).join("/");return`${this.endpoint}/threads/${t}/fs/${r}`}getThumbnailUrl(t,s){return`${this.getFileUrl(t,s)}?thumbnail=true`}async listFiles(t){const s=await fetch(`${this.endpoint}/threads/${t}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!s.ok)throw new Error(`Failed to list files: ${s.statusText}`);return(await s.json()).files||[]}connectMessageWebSocket(t,s={},n={}){const r=new URLSearchParams;this.token&&r.set("token",this.token),n.includeSilent!==void 0&&r.set("includeSilent",String(n.includeSilent)),n.depth!==void 0&&r.set("depth",String(n.depth));const a=this.endpoint.startsWith("https")?"wss":"ws",i=`${this.endpoint.replace(/^https?/,a)}/threads/${t}/stream?${r.toString()}`,p=new WebSocket(i);return p.onopen=()=>{s.onOpen?.()},p.onmessage=m=>{try{if(typeof m.data=="string"&&m.data==="pong")return;const x=JSON.parse(m.data);switch(x.type){case"message_data":s.onMessage?.(x);break;case"message_chunk":s.onChunk?.(x);break;case"event":s.onEvent?.(x);break;case"error":s.onError?.(x);break}}catch(x){console.error("Failed to parse WebSocket message:",x)}},p.onerror=m=>{console.error("WebSocket error:",m),s.onError?.({type:"error",error:"WebSocket connection error"})},p.onclose=m=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${m.code}, reason: ${m.reason||"none"}, wasClean: ${m.wasClean}`),s.onClose?.()},p}connectLogWebSocket(t,s={}){const n=new URLSearchParams;this.token&&n.set("token",this.token);const r=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,r)}/threads/${t}?${n.toString()}`,i=new WebSocket(u);return i.onopen=()=>{s.onOpen?.()},i.onmessage=p=>{try{if(typeof p.data=="string"&&p.data==="pong")return;const m=JSON.parse(p.data);switch(m.type){case"log_data":s.onLog?.(m);break;case"custom":s.onCustom?.(m);break;case"stopped_by_user":s.onStopped?.(m);break}}catch(m){console.error("Failed to parse WebSocket message:",m)}},i.onerror=p=>{console.error("WebSocket error:",p)},i.onclose=()=>{s.onClose?.()},i}getHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}},aa=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(t,s,n={},r={}){this.client=t,this.threadId=s,this.callbacks=n,this.options={depth:r.depth??0,includeSilent:r.includeSilent??!1,heartbeatInterval:r.heartbeatInterval??3e4,maxReconnectDelay:r.maxReconnectDelay??3e4}}getStatus(){return this.status}getThreadId(){return this.threadId}connect(){this.ws&&this.ws.readyState!==WebSocket.CLOSED||(this.shouldReconnect=!0,this.isReconnecting=!1,this.setStatus("connecting"),this.ws=this.client.connectMessageWebSocket(this.threadId,{onOpen:()=>{this.setStatus("connected"),this.reconnectAttempts=0,this.isReconnecting=!1,this.startHeartbeat()},onMessage:t=>{this.callbacks.onMessage?.(t)},onChunk:t=>{this.callbacks.onChunk?.(t)},onEvent:t=>{this.callbacks.onEvent?.(t)},onError:t=>{this.callbacks.onError?.(t)},onClose:()=>{this.clearTimers(),this.scheduleReconnect()}},{depth:this.options.depth,includeSilent:this.options.includeSilent}))}disconnect(){this.shouldReconnect=!1,this.clearTimers(),this.ws&&(this.ws.close(),this.ws=null),this.reconnectAttempts=0,this.isReconnecting=!1,this.setStatus("disconnected")}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}updateOptions(t){this.options={...this.options,...t}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.onStatusChange?.(t))}startHeartbeat(){this.clearHeartbeat(),this.heartbeatInterval=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("ping")},this.options.heartbeatInterval)}clearHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}clearTimers(){this.clearHeartbeat(),this.clearReconnectTimeout()}scheduleReconnect(){if(!this.shouldReconnect||this.isReconnecting){this.setStatus("disconnected");return}this.isReconnecting=!0,this.setStatus("reconnecting");const t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.options.maxReconnectDelay);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.shouldReconnect&&this.connect()},t)}};function At(t){return t.toLowerCase().startsWith("image/")}var Pt=256;function la(t){return new Promise((s,n)=>{const r=new Image,a=URL.createObjectURL(t);r.onload=()=>{URL.revokeObjectURL(a),s(r)},r.onerror=()=>{URL.revokeObjectURL(a),n(new Error("Failed to load image"))},r.src=a})}function sa(t){const{width:s,height:n}=t,r=s/n;let a,u;r>1?(a=Math.min(Pt,s),u=Math.floor(a/r)):(u=Math.min(Pt,n),a=Math.floor(u*r));const i=document.createElement("canvas");i.width=a,i.height=u;const p=i.getContext("2d");if(!p)throw new Error("Failed to get canvas context");return p.drawImage(t,0,0,a,u),i.toDataURL("image/webp",.8).split(",")[1]}async function na(t){const s=await la(t);return{thumbnail:sa(s),width:s.width,height:s.height}}function ra(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ia(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}var da=class{createPendingFile(t){return{id:ra(),name:t.name,mimeType:t.type,size:t.size,isImage:At(t.type),localPreviewUrl:null,status:"uploading"}}queueFiles(t){return Array.from(t).map(s=>({pending:this.createPendingFile(s),file:s}))}async executeUpload(t,s,n,r,a,u={}){const{generateThumbnail:i=!0,generatePreview:p=!0}=u,m=At(s.type);m&&p&&ia(s).then(x=>a({localPreviewUrl:x})).catch(x=>console.error("Failed to generate preview:",x));try{let x;if(m&&i)try{const v=await na(s);x={thumbnail:v.thumbnail,width:v.width,height:v.height}}catch(v){console.warn("Failed to generate thumbnail:",v)}const d=await r.uploadFile(t,s,x);return a({id:d.id,status:"ready",path:d.path,width:d.width,height:d.height}),d}catch(x){throw a({status:"error",error:x instanceof Error?x.message:"Failed to upload file"}),x}}async executeUploads(t,s,n,r,a={}){const u=s.map(({pending:i,file:p})=>this.executeUpload(t,p,i.id,n,m=>r(i.id,m),a).catch(m=>m instanceof Error?m:new Error(String(m))));return Promise.all(u)}};function ua(t){if(t.length===0)return[];const s=[];let n=0;for(;n<t.length;){const r=t[n];if(r.role==="assistant"&&r.tool_calls){let a;try{a=JSON.parse(r.tool_calls)}catch{s.push(r),n++;continue}const u=[],i=[];let p=r.reasoning_content||null,m="completed";const x=r.id,d=r.created_at,v=r.depth;r.status==="pending"?m="pending":r.status==="failed"&&(m="failed"),r.content&&i.push(r.content);for(const b of a)u.push({id:b.id||r.id,type:"tool_call",name:b.function?.name,content:b.function?.arguments||null,status:null,tool_call_id:b.id});let c=n+1;for(;c<t.length;){const b=t[c];if(b.role==="tool"){const V=b.tool_status||"pending";u.push({id:b.id,type:"tool_result",name:b.name||void 0,content:b.content,status:V,tool_call_id:b.tool_call_id||void 0}),c++}else if(b.role==="assistant"&&b.tool_calls){let V;try{V=JSON.parse(b.tool_calls)}catch{break}b.status==="pending"?m="pending":b.status==="failed"&&m!=="pending"&&(m="failed"),b.content&&i.push(b.content),!p&&b.reasoning_content&&(p=b.reasoning_content);for(const P of V)u.push({id:P.id||b.id,type:"tool_call",name:P.function?.name,content:P.function?.arguments||null,status:null,tool_call_id:P.id});c++}else break}const k=new Set(u.filter(b=>b.type==="tool_call").map(b=>b.tool_call_id)),g=u.filter(b=>b.type==="tool_result"&&b.tool_call_id&&!k.has(b.tool_call_id));for(const b of g){const V=u.indexOf(b),P=b.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",U={id:`synthetic-${b.tool_call_id}`,type:"tool_call",name:P,content:null,status:b.status,tool_call_id:b.tool_call_id};u.splice(V,0,U)}for(const b of u)if(b.type==="tool_call"&&b.tool_call_id&&b.status===null){const V=u.find(P=>P.type==="tool_result"&&P.tool_call_id===b.tool_call_id);V?b.status=V.status:b.status="pending"}const h=i.length>0?i.join(""):null,w={id:x,type:"workblock",content:h,reasoning_content:p,workItems:u,status:m,created_at:d,depth:v};s.push(w),n=c}else s.push(r),n++}return s}var ao=Symbol("StandardAgents"),lo=Symbol("Thread"),ca={install(t,s){if(!s?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const r={client:new oo(s.endpoint),endpoint:s.endpoint};t.provide(ao,r)}};function pa(){const t=Zt(ao);if(!t)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return t}var jt=new da;function ma(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>{const u=r.result.split(",")[1];s(u)},r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(t)})}function va(t,s={}){const{preload:n=!0,live:r=!0,useWorkblocks:a=!1,depth:u=0,includeSilent:i=!1,endpoint:p}=s,m=W(()=>Io(t)),x=pa(),d=p?new oo(p):x.client,v={preload:n,live:r,useWorkblocks:a,depth:u,includeSilent:i},c=f([]),k=f("disconnected"),g=f(n),h=f(null),w=f([]),b=f([]),V=f([]),P=W(()=>{const I=new Set(b.value.map(ae=>ae.path));return[...w.value.filter(ae=>!ae.path||!I.has(ae.path)),...b.value]}),U=new Map;let q=null;const K=W(()=>a?ua(c.value):c.value);async function R(){g.value=!0,h.value=null;try{const I=await d.getMessages(m.value,{depth:u,includeSilent:i});c.value=I}catch(I){h.value=I instanceof Error?I:new Error(String(I))}finally{g.value=!1}}async function j(){try{const I=await d.listFiles(m.value);b.value=I.filter(ee=>!ee.isDirectory).map(ee=>({id:ee.path,name:ee.name,path:ee.path,mimeType:ee.mimeType,size:ee.size,isImage:ee.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(I){console.error("Failed to load files:",I)}}function Z(I){if(I.file.isDirectory)return;const ee={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ae=b.value.findIndex(me=>me.path===I.path);ae>=0?b.value[ae]=ee:b.value=[...b.value,ee]}function N(I){if(I.file.isDirectory)return;const ee={id:I.path,name:I.file.name,path:I.path,mimeType:I.file.mimeType,size:I.file.size,isImage:I.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},ae=b.value.findIndex(me=>me.path===I.path);ae>=0?b.value[ae]=ee:b.value=[...b.value,ee]}function F(I){b.value=b.value.filter(ee=>ee.path!==I.path)}function B(){r&&(q=new aa(d,m.value,{onStatusChange:I=>{k.value=I},onMessage:I=>{if(I.type==="message_data"){const ee=c.value.findIndex(ae=>ae.id===I.data.id);ee>=0?c.value[ee]=I.data:c.value=[...c.value,I.data]}},onChunk:I=>{const ee=c.value.findIndex(ae=>ae.id===I.message_id);if(ee>=0){const ae=c.value[ee];c.value[ee]={...ae,content:(ae.content||"")+I.chunk}}},onEvent:I=>{I.eventType==="file_created"?Z(I.data):I.eventType==="file_updated"?N(I.data):I.eventType==="file_deleted"&&F(I.data);const ee=U.get(I.eventType);ee&&ee.forEach(ae=>{try{ae(I.data)}catch(me){console.error(`Error in event listener for "${I.eventType}":`,me)}})},onError:I=>{h.value=I instanceof Error?I:new Error(String(I))}},{depth:u,includeSilent:i}),q.connect())}async function y(I){const ee=`optimistic-${crypto.randomUUID()}`,ae=V.value.map(fe=>({id:fe.id,type:"file",path:"",name:fe.name,mimeType:fe.mimeType,size:fe.size,width:fe.width,height:fe.height,localPreviewUrl:fe.previewUrl||void 0})),me={id:ee,role:I.role,content:I.content,attachments:ae.length>0?JSON.stringify(ae):null,created_at:Date.now()*1e3,status:"pending"};c.value=[...c.value,me];const $e=[...V.value];V.value=[];try{const fe=await Promise.all($e.map(async we=>({name:we.name,mimeType:we.mimeType,data:await ma(we.file),width:we.width,height:we.height}))),ke=await d.sendMessage(m.value,{...I,attachments:fe.length>0?fe:void 0});return c.value=c.value.filter(we=>we.id!==ee),$e.forEach(we=>{we.previewUrl&&URL.revokeObjectURL(we.previewUrl)}),ke}catch(fe){throw V.value=$e,c.value=c.value.filter(ke=>ke.id!==ee),h.value=fe instanceof Error?fe:new Error(String(fe)),fe}}async function $(){try{await d.stopExecution(m.value)}catch(I){throw h.value=I instanceof Error?I:new Error(String(I)),I}}async function E(I){const ee=[...c.value];c.value=c.value.filter(ae=>ae.id!==I);try{await d.deleteMessage(m.value,I)}catch(ae){throw c.value=ee,h.value=ae instanceof Error?ae:new Error(String(ae)),ae}}function _(I){const ee=jt.queueFiles(I);w.value=[...w.value,...ee.map(ae=>ae.pending)];for(const{pending:ae,file:me}of ee)jt.executeUpload(m.value,me,ae.id,d,$e=>{w.value=w.value.map(fe=>fe.id===ae.id?{...fe,...$e}:fe)}).catch(()=>{})}function S(I){w.value=w.value.filter(ee=>ee.id!==I)}function L(I){return I.path?d.getFileUrl(m.value,I.path):""}function J(I){return I.path?d.getThumbnailUrl(m.value,I.path):""}function X(I){return I.isImage?I.localPreviewUrl?I.localPreviewUrl:I.path?J(I):null:null}function G(I){const ae=(I instanceof FileList?Array.from(I):Array.isArray(I)?I:[I]).map(me=>{const $e=me.type.startsWith("image/");return{id:crypto.randomUUID(),file:me,name:me.name,mimeType:me.type,size:me.size,isImage:$e,previewUrl:$e?URL.createObjectURL(me):null}});V.value=[...V.value,...ae]}function D(I){const ee=V.value.find(ae=>ae.id===I);ee?.previewUrl&&URL.revokeObjectURL(ee.previewUrl),V.value=V.value.filter(ae=>ae.id!==I)}function O(){V.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)}),V.value=[]}function A(I,ee){return U.has(I)||U.set(I,new Set),U.get(I).add(ee),()=>{const ae=U.get(I);ae&&(ae.delete(ee),ae.size===0&&U.delete(I))}}function de(){q?.disconnect(),q=null,k.value="disconnected"}return pe(m,(I,ee)=>{I!==ee&&(de(),c.value=[],h.value=null,w.value=[],b.value=[],V.value.forEach(ae=>{ae.previewUrl&&URL.revokeObjectURL(ae.previewUrl)}),V.value=[],n&&R(),j(),B())}),Te(()=>{n&&R(),j(),B()}),Ne(()=>{q?.disconnect(),U.clear(),V.value.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)})}),{threadId:m,options:v,messages:c,workblocks:K,status:k,connectionStatus:k,isLoading:g,loading:g,error:h,sendMessage:y,stopExecution:$,deleteMessage:E,onEvent:A,subscribeToEvent:A,files:P,addFiles:_,removeFile:S,getFileUrl:L,getThumbnailUrl:J,getPreviewUrl:X,attachments:V,addAttachment:G,removeAttachment:D,clearAttachments:O}}var ha=re({name:"ThreadProvider",props:{threadId:{type:String,required:!0},preload:{type:Boolean,default:void 0},live:{type:Boolean,default:void 0},useWorkblocks:{type:Boolean,default:void 0},depth:{type:Number,default:void 0},includeSilent:{type:Boolean,default:void 0},endpoint:{type:String,default:void 0}},setup(t,{slots:s}){const n={};t.preload!==void 0&&(n.preload=t.preload),t.live!==void 0&&(n.live=t.live),t.useWorkblocks!==void 0&&(n.useWorkblocks=t.useWorkblocks),t.depth!==void 0&&(n.depth=t.depth),t.includeSilent!==void 0&&(n.includeSilent=t.includeSilent),t.endpoint!==void 0&&(n.endpoint=t.endpoint);const r=va(()=>t.threadId,n);return Lo(lo,r),()=>s.default?.()}});function so(){const t=Zt(lo);if(!t)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return t}const fa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ga(t,s){return o(),l("svg",fa,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 8V4H8"}),e("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const Ot=Ie({name:"lucide-bot",render:ga}),ba={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xa(t,s){return o(),l("svg",ba,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const Ut=Ie({name:"lucide-message-square",render:xa}),ya={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ka(t,s){return o(),l("svg",ya,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),e("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),e("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const wa=Ie({name:"lucide-cpu",render:ka}),_a={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $a(t,s){return o(),l("svg",_a,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Ca=Ie({name:"lucide-server",render:$a}),Sa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ta(t,s){return o(),l("svg",Sa,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Va=Ie({name:"lucide-wrench",render:Ta}),Ma={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ia(t,s){return o(),l("svg",Ma,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const La=Ie({name:"lucide-settings",render:Ia}),Ea={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Aa(t,s){return o(),l("svg",Ea,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Pa=Ie({name:"lucide-chevron-left",render:Aa}),ja={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Oa(t,s){return o(),l("svg",ja,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"4"}),e("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const Ua=Ie({name:"lucide-sun",render:Oa}),Ra={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Da(t,s){return o(),l("svg",Ra,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const Ba=Ie({name:"lucide-moon",render:Da}),Na={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fa(t,s){return o(),l("svg",Na,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const qa=Ie({name:"lucide-activity",render:Fa}),za={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ha(t,s){return o(),l("svg",za,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const Wa=Ie({name:"lucide-function-square",render:Ha}),Ja={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Za(t,s){return o(),l("svg",Ja,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const Ka=Ie({name:"lucide-log-out",render:Za}),Ga={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Xa(t,s){return o(),l("svg",Ga,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),e("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const Ya=Ie({name:"lucide-users",render:Xa}),Qa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function el(t,s){return o(),l("svg",Qa,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),e("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const tl=Ie({name:"lucide-key",render:el}),ol={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function al(t,s){return o(),l("svg",ol,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 7v14m-9-3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4a4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3a3 3 0 0 0-3-3z"},null,-1)])])}const ll=Ie({name:"lucide-book-open",render:al}),sl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nl(t,s){return o(),l("svg",sl,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},null,-1)])])}const rl=Ie({name:"lucide-external-link",render:nl}),no="agentbuilder-accent-theme",ro=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],kt=f("purple");let Rt=!1;function io(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function il(t){try{localStorage.setItem(no,t)}catch{}}function dl(){try{const t=localStorage.getItem(no);if(t&&ro.includes(t))return t}catch{}return"purple"}function uo(){if(Rt)return;Rt=!0;const t=dl();kt.value=t,io(t)}function ul(){uo();function t(s){kt.value=s,io(s),il(s)}return{theme:kt,themes:ro,setTheme:t}}const Ye=re({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const s=t,n=f(),r=f(),a=f(),u=f(0),i=(d,v,c,k,g,h)=>{d.beginPath(),d.moveTo(v+h,c),d.lineTo(v+k-h,c),d.quadraticCurveTo(v+k,c,v+k,c+h),d.lineTo(v+k,c+g-h),d.quadraticCurveTo(v+k,c+g,v+k-h,c+g),d.lineTo(v+h,c+g),d.quadraticCurveTo(v,c+g,v,c+g-h),d.lineTo(v,c+h),d.quadraticCurveTo(v,c,v+h,c),d.closePath()},p=async()=>{if(await Ce(),!n.value||!r.value||!a.value)return;const d=n.value.getContext("2d");if(!d)return;const v=a.value.getBoundingClientRect(),c=a.value.firstElementChild;if(c){const w=getComputedStyle(c);u.value=parseFloat(w.borderRadius)||0}const k=v.width+s.offsetX+4,g=v.height+s.offsetY+4;n.value.width=k,n.value.height=g,n.value.style.width=`${k}px`,n.value.style.height=`${g}px`,d.clearRect(0,0,n.value.width,n.value.height);const h=document.documentElement.classList.contains("dark");if(d.fillStyle=h?"#6b7280":"black",d.globalAlpha=s.intensity,d.save(),i(d,s.offsetX,s.offsetY,v.width,v.height,u.value),d.clip(),s.pattern==="crosshatch"){const w=h?4:3;d.lineWidth=1,d.strokeStyle=h?"#6b7280":"black";for(let b=-v.height;b<v.width;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY),d.lineTo(s.offsetX+b+v.height,s.offsetY+v.height),d.stroke();for(let b=0;b<v.width+v.height;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY+v.height),d.lineTo(s.offsetX+b-v.height,s.offsetY),d.stroke()}else if(s.pattern==="dots"){const b=h?3:2,V=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let P=0;P<v.width;P+=b)for(let U=0;U<v.height;U+=b){const q=Math.floor(P/b)%4,K=Math.floor(U/b)%4;V[K][q]/16<s.intensity&&d.fillRect(s.offsetX+P,s.offsetY+U,1,1)}}else if(s.pattern==="diagonal"){const w=h?5:4;d.lineWidth=1,d.strokeStyle=h?"#6b7280":"black";for(let b=-v.height;b<v.width;b+=w)d.beginPath(),d.moveTo(s.offsetX+b,s.offsetY),d.lineTo(s.offsetX+b+v.height,s.offsetY+v.height),d.stroke()}d.restore()};let m=null,x=null;return Te(()=>{m=new ResizeObserver(()=>{p()}),a.value&&m.observe(a.value),p(),x=new MutationObserver(()=>{p()}),x.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Ne(()=>{a.value&&m&&m.unobserve(a.value),x&&x.disconnect()}),pe(()=>[s.offsetX,s.offsetY,s.intensity,s.pattern],()=>{p()}),(d,v)=>(o(),l("div",{ref_key:"container",ref:r,class:"relative",style:lt({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:n,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:a,class:"relative"},[Ke(d.$slots,"default")],512)],4))}}),co="/agents/assets/img/agent-builder-logo-light.svg",po="/agents/assets/img/agent-builder-logo-dark.svg",cl="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(31,41,55);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(31,41,55);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",pl="data:image/svg+xml,%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20150%20150'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%20id='Artboard1'%20transform='matrix(1,0,0,1,1,1)'%3e%3crect%20x='-1'%20y='-1'%20width='150'%20height='150'%20style='fill:none;'/%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.816,92.912L108.064,59.193C103.573,53.307%20101.473,45.937%20102.197,38.566L105.475,5.046L99.553,4.466L96.312,37.643C95.895,41.808%2091.44,44.27%2087.71,42.369L30.34,13.394L27.659,18.7L84.686,47.494C87.184,48.762%2087.076,52.347%2084.504,53.452L0.387,89.671L2.741,95.139L86.189,59.211C88.76,58.106%2091.422,60.587%2090.48,63.231L62.918,141.119L68.532,143.111L96.384,64.408C97.507,61.257%20101.672,60.605%20103.7,63.249L129.107,96.498L133.834,92.876L133.816,92.912Z'%20style='fill:rgb(249,250,251);fill-opacity:0.5;fill-rule:nonzero;'/%3e%3c/g%3e%3cg%20transform='matrix(1.034881,0,0,1.034881,4.124225,0)'%3e%3cpath%20d='M133.925,90.214L107.648,7.346C106.036,2.257%20100.875,-0.821%2095.624,0.193L32.64,12.344C29.959,12.869%2027.605,14.408%2026.066,16.6C25.523,17.36%2025.07,18.211%2024.744,19.117L0.622,86.284C-0.917,90.594%200.459,95.375%204.081,98.164L59.568,141.137C61.469,142.604%2063.733,143.346%2066.015,143.346C68.079,143.346%2070.144,142.731%2071.937,141.517L129.832,102.111C133.707,99.468%20135.355,94.687%20133.943,90.232L133.925,90.214ZM116.92,85.922L47.127,53.923C44.374,52.673%2043.994,48.925%2046.421,47.132L94.175,11.873C97.416,9.483%20102.034,10.95%20103.284,14.771C108.173,29.548%20118.64,62.054%20124.218,79.457C125.631,83.876%20121.121,87.859%20116.902,85.94L116.92,85.922ZM79.162,15.567L42.455,42.659C40.083,44.415%2036.696,43.057%2036.189,40.16L33.781,26.342C33.038,22.05%2035.845,17.94%2040.119,17.089C49.409,15.241%2065.254,12.145%2076.681,9.917C79.995,9.265%2081.879,13.557%2079.162,15.567ZM29.126,34.238L31.716,49.069C31.915,50.21%2031.607,51.388%2030.865,52.275L16.559,69.587C15.291,71.127%2012.846,69.732%2013.516,67.849L25.704,33.93C26.32,32.21%2028.8,32.427%2029.126,34.22L29.126,34.238ZM12.882,83.386L29.543,63.231C31.517,60.84%2035.356,61.547%2036.352,64.499L56.308,123.661C57.322,126.668%2053.809,129.149%2051.31,127.193C41.223,119.297%2024.4,106.132%2014.404,98.164C9.84,94.542%209.152,87.878%2012.864,83.386L12.882,83.386ZM63.498,126.305L43.161,66.002C42.056,62.706%2045.407,59.681%2048.576,61.13L117.337,92.677C121.375,94.524%20121.864,100.083%20118.206,102.6C107.358,110.061%2088.326,123.064%2076.826,130.815C71.991,134.074%2065.381,131.829%2063.516,126.305L63.498,126.305Z'%20style='fill:rgb(249,250,251);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function ml(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function at(){return ml().mountPoint}function le(t){const s=at(),n=t.startsWith("/")?t:`/${t}`;return s==="/"?n:`${s}${n}`}const vl=["src"],hl=["src"],fl={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},gl={class:"flex flex-col gap-1 px-2"},bl={key:0},xl=["onClick","title"],yl={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},kl={key:0,class:"ml-4 space-y-0.5"},wl=["onClick"],_l={class:"whitespace-nowrap overflow-hidden text-ellipsis"},$l=["onClick","title"],Cl={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Sl={class:"flex flex-col gap-1 px-2"},Tl=["title"],Vl={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Ml={class:"relative settings-menu-container"},Il={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Ll={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg py-2 min-w-[200px]"},El={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Al=["title"],Pl={class:"relative z-10 flex items-center justify-center w-8 h-full"},jl={class:"relative z-10 flex items-center justify-center w-8 h-full"},Ol={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Ul={class:"grid grid-cols-5 gap-3"},Rl=["onClick","title"],Dl={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Bl={key:0,class:"text-sm overflow-hidden whitespace-nowrap max-w-0 group-hover:max-w-[60px] group-hover:ml-2 transition-all duration-200"},Nl=re({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:s}){function n(F){if(F.startsWith("/src/")||F.startsWith("data:"))return F;const B=at();return B==="/"?F.replace("/agents/","/"):F.replace("/agents/",`${B}/`)}const r=n(co),a=n(po),u=n(cl),i=n(pl),p=t,m=We(),x=ot(),d=W(()=>m.name);function v(F){const B=m.path;return B===F.path||B.startsWith(F.path+"/")}const c=W(()=>p.isDark?a:r),k=W(()=>p.isDark?i:u),g=[{id:"threads",label:"Threads",icon:qa,path:"/threads"},{id:"agents",label:"Agents",icon:Ot,path:"/agents"},{id:"prompts",label:"Prompts",icon:Ut,path:"/prompts"},{id:"tools",label:"Tools",icon:Va,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Wa,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Ut,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:Ot,path:"/tools#agents"}]},{id:"models",label:"Models",icon:wa,path:"/models"},{id:"providers",label:"Providers",icon:Ca,path:"/providers"}],h=F=>{x.push(F)},w=F=>{x.push(F),V.value=!1},b=W(()=>typeof d.value=="string"&&(d.value==="tools"||d.value.startsWith("tools-"))),V=f(!1),{theme:P,themes:U,setTheme:q}=ul(),K={amber:"bg-amber-500",lime:"bg-lime-500",emerald:"bg-emerald-500",sky:"bg-sky-500",blue:"bg-blue-500",indigo:"bg-indigo-500",purple:"bg-purple-500",fuchsia:"bg-fuchsia-500",pink:"bg-pink-500",white:"bg-neutral-400 dark:bg-neutral-500"},R=W(()=>d.value==="users"||d.value==="api-keys"),j=()=>{V.value=!V.value},Z=()=>{localStorage.removeItem("auth_token"),x.push("/login")},N=F=>{const B=F.target;V.value&&!B.closest(".settings-menu-container")&&(V.value=!1)};return Te(()=>{document.addEventListener("click",N)}),Ne(()=>{document.removeEventListener("click",N)}),(F,B)=>(o(),l("aside",{class:Q(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:Q(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?T("",!0):(o(),l("img",{key:0,src:c.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,vl)),e("button",{onClick:B[0]||(B[0]=y=>F.$emit("toggle-sidebar")),class:Q(`p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors ${t.isCollapsed?"m-auto":"border border-black/20 dark:border-white/20 opacity-50 hover:opacity-100"}`),"aria-label":"Toggle sidebar"},[t.isCollapsed?(o(),l("img",{key:1,src:k.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,hl)):(o(),Y(H(Pa),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",fl,[e("div",gl,[(o(),l(he,null,ye(g,y=>(o(),l(he,{key:y.id},[y.hasSubnav?(o(),l("div",bl,[e("button",{onClick:$=>h(y.path),class:Q(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",b.value?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),Y(Ze(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?T("",!0):(o(),l("span",yl,C(y.label),1))],10,xl),!t.isCollapsed&&y.subnav?(o(),l("div",kl,[(o(!0),l(he,null,ye(y.subnav,$=>(o(),l("button",{key:$.id,onClick:E=>h($.path),class:Q(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",d.value===$.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(o(),Y(Ze($.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",_l,C($.label),1)],10,wl))),128))])):T("",!0)])):(o(),l("button",{key:1,onClick:$=>h(y.path),class:Q(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",v(y)?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?y.label:void 0},[(o(),Y(Ze(y.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?T("",!0):(o(),l("span",Cl,C(y.label),1))],10,$l))],64))),64))]),e("div",Sl,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:Q(["flex items-center gap-3 px-3 py-2 rounded text-sm transition-all","hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white",t.isCollapsed&&"justify-center"]),title:t.isCollapsed?"Documentation":void 0},[M(H(ll),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?T("",!0):(o(),l("span",Vl," Docs ")),t.isCollapsed?T("",!0):(o(),Y(H(rl),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Tl),e("div",{class:Q(["flex items-center gap-1 pt-2 mt-1 border-t border-black/10 dark:border-white/10",t.isCollapsed?"flex-col":"justify-between"])},[e("div",Ml,[e("button",{onClick:Me(j,["stop"]),class:Q(["p-2 rounded transition-colors flex items-center",V.value||R.value?"bg-black/10 dark:bg-white/10 text-black dark:text-white":"hover:bg-black/5 dark:hover:bg-white/10 text-neutral-600 dark:text-neutral-400 hover:text-black dark:hover:text-white"]),title:"Settings"},[M(H(La),{class:"w-5 h-5 flex-shrink-0"})],2),V.value?(o(),l("div",Il,[M(Ye,{"offset-x":6,"offset-y":6,intensity:.4},{default:ce(()=>[e("div",Ll,[e("div",El,[B[4]||(B[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:B[1]||(B[1]=Me(y=>F.$emit("toggle-theme"),["stop"])),class:"relative flex items-center h-7 rounded-full bg-neutral-200 dark:bg-neutral-800 hover:bg-neutral-300 dark:hover:bg-neutral-700 transition-colors",title:t.isDark?"Switch to light mode":"Switch to dark mode"},[e("span",{class:Q(["absolute top-0.5 h-6 w-8 rounded-full bg-white dark:bg-black shadow-sm transition-transform duration-200",t.isDark?"translate-x-[calc(100%-2px)]":"translate-x-0.5"])},null,2),e("span",Pl,[M(H(Ua),{class:Q(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",jl,[M(H(Ba),{class:Q(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Al)]),e("div",Ol,[B[5]||(B[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Ul,[(o(!0),l(he,null,ye(H(U),y=>(o(),l("button",{key:y,onClick:Me($=>H(q)(y),["stop"]),class:Q(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[K[y],H(P)===y?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:y.charAt(0).toUpperCase()+y.slice(1)},[H(P)===y?(o(),l("span",Dl)):T("",!0)],10,Rl))),128))])]),e("button",{onClick:B[2]||(B[2]=y=>w("/settings/users")),class:Q(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[M(H(Ya),{class:"w-4 h-4 flex-shrink-0"}),B[6]||(B[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:B[3]||(B[3]=y=>w("/settings/api-keys")),class:Q(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",d.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[M(H(tl),{class:"w-4 h-4 flex-shrink-0"}),B[7]||(B[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])]),_:1})])):T("",!0)]),e("button",{onClick:Z,class:"group p-2 rounded hover:bg-red-500/10 transition-colors text-neutral-600 dark:text-neutral-400 hover:text-red-600 dark:hover:text-red-400 flex items-center",title:"Logout"},[M(H(Ka),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?T("",!0):(o(),l("span",Bl,"Logout"))])],2)])])],2))}}),Fl={class:"warning-banner-container"},ql={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},zl={class:"flex items-center gap-2"},Hl=["onClick"],Wl=re({__name:"WarningBanner",setup(t){const s=f([]),n=f(new Set),r=async()=>{if(localStorage.getItem("auth_token"))try{const m=await fetch(le("/api/diagnostics"));if(m.ok){const x=await m.json();s.value=x.warnings||[]}}catch{}},a=p=>{const m=`${p.type}:${p.details?.name||p.message}`;n.value.add(m)},u=p=>{const m=`${p.type}:${p.details?.name||p.message}`;return!n.value.has(m)},i=p=>{if(p.type==="duplicate_tool_name"){const m=p.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${p.details?.name}" (defined as both ${m}). This may cause unexpected behavior.`}return p.message};return Te(()=>{r()}),(p,m)=>(o(),l("div",Fl,[(o(!0),l(he,null,ye(s.value,x=>(o(),l(he,{key:`${x.type}:${x.details?.name}`},[u(x)?(o(),l("div",ql,[e("div",zl,[m[0]||(m[0]=e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),e("span",null,C(i(x)),1)]),e("button",{onClick:d=>a(x),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...m[1]||(m[1]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,Hl)])):T("",!0)],64))),128))]))}}),Jl={key:2,class:"flex-1 overflow-auto my-3 mr-4 border border-neutral-300 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 flex flex-col"},Zl={class:"flex-1 overflow-auto"},Kl=re({__name:"App",setup(t){uo();const s=We(),n=f(!1),r=f(!1),a=W(()=>s.name!=="login"),u=()=>{n.value=!n.value},i=()=>{r.value=!r.value,r.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Te(()=>{const p=localStorage.getItem("theme");(p==="dark"||!p&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(r.value=!0,document.documentElement.classList.add("dark"))}),(p,m)=>(o(),l("div",{class:Q(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":r.value}])},[a.value?(o(),Y(Nl,{key:0,"is-collapsed":n.value,"is-dark":r.value,onToggleSidebar:u,onToggleTheme:i},null,8,["is-collapsed","is-dark"])):T("",!0),a.value?(o(),l("main",Jl,[M(Wl),e("div",Zl,[M(H(Vt))])])):(o(),Y(H(Vt),{key:1}))],2))}}),Qe=(t,s)=>{const n=t.__vccOpts||t;for(const[r,a]of s)n[r]=a;return n},Gl=Qe(Kl,[["__scopeId","data-v-2125e5d3"]]),Xl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yl(t,s){return o(),l("svg",Xl,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const Ql=Ie({name:"lucide-trash-2",render:Yl}),es={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ts(t,s){return o(),l("svg",es,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const os=Ie({name:"lucide-edit",render:ts}),as={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ls(t,s){return o(),l("svg",as,[...s[0]||(s[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const wt=Ie({name:"lucide-eye",render:ls}),ss={class:"w-full"},ns={class:"border border-black dark:border-neutral-300 rounded overflow-hidden"},rs={class:"overflow-x-auto"},is={class:"w-full"},ds={class:"border-b border-black dark:border-neutral-300"},us={key:0,class:"px-4 py-3 text-right font-medium text-sm"},cs={key:0},ps=["colspan"],ms={key:1},vs=["colspan"],hs=["innerHTML"],fs={key:0,class:"px-4 py-3 text-right"},gs={class:"inline-flex gap-1"},bs=["onClick","title"],He=re({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1}},setup(t){const s=u=>{switch(u){case"edit":return os;case"delete":return Ql;case"view":return wt;default:return null}},n=(u,i)=>{const p=u[i.key];return i.formatter?i.formatter(p):p??"-"},r=u=>{switch(u){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},a=(u,i)=>{if(u.confirm){const p=u.confirmMessage||`Are you sure you want to ${u.label.toLowerCase()}?`;confirm(p)&&u.handler(i)}else u.handler(i)};return(u,i)=>(o(),l("div",ss,[e("div",ns,[e("div",rs,[e("table",is,[e("thead",ds,[e("tr",null,[(o(!0),l(he,null,ye(t.columns,p=>(o(),l("th",{key:p.key,class:Q(["px-4 py-3 font-medium text-sm",r(p.align),p.width||""])},C(p.label),3))),128)),t.actions&&t.actions.length>0?(o(),l("th",us," Actions ")):T("",!0)])]),e("tbody",null,[t.loading?(o(),l("tr",cs,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},[...i[0]||(i[0]=[e("div",{class:"inline-flex items-center gap-2"},[e("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),Ve(" Loading... ")],-1)])],8,ps)])):t.data.length===0?(o(),l("tr",ms,[e("td",{colspan:t.columns.length+(t.actions?1:0),class:"px-4 py-8 text-center text-neutral-500"},C(t.emptyMessage),9,vs)])):(o(!0),l(he,{key:2},ye(t.data,(p,m)=>(o(),l("tr",{key:m,class:"border-t border-neutral-200 dark:border-neutral-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(o(!0),l(he,null,ye(t.columns,x=>(o(),l("td",{key:x.key,class:Q(["px-4 py-3 text-sm",r(x.align)])},[Ke(u.$slots,`cell-${x.key}`,{value:p[x.key],row:p,column:x},()=>[x.html?(o(),l("span",{key:0,innerHTML:n(p,x)},null,8,hs)):(o(),l(he,{key:1},[Ve(C(n(p,x)),1)],64))])],2))),128)),t.actions&&t.actions.length>0?(o(),l("td",fs,[e("div",gs,[(o(!0),l(he,null,ye(t.actions,(x,d)=>(o(),l("button",{key:d,onClick:v=>a(x,p),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:x.label},[(o(),Y(Ze(s(x.icon)),{class:"w-4 h-4"}))],8,bs))),128))])])):T("",!0)]))),128))])])])])]))}}),xs=re({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(t,{expose:s,emit:n}){const r=n,a=f([]),u=f(!1),i=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:d=>d==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:d=>d||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:d=>d||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:d=>r("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await x(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],m=async()=>{u.value=!0;try{const d=await fetch(le("/api/agents"));if(d.ok){const v=await d.json();a.value=v.agents||[]}}catch(d){console.error("Error fetching agents:",d)}finally{u.value=!1}},x=async d=>{try{const v=await fetch(le(`/api/agents/${d.id}`),{method:"DELETE"});if(v.ok)await m();else{const c=await v.json();alert(c.error||"Failed to delete agent")}}catch(v){console.error("Error deleting agent:",v),alert("Failed to delete agent")}};return Te(()=>{m()}),s({refresh:m}),(d,v)=>(o(),l("div",null,[M(He,{columns:i,data:a.value,actions:p,loading:u.value,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])]))}}),ys={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ks(t,s){return o(),l("svg",ys,[...s[0]||(s[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const mo=Ie({name:"lucide-x",render:ks}),ws={key:0,class:"w-full max-w-md"},_s={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},$s={class:"text-xl font-bold text-red-600"},Cs={class:"p-6"},Ss={class:"text-neutral-700 dark:text-neutral-300 mb-6"},Ts={class:"flex justify-end gap-3"},vo=re({__name:"ConfirmDialog",props:{modelValue:{type:Boolean},title:{default:"Confirm Action"},message:{default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{default:"Continue"},cancelText:{default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(t,{emit:s}){const n=t,r=s,a=()=>{r("update:modelValue",!1)},u=()=>{r("confirm"),a()},i=()=>{r("cancel"),a()},p=m=>{m.key==="Escape"&&n.modelValue&&i()};return pe(()=>n.modelValue,m=>{m?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")}),(m,x)=>(o(),Y(vt,{to:"body"},[M(Ge,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:i},[M(Ge,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ce(()=>[t.modelValue?(o(),l("div",ws,[M(Ye,{"offset-x":12,"offset-y":12,intensity:.4},{default:ce(()=>[e("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:x[0]||(x[0]=Me(()=>{},["stop"]))},[e("div",_s,[e("h2",$s,C(t.title),1),e("button",{onClick:i,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[M(H(mo),{class:"w-5 h-5 text-red-600"})])]),e("div",Cs,[e("p",Ss,C(t.message),1),e("div",Ts,[e("button",{onClick:i,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors"},C(t.cancelText),1),e("button",{onClick:u,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},C(t.confirmText),1)])])])]),_:1})])):T("",!0)]),_:1})])):T("",!0)]),_:1})]))}}),Vs={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-neutral-300 flex-shrink-0"},Ms={class:"text-xl font-bold"},Is={class:"overflow-y-auto flex-1"},Ls={class:"p-6"},Es={key:0,class:"p-6 border-t-2 border-black dark:border-neutral-300 flex-shrink-0"},Be=re({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0}},emits:["update:modelValue","close"],setup(t,{emit:s}){const n=t,r=s,a=f(),u=f(!1),i=f(new Map),p=()=>a.value&&(a.value.querySelector("input")||a.value.querySelector("textarea")||a.value.querySelector("select")||a.value.querySelector("[contenteditable]")||a.value.querySelector(".monaco-editor")),m=()=>{if(!a.value)return;a.value.querySelectorAll(".monaco-editor-container").forEach(U=>{const q=U.__monacoEditor;if(q&&typeof q.getValue=="function"){const K=q.getValue();i.value.set(U,K)}})},x=()=>{if(!a.value)return!1;const P=a.value.querySelectorAll(".monaco-editor-container");for(const U of P){const q=U.__monacoEditor;if(q&&typeof q.getValue=="function"){const K=q.getValue(),R=i.value.get(U);if(R===void 0||(q.getRawOptions?.()||{}).readOnly===!0)continue;if(K!==R)return!0}}return!1},d=()=>{if(n.hasChanges!==void 0)return n.hasChanges;if(!a.value)return!1;if(x())return!0;const P=a.value.querySelectorAll("form");for(const q of P){const R=q.querySelectorAll("input, textarea, select");for(const j of R){const Z=j;if(Z.type==="checkbox"||Z.type==="radio"){const N=Z;if(N.checked!==N.defaultChecked)return!0}else if(Z.tagName==="SELECT"){const N=Z;if(N.value!==N.defaultValue)return!0}else if(Z.value!==Z.defaultValue)return!0}}const U=a.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const q of U){const K=q;if(K.type==="checkbox"||K.type==="radio"){const R=K;if(R.checked!==R.defaultChecked)return!0}else if(K.tagName==="SELECT"){const R=K;if(R.value!==R.defaultValue)return!0}else if(K.value!==K.defaultValue)return!0}return!1},v=()=>{p()&&d()?u.value=!0:c()},c=()=>{r("update:modelValue",!1),r("close")},k=()=>{u.value=!1,c()},g=()=>{u.value=!1},h=P=>{P.key==="Escape"&&n.modelValue&&(p()||c())};pe(()=>n.modelValue,async P=>{P?(document.addEventListener("keydown",h),document.body.style.overflow="hidden",await Ce(),setTimeout(()=>{m()},100)):(document.removeEventListener("keydown",h),document.body.style.overflow="",i.value.clear())});const w=f(!1),b=P=>{w.value=P.target===P.currentTarget},V=P=>{P.target===P.currentTarget&&w.value&&(p()||c()),w.value=!1};return(P,U)=>(o(),Y(vt,{to:"body"},[M(Ge,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:b,onClick:V},[M(Ge,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ce(()=>[t.modelValue?(o(),l("div",{key:0,class:Q(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[M(Ye,{"offset-x":12,"offset-y":12,intensity:.4},{default:ce(()=>[e("div",{ref_key:"modalRef",ref:a,class:Q(["bg-white dark:bg-black border-2 border-black dark:border-neutral-300 flex flex-col max-h-[85vh]",t.minHeight])},[e("div",Vs,[e("h2",Ms,C(t.title),1),e("button",{onClick:v,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[M(H(mo),{class:"w-5 h-5"})])]),e("div",Is,[e("div",Ls,[Ke(P.$slots,"default")])]),P.$slots.footer?(o(),l("div",Es,[Ke(P.$slots,"footer")])):T("",!0)],2)]),_:3})],2)):T("",!0)]),_:3})],32)):T("",!0)]),_:3}),M(vo,{modelValue:u.value,"onUpdate:modelValue":U[0]||(U[0]=q=>u.value=q),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:k,onCancel:g},null,8,["modelValue"])]))}}),As={class:"space-y-1.5"},Ps={key:0,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},js={key:0,class:"text-red-500"},Os=["type","value","placeholder","disabled"],Us={key:1,class:"text-xs text-red-500 dark:text-red-400"},Ee=re({__name:"TextInput",props:{modelValue:{},label:{},placeholder:{},type:{default:"text"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","click"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(null),i=W(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors placeholder:text-neutral-400 dark:placeholder:text-neutral-500",r.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",r.disabled?"opacity-50 cursor-not-allowed":""]),p=d=>{const v=d.target;a("update:modelValue",v.value)},m=d=>{a("focus",d)},x=d=>{a("click",d)};return s({inputRef:u}),(d,v)=>(o(),l("div",As,[t.label?(o(),l("label",Ps,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",js,"*")):T("",!0)])):T("",!0),e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:Q(i.value),onInput:p,onFocus:m,onClick:x},null,42,Os),t.error?(o(),l("p",Us,C(t.error),1)):T("",!0)]))}}),Rs={class:"space-y-1"},Ds={key:0,class:"block text-sm font-medium"},Bs={key:0,class:"text-red-500"},Ns=["value","placeholder","disabled","rows"],Fs={key:1,class:"text-xs text-red-500 dark:text-red-400"},ho=re({__name:"TextareaInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{default:4}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50 cursor-not-allowed":""]),u=i=>{const p=i.target;r("update:modelValue",p.value)};return(i,p)=>(o(),l("div",Rs,[t.label?(o(),l("label",Ds,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",Bs,"*")):T("",!0)])):T("",!0),e("textarea",{value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,class:Q(a.value),onInput:u},null,42,Ns),t.error?(o(),l("p",Fs,C(t.error),1)):T("",!0)]))}}),qs={key:0,class:"block text-sm font-medium mb-2"},zs={key:0,class:"text-red-500"},Hs=["disabled","aria-expanded"],Ws={class:"flex items-center justify-between gap-1"},Js={key:0,class:"flex items-center gap-2 text-neutral-400 flex-1 min-w-0"},Zs={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},Ks=["src","alt"],Gs={class:"block truncate"},Xs={key:2,class:"block truncate text-neutral-400 flex-1 min-w-0"},Ys={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden"},Qs={class:"p-2 border-b border-neutral-200 dark:border-neutral-700"},en=["placeholder"],tn={class:"max-h-60 overflow-y-auto"},on={key:0,class:"px-4 py-3 text-sm text-neutral-500 dark:text-neutral-400"},an=["onClick","onMouseenter"],ln={class:"flex-shrink-0 w-5 h-5 mt-0.5"},sn=["src","alt"],nn={key:1,class:"w-full h-full bg-neutral-200 dark:bg-neutral-700 rounded"},rn={class:"flex-1 min-w-0"},dn={class:"text-sm font-medium text-black dark:text-white"},un={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},cn={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"},_e=re({__name:"SelectInput",props:{modelValue:{},options:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},label:{},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},error:{},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=f(!1),u=f(""),i=f(),p=f(),m=f(),x=f(),d=f(-1),v=W(()=>n.options.find(j=>j.value===n.modelValue)),c=W(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",n.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-neutral-300 focus:ring-black dark:focus:ring-white"]),k=W(()=>{if(!u.value)return n.options;const j=u.value.toLowerCase();return n.options.filter(Z=>Z.label.toLowerCase().includes(j)||Z.value.toLowerCase().includes(j)||Z.description&&Z.description.toLowerCase().includes(j))});pe(k,()=>{d.value=-1});const g=()=>{n.disabled||(a.value?b():(a.value=!0,u.value="",d.value=-1,Ce(()=>{if(x.value&&(x.value.setAttribute("popover","auto"),x.value.addEventListener("toggle",R),"showPopover"in x.value))try{x.value.showPopover()}catch{}V(),setTimeout(()=>i.value?.focus(),0)})))},h=j=>{r("update:modelValue",j.value),b(),u.value="",d.value=-1},w=j=>{j.stopPropagation(),r("update:modelValue","")},b=()=>{if(x.value){if("hidePopover"in x.value)try{x.value.hidePopover()}catch{}x.value.removeEventListener("toggle",R)}a.value=!1,d.value=-1},V=()=>{if(!m.value||!x.value)return;const j=m.value.getBoundingClientRect();x.value.offsetWidth||j.width,x.value.style.position="fixed",x.value.style.top=`${j.bottom+8}px`,x.value.style.left=`${j.left}px`,x.value.style.width=`${j.width}px`,x.value.style.margin="0"},P=j=>{p.value&&!p.value.contains(j.target)&&x.value&&!x.value.contains(j.target)&&b()},U=j=>{j.key==="Escape"&&a.value&&(b(),m.value?.focus())},q=j=>{if(!a.value)return;const Z=k.value;if(Z.length!==0)switch(j.key){case"ArrowDown":j.preventDefault(),d.value=d.value<Z.length-1?d.value+1:0,K();break;case"ArrowUp":j.preventDefault(),d.value=d.value>0?d.value-1:Z.length-1,K();break;case"Enter":j.preventDefault(),d.value>=0&&d.value<Z.length&&h(Z[d.value]);break}},K=()=>{Ce(()=>{const j=x.value?.querySelector(".highlighted-option");j&&j.scrollIntoView({block:"nearest",behavior:"smooth"})})},R=j=>{j.target===x.value&&(a.value=j.newState==="open",a.value&&V())};return Te(()=>{document.addEventListener("click",P),document.addEventListener("keydown",U);const j=()=>{a.value&&V()};window.addEventListener("resize",j),window.addEventListener("scroll",j,!0)}),Ne(()=>{document.removeEventListener("click",P),document.removeEventListener("keydown",U),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}),(j,Z)=>(o(),l("div",{ref_key:"dropdownRef",ref:p,class:"relative"},[t.label?(o(),l("label",qs,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",zs,"*")):T("",!0)])):T("",!0),e("button",{ref_key:"buttonRef",ref:m,type:"button",onClick:g,disabled:t.disabled,"aria-expanded":a.value,"aria-haspopup":!0,class:Q(c.value)},[e("div",Ws,[t.loading?(o(),l("span",Js,[...Z[1]||(Z[1]=[e("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),Ve(" Loading... ",-1)])])):v.value?(o(),l("span",Zs,[v.value.icon?(o(),l("img",{key:0,src:v.value.icon,alt:v.value.label,class:"w-5 h-5 flex-shrink-0"},null,8,Ks)):T("",!0),e("span",Gs,C(v.value.label),1)])):(o(),l("span",Xs,C(t.placeholder),1)),v.value&&!t.disabled?(o(),l("button",{key:3,type:"button",onClick:w,class:"flex-shrink-0 p-0.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":"Clear selection"},[...Z[2]||(Z[2]=[e("svg",{class:"h-4 w-4 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):T("",!0),Z[3]||(Z[3]=e("svg",{class:"h-5 w-5 text-neutral-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,Hs),a.value?(o(),l("div",{key:1,ref_key:"popoverRef",ref:x,class:"dropdown-popover"},[M(Ye,{"offset-x":4,"offset-y":4,intensity:.3},{default:ce(()=>[e("div",Ys,[e("div",Qs,[Pe(e("input",{ref_key:"searchInput",ref:i,"onUpdate:modelValue":Z[0]||(Z[0]=N=>u.value=N),type:"text",placeholder:t.searchPlaceholder,onKeydown:q,class:"w-full px-3 py-1.5 text-sm border border-neutral-300 dark:border-neutral-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-neutral-400 dark:placeholder:text-neutral-500"},null,40,en),[[De,u.value]])]),e("div",tn,[k.value.length===0?(o(),l("div",on," No options found ")):T("",!0),(o(!0),l(he,null,ye(k.value,(N,F)=>(o(),l("button",{key:N.value,type:"button",onClick:B=>h(N),onMouseenter:B=>d.value=F,class:Q(["w-full px-4 py-2 text-left hover:bg-neutral-100 dark:hover:bg-neutral-900 focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none flex items-start gap-3",{"bg-neutral-50 dark:bg-neutral-900":N.value===t.modelValue,"bg-neutral-100 dark:bg-neutral-800 highlighted-option":F===d.value}])},[e("div",ln,[N.icon?(o(),l("img",{key:0,src:N.icon,alt:N.label,class:"w-full h-full"},null,8,sn)):(o(),l("div",nn))]),e("div",rn,[e("div",dn,C(N.label),1),N.description?(o(),l("div",un,C(N.description),1)):T("",!0)])],42,an))),128))])])]),_:1})],512)):T("",!0),t.error?(o(),l("p",cn,C(t.error),1)):T("",!0)],512))}}),pn={class:"flex items-start"},mn=["for"],vn=["id","checked","disabled"],hn={class:"flex items-center h-5"},fn={class:"flex-1"},gn={key:0,class:"text-red-500"},bn={key:1,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},xn={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"},je=re({__name:"CheckboxInput",props:{modelValue:{type:Boolean,default:!1},label:{},helpText:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(t,{emit:s}){const n=t,r=s,a=Eo(),u=W(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",n.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",n.disabled?"opacity-50":"hover:scale-110",n.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",n.modelValue?"before:block":"before:hidden"]),i=p=>{if(!n.disabled){const m=p.target;r("update:modelValue",m.checked)}};return(p,m)=>(o(),l("div",pn,[e("label",{for:H(a),class:Q(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:H(a),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:i,class:"absolute left-[-9999px]"},null,40,vn),e("div",hn,[e("span",{class:Q(u.value)},null,2)]),e("div",fn,[t.label?(o(),l("span",{key:0,class:Q(["block text-sm font-medium",{"opacity-50":t.disabled}])},[Ve(C(t.label)+" ",1),t.required?(o(),l("span",gn,"*")):T("",!0)],2)):T("",!0),t.helpText?(o(),l("p",bn,C(t.helpText),1)):T("",!0),t.error?(o(),l("p",xn,C(t.error),1)):T("",!0)])],10,mn)]))}}),yn={key:0,class:"min-h-[400px] flex items-center justify-center"},kn={key:1,class:"space-y-6 pr-2 pb-4"},wn={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg"},_n={class:"text-sm text-red-800 dark:text-red-200"},$n={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Cn={key:1,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Sn={key:1},Tn={key:2},Vn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Mn={key:3},In={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Ln={class:"grid grid-cols-2 gap-6"},En={class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},An={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Pn={class:"space-y-3"},jn={class:"flex items-start"},On={key:0,class:"ml-8 mt-2 space-y-2"},Un={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Rn={key:1},Dn={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},Bn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Nn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Fn={class:"space-y-4 p-4 bg-neutral-100 dark:bg-neutral-800 rounded-lg"},qn={class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"},zn={key:0,class:"flex flex-col items-center justify-center py-8"},Hn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Wn={class:"space-y-3"},Jn={class:"flex items-start"},Zn={key:0,class:"ml-8 mt-2 space-y-2"},Kn={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"},Gn={key:1},Xn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Yn={key:0,class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Qn={class:"flex justify-between"},er=["disabled"],tr=re({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>n.mode==="edit"),u=f(!1),i=f(""),p=f(""),m=f(""),x=f(null),d=f(""),v=f("dual_ai"),c=f(!1),k=f(""),g=f(""),h=f(null),w=f(""),b=f(""),V=f(""),P=f(""),U=f(!0),q=f(!1),K=f(""),R=f(""),j=f(""),Z=f(""),N=f(!1),F=f(null),B=f(""),y=f(""),$=f(""),E=f(""),_=f(""),S=f(""),L=f(!0),J=f(!1),X=f(""),G=f(""),D=f(""),O=f(""),A=f(null),de=f(""),I=f(""),ee=f(""),{data:ae,execute:me}=Ue(le("/api/prompts"),{immediate:!1}).json(),{data:$e,execute:fe}=Ue(le("/api/tools?schema=true"),{immediate:!1}).json(),ke=f(null),we=f(!1),Ae=f(null),oe=f(!1),ie=f(!1),ne=W(()=>{if(!ae.value)return[{value:"",label:"Select a prompt..."}];const ue=ae.value?.prompts||[];return[{value:"",label:"None"},...ue.map(z=>({value:z.id,label:z.name}))]}),be=ue=>$e.value?$e.value[ue]:null,xe=W(()=>!ke.value||!ke.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...ke.value.tools.map(ue=>{const z=typeof ue=="string"?ue:ue.name;return{value:z,label:z}})]),Le=W(()=>!Ae.value||!Ae.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ae.value.tools.map(ue=>{const z=typeof ue=="string"?ue:ue.name;return{value:z,label:z}})]),ve=W(()=>{if(!K.value)return[];const ue=be(K.value);return!ue||!ue.schema||!ue.schema.properties?[]:Object.keys(ue.schema.properties).map(z=>({value:z,label:z}))}),se=W(()=>{if(!X.value)return[];const ue=be(X.value);return!ue||!ue.schema||!ue.schema.properties?[]:Object.keys(ue.schema.properties).map(z=>({value:z,label:z}))}),ge=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Oe=W({get(){return p.value},set(ue){const z=x.value?.inputRef,te=z?.selectionStart??ue.length;let Fe=ue.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Fe.endsWith("_agent")||(Fe=Fe+"_agent"),p.value=Fe,z){z.value=Fe;const Re=Math.min(te,Fe.length-6);z.setSelectionRange(Re,Re)}}}),st=async()=>{await Ce();const ue=x.value?.inputRef;if(ue&&p.value.endsWith("_agent")){const z=p.value.length-6;ue.setSelectionRange(z,z)}},wo=ue=>!ue||ue==="_agent"?(m.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(ue)?(m.value="",!0):(m.value="Name must start with a letter",!1),nt=()=>{p.value="",i.value="",m.value="",d.value="",v.value="dual_ai",c.value=!1,k.value="",g.value="",h.value=null,w.value="",V.value="",P.value="",U.value=!0,q.value=!1,K.value="",R.value="",j.value="",Z.value="",N.value=!1,F.value=null,B.value="",y.value="",$.value="",ke.value=null,_.value="",S.value="",L.value=!0,J.value=!1,X.value="",G.value="",D.value="",O.value="",A.value=null,de.value="",I.value="",ee.value="",Ae.value=null},_o=async()=>{if(n.editAgent?.id){u.value=!0,ie.value=!0;try{const ue=await fetch(le(`/api/agents/${n.editAgent.id}`));if(ue.ok){const z=await ue.json(),te=z.agent||z;p.value=te.name||"",i.value=te.name||"",d.value=te.title||"",v.value=te.type||"dual_ai",c.value=te.expose_as_tool||!1,k.value=te.tool_description||"",h.value=te.max_session_turns;const Fe=te.side_a_stop_tool||"",Re=te.side_a_stop_tool_response_property||"",So=te.side_b_stop_tool||"",To=te.side_b_stop_tool_response_property||"",Vo=te.side_a_end_conversation_tool||"",Mo=te.side_b_end_conversation_tool||"";b.value=te.side_a_label||"",E.value=te.side_b_label||"",V.value=te.side_a_agent_prompt||"",_.value=te.side_b_agent_prompt||"",U.value=!!te.side_a_stop_on_response,q.value=!!te.side_a_stop_tool,N.value=!!te.side_a_manual_stop_condition,F.value=te.side_a_max_turns,L.value=!!te.side_b_stop_on_response,J.value=!!te.side_b_stop_tool,A.value=te.side_b_max_turns,await Ce(),K.value=Fe,j.value=Re,X.value=So,D.value=To,y.value=Vo,I.value=Mo}}catch(ue){console.error("Error loading agent data:",ue)}finally{u.value=!1,ie.value=!1}}},$o=async()=>{m.value="",w.value="",P.value="",R.value="",Z.value="",B.value="",$.value="",S.value="",G.value="",O.value="",de.value="",ee.value="";let ue=!1;wo(p.value)||(ue=!0);const z=p.value;v.value==="dual_ai"&&h.value!==null&&h.value!==void 0&&h.value<=0&&(w.value="Max session turns must be a positive number",ue=!0),V.value||(P.value="Please select an agent prompt",ue=!0);const te=U.value||K.value,Fe=v.value==="ai_human"&&N.value;if(!te&&!Fe&&(P.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",ue=!0),K.value&&!j.value&&(Z.value="Response property required when using stop tool",ue=!0),F.value!==null&&F.value<=0&&(B.value="Max turns must be a positive number",ue=!0),v.value==="dual_ai"&&!y.value&&!I.value&&($.value="At least one side must have an end conversation tool",ee.value="At least one side must have an end conversation tool",ue=!0),v.value==="dual_ai"&&(_.value||(S.value="Please select an agent prompt",ue=!0),X.value&&!D.value&&(O.value="Response property required when using stop tool",ue=!0),A.value!==null&&A.value<=0&&(de.value="Max turns must be a positive number",ue=!0)),ue)return;const Re={name:z,title:d.value||null,type:v.value,expose_as_tool:c.value,tool_description:c.value?k.value:null,max_session_turns:v.value==="dual_ai"?h.value:null,side_a_label:b.value||null,side_a_agent_prompt:V.value,side_a_stop_on_response:U.value,side_a_stop_tool:K.value||null,side_a_stop_tool_response_property:j.value||null,side_a_manual_stop_condition:N.value,side_a_max_turns:F.value,side_a_end_conversation_tool:y.value||null};v.value==="dual_ai"&&(Re.side_b_label=E.value||null,Re.side_b_agent_prompt=_.value,Re.side_b_stop_on_response=L.value,Re.side_b_stop_tool=X.value||null,Re.side_b_stop_tool_response_property=D.value||null,Re.side_b_max_turns=A.value,Re.side_b_end_conversation_tool=I.value||null),a.value&&n.editAgent?.id&&(Re.id=n.editAgent.id),r("save",Re)},Co=()=>{nt(),r("update:modelValue",!1)};return pe(V,async ue=>{if(ie.value||(K.value="",j.value=""),!ue){ke.value=null;return}we.value=!0;try{const z=await fetch(le(`/api/prompts/${ue}`));z.ok&&(ke.value=await z.json())}catch(z){console.error("Error fetching Side A prompt:",z)}finally{we.value=!1}}),pe(_,async ue=>{if(ie.value||(X.value="",D.value=""),!ue){Ae.value=null;return}oe.value=!0;try{const z=await fetch(le(`/api/prompts/${ue}`));z.ok&&(Ae.value=await z.json())}catch(z){console.error("Error fetching Side B prompt:",z)}finally{oe.value=!1}}),pe(q,ue=>{ue||(K.value="",j.value="")}),pe(J,ue=>{ue||(X.value="",D.value="")}),pe(()=>n.modelValue,async ue=>{ue?(await Promise.all([me(),fe()]),a.value?(nt(),await _o()):nt()):nt()}),(ue,z)=>(o(),Y(Be,{"model-value":t.modelValue,"onUpdate:modelValue":z[23]||(z[23]=te=>ue.$emit("update:modelValue",te)),title:a.value?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:ce(()=>[e("div",Qn,[e("button",{onClick:Co,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),e("button",{onClick:$o,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:u.value},C(a.value?"Update Agent":"Create Agent"),9,er)])]),default:ce(()=>[u.value?(o(),l("div",yn,[...z[24]||(z[24]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(o(),l("div",kn,[t.apiError?(o(),l("div",wn,[e("p",_n,C(t.apiError),1)])):T("",!0),e("div",null,[M(Ee,{ref_key:"nameInputRef",ref:x,modelValue:Oe.value,"onUpdate:modelValue":z[0]||(z[0]=te=>Oe.value=te),label:"Agent Name",error:m.value,required:"",disabled:a.value,onFocus:st,onClick:st},null,8,["modelValue","error","disabled"]),!m.value&&!a.value?(o(),l("p",$n," Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ")):T("",!0),a.value?(o(),l("p",Cn," Agent names cannot be changed after creation (used as foreign key for threads) ")):T("",!0)]),e("div",null,[M(Ee,{modelValue:d.value,"onUpdate:modelValue":z[1]||(z[1]=te=>d.value=te),label:"Display Title (Optional)"},null,8,["modelValue"]),z[25]||(z[25]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Human-readable title shown in the UI (e.g., Research Assistant). If not set, the name will be used. ",-1))]),e("div",null,[M(_e,{modelValue:v.value,"onUpdate:modelValue":z[2]||(z[2]=te=>v.value=te),label:"Agent Type",options:ge},null,8,["modelValue"]),z[26]||(z[26]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),v.value==="dual_ai"?(o(),l("div",Sn,[M(je,{modelValue:c.value,"onUpdate:modelValue":z[3]||(z[3]=te=>c.value=te),label:"Expose as Tool"},null,8,["modelValue"]),z[27]||(z[27]=e("p",{class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):T("",!0),c.value&&v.value==="dual_ai"?(o(),l("div",Tn,[M(ho,{modelValue:k.value,"onUpdate:modelValue":z[4]||(z[4]=te=>k.value=te),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:g.value,rows:3},null,8,["modelValue","error"]),g.value?T("",!0):(o(),l("p",Vn," This description helps other agents understand when to use this agent "))])):T("",!0),v.value==="dual_ai"?(o(),l("div",Mn,[M(Ee,{"model-value":h.value?.toString()||"","onUpdate:modelValue":z[5]||(z[5]=te=>h.value=te?parseInt(te):null),label:"Max Session Turns",type:"number",error:w.value,placeholder:"Unlimited"},null,8,["model-value","error"]),w.value?T("",!0):(o(),l("p",In," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):T("",!0),e("div",Ln,[e("div",En,[z[34]||(z[34]=e("h4",{class:"font-semibold text-base mb-4 text-neutral-800 dark:text-neutral-200"}," Side A (AI) ",-1)),e("div",null,[M(Ee,{modelValue:b.value,"onUpdate:modelValue":z[6]||(z[6]=te=>b.value=te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),z[28]||(z[28]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e("div",null,[M(_e,{modelValue:V.value,"onUpdate:modelValue":z[7]||(z[7]=te=>V.value=te),label:"Agent Prompt",options:ne.value,error:P.value,required:""},null,8,["modelValue","options","error"]),P.value?T("",!0):(o(),l("p",An," The prompt that defines this agent's behavior "))]),e("div",Pn,[z[31]||(z[31]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),z[32]||(z[32]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",jn,[M(je,{modelValue:U.value,"onUpdate:modelValue":z[8]||(z[8]=te=>U.value=te),label:"Stop when agent returns content"},null,8,["modelValue"])]),z[33]||(z[33]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[M(je,{modelValue:q.value,"onUpdate:modelValue":z[9]||(z[9]=te=>q.value=te),label:"Stop on specific tool call"},null,8,["modelValue"]),q.value?(o(),l("div",On,[M(_e,{modelValue:K.value,"onUpdate:modelValue":z[10]||(z[10]=te=>K.value=te),label:"Stop Tool",options:xe.value,error:R.value,placeholder:"Select a tool...",disabled:we.value||!V.value},null,8,["modelValue","options","error","disabled"]),R.value?T("",!0):(o(),l("p",Un," Agent stops when this tool is called ")),K.value?(o(),l("div",Rn,[M(_e,{modelValue:j.value,"onUpdate:modelValue":z[11]||(z[11]=te=>j.value=te),label:"Response Property",options:ve.value,error:Z.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),z[29]||(z[29]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):T("",!0)])):T("",!0)]),v.value==="ai_human"&&!U.value&&!q.value?(o(),l("div",Dn,[M(je,{modelValue:N.value,"onUpdate:modelValue":z[12]||(z[12]=te=>N.value=te),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),z[30]||(z[30]=e("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):T("",!0)]),e("div",null,[M(Ee,{"model-value":F.value?.toString()||"","onUpdate:modelValue":z[13]||(z[13]=te=>F.value=te?parseInt(te):null),label:"Max Turns",type:"number",error:B.value,placeholder:"Unlimited"},null,8,["model-value","error"]),B.value?T("",!0):(o(),l("p",Bn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[M(_e,{modelValue:y.value,"onUpdate:modelValue":z[14]||(z[14]=te=>y.value=te),label:"End Conversation Tool",options:xe.value,error:$.value,placeholder:"Select a tool...",disabled:we.value||!V.value},null,8,["modelValue","options","error","disabled"]),$.value?T("",!0):(o(),l("p",Nn," Tool that ends the entire conversation when called "))])]),e("div",Fn,[e("h4",qn," Side B ("+C(v.value==="ai_human"?"Human":"AI")+") ",1),e("div",null,[M(Ee,{modelValue:E.value,"onUpdate:modelValue":z[15]||(z[15]=te=>E.value=te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),z[35]||(z[35]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),v.value==="ai_human"?(o(),l("div",zn,[...z[36]||(z[36]=[e("svg",{class:"w-20 h-20 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),e("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(o(),l(he,{key:1},[e("div",null,[M(_e,{modelValue:_.value,"onUpdate:modelValue":z[16]||(z[16]=te=>_.value=te),label:"Agent Prompt",options:ne.value,error:S.value,required:""},null,8,["modelValue","options","error"]),S.value?T("",!0):(o(),l("p",Hn," The prompt that defines this agent's behavior "))]),e("div",Wn,[z[38]||(z[38]=e("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),z[39]||(z[39]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),e("div",Jn,[M(je,{modelValue:L.value,"onUpdate:modelValue":z[17]||(z[17]=te=>L.value=te),label:"Stop when agent returns content"},null,8,["modelValue"])]),z[40]||(z[40]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),e("div",null,[M(je,{modelValue:J.value,"onUpdate:modelValue":z[18]||(z[18]=te=>J.value=te),label:"Stop on specific tool call"},null,8,["modelValue"]),J.value?(o(),l("div",Zn,[M(_e,{modelValue:X.value,"onUpdate:modelValue":z[19]||(z[19]=te=>X.value=te),label:"Stop Tool",options:Le.value,error:G.value,placeholder:"Select a tool...",disabled:oe.value||!_.value},null,8,["modelValue","options","error","disabled"]),G.value?T("",!0):(o(),l("p",Kn," Agent stops when this tool is called ")),X.value?(o(),l("div",Gn,[M(_e,{modelValue:D.value,"onUpdate:modelValue":z[20]||(z[20]=te=>D.value=te),label:"Response Property",options:se.value,error:O.value,placeholder:"Select property..."},null,8,["modelValue","options","error"]),z[37]||(z[37]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Property from tool arguments to return as final response ",-1))])):T("",!0)])):T("",!0)])]),e("div",null,[M(Ee,{"model-value":A.value?.toString()||"","onUpdate:modelValue":z[21]||(z[21]=te=>A.value=te?parseInt(te):null),label:"Max Turns",type:"number",error:de.value,placeholder:"Unlimited"},null,8,["model-value","error"]),de.value?T("",!0):(o(),l("p",Xn," Maximum turns this side can take before yielding (safety limit) "))]),e("div",null,[M(_e,{modelValue:I.value,"onUpdate:modelValue":z[22]||(z[22]=te=>I.value=te),label:"End Conversation Tool",options:Le.value,error:ee.value,placeholder:"Select a tool...",disabled:oe.value||!_.value},null,8,["modelValue","options","error","disabled"]),ee.value?T("",!0):(o(),l("p",Yn," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"]))}}),or={},ar={class:"p-8 w-full max-w-7xl mx-auto"};function lr(t,s){return o(),l("div",ar,[Ke(t.$slots,"default")])}const et=Qe(or,[["render",lr]]),sr=re({__name:"AgentsView",setup(t){const s=ot(),n=We(),r=f(!1),a=f("add"),u=f(null),i=f(null),p=f(null);pe(()=>n.query.refresh,()=>{n.query.refresh&&(i.value?.refresh(),s.replace({path:"/agents",query:{}}))});const m=()=>{a.value="add",u.value=null,p.value=null,r.value=!0},x=v=>{a.value="edit",u.value=v,p.value=null,r.value=!0},d=async v=>{p.value=null;try{const c=a.value==="edit"&&u.value?.id,{originalName:k,...g}=v,h=le(c?`/api/agents/${u.value.id}`:"/api/agents"),b=await fetch(h,{method:c?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(b.ok)i.value?.refresh(),r.value=!1,u.value=null;else{const V=await b.json();p.value=V.error||`Failed to ${c?"update":"create"} agent`}}catch(c){console.error(`Error ${a.value==="edit"?"updating":"creating"} agent:`,c),p.value=`Failed to ${a.value==="edit"?"update":"create"} agent`}};return(v,c)=>(o(),Y(et,null,{default:ce(()=>[e("div",{class:"flex justify-between items-center mb-6"},[c[1]||(c[1]=e("h1",{class:"text-3xl font-bold"},"Agents",-1)),e("button",{onClick:m,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),c[2]||(c[2]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Configure and manage your AI agents. ",-1)),M(xs,{ref_key:"dataTableRef",ref:i,onAdd:m,onEdit:x},null,512),M(tr,{modelValue:r.value,"onUpdate:modelValue":c[0]||(c[0]=k=>r.value=k),mode:a.value,editAgent:u.value,apiError:p.value,onSave:d},null,8,["modelValue","mode","editAgent","apiError"])]),_:1}))}});function nr(t){const{limit:s=50,offset:n=0,agentId:r=null,userId:a=null,autoFetch:u=!0}={},i=W(()=>{const w=new URLSearchParams,b=typeof s=="number"?s:s.value,V=typeof n=="number"?n:n.value,P=typeof r=="string"?r:r?.value,U=typeof a=="string"?a:a?.value;return w.append("limit",b.toString()),w.append("offset",V.toString()),P&&w.append("agent_id",P),U&&w.append("user_id",U),le(`/api/threads?${w.toString()}`)}),{data:p,error:m,isFetching:x,isFinished:d,execute:v,abort:c}=Ue(i,{immediate:u}).get().json(),k=W(()=>p.value?.threads||[]),g=W(()=>p.value?.total||0),h=W(()=>p.value?.hasMore||!1);return{threads:k,total:g,hasMore:h,error:m,isFetching:x,isFinished:d,refetch:v,abort:c}}function Ct(t){const s=W(()=>!!(typeof t=="string"?t:t?.value)),n=W(()=>{const d=typeof t=="string"?t:t?.value;return le(d?`/api/threads/${d}`:"/api/threads/placeholder")}),{data:r,error:a,isFetching:u,isFinished:i,execute:p,abort:m}=Ue(n,{immediate:!1}).get().json();return pe(s,d=>{d&&p()},{immediate:!0}),{thread:W(()=>r.value?{id:r.value.thread.id,agent_id:r.value.thread.agent_id,user_id:r.value.thread.user_id,tags:r.value.thread.tags||[],created_at:r.value.thread.created_at,agent:r.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:r.value.stats}:null),error:a,isFetching:u,isFinished:i,refetch:p,abort:m}}function rr(t){const{autoConnect:s=!0,onEvent:n}=t||{},r=f(null),a=f(!1),u=f(null),i=()=>{r.value&&r.value.close();const m=window.location.protocol==="https:"?"wss:":"ws:",x=window.location.host;let d=`${m}//${x}${le("/api/events")}`;const v=localStorage.getItem("auth_token");v&&(d+=`?token=${encodeURIComponent(v)}`);try{r.value=new WebSocket(d),r.value.onopen=()=>{a.value=!0,u.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},r.value.onmessage=c=>{try{const k=JSON.parse(c.data);console.log("[AgentBuilderEvents] Received event:",k.type),n&&n(k)}catch(k){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",k)}},r.value.onerror=c=>{u.value="WebSocket connection error",a.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",c)},r.value.onclose=()=>{a.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(c){u.value=c.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",c)}},p=()=>{r.value&&(r.value.close(),r.value=null,a.value=!1)};return s&&i(),Ne(()=>{p()}),{wsConnected:a,wsError:u,connect:i,disconnect:p}}const ir={class:"inline-flex items-center justify-center"},Se=re({__name:"Loader",props:{size:{default:"md"}},setup(t){const s=t,n=W(()=>{switch(s.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}});return(r,a)=>(o(),l("div",ir,[e("div",{class:Q([n.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}});function dr(t){const n=Date.now()*1e3-t,r=Math.floor(n/1e6);if(r<60)return r===1?"1 second ago":`${r} seconds ago`;const a=Math.floor(r/60);if(a<60)return a===1?"1 minute ago":`${a} minutes ago`;const u=Math.floor(a/60);if(u<24)return u===1?"1 hour ago":`${u} hours ago`;const i=Math.floor(u/24);if(i<30)return i===1?"1 day ago":`${i} days ago`;const p=Math.floor(i/30);if(p<12)return p===1?"1 month ago":`${p} months ago`;const m=Math.floor(p/12);return m===1?"1 year ago":`${m} years ago`}function ur(t){const s=f("");let n=null;const r=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,a=()=>{const u=r();s.value=dr(u);const p=Date.now()*1e3-u,m=Math.floor(p/1e6);n!==null&&(clearInterval(n),n=null),m<60?n=setInterval(a,1e3):m<3600?n=setInterval(a,6e4):m<86400&&(n=setInterval(a,6e5))};return a(),Ne(()=>{n!==null&&clearInterval(n)}),s}const ct=re({__name:"TimeAgo",props:{timestamp:{}},setup(t){const s=t,n=ur(()=>s.timestamp);return(r,a)=>(o(),l("span",null,C(H(n)),1))}}),cr={class:"relative inline-flex items-center"},pr={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},mr={key:1,class:"inline-block w-2 h-2 rounded-full bg-red-500 dark:bg-red-400"},vr={key:2,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},hr={key:0},fr={key:1},gr={key:2},St=re({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const s=f(!1),n=f(null);return(r,a)=>(o(),l("div",cr,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:a[0]||(a[0]=u=>s.value=!0),onMouseleave:a[1]||(a[1]=u=>s.value=!1)},[t.connected?(o(),l("span",pr)):t.error?(o(),l("span",mr)):(o(),l("span",vr))],32),M(Ge,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ce(()=>[s.value?(o(),l("div",{key:0,ref_key:"popoverRef",ref:n,class:Q(["absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs rounded shadow-lg whitespace-nowrap z-50 border",{"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800 text-green-700 dark:text-green-300":t.connected,"bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800 text-red-700 dark:text-red-300":!t.connected&&t.error,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected&&!t.error}])},[t.connected?(o(),l("span",hr,"Live - Connected")):t.error?(o(),l("span",fr,"Connection Error")):(o(),l("span",gr,"Offline"))],2)):T("",!0)]),_:1})]))}}),br={class:"flex flex-col flex-1"},xr={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},yr={class:"flex items-center justify-between"},kr={class:"flex items-center gap-2"},wr={class:"flex items-center gap-2"},_r={class:"flex-1 overflow-y-auto text-xs"},$r={key:0,class:"p-2 flex justify-center"},Cr={key:1,class:"p-2 text-red-600 dark:text-red-400"},Sr={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12 text-base"},Tr={key:3},Vr=["id","onClick"],Mr={class:"flex items-center gap-2 mb-1"},Ir={class:"font-medium truncate flex-1 min-w-0"},Lr={class:"flex-shrink-0 text-neutral-500 dark:text-neutral-400"},Er={key:0,class:"flex flex-wrap gap-1"},Ar=re({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:s,emit:n}){const r=n;f("");const{threads:a,isFetching:u,isFinished:i,error:p,refetch:m}=nr(),x=f([]),d=f(new Set),v=W(()=>{const b=a.value.filter(U=>!d.value.has(U.id)),V=new Set(b.map(U=>U.id));return[...x.value.filter(U=>!V.has(U.id)&&!d.value.has(U.id)),...b].sort((U,q)=>q.created_at-U.created_at)}),c=async b=>{if(b.type==="thread_created"){const V={id:b.thread.id,agent_id:b.thread.agent_name,user_id:b.thread.user_id,tags:b.thread.tags||[],created_at:b.thread.created_at,agent:{name:b.thread.agent_name,title:void 0,type:"ai_human"}};x.value.unshift(V)}else b.type==="thread_deleted"&&(d.value.add(b.threadId),x.value=x.value.filter(V=>V.id!==b.threadId))},{wsConnected:k,wsError:g}=rr({onEvent:c});pe(a,()=>{x.value=[]});const h=f(!1);pe(()=>({threads:a.value,finished:i.value}),({threads:b,finished:V})=>{V&&!h.value&&(h.value=!0,r("threadsLoaded",b[0]?.id??null))},{immediate:!0}),s({refetch:m});const w=b=>{r("selectThread",b)};return(b,V)=>(o(),l("div",br,[e("div",xr,[e("div",yr,[e("div",kr,[M(H(Kt),{size:18,class:"shrink-0"}),V[2]||(V[2]=e("h2",{class:"text-base font-bold"},"Threads",-1)),M(St,{connected:H(k),error:H(g)},null,8,["connected","error"])]),e("div",wr,[e("button",{onClick:V[0]||(V[0]=P=>r("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),e("button",{onClick:V[1]||(V[1]=P=>r("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[M(H($t),{size:20})])])])]),e("div",_r,[H(u)?(o(),l("div",$r,[M(Se)])):H(p)?(o(),l("div",Cr," Error: "+C(H(p)),1)):v.value.length===0?(o(),l("div",Sr," No threads found ")):(o(),l("div",Tr,[(o(!0),l(he,null,ye(v.value,P=>(o(),l("button",{key:P.id,id:`thread-${P.id}`,class:Q(["w-full text-left px-2 py-2 border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative hover:ring-2 hover:ring-inset hover:ring-accent-400 dark:hover:ring-accent-400",{"bg-accent-100 dark:bg-accent-900 dark:text-white ring-2 ring-inset ring-accent-400 dark:ring-accent-400":t.selectedThreadId===P.id}]),onClick:U=>w(P.id)},[e("div",Mr,[e("span",Ir,C(P.agent.title||P.agent.name),1),e("span",Lr,[M(ct,{timestamp:P.created_at*1e6},null,8,["timestamp"])])]),P.tags.length>0?(o(),l("div",Er,[(o(!0),l(he,null,ye(P.tags,U=>(o(),l("span",{key:U,class:Q(["inline-block px-1.5 py-0.5 rounded text-[10px]",t.selectedThreadId===P.id?"bg-accent-400 dark:bg-accent-950 text-accent-950 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"])},C(U),3))),128))])):T("",!0)],10,Vr))),128))]))])]))}});function Pr(t,s={}){const n=f(null),r=f(!1),a=f(null);let u=null;try{u=so()}catch{}const i=u?.messages??f([]),p=W(()=>u?.status.value==="connected"),m=f(null);u?.loading??f(!1);const x=W(()=>i.value.some(_=>_.status==="pending")),d=f(!1),v=f(0),c=f(!1);function k(_){if(!n.value?.agent)return null;const S=n.value.agent,L=_==="assistant"?"A":"B";return L==="A"&&S.side_a_label?S.side_a_label:L==="B"&&S.side_b_label?S.side_b_label:null}function g(_,S){return _==="system"||S==="system"?!1:_!==S}function h(_){if(_){if(Array.isArray(_))return _.length>0?_:void 0;try{const S=JSON.parse(_);return Array.isArray(S)&&S.length>0?S:void 0}catch(S){console.error("Failed to parse attachments:",S);return}}}const w=W(()=>{const _=[],S=i.value.filter(X=>(X.depth??0)===0),L=new Map;for(let X=0;X<S.length;X++){const G=S[X],D=G.role;if(D==="tool"){const me=G.tool_call_id;if(me&&L.has(me)){const $e=L.get(me),fe=_[$e],ke=fe.items.find(we=>we.type==="tool_call"&&we.tool_call_id===me);if(ke){ke.response=G.content||"",ke.response_log_id=G.log_id;const we=(G.content||"").toLowerCase(),Ae=we.length,oe=we.includes("failed")||we.includes("error"),ie=Ae<500;oe&&ie?ke.response_status="failed":ke.response_status="success"}fe.updated_at=G.created_at,L.delete(me)}continue}const O=k(D==="tool"?"assistant":D),A=_[_.length-1],de=A?.role;A&&g(D,de)&&A.type==="work"&&!A.isComplete&&(A.isComplete=!0);let I=null;if(G.tool_calls)if(typeof G.tool_calls=="string")try{I=JSON.parse(G.tool_calls)}catch(me){console.error("Failed to parse tool_calls:",me)}else Array.isArray(G.tool_calls)&&(I=G.tool_calls);const ee=I&&I.length>0,ae=A?.type==="work"&&A.role===D&&!A.isComplete;if(ee){let me,$e;ae?(me=A,$e=_.length-1):(me={type:"work",id:G.id,role:D,items:[],created_at:G.created_at,updated_at:G.created_at,isComplete:!1,sideLabel:O,isExpanded:!1,request_sent_at:G.request_sent_at,response_completed_at:G.response_completed_at,status:G.status||"completed"},_.push(me),$e=_.length-1),G.reasoning_content&&me.items.push({id:`${G.id}-reasoning`,type:"reasoning",content:G.reasoning_content,created_at:G.created_at,log_id:G.log_id}),G.content&&me.items.push({id:`${G.id}-content`,type:"content",content:G.content,created_at:G.created_at,log_id:G.log_id}),I.forEach(fe=>{me.items.push({id:fe.id,type:"tool_call",content:fe.function.name,created_at:G.created_at,tool_name:fe.function.name,tool_call_id:fe.id,tool_arguments:fe.function.arguments,log_id:G.log_id,response:null,response_status:"pending",response_log_id:null}),L.set(fe.id,$e)}),me.updated_at=G.created_at,G.response_completed_at&&(me.response_completed_at=G.response_completed_at),G.status&&G.status!=="completed"?me.status=G.status:G.status==="completed"&&me.status==="pending"&&(me.status="completed")}else ae&&G.status!=="pending"&&(A.isComplete=!0),(G.content||D==="system"||G.status==="pending"||G.attachments)&&_.push({type:"text",id:G.id,role:D,content:G.content||"",attachments:h(G.attachments),created_at:G.created_at,log_id:G.log_id,sideLabel:O,isOptimistic:G.isOptimistic,status:G.status})}const J=_[_.length-1];return J?.type==="work"&&!J.isComplete&&(J.isComplete=!0),_});async function b(){if(!t.value){n.value=null;return}try{const _=await fetch(le(`/api/threads/${t.value}`));_.ok&&(n.value=await _.json())}catch(_){console.error("Error fetching thread info:",_)}}async function V(_){if(t.value){if(u?.deleteMessage){await u.deleteMessage(_);return}try{if(!(await fetch(le(`/api/threads/${t.value}/messages/${_}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(S){throw S}}}async function P(_,S){if(t.value)try{if(!(await fetch(le(`/api/threads/${t.value}/messages/${_}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S})})).ok)throw new Error("Failed to update message")}catch(L){throw L}}pe(t,async _=>{_?(r.value=!0,await b(),r.value=!1):n.value=null},{immediate:!0});const U=u?.sendMessage,q=u?.stopExecution,K=u?.attachments??f([]),R=u?.addAttachment??(()=>{}),j=u?.removeAttachment??(()=>{}),Z=u?.clearAttachments??(()=>{});function N(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function F(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function B(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function y(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function $(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function E(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:w,threadInfo:n,isFetching:r,isLoadingMore:c,error:a,wsConnected:p,wsError:m,isExecuting:x,hasMore:d,totalMessages:v,sendMessage:U,stopThread:q,attachments:K,addAttachment:R,removeAttachment:j,clearAttachments:Z,deleteMessageById:V,updateMessageContent:P,refetch:E,loadMoreMessages:N,connectWebSocket:F,disconnectWebSocket:B,addOptimisticMessage:y,removeOptimisticMessage:$}}const jr={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},Or={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},Ur=["src","alt"],Rr={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center p-1"},Dr={key:0,class:"text-white text-[10px] mb-1"},Br={class:"text-white text-[10px] truncate w-full text-center"},Nr={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},Fr=re({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(t,{emit:s}){const n=t,r=s,a=f(!0),u=f(!1),i=W(()=>n.attachment.mimeType.startsWith("image/")),p=W(()=>!!n.attachment.thumbnailBase64),m=W(()=>{if(!n.threadId||!n.attachment.path)return"";const g=n.attachment.path.startsWith("/")?n.attachment.path.slice(1):n.attachment.path;return le(`/api/threads/${n.threadId}/fs/${g}`)}),x=W(()=>i.value?n.attachment.thumbnailBase64?`data:image/webp;base64,${n.attachment.thumbnailBase64}`:m.value:"");function d(){a.value=!1,u.value=!1}function v(){a.value=!1,u.value=!0}function c(){r("remove",n.attachment.id)}function k(){m.value&&window.open(m.value,"_blank")}return(g,h)=>(o(),l("div",{class:Q(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-20 h-20":i.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!i.value,"cursor-pointer":i.value&&m.value}]),onClick:h[0]||(h[0]=w=>i.value&&m.value?k():void 0)},[i.value?(o(),l(he,{key:0},[a.value&&!u.value&&!p.value?(o(),l("div",jr,[...h[1]||(h[1]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):T("",!0),u.value&&!p.value?(o(),l("div",Or,[M(H(Gt),{size:24})])):T("",!0),Pe(e("img",{src:x.value||m.value,alt:t.attachment.name,class:"w-full h-full object-cover",onLoad:d,onError:v},null,40,Ur),[[Je,!a.value&&!u.value||p.value]]),e("div",Rr,[m.value?(o(),l("span",Dr,"Click to view")):T("",!0),e("span",Br,C(t.attachment.name),1)])],64)):(o(),l(he,{key:1},[M(H(Xt),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),e("span",Nr,C(t.attachment.name),1)],64)),t.showRemove?(o(),l("button",{key:2,onClick:Me(c,["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"},[M(H(Ao),{size:10})])):T("",!0)],2))}}),qr=["onMouseenter","onMouseleave","onClick"],zr=["onClick"],Hr={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"3",stroke:"currentColor",class:"w-3 h-3 text-white"},Wr={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2.5",stroke:"currentColor",class:"w-3 h-3 text-white"},Jr={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},Zr={key:0,class:"flex flex-wrap gap-2 mb-2"},Kr=["contenteditable","onInput"],Gr={key:2,class:"flex gap-1 items-center min-h-[1.5rem]"},Xr={key:0,class:"opacity-50"},Yr={key:1,class:"opacity-50 italic text-neutral-500 dark:text-neutral-400"},Qr=["onClick","onMouseenter"],ei={key:0,class:"space-y-1"},ti={class:"flex items-start gap-2"},oi={class:"flex-1 min-w-0"},ai={key:0,class:"truncate opacity-80"},li={key:1,class:"italic opacity-60"},si={class:"flex items-center gap-2 pl-5 opacity-60"},ni={class:"text-[10px]"},ri={class:"text-[10px]"},ii={key:1,class:"space-y-2"},di={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},ui={class:"text-[10px] italic"},ci={class:"text-[10px] ml-auto"},pi={key:0,class:"space-y-1"},mi=["onClick","onMouseenter"],vi={class:"font-mono text-[11px] flex-shrink-0"},hi={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},fi={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},gi={key:0,class:"pl-4 space-y-2 text-[10px]"},bi={key:0},xi={class:"w-full border-collapse"},yi={class:"py-0.5 pr-2 opacity-65 align-top"},ki={class:"py-0.5 opacity-85 break-all"},wi={key:1},_i=["onClick","onMouseenter"],$i={class:"whitespace-pre-wrap break-all"},Ci={key:1,class:"text-[10px]"},Si=["onClick"],Ti={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},Vi={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},Mi=re({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:s,emit:n}){const r=t,a=n;function u(D){const O=r.selectedForDelete?.has(D)??!1;a("selectionChange",D,!O)}function i(D,O){const de=D.target.innerText;a("messageEdit",O,de)}function p(D){return r.editedMessages?.has(D)??!1}const m=f(new Map);function x(D,O){O?m.value.set(D,O):m.value.delete(D)}function d(D){const O=r.messages.findIndex(A=>A.log_id===D);if(O<=0)return-1;for(let A=O-1;A>=0;A--){const de=r.messages[A];if(de.role==="user")return A;if(de.role==="assistant"&&de.log_id)break}return-1}function v(D){for(let O=0;O<r.messages.length;O++){const A=r.messages[O];if(A.log_id===D||A.type==="work"&&A.items&&A.items.some(ee=>ee.log_id===D||ee.response_log_id===D))return O}return-1}function c(D,O){const de=v(D);if(de===-1)return!1;const I=m.value.get(de);if(!I)return!1;const ee=r.messages[de];let ae=null;if(ee.role==="assistant"&&ee.log_id){const fe=d(ee.log_id);ae=fe!==-1?m.value.get(fe):null}const me=O.getBoundingClientRect(),$e=I.getBoundingClientRect();if($e.top<me.top){const we=(ae||I).getBoundingClientRect().top-me.top-10;O.scrollBy({top:we,behavior:"smooth"})}else if($e.bottom>me.bottom){const fe=$e.bottom-me.bottom+10;O.scrollBy({top:fe,behavior:"smooth"})}else if(ae){const fe=ae.getBoundingClientRect();if(fe.top<me.top){const ke=fe.top-me.top-10;O.scrollBy({top:ke,behavior:"smooth"})}}return!0}function k(D){for(const O of r.messages){if(O.type!=="work")continue;if(O.items.some(I=>I.log_id===D||I.response_log_id===D))return!0}return!1}s({scrollToLogId:c,hasWorkblockForLogId:k});function g(D){const O=r.messages[D];if(O.log_id)return O.log_id;if(O.role==="user")for(let A=D+1;A<r.messages.length;A++){const de=r.messages[A];if(de.log_id)return de.log_id;if(de.role==="user")break}return null}function h(D,O){return O?g(D)===O:!1}function w(D){const O=g(D);O&&a("messageHover",O)}function b(D){g(D)&&a("messageHover",null)}function V(D){const O=r.messages[D],A=g(D);A&&a("messageClick",O.id,A)}const P=f(new Set),U=f(new Set),q=f(new Set);function K(D){P.value.has(D)?P.value.delete(D):P.value.add(D)}function R(D){U.value.has(D)?U.value.delete(D):U.value.add(D)}function j(D){q.value.has(D)?q.value.delete(D):q.value.add(D)}function Z(D){if(!D)return{};try{return JSON.parse(D)}catch{return{raw:D}}}function N(D){if(!D)return null;const O=Z(D),A=Object.keys(O);if(A.length===0)return null;const de=O[A[0]];return typeof de=="string"?de:JSON.stringify(de)}function F(D){return new Date(D/1e3).toLocaleTimeString()}function B(D){const O=Math.round(D/1e6);if(O<1)return"< 1s";if(O<60)return`${O}s`;const A=Math.floor(O/60),de=O%60;return`${A}m ${de}s`}function y(D){if(D.status==="pending")return"...";if(!D.isComplete)return"Working...";let O;return D.request_sent_at&&D.response_completed_at?O=D.response_completed_at-D.request_sent_at:O=D.updated_at-D.created_at,`Worked for ${B(O)}`}function $(D){const O=D.filter(A=>A.type==="content");if(O.length===0){const A=D.filter(de=>de.type==="reasoning");return A.length>0?A[A.length-1].content:null}return O[O.length-1].content}function E(D){const A=D.trim().split(`
2
2
  `)[0];return A.length>60?A.substring(0,60):A}function _(D){return r.selectedMessageId===D.id?!0:r.selectedLogId?D.items.some(O=>O.log_id===r.selectedLogId||O.response_log_id===r.selectedLogId):!1}function S(D){return!!(r.selectedLogId&&(D.log_id===r.selectedLogId||D.response_log_id===r.selectedLogId))}function L(D){return r.hoveredLogId?D.items.some(O=>O.log_id===r.hoveredLogId||O.response_log_id===r.hoveredLogId):!1}function J(D){return!!(r.hoveredLogId&&(D.log_id===r.hoveredLogId||D.response_log_id===r.hoveredLogId))}function X(D){const O=[];for(const A of D.items)A.log_id&&O.push(A.log_id),A.response_log_id&&O.push(A.response_log_id);return O}function G(D){return D?D.trim():""}return(D,O)=>(o(),l("div",null,[(o(!0),l(he,null,ye(t.messages,(A,de)=>(o(),l("div",{key:A.id,ref_for:!0,ref:I=>x(de,I),class:"flex items-center gap-2 pb-3",onMouseenter:I=>w(de),onMouseleave:I=>b(de),onClick:I=>t.isEditMode?u(A.id):V(de)},[t.isEditMode&&A.role!=="system"?(o(),l("button",{key:0,onClick:Me(I=>u(A.id),["stop"]),class:Q(["flex-shrink-0 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",{"border-red-500 bg-red-500":t.selectedForDelete?.has(A.id),"border-green-500 bg-green-500":!t.selectedForDelete?.has(A.id)&&p(A.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!t.selectedForDelete?.has(A.id)&&!p(A.id)}])},[t.selectedForDelete?.has(A.id)?(o(),l("svg",Hr,[...O[4]||(O[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):p(A.id)?(o(),l("svg",Wr,[...O[5]||(O[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"},null,-1)])])):T("",!0)],10,zr)):T("",!0),e("div",{class:Q(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":A.role==="assistant","justify-end":A.role==="user","justify-center":A.role==="system","cursor-pointer":g(de)&&!t.isEditMode}])},[A.type==="text"&&A.role==="system"&&A.content?.includes("Execution stopped")?(o(),l("div",Jr,C(A.content),1)):A.type==="text"?(o(),l("div",{key:1,class:Q(["max-w-[80%] rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[A.silent?"bg-neutral-300 text-neutral-500 dark:bg-neutral-700 dark:text-neutral-400 opacity-70 border-2 border-dashed border-neutral-400 dark:border-neutral-500":!t.isEditMode&&A.role!=="user"&&h(de,t.selectedLogId)?"bg-accent-200 text-accent-950 dark:bg-accent-200 dark:text-accent-950 ring-2 ring-accent-400 dark:ring-accent-400":A.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":A.role==="user"?"bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":"bg-neutral-100 text-neutral-600 dark:bg-neutral-900 dark:text-neutral-400 text-xs",{"opacity-60":A.isOptimistic},{"ring-2 ring-accent-400 dark:ring-accent-400 !bg-accent-200 !text-accent-950 dark:!bg-accent-200 dark:!text-accent-950":!t.isEditMode&&A.role!=="user"&&g(de)&&!A.silent&&!h(de,t.selectedLogId)&&h(de,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&p(A.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&A.role!=="system"&&!p(A.id)}]])},[A.attachments?.length&&t.threadId?(o(),l("div",Zr,[(o(!0),l(he,null,ye(A.attachments,I=>(o(),Y(Fr,{key:I.id,attachment:I,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):T("",!0),A.content||t.isEditMode?(o(),l("div",{key:1,class:"whitespace-pre-wrap break-words text-sm outline-none",contenteditable:t.isEditMode&&A.role!=="system",onInput:I=>i(I,A.id),onClick:O[0]||(O[0]=I=>t.isEditMode&&I.stopPropagation())},C(G(A.content)),41,Kr)):A.status==="pending"?(o(),l("div",Gr,[...O[6]||(O[6]=[e("span",{class:"typing-dot",style:{"animation-delay":"0ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"150ms"}},null,-1),e("span",{class:"typing-dot",style:{"animation-delay":"300ms"}},null,-1)])])):T("",!0),A.status!=="pending"?(o(),l("div",{key:3,class:Q(["text-[10px] mt-1 opacity-50 flex gap-2",{"justify-start":A.role==="assistant","justify-end":A.role!=="assistant"}])},[A.sideLabel?(o(),l("span",Xr,C(A.sideLabel),1)):T("",!0),e("span",null,C(F(A.created_at)),1),A.silent?(o(),l("span",Yr," silent ")):T("",!0)],2)):T("",!0)],2)):A.type==="work"?(o(),l("div",{key:2,class:Q(["w-full rounded-lg px-3 py-2 text-xs transition-all border overflow-hidden",{"cursor-pointer":!t.isEditMode,"bg-neutral-50 text-neutral-700 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700":A.role==="assistant"&&!A.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":A.role==="user"&&!A.silent,"bg-neutral-200 text-neutral-500 border-neutral-400 dark:bg-neutral-800 dark:text-neutral-400 dark:border-neutral-600 opacity-70 border-dashed":A.silent,"ring-2 ring-accent-500":!t.isEditMode&&_(A),"ring-2 ring-accent-400":!t.isEditMode&&!_(A)&&L(A)}]),onClick:I=>!t.isEditMode&&(K(A.id),X(A)[0]&&a("messageClick",A.id,X(A)[0])),onMouseenter:I=>!t.isEditMode&&X(A)[0]&&a("messageHover",X(A)[0]),onMouseleave:O[3]||(O[3]=I=>!t.isEditMode&&a("messageHover",null))},[P.value.has(A.id)?(o(),l("div",ii,[e("div",di,[M(H(ht),{size:14,class:"flex-shrink-0"}),e("span",ui,C(y(A)),1),e("span",ci,C(A.items.length)+" operation"+C(A.items.length!==1?"s":""),1)]),(o(!0),l(he,null,ye(A.items,I=>(o(),l("div",{key:I.id,class:"mb-1"},[I.type==="tool_call"?(o(),l("div",pi,[e("div",{onClick:Me(ee=>{R(I.id),I.log_id&&a("messageClick",A.id,I.log_id)},["stop"]),onMouseenter:Me(ee=>I.log_id&&a("messageHover",I.log_id),["stop"]),onMouseleave:O[1]||(O[1]=Me(ee=>a("messageHover",null),["stop"])),class:Q(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":S(I),"ring-1 ring-accent-400":!S(I)&&J(I)}])},[U.value.has(I.id)?(o(),Y(H(ht),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(o(),Y(H(dt),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",vi,C(I.tool_name),1),N(I.tool_arguments)?(o(),l("span",hi,C(N(I.tool_arguments)),1)):T("",!0),I.response_status==="success"?(o(),l("span",fi,"✓")):I.response_status==="failed"?(o(),Y(H(Po),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):T("",!0)],42,mi),U.value.has(I.id)?(o(),l("div",gi,[I.tool_arguments?(o(),l("div",bi,[O[7]||(O[7]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",xi,[e("tbody",null,[(o(!0),l(he,null,ye(Z(I.tool_arguments),(ee,ae)=>(o(),l("tr",{key:ae,class:"border-b border-current border-opacity-10"},[e("td",yi,C(ae),1),e("td",ki,C(typeof ee=="object"?JSON.stringify(ee):ee),1)]))),128))])])])):T("",!0),I.response?(o(),l("div",wi,[O[8]||(O[8]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:Q(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&I.response_log_id===t.selectedLogId,"ring-1 ring-accent-400":t.hoveredLogId&&I.response_log_id===t.hoveredLogId&&I.response_log_id!==t.selectedLogId}]),onClick:Me(ee=>I.response_log_id&&a("messageClick",A.id,I.response_log_id),["stop"]),onMouseenter:Me(ee=>I.response_log_id&&a("messageHover",I.response_log_id),["stop"]),onMouseleave:O[2]||(O[2]=Me(ee=>a("messageHover",null),["stop"]))},[e("div",$i,C(G(I.response)),1)],42,_i)])):T("",!0)])):T("",!0)])):I.type==="reasoning"?(o(),l("div",Ci,[e("button",{onClick:Me(ee=>j(I.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[q.value.has(I.id)?(o(),Y(H(ht),{key:1,size:12,class:"flex-shrink-0"})):(o(),Y(H(dt),{key:0,size:12,class:"flex-shrink-0"})),O[9]||(O[9]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,Si),q.value.has(I.id)?(o(),l("div",Ti,C(G(I.content)),1)):T("",!0)])):I.type==="content"?(o(),l("div",Vi,C(G(I.content)),1)):T("",!0)]))),128))])):(o(),l("div",ei,[e("div",ti,[M(H(dt),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",oi,[$(A.items)?(o(),l("div",ai,C(E($(A.items)))+"... ",1)):(o(),l("div",li,C(y(A)),1))])]),e("div",si,[e("span",ni,C(A.items.length)+" operation"+C(A.items.length!==1?"s":""),1),e("span",ri,"• "+C(y(A)),1)])]))],42,Qr)):T("",!0)],2)],40,qr))),128))]))}}),Ii=Qe(Mi,[["__scopeId","data-v-07039c48"]]),Li={key:0,class:"overflow-hidden border-b border-neutral-300 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900"},Ei={class:"max-h-[400px] overflow-y-auto"},Ai={class:"flex items-center justify-between px-4 py-2 border-b border-neutral-200 dark:border-neutral-800 sticky top-0 bg-neutral-50 dark:bg-neutral-900"},Pi={class:"p-4"},ji={key:0,class:"flex justify-center py-4"},Oi={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-sm"},Ui={key:2,class:"space-y-3 text-sm"},Ri={class:"flex items-start gap-2"},Di={class:"font-mono text-xs break-all"},Bi={class:"flex items-start gap-2"},Ni={class:"flex-1"},Fi={key:0,class:"flex items-center gap-2"},qi={class:"text-xs text-neutral-500"},zi={key:1,class:"space-y-2"},Hi={class:"flex gap-2"},Wi=["disabled"],Ji=["disabled"],Zi={class:"flex items-start gap-2"},Ki={key:0,class:"flex items-start gap-2"},Gi={class:"font-mono text-xs"},Xi={class:"flex items-start gap-2"},Yi={class:"flex-1 flex items-center gap-2 flex-wrap"},Qi={key:1,class:"text-neutral-500 dark:text-neutral-500 italic text-xs"},ed={class:"flex items-start gap-2"},td=["disabled"],od={key:1,class:"flex justify-center py-2"},ad={key:1,class:"p-3 rounded border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 space-y-2"},ld={class:"flex items-center gap-4 text-xs"},sd={class:"font-mono font-bold ml-1"},nd={class:"font-mono font-bold ml-1"},rd={key:0,class:"text-xs"},id={class:"w-full"},dd={class:"py-1"},ud={class:"text-right py-1 font-mono"},cd={class:"text-right py-1 font-mono"},pd={class:"pt-2 border-t border-neutral-200 dark:border-neutral-800 flex justify-end"},md=["disabled"],vd={key:0},hd={key:1},fd=re({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread"],setup(t,{emit:s}){const n=t,r=s,{thread:a,isFetching:u,error:i}=Ct(W(()=>n.threadId)),p=f(!1),m=f(!1),x=f(!1),d=f(!1),v=f(""),c=f(!1),k=f(!1),g=f(null),{data:h,isFetching:w}=Ue(le("/api/agents"),{refetch:!0}).json(),b=W(()=>h.value?.agents?h.value.agents.filter(N=>N.type==="ai_human").map(N=>({value:N.id,label:N.title,description:`Type: ${N.type}`})):[]),V=W(()=>a.value?.agent.type==="ai_human"),P=N=>new Date(N*1e3).toLocaleString(),U=()=>{a.value&&(v.value=a.value.agent.id,x.value=!0)},q=()=>{x.value=!1,v.value=""},K=async()=>{if(!(!n.threadId||!v.value)){d.value=!0;try{const N=await fetch(le(`/api/threads/${n.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:v.value})});if(!N.ok){const F=await N.json();throw new Error(F.error||"Failed to update agent")}window.location.reload()}catch(N){console.error("Error updating agent:",N),alert(`Failed to update agent: ${N.message}`)}finally{d.value=!1}}},R=async()=>{if(n.threadId){k.value=!0,c.value=!0;try{const N=await fetch(le(`/api/threads/${n.threadId}/cost`));if(!N.ok){const F=await N.json();throw new Error(F.error||"Failed to fetch cost breakdown")}g.value=await N.json()}catch(N){console.error("Error fetching cost breakdown:",N),alert(`Failed to fetch cost breakdown: ${N.message}`),c.value=!1}finally{k.value=!1}}},j=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(N),Z=async()=>{if(n.threadId){m.value=!0;try{const N=await fetch(le(`/api/threads/${n.threadId}`),{method:"DELETE"});if(!N.ok){const F=await N.json();throw new Error(F.error||"Failed to delete thread")}r("threadDeleted",n.threadId)}catch(N){console.error("Error deleting thread:",N),alert(`Failed to delete thread: ${N.message}`)}finally{m.value=!1}}};return pe(()=>n.show,N=>{N||(x.value=!1,v.value="")}),(N,F)=>(o(),Y(Ge,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[400px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[400px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:ce(()=>[t.show&&t.threadId?(o(),l("div",Li,[e("div",Ei,[e("div",Ai,[F[6]||(F[6]=e("span",{class:"text-sm font-medium text-neutral-600 dark:text-neutral-400"},"Thread Info",-1)),e("button",{onClick:F[0]||(F[0]=B=>r("close")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Close metadata"},[M(H(jo),{size:16})])]),e("div",Pi,[H(u)?(o(),l("div",ji,[M(Se)])):H(i)?(o(),l("div",Oi," Error loading metadata: "+C(H(i)),1)):H(a)?(o(),l("div",Ui,[e("div",Ri,[F[7]||(F[7]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"ID",-1)),e("span",Di,C(H(a).id),1)]),e("div",Bi,[F[8]||(F[8]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Agent",-1)),e("div",Ni,[x.value?(o(),l("div",zi,[M(_e,{modelValue:v.value,"onUpdate:modelValue":F[1]||(F[1]=B=>v.value=B),options:b.value,loading:H(w),placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),e("div",Hi,[e("button",{onClick:K,disabled:d.value||!v.value,class:"px-2 py-1 text-xs bg-black dark:bg-white text-white dark:text-black hover:bg-black/80 dark:hover:bg-white/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"},C(d.value?"Saving...":"Save"),9,Wi),e("button",{onClick:q,disabled:d.value,class:"px-2 py-1 text-xs border border-black dark:border-neutral-300 hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed rounded"}," Cancel ",8,Ji)])])):(o(),l("div",Fi,[e("span",null,C(H(a).agent.title),1),e("span",qi,"("+C(H(a).agent.type)+")",1),V.value?(o(),l("button",{key:0,onClick:U,type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Change agent"},[M(H(xt),{size:12})])):T("",!0)]))])]),e("div",Zi,[F[9]||(F[9]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Created",-1)),e("span",null,C(P(H(a).created_at)),1)]),H(a).user_id?(o(),l("div",Ki,[F[10]||(F[10]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"User",-1)),e("span",Gi,C(H(a).user_id),1)])):T("",!0),e("div",Xi,[F[11]||(F[11]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 flex-shrink-0 text-left"},"Tags",-1)),e("div",Yi,[H(a).tags?.length>0?(o(!0),l(he,{key:0},ye(H(a).tags,B=>(o(),l("span",{key:B,class:"inline-block px-2 py-0.5 text-xs rounded bg-black text-white dark:bg-white dark:text-black"},C(B),1))),128)):(o(),l("span",Qi,"No tags")),e("button",{onClick:F[2]||(F[2]=B=>r("editThread")),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors",title:"Edit tags"},[M(H(xt),{size:12})])])]),e("div",ed,[F[14]||(F[14]=e("span",{class:"font-medium text-neutral-600 dark:text-neutral-400 w-14 shrink-0 text-left"},"Cost",-1)),!c.value&&!k.value?(o(),l("button",{key:0,onClick:R,disabled:k.value,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[M(H(Mt),{size:12}),F[12]||(F[12]=e("span",null,"View Costs",-1))],8,td)):T("",!0),k.value?(o(),l("div",od,[M(Se)])):T("",!0),c.value?(o(),l("button",{key:2,onClick:F[3]||(F[3]=B=>c.value=!1),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors"},[M(H(Mt),{size:12}),F[13]||(F[13]=e("span",null,"Hide Costs",-1))])):T("",!0)]),c.value&&g.value?(o(),l("div",ad,[e("div",ld,[e("div",null,[F[15]||(F[15]=e("span",{class:"text-neutral-500"},"Total:",-1)),e("span",sd,C(j(g.value.totalCost)),1)]),e("div",null,[F[16]||(F[16]=e("span",{class:"text-neutral-500"},"Avg/msg:",-1)),e("span",nd,C(j(g.value.avgCostPerMessage)),1)])]),g.value.modelBreakdown.length>0?(o(),l("div",rd,[e("table",id,[F[17]||(F[17]=e("thead",null,[e("tr",{class:"border-b border-neutral-300 dark:border-neutral-600"},[e("th",{class:"text-left py-1 font-medium text-neutral-500"}," Model "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Reqs "),e("th",{class:"text-right py-1 font-medium text-neutral-500"}," Cost ")])],-1)),e("tbody",null,[(o(!0),l(he,null,ye(g.value.modelBreakdown,B=>(o(),l("tr",{key:B.modelName},[e("td",dd,C(B.modelName),1),e("td",ud,C(B.requestCount),1),e("td",cd,C(j(B.totalCost)),1)]))),128))])])])):T("",!0)])):T("",!0),e("div",pd,[e("button",{onClick:F[4]||(F[4]=B=>p.value=!0),disabled:m.value,class:"flex items-center gap-1 px-2 py-1 text-xs text-red-600 border border-red-600 rounded hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[M(H(Oo),{size:12}),m.value?(o(),l("span",vd,"Deleting...")):(o(),l("span",hd,"Delete Thread"))],8,md)])])):T("",!0)])]),M(vo,{modelValue:p.value,"onUpdate:modelValue":F[5]||(F[5]=B=>p.value=B),title:"Delete Thread?",message:"Are you sure you want to delete this thread? This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete Thread","cancel-text":"Cancel",onConfirm:Z},null,8,["modelValue"])])):T("",!0)]),_:1}))}}),gd={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden"},bd={class:"px-3 py-2 border-b border-neutral-200 dark:border-neutral-700 flex items-center justify-between"},xd={class:"max-h-64 overflow-y-auto"},yd={key:0,class:"px-3 py-6 text-center text-neutral-500 dark:text-neutral-400 text-sm"},kd=["onClick"],wd={class:"text-xs truncate"},_d={class:"text-[10px] text-neutral-400 ml-auto"},$d=["href"],Cd={class:"shrink-0 text-neutral-500 dark:text-neutral-400"},Sd={class:"flex-1 min-w-0"},Td={class:"shrink-0 text-[10px] text-neutral-400 dark:text-neutral-500 ml-auto"},Vd={key:0,class:"text-blue-500"},Md={key:1,class:"text-red-500"},Id={key:2},Ld=["href"],Ed={class:"shrink-0 text-neutral-500 dark:text-neutral-400"},Ad={class:"flex-1 min-w-0"},Pd={class:"shrink-0 text-[10px] text-neutral-400 dark:text-neutral-500 ml-auto"},jd={key:0,class:"text-blue-500"},Od={key:1,class:"text-red-500"},Ud={key:2},Rd={class:"px-3 py-1.5 border-t border-neutral-200 dark:border-neutral-700 text-[10px] text-neutral-400 dark:text-neutral-500"},Dd=re({__name:"FilesDropdown",props:{threadId:{}},setup(t){const s=t;let n=null;try{n=so()}catch{}const r=n?.files??f([]),a=n?.addFiles??(()=>{}),u=f(null),i=f(null),p=f(null),m=f(new Set(["/attachments"]));function x(){if(!u.value||!i.value)return;const U=u.value.getBoundingClientRect(),q=320;let K=U.left+U.width/2-q/2;const R=8;K<R&&(K=R),K+q>window.innerWidth-R&&(K=window.innerWidth-q-R),i.value.style.top=`${U.bottom+4}px`,i.value.style.left=`${K}px`}function d(){i.value&&(i.value.matches(":popover-open")?i.value.hidePopover():(x(),i.value.showPopover()))}function v(){i.value?.matches(":popover-open")&&x()}Te(()=>{window.addEventListener("scroll",v,!0),window.addEventListener("resize",v)}),Ne(()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)});function c(U){if(U===0)return"0 B";const q=1024,K=["B","KB","MB","GB"],R=Math.floor(Math.log(U)/Math.log(q));return parseFloat((U/Math.pow(q,R)).toFixed(1))+" "+K[R]}function k(U){const q=U.startsWith("/")?U.slice(1):U;return le(`/api/threads/${s.threadId}/fs/${q}`)}function g(U,q){return q?Gt:U.startsWith("audio/")?Do:U.startsWith("video/")?Bo:U.startsWith("text/")?No:U.includes("javascript")||U.includes("json")||U.includes("xml")?Fo:Xt}function h(U){const q=U.target;q.files?.length&&(a(q.files),q.value="")}function w(){p.value?.click()}function b(U){m.value.has(U)?m.value.delete(U):m.value.add(U),m.value=new Set(m.value)}const V=W(()=>{const U=[],q=new Map,K=[...r.value].sort((R,j)=>R.status==="uploading"&&j.status!=="uploading"?-1:j.status==="uploading"&&R.status!=="uploading"?1:(R.path||R.name).localeCompare(j.path||j.name));for(const R of K){const j=R.path||`/${R.name}`,Z=j.split("/").filter(Boolean);if(Z.length===1)U.push({type:"file",name:R.name,path:j,file:R});else{const N="/"+Z.slice(0,-1).join("/"),F=Z[Z.length-2];if(!q.has(N)){const B={type:"directory",name:F,path:N,children:[]};q.set(N,B),U.push(B)}q.get(N).children.push({type:"file",name:R.name,path:j,file:R})}}return U}),P=W(()=>r.value.length);return(U,q)=>(o(),l(he,null,[e("button",{ref_key:"triggerButton",ref:u,onClick:d,type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors flex items-center justify-center",title:"Thread files"},[M(H(It),{size:20})],512),e("div",{ref_key:"popoverEl",ref:i,popover:"auto",class:"w-80 p-0 m-0 border-0 bg-transparent overflow-visible"},[M(Ye,{"offset-x":6,"offset-y":6,intensity:.4},{default:ce(()=>[e("div",gd,[e("div",bd,[q[0]||(q[0]=e("span",{class:"font-medium text-sm"},"Thread Files",-1)),e("input",{ref_key:"fileInput",ref:p,type:"file",multiple:"",class:"hidden",onChange:h},null,544),e("button",{onClick:w,type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",title:"Upload files"},[M(H(Uo),{size:16})])]),e("div",xd,[V.value.length===0?(o(),l("div",yd," No files yet ")):T("",!0),(o(!0),l(he,null,ye(V.value,K=>(o(),l(he,{key:K.path},[K.type==="directory"?(o(),l(he,{key:0},[e("button",{onClick:R=>b(K.path),type:"button",class:"w-full flex items-center gap-1.5 px-2 py-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors text-left"},[M(H(dt),{size:12,class:Q(["shrink-0 text-neutral-400 transition-transform",{"rotate-90":m.value.has(K.path)}])},null,8,["class"]),(o(),Y(Ze(m.value.has(K.path)?H(Ro):H(It)),{size:14,class:"shrink-0",style:{color:"var(--accent-500)"}})),e("span",wd,C(K.name),1),e("span",_d,C(K.children?.length),1)],8,kd),m.value.has(K.path)?(o(!0),l(he,{key:0},ye(K.children,R=>(o(),l("a",{key:R.path,href:R.path?k(R.path):void 0,target:"_blank",rel:"noopener noreferrer",class:Q(["flex items-center gap-2 pl-7 pr-2 py-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors cursor-pointer",{"pointer-events-none":R.file?.status==="uploading"}])},[e("div",Cd,[R.file?.status==="uploading"?(o(),Y(H(Lt),{key:0,size:12,class:"animate-spin"})):(o(),Y(Ze(g(R.file?.mimeType||"",R.file?.isImage||!1)),{key:1,size:12}))]),e("div",Sd,[e("div",{class:Q(["text-[11px] truncate",{"text-neutral-400":R.file?.status==="uploading"}])},C(R.name),3)]),e("div",Td,[R.file?.status==="uploading"?(o(),l("span",Vd,"...")):R.file?.status==="error"?(o(),l("span",Md,"err")):(o(),l("span",Id,C(c(R.file?.size||0)),1))])],10,$d))),128)):T("",!0)],64)):(o(),l("a",{key:1,href:K.path?k(K.path):void 0,target:"_blank",rel:"noopener noreferrer",class:Q(["flex items-center gap-2 px-2 py-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors cursor-pointer",{"pointer-events-none":K.file?.status==="uploading"}])},[e("div",Ed,[K.file?.status==="uploading"?(o(),Y(H(Lt),{key:0,size:14,class:"animate-spin"})):(o(),Y(Ze(g(K.file?.mimeType||"",K.file?.isImage||!1)),{key:1,size:14}))]),e("div",Ad,[e("div",{class:Q(["text-xs truncate",{"text-neutral-400":K.file?.status==="uploading"}])},C(K.name),3)]),e("div",Pd,[K.file?.status==="uploading"?(o(),l("span",jd,"...")):K.file?.status==="error"?(o(),l("span",Od,"err")):(o(),l("span",Ud,C(c(K.file?.size||0)),1))])],10,Ld))],64))),128))]),e("div",Rd,C(P.value)+" file"+C(P.value!==1?"s":""),1)])]),_:1})],512)],64))}}),Bd=["accept"],Nd=["disabled"],Fd=re({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{}},emits:["filesSelected"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(null),i=W(()=>r.accept||"image/*,.pdf,.txt,.md,.json,.csv");function p(){u.value?.click()}function m(d){const v=d.target;v.files&&v.files.length>0&&(a("filesSelected",v.files),v.value="")}function x(d){const v=d.clipboardData?.items;if(!v)return;const c=[];for(let k=0;k<v.length;k++){const g=v[k];if(g.kind==="file"){const h=g.getAsFile();h&&c.push(h)}}if(c.length>0){const k=new DataTransfer;c.forEach(g=>k.items.add(g)),a("filesSelected",k.files)}}return s({handlePaste:x}),(d,v)=>(o(),l(he,null,[e("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:i.value,multiple:"",class:"hidden",onChange:m},null,40,Bd),e("button",{type:"button",onClick:p,class:Q(["p-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",{"opacity-50 cursor-not-allowed":t.isProcessing}]),disabled:t.isProcessing,title:"Attach files"},[M(H(qo),{size:18})],10,Nd)],64))}}),qd={class:"flex flex-col h-full"},zd={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Hd={class:"flex items-center justify-between"},Wd={class:"flex items-center gap-2"},Jd={class:"flex items-center gap-2"},Zd={class:"flex-1 flex flex-col overflow-hidden relative"},Kd={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Gd={key:1,class:"flex justify-center py-2"},Xd={key:2,class:"flex justify-center py-8"},Yd={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},Qd={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},eu={key:0,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},tu={class:"flex items-center justify-end gap-2"},ou=["disabled"],au={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},lu={key:0,class:"mb-2 flex flex-wrap gap-2"},su={key:0,class:"w-16 h-16 rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800"},nu=["src","alt"],ru={key:1,class:"w-full h-full flex items-center justify-center"},iu={key:1,class:"h-16 px-3 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 flex items-center gap-2"},du=["title"],uu=["onClick"],cu={class:"flex items-start gap-2"},pu={class:"flex-1 flex items-start gap-2 p-2 rounded-2xl border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-neutral-900"},mu=["disabled"],vu=["disabled"],hu={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},fu={key:1,class:"w-4 h-4"},Dt=re({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(!1),i=()=>{u.value=!u.value},p=f(!1),m=f(new Set),x=f(new Map),d=()=>{p.value=!p.value,p.value||(m.value=new Set,x.value=new Map)},v=(ve,se)=>{const ge=new Set(m.value);se?ge.add(ve):ge.delete(ve),m.value=ge},c=(ve,se)=>{const ge=new Map(x.value);ge.set(ve,se),x.value=ge},k=()=>{p.value=!1,m.value=new Set,x.value=new Map},g=W(()=>m.value.size),h=W(()=>{let ve=0;for(const[se]of x.value)m.value.has(se)||ve++;return ve}),w=W(()=>{const ve=g.value,se=h.value;return ve>0&&se>0?`Delete (${ve}), Update (${se})`:ve>0?`Delete (${ve})`:se>0?`Save changes (${se})`:"Delete"}),b=W(()=>g.value>0||h.value>0),V=async()=>{if(!r.threadId||!b.value)return;const ve=[];for(const se of m.value){const ge=P.value.find(Oe=>Oe.id===se);ge&&"log_id"in ge&&ge.log_id&&ve.push(ge.log_id)}try{for(const[se,ge]of x.value)m.value.has(se)||await $(se,ge);for(const se of m.value)await y(se);ve.length>0&&a("logsDeleted",ve)}catch(se){console.error("Error applying changes:",se)}finally{k()}},{messages:P,threadInfo:U,isFetching:q,isLoadingMore:K,error:R,wsConnected:j,wsError:Z,isExecuting:N,hasMore:F,loadMoreMessages:B,deleteMessageById:y,updateMessageContent:$,stopThread:E,sendMessage:_,attachments:S,addAttachment:L,removeAttachment:J}=Pr(W(()=>r.threadId),{}),{thread:X}=Ct(W(()=>r.threadId)),G=W(()=>S.value.length>0),D=W(()=>!1),O=f(null),A=ve=>{L(ve)},de=f(null),I=f(null);s({scrollToLogId:ve=>I.value&&de.value?I.value.scrollToLogId(ve,de.value):!1,hasWorkblockForLogId:ve=>I.value?I.value.hasWorkblockForLogId(ve):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=B);const me=f(""),$e=f(null),fe=f("B"),ke=f(!1),we=f(!1),Ae=async()=>{await Ce(),de.value&&(de.value.scrollTop=de.value.scrollHeight)},oe=async ve=>{ve.target.scrollTop<100&&F.value&&!K.value&&!we.value&&(we.value=!0,await B(),we.value=!1)};pe(()=>P.value.length,async()=>{!K.value&&!we.value&&await Ae()}),pe(()=>r.threadId,async ve=>{ve&&await Ae()}),pe(q,async(ve,se)=>{se&&!ve&&await Ae()});const ie=W(()=>{const ve=U.value?.agent||X.value?.agent;if(!ve)return"ai A";const se=ve.type;return fe.value==="A"&&ve.side_a_label?ve.side_a_label:fe.value==="B"&&ve.side_b_label?ve.side_b_label:se==="ai_human"?fe.value==="A"?"ai":"human":fe.value==="A"?"ai A":"ai B"}),ne=()=>{fe.value=fe.value==="A"?"B":"A"},be=async()=>{const ve=me.value.trim().length>0,se=G.value;if(!ve&&!se||!r.threadId||ke.value||!_)return;const ge=me.value,Oe=fe.value==="A"?"assistant":"user";me.value="",$e.value&&($e.value.style.height="auto",$e.value.style.height="24px"),ke.value=!0;try{await _({role:Oe,content:ge}),await Ae()}catch(st){console.error("Error sending message:",st)}finally{ke.value=!1,await Ce(),$e.value&&$e.value.focus()}},xe=ve=>{ve.key==="Enter"&&!ve.shiftKey&&(ve.preventDefault(),be())},Le=async()=>{if(r.threadId)try{await E()}catch(ve){console.error("Error stopping thread:",ve)}};return(ve,se)=>(o(),l("div",qd,[e("div",zd,[e("div",Hd,[e("div",Wd,[M(H(Yt),{size:18,class:"shrink-0"}),se[9]||(se[9]=e("h2",{class:"text-base font-bold"},"Messages",-1)),t.threadId?(o(),Y(St,{key:0,connected:H(j),error:H(Z)},null,8,["connected","error"])):T("",!0)]),e("div",Jd,[t.threadId?(o(),Y(Dd,{key:0,"thread-id":t.threadId},null,8,["thread-id"])):T("",!0),t.threadId?(o(),l("button",{key:1,onClick:i,type:"button",class:Q(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":u.value}]),title:"Toggle metadata"},[M(H(zo),{size:20})],2)):T("",!0),t.threadId&&H(P).length>0?(o(),l("button",{key:2,onClick:d,type:"button",class:Q(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":p.value}]),title:"Edit messages"},[M(H(xt),{size:20})],2)):T("",!0),e("button",{onClick:se[0]||(se[0]=ge=>a("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[M(H($t),{size:20})])])])]),e("div",Zd,[M(fd,{"thread-id":t.threadId,show:u.value,onClose:se[1]||(se[1]=ge=>u.value=!1),onThreadDeleted:se[2]||(se[2]=ge=>a("threadDeleted",ge)),onEditThread:se[3]||(se[3]=ge=>a("editThread"))},null,8,["thread-id","show"]),e("div",{ref_key:"messagesContainer",ref:de,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:oe},[t.threadId?T("",!0):(o(),l("div",Kd," Select a thread to view messages ")),H(K)?(o(),l("div",Gd,[M(Se,{size:"sm"}),se[10]||(se[10]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):H(q)?(o(),l("div",Xd,[M(Se)])):H(R)?(o(),l("div",Yd," Error loading messages: "+C(H(R)),1)):t.threadId&&H(P).length===0?(o(),l("div",Qd," No messages yet ")):(o(),Y(Ii,{key:5,ref_key:"agentMessagesRef",ref:I,messages:H(P),threadId:t.threadId,selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:p.value,selectedForDelete:m.value,editedMessages:x.value,onMessageClick:se[4]||(se[4]=(ge,Oe)=>a("messageClick",ge,Oe)),onMessageHover:se[5]||(se[5]=ge=>a("messageHover",ge)),onSelectionChange:v,onMessageEdit:c},null,8,["messages","threadId","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&p.value?(o(),l("div",eu,[e("div",tu,[e("button",{onClick:k,class:"px-4 py-2 rounded-lg font-medium text-sm transition-colors bg-neutral-200 text-black hover:bg-neutral-300 dark:bg-neutral-700 dark:text-white dark:hover:bg-neutral-600"}," Cancel "),e("button",{onClick:V,disabled:!b.value,class:Q(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":b.value&&g.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":b.value&&g.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!b.value}])},C(w.value),11,ou)])])):t.threadId?(o(),l("div",au,[H(S).length>0?(o(),l("div",lu,[(o(!0),l(he,null,ye(H(S),ge=>(o(),l("div",{key:ge.id,class:"relative group"},[ge.isImage?(o(),l("div",su,[ge.previewUrl?(o(),l("img",{key:0,src:ge.previewUrl,alt:ge.name,class:"w-full h-full object-cover"},null,8,nu)):(o(),l("div",ru,[...se[11]||(se[11]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(o(),l("div",iu,[e("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:ge.name},C(ge.name),9,du)])),e("button",{onClick:Me(Oe=>H(J)(ge.id),["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-neutral-600 dark:bg-neutral-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500"},[...se[12]||(se[12]=[e("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,uu)]))),128))])):T("",!0),e("div",cu,[e("button",{onClick:ne,class:Q(["flex-shrink-0 px-2 h-7 rounded-md flex items-center justify-center font-medium text-xs transition-colors mt-2.5",{"bg-black text-white dark:bg-white dark:text-black":fe.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":fe.value==="B"}]),title:"Toggle between sides"},C(ie.value),3),e("div",pu,[M(Fd,{ref_key:"fileUploadRef",ref:O,"is-processing":!1,onFilesSelected:A},null,512),Pe(e("textarea",{ref_key:"messageTextarea",ref:$e,"onUpdate:modelValue":se[6]||(se[6]=ge=>me.value=ge),onKeydown:xe,onPaste:se[7]||(se[7]=ge=>O.value?.handlePaste(ge)),disabled:ke.value,placeholder:"Type a message...",rows:"1",class:"flex-1 bg-transparent text-black dark:text-white resize-none focus:outline-none disabled:opacity-50 mt-0.5",style:{"max-height":"120px","min-height":"24px"},onInput:se[8]||(se[8]=ge=>{const Oe=ge.target;Oe.style.height="auto",Oe.style.height=Math.min(Oe.scrollHeight,120)+"px"})},null,40,mu),[[De,me.value]]),H(N)?(o(),l("button",{key:1,id:"stop-thread-button",onClick:Le,class:"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",title:"Stop execution"},[...se[14]||(se[14]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])])):(o(),l("button",{key:0,id:"send-message-button",onClick:be,disabled:!me.value.trim()&&!G.value||ke.value||D.value,class:Q(["flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all",{"bg-black text-white dark:bg-white dark:text-black":(me.value.trim()||G.value)&&!ke.value&&!D.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!me.value.trim()&&!G.value||ke.value||D.value}]),title:"Send message (Enter)"},[ke.value?(o(),l("div",fu,[M(Se)])):(o(),l("svg",hu,[...se[13]||(se[13]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,vu))])])])):T("",!0)])]))}});function gu(t,s){const{limit:n=100,offset:r=0,order:a="desc",autoFetch:u=!0,enableWebSocket:i=!1}=s||{};W(()=>!!(typeof t=="string"?t:t?.value));const p=W(()=>{const Z=typeof t=="string"?t:t?.value;if(!Z)return le("/api/threads/placeholder/logs");const N=new URLSearchParams,F=typeof n=="number"?n:n.value,B=typeof r=="number"?r:r.value,y=typeof a=="string"?a:a.value;return N.append("limit",F.toString()),N.append("offset",B.toString()),N.append("order",y),le(`/api/threads/${Z}/logs?${N.toString()}`)}),{data:m,error:x,isFetching:d,isFinished:v,execute:c,abort:k}=Ue(p,{immediate:!1}).get().json();pe([p,()=>u],([Z,N])=>{Z&&!Z.includes("placeholder")&&N&&c()},{immediate:!0});const g=W(()=>!x.value||x.value.toString().includes("aborted")||x.value.toString().includes("abort")?null:x.value),h=W(()=>m.value?.logs||[]),w=W(()=>m.value?.total||0),b=W(()=>m.value?.hasMore||!1),V=f(null),P=f(!1),U=f(null),q=f([]),K=()=>{const Z=typeof t=="string"?t:t?.value;if(!Z||!i)return;V.value&&V.value.close(),q.value=[];const N=window.location.protocol==="https:"?"wss:":"ws:",F=window.location.host;let B=`${N}//${F}${le(`/api/threads/${Z}/logs`)}`;const y=localStorage.getItem("auth_token");y&&(B+=`?token=${encodeURIComponent(y)}`);try{V.value=new WebSocket(B),V.value.onopen=()=>{P.value=!0,U.value=null,console.log("WebSocket connected for logs")},V.value.onmessage=$=>{try{const E=JSON.parse($.data);if(E.type==="log_data"){const _=q.value.findIndex(L=>L.id===E.log_id),S=h.value.find(L=>L.id===E.log_id);_>=0?(q.value[_]={...q.value[_],...E.data},console.log("[WebSocket] Updated existing realtime log:",E.log_id)):S?(q.value.push({...S,...E.data}),console.log("[WebSocket] Updated HTTP log:",E.log_id)):(q.value.push({id:E.log_id,...E.data}),console.log("[WebSocket] Added new log:",E.log_id))}}catch(E){console.error("Failed to parse WebSocket message:",E)}},V.value.onerror=$=>{U.value="WebSocket connection error",P.value=!1,console.error("WebSocket error:",$)},V.value.onclose=()=>{P.value=!1,console.log("WebSocket disconnected")}}catch($){U.value=$.message||"Failed to create WebSocket",console.error("WebSocket creation error:",$)}},R=()=>{V.value&&(V.value.close(),V.value=null,P.value=!1),q.value=[]};return Ne(()=>{R()}),{logs:W(()=>{if(!i)return h.value;const Z=new Map;h.value.forEach(B=>Z.set(B.id,B)),q.value.forEach(B=>Z.set(B.id,B));const N=typeof a=="string"?a:a.value;return Array.from(Z.values()).sort((B,y)=>N==="desc"?y.created_at-B.created_at:B.created_at-y.created_at)}),total:w,hasMore:b,error:g,isFetching:d,isFinished:v,refetch:c,abort:k,wsConnected:P,wsError:U,connectWebSocket:K,disconnectWebSocket:R}}function bu(t,s){const n=W(()=>{const p=t.value,m=s.value;return!p||!m?null:le(`/api/threads/${p}/logs/${m}`)}),{data:r,error:a,isFetching:u,execute:i}=Ue(n,{immediate:!1}).get().json();return pe([t,s],([p,m])=>{p&&m&&i()},{immediate:!0}),{logDetails:r,error:a,isFetching:u,refetch:i}}const xu=["disabled","title"],yu={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},ku={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},wu={key:3},fo=re({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const s=t,n=f(!1),r=f(!1),a=async()=>{n.value=!0;try{await navigator.clipboard.writeText(s.content),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch(p){console.error("Failed to copy:",p),alert(`Failed to copy: ${p instanceof Error?p.message:"Unknown error"}`)}finally{n.value=!1}},u={xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},i={solid:"bg-black text-white dark:bg-white dark:text-black",ghost:"bg-white dark:bg-neutral-950 border border-neutral-300 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900"};return(p,m)=>(o(),l("button",{onClick:a,disabled:n.value||t.disabled,class:Q([u[t.size||"sm"],i[t.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:t.disabled?"No content to copy":r.value?"Copied!":"Copy to clipboard"},[n.value?(o(),Y(Se,{key:0,size:"xs"})):t.variant==="ghost"&&!r.value?(o(),l("svg",yu,[...m[0]||(m[0]=[e("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),e("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):t.variant==="ghost"&&r.value?(o(),l("svg",ku,[...m[1]||(m[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(o(),l("span",wu,C(r.value?"Copied!":"Copy"),1))],10,xu))}}),ft="__shiki_highlighter__";let rt=null;async function _u(){return typeof window<"u"&&window[ft]?window[ft]:rt||(rt=ea({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[ft]=t),t)),rt)}const $u={class:"code-block"},Cu={key:0,class:"text-xs text-neutral-500 p-2"},Su=["innerHTML"],gt=re({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const s=t,n=f(""),r=f(!0),a=async()=>{const u=s.code??"";if(!u){n.value='<pre class="shiki"><code></code></pre>',r.value=!1;return}try{const i=await _u();if(s.language==="json"||s.language==="markdown")n.value=i.codeToHtml(u,{lang:s.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.value=`<pre class="shiki shiki-text"><code>${p}</code></pre>`}}catch{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.value=`<pre class="shiki"><code>${p}</code></pre>`}finally{r.value=!1}};return Te(()=>{a()}),pe(()=>s.code,()=>{a()}),(u,i)=>(o(),l("div",$u,[r.value?(o(),l("div",Cu,"Loading...")):(o(),l("div",{key:1,innerHTML:n.value,class:"code-content"},null,8,Su))]))}}),Tu={class:"json-viewer relative bg-white dark:bg-neutral-900"},Vu={key:0,class:"absolute top-[5px] right-[5px] z-10"},Mu=["innerHTML"],Iu=["src","alt"],Lu=re({__name:"JsonViewer",props:{json:{},threadId:{},showCopyButton:{type:Boolean}},setup(t){const s=t,n=f(null),r=f(null),a=c=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(g=>c.toLowerCase().endsWith(g)),u=c=>s.threadId?le(`/api/threads/${s.threadId}/fs${c}`):null,i=W(()=>{if(!s.json)return"";if(typeof s.json=="string")try{return JSON.stringify(JSON.parse(s.json),null,2)}catch{return s.json}return JSON.stringify(s.json,null,2)}),p=c=>c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),m=(c,k=0)=>{const g=" ".repeat(k),h=w=>`<span class="json-punct">${w}</span>`;if(c===null)return'<span class="json-null">null</span>';if(typeof c=="boolean")return`<span class="json-boolean">${c}</span>`;if(typeof c=="number")return`<span class="json-number">${c}</span>`;if(typeof c=="string"){const w=p(c);return s.threadId&&a(c)&&c.startsWith("/attachments/")?`${h('"')}<span class="json-image-path" data-path="${p(c)}">${w}</span>${h('"')}`:`${h('"')}<span class="json-string">${w}</span>${h('"')}`}if(Array.isArray(c)){if(c.length===0)return`${h("[")}${h("]")}`;const w=c.map((b,V)=>{const P=V<c.length-1?h(","):"";return`${g} ${m(b,k+1)}${P}`});return`${h("[")}
3
3
  ${w.join(`
4
4
  `)}
@@ -11,7 +11,7 @@ ${g}${h("}")}`}return String(c)},x=W(()=>{if(!s.json)return'<span class="json-nu
11
11
  `,E+=` -H 'HTTP-Referer: https://agentkit.local' \\
12
12
  `,E+=` -H 'X-Title: AgentKit' \\
13
13
  `):y.sdk?.toLowerCase()==="openai"&&(E+=` -H 'Authorization: Bearer ${y.api_key}' \\
14
- `),E+=` -d '${$.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(E),m.value=!0,setTimeout(()=>{m.value=!1},2e3)}catch(B){console.error("Failed to copy cURL command:",B),alert(`Failed to copy cURL: ${B instanceof Error?B.message:"Unknown error"}`)}finally{p.value=!1}};return(B,y)=>(o(),l("div",{ref_key:"scrollContainer",ref:x,class:"p-4 h-full overflow-y-auto"},[e("div",ju,[e("div",Ou,[e("div",Uu,[e("button",{onClick:y[0]||(y[0]=$=>r("previous")),disabled:!t.hasPrevious,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Previous log",title:"Previous log"},[...y[9]||(y[9]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,Ru),e("button",{onClick:y[1]||(y[1]=$=>r("next")),disabled:!t.hasNext,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Next log",title:"Next log"},[...y[10]||(y[10]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,Du)]),e("h3",Bu,C(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",Nu,[e("button",{onClick:F,disabled:p.value||!t.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:t.log.request_body?"Copy cURL command":"No request data available"},[p.value?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",qu,C(m.value?"Copied!":"Copy cURL"),1))],8,Fu),e("button",{onClick:y[2]||(y[2]=$=>r("close")),class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 transition-all","aria-label":"Close details",title:"Close"},[...y[11]||(y[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),e("div",zu,[e("div",Hu,[e("table",Wu,[y[12]||(y[12]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:Q(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",Ju,C(t.log.provider),1),e("td",Zu,[!t.log.is_complete&&!t.log.prompt_name?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Ku,C(t.log.prompt_name||"—"),1))]),e("td",Gu,[!t.log.is_complete&&!t.log.latency_ms?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Xu,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",Yu,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Qu,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",ec,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",tc,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",oc,[M(ct,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",ac,[e("table",lc,[y[13]||(y[13]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:Q(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",sc,C(t.log.provider),1),e("td",nc,[!t.log.is_complete&&!t.log.prompt_name?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",rc,C(t.log.prompt_name||"—"),1))])])])]),e("table",ic,[y[14]||(y[14]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",dc,[!t.log.is_complete&&!t.log.latency_ms?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",uc,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",cc,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",pc,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",mc,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",vc,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",hc,[M(ct,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",fc,[e("div",gc,[e("button",{onClick:y[3]||(y[3]=$=>a.value="request"),class:Q(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",a.value==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])}," Request ",2),e("button",{onClick:y[4]||(y[4]=$=>a.value="response"),class:Q(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",a.value==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])},[y[15]||(y[15]=Ve(" Response ",-1)),t.log.error||N.value.length>0?(o(),l("span",bc,"⚠")):T("",!0)],2)])]),e("div",xc,[Pe(e("div",yc,[b.value.length>0?(o(),Y(it,{key:0,ref_key:"toolsSectionRef",ref:d,title:`Available Tools (${b.value.length})`,"section-id":"tools",expanded:Z("tools"),"scroll-container":x.value,onToggle:y[5]||(y[5]=$=>j("tools"))},{default:ce(()=>[(o(!0),l(he,null,ye(b.value,($,E)=>(o(),l("div",{key:E,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>K(E),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",wc,C($.function?.name||$.name||"Unknown"),1),e("span",_c,C(u.value.has(E)?"▼":"▶"),1)],8,kc),Pe(e("div",$c,[$.function?.description||$.description?(o(),l("div",Cc,C($.function?.description||$.description),1)):T("",!0),M(gt,{code:JSON.stringify($,null,2),language:"json"},null,8,["code"])],512),[[Je,u.value.has(E)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):T("",!0),t.log.message_history?(o(),Y(it,{key:1,ref_key:"messagesSectionRef",ref:v,title:`Messages (${t.log.message_history_length||0} messages)`,"section-id":"messages",expanded:Z("messages"),"scroll-container":x.value,onToggle:y[6]||(y[6]=$=>j("messages"))},{default:ce(()=>[M(ut,{json:t.log.message_history,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","expanded","scroll-container"])):T("",!0),t.log.system_prompt?(o(),Y(it,{key:2,ref_key:"systemPromptSectionRef",ref:c,title:"System Prompt","section-id":"system_prompt",expanded:Z("system_prompt"),"scroll-container":x.value,onToggle:y[7]||(y[7]=$=>j("system_prompt"))},{default:ce(()=>[e("div",Sc,[M(gt,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",Tc,[M(fo,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):T("",!0),t.log.request_body?(o(),Y(it,{key:3,ref_key:"requestBodySectionRef",ref:k,title:"Full Request Body","section-id":"request_body",expanded:Z("request_body"),"scroll-container":x.value,onToggle:y[8]||(y[8]=$=>j("request_body"))},{default:ce(()=>[M(ut,{json:t.log.request_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["expanded","scroll-container"])):T("",!0)],512),[[Je,a.value==="request"]]),Pe(e("div",null,[N.value.length>0?(o(),l("div",Vc,[e("div",Mc,C(N.value.length>1?`Errors (${N.value.length})`:"Error"),1),e("div",Ic,[(o(!0),l(he,null,ye(N.value,($,E)=>(o(),l("div",{key:E,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",Lc,C($.type||"error"),1),e("pre",Ec,C($.message),1)]))),128))])])):t.log.error?(o(),l("div",Ac,[e("div",Pc," Error "+C(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",jc,C(t.log.error),1)])):T("",!0),t.log.is_complete||!t.log.error?(o(),l("div",Oc,[y[23]||(y[23]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",Uc,[e("tbody",null,[e("tr",Rc,[y[16]||(y[16]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Finish Reason ",-1)),e("td",Dc,[!t.log.is_complete&&!t.log.finish_reason?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Bc,C(t.log.finish_reason||"—"),1))])]),e("tr",Nc,[y[17]||(y[17]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Input Tokens ",-1)),e("td",Fc,[!t.log.is_complete&&!t.log.input_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",qc,C(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(o(),l("tr",zc,[y[18]||(y[18]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Cached Tokens ",-1)),e("td",Hc,[!t.log.is_complete&&!t.log.cached_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Wc,C(t.log.cached_tokens||0),1))])])):T("",!0),e("tr",Jc,[y[19]||(y[19]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Output Tokens ",-1)),e("td",Zc,[!t.log.is_complete&&!t.log.output_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Kc,C(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(o(),l("tr",Gc,[y[20]||(y[20]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Reasoning Tokens ",-1)),e("td",Xc,C(t.log.reasoning_tokens),1)])):T("",!0),e("tr",Yc,[y[21]||(y[21]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Tokens ",-1)),e("td",Qc,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",e0,C(t.log.total_tokens||"—"),1))])]),e("tr",null,[y[22]||(y[22]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Cost ",-1)),e("td",t0,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",o0,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):T("",!0),V.value.length>0?(o(),l("div",a0,[e("div",l0," Tools Called ("+C(V.value.length)+") ",1),e("div",s0,[(o(!0),l(he,null,ye(V.value,($,E)=>(o(),l("div",{key:E,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>R(E),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",r0,C($.function?.name||"Unknown"),1),e("span",i0,C(i.value.has(E)?"▼":"▶"),1)],8,n0),Pe(e("div",d0,[e("div",u0,[y[24]||(y[24]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",c0,C($.id),1)]),e("div",p0,[y[25]||(y[25]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",m0,C($.function?.name),1)]),e("div",v0,[y[26]||(y[26]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",h0,[M(gt,{code:w($.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),P.value.has($.id)?(o(),l("div",f0,[y[27]||(y[27]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",g0,C(P.value.get($.id)?.content||"No content"),1)])):(o(),l("div",b0,[...y[28]||(y[28]=[e("div",{class:"font-semibold text-neutral-500 dark:text-neutral-500 mb-1"}," Result ",-1),e("div",{class:"text-xs text-neutral-500 dark:text-neutral-500 italic"}," No result available ",-1)])]))],512),[[Je,i.value.has(E)]])]))),128))])])):T("",!0),q.value.length>0?(o(),l("div",x0,[e("div",y0," Generated Images ("+C(q.value.length)+") ",1),e("div",k0,[y[29]||(y[29]=e("div",{class:"px-2 py-1.5 bg-emerald-100 dark:bg-emerald-900/30 text-xs text-emerald-800 dark:text-emerald-200 border-b border-emerald-300 dark:border-emerald-700"}," Images returned by the model ",-1)),e("div",w0,[(o(!0),l(he,null,ye(q.value,($,E)=>(o(),l("div",{key:E,class:"relative"},[$.image_url?.url?(o(),l("img",{key:0,src:h($.image_url.url)||$.image_url.url,alt:`Generated image ${E+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,_0)):(o(),l("div",$0," No URL "))]))),128))])])])):T("",!0),t.log.reasoning_content?(o(),l("div",C0,[y[31]||(y[31]=e("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),e("div",S0,[y[30]||(y[30]=e("div",{class:"px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 border-b border-accent-300 dark:border-accent-700"}," Internal reasoning output (not displayed to users) ",-1)),e("pre",T0,C(t.log.reasoning_content),1)])])):T("",!0),U.value.length>0?(o(),l("div",V0,[e("div",M0," Reasoning Details ("+C(U.value.length)+" blocks) ",1),e("div",I0,[y[36]||(y[36]=e("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),e("div",L0,[(o(!0),l(he,null,ye(U.value,($,E)=>(o(),l("div",{key:E,class:"p-2"},[e("div",E0,[e("span",A0,C($.type||"unknown"),1),$.id?(o(),l("span",P0," ID: "+C($.id),1)):T("",!0),$.format?(o(),l("span",j0," Format: "+C($.format),1)):T("",!0),$.index!==void 0?(o(),l("span",O0," Index: "+C($.index),1)):T("",!0)]),$.type==="reasoning.summary"&&$.summary?(o(),l("div",U0,[y[32]||(y[32]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",R0,C($.summary),1)])):T("",!0),$.type==="reasoning.encrypted"&&$.data?(o(),l("div",D0,[y[33]||(y[33]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",B0,C($.data),1)])):T("",!0),$.type==="reasoning.text"&&$.text?(o(),l("div",N0,[y[35]||(y[35]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",F0,C($.text),1),$.signature?(o(),l("div",q0,[y[34]||(y[34]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",z0,C($.signature),1)])):T("",!0)])):T("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes($.type)?T("",!0):(o(),l("div",H0,[e("pre",W0,C(JSON.stringify($,null,2)),1)]))]))),128))])])])):T("",!0),t.log.response_body?(o(),l("div",J0,[y[37]||(y[37]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",Z0,[M(ut,{json:t.log.response_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):T("",!0)],512),[[Je,a.value==="response"]])])],512))}}),G0={class:"flex flex-col h-full"},X0={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Y0={class:"flex items-center justify-between"},Q0={class:"flex items-center gap-2"},ep={class:"flex items-center gap-2"},tp={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},op={key:1,class:"flex justify-center py-12"},ap={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},lp={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},sp={key:4},np={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},rp=["disabled"],ip={key:1},dp={key:2},up={key:3},cp={class:"w-full text-sm"},pp=["onClick","onMouseenter"],mp={class:"px-3 py-2 text-xs"},vp={class:"flex items-center gap-1"},hp={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},fp={key:3},gp={class:"px-3 py-2"},bp={class:"flex items-center gap-2"},xp={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},yp={class:"font-mono text-xs"},kp={class:"px-3 py-2 font-mono text-xs"},wp={key:1},_p={key:1},$p={key:0,class:"log-details-panel relative shrink-0 bg-neutral-100 dark:bg-neutral-950 border-t border-neutral-300 dark:border-neutral-700 overflow-hidden"},Cp={class:"m-2 border h-[calc(100%-1rem)] border-neutral-300 shrink-0 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-auto"},Sp={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},Tp={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},Bt=20,Vp=20,Mp=re({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","logClick","logHover","logsLoaded"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(0),i=f(Bt),{logs:p,hasMore:m,isFetching:x,error:d,wsConnected:v,wsError:c,connectWebSocket:k,disconnectWebSocket:g,refetch:h}=gu(W(()=>r.threadId),{limit:W(()=>i.value),offset:W(()=>u.value),enableWebSocket:!0,order:"desc"}),w=f([]),b=f(!0),V=f(null),P=f(null),U=f(!1),q=f(!1),K=f(new Map),R=async()=>{await Ce(),P.value&&(P.value.scrollTop=P.value.scrollHeight)},j=f(null);pe(p,async oe=>{if(u.value===0)w.value=[...oe].reverse(),b.value&&w.value.length>0&&(await R(),b.value=!1);else{const ie=[...oe].reverse(),ne=new Map;w.value.forEach(be=>ne.set(be.id,be)),ie.forEach(be=>ne.set(be.id,be)),w.value=Array.from(ne.values()).sort((be,xe)=>be.created_at-xe.created_at)}},{deep:!0,immediate:!0}),pe(x,(oe,ie)=>{if(ie&&!oe&&u.value===0&&r.threadId&&j.value!==r.threadId&&w.value.length>0){j.value=r.threadId;const ne=w.value[w.value.length-1];a("logsLoaded",ne?.id??null)}});const{logDetails:Z,isFetching:N}=bu(W(()=>r.threadId),W(()=>V.value)),F=W(()=>{if(!V.value)return null;const ie=w.value.find(ne=>ne.id===V.value);return ie?Z.value?{...Z.value,...ie}:ie:null}),B=W(()=>V.value?Ae.value.findIndex(oe=>oe.id===V.value):-1),y=W(()=>B.value>0),$=W(()=>B.value>=0&&B.value<Ae.value.length-1),E=()=>{if(y.value){const oe=Ae.value[B.value-1];L(oe)}},_=()=>{if($.value){const oe=Ae.value[B.value+1];L(oe)}},S=oe=>{if(!P.value)return;const ie=K.value.get(oe);if(!ie)return;const ne=P.value,be=ie.getBoundingClientRect(),xe=ne.getBoundingClientRect(),Le=ne.querySelectorAll(".sticky");let ve=0;Le.forEach(Oe=>{ve+=Oe.getBoundingClientRect().height}),ve+=16;const se=be.top<xe.top+ve,ge=be.bottom>xe.bottom;se?ne.scrollBy({top:be.top-xe.top-ve,behavior:"smooth"}):ge&&ne.scrollBy({top:be.bottom-xe.bottom,behavior:"smooth"})},L=oe=>{a("logClick",oe.id),V.value=oe.id},J=(oe,ie)=>{ie?K.value.set(oe,ie):K.value.delete(oe)};pe(V,async oe=>{oe&&(await Ce(),S(oe))}),pe(()=>r.selectedLogId,oe=>{oe&&(V.value=oe)},{immediate:!0});const X=oe=>{V.value=oe},G=async oe=>{await Ce();const ie=K.value.get(oe);if(ie&&P.value){const ne=P.value,be=ie.getBoundingClientRect(),xe=ne.getBoundingClientRect(),Le=ne.querySelector("thead"),ve=ne.querySelector(":scope > div > div.sticky");let se=0;Le&&(se+=Le.getBoundingClientRect().height),ve&&(se+=ve.getBoundingClientRect().height),se+=40;const ge=be.top<xe.top+se,Oe=be.bottom>xe.bottom;ge?ne.scrollBy({top:be.top-xe.top-se,behavior:"smooth"}):Oe&&ne.scrollBy({top:be.bottom-xe.bottom,behavior:"smooth"})}},D=oe=>{if(oe.length===0)return;const ie=new Set(oe);w.value=w.value.filter(ne=>!ie.has(ne.id))},O=f(!1),A=oe=>w.value.some(ie=>ie.id===oe),de=oe=>w.value.find(ie=>ie.id===oe)??null,I=(oe,ie=3e3)=>new Promise(ne=>{const be=Date.now(),xe=pe(w,()=>{w.value.length!==oe&&(xe(),ne(!0))},{deep:!0}),Le=setInterval(()=>{w.value.length!==oe?(clearInterval(Le),xe(),ne(!0)):Date.now()-be>ie&&(clearInterval(Le),xe(),ne(!1))},50)});s({scrollToLog:G,selectLogById:X,removeLogsByIds:D,loadUntilLogId:async oe=>{if(A(oe))return!0;if(!m.value)return!1;O.value=!0;const ie=100,ne=50;try{let be=0;for(;m.value&&!A(oe)&&be<ne;){be++;const xe=w.value.length;if(u.value+=i.value,i.value=ie,await h(),!await I(xe))break}return A(oe)}finally{O.value=!1}},hasLog:A,getLog:de,setLoadingForLog:oe=>{O.value=oe},waitForLogRow:async(oe,ie=2e3)=>{const ne=Date.now();for(;Date.now()-ne<ie;){if(K.value.has(oe))return!0;if(!Ae.value.some(xe=>xe.id===oe)){await Ce(),await new Promise(xe=>setTimeout(xe,16));continue}await Ce(),await new Promise(xe=>setTimeout(xe,16))}return!1}});const $e=async()=>{if(q.value||!m.value||x.value)return;q.value=!0;const oe=P.value?.scrollHeight||0;if(u.value+=i.value,i.value=Vp,await h(),await Ce(),P.value){const ie=P.value.scrollHeight;P.value.scrollTop+=ie-oe}q.value=!1};pe(()=>r.threadId,async oe=>{oe?(g(),k()):g(),u.value=0,i.value=Bt,w.value=[],V.value=null,U.value=!1,b.value=!0},{immediate:!0}),pe(w,async()=>{U.value||await R()},{deep:!0});const fe=()=>{if(!P.value)return;const{scrollTop:oe,scrollHeight:ie,clientHeight:ne}=P.value,be=ie-oe-ne<50;U.value=!be},ke=oe=>{if(!oe.tools_called)return"—";try{const ie=JSON.parse(oe.tools_called);return Array.isArray(ie)?ie.join(", "):oe.tools_called}catch{return oe.tools_called}},we=oe=>oe==null?"—":`$${oe.toFixed(6)}`,Ae=W(()=>{const oe=new Map,ie=new Map;w.value.forEach(xe=>{oe.set(xe.id,xe);const Le=xe.parent_log_id;Le&&(ie.has(Le)||ie.set(Le,[]),ie.get(Le).push(xe))});const ne=[],be=(xe,Le)=>{ne.push({...xe,depth:Le}),(ie.get(xe.id)||[]).forEach(se=>{be(se,Le+1)})};return w.value.forEach(xe=>{xe.parent_log_id||be(xe,0)}),ne});return(oe,ie)=>(o(),l("div",G0,[e("div",X0,[e("div",Y0,[e("div",Q0,[M(H(Qt),{size:18,class:"shrink-0"}),ie[4]||(ie[4]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(o(),Y(St,{key:0,connected:H(v),error:H(c)},null,8,["connected","error"])):T("",!0)]),e("div",ep,[e("button",{onClick:ie[0]||(ie[0]=ne=>a("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[M(H($t),{size:20})])])])]),e("div",{ref_key:"logsScrollContainer",ref:P,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:fe},[t.threadId?H(x)&&u.value===0?(o(),l("div",op,[M(Se)])):H(d)?(o(),l("div",ap," Error loading logs: "+C(H(d)),1)):w.value.length===0?(o(),l("div",lp," No logs yet ")):(o(),l("div",sp,[H(m)?(o(),l("div",np,[e("button",{onClick:$e,disabled:q.value||O.value,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[q.value||O.value?(o(),Y(Se,{key:0,size:"xs"})):T("",!0),O.value?(o(),l("span",ip,"Loading to find log...")):q.value?(o(),l("span",dp,"Loading older logs...")):(o(),l("span",up,"Load previous logs"))],8,rp)])):T("",!0),e("table",cp,[e("thead",{class:Q(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!H(m),"top-[34px]":H(m)}])},[...ie[5]||(ie[5]=[e("tr",null,[e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Prompt"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Model"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Cost"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Tools Called"),e("th",{class:"text-right px-3 py-1.5 text-xs font-semibold"},"Called At")],-1)])],2),e("tbody",null,[(o(!0),l(he,null,ye(Ae.value,ne=>(o(),l("tr",{key:ne.id,ref_for:!0,ref:be=>J(ne.id,be),class:Q(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":F.value,"bg-red-50 dark:bg-red-950/20":ne.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":V.value===ne.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":ne.id===r.selectedLogId||ne.id!==r.selectedLogId&&ne.id===r.hoveredLogId}]),onClick:be=>L(ne),onMouseenter:be=>a("logHover",ne.id),onMouseleave:ie[1]||(ie[1]=be=>a("logHover",null))},[e("td",mp,[e("div",vp,[ne.depth>0?(o(),l("span",hp,"└─")):T("",!0),ne.retry_of_log_id?(o(),Y(H(Ho),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):T("",!0),!ne.is_complete&&!ne.prompt_name?(o(),Y(Se,{key:2,size:"xs"})):(o(),l("span",fp,C(ne.prompt_name||"—"),1))])]),e("td",gp,[e("div",bp,[ne.error?(o(),l("span",xp," ✕ ")):T("",!0),e("span",yp,C(ne.model_name||ne.model),1)])]),e("td",kp,[!ne.is_complete&&!ne.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",wp,C(we(ne.cost_total)),1))]),e("td",{class:Q(["px-3 py-2 text-xs",V.value===ne.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!ne.is_complete&&ke(ne)==="—"?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",_p,C(ke(ne)),1))],2),e("td",{class:Q(["px-3 py-2 text-right text-xs",V.value===ne.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[M(ct,{timestamp:ne.created_at},null,8,["timestamp"])],2)],42,pp))),128))])])])):(o(),l("div",tp," Select a thread to view logs "))],544),M(Ge,{name:"slide-up",onAfterEnter:ie[3]||(ie[3]=()=>V.value&&S(V.value))},{default:ce(()=>[F.value||O.value&&V.value?(o(),l("div",$p,[e("div",Cp,[O.value&&!F.value?(o(),l("div",Sp,[M(Se),ie[6]||(ie[6]=e("span",{class:"text-sm"},"Loading log...",-1))])):F.value?(o(),Y(K0,{key:1,log:F.value,"thread-id":t.threadId,"has-previous":y.value,"has-next":$.value,onClose:ie[2]||(ie[2]=ne=>V.value=null),onPrevious:E,onNext:_},null,8,["log","thread-id","has-previous","has-next"])):T("",!0),H(N)&&F.value?(o(),l("div",Tp,[M(Se)])):T("",!0)])])):T("",!0)]),_:1})]))}}),Ip=Qe(Mp,[["__scopeId","data-v-30798cba"]]),Lp={class:"space-y-4"},Ep={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},Ap={class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Pp={key:0},jp={key:1},Op={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Up={key:3,class:"flex items-center gap-2"},Rp=["onUpdate:modelValue","id"],Dp=["for"],Bp={key:0,class:"text-red-500"},Np={key:5,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-1"},Fp={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},qp={key:3},zp={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},Hp={class:"text-xs font-medium mb-1 opacity-70"},Wp={class:"text-sm whitespace-pre-wrap"},Jp=["onClick"],Zp={key:1,class:"text-center py-8 text-neutral-500 dark:text-neutral-400 text-sm"},Kp={class:"space-y-2"},Gp={class:"flex items-stretch border border-black dark:border-neutral-300 rounded overflow-hidden bg-white dark:bg-neutral-900"},Xp=["disabled","title"],Yp={class:"flex-1 relative"},Qp=["disabled","title"],e2={class:"text-xs text-neutral-500 dark:text-neutral-400"},t2={class:"flex justify-between"},o2=["disabled"],a2=["disabled"],l2=re({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>!!n.editThread),u=f(""),i=f(""),p=f({}),m=f([]),x=f(""),d=f(!1),v=f(""),c=f(null),{data:k,isFetching:g,execute:h}=Ue(le("/api/agents"),{immediate:!1}).json(),w=W(()=>k.value?(k.value?.agents||[]).map(S=>({value:S.id,label:S.title})):[]),b=W(()=>!u.value||!k.value?null:(k.value?.agents||[]).find(S=>S.id===u.value)),V=W(()=>b.value&&b.value.type==="ai_human"?"AI":"Side A"),P=W(()=>b.value&&b.value.type==="ai_human"?"Human":"Side B"),{data:U,isFetching:q,execute:K}=Ue(W(()=>b.value?.side_a_system_prompt?le(`/api/prompts/${b.value.side_a_system_prompt}`):""),{immediate:!1}).json(),R=W(()=>{if(!U.value)return null;const _=U.value?.required_schema;if(!_)return null;try{return typeof _=="string"?JSON.parse(_):_}catch{return null}}),j=W(()=>{const _=R.value;return!_||!_.properties?[]:Object.entries(_.properties).map(([S,L])=>({name:S,type:L.type||"string",description:L.description||"",required:_.required?.includes(S)||!1,enum:L.enum}))});pe(u,async _=>{_&&b.value?.side_a_system_prompt?(await K(),p.value={}):p.value={}});const Z=()=>{const _=c.value;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},N=_=>{x.value.trim()&&(m.value.push({id:crypto.randomUUID(),role:_,content:x.value.trim()}),x.value="",setTimeout(()=>Z(),0))},F=_=>{m.value=m.value.filter(S=>S.id!==_)},B=()=>{u.value="",i.value="",p.value={},m.value=[],x.value="",v.value=""},y=()=>{n.editThread&&(u.value=n.editThread.agent_id,i.value=n.editThread.tags?.join(", ")||"")},$=async()=>{if(!u.value){v.value="Please select an agent";return}if(!a.value&&j.value.length>0){for(const _ of j.value)if(_.required&&!p.value[_.name]){v.value=`Please provide ${_.name}`;return}}d.value=!0,v.value="";try{const _=i.value.split(",").map(S=>S.trim()).filter(S=>S.length>0);if(a.value){const S=await fetch(le(`/api/threads/${n.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:_})});if(!S.ok){const L=await S.json();throw new Error(L.error||"Failed to update thread")}r("thread-updated"),B(),r("update:modelValue",!1)}else{const S={agent_id:u.value,tags:_.length>0?_:void 0};m.value.length>0&&(S.initial_messages=m.value.map(G=>({role:G.role,content:G.content}))),Object.keys(p.value).length>0&&(S.data=p.value);const L=await fetch(le("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)});if(!L.ok){const G=await L.json();throw new Error(G.error||"Failed to create thread")}const X=(await L.json()).threadId;if(!X)throw new Error("Thread created but ID not found in response");r("thread-created",X),B(),r("update:modelValue",!1)}}catch(_){console.error(`Error ${a.value?"updating":"creating"} thread:`,_),v.value=_.message||`Failed to ${a.value?"update":"create"} thread`}finally{d.value=!1}},E=()=>{B(),r("update:modelValue",!1)};return pe(()=>n.modelValue,async _=>{_&&(await h(),B(),a.value&&y())}),(_,S)=>(o(),Y(Be,{"model-value":t.modelValue,"onUpdate:modelValue":S[7]||(S[7]=L=>_.$emit("update:modelValue",L)),title:a.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:ce(()=>[e("div",t2,[e("button",{onClick:E,type:"button",disabled:d.value,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,o2),e("button",{onClick:$,type:"button",disabled:d.value||H(g),class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[a.value?(o(),l(he,{key:0},[Ve(C(d.value?"Updating...":"Update Thread"),1)],64)):(o(),l(he,{key:1},[Ve(C(d.value?"Creating...":"Create Thread"),1)],64))],8,a2)])]),default:ce(()=>[e("div",Lp,[v.value?(o(),l("div",Ep,C(v.value),1)):T("",!0),e("div",null,[M(_e,{modelValue:u.value,"onUpdate:modelValue":S[0]||(S[0]=L=>u.value=L),label:"Agent",options:w.value,disabled:H(g)||a.value,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),e("p",Ap,[a.value?(o(),l("span",Pp,"Agent cannot be changed after thread creation")):(o(),l("span",jp,"Choose which agent will handle this conversation"))])]),!a.value&&j.value.length>0&&!H(q)?(o(),l("div",Op,[S[8]||(S[8]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(o(!0),l(he,null,ye(j.value,L=>(o(),l("div",{key:L.name,class:"space-y-2"},[L.enum?(o(),Y(_e,{key:0,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,options:[{value:"",label:"Select..."},...L.enum.map(J=>({value:J,label:J}))],required:L.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):L.type==="string"?(o(),Y(Ee,{key:1,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,placeholder:L.description,required:L.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):L.type==="number"||L.type==="integer"?(o(),Y(Ee,{key:2,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,modelModifiers:{number:!0},label:L.name,placeholder:L.description,type:"number",required:L.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):L.type==="boolean"?(o(),l("div",Up,[Pe(e("input",{"onUpdate:modelValue":J=>p.value[L.name]=J,type:"checkbox",id:`field-${L.name}`,class:"w-4 h-4"},null,8,Rp),[[Wo,p.value[L.name]]]),e("label",{for:`field-${L.name}`,class:"text-sm"},[Ve(C(L.name)+" ",1),L.required?(o(),l("span",Bp,"*")):T("",!0)],8,Dp)])):(o(),Y(ho,{key:4,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,placeholder:L.description||`Enter ${L.name} (JSON format)`,required:L.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])),L.description?(o(),l("p",Np,C(L.description),1)):T("",!0)]))),128))])):T("",!0),!a.value&&H(q)?(o(),l("div",Fp," Loading agent requirements... ")):T("",!0),a.value?T("",!0):(o(),l("div",qp,[S[11]||(S[11]=e("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),m.value.length>0?(o(),l("div",zp,[(o(!0),l(he,null,ye(m.value,L=>(o(),l("div",{key:L.id,class:Q(["flex items-start gap-2",{"justify-start":L.role==="assistant","justify-end":L.role==="user"}])},[e("div",{class:Q(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":L.role==="assistant","bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":L.role==="user"}])},[e("div",Hp,C(L.role==="assistant"?V.value:P.value),1),e("div",Wp,C(L.content),1)],2),e("button",{onClick:J=>F(L.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,Jp)],2))),128))])):(o(),l("div",Zp," No messages yet. Add messages to start the conversation. ")),e("div",Kp,[e("div",Gp,[e("button",{onClick:S[1]||(S[1]=L=>N("assistant")),type:"button",disabled:!x.value.trim(),title:`Add as ${V.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-neutral-300 flex-shrink-0"},[S[9]||(S[9]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(V.value),1)],8,Xp),e("div",Yp,[Pe(e("textarea",{"onUpdate:modelValue":S[2]||(S[2]=L=>x.value=L),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref_key:"textareaRef",ref:c,onInput:Z,onKeydown:[S[3]||(S[3]=yt(Me(L=>N("user"),["meta"]),["enter"])),S[4]||(S[4]=yt(Me(L=>N("user"),["ctrl"]),["enter"]))]},null,544),[[De,x.value]])]),e("button",{onClick:S[5]||(S[5]=L=>N("user")),type:"button",disabled:!x.value.trim(),title:`Add as ${P.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-neutral-300 flex-shrink-0"},[S[10]||(S[10]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(P.value),1)],8,Qp)]),e("p",e2," Type a message and click "+C(V.value)+" (left) or "+C(P.value)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+C(P.value)+". ",1)])])),e("div",null,[M(Ee,{modelValue:i.value,"onUpdate:modelValue":S[6]||(S[6]=L=>i.value=L),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),S[12]||(S[12]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"]))}}),s2={class:"flex h-full overflow-hidden"},n2={key:0,class:"flex flex-col items-center p-4"},r2={key:0,class:"flex flex-col items-center p-4"},i2={key:0,class:"flex flex-col items-center p-4"},Nt=re({__name:"ThreadsView",setup(t){const s=We(),n=ot(),r=f(typeof s.params.id=="string"?s.params.id:null),a=f({threadList:!1,messages:!1,logs:!1}),u=f(!1),i=f(null),p=f(null),{thread:m}=Ct(W(()=>r.value)),x=f(null),d=f(null),v=f(null),c=f(null),k=f(null),g=$=>{c.value=$,k.value=$},h=$=>{if(c.value=$,!$){k.value=null;return}k.value=$;const E=w.value,_=b.value;if(!E||!_||E.hasWorkblockForLogId($))return;let S=$;const L=10;for(let J=0;J<L&&S;J++){const X=_.getLog(S);if(!X)break;const G=X.parent_log_id;if(!G)break;if(E.hasWorkblockForLogId(G)){k.value=G;return}S=G}},w=f(null),b=f(null);pe(()=>s.params.id,$=>{r.value=typeof $=="string"?$:null,x.value=null,d.value=null,v.value=null});const V=$=>{n.push(`/threads/${$}`)},P=$=>{window.location.href="/threads"},U=()=>{m.value&&(i.value=m.value,u.value=!0)},q=()=>{i.value=null,u.value=!0},K=$=>{p.value?.refetch(),n.push(`/threads/${$}`)},R=()=>{window.location.reload()},j=$=>{a.value[$]=!a.value[$]},Z=async($,E)=>{if(x.value=$,!E){d.value=null,v.value=null;return}const _=b.value;if(!_){d.value=E,v.value=E;return}const S=!_.hasLog(E);if(S&&_.setLoadingForLog(!0),d.value=E,v.value=E,S&&!await _.loadUntilLogId(E)){console.warn(`Could not find log ${E} after loading all available logs`),_.setLoadingForLog(!1);return}if(!await _.waitForLogRow(E)){console.warn(`Log row ${E} not rendered in time`);return}_.scrollToLog(E),_.selectLogById(E)},N=$=>{d.value=$,v.value=$,x.value=null;const E=w.value,_=b.value;if(!E||!_)return;let S=E.scrollToLogId($);if(S)return;let L=$;const J=10;for(let X=0;X<J&&L;X++){const G=_.getLog(L);if(!G)break;const D=G.parent_log_id;if(!D)break;if(S=E.scrollToLogId(D),S){v.value=D;return}L=D}},F=$=>{$&&(d.value=$)},B=$=>{b.value?.removeLogsByIds($)},y=$=>{$&&!r.value&&n.push(`/threads/${$}`)};return($,E)=>(o(),l("div",s2,[e("div",{class:Q([a.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200 flex flex-col min-h-0"])},[a.value.threadList?(o(),l("div",n2,[e("button",{onClick:E[0]||(E[0]=_=>j("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[M(H(Kt),{size:20})])])):(o(),Y(Ar,{key:1,ref_key:"threadListPaneRef",ref:p,"selected-thread-id":r.value,onSelectThread:V,onCollapse:E[1]||(E[1]=_=>j("threadList")),onCreateThread:q,onThreadsLoaded:y},null,8,["selected-thread-id"]))],2),e("div",{class:Q([a.value.messages?"w-[60px]":"w-[380px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200 flex flex-col min-h-0"])},[a.value.messages?(o(),l("div",r2,[e("button",{onClick:E[2]||(E[2]=_=>j("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[M(H(Yt),{size:20})])])):r.value?(o(),Y(H(ha),{key:1,"thread-id":r.value,preload:!0,live:!0,"include-silent":!0},{default:ce(()=>[M(Dt,{ref_key:"messagesPaneRef",ref:w,"thread-id":r.value,"selected-message-id":x.value,"selected-log-id":v.value,"hovered-log-id":k.value,onCollapse:E[3]||(E[3]=_=>j("messages")),onMessageClick:Z,onMessageHover:g,onThreadDeleted:P,onEditThread:U,onLogsDeleted:B},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):a.value.messages?T("",!0):(o(),Y(Dt,{key:2,ref_key:"messagesPaneRef",ref:w,"thread-id":null,"selected-message-id":x.value,"selected-log-id":v.value,"hovered-log-id":k.value,onCollapse:E[4]||(E[4]=_=>j("messages")),onMessageClick:Z,onMessageHover:g,onThreadDeleted:P,onEditThread:U,onLogsDeleted:B},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",{class:Q([a.value.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200 flex flex-col min-h-0"])},[a.value.logs?(o(),l("div",i2,[e("button",{onClick:E[5]||(E[5]=_=>j("logs")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Logs pane"},[M(H(Qt),{size:20})])])):(o(),Y(Ip,{key:1,ref_key:"logsPaneRef",ref:b,"thread-id":r.value,"selected-log-id":d.value,"hovered-log-id":c.value,onCollapse:E[6]||(E[6]=_=>j("logs")),onLogClick:N,onLogHover:h,onLogsLoaded:F},null,8,["thread-id","selected-log-id","hovered-log-id"]))],2),M(l2,{modelValue:u.value,"onUpdate:modelValue":E[7]||(E[7]=_=>u.value=_),"edit-thread":i.value,onThreadCreated:K,onThreadUpdated:R},null,8,["modelValue","edit-thread"])]))}}),d2=re({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(t,{expose:s,emit:n}){const r=n,a=f([]),u=f(!1),i=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(d,v)=>d||v.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:d=>r("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await x(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],m=async()=>{u.value=!0;try{const d=await fetch(le("/api/prompts"));if(d.ok){const v=await d.json();a.value=v.prompts||[]}}catch(d){console.error("Error fetching prompts:",d)}finally{u.value=!1}},x=async d=>{try{const v=await fetch(le(`/api/prompts/${d.id}`),{method:"DELETE"});if(v.ok)await m();else{const c=await v.json();alert(c.error||"Failed to delete prompt")}}catch(v){console.error("Error deleting prompt:",v),alert("Failed to delete prompt")}};return Te(()=>{m()}),s({refresh:m}),(d,v)=>(o(),l("div",null,[M(He,{columns:i,data:a.value,actions:p,loading:u.value,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])]))}}),u2={class:"space-y-4"},c2={key:0,class:"mt-1 text-sm text-red-500"},p2={key:1,class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"},m2={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},v2=["value"],h2=re({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:s}){const n=t,r=s,a=f(""),u=p=>{let m=p.replace(/[^a-zA-Z0-9\s_]/g,"");return m=m.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),m?/^[a-z][a-z0-9_]*$/.test(m)?a.value="":a.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":a.value="Name is required",m},i=p=>{const m=u(p);r("update:name",m)};return pe(()=>n.name,p=>{p&&u(p)},{immediate:!0}),(p,m)=>(o(),l("div",u2,[e("div",null,[M(Ee,{"model-value":t.name,"onUpdate:modelValue":i,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),a.value?(o(),l("p",c2,C(a.value),1)):t.name?(o(),l("p",p2,[m[1]||(m[1]=Ve(" Will be saved as: ",-1)),e("code",m2,C(t.name),1)])):T("",!0)]),e("div",null,[m[2]||(m[2]=e("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),e("textarea",{value:t.toolDescription,onInput:m[0]||(m[0]=x=>r("update:toolDescription",x.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,v2)])]))}}),f2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",_t="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",g2="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",Ft="/agents/assets/img/meta.svg",b2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",x2="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",y2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",k2="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",w2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",_2="/agents/assets/img/moonshotai.svg",$2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",C2="/agents/assets/img/zai.svg",S2="/agents/assets/img/zai.svg",T2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",go="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function V2(t){const s=at();return s==="/"?t.replace("/agents/","/"):t.replace("/agents/",`${s}/`)}const M2={anthropic:f2,openai:_t,"openai-sdk":_t,google:g2,meta:Ft,"meta-llama":Ft,nvidia:b2,alibaba:x2,deepseek:y2,qwen:k2,minimax:w2,moonshotai:_2,"x-ai":$2,"z-ai":C2,zai:S2,exaone:T2,openrouter:go},I2=new Proxy(M2,{get(t,s){const n=t[s];return n?V2(n):void 0}});function L2(t){if(t&&t.includes("/"))return t.split("/")[0].toLowerCase()}function pt(t){return I2[t.toLowerCase()]}function tt(t,s){const n=L2(t);if(n){const r=pt(n);if(r)return r}if(s)return pt(s)}const E2={class:"space-y-4"},A2=re({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:s}){const n=s,r=f([]),a=f(!1),u=W(()=>r.value.map(p=>({value:p.id,label:p.name,description:p.model||p.provider,icon:tt(p.model||p.name,p.provider_id||p.provider)}))),i=async()=>{a.value=!0;try{const p=await fetch(le("/api/models"));if(p.ok){const m=await p.json();r.value=m.models||[]}}catch(p){console.error("Error fetching models:",p)}finally{a.value=!1}};return Te(()=>{i()}),(p,m)=>(o(),l("div",E2,[M(_e,{"model-value":t.modelValue,"onUpdate:modelValue":m[0]||(m[0]=x=>n("update:modelValue",x)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:a.value},null,8,["model-value","options","loading"])]))}}),P2=["data-property-id","data-nested-property-id"],j2={class:"p-3 space-y-3"},O2={class:"flex items-start gap-2"},U2={key:0,class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400 mt-2"},R2={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},D2={class:"flex items-center gap-2 mt-2"},B2=["disabled"],N2={key:0,class:"ml-6"},F2={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},q2={class:"flex items-center justify-between mb-2"},z2=["disabled"],H2={key:0,class:"space-y-1"},W2=["onClick","disabled"],J2={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Z2={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},K2={class:"space-y-2"},G2={class:"flex items-center justify-between"},X2=["disabled"],Y2={class:"space-y-2"},Q2={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},em={key:0,class:"mb-2"},tm=["disabled"],om={key:1,class:"space-y-2"},am=re({__name:"PropertyEditor",props:qe({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:qe(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:s}){const n=t,r=s,a=Xe(t,"modelValue"),u=f(!1);f();const i=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],p=W(()=>["object","array","enum","anyOf"].includes(a.value.type));pe(()=>a.value.type,async(g,h)=>{if(["object","array","enum","anyOf"].includes(g)&&(u.value=!0,g==="anyOf"&&!a.value.anyOf&&(a.value.anyOf=[]),g==="object"&&!a.value.properties&&(a.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),g==="array"&&!a.value.items&&(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),g==="enum"&&!a.value.enum&&(a.value.enum=["value1"])),h!==void 0){await Ce();const w=n.isNested?`[data-nested-property-id="${n.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${n.propertyId}"] input[placeholder="Description"]`,b=document.querySelector(w);b&&b.focus()}});const m=g=>{g.shiftKey&&a.value.type==="object"&&a.value.properties?c():r("add-top-level")},x=()=>{a.value.items||(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},d=()=>{a.value.enum||(a.value.enum=[]),a.value.enum.push(`value${a.value.enum.length+1}`)},v=g=>{a.value.enum&&a.value.enum.splice(g,1)},c=async()=>{const g={id:crypto.randomUUID(),name:a.value.type==="anyOf"?"":`property${(a.value.properties?.length||a.value.anyOf?.length||0)+1}`,type:"string",description:""};a.value.type==="anyOf"?(a.value.anyOf||(a.value.anyOf=[]),a.value.anyOf.push(g)):(a.value.properties||(a.value.properties=[]),a.value.properties.push(g)),await Ce();const h=document.querySelector(`[data-nested-property-id="${g.id}"] input[placeholder="Property name"]`);h&&(h.focus(),h.select())},k=g=>{a.value.type==="anyOf"&&a.value.anyOf?a.value.anyOf=a.value.anyOf.filter(h=>h.id!==g):a.value.properties&&(a.value.properties=a.value.properties.filter(h=>h.id!==g))};return(g,h)=>{const w=Jo("PropertyEditor",!0);return o(),l("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:Q(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",j2,[e("div",O2,[t.enableDrag?(o(),l("div",U2,[...h[10]||(h[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):T("",!0),e("div",R2,[M(Ee,{modelValue:a.value.name,"onUpdate:modelValue":h[0]||(h[0]=b=>a.value.name=b),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),M(_e,{modelValue:a.value.type,"onUpdate:modelValue":h[1]||(h[1]=b=>a.value.type=b),options:i,disabled:t.disabled},null,8,["modelValue","disabled"]),M(Ee,{modelValue:a.value.description,"onUpdate:modelValue":h[2]||(h[2]=b=>a.value.description=b),placeholder:"Description",disabled:t.disabled,onKeydown:h[3]||(h[3]=yt(Me(b=>m(b),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",D2,[p.value?(o(),l("button",{key:0,onClick:h[4]||(h[4]=b=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(o(),l("svg",{class:Q(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...h[11]||(h[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):T("",!0),e("button",{onClick:h[5]||(h[5]=b=>g.$emit("remove")),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...h[12]||(h[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,B2)])]),u.value&&p.value?(o(),l("div",N2,[a.value.type==="enum"?(o(),l("div",F2,[e("div",q2,[h[13]||(h[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:d,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,z2)]),a.value.enum?(o(),l("div",H2,[(o(!0),l(he,null,ye(a.value.enum,(b,V)=>(o(),l("div",{key:V,class:"flex items-center gap-2"},[M(Ee,{modelValue:a.value.enum[V],"onUpdate:modelValue":P=>a.value.enum[V]=P,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:P=>v(V),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...h[14]||(h[14]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,W2)]))),128))])):T("",!0)])):T("",!0),a.value.type==="object"||a.value.type==="anyOf"?(o(),l("div",J2,[e("h4",Z2,C(a.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",K2,[e("div",G2,[e("button",{onClick:c,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add "+C(a.value.type==="anyOf"?"Type Option":"Property"),9,X2)]),e("div",Y2,[(o(!0),l(he,null,ye(a.value.type==="anyOf"?a.value.anyOf:a.value.properties,(b,V)=>(o(),Y(w,{key:b.id,modelValue:(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[V],"onUpdate:modelValue":P=>(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[V]=P,"property-id":b.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:P=>k(b.id),onAddTopLevel:h[6]||(h[6]=P=>r("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):T("",!0),a.value.type==="array"?(o(),l("div",Q2,[h[15]||(h[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),a.value.items?T("",!0):(o(),l("div",em,[e("button",{onClick:x,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,tm)])),a.value.items?(o(),l("div",om,[M(w,{modelValue:a.value.items,"onUpdate:modelValue":h[7]||(h[7]=b=>a.value.items=b),"property-id":a.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:h[8]||(h[8]=b=>a.value.items=null),onAddTopLevel:h[9]||(h[9]=b=>r("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):T("",!0)])):T("",!0)])):T("",!0)])],10,P2)}}}),lm={class:"space-y-2"},sm=["disabled"],nm=re({__name:"PropertyList",props:qe({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:qe(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:s,emit:n}){const r=t,a=n,u=Xe(t,"modelValue"),i=f();let p=!1;Te(async()=>{}),Ne(()=>{});const m=async()=>{if(p)return;p=!0;const d={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,d],await Ce();const v=r.parentId?`[data-nested-property-id="${d.id}"]`:`[data-property-id="${d.id}"]`,c=document.querySelector(`${v} input[placeholder="Property name"]`);c&&(c.focus(),c.select()),a("add-property"),p=!1},x=d=>{u.value=u.value.filter(v=>v.id!==d)};return s({addProperty:m}),(d,v)=>(o(),l("div",lm,[e("div",{ref_key:"dragAreaRef",ref:i,class:"space-y-2"},[(o(!0),l(he,null,ye(u.value,c=>(o(),Y(am,{key:c.id,modelValue:u.value[u.value.indexOf(c)],"onUpdate:modelValue":k=>u.value[u.value.indexOf(c)]=k,"property-id":c.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:k=>x(c.id),onAddTopLevel:v[0]||(v[0]=k=>d.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:Q(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:m,type:"button",disabled:t.disabled,class:Q(t.isNested?"px-2 py-1 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-neutral-50 dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded transition-colors disabled:opacity-50 border border-dashed border-neutral-300 dark:border-neutral-700")},[...v[1]||(v[1]=[e("span",{class:"flex items-center justify-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),Ve(" Add Property ")],-1)])],10,sm)],2)]))}}),rm={class:"space-y-4"},im={key:0,class:"flex items-center justify-between"},dm={class:"text-sm font-medium"},um={key:0,class:"text-red-500"},cm={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},pm={key:0,class:"flex items-center justify-between mb-2"},mm={key:1,class:"text-center py-12"},vm=["disabled"],hm={class:"mt-4 text-center"},fm={key:3,class:"mt-4"},gm={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},bm={class:"text-xs leading-relaxed"},xm=["innerHTML"],bo=re({__name:"JSONSchemaInput",props:qe({label:{},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const s=Xe(t,"modelValue"),n=f([]),r=f(),a=f(!1),u=()=>{if(s.value?.properties){const g=[];s.value.required;for(const[h,w]of Object.entries(s.value.properties)){const b=w,V={id:crypto.randomUUID(),name:h,type:b.type||"string",description:b.description||""};b.enum&&(V.enum=b.enum),b.anyOf&&(V.type="anyOf",V.anyOf=i(b.anyOf)),b.type==="array"&&b.items&&(V.items=p(b.items)),b.type==="object"&&b.properties&&(V.properties=m(b.properties,b.required||[])),g.push(V)}n.value=g}},i=g=>g.map(h=>typeof h=="object"&&h.type?{id:crypto.randomUUID(),name:"",type:h.type,description:h.description||"",properties:h.properties?m(h.properties,h.required||[]):void 0,items:h.items?p(h.items):void 0,enum:h.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),p=g=>{const h={id:crypto.randomUUID(),name:"",type:g.type||"string",description:g.description||""};return g.enum&&(h.enum=g.enum),g.anyOf&&(h.type="anyOf",h.anyOf=i(g.anyOf)),g.type==="array"&&g.items&&(h.items=p(g.items)),g.type==="object"&&g.properties&&(h.properties=m(g.properties,g.required||[])),h},m=(g,h)=>{const w=[];for(const[b,V]of Object.entries(g)){const P=V,U={id:crypto.randomUUID(),name:b,type:P.type||"string",description:P.description||""};P.enum&&(U.enum=P.enum),P.anyOf&&(U.type="anyOf",U.anyOf=i(P.anyOf)),P.type==="array"&&P.items&&(U.items=p(P.items)),P.type==="object"&&P.properties&&(U.properties=m(P.properties,P.required||[])),w.push(U)}return w};u();const x=()=>{const g={type:"object",properties:{},required:[],additionalProperties:!1},{properties:h}=v(n.value);g.properties=h,g.required=Object.keys(h),s.value=g},d=g=>{const h={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(g.type==="enum"&&g.enum&&(h.enum=g.enum,h.type="string"),g.type==="anyOf"&&g.anyOf&&(delete h.type,h.anyOf=g.anyOf.map(d)),g.type==="object"&&g.properties){const{properties:w}=v(g.properties);h.properties=w,h.required=Object.keys(w),h.additionalProperties=!1}return g.type==="array"&&g.items&&(h.items=d(g.items)),h},v=g=>{const h={},w=[];for(const b of g){const V={type:b.type==="anyOf"?void 0:b.type,description:b.description};if(w.push(b.name),b.type==="enum"&&b.enum&&(V.enum=b.enum,V.type="string"),b.type==="anyOf"&&b.anyOf&&b.anyOf.length>0&&(delete V.type,V.anyOf=b.anyOf.map(d)),b.type==="array"&&b.items&&(V.items=d(b.items)),b.type==="object"&&b.properties){const{properties:P}=v(b.properties);V.properties=P,V.required=Object.keys(P),V.additionalProperties=!1}h[b.name]=V}return{properties:h,required:w}};pe(n,()=>{x()},{deep:!0}),x();const c=W(()=>JSON.stringify(s.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),k=async()=>{if(n.value.length===0){const g={id:crypto.randomUUID(),name:"property1",type:"string",description:""};n.value.push(g),await Ce();const h=document.querySelector(`[data-property-id="${g.id}"] input[placeholder="Property name"]`);h&&(h.focus(),h.select())}else r.value&&r.value.addProperty()};return(g,h)=>(o(),l("div",rm,[t.label?(o(),l("div",im,[e("label",dm,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",um,"*")):T("",!0)])])):T("",!0),e("div",cm,[n.value.length>0?(o(),l("div",pm,[...h[2]||(h[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):T("",!0),n.value.length===0?(o(),l("div",mm,[h[4]||(h[4]=e("div",{class:"mb-4"},[e("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),h[5]||(h[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:k,type:"button",disabled:t.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...h[3]||(h[3]=[e("span",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),Ve(" Add Property ")],-1)])],8,vm)])):T("",!0),n.value.length>0?(o(),Y(nm,{key:2,ref_key:"propertyListRef",ref:r,modelValue:n.value,"onUpdate:modelValue":h[0]||(h[0]=w=>n.value=w),disabled:t.disabled,onAddProperty:k},null,8,["modelValue","disabled"])):T("",!0),e("div",hm,[e("button",{onClick:h[1]||(h[1]=w=>a.value=!a.value),type:"button",class:"text-xs text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:underline transition-colors"},C(a.value?"Hide":"Show")+" JSON Schema ",1)]),a.value?(o(),l("div",fm,[e("div",gm,[e("pre",bm,[e("code",{class:"font-mono",innerHTML:c.value},null,8,xm)])])])):T("",!0)])]))}}),ym={class:"prompt-input-container relative"},km=["contenteditable","data-placeholder"],wm={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},_m={key:0,class:"p-3 text-sm text-neutral-500"},$m={key:1,class:"p-3 text-sm text-neutral-500"},Cm={key:2,class:"max-h-[220px] overflow-y-auto"},Sm=["onClick"],Tm={class:"font-medium flex items-center gap-2"},Vm=["title"],Mm={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Im={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Lm={class:"text-xs mt-1"},Em=re({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(t,{emit:s}){const n=t,r=s,a=f(),u=f(),i=Zo({segments:n.modelValue&&n.modelValue.length?n.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),m=y=>y.type==="string"?"":`@${y.type==="variable"?y.label||y.value:y.label||y.id}`,x=()=>{const y=window.getSelection();if(!y||!y.rangeCount||!a.value)return null;const $=y.getRangeAt(0);let E=0;const _=Array.from(a.value.childNodes);for(let S=0;S<_.length;S++){const L=_[S];if(L===$.startContainer||L.contains?.($.startContainer)){if(L.nodeType===Node.TEXT_NODE)return{segmentIndex:E,offset:$.startOffset};if(L.nodeType===Node.ELEMENT_NODE&&L.classList?.contains("prompt-tag"))return{segmentIndex:E,offset:0}}(L.nodeType===Node.TEXT_NODE||L.nodeType===Node.ELEMENT_NODE&&L.classList?.contains("prompt-tag"))&&E++}return{segmentIndex:0,offset:0}},d=()=>{if(!a.value)return;const y=i.segments.map($=>{if($.type==="string")return($.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const E=$._uid||($._uid=p()),_=m($),S=$.type==="variable"?{type:"variable",value:$.value,label:$.label,schema:$.schema,meta:$.meta}:{type:"prompt",id:$.id,label:$.label,schema:$.schema,meta:$.meta},L=encodeURIComponent(JSON.stringify(S)),J=$.type==="prompt"&&$.meta&&!$.meta.isValid,X=J?'<span class="prompt-tag-warning" title="'+($.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${J?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${E}" data-segment="${L}">${_}${X}</span>`}}).join("");a.value.innerHTML=y||"<br>"},v=()=>{const y=[];for(const $ of i.segments)$.type==="string"&&y.length>0&&y[y.length-1].type==="string"?y[y.length-1].value+=$.value:y.push($);i.segments=y.length?y:[{type:"string",value:""}]},c=y=>{const $=y.dataset.segmentUid;let E=i.segments.find(_=>_._uid===$);if(!E){const _=y.dataset.segment;if(_)try{const S=JSON.parse(decodeURIComponent(_));S&&(S.type==="variable"||S.type==="prompt")&&(E=S.type==="variable"?{type:"variable",value:S.value,label:S.label,schema:S.schema,meta:S.meta,_uid:$}:{type:"prompt",id:S.id,label:S.label,schema:S.schema,meta:S.meta,_uid:$})}catch{}}return E||null},k=y=>{const $=y.target;if($.classList?.contains("prompt-tag")){const E=c($);E&&r("segment-click",E,y)}},g=y=>{if(i.isComposing)return;const $=y.target,E=[];let _="";const S=()=>{_.length>0&&(E.push({type:"string",value:_}),_="")},L=D=>{if(D.nodeType===Node.TEXT_NODE){const O=(D.textContent||"").replace(/\u00A0/g," ");_+=O;return}if(D.nodeType===Node.ELEMENT_NODE){const O=D;if(O.classList?.contains("prompt-tag")){S();const de=c(O);de&&E.push(de);return}if(O.tagName==="BR"){_+=`
14
+ `),E+=` -d '${$.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(E),m.value=!0,setTimeout(()=>{m.value=!1},2e3)}catch(B){console.error("Failed to copy cURL command:",B),alert(`Failed to copy cURL: ${B instanceof Error?B.message:"Unknown error"}`)}finally{p.value=!1}};return(B,y)=>(o(),l("div",{ref_key:"scrollContainer",ref:x,class:"p-4 h-full overflow-y-auto"},[e("div",ju,[e("div",Ou,[e("div",Uu,[e("button",{onClick:y[0]||(y[0]=$=>r("previous")),disabled:!t.hasPrevious,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Previous log",title:"Previous log"},[...y[9]||(y[9]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,Ru),e("button",{onClick:y[1]||(y[1]=$=>r("next")),disabled:!t.hasNext,class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent transition-all","aria-label":"Next log",title:"Next log"},[...y[10]||(y[10]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,Du)]),e("h3",Bu,C(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",Nu,[e("button",{onClick:F,disabled:p.value||!t.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:t.log.request_body?"Copy cURL command":"No request data available"},[p.value?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",qu,C(m.value?"Copied!":"Copy cURL"),1))],8,Fu),e("button",{onClick:y[2]||(y[2]=$=>r("close")),class:"w-7 h-7 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:text-neutral-200 dark:hover:bg-neutral-800 transition-all","aria-label":"Close details",title:"Close"},[...y[11]||(y[11]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),e("div",zu,[e("div",Hu,[e("table",Wu,[y[12]||(y[12]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:Q(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",Ju,C(t.log.provider),1),e("td",Zu,[!t.log.is_complete&&!t.log.prompt_name?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Ku,C(t.log.prompt_name||"—"),1))]),e("td",Gu,[!t.log.is_complete&&!t.log.latency_ms?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Xu,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",Yu,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Qu,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",ec,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",tc,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",oc,[M(ct,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",ac,[e("table",lc,[y[13]||(y[13]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt ")])],-1)),e("tbody",null,[e("tr",null,[e("td",{class:Q(["py-1 font-mono",t.log.error?"text-red-600 dark:text-red-400":t.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(t.log.error?"ERROR":t.log.is_complete?"SUCCESS":"LOADING"),3),e("td",sc,C(t.log.provider),1),e("td",nc,[!t.log.is_complete&&!t.log.prompt_name?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",rc,C(t.log.prompt_name||"—"),1))])])])]),e("table",ic,[y[14]||(y[14]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),e("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),e("tbody",null,[e("tr",null,[e("td",dc,[!t.log.is_complete&&!t.log.latency_ms?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",uc,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",cc,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",pc,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",mc,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",vc,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",hc,[M(ct,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",fc,[e("div",gc,[e("button",{onClick:y[3]||(y[3]=$=>a.value="request"),class:Q(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",a.value==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])}," Request ",2),e("button",{onClick:y[4]||(y[4]=$=>a.value="response"),class:Q(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",a.value==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"])},[y[15]||(y[15]=Ve(" Response ",-1)),t.log.error||N.value.length>0?(o(),l("span",bc,"⚠")):T("",!0)],2)])]),e("div",xc,[Pe(e("div",yc,[b.value.length>0?(o(),Y(it,{key:0,ref_key:"toolsSectionRef",ref:d,title:`Available Tools (${b.value.length})`,"section-id":"tools",expanded:Z("tools"),"scroll-container":x.value,onToggle:y[5]||(y[5]=$=>j("tools"))},{default:ce(()=>[(o(!0),l(he,null,ye(b.value,($,E)=>(o(),l("div",{key:E,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>K(E),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",wc,C($.function?.name||$.name||"Unknown"),1),e("span",_c,C(u.value.has(E)?"▼":"▶"),1)],8,kc),Pe(e("div",$c,[$.function?.description||$.description?(o(),l("div",Cc,C($.function?.description||$.description),1)):T("",!0),M(gt,{code:JSON.stringify($,null,2),language:"json"},null,8,["code"])],512),[[Je,u.value.has(E)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):T("",!0),t.log.message_history?(o(),Y(it,{key:1,ref_key:"messagesSectionRef",ref:v,title:`Messages (${t.log.message_history_length||0} messages)`,"section-id":"messages",expanded:Z("messages"),"scroll-container":x.value,onToggle:y[6]||(y[6]=$=>j("messages"))},{default:ce(()=>[M(ut,{json:t.log.message_history,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","expanded","scroll-container"])):T("",!0),t.log.system_prompt?(o(),Y(it,{key:2,ref_key:"systemPromptSectionRef",ref:c,title:"System Prompt","section-id":"system_prompt",expanded:Z("system_prompt"),"scroll-container":x.value,onToggle:y[7]||(y[7]=$=>j("system_prompt"))},{default:ce(()=>[e("div",Sc,[M(gt,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",Tc,[M(fo,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):T("",!0),t.log.request_body?(o(),Y(it,{key:3,ref_key:"requestBodySectionRef",ref:k,title:"Full Request Body","section-id":"request_body",expanded:Z("request_body"),"scroll-container":x.value,onToggle:y[8]||(y[8]=$=>j("request_body"))},{default:ce(()=>[M(ut,{json:t.log.request_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["expanded","scroll-container"])):T("",!0)],512),[[Je,a.value==="request"]]),Pe(e("div",null,[N.value.length>0?(o(),l("div",Vc,[e("div",Mc,C(N.value.length>1?`Errors (${N.value.length})`:"Error"),1),e("div",Ic,[(o(!0),l(he,null,ye(N.value,($,E)=>(o(),l("div",{key:E,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",Lc,C($.type||"error"),1),e("pre",Ec,C($.message),1)]))),128))])])):t.log.error?(o(),l("div",Ac,[e("div",Pc," Error "+C(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",jc,C(t.log.error),1)])):T("",!0),t.log.is_complete||!t.log.error?(o(),l("div",Oc,[y[23]||(y[23]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",Uc,[e("tbody",null,[e("tr",Rc,[y[16]||(y[16]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Finish Reason ",-1)),e("td",Dc,[!t.log.is_complete&&!t.log.finish_reason?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Bc,C(t.log.finish_reason||"—"),1))])]),e("tr",Nc,[y[17]||(y[17]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Input Tokens ",-1)),e("td",Fc,[!t.log.is_complete&&!t.log.input_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",qc,C(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(o(),l("tr",zc,[y[18]||(y[18]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Cached Tokens ",-1)),e("td",Hc,[!t.log.is_complete&&!t.log.cached_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Wc,C(t.log.cached_tokens||0),1))])])):T("",!0),e("tr",Jc,[y[19]||(y[19]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Output Tokens ",-1)),e("td",Zc,[!t.log.is_complete&&!t.log.output_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",Kc,C(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(o(),l("tr",Gc,[y[20]||(y[20]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Reasoning Tokens ",-1)),e("td",Xc,C(t.log.reasoning_tokens),1)])):T("",!0),e("tr",Yc,[y[21]||(y[21]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Tokens ",-1)),e("td",Qc,[!t.log.is_complete&&!t.log.total_tokens?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",e0,C(t.log.total_tokens||"—"),1))])]),e("tr",null,[y[22]||(y[22]=e("td",{class:"py-1 px-2 text-neutral-600 dark:text-neutral-400 font-medium bg-neutral-50 dark:bg-neutral-950"}," Total Cost ",-1)),e("td",t0,[!t.log.is_complete&&!t.log.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",o0,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):T("",!0),V.value.length>0?(o(),l("div",a0,[e("div",l0," Tools Called ("+C(V.value.length)+") ",1),e("div",s0,[(o(!0),l(he,null,ye(V.value,($,E)=>(o(),l("div",{key:E,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:_=>R(E),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[e("span",r0,C($.function?.name||"Unknown"),1),e("span",i0,C(i.value.has(E)?"▼":"▶"),1)],8,n0),Pe(e("div",d0,[e("div",u0,[y[24]||(y[24]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",c0,C($.id),1)]),e("div",p0,[y[25]||(y[25]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",m0,C($.function?.name),1)]),e("div",v0,[y[26]||(y[26]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",h0,[M(gt,{code:w($.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),P.value.has($.id)?(o(),l("div",f0,[y[27]||(y[27]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",g0,C(P.value.get($.id)?.content||"No content"),1)])):(o(),l("div",b0,[...y[28]||(y[28]=[e("div",{class:"font-semibold text-neutral-500 dark:text-neutral-500 mb-1"}," Result ",-1),e("div",{class:"text-xs text-neutral-500 dark:text-neutral-500 italic"}," No result available ",-1)])]))],512),[[Je,i.value.has(E)]])]))),128))])])):T("",!0),q.value.length>0?(o(),l("div",x0,[e("div",y0," Generated Images ("+C(q.value.length)+") ",1),e("div",k0,[y[29]||(y[29]=e("div",{class:"px-2 py-1.5 bg-emerald-100 dark:bg-emerald-900/30 text-xs text-emerald-800 dark:text-emerald-200 border-b border-emerald-300 dark:border-emerald-700"}," Images returned by the model ",-1)),e("div",w0,[(o(!0),l(he,null,ye(q.value,($,E)=>(o(),l("div",{key:E,class:"relative"},[$.image_url?.url?(o(),l("img",{key:0,src:h($.image_url.url)||$.image_url.url,alt:`Generated image ${E+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,_0)):(o(),l("div",$0," No URL "))]))),128))])])])):T("",!0),t.log.reasoning_content?(o(),l("div",C0,[y[31]||(y[31]=e("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),e("div",S0,[y[30]||(y[30]=e("div",{class:"px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 border-b border-accent-300 dark:border-accent-700"}," Internal reasoning output (not displayed to users) ",-1)),e("pre",T0,C(t.log.reasoning_content),1)])])):T("",!0),U.value.length>0?(o(),l("div",V0,[e("div",M0," Reasoning Details ("+C(U.value.length)+" blocks) ",1),e("div",I0,[y[36]||(y[36]=e("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),e("div",L0,[(o(!0),l(he,null,ye(U.value,($,E)=>(o(),l("div",{key:E,class:"p-2"},[e("div",E0,[e("span",A0,C($.type||"unknown"),1),$.id?(o(),l("span",P0," ID: "+C($.id),1)):T("",!0),$.format?(o(),l("span",j0," Format: "+C($.format),1)):T("",!0),$.index!==void 0?(o(),l("span",O0," Index: "+C($.index),1)):T("",!0)]),$.type==="reasoning.summary"&&$.summary?(o(),l("div",U0,[y[32]||(y[32]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",R0,C($.summary),1)])):T("",!0),$.type==="reasoning.encrypted"&&$.data?(o(),l("div",D0,[y[33]||(y[33]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",B0,C($.data),1)])):T("",!0),$.type==="reasoning.text"&&$.text?(o(),l("div",N0,[y[35]||(y[35]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",F0,C($.text),1),$.signature?(o(),l("div",q0,[y[34]||(y[34]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",z0,C($.signature),1)])):T("",!0)])):T("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes($.type)?T("",!0):(o(),l("div",H0,[e("pre",W0,C(JSON.stringify($,null,2)),1)]))]))),128))])])])):T("",!0),t.log.response_body?(o(),l("div",J0,[y[37]||(y[37]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",Z0,[M(ut,{json:t.log.response_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):T("",!0)],512),[[Je,a.value==="response"]])])],512))}}),G0={class:"flex flex-col h-full"},X0={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Y0={class:"flex items-center justify-between"},Q0={class:"flex items-center gap-2"},ep={class:"flex items-center gap-2"},tp={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},op={key:1,class:"flex justify-center py-12"},ap={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},lp={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},sp={key:4},np={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},rp=["disabled"],ip={key:1},dp={key:2},up={key:3},cp={class:"w-full text-sm"},pp=["onClick","onMouseenter"],mp={class:"px-3 py-2 text-xs"},vp={class:"flex items-center gap-1"},hp={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},fp={key:3},gp={class:"px-3 py-2"},bp={class:"flex items-center gap-2"},xp={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},yp={class:"font-mono text-xs"},kp={class:"px-3 py-2 font-mono text-xs"},wp={key:1},_p={key:1},$p={key:0,class:"log-details-panel relative shrink-0 bg-neutral-100 dark:bg-neutral-950 border-t border-neutral-300 dark:border-neutral-700 overflow-hidden"},Cp={class:"m-2 border h-[calc(100%-1rem)] border-neutral-300 shrink-0 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-auto"},Sp={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},Tp={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},Bt=20,Vp=20,Mp=re({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","logClick","logHover","logsLoaded"],setup(t,{expose:s,emit:n}){const r=t,a=n,u=f(0),i=f(Bt),{logs:p,hasMore:m,isFetching:x,error:d,wsConnected:v,wsError:c,connectWebSocket:k,disconnectWebSocket:g,refetch:h}=gu(W(()=>r.threadId),{limit:W(()=>i.value),offset:W(()=>u.value),enableWebSocket:!0,order:"desc"}),w=f([]),b=f(!0),V=f(null),P=f(null),U=f(!1),q=f(!1),K=f(new Map),R=async()=>{await Ce(),P.value&&(P.value.scrollTop=P.value.scrollHeight)},j=f(null);pe(p,async oe=>{if(u.value===0)w.value=[...oe].reverse(),b.value&&w.value.length>0&&(await R(),b.value=!1);else{const ie=[...oe].reverse(),ne=new Map;w.value.forEach(be=>ne.set(be.id,be)),ie.forEach(be=>ne.set(be.id,be)),w.value=Array.from(ne.values()).sort((be,xe)=>be.created_at-xe.created_at)}},{deep:!0,immediate:!0}),pe(x,(oe,ie)=>{if(ie&&!oe&&u.value===0&&r.threadId&&j.value!==r.threadId&&w.value.length>0){j.value=r.threadId;const ne=w.value[w.value.length-1];a("logsLoaded",ne?.id??null)}});const{logDetails:Z,isFetching:N}=bu(W(()=>r.threadId),W(()=>V.value)),F=W(()=>{if(!V.value)return null;const ie=w.value.find(ne=>ne.id===V.value);return ie?Z.value?{...Z.value,...ie}:ie:null}),B=W(()=>V.value?Ae.value.findIndex(oe=>oe.id===V.value):-1),y=W(()=>B.value>0),$=W(()=>B.value>=0&&B.value<Ae.value.length-1),E=()=>{if(y.value){const oe=Ae.value[B.value-1];L(oe)}},_=()=>{if($.value){const oe=Ae.value[B.value+1];L(oe)}},S=oe=>{if(!P.value)return;const ie=K.value.get(oe);if(!ie)return;const ne=P.value,be=ie.getBoundingClientRect(),xe=ne.getBoundingClientRect(),Le=ne.querySelectorAll(".sticky");let ve=0;Le.forEach(Oe=>{ve+=Oe.getBoundingClientRect().height}),ve+=16;const se=be.top<xe.top+ve,ge=be.bottom>xe.bottom;se?ne.scrollBy({top:be.top-xe.top-ve,behavior:"smooth"}):ge&&ne.scrollBy({top:be.bottom-xe.bottom,behavior:"smooth"})},L=oe=>{a("logClick",oe.id),V.value=oe.id},J=(oe,ie)=>{ie?K.value.set(oe,ie):K.value.delete(oe)};pe(V,async oe=>{oe&&(await Ce(),S(oe))}),pe(()=>r.selectedLogId,oe=>{oe&&(V.value=oe)},{immediate:!0});const X=oe=>{V.value=oe},G=async oe=>{await Ce();const ie=K.value.get(oe);if(ie&&P.value){const ne=P.value,be=ie.getBoundingClientRect(),xe=ne.getBoundingClientRect(),Le=ne.querySelector("thead"),ve=ne.querySelector(":scope > div > div.sticky");let se=0;Le&&(se+=Le.getBoundingClientRect().height),ve&&(se+=ve.getBoundingClientRect().height),se+=40;const ge=be.top<xe.top+se,Oe=be.bottom>xe.bottom;ge?ne.scrollBy({top:be.top-xe.top-se,behavior:"smooth"}):Oe&&ne.scrollBy({top:be.bottom-xe.bottom,behavior:"smooth"})}},D=oe=>{if(oe.length===0)return;const ie=new Set(oe);w.value=w.value.filter(ne=>!ie.has(ne.id))},O=f(!1),A=oe=>w.value.some(ie=>ie.id===oe),de=oe=>w.value.find(ie=>ie.id===oe)??null,I=(oe,ie=3e3)=>new Promise(ne=>{const be=Date.now(),xe=pe(w,()=>{w.value.length!==oe&&(xe(),ne(!0))},{deep:!0}),Le=setInterval(()=>{w.value.length!==oe?(clearInterval(Le),xe(),ne(!0)):Date.now()-be>ie&&(clearInterval(Le),xe(),ne(!1))},50)});s({scrollToLog:G,selectLogById:X,removeLogsByIds:D,loadUntilLogId:async oe=>{if(A(oe))return!0;if(!m.value)return!1;O.value=!0;const ie=100,ne=50;try{let be=0;for(;m.value&&!A(oe)&&be<ne;){be++;const xe=w.value.length;if(u.value+=i.value,i.value=ie,await h(),!await I(xe))break}return A(oe)}finally{O.value=!1}},hasLog:A,getLog:de,setLoadingForLog:oe=>{O.value=oe},waitForLogRow:async(oe,ie=2e3)=>{const ne=Date.now();for(;Date.now()-ne<ie;){if(K.value.has(oe))return!0;if(!Ae.value.some(xe=>xe.id===oe)){await Ce(),await new Promise(xe=>setTimeout(xe,16));continue}await Ce(),await new Promise(xe=>setTimeout(xe,16))}return!1}});const $e=async()=>{if(q.value||!m.value||x.value)return;q.value=!0;const oe=P.value?.scrollHeight||0;if(u.value+=i.value,i.value=Vp,await h(),await Ce(),P.value){const ie=P.value.scrollHeight;P.value.scrollTop+=ie-oe}q.value=!1};pe(()=>r.threadId,async oe=>{oe?(g(),k()):g(),u.value=0,i.value=Bt,w.value=[],V.value=null,U.value=!1,b.value=!0},{immediate:!0}),pe(w,async()=>{U.value||await R()},{deep:!0});const fe=()=>{if(!P.value)return;const{scrollTop:oe,scrollHeight:ie,clientHeight:ne}=P.value,be=ie-oe-ne<50;U.value=!be},ke=oe=>{if(!oe.tools_called)return"—";try{const ie=JSON.parse(oe.tools_called);return Array.isArray(ie)?ie.join(", "):oe.tools_called}catch{return oe.tools_called}},we=oe=>oe==null?"—":`$${oe.toFixed(6)}`,Ae=W(()=>{const oe=new Map,ie=new Map;w.value.forEach(xe=>{oe.set(xe.id,xe);const Le=xe.parent_log_id;Le&&(ie.has(Le)||ie.set(Le,[]),ie.get(Le).push(xe))});const ne=[],be=(xe,Le)=>{ne.push({...xe,depth:Le}),(ie.get(xe.id)||[]).forEach(se=>{be(se,Le+1)})};return w.value.forEach(xe=>{xe.parent_log_id||be(xe,0)}),ne});return(oe,ie)=>(o(),l("div",G0,[e("div",X0,[e("div",Y0,[e("div",Q0,[M(H(Qt),{size:18,class:"shrink-0"}),ie[4]||(ie[4]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(o(),Y(St,{key:0,connected:H(v),error:H(c)},null,8,["connected","error"])):T("",!0)]),e("div",ep,[e("button",{onClick:ie[0]||(ie[0]=ne=>a("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[M(H($t),{size:20})])])])]),e("div",{ref_key:"logsScrollContainer",ref:P,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:fe},[t.threadId?H(x)&&u.value===0?(o(),l("div",op,[M(Se)])):H(d)?(o(),l("div",ap," Error loading logs: "+C(H(d)),1)):w.value.length===0?(o(),l("div",lp," No logs yet ")):(o(),l("div",sp,[H(m)?(o(),l("div",np,[e("button",{onClick:$e,disabled:q.value||O.value,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[q.value||O.value?(o(),Y(Se,{key:0,size:"xs"})):T("",!0),O.value?(o(),l("span",ip,"Loading to find log...")):q.value?(o(),l("span",dp,"Loading older logs...")):(o(),l("span",up,"Load previous logs"))],8,rp)])):T("",!0),e("table",cp,[e("thead",{class:Q(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!H(m),"top-[34px]":H(m)}])},[...ie[5]||(ie[5]=[e("tr",null,[e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Prompt"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Model"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Cost"),e("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Tools Called"),e("th",{class:"text-right px-3 py-1.5 text-xs font-semibold"},"Called At")],-1)])],2),e("tbody",null,[(o(!0),l(he,null,ye(Ae.value,ne=>(o(),l("tr",{key:ne.id,ref_for:!0,ref:be=>J(ne.id,be),class:Q(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":F.value,"bg-red-50 dark:bg-red-950/20":ne.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":V.value===ne.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":ne.id===r.selectedLogId||ne.id!==r.selectedLogId&&ne.id===r.hoveredLogId}]),onClick:be=>L(ne),onMouseenter:be=>a("logHover",ne.id),onMouseleave:ie[1]||(ie[1]=be=>a("logHover",null))},[e("td",mp,[e("div",vp,[ne.depth>0?(o(),l("span",hp,"└─")):T("",!0),ne.retry_of_log_id?(o(),Y(H(Ho),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):T("",!0),!ne.is_complete&&!ne.prompt_name?(o(),Y(Se,{key:2,size:"xs"})):(o(),l("span",fp,C(ne.prompt_name||"—"),1))])]),e("td",gp,[e("div",bp,[ne.error?(o(),l("span",xp," ✕ ")):T("",!0),e("span",yp,C(ne.model_name||ne.model),1)])]),e("td",kp,[!ne.is_complete&&!ne.cost_total?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",wp,C(we(ne.cost_total)),1))]),e("td",{class:Q(["px-3 py-2 text-xs",V.value===ne.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!ne.is_complete&&ke(ne)==="—"?(o(),Y(Se,{key:0,size:"xs"})):(o(),l("span",_p,C(ke(ne)),1))],2),e("td",{class:Q(["px-3 py-2 text-right text-xs",V.value===ne.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[M(ct,{timestamp:ne.created_at},null,8,["timestamp"])],2)],42,pp))),128))])])])):(o(),l("div",tp," Select a thread to view logs "))],544),M(Ge,{name:"slide-up",onAfterEnter:ie[3]||(ie[3]=()=>V.value&&S(V.value))},{default:ce(()=>[F.value||O.value&&V.value?(o(),l("div",$p,[e("div",Cp,[O.value&&!F.value?(o(),l("div",Sp,[M(Se),ie[6]||(ie[6]=e("span",{class:"text-sm"},"Loading log...",-1))])):F.value?(o(),Y(K0,{key:1,log:F.value,"thread-id":t.threadId,"has-previous":y.value,"has-next":$.value,onClose:ie[2]||(ie[2]=ne=>V.value=null),onPrevious:E,onNext:_},null,8,["log","thread-id","has-previous","has-next"])):T("",!0),H(N)&&F.value?(o(),l("div",Tp,[M(Se)])):T("",!0)])])):T("",!0)]),_:1})]))}}),Ip=Qe(Mp,[["__scopeId","data-v-30798cba"]]),Lp={class:"space-y-4"},Ep={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},Ap={class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Pp={key:0},jp={key:1},Op={key:1,class:"space-y-4 p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Up={key:3,class:"flex items-center gap-2"},Rp=["onUpdate:modelValue","id"],Dp=["for"],Bp={key:0,class:"text-red-500"},Np={key:5,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-1"},Fp={key:2,class:"p-4 bg-neutral-50 dark:bg-neutral-900 rounded-lg text-center text-sm text-neutral-500"},qp={key:3},zp={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},Hp={class:"text-xs font-medium mb-1 opacity-70"},Wp={class:"text-sm whitespace-pre-wrap"},Jp=["onClick"],Zp={key:1,class:"text-center py-8 text-neutral-500 dark:text-neutral-400 text-sm"},Kp={class:"space-y-2"},Gp={class:"flex items-stretch border border-black dark:border-neutral-300 rounded overflow-hidden bg-white dark:bg-neutral-900"},Xp=["disabled","title"],Yp={class:"flex-1 relative"},Qp=["disabled","title"],e2={class:"text-xs text-neutral-500 dark:text-neutral-400"},t2={class:"flex justify-between"},o2=["disabled"],a2=["disabled"],l2=re({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:s}){const n=t,r=s,a=W(()=>!!n.editThread),u=f(""),i=f(""),p=f({}),m=f([]),x=f(""),d=f(!1),v=f(""),c=f(null),{data:k,isFetching:g,execute:h}=Ue(le("/api/agents"),{immediate:!1}).json(),w=W(()=>k.value?(k.value?.agents||[]).map(S=>({value:S.id,label:S.title})):[]),b=W(()=>!u.value||!k.value?null:(k.value?.agents||[]).find(S=>S.id===u.value)),V=W(()=>b.value&&b.value.type==="ai_human"?"AI":"Side A"),P=W(()=>b.value&&b.value.type==="ai_human"?"Human":"Side B"),{data:U,isFetching:q,execute:K}=Ue(W(()=>b.value?.side_a_system_prompt?le(`/api/prompts/${b.value.side_a_system_prompt}`):""),{immediate:!1}).json(),R=W(()=>{if(!U.value)return null;const _=U.value?.required_schema;if(!_)return null;try{return typeof _=="string"?JSON.parse(_):_}catch{return null}}),j=W(()=>{const _=R.value;return!_||!_.properties?[]:Object.entries(_.properties).map(([S,L])=>({name:S,type:L.type||"string",description:L.description||"",required:_.required?.includes(S)||!1,enum:L.enum}))});pe(u,async _=>{_&&b.value?.side_a_system_prompt?(await K(),p.value={}):p.value={}});const Z=()=>{const _=c.value;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},N=_=>{x.value.trim()&&(m.value.push({id:crypto.randomUUID(),role:_,content:x.value.trim()}),x.value="",setTimeout(()=>Z(),0))},F=_=>{m.value=m.value.filter(S=>S.id!==_)},B=()=>{u.value="",i.value="",p.value={},m.value=[],x.value="",v.value=""},y=()=>{n.editThread&&(u.value=n.editThread.agent_id,i.value=n.editThread.tags?.join(", ")||"")},$=async()=>{if(!u.value){v.value="Please select an agent";return}if(!a.value&&j.value.length>0){for(const _ of j.value)if(_.required&&!p.value[_.name]){v.value=`Please provide ${_.name}`;return}}d.value=!0,v.value="";try{const _=i.value.split(",").map(S=>S.trim()).filter(S=>S.length>0);if(a.value){const S=await fetch(le(`/api/threads/${n.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:_})});if(!S.ok){const L=await S.json();throw new Error(L.error||"Failed to update thread")}r("thread-updated"),B(),r("update:modelValue",!1)}else{const S={agent_id:u.value,tags:_.length>0?_:void 0};m.value.length>0&&(S.initial_messages=m.value.map(G=>({role:G.role,content:G.content}))),Object.keys(p.value).length>0&&(S.data=p.value);const L=await fetch(le("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)});if(!L.ok){const G=await L.json();throw new Error(G.error||"Failed to create thread")}const X=(await L.json()).threadId;if(!X)throw new Error("Thread created but ID not found in response");r("thread-created",X),B(),r("update:modelValue",!1)}}catch(_){console.error(`Error ${a.value?"updating":"creating"} thread:`,_),v.value=_.message||`Failed to ${a.value?"update":"create"} thread`}finally{d.value=!1}},E=()=>{B(),r("update:modelValue",!1)};return pe(()=>n.modelValue,async _=>{_&&(await h(),B(),a.value&&y())}),(_,S)=>(o(),Y(Be,{"model-value":t.modelValue,"onUpdate:modelValue":S[7]||(S[7]=L=>_.$emit("update:modelValue",L)),title:a.value?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:ce(()=>[e("div",t2,[e("button",{onClick:E,type:"button",disabled:d.value,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,o2),e("button",{onClick:$,type:"button",disabled:d.value||H(g),class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[a.value?(o(),l(he,{key:0},[Ve(C(d.value?"Updating...":"Update Thread"),1)],64)):(o(),l(he,{key:1},[Ve(C(d.value?"Creating...":"Create Thread"),1)],64))],8,a2)])]),default:ce(()=>[e("div",Lp,[v.value?(o(),l("div",Ep,C(v.value),1)):T("",!0),e("div",null,[M(_e,{modelValue:u.value,"onUpdate:modelValue":S[0]||(S[0]=L=>u.value=L),label:"Agent",options:w.value,disabled:H(g)||a.value,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),e("p",Ap,[a.value?(o(),l("span",Pp,"Agent cannot be changed after thread creation")):(o(),l("span",jp,"Choose which agent will handle this conversation"))])]),!a.value&&j.value.length>0&&!H(q)?(o(),l("div",Op,[S[8]||(S[8]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),(o(!0),l(he,null,ye(j.value,L=>(o(),l("div",{key:L.name,class:"space-y-2"},[L.enum?(o(),Y(_e,{key:0,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,options:[{value:"",label:"Select..."},...L.enum.map(J=>({value:J,label:J}))],required:L.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):L.type==="string"?(o(),Y(Ee,{key:1,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,placeholder:L.description,required:L.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):L.type==="number"||L.type==="integer"?(o(),Y(Ee,{key:2,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,modelModifiers:{number:!0},label:L.name,placeholder:L.description,type:"number",required:L.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])):L.type==="boolean"?(o(),l("div",Up,[Pe(e("input",{"onUpdate:modelValue":J=>p.value[L.name]=J,type:"checkbox",id:`field-${L.name}`,class:"w-4 h-4"},null,8,Rp),[[Wo,p.value[L.name]]]),e("label",{for:`field-${L.name}`,class:"text-sm"},[Ve(C(L.name)+" ",1),L.required?(o(),l("span",Bp,"*")):T("",!0)],8,Dp)])):(o(),Y(ho,{key:4,modelValue:p.value[L.name],"onUpdate:modelValue":J=>p.value[L.name]=J,label:L.name,placeholder:L.description||`Enter ${L.name} (JSON format)`,required:L.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])),L.description?(o(),l("p",Np,C(L.description),1)):T("",!0)]))),128))])):T("",!0),!a.value&&H(q)?(o(),l("div",Fp," Loading agent requirements... ")):T("",!0),a.value?T("",!0):(o(),l("div",qp,[S[11]||(S[11]=e("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),m.value.length>0?(o(),l("div",zp,[(o(!0),l(he,null,ye(m.value,L=>(o(),l("div",{key:L.id,class:Q(["flex items-start gap-2",{"justify-start":L.role==="assistant","justify-end":L.role==="user"}])},[e("div",{class:Q(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":L.role==="assistant","bg-neutral-200 text-black dark:bg-neutral-800 dark:text-white":L.role==="user"}])},[e("div",Hp,C(L.role==="assistant"?V.value:P.value),1),e("div",Wp,C(L.content),1)],2),e("button",{onClick:J=>F(L.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,Jp)],2))),128))])):(o(),l("div",Zp," No messages yet. Add messages to start the conversation. ")),e("div",Kp,[e("div",Gp,[e("button",{onClick:S[1]||(S[1]=L=>N("assistant")),type:"button",disabled:!x.value.trim(),title:`Add as ${V.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-neutral-300 flex-shrink-0"},[S[9]||(S[9]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(V.value),1)],8,Xp),e("div",Yp,[Pe(e("textarea",{"onUpdate:modelValue":S[2]||(S[2]=L=>x.value=L),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref_key:"textareaRef",ref:c,onInput:Z,onKeydown:[S[3]||(S[3]=yt(Me(L=>N("user"),["meta"]),["enter"])),S[4]||(S[4]=yt(Me(L=>N("user"),["ctrl"]),["enter"]))]},null,544),[[De,x.value]])]),e("button",{onClick:S[5]||(S[5]=L=>N("user")),type:"button",disabled:!x.value.trim(),title:`Add as ${P.value}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-neutral-300 flex-shrink-0"},[S[10]||(S[10]=e("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),e("span",null,C(P.value),1)],8,Qp)]),e("p",e2," Type a message and click "+C(V.value)+" (left) or "+C(P.value)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+C(P.value)+". ",1)])])),e("div",null,[M(Ee,{modelValue:i.value,"onUpdate:modelValue":S[6]||(S[6]=L=>i.value=L),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),S[12]||(S[12]=e("p",{class:"mt-1 text-xs text-neutral-500 dark:text-neutral-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"]))}}),s2={class:"flex h-full overflow-hidden"},n2={key:0,class:"flex flex-col items-center p-4"},r2={key:0,class:"flex flex-col items-center p-4"},i2={key:0,class:"flex flex-col items-center p-4"},Nt=re({__name:"ThreadsView",setup(t){const s=We(),n=ot(),r=f(typeof s.params.id=="string"?s.params.id:null),a=f({threadList:!1,messages:!1,logs:!1}),u=f(!1),i=f(null),p=f(null),{thread:m}=Ct(W(()=>r.value)),x=f(null),d=f(null),v=f(null),c=f(null),k=f(null),g=$=>{c.value=$,k.value=$},h=$=>{if(c.value=$,!$){k.value=null;return}k.value=$;const E=w.value,_=b.value;if(!E||!_||E.hasWorkblockForLogId($))return;let S=$;const L=10;for(let J=0;J<L&&S;J++){const X=_.getLog(S);if(!X)break;const G=X.parent_log_id;if(!G)break;if(E.hasWorkblockForLogId(G)){k.value=G;return}S=G}},w=f(null),b=f(null);pe(()=>s.params.id,$=>{r.value=typeof $=="string"?$:null,x.value=null,d.value=null,v.value=null});const V=$=>{n.push(`/threads/${$}`)},P=$=>{window.location.href="/threads"},U=()=>{m.value&&(i.value=m.value,u.value=!0)},q=()=>{i.value=null,u.value=!0},K=$=>{p.value?.refetch(),n.push(`/threads/${$}`)},R=()=>{window.location.reload()},j=$=>{a.value[$]=!a.value[$]},Z=async($,E)=>{if(x.value=$,!E){d.value=null,v.value=null;return}const _=b.value;if(!_){d.value=E,v.value=E;return}const S=!_.hasLog(E);if(S&&_.setLoadingForLog(!0),d.value=E,v.value=E,S&&!await _.loadUntilLogId(E)){console.warn(`Could not find log ${E} after loading all available logs`),_.setLoadingForLog(!1);return}if(!await _.waitForLogRow(E)){console.warn(`Log row ${E} not rendered in time`);return}_.scrollToLog(E),_.selectLogById(E)},N=$=>{d.value=$,v.value=$,x.value=null;const E=w.value,_=b.value;if(!E||!_)return;let S=E.scrollToLogId($);if(S)return;let L=$;const J=10;for(let X=0;X<J&&L;X++){const G=_.getLog(L);if(!G)break;const D=G.parent_log_id;if(!D)break;if(S=E.scrollToLogId(D),S){v.value=D;return}L=D}},F=$=>{$&&(d.value=$)},B=$=>{b.value?.removeLogsByIds($)},y=$=>{$&&!r.value&&n.push(`/threads/${$}`)};return($,E)=>(o(),l("div",s2,[e("div",{class:Q([a.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[a.value.threadList?(o(),l("div",n2,[e("button",{onClick:E[0]||(E[0]=_=>j("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[M(H(Kt),{size:20})])])):(o(),Y(Ar,{key:1,ref_key:"threadListPaneRef",ref:p,"selected-thread-id":r.value,onSelectThread:V,onCollapse:E[1]||(E[1]=_=>j("threadList")),onCreateThread:q,onThreadsLoaded:y},null,8,["selected-thread-id"]))],2),e("div",{class:Q([a.value.messages?"w-[60px]":"w-[380px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[a.value.messages?(o(),l("div",r2,[e("button",{onClick:E[2]||(E[2]=_=>j("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[M(H(Yt),{size:20})])])):r.value?(o(),Y(H(ha),{key:1,"thread-id":r.value,preload:!0,live:!0,"include-silent":!0},{default:ce(()=>[M(Dt,{ref_key:"messagesPaneRef",ref:w,"thread-id":r.value,"selected-message-id":x.value,"selected-log-id":v.value,"hovered-log-id":k.value,onCollapse:E[3]||(E[3]=_=>j("messages")),onMessageClick:Z,onMessageHover:g,onThreadDeleted:P,onEditThread:U,onLogsDeleted:B},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):a.value.messages?T("",!0):(o(),Y(Dt,{key:2,ref_key:"messagesPaneRef",ref:w,"thread-id":null,"selected-message-id":x.value,"selected-log-id":v.value,"hovered-log-id":k.value,onCollapse:E[4]||(E[4]=_=>j("messages")),onMessageClick:Z,onMessageHover:g,onThreadDeleted:P,onEditThread:U,onLogsDeleted:B},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",{class:Q([a.value.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200"])},[a.value.logs?(o(),l("div",i2,[e("button",{onClick:E[5]||(E[5]=_=>j("logs")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Logs pane"},[M(H(Qt),{size:20})])])):(o(),Y(Ip,{key:1,ref_key:"logsPaneRef",ref:b,"thread-id":r.value,"selected-log-id":d.value,"hovered-log-id":c.value,onCollapse:E[6]||(E[6]=_=>j("logs")),onLogClick:N,onLogHover:h,onLogsLoaded:F},null,8,["thread-id","selected-log-id","hovered-log-id"]))],2),M(l2,{modelValue:u.value,"onUpdate:modelValue":E[7]||(E[7]=_=>u.value=_),"edit-thread":i.value,onThreadCreated:K,onThreadUpdated:R},null,8,["modelValue","edit-thread"])]))}}),d2=re({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(t,{expose:s,emit:n}){const r=n,a=f([]),u=f(!1),i=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(d,v)=>d||v.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],p=[{icon:"edit",label:"Edit",handler:d=>r("edit",d)},{icon:"delete",label:"Delete",handler:async d=>{await x(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],m=async()=>{u.value=!0;try{const d=await fetch(le("/api/prompts"));if(d.ok){const v=await d.json();a.value=v.prompts||[]}}catch(d){console.error("Error fetching prompts:",d)}finally{u.value=!1}},x=async d=>{try{const v=await fetch(le(`/api/prompts/${d.id}`),{method:"DELETE"});if(v.ok)await m();else{const c=await v.json();alert(c.error||"Failed to delete prompt")}}catch(v){console.error("Error deleting prompt:",v),alert("Failed to delete prompt")}};return Te(()=>{m()}),s({refresh:m}),(d,v)=>(o(),l("div",null,[M(He,{columns:i,data:a.value,actions:p,loading:u.value,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])]))}}),u2={class:"space-y-4"},c2={key:0,class:"mt-1 text-sm text-red-500"},p2={key:1,class:"mt-1 text-sm text-neutral-500 dark:text-neutral-400"},m2={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},v2=["value"],h2=re({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:s}){const n=t,r=s,a=f(""),u=p=>{let m=p.replace(/[^a-zA-Z0-9\s_]/g,"");return m=m.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),m?/^[a-z][a-z0-9_]*$/.test(m)?a.value="":a.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":a.value="Name is required",m},i=p=>{const m=u(p);r("update:name",m)};return pe(()=>n.name,p=>{p&&u(p)},{immediate:!0}),(p,m)=>(o(),l("div",u2,[e("div",null,[M(Ee,{"model-value":t.name,"onUpdate:modelValue":i,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),a.value?(o(),l("p",c2,C(a.value),1)):t.name?(o(),l("p",p2,[m[1]||(m[1]=Ve(" Will be saved as: ",-1)),e("code",m2,C(t.name),1)])):T("",!0)]),e("div",null,[m[2]||(m[2]=e("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),e("textarea",{value:t.toolDescription,onInput:m[0]||(m[0]=x=>r("update:toolDescription",x.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,v2)])]))}}),f2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",_t="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",g2="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",Ft="/agents/assets/img/meta.svg",b2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",x2="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",y2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",k2="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",w2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",_2="/agents/assets/img/moonshotai.svg",$2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",C2="/agents/assets/img/zai.svg",S2="/agents/assets/img/zai.svg",T2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",go="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function V2(t){const s=at();return s==="/"?t.replace("/agents/","/"):t.replace("/agents/",`${s}/`)}const M2={anthropic:f2,openai:_t,"openai-sdk":_t,google:g2,meta:Ft,"meta-llama":Ft,nvidia:b2,alibaba:x2,deepseek:y2,qwen:k2,minimax:w2,moonshotai:_2,"x-ai":$2,"z-ai":C2,zai:S2,exaone:T2,openrouter:go},I2=new Proxy(M2,{get(t,s){const n=t[s];return n?V2(n):void 0}});function L2(t){if(t&&t.includes("/"))return t.split("/")[0].toLowerCase()}function pt(t){return I2[t.toLowerCase()]}function tt(t,s){const n=L2(t);if(n){const r=pt(n);if(r)return r}if(s)return pt(s)}const E2={class:"space-y-4"},A2=re({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:s}){const n=s,r=f([]),a=f(!1),u=W(()=>r.value.map(p=>({value:p.id,label:p.name,description:p.model||p.provider,icon:tt(p.model||p.name,p.provider_id||p.provider)}))),i=async()=>{a.value=!0;try{const p=await fetch(le("/api/models"));if(p.ok){const m=await p.json();r.value=m.models||[]}}catch(p){console.error("Error fetching models:",p)}finally{a.value=!1}};return Te(()=>{i()}),(p,m)=>(o(),l("div",E2,[M(_e,{"model-value":t.modelValue,"onUpdate:modelValue":m[0]||(m[0]=x=>n("update:modelValue",x)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:a.value},null,8,["model-value","options","loading"])]))}}),P2=["data-property-id","data-nested-property-id"],j2={class:"p-3 space-y-3"},O2={class:"flex items-start gap-2"},U2={key:0,class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400 mt-2"},R2={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},D2={class:"flex items-center gap-2 mt-2"},B2=["disabled"],N2={key:0,class:"ml-6"},F2={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},q2={class:"flex items-center justify-between mb-2"},z2=["disabled"],H2={key:0,class:"space-y-1"},W2=["onClick","disabled"],J2={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Z2={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},K2={class:"space-y-2"},G2={class:"flex items-center justify-between"},X2=["disabled"],Y2={class:"space-y-2"},Q2={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},em={key:0,class:"mb-2"},tm=["disabled"],om={key:1,class:"space-y-2"},am=re({__name:"PropertyEditor",props:qe({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:qe(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:s}){const n=t,r=s,a=Xe(t,"modelValue"),u=f(!1);f();const i=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],p=W(()=>["object","array","enum","anyOf"].includes(a.value.type));pe(()=>a.value.type,async(g,h)=>{if(["object","array","enum","anyOf"].includes(g)&&(u.value=!0,g==="anyOf"&&!a.value.anyOf&&(a.value.anyOf=[]),g==="object"&&!a.value.properties&&(a.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),g==="array"&&!a.value.items&&(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),g==="enum"&&!a.value.enum&&(a.value.enum=["value1"])),h!==void 0){await Ce();const w=n.isNested?`[data-nested-property-id="${n.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${n.propertyId}"] input[placeholder="Description"]`,b=document.querySelector(w);b&&b.focus()}});const m=g=>{g.shiftKey&&a.value.type==="object"&&a.value.properties?c():r("add-top-level")},x=()=>{a.value.items||(a.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},d=()=>{a.value.enum||(a.value.enum=[]),a.value.enum.push(`value${a.value.enum.length+1}`)},v=g=>{a.value.enum&&a.value.enum.splice(g,1)},c=async()=>{const g={id:crypto.randomUUID(),name:a.value.type==="anyOf"?"":`property${(a.value.properties?.length||a.value.anyOf?.length||0)+1}`,type:"string",description:""};a.value.type==="anyOf"?(a.value.anyOf||(a.value.anyOf=[]),a.value.anyOf.push(g)):(a.value.properties||(a.value.properties=[]),a.value.properties.push(g)),await Ce();const h=document.querySelector(`[data-nested-property-id="${g.id}"] input[placeholder="Property name"]`);h&&(h.focus(),h.select())},k=g=>{a.value.type==="anyOf"&&a.value.anyOf?a.value.anyOf=a.value.anyOf.filter(h=>h.id!==g):a.value.properties&&(a.value.properties=a.value.properties.filter(h=>h.id!==g))};return(g,h)=>{const w=Jo("PropertyEditor",!0);return o(),l("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:Q(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",j2,[e("div",O2,[t.enableDrag?(o(),l("div",U2,[...h[10]||(h[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):T("",!0),e("div",R2,[M(Ee,{modelValue:a.value.name,"onUpdate:modelValue":h[0]||(h[0]=b=>a.value.name=b),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),M(_e,{modelValue:a.value.type,"onUpdate:modelValue":h[1]||(h[1]=b=>a.value.type=b),options:i,disabled:t.disabled},null,8,["modelValue","disabled"]),M(Ee,{modelValue:a.value.description,"onUpdate:modelValue":h[2]||(h[2]=b=>a.value.description=b),placeholder:"Description",disabled:t.disabled,onKeydown:h[3]||(h[3]=yt(Me(b=>m(b),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",D2,[p.value?(o(),l("button",{key:0,onClick:h[4]||(h[4]=b=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(o(),l("svg",{class:Q(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...h[11]||(h[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):T("",!0),e("button",{onClick:h[5]||(h[5]=b=>g.$emit("remove")),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...h[12]||(h[12]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,B2)])]),u.value&&p.value?(o(),l("div",N2,[a.value.type==="enum"?(o(),l("div",F2,[e("div",q2,[h[13]||(h[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:d,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,z2)]),a.value.enum?(o(),l("div",H2,[(o(!0),l(he,null,ye(a.value.enum,(b,V)=>(o(),l("div",{key:V,class:"flex items-center gap-2"},[M(Ee,{modelValue:a.value.enum[V],"onUpdate:modelValue":P=>a.value.enum[V]=P,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:P=>v(V),type:"button",disabled:t.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...h[14]||(h[14]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,W2)]))),128))])):T("",!0)])):T("",!0),a.value.type==="object"||a.value.type==="anyOf"?(o(),l("div",J2,[e("h4",Z2,C(a.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",K2,[e("div",G2,[e("button",{onClick:c,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add "+C(a.value.type==="anyOf"?"Type Option":"Property"),9,X2)]),e("div",Y2,[(o(!0),l(he,null,ye(a.value.type==="anyOf"?a.value.anyOf:a.value.properties,(b,V)=>(o(),Y(w,{key:b.id,modelValue:(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[V],"onUpdate:modelValue":P=>(a.value.type==="anyOf"?a.value.anyOf:a.value.properties)[V]=P,"property-id":b.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:P=>k(b.id),onAddTopLevel:h[6]||(h[6]=P=>r("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):T("",!0),a.value.type==="array"?(o(),l("div",Q2,[h[15]||(h[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),a.value.items?T("",!0):(o(),l("div",em,[e("button",{onClick:x,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,tm)])),a.value.items?(o(),l("div",om,[M(w,{modelValue:a.value.items,"onUpdate:modelValue":h[7]||(h[7]=b=>a.value.items=b),"property-id":a.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:h[8]||(h[8]=b=>a.value.items=null),onAddTopLevel:h[9]||(h[9]=b=>r("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):T("",!0)])):T("",!0)])):T("",!0)])],10,P2)}}}),lm={class:"space-y-2"},sm=["disabled"],nm=re({__name:"PropertyList",props:qe({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:qe(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:s,emit:n}){const r=t,a=n,u=Xe(t,"modelValue"),i=f();let p=!1;Te(async()=>{}),Ne(()=>{});const m=async()=>{if(p)return;p=!0;const d={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,d],await Ce();const v=r.parentId?`[data-nested-property-id="${d.id}"]`:`[data-property-id="${d.id}"]`,c=document.querySelector(`${v} input[placeholder="Property name"]`);c&&(c.focus(),c.select()),a("add-property"),p=!1},x=d=>{u.value=u.value.filter(v=>v.id!==d)};return s({addProperty:m}),(d,v)=>(o(),l("div",lm,[e("div",{ref_key:"dragAreaRef",ref:i,class:"space-y-2"},[(o(!0),l(he,null,ye(u.value,c=>(o(),Y(am,{key:c.id,modelValue:u.value[u.value.indexOf(c)],"onUpdate:modelValue":k=>u.value[u.value.indexOf(c)]=k,"property-id":c.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:k=>x(c.id),onAddTopLevel:v[0]||(v[0]=k=>d.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:Q(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:m,type:"button",disabled:t.disabled,class:Q(t.isNested?"px-2 py-1 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-neutral-50 dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800 text-neutral-700 dark:text-neutral-300 rounded transition-colors disabled:opacity-50 border border-dashed border-neutral-300 dark:border-neutral-700")},[...v[1]||(v[1]=[e("span",{class:"flex items-center justify-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),Ve(" Add Property ")],-1)])],10,sm)],2)]))}}),rm={class:"space-y-4"},im={key:0,class:"flex items-center justify-between"},dm={class:"text-sm font-medium"},um={key:0,class:"text-red-500"},cm={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},pm={key:0,class:"flex items-center justify-between mb-2"},mm={key:1,class:"text-center py-12"},vm=["disabled"],hm={class:"mt-4 text-center"},fm={key:3,class:"mt-4"},gm={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},bm={class:"text-xs leading-relaxed"},xm=["innerHTML"],bo=re({__name:"JSONSchemaInput",props:qe({label:{},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const s=Xe(t,"modelValue"),n=f([]),r=f(),a=f(!1),u=()=>{if(s.value?.properties){const g=[];s.value.required;for(const[h,w]of Object.entries(s.value.properties)){const b=w,V={id:crypto.randomUUID(),name:h,type:b.type||"string",description:b.description||""};b.enum&&(V.enum=b.enum),b.anyOf&&(V.type="anyOf",V.anyOf=i(b.anyOf)),b.type==="array"&&b.items&&(V.items=p(b.items)),b.type==="object"&&b.properties&&(V.properties=m(b.properties,b.required||[])),g.push(V)}n.value=g}},i=g=>g.map(h=>typeof h=="object"&&h.type?{id:crypto.randomUUID(),name:"",type:h.type,description:h.description||"",properties:h.properties?m(h.properties,h.required||[]):void 0,items:h.items?p(h.items):void 0,enum:h.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),p=g=>{const h={id:crypto.randomUUID(),name:"",type:g.type||"string",description:g.description||""};return g.enum&&(h.enum=g.enum),g.anyOf&&(h.type="anyOf",h.anyOf=i(g.anyOf)),g.type==="array"&&g.items&&(h.items=p(g.items)),g.type==="object"&&g.properties&&(h.properties=m(g.properties,g.required||[])),h},m=(g,h)=>{const w=[];for(const[b,V]of Object.entries(g)){const P=V,U={id:crypto.randomUUID(),name:b,type:P.type||"string",description:P.description||""};P.enum&&(U.enum=P.enum),P.anyOf&&(U.type="anyOf",U.anyOf=i(P.anyOf)),P.type==="array"&&P.items&&(U.items=p(P.items)),P.type==="object"&&P.properties&&(U.properties=m(P.properties,P.required||[])),w.push(U)}return w};u();const x=()=>{const g={type:"object",properties:{},required:[],additionalProperties:!1},{properties:h}=v(n.value);g.properties=h,g.required=Object.keys(h),s.value=g},d=g=>{const h={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(g.type==="enum"&&g.enum&&(h.enum=g.enum,h.type="string"),g.type==="anyOf"&&g.anyOf&&(delete h.type,h.anyOf=g.anyOf.map(d)),g.type==="object"&&g.properties){const{properties:w}=v(g.properties);h.properties=w,h.required=Object.keys(w),h.additionalProperties=!1}return g.type==="array"&&g.items&&(h.items=d(g.items)),h},v=g=>{const h={},w=[];for(const b of g){const V={type:b.type==="anyOf"?void 0:b.type,description:b.description};if(w.push(b.name),b.type==="enum"&&b.enum&&(V.enum=b.enum,V.type="string"),b.type==="anyOf"&&b.anyOf&&b.anyOf.length>0&&(delete V.type,V.anyOf=b.anyOf.map(d)),b.type==="array"&&b.items&&(V.items=d(b.items)),b.type==="object"&&b.properties){const{properties:P}=v(b.properties);V.properties=P,V.required=Object.keys(P),V.additionalProperties=!1}h[b.name]=V}return{properties:h,required:w}};pe(n,()=>{x()},{deep:!0}),x();const c=W(()=>JSON.stringify(s.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),k=async()=>{if(n.value.length===0){const g={id:crypto.randomUUID(),name:"property1",type:"string",description:""};n.value.push(g),await Ce();const h=document.querySelector(`[data-property-id="${g.id}"] input[placeholder="Property name"]`);h&&(h.focus(),h.select())}else r.value&&r.value.addProperty()};return(g,h)=>(o(),l("div",rm,[t.label?(o(),l("div",im,[e("label",dm,[Ve(C(t.label)+" ",1),t.required?(o(),l("span",um,"*")):T("",!0)])])):T("",!0),e("div",cm,[n.value.length>0?(o(),l("div",pm,[...h[2]||(h[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):T("",!0),n.value.length===0?(o(),l("div",mm,[h[4]||(h[4]=e("div",{class:"mb-4"},[e("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),h[5]||(h[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:k,type:"button",disabled:t.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...h[3]||(h[3]=[e("span",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),Ve(" Add Property ")],-1)])],8,vm)])):T("",!0),n.value.length>0?(o(),Y(nm,{key:2,ref_key:"propertyListRef",ref:r,modelValue:n.value,"onUpdate:modelValue":h[0]||(h[0]=w=>n.value=w),disabled:t.disabled,onAddProperty:k},null,8,["modelValue","disabled"])):T("",!0),e("div",hm,[e("button",{onClick:h[1]||(h[1]=w=>a.value=!a.value),type:"button",class:"text-xs text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:underline transition-colors"},C(a.value?"Hide":"Show")+" JSON Schema ",1)]),a.value?(o(),l("div",fm,[e("div",gm,[e("pre",bm,[e("code",{class:"font-mono",innerHTML:c.value},null,8,xm)])])])):T("",!0)])]))}}),ym={class:"prompt-input-container relative"},km=["contenteditable","data-placeholder"],wm={class:"bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},_m={key:0,class:"p-3 text-sm text-neutral-500"},$m={key:1,class:"p-3 text-sm text-neutral-500"},Cm={key:2,class:"max-h-[220px] overflow-y-auto"},Sm=["onClick"],Tm={class:"font-medium flex items-center gap-2"},Vm=["title"],Mm={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Im={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Lm={class:"text-xs mt-1"},Em=re({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(t,{emit:s}){const n=t,r=s,a=f(),u=f(),i=Zo({segments:n.modelValue&&n.modelValue.length?n.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),m=y=>y.type==="string"?"":`@${y.type==="variable"?y.label||y.value:y.label||y.id}`,x=()=>{const y=window.getSelection();if(!y||!y.rangeCount||!a.value)return null;const $=y.getRangeAt(0);let E=0;const _=Array.from(a.value.childNodes);for(let S=0;S<_.length;S++){const L=_[S];if(L===$.startContainer||L.contains?.($.startContainer)){if(L.nodeType===Node.TEXT_NODE)return{segmentIndex:E,offset:$.startOffset};if(L.nodeType===Node.ELEMENT_NODE&&L.classList?.contains("prompt-tag"))return{segmentIndex:E,offset:0}}(L.nodeType===Node.TEXT_NODE||L.nodeType===Node.ELEMENT_NODE&&L.classList?.contains("prompt-tag"))&&E++}return{segmentIndex:0,offset:0}},d=()=>{if(!a.value)return;const y=i.segments.map($=>{if($.type==="string")return($.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const E=$._uid||($._uid=p()),_=m($),S=$.type==="variable"?{type:"variable",value:$.value,label:$.label,schema:$.schema,meta:$.meta}:{type:"prompt",id:$.id,label:$.label,schema:$.schema,meta:$.meta},L=encodeURIComponent(JSON.stringify(S)),J=$.type==="prompt"&&$.meta&&!$.meta.isValid,X=J?'<span class="prompt-tag-warning" title="'+($.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${J?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${E}" data-segment="${L}">${_}${X}</span>`}}).join("");a.value.innerHTML=y||"<br>"},v=()=>{const y=[];for(const $ of i.segments)$.type==="string"&&y.length>0&&y[y.length-1].type==="string"?y[y.length-1].value+=$.value:y.push($);i.segments=y.length?y:[{type:"string",value:""}]},c=y=>{const $=y.dataset.segmentUid;let E=i.segments.find(_=>_._uid===$);if(!E){const _=y.dataset.segment;if(_)try{const S=JSON.parse(decodeURIComponent(_));S&&(S.type==="variable"||S.type==="prompt")&&(E=S.type==="variable"?{type:"variable",value:S.value,label:S.label,schema:S.schema,meta:S.meta,_uid:$}:{type:"prompt",id:S.id,label:S.label,schema:S.schema,meta:S.meta,_uid:$})}catch{}}return E||null},k=y=>{const $=y.target;if($.classList?.contains("prompt-tag")){const E=c($);E&&r("segment-click",E,y)}},g=y=>{if(i.isComposing)return;const $=y.target,E=[];let _="";const S=()=>{_.length>0&&(E.push({type:"string",value:_}),_="")},L=D=>{if(D.nodeType===Node.TEXT_NODE){const O=(D.textContent||"").replace(/\u00A0/g," ");_+=O;return}if(D.nodeType===Node.ELEMENT_NODE){const O=D;if(O.classList?.contains("prompt-tag")){S();const de=c(O);de&&E.push(de);return}if(O.tagName==="BR"){_+=`
15
15
  `;return}const A=Array.from(O.childNodes);for(const de of A)L(de);(O.tagName==="DIV"||O.tagName==="P"||O.tagName==="LI")&&O.nextSibling&&(_+=`
16
16
  `);return}},J=Array.from($.childNodes);for(const D of J)L(D);S();const G=E.some(D=>D.type!=="string")?E:[{type:"string",value:($.innerText||"").replace(/\r\n/g,`
17
17
  `)}];i.segments=G.length?G:[{type:"string",value:""}],v(),h(),N()},h=()=>{const y=window.getSelection();if(!y||!y.rangeCount||!a.value)return;const $=y.getRangeAt(0);if($.startContainer.nodeType!==Node.TEXT_NODE){i.dialogOpen&&b();return}const _=$.startContainer.textContent||"",S=$.startOffset;if(S>0&&_[S-1]==="@")i.atTriggerIndex=S-1,i.searchQuery="",w(),U("");else if(i.dialogOpen&&i.atTriggerIndex>=0)if($.startContainer.nodeType===Node.TEXT_NODE){const L=$.startContainer.textContent||"",J=$.startOffset;if(J<=i.atTriggerIndex){b();return}const X=L.substring(0,J);if(X.length>i.atTriggerIndex&&X[i.atTriggerIndex]==="@"){const G=X.substring(i.atTriggerIndex+1);G.includes(" ")||G.includes(`